@gridsheet/core 3.0.0-rc.8

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 (250) hide show
  1. package/README.md +17 -0
  2. package/dist/constants.d.ts +21 -0
  3. package/dist/constants.d.ts.map +1 -0
  4. package/dist/constants.js +28 -0
  5. package/dist/constants.js.map +1 -0
  6. package/dist/formula/evaluator.d.ts +134 -0
  7. package/dist/formula/evaluator.d.ts.map +1 -0
  8. package/dist/formula/evaluator.js +585 -0
  9. package/dist/formula/evaluator.js.map +1 -0
  10. package/dist/formula/formula-error.d.ts +10 -0
  11. package/dist/formula/formula-error.d.ts.map +1 -0
  12. package/dist/formula/formula-error.js +15 -0
  13. package/dist/formula/formula-error.js.map +1 -0
  14. package/dist/formula/functions/__async.d.ts +67 -0
  15. package/dist/formula/functions/__async.d.ts.map +1 -0
  16. package/dist/formula/functions/__async.js +70 -0
  17. package/dist/formula/functions/__async.js.map +1 -0
  18. package/dist/formula/functions/__base.d.ts +112 -0
  19. package/dist/formula/functions/__base.d.ts.map +1 -0
  20. package/dist/formula/functions/__base.js +265 -0
  21. package/dist/formula/functions/__base.js.map +1 -0
  22. package/dist/formula/functions/__utils.d.ts +28 -0
  23. package/dist/formula/functions/__utils.d.ts.map +1 -0
  24. package/dist/formula/functions/__utils.js +179 -0
  25. package/dist/formula/functions/__utils.js.map +1 -0
  26. package/dist/formula/functions/abs.d.ts +9 -0
  27. package/dist/formula/functions/abs.d.ts.map +1 -0
  28. package/dist/formula/functions/abs.js +15 -0
  29. package/dist/formula/functions/abs.js.map +1 -0
  30. package/dist/formula/functions/add.d.ts +10 -0
  31. package/dist/formula/functions/add.d.ts.map +1 -0
  32. package/dist/formula/functions/add.js +37 -0
  33. package/dist/formula/functions/add.js.map +1 -0
  34. package/dist/formula/functions/and.d.ts +9 -0
  35. package/dist/formula/functions/and.d.ts.map +1 -0
  36. package/dist/formula/functions/and.js +23 -0
  37. package/dist/formula/functions/and.js.map +1 -0
  38. package/dist/formula/functions/arrayformula.d.ts +12 -0
  39. package/dist/formula/functions/arrayformula.d.ts.map +1 -0
  40. package/dist/formula/functions/arrayformula.js +24 -0
  41. package/dist/formula/functions/arrayformula.js.map +1 -0
  42. package/dist/formula/functions/average.d.ts +9 -0
  43. package/dist/formula/functions/average.d.ts.map +1 -0
  44. package/dist/formula/functions/average.js +40 -0
  45. package/dist/formula/functions/average.js.map +1 -0
  46. package/dist/formula/functions/concat.d.ts +9 -0
  47. package/dist/formula/functions/concat.d.ts.map +1 -0
  48. package/dist/formula/functions/concat.js +27 -0
  49. package/dist/formula/functions/concat.js.map +1 -0
  50. package/dist/formula/functions/count.d.ts +9 -0
  51. package/dist/formula/functions/count.d.ts.map +1 -0
  52. package/dist/formula/functions/count.js +32 -0
  53. package/dist/formula/functions/count.js.map +1 -0
  54. package/dist/formula/functions/counta.d.ts +9 -0
  55. package/dist/formula/functions/counta.d.ts.map +1 -0
  56. package/dist/formula/functions/counta.js +32 -0
  57. package/dist/formula/functions/counta.js.map +1 -0
  58. package/dist/formula/functions/divide.d.ts +10 -0
  59. package/dist/formula/functions/divide.d.ts.map +1 -0
  60. package/dist/formula/functions/divide.js +34 -0
  61. package/dist/formula/functions/divide.js.map +1 -0
  62. package/dist/formula/functions/eq.d.ts +9 -0
  63. package/dist/formula/functions/eq.d.ts.map +1 -0
  64. package/dist/formula/functions/eq.js +19 -0
  65. package/dist/formula/functions/eq.js.map +1 -0
  66. package/dist/formula/functions/gt.d.ts +9 -0
  67. package/dist/formula/functions/gt.d.ts.map +1 -0
  68. package/dist/formula/functions/gt.js +19 -0
  69. package/dist/formula/functions/gt.js.map +1 -0
  70. package/dist/formula/functions/gte.d.ts +9 -0
  71. package/dist/formula/functions/gte.d.ts.map +1 -0
  72. package/dist/formula/functions/gte.js +19 -0
  73. package/dist/formula/functions/gte.js.map +1 -0
  74. package/dist/formula/functions/if.d.ts +9 -0
  75. package/dist/formula/functions/if.d.ts.map +1 -0
  76. package/dist/formula/functions/if.js +29 -0
  77. package/dist/formula/functions/if.js.map +1 -0
  78. package/dist/formula/functions/iferror.d.ts +10 -0
  79. package/dist/formula/functions/iferror.d.ts.map +1 -0
  80. package/dist/formula/functions/iferror.js +28 -0
  81. package/dist/formula/functions/iferror.js.map +1 -0
  82. package/dist/formula/functions/len.d.ts +9 -0
  83. package/dist/formula/functions/len.d.ts.map +1 -0
  84. package/dist/formula/functions/len.js +21 -0
  85. package/dist/formula/functions/len.js.map +1 -0
  86. package/dist/formula/functions/lt.d.ts +9 -0
  87. package/dist/formula/functions/lt.d.ts.map +1 -0
  88. package/dist/formula/functions/lt.js +19 -0
  89. package/dist/formula/functions/lt.js.map +1 -0
  90. package/dist/formula/functions/lte.d.ts +9 -0
  91. package/dist/formula/functions/lte.d.ts.map +1 -0
  92. package/dist/formula/functions/lte.js +19 -0
  93. package/dist/formula/functions/lte.js.map +1 -0
  94. package/dist/formula/functions/max.d.ts +9 -0
  95. package/dist/formula/functions/max.d.ts.map +1 -0
  96. package/dist/formula/functions/max.js +37 -0
  97. package/dist/formula/functions/max.js.map +1 -0
  98. package/dist/formula/functions/min.d.ts +9 -0
  99. package/dist/formula/functions/min.d.ts.map +1 -0
  100. package/dist/formula/functions/min.js +37 -0
  101. package/dist/formula/functions/min.js.map +1 -0
  102. package/dist/formula/functions/minus.d.ts +10 -0
  103. package/dist/formula/functions/minus.d.ts.map +1 -0
  104. package/dist/formula/functions/minus.js +41 -0
  105. package/dist/formula/functions/minus.js.map +1 -0
  106. package/dist/formula/functions/multiply.d.ts +9 -0
  107. package/dist/formula/functions/multiply.d.ts.map +1 -0
  108. package/dist/formula/functions/multiply.js +19 -0
  109. package/dist/formula/functions/multiply.js.map +1 -0
  110. package/dist/formula/functions/ne.d.ts +9 -0
  111. package/dist/formula/functions/ne.d.ts.map +1 -0
  112. package/dist/formula/functions/ne.js +19 -0
  113. package/dist/formula/functions/ne.js.map +1 -0
  114. package/dist/formula/functions/not.d.ts +9 -0
  115. package/dist/formula/functions/not.d.ts.map +1 -0
  116. package/dist/formula/functions/not.js +22 -0
  117. package/dist/formula/functions/not.js.map +1 -0
  118. package/dist/formula/functions/now.d.ts +9 -0
  119. package/dist/formula/functions/now.d.ts.map +1 -0
  120. package/dist/formula/functions/now.js +14 -0
  121. package/dist/formula/functions/now.js.map +1 -0
  122. package/dist/formula/functions/or.d.ts +9 -0
  123. package/dist/formula/functions/or.d.ts.map +1 -0
  124. package/dist/formula/functions/or.js +23 -0
  125. package/dist/formula/functions/or.js.map +1 -0
  126. package/dist/formula/functions/power.d.ts +9 -0
  127. package/dist/formula/functions/power.d.ts.map +1 -0
  128. package/dist/formula/functions/power.js +18 -0
  129. package/dist/formula/functions/power.js.map +1 -0
  130. package/dist/formula/functions/sum.d.ts +9 -0
  131. package/dist/formula/functions/sum.d.ts.map +1 -0
  132. package/dist/formula/functions/sum.js +34 -0
  133. package/dist/formula/functions/sum.js.map +1 -0
  134. package/dist/formula/functions/uminus.d.ts +9 -0
  135. package/dist/formula/functions/uminus.d.ts.map +1 -0
  136. package/dist/formula/functions/uminus.js +17 -0
  137. package/dist/formula/functions/uminus.js.map +1 -0
  138. package/dist/formula/mapping.d.ts +11 -0
  139. package/dist/formula/mapping.d.ts.map +1 -0
  140. package/dist/formula/mapping.js +82 -0
  141. package/dist/formula/mapping.js.map +1 -0
  142. package/dist/formula/solver.d.ts +39 -0
  143. package/dist/formula/solver.d.ts.map +1 -0
  144. package/dist/formula/solver.js +71 -0
  145. package/dist/formula/solver.js.map +1 -0
  146. package/dist/index.d.ts +22 -0
  147. package/dist/index.d.ts.map +1 -0
  148. package/dist/index.js +74 -0
  149. package/dist/index.js.map +1 -0
  150. package/dist/lib/autofill.d.ts +22 -0
  151. package/dist/lib/autofill.d.ts.map +1 -0
  152. package/dist/lib/autofill.js +276 -0
  153. package/dist/lib/autofill.js.map +1 -0
  154. package/dist/lib/book.d.ts +131 -0
  155. package/dist/lib/book.d.ts.map +1 -0
  156. package/dist/lib/book.js +53 -0
  157. package/dist/lib/book.js.map +1 -0
  158. package/dist/lib/cell.d.ts +17 -0
  159. package/dist/lib/cell.d.ts.map +1 -0
  160. package/dist/lib/cell.js +17 -0
  161. package/dist/lib/cell.js.map +1 -0
  162. package/dist/lib/coords.d.ts +22 -0
  163. package/dist/lib/coords.d.ts.map +1 -0
  164. package/dist/lib/coords.js +73 -0
  165. package/dist/lib/coords.js.map +1 -0
  166. package/dist/lib/date.d.ts +2 -0
  167. package/dist/lib/date.d.ts.map +1 -0
  168. package/dist/lib/date.js +91 -0
  169. package/dist/lib/date.js.map +1 -0
  170. package/dist/lib/dom.d.ts +7 -0
  171. package/dist/lib/dom.d.ts.map +1 -0
  172. package/dist/lib/dom.js +28 -0
  173. package/dist/lib/dom.js.map +1 -0
  174. package/dist/lib/filter.d.ts +7 -0
  175. package/dist/lib/filter.d.ts.map +1 -0
  176. package/dist/lib/filter.js +122 -0
  177. package/dist/lib/filter.js.map +1 -0
  178. package/dist/lib/input.d.ts +28 -0
  179. package/dist/lib/input.d.ts.map +1 -0
  180. package/dist/lib/input.js +73 -0
  181. package/dist/lib/input.js.map +1 -0
  182. package/dist/lib/label.d.ts +4 -0
  183. package/dist/lib/label.d.ts.map +1 -0
  184. package/dist/lib/label.js +10 -0
  185. package/dist/lib/label.js.map +1 -0
  186. package/dist/lib/operation.d.ts +31 -0
  187. package/dist/lib/operation.d.ts.map +1 -0
  188. package/dist/lib/operation.js +36 -0
  189. package/dist/lib/operation.js.map +1 -0
  190. package/dist/lib/palette.d.ts +2 -0
  191. package/dist/lib/palette.d.ts.map +1 -0
  192. package/dist/lib/palette.js +26 -0
  193. package/dist/lib/palette.js.map +1 -0
  194. package/dist/lib/popup.d.ts +24 -0
  195. package/dist/lib/popup.d.ts.map +1 -0
  196. package/dist/lib/popup.js +21 -0
  197. package/dist/lib/popup.js.map +1 -0
  198. package/dist/lib/reference.d.ts +19 -0
  199. package/dist/lib/reference.d.ts.map +1 -0
  200. package/dist/lib/reference.js +40 -0
  201. package/dist/lib/reference.js.map +1 -0
  202. package/dist/lib/sheet.d.ts +512 -0
  203. package/dist/lib/sheet.d.ts.map +1 -0
  204. package/dist/lib/sheet.js +1530 -0
  205. package/dist/lib/sheet.js.map +1 -0
  206. package/dist/lib/sheet_utils.d.ts +55 -0
  207. package/dist/lib/sheet_utils.d.ts.map +1 -0
  208. package/dist/lib/sheet_utils.js +125 -0
  209. package/dist/lib/sheet_utils.js.map +1 -0
  210. package/dist/lib/spatial.d.ts +79 -0
  211. package/dist/lib/spatial.d.ts.map +1 -0
  212. package/dist/lib/spatial.js +227 -0
  213. package/dist/lib/spatial.js.map +1 -0
  214. package/dist/lib/time.d.ts +29 -0
  215. package/dist/lib/time.d.ts.map +1 -0
  216. package/dist/lib/time.js +113 -0
  217. package/dist/lib/time.js.map +1 -0
  218. package/dist/lib/virtualization.d.ts +22 -0
  219. package/dist/lib/virtualization.d.ts.map +1 -0
  220. package/dist/lib/virtualization.js +91 -0
  221. package/dist/lib/virtualization.js.map +1 -0
  222. package/dist/policy/core.d.ts +161 -0
  223. package/dist/policy/core.d.ts.map +1 -0
  224. package/dist/policy/core.js +248 -0
  225. package/dist/policy/core.js.map +1 -0
  226. package/dist/policy/thousand_separator.d.ts +4 -0
  227. package/dist/policy/thousand_separator.d.ts.map +1 -0
  228. package/dist/policy/thousand_separator.js +13 -0
  229. package/dist/policy/thousand_separator.js.map +1 -0
  230. package/dist/sentinels.d.ts +40 -0
  231. package/dist/sentinels.d.ts.map +1 -0
  232. package/dist/sentinels.js +41 -0
  233. package/dist/sentinels.js.map +1 -0
  234. package/dist/styles/embedder.d.ts +2 -0
  235. package/dist/styles/embedder.d.ts.map +1 -0
  236. package/dist/styles/embedder.js +11 -0
  237. package/dist/styles/embedder.js.map +1 -0
  238. package/dist/styles/minified.d.ts +3 -0
  239. package/dist/styles/minified.d.ts.map +1 -0
  240. package/dist/styles/minified.js +6 -0
  241. package/dist/styles/minified.js.map +1 -0
  242. package/dist/types.d.ts +310 -0
  243. package/dist/types.d.ts.map +1 -0
  244. package/dist/types.js +2 -0
  245. package/dist/types.js.map +1 -0
  246. package/dist/utils.d.ts +2 -0
  247. package/dist/utils.d.ts.map +1 -0
  248. package/dist/utils.js +5 -0
  249. package/dist/utils.js.map +1 -0
  250. package/package.json +59 -0
