1(globalThis["TURBOPACK"] || (globalThis["TURBOPACK"] = [])).push([typeof document === "object" ? document.currentScript : undefined, 2145963, 608199, 3((__turbopack_context__) => { 4"use strict"; 5 6// MERGED MODULE: [project]/node_modules/date-fns/endOfDay.js [app-client] (ecmascript) 7; 8var __TURBOPACK__imported__module__281092__ = __turbopack_context__.i(281092); 9; 10function endOfDay(date, options) { 11 const _date = (0, __TURBOPACK__imported__module__281092__["toDate"])(date, options?.in); 12 _date.setHours(23, 59, 59, 999); 13 return _date; 14} 15const __TURBOPACK__default__export__ = endOfDay; 16__turbopack_context__.s([ 17 "endOfDay", 18 0, 19 endOfDay 20], 145963); 21// MERGED MODULE: [project]/node_modules/date-fns/startOfMonth.js [app-client] (ecmascript) 22; 23var __TURBOPACK__imported__module__281092__1 = __TURBOPACK__imported__module__281092__; 24; 25function startOfMonth(date, options) { 26 const _date = (0, __TURBOPACK__imported__module__281092__1["toDate"])(date, options?.in); 27 _date.setDate(1); 28 _date.setHours(0, 0, 0, 0); 29 return _date; 30} 31const __TURBOPACK__default__export__1 = startOfMonth; 32__turbopack_context__.s([ 33 "startOfMonth", 34 0, 35 startOfMonth 36], 608199); 37}), 38595727, ((__turbopack_context__) => { 39"use strict"; 40 41var __TURBOPACK__imported__module__677241__ = __turbopack_context__.i(677241); 42var __TURBOPACK__imported__module__281092__ = __turbopack_context__.i(281092); 43; 44; 45function addDays(date, amount, options) { 46 const _date = (0, __TURBOPACK__imported__module__281092__["toDate"])(date, options?.in); 47 if (isNaN(amount)) return (0, __TURBOPACK__imported__module__677241__["constructFrom"])(options?.in || date, NaN); 48 // If 0 days, no-op to avoid changing times in the hour before end of DST 49 if (!amount) return _date; 50 _date.setDate(_date.getDate() + amount); 51 return _date; 52} 53const __TURBOPACK__default__export__ = addDays; 54__turbopack_context__.s([ 55 "addDays", 56 0, 57 addDays 58]); 59}), 60688594, ((__turbopack_context__) => { 61"use strict"; 62 63var __TURBOPACK__imported__module__677241__ = __turbopack_context__.i(677241); 64var __TURBOPACK__imported__module__281092__ = __turbopack_context__.i(281092); 65; 66; 67function addMonths(date, amount, options) { 68 const _date = (0, __TURBOPACK__imported__module__281092__["toDate"])(date, options?.in); 69 if (isNaN(amount)) return (0, __TURBOPACK__imported__module__677241__["constructFrom"])(options?.in || date, NaN); 70 if (!amount) { 71 // If 0 months, no-op to avoid changing times in the hour before end of DST 72 return _date; 73 } 74 const dayOfMonth = _date.getDate(); 75 // The JS Date object supports date math by accepting out-of-bounds values for 76 // month, day, etc. For example, new Date(2020, 0, 0) returns 31 Dec 2019 and 77 // new Date(2020, 13, 1) returns 1 Feb 2021. This is *almost* the behavior we 78 // want except that dates will wrap around the end of a month, meaning that 79 // new Date(2020, 13, 31) will return 3 Mar 2021 not 28 Feb 2021 as desired. So 80 // we'll default to the end of the desired month by adding 1 to the desired 81 // month and using a date of 0 to back up one day to the end of the desired 82 // month. 83 const endOfDesiredMonth = (0, __TURBOPACK__imported__module__677241__["constructFrom"])(options?.in || date, _date.getTime()); 84 endOfDesiredMonth.setMonth(_date.getMonth() + amount + 1, 0); 85 const daysInMonth = endOfDesiredMonth.getDate(); 86 if (dayOfMonth >= daysInMonth) { 87 // If we're already at the end of the month, then this is the correct date 88 // and we're done. 89 return endOfDesiredMonth; 90 } else { 91 // Otherwise, we now know that setting the original day-of-month value won't 92 // cause an overflow, so set the desired day-of-month. Note that we can't 93 // just set the date of `endOfDesiredMonth` because that object may have had 94 // its time changed in the unusual case where where a DST transition was on 95 // the last day of the month and its local time was in the hour skipped or 96 // repeated next to a DST transition. So we use `date` instead which is 97 // guaranteed to still have the original time. 98 _date.setFullYear(endOfDesiredMonth.getFullYear(), endOfDesiredMonth.getMonth(), dayOfMonth); 99 return _date; 100 } 101} 102const __TURBOPACK__default__export__ = addMonths; 103__turbopack_context__.s([ 104 "addMonths", 105 0, 106 addMonths 107]); 108}), 109751371, 619578, 110510637, 111((__turbopack_context__) => { 112"use strict"; 113 114// MERGED MODULE: [project]/node_modules/date-fns/subDays.js [app-client] (ecmascript) 115; 116var __TURBOPACK__imported__module__595727__ = __turbopack_context__.i(595727); 117; 118function subDays(date, amount, options) { 119 return (0, __TURBOPACK__imported__module__595727__["addDays"])(date, -amount, options); 120} 121const __TURBOPACK__default__export__ = subDays; 122__turbopack_context__.s([ 123 "subDays", 124 0, 125 subDays 126], 751371); 127// MERGED MODULE: [project]/node_modules/date-fns/subMonths.js [app-client] (ecmascript) 128; 129var __TURBOPACK__imported__module__688594__ = __turbopack_context__.i(688594); 130; 131function subMonths(date, amount, options) { 132 return (0, __TURBOPACK__imported__module__688594__["addMonths"])(date, -amount, options); 133} 134const __TURBOPACK__default__export__1 = subMonths; 135__turbopack_context__.s([ 136 "subMonths", 137 0, 138 subMonths 139], 619578); 140// MERGED MODULE: [project]/node_modules/date-fns/subYears.js [app-client] (ecmascript) 141; 142// MERGED MODULE: [project]/node_modules/date-fns/addYears.js [app-client] (ecmascript) 143; 144var __TURBOPACK__imported__module__688594__1 = __TURBOPACK__imported__module__688594__; 145; 146function addYears(date, amount, options) { 147 return (0, __TURBOPACK__imported__module__688594__1["addMonths"])(date, amount * 12, options); 148} 149const __TURBOPACK__default__export__2 = addYears; 150; 151function subYears(date, amount, options) { 152 return addYears(date, -amount, options); 153} 154const __TURBOPACK__default__export__3 = subYears; 155__turbopack_context__.s([ 156 "subYears", 157 0, 158 subYears 159], 510637); 160}), 161711641, 152392, 162((__turbopack_context__) => { 163"use strict"; 164 165// MERGED MODULE: [project]/node_modules/lucide-react/dist/esm/icons/list-filter.js [app-client] (ecmascript) <export default as ListFilter> 166; 167// MERGED MODULE: [project]/node_modules/lucide-react/dist/esm/icons/list-filter.js [app-client] (ecmascript) 168; 169/** 170 * @license lucide-react v0.556.0 - ISC 171 * 172 * This source code is licensed under the ISC license. 173 * See the LICENSE file in the root directory of this source tree. 174 */ var __TURBOPACK__imported__module__475254__ = __turbopack_context__.i(475254); 175; 176const __iconNode = [ 177 [ 178 "path", 179 { 180 d: "M2 5h20", 181 key: "1fs1ex" 182 } 183 ], 184 [ 185 "path", 186 { 187 d: "M6 12h12", 188 key: "8npq4p" 189 } 190 ], 191 [ 192 "path", 193 { 194 d: "M9 19h6", 195 key: "456am0" 196 } 197 ] 198]; 199const ListFilter = (0, __TURBOPACK__imported__module__475254__["default"])("list-filter", __iconNode); 200; 201__turbopack_context__.s([ 202 "default", 203 0, 204 ListFilter 205], 152392); 206__turbopack_context__.s([ 207 "ListFilter", 208 0, 209 ListFilter 210], 711641); 211}), 212380188, ((__turbopack_context__) => { 213"use strict"; 214 215// MERGED MODULE: [project]/node_modules/@open-mercato/ui/dist/backend/FilterBar.js [a
215pp-client] (ecmascript) 216; 217var __TURBOPACK__imported__module__843476__ = __turbopack_context__.i(843476); 218var __TURBOPACK__imported__module__271645__ = __turbopack_context__.i(271645); 219var __TURBOPACK__imported__module__711641__ = __turbopack_context__.i(711641); 220var __TURBOPACK__imported__module__110035__ = __turbopack_context__.i(110035); 221var __TURBOPACK__imported__module__9762__ = __turbopack_context__.i(9762); 222// MERGED MODULE: [project]/node_modules/@open-mercato/ui/dist/backend/FilterOverlay.js [app-client] (ecmascript) 223; 224var __TURBOPACK__imported__module__843476__1 = __TURBOPACK__imported__module__843476__; 225var __TURBOPACK__imported__module__271645__1 = __TURBOPACK__imported__module__271645__; 226var __TURBOPACK__imported__module__401851__ = __turbopack_context__.i(401851); 227var __TURBOPACK__imported__module__952571__ = __turbopack_context__.i(952571); 228var __TURBOPACK__imported__module__110035__1 = __TURBOPACK__imported__module__110035__; 229var __TURBOPACK__imported__module__848476__ = __turbopack_context__.i(848476); 230// MERGED MODULE: [project]/node_modules/@open-mercato/ui/dist/primitives/date-range-picker.js [app-client] (ecmascript) 231; 232var __TURBOPACK__imported__module__843476__2 = __TURBOPACK__imported__module__843476__; 233var __TURBOPACK__imported__module__271645__2 = __TURBOPACK__imported__module__271645__; 234var __TURBOPACK__imported__module__747697__ = __turbopack_context__.i(747697); 235var __TURBOPACK__imported__module__406911__ = __turbopack_context__.i(406911); 236var __TURBOPACK__imported__module__928441__ = __turbopack_context__.i(928441); 237var __TURBOPACK__imported__module__388528__ = __turbopack_context__.i(388528); 238var __TURBOPACK__imported__module__422580__ = __turbopack_context__.i(422580); 239var __TURBOPACK__imported__module__110035__2 = __TURBOPACK__imported__module__110035__; 240// MERGED MODULE: [project]/node_modules/@open-mercato/ui/dist/primitives/date-picker-helpers.js [app-client] (ecmascript) 241; 242var __TURBOPACK__imported__module__145963__ = __turbopack_context__.i(145963); 243var __TURBOPACK__imported__module__585890__ = __turbopack_context__.i(585890); 244var __TURBOPACK__imported__module__608199__ = __turbopack_context__.i(608199); 245var __TURBOPACK__imported__module__668113__ = __turbopack_context__.i(668113); 246var __TURBOPACK__imported__module__751371__ = __turbopack_context__.i(751371); 247var __TURBOPACK__imported__module__619578__ = __turbopack_context__.i(619578); 248var __TURBOPACK__imported__module__510637__ = __turbopack_context__.i(510637); 249; 250; 251; 252; 253; 254; 255; 256function defaultDateRangePresets() { 257 return [ 258 { 259 id: "today", 260 labelKey: "ui.dateRangePicker.presets.today", 261 range: (ref = /* @__PURE__ */ new Date())=>({ 262 start: (0, __TURBOPACK__imported__module__585890__["startOfDay"])(ref), 263 end: (0, __TURBOPACK__imported__module__145963__["endOfDay"])(ref) 264 }) 265 }, 266 { 267 id: "last_7_days", 268 labelKey: "ui.dateRangePicker.presets.last7Days", 269 range: (ref = /* @__PURE__ */ new Date())=>({ 270 start: (0, __TURBOPACK__imported__module__585890__["startOfDay"])((0, __TURBOPACK__imported__module__751371__["subDays"])(ref, 6)), 271 end: (0, __TURBOPACK__imported__module__145963__["endOfDay"])(ref) 272 }) 273 }, 274 { 275 id: "last_30_days", 276 labelKey: "ui.dateRangePicker.presets.last30Days", 277 range: (ref = /* @__PURE__ */ new Date())=>({ 278 start: (0, __TURBOPACK__imported__module__585890__["startOfDay"])((0, __TURBOPACK__imported__module__751371__["subDays"])(ref, 29)), 279 end: (0, __TURBOPACK__imported__module__145963__["endOfDay"])(ref) 280 }) 281 }, 282 { 283 id: "last_3_months", 284 labelKey: "ui.dateRangePicker.presets.last3Months", 285 range: (ref = /* @__PURE__ */ new Date())=>({ 286 start: (0, __TURBOPACK__imported__module__585890__["startOfDay"])((0, __TURBOPACK__imported__module__619578__["subMonths"])(ref, 3)), 287 end: (0, __TURBOPACK__imported__module__145963__["endOfDay"])(ref) 288 }) 289 }, 290 { 291 id: "last_12_months", 292 labelKey: "ui.dateRangePicker.presets.last12Months", 293 range: (ref = /* @__PURE__ */ new Date())=>({ 294 start: (0, __TURBOPACK__imported__module__585890__["startOfDay"])((0, __TURBOPACK__imported__module__510637__["subYears"])(ref, 1)), 295 end: (0, __TURBOPACK__imported__module__145963__["endOfDay"])(ref) 296 }) 297 }, 298 { 299 id: "month_to_date", 300 labelKey: "ui.dateRangePicker.presets.monthToDate", 301 range: (ref = /* @__PURE__ */ new Date())=>({ 302 start: (0, __TURBOPACK__imported__module__608199__["startOfMonth"])(ref), 303 end: (0, __TURBOPACK__imported__module__145963__["endOfDay"])(ref) 304 }) 305 }, 306 { 307 id: "year_to_date", 308 labelKey: "ui.dateRangePicker.presets.yearToDate", 309 range: (ref = /* @__PURE__ */ new Date())=>({ 310 start: (0, __TURBOPACK__imported__module__668113__["startOfYear"])(ref), 311 end: (0, __TURBOPACK__imported__module__145963__["endOfDay"])(ref) 312 }) 313 }, 314 { 315 id: "all_time", 316 labelKey: "ui.dateRangePicker.presets.allTime", 317 range: (ref = /* @__PURE__ */ new Date())=>({ 318 // Symbolic "all time": from epoch to end of reference day. 319 start: /* @__PURE__ */ new Date(0), 320 end: (0, __TURBOPACK__imported__module__145963__["endOfDay"])(ref) 321 }) 322 } 323 ]; 324} 325; 326var __TURBOPACK__imported__module__900697__ = __turbopack_context__.i(900697); 327"use client"; 328; 329; 330; 331; 332; 333; 334; 335; 336; 337; 338function defaultFormatRange(range, locale) { 339 const fmt = (0, __TURBOPACK__imported__module__900697__["resolvePublicDateFormat"])(locale); 340 return `${(0, __TURBOPACK__imported__module__900697__["formatWithPublicDateFormat"])(range.start, fmt, locale) ?? ""} \u2013 ${(0, __TURBOPACK__imported__module__900697__["formatWithPublicDateFormat"])(range.end, fmt, locale) ?? ""}`; 341} 342function toRDPRange(range) { 343 if (!range) return void 0; 344 return { 345 from: range.start, 346 to: range.end 347 }; 348} 349function fromRDPRange(rdp) { 350 if (!rdp || !rdp.from) return null; 351 return { 352 start: rdp.from, 353 end: rdp.to ?? rdp.from 354 }; 355} 356function rangesEqual(a, b) { 357 if (!a && !b) return true; 358 if (!a || !b) return false;
359 return a.start.getTime() === b.start.getTime() && a.end.getTime() === b.end.getTime(); 360} 361function DateRangePicker({ value, onChange, presets, showPresets = true, placeholder, size = "default", disabled = false, readOnly = false, withFooter = true, align = "start", minDate, maxDate, numberOfMonths = 2, locale, formatRange, className, popoverClassName, id, name, required, "aria-label": ariaLabel, "aria-describedby": ariaDescribedBy }) { 362 const t = (0, __TURBOPACK__imported__module__928441__["useT"])(); 363 const [open, setOpen] = __TURBOPACK__imported__module__271645__2["useState"](false); 364 const [draft, setDraft] = __TURBOPACK__imported__module__271645__2["useState"](value ?? null); 365 const [activePresetId, setActivePresetId] = __TURBOPACK__imported__module__271645__2["useState"](null); 366 const isInteractive = !disabled && !readOnly; 367 const useDraft = withFooter; 368 __TURBOPACK__imported__module__271645__2["useEffect"](()=>{ 369 if (open) { 370 setDraft(value ?? null); 371 setActivePresetId(null); 372 } 373 }, [ 374 open, 375 value 376 ]); 377 const resolvedPresets = __TURBOPACK__imported__module__271645__2["useMemo"](()=>presets ?? defaultDateRangePresets(), [ 378 presets 379 ]); 380 const placeholderText = placeholder ?? t("ui.dateRangePicker.placeholder", "Pick a date range"); 381 const formatter = formatRange ?? defaultFormatRange; 382 const formattedValue = __TURBOPACK__imported__module__271645__2["useMemo"](()=>{ 383 if (!value) return null; 384 return formatter(value, locale); 385 }, [ 386 value, 387 formatter, 388 locale 389 ]); 390 const selectedDate = useDraft ? draft : value; 391 const rdpSelected = toRDPRange(selectedDate); 392 const handleRangeSelect = __TURBOPACK__imported__module__271645__2["useCallback"]((rdpRange)=>{ 393 if (!isInteractive) return; 394 const next = fromRDPRange(rdpRange); 395 setActivePresetId(null); 396 if (useDraft) { 397 setDraft(next); 398 } else { 399 onChange(next); 400 if (next?.start && next?.end) setOpen(false); 401 } 402 }, [ 403 isInteractive, 404 useDraft, 405 onChange 406 ]); 407 const handlePresetClick = __TURBOPACK__imported__module__271645__2["useCallback"]((preset)=>{ 408 if (!isInteractive) return; 409 const range = preset.range(); 410 setActivePresetId(preset.id); 411 if (useDraft) { 412 setDraft(range); 413 } else { 414 onChange(range); 415 setOpen(false); 416 } 417 }, [ 418 isInteractive, 419 useDraft, 420 onChange 421 ]); 422 const handleApply = __TURBOPACK__imported__module__271645__2["useCallback"](()=>{ 423 onChange(draft); 424 setOpen(false); 425 }, [ 426 draft, 427 onChange 428 ]); 429 const handleCancel = __TURBOPACK__imported__module__271645__2["useCallback"](()=>{ 430 setDraft(value ?? null); 431 setActivePresetId(null); 432 setOpen(false); 433 }, [ 434 value 435 ]); 436 const disabledMatcher = __TURBOPACK__imported__module__271645__2["useMemo"](()=>{ 437 if (!minDate && !maxDate) return void 0; 438 const matchers = []; 439 if (minDate) matchers.push({ 440 before: minDate 441 }); 442 if (maxDate) matchers.push({ 443 after: maxDate 444 }); 445 return matchers; 446 }, [ 447 minDate, 448 maxDate 449 ]); 450 const heightClass = size === "sm" ? "h-8 px-2.5 text-xs" : "h-9 px-3 text-sm"; 451 return /* @__PURE__ */ (0, __TURBOPACK__imported__module__843476__2["jsxs"])(__TURBOPACK__imported__module__388528__["Popover"], { 452 open, 453 onOpenChange: isInteractive ? setOpen : void 0, 454 children: [
455 /* @__PURE__ */ (0, __TURBOPACK__imported__module__843476__2["jsx"])(__TURBOPACK__imported__module__388528__["PopoverTrigger"], { 456 asChild: true, 457 children: /* @__PURE__ */ (0, __TURBOPACK__imported__module__843476__2["jsxs"])("button", { 458 type: "button", 459 id, 460 name, 461 "aria-label": ariaLabel, 462 "aria-describedby": ariaDescribedBy, 463 "aria-haspopup": "dialog", 464 "aria-required": required ? true : void 0, 465 "data-crud-focus-target": "", 466 "data-slot": "date-range-picker-trigger", 467 disabled, 468 className: (0, __TURBOPACK__imported__module__406911__["cn"])("w-full inline-flex items-center gap-2 rounded-md border border-input bg-background shadow-xs transition-colors text-left", "focus-visible:outline-none focus-visible:shadow-focus focus-visible:border-foreground", "hover:bg-muted/40", "disabled:bg-bg-disabled disabled:border-border-disabled disabled:shadow-none disabled:hover:bg-bg-disabled disabled:cursor-not-allowed", "aria-invalid:border-destructive", heightClass, readOnly && "cursor-default opacity-70", !formattedValue && "text-muted-foreground", className), 469 onClick: isInteractive ? void 0 : (event)=>event.preventDefault(), 470 children: [
471 /* @__PURE__ */ (0, __TURBOPACK__imported__module__843476__2["jsx"])(__TURBOPACK__imported__module__747697__["CalendarIcon"], { 472 className: "h-4 w-4 shrink-0 text-muted-foreground", 473 "aria-hidden": "true" 474 }), 475 /* @__PURE__ */ (0, __TURBOPACK__imported__module__843476__2["jsx"])("span", { 476 className: "flex-1 truncate", 477 children: formattedValue ?? placeholderText 478 }) 479 ] 480 }) 481 }), 482 /* @__PURE__ */ (0, __TURBOPACK__imported__module__843476__2["jsxs"])(__TURBOPACK__imported__module__388528__["PopoverContent"], { 483 align, 484 className: (0, __TURBOPACK__imported__module__406911__["cn"])("w-auto p-0 flex flex-col overflow-hidden", "max-h-[var(--radix-popover-content-available-height)]", popoverClassName), 485 children: [ 486 /* @__P
486URE__ */ (0, __TURBOPACK__imported__module__843476__2["jsxs"])("div", { 487 className: "flex min-h-0 flex-1 overflow-auto", 488 children: [ 489 showPresets ? /* @__PURE__ */ (0, __TURBOPACK__imported__module__843476__2["jsx"])("div", { 490 "data-slot": "date-range-presets", 491 className: "flex w-[200px] shrink-0 flex-col gap-0.5 overflow-y-auto border-r p-2", 492 children: resolvedPresets.map((preset)=>{ 493 const isActive = activePresetId === preset.id; 494 return /* @__PURE__ */ (0, __TURBOPACK__imported__module__843476__2["jsx"])("button", { 495 type: "button", 496 onClick: ()=>handlePresetClick(preset), 497 className: (0, __TURBOPACK__imported__module__406911__["cn"])("inline-flex h-8 items-center rounded-md px-3 text-left text-sm transition-colors shrink-0", "hover:bg-accent hover:text-accent-foreground", "focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2", isActive && "bg-muted font-medium text-foreground"), 498 children: t(preset.labelKey, preset.id.replace(/_/g, " ")) 499 }, preset.id); 500 }) 501 }) : null,
502 /* @__PURE__ */ (0, __TURBOPACK__imported__module__843476__2["jsx"])("div", { 503 className: "p-3", 504 children: /* @__PURE__ */ (0, __TURBOPACK__imported__module__843476__2["jsx"])(__TURBOPACK__imported__module__422580__["Calendar"], { 505 mode: "range", 506 selected: rdpSelected, 507 onSelect: handleRangeSelect, 508 locale, 509 disabled: disabledMatcher, 510 numberOfMonths, 511 autoFocus: true 512 }) 513 }) 514 ] 515 }), 516 withFooter ? /* @__PURE__ */ (0, __TURBOPACK__imported__module__843476__2["jsxs"])("div", { 517 className: "flex shrink-0 items-center justify-between gap-3 border-t bg-popover px-3 py-2", 518 children: [
519 /* @__PURE__ */ (0, __TURBOPACK__imported__module__843476__2["jsx"])("span", { 520 className: "truncate text-xs text-muted-foreground", 521 children: selectedDate ? `${t("ui.dateRangePicker.rangeLabel", "Range")}: ${formatter(selectedDate, locale)}` : t("ui.dateRangePicker.rangeEmpty", "No range selected") 522 }), 523 /* @__PURE__ */ (0, __TURBOPACK__imported__module__843476__2["jsxs"])("div", { 524 className: "flex shrink-0 items-center gap-2", 525 children: [ 526 /* @__PURE__ */ (0, __TURBOPACK__imported__module__843476__2["jsx"])(__TURBOPACK__imported__module__110035__2["Button"], { 527 type: "button", 528 variant: "outline", 529 size: "sm", 530 onClick: handleCancel, 531 children: t("ui.dateRangePicker.cancelButton", "Cancel") 532 }),
533 /* @__PURE__ */ (0, __TURBOPACK__imported__module__843476__2["jsx"])(__TURBOPACK__imported__module__110035__2["Button"], { 534 type: "button", 535 size: "sm", 536 onClick: handleApply, 537 children: t("ui.dateRangePicker.applyButton", "Apply") 538 }) 539 ] 540 }) 541 ] 542 }) : null 543 ] 544 }) 545 ] 546 }); 547} 548; 549var __TURBOPACK__imported__module__262524__ = __turbopack_context__.i(262524); 550var __TURBOPACK__imported__module__341881__ = __turbopack_context__.i(341881); 551var __TURBOPACK__imported__module__276583__ = __turbopack_context__.i(276583); 552var __TURBOPACK__imported__module__928441__1 = __TURBOPACK__imported__module__928441__; 553var __TURBOPACK__imported__module__220339__ = __turbopack_context__.i(220339); 554"use client"; 555; 556; 557; 558; 559; 560; 561; 562; 563; 564; 565; 566; 567const EMPTY_FILTER_VALUES = {}; 568function isPlainObject(value) { 569 return value != null && typeof value === "object" && !Array.isArray(value); 570} 571function normalizeKeys(source) { 572 if (!source) return []; 573 return Object.keys(source).filter((key)=>source[key] !== void 0); 574} 575function areFieldValuesEqual(a, b) { 576 if (a === b) return true; 577 if (Array.isArray(a) && Array.isArray(b)) { 578 if (a.length !== b.length) return false; 579 for(let i = 0; i < a.length; i += 1){ 580 if (!areFieldValuesEqual(a[i], b[i])) return false; 581 } 582 return true; 583 } 584 if (isPlainObject(a) && isPlainObject(b)) { 585 const keysA = normalizeKeys(a); 586 const keysB = normalizeKeys(b); 587 if (keysA.length !== keysB.length) return false; 588 for (const key of keysA){ 589 if (!keysB.includes(key)) return false; 590 if (!areFieldValuesEqual(a[key], b[key])) return false; 591 } 592 return true; 593 } 594 return false; 595} 596function areFilterValuesEqual(a, b) { 597 if (a === b) return true; 598 const keysA = normalizeKeys(a || EMPTY_FILTER_VALUES); 599 const keysB = normalizeKeys(b || EMPTY_FILTER_VALUES); 600 if (keysA.length !== keysB.length) return false; 601 for (const key of keysA){ 602 if (!keysB.includes(key)) return false; 603 if (!areFieldValuesEqual(a?.[key], b?.[key])) return false; 604 } 605 return true; 606} 607function FilterOverlay({ title, filters, initialValues, open, onOpenChange, onApply, onClear, extraContent }) { 608 const t = (0, __TURBOPACK__imported__module__928441__1["useT"])(); 609 const defaultTitle = title ?? t("ui.filters.title", "Filters"); 610 const [values, setValues] = __TURBOPACK__imported__module__271645__1["useState"](initialValues); 611 __TURBOPACK__imported__module__271645__1["useEffect"](()=>{ 612 setValues((prev)=>areFilterValuesEqual(prev, initialValues) ? prev : initialValues); 613 }, [ 614 initialValues 615 ]); 616 const filtersSignature = __TURBOPACK__imported__module__271645__1["useMemo"](()=>filters.map((f)=>`${f.id}:${f.type}:${Boolean(f.loadOptions)}:${(f.options || []).length}`).join("|"), [ 617 filters 618 ]); 619 const lastLoadedSignatureRef = __TURBOPACK__imported__module__271645__1["useRef"](null); 620 const stableFilters = __TURBOPACK__imported__module__271645__1["useMemo"](()=>filters, [ 621 filtersSignature 622 ]); 623 const [dynamicOptions, setDynamicOptions] = __TURBOPACK__imported__module__271645__1["useState"]({}); 624 __TURBOPACK__imported__module__271645__1["useEffect"](()=>{ 625 if (!open) return; 626 if (lastLoadedSignatureRef.current === filtersSignature) return; 627 lastLoadedSignatureRef.current = filtersSignature; 628 setDynamicOptions({}); 629 let cancelled = false; 630 const loadAll = async ()=>{ 631 const loaders = filters.filter((f)=>f.loadOptions != null).map(async (f)=>{ 632 try { 633 const opts = await f.loadOptions(); 634 if (!cancelled) setDynamicOptions((prev)=>({ 635 ...prev, 636 [f.id]: opts 637 })); 638 } catch {} 639 }); 640 await Promise.all(loaders); 641 }; 642 loadAll(); 643 return ()=>{ 644 cancelled = true; 645 }; 646 }, [ 647 filters, 648 filtersSignature, 649 open 650 ]); 651 __TURBOPACK__imported__module__271645__1["useEffect"](()=>{ 652 if (!open) { 653 lastLoadedSignatureRef.current = null; 654 } 655 }, [ 656 open 657 ]); 658 const setValue = (id, v)=>setValues((prev)=>({ 659 ...prev, 660 [id]: v 661 })); 662 const handleApply = ()=>{ 663 onApply(values); 664 onOpenChange(false); 665 }; 666 const handleClear = ()=>{ 667 setValues({}); 668 onClear?.(); 669 }; 670 const tagLoaders = __TURBOPACK__imported__module__271645__1["useMemo"](()=>{ 671 const map = /* @__PURE__ */ new Map(); 672 for (const f of stableFilters){ 673 if (f.type === "tags" && typeof f.loadOptions === "function") { 674 const fieldId = f.id; 675 const load = f.loadOptions; 676 map.set(fieldId, async (q)=>{ 677 const query = (q ?? "").trim(); 678 if (!query.length) return []; 679 try { 680 const opts = await load(query); 681 setDynamicOptions((prev)=>({ 682 ...prev, 683 [fieldId]: opts 684 })); 685 return opts.map((o)=>({ 686 value: o.value, 687 label: o.label, 688 description: o.description ?? null 689 })); 690 } catch { 691 return []; 692 } 693 }); 694 } 695 } 696 return map; 697 }, [ 698 stableFilters 699 ]); 700 const comboboxLoaders = __TURBOPACK__imported__module__271645__1["useMemo"](()=>{ 701 const map = /* @__PURE__ */ new Map(); 702 for (const f of stableFilters){ 703 if (f.type === "combobox" && typeof f.loadOptions === "function") { 704 map.set(f.id, async (query)=>{ 705 try { 706 const opts = await f.loadOptions?.(query); 707 setDynamicOptions((prev)=>({ 708 ...prev, 709 [f.id]: opts ?? [] 710 })); 711 return opts ?? []; 712 } catch { 713 return []; 714 } 715 }); 716 } 717 } 718 return map; 719 }, [ 720 stableFilters 721 ]); 722 return /* @__PURE__ */ (0, __TURBOPACK__imported__module__843476__1["jsx"])(__TURBOPACK__imported__module__843476__1["Fragment"], {
723 children: open && /* @__PURE__ */ (0, __TURBOPACK__imported__module__843476__1["jsxs"])("div", { 724 className: "fixed inset-0 z-modal", 725 children: [ 726 /* @__PURE__ */ (0, __TURBOPACK__imported__module__843476__1["jsx"])("div", { 727 className: "absolute inset-0 bg-black/20", 728 onClick: ()=>onOpenChange(false), 729 role: "presentation" 730 }), 731 /* @__PURE__ */ (0, __TURBOPACK__imported__module__843476__1["jsxs"])("div", { 732 className: "absolute left-0 top-0 h-full w-full sm:w-[380px] bg-background shadow-xl border-r flex flex-col", 733 children: [ 734 /* @__PURE__ */ (0, __TURBOPACK__imported__module__843476__1["jsxs"])("div", { 735 className: "flex items-center justify-between p-4 border-b", 736 children: [ 737 /* @__PURE__ */ (0, __TURBOPACK__imported__module__843476__1["jsx"])("h2", { 738 className: "text-base font-semibold", 739 children: defaultTitle 740 }),
741 /* @__PURE__ */ (0, __TURBOPACK__imported__module__843476__1["jsx"])(__TURBOPACK__imported__module__110035__1["Button"], { 742 variant: "muted", 743 size: "sm", 744 onClick: ()=>onOpenChange(false), 745 children: t("common.close") 746 }) 747 ] 748 }), 749 /* @__PURE__ */ (0, __TURBOPACK__imported__module__843476__1["jsxs"])("div", { 750 className: "px-4 py-2 border-b flex items-center justify-between gap-2", 751 children: [ 752 /* @__PURE__ */ (0, __TURBOPACK__imported__module__843476__1["jsx"])(__TURBOPACK__imported__module__110035__1["Button"], { 753 variant: "outline", 754 size: "sm", 755 onClick: handleClear, 756 children: t("ui.filters.actions.clear", "Clear") 757 }),
758 /* @__PURE__ */ (0, __TURBOPACK__imported__module__843476__1["jsxs"])(__TURBOPACK__imported__module__110035__1["Button"], { 759 size: "sm", 760 onClick: handleApply, 761 children: [ 762 /* @__PURE__ */ (0, __TURBOPACK__imported__module__843476__1["jsxs"])("svg", { 763 width: "14", 764 height: "14", 765 viewBox: "0 0 24 24", 766 fill: "none", 767 stroke: "currentColor", 768 strokeWidth: "2", 769 "aria-hidden": "true", 770 className: "opacity-80", 771 children: [ 772 /* @__P
772URE__ */ (0, __TURBOPACK__imported__module__843476__1["jsx"])("path", { 773 d: "M3 4h18" 774 }), 775 /* @__PURE__ */ (0, __TURBOPACK__imported__module__843476__1["jsx"])("path", { 776 d: "M6 8h12l-3 8H9L6 8z" 777 }) 778 ] 779 }), 780 t("ui.filters.actions.apply", "Apply") 781 ] 782 }) 783 ] 784 }), 785 /* @__PURE__ */ (0, __TURBOPACK__imported__module__843476__1["jsxs"])("div", { 786 className: "flex-1 overflow-auto p-4 space-y-4", 787 children: [ 788 extraContent ? /* @__PURE__ */ (0, __TURBOPACK__imported__module__843476__1["jsx"])("div", { 789 className: "space-y-2 rounded-md border bg-muted/30 p-3", 790 children: extraContent 791 }) : null, 792 filters.map((f)=>/* @__PURE__ */ (0, __TURBOPACK__imported__module__843476__1["jsxs"])("div", { 793 className: "space-y-2", 794 children: [
795 /* @__PURE__ */ (0, __TURBOPACK__imported__module__843476__1["jsxs"])("div", { 796 className: "flex items-center gap-1.5 text-sm font-medium", 797 children: [ 798 f.label, 799 f.tooltip ? /* @__PURE__ */ (0, __TURBOPACK__imported__module__843476__1["jsx"])(__TURBOPACK__imported__module__220339__["SimpleTooltip"], { 800 content: f.tooltip, 801 children: /* @__PURE__ */ (0, __TURBOPACK__imported__module__843476__1["jsx"])(__TURBOPACK__imported__module__952571__["Info"], { 802 className: "size-3.5 text-muted-foreground", 803 "aria-label": "More information" 804 }) 805 }) : null 806 ] 807 }), 808 f.type === "text" && /* @__PURE__ */ (0, __TURBOPACK__imported__module__843476__1["jsx"])("input", { 809 type: "text", 810 className: "w-full h-11 rounded border px-2 text-sm", 811 placeholder: f.placeholder, 812 value: values[f.id] ?? "", 813 onChange: (e)=>setValue(f.id, e.target.value || void 0) 814 }), 815 f.type === "dateRange" && (()=>{ 816 const fromStr = values[f.id]?.from; 817 const toStr = values[f.id]?.to; 818 const parseISODate = (input)=>{ 819 if (typeof input !== "string" || !input.length) return null; 820 const candidate = new Date(input); 821 return Number.isNaN(candidate.getTime()) ? null : candidate; 822 }; 823 const fromDate = parseISODate(fromStr); 824 const toDate = parseISODate(toStr); 825 const rangeValue = fromDate && toDate ? { 826 start: fromDate, 827 end: toDate 828 } : fromDate ? { 829 start: fromDate, 830 end: fromDate 831 } : toDate ? { 832 start: toDate, 833 end: toDate 834 } : null; 835 return /* @__PURE__ */ (0, __TURBOPACK__imported__module__843476__1["jsx"])(DateRangePicker, { 836 value: rangeValue, 837 onChange: (next)=>{ 838 if (!next) { 839 setValue(f.id, { 840 from: void 0, 841 to: void 0 842 }); 843 return; 844 } 845 setValue(f.id, { 846 from: (0, __TURBOPACK__imported__module__401851__["format"])(next.start, "yyyy-MM-dd"), 847 to: (0, __TURBOPACK__imported__module__401851__["format"])(next.end, "yyyy-MM-dd") 848 }); 849 }, 850 placeholder: t("ui.filters.dateRange.placeholder", "Pick a date range") 851 }); 852 })(), 853 f.type === "select" && /* @__P
853URE__ */ (0, __TURBOPACK__imported__module__843476__1["jsx"])("div", { 854 className: "space-y-1", 855 children: f.multiple ? /* @__PURE__ */ (0, __TURBOPACK__imported__module__843476__1["jsx"])("div", { 856 className: "flex flex-col gap-1", 857 children: (f.options || dynamicOptions[f.id] || []).map((opt)=>{ 858 const arr = Array.isArray(values[f.id]) ? values[f.id] : []; 859 const checked = arr.includes(opt.value); 860 return /* @__PURE__ */ (0, __TURBOPACK__imported__module__843476__1["jsxs"])("label", { 861 className: "inline-flex items-center gap-2 cursor-pointer", 862 children: [ 863 /* @__P
863URE__ */ (0, __TURBOPACK__imported__module__843476__1["jsx"])(__TURBOPACK__imported__module__848476__["Checkbox"], { 864 checked, 865 onCheckedChange: (next)=>{ 866 const set = new Set(arr); 867 if (next === true) set.add(opt.value); 868 else set.delete(opt.value); 869 setValue(f.id, Array.from(set)); 870 } 871 }), 872 /* @__PURE__ */ (0, __TURBOPACK__imported__module__843476__1["jsx"])("span", { 873 className: "text-sm", 874 children: opt.label 875 }) 876 ] 877 }, opt.value); 878 }) 879 }) : /* @__PURE__ */ (0, __TURBOPACK__imported__module__843476__1["jsxs"])(__TURBOPACK__imported__module__262524__["Select"], { 880 value: values[f.id] || void 0, 881 onValueChange: (next)=>setValue(f.id, next || void 0), 882 children: [
883 /* @__PURE__ */ (0, __TURBOPACK__imported__module__843476__1["jsx"])(__TURBOPACK__imported__module__262524__["SelectTrigger"], { 884 size: "lg", 885 children: /* @__PURE__ */ (0, __TURBOPACK__imported__module__843476__1["jsx"])(__TURBOPACK__imported__module__262524__["SelectValue"], { 886 placeholder: t("ui.forms.select.emptyOption", "\u2014") 887 }) 888 }), 889 /* @__PURE__ */ (0, __TURBOPACK__imported__module__843476__1["jsx"])(__TURBOPACK__imported__module__262524__["SelectContent"], { 890 children: (f.options || dynamicOptions[f.id] || []).filter((opt)=>opt.value !== "").map((opt)=>/* @__PURE__ */ (0, __TURBOPACK__imported__module__843476__1["jsx"])(__TURBOPACK__imported__module__262524__["SelectItem"], { 891 value: opt.value, 892 children: opt.label 893 }, opt.value)) 894 }) 895 ] 896 }) 897 }), 898 f.type === "combobox" && (()=>{ 899 const staticOptions = f.options || []; 900 const dynamic = dynamicOptions[f.id] || []; 901 const optionMap = /* @__PURE__ */ new Map(); 902 staticOptions.forEach((opt)=>optionMap.set(opt.value, opt)); 903 dynamic.forEach((opt)=>optionMap.set(opt.value, opt)); 904 const currentValue = typeof values[f.id] === "string" ? values[f.id] : ""; 905 const suggestions = Array.from(optionMap.values()).map((opt)=>({ 906 value: opt.value, 907 label: opt.label, 908 description: opt.description ?? null 909 })); 910 const loadSuggestions = comboboxLoaders.get(f.id); 911 return /* @__PURE__ */ (0, __TURBOPACK__imported__module__843476__1["jsxs"])("div", { 912 className: "flex items-start gap-2", 913 children: [
914 /* @__PURE__ */ (0, __TURBOPACK__imported__module__843476__1["jsx"])("div", { 915 className: "min-w-0 flex-1", 916 children: /* @__PURE__ */ (0, __TURBOPACK__imported__module__843476__1["jsx"])(__TURBOPACK__imported__module__341881__["ComboboxInput"], { 917 value: currentValue, 918 onChange: (next)=>setValue(f.id, next.trim().length ? next : void 0), 919 suggestions, 920 loadSuggestions, 921 resolveLabel: (value)=>f.formatValue?.(value) ?? optionMap.get(value)?.label ?? value, 922 resolveDescription: (value)=>optionMap.get(value)?.description ?? null, 923 placeholder: f.placeholder, 924 allowCustomValues: false 925 }) 926 }), 927 currentValue ? /* @__P
927URE__ */ (0, __TURBOPACK__imported__module__843476__1["jsx"])(__TURBOPACK__imported__module__110035__1["Button"], { 928 type: "button", 929 variant: "outline", 930 size: "sm", 931 className: "shrink-0", 932 onClick: ()=>setValue(f.id, void 0), 933 children: t("ui.filters.actions.clear", "Clear") 934 }) : null 935 ] 936 }); 937 })(), 938 f.type === "tags" && (()=>{ 939 const arr = Array.isArray(values[f.id]) ? values[f.id] : []; 940 const staticOptions = f.options || []; 941 const dynamic = dynamicOptions[f.id] || []; 942 const optionMap = /* @__PURE__ */ new Map(); 943 staticOptions.forEach((opt)=>optionMap.set(opt.value, opt)); 944 dynamic.forEach((opt)=>optionMap.set(opt.value, opt)); 945 const loadSuggestions = tagLoaders.get(f.id); 946 const resolveTagLabel = f.formatValue ? (val)=>f.formatValue(val) : (val)=>optionMap.get(val)?.label ?? val; 947 const resolveTagDescription = f.formatDescription ? (val)=>f.formatDescription(val) ?? null : (val)=>optionMap.get(val)?.description ?? null; 948 const suggestionList = Array.from(optionMap.values()).map((opt)=>({ 949 value: opt.value, 950 label: opt.label, 951 description: opt.description ?? null 952 })); 953 return /* @__PURE__ */ (0, __TURBOPACK__imported__module__843476__1["jsx"])(__TURBOPACK__imported__module__276583__["TagsInput"], { 954 value: arr, 955 suggestions: suggestionList, 956 loadSuggestions, 957 allowCustomValues: false, 958 resolveLabel: resolveTagLabel, 959 resolveDescription: resolveTagDescription, 960 placeholder: f.placeholder, 961 onChange: (next)=>setValue(f.id, next.length ? next : void 0) 962 }); 963 })(), 964 f.type === "checkbox" && /* @__PURE__ */ (0, __TURBOPACK__imported__module__843476__1["jsx"])("div", { 965 children: /* @__PURE__ */ (0, __TURBOPACK__imported__module__843476__1["jsxs"])(__TURBOPACK__imported__module__262524__["Select"], { 966 value: values[f.id] === true ? "true" : values[f.id] === false ? "false" : void 0, 967 onValueChange: (next)=>{ 968 if (!next) setValue(f.id, void 0); 969 else if (next === "true") setValue(f.id, true); 970 else if (next === "fal
970se") setValue(f.id, false); 971 }, 972 children: [ 973 /* @__PURE__ */ (0, __TURBOPACK__imported__module__843476__1["jsx"])(__TURBOPACK__imported__module__262524__["SelectTrigger"], { 974 size: "lg", 975 children: /* @__PURE__ */ (0, __TURBOPACK__imported__module__843476__1["jsx"])(__TURBOPACK__imported__module__262524__["SelectValue"], { 976 placeholder: t("ui.forms.select.emptyOption", "\u2014") 977 }) 978 }), 979 /* @__PURE__ */ (0, __TURBOPACK__imported__module__843476__1["jsxs"])(__TURBOPACK__imported__module__262524__["SelectContent"], { 980 children: [ 981 /* @__P
981URE__ */ (0, __TURBOPACK__imported__module__843476__1["jsx"])(__TURBOPACK__imported__module__262524__["SelectItem"], { 982 value: "true", 983 children: t("common.yes", "Yes") 984 }), 985 /* @__PURE__ */ (0, __TURBOPACK__imported__module__843476__1["jsx"])(__TURBOPACK__imported__module__262524__["SelectItem"], { 986 value: "false", 987 children: t("common.no", "No") 988 }) 989 ] 990 }) 991 ] 992 }) 993 }) 994 ] 995 }, f.id)) 996 ] 997 }),
998 /* @__PURE__ */ (0, __TURBOPACK__imported__module__843476__1["jsxs"])("div", { 999 className: "p-4 border-t flex items-center justify-between gap-2", 1000 children: [ 1001 /* @__PURE__ */ (0, __TURBOPACK__imported__module__843476__1["jsx"])(__TURBOPACK__imported__module__110035__1["Button"], { 1002 variant: "outline", 1003 onClick: handleClear, 1004 children: t("ui.filters.actions.clear", "Clear") 1005 }), 1006 /* @__PURE__ */ (0, __TURBOPACK__imported__module__843476__1["jsxs"])(__TURBOPACK__imported__module__110035__1["Button"], { 1007 onClick: handleApply, 1008 children: [ 1009 /* @__PURE__ */ (0, __TURBOPACK__imported__module__843476__1["jsxs"])("svg", { 1010 width: "14", 1011 height: "14",
1012 viewBox: "0 0 24 24", 1013 fill: "none", 1014 stroke: "currentColor", 1015 strokeWidth: "2", 1016 "aria-hidden": "true", 1017 className: "opacity-80", 1018 children: [ 1019 /* @__PURE__ */ (0, __TURBOPACK__imported__module__843476__1["jsx"])("path", { 1020 d: "M3 4h18" 1021 }), 1022 /* @__PURE__ */ (0, __TURBOPACK__imported__module__843476__1["jsx"])("path", { 1023 d: "M6 8h12l-3 8H9L6 8z" 1024 }) 1025 ] 1026 }), 1027 t("ui.filters.actions.apply", "Apply") 1028 ] 1029 }) 1030 ] 1031 }) 1032 ] 1033 }) 1034 ] 1035 }) 1036 }); 1037} 1038; 1039var __TURBOPACK__imported__module__928441__2 = __TURBOPACK__imported__module__928441__; 1040"use client"; 1041; 1042; 1043; 1044; 1045; 1046; 1047; 1048function FilterBar({ searchValue, onSearchChange, searchPlaceholder, searchAlign = "left", filters = [], values = {}, onApply, onClear, className, leadingItems, trailingItems, searchTrailing, layout = "stacked", filtersExtraContent }) { 1049 const t = (0, __TURBOPACK__imported__module__928441__2["useT"])(); 1050 const resolvedSearchPlaceholder = searchPlaceholder ?? t("ui.filterBar.searchPlaceholder", "Search"); 1051 const [open, setOpen] = __TURBOPACK__imported__module__271645__["useState"](false); 1052 const [searchDraft, setSearchDraft] = __TURBOPACK__imported__module__271645__["useState"](searchValue ?? ""); 1053 const lastAppliedSearchRef = __TURBOPACK__imported__module__271645__["useRef"](searchValue ?? ""); 1054 __TURBOPACK__imported__module__271645__["useEffect"](()=>{ 1055 const next = searchValue ?? ""; 1056 lastAppliedSearchRef.current = next; 1057 setSearchDraft((prev)=>prev === next ? prev : next); 1058 }, [ 1059 searchValue 1060 ]); 1061 __TURBOPACK__imported__module__271645__["useEffect"](()=>{ 1062 if (!onSearchChange) return; 1063 const handle = window.setTimeout(()=>{ 1064 if (lastAppliedSearchRef.current === searchDraft) return; 1065 lastAppliedSearchRef.current = searchDraft; 1066 onSearchChange(searchDraft); 1067 }, 1e3); 1068 return ()=>{ 1069 window.clearTimeout(handle); 1070 }; 1071 }, [ 1072 searchDraft, 1073 onSearchChange 1074 ]); 1075 const activeCount = __TURBOPACK__imported__module__271645__["useMemo"](()=>{ 1076 const isActive = (v)=>{ 1077 if (v == null) return false; 1078 if (typeof v === "string") return v.trim() !== ""; 1079 if (Array.isArray(v)) return v.length > 0; 1080 if (typeof v === "object") return Object.values(v).some((x)=>x != null && x !== ""); 1081 return Boolean(v); 1082 }; 1083 return Object.values(values).filter(isActive).length; 1084 }, [ 1085 values 1086 ]); 1087 const containerClass = `flex flex-col ${layout === "inline" ? "gap-1 sm:gap-2" : "gap-2"} w-full`;
1088 const searchBlock = onSearchChange ? /* @__PURE__ */ (0, __TURBOPACK__imported__module__843476__["jsxs"])("div", { 1089 className: `flex items-center gap-2 ${searchAlign === "right" ? "sm:ml-auto" : ""}`, 1090 children: [ 1091 /* @__PURE__ */ (0, __TURBOPACK__imported__module__843476__["jsx"])("div", { 1092 className: "w-full sm:w-72 lg:w-80", 1093 children: /* @__PURE__ */ (0, __TURBOPACK__imported__module__843476__["jsx"])(__TURBOPACK__imported__module__9762__["SearchInput"], { 1094 value: searchDraft, 1095 onChange: setSearchDraft, 1096 placeholder: resolvedSearchPlaceholder, 1097 suppressHydrationWarning: true 1098 }) 1099 }), 1100 searchTrailing ? /* @__PURE__ */ (0, __TURBOPACK__imported__module__843476__["jsx"])("div", { 1101 className: "flex items-center gap-1", 1102 children: searchTrailing 1103 }) : null 1104 ] 1105 }) : null; 1106 const controls = /* @__PURE__ */ (0, __TURBOPACK__imported__module__843476__["jsxs"])("div", { 1107 className: `flex flex-wrap items-center gap-2 ${searchAlign === "left" && searchBlock ? "sm:ml-auto" : ""}`, 1108 children: [ 1109 filters.length > 0 && /* @__PURE__ */ (0, __TURBOPACK__imported__module__843476__["jsxs"])(__TURBOPACK__imported__module__110035__["Button"], { 1110 variant: "outline", 1111 onClick: ()=>setOpen(true),
1112 children: [ 1113 /* @__PURE__ */ (0, __TURBOPACK__imported__module__843476__["jsx"])(__TURBOPACK__imported__module__711641__["ListFilter"], { 1114 "aria-hidden": "true", 1115 className: "size-4 opacity-80" 1116 }), 1117 activeCount ? t("ui.filterBar.filtersWithCount", "Filters {count}", { 1118 count: activeCount 1119 }) : t("ui.filterBar.filters", "Filters") 1120 ] 1121 }), 1122 leadingItems, 1123 trailingItems 1124 ] 1125 }); 1126 return /* @__PURE__ */ (0, __TURBOPACK__imported__module__843476__["jsxs"])("div", { 1127 className: `${containerClass} ${className ?? ""}`, 1128 children: [ 1129 /* @__PURE__ */ (0, __TURBOPACK__imported__module__843476__["jsxs"])("div", { 1130 className: "flex flex-wrap items-center gap-2 w-full", 1131 children: [ 1132 searchAlign === "left" ? searchBlock : null, 1133 controls, 1134 searchAlign === "right" ? searchBlock : null 1135 ] 1136 }), 1137 filters.length > 0 && activeCount > 0 && /* @__PURE__ */ (0, __TURBOPACK__imported__module__843476__["jsx"])("div", { 1138 className: "flex flex-wrap items-center gap-1", 1139 children: filters.map((f)=>{ 1140 const v = values[f.id]; 1141 if (v == null || v === "" || Array.isArray(v) && v.length === 0) return null; 1142 const toLabel = (val)=>{ 1143 if (typeof f.formatValue === "function" && (typeof val === "string" || typeof val === "number")) { 1144 const formatted = f.formatValue(String(val)); 1145 if (formatted) return formatted; 1146 } 1147 if (f.type === "select" && f.options) { 1148 const o = f.options.find((o2)=>o2.value === val); 1149 return o ? o.label : String(val); 1150 } 1151 if (typeof val === "object" && val.from == null && val.to == null) return null; 1152 if (typeof val === "object") { 1153 const from = val.from ?? ""; 1154 const to = val.to ? ` \u2192 ${val.to}` : ""; 1155 return `${from}${to}`.trim(); 1156 } 1157 if (val === true) return t("common.yes", "Yes"); 1158 if (val === false) return t("common.no", "No"); 1159 return String(val); 1160 }; 1161 const removeValue = (val)=>{ 1162 const next = { 1163 ...values || {} 1164 }; 1165 if (Array.isArray(v) && val !== void 0) next[f.id] = v.filter((x)=>x !== val); 1166 else delete next[f.id]; 1167 onApply?.(next); 1168 }; 1169 if (Array.isArray(v)) { 1170 return v.map((item)=>/* @__PURE__ */ (0, __TURBOPACK__imported__module__843476__["jsxs"])(__TURBOPACK__imported__module__110035__["Button"], { 1171 size: "sm", 1172 variant: "outline", 1173 className: "max-w-[calc(100vw-4rem)] truncate", 1174 onClick: ()=>removeValue(item), 1175 children: [ 1176 f.label, 1177 ": ", 1178 toLabel(item), 1179 " \xD7" 1180 ] 1181 }, `${f.id}:${item}`)); 1182 } 1183 const label = toLabel(v); 1184 if (!label) return null; 1185 return /* @__PURE__ */ (0, __TURBOPACK__imported__module__843476__["jsxs"])(__TURBOPACK__imported__module__110035__["Button"], { 1186 size: "sm", 1187 variant: "outline", 1188 className: "max-w-[calc(100vw-4rem)] truncate", 1189 onClick: ()=>removeValue(), 1190 children: [ 1191 f.label, 1192 ": ", 1193 label, 1194 " \xD7" 1195 ] 1196 }, f.id); 1197 }) 1198 }),
1199 /* @__PURE__ */ (0, __TURBOPACK__imported__module__843476__["jsx"])(FilterOverlay, { 1200 title: t("ui.filterOverlay.title", "Filters"), 1201 filters, 1202 initialValues: values, 1203 open, 1204 onOpenChange: setOpen, 1205 onApply: (v)=>onApply?.(v), 1206 onClear, 1207 extraContent: filtersExtraContent 1208 }) 1209 ] 1210 }); 1211} 1212; 1213__turbopack_context__.s([ 1214 "FilterBar", 1215 0, 1216 FilterBar 1217], 380188); 1218}), 1219]);
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.