@mbpockets/shared-ui 0.1.20 → 0.1.21

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 (125) hide show
  1. package/dist/EventPage/index.cjs +209 -121
  2. package/dist/EventPage/index.cjs.map +1 -1
  3. package/dist/EventPage/index.mjs +201 -119
  4. package/dist/EventPage/index.mjs.map +1 -1
  5. package/dist/EventPage.cjs +209 -121
  6. package/dist/EventPage.cjs.map +1 -1
  7. package/dist/EventPage.mjs +201 -119
  8. package/dist/EventPage.mjs.map +1 -1
  9. package/dist/PlayerPage/index.cjs.map +1 -1
  10. package/dist/PlayerPage/index.mjs.map +1 -1
  11. package/dist/PlayerPage.cjs.map +1 -1
  12. package/dist/PlayerPage.mjs.map +1 -1
  13. package/dist/ProfilePage/index.cjs.map +1 -1
  14. package/dist/ProfilePage/index.mjs.map +1 -1
  15. package/dist/ProfilePage.cjs.map +1 -1
  16. package/dist/ProfilePage.mjs.map +1 -1
  17. package/dist/SearchPage/Filters/index.cjs +149 -43
  18. package/dist/SearchPage/Filters/index.cjs.map +1 -1
  19. package/dist/SearchPage/Filters/index.d.cts +1 -2
  20. package/dist/SearchPage/Filters/index.d.ts +1 -2
  21. package/dist/SearchPage/Filters/index.mjs +146 -42
  22. package/dist/SearchPage/Filters/index.mjs.map +1 -1
  23. package/dist/SearchPage/Filters.cjs +149 -43
  24. package/dist/SearchPage/Filters.cjs.map +1 -1
  25. package/dist/SearchPage/Filters.d.cts +38 -3
  26. package/dist/SearchPage/Filters.d.ts +38 -3
  27. package/dist/SearchPage/Filters.mjs +146 -42
  28. package/dist/SearchPage/Filters.mjs.map +1 -1
  29. package/dist/SearchPage/Results/index.cjs +139 -67
  30. package/dist/SearchPage/Results/index.cjs.map +1 -1
  31. package/dist/SearchPage/Results/index.mjs +127 -63
  32. package/dist/SearchPage/Results/index.mjs.map +1 -1
  33. package/dist/SearchPage/Results.cjs +139 -67
  34. package/dist/SearchPage/Results.cjs.map +1 -1
  35. package/dist/SearchPage/Results.d.cts +21 -12
  36. package/dist/SearchPage/Results.d.ts +21 -12
  37. package/dist/SearchPage/Results.mjs +127 -63
  38. package/dist/SearchPage/Results.mjs.map +1 -1
  39. package/dist/SearchPage/index.cjs +496 -221
  40. package/dist/SearchPage/index.cjs.map +1 -1
  41. package/dist/SearchPage/index.d.cts +1 -1
  42. package/dist/SearchPage/index.d.ts +1 -1
  43. package/dist/SearchPage/index.mjs +483 -216
  44. package/dist/SearchPage/index.mjs.map +1 -1
  45. package/dist/SearchPage.cjs +496 -221
  46. package/dist/SearchPage.cjs.map +1 -1
  47. package/dist/SearchPage.d.cts +78 -7
  48. package/dist/SearchPage.d.ts +78 -7
  49. package/dist/SearchPage.mjs +483 -216
  50. package/dist/SearchPage.mjs.map +1 -1
  51. package/dist/TablePage/index.cjs +10 -1
  52. package/dist/TablePage/index.cjs.map +1 -1
  53. package/dist/TablePage/index.d.cts +2 -2
  54. package/dist/TablePage/index.d.ts +2 -2
  55. package/dist/TablePage/index.mjs +10 -2
  56. package/dist/TablePage/index.mjs.map +1 -1
  57. package/dist/TablePage.cjs +10 -1
  58. package/dist/TablePage.cjs.map +1 -1
  59. package/dist/TablePage.d.cts +7 -2
  60. package/dist/TablePage.d.ts +7 -2
  61. package/dist/TablePage.mjs +10 -2
  62. package/dist/TablePage.mjs.map +1 -1
  63. package/dist/index.cjs +447 -178
  64. package/dist/index.cjs.map +1 -1
  65. package/dist/index.d.cts +3 -3
  66. package/dist/index.d.ts +3 -3
  67. package/dist/index.mjs +435 -175
  68. package/dist/index.mjs.map +1 -1
  69. package/dist/mocks/SearchResults.cjs +22 -15
  70. package/dist/mocks/SearchResults.cjs.map +1 -1
  71. package/dist/mocks/SearchResults.d.cts +3 -15
  72. package/dist/mocks/SearchResults.d.ts +3 -15
  73. package/dist/mocks/SearchResults.mjs +22 -15
  74. package/dist/mocks/SearchResults.mjs.map +1 -1
  75. package/dist/mocks/index.cjs +22 -15
  76. package/dist/mocks/index.cjs.map +1 -1
  77. package/dist/mocks/index.d.cts +2 -1
  78. package/dist/mocks/index.d.ts +2 -1
  79. package/dist/mocks/index.mjs +22 -15
  80. package/dist/mocks/index.mjs.map +1 -1
  81. package/dist/mocks.cjs +22 -15
  82. package/dist/mocks.cjs.map +1 -1
  83. package/dist/mocks.d.cts +2 -1
  84. package/dist/mocks.d.ts +2 -1
  85. package/dist/mocks.mjs +22 -15
  86. package/dist/mocks.mjs.map +1 -1
  87. package/dist/{common → shared}/index.cjs.map +1 -1
  88. package/dist/{common → shared}/index.d.cts +1 -1
  89. package/dist/{common → shared}/index.d.ts +1 -1
  90. package/dist/{common → shared}/index.mjs.map +1 -1
  91. package/dist/{common.cjs → shared.cjs} +2 -2
  92. package/dist/{common.cjs.map → shared.cjs.map} +1 -1
  93. package/dist/{common.css → shared.css} +1 -1
  94. package/dist/{common.mjs → shared.mjs} +2 -2
  95. package/dist/{common.mjs.map → shared.mjs.map} +1 -1
  96. package/dist/types/index.d.cts +1 -1
  97. package/dist/types/index.d.ts +1 -1
  98. package/dist/types/search.d.cts +23 -1
  99. package/dist/types/search.d.ts +23 -1
  100. package/dist/types.d.cts +1 -1
  101. package/dist/types.d.ts +1 -1
  102. package/package.json +1 -1
  103. /package/dist/{common → shared}/Modal/index.cjs +0 -0
  104. /package/dist/{common → shared}/Modal/index.cjs.map +0 -0
  105. /package/dist/{common → shared}/Modal/index.css +0 -0
  106. /package/dist/{common → shared}/Modal/index.css.map +0 -0
  107. /package/dist/{common → shared}/Modal/index.d.cts +0 -0
  108. /package/dist/{common → shared}/Modal/index.d.ts +0 -0
  109. /package/dist/{common → shared}/Modal/index.mjs +0 -0
  110. /package/dist/{common → shared}/Modal/index.mjs.map +0 -0
  111. /package/dist/{common → shared}/Modal.cjs +0 -0
  112. /package/dist/{common → shared}/Modal.cjs.map +0 -0
  113. /package/dist/{common → shared}/Modal.css +0 -0
  114. /package/dist/{common → shared}/Modal.css.map +0 -0
  115. /package/dist/{common → shared}/Modal.d.cts +0 -0
  116. /package/dist/{common → shared}/Modal.d.ts +0 -0
  117. /package/dist/{common → shared}/Modal.mjs +0 -0
  118. /package/dist/{common → shared}/Modal.mjs.map +0 -0
  119. /package/dist/{common → shared}/index.cjs +0 -0
  120. /package/dist/{common → shared}/index.css +0 -0
  121. /package/dist/{common → shared}/index.css.map +0 -0
  122. /package/dist/{common → shared}/index.mjs +0 -0
  123. /package/dist/{common.css.map → shared.css.map} +0 -0
  124. /package/dist/{common.d.cts → shared.d.cts} +0 -0
  125. /package/dist/{common.d.ts → shared.d.ts} +0 -0
