@objectstack/console 9.9.1 → 9.10.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (77) hide show
  1. package/dist/assets/{AiPendingActionsPage-BI-QQNee.js → AiPendingActionsPage-BDYUc-T8.js} +1 -1
  2. package/dist/assets/{ApiConsolePage-B6QExly9.js → ApiConsolePage-BJB9Xho6.js} +1 -1
  3. package/dist/assets/{AppDocsIndex-S-ilhz4W.js → AppDocsIndex-Cj0DpA3d.js} +1 -1
  4. package/dist/assets/{AppManagementPage-JgLQ-wXj.js → AppManagementPage-BzjUDLx3.js} +1 -1
  5. package/dist/assets/{ApprovalsInboxPage-CAyznoRP.js → ApprovalsInboxPage-Dym3zM3t.js} +1 -1
  6. package/dist/assets/{AuditLogPage-BeEqEy4g.js → AuditLogPage-BJh3wy1L.js} +1 -1
  7. package/dist/assets/{ComponentNavView-DmALsugj.js → ComponentNavView-BFSklq8D.js} +1 -1
  8. package/dist/assets/{ConsoleFloatingChatbot-D13eK4M8.js → ConsoleFloatingChatbot-_UeVODsx.js} +1 -1
  9. package/dist/assets/{DashboardView-P--eXDC-.js → DashboardView-kL9_gMzd.js} +1 -1
  10. package/dist/assets/{DashboardWidgetInspector-VPDtQEP_.js → DashboardWidgetInspector-BN8Yy27Q.js} +1 -1
  11. package/dist/assets/{DeveloperHubPage-DbQwi1EV.js → DeveloperHubPage-CB5nkyun.js} +1 -1
  12. package/dist/assets/{FlowRunsPage-CCS9xNVc.js → FlowRunsPage-65yB_BWO.js} +1 -1
  13. package/dist/assets/{IntegrationsPage-DU_wvj4-.js → IntegrationsPage-8M_88h2y.js} +2 -2
  14. package/dist/assets/{InterfaceListPage-B3jzgT27.js → InterfaceListPage-CBomrdcf.js} +1 -1
  15. package/dist/assets/{ManagedByBadge-Difq_L_A.js → ManagedByBadge-Bmg77Q4v.js} +1 -1
  16. package/dist/assets/{MarketplaceAccessDenied-CXUE33gy.js → MarketplaceAccessDenied-CX0RbkOJ.js} +1 -1
  17. package/dist/assets/{MarketplaceInstalledPage-CBfcARvX.js → MarketplaceInstalledPage-BYXiUCpz.js} +1 -1
  18. package/dist/assets/{MarketplacePackagePage-DOZgrTZo.js → MarketplacePackagePage-C8yVjW5r.js} +2 -2
  19. package/dist/assets/{MarketplacePage-BT-WkhAG.js → MarketplacePage-pVW-NfrG.js} +1 -1
  20. package/dist/assets/{MetadataInspector-BRICMLXW.js → MetadataInspector-CACgSTc7.js} +1 -1
  21. package/dist/assets/{MetadataProvider-Bja7m8Gt.js → MetadataProvider-Dh20h6BN.js} +1 -1
  22. package/dist/assets/{PageView-My4nP5w4.js → PageView-D388xYQA.js} +1 -1
  23. package/dist/assets/{ProfilePage-BAtKSxuK.js → ProfilePage-SXmEEOn3.js} +1 -1
  24. package/dist/assets/{PublicFormsPage-CcRFrTQC.js → PublicFormsPage-aXes2XrW.js} +1 -1
  25. package/dist/assets/{RecordDetailView-CMIRy42W.js → RecordDetailView-DIiHv2mR.js} +1 -1
  26. package/dist/assets/{RecordFormPage-BUfFijzM.js → RecordFormPage-C052nJig.js} +1 -1
  27. package/dist/assets/ReportDefaultInspector-CjR-PcBn.js +1 -0
  28. package/dist/assets/{ReportView-DSrtPxzA.js → ReportView-M_mx8mgW.js} +1 -1
  29. package/dist/assets/{RuntimeDraftBar-B2fJIAhv.js → RuntimeDraftBar-DTf-DIfT.js} +1 -1
  30. package/dist/assets/{SearchResultsPage-C7i-b3gn.js → SearchResultsPage-DGuFKZit.js} +1 -1
  31. package/dist/assets/{SettingsHub-BLEC_8Ao.js → SettingsHub-eYWWi8O5.js} +1 -1
  32. package/dist/assets/{SettingsView-BEjR60F6.js → SettingsView-Cq3IKOhI.js} +1 -1
  33. package/dist/assets/{SystemHubPage-DWGnZfF0.js → SystemHubPage-6FccxnKY.js} +1 -1
  34. package/dist/assets/{highlighted-body-OFNGDK62-DiT7C6XW.js → highlighted-body-OFNGDK62-CKMBhexn.js} +1 -1
  35. package/dist/assets/index-A8r_lURn.js +4 -0
  36. package/dist/assets/index-BGyrRTzt.css +2 -0
  37. package/dist/assets/{mergeServerFields-zZ2r6yTA.js → mergeServerFields-CMIOI8QD.js} +2 -2
  38. package/dist/assets/mermaid-GHXKKRXX-C3g3SOag.js +1 -0
  39. package/dist/assets/metadata-admin-ORqaeHUJ.js +19 -0
  40. package/dist/assets/plugin-calendar-Czocnijo.js +1 -0
  41. package/dist/assets/{plugin-charts-AMObsZz3.js → plugin-charts-dCyWH9k8.js} +1 -1
  42. package/dist/assets/{plugin-chatbot-Ch8YIyYL.js → plugin-chatbot-BpAQS7-q.js} +6 -6
  43. package/dist/assets/plugin-dashboard-CjtE0zwv.js +5 -0
  44. package/dist/assets/{plugin-form-DXCdD2d-.js → plugin-form-Dzz6GAZM.js} +1 -1
  45. package/dist/assets/plugin-gantt-BedjcmIc.js +23 -0
  46. package/dist/assets/plugin-grid-BqmF7p-H.js +6 -0
  47. package/dist/assets/{plugin-kanban-DOsTOpJz.js → plugin-kanban-Dq0xJjXt.js} +1 -1
  48. package/dist/assets/{plugin-map-Bid9UXOR.js → plugin-map-DG62gl97.js} +1 -1
  49. package/dist/assets/{plugin-markdown-BUQOG31j.js → plugin-markdown-BL0QvMCD.js} +1 -1
  50. package/dist/assets/{plugin-report-FxG9jOvy.js → plugin-report-DckNGNq6.js} +1 -1
  51. package/dist/assets/{plugin-timeline-DDrFKEb8.js → plugin-timeline-dBrX3lS3.js} +1 -1
  52. package/dist/assets/plugin-view-DCPYomdU.js +1 -0
  53. package/dist/assets/plugins-views-B-EGcBP2.js +4 -0
  54. package/dist/assets/{resolveActionParams-xmwfLvud.js → resolveActionParams-B_7wSkli.js} +1 -1
  55. package/dist/assets/{skeletons-B_SNEnMn.js → skeletons-BK7w4pLE.js} +1 -1
  56. package/dist/assets/src-9qM7N8MR.js +2 -0
  57. package/dist/assets/{src-DbxuLwqh.js → src-Czx03pos.js} +1 -1
  58. package/dist/assets/{types-CosU35As.js → types-C2_UYDEK.js} +1 -1
  59. package/dist/assets/{ui-components-CrPYFyEM.js → ui-components-NS_7__gn.js} +7 -7
  60. package/dist/assets/{ui-layout-DAWxaQvy.js → ui-layout-BdKOzi1L.js} +1 -1
  61. package/dist/assets/{useActionModal-DsVCm46J.js → useActionModal-BE61500N.js} +1 -1
  62. package/dist/assets/{useReconcileOnError-D6sIYKrb.js → useReconcileOnError-Cvd01WQv.js} +1 -1
  63. package/dist/assets/{utils-bipVuqQL.js → utils-29quoGQV.js} +1 -1
  64. package/dist/index.html +3 -3
  65. package/package.json +1 -1
  66. package/dist/assets/ReportDefaultInspector-C8gR3RMr.js +0 -1
  67. package/dist/assets/index-BgnAjV6_.js +0 -4
  68. package/dist/assets/index-CJe1zUD0.css +0 -2
  69. package/dist/assets/mermaid-GHXKKRXX-CK-9EMhD.js +0 -1
  70. package/dist/assets/metadata-admin-BgoJzjrj.js +0 -19
  71. package/dist/assets/plugin-calendar-DQC9zdKq.js +0 -1
  72. package/dist/assets/plugin-dashboard-C7fxXXeO.js +0 -5
  73. package/dist/assets/plugin-gantt-BHmpu6VX.js +0 -23
  74. package/dist/assets/plugin-grid-boi_rkH3.js +0 -6
  75. package/dist/assets/plugin-view-D58aYgqA.js +0 -1
  76. package/dist/assets/plugins-views-DUKPQNs8.js +0 -4
  77. package/dist/assets/src-DXFkWHTV.js +0 -2