@@ -0,0 +1,79 @@
1
+ import { MatrixType, AreaType, ZoneType, RangeType, PointType, CellsByAddressType, ShapeType, MatricesByAddress, CellType, Address } from '../types';
2
+ export declare const superposeArea: (srcArea: AreaType, dstArea: AreaType) => ShapeType;
3
+ export declare const concatAreas: (area1: AreaType, area2: AreaType) => AreaType;
4
+ export declare const zoneToArea: (zone: ZoneType) => AreaType;
5
+ export declare const areaToZone: (area: AreaType) => ZoneType;
6
+ export declare const areaToRange: (area: AreaType) => string;
7
+ export declare const between: (range: RangeType, index: number) => boolean;
8
+ export declare const among: (area: AreaType, point: PointType) => boolean;
9
+ type ShapeExtension = {
10
+ base?: number;
11
+ };
12
+ export declare const zoneDiff: (zone: ZoneType) => ShapeType;
13
+ export declare const zoneShape: (zone: ZoneType) => ShapeType;
14
+ export declare const areaDiff: (area: AreaType) => ShapeType;
15
+ export declare const areaShape: (area: AreaType) => ShapeType;
16
+ export declare const matrixShape: ({ base, matrix }: {
17
+ matrix: MatrixType;
18
+ } & ShapeExtension) => ShapeType;
19
+ export declare const makeSequence: (start: number, stop: number, step?: number) => number[];
20
+ export declare const oa2aa: (oa: {
21
+ [s: string]: any;
22
+ }[], fields: string[]) => MatrixType;
23
+ export declare const aa2oa: (aa: MatrixType, fields: string[]) => {
24
+ [s: string]: any;
25
+ }[];
26
+ export declare const createMatrix: <T = any>(numRows: number, numCols: number, fill?: T) => T[][];
27
+ export declare const buildInitialCellsFromOrigin: ({ cells, ensured, matrix, flattenAs, origin, }: {
28
+ cells?: CellsByAddressType;
29
+ ensured?: {
30
+ numRows?: number;
31
+ numCols?: number;
32
+ };
33
+ flattenAs?: keyof CellType;
34
+ matrix?: MatrixType;
35
+ origin?: Address;
36
+ }) => CellsByAddressType;
37
+ export declare const buildInitialCells: ({ cells, ensured, matrices, flattenAs, }?: {
38
+ cells?: CellsByAddressType;
39
+ ensured?: {
40
+ numRows?: number;
41
+ numCols?: number;
42
+ };
43
+ flattenAs?: keyof CellType;
44
+ matrices?: MatricesByAddress<any>;
45
+ }) => CellsByAddressType;
46
+ export declare const buildCells: <T>({ cells, matrices, flattenAs, }: {
47
+ cells?: CellsByAddressType;
48
+ flattenAs?: keyof CellType;
49
+ matrices?: MatricesByAddress<T>;
50
+ }) => CellsByAddressType;
51
+ export declare const getMaxSizesFromCells: (cells?: CellsByAddressType) => {
52
+ numRows: number;
53
+ numCols: number;
54
+ };
55
+ export declare const range: (start: number, end: number) => number[];
56
+ export declare const complementSelectingArea: (selectingArea: AreaType, choosing: PointType) => AreaType;
57
+ export declare const expandRange: (range: string) => Address[];
58
+ export declare const restrictZone: (zone: ZoneType) => ZoneType;
59
+ export type BinarySearchPredicate = (mid: number) => boolean;
60
+ export declare const binarySearch: (low: number, high: number, predicate: BinarySearchPredicate, lessThan: boolean) => number;
61
+ /**
62
+ * Convert a list of addresses into an array of bounding areas.
63
+ * Adjacent cells (4-connected: up/down/left/right) are grouped into the same area.
64
+ * Each resulting AreaType is the bounding rectangle of one connected group.
65
+ */
66
+ export declare const addressesToAreas: (addresses: Address[]) => AreaType[];
67
+ /**
68
+ * Extract unique column indices (x) from a list of addresses, ignoring row information.
69
+ * @param asc - true: ascending, false: descending, null: insertion order
70
+ */
71
+ export declare const addressesToCols: (addresses: Address[], asc?: boolean | null) => number[];
72
+ /**
73
+ * Extract unique row indices (y) from a list of addresses, ignoring column information.
74
+ * @param asc - true: ascending, false: descending, null: insertion order
75
+ */
76
+ export declare const addressesToRows: (addresses: Address[], asc?: boolean | null) => number[];
77
+ export declare const isZoneNotSelected: (zone: ZoneType) => boolean;
78
+ export {};
79
+ //# sourceMappingURL=spatial.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"spatial.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CAAC;CACjC,uBAiBA,CAAC;AAEF,eAAO,MAAM,oBAAoB,GAAI,QAAO,kBAAuB;;;CAelE,CAAC;AAEF,eAAO,MAAM,KAAK,GAAI,OAAO,MAAM,EAAE,KAAK,MAAM,aAM/C,CAAC;AAEF,eAAO,MAAM,uBAAuB,GAAI,eAAe,QAAQ,EAAE,UAAU,SAAS,aAUnF,CAAC;AAEF,eAAO,MAAM,WAAW,GAAI,OAAO,MAAM,KAAG,OAAO,EAsClD,CAAC;AAGF,eAAO,MAAM,YAAY,GAAI,MAAM,QAAQ,KAAG,QAM7C,CAAC;AAEF,MAAM,MAAM,qBAAqB,GAAG,CAAC,GAAG,EAAE,MAAM,KAAK,OAAO,CAAC;AAE7D,eAAO,MAAM,YAAY,GACvB,KAAK,MAAM,EACX,MAAM,MAAM,EACZ,WAAW,qBAAqB,EAChC,UAAU,OAAO,KAChB,MAkBF,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,gBAAgB,GAAI,WAAW,OAAO,EAAE,KAAG,QAAQ,EA8D/D,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,eAAe,GAAI,WAAW,OAAO,EAAE,EAAE,MAAK,OAAO,GAAG,IAAW,KAAG,MAAM,EAgBxF,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,eAAe,GAAI,WAAW,OAAO,EAAE,EAAE,MAAK,OAAO,GAAG,IAAW,KAAG,MAAM,EAgBxF,CAAC;AAEF,eAAO,MAAM,iBAAiB,GAAI,MAAM,QAAQ,KAAG,OAElD,CAAC"}
@@ -0,0 +1,227 @@
1
+ import { DEFAULT_KEY as R, DEFAULT_COL_KEY as C, DEFAULT_ROW_KEY as E } from "../constants.js";
2
+ import { p2a as p, a2p as b, c2x as Y, x2c as g } from "./coords.js";
3
+ const O = (t, o) => {
4
+ const { rows: s, cols: n } = X(t), { rows: r, cols: e } = X(o);
5
+ return {
6
+ rows: s > r ? s : r,
7
+ cols: n > e ? n : e
8
+ };
9
+ }, k = (t, o) => {
10
+ const s = { ...t };
11
+ return o.left < t.left && (s.left = o.left), o.right > t.right && (s.right = o.right), o.top < t.top && (s.top = o.top), o.bottom > t.bottom && (s.bottom = o.bottom), s;
12
+ }, _ = (t) => {
13
+ if (t.endY === -1 || t.endX === -1)
14
+ return { top: -1, left: -1, bottom: -1, right: -1 };
15
+ const [o, s] = t.startY < t.endY ? [t.startY, t.endY] : [t.endY, t.startY], [n, r] = t.startX < t.endX ? [t.startX, t.endX] : [t.endX, t.startX];
16
+ return { top: o, left: n, bottom: s, right: r };
17
+ }, D = (t) => ({
18
+ startY: t.top,
19
+ startX: t.left,
20
+ endY: t.bottom,
21
+ endX: t.right
22
+ }), F = (t) => {
23
+ const { top: o, left: s, bottom: n, right: r } = t;
24
+ if (o === n && s === r)
25
+ return p({ y: o, x: s });
26
+ const e = p({ y: o, x: s }), c = p({ y: n, x: r });
27
+ return `${e}:${c}`;
28
+ }, I = (t, o) => t.start === -1 || t.end === -1 ? !1 : t.start <= o && o <= t.end || t.end <= o && o <= t.start, Z = (t, o) => {
29
+ if (t.top === -1 || t.left === -1 || t.bottom === -1 || t.right === -1)
30
+ return !1;
31
+ const { y: s, x: n } = o, { top: r, left: e, bottom: c, right: f } = t;
32
+ return r <= s && s <= c && e <= n && n <= f;
33
+ }, S = (t) => t.endY === -1 || t.endX === -1 ? { rows: 0, cols: 0 } : {
34
+ rows: Math.abs(t.startY - t.endY),
35
+ cols: Math.abs(t.startX - t.endX)
36
+ }, v = (t) => t.endY === -1 || t.endX === -1 ? { rows: 1, cols: 1 } : {
37
+ rows: 1 + Math.abs(t.startY - t.endY),
38
+ cols: 1 + Math.abs(t.startX - t.endX)
39
+ }, X = (t) => ({
40
+ rows: Math.abs(t.top - t.bottom),
41
+ cols: Math.abs(t.left - t.right)
42
+ }), L = (t) => ({
43
+ rows: 1 + Math.abs(t.top - t.bottom),
44
+ cols: 1 + Math.abs(t.left - t.right)
45
+ }), N = ({ base: t = 0, matrix: o }) => {
46
+ const s = o.length;
47
+ return s === 0 ? { rows: 0, cols: 0 } : { rows: t + s, cols: t + o[0].length };
48
+ }, j = (t, o, s = 1) => Array.from({ length: (o - t - 1) / s + 1 }, (n, r) => t + r * s), K = (t, o) => {
49
+ const s = [];
50
+ return t.forEach((n) => {
51
+ const r = [];
52
+ o.forEach((e) => {
53
+ r.push(n[e]);
54
+ }), s.push(r);
55
+ }), s;
56
+ }, U = (t, o) => {
57
+ const s = [];
58
+ return t.forEach((n) => {
59
+ const r = {};
60
+ n.forEach((e, c) => {
61
+ if (c >= o.length)
62
+ return;
63
+ const f = o[c];
64
+ r[f] = e;
65
+ }), s.push(r);
66
+ }), s;
67
+ }, q = (t, o, s) => [...Array(t)].map(() => Array(o).fill(s)), B = ({
68
+ cells: t = {},
69
+ ensured: o = {},
70
+ matrix: s = [],
71
+ flattenAs: n = "value",
72
+ origin: r = "A1"
73
+ }) => M({
74
+ cells: t,
75
+ ensured: o,
76
+ matrices: { [r]: s },
77
+ flattenAs: n
78
+ }), M = ({
79
+ cells: t = {},
80
+ ensured: o = {},
81
+ matrices: s = {},
82
+ flattenAs: n = "value"
83
+ } = {}) => {
84
+ A({ cells: t, flattenAs: n, matrices: s });
85
+ const { numRows: r, numCols: e } = Object.assign({ numRows: 1, numCols: 1 }, o), c = p({ y: r, x: e });
86
+ return t[c] == null && (t[c] = {}), t;
87
+ }, A = ({
88
+ cells: t = {},
89
+ matrices: o = {},
90
+ flattenAs: s
91
+ }) => (Object.keys(o).forEach((n) => {
92
+ const r = o[n], { y: e, x: c } = b(n);
93
+ r.forEach((f, a) => {
94
+ f.forEach((d, l) => {
95
+ const i = p({ y: e + a, x: c + l });
96
+ if (s) {
97
+ const u = t[i];
98
+ t[i] = { [s]: d, ...u };
99
+ } else
100
+ t[i] = d;
101
+ });
102
+ });
103
+ }), t), W = (t = {}) => {
104
+ let [o, s] = [0, 0];
105
+ return Object.keys(t).forEach((n) => {
106
+ if (n === R || n === C || n === E)
107
+ return;
108
+ const { y: r, x: e } = b(n);
109
+ o < r && (o = r), s < e && (s = e);
110
+ }), { numRows: o, numCols: s };
111
+ }, G = (t, o) => {
112
+ const s = [];
113
+ for (let n = t; n <= o; n++)
114
+ s.push(n);
115
+ return s;
116
+ }, H = (t, o) => (t.left === -1 && (t = {
117
+ left: o.x,
118
+ top: o.y,
119
+ right: o.x,
120
+ bottom: o.y
121
+ }), t), J = (t) => {
122
+ if (t.indexOf(":") === -1)
123
+ return [t];
124
+ const o = [];
125
+ if (/^\d+\:\d+$/.test(t)) {
126
+ const [l, i] = t.split(":").map(Number);
127
+ for (let u = l; u <= i; u++)
128
+ o.push(`${u}`);
129
+ return o;
130
+ }
131
+ const n = t.match(/^([A-Z]*)(\d+)?\:([A-Z]*)(\d+)?$/);
132
+ if (!n)
133
+ return console.error("Invalid range format", t), [t];
134
+ const [, r, e, c, f] = n, a = r ? Y(r) : 1, d = c ? Y(c) : 1;
135
+ for (let l = a; l <= d; l++) {
136
+ const i = r || c ? g(l) : "";
137
+ if (e && f)
138
+ for (let u = Number(e); u <= Number(f); u++)
139
+ o.push(`${i}${u}`);
140
+ else !e && !f && o.push(i);
141
+ }
142
+ return o;
143
+ }, P = (t) => {
144
+ const o = S(t);
145
+ return o.rows + o.cols === 0 ? { startY: -1, startX: -1, endY: -1, endX: -1 } : { ...t };
146
+ }, Q = (t, o, s, n) => {
147
+ for (; t <= o; ) {
148
+ const r = Math.floor((t + o) / 2);
149
+ s(r) ? n ? o = r - 1 : t = r + 1 : n ? t = r + 1 : o = r - 1;
150
+ }
151
+ return n ? t : o;
152
+ }, V = (t) => {
153
+ if (t.length === 0)
154
+ return [];
155
+ const o = t.map((c) => {
156
+ const { y: f, x: a } = b(c);
157
+ return { y: f, x: a };
158
+ }), s = (c, f) => `${c},${f}`, n = new Set(o.map((c) => s(c.y, c.x))), r = /* @__PURE__ */ new Set(), e = [];
159
+ for (const c of o) {
160
+ const f = s(c.y, c.x);
161
+ if (r.has(f))
162
+ continue;
163
+ let a = c.y, d = c.x, l = c.y, i = c.x;
164
+ const u = [c];
165
+ for (r.add(f); u.length > 0; ) {
166
+ const { y: h, x: m } = u.shift();
167
+ h < a && (a = h), h > l && (l = h), m < d && (d = m), m > i && (i = m);
168
+ for (const [x, y] of [
169
+ [0, 1],
170
+ [0, -1],
171
+ [1, 0],
172
+ [-1, 0]
173
+ ]) {
174
+ const w = s(h + x, m + y);
175
+ n.has(w) && !r.has(w) && (r.add(w), u.push({ y: h + x, x: m + y }));
176
+ }
177
+ }
178
+ e.push({ top: a, left: d, bottom: l, right: i });
179
+ }
180
+ return e;
181
+ }, z = (t, o = !0) => {
182
+ const s = /* @__PURE__ */ new Set(), n = [];
183
+ for (const r of t) {
184
+ const { x: e } = b(r);
185
+ s.has(e) || (s.add(e), n.push(e));
186
+ }
187
+ return o === !0 ? n.sort((r, e) => r - e) : o === !1 && n.sort((r, e) => e - r), n;
188
+ }, tt = (t, o = !0) => {
189
+ const s = /* @__PURE__ */ new Set(), n = [];
190
+ for (const r of t) {
191
+ const { y: e } = b(r);
192
+ s.has(e) || (s.add(e), n.push(e));
193
+ }
194
+ return o === !0 ? n.sort((r, e) => r - e) : o === !1 && n.sort((r, e) => e - r), n;
195
+ }, ot = (t) => t.startY === -1 || t.startX === -1 || t.endY === -1 || t.endX === -1;
196
+ export {
197
+ U as aa2oa,
198
+ V as addressesToAreas,
199
+ z as addressesToCols,
200
+ tt as addressesToRows,
201
+ Z as among,
202
+ X as areaDiff,
203
+ L as areaShape,
204
+ F as areaToRange,
205
+ D as areaToZone,
206
+ I as between,
207
+ Q as binarySearch,
208
+ A as buildCells,
209
+ M as buildInitialCells,
210
+ B as buildInitialCellsFromOrigin,
211
+ H as complementSelectingArea,
212
+ k as concatAreas,
213
+ q as createMatrix,
214
+ J as expandRange,
215
+ W as getMaxSizesFromCells,
216
+ ot as isZoneNotSelected,
217
+ j as makeSequence,
218
+ N as matrixShape,
219
+ K as oa2aa,
220
+ G as range,
221
+ P as restrictZone,
222
+ O as superposeArea,
223
+ S as zoneDiff,
224
+ v as zoneShape,
225
+ _ as zoneToArea
226
+ };
227
+ //# sourceMappingURL=spatial.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"spatial.js","sources":["../../src/lib/spatial.ts"],"sourcesContent":["import { DEFAULT_KEY, DEFAULT_COL_KEY, DEFAULT_ROW_KEY } from '../constants';\nimport type {\n MatrixType,\n AreaType,\n ZoneType,\n RangeType,\n PointType,\n CellsByAddressType,\n ShapeType,\n MatricesByAddress,\n CellType,\n Address,\n} from '../types';\nimport { a2p, p2a, x2c, c2x } from './coords';\n\nexport const superposeArea = (srcArea: AreaType, dstArea: AreaType): ShapeType => {\n const { rows: srcRows, cols: srcCols } = areaDiff(srcArea);\n const { rows: dstRows, cols: dstCols } = areaDiff(dstArea);\n\n // biggerRows, biggerCols\n return {\n rows: srcRows > dstRows ? srcRows : dstRows,\n cols: srcCols > dstCols ? srcCols : dstCols,\n };\n};\n\nexport const concatAreas = (area1: AreaType, area2: AreaType): AreaType => {\n const result: AreaType = { ...area1 };\n if (area2.left < area1.left) {\n result.left = area2.left;\n }\n if (area2.right > area1.right) {\n result.right = area2.right;\n }\n if (area2.top < area1.top) {\n result.top = area2.top;\n }\n if (area2.bottom > area1.bottom) {\n result.bottom = area2.bottom;\n }\n return result;\n};\n\nexport const zoneToArea = (zone: ZoneType): AreaType => {\n if (zone.endY === -1 || zone.endX === -1) {\n return { top: -1, left: -1, bottom: -1, right: -1 };\n }\n const [top, bottom] = zone.startY < zone.endY ? [zone.startY, zone.endY] : [zone.endY, zone.startY];\n const [left, right] = zone.startX < zone.endX ? [zone.startX, zone.endX] : [zone.endX, zone.startX];\n return { top, left, bottom, right };\n};\n\nexport const areaToZone = (area: AreaType): ZoneType => {\n return {\n startY: area.top,\n startX: area.left,\n endY: area.bottom,\n endX: area.right,\n };\n};\n\nexport const areaToRange = (area: AreaType): string => {\n const { top, left, bottom, right } = area;\n if (top === bottom && left === right) {\n return p2a({ y: top, x: left });\n }\n const leftTop = p2a({ y: top, x: left });\n const rightBottom = p2a({ y: bottom, x: right });\n return `${leftTop}:${rightBottom}`;\n};\n\nexport const between = (range: RangeType, index: number) => {\n if (range.start === -1 || range.end === -1) {\n return false;\n }\n return (range.start <= index && index <= range.end) || (range.end <= index && index <= range.start);\n};\n\nexport const among = (area: AreaType, point: PointType) => {\n if (area.top === -1 || area.left === -1 || area.bottom === -1 || area.right === -1) {\n return false;\n }\n const { y, x } = point;\n const { top, left, bottom, right } = area;\n return top <= y && y <= bottom && left <= x && x <= right;\n};\n\ntype ShapeExtension = { base?: number };\n\nexport const zoneDiff = (zone: ZoneType): ShapeType => {\n if (zone.endY === -1 || zone.endX === -1) {\n return { rows: 0, cols: 0 };\n }\n return {\n rows: Math.abs(zone.startY - zone.endY),\n cols: Math.abs(zone.startX - zone.endX),\n };\n};\n\nexport const zoneShape = (zone: ZoneType): ShapeType => {\n if (zone.endY === -1 || zone.endX === -1) {\n return { rows: 1, cols: 1 };\n }\n return {\n rows: 1 + Math.abs(zone.startY - zone.endY),\n cols: 1 + Math.abs(zone.startX - zone.endX),\n };\n};\n\nexport const areaDiff = (area: AreaType): ShapeType => {\n return {\n rows: Math.abs(area.top - area.bottom),\n cols: Math.abs(area.left - area.right),\n };\n};\n\nexport const areaShape = (area: AreaType): ShapeType => {\n return {\n rows: 1 + Math.abs(area.top - area.bottom),\n cols: 1 + Math.abs(area.left - area.right),\n };\n};\n\nexport const matrixShape = ({ base = 0, matrix }: { matrix: MatrixType } & ShapeExtension): ShapeType => {\n const h = matrix.length;\n if (h === 0) {\n return { rows: 0, cols: 0 };\n }\n return { rows: base + h, cols: base + matrix[0].length };\n};\n\nexport const makeSequence = (start: number, stop: number, step: number = 1) => {\n return Array.from({ length: (stop - start - 1) / step + 1 }, (_, i) => start + i * step);\n};\n\nexport const oa2aa = (oa: { [s: string]: any }[], fields: string[]): MatrixType => {\n const aa: any[][] = [];\n oa.forEach((o) => {\n const a: any[] = [];\n fields.forEach((field) => {\n a.push(o[field]);\n });\n aa.push(a);\n });\n return aa;\n};\n\nexport const aa2oa = (aa: MatrixType, fields: string[]): { [s: string]: any }[] => {\n const oa: { [s: string]: any }[] = [];\n aa.forEach((a) => {\n const o: { [s: string]: any } = {};\n a.forEach((v, i) => {\n if (i >= fields.length) {\n return;\n }\n const field = fields[i];\n o[field] = v;\n });\n oa.push(o);\n });\n return oa;\n};\n\nexport const createMatrix = <T = any>(numRows: number, numCols: number, fill?: T): T[][] => {\n return [...Array(numRows)].map(() => Array(numCols).fill(fill));\n};\n\nexport const buildInitialCellsFromOrigin = ({\n cells = {},\n ensured = {},\n matrix = [],\n flattenAs = 'value',\n origin = 'A1',\n}: {\n cells?: CellsByAddressType;\n ensured?: {\n numRows?: number;\n numCols?: number;\n };\n flattenAs?: keyof CellType;\n matrix?: MatrixType;\n origin?: Address;\n}) => {\n return buildInitialCells({\n cells,\n ensured,\n matrices: { [origin]: matrix },\n flattenAs,\n });\n};\n\nexport const buildInitialCells = ({\n cells = {},\n ensured = {},\n matrices = {},\n flattenAs = 'value',\n}: {\n cells?: CellsByAddressType;\n ensured?: {\n numRows?: number;\n numCols?: number;\n };\n flattenAs?: keyof CellType;\n matrices?: MatricesByAddress<any>;\n} = {}) => {\n buildCells({ cells, flattenAs, matrices });\n const { numRows, numCols } = Object.assign({ numRows: 1, numCols: 1 }, ensured);\n const rightBottom = p2a({ y: numRows, x: numCols });\n if (cells[rightBottom] == null) {\n cells[rightBottom] = {};\n }\n return cells;\n};\n\nexport const buildCells = <T>({\n cells = {},\n matrices = {},\n flattenAs,\n}: {\n cells?: CellsByAddressType;\n flattenAs?: keyof CellType;\n matrices?: MatricesByAddress<T>;\n}) => {\n Object.keys(matrices).forEach((baseAddress) => {\n const matrix = matrices[baseAddress];\n const { y: baseY, x: baseX } = a2p(baseAddress);\n matrix.forEach((row, y) => {\n row.forEach((e, x) => {\n const id = p2a({ y: baseY + y, x: baseX + x });\n if (flattenAs) {\n const cell = cells[id];\n cells[id] = { [flattenAs]: e, ...cell };\n } else {\n cells[id] = e as CellType;\n }\n });\n });\n });\n return cells;\n};\n\nexport const getMaxSizesFromCells = (cells: CellsByAddressType = {}) => {\n let [lastY, lastX] = [0, 0];\n Object.keys(cells).forEach((address) => {\n if (address === DEFAULT_KEY || address === DEFAULT_COL_KEY || address === DEFAULT_ROW_KEY) {\n return;\n }\n const { y, x } = a2p(address);\n if (lastY < y) {\n lastY = y;\n }\n if (lastX < x) {\n lastX = x;\n }\n });\n return { numRows: lastY, numCols: lastX };\n};\n\nexport const range = (start: number, end: number) => {\n const list: number[] = [];\n for (let i = start; i <= end; i++) {\n list.push(i);\n }\n return list;\n};\n\nexport const complementSelectingArea = (selectingArea: AreaType, choosing: PointType) => {\n if (selectingArea.left === -1) {\n selectingArea = {\n left: choosing.x,\n top: choosing.y,\n right: choosing.x,\n bottom: choosing.y,\n };\n }\n return selectingArea;\n};\n\nexport const expandRange = (range: string): Address[] => {\n if (range.indexOf(':') === -1) {\n return [range];\n }\n\n const result: Address[] = [];\n\n const isRowRange = /^\\d+\\:\\d+$/.test(range);\n\n if (isRowRange) {\n const [startRow, endRow] = range.split(':').map(Number);\n for (let row = startRow; row <= endRow; row++) {\n result.push(`${row}`);\n }\n return result;\n }\n\n const match = range.match(/^([A-Z]*)(\\d+)?\\:([A-Z]*)(\\d+)?$/);\n if (!match) {\n console.error('Invalid range format', range);\n return [range];\n }\n\n const [, startCol, startRow, endCol, endRow] = match;\n const startColIndex = startCol ? c2x(startCol) : 1;\n const endColIndex = endCol ? c2x(endCol) : 1;\n\n for (let col = startColIndex; col <= endColIndex; col++) {\n const currentColumn = startCol || endCol ? x2c(col) : '';\n if (startRow && endRow) {\n for (let row = Number(startRow); row <= Number(endRow); row++) {\n result.push(`${currentColumn}${row}`);\n }\n } else if (!startRow && !endRow) {\n result.push(currentColumn);\n }\n }\n return result;\n};\n\n// restrictZone resets a zone if the zone consists of a single cell.\nexport const restrictZone = (zone: ZoneType): ZoneType => {\n const s = zoneDiff(zone);\n if (s.rows + s.cols === 0) {\n return { startY: -1, startX: -1, endY: -1, endX: -1 };\n }\n return { ...zone };\n};\n\nexport type BinarySearchPredicate = (mid: number) => boolean;\n\nexport const binarySearch = (\n low: number,\n high: number,\n predicate: BinarySearchPredicate,\n lessThan: boolean,\n): number => {\n while (low <= high) {\n const mid = Math.floor((low + high) / 2);\n if (predicate(mid)) {\n if (lessThan) {\n high = mid - 1;\n } else {\n low = mid + 1;\n }\n } else {\n if (lessThan) {\n low = mid + 1;\n } else {\n high = mid - 1;\n }\n }\n }\n return lessThan ? low : high;\n};\n\n/**\n * Convert a list of addresses into an array of bounding areas.\n * Adjacent cells (4-connected: up/down/left/right) are grouped into the same area.\n * Each resulting AreaType is the bounding rectangle of one connected group.\n */\nexport const addressesToAreas = (addresses: Address[]): AreaType[] => {\n if (addresses.length === 0) {\n return [];\n }\n\n const points = addresses.map((addr) => {\n const { y, x } = a2p(addr);\n return { y, x };\n });\n\n const key = (y: number, x: number) => `${y},${x}`;\n const pointSet = new Set(points.map((p) => key(p.y, p.x)));\n const visited = new Set<string>();\n const areas: AreaType[] = [];\n\n for (const p of points) {\n const k = key(p.y, p.x);\n if (visited.has(k)) {\n continue;\n }\n\n // BFS to find connected component\n let top = p.y,\n left = p.x,\n bottom = p.y,\n right = p.x;\n const queue = [p];\n visited.add(k);\n\n while (queue.length > 0) {\n const { y, x } = queue.shift()!;\n if (y < top) {\n top = y;\n }\n if (y > bottom) {\n bottom = y;\n }\n if (x < left) {\n left = x;\n }\n if (x > right) {\n right = x;\n }\n\n for (const [dy, dx] of [\n [0, 1],\n [0, -1],\n [1, 0],\n [-1, 0],\n ]) {\n const nk = key(y + dy, x + dx);\n if (pointSet.has(nk) && !visited.has(nk)) {\n visited.add(nk);\n queue.push({ y: y + dy, x: x + dx });\n }\n }\n }\n\n areas.push({ top, left, bottom, right });\n }\n\n return areas;\n};\n\n/**\n * Extract unique column indices (x) from a list of addresses, ignoring row information.\n * @param asc - true: ascending, false: descending, null: insertion order\n */\nexport const addressesToCols = (addresses: Address[], asc: boolean | null = true): number[] => {\n const seen = new Set<number>();\n const cols: number[] = [];\n for (const addr of addresses) {\n const { x } = a2p(addr);\n if (!seen.has(x)) {\n seen.add(x);\n cols.push(x);\n }\n }\n if (asc === true) {\n cols.sort((a, b) => a - b);\n } else if (asc === false) {\n cols.sort((a, b) => b - a);\n }\n return cols;\n};\n\n/**\n * Extract unique row indices (y) from a list of addresses, ignoring column information.\n * @param asc - true: ascending, false: descending, null: insertion order\n */\nexport const addressesToRows = (addresses: Address[], asc: boolean | null = true): number[] => {\n const seen = new Set<number>();\n const rows: number[] = [];\n for (const addr of addresses) {\n const { y } = a2p(addr);\n if (!seen.has(y)) {\n seen.add(y);\n rows.push(y);\n }\n }\n if (asc === true) {\n rows.sort((a, b) => a - b);\n } else if (asc === false) {\n rows.sort((a, b) => b - a);\n }\n return rows;\n};\n\nexport const isZoneNotSelected = (zone: ZoneType): boolean => {\n return zone.startY === -1 || zone.startX === -1 || zone.endY === -1 || zone.endX === -1;\n};\n"],"names":["superposeArea","srcArea","dstArea","srcRows","srcCols","areaDiff","dstRows","dstCols","concatAreas","area1","area2","result","zoneToArea","zone","top","bottom","left","right","areaToZone","area","areaToRange","p2a","leftTop","rightBottom","between","range","index","among","point","y","x","zoneDiff","zoneShape","areaShape","matrixShape","base","matrix","h","makeSequence","start","stop","step","_","i","oa2aa","oa","fields","aa","o","a","field","aa2oa","v","createMatrix","numRows","numCols","fill","buildInitialCellsFromOrigin","cells","ensured","flattenAs","origin","buildInitialCells","matrices","buildCells","baseAddress","baseY","baseX","a2p","row","e","id","cell","getMaxSizesFromCells","lastY","lastX","address","DEFAULT_KEY","DEFAULT_COL_KEY","DEFAULT_ROW_KEY","end","list","complementSelectingArea","selectingArea","choosing","expandRange","startRow","endRow","match","startCol","endCol","startColIndex","c2x","endColIndex","col","currentColumn","x2c","restrictZone","s","binarySearch","low","high","predicate","lessThan","mid","addressesToAreas","addresses","points","addr","key","pointSet","p","visited","areas","k","queue","dy","dx","nk","addressesToCols","asc","seen","cols","b","addressesToRows","rows","isZoneNotSelected"],"mappings":";;AAea,MAAAA,IAAgB,CAACC,GAAmBC,MAAiC;AAChF,QAAM,EAAE,MAAMC,GAAS,MAAMC,EAAQ,IAAIC,EAASJ,CAAO,GACnD,EAAE,MAAMK,GAAS,MAAMC,EAAQ,IAAIF,EAASH,CAAO;AAGlD,SAAA;AAAA,IACL,MAAMC,IAAUG,IAAUH,IAAUG;AAAA,IACpC,MAAMF,IAAUG,IAAUH,IAAUG;AAAA,EACtC;AACF,GAEaC,IAAc,CAACC,GAAiBC,MAA8B;AACnE,QAAAC,IAAmB,EAAE,GAAGF,EAAM;AAChC,SAAAC,EAAM,OAAOD,EAAM,SACrBE,EAAO,OAAOD,EAAM,OAElBA,EAAM,QAAQD,EAAM,UACtBE,EAAO,QAAQD,EAAM,QAEnBA,EAAM,MAAMD,EAAM,QACpBE,EAAO,MAAMD,EAAM,MAEjBA,EAAM,SAASD,EAAM,WACvBE,EAAO,SAASD,EAAM,SAEjBC;AACT,GAEaC,IAAa,CAACC,MAA6B;AACtD,MAAIA,EAAK,SAAS,MAAMA,EAAK,SAAS;AAC7B,WAAA,EAAE,KAAK,IAAI,MAAM,IAAI,QAAQ,IAAI,OAAO,GAAG;AAEpD,QAAM,CAACC,GAAKC,CAAM,IAAIF,EAAK,SAASA,EAAK,OAAO,CAACA,EAAK,QAAQA,EAAK,IAAI,IAAI,CAACA,EAAK,MAAMA,EAAK,MAAM,GAC5F,CAACG,GAAMC,CAAK,IAAIJ,EAAK,SAASA,EAAK,OAAO,CAACA,EAAK,QAAQA,EAAK,IAAI,IAAI,CAACA,EAAK,MAAMA,EAAK,MAAM;AAClG,SAAO,EAAE,KAAAC,GAAK,MAAAE,GAAM,QAAAD,GAAQ,OAAAE,EAAM;AACpC,GAEaC,IAAa,CAACC,OAClB;AAAA,EACL,QAAQA,EAAK;AAAA,EACb,QAAQA,EAAK;AAAA,EACb,MAAMA,EAAK;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,MAAQ,MACjBK,EAAK,KAAK,CAAC5E,GAAG0E,MAAMA,IAAI1E,CAAC,GAEpB4E;AACT,GAEaC,KAAoB,CAACjH,MACzBA,EAAK,WAAW,MAAMA,EAAK,WAAW,MAAMA,EAAK,SAAS,MAAMA,EAAK,SAAS;"}
@@ -0,0 +1,29 @@
1
+ export declare class Time {
2
+ readonly __gsType: "Time";
3
+ readonly days: number;
4
+ format: string;
5
+ constructor(days: number, format?: string);
6
+ add(date: Date): Date;
7
+ sub(date: Date): Date;
8
+ stringify(format?: string): string;
9
+ toMilliseconds(): number;
10
+ toDate(): Date;
11
+ toJSON(): {
12
+ __gsType: 'Time';
13
+ days: number;
14
+ format: string;
15
+ };
16
+ toString(): string;
17
+ static create(hours?: number, minutes?: number, seconds?: number, milliseconds?: number): Time;
18
+ static fromDate(date: Date): Time;
19
+ static fromDates(date1: Date, date2: Date): Time;
20
+ static fromObject(obj: {
21
+ days: number;
22
+ format?: string;
23
+ }): Time;
24
+ static is(obj: any): boolean;
25
+ static ensure(obj: any): Time;
26
+ static parse(value: string, format?: string, strict?: boolean): Time | undefined;
27
+ }
28
+ export declare const safeQueueMicrotask: typeof queueMicrotask;
29
+ //# sourceMappingURL=time.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"time.d.ts","sourceRoot":"","sources":["../../src/lib/time.ts"],"names":[],"mappings":"AAIA,qBAAa,IAAI;IACf,SAAgB,QAAQ,EAAG,MAAM,CAAU;IAC3C,SAAgB,IAAI,EAAE,MAAM,CAAC;IACtB,MAAM,EAAE,MAAM,CAAC;gBAEV,IAAI,EAAE,MAAM,EAAE,MAAM,SAAa;IAKtC,GAAG,CAAC,IAAI,EAAE,IAAI,GAAG,IAAI;IAIrB,GAAG,CAAC,IAAI,EAAE,IAAI,GAAG,IAAI;IAIrB,SAAS,CAAC,MAAM,CAAC,EAAE,MAAM,GAAG,MAAM;IAyBlC,cAAc,IAAI,MAAM;IAIxB,MAAM,IAAI,IAAI;IAId,MAAM,IAAI;QAAE,QAAQ,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,CAAA;KAAE;IAI5D,QAAQ,IAAI,MAAM;IAIzB,MAAM,CAAC,MAAM,CAAC,KAAK,SAAI,EAAE,OAAO,SAAI,EAAE,OAAO,SAAI,EAAE,YAAY,SAAI,GAAG,IAAI;IAK1E,MAAM,CAAC,QAAQ,CAAC,IAAI,EAAE,IAAI,GAAG,IAAI;IAMjC,MAAM,CAAC,SAAS,CAAC,KAAK,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,GAAG,IAAI;IAIhD,MAAM,CAAC,UAAU,CAAC,GAAG,EAAE;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,MAAM,CAAC,EAAE,MAAM,CAAA;KAAE,GAAG,IAAI;IAI/D,MAAM,CAAC,EAAE,CAAC,GAAG,EAAE,GAAG,GAAG,OAAO;IAU5B,MAAM,CAAC,MAAM,CAAC,GAAG,EAAE,GAAG,GAAG,IAAI;IAU7B,MAAM,CAAC,KAAK,CAAC,KAAK,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,MAAM,EAAE,MAAM,UAAQ,GAAG,IAAI,GAAG,SAAS;CAyC/E;AA2BD,eAAO,MAAM,kBAAkB,uBACyE,CAAC"}
@@ -0,0 +1,113 @@
1
+ import { BASE_DATE as f } from "../constants.js";
2
+ const g = 864e5;
3
+ class a {
4
+ constructor(t, n = "HH:mm:ss") {
5
+ this.__gsType = "Time", this.days = t, this.format = n;
6
+ }
7
+ add(t) {
8
+ return new Date(t.getTime() + this.days * g);
9
+ }
10
+ sub(t) {
11
+ return new Date(t.getTime() - this.days * g);
12
+ }
13
+ stringify(t) {
14
+ const n = this.toMilliseconds(), i = Math.abs(n), r = n < 0 ? "-" : "", e = i % 1e3;
15
+ let s = Math.floor(i / 1e3);
16
+ const m = s % 60;
17
+ s = Math.floor(s / 60);
18
+ const u = s % 60, c = Math.floor(s / 60);
19
+ let o = t ?? (e === 0 ? "HH:mm:ss" : "HH:mm:ss.SSS");
20
+ return o = o.replace("HH", r + String(c).padStart(2, "0")), o = o.replace("H", r + String(c)), o = o.replace("mm", String(u).padStart(2, "0")), o = o.replace("ss", String(m).padStart(2, "0")), o = o.replace("SSS", String(e).padStart(3, "0")), o = o.replace("SS", String(e).padStart(3, "0").substring(0, 2)), o = o.replace("S", String(e).padStart(3, "0").substring(0, 1)), o;
21
+ }
22
+ toMilliseconds() {
23
+ return this.days * g;
24
+ }
25
+ toDate() {
26
+ return new Date(f.getTime() + this.days * g);
27
+ }
28
+ toJSON() {
29
+ return { __gsType: "Time", days: this.days, format: this.format };
30
+ }
31
+ toString() {
32
+ return this.stringify();
33
+ }
34
+ static create(t = 0, n = 0, i = 0, r = 0) {
35
+ const e = t * 36e5 + n * 6e4 + i * 1e3 + r;
36
+ return new a(e / g);
37
+ }
38
+ static fromDate(t) {
39
+ const n = t.getHours() * 36e5 + t.getMinutes() * 6e4 + t.getSeconds() * 1e3 + t.getMilliseconds();
40
+ return new a(n / g);
41
+ }
42
+ static fromDates(t, n) {
43
+ return new a((t.getTime() - n.getTime()) / g);
44
+ }
45
+ static fromObject(t) {
46
+ return new a(t.days, t.format);
47
+ }
48
+ static is(t) {
49
+ return t instanceof a || (t == null ? void 0 : t.__gsType) === "Time";
50
+ }
51
+ static ensure(t) {
52
+ return t instanceof a ? t : (t == null ? void 0 : t.__gsType) === "Time" ? a.fromObject(t) : a.create();
53
+ }
54
+ static parse(t, n, i = !1) {
55
+ if (n != null) {
56
+ const r = l(n), e = t.match(r);
57
+ if (e != null && e.groups)
58
+ return a.create(
59
+ Number(e.groups.HH || e.groups.H || 0),
60
+ Number(e.groups.mm || e.groups.m || 0),
61
+ Number(e.groups.ss || e.groups.s || 0),
62
+ Number(e.groups.SSS || e.groups.SS || e.groups.S || 0)
63
+ );
64
+ }
65
+ if (!i) {
66
+ {
67
+ const r = t.match(/^([+-]?)(\d+):(\d{2})$/);
68
+ if (r) {
69
+ const [, e, s, m] = r, u = e === "-" ? -1 : 1;
70
+ return a.create(u * Number(s), u * Number(m));
71
+ }
72
+ }
73
+ {
74
+ const r = t.match(/^([+-]?)(\d+):(\d{2}):(\d{2})$/);
75
+ if (r) {
76
+ const [, e, s, m, u] = r, c = e === "-" ? -1 : 1;
77
+ return a.create(c * Number(s), c * Number(m), c * Number(u));
78
+ }
79
+ }
80
+ {
81
+ const r = t.match(/^([+-]?)(\d+):(\d{2}):(\d{2})\.(\d+)$/);
82
+ if (r) {
83
+ const [, e, s, m, u, c] = r, p = e === "-" ? -1 : 1;
84
+ return a.create(p * Number(s), p * Number(m), p * Number(u), p * Number(c));
85
+ }
86
+ }
87
+ }
88
+ }
89
+ }
90
+ const d = {
91
+ HH: { group: "HH", pattern: "(?<HH>\\d+)" },
92
+ H: { group: "H", pattern: "(?<HH>\\d+)" },
93
+ mm: { group: "mm", pattern: "(?<mm>[0-5]\\d)" },
94
+ m: { group: "m", pattern: "(?<m>\\d|[1-5]\\d)" },
95
+ ss: { group: "ss", pattern: "(?<ss>[0-5]\\d)" },
96
+ s: { group: "s", pattern: "(?<s>\\d|[1-5]\\d)" },
97
+ SSS: { group: "SSS", pattern: "(?<SSS>\\d{3})" },
98
+ SS: { group: "SS", pattern: "(?<SS>\\d{2})" },
99
+ S: { group: "S", pattern: "(?<S>\\d)" }
100
+ };
101
+ function l(S) {
102
+ const t = Object.keys(d).sort((e, s) => s.length - e.length), n = new RegExp(t.join("|"), "g"), r = S.replace(/[-\/\\^$*+?.()|[\]{}]/g, "\\$&").replace(n, (e) => {
103
+ var s;
104
+ return ((s = d[e]) == null ? void 0 : s.pattern) ?? e;
105
+ });
106
+ return new RegExp(`^${r}$`);
107
+ }
108
+ const H = typeof queueMicrotask == "function" ? queueMicrotask : (S) => Promise.resolve().then(S);
109
+ export {
110
+ a as Time,
111
+ H as safeQueueMicrotask
112
+ };
113
+ //# sourceMappingURL=time.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"time.js","sources":["../../src/lib/time.ts"],"sourcesContent":["import { BASE_DATE } from '../constants';\n\nconst MS_PER_DAY = 86400000;\n\nexport class Time {\n public readonly __gsType = 'Time' as const;\n public readonly days: number;\n public format: string;\n\n constructor(days: number, format = 'HH:mm:ss') {\n this.days = days;\n this.format = format;\n }\n\n public add(date: Date): Date {\n return new Date(date.getTime() + this.days * MS_PER_DAY);\n }\n\n public sub(date: Date): Date {\n return new Date(date.getTime() - this.days * MS_PER_DAY);\n }\n\n public stringify(format?: string): string {\n const totalMs = this.toMilliseconds();\n const absMs = Math.abs(totalMs);\n const sign = totalMs < 0 ? '-' : '';\n\n const millis = absMs % 1000;\n let remaining = Math.floor(absMs / 1000);\n const seconds = remaining % 60;\n remaining = Math.floor(remaining / 60);\n const minutes = remaining % 60;\n const hours = Math.floor(remaining / 60);\n\n const resolvedFormat = format ?? (millis === 0 ? 'HH:mm:ss' : 'HH:mm:ss.SSS');\n\n let result = resolvedFormat;\n result = result.replace('HH', sign + String(hours).padStart(2, '0'));\n result = result.replace('H', sign + String(hours));\n result = result.replace('mm', String(minutes).padStart(2, '0'));\n result = result.replace('ss', String(seconds).padStart(2, '0'));\n result = result.replace('SSS', String(millis).padStart(3, '0'));\n result = result.replace('SS', String(millis).padStart(3, '0').substring(0, 2));\n result = result.replace('S', String(millis).padStart(3, '0').substring(0, 1));\n return result;\n }\n\n public toMilliseconds(): number {\n return this.days * MS_PER_DAY;\n }\n\n public toDate(): Date {\n return new Date(BASE_DATE.getTime() + this.days * MS_PER_DAY);\n }\n\n public toJSON(): { __gsType: 'Time'; days: number; format: string } {\n return { __gsType: 'Time', days: this.days, format: this.format };\n }\n\n public toString(): string {\n return this.stringify();\n }\n\n static create(hours = 0, minutes = 0, seconds = 0, milliseconds = 0): Time {\n const ms = hours * 3600000 + minutes * 60000 + seconds * 1000 + milliseconds;\n return new Time(ms / MS_PER_DAY);\n }\n\n static fromDate(date: Date): Time {\n const timeMs =\n date.getHours() * 3600000 + date.getMinutes() * 60000 + date.getSeconds() * 1000 + date.getMilliseconds();\n return new Time(timeMs / MS_PER_DAY);\n }\n\n static fromDates(date1: Date, date2: Date): Time {\n return new Time((date1.getTime() - date2.getTime()) / MS_PER_DAY);\n }\n\n static fromObject(obj: { days: number; format?: string }): Time {\n return new Time(obj.days, obj.format);\n }\n\n static is(obj: any): boolean {\n if (obj instanceof Time) {\n return true;\n }\n if (obj?.__gsType === 'Time') {\n return true;\n }\n return false;\n }\n\n static ensure(obj: any): Time {\n if (obj instanceof Time) {\n return obj;\n }\n if (obj?.__gsType === 'Time') {\n return Time.fromObject(obj);\n }\n return Time.create();\n }\n\n static parse(value: string, format?: string, strict = false): Time | undefined {\n if (format != null) {\n const formattedMatcher = dayjsFormatToNamedRegex(format);\n const match = value.match(formattedMatcher);\n if (match?.groups) {\n return Time.create(\n Number(match.groups.HH || match.groups.H || 0),\n Number(match.groups.mm || match.groups.m || 0),\n Number(match.groups.ss || match.groups.s || 0),\n Number(match.groups.SSS || match.groups.SS || match.groups.S || 0),\n );\n }\n }\n if (strict) {\n return;\n }\n {\n const match = value.match(/^([+-]?)(\\d+):(\\d{2})$/);\n if (match) {\n const [, _sign, hours, minutes] = match;\n const sign = _sign === '-' ? -1 : 1;\n return Time.create(sign * Number(hours), sign * Number(minutes));\n }\n }\n {\n const match = value.match(/^([+-]?)(\\d+):(\\d{2}):(\\d{2})$/);\n if (match) {\n const [, _sign, hours, minutes, seconds] = match;\n const sign = _sign === '-' ? -1 : 1;\n return Time.create(sign * Number(hours), sign * Number(minutes), sign * Number(seconds));\n }\n }\n {\n const match = value.match(/^([+-]?)(\\d+):(\\d{2}):(\\d{2})\\.(\\d+)$/);\n if (match) {\n const [, _sign, hours, minutes, seconds, msecs] = match;\n const sign = _sign === '-' ? -1 : 1;\n return Time.create(sign * Number(hours), sign * Number(minutes), sign * Number(seconds), sign * Number(msecs));\n }\n }\n }\n}\n\nconst tokenRegexMap: Record<string, { group: string; pattern: string }> = {\n HH: { group: 'HH', pattern: '(?<HH>\\\\d+)' },\n H: { group: 'H', pattern: '(?<HH>\\\\d+)' },\n mm: { group: 'mm', pattern: '(?<mm>[0-5]\\\\d)' },\n m: { group: 'm', pattern: '(?<m>\\\\d|[1-5]\\\\d)' },\n ss: { group: 'ss', pattern: '(?<ss>[0-5]\\\\d)' },\n s: { group: 's', pattern: '(?<s>\\\\d|[1-5]\\\\d)' },\n SSS: { group: 'SSS', pattern: '(?<SSS>\\\\d{3})' },\n SS: { group: 'SS', pattern: '(?<SS>\\\\d{2})' },\n S: { group: 'S', pattern: '(?<S>\\\\d)' },\n};\n\nfunction dayjsFormatToNamedRegex(format: string): RegExp {\n const sortedTokens = Object.keys(tokenRegexMap).sort((a, b) => b.length - a.length);\n const tokenPattern = new RegExp(sortedTokens.join('|'), 'g');\n\n const escapedFormat = format.replace(/[-\\/\\\\^$*+?.()|[\\]{}]/g, '\\\\$&');\n\n const regexSource = escapedFormat.replace(tokenPattern, (match) => {\n return tokenRegexMap[match]?.pattern ?? match;\n });\n\n return new RegExp(`^${regexSource}$`);\n}\n\nexport const safeQueueMicrotask =\n typeof queueMicrotask === 'function' ? queueMicrotask : (cb: () => void) => Promise.resolve().then(cb);\n"],"names":["MS_PER_DAY","Time","days","format","date","totalMs","absMs","sign","millis","remaining","seconds","minutes","hours","result","BASE_DATE","milliseconds","ms","timeMs","date1","date2","obj","value","strict","formattedMatcher","dayjsFormatToNamedRegex","match","_sign","msecs","tokenRegexMap","sortedTokens","a","b","tokenPattern","regexSource","_a","safeQueueMicrotask","cb"],"mappings":";AAEA,MAAMA,IAAa;AAEZ,MAAMC,EAAK;AAAA,EAKhB,YAAYC,GAAcC,IAAS,YAAY;AAJ/C,SAAgB,WAAW,QAKzB,KAAK,OAAOD,GACZ,KAAK,SAASC;AAAA,EAAA;AAAA,EAGT,IAAIC,GAAkB;AAC3B,WAAO,IAAI,KAAKA,EAAK,QAAY,IAAA,KAAK,OAAOJ,CAAU;AAAA,EAAA;AAAA,EAGlD,IAAII,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EACxE,IAAI,EAAE,OAAO,MAAM,SAAS,cAAc;AAAA,EAC1C,GAAG,EAAE,OAAO,KAAK,SAAS,cAAc;AAAA,EACxC,IAAI,EAAE,OAAO,MAAM,SAAS,kBAAkB;AAAA,EAC9C,GAAG,EAAE,OAAO,KAAK,SAAS,qBAAqB;AAAA,EAC/C,IAAI,EAAE,OAAO,MAAM,SAAS,kBAAkB;AAAA,EAC9C,GAAG,EAAE,OAAO,KAAK,SAAS,qBAAqB;AAAA,EAC/C,KAAK,EAAE,OAAO,OAAO,SAAS,iBAAiB;AAAA,EAC/C,IAAI,EAAE,OAAO,MAAM,SAAS,gBAAgB;AAAA,EAC5C,GAAG,EAAE,OAAO,KAAK,SAAS,YAAY;AACxC;AAEA,SAASJ,EAAwBrB,GAAwB;AACvD,QAAM0B,IAAe,OAAO,KAAKD,CAAa,EAAE,KAAK,CAACE,GAAGC,MAAMA,EAAE,SAASD,EAAE,MAAM,GAC5EE,IAAe,IAAI,OAAOH,EAAa,KAAK,GAAG,GAAG,GAAG,GAIrDI,IAFgB9B,EAAO,QAAQ,0BAA0B,MAAM,EAEnC,QAAQ6B,GAAc,CAACP,MAAU;;AAC1D,aAAAS,IAAAN,EAAcH,CAAK,MAAnB,gBAAAS,EAAsB,YAAWT;AAAA,EAAA,CACzC;AAED,SAAO,IAAI,OAAO,IAAIQ,CAAW,GAAG;AACtC;AAEa,MAAAE,IACX,OAAO,kBAAmB,aAAa,iBAAiB,CAACC,MAAmB,QAAQ,UAAU,KAAKA,CAAE;"}
@@ -0,0 +1,22 @@
1
+ import { Sheet } from './sheet';
2
+ import { AreaType, PointType, Virtualization } from '../types';
3
+ export declare const getCellRectPositions: (sheet: Sheet, { y, x }: PointType) => {
4
+ top: number;
5
+ left: number;
6
+ bottom: number;
7
+ right: number;
8
+ width: number;
9
+ height: number;
10
+ };
11
+ export declare const getScreenRect: (e: HTMLDivElement) => {
12
+ top: number;
13
+ left: number;
14
+ bottom: number;
15
+ right: number;
16
+ height: number;
17
+ width: number;
18
+ };
19
+ export declare const virtualize: (sheet: Sheet, e: HTMLDivElement | null) => Virtualization | null;
20
+ export declare const smartScroll: (sheet: Sheet, e: HTMLDivElement | null, targetPoint: PointType, behavior?: ScrollBehavior) => void;
21
+ export declare const getAreaInTabular: (tabularElement: HTMLDivElement) => AreaType;
22
+ //# sourceMappingURL=virtualization.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"virtualization.d.ts","sourceRoot":"","sources":["../../src/lib/virtualization.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AAChC,OAAO,KAAK,EAAE,QAAQ,EAAE,SAAS,EAAE,cAAc,EAAE,MAAM,UAAU,CAAC;AAEpE,eAAO,MAAM,oBAAoB,GAAI,OAAO,KAAK,EAAE,UAAU,SAAS;;;;;;;CAgBrE,CAAC;AAEF,eAAO,MAAM,aAAa,GAAI,GAAG,cAAc;;;;;;;CAQ9C,CAAC;AAEF,eAAO,MAAM,UAAU,GAAI,OAAO,KAAK,EAAE,GAAG,cAAc,GAAG,IAAI,KAAG,cAAc,GAAG,IA6DpF,CAAC;AAEF,eAAO,MAAM,WAAW,GACtB,OAAO,KAAK,EACZ,GAAG,cAAc,GAAG,IAAI,EACxB,aAAa,SAAS,EACtB,WAAU,cAAuB,SAoDlC,CAAC;AAmBF,eAAO,MAAM,gBAAgB,GAAI,gBAAgB,cAAc,KAAG,QAiBjE,CAAC"}
@@ -0,0 +1,91 @@
1
+ import { DEFAULT_WIDTH as A, DEFAULT_HEIGHT as C, OVERSCAN_X as w, OVERSCAN_Y as b } from "../constants.js";
2
+ import { range as x, binarySearch as M } from "./spatial.js";
3
+ const L = (t, { y: i, x: s }) => {
4
+ var m, f;
5
+ const n = t.getCell({ y: 0, x: s }, { resolution: "SYSTEM" }), o = t.getCell({ y: i, x: 0 }, { resolution: "SYSTEM" }), l = ((m = t.getSystem({ y: 0, x: s })) == null ? void 0 : m.offsetLeft) ?? 0, r = ((f = t.getSystem({ y: i, x: 0 })) == null ? void 0 : f.offsetTop) ?? 0, g = (n == null ? void 0 : n.width) || A, u = o != null && o.filtered ? 0 : (o == null ? void 0 : o.height) || C;
6
+ return {
7
+ top: r,
8
+ left: l,
9
+ bottom: r + u,
10
+ right: l + g,
11
+ width: g,
12
+ height: u
13
+ };
14
+ }, E = (t) => {
15
+ const i = t.scrollTop, s = t.scrollLeft, n = t.offsetHeight, o = t.offsetWidth, l = i + n, r = s + o;
16
+ return { top: i, left: s, bottom: l, right: r, height: n, width: o };
17
+ }, P = (t, i) => {
18
+ var y, R;
19
+ if (i == null)
20
+ return null;
21
+ let s = 0, n = 0, o = t.numRows, l = t.numCols;
22
+ const { top: r, left: g, bottom: u, right: m } = E(i);
23
+ let f = 0, c = 0;
24
+ for (let e = 1; e <= t.numCols; e++) {
25
+ const a = ((y = t.getCell({ y: 0, x: e }, { resolution: "SYSTEM" })) == null ? void 0 : y.width) || A;
26
+ if (f += a, n === 0 && f > g && (n = Math.max(e - w, 1)), f > m) {
27
+ l = Math.min(e + w, t.numCols);
28
+ break;
29
+ }
30
+ }
31
+ for (let e = 1; e <= t.numRows; e++) {
32
+ if (t.isRowFiltered(e))
33
+ continue;
34
+ const a = ((R = t.getCell({ y: e, x: 0 }, { resolution: "SYSTEM" })) == null ? void 0 : R.height) || C;
35
+ if (c += a, s === 0 && c > r && (s = Math.max(e - b, 1)), c > u) {
36
+ o = Math.min(e + b, t.numRows);
37
+ break;
38
+ }
39
+ }
40
+ const p = s === 0 ? [] : x(s, o).filter((e) => !t.isRowFiltered(e)), d = x(n, l), T = t.getRectSize({
41
+ top: 1,
42
+ left: 1,
43
+ bottom: s,
44
+ right: n
45
+ }), S = t.getRectSize({
46
+ top: o,
47
+ left: l,
48
+ bottom: t.numRows,
49
+ right: t.numCols
50
+ });
51
+ return {
52
+ ys: p,
53
+ xs: d,
54
+ adjuster: {
55
+ top: T.height,
56
+ left: T.width,
57
+ bottom: S.height,
58
+ right: S.width
59
+ }
60
+ };
61
+ }, Y = (t, i, s, n = "auto") => {
62
+ if (i == null)
63
+ return;
64
+ const o = E(i), l = L(t, s), r = l.top - t.headerHeight, g = l.left - t.headerWidth, u = l.bottom - o.height + 1, m = l.right - o.width + 1, f = r < o.top, c = g < o.left, p = l.bottom > o.bottom, d = l.right > o.right;
65
+ c ? f ? i.scrollTo({ left: g, top: r, behavior: n }) : p ? i.scrollTo({ left: g, top: u, behavior: n }) : i.scrollTo({ left: g, top: o.top, behavior: n }) : d ? f ? i.scrollTo({ left: m, top: r, behavior: n }) : p ? i.scrollTo({ left: m, top: u, behavior: n }) : i.scrollTo({ left: m, top: o.top, behavior: n }) : f ? i.scrollTo({ left: o.left, top: r, behavior: n }) : p && i.scrollTo({ left: o.left, top: u, behavior: n });
66
+ }, h = (t, i, s, n) => {
67
+ var l;
68
+ const o = M(
69
+ 0,
70
+ t.length - 1,
71
+ (r) => i(t[r].getBoundingClientRect()) < s,
72
+ !1
73
+ );
74
+ return parseInt(((l = t[o]) == null ? void 0 : l.dataset[n]) ?? "1");
75
+ }, B = (t) => {
76
+ const {
77
+ top: i,
78
+ left: s,
79
+ bottom: n,
80
+ right: o
81
+ } = t.getBoundingClientRect(), l = Array.from(t.querySelectorAll(".gs-th-left")), r = Array.from(t.querySelectorAll(".gs-th-top")), g = h(l, (c) => c.top, i, "y"), u = h(l, (c) => c.bottom, n, "y"), m = h(r, (c) => c.left, s, "x"), f = h(r, (c) => c.right, o, "x");
82
+ return { top: g, left: m, bottom: u, right: f };
83
+ };
84
+ export {
85
+ B as getAreaInTabular,
86
+ L as getCellRectPositions,
87
+ E as getScreenRect,
88
+ Y as smartScroll,
89
+ P as virtualize
90
+ };
91
+ //# sourceMappingURL=virtualization.js.map