@@ -1,32 +1,58 @@
1
1
  "use client";
2
- import Typography2 from '@mui/material/Typography';
2
+ import FormControlLabel from '@mui/material/FormControlLabel';
3
+ import Checkbox from '@mui/material/Checkbox';
4
+ import Box8 from '@mui/material/Box';
5
+ import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
6
+ import Typography6 from '@mui/material/Typography';
3
7
  import FormControl from '@mui/material/FormControl';
4
8
  import RadioGroup from '@mui/material/RadioGroup';
5
- import FormControlLabel from '@mui/material/FormControlLabel';
6
9
  import Radio from '@mui/material/Radio';
7
- import { jsxs, Fragment, jsx } from 'react/jsx-runtime';
8
- import React from 'react';
9
- import Box2 from '@mui/material/Box';
10
+ import React, { useEffect, useState } from 'react';
10
11
  import Autocomplete from '@mui/material/Autocomplete';
11
12
  import TextField from '@mui/material/TextField';
12
13
  import Popper from '@mui/material/Popper';
13
- import Divider from '@mui/material/Divider';
14
+ import Divider2 from '@mui/material/Divider';
14
15
  import FormGroup from '@mui/material/FormGroup';
15
- import Checkbox from '@mui/material/Checkbox';
16
16
  import Button from '@mui/material/Button';
17
17
  import SearchIcon from '@mui/icons-material/Search';
18
+ import Pagination from '@mui/material/Pagination';
18
19
  import Avatar from '@mui/material/Avatar';
19
- import { Card, CardContent, Box, Typography, Chip as Chip$1, LinearProgress, useTheme, useMediaQuery } from '@mui/material';
20
- import CasinoIcon from '@mui/icons-material/Casino';
20
+ import Card2 from '@mui/material/Card';
21
+ import CardContent2 from '@mui/material/CardContent';
22
+ import { useTheme, useMediaQuery, Typography } from '@mui/material';
23
+ import Chip2 from '@mui/material/Chip';
24
+ import LinearProgress from '@mui/material/LinearProgress';
25
+ import PersonIcon from '@mui/icons-material/Person';
26
+ import SupervisorAccountIcon from '@mui/icons-material/SupervisorAccount';
27
+ import TableRestaurantIcon from '@mui/icons-material/TableRestaurant';
21
28
  import CalendarTodayIcon from '@mui/icons-material/CalendarToday';
22
29
  import LocationOnIcon from '@mui/icons-material/LocationOn';
23
30
  import EventIcon from '@mui/icons-material/Event';
24
31
  import Grid from '@mui/material/Grid';
25
- import Card2 from '@mui/material/Card';
26
32
  import CardHeader from '@mui/material/CardHeader';
27
- import CardContent2 from '@mui/material/CardContent';
33
+ import CircularProgress from '@mui/material/CircularProgress';
28
34
 
