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WwpB,EACXvpB,oBAAqBA,EACrBC,OAAQA,EACRC,WAAY6pB,GAEZx5B,EAAAA,cAAC0I,EAAwB,CACxBC,6BAA8BwwB,EAC9B5xB,kBAAmBA,GAEnBvH,EAAAA,cAAC65B,EAAAA,EAAwB,CAACC,eAAgBT,GAAaS,gBACtD95B,EAAAA,cAAC+0B,GAAoB,CACpBC,WAAYoE,EACZjhB,oBAAqBA,EACrB4T,iBAAkBA,EAClBlF,qBAAsBA,EACtB6I,oBAAqBA,EACrBC,WAAYA,EACZC,WAAYA,EACZlE,qBAAsBA,EACtBtoB,mBAAoBA,EACpBolB,gBAAiBA,EACjByM,cAAeA,SAOrBj1B,EAAAA,cAAC6G,EAAe,CAACxC,YAAY,qBAAqBK,uBAAwBrB,KAI9E,gBGl5BO,SAASo2B,EAAuBz2B,GACtC,GAAIA,QACH,OAAO,KAGR,IACC,OAAO4K,KAAKc,MAAM1L,EACnB,CAAE,MACD,OAAO,IACR,CACD","sources":["webpack://@logos/commerceweb-frontend/./Scripts/site/components/shared/scroll-threshold-bar/index.tsx","webpack://@logos/commerceweb-frontend/./Scripts/site/components/shared/books-by-author/index.tsx","webpack://@logos/commerceweb-frontend/./Scripts/site/hooks/use-publisher.tsx","webpack://@logos/commerceweb-frontend/./Scripts/site/components/content/section-content.tsx","webpack://@logos/commerceweb-frontend/./Scripts/site/clients/content-client.ts","webpack://@logos/commerceweb-frontend/./Scripts/site/components/search/category-content.tsx","webpack://@logos/commerceweb-frontend/./Scripts/site/components/search/user-search-filter-context.tsx","webpack://@logos/commerceweb-frontend/./Scripts/site/components/accordion/accordion.tsx","webpack://@logos/commerceweb-frontend/./Scripts/site/components/search/facet-label.ts","webpack://@logos/commerceweb-frontend/./Scripts/site/components/search/search-resources.ts","webpack://@logos/commerceweb-frontend/./Scripts/site/components/search/bounded-responses-cache.ts","webpack://@logos/commerceweb-frontend/./Scripts/site/components/search/algolia-search-context.tsx","webpack://@logos/commerceweb-frontend/./Scripts/site/components/search/util.ts","webpack://@logos/commerceweb-frontend/./Scripts/site/components/search/filters.tsx","webpack://@logos/commerceweb-frontend/./Scripts/site/components/search/refinements.tsx","webpack://@logos/commerceweb-frontend/./Scripts/site/components/search/hidden-facet-refinements.tsx","webpack://@logos/commerceweb-frontend/./Scripts/site/components/skeleton/index.tsx","webpack://@logos/commerceweb-frontend/./Scripts/site/components/shared/enhanced-for-logos-label/index.tsx","webpack://@logos/commerceweb-frontend/./Scripts/site/components/shared/enhanced-for-logos-with-tooltip/index.tsx","webpack://@logos/commerceweb-frontend/./Scripts/site/components/search/product-card/use-product-card.ts","webpack://@logos/commerceweb-frontend/./Scripts/site/components/search/product-card/product-image.tsx","webpack://@logos/commerceweb-frontend/./Scripts/site/components/search/product-card/discount-badge.tsx","webpack://@logos/commerceweb-frontend/./Scripts/site/components/search/product-card/product-title.tsx","webpack://@logos/commerceweb-frontend/./Scripts/site/components/search/product-card/product-authors.tsx","webpack://@logos/commerceweb-frontend/./Scripts/site/components/search/product-card/product-pricing.tsx","webpack://@logos/commerceweb-frontend/./Scripts/site/components/search/product-card/algolia-grid-card.tsx","webpack://@logos/commerceweb-frontend/./Scripts/site/components/search/product-card/product-overview.tsx","webpack://@logos/commerceweb-frontend/./Scripts/site/components/search/product-card/algolia-list-card.tsx","webpack://@logos/commerceweb-frontend/./Scripts/site/components/search/products.tsx","webpack://@logos/commerceweb-frontend/./Scripts/site/components/search/radio-accordion.tsx","webpack://@logos/commerceweb-frontend/./Scripts/site/components/search/sort-by-accordion.tsx","webpack://@logos/commerceweb-frontend/./Scripts/site/components/search/hits-per-page-accordion.tsx","webpack://@logos/commerceweb-frontend/./Scripts/site/components/search/use-view-mode.tsx","webpack://@logos/commerceweb-frontend/./Scripts/site/components/search/routing.ts","webpack://@logos/commerceweb-frontend/./Scripts/site/components/search/use-hydration-settled.ts","webpack://@logos/commerceweb-frontend/./Scripts/site/components/search/index.tsx","webpack://@logos/commerceweb-frontend/./Scripts/site/components/search/hooks/use-search-impressions.ts","webpack://@logos/commerceweb-frontend/./Scripts/site/components/search/hooks/use-search-analytics.ts","webpack://@logos/commerceweb-frontend/./Scripts/site/util/safe-json-parse.ts"],"sourcesContent":["import React, { useCallback, useEffect, useState } from 'react';\nimport type { ReactNode, RefObject } from 'react';\nimport { cn } from '../../../util/cn';\n\nexport interface ScrollThresholdBarProps {\n\ttargetRef: RefObject<HTMLElement | null>;\n\tchildren: ReactNode;\n\tthreshold?: number;\n\tposition?: 'top' | 'bottom';\n\trefreshKey?: unknown;\n\tclassName?: string;\n}\n\nexport function ScrollThresholdBar({\n\ttargetRef,\n\tchildren,\n\tthreshold = 1,\n\tposition = 'top',\n\trefreshKey,\n\tclassName,\n}: ScrollThresholdBarProps) {\n\tconst [isVisible, setIsVisible] = useState(false);\n\n\tuseEffect(() => {\n\t\tconst target = targetRef.current;\n\n\t\tif (!target) {\n\t\t\tsetIsVisible(false);\n\t\t\treturn;\n\t\t}\n\n\t\tconst normalizedThreshold = Number.isFinite(threshold) ? Math.min(1, Math.max(0, threshold)) : 1;\n\n\t\tlet scrollContainer = target.parentElement;\n\t\twhile (scrollContainer && scrollContainer !== document.body && scrollContainer !== document.documentElement) {\n\t\t\tconst { overflowY } = window.getComputedStyle(scrollContainer);\n\t\t\tif (['auto', 'scroll', 'overlay'].includes(overflowY)) {\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tscrollContainer = scrollContainer.parentElement;\n\t\t}\n\n\t\tconst scrollTarget =\n\t\t\tscrollContainer && scrollContainer !== document.body && scrollContainer !== document.documentElement\n\t\t\t\t? scrollContainer\n\t\t\t\t: null;\n\n\t\tlet animationFrame = 0;\n\n\t\tconst updateVisibility = () => {\n\t\t\tanimationFrame = 0;\n\t\t\tconst targetBounds = target.getBoundingClientRect();\n\t\t\tconst triggerPosition = targetBounds.top + targetBounds.height * normalizedThreshold;\n\t\t\tconst scrollportTop = scrollTarget ? scrollTarget.getBoundingClientRect().top + scrollTarget.clientTop : 0;\n\t\t\tsetIsVisible(triggerPosition <= scrollportTop);\n\t\t};\n\n\t\tconst scheduleUpdate = () => {\n\t\t\tif (!animationFrame) {\n\t\t\t\tanimationFrame = window.requestAnimationFrame(updateVisibility);\n\t\t\t}\n\t\t};\n\n\t\tupdateVisibility();\n\t\tconst eventTarget = scrollTarget ?? window;\n\t\teventTarget.addEventListener('scroll', scheduleUpdate, { passive: true });\n\t\twindow.addEventListener('resize', scheduleUpdate);\n\n\t\treturn () => {\n\t\t\teventTarget.removeEventListener('scroll', scheduleUpdate);\n\t\t\twindow.removeEventListener('resize', scheduleUpdate);\n\t\t\tif (animationFrame) {\n\t\t\t\twindow.cancelAnimationFrame(animationFrame);\n\t\t\t}\n\t\t};\n\t}, [refreshKey, targetRef, threshold]);\n\n\tconst stickyBarRef = useCallback(\n\t\t(stickyBar: HTMLDivElement | null) => {\n\t\t\tif (!stickyBar) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\t// React 16 drops boolean values for unknown attributes, so update inert through the DOM.\n\t\t\tif (isVisible) {\n\t\t\t\tstickyBar.removeAttribute('inert');\n\t\t\t} else {\n\t\t\t\tstickyBar.setAttribute('inert', '');\n\t\t\t}\n\t\t},\n\t\t[isVisible]\n\t);\n\n\tconst isAtTop = position === 'top';\n\n\treturn (\n\t\t<div\n\t\t\taria-hidden={!isVisible}\n\t\t\tclassName={cn(\n\t\t\t\t'fixed inset-x-0 transition-[transform,translate,visibility] duration-300 ease-in-out motion-reduce:transition-none',\n\t\t\t\tisAtTop ? 'top-0' : 'bottom-0',\n\t\t\t\tisVisible\n\t\t\t\t\t? 'visible translate-y-0'\n\t\t\t\t\t: isAtTop\n\t\t\t\t\t\t? 'invisible pointer-events-none -translate-y-full'\n\t\t\t\t\t\t: 'invisible pointer-events-none translate-y-full',\n\t\t\t\tclassName\n\t\t\t)}\n\t\t\tref={stickyBarRef}\n\t\t>\n\t\t\t{children}\n\t\t</div>\n\t);\n}\n\nexport default ScrollThresholdBar;\n","import React, { useState } from 'react';\nimport { IconButton, Typography } from '@faithlife/commerce-components';\nimport { ChevronDown, ChevronUp } from 'lucide-react';\nimport { useRefinementList } from 'react-instantsearch';\nimport { AuthorBio } from '../author-bio';\nimport { useAuthor } from '../../../hooks/use-author';\n\nconst useGetRefinedValues = (attribute: string) =>\n\tuseRefinementList({ attribute })\n\t\t.items.filter(item => item.isRefined)\n\t\t.map(item => item.value) ?? [];\n\ninterface BooksByAuthorProps {\n\tresources: {\n\t\tbooksBy: string;\n\t\tshowMore: string;\n\t\tshowLess: string;\n\t};\n}\n\nexport const BooksByAuthor = ({ resources }: BooksByAuthorProps) => {\n\tconst refinedAuthorIds = useGetRefinedValues('authorIds');\n\tconst authorId = refinedAuthorIds?.length === 1 ? refinedAuthorIds[0] : '';\n\tconst { data: author, isLoading } = useAuthor(authorId);\n\n\tconst [isCollapsed, setIsCollapsed] = useState(false);\n\n\tif (isLoading || !authorId || !author || !author.displayName || !author.longDescription) {\n\t\treturn <></>;\n\t}\n\n\treturn (\n\t\t<div className=\"bg-[#f2f2f2] border-t border-b border-[#b1b1b1] px-3 py-4 md:p-6\">\n\t\t\t<div className=\"flex justify-between\">\n\t\t\t\t<Typography variant=\"headingH6\">\n\t\t\t\t\t{resources.booksBy} {author?.displayName}\n\t\t\t\t</Typography>\n\t\t\t\t<IconButton aria-label=\"Toggle collapse\" scale=\"sm\" onClick={() => setIsCollapsed(!isCollapsed)}>\n\t\t\t\t\t{isCollapsed ? <ChevronDown /> : <ChevronUp />}\n\t\t\t\t</IconButton>\n\t\t\t</div>\n\t\t\t{!isCollapsed && (\n\t\t\t\t<AuthorBio\n\t\t\t\t\tclassName=\"mt-4 rounded-[3px] border border-[#d8d8d8] bg-white p-4 md:p-8\"\n\t\t\t\t\tresources={resources}\n\t\t\t\t\tdisplayName={author?.displayName}\n\t\t\t\t\timageUrl={author?.imageUrlLarge}\n\t\t\t\t\tbio={author?.longDescription}\n\t\t\t\t/>\n\t\t\t)}\n\t\t</div>\n\t);\n};\n","import { createBatchContext } from './use-batch';\n\nexport interface PublisherInfo {\n\tid: string;\n\tdisplayName: string;\n}\n\nexport const PublisherBatch = createBatchContext<string, PublisherInfo>(\n\tasync ids => {\n\t\tconst nonEmptyIds = ids.filter(id => id);\n\t\tif (nonEmptyIds.length === 0) {\n\t\t\treturn [];\n\t\t}\n\t\tconst response = await fetch(`/api/publisher?ids=${nonEmptyIds.join(',')}`);\n\n\t\tif (!response.ok) {\n\t\t\tthrow new Error(`HTTP error! status: ${response.status}`);\n\t\t}\n\n\t\treturn (await response.json()) as PublisherInfo[];\n\t},\n\t(id, data) => data.find(d => d.id === id)\n);\n\nexport function usePublisher(id: string) {\n\treturn PublisherBatch.useData(id);\n}\n","import React, { useEffect, useRef, useState } from 'react';\n\nimport { RenderBuilderContent } from '../builder';\nimport { getSections } from '../../clients/content-client';\nimport { useLocation } from '../../location';\nimport { useIsPreviewingThisBuilderModel, SectionContentViewModel, SectionKind } from '../../builder';\nimport { c_defaultUserInfo } from '../per-user-data/per-user-data-context';\nimport { notifyWarning } from '../notifications';\n\ninterface ContentChangeEvent {\n\thasContent: boolean;\n\tcontentKey: string;\n}\n\nconst builderIoModelNamesBySectionKindMap: Record<SectionKind, string> = {\n\tsearchResultsAbove: 'search-results-above',\n\tsearchResultsBelow: 'search-results-below',\n\tuniversalHeader: 'universal-header',\n\tuniversalFooter: 'universal-footer',\n\tsubscriptionChurnPrevention: 'subscription-churn-prevention',\n\tconfigurationWizardSubscriptionsBanner: 'configuration-wizard-subscriptions-banner',\n\tconfigurationWizardSubscriptionsContent: 'configuration-wizard-subscriptions-content',\n\tconfigurationWizardLibrariesBanner: 'configuration-wizard-libraries-banner',\n\torderSummary: 'order-summary',\n\torderSummaryFooter: 'order-summary-footer',\n\tproductPage: 'product-page',\n\tadzone: 'adzone',\n\tnotifications: 'notifications',\n\tpdpBanner: 'pdp-banner',\n};\n\nfunction getContentKey(sectionContents: SectionContentViewModel[]): string {\n\treturn sectionContents\n\t\t.filter(sc => !!sc)\n\t\t.map(sc => `${sc.sectionKind}:${sc.contentSourceKind}:${sc.contentId}`)\n\t\t.join('|');\n}\n\nconst SectionContent = ({\n\tsectionKind,\n\tinitialSectionContents,\n\tonContentChange,\n}: {\n\tsectionKind: SectionKind;\n\tinitialSectionContents?: SectionContentViewModel[];\n\tonContentChange?: (event: ContentChangeEvent) => void;\n}) => {\n\tconst [sectionContents, setSectionContents] = useState<SectionContentViewModel[]>(initialSectionContents ?? []);\n\tconst builderIoModel = builderIoModelNamesBySectionKindMap[sectionKind];\n\tconst isBuilderIoPreviewingThisModel = useIsPreviewingThisBuilderModel(builderIoModel);\n\tconst location = useLocation();\n\tconst lastRequestedLocationHref = useRef(initialSectionContents === undefined ? undefined : location.href);\n\n\tuseEffect(() => {\n\t\tconst fetchSections = async () => {\n\t\t\tconst sections = await getSections({\n\t\t\t\tkind: sectionKind,\n\t\t\t\turl: location.href,\n\t\t\t});\n\n\t\t\tsetSectionContents(sections);\n\n\t\t\tconst filteredSections = sections.filter(sc => !!sc);\n\t\t\tonContentChange?.({\n\t\t\t\thasContent: filteredSections.length > 0 || isBuilderIoPreviewingThisModel,\n\t\t\t\tcontentKey: getContentKey(filteredSections),\n\t\t\t});\n\t\t};\n\n\t\tif (!isBuilderIoPreviewingThisModel && location.href !== lastRequestedLocationHref.current) {\n\t\t\tlastRequestedLocationHref.current = location.href;\n\t\t\tfetchSections();\n\t\t}\n\t}, [sectionKind, location.href, onContentChange, isBuilderIoPreviewingThisModel, initialSectionContents]);\n\n\tuseEffect(() => {\n\t\tif (isBuilderIoPreviewingThisModel) {\n\t\t\tnotifyWarning(`You are previewing the \"${builderIoModel}\" Builder.io model.`);\n\t\t}\n\t}, [isBuilderIoPreviewingThisModel, builderIoModel]);\n\n\tif (isBuilderIoPreviewingThisModel) {\n\t\treturn (\n\t\t\t<RenderBuilderContent\n\t\t\t\tmodel={builderIoModel}\n\t\t\t\tstaticData={{\n\t\t\t\t\tstaticProductData: [],\n\t\t\t\t\tuserInfo: c_defaultUserInfo,\n\t\t\t\t}}\n\t\t\t/>\n\t\t);\n\t}\n\n\tconst filteredContents = sectionContents.filter(sc => !!sc);\n\tconst hasContent = filteredContents.length > 0;\n\n\tif (!hasContent) {\n\t\treturn null;\n\t}\n\n\treturn (\n\t\t<>\n\t\t\t{filteredContents.map(sc =>\n\t\t\t\tsc.contentSourceKind === 'builderIo' ? <RenderBuilderContent key={sc.contentId} {...sc.builderIo} /> : null\n\t\t\t)}\n\t\t</>\n\t);\n};\n\nexport default SectionContent;\n","import { fetch } from '../util/fetch';\nimport { SectionContentViewModel, SectionKind } from '../builder';\n\ninterface Params {\n\tkind: SectionKind;\n\turl: string;\n}\n\nexport async function getSections({ kind, url }: Params): Promise<SectionContentViewModel[]> {\n\ttry {\n\t\tconst response = await fetch.get({\n\t\t\turl: '/api/sections',\n\t\t\tparams: { kind, url },\n\t\t});\n\n\t\tconst results = await response.json();\n\t\treturn results as unknown as SectionContentViewModel[];\n\t} catch (error) {\n\t\treturn [];\n\t}\n}\n","import React, { useState, useCallback } from 'react';\n\nimport ReadMoreReadLess from '../read-more-read-less';\nimport { SectionContent } from '../content';\nimport ErrorBoundary from '../error-boundary';\nimport type { SectionContentViewModel, SectionKind } from '../../builder';\n\ninterface Props {\n\tsectionKind: SectionKind;\n\tinitialSectionContents?: SectionContentViewModel[];\n}\n\ninterface ContentChangeEvent {\n\thasContent: boolean;\n\tcontentKey: string;\n}\n\nconst CategoryContent = ({ sectionKind, initialSectionContents }: Props) => {\n\t// Merged into one state object so both values update in a single render,\n\t// avoiding separate re-renders that can cause SectionContent to remount.\n\tconst [{ hasContent, contentKey }, setContentState] = useState(() => {\n\t\tconst filteredSections = initialSectionContents?.filter(sc => !!sc) ?? [];\n\t\treturn {\n\t\t\thasContent: filteredSections.length > 0,\n\t\t\tcontentKey: filteredSections.map(sc => `${sc.sectionKind}:${sc.contentSourceKind}:${sc.contentId}`).join('|'),\n\t\t};\n\t});\n\n\tconst handleContentChange = useCallback((event: ContentChangeEvent) => {\n\t\tsetContentState(prev =>\n\t\t\tprev.hasContent === event.hasContent && prev.contentKey === event.contentKey\n\t\t\t\t? prev\n\t\t\t\t: { hasContent: event.hasContent, contentKey: event.contentKey }\n\t\t);\n\t}, []);\n\n\t// SectionContent always stays in the same tree position (inside ReadMoreReadLess).\n\t// Changing the parent conditionally would cause SectionContent to unmount/remount\n\t// and re-fire the sections AJAX on every hasContent or contentKey state change.\n\treturn (\n\t\t<ErrorBoundary>\n\t\t\t<div className={hasContent ? 'w-full' : 'hidden'}>\n\t\t\t\t<ReadMoreReadLess contentKey={contentKey}>\n\t\t\t\t\t<SectionContent\n\t\t\t\t\t\tsectionKind={sectionKind}\n\t\t\t\t\t\tinitialSectionContents={initialSectionContents}\n\t\t\t\t\t\tonContentChange={handleContentChange}\n\t\t\t\t\t/>\n\t\t\t\t</ReadMoreReadLess>\n\t\t\t</div>\n\t\t</ErrorBoundary>\n\t);\n};\n\nexport default CategoryContent;\n","import React, { createContext, useContext, useEffect, useMemo, useState } from 'react';\n\nimport { useLocation } from '../../location';\n\nexport interface UserSearchFilterOption {\n\tdisplayName: string;\n\tisDefault?: boolean;\n\talgoliaValue: string;\n\ttoken: string;\n}\n\nexport interface UserSearchFilter {\n\ttitle: string;\n\toptions: UserSearchFilterOption[];\n\ttoken: string;\n}\n\nexport interface UserSearchFilters {\n\tfilters: UserSearchFilter[];\n}\n\ninterface UserSearchFilterContextValue {\n\tselectedFilterOptions: Record<string, string>;\n\tsetSelectedFilterOption: (filterToken: string, optionToken: string) => void;\n\tuserSearchFilters: UserSearchFilter[];\n}\n\nconst UserSearchFilterContext = createContext<UserSearchFilterContextValue | null>(null);\n\nfunction getDefaultSelectedFilterOptions(userSearchFilters: UserSearchFilter[]) {\n\treturn userSearchFilters.reduce<Record<string, string>>((selectedOptions, filter) => {\n\t\tconst options = Array.isArray(filter?.options) ? filter.options : [];\n\t\tconst selectedOption = options.find(option => option?.isDefault) ?? options[0];\n\n\t\tif (selectedOption?.token) {\n\t\t\tselectedOptions[filter.token] = selectedOption.token;\n\t\t}\n\n\t\treturn selectedOptions;\n\t}, {});\n}\n\nfunction areSelectedFilterOptionsEqual(first: Record<string, string>, second: Record<string, string>): boolean {\n\tconst firstKeys = Object.keys(first);\n\tconst secondKeys = Object.keys(second);\n\n\treturn firstKeys.length === secondKeys.length && firstKeys.every(key => first[key] === second[key]);\n}\n\nfunction readUserFilterSelectionsFromUrl(\n\tuserSearchFilters: UserSearchFilter[],\n\tsearchParams: URLSearchParams\n): Record<string, string> {\n\tconst defaults = getDefaultSelectedFilterOptions(userSearchFilters);\n\n\treturn userSearchFilters.reduce<Record<string, string>>((selectedOptions, filter) => {\n\t\tconst options = Array.isArray(filter?.options) ? filter.options : [];\n\t\tconst urlValue = searchParams.get(filter.token);\n\t\tconst matchingOption = urlValue ? options.find(option => option?.token === urlValue) : undefined;\n\n\t\tconst resolved = matchingOption?.token ?? defaults[filter.token];\n\t\tif (resolved) {\n\t\t\tselectedOptions[filter.token] = resolved;\n\t\t}\n\n\t\treturn selectedOptions;\n\t}, {});\n}\n\nfunction writeUserFilterSelectionsToUrl(\n\tselectedFilterOptions: Record<string, string>,\n\tuserSearchFilters: UserSearchFilter[],\n\tsearch: string,\n\tpathname: string,\n\treplaceUrl: (url: string) => void\n) {\n\tlet url: URL;\n\ttry {\n\t\turl = new URL(`https://placeholder${pathname}${search}`);\n\t} catch {\n\t\t// Malformed pathname/search — skip URL update rather than crash.\n\t\treturn;\n\t}\n\n\tfor (const filter of userSearchFilters) {\n\t\tconst selectedToken = selectedFilterOptions[filter.token];\n\n\t\tif (selectedToken) {\n\t\t\turl.searchParams.set(filter.token, selectedToken);\n\t\t} else {\n\t\t\turl.searchParams.delete(filter.token);\n\t\t}\n\t}\n\n\ttry {\n\t\treplaceUrl(`${url.pathname}${url.search}`);\n\t} catch {\n\t\t// History replacement can fail in some browsers / iframes.\n\t}\n}\n\nexport function useUserSearchFilterContext() {\n\tconst context = useContext(UserSearchFilterContext);\n\tif (!context) {\n\t\tthrow new Error('useUserSearchFilterContext must be used within UserSearchFilterProvider');\n\t}\n\treturn context;\n}\n\nexport function UserSearchFilterProvider({\n\tuserSearchFilters,\n\tinitialSelectedFilterOptions,\n\tsetSelectedFilterOptionsOverride,\n\tchildren,\n}: {\n\tuserSearchFilters: UserSearchFilter[];\n\tinitialSelectedFilterOptions?: Record<string, string>;\n\tsetSelectedFilterOptionsOverride?: () => Record<string, string>;\n\tchildren: React.ReactNode;\n}) {\n\tconst { search, pathname, replaceUrl } = useLocation();\n\tconst searchParams = useMemo(() => new URLSearchParams(search), [search]);\n\n\tconst [selectedFilterOptions, setSelectedFilterOptions] = useState<Record<string, string>>(() => {\n\t\tconst urlSelections = readUserFilterSelectionsFromUrl(userSearchFilters, searchParams);\n\n\t\treturn userSearchFilters.reduce<Record<string, string>>((selectedOptions, filter) => {\n\t\t\tconst initialSelection = initialSelectedFilterOptions?.[filter.token];\n\t\t\tconst isInitialSelectionValid = filter.options.some(option => option.token === initialSelection);\n\t\t\tconst selectedOption = isInitialSelectionValid ? initialSelection : urlSelections[filter.token];\n\n\t\t\tif (selectedOption) {\n\t\t\t\tselectedOptions[filter.token] = selectedOption;\n\t\t\t}\n\n\t\t\treturn selectedOptions;\n\t\t}, {});\n\t});\n\n\tuseEffect(() => {\n\t\tsetSelectedFilterOptions(prev => {\n\t\t\tlet next: Record<string, string>;\n\n\t\t\tif (setSelectedFilterOptionsOverride) {\n\t\t\t\tnext = setSelectedFilterOptionsOverride();\n\t\t\t} else {\n\t\t\t\tconst urlSelections = readUserFilterSelectionsFromUrl(userSearchFilters, searchParams);\n\n\t\t\t\t// Only reset if userSearchFilters changed (not a URL-driven update).\n\t\t\t\t// Preserve current selection if the option is still valid for the new filter set.\n\t\t\t\tnext = userSearchFilters.reduce<Record<string, string>>((selectedOptions, filter) => {\n\t\t\t\t\tconst currentSelection = prev[filter.token];\n\t\t\t\t\tconst isStillValid = filter.options.some(option => option.token === currentSelection);\n\t\t\t\t\tconst selectedOption = isStillValid ? currentSelection : urlSelections[filter.token];\n\n\t\t\t\t\tif (selectedOption) {\n\t\t\t\t\t\tselectedOptions[filter.token] = selectedOption;\n\t\t\t\t\t}\n\n\t\t\t\t\treturn selectedOptions;\n\t\t\t\t}, {});\n\t\t\t}\n\n\t\t\treturn areSelectedFilterOptionsEqual(prev, next) ? prev : next;\n\t\t});\n\t}, [setSelectedFilterOptionsOverride, userSearchFilters, searchParams]);\n\n\tuseEffect(() => {\n\t\twriteUserFilterSelectionsToUrl(selectedFilterOptions, userSearchFilters, search, pathname, replaceUrl);\n\t}, [selectedFilterOptions, userSearchFilters, search, pathname, replaceUrl]);\n\n\tconst handleSetSelectedFilterOption = (filterToken: string, optionToken: string) => {\n\t\tsetSelectedFilterOptions(prev => ({\n\t\t\t...prev,\n\t\t\t[filterToken]: optionToken,\n\t\t}));\n\t};\n\n\tconst contextValue = useMemo(\n\t\t() => ({\n\t\t\tselectedFilterOptions,\n\t\t\tsetSelectedFilterOption: handleSetSelectedFilterOption,\n\t\t\tuserSearchFilters,\n\t\t}),\n\t\t[selectedFilterOptions, userSearchFilters]\n\t);\n\n\treturn <UserSearchFilterContext.Provider value={contextValue}>{children}</UserSearchFilterContext.Provider>;\n}\n","import * as React from 'react';\nimport * as AccordionPrimitive from '@radix-ui/react-accordion';\nimport { ChevronDown } from 'lucide-react';\n\nimport { cn } from '../../util/cn';\n\nconst Accordion = AccordionPrimitive.Root;\n\nconst AccordionItem = React.forwardRef<\n\tReact.ComponentRef<typeof AccordionPrimitive.Item>,\n\tReact.ComponentPropsWithoutRef<typeof AccordionPrimitive.Item>\n>(({ className, ...props }, ref) => <AccordionPrimitive.Item className={cn('', className)} ref={ref} {...props} />);\n\nAccordionItem.displayName = AccordionPrimitive.Item.displayName;\n\nconst AccordionTrigger = React.forwardRef<\n\tReact.ComponentRef<typeof AccordionPrimitive.Trigger>,\n\tReact.ComponentPropsWithoutRef<typeof AccordionPrimitive.Trigger>\n>(({ className, children, ...props }, ref) => (\n\t<AccordionPrimitive.Header className=\"flex\">\n\t\t<AccordionPrimitive.Trigger\n\t\t\tclassName={cn(\n\t\t\t\t'flex flex-1 items-center justify-between py-[9.5px] text-lg font-bold outline-hidden transition-all hover:text-secondary focus-visible:text-secondary [&[data-state=open]>svg]:rotate-180',\n\t\t\t\tclassName\n\t\t\t)}\n\t\t\tref={ref}\n\t\t\t{...props}\n\t\t>\n\t\t\t{children}\n\t\t\t{/* TODO: For the sake of moving fast we are leaving this in, but in the future we need to figure out how enable custom icons */}\n\t\t\t<ChevronDown className=\"h-6 w-6 shrink-0 transition-transform duration-200\" />\n\t\t</AccordionPrimitive.Trigger>\n\t</AccordionPrimitive.Header>\n));\n\nAccordionTrigger.displayName = AccordionPrimitive.Trigger.displayName;\n\nconst AccordionContent = React.forwardRef<\n\tReact.ComponentRef<typeof AccordionPrimitive.Content>,\n\tReact.ComponentPropsWithoutRef<typeof AccordionPrimitive.Content>\n>(({ className, children, ...props }, ref) => (\n\t<AccordionPrimitive.Content\n\t\tclassName={cn(\n\t\t\t'data-[state=closed]:animate-accordion-up data-[state=open]:animate-accordion-down mb-4 overflow-hidden transition-all',\n\t\t\tclassName\n\t\t)}\n\t\tref={ref}\n\t\t{...props}\n\t>\n\t\t{children}\n\t</AccordionPrimitive.Content>\n));\n\nAccordionContent.displayName = AccordionPrimitive.Content.displayName;\n\nexport { Accordion, AccordionItem, AccordionTrigger, AccordionContent };\n","import { useLocalization } from '../../localization/use-localization';\n\nconst c_nonWordCharacters = /[^\\p{L}\\p{Mn}\\p{Nd}\\p{Pc}]/gu;\nconst c_leadingDecimalDigit = /^\\p{Nd}/u;\nconst c_facetResourceKeyAliases: Readonly<Record<string, Readonly<Record<string, string>>>> = {\n\t// The existing resource key for 3 John is John4.\n\tbibleAndApocrypha: {\n\t\t'3 John': 'John4',\n\t},\n\tcontainment: {\n\t\tsingle: 'SingleTitle',\n\t\tstandalone: 'SoldIndividually',\n\t},\n\tformat: {\n\t\treader: 'ReaderEdition',\n\t},\n\treligiousGroup: {\n\t\t'Pentecostal/Charismatic': 'PentecostalCharismatic1',\n\t},\n\ttopic: {\n\t\t'Angelology/Demonology': 'AngelologyDemonology1',\n\t},\n};\n\nexport function getFacetDisplayLabel(rawLabel: string, resources: Record<string, string>, attribute?: string): string {\n\tconst leaf = getFacetLeaf(rawLabel);\n\tconst resourceName = leaf.replace(c_nonWordCharacters, '');\n\tconst baseAttribute = attribute?.replace(/\\.lvl\\d+$/, '');\n\tconst resourceKeyAlias = baseAttribute ? c_facetResourceKeyAliases[baseAttribute]?.[leaf] : undefined;\n\tconst resourceKeys = resourceKeyAlias ? [resourceKeyAlias] : getResourceKeys(resourceName);\n\n\tfor (const resourceKey of resourceKeys) {\n\t\tconst translation = getResourceValue(resources, resourceKey);\n\t\tif (typeof translation === 'string') {\n\t\t\treturn translation.trim();\n\t\t}\n\t}\n\n\treturn leaf;\n}\n\nfunction getResourceKeys(resourceName: string): string[] {\n\tconst leadingDigitKey = c_leadingDecimalDigit.test(resourceName) ? `_${resourceName}` : resourceName;\n\tconst keys = [leadingDigitKey];\n\tconst leadingDigits = resourceName.match(/^(\\p{Nd}+)(.+)$/u);\n\n\tif (leadingDigits) {\n\t\tkeys.push(`${leadingDigits[2]}${leadingDigits[1]}`);\n\t}\n\n\treturn keys;\n}\n\nfunction getResourceValue(resources: Record<string, string>, resourceKey: string): string | undefined {\n\tif (Object.prototype.hasOwnProperty.call(resources, resourceKey)) {\n\t\treturn resources[resourceKey];\n\t}\n\n\tconst caseInsensitiveKey = Object.keys(resources).find(key => key.toLowerCase() === resourceKey.toLowerCase());\n\treturn caseInsensitiveKey ? resources[caseInsensitiveKey] : undefined;\n}\n\nexport function useFacetConstraints() {\n\treturn useLocalization('CommerceWeb.Resources.Search.FacetConstraints');\n}\n\nfunction getFacetLeaf(rawLabel: string): string {\n\tconst separatorIndex = rawLabel.lastIndexOf('>');\n\tif (separatorIndex === -1) {\n\t\treturn rawLabel;\n\t}\n\n\treturn rawLabel.slice(separatorIndex + 1).trim();\n}\n","import { createContext, useContext } from 'react';\n\nexport const SearchResourcesContext = createContext<Record<string, string>>({});\n\nexport function useSearchResources(): Record<string, string> {\n\treturn useContext(SearchResourcesContext);\n}\n","import type { Cache, CacheEvents } from '@algolia/client-common';\n\n// Algolia's default `createMemoryCache` never evicts, so a long filtering session retains every\n// distinct search indefinitely. That is costly here because ownership-filtered searches carry a\n// `filters` string listing every owned productId, and it is stored twice: once as the cache key and\n// again inside the response, which echoes the request params back. Measured against a 20k-product\n// library, each cached search retained ~2.1MB (~1.0MB key, ~1.1MB value) against a ~0.15MB baseline,\n// and 14 cached searches held 26.6MB.\n//\n// Because entry size scales with the size of the user's library, the budget is in characters rather\n// than entries. This cache otherwise keeps `createMemoryCache`'s exact semantics -- same\n// `JSON.stringify` key, same serialized value, same miss handling -- and only adds eviction, so an\n// evicted entry behaves precisely like the cache miss that would have happened before it was ever\n// cached.\n\nconst defaultMaxCharacters = 8 * 1024 * 1024;\n\nfunction serializeKey(key: Record<string, any> | string): string {\n\treturn JSON.stringify(key);\n}\n\nexport function createBoundedResponsesCache(maxCharacters: number = defaultMaxCharacters): Cache {\n\tconst cache = new Map<string, string>();\n\tlet characters = 0;\n\n\tfunction evict() {\n\t\t// Always keep the most recently written entry, so a single oversized response still caches.\n\t\twhile (characters > maxCharacters && cache.size > 1) {\n\t\t\tconst oldestKey = cache.keys().next().value;\n\t\t\tif (oldestKey === undefined) {\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tcharacters -= oldestKey.length + (cache.get(oldestKey)?.length ?? 0);\n\t\t\tcache.delete(oldestKey);\n\t\t}\n\t}\n\n\treturn {\n\t\tget<TValue>(\n\t\t\tkey: Record<string, any> | string,\n\t\t\tdefaultValue: () => Promise<TValue>,\n\t\t\tevents: CacheEvents<TValue> = { miss: () => Promise.resolve() }\n\t\t): Promise<TValue> {\n\t\t\tconst serializedKey = serializeKey(key);\n\t\t\tconst cached = cache.get(serializedKey);\n\n\t\t\tif (cached !== undefined) {\n\t\t\t\tcache.delete(serializedKey);\n\t\t\t\tcache.set(serializedKey, cached);\n\n\t\t\t\treturn Promise.resolve(JSON.parse(cached) as TValue);\n\t\t\t}\n\n\t\t\tconst promise = defaultValue();\n\n\t\t\treturn promise.then(value => events.miss(value)).then(() => promise);\n\t\t},\n\n\t\tset<TValue>(key: Record<string, any> | string, value: TValue): Promise<TValue> {\n\t\t\tconst serializedKey = serializeKey(key);\n\t\t\tconst serializedValue = JSON.stringify(value);\n\n\t\t\tconst existing = cache.get(serializedKey);\n\t\t\tif (existing !== undefined) {\n\t\t\t\tcharacters -= serializedKey.length + existing.length;\n\t\t\t\tcache.delete(serializedKey);\n\t\t\t}\n\n\t\t\tcache.set(serializedKey, serializedValue);\n\t\t\tcharacters += serializedKey.length + serializedValue.length;\n\t\t\tevict();\n\n\t\t\treturn Promise.resolve(value);\n\t\t},\n\n\t\tdelete(key: Record<string, any> | string): Promise<void> {\n\t\t\tconst serializedKey = serializeKey(key);\n\t\t\tconst existing = cache.get(serializedKey);\n\t\t\tif (existing !== undefined) {\n\t\t\t\tcharacters -= serializedKey.length + existing.length;\n\t\t\t\tcache.delete(serializedKey);\n\t\t\t}\n\n\t\t\treturn Promise.resolve();\n\t\t},\n\n\t\tclear(): Promise<void> {\n\t\t\tcache.clear();\n\t\t\tcharacters = 0;\n\n\t\t\treturn Promise.resolve();\n\t\t},\n\t};\n}\n","import React, { createContext, useContext, useEffect, useMemo, useState } from 'react';\nimport { algoliasearch } from 'algoliasearch';\nimport insightsClient from 'search-insights';\nimport { createAlgoliaInsightsInitOptions } from '../../util/algolia';\nimport { createBoundedResponsesCache } from './bounded-responses-cache';\n\n// ---------------------------------------------------------------------------\n// Algolia search context — provides the configured Algolia client\n// ---------------------------------------------------------------------------\n\ninterface AlgoliaSearchContextValue {\n\tclient: ReturnType<typeof algoliasearch>;\n\tindexName: string;\n\tstorefrontShortname: string;\n\tuserId: string | null;\n\tisSignedIn: boolean;\n\tanonymousUserToken: string | null;\n}\n\nconst AlgoliaSearchContext = createContext<AlgoliaSearchContextValue | null>(null);\n\ninterface AlgoliaSearchContextProviderProps {\n\tappId: string;\n\tappKey: string;\n\tcookieDuration?: number | null;\n\tindexName: string;\n\tstorefrontShortname: string;\n\tuserId?: string | null;\n\tisSignedIn?: boolean;\n\tchildren: React.ReactNode;\n}\n\nexport function AlgoliaSearchContextProvider({\n\tappId,\n\tappKey,\n\tcookieDuration,\n\tindexName,\n\tstorefrontShortname,\n\tuserId = null,\n\tisSignedIn = false,\n\tchildren,\n}: AlgoliaSearchContextProviderProps) {\n\tconst client = useMemo(\n\t\t() => algoliasearch(appId, appKey, { responsesCache: createBoundedResponsesCache() }),\n\t\t[appId, appKey]\n\t);\n\tconst [anonymousUserToken, setAnonymousUserToken] = useState<string | null>(null);\n\n\tuseEffect(() => {\n\t\tinsightsClient('init', createAlgoliaInsightsInitOptions(appId, appKey, cookieDuration));\n\t\tinsightsClient('getUserToken', {}, (error, userToken) => {\n\t\t\tif (!error && userToken !== undefined) {\n\t\t\t\tsetAnonymousUserToken(String(userToken));\n\t\t\t}\n\t\t});\n\t\tif (userId) {\n\t\t\tinsightsClient('setAuthenticatedUserToken', userId);\n\t\t}\n\t}, [appId, appKey, cookieDuration, userId]);\n\n\tconst value = useMemo(\n\t\t() => ({ client, indexName, storefrontShortname, userId, isSignedIn, anonymousUserToken }),\n\t\t[client, indexName, storefrontShortname, userId, isSignedIn, anonymousUserToken]\n\t);\n\n\treturn <AlgoliaSearchContext.Provider value={value}>{children}</AlgoliaSearchContext.Provider>;\n}\n\nexport function useAlgoliaSearch(): AlgoliaSearchContextValue {\n\tconst context = useContext(AlgoliaSearchContext);\n\n\tif (!context) {\n\t\tthrow new Error('useAlgoliaSearch must be used within an AlgoliaSearchContextProvider');\n\t}\n\n\treturn context;\n}\n","import type { ProductPriceAmount } from '../per-user-data/per-user-data-context';\n\ninterface SavingsPrices {\n\tsalePrice?: Pick<ProductPriceAmount, 'amount'> | null;\n\tanchorPrice?: Pick<ProductPriceAmount, 'amount'> | null;\n}\n\n/**\n * Transliterates Unicode characters to their closest ASCII equivalents.\n * Approximates the behavior of the .NET Unidecode library used by SlugHelper on the server.\n */\nfunction unidecode(text: string): string {\n\t// Handle characters that don't decompose via NFD but have ASCII equivalents.\n\t// Order matters: apply multi-char replacements before NFD strips combining marks.\n\tconst result = text\n\t\t.replace(/ß/g, 'ss')\n\t\t.replace(/[æÆ]/g, 'ae')\n\t\t.replace(/[œŒ]/g, 'oe')\n\t\t.replace(/[øØ]/g, 'o')\n\t\t.replace(/[ðÐ]/g, 'd')\n\t\t.replace(/[þÞ]/g, 'th')\n\t\t.replace(/[łŁ]/g, 'l');\n\n\t// Strip combining diacritical marks from remaining Latin characters via NFD normalization.\n\treturn result.normalize('NFD').replace(/\\p{Mn}/gu, '');\n}\n\n/**\n * Converts a string to a URL-friendly slug.\n * Matches the server-side SlugHelper.Slugify method used to generate product URL slugs.\n */\nexport function slugify(value: string | undefined): string {\n\tif (!value) {\n\t\treturn '';\n\t}\n\n\t// Remove trademark/registered symbols\n\tlet input = value.replace(/®/g, '').replace(/™/g, '');\n\n\t// Transliterate Unicode → ASCII, then lowercase (matches .Unidecode().ToLowerInvariant())\n\tinput = unidecode(input).toLowerCase();\n\n\t// Remove trailing parenthetical and bracket blocks, e.g. \"Title (Subtitle) [Edition]\"\n\t// Matches s_parenBlocks = new Regex(\"(\\\\(.*\\\\))?(\\\\s*\\\\[.*\\\\])*$\")\n\tinput = input.replace(/(\\(.*\\))?(\\s*\\[.*\\])*$/g, '');\n\n\t// Strip HTML tags — matches s_htmlTags = new Regex(\"</?[^>]+>\")\n\tinput = input.replace(/<\\/?[^>]+>/g, '');\n\n\t// Expand ampersand\n\tinput = input.replace(/ & /g, ' and ');\n\n\t// Convert separating punctuation to spaces — matches s_punctuationForSpace = new Regex(\"[/\\\\-:_]\")\n\tinput = input.replace(/[/\\-:_]/g, ' ');\n\n\t// Remove all remaining non-alphanumeric, non-space characters — matches s_punctuationAndNonAlpha = new Regex(\"[^a-z0-9 ]\")\n\tinput = input.replace(/[^a-z0-9 ]/g, '');\n\n\t// Collapse whitespace runs to hyphens — matches s_excessWhitespace = new Regex(\"\\\\s+\")\n\treturn input.trim().replace(/\\s+/g, '-');\n}\n\nexport function getSavingsPercent(prices: SavingsPrices | null | undefined): number {\n\tconst anchor = prices?.anchorPrice?.amount;\n\tconst sale = prices?.salePrice?.amount;\n\tif (!anchor || !sale) {\n\t\treturn 0;\n\t}\n\tif (anchor <= 0) {\n\t\treturn 0;\n\t}\n\treturn ((anchor - sale) / anchor) * 100;\n}\n\n/**\n * Splits an author/publisher facet value of the form \"id:displayName\" into its parts.\n * Uses the first colon as the separator so display names that themselves contain colons\n * are preserved. When no colon is present, the whole value is treated as both id and name.\n */\nexport function parseFacetValue(value: string): { id: string; displayName: string } {\n\tconst separatorIndex = value.indexOf(':');\n\tif (separatorIndex === -1) {\n\t\treturn { id: value, displayName: value };\n\t}\n\treturn {\n\t\tid: value.substring(0, separatorIndex),\n\t\tdisplayName: value.substring(separatorIndex + 1),\n\t};\n}\n\nexport function safeUrl(input: string, base?: string): URL | null {\n\ttry {\n\t\treturn new URL(input, base);\n\t} catch {\n\t\treturn null;\n\t}\n}\n","import React, { useEffect, useRef, useState } from 'react';\nimport insightsClient from 'search-insights';\nimport { LinkButton, Typography } from '@faithlife/commerce-components';\nimport {\n\tRefinementListItem,\n\tRefinementListRenderState,\n} from 'instantsearch.js/es/connectors/refinement-list/connectRefinementList';\nimport { useRefinementList } from 'react-instantsearch';\nimport { cn } from '../../util/cn';\n\nimport { Accordion, AccordionContent, AccordionItem, AccordionTrigger } from '../accordion';\nimport { getFacetDisplayLabel, useFacetConstraints } from './facet-label';\nimport { useSearchResources } from './search-resources';\nimport { UserSearchFilter, UserSearchFilterOption, useUserSearchFilterContext } from './user-search-filter-context';\nimport { useAlgoliaSearch } from './algolia-search-context';\nimport { parseFacetValue } from './util';\n\nfunction Check({ className, checked }: { className?: string; checked: boolean }) {\n\treturn (\n\t\t<svg\n\t\t\tclassName={cn('inline', className)}\n\t\t\tfill=\"none\"\n\t\t\theight=\"14\"\n\t\t\tviewBox=\"0 0 13 14\"\n\t\t\twidth=\"13\"\n\t\t\txmlns=\"http://www.w3.org/2000/svg\"\n\t\t>\n\t\t\t<rect\n\t\t\t\tfill={checked ? '#1E6AFE' : 'white'}\n\t\t\t\theight=\"13\"\n\t\t\t\trx=\"1\"\n\t\t\t\tstroke={checked ? undefined : '#C7C7C7'}\n\t\t\t\twidth=\"13\"\n\t\t\t\ty=\"0.5\"\n\t\t\t/>\n\t\t\t<path d=\"M3.28223 7.73706L5.2634 9.71824L9.71857 5.26308\" stroke=\"white\" strokeLinecap=\"round\" />\n\t\t</svg>\n\t);\n}\n\nconst c_statusLabelKeys: Record<string, string> = {\n\t'status > live': 'liveStatusText',\n\t'status > prepub': 'prepubStatusText',\n\t'status > prepub > gatheringinterest': 'gatheringInterestStatusText',\n\t'status > prepub > undercontract': 'underContractStatusText',\n\t'status > prepub > gatheringinterest > almostfunded': 'almostFundedStatusText',\n\t'status > prepub > undercontract > shippingsoon': 'shippingSoonStatusText',\n};\n\nfunction ShowMoreToggle({\n\tshowMore,\n\tattribute,\n\tsetShowMore,\n}: {\n\tshowMore: string | undefined;\n\tattribute: string;\n\tsetShowMore: (showMore: string | undefined) => void;\n}) {\n\tconst resources = useSearchResources();\n\tconst isShowingMore = showMore === attribute;\n\n\treturn (\n\t\t<LinkButton as=\"button\" onClick={() => setShowMore(isShowingMore ? undefined : attribute)} scale=\"sm\">\n\t\t\t{isShowingMore ? resources['showLess'] : resources['showMore']}\n\t\t</LinkButton>\n\t);\n}\n\nfunction countDepth(value: string) {\n\tlet index = value.indexOf('>');\n\tlet depth = 0;\n\n\twhile (index !== -1) {\n\t\tindex = value.indexOf('>', index + 1);\n\t\tdepth += 1;\n\t}\n\n\treturn depth;\n}\n\nexport interface RefinementItem {\n\trefinement: RefinementListRenderState;\n\titem: RefinementListItem;\n}\n\nfunction hasChildren(items: RefinementItem[], { item: parent }: RefinementItem) {\n\treturn items.some(({ item }) => parent !== item && item.value.startsWith(parent.value));\n}\n\nfunction getChildren(items: RefinementItem[], parent: RefinementItem) {\n\tconst depth = countDepth(parent.item.value);\n\n\treturn items.filter(({ item }) => countDepth(item.value) === depth + 1 && item.value.startsWith(parent.item.value));\n}\n\nexport function getAccordions(category: string, items: RefinementItem[]) {\n\tconst root = {\n\t\tkey: category,\n\t\tlabel: category,\n\t\tlabelKind: 'search' as const,\n\t\titems: items.filter(({ item }) => countDepth(item.value) === 0),\n\t};\n\n\tconst subCategories = items\n\t\t.filter(({ item }) => item.isRefined)\n\t\t.filter(parent => hasChildren(items, parent))\n\t\t.map(c => ({\n\t\t\tkey: c.item.value,\n\t\t\tlabel: c.item.label.replace(/^((.*) > )*/, ''),\n\t\t\tlabelKind: 'facetConstraints' as const,\n\t\t\titems: getChildren(items, c),\n\t\t}));\n\n\treturn [root, ...subCategories];\n}\n\nfunction useRefinementLists(category: string, levels?: number) {\n\t// not neccessary, but let's avoid shooting ourselves in the foot, shall we?\n\tconst levelsRef = useRef(levels);\n\tconst items: RefinementItem[] = [];\n\n\tif (levelsRef.current !== undefined) {\n\t\tfor (let level = 0; level <= levelsRef.current; level += 1) {\n\t\t\tconst attribute = `${category}.lvl${level}`;\n\t\t\t// eslint-disable-next-line react-hooks/rules-of-hooks\n\t\t\tconst refinement = useRefinementList({ attribute, limit: 1000 }, { skipSuspense: level < levelsRef.current - 1 });\n\n\t\t\titems.push(...refinement.items.map(item => ({ item, refinement })));\n\t\t}\n\t} else {\n\t\t// eslint-disable-next-line react-hooks/rules-of-hooks\n\t\tconst refinement = useRefinementList({ attribute: category, limit: 1000 });\n\n\t\titems.push(...refinement.items.map(item => ({ item, refinement })));\n\t}\n\n\treturn items;\n}\n\nfunction Category({\n\tcategory,\n\tsetExpandedFacets,\n\tsetShowMore,\n\tshowMore,\n\tmaxLevel,\n}: {\n\tcategory: string;\n\tsetExpandedFacets: (setState: (expandedFacets: string[]) => string[]) => void;\n\tsetShowMore: (showMore: string | undefined) => void;\n\tshowMore: string | undefined;\n\tmaxLevel?: number;\n}) {\n\tconst resources = useSearchResources();\n\tconst facetConstraints = useFacetConstraints();\n\tconst { indexName } = useAlgoliaSearch();\n\tconst items = useRefinementLists(category, maxLevel);\n\n\tif (!items?.length) {\n\t\treturn null;\n\t}\n\n\tconst accordions = getAccordions(category, items);\n\n\treturn accordions.map(accordion => (\n\t\t<AccordionItem key={accordion.key} value={accordion.key}>\n\t\t\t<AccordionTrigger className=\"border-t border-primary-100 p-4 lg:border-t-0 [&>svg]:text-primary\">\n\t\t\t\t<Typography className=\"text-primary-400\" variant=\"bodyRegular\" tag=\"div\">\n\t\t\t\t\t{accordion.labelKind === 'search'\n\t\t\t\t\t\t? (resources[accordion.label] ?? accordion.label)\n\t\t\t\t\t\t: getFacetDisplayLabel(accordion.label, facetConstraints, category)}\n\t\t\t\t</Typography>\n\t\t\t</AccordionTrigger>\n\t\t\t<AccordionContent className=\"m-0 bg-grey-200 p-4\">\n\t\t\t\t<div className=\"flex flex-col gap-y-4\">\n\t\t\t\t\t{(showMore === accordion.key ? accordion.items : accordion.items.slice(0, 7)).map(({ item, refinement }) => (\n\t\t\t\t\t\t<div key={item.value}>\n\t\t\t\t\t\t\t<button\n\t\t\t\t\t\t\t\tclassName={cn(\n\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\t'text-black-200 hover:text-secondary-200': !item.isRefined,\n\t\t\t\t\t\t\t\t\t\t'text-primary': item.isRefined,\n\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t'bodySm w-full text-left capitalize'\n\t\t\t\t\t\t\t\t)}\n\t\t\t\t\t\t\t\tonClick={() => {\n\t\t\t\t\t\t\t\t\trefinement.refine(item.value);\n\n\t\t\t\t\t\t\t\t\tinsightsClient('clickedFilters', {\n\t\t\t\t\t\t\t\t\t\tindex: indexName,\n\t\t\t\t\t\t\t\t\t\teventName: 'Clicked filter',\n\t\t\t\t\t\t\t\t\t\tfilters: [`${category}:${item.value}`],\n\t\t\t\t\t\t\t\t\t});\n\n\t\t\t\t\t\t\t\t\tif (!item.isRefined) {\n\t\t\t\t\t\t\t\t\t\tsetExpandedFacets(old => [...old, item.value]);\n\t\t\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\t\t\titems\n\t\t\t\t\t\t\t\t\t\t\t.filter(\n\t\t\t\t\t\t\t\t\t\t\t\t({ item: child }) =>\n\t\t\t\t\t\t\t\t\t\t\t\t\tchild.isRefined && child.value !== item.value && child.value.startsWith(item.value)\n\t\t\t\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t\t\t\t\t.forEach(({ item: child, refinement: childRefinement }) => {\n\t\t\t\t\t\t\t\t\t\t\t\tchildRefinement.refine(child.value);\n\t\t\t\t\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\t\t\t\tsetExpandedFacets(old => old.filter(v => !v.startsWith(item.value)));\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t}}\n\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t<Check checked={item.isRefined} className=\"mr-3\" />\n\t\t\t\t\t\t\t\t<span className=\"normal-case\">\n\t\t\t\t\t\t\t\t\t{`${getFacetDisplayLabel(item.label, facetConstraints, category)} `}\n\t\t\t\t\t\t\t\t</span>\n\t\t\t\t\t\t\t\t<span className=\"text-black-100\">\n\t\t\t\t\t\t\t\t\t{'('}\n\t\t\t\t\t\t\t\t\t{item.count}\n\t\t\t\t\t\t\t\t\t{')'}\n\t\t\t\t\t\t\t\t</span>\n\t\t\t\t\t\t\t</button>\n\t\t\t\t\t\t</div>\n\t\t\t\t\t))}\n\t\t\t\t\t{accordion.items.length > 7 && (\n\t\t\t\t\t\t<ShowMoreToggle attribute={accordion.key} setShowMore={setShowMore} showMore={showMore} />\n\t\t\t\t\t)}\n\t\t\t\t</div>\n\t\t\t</AccordionContent>\n\t\t</AccordionItem>\n\t));\n}\n\nfunction AuthorFacetItem({\n\tid,\n\tdisplayName,\n\tcount,\n\tisRefined,\n\tonRefine,\n}: {\n\tid: string;\n\tdisplayName: string;\n\tcount: number;\n\tisRefined: boolean;\n\tonRefine: (id: string) => void;\n}) {\n\treturn (\n\t\t<div>\n\t\t\t<button\n\t\t\t\tclassName={cn(\n\t\t\t\t\t{\n\t\t\t\t\t\t'text-black-200 hover:text-secondary-200': !isRefined,\n\t\t\t\t\t\t'text-primary': isRefined,\n\t\t\t\t\t},\n\t\t\t\t\t'bodySm w-full text-left capitalize'\n\t\t\t\t)}\n\t\t\t\tonClick={() => onRefine(id)}\n\t\t\t>\n\t\t\t\t{displayName}{' '}\n\t\t\t\t<span className=\"text-black-100\">\n\t\t\t\t\t{'('}\n\t\t\t\t\t{count}\n\t\t\t\t\t{')'}\n\t\t\t\t</span>\n\t\t\t</button>\n\t\t</div>\n\t);\n}\n\nfunction PublisherFacetItem({\n\tid,\n\tdisplayName,\n\tcount,\n\tisRefined,\n\tonRefine,\n}: {\n\tid: string;\n\tdisplayName: string;\n\tcount: number;\n\tisRefined: boolean;\n\tonRefine: (id: string) => void;\n}) {\n\treturn (\n\t\t<div>\n\t\t\t<button\n\t\t\t\tclassName={cn(\n\t\t\t\t\t{\n\t\t\t\t\t\t'text-black-200 hover:text-secondary-200': !isRefined,\n\t\t\t\t\t\t'text-primary': isRefined,\n\t\t\t\t\t},\n\t\t\t\t\t'bodySm w-full text-left capitalize'\n\t\t\t\t)}\n\t\t\t\tonClick={() => onRefine(id)}\n\t\t\t>\n\t\t\t\t{displayName}{' '}\n\t\t\t\t<span className=\"text-black-100\">\n\t\t\t\t\t{'('}\n\t\t\t\t\t{count}\n\t\t\t\t\t{')'}\n\t\t\t\t</span>\n\t\t\t</button>\n\t\t</div>\n\t);\n}\n\nfunction AuthorsOrPublishers({\n\tattribute,\n\tnameAttribute,\n\tsetShowMore,\n\tshowMore,\n}: {\n\tattribute: 'authorIds' | 'publisherIds';\n\tnameAttribute: 'authorFacets' | 'publisherFacets';\n\tshowMore: string | undefined;\n\tsetShowMore: (showMore: string | undefined) => void;\n}) {\n\tconst resources = useSearchResources();\n\tconst { indexName } = useAlgoliaSearch();\n\n\tconst { isShowingMore, items, canToggleShowMore, toggleShowMore } = useRefinementList({\n\t\tattribute: nameAttribute,\n\t\tlimit: 7,\n\t\tshowMore: true,\n\t});\n\tconst { items: idItems, refine } = useRefinementList({\n\t\tattribute,\n\t});\n\n\tuseEffect(() => {\n\t\tif ((showMore === attribute) !== isShowingMore) {\n\t\t\ttoggleShowMore();\n\t\t}\n\t}, [attribute, isShowingMore, showMore, toggleShowMore]);\n\n\tconst FacetItem = attribute === 'authorIds' ? AuthorFacetItem : PublisherFacetItem;\n\n\tconst facetItems = items.map(item => {\n\t\tconst { id, displayName } = parseFacetValue(item.value);\n\t\treturn {\n\t\t\tid,\n\t\t\tdisplayName,\n\t\t\tcount: item.count,\n\t\t\tisRefined: idItems.some(idItem => idItem.value === id && idItem.isRefined),\n\t\t};\n\t});\n\n\tfacetItems.sort((a, b) => {\n\t\tif (a.isRefined && !b.isRefined) {\n\t\t\treturn -1;\n\t\t}\n\n\t\tif (!a.isRefined && b.isRefined) {\n\t\t\treturn 1;\n\t\t}\n\n\t\treturn b.count - a.count;\n\t});\n\n\treturn (\n\t\t<AccordionItem value={attribute}>\n\t\t\t<AccordionTrigger className=\"border-t border-primary-100 p-4 lg:border-t-0 [&>svg]:text-primary\">\n\t\t\t\t<Typography className=\"text-primary-400\" variant=\"bodyRegular\" tag=\"div\">\n\t\t\t\t\t{resources[attribute] ?? attribute}\n\t\t\t\t</Typography>\n\t\t\t</AccordionTrigger>\n\t\t\t<AccordionContent className=\"m-0 bg-grey-200 p-4\">\n\t\t\t\t<div className=\"flex flex-col gap-y-4\">\n\t\t\t\t\t{facetItems.map(i => {\n\t\t\t\t\t\treturn (\n\t\t\t\t\t\t\t<FacetItem\n\t\t\t\t\t\t\t\tkey={i.id}\n\t\t\t\t\t\t\t\t{...i}\n\t\t\t\t\t\t\t\tonRefine={id => {\n\t\t\t\t\t\t\t\t\trefine(id);\n\t\t\t\t\t\t\t\t\tinsightsClient('clickedFilters', {\n\t\t\t\t\t\t\t\t\t\tindex: indexName,\n\t\t\t\t\t\t\t\t\t\teventName: 'Clicked filter',\n\t\t\t\t\t\t\t\t\t\tfilters: [`${attribute}:${id}`],\n\t\t\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\t\t}}\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t);\n\t\t\t\t\t})}\n\t\t\t\t\t{canToggleShowMore && <ShowMoreToggle attribute={attribute} setShowMore={setShowMore} showMore={showMore} />}\n\t\t\t\t</div>\n\t\t\t</AccordionContent>\n\t\t</AccordionItem>\n\t);\n}\n\nfunction Statuses({\n\tsetExpandedFacets,\n}: {\n\tsetExpandedFacets: (setState: (expandedFacets: string[]) => string[]) => void;\n}) {\n\tconst resources = useSearchResources();\n\tconst { indexName } = useAlgoliaSearch();\n\tconst level1 = useRefinementList({ attribute: 'categories.lvl1', limit: 100 }, { skipSuspense: true });\n\tconst level2 = useRefinementList({ attribute: 'categories.lvl2', limit: 1000 }, { skipSuspense: true });\n\tconst level3 = useRefinementList({ attribute: 'categories.lvl3', limit: 1000 }, { skipSuspense: true });\n\tconst level4 = useRefinementList({ attribute: 'categories.lvl4', limit: 1000 }, { skipSuspense: true });\n\n\tconst sections: {\n\t\tvalue: string;\n\t\trefinement: RefinementListRenderState;\n\t\titems: RefinementListItem[];\n\t}[] = [\n\t\t{\n\t\t\tvalue: 'status',\n\t\t\trefinement: level1,\n\t\t\titems: level1.items.filter(i => i.value.startsWith('status')),\n\t\t},\n\t\t...level1.items\n\t\t\t.filter(i => i.isRefined && i.value.startsWith('status'))\n\t\t\t.map(status => ({\n\t\t\t\tvalue: status.value,\n\t\t\t\trefinement: level2,\n\t\t\t\titems: level2.items.filter(i => i.value.startsWith(status.value)),\n\t\t\t})),\n\t\t...level2.items\n\t\t\t.filter(i => i.isRefined && i.value.startsWith('status'))\n\t\t\t.map(status => ({\n\t\t\t\tvalue: status.value,\n\t\t\t\trefinement: level3,\n\t\t\t\titems: level3.items.filter(i => i.value.startsWith(status.value)),\n\t\t\t})),\n\t\t...level3.items\n\t\t\t.filter(i => i.isRefined && i.value.startsWith('status'))\n\t\t\t.map(status => ({\n\t\t\t\tvalue: status.value,\n\t\t\t\trefinement: level4,\n\t\t\t\titems: level4.items.filter(i => i.value.startsWith(status.value)),\n\t\t\t})),\n\t];\n\n\treturn (\n\t\t<>\n\t\t\t{sections.map(({ value, refinement, items }) =>\n\t\t\t\titems.length ? (\n\t\t\t\t\t<AccordionItem key={value} value={value}>\n\t\t\t\t\t\t<AccordionTrigger className=\"border-t border-primary-100 p-4 lg:border-t-0 [&>svg]:text-primary\">\n\t\t\t\t\t\t\t<Typography className=\"text-primary-400\" variant=\"bodyRegular\" tag=\"div\">\n\t\t\t\t\t\t\t\t{resources[c_statusLabelKeys[value] ?? value] ?? value}\n\t\t\t\t\t\t\t</Typography>\n\t\t\t\t\t\t</AccordionTrigger>\n\t\t\t\t\t\t<AccordionContent className=\"m-0 bg-grey-200 p-4\">\n\t\t\t\t\t\t\t<div className=\"flex flex-col gap-y-4\">\n\t\t\t\t\t\t\t\t{items.map(item => (\n\t\t\t\t\t\t\t\t\t<div key={item.value}>\n\t\t\t\t\t\t\t\t\t\t<button\n\t\t\t\t\t\t\t\t\t\t\tclassName={cn(\n\t\t\t\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\t\t\t\t'text-black-200 hover:text-secondary-200': !item.isRefined,\n\t\t\t\t\t\t\t\t\t\t\t\t\t'text-primary': item.isRefined,\n\t\t\t\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t\t\t\t'bodySm w-full text-left capitalize'\n\t\t\t\t\t\t\t\t\t\t\t)}\n\t\t\t\t\t\t\t\t\t\t\tonClick={() => {\n\t\t\t\t\t\t\t\t\t\t\t\trefinement.refine(item.value);\n\n\t\t\t\t\t\t\t\t\t\t\t\tinsightsClient('clickedFilters', {\n\t\t\t\t\t\t\t\t\t\t\t\t\tindex: indexName,\n\t\t\t\t\t\t\t\t\t\t\t\t\teventName: 'Clicked filter',\n\t\t\t\t\t\t\t\t\t\t\t\t\tfilters: [`categories:${item.value}`],\n\t\t\t\t\t\t\t\t\t\t\t\t});\n\n\t\t\t\t\t\t\t\t\t\t\t\tif (!item.isRefined) {\n\t\t\t\t\t\t\t\t\t\t\t\t\tsetExpandedFacets(old => [...old, item.value]);\n\t\t\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\t\t}}\n\t\t\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t\t\t{resources[c_statusLabelKeys[item.value] ?? item.value] ?? item.value}{' '}\n\t\t\t\t\t\t\t\t\t\t\t<span className=\"text-black-100\">\n\t\t\t\t\t\t\t\t\t\t\t\t{'('}\n\t\t\t\t\t\t\t\t\t\t\t\t{item.count}\n\t\t\t\t\t\t\t\t\t\t\t\t{')'}\n\t\t\t\t\t\t\t\t\t\t\t</span>\n\t\t\t\t\t\t\t\t\t\t</button>\n\t\t\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t\t\t))}\n\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t</AccordionContent>\n\t\t\t\t\t</AccordionItem>\n\t\t\t\t) : null\n\t\t\t)}\n\t\t</>\n\t);\n}\n\nexport function UserSearchFilterAccordionItem({ filter }: { filter: UserSearchFilter }) {\n\tconst { selectedFilterOptions, setSelectedFilterOption } = useUserSearchFilterContext();\n\tconst selectedFilterOption = selectedFilterOptions[filter.token];\n\tconst title = filter.title;\n\tconst options = (Array.isArray(filter.options) ? filter.options : []).filter(\n\t\t(option: { displayName: string }) => option && option.displayName !== ''\n\t);\n\n\tif (!title || options.length === 0) {\n\t\treturn null;\n\t}\n\n\treturn (\n\t\t<AccordionItem value={`user-filter-${title}`}>\n\t\t\t<AccordionTrigger className=\"border-t border-primary-100 p-4 lg:border-t-0 [&>svg]:text-primary\">\n\t\t\t\t<Typography className=\"text-primary-400\" variant=\"bodyRegular\" tag=\"div\">\n\t\t\t\t\t{title}\n\t\t\t\t</Typography>\n\t\t\t</AccordionTrigger>\n\t\t\t<AccordionContent className=\"m-0 bg-grey-200 p-4\">\n\t\t\t\t<div className=\"flex flex-col gap-y-4\">\n\t\t\t\t\t{options.map((option: UserSearchFilterOption) => {\n\t\t\t\t\t\tconst label = option.displayName;\n\t\t\t\t\t\tconst isSelected = selectedFilterOption === option.token;\n\n\t\t\t\t\t\treturn (\n\t\t\t\t\t\t\t<Typography\n\t\t\t\t\t\t\t\tvariant=\"bodySmall\"\n\t\t\t\t\t\t\t\tclassName=\"flex cursor-pointer items-center text-black-200\"\n\t\t\t\t\t\t\t\tkey={label}\n\t\t\t\t\t\t\t\ttag=\"label\"\n\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t<input\n\t\t\t\t\t\t\t\t\tchecked={isSelected}\n\t\t\t\t\t\t\t\t\tclassName=\"mr-3 h-[13px] w-[13px] border-grey-100 text-primary\"\n\t\t\t\t\t\t\t\t\tonChange={() => setSelectedFilterOption(filter.token, option.token)}\n\t\t\t\t\t\t\t\t\ttype=\"radio\"\n\t\t\t\t\t\t\t\t\tvalue={option.token}\n\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t\t<span className={cn(isSelected ? 'text-primary' : 'text-black-200 hover:text-secondary-200')}>\n\t\t\t\t\t\t\t\t\t{label}\n\t\t\t\t\t\t\t\t</span>\n\t\t\t\t\t\t\t</Typography>\n\t\t\t\t\t\t);\n\t\t\t\t\t})}\n\t\t\t\t</div>\n\t\t\t</AccordionContent>\n\t\t</AccordionItem>\n\t);\n}\n\nexport function Categories() {\n\tconst [expandedFacets, setExpandedFacets] = useState<string[]>([]);\n\tconst [showMore, setShowMore] = useState<string>();\n\tconst { userSearchFilters } = useUserSearchFilterContext();\n\n\treturn (\n\t\t<Accordion onValueChange={setExpandedFacets} type=\"multiple\" value={expandedFacets}>\n\t\t\t{userSearchFilters?.map((filter, index) => {\n\t\t\t\tconst key = `${filter.title}-${index}`;\n\n\t\t\t\treturn <UserSearchFilterAccordionItem filter={filter} key={key} />;\n\t\t\t})}\n\t\t\t<Category\n\t\t\t\tcategory=\"topic\"\n\t\t\t\tmaxLevel={3}\n\t\t\t\tsetExpandedFacets={setExpandedFacets}\n\t\t\t\tsetShowMore={setShowMore}\n\t\t\t\tshowMore={showMore}\n\t\t\t/>\n\t\t\t<Category\n\t\t\t\tcategory=\"resourceType\"\n\t\t\t\tmaxLevel={1}\n\t\t\t\tsetExpandedFacets={setExpandedFacets}\n\t\t\t\tsetShowMore={setShowMore}\n\t\t\t\tshowMore={showMore}\n\t\t\t/>\n\t\t\t<AuthorsOrPublishers\n\t\t\t\tattribute=\"authorIds\"\n\t\t\t\tnameAttribute=\"authorFacets\"\n\t\t\t\tsetShowMore={setShowMore}\n\t\t\t\tshowMore={showMore}\n\t\t\t/>\n\t\t\t<Statuses setExpandedFacets={setExpandedFacets} />\n\t\t\t<Category\n\t\t\t\tcategory=\"specials\"\n\t\t\t\tsetExpandedFacets={setExpandedFacets}\n\t\t\t\tsetShowMore={setShowMore}\n\t\t\t\tshowMore={showMore}\n\t\t\t/>\n\t\t\t<Category\n\t\t\t\tcategory=\"language\"\n\t\t\t\tsetExpandedFacets={setExpandedFacets}\n\t\t\t\tsetShowMore={setShowMore}\n\t\t\t\tshowMore={showMore}\n\t\t\t/>\n\t\t\t<Category\n\t\t\t\tcategory=\"seriesSets\"\n\t\t\t\tmaxLevel={1}\n\t\t\t\tsetExpandedFacets={setExpandedFacets}\n\t\t\t\tsetShowMore={setShowMore}\n\t\t\t\tshowMore={showMore}\n\t\t\t/>\n\t\t\t<AuthorsOrPublishers\n\t\t\t\tattribute=\"publisherIds\"\n\t\t\t\tnameAttribute=\"publisherFacets\"\n\t\t\t\tsetShowMore={setShowMore}\n\t\t\t\tshowMore={showMore}\n\t\t\t/>\n\t\t\t<Category\n\t\t\t\tcategory=\"bibleAndApocrypha\"\n\t\t\t\tmaxLevel={3}\n\t\t\t\tsetExpandedFacets={setExpandedFacets}\n\t\t\t\tsetShowMore={setShowMore}\n\t\t\t\tshowMore={showMore}\n\t\t\t/>\n\t\t\t<Category\n\t\t\t\tcategory=\"containment\"\n\t\t\t\tmaxLevel={1}\n\t\t\t\tsetExpandedFacets={setExpandedFacets}\n\t\t\t\tsetShowMore={setShowMore}\n\t\t\t\tshowMore={showMore}\n\t\t\t/>\n\t\t\t<Category category=\"format\" setExpandedFacets={setExpandedFacets} setShowMore={setShowMore} showMore={showMore} />\n\t\t\t<Category\n\t\t\t\tcategory=\"genre\"\n\t\t\t\tmaxLevel={2}\n\t\t\t\tsetExpandedFacets={setExpandedFacets}\n\t\t\t\tsetShowMore={setShowMore}\n\t\t\t\tshowMore={showMore}\n\t\t\t/>\n\t\t\t<Category\n\t\t\t\tcategory=\"licensingMethod\"\n\t\t\t\tsetExpandedFacets={setExpandedFacets}\n\t\t\t\tsetShowMore={setShowMore}\n\t\t\t\tshowMore={showMore}\n\t\t\t/>\n\t\t\t<Category\n\t\t\t\tcategory=\"religiousGroup\"\n\t\t\t\tmaxLevel={0}\n\t\t\t\tsetExpandedFacets={setExpandedFacets}\n\t\t\t\tsetShowMore={setShowMore}\n\t\t\t\tshowMore={showMore}\n\t\t\t/>\n\t\t</Accordion>\n\t);\n}\n","import React, { useEffect, useRef } from 'react';\nimport {\n\tCurrentRefinementsConnectorParamsItem,\n\tCurrentRefinementsConnectorParamsRefinement,\n} from 'instantsearch.js/es/connectors/current-refinements/connectCurrentRefinements';\nimport { X } from 'lucide-react';\nimport { useCurrentRefinements, useRefinementList, useSearchBox } from 'react-instantsearch';\n\nimport { useLocation } from '../../location';\nimport { useAuthor } from '../../hooks/use-author';\nimport { usePublisher } from '../../hooks/use-publisher';\nimport { getFacetDisplayLabel, useFacetConstraints } from './facet-label';\nimport { parseFacetValue } from './util';\n\n// ---------------------------------------------------------------------------\n// CurrentRefinements — chips for active facet refinements\n// ---------------------------------------------------------------------------\n\nfunction isStatusRefinement(attribute: string, value: string): boolean {\n\treturn /^categories\\.lvl\\d+$/.test(attribute) && value.split('>')[0].trim() === 'status';\n}\n\nfunction isGenericLocalizableFacet(attribute: string, value: string): boolean {\n\treturn attribute !== 'authorIds' && attribute !== 'publisherIds' && !isStatusRefinement(attribute, value);\n}\n\nfunction RefinementLabel({ attribute, value, facetLabel }: { attribute: string; value: string; facetLabel: string }) {\n\tconst stringValue = typeof value === 'string' ? value : String(value ?? '');\n\n\tif (attribute === 'authorIds') {\n\t\treturn <AuthorLabel value={stringValue} />;\n\t}\n\n\tif (attribute === 'publisherIds') {\n\t\treturn <PublisherLabel value={stringValue} />;\n\t}\n\n\tif (!isGenericLocalizableFacet(attribute, stringValue)) {\n\t\treturn <span>{stringValue.replace(/^((.*) > )*/, '')}</span>;\n\t}\n\n\treturn <span className=\"normal-case\">{facetLabel}</span>;\n}\n\nfunction AuthorLabel({ value }: { value: string }) {\n\tconst { items } = useRefinementList({ attribute: 'authorFacets' });\n\n\tif (!items.length) {\n\t\treturn <span>{'…'}</span>;\n\t}\n\n\tconst item = items.find(i => i.value.startsWith(`${value}:`));\n\n\tif (item) {\n\t\tconst { displayName } = parseFacetValue(item.label);\n\t\treturn <span>{displayName}</span>;\n\t}\n\n\treturn <AuthorApiLabel value={value} />;\n}\n\nfunction AuthorApiLabel({ value }: { value: string }) {\n\tconst { data, isLoading } = useAuthor(value);\n\n\tif (isLoading) {\n\t\treturn <span>{'…'}</span>;\n\t}\n\n\tif (!data) {\n\t\treturn null;\n\t}\n\n\treturn <span>{data.displayName}</span>;\n}\n\nfunction PublisherLabel({ value }: { value: string }) {\n\tconst { items } = useRefinementList({ attribute: 'publisherFacets' });\n\n\tif (!items.length) {\n\t\treturn <span>{'…'}</span>;\n\t}\n\n\tconst item = items.find(i => i.value.startsWith(`${value}:`));\n\n\tif (item) {\n\t\tconst { displayName } = parseFacetValue(item.label);\n\t\treturn <span>{displayName}</span>;\n\t}\n\n\treturn <PublisherApiLabel value={value} />;\n}\n\nfunction PublisherApiLabel({ value }: { value: string }) {\n\tconst { data, isLoading } = usePublisher(value);\n\n\tif (isLoading) {\n\t\treturn <span>{'…'}</span>;\n\t}\n\n\tif (!data) {\n\t\treturn null;\n\t}\n\n\treturn <span>{data.displayName}</span>;\n}\n\nexport function CurrentRefinements() {\n\tconst currentRefinements = useCurrentRefinements();\n\tconst itemsByAttribute: Record<string, CurrentRefinementsConnectorParamsItem> = {};\n\tconst refinementList: CurrentRefinementsConnectorParamsRefinement[] = [];\n\n\tfor (const item of currentRefinements?.items ?? []) {\n\t\titemsByAttribute[item.attribute] = item;\n\n\t\tfor (const refinement of item.refinements ?? []) {\n\t\t\trefinementList.push(refinement);\n\t\t}\n\t}\n\n\treturn refinementList.map(item => {\n\t\tconst itemValue = item.value;\n\t\tconst itemAndChildren =\n\t\t\ttypeof itemValue === 'string'\n\t\t\t\t? refinementList.filter(r => typeof r.value === 'string' && r.value.startsWith(itemValue))\n\t\t\t\t: [item];\n\n\t\treturn (\n\t\t\t<RefinementChip\n\t\t\t\tattribute={item.attribute}\n\t\t\t\titemAndChildren={itemAndChildren}\n\t\t\t\titemsByAttribute={itemsByAttribute}\n\t\t\t\tkey={`${item.attribute}:${String(itemValue)}`}\n\t\t\t\tlabel={item.label}\n\t\t\t\tvalue={String(itemValue)}\n\t\t\t/>\n\t\t);\n\t});\n}\n\nfunction RefinementChip({\n\tattribute,\n\tvalue,\n\tlabel,\n\titemAndChildren,\n\titemsByAttribute,\n}: {\n\tattribute: string;\n\tvalue: string;\n\tlabel: string;\n\titemAndChildren: CurrentRefinementsConnectorParamsRefinement[];\n\titemsByAttribute: Record<string, CurrentRefinementsConnectorParamsItem>;\n}) {\n\tconst facetConstraints = useFacetConstraints();\n\tconst facetLabel = isGenericLocalizableFacet(attribute, value)\n\t\t? getFacetDisplayLabel(value, facetConstraints, attribute)\n\t\t: label;\n\n\treturn (\n\t\t<button\n\t\t\taria-label={`Remove ${facetLabel} from filters`}\n\t\t\tclassName=\"flex items-center gap-x-1 bg-grey-200 py-[6px] pl-3 pr-2 text-xs capitalize text-black-100\"\n\t\t\tonClick={() => itemAndChildren.forEach(i => itemsByAttribute[attribute]?.refine(i))}\n\t\t>\n\t\t\t<RefinementLabel attribute={attribute} facetLabel={facetLabel} value={value} />\n\t\t\t<X aria-hidden=\"true\" height={14} width={14} />\n\t\t</button>\n\t);\n}\n\n// ---------------------------------------------------------------------------\n// CurrentQueryRefinement — chip for the active search query\n// ---------------------------------------------------------------------------\n\nexport default function CurrentQueryRefinement() {\n\tconst { searchParams } = useLocation();\n\tconst urlQuery = searchParams.get('query')?.trim() ?? '';\n\n\tconst { query, refine, clear } = useSearchBox();\n\tconst queryRef = useRef(query);\n\tqueryRef.current = query;\n\n\tuseEffect(() => {\n\t\tif (urlQuery && queryRef.current !== urlQuery) {\n\t\t\trefine(urlQuery);\n\t\t}\n\t}, [urlQuery, refine]);\n\n\tconst removeQuery = () => {\n\t\tclear();\n\t};\n\n\treturn query ? (\n\t\t<button\n\t\t\taria-label=\"remove search term from filters\"\n\t\t\tclassName=\"flex items-center gap-x-1 bg-grey-200 py-[6px] pl-3 pr-2 text-xs capitalize text-black-100\"\n\t\t\tonClick={removeQuery}\n\t\t>\n\t\t\t<span>\n\t\t\t\t{'\"'}\n\t\t\t\t{query}\n\t\t\t\t{'\"'}\n\t\t\t</span>\n\t\t\t<X aria-hidden=\"true\" height={14} width={14} />\n\t\t</button>\n\t) : null;\n}\n","import React from 'react';\nimport { useRefinementList } from 'react-instantsearch';\n\nimport type { FacetConfiguration } from './routing';\n\n// Keeps a real refinementList widget mounted for each hidden facet attribute (and, for hierarchical facets,\n// each of its levels) so Algolia treats it as refinable, without rendering any UI. Filtering itself is driven\n// entirely by the URL via routing.ts.\n// skipSuspense avoids blocking rendering on data that is never displayed.\nfunction HiddenRefinementList({ attribute }: { attribute: string }) {\n\tuseRefinementList({ attribute }, { skipSuspense: true });\n\n\treturn null;\n}\n\nfunction getHiddenAlgoliaAttributes(config: FacetConfiguration): string[] {\n\tif (config.type === 'simple') {\n\t\treturn [config.algoliaAttribute];\n\t}\n\n\tconst attributes: string[] = [];\n\n\tfor (let level = config.minLevel; level <= config.maxLevel; level += 1) {\n\t\tattributes.push(`${config.algoliaAttributeBase}.lvl${level}`);\n\t}\n\n\treturn attributes;\n}\n\nexport default function HiddenFacetRefinements({ facetConfigurations }: { facetConfigurations: FacetConfiguration[] }) {\n\tconst attributes = facetConfigurations.filter(config => config.isHidden).flatMap(getHiddenAlgoliaAttributes);\n\n\treturn (\n\t\t<>\n\t\t\t{attributes.map(attribute => (\n\t\t\t\t<HiddenRefinementList attribute={attribute} key={attribute} />\n\t\t\t))}\n\t\t</>\n\t);\n}\n","import React, { ReactNode } from 'react';\nimport { cn } from '../../util/cn';\n\nfunction SkeletonRoot({\n\tclassName,\n\tchildren,\n\tpending = false,\n\thideOverflow = false,\n}: {\n\tclassName?: string;\n\tchildren?: React.ReactNode;\n\tpending?: boolean;\n\thideOverflow?: boolean;\n}) {\n\treturn (\n\t\t<div\n\t\t\tclassName={cn('@container', hideOverflow && 'overflow-hidden', className)}\n\t\t\tdata-pending={pending ? '' : undefined}\n\t\t\trole={pending ? 'status' : undefined}\n\t\t>\n\t\t\t{children}\n\t\t\t{pending && <span className=\"sr-only\">{'Loading...'}</span>}\n\t\t</div>\n\t);\n}\n\nfunction SkeletonBox({ className }: { className?: string }) {\n\treturn <div className={cn('rounded-lg bg-gray-300', className)} />;\n}\n\nfunction SkeletonText({ characterCount = 10, className }: { characterCount?: number | 'full'; className?: string }) {\n\treturn (\n\t\t<div className={cn('flex h-[1lh] items-center', className)}>\n\t\t\t<div\n\t\t\t\tclassName={cn(`h-[1ex] max-w-full rounded-[inherit] bg-gray-300`)}\n\t\t\t\tstyle={{ width: characterCount === 'full' ? '100%' : `${characterCount}ch` }}\n\t\t\t/>\n\t\t</div>\n\t);\n}\n\nfunction SkeletonIcon({ className, icon }: { className?: string; icon: ReactNode }) {\n\treturn <div className={cn('text-gray-300 opacity-25', className)}>{icon}</div>;\n}\n\nexport { SkeletonIcon as Icon, SkeletonRoot as Root, SkeletonBox as Box, SkeletonText as Text };\n","import React from 'react';\n\nimport { CommandSentence } from '@faithlife/command-sentence-control';\nimport { useLocalization } from '../../../localization';\nimport { useBrandName } from '../../../util/brand-name-context';\n\nexport default function EnhancedForLogosLabel() {\n\tconst resources = useLocalization('CommerceWeb.Resources.Search.DisplayTemplates.ProductSearchResultViewModel');\n\tconst logosOrVerbum = useBrandName();\n\tconst isVerbum = logosOrVerbum?.toLowerCase() === 'verbum';\n\treturn (\n\t\t<CommandSentence className=\"text-xs text-primary\" template={resources.EnhancedForLogos}>\n\t\t\t<CommandSentence.Field name=\"ICON\">\n\t\t\t\t<img\n\t\t\t\t\tclassName={\n\t\t\t\t\t\tisVerbum\n\t\t\t\t\t\t\t? 'inline-block w-[17px] h-[12px] [vertical-align:-1.5px]'\n\t\t\t\t\t\t\t: 'inline-block w-[14px] h-[14px] [vertical-align:-2px] mx-px'\n\t\t\t\t\t}\n\t\t\t\t\talt={logosOrVerbum}\n\t\t\t\t\tsrc={\n\t\t\t\t\t\tisVerbum\n\t\t\t\t\t\t\t? 'https://files.logoscdn.com/v1/files/70496318/assets/14995970/content.svg?signature=SsnOeyt3lPzdfqreDLuA7km2gRs'\n\t\t\t\t\t\t\t: 'https://files.logoscdn.com/v1/files/71036773/assets/14991834/content.svg?signature=NlgSyNjXKmP7caOrWgZiZv5hSEE'\n\t\t\t\t\t}\n\t\t\t\t/>\n\t\t\t</CommandSentence.Field>\n\t\t</CommandSentence>\n\t);\n}\n","import React from 'react';\nimport { CommandSentence } from '@faithlife/command-sentence-control';\n\nimport EnhancedForLogosLabel from '../enhanced-for-logos-label';\nimport Tooltip from '../tooltip';\nimport { InfoIconSvgUrl } from '../svgs';\n\nimport { useLocalization } from '../../../localization';\nimport { useBrandName } from '../../../util/brand-name-context';\n\nexport interface EnhancedForLogosWithTooltipProps {\n\tclassName?: string;\n}\n\nconst EnhancedForLogosWithTooltip = ({ className }: EnhancedForLogosWithTooltipProps) => {\n\tconst resources = useLocalization('CommerceWeb.Resources.Search.DisplayTemplates.ProductSearchResultViewModel');\n\n\tconst logosOrVerbum = useBrandName();\n\n\treturn (\n\t\t<Tooltip placement=\"bottom\" className={className} link={<EnhancedForLogosLabel />}>\n\t\t\t<div className={'w-[250px] text-start flex items-start gap-sp8'}>\n\t\t\t\t<div>\n\t\t\t\t\t<img className=\"max-w-none w-[20px] h-[20px]\" src={InfoIconSvgUrl} alt=\"\" />\n\t\t\t\t</div>\n\t\t\t\t<div>\n\t\t\t\t\t<CommandSentence className=\"text-xs\" template={resources.EnhancedForLogosTooltipContent}>\n\t\t\t\t\t\t<CommandSentence.Field name=\"LOGOSORVERBUM\">{logosOrVerbum}</CommandSentence.Field>\n\t\t\t\t\t</CommandSentence>\n\t\t\t\t</div>\n\t\t\t</div>\n\t\t</Tooltip>\n\t);\n};\n\nexport default EnhancedForLogosWithTooltip;\n","import { useCallback, useEffect, useRef, useState } from 'react';\nimport insightsClient from 'search-insights';\n\nimport { PrepubProductStatus, useCurrentUser, usePricing } from '../../per-user-data/per-user-data-context';\nimport type { PrepubProductStatusSummary, ProductPrices } from '../../per-user-data/per-user-data-context';\nimport { detectIsAmberOptimizedUrl } from '../../shared/enhanced-image-tag/image';\nimport { useLocale } from '../../../localization/use-localization';\nimport { getSavingsPercent, slugify } from '../util';\nimport { ProductHitResult } from '../types';\nimport { useSearchResources } from '../search-resources';\nimport { useAlgoliaSearch } from '../algolia-search-context';\n\ntype AlgoliaPrepubStatus = Exclude<PrepubProductStatus, PrepubProductStatus.none>;\n\nconst c_gatheringInterestPercent = 75;\n\nconst usdFormat = new Intl.NumberFormat('en-US', {\n\tstyle: 'currency',\n\tcurrency: 'USD',\n\tminimumFractionDigits: 2,\n\tmaximumFractionDigits: 2,\n});\n\nconst placeholderImage = 'https://files.logoscdn.com/v1/assets/15953102/optimized';\n\nfunction getPrepubStatus(status: ProductHitResult['status'], percentCommitted: number): AlgoliaPrepubStatus | null {\n\tconst statusValues = Array.isArray(status) ? status : status ? [status] : [];\n\tconst normalizedStatusValues = statusValues.map(value => value.toLowerCase().replace(/[^a-z0-9]/g, ''));\n\n\tif (normalizedStatusValues.some(value => value.includes('shippingsoon'))) {\n\t\treturn PrepubProductStatus.shippingSoon;\n\t}\n\tif (normalizedStatusValues.some(value => value.includes('almostfunded'))) {\n\t\treturn PrepubProductStatus.almostThere;\n\t}\n\tif (normalizedStatusValues.some(value => value.includes('undercontract'))) {\n\t\treturn PrepubProductStatus.underContract;\n\t}\n\tif (normalizedStatusValues.some(value => value.includes('gatheringinterest'))) {\n\t\treturn percentCommitted >= c_gatheringInterestPercent\n\t\t\t? PrepubProductStatus.almostThere\n\t\t\t: PrepubProductStatus.gatheringInterest;\n\t}\n\n\treturn null;\n}\n\nfunction parsePrepubShipDate(value: ProductHitResult['prepubShipDate']): Date | null {\n\tif (typeof value === 'number') {\n\t\tif (!Number.isFinite(value)) {\n\t\t\treturn null;\n\t\t}\n\n\t\tconst milliseconds = Math.abs(value) < 1_000_000_000_000 ? value * 1000 : value;\n\t\tconst date = new Date(milliseconds);\n\t\treturn Number.isNaN(date.getTime()) ? null : date;\n\t}\n\n\tif (!value) {\n\t\treturn null;\n\t}\n\n\tconst dateOnlyMatch = /^(\\d{4})-(\\d{2})-(\\d{2})$/.exec(value);\n\tconst date = dateOnlyMatch\n\t\t? new Date(Number(dateOnlyMatch[1]), Number(dateOnlyMatch[2]) - 1, Number(dateOnlyMatch[3]))\n\t\t: new Date(value);\n\n\tif (\n\t\tNumber.isNaN(date.getTime()) ||\n\t\t(dateOnlyMatch &&\n\t\t\t(date.getFullYear() !== Number(dateOnlyMatch[1]) ||\n\t\t\t\tdate.getMonth() !== Number(dateOnlyMatch[2]) - 1 ||\n\t\t\t\tdate.getDate() !== Number(dateOnlyMatch[3])))\n\t) {\n\t\treturn null;\n\t}\n\n\treturn date;\n}\n\nfunction getShippingDateDescription(shipDate: Date, locale: string, resources: Record<string, string>): string {\n\tconst now = new Date();\n\tconst thirtyDaysFromNow = new Date(now);\n\tthirtyDaysFromNow.setDate(thirtyDaysFromNow.getDate() + 30);\n\tconst ninetyDaysFromNow = new Date(now);\n\tninetyDaysFromNow.setDate(ninetyDaysFromNow.getDate() + 90);\n\n\tlet shipDateString: string;\n\tif (shipDate < thirtyDaysFromNow) {\n\t\tshipDateString = new Intl.DateTimeFormat(locale).format(shipDate);\n\t} else if (shipDate < ninetyDaysFromNow) {\n\t\tshipDateString = new Intl.DateTimeFormat(locale, { month: 'short', year: 'numeric' }).format(shipDate);\n\t} else {\n\t\tshipDateString = `Q${Math.floor(shipDate.getMonth() / 3) + 1}-${shipDate.getFullYear()}`;\n\t}\n\n\treturn resources['shipsFormat'].replace('{0}', shipDateString);\n}\n\nfunction getPrepubProductStatusSummary(\n\thit: ProductHitResult,\n\tlocale: string,\n\tresources: Record<string, string>\n): PrepubProductStatusSummary | null {\n\tconst rawPercentCommitted = hit.percentCommitted;\n\tconst percentCommitted =\n\t\ttypeof rawPercentCommitted === 'number' && Number.isFinite(rawPercentCommitted)\n\t\t\t? Math.min(100, Math.max(0, rawPercentCommitted))\n\t\t\t: 0;\n\tconst status = getPrepubStatus(hit.status, percentCommitted);\n\n\tif (!status) {\n\t\treturn null;\n\t}\n\n\tconst shipDate = parsePrepubShipDate(hit.prepubShipDate);\n\tconst description =\n\t\tstatus === PrepubProductStatus.shippingSoon && shipDate\n\t\t\t? getShippingDateDescription(shipDate, locale, resources)\n\t\t\t: resources[\n\t\t\t\t\tstatus === PrepubProductStatus.gatheringInterest\n\t\t\t\t\t\t? 'gatheringInterestStatusText'\n\t\t\t\t\t\t: status === PrepubProductStatus.almostThere\n\t\t\t\t\t\t\t? 'almostFundedStatusText'\n\t\t\t\t\t\t\t: status === PrepubProductStatus.underContract\n\t\t\t\t\t\t\t\t? 'inProductionStatusText'\n\t\t\t\t\t\t\t\t: 'shippingSoonStatusText'\n\t\t\t\t];\n\n\treturn {\n\t\tstatus,\n\t\tpercentCommitted,\n\t\tshipDate: shipDate?.toISOString(),\n\t\tdescription,\n\t};\n}\n\nfunction getIndexedPrimarySkuId(\n\tprimarySkuStorefronts: ProductHitResult['primarySkuStorefronts'],\n\tstorefrontShortname: string\n): string | undefined {\n\tif (!primarySkuStorefronts) {\n\t\treturn undefined;\n\t}\n\n\tconst normalizedStorefrontShortname = storefrontShortname.toLowerCase();\n\treturn Object.entries(primarySkuStorefronts).find(([, storefronts]) =>\n\t\tstorefronts.some(storefront => storefront.toLowerCase() === normalizedStorefrontShortname)\n\t)?.[0];\n}\n\ninterface UseProductCardProps {\n\thit: ProductHitResult;\n\tqueryId?: string | null;\n\tposition?: number;\n}\n\nexport function useProductCard({ hit, queryId = null, position }: UseProductCardProps) {\n\tconst { data: pricingData } = usePricing(hit.productId);\n\tconst { preferredCurrency, isSignedIn: currentUserIsSignedIn } = useCurrentUser();\n\tconst { indexName, anonymousUserToken, storefrontShortname, isSignedIn: searchIsSignedIn } = useAlgoliaSearch();\n\tconst locale = useLocale();\n\tconst hasGeoRestriction = pricingData?.isGeographicallyRestricted;\n\tconst [isAddingToCart, setIsAddingToCart] = useState(false);\n\tconst resources = useSearchResources();\n\tconst productId = hit?.productId;\n\tconst requestIdRef = useRef<string | null>(null);\n\n\t// Use API pricing when available, fall back to Algolia pricing\n\tconst prices: ProductPrices = pricingData?.primarySku?.prices ?? {\n\t\tsalePrice: {\n\t\t\tamount: hit.salePrice ?? 0,\n\t\t\tdisplayAmount: usdFormat.format(hit.salePrice ?? 0),\n\t\t\tcurrencyCode: 'USD',\n\t\t},\n\t\tanchorPrice:\n\t\t\thit.salePrice !== hit.anchorPrice\n\t\t\t\t? {\n\t\t\t\t\t\tamount: hit.anchorPrice ?? 0,\n\t\t\t\t\t\tdisplayAmount: usdFormat.format(hit.anchorPrice ?? 0),\n\t\t\t\t\t\tdisplayAmountCurrencyCode: 'USD',\n\t\t\t\t\t\tcurrencyCode: 'USD',\n\t\t\t\t\t}\n\t\t\t\t: undefined,\n\t};\n\n\tconst accessKind = pricingData?.accessKind;\n\tconst isOwned = accessKind === 'Permanent' || accessKind === 'Temporary';\n\tconst hasPreorder = pricingData?.hasPreorder;\n\tconst prepubProductStatusSummary = getPrepubProductStatusSummary(hit, locale, resources);\n\tconst isPrepubProduct = pricingData ? pricingData.isPrepubProduct : Boolean(prepubProductStatusSummary);\n\tconst indexedPrimarySkuId = getIndexedPrimarySkuId(hit.primarySkuStorefronts, storefrontShortname);\n\tconst hasIndexedPrimarySkuData = hit.primarySkuStorefronts !== undefined;\n\tconst canUseIndexedPrimarySku = !(currentUserIsSignedIn || searchIsSignedIn);\n\tconst skuId = pricingData ? pricingData.primarySku?.skuId : canUseIndexedPrimarySku ? indexedPrimarySkuId : undefined;\n\tconst isPurchasable = pricingData\n\t\t? pricingData.primarySku?.isPurchasable\n\t\t: canUseIndexedPrimarySku && hasIndexedPrimarySkuData\n\t\t\t? Boolean(indexedPrimarySkuId)\n\t\t\t: undefined;\n\n\tuseEffect(() => {\n\t\tconst handleCartUpdated = (e: CustomEvent) => {\n\t\t\tif (e.detail.requestId === requestIdRef.current) {\n\t\t\t\tsetIsAddingToCart(false);\n\t\t\t}\n\t\t};\n\n\t\tconst handleCartUpdateError = (e: CustomEvent) => {\n\t\t\tif (e.detail.requestId === requestIdRef.current) {\n\t\t\t\tsetIsAddingToCart(false);\n\t\t\t}\n\t\t};\n\n\t\tdocument.addEventListener('faithlife.sites.cart.updated', handleCartUpdated as EventListener);\n\t\tdocument.addEventListener('faithlife.sites.cart.updateError', handleCartUpdateError as EventListener);\n\n\t\treturn () => {\n\t\t\tdocument.removeEventListener('faithlife.sites.cart.updated', handleCartUpdated as EventListener);\n\t\t\tdocument.removeEventListener('faithlife.sites.cart.updateError', handleCartUpdateError as EventListener);\n\t\t};\n\t}, []);\n\n\tconst slug = slugify(hit.title);\n\tconst productPath = slug ? `/product/${productId}/${slug}` : `/product/${productId}`;\n\tconst productUrl = queryId ? `${productPath}?queryId=${encodeURIComponent(queryId)}` : productPath;\n\tconst productName = hit.title ?? '';\n\tconst regularPrice = prices?.anchorPrice?.displayAmount;\n\tconst salePrice = prices?.salePrice?.displayAmount;\n\tconst salePriceCurrency = preferredCurrency !== 'USD' ? 'USD' : undefined;\n\tconst localizedSalePrice = prices?.salePrice?.localizedDisplayAmount ?? undefined;\n\tconst discountPercentage = getSavingsPercent(prices);\n\tconst isDiscounted = !!pricingData?.primarySku?.prices?.discountSavings;\n\tconst productImageSrc = hit.primaryImageUri;\n\tconst imageSrc = detectIsAmberOptimizedUrl(productImageSrc ?? '') ? productImageSrc : placeholderImage;\n\tconst isLogosEdition = hit.isLogosEdition ?? false;\n\n\tconst handleProductClick = useCallback(() => {\n\t\tif (!productId) {\n\t\t\treturn;\n\t\t}\n\n\t\tif (queryId && position) {\n\t\t\tinsightsClient('clickedObjectIDsAfterSearch', {\n\t\t\t\tindex: indexName,\n\t\t\t\teventName: `Clicked result on ${window.location.pathname}`.substring(0, 64),\n\t\t\t\tqueryID: queryId,\n\t\t\t\tobjectIDs: [productId],\n\t\t\t\tpositions: [position],\n\t\t\t});\n\t\t} else {\n\t\t\tinsightsClient('clickedObjectIDs', {\n\t\t\t\tindex: indexName,\n\t\t\t\teventName: `Clicked result on ${window.location.pathname}`.substring(0, 64),\n\t\t\t\tobjectIDs: [productId],\n\t\t\t});\n\t\t}\n\t}, [productId, queryId, position, indexName]);\n\n\tconst handleAddToCart = (e: React.MouseEvent<HTMLButtonElement>) => {\n\t\tif (!skuId || isAddingToCart) {\n\t\t\treturn;\n\t\t}\n\n\t\t// Track add-to-cart with Algolia insights\n\t\tif (productId) {\n\t\t\tconst eventType = queryId ? 'addedToCartObjectIDsAfterSearch' : 'addedToCartObjectIDs';\n\t\t\tconst eventData: Record<string, any> = {\n\t\t\t\tindex: indexName,\n\t\t\t\teventName: `Added product to cart on ${window.location.pathname}`.substring(0, 64),\n\t\t\t\tobjectIDs: [productId],\n\t\t\t};\n\t\t\tif (queryId) {\n\t\t\t\teventData.queryID = queryId;\n\t\t\t}\n\t\t\tinsightsClient(eventType as any, eventData);\n\t\t}\n\n\t\tconst requestId = (requestIdRef.current = `${Date.now()}-${Math.random()}`);\n\n\t\tconst eventDetail: Record<string, any> = {\n\t\t\taddToCartUrl: pricingData?.primarySku?.routes?.addToCartUrl,\n\t\t\tskuIds: [pricingData?.primarySku?.addToCartSkuId ?? skuId],\n\t\t\tquantity: 1,\n\t\t\tpayInFull: true,\n\t\t\trequestId,\n\t\t};\n\n\t\t// Include the query ID for Algolia purchase attribution\n\t\tif (queryId) {\n\t\t\teventDetail.searchData = {\n\t\t\t\tqueryId,\n\t\t\t\t...(productId ? { productIds: [productId] } : {}),\n\t\t\t\tanonymousUserToken,\n\t\t\t};\n\t\t}\n\n\t\te.currentTarget.dispatchEvent(\n\t\t\tnew CustomEvent('faithlife.sites.addToCartButton.click', {\n\t\t\t\tbubbles: true,\n\t\t\t\tdetail: eventDetail,\n\t\t\t})\n\t\t);\n\n\t\tsetIsAddingToCart(true);\n\t};\n\n\treturn {\n\t\tresources,\n\t\tproductUrl,\n\t\tproductName,\n\t\timageSrc,\n\t\tisLogosEdition,\n\t\tregularPrice,\n\t\tsalePrice,\n\t\tsalePriceCurrency,\n\t\tlocalizedSalePrice,\n\t\tdiscountPercentage,\n\t\tisDiscounted,\n\t\taccessKind,\n\t\tisOwned,\n\t\thasGeoRestriction,\n\t\tisPurchasable,\n\t\thasPreorder,\n\t\tisPrepubProduct,\n\t\tprepubProductStatusSummary,\n\t\tskuId,\n\t\tisAddingToCart,\n\t\thandleProductClick,\n\t\thandleAddToCart,\n\t\thit,\n\t};\n}\n\nexport type ProductCardData = ReturnType<typeof useProductCard>;\n","import React from 'react';\n\nimport { Image } from '../../shared/enhanced-image-tag/image';\n\ninterface ProductImageProps {\n\tproductName: string;\n\timageSrc: string;\n\tproductUrl: string;\n\tpriority?: boolean;\n\thandleProductClick: () => void;\n}\n\nexport function ProductImage({ productName, imageSrc, productUrl, priority, handleProductClick }: ProductImageProps) {\n\treturn (\n\t\t<a\n\t\t\tclassName=\"flex aspect-[100/122] w-auto justify-center lg:aspect-[129/158]\"\n\t\t\thref={productUrl}\n\t\t\tonClick={handleProductClick}\n\t\t\tonAuxClick={handleProductClick}\n\t\t>\n\t\t\t<Image\n\t\t\t\talt={productName}\n\t\t\t\tbelowTheFold={!priority}\n\t\t\t\tclassName=\"w-[100px] h-[122px] object-contain lg:h-[158px] lg:w-[129px]\"\n\t\t\t\tsizes={{ mobile: 100, desktop: 129 }}\n\t\t\t\tsrc={imageSrc}\n\t\t\t\ttargetAspectRatio={[129, 158]}\n\t\t\t/>\n\t\t</a>\n\t);\n}\n","import React from 'react';\nimport { Typography } from '@faithlife/commerce-components';\n\nimport { useSearchResources } from '../search-resources';\n\ninterface DiscountBadgeProps {\n\tdiscountPercentage: number;\n\tisDiscounted: boolean;\n\tclassName?: string;\n}\n\nexport function DiscountBadge({ discountPercentage, isDiscounted, className }: DiscountBadgeProps) {\n\tconst resources = useSearchResources();\n\n\tif (discountPercentage <= 1) {\n\t\treturn null;\n\t}\n\n\tconst badgeClassName = isDiscounted ? 'bg-red-300 text-white' : 'bg-primary-200 text-primary-400';\n\n\treturn (\n\t\t<Typography className={`rounded-full px-2 py-[2px] ${badgeClassName} ${className ?? ''}`} variant=\"finePrint\">\n\t\t\t{resources['discountFormat']?.replace('%DISCOUNT_PERCENTAGE%', discountPercentage.toFixed())}\n\t\t</Typography>\n\t);\n}\n","import React from 'react';\nimport { Typography } from '@faithlife/commerce-components';\n\nimport { cn } from '../../../util/cn';\n\ninterface ProductTitleProps {\n\tproductName: string;\n\tproductUrl: string;\n\thandleProductClick: () => void;\n\tclassName?: string;\n}\n\nexport function ProductTitle({ productName, productUrl, handleProductClick, className }: ProductTitleProps) {\n\treturn (\n\t\t<a href={productUrl} onAuxClick={handleProductClick} onClick={handleProductClick} title={productName}>\n\t\t\t<Typography\n\t\t\t\tclassName={cn('line-clamp-2 hover:underline focus-visible:underline', className)}\n\t\t\t\ttag=\"h3\"\n\t\t\t\tvariant=\"bodySmall\"\n\t\t\t>\n\t\t\t\t{productName}\n\t\t\t</Typography>\n\t\t</a>\n\t);\n}\n","import React from 'react';\nimport { Typography } from '@faithlife/commerce-components';\n\ninterface ProductAuthorsProps {\n\tauthors?: string[];\n}\n\nexport function ProductAuthors({ authors }: ProductAuthorsProps) {\n\treturn (\n\t\t<Typography className=\"bodyMd line-clamp-1 text-black\" variant=\"finePrint\">\n\t\t\t{authors?.join(', ')}\n\t\t</Typography>\n\t);\n}\n","import React from 'react';\nimport { Button, PriceLabel, Typography } from '@faithlife/commerce-components';\nimport type { buttonScaleOptions } from '@faithlife/commerce-components';\n\nimport { cn } from '../../../util/cn';\nimport * as Skeleton from '../../skeleton';\nimport { useSearchResources } from '../search-resources';\nimport { ProductCardData } from './use-product-card';\n\ntype ButtonScale = (typeof buttonScaleOptions)[number];\n\nconst ctaButtonScale: ButtonScale = 'medium';\nconst skeletonHeightByButtonScale = {\n\tsmall: 'h-8',\n\tmedium: 'h-12',\n\tlarge: 'h-[60px]',\n} satisfies Record<ButtonScale, string>;\n\ninterface ProductPricingProps {\n\tcardData: ProductCardData;\n\tbuttonLayoutClassName: string;\n}\n\nfunction getOwnershipLabel(\n\tresources: ReturnType<typeof useSearchResources>,\n\thasGeoRestriction: boolean | undefined,\n\taccessKind: string | undefined,\n\thasPreorder: boolean | undefined\n): string | null {\n\tif (hasGeoRestriction) {\n\t\treturn resources['geoRestrictionMessage'];\n\t}\n\tif (accessKind === 'Permanent') {\n\t\treturn resources['permanentOwnMessage'];\n\t}\n\tif (accessKind === 'Temporary') {\n\t\treturn resources['temporaryOwnMessage'];\n\t}\n\tif (hasPreorder) {\n\t\treturn resources['hasPreorderMessage'];\n\t}\n\treturn null;\n}\n\nexport function ProductPricing({ cardData, buttonLayoutClassName }: ProductPricingProps) {\n\treturn (\n\t\t<>\n\t\t\t<ProductPrice cardData={cardData} className=\"items-end\" />\n\t\t\t<ProductCta\n\t\t\t\tbuttonLayoutClassName={buttonLayoutClassName}\n\t\t\t\tcardData={cardData}\n\t\t\t\townershipLabelClassName=\"text-right\"\n\t\t\t/>\n\t\t</>\n\t);\n}\n\ninterface ProductPriceProps {\n\tcardData: ProductCardData;\n\tclassName?: string;\n}\n\nexport function ProductPrice({ cardData, className }: ProductPriceProps) {\n\tconst { salePrice, salePriceCurrency, regularPrice, localizedSalePrice, isDiscounted, accessKind } = cardData;\n\n\tif (accessKind === 'Permanent' || accessKind === 'Temporary') {\n\t\treturn null;\n\t}\n\n\treturn (\n\t\t<PriceLabel\n\t\t\tvariant={isDiscounted ? 'sale' : 'value'}\n\t\t\tlayout=\"vertical\"\n\t\t\tsalePrice={salePrice ?? ''}\n\t\t\tsalePriceCurrency={salePriceCurrency ?? undefined}\n\t\t\tanchorPrice={regularPrice}\n\t\t\tlocalizedSalePrice={localizedSalePrice ?? undefined}\n\t\t\tclassName={cn(className)}\n\t\t/>\n\t);\n}\n\ninterface ProductCtaProps {\n\tcardData: ProductCardData;\n\tbuttonLayoutClassName: string;\n\townershipLabelClassName?: string;\n}\n\nexport function ProductCta({ cardData, buttonLayoutClassName, ownershipLabelClassName }: ProductCtaProps) {\n\tconst resources = useSearchResources();\n\tconst {\n\t\tisPurchasable,\n\t\thasGeoRestriction,\n\t\taccessKind,\n\t\thasPreorder,\n\t\tskuId,\n\t\tisAddingToCart,\n\t\tisPrepubProduct,\n\t\thandleAddToCart,\n\t} = cardData;\n\n\tlet purchaseStatusMessage = getOwnershipLabel(resources, hasGeoRestriction, accessKind, hasPreorder);\n\n\tif (isPurchasable !== undefined && !isPurchasable && !purchaseStatusMessage) {\n\t\tpurchaseStatusMessage = resources['UnavailableToPurchase'];\n\t}\n\n\tif (purchaseStatusMessage) {\n\t\treturn (\n\t\t\t<Typography\n\t\t\t\tvariant=\"bodyRegular\"\n\t\t\t\tclassName={cn('text-primary-500', ownershipLabelClassName ?? cn('text-center', !hasPreorder && 'md:pt-sp16'))}\n\t\t\t>\n\t\t\t\t{purchaseStatusMessage}\n\t\t\t</Typography>\n\t\t);\n\t}\n\n\tif (skuId) {\n\t\treturn (\n\t\t\t<div className={cn('inline-flex gap-2 lg:gap-3', buttonLayoutClassName)}>\n\t\t\t\t<Button\n\t\t\t\t\tdisabled={isAddingToCart}\n\t\t\t\t\tonClick={handleAddToCart}\n\t\t\t\t\tscale={ctaButtonScale}\n\t\t\t\t\ttype=\"button\"\n\t\t\t\t\tvariant=\"primary\"\n\t\t\t\t>\n\t\t\t\t\t{isAddingToCart\n\t\t\t\t\t\t? resources['addingToCart']\n\t\t\t\t\t\t: isPrepubProduct\n\t\t\t\t\t\t\t? resources['preorder']\n\t\t\t\t\t\t\t: resources['addToCart']}\n\t\t\t\t</Button>\n\t\t\t</div>\n\t\t);\n\t}\n\n\treturn (\n\t\t<Skeleton.Root className={cn('animate-pulse inline-flex gap-2 lg:gap-3', buttonLayoutClassName)}>\n\t\t\t<Skeleton.Box className={cn('w-full', skeletonHeightByButtonScale[ctaButtonScale])} />\n\t\t</Skeleton.Root>\n\t);\n}\n","import React from 'react';\nimport { StarRating } from '@faithlife/commerce-components';\n\nimport { ProductHitResult } from '../types';\nimport { useProductInWishList } from '../../add-to-wish-list/hooks';\nimport { AddToWishList } from '../../add-to-wish-list';\nimport EnhancedForLogosWithTooltip from '../../shared/enhanced-for-logos-with-tooltip';\nimport { hasValidReviewData } from '../../shared/ratings/review-data';\nimport { PrepubProductStatusSummary } from '../../product/product-details-page/right-column/prepub-product-status-summary';\nimport { useProductCard } from './use-product-card';\nimport { ProductImage } from './product-image';\nimport { DiscountBadge } from './discount-badge';\nimport { ProductTitle } from './product-title';\nimport { ProductAuthors } from './product-authors';\nimport { ProductPrice, ProductCta } from './product-pricing';\n\ninterface AlgoliaGridCardProps {\n\thit: ProductHitResult;\n\tpriority?: boolean;\n\tqueryId?: string | null;\n\tposition?: number;\n}\n\nexport function AlgoliaGridCard({ hit, priority, queryId = null, position }: AlgoliaGridCardProps) {\n\tconst cardData = useProductCard({ hit, queryId, position });\n\tconst {\n\t\tproductUrl,\n\t\tproductName,\n\t\timageSrc,\n\t\tdiscountPercentage,\n\t\tisDiscounted,\n\t\thandleProductClick,\n\t\tskuId,\n\t\tisLogosEdition,\n\t\tprepubProductStatusSummary,\n\t\tisOwned,\n\t\tisPrepubProduct,\n\t} = cardData;\n\tconst productWishlistData = useProductInWishList(hit.productId, skuId, !isOwned && !isPrepubProduct);\n\tconst averageRating = hit.averageRating ?? 0;\n\tconst reviewCount = hit.reviewCount ?? 0;\n\tconst hasReviewData = hasValidReviewData(averageRating, reviewCount);\n\n\treturn (\n\t\t<div className=\"grid gap-y-0 grid-rows-subgrid row-span-5 grid-cols-1\">\n\t\t\t{/* Row 1: Image — fixed aspect ratio, never grows */}\n\t\t\t<div className=\"relative flex flex-col items-center justify-start gap-sp12 pt-3 lg:pt-4\">\n\t\t\t\t<div className=\"flex h-43.5 w-full items-end justify-center\">\n\t\t\t\t\t<ProductImage\n\t\t\t\t\t\thandleProductClick={handleProductClick}\n\t\t\t\t\t\timageSrc={imageSrc}\n\t\t\t\t\t\tpriority={priority}\n\t\t\t\t\t\tproductName={productName}\n\t\t\t\t\t\tproductUrl={productUrl}\n\t\t\t\t\t/>\n\t\t\t\t</div>\n\n\t\t\t\t<div className=\"h-4 text-center\">{isLogosEdition && <EnhancedForLogosWithTooltip />}</div>\n\t\t\t\t{!isOwned && (\n\t\t\t\t\t<DiscountBadge\n\t\t\t\t\t\tclassName=\"absolute top-2 left-2\"\n\t\t\t\t\t\tdiscountPercentage={discountPercentage}\n\t\t\t\t\t\tisDiscounted={isDiscounted}\n\t\t\t\t\t/>\n\t\t\t\t)}\n\n\t\t\t\t{productWishlistData !== null && <AddToWishList {...productWishlistData} variant=\"icon\" isOwned={isOwned} />}\n\t\t\t</div>\n\n\t\t\t{/* Row 2: Info — grows to absorb variable space */}\n\t\t\t<div className=\"px-2 pt-sp12 pb-1 lg:px-4 lg:pb-2\">\n\t\t\t\t<ProductTitle\n\t\t\t\t\tclassName=\"line-clamp-2\"\n\t\t\t\t\thandleProductClick={handleProductClick}\n\t\t\t\t\tproductName={productName}\n\t\t\t\t\tproductUrl={productUrl}\n\t\t\t\t/>\n\n\t\t\t\t<div className=\"mt-sp8\">\n\t\t\t\t\t<ProductAuthors authors={hit.authors} />\n\t\t\t\t</div>\n\n\t\t\t\t{hasReviewData && (\n\t\t\t\t\t<div className=\"mt-sp8\">\n\t\t\t\t\t\t<StarRating rating={averageRating} reviewCount={reviewCount} />\n\t\t\t\t\t</div>\n\t\t\t\t)}\n\t\t\t</div>\n\n\t\t\t{/* Row 3: Prepub summary — empty when not present */}\n\t\t\t<div className=\"px-2 lg:px-4\">\n\t\t\t\t{prepubProductStatusSummary && (\n\t\t\t\t\t<PrepubProductStatusSummary {...prepubProductStatusSummary} variant=\"search-grid\" />\n\t\t\t\t)}\n\t\t\t</div>\n\n\t\t\t{/* Row 4: Price — always aligned across cards */}\n\t\t\t<div className=\"flex items-end px-2 md:pb-1 lg:px-4\">\n\t\t\t\t<ProductPrice cardData={cardData} />\n\t\t\t</div>\n\n\t\t\t{/* Row 5: CTA — always aligned across cards */}\n\t\t\t<ProductCta buttonLayoutClassName=\"w-full flex-col px-2 pb-2 pt-2 lg:px-4 lg:pb-4\" cardData={cardData} />\n\t\t</div>\n\t);\n}\n","import React, { useEffect, useRef, useState } from 'react';\nimport { LinkButton } from '@faithlife/commerce-components';\n\nimport { cn } from '../../../util/cn';\nimport { useSearchResources } from '../search-resources';\n\ninterface ProductOverviewProps {\n\toverview?: string;\n}\n\nexport function ProductOverview({ overview }: ProductOverviewProps) {\n\tconst [isExpanded, setIsExpanded] = useState(false);\n\tconst [showButton, setShowButton] = useState(false);\n\tconst overviewRef = useRef<HTMLDivElement>(null);\n\tconst resources = useSearchResources();\n\n\tuseEffect(() => {\n\t\tconst element = overviewRef.current;\n\n\t\tif (element) {\n\t\t\ttry {\n\t\t\t\tconst height = element.scrollHeight;\n\t\t\t\tconst computedLineHeight = getComputedStyle(element).lineHeight;\n\t\t\t\tconst parsedLineHeight = parseInt(computedLineHeight, 10);\n\t\t\t\tconst lineHeight = Number.isFinite(parsedLineHeight) && parsedLineHeight > 0 ? parsedLineHeight : 20;\n\t\t\t\tconst maxHeight = lineHeight * 4;\n\t\t\t\tconst maxHeightMobile = lineHeight * 2;\n\n\t\t\t\tif (height > maxHeight || height > maxHeightMobile) {\n\t\t\t\t\tsetShowButton(true);\n\t\t\t\t} else {\n\t\t\t\t\tsetShowButton(false);\n\t\t\t\t}\n\t\t\t} catch {\n\t\t\t\tsetShowButton(false);\n\t\t\t}\n\t\t}\n\t}, [overview]);\n\n\tconst toggleExpand = () => {\n\t\tsetIsExpanded(!isExpanded);\n\t};\n\n\treturn (\n\t\t<>\n\t\t\t<div\n\t\t\t\tclassName={cn(\n\t\t\t\t\t'hidden text-black [&>*:first-child]:mt-0',\n\t\t\t\t\t!isExpanded && 'md:line-clamp-2',\n\t\t\t\t\tisExpanded && 'md:line-clamp-none'\n\t\t\t\t)}\n\t\t\t\tdangerouslySetInnerHTML={{ __html: overview ?? '' }}\n\t\t\t\tref={overviewRef}\n\t\t\t/>\n\t\t\t{showButton && (\n\t\t\t\t<LinkButton\n\t\t\t\t\tas=\"button\"\n\t\t\t\t\tclassName=\"hidden md:inline-flex bodyMd !font-normal\"\n\t\t\t\t\tintent=\"none\"\n\t\t\t\t\tonClick={toggleExpand}\n\t\t\t\t\tscale=\"sm\"\n\t\t\t\t>\n\t\t\t\t\t{isExpanded ? resources['readLess'] : resources['readMore']}\n\t\t\t\t</LinkButton>\n\t\t\t)}\n\t\t</>\n\t);\n}\n","import React from 'react';\nimport { StarRating } from '@faithlife/commerce-components';\n\nimport { ProductHitResult } from '../types';\nimport { AddToWishList } from '../../add-to-wish-list';\nimport { useProductInWishList } from '../../add-to-wish-list/hooks';\nimport EnhancedForLogosWithTooltip from '../../shared/enhanced-for-logos-with-tooltip';\nimport { hasValidReviewData } from '../../shared/ratings/review-data';\nimport { PrepubProductStatusSummary } from '../../product/product-details-page/right-column/prepub-product-status-summary';\nimport { useProductCard } from './use-product-card';\nimport { DiscountBadge } from './discount-badge';\nimport { ProductTitle } from './product-title';\nimport { ProductAuthors } from './product-authors';\nimport { ProductOverview } from './product-overview';\nimport { ProductPricing } from './product-pricing';\nimport { ProductImage } from './product-image';\n\ninterface AlgoliaListCardProps {\n\thit: ProductHitResult;\n\tpriority?: boolean;\n\tqueryId?: string | null;\n\tposition?: number;\n}\n\nexport function AlgoliaListCard({ hit, priority, queryId = null, position }: AlgoliaListCardProps) {\n\tconst cardData = useProductCard({ hit, queryId, position });\n\tconst {\n\t\tproductUrl,\n\t\tproductName,\n\t\timageSrc,\n\t\tdiscountPercentage,\n\t\tisDiscounted,\n\t\thandleProductClick,\n\t\tskuId,\n\t\tisOwned,\n\t\tisLogosEdition,\n\t\tprepubProductStatusSummary,\n\t\tisPrepubProduct,\n\t} = cardData;\n\tconst productWishlistData = useProductInWishList(hit.productId, skuId, !isOwned && !isPrepubProduct);\n\tconst averageRating = hit.averageRating ?? 0;\n\tconst reviewCount = hit.reviewCount ?? 0;\n\tconst hasReviewData = hasValidReviewData(averageRating, reviewCount);\n\n\treturn (\n\t\t<div className=\"grid grid-cols-[139px_auto] md:grid-cols-[190px_auto]\">\n\t\t\t<div className=\"relative col-span-1 flex w-full items-start justify-center\">\n\t\t\t\t<div className=\"flex w-auto flex-col gap-sp8 pt-2 pb-[43px] lg:pt-3 md:pb-9\">\n\t\t\t\t\t<div className=\"relative\">\n\t\t\t\t\t\t<ProductImage\n\t\t\t\t\t\t\thandleProductClick={handleProductClick}\n\t\t\t\t\t\t\timageSrc={imageSrc}\n\t\t\t\t\t\t\tpriority={priority}\n\t\t\t\t\t\t\tproductName={productName}\n\t\t\t\t\t\t\tproductUrl={productUrl}\n\t\t\t\t\t\t/>\n\t\t\t\t\t\t{!isOwned && (\n\t\t\t\t\t\t\t<DiscountBadge\n\t\t\t\t\t\t\t\tclassName=\"absolute top-0 left-1/2 -translate-x-1/2 -translate-y-1/2 pointer-events-none\"\n\t\t\t\t\t\t\t\tdiscountPercentage={discountPercentage}\n\t\t\t\t\t\t\t\tisDiscounted={isDiscounted}\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t)}\n\t\t\t\t\t</div>\n\n\t\t\t\t\t{isLogosEdition && (\n\t\t\t\t\t\t<div className=\"text-center\">\n\t\t\t\t\t\t\t<EnhancedForLogosWithTooltip />\n\t\t\t\t\t\t</div>\n\t\t\t\t\t)}\n\t\t\t\t</div>\n\t\t\t</div>\n\n\t\t\t<div className=\"grid p-2 pb-8 md:grid-cols-[auto_168px] md:gap-8 md:pb-2 lg:p-3\">\n\t\t\t\t<div className=\"flex-1\">\n\t\t\t\t\t<ProductTitle handleProductClick={handleProductClick} productName={productName} productUrl={productUrl} />\n\n\t\t\t\t\t<div className=\"mt-sp8\">\n\t\t\t\t\t\t<ProductAuthors authors={hit.authors} />\n\t\t\t\t\t</div>\n\n\t\t\t\t\t{hasReviewData && (\n\t\t\t\t\t\t<div className=\"mt-sp8\">\n\t\t\t\t\t\t\t<StarRating rating={averageRating} reviewCount={reviewCount} />\n\t\t\t\t\t\t</div>\n\t\t\t\t\t)}\n\t\t\t\t\t<div className=\"mt-sp12\">\n\t\t\t\t\t\t<ProductOverview overview={hit.overview} />\n\t\t\t\t\t</div>\n\t\t\t\t\t{prepubProductStatusSummary && (\n\t\t\t\t\t\t<PrepubProductStatusSummary {...prepubProductStatusSummary} variant=\"search-list\" />\n\t\t\t\t\t)}\n\t\t\t\t</div>\n\n\t\t\t\t<div className=\"flex grow-0 flex-col gap-2 lg:gap-3 items-end\">\n\t\t\t\t\t<ProductPricing\n\t\t\t\t\t\tbuttonLayoutClassName=\"w-full flex-col xmd:flex-row md:flex-col max-w-[145px]\"\n\t\t\t\t\t\tcardData={cardData}\n\t\t\t\t\t/>\n\t\t\t\t\t{productWishlistData !== null && <AddToWishList {...productWishlistData} variant=\"link\" isOwned={isOwned} />}\n\t\t\t\t</div>\n\t\t\t</div>\n\t\t</div>\n\t);\n}\n","import React, { useCallback } from 'react';\nimport { Hit } from 'instantsearch.js';\nimport { Hits, useInstantSearch } from 'react-instantsearch';\n\nimport { cn } from '../../util/cn';\nimport * as Skeleton from '../skeleton';\nimport { WishlistContextProvider } from '../add-to-wish-list/wishlist-context-provider';\nimport { ProductHit, ProductHitResult } from './types';\nimport { AlgoliaGridCard } from './product-card/algolia-grid-card';\nimport { AlgoliaListCard } from './product-card/algolia-list-card';\n\n// ---------------------------------------------------------------------------\n// ProductHits — grid/list of search result cards\n// ---------------------------------------------------------------------------\n\ninterface ProductHitsProps {\n\tlayoutType: 'grid' | 'list';\n\twishListsProductsUrl: string;\n\tcurrentHitsPerPage: number;\n}\n\nfunction SkeletonBlock({ className, rootClassName }: { className: string; rootClassName?: string }) {\n\treturn <Skeleton.Box className={cn(className, rootClassName)} />;\n}\n\nfunction SkeletonButton({ className }: { className: string }) {\n\treturn <Skeleton.Box className={cn('h-12 inline-flex gap-2 lg:gap-3', className)} />;\n}\n\nfunction ProductSkeleton({ layoutType }: { layoutType: 'grid' | 'list' }) {\n\tif (layoutType === 'list') {\n\t\treturn (\n\t\t\t<Skeleton.Root className=\"animate-pulse\">\n\t\t\t\t<div className=\"grid grid-cols-[139px_auto] md:grid-cols-[190px_auto]\">\n\t\t\t\t\t<div className=\"relative col-span-1 flex w-full items-start justify-center\">\n\t\t\t\t\t\t<div className=\"flex w-auto flex-col gap-sp8 pt-2 pb-[43px] lg:pt-3 md:pb-9\">\n\t\t\t\t\t\t\t<div className=\"relative\">\n\t\t\t\t\t\t\t\t<SkeletonBlock className=\"h-[122px] w-[122px] lg:h-[158px] lg:w-[158px]\" />\n\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t\t<div className=\"text-center\">\n\t\t\t\t\t\t\t\t<SkeletonBlock className=\"h-4 w-20\" rootClassName=\"mx-auto h-4 w-20\" />\n\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t</div>\n\t\t\t\t\t</div>\n\t\t\t\t\t<div className=\"grid gap-sp8 p-2 pb-8 md:grid-cols-[auto_168px] md:gap-8 md:pb-2 lg:p-3\">\n\t\t\t\t\t\t<div className=\"flex-1\">\n\t\t\t\t\t\t\t<SkeletonBlock className=\"h-12 w-full\" />\n\t\t\t\t\t\t\t<SkeletonBlock className=\"mt-sp8 h-4 w-3/5\" />\n\t\t\t\t\t\t\t<SkeletonBlock className=\"mt-sp8 h-5 w-2/5\" />\n\t\t\t\t\t\t\t<SkeletonBlock className=\"mt-sp12 h-16 w-full\" />\n\t\t\t\t\t\t</div>\n\t\t\t\t\t\t<div className=\"flex flex-col items-end gap-2 lg:gap-3\">\n\t\t\t\t\t\t\t<div className=\"flex flex-col items-end gap-sp4\">\n\t\t\t\t\t\t\t\t<SkeletonBlock className=\"h-4 w-20\" />\n\t\t\t\t\t\t\t\t<SkeletonBlock className=\"h-7 w-24\" />\n\t\t\t\t\t\t\t\t<SkeletonBlock className=\"h-4 w-16\" />\n\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t\t<SkeletonButton className=\"w-full max-w-[145px]\" />\n\t\t\t\t\t\t\t<SkeletonBlock className=\"h-4 w-24\" />\n\t\t\t\t\t\t</div>\n\t\t\t\t\t</div>\n\t\t\t\t</div>\n\t\t\t</Skeleton.Root>\n\t\t);\n\t}\n\n\treturn (\n\t\t<Skeleton.Root className=\"animate-pulse grid gap-y-0 grid-rows-subgrid row-span-5 grid-cols-1\">\n\t\t\t<div className=\"relative flex flex-col items-center justify-start gap-sp12 pt-3 lg:pt-4\">\n\t\t\t\t<div className=\"flex h-43.5 w-full items-end justify-center\">\n\t\t\t\t\t<SkeletonBlock\n\t\t\t\t\t\tclassName=\"h-[122px] w-[100px] lg:h-[158px] lg:w-[129px]\"\n\t\t\t\t\t\trootClassName=\"h-[122px] w-[100px] lg:h-[158px] lg:w-[129px]\"\n\t\t\t\t\t/>\n\t\t\t\t</div>\n\t\t\t\t<SkeletonBlock className=\"h-4 w-20\" rootClassName=\"mx-auto h-4 w-20\" />\n\t\t\t</div>\n\t\t\t<div className=\"px-2 pt-sp12 pb-1 lg:px-4 lg:pb-2\">\n\t\t\t\t<SkeletonBlock className=\"h-12 w-full\" />\n\t\t\t\t<SkeletonBlock className=\"mt-sp8 h-4 w-3/5\" />\n\t\t\t\t<SkeletonBlock className=\"mt-sp8 h-5 w-2/5\" />\n\t\t\t</div>\n\t\t\t<div className=\"px-2 lg:px-4\" />\n\t\t\t<div className=\"flex items-end px-2 md:pb-1 lg:px-4\">\n\t\t\t\t<div className=\"flex w-full flex-col gap-sp4\">\n\t\t\t\t\t<SkeletonBlock className=\"h-4 w-3/5\" rootClassName=\"h-4 w-3/5\" />\n\t\t\t\t\t<SkeletonBlock className=\"h-7 w-4/5\" rootClassName=\"h-7 w-4/5\" />\n\t\t\t\t\t<SkeletonBlock className=\"h-4 w-2/5\" rootClassName=\"h-4 w-2/5\" />\n\t\t\t\t</div>\n\t\t\t</div>\n\t\t\t<div className=\"flex items-end justify-center px-2 pb-2 pt-2 lg:px-4 lg:pb-4\">\n\t\t\t\t<SkeletonButton className=\"w-full\" />\n\t\t\t</div>\n\t\t</Skeleton.Root>\n\t);\n}\n\nfunction ProductSkeletons({\n\tlayoutType,\n\tcurrentHitsPerPage,\n}: {\n\tlayoutType: 'grid' | 'list';\n\tcurrentHitsPerPage: number;\n}) {\n\treturn (\n\t\t<ol\n\t\t\taria-label=\"Loading search results\"\n\t\t\tclassName={cn(\n\t\t\t\t'grid grid-cols-1',\n\t\t\t\tlayoutType === 'grid' &&\n\t\t\t\t\t'auto-rows-[max-content_auto_max-content_max-content_max-content] grid-cols-2 gap-sp8 lg:grid-cols-3 lg:gap-sp16',\n\t\t\t\tlayoutType === 'list' && 'gap-6 md:gap-8'\n\t\t\t)}\n\t\t>\n\t\t\t{Array.from({ length: currentHitsPerPage }, (_, index) => (\n\t\t\t\t<li\n\t\t\t\t\taria-hidden=\"true\"\n\t\t\t\t\tclassName={cn(\n\t\t\t\t\t\tlayoutType === 'grid' &&\n\t\t\t\t\t\t\t'grid gap-y-0 grid-rows-subgrid row-span-5 grid-cols-1 outline outline-1 outline-grey',\n\t\t\t\t\t\tlayoutType === 'list' && 'first:border-t border-b border-grey-200 first:pt-6 first:md:pt-8'\n\t\t\t\t\t)}\n\t\t\t\t\tkey={index}\n\t\t\t\t>\n\t\t\t\t\t<ProductSkeleton layoutType={layoutType} />\n\t\t\t\t</li>\n\t\t\t))}\n\t\t</ol>\n\t);\n}\n\nfunction toProductHitResult(hit: Hit<ProductHit>): ProductHitResult {\n\treturn {\n\t\t...hit,\n\t\tproductId: hit.productId !== null && hit.productId !== undefined ? hit.productId.toString() : undefined,\n\t};\n}\n\nexport function ProductHits({ layoutType, wishListsProductsUrl, currentHitsPerPage }: ProductHitsProps) {\n\tconst { status } = useInstantSearch();\n\tconst HitComponent = useCallback(\n\t\t({ hit }: { hit: Hit<ProductHit> }) => {\n\t\t\tconst cardProps = {\n\t\t\t\thit: toProductHitResult(hit),\n\t\t\t\t// eslint-disable-next-line no-underscore-dangle\n\t\t\t\tpriority: typeof hit.__position === 'number' && hit.__position <= 6,\n\t\t\t\t// eslint-disable-next-line no-underscore-dangle\n\t\t\t\tqueryId: (hit as any).__queryID ?? null,\n\t\t\t\t// eslint-disable-next-line no-underscore-dangle\n\t\t\t\tposition: hit.__position,\n\t\t\t};\n\t\t\treturn layoutType === 'list' ? <AlgoliaListCard {...cardProps} /> : <AlgoliaGridCard {...cardProps} />;\n\t\t},\n\t\t[layoutType]\n\t);\n\n\treturn (\n\t\t<WishlistContextProvider wishListsProductsUrl={wishListsProductsUrl}>\n\t\t\t<section aria-label=\"Search results\">\n\t\t\t\t{status === 'stalled' && (\n\t\t\t\t\t<div className=\"pt-4 pb-6 lg:px-4 lg:py-8\">\n\t\t\t\t\t\t<ProductSkeletons layoutType={layoutType} currentHitsPerPage={currentHitsPerPage} />\n\t\t\t\t\t</div>\n\t\t\t\t)}\n\t\t\t\t<Hits\n\t\t\t\t\tclassNames={{\n\t\t\t\t\t\troot: cn('pt-4 pb-6 lg:px-4 lg:py-8', status === 'stalled' && 'hidden'),\n\t\t\t\t\t\tlist: cn(\n\t\t\t\t\t\t\t'grid grid-cols-1',\n\t\t\t\t\t\t\tlayoutType === 'grid' &&\n\t\t\t\t\t\t\t\t'auto-rows-[max-content_auto_max-content_max-content_max-content] grid-cols-2 gap-sp8 lg:grid-cols-3 lg:gap-sp16',\n\t\t\t\t\t\t\tlayoutType === 'list' && 'gap-6 md:gap-8'\n\t\t\t\t\t\t),\n\t\t\t\t\t\titem: cn(\n\t\t\t\t\t\t\t/* the grid definition must match AlgoliaGridCard to pass subgrid tracks to it correctly */\n\t\t\t\t\t\t\tlayoutType === 'grid' &&\n\t\t\t\t\t\t\t\t'grid gap-y-0 grid-rows-subgrid row-span-5 grid-cols-1 outline outline-1 outline-grey',\n\t\t\t\t\t\t\t/* first:pt matches the gap-6/md:gap-8 list gutter so item 1's top spacing matches the gap preceding every other item */\n\t\t\t\t\t\t\tlayoutType === 'list' && 'first:border-t border-b border-grey-200 first:pt-6 first:md:pt-8'\n\t\t\t\t\t\t),\n\t\t\t\t\t}}\n\t\t\t\t\thitComponent={HitComponent}\n\t\t\t\t/>\n\t\t\t</section>\n\t\t</WishlistContextProvider>\n\t);\n}\n\nexport default ProductHits;\n","import React from 'react';\nimport { Typography } from '@faithlife/commerce-components';\n\nimport { cn } from '../../util/cn';\nimport { Accordion, AccordionContent, AccordionItem, AccordionTrigger } from '../accordion';\n\nexport interface RadioAccordionItem<TValue extends string | number> {\n\tchecked: boolean;\n\tlabel: string;\n\tvalue: TValue;\n}\n\ninterface RadioAccordionProps<TValue extends string | number> {\n\tradioGroupName: string;\n\titems: RadioAccordionItem<TValue>[];\n\tonSelect: (value: TValue) => void;\n\tprefixLabel: string;\n}\n\nexport default function RadioAccordion<TValue extends string | number>({\n\tradioGroupName,\n\titems,\n\tonSelect,\n\tprefixLabel,\n}: RadioAccordionProps<TValue>) {\n\tconst currentItem = items.find(item => item.checked);\n\n\treturn (\n\t\t<Accordion collapsible type=\"single\">\n\t\t\t<AccordionItem value={radioGroupName}>\n\t\t\t\t<AccordionTrigger className=\"border-t border-primary-100 p-4 lg:border-t-0 [&>svg]:text-primary\">\n\t\t\t\t\t<Typography className=\"text-primary-400\" variant=\"bodyRegular\">\n\t\t\t\t\t\t{prefixLabel} {}\n\t\t\t\t\t\t{currentItem && <span className=\"font-semibold\">{currentItem.label}</span>}\n\t\t\t\t\t</Typography>\n\t\t\t\t</AccordionTrigger>\n\t\t\t\t<AccordionContent className=\"m-0 bg-grey-200 p-4\">\n\t\t\t\t\t<div className=\"flex flex-col gap-y-4\">\n\t\t\t\t\t\t{items.map(item => (\n\t\t\t\t\t\t\t<label className=\"bodySm flex cursor-pointer items-center text-black-200\" key={item.value}>\n\t\t\t\t\t\t\t\t<input\n\t\t\t\t\t\t\t\t\tchecked={item.checked}\n\t\t\t\t\t\t\t\t\tname={radioGroupName}\n\t\t\t\t\t\t\t\t\tclassName=\"mr-3 h-3.25 w-3.25 border-grey-100 text-primary\"\n\t\t\t\t\t\t\t\t\tonChange={() => onSelect(item.value)}\n\t\t\t\t\t\t\t\t\ttype=\"radio\"\n\t\t\t\t\t\t\t\t\tvalue={item.value}\n\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t\t<span className={cn(item.checked ? 'text-primary' : 'text-black-200 hover:text-secondary-200')}>\n\t\t\t\t\t\t\t\t\t{item.label}\n\t\t\t\t\t\t\t\t</span>\n\t\t\t\t\t\t\t</label>\n\t\t\t\t\t\t))}\n\t\t\t\t\t</div>\n\t\t\t\t</AccordionContent>\n\t\t\t</AccordionItem>\n\t\t</Accordion>\n\t);\n}\n","import React from 'react';\nimport { useSortBy } from 'react-instantsearch';\n\nimport { useSearchResources } from './search-resources';\nimport RadioAccordion from './radio-accordion';\n\ninterface SortByItem {\n\tlabel: string;\n\tvalue: string;\n}\n\ninterface SortByAccordionProps {\n\titems: SortByItem[];\n}\n\nexport default function SortByAccordion({ items }: SortByAccordionProps) {\n\tconst resources = useSearchResources();\n\tconst { currentRefinement, refine } = useSortBy({ items });\n\n\treturn (\n\t\t<RadioAccordion\n\t\t\tradioGroupName=\"sort-by\"\n\t\t\titems={items.map(item => ({ ...item, checked: item.value === currentRefinement }))}\n\t\t\tonSelect={refine}\n\t\t\tprefixLabel={resources['sortBy']}\n\t\t/>\n\t);\n}\n","import React from 'react';\nimport { useHitsPerPage } from 'react-instantsearch';\n\nimport { useSearchResources } from './search-resources';\nimport RadioAccordion from './radio-accordion';\n\ninterface HitsPerPageItem {\n\tdefault?: boolean;\n\tlabel: string;\n\tvalue: number;\n}\n\ninterface HitsPerPageAccordionProps {\n\titems: HitsPerPageItem[];\n}\n\nexport default function HitsPerPageAccordion({ items }: HitsPerPageAccordionProps) {\n\tconst resources = useSearchResources();\n\tconst { items: showItems, refine } = useHitsPerPage({ items });\n\n\treturn (\n\t\t<RadioAccordion\n\t\t\tradioGroupName=\"hits-per-page\"\n\t\t\titems={showItems.map(item => ({ ...item, checked: item.isRefined }))}\n\t\t\tonSelect={refine}\n\t\t\tprefixLabel={resources['show']}\n\t\t/>\n\t);\n}\n","import React, { createContext, useContext, useEffect, useState } from 'react';\nimport Cookies from 'js-cookie';\nimport { safeUrl } from './util';\n\nexport enum ViewMode {\n\tgrid = 'grid',\n\tlist = 'list',\n}\n\ninterface ViewModeContextType {\n\tviewMode: ViewMode;\n\tsetViewMode: (mode: ViewMode) => void;\n}\n\nconst ViewModeContext = createContext<ViewModeContextType | null>(null);\n\nexport const viewModeKey = 'viewMode';\n\nexport const ViewModeProvider = ({\n\tchildren,\n\tinitialViewMode,\n}: {\n\tchildren: React.ReactNode;\n\tinitialViewMode: ViewMode;\n}) => {\n\tconst [viewMode, setViewMode] = useState(initialViewMode);\n\n\tuseEffect(() => {\n\t\tconst url = typeof window !== 'undefined' ? safeUrl(window.location.href) : null;\n\t\tif (url) {\n\t\t\turl?.searchParams.set(viewModeKey, viewMode);\n\t\t\twindow.history.replaceState({}, '', url);\n\t\t}\n\t\tCookies.set(viewModeKey, viewMode);\n\t}, [viewMode]);\n\n\treturn <ViewModeContext.Provider value={{ viewMode, setViewMode }}>{children}</ViewModeContext.Provider>;\n};\n\nexport const useViewMode = () => {\n\tconst context = useContext(ViewModeContext);\n\n\tif (!context) {\n\t\tthrow new Error('useViewMode must be used within ViewModeProvider');\n\t}\n\n\treturn context;\n};\n","import { StateMapping, UiState } from 'instantsearch.js';\nimport history from 'instantsearch.js/es/lib/routers/history';\n\nimport { SearchCategory, SearchSortOrder } from './types';\nimport { UserSearchFilter } from './user-search-filter-context';\nimport { safeUrl } from './util';\nimport { viewModeKey } from './use-view-mode';\n\n// ---------------------------------------------------------------------------\n// Facet configuration\n// ---------------------------------------------------------------------------\n\nexport interface SimpleFacetConfiguration {\n\ttype: 'simple';\n\talgoliaAttribute: string;\n\trouteKey: string;\n\tisHidden?: boolean;\n}\n\nexport interface HierarchicalFacetConfiguration {\n\ttype: 'hierarchical';\n\talgoliaAttributeBase: string;\n\trouteKeyPrefix: string;\n\tminLevel: number;\n\tmaxLevel: number;\n\tcategoryToken?: string;\n\tisHidden?: boolean;\n}\n\nexport type FacetConfiguration = SimpleFacetConfiguration | HierarchicalFacetConfiguration;\n\n// ---------------------------------------------------------------------------\n// Route state types and helpers\n// ---------------------------------------------------------------------------\n\ntype RouteStateFacets = Record<string, string[]>;\ntype RouteStateFilters = Record<string, string>;\n\nfunction getAllFacetingKeys(facetConfigurations: FacetConfiguration[]): string[] {\n\treturn [\n\t\t...facetConfigurations\n\t\t\t.filter((config): config is SimpleFacetConfiguration => config.type === 'simple')\n\t\t\t.map(config => config.routeKey),\n\t\t...facetConfigurations\n\t\t\t.filter((config): config is HierarchicalFacetConfiguration => config.type === 'hierarchical')\n\t\t\t.flatMap(config => {\n\t\t\t\tconst keys: string[] = [];\n\n\t\t\t\tfor (let level = config.minLevel; level <= config.maxLevel; level += 1) {\n\t\t\t\t\tkeys.push(`${config.routeKeyPrefix}${level}`);\n\t\t\t\t}\n\n\t\t\t\treturn keys;\n\t\t\t}),\n\t];\n}\n\nexport interface RouteState {\n\tquery?: string;\n\n\tfacets?: RouteStateFacets;\n\tfilters?: RouteStateFilters;\n\n\tsortBy?: string;\n\tlimit?: number;\n\tpage?: number;\n}\n\nconst delimiter = '+';\n\nfunction arrayToQueryParam(array: string[] | undefined): string | undefined {\n\treturn array?.length ? array.join(delimiter) : undefined;\n}\n\nfunction emptyIfUndefined<T>(array: T[] | undefined): T[] {\n\treturn array && array.length > 0 ? array : [];\n}\n\nfunction getTrimmedOrUndefinedIfStringEmpty(value: string): string | undefined {\n\tconst trimmed = value.trim();\n\n\treturn trimmed.length > 0 ? trimmed : undefined;\n}\n\ninterface CategoryPageFacetConfiguration {\n\tqueryParamName: string;\n\tvalue: string;\n}\n\ninterface CategoryPageConfiguration {\n\tfacets: CategoryPageFacetConfiguration[];\n\tcategoryPageUrl: string;\n\tpageTitle: string;\n}\n\nfunction getMatchingCategoryPageFromRouteState(\n\trouteState: RouteState,\n\tcategoryPageConfigurations: CategoryPageConfiguration[],\n\tallFacetingKeys: string[]\n): CategoryPageConfiguration | null {\n\tconst facetKeys = new Set([...allFacetingKeys, ...Object.keys(routeState.facets ?? {})]);\n\tconst facets = [...facetKeys].map(key => ({\n\t\tkey,\n\t\tvalue: routeState.facets?.[key],\n\t}));\n\n\tfor (const categoryPageConfiguration of categoryPageConfigurations) {\n\t\tconst matches = checkCategoryPageConfigurationMatches(categoryPageConfiguration, facets);\n\n\t\tif (matches) {\n\t\t\treturn categoryPageConfiguration;\n\t\t}\n\t}\n\n\treturn null;\n}\n\nfunction preserveCustomQueryParams(sourceUrl: URL, targetUrl: URL, preserveKeys: Set<string>) {\n\tfor (const [key, value] of sourceUrl.searchParams.entries()) {\n\t\tif (preserveKeys.has(key)) {\n\t\t\ttargetUrl.searchParams.set(key, value);\n\t\t}\n\t}\n}\n\nfunction preserveNonSearchQueryParams(sourceUrl: URL, targetUrl: URL, searchParamKeys: Set<string>) {\n\tfor (const [key, value] of sourceUrl.searchParams.entries()) {\n\t\tif (!searchParamKeys.has(key)) {\n\t\t\ttargetUrl.searchParams.set(key, value);\n\t\t}\n\t}\n}\n\nfunction writeFacetsSearchParams(url: URL, facets?: RouteStateFacets, excludedKeys?: Set<string>) {\n\tif (!facets) {\n\t\treturn;\n\t}\n\n\tfor (const [key, value] of Object.entries(facets)) {\n\t\tif (excludedKeys?.has(key)) {\n\t\t\tcontinue;\n\t\t}\n\n\t\tconst candidateQueryParamValue = arrayToQueryParam(value);\n\n\t\tif (candidateQueryParamValue !== undefined) {\n\t\t\turl.searchParams.set(key, candidateQueryParamValue);\n\t\t}\n\t}\n}\n\nfunction writeUserFilterSearchParams(targetUrl: URL, userSearchFilters: UserSearchFilter[], sourceUrl: URL) {\n\tfor (const filter of userSearchFilters) {\n\t\tconst value = sourceUrl.searchParams.get(filter.token);\n\n\t\tif (value) {\n\t\t\ttargetUrl.searchParams.set(filter.token, value);\n\t\t}\n\t}\n}\n\n// ---------------------------------------------------------------------------\n// State mapping — Algolia UI state ↔ route state\n// ---------------------------------------------------------------------------\n\nexport function makeStateMapping(\n\tindex: string,\n\tfacetConfigurations: FacetConfiguration[],\n\tsortOrders: SearchSortOrder[]\n): StateMapping<UiState, RouteState> {\n\treturn {\n\t\tstateToRoute: (uiState: UiState) => {\n\t\t\tconst indexUiState = uiState[index];\n\n\t\t\tif (!indexUiState) {\n\t\t\t\treturn {};\n\t\t\t}\n\n\t\t\tconst facets: RouteStateFacets = {};\n\n\t\t\tfor (const config of facetConfigurations) {\n\t\t\t\tif (config.type === 'simple') {\n\t\t\t\t\tconst facetValues = indexUiState.refinementList?.[config.algoliaAttribute];\n\n\t\t\t\t\tif (facetValues) {\n\t\t\t\t\t\tfacets[config.routeKey] = facetValues;\n\t\t\t\t\t}\n\t\t\t\t} else if (config.type === 'hierarchical') {\n\t\t\t\t\tfor (let level = config.minLevel; level <= config.maxLevel; level += 1) {\n\t\t\t\t\t\tconst routeKey = `${config.routeKeyPrefix}${level}`;\n\t\t\t\t\t\tconst algoliaAttribute = `${config.algoliaAttributeBase}.lvl${level}`;\n\n\t\t\t\t\t\tconst facetValues = indexUiState.refinementList?.[algoliaAttribute];\n\n\t\t\t\t\t\tif (facetValues) {\n\t\t\t\t\t\t\tfacets[routeKey] = facetValues;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tconst sortOrder = sortOrders.find(order => order.value === indexUiState.sortBy);\n\n\t\t\treturn {\n\t\t\t\tquery: indexUiState.query,\n\t\t\t\tfacets,\n\t\t\t\tsortBy: sortOrder?.routeValue ?? undefined,\n\t\t\t\tlimit: indexUiState.hitsPerPage,\n\t\t\t\tpage: indexUiState.page,\n\t\t\t} satisfies RouteState;\n\t\t},\n\t\trouteToState: (routeState: RouteState) => {\n\t\t\tconst refinementList: Record<string, string[]> = {};\n\n\t\t\tfor (const config of facetConfigurations) {\n\t\t\t\tif (config.type === 'simple') {\n\t\t\t\t\trefinementList[config.algoliaAttribute] = emptyIfUndefined(routeState.facets?.[config.routeKey]);\n\t\t\t\t} else if (config.type === 'hierarchical') {\n\t\t\t\t\tfor (let level = config.minLevel; level <= config.maxLevel; level += 1) {\n\t\t\t\t\t\tconst routeKey = `${config.routeKeyPrefix}${level}`;\n\n\t\t\t\t\t\tconst algoliaAttribute = `${config.algoliaAttributeBase}.lvl${level}`;\n\n\t\t\t\t\t\trefinementList[algoliaAttribute] = emptyIfUndefined(routeState.facets?.[routeKey]);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tconst sortBy = routeState.sortBy\n\t\t\t\t? sortOrders.find(order => order.routeValue === routeState.sortBy)?.value\n\t\t\t\t: undefined;\n\n\t\t\treturn {\n\t\t\t\t[index]: {\n\t\t\t\t\tquery: routeState.query,\n\t\t\t\t\tsortBy,\n\t\t\t\t\thitsPerPage: routeState.limit,\n\t\t\t\t\trefinementList,\n\t\t\t\t\tpage: routeState.page,\n\t\t\t\t},\n\t\t\t};\n\t\t},\n\t};\n}\n\n// ---------------------------------------------------------------------------\n// Category page configuration\n// ---------------------------------------------------------------------------\n\nfunction checkFacetValueConfigurationMatches(\n\tfacetValueConfiguration: string,\n\trouteStateFacetValue: string[] | undefined\n): boolean {\n\tif (routeStateFacetValue === undefined) {\n\t\treturn false;\n\t}\n\n\tif (routeStateFacetValue.length !== 1) {\n\t\treturn false;\n\t}\n\n\treturn facetValueConfiguration === routeStateFacetValue[0];\n}\n\nfunction checkCategoryPageConfigurationMatches(\n\tcategoryPageConfiguration: CategoryPageConfiguration,\n\trouteStateFacets: {\n\t\tkey: string;\n\t\tvalue: string[] | undefined;\n\t}[]\n): boolean {\n\tconst { facets: facetsConfiguration } = categoryPageConfiguration;\n\n\tlet matches = true;\n\n\tfor (const routeStateFacet of routeStateFacets) {\n\t\tconst facetConfiguration = facetsConfiguration.find(f => f.queryParamName === routeStateFacet.key);\n\n\t\tif (facetConfiguration) {\n\t\t\tif (!checkFacetValueConfigurationMatches(facetConfiguration.value, routeStateFacet.value)) {\n\t\t\t\tmatches = false;\n\t\t\t\tbreak;\n\t\t\t}\n\t\t} else if (routeStateFacet.value !== undefined && routeStateFacet.value.length > 0) {\n\t\t\tmatches = false;\n\t\t\tbreak;\n\t\t}\n\t}\n\n\treturn matches;\n}\n\nfunction writeCommonSearchParams(url: URL, routeState: RouteState) {\n\tif (routeState.query) {\n\t\turl.searchParams.set('query', routeState.query);\n\t}\n\n\tif (routeState.sortBy) {\n\t\turl.searchParams.set('sortBy', routeState.sortBy);\n\t}\n\n\tif (routeState.limit !== undefined) {\n\t\turl.searchParams.set('limit', String(routeState.limit));\n\t}\n\n\tif (routeState.page !== undefined) {\n\t\turl.searchParams.set('page', String(routeState.page));\n\t}\n}\n\nexport function getCanonicalSearchUrl({\n\trouteState,\n\tcanonicalOrigin,\n\tcategoryPageConfigurations,\n\tfacetConfigurations,\n\tindexName,\n\tpageLimits,\n\tsortOrders,\n}: {\n\trouteState: RouteState;\n\tcanonicalOrigin: string;\n\tcategoryPageConfigurations: CategoryPageConfiguration[];\n\tfacetConfigurations: FacetConfiguration[];\n\tindexName: string;\n\tpageLimits: number[];\n\tsortOrders: SearchSortOrder[];\n}): string {\n\tconst canonicalUrl = new URL('/search', canonicalOrigin);\n\tconst allFacetingKeys = getAllFacetingKeys(facetConfigurations);\n\tconst matchingCategoryPage = getMatchingCategoryPageFromRouteState(\n\t\trouteState,\n\t\tcategoryPageConfigurations,\n\t\tallFacetingKeys\n\t);\n\n\tif (matchingCategoryPage) {\n\t\tconst categoryUrl = safeUrl(matchingCategoryPage.categoryPageUrl, canonicalOrigin);\n\t\tif (categoryUrl) {\n\t\t\tcanonicalUrl.pathname = categoryUrl.pathname;\n\t\t}\n\t}\n\n\tconst sortOrder = sortOrders.find(order => order.routeValue === routeState.sortBy);\n\twriteCommonSearchParams(canonicalUrl, {\n\t\tquery: routeState.query,\n\t\tsortBy: sortOrder?.routeValue && sortOrder.value !== indexName ? sortOrder.routeValue : undefined,\n\t\tlimit: routeState.limit !== pageLimits[0] ? routeState.limit : undefined,\n\t\tpage: routeState.page !== undefined && routeState.page > 1 ? routeState.page : undefined,\n\t});\n\n\tconst facets = Object.fromEntries(\n\t\t[...new Set(allFacetingKeys)].sort().map(key => [key, [...new Set(routeState.facets?.[key] ?? [])].sort()])\n\t);\n\tconst categoryFacetKeys = new Set(matchingCategoryPage?.facets.map(facet => facet.queryParamName) ?? []);\n\twriteFacetsSearchParams(canonicalUrl, facets, categoryFacetKeys);\n\n\treturn canonicalUrl.href;\n}\n\n// ---------------------------------------------------------------------------\n// Router — URL creation and parsing\n// ---------------------------------------------------------------------------\n\nexport function makeRouter(\n\tcategoryPageConfigurations: CategoryPageConfiguration[],\n\tfacetConfigurations: FacetConfiguration[],\n\tuserSearchFilters: UserSearchFilter[] = [],\n\tinitialUrl?: string\n) {\n\tconst allFacetingKeys = getAllFacetingKeys(facetConfigurations);\n\tconst allFacetingKeysSet = new Set<string>(allFacetingKeys);\n\tconst userFilterKeysSet = new Set<string>(userSearchFilters.map(f => f.token));\n\tconst preserveCustomKeysSet = new Set<string>([viewModeKey, 'ownership', 'geographicAvailability']);\n\tconst searchParamKeysSet = new Set<string>([\n\t\t'query',\n\t\t'sortBy',\n\t\t'limit',\n\t\t'page',\n\t\t...allFacetingKeys,\n\t\t...userFilterKeysSet,\n\t\t...preserveCustomKeysSet,\n\t]);\n\tconst categoryPagesByCategoryPageUrl: Map<string, CategoryPageConfiguration> = new Map<\n\t\tstring,\n\t\tCategoryPageConfiguration\n\t>();\n\n\tfor (const configuration of categoryPageConfigurations) {\n\t\tcategoryPagesByCategoryPageUrl.set(configuration.categoryPageUrl, configuration);\n\t}\n\n\treturn history<RouteState>({\n\t\tgetLocation: () => {\n\t\t\tif (typeof window !== 'undefined') {\n\t\t\t\treturn window.location;\n\t\t\t}\n\n\t\t\tconst location = safeUrl(initialUrl ?? '');\n\t\t\tif (!location) {\n\t\t\t\tthrow new Error('A valid initial URL is required to render search server-side.');\n\t\t\t}\n\n\t\t\treturn {\n\t\t\t\tancestorOrigins: {\n\t\t\t\t\tcontains: () => false,\n\t\t\t\t\titem: () => null,\n\t\t\t\t\tlength: 0,\n\t\t\t\t\t[Symbol.iterator]: function (): IterableIterator<string> {\n\t\t\t\t\t\treturn [][Symbol.iterator]();\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t\tassign: () => {\n\t\t\t\t\tthrow new Error('Search routing cannot navigate while rendering server-side.');\n\t\t\t\t},\n\t\t\t\thash: location.hash,\n\t\t\t\thost: location.host,\n\t\t\t\thostname: location.hostname,\n\t\t\t\thref: location.href,\n\t\t\t\torigin: location.origin,\n\t\t\t\tpathname: location.pathname,\n\t\t\t\tport: location.port,\n\t\t\t\tprotocol: location.protocol,\n\t\t\t\treload: () => {\n\t\t\t\t\tthrow new Error('Search routing cannot reload while rendering server-side.');\n\t\t\t\t},\n\t\t\t\treplace: () => {\n\t\t\t\t\tthrow new Error('Search routing cannot navigate while rendering server-side.');\n\t\t\t\t},\n\t\t\t\tsearch: location.search,\n\t\t\t\ttoString: () => location.toString(),\n\t\t\t};\n\t\t},\n\t\tcleanUrlOnDispose: false,\n\t\tcreateURL({ location, routeState }: { location: { href: string }; routeState: RouteState }) {\n\t\t\ttry {\n\t\t\t\t// detect if we match a category page\n\t\t\t\tconst matchingCategoryPage = getMatchingCategoryPageFromRouteState(\n\t\t\t\t\trouteState,\n\t\t\t\t\tcategoryPageConfigurations,\n\t\t\t\t\tallFacetingKeys\n\t\t\t\t);\n\n\t\t\t\tconst currentUrl = safeUrl(location.href);\n\t\t\t\tif (!currentUrl) {\n\t\t\t\t\treturn location.href;\n\t\t\t\t}\n\n\t\t\t\tif (matchingCategoryPage) {\n\t\t\t\t\tconst categoryPageUrl = safeUrl(matchingCategoryPage.categoryPageUrl, location.href);\n\t\t\t\t\tif (categoryPageUrl) {\n\t\t\t\t\t\twriteCommonSearchParams(categoryPageUrl, routeState);\n\t\t\t\t\t\tconst categoryFacetKeys = new Set(\n\t\t\t\t\t\t\tmatchingCategoryPage.facets.map(facetConfiguration => facetConfiguration.queryParamName)\n\t\t\t\t\t\t);\n\t\t\t\t\t\twriteFacetsSearchParams(categoryPageUrl, routeState.facets, categoryFacetKeys);\n\t\t\t\t\t\twriteUserFilterSearchParams(categoryPageUrl, userSearchFilters, currentUrl);\n\t\t\t\t\t\tpreserveCustomQueryParams(currentUrl, categoryPageUrl, preserveCustomKeysSet);\n\t\t\t\t\t\tpreserveNonSearchQueryParams(currentUrl, categoryPageUrl, searchParamKeysSet);\n\n\t\t\t\t\t\treturn categoryPageUrl.href;\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tconst url = safeUrl('/search', location.href);\n\t\t\t\tif (!url) {\n\t\t\t\t\treturn location.href;\n\t\t\t\t}\n\n\t\t\t\twriteCommonSearchParams(url, routeState);\n\t\t\t\twriteFacetsSearchParams(url, routeState.facets);\n\t\t\t\twriteUserFilterSearchParams(url, userSearchFilters, currentUrl);\n\t\t\t\tpreserveCustomQueryParams(currentUrl, url, preserveCustomKeysSet);\n\t\t\t\tpreserveNonSearchQueryParams(currentUrl, url, searchParamKeysSet);\n\n\t\t\t\treturn url.href;\n\t\t\t} catch (err) {\n\t\t\t\t// eslint-disable-next-line no-console\n\t\t\t\tconsole.error('[search] router.createURL failed', err);\n\t\t\t\treturn location.href;\n\t\t\t}\n\t\t},\n\n\t\tparseURL({ location }: { location: { href: string } }) {\n\t\t\ttry {\n\t\t\t\tconst locationUrl = safeUrl(location.href);\n\t\t\t\tif (!locationUrl) {\n\t\t\t\t\treturn {};\n\t\t\t\t}\n\t\t\t\tconst locationPathname = locationUrl.pathname;\n\n\t\t\t\tconst matchingCategoryPage = categoryPagesByCategoryPageUrl.get(locationPathname);\n\n\t\t\t\tconst routeState: RouteState = {};\n\n\t\t\t\tconst addRouteStateFacetValues = (key: string, values: string[]) => {\n\t\t\t\t\tif (values.length === 0) {\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\n\t\t\t\t\trouteState.facets ??= {};\n\t\t\t\t\trouteState.facets[key] ??= [];\n\n\t\t\t\t\tfor (const value of values) {\n\t\t\t\t\t\trouteState.facets[key].push(value);\n\t\t\t\t\t}\n\t\t\t\t};\n\n\t\t\t\tif (matchingCategoryPage) {\n\t\t\t\t\tfor (const facetConfiguration of matchingCategoryPage.facets) {\n\t\t\t\t\t\taddRouteStateFacetValues(facetConfiguration.queryParamName, [facetConfiguration.value]);\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tconst queryParams = locationUrl.searchParams;\n\n\t\t\t\tfor (const [paramName, paramValue] of queryParams.entries()) {\n\t\t\t\t\tif (allFacetingKeysSet.has(paramName)) {\n\t\t\t\t\t\tif (matchingCategoryPage?.facets.some(facet => facet.queryParamName === paramName)) {\n\t\t\t\t\t\t\tcontinue;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\taddRouteStateFacetValues(\n\t\t\t\t\t\t\tparamName,\n\t\t\t\t\t\t\tparamValue\n\t\t\t\t\t\t\t\t.split(delimiter)\n\t\t\t\t\t\t\t\t.map(v => getTrimmedOrUndefinedIfStringEmpty(v))\n\t\t\t\t\t\t\t\t.filter((v): v is string => v !== undefined)\n\t\t\t\t\t\t);\n\t\t\t\t\t} else if (userFilterKeysSet.has(paramName)) {\n\t\t\t\t\t\trouteState.filters ??= {};\n\t\t\t\t\t\trouteState.filters[paramName] = paramValue;\n\t\t\t\t\t} else if (paramName === 'query') {\n\t\t\t\t\t\trouteState.query = getTrimmedOrUndefinedIfStringEmpty(paramValue);\n\t\t\t\t\t} else if (paramName === 'sortBy') {\n\t\t\t\t\t\trouteState.sortBy = paramValue;\n\t\t\t\t\t} else if (paramName === 'limit') {\n\t\t\t\t\t\tconst limit = parseInt(paramValue, 10);\n\n\t\t\t\t\t\tif (Number.isFinite(limit) && limit > 0) {\n\t\t\t\t\t\t\trouteState.limit = limit;\n\t\t\t\t\t\t}\n\t\t\t\t\t} else if (paramName === 'page') {\n\t\t\t\t\t\tconst page = parseInt(paramValue, 10);\n\n\t\t\t\t\t\tif (Number.isFinite(page) && page >= 1) {\n\t\t\t\t\t\t\trouteState.page = page;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\treturn routeState;\n\t\t\t} catch (err) {\n\t\t\t\t// eslint-disable-next-line no-console\n\t\t\t\tconsole.error('[search] router.parseURL failed', err);\n\t\t\t\treturn {};\n\t\t\t}\n\t\t},\n\n\t\twindowTitle(routeState: RouteState) {\n\t\t\ttry {\n\t\t\t\tconst matchingCategoryPage = getMatchingCategoryPageFromRouteState(\n\t\t\t\t\trouteState,\n\t\t\t\t\tcategoryPageConfigurations,\n\t\t\t\t\tallFacetingKeys\n\t\t\t\t);\n\n\t\t\t\tif (matchingCategoryPage) {\n\t\t\t\t\treturn matchingCategoryPage.pageTitle;\n\t\t\t\t}\n\n\t\t\t\treturn 'Search';\n\t\t\t} catch (err) {\n\t\t\t\t// eslint-disable-next-line no-console\n\t\t\t\tconsole.error('[search] router.windowTitle failed', err);\n\t\t\t\treturn 'Search';\n\t\t\t}\n\t\t},\n\t});\n}\n\n// ---------------------------------------------------------------------------\n// Convert search categories to category page configurations\n// ---------------------------------------------------------------------------\n\nexport function convertSearchCategoriesToCategoryPageConfiguration(\n\tcategories: SearchCategory[]\n): CategoryPageConfiguration[] {\n\treturn (categories ?? [])\n\t\t.map(category => {\n\t\t\tif (!category) {\n\t\t\t\treturn null;\n\t\t\t}\n\n\t\t\tconst categoryPageUrl = category.categoryPageUrl;\n\t\t\tif (!categoryPageUrl) {\n\t\t\t\treturn null;\n\t\t\t}\n\n\t\t\tif (!category.facetRouteKey) {\n\t\t\t\treturn null;\n\t\t\t}\n\n\t\t\treturn {\n\t\t\t\tcategoryPageUrl,\n\t\t\t\tfacets: [\n\t\t\t\t\t{\n\t\t\t\t\t\tqueryParamName: category.facetRouteKey,\n\t\t\t\t\t\tvalue: category.displayName,\n\t\t\t\t\t},\n\t\t\t\t],\n\t\t\t\tpageTitle: category.pageTitle,\n\t\t\t} satisfies CategoryPageConfiguration;\n\t\t})\n\t\t.filter((x): x is CategoryPageConfiguration => x !== null);\n}\n","import { useEffect, useState } from 'react';\n\nexport const hydrationSettledAttribute = 'data-hydration-settled';\n\n/**\n * Reports when the calling component has stopped re-rendering after hydration.\n *\n * End-to-end tests need to know that no further widget can mount, because mounting one calls\n * `addWidgets`, which schedules a search once `ResetScheduleSearch` has restored `scheduleSearch`.\n * The timer is re-armed by every render and fires from a macrotask, so once it resolves any search\n * deferred to a microtask has already reached the network layer.\n *\n * The caller must subscribe to InstantSearch renders (via `useInstantSearch`) so that search\n * cycles re-arm the timer too.\n */\nexport default function useHydrationSettled(): boolean {\n\tconst [isSettled, setIsSettled] = useState(false);\n\n\tuseEffect(() => {\n\t\tconst timeoutId = window.setTimeout(() => setIsSettled(true), 0);\n\t\treturn () => window.clearTimeout(timeoutId);\n\t});\n\n\treturn isSettled;\n}\n","import React, { useCallback, useEffect, useMemo, useRef, useState } from 'react';\nimport { CommandSentence } from '@faithlife/command-sentence-control';\nimport { Button, Typography } from '@faithlife/commerce-components';\nimport { ChevronDown } from 'lucide-react';\nimport { UiState } from 'instantsearch.js';\nimport type { InstantSearchServerState } from 'react-instantsearch-core';\nimport {\n\tConfigure,\n\tConfigureProps,\n\tInstantSearch,\n\tInstantSearchProps,\n\tInstantSearchSSRProvider,\n} from 'react-instantsearch';\nimport {\n\tPagination,\n\tuseHitsPerPage,\n\tuseInstantSearch,\n\tuseCurrentRefinements,\n\tusePagination,\n\tuseSearchBox,\n\tuseSortBy,\n} from 'react-instantsearch';\nimport Drawer from '../shared/drawer';\nimport ScrollThresholdBar from '../shared/scroll-threshold-bar';\nimport {\n\tDropdownMenu,\n\tDropdownMenuContent,\n\tDropdownMenuRadioGroup,\n\tDropdownMenuRadioItem,\n\tDropdownMenuTrigger,\n} from '../shared/dropdown-menu';\nimport useScreensize from '../../util/hooks/use-screensize';\n\nimport { cn } from '../../util/cn';\nimport { PerUserDataContextProvider, useCurrentUser } from '../per-user-data/per-user-data-context';\n\nimport { safeJsonParse } from '../../util/safe-json-parse';\nimport { useLocalization } from '../../localization';\nimport { useLocation } from '../../location';\nimport ErrorBoundary from '../error-boundary';\nimport { BooksByAuthor } from '../shared/books-by-author';\nimport { AuthorBatch } from '../../hooks/use-author';\nimport type { AuthorInfo } from '../../hooks/use-author';\nimport { PublisherBatch } from '../../hooks/use-publisher';\nimport type { SectionContentViewModel } from '../../builder';\nimport CategoryContent from './category-content';\nimport {\n\tUserSearchFilter,\n\tUserSearchFilters,\n\tUserSearchFilterProvider,\n\tuseUserSearchFilterContext,\n} from './user-search-filter-context';\nimport { Categories } from './filters';\nimport CurrentQueryRefinement, { CurrentRefinements } from './refinements';\nimport HiddenFacetRefinements from './hidden-facet-refinements';\nimport ProductHits from './products';\nimport SortByAccordion from './sort-by-accordion';\nimport HitsPerPageAccordion from './hits-per-page-accordion';\nimport { SearchCategory, SearchSortOrder } from './types';\nimport {\n\tconvertSearchCategoriesToCategoryPageConfiguration,\n\tgetCanonicalSearchUrl,\n\tmakeRouter,\n\tmakeStateMapping,\n} from './routing';\nimport type { FacetConfiguration, RouteState } from './routing';\nexport { SearchResourcesContext, useSearchResources } from './search-resources';\nimport { SearchResourcesContext, useSearchResources } from './search-resources';\nimport { useSearchImpressions } from './hooks/use-search-impressions';\nimport { useSearchAnalytics } from './hooks/use-search-analytics';\nexport { AlgoliaSearchContextProvider, useAlgoliaSearch } from './algolia-search-context';\nimport { AlgoliaSearchContextProvider, useAlgoliaSearch } from './algolia-search-context';\nimport { useViewMode, ViewMode, ViewModeProvider } from './use-view-mode';\nimport useHydrationSettled, { hydrationSettledAttribute } from './use-hydration-settled';\n\n// ---------------------------------------------------------------------------\n// AlgoliaSSRProvider / AlgoliaProvider — InstantSearch + Configure wrappers\n// ---------------------------------------------------------------------------\n\ntype AlgoliaSearchParameters = Record<string, any>;\n\ntype ConfigurableConfigureProps = Pick<\n\tConfigureProps,\n\t'attributesToHighlight' | 'attributesToRetrieve' | 'queryType' | 'restrictSearchableAttributes'\n> & { searchParameters?: AlgoliaSearchParameters; userSearchFilters?: UserSearchFilter[] };\n\ntype AlgoliaProviderProps<TUiState extends UiState, TRouteState> = Pick<\n\tInstantSearchProps<TUiState, TRouteState>,\n\t'routing' | 'searchClient'\n> &\n\tConfigurableConfigureProps & { initialViewMode: ViewMode };\n\nfunction AlgoliaSSRProvider<TUiState extends UiState = UiState, TRouteState = TUiState>(\n\tprops: React.PropsWithChildren<AlgoliaProviderProps<TUiState, TRouteState>>\n) {\n\treturn <AlgoliaProvider {...props} />;\n}\n\nfunction AlgoliaProvider<TUiState extends UiState = UiState, TRouteState = TUiState>({\n\tattributesToHighlight,\n\tattributesToRetrieve,\n\tqueryType,\n\trestrictSearchableAttributes,\n\trouting,\n\tsearchClient,\n\tsearchParameters,\n\tinitialViewMode,\n\tchildren,\n}: React.PropsWithChildren<AlgoliaProviderProps<TUiState, TRouteState>>) {\n\tconst { indexName } = useAlgoliaSearch();\n\n\treturn (\n\t\t<ViewModeProvider initialViewMode={initialViewMode}>\n\t\t\t<InstantSearch\n\t\t\t\tfuture={{\n\t\t\t\t\tpreserveSharedStateOnUnmount: true,\n\t\t\t\t}}\n\t\t\t\tindexName={indexName}\n\t\t\t\tinsights\n\t\t\t\trouting={routing}\n\t\t\t\tsearchClient={searchClient}\n\t\t\t>\n\t\t\t\t<ConfigureCore\n\t\t\t\t\tattributesToHighlight={attributesToHighlight}\n\t\t\t\t\tattributesToRetrieve={attributesToRetrieve}\n\t\t\t\t\tqueryType={queryType}\n\t\t\t\t\trestrictSearchableAttributes={restrictSearchableAttributes}\n\t\t\t\t\tsearchParameters={searchParameters}\n\t\t\t\t/>\n\t\t\t\t{children}\n\t\t\t</InstantSearch>\n\t\t</ViewModeProvider>\n\t);\n}\n\nconst ParameterBlacklist = new Set(['facets']);\n\nfunction ConfigureCore({\n\tattributesToHighlight,\n\tattributesToRetrieve,\n\tqueryType,\n\trestrictSearchableAttributes,\n\tsearchParameters,\n}: ConfigurableConfigureProps) {\n\tconst { selectedFilterOptions, userSearchFilters } = useUserSearchFilterContext();\n\n\tconst props = useMemo(() => {\n\t\tconst mergedParams = { ...(searchParameters ?? {}) };\n\t\tconst userFilters = Array.isArray(userSearchFilters) ? userSearchFilters : [];\n\n\t\tconst selectedOptions = userFilters\n\t\t\t.map(uf => {\n\t\t\t\tconst selectedOptionToken = selectedFilterOptions[uf.token];\n\t\t\t\tif (!selectedOptionToken) {\n\t\t\t\t\treturn null;\n\t\t\t\t}\n\n\t\t\t\tconst selectedOption = uf.options?.find(o => o.token === selectedOptionToken);\n\t\t\t\tif (!selectedOption?.algoliaValue) {\n\t\t\t\t\treturn null;\n\t\t\t\t}\n\n\t\t\t\treturn selectedOption.algoliaValue;\n\t\t\t})\n\t\t\t.filter((o): o is string => typeof o === 'string' && o.length > 0);\n\n\t\tconst filterParts = [mergedParams.filters, ...selectedOptions].filter(\n\t\t\t(f): f is string => typeof f === 'string' && f.length > 0\n\t\t);\n\t\tif (filterParts.length > 0) {\n\t\t\tmergedParams.filters = filterParts.join(' AND ');\n\t\t} else {\n\t\t\tdelete mergedParams.filters;\n\t\t}\n\n\t\treturn Object.fromEntries(Object.entries(mergedParams).filter(([key]) => !ParameterBlacklist.has(key)));\n\t}, [searchParameters, userSearchFilters, selectedFilterOptions]);\n\n\treturn (\n\t\t<Configure\n\t\t\tattributesToHighlight={attributesToHighlight}\n\t\t\tattributesToRetrieve={attributesToRetrieve}\n\t\t\tdistinct\n\t\t\tqueryType={queryType}\n\t\t\trestrictSearchableAttributes={restrictSearchableAttributes}\n\t\t\tclickAnalytics\n\t\t\t{...props}\n\t\t/>\n\t);\n}\n\n// ---------------------------------------------------------------------------\n// Icons\n// ---------------------------------------------------------------------------\n\n// eslint-disable-next-line @typescript-eslint/no-unused-vars\nfunction CloseIcon({ className, fillColor: _fillColor, ...rest }: any) {\n\treturn (\n\t\t<svg\n\t\t\tclassName={className}\n\t\t\tfill=\"none\"\n\t\t\theight=\"16\"\n\t\t\tviewBox=\"0 0 16 16\"\n\t\t\twidth=\"16\"\n\t\t\txmlns=\"http://www.w3.org/2000/svg\"\n\t\t\t{...rest}\n\t\t>\n\t\t\t<path d=\"M12.5 3.5L3.5 12.5M3.5 3.5l9 9\" stroke=\"currentColor\" strokeLinecap=\"round\" strokeWidth=\"1.5\" />\n\t\t</svg>\n\t);\n}\n\nfunction FilterIcon({ className, ...rest }: any) {\n\treturn (\n\t\t<svg\n\t\t\tclassName={className}\n\t\t\tfill=\"none\"\n\t\t\theight=\"16\"\n\t\t\tviewBox=\"0 0 16 16\"\n\t\t\twidth=\"16\"\n\t\t\txmlns=\"http://www.w3.org/2000/svg\"\n\t\t\t{...rest}\n\t\t>\n\t\t\t<path d=\"M2 4h12M4 8h8M6 12h4\" stroke=\"currentColor\" strokeLinecap=\"round\" strokeWidth=\"1.5\" />\n\t\t</svg>\n\t);\n}\n\nfunction FilterAndSortButton({ onClick, testId = 'filter-and-sort-button' }: { onClick: () => void; testId?: string }) {\n\tconst resources = useSearchResources();\n\n\treturn (\n\t\t<button\n\t\t\tclassName=\"inline-flex cursor-pointer items-center gap-sp8 rounded-[4px] border border-primary-500 px-sp16 py-sp16 text-primary-500 focus:outline-0 focus:ring-0\"\n\t\t\tdata-testid={testId}\n\t\t\tonClick={onClick}\n\t\t\ttype=\"button\"\n\t\t>\n\t\t\t<FilterIcon />\n\t\t\t<Typography className=\"text-primary-500 font-medium leading-[100%]\" variant=\"bodySmall\">\n\t\t\t\t{resources['filterAndSort']}\n\t\t\t</Typography>\n\t\t</button>\n\t);\n}\n\nfunction LayoutGridIcon({ className, ...rest }: any) {\n\treturn (\n\t\t<svg\n\t\t\tclassName={className}\n\t\t\tfill=\"none\"\n\t\t\theight=\"16\"\n\t\t\tviewBox=\"0 0 16 16\"\n\t\t\twidth=\"16\"\n\t\t\txmlns=\"http://www.w3.org/2000/svg\"\n\t\t\t{...rest}\n\t\t>\n\t\t\t<rect height=\"5\" rx=\"1\" stroke=\"currentColor\" width=\"5\" x=\"1.5\" y=\"1.5\" />\n\t\t\t<rect height=\"5\" rx=\"1\" stroke=\"currentColor\" width=\"5\" x=\"9.5\" y=\"1.5\" />\n\t\t\t<rect height=\"5\" rx=\"1\" stroke=\"currentColor\" width=\"5\" x=\"1.5\" y=\"9.5\" />\n\t\t\t<rect height=\"5\" rx=\"1\" stroke=\"currentColor\" width=\"5\" x=\"9.5\" y=\"9.5\" />\n\t\t</svg>\n\t);\n}\n\nfunction LayoutListIcon({ className, ...rest }: any) {\n\treturn (\n\t\t<svg\n\t\t\tclassName={className}\n\t\t\tfill=\"none\"\n\t\t\theight=\"16\"\n\t\t\tviewBox=\"0 0 16 16\"\n\t\t\twidth=\"16\"\n\t\t\txmlns=\"http://www.w3.org/2000/svg\"\n\t\t\t{...rest}\n\t\t>\n\t\t\t<rect height=\"3\" rx=\"1\" stroke=\"currentColor\" width=\"14\" x=\"1\" y=\"1.5\" />\n\t\t\t<rect height=\"3\" rx=\"1\" stroke=\"currentColor\" width=\"14\" x=\"1\" y=\"6.5\" />\n\t\t\t<rect height=\"3\" rx=\"1\" stroke=\"currentColor\" width=\"14\" x=\"1\" y=\"11.5\" />\n\t\t</svg>\n\t);\n}\n\n// ---------------------------------------------------------------------------\n// Layout buttons — grid/list toggle\n// ---------------------------------------------------------------------------\n\nconst LayoutButtonOptions = [\n\t{ label: 'Grid Layout', value: ViewMode.grid, icon: LayoutGridIcon, additionalClassNames: 'lg:p-[6px]' },\n\t{ label: 'List Layout', value: ViewMode.list, icon: LayoutListIcon, additionalClassNames: 'lg:px-[3px] lg:py-[6px]' },\n];\n\nfunction LayoutButtons({\n\tcurrentLayoutType,\n\tsetLayoutType,\n}: {\n\tcurrentLayoutType: ViewMode;\n\tsetLayoutType: (mode: ViewMode) => void;\n}) {\n\treturn (\n\t\t<div className=\"flex gap-[6px]\">\n\t\t\t{LayoutButtonOptions.map(option => {\n\t\t\t\tconst isSelected = currentLayoutType === option.value;\n\t\t\t\tconst IconComponent = option.icon;\n\n\t\t\t\treturn (\n\t\t\t\t\t<button\n\t\t\t\t\t\tkey={option.value}\n\t\t\t\t\t\taria-label={option.label}\n\t\t\t\t\t\taria-pressed={isSelected}\n\t\t\t\t\t\tonClick={() => setLayoutType(option.value)}\n\t\t\t\t\t\tclassName={cn(\n\t\t\t\t\t\t\t'px-sp16 py-sp16',\n\t\t\t\t\t\t\t'inline-flex items-center gap-sp8',\n\t\t\t\t\t\t\t'rounded-[4px] border border-primary-500 lg:border-0',\n\t\t\t\t\t\t\t'cursor-pointer',\n\t\t\t\t\t\t\t'text-black-100 aria-pressed:text-primary-400',\n\t\t\t\t\t\t\toption.additionalClassNames\n\t\t\t\t\t\t)}\n\t\t\t\t\t>\n\t\t\t\t\t\t<IconComponent />\n\t\t\t\t\t</button>\n\t\t\t\t);\n\t\t\t})}\n\t\t</div>\n\t);\n}\n\n// ---------------------------------------------------------------------------\n// ScrollToTopOnPaginationChange\n// ---------------------------------------------------------------------------\n\nfunction DesktopSearchControl({\n\tprefixText,\n\tvalue,\n\titems,\n\tonChange,\n\ttestId,\n\tcontentClassName,\n}: {\n\tprefixText: string;\n\tvalue: string | number;\n\titems: { label: string; value: string | number }[];\n\tonChange: (value: string | number) => void;\n\ttestId: string;\n\tcontentClassName?: string;\n}) {\n\tconst selectedItem = useMemo(() => {\n\t\treturn items.find(item => item.value === value) ?? items[0];\n\t}, [items, value]);\n\n\tconst selectedLabel = selectedItem?.label ?? value.toString();\n\n\tconst handleValueChange = useCallback(\n\t\t(newValue: string) => {\n\t\t\tconst matchedItem = items.find(item => item.value.toString() === newValue);\n\t\t\tif (matchedItem) {\n\t\t\t\tonChange(matchedItem.value);\n\t\t\t}\n\t\t},\n\t\t[items, onChange]\n\t);\n\n\treturn (\n\t\t<DropdownMenu>\n\t\t\t<DropdownMenuTrigger\n\t\t\t\tclassName=\"inline-flex cursor-pointer items-center whitespace-nowrap border-0 bg-transparent p-0 text-black [&[data-state=open]>svg]:rotate-180\"\n\t\t\t\tdata-testid={testId}\n\t\t\t>\n\t\t\t\t<span className=\"mr-[3px] font-normal\">{prefixText}</span>\n\t\t\t\t<span className=\"font-semibold\">{selectedLabel}</span>\n\t\t\t\t<ChevronDown className=\"ml-[2px] h-4 w-4 transition-transform\" />\n\t\t\t</DropdownMenuTrigger>\n\t\t\t<DropdownMenuContent className={contentClassName}>\n\t\t\t\t<DropdownMenuRadioGroup onValueChange={handleValueChange} value={value.toString()}>\n\t\t\t\t\t{items.map(item => (\n\t\t\t\t\t\t<DropdownMenuRadioItem\n\t\t\t\t\t\t\tclassName=\"w-full data-[state=checked]:bg-primary-100 active:bg-secondary-100 focus-visible:ring-2 focus-visible:ring-primary\"\n\t\t\t\t\t\t\tkey={item.value.toString()}\n\t\t\t\t\t\t\tvalue={item.value.toString()}\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t{item.label}\n\t\t\t\t\t\t</DropdownMenuRadioItem>\n\t\t\t\t\t))}\n\t\t\t\t</DropdownMenuRadioGroup>\n\t\t\t</DropdownMenuContent>\n\t\t</DropdownMenu>\n\t);\n}\n\nfunction ScrollToTopOnPaginationChange() {\n\tconst { currentRefinement } = usePagination();\n\n\tuseEffect(() => {\n\t\twindow.scrollTo({ top: 0, behavior: 'smooth' });\n\t}, [currentRefinement]);\n\n\treturn null;\n}\n\nfunction NoResultsState({ query }: { query: string }) {\n\tconst resources = useSearchResources();\n\tconst normalizedQuery = query.trim();\n\tconst noResultsMessageTemplate = resources['noResults'];\n\tconst searchTips = [resources['checkSpelling'], resources['differentKeywords'], resources['lessSpecific']];\n\n\treturn (\n\t\t<section className=\"my-sp60 mx-auto flex w-full max-w-[640px] flex-col items-start gap-sp48 rounded-md border border-grey-200 bg-grey-50 p-sp60 text-left shadow-sm\">\n\t\t\t<Typography className=\"break-words text-left font-semibold text-black\" tag=\"p\" variant=\"bodyLarge\">\n\t\t\t\t{normalizedQuery && (\n\t\t\t\t\t<CommandSentence Container={React.Fragment} template={noResultsMessageTemplate}>\n\t\t\t\t\t\t<CommandSentence.Field name=\"QUERY\">{normalizedQuery}</CommandSentence.Field>\n\t\t\t\t\t</CommandSentence>\n\t\t\t\t)}\n\t\t\t</Typography>\n\t\t\t<div className=\"flex flex-col items-start gap-sp8 text-left text-black\">\n\t\t\t\t<Typography className=\"font-semibold text-black\" tag=\"p\" variant=\"bodyRegular\">\n\t\t\t\t\t{resources['searchTips']}\n\t\t\t\t</Typography>\n\t\t\t\t<ul className=\"list-disc pl-5\">\n\t\t\t\t\t{searchTips.map(tip => (\n\t\t\t\t\t\t<li className=\"bodyMd\" key={tip}>\n\t\t\t\t\t\t\t{tip}\n\t\t\t\t\t\t</li>\n\t\t\t\t\t))}\n\t\t\t\t</ul>\n\t\t\t</div>\n\t\t\t<Button onClick={() => window.location.assign('/search')} type=\"button\" variant=\"primary\">\n\t\t\t\t{resources['seeAllProducts']}\n\t\t\t</Button>\n\t\t</section>\n\t);\n}\n// ---------------------------------------------------------------------------\n// FilterSortLayout — main search page layout\n// ---------------------------------------------------------------------------\n\nconst FilterSortLayout = ({\n\twishListsProductsUrl,\n\tenableAuthorBioView,\n\tpageLimits,\n\tsortOrders,\n\tsearchResultsAbove,\n}: {\n\twishListsProductsUrl: string;\n\tenableAuthorBioView: boolean;\n\tpageLimits: number[];\n\tsortOrders: SearchSortOrder[];\n\tsearchResultsAbove?: SectionContentViewModel[];\n}) => {\n\tconst resources = useSearchResources();\n\tconst authorBioResources = useLocalization('CommerceWeb.Resources.Search.AuthorBio');\n\n\tconst [isMobileFilterOpen, setIsMobileFilterOpen] = useState(false);\n\n\tconst { viewMode, setViewMode } = useViewMode();\n\tconst { isMobile, isDesktop } = useScreensize();\n\tconst isHydrationSettled = useHydrationSettled();\n\tconst { selectedFilterOptions } = useUserSearchFilterContext();\n\n\tuseSearchImpressions();\n\tuseSearchAnalytics();\n\tconst { results } = useInstantSearch();\n\tconst { query } = useSearchBox();\n\tconst hasNoSearchResults = !results.__isArtificial && results.nbHits === 0;\n\tconst shouldShowResultsRoute = !hasNoSearchResults;\n\tconst { items: currentRefinements } = useCurrentRefinements();\n\n\tconst allSortItems = useMemo(\n\t\t() =>\n\t\t\tsortOrders.map(sortOrder => ({\n\t\t\t\tlabel: resources[sortOrder.label] ?? sortOrder.label,\n\t\t\t\tvalue: sortOrder.value,\n\t\t\t\tisPrepub: sortOrder.isPrepub,\n\t\t\t})),\n\t\t[resources, sortOrders]\n\t);\n\tconst { currentRefinement: currentSortBy, refine: refineSortBy } = useSortBy({ items: allSortItems });\n\tconst hasPrepubCategory = currentRefinements.some(\n\t\titem =>\n\t\t\titem.attribute === 'categories.lvl1' &&\n\t\t\titem.refinements?.some(refinement => refinement.value === 'status > prepub')\n\t);\n\tconst sortItems = useMemo(\n\t\t() => allSortItems.filter(item => !item.isPrepub || hasPrepubCategory || item.value === currentSortBy),\n\t\t[allSortItems, currentSortBy, hasPrepubCategory]\n\t);\n\n\tconst hitsPerPageItems = useMemo(\n\t\t() => pageLimits.map((pageLimit, index) => ({ default: index === 0, label: String(pageLimit), value: pageLimit })),\n\t\t[pageLimits]\n\t);\n\tconst { items: showItems, refine: refineHitsPerPage } = useHitsPerPage({\n\t\titems: hitsPerPageItems,\n\t});\n\tconst currentHitsPerPage = showItems.find(item => item.isRefined)?.value ?? hitsPerPageItems[0].value;\n\tconst searchStateKey = useMemo(\n\t\t() =>\n\t\t\tJSON.stringify({\n\t\t\t\tquery,\n\t\t\t\tsortBy: currentSortBy,\n\t\t\t\thitsPerPage: currentHitsPerPage,\n\t\t\t\trefinements: currentRefinements\n\t\t\t\t\t.map(item => ({\n\t\t\t\t\t\tattribute: item.attribute,\n\t\t\t\t\t\tvalues: item.refinements.map(refinement => String(refinement.value)).sort(),\n\t\t\t\t\t}))\n\t\t\t\t\t.sort((left, right) => left.attribute.localeCompare(right.attribute)),\n\t\t\t\tuserFilters: selectedFilterOptions,\n\t\t\t}),\n\t\t[currentHitsPerPage, currentRefinements, currentSortBy, query, selectedFilterOptions]\n\t);\n\tconst previousSearchStateKey = useRef<string | undefined>(undefined);\n\tuseEffect(() => {\n\t\tif (!isHydrationSettled) {\n\t\t\treturn;\n\t\t}\n\n\t\tif (\n\t\t\t!isDesktop &&\n\t\t\tpreviousSearchStateKey.current !== undefined &&\n\t\t\tpreviousSearchStateKey.current !== searchStateKey\n\t\t) {\n\t\t\twindow.scrollTo({ top: 0, behavior: 'smooth' });\n\t\t}\n\n\t\tpreviousSearchStateKey.current = searchStateKey;\n\t}, [isDesktop, isHydrationSettled, searchStateKey]);\n\n\tconst toggleFilter = useCallback(() => setIsMobileFilterOpen(prev => !prev), []);\n\n\tconst staticFilterAndSortControlsRef = useRef<HTMLDivElement>(null);\n\tconst closeFilter = useCallback(() => setIsMobileFilterOpen(false), []);\n\n\t// Close when resized to desktop\n\tuseEffect(() => {\n\t\tif (isDesktop) {\n\t\t\tcloseFilter();\n\t\t}\n\t}, [isDesktop, closeFilter]);\n\n\tuseEffect(() => {\n\t\tif (hasNoSearchResults) {\n\t\t\tcloseFilter();\n\t\t}\n\t}, [hasNoSearchResults, closeFilter]);\n\n\t// Shared filter panel content used in both mobile fullscreen and tablet drawer\n\tconst filterPanelContent = (\n\t\t<div className=\"isolate flex h-full flex-col\">\n\t\t\t{/* Sticky header — title + close button always visible */}\n\t\t\t<div className=\"sticky top-0 z-10 flex items-center justify-between bg-white py-4 pl-4 pr-5 shadow-sm\">\n\t\t\t\t<Typography className=\"!font-medium text-primary-400\" variant=\"bodyLarge\">\n\t\t\t\t\t{resources['filterAndSort']}\n\t\t\t\t</Typography>\n\t\t\t\t<button\n\t\t\t\t\taria-label=\"Close\"\n\t\t\t\t\tclassName=\"w-auto border-0 bg-transparent p-0 hover:bg-transparent\"\n\t\t\t\t\tonClick={closeFilter}\n\t\t\t\t\ttype=\"button\"\n\t\t\t\t>\n\t\t\t\t\t<CloseIcon className=\"h-4 w-4\" fillColor=\"fill-primary-400\" />\n\t\t\t\t</button>\n\t\t\t</div>\n\n\t\t\t<div className=\"flex-1 overflow-y-auto\">\n\t\t\t\t<div className=\"px-4 pt-4\">\n\t\t\t\t\t<Typography className=\"mb-2 text-black\" variant=\"bodySmall\">\n\t\t\t\t\t\t{resources['allFilters']}\n\t\t\t\t\t</Typography>\n\t\t\t\t\t<div className=\"mb-4 flex flex-wrap gap-1\">\n\t\t\t\t\t\t<CurrentQueryRefinement />\n\t\t\t\t\t\t<CurrentRefinements />\n\t\t\t\t\t</div>\n\t\t\t\t</div>\n\t\t\t\t<SortByAccordion items={sortItems} />\n\t\t\t\t<HitsPerPageAccordion items={hitsPerPageItems} />\n\t\t\t\t<Categories />\n\t\t\t</div>\n\t\t\t<div className=\"border-t border-grey-200 p-4\">\n\t\t\t\t<Button className=\"w-full\" onClick={closeFilter} type=\"button\" variant=\"primary\">\n\t\t\t\t\t{resources['seeResults']}\n\t\t\t\t</Button>\n\t\t\t</div>\n\t\t</div>\n\t);\n\n\treturn (\n\t\t<>\n\t\t\t{/* Tablet & Mobile: left-side slide-in drawer with scrim via react-modern-drawer, full screen on mobile*/}\n\t\t\t{!isDesktop && shouldShowResultsRoute && (\n\t\t\t\t<Drawer\n\t\t\t\t\tid=\"search-filter-drawer\"\n\t\t\t\t\tisOpen={isMobileFilterOpen}\n\t\t\t\t\tonClose={closeFilter}\n\t\t\t\t\tplacement=\"left\"\n\t\t\t\t\tsize={isMobile ? '100vw' : '320px' /* isTablet */}\n\t\t\t\t\tzIndex={5000}\n\t\t\t\t>\n\t\t\t\t\t<div className=\"h-full bg-white\">{filterPanelContent}</div>\n\t\t\t\t</Drawer>\n\t\t\t)}\n\t\t\t{!isDesktop && shouldShowResultsRoute && (\n\t\t\t\t<ScrollThresholdBar\n\t\t\t\t\trefreshKey={isMobileFilterOpen}\n\t\t\t\t\ttargetRef={staticFilterAndSortControlsRef}\n\t\t\t\t\tclassName=\"z-10 flex items-center justify-between border-y border-grey bg-white p-sp16 shadow-sm\"\n\t\t\t\t>\n\t\t\t\t\t<FilterAndSortButton onClick={toggleFilter} testId=\"sticky-filter-and-sort-button\" />\n\t\t\t\t\t<LayoutButtons currentLayoutType={viewMode} setLayoutType={setViewMode} />\n\t\t\t\t</ScrollThresholdBar>\n\t\t\t)}\n\n\t\t\t<div\n\t\t\t\tclassName={cn(\n\t\t\t\t\t'relative grid gap-8 px-4 md:px-6 lg:mx-auto lg:max-w-[1323px] xxlg:px-4',\n\t\t\t\t\tshouldShowResultsRoute ? 'lg:grid-cols-[300px_auto] xl:grid-cols-[375px_auto]' : 'lg:grid-cols-1'\n\t\t\t\t)}\n\t\t\t\t{...{ [hydrationSettledAttribute]: isHydrationSettled || undefined }}\n\t\t\t>\n\t\t\t\t<ScrollToTopOnPaginationChange />\n\n\t\t\t\t{/* Desktop: static sidebar (always visible in grid flow) */}\n\t\t\t\t{shouldShowResultsRoute && (\n\t\t\t\t\t<div className=\"mt-sp20 hidden self-start border-b border-primary-100 lg:block\">\n\t\t\t\t\t\t<Typography className=\"mb-8 text-black\" variant=\"bodyLarge\">\n\t\t\t\t\t\t\t{resources['allFilters']}\n\t\t\t\t\t\t</Typography>\n\t\t\t\t\t\t<Categories />\n\t\t\t\t\t</div>\n\t\t\t\t)}\n\n\t\t\t\t<div>\n\t\t\t\t\t<div className=\"flex flex-col gap-8\">\n\t\t\t\t\t\t<CategoryContent sectionKind=\"searchResultsAbove\" initialSectionContents={searchResultsAbove} />\n\t\t\t\t\t\t{enableAuthorBioView && <BooksByAuthor resources={authorBioResources} />}\n\t\t\t\t\t\t{hasNoSearchResults ? (\n\t\t\t\t\t\t\t<NoResultsState query={query} />\n\t\t\t\t\t\t) : (\n\t\t\t\t\t\t\t<div className=\"mt-sp20 -mx-4 flex flex-col-reverse justify-between px-4 md:-mx-6 md:px-6 lg:mx-0 lg:flex-row lg:items-start lg:px-0\">\n\t\t\t\t\t\t\t\t<div className=\"mt-4 flex flex-wrap items-center gap-1 lg:mt-0 lg:min-w-0 lg:flex-1\">\n\t\t\t\t\t\t\t\t\t<CurrentQueryRefinement />\n\t\t\t\t\t\t\t\t\t<CurrentRefinements />\n\t\t\t\t\t\t\t\t</div>\n\n\t\t\t\t\t\t\t\t<div\n\t\t\t\t\t\t\t\t\tref={staticFilterAndSortControlsRef}\n\t\t\t\t\t\t\t\t\tclassName=\"flex shrink-0 gap-8\"\n\t\t\t\t\t\t\t\t\tdata-testid=\"static-filter-and-sort-controls\"\n\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t<div className=\"mr-auto lg:hidden\">\n\t\t\t\t\t\t\t\t\t\t<FilterAndSortButton onClick={toggleFilter} />\n\t\t\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t\t\t\t<LayoutButtons currentLayoutType={viewMode} setLayoutType={setViewMode} />\n\t\t\t\t\t\t\t\t\t<div className=\"bodyMd hidden shrink-0 items-center text-black lg:flex\">\n\t\t\t\t\t\t\t\t\t\t<DesktopSearchControl\n\t\t\t\t\t\t\t\t\t\t\tonChange={newSortBy => refineSortBy(newSortBy.toString())}\n\t\t\t\t\t\t\t\t\t\t\titems={sortItems}\n\t\t\t\t\t\t\t\t\t\t\tprefixText={resources['sortBy']}\n\t\t\t\t\t\t\t\t\t\t\ttestId=\"sort-by-menu-button\"\n\t\t\t\t\t\t\t\t\t\t\tvalue={currentSortBy ?? sortItems[0].value}\n\t\t\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t\t\t\t<div className=\"bodyMd hidden shrink-0 items-center text-black lg:flex\">\n\t\t\t\t\t\t\t\t\t\t<DesktopSearchControl\n\t\t\t\t\t\t\t\t\t\t\tcontentClassName=\"w-(--radix-popper-anchor-width) min-w-0\"\n\t\t\t\t\t\t\t\t\t\t\tonChange={newHitsPerPage => refineHitsPerPage(Number(newHitsPerPage))}\n\t\t\t\t\t\t\t\t\t\t\titems={showItems.map(item => ({\n\t\t\t\t\t\t\t\t\t\t\t\tlabel: item.label,\n\t\t\t\t\t\t\t\t\t\t\t\tvalue: item.value,\n\t\t\t\t\t\t\t\t\t\t\t}))}\n\t\t\t\t\t\t\t\t\t\t\tprefixText={resources['show']}\n\t\t\t\t\t\t\t\t\t\t\ttestId=\"hits-per-page-menu-button\"\n\t\t\t\t\t\t\t\t\t\t\tvalue={currentHitsPerPage ?? hitsPerPageItems[0].value}\n\t\t\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t)}\n\t\t\t\t\t</div>\n\t\t\t\t\t{shouldShowResultsRoute && (\n\t\t\t\t\t\t<>\n\t\t\t\t\t\t\t<ProductHits\n\t\t\t\t\t\t\t\tlayoutType={viewMode}\n\t\t\t\t\t\t\t\twishListsProductsUrl={wishListsProductsUrl}\n\t\t\t\t\t\t\t\tcurrentHitsPerPage={currentHitsPerPage}\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t<Pagination\n\t\t\t\t\t\t\t\tclassName={cn(\n\t\t\t\t\t\t\t\t\t'[&>ul>li.previous-page-item>.ais-Pagination-link]:bodyLg',\n\t\t\t\t\t\t\t\t\t'[&>ul>li.next-page-item>.ais-Pagination-link]:bodyLg'\n\t\t\t\t\t\t\t\t)}\n\t\t\t\t\t\t\t\tclassNames={{\n\t\t\t\t\t\t\t\t\troot: 'py-4 lg:px-4 lg:py-8',\n\t\t\t\t\t\t\t\t\tnoRefinementRoot: 'hidden',\n\t\t\t\t\t\t\t\t\tlist: 'flex gap-[2px] items-center justify-center',\n\t\t\t\t\t\t\t\t\titem: 'bodySm text-black h-6 w-[23px]',\n\t\t\t\t\t\t\t\t\tpreviousPageItem: 'previous-page-item text-primary',\n\t\t\t\t\t\t\t\t\tpageItem: 'pageItem',\n\t\t\t\t\t\t\t\t\tselectedItem: 'bg-primary-100 text-primary',\n\t\t\t\t\t\t\t\t\tdisabledItem: 'opacity-25',\n\t\t\t\t\t\t\t\t\tnextPageItem: 'next-page-item text-primary',\n\t\t\t\t\t\t\t\t\tlink: 'flex items-center justify-center px-2 py-1 h-full w-full',\n\t\t\t\t\t\t\t\t}}\n\t\t\t\t\t\t\t\tshowFirst={false}\n\t\t\t\t\t\t\t\tshowLast={false}\n\t\t\t\t\t\t\t\tshowNext\n\t\t\t\t\t\t\t\tshowPrevious\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t</>\n\t\t\t\t\t)}\n\t\t\t\t</div>\n\t\t\t</div>\n\t\t</>\n\t);\n};\n\n// ---------------------------------------------------------------------------\n// InstantSearchWrapper — wires up Algolia routing + providers\n// ---------------------------------------------------------------------------\n\nconst InstantSearchWrapper = ({\n\tcategories,\n\tfacetConfigurations,\n\tsearchParameters,\n\twishListsProductsUrl,\n\tenableAuthorBioView,\n\tpageLimits,\n\tsortOrders,\n\tattributesToRetrieve,\n\tsearchResultsAbove,\n\tinitialViewMode,\n\tinitialAuthor,\n}: {\n\tcategories: SearchCategory[];\n\tfacetConfigurations: FacetConfiguration[];\n\tsearchParameters: AlgoliaSearchParameters;\n\twishListsProductsUrl: string;\n\tenableAuthorBioView: boolean;\n\tpageLimits: number[];\n\tsortOrders: SearchSortOrder[];\n\tattributesToRetrieve: string[];\n\tsearchResultsAbove?: SectionContentViewModel[];\n\tinitialViewMode: ViewMode;\n\tinitialAuthor?: AuthorInfo;\n}) => {\n\tconst { client: searchClient, indexName } = useAlgoliaSearch();\n\tconst { userSearchFilters } = useUserSearchFilterContext();\n\tconst { href } = useLocation();\n\tconst stateMapping = useMemo(\n\t\t() => makeStateMapping(indexName, facetConfigurations, sortOrders),\n\t\t[indexName, facetConfigurations, sortOrders]\n\t);\n\tconst categoryPageConfigurations = useMemo(\n\t\t() => convertSearchCategoriesToCategoryPageConfiguration(categories),\n\t\t[categories]\n\t);\n\tconst router = useMemo(\n\t\t() => makeRouter(categoryPageConfigurations, facetConfigurations, userSearchFilters, href),\n\t\t[categoryPageConfigurations, facetConfigurations, userSearchFilters, href]\n\t);\n\tconst routing = useMemo(() => ({ router, stateMapping }), [router, stateMapping]);\n\n\tuseEffect(() => {\n\t\tconst canonicalLink = document.head.querySelector<HTMLLinkElement>('link[rel=\"canonical\"]');\n\t\tif (!canonicalLink) {\n\t\t\treturn;\n\t\t}\n\n\t\tcanonicalLink.href = getCanonicalSearchUrl({\n\t\t\trouteState: router.read(),\n\t\t\tcanonicalOrigin: new URL(canonicalLink.href).origin,\n\t\t\tcategoryPageConfigurations,\n\t\t\tfacetConfigurations,\n\t\t\tindexName,\n\t\t\tpageLimits,\n\t\t\tsortOrders,\n\t\t});\n\t}, [router, categoryPageConfigurations, facetConfigurations, indexName, pageLimits, sortOrders]);\n\n\treturn (\n\t\t<AlgoliaSSRProvider<UiState, RouteState>\n\t\t\tattributesToRetrieve={attributesToRetrieve}\n\t\t\tqueryType=\"prefixNone\"\n\t\t\trouting={routing}\n\t\t\tsearchClient={searchClient}\n\t\t\tsearchParameters={searchParameters}\n\t\t\tinitialViewMode={initialViewMode}\n\t\t>\n\t\t\t<HiddenFacetRefinements facetConfigurations={facetConfigurations} />\n\t\t\t<AuthorBatch.Provider initialData={initialAuthor ? [{ id: initialAuthor.id, data: initialAuthor }] : undefined}>\n\t\t\t\t<PublisherBatch.Provider>\n\t\t\t\t\t<FilterSortLayout\n\t\t\t\t\t\tpageLimits={pageLimits}\n\t\t\t\t\t\tsortOrders={sortOrders}\n\t\t\t\t\t\twishListsProductsUrl={wishListsProductsUrl}\n\t\t\t\t\t\tenableAuthorBioView={enableAuthorBioView}\n\t\t\t\t\t\tsearchResultsAbove={searchResultsAbove}\n\t\t\t\t\t/>\n\t\t\t\t</PublisherBatch.Provider>\n\t\t\t</AuthorBatch.Provider>\n\t\t</AlgoliaSSRProvider>\n\t);\n};\n\n// ---------------------------------------------------------------------------\n// Search — top-level entry component (default export)\n// ---------------------------------------------------------------------------\n\ninterface SearchProps {\n\talgoliaAppId?: string;\n\talgoliaAppKey?: string;\n\talgoliaUserTokenCookieDurationInMilliseconds?: number | null;\n\talgoliaIndexName?: string;\n\tstorefrontShortname?: string;\n\talgoliaSearchParametersJson?: string;\n\tuserSearchFiltersJson?: string;\n\tinitialUserSearchFilterSelections?: Record<string, string>;\n\tfacetConfigurations?: FacetConfiguration[];\n\tsearchCategories?: SearchCategory[];\n\twishListsProductsUrl?: string;\n\tenableAuthorBioView?: boolean;\n\tsearchResultsAbove?: SectionContentViewModel[];\n\tsearchResultsBelow?: SectionContentViewModel[];\n\tinitialViewMode: ViewMode;\n\tpageLimits: number[];\n\tsortOrders: SearchSortOrder[];\n\tattributesToRetrieve: string[];\n\tinitialIsSignedIn?: boolean;\n\tserverState?: InstantSearchServerState;\n\tinitialAuthor?: AuthorInfo;\n}\n\nexport default function Search({\n\talgoliaAppId = '',\n\talgoliaAppKey = '',\n\talgoliaUserTokenCookieDurationInMilliseconds,\n\talgoliaIndexName = '',\n\tstorefrontShortname = '',\n\talgoliaSearchParametersJson,\n\tuserSearchFiltersJson,\n\tinitialUserSearchFilterSelections,\n\tfacetConfigurations = [],\n\tsearchCategories = [],\n\twishListsProductsUrl = '',\n\tenableAuthorBioView = false,\n\tpageLimits,\n\tsortOrders,\n\tattributesToRetrieve,\n\tinitialViewMode,\n\tserverState,\n\tinitialAuthor,\n\tsearchResultsAbove,\n\tsearchResultsBelow,\n\tinitialIsSignedIn,\n}: SearchProps) {\n\tconst localizedResources = useLocalization('CommerceWeb.Resources.Search.Search');\n\tconst { userId, isSignedIn } = useCurrentUser();\n\tconst effectiveIsSignedIn = isSignedIn || initialIsSignedIn === true;\n\tconst searchParameters = useMemo(\n\t\t() => safeJsonParse(algoliaSearchParametersJson) ?? {},\n\t\t[algoliaSearchParametersJson]\n\t);\n\tconst userSearchFilters = useMemo((): UserSearchFilter[] => {\n\t\tconst parsedFilters = safeJsonParse<UserSearchFilters>(userSearchFiltersJson);\n\t\treturn (\n\t\t\tparsedFilters?.filters?.map(filter => ({\n\t\t\t\t...filter,\n\t\t\t\toptions: filter.options.map(option => ({ ...option, isSelected: option.isDefault })),\n\t\t\t})) ?? []\n\t\t);\n\t}, [userSearchFiltersJson]);\n\n\treturn (\n\t\t<div className=\"tw-preflight\">\n\t\t\t<PerUserDataContextProvider requestAnonymousPricing>\n\t\t\t\t<SearchResourcesContext.Provider value={localizedResources}>\n\t\t\t\t\t<ErrorBoundary>\n\t\t\t\t\t\t<AlgoliaSearchContextProvider\n\t\t\t\t\t\t\tappId={algoliaAppId}\n\t\t\t\t\t\t\tappKey={algoliaAppKey}\n\t\t\t\t\t\t\tcookieDuration={algoliaUserTokenCookieDurationInMilliseconds}\n\t\t\t\t\t\t\tindexName={algoliaIndexName}\n\t\t\t\t\t\t\tstorefrontShortname={storefrontShortname}\n\t\t\t\t\t\t\tuserId={userId}\n\t\t\t\t\t\t\tisSignedIn={effectiveIsSignedIn}\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t<UserSearchFilterProvider\n\t\t\t\t\t\t\t\tinitialSelectedFilterOptions={initialUserSearchFilterSelections}\n\t\t\t\t\t\t\t\tuserSearchFilters={userSearchFilters}\n\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t<InstantSearchSSRProvider initialResults={serverState?.initialResults}>\n\t\t\t\t\t\t\t\t\t<InstantSearchWrapper\n\t\t\t\t\t\t\t\t\t\tcategories={searchCategories}\n\t\t\t\t\t\t\t\t\t\tfacetConfigurations={facetConfigurations}\n\t\t\t\t\t\t\t\t\t\tsearchParameters={searchParameters}\n\t\t\t\t\t\t\t\t\t\twishListsProductsUrl={wishListsProductsUrl}\n\t\t\t\t\t\t\t\t\t\tenableAuthorBioView={enableAuthorBioView}\n\t\t\t\t\t\t\t\t\t\tpageLimits={pageLimits}\n\t\t\t\t\t\t\t\t\t\tsortOrders={sortOrders}\n\t\t\t\t\t\t\t\t\t\tattributesToRetrieve={attributesToRetrieve}\n\t\t\t\t\t\t\t\t\t\tsearchResultsAbove={searchResultsAbove}\n\t\t\t\t\t\t\t\t\t\tinitialViewMode={initialViewMode}\n\t\t\t\t\t\t\t\t\t\tinitialAuthor={initialAuthor}\n\t\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t\t</InstantSearchSSRProvider>\n\t\t\t\t\t\t\t</UserSearchFilterProvider>\n\t\t\t\t\t\t</AlgoliaSearchContextProvider>\n\t\t\t\t\t</ErrorBoundary>\n\t\t\t\t</SearchResourcesContext.Provider>\n\t\t\t\t<CategoryContent sectionKind=\"searchResultsBelow\" initialSectionContents={searchResultsBelow} />\n\t\t\t</PerUserDataContextProvider>\n\t\t</div>\n\t);\n}\n","import { useEffect, useRef } from 'react';\nimport { useHits } from 'react-instantsearch';\n\nimport { ProductHit } from '../types';\n\n/**\n * Pushes UA Enhanced Ecommerce impression data to the dataLayer when search results change.\n * Matches the Skeletor pattern of `dataLayer.push({ ecommerce: { impressions: [...] } })`.\n */\nexport function useSearchImpressions() {\n\tconst { results } = useHits<ProductHit>();\n\tconst lastPushedQueryRef = useRef<string | null>(null);\n\n\tuseEffect(() => {\n\t\tif (!results?.hits?.length) {\n\t\t\treturn;\n\t\t}\n\n\t\t// Deduplicate pushes by using the Algolia query ID (or query string + page as fallback)\n\t\tconst queryKey = (results as any).queryID ?? `${results.query ?? ''}_${results.page ?? 0}`;\n\t\tif (queryKey === lastPushedQueryRef.current) {\n\t\t\treturn;\n\t\t}\n\t\tlastPushedQueryRef.current = queryKey;\n\n\t\tconst impressions = results.hits.map((hit, index) => ({\n\t\t\tid: String(hit.productId),\n\t\t\tname: hit.title ?? '',\n\t\t\tprice: String(hit.salePrice ?? 0),\n\t\t\tlist: 'Search Results',\n\t\t\tposition: String(index),\n\t\t}));\n\n\t\t(window as any).dataLayer = (window as any).dataLayer || [];\n\t\t(window as any).dataLayer.push({\n\t\t\tecommerce: {\n\t\t\t\timpressions,\n\t\t\t},\n\t\t});\n\t}, [results]);\n}\n","import { useEffect, useRef } from 'react';\nimport { useInstantSearch } from 'react-instantsearch';\n\n/**\n * Pushes GTM dataLayer events when users interact with search facets, sort options,\n * and hits-per-page controls. Matches the Skeletor `facet_search` and `results_search` events.\n */\nexport function useSearchAnalytics() {\n\tconst { indexUiState } = useInstantSearch();\n\tconst previousStateRef = useRef<typeof indexUiState | null>(null);\n\n\tuseEffect(() => {\n\t\tconst prevState = previousStateRef.current;\n\t\tpreviousStateRef.current = indexUiState;\n\n\t\t// Skip the initial render — only track user-initiated changes\n\t\tif (!prevState) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst dataLayer = ((window as any).dataLayer = (window as any).dataLayer || []);\n\n\t\t// Track sort changes\n\t\tif (indexUiState.sortBy !== prevState.sortBy) {\n\t\t\tdataLayer.push({\n\t\t\t\tevent: 'results_search',\n\t\t\t\tselection: {\n\t\t\t\t\tgroup: 'Sort By',\n\t\t\t\t\toption: indexUiState.sortBy ?? 'default',\n\t\t\t\t},\n\t\t\t});\n\t\t}\n\n\t\t// Track hits-per-page changes\n\t\tif (indexUiState.hitsPerPage !== prevState.hitsPerPage) {\n\t\t\tdataLayer.push({\n\t\t\t\tevent: 'results_search',\n\t\t\t\tselection: {\n\t\t\t\t\tgroup: 'Show',\n\t\t\t\t\toption: String(indexUiState.hitsPerPage ?? 15),\n\t\t\t\t},\n\t\t\t});\n\t\t}\n\n\t\t// Track refinement list (facet) changes\n\t\tconst currentRefinements = indexUiState.refinementList ?? {};\n\t\tconst previousRefinements = prevState.refinementList ?? {};\n\n\t\tconst allFacetKeys = new Set([...Object.keys(currentRefinements), ...Object.keys(previousRefinements)]);\n\n\t\tfor (const facetKey of allFacetKeys) {\n\t\t\tconst currentValues = new Set(currentRefinements[facetKey] ?? []);\n\t\t\tconst previousValues = new Set(previousRefinements[facetKey] ?? []);\n\n\t\t\t// Find newly selected facets\n\t\t\tfor (const value of currentValues) {\n\t\t\t\tif (!previousValues.has(value)) {\n\t\t\t\t\tdataLayer.push({\n\t\t\t\t\t\tevent: 'facet_search',\n\t\t\t\t\t\tselection: {\n\t\t\t\t\t\t\tfacetGroup: facetKey,\n\t\t\t\t\t\t\tfacet: value,\n\t\t\t\t\t\t\tchecked: true,\n\t\t\t\t\t\t},\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t// Find deselected facets\n\t\t\tfor (const value of previousValues) {\n\t\t\t\tif (!currentValues.has(value)) {\n\t\t\t\t\tdataLayer.push({\n\t\t\t\t\t\tevent: 'facet_search',\n\t\t\t\t\t\tselection: {\n\t\t\t\t\t\t\tfacetGroup: facetKey,\n\t\t\t\t\t\t\tfacet: value,\n\t\t\t\t\t\t\tchecked: false,\n\t\t\t\t\t\t},\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\t// Track page changes\n\t\tif (indexUiState.page !== prevState.page) {\n\t\t\tdataLayer.push({\n\t\t\t\tevent: 'results_search',\n\t\t\t\tselection: {\n\t\t\t\t\tgroup: 'Page',\n\t\t\t\t\toption: String(indexUiState.page ?? 1),\n\t\t\t\t},\n\t\t\t});\n\t\t}\n\t}, [indexUiState]);\n}\n","export function safeJsonParse<T = any>(json: string | null | undefined): T | null {\n\tif (json === null || json === undefined) {\n\t\treturn null;\n\t}\n\n\ttry {\n\t\treturn JSON.parse(json) as T;\n\t} catch {\n\t\treturn null;\n\t}\n}\n"],"names":["scroll_threshold_bar","targetRef","children","threshold","position","refreshKey","className","isVisible","setIsVisible","useState","useEffect","target","current","normalizedThreshold","Number","isFinite","Math","min","max","scrollContainer","parentElement","document","body","documentElement","overflowY","window","getComputedStyle","includes","scrollTarget","animationFrame","updateVisibility","targetBounds","getBoundingClientRect","triggerPosition","top","height","scrollportTop","clientTop","scheduleUpdate","requestAnimationFrame","eventTarget","addEventListener","passive","removeEventListener","cancelAnimationFrame","stickyBarRef","useCallback","stickyBar","removeAttribute","setAttribute","isAtTop","React","cn","ref","BooksByAuthor","resources","refinedAuthorIds","useRefinementList","attribute","items","filter","item","isRefined","map","value","authorId","length","data","author","isLoading","useAuthor","isCollapsed","setIsCollapsed","displayName","longDescription","Typography","variant","booksBy","IconButton","scale","onClick","ChevronDown","ChevronUp","AuthorBio","imageUrl","imageUrlLarge","bio","PublisherBatch","createBatchContext","async","nonEmptyIds","ids","id","response","fetch","join","ok","Error","status","json","find","d","builderIoModelNamesBySectionKindMap","searchResultsAbove","searchResultsBelow","universalHeader","universalFooter","subscriptionChurnPrevention","configurationWizardSubscriptionsBanner","configurationWizardSubscriptionsContent","configurationWizardLibrariesBanner","orderSummary","orderSummaryFooter","productPage","adzone","notifications","pdpBanner","getContentKey","sectionContents","sc","sectionKind","contentSourceKind","contentId","section_content","SectionContent","initialSectionContents","onContentChange","setSectionContents","builderIoModel","isBuilderIoPreviewingThisModel","useIsPreviewingThisBuilderModel","location","useLocation","lastRequestedLocationHref","useRef","undefined","href","sections","kind","url","get","params","error","getSections","filteredSections","hasContent","contentKey","fetchSections","notifyWarning","RenderBuilderContent","model","staticData","staticProductData","userInfo","c_defaultUserInfo","filteredContents","_extends","key","builderIo","category_content","CategoryContent","setContentState","handleContentChange","event","prev","ErrorBoundary","ReadMoreReadLess","UserSearchFilterContext","createContext","readUserFilterSelectionsFromUrl","userSearchFilters","searchParams","defaults","reduce","selectedOptions","options","Array","isArray","selectedOption","option","isDefault","token","getDefaultSelectedFilterOptions","urlValue","matchingOption","resolved","useUserSearchFilterContext","context","useContext","UserSearchFilterProvider","initialSelectedFilterOptions","setSelectedFilterOptionsOverride","search","pathname","replaceUrl","useMemo","URLSearchParams","selectedFilterOptions","setSelectedFilterOptions","urlSelections","initialSelection","some","next","currentSelection","first","second","firstKeys","Object","keys","secondKeys","every","areSelectedFilterOptionsEqual","URL","selectedToken","set","delete","writeUserFilterSelectionsToUrl","handleSetSelectedFilterOption","filterToken","optionToken","contextValue","setSelectedFilterOption","Provider","Accordion","AccordionPrimitive","AccordionItem","props","AccordionTrigger","AccordionContent","c_nonWordCharacters","c_leadingDecimalDigit","c_facetResourceKeyAliases","bibleAndApocrypha","containment","single","standalone","format","reader","religiousGroup","topic","getFacetDisplayLabel","rawLabel","leaf","separatorIndex","lastIndexOf","slice","trim","getFacetLeaf","resourceName","replace","baseAttribute","resourceKeyAlias","resourceKeys","test","leadingDigits","match","push","getResourceKeys","resourceKey","translation","getResourceValue","prototype","hasOwnProperty","call","caseInsensitiveKey","toLowerCase","useFacetConstraints","useLocalization","SearchResourcesContext","useSearchResources","serializeKey","JSON","stringify","createBoundedResponsesCache","maxCharacters","cache","Map","characters","defaultValue","events","miss","Promise","resolve","serializedKey","cached","parse","promise","then","serializedValue","existing","size","oldestKey","evict","clear","AlgoliaSearchContext","AlgoliaSearchContextProvider","appId","appKey","cookieDuration","indexName","storefrontShortname","userId","isSignedIn","client","algoliasearch","responsesCache","anonymousUserToken","setAnonymousUserToken","insightsClient","createAlgoliaInsightsInitOptions","userToken","String","useAlgoliaSearch","parseFacetValue","indexOf","substring","safeUrl","input","base","Check","checked","fill","viewBox","width","xmlns","rx","stroke","y","strokeLinecap","c_statusLabelKeys","ShowMoreToggle","showMore","setShowMore","isShowingMore","LinkButton","as","countDepth","index","depth","getChildren","parent","startsWith","Category","category","setExpandedFacets","maxLevel","facetConstraints","levels","levelsRef","level","refinement","limit","skipSuspense","useRefinementLists","accordions","root","label","labelKind","subCategories","hasChildren","c","getAccordions","accordion","tag","refine","eventName","filters","child","forEach","childRefinement","old","v","count","AuthorFacetItem","onRefine","PublisherFacetItem","AuthorsOrPublishers","nameAttribute","canToggleShowMore","toggleShowMore","idItems","FacetItem","facetItems","idItem","sort","a","b","i","Statuses","level1","level2","level3","level4","UserSearchFilterAccordionItem","selectedFilterOption","title","isSelected","onChange","type","Categories","expandedFacets","onValueChange","isGenericLocalizableFacet","split","isStatusRefinement","RefinementLabel","facetLabel","stringValue","AuthorLabel","PublisherLabel","AuthorApiLabel","PublisherApiLabel","useData","CurrentRefinements","currentRefinements","useCurrentRefinements","itemsByAttribute","refinementList","refinements","itemValue","itemAndChildren","r","RefinementChip","X","CurrentQueryRefinement","urlQuery","query","useSearchBox","queryRef","removeQuery","HiddenRefinementList","getHiddenAlgoliaAttributes","config","algoliaAttribute","attributes","minLevel","algoliaAttributeBase","HiddenFacetRefinements","facetConfigurations","isHidden","flatMap","SkeletonRoot","pending","hideOverflow","role","SkeletonBox","EnhancedForLogosLabel","logosOrVerbum","useBrandName","isVerbum","CommandSentence","template","EnhancedForLogos","Field","name","alt","src","enhanced_for_logos_with_tooltip","EnhancedForLogosWithTooltip","Tooltip","placement","link","InfoIconSvgUrl","EnhancedForLogosTooltipContent","usdFormat","Intl","NumberFormat","style","currency","minimumFractionDigits","maximumFractionDigits","useProductCard","hit","queryId","pricingData","usePricing","productId","preferredCurrency","currentUserIsSignedIn","useCurrentUser","searchIsSignedIn","locale","useLocale","hasGeoRestriction","isGeographicallyRestricted","isAddingToCart","setIsAddingToCart","requestIdRef","prices","primarySku","salePrice","amount","displayAmount","currencyCode","anchorPrice","displayAmountCurrencyCode","accessKind","isOwned","hasPreorder","prepubProductStatusSummary","rawPercentCommitted","percentCommitted","normalizedStatusValues","PrepubProductStatus","shippingSoon","almostThere","underContract","gatheringInterest","getPrepubStatus","shipDate","milliseconds","abs","date","Date","isNaN","getTime","dateOnlyMatch","exec","getFullYear","getMonth","getDate","parsePrepubShipDate","prepubShipDate","description","now","thirtyDaysFromNow","setDate","ninetyDaysFromNow","shipDateString","DateTimeFormat","month","year","floor","getShippingDateDescription","toISOString","getPrepubProductStatusSummary","isPrepubProduct","Boolean","indexedPrimarySkuId","primarySkuStorefronts","normalizedStorefrontShortname","entries","storefronts","storefront","getIndexedPrimarySkuId","hasIndexedPrimarySkuData","canUseIndexedPrimarySku","skuId","isPurchasable","handleCartUpdated","e","detail","requestId","handleCartUpdateError","slug","text","normalize","slugify","productPath","productUrl","encodeURIComponent","productName","regularPrice","salePriceCurrency","localizedSalePrice","localizedDisplayAmount","discountPercentage","anchor","sale","getSavingsPercent","isDiscounted","discountSavings","productImageSrc","primaryImageUri","imageSrc","detectIsAmberOptimizedUrl","isLogosEdition","handleProductClick","queryID","objectIDs","positions","handleAddToCart","eventType","eventData","random","eventDetail","addToCartUrl","routes","skuIds","addToCartSkuId","quantity","payInFull","searchData","productIds","currentTarget","dispatchEvent","CustomEvent","bubbles","ProductImage","priority","onAuxClick","Image","belowTheFold","sizes","mobile","desktop","targetAspectRatio","DiscountBadge","badgeClassName","toFixed","ProductTitle","ProductAuthors","authors","ctaButtonScale","skeletonHeightByButtonScale","small","medium","large","ProductPricing","cardData","buttonLayoutClassName","ProductPrice","ProductCta","ownershipLabelClassName","PriceLabel","layout","purchaseStatusMessage","getOwnershipLabel","Button","disabled","Skeleton","AlgoliaGridCard","productWishlistData","useProductInWishList","averageRating","reviewCount","hasReviewData","hasValidReviewData","AddToWishList","StarRating","rating","PrepubProductStatusSummary","ProductOverview","overview","isExpanded","setIsExpanded","showButton","setShowButton","overviewRef","element","scrollHeight","computedLineHeight","lineHeight","parsedLineHeight","parseInt","dangerouslySetInnerHTML","__html","intent","toggleExpand","AlgoliaListCard","SkeletonBlock","rootClassName","SkeletonButton","ProductSkeleton","layoutType","ProductSkeletons","currentHitsPerPage","from","_","toProductHitResult","toString","products","wishListsProductsUrl","useInstantSearch","HitComponent","cardProps","__position","__queryID","WishlistContextProvider","Hits","classNames","list","hitComponent","RadioAccordion","radioGroupName","onSelect","prefixLabel","currentItem","collapsible","SortByAccordion","currentRefinement","useSortBy","HitsPerPageAccordion","showItems","useHitsPerPage","ViewMode","ViewModeContext","viewModeKey","ViewModeProvider","initialViewMode","viewMode","setViewMode","history","replaceState","Cookies","getAllFacetingKeys","routeKey","routeKeyPrefix","arrayToQueryParam","array","emptyIfUndefined","getTrimmedOrUndefinedIfStringEmpty","trimmed","getMatchingCategoryPageFromRouteState","routeState","categoryPageConfigurations","allFacetingKeys","facets","Set","categoryPageConfiguration","checkCategoryPageConfigurationMatches","preserveCustomQueryParams","sourceUrl","targetUrl","preserveKeys","has","preserveNonSearchQueryParams","searchParamKeys","writeFacetsSearchParams","excludedKeys","candidateQueryParamValue","writeUserFilterSearchParams","checkFacetValueConfigurationMatches","facetValueConfiguration","routeStateFacetValue","routeStateFacets","facetsConfiguration","matches","routeStateFacet","facetConfiguration","f","queryParamName","writeCommonSearchParams","sortBy","page","hydrationSettledAttribute","AlgoliaSSRProvider","AlgoliaProvider","attributesToHighlight","attributesToRetrieve","queryType","restrictSearchableAttributes","routing","searchClient","searchParameters","InstantSearch","future","preserveSharedStateOnUnmount","insights","ConfigureCore","ParameterBlacklist","mergedParams","uf","selectedOptionToken","o","algoliaValue","filterParts","fromEntries","Configure","distinct","clickAnalytics","CloseIcon","fillColor","_fillColor","rest","strokeWidth","FilterIcon","FilterAndSortButton","testId","LayoutButtonOptions","grid","icon","x","additionalClassNames","LayoutButtons","currentLayoutType","setLayoutType","IconComponent","DesktopSearchControl","prefixText","contentClassName","selectedItem","selectedLabel","handleValueChange","newValue","matchedItem","DropdownMenu","DropdownMenuTrigger","DropdownMenuContent","DropdownMenuRadioGroup","DropdownMenuRadioItem","ScrollToTopOnPaginationChange","usePagination","scrollTo","behavior","NoResultsState","normalizedQuery","noResultsMessageTemplate","searchTips","Container","tip","assign","FilterSortLayout","enableAuthorBioView","pageLimits","sortOrders","authorBioResources","isMobileFilterOpen","setIsMobileFilterOpen","useViewMode","isMobile","isDesktop","useScreensize","isHydrationSettled","isSettled","setIsSettled","timeoutId","setTimeout","clearTimeout","useHydrationSettled","results","useHits","lastPushedQueryRef","hits","queryKey","impressions","price","dataLayer","ecommerce","useSearchImpressions","indexUiState","previousStateRef","prevState","selection","group","hitsPerPage","previousRefinements","allFacetKeys","facetKey","currentValues","previousValues","facetGroup","facet","useSearchAnalytics","hasNoSearchResults","__isArtificial","nbHits","shouldShowResultsRoute","allSortItems","sortOrder","isPrepub","currentSortBy","refineSortBy","hasPrepubCategory","sortItems","hitsPerPageItems","pageLimit","default","refineHitsPerPage","searchStateKey","values","left","right","localeCompare","userFilters","previousSearchStateKey","toggleFilter","staticFilterAndSortControlsRef","closeFilter","filterPanelContent","Drawer","isOpen","onClose","zIndex","ScrollThresholdBar","newSortBy","newHitsPerPage","ProductHits","Pagination","noRefinementRoot","previousPageItem","pageItem","disabledItem","nextPageItem","showFirst","showLast","showNext","showPrevious","InstantSearchWrapper","categories","initialAuthor","stateMapping","stateToRoute","uiState","facetValues","order","routeValue","routeToState","makeStateMapping","categoryPageUrl","facetRouteKey","pageTitle","convertSearchCategoriesToCategoryPageConfiguration","router","initialUrl","allFacetingKeysSet","userFilterKeysSet","preserveCustomKeysSet","searchParamKeysSet","categoryPagesByCategoryPageUrl","configuration","getLocation","ancestorOrigins","contains","Symbol","iterator","hash","host","hostname","origin","port","protocol","reload","cleanUrlOnDispose","createURL","matchingCategoryPage","currentUrl","categoryFacetKeys","err","console","parseURL","locationUrl","locationPathname","addRouteStateFacetValues","queryParams","paramName","paramValue","windowTitle","makeRouter","canonicalLink","head","querySelector","canonicalOrigin","canonicalUrl","categoryUrl","getCanonicalSearchUrl","read","AuthorBatch","initialData","Search","algoliaAppId","algoliaAppKey","algoliaUserTokenCookieDurationInMilliseconds","algoliaIndexName","algoliaSearchParametersJson","userSearchFiltersJson","initialUserSearchFilterSelections","searchCategories","serverState","initialIsSignedIn","localizedResources","effectiveIsSignedIn","safeJsonParse","parsedFilters","PerUserDataContextProvider","requestAnonymousPricing","InstantSearchSSRProvider","initialResults"],"sourceRoot":""}