@@ -0,0 +1,4 @@
1
+ import{o as e,r as t}from"./rolldown-runtime-CMxvf4Kt.js";import{_ as n,f as r,r as i,t as a}from"./vendor-react-DR370ovB.js";import{n as o,t as s}from"./infrastructure-CJNwTVno.js";import{B as c,D as l,E as u,F as d,H as f,M as p,R as m,W as h,_ as g,f as _,ft as v,g as y,h as b,ht as x,pt as S,r as C,ut as ee,z as w}from"./framework-BLEk-ou3.js";import{$n as T,$s as E,$t as D,At as O,Bi as k,Bo as A,Bt as j,C as M,Co as N,Di as P,Ds as F,Ea as I,Ei as te,Es as ne,Fo as re,Ft as ie,G as ae,Gn as L,Ht as oe,I as se,Io as R,Is as z,Ji as ce,Jn as le,K as B,Ki as ue,Lt as V,M as de,Ma as H,Mt as U,N as fe,Na as pe,No as me,Nt as W,Oa as G,Oi as he,Os as ge,Ot as K,P as q,Po as _e,Pr as ve,Pt as ye,Qi as be,Qo as xe,Rr as Se,Rs as Ce,Rt as we,S as Te,Sa as Ee,Si as De,Sr as Oe,Ts as ke,Ui as Ae,Un as je,Ut as Me,Vr as Ne,Vt as Pe,Wn as Fe,Wt as Ie,X as J,Xa as Le,Xn as Re,Xs as ze,Ya as Be,Yo as Ve,Za as He,Zn as Ue,Zs as We,_c as Ge,_r as Ke,ac as qe,ai as Je,ao as Ye,ar as Xe,at as Ze,bo as Qe,br as $e,ci as et,cn as tt,cr as nt,d as Y,di as rt,dr as it,ec as at,en as ot,er as st,fc as ct,fr as lt,fs as ut,g as dt,gc as ft,gn as pt,gr as mt,hr as X,ic as ht,ir as gt,it as _t,ja as vt,jt as yt,ki as bt,kt as xt,la as St,lr as Ct,m as wt,na as Tt,ni as Et,nn as Dt,nr as Ot,nt as kt,oc as At,or as jt,pc as Z,pr as Mt,q as Nt,qa as Pt,qn as Ft,ra as It,ro as Lt,rr as Rt,rt as zt,sc as Bt,si as Vt,sn as Ht,sr as Ut,tn as Wt,tr as Gt,ui as Kt,un as qt,ur as Jt,vi as Yt,xi as Xt,yi as Zt,za as Qt}from"./ui-components-NS_7__gn.js";import{a as $t}from"./plugin-grid-BqmF7p-H.js";var Q=e(n(),1),$=a(),en={grid:(0,$.jsx)(Ye,{className:`h-4 w-4`}),kanban:(0,$.jsx)(Qt,{className:`h-4 w-4`}),gallery:(0,$.jsx)(He,{className:`h-4 w-4`}),calendar:(0,$.jsx)(Ce,{className:`h-4 w-4`}),timeline:(0,$.jsx)(ct,{className:`h-4 w-4`}),gantt:(0,$.jsx)(et,{className:`h-4 w-4`}),map:(0,$.jsx)(I,{className:`h-4 w-4`}),chart:(0,$.jsx)(z,{className:`h-4 w-4`})},tn={grid:`Grid`,kanban:`Kanban`,gallery:`Gallery`,calendar:`Calendar`,timeline:`Timeline`,gantt:`Gantt`,map:`Map`,chart:`Chart`},nn=({currentView:e,availableViews:t=[`grid`,`kanban`],onViewChange:n,className:r,animated:i=!0})=>{let[a,o]=Q.useState(!1),s=Q.useCallback(t=>{o(!1),t!==e&&(i&&typeof document<`u`&&`startViewTransition`in document?document.startViewTransition(()=>n(t)):n(t))},[i,e,n]);return(0,$.jsxs)(D,{open:a,onOpenChange:o,children:[(0,$.jsx)(Wt,{asChild:!0,children:(0,$.jsxs)(`button`,{type:`button`,"data-testid":`view-switcher-dropdown`,"aria-label":tn[e],className:Z(`inline-flex items-center gap-1.5 h-7 px-2 rounded-md text-xs font-medium transition-colors oui-view-switcher`,a?`text-foreground bg-muted`:`text-muted-foreground hover:text-foreground`,r),children:[en[e],(0,$.jsx)(`span`,{className:`hidden sm:inline-block`,children:tn[e]}),(0,$.jsx)(F,{className:`h-3 w-3 opacity-60`})]})}),(0,$.jsx)(ot,{align:`end`,className:`w-44 p-1`,children:t.map(t=>(0,$.jsxs)(`button`,{type:`button`,onClick:()=>s(t),"data-state":t===e?`on`:`off`,className:Z(`flex w-full items-center gap-2 rounded-sm px-2 py-1.5 text-xs transition-colors hover:bg-muted`,t===e?`text-foreground font-medium`:`text-muted-foreground`),children:[en[t],(0,$.jsx)(`span`,{className:`flex-1 text-left`,children:tn[t]}),t===e&&(0,$.jsx)(ge,{className:`h-3.5 w-3.5`})]},t))})]})};function rn(e){return e?Ke[e.split(`-`).map(e=>e.charAt(0).toUpperCase()+e.slice(1)).join(``)]??null:null}function an(e){return e.filter(e=>e.pinned||e.visible!==`false`&&e.visible!==!1).sort((e,t)=>(e.order??0)-(t.order??0))}var on=({tabs:e,activeTab:t,onTabChange:n,className:r})=>{let i=Q.useMemo(()=>an(e),[e]),a=Q.useMemo(()=>i.find(e=>e.isDefault)?.name??i[0]?.name,[i]),[o,s]=Q.useState(a),c=t??o,l=Q.useCallback(e=>{s(e.name),n?.(e)},[n]);return i.length===0?null:(0,$.jsx)(`div`,{className:Z(`px-2 sm:px-4 py-1 flex items-center gap-0.5 bg-background`,r),"data-testid":`view-tabs`,role:`tablist`,children:i.map(e=>{let t=rn(e.icon),n=c===e.name;return(0,$.jsxs)(X,{variant:`ghost`,size:`sm`,className:Z(`h-7 px-2.5 py-1 text-xs rounded-md transition-colors duration-150`,n?`font-medium text-foreground bg-muted`:`text-muted-foreground hover:text-foreground hover:bg-transparent`),"data-testid":`view-tab-${e.name}`,role:`tab`,"aria-selected":n,onClick:()=>l(e),children:[t&&(0,$.jsx)(t,{className:`h-3 w-3 mr-1.5`}),e.label]},e.name)})})},sn=({tabs:e,activeTab:t,onTabChange:n,className:r})=>{let i=Q.useMemo(()=>an(e),[e]),a=Q.useMemo(()=>i.find(e=>e.isDefault)?.name??i[0]?.name,[i]),[o,s]=Q.useState(a),c=t??o,l=Q.useMemo(()=>i.find(e=>e.name===c)??i[0],[i,c]),u=Q.useCallback(e=>{s(e.name),n?.(e)},[n]);if(i.length===0)return null;let d=rn(l?.icon);return(0,$.jsx)(`div`,{className:Z(`px-2 py-1`,r),"data-testid":`view-tabs-select`,children:(0,$.jsxs)(Ht,{children:[(0,$.jsx)(pt,{asChild:!0,children:(0,$.jsxs)(X,{variant:`ghost`,size:`sm`,className:`h-7 px-2 text-xs font-medium text-foreground gap-1.5 max-w-[60vw] truncate`,"aria-label":`Switch view`,children:[d&&(0,$.jsx)(d,{className:`h-3.5 w-3.5 shrink-0`}),(0,$.jsx)(`span`,{className:`truncate`,children:l?.label??``}),(0,$.jsx)(F,{className:`h-3.5 w-3.5 shrink-0 text-muted-foreground`})]})}),(0,$.jsx)(tt,{align:`start`,className:`w-56 max-h-72 overflow-y-auto`,children:i.map(e=>{let t=rn(e.icon);return(0,$.jsxs)(qt,{onClick:()=>u(e),className:Z(`text-sm`,c===e.name&&`font-medium bg-muted`),"data-testid":`view-tab-select-${e.name}`,children:[t&&(0,$.jsx)(t,{className:`h-3.5 w-3.5 mr-2 shrink-0`}),(0,$.jsx)(`span`,{className:`truncate`,children:e.label})]},e.name)})})]})})};function cn({title:e,badge:t,onClear:n,clearLabel:r,defaultOpen:i=!0,children:a}){let[o,s]=Q.useState(i);return(0,$.jsxs)(`div`,{className:`border-b last:border-b-0`,children:[(0,$.jsxs)(`div`,{className:`flex items-center justify-between px-3 py-2`,children:[(0,$.jsxs)(`button`,{type:`button`,onClick:()=>s(e=>!e),className:`flex items-center gap-1.5 text-xs font-medium text-foreground/80 hover:text-foreground`,children:[(0,$.jsx)(F,{className:Z(`h-3.5 w-3.5 transition-transform`,!o&&`-rotate-90`)}),e,typeof t==`number`&&t>0&&(0,$.jsx)(`span`,{className:`ml-1 inline-flex h-4 min-w-[16px] items-center justify-center rounded-full bg-primary/10 px-1 text-[10px] text-primary tabular-nums`,children:t})]}),n&&(0,$.jsx)(`button`,{type:`button`,onClick:n,className:`text-[11px] text-muted-foreground hover:text-foreground`,children:r})]}),o&&(0,$.jsx)(`div`,{className:`px-3 pb-3`,children:a})]})}function ln(e){let{t,allFields:n,showGroup:r,groupingConfig:i,setGroupingConfig:a,showColor:o,rowColorConfig:s,setRowColorConfig:c,showDensity:l,density:u,showHideFields:d,hiddenFields:f,updateHiddenFields:p}=e,[m,h]=Q.useState(!1),g=[!!i?.fields?.length,!!s?.field,u&&u.mode!==`compact`,(f?.size??0)>0].filter(Boolean).length,_=u?.mode===`compact`?te:u?.mode===`comfortable`?P:he,v=t(`list.viewSettings`,{defaultValue:`View settings`});return(0,$.jsxs)(D,{open:m,onOpenChange:h,children:[(0,$.jsx)(Wt,{asChild:!0,children:(0,$.jsxs)(X,{variant:`ghost`,size:`sm`,"aria-label":v,title:v,className:Z(`h-7 px-2 text-muted-foreground hover:text-primary text-xs transition-colors duration-150`,g>0&&`text-foreground font-medium`),"data-testid":`view-settings-trigger`,children:[(0,$.jsx)(Zt,{className:`h-3.5 w-3.5 sm:mr-1.5`}),(0,$.jsx)(`span`,{className:`hidden sm:inline`,children:v}),g>0&&(0,$.jsx)(`span`,{className:`ml-1 flex h-4 min-w-[16px] items-center justify-center text-[10px] font-medium text-muted-foreground tabular-nums`,children:g})]})}),(0,$.jsxs)(ot,{align:`end`,className:`w-80 p-0`,"data-testid":`view-settings-content`,children:[(0,$.jsxs)(`div`,{className:`px-3 py-2 border-b`,children:[(0,$.jsx)(`div`,{className:`text-sm font-semibold`,children:v}),(0,$.jsx)(`div`,{className:`text-[11px] text-muted-foreground`,children:t(`list.viewSettingsHint`,{defaultValue:`Grouping, color, density, and visible fields.`})})]}),r&&a&&(0,$.jsx)(cn,{title:t(`list.group`,{defaultValue:`Group`}),badge:i?.fields?.length||0,onClear:i?()=>a(void 0):void 0,clearLabel:t(`list.clear`,{defaultValue:`Clear`}),children:(0,$.jsx)(q,{value:i,fieldOptions:n.map(e=>({value:e.name,label:e.label||e.name})),maxLevels:3,labels:{addGroup:t(`list.addGroup`,`Add group field`),collapseTitle:t(`list.collapsedByDefault`,`Collapsed by default`),removeTitle:t(`list.removeGroup`,`Remove`)},onChange:e=>a(e)})}),o&&c&&(0,$.jsxs)(cn,{title:t(`list.color`,{defaultValue:`Row color`}),onClear:s?()=>c(void 0):void 0,clearLabel:t(`list.clear`,{defaultValue:`Clear`}),defaultOpen:!!s,children:[(0,$.jsx)(`label`,{className:`block text-[11px] text-muted-foreground mb-1`,children:t(`list.colorByField`,{defaultValue:`Color by field`})}),(0,$.jsxs)(`select`,{className:`w-full h-8 rounded border border-input bg-background px-2 text-xs`,value:s?.field||``,onChange:e=>{let t=e.target.value;c(t?{field:t,colors:s?.colors||{}}:void 0)},"data-testid":`color-field-select`,children:[(0,$.jsx)(`option`,{value:``,children:t(`list.none`,{defaultValue:`None`})}),n.map(e=>(0,$.jsx)(`option`,{value:e.name,children:e.label||e.name},e.name))]})]}),l&&u&&(0,$.jsx)(cn,{title:t(`grid.toolbar.densityMode`,{defaultValue:`Density`}),defaultOpen:u.mode!==`compact`,children:(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsxs)(X,{variant:`outline`,size:`sm`,className:`h-7 gap-1.5`,onClick:u.cycle,"data-testid":`view-settings-density-cycle`,children:[(0,$.jsx)(_,{className:`h-3.5 w-3.5`}),(0,$.jsx)(`span`,{className:`text-xs`,children:u.mode===`compact`?t(`grid.toolbar.densityCompact`,{defaultValue:`Compact`}):u.mode===`comfortable`?t(`grid.toolbar.densityComfortable`,{defaultValue:`Comfortable`}):t(`grid.toolbar.densitySpacious`,{defaultValue:`Spacious`})})]}),(0,$.jsx)(`span`,{className:`text-[11px] text-muted-foreground`,children:t(`grid.toolbar.densityCycleShortHint`,{defaultValue:`Click to cycle`})})]})}),d&&f&&p&&(0,$.jsx)(cn,{title:t(`list.hideFieldsTitle`,{defaultValue:`Hide fields`}),badge:f.size,onClear:f.size>0?()=>p(new Set):void 0,clearLabel:t(`list.showAll`,{defaultValue:`Show all`}),defaultOpen:f.size>0,children:(0,$.jsx)(`div`,{className:`max-h-48 overflow-y-auto space-y-0.5`,children:n.map(e=>(0,$.jsxs)(`label`,{className:`flex items-center gap-2 text-xs py-1 px-1 rounded hover:bg-muted cursor-pointer`,children:[(0,$.jsx)(`input`,{type:`checkbox`,checked:!f.has(e.name),onChange:()=>{let t=new Set(f);t.has(e.name)?t.delete(e.name):t.add(e.name),p(t)},className:`rounded border-input`}),(0,$.jsx)(`span`,{className:`truncate`,children:e.label||e.name})]},e.name))})})]})]})}function un(){try{let{t:e}=C(),t=e(`common.more`);return!t||t===`common.more`?`More`:t}catch{return`More`}}var dn=new Set([`lookup`,`master_detail`,`user`,`owner`]);function fn(e){switch(e){case void 0:case`equals`:case`eq`:return`=`;case`not_equals`:case`ne`:case`neq`:return`!=`;case`gte`:return`>=`;case`lte`:return`<=`;case`gt`:return`>`;case`lt`:return`<`;case`not_in`:case`nin`:return`not in`;default:return e}}function pn(e){return(e||[]).filter(e=>e&&(e.id||e.name)).map(e=>({id:e.id??e.name,label:typeof e.label==`string`?e.label:e.label?.toString?.()??e.id??e.name,filters:Array.isArray(e.filters)?e.filters:Array.isArray(e.filter)?e.filter.filter(e=>e&&typeof e.field==`string`).map(e=>[e.field,fn(e.operator),e.value]):[],default:e.default??e.isDefault}))}function mn({config:e,objectDef:t,data:n=[],onFilterChange:r,maxVisible:i,className:a,initialSelections:o,onSelectionsChange:s}){switch(e.element){case`dropdown`:return(0,$.jsx)(gn,{fields:e.fields||[],objectDef:t,data:n,onFilterChange:r,maxVisible:i,className:a,initialSelections:o,onSelectionsChange:s});case`tabs`:return(0,$.jsx)(_n,{tabs:pn(e.tabs||[]),showAllRecords:e.showAllRecords!==!1,allowAddTab:e.allowAddTab,onFilterChange:r,className:a,initialTab:typeof o?._tab?.[0]==`string`?o._tab[0]:void 0,onSelectionsChange:s});case`toggle`:return(0,$.jsx)(vn,{fields:e.fields||[],onFilterChange:r,className:a});default:return null}}function hn(e,t,n,r){return e.map(e=>{let i=e.options?[...e.options]:[],a=e.type,o,s,c;if(t?.fields){let n=Array.isArray(t.fields)?t.fields.find(t=>t.name===e.field):t.fields[e.field];n&&(a||=n.type,o=n.reference_to??n.reference,s=n.display_field??n.reference_field,c=n.id_field,i.length===0&&n.options&&(i=Array.isArray(n.options)?n.options.map(e=>({label:e.label??String(e.value??e),value:e.value??e,color:e.color})):Object.entries(n.options).map(([e,t])=>({label:t?.label||e,value:e,color:t?.color}))))}i.length===0&&a===`boolean`&&(i=[{label:`True`,value:!0},{label:`False`,value:!1}]),e.showCount&&n.length>0&&(i=i.map(t=>({...t,count:n.filter(n=>n[e.field]===t.value).length})));let l=e.label;return r?.objectName&&(i=r.translateOptions(r.objectName,e.field,i),l=r.fieldLabel(r.objectName,e.field,e.label||e.field)),{...e,label:l,type:a,options:i,referenceTo:o,displayField:s,idField:c}})}function gn({fields:e,objectDef:t,data:n,onFilterChange:r,maxVisible:i,className:a,initialSelections:o,onSelectionsChange:s}){let{fieldLabel:c,translateOptions:l}=Ge(),u=un(),d=t?.name,[f,p]=Q.useState(()=>{let t={};return e.forEach(e=>{e.defaultValues&&e.defaultValues.length>0&&(t[e.field]=e.defaultValues);let n=o?.[e.field];n&&n.length>0&&(t[e.field]=n)}),t}),m=Q.useRef({}),h=Q.useMemo(()=>hn(e,t,n,{objectName:d,fieldLabel:c,translateOptions:l}).map(e=>{if(!e.showCount)return e;if((f[e.field]||[]).length===0)return m.current[e.field]=new Map(e.options.map(e=>[String(e.value),e.count??0])),e;let t=m.current[e.field];return t?{...e,options:e.options.map(e=>({...e,count:t.get(String(e.value))??e.count}))}:e}),[e,t,n,d,c,l,f]),g=Q.useCallback(e=>{r(Object.entries(e).filter(([,e])=>e.length>0).map(([e,t])=>[e,`in`,t]))},[r]),_=(e,t)=>{let n={...f,[e]:t};p(n),g(n),s?.(n)};Q.useEffect(()=>{let e=f,t={},n=!1;for(let[r,i]of Object.entries(e)){let e=h.find(e=>e.field===r),a=i.map(t=>{if(!e||typeof t!=`string`)return t;let n=e.options.find(e=>String(e.value)===t);return n&&n.value!==t?n.value:e.type===`boolean`&&(t===`true`||t===`false`)?t===`true`:t});t[r]=a,a.some((e,t)=>e!==i[t])&&(n=!0)}n&&(p(t),e=t),Object.values(e).some(e=>e.length>0)&&g(e)},[]);let v=i!==void 0&&i<h.length?h.slice(0,i):h,y=i!==void 0&&i<h.length?h.slice(i):[],b=e=>{let t=f[e.field]||[],n=t.length>0,r=dn.has(e.type||``)&&e.options.length===0&&(e.referenceTo||e.type===`user`||e.type===`owner`),i=r?`w-72`:`w-56`;return(0,$.jsxs)(D,{children:[(0,$.jsx)(Wt,{asChild:!0,children:(0,$.jsxs)(`button`,{"data-testid":`filter-badge-${e.field}`,className:Z(`inline-flex items-center gap-1 h-7 px-2 text-xs transition-colors shrink-0 rounded-md`,n?`text-foreground font-medium`:`text-muted-foreground hover:text-foreground`),children:[(0,$.jsx)(`span`,{className:`truncate max-w-[100px]`,children:e.label||e.field}),n&&(0,$.jsx)(`span`,{className:`text-[10px] text-muted-foreground/80 tabular-nums`,children:t.length}),n?(0,$.jsx)(Oe,{className:`h-3 w-3 opacity-60 hover:opacity-100`,"data-testid":`filter-clear-${e.field}`,onClick:t=>{t.stopPropagation(),_(e.field,[])}}):(0,$.jsx)(F,{className:`h-3 w-3 opacity-60`})]})}),(0,$.jsx)(ot,{align:`start`,className:Z(i,`p-2`),children:r?(0,$.jsx)(`div`,{"data-testid":`filter-lookup-${e.field}`,children:(0,$.jsx)(Nt,{field:{value:e.field,label:e.label||e.field,type:e.type,referenceTo:e.referenceTo,displayField:e.displayField,idField:e.idField},value:t,multiple:!0,onChange:t=>{let n=Array.isArray(t)?t:t==null||t===``?[]:[t];_(e.field,n)}})}):(0,$.jsx)(`div`,{className:`max-h-60 overflow-y-auto space-y-0.5`,"data-testid":`filter-options-${e.field}`,children:e.options.length===0?(0,$.jsx)(`div`,{className:`px-2 py-3 text-center text-xs text-muted-foreground`,children:`No options`}):e.options.map(n=>(0,$.jsxs)(`label`,{className:Z(`flex items-center gap-2 text-sm py-1.5 px-2 rounded cursor-pointer`,t.includes(n.value)?`bg-primary/5 text-primary`:`hover:bg-muted`),children:[(0,$.jsx)(`input`,{type:`checkbox`,checked:t.includes(n.value),onChange:()=>{let r=t.includes(n.value)?t.filter(e=>e!==n.value):[...t,n.value];_(e.field,r)},className:`rounded border-input`}),n.color&&(0,$.jsx)(`span`,{className:`h-2.5 w-2.5 rounded-full shrink-0`,style:{backgroundColor:n.color}}),(0,$.jsx)(`span`,{className:`truncate flex-1`,children:n.label}),n.count!==void 0&&(0,$.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:n.count})]},String(n.value)))})})]},e.field)};return(0,$.jsx)(`div`,{className:Z(`flex items-center gap-0.5 overflow-x-auto`,a),"data-testid":`user-filters-dropdown`,children:h.length===0?(0,$.jsx)(`span`,{className:`text-xs text-muted-foreground`,"data-testid":`user-filters-empty`,children:`No filter fields`}):(0,$.jsxs)($.Fragment,{children:[v.map(b),y.length>0&&(0,$.jsxs)(D,{children:[(0,$.jsx)(Wt,{asChild:!0,children:(0,$.jsxs)(`button`,{"data-testid":`user-filters-more`,className:`inline-flex items-center gap-1 h-7 px-2 text-xs text-muted-foreground hover:text-foreground transition-colors shrink-0 rounded-md`,children:[(0,$.jsx)(`span`,{children:u}),(0,$.jsx)(`span`,{className:`text-[10px] text-muted-foreground/80 tabular-nums`,children:y.length}),(0,$.jsx)(F,{className:`h-3 w-3 opacity-60`})]})}),(0,$.jsx)(ot,{align:`start`,className:`w-64 p-2`,"data-testid":`user-filters-more-content`,children:(0,$.jsx)(`div`,{className:`space-y-1`,children:y.map(b)})})]})]})})}function _n({tabs:e,showAllRecords:t,allowAddTab:n,onFilterChange:r,className:i,initialTab:a,onSelectionsChange:o}){let[s,c]=Q.useState(()=>a&&(a===`__all__`||e.some(e=>e.id===a))?a:e.find(e=>e.default)?.id||(t?`__all__`:e[0]?.id||``)),l=Q.useCallback(t=>{c(t),r(t===`__all__`?[]:e.find(e=>e.id===t)?.filters||[]),o?.({_tab:[t]})},[e,r,o]),u=Q.useMemo(()=>{let n=[...e];return t&&n.push({id:`__all__`,label:`All records`,filters:[]}),n},[e,t]);return Q.useEffect(()=>{if(s&&s!==`__all__`){let t=e.find(e=>e.id===s);t&&r(t.filters||[])}},[]),(0,$.jsxs)(`div`,{className:Z(`flex items-center gap-0.5 overflow-x-auto`,i),"data-testid":`user-filters-tabs`,children:[u.map(e=>(0,$.jsx)(`button`,{"data-testid":`filter-tab-${e.id}`,onClick:()=>l(e.id),className:Z(`inline-flex items-center h-7 px-3 text-xs font-medium rounded-md transition-colors shrink-0`,s===e.id?`bg-primary text-primary-foreground`:`text-muted-foreground hover:text-foreground hover:bg-muted`),children:e.label},e.id)),n&&(0,$.jsx)(`button`,{className:`inline-flex items-center justify-center h-7 w-7 rounded-md text-muted-foreground hover:text-foreground hover:bg-muted shrink-0`,"data-testid":`filter-tab-add`,title:`Add filter tab`,children:(0,$.jsx)(Ae,{className:`h-3.5 w-3.5`})})]})}function vn({fields:e,onFilterChange:t,className:n}){let[r,i]=Q.useState(()=>{let t=new Set;return e.forEach(e=>{e.defaultValues&&e.defaultValues.length>0&&t.add(e.field)}),t}),a=Q.useCallback(n=>{t(Array.from(n).map(t=>{let n=e.find(e=>e.field===t);return n?.defaultValues?[t,`in`,n.defaultValues]:[t,`!=`,null]}))},[e,t]),o=e=>{i(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),a(n),n})};return Q.useEffect(()=>{r.size>0&&a(r)},[]),(0,$.jsx)(`div`,{className:Z(`flex items-center gap-1 overflow-x-auto`,n),"data-testid":`user-filters-toggle`,children:e.map(e=>(0,$.jsx)(X,{variant:r.has(e.field)?`default`:`outline`,size:`sm`,className:`h-7 px-3 text-xs shrink-0`,"data-testid":`filter-toggle-${e.field}`,onClick:()=>o(e.field),children:e.label||e.field},e.field))})}function yn(e){switch(e){case`equals`:case`eq`:return`=`;case`notEquals`:case`not_equals`:case`ne`:case`neq`:return`!=`;case`contains`:return`contains`;case`notContains`:case`notcontains`:return`notcontains`;case`greaterThan`:case`gt`:return`>`;case`greaterOrEqual`:case`gte`:return`>=`;case`lessThan`:case`lt`:return`<`;case`lessOrEqual`:case`lte`:return`<=`;case`in`:return`in`;case`notIn`:case`not_in`:case`nin`:return`not in`;case`before`:return`<`;case`after`:return`>`;default:return e}}function bn(e){if(!Array.isArray(e)||e.length<3)return e;let[t,n,r]=e;return typeof t==`string`&&(t===`and`||t===`or`)?[t,...e.slice(1).map(e=>Array.isArray(e)?bn(e):e)]:n===`in`&&Array.isArray(r)?r.length===0?[]:r.length===1?[t,`=`,r[0]]:[`or`,...r.map(e=>[t,`=`,e])]:n===`not in`&&Array.isArray(r)?r.length===0?[]:r.length===1?[t,`!=`,r[0]]:[`and`,...r.map(e=>[t,`!=`,e])]:e}function xn(e){return e.replace(/_/g,` `).replace(/\b\w/g,e=>e.toUpperCase())}function Sn(e){return!Array.isArray(e)||e.length===0?[]:e.map(e=>Array.isArray(e)?bn(e):e).filter(e=>Array.isArray(e)&&e.length>0)}function Cn(e){if(!e||!e.conditions||e.conditions.length===0)return[];let t=Sn(e.conditions.map(e=>e.operator===`isEmpty`?[e.field,`=`,null]:e.operator===`isNotEmpty`?[e.field,`!=`,null]:[e.field,yn(e.operator),e.value]));return t.length===0?[]:t.length===1?t[0]:[e.logic,...t]}var wn={"list.recordCount":`{{count}} records`,"list.recordCountOne":`{{count}} record`,"list.noItems":`No items found`,"list.noItemsMessage":`There are no records to display. Try adjusting your filters or adding new data.`,"list.firstRunTitle":`Nothing here yet`,"list.firstRunMessage":`Create your first record to get started.`,"list.noMatches":`No matching records`,"list.noMatchesMessage":`No records match your current filters or search. Try adjusting or clearing them.`,"list.loading":`Loading records…`,"list.loadErrorTitle":`Couldn’t load records`,"list.loadErrorMessage":`Something went wrong while loading this data. Check your connection and try again.`,"list.retry":`Retry`,"list.search":`Search`,"list.filter":`Filter`,"list.filterRecords":`Filter Records`,"list.sort":`Sort`,"list.sortRecords":`Sort Records`,"list.group":`Group`,"list.groupBy":`Group By`,"list.export":`Export`,"list.exportAs":`Export as {{format}}`,"list.color":`Color`,"list.rowColor":`Row Color`,"list.colorByField":`Color by field`,"list.clear":`Clear`,"list.none":`None`,"list.hideFields":`Hide fields`,"list.showAll":`Show all`,"list.pullToRefresh":`Pull to refresh`,"list.refreshing":`Refreshing…`,"list.dataLimitReached":`Showing first {{limit}} records. More data may be available.`,"list.addRecord":`Add record`,"list.tabs":`Tabs`,"list.allRecords":`All Records`,"list.share":`Share`,"list.print":`Print`,"list.hideFieldsTitle":`Hide Fields`,"table.rowsPerPage":`Rows per page`,"grid.toolbar.densityMode":`Density`,"grid.toolbar.densityCompact":`Compact`,"grid.toolbar.densityComfortable":`Comfortable`,"grid.toolbar.densitySpacious":`Spacious`,"grid.toolbar.densityCycleHint":`{{label}} (click to cycle)`,"grid.toolbar.densityCycleShortHint":`Click to cycle`,"list.viewSettings":`View settings`,"list.viewSettingsHint":`Grouping, color, density, and visible fields.`},Tn=(e,t,n)=>n,En=(e,t)=>{let n=wn[e]||e;if(t)for(let[e,r]of Object.entries(t))n=n.replace(`{{${e}}}`,String(r));return n};function Dn(){try{let e=C();return e.t(`list.recordCount`)===`list.recordCount`?{t:En}:{t:e.t}}catch{return{t:En}}}function On(){try{let{fieldLabel:e,actionLabel:t}=ft();return{fieldLabel:e,actionLabel:t}}catch{return{fieldLabel:Tn,actionLabel:void 0}}}var kn=Q.forwardRef(({schema:e,className:t,onViewChange:n,onFilterChange:r,onSortChange:i,onSearchChange:a,onHiddenFieldsChange:s,onColumnStateChange:l,onRowClick:u,showViewSwitcher:f,userFilterSelections:m,onUserFilterSelectionsChange:h,...g},_)=>{let y=f??e?.showViewSwitcher??!1,{t:b}=Dn(),{fieldLabel:x,actionLabel:C}=On(),{translateOptions:w}=Ge(),T=Q.useMemo(()=>e.viewType&&e.viewType!==`list`?e:{...e,viewType:`grid`},[e]),E=Q.useCallback((e,t)=>T.objectName?x(T.objectName,e,t):t,[T.objectName,x]),O=Q.useCallback(e=>{let t=xn(e);return T.objectName&&typeof C==`function`?C(T.objectName,e,t):t},[T.objectName,C]),j=Q.useMemo(()=>{let e=T.userActions,t=T.addRecord?.enabled===!0&&e?.addRecordForm!==!1;return{showSearch:e?.search===void 0?T.showSearch!==!1:e.search,showSort:e?.sort===void 0?T.showSort!==!1:e.sort,showFilters:e?.filter===void 0?T.showFilters!==!1:e.filter,showDensity:e?.rowHeight===void 0?T.showDensity!==!1:e.rowHeight,showHideFields:T.showHideFields===!0,showGroup:T.showGroup!==!1,showColor:T.showColor===!0,compactToolbar:T.compactToolbar===!0,showAddRecord:t,addRecordPosition:T.addRecord?.position===`bottom`?`bottom`:`top`}},[T.userActions,T.showSearch,T.showSort,T.showFilters,T.showDensity,T.showHideFields,T.showGroup,T.showColor,T.compactToolbar,T.addRecord,T.userActions?.addRecordForm]),[M,N]=Q.useState(T.viewType),[F,I]=Q.useState(``),[ne,ie]=Q.useState(!1),[L,oe]=Q.useState(!1),[R,z]=Q.useState(()=>T.sort&&T.sort.length>0?T.sort.map(e=>{if(typeof e==`string`){let t=e.trim().split(/\s+/);return{id:crypto.randomUUID(),field:t[0],order:t[1]?.toLowerCase()===`desc`?`desc`:`asc`}}return{id:crypto.randomUUID(),field:e.field,order:e.order||`asc`}}):[]),ce=Q.useMemo(()=>JSON.stringify(T.sort||[]),[T.sort]);Q.useEffect(()=>{T.sort&&T.sort.length>0?z(T.sort.map(e=>{if(typeof e==`string`){let t=e.trim().split(/\s+/);return{id:crypto.randomUUID(),field:t[0],order:t[1]?.toLowerCase()===`desc`?`desc`:`asc`}}return{id:crypto.randomUUID(),field:e.field,order:e.order||`asc`}})):z([])},[ce]);let[le,ue]=Q.useState(!1),[V,H]=Q.useState({id:`root`,logic:`and`,conditions:[]}),[U,pe]=Q.useState(()=>{if(!T.tabs||T.tabs.length===0)return;let e=m?._tab?.[0];return typeof e==`string`&&T.tabs.some(t=>t.name===e)?e:T.tabs.find(e=>e.isDefault)?.name??T.tabs[0]?.name});Q.useEffect(()=>{let e=T.tabs?.find(e=>e.name===U);if(e&&Array.isArray(e.filter)&&e.filter.length>0){let t=e.filter.filter(e=>e&&typeof e.field==`string`).map(e=>({field:e.field,operator:e.operator??`equals`,value:e.value}));H({id:`tab-filter-${e.name}`,logic:`and`,conditions:t})}},[]);let me=Q.useCallback(e=>{if(pe(e.name),h?.({_tab:[e.name]}),e.filter){let t=Array.isArray(e.filter)?e.filter.filter(e=>e&&typeof e.field==`string`).map(e=>({field:e.field,operator:e.operator??`equals`,value:e.value})):e.filter.conditions||[],n={id:`tab-filter-${e.name}`,logic:!Array.isArray(e.filter)&&e.filter.logic||`and`,conditions:t};H(n),r?.(n)}else{let e={id:`root`,logic:`and`,conditions:[]};H(e),r?.(e)}},[r,h]),W=g.dataSource,[G,ge]=Q.useState([]),[K,_e]=Q.useState(null),[ve,ye]=Q.useState(()=>!(Array.isArray(T.data)||T.data&&typeof T.data==`object`&&T.data.provider===`value`&&Array.isArray(T.data.items))),[be,xe]=Q.useState(null),[Ce,we]=Q.useState(!1),[Te,Ee]=Q.useState(0),[ke,je]=Q.useState(!1);Q.useImperativeHandle(_,()=>({refresh:()=>Ee(e=>e+1)}),[]),Q.useEffect(()=>{if(!(!W?.onMutation||!T.objectName||T.refreshTrigger))return W.onMutation(e=>{e.resource===T.objectName&&Ee(e=>e+1)})},[W,T.objectName,T.refreshTrigger]);let[Me,Pe]=Q.useState(void 0),Fe=Me??T.pagination?.pageSize??100,Ie=Q.useMemo(()=>{if(T.grouping?.fields?.length)return T.grouping;let e=typeof T.groupBy==`string`?T.groupBy.trim():``,t=typeof T.groupBy2==`string`?T.groupBy2.trim():``,n=[];return e&&n.push({field:e,order:`asc`,collapsed:!1}),t&&t!==e&&n.push({field:t,order:`asc`,collapsed:!1}),n.length>0?{fields:n}:void 0},[T.grouping,T.groupBy,T.groupBy2]),[J,Le]=Q.useState(Ie),[Re,ze]=Q.useState(!1),Ve=Q.useRef(Ie);Q.useEffect(()=>{Ve.current!==Ie&&(Ve.current=Ie,Le(Ie))},[Ie]);let[He,Ue]=Q.useState(T.rowColor),[We,qe]=Q.useState(!1),[Je,Ye]=Q.useState([]),Xe=Q.useRef(0),[Ze,Qe]=Q.useState(()=>{let e=new Set;return T.quickFilters?.forEach(t=>{let n=v(t);n.defaultActive&&e.add(n.id)}),e}),[$e,et]=Q.useState([]),tt=Q.useMemo(()=>{let e=T.userFilters;if(!e)return;if(e.element===`tabs`||e.fields&&e.fields.length>0||!be?.fields)return e;let t=new Set([`select`,`multi-select`,`boolean`]),n=[],r=Array.isArray(be.fields)?be.fields.map(e=>[e.name,e]):Object.entries(be.fields);for(let[e,i]of r)(t.has(i.type)||i.options&&!i.type)&&n.push({field:e,label:E(e,i.label||e),type:i.type===`boolean`?`boolean`:i.type===`multi-select`?`multi-select`:`select`});return n.length===0?e:{...e,fields:n}},[T.userFilters,be,E]),nt=T.tabs&&T.tabs.length>0?void 0:tt,[Y,it]=Q.useState(()=>new Set(T.hiddenFields||[])),at=Q.useMemo(()=>JSON.stringify(T.hiddenFields||[]),[T.hiddenFields]);Q.useEffect(()=>{it(new Set(T.hiddenFields||[]))},[at]);let st=Q.useCallback(e=>{it(e),s?.(Array.from(e))},[s]),[ct,lt]=Q.useState(!1),[ut,dt]=Q.useState(!1),ft=Q.useMemo(()=>S(T.quickFilters),[T.quickFilters]),pt=Q.useMemo(()=>{if(T.exportOptions)return Array.isArray(T.exportOptions)?{formats:T.exportOptions}:T.exportOptions},[T.exportOptions]),mt=p(Q.useMemo(()=>T.densityMode?T.densityMode:T.rowHeight?{compact:`compact`,short:`compact`,medium:`comfortable`,tall:`spacious`,extra_tall:`spacious`}[T.rowHeight]||`comfortable`:`compact`,[T.densityMode,T.rowHeight]),{onChange:T.onDensityChange}),gt=Q.useMemo(()=>`objectui:gallery:density:${T.objectName??`default`}`,[T.objectName]),[_t,vt]=Q.useState(()=>{if(typeof window>`u`)return T.gallery?.cardSize??`medium`;try{let e=window.localStorage.getItem(gt);if(e===`small`||e===`medium`||e===`large`)return e}catch{}return T.gallery?.cardSize??`medium`}),yt=Q.useCallback(()=>{vt(e=>{let t=e===`large`?`medium`:e===`medium`?`small`:`large`;try{window.localStorage.setItem(gt,t)}catch{}return t})},[gt]),{ref:xt,isRefreshing:Ct,pullDistance:wt}=$t({onRefresh:Q.useCallback(async()=>{Ee(e=>e+1)},[]),enabled:!!W&&!!T.objectName}),Tt=Q.useMemo(()=>T.id?`listview-${T.objectName}-${T.id}-view`:`listview-${T.objectName}-view`,[T.objectName,T.id]);Q.useEffect(()=>{let e=!0;return we(!1),xe(null),(async()=>{if(!W||!T.objectName){we(!0);return}if(typeof W.getObjectSchema!=`function`){we(!0);return}try{let t=await W.getObjectSchema(T.objectName);e&&xe(t)}catch(e){console.warn(`Failed to fetch object schema for ListView:`,e)}finally{e&&we(!0)}})(),()=>{e=!1}},[T.objectName,W]);let Et=Q.useMemo(()=>{let e=Array.isArray(T.fields)?T.fields.map(e=>typeof e==`string`?e:e?.field).filter(e=>typeof e==`string`&&e.length>0):[],t=new Set(e),n=e=>{if(!e)return;let n=[e.groupField,e.groupBy,e.titleField,e.cardTitle,e.startDateField,e.endDateField,e.dateField,e.endField,e.colorField,e.allDayField,e.coverField,e.imageField,e.subtitleField,e.swimlaneField,e.valueField,...Array.isArray(e.cardFields)?e.cardFields:[],...Array.isArray(e.visibleFields)?e.visibleFields:[],...Array.isArray(e.metaFields)?e.metaFields:[]];for(let e of n)typeof e==`string`&&e&&t.add(e)};n(T.kanban),n(T.options?.kanban),n(T.calendar),n(T.options?.calendar),n(T.gallery),n(T.options?.gallery),n(T.timeline),n(T.options?.timeline),n(T.gantt),n(T.options?.gantt);let r=t.size>0?Array.from(t):void 0;return ee(be?.fields,r)},[be?.fields,T.fields,T.kanban,T.calendar,T.gallery,T.timeline,T.gantt,T.options]),Ot=o();Q.useEffect(()=>{let e=!0,t=++Xe.current;if(T.data&&typeof T.data==`object`&&!Array.isArray(T.data)){let e=T.data;if(e.provider===`value`&&Array.isArray(e.items)){let t=e.items;if(F){let e=F.toLowerCase();t=t.filter(t=>Object.values(t).some(t=>t!=null&&String(t).toLowerCase().includes(e)))}ge(t),ye(!1),je(!1);return}}if(Array.isArray(T.data)){let e=T.data;if(F){let t=F.toLowerCase();e=e.filter(e=>Object.values(e).some(e=>e!=null&&String(e).toLowerCase().includes(t)))}ge(e),ye(!1),je(!1);return}return Ce?((async()=>{if(!W||!T.objectName){ye(!1);return}ye(!0),_e(null);try{let n=[],r=T.filters||[],i=Cn(V),a=[];ft&&Ze.size>0&&ft.forEach(e=>{Ze.has(e.id)&&e.filters&&e.filters.length>0&&a.push(e.filters)});let o=Sn($e),s=[...r.length>0?[r]:[],...i.length>0?[i]:[],...a,...o].filter(e=>Array.isArray(e)&&e.length>0);s.length>1?n=[`and`,...s]:s.length===1&&(n=s[0]);let c=R.length>0?R.filter(e=>e.field).map(e=>({field:e.field,order:e.order})):void 0,l=(()=>{let e=Array.isArray(T.fields)?T.fields.map(e=>typeof e==`string`?e:e?.field).filter(e=>typeof e==`string`&&e.length>0):[],t=Ot?.isLoaded&&T.objectName?e.filter(e=>Ot.checkField(T.objectName,e,`read`)):e;if(t.length===0)return;let n=new Set([`id`]);for(let e of t)n.add(e);for(let e of Et)n.add(e);let r=(()=>{let e=be?.fields;if(!e)return null;let t=Array.isArray(e)?e.map(e=>e?.name).filter(e=>typeof e==`string`):Object.keys(e),n=new Set(t);return n.add(`id`),n.add(`created_at`),n.add(`updated_at`),n})(),i=e=>{typeof e!=`string`||!e||(!r||r.has(e))&&n.add(e)},a=e=>{if(!e)return;let t=[e.groupField,e.groupBy,e.titleField,e.cardTitle,e.startDateField,e.endDateField,e.dateField,e.endField,e.colorField,e.allDayField,e.coverField,e.imageField,e.subtitleField,e.swimlaneField,e.valueField,...Array.isArray(e.cardFields)?e.cardFields:[],...Array.isArray(e.visibleFields)?e.visibleFields:[],...Array.isArray(e.metaFields)?e.metaFields:[]];for(let e of t)i(e)};a(T.kanban),a(T.options?.kanban),a(T.calendar),a(T.options?.calendar),a(T.gallery),a(T.options?.gallery),a(T.timeline),a(T.options?.timeline);{let e=T.timeline??T.options?.timeline;e&&!Array.isArray(e.metaFields)&&(i(`status`),i(`priority`))}return a(T.gantt),a(T.options?.gantt),Array.from(n)})(),u=Array.isArray(n)?n.length>0:!!n&&Object.keys(n).length>0,d=await W.find(T.objectName,{...u?{$filter:n}:{},$orderby:c,$top:Fe,...l?{$select:l}:{},...Et.length>0?{$expand:Et}:{},...F?{$search:F,...T.searchableFields&&T.searchableFields.length>0?{$searchFields:T.searchableFields}:{}}:{}});if(!e||t!==Xe.current)return;let f=[];Array.isArray(d)?f=d:d&&typeof d==`object`&&(Array.isArray(d.data)?f=d.data:Array.isArray(d.records)?f=d.records:Array.isArray(d.value)&&(f=d.value)),ge(f),je(f.length>=Fe)}catch(e){t===Xe.current&&(console.error(`ListView data fetch error:`,e),ge([]),_e(e?.message?String(e.message):String(e??`Unknown error`)))}finally{e&&t===Xe.current&&ye(!1)}})(),()=>{e=!1}):void 0},[T.objectName,T.data,W,T.filters,Fe,R,V,Ze,ft,$e,Te,F,T.searchableFields,Et,Ce,T.refreshTrigger,Ot]);let kt=Q.useMemo(()=>{let e=[`grid`];(T.kanban?.groupByField||T.kanban?.groupField||T.options?.kanban?.groupField)&&e.push(`kanban`),(T.gallery?.coverField||T.gallery?.imageField||T.options?.gallery?.imageField)&&e.push(`gallery`),(T.calendar?.startDateField||T.options?.calendar?.startDateField)&&e.push(`calendar`),(T.timeline?.startDateField||T.options?.timeline?.startDateField||T.options?.timeline?.dateField||T.options?.calendar?.startDateField)&&e.push(`timeline`),(T.gantt?.startDateField||T.options?.gantt?.startDateField)&&e.push(`gantt`),(T.options?.map?.locationField||T.options?.map?.latitudeField&&T.options?.map?.longitudeField)&&e.push(`map`),T.viewType&&!e.includes(T.viewType)&&[`grid`,`kanban`,`calendar`,`timeline`,`gantt`,`map`,`gallery`,`chart`].includes(T.viewType)&&e.push(T.viewType);let t=T.appearance?.allowedVisualizations;if(Array.isArray(t)&&t.length>0){let n=t.filter(t=>e.includes(t));return n.length>0?n:[`grid`]}return e},[T.options,T.viewType,T.kanban,T.calendar,T.gantt,T.gallery,T.timeline,T.appearance?.allowedVisualizations]);Q.useEffect(()=>{T.viewType&&N(T.viewType)},[T.viewType]);let At=Q.useCallback(e=>{N(e);try{localStorage.setItem(Tt,e)}catch(e){console.warn(`Failed to save view preference to localStorage:`,e)}n?.(e)},[Tt,n]),jt=Q.useCallback(e=>{I(e),a?.(e)},[a]),Mt=d({navigation:T.navigation,objectName:T.objectName,onNavigate:T.onNavigate,onRowClick:u}),Nt=Q.useMemo(()=>{let e=T.fields||[];if(Array.isArray(e)||(e=[]),Ot?.isLoaded&&T.objectName&&(e=e.filter(e=>{let t=typeof e==`string`?e:e?.name||e?.fieldName||e?.field;return t?Ot.checkField(T.objectName,t,`read`):!0})),Y.size>0&&(e=e.filter(e=>{let t=typeof e==`string`?e:e?.name||e?.fieldName||e?.field;return t!=null&&!Y.has(t)})),T.fieldOrder&&T.fieldOrder.length>0){let t=new Map(T.fieldOrder.map((e,t)=>[e,t]));e=[...e].sort((e,n)=>{let r=typeof e==`string`?e:e?.name||e?.fieldName||e?.field,i=typeof n==`string`?n:n?.name||n?.fieldName||n?.field;return(t.get(r)??1/0)-(t.get(i)??1/0)})}return e},[T.fields,T.objectName,Y,T.fieldOrder,Ot]),Pt=Q.useMemo(()=>{let e=mt.mode===`compact`?`compact`:mt.mode===`spacious`?`tall`:`medium`,t={objectName:T.objectName,fields:Nt,filters:T.filters,sort:R,className:`h-full w-full`,showSearch:!1,onRowClick:Mt.handleClick,rowHeight:e,hideRowHeightToggle:!0,...T.striped==null?{}:{striped:T.striped},...T.bordered==null?{}:{bordered:T.bordered},...l?{onColumnStateChange:l}:{},...T.columnState?{columnState:T.columnState}:{}};switch(M){default:case`grid`:return{type:`object-grid`,...t,columns:Nt,...T.conditionalFormatting?{conditionalFormatting:T.conditionalFormatting}:{},...T.inlineEdit==null?{}:{editable:T.inlineEdit},...T.wrapHeaders==null?{}:{wrapHeaders:T.wrapHeaders},...T.virtualScroll==null?{}:{virtualScroll:T.virtualScroll},...T.resizable==null?{}:{resizable:T.resizable},...T.selection?{selection:T.selection}:{},...T.pagination?{pagination:T.pagination}:{},...J?{grouping:J}:{},...He?{rowColor:He}:{},...T.rowActions?{rowActions:T.rowActions}:{},...T.rowActionDefs?{rowActionDefs:T.rowActionDefs}:{},...T.bulkActions?{batchActions:T.bulkActions}:{},...T.bulkActionDefs?{bulkActionDefs:T.bulkActionDefs}:{},...T.options?.grid||{}};case`kanban`:return{type:`object-kanban`,...t,groupBy:T.kanban?.groupField||T.options?.kanban?.groupField||`status`,groupField:T.kanban?.groupField||T.options?.kanban?.groupField||`status`,...T.kanban?.titleField||T.options?.kanban?.titleField?{titleField:T.kanban?.titleField||T.options?.kanban?.titleField}:{},cardFields:T.kanban?.cardFields||Nt||[],...J?{grouping:J}:{},...T.options?.kanban||{},...T.kanban||{}};case`calendar`:return{type:`object-calendar`,...t,startDateField:T.calendar?.startDateField||T.options?.calendar?.startDateField||`start_date`,endDateField:T.calendar?.endDateField||T.options?.calendar?.endDateField||`end_date`,...T.calendar?.titleField||T.options?.calendar?.titleField?{titleField:T.calendar?.titleField||T.options?.calendar?.titleField}:{},...T.calendar?.defaultView?{defaultView:T.calendar.defaultView}:{},...T.options?.calendar||{},...T.calendar||{}};case`gallery`:{let e={...T.options?.gallery||{},...T.gallery||{},cardSize:_t};return{type:`object-gallery`,...t,gallery:Object.keys(e).length>0?e:void 0,imageField:T.gallery?.coverField||T.gallery?.imageField||T.options?.gallery?.imageField,titleField:T.gallery?.titleField||T.options?.gallery?.titleField||`name`,subtitleField:T.gallery?.subtitleField||T.options?.gallery?.subtitleField,...J?{grouping:J}:{}}}case`timeline`:{let e={...T.options?.timeline||{},...T.timeline||{}};return{type:`object-timeline`,...t,timeline:Object.keys(e).length>0?e:void 0,startDateField:T.timeline?.startDateField||T.options?.timeline?.startDateField||T.options?.timeline?.dateField||`created_at`,titleField:T.timeline?.titleField||T.options?.timeline?.titleField||`name`,...T.timeline?.endDateField?{endDateField:T.timeline.endDateField}:{},...T.timeline?.groupByField?{groupByField:T.timeline.groupByField}:{},...T.timeline?.colorField?{colorField:T.timeline.colorField}:{},...T.timeline?.scale?{scale:T.timeline.scale}:{}}}case`gantt`:return{type:`object-gantt`,...t,startDateField:T.gantt?.startDateField||T.options?.gantt?.startDateField||`start_date`,endDateField:T.gantt?.endDateField||T.options?.gantt?.endDateField||`end_date`,progressField:T.gantt?.progressField||T.options?.gantt?.progressField||`progress`,dependenciesField:T.gantt?.dependenciesField||T.options?.gantt?.dependenciesField||`dependencies`,...T.gantt?.titleField?{titleField:T.gantt.titleField}:{},...T.options?.gantt||{},...T.gantt||{}};case`map`:return{type:`object-map`,...t,locationField:T.options?.map?.locationField||`location`,...T.options?.map||{}};case`chart`:{let e=T.chart||T.options?.chart||{};if(e.dataset){let t=Array.isArray(e.dimensions)?e.dimensions:[],n=Array.isArray(e.values)?e.values:[];return{type:`object-chart`,dataset:e.dataset,dimensions:t,values:n,chartType:e.chartType||`bar`,xAxisKey:t[0],series:n.map(e=>({dataKey:e,label:e})),className:`h-[400px] w-full`}}let t=Array.isArray(e.yAxisFields)&&e.yAxisFields[0]||e.valueField||`value`,n=e.xAxisField||e.categoryField||`name`;return{type:`object-chart`,objectName:T.objectName,chartType:e.chartType||`bar`,filters:T.filters,aggregate:{field:t,function:e.aggregation||`count`,groupBy:n},xAxisKey:n,series:[{dataKey:t,label:t}],className:`h-[400px] w-full`}}}},[M,T,R,Nt,J,He,Mt.handleClick,mt.mode,_t]),Ft=V.conditions&&V.conditions.length>0,It=Q.useMemo(()=>{let e,t=(e,t)=>{if(!t)return;let n=Array.isArray(t)?t.map(e=>({value:e?.value??e,label:e?.label??String(e?.value??e),...e&&typeof e==`object`?e:{}})):Object.entries(t).map(([e,t])=>({value:e,label:t?.label||e,...t}));return T.objectName?w(T.objectName,e,n):n};if(e=be?.fields?Object.entries(be.fields).map(([e,n])=>({value:e,label:E(e,n.label||e),type:n.type||`text`,options:t(e,n.options),referenceTo:n.reference_to||n.reference,displayField:n.display_field||n.reference_field,idField:n.id_field})):(T.fields||[]).map(e=>{if(typeof e==`string`)return{value:e,label:e,type:`text`};let n=e.name||e.fieldName;return{value:n,label:E(n,e.label||e.name),type:e.type||`text`,options:t(n,e.options),referenceTo:e.reference_to||e.reference,displayField:e.display_field||e.reference_field,idField:e.id_field}}),T.filterableFields&&T.filterableFields.length>0){let t=new Set(T.filterableFields);e=e.filter(e=>t.has(e.value))}return e},[be,T.fields,T.filterableFields,T.objectName,E,w]),Rt=Q.useCallback(e=>{Qe(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},[]),zt=Q.useCallback(e=>{let t=pt,n=t?.maxRecords||0,r=t?.includeHeaders!==!1,i=t?.fileNamePrefix||T.objectName||`export`,a=n>0?G.slice(0,n):G;if(e===`csv`){let e=Nt.map(e=>typeof e==`string`?e:e.name||e.fieldName||e.field),t=[];r&&t.push(e.join(`,`)),a.forEach(n=>{t.push(e.map(e=>{let t=n[e],r;return r=t==null?``:Array.isArray(t)?t.map(e=>typeof e==`object`&&e?JSON.stringify(e):String(e??``)).join(`; `):typeof t==`object`?JSON.stringify(t):String(t),r.includes(`,`)||r.includes(`"`)||r.includes(`
2
+ `)||r.includes(`\r`)?`"${r.replace(/"/g,`""`)}"`:r}).join(`,`))});let n=new Blob([t.join(`
3
+ `)],{type:`text/csv;charset=utf-8;`}),o=URL.createObjectURL(n),s=document.createElement(`a`);s.href=o,s.download=`${i}.csv`,s.click(),URL.revokeObjectURL(o)}else if(e===`json`){let e=new Blob([JSON.stringify(a,null,2)],{type:`application/json`}),t=URL.createObjectURL(e),n=document.createElement(`a`);n.href=t,n.download=`${i}.json`,n.click(),URL.revokeObjectURL(t)}dt(!1)},[G,Nt,pt,T.objectName]),Bt=Q.useMemo(()=>(T.fields||[]).map(e=>{if(typeof e==`string`)return{name:e,label:E(e,e)};let t=e.name||e.fieldName||e.field;return{name:t,label:E(t,e.label||e.name||e.field)}}),[T.fields,E]);return(0,$.jsxs)(`div`,{ref:xt,className:Z(`flex flex-col h-full bg-background relative min-w-0 overflow-hidden`,t),...T.aria?.label?{"aria-label":T.aria.label}:{},...T.aria?.describedBy?{"aria-describedby":T.aria.describedBy}:{},...T.aria?.live?{"aria-live":T.aria.live}:{},role:`region`,children:[wt>0&&(0,$.jsx)(`div`,{className:`flex items-center justify-center text-xs text-muted-foreground`,style:{height:wt},children:b(Ct?`list.refreshing`:`list.pullToRefresh`)}),T.description&&T.appearance?.showDescription!==!1&&(0,$.jsx)(`div`,{className:`px-4 pt-1.5 text-xs text-muted-foreground bg-background`,"data-testid":`view-description`,children:typeof T.description==`string`?T.description:``}),(0,$.jsxs)(`div`,{className:`border-b px-2 sm:px-4 py-1.5 flex items-center justify-between gap-1 sm:gap-2 bg-background`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-2 overflow-x-auto min-w-0`,children:[T.tabs&&T.tabs.length>0&&(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`div`,{className:`hidden sm:block shrink-0`,children:(0,$.jsx)(on,{tabs:T.tabs,activeTab:U,onTabChange:me,className:`!px-0 !py-0`})}),(0,$.jsx)(`div`,{className:`sm:hidden shrink-0`,children:(0,$.jsx)(sn,{tabs:T.tabs,activeTab:U,onTabChange:me,className:`!px-0 !py-0`})})]}),nt&&(0,$.jsx)(`div`,{className:`shrink-0 min-w-0 overflow-x-auto`,"data-testid":`user-filters`,children:(0,$.jsx)(mn,{config:nt,objectDef:be,data:G,onFilterChange:et,maxVisible:3,initialSelections:m,onSelectionsChange:h})})]}),(0,$.jsxs)(`div`,{className:`flex items-center gap-0 shrink-0 rounded-lg border border-border bg-muted/40 p-0.5 shadow-sm`,children:[y&&(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(nn,{currentView:M,availableViews:kt,onViewChange:At}),(0,$.jsx)(`div`,{className:`h-4 w-px bg-border/60 mx-0.5`})]}),j.showHideFields&&!j.compactToolbar&&(0,$.jsxs)(D,{open:ct,onOpenChange:lt,children:[(0,$.jsx)(Wt,{asChild:!0,children:(0,$.jsxs)(X,{variant:`ghost`,size:`sm`,className:Z(`hidden sm:inline-flex h-7 px-2 text-muted-foreground hover:text-primary text-xs transition-colors duration-150`,Y.size>0&&`text-primary`),children:[(0,$.jsx)(re,{className:`h-3.5 w-3.5 mr-1.5`}),(0,$.jsx)(`span`,{className:`hidden sm:inline`,children:b(`list.hideFields`)}),Y.size>0&&(0,$.jsx)(`span`,{className:`ml-1 flex h-4 min-w-[16px] items-center justify-center text-[10px] font-medium text-muted-foreground tabular-nums`,children:Y.size})]})}),(0,$.jsx)(ot,{align:`start`,className:`w-64 p-3`,children:(0,$.jsxs)(`div`,{className:`space-y-2`,children:[(0,$.jsxs)(`div`,{className:`flex items-center justify-between border-b pb-2`,children:[(0,$.jsx)(`h4`,{className:`font-medium text-sm`,children:b(`list.hideFieldsTitle`)}),Y.size>0&&(0,$.jsx)(X,{variant:`ghost`,size:`sm`,className:`h-6 px-2 text-xs`,onClick:()=>st(new Set),children:b(`list.showAll`)})]}),(0,$.jsx)(`div`,{className:`max-h-60 overflow-y-auto space-y-1`,children:Bt.map(e=>(0,$.jsxs)(`label`,{className:`flex items-center gap-2 text-sm py-1 px-1 rounded hover:bg-muted cursor-pointer`,children:[(0,$.jsx)(`input`,{type:`checkbox`,checked:!Y.has(e.name),onChange:()=>{let t=new Set(Y);t.has(e.name)?t.delete(e.name):t.add(e.name),st(t)},className:`rounded border-input`}),(0,$.jsx)(`span`,{className:`truncate`,children:e.label})]},e.name))})]})})]}),j.showHideFields&&!j.compactToolbar&&(j.showFilters||j.showSort||j.showGroup)&&(0,$.jsx)(`div`,{className:`hidden sm:block h-5 w-px bg-border/50 mx-1 shrink-0`}),j.showFilters&&(0,$.jsxs)(D,{open:le,onOpenChange:ue,children:[(0,$.jsx)(Wt,{asChild:!0,children:(0,$.jsxs)(X,{variant:`ghost`,size:`sm`,className:Z(`h-7 px-2 text-muted-foreground hover:text-primary text-xs transition-colors duration-150`,Ft&&`text-foreground font-medium`),children:[(0,$.jsx)(rt,{className:`h-3.5 w-3.5 mr-1.5`}),(0,$.jsx)(`span`,{className:`hidden sm:inline`,children:b(`list.filter`)}),Ft&&(0,$.jsx)(`span`,{className:`ml-1 flex h-4 min-w-[16px] items-center justify-center text-[10px] font-medium text-muted-foreground tabular-nums`,children:V.conditions?.length||0})]})}),(0,$.jsx)(ot,{align:`start`,className:`w-[calc(100vw-2rem)] sm:w-[600px] max-w-[600px] p-3 sm:p-4`,children:(0,$.jsxs)(`div`,{className:`space-y-4`,children:[(0,$.jsx)(`div`,{className:`flex items-center justify-between border-b pb-2`,children:(0,$.jsx)(`h4`,{className:`font-medium text-sm`,children:b(`list.filterRecords`)})}),(0,$.jsx)(B,{fields:It,value:V,onChange:e=>{H(e),r&&r(e)}})]})})]}),j.showGroup&&!j.compactToolbar&&(0,$.jsxs)(D,{open:Re,onOpenChange:ze,children:[(0,$.jsx)(Wt,{asChild:!0,children:(0,$.jsxs)(X,{variant:`ghost`,size:`sm`,className:Z(`hidden sm:inline-flex h-7 px-2 text-muted-foreground hover:text-primary text-xs transition-colors duration-150`,J&&`text-foreground font-medium`),children:[(0,$.jsx)(Lt,{className:`h-3.5 w-3.5 mr-1.5`}),(0,$.jsx)(`span`,{className:`hidden sm:inline`,children:b(`list.group`)}),J&&J.fields?.length>0&&(0,$.jsx)(`span`,{className:`ml-1 flex h-4 min-w-[16px] items-center justify-center text-[10px] font-medium text-muted-foreground tabular-nums`,children:J.fields.length})]})}),(0,$.jsx)(ot,{align:`start`,className:`w-72 p-3`,children:(0,$.jsxs)(`div`,{className:`space-y-2`,children:[(0,$.jsxs)(`div`,{className:`flex items-center justify-between border-b pb-2`,children:[(0,$.jsx)(`h4`,{className:`font-medium text-sm`,children:b(`list.groupBy`)}),J&&(0,$.jsx)(X,{variant:`ghost`,size:`sm`,className:`h-6 px-2 text-xs`,onClick:()=>Le(void 0),"data-testid":`clear-grouping`,children:b(`list.clear`)})]}),(0,$.jsx)(`div`,{"data-testid":`group-field-list`,children:(0,$.jsx)(q,{value:J,fieldOptions:Bt.map(e=>({value:e.name,label:e.label||e.name})),maxLevels:3,labels:{addGroup:b(`list.addGroup`,{defaultValue:`Add group field`}),collapseTitle:b(`list.collapsedByDefault`,{defaultValue:`Collapsed by default`}),removeTitle:b(`list.removeGroup`,{defaultValue:`Remove`})},onChange:e=>Le(e)})})]})})]}),j.showSort&&(0,$.jsxs)(D,{open:L,onOpenChange:oe,children:[(0,$.jsx)(Wt,{asChild:!0,children:(0,$.jsxs)(X,{variant:`ghost`,size:`sm`,className:Z(`hidden sm:inline-flex h-7 px-2 text-muted-foreground hover:text-primary text-xs transition-colors duration-150`,R.length>0&&`text-foreground font-medium`),children:[(0,$.jsx)(ht,{className:`h-3.5 w-3.5 mr-1.5`}),(0,$.jsx)(`span`,{className:`hidden sm:inline`,children:b(`list.sort`)}),R.length>0&&(0,$.jsx)(`span`,{className:`ml-1 flex h-4 min-w-[16px] items-center justify-center text-[10px] font-medium text-muted-foreground tabular-nums`,children:R.length})]})}),(0,$.jsx)(ot,{align:`start`,className:`w-[calc(100vw-2rem)] sm:w-[600px] max-w-[600px] p-3 sm:p-4`,children:(0,$.jsxs)(`div`,{className:`space-y-4`,children:[(0,$.jsx)(`div`,{className:`flex items-center justify-between border-b pb-2`,children:(0,$.jsx)(`h4`,{className:`font-medium text-sm`,children:b(`list.sortRecords`)})}),(0,$.jsx)(ae,{fields:It,value:R,onChange:e=>{z(e),i&&i(e)}})]})})]}),!j.compactToolbar&&(j.showFilters||j.showSort||j.showGroup)&&(j.showColor||j.showDensity)&&(0,$.jsx)(`div`,{className:`hidden sm:block h-5 w-px bg-border/50 mx-1 shrink-0`}),j.showColor&&!j.compactToolbar&&(0,$.jsxs)(D,{open:We,onOpenChange:qe,children:[(0,$.jsx)(Wt,{asChild:!0,children:(0,$.jsxs)(X,{variant:`ghost`,size:`sm`,className:Z(`hidden sm:inline-flex h-7 px-2 text-muted-foreground hover:text-primary text-xs transition-colors duration-150`,He&&`text-foreground font-medium`),children:[(0,$.jsx)(St,{className:`h-3.5 w-3.5 mr-1.5`}),(0,$.jsx)(`span`,{className:`hidden sm:inline`,children:b(`list.color`)})]})}),(0,$.jsx)(ot,{align:`start`,className:`w-64 p-3`,children:(0,$.jsxs)(`div`,{className:`space-y-2`,children:[(0,$.jsxs)(`div`,{className:`flex items-center justify-between border-b pb-2`,children:[(0,$.jsx)(`h4`,{className:`font-medium text-sm`,children:b(`list.rowColor`)}),He&&(0,$.jsx)(X,{variant:`ghost`,size:`sm`,className:`h-6 px-2 text-xs`,onClick:()=>Ue(void 0),"data-testid":`clear-row-color`,children:b(`list.clear`)})]}),(0,$.jsxs)(`div`,{className:`space-y-2`,"data-testid":`color-field-list`,children:[(0,$.jsx)(`label`,{className:`text-xs text-muted-foreground`,children:b(`list.colorByField`)}),(0,$.jsxs)(`select`,{className:`w-full h-8 rounded border border-input bg-background px-2 text-xs`,value:He?.field||``,onChange:e=>{let t=e.target.value;Ue(t?{field:t,colors:He?.colors||{}}:void 0)},"data-testid":`color-field-select`,children:[(0,$.jsx)(`option`,{value:``,children:b(`list.none`)}),Bt.map(e=>(0,$.jsx)(`option`,{value:e.name,children:e.label},e.name))]})]})]})})]}),j.showDensity&&!j.compactToolbar&&M!==`gallery`&&(()=>{let e=mt.mode===`compact`?te:mt.mode===`comfortable`?P:he,t=mt.mode===`compact`?b(`grid.toolbar.densityCompact`,{defaultValue:`Compact`}):mt.mode===`comfortable`?b(`grid.toolbar.densityComfortable`,{defaultValue:`Comfortable`}):b(`grid.toolbar.densitySpacious`,{defaultValue:`Spacious`}),n=`${b(`grid.toolbar.densityMode`,{defaultValue:`Density`})}: ${t}`,r=b(`grid.toolbar.densityCycleHint`,{defaultValue:`{{label}} (click to cycle)`,label:n});return(0,$.jsx)(X,{variant:`ghost`,size:`sm`,"aria-label":n,className:Z(`hidden sm:inline-flex h-7 w-7 p-0 text-muted-foreground hover:text-primary transition-colors duration-150`,mt.mode!==`compact`&&`text-foreground font-medium`),onClick:mt.cycle,title:r,children:(0,$.jsx)(e,{className:`h-3.5 w-3.5`})})})(),j.showDensity&&!j.compactToolbar&&M===`gallery`&&(()=>{let e=_t===`small`?te:_t===`medium`?P:he,t=_t===`small`?b(`grid.toolbar.densityCompact`,{defaultValue:`Compact`}):_t===`medium`?b(`grid.toolbar.densityComfortable`,{defaultValue:`Comfortable`}):b(`grid.toolbar.densitySpacious`,{defaultValue:`Spacious`}),n=`${b(`grid.toolbar.densityMode`,{defaultValue:`Density`})}: ${t}`,r=b(`grid.toolbar.densityCycleHint`,{defaultValue:`{{label}} (click to cycle)`,label:n});return(0,$.jsx)(X,{variant:`ghost`,size:`sm`,"aria-label":n,className:Z(`hidden sm:inline-flex h-7 w-7 p-0 text-muted-foreground hover:text-primary transition-colors duration-150`,_t!==`small`&&`text-foreground font-medium`),onClick:yt,title:r,children:(0,$.jsx)(e,{className:`h-3.5 w-3.5`})})})(),j.compactToolbar&&(j.showGroup||j.showColor||j.showDensity||j.showHideFields)&&(0,$.jsx)(ln,{t:b,allFields:Bt,showGroup:j.showGroup,groupingConfig:J,setGroupingConfig:Le,showColor:j.showColor,rowColorConfig:He,setRowColorConfig:Ue,showDensity:j.showDensity,density:mt,showHideFields:j.showHideFields,hiddenFields:Y,updateHiddenFields:st}),(j.showColor||j.showDensity||j.compactToolbar)&&pt&&T.allowExport!==!1&&(0,$.jsx)(`div`,{className:`h-5 w-px bg-border/50 mx-1 shrink-0`}),pt&&T.allowExport!==!1&&(0,$.jsxs)(D,{open:ut,onOpenChange:dt,children:[(0,$.jsx)(Wt,{asChild:!0,children:(0,$.jsxs)(X,{variant:`ghost`,size:`sm`,className:`h-7 px-2 text-muted-foreground hover:text-primary text-xs transition-colors duration-150`,children:[(0,$.jsx)(A,{className:`h-3.5 w-3.5 mr-1.5`}),(0,$.jsx)(`span`,{className:`hidden sm:inline`,children:b(`list.export`)})]})}),(0,$.jsx)(ot,{align:`start`,className:`w-48 p-2`,children:(0,$.jsx)(`div`,{className:`space-y-1`,children:(pt.formats||[`csv`,`json`]).map(e=>(0,$.jsxs)(X,{variant:`ghost`,size:`sm`,className:`w-full justify-start h-8 text-xs`,onClick:()=>zt(e),children:[(0,$.jsx)(A,{className:`h-3.5 w-3.5 mr-2`}),b(`list.exportAs`,{format:e.toUpperCase()})]},e))})})]}),(T.sharing?.enabled||T.sharing?.type)&&(0,$.jsxs)(X,{variant:`ghost`,size:`sm`,className:`h-7 px-2 text-muted-foreground hover:text-primary text-xs transition-colors duration-150`,title:`Sharing: ${T.sharing?.visibility||T.sharing?.type||`private`}`,"data-testid":`share-button`,children:[(0,$.jsx)(Yt,{className:`h-3.5 w-3.5 mr-1.5`}),(0,$.jsx)(`span`,{className:`hidden sm:inline`,children:b(`list.share`)})]}),T.allowPrinting&&(0,$.jsxs)(X,{variant:`ghost`,size:`sm`,className:`h-7 px-2 text-muted-foreground hover:text-primary text-xs transition-colors duration-150`,onClick:()=>window.print(),"data-testid":`print-button`,children:[(0,$.jsx)(k,{className:`h-3.5 w-3.5 mr-1.5`}),(0,$.jsx)(`span`,{className:`hidden sm:inline`,children:b(`list.print`)})]}),(()=>{let e=T.allowPrinting||T.sharing?.enabled||T.sharing?.type||pt&&T.allowExport!==!1;return j.showSearch&&e?(0,$.jsx)(`div`,{className:`h-5 w-px bg-border/50 mx-1 shrink-0`}):null})(),j.showSearch&&(0,$.jsxs)(D,{open:ne,onOpenChange:ie,children:[(0,$.jsx)(Wt,{asChild:!0,children:(0,$.jsx)(X,{variant:`ghost`,size:`sm`,className:Z(`hidden sm:inline-flex h-7 w-7 p-0 text-muted-foreground hover:text-primary text-xs transition-colors duration-150`,F&&`text-foreground font-medium`),"data-testid":`search-icon-button`,title:b(`list.search`),children:(0,$.jsx)(De,{className:`h-3.5 w-3.5`})})}),(0,$.jsx)(ot,{align:`end`,className:`w-[calc(100vw-2rem)] sm:w-64 p-2`,"data-testid":`search-popover`,children:(0,$.jsxs)(`div`,{className:`relative`,children:[(0,$.jsx)(De,{className:`absolute left-2 top-1/2 -translate-y-1/2 h-3.5 w-3.5 text-muted-foreground`}),(0,$.jsx)(Dt,{placeholder:b(`list.search`)+`...`,value:F,onChange:e=>jt(e.target.value),className:`pl-7 h-8 text-xs`,autoFocus:!0}),F&&(0,$.jsx)(X,{variant:`ghost`,size:`sm`,className:`absolute right-0.5 top-1/2 -translate-y-1/2 h-5 w-5 p-0 hover:bg-muted-foreground/20`,onClick:()=>jt(``),children:(0,$.jsx)(Oe,{className:`h-3 w-3`})})]})})]}),j.showAddRecord&&j.addRecordPosition===`top`&&(0,$.jsxs)(X,{variant:`ghost`,size:`sm`,className:`h-7 px-2 text-muted-foreground hover:text-primary text-xs transition-colors duration-150`,"data-testid":`add-record-button`,onClick:()=>g.onAddRecord?.(),children:[(0,$.jsx)(Ae,{className:`h-3.5 w-3.5 mr-1.5`}),(0,$.jsx)(`span`,{className:`hidden sm:inline`,children:b(`list.addRecord`)})]})]})]}),ft&&ft.length>0&&(0,$.jsx)(`div`,{className:`hidden sm:flex border-b px-2 sm:px-4 py-1 items-center gap-1 flex-wrap bg-background`,"data-testid":`quick-filters`,children:ft.map(e=>{let t=Ze.has(e.id),n=e.icon?Ke[e.icon.split(`-`).map(e=>e.charAt(0).toUpperCase()+e.slice(1)).join(``)]??null:null;return(0,$.jsxs)(X,{variant:t?`default`:`outline`,size:`sm`,className:`h-7 px-3 text-xs`,onClick:()=>Rt(e.id),children:[n&&(0,$.jsx)(n,{className:`h-3 w-3 mr-1.5`}),e.label]},e.id)})}),(0,$.jsxs)(`div`,{className:`flex-1 min-h-0 bg-background relative overflow-hidden animate-in fade-in-0 duration-200`,children:[(0,$.jsx)(fe,{active:ve&&G.length>0}),K&&G.length===0?(0,$.jsx)(de,{"data-testid":`list-error-state`,className:`h-full min-h-[200px] p-8 gap-1 [&>h3]:text-lg [&>h3]:font-medium [&>h3]:text-foreground [&>p]:max-w-md`,icon:(0,$.jsx)(Se,{className:`h-12 w-12 text-destructive/60`}),iconWrapperClassName:`mb-3`,title:b(`list.loadErrorTitle`),description:b(`list.loadErrorMessage`),action:(0,$.jsxs)(X,{variant:`outline`,size:`sm`,"data-testid":`list-error-retry`,onClick:()=>Ee(e=>e+1),children:[(0,$.jsx)(bt,{className:`h-4 w-4 mr-1.5`}),b(`list.retry`)]})}):ve&&G.length===0?(0,$.jsxs)(`div`,{className:`flex flex-col h-full min-h-[200px] p-4 gap-2`,"data-testid":`list-loading`,role:`status`,"aria-live":`polite`,"aria-busy":`true`,children:[(0,$.jsx)(`span`,{className:`sr-only`,children:b(`list.loading`)}),[0,1,2,3,4,5].map(e=>(0,$.jsx)(`div`,{className:`h-9 rounded bg-muted/60 animate-pulse`,style:{opacity:Math.max(.25,1-e*.12)}},e))]}):!ve&&G.length===0&&M===`grid`?(()=>{let e=T.emptyState?.icon,t=e?Ke[e.split(`-`).map(e=>e.charAt(0).toUpperCase()+e.slice(1)).join(``)]??Be:Be,n=!!(F&&F.trim())||Array.isArray($e)&&$e.length>0||Ze.size>0||Array.isArray(V?.conditions)&&V.conditions.length>0,r=(typeof T.emptyState?.title==`string`?T.emptyState.title:void 0)??b(n?`list.noMatches`:`list.firstRunTitle`),i=(typeof T.emptyState?.message==`string`?T.emptyState.message:void 0)??b(n?`list.noMatchesMessage`:`list.firstRunMessage`);return(0,$.jsx)(de,{"data-testid":`empty-state`,className:`h-full min-h-[200px] p-8 gap-1 [&>h3]:text-lg [&>h3]:font-medium [&>h3]:text-foreground [&>p]:max-w-md`,icon:(0,$.jsx)(t,{className:`h-12 w-12 text-muted-foreground/50`}),iconWrapperClassName:`mb-3`,title:r,description:i,action:j.showAddRecord?(0,$.jsxs)(X,{variant:`default`,size:`sm`,"data-testid":`empty-state-add-record`,onClick:()=>g.onAddRecord?.(),children:[(0,$.jsx)(Ae,{className:`h-4 w-4 mr-1.5`}),b(`list.addRecord`)]}):void 0})})():(0,$.jsx)(c,{schema:Pt,...g,data:G,loading:ve,onRowSelect:Ye})]},M),j.showAddRecord&&j.addRecordPosition===`bottom`&&(0,$.jsx)(`div`,{className:`border-t px-2 sm:px-4 py-1 bg-background shrink-0`,children:(0,$.jsxs)(X,{variant:`ghost`,size:`sm`,className:`h-7 px-2 text-muted-foreground hover:text-primary text-xs transition-colors duration-150`,"data-testid":`add-record-button`,onClick:()=>g.onAddRecord?.(),children:[(0,$.jsx)(Ae,{className:`h-3.5 w-3.5 mr-1.5`}),(0,$.jsx)(`span`,{className:`hidden sm:inline`,children:b(`list.addRecord`)})]})}),T.bulkActions&&T.bulkActions.length>0&&Je.length>0&&M!==`grid`&&(0,$.jsxs)(`div`,{className:`border-t border-primary/30 px-4 py-2 flex items-center gap-2 text-xs bg-primary/10 text-foreground shrink-0 shadow-sm`,role:`region`,"aria-label":`Bulk actions`,"data-testid":`bulk-actions-bar`,children:[(0,$.jsx)(Vt,{className:`h-3.5 w-3.5 text-primary shrink-0`}),(0,$.jsxs)(`span`,{className:`font-medium`,children:[Je.length,` `,Je.length===1?`item`:`items`,` selected`]}),(0,$.jsx)(`div`,{className:`flex items-center gap-1.5 ml-3`,children:T.bulkActions.map(e=>{let t=String(e).toLowerCase(),n=t.includes(`delete`)||t.includes(`remove`)||t.includes(`destroy`),r=n?Ne:null;return(0,$.jsxs)(X,{variant:n?`destructive`:`outline`,size:`sm`,className:`h-7 px-2.5 text-xs gap-1.5`,onClick:()=>g.onBulkAction?.(e,Je),"data-testid":`bulk-action-${e}`,children:[r&&(0,$.jsx)(r,{className:`h-3 w-3`}),O(e)]},e)})}),(0,$.jsxs)(X,{variant:`ghost`,size:`sm`,className:`h-7 px-2 text-xs ml-auto gap-1`,onClick:()=>Ye([]),children:[(0,$.jsx)(Oe,{className:`h-3 w-3`}),`Clear`]})]}),!ve&&G.length>0&&T.showRecordCount!==!1&&(0,$.jsxs)(`div`,{className:`border-t px-4 py-2 flex items-center gap-3 text-xs text-muted-foreground bg-background shrink-0`,"data-testid":`record-count-bar`,children:[(0,$.jsx)(`span`,{className:`font-medium text-foreground/80`,children:G.length===1?b(`list.recordCountOne`,{count:G.length}):b(`list.recordCount`,{count:G.length})}),ke&&(0,$.jsx)(`span`,{className:`text-amber-600`,"data-testid":`data-limit-warning`,children:b(`list.dataLimitReached`,{limit:Fe})}),T.pagination?.pageSizeOptions&&T.pagination.pageSizeOptions.length>0&&(0,$.jsxs)(`div`,{className:`ml-auto flex items-center gap-2`,children:[(0,$.jsx)(`span`,{children:b(`table.rowsPerPage`,{defaultValue:`Rows per page`})}),(0,$.jsx)(`select`,{"data-testid":`page-size-selector`,className:`h-7 w-[72px] px-2 py-1 text-xs rounded-md border border-input bg-background`,value:String(Fe),onChange:e=>{let t=Number(e.target.value);Pe(t),g.onPageSizeChange&&g.onPageSizeChange(t)},children:T.pagination.pageSizeOptions.map(e=>(0,$.jsx)(`option`,{value:String(e),children:e},e))})]})]}),Mt.isOverlay&&(0,$.jsx)(se,{...Mt,title:T.label?`${T.label} Detail`:T.objectName?`${T.objectName.charAt(0).toUpperCase()+T.objectName.slice(1)} Detail`:`Record Detail`,children:e=>(0,$.jsx)(`div`,{className:`space-y-3`,children:Object.entries(e).map(([e,t])=>(0,$.jsxs)(`div`,{className:`flex flex-col`,children:[(0,$.jsx)(`span`,{className:`text-xs font-medium text-muted-foreground uppercase tracking-wide`,children:e.replace(/_/g,` `)}),(0,$.jsx)(`span`,{className:`text-sm`,children:String(t??`—`)})]},e))})})]})});kn.displayName=`ListView`;var An={small:`grid-cols-2 sm:grid-cols-3 md:grid-cols-4 lg:grid-cols-5 xl:grid-cols-6`,medium:`grid-cols-1 sm:grid-cols-2 md:grid-cols-3 lg:grid-cols-4`,large:`grid-cols-1 sm:grid-cols-1 md:grid-cols-2 lg:grid-cols-3`},jn={small:`aspect-square`,medium:`aspect-[4/3]`,large:`aspect-[16/10]`},Mn=new Set([`number`,`currency`,`percent`,`integer`,`decimal`]),Nn=[{bg:`from-indigo-500/15 via-indigo-500/5 to-purple-500/10`,ring:`ring-indigo-500/15`,text:`text-indigo-600/70 dark:text-indigo-300/70`},{bg:`from-sky-500/15 via-sky-500/5 to-cyan-500/10`,ring:`ring-sky-500/15`,text:`text-sky-600/70 dark:text-sky-300/70`},{bg:`from-emerald-500/15 via-emerald-500/5 to-teal-500/10`,ring:`ring-emerald-500/15`,text:`text-emerald-600/70 dark:text-emerald-300/70`},{bg:`from-amber-500/15 via-amber-500/5 to-orange-500/10`,ring:`ring-amber-500/15`,text:`text-amber-600/70 dark:text-amber-300/70`},{bg:`from-rose-500/15 via-rose-500/5 to-pink-500/10`,ring:`ring-rose-500/15`,text:`text-rose-600/70 dark:text-rose-300/70`},{bg:`from-violet-500/15 via-violet-500/5 to-fuchsia-500/10`,ring:`ring-violet-500/15`,text:`text-violet-600/70 dark:text-violet-300/70`}];function Pn(e){let t=5381;for(let n=0;n<e.length;n++)t=(t<<5)+t+e.charCodeAt(n);return Nn[Math.abs(t)%Nn.length]}var Fn=({imageUrl:e,title:t,coverFit:n,aspectClass:r,placeholder:i,hidden:a})=>{let[o,s]=(0,Q.useState)(!1),c=!!e&&!o;return(0,$.jsx)(`div`,{className:Z(`w-full overflow-hidden relative`,r),hidden:a,children:c?n===`contain`?(0,$.jsx)(`div`,{className:Z(`flex h-full w-full items-center justify-center bg-gradient-to-br`,i.bg),children:(0,$.jsx)(`img`,{src:e,alt:t,loading:`lazy`,onError:()=>s(!0),className:`h-1/2 w-1/2 max-h-24 max-w-24 object-contain transition-transform duration-300 ease-out group-hover:scale-[1.08]`})}):(0,$.jsx)(`img`,{src:e,alt:t,loading:`lazy`,onError:()=>s(!0),className:`h-full w-full object-cover transition-transform duration-300 ease-out group-hover:scale-[1.04]`}):(0,$.jsx)(`div`,{className:Z(`flex h-full w-full items-center justify-center bg-gradient-to-br ring-1 ring-inset`,i.bg,i.ring),children:(0,$.jsx)(`span`,{className:Z(`text-5xl font-semibold tracking-tight opacity-90`,i.text),children:t[0]?.toUpperCase()})})})},In=({imageUrl:e,title:t,placeholder:n})=>{let[r,i]=(0,Q.useState)(!1),a=!!e&&!r;return(0,$.jsx)(`div`,{className:Z(`flex h-11 w-11 shrink-0 items-center justify-center rounded-xl bg-gradient-to-br ring-1 ring-inset`,n.bg,n.ring),children:a?(0,$.jsx)(`img`,{src:e,alt:t,loading:`lazy`,onError:()=>i(!0),className:`h-6 w-6 object-contain transition-transform duration-300 ease-out group-hover:scale-110`}):(0,$.jsx)(`span`,{className:Z(`text-base font-semibold`,n.text),children:t[0]?.toUpperCase()})})};x.register(`object-gallery`,e=>{let{schema:t}=e,n=(0,Q.useContext)(f),r=e.dataSource||n?.dataSource,i=h(t.bind),[a,o]=(0,Q.useState)([]),[s,c]=(0,Q.useState)(!1),[l,u]=(0,Q.useState)(null),p=d({navigation:t.navigation,objectName:t.objectName,onRowClick:e.onRowClick??e.onCardClick}),m=t.gallery,g=m?.coverField??t.imageField??`image`,_=m?.coverFit??`cover`,v=m?.cardSize??`medium`,y=m?.titleField??t.titleField??`name`,b=m?.visibleFields,{fieldLabel:x,fieldOptionLabel:S}=Ge(),C=(0,Q.useCallback)(e=>{let n=l?.fields?.[e],r={name:e};if(n){n.type&&(r.type=n.type),n.label&&(r.label=n.label),n.options&&(r.options=n.options),n.currency&&(r.currency=n.currency),n.precision!==void 0&&(r.precision=n.precision),n.format&&(r.format=n.format);let e=n.reference_to||n.reference;e&&(r.reference_to=e),n.reference_field&&(r.reference_field=n.reference_field)}if(t.objectName){let n=String(r.label??e);r.label=x(t.objectName,e,n)}return t.objectName&&Array.isArray(r.options)&&(r.options=r.options.map(n=>{let r=String(n?.value??n),i=String(n?.label??r);return{...n,value:r,label:S(t.objectName,e,r,i)}})),r},[l,t.objectName,x,S]);(0,Q.useEffect)(()=>{let e=!0;return(async()=>{if(!(!r||typeof r.getObjectSchema!=`function`||!t.objectName))try{let n=await r.getObjectSchema(t.objectName);e&&u(n)}catch(e){console.warn(`Failed to fetch object def for ObjectGallery`,e)}})(),()=>{e=!1}},[t.objectName,r]),(0,Q.useEffect)(()=>{let n=!0;if(e.data&&Array.isArray(e.data)){o(e.data);return}return t.objectName&&!i&&!t.data&&!e.data&&(async()=>{if(!(!r||typeof r.find!=`function`||!t.objectName)){n&&c(!0);try{let e=ee(l?.fields),i=await r.find(t.objectName,{$filter:t.filter,...e.length>0?{$expand:e}:{}}),a=[];if(Array.isArray(i))a=i;else if(i&&typeof i==`object`){let e=i;Array.isArray(e.records)?a=e.records:Array.isArray(e.data)&&(a=e.data)}n&&o(a)}catch(e){console.error(`[ObjectGallery] Fetch error:`,e)}finally{n&&c(!1)}}})(),()=>{n=!1}},[t.objectName,r,i,t.data,t.filter,e.data,l]);let w=e.data||i||t.data||a||[],T=(0,Q.useMemo)(()=>w.some(e=>typeof e[g]==`string`&&!!e[g]),[w,g]),E=t.grouping?.fields,D=!!(E&&E.length>0),[O,k]=(0,Q.useState)({}),A=(0,Q.useMemo)(()=>E?E.some(e=>e.collapsed):!1,[E]),j=(0,Q.useCallback)(e=>{k(t=>({...t,[e]:t[e]===void 0?!A:!t[e]}))},[A]),M=(0,Q.useMemo)(()=>{if(!D||!E)return[];let e=new Map,t=[];for(let n of w){let r=E.map(e=>String(n[e.field]??``)).join(` / `);if(!e.has(r)){let i=E.map(e=>{let t=n[e.field];return t!=null&&t!==``?String(t):`(empty)`}).join(` / `);e.set(r,{label:i,items:[]}),t.push(r)}e.get(r).items.push(n)}let n=E[0]?.order??`asc`;return t.sort((e,t)=>{let r=e.localeCompare(t,void 0,{numeric:!0,sensitivity:`base`});return n===`desc`?-r:r}),t.map(t=>{let n=e.get(t),r=t in O?O[t]:A;return{key:t,label:n.label,items:n.items,collapsed:r}})},[w,E,D,O,A]);if(s&&!w.length)return(0,$.jsx)(`div`,{className:`p-4 text-sm text-muted-foreground`,children:`Loading Gallery...`});if(!w.length)return(0,$.jsx)(`div`,{className:`p-4 text-sm text-muted-foreground`,children:`No items to display`});let N=e=>!b||b.length===0?null:(0,$.jsx)(`div`,{className:`mt-1.5 space-y-1`,children:b.map(t=>{let n=e[t];if(n==null||n===``)return null;let r=C(t),i=dt(r)||r.type||`text`,a=Y(i),o=r?.label&&String(r.label).trim()?String(r.label):void 0,s=o!=null&&Mn.has(i);return(0,$.jsxs)(`div`,{className:Z(`text-xs text-muted-foreground truncate [&_*]:!text-xs`,s&&`flex items-baseline gap-1.5`),onClick:e=>{e.target.closest(`a,button`)&&e.stopPropagation()},children:[s&&(0,$.jsx)(`span`,{className:`shrink-0 text-muted-foreground/70 tabular-nums`,children:o}),(0,$.jsx)(a,{value:n,field:r})]},t)})}),P=(n,r)=>{let i=n.id??n._id??r,a=String(n[y]??`Untitled`),o=n[g],s=Pn(String(i)+`|`+a),c=Z(`group relative overflow-hidden border-border/60 bg-card`,`transition-all duration-200 ease-out`,`hover:shadow-lg hover:border-border hover:-translate-y-0.5`,(e.onCardClick||e.onRowClick||t.navigation)&&`cursor-pointer`);return T&&_===`contain`?(0,$.jsxs)(Ft,{role:`listitem`,className:c,onClick:e=>p.handleClick(n,e),children:[(0,$.jsx)(`div`,{"aria-hidden":!0,className:Z(`absolute inset-x-0 top-0 h-[3px] bg-gradient-to-r`,s.bg)}),(0,$.jsx)(le,{className:`p-4`,children:(0,$.jsxs)(`div`,{className:`flex items-start gap-3`,children:[(0,$.jsx)(In,{imageUrl:o,title:a,placeholder:s}),(0,$.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,$.jsx)(`h3`,{className:`font-semibold tracking-tight truncate text-sm leading-tight text-foreground`,title:a,children:a}),N(n)]})]})})]},i):(0,$.jsxs)(Ft,{role:`listitem`,className:c,onClick:e=>p.handleClick(n,e),children:[!T&&(0,$.jsx)(`div`,{"aria-hidden":!0,className:Z(`absolute inset-x-0 top-0 h-[3px] bg-gradient-to-r`,s.bg)}),(0,$.jsx)(Fn,{imageUrl:o,title:a,coverFit:_,aspectClass:jn[v],placeholder:s,hidden:!T}),(0,$.jsxs)(le,{className:Z(`p-3`,T&&`border-t border-border/60`),children:[(0,$.jsx)(`h3`,{className:`font-semibold tracking-tight truncate text-sm leading-tight text-foreground`,title:a,children:a}),N(n)]})]},i)},I=e=>(0,$.jsx)(`div`,{className:Z(`grid gap-4 p-4 auto-rows-min content-start`,An[v],t.className),role:`list`,children:e.map((e,t)=>P(e,t))});return(0,$.jsxs)($.Fragment,{children:[D?(0,$.jsx)(`div`,{className:`space-y-2`,children:M.map(e=>(0,$.jsxs)(`div`,{className:`border rounded-md`,children:[(0,$.jsxs)(`button`,{type:`button`,className:`flex w-full items-center gap-2 px-3 py-2 text-sm font-medium text-left bg-muted/50 hover:bg-muted transition-colors`,onClick:()=>j(e.key),children:[e.collapsed?(0,$.jsx)(ke,{className:`h-4 w-4 shrink-0`}):(0,$.jsx)(F,{className:`h-4 w-4 shrink-0`}),(0,$.jsx)(`span`,{children:e.label}),(0,$.jsx)(`span`,{className:`ml-auto text-xs text-muted-foreground`,children:e.items.length})]}),!e.collapsed&&I(e.items)]},e.key))}):I(w),p.isOverlay&&(0,$.jsx)(se,{...p,title:`Gallery Item`,children:e=>(0,$.jsx)(`div`,{className:`space-y-3`,children:Object.entries(e).map(([e,t])=>(0,$.jsxs)(`div`,{className:`flex flex-col`,children:[(0,$.jsx)(`span`,{className:`text-xs font-medium text-muted-foreground uppercase tracking-wide`,children:e.replace(/_/g,` `)}),(0,$.jsx)(`span`,{className:`text-sm`,children:String(t??`—`)})]},e))})})]})},{namespace:`plugin-list`,label:`Gallery View`,category:`view`}),x.register(`list-view`,kn,{namespace:`plugin-list`,label:`List View`,category:`Views`,icon:`LayoutList`,inputs:[{name:`objectName`,type:`string`,label:`Object Name`,required:!0},{name:`viewType`,type:`enum`,label:`Default View`,enum:[{label:`Grid`,value:`grid`},{label:`Kanban`,value:`kanban`},{label:`Gallery`,value:`gallery`},{label:`Calendar`,value:`calendar`},{label:`Timeline`,value:`timeline`},{label:`Gantt`,value:`gantt`},{label:`Map`,value:`map`}],defaultValue:`grid`},{name:`fields`,type:`array`,label:`Fields`},{name:`filters`,type:`array`,label:`Filters`},{name:`sort`,type:`array`,label:`Sort`},{name:`options`,type:`object`,label:`View Options`}],defaultProps:{objectName:``,viewType:`grid`,fields:[],filters:[],sort:[],options:{}}}),x.register(`list`,kn,{namespace:`view`,category:`view`,label:`List`,icon:`LayoutList`,inputs:[{name:`objectName`,type:`string`,label:`Object Name`,required:!0},{name:`viewType`,type:`enum`,label:`Default View`,enum:[{label:`Grid`,value:`grid`},{label:`Kanban`,value:`kanban`},{label:`Gallery`,value:`gallery`},{label:`Calendar`,value:`calendar`},{label:`Timeline`,value:`timeline`},{label:`Gantt`,value:`gantt`},{label:`Map`,value:`map`}],defaultValue:`grid`},{name:`fields`,type:`array`,label:`Fields`},{name:`filters`,type:`array`,label:`Filters`},{name:`sort`,type:`array`,label:`Sort`},{name:`options`,type:`object`,label:`View Options`}]});var Ln=new Set([`textarea`,`markdown`,`html`,`grid`,`rich-text`,`field:textarea`,`field:markdown`,`field:html`,`field:grid`,`field:rich-text`]);function Rn(e){return Ln.has(e)}function zn(e,t){let n;return n=e<=3?1:2,t!==void 0&&t<640?Math.min(n,1):n}function Bn(e,t){return t<=1?e:e.map(e=>e.span===void 0&&e.type&&Rn(e.type)?{...e,span:t}:e)}function Vn(e,t,n){if(t!==void 0)return{fields:Bn(e,t),columns:t};let r=zn(e.length,n);return{fields:Bn(e,r),columns:r}}function Hn(e,t){return function(){try{let n=C();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 Un=Hn({"detail.back":`Back`,"detail.edit":`Edit`,"detail.editInline":`Edit`,"detail.save":`Save`,"detail.saveChanges":`Save changes`,"detail.editFieldsInline":`Edit fields inline`,"detail.cancel":`Cancel`,"detail.cancelEdit":`Discard changes`,"detail.openInNewTab":`Open in new tab`,"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.noValue":`No value`,"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.createdBy":`Created by`,"detail.updatedBy":`Updated by`,"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.sendComment":`Send`,"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.showEmptyRelated_one":`+ {{count}} empty`,"detail.showEmptyRelated_other":`+ {{count}} empty`,"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.viewSource":`View 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`,"detail.concurrentUpdateTitle":`This record was modified by someone else`,"detail.concurrentUpdateDescription":`Another user saved a newer version of {{field}} while you were editing. To prevent silently overwriting their change, please choose how to resolve the conflict.`,"detail.concurrentUpdateYourEdit":`Your edit`,"detail.concurrentUpdateCurrentValue":`Current value`,"detail.concurrentUpdateUpdatedBy":`Updated by {{name}}`,"detail.concurrentUpdateUpdatedAt":`Updated at {{when}}`,"detail.concurrentUpdateReload":`Reload latest`,"detail.concurrentUpdateOverwrite":`Overwrite anyway`,"detail.concurrentUpdateCancel":`Cancel`},`detail.back`);function Wn(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 Gn=({section:e,data:t,className:n,objectSchema:r,objectName:i,isEditing:a=!1,onFieldChange:o,virtualScroll:s})=>{let[l,u]=Q.useState(e.defaultCollapsed??!1),[d,f]=Q.useState(null),[p,m]=Q.useState(void 0),[h,g]=Q.useState(!1),{t:_}=Un(),{fieldLabel:v,translateOptions:y}=Ge(),b=Q.useCallback((e,t)=>{let n=t==null?``:String(t);navigator.clipboard.writeText(n).then(()=>{f(e),setTimeout(()=>f(null),2e3)})},[]),x=Q.useCallback(e=>{let n=t?.[e.name]??e.value;return n==null||n===``},[t]),S=Q.useMemo(()=>e.fields.filter(x).length,[e.fields,x]),C=W(),ee=C?3:4,w=C?.2:.25,T=e.fields.length-S,E=!e.hideEmpty&&!a&&e.fields.length>=ee&&S/e.fields.length>=w&&T>0,D=!h&&(e.hideEmpty||E)?e.fields.filter(e=>!x(e)):e.fields;if(D.length===0&&S===e.fields.length)return null;let{fields:k,columns:A}=Vn(D,e.columns),j=e=>{let n=t?.[e.name]??e.value;if(e.render)return(0,$.jsx)(c,{schema:e.render,data:{...t,value:n}});let s=Wn(e.span,A),l=r?.fields?.[e.name],u={...e};if(l){!e.type&&l.type&&(u.type=l.type),l.options&&!u.options&&(u.options=l.options),l.currency&&!u.currency&&(u.currency=l.currency),l.precision!==void 0&&u.precision===void 0&&(u.precision=l.precision),l.format&&!u.format&&(u.format=l.format);let t=l.reference_to||l.reference;t&&!u.reference_to&&(u.reference_to=t),l.reference_field&&!u.reference_field&&(u.reference_field=l.reference_field)}i&&Array.isArray(u.options)&&u.options.length>0&&(u.options=y(i,e.name,u.options));let f=(()=>{if(n==null||n===``)return(0,$.jsx)(`span`,{className:`text-muted-foreground/60 text-sm select-none`,"aria-label":_(`detail.noValue`,{defaultValue:`No value`}),title:_(`detail.noValue`,{defaultValue:`No value`}),children:`—`});let t=dt(u)||e.type;if(t){let e=Y(t);if(e)return(0,$.jsx)(e,{value:n,field:u})}return String(n)})(),p=n!=null&&n!==``,m=d===e.name;return(0,$.jsxs)(`div`,{className:Z(`space-y-1.5 group`,s),children:[(0,$.jsx)(`div`,{className:`text-xs font-medium text-muted-foreground uppercase tracking-wide`,children:v(i||``,e.name,e.label||e.name)}),a&&!e.readonly?(0,$.jsx)(`div`,{className:`min-h-[44px] sm:min-h-0`,children:(()=>{let t=u.type||e.type;if(t===`select`&&Array.isArray(u.options)&&u.options.length>0)return(0,$.jsx)(Te,{field:u,value:n==null?``:String(n),onChange:t=>o?.(e.name,t)});if(t===`boolean`)return(0,$.jsx)(M,{field:u,value:!!n,onChange:t=>o?.(e.name,t)});let r=t===`date`||t===`datetime`;return(0,$.jsx)(`input`,{type:t===`number`?`number`:r?`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?``:r?(()=>{let e=String(n);if(/^\d{4}-\d{2}-\d{2}/.test(e))return e.slice(0,10);let t=new Date(e);return isNaN(t.getTime())?``:t.toLocaleDateString(`en-CA`)})():String(n),onChange:t=>{let n=t.target.value;if(r&&n){let t=new Date(n+`T00:00:00`).toISOString();o?.(e.name,t)}else o?.(e.name,n)}})})()}):(0,$.jsxs)(`div`,{className:Z(`flex items-start justify-between gap-2 min-h-[44px] sm:min-h-0 rounded-md`,p&&`cursor-pointer active:bg-muted/60 transition-colors`),onClick:p?()=>b(e.name,n):void 0,onKeyDown:p?t=>{(t.key===`Enter`||t.key===` `)&&(t.preventDefault(),b(e.name,n))}:void 0,role:p?`button`:void 0,tabIndex:p?0:void 0,children:[(0,$.jsx)(`div`,{className:`text-sm flex-1 break-words py-1`,children:f}),p&&(0,$.jsx)(O,{children:(0,$.jsxs)(K,{children:[(0,$.jsx)(yt,{asChild:!0,children:(0,$.jsx)(X,{variant:`ghost`,size:`icon`,className:`h-6 w-6 opacity-0 group-hover:opacity-100 transition-opacity shrink-0`,onClick:t=>{t.stopPropagation(),b(e.name,n)},children:m?(0,$.jsx)(ge,{className:`h-3 w-3 text-green-600`}):(0,$.jsx)(Ve,{className:`h-3 w-3`})})}),(0,$.jsx)(xt,{children:_(m?`detail.copied`:`detail.copyToClipboard`)})]})})]})]},e.name)},N=s?.enabled===!0,P=s?.batchSize??20;Q.useEffect(()=>{if(!N){m(void 0);return}if(k.length<=P){m(void 0);return}m(P);let e=setTimeout(()=>m(void 0),100);return()=>clearTimeout(e)},[N,k.length,P]);let I=p===void 0?k:k.slice(0,p),te=S>0&&(e.hideEmpty||E),ne=(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`div`,{className:Z(`grid gap-3 sm:gap-4`,A===1?`grid-cols-1`:A===2?`grid-cols-1 md:grid-cols-2`:`grid-cols-1 md:grid-cols-2 lg:grid-cols-3`),children:I.map(j)}),te&&(0,$.jsx)(`div`,{className:`mt-3 -ml-2`,children:(0,$.jsxs)(X,{type:`button`,variant:`ghost`,size:`sm`,onClick:()=>g(e=>!e),className:`h-7 px-2 text-xs text-muted-foreground hover:text-foreground`,children:[h?(0,$.jsx)(re,{className:`h-3.5 w-3.5 mr-1.5`}):(0,$.jsx)(_e,{className:`h-3.5 w-3.5 mr-1.5`}),h?_(`detail.hideEmptyFields`,{defaultValue:`Hide empty fields`}):_(`detail.showEmptyFields`,{count:S,defaultValue:`Show ${S} empty field${S===1?``:`s`}`})]})})]});return!e.title&&!e.collapsible&&e.showBorder===!1?(0,$.jsx)(`div`,{className:Z(n),children:ne}):e.collapsible?(0,$.jsx)(je,{open:!l,onOpenChange:e=>u(!e),className:n,children:(0,$.jsxs)(Ft,{children:[(0,$.jsx)(L,{asChild:!0,children:(0,$.jsxs)(Re,{className:Z(`py-3 px-4 sm:py-4 sm:px-6 cursor-pointer hover:bg-muted/50 transition-colors`,e.headerColor&&`bg-${e.headerColor}`),children:[(0,$.jsxs)(Ue,{className:`flex items-center justify-between text-base font-semibold tracking-tight`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[e.icon&&(0,$.jsx)(`span`,{className:`text-muted-foreground`,children:e.icon}),(0,$.jsx)(`span`,{children:e.title})]}),(0,$.jsx)(`div`,{className:`flex items-center gap-2`,children:l?(0,$.jsx)(ke,{className:`h-4 w-4 text-muted-foreground`}):(0,$.jsx)(F,{className:`h-4 w-4 text-muted-foreground`})})]}),e.description&&!l&&(0,$.jsx)(`p`,{className:`text-xs text-muted-foreground mt-1`,children:e.description})]})}),(0,$.jsx)(Fe,{children:(0,$.jsx)(le,{className:`pt-3 sm:pt-4 px-3 sm:px-6 pb-4 sm:pb-5`,children:ne})})]})}):(0,$.jsxs)(Ft,{className:Z(e.showBorder===!1?`border-none shadow-none`:``,n),children:[e.title&&(0,$.jsxs)(Re,{className:Z(`py-3 px-4 sm:py-4 sm:px-6`,e.headerColor&&`bg-${e.headerColor}`),children:[(0,$.jsx)(Ue,{className:`flex items-center justify-between text-base font-semibold tracking-tight`,children:(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[e.icon&&(0,$.jsx)(`span`,{className:`text-muted-foreground`,children:e.icon}),(0,$.jsx)(`span`,{children:e.title})]})}),e.description&&(0,$.jsx)(`p`,{className:`text-xs text-muted-foreground mt-1`,children:e.description})]}),(0,$.jsx)(le,{className:`pt-3 sm:pt-4 px-3 sm:px-6 pb-4 sm:pb-5`,children:ne})]})},Kn=({tabs:e,data:t,className:n})=>{let[r,i]=Q.useState(e[0]?.key),a=e.filter(e=>typeof e.visible==`boolean`?e.visible:(e.visible,!0));return(0,$.jsxs)(kt,{value:r,onValueChange:i,className:n,children:[(0,$.jsx)(_t,{className:`w-full justify-start border-b rounded-none bg-transparent p-0`,children:a.map(e=>(0,$.jsx)(Ze,{value:e.key,className:`relative rounded-none border-b-2 border-transparent data-[state=active]:border-primary data-[state=active]:bg-transparent`,children:(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[e.icon&&(0,$.jsx)(`span`,{children:e.icon}),(0,$.jsx)(`span`,{children:e.label}),e.badge&&(0,$.jsx)(T,{variant:`secondary`,className:`ml-1`,children:e.badge})]})},e.key))}),a.map(e=>(0,$.jsx)(zt,{value:e.key,className:`mt-4 motion-safe:data-[state=active]:animate-in motion-safe:data-[state=active]:fade-in-0 motion-safe:duration-150`,children:(0,$.jsx)(Q.Suspense,{fallback:null,children:Array.isArray(e.content)?(0,$.jsx)(`div`,{className:`space-y-4`,children:e.content.map((e,n)=>(0,$.jsx)(c,{schema:e,data:t},n))}):(0,$.jsx)(c,{schema:e.content,data:t})})},e.key))]})};function qn(e){return e&&Ke[e.split(/[-_\s]/).filter(Boolean).map(e=>e.charAt(0).toUpperCase()+e.slice(1)).join(``)]||Be}var Jn=({title:e,type:t,api:n,data:r,schema:i,columns:a,className:s,dataSource:l,objectName:u,onNew:d,onViewAll:f,onRowEdit:p,onRowDelete:m,onRowClick:h,maxColumns:g=6,pageSize:_,sortable:v=!1,filterable:y=!1,collapsible:b=!1,defaultCollapsed:x=!1,referenceField:S,parentId:C,icon:ee})=>{let w=r!==void 0,E=r??[],[D,O]=Q.useState(E),[k,A]=Q.useState(()=>!!n&&!w),[j,M]=Q.useState(0),[N,P]=Q.useState(null),[I,te]=Q.useState(`asc`),[re,ie]=Q.useState(``),[ae,L]=Q.useState(null),[oe,se]=Q.useState(x),[z,ce]=Q.useState({}),{t:B}=Un(),{fieldLabel:ue}=Ge();Q.useEffect(()=>{w&&O(r??[])},[r,w]),Q.useEffect(()=>{n&&l?.getObjectSchema&&l.getObjectSchema(n).then(L).catch(e=>{console.warn(`[RelatedList] Failed to fetch schema for ${n}:`,e)})},[n,l]),Q.useEffect(()=>{if(n&&!w){if(!(S&&C!=null&&C!==``)){n&&(C==null||C===``)&&!S&&console.warn(`[RelatedList] "${n}" has no referenceField/parentId — refusing to fetch all rows. Pass relationshipField + parentId to scope the query.`),O([]),A(!1);return}A(!0);let e={[S]:C};if(l&&typeof l.find==`function`)l.find(n,{$filter:e}).then(e=>{O(Array.isArray(e)?e:Array.isArray(e?.data)?e.data:[]),A(!1)}).catch(e=>{console.error(`Failed to fetch related data:`,e),A(!1)});else{let e=new URLSearchParams({[`filter[${S}]`]:String(C)}).toString();fetch(`${n}?${e}`).then(e=>e.json()).then(e=>{O(Array.isArray(e)?e:e?.data||[])}).catch(e=>{console.error(`Failed to fetch related data:`,e)}).finally(()=>A(!1))}}},[n,w,l,S,C]),Q.useEffect(()=>{if(!l?.find||!ae?.fields||!D.length)return;let e=ae.fields,t=[];for(let[n,r]of Object.entries(e)){if(!r||r.type!==`lookup`&&r.type!==`master_detail`)continue;let e=r.reference_to||r.reference;if(!e)continue;let i=new Set;for(let e of D){let t=e?.[n];t!=null&&(typeof t==`string`&&t?i.add(t):typeof t==`number`&&i.add(String(t)))}let a=z[n]||{},o=Array.from(i).filter(e=>!(e in a));o.length>0&&t.push({fieldName:n,target:e,ids:o})}if(t.length===0)return;let n=!1;return Promise.all(t.map(({fieldName:e,target:t,ids:n})=>l.find(t,{$filter:{id:{$in:n}},$top:n.length}).then(t=>{let n=Array.isArray(t)?t:t?.data||[],r={};for(let e of n){let t=e?.id||e?._id;t&&(r[String(t)]=e?.full_name||e?.fullname||e?.display_name||e?.name||e?.subject||e?.title||e?.label||e?.code||String(t))}return{fieldName:e,map:r}}).catch(t=>(console.warn(`[RelatedList] Failed to resolve lookups for ${e}:`,t),{fieldName:e,map:{}})))).then(e=>{n||ce(t=>{let n={...t};for(let{fieldName:t,map:r}of e)n[t]={...n[t]||{},...r};return n})}),()=>{n=!0}},[l,ae,D]);let V=Q.useMemo(()=>{if(!re)return D;let e=re.toLowerCase();return D.filter(t=>Object.values(t).some(t=>t!=null&&String(t).toLowerCase().includes(e)))},[D,re]),de=Q.useMemo(()=>N?[...V].sort((e,t)=>{let n=e[N],r=t[N];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}):V,[V,N,I]),H=_&&_>0?_:0,U=H?Math.max(1,Math.ceil(de.length/H)):1,fe=H?de.slice(j*H,(j+1)*H):de;Q.useEffect(()=>{M(0)},[re,N,I]);let pe=Q.useCallback(e=>{N===e?te(e=>e===`asc`?`desc`:`asc`):(P(e),te(`asc`))},[N]),[me,G]=Q.useState(null),he=Q.useCallback(e=>{G(e)},[]),ge=Q.useCallback(()=>{me&&m?.(me),G(null)},[me,m]),K=o(),q=Q.useMemo(()=>{let e=u||n||``,t=t=>!K?.isLoaded||!e?t:t.filter(t=>{let n=t?.accessorKey||t?.field||t?.name;return n?K.checkField(e,String(n),`read`):!0}),r=e=>S?e.filter(e=>(e?.accessorKey||e?.field||e?.name)!==S):e,i=e=>e==null||typeof e==`string`&&e.trim()===``||Array.isArray(e)&&e.length===0,o=e=>D.length?e.filter(e=>{let t=e?.accessorKey||e?.field||e?.name;return t?D.some(e=>!i(e?.[t])):!0}):e,s=(e,t)=>{if(!t?.type)return;let n=Y(dt({type:t.type,format:t.format})||t.type);if(!n)return;let r=t.type===`lookup`||t.type===`master_detail`?z[e]:void 0,i=r&&Object.keys(r).length>0?Object.entries(r).map(([e,t])=>({value:e,label:t})):void 0,a={name:e,label:t.label||e,type:t.type,...(i||t.options)&&{options:i||t.options},...t.currency&&{currency:t.currency},...t.precision!==void 0&&{precision:t.precision},...t.format&&{format:t.format},...(t.reference_to||t.reference)&&{reference_to:t.reference_to||t.reference},...t.reference_field&&{reference_field:t.reference_field}};return e=>e==null?Q.createElement(`span`,{className:`text-muted-foreground/50 text-xs italic`},`—`):Q.createElement(n,{value:e,field:a})},c=t=>{if(typeof t!=`string`){let e=t?.accessorKey||t?.field||t?.name;if(t&&!t.cell&&!t.render&&e){let n=ae?.fields?.[e],r=n?s(String(e),n):void 0;if(r)return{...t,cell:r}}return t}let n=ae?.fields?.[t],r={accessorKey:t,header:n?.label||ue(e,t,n)||t,fieldDef:n,fieldType:n?.type},i=n?s(t,n):void 0;return i&&(r.cell=i),r};if(a&&a.length>0)return o(t(r(a.map(c))));if(!ae?.fields)return[];let l=e,d=new Set([`image`,`file`,`attachment`,`rich_text`,`html`,`json`]),f=[`name`,`full_name`,`fullname`,`title`,`subject`,`label`,`code`,`number`],p=Object.entries(ae.fields).filter(([e,t])=>!(e.startsWith(`_`)||e===`id`||e===S||t?.hidden||t?.type&&d.has(t.type)||K?.isLoaded&&l&&!K.checkField(l,e,`read`)));return p.sort(([e,t],[n,r])=>{let i=f.indexOf(e),a=f.indexOf(n),o=i>=0?i:100,s=a>=0?a:100;if(o!==s)return o-s;let c=t?.type===`select`||e.includes(`status`);return c===(r?.type===`select`||n.includes(`status`))?0:c?-1:1}),o(p.map(([e,t])=>{let n={accessorKey:e,header:ue(l,e,t.label||e)};if(t.type){let r=s(e,t);r&&(n.cell=r)}return n})).slice(0,Math.max(1,g))},[a,ae,u,n,ue,S,D,g,z,K]),_e=!!p||!!m,ve=W(),ye=Q.useMemo(()=>{if(i)return i;if(ve&&(t===`grid`||t===`table`)){let e=q[0]?.accessorKey||q[0]?.field||q[0]?.name,t=q.slice(1,4).map(e=>e.accessorKey||e.field||e.name).filter(Boolean);return{type:`object-gallery`,data:fe,objectName:n,gallery:{titleField:e||`name`,visibleFields:t,cardSize:`medium`},onRowClick:h}}switch(t){case`grid`:case`table`:return{type:`data-table`,data:fe,columns:q,pagination:!1,pageSize:H||10,searchable:!1,exportable:!1,rowActions:_e,onRowEdit:p,onRowDelete:m?he:void 0,onRowClick:h};case`list`:return{type:`data-list`,data:fe};default:return{type:`div`,children:`No view configured`}}},[t,fe,q,i,H,_e,p,m,he,h,ve,n]),be=b?`cursor-pointer select-none`:void 0,xe=b?()=>se(e=>!e):void 0,Se=qn(ee),Ce=!k&&D.length===0,we=y;return(0,$.jsxs)(Ft,{className:Z(`shadow-none border-border/60 bg-transparent`,Ce&&`bg-muted/10`,s),children:[(0,$.jsx)(Re,{className:Z(`py-3 px-4 sm:py-3 min-h-12 sm:min-h-0`,be),onClick:xe,children:(0,$.jsxs)(Ue,{className:`flex items-center justify-between gap-2 text-sm font-semibold`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-2 min-w-0`,children:[b&&(oe?(0,$.jsx)(ke,{className:`h-3.5 w-3.5 text-muted-foreground shrink-0`}):(0,$.jsx)(F,{className:`h-3.5 w-3.5 text-muted-foreground shrink-0`})),(0,$.jsx)(Se,{className:`h-4 w-4 text-muted-foreground shrink-0`,"aria-hidden":!0}),(0,$.jsx)(`span`,{className:Z(`truncate`,Ce&&`text-muted-foreground font-medium`),children:e}),(0,$.jsx)(T,{variant:`secondary`,className:Z(`text-xs font-normal h-5 px-1.5`,D.length===0&&`bg-muted text-muted-foreground`),"aria-label":`${D.length} records`,children:D.length}),Ce&&(0,$.jsx)(`span`,{className:`text-xs text-muted-foreground/70 italic ml-1 truncate`,children:B(`detail.noRelatedRecords`)})]}),(0,$.jsx)(`div`,{className:`flex items-center gap-1 shrink-0`,children:d&&(0,$.jsxs)(X,{variant:Ce?`ghost`:`outline`,size:`sm`,onClick:e=>{e.stopPropagation(),d()},className:`gap-1 h-9 sm:h-7 text-xs shadow-none`,children:[(0,$.jsx)(Ae,{className:`h-3.5 w-3.5`}),B(`detail.new`)]})})]})}),!oe&&!Ce&&(0,$.jsxs)(le,{className:Z(`pt-0 pb-4 px-4`),children:[we&&(0,$.jsx)(`div`,{className:`mb-3`,children:(0,$.jsx)(Dt,{placeholder:B(`detail.filterPlaceholder`),value:re,onChange:e=>ie(e.target.value),className:`h-8 text-sm`})}),v&&q&&q.length>0&&D.length>0&&(0,$.jsx)(`div`,{className:`flex flex-wrap gap-1 mb-3`,children:q.map(e=>{let t=e.accessorKey||e.field||e.name;if(!t)return null;let n=e.header||e.label||t,r=N===t;return(0,$.jsxs)(X,{variant:r?`secondary`:`ghost`,size:`sm`,className:`gap-1 h-7 text-xs`,onClick:()=>pe(t),children:[(0,$.jsx)(ht,{className:`h-3 w-3`}),n,r&&(I===`asc`?` ↑`:` ↓`)]},t)})}),k?(0,$.jsx)(`div`,{className:`flex items-center justify-center py-6 text-muted-foreground text-sm`,children:B(`detail.loading`)}):(0,$.jsx)(c,{schema:ye}),H>0&&de.length>H&&(0,$.jsxs)(`div`,{className:`flex items-center justify-between mt-3 pt-3 border-t`,children:[(0,$.jsxs)(X,{variant:`outline`,size:`sm`,className:`h-7 text-xs gap-1`,disabled:j===0,onClick:()=>M(e=>Math.max(0,e-1)),children:[(0,$.jsx)(ne,{className:`h-3 w-3`}),B(`detail.previousPage`)]}),(0,$.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:B(`detail.pageOf`,{current:j+1,total:U})}),(0,$.jsxs)(X,{variant:`outline`,size:`sm`,className:`h-7 text-xs gap-1`,disabled:j>=U-1,onClick:()=>M(e=>Math.min(U-1,e+1)),children:[B(`detail.nextPage`),(0,$.jsx)(ke,{className:`h-3 w-3`})]})]}),f&&!Ce&&H>0&&de.length>H&&(0,$.jsx)(`div`,{className:`mt-3 pt-3 border-t flex justify-center`,children:(0,$.jsxs)(`button`,{type:`button`,onClick:e=>{e.stopPropagation(),f()},className:`text-xs text-muted-foreground hover:text-foreground inline-flex items-center gap-1 transition-colors`,children:[B(`detail.viewAll`),(0,$.jsx)(R,{className:`h-3 w-3`})]})})]}),(0,$.jsx)(jt,{open:me!==null,onOpenChange:e=>{e||G(null)},children:(0,$.jsxs)(Ct,{children:[(0,$.jsxs)(lt,{children:[(0,$.jsx)(Mt,{children:B(`detail.deleteRowTitle`,{defaultValue:`Delete record`})}),(0,$.jsx)(Jt,{children:B(`detail.deleteRowConfirmation`)})]}),(0,$.jsxs)(it,{children:[(0,$.jsx)(nt,{children:B(`detail.cancel`,{defaultValue:`Cancel`})}),(0,$.jsx)(Ut,{onClick:ge,className:`bg-destructive text-destructive-foreground hover:bg-destructive/90`,children:B(`detail.delete`,{defaultValue:`Delete`})})]})]})})]})},Yn=({group:e,data:t,className:n,objectSchema:r,objectName:i,isEditing:a=!1,onFieldChange:o})=>{let s=e.collapsible??!0,[c,l]=Q.useState(e.defaultCollapsed??!1),u=(0,$.jsx)(`div`,{className:`space-y-3 sm:space-y-4`,children:e.sections.map((e,n)=>(0,$.jsx)(Gn,{section:e,data:t,objectSchema:r,objectName:i,isEditing:a,onFieldChange:o},n))});return s?(0,$.jsxs)(je,{open:!c,onOpenChange:e=>l(!e),className:n,children:[(0,$.jsx)(L,{asChild:!0,children:(0,$.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:[c?(0,$.jsx)(ke,{className:`h-4 w-4 text-muted-foreground shrink-0`}):(0,$.jsx)(F,{className:`h-4 w-4 text-muted-foreground shrink-0`}),e.icon&&(0,$.jsx)(`span`,{className:`text-muted-foreground`,children:e.icon}),(0,$.jsx)(`h3`,{className:`text-lg font-semibold`,children:e.title})]})}),e.description&&!c&&(0,$.jsx)(`p`,{className:`text-sm text-muted-foreground mt-1`,children:e.description}),(0,$.jsx)(Fe,{children:(0,$.jsx)(`div`,{className:`mt-3`,children:u})})]}):(0,$.jsxs)(`div`,{className:Z(`space-y-3`,n),children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-2 pb-2 border-b`,children:[e.icon&&(0,$.jsx)(`span`,{className:`text-muted-foreground`,children:e.icon}),(0,$.jsx)(`h3`,{className:`text-lg font-semibold`,children:e.title})]}),e.description&&(0,$.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:e.description}),u]})},Xn=({fields:e,data:t,className:n,objectName:r,objectSchema:i})=>{let{fieldLabel:a}=Ge();if(!e.length||!t)return null;let o=e.filter(e=>{let n=t?.[e.name];return n!=null&&n!==``});return o.length===0?null:(0,$.jsx)(`section`,{className:Z(`@container border-b border-border/60 pb-4`,n),"aria-label":`Record highlights`,children:(0,$.jsx)(`div`,{className:Z(`flex flex-wrap gap-x-8 gap-y-3`),children:o.map(e=>{let n=t[e.name],o=i?.fields?.[e.name],s=e.type||o?.type,c={name:e.name,label:e.label,type:s||`text`,...o?.options&&{options:o.options},...o?.currency&&{currency:o.currency},...o?.precision!==void 0&&{precision:o.precision},...o?.format&&{format:o.format}},l=Y(dt(c)||s||`text`),u=s===`number`||s===`integer`||s===`currency`||s===`percent`||s===`decimal`,d=s===`email`||s===`url`||s===`textarea`,f=s===`boolean`;return(0,$.jsxs)(`div`,{className:Z(`flex flex-col gap-1 min-w-[8rem] basis-[10rem]`,d?`max-w-[24rem] basis-[16rem]`:`max-w-[16rem]`),children:[(0,$.jsx)(`span`,{className:`text-xs font-medium text-muted-foreground uppercase tracking-wide`,children:a(r||``,e.name,e.label)}),f?n?(0,$.jsxs)(`span`,{className:`inline-flex items-center gap-1 self-start rounded-full bg-emerald-500/10 px-2 py-0.5 text-xs font-medium text-emerald-600 ring-1 ring-inset ring-emerald-500/30 dark:text-emerald-400`,children:[(0,$.jsx)(ge,{className:`h-3 w-3`,"aria-hidden":!0}),`Yes`]}):(0,$.jsxs)(`span`,{className:`inline-flex items-center gap-1 self-start rounded-full bg-amber-500/10 px-2 py-0.5 text-xs font-medium text-amber-700 ring-1 ring-inset ring-amber-500/30 dark:text-amber-400`,children:[(0,$.jsx)(Oe,{className:`h-3 w-3`,"aria-hidden":!0}),`No`]}):(0,$.jsx)(`span`,{className:Z(`block min-w-0 truncate`,u?`text-xl md:text-2xl font-semibold leading-tight tabular-nums tracking-tight`:`text-sm font-semibold`),children:(0,$.jsx)(l,{value:n,field:c})})]},e.name)})})})};function Zn(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 Qn=({comments:e,onAddComment:t,onTogglePin:n,searchable:r=!1,className:i})=>{let{t:a}=Un(),[o,s]=Q.useState(``),[c,l]=Q.useState(!1),[u,d]=Q.useState(``),f=Q.useCallback(async()=>{let e=o.trim();if(!(!e||!t)){l(!0);try{await t(e),s(``)}finally{l(!1)}}},[o,t]),p=Q.useCallback(e=>{e.key===`Enter`&&(e.ctrlKey||e.metaKey)&&(e.preventDefault(),f())},[f]),m=Q.useMemo(()=>[...u.trim()?e.filter(e=>{let t=u.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,u]);return(0,$.jsxs)(Ft,{className:Z(``,i),children:[(0,$.jsx)(Re,{children:(0,$.jsxs)(Ue,{className:`flex items-center gap-2 text-base`,children:[(0,$.jsx)(Ee,{className:`h-4 w-4`}),a(`detail.comments`),(0,$.jsxs)(`span`,{className:`text-sm font-normal text-muted-foreground`,children:[`(`,e.length,`)`]})]})}),(0,$.jsxs)(le,{className:`space-y-4`,children:[r&&(0,$.jsx)(`div`,{className:`flex items-center gap-2`,children:(0,$.jsxs)(`div`,{className:`relative flex-1`,children:[(0,$.jsx)(De,{className:`absolute left-2.5 top-1/2 -translate-y-1/2 h-3.5 w-3.5 text-muted-foreground`}),(0,$.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:a(`detail.searchComments`),value:u,onChange:e=>d(e.target.value),"aria-label":a(`detail.searchComments`)}),u&&(0,$.jsx)(`button`,{className:`absolute right-2 top-1/2 -translate-y-1/2 text-muted-foreground hover:text-foreground`,onClick:()=>d(``),"aria-label":a(`detail.clearSearch`),type:`button`,children:(0,$.jsx)(Oe,{className:`h-3.5 w-3.5`})})]})}),t&&(0,$.jsxs)(`div`,{className:`flex gap-2`,children:[(0,$.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:a(`detail.addCommentPlaceholder`),value:o,onChange:e=>s(e.target.value),onKeyDown:p,disabled:c}),(0,$.jsx)(X,{size:`icon`,variant:`default`,onClick:f,disabled:!o.trim()||c,className:`shrink-0 self-end`,children:(0,$.jsx)(Xt,{className:`h-4 w-4`})})]}),m.length===0?(0,$.jsx)(`p`,{className:`text-sm text-muted-foreground text-center py-4`,children:u.trim()?a(`detail.noMatchingComments`):a(`detail.noCommentsYet`)}):(0,$.jsx)(`div`,{className:`space-y-3`,children:m.map(e=>(0,$.jsxs)(`div`,{className:Z(`flex gap-3`,e.pinned&&`bg-muted/40 rounded-md p-2 -mx-2`),children:[(0,$.jsx)(`div`,{className:`shrink-0`,children:e.avatarUrl?(0,$.jsx)(`img`,{src:e.avatarUrl,alt:e.author,className:`h-8 w-8 rounded-full object-cover`}):(0,$.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,$.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-2 mb-0.5`,children:[(0,$.jsx)(`span`,{className:`text-sm font-medium truncate`,children:e.author}),(0,$.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:Zn(e.createdAt)}),e.pinned&&(0,$.jsxs)(`span`,{className:`text-xs text-amber-600 flex items-center gap-0.5`,children:[(0,$.jsx)(ue,{className:`h-3 w-3`}),a(`detail.pinned`)]})]}),(0,$.jsx)(`p`,{className:`text-sm whitespace-pre-wrap break-words`,children:e.text}),n&&(0,$.jsxs)(`button`,{type:`button`,className:`mt-1 text-xs text-muted-foreground hover:text-foreground flex items-center gap-1`,onClick:()=>n(e.id),"aria-label":e.pinned?a(`detail.unpin`):a(`detail.pin`),children:[(0,$.jsx)(ue,{className:`h-3 w-3`}),e.pinned?a(`detail.unpin`):a(`detail.pin`)]})]})]},e.id))})]})]})},$n={field_change:Je,create:ut,delete:Ne,comment:Ee,status_change:At},er={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 tr(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 nr(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 rr={all:`All`,field_change:`Field Changes`,create:`Creates`,delete:`Deletes`,comment:`Comments`,status_change:`Status Changes`},ir=({activities:e,filterable:t=!1,defaultFilter:n=`all`,className:r})=>{let[i,a]=Q.useState(n),o=Q.useMemo(()=>i===`all`?e:e.filter(e=>e.type===i),[e,i]);return(0,$.jsxs)(Ft,{className:Z(``,r),children:[(0,$.jsx)(Re,{children:(0,$.jsxs)(Ue,{className:`flex items-center gap-2 text-base`,children:[(0,$.jsx)(ct,{className:`h-4 w-4`}),`Activity`,(0,$.jsxs)(`span`,{className:`text-sm font-normal text-muted-foreground`,children:[`(`,o.length,`)`]})]})}),(0,$.jsxs)(le,{children:[t&&(0,$.jsx)(`div`,{className:`flex flex-wrap gap-1.5 mb-4`,role:`group`,"aria-label":`Activity type filter`,children:Object.keys(rr).map(e=>(0,$.jsxs)(`button`,{type:`button`,className:Z(`inline-flex items-center gap-1 rounded-full px-2.5 py-0.5 text-xs font-medium transition-colors`,i===e?`bg-primary text-primary-foreground`:`bg-muted text-muted-foreground hover:bg-muted/80`),onClick:()=>a(e),"aria-pressed":i===e,children:[e!==`all`&&Q.createElement($n[e]||Je,{className:`h-3 w-3`}),rr[e]]},e))}),o.length===0?(0,$.jsx)(de,{title:`No activity recorded`,className:`py-6`}):(0,$.jsxs)(`div`,{className:`relative`,children:[(0,$.jsx)(`div`,{className:`absolute left-4 top-2 bottom-2 w-px bg-border`}),(0,$.jsx)(`div`,{className:`space-y-4`,children:o.map(e=>{let t=$n[e.type]||Je;return(0,$.jsxs)(`div`,{className:`flex gap-3 relative`,children:[(0,$.jsx)(`div`,{className:Z(`shrink-0 h-8 w-8 rounded-full flex items-center justify-center z-10`,er[e.type]||`bg-gray-100 text-gray-600`),children:(0,$.jsx)(t,{className:`h-3.5 w-3.5`})}),(0,$.jsxs)(`div`,{className:`flex-1 min-w-0 pt-1`,children:[(0,$.jsxs)(`p`,{className:`text-sm`,children:[(0,$.jsx)(`span`,{className:`font-medium`,children:e.user}),` `,(0,$.jsx)(`span`,{className:`text-muted-foreground`,children:nr(e)})]}),(0,$.jsx)(`p`,{className:`text-xs text-muted-foreground mt-0.5`,children:tr(e.timestamp)})]})]},e.id)})})]})]})]})},ar={create:`default`,update:`secondary`,delete:`destructive`,restore:`outline`,login:`outline`,logout:`outline`,permission_change:`secondary`,config_change:`secondary`,export:`outline`,import:`outline`};function or(e){if(!e)return``;let t=e instanceof Date?e:new Date(e);return Number.isNaN(t.getTime())?String(e):t.toLocaleString()}var sr=[[60,`second`],[60,`minute`],[24,`hour`],[7,`day`],[4.34524,`week`],[12,`month`],[1/0,`year`]];function cr(e,t){if(!e)return``;let n=e instanceof Date?e:new Date(e);if(Number.isNaN(n.getTime()))return String(e);let r=(n.getTime()-Date.now())/1e3;for(let[n,i]of sr){if(Math.abs(r)<n)try{return new Intl.RelativeTimeFormat(t,{numeric:`auto`}).format(Math.round(r),i)}catch{return or(e)}r/=n}return or(e)}function lr(e){if(!e)return`?`;let t=e.trim().split(/\s+/).filter(Boolean).slice(0,2);return t.length===0?`?`:t.map(e=>e.charAt(0).toUpperCase()).join(``)}function ur(e){if(e==null||e===``)return`—`;if(typeof e==`string`)return e;if(typeof e==`number`||typeof e==`boolean`)return String(e);try{return JSON.stringify(e)}catch{return String(e)}}function dr({entries:e,loading:t,emptyText:n,className:r,locale:i}){return t?(0,$.jsx)(`div`,{className:Z(`space-y-3`,r),children:Array.from({length:4}).map((e,t)=>(0,$.jsxs)(`div`,{className:`flex items-start gap-3`,children:[(0,$.jsx)(U,{className:`h-8 w-8 rounded-full`}),(0,$.jsxs)(`div`,{className:`flex-1 space-y-2`,children:[(0,$.jsx)(U,{className:`h-4 w-1/3`}),(0,$.jsx)(U,{className:`h-3 w-1/2`})]})]},t))}):!e||e.length===0?(0,$.jsx)(`div`,{className:Z(`flex items-center justify-center rounded-md border border-dashed py-10 text-sm text-muted-foreground`,r),children:n??`No history yet`}):(0,$.jsx)(O,{delayDuration:150,children:(0,$.jsx)(`ol`,{className:Z(`space-y-4`,r),children:e.map((e,t)=>{let n=(e.action??``).toLowerCase(),r=ar[n]??`outline`,a=typeof e.user_name==`string`&&e.user_name.trim()||`Unknown user`,o=or(e.created_at),s=cr(e.created_at,i),c=typeof e.user_avatar==`string`?e.user_avatar:void 0;return(0,$.jsxs)(`li`,{className:`flex items-start gap-3`,children:[(0,$.jsxs)(st,{className:`h-8 w-8 mt-0.5 shrink-0`,children:[c?(0,$.jsx)(Ot,{src:c,alt:a}):null,(0,$.jsx)(Gt,{className:`text-[10px] font-medium`,children:lr(e.user_name)})]}),(0,$.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,$.jsxs)(`div`,{className:`flex flex-wrap items-baseline gap-x-2 gap-y-1`,children:[(0,$.jsx)(`span`,{className:`text-sm font-medium text-foreground`,children:a}),e.action&&(0,$.jsx)(T,{variant:r,className:`text-[10px] uppercase tracking-wide`,children:e.action}),o&&(0,$.jsxs)(K,{children:[(0,$.jsx)(yt,{asChild:!0,children:(0,$.jsx)(`span`,{className:`text-xs text-muted-foreground cursor-help`,"aria-label":o,children:s||o})}),(0,$.jsx)(xt,{children:o})]})]}),e.summary&&(0,$.jsx)(`p`,{className:`mt-1 text-sm text-muted-foreground`,children:e.summary}),e.changes&&e.changes.length>0&&(n===`create`?(0,$.jsxs)(`details`,{className:`mt-1 group`,children:[(0,$.jsxs)(`summary`,{className:`cursor-pointer list-none text-xs text-muted-foreground hover:text-foreground inline-flex items-center gap-1 select-none`,children:[(0,$.jsx)(`span`,{className:`transition-transform group-open:rotate-90`,children:`▸`}),(0,$.jsx)(`span`,{children:e.changes.length===1?`1 field populated`:`${e.changes.length} fields populated`})]}),(0,$.jsx)(`ul`,{className:`mt-1.5 space-y-0.5 text-xs text-muted-foreground pl-4`,children:e.changes.map(e=>(0,$.jsxs)(`li`,{className:`leading-relaxed`,children:[(0,$.jsx)(`span`,{className:`font-medium text-foreground`,children:e.label||e.field}),`: `,(0,$.jsx)(`span`,{className:`text-foreground`,children:ur(e.to)})]},e.field))})]}):(0,$.jsx)(`ul`,{className:`mt-1.5 space-y-0.5 text-xs text-muted-foreground`,children:e.changes.map(e=>(0,$.jsxs)(`li`,{className:`leading-relaxed`,children:[(0,$.jsx)(`span`,{className:`font-medium text-foreground`,children:e.label||e.field}),`: `,(0,$.jsx)(`span`,{className:`line-through opacity-70`,children:ur(e.from)}),` → `,(0,$.jsx)(`span`,{className:`text-foreground`,children:ur(e.to)})]},e.field))}))]})]},e.id??t)})})})}var fr={createdAt:`created_at`,createdBy:`created_by`,updatedAt:`updated_at`,updatedBy:`updated_by`};function pr(e){if(!e)return null;if(e instanceof Date)return isNaN(e.getTime())?null:e;if(typeof e==`string`||typeof e==`number`){let t=new Date(e);return isNaN(t.getTime())?null:t}return null}function mr(e,t){let n=Date.now()-e.getTime(),r=Math.max(0,Math.floor(n/1e3));if(r<60)return t(`detail.justNow`);let i=Math.floor(r/60);if(i<60)return t(`detail.minutesAgo`,{count:i});let a=Math.floor(i/60);return a<24?t(`detail.hoursAgo`,{count:a}):t(`detail.daysAgo`,{count:Math.floor(a/24)})}function hr(e){try{return new Intl.DateTimeFormat(void 0,{dateStyle:`medium`,timeStyle:`short`}).format(e)}catch{return e.toISOString()}}var gr=({value:e,objectSchema:t,fieldName:n})=>{if(e==null||e===``)return null;let r=t?.fields?.[n],i=r?.reference_to||r?.reference,a={name:n,type:r?.type||(i?`lookup`:`text`),...i&&{reference_to:i},...r?.reference_field&&{reference_field:r.reference_field}},o=dt(a)||a.type;if(o){let t=Y(o);if(t)return(0,$.jsx)(`span`,{className:`inline-flex items-center [&_a]:text-inherit [&_a]:hover:underline`,children:(0,$.jsx)(t,{value:e,field:a})})}return(0,$.jsx)(`span`,{children:String(e)})},_r=({label:e,user:t,date:n,objectSchema:r,userField:i,t:a})=>{if(!t&&!n)return null;let o=n?(0,$.jsx)(O,{delayDuration:200,children:(0,$.jsxs)(K,{children:[(0,$.jsx)(yt,{asChild:!0,children:(0,$.jsx)(`time`,{dateTime:n.toISOString(),className:`cursor-default underline decoration-dotted decoration-muted-foreground/40 underline-offset-2`,children:mr(n,a)})}),(0,$.jsx)(xt,{side:`top`,children:hr(n)})]})}):null;return(0,$.jsxs)(`span`,{className:`inline-flex items-center gap-1.5`,children:[(0,$.jsx)(`span`,{className:`text-muted-foreground/70`,children:e}),t?(0,$.jsx)(gr,{value:t,objectSchema:r,fieldName:i}):null,t&&o?(0,$.jsx)(`span`,{className:`text-muted-foreground/40`,children:`·`}):null,o]})},vr=({data:e,objectSchema:t,objectName:n,className:r})=>{let{t:i}=Un();if(!e)return null;let a=pr(e[fr.createdAt]),o=pr(e[fr.updatedAt]),s=e[fr.createdBy],c=e[fr.updatedBy],l=!!(a||s),u=a&&o&&Math.abs(o.getTime()-a.getTime())<2e3,d=!!(o||c)&&!(u&&(s!=null&&c!=null&&String(s)===String(c)||!c));return!l&&!d?null:(0,$.jsxs)(`div`,{className:Z(`mt-6 pt-3 border-t border-border/40`,`flex flex-wrap items-center gap-x-4 gap-y-1`,`text-xs text-muted-foreground`,r),"data-testid":`record-meta-footer`,children:[l&&(0,$.jsx)(_r,{label:i(`detail.createdBy`),user:s,date:a,objectSchema:t,userField:fr.createdBy,t:i}),d&&(0,$.jsx)(_r,{label:i(`detail.updatedBy`),user:c,date:o,objectSchema:t,userField:fr.updatedBy,t:i})]})},yr=5;function br(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=String(r).trim().split(`.`),a=e;for(let e of i){if(a==null)break;a=a[e]}if(a&&typeof a==`object`){let e=a,t=e.name??e.full_name??e.display_name??e.label??e.title??e.subject??null;(t==null||typeof t==`string`&&!t.trim())&&(t=[e.salutation,e.first_name,e.last_name].filter(e=>typeof e==`string`&&e.trim()).map(e=>e.trim()).join(` `)||(typeof e.email==`string`&&e.email.trim()?e.email.trim():null)),a=t}return a!=null&&a!==``?(n=!0,String(a)):`\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 xr=({schema:e,dataSource:t,className:n,onEdit:r,onDelete:i,onBack:a,inlineEdit:s=!1,onFieldSave:l,discussionSlot:u,rightRail:d,objectLabel:f,onDataLoaded:p,isFavorite:m,onToggleFavorite:h})=>{let[g,_]=Q.useState(e.data),[v,y]=Q.useState(!e.data&&!!(e.api&&e.resourceId||t&&e.objectName&&e.resourceId)),[b,x]=Q.useState(!1),S=m??b,[C,w]=Q.useState(!1),[E,D]=Q.useState({}),[k,A]=Q.useState(!1),[j,M]=Q.useState(null),[N,P]=Q.useState(null),[F,I]=Q.useState(!1),[te,re]=Q.useState(0),[ie,ae]=Q.useState(!1),{t:L}=Un(),{fieldOptionLabel:oe}=Ge(),se=W(),R=o(),z=Q.useMemo(()=>{if(!R?.isLoaded||!e.objectName)return e;let t=t=>R.checkField(e.objectName,t,`read`),n=e=>e&&e.filter(e=>{let n=typeof e==`string`?e:e?.name;return!n||t(n)});return{...e,fields:n(e.fields),sections:e.sections?.map(e=>({...e,fields:n(e.fields)})),summaryFields:n(e.summaryFields)}},[e,R]);Q.useEffect(()=>{g&&p&&p(g)},[g,p]);let ce=Q.useMemo(()=>{if(z.summaryFields&&z.summaryFields.length>0)return[];let e=[...z.sections?.flatMap(e=>e.fields)||[],...z.fields||[]],t={};for(let n of e)t[n.name]||(t[n.name]=n);if(N?.fields)for(let[e,n]of Object.entries(N.fields))t[e]={...t[e]||{},...n,name:e};let n=e=>g?.[e]!==void 0&&g?.[e]!==null&&g?.[e]!==``,r=[],i=[`status`,`stage`,`state`,`phase`].find(e=>t[e]&&n(e))||Object.keys(t).find(e=>t[e]?.type===`select`&&n(e));i&&r.push(i);let a=Object.keys(t).find(e=>(t[e]?.type===`currency`||/amount|revenue|value|total|price/i.test(e))&&n(e));a&&!r.includes(a)&&r.push(a);let o=Object.keys(t).find(e=>(t[e]?.type===`date`||t[e]?.type===`datetime`)&&/close|due|start|end|expected/i.test(e)&&n(e));return o&&!r.includes(o)&&r.push(o),r},[z.summaryFields,z.sections,z.fields,N,g]),le=z.summaryFields&&z.summaryFields.length>0?z.summaryFields:ce,B=Q.useCallback(()=>{z.resourceId&&navigator.clipboard.writeText(String(z.resourceId)).then(()=>{I(!0),setTimeout(()=>I(!1),1500)})},[z.resourceId]);Q.useEffect(()=>{let e=!0;if(z.data)return _(z.data),y(!1),t?.getObjectSchema&&z.objectName&&t.getObjectSchema(z.objectName).then(t=>{e&&P(t)}).catch(()=>{}),()=>{e=!1};if(t&&z.objectName&&z.resourceId){y(!0),P(null),_(null);let n=z.objectName,r=z.resourceId,i=`${n}-`,a=[...z.sections?.flatMap(e=>e.fields)||[],...z.fields||[]];(t.getObjectSchema?t.getObjectSchema(n).catch(()=>null):Promise.resolve(null)).then(o=>{if(!e)return;P(o);let s=ee(o?.fields,a),c=s.length>0?{$expand:s}:void 0,l=c?t.findOne(n,r,c):t.findOne(n,r),u=()=>{let a=String(r),o=a.startsWith(i)?a.slice(i.length):`${i}${a}`;return(c?t.findOne(n,o,c):t.findOne(n,o)).then(t=>{e&&(_(t),y(!1))}).catch(()=>{e&&(_(null),y(!1))})};return l.catch(()=>null).then(t=>{if(e){if(t){_(t),y(!1);return}return u()}})}).catch(t=>{e&&(console.error(`Failed to fetch detail data:`,t),y(!1))})}else z.api&&z.resourceId&&(y(!0),fetch(`${z.api}/${z.resourceId}`).then(e=>e.json()).then(t=>{e&&_(t?.data||t)}).catch(e=>{console.error(`Failed to fetch detail data:`,e)}).finally(()=>{e&&y(!1)}));return()=>{e=!1}},[z.api,z.resourceId,z.objectName,t,z.sections,z.fields,te]);let ue=Q.useCallback(()=>{if(a)a();else if(z.onNavigate){let e=z.backUrl||(z.objectName?`/${z.objectName}`:`/`);z.onNavigate(e,{replace:!0})}else z.backUrl?window.location.href=z.backUrl:window.history.back()},[a,z]),V=Q.useCallback(()=>{r?r():z.onNavigate&&z.editUrl?z.onNavigate(z.editUrl):z.onNavigate&&z.objectName&&z.resourceId?z.onNavigate(`/${z.objectName}/${z.resourceId}/edit`):z.editUrl&&(window.location.href=z.editUrl)},[r,z]),de=Q.useCallback(async()=>{if(!t?.cancelPendingApproval||!z.objectName||!z.resourceId){M(L(`detail.cancelApprovalUnavailable`));return}ae(!0),M(null);try{if(await t.cancelPendingApproval(String(z.objectName),String(z.resourceId)),t.findOne)try{let e=await t.findOne(String(z.objectName),String(z.resourceId));e&&_(e)}catch{}re(e=>e+1);try{window.dispatchEvent(new CustomEvent(`objectui:record-changed`,{detail:{objectName:String(z.objectName),recordId:String(z.resourceId),reason:`approval-recalled`}}))}catch{}}catch(e){let t=(e?.message||e?.error||String(e??`Cancel failed`)).replace(/^\[[^\]]+\]\s*/,``).replace(/^[A-Z][A-Z0-9_]+:\s*/,``);M(`${L(`detail.cancelApprovalFailed`)}: ${t}`)}finally{ae(!1)}},[t,z.objectName,z.resourceId,L]),H=Q.useCallback(()=>{let e=z.deleteConfirmation||L(`detail.deleteConfirmation`);window.confirm(e)&&(i?.(),z.onNavigate&&z.objectName&&z.onNavigate(`/${z.objectName}`,{replace:!0}))},[i,z]),fe=Q.useCallback(()=>{navigator.share&&z.objectName&&z.resourceId?navigator.share({title:z.title||L(`detail.details`),text:`${z.objectName} #${z.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`)})},[z]),pe=Q.useCallback(()=>{let e=!S;h&&h(e),m===void 0&&x(e)},[S,m,h]),me=Q.useCallback(async()=>{if(C){let e=Object.entries(E);if(e.length>0){let t=g,n={...g,...E};_(n),M(null),A(!0);try{if(l)for(let[t,r]of e)await l(t,r,n);D({}),w(!1)}catch(e){_(t),M((e?.message||e?.error||String(e??`Save failed`)).replace(/^\[[^\]]+\]\s*/,``).replace(/^[A-Z][A-Z0-9_]+:\s*/,``))}finally{A(!1)}return}D({})}w(!C),M(null)},[C,E,g,l]),G=Q.useCallback(()=>{D({}),w(!1),M(null)},[]),he=Q.useCallback((e,t)=>{D(n=>({...n,[e]:t}))},[]);Q.useEffect(()=>{if(!z.recordNavigation)return;let e=z.recordNavigation,t=t=>{let n=t.target?.tagName;n===`INPUT`||n===`TEXTAREA`||t.target?.isContentEditable||(t.key===`ArrowLeft`&&e.currentIndex>0?(t.preventDefault(),e.onNavigate(e.recordIds[e.currentIndex-1])):t.key===`ArrowRight`&&e.currentIndex<e.recordIds.length-1&&(t.preventDefault(),e.onNavigate(e.recordIds[e.currentIndex+1])))};return document.addEventListener(`keydown`,t),()=>document.removeEventListener(`keydown`,t)},[z.recordNavigation]),Q.useEffect(()=>{if(!s||z.showHeader!==!1)return;let e=`objectui:record:inline-edit-toggle`,t=e=>{let t=e.detail;t?.recordId&&z.recordId&&t.recordId!==z.recordId||t?.objectName&&z.objectName&&t.objectName!==z.objectName||me()};return window.addEventListener(e,t),()=>window.removeEventListener(e,t)},[s,z.showHeader,z.recordId,z.objectName,me]);let q=Q.useMemo(()=>z.related??[],[z.related]),_e=Q.useMemo(()=>{let e=[];return e.push({name:`sys_share`,label:L(`detail.share`),icon:`share-2`,type:`script`,onClick:fe}),z.showEdit&&e.push({name:`sys_edit_mobile`,label:L(`detail.edit`),icon:`edit`,type:`script`,className:`sm:hidden`,onClick:V}),s&&e.push({name:`sys_toggle_inline_edit_mobile`,label:L(C?`detail.save`:`detail.editInline`),icon:`edit`,type:`script`,className:`sm:hidden`,onClick:me}),z.showDelete&&e.push({name:`sys_delete`,label:L(`detail.delete`),icon:`trash-2`,type:`script`,variant:`destructive`,tags:[`separator-before`],onClick:H}),e},[L,z.showEdit,z.showDelete,s,C,fe,V,me,H]),ve=Q.useMemo(()=>{let e=z.actions??[];if(_e.length===0)return e;let t=!1,n=e.map(e=>{let n=e;if(n&&typeof n==`object`&&n.type===`action:bar`&&(!n.location||n.location===`record_header`)){t=!0;let e=Array.isArray(n.systemActions)?n.systemActions:[];return{...n,systemActions:[...e,..._e]}}return e});return t||n.push({type:`action:bar`,location:`record_header`,systemActions:_e}),n},[z.actions,_e]);return v||z.loading?(0,$.jsxs)(`div`,{className:Z(`space-y-4`,n),children:[(0,$.jsx)(U,{className:`h-10 w-full`}),(0,$.jsx)(U,{className:`h-64 w-full`}),(0,$.jsx)(U,{className:`h-48 w-full`})]}):!g&&!z.data?(0,$.jsxs)(`div`,{className:Z(`flex flex-col items-center justify-center py-16 text-center`,n),children:[(0,$.jsx)(`p`,{className:`text-lg font-semibold`,children:L(`detail.recordNotFound`)}),(0,$.jsx)(`p`,{className:`text-sm text-muted-foreground mt-1`,children:L(`detail.recordNotFoundDescription`)}),(z.showBack??!0)&&(0,$.jsxs)(X,{variant:`outline`,size:`sm`,onClick:ue,className:`mt-4 gap-2`,children:[(0,$.jsx)(Bt,{className:`h-4 w-4`}),L(`detail.goBack`)]})]}):(0,$.jsx)(O,{children:(0,$.jsxs)(`div`,{className:Z(`space-y-6`,n),children:[z.showHeader!==!1&&(0,$.jsxs)(`div`,{className:`flex flex-col sm:flex-row items-start justify-between gap-3 sm:gap-4 pb-4 border-b`,children:[(0,$.jsxs)(`div`,{className:`flex items-start gap-2 sm:gap-3 flex-1 min-w-0`,children:[(z.showBack??!0)&&(0,$.jsxs)(K,{children:[(0,$.jsx)(yt,{asChild:!0,children:(0,$.jsx)(X,{variant:`ghost`,size:`icon`,onClick:ue,className:`shrink-0 mt-1`,children:(0,$.jsx)(Bt,{className:`h-4 w-4`})})}),(0,$.jsx)(xt,{children:L(`detail.back`)})]}),(0,$.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-2 flex-wrap`,children:[(0,$.jsx)(`h1`,{className:`text-xl sm:text-2xl font-bold truncate`,children:br(g,z,N,L(`detail.details`))}),le.map(e=>{let t=g?.[e];if(t==null||t===``)return null;let n=(z.sections||[]).flatMap(e=>e.fields).concat(z.fields||[]).find(t=>t.name===e),r=N?.fields?.[e],i=n?.type||r?.type,a=String(t),o=null;try{if(i===`currency`){let e=Number(t);if(!Number.isNaN(e)){let t=n?.currency||r?.currency;a=t?new Intl.NumberFormat(void 0,{style:`currency`,currency:t,maximumFractionDigits:0}).format(e):new Intl.NumberFormat(void 0,{maximumFractionDigits:0}).format(e)}}else if(i===`date`||i===`datetime`){let e=new Date(t);Number.isNaN(e.getTime())||(a=i===`datetime`?e.toLocaleString(void 0,{dateStyle:`medium`,timeStyle:`short`}):e.toLocaleDateString(void 0,{dateStyle:`medium`}))}else if(i===`percent`){let e=Number(t);if(!Number.isNaN(e)){a=`${e}%`;let t=e<=1?e*100:e;o=Math.max(0,Math.min(100,t))}}else if(i===`select`||i===`status`||i===`multiselect`){let i=n?.options||r?.options,o=String(t);if(Array.isArray(i)){let e=i.find(e=>String(e?.value??e)===String(t));e?.label&&(o=e.label)}else if(i&&typeof i==`object`){let e=i[String(t)];e?.label&&(o=e.label)}a=z.objectName?oe(z.objectName,e,String(t),o):o}}catch{}return o===null?(0,$.jsx)(T,{variant:`secondary`,className:`text-xs bg-primary/10 text-primary border-transparent hover:bg-primary/15`,"aria-label":`${e}: ${a}`,children:a},e):(0,$.jsxs)(T,{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":`${e}: ${a}`,children:[(0,$.jsx)(`span`,{className:`relative inline-block h-1.5 w-12 rounded-full bg-primary/20 overflow-hidden`,"aria-hidden":!0,children:(0,$.jsx)(`span`,{className:`absolute inset-y-0 left-0 rounded-full bg-primary`,style:{width:`${o}%`}})}),a]},e)}),(0,$.jsxs)(K,{children:[(0,$.jsx)(yt,{asChild:!0,children:(0,$.jsx)(X,{variant:`ghost`,size:`icon`,className:`h-6 w-6 shrink-0`,onClick:pe,"aria-label":L(S?`detail.removeFromFavorites`:`detail.addToFavorites`),children:S?(0,$.jsx)(Et,{className:`h-4 w-4 fill-yellow-400 text-yellow-400`}):(0,$.jsx)(Et,{className:`h-4 w-4 text-muted-foreground`})})}),(0,$.jsx)(xt,{children:L(S?`detail.removeFromFavorites`:`detail.addToFavorites`)})]})]}),z.objectName&&(0,$.jsxs)(`p`,{className:`text-sm text-muted-foreground mt-1 flex items-center gap-1`,children:[(0,$.jsx)(`span`,{className:`font-medium`,children:f||z.objectName}),z.resourceId&&(0,$.jsxs)(K,{children:[(0,$.jsx)(yt,{asChild:!0,children:(0,$.jsx)(X,{variant:`ghost`,size:`icon`,className:`h-5 w-5 shrink-0 text-muted-foreground/60 hover:text-foreground`,onClick:B,"aria-label":L(`detail.copyRecordId`,{defaultValue:`Copy record ID`}),children:F?(0,$.jsx)(ge,{className:`h-3 w-3 text-green-600`}):(0,$.jsx)(Ve,{className:`h-3 w-3`})})}),(0,$.jsx)(xt,{children:F?L(`detail.copied`,{defaultValue:`Copied`}):L(`detail.copyRecordId`,{defaultValue:`Copy record ID`})})]})]})]})]}),(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center gap-1.5 shrink-0 w-full sm:w-auto`,children:[z.recordNavigation&&(0,$.jsxs)(`div`,{className:`flex items-center gap-1 mr-2`,children:[(0,$.jsxs)(K,{children:[(0,$.jsx)(yt,{asChild:!0,children:(0,$.jsx)(X,{variant:`outline`,size:`icon`,className:`h-8 w-8`,disabled:z.recordNavigation.currentIndex<=0,onClick:()=>{let e=z.recordNavigation;e.currentIndex>0&&e.onNavigate(e.recordIds[e.currentIndex-1])},children:(0,$.jsx)(ne,{className:`h-4 w-4`})})}),(0,$.jsx)(xt,{children:L(`detail.previousRecord`)})]}),(0,$.jsx)(`span`,{className:`text-xs text-muted-foreground whitespace-nowrap px-1`,children:L(`detail.recordOf`,{current:z.recordNavigation.currentIndex+1,total:z.recordNavigation.recordIds.length})}),(0,$.jsxs)(K,{children:[(0,$.jsx)(yt,{asChild:!0,children:(0,$.jsx)(X,{variant:`outline`,size:`icon`,className:`h-8 w-8`,disabled:z.recordNavigation.currentIndex>=z.recordNavigation.recordIds.length-1,onClick:()=>{let e=z.recordNavigation;e.currentIndex<e.recordIds.length-1&&e.onNavigate(e.recordIds[e.currentIndex+1])},children:(0,$.jsx)(ke,{className:`h-4 w-4`})})}),(0,$.jsx)(xt,{children:L(`detail.nextRecord`)})]})]}),s&&(0,$.jsxs)($.Fragment,{children:[C&&(0,$.jsxs)(K,{children:[(0,$.jsx)(yt,{asChild:!0,children:(0,$.jsxs)(X,{variant:`ghost`,size:`sm`,onClick:G,className:`gap-2 hidden sm:inline-flex`,children:[(0,$.jsx)(Oe,{className:`h-4 w-4`}),(0,$.jsx)(`span`,{className:`hidden sm:inline`,children:L(`detail.cancel`)})]})}),(0,$.jsx)(xt,{children:L(`detail.cancelEdit`)})]}),(0,$.jsxs)(K,{children:[(0,$.jsx)(yt,{asChild:!0,children:(0,$.jsx)(X,{variant:C?`default`:`outline`,size:`sm`,onClick:me,className:`gap-2 hidden sm:inline-flex`,children:C?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(ge,{className:`h-4 w-4`}),(0,$.jsx)(`span`,{className:`hidden sm:inline`,children:L(`detail.save`)})]}):(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(Je,{className:`h-4 w-4`}),(0,$.jsx)(`span`,{className:`hidden sm:inline`,children:L(`detail.editInline`)})]})})}),(0,$.jsx)(xt,{children:L(C?`detail.saveChanges`:`detail.editFieldsInline`)})]})]}),z.showEdit&&(0,$.jsxs)(K,{children:[(0,$.jsx)(yt,{asChild:!0,children:(0,$.jsxs)(X,{variant:`default`,onClick:V,className:`gap-2 hidden sm:inline-flex`,children:[(0,$.jsx)(Je,{className:`h-4 w-4`}),(0,$.jsx)(`span`,{className:`hidden sm:inline`,children:L(`detail.edit`)})]})}),(0,$.jsx)(xt,{children:L(`detail.editRecord`)})]}),ve.map((e,t)=>(0,$.jsx)(c,{schema:e,data:g},`header-action-${t}`))]})]}),z.header&&(0,$.jsx)(`div`,{children:(0,$.jsx)(c,{schema:z.header,data:g})}),z.highlightFields&&z.highlightFields.length>0&&(0,$.jsx)(Xn,{fields:z.highlightFields,data:g,objectName:z.objectName,objectSchema:N}),s&&z.showHeader===!1&&(()=>{let e=g?.approval_status,n=e===`pending`||e===`in_approval`;return!C&&!k&&!j&&!n?null:(0,$.jsxs)(`div`,{className:`flex flex-col items-end gap-1`,children:[(0,$.jsxs)(`div`,{className:`flex items-center justify-end gap-2`,children:[n&&!C&&(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(`span`,{role:`status`,className:`inline-flex items-center gap-1 rounded-md border border-amber-300 bg-amber-50 px-2 py-1 text-xs text-amber-800`,title:L(`detail.lockedTooltip`),children:[(0,$.jsx)(vt,{className:`h-3 w-3`}),(0,$.jsx)(`span`,{children:L(`detail.lockedByApproval`)})]}),t?.cancelPendingApproval&&(0,$.jsxs)(X,{variant:`outline`,size:`sm`,onClick:de,disabled:ie,className:`gap-2 border-amber-300 text-amber-800 hover:bg-amber-50`,title:L(`detail.cancelApprovalTooltip`),children:[(0,$.jsx)(Oe,{className:`h-4 w-4`}),(0,$.jsx)(`span`,{children:L(ie?`detail.cancelApprovalInFlight`:`detail.cancelApproval`)})]})]}),C&&(0,$.jsxs)(X,{variant:`ghost`,size:`sm`,onClick:G,className:`gap-2`,disabled:k,children:[(0,$.jsx)(Oe,{className:`h-4 w-4`}),(0,$.jsx)(`span`,{children:L(`detail.cancel`)})]}),(0,$.jsxs)(X,{variant:C?`default`:`outline`,size:`sm`,onClick:me,className:`gap-2`,disabled:k||n&&!C,title:n&&!C?L(`detail.lockedTooltip`):void 0,children:[C?(0,$.jsx)(ge,{className:`h-4 w-4`}):(0,$.jsx)(Je,{className:`h-4 w-4`}),(0,$.jsx)(`span`,{children:L(k?`detail.saving`:C?`detail.save`:`detail.editFieldsInline`)})]})]}),j&&(0,$.jsx)(`div`,{role:`alert`,className:`text-xs text-destructive bg-destructive/10 border border-destructive/20 rounded-md px-2 py-1 max-w-md text-right`,children:j})]})})(),z.autoTabs&&!z.tabs?.length?(()=>{let e=q.length>0,n=!!z.activities&&z.activities.length>0,r=!!u,i=!!z.history,a=(0,$.jsxs)(`div`,{className:`space-y-3 sm:space-y-4`,children:[z.sectionGroups&&z.sectionGroups.length>0&&z.sectionGroups.map((e,t)=>(0,$.jsx)(Yn,{group:e,data:{...g,...E},objectSchema:N,objectName:z.objectName,isEditing:C,onFieldChange:he},t)),z.sections&&z.sections.length>0&&z.sections.map((e,t)=>(0,$.jsx)(Gn,{section:e,data:{...g,...E},objectSchema:N,objectName:z.objectName,isEditing:C,onFieldChange:he},t)),z.fields&&z.fields.length>0&&!z.sections?.length&&(0,$.jsx)(Gn,{section:{fields:z.fields,columns:z.columns},data:{...g,...E},objectSchema:N,objectName:z.objectName,isEditing:C,onFieldChange:he}),z.comments&&(0,$.jsx)(Qn,{comments:z.comments,onAddComment:z.onAddComment})]});return!e&&!n&&!r&&!i?(0,$.jsx)(`div`,{className:`mt-2`,children:a}):(0,$.jsxs)(kt,{defaultValue:`details`,className:`w-full`,children:[(0,$.jsxs)(_t,{className:`w-full justify-start border-b rounded-none bg-transparent p-0`,children:[(0,$.jsx)(Ze,{value:`details`,className:`relative rounded-none border-b-2 border-transparent data-[state=active]:border-primary data-[state=active]:bg-transparent`,children:L(`detail.details`)}),e&&(0,$.jsx)(Ze,{value:`related`,className:`relative rounded-none border-b-2 border-transparent data-[state=active]:border-primary data-[state=active]:bg-transparent`,children:(0,$.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[L(`detail.related`),(0,$.jsx)(T,{variant:`secondary`,className:`text-xs bg-primary/10 text-primary border-transparent`,children:q.length})]})}),n&&(0,$.jsx)(Ze,{value:`activity`,className:`relative rounded-none border-b-2 border-transparent data-[state=active]:border-primary data-[state=active]:bg-transparent`,children:(0,$.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[L(`detail.activity`),(0,$.jsx)(T,{variant:`secondary`,className:`text-xs bg-primary/10 text-primary border-transparent`,children:z.activities.length})]})}),r&&(0,$.jsx)(Ze,{value:`discussion`,className:`relative rounded-none border-b-2 border-transparent data-[state=active]:border-primary data-[state=active]:bg-transparent`,children:L(`detail.discussion`,{defaultValue:`Discussion`})}),i&&(0,$.jsx)(Ze,{value:`history`,className:`relative rounded-none border-b-2 border-transparent data-[state=active]:border-primary data-[state=active]:bg-transparent`,children:(0,$.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[L(`detail.history`,{defaultValue:`History`}),!z.history.loading&&z.history.entries.length>0&&(0,$.jsx)(T,{variant:`secondary`,className:`text-xs bg-primary/10 text-primary border-transparent`,children:z.history.entries.length})]})})]}),(0,$.jsx)(zt,{value:`details`,className:`mt-4 motion-safe:data-[state=active]:animate-in motion-safe:data-[state=active]:fade-in-0 motion-safe:duration-150`,children:a}),e&&(0,$.jsx)(zt,{value:`related`,className:`mt-4 motion-safe:data-[state=active]:animate-in motion-safe:data-[state=active]:fade-in-0 motion-safe:duration-150`,children:(0,$.jsx)(`div`,{className:`space-y-3`,children:q.map((e,n)=>(0,$.jsx)(Jn,{title:e.title,type:e.type,api:e.api,data:e.data,columns:e.columns,dataSource:t,objectName:e.api,referenceField:e.referenceField,icon:e.icon,onNew:e.onNew,onViewAll:e.onViewAll,onRowClick:e.onRowClick,onRowEdit:e.onRowEdit,onRowDelete:e.onRowDelete,collapsible:!0,defaultCollapsed:se&&n>0,pageSize:yr},n))})}),n&&(0,$.jsx)(zt,{value:`activity`,className:`mt-4 motion-safe:data-[state=active]:animate-in motion-safe:data-[state=active]:fade-in-0 motion-safe:duration-150`,children:(0,$.jsx)(ir,{activities:z.activities})}),r&&(0,$.jsx)(zt,{value:`discussion`,className:`mt-4 motion-safe:data-[state=active]:animate-in motion-safe:data-[state=active]:fade-in-0 motion-safe:duration-150`,children:u}),i&&(0,$.jsx)(zt,{value:`history`,className:`mt-4 motion-safe:data-[state=active]:animate-in motion-safe:data-[state=active]:fade-in-0 motion-safe:duration-150`,children:(0,$.jsx)(dr,{entries:z.history.entries,loading:z.history.loading,emptyText:z.history.emptyText??L(`detail.historyEmpty`,{defaultValue:`No history yet`})})})]})})():(0,$.jsxs)($.Fragment,{children:[z.sectionGroups&&z.sectionGroups.length>0&&(0,$.jsx)(`div`,{className:`space-y-3 sm:space-y-4`,children:z.sectionGroups.map((e,t)=>(0,$.jsx)(Yn,{group:e,data:{...g,...E},objectSchema:N,objectName:z.objectName,isEditing:C,onFieldChange:he},t))}),z.sections&&z.sections.length>0&&(0,$.jsx)(`div`,{className:`space-y-3 sm:space-y-4`,children:z.sections.map((e,t)=>(0,$.jsx)(Gn,{section:e,data:{...g,...E},objectSchema:N,objectName:z.objectName,isEditing:C,onFieldChange:he},t))}),z.fields&&z.fields.length>0&&!z.sections?.length&&(0,$.jsx)(Gn,{section:{fields:z.fields,columns:z.columns},data:{...g,...E},objectSchema:N,objectName:z.objectName,isEditing:C,onFieldChange:he}),z.tabs&&z.tabs.length>0&&(0,$.jsx)(Kn,{tabs:z.tabs,data:g}),q.length>0&&(0,$.jsxs)(`div`,{className:`space-y-3`,children:[(0,$.jsx)(`h2`,{className:`text-lg font-semibold`,children:L(`detail.related`)}),q.map((e,n)=>(0,$.jsx)(Jn,{title:e.title,type:e.type,api:e.api,data:e.data,columns:e.columns,dataSource:t,objectName:e.api,referenceField:e.referenceField,icon:e.icon,onNew:e.onNew,onViewAll:e.onViewAll,onRowClick:e.onRowClick,onRowEdit:e.onRowEdit,onRowDelete:e.onRowDelete,collapsible:!0,defaultCollapsed:se&&n>0,pageSize:yr},n))]}),z.comments&&(0,$.jsx)(Qn,{comments:z.comments,onAddComment:z.onAddComment}),z.activities&&z.activities.length>0&&(0,$.jsx)(ir,{activities:z.activities})]}),(0,$.jsx)(vr,{data:{...g,...E},objectSchema:N,objectName:z.objectName}),z.footer&&(0,$.jsx)(`div`,{children:(0,$.jsx)(c,{schema:z.footer,data:g})})]})})},Sr=e=>{if(e==null)return`—`;if(typeof e==`string`)return e.length>0?e:`""`;if(typeof e==`number`||typeof e==`boolean`)return String(e);try{return JSON.stringify(e)}catch{return String(e)}},Cr=e=>{if(typeof e!=`string`||e.length===0)return null;let t=/\d{4}-\d{2}-\d{2}[ T]/.test(e)?e.replace(` `,`T`):e,n=new Date(t);if(Number.isNaN(n.getTime()))return null;try{return n.toLocaleString()}catch{return n.toISOString()}},wr=({open:e,conflict:t,onReload:n,onOverwrite:r,onCancel:i,busy:a=!1})=>{let{t:o}=Un(),s=t?.label||t?.field||``,c=t?Sr(t.pendingValue):``,l=t?Sr(t.currentValue):``,u=t?.currentRecord??{},d=(()=>{let e=[u.updated_by_name,u.updated_by_label];for(let t of e)if(typeof t==`string`&&t.length>0)return t;let t=u.updated_by;return typeof t!=`string`||t.length===0||t.length>=16&&!/\s/.test(t)&&/^[A-Za-z0-9_-]+$/.test(t)?null:t})(),f=Cr(u.updated_at??t?.currentVersion),[p,m]=o(`detail.concurrentUpdateDescription`,{field:`{{field}}`}).split(`{{field}}`);return(0,$.jsx)(jt,{open:e,onOpenChange:e=>{!e&&!a&&i()},children:(0,$.jsxs)(Ct,{className:`max-w-lg`,children:[(0,$.jsx)(lt,{children:(0,$.jsxs)(`div`,{className:`flex items-start gap-3`,children:[(0,$.jsx)(`span`,{className:`inline-flex h-9 w-9 flex-none items-center justify-center rounded-full bg-amber-100 text-amber-700 dark:bg-amber-500/20 dark:text-amber-300`,"aria-hidden":`true`,children:(0,$.jsx)(Se,{className:`h-5 w-5`})}),(0,$.jsxs)(`div`,{className:`flex-1`,children:[(0,$.jsx)(Mt,{children:o(`detail.concurrentUpdateTitle`)}),(0,$.jsxs)(Jt,{className:`mt-1`,children:[p,(0,$.jsx)(`strong`,{className:`font-semibold`,children:s}),m]})]})]})}),(0,$.jsxs)(`div`,{className:`space-y-2 text-sm`,children:[(0,$.jsxs)(`div`,{className:`rounded-md border border-amber-200/70 bg-amber-50/60 p-3 dark:border-amber-500/30 dark:bg-amber-500/10`,children:[(0,$.jsx)(`div`,{className:`text-xs font-medium uppercase tracking-wide text-amber-800 dark:text-amber-300`,children:o(`detail.concurrentUpdateYourEdit`)}),(0,$.jsx)(`div`,{className:`mt-1 break-all font-mono text-foreground`,children:c})]}),(0,$.jsxs)(`div`,{className:`rounded-md border border-sky-200/70 bg-sky-50/60 p-3 dark:border-sky-500/30 dark:bg-sky-500/10`,children:[(0,$.jsxs)(`div`,{className:`flex items-baseline justify-between gap-2`,children:[(0,$.jsx)(`div`,{className:`text-xs font-medium uppercase tracking-wide text-sky-800 dark:text-sky-300`,children:o(`detail.concurrentUpdateCurrentValue`)}),(d||f)&&(0,$.jsxs)(`div`,{className:`text-[11px] text-muted-foreground`,children:[d&&(0,$.jsx)(`span`,{children:o(`detail.concurrentUpdateUpdatedBy`,{name:d})}),d&&f&&(0,$.jsx)(`span`,{children:` · `}),f&&(0,$.jsx)(`span`,{children:o(`detail.concurrentUpdateUpdatedAt`,{when:f})})]})]}),(0,$.jsx)(`div`,{className:`mt-1 break-all font-mono text-foreground`,children:l})]})]}),(0,$.jsxs)(it,{className:`gap-2 sm:gap-2`,children:[(0,$.jsx)(`button`,{type:`button`,disabled:a,onClick:i,className:Z(mt({variant:`ghost`}),`mt-2 sm:mt-0`),children:o(`detail.concurrentUpdateCancel`)}),(0,$.jsx)(`button`,{type:`button`,disabled:a,onClick:r,className:Z(mt({variant:`outline`}),`mt-2 sm:mt-0 text-destructive border-destructive/40 hover:bg-destructive/10 hover:text-destructive`),children:o(`detail.concurrentUpdateOverwrite`)}),(0,$.jsx)(`button`,{type:`button`,disabled:a,onClick:n,autoFocus:!0,className:Z(mt({variant:`default`}),`mt-2 sm:mt-0`),children:o(`detail.concurrentUpdateReload`)})]})]})})};function Tr(e){if(!e||typeof e!=`object`)return!1;let t=e;return t.code===`CONCURRENT_UPDATE`||t.name===`ConcurrentUpdateError`}var Er=e=>typeof e==`string`?e:e&&typeof e==`object`&&(e.field||e.name)||null,Dr=e=>{let{"data-obj-id":t,"data-obj-type":n,style:r,...i}=e||{};return{designer:{"data-obj-id":t,"data-obj-type":n,style:r},rest:i}},Or=({schema:e={},className:t,...n})=>{let r=y(),{designer:i}=Dr(n);if(!r)return(0,$.jsx)(`div`,{className:t,"data-record-details-placeholder":!0,...i,children:(0,$.jsx)(`div`,{className:`text-xs text-muted-foreground italic px-3 py-2 border border-dashed rounded`,children:`record:details — bind a record to preview`})});let a=e.layout===`inline`||e.layout===`compact`?`horizontal`:`vertical`,c=r.objectName||``,l=o(),{readableFields:u}=s(c),{sectionLabel:d}=Ge(),f=Array.isArray(e.requiredPermissions)?e.requiredPermissions:[];if(f.length>0&&c&&!f.every(e=>l.can(c,e)))return(0,$.jsx)(`div`,{className:t,...i,role:`status`,"aria-live":`polite`,children:(0,$.jsx)(`p`,{className:`text-sm text-muted-foreground italic`,children:`Insufficient permissions to view details.`})});let p=e.enforceFieldSecurity===!0,m=Array.isArray(e.redactFields)?e.redactFields:[],h=e=>{if(!e||!p&&m.length===0)return e;let t=e.map(Er).filter(e=>!!e),n=new Set((p&&c?u(t):t).filter(e=>!m.includes(e)));return e.filter(e=>{let t=Er(e);return t?n.has(t):!0})},g=e=>typeof e==`string`?{name:e}:e&&typeof e==`object`&&!e.name&&e.field?{...e,name:e.field}:e,_=e=>Array.isArray(e)?e.map(g):e,v=b(),x=new Set((Array.isArray(e.hideFields)?e.hideFields:[]).map(e=>typeof e==`string`?e:Er(e)).filter(e=>!!e));for(let e of v)x.add(e);let S=r.objectSchema,C=r.data??{},ee=[S?.primaryField,`name`,`full_name`,`title`,`subject`,`display_name`,`label`].filter(e=>typeof e==`string`&&e.length>0);for(let e of ee)if(C[e]!==void 0&&C[e]!==null&&C[e]!==``){x.add(e);break}let w=e=>!e||x.size===0?e:e.filter(e=>{let t=Er(e);return t?!x.has(t):!0}),T=w(_(h(e.fields))),E=Array.isArray(e.sections)?e.sections.map(e=>{let t=e.title??e.label,n=e.name&&c?d(c,e.name,t??e.name):t;return{...e,title:n,showBorder:e.showBorder??!!n,hideEmpty:e.hideEmpty??!0,fields:w(_(h(e.fields)))}}):e.sections,D=e.inlineEdit??!0,[O,k]=Q.useState(null),[A,j]=Q.useState(!1),M=Q.useCallback(t=>{let n=[...Array.isArray(e.fields)?e.fields:[],...(Array.isArray(e.sections)?e.sections:[]).flatMap(e=>Array.isArray(e?.fields)?e.fields:[])];for(let e of n)if((typeof e==`string`?e:e?.name||e?.field)===t)return typeof e==`object`?e?.label:void 0},[e.fields,e.sections]),N=Q.useCallback(async(e,t)=>{let n=r.dataSource,i=r.recordId,a=r.objectName;if(!n||!i||!a)return;let o=typeof r.data?.updated_at==`string`?r.data.updated_at:void 0,s=o?{ifMatch:o}:void 0;try{if(typeof n.update==`function`)await n.update(a,i,{[e]:t},s);else if(typeof n.updateOne==`function`)await n.updateOne(a,i,{[e]:t},s);else if(typeof n.patch==`function`)await n.patch(a,i,{[e]:t},s);else{console.warn(`[record:details] DataSource exposes no update/updateOne/patch method; cannot persist inline edit`);return}typeof r.refresh==`function`&&await r.refresh()}catch(n){if(Tr(n)){let r=n.currentRecord??null;throw k({field:e,label:M(e),pendingValue:t,currentValue:r?r[e]:void 0,currentVersion:n.currentVersion,currentRecord:r}),n}throw console.error(`[record:details] Inline-edit save failed`,n),n}},[r.dataSource,r.recordId,r.objectName,r.data,r.refresh,M]),P=Q.useCallback(()=>{k(null),j(!1)},[]),F=Q.useCallback(async()=>{j(!0);try{typeof r.refresh==`function`&&await r.refresh()}finally{P()}},[r.refresh,P]),I=Q.useCallback(async()=>{if(!O){P();return}let e=r.dataSource,t=r.recordId,n=r.objectName;if(!e||!t||!n){P();return}j(!0);try{let i=O.currentVersion?{ifMatch:O.currentVersion}:void 0;typeof e.update==`function`?await e.update(n,t,{[O.field]:O.pendingValue},i):typeof e.updateOne==`function`?await e.updateOne(n,t,{[O.field]:O.pendingValue},i):typeof e.patch==`function`&&await e.patch(n,t,{[O.field]:O.pendingValue},i),typeof r.refresh==`function`&&await r.refresh()}catch(e){console.error(`[record:details] Overwrite-on-conflict failed`,e)}finally{P()}},[O,r.dataSource,r.recordId,r.objectName,r.refresh,P]),te={type:`detail-view`,objectName:r.objectName,resourceId:r.recordId,data:r.data,layout:a,columns:e.columns,sections:E,fields:T,showBack:!1,showHeader:e.showHeader??!1,inlineEdit:D};return(0,$.jsxs)(`div`,{className:t,...i,children:[(0,$.jsx)(xr,{schema:te,dataSource:r.dataSource,inlineEdit:D,onFieldSave:N}),(0,$.jsx)(wr,{open:!!O,conflict:O,busy:A,onCancel:P,onReload:F,onOverwrite:I})]})},kr=e=>typeof e==`string`?e:e&&typeof e==`object`&&(e.field||e.name||e.key)||null,Ar=e=>{let{"data-obj-id":t,"data-obj-type":n,style:r,...i}=e||{};return{designer:{"data-obj-id":t,"data-obj-type":n,style:r},rest:i}},jr=({schema:e={},className:t,...n})=>{let r=y(),{designer:i}=Ar(n),a=Ge(),c=e.objectName,l=c&&a.objectLabel?a.objectLabel({name:c,label:wt(c)}):c?wt(c):``,u=e.title||l||`Related`;if(!c)return(0,$.jsx)(`div`,{className:t,...i,children:(0,$.jsx)(`div`,{className:`text-xs text-muted-foreground italic px-3 py-2 border border-dashed rounded`,children:`record:related_list — missing objectName`})});let d=o(),{readableFields:f}=s(c),p=Array.isArray(e.requiredPermissions)?e.requiredPermissions:[];if(p.length>0&&!p.every(e=>d.can(c,e)))return(0,$.jsx)(`div`,{className:t,...i,role:`status`,"aria-live":`polite`,children:(0,$.jsx)(`p`,{className:`text-sm text-muted-foreground italic`,children:`Insufficient permissions to view related list.`})});let m=e.enforceFieldSecurity===!0,h=Array.isArray(e.redactFields)?e.redactFields:[],g=Array.isArray(e.columns)?e.columns:[],_=g;if(m||h.length>0){let e=g.map(kr).filter(e=>!!e),t=new Set((m?f(e):e).filter(e=>!h.includes(e)));_=g.filter(e=>{let n=kr(e);return n?t.has(n):!0})}return(0,$.jsx)(`div`,{className:t,...i,children:(0,$.jsx)(Jn,{title:u,type:`table`,api:c,objectName:c,referenceField:e.relationshipField,parentId:r?.recordId,columns:_,pageSize:e.limit,dataSource:r?.dataSource})})},Mr=e=>{let{"data-obj-id":t,"data-obj-type":n,style:r,...i}=e||{};return{designer:{"data-obj-id":t,"data-obj-type":n,style:r},rest:i}},Nr=({schema:e={},className:t,...n})=>{let r=y(),{designer:i}=Mr(n),a=r?.objectName||``,c=o(),{readableFields:l}=s(a),u=Array.isArray(e.requiredPermissions)?e.requiredPermissions:[];if(u.length>0&&a&&!u.every(e=>c.can(a,e)))return(0,$.jsx)(`div`,{className:t,...i,role:`status`,"aria-live":`polite`,children:(0,$.jsx)(`p`,{className:`text-sm text-muted-foreground italic`,children:`Insufficient permissions to view highlights.`})});let d=(Array.isArray(e.fields)?e.fields:[]).map(e=>typeof e==`string`?{name:e}:{name:e?.name,label:e?.label,icon:e?.icon,type:e?.type}).filter(e=>typeof e.name==`string`&&e.name.length>0),f=e.enforceFieldSecurity===!0,p=Array.isArray(e.redactFields)?e.redactFields:[],m=f&&a?new Set(l(d.map(e=>e.name))):null,h=d.filter(e=>!(p.includes(e.name)||m&&!m.has(e.name)));return g(Q.useId(),h.map(e=>e.name)),(0,$.jsx)(`div`,{className:t,...i,children:(0,$.jsx)(Xn,{fields:h,data:r?.data,objectName:r?.objectName,objectSchema:r?.objectSchema})})},Pr=({change:e,className:t})=>{let n=e.fieldLabel??e.field.charAt(0).toUpperCase()+e.field.slice(1).replace(/_/g,` `),r=e.oldDisplayValue??(e.oldValue==null?`(empty)`:String(e.oldValue)),i=e.newDisplayValue??(e.newValue==null?`(empty)`:String(e.newValue));return(0,$.jsxs)(`div`,{className:Z(`flex items-center gap-1.5 text-sm flex-wrap`,t),children:[(0,$.jsx)(`span`,{className:`font-medium text-foreground`,children:n}),(0,$.jsx)(`span`,{className:`text-muted-foreground line-through`,children:r}),(0,$.jsx)(qe,{className:`h-3 w-3 text-muted-foreground shrink-0`}),(0,$.jsx)(`span`,{className:`text-foreground`,children:i})]})},Fr=[`👍`,`❤️`,`🎉`,`😂`,`😮`,`😢`],Ir=({reactions:e,onToggleReaction:t,emojiOptions:n=Fr,className:r})=>{let[i,a]=Q.useState(!1),o=Q.useCallback(e=>{t?.(e),a(!1)},[t]);return(0,$.jsxs)(`div`,{className:Z(`flex items-center gap-1 flex-wrap`,r),children:[e.map(e=>(0,$.jsxs)(`button`,{type:`button`,className:Z(`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:()=>o(e.emoji),disabled:!t,"aria-label":`${e.emoji} ${e.count} reaction${e.count===1?``:`s`}`,children:[(0,$.jsx)(`span`,{children:e.emoji}),(0,$.jsx)(`span`,{children:e.count})]},e.emoji)),t&&(0,$.jsxs)(`div`,{className:`relative`,children:[(0,$.jsx)(X,{variant:`ghost`,size:`icon`,className:`h-6 w-6`,onClick:()=>a(!i),"aria-label":`Add reaction`,children:(0,$.jsx)(Kt,{className:`h-3.5 w-3.5`})}),i&&(0,$.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:n.map(t=>(0,$.jsx)(`button`,{type:`button`,className:`hover:bg-accent rounded p-1 text-base transition-colors`,onClick:()=>o(t),role:`option`,"aria-selected":e.some(e=>e.emoji===t&&e.reacted),children:t},t))})]})]})};function Lr(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 Rr=({parentItem:e,replies:t,onAddReply:n,showReplyInput:r=!0,className:i})=>{let{t:a}=Un(),[o,s]=Q.useState(!1),[c,l]=Q.useState(``),[u,d]=Q.useState(!1),f=Q.useCallback(async()=>{let t=c.trim();if(!(!t||!n)){d(!0);try{await n(e.id,t),l(``)}finally{d(!1)}}},[c,n,e.id]),p=Q.useCallback(e=>{e.key===`Enter`&&(e.ctrlKey||e.metaKey)&&(e.preventDefault(),f())},[f]);return t.length===0&&!r?null:(0,$.jsxs)(`div`,{className:Z(`ml-10 mt-1`,i),children:[t.length>0&&(0,$.jsxs)(`button`,{type:`button`,className:`flex items-center gap-1 text-xs text-muted-foreground hover:text-foreground transition-colors mb-1`,onClick:()=>s(!o),"aria-expanded":o,children:[o?(0,$.jsx)(F,{className:`h-3 w-3`}):(0,$.jsx)(ke,{className:`h-3 w-3`}),(0,$.jsx)(Ee,{className:`h-3 w-3`}),(0,$.jsx)(`span`,{children:t.length===1?a(`detail.replyCount`,{count:t.length}):a(`detail.replyCountPlural`,{count:t.length})})]}),o&&(0,$.jsx)(`div`,{className:`space-y-2 border-l-2 border-border pl-3`,children:t.map(e=>(0,$.jsxs)(`div`,{className:`flex gap-2`,children:[(0,$.jsx)(`div`,{className:`shrink-0`,children:e.actorAvatarUrl?(0,$.jsx)(`img`,{src:e.actorAvatarUrl,alt:e.actor,className:`h-6 w-6 rounded-full object-cover`}):(0,$.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,$.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,$.jsx)(`span`,{className:`text-xs font-medium`,children:e.actor}),(0,$.jsx)(`span`,{className:`text-[10px] text-muted-foreground`,children:Lr(e.createdAt)})]}),(0,$.jsx)(`p`,{className:`text-xs whitespace-pre-wrap break-words`,children:e.body})]})]},e.id))}),r&&n&&(0,$.jsxs)(`div`,{className:`flex gap-1.5 mt-1.5`,children:[(0,$.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:a(`detail.replyPlaceholder`),value:c,onChange:e=>l(e.target.value),onKeyDown:p,disabled:u}),(0,$.jsx)(X,{variant:`ghost`,size:`icon`,className:`h-6 w-6 shrink-0`,onClick:f,disabled:!c.trim()||u,"aria-label":`Send reply`,children:(0,$.jsx)(Xt,{className:`h-3 w-3`})})]})]})},zr=({subscription:e,onToggle:t,className:n})=>{let{t:r}=Un(),[i,a]=Q.useState(!1),o=Q.useCallback(async()=>{if(t){a(!0);try{await t(!e.subscribed)}finally{a(!1)}}},[t,e.subscribed]);return(0,$.jsx)(X,{variant:`ghost`,size:`icon`,className:Z(`h-8 w-8`,n),onClick:o,disabled:i||!t,"aria-label":e.subscribed?r(`detail.unsubscribeAriaLabel`):r(`detail.subscribeAriaLabel`),title:e.subscribed?r(`detail.subscribedTooltip`):r(`detail.unsubscribedTooltip`),children:e.subscribed?(0,$.jsx)(We,{className:`h-4 w-4 text-primary`}):(0,$.jsx)(E,{className:`h-4 w-4 text-muted-foreground`})})};function Br(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 Vr=({value:e,onChange:t,onSubmit:n,mentionSuggestions:r=[],placeholder:i,className:a,disabled:o=!1,extraSlot:s,canSubmitEmpty:c=!1})=>{let{t:l}=Un(),[u,d]=Q.useState(!1),[f,p]=Q.useState(!1),[m,h]=Q.useState(``),[g,_]=Q.useState(0),v=Q.useRef(null),y=Q.useMemo(()=>{if(!m)return r;let e=m.toLowerCase();return r.filter(t=>t.label.toLowerCase().includes(e))},[m,r]),b=Q.useCallback((n,r=``)=>{let i=v.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]),x=Q.useCallback(()=>b(`**`,`**`),[b]),S=Q.useCallback(()=>b(`*`,`*`),[b]),C=Q.useCallback(()=>b(`
4
+ - `,``),[b]),ee=Q.useCallback(()=>b("`","`"),[b]),w=Q.useCallback(()=>{b(`@`,``),p(!0),h(``),_(0)},[b]),T=Q.useCallback(n=>{let r=v.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)),p(!1),h(``),requestAnimationFrame(()=>r.focus())},[e,t]),E=Q.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)){p(!0),h(e),_(0);return}}p(!1)},[t]),D=Q.useCallback(e=>{if(f&&y.length>0){if(e.key===`ArrowDown`){e.preventDefault(),_(e=>e<y.length-1?e+1:0);return}if(e.key===`ArrowUp`){e.preventDefault(),_(e=>e>0?e-1:y.length-1);return}if(e.key===`Enter`||e.key===`Tab`){e.preventDefault(),T(y[g]);return}if(e.key===`Escape`){p(!1);return}}e.key===`Enter`&&(e.ctrlKey||e.metaKey)&&(e.preventDefault(),n?.())},[f,y,g,T,n]);return(0,$.jsxs)(`div`,{className:Z(`border rounded-md`,a),children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-0.5 px-2 py-1.5 border-b bg-muted/30`,children:[(0,$.jsx)(X,{variant:`ghost`,size:`icon`,className:`h-7 w-7`,onClick:x,disabled:o||u,title:l(`detail.bold`),children:(0,$.jsx)(ze,{className:`h-3.5 w-3.5`})}),(0,$.jsx)(X,{variant:`ghost`,size:`icon`,className:`h-7 w-7`,onClick:S,disabled:o||u,title:l(`detail.italic`),children:(0,$.jsx)(Pt,{className:`h-3.5 w-3.5`})}),(0,$.jsx)(X,{variant:`ghost`,size:`icon`,className:`h-7 w-7`,onClick:C,disabled:o||u,title:l(`detail.listFormat`),children:(0,$.jsx)(pe,{className:`h-3.5 w-3.5`})}),(0,$.jsx)(X,{variant:`ghost`,size:`icon`,className:`h-7 w-7`,onClick:ee,disabled:o||u,title:l(`detail.inlineCode`),children:(0,$.jsx)(xe,{className:`h-3.5 w-3.5`})}),(0,$.jsx)(X,{variant:`ghost`,size:`icon`,className:`h-7 w-7`,onClick:w,disabled:o||u,title:l(`detail.mentionSomeone`),children:(0,$.jsx)(at,{className:`h-3.5 w-3.5`})}),(0,$.jsx)(`div`,{className:`flex-1`}),(0,$.jsx)(X,{variant:`ghost`,size:`icon`,className:`h-7 w-7`,onClick:()=>d(!u),title:l(u?`detail.edit`:`detail.preview`),children:u?(0,$.jsx)(Je,{className:`h-3.5 w-3.5`}):(0,$.jsx)(_e,{className:`h-3.5 w-3.5`})}),n&&(0,$.jsx)(X,{variant:`ghost`,size:`icon`,className:`h-7 w-7`,onClick:n,disabled:o||!c&&!e.trim(),title:l(`detail.submitComment`),children:(0,$.jsx)(Xt,{className:`h-3.5 w-3.5`})})]}),(0,$.jsx)(`div`,{className:`relative`,children:u?(0,$.jsx)(`div`,{className:`min-h-[80px] px-3 py-2 text-sm prose prose-sm max-w-none`,dangerouslySetInnerHTML:{__html:Br(e)}}):(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`textarea`,{ref:v,className:`w-full min-h-[80px] px-3 py-2 text-sm bg-transparent resize-none focus:outline-none placeholder:text-muted-foreground`,placeholder:i??l(`detail.writeComment`),value:e,onChange:E,onKeyDown:D,disabled:o}),f&&y.length>0&&(0,$.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:y.map((e,t)=>(0,$.jsxs)(`button`,{type:`button`,className:Z(`w-full text-left px-3 py-1.5 text-sm flex items-center gap-2 hover:bg-accent transition-colors`,t===g&&`bg-accent`),onMouseDown:t=>{t.preventDefault(),T(e)},children:[e.avatarUrl?(0,$.jsx)(`img`,{src:e.avatarUrl,alt:e.label,className:`h-5 w-5 rounded-full object-cover`}):(0,$.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,$.jsx)(`span`,{children:e.label})]},e.id))})]})}),s&&(0,$.jsx)(`div`,{className:`border-t px-2 py-2 bg-muted/20`,children:s})]})};function Hr(e){return e<1024?`${e} B`:e<1024*1024?`${(e/1024).toFixed(1)} KB`:`${(e/(1024*1024)).toFixed(1)} MB`}function Ur(e){return e.startsWith(`image/`)}function Wr(e){return Ur(e)?Le:e.includes(`pdf`)||e.includes(`document`)||e.includes(`text`)?N:e.includes(`zip`)||e.includes(`archive`)||e.includes(`compressed`)?me:Qe}var Gr=({attachments:e,onUpload:t,onRemove:n,className:r,readOnly:i=!1})=>{let{t:a}=Un(),[o,s]=Q.useState(!1),c=Q.useRef(null),l=Q.useCallback(e=>{e.preventDefault(),e.stopPropagation(),s(!0)},[]),u=Q.useCallback(e=>{e.preventDefault(),e.stopPropagation(),s(!1)},[]),d=Q.useCallback(e=>{e.preventDefault(),e.stopPropagation(),s(!1),t&&e.dataTransfer.files.length>0&&t(e.dataTransfer.files)},[t]),f=Q.useCallback(e=>{t&&e.target.files&&e.target.files.length>0&&(t(e.target.files),e.target.value=``)},[t]);return(0,$.jsxs)(`div`,{className:Z(`space-y-2`,r),children:[t&&!i&&(0,$.jsxs)(`div`,{className:Z(`border-2 border-dashed rounded-md px-4 py-3 text-center transition-colors cursor-pointer`,o?`border-primary bg-primary/5`:`border-muted-foreground/25 hover:border-muted-foreground/40`),onDragOver:l,onDragLeave:u,onDrop:d,onClick:()=>c.current?.click(),role:`button`,tabIndex:0,onKeyDown:e=>{(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),c.current?.click())},children:[(0,$.jsx)(ve,{className:`h-5 w-5 mx-auto text-muted-foreground mb-1`}),(0,$.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:a(`detail.dropFilesToUpload`)}),(0,$.jsx)(`input`,{ref:c,type:`file`,multiple:!0,className:`hidden`,onChange:f})]}),e.length>0&&(0,$.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-1.5 text-xs text-muted-foreground`,children:[(0,$.jsx)(be,{className:`h-3 w-3`}),(0,$.jsx)(`span`,{children:e.length===1?a(`detail.attachmentCount`,{count:e.length}):a(`detail.attachmentCountPlural`,{count:e.length})})]}),(0,$.jsx)(`div`,{className:`grid grid-cols-1 sm:grid-cols-2 gap-2`,children:e.map(e=>{let t=Ur(e.type),r=Wr(e.type);return(0,$.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,$.jsx)(`img`,{src:e.thumbnailUrl||e.url,alt:e.name,className:`h-10 w-10 rounded object-cover shrink-0`}):(0,$.jsx)(`div`,{className:`h-10 w-10 rounded bg-muted flex items-center justify-center shrink-0`,children:(0,$.jsx)(r,{className:`h-5 w-5 text-muted-foreground`})}),(0,$.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,$.jsx)(`p`,{className:`text-xs font-medium truncate`,children:e.name}),(0,$.jsx)(`p`,{className:`text-[10px] text-muted-foreground`,children:Hr(e.size)})]}),n&&!i&&(0,$.jsx)(X,{variant:`ghost`,size:`icon`,className:`h-6 w-6 shrink-0 opacity-0 group-hover:opacity-100 transition-opacity`,onClick:()=>n(e.id),title:a(`detail.removeAttachment`),children:(0,$.jsx)(Oe,{className:`h-3.5 w-3.5`})})]},e.id)})})]})]})},Kr={comment:Ee,field_change:Je,task:Vt,event:Ce,system:$e,email:G,call:ce},qr={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 Jr(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 Yr(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 Xr(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 Zr=({items:e,config:t,filterMode:n,onFilterChange:r,hasMore:i=!1,onLoadMore:a,loading:o=!1,onAddComment:s,onAddReply:c,onToggleReaction:l,subscription:u,onToggleSubscription:d,collapseWhenEmpty:f=!1,mentionSuggestions:p,onUploadAttachments:m,titleLabel:h,emptyLabel:g,className:_})=>{let{t:v}=Un(),[y,b]=Q.useState(`all`),[x,S]=Q.useState(``),[C,ee]=Q.useState(!1),[w,T]=Q.useState(!1),[E,D]=Q.useState([]),[O,k]=Q.useState(!1),A=n??y,M=t?.showFilterToggle!==!1,N=t?.showCommentInput!==!1&&!!s,P=t?.enableReactions??!1,I=t?.enableThreading??!1,te=t?.showSubscriptionToggle??!1,ne=Q.useMemo(()=>Xr(e,A),[e,A]),re=Q.useMemo(()=>I?ne.filter(e=>!e.parentId):ne,[ne,I]),ie=Q.useMemo(()=>{if(!I)return new Map;let e=new Map;for(let t of ne)if(t.parentId){let n=e.get(t.parentId)??[];n.push(t),e.set(t.parentId,n)}return e},[ne,I]),ae=Q.useCallback(e=>{r?r(e):b(e)},[r]),L=Q.useCallback(async()=>{let e=x.trim();if(s&&!(!e&&E.length===0)){ee(!0);try{await s(e,E.length>0?E:void 0),S(``),D([])}finally{ee(!1)}}},[x,E,s]),se=Q.useCallback(async e=>{if(!(!m||e.length===0)){k(!0);try{let t=await m(e);Array.isArray(t)&&t.length>0&&D(e=>[...e,...t])}finally{k(!1)}}},[m]),R=Q.useCallback(e=>{D(t=>t.filter(t=>t.id!==e))},[]),z=Q.useCallback(async()=>{if(a){T(!0);try{await a()}finally{T(!1)}}},[a]);return(0,$.jsxs)(`section`,{className:Z(`border-t border-border/60 pt-5`,_),"aria-label":`Discussion`,children:[(0,$.jsx)(`header`,{className:`mb-4`,children:(0,$.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,$.jsxs)(`h2`,{className:`flex items-center gap-2 text-base font-semibold leading-none tracking-tight`,children:[(0,$.jsx)(ct,{className:`h-4 w-4`}),h??v(`detail.activity`),(0,$.jsxs)(`span`,{className:`text-sm font-normal text-muted-foreground`,children:[`(`,ne.length,`)`]})]}),(0,$.jsx)(`div`,{className:`flex items-center gap-1`,children:te&&u&&(0,$.jsx)(zr,{subscription:u,onToggle:d})})]})}),(0,$.jsxs)(`div`,{className:`space-y-4`,children:[M&&(0,$.jsx)(`div`,{className:`flex items-center gap-2`,children:(0,$.jsxs)(j,{value:A,onValueChange:e=>ae(e),children:[(0,$.jsx)(Me,{"aria-label":v(`detail.filterActivity`),className:`h-8 w-auto min-w-[140px] py-1 text-sm`,children:(0,$.jsx)(Ie,{})}),(0,$.jsx)(Pe,{children:Jr(v).map(e=>(0,$.jsx)(oe,{value:e.value,children:e.label},e.value))})]})}),N&&(0,$.jsx)(Vr,{value:x,onChange:S,onSubmit:L,mentionSuggestions:p,placeholder:v(`detail.leaveCommentPlaceholder`),disabled:C,canSubmitEmpty:E.length>0,extraSlot:m?(0,$.jsx)(Gr,{attachments:E,onUpload:se,onRemove:R,readOnly:C||O}):E.length>0?(0,$.jsx)(Gr,{attachments:E,onRemove:R,readOnly:C}):void 0}),ne.length===0?f?null:(0,$.jsx)(de,{title:g??v(`detail.noActivity`),className:`py-6`}):(0,$.jsxs)(`div`,{className:`relative`,children:[(0,$.jsx)(`div`,{className:`absolute left-4 top-2 bottom-2 w-px bg-border`}),(0,$.jsx)(`div`,{className:`space-y-4`,children:re.map(e=>{let t=Kr[e.type]||$e,n=qr[e.type]||`bg-gray-100 text-gray-600`,r=ie.get(e.id)??[];return(0,$.jsxs)(`div`,{children:[(0,$.jsxs)(`div`,{className:`flex gap-3 relative`,children:[(0,$.jsx)(`div`,{className:Z(`shrink-0 h-8 w-8 rounded-full flex items-center justify-center z-10`,n),children:e.actorAvatarUrl?(0,$.jsx)(`img`,{src:e.actorAvatarUrl,alt:e.actor,className:`h-8 w-8 rounded-full object-cover`}):(0,$.jsx)(t,{className:`h-3.5 w-3.5`})}),(0,$.jsxs)(`div`,{className:`flex-1 min-w-0 pt-1`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-2 mb-0.5`,children:[(0,$.jsx)(`span`,{className:`text-sm font-medium`,children:e.actor}),e.source&&(0,$.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:v(`detail.via`,{source:e.source})}),(0,$.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:Yr(e.createdAt)}),e.edited&&(0,$.jsx)(`span`,{className:`text-xs text-muted-foreground italic`,children:v(`detail.edited`)}),e.pinned&&(0,$.jsxs)(`span`,{className:`text-xs text-amber-600`,children:[`📌 `,v(`detail.pinned`)]})]}),e.body&&(0,$.jsx)(`p`,{className:`text-sm whitespace-pre-wrap break-words text-muted-foreground`,children:e.body}),e.sourceObject&&e.sourceId!=null&&(0,$.jsxs)(`a`,{href:`/objects/${e.sourceObject}/${e.sourceId}`,className:`mt-1 inline-flex items-center gap-1 text-xs text-primary hover:underline`,"data-testid":`activity-source-link`,children:[v(`detail.viewSource`),(0,$.jsx)(`span`,{"aria-hidden":!0,children:`→`})]}),e.type===`field_change`&&e.fieldChanges&&(0,$.jsx)(`div`,{className:`space-y-1 mt-1`,children:e.fieldChanges.map((e,t)=>(0,$.jsx)(Pr,{change:e},t))}),P&&e.reactions&&e.reactions.length>0&&(0,$.jsx)(`div`,{className:`mt-1.5`,children:(0,$.jsx)(Ir,{reactions:e.reactions,onToggleReaction:l?t=>l(e.id,t):void 0})}),P&&(!e.reactions||e.reactions.length===0)&&l&&(0,$.jsx)(`div`,{className:`mt-1.5`,children:(0,$.jsx)(Ir,{reactions:[],onToggleReaction:t=>l(e.id,t)})})]})]}),I&&(e.replyCount??0)>0&&(0,$.jsx)(Rr,{parentItem:e,replies:r,onAddReply:c,showReplyInput:!!c})]},e.id)})})]}),i&&(0,$.jsx)(`div`,{className:`text-center pt-2`,children:(0,$.jsxs)(X,{variant:`ghost`,size:`sm`,onClick:z,disabled:w,"aria-label":v(`detail.loadMore`),children:[w?(0,$.jsx)(H,{className:`h-4 w-4 animate-spin mr-1`}):(0,$.jsx)(F,{className:`h-4 w-4 mr-1`}),v(`detail.loadMore`)]})})]})]})},Qr=e=>{let{"data-obj-id":t,"data-obj-type":n,style:r,...i}=e||{};return{designer:{"data-obj-id":t,"data-obj-type":n,style:r},rest:i}},$r=({schema:e={},className:t,...n})=>{y();let{designer:r}=Qr(n);return(0,$.jsx)(`div`,{className:t,...r,children:(0,$.jsx)(Zr,{items:[],config:e})})},ei=({config:e,items:t,hasMore:n,onLoadMore:r,loading:i,onAddComment:a,onAddReply:o,onToggleReaction:s,subscription:c,onToggleSubscription:l,filterMode:u,onFilterChange:d,collapseWhenEmpty:f=!1,mentionSuggestions:p,onUploadAttachments:m,className:h})=>{let g=e?.position??`right`,_=e?.width??`360px`,v=e?.collapsible??!0,y=f&&t.length===0||(e?.defaultCollapsed??!1),{t:b}=Un(),[x,S]=Q.useState(y);return g===`right`||g===`left`?x&&v?(0,$.jsx)(`div`,{className:Z(`flex items-start pt-4`,g===`right`?`border-l`:`border-r`,h),children:(0,$.jsx)(X,{variant:`ghost`,size:`icon`,className:`h-8 w-8 mx-1`,onClick:()=>S(!1),"aria-label":b(`detail.openDiscussion`),children:(0,$.jsx)(Tt,{className:`h-4 w-4`})})}):(0,$.jsxs)(`div`,{className:Z(`flex flex-col overflow-hidden`,g===`right`?`border-l`:`border-r`,h),style:{width:_,minWidth:_},children:[(0,$.jsxs)(`div`,{className:`flex items-center justify-between px-4 py-3 border-b`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(Ee,{className:`h-4 w-4`}),(0,$.jsx)(`span`,{className:`text-sm font-medium`,children:b(`detail.discussion`)})]}),v&&(0,$.jsx)(X,{variant:`ghost`,size:`icon`,className:`h-7 w-7`,onClick:()=>S(!0),"aria-label":b(`detail.closeDiscussion`),children:(0,$.jsx)(Oe,{className:`h-3.5 w-3.5`})})]}),(0,$.jsx)(`div`,{className:`flex-1 overflow-y-auto`,children:(0,$.jsx)(Zr,{items:t,config:e?.feed,hasMore:n,onLoadMore:r,loading:i,onAddComment:a,onAddReply:o,onToggleReaction:s,subscription:c,onToggleSubscription:l,filterMode:u,onFilterChange:d,collapseWhenEmpty:f,mentionSuggestions:p,onUploadAttachments:m,titleLabel:b(`detail.discussion`),emptyLabel:b(`detail.noCommentsYet`),className:`border-0 shadow-none`})})]}):(0,$.jsx)(`div`,{className:Z(``,h),children:v&&x?(0,$.jsxs)(X,{variant:`ghost`,className:`w-full justify-start gap-2 text-muted-foreground`,onClick:()=>S(!1),"aria-label":b(`detail.showDiscussion`,{count:t.length}),children:[(0,$.jsx)(Ee,{className:`h-4 w-4`}),(0,$.jsx)(`span`,{children:b(`detail.showDiscussion`,{count:t.length})})]}):(0,$.jsxs)(`div`,{children:[v&&(0,$.jsxs)(`div`,{className:`flex items-center justify-between mb-2`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-2 text-sm font-medium`,children:[(0,$.jsx)(Ee,{className:`h-4 w-4`}),b(`detail.discussion`)]}),(0,$.jsx)(X,{variant:`ghost`,size:`icon`,className:`h-7 w-7`,onClick:()=>S(!0),"aria-label":b(`detail.hideDiscussion`),children:(0,$.jsx)(It,{className:`h-3.5 w-3.5`})})]}),(0,$.jsx)(Zr,{items:t,config:e?.feed,hasMore:n,onLoadMore:r,loading:i,onAddComment:a,onAddReply:o,onToggleReaction:s,subscription:c,onToggleSubscription:l,filterMode:u,onFilterChange:d,collapseWhenEmpty:f,mentionSuggestions:p,onUploadAttachments:m,titleLabel:b(`detail.discussion`),emptyLabel:b(`detail.noCommentsYet`)})]})})},ti=e=>{let{"data-obj-id":t,"data-obj-type":n,style:r,...i}=e||{};return{designer:{"data-obj-id":t,"data-obj-type":n,style:r},rest:i}},ni=({schema:e={},className:t,...n})=>{y();let r=_(),{designer:i}=ti(n),a={position:`bottom`,collapsible:!1,feed:{enableReactions:!0,enableThreading:!0,showCommentInput:!0},...e};return(0,$.jsx)(`div`,{className:t,...i,children:(0,$.jsx)(ei,{items:r?.items||[],config:a,onAddComment:r?.onAddComment,onAddReply:r?.onAddReply,onToggleReaction:r?.onToggleReaction,mentionSuggestions:r?.mentionSuggestions,onUploadAttachments:r?.onUploadAttachments})})},ri=e=>{let{"data-obj-id":t,"data-obj-type":n,style:r,...i}=e||{};return{designer:{"data-obj-id":t,"data-obj-type":n,style:r},rest:i}},ii=({schema:e={},className:t,...n})=>{let r=y(),{translateOptions:i}=Ge(),{designer:a}=ri(n),o=Array.isArray(e.stages)?e.stages:[],s=e.statusField,c=Q.useMemo(()=>{if(o.length===0||!s||!r?.objectName)return o;let e=i(r.objectName,s,o);return Array.isArray(e)&&e.length===o.length?o.map((t,n)=>({...t,label:e[n]?.label??t.label})):o},[o,s,r?.objectName,i]),l=s&&r?.data?r.data[s]:void 0,u=/(^|[_-\s])(closed_)?(lost|failed?|cancell?ed|失败|流失|丢单|败)([_-\s]|$)/i,d=/(^|[_-\s])(closed_)?(won|success|成交|赢|完成)([_-\s]|$)/i,f=c.map(e=>{if(e.terminal)return e.terminal;let t=`${String(e.value??``)} ${String(e.label??``)}`;if(u.test(t))return`lost`;if(d.test(t))return`won`}),p=f.findIndex(e=>e===`lost`),m=p===-1?c:c.slice(0,p),h=p===-1?[]:c.slice(p),g=p===-1?f:f.slice(0,p),_=c.findIndex(e=>e.value===l);_<0&&(_=-1);let v=p!==-1&&_>=p;if(c.length===0)return(0,$.jsx)(`div`,{className:t,...a,children:(0,$.jsx)(`div`,{className:`text-xs text-muted-foreground italic px-3 py-2 border border-dashed rounded`,children:`record:path — no stages configured`})});let b=m.length-1;return(0,$.jsxs)(`div`,{className:Z(`w-full`,t),...a,children:[(0,$.jsxs)(`div`,{className:`hidden sm:flex w-full items-stretch gap-2`,role:`list`,"aria-label":e.aria?.label||`Record path`,children:[(0,$.jsx)(`div`,{className:`flex flex-1 items-stretch gap-1.5`,children:m.map((e,t)=>{let n=!v&&_>=0&&t<_,r=!v&&t===_,i=g[t]===`won`&&t===b;return(0,$.jsx)(`div`,{role:`listitem`,"aria-current":r?`step`:void 0,className:Z(`relative flex-1 min-w-0 px-4 py-2 text-xs font-medium text-center rounded-xl`,r&&`bg-primary text-primary-foreground shadow-sm`,n&&`bg-emerald-500/15 text-emerald-800 dark:text-emerald-200`,!r&&!n&&i&&`bg-emerald-500/10 text-emerald-700/85 dark:text-emerald-300/85`,!r&&!n&&!i&&`bg-muted text-muted-foreground`),children:(0,$.jsxs)(`span`,{className:`inline-flex items-center justify-center gap-1.5 truncate`,children:[n&&(0,$.jsx)(`span`,{"aria-hidden":!0,className:`text-emerald-600 dark:text-emerald-400 font-semibold`,children:`✓`}),i&&!r&&(0,$.jsx)(`span`,{"aria-hidden":!0,className:`opacity-70`,children:`🏆`}),e.label]})},`${e.value}-${t}`)})}),h.length>0&&(0,$.jsx)(`div`,{className:`flex items-stretch gap-1 pl-2 border-l border-border/40`,"aria-label":`Alternative terminal stages`,children:h.map((e,t)=>{let n=p+t===_;return(0,$.jsx)(`div`,{role:`listitem`,"aria-current":n?`step`:void 0,className:Z(`shrink-0 px-3 py-2 text-xs font-medium rounded-md border whitespace-nowrap`,n&&`bg-destructive text-destructive-foreground border-destructive shadow-sm ring-1 ring-destructive/40`,!n&&`bg-destructive/5 text-destructive/85 border-destructive/20`),children:(0,$.jsxs)(`span`,{className:`inline-flex items-center gap-1`,children:[(0,$.jsx)(`span`,{"aria-hidden":!0,className:`opacity-70`,children:`✗`}),e.label]})},`${e.value}-lost-${t}`)})})]}),(0,$.jsx)(`div`,{className:`flex sm:hidden w-full items-stretch gap-1 overflow-x-auto pb-1 -mx-1 px-1 [-ms-overflow-style:none] [scrollbar-width:none] [&::-webkit-scrollbar]:hidden`,role:`list`,"aria-label":e.aria?.label||`Record path`,children:c.map((e,t)=>{let n=f[t]===`lost`,r=!n&&!v&&_>=0&&t<_,i=t===_;return(0,$.jsx)(`div`,{role:`listitem`,"aria-current":i?`step`:void 0,className:Z(`shrink-0 px-3 py-1.5 rounded-full text-xs font-medium border whitespace-nowrap`,n&&i&&`bg-destructive text-destructive-foreground border-destructive shadow-sm`,n&&!i&&`bg-destructive/5 text-destructive/85 border-destructive/20`,!n&&i&&`bg-primary text-primary-foreground border-primary shadow-sm ring-1 ring-primary/40`,!n&&r&&`bg-emerald-500/15 text-emerald-800 dark:text-emerald-200 border-emerald-500/30`,!n&&!i&&!r&&`bg-background text-foreground/85 border-border/60`),children:(0,$.jsxs)(`span`,{className:`inline-flex items-center gap-1`,children:[n&&(0,$.jsx)(`span`,{"aria-hidden":!0,className:`opacity-70`,children:`✗`}),!n&&r&&(0,$.jsx)(`span`,{"aria-hidden":!0,className:`text-emerald-600 dark:text-emerald-400 font-semibold`,children:`✓`}),e.label]})},`${e.value}-${t}-m`)})})]})},ai=e=>{let{"data-obj-id":t,"data-obj-type":n,style:r,...i}=e||{};return{designer:{"data-obj-id":t,"data-obj-type":n,style:r},rest:i}},oi=({schema:e={},className:t,...n})=>{let r=y(),{designer:i}=ai(n),a=o(),s=Array.isArray(e.actions)?e.actions:Array.isArray(e.properties?.actions)?e.properties.actions:[],c=Array.isArray(e.actionNames)?e.actionNames:Array.isArray(e.properties?.actionNames)?e.properties.actionNames:[],d=r?.objectName||``,f=c.length>0?c:Array.isArray(s)&&s.every(e=>typeof e==`string`)?s:[],p=f.length>0&&!!d,{item:m}=u(`object`,p?d:null),h=p?(()=>{let e=Array.isArray(m?.actions)?m.actions:[],t=new Map(e.map(e=>[e.name,e]));return f.map(e=>t.get(e)).filter(e=>!!e)})():Array.isArray(s)?s:[],g=Array.isArray(e.requiredPermissions)?e.requiredPermissions:[];if(g.length>0&&d&&!g.every(e=>a.can(d,e)))return(0,$.jsx)(`div`,{className:t,...i,role:`status`,"aria-live":`polite`,children:(0,$.jsx)(`p`,{className:`text-sm text-muted-foreground italic`,children:`Insufficient permissions to view quick actions.`})});let _=e.location||`record_header`,{getActionsForLocation:v,executeAction:b}=l({actions:h,context:{record:r?.data,recordId:r?.recordId,objectName:r?.objectName}}),x=h.length>0?v(_):[];if(x.length===0)return(0,$.jsx)(`div`,{className:t,...i,children:(0,$.jsx)(`div`,{className:`text-xs text-muted-foreground italic px-3 py-2 border border-dashed rounded`,children:`record:quick_actions — no actions configured`})});let S=e.align||`end`,C=S===`start`?`justify-start`:S===`center`?`justify-center`:`justify-end`;return(0,$.jsx)(`div`,{className:Z(`flex flex-wrap items-center gap-2`,_===`record_header`&&!e.inline&&`-mt-12 sm:-mt-14 mb-2 relative z-10`,C,t),role:`toolbar`,"aria-label":e.aria?.label||`Quick actions`,...i,children:x.map((t,n)=>(0,$.jsx)(si,{action:t,record:r?.data,variant:t.variant||e.variant||`default`,size:t.size||e.size||`sm`,label:t.label||t.name||`Action ${n+1}`,onRun:async()=>{typeof t.onClick==`function`?await t.onClick():t.name&&await b(t.name)}},t.name||`qa-${n}`))})};function si({action:e,record:t,variant:n,size:r,label:i,onRun:a}){let[o,s]=Q.useState(!1),c=Q.useMemo(()=>({record:t||{}}),[t]),l=m(e.disabled),u=w(typeof l==`string`?l:void 0,c);return(0,$.jsxs)(X,{variant:n,size:r,disabled:(typeof l==`string`?u:l===!0)||o,onClick:async()=>{s(!0);try{await a()}finally{s(!1)}},children:[o&&(0,$.jsx)(H,{className:`mr-2 h-4 w-4 animate-spin`}),i]})}var ci=e=>{let{"data-obj-id":t,"data-obj-type":n,style:r,...i}=e||{};return{designer:{"data-obj-id":t,"data-obj-type":n,style:r},rest:i}},li=({schema:e={},className:t,...n})=>{let{designer:r}=ci(n),i=Array.isArray(e.entries)?e.entries:Array.isArray(e.properties?.entries)?e.properties.entries:[],a=e.loading??e.properties?.loading??!1,o=e.emptyText??e.properties?.emptyText;return(0,$.jsx)(`div`,{className:t,...r,children:(0,$.jsx)(dr,{entries:i,loading:a,emptyText:o})})},ui=e=>{let{"data-obj-id":t,"data-obj-type":n,style:r,...i}=e||{};return{designer:{"data-obj-id":t,"data-obj-type":n,style:r},rest:i}},di=e=>e.replace(/[_-]+/g,` `).replace(/\b\w/g,e=>e.toUpperCase()).trim(),fi=(e,t)=>t&&e?.[t]!=null&&e[t]!==``?String(e[t]):e?.name||e?.title||e?.subject||e?.label||e?.email||e?.username||e?.code||e?.slug||e?.provider_id||e?.user_agent||e?.ip_address||e?.id||`—`,pi=({schema:e={},className:t,...n})=>{let a=y(),o=Ge(),{t:s}=Un(),{designer:c}=ui(n),l=r().appName,u=Array.isArray(e.entries)?e.entries:Array.isArray(e.properties?.entries)?e.properties.entries:[],d=a?.recordId,f=a?.dataSource,[p,m]=Q.useState({}),h=Q.useRef(null),[g,_]=Q.useState(!1),v=Q.useRef(!0);Q.useEffect(()=>(v.current=!0,()=>{v.current=!1}),[]);let b=Q.useRef(``);Q.useEffect(()=>{if(g)return;let e=h.current;if(!e||typeof IntersectionObserver>`u`){_(!0);return}let t=new IntersectionObserver(e=>{e.some(e=>e.isIntersecting)&&_(!0)},{rootMargin:`200px`});return t.observe(e),()=>t.disconnect()},[g]);let x=JSON.stringify(u.map(e=>`${e.objectName}:${e.relationshipField}:${e.limit??3}`));if(Q.useEffect(()=>{if(!g||!f?.find||!d||u.length===0)return;let e=`${d}::${x}`;if(b.current===e)return;b.current=e,m(e=>{let t={...e};for(let n of u)t[n.objectName]={loading:!0,total:0,items:e[n.objectName]?.items||[]};return t});let t=async e=>{let t=e.objectName;try{let n=await f.find(e.objectName,{$filter:{[e.relationshipField]:d},$top:e.limit??3,$count:!0});if(!v.current)return;let r=Array.isArray(n)?n:n?.data||[],i=typeof n?.total==`number`?n.total:typeof n?.count==`number`?n.count:r.length;m(e=>({...e,[t]:{loading:!1,total:i,items:r}}))}catch(e){if(!v.current)return;m(n=>({...n,[t]:{loading:!1,total:0,items:[],error:String(e?.message||e)}}))}},n=[...u],r=async()=>{for(;v.current;){let e=n.shift();if(!e)return;await t(e)}},i=Array.from({length:Math.min(3,n.length)},()=>r());Promise.all(i)},[g,f,d,x]),u.length===0)return null;let S=e.hideEmpty!==!1,[C,ee]=Q.useState(!1),w=new Set(u.filter(e=>{let t=p[e.objectName];return S&&t&&!t.loading&&!t.error&&t.total===0}).map(e=>e.objectName)),E=u.filter(e=>C||!w.has(e.objectName)),D=u.filter(e=>w.has(e.objectName)).map(e=>e.title||(o?.objectLabel?o.objectLabel({name:e.objectName,label:di(e.objectName)}):di(e.objectName)));return(0,$.jsxs)(`div`,{ref:h,className:Z(`flex flex-col gap-3`,e.className,t),...c,children:[E.map(e=>{let t=e.objectName,n=p[t]||{loading:!0,total:0,items:[]};return(0,$.jsxs)(Ft,{className:`overflow-hidden`,children:[(0,$.jsxs)(Re,{className:`flex flex-row items-center justify-between gap-2 py-3 px-4 space-y-0 border-b`,children:[(0,$.jsx)(Ue,{className:`text-sm font-semibold tracking-tight truncate`,children:e.title||(o?.objectLabel?o.objectLabel({name:e.objectName,label:di(e.objectName)}):di(e.objectName))}),(0,$.jsxs)(`div`,{className:`flex items-center gap-2 shrink-0`,children:[!n.loading&&(0,$.jsx)(T,{variant:`secondary`,className:`tabular-nums`,children:n.total}),l&&d&&(0,$.jsx)(i,{to:`/apps/${l}/${e.objectName}?filter%5B${e.relationshipField}%5D=${encodeURIComponent(String(d))}`,className:`text-[11px] font-medium text-muted-foreground hover:text-foreground transition-colors`,title:s(`detail.viewAll`,{defaultValue:`View all`}),children:s(`detail.viewAll`,{defaultValue:`View all`})})]})]}),(0,$.jsx)(le,{className:`p-0`,children:n.loading?(0,$.jsxs)(`div`,{className:`space-y-1.5 p-3`,children:[(0,$.jsx)(U,{className:`h-3.5 w-4/5`}),(0,$.jsx)(U,{className:`h-3.5 w-3/5`}),(0,$.jsx)(U,{className:`h-3.5 w-2/3`})]}):n.items.length===0?(0,$.jsx)(`p`,{className:`px-4 py-3 text-xs text-muted-foreground`,children:s(`detail.noRecords`)}):(0,$.jsx)(`ul`,{className:`divide-y`,children:n.items.map(t=>{let n=t.id||t._id,r=fi(t,e.displayField),a=n?`../${e.objectName}/record/${encodeURIComponent(String(n))}`:void 0;return(0,$.jsx)(`li`,{className:`px-4 py-2`,children:a?(0,$.jsxs)(i,{to:a,className:`group flex items-center justify-between gap-2 text-xs hover:text-foreground text-muted-foreground transition-colors`,children:[(0,$.jsx)(`span`,{className:`truncate`,children:r}),(0,$.jsx)(ke,{className:`h-3 w-3 shrink-0 opacity-0 group-hover:opacity-100 transition-opacity`})]}):(0,$.jsx)(`span`,{className:`block truncate text-xs text-muted-foreground`,children:r})},String(n||r))})})})]},t)}),!C&&D.length>0&&(0,$.jsxs)(`button`,{type:`button`,onClick:()=>ee(!0),className:`self-start inline-flex items-center gap-1.5 text-[11px] text-muted-foreground hover:text-foreground transition-colors px-2.5 py-1 rounded-md border border-dashed border-border/60 hover:border-border bg-background`,title:D.join(` · `),children:[(0,$.jsx)(`span`,{children:s(`detail.showEmptyRelated`,{defaultValue:`+ {{count}} empty`,count:D.length})}),(0,$.jsxs)(`span`,{className:`truncate max-w-[180px] text-muted-foreground/70`,children:[`(`,D.join(` · `),`)`]})]})]})},mi={info:{wrap:`border-blue-300/60 bg-blue-50 text-blue-900 dark:border-blue-700/40 dark:bg-blue-950/30 dark:text-blue-100 [&>svg]:text-blue-600 dark:[&>svg]:text-blue-300`,icon:`Info`},warning:{wrap:`border-amber-300/60 bg-amber-50 text-amber-900 dark:border-amber-700/40 dark:bg-amber-950/30 dark:text-amber-100 [&>svg]:text-amber-600 dark:[&>svg]:text-amber-300`,icon:`AlertTriangle`},error:{wrap:`border-destructive/60 bg-destructive/10 text-destructive dark:bg-destructive/20 [&>svg]:text-destructive`,icon:`AlertCircle`},success:{wrap:`border-emerald-300/60 bg-emerald-50 text-emerald-900 dark:border-emerald-700/40 dark:bg-emerald-950/30 dark:text-emerald-100 [&>svg]:text-emerald-600 dark:[&>svg]:text-emerald-300`,icon:`CheckCircle2`}};function hi(e){let t=e?.properties??{};return{...e,...t}}var gi=({schema:e={},className:t})=>{let n=hi(e),r=y(),i=r?.data,a=r?.objectName||``,o=r?.recordId??i?.id,s=[`info`,`warning`,`error`,`success`].includes(n.severity)?n.severity:`info`,c=mi[s],d=n.icon||c.icon,f=m(n.visible),p=w(f,{record:i}),h=Q.useMemo(()=>{if(!n.dismissible)return null;let e=n.dismissKey||n.title||s;return`os.record-alert:${a}:${o??`_`}:${e}`},[n.dismissible,n.dismissKey,n.title,s,a,o]),[g,_]=Q.useState(()=>{if(!h||typeof window>`u`)return!1;try{return window.localStorage.getItem(h)===`1`}catch{return!1}}),v=n.action?.actionName,{item:b}=u(`object`,v&&a?a:null),x=Q.useMemo(()=>{if(!(!v||!b?.actions))return b.actions.find(e=>e.name===v)},[v,b]),{executeAction:S}=l({actions:Q.useMemo(()=>x?[x]:[],[x]),context:{record:i,recordId:o,objectName:a}});return g||!i||Object.keys(i).length===0||f!==void 0&&!p?null:(0,$.jsxs)(Rt,{className:Z(`relative pr-12`,c.wrap,t),role:s===`error`?`alert`:`status`,"aria-live":s===`error`?`assertive`:`polite`,children:[(0,$.jsx)(J,{name:d,className:`h-4 w-4`,"aria-hidden":`true`}),n.title?(0,$.jsx)(Xe,{children:n.title}):null,n.body||x?(0,$.jsxs)(gt,{children:[n.body?(0,$.jsx)(`p`,{className:`mb-2 last:mb-0`,children:n.body}):null,x?(0,$.jsx)(X,{size:`sm`,variant:n.action?.variant||(s===`error`?`destructive`:`default`),onClick:()=>{x?.name&&S(x.name)},children:n.action?.label||x.label||x.name}):null]}):null,n.dismissible?(0,$.jsx)(`button`,{type:`button`,onClick:()=>{if(_(!0),h)try{window.localStorage.setItem(h,`1`)}catch{}},"aria-label":`Dismiss`,className:`absolute right-3 top-3 inline-flex h-6 w-6 items-center justify-center rounded-md text-muted-foreground/80 hover:bg-foreground/5 hover:text-foreground focus:outline-none focus:ring-2 focus:ring-ring`,children:(0,$.jsx)(J,{name:`X`,className:`h-4 w-4`,"aria-hidden":`true`})}):null]})},_i=new Set([`id`,`_id`,`__v`,`created_at`,`updated_at`,`createdAt`,`updatedAt`,`created_by`,`updated_by`,`organization_id`,`tenant_id`,`owner_id`,`deleted_at`,`is_deleted`]),vi=480,yi=95;function bi({open:e,onClose:t,title:n,record:r,objectName:i,recordId:a,dataSource:o,objectSchema:s,width:c=`min(960px, 60vw)`,columns:l=2,systemFields:u=_i,onFieldSave:d,onDelete:f,resizable:p=!0,fullPageHref:m}){let{t:h}=Un(),g=`objectui.drawerWidth.${i}`,[_,v]=Q.useState(()=>{if(typeof window>`u`||!p)return null;try{let e=window.localStorage.getItem(g);if(e){let t=parseInt(e,10);if(Number.isFinite(t)&&t>=vi)return t}}catch{}return null}),y=Q.useMemo(()=>p&&_!=null?`${_}px`:typeof c==`number`?`${c}px`:c,[p,_,c]),b=y?{width:y,maxWidth:y}:void 0,x=Q.useRef(null),S=Q.useCallback(e=>{if(!p)return;e.preventDefault();let t=_??(typeof window<`u`?Math.min(window.innerWidth*.6,960):720);x.current={startX:e.clientX,startWidth:t};let n=e=>{let t=x.current;if(!t)return;let n=t.startX-e.clientX,r=typeof window<`u`?window.innerWidth*yi/100:1600,i=Math.min(r,Math.max(vi,t.startWidth+n));v(Math.round(i))},r=()=>{x.current,x.current=null,window.removeEventListener(`pointermove`,n),window.removeEventListener(`pointerup`,r),window.removeEventListener(`pointercancel`,r);try{v(e=>(e!=null&&window.localStorage.setItem(g,String(e)),e))}catch{}};window.addEventListener(`pointermove`,n),window.addEventListener(`pointerup`,r),window.addEventListener(`pointercancel`,r)},[p,_,g]),C=s?.fields??{},ee=(Object.keys(C).length?Object.keys(C):Object.keys(r)).filter(e=>!u.has(e)&&!e.startsWith(`__`)).filter(e=>e in r).filter(e=>!C[e]?.hidden).map(e=>{let t=C[e]||{},n=t.type===`lookup`||t.type===`master_detail`||t.type===`reference`;return{name:e,label:t.label,type:t.type,readonly:!!t.readonly||n,options:t.options,currency:t.currency,precision:t.precision,format:t.format,reference_to:t.reference_to??t.referenceTo??t.target,reference_field:t.reference_field??t.referenceField,required:t.required,validation:t.validation,placeholder:t.placeholder,description:t.description}});return(0,$.jsx)(ye,{open:e,onOpenChange:e=>{e||t()},children:(0,$.jsxs)(ie,{side:`right`,className:`w-full overflow-y-auto p-0 sm:!max-w-none`,style:b,onOpenAutoFocus:e=>e.preventDefault(),children:[p&&(0,$.jsx)(`div`,{role:`separator`,"aria-orientation":`vertical`,"aria-label":`Resize drawer`,onPointerDown:S,className:`hidden sm:block absolute left-0 top-0 h-full w-1.5 cursor-col-resize select-none bg-transparent hover:bg-primary/30 active:bg-primary/50 transition-colors z-10`}),(0,$.jsx)(V,{className:`sr-only`,children:(0,$.jsx)(we,{children:n})}),(0,$.jsx)(`div`,{className:`px-6 pt-6 pb-6`,children:(0,$.jsx)(xr,{dataSource:o,inlineEdit:!0,schema:{type:`detail-view`,objectName:i,resourceId:String(a),data:r,showDelete:!0,columns:l,fields:ee,actions:m?[{type:`action:bar`,location:`record_header`,systemActions:[{name:`sys_open_new_tab`,label:h(`detail.openInNewTab`),icon:`external-link`,type:`script`,onClick:()=>window.open(m,`_blank`,`noopener`)}]}]:void 0},onFieldSave:async(e,t)=>{try{await d?.(e,t)}catch(e){console.error(`[RecordDetailDrawer] inline field save failed:`,e)}},onDelete:async()=>{try{await f?.(),t()}catch(e){console.error(`[RecordDetailDrawer] delete failed:`,e)}}})})]})})}function xi(e,t){if(typeof window>`u`)return null;let n=window.location.pathname,r=`/${e}`,i=n.indexOf(r);return`${i>=0?n.slice(0,i):n.replace(/\/$/,``)}/${e}/record/${encodeURIComponent(String(t))}`}function Si(e,t){if(!e||!t.length)return[];let n=[...t].sort((e,t)=>t.label.length-e.label.length),r=e,i=new Set;for(let e of n){if(!e.label)continue;let t=e.label.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`),n=RegExp(`@${t}(?![\\p{L}\\p{N}_])`,`gu`);n.test(r)&&(i.add(e.id),r=r.replace(n,e=>` `.repeat(e.length)))}return[...i]}function Ci(e){return e==null?[]:Array.isArray(e)?e.filter(e=>e!=null):[e]}function wi(e){if(!e)return null;if(e.stageField)return e.stageField;let t=e.fields||{};for(let e of[`status`,`stage`,`state`,`phase`])if(e in t)return e;for(let[e,n]of Object.entries(t)){let t=(n?.type||``).toLowerCase();if(t===`status`||t===`stage`)return e}return null}function Ti(e,t){if(!e||!t)return null;let n=e.fields?.[t]?.options;return!Array.isArray(n)||n.length===0?null:n.map(e=>({value:e.value,label:e.label}))}function Ei(e,t,n=4){if(!e)return[];if(Array.isArray(e.highlightFields)&&e.highlightFields.length>0)return e.highlightFields.slice(0,n);let r=new Set([`id`,`_id`,`created_at`,`updated_at`,`deleted_at`,`created_by`,`updated_by`,`deleted_by`,`organization_id`,`workspace_id`,`tenant_id`,`org_id`]);t&&r.add(t),e.primaryField&&r.add(e.primaryField);for(let t of[`name`,`full_name`,`title`,`subject`,`display_name`])t in(e.fields||{})&&r.add(t);let i=[`owner`,`owner_id`,`amount`,`rating`,`source`,`priority`,`industry`,`phone`,`email`,`close_date`,`due_date`,`start_date`,`expected_close_date`,`account`,`account_id`,`contact`,`contact_id`],a=new Set([`currency`,`number`,`integer`,`decimal`,`percent`,`date`,`datetime`,`time`,`reference`,`lookup`,`user`,`owner`,`select`,`enum`,`multiselect`,`status`,`email`,`phone`,`url`,`text`,`string`]),o=[],s=e.fields||{};for(let e of i)if(e in s&&!r.has(e)&&o.push(e),o.length>=n)return o;for(let e of Object.keys(s)){if(o.includes(e)||r.has(e))continue;let t=s[e]?.type;if(!(t&&!a.has(t))&&(o.push(e),o.length>=n))break}return o}function Di(e,t={}){return{type:`page:header`,recordChrome:t.recordChrome!==!1,...Array.isArray(t.actions)&&t.actions.length>0?{actions:t.actions}:{}}}function Oi(e,t={}){let n=t.statusField??wi(e),r=t.stages??(n?Ti(e,n):null),i=t.highlightFields??Ei(e,n),a=[];return!t.hideHighlights&&i.length>0&&a.push({type:`record:highlights`,fields:i}),!t.hidePath&&n&&r&&r.length>0&&a.push({type:`record:path`,statusField:n,stages:r}),a}function ki(e,t,n){return{type:`record:details`,sections:t,...n&&n.length>0?{hideFields:n}:{}}}function Ai(e,t={}){let n=t.statusField??wi(e),r=t.highlightFields??Ei(e,n),i=[{label:`Details`,children:[ki(e,t.sections,r)]}];return!t.hideRelatedTab&&Array.isArray(t.related)&&t.related.length>0&&i.push({label:`Related`,children:t.related.map(e=>({type:`record:related_list`,title:e.title,objectName:e.objectName,relationshipField:e.relationshipField,...e.columns?{columns:e.columns}:{},...e.limit?{limit:e.limit}:{},...e.icon?{icon:e.icon}:{}}))}),t.showActivity&&i.push({label:`Activity`,children:[{type:`record:activity`}]}),t.history&&i.push({label:`History`,children:[{type:`record:history`,entries:t.history.entries,loading:t.history.loading,emptyText:t.history.emptyText}]}),{type:`page:tabs`,items:i}}function ji(){return{type:`record:discussion`}}function Mi(e,t={}){let n=t.slots||{},r=[];`header`in n&&n.header!==void 0?r.push(...Ci(n.header)):r.push(Di(e,{recordChrome:t.recordChrome,actions:t.headerActions})),`actions`in n&&n.actions!==void 0&&r.push(...Ci(n.actions)),`alerts`in n&&n.alerts!==void 0&&r.push(...Ci(n.alerts)),`highlights`in n&&n.highlights!==void 0?r.push(...Ci(n.highlights)):r.push(...Oi(e,{highlightFields:t.highlightFields,statusField:t.statusField,stages:t.stages,hideHighlights:t.hideHighlights,hidePath:t.hidePath}));let i=t.showReferenceRail===!0&&!t.hideReferenceRail&&Array.isArray(t.related)&&t.related.length>=2,a=t.hideRelatedTab??i;if(`tabs`in n&&n.tabs!==void 0)r.push(...Ci(n.tabs));else if(`details`in n&&n.details!==void 0){let i=Ci(n.details),o=Ai(e,{sections:t.sections,related:t.related,showActivity:t.showActivity,history:t.history,highlightFields:t.highlightFields,statusField:t.statusField,hideRelatedTab:a});Array.isArray(o.items)&&o.items.length>0&&(o.items[0]={...o.items[0],children:i}),r.push(o)}else r.push(Ai(e,{sections:t.sections,related:t.related,showActivity:t.showActivity,history:t.history,highlightFields:t.highlightFields,statusField:t.statusField,hideRelatedTab:a}));`discussion`in n&&n.discussion!==void 0?r.push(...Ci(n.discussion)):t.hideDiscussion||r.push(ji());let o=[{name:`main`,width:`full`,components:r}],s=Ci(n.rightRail);if(i||s.length>0){let e=[];i&&e.push({type:`record:reference_rail`,entries:t.related.map(e=>({objectName:e.objectName,relationshipField:e.relationshipField,title:e.title,icon:e.icon,displayField:e.displayField,limit:3}))}),s.length>0&&e.push(...s),o.push({name:`aside`,width:`small`,className:`hidden xl:flex flex-col gap-4`,components:e})}return{type:`record`,pageType:`record`,object:e?.name,template:`full-width`,regions:o}}var Ni=t({DetailSection:()=>Gn,DetailView:()=>xr,RecordActivityRenderer:()=>$r,RecordAlertRenderer:()=>gi,RecordChatterRenderer:()=>ni,RecordDetailsRenderer:()=>Or,RecordHighlightsRenderer:()=>Nr,RecordHistoryRenderer:()=>li,RecordPathRenderer:()=>ii,RecordQuickActionsRenderer:()=>oi,RecordReferenceRailRenderer:()=>pi,RecordRelatedListRenderer:()=>jr,RelatedList:()=>Jn,buildDefaultPageSchema:()=>Mi});x.register(`detail-view`,xr,{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:[]}}),x.register(`detail-section`,Gn,{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`}]}),x.register(`related-list`,Jn,{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`}]}),x.register(`detail`,xr,{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`}]}),x.register(`record:details`,Or,{namespace:`record`,category:`record`,label:`Record Details`,icon:`FileText`}),x.register(`record:related_list`,jr,{namespace:`record`,category:`record`,label:`Related List`,icon:`List`}),x.register(`record:highlights`,Nr,{namespace:`record`,category:`record`,label:`Highlights Panel`,icon:`Star`}),x.register(`record:activity`,$r,{namespace:`record`,category:`record`,label:`Activity Timeline`,icon:`Activity`}),x.register(`record:chatter`,ni,{namespace:`record`,category:`record`,label:`Chatter Feed`,icon:`MessageSquare`}),x.register(`record:discussion`,ni,{namespace:`record`,category:`record`,label:`Discussion`,icon:`MessageSquare`}),x.register(`record:path`,ii,{namespace:`record`,category:`record`,label:`Path / Stepper`,icon:`GitBranch`}),x.register(`record:quick_actions`,oi,{namespace:`record`,category:`record`,label:`Quick Actions`,icon:`Zap`}),x.register(`record:history`,li,{namespace:`record`,category:`record`,label:`History Timeline`,icon:`Clock`}),x.register(`record:reference_rail`,pi,{namespace:`record`,category:`record`,label:`Reference Rail`,icon:`PanelRight`}),x.register(`record:alert`,gi,{namespace:`record`,category:`record`,label:`Alert Banner`,icon:`AlertTriangle`});export{xi as a,kn as c,bi as i,Mi as n,ei as o,Si as r,xr as s,Ni as t};
@@ -1,4 +1,4 @@
1
- import{o as e,t}from"./rolldown-runtime-CMxvf4Kt.js";import{_ as n,t as r}from"./vendor-react-DR370ovB.js";import{r as i}from"./framework-BLEk-ou3.js";import{Bn as a,Bt as o,Fo as s,Hn as c,Ht as l,Kn as u,Ln as d,Os as f,Po as p,Rn as m,Ut as h,Vn as g,Vt as _,Wt as v,Yo as y,cr as b,dr as x,fr as S,hc as C,hr as w,lr as T,nn as E,on as D,or as O,pr as k,sr as A,tt as j,ur as ee,x as M,zn as N}from"./ui-components-CrPYFyEM.js";import{r as P}from"./vendor-ui-utils-rQOI1gAo.js";import{t as te}from"./plugin-form-DXCdD2d-.js";var F=r();function I({state:e,onOpenChange:t}){let{t:n}=i(),r=()=>{e.resolve?.(!0),t(!1)},a=()=>{e.resolve?.(!1),t(!1)};return(0,F.jsx)(O,{open:e.open,onOpenChange:e=>{e||a()},children:(0,F.jsxs)(T,{children:[(0,F.jsxs)(S,{children:[(0,F.jsx)(k,{children:e.options?.title||n(`actionConfirm.title`)}),(0,F.jsx)(ee,{children:e.message})]}),(0,F.jsxs)(x,{children:[(0,F.jsx)(b,{onClick:a,children:e.options?.cancelText||n(`actionConfirm.cancel`)}),(0,F.jsx)(A,{onClick:r,children:e.options?.confirmText||n(`actionConfirm.confirm`)})]})]})})}var L=e(n(),1);function R({state:e,onOpenChange:t}){let{t:n,language:r}=i(),[s,f]=(0,L.useState)({}),[p,y]=(0,L.useState)({});(0,L.useEffect)(()=>{if(e.open){let t={};for(let n of e.params)n.defaultValue!==void 0&&(t[n.name]=n.defaultValue);f(t),y({})}},[e.open,e.params]);let b=e=>e==null?!0:typeof e==`string`?e.trim()===``:Array.isArray(e)?e.length===0:!1,x=()=>{let n={};for(let t of e.params)t.required&&b(s[t.name])&&(n[t.name]=!0);if(Object.keys(n).length>0){y(n);return}e.resolve?.(s),t(!1)},S=()=>{e.resolve?.(null),t(!1)},T=(e,t)=>{f(n=>({...n,[e]:t})),y(t=>({...t,[e]:!1}))};return(0,F.jsx)(d,{open:e.open,onOpenChange:e=>{e||S()},children:(0,F.jsxs)(m,{children:[(0,F.jsxs)(g,{children:[(0,F.jsx)(c,{children:e.title||n(`actionDialog.title`)}),(0,F.jsx)(N,{children:e.description||n(`actionDialog.description`)})]}),(0,F.jsx)(`div`,{className:`grid gap-4 py-4`,children:e.params.map(e=>{let t={...e,label:C(e.label,r),helpText:e.helpText==null?e.helpText:C(e.helpText,r),options:e.options?.map(e=>({...e,label:C(e.label,r)}))};if(t.type===`boolean`||t.type===`checkbox`){let e=s[t.name]===!0;return(0,F.jsxs)(`div`,{className:`grid gap-1`,children:[(0,F.jsxs)(`div`,{className:`flex items-start gap-2`,children:[(0,F.jsx)(u,{id:t.name,checked:e,onCheckedChange:e=>T(t.name,e===!0),className:`mt-0.5`}),(0,F.jsxs)(D,{htmlFor:t.name,className:`font-normal cursor-pointer`,children:[t.label,t.required&&(0,F.jsx)(`span`,{className:`text-destructive ml-1`,children:`*`})]})]}),p[t.name]&&(0,F.jsx)(`p`,{className:`text-xs text-destructive ml-6`,children:n(`actionDialog.requiredError`,{label:t.label})}),t.helpText&&(0,F.jsx)(`p`,{className:`text-xs text-muted-foreground ml-6`,children:t.helpText})]},t.name)}let i=t.type===`lookup`||t.type===`reference`;return(0,F.jsxs)(`div`,{className:`grid gap-2`,children:[(0,F.jsxs)(D,{htmlFor:t.name,children:[t.label,t.required&&(0,F.jsx)(`span`,{className:`text-destructive ml-1`,children:`*`})]}),t.type===`select`&&t.options?(0,F.jsxs)(o,{value:s[t.name]??``,onValueChange:e=>T(t.name,e),children:[(0,F.jsx)(h,{id:t.name,className:p[t.name]?`border-destructive`:``,children:(0,F.jsx)(v,{placeholder:t.placeholder||n(`actionDialog.selectPlaceholder`,{label:t.label})})}),(0,F.jsx)(_,{children:t.options.map(e=>(0,F.jsx)(l,{value:e.value,children:e.label},e.value))})]}):i&&t.referenceTo?(0,F.jsx)(M,{value:s[t.name]??null,onChange:e=>T(t.name,e),field:{name:t.name,type:`lookup`,reference_to:t.referenceTo,display_field:t.displayField,id_field:t.idField,description_field:t.descriptionField,multiple:t.multiple,title_format:t.titleFormat,lookup_columns:t.lookupColumns,lookup_filters:t.lookupFilters,lookup_page_size:t.lookupPageSize,depends_on:t.dependsOn,placeholder:t.placeholder}}):t.type===`textarea`?(0,F.jsx)(j,{id:t.name,value:s[t.name]??``,onChange:e=>T(t.name,e.target.value),placeholder:t.placeholder,className:p[t.name]?`border-destructive`:``}):t.type===`number`?(0,F.jsx)(E,{id:t.name,type:`number`,value:s[t.name]??``,onChange:e=>T(t.name,e.target.value===``?void 0:e.target.valueAsNumber),placeholder:t.placeholder,className:p[t.name]?`border-destructive`:``}):(0,F.jsx)(E,{id:t.name,type:[`email`,`url`,`date`,`datetime-local`,`time`,`password`].includes(t.type)?t.type:`text`,value:s[t.name]??``,onChange:e=>T(t.name,e.target.value),placeholder:t.placeholder||(i?n(`actionDialog.lookupPlaceholder`,{label:t.label}):void 0),className:p[t.name]?`border-destructive`:``}),p[t.name]&&(0,F.jsx)(`p`,{className:`text-xs text-destructive`,children:n(`actionDialog.requiredError`,{label:t.label})}),t.helpText&&(0,F.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:t.helpText}),i&&!t.helpText&&(0,F.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:n(`actionDialog.lookupHelpText`)})]},t.name)})}),(0,F.jsxs)(a,{children:[(0,F.jsx)(w,{variant:`outline`,onClick:S,children:n(`actionDialog.cancel`)}),(0,F.jsx)(w,{onClick:x,children:n(`actionDialog.confirm`)})]})]})})}var ne=t(((e,t)=>{t.exports=function(){return typeof Promise==`function`&&Promise.prototype&&Promise.prototype.then}})),z=t((e=>{var t,n=[0,26,44,70,100,134,172,196,242,292,346,404,466,532,581,655,733,815,901,991,1085,1156,1258,1364,1474,1588,1706,1828,1921,2051,2185,2323,2465,2611,2761,2876,3034,3196,3362,3532,3706];e.getSymbolSize=function(e){if(!e)throw Error(`"version" cannot be null or undefined`);if(e<1||e>40)throw Error(`"version" should be in range from 1 to 40`);return e*4+17},e.getSymbolTotalCodewords=function(e){return n[e]},e.getBCHDigit=function(e){let t=0;for(;e!==0;)t++,e>>>=1;return t},e.setToSJISFunction=function(e){if(typeof e!=`function`)throw Error(`"toSJISFunc" is not a valid function.`);t=e},e.isKanjiModeEnabled=function(){return t!==void 0},e.toSJIS=function(e){return t(e)}})),B=t((e=>{e.L={bit:1},e.M={bit:0},e.Q={bit:3},e.H={bit:2};function t(t){if(typeof t!=`string`)throw Error(`Param is not a string`);switch(t.toLowerCase()){case`l`:case`low`:return e.L;case`m`:case`medium`:return e.M;case`q`:case`quartile`:return e.Q;case`h`:case`high`:return e.H;default:throw Error(`Unknown EC Level: `+t)}}e.isValid=function(e){return e&&e.bit!==void 0&&e.bit>=0&&e.bit<4},e.from=function(n,r){if(e.isValid(n))return n;try{return t(n)}catch{return r}}})),re=t(((e,t)=>{function n(){this.buffer=[],this.length=0}n.prototype={get:function(e){let t=Math.floor(e/8);return(this.buffer[t]>>>7-e%8&1)==1},put:function(e,t){for(let n=0;n<t;n++)this.putBit((e>>>t-n-1&1)==1)},getLengthInBits:function(){return this.length},putBit:function(e){let t=Math.floor(this.length/8);this.buffer.length<=t&&this.buffer.push(0),e&&(this.buffer[t]|=128>>>this.length%8),this.length++}},t.exports=n})),ie=t(((e,t)=>{function n(e){if(!e||e<1)throw Error(`BitMatrix size must be defined and greater than 0`);this.size=e,this.data=new Uint8Array(e*e),this.reservedBit=new Uint8Array(e*e)}n.prototype.set=function(e,t,n,r){let i=e*this.size+t;this.data[i]=n,r&&(this.reservedBit[i]=!0)},n.prototype.get=function(e,t){return this.data[e*this.size+t]},n.prototype.xor=function(e,t,n){this.data[e*this.size+t]^=n},n.prototype.isReserved=function(e,t){return this.reservedBit[e*this.size+t]},t.exports=n})),ae=t((e=>{var t=z().getSymbolSize;e.getRowColCoords=function(e){if(e===1)return[];let n=Math.floor(e/7)+2,r=t(e),i=r===145?26:Math.ceil((r-13)/(2*n-2))*2,a=[r-7];for(let e=1;e<n-1;e++)a[e]=a[e-1]-i;return a.push(6),a.reverse()},e.getPositions=function(t){let n=[],r=e.getRowColCoords(t),i=r.length;for(let e=0;e<i;e++)for(let t=0;t<i;t++)e===0&&t===0||e===0&&t===i-1||e===i-1&&t===0||n.push([r[e],r[t]]);return n}})),V=t((e=>{var t=z().getSymbolSize,n=7;e.getPositions=function(e){let r=t(e);return[[0,0],[r-n,0],[0,r-n]]}})),H=t((e=>{e.Patterns={PATTERN000:0,PATTERN001:1,PATTERN010:2,PATTERN011:3,PATTERN100:4,PATTERN101:5,PATTERN110:6,PATTERN111:7};var t={N1:3,N2:3,N3:40,N4:10};e.isValid=function(e){return e!=null&&e!==``&&!isNaN(e)&&e>=0&&e<=7},e.from=function(t){return e.isValid(t)?parseInt(t,10):void 0},e.getPenaltyN1=function(e){let n=e.size,r=0,i=0,a=0,o=null,s=null;for(let c=0;c<n;c++){i=a=0,o=s=null;for(let l=0;l<n;l++){let n=e.get(c,l);n===o?i++:(i>=5&&(r+=t.N1+(i-5)),o=n,i=1),n=e.get(l,c),n===s?a++:(a>=5&&(r+=t.N1+(a-5)),s=n,a=1)}i>=5&&(r+=t.N1+(i-5)),a>=5&&(r+=t.N1+(a-5))}return r},e.getPenaltyN2=function(e){let n=e.size,r=0;for(let t=0;t<n-1;t++)for(let i=0;i<n-1;i++){let n=e.get(t,i)+e.get(t,i+1)+e.get(t+1,i)+e.get(t+1,i+1);(n===4||n===0)&&r++}return r*t.N2},e.getPenaltyN3=function(e){let n=e.size,r=0,i=0,a=0;for(let t=0;t<n;t++){i=a=0;for(let o=0;o<n;o++)i=i<<1&2047|e.get(t,o),o>=10&&(i===1488||i===93)&&r++,a=a<<1&2047|e.get(o,t),o>=10&&(a===1488||a===93)&&r++}return r*t.N3},e.getPenaltyN4=function(e){let n=0,r=e.data.length;for(let t=0;t<r;t++)n+=e.data[t];return Math.abs(Math.ceil(n*100/r/5)-10)*t.N4};function n(t,n,r){switch(t){case e.Patterns.PATTERN000:return(n+r)%2==0;case e.Patterns.PATTERN001:return n%2==0;case e.Patterns.PATTERN010:return r%3==0;case e.Patterns.PATTERN011:return(n+r)%3==0;case e.Patterns.PATTERN100:return(Math.floor(n/2)+Math.floor(r/3))%2==0;case e.Patterns.PATTERN101:return n*r%2+n*r%3==0;case e.Patterns.PATTERN110:return(n*r%2+n*r%3)%2==0;case e.Patterns.PATTERN111:return(n*r%3+(n+r)%2)%2==0;default:throw Error(`bad maskPattern:`+t)}}e.applyMask=function(e,t){let r=t.size;for(let i=0;i<r;i++)for(let a=0;a<r;a++)t.isReserved(a,i)||t.xor(a,i,n(e,a,i))},e.getBestMask=function(t,n){let r=Object.keys(e.Patterns).length,i=0,a=1/0;for(let o=0;o<r;o++){n(o),e.applyMask(o,t);let r=e.getPenaltyN1(t)+e.getPenaltyN2(t)+e.getPenaltyN3(t)+e.getPenaltyN4(t);e.applyMask(o,t),r<a&&(a=r,i=o)}return i}})),U=t((e=>{var t=B(),n=[1,1,1,1,1,1,1,1,1,1,2,2,1,2,2,4,1,2,4,4,2,4,4,4,2,4,6,5,2,4,6,6,2,5,8,8,4,5,8,8,4,5,8,11,4,8,10,11,4,9,12,16,4,9,16,16,6,10,12,18,6,10,17,16,6,11,16,19,6,13,18,21,7,14,21,25,8,16,20,25,8,17,23,25,9,17,23,34,9,18,25,30,10,20,27,32,12,21,29,35,12,23,34,37,12,25,34,40,13,26,35,42,14,28,38,45,15,29,40,48,16,31,43,51,17,33,45,54,18,35,48,57,19,37,51,60,19,38,53,63,20,40,56,66,21,43,59,70,22,45,62,74,24,47,65,77,25,49,68,81],r=[7,10,13,17,10,16,22,28,15,26,36,44,20,36,52,64,26,48,72,88,36,64,96,112,40,72,108,130,48,88,132,156,60,110,160,192,72,130,192,224,80,150,224,264,96,176,260,308,104,198,288,352,120,216,320,384,132,240,360,432,144,280,408,480,168,308,448,532,180,338,504,588,196,364,546,650,224,416,600,700,224,442,644,750,252,476,690,816,270,504,750,900,300,560,810,960,312,588,870,1050,336,644,952,1110,360,700,1020,1200,390,728,1050,1260,420,784,1140,1350,450,812,1200,1440,480,868,1290,1530,510,924,1350,1620,540,980,1440,1710,570,1036,1530,1800,570,1064,1590,1890,600,1120,1680,1980,630,1204,1770,2100,660,1260,1860,2220,720,1316,1950,2310,750,1372,2040,2430];e.getBlocksCount=function(e,r){switch(r){case t.L:return n[(e-1)*4+0];case t.M:return n[(e-1)*4+1];case t.Q:return n[(e-1)*4+2];case t.H:return n[(e-1)*4+3];default:return}},e.getTotalCodewordsCount=function(e,n){switch(n){case t.L:return r[(e-1)*4+0];case t.M:return r[(e-1)*4+1];case t.Q:return r[(e-1)*4+2];case t.H:return r[(e-1)*4+3];default:return}}})),W=t((e=>{var t=new Uint8Array(512),n=new Uint8Array(256);(function(){let e=1;for(let r=0;r<255;r++)t[r]=e,n[e]=r,e<<=1,e&256&&(e^=285);for(let e=255;e<512;e++)t[e]=t[e-255]})(),e.log=function(e){if(e<1)throw Error(`log(`+e+`)`);return n[e]},e.exp=function(e){return t[e]},e.mul=function(e,r){return e===0||r===0?0:t[n[e]+n[r]]}})),G=t((e=>{var t=W();e.mul=function(e,n){let r=new Uint8Array(e.length+n.length-1);for(let i=0;i<e.length;i++)for(let a=0;a<n.length;a++)r[i+a]^=t.mul(e[i],n[a]);return r},e.mod=function(e,n){let r=new Uint8Array(e);for(;r.length-n.length>=0;){let e=r[0];for(let i=0;i<n.length;i++)r[i]^=t.mul(n[i],e);let i=0;for(;i<r.length&&r[i]===0;)i++;r=r.slice(i)}return r},e.generateECPolynomial=function(n){let r=new Uint8Array([1]);for(let i=0;i<n;i++)r=e.mul(r,new Uint8Array([1,t.exp(i)]));return r}})),K=t(((e,t)=>{var n=G();function r(e){this.genPoly=void 0,this.degree=e,this.degree&&this.initialize(this.degree)}r.prototype.initialize=function(e){this.degree=e,this.genPoly=n.generateECPolynomial(this.degree)},r.prototype.encode=function(e){if(!this.genPoly)throw Error(`Encoder not initialized`);let t=new Uint8Array(e.length+this.degree);t.set(e);let r=n.mod(t,this.genPoly),i=this.degree-r.length;if(i>0){let e=new Uint8Array(this.degree);return e.set(r,i),e}return r},t.exports=r})),q=t((e=>{e.isValid=function(e){return!isNaN(e)&&e>=1&&e<=40}})),J=t((e=>{var t=`[0-9]+`,n=`[A-Z $%*+\\-./:]+`,r=`(?:[u3000-u303F]|[u3040-u309F]|[u30A0-u30FF]|[uFF00-uFFEF]|[u4E00-u9FAF]|[u2605-u2606]|[u2190-u2195]|u203B|[u2010u2015u2018u2019u2025u2026u201Cu201Du2225u2260]|[u0391-u0451]|[u00A7u00A8u00B1u00B4u00D7u00F7])+`;r=r.replace(/u/g,`\\u`);var i=`(?:(?![A-Z0-9 $%*+\\-./:]|`+r+`)(?:.|[\r
1
+ import{o as e,t}from"./rolldown-runtime-CMxvf4Kt.js";import{_ as n,t as r}from"./vendor-react-DR370ovB.js";import{r as i}from"./framework-BLEk-ou3.js";import{Bn as a,Bt as o,Fo as s,Hn as c,Ht as l,Kn as u,Ln as d,Os as f,Po as p,Rn as m,Ut as h,Vn as g,Vt as _,Wt as v,Yo as y,cr as b,dr as x,fr as S,hc as C,hr as w,lr as T,nn as E,on as D,or as O,pr as k,sr as A,tt as j,ur as ee,x as M,zn as N}from"./ui-components-NS_7__gn.js";import{r as P}from"./vendor-ui-utils-rQOI1gAo.js";import{t as te}from"./plugin-form-Dzz6GAZM.js";var F=r();function I({state:e,onOpenChange:t}){let{t:n}=i(),r=()=>{e.resolve?.(!0),t(!1)},a=()=>{e.resolve?.(!1),t(!1)};return(0,F.jsx)(O,{open:e.open,onOpenChange:e=>{e||a()},children:(0,F.jsxs)(T,{children:[(0,F.jsxs)(S,{children:[(0,F.jsx)(k,{children:e.options?.title||n(`actionConfirm.title`)}),(0,F.jsx)(ee,{children:e.message})]}),(0,F.jsxs)(x,{children:[(0,F.jsx)(b,{onClick:a,children:e.options?.cancelText||n(`actionConfirm.cancel`)}),(0,F.jsx)(A,{onClick:r,children:e.options?.confirmText||n(`actionConfirm.confirm`)})]})]})})}var L=e(n(),1);function R({state:e,onOpenChange:t}){let{t:n,language:r}=i(),[s,f]=(0,L.useState)({}),[p,y]=(0,L.useState)({});(0,L.useEffect)(()=>{if(e.open){let t={};for(let n of e.params)n.defaultValue!==void 0&&(t[n.name]=n.defaultValue);f(t),y({})}},[e.open,e.params]);let b=e=>e==null?!0:typeof e==`string`?e.trim()===``:Array.isArray(e)?e.length===0:!1,x=()=>{let n={};for(let t of e.params)t.required&&b(s[t.name])&&(n[t.name]=!0);if(Object.keys(n).length>0){y(n);return}e.resolve?.(s),t(!1)},S=()=>{e.resolve?.(null),t(!1)},T=(e,t)=>{f(n=>({...n,[e]:t})),y(t=>({...t,[e]:!1}))};return(0,F.jsx)(d,{open:e.open,onOpenChange:e=>{e||S()},children:(0,F.jsxs)(m,{children:[(0,F.jsxs)(g,{children:[(0,F.jsx)(c,{children:e.title||n(`actionDialog.title`)}),(0,F.jsx)(N,{children:e.description||n(`actionDialog.description`)})]}),(0,F.jsx)(`div`,{className:`grid gap-4 py-4`,children:e.params.map(e=>{let t={...e,label:C(e.label,r),helpText:e.helpText==null?e.helpText:C(e.helpText,r),options:e.options?.map(e=>({...e,label:C(e.label,r)}))};if(t.type===`boolean`||t.type===`checkbox`){let e=s[t.name]===!0;return(0,F.jsxs)(`div`,{className:`grid gap-1`,children:[(0,F.jsxs)(`div`,{className:`flex items-start gap-2`,children:[(0,F.jsx)(u,{id:t.name,checked:e,onCheckedChange:e=>T(t.name,e===!0),className:`mt-0.5`}),(0,F.jsxs)(D,{htmlFor:t.name,className:`font-normal cursor-pointer`,children:[t.label,t.required&&(0,F.jsx)(`span`,{className:`text-destructive ml-1`,children:`*`})]})]}),p[t.name]&&(0,F.jsx)(`p`,{className:`text-xs text-destructive ml-6`,children:n(`actionDialog.requiredError`,{label:t.label})}),t.helpText&&(0,F.jsx)(`p`,{className:`text-xs text-muted-foreground ml-6`,children:t.helpText})]},t.name)}let i=t.type===`lookup`||t.type===`reference`;return(0,F.jsxs)(`div`,{className:`grid gap-2`,children:[(0,F.jsxs)(D,{htmlFor:t.name,children:[t.label,t.required&&(0,F.jsx)(`span`,{className:`text-destructive ml-1`,children:`*`})]}),t.type===`select`&&t.options?(0,F.jsxs)(o,{value:s[t.name]??``,onValueChange:e=>T(t.name,e),children:[(0,F.jsx)(h,{id:t.name,className:p[t.name]?`border-destructive`:``,children:(0,F.jsx)(v,{placeholder:t.placeholder||n(`actionDialog.selectPlaceholder`,{label:t.label})})}),(0,F.jsx)(_,{children:t.options.map(e=>(0,F.jsx)(l,{value:e.value,children:e.label},e.value))})]}):i&&t.referenceTo?(0,F.jsx)(M,{value:s[t.name]??null,onChange:e=>T(t.name,e),field:{name:t.name,type:`lookup`,reference_to:t.referenceTo,display_field:t.displayField,id_field:t.idField,description_field:t.descriptionField,multiple:t.multiple,title_format:t.titleFormat,lookup_columns:t.lookupColumns,lookup_filters:t.lookupFilters,lookup_page_size:t.lookupPageSize,depends_on:t.dependsOn,placeholder:t.placeholder}}):t.type===`textarea`?(0,F.jsx)(j,{id:t.name,value:s[t.name]??``,onChange:e=>T(t.name,e.target.value),placeholder:t.placeholder,className:p[t.name]?`border-destructive`:``}):t.type===`number`?(0,F.jsx)(E,{id:t.name,type:`number`,value:s[t.name]??``,onChange:e=>T(t.name,e.target.value===``?void 0:e.target.valueAsNumber),placeholder:t.placeholder,className:p[t.name]?`border-destructive`:``}):(0,F.jsx)(E,{id:t.name,type:[`email`,`url`,`date`,`datetime-local`,`time`,`password`].includes(t.type)?t.type:`text`,value:s[t.name]??``,onChange:e=>T(t.name,e.target.value),placeholder:t.placeholder||(i?n(`actionDialog.lookupPlaceholder`,{label:t.label}):void 0),className:p[t.name]?`border-destructive`:``}),p[t.name]&&(0,F.jsx)(`p`,{className:`text-xs text-destructive`,children:n(`actionDialog.requiredError`,{label:t.label})}),t.helpText&&(0,F.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:t.helpText}),i&&!t.helpText&&(0,F.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:n(`actionDialog.lookupHelpText`)})]},t.name)})}),(0,F.jsxs)(a,{children:[(0,F.jsx)(w,{variant:`outline`,onClick:S,children:n(`actionDialog.cancel`)}),(0,F.jsx)(w,{onClick:x,children:n(`actionDialog.confirm`)})]})]})})}var ne=t(((e,t)=>{t.exports=function(){return typeof Promise==`function`&&Promise.prototype&&Promise.prototype.then}})),z=t((e=>{var t,n=[0,26,44,70,100,134,172,196,242,292,346,404,466,532,581,655,733,815,901,991,1085,1156,1258,1364,1474,1588,1706,1828,1921,2051,2185,2323,2465,2611,2761,2876,3034,3196,3362,3532,3706];e.getSymbolSize=function(e){if(!e)throw Error(`"version" cannot be null or undefined`);if(e<1||e>40)throw Error(`"version" should be in range from 1 to 40`);return e*4+17},e.getSymbolTotalCodewords=function(e){return n[e]},e.getBCHDigit=function(e){let t=0;for(;e!==0;)t++,e>>>=1;return t},e.setToSJISFunction=function(e){if(typeof e!=`function`)throw Error(`"toSJISFunc" is not a valid function.`);t=e},e.isKanjiModeEnabled=function(){return t!==void 0},e.toSJIS=function(e){return t(e)}})),B=t((e=>{e.L={bit:1},e.M={bit:0},e.Q={bit:3},e.H={bit:2};function t(t){if(typeof t!=`string`)throw Error(`Param is not a string`);switch(t.toLowerCase()){case`l`:case`low`:return e.L;case`m`:case`medium`:return e.M;case`q`:case`quartile`:return e.Q;case`h`:case`high`:return e.H;default:throw Error(`Unknown EC Level: `+t)}}e.isValid=function(e){return e&&e.bit!==void 0&&e.bit>=0&&e.bit<4},e.from=function(n,r){if(e.isValid(n))return n;try{return t(n)}catch{return r}}})),re=t(((e,t)=>{function n(){this.buffer=[],this.length=0}n.prototype={get:function(e){let t=Math.floor(e/8);return(this.buffer[t]>>>7-e%8&1)==1},put:function(e,t){for(let n=0;n<t;n++)this.putBit((e>>>t-n-1&1)==1)},getLengthInBits:function(){return this.length},putBit:function(e){let t=Math.floor(this.length/8);this.buffer.length<=t&&this.buffer.push(0),e&&(this.buffer[t]|=128>>>this.length%8),this.length++}},t.exports=n})),ie=t(((e,t)=>{function n(e){if(!e||e<1)throw Error(`BitMatrix size must be defined and greater than 0`);this.size=e,this.data=new Uint8Array(e*e),this.reservedBit=new Uint8Array(e*e)}n.prototype.set=function(e,t,n,r){let i=e*this.size+t;this.data[i]=n,r&&(this.reservedBit[i]=!0)},n.prototype.get=function(e,t){return this.data[e*this.size+t]},n.prototype.xor=function(e,t,n){this.data[e*this.size+t]^=n},n.prototype.isReserved=function(e,t){return this.reservedBit[e*this.size+t]},t.exports=n})),ae=t((e=>{var t=z().getSymbolSize;e.getRowColCoords=function(e){if(e===1)return[];let n=Math.floor(e/7)+2,r=t(e),i=r===145?26:Math.ceil((r-13)/(2*n-2))*2,a=[r-7];for(let e=1;e<n-1;e++)a[e]=a[e-1]-i;return a.push(6),a.reverse()},e.getPositions=function(t){let n=[],r=e.getRowColCoords(t),i=r.length;for(let e=0;e<i;e++)for(let t=0;t<i;t++)e===0&&t===0||e===0&&t===i-1||e===i-1&&t===0||n.push([r[e],r[t]]);return n}})),V=t((e=>{var t=z().getSymbolSize,n=7;e.getPositions=function(e){let r=t(e);return[[0,0],[r-n,0],[0,r-n]]}})),H=t((e=>{e.Patterns={PATTERN000:0,PATTERN001:1,PATTERN010:2,PATTERN011:3,PATTERN100:4,PATTERN101:5,PATTERN110:6,PATTERN111:7};var t={N1:3,N2:3,N3:40,N4:10};e.isValid=function(e){return e!=null&&e!==``&&!isNaN(e)&&e>=0&&e<=7},e.from=function(t){return e.isValid(t)?parseInt(t,10):void 0},e.getPenaltyN1=function(e){let n=e.size,r=0,i=0,a=0,o=null,s=null;for(let c=0;c<n;c++){i=a=0,o=s=null;for(let l=0;l<n;l++){let n=e.get(c,l);n===o?i++:(i>=5&&(r+=t.N1+(i-5)),o=n,i=1),n=e.get(l,c),n===s?a++:(a>=5&&(r+=t.N1+(a-5)),s=n,a=1)}i>=5&&(r+=t.N1+(i-5)),a>=5&&(r+=t.N1+(a-5))}return r},e.getPenaltyN2=function(e){let n=e.size,r=0;for(let t=0;t<n-1;t++)for(let i=0;i<n-1;i++){let n=e.get(t,i)+e.get(t,i+1)+e.get(t+1,i)+e.get(t+1,i+1);(n===4||n===0)&&r++}return r*t.N2},e.getPenaltyN3=function(e){let n=e.size,r=0,i=0,a=0;for(let t=0;t<n;t++){i=a=0;for(let o=0;o<n;o++)i=i<<1&2047|e.get(t,o),o>=10&&(i===1488||i===93)&&r++,a=a<<1&2047|e.get(o,t),o>=10&&(a===1488||a===93)&&r++}return r*t.N3},e.getPenaltyN4=function(e){let n=0,r=e.data.length;for(let t=0;t<r;t++)n+=e.data[t];return Math.abs(Math.ceil(n*100/r/5)-10)*t.N4};function n(t,n,r){switch(t){case e.Patterns.PATTERN000:return(n+r)%2==0;case e.Patterns.PATTERN001:return n%2==0;case e.Patterns.PATTERN010:return r%3==0;case e.Patterns.PATTERN011:return(n+r)%3==0;case e.Patterns.PATTERN100:return(Math.floor(n/2)+Math.floor(r/3))%2==0;case e.Patterns.PATTERN101:return n*r%2+n*r%3==0;case e.Patterns.PATTERN110:return(n*r%2+n*r%3)%2==0;case e.Patterns.PATTERN111:return(n*r%3+(n+r)%2)%2==0;default:throw Error(`bad maskPattern:`+t)}}e.applyMask=function(e,t){let r=t.size;for(let i=0;i<r;i++)for(let a=0;a<r;a++)t.isReserved(a,i)||t.xor(a,i,n(e,a,i))},e.getBestMask=function(t,n){let r=Object.keys(e.Patterns).length,i=0,a=1/0;for(let o=0;o<r;o++){n(o),e.applyMask(o,t);let r=e.getPenaltyN1(t)+e.getPenaltyN2(t)+e.getPenaltyN3(t)+e.getPenaltyN4(t);e.applyMask(o,t),r<a&&(a=r,i=o)}return i}})),U=t((e=>{var t=B(),n=[1,1,1,1,1,1,1,1,1,1,2,2,1,2,2,4,1,2,4,4,2,4,4,4,2,4,6,5,2,4,6,6,2,5,8,8,4,5,8,8,4,5,8,11,4,8,10,11,4,9,12,16,4,9,16,16,6,10,12,18,6,10,17,16,6,11,16,19,6,13,18,21,7,14,21,25,8,16,20,25,8,17,23,25,9,17,23,34,9,18,25,30,10,20,27,32,12,21,29,35,12,23,34,37,12,25,34,40,13,26,35,42,14,28,38,45,15,29,40,48,16,31,43,51,17,33,45,54,18,35,48,57,19,37,51,60,19,38,53,63,20,40,56,66,21,43,59,70,22,45,62,74,24,47,65,77,25,49,68,81],r=[7,10,13,17,10,16,22,28,15,26,36,44,20,36,52,64,26,48,72,88,36,64,96,112,40,72,108,130,48,88,132,156,60,110,160,192,72,130,192,224,80,150,224,264,96,176,260,308,104,198,288,352,120,216,320,384,132,240,360,432,144,280,408,480,168,308,448,532,180,338,504,588,196,364,546,650,224,416,600,700,224,442,644,750,252,476,690,816,270,504,750,900,300,560,810,960,312,588,870,1050,336,644,952,1110,360,700,1020,1200,390,728,1050,1260,420,784,1140,1350,450,812,1200,1440,480,868,1290,1530,510,924,1350,1620,540,980,1440,1710,570,1036,1530,1800,570,1064,1590,1890,600,1120,1680,1980,630,1204,1770,2100,660,1260,1860,2220,720,1316,1950,2310,750,1372,2040,2430];e.getBlocksCount=function(e,r){switch(r){case t.L:return n[(e-1)*4+0];case t.M:return n[(e-1)*4+1];case t.Q:return n[(e-1)*4+2];case t.H:return n[(e-1)*4+3];default:return}},e.getTotalCodewordsCount=function(e,n){switch(n){case t.L:return r[(e-1)*4+0];case t.M:return r[(e-1)*4+1];case t.Q:return r[(e-1)*4+2];case t.H:return r[(e-1)*4+3];default:return}}})),W=t((e=>{var t=new Uint8Array(512),n=new Uint8Array(256);(function(){let e=1;for(let r=0;r<255;r++)t[r]=e,n[e]=r,e<<=1,e&256&&(e^=285);for(let e=255;e<512;e++)t[e]=t[e-255]})(),e.log=function(e){if(e<1)throw Error(`log(`+e+`)`);return n[e]},e.exp=function(e){return t[e]},e.mul=function(e,r){return e===0||r===0?0:t[n[e]+n[r]]}})),G=t((e=>{var t=W();e.mul=function(e,n){let r=new Uint8Array(e.length+n.length-1);for(let i=0;i<e.length;i++)for(let a=0;a<n.length;a++)r[i+a]^=t.mul(e[i],n[a]);return r},e.mod=function(e,n){let r=new Uint8Array(e);for(;r.length-n.length>=0;){let e=r[0];for(let i=0;i<n.length;i++)r[i]^=t.mul(n[i],e);let i=0;for(;i<r.length&&r[i]===0;)i++;r=r.slice(i)}return r},e.generateECPolynomial=function(n){let r=new Uint8Array([1]);for(let i=0;i<n;i++)r=e.mul(r,new Uint8Array([1,t.exp(i)]));return r}})),K=t(((e,t)=>{var n=G();function r(e){this.genPoly=void 0,this.degree=e,this.degree&&this.initialize(this.degree)}r.prototype.initialize=function(e){this.degree=e,this.genPoly=n.generateECPolynomial(this.degree)},r.prototype.encode=function(e){if(!this.genPoly)throw Error(`Encoder not initialized`);let t=new Uint8Array(e.length+this.degree);t.set(e);let r=n.mod(t,this.genPoly),i=this.degree-r.length;if(i>0){let e=new Uint8Array(this.degree);return e.set(r,i),e}return r},t.exports=r})),q=t((e=>{e.isValid=function(e){return!isNaN(e)&&e>=1&&e<=40}})),J=t((e=>{var t=`[0-9]+`,n=`[A-Z $%*+\\-./:]+`,r=`(?:[u3000-u303F]|[u3040-u309F]|[u30A0-u30FF]|[uFF00-uFFEF]|[u4E00-u9FAF]|[u2605-u2606]|[u2190-u2195]|u203B|[u2010u2015u2018u2019u2025u2026u201Cu201Du2225u2260]|[u0391-u0451]|[u00A7u00A8u00B1u00B4u00D7u00F7])+`;r=r.replace(/u/g,`\\u`);var i=`(?:(?![A-Z0-9 $%*+\\-./:]|`+r+`)(?:.|[\r
2
2
  ]))+`;e.KANJI=new RegExp(r,`g`),e.BYTE_KANJI=RegExp(`[^A-Z0-9 $%*+\\-./:]+`,`g`),e.BYTE=new RegExp(i,`g`),e.NUMERIC=new RegExp(t,`g`),e.ALPHANUMERIC=new RegExp(n,`g`);var a=RegExp(`^`+r+`$`),o=RegExp(`^[0-9]+$`),s=RegExp(`^[A-Z0-9 $%*+\\-./:]+$`);e.testKanji=function(e){return a.test(e)},e.testNumeric=function(e){return o.test(e)},e.testAlphanumeric=function(e){return s.test(e)}})),Y=t((e=>{var t=q(),n=J();e.NUMERIC={id:`Numeric`,bit:1,ccBits:[10,12,14]},e.ALPHANUMERIC={id:`Alphanumeric`,bit:2,ccBits:[9,11,13]},e.BYTE={id:`Byte`,bit:4,ccBits:[8,16,16]},e.KANJI={id:`Kanji`,bit:8,ccBits:[8,10,12]},e.MIXED={bit:-1},e.getCharCountIndicator=function(e,n){if(!e.ccBits)throw Error(`Invalid mode: `+e);if(!t.isValid(n))throw Error(`Invalid version: `+n);return n>=1&&n<10?e.ccBits[0]:n<27?e.ccBits[1]:e.ccBits[2]},e.getBestModeForData=function(t){return n.testNumeric(t)?e.NUMERIC:n.testAlphanumeric(t)?e.ALPHANUMERIC:n.testKanji(t)?e.KANJI:e.BYTE},e.toString=function(e){if(e&&e.id)return e.id;throw Error(`Invalid mode`)},e.isValid=function(e){return e&&e.bit&&e.ccBits};function r(t){if(typeof t!=`string`)throw Error(`Param is not a string`);switch(t.toLowerCase()){case`numeric`:return e.NUMERIC;case`alphanumeric`:return e.ALPHANUMERIC;case`kanji`:return e.KANJI;case`byte`:return e.BYTE;default:throw Error(`Unknown mode: `+t)}}e.from=function(t,n){if(e.isValid(t))return t;try{return r(t)}catch{return n}}})),oe=t((e=>{var t=z(),n=U(),r=B(),i=Y(),a=q(),o=7973,s=t.getBCHDigit(o);function c(t,n,r){for(let i=1;i<=40;i++)if(n<=e.getCapacity(i,r,t))return i}function l(e,t){return i.getCharCountIndicator(e,t)+4}function u(e,t){let n=0;return e.forEach(function(e){let r=l(e.mode,t);n+=r+e.getBitsLength()}),n}function d(t,n){for(let r=1;r<=40;r++)if(u(t,r)<=e.getCapacity(r,n,i.MIXED))return r}e.from=function(e,t){return a.isValid(e)?parseInt(e,10):t},e.getCapacity=function(e,r,o){if(!a.isValid(e))throw Error(`Invalid QR Code version`);o===void 0&&(o=i.BYTE);let s=(t.getSymbolTotalCodewords(e)-n.getTotalCodewordsCount(e,r))*8;if(o===i.MIXED)return s;let c=s-l(o,e);switch(o){case i.NUMERIC:return Math.floor(c/10*3);case i.ALPHANUMERIC:return Math.floor(c/11*2);case i.KANJI:return Math.floor(c/13);case i.BYTE:default:return Math.floor(c/8)}},e.getBestVersionForData=function(e,t){let n,i=r.from(t,r.M);if(Array.isArray(e)){if(e.length>1)return d(e,i);if(e.length===0)return 1;n=e[0]}else n=e;return c(n.mode,n.getLength(),i)},e.getEncodedBits=function(e){if(!a.isValid(e)||e<7)throw Error(`Invalid QR Code version`);let n=e<<12;for(;t.getBCHDigit(n)-s>=0;)n^=o<<t.getBCHDigit(n)-s;return e<<12|n}})),se=t((e=>{var t=z(),n=1335,r=21522,i=t.getBCHDigit(n);e.getEncodedBits=function(e,a){let o=e.bit<<3|a,s=o<<10;for(;t.getBCHDigit(s)-i>=0;)s^=n<<t.getBCHDigit(s)-i;return(o<<10|s)^r}})),ce=t(((e,t)=>{var n=Y();function r(e){this.mode=n.NUMERIC,this.data=e.toString()}r.getBitsLength=function(e){return 10*Math.floor(e/3)+(e%3?e%3*3+1:0)},r.prototype.getLength=function(){return this.data.length},r.prototype.getBitsLength=function(){return r.getBitsLength(this.data.length)},r.prototype.write=function(e){let t,n,r;for(t=0;t+3<=this.data.length;t+=3)n=this.data.substr(t,3),r=parseInt(n,10),e.put(r,10);let i=this.data.length-t;i>0&&(n=this.data.substr(t),r=parseInt(n,10),e.put(r,i*3+1))},t.exports=r})),le=t(((e,t)=>{var n=Y(),r=`0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ $%*+-./:`.split(``);function i(e){this.mode=n.ALPHANUMERIC,this.data=e}i.getBitsLength=function(e){return 11*Math.floor(e/2)+e%2*6},i.prototype.getLength=function(){return this.data.length},i.prototype.getBitsLength=function(){return i.getBitsLength(this.data.length)},i.prototype.write=function(e){let t;for(t=0;t+2<=this.data.length;t+=2){let n=r.indexOf(this.data[t])*45;n+=r.indexOf(this.data[t+1]),e.put(n,11)}this.data.length%2&&e.put(r.indexOf(this.data[t]),6)},t.exports=i})),ue=t(((e,t)=>{var n=Y();function r(e){this.mode=n.BYTE,typeof e==`string`?this.data=new TextEncoder().encode(e):this.data=new Uint8Array(e)}r.getBitsLength=function(e){return e*8},r.prototype.getLength=function(){return this.data.length},r.prototype.getBitsLength=function(){return r.getBitsLength(this.data.length)},r.prototype.write=function(e){for(let t=0,n=this.data.length;t<n;t++)e.put(this.data[t],8)},t.exports=r})),de=t(((e,t)=>{var n=Y(),r=z();function i(e){this.mode=n.KANJI,this.data=e}i.getBitsLength=function(e){return e*13},i.prototype.getLength=function(){return this.data.length},i.prototype.getBitsLength=function(){return i.getBitsLength(this.data.length)},i.prototype.write=function(e){let t;for(t=0;t<this.data.length;t++){let n=r.toSJIS(this.data[t]);if(n>=33088&&n<=40956)n-=33088;else if(n>=57408&&n<=60351)n-=49472;else throw Error(`Invalid SJIS character: `+this.data[t]+`
3
3
  Make sure your charset is UTF-8`);n=(n>>>8&255)*192+(n&255),e.put(n,13)}},t.exports=i})),fe=t(((e,t)=>{var n={single_source_shortest_paths:function(e,t,r){var i={},a={};a[t]=0;var o=n.PriorityQueue.make();o.push(t,0);for(var s,c,l,u,d,f,p,m,h;!o.empty();)for(l in s=o.pop(),c=s.value,u=s.cost,d=e[c]||{},d)d.hasOwnProperty(l)&&(f=d[l],p=u+f,m=a[l],h=a[l]===void 0,(h||m>p)&&(a[l]=p,o.push(l,p),i[l]=c));if(r!==void 0&&a[r]===void 0){var g=[`Could not find a path from `,t,` to `,r,`.`].join(``);throw Error(g)}return i},extract_shortest_path_from_predecessor_list:function(e,t){for(var n=[],r=t;r;)n.push(r),e[r],r=e[r];return n.reverse(),n},find_path:function(e,t,r){var i=n.single_source_shortest_paths(e,t,r);return n.extract_shortest_path_from_predecessor_list(i,r)},PriorityQueue:{make:function(e){var t=n.PriorityQueue,r={},i;for(i in e||={},t)t.hasOwnProperty(i)&&(r[i]=t[i]);return r.queue=[],r.sorter=e.sorter||t.default_sorter,r},default_sorter:function(e,t){return e.cost-t.cost},push:function(e,t){var n={value:e,cost:t};this.queue.push(n),this.queue.sort(this.sorter)},pop:function(){return this.queue.shift()},empty:function(){return this.queue.length===0}}};t!==void 0&&(t.exports=n)})),pe=t((e=>{var t=Y(),n=ce(),r=le(),i=ue(),a=de(),o=J(),s=z(),c=fe();function l(e){return unescape(encodeURIComponent(e)).length}function u(e,t,n){let r=[],i;for(;(i=e.exec(n))!==null;)r.push({data:i[0],index:i.index,mode:t,length:i[0].length});return r}function d(e){let n=u(o.NUMERIC,t.NUMERIC,e),r=u(o.ALPHANUMERIC,t.ALPHANUMERIC,e),i,a;return s.isKanjiModeEnabled()?(i=u(o.BYTE,t.BYTE,e),a=u(o.KANJI,t.KANJI,e)):(i=u(o.BYTE_KANJI,t.BYTE,e),a=[]),n.concat(r,i,a).sort(function(e,t){return e.index-t.index}).map(function(e){return{data:e.data,mode:e.mode,length:e.length}})}function f(e,o){switch(o){case t.NUMERIC:return n.getBitsLength(e);case t.ALPHANUMERIC:return r.getBitsLength(e);case t.KANJI:return a.getBitsLength(e);case t.BYTE:return i.getBitsLength(e)}}function p(e){return e.reduce(function(e,t){let n=e.length-1>=0?e[e.length-1]:null;return n&&n.mode===t.mode?(e[e.length-1].data+=t.data,e):(e.push(t),e)},[])}function m(e){let n=[];for(let r=0;r<e.length;r++){let i=e[r];switch(i.mode){case t.NUMERIC:n.push([i,{data:i.data,mode:t.ALPHANUMERIC,length:i.length},{data:i.data,mode:t.BYTE,length:i.length}]);break;case t.ALPHANUMERIC:n.push([i,{data:i.data,mode:t.BYTE,length:i.length}]);break;case t.KANJI:n.push([i,{data:i.data,mode:t.BYTE,length:l(i.data)}]);break;case t.BYTE:n.push([{data:i.data,mode:t.BYTE,length:l(i.data)}])}}return n}function h(e,n){let r={},i={start:{}},a=[`start`];for(let o=0;o<e.length;o++){let s=e[o],c=[];for(let e=0;e<s.length;e++){let l=s[e],u=``+o+e;c.push(u),r[u]={node:l,lastCount:0},i[u]={};for(let e=0;e<a.length;e++){let o=a[e];r[o]&&r[o].node.mode===l.mode?(i[o][u]=f(r[o].lastCount+l.length,l.mode)-f(r[o].lastCount,l.mode),r[o].lastCount+=l.length):(r[o]&&(r[o].lastCount=l.length),i[o][u]=f(l.length,l.mode)+4+t.getCharCountIndicator(l.mode,n))}}a=c}for(let e=0;e<a.length;e++)i[a[e]].end=0;return{map:i,table:r}}function g(e,o){let c,l=t.getBestModeForData(e);if(c=t.from(o,l),c!==t.BYTE&&c.bit<l.bit)throw Error(`"`+e+`" cannot be encoded with mode `+t.toString(c)+`.
4
4
  Suggested mode is: `+t.toString(l));switch(c===t.KANJI&&!s.isKanjiModeEnabled()&&(c=t.BYTE),c){case t.NUMERIC:return new n(e);case t.ALPHANUMERIC:return new r(e);case t.KANJI:return new a(e);case t.BYTE:return new i(e)}}e.fromArray=function(e){return e.reduce(function(e,t){return typeof t==`string`?e.push(g(t,null)):t.data&&e.push(g(t.data,t.mode)),e},[])},e.fromString=function(t,n){let r=h(m(d(t,s.isKanjiModeEnabled())),n),i=c.find_path(r.map,`start`,`end`),a=[];for(let e=1;e<i.length-1;e++)a.push(r.table[i[e]].node);return e.fromArray(p(a))},e.rawSplit=function(t){return e.fromArray(d(t,s.isKanjiModeEnabled()))}})),me=t((e=>{var t=z(),n=B(),r=re(),i=ie(),a=ae(),o=V(),s=H(),c=U(),l=K(),u=oe(),d=se(),f=Y(),p=pe();function m(e,t){let n=e.size,r=o.getPositions(t);for(let t=0;t<r.length;t++){let i=r[t][0],a=r[t][1];for(let t=-1;t<=7;t++)if(!(i+t<=-1||n<=i+t))for(let r=-1;r<=7;r++)a+r<=-1||n<=a+r||(t>=0&&t<=6&&(r===0||r===6)||r>=0&&r<=6&&(t===0||t===6)||t>=2&&t<=4&&r>=2&&r<=4?e.set(i+t,a+r,!0,!0):e.set(i+t,a+r,!1,!0))}}function h(e){let t=e.size;for(let n=8;n<t-8;n++){let t=n%2==0;e.set(n,6,t,!0),e.set(6,n,t,!0)}}function g(e,t){let n=a.getPositions(t);for(let t=0;t<n.length;t++){let r=n[t][0],i=n[t][1];for(let t=-2;t<=2;t++)for(let n=-2;n<=2;n++)t===-2||t===2||n===-2||n===2||t===0&&n===0?e.set(r+t,i+n,!0,!0):e.set(r+t,i+n,!1,!0)}}function _(e,t){let n=e.size,r=u.getEncodedBits(t),i,a,o;for(let t=0;t<18;t++)i=Math.floor(t/3),a=t%3+n-8-3,o=(r>>t&1)==1,e.set(i,a,o,!0),e.set(a,i,o,!0)}function v(e,t,n){let r=e.size,i=d.getEncodedBits(t,n),a,o;for(a=0;a<15;a++)o=(i>>a&1)==1,a<6?e.set(a,8,o,!0):a<8?e.set(a+1,8,o,!0):e.set(r-15+a,8,o,!0),a<8?e.set(8,r-a-1,o,!0):a<9?e.set(8,15-a-1+1,o,!0):e.set(8,15-a-1,o,!0);e.set(r-8,8,1,!0)}function y(e,t){let n=e.size,r=-1,i=n-1,a=7,o=0;for(let s=n-1;s>0;s-=2)for(s===6&&s--;;){for(let n=0;n<2;n++)if(!e.isReserved(i,s-n)){let r=!1;o<t.length&&(r=(t[o]>>>a&1)==1),e.set(i,s-n,r),a--,a===-1&&(o++,a=7)}if(i+=r,i<0||n<=i){i-=r,r=-r;break}}}function b(e,n,i){let a=new r;i.forEach(function(t){a.put(t.mode.bit,4),a.put(t.getLength(),f.getCharCountIndicator(t.mode,e)),t.write(a)});let o=(t.getSymbolTotalCodewords(e)-c.getTotalCodewordsCount(e,n))*8;for(a.getLengthInBits()+4<=o&&a.put(0,4);a.getLengthInBits()%8!=0;)a.putBit(0);let s=(o-a.getLengthInBits())/8;for(let e=0;e<s;e++)a.put(e%2?17:236,8);return x(a,e,n)}function x(e,n,r){let i=t.getSymbolTotalCodewords(n),a=i-c.getTotalCodewordsCount(n,r),o=c.getBlocksCount(n,r),s=o-i%o,u=Math.floor(i/o),d=Math.floor(a/o),f=d+1,p=u-d,m=new l(p),h=0,g=Array(o),_=Array(o),v=0,y=new Uint8Array(e.buffer);for(let e=0;e<o;e++){let t=e<s?d:f;g[e]=y.slice(h,h+t),_[e]=m.encode(g[e]),h+=t,v=Math.max(v,t)}let b=new Uint8Array(i),x=0,S,C;for(S=0;S<v;S++)for(C=0;C<o;C++)S<g[C].length&&(b[x++]=g[C][S]);for(S=0;S<p;S++)for(C=0;C<o;C++)b[x++]=_[C][S];return b}function S(e,n,r,a){let o;if(Array.isArray(e))o=p.fromArray(e);else if(typeof e==`string`){let t=n;if(!t){let n=p.rawSplit(e);t=u.getBestVersionForData(n,r)}o=p.fromString(e,t||40)}else throw Error(`Invalid data`);let c=u.getBestVersionForData(o,r);if(!c)throw Error(`The amount of data is too big to be stored in a QR Code`);if(!n)n=c;else if(n<c)throw Error(`