29
- // src/components/SearchPage/Filters/SortOptions.tsx
35
+ // src/components/SearchPage/Filters/ExpiredTablesFilter.tsx
36
+ var ExpiredTablesFilter = ({
37
+ includeExpiredTables,
38
+ onChange
39
+ }) => {
40
+ return /* @__PURE__ */ jsx(Box8, { sx: { mt: 2 }, children: /* @__PURE__ */ jsx(
41
+ FormControlLabel,
42
+ {
43
+ control: /* @__PURE__ */ jsx(
44
+ Checkbox,
45
+ {
46
+ checked: includeExpiredTables,
47
+ onChange: (e) => onChange(e.target.checked),
48
+ color: "primary"
49
+ }
50
+ ),
51
+ label: "Show expired tables"
52
+ }
53
+ ) });
54
+ };
55
+ var ExpiredTablesFilter_default = ExpiredTablesFilter;
30
56
  var SORT_OPTIONS = [
31
57
  { id: "relevance", label: "Relevance" },
32
58
  { id: "newest", label: "Newest" },
@@ -40,7 +66,7 @@ var SortOptions = ({
40
66
  onChange == null ? void 0 : onChange(event.target.value);
41
67
  };
42
68
  return /* @__PURE__ */ jsxs(Fragment, { children: [
43
- /* @__PURE__ */ jsx(Typography2, { variant: "h6", gutterBottom: true, children: "Sort By" }),
69
+ /* @__PURE__ */ jsx(Typography6, { variant: "h6", gutterBottom: true, children: "Sort By" }),
44
70
  /* @__PURE__ */ jsx(FormControl, { children: /* @__PURE__ */ jsx(RadioGroup, { defaultValue, onChange: handleSortChange, children: SORT_OPTIONS.map((option) => /* @__PURE__ */ jsx(
45
71
  FormControlLabel,
46
72
  {
@@ -53,13 +79,53 @@ var SortOptions = ({
53
79
  ] });
54
80
  };
55
81
  var SortOptions_default = SortOptions;
82
+ function Chip({ tag, removeCallback }) {
83
+ var _a;
84
+ const color = (_a = tag.color) != null ? _a : "#bfbcbb";
85
+ return /* @__PURE__ */ jsx(Fragment, { children: /* @__PURE__ */ jsxs(
86
+ "span",
87
+ {
88
+ className: "inline-block text-sm px-3 py-1 rounded-full border-2 font-outlined text-white m-0.5 font-stretch-105% font-sans",
89
+ style: {
90
+ borderColor: `color-mix(in srgb, ${color}, black 50%)`,
91
+ background: `linear-gradient(160deg, color-mix(in srgb, ${color}, white 10%) 0%, color-mix(in srgb, ${color}, black 60%) 100%)`,
92
+ textShadow: "black 1.5px 1px 1.5px",
93
+ filter: `drop-shadow(2px 2px 1.5px color-mix(in srgb, ${color}, black 80%))`
94
+ },
95
+ children: [
96
+ tag.label,
97
+ removeCallback && /* @__PURE__ */ jsx(
98
+ "button",
99
+ {
100
+ type: "button",
101
+ onClick: () => removeCallback(tag.id),
102
+ className: "ml-2 text-white hover:text-red-700 focus:outline-none pl-0.5 pr-1 cursor-pointer hover:bg-white rounded-full",
103
+ style: {
104
+ textShadow: "black 1px 1px 1px"
105
+ },
106
+ children: "X"
107
+ }
108
+ )
109
+ ]
110
+ },
111
+ tag.id
112
+ ) });
113
+ }
56
114
  var TagsFilter = ({
57
115
  onChange,
58
- tags: Tags = []
116
+ tags: Tags = [],
117
+ initialSelectedTags
59
118
  }) => {
60
- const [mustHaveTags, setMustHaveTags] = React.useState([]);
61
- const [mustNotHaveTags, setMustNotHaveTags] = React.useState([]);
62
- const [shouldHaveAtLeastOneTags, setShouldHaveAtLeastOneTags] = React.useState([]);
119
+ const [mustHaveTags, setMustHaveTags] = React.useState((initialSelectedTags == null ? void 0 : initialSelectedTags.mustHave) || []);
120
+ const [mustNotHaveTags, setMustNotHaveTags] = React.useState((initialSelectedTags == null ? void 0 : initialSelectedTags.mustNotHave) || []);
121
+ const [shouldHaveAtLeastOneTags, setShouldHaveAtLeastOneTags] = React.useState((initialSelectedTags == null ? void 0 : initialSelectedTags.shouldHaveAtLeastOne) || []);
122
+ React.useEffect(() => {
123
+ if (initialSelectedTags) {
124
+ setMustHaveTags(initialSelectedTags.mustHave || []);
125
+ setMustNotHaveTags(initialSelectedTags.mustNotHave || []);
126
+ setShouldHaveAtLeastOneTags(initialSelectedTags.shouldHaveAtLeastOne || []);
127
+ }
128
+ }, [initialSelectedTags]);
63
129
  Tags = !!Tags ? Tags : [];
64
130
  const [inputValues, setInputValues] = React.useState({
65
131
  mustHave: "",
@@ -69,7 +135,7 @@ var TagsFilter = ({
69
135
  const tagOptions = React.useMemo(() => {
70
136
  console.log("available tags: " + JSON.stringify(Tags));
71
137
  console.log(!Tags);
72
- if (!Tags || Tags.length == 0 || !Tags.map) return [];
138
+ if (!Tags || Tags.length === 0 || !Tags.map) return [];
73
139
  return Tags.map((tag) => ({
74
140
  value: tag.id,
75
141
  label: tag.label
@@ -101,7 +167,7 @@ var TagsFilter = ({
101
167
  };
102
168
  const renderSelectedTags = (selectedTags, category) => {
103
169
  const tagValues = [];
104
- if (!Tags || Tags.length == 0 || !Tags.map) return null;
170
+ if (!Tags || Tags.length === 0 || !Tags.map) return null;
105
171
  Tags.forEach((tag) => {
106
172
  if (selectedTags.includes(tag.id)) {
107
173
  tagValues.push(tag);
@@ -110,27 +176,11 @@ var TagsFilter = ({
110
176
  if (tagValues.length === 0) {
111
177
  return null;
112
178
  }
113
- return /* @__PURE__ */ jsx(Box2, { sx: { display: "flex", flexWrap: "wrap", gap: 1, mb: 2 }, children: tagValues.map((tag) => /* @__PURE__ */ jsxs(
114
- "span",
179
+ return /* @__PURE__ */ jsx(Box8, { sx: { display: "flex", flexWrap: "wrap", gap: 1, mb: 2 }, children: tagValues.map((tag) => /* @__PURE__ */ jsx(
180
+ Chip,
115
181
  {
116
- className: "inline-block text-sm px-3 py-1 rounded-full outline-black outline-2 font-outlined",
117
- style: {
118
- background: tag.color || "#bfbcbb",
119
- color: "white",
120
- textShadow: "black 0.2em 0.2em 0.4em"
121
- },
122
- children: [
123
- tag.label,
124
- /* @__PURE__ */ jsx(
125
- "button",
126
- {
127
- type: "button",
128
- onClick: () => handleTagChange(tag.id, category),
129
- className: "ml-2 text-red-500 bg-white bg-opacity-50 rounded-full outline-black outline-2 font-outlined",
130
- children: "\xD7"
131
- }
132
- )
133
- ]
182
+ tag,
183
+ removeCallback: (tagId) => handleTagChange(tagId, category)
134
184
  },
135
185
  tag.id
136
186
  )) });
@@ -138,7 +188,7 @@ var TagsFilter = ({
138
188
  const createTagSelector = (category, label) => {
139
189
  const selectedTags = category === "mustHave" ? mustHaveTags : category === "mustNotHave" ? mustNotHaveTags : shouldHaveAtLeastOneTags;
140
190
  return /* @__PURE__ */ jsxs(Fragment, { children: [
141
- /* @__PURE__ */ jsx(Typography2, { variant: "subtitle1", gutterBottom: true, sx: { mt: 2 }, children: label }),
191
+ /* @__PURE__ */ jsx(Typography6, { variant: "subtitle1", gutterBottom: true, sx: { mt: 2 }, children: label }),
142
192
  renderSelectedTags(selectedTags, category),
143
193
  /* @__PURE__ */ jsx(
144
194
  Autocomplete,
@@ -191,11 +241,11 @@ var TagsFilter = ({
191
241
  ] });
192
242
  };
193
243
  return /* @__PURE__ */ jsxs(Fragment, { children: [
194
- /* @__PURE__ */ jsx(Typography2, { variant: "h6", gutterBottom: true, children: "Tags" }),
244
+ /* @__PURE__ */ jsx(Typography6, { variant: "h6", gutterBottom: true, children: "Tags" }),
195
245
  createTagSelector("mustHave", "Must Have Tags"),
196
- /* @__PURE__ */ jsx(Divider, { sx: { my: 2 } }),
246
+ /* @__PURE__ */ jsx(Divider2, { sx: { my: 2 } }),
197
247
  createTagSelector("mustNotHave", "Must Not Have Tags"),
198
- /* @__PURE__ */ jsx(Divider, { sx: { my: 2 } }),
248
+ /* @__PURE__ */ jsx(Divider2, { sx: { my: 2 } }),
199
249
  createTagSelector("shouldHaveAtLeastOne", "Should Contain At Least One Tag")
200
250
  ] });
201
251
  };
@@ -225,21 +275,80 @@ var CustomPopper = (props) => {
225
275
  );
226
276
  };
227
277
  var TagsFilter_default = TagsFilter;
228
- var FILTER_TYPES = [
229
- { id: "player", label: "Players" },
230
- { id: "event", label: "Events", disabled: true },
231
- { id: "table", label: "Tables", disabled: true }
232
- ];
233
- var TypeFilter = ({ onChange }) => {
234
- const [selectedTypes, setSelectedTypes] = React.useState([]);
278
+ var TextSearchCard = ({ onChange, selectedTypes, initialTextSearch }) => {
279
+ const [query, setQuery] = React.useState((initialTextSearch == null ? void 0 : initialTextSearch.query) || "");
280
+ const [titleOnly, setTitleOnly] = React.useState((initialTextSearch == null ? void 0 : initialTextSearch.titleOnly) || false);
281
+ useEffect(() => {
282
+ if (initialTextSearch) {
283
+ setQuery(initialTextSearch.query || "");
284
+ setTitleOnly(initialTextSearch.titleOnly || false);
285
+ }
286
+ }, [initialTextSearch]);
287
+ const shouldShow = selectedTypes.includes("table") || selectedTypes.includes("event");
288
+ if (!shouldShow) {
289
+ return null;
290
+ }
291
+ const handleQueryChange = (e) => {
292
+ const newQuery = e.target.value;
293
+ setQuery(newQuery);
294
+ if (onChange) {
295
+ onChange({ query: newQuery, titleOnly });
296
+ }
297
+ };
298
+ const handleTitleOnlyChange = (e) => {
299
+ const newTitleOnly = e.target.checked;
300
+ setTitleOnly(newTitleOnly);
301
+ if (onChange) {
302
+ onChange({ query, titleOnly: newTitleOnly });
303
+ }
304
+ };
305
+ return /* @__PURE__ */ jsxs(Fragment, { children: [
306
+ /* @__PURE__ */ jsx(Typography6, { variant: "h6", gutterBottom: true, children: "Text Search" }),
307
+ /* @__PURE__ */ jsxs(Box8, { sx: { mb: 2 }, children: [
308
+ /* @__PURE__ */ jsx(
309
+ TextField,
310
+ {
311
+ fullWidth: true,
312
+ label: "Search in title and description",
313
+ variant: "outlined",
314
+ value: query,
315
+ onChange: handleQueryChange,
316
+ placeholder: "Enter search terms...",
317
+ sx: { mb: 1 }
318
+ }
319
+ ),
320
+ /* @__PURE__ */ jsx(
321
+ FormControlLabel,
322
+ {
323
+ control: /* @__PURE__ */ jsx(
324
+ Checkbox,
325
+ {
326
+ checked: titleOnly,
327
+ onChange: handleTitleOnlyChange
328
+ }
329
+ ),
330
+ label: "Search in title only"
331
+ }
332
+ )
333
+ ] })
334
+ ] });
335
+ };
336
+ var TextSearchCard_default = TextSearchCard;
337
+ var TypeFilter = ({ types, initialSelectedTypes = [], onChange }) => {
338
+ const [selectedTypes, setSelectedTypes] = React.useState(initialSelectedTypes);
339
+ useEffect(() => {
340
+ setSelectedTypes(initialSelectedTypes);
341
+ }, [initialSelectedTypes]);
235
342
  const handleTypeChange = (typeId) => {
236
343
  const newSelectedTypes = selectedTypes.includes(typeId) ? selectedTypes.filter((id) => id !== typeId) : [...selectedTypes, typeId];
237
344
  setSelectedTypes(newSelectedTypes);
238
- onChange == null ? void 0 : onChange(newSelectedTypes);
345
+ if (onChange) {
346
+ onChange(newSelectedTypes);
347
+ }
239
348
  };
240
349
  return /* @__PURE__ */ jsxs(Fragment, { children: [
241
- /* @__PURE__ */ jsx(Typography2, { variant: "h6", gutterBottom: true, children: "Type" }),
242
- /* @__PURE__ */ jsx(FormGroup, { children: FILTER_TYPES.map((type) => /* @__PURE__ */ jsx(
350
+ /* @__PURE__ */ jsx(Typography6, { variant: "h6", gutterBottom: true, children: "Type" }),
351
+ /* @__PURE__ */ jsx(FormGroup, { children: types.map((type) => /* @__PURE__ */ jsx(
243
352
  FormControlLabel,
244
353
  {
245
354
  control: /* @__PURE__ */ jsx(
@@ -247,7 +356,8 @@ var TypeFilter = ({ onChange }) => {
247
356
  {
248
357
  checked: selectedTypes.includes(type.id),
249
358
  onChange: () => handleTypeChange(type.id),
250
- disabled: type.disabled
359
+ disabled: type.id === "event",
360
+ title: type.id === "event" ? "Coming soon! Currently only player and table search are supported." : ""
251
361
  }
252
362
  ),
253
363
  label: type.label
@@ -258,23 +368,68 @@ var TypeFilter = ({ onChange }) => {
258
368
  };
259
369
  var TypeFilter_default = TypeFilter;
260
370
  var FiltersContainer = ({
371
+ initialSelectedTypes = [],
372
+ initialSelectedTags,
373
+ initialTextSearch,
374
+ includeExpiredTables = false,
261
375
  onTypeChange,
262
376
  onTagChange,
377
+ onTextSearchChange,
378
+ onIncludeExpiredTablesChange,
263
379
  onSubmit,
264
- tags
380
+ tags,
381
+ searchTypes
265
382
  }) => {
266
- return /* @__PURE__ */ jsxs(Box2, { children: [
267
- /* @__PURE__ */ jsx(TypeFilter_default, { onChange: onTypeChange }),
268
- /* @__PURE__ */ jsx(Divider, { sx: { my: 2 } }),
383
+ const [selectedTypes, setSelectedTypes] = React.useState(initialSelectedTypes);
384
+ useEffect(() => {
385
+ setSelectedTypes(initialSelectedTypes);
386
+ }, [initialSelectedTypes]);
387
+ const handleTypeChange = (types) => {
388
+ setSelectedTypes(types);
389
+ if (onTypeChange) {
390
+ onTypeChange(types);
391
+ }
392
+ };
393
+ return /* @__PURE__ */ jsxs(Box8, { children: [
394
+ /* @__PURE__ */ jsx(
395
+ TypeFilter_default,
396
+ {
397
+ types: searchTypes,
398
+ initialSelectedTypes,
399
+ onChange: handleTypeChange
400
+ }
401
+ ),
402
+ /* @__PURE__ */ jsx(Divider2, { sx: { my: 2 } }),
403
+ /* @__PURE__ */ jsx(
404
+ TextSearchCard_default,
405
+ {
406
+ selectedTypes,
407
+ initialTextSearch,
408
+ onChange: onTextSearchChange
409
+ }
410
+ ),
411
+ (selectedTypes.includes("table") || selectedTypes.includes("event")) && /* @__PURE__ */ jsx(Divider2, { sx: { my: 2 } }),
269
412
  /* @__PURE__ */ jsx(
270
413
  TagsFilter_default,
271
414
  {
272
415
  tags,
416
+ initialSelectedTags,
273
417
  onChange: onTagChange
274
418
  }
275
419
  ),
276
- /* @__PURE__ */ jsx(Divider, { sx: { my: 2 } }),
277
- /* @__PURE__ */ jsx(Box2, { sx: { display: "flex", justifyContent: "center", mt: 2 }, children: /* @__PURE__ */ jsx(
420
+ /* @__PURE__ */ jsx(Divider2, { sx: { my: 2 } }),
421
+ selectedTypes.includes("table") && /* @__PURE__ */ jsxs(Fragment, { children: [
422
+ /* @__PURE__ */ jsx(
423
+ ExpiredTablesFilter_default,
424
+ {
425
+ includeExpiredTables,
426
+ onChange: onIncludeExpiredTablesChange || (() => {
427
+ })
428
+ }
429
+ ),
430
+ /* @__PURE__ */ jsx(Divider2, { sx: { my: 2 } })
431
+ ] }),
432
+ /* @__PURE__ */ jsx(Box8, { sx: { display: "flex", justifyContent: "center", mt: 2 }, children: /* @__PURE__ */ jsx(
278
433
  Button,
279
434
  {
280
435
  variant: "contained",
@@ -299,41 +454,24 @@ var FiltersContainer = ({
299
454
  ] });
300
455
  };
301
456
  var FiltersContainer_default = FiltersContainer;
302
- function Chip({ tag, removeCallback }) {
303
- var _a;
304
- const color = (_a = tag.color) != null ? _a : "#bfbcbb";
305
- return /* @__PURE__ */ jsx(Fragment, { children: /* @__PURE__ */ jsxs(
306
- "span",
307
- {
308
- className: "inline-block text-sm px-3 py-1 rounded-full border-2 font-outlined text-white m-0.5 font-stretch-105% font-sans",
309
- style: {
310
- borderColor: `color-mix(in srgb, ${color}, black 50%)`,
311
- background: `linear-gradient(160deg, color-mix(in srgb, ${color}, white 10%) 0%, color-mix(in srgb, ${color}, black 60%) 100%)`,
312
- textShadow: "black 1.5px 1px 1.5px",
313
- filter: `drop-shadow(2px 2px 1.5px color-mix(in srgb, ${color}, black 80%))`
314
- },
315
- children: [
316
- tag.label,
317
- removeCallback && /* @__PURE__ */ jsx(
318
- "button",
319
- {
320
- type: "button",
321
- onClick: () => removeCallback(tag.id),
322
- className: "ml-2 text-white hover:text-red-700 focus:outline-none pl-0.5 pr-1 cursor-pointer hover:bg-white rounded-full",
323
- style: {
324
- textShadow: "black 1px 1px 1px"
325
- },
326
- children: "X"
327
- }
328
- )
329
- ]
330
- },
331
- tag.id
332
- ) });
333
- }
457
+ var NextGameLabel = ({ nextGameTime }) => {
458
+ const date = typeof nextGameTime === "string" ? new Date(nextGameTime) : nextGameTime;
459
+ return /* @__PURE__ */ jsxs(Typography, { variant: "caption", sx: { display: "block", mb: 1, color: "primary.main", fontWeight: "bold" }, children: [
460
+ "Next Game: ",
461
+ date.toLocaleString()
462
+ ] });
463
+ };
464
+ var NextGameLabel_default = NextGameLabel;
334
465
  function generateTagsDisplay(tag) {
335
466
  return /* @__PURE__ */ jsx(Chip, { tag }, tag.id);
336
467
  }
468
+ function renderTagsFromIds(ids, legalTags) {
469
+ if (!ids || !legalTags || legalTags.length === 0) {
470
+ return /* @__PURE__ */ jsx(Fragment, {});
471
+ }
472
+ const validTags = ids.map((id) => legalTags.find((tag) => tag.id === id)).filter((tag) => Boolean(tag));
473
+ return validTags.map((tag) => generateTagsDisplay(tag));
474
+ }
337
475
  var BaseSearchResultCard = ({
338
476
  result,
339
477
  onClick,
@@ -341,13 +479,19 @@ var BaseSearchResultCard = ({
341
479
  icon,
342
480
  tags
343
481
  }) => {
344
- const handleClick = () => {
482
+ const handleClick = (e) => {
345
483
  if (onClick) {
346
- onClick(result.id);
484
+ if (e.ctrlKey || e.metaKey || e.shiftKey) {
485
+ e.stopPropagation();
486
+ const url = `/${result.type}/${result.id}`;
487
+ window.open(url, "_blank");
488
+ } else {
489
+ onClick(result.id);
490
+ }
347
491
  }
348
492
  };
349
493
  return /* @__PURE__ */ jsx(
350
- Card,
494
+ Card2,
351
495
  {
352
496
  elevation: 6,
353
497
  sx: {
@@ -360,48 +504,22 @@ var BaseSearchResultCard = ({
360
504
  },
361
505
  marginBottom: 2
362
506
  },
363
- onClick: handleClick,
364
- children: /* @__PURE__ */ jsxs(CardContent, { sx: { display: "flex", alignItems: "flex-start" }, children: [
365
- icon && /* @__PURE__ */ jsx(Box, { sx: { mr: 2, display: "flex", alignItems: "center", pt: 0.5 }, children: icon }),
366
- /* @__PURE__ */ jsxs(Box, { sx: { flex: 1 }, children: [
367
- /* @__PURE__ */ jsx(Typography, { variant: "h6", sx: { mb: 1 }, children: result.title }),
507
+ onClick: (e) => handleClick(e),
508
+ children: /* @__PURE__ */ jsxs(CardContent2, { sx: { display: "flex", alignItems: "flex-start" }, children: [
509
+ icon && /* @__PURE__ */ jsx(Box8, { sx: { mr: 2, display: "flex", alignItems: "center", pt: 0.5 }, children: icon }),
510
+ /* @__PURE__ */ jsxs(Box8, { sx: { flex: 1 }, children: [
511
+ /* @__PURE__ */ jsx(Typography6, { variant: "h6", sx: { mb: 1 }, children: result.title }),
512
+ result.nextGameTime && /* @__PURE__ */ jsx(NextGameLabel_default, { nextGameTime: result.nextGameTime }),
513
+ result.type === "table" && result.shortDescription ? /* @__PURE__ */ jsx(Typography6, { variant: "body2", sx: { mb: 1 }, children: result.shortDescription }) : null,
368
514
  children,
369
- /* @__PURE__ */ jsx(Typography, { variant: "body1", children: result.description }),
370
- result.tags && result.tags.length > 0 && /* @__PURE__ */ jsx(Box, { sx: { mt: 1 }, children: /* @__PURE__ */ jsx(Box, { sx: {
371
- display: "block",
372
- whiteSpace: "nowrap",
373
- overflow: "hidden",
374
- textOverflow: "clip",
375
- pl: 0.5
376
- // Add some padding to prevent clipping of the leftmost tag
377
- }, children: (() => {
378
- const MAX_VISIBLE = 5;
379
- const tagObjs = result.tags.map((tagId) => tags.find((t) => t.id === tagId)).filter((t) => Boolean(t));
380
- const visible = tagObjs.slice(0, MAX_VISIBLE);
381
- const hiddenCount = Math.max(tagObjs.length - visible.length, 0);
382
- return /* @__PURE__ */ jsxs(Fragment, { children: [
383
- visible.map((tag) => generateTagsDisplay(tag)),
384
- hiddenCount > 0 && /* @__PURE__ */ jsxs(
385
- "span",
386
- {
387
- className: "inline-block text-sm px-3 py-1 rounded-full outline-black outline-2 font-outlined",
388
- style: {
389
- marginTop: "6px",
390
- marginRight: "6px",
391
- marginBottom: "6px",
392
- background: "#9e9e9e",
393
- color: "white",
394
- textShadow: "black 0.2em 0.2em 0.4em"
395
- },
396
- children: [
397
- "+",
398
- hiddenCount,
399
- " more"
400
- ]
401
- }
402
- )
403
- ] });
404
- })() }) })
515
+ result.type === "table" ? /* @__PURE__ */ jsx(Typography6, { variant: "body1", children: (() => {
516
+ var _a, _b;
517
+ const full = (_b = (_a = result.fullDescription) != null ? _a : result.description) != null ? _b : "";
518
+ if (typeof full !== "string") return "";
519
+ const text = full || "";
520
+ return text.length > 200 ? `${text.slice(0, 200).trimEnd()}...` : text;
521
+ })() }) : /* @__PURE__ */ jsx(Typography6, { variant: "body1", children: result.description }),
522
+ result.tags && result.tags.length > 0 && /* @__PURE__ */ jsx(Box8, { sx: { mt: 1, display: "flex", flexWrap: "wrap", gap: 1 }, children: renderTagsFromIds(result.tags, tags) })
405
523
  ] })
406
524
  ] })
407
525
  }
@@ -456,21 +574,60 @@ var PlayerResultCard = ({
456
574
  return /* @__PURE__ */ jsx(BaseSearchResultCard_default, { result, onClick, icon: playerIcon, tags });
457
575
  };
458
576
  var PlayerResultCard_default = PlayerResultCard;
459
- var TableResultCard = ({ result, tags, onClick }) => {
460
- const capacity = result.capacity || 1;
461
- const numPlayers = result.numPlayers || 0;
462
- const occupancy = numPlayers / capacity * 100;
463
- return /* @__PURE__ */ jsx(BaseSearchResultCard, { result, tags, onClick, icon: /* @__PURE__ */ jsx(CasinoIcon, { color: "primary" }), children: /* @__PURE__ */ jsxs(Box, { sx: { mb: 1 }, children: [
464
- /* @__PURE__ */ jsxs(Box, { sx: { display: "flex", justifyContent: "space-between", alignItems: "center", mb: 0.5 }, children: [
465
- /* @__PURE__ */ jsxs(Typography, { variant: "body2", color: "text.secondary", children: [
466
- "Players: ",
467
- numPlayers,
468
- " / ",
469
- capacity
577
+ var TableResultCard = ({
578
+ result,
579
+ onClick,
580
+ tags
581
+ }) => {
582
+ const rawCapacity = result.capacity;
583
+ const hasDefinedCapacity = typeof rawCapacity === "number" && Number.isFinite(rawCapacity) && rawCapacity > 0;
584
+ const capacity = hasDefinedCapacity ? rawCapacity : 0;
585
+ const activePlayers = typeof result.numPlayers === "number" ? result.numPlayers : 0;
586
+ const availableSlots = Math.max(capacity - activePlayers, 0);
587
+ const hasDM = typeof result.hasDM === "boolean" ? result.hasDM : Boolean(result.dungeonMaster);
588
+ const occupancyPercentage = hasDefinedCapacity ? activePlayers / capacity * 100 : 100;
589
+ const tableIcon = /* @__PURE__ */ jsx(
590
+ TableRestaurantIcon,
591
+ {
592
+ sx: {
593
+ fontSize: 40,
594
+ color: "primary.main"
595
+ }
596
+ }
597
+ );
598
+ return /* @__PURE__ */ jsx(BaseSearchResultCard_default, { result, onClick, icon: tableIcon, tags, children: /* @__PURE__ */ jsxs(Box8, { sx: { mb: 2 }, children: [
599
+ /* @__PURE__ */ jsxs(Box8, { sx: { display: "flex", justifyContent: "space-between", alignItems: "center", mb: 1 }, children: [
600
+ /* @__PURE__ */ jsxs(Typography6, { variant: "body2", children: [
601
+ /* @__PURE__ */ jsx("strong", { children: "Players:" }),
602
+ " ",
603
+ hasDefinedCapacity ? `${activePlayers}/${capacity}` : activePlayers
470
604
  ] }),
471
- result.dungeonMaster ? /* @__PURE__ */ jsx(Chip$1, { label: "DM Present", size: "small", color: "success", variant: "outlined" }) : /* @__PURE__ */ jsx(Chip$1, { label: "No DM", size: "small", color: "warning", variant: "outlined" })
605
+ typeof hasDM === "boolean" && /* @__PURE__ */ jsx(
606
+ Chip2,
607
+ {
608
+ icon: hasDM ? /* @__PURE__ */ jsx(SupervisorAccountIcon, {}) : /* @__PURE__ */ jsx(PersonIcon, {}),
609
+ label: hasDM ? "DM Present" : "No DM",
610
+ color: hasDM ? "success" : "warning",
611
+ size: "small"
612
+ }
613
+ )
472
614
  ] }),
473
- /* @__PURE__ */ jsx(LinearProgress, { variant: "determinate", value: occupancy, sx: { height: 8, borderRadius: 4 } })
615
+ /* @__PURE__ */ jsx(
616
+ LinearProgress,
617
+ {
618
+ variant: "determinate",
619
+ value: occupancyPercentage,
620
+ sx: {
621
+ height: 10,
622
+ borderRadius: 5,
623
+ backgroundColor: "#e0e0e0",
624
+ "& .MuiLinearProgress-bar": {
625
+ backgroundColor: hasDefinedCapacity ? availableSlots > 0 ? "#4caf50" : "#f44336" : "#2196f3"
626
+ }
627
+ }
628
+ }
629
+ ),
630
+ hasDefinedCapacity && /* @__PURE__ */ jsx(Typography6, { variant: "body2", sx: { mt: 0.5, textAlign: "right" }, children: availableSlots > 0 ? `${availableSlots} slot${availableSlots !== 1 ? "s" : ""} available` : "Table full" })
474
631
  ] }) });
475
632
  };
476
633
  var TableResultCard_default = TableResultCard;
@@ -489,20 +646,42 @@ var EventResultCard = ({
489
646
  try {
490
647
  const date = new Date(dateString);
491
648
  return date.toLocaleDateString("en-US", options);
492
- } catch {
649
+ } catch (error) {
493
650
  return dateString;
494
651
  }
495
652
  };
496
653
  const formattedDate = result.date ? formatDate(result.date) : "Date TBD";
497
654
  const location = result.location || "Location TBD";
498
- return /* @__PURE__ */ jsx(BaseSearchResultCard_default, { result, onClick, icon: /* @__PURE__ */ jsx(EventIcon, { color: "primary" }), tags, children: /* @__PURE__ */ jsxs(Box, { sx: { mb: 1 }, children: [
499
- /* @__PURE__ */ jsxs(Box, { sx: { display: "flex", alignItems: "center", mb: 0.5 }, children: [
500
- /* @__PURE__ */ jsx(CalendarTodayIcon, { sx: { mr: 1, fontSize: "small", color: "text.secondary" } }),
501
- /* @__PURE__ */ jsx(Typography, { variant: "body2", color: "text.secondary", children: formattedDate })
655
+ const eventIcon = /* @__PURE__ */ jsx(
656
+ EventIcon,
657
+ {
658
+ sx: {
659
+ fontSize: 40,
660
+ color: "primary.main"
661
+ }
662
+ }
663
+ );
664
+ return /* @__PURE__ */ jsx(BaseSearchResultCard_default, { result, onClick, icon: eventIcon, tags, children: /* @__PURE__ */ jsxs(Box8, { sx: { mb: 2 }, children: [
665
+ /* @__PURE__ */ jsxs(Box8, { sx: { display: "flex", alignItems: "center", mb: 1 }, children: [
666
+ /* @__PURE__ */ jsx(CalendarTodayIcon, { sx: { mr: 1, color: "primary.main" } }),
667
+ /* @__PURE__ */ jsxs(Typography6, { variant: "body2", children: [
668
+ /* @__PURE__ */ jsx("strong", { children: "Date:" }),
669
+ " ",
670
+ formattedDate
671
+ ] })
672
+ ] }),
673
+ /* @__PURE__ */ jsxs(Box8, { sx: { display: "flex", alignItems: "center" }, children: [
674
+ /* @__PURE__ */ jsx(LocationOnIcon, { sx: { mr: 1, color: "primary.main" } }),
675
+ /* @__PURE__ */ jsxs(Typography6, { variant: "body2", children: [
676
+ /* @__PURE__ */ jsx("strong", { children: "Location:" }),
677
+ " ",
678
+ location
679
+ ] })
502
680
  ] }),
503
- /* @__PURE__ */ jsxs(Box, { sx: { display: "flex", alignItems: "center", mb: 1 }, children: [
504
- /* @__PURE__ */ jsx(LocationOnIcon, { sx: { mr: 1, fontSize: "small", color: "text.secondary" } }),
505
- /* @__PURE__ */ jsx(Typography, { variant: "body2", color: "text.secondary", children: location })
681
+ result.organizer && /* @__PURE__ */ jsxs(Typography6, { variant: "body2", sx: { mt: 1 }, children: [
682
+ /* @__PURE__ */ jsx("strong", { children: "Organizer:" }),
683
+ " ",
684
+ result.organizer
506
685
  ] })
507
686
  ] }) });
508
687
  };
@@ -510,10 +689,12 @@ var EventResultCard_default = EventResultCard;
510
689
  var ResultsContainer = ({
511
690
  results,
512
691
  onResultClick,
513
- tags
692
+ tags,
693
+ pagination,
694
+ onPacketChange
514
695
  }) => {
515
- if (results.length === 0 || !results.map) {
516
- return /* @__PURE__ */ jsx(Box2, { sx: { textAlign: "center", py: 4 }, children: "No results found. Try adjusting your filters." });
696
+ if (!results || results.length === 0 || !results.map) {
697
+ return /* @__PURE__ */ jsx(Box8, { sx: { textAlign: "center", py: 4 }, children: "No results found. Try adjusting your filters." });
517
698
  }
518
699
  const onPlayerClick = (id) => {
519
700
  onResultClick == null ? void 0 : onResultClick(id, "player");
@@ -524,43 +705,68 @@ var ResultsContainer = ({
524
705
  const onEventClick = (id) => {
525
706
  onResultClick == null ? void 0 : onResultClick(id, "event");
526
707
  };
527
- return /* @__PURE__ */ jsx(Box2, { sx: { display: "flex", flexDirection: "column", gap: 2 }, children: results.map((result) => {
528
- switch (result.type) {
529
- case "player":
530
- return /* @__PURE__ */ jsx(
531
- PlayerResultCard_default,
532
- {
533
- result,
534
- onClick: onPlayerClick,
535
- tags
536
- },
537
- result.id
538
- );
539
- case "table":
540
- return /* @__PURE__ */ jsx(
541
- TableResultCard_default,
542
- {
543
- result,
544
- onClick: onTableClick,
545
- tags
546
- },
547
- result.id
548
- );
549
- case "event":
550
- return /* @__PURE__ */ jsx(
551
- EventResultCard_default,
552
- {
553
- result,
554
- onClick: onEventClick,
555
- tags
556
- },
557
- result.id
558
- );
559
- default:
560
- console.error(`Unknown result type: ${result.type}`);
561
- return null;
562
- }
563
- }) });
708
+ const handlePacketChange = (_event, packet) => {
709
+ onPacketChange == null ? void 0 : onPacketChange(packet);
710
+ };
711
+ const startResult = pagination ? (pagination.currentPacket - 1) * pagination.packetSize + 1 : 1;
712
+ const endResult = pagination ? Math.min(pagination.currentPacket * pagination.packetSize, pagination.totalResults) : results.length;
713
+ return /* @__PURE__ */ jsxs(Box8, { sx: { display: "flex", flexDirection: "column", gap: 2 }, children: [
714
+ pagination && /* @__PURE__ */ jsx(Box8, { sx: { display: "flex", justifyContent: "space-between", alignItems: "center", mb: 1 }, children: /* @__PURE__ */ jsxs(Typography6, { variant: "body2", color: "text.secondary", children: [
715
+ "Showing ",
716
+ startResult,
717
+ "-",
718
+ endResult,
719
+ " of ",
720
+ pagination.totalResults,
721
+ " results"
722
+ ] }) }),
723
+ results.map((result, index) => {
724
+ switch (result.type) {
725
+ case "player":
726
+ return /* @__PURE__ */ jsx(
727
+ PlayerResultCard_default,
728
+ {
729
+ result,
730
+ onClick: onPlayerClick,
731
+ tags
732
+ },
733
+ result.id
734
+ );
735
+ case "table":
736
+ return /* @__PURE__ */ jsx(
737
+ TableResultCard_default,
738
+ {
739
+ result,
740
+ onClick: onTableClick,
741
+ tags
742
+ },
743
+ result.id
744
+ );
745
+ case "event":
746
+ return /* @__PURE__ */ jsx(
747
+ EventResultCard_default,
748
+ {
749
+ result,
750
+ onClick: onEventClick,
751
+ tags
752
+ },
753
+ result.id
754
+ );
755
+ default:
756
+ console.error(`Unknown result type: ${result.type}`);
757
+ return null;
758
+ }
759
+ }),
760
+ pagination && pagination.totalPackets > 1 && /* @__PURE__ */ jsx(Box8, { sx: { display: "flex", justifyContent: "center", mt: 4 }, children: /* @__PURE__ */ jsx(
761
+ Pagination,
762
+ {
763
+ count: pagination.totalPackets,
764
+ page: pagination.currentPacket,
765
+ onChange: handlePacketChange,
766
+ color: "primary"
767
+ }
768
+ ) })
769
+ ] });
564
770
  };
565
771
  var ResultsContainer_default = ResultsContainer;
566
772
  var ScrollableResultsList = ({
@@ -571,7 +777,7 @@ var ScrollableResultsList = ({
571
777
  emptyText
572
778
  }) => {
573
779
  const hasResults = Array.isArray(results) && results.length > 0;
574
- return /* @__PURE__ */ jsx(Box2, { sx: { maxHeight, overflowY: "auto", pr: 1 }, children: hasResults ? /* @__PURE__ */ jsx(ResultsContainer_default, { results, onResultClick, tags }) : /* @__PURE__ */ jsx(Box2, { sx: { textAlign: "center", py: 2 }, children: emptyText || "No results to display." }) });
780
+ return /* @__PURE__ */ jsx(Box8, { sx: { maxHeight, overflowY: "auto", pr: 1 }, children: hasResults ? /* @__PURE__ */ jsx(ResultsContainer_default, { results, onResultClick, tags }) : /* @__PURE__ */ jsx(Box8, { sx: { textAlign: "center", py: 2 }, children: emptyText || "No results to display." }) });
575
781
  };
576
782
  var ScrollableResultsList_default = ScrollableResultsList;
577
783
  var PlayersScrollableList = ({
@@ -606,17 +812,76 @@ var SearchResultCard_default = SearchResultCard;
606
812
  function SearchPageLayout({
607
813
  results,
608
814
  title = "Search Results",
815
+ initialSelectedTypes = [],
816
+ initialSelectedTags = {
817
+ mustHave: [],
818
+ mustNotHave: [],
819
+ shouldHaveAtLeastOne: []
820
+ },
821
+ initialTextSearch = {
822
+ query: "",
823
+ titleOnly: false
824
+ },
825
+ includeExpiredTables: initialIncludeExpiredTables = false,
609
826
  onTypeChange,
610
827
  onTagChange,
828
+ onTextSearchChange,
829
+ onIncludeExpiredTablesChange,
611
830
  onSubmit,
612
831
  onResultClick,
832
+ onPacketChange,
833
+ pagination,
613
834
  validTags,
614
- allTags
835
+ allTags,
836
+ searchTypes,
837
+ isLoading = false
615
838
  }) {
616
- "use client";
617
839
  const theme = useTheme();
618
840
  const isMobile = useMediaQuery(theme.breakpoints.down("md"));
619
- return /* @__PURE__ */ jsxs(Box2, { sx: { padding: 2 }, children: [
841
+ const [selectedTypes, setSelectedTypes] = useState(initialSelectedTypes);
842
+ const [selectedTags, setSelectedTags] = useState(initialSelectedTags);
843
+ const [textSearch, setTextSearch] = useState(initialTextSearch);
844
+ const [includeExpiredTables, setIncludeExpiredTables] = useState(initialIncludeExpiredTables);
845
+ useEffect(() => {
846
+ setSelectedTypes(initialSelectedTypes);
847
+ }, [initialSelectedTypes]);
848
+ useEffect(() => {
849
+ setSelectedTags(initialSelectedTags);
850
+ }, [initialSelectedTags]);
851
+ useEffect(() => {
852
+ setTextSearch(initialTextSearch);
853
+ }, [initialTextSearch]);
854
+ useEffect(() => {
855
+ setIncludeExpiredTables(initialIncludeExpiredTables);
856
+ }, [initialIncludeExpiredTables]);
857
+ const handleTypeChange = (types) => {
858
+ setSelectedTypes(types);
859
+ if (onTypeChange) onTypeChange(types);
860
+ };
861
+ const handleTagChange = (tags) => {
862
+ setSelectedTags(tags);
863
+ if (onTagChange) onTagChange(tags);
864
+ };
865
+ const handleTextSearchChange = (ts) => {
866
+ setTextSearch(ts);
867
+ if (onTextSearchChange) onTextSearchChange(ts);
868
+ };
869
+ const handleIncludeExpiredTablesChange = (include) => {
870
+ setIncludeExpiredTables(include);
871
+ if (onIncludeExpiredTablesChange) onIncludeExpiredTablesChange(include);
872
+ };
873
+ const handleSubmit = () => {
874
+ const currentCriteria = {
875
+ selectedTypes,
876
+ selectedTags,
877
+ textSearch,
878
+ includeExpiredTables
879
+ };
880
+ if (onSubmit) {
881
+ onSubmit(currentCriteria);
882
+ }
883
+ };
884
+ return /* @__PURE__ */ jsxs(Box8, { sx: { padding: 2 }, children: [
620
885
  /* @__PURE__ */ jsx(Card2, { sx: { marginBottom: 2 }, children: /* @__PURE__ */ jsx(
621
886
  CardHeader,
622
887
  {
@@ -646,10 +911,17 @@ function SearchPageLayout({
646
911
  /* @__PURE__ */ jsx(CardContent2, { children: /* @__PURE__ */ jsx(
647
912
  FiltersContainer_default,
648
913
  {
649
- onTypeChange,
650
- onTagChange,
651
- onSubmit,
652
- tags: validTags
914
+ initialSelectedTypes: selectedTypes,
915
+ initialSelectedTags: selectedTags,
916
+ initialTextSearch: textSearch,
917
+ includeExpiredTables,
918
+ onTypeChange: handleTypeChange,
919
+ onTagChange: handleTagChange,
920
+ onTextSearchChange: handleTextSearchChange,
921
+ onIncludeExpiredTablesChange: handleIncludeExpiredTablesChange,
922
+ onSubmit: handleSubmit,
923
+ tags: validTags,
924
+ searchTypes
653
925
  }
654
926
  ) })
655
927
  ] }) }),
@@ -666,10 +938,12 @@ function SearchPageLayout({
666
938
  }
667
939
  }
668
940
  ),
669
- /* @__PURE__ */ jsx(CardContent2, { children: /* @__PURE__ */ jsx(
941
+ /* @__PURE__ */ jsx(CardContent2, { children: isLoading ? /* @__PURE__ */ jsx(Box8, { sx: { display: "flex", justifyContent: "center", py: 8 }, children: /* @__PURE__ */ jsx(CircularProgress, { size: 60, thickness: 4 }) }) : /* @__PURE__ */ jsx(
670
942
  ResultsContainer_default,
671
943
  {
672
944
  results,
945
+ pagination,
946
+ onPacketChange,
673
947
  onResultClick,
674
948
  tags: allTags
675
949
  }
@@ -682,21 +956,14 @@ var TablesScrollableList = ({
682
956
  results,
683
957
  tags,
684
958
  maxHeight,
685
- onResultClick,
686
- sortBy = "availability"
959
+ onResultClick
687
960
  }) => {
688
961
  const tables = (results || []).filter((r) => (r == null ? void 0 : r.type) === "table");
689
- const getAvailableSlots = (r) => {
690
- const capacity = typeof r.capacity === "number" ? r.capacity : 0;
691
- const playersCount = typeof r.numPlayers === "number" ? r.numPlayers : 0;
692
- return Math.max(capacity - playersCount, 0);
693
- };
694
- const sortedTables = sortBy === "availability" ? [...tables].sort((a, b) => getAvailableSlots(b) - getAvailableSlots(a)) : tables;
695
962
  const handleClick = (id) => onResultClick == null ? void 0 : onResultClick(id);
696
963
  return /* @__PURE__ */ jsx(
697
964
  ScrollableResultsList_default,
698
965
  {
699
- results: sortedTables,
966
+ results: tables,
700
967
  tags,
701
968
  maxHeight,
702
969
  onResultClick: (id, type) => {
@@ -707,6 +974,6 @@ var TablesScrollableList = ({
707
974
  };
708
975
  var TablesScrollableList_default = TablesScrollableList;
709
976
 
710
- export { BaseSearchResultCard_default as BaseSearchResultCard, EventResultCard_default as EventResultCard, FiltersContainer_default as FiltersContainer, PlayerResultCard_default as PlayerResultCard, PlayersScrollableList_default as PlayersScrollableList, ResultsContainer_default as ResultsContainer, ScrollableResultsList_default as ScrollableResultsList, SearchPageLayout, SearchResultCard_default as SearchResultCard, SortOptions_default as SortOptions, TableResultCard_default as TableResultCard, TablesScrollableList_default as TablesScrollableList, TagsFilter_default as TagsFilter, TypeFilter_default as TypeFilter };
977
+ export { BaseSearchResultCard_default as BaseSearchResultCard, EventResultCard_default as EventResultCard, ExpiredTablesFilter_default as ExpiredTablesFilter, FiltersContainer_default as FiltersContainer, PlayerResultCard_default as PlayerResultCard, PlayersScrollableList_default as PlayersScrollableList, ResultsContainer_default as ResultsContainer, ScrollableResultsList_default as ScrollableResultsList, SearchPageLayout, SearchResultCard_default as SearchResultCard, SortOptions_default as SortOptions, TableResultCard_default as TableResultCard, TablesScrollableList_default as TablesScrollableList, TagsFilter_default as TagsFilter, TextSearchCard_default as TextSearchCard, TypeFilter_default as TypeFilter };
711
978
  //# sourceMappingURL=SearchPage.mjs.map
712
979
  //# sourceMappingURL=SearchPage.mjs.map