@synertech/ui 0.51.0 → 0.52.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 (147) hide show
  1. package/.claude/skills/use-synertech-ui/SKILL.md +183 -147
  2. package/README.md +27 -19
  3. package/dist/components/advance-detachable/AdvanceDetachable.cjs +1 -1
  4. package/dist/components/advance-detachable/AdvanceDetachable.js +1 -1
  5. package/dist/components/area-chart/AreaChart.cjs +1 -1
  6. package/dist/components/area-chart/AreaChart.js +1 -1
  7. package/dist/components/avatar/Avatar.cjs +1 -1
  8. package/dist/components/avatar/Avatar.js +1 -1
  9. package/dist/components/avatar/AvatarImage.cjs +1 -0
  10. package/dist/components/avatar/AvatarImage.js +1 -0
  11. package/dist/components/banner/Banner.cjs +1 -1
  12. package/dist/components/banner/Banner.js +1 -1
  13. package/dist/components/bar-chart/BarChart.cjs +1 -1
  14. package/dist/components/bar-chart/BarChart.js +1 -1
  15. package/dist/components/box-plot/BoxPlot.cjs +1 -1
  16. package/dist/components/box-plot/BoxPlot.js +1 -1
  17. package/dist/components/breadcrumb/Breadcrumb.cjs +1 -1
  18. package/dist/components/breadcrumb/Breadcrumb.js +1 -1
  19. package/dist/components/bullet-chart/BulletChart.cjs +1 -1
  20. package/dist/components/bullet-chart/BulletChart.js +1 -1
  21. package/dist/components/calendar/Calendar.cjs +1 -1
  22. package/dist/components/calendar/Calendar.js +1 -1
  23. package/dist/components/candlestick-chart/CandlestickChart.cjs +1 -1
  24. package/dist/components/candlestick-chart/CandlestickChart.js +1 -1
  25. package/dist/components/card/Card.cjs +1 -1
  26. package/dist/components/card/Card.js +1 -1
  27. package/dist/components/chart/ChartAnnotations.cjs +1 -1
  28. package/dist/components/chart/ChartAnnotations.js +1 -1
  29. package/dist/components/chart/ChartBrush.cjs +1 -1
  30. package/dist/components/chart/ChartBrush.js +1 -1
  31. package/dist/components/chart/ChartContainer.cjs +1 -1
  32. package/dist/components/chart/ChartContainer.js +1 -1
  33. package/dist/components/chart/ChartExportButton.cjs +1 -1
  34. package/dist/components/chart/ChartExportButton.js +1 -1
  35. package/dist/components/chart/ChartPatterns.cjs +1 -1
  36. package/dist/components/chart/ChartPatterns.js +1 -1
  37. package/dist/components/chart/ChartPlotClip.cjs +1 -0
  38. package/dist/components/chart/ChartPlotClip.js +1 -0
  39. package/dist/components/chart/ChartSync.cjs +1 -1
  40. package/dist/components/chart/ChartSync.js +1 -1
  41. package/dist/components/chart/ChartTableView.cjs +1 -1
  42. package/dist/components/chart/ChartTableView.js +1 -1
  43. package/dist/components/chart/exportSource.cjs +1 -0
  44. package/dist/components/chart/exportSource.js +1 -0
  45. package/dist/components/chart/palette.cjs +1 -1
  46. package/dist/components/chart/palette.js +1 -1
  47. package/dist/components/chart/useChartSize.cjs +1 -1
  48. package/dist/components/chart/useChartSize.js +1 -1
  49. package/dist/components/chart/utils/bins.cjs +1 -1
  50. package/dist/components/chart/utils/bins.js +1 -1
  51. package/dist/components/chart/utils/cartesian.cjs +1 -1
  52. package/dist/components/chart/utils/cartesian.js +1 -1
  53. package/dist/components/chart/utils/export.cjs +7 -1
  54. package/dist/components/chart/utils/export.js +7 -1
  55. package/dist/components/chart/utils/format.cjs +1 -1
  56. package/dist/components/chart/utils/format.js +1 -1
  57. package/dist/components/chart/utils/keyboard.cjs +1 -1
  58. package/dist/components/chart/utils/keyboard.js +1 -1
  59. package/dist/components/chart/utils/period.cjs +1 -1
  60. package/dist/components/chart/utils/period.js +1 -1
  61. package/dist/components/chart/utils/regression.cjs +1 -0
  62. package/dist/components/chart/utils/regression.js +1 -0
  63. package/dist/components/chart/utils/stack.cjs +1 -1
  64. package/dist/components/chart/utils/stack.js +1 -1
  65. package/dist/components/chart/utils/ticks.cjs +1 -1
  66. package/dist/components/chart/utils/ticks.js +1 -1
  67. package/dist/components/checkbox/Checkbox.cjs +1 -1
  68. package/dist/components/checkbox/Checkbox.js +1 -1
  69. package/dist/components/circular-progress/CircularProgress.cjs +1 -1
  70. package/dist/components/circular-progress/CircularProgress.js +1 -1
  71. package/dist/components/datagrid/DataGrid.cjs +1 -1
  72. package/dist/components/datagrid/DataGrid.js +1 -1
  73. package/dist/components/detachable/Detachable.cjs +1 -1
  74. package/dist/components/detachable/Detachable.js +1 -1
  75. package/dist/components/detachable/popup-window.cjs +1 -0
  76. package/dist/components/detachable/popup-window.js +1 -0
  77. package/dist/components/device-mockup/DeviceMockup.cjs +1 -1
  78. package/dist/components/device-mockup/DeviceMockup.js +1 -1
  79. package/dist/components/divider/Divider.cjs +1 -1
  80. package/dist/components/divider/Divider.js +1 -1
  81. package/dist/components/dumbbell-chart/DumbbellChart.cjs +1 -1
  82. package/dist/components/dumbbell-chart/DumbbellChart.js +1 -1
  83. package/dist/components/file-selector/FileSelector.cjs +1 -1
  84. package/dist/components/file-selector/FileSelector.js +1 -1
  85. package/dist/components/footer/FooterBottom.cjs +1 -1
  86. package/dist/components/footer/FooterBottom.js +1 -1
  87. package/dist/components/form/input/Input.cjs +1 -1
  88. package/dist/components/form/input/Input.js +1 -1
  89. package/dist/components/form/mention-input/MentionInput.cjs +5 -4
  90. package/dist/components/form/mention-input/MentionInput.js +5 -4
  91. package/dist/components/form/number-input/NumberInput.cjs +1 -1
  92. package/dist/components/form/number-input/NumberInput.js +1 -1
  93. package/dist/components/form/shared/InputWrapper.cjs +1 -1
  94. package/dist/components/form/shared/InputWrapper.js +1 -1
  95. package/dist/components/funnel-chart/FunnelChart.cjs +1 -1
  96. package/dist/components/funnel-chart/FunnelChart.js +1 -1
  97. package/dist/components/gantt-chart/GanttChart.cjs +1 -1
  98. package/dist/components/gantt-chart/GanttChart.js +1 -1
  99. package/dist/components/heat-map/Heatmap.cjs +1 -1
  100. package/dist/components/heat-map/Heatmap.js +1 -1
  101. package/dist/components/image-uploader/ImageUploader.cjs +1 -1
  102. package/dist/components/image-uploader/ImageUploader.js +1 -1
  103. package/dist/components/line-chart/LineChart.cjs +1 -1
  104. package/dist/components/line-chart/LineChart.js +1 -1
  105. package/dist/components/pagination/Pagination.cjs +1 -1
  106. package/dist/components/pagination/Pagination.js +1 -1
  107. package/dist/components/pie-chart/PieChart.cjs +1 -1
  108. package/dist/components/pie-chart/PieChart.js +1 -1
  109. package/dist/components/progress-bar/ProgressBar.cjs +1 -1
  110. package/dist/components/progress-bar/ProgressBar.js +1 -1
  111. package/dist/components/radio-button/RadioButton.cjs +1 -1
  112. package/dist/components/radio-button/RadioButton.js +1 -1
  113. package/dist/components/scatter-chart/ScatterChart.cjs +1 -1
  114. package/dist/components/scatter-chart/ScatterChart.js +1 -1
  115. package/dist/components/scatter-chart/index.cjs +1 -1
  116. package/dist/components/scatter-chart/index.js +1 -1
  117. package/dist/components/schema-editor/SchemaEditor.cjs +1 -1
  118. package/dist/components/schema-editor/SchemaEditor.js +1 -1
  119. package/dist/components/schema-editor/canvas/GridLayer.cjs +1 -1
  120. package/dist/components/schema-editor/canvas/GridLayer.js +1 -1
  121. package/dist/components/schema-editor/relations/SchemaRelationRenderer.cjs +1 -1
  122. package/dist/components/schema-editor/relations/SchemaRelationRenderer.js +1 -1
  123. package/dist/components/schema-editor/utils/sql-export.cjs +4 -4
  124. package/dist/components/schema-editor/utils/sql-export.js +7 -7
  125. package/dist/components/slider/Slider.cjs +1 -1
  126. package/dist/components/slider/Slider.js +1 -1
  127. package/dist/components/sparkline/Sparkline.cjs +1 -1
  128. package/dist/components/sparkline/Sparkline.js +1 -1
  129. package/dist/components/table/TableRow.cjs +1 -1
  130. package/dist/components/table/TableRow.js +1 -1
  131. package/dist/components/waterfall-chart/WaterfallChart.cjs +1 -1
  132. package/dist/components/waterfall-chart/WaterfallChart.js +1 -1
  133. package/dist/components/workflow-editor/WorkflowEditor.cjs +1 -1
  134. package/dist/components/workflow-editor/WorkflowEditor.js +1 -1
  135. package/dist/components/workflow-editor/canvas/GridLayer.cjs +1 -1
  136. package/dist/components/workflow-editor/canvas/GridLayer.js +1 -1
  137. package/dist/index.d.cts +433 -170
  138. package/dist/index.d.ts +433 -170
  139. package/dist/lib/accept.cjs +1 -0
  140. package/dist/lib/accept.js +1 -0
  141. package/dist/lib/css-value.cjs +1 -0
  142. package/dist/lib/css-value.js +1 -0
  143. package/dist/lib/ui-labels.cjs +1 -1
  144. package/dist/lib/ui-labels.js +1 -1
  145. package/dist/styles-no-preflight.css +10270 -0
  146. package/dist/styles.css +301 -28
  147. package/package.json +9 -4
@@ -1 +1 @@
1
- "use strict";"use client";var Or=Object.create;var Re=Object.defineProperty;var Ar=Object.getOwnPropertyDescriptor;var Hr=Object.getOwnPropertyNames;var Lr=Object.getPrototypeOf,Vr=Object.prototype.hasOwnProperty;var Kr=(o,l)=>{for(var d in l)Re(o,d,{get:l[d],enumerable:!0})},It=(o,l,d,u)=>{if(l&&typeof l=="object"||typeof l=="function")for(let c of Hr(l))!Vr.call(o,c)&&c!==d&&Re(o,c,{get:()=>l[c],enumerable:!(u=Ar(l,c))||u.enumerable});return o};var Wr=(o,l,d)=>(d=o!=null?Or(Lr(o)):{},It(l||!o||!o.__esModule?Re(d,"default",{value:o,enumerable:!0}):d,o)),Br=o=>It(Re({},"__esModule",{value:!0}),o);var un={};Kr(un,{DataGrid:()=>cn,resetRowKeyWarning:()=>Zr});module.exports=Br(un);var a=Wr(require("react"),1),y=require("../../lib/cn.cjs"),zt=require("../../lib/csv.cjs"),E=require("../../lib/i18n.cjs"),r=require("react/jsx-runtime"),I={compact:"px-3 py-1.5",default:"px-4 py-3",comfortable:"px-6 py-4"},Ur={compact:"px-3 py-0",default:"px-4 py-0",comfortable:"px-6 py-0"},Te={compact:"text-xs",default:"text-sm",comfortable:"text-base"},jr=()=>(0,r.jsx)("svg",{className:"w-3.5 h-3.5",viewBox:"0 0 16 16",fill:"currentColor",children:(0,r.jsx)("path",{d:"M8 3l4 5H4l4-5z"})}),qr=()=>(0,r.jsx)("svg",{className:"w-3.5 h-3.5",viewBox:"0 0 16 16",fill:"currentColor",children:(0,r.jsx)("path",{d:"M8 13l4-5H4l4 5z"})}),$r=()=>(0,r.jsx)("svg",{className:"w-3.5 h-3.5 opacity-30",viewBox:"0 0 16 16",fill:"currentColor",children:(0,r.jsx)("path",{d:"M8 3l3 4H5l3-4zM8 13l3-4H5l3 4z"})}),Pt=({className:o})=>(0,r.jsx)("svg",{className:(0,y.cn)("w-4 h-4",o),viewBox:"0 0 20 20",fill:"currentColor",children:(0,r.jsx)("path",{fillRule:"evenodd",d:"M5.23 7.21a.75.75 0 011.06.02L10 11.168l3.71-3.938a.75.75 0 111.08 1.04l-4.25 4.5a.75.75 0 01-1.08 0l-4.25-4.5a.75.75 0 01.02-1.06z",clipRule:"evenodd"})}),Xr=()=>(0,r.jsx)("svg",{className:"w-4 h-4 text-gray-500 dark:text-gray-400",viewBox:"0 0 20 20",fill:"currentColor",children:(0,r.jsx)("path",{fillRule:"evenodd",d:"M9 3.5a5.5 5.5 0 100 11 5.5 5.5 0 000-11zM2 9a7 7 0 1112.452 4.391l3.328 3.329a.75.75 0 11-1.06 1.06l-3.329-3.328A7 7 0 012 9z",clipRule:"evenodd"})}),_r=()=>(0,r.jsx)("svg",{className:"w-4 h-4 text-gray-500 dark:text-gray-400",viewBox:"0 0 20 20",fill:"currentColor",children:(0,r.jsx)("path",{d:"M7 4a1.5 1.5 0 110-3 1.5 1.5 0 010 3zm6 0a1.5 1.5 0 110-3 1.5 1.5 0 010 3zM7 10.5a1.5 1.5 0 110-3 1.5 1.5 0 010 3zm6 0a1.5 1.5 0 110-3 1.5 1.5 0 010 3zM7 17a1.5 1.5 0 110-3 1.5 1.5 0 010 3zm6 0a1.5 1.5 0 110-3 1.5 1.5 0 010 3z"})}),Jr=()=>(0,r.jsx)("svg",{className:"w-3.5 h-3.5",viewBox:"0 0 20 20",fill:"currentColor",children:(0,r.jsx)("path",{fillRule:"evenodd",d:"M2.628 1.601C5.028 1.206 7.49 1 10 1s4.973.206 7.372.601a.75.75 0 01.628.74v2.288a2.25 2.25 0 01-.659 1.59l-4.682 4.683a2.25 2.25 0 00-.659 1.59v3.037c0 .684-.31 1.33-.844 1.757l-1.937 1.55A.75.75 0 018 18.25v-5.757a2.25 2.25 0 00-.659-1.591L2.659 6.22A2.25 2.25 0 012 4.629V2.34a.75.75 0 01.628-.74z",clipRule:"evenodd"})}),Qr=()=>(0,r.jsxs)("svg",{className:"w-4 h-4",viewBox:"0 0 20 20",fill:"currentColor",children:[(0,r.jsx)("path",{d:"M10.75 2.75a.75.75 0 00-1.5 0v8.614L6.295 8.235a.75.75 0 10-1.09 1.03l4.25 4.5a.75.75 0 001.09 0l4.25-4.5a.75.75 0 00-1.09-1.03l-2.955 3.129V2.75z"}),(0,r.jsx)("path",{d:"M3.5 12.75a.75.75 0 00-1.5 0v2.5A2.75 2.75 0 004.75 18h10.5A2.75 2.75 0 0018 15.25v-2.5a.75.75 0 00-1.5 0v2.5c0 .69-.56 1.25-1.25 1.25H4.75c-.69 0-1.25-.56-1.25-1.25v-2.5z"})]}),Yr=()=>(0,r.jsx)("svg",{className:"w-4 h-4",viewBox:"0 0 20 20",fill:"currentColor",children:(0,r.jsx)("path",{fillRule:"evenodd",d:"M2.5 3A1.5 1.5 0 001 4.5v11A1.5 1.5 0 002.5 17h15a1.5 1.5 0 001.5-1.5v-11A1.5 1.5 0 0017.5 3h-15zM2.5 4.5h6v11h-6v-11zm7.5 0h7.5v11H10v-11z",clipRule:"evenodd"})});function Ye(o,l,d){return typeof d=="function"?d(o,l):String(typeof d=="string"?o[d]:l)}var Ze=!1;function Zr(){Ze=!1}function en(){Ze||(Ze=!0,console.warn("[@synertech/ui] DataGrid has no `rowKey`: each row is known by its position in `data`. Selection, expansion and edits follow that position when `data` is refetched or reordered, and from one page to the next in server mode. Pass `rowKey` to tie them to the row."))}function O(o,l){return o[l]}function Ft(o,l){return l.map(d=>String(O(o,d)??"")).join(" / ")}function et(o){return o==null||typeof o=="string"&&o.trim()===""||typeof o=="number"&&Number.isNaN(o)||o instanceof Date&&Number.isNaN(o.getTime())}function tn(o,l,d){let u=et(o),c=et(l);return u||c?u===c?0:u?-1:1:o instanceof Date&&l instanceof Date?o.getTime()-l.getTime():typeof o=="number"&&typeof l=="number"?o-l:d.compare(String(o),String(l))}function rn(o,l){let d=String(o??"").toLowerCase(),u=l.value.toLowerCase();switch(l.operator){case"contains":return d.includes(u);case"equals":return d===u;case"startsWith":return d.startsWith(u);case"endsWith":return d.endsWith(u);case"gt":return Number(o)>Number(l.value);case"gte":return Number(o)>=Number(l.value);case"lt":return Number(o)<Number(l.value);case"lte":return Number(o)<=Number(l.value);case"isEmpty":return d==="";case"isNotEmpty":return d!=="";default:return!0}}function nn(o,l,d){let u=0,c=0,f=0,D=1/0,S=-1/0;for(let w of o){let N=O(w,l);if(et(N))continue;u++;let m=Number(N);Number.isNaN(m)||(c++,f+=m,m<D&&(D=m),m>S&&(S=m))}switch(d){case"count":return u;case"sum":return f;case"avg":return c===0?null:f/c;case"min":return c===0?null:D;case"max":return c===0?null:S}}function an(o,l,d){if(o==="count")return l;let u=o==="avg"?d.dataGridAggregateAvg:o==="sum"?d.dataGridAggregateSum:o==="min"?d.dataGridAggregateMin:d.dataGridAggregateMax;return(0,E.formatUILabel)(u,{value:l})}function on({cols:o,density:l}){return(0,r.jsx)("tr",{className:"border-b border-gray-200 dark:border-gray-700",children:Array.from({length:o}).map((d,u)=>(0,r.jsx)("td",{className:I[l],children:(0,r.jsx)("div",{className:"h-4 bg-gray-200 dark:bg-gray-700 rounded animate-pulse"})},u))})}function sn({column:o,value:l,onApply:d,onClear:u,labels:c}){let f=o.filterType??"text",D=String(o.header),S=f==="number"?[{value:"equals",label:c.dataGridOperatorEquals},{value:"gt",label:c.dataGridOperatorGreaterThan},{value:"gte",label:c.dataGridOperatorGreaterOrEqual},{value:"lt",label:c.dataGridOperatorLessThan},{value:"lte",label:c.dataGridOperatorLessOrEqual}]:[{value:"contains",label:c.dataGridOperatorContains},{value:"equals",label:c.dataGridOperatorEquals},{value:"startsWith",label:c.dataGridOperatorStartsWith},{value:"endsWith",label:c.dataGridOperatorEndsWith},{value:"isEmpty",label:c.dataGridOperatorIsEmpty},{value:"isNotEmpty",label:c.dataGridOperatorIsNotEmpty}],w=g=>g&&S.some(R=>R.value===g.operator)?g.operator:S[0].value,[N,m]=(0,a.useState)(!1),[P,Z]=(0,a.useState)(()=>w(l)),[$,K]=(0,a.useState)(l?.value??""),ee=(0,a.useRef)(null),A=()=>{N||(Z(w(l)),K(l?.value??"")),m(!N)};return(0,a.useEffect)(()=>{let g=R=>{ee.current&&!ee.current.contains(R.target)&&m(!1)};return N&&document.addEventListener("mousedown",g),()=>document.removeEventListener("mousedown",g)},[N]),(0,r.jsxs)("div",{className:"relative inline-block",ref:ee,onClick:g=>g.stopPropagation(),children:[(0,r.jsx)("button",{type:"button",onClick:A,className:(0,y.cn)("p-0.5 rounded hover:bg-gray-200 dark:hover:bg-gray-600 cursor-pointer",l&&"text-synertech-primary-600 dark:text-synertech-primary-400"),"aria-label":(0,E.formatUILabel)(c.dataGridFilterColumn,{column:D}),children:(0,r.jsx)(Jr,{})}),N&&(0,r.jsx)("div",{className:"absolute z-50 top-full left-0 mt-1 bg-white dark:bg-gray-800 border border-gray-200 dark:border-gray-700 rounded-lg shadow-lg p-3 min-w-[220px]",children:f==="select"&&o.filterOptions?(0,r.jsxs)("div",{className:"flex flex-col gap-1.5",children:[o.filterOptions.map(g=>(0,r.jsxs)("label",{className:"flex items-center gap-2 text-sm cursor-pointer",children:[(0,r.jsx)("input",{type:"radio",name:`filter-${o.key}`,value:g,checked:$===g,onChange:()=>K(g),className:"cursor-pointer"}),(0,r.jsx)("span",{className:"text-gray-700 dark:text-gray-300",children:g})]},g)),(0,r.jsxs)("div",{className:"flex gap-2 mt-2",children:[(0,r.jsx)("button",{type:"button",onClick:()=>{d({column:o.key,operator:"equals",value:$}),m(!1)},className:"px-2 py-1 text-xs bg-synertech-primary-600 text-synertech-on-primary rounded hover:bg-synertech-primary-700 cursor-pointer",children:c.dataGridFilterApply}),(0,r.jsx)("button",{type:"button",onClick:()=>{K(""),u(),m(!1)},className:"px-2 py-1 text-xs text-gray-600 dark:text-gray-400 hover:text-gray-800 dark:hover:text-gray-200 cursor-pointer",children:c.dataGridFilterClear})]})]}):(0,r.jsxs)("div",{className:"flex flex-col gap-2",children:[(0,r.jsx)("select",{value:P,onChange:g=>Z(g.target.value),className:"text-xs border border-gray-300 dark:border-gray-600 rounded px-2 py-1 bg-white dark:bg-gray-700 text-gray-700 dark:text-gray-200",children:S.map(g=>(0,r.jsx)("option",{value:g.value,children:g.label},g.value))}),P!=="isEmpty"&&P!=="isNotEmpty"&&(0,r.jsx)("input",{type:f==="number"?"number":f==="date"?"date":"text",value:$,onChange:g=>K(g.target.value),placeholder:c.dataGridFilterValuePlaceholder,className:"text-xs border border-gray-300 dark:border-gray-600 rounded px-2 py-1 bg-white dark:bg-gray-700 text-gray-700 dark:text-gray-200",autoFocus:!0,"aria-label":(0,E.formatUILabel)(c.dataGridFilterValue,{column:D})}),(0,r.jsxs)("div",{className:"flex gap-2",children:[(0,r.jsx)("button",{type:"button",onClick:()=>{d({column:o.key,operator:P,value:$}),m(!1)},className:"px-2 py-1 text-xs bg-synertech-primary-600 text-synertech-on-primary rounded hover:bg-synertech-primary-700 cursor-pointer",children:c.dataGridFilterApply}),(0,r.jsx)("button",{type:"button",onClick:()=>{K(""),u(),m(!1)},className:"px-2 py-1 text-xs text-gray-600 dark:text-gray-400 hover:text-gray-800 dark:hover:text-gray-200 cursor-pointer",children:c.dataGridFilterClear})]})]})})]})}function ln({value:o,onSave:l,density:d,labels:u}){let[c,f]=(0,a.useState)(!1),[D,S]=(0,a.useState)(String(o??"")),w=(0,a.useRef)(null);if((0,a.useEffect)(()=>{c&&w.current&&(w.current.focus(),w.current.select())},[c]),!c)return(0,r.jsx)("div",{onDoubleClick:()=>{S(String(o??"")),f(!0)},className:"cursor-text min-h-[1.5em]",title:u.dataGridEditHint,children:String(o??"")});let N=()=>{f(!1),D!==String(o??"")&&l(D)};return(0,r.jsx)("input",{ref:w,type:"text",value:D,onChange:m=>S(m.target.value),onBlur:N,"aria-label":u.dataGridEditCell,onKeyDown:m=>{m.key==="Enter"&&N(),m.key==="Escape"&&f(!1)},className:(0,y.cn)("w-full border border-synertech-primary-500 rounded px-1 py-0.5 bg-white dark:bg-gray-700 text-gray-900 dark:text-gray-100 outline-none",Te[d])})}function dn(o,l){let{columns:d,data:u,rowKey:c,mode:f="client",sortable:D=!1,multiSort:S=!1,sort:w,defaultSort:N,onSort:m,pagination:P=!1,page:Z,onPageChange:$,onPageSizeChange:K,totalItems:ee,selectable:A=!1,selectionMode:g="multiple",selectedRows:R,onSelectionChange:W,searchable:tt=!1,searchPlaceholder:Ot,searchValue:ye,onSearch:xe,filters:X,onFilterChange:te,expandable:re=!1,expandedContent:rt,expandedRows:Ee,onExpandChange:nt,editable:at=!1,onCellEdit:At,reorderable:ne=!1,onReorder:ot,columnReorderable:B=!1,onColumnReorder:st,columnToggle:it=!1,hiddenColumns:De,onColumnVisibilityChange:lt,groupBy:we,renderGroupHeader:dt,exportable:ct=!1,exportFormats:Ht=["csv","json"],exportFilename:ut="export",exportNeutralizeFormulas:gt,virtualized:T=!1,rowHeight:U=40,virtualHeight:pt=400,density:v="default",striped:mt=!1,bordered:Ge=!1,borderless:Lt=!1,stickyHeader:yt=!1,maxHeight:ae,loading:Vt=!1,loadingRows:Kt=5,emptyState:Wt,labels:Bt,locale:Ut,showFooter:jt=!1,onRowClick:Me,onRowDoubleClick:bt,onRowContextMenu:ft,className:qt,rowClassName:Ie,cellClassName:$t,headerClassName:Xt}=o,b=(0,E.useUILabels)(Bt),Pe=(0,E.useUILocale)(Ut),ht=(0,a.useMemo)(()=>new Intl.Collator(Pe,{numeric:!0}),[Pe]),[_t,vt]=(0,a.useState)(N??[]),[Jt,Qt]=(0,a.useState)(1),oe=typeof P=="object"?P.pageSize:void 0,[Yt,xt]=(0,a.useState)(oe??10),[Zt,er]=(0,a.useState)(oe);oe!==Zt&&(er(oe),oe!==void 0&&xt(oe));let[tr,ke]=(0,a.useState)([]),[rr,wt]=(0,a.useState)(""),[nr,Fe]=(0,a.useState)([]),[ar,or]=(0,a.useState)([]),[sr,ir]=(0,a.useState)(()=>d.flatMap(e=>e.hidden?[e.key]:[])),[ze,lr]=(0,a.useState)({}),[Ce,dr]=(0,a.useState)(()=>d.map(e=>e.key)),[_,Oe]=(0,a.useState)(null),[se,kt]=(0,a.useState)(null),[Se,Ct]=(0,a.useState)(!1),[Ae,cr]=(0,a.useState)(new Set),He=(0,a.useRef)(null),[St,ur]=(0,a.useState)(0),[gr,Nt]=(0,a.useState)(null),Le=(0,a.useRef)(null),Ve=(0,a.useRef)(!1),F=w??_t,Rt=Z??Jt,k=R??tr,Ne=ye??rr,j=X??nr,be=Ee??ar,J=De??sr,ie=P?typeof P=="object"?P:{pageSize:10,pageSizeOptions:[10,25,50,100]}:null,fe=Yt;!c&&(A||re||at||ne)&&en();let Tt=e=>Ye(e.row,e.sourceIndex,c),H=(0,a.useMemo)(()=>{let e=new Map(d.map(s=>[s.key,s])),t=Ce.flatMap(s=>{let i=e.get(s);return i?[i]:[]}),n=new Set(t.map(s=>s.key));for(let s of d)n.has(s.key)||(t.push(s),n.add(s.key));return t.filter(s=>!J.includes(s.key))},[d,Ce,J]),le=(0,a.useMemo)(()=>{let e=u.map((t,n)=>({row:t,sourceIndex:n}));if(f==="server")return e;if(Ne){let t=Ne.toLowerCase();e=e.filter(({row:n})=>H.some(s=>{let i=O(n,s.key);return String(i??"").toLowerCase().includes(t)}))}if(j.length>0&&(e=e.filter(({row:t})=>j.every(n=>rn(O(t,n.column),n)))),F.length>0){let t=new Map(d.map(n=>[n.key,n]));e.sort((n,s)=>{for(let i of F){if(!i.direction)continue;let h=t.get(i.key),M=h?.sortComparator?h.sortComparator(n.row,s.row):tn(O(n.row,i.key),O(s.row,i.key),ht);if(M!==0)return i.direction==="asc"?M:-M}return 0})}return e},[u,f,Ne,j,F,H,d,ht]),he=(0,a.useMemo)(()=>le.map(e=>e.row),[le]),Ke=we?(Array.isArray(we)?we:[we]).join("\0"):"",de=(0,a.useMemo)(()=>Ke?Ke.split("\0"):[],[Ke]),ce=(0,a.useMemo)(()=>{if(de.length===0)return null;let e=new Map;for(let t of le){let n=Ft(t.row,de),s=e.get(n);s?s.push(t):e.set(n,[t])}return e},[le,de]),We=(0,a.useMemo)(()=>ce?Array.from(ce.values()).flat():le,[ce,le]),Be=ee??he.length,Q=Math.max(1,Math.ceil(Be/fe)),L=f==="server"&&ee===void 0?Rt:Math.min(Math.max(1,Rt),Q),Et=ie!==null,V=(0,a.useMemo)(()=>{if(!Et||f==="server")return We;let e=(L-1)*fe;return We.slice(e,e+fe)},[We,Et,L,fe,f]),Ue=(0,a.useMemo)(()=>V.map(e=>e.row),[V]),ue=(0,a.useMemo)(()=>{let e=[],t=null;return V.forEach((n,s)=>{if(ce){let i=Ft(n.row,de);if(i!==t&&(t=i,e.push({kind:"group",key:i,rows:ce.get(i)??[n]})),Ae.has(i))return}e.push({kind:"row",entry:n,index:s})}),e},[V,ce,de,Ae]),Dt=gr??(typeof ae=="number"?ae:pt),ge=ue.length,pr=(0,a.useMemo)(()=>{if(!T)return{start:0,end:ge};let e=Math.max(1,Math.ceil(Dt/U)),t=Math.min(St,Math.max(0,ge-e)),n=5;return{start:Math.max(0,t-n),end:Math.min(ge,t+e+n)}},[T,St,U,Dt,ge]);(0,a.useEffect)(()=>{if(!T)return;let e=He.current;if(!e)return;let t=()=>{e.clientHeight>0&&Nt(e.clientHeight)};if(t(),typeof ResizeObserver>"u")return;let n=new ResizeObserver(t);return n.observe(e),()=>n.disconnect()},[T]);let je=(0,a.useCallback)(e=>{w||vt(e),m?.(e)},[w,m]),mr=(0,a.useCallback)(e=>{let t=F.find(s=>s.key===e),n;if(!t||!t.direction?n="asc":t.direction==="asc"?n="desc":n=null,S){let s;n?t?s=F.map(i=>i.key===e?{key:e,direction:n}:i):s=[...F,{key:e,direction:n}]:s=F.filter(i=>i.key!==e),je(s)}else je(n?[{key:e,direction:n}]:[])},[F,S,je]),C=(0,a.useCallback)(e=>{let t=Math.max(1,Math.min(e,Q));Z||Qt(t),$?.(t)},[Z,$,Q]),yr=(0,a.useCallback)(e=>{xt(e),C(1),K?.(e)},[C,K]),br=(0,a.useCallback)(e=>{let t;g==="single"?t=k.includes(e)?[]:[e]:t=k.includes(e)?k.filter(n=>n!==e):[...k,e],R||ke(t),W?.(t)},[g,k,R,W]),qe=(0,a.useMemo)(()=>new Set(k),[k]),$e=(0,a.useCallback)(()=>{let e=new Set(k),t=[...k];for(let n of V){let s=Ye(n.row,n.sourceIndex,c);e.has(s)||(e.add(s),t.push(s))}R||ke(t),W?.(t)},[V,c,k,R,W]),Gt=(0,a.useCallback)(()=>{R||ke([]),W?.([])},[R,W]),fr=(0,a.useCallback)(()=>{let e=new Set(V.map(n=>Ye(n.row,n.sourceIndex,c))),t=k.filter(n=>!e.has(n));R||ke(t),W?.(t)},[V,c,k,R,W]),Xe=A?V.map(Tt):[],_e=Xe.length>0&&Xe.every(e=>qe.has(e)),hr=!_e&&Xe.some(e=>qe.has(e)),vr=(0,a.useCallback)(e=>{let t=be.includes(e)?be.filter(n=>n!==e):[...be,e];Ee||or(t),nt?.(t)},[be,Ee,nt]),xr=(0,a.useCallback)(e=>{let t=e.target.value;ye||wt(t),xe?.(t),C(1)},[ye,xe,C]),wr=(0,a.useCallback)(e=>{let t=[...j.filter(n=>n.column!==e.column),e];X||Fe(t),te?.(t),C(1)},[j,X,te,C]),kr=(0,a.useCallback)(e=>{let t=j.filter(n=>n.column!==e);X||Fe(t),te?.(t),C(1)},[j,X,te,C]),Cr=(0,a.useCallback)(e=>{let t=J.includes(e)?J.filter(n=>n!==e):[...J,e];De||ir(t),lt?.(t)},[J,De,lt]),Sr=(0,a.useCallback)((e,t)=>{e.preventDefault(),e.stopPropagation(),Ve.current=!0;let n=e.clientX,s=ze[t]??e.currentTarget.parentElement?.getBoundingClientRect().width??100,i=d.find(x=>x.key===t),h=i?.minWidth??50,M=i?.maxWidth??1/0,Y=x=>{let q=x.clientX-n,z=Math.min(M,Math.max(h,s+q));lr(me=>({...me,[t]:z}))},p=()=>{document.removeEventListener("mousemove",Y),document.removeEventListener("mouseup",p),setTimeout(()=>{Ve.current=!1},0)};document.addEventListener("mousemove",Y),document.addEventListener("mouseup",p)},[ze,d]),G=ne&&!(f==="client"&&F.some(e=>e.direction)),Nr=(0,a.useCallback)((e,t)=>{G&&Oe({key:e,sourceIndex:t})},[G]),Rr=(0,a.useCallback)(e=>{!G||_===null||e.preventDefault()},[G,_]),Tr=(0,a.useCallback)((e,t)=>{!G||_===null||(Oe(null),_.key!==e&&ot?.(_.sourceIndex,t))},[G,_,ot]),Er=(0,a.useCallback)(e=>{B&&kt(e)},[B]),Dr=(0,a.useCallback)(e=>{if(!B||!se||se===e)return;let t=[...Ce],n=t.indexOf(se),s=t.indexOf(e);n===-1||s===-1||(t.splice(n,1),t.splice(s,0,se),dr(t),st?.(se,e),kt(null))},[B,se,Ce,st]),Je=(0,a.useCallback)(e=>{let t=H.filter(x=>x.type!=="actions"&&x.type!=="selection"&&x.type!=="expand"),n=he,s,i,h;if(e==="csv")s=(0,zt.csvDocument)([t.map(x=>String(x.header)),...n.map(x=>t.map(q=>{let z=O(x,q.key);return typeof z=="number"?z:String(z??"")}))],{neutralizeFormulas:gt}),i="text/csv",h="csv";else{let x=n.map(q=>{let z={};for(let me of t)z[me.key]=O(q,me.key);return z});s=JSON.stringify(x,null,2),i="application/json",h="json"}let M=new Blob([s],{type:i}),Y=URL.createObjectURL(M),p=document.createElement("a");p.href=Y,p.download=`${ut}.${h}`,p.click(),URL.revokeObjectURL(Y)},[H,he,ut,gt]);(0,a.useEffect)(()=>{if(!Se)return;let e=t=>{Le.current&&!Le.current.contains(t.target)&&Ct(!1)};return document.addEventListener("mousedown",e),()=>document.removeEventListener("mousedown",e)},[Se]),(0,a.useImperativeHandle)(l,()=>({getVisibleData:()=>Ue,resetFilters:()=>{X||Fe([]),ye||wt(""),te?.([]),xe?.(""),C(1)},resetSort:()=>{w||vt([]),m?.([])},selectAll:$e,deselectAll:Gt,exportData:Je,scrollToRow:e=>{let t=He.current;if(!t||!T)return;let n=-1;for(let s=0;s<ue.length;s++){let i=ue[s];if(i.kind==="group")n=s;else if(i.index>=e){i.index===e&&(n=s);break}}n>=0&&(t.scrollTop=n*U)}}),[Ue,X,ye,w,te,xe,m,C,$e,Gt,Je,T,U,ue]);let Qe=e=>{let t={},n=ze[e.key]??e.width;return n&&(t.width=typeof n=="number"?`${n}px`:n,t.minWidth=typeof n=="number"?`${n}px`:n),e.sticky&&(t.position="sticky",t[e.sticky]=0,t.zIndex=10),t},pe=H.length+(A?1:0)+(re?1:0)+(ne?1:0),Gr=e=>{let t=D&&e.sortable!==!1&&e.type!=="actions",n=F.find(i=>i.key===e.key),s=e.filterable&&(e.filterType||e.filterOptions);return(0,r.jsxs)("th",{className:(0,y.cn)(I[v],Te[v],"relative font-semibold text-gray-700 dark:text-gray-300 whitespace-nowrap",e.align==="center"&&"text-center",e.align==="right"&&"text-right",t&&"cursor-pointer select-none hover:bg-gray-100 dark:hover:bg-gray-700",Ge&&"border border-gray-200 dark:border-gray-700",e.sticky&&"bg-gray-50 dark:bg-gray-800",e.headerClassName,Xt),style:Qe(e),onClick:t?()=>{Ve.current||mr(e.key)}:void 0,draggable:B,onDragStart:B?()=>Er(e.key):void 0,onDragOver:B?i=>i.preventDefault():void 0,onDrop:B?()=>Dr(e.key):void 0,"aria-sort":n?.direction==="asc"?"ascending":n?.direction==="desc"?"descending":void 0,children:[(0,r.jsxs)("div",{className:"flex items-center gap-1",children:[e.renderHeader?e.renderHeader(e):e.header,t&&(0,r.jsx)("span",{className:"inline-flex ml-1",children:n?.direction==="asc"?(0,r.jsx)(jr,{}):n?.direction==="desc"?(0,r.jsx)(qr,{}):(0,r.jsx)($r,{})}),s&&(0,r.jsx)(sn,{column:e,value:j.find(i=>i.column===e.key),onApply:wr,onClear:()=>kr(e.key),labels:b})]}),e.resizable!==!1&&(0,r.jsx)("div",{className:"absolute top-0 right-0 w-1 h-full cursor-col-resize hover:bg-synertech-primary-500 opacity-0 hover:opacity-100",onMouseDown:i=>Sr(i,e.key)})]},e.key)},ve=T?Ur[v]:I[v],Mt=T?{height:U}:void 0,Mr=(e,t)=>{let{row:n,sourceIndex:s}=e,i=Tt(e),h=qe.has(i),M=be.includes(i),Y=typeof Ie=="function"?Ie(n,t):Ie;return(0,r.jsxs)(a.default.Fragment,{children:[(0,r.jsxs)("tr",{className:(0,y.cn)("border-b border-gray-200 dark:border-gray-700 transition-colors",T&&"whitespace-nowrap",mt&&t%2===1&&"bg-gray-50/50 dark:bg-gray-800/50",h&&"bg-synertech-primary-50 dark:bg-synertech-primary-900/20",Me&&"cursor-pointer hover:bg-gray-50 dark:hover:bg-gray-700/50",_?.key===i&&"opacity-50",Y),onClick:Me?()=>Me(n,t):void 0,onDoubleClick:bt?()=>bt(n,t):void 0,onContextMenu:ft?p=>ft(n,t,p):void 0,draggable:G,onDragStart:G?()=>Nr(i,s):void 0,onDragOver:G?Rr:void 0,onDrop:G?()=>Tr(i,s):void 0,onDragEnd:G?()=>Oe(null):void 0,"data-row-key":i,"aria-selected":A?h:void 0,style:Mt,children:[ne&&(0,r.jsx)("td",{className:(0,y.cn)(ve,G?"cursor-grab active:cursor-grabbing":"cursor-not-allowed opacity-40"),children:(0,r.jsx)(_r,{})}),A&&(0,r.jsx)("td",{className:(0,y.cn)(ve,"w-10"),children:(0,r.jsx)("input",{type:"checkbox",checked:h,onChange:()=>br(i),onClick:p=>p.stopPropagation(),className:"rounded border-gray-300 dark:border-gray-600 cursor-pointer","aria-label":(0,E.formatUILabel)(b.dataGridSelectRow,{row:i})})}),re&&(0,r.jsx)("td",{className:(0,y.cn)(ve,"w-10"),children:(0,r.jsx)("button",{type:"button",onClick:p=>{p.stopPropagation(),vr(i)},className:"p-0.5 rounded hover:bg-gray-200 dark:hover:bg-gray-600 cursor-pointer","aria-label":M?b.dataGridCollapseRow:b.dataGridExpandRow,"aria-expanded":M,children:(0,r.jsx)(Pt,{className:(0,y.cn)("transition-transform",M&&"rotate-180")})})}),H.map(p=>{let x=O(n,p.key),q=p.colSpan?.(n,t);if(q===0)return null;let z=at&&p.editable!==!1&&p.type!=="actions";return(0,r.jsx)("td",{className:(0,y.cn)(ve,Te[v],"text-gray-700 dark:text-gray-300",p.align==="center"&&"text-center",p.align==="right"&&"text-right",Ge&&"border border-gray-200 dark:border-gray-700",p.sticky&&(h?"bg-synertech-primary-50 dark:bg-synertech-primary-900/20":mt&&t%2===1?"bg-gray-50/50 dark:bg-gray-800/50":"bg-white dark:bg-gray-900"),p.cellClassName,$t),style:Qe(p),colSpan:q,children:z?(0,r.jsx)(ln,{value:x,onSave:me=>At?.(i,p.key,me),density:v,labels:b}):p.render?p.render(x,n,t):String(x??"")},p.key)})]}),re&&M&&rt&&(0,r.jsx)("tr",{className:"bg-gray-50 dark:bg-gray-800/70",children:(0,r.jsx)("td",{colSpan:pe,className:(0,y.cn)(I[v]),children:rt(n,t)})})]},i)},Ir=e=>{let{key:t,rows:n}=e,s=Ae.has(t);return(0,r.jsx)("tr",{className:(0,y.cn)("bg-gray-100 dark:bg-gray-800 font-medium",T&&"whitespace-nowrap"),style:Mt,children:(0,r.jsx)("td",{colSpan:pe,className:(0,y.cn)(ve,"cursor-pointer"),onClick:()=>{cr(i=>{let h=new Set(i);return h.has(t)?h.delete(t):h.add(t),h})},children:(0,r.jsxs)("div",{className:"flex items-center gap-2",children:[(0,r.jsx)(Pt,{className:(0,y.cn)("transition-transform",s&&"-rotate-90")}),dt?dt(t,O(n[0].row,de[0]),n.map(i=>i.row)):`${t} (${n.length})`]})})},`group-${t}`)},Pr=()=>{if(Vt)return Array.from({length:Kt}).map((s,i)=>(0,r.jsx)(on,{cols:pe,density:v},i));if(Ue.length===0)return(0,r.jsx)("tr",{children:(0,r.jsx)("td",{colSpan:pe,className:(0,y.cn)("text-center text-gray-500 dark:text-gray-400",I[v]),children:Wt??b.dataGridNoData})});let e=s=>s.kind==="row"?Mr(s.entry,s.index):Ir(s);if(!T)return ue.map(e);let{start:t,end:n}=pr;return(0,r.jsxs)(r.Fragment,{children:[t>0&&(0,r.jsx)("tr",{"aria-hidden":"true",children:(0,r.jsx)("td",{colSpan:pe,style:{height:t*U,padding:0}})}),ue.slice(t,n).map(e),n<ge&&(0,r.jsx)("tr",{"aria-hidden":"true",children:(0,r.jsx)("td",{colSpan:pe,style:{height:(ge-n)*U,padding:0}})})]})},Fr=(e,t)=>{let n=nn(he,e.key,t);return e.renderAggregate?e.renderAggregate(n??0,he):n===null?"":an(t,n.toLocaleString(Pe),b)},zr=()=>!jt||!H.some(t=>t.aggregate)?null:(0,r.jsx)("tfoot",{children:(0,r.jsxs)("tr",{className:"bg-gray-50 dark:bg-gray-800 font-semibold border-t-2 border-gray-300 dark:border-gray-600",children:[ne&&(0,r.jsx)("td",{className:I[v]}),A&&(0,r.jsx)("td",{className:I[v]}),re&&(0,r.jsx)("td",{className:I[v]}),H.map(t=>(0,r.jsx)("td",{className:(0,y.cn)(I[v],Te[v],"text-gray-700 dark:text-gray-300",t.align==="center"&&"text-center",t.align==="right"&&"text-right",Ge&&"border border-gray-200 dark:border-gray-700"),style:Qe(t),children:t.aggregate?Fr(t,t.aggregate):""},t.key))]})});return(0,r.jsxs)("div",{className:(0,y.cn)("flex flex-col gap-3",qt),children:[(tt||ct||it)&&(0,r.jsxs)("div",{className:"flex items-center justify-between gap-3 flex-wrap",children:[(0,r.jsxs)("div",{className:"flex items-center gap-3 flex-1",children:[tt&&(0,r.jsxs)("div",{className:"relative flex-1 max-w-xs",children:[(0,r.jsx)("div",{className:"absolute inset-y-0 left-0 flex items-center pl-3 pointer-events-none",children:(0,r.jsx)(Xr,{})}),(0,r.jsx)("input",{type:"text",value:Ne,onChange:xr,placeholder:Ot??b.dataGridSearchPlaceholder,className:"w-full pl-9 pr-3 py-1.5 text-sm border border-gray-300 dark:border-gray-600 rounded-md bg-white dark:bg-gray-800 text-gray-700 dark:text-gray-200 focus:outline-none focus:ring-2 focus:ring-synertech-primary-500 focus:border-synertech-primary-500","aria-label":b.dataGridSearch})]}),k.length>0&&(0,r.jsx)("span",{className:"text-sm text-gray-500 dark:text-gray-400",children:(0,E.formatUILabel)(b.dataGridSelectedCount,{count:k.length})})]}),(0,r.jsxs)("div",{className:"flex items-center gap-2",children:[it&&(0,r.jsxs)("div",{className:"relative",ref:Le,children:[(0,r.jsx)("button",{type:"button",onClick:()=>Ct(!Se),className:"p-1.5 rounded-md border border-gray-300 dark:border-gray-600 text-gray-600 dark:text-gray-400 hover:bg-gray-100 dark:hover:bg-gray-700 cursor-pointer","aria-label":b.dataGridToggleColumns,title:b.dataGridToggleColumns,children:(0,r.jsx)(Yr,{})}),Se&&(0,r.jsx)("div",{className:"absolute z-50 right-0 top-full mt-1 bg-white dark:bg-gray-800 border border-gray-200 dark:border-gray-700 rounded-lg shadow-lg p-2 min-w-[180px]",children:d.filter(e=>e.type!=="selection"&&e.type!=="expand").map(e=>(0,r.jsxs)("label",{className:"flex items-center gap-2 px-2 py-1.5 text-sm rounded hover:bg-gray-100 dark:hover:bg-gray-700 cursor-pointer",children:[(0,r.jsx)("input",{type:"checkbox",checked:!J.includes(e.key),onChange:()=>Cr(e.key),className:"rounded border-gray-300 dark:border-gray-600 cursor-pointer"}),(0,r.jsx)("span",{className:"text-gray-700 dark:text-gray-300",children:String(e.header)})]},e.key))})]}),ct&&Ht.map(e=>(0,r.jsxs)("button",{type:"button",onClick:()=>Je(e),className:"inline-flex items-center gap-1.5 px-2.5 py-1.5 text-xs font-medium rounded-md border border-gray-300 dark:border-gray-600 text-gray-600 dark:text-gray-400 hover:bg-gray-100 dark:hover:bg-gray-700 cursor-pointer",title:(0,E.formatUILabel)(b.dataGridExportAs,{format:e.toUpperCase()}),children:[(0,r.jsx)(Qr,{}),e.toUpperCase()]},e))]})]}),(0,r.jsx)("div",{ref:He,className:(0,y.cn)("overflow-auto rounded-lg",!Lt&&"border border-gray-200 dark:border-gray-700",yt&&"relative"),style:ae?{maxHeight:typeof ae=="number"?`${ae}px`:ae}:T?{maxHeight:pt,overflow:"auto"}:void 0,onScroll:T?e=>{let t=e.currentTarget;ur(Math.floor(t.scrollTop/U)),t.clientHeight>0&&Nt(t.clientHeight)}:void 0,children:(0,r.jsxs)("table",{className:"w-full text-left",children:[(0,r.jsx)("thead",{className:(0,y.cn)("bg-gray-50 dark:bg-gray-800 text-xs uppercase",yt&&"sticky top-0 z-20"),children:(0,r.jsxs)("tr",{children:[ne&&(0,r.jsx)("th",{className:(0,y.cn)(I[v],"w-10 font-semibold text-gray-700 dark:text-gray-300")}),A&&(0,r.jsx)("th",{className:(0,y.cn)(I[v],"w-10"),children:g==="multiple"&&(0,r.jsx)("input",{type:"checkbox",checked:_e,ref:e=>{e&&(e.indeterminate=hr)},onChange:_e?fr:$e,className:"rounded border-gray-300 dark:border-gray-600 cursor-pointer","aria-label":b.dataGridSelectAllRows})}),re&&(0,r.jsx)("th",{className:(0,y.cn)(I[v],"w-10 font-semibold text-gray-700 dark:text-gray-300")}),H.map(Gr)]})}),(0,r.jsx)("tbody",{children:Pr()}),zr()]})}),ie&&(0,r.jsxs)("div",{className:"flex items-center justify-between flex-wrap gap-3 text-sm text-gray-600 dark:text-gray-400",children:[(0,r.jsxs)("div",{className:"flex items-center gap-3",children:[ie.showTotalItems!==!1&&(0,r.jsx)("span",{children:(0,E.formatUILabel)(Be===1?b.dataGridItemCount:b.dataGridItemsCount,{count:Be})}),ie.showPageSizeSelector!==!1&&ie.pageSizeOptions&&(0,r.jsxs)("div",{className:"flex items-center gap-1.5",children:[(0,r.jsx)("span",{children:b.dataGridRowsPerPage}),(0,r.jsx)("select",{value:fe,onChange:e=>yr(Number(e.target.value)),className:"border border-gray-300 dark:border-gray-600 rounded px-1.5 py-0.5 bg-white dark:bg-gray-800 text-gray-700 dark:text-gray-200 text-sm",children:ie.pageSizeOptions.map(e=>(0,r.jsx)("option",{value:e,children:e},e))})]})]}),(0,r.jsxs)("div",{className:"flex items-center gap-1",children:[(0,r.jsx)("span",{className:"mr-2",children:(0,E.formatUILabel)(b.dataGridPageOf,{page:L,total:Q})}),(0,r.jsx)("button",{type:"button",onClick:()=>C(1),disabled:L<=1,className:"px-2 py-1 rounded border border-gray-300 dark:border-gray-600 disabled:opacity-50 disabled:cursor-not-allowed hover:bg-gray-100 dark:hover:bg-gray-700 cursor-pointer","aria-label":b.dataGridFirstPage,children:"\xAB\xAB"}),(0,r.jsx)("button",{type:"button",onClick:()=>C(L-1),disabled:L<=1,className:"px-2 py-1 rounded border border-gray-300 dark:border-gray-600 disabled:opacity-50 disabled:cursor-not-allowed hover:bg-gray-100 dark:hover:bg-gray-700 cursor-pointer","aria-label":b.dataGridPreviousPage,children:"\xAB"}),(0,r.jsx)("button",{type:"button",onClick:()=>C(L+1),disabled:L>=Q,className:"px-2 py-1 rounded border border-gray-300 dark:border-gray-600 disabled:opacity-50 disabled:cursor-not-allowed hover:bg-gray-100 dark:hover:bg-gray-700 cursor-pointer","aria-label":b.dataGridNextPage,children:"\xBB"}),(0,r.jsx)("button",{type:"button",onClick:()=>C(Q),disabled:L>=Q,className:"px-2 py-1 rounded border border-gray-300 dark:border-gray-600 disabled:opacity-50 disabled:cursor-not-allowed hover:bg-gray-100 dark:hover:bg-gray-700 cursor-pointer","aria-label":b.dataGridLastPage,children:"\xBB\xBB"})]})]})]})}var cn=(0,a.forwardRef)(dn);0&&(module.exports={DataGrid,resetRowKeyWarning});
1
+ "use strict";"use client";var Wr=Object.create;var De=Object.defineProperty;var Br=Object.getOwnPropertyDescriptor;var Kr=Object.getOwnPropertyNames;var Ur=Object.getPrototypeOf,jr=Object.prototype.hasOwnProperty;var qr=(o,l)=>{for(var c in l)De(o,c,{get:l[c],enumerable:!0})},Ot=(o,l,c,y)=>{if(l&&typeof l=="object"||typeof l=="function")for(let d of Kr(l))!jr.call(o,d)&&d!==c&&De(o,d,{get:()=>l[d],enumerable:!(y=Br(l,d))||y.enumerable});return o};var $r=(o,l,c)=>(c=o!=null?Wr(Ur(o)):{},Ot(l||!o||!o.__esModule?De(c,"default",{value:o,enumerable:!0}):c,o)),Xr=o=>Ot(De({},"__esModule",{value:!0}),o);var vn={};qr(vn,{DataGrid:()=>hn,resetRowKeyWarning:()=>an});module.exports=Xr(vn);var a=$r(require("react"),1),h=require("../../lib/cn.cjs"),Ht=require("../../lib/csv.cjs"),Lt=require("../chart/utils/timestamp.cjs"),D=require("../../lib/i18n.cjs"),r=require("react/jsx-runtime"),O={compact:"px-3 py-1.5",default:"px-4 py-3",comfortable:"px-6 py-4"},_r={compact:"px-3 py-0",default:"px-4 py-0",comfortable:"px-6 py-0"},Ge={compact:"text-xs",default:"text-sm",comfortable:"text-base"},Jr=()=>(0,r.jsx)("svg",{className:"w-3.5 h-3.5",viewBox:"0 0 16 16",fill:"currentColor",children:(0,r.jsx)("path",{d:"M8 3l4 5H4l4-5z"})}),Yr=()=>(0,r.jsx)("svg",{className:"w-3.5 h-3.5",viewBox:"0 0 16 16",fill:"currentColor",children:(0,r.jsx)("path",{d:"M8 13l4-5H4l4 5z"})}),Qr=()=>(0,r.jsx)("svg",{className:"w-3.5 h-3.5 opacity-30",viewBox:"0 0 16 16",fill:"currentColor",children:(0,r.jsx)("path",{d:"M8 3l3 4H5l3-4zM8 13l3-4H5l3 4z"})}),Pt=({className:o})=>(0,r.jsx)("svg",{className:(0,h.cn)("w-4 h-4",o),viewBox:"0 0 20 20",fill:"currentColor",children:(0,r.jsx)("path",{fillRule:"evenodd",d:"M5.23 7.21a.75.75 0 011.06.02L10 11.168l3.71-3.938a.75.75 0 111.08 1.04l-4.25 4.5a.75.75 0 01-1.08 0l-4.25-4.5a.75.75 0 01.02-1.06z",clipRule:"evenodd"})}),Zr=()=>(0,r.jsx)("svg",{className:"w-4 h-4 text-gray-500 dark:text-gray-400",viewBox:"0 0 20 20",fill:"currentColor",children:(0,r.jsx)("path",{fillRule:"evenodd",d:"M9 3.5a5.5 5.5 0 100 11 5.5 5.5 0 000-11zM2 9a7 7 0 1112.452 4.391l3.328 3.329a.75.75 0 11-1.06 1.06l-3.329-3.328A7 7 0 012 9z",clipRule:"evenodd"})}),en=()=>(0,r.jsx)("svg",{className:"w-4 h-4 text-gray-500 dark:text-gray-400",viewBox:"0 0 20 20",fill:"currentColor",children:(0,r.jsx)("path",{d:"M7 4a1.5 1.5 0 110-3 1.5 1.5 0 010 3zm6 0a1.5 1.5 0 110-3 1.5 1.5 0 010 3zM7 10.5a1.5 1.5 0 110-3 1.5 1.5 0 010 3zm6 0a1.5 1.5 0 110-3 1.5 1.5 0 010 3zM7 17a1.5 1.5 0 110-3 1.5 1.5 0 010 3zm6 0a1.5 1.5 0 110-3 1.5 1.5 0 010 3z"})}),tn=()=>(0,r.jsx)("svg",{className:"w-3.5 h-3.5",viewBox:"0 0 20 20",fill:"currentColor",children:(0,r.jsx)("path",{fillRule:"evenodd",d:"M2.628 1.601C5.028 1.206 7.49 1 10 1s4.973.206 7.372.601a.75.75 0 01.628.74v2.288a2.25 2.25 0 01-.659 1.59l-4.682 4.683a2.25 2.25 0 00-.659 1.59v3.037c0 .684-.31 1.33-.844 1.757l-1.937 1.55A.75.75 0 018 18.25v-5.757a2.25 2.25 0 00-.659-1.591L2.659 6.22A2.25 2.25 0 012 4.629V2.34a.75.75 0 01.628-.74z",clipRule:"evenodd"})}),rn=()=>(0,r.jsxs)("svg",{className:"w-4 h-4",viewBox:"0 0 20 20",fill:"currentColor",children:[(0,r.jsx)("path",{d:"M10.75 2.75a.75.75 0 00-1.5 0v8.614L6.295 8.235a.75.75 0 10-1.09 1.03l4.25 4.5a.75.75 0 001.09 0l4.25-4.5a.75.75 0 00-1.09-1.03l-2.955 3.129V2.75z"}),(0,r.jsx)("path",{d:"M3.5 12.75a.75.75 0 00-1.5 0v2.5A2.75 2.75 0 004.75 18h10.5A2.75 2.75 0 0018 15.25v-2.5a.75.75 0 00-1.5 0v2.5c0 .69-.56 1.25-1.25 1.25H4.75c-.69 0-1.25-.56-1.25-1.25v-2.5z"})]}),nn=()=>(0,r.jsx)("svg",{className:"w-4 h-4",viewBox:"0 0 20 20",fill:"currentColor",children:(0,r.jsx)("path",{fillRule:"evenodd",d:"M2.5 3A1.5 1.5 0 001 4.5v11A1.5 1.5 0 002.5 17h15a1.5 1.5 0 001.5-1.5v-11A1.5 1.5 0 0017.5 3h-15zM2.5 4.5h6v11h-6v-11zm7.5 0h7.5v11H10v-11z",clipRule:"evenodd"})});function tt(o,l,c){return typeof c=="function"?c(o,l):String(typeof c=="string"?o[c]:l)}var rt=!1;function an(){rt=!1}function on(){rt||(rt=!0,console.warn("[@synertech/ui] DataGrid has no `rowKey`: each row is known by its position in `data`. Selection, expansion and edits follow that position when `data` is refetched or reordered, and from one page to the next in server mode. Pass `rowKey` to tie them to the row."))}var zt=!1;function sn(){zt||(zt=!0,console.warn("[@synertech/ui] DataGrid has a sticky column after another one with no `width` on the same side: it cannot know where the first one ends, and the two overlap. Give every sticky column but the last a `width`."))}function L(o,l){return o[l]}function At(o,l){return l.map(c=>String(L(o,c)??"")).join(" / ")}function ye(o){return o==null||typeof o=="string"&&o.trim()===""||typeof o=="number"&&Number.isNaN(o)||o instanceof Date&&Number.isNaN(o.getTime())}function ln(o,l,c){let y=ye(o),d=ye(l);return y||d?y===d?0:y?-1:1:o instanceof Date&&l instanceof Date?o.getTime()-l.getTime():typeof o=="number"&&typeof l=="number"?o-l:c.compare(String(o),String(l))}function dn(o){let l=(0,Lt.toTimestamp)(o);if(l===null)return null;let c=new Date(l);return new Date(c.getFullYear(),c.getMonth(),c.getDate()).getTime()}function cn(o){if(ye(o))return null;let l=typeof o=="number"?o:Number(o);return Number.isFinite(l)?l:null}function un(o,l,c="text"){if(l.operator==="isEmpty")return ye(o);if(l.operator==="isNotEmpty")return!ye(o);let y=["gt","gte","lt","lte","between"].includes(l.operator);if(c==="number"||c==="date"||y){let k=c==="date"?dn:cn,f=k(o),g=l.value.trim()===""?null:k(l.value),N=l.valueTo===void 0||l.valueTo.trim()===""?null:k(l.valueTo);if(f===null)return!1;switch(l.operator){case"equals":return g===null||f===g;case"gt":return g===null||f>g;case"gte":return g===null||f>=g;case"lt":return g===null||f<g;case"lte":return g===null||f<=g;case"between":return(g===null||f>=g)&&(N===null||f<=N);default:return!0}}let d=String(o??"").toLowerCase(),m=l.value.toLowerCase();switch(l.operator){case"contains":return d.includes(m);case"equals":return d===m;case"startsWith":return d.startsWith(m);case"endsWith":return d.endsWith(m);default:return!0}}function gn(o,l,c){let y=0,d=0,m=0,k=1/0,f=-1/0;for(let g of o){let N=L(g,l);if(ye(N))continue;y++;let b=Number(N);Number.isNaN(b)||(d++,m+=b,b<k&&(k=b),b>f&&(f=b))}switch(c){case"count":return y;case"sum":return m;case"avg":return d===0?null:m/d;case"min":return d===0?null:k;case"max":return d===0?null:f}}function pn(o,l,c){if(o==="count")return l;let y=o==="avg"?c.dataGridAggregateAvg:o==="sum"?c.dataGridAggregateSum:o==="min"?c.dataGridAggregateMin:c.dataGridAggregateMax;return(0,D.formatUILabel)(y,{value:l})}function mn({cols:o,density:l}){return(0,r.jsx)("tr",{className:"border-b border-gray-200 dark:border-gray-700",children:Array.from({length:o}).map((c,y)=>(0,r.jsx)("td",{className:O[l],children:(0,r.jsx)("div",{className:"h-4 bg-gray-200 dark:bg-gray-700 rounded animate-pulse"})},y))})}function yn({column:o,value:l,onApply:c,onClear:y,labels:d}){let m=o.filterType??"text",k=String(o.header),f=m==="number"?[{value:"equals",label:d.dataGridOperatorEquals},{value:"gt",label:d.dataGridOperatorGreaterThan},{value:"gte",label:d.dataGridOperatorGreaterOrEqual},{value:"lt",label:d.dataGridOperatorLessThan},{value:"lte",label:d.dataGridOperatorLessOrEqual},{value:"between",label:d.dataGridOperatorBetween}]:m==="date"?[{value:"equals",label:d.dataGridOperatorOn},{value:"lt",label:d.dataGridOperatorBefore},{value:"gt",label:d.dataGridOperatorAfter},{value:"between",label:d.dataGridOperatorBetween},{value:"isEmpty",label:d.dataGridOperatorIsEmpty},{value:"isNotEmpty",label:d.dataGridOperatorIsNotEmpty}]:[{value:"contains",label:d.dataGridOperatorContains},{value:"equals",label:d.dataGridOperatorEquals},{value:"startsWith",label:d.dataGridOperatorStartsWith},{value:"endsWith",label:d.dataGridOperatorEndsWith},{value:"isEmpty",label:d.dataGridOperatorIsEmpty},{value:"isNotEmpty",label:d.dataGridOperatorIsNotEmpty}],g=u=>u&&f.some(ee=>ee.value===u.operator)?u.operator:f[0].value,[N,b]=(0,a.useState)(!1),[S,M]=(0,a.useState)(()=>g(l)),[$,B]=(0,a.useState)(l?.value??""),[fe,z]=(0,a.useState)(l?.valueTo??""),X=(0,a.useRef)(null),P=()=>{N||(M(g(l)),B(l?.value??""),z(l?.valueTo??"")),b(!N)};return(0,a.useEffect)(()=>{let u=ee=>{X.current&&!X.current.contains(ee.target)&&b(!1)};return N&&document.addEventListener("mousedown",u),()=>document.removeEventListener("mousedown",u)},[N]),(0,r.jsxs)("div",{className:"relative inline-block",ref:X,onClick:u=>u.stopPropagation(),children:[(0,r.jsx)("button",{type:"button",onClick:P,className:(0,h.cn)("p-0.5 rounded hover:bg-gray-200 dark:hover:bg-gray-600 cursor-pointer",l&&"text-synertech-primary-600 dark:text-synertech-primary-400"),"aria-label":(0,D.formatUILabel)(d.dataGridFilterColumn,{column:k}),children:(0,r.jsx)(tn,{})}),N&&(0,r.jsx)("div",{className:"absolute z-50 top-full left-0 mt-1 bg-white dark:bg-gray-800 border border-gray-200 dark:border-gray-700 rounded-lg shadow-lg p-3 min-w-[220px]",children:m==="select"&&o.filterOptions?(0,r.jsxs)("div",{className:"flex flex-col gap-1.5",children:[o.filterOptions.map(u=>(0,r.jsxs)("label",{className:"flex items-center gap-2 text-sm cursor-pointer",children:[(0,r.jsx)("input",{type:"radio",name:`filter-${o.key}`,value:u,checked:$===u,onChange:()=>B(u),className:"cursor-pointer"}),(0,r.jsx)("span",{className:"text-gray-700 dark:text-gray-300",children:u})]},u)),(0,r.jsxs)("div",{className:"flex gap-2 mt-2",children:[(0,r.jsx)("button",{type:"button",onClick:()=>{c({column:o.key,operator:"equals",value:$}),b(!1)},className:"px-2 py-1 text-xs bg-synertech-primary-600 text-synertech-on-primary rounded hover:bg-synertech-primary-700 cursor-pointer",children:d.dataGridFilterApply}),(0,r.jsx)("button",{type:"button",onClick:()=>{B(""),y(),b(!1)},className:"px-2 py-1 text-xs text-gray-600 dark:text-gray-400 hover:text-gray-800 dark:hover:text-gray-200 cursor-pointer",children:d.dataGridFilterClear})]})]}):(0,r.jsxs)("div",{className:"flex flex-col gap-2",children:[(0,r.jsx)("select",{value:S,onChange:u=>M(u.target.value),className:"text-xs border border-gray-300 dark:border-gray-600 rounded px-2 py-1 bg-white dark:bg-gray-700 text-gray-700 dark:text-gray-200",children:f.map(u=>(0,r.jsx)("option",{value:u.value,children:u.label},u.value))}),S!=="isEmpty"&&S!=="isNotEmpty"&&(0,r.jsx)("input",{type:m==="number"?"number":m==="date"?"date":"text",value:$,onChange:u=>B(u.target.value),placeholder:d.dataGridFilterValuePlaceholder,className:"text-xs border border-gray-300 dark:border-gray-600 rounded px-2 py-1 bg-white dark:bg-gray-700 text-gray-700 dark:text-gray-200",autoFocus:!0,"aria-label":(0,D.formatUILabel)(d.dataGridFilterValue,{column:k})}),S==="between"&&(0,r.jsx)("input",{type:m==="date"?"date":"number",value:fe,onChange:u=>z(u.target.value),placeholder:d.dataGridFilterValuePlaceholder,className:"text-xs border border-gray-300 dark:border-gray-600 rounded px-2 py-1 bg-white dark:bg-gray-700 text-gray-700 dark:text-gray-200","aria-label":(0,D.formatUILabel)(d.dataGridFilterValueTo,{column:k})}),(0,r.jsxs)("div",{className:"flex gap-2",children:[(0,r.jsx)("button",{type:"button",onClick:()=>{c({column:o.key,operator:S,value:$,...S==="between"?{valueTo:fe}:{}}),b(!1)},className:"px-2 py-1 text-xs bg-synertech-primary-600 text-synertech-on-primary rounded hover:bg-synertech-primary-700 cursor-pointer",children:d.dataGridFilterApply}),(0,r.jsx)("button",{type:"button",onClick:()=>{B(""),y(),b(!1)},className:"px-2 py-1 text-xs text-gray-600 dark:text-gray-400 hover:text-gray-800 dark:hover:text-gray-200 cursor-pointer",children:d.dataGridFilterClear})]})]})})]})}function fn({value:o,display:l,onSave:c,density:y,labels:d}){let m=typeof o=="number",[k,f]=(0,a.useState)(!1),[g,N]=(0,a.useState)(String(o??"")),b=(0,a.useRef)(null);if((0,a.useEffect)(()=>{k&&b.current&&(b.current.focus(),b.current.select())},[k]),!k)return(0,r.jsx)("div",{onDoubleClick:()=>{N(String(o??"")),f(!0)},className:"cursor-text min-h-[1.5em]",title:d.dataGridEditHint,children:l});let S=()=>{if(f(!1),g!==String(o??"")){if(!m){c(g);return}g.trim()===""?c(null):Number.isFinite(Number(g))&&c(Number(g))}};return(0,r.jsx)("input",{ref:b,type:m?"number":"text",value:g,onChange:M=>N(M.target.value),onBlur:S,"aria-label":d.dataGridEditCell,onKeyDown:M=>{M.key==="Enter"&&S(),M.key==="Escape"&&(M.preventDefault(),f(!1))},className:(0,h.cn)("w-full border border-synertech-primary-500 rounded px-1 py-0.5 bg-white dark:bg-gray-700 text-gray-900 dark:text-gray-100 outline-none",Ge[y])})}function bn(o,l){let{columns:c,data:y,rowKey:d,mode:m="client",sortable:k=!1,multiSort:f=!1,sort:g,defaultSort:N,onSort:b,pagination:S=!1,page:M,onPageChange:$,onPageSizeChange:B,totalItems:fe,selectable:z=!1,selectionMode:X="multiple",selectedRows:P,onSelectionChange:u,searchable:ee=!1,searchPlaceholder:Vt,searchValue:be,onSearch:Ce,filters:_,onFilterChange:te,expandable:re=!1,expandedContent:nt,expandedRows:Me,onExpandChange:at,editable:ot=!1,onCellEdit:Wt,reorderable:ne=!1,onReorder:st,columnReorderable:K=!1,onColumnReorder:it,columnToggle:lt=!1,hiddenColumns:Fe,onColumnVisibilityChange:dt,groupBy:Ne,renderGroupHeader:ct,exportable:ut=!1,exportFormats:Bt=["csv","json"],exportFilename:gt="export",exportNeutralizeFormulas:pt,virtualized:G=!1,rowHeight:U=40,virtualHeight:mt=400,density:C="default",striped:yt=!1,bordered:Ie=!1,borderless:Kt=!1,stickyHeader:ft=!1,maxHeight:ae,loading:Ut=!1,loadingRows:jt=5,emptyState:qt,labels:$t,locale:Xt,showFooter:_t=!1,onRowClick:Oe,onRowDoubleClick:bt,onRowContextMenu:ht,className:Jt,rowClassName:Pe,cellClassName:Yt,headerClassName:Qt}=o,v=(0,D.useUILabels)($t),ze=(0,D.useUILocale)(Xt),vt=(0,a.useMemo)(()=>new Intl.Collator(ze,{numeric:!0}),[ze]),[Zt,xt]=(0,a.useState)(N??[]),[er,tr]=(0,a.useState)(1),oe=typeof S=="object"?S.pageSize:void 0,[rr,wt]=(0,a.useState)(oe??10),[nr,ar]=(0,a.useState)(oe);oe!==nr&&(ar(oe),oe!==void 0&&wt(oe));let[or,Se]=(0,a.useState)([]),[sr,kt]=(0,a.useState)(""),[ir,Ae]=(0,a.useState)([]),[lr,dr]=(0,a.useState)([]),[cr,ur]=(0,a.useState)(()=>c.flatMap(e=>e.hidden?[e.key]:[])),[he,gr]=(0,a.useState)({}),[Ct,pr]=(0,a.useState)(()=>c.map(e=>e.key)),[J,He]=(0,a.useState)(null),[se,Nt]=(0,a.useState)(null),[Te,St]=(0,a.useState)(!1),[Le,mr]=(0,a.useState)(new Set),Ve=(0,a.useRef)(null),[Tt,yr]=(0,a.useState)(0),[fr,Rt]=(0,a.useState)(null),We=(0,a.useRef)(null),Be=(0,a.useRef)(!1),A=g??Zt,Et=M??er,R=P??or,Re=be??sr,j=_??ir,ve=Me??lr,Y=Fe??cr,ie=S?typeof S=="object"?S:{pageSize:10,pageSizeOptions:[10,25,50,100]}:null,xe=rr;!d&&(z||re||ot||ne)&&on();let Dt=e=>tt(e.row,e.sourceIndex,d),Ee=(0,a.useMemo)(()=>{let e=new Map(c.map(s=>[s.key,s])),t=Ct.flatMap(s=>{let i=e.get(s);return i?[i]:[]}),n=new Set(t.map(s=>s.key));for(let s of c)n.has(s.key)||(t.push(s),n.add(s.key));return t},[c,Ct]),F=(0,a.useMemo)(()=>Ee.filter(e=>!Y.includes(e.key)),[Ee,Y]),le=(0,a.useMemo)(()=>{let e=y.map((t,n)=>({row:t,sourceIndex:n}));if(m==="server")return e;if(Re){let t=Re.toLowerCase();e=e.filter(({row:n})=>F.some(s=>{let i=L(n,s.key);return String(i??"").toLowerCase().includes(t)}))}if(j.length>0){let t=new Map(c.map(n=>[n.key,n.filterType]));e=e.filter(({row:n})=>j.every(s=>un(L(n,s.column),s,t.get(s.column))))}if(A.length>0){let t=new Map(c.map(n=>[n.key,n]));e.sort((n,s)=>{for(let i of A){if(!i.direction)continue;let x=t.get(i.key),T=x?.sortComparator?x.sortComparator(n.row,s.row):ln(L(n.row,i.key),L(s.row,i.key),vt);if(T!==0)return i.direction==="asc"?T:-T}return 0})}return e},[y,m,Re,j,A,F,c,vt]),we=(0,a.useMemo)(()=>le.map(e=>e.row),[le]),Ke=Ne?(Array.isArray(Ne)?Ne:[Ne]).join("\0"):"",de=(0,a.useMemo)(()=>Ke?Ke.split("\0"):[],[Ke]),ce=(0,a.useMemo)(()=>{if(de.length===0)return null;let e=new Map;for(let t of le){let n=At(t.row,de),s=e.get(n);s?s.push(t):e.set(n,[t])}return e},[le,de]),Ue=(0,a.useMemo)(()=>ce?Array.from(ce.values()).flat():le,[ce,le]),je=fe??we.length,Q=Math.max(1,Math.ceil(je/xe)),V=m==="server"&&fe===void 0?Et:Math.min(Math.max(1,Et),Q),Gt=ie!==null,W=(0,a.useMemo)(()=>{if(!Gt||m==="server")return Ue;let e=(V-1)*xe;return Ue.slice(e,e+xe)},[Ue,Gt,V,xe,m]),qe=(0,a.useMemo)(()=>W.map(e=>e.row),[W]),ue=(0,a.useMemo)(()=>{let e=[],t=null;return W.forEach((n,s)=>{if(ce){let i=At(n.row,de);if(i!==t&&(t=i,e.push({kind:"group",key:i,rows:ce.get(i)??[n]})),Le.has(i))return}e.push({kind:"row",entry:n,index:s})}),e},[W,ce,de,Le]),Mt=fr??(typeof ae=="number"?ae:mt),ge=ue.length,br=(0,a.useMemo)(()=>{if(!G)return{start:0,end:ge};let e=Math.max(1,Math.ceil(Mt/U)),t=Math.min(Tt,Math.max(0,ge-e)),n=5;return{start:Math.max(0,t-n),end:Math.min(ge,t+e+n)}},[G,Tt,U,Mt,ge]);(0,a.useEffect)(()=>{if(!G)return;let e=Ve.current;if(!e)return;let t=()=>{e.clientHeight>0&&Rt(e.clientHeight)};if(t(),typeof ResizeObserver>"u")return;let n=new ResizeObserver(t);return n.observe(e),()=>n.disconnect()},[G]);let $e=(0,a.useCallback)(e=>{g||xt(e),b?.(e)},[g,b]),hr=(0,a.useCallback)(e=>{let t=A.find(s=>s.key===e),n;if(!t||!t.direction?n="asc":t.direction==="asc"?n="desc":n=null,f){let s;n?t?s=A.map(i=>i.key===e?{key:e,direction:n}:i):s=[...A,{key:e,direction:n}]:s=A.filter(i=>i.key!==e),$e(s)}else $e(n?[{key:e,direction:n}]:[])},[A,f,$e]),E=(0,a.useCallback)(e=>{let t=Math.max(1,Math.min(e,Q));M||tr(t),$?.(t)},[M,$,Q]),vr=(0,a.useCallback)(e=>{wt(e),E(1),B?.(e)},[E,B]),xr=(0,a.useCallback)(e=>{let t;X==="single"?t=R.includes(e)?[]:[e]:t=R.includes(e)?R.filter(n=>n!==e):[...R,e],P||Se(t),u?.(t)},[X,R,P,u]),Xe=(0,a.useMemo)(()=>new Set(R),[R]),_e=(0,a.useCallback)(()=>{let e=new Set(R),t=[...R];for(let n of W){let s=tt(n.row,n.sourceIndex,d);e.has(s)||(e.add(s),t.push(s))}P||Se(t),u?.(t)},[W,d,R,P,u]),Ft=(0,a.useCallback)(()=>{P||Se([]),u?.([])},[P,u]),wr=(0,a.useCallback)(()=>{let e=new Set(W.map(n=>tt(n.row,n.sourceIndex,d))),t=R.filter(n=>!e.has(n));P||Se(t),u?.(t)},[W,d,R,P,u]),Je=z?W.map(Dt):[],Ye=Je.length>0&&Je.every(e=>Xe.has(e)),kr=!Ye&&Je.some(e=>Xe.has(e)),Cr=(0,a.useCallback)(e=>{let t=ve.includes(e)?ve.filter(n=>n!==e):[...ve,e];Me||dr(t),at?.(t)},[ve,Me,at]),Nr=(0,a.useCallback)(e=>{let t=e.target.value;be||kt(t),Ce?.(t),E(1)},[be,Ce,E]),Sr=(0,a.useCallback)(e=>{let t=[...j.filter(n=>n.column!==e.column),e];_||Ae(t),te?.(t),E(1)},[j,_,te,E]),Tr=(0,a.useCallback)(e=>{let t=j.filter(n=>n.column!==e);_||Ae(t),te?.(t),E(1)},[j,_,te,E]),Rr=(0,a.useCallback)(e=>{let t=Y.includes(e)?Y.filter(n=>n!==e):[...Y,e];Fe||ur(t),dt?.(t)},[Y,Fe,dt]),Er=(0,a.useCallback)((e,t)=>{e.preventDefault(),e.stopPropagation(),Be.current=!0;let n=e.clientX,s=he[t]??e.currentTarget.parentElement?.getBoundingClientRect().width??100,i=c.find(w=>w.key===t),x=i?.minWidth??50,T=i?.maxWidth??1/0,Z=w=>{let q=w.clientX-n,H=Math.min(T,Math.max(x,s+q));gr(me=>({...me,[t]:H}))},p=()=>{document.removeEventListener("mousemove",Z),document.removeEventListener("mouseup",p),setTimeout(()=>{Be.current=!1},0)};document.addEventListener("mousemove",Z),document.addEventListener("mouseup",p)},[he,c]),I=ne&&!(m==="client"&&A.some(e=>e.direction)),Dr=(0,a.useCallback)((e,t)=>{I&&He({key:e,sourceIndex:t})},[I]),Gr=(0,a.useCallback)(e=>{!I||J===null||e.preventDefault()},[I,J]),Mr=(0,a.useCallback)((e,t)=>{!I||J===null||(He(null),J.key!==e&&st?.(J.sourceIndex,t))},[I,J,st]),Fr=(0,a.useCallback)(e=>{K&&Nt(e)},[K]),Ir=(0,a.useCallback)(e=>{if(!K||!se||se===e)return;let t=Ee.map(i=>i.key),n=t.indexOf(se),s=t.indexOf(e);n===-1||s===-1||(t.splice(n,1),t.splice(s,0,se),pr(t),it?.(se,e),Nt(null))},[K,se,Ee,it]),Qe=(0,a.useCallback)(e=>{let t=F.filter(w=>w.type!=="actions"&&w.type!=="selection"&&w.type!=="expand"),n=we,s,i,x;if(e==="csv")s=(0,Ht.csvDocument)([t.map(w=>String(w.header)),...n.map(w=>t.map(q=>{let H=L(w,q.key);return typeof H=="number"?H:String(H??"")}))],{neutralizeFormulas:pt}),i="text/csv",x="csv";else{let w=n.map(q=>{let H={};for(let me of t)H[me.key]=L(q,me.key);return H});s=JSON.stringify(w,null,2),i="application/json",x="json"}let T=new Blob([s],{type:i}),Z=URL.createObjectURL(T),p=document.createElement("a");p.href=Z,p.download=`${gt}.${x}`,p.click(),URL.revokeObjectURL(Z)},[F,we,gt,pt]);(0,a.useEffect)(()=>{if(!Te)return;let e=t=>{We.current&&!We.current.contains(t.target)&&St(!1)};return document.addEventListener("mousedown",e),()=>document.removeEventListener("mousedown",e)},[Te]),(0,a.useImperativeHandle)(l,()=>({getVisibleData:()=>qe,resetFilters:()=>{_||Ae([]),be||kt(""),te?.([]),Ce?.(""),E(1)},resetSort:()=>{g||xt([]),b?.([])},selectAll:_e,deselectAll:Ft,exportData:Qe,scrollToRow:e=>{let t=Ve.current;if(!t||!G)return;let n=-1;for(let s=0;s<ue.length;s++){let i=ue[s];if(i.kind==="group")n=s;else if(i.index>=e){i.index===e&&(n=s);break}}n>=0&&(t.scrollTop=n*U)}}),[qe,_,be,g,te,Ce,b,E,_e,Ft,Qe,G,U,ue]);let Ze=(0,a.useCallback)(e=>{let t=e.key in he?he[e.key]:e.width;return t===void 0||t===""?null:typeof t=="number"?`${t}px`:t},[he]),Or=(0,a.useMemo)(()=>{let e=new Map;for(let t of["left","right"]){let n=t==="left"?F:[...F].reverse(),s=[],i=!1;for(let x of n){if(x.sticky!==t)continue;i&&sn(),e.set(x.key,s.length===0?"0px":s.length===1?s[0]:`calc(${s.join(" + ")})`);let T=Ze(x);T===null?i=!0:s.push(T)}}return e},[F,Ze]),et=e=>{let t={},n=Ze(e);return n&&(t.width=n,t.minWidth=n),e.sticky&&(t.position="sticky",t[e.sticky]=Or.get(e.key)??0,t.zIndex=10),t},pe=F.length+(z?1:0)+(re?1:0)+(ne?1:0),Pr=e=>{let t=k&&e.sortable!==!1&&e.type!=="actions",n=A.find(i=>i.key===e.key),s=e.filterable;return(0,r.jsxs)("th",{className:(0,h.cn)(O[C],Ge[C],"relative font-semibold text-gray-700 dark:text-gray-300 whitespace-nowrap",e.align==="center"&&"text-center",e.align==="right"&&"text-right",t&&"cursor-pointer select-none hover:bg-gray-100 dark:hover:bg-gray-700",Ie&&"border border-gray-200 dark:border-gray-700",e.sticky&&"bg-gray-50 dark:bg-gray-800",e.headerClassName,Qt),style:et(e),onClick:t?()=>{Be.current||hr(e.key)}:void 0,draggable:K,onDragStart:K?()=>Fr(e.key):void 0,onDragOver:K?i=>i.preventDefault():void 0,onDrop:K?()=>Ir(e.key):void 0,"aria-sort":n?.direction==="asc"?"ascending":n?.direction==="desc"?"descending":void 0,children:[(0,r.jsxs)("div",{className:"flex items-center gap-1",children:[e.renderHeader?e.renderHeader(e):e.header,t&&(0,r.jsx)("span",{className:"inline-flex ml-1",children:n?.direction==="asc"?(0,r.jsx)(Jr,{}):n?.direction==="desc"?(0,r.jsx)(Yr,{}):(0,r.jsx)(Qr,{})}),s&&(0,r.jsx)(yn,{column:e,value:j.find(i=>i.column===e.key),onApply:Sr,onClear:()=>Tr(e.key),labels:v})]}),e.resizable!==!1&&(0,r.jsx)("div",{className:"absolute top-0 right-0 w-1 h-full cursor-col-resize hover:bg-synertech-primary-500 opacity-0 hover:opacity-100",onMouseDown:i=>Er(i,e.key)})]},e.key)},ke=G?_r[C]:O[C],It=G?{height:U}:void 0,zr=(e,t)=>{let{row:n,sourceIndex:s}=e,i=Dt(e),x=Xe.has(i),T=ve.includes(i),Z=typeof Pe=="function"?Pe(n,t):Pe;return(0,r.jsxs)(a.default.Fragment,{children:[(0,r.jsxs)("tr",{className:(0,h.cn)("border-b border-gray-200 dark:border-gray-700 transition-colors",G&&"whitespace-nowrap",yt&&t%2===1&&"bg-gray-50/50 dark:bg-gray-800/50",x&&"bg-synertech-primary-50 dark:bg-synertech-primary-900/20",Oe&&"cursor-pointer hover:bg-gray-50 dark:hover:bg-gray-700/50",J?.key===i&&"opacity-50",Z),onClick:Oe?()=>Oe(n,t):void 0,onDoubleClick:bt?()=>bt(n,t):void 0,onContextMenu:ht?p=>ht(n,t,p):void 0,draggable:I,onDragStart:I?()=>Dr(i,s):void 0,onDragOver:I?Gr:void 0,onDrop:I?()=>Mr(i,s):void 0,onDragEnd:I?()=>He(null):void 0,"data-row-key":i,"aria-selected":z?x:void 0,style:It,children:[ne&&(0,r.jsx)("td",{className:(0,h.cn)(ke,I?"cursor-grab active:cursor-grabbing":"cursor-not-allowed opacity-40"),children:(0,r.jsx)(en,{})}),z&&(0,r.jsx)("td",{className:(0,h.cn)(ke,"w-10"),children:(0,r.jsx)("input",{type:"checkbox",checked:x,onChange:()=>xr(i),onClick:p=>p.stopPropagation(),className:"rounded border-gray-300 dark:border-gray-600 cursor-pointer","aria-label":(0,D.formatUILabel)(v.dataGridSelectRow,{row:i})})}),re&&(0,r.jsx)("td",{className:(0,h.cn)(ke,"w-10"),children:(0,r.jsx)("button",{type:"button",onClick:p=>{p.stopPropagation(),Cr(i)},className:"p-0.5 rounded hover:bg-gray-200 dark:hover:bg-gray-600 cursor-pointer","aria-label":T?v.dataGridCollapseRow:v.dataGridExpandRow,"aria-expanded":T,children:(0,r.jsx)(Pt,{className:(0,h.cn)("transition-transform",T&&"rotate-180")})})}),F.map(p=>{let w=L(n,p.key),q=p.colSpan?.(n,t);if(q===0)return null;let H=ot&&p.editable!==!1&&p.type!=="actions";return(0,r.jsx)("td",{className:(0,h.cn)(ke,Ge[C],"text-gray-700 dark:text-gray-300",p.align==="center"&&"text-center",p.align==="right"&&"text-right",Ie&&"border border-gray-200 dark:border-gray-700",p.sticky&&(x?"bg-synertech-primary-50 dark:bg-gray-900 dark:bg-linear-to-r dark:from-synertech-primary-900/20 dark:to-synertech-primary-900/20":yt&&t%2===1?"bg-white bg-linear-to-r from-gray-50/50 to-gray-50/50 dark:bg-gray-900 dark:from-gray-800/50 dark:to-gray-800/50":"bg-white dark:bg-gray-900"),p.cellClassName,Yt),style:et(p),colSpan:q,children:H?(0,r.jsx)(fn,{value:w,display:p.render?p.render(w,n,t):String(w??""),onSave:me=>Wt?.(i,p.key,me),density:C,labels:v}):p.render?p.render(w,n,t):String(w??"")},p.key)})]}),re&&T&&nt&&(0,r.jsx)("tr",{className:"bg-gray-50 dark:bg-gray-800/70",children:(0,r.jsx)("td",{colSpan:pe,className:(0,h.cn)(O[C]),children:nt(n,t)})})]},i)},Ar=e=>{let{key:t,rows:n}=e,s=Le.has(t);return(0,r.jsx)("tr",{className:(0,h.cn)("bg-gray-100 dark:bg-gray-800 font-medium",G&&"whitespace-nowrap"),style:It,children:(0,r.jsx)("td",{colSpan:pe,className:(0,h.cn)(ke,"cursor-pointer"),onClick:()=>{mr(i=>{let x=new Set(i);return x.has(t)?x.delete(t):x.add(t),x})},children:(0,r.jsxs)("div",{className:"flex items-center gap-2",children:[(0,r.jsx)(Pt,{className:(0,h.cn)("transition-transform",s&&"-rotate-90")}),ct?ct(t,L(n[0].row,de[0]),n.map(i=>i.row)):`${t} (${n.length})`]})})},`group-${t}`)},Hr=()=>{if(Ut)return Array.from({length:jt}).map((s,i)=>(0,r.jsx)(mn,{cols:pe,density:C},i));if(qe.length===0)return(0,r.jsx)("tr",{children:(0,r.jsx)("td",{colSpan:pe,className:(0,h.cn)("text-center text-gray-500 dark:text-gray-400",O[C]),children:qt??v.dataGridNoData})});let e=s=>s.kind==="row"?zr(s.entry,s.index):Ar(s);if(!G)return ue.map(e);let{start:t,end:n}=br;return(0,r.jsxs)(r.Fragment,{children:[t>0&&(0,r.jsx)("tr",{"aria-hidden":"true",children:(0,r.jsx)("td",{colSpan:pe,style:{height:t*U,padding:0}})}),ue.slice(t,n).map(e),n<ge&&(0,r.jsx)("tr",{"aria-hidden":"true",children:(0,r.jsx)("td",{colSpan:pe,style:{height:(ge-n)*U,padding:0}})})]})},Lr=(e,t)=>{let n=gn(we,e.key,t);return e.renderAggregate?e.renderAggregate(n??0,we):n===null?"":pn(t,n.toLocaleString(ze),v)},Vr=()=>!_t||!F.some(t=>t.aggregate)?null:(0,r.jsx)("tfoot",{children:(0,r.jsxs)("tr",{className:"bg-gray-50 dark:bg-gray-800 font-semibold border-t-2 border-gray-300 dark:border-gray-600",children:[ne&&(0,r.jsx)("td",{className:O[C]}),z&&(0,r.jsx)("td",{className:O[C]}),re&&(0,r.jsx)("td",{className:O[C]}),F.map(t=>(0,r.jsx)("td",{className:(0,h.cn)(O[C],Ge[C],"text-gray-700 dark:text-gray-300",t.align==="center"&&"text-center",t.align==="right"&&"text-right",Ie&&"border border-gray-200 dark:border-gray-700"),style:et(t),children:t.aggregate?Lr(t,t.aggregate):""},t.key))]})});return(0,r.jsxs)("div",{className:(0,h.cn)("flex flex-col gap-3",Jt),children:[(ee||ut||lt)&&(0,r.jsxs)("div",{className:"flex items-center justify-between gap-3 flex-wrap",children:[(0,r.jsxs)("div",{className:"flex items-center gap-3 flex-1",children:[ee&&(0,r.jsxs)("div",{className:"relative flex-1 max-w-xs",children:[(0,r.jsx)("div",{className:"absolute inset-y-0 left-0 flex items-center pl-3 pointer-events-none",children:(0,r.jsx)(Zr,{})}),(0,r.jsx)("input",{type:"text",value:Re,onChange:Nr,placeholder:Vt??v.dataGridSearchPlaceholder,className:"w-full pl-9 pr-3 py-1.5 text-sm border border-gray-300 dark:border-gray-600 rounded-md bg-white dark:bg-gray-800 text-gray-700 dark:text-gray-200 focus:outline-none focus:ring-2 focus:ring-synertech-primary-500 focus:border-synertech-primary-500","aria-label":v.dataGridSearch})]}),R.length>0&&(0,r.jsx)("span",{className:"text-sm text-gray-500 dark:text-gray-400",children:(0,D.formatUILabel)(v.dataGridSelectedCount,{count:R.length})})]}),(0,r.jsxs)("div",{className:"flex items-center gap-2",children:[lt&&(0,r.jsxs)("div",{className:"relative",ref:We,children:[(0,r.jsx)("button",{type:"button",onClick:()=>St(!Te),className:"p-1.5 rounded-md border border-gray-300 dark:border-gray-600 text-gray-600 dark:text-gray-400 hover:bg-gray-100 dark:hover:bg-gray-700 cursor-pointer","aria-label":v.dataGridToggleColumns,title:v.dataGridToggleColumns,children:(0,r.jsx)(nn,{})}),Te&&(0,r.jsx)("div",{className:"absolute z-50 right-0 top-full mt-1 bg-white dark:bg-gray-800 border border-gray-200 dark:border-gray-700 rounded-lg shadow-lg p-2 min-w-[180px]",children:c.filter(e=>e.type!=="selection"&&e.type!=="expand").map(e=>(0,r.jsxs)("label",{className:"flex items-center gap-2 px-2 py-1.5 text-sm rounded hover:bg-gray-100 dark:hover:bg-gray-700 cursor-pointer",children:[(0,r.jsx)("input",{type:"checkbox",checked:!Y.includes(e.key),onChange:()=>Rr(e.key),className:"rounded border-gray-300 dark:border-gray-600 cursor-pointer"}),(0,r.jsx)("span",{className:"text-gray-700 dark:text-gray-300",children:String(e.header)})]},e.key))})]}),ut&&Bt.map(e=>(0,r.jsxs)("button",{type:"button",onClick:()=>Qe(e),className:"inline-flex items-center gap-1.5 px-2.5 py-1.5 text-xs font-medium rounded-md border border-gray-300 dark:border-gray-600 text-gray-600 dark:text-gray-400 hover:bg-gray-100 dark:hover:bg-gray-700 cursor-pointer",title:(0,D.formatUILabel)(v.dataGridExportAs,{format:e.toUpperCase()}),children:[(0,r.jsx)(rn,{}),e.toUpperCase()]},e))]})]}),(0,r.jsx)("div",{ref:Ve,className:(0,h.cn)("overflow-auto rounded-lg",!Kt&&"border border-gray-200 dark:border-gray-700",ft&&"relative"),style:ae?{maxHeight:typeof ae=="number"?`${ae}px`:ae}:G?{maxHeight:mt,overflow:"auto"}:void 0,onScroll:G?e=>{let t=e.currentTarget;yr(Math.floor(t.scrollTop/U)),t.clientHeight>0&&Rt(t.clientHeight)}:void 0,children:(0,r.jsxs)("table",{className:"w-full text-left",children:[(0,r.jsx)("thead",{className:(0,h.cn)("bg-gray-50 dark:bg-gray-800 text-xs uppercase",ft&&"sticky top-0 z-20"),children:(0,r.jsxs)("tr",{children:[ne&&(0,r.jsx)("th",{className:(0,h.cn)(O[C],"w-10 font-semibold text-gray-700 dark:text-gray-300")}),z&&(0,r.jsx)("th",{className:(0,h.cn)(O[C],"w-10"),children:X==="multiple"&&(0,r.jsx)("input",{type:"checkbox",checked:Ye,ref:e=>{e&&(e.indeterminate=kr)},onChange:Ye?wr:_e,className:"rounded border-gray-300 dark:border-gray-600 cursor-pointer","aria-label":v.dataGridSelectAllRows})}),re&&(0,r.jsx)("th",{className:(0,h.cn)(O[C],"w-10 font-semibold text-gray-700 dark:text-gray-300")}),F.map(Pr)]})}),(0,r.jsx)("tbody",{children:Hr()}),Vr()]})}),ie&&(0,r.jsxs)("div",{className:"flex items-center justify-between flex-wrap gap-3 text-sm text-gray-600 dark:text-gray-400",children:[(0,r.jsxs)("div",{className:"flex items-center gap-3",children:[ie.showTotalItems!==!1&&(0,r.jsx)("span",{children:(0,D.formatUILabel)(je===1?v.dataGridItemCount:v.dataGridItemsCount,{count:je})}),ie.showPageSizeSelector!==!1&&ie.pageSizeOptions&&(0,r.jsxs)("div",{className:"flex items-center gap-1.5",children:[(0,r.jsx)("span",{children:v.dataGridRowsPerPage}),(0,r.jsx)("select",{value:xe,onChange:e=>vr(Number(e.target.value)),className:"border border-gray-300 dark:border-gray-600 rounded px-1.5 py-0.5 bg-white dark:bg-gray-800 text-gray-700 dark:text-gray-200 text-sm",children:ie.pageSizeOptions.map(e=>(0,r.jsx)("option",{value:e,children:e},e))})]})]}),(0,r.jsxs)("div",{className:"flex items-center gap-1",children:[(0,r.jsx)("span",{className:"mr-2",children:(0,D.formatUILabel)(v.dataGridPageOf,{page:V,total:Q})}),(0,r.jsx)("button",{type:"button",onClick:()=>E(1),disabled:V<=1,className:"px-2 py-1 rounded border border-gray-300 dark:border-gray-600 disabled:opacity-50 disabled:cursor-not-allowed hover:bg-gray-100 dark:hover:bg-gray-700 cursor-pointer","aria-label":v.dataGridFirstPage,children:"\xAB\xAB"}),(0,r.jsx)("button",{type:"button",onClick:()=>E(V-1),disabled:V<=1,className:"px-2 py-1 rounded border border-gray-300 dark:border-gray-600 disabled:opacity-50 disabled:cursor-not-allowed hover:bg-gray-100 dark:hover:bg-gray-700 cursor-pointer","aria-label":v.dataGridPreviousPage,children:"\xAB"}),(0,r.jsx)("button",{type:"button",onClick:()=>E(V+1),disabled:V>=Q,className:"px-2 py-1 rounded border border-gray-300 dark:border-gray-600 disabled:opacity-50 disabled:cursor-not-allowed hover:bg-gray-100 dark:hover:bg-gray-700 cursor-pointer","aria-label":v.dataGridNextPage,children:"\xBB"}),(0,r.jsx)("button",{type:"button",onClick:()=>E(Q),disabled:V>=Q,className:"px-2 py-1 rounded border border-gray-300 dark:border-gray-600 disabled:opacity-50 disabled:cursor-not-allowed hover:bg-gray-100 dark:hover:bg-gray-700 cursor-pointer","aria-label":v.dataGridLastPage,children:"\xBB\xBB"})]})]})]})}var hn=(0,a.forwardRef)(bn);0&&(module.exports={DataGrid,resetRowKeyWarning});
@@ -1 +1 @@
1
- "use client";import Hr,{useState as f,useRef as Ce,useCallback as h,useEffect as Me,useMemo as P,forwardRef as Lr,useImperativeHandle as Vr}from"react";import{cn as b}from"../../lib/cn.js";import{csvDocument as Kr}from"../../lib/csv.js";import{formatUILabel as _,useUILabels as Wr,useUILocale as Br}from"../../lib/i18n.js";import{Fragment as dn,jsx as n,jsxs as c}from"react/jsx-runtime";var F={compact:"px-3 py-1.5",default:"px-4 py-3",comfortable:"px-6 py-4"},Ur={compact:"px-3 py-0",default:"px-4 py-0",comfortable:"px-6 py-0"},Ge={compact:"text-xs",default:"text-sm",comfortable:"text-base"},jr=()=>n("svg",{className:"w-3.5 h-3.5",viewBox:"0 0 16 16",fill:"currentColor",children:n("path",{d:"M8 3l4 5H4l4-5z"})}),qr=()=>n("svg",{className:"w-3.5 h-3.5",viewBox:"0 0 16 16",fill:"currentColor",children:n("path",{d:"M8 13l4-5H4l4 5z"})}),$r=()=>n("svg",{className:"w-3.5 h-3.5 opacity-30",viewBox:"0 0 16 16",fill:"currentColor",children:n("path",{d:"M8 3l3 4H5l3-4zM8 13l3-4H5l3 4z"})}),Ot=({className:s})=>n("svg",{className:b("w-4 h-4",s),viewBox:"0 0 20 20",fill:"currentColor",children:n("path",{fillRule:"evenodd",d:"M5.23 7.21a.75.75 0 011.06.02L10 11.168l3.71-3.938a.75.75 0 111.08 1.04l-4.25 4.5a.75.75 0 01-1.08 0l-4.25-4.5a.75.75 0 01.02-1.06z",clipRule:"evenodd"})}),Xr=()=>n("svg",{className:"w-4 h-4 text-gray-500 dark:text-gray-400",viewBox:"0 0 20 20",fill:"currentColor",children:n("path",{fillRule:"evenodd",d:"M9 3.5a5.5 5.5 0 100 11 5.5 5.5 0 000-11zM2 9a7 7 0 1112.452 4.391l3.328 3.329a.75.75 0 11-1.06 1.06l-3.329-3.328A7 7 0 012 9z",clipRule:"evenodd"})}),_r=()=>n("svg",{className:"w-4 h-4 text-gray-500 dark:text-gray-400",viewBox:"0 0 20 20",fill:"currentColor",children:n("path",{d:"M7 4a1.5 1.5 0 110-3 1.5 1.5 0 010 3zm6 0a1.5 1.5 0 110-3 1.5 1.5 0 010 3zM7 10.5a1.5 1.5 0 110-3 1.5 1.5 0 010 3zm6 0a1.5 1.5 0 110-3 1.5 1.5 0 010 3zM7 17a1.5 1.5 0 110-3 1.5 1.5 0 010 3zm6 0a1.5 1.5 0 110-3 1.5 1.5 0 010 3z"})}),Jr=()=>n("svg",{className:"w-3.5 h-3.5",viewBox:"0 0 20 20",fill:"currentColor",children:n("path",{fillRule:"evenodd",d:"M2.628 1.601C5.028 1.206 7.49 1 10 1s4.973.206 7.372.601a.75.75 0 01.628.74v2.288a2.25 2.25 0 01-.659 1.59l-4.682 4.683a2.25 2.25 0 00-.659 1.59v3.037c0 .684-.31 1.33-.844 1.757l-1.937 1.55A.75.75 0 018 18.25v-5.757a2.25 2.25 0 00-.659-1.591L2.659 6.22A2.25 2.25 0 012 4.629V2.34a.75.75 0 01.628-.74z",clipRule:"evenodd"})}),Qr=()=>c("svg",{className:"w-4 h-4",viewBox:"0 0 20 20",fill:"currentColor",children:[n("path",{d:"M10.75 2.75a.75.75 0 00-1.5 0v8.614L6.295 8.235a.75.75 0 10-1.09 1.03l4.25 4.5a.75.75 0 001.09 0l4.25-4.5a.75.75 0 00-1.09-1.03l-2.955 3.129V2.75z"}),n("path",{d:"M3.5 12.75a.75.75 0 00-1.5 0v2.5A2.75 2.75 0 004.75 18h10.5A2.75 2.75 0 0018 15.25v-2.5a.75.75 0 00-1.5 0v2.5c0 .69-.56 1.25-1.25 1.25H4.75c-.69 0-1.25-.56-1.25-1.25v-2.5z"})]}),Yr=()=>n("svg",{className:"w-4 h-4",viewBox:"0 0 20 20",fill:"currentColor",children:n("path",{fillRule:"evenodd",d:"M2.5 3A1.5 1.5 0 001 4.5v11A1.5 1.5 0 002.5 17h15a1.5 1.5 0 001.5-1.5v-11A1.5 1.5 0 0017.5 3h-15zM2.5 4.5h6v11h-6v-11zm7.5 0h7.5v11H10v-11z",clipRule:"evenodd"})});function rt(s,d,i){return typeof i=="function"?i(s,d):String(typeof i=="string"?s[i]:d)}var nt=!1;function yn(){nt=!1}function Zr(){nt||(nt=!0,console.warn("[@synertech/ui] DataGrid has no `rowKey`: each row is known by its position in `data`. Selection, expansion and edits follow that position when `data` is refetched or reordered, and from one page to the next in server mode. Pass `rowKey` to tie them to the row."))}function H(s,d){return s[d]}function At(s,d){return d.map(i=>String(H(s,i)??"")).join(" / ")}function at(s){return s==null||typeof s=="string"&&s.trim()===""||typeof s=="number"&&Number.isNaN(s)||s instanceof Date&&Number.isNaN(s.getTime())}function en(s,d,i){let p=at(s),l=at(d);return p||l?p===l?0:p?-1:1:s instanceof Date&&d instanceof Date?s.getTime()-d.getTime():typeof s=="number"&&typeof d=="number"?s-d:i.compare(String(s),String(d))}function tn(s,d){let i=String(s??"").toLowerCase(),p=d.value.toLowerCase();switch(d.operator){case"contains":return i.includes(p);case"equals":return i===p;case"startsWith":return i.startsWith(p);case"endsWith":return i.endsWith(p);case"gt":return Number(s)>Number(d.value);case"gte":return Number(s)>=Number(d.value);case"lt":return Number(s)<Number(d.value);case"lte":return Number(s)<=Number(d.value);case"isEmpty":return i==="";case"isNotEmpty":return i!=="";default:return!0}}function rn(s,d,i){let p=0,l=0,v=0,G=1/0,R=-1/0;for(let C of s){let T=H(C,d);if(at(T))continue;p++;let m=Number(T);Number.isNaN(m)||(l++,v+=m,m<G&&(G=m),m>R&&(R=m))}switch(i){case"count":return p;case"sum":return v;case"avg":return l===0?null:v/l;case"min":return l===0?null:G;case"max":return l===0?null:R}}function nn(s,d,i){if(s==="count")return d;let p=s==="avg"?i.dataGridAggregateAvg:s==="sum"?i.dataGridAggregateSum:s==="min"?i.dataGridAggregateMin:i.dataGridAggregateMax;return _(p,{value:d})}function an({cols:s,density:d}){return n("tr",{className:"border-b border-gray-200 dark:border-gray-700",children:Array.from({length:s}).map((i,p)=>n("td",{className:F[d],children:n("div",{className:"h-4 bg-gray-200 dark:bg-gray-700 rounded animate-pulse"})},p))})}function on({column:s,value:d,onApply:i,onClear:p,labels:l}){let v=s.filterType??"text",G=String(s.header),R=v==="number"?[{value:"equals",label:l.dataGridOperatorEquals},{value:"gt",label:l.dataGridOperatorGreaterThan},{value:"gte",label:l.dataGridOperatorGreaterOrEqual},{value:"lt",label:l.dataGridOperatorLessThan},{value:"lte",label:l.dataGridOperatorLessOrEqual}]:[{value:"contains",label:l.dataGridOperatorContains},{value:"equals",label:l.dataGridOperatorEquals},{value:"startsWith",label:l.dataGridOperatorStartsWith},{value:"endsWith",label:l.dataGridOperatorEndsWith},{value:"isEmpty",label:l.dataGridOperatorIsEmpty},{value:"isNotEmpty",label:l.dataGridOperatorIsNotEmpty}],C=u=>u&&R.some(E=>E.value===u.operator)?u.operator:R[0].value,[T,m]=f(!1),[z,re]=f(()=>C(d)),[J,B]=f(d?.value??""),ne=Ce(null),L=()=>{T||(re(C(d)),B(d?.value??"")),m(!T)};return Me(()=>{let u=E=>{ne.current&&!ne.current.contains(E.target)&&m(!1)};return T&&document.addEventListener("mousedown",u),()=>document.removeEventListener("mousedown",u)},[T]),c("div",{className:"relative inline-block",ref:ne,onClick:u=>u.stopPropagation(),children:[n("button",{type:"button",onClick:L,className:b("p-0.5 rounded hover:bg-gray-200 dark:hover:bg-gray-600 cursor-pointer",d&&"text-synertech-primary-600 dark:text-synertech-primary-400"),"aria-label":_(l.dataGridFilterColumn,{column:G}),children:n(Jr,{})}),T&&n("div",{className:"absolute z-50 top-full left-0 mt-1 bg-white dark:bg-gray-800 border border-gray-200 dark:border-gray-700 rounded-lg shadow-lg p-3 min-w-[220px]",children:v==="select"&&s.filterOptions?c("div",{className:"flex flex-col gap-1.5",children:[s.filterOptions.map(u=>c("label",{className:"flex items-center gap-2 text-sm cursor-pointer",children:[n("input",{type:"radio",name:`filter-${s.key}`,value:u,checked:J===u,onChange:()=>B(u),className:"cursor-pointer"}),n("span",{className:"text-gray-700 dark:text-gray-300",children:u})]},u)),c("div",{className:"flex gap-2 mt-2",children:[n("button",{type:"button",onClick:()=>{i({column:s.key,operator:"equals",value:J}),m(!1)},className:"px-2 py-1 text-xs bg-synertech-primary-600 text-synertech-on-primary rounded hover:bg-synertech-primary-700 cursor-pointer",children:l.dataGridFilterApply}),n("button",{type:"button",onClick:()=>{B(""),p(),m(!1)},className:"px-2 py-1 text-xs text-gray-600 dark:text-gray-400 hover:text-gray-800 dark:hover:text-gray-200 cursor-pointer",children:l.dataGridFilterClear})]})]}):c("div",{className:"flex flex-col gap-2",children:[n("select",{value:z,onChange:u=>re(u.target.value),className:"text-xs border border-gray-300 dark:border-gray-600 rounded px-2 py-1 bg-white dark:bg-gray-700 text-gray-700 dark:text-gray-200",children:R.map(u=>n("option",{value:u.value,children:u.label},u.value))}),z!=="isEmpty"&&z!=="isNotEmpty"&&n("input",{type:v==="number"?"number":v==="date"?"date":"text",value:J,onChange:u=>B(u.target.value),placeholder:l.dataGridFilterValuePlaceholder,className:"text-xs border border-gray-300 dark:border-gray-600 rounded px-2 py-1 bg-white dark:bg-gray-700 text-gray-700 dark:text-gray-200",autoFocus:!0,"aria-label":_(l.dataGridFilterValue,{column:G})}),c("div",{className:"flex gap-2",children:[n("button",{type:"button",onClick:()=>{i({column:s.key,operator:z,value:J}),m(!1)},className:"px-2 py-1 text-xs bg-synertech-primary-600 text-synertech-on-primary rounded hover:bg-synertech-primary-700 cursor-pointer",children:l.dataGridFilterApply}),n("button",{type:"button",onClick:()=>{B(""),p(),m(!1)},className:"px-2 py-1 text-xs text-gray-600 dark:text-gray-400 hover:text-gray-800 dark:hover:text-gray-200 cursor-pointer",children:l.dataGridFilterClear})]})]})})]})}function sn({value:s,onSave:d,density:i,labels:p}){let[l,v]=f(!1),[G,R]=f(String(s??"")),C=Ce(null);if(Me(()=>{l&&C.current&&(C.current.focus(),C.current.select())},[l]),!l)return n("div",{onDoubleClick:()=>{R(String(s??"")),v(!0)},className:"cursor-text min-h-[1.5em]",title:p.dataGridEditHint,children:String(s??"")});let T=()=>{v(!1),G!==String(s??"")&&d(G)};return n("input",{ref:C,type:"text",value:G,onChange:m=>R(m.target.value),onBlur:T,"aria-label":p.dataGridEditCell,onKeyDown:m=>{m.key==="Enter"&&T(),m.key==="Escape"&&v(!1)},className:b("w-full border border-synertech-primary-500 rounded px-1 py-0.5 bg-white dark:bg-gray-700 text-gray-900 dark:text-gray-100 outline-none",Ge[i])})}function ln(s,d){let{columns:i,data:p,rowKey:l,mode:v="client",sortable:G=!1,multiSort:R=!1,sort:C,defaultSort:T,onSort:m,pagination:z=!1,page:re,onPageChange:J,onPageSizeChange:B,totalItems:ne,selectable:L=!1,selectionMode:u="multiple",selectedRows:E,onSelectionChange:U,searchable:ot=!1,searchPlaceholder:Ht,searchValue:he,onSearch:Se,filters:Q,onFilterChange:ae,expandable:oe=!1,expandedContent:st,expandedRows:Ie,onExpandChange:it,editable:lt=!1,onCellEdit:Lt,reorderable:se=!1,onReorder:dt,columnReorderable:j=!1,onColumnReorder:ct,columnToggle:ut=!1,hiddenColumns:Pe,onColumnVisibilityChange:gt,groupBy:Ne,renderGroupHeader:pt,exportable:mt=!1,exportFormats:Vt=["csv","json"],exportFilename:yt="export",exportNeutralizeFormulas:bt,virtualized:D=!1,rowHeight:q=40,virtualHeight:ft=400,density:w="default",striped:ht=!1,bordered:Fe=!1,borderless:Kt=!1,stickyHeader:vt=!1,maxHeight:ie,loading:Wt=!1,loadingRows:Bt=5,emptyState:Ut,labels:jt,locale:qt,showFooter:$t=!1,onRowClick:ze,onRowDoubleClick:xt,onRowContextMenu:wt,className:Xt,rowClassName:Oe,cellClassName:_t,headerClassName:Jt}=s,y=Wr(jt),Ae=Br(qt),kt=P(()=>new Intl.Collator(Ae,{numeric:!0}),[Ae]),[Qt,Ct]=f(T??[]),[Yt,Zt]=f(1),le=typeof z=="object"?z.pageSize:void 0,[er,St]=f(le??10),[tr,rr]=f(le);le!==tr&&(rr(le),le!==void 0&&St(le));let[nr,Re]=f([]),[ar,Nt]=f(""),[or,He]=f([]),[sr,ir]=f([]),[lr,dr]=f(()=>i.flatMap(e=>e.hidden?[e.key]:[])),[Le,cr]=f({}),[Te,ur]=f(()=>i.map(e=>e.key)),[Y,Ve]=f(null),[de,Rt]=f(null),[Ee,Tt]=f(!1),[Ke,gr]=f(new Set),We=Ce(null),[Et,pr]=f(0),[mr,Dt]=f(null),Be=Ce(null),Ue=Ce(!1),O=C??Qt,Gt=re??Yt,S=E??nr,De=he??ar,$=Q??or,ve=Ie??sr,Z=Pe??lr,ce=z?typeof z=="object"?z:{pageSize:10,pageSizeOptions:[10,25,50,100]}:null,xe=er;!l&&(L||oe||lt||se)&&Zr();let Mt=e=>rt(e.row,e.sourceIndex,l),V=P(()=>{let e=new Map(i.map(a=>[a.key,a])),t=Te.flatMap(a=>{let o=e.get(a);return o?[o]:[]}),r=new Set(t.map(a=>a.key));for(let a of i)r.has(a.key)||(t.push(a),r.add(a.key));return t.filter(a=>!Z.includes(a.key))},[i,Te,Z]),ue=P(()=>{let e=p.map((t,r)=>({row:t,sourceIndex:r}));if(v==="server")return e;if(De){let t=De.toLowerCase();e=e.filter(({row:r})=>V.some(a=>{let o=H(r,a.key);return String(o??"").toLowerCase().includes(t)}))}if($.length>0&&(e=e.filter(({row:t})=>$.every(r=>tn(H(t,r.column),r)))),O.length>0){let t=new Map(i.map(r=>[r.key,r]));e.sort((r,a)=>{for(let o of O){if(!o.direction)continue;let x=t.get(o.key),I=x?.sortComparator?x.sortComparator(r.row,a.row):en(H(r.row,o.key),H(a.row,o.key),kt);if(I!==0)return o.direction==="asc"?I:-I}return 0})}return e},[p,v,De,$,O,V,i,kt]),we=P(()=>ue.map(e=>e.row),[ue]),je=Ne?(Array.isArray(Ne)?Ne:[Ne]).join("\0"):"",ge=P(()=>je?je.split("\0"):[],[je]),pe=P(()=>{if(ge.length===0)return null;let e=new Map;for(let t of ue){let r=At(t.row,ge),a=e.get(r);a?a.push(t):e.set(r,[t])}return e},[ue,ge]),qe=P(()=>pe?Array.from(pe.values()).flat():ue,[pe,ue]),$e=ne??we.length,ee=Math.max(1,Math.ceil($e/xe)),K=v==="server"&&ne===void 0?Gt:Math.min(Math.max(1,Gt),ee),It=ce!==null,W=P(()=>{if(!It||v==="server")return qe;let e=(K-1)*xe;return qe.slice(e,e+xe)},[qe,It,K,xe,v]),Xe=P(()=>W.map(e=>e.row),[W]),me=P(()=>{let e=[],t=null;return W.forEach((r,a)=>{if(pe){let o=At(r.row,ge);if(o!==t&&(t=o,e.push({kind:"group",key:o,rows:pe.get(o)??[r]})),Ke.has(o))return}e.push({kind:"row",entry:r,index:a})}),e},[W,pe,ge,Ke]),Pt=mr??(typeof ie=="number"?ie:ft),ye=me.length,yr=P(()=>{if(!D)return{start:0,end:ye};let e=Math.max(1,Math.ceil(Pt/q)),t=Math.min(Et,Math.max(0,ye-e)),r=5;return{start:Math.max(0,t-r),end:Math.min(ye,t+e+r)}},[D,Et,q,Pt,ye]);Me(()=>{if(!D)return;let e=We.current;if(!e)return;let t=()=>{e.clientHeight>0&&Dt(e.clientHeight)};if(t(),typeof ResizeObserver>"u")return;let r=new ResizeObserver(t);return r.observe(e),()=>r.disconnect()},[D]);let _e=h(e=>{C||Ct(e),m?.(e)},[C,m]),br=h(e=>{let t=O.find(a=>a.key===e),r;if(!t||!t.direction?r="asc":t.direction==="asc"?r="desc":r=null,R){let a;r?t?a=O.map(o=>o.key===e?{key:e,direction:r}:o):a=[...O,{key:e,direction:r}]:a=O.filter(o=>o.key!==e),_e(a)}else _e(r?[{key:e,direction:r}]:[])},[O,R,_e]),N=h(e=>{let t=Math.max(1,Math.min(e,ee));re||Zt(t),J?.(t)},[re,J,ee]),fr=h(e=>{St(e),N(1),B?.(e)},[N,B]),hr=h(e=>{let t;u==="single"?t=S.includes(e)?[]:[e]:t=S.includes(e)?S.filter(r=>r!==e):[...S,e],E||Re(t),U?.(t)},[u,S,E,U]),Je=P(()=>new Set(S),[S]),Qe=h(()=>{let e=new Set(S),t=[...S];for(let r of W){let a=rt(r.row,r.sourceIndex,l);e.has(a)||(e.add(a),t.push(a))}E||Re(t),U?.(t)},[W,l,S,E,U]),Ft=h(()=>{E||Re([]),U?.([])},[E,U]),vr=h(()=>{let e=new Set(W.map(r=>rt(r.row,r.sourceIndex,l))),t=S.filter(r=>!e.has(r));E||Re(t),U?.(t)},[W,l,S,E,U]),Ye=L?W.map(Mt):[],Ze=Ye.length>0&&Ye.every(e=>Je.has(e)),xr=!Ze&&Ye.some(e=>Je.has(e)),wr=h(e=>{let t=ve.includes(e)?ve.filter(r=>r!==e):[...ve,e];Ie||ir(t),it?.(t)},[ve,Ie,it]),kr=h(e=>{let t=e.target.value;he||Nt(t),Se?.(t),N(1)},[he,Se,N]),Cr=h(e=>{let t=[...$.filter(r=>r.column!==e.column),e];Q||He(t),ae?.(t),N(1)},[$,Q,ae,N]),Sr=h(e=>{let t=$.filter(r=>r.column!==e);Q||He(t),ae?.(t),N(1)},[$,Q,ae,N]),Nr=h(e=>{let t=Z.includes(e)?Z.filter(r=>r!==e):[...Z,e];Pe||dr(t),gt?.(t)},[Z,Pe,gt]),Rr=h((e,t)=>{e.preventDefault(),e.stopPropagation(),Ue.current=!0;let r=e.clientX,a=Le[t]??e.currentTarget.parentElement?.getBoundingClientRect().width??100,o=i.find(k=>k.key===t),x=o?.minWidth??50,I=o?.maxWidth??1/0,te=k=>{let X=k.clientX-r,A=Math.min(I,Math.max(x,a+X));cr(fe=>({...fe,[t]:A}))},g=()=>{document.removeEventListener("mousemove",te),document.removeEventListener("mouseup",g),setTimeout(()=>{Ue.current=!1},0)};document.addEventListener("mousemove",te),document.addEventListener("mouseup",g)},[Le,i]),M=se&&!(v==="client"&&O.some(e=>e.direction)),Tr=h((e,t)=>{M&&Ve({key:e,sourceIndex:t})},[M]),Er=h(e=>{!M||Y===null||e.preventDefault()},[M,Y]),Dr=h((e,t)=>{!M||Y===null||(Ve(null),Y.key!==e&&dt?.(Y.sourceIndex,t))},[M,Y,dt]),Gr=h(e=>{j&&Rt(e)},[j]),Mr=h(e=>{if(!j||!de||de===e)return;let t=[...Te],r=t.indexOf(de),a=t.indexOf(e);r===-1||a===-1||(t.splice(r,1),t.splice(a,0,de),ur(t),ct?.(de,e),Rt(null))},[j,de,Te,ct]),et=h(e=>{let t=V.filter(k=>k.type!=="actions"&&k.type!=="selection"&&k.type!=="expand"),r=we,a,o,x;if(e==="csv")a=Kr([t.map(k=>String(k.header)),...r.map(k=>t.map(X=>{let A=H(k,X.key);return typeof A=="number"?A:String(A??"")}))],{neutralizeFormulas:bt}),o="text/csv",x="csv";else{let k=r.map(X=>{let A={};for(let fe of t)A[fe.key]=H(X,fe.key);return A});a=JSON.stringify(k,null,2),o="application/json",x="json"}let I=new Blob([a],{type:o}),te=URL.createObjectURL(I),g=document.createElement("a");g.href=te,g.download=`${yt}.${x}`,g.click(),URL.revokeObjectURL(te)},[V,we,yt,bt]);Me(()=>{if(!Ee)return;let e=t=>{Be.current&&!Be.current.contains(t.target)&&Tt(!1)};return document.addEventListener("mousedown",e),()=>document.removeEventListener("mousedown",e)},[Ee]),Vr(d,()=>({getVisibleData:()=>Xe,resetFilters:()=>{Q||He([]),he||Nt(""),ae?.([]),Se?.(""),N(1)},resetSort:()=>{C||Ct([]),m?.([])},selectAll:Qe,deselectAll:Ft,exportData:et,scrollToRow:e=>{let t=We.current;if(!t||!D)return;let r=-1;for(let a=0;a<me.length;a++){let o=me[a];if(o.kind==="group")r=a;else if(o.index>=e){o.index===e&&(r=a);break}}r>=0&&(t.scrollTop=r*q)}}),[Xe,Q,he,C,ae,Se,m,N,Qe,Ft,et,D,q,me]);let tt=e=>{let t={},r=Le[e.key]??e.width;return r&&(t.width=typeof r=="number"?`${r}px`:r,t.minWidth=typeof r=="number"?`${r}px`:r),e.sticky&&(t.position="sticky",t[e.sticky]=0,t.zIndex=10),t},be=V.length+(L?1:0)+(oe?1:0)+(se?1:0),Ir=e=>{let t=G&&e.sortable!==!1&&e.type!=="actions",r=O.find(o=>o.key===e.key),a=e.filterable&&(e.filterType||e.filterOptions);return c("th",{className:b(F[w],Ge[w],"relative font-semibold text-gray-700 dark:text-gray-300 whitespace-nowrap",e.align==="center"&&"text-center",e.align==="right"&&"text-right",t&&"cursor-pointer select-none hover:bg-gray-100 dark:hover:bg-gray-700",Fe&&"border border-gray-200 dark:border-gray-700",e.sticky&&"bg-gray-50 dark:bg-gray-800",e.headerClassName,Jt),style:tt(e),onClick:t?()=>{Ue.current||br(e.key)}:void 0,draggable:j,onDragStart:j?()=>Gr(e.key):void 0,onDragOver:j?o=>o.preventDefault():void 0,onDrop:j?()=>Mr(e.key):void 0,"aria-sort":r?.direction==="asc"?"ascending":r?.direction==="desc"?"descending":void 0,children:[c("div",{className:"flex items-center gap-1",children:[e.renderHeader?e.renderHeader(e):e.header,t&&n("span",{className:"inline-flex ml-1",children:r?.direction==="asc"?n(jr,{}):r?.direction==="desc"?n(qr,{}):n($r,{})}),a&&n(on,{column:e,value:$.find(o=>o.column===e.key),onApply:Cr,onClear:()=>Sr(e.key),labels:y})]}),e.resizable!==!1&&n("div",{className:"absolute top-0 right-0 w-1 h-full cursor-col-resize hover:bg-synertech-primary-500 opacity-0 hover:opacity-100",onMouseDown:o=>Rr(o,e.key)})]},e.key)},ke=D?Ur[w]:F[w],zt=D?{height:q}:void 0,Pr=(e,t)=>{let{row:r,sourceIndex:a}=e,o=Mt(e),x=Je.has(o),I=ve.includes(o),te=typeof Oe=="function"?Oe(r,t):Oe;return c(Hr.Fragment,{children:[c("tr",{className:b("border-b border-gray-200 dark:border-gray-700 transition-colors",D&&"whitespace-nowrap",ht&&t%2===1&&"bg-gray-50/50 dark:bg-gray-800/50",x&&"bg-synertech-primary-50 dark:bg-synertech-primary-900/20",ze&&"cursor-pointer hover:bg-gray-50 dark:hover:bg-gray-700/50",Y?.key===o&&"opacity-50",te),onClick:ze?()=>ze(r,t):void 0,onDoubleClick:xt?()=>xt(r,t):void 0,onContextMenu:wt?g=>wt(r,t,g):void 0,draggable:M,onDragStart:M?()=>Tr(o,a):void 0,onDragOver:M?Er:void 0,onDrop:M?()=>Dr(o,a):void 0,onDragEnd:M?()=>Ve(null):void 0,"data-row-key":o,"aria-selected":L?x:void 0,style:zt,children:[se&&n("td",{className:b(ke,M?"cursor-grab active:cursor-grabbing":"cursor-not-allowed opacity-40"),children:n(_r,{})}),L&&n("td",{className:b(ke,"w-10"),children:n("input",{type:"checkbox",checked:x,onChange:()=>hr(o),onClick:g=>g.stopPropagation(),className:"rounded border-gray-300 dark:border-gray-600 cursor-pointer","aria-label":_(y.dataGridSelectRow,{row:o})})}),oe&&n("td",{className:b(ke,"w-10"),children:n("button",{type:"button",onClick:g=>{g.stopPropagation(),wr(o)},className:"p-0.5 rounded hover:bg-gray-200 dark:hover:bg-gray-600 cursor-pointer","aria-label":I?y.dataGridCollapseRow:y.dataGridExpandRow,"aria-expanded":I,children:n(Ot,{className:b("transition-transform",I&&"rotate-180")})})}),V.map(g=>{let k=H(r,g.key),X=g.colSpan?.(r,t);if(X===0)return null;let A=lt&&g.editable!==!1&&g.type!=="actions";return n("td",{className:b(ke,Ge[w],"text-gray-700 dark:text-gray-300",g.align==="center"&&"text-center",g.align==="right"&&"text-right",Fe&&"border border-gray-200 dark:border-gray-700",g.sticky&&(x?"bg-synertech-primary-50 dark:bg-synertech-primary-900/20":ht&&t%2===1?"bg-gray-50/50 dark:bg-gray-800/50":"bg-white dark:bg-gray-900"),g.cellClassName,_t),style:tt(g),colSpan:X,children:A?n(sn,{value:k,onSave:fe=>Lt?.(o,g.key,fe),density:w,labels:y}):g.render?g.render(k,r,t):String(k??"")},g.key)})]}),oe&&I&&st&&n("tr",{className:"bg-gray-50 dark:bg-gray-800/70",children:n("td",{colSpan:be,className:b(F[w]),children:st(r,t)})})]},o)},Fr=e=>{let{key:t,rows:r}=e,a=Ke.has(t);return n("tr",{className:b("bg-gray-100 dark:bg-gray-800 font-medium",D&&"whitespace-nowrap"),style:zt,children:n("td",{colSpan:be,className:b(ke,"cursor-pointer"),onClick:()=>{gr(o=>{let x=new Set(o);return x.has(t)?x.delete(t):x.add(t),x})},children:c("div",{className:"flex items-center gap-2",children:[n(Ot,{className:b("transition-transform",a&&"-rotate-90")}),pt?pt(t,H(r[0].row,ge[0]),r.map(o=>o.row)):`${t} (${r.length})`]})})},`group-${t}`)},zr=()=>{if(Wt)return Array.from({length:Bt}).map((a,o)=>n(an,{cols:be,density:w},o));if(Xe.length===0)return n("tr",{children:n("td",{colSpan:be,className:b("text-center text-gray-500 dark:text-gray-400",F[w]),children:Ut??y.dataGridNoData})});let e=a=>a.kind==="row"?Pr(a.entry,a.index):Fr(a);if(!D)return me.map(e);let{start:t,end:r}=yr;return c(dn,{children:[t>0&&n("tr",{"aria-hidden":"true",children:n("td",{colSpan:be,style:{height:t*q,padding:0}})}),me.slice(t,r).map(e),r<ye&&n("tr",{"aria-hidden":"true",children:n("td",{colSpan:be,style:{height:(ye-r)*q,padding:0}})})]})},Or=(e,t)=>{let r=rn(we,e.key,t);return e.renderAggregate?e.renderAggregate(r??0,we):r===null?"":nn(t,r.toLocaleString(Ae),y)},Ar=()=>!$t||!V.some(t=>t.aggregate)?null:n("tfoot",{children:c("tr",{className:"bg-gray-50 dark:bg-gray-800 font-semibold border-t-2 border-gray-300 dark:border-gray-600",children:[se&&n("td",{className:F[w]}),L&&n("td",{className:F[w]}),oe&&n("td",{className:F[w]}),V.map(t=>n("td",{className:b(F[w],Ge[w],"text-gray-700 dark:text-gray-300",t.align==="center"&&"text-center",t.align==="right"&&"text-right",Fe&&"border border-gray-200 dark:border-gray-700"),style:tt(t),children:t.aggregate?Or(t,t.aggregate):""},t.key))]})});return c("div",{className:b("flex flex-col gap-3",Xt),children:[(ot||mt||ut)&&c("div",{className:"flex items-center justify-between gap-3 flex-wrap",children:[c("div",{className:"flex items-center gap-3 flex-1",children:[ot&&c("div",{className:"relative flex-1 max-w-xs",children:[n("div",{className:"absolute inset-y-0 left-0 flex items-center pl-3 pointer-events-none",children:n(Xr,{})}),n("input",{type:"text",value:De,onChange:kr,placeholder:Ht??y.dataGridSearchPlaceholder,className:"w-full pl-9 pr-3 py-1.5 text-sm border border-gray-300 dark:border-gray-600 rounded-md bg-white dark:bg-gray-800 text-gray-700 dark:text-gray-200 focus:outline-none focus:ring-2 focus:ring-synertech-primary-500 focus:border-synertech-primary-500","aria-label":y.dataGridSearch})]}),S.length>0&&n("span",{className:"text-sm text-gray-500 dark:text-gray-400",children:_(y.dataGridSelectedCount,{count:S.length})})]}),c("div",{className:"flex items-center gap-2",children:[ut&&c("div",{className:"relative",ref:Be,children:[n("button",{type:"button",onClick:()=>Tt(!Ee),className:"p-1.5 rounded-md border border-gray-300 dark:border-gray-600 text-gray-600 dark:text-gray-400 hover:bg-gray-100 dark:hover:bg-gray-700 cursor-pointer","aria-label":y.dataGridToggleColumns,title:y.dataGridToggleColumns,children:n(Yr,{})}),Ee&&n("div",{className:"absolute z-50 right-0 top-full mt-1 bg-white dark:bg-gray-800 border border-gray-200 dark:border-gray-700 rounded-lg shadow-lg p-2 min-w-[180px]",children:i.filter(e=>e.type!=="selection"&&e.type!=="expand").map(e=>c("label",{className:"flex items-center gap-2 px-2 py-1.5 text-sm rounded hover:bg-gray-100 dark:hover:bg-gray-700 cursor-pointer",children:[n("input",{type:"checkbox",checked:!Z.includes(e.key),onChange:()=>Nr(e.key),className:"rounded border-gray-300 dark:border-gray-600 cursor-pointer"}),n("span",{className:"text-gray-700 dark:text-gray-300",children:String(e.header)})]},e.key))})]}),mt&&Vt.map(e=>c("button",{type:"button",onClick:()=>et(e),className:"inline-flex items-center gap-1.5 px-2.5 py-1.5 text-xs font-medium rounded-md border border-gray-300 dark:border-gray-600 text-gray-600 dark:text-gray-400 hover:bg-gray-100 dark:hover:bg-gray-700 cursor-pointer",title:_(y.dataGridExportAs,{format:e.toUpperCase()}),children:[n(Qr,{}),e.toUpperCase()]},e))]})]}),n("div",{ref:We,className:b("overflow-auto rounded-lg",!Kt&&"border border-gray-200 dark:border-gray-700",vt&&"relative"),style:ie?{maxHeight:typeof ie=="number"?`${ie}px`:ie}:D?{maxHeight:ft,overflow:"auto"}:void 0,onScroll:D?e=>{let t=e.currentTarget;pr(Math.floor(t.scrollTop/q)),t.clientHeight>0&&Dt(t.clientHeight)}:void 0,children:c("table",{className:"w-full text-left",children:[n("thead",{className:b("bg-gray-50 dark:bg-gray-800 text-xs uppercase",vt&&"sticky top-0 z-20"),children:c("tr",{children:[se&&n("th",{className:b(F[w],"w-10 font-semibold text-gray-700 dark:text-gray-300")}),L&&n("th",{className:b(F[w],"w-10"),children:u==="multiple"&&n("input",{type:"checkbox",checked:Ze,ref:e=>{e&&(e.indeterminate=xr)},onChange:Ze?vr:Qe,className:"rounded border-gray-300 dark:border-gray-600 cursor-pointer","aria-label":y.dataGridSelectAllRows})}),oe&&n("th",{className:b(F[w],"w-10 font-semibold text-gray-700 dark:text-gray-300")}),V.map(Ir)]})}),n("tbody",{children:zr()}),Ar()]})}),ce&&c("div",{className:"flex items-center justify-between flex-wrap gap-3 text-sm text-gray-600 dark:text-gray-400",children:[c("div",{className:"flex items-center gap-3",children:[ce.showTotalItems!==!1&&n("span",{children:_($e===1?y.dataGridItemCount:y.dataGridItemsCount,{count:$e})}),ce.showPageSizeSelector!==!1&&ce.pageSizeOptions&&c("div",{className:"flex items-center gap-1.5",children:[n("span",{children:y.dataGridRowsPerPage}),n("select",{value:xe,onChange:e=>fr(Number(e.target.value)),className:"border border-gray-300 dark:border-gray-600 rounded px-1.5 py-0.5 bg-white dark:bg-gray-800 text-gray-700 dark:text-gray-200 text-sm",children:ce.pageSizeOptions.map(e=>n("option",{value:e,children:e},e))})]})]}),c("div",{className:"flex items-center gap-1",children:[n("span",{className:"mr-2",children:_(y.dataGridPageOf,{page:K,total:ee})}),n("button",{type:"button",onClick:()=>N(1),disabled:K<=1,className:"px-2 py-1 rounded border border-gray-300 dark:border-gray-600 disabled:opacity-50 disabled:cursor-not-allowed hover:bg-gray-100 dark:hover:bg-gray-700 cursor-pointer","aria-label":y.dataGridFirstPage,children:"\xAB\xAB"}),n("button",{type:"button",onClick:()=>N(K-1),disabled:K<=1,className:"px-2 py-1 rounded border border-gray-300 dark:border-gray-600 disabled:opacity-50 disabled:cursor-not-allowed hover:bg-gray-100 dark:hover:bg-gray-700 cursor-pointer","aria-label":y.dataGridPreviousPage,children:"\xAB"}),n("button",{type:"button",onClick:()=>N(K+1),disabled:K>=ee,className:"px-2 py-1 rounded border border-gray-300 dark:border-gray-600 disabled:opacity-50 disabled:cursor-not-allowed hover:bg-gray-100 dark:hover:bg-gray-700 cursor-pointer","aria-label":y.dataGridNextPage,children:"\xBB"}),n("button",{type:"button",onClick:()=>N(ee),disabled:K>=ee,className:"px-2 py-1 rounded border border-gray-300 dark:border-gray-600 disabled:opacity-50 disabled:cursor-not-allowed hover:bg-gray-100 dark:hover:bg-gray-700 cursor-pointer","aria-label":y.dataGridLastPage,children:"\xBB\xBB"})]})]})]})}var bn=Lr(ln);export{bn as DataGrid,yn as resetRowKeyWarning};
1
+ "use client";import Br,{useState as b,useRef as Te,useCallback as w,useEffect as Oe,useMemo as M,forwardRef as Kr,useImperativeHandle as Ur}from"react";import{cn as x}from"../../lib/cn.js";import{csvDocument as jr}from"../../lib/csv.js";import{toTimestamp as qr}from"../chart/utils/timestamp.js";import{formatUILabel as U,useUILabels as $r,useUILocale as Xr}from"../../lib/i18n.js";import{Fragment as bn,jsx as n,jsxs as p}from"react/jsx-runtime";var z={compact:"px-3 py-1.5",default:"px-4 py-3",comfortable:"px-6 py-4"},_r={compact:"px-3 py-0",default:"px-4 py-0",comfortable:"px-6 py-0"},Ie={compact:"text-xs",default:"text-sm",comfortable:"text-base"},Jr=()=>n("svg",{className:"w-3.5 h-3.5",viewBox:"0 0 16 16",fill:"currentColor",children:n("path",{d:"M8 3l4 5H4l4-5z"})}),Yr=()=>n("svg",{className:"w-3.5 h-3.5",viewBox:"0 0 16 16",fill:"currentColor",children:n("path",{d:"M8 13l4-5H4l4 5z"})}),Qr=()=>n("svg",{className:"w-3.5 h-3.5 opacity-30",viewBox:"0 0 16 16",fill:"currentColor",children:n("path",{d:"M8 3l3 4H5l3-4zM8 13l3-4H5l3 4z"})}),Ht=({className:s})=>n("svg",{className:x("w-4 h-4",s),viewBox:"0 0 20 20",fill:"currentColor",children:n("path",{fillRule:"evenodd",d:"M5.23 7.21a.75.75 0 011.06.02L10 11.168l3.71-3.938a.75.75 0 111.08 1.04l-4.25 4.5a.75.75 0 01-1.08 0l-4.25-4.5a.75.75 0 01.02-1.06z",clipRule:"evenodd"})}),Zr=()=>n("svg",{className:"w-4 h-4 text-gray-500 dark:text-gray-400",viewBox:"0 0 20 20",fill:"currentColor",children:n("path",{fillRule:"evenodd",d:"M9 3.5a5.5 5.5 0 100 11 5.5 5.5 0 000-11zM2 9a7 7 0 1112.452 4.391l3.328 3.329a.75.75 0 11-1.06 1.06l-3.329-3.328A7 7 0 012 9z",clipRule:"evenodd"})}),en=()=>n("svg",{className:"w-4 h-4 text-gray-500 dark:text-gray-400",viewBox:"0 0 20 20",fill:"currentColor",children:n("path",{d:"M7 4a1.5 1.5 0 110-3 1.5 1.5 0 010 3zm6 0a1.5 1.5 0 110-3 1.5 1.5 0 010 3zM7 10.5a1.5 1.5 0 110-3 1.5 1.5 0 010 3zm6 0a1.5 1.5 0 110-3 1.5 1.5 0 010 3zM7 17a1.5 1.5 0 110-3 1.5 1.5 0 010 3zm6 0a1.5 1.5 0 110-3 1.5 1.5 0 010 3z"})}),tn=()=>n("svg",{className:"w-3.5 h-3.5",viewBox:"0 0 20 20",fill:"currentColor",children:n("path",{fillRule:"evenodd",d:"M2.628 1.601C5.028 1.206 7.49 1 10 1s4.973.206 7.372.601a.75.75 0 01.628.74v2.288a2.25 2.25 0 01-.659 1.59l-4.682 4.683a2.25 2.25 0 00-.659 1.59v3.037c0 .684-.31 1.33-.844 1.757l-1.937 1.55A.75.75 0 018 18.25v-5.757a2.25 2.25 0 00-.659-1.591L2.659 6.22A2.25 2.25 0 012 4.629V2.34a.75.75 0 01.628-.74z",clipRule:"evenodd"})}),rn=()=>p("svg",{className:"w-4 h-4",viewBox:"0 0 20 20",fill:"currentColor",children:[n("path",{d:"M10.75 2.75a.75.75 0 00-1.5 0v8.614L6.295 8.235a.75.75 0 10-1.09 1.03l4.25 4.5a.75.75 0 001.09 0l4.25-4.5a.75.75 0 00-1.09-1.03l-2.955 3.129V2.75z"}),n("path",{d:"M3.5 12.75a.75.75 0 00-1.5 0v2.5A2.75 2.75 0 004.75 18h10.5A2.75 2.75 0 0018 15.25v-2.5a.75.75 0 00-1.5 0v2.5c0 .69-.56 1.25-1.25 1.25H4.75c-.69 0-1.25-.56-1.25-1.25v-2.5z"})]}),nn=()=>n("svg",{className:"w-4 h-4",viewBox:"0 0 20 20",fill:"currentColor",children:n("path",{fillRule:"evenodd",d:"M2.5 3A1.5 1.5 0 001 4.5v11A1.5 1.5 0 002.5 17h15a1.5 1.5 0 001.5-1.5v-11A1.5 1.5 0 0017.5 3h-15zM2.5 4.5h6v11h-6v-11zm7.5 0h7.5v11H10v-11z",clipRule:"evenodd"})});function ot(s,l,d){return typeof d=="function"?d(s,l):String(typeof d=="string"?s[d]:l)}var st=!1;function Nn(){st=!1}function an(){st||(st=!0,console.warn("[@synertech/ui] DataGrid has no `rowKey`: each row is known by its position in `data`. Selection, expansion and edits follow that position when `data` is refetched or reordered, and from one page to the next in server mode. Pass `rowKey` to tie them to the row."))}var Lt=!1;function on(){Lt||(Lt=!0,console.warn("[@synertech/ui] DataGrid has a sticky column after another one with no `width` on the same side: it cannot know where the first one ends, and the two overlap. Give every sticky column but the last a `width`."))}function W(s,l){return s[l]}function Vt(s,l){return l.map(d=>String(W(s,d)??"")).join(" / ")}function he(s){return s==null||typeof s=="string"&&s.trim()===""||typeof s=="number"&&Number.isNaN(s)||s instanceof Date&&Number.isNaN(s.getTime())}function sn(s,l,d){let k=he(s),i=he(l);return k||i?k===i?0:k?-1:1:s instanceof Date&&l instanceof Date?s.getTime()-l.getTime():typeof s=="number"&&typeof l=="number"?s-l:d.compare(String(s),String(l))}function ln(s){let l=qr(s);if(l===null)return null;let d=new Date(l);return new Date(d.getFullYear(),d.getMonth(),d.getDate()).getTime()}function dn(s){if(he(s))return null;let l=typeof s=="number"?s:Number(s);return Number.isFinite(l)?l:null}function cn(s,l,d="text"){if(l.operator==="isEmpty")return he(s);if(l.operator==="isNotEmpty")return!he(s);let k=["gt","gte","lt","lte","between"].includes(l.operator);if(d==="number"||d==="date"||k){let N=d==="date"?ln:dn,y=N(s),u=l.value.trim()===""?null:N(l.value),T=l.valueTo===void 0||l.valueTo.trim()===""?null:N(l.valueTo);if(y===null)return!1;switch(l.operator){case"equals":return u===null||y===u;case"gt":return u===null||y>u;case"gte":return u===null||y>=u;case"lt":return u===null||y<u;case"lte":return u===null||y<=u;case"between":return(u===null||y>=u)&&(T===null||y<=T);default:return!0}}let i=String(s??"").toLowerCase(),m=l.value.toLowerCase();switch(l.operator){case"contains":return i.includes(m);case"equals":return i===m;case"startsWith":return i.startsWith(m);case"endsWith":return i.endsWith(m);default:return!0}}function un(s,l,d){let k=0,i=0,m=0,N=1/0,y=-1/0;for(let u of s){let T=W(u,l);if(he(T))continue;k++;let f=Number(T);Number.isNaN(f)||(i++,m+=f,f<N&&(N=f),f>y&&(y=f))}switch(d){case"count":return k;case"sum":return m;case"avg":return i===0?null:m/i;case"min":return i===0?null:N;case"max":return i===0?null:y}}function gn(s,l,d){if(s==="count")return l;let k=s==="avg"?d.dataGridAggregateAvg:s==="sum"?d.dataGridAggregateSum:s==="min"?d.dataGridAggregateMin:d.dataGridAggregateMax;return U(k,{value:l})}function pn({cols:s,density:l}){return n("tr",{className:"border-b border-gray-200 dark:border-gray-700",children:Array.from({length:s}).map((d,k)=>n("td",{className:z[l],children:n("div",{className:"h-4 bg-gray-200 dark:bg-gray-700 rounded animate-pulse"})},k))})}function mn({column:s,value:l,onApply:d,onClear:k,labels:i}){let m=s.filterType??"text",N=String(s.header),y=m==="number"?[{value:"equals",label:i.dataGridOperatorEquals},{value:"gt",label:i.dataGridOperatorGreaterThan},{value:"gte",label:i.dataGridOperatorGreaterOrEqual},{value:"lt",label:i.dataGridOperatorLessThan},{value:"lte",label:i.dataGridOperatorLessOrEqual},{value:"between",label:i.dataGridOperatorBetween}]:m==="date"?[{value:"equals",label:i.dataGridOperatorOn},{value:"lt",label:i.dataGridOperatorBefore},{value:"gt",label:i.dataGridOperatorAfter},{value:"between",label:i.dataGridOperatorBetween},{value:"isEmpty",label:i.dataGridOperatorIsEmpty},{value:"isNotEmpty",label:i.dataGridOperatorIsNotEmpty}]:[{value:"contains",label:i.dataGridOperatorContains},{value:"equals",label:i.dataGridOperatorEquals},{value:"startsWith",label:i.dataGridOperatorStartsWith},{value:"endsWith",label:i.dataGridOperatorEndsWith},{value:"isEmpty",label:i.dataGridOperatorIsEmpty},{value:"isNotEmpty",label:i.dataGridOperatorIsNotEmpty}],u=c=>c&&y.some(ne=>ne.value===c.operator)?c.operator:y[0].value,[T,f]=b(!1),[R,I]=b(()=>u(l)),[J,j]=b(l?.value??""),[ve,H]=b(l?.valueTo??""),Y=Te(null),A=()=>{T||(I(u(l)),j(l?.value??""),H(l?.valueTo??"")),f(!T)};return Oe(()=>{let c=ne=>{Y.current&&!Y.current.contains(ne.target)&&f(!1)};return T&&document.addEventListener("mousedown",c),()=>document.removeEventListener("mousedown",c)},[T]),p("div",{className:"relative inline-block",ref:Y,onClick:c=>c.stopPropagation(),children:[n("button",{type:"button",onClick:A,className:x("p-0.5 rounded hover:bg-gray-200 dark:hover:bg-gray-600 cursor-pointer",l&&"text-synertech-primary-600 dark:text-synertech-primary-400"),"aria-label":U(i.dataGridFilterColumn,{column:N}),children:n(tn,{})}),T&&n("div",{className:"absolute z-50 top-full left-0 mt-1 bg-white dark:bg-gray-800 border border-gray-200 dark:border-gray-700 rounded-lg shadow-lg p-3 min-w-[220px]",children:m==="select"&&s.filterOptions?p("div",{className:"flex flex-col gap-1.5",children:[s.filterOptions.map(c=>p("label",{className:"flex items-center gap-2 text-sm cursor-pointer",children:[n("input",{type:"radio",name:`filter-${s.key}`,value:c,checked:J===c,onChange:()=>j(c),className:"cursor-pointer"}),n("span",{className:"text-gray-700 dark:text-gray-300",children:c})]},c)),p("div",{className:"flex gap-2 mt-2",children:[n("button",{type:"button",onClick:()=>{d({column:s.key,operator:"equals",value:J}),f(!1)},className:"px-2 py-1 text-xs bg-synertech-primary-600 text-synertech-on-primary rounded hover:bg-synertech-primary-700 cursor-pointer",children:i.dataGridFilterApply}),n("button",{type:"button",onClick:()=>{j(""),k(),f(!1)},className:"px-2 py-1 text-xs text-gray-600 dark:text-gray-400 hover:text-gray-800 dark:hover:text-gray-200 cursor-pointer",children:i.dataGridFilterClear})]})]}):p("div",{className:"flex flex-col gap-2",children:[n("select",{value:R,onChange:c=>I(c.target.value),className:"text-xs border border-gray-300 dark:border-gray-600 rounded px-2 py-1 bg-white dark:bg-gray-700 text-gray-700 dark:text-gray-200",children:y.map(c=>n("option",{value:c.value,children:c.label},c.value))}),R!=="isEmpty"&&R!=="isNotEmpty"&&n("input",{type:m==="number"?"number":m==="date"?"date":"text",value:J,onChange:c=>j(c.target.value),placeholder:i.dataGridFilterValuePlaceholder,className:"text-xs border border-gray-300 dark:border-gray-600 rounded px-2 py-1 bg-white dark:bg-gray-700 text-gray-700 dark:text-gray-200",autoFocus:!0,"aria-label":U(i.dataGridFilterValue,{column:N})}),R==="between"&&n("input",{type:m==="date"?"date":"number",value:ve,onChange:c=>H(c.target.value),placeholder:i.dataGridFilterValuePlaceholder,className:"text-xs border border-gray-300 dark:border-gray-600 rounded px-2 py-1 bg-white dark:bg-gray-700 text-gray-700 dark:text-gray-200","aria-label":U(i.dataGridFilterValueTo,{column:N})}),p("div",{className:"flex gap-2",children:[n("button",{type:"button",onClick:()=>{d({column:s.key,operator:R,value:J,...R==="between"?{valueTo:ve}:{}}),f(!1)},className:"px-2 py-1 text-xs bg-synertech-primary-600 text-synertech-on-primary rounded hover:bg-synertech-primary-700 cursor-pointer",children:i.dataGridFilterApply}),n("button",{type:"button",onClick:()=>{j(""),k(),f(!1)},className:"px-2 py-1 text-xs text-gray-600 dark:text-gray-400 hover:text-gray-800 dark:hover:text-gray-200 cursor-pointer",children:i.dataGridFilterClear})]})]})})]})}function yn({value:s,display:l,onSave:d,density:k,labels:i}){let m=typeof s=="number",[N,y]=b(!1),[u,T]=b(String(s??"")),f=Te(null);if(Oe(()=>{N&&f.current&&(f.current.focus(),f.current.select())},[N]),!N)return n("div",{onDoubleClick:()=>{T(String(s??"")),y(!0)},className:"cursor-text min-h-[1.5em]",title:i.dataGridEditHint,children:l});let R=()=>{if(y(!1),u!==String(s??"")){if(!m){d(u);return}u.trim()===""?d(null):Number.isFinite(Number(u))&&d(Number(u))}};return n("input",{ref:f,type:m?"number":"text",value:u,onChange:I=>T(I.target.value),onBlur:R,"aria-label":i.dataGridEditCell,onKeyDown:I=>{I.key==="Enter"&&R(),I.key==="Escape"&&(I.preventDefault(),y(!1))},className:x("w-full border border-synertech-primary-500 rounded px-1 py-0.5 bg-white dark:bg-gray-700 text-gray-900 dark:text-gray-100 outline-none",Ie[k])})}function fn(s,l){let{columns:d,data:k,rowKey:i,mode:m="client",sortable:N=!1,multiSort:y=!1,sort:u,defaultSort:T,onSort:f,pagination:R=!1,page:I,onPageChange:J,onPageSizeChange:j,totalItems:ve,selectable:H=!1,selectionMode:Y="multiple",selectedRows:A,onSelectionChange:c,searchable:ne=!1,searchPlaceholder:Wt,searchValue:xe,onSearch:Re,filters:Q,onFilterChange:ae,expandable:oe=!1,expandedContent:it,expandedRows:Pe,onExpandChange:lt,editable:dt=!1,onCellEdit:Bt,reorderable:se=!1,onReorder:ct,columnReorderable:q=!1,onColumnReorder:ut,columnToggle:gt=!1,hiddenColumns:ze,onColumnVisibilityChange:pt,groupBy:Ee,renderGroupHeader:mt,exportable:yt=!1,exportFormats:Kt=["csv","json"],exportFilename:ft="export",exportNeutralizeFormulas:bt,virtualized:F=!1,rowHeight:$=40,virtualHeight:ht=400,density:S="default",striped:vt=!1,bordered:Ae=!1,borderless:Ut=!1,stickyHeader:xt=!1,maxHeight:ie,loading:jt=!1,loadingRows:qt=5,emptyState:$t,labels:Xt,locale:_t,showFooter:Jt=!1,onRowClick:He,onRowDoubleClick:wt,onRowContextMenu:kt,className:Yt,rowClassName:Le,cellClassName:Qt,headerClassName:Zt}=s,h=$r(Xt),Ve=Xr(_t),Ct=M(()=>new Intl.Collator(Ve,{numeric:!0}),[Ve]),[er,Nt]=b(T??[]),[tr,rr]=b(1),le=typeof R=="object"?R.pageSize:void 0,[nr,St]=b(le??10),[ar,or]=b(le);le!==ar&&(or(le),le!==void 0&&St(le));let[sr,De]=b([]),[ir,Tt]=b(""),[lr,We]=b([]),[dr,cr]=b([]),[ur,gr]=b(()=>d.flatMap(e=>e.hidden?[e.key]:[])),[we,pr]=b({}),[Rt,mr]=b(()=>d.map(e=>e.key)),[Z,Be]=b(null),[de,Et]=b(null),[Ge,Dt]=b(!1),[Ke,yr]=b(new Set),Ue=Te(null),[Gt,fr]=b(0),[br,Mt]=b(null),je=Te(null),qe=Te(!1),L=u??er,Ft=I??tr,D=A??sr,Me=xe??ir,X=Q??lr,ke=Pe??dr,ee=ze??ur,ce=R?typeof R=="object"?R:{pageSize:10,pageSizeOptions:[10,25,50,100]}:null,Ce=nr;!i&&(H||oe||dt||se)&&an();let It=e=>ot(e.row,e.sourceIndex,i),Fe=M(()=>{let e=new Map(d.map(a=>[a.key,a])),t=Rt.flatMap(a=>{let o=e.get(a);return o?[o]:[]}),r=new Set(t.map(a=>a.key));for(let a of d)r.has(a.key)||(t.push(a),r.add(a.key));return t},[d,Rt]),O=M(()=>Fe.filter(e=>!ee.includes(e.key)),[Fe,ee]),ue=M(()=>{let e=k.map((t,r)=>({row:t,sourceIndex:r}));if(m==="server")return e;if(Me){let t=Me.toLowerCase();e=e.filter(({row:r})=>O.some(a=>{let o=W(r,a.key);return String(o??"").toLowerCase().includes(t)}))}if(X.length>0){let t=new Map(d.map(r=>[r.key,r.filterType]));e=e.filter(({row:r})=>X.every(a=>cn(W(r,a.column),a,t.get(a.column))))}if(L.length>0){let t=new Map(d.map(r=>[r.key,r]));e.sort((r,a)=>{for(let o of L){if(!o.direction)continue;let v=t.get(o.key),E=v?.sortComparator?v.sortComparator(r.row,a.row):sn(W(r.row,o.key),W(a.row,o.key),Ct);if(E!==0)return o.direction==="asc"?E:-E}return 0})}return e},[k,m,Me,X,L,O,d,Ct]),Ne=M(()=>ue.map(e=>e.row),[ue]),$e=Ee?(Array.isArray(Ee)?Ee:[Ee]).join("\0"):"",ge=M(()=>$e?$e.split("\0"):[],[$e]),pe=M(()=>{if(ge.length===0)return null;let e=new Map;for(let t of ue){let r=Vt(t.row,ge),a=e.get(r);a?a.push(t):e.set(r,[t])}return e},[ue,ge]),Xe=M(()=>pe?Array.from(pe.values()).flat():ue,[pe,ue]),_e=ve??Ne.length,te=Math.max(1,Math.ceil(_e/Ce)),B=m==="server"&&ve===void 0?Ft:Math.min(Math.max(1,Ft),te),Ot=ce!==null,K=M(()=>{if(!Ot||m==="server")return Xe;let e=(B-1)*Ce;return Xe.slice(e,e+Ce)},[Xe,Ot,B,Ce,m]),Je=M(()=>K.map(e=>e.row),[K]),me=M(()=>{let e=[],t=null;return K.forEach((r,a)=>{if(pe){let o=Vt(r.row,ge);if(o!==t&&(t=o,e.push({kind:"group",key:o,rows:pe.get(o)??[r]})),Ke.has(o))return}e.push({kind:"row",entry:r,index:a})}),e},[K,pe,ge,Ke]),Pt=br??(typeof ie=="number"?ie:ht),ye=me.length,hr=M(()=>{if(!F)return{start:0,end:ye};let e=Math.max(1,Math.ceil(Pt/$)),t=Math.min(Gt,Math.max(0,ye-e)),r=5;return{start:Math.max(0,t-r),end:Math.min(ye,t+e+r)}},[F,Gt,$,Pt,ye]);Oe(()=>{if(!F)return;let e=Ue.current;if(!e)return;let t=()=>{e.clientHeight>0&&Mt(e.clientHeight)};if(t(),typeof ResizeObserver>"u")return;let r=new ResizeObserver(t);return r.observe(e),()=>r.disconnect()},[F]);let Ye=w(e=>{u||Nt(e),f?.(e)},[u,f]),vr=w(e=>{let t=L.find(a=>a.key===e),r;if(!t||!t.direction?r="asc":t.direction==="asc"?r="desc":r=null,y){let a;r?t?a=L.map(o=>o.key===e?{key:e,direction:r}:o):a=[...L,{key:e,direction:r}]:a=L.filter(o=>o.key!==e),Ye(a)}else Ye(r?[{key:e,direction:r}]:[])},[L,y,Ye]),G=w(e=>{let t=Math.max(1,Math.min(e,te));I||rr(t),J?.(t)},[I,J,te]),xr=w(e=>{St(e),G(1),j?.(e)},[G,j]),wr=w(e=>{let t;Y==="single"?t=D.includes(e)?[]:[e]:t=D.includes(e)?D.filter(r=>r!==e):[...D,e],A||De(t),c?.(t)},[Y,D,A,c]),Qe=M(()=>new Set(D),[D]),Ze=w(()=>{let e=new Set(D),t=[...D];for(let r of K){let a=ot(r.row,r.sourceIndex,i);e.has(a)||(e.add(a),t.push(a))}A||De(t),c?.(t)},[K,i,D,A,c]),zt=w(()=>{A||De([]),c?.([])},[A,c]),kr=w(()=>{let e=new Set(K.map(r=>ot(r.row,r.sourceIndex,i))),t=D.filter(r=>!e.has(r));A||De(t),c?.(t)},[K,i,D,A,c]),et=H?K.map(It):[],tt=et.length>0&&et.every(e=>Qe.has(e)),Cr=!tt&&et.some(e=>Qe.has(e)),Nr=w(e=>{let t=ke.includes(e)?ke.filter(r=>r!==e):[...ke,e];Pe||cr(t),lt?.(t)},[ke,Pe,lt]),Sr=w(e=>{let t=e.target.value;xe||Tt(t),Re?.(t),G(1)},[xe,Re,G]),Tr=w(e=>{let t=[...X.filter(r=>r.column!==e.column),e];Q||We(t),ae?.(t),G(1)},[X,Q,ae,G]),Rr=w(e=>{let t=X.filter(r=>r.column!==e);Q||We(t),ae?.(t),G(1)},[X,Q,ae,G]),Er=w(e=>{let t=ee.includes(e)?ee.filter(r=>r!==e):[...ee,e];ze||gr(t),pt?.(t)},[ee,ze,pt]),Dr=w((e,t)=>{e.preventDefault(),e.stopPropagation(),qe.current=!0;let r=e.clientX,a=we[t]??e.currentTarget.parentElement?.getBoundingClientRect().width??100,o=d.find(C=>C.key===t),v=o?.minWidth??50,E=o?.maxWidth??1/0,re=C=>{let _=C.clientX-r,V=Math.min(E,Math.max(v,a+_));pr(be=>({...be,[t]:V}))},g=()=>{document.removeEventListener("mousemove",re),document.removeEventListener("mouseup",g),setTimeout(()=>{qe.current=!1},0)};document.addEventListener("mousemove",re),document.addEventListener("mouseup",g)},[we,d]),P=se&&!(m==="client"&&L.some(e=>e.direction)),Gr=w((e,t)=>{P&&Be({key:e,sourceIndex:t})},[P]),Mr=w(e=>{!P||Z===null||e.preventDefault()},[P,Z]),Fr=w((e,t)=>{!P||Z===null||(Be(null),Z.key!==e&&ct?.(Z.sourceIndex,t))},[P,Z,ct]),Ir=w(e=>{q&&Et(e)},[q]),Or=w(e=>{if(!q||!de||de===e)return;let t=Fe.map(o=>o.key),r=t.indexOf(de),a=t.indexOf(e);r===-1||a===-1||(t.splice(r,1),t.splice(a,0,de),mr(t),ut?.(de,e),Et(null))},[q,de,Fe,ut]),rt=w(e=>{let t=O.filter(C=>C.type!=="actions"&&C.type!=="selection"&&C.type!=="expand"),r=Ne,a,o,v;if(e==="csv")a=jr([t.map(C=>String(C.header)),...r.map(C=>t.map(_=>{let V=W(C,_.key);return typeof V=="number"?V:String(V??"")}))],{neutralizeFormulas:bt}),o="text/csv",v="csv";else{let C=r.map(_=>{let V={};for(let be of t)V[be.key]=W(_,be.key);return V});a=JSON.stringify(C,null,2),o="application/json",v="json"}let E=new Blob([a],{type:o}),re=URL.createObjectURL(E),g=document.createElement("a");g.href=re,g.download=`${ft}.${v}`,g.click(),URL.revokeObjectURL(re)},[O,Ne,ft,bt]);Oe(()=>{if(!Ge)return;let e=t=>{je.current&&!je.current.contains(t.target)&&Dt(!1)};return document.addEventListener("mousedown",e),()=>document.removeEventListener("mousedown",e)},[Ge]),Ur(l,()=>({getVisibleData:()=>Je,resetFilters:()=>{Q||We([]),xe||Tt(""),ae?.([]),Re?.(""),G(1)},resetSort:()=>{u||Nt([]),f?.([])},selectAll:Ze,deselectAll:zt,exportData:rt,scrollToRow:e=>{let t=Ue.current;if(!t||!F)return;let r=-1;for(let a=0;a<me.length;a++){let o=me[a];if(o.kind==="group")r=a;else if(o.index>=e){o.index===e&&(r=a);break}}r>=0&&(t.scrollTop=r*$)}}),[Je,Q,xe,u,ae,Re,f,G,Ze,zt,rt,F,$,me]);let nt=w(e=>{let t=e.key in we?we[e.key]:e.width;return t===void 0||t===""?null:typeof t=="number"?`${t}px`:t},[we]),Pr=M(()=>{let e=new Map;for(let t of["left","right"]){let r=t==="left"?O:[...O].reverse(),a=[],o=!1;for(let v of r){if(v.sticky!==t)continue;o&&on(),e.set(v.key,a.length===0?"0px":a.length===1?a[0]:`calc(${a.join(" + ")})`);let E=nt(v);E===null?o=!0:a.push(E)}}return e},[O,nt]),at=e=>{let t={},r=nt(e);return r&&(t.width=r,t.minWidth=r),e.sticky&&(t.position="sticky",t[e.sticky]=Pr.get(e.key)??0,t.zIndex=10),t},fe=O.length+(H?1:0)+(oe?1:0)+(se?1:0),zr=e=>{let t=N&&e.sortable!==!1&&e.type!=="actions",r=L.find(o=>o.key===e.key),a=e.filterable;return p("th",{className:x(z[S],Ie[S],"relative font-semibold text-gray-700 dark:text-gray-300 whitespace-nowrap",e.align==="center"&&"text-center",e.align==="right"&&"text-right",t&&"cursor-pointer select-none hover:bg-gray-100 dark:hover:bg-gray-700",Ae&&"border border-gray-200 dark:border-gray-700",e.sticky&&"bg-gray-50 dark:bg-gray-800",e.headerClassName,Zt),style:at(e),onClick:t?()=>{qe.current||vr(e.key)}:void 0,draggable:q,onDragStart:q?()=>Ir(e.key):void 0,onDragOver:q?o=>o.preventDefault():void 0,onDrop:q?()=>Or(e.key):void 0,"aria-sort":r?.direction==="asc"?"ascending":r?.direction==="desc"?"descending":void 0,children:[p("div",{className:"flex items-center gap-1",children:[e.renderHeader?e.renderHeader(e):e.header,t&&n("span",{className:"inline-flex ml-1",children:r?.direction==="asc"?n(Jr,{}):r?.direction==="desc"?n(Yr,{}):n(Qr,{})}),a&&n(mn,{column:e,value:X.find(o=>o.column===e.key),onApply:Tr,onClear:()=>Rr(e.key),labels:h})]}),e.resizable!==!1&&n("div",{className:"absolute top-0 right-0 w-1 h-full cursor-col-resize hover:bg-synertech-primary-500 opacity-0 hover:opacity-100",onMouseDown:o=>Dr(o,e.key)})]},e.key)},Se=F?_r[S]:z[S],At=F?{height:$}:void 0,Ar=(e,t)=>{let{row:r,sourceIndex:a}=e,o=It(e),v=Qe.has(o),E=ke.includes(o),re=typeof Le=="function"?Le(r,t):Le;return p(Br.Fragment,{children:[p("tr",{className:x("border-b border-gray-200 dark:border-gray-700 transition-colors",F&&"whitespace-nowrap",vt&&t%2===1&&"bg-gray-50/50 dark:bg-gray-800/50",v&&"bg-synertech-primary-50 dark:bg-synertech-primary-900/20",He&&"cursor-pointer hover:bg-gray-50 dark:hover:bg-gray-700/50",Z?.key===o&&"opacity-50",re),onClick:He?()=>He(r,t):void 0,onDoubleClick:wt?()=>wt(r,t):void 0,onContextMenu:kt?g=>kt(r,t,g):void 0,draggable:P,onDragStart:P?()=>Gr(o,a):void 0,onDragOver:P?Mr:void 0,onDrop:P?()=>Fr(o,a):void 0,onDragEnd:P?()=>Be(null):void 0,"data-row-key":o,"aria-selected":H?v:void 0,style:At,children:[se&&n("td",{className:x(Se,P?"cursor-grab active:cursor-grabbing":"cursor-not-allowed opacity-40"),children:n(en,{})}),H&&n("td",{className:x(Se,"w-10"),children:n("input",{type:"checkbox",checked:v,onChange:()=>wr(o),onClick:g=>g.stopPropagation(),className:"rounded border-gray-300 dark:border-gray-600 cursor-pointer","aria-label":U(h.dataGridSelectRow,{row:o})})}),oe&&n("td",{className:x(Se,"w-10"),children:n("button",{type:"button",onClick:g=>{g.stopPropagation(),Nr(o)},className:"p-0.5 rounded hover:bg-gray-200 dark:hover:bg-gray-600 cursor-pointer","aria-label":E?h.dataGridCollapseRow:h.dataGridExpandRow,"aria-expanded":E,children:n(Ht,{className:x("transition-transform",E&&"rotate-180")})})}),O.map(g=>{let C=W(r,g.key),_=g.colSpan?.(r,t);if(_===0)return null;let V=dt&&g.editable!==!1&&g.type!=="actions";return n("td",{className:x(Se,Ie[S],"text-gray-700 dark:text-gray-300",g.align==="center"&&"text-center",g.align==="right"&&"text-right",Ae&&"border border-gray-200 dark:border-gray-700",g.sticky&&(v?"bg-synertech-primary-50 dark:bg-gray-900 dark:bg-linear-to-r dark:from-synertech-primary-900/20 dark:to-synertech-primary-900/20":vt&&t%2===1?"bg-white bg-linear-to-r from-gray-50/50 to-gray-50/50 dark:bg-gray-900 dark:from-gray-800/50 dark:to-gray-800/50":"bg-white dark:bg-gray-900"),g.cellClassName,Qt),style:at(g),colSpan:_,children:V?n(yn,{value:C,display:g.render?g.render(C,r,t):String(C??""),onSave:be=>Bt?.(o,g.key,be),density:S,labels:h}):g.render?g.render(C,r,t):String(C??"")},g.key)})]}),oe&&E&&it&&n("tr",{className:"bg-gray-50 dark:bg-gray-800/70",children:n("td",{colSpan:fe,className:x(z[S]),children:it(r,t)})})]},o)},Hr=e=>{let{key:t,rows:r}=e,a=Ke.has(t);return n("tr",{className:x("bg-gray-100 dark:bg-gray-800 font-medium",F&&"whitespace-nowrap"),style:At,children:n("td",{colSpan:fe,className:x(Se,"cursor-pointer"),onClick:()=>{yr(o=>{let v=new Set(o);return v.has(t)?v.delete(t):v.add(t),v})},children:p("div",{className:"flex items-center gap-2",children:[n(Ht,{className:x("transition-transform",a&&"-rotate-90")}),mt?mt(t,W(r[0].row,ge[0]),r.map(o=>o.row)):`${t} (${r.length})`]})})},`group-${t}`)},Lr=()=>{if(jt)return Array.from({length:qt}).map((a,o)=>n(pn,{cols:fe,density:S},o));if(Je.length===0)return n("tr",{children:n("td",{colSpan:fe,className:x("text-center text-gray-500 dark:text-gray-400",z[S]),children:$t??h.dataGridNoData})});let e=a=>a.kind==="row"?Ar(a.entry,a.index):Hr(a);if(!F)return me.map(e);let{start:t,end:r}=hr;return p(bn,{children:[t>0&&n("tr",{"aria-hidden":"true",children:n("td",{colSpan:fe,style:{height:t*$,padding:0}})}),me.slice(t,r).map(e),r<ye&&n("tr",{"aria-hidden":"true",children:n("td",{colSpan:fe,style:{height:(ye-r)*$,padding:0}})})]})},Vr=(e,t)=>{let r=un(Ne,e.key,t);return e.renderAggregate?e.renderAggregate(r??0,Ne):r===null?"":gn(t,r.toLocaleString(Ve),h)},Wr=()=>!Jt||!O.some(t=>t.aggregate)?null:n("tfoot",{children:p("tr",{className:"bg-gray-50 dark:bg-gray-800 font-semibold border-t-2 border-gray-300 dark:border-gray-600",children:[se&&n("td",{className:z[S]}),H&&n("td",{className:z[S]}),oe&&n("td",{className:z[S]}),O.map(t=>n("td",{className:x(z[S],Ie[S],"text-gray-700 dark:text-gray-300",t.align==="center"&&"text-center",t.align==="right"&&"text-right",Ae&&"border border-gray-200 dark:border-gray-700"),style:at(t),children:t.aggregate?Vr(t,t.aggregate):""},t.key))]})});return p("div",{className:x("flex flex-col gap-3",Yt),children:[(ne||yt||gt)&&p("div",{className:"flex items-center justify-between gap-3 flex-wrap",children:[p("div",{className:"flex items-center gap-3 flex-1",children:[ne&&p("div",{className:"relative flex-1 max-w-xs",children:[n("div",{className:"absolute inset-y-0 left-0 flex items-center pl-3 pointer-events-none",children:n(Zr,{})}),n("input",{type:"text",value:Me,onChange:Sr,placeholder:Wt??h.dataGridSearchPlaceholder,className:"w-full pl-9 pr-3 py-1.5 text-sm border border-gray-300 dark:border-gray-600 rounded-md bg-white dark:bg-gray-800 text-gray-700 dark:text-gray-200 focus:outline-none focus:ring-2 focus:ring-synertech-primary-500 focus:border-synertech-primary-500","aria-label":h.dataGridSearch})]}),D.length>0&&n("span",{className:"text-sm text-gray-500 dark:text-gray-400",children:U(h.dataGridSelectedCount,{count:D.length})})]}),p("div",{className:"flex items-center gap-2",children:[gt&&p("div",{className:"relative",ref:je,children:[n("button",{type:"button",onClick:()=>Dt(!Ge),className:"p-1.5 rounded-md border border-gray-300 dark:border-gray-600 text-gray-600 dark:text-gray-400 hover:bg-gray-100 dark:hover:bg-gray-700 cursor-pointer","aria-label":h.dataGridToggleColumns,title:h.dataGridToggleColumns,children:n(nn,{})}),Ge&&n("div",{className:"absolute z-50 right-0 top-full mt-1 bg-white dark:bg-gray-800 border border-gray-200 dark:border-gray-700 rounded-lg shadow-lg p-2 min-w-[180px]",children:d.filter(e=>e.type!=="selection"&&e.type!=="expand").map(e=>p("label",{className:"flex items-center gap-2 px-2 py-1.5 text-sm rounded hover:bg-gray-100 dark:hover:bg-gray-700 cursor-pointer",children:[n("input",{type:"checkbox",checked:!ee.includes(e.key),onChange:()=>Er(e.key),className:"rounded border-gray-300 dark:border-gray-600 cursor-pointer"}),n("span",{className:"text-gray-700 dark:text-gray-300",children:String(e.header)})]},e.key))})]}),yt&&Kt.map(e=>p("button",{type:"button",onClick:()=>rt(e),className:"inline-flex items-center gap-1.5 px-2.5 py-1.5 text-xs font-medium rounded-md border border-gray-300 dark:border-gray-600 text-gray-600 dark:text-gray-400 hover:bg-gray-100 dark:hover:bg-gray-700 cursor-pointer",title:U(h.dataGridExportAs,{format:e.toUpperCase()}),children:[n(rn,{}),e.toUpperCase()]},e))]})]}),n("div",{ref:Ue,className:x("overflow-auto rounded-lg",!Ut&&"border border-gray-200 dark:border-gray-700",xt&&"relative"),style:ie?{maxHeight:typeof ie=="number"?`${ie}px`:ie}:F?{maxHeight:ht,overflow:"auto"}:void 0,onScroll:F?e=>{let t=e.currentTarget;fr(Math.floor(t.scrollTop/$)),t.clientHeight>0&&Mt(t.clientHeight)}:void 0,children:p("table",{className:"w-full text-left",children:[n("thead",{className:x("bg-gray-50 dark:bg-gray-800 text-xs uppercase",xt&&"sticky top-0 z-20"),children:p("tr",{children:[se&&n("th",{className:x(z[S],"w-10 font-semibold text-gray-700 dark:text-gray-300")}),H&&n("th",{className:x(z[S],"w-10"),children:Y==="multiple"&&n("input",{type:"checkbox",checked:tt,ref:e=>{e&&(e.indeterminate=Cr)},onChange:tt?kr:Ze,className:"rounded border-gray-300 dark:border-gray-600 cursor-pointer","aria-label":h.dataGridSelectAllRows})}),oe&&n("th",{className:x(z[S],"w-10 font-semibold text-gray-700 dark:text-gray-300")}),O.map(zr)]})}),n("tbody",{children:Lr()}),Wr()]})}),ce&&p("div",{className:"flex items-center justify-between flex-wrap gap-3 text-sm text-gray-600 dark:text-gray-400",children:[p("div",{className:"flex items-center gap-3",children:[ce.showTotalItems!==!1&&n("span",{children:U(_e===1?h.dataGridItemCount:h.dataGridItemsCount,{count:_e})}),ce.showPageSizeSelector!==!1&&ce.pageSizeOptions&&p("div",{className:"flex items-center gap-1.5",children:[n("span",{children:h.dataGridRowsPerPage}),n("select",{value:Ce,onChange:e=>xr(Number(e.target.value)),className:"border border-gray-300 dark:border-gray-600 rounded px-1.5 py-0.5 bg-white dark:bg-gray-800 text-gray-700 dark:text-gray-200 text-sm",children:ce.pageSizeOptions.map(e=>n("option",{value:e,children:e},e))})]})]}),p("div",{className:"flex items-center gap-1",children:[n("span",{className:"mr-2",children:U(h.dataGridPageOf,{page:B,total:te})}),n("button",{type:"button",onClick:()=>G(1),disabled:B<=1,className:"px-2 py-1 rounded border border-gray-300 dark:border-gray-600 disabled:opacity-50 disabled:cursor-not-allowed hover:bg-gray-100 dark:hover:bg-gray-700 cursor-pointer","aria-label":h.dataGridFirstPage,children:"\xAB\xAB"}),n("button",{type:"button",onClick:()=>G(B-1),disabled:B<=1,className:"px-2 py-1 rounded border border-gray-300 dark:border-gray-600 disabled:opacity-50 disabled:cursor-not-allowed hover:bg-gray-100 dark:hover:bg-gray-700 cursor-pointer","aria-label":h.dataGridPreviousPage,children:"\xAB"}),n("button",{type:"button",onClick:()=>G(B+1),disabled:B>=te,className:"px-2 py-1 rounded border border-gray-300 dark:border-gray-600 disabled:opacity-50 disabled:cursor-not-allowed hover:bg-gray-100 dark:hover:bg-gray-700 cursor-pointer","aria-label":h.dataGridNextPage,children:"\xBB"}),n("button",{type:"button",onClick:()=>G(te),disabled:B>=te,className:"px-2 py-1 rounded border border-gray-300 dark:border-gray-600 disabled:opacity-50 disabled:cursor-not-allowed hover:bg-gray-100 dark:hover:bg-gray-700 cursor-pointer","aria-label":h.dataGridLastPage,children:"\xBB\xBB"})]})]})]})}var Sn=Kr(fn);export{Sn as DataGrid,Nn as resetRowKeyWarning};
@@ -1 +1 @@
1
- "use strict";"use client";var k=Object.defineProperty;var Y=Object.getOwnPropertyDescriptor;var J=Object.getOwnPropertyNames;var K=Object.prototype.hasOwnProperty;var Q=(o,e)=>{for(var r in e)k(o,r,{get:e[r],enumerable:!0})},Z=(o,e,r,u)=>{if(e&&typeof e=="object"||typeof e=="function")for(let l of J(e))!K.call(o,l)&&l!==r&&k(o,l,{get:()=>e[l],enumerable:!(u=Y(e,l))||u.enumerable});return o};var ee=o=>Z(k({},"__esModule",{value:!0}),o);var ce={};Q(ce,{Detachable:()=>z});module.exports=ee(ce);var n=require("react"),_=require("../../lib/cn.cjs"),q=require("../../lib/layer-document.cjs"),j=require("./useMovableContent.cjs"),p=require("react/jsx-runtime"),ne=500,te=800,re=600;function oe(o,e,r){let u=[`width=${o}`,`height=${e}`,"menubar=no","toolbar=no","location=no","status=no","scrollbars=yes","resizable=yes"];if(r.left!==void 0)u.push(`left=${r.left}`);else if(r.center!==!1&&typeof window<"u"){let l=window.screenLeft??window.screenX,c=window.screenTop??window.screenY,t=window.outerWidth??screen.availWidth,i=window.outerHeight??screen.availHeight;u.push(`left=${l+(t-o)/2}`),u.push(`top=${c+(i-e)/2}`)}if(r.top!==void 0){let l=u.filter(c=>!c.startsWith("top="));return l.push(`top=${r.top}`),l.join(",")}return u.join(",")}function le(o,e){o.querySelectorAll("style").forEach(t=>{let i=e.createElement("style");i.textContent=t.textContent,e.head.appendChild(i)}),o.querySelectorAll('link[rel="stylesheet"]').forEach(t=>{let i=e.createElement("link");i.rel="stylesheet",i.href=t.href,t.crossOrigin&&(i.crossOrigin=t.crossOrigin),e.head.appendChild(i)});let l=o.documentElement.className;l&&(e.documentElement.className=l);let c=o.body.className;c&&(e.body.className=c)}function se(o,e){let r=new MutationObserver(u=>{for(let l of u)for(let c of Array.from(l.addedNodes))if(c instanceof HTMLStyleElement){let t=e.createElement("style");t.textContent=c.textContent,e.head.appendChild(t)}else if(c instanceof HTMLLinkElement&&c.rel==="stylesheet"){let t=e.createElement("link");t.rel="stylesheet",t.href=c.href,e.head.appendChild(t)}});return r.observe(o.head,{childList:!0}),r}var z=(0,n.forwardRef)(function({children:e,detached:r,defaultDetached:u=!1,onClose:l,onDetach:c,title:t="",width:i=te,height:H=re,left:I,top:M,center:O=!0,copyStyles:P=!0,closeOnParentUnmount:W=!0,className:G,windowClassName:S,onPopupBlocked:x},V){let f=r!==void 0,[E,b]=(0,n.useState)(u),A=f?r:E,[C,$]=(0,n.useState)(null),a=(0,n.useRef)(null),w=(0,n.useRef)(null),y=(0,n.useRef)(null),v=(0,n.useRef)(!1),R=(0,n.useRef)(null),g=(0,n.useRef)({width:i,height:H,left:I,top:M,center:O,shouldCopyStyles:P,title:t,windowClassName:S,closeOnParentUnmount:W});g.current={width:i,height:H,left:I,top:M,center:O,shouldCopyStyles:P,title:t,windowClassName:S,closeOnParentUnmount:W};let L=(0,n.useRef)({onClose:l,onDetach:c,onPopupBlocked:x});L.current={onClose:l,onDetach:c,onPopupBlocked:x};let h=(0,j.useMovableContent)(C),T=(0,n.useRef)(h.bringBack);T.current=h.bringBack;let m=(0,n.useCallback)(()=>{R.current?.(),R.current=null,w.current&&(clearInterval(w.current),w.current=null),y.current&&(y.current.disconnect(),y.current=null),$(null)},[]),B=(0,n.useCallback)(()=>{T.current();let s=a.current;a.current=null,m(),s&&!s.closed&&s.close()},[m]),F=(0,n.useCallback)(()=>{if(typeof window>"u"||v.current||a.current&&!a.current.closed)return;v.current=!0;let s=g.current,X=oe(s.width,s.height,{center:s.center,left:s.left,top:s.top}),d=window.open("","",X);if(!d){v.current=!1,f||b(!1),L.current.onPopupBlocked?.();return}a.current=d,d.document.title=s.title||document.title;let D=d.document.createElement("div");s.windowClassName&&(D.className=s.windowClassName),d.document.body.appendChild(D),$(D),s.shouldCopyStyles&&(le(document,d.document),y.current=se(document,d.document));let U=!1,N=()=>{U||(U=!0,T.current(),m(),a.current=null,f||b(!1),L.current.onClose?.())};d.addEventListener("pagehide",N),R.current=()=>d.removeEventListener("pagehide",N),w.current=setInterval(()=>{d.closed&&N()},ne),v.current=!1,L.current.onDetach?.()},[f,m]);return(0,n.useEffect)(()=>{A?F():B()},[A,F,B]),(0,n.useEffect)(()=>{a.current&&!a.current.closed&&t&&(a.current.document.title=t)},[t]),(0,n.useEffect)(()=>()=>{let s=a.current;m(),a.current=null,g.current.closeOnParentUnmount&&s&&!s.closed&&s.close()},[m]),(0,n.useImperativeHandle)(V,()=>({detach:()=>{f||b(!0)},attach:()=>{f||b(!1)},get isDetached(){return f?!!r:E},get window(){return a.current}}),[f,r,E]),(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)("div",{ref:h.hostRef,className:(0,_.cn)(G),hidden:C!==null,children:h.inline(e)}),h.portal((0,p.jsx)(q.LayerDocumentProvider,{document:C?.ownerDocument??null,children:e}))]})});z.displayName="Detachable";0&&(module.exports={Detachable});
1
+ "use strict";"use client";var k=Object.defineProperty;var Q=Object.getOwnPropertyDescriptor;var Z=Object.getOwnPropertyNames;var ee=Object.prototype.hasOwnProperty;var ne=(c,t)=>{for(var r in t)k(c,r,{get:t[r],enumerable:!0})},te=(c,t,r,u)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of Z(t))!ee.call(c,o)&&o!==r&&k(c,o,{get:()=>t[o],enumerable:!(u=Q(t,o))||u.enumerable});return c};var re=c=>te(k({},"__esModule",{value:!0}),c);var se={};ne(se,{Detachable:()=>q});module.exports=re(se);var e=require("react"),V=require("../../lib/cn.cjs"),X=require("../../lib/layer-document.cjs"),Y=require("./useMovableContent.cjs"),s=require("./popup-window.cjs"),d=require("react/jsx-runtime"),oe=500,ce=800,ue=600;function le(c,t,r){let u=[`width=${c}`,`height=${t}`,"menubar=no","toolbar=no","location=no","status=no","scrollbars=yes","resizable=yes"];if(r.left!==void 0)u.push(`left=${r.left}`);else if(r.center!==!1&&typeof window<"u"){let o=window.screenLeft??window.screenX,m=window.screenTop??window.screenY,f=window.outerWidth??screen.availWidth,w=window.outerHeight??screen.availHeight;u.push(`left=${o+(f-c)/2}`),u.push(`top=${m+(w-t)/2}`)}if(r.top!==void 0){let o=u.filter(m=>!m.startsWith("top="));return o.push(`top=${r.top}`),o.join(",")}return u.join(",")}var q=(0,e.forwardRef)(function({children:t,detached:r,defaultDetached:u=!1,onClose:o,onDetach:m,title:f="",width:w=ce,height:$=ue,left:B,top:O,center:A=!0,copyStyles:F=!0,closeOnParentUnmount:M=!0,className:J,windowClassName:S,onPopupBlocked:U},K){let i=r!==void 0,[I,v]=(0,e.useState)(u),_=i?r:I,[P,x]=(0,e.useState)(null),l=(0,e.useRef)(null),D=(0,e.useRef)(null),g=(0,e.useRef)(null),C=(0,e.useRef)(null),R=(0,e.useRef)(!1),T=(0,e.useRef)(null),E=(0,e.useRef)({width:w,height:$,left:B,top:O,center:A,shouldCopyStyles:F,title:f,windowClassName:S,closeOnParentUnmount:M});E.current={width:w,height:$,left:B,top:O,center:A,shouldCopyStyles:F,title:f,windowClassName:S,closeOnParentUnmount:M};let y=(0,e.useRef)({onClose:o,onDetach:m,onPopupBlocked:U});y.current={onClose:o,onDetach:m,onPopupBlocked:U};let b=(0,Y.useMovableContent)(P),N=(0,e.useRef)(b.bringBack);N.current=b.bringBack;let h=(0,e.useCallback)(()=>{T.current?.(),T.current=null,g.current&&(clearInterval(g.current),g.current=null),C.current?.(),C.current=null,x(null)},[]),j=(0,e.useCallback)(()=>{N.current();let n=l.current;l.current=null,D.current=null,h(),n&&!n.closed&&n.close()},[h]),z=(0,e.useCallback)(()=>{if(typeof window>"u"||R.current||l.current&&!l.current.closed)return;R.current=!0;let n=E.current,L=le(n.width,n.height,{center:n.center,left:n.left,top:n.top}),a=window.open("","",L),p=a?(0,s.popupDocument)(a):null;if(!a||!p){R.current=!1,i||v(!1),y.current.onPopupBlocked?.();return}(0,s.severOpener)(a),l.current=a,D.current=p,p.title=n.title||document.title;let H=p.createElement("div");n.windowClassName&&(H.className=n.windowClassName),p.body.appendChild(H),x(H),n.shouldCopyStyles&&(C.current=(0,s.mirrorDocument)(document,p));let G=!1,W=()=>{G||(G=!0,N.current(),h(),l.current=null,D.current=null,i||v(!1),y.current.onClose?.())};a.addEventListener("pagehide",W),T.current=()=>a.removeEventListener("pagehide",W),g.current=setInterval(()=>{(0,s.popupDocument)(a,p)||W()},oe),R.current=!1,y.current.onDetach?.()},[i,h]);return(0,e.useEffect)(()=>{_?z():j()},[_,z,j]),(0,e.useEffect)(()=>{let n=l.current,L=D.current;n&&L&&f&&(0,s.setPopupTitle)(n,L,f)},[f]),(0,e.useEffect)(()=>()=>{let n=l.current;h(),l.current=null,E.current.closeOnParentUnmount&&n&&!n.closed&&n.close()},[h]),(0,e.useImperativeHandle)(K,()=>({detach:()=>{i||v(!0)},attach:()=>{i||v(!1)},get isDetached(){return i?!!r:I},get window(){return l.current}}),[i,r,I]),(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)("div",{ref:b.hostRef,className:(0,V.cn)(J),hidden:P!==null,children:b.inline(t)}),b.portal((0,d.jsx)(X.LayerDocumentProvider,{document:P?.ownerDocument??null,children:t}))]})});q.displayName="Detachable";0&&(module.exports={Detachable});
@@ -1 +1 @@
1
- "use client";import{useState as _,useRef as f,useEffect as N,useCallback as k,useImperativeHandle as V,forwardRef as X}from"react";import{cn as Y}from"../../lib/cn.js";import{LayerDocumentProvider as J}from"../../lib/layer-document.js";import{useMovableContent as K}from"./useMovableContent.js";import{Fragment as le,jsx as q,jsxs as se}from"react/jsx-runtime";var Q=500,Z=800,ee=600;function ne(u,n,o){let i=[`width=${u}`,`height=${n}`,"menubar=no","toolbar=no","location=no","status=no","scrollbars=yes","resizable=yes"];if(o.left!==void 0)i.push(`left=${o.left}`);else if(o.center!==!1&&typeof window<"u"){let l=window.screenLeft??window.screenX,r=window.screenTop??window.screenY,e=window.outerWidth??screen.availWidth,s=window.outerHeight??screen.availHeight;i.push(`left=${l+(e-u)/2}`),i.push(`top=${r+(s-n)/2}`)}if(o.top!==void 0){let l=i.filter(r=>!r.startsWith("top="));return l.push(`top=${o.top}`),l.join(",")}return i.join(",")}function te(u,n){u.querySelectorAll("style").forEach(e=>{let s=n.createElement("style");s.textContent=e.textContent,n.head.appendChild(s)}),u.querySelectorAll('link[rel="stylesheet"]').forEach(e=>{let s=n.createElement("link");s.rel="stylesheet",s.href=e.href,e.crossOrigin&&(s.crossOrigin=e.crossOrigin),n.head.appendChild(s)});let l=u.documentElement.className;l&&(n.documentElement.className=l);let r=u.body.className;r&&(n.body.className=r)}function re(u,n){let o=new MutationObserver(i=>{for(let l of i)for(let r of Array.from(l.addedNodes))if(r instanceof HTMLStyleElement){let e=n.createElement("style");e.textContent=r.textContent,n.head.appendChild(e)}else if(r instanceof HTMLLinkElement&&r.rel==="stylesheet"){let e=n.createElement("link");e.rel="stylesheet",e.href=r.href,n.head.appendChild(e)}});return o.observe(u.head,{childList:!0}),o}var oe=X(function({children:n,detached:o,defaultDetached:i=!1,onClose:l,onDetach:r,title:e="",width:s=Z,height:H=ee,left:I,top:M,center:O=!0,copyStyles:P=!0,closeOnParentUnmount:W=!0,className:j,windowClassName:S,onPopupBlocked:x},z){let d=o!==void 0,[L,h]=_(i),A=d?o:L,[E,$]=_(null),c=f(null),b=f(null),w=f(null),y=f(!1),C=f(null),R=f({width:s,height:H,left:I,top:M,center:O,shouldCopyStyles:P,title:e,windowClassName:S,closeOnParentUnmount:W});R.current={width:s,height:H,left:I,top:M,center:O,shouldCopyStyles:P,title:e,windowClassName:S,closeOnParentUnmount:W};let v=f({onClose:l,onDetach:r,onPopupBlocked:x});v.current={onClose:l,onDetach:r,onPopupBlocked:x};let m=K(E),g=f(m.bringBack);g.current=m.bringBack;let p=k(()=>{C.current?.(),C.current=null,b.current&&(clearInterval(b.current),b.current=null),w.current&&(w.current.disconnect(),w.current=null),$(null)},[]),B=k(()=>{g.current();let t=c.current;c.current=null,p(),t&&!t.closed&&t.close()},[p]),F=k(()=>{if(typeof window>"u"||y.current||c.current&&!c.current.closed)return;y.current=!0;let t=R.current,G=ne(t.width,t.height,{center:t.center,left:t.left,top:t.top}),a=window.open("","",G);if(!a){y.current=!1,d||h(!1),v.current.onPopupBlocked?.();return}c.current=a,a.document.title=t.title||document.title;let T=a.document.createElement("div");t.windowClassName&&(T.className=t.windowClassName),a.document.body.appendChild(T),$(T),t.shouldCopyStyles&&(te(document,a.document),w.current=re(document,a.document));let U=!1,D=()=>{U||(U=!0,g.current(),p(),c.current=null,d||h(!1),v.current.onClose?.())};a.addEventListener("pagehide",D),C.current=()=>a.removeEventListener("pagehide",D),b.current=setInterval(()=>{a.closed&&D()},Q),y.current=!1,v.current.onDetach?.()},[d,p]);return N(()=>{A?F():B()},[A,F,B]),N(()=>{c.current&&!c.current.closed&&e&&(c.current.document.title=e)},[e]),N(()=>()=>{let t=c.current;p(),c.current=null,R.current.closeOnParentUnmount&&t&&!t.closed&&t.close()},[p]),V(z,()=>({detach:()=>{d||h(!0)},attach:()=>{d||h(!1)},get isDetached(){return d?!!o:L},get window(){return c.current}}),[d,o,L]),se(le,{children:[q("div",{ref:m.hostRef,className:Y(j),hidden:E!==null,children:m.inline(n)}),m.portal(q(J,{document:E?.ownerDocument??null,children:n}))]})});oe.displayName="Detachable";export{oe as Detachable};
1
+ "use client";import{useState as G,useRef as r,useEffect as H,useCallback as W,useImperativeHandle as J,forwardRef as K}from"react";import{cn as Q}from"../../lib/cn.js";import{LayerDocumentProvider as Z}from"../../lib/layer-document.js";import{useMovableContent as ee}from"./useMovableContent.js";import{mirrorDocument as ne,popupDocument as V,setPopupTitle as te,severOpener as re}from"./popup-window.js";import{Fragment as ie,jsx as X,jsxs as ae}from"react/jsx-runtime";var oe=500,ce=800,ue=600;function le(R,p,n){let u=[`width=${R}`,`height=${p}`,"menubar=no","toolbar=no","location=no","status=no","scrollbars=yes","resizable=yes"];if(n.left!==void 0)u.push(`left=${n.left}`);else if(n.center!==!1&&typeof window<"u"){let l=window.screenLeft??window.screenX,a=window.screenTop??window.screenY,s=window.outerWidth??screen.availWidth,m=window.outerHeight??screen.availHeight;u.push(`left=${l+(s-R)/2}`),u.push(`top=${a+(m-p)/2}`)}if(n.top!==void 0){let l=u.filter(a=>!a.startsWith("top="));return l.push(`top=${n.top}`),l.join(",")}return u.join(",")}var se=K(function({children:p,detached:n,defaultDetached:u=!1,onClose:l,onDetach:a,title:s="",width:m=ce,height:k=ue,left:$,top:B,center:O=!0,copyStyles:A=!0,closeOnParentUnmount:F=!0,className:Y,windowClassName:M,onPopupBlocked:S},q){let o=n!==void 0,[y,h]=G(u),U=o?n:y,[L,_]=G(null),t=r(null),b=r(null),w=r(null),I=r(null),v=r(!1),P=r(null),C=r({width:m,height:k,left:$,top:B,center:O,shouldCopyStyles:A,title:s,windowClassName:M,closeOnParentUnmount:F});C.current={width:m,height:k,left:$,top:B,center:O,shouldCopyStyles:A,title:s,windowClassName:M,closeOnParentUnmount:F};let D=r({onClose:l,onDetach:a,onPopupBlocked:S});D.current={onClose:l,onDetach:a,onPopupBlocked:S};let d=ee(L),T=r(d.bringBack);T.current=d.bringBack;let f=W(()=>{P.current?.(),P.current=null,w.current&&(clearInterval(w.current),w.current=null),I.current?.(),I.current=null,_(null)},[]),x=W(()=>{T.current();let e=t.current;t.current=null,b.current=null,f(),e&&!e.closed&&e.close()},[f]),j=W(()=>{if(typeof window>"u"||v.current||t.current&&!t.current.closed)return;v.current=!0;let e=C.current,g=le(e.width,e.height,{center:e.center,left:e.left,top:e.top}),c=window.open("","",g),i=c?V(c):null;if(!c||!i){v.current=!1,o||h(!1),D.current.onPopupBlocked?.();return}re(c),t.current=c,b.current=i,i.title=e.title||document.title;let E=i.createElement("div");e.windowClassName&&(E.className=e.windowClassName),i.body.appendChild(E),_(E),e.shouldCopyStyles&&(I.current=ne(document,i));let z=!1,N=()=>{z||(z=!0,T.current(),f(),t.current=null,b.current=null,o||h(!1),D.current.onClose?.())};c.addEventListener("pagehide",N),P.current=()=>c.removeEventListener("pagehide",N),w.current=setInterval(()=>{V(c,i)||N()},oe),v.current=!1,D.current.onDetach?.()},[o,f]);return H(()=>{U?j():x()},[U,j,x]),H(()=>{let e=t.current,g=b.current;e&&g&&s&&te(e,g,s)},[s]),H(()=>()=>{let e=t.current;f(),t.current=null,C.current.closeOnParentUnmount&&e&&!e.closed&&e.close()},[f]),J(q,()=>({detach:()=>{o||h(!0)},attach:()=>{o||h(!1)},get isDetached(){return o?!!n:y},get window(){return t.current}}),[o,n,y]),ae(ie,{children:[X("div",{ref:d.hostRef,className:Q(Y),hidden:L!==null,children:d.inline(p)}),d.portal(X(Z,{document:L?.ownerDocument??null,children:p}))]})});se.displayName="Detachable";export{se as Detachable};
@@ -0,0 +1 @@
1
+ "use strict";var a=Object.defineProperty;var T=Object.getOwnPropertyDescriptor;var y=Object.getOwnPropertyNames;var v=Object.prototype.hasOwnProperty;var N=(e,t)=>{for(var i in t)a(e,i,{get:t[i],enumerable:!0})},p=(e,t,i,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of y(t))!v.call(e,o)&&o!==i&&a(e,o,{get:()=>t[o],enumerable:!(n=T(t,o))||n.enumerable});return e};var M=e=>p(a({},"__esModule",{value:!0}),e);var w={};N(w,{mirrorDocument:()=>g,popupDocument:()=>L,setPopupTitle:()=>H,severOpener:()=>S});module.exports=M(w);function S(e){try{e.opener=null}catch{}}function L(e,t){if(e.closed)return null;try{let i=e.document;return t===void 0||i===t?i:null}catch{return null}}function H(e,t,i){let n=L(e,t);n&&(n.title=i)}var f=["class","data-theme","dir","lang","style"],h=["class","data-theme","dir"],b=e=>e.nodeName==="STYLE"||e.nodeName==="LINK"&&(e.getAttribute("rel")??"").toLowerCase().split(/\s+/).includes("stylesheet");function E(e,t,i,n){for(let o of i){let s=e.getAttribute(o);o==="class"&&n&&(s=s?`${s} ${n}`:n),s===null?t.removeAttribute(o):t.getAttribute(o)!==s&&t.setAttribute(o,s)}}function g(e,t,{bodyClassName:i}={}){let n=new Map,o=r=>{if(n.has(r))return;let c=t.importNode(r,!0);r.nodeName==="LINK"&&(c.href=r.href),r.nonce&&(c.nonce=r.nonce),n.set(r,c);let l=r.nextSibling;for(;l&&!n.has(l);)l=l.nextSibling;let m=l?n.get(l):null;t.head.insertBefore(c,m&&m.parentNode===t.head?m:null)};e.head.childNodes.forEach(r=>{b(r)&&o(r)});let s=()=>{E(e.documentElement,t.documentElement,f),E(e.body,t.body,h,i)};s();let d=new MutationObserver(r=>{for(let c of r)c.addedNodes.forEach(l=>{b(l)&&o(l)}),c.removedNodes.forEach(l=>{n.get(l)?.remove(),n.delete(l)})});d.observe(e.head,{childList:!0});let u=new MutationObserver(s);return u.observe(e.documentElement,{attributes:!0,attributeFilter:f}),u.observe(e.body,{attributes:!0,attributeFilter:h}),()=>{d.disconnect(),u.disconnect()}}0&&(module.exports={mirrorDocument,popupDocument,setPopupTitle,severOpener});
@@ -0,0 +1 @@
1
+ function L(e){try{e.opener=null}catch{}}function E(e,t){if(e.closed)return null;try{let l=e.document;return t===void 0||l===t?l:null}catch{return null}}function T(e,t,l){let n=E(e,t);n&&(n.title=l)}var d=["class","data-theme","dir","lang","style"],f=["class","data-theme","dir"],h=e=>e.nodeName==="STYLE"||e.nodeName==="LINK"&&(e.getAttribute("rel")??"").toLowerCase().split(/\s+/).includes("stylesheet");function b(e,t,l,n){for(let s of l){let r=e.getAttribute(s);s==="class"&&n&&(r=r?`${r} ${n}`:n),r===null?t.removeAttribute(s):t.getAttribute(s)!==r&&t.setAttribute(s,r)}}function y(e,t,{bodyClassName:l}={}){let n=new Map,s=o=>{if(n.has(o))return;let c=t.importNode(o,!0);o.nodeName==="LINK"&&(c.href=o.href),o.nonce&&(c.nonce=o.nonce),n.set(o,c);let i=o.nextSibling;for(;i&&!n.has(i);)i=i.nextSibling;let m=i?n.get(i):null;t.head.insertBefore(c,m&&m.parentNode===t.head?m:null)};e.head.childNodes.forEach(o=>{h(o)&&s(o)});let r=()=>{b(e.documentElement,t.documentElement,d),b(e.body,t.body,f,l)};r();let a=new MutationObserver(o=>{for(let c of o)c.addedNodes.forEach(i=>{h(i)&&s(i)}),c.removedNodes.forEach(i=>{n.get(i)?.remove(),n.delete(i)})});a.observe(e.head,{childList:!0});let u=new MutationObserver(r);return u.observe(e.documentElement,{attributes:!0,attributeFilter:d}),u.observe(e.body,{attributes:!0,attributeFilter:f}),()=>{a.disconnect(),u.disconnect()}}export{y as mirrorDocument,E as popupDocument,T as setPopupTitle,L as severOpener};
@@ -1 +1 @@
1
- "use strict";"use client";var R=Object.defineProperty;var A=Object.getOwnPropertyDescriptor;var P=Object.getOwnPropertyNames;var L=Object.prototype.hasOwnProperty;var I=(t,a)=>{for(var r in a)R(t,r,{get:a[r],enumerable:!0})},V=(t,a,r,i)=>{if(a&&typeof a=="object"||typeof a=="function")for(let d of P(a))!L.call(t,d)&&d!==r&&R(t,d,{get:()=>a[d],enumerable:!(i=A(a,d))||i.enumerable});return t};var X=t=>V(R({},"__esModule",{value:!0}),t);var ee={};I(ee,{DeviceMockup:()=>$});module.exports=X(ee);var p=require("react"),o=require("../../lib/cn.cjs"),B=require("../../lib/i18n.cjs"),e=require("react/jsx-runtime"),j={phone:{sm:{w:180,h:320},md:{w:240,h:480},lg:{w:300,h:600}},android:{sm:{w:180,h:320},md:{w:240,h:480},lg:{w:300,h:600}},tablet:{sm:{w:320,h:420},md:{w:420,h:560},lg:{w:540,h:720}},laptop:{sm:{w:400,h:250},md:{w:560,h:350},lg:{w:720,h:450}},desktop:{sm:{w:400,h:300},md:{w:560,h:400},lg:{w:720,h:520}},watch:{sm:{w:80,h:96},md:{w:120,h:144},lg:{w:160,h:192}},browser:{sm:{w:400,h:280},md:{w:560,h:380},lg:{w:720,h:480}}},q=({className:t})=>(0,e.jsxs)("svg",{className:(0,o.cn)("w-3 h-3",t),viewBox:"0 0 16 16",fill:"currentColor",children:[(0,e.jsx)("rect",{x:"1",y:"11",width:"2.5",height:"4",rx:"0.5"}),(0,e.jsx)("rect",{x:"5",y:"8",width:"2.5",height:"7",rx:"0.5"}),(0,e.jsx)("rect",{x:"9",y:"5",width:"2.5",height:"10",rx:"0.5"}),(0,e.jsx)("rect",{x:"13",y:"1",width:"2.5",height:"14",rx:"0.5"})]}),E=({className:t})=>(0,e.jsxs)("svg",{className:(0,o.cn)("w-3 h-3",t),viewBox:"0 0 20 20",fill:"currentColor",children:[(0,e.jsx)("path",{d:"M10 14.5a1.5 1.5 0 100 3 1.5 1.5 0 000-3z"}),(0,e.jsx)("path",{fillRule:"evenodd",d:"M6.05 11.95a5.5 5.5 0 017.9 0 .75.75 0 001.08-1.04 7 7 0 00-10.06 0 .75.75 0 001.08 1.04z",clipRule:"evenodd"}),(0,e.jsx)("path",{fillRule:"evenodd",d:"M2.81 8.72a10 10 0 0114.38 0 .75.75 0 001.06-1.06 11.5 11.5 0 00-16.5 0 .75.75 0 001.06 1.06z",clipRule:"evenodd"})]}),O=({className:t})=>(0,e.jsxs)("svg",{className:(0,o.cn)("w-4 h-3",t),viewBox:"0 0 24 14",fill:"currentColor",children:[(0,e.jsx)("rect",{x:"0.5",y:"0.5",width:"20",height:"13",rx:"2",stroke:"currentColor",fill:"none",strokeWidth:"1"}),(0,e.jsx)("rect",{x:"22",y:"4",width:"2",height:"6",rx:"0.5"}),(0,e.jsx)("rect",{x:"2.5",y:"2.5",width:"14",height:"9",rx:"1"})]});function f({time:t="9:41",theme:a,device:r}){let i=r==="watch",d=a==="dark"?"text-white":"text-gray-900";return i?(0,e.jsx)("div",{className:(0,o.cn)("flex items-center justify-center py-0.5",d),style:{fontSize:"8px"},children:(0,e.jsx)("span",{className:"font-medium",children:t})}):(0,e.jsxs)("div",{className:(0,o.cn)("flex items-center justify-between px-4 py-1",a==="dark"?"bg-black/20":"bg-white/20",d),style:{fontSize:"10px"},"data-testid":"status-bar",children:[(0,e.jsx)("span",{className:"font-semibold",children:t}),(0,e.jsxs)("div",{className:"flex items-center gap-1",children:[(0,e.jsx)(q,{className:d}),(0,e.jsx)(E,{className:d}),(0,e.jsx)(O,{className:d})]})]})}function U({theme:t}){let a=t==="dark";return(0,e.jsxs)("div",{className:(0,o.cn)("flex items-center gap-2 px-3 py-2 border-b",a?"bg-gray-800 border-gray-700":"bg-gray-100 border-gray-200"),"data-testid":"browser-chrome",children:[(0,e.jsxs)("div",{className:"flex items-center gap-1.5",children:[(0,e.jsx)("div",{className:"w-2.5 h-2.5 rounded-full bg-red-400"}),(0,e.jsx)("div",{className:"w-2.5 h-2.5 rounded-full bg-yellow-400"}),(0,e.jsx)("div",{className:"w-2.5 h-2.5 rounded-full bg-green-400"})]}),(0,e.jsx)("div",{className:(0,o.cn)("flex-1 rounded-md px-3 py-1 text-center",a?"bg-gray-700 text-gray-300":"bg-white text-gray-500 border border-gray-200"),style:{fontSize:"11px"},children:(0,e.jsxs)("span",{className:"flex items-center justify-center gap-1",children:[(0,e.jsx)("svg",{className:"w-2.5 h-2.5",viewBox:"0 0 16 16",fill:"currentColor",children:(0,e.jsx)("path",{fillRule:"evenodd",d:"M8 1a4 4 0 00-4 4v3.5H3a1 1 0 00-1 1V14a1 1 0 001 1h10a1 1 0 001-1V9.5a1 1 0 00-1-1h-1V5a4 4 0 00-4-4zm2.5 7.5V5a2.5 2.5 0 00-5 0v3.5h5z",clipRule:"evenodd"})}),"example.com"]})})]})}function Y({children:t,theme:a,screenW:r,screenH:i,showStatusBar:d,statusBarTime:s,frameColor:l,landscape:n=!1}){let h=a==="dark",c=l??(h?"#1a1a1a":"#e5e7eb");if(n){let m=Math.round(i*.35);return(0,e.jsxs)("div",{className:"relative inline-flex flex-row items-center rounded-[2.5rem] shadow-xl",style:{backgroundColor:c,padding:"8px 12px",height:i+16},"data-testid":"device-frame","data-device":"phone",children:[(0,e.jsx)("div",{className:(0,o.cn)("rounded-full mr-2",h?"bg-gray-600":"bg-gray-400"),style:{width:4,height:Math.round(i*.35)},"data-testid":"home-indicator"}),(0,e.jsxs)("div",{className:"rounded-[2rem] overflow-hidden bg-black relative",style:{width:r,height:i},children:[d&&(0,e.jsx)(f,{time:s,theme:a,device:"phone"}),t]}),(0,e.jsx)("div",{className:"absolute rounded-full bg-black z-10",style:{width:20,height:m,right:10,top:"50%",transform:"translateY(-50%)"},"data-testid":"phone-notch"})]})}let w=Math.round(r*.35);return(0,e.jsxs)("div",{className:"relative inline-flex flex-col items-center rounded-[2.5rem] shadow-xl",style:{backgroundColor:c,padding:"12px 8px",width:r+16},"data-testid":"device-frame","data-device":"phone",children:[(0,e.jsx)("div",{className:"absolute top-[10px] rounded-full bg-black z-10",style:{width:w,height:20,left:"50%",transform:"translateX(-50%)"},"data-testid":"phone-notch"}),(0,e.jsxs)("div",{className:"rounded-[2rem] overflow-hidden bg-black relative",style:{width:r,height:i},children:[d&&(0,e.jsx)(f,{time:s,theme:a,device:"phone"}),t]}),(0,e.jsx)("div",{className:(0,o.cn)("rounded-full mt-2",h?"bg-gray-600":"bg-gray-400"),style:{width:Math.round(r*.35),height:4},"data-testid":"home-indicator"})]})}function G({children:t,theme:a,screenW:r,screenH:i,showStatusBar:d,statusBarTime:s,frameColor:l}){return(0,e.jsxs)("div",{className:"relative inline-flex flex-col items-center rounded-[2rem] shadow-xl",style:{backgroundColor:l??(a==="dark"?"#1a1a1a":"#e5e7eb"),padding:"10px 6px",width:r+12},"data-testid":"device-frame","data-device":"android",children:[(0,e.jsx)("div",{className:"absolute top-[6px] rounded-full bg-gray-800 z-10 border border-gray-700",style:{width:8,height:8,left:"50%",transform:"translateX(-50%)"},"data-testid":"camera-dot"}),(0,e.jsxs)("div",{className:"rounded-[1.5rem] overflow-hidden bg-black relative",style:{width:r,height:i},children:[d&&(0,e.jsx)(f,{time:s,theme:a,device:"android"}),t]})]})}function J({children:t,theme:a,screenW:r,screenH:i,showStatusBar:d,statusBarTime:s,frameColor:l}){return(0,e.jsxs)("div",{className:"relative inline-flex flex-col items-center rounded-[1.5rem] shadow-xl",style:{backgroundColor:l??(a==="dark"?"#1a1a1a":"#e5e7eb"),padding:"16px 12px",width:r+24},"data-testid":"device-frame","data-device":"tablet",children:[(0,e.jsx)("div",{className:"absolute top-[8px] rounded-full bg-gray-700 z-10",style:{width:6,height:6,left:"50%",transform:"translateX(-50%)"}}),(0,e.jsxs)("div",{className:"rounded-lg overflow-hidden bg-black relative",style:{width:r,height:i},children:[d&&(0,e.jsx)(f,{time:s,theme:a,device:"tablet"}),t]})]})}function K({children:t,theme:a,screenW:r,screenH:i,frameColor:d}){let s=a==="dark",l=d??(s?"#1a1a1a":"#d1d5db"),n=r+60;return(0,e.jsxs)("div",{className:"inline-flex flex-col items-center","data-testid":"device-frame","data-device":"laptop",children:[(0,e.jsxs)("div",{className:"rounded-t-xl shadow-xl relative",style:{backgroundColor:l,padding:"8px 8px 0",width:r+16},children:[(0,e.jsx)("div",{className:"absolute top-[3px] rounded-full bg-gray-700 z-10",style:{width:4,height:4,left:"50%",transform:"translateX(-50%)"}}),(0,e.jsx)("div",{className:"rounded-t-sm overflow-hidden bg-black",style:{width:r,height:i},children:t})]}),(0,e.jsx)("div",{className:(0,o.cn)(s?"bg-gray-800":"bg-gray-400"),style:{width:r+16,height:3}}),(0,e.jsx)("div",{className:"rounded-b-xl shadow-lg",style:{backgroundColor:l,width:n,height:12,clipPath:"polygon(3% 0%, 97% 0%, 100% 100%, 0% 100%)"},"data-testid":"laptop-base"})]})}function Q({children:t,theme:a,screenW:r,screenH:i,frameColor:d}){let s=a==="dark";return(0,e.jsxs)("div",{className:"inline-flex flex-col items-center","data-testid":"device-frame","data-device":"desktop",children:[(0,e.jsx)("div",{className:"rounded-lg shadow-xl",style:{backgroundColor:d??(s?"#1a1a1a":"#d1d5db"),padding:"8px 8px 20px",width:r+16},children:(0,e.jsx)("div",{className:"rounded-sm overflow-hidden bg-black",style:{width:r,height:i},children:t})}),(0,e.jsx)("div",{className:(0,o.cn)(s?"bg-gray-800":"bg-gray-400"),style:{width:40,height:24},"data-testid":"monitor-stand"}),(0,e.jsx)("div",{className:(0,o.cn)("rounded-t-sm",s?"bg-gray-800":"bg-gray-400"),style:{width:Math.round(r*.4),height:6,borderRadius:"2px 2px 4px 4px"}})]})}function Z({children:t,theme:a,screenW:r,screenH:i,showStatusBar:d,statusBarTime:s,frameColor:l}){let n=a==="dark",h=l??(n?"#1a1a1a":"#d1d5db"),c=Math.round(r*.7);return(0,e.jsxs)("div",{className:"inline-flex flex-col items-center","data-testid":"device-frame","data-device":"watch",children:[(0,e.jsx)("div",{className:(0,o.cn)("rounded-t-lg",n?"bg-gray-800":"bg-gray-400"),style:{width:c,height:30},"data-testid":"watch-band"}),(0,e.jsxs)("div",{className:"relative rounded-[1.2rem] shadow-xl",style:{backgroundColor:h,padding:"8px 6px",width:r+12},children:[(0,e.jsx)("div",{className:(0,o.cn)("absolute rounded-sm",n?"bg-gray-600":"bg-gray-400"),style:{width:4,height:16,right:-4,top:"30%"},"data-testid":"watch-crown"}),(0,e.jsxs)("div",{className:"rounded-xl overflow-hidden bg-black",style:{width:r,height:i},children:[d&&(0,e.jsx)(f,{time:s,theme:a,device:"watch"}),t]})]}),(0,e.jsx)("div",{className:(0,o.cn)("rounded-b-lg",n?"bg-gray-800":"bg-gray-400"),style:{width:c,height:30}})]})}function _({children:t,theme:a,screenW:r,screenH:i,frameColor:d}){return(0,e.jsxs)("div",{className:"inline-flex flex-col rounded-lg shadow-xl overflow-hidden",style:{backgroundColor:d??(a==="dark"?"#1f2937":"#f3f4f6"),width:r},"data-testid":"device-frame","data-device":"browser",children:[(0,e.jsx)(U,{theme:a}),(0,e.jsx)("div",{className:"overflow-hidden bg-white",style:{width:r,height:i},children:t})]})}function $({device:t="phone",src:a,alt:r,children:i,orientation:d="portrait",theme:s="dark",size:l="md",showStatusBar:n=!1,statusBarTime:h,animated:c=!1,scrollSpeed:w=30,frameColor:m,className:F,contentClassName:H}){let M=(0,B.useUILabels)(),D=(0,p.useRef)(null),x=(0,p.useRef)(null),y=j[t][l],C=d==="landscape"&&t!=="watch"&&t!=="browser",g=C?y.h:y.w,u=C?y.w:y.h;(0,p.useEffect)(()=>{if(!c||!D.current)return;let b=D.current,k=null,z=T=>{k===null&&(k=T);let W=(T-k)/1e3;k=T,b.scrollTop+=w*W,b.scrollTop>=b.scrollHeight-b.clientHeight&&(b.scrollTop=0),x.current=requestAnimationFrame(z)};return x.current=requestAnimationFrame(z),()=>{x.current!==null&&cancelAnimationFrame(x.current)}},[c,w]);let v=(0,e.jsx)("div",{ref:c?D:void 0,className:(0,o.cn)("w-full h-full overflow-hidden",c&&"overflow-y-auto scrollbar-hide",H),style:c?{scrollBehavior:"auto"}:void 0,children:a?(0,e.jsx)("img",{src:a,alt:r??M.deviceMockupAlt,className:"w-full h-auto object-cover",draggable:!1}):i}),N={showStatusBar:n,statusBarTime:h},S=()=>{switch(t){case"phone":return(0,e.jsx)(Y,{theme:s,screenW:g,screenH:u,frameColor:m,landscape:C,...N,children:v});case"android":return(0,e.jsx)(G,{theme:s,screenW:g,screenH:u,frameColor:m,...N,children:v});case"tablet":return(0,e.jsx)(J,{theme:s,screenW:g,screenH:u,frameColor:m,...N,children:v});case"laptop":return(0,e.jsx)(K,{theme:s,screenW:g,screenH:u,frameColor:m,children:v});case"desktop":return(0,e.jsx)(Q,{theme:s,screenW:g,screenH:u,frameColor:m,children:v});case"watch":return(0,e.jsx)(Z,{theme:s,screenW:g,screenH:u,frameColor:m,...N,children:v});case"browser":return(0,e.jsx)(_,{theme:s,screenW:g,screenH:u,frameColor:m,children:v})}};return(0,e.jsx)("div",{className:(0,o.cn)("inline-flex",F),"data-testid":"device-mockup","data-orientation":d,"data-theme":s,"data-size":l,children:S()})}0&&(module.exports={DeviceMockup});
1
+ "use strict";"use client";var T=Object.defineProperty;var X=Object.getOwnPropertyDescriptor;var j=Object.getOwnPropertyNames;var q=Object.prototype.hasOwnProperty;var U=(t,a)=>{for(var r in a)T(t,r,{get:a[r],enumerable:!0})},Q=(t,a,r,d)=>{if(a&&typeof a=="object"||typeof a=="function")for(let o of j(a))!q.call(t,o)&&o!==r&&T(t,o,{get:()=>a[o],enumerable:!(d=X(a,o))||d.enumerable});return t};var Y=t=>Q(T({},"__esModule",{value:!0}),t);var le={};U(le,{DeviceMockup:()=>ie});module.exports=Y(le);var p=require("react"),i=require("../../lib/cn.cjs"),W=require("../../lib/css-value.cjs"),L=require("../../lib/i18n.cjs"),e=require("react/jsx-runtime"),_={phone:{sm:{w:180,h:320},md:{w:240,h:480},lg:{w:300,h:600}},android:{sm:{w:180,h:320},md:{w:240,h:480},lg:{w:300,h:600}},tablet:{sm:{w:320,h:420},md:{w:420,h:560},lg:{w:540,h:720}},laptop:{sm:{w:400,h:250},md:{w:560,h:350},lg:{w:720,h:450}},desktop:{sm:{w:400,h:300},md:{w:560,h:400},lg:{w:720,h:520}},watch:{sm:{w:80,h:96},md:{w:120,h:144},lg:{w:160,h:192}},browser:{sm:{w:400,h:280},md:{w:560,h:380},lg:{w:720,h:480}}},G=({className:t})=>(0,e.jsxs)("svg",{className:(0,i.cn)("w-3 h-3",t),viewBox:"0 0 16 16",fill:"currentColor",children:[(0,e.jsx)("rect",{x:"1",y:"11",width:"2.5",height:"4",rx:"0.5"}),(0,e.jsx)("rect",{x:"5",y:"8",width:"2.5",height:"7",rx:"0.5"}),(0,e.jsx)("rect",{x:"9",y:"5",width:"2.5",height:"10",rx:"0.5"}),(0,e.jsx)("rect",{x:"13",y:"1",width:"2.5",height:"14",rx:"0.5"})]}),J=({className:t})=>(0,e.jsxs)("svg",{className:(0,i.cn)("w-3 h-3",t),viewBox:"0 0 20 20",fill:"currentColor",children:[(0,e.jsx)("path",{d:"M10 14.5a1.5 1.5 0 100 3 1.5 1.5 0 000-3z"}),(0,e.jsx)("path",{fillRule:"evenodd",d:"M6.05 11.95a5.5 5.5 0 017.9 0 .75.75 0 001.08-1.04 7 7 0 00-10.06 0 .75.75 0 001.08 1.04z",clipRule:"evenodd"}),(0,e.jsx)("path",{fillRule:"evenodd",d:"M2.81 8.72a10 10 0 0114.38 0 .75.75 0 001.06-1.06 11.5 11.5 0 00-16.5 0 .75.75 0 001.06 1.06z",clipRule:"evenodd"})]}),K=({className:t})=>(0,e.jsxs)("svg",{className:(0,i.cn)("w-4 h-3",t),viewBox:"0 0 24 14",fill:"currentColor",children:[(0,e.jsx)("rect",{x:"0.5",y:"0.5",width:"20",height:"13",rx:"2",stroke:"currentColor",fill:"none",strokeWidth:"1"}),(0,e.jsx)("rect",{x:"22",y:"4",width:"2",height:"6",rx:"0.5"}),(0,e.jsx)("rect",{x:"2.5",y:"2.5",width:"14",height:"9",rx:"1"})]});function x({time:t="9:41",theme:a,device:r}){let d=r==="watch",o=a==="dark"?"text-white":"text-gray-900";return d?(0,e.jsx)("div",{className:(0,i.cn)("flex shrink-0 items-center justify-center py-0.5",o),style:{fontSize:"8px"},children:(0,e.jsx)("span",{className:"font-medium",children:t})}):(0,e.jsxs)("div",{className:(0,i.cn)("flex shrink-0 items-center justify-between px-4 py-1",a==="dark"?"bg-black/20":"bg-white/20",o),style:{fontSize:"10px"},"data-testid":"status-bar",children:[(0,e.jsx)("span",{className:"font-semibold",children:t}),(0,e.jsxs)("div",{className:"flex items-center gap-1",children:[(0,e.jsx)(G,{className:o}),(0,e.jsx)(J,{className:o}),(0,e.jsx)(K,{className:o})]})]})}function Z({theme:t}){let a=t==="dark";return(0,e.jsxs)("div",{className:(0,i.cn)("flex items-center gap-2 px-3 py-2 border-b",a?"bg-gray-800 border-gray-700":"bg-gray-100 border-gray-200"),"data-testid":"browser-chrome",children:[(0,e.jsxs)("div",{className:"flex items-center gap-1.5",children:[(0,e.jsx)("div",{className:"w-2.5 h-2.5 rounded-full bg-red-400"}),(0,e.jsx)("div",{className:"w-2.5 h-2.5 rounded-full bg-yellow-400"}),(0,e.jsx)("div",{className:"w-2.5 h-2.5 rounded-full bg-green-400"})]}),(0,e.jsx)("div",{className:(0,i.cn)("flex-1 rounded-md px-3 py-1 text-center",a?"bg-gray-700 text-gray-300":"bg-white text-gray-500 border border-gray-200"),style:{fontSize:"11px"},children:(0,e.jsxs)("span",{className:"flex items-center justify-center gap-1",children:[(0,e.jsx)("svg",{className:"w-2.5 h-2.5",viewBox:"0 0 16 16",fill:"currentColor",children:(0,e.jsx)("path",{fillRule:"evenodd",d:"M8 1a4 4 0 00-4 4v3.5H3a1 1 0 00-1 1V14a1 1 0 001 1h10a1 1 0 001-1V9.5a1 1 0 00-1-1h-1V5a4 4 0 00-4-4zm2.5 7.5V5a2.5 2.5 0 00-5 0v3.5h5z",clipRule:"evenodd"})}),"example.com"]})})]})}function $({children:t,theme:a,screenW:r,screenH:d,showStatusBar:o,statusBarTime:s,frameColor:l,landscape:n=!1}){let h=a==="dark",c=l??(h?"#1a1a1a":"#e5e7eb");if(n){let k=Math.round(d*.35);return(0,e.jsxs)("div",{className:"relative inline-flex flex-row items-center rounded-[2.5rem] shadow-xl",style:{backgroundColor:c,padding:"8px 12px",height:d+16},"data-testid":"device-frame","data-device":"phone",children:[(0,e.jsx)("div",{className:(0,i.cn)("rounded-full mr-2",h?"bg-gray-600":"bg-gray-400"),style:{width:4,height:Math.round(d*.35)},"data-testid":"home-indicator"}),(0,e.jsxs)("div",{className:"flex flex-col rounded-[2rem] overflow-hidden bg-black relative",style:{width:r,height:d},children:[o&&(0,e.jsx)(x,{time:s,theme:a,device:"phone"}),t]}),(0,e.jsx)("div",{className:"absolute rounded-full bg-black z-10",style:{width:20,height:k,right:10,top:"50%",transform:"translateY(-50%)"},"data-testid":"phone-notch"})]})}let w=Math.round(r*.35);return(0,e.jsxs)("div",{className:"relative inline-flex flex-col items-center rounded-[2.5rem] shadow-xl",style:{backgroundColor:c,padding:"12px 8px",width:r+16},"data-testid":"device-frame","data-device":"phone",children:[(0,e.jsx)("div",{className:"absolute top-[10px] rounded-full bg-black z-10",style:{width:w,height:20,left:"50%",transform:"translateX(-50%)"},"data-testid":"phone-notch"}),(0,e.jsxs)("div",{className:"flex flex-col rounded-[2rem] overflow-hidden bg-black relative",style:{width:r,height:d},children:[o&&(0,e.jsx)(x,{time:s,theme:a,device:"phone"}),t]}),(0,e.jsx)("div",{className:(0,i.cn)("rounded-full mt-2",h?"bg-gray-600":"bg-gray-400"),style:{width:Math.round(r*.35),height:4},"data-testid":"home-indicator"})]})}function ee({children:t,theme:a,screenW:r,screenH:d,showStatusBar:o,statusBarTime:s,frameColor:l}){return(0,e.jsxs)("div",{className:"relative inline-flex flex-col items-center rounded-[2rem] shadow-xl",style:{backgroundColor:l??(a==="dark"?"#1a1a1a":"#e5e7eb"),padding:"10px 6px",width:r+12},"data-testid":"device-frame","data-device":"android",children:[(0,e.jsx)("div",{className:"absolute top-[6px] rounded-full bg-gray-800 z-10 border border-gray-700",style:{width:8,height:8,left:"50%",transform:"translateX(-50%)"},"data-testid":"camera-dot"}),(0,e.jsxs)("div",{className:"flex flex-col rounded-[1.5rem] overflow-hidden bg-black relative",style:{width:r,height:d},children:[o&&(0,e.jsx)(x,{time:s,theme:a,device:"android"}),t]})]})}function te({children:t,theme:a,screenW:r,screenH:d,showStatusBar:o,statusBarTime:s,frameColor:l}){return(0,e.jsxs)("div",{className:"relative inline-flex flex-col items-center rounded-[1.5rem] shadow-xl",style:{backgroundColor:l??(a==="dark"?"#1a1a1a":"#e5e7eb"),padding:"16px 12px",width:r+24},"data-testid":"device-frame","data-device":"tablet",children:[(0,e.jsx)("div",{className:"absolute top-[8px] rounded-full bg-gray-700 z-10",style:{width:6,height:6,left:"50%",transform:"translateX(-50%)"}}),(0,e.jsxs)("div",{className:"flex flex-col rounded-lg overflow-hidden bg-black relative",style:{width:r,height:d},children:[o&&(0,e.jsx)(x,{time:s,theme:a,device:"tablet"}),t]})]})}function ae({children:t,theme:a,screenW:r,screenH:d,frameColor:o}){let s=a==="dark",l=o??(s?"#1a1a1a":"#d1d5db"),n=r+60;return(0,e.jsxs)("div",{className:"inline-flex flex-col items-center","data-testid":"device-frame","data-device":"laptop",children:[(0,e.jsxs)("div",{className:"rounded-t-xl shadow-xl relative",style:{backgroundColor:l,padding:"8px 8px 0",width:r+16},children:[(0,e.jsx)("div",{className:"absolute top-[3px] rounded-full bg-gray-700 z-10",style:{width:4,height:4,left:"50%",transform:"translateX(-50%)"}}),(0,e.jsx)("div",{className:"flex flex-col rounded-t-sm overflow-hidden bg-black",style:{width:r,height:d},children:t})]}),(0,e.jsx)("div",{className:(0,i.cn)(s?"bg-gray-800":"bg-gray-400"),style:{width:r+16,height:3}}),(0,e.jsx)("div",{className:"rounded-b-xl shadow-lg",style:{backgroundColor:l,width:n,height:12,clipPath:"polygon(3% 0%, 97% 0%, 100% 100%, 0% 100%)"},"data-testid":"laptop-base"})]})}function re({children:t,theme:a,screenW:r,screenH:d,frameColor:o}){let s=a==="dark";return(0,e.jsxs)("div",{className:"inline-flex flex-col items-center","data-testid":"device-frame","data-device":"desktop",children:[(0,e.jsx)("div",{className:"rounded-lg shadow-xl",style:{backgroundColor:o??(s?"#1a1a1a":"#d1d5db"),padding:"8px 8px 20px",width:r+16},children:(0,e.jsx)("div",{className:"flex flex-col rounded-sm overflow-hidden bg-black",style:{width:r,height:d},children:t})}),(0,e.jsx)("div",{className:(0,i.cn)(s?"bg-gray-800":"bg-gray-400"),style:{width:40,height:24},"data-testid":"monitor-stand"}),(0,e.jsx)("div",{className:(0,i.cn)("rounded-t-sm",s?"bg-gray-800":"bg-gray-400"),style:{width:Math.round(r*.4),height:6,borderRadius:"2px 2px 4px 4px"}})]})}function oe({children:t,theme:a,screenW:r,screenH:d,showStatusBar:o,statusBarTime:s,frameColor:l}){let n=a==="dark",h=l??(n?"#1a1a1a":"#d1d5db"),c=Math.round(r*.7);return(0,e.jsxs)("div",{className:"inline-flex flex-col items-center","data-testid":"device-frame","data-device":"watch",children:[(0,e.jsx)("div",{className:(0,i.cn)("rounded-t-lg",n?"bg-gray-800":"bg-gray-400"),style:{width:c,height:30},"data-testid":"watch-band"}),(0,e.jsxs)("div",{className:"relative rounded-[1.2rem] shadow-xl",style:{backgroundColor:h,padding:"8px 6px",width:r+12},children:[(0,e.jsx)("div",{className:(0,i.cn)("absolute rounded-sm",n?"bg-gray-600":"bg-gray-400"),style:{width:4,height:16,right:-4,top:"30%"},"data-testid":"watch-crown"}),(0,e.jsxs)("div",{className:"flex flex-col rounded-xl overflow-hidden bg-black",style:{width:r,height:d},children:[o&&(0,e.jsx)(x,{time:s,theme:a,device:"watch"}),t]})]}),(0,e.jsx)("div",{className:(0,i.cn)("rounded-b-lg",n?"bg-gray-800":"bg-gray-400"),style:{width:c,height:30}})]})}function de({children:t,theme:a,screenW:r,screenH:d,frameColor:o}){return(0,e.jsxs)("div",{className:"inline-flex flex-col rounded-lg shadow-xl overflow-hidden",style:{backgroundColor:o??(a==="dark"?"#1f2937":"#f3f4f6"),width:r},"data-testid":"device-frame","data-device":"browser",children:[(0,e.jsx)(Z,{theme:a}),(0,e.jsx)("div",{className:"flex flex-col overflow-hidden bg-white",style:{width:r,height:d},children:t})]})}var H="(prefers-reduced-motion: reduce)",S=()=>typeof window<"u"&&typeof window.matchMedia=="function";function se(){let[t,a]=(0,p.useState)(()=>S()&&window.matchMedia(H).matches);return(0,p.useEffect)(()=>{if(!S())return;let r=window.matchMedia(H);a(r.matches);let d=o=>a(o.matches);return r.addEventListener?.("change",d),()=>r.removeEventListener?.("change",d)},[]),t}function ie({device:t="phone",src:a,alt:r,children:d,orientation:o="portrait",theme:s="dark",size:l="md",showStatusBar:n=!1,statusBarTime:h,animated:c=!1,scrollSpeed:w=30,frameColor:k,className:A,contentClassName:E}){let P=(0,L.useUILabels)(),g=(0,W.safeCssColor)(k),[m,I]=(0,p.useState)(null),M=se(),y=_[t][l],C=o==="landscape"&&(t==="phone"||t==="android"||t==="tablet"),u=C?y.h:y.w,v=C?y.w:y.h;(0,p.useEffect)(()=>{if(!c||M||!m)return;let b=m.scrollTop,D=null,R=requestAnimationFrame(function V(z){let B=D===null?0:Math.min(z-D,250)/1e3;D=z,Math.abs(m.scrollTop-b)>1&&(b=m.scrollTop);let F=m.scrollHeight-m.clientHeight;b=F>0&&b+w*B<F?b+w*B:0,m.scrollTop=b,R=requestAnimationFrame(V)});return()=>cancelAnimationFrame(R)},[c,M,m,w]);let f=(0,e.jsx)("div",{ref:c?I:void 0,className:(0,i.cn)("w-full flex-1 min-h-0 overflow-hidden",c&&"overflow-y-auto scrollbar-hide",E),style:c?{scrollBehavior:"auto"}:void 0,children:a?(0,e.jsx)("img",{src:a,alt:r??P.deviceMockupAlt,className:"w-full h-auto object-cover",draggable:!1}):d}),N={showStatusBar:n,statusBarTime:h},O=()=>{switch(t){case"phone":return(0,e.jsx)($,{theme:s,screenW:u,screenH:v,frameColor:g,landscape:C,...N,children:f});case"android":return(0,e.jsx)(ee,{theme:s,screenW:u,screenH:v,frameColor:g,...N,children:f});case"tablet":return(0,e.jsx)(te,{theme:s,screenW:u,screenH:v,frameColor:g,...N,children:f});case"laptop":return(0,e.jsx)(ae,{theme:s,screenW:u,screenH:v,frameColor:g,children:f});case"desktop":return(0,e.jsx)(re,{theme:s,screenW:u,screenH:v,frameColor:g,children:f});case"watch":return(0,e.jsx)(oe,{theme:s,screenW:u,screenH:v,frameColor:g,...N,children:f});case"browser":return(0,e.jsx)(de,{theme:s,screenW:u,screenH:v,frameColor:g,children:f})}};return(0,e.jsx)("div",{className:(0,i.cn)("inline-flex",A),"data-testid":"device-mockup","data-orientation":o,"data-theme":s,"data-size":l,children:O()})}0&&(module.exports={DeviceMockup});
@@ -1 +1 @@
1
- "use client";import{useRef as z,useEffect as W}from"react";import{cn as l}from"../../lib/cn.js";import{useUILabels as A}from"../../lib/i18n.js";import{jsx as e,jsxs as i}from"react/jsx-runtime";var P={phone:{sm:{w:180,h:320},md:{w:240,h:480},lg:{w:300,h:600}},android:{sm:{w:180,h:320},md:{w:240,h:480},lg:{w:300,h:600}},tablet:{sm:{w:320,h:420},md:{w:420,h:560},lg:{w:540,h:720}},laptop:{sm:{w:400,h:250},md:{w:560,h:350},lg:{w:720,h:450}},desktop:{sm:{w:400,h:300},md:{w:560,h:400},lg:{w:720,h:520}},watch:{sm:{w:80,h:96},md:{w:120,h:144},lg:{w:160,h:192}},browser:{sm:{w:400,h:280},md:{w:560,h:380},lg:{w:720,h:480}}},L=({className:a})=>i("svg",{className:l("w-3 h-3",a),viewBox:"0 0 16 16",fill:"currentColor",children:[e("rect",{x:"1",y:"11",width:"2.5",height:"4",rx:"0.5"}),e("rect",{x:"5",y:"8",width:"2.5",height:"7",rx:"0.5"}),e("rect",{x:"9",y:"5",width:"2.5",height:"10",rx:"0.5"}),e("rect",{x:"13",y:"1",width:"2.5",height:"14",rx:"0.5"})]}),I=({className:a})=>i("svg",{className:l("w-3 h-3",a),viewBox:"0 0 20 20",fill:"currentColor",children:[e("path",{d:"M10 14.5a1.5 1.5 0 100 3 1.5 1.5 0 000-3z"}),e("path",{fillRule:"evenodd",d:"M6.05 11.95a5.5 5.5 0 017.9 0 .75.75 0 001.08-1.04 7 7 0 00-10.06 0 .75.75 0 001.08 1.04z",clipRule:"evenodd"}),e("path",{fillRule:"evenodd",d:"M2.81 8.72a10 10 0 0114.38 0 .75.75 0 001.06-1.06 11.5 11.5 0 00-16.5 0 .75.75 0 001.06 1.06z",clipRule:"evenodd"})]}),V=({className:a})=>i("svg",{className:l("w-4 h-3",a),viewBox:"0 0 24 14",fill:"currentColor",children:[e("rect",{x:"0.5",y:"0.5",width:"20",height:"13",rx:"2",stroke:"currentColor",fill:"none",strokeWidth:"1"}),e("rect",{x:"22",y:"4",width:"2",height:"6",rx:"0.5"}),e("rect",{x:"2.5",y:"2.5",width:"14",height:"9",rx:"1"})]});function f({time:a="9:41",theme:r,device:t}){let o=t==="watch",s=r==="dark"?"text-white":"text-gray-900";return o?e("div",{className:l("flex items-center justify-center py-0.5",s),style:{fontSize:"8px"},children:e("span",{className:"font-medium",children:a})}):i("div",{className:l("flex items-center justify-between px-4 py-1",r==="dark"?"bg-black/20":"bg-white/20",s),style:{fontSize:"10px"},"data-testid":"status-bar",children:[e("span",{className:"font-semibold",children:a}),i("div",{className:"flex items-center gap-1",children:[e(L,{className:s}),e(I,{className:s}),e(V,{className:s})]})]})}function X({theme:a}){let r=a==="dark";return i("div",{className:l("flex items-center gap-2 px-3 py-2 border-b",r?"bg-gray-800 border-gray-700":"bg-gray-100 border-gray-200"),"data-testid":"browser-chrome",children:[i("div",{className:"flex items-center gap-1.5",children:[e("div",{className:"w-2.5 h-2.5 rounded-full bg-red-400"}),e("div",{className:"w-2.5 h-2.5 rounded-full bg-yellow-400"}),e("div",{className:"w-2.5 h-2.5 rounded-full bg-green-400"})]}),e("div",{className:l("flex-1 rounded-md px-3 py-1 text-center",r?"bg-gray-700 text-gray-300":"bg-white text-gray-500 border border-gray-200"),style:{fontSize:"11px"},children:i("span",{className:"flex items-center justify-center gap-1",children:[e("svg",{className:"w-2.5 h-2.5",viewBox:"0 0 16 16",fill:"currentColor",children:e("path",{fillRule:"evenodd",d:"M8 1a4 4 0 00-4 4v3.5H3a1 1 0 00-1 1V14a1 1 0 001 1h10a1 1 0 001-1V9.5a1 1 0 00-1-1h-1V5a4 4 0 00-4-4zm2.5 7.5V5a2.5 2.5 0 00-5 0v3.5h5z",clipRule:"evenodd"})}),"example.com"]})})]})}function j({children:a,theme:r,screenW:t,screenH:o,showStatusBar:s,statusBarTime:d,frameColor:n,landscape:c=!1}){let m=r==="dark",h=n??(m?"#1a1a1a":"#e5e7eb");if(c){let g=Math.round(o*.35);return i("div",{className:"relative inline-flex flex-row items-center rounded-[2.5rem] shadow-xl",style:{backgroundColor:h,padding:"8px 12px",height:o+16},"data-testid":"device-frame","data-device":"phone",children:[e("div",{className:l("rounded-full mr-2",m?"bg-gray-600":"bg-gray-400"),style:{width:4,height:Math.round(o*.35)},"data-testid":"home-indicator"}),i("div",{className:"rounded-[2rem] overflow-hidden bg-black relative",style:{width:t,height:o},children:[s&&e(f,{time:d,theme:r,device:"phone"}),a]}),e("div",{className:"absolute rounded-full bg-black z-10",style:{width:20,height:g,right:10,top:"50%",transform:"translateY(-50%)"},"data-testid":"phone-notch"})]})}let w=Math.round(t*.35);return i("div",{className:"relative inline-flex flex-col items-center rounded-[2.5rem] shadow-xl",style:{backgroundColor:h,padding:"12px 8px",width:t+16},"data-testid":"device-frame","data-device":"phone",children:[e("div",{className:"absolute top-[10px] rounded-full bg-black z-10",style:{width:w,height:20,left:"50%",transform:"translateX(-50%)"},"data-testid":"phone-notch"}),i("div",{className:"rounded-[2rem] overflow-hidden bg-black relative",style:{width:t,height:o},children:[s&&e(f,{time:d,theme:r,device:"phone"}),a]}),e("div",{className:l("rounded-full mt-2",m?"bg-gray-600":"bg-gray-400"),style:{width:Math.round(t*.35),height:4},"data-testid":"home-indicator"})]})}function q({children:a,theme:r,screenW:t,screenH:o,showStatusBar:s,statusBarTime:d,frameColor:n}){return i("div",{className:"relative inline-flex flex-col items-center rounded-[2rem] shadow-xl",style:{backgroundColor:n??(r==="dark"?"#1a1a1a":"#e5e7eb"),padding:"10px 6px",width:t+12},"data-testid":"device-frame","data-device":"android",children:[e("div",{className:"absolute top-[6px] rounded-full bg-gray-800 z-10 border border-gray-700",style:{width:8,height:8,left:"50%",transform:"translateX(-50%)"},"data-testid":"camera-dot"}),i("div",{className:"rounded-[1.5rem] overflow-hidden bg-black relative",style:{width:t,height:o},children:[s&&e(f,{time:d,theme:r,device:"android"}),a]})]})}function E({children:a,theme:r,screenW:t,screenH:o,showStatusBar:s,statusBarTime:d,frameColor:n}){return i("div",{className:"relative inline-flex flex-col items-center rounded-[1.5rem] shadow-xl",style:{backgroundColor:n??(r==="dark"?"#1a1a1a":"#e5e7eb"),padding:"16px 12px",width:t+24},"data-testid":"device-frame","data-device":"tablet",children:[e("div",{className:"absolute top-[8px] rounded-full bg-gray-700 z-10",style:{width:6,height:6,left:"50%",transform:"translateX(-50%)"}}),i("div",{className:"rounded-lg overflow-hidden bg-black relative",style:{width:t,height:o},children:[s&&e(f,{time:d,theme:r,device:"tablet"}),a]})]})}function O({children:a,theme:r,screenW:t,screenH:o,frameColor:s}){let d=r==="dark",n=s??(d?"#1a1a1a":"#d1d5db"),c=t+60;return i("div",{className:"inline-flex flex-col items-center","data-testid":"device-frame","data-device":"laptop",children:[i("div",{className:"rounded-t-xl shadow-xl relative",style:{backgroundColor:n,padding:"8px 8px 0",width:t+16},children:[e("div",{className:"absolute top-[3px] rounded-full bg-gray-700 z-10",style:{width:4,height:4,left:"50%",transform:"translateX(-50%)"}}),e("div",{className:"rounded-t-sm overflow-hidden bg-black",style:{width:t,height:o},children:a})]}),e("div",{className:l(d?"bg-gray-800":"bg-gray-400"),style:{width:t+16,height:3}}),e("div",{className:"rounded-b-xl shadow-lg",style:{backgroundColor:n,width:c,height:12,clipPath:"polygon(3% 0%, 97% 0%, 100% 100%, 0% 100%)"},"data-testid":"laptop-base"})]})}function U({children:a,theme:r,screenW:t,screenH:o,frameColor:s}){let d=r==="dark";return i("div",{className:"inline-flex flex-col items-center","data-testid":"device-frame","data-device":"desktop",children:[e("div",{className:"rounded-lg shadow-xl",style:{backgroundColor:s??(d?"#1a1a1a":"#d1d5db"),padding:"8px 8px 20px",width:t+16},children:e("div",{className:"rounded-sm overflow-hidden bg-black",style:{width:t,height:o},children:a})}),e("div",{className:l(d?"bg-gray-800":"bg-gray-400"),style:{width:40,height:24},"data-testid":"monitor-stand"}),e("div",{className:l("rounded-t-sm",d?"bg-gray-800":"bg-gray-400"),style:{width:Math.round(t*.4),height:6,borderRadius:"2px 2px 4px 4px"}})]})}function Y({children:a,theme:r,screenW:t,screenH:o,showStatusBar:s,statusBarTime:d,frameColor:n}){let c=r==="dark",m=n??(c?"#1a1a1a":"#d1d5db"),h=Math.round(t*.7);return i("div",{className:"inline-flex flex-col items-center","data-testid":"device-frame","data-device":"watch",children:[e("div",{className:l("rounded-t-lg",c?"bg-gray-800":"bg-gray-400"),style:{width:h,height:30},"data-testid":"watch-band"}),i("div",{className:"relative rounded-[1.2rem] shadow-xl",style:{backgroundColor:m,padding:"8px 6px",width:t+12},children:[e("div",{className:l("absolute rounded-sm",c?"bg-gray-600":"bg-gray-400"),style:{width:4,height:16,right:-4,top:"30%"},"data-testid":"watch-crown"}),i("div",{className:"rounded-xl overflow-hidden bg-black",style:{width:t,height:o},children:[s&&e(f,{time:d,theme:r,device:"watch"}),a]})]}),e("div",{className:l("rounded-b-lg",c?"bg-gray-800":"bg-gray-400"),style:{width:h,height:30}})]})}function G({children:a,theme:r,screenW:t,screenH:o,frameColor:s}){return i("div",{className:"inline-flex flex-col rounded-lg shadow-xl overflow-hidden",style:{backgroundColor:s??(r==="dark"?"#1f2937":"#f3f4f6"),width:t},"data-testid":"device-frame","data-device":"browser",children:[e(X,{theme:r}),e("div",{className:"overflow-hidden bg-white",style:{width:t,height:o},children:a})]})}function Z({device:a="phone",src:r,alt:t,children:o,orientation:s="portrait",theme:d="dark",size:n="md",showStatusBar:c=!1,statusBarTime:m,animated:h=!1,scrollSpeed:w=30,frameColor:g,className:B,contentClassName:F}){let H=A(),D=z(null),x=z(null),y=P[a][n],C=s==="landscape"&&a!=="watch"&&a!=="browser",u=C?y.h:y.w,v=C?y.w:y.h;W(()=>{if(!h||!D.current)return;let p=D.current,k=null,R=T=>{k===null&&(k=T);let S=(T-k)/1e3;k=T,p.scrollTop+=w*S,p.scrollTop>=p.scrollHeight-p.clientHeight&&(p.scrollTop=0),x.current=requestAnimationFrame(R)};return x.current=requestAnimationFrame(R),()=>{x.current!==null&&cancelAnimationFrame(x.current)}},[h,w]);let b=e("div",{ref:h?D:void 0,className:l("w-full h-full overflow-hidden",h&&"overflow-y-auto scrollbar-hide",F),style:h?{scrollBehavior:"auto"}:void 0,children:r?e("img",{src:r,alt:t??H.deviceMockupAlt,className:"w-full h-auto object-cover",draggable:!1}):o}),N={showStatusBar:c,statusBarTime:m},M=()=>{switch(a){case"phone":return e(j,{theme:d,screenW:u,screenH:v,frameColor:g,landscape:C,...N,children:b});case"android":return e(q,{theme:d,screenW:u,screenH:v,frameColor:g,...N,children:b});case"tablet":return e(E,{theme:d,screenW:u,screenH:v,frameColor:g,...N,children:b});case"laptop":return e(O,{theme:d,screenW:u,screenH:v,frameColor:g,children:b});case"desktop":return e(U,{theme:d,screenW:u,screenH:v,frameColor:g,children:b});case"watch":return e(Y,{theme:d,screenW:u,screenH:v,frameColor:g,...N,children:b});case"browser":return e(G,{theme:d,screenW:u,screenH:v,frameColor:g,children:b})}};return e("div",{className:l("inline-flex",B),"data-testid":"device-mockup","data-orientation":s,"data-theme":d,"data-size":n,children:M()})}export{Z as DeviceMockup};
1
+ "use client";import{useEffect as S,useState as W}from"react";import{cn as l}from"../../lib/cn.js";import{safeCssColor as V}from"../../lib/css-value.js";import{useUILabels as X}from"../../lib/i18n.js";import{jsx as e,jsxs as i}from"react/jsx-runtime";var j={phone:{sm:{w:180,h:320},md:{w:240,h:480},lg:{w:300,h:600}},android:{sm:{w:180,h:320},md:{w:240,h:480},lg:{w:300,h:600}},tablet:{sm:{w:320,h:420},md:{w:420,h:560},lg:{w:540,h:720}},laptop:{sm:{w:400,h:250},md:{w:560,h:350},lg:{w:720,h:450}},desktop:{sm:{w:400,h:300},md:{w:560,h:400},lg:{w:720,h:520}},watch:{sm:{w:80,h:96},md:{w:120,h:144},lg:{w:160,h:192}},browser:{sm:{w:400,h:280},md:{w:560,h:380},lg:{w:720,h:480}}},q=({className:a})=>i("svg",{className:l("w-3 h-3",a),viewBox:"0 0 16 16",fill:"currentColor",children:[e("rect",{x:"1",y:"11",width:"2.5",height:"4",rx:"0.5"}),e("rect",{x:"5",y:"8",width:"2.5",height:"7",rx:"0.5"}),e("rect",{x:"9",y:"5",width:"2.5",height:"10",rx:"0.5"}),e("rect",{x:"13",y:"1",width:"2.5",height:"14",rx:"0.5"})]}),U=({className:a})=>i("svg",{className:l("w-3 h-3",a),viewBox:"0 0 20 20",fill:"currentColor",children:[e("path",{d:"M10 14.5a1.5 1.5 0 100 3 1.5 1.5 0 000-3z"}),e("path",{fillRule:"evenodd",d:"M6.05 11.95a5.5 5.5 0 017.9 0 .75.75 0 001.08-1.04 7 7 0 00-10.06 0 .75.75 0 001.08 1.04z",clipRule:"evenodd"}),e("path",{fillRule:"evenodd",d:"M2.81 8.72a10 10 0 0114.38 0 .75.75 0 001.06-1.06 11.5 11.5 0 00-16.5 0 .75.75 0 001.06 1.06z",clipRule:"evenodd"})]}),Q=({className:a})=>i("svg",{className:l("w-4 h-3",a),viewBox:"0 0 24 14",fill:"currentColor",children:[e("rect",{x:"0.5",y:"0.5",width:"20",height:"13",rx:"2",stroke:"currentColor",fill:"none",strokeWidth:"1"}),e("rect",{x:"22",y:"4",width:"2",height:"6",rx:"0.5"}),e("rect",{x:"2.5",y:"2.5",width:"14",height:"9",rx:"1"})]});function x({time:a="9:41",theme:r,device:t}){let s=t==="watch",o=r==="dark"?"text-white":"text-gray-900";return s?e("div",{className:l("flex shrink-0 items-center justify-center py-0.5",o),style:{fontSize:"8px"},children:e("span",{className:"font-medium",children:a})}):i("div",{className:l("flex shrink-0 items-center justify-between px-4 py-1",r==="dark"?"bg-black/20":"bg-white/20",o),style:{fontSize:"10px"},"data-testid":"status-bar",children:[e("span",{className:"font-semibold",children:a}),i("div",{className:"flex items-center gap-1",children:[e(q,{className:o}),e(U,{className:o}),e(Q,{className:o})]})]})}function Y({theme:a}){let r=a==="dark";return i("div",{className:l("flex items-center gap-2 px-3 py-2 border-b",r?"bg-gray-800 border-gray-700":"bg-gray-100 border-gray-200"),"data-testid":"browser-chrome",children:[i("div",{className:"flex items-center gap-1.5",children:[e("div",{className:"w-2.5 h-2.5 rounded-full bg-red-400"}),e("div",{className:"w-2.5 h-2.5 rounded-full bg-yellow-400"}),e("div",{className:"w-2.5 h-2.5 rounded-full bg-green-400"})]}),e("div",{className:l("flex-1 rounded-md px-3 py-1 text-center",r?"bg-gray-700 text-gray-300":"bg-white text-gray-500 border border-gray-200"),style:{fontSize:"11px"},children:i("span",{className:"flex items-center justify-center gap-1",children:[e("svg",{className:"w-2.5 h-2.5",viewBox:"0 0 16 16",fill:"currentColor",children:e("path",{fillRule:"evenodd",d:"M8 1a4 4 0 00-4 4v3.5H3a1 1 0 00-1 1V14a1 1 0 001 1h10a1 1 0 001-1V9.5a1 1 0 00-1-1h-1V5a4 4 0 00-4-4zm2.5 7.5V5a2.5 2.5 0 00-5 0v3.5h5z",clipRule:"evenodd"})}),"example.com"]})})]})}function _({children:a,theme:r,screenW:t,screenH:s,showStatusBar:o,statusBarTime:d,frameColor:n,landscape:c=!1}){let m=r==="dark",h=n??(m?"#1a1a1a":"#e5e7eb");if(c){let k=Math.round(s*.35);return i("div",{className:"relative inline-flex flex-row items-center rounded-[2.5rem] shadow-xl",style:{backgroundColor:h,padding:"8px 12px",height:s+16},"data-testid":"device-frame","data-device":"phone",children:[e("div",{className:l("rounded-full mr-2",m?"bg-gray-600":"bg-gray-400"),style:{width:4,height:Math.round(s*.35)},"data-testid":"home-indicator"}),i("div",{className:"flex flex-col rounded-[2rem] overflow-hidden bg-black relative",style:{width:t,height:s},children:[o&&e(x,{time:d,theme:r,device:"phone"}),a]}),e("div",{className:"absolute rounded-full bg-black z-10",style:{width:20,height:k,right:10,top:"50%",transform:"translateY(-50%)"},"data-testid":"phone-notch"})]})}let w=Math.round(t*.35);return i("div",{className:"relative inline-flex flex-col items-center rounded-[2.5rem] shadow-xl",style:{backgroundColor:h,padding:"12px 8px",width:t+16},"data-testid":"device-frame","data-device":"phone",children:[e("div",{className:"absolute top-[10px] rounded-full bg-black z-10",style:{width:w,height:20,left:"50%",transform:"translateX(-50%)"},"data-testid":"phone-notch"}),i("div",{className:"flex flex-col rounded-[2rem] overflow-hidden bg-black relative",style:{width:t,height:s},children:[o&&e(x,{time:d,theme:r,device:"phone"}),a]}),e("div",{className:l("rounded-full mt-2",m?"bg-gray-600":"bg-gray-400"),style:{width:Math.round(t*.35),height:4},"data-testid":"home-indicator"})]})}function G({children:a,theme:r,screenW:t,screenH:s,showStatusBar:o,statusBarTime:d,frameColor:n}){return i("div",{className:"relative inline-flex flex-col items-center rounded-[2rem] shadow-xl",style:{backgroundColor:n??(r==="dark"?"#1a1a1a":"#e5e7eb"),padding:"10px 6px",width:t+12},"data-testid":"device-frame","data-device":"android",children:[e("div",{className:"absolute top-[6px] rounded-full bg-gray-800 z-10 border border-gray-700",style:{width:8,height:8,left:"50%",transform:"translateX(-50%)"},"data-testid":"camera-dot"}),i("div",{className:"flex flex-col rounded-[1.5rem] overflow-hidden bg-black relative",style:{width:t,height:s},children:[o&&e(x,{time:d,theme:r,device:"android"}),a]})]})}function J({children:a,theme:r,screenW:t,screenH:s,showStatusBar:o,statusBarTime:d,frameColor:n}){return i("div",{className:"relative inline-flex flex-col items-center rounded-[1.5rem] shadow-xl",style:{backgroundColor:n??(r==="dark"?"#1a1a1a":"#e5e7eb"),padding:"16px 12px",width:t+24},"data-testid":"device-frame","data-device":"tablet",children:[e("div",{className:"absolute top-[8px] rounded-full bg-gray-700 z-10",style:{width:6,height:6,left:"50%",transform:"translateX(-50%)"}}),i("div",{className:"flex flex-col rounded-lg overflow-hidden bg-black relative",style:{width:t,height:s},children:[o&&e(x,{time:d,theme:r,device:"tablet"}),a]})]})}function K({children:a,theme:r,screenW:t,screenH:s,frameColor:o}){let d=r==="dark",n=o??(d?"#1a1a1a":"#d1d5db"),c=t+60;return i("div",{className:"inline-flex flex-col items-center","data-testid":"device-frame","data-device":"laptop",children:[i("div",{className:"rounded-t-xl shadow-xl relative",style:{backgroundColor:n,padding:"8px 8px 0",width:t+16},children:[e("div",{className:"absolute top-[3px] rounded-full bg-gray-700 z-10",style:{width:4,height:4,left:"50%",transform:"translateX(-50%)"}}),e("div",{className:"flex flex-col rounded-t-sm overflow-hidden bg-black",style:{width:t,height:s},children:a})]}),e("div",{className:l(d?"bg-gray-800":"bg-gray-400"),style:{width:t+16,height:3}}),e("div",{className:"rounded-b-xl shadow-lg",style:{backgroundColor:n,width:c,height:12,clipPath:"polygon(3% 0%, 97% 0%, 100% 100%, 0% 100%)"},"data-testid":"laptop-base"})]})}function Z({children:a,theme:r,screenW:t,screenH:s,frameColor:o}){let d=r==="dark";return i("div",{className:"inline-flex flex-col items-center","data-testid":"device-frame","data-device":"desktop",children:[e("div",{className:"rounded-lg shadow-xl",style:{backgroundColor:o??(d?"#1a1a1a":"#d1d5db"),padding:"8px 8px 20px",width:t+16},children:e("div",{className:"flex flex-col rounded-sm overflow-hidden bg-black",style:{width:t,height:s},children:a})}),e("div",{className:l(d?"bg-gray-800":"bg-gray-400"),style:{width:40,height:24},"data-testid":"monitor-stand"}),e("div",{className:l("rounded-t-sm",d?"bg-gray-800":"bg-gray-400"),style:{width:Math.round(t*.4),height:6,borderRadius:"2px 2px 4px 4px"}})]})}function $({children:a,theme:r,screenW:t,screenH:s,showStatusBar:o,statusBarTime:d,frameColor:n}){let c=r==="dark",m=n??(c?"#1a1a1a":"#d1d5db"),h=Math.round(t*.7);return i("div",{className:"inline-flex flex-col items-center","data-testid":"device-frame","data-device":"watch",children:[e("div",{className:l("rounded-t-lg",c?"bg-gray-800":"bg-gray-400"),style:{width:h,height:30},"data-testid":"watch-band"}),i("div",{className:"relative rounded-[1.2rem] shadow-xl",style:{backgroundColor:m,padding:"8px 6px",width:t+12},children:[e("div",{className:l("absolute rounded-sm",c?"bg-gray-600":"bg-gray-400"),style:{width:4,height:16,right:-4,top:"30%"},"data-testid":"watch-crown"}),i("div",{className:"flex flex-col rounded-xl overflow-hidden bg-black",style:{width:t,height:s},children:[o&&e(x,{time:d,theme:r,device:"watch"}),a]})]}),e("div",{className:l("rounded-b-lg",c?"bg-gray-800":"bg-gray-400"),style:{width:h,height:30}})]})}function ee({children:a,theme:r,screenW:t,screenH:s,frameColor:o}){return i("div",{className:"inline-flex flex-col rounded-lg shadow-xl overflow-hidden",style:{backgroundColor:o??(r==="dark"?"#1f2937":"#f3f4f6"),width:t},"data-testid":"device-frame","data-device":"browser",children:[e(Y,{theme:r}),e("div",{className:"flex flex-col overflow-hidden bg-white",style:{width:t,height:s},children:a})]})}var F="(prefers-reduced-motion: reduce)",H=()=>typeof window<"u"&&typeof window.matchMedia=="function";function te(){let[a,r]=W(()=>H()&&window.matchMedia(F).matches);return S(()=>{if(!H())return;let t=window.matchMedia(F);r(t.matches);let s=o=>r(o.matches);return t.addEventListener?.("change",s),()=>t.removeEventListener?.("change",s)},[]),a}function se({device:a="phone",src:r,alt:t,children:s,orientation:o="portrait",theme:d="dark",size:n="md",showStatusBar:c=!1,statusBarTime:m,animated:h=!1,scrollSpeed:w=30,frameColor:k,className:L,contentClassName:A}){let E=X(),u=V(k),[g,P]=W(null),T=te(),y=j[a][n],C=o==="landscape"&&(a==="phone"||a==="android"||a==="tablet"),v=C?y.h:y.w,f=C?y.w:y.h;S(()=>{if(!h||T||!g)return;let p=g.scrollTop,D=null,M=requestAnimationFrame(function O(R){let z=D===null?0:Math.min(R-D,250)/1e3;D=R,Math.abs(g.scrollTop-p)>1&&(p=g.scrollTop);let B=g.scrollHeight-g.clientHeight;p=B>0&&p+w*z<B?p+w*z:0,g.scrollTop=p,M=requestAnimationFrame(O)});return()=>cancelAnimationFrame(M)},[h,T,g,w]);let b=e("div",{ref:h?P:void 0,className:l("w-full flex-1 min-h-0 overflow-hidden",h&&"overflow-y-auto scrollbar-hide",A),style:h?{scrollBehavior:"auto"}:void 0,children:r?e("img",{src:r,alt:t??E.deviceMockupAlt,className:"w-full h-auto object-cover",draggable:!1}):s}),N={showStatusBar:c,statusBarTime:m},I=()=>{switch(a){case"phone":return e(_,{theme:d,screenW:v,screenH:f,frameColor:u,landscape:C,...N,children:b});case"android":return e(G,{theme:d,screenW:v,screenH:f,frameColor:u,...N,children:b});case"tablet":return e(J,{theme:d,screenW:v,screenH:f,frameColor:u,...N,children:b});case"laptop":return e(K,{theme:d,screenW:v,screenH:f,frameColor:u,children:b});case"desktop":return e(Z,{theme:d,screenW:v,screenH:f,frameColor:u,children:b});case"watch":return e($,{theme:d,screenW:v,screenH:f,frameColor:u,...N,children:b});case"browser":return e(ee,{theme:d,screenW:v,screenH:f,frameColor:u,children:b})}};return e("div",{className:l("inline-flex",L),"data-testid":"device-mockup","data-orientation":o,"data-theme":d,"data-size":n,children:I()})}export{se as DeviceMockup};
@@ -1 +1 @@
1
- "use strict";var p=Object.defineProperty;var g=Object.getOwnPropertyDescriptor;var v=Object.getOwnPropertyNames;var m=Object.prototype.hasOwnProperty;var c=(t,e)=>{for(var o in e)p(t,o,{get:e[o],enumerable:!0})},y=(t,e,o,d)=>{if(e&&typeof e=="object"||typeof e=="function")for(let r of v(e))!m.call(t,r)&&r!==o&&p(t,r,{get:()=>e[r],enumerable:!(d=g(e,r))||d.enumerable});return t};var D=t=>y(p({},"__esModule",{value:!0}),t);var W={};c(W,{Divider:()=>h});module.exports=D(W);var a=require("../../lib/cn.cjs"),i=require("react/jsx-runtime"),s={solid:"border-solid",dashed:"border-dashed",dotted:"border-dotted"},u={left:{before:"flex-[0.1]",after:"flex-1"},center:{before:"flex-1",after:"flex-1"},right:{before:"flex-1",after:"flex-[0.1]"}};function h({orientation:t="horizontal",variant:e="solid",label:o,textAlign:d="center",thickness:r=1,color:n="border-gray-300 dark:border-gray-700",spacing:l,className:f,...x}){if(t==="vertical")return(0,i.jsx)("hr",{"aria-orientation":"vertical",className:(0,a.cn)("h-full border-l-0 border-r",s[e],n,l||"mx-2",f),style:{borderRightWidth:`${r}px`},...x});if(o){let b=u[d];return(0,i.jsxs)("div",{role:"separator","aria-orientation":"horizontal",className:(0,a.cn)("flex items-center text-sm text-gray-500 dark:text-gray-400",l||"my-4",f),...x,children:[(0,i.jsx)("div",{className:(0,a.cn)("border-t",s[e],n,b.before),style:{borderTopWidth:`${r}px`}}),(0,i.jsx)("span",{className:"px-3 whitespace-nowrap",children:o}),(0,i.jsx)("div",{className:(0,a.cn)("border-t",s[e],n,b.after),style:{borderTopWidth:`${r}px`}})]})}return(0,i.jsx)("hr",{"aria-orientation":"horizontal",className:(0,a.cn)("border-t-0 border-b",s[e],n,l||"my-4",f),style:{borderBottomWidth:`${r}px`},...x})}h.displayName="Divider";0&&(module.exports={Divider});
1
+ "use strict";var p=Object.defineProperty;var g=Object.getOwnPropertyDescriptor;var m=Object.getOwnPropertyNames;var v=Object.prototype.hasOwnProperty;var c=(t,e)=>{for(var o in e)p(t,o,{get:e[o],enumerable:!0})},y=(t,e,o,d)=>{if(e&&typeof e=="object"||typeof e=="function")for(let r of m(e))!v.call(t,r)&&r!==o&&p(t,r,{get:()=>e[r],enumerable:!(d=g(e,r))||d.enumerable});return t};var D=t=>y(p({},"__esModule",{value:!0}),t);var W={};c(W,{Divider:()=>h});module.exports=D(W);var a=require("../../lib/cn.cjs"),i=require("react/jsx-runtime"),s={solid:"border-solid",dashed:"border-dashed",dotted:"border-dotted"},u={left:{before:"flex-[0.1]",after:"flex-1"},center:{before:"flex-1",after:"flex-1"},right:{before:"flex-1",after:"flex-[0.1]"}};function h({orientation:t="horizontal",variant:e="solid",label:o,textAlign:d="center",thickness:r=1,color:n="border-gray-300 dark:border-gray-700",spacing:l,className:f,...x}){if(t==="vertical")return(0,i.jsx)("hr",{"aria-orientation":"vertical",className:(0,a.cn)("h-auto min-h-4 self-stretch border-t-0 border-l-0 border-r",s[e],n,l||"mx-2",f),style:{borderRightWidth:`${r}px`},...x});if(o){let b=u[d];return(0,i.jsxs)("div",{role:"separator","aria-orientation":"horizontal",className:(0,a.cn)("flex items-center text-sm text-gray-500 dark:text-gray-400",l||"my-4",f),...x,children:[(0,i.jsx)("div",{className:(0,a.cn)("border-t",s[e],n,b.before),style:{borderTopWidth:`${r}px`}}),(0,i.jsx)("span",{className:"px-3 whitespace-nowrap",children:o}),(0,i.jsx)("div",{className:(0,a.cn)("border-t",s[e],n,b.after),style:{borderTopWidth:`${r}px`}})]})}return(0,i.jsx)("hr",{"aria-orientation":"horizontal",className:(0,a.cn)("border-t-0 border-b",s[e],n,l||"my-4",f),style:{borderBottomWidth:`${r}px`},...x})}h.displayName="Divider";0&&(module.exports={Divider});