[{"data":1,"prerenderedAt":3969},["ShallowReactive",2],{"docs-navigation":3,"docs-\u002Fdocs\u002Fgetting-started\u002Fjavascript-sdk":331,"docs-\u002Fdocs\u002Fgetting-started\u002Fjavascript-sdk-surround":3966},[4],{"title":5,"path":6,"stem":7,"children":8,"page":46},"Docs","\u002Fdocs","docs",[9,47,72,90,132,198,241,252,276,301],{"title":10,"description":11,"icon":12,"path":13,"stem":14,"children":15,"page":46},"Getting started","What Zaproo Search is, a quickstart, and wiring search into a storefront.","i-lucide-rocket","\u002Fdocs\u002Fgetting-started","docs\u002F1.getting-started",[16,22,28,34,40],{"title":17,"path":18,"stem":19,"description":20,"icon":21},"Introduction","\u002Fdocs\u002Fgetting-started\u002Fintroduction","docs\u002F1.getting-started\u002F1.introduction","What Zaproo Search is, the five things you work with, and how a product catalog becomes a search box on your shop.","i-lucide-book-open-text",{"title":23,"path":24,"stem":25,"description":26,"icon":27},"Quickstart","\u002Fdocs\u002Fgetting-started\u002Fquickstart","docs\u002F1.getting-started\u002F2.quickstart","Set up search for your shop in the cabinet, from a new account to a first search, with the API and MCP as other ways to do the same.","i-lucide-zap",{"title":29,"path":30,"stem":31,"description":32,"icon":33},"Integrate a storefront","\u002Fdocs\u002Fgetting-started\u002Fstorefront","docs\u002F1.getting-started\u002F3.storefront","Build a search results page with facets and an autocomplete box on top of the search and suggest routes.","i-lucide-store",{"title":35,"path":36,"stem":37,"description":38,"icon":39},"JavaScript SDK","\u002Fdocs\u002Fgetting-started\u002Fjavascript-sdk","docs\u002F1.getting-started\u002F4.javascript-sdk","Search, autocomplete and event tracking from a storefront with one small client that runs in the browser, on your server and in edge functions.","i-lucide-braces",{"title":41,"path":42,"stem":43,"description":44,"icon":45},"AI shopping assistant","\u002Fdocs\u002Fgetting-started\u002Fai-assistant","docs\u002F1.getting-started\u002F5.ai-assistant","A chat widget for your storefront that finds products and answers questions from your indexes.","i-lucide-sparkles",false,{"title":48,"description":49,"icon":50,"path":51,"stem":52,"children":53,"page":46},"Account and team","Sign-in, sessions, organizations, members, roles and projects.","i-lucide-users","\u002Fdocs\u002Faccount","docs\u002F2.account",[54,60,66],{"title":55,"path":56,"stem":57,"description":58,"icon":59},"Account and sign-in","\u002Fdocs\u002Faccount\u002Fsign-in","docs\u002F2.account\u002F1.sign-in","Create an account, verify your email, stay signed in, manage signed-in devices and change or reset your password.","i-lucide-log-in",{"title":61,"path":62,"stem":63,"description":64,"icon":65},"Organizations, members and roles","\u002Fdocs\u002Faccount\u002Forganizations","docs\u002F2.account\u002F2.organizations","What an organization holds, how to add members, and what owners, admins and members may do.","i-lucide-building-2",{"title":67,"path":68,"stem":69,"description":70,"icon":71},"Projects","\u002Fdocs\u002Faccount\u002Fprojects","docs\u002F2.account\u002F3.projects","Group the indices and API keys of one shop or one environment, and keep staging apart from production.","i-lucide-folder-kanban",{"title":73,"description":74,"icon":75,"path":76,"stem":77,"children":78,"page":46},"API keys and security","Secret and public keys, scopes, allowed origins, rate limits and errors.","i-lucide-key-round","\u002Fdocs\u002Fkeys","docs\u002F3.keys",[79,84],{"title":80,"path":81,"stem":82,"description":83,"icon":75},"API keys","\u002Fdocs\u002Fkeys\u002Fapi-keys","docs\u002F3.keys\u002F1.api-keys","Secret and public keys, full and read access, index scope, allowed origins, expiry, and how to revoke a key.",{"title":85,"path":86,"stem":87,"description":88,"icon":89},"Rate limits and errors","\u002Fdocs\u002Fkeys\u002Frate-limits","docs\u002F3.keys\u002F2.rate-limits","How many requests each route accepts per minute, what a 429 looks like, the error format and every error code with its HTTP status.","i-lucide-gauge",{"title":91,"description":92,"icon":93,"path":94,"stem":95,"children":96,"page":46},"Indexing","Indices, languages, mappings, documents, tasks, full catalog sync and reindexing.","i-lucide-database","\u002Fdocs\u002Findexing","docs\u002F4.indexing",[97,102,108,114,120,126],{"title":98,"path":99,"stem":100,"description":101,"icon":93},"Indices and languages","\u002Fdocs\u002Findexing\u002Findices","docs\u002F4.indexing\u002F1.indices","Create an index, pick its language, read its status, and change the language later with a reindex.",{"title":103,"path":104,"stem":105,"description":106,"icon":107},"Mapping and fields","\u002Fdocs\u002Findexing\u002Fmapping","docs\u002F4.indexing\u002F2.mapping","Field types, the five flags that decide what a field is used for, text analysis options, unmapped fields, and which changes need a reindex.","i-lucide-table-properties",{"title":109,"path":110,"stem":111,"description":112,"icon":113},"Documents and tasks","\u002Fdocs\u002Findexing\u002Fdocuments","docs\u002F4.indexing\u002F3.documents","Upload, browse and delete documents in the cabinet or through the API, follow each write as a task, and retry safely with Idempotency-Key.","i-lucide-file-json",{"title":115,"path":116,"stem":117,"description":118,"icon":119},"Full catalog sync","\u002Fdocs\u002Findexing\u002Ffull-sync","docs\u002F4.indexing\u002F4.full-sync","Replace the whole catalog with a replace session, so products missing from your export disappear from search, without downtime.","i-lucide-refresh-cw",{"title":121,"path":122,"stem":123,"description":124,"icon":125},"Reindex and versions","\u002Fdocs\u002Findexing\u002Fversions","docs\u002F4.indexing\u002F5.versions","Rebuild an index with its saved mapping and swap it in without downtime, follow or cancel the rebuild, and read activeVersion and buildingVersion.","i-lucide-git-compare-arrows",{"title":127,"path":128,"stem":129,"description":130,"icon":131},"Data source","\u002Fdocs\u002Findexing\u002Fdata-source","docs\u002F4.indexing\u002F6.data-source","Let Zaproo download your product feed on a schedule, map it to documents, write only what changed and delete what left the feed.","i-lucide-rss",{"title":133,"description":134,"icon":135,"path":136,"stem":137,"children":138,"page":46},"Integrations","Connect your shop. Magento 2, product feeds and the API work today; more platforms are coming.","i-lucide-plug-zap","\u002Fdocs\u002Fintegrations","docs\u002F4.integrations",[139,145,151,156,162,168,173,178,183,188,193],{"title":140,"path":141,"stem":142,"description":143,"icon":144},"Integrations overview","\u002Fdocs\u002Fintegrations\u002Foverview","docs\u002F4.integrations\u002F01.overview","The ways to get your catalog into Zaproo Search, which one to pick, and how a connected shop shows up in the cabinet.","i-lucide-layout-grid",{"title":146,"path":147,"stem":148,"description":149,"icon":150},"Magento 2","\u002Fdocs\u002Fintegrations\u002Fmagento","docs\u002F4.integrations\u002F02.magento","Install the Zaproo Search module for Magento 2, connect each store view to its own index, and keep the catalog in sync.","i-lucide-shopping-cart",{"title":152,"path":153,"stem":154,"description":155,"icon":131},"Product feed","\u002Fdocs\u002Fintegrations\u002Fproduct-feed","docs\u002F4.integrations\u002F03.product-feed","Connect any shop that can publish its catalog as a feed. You set it up in the cabinet, and Zaproo downloads the feed on a schedule and writes only what changed.",{"title":157,"path":158,"stem":159,"description":160,"icon":161},"REST API and MCP","\u002Fdocs\u002Fintegrations\u002Frest-api-and-mcp","docs\u002F4.integrations\u002F04.rest-api-and-mcp","Send documents from your own code with the REST API, or let an AI agent manage the index over MCP.","i-lucide-code",{"title":163,"path":164,"stem":165,"description":166,"icon":167},"Shopify","\u002Fdocs\u002Fintegrations\u002Fshopify","docs\u002F4.integrations\u002F05.shopify","A Zaproo Search integration for Shopify is coming soon. Until then, connect the shop through a product feed or the REST API.","i-lucide-shopping-bag",{"title":169,"path":170,"stem":171,"description":172,"icon":167},"WooCommerce","\u002Fdocs\u002Fintegrations\u002Fwoocommerce","docs\u002F4.integrations\u002F06.woocommerce","A Zaproo Search integration for WooCommerce is coming soon. Until then, connect the shop through a product feed or the REST API.",{"title":174,"path":175,"stem":176,"description":177,"icon":167},"Shopware","\u002Fdocs\u002Fintegrations\u002Fshopware","docs\u002F4.integrations\u002F07.shopware","A Zaproo Search integration for Shopware is coming soon. Until then, connect the shop through a product feed or the REST API.",{"title":179,"path":180,"stem":181,"description":182,"icon":167},"BigCommerce","\u002Fdocs\u002Fintegrations\u002Fbigcommerce","docs\u002F4.integrations\u002F08.bigcommerce","A Zaproo Search integration for BigCommerce is coming soon. Until then, connect the shop through a product feed or the REST API.",{"title":184,"path":185,"stem":186,"description":187,"icon":167},"PrestaShop","\u002Fdocs\u002Fintegrations\u002Fprestashop","docs\u002F4.integrations\u002F09.prestashop","A Zaproo Search integration for PrestaShop is coming soon. Until then, connect the shop through a product feed or the REST API.",{"title":189,"path":190,"stem":191,"description":192,"icon":167},"commercetools","\u002Fdocs\u002Fintegrations\u002Fcommercetools","docs\u002F4.integrations\u002F10.commercetools","A Zaproo Search integration for commercetools is coming soon. Until then, connect the shop through a product feed or the REST API.",{"title":194,"path":195,"stem":196,"description":197,"icon":167},"Salesforce Commerce Cloud","\u002Fdocs\u002Fintegrations\u002Fsalesforce-commerce-cloud","docs\u002F4.integrations\u002F11.salesforce-commerce-cloud","A Zaproo Search integration for Salesforce Commerce Cloud is coming soon. Until then, connect the shop through a product feed or the REST API.",{"title":199,"description":200,"icon":201,"path":202,"stem":203,"children":204,"page":46},"Search and relevance","The search API, search profiles, facets, synonyms and ranking rules.","i-lucide-search","\u002Fdocs\u002Fsearch","docs\u002F5.search",[205,211,217,223,229,235],{"title":206,"path":207,"stem":208,"description":209,"icon":210},"Search API","\u002Fdocs\u002Fsearch\u002Fsearch-api","docs\u002F5.search\u002F1.search-api","Try a search in the playground, then the search request and response for developers, with every filter form, sorting, paging, highlighting and the inline profile.","i-lucide-search-code",{"title":212,"path":213,"stem":214,"description":215,"icon":216},"Search profiles","\u002Fdocs\u002Fsearch\u002Fprofiles","docs\u002F5.search\u002F2.profiles","Every setting of a search profile, what it does to results, and the mistakes to avoid.","i-lucide-sliders-horizontal",{"title":218,"path":219,"stem":220,"description":221,"icon":222},"Facets","\u002Fdocs\u002Fsearch\u002Ffacets","docs\u002F5.search\u002F3.facets","The filter panels next to the results, the four facet types, index facets and profile facets, and how a shopper's clicks change the counts.","i-lucide-list-filter",{"title":224,"path":225,"stem":226,"description":227,"icon":228},"Synonyms","\u002Fdocs\u002Fsearch\u002Fsynonyms","docs\u002F5.search\u002F4.synonyms","Let different words find the same products, with equivalent and one-way rules, bulk import and export in the Solr format, and no reindex.","i-lucide-arrow-left-right",{"title":230,"path":231,"stem":232,"description":233,"icon":234},"Ranking rules","\u002Fdocs\u002Fsearch\u002Frules","docs\u002F5.search\u002F5.rules","Change the results for chosen searches. Put products first, hide them, lift or lower a brand, narrow the results or weigh fields differently, on a schedule and per profile.","i-lucide-list-ordered",{"title":236,"path":237,"stem":238,"description":239,"icon":240},"Language groups","\u002Fdocs\u002Fsearch\u002Flanguage-groups","docs\u002F5.search\u002F6.language-groups","Let each store of a multilingual shop find its products by the other stores' text, so an English search on the Estonian store still finds the Estonian product.","i-lucide-languages",{"title":242,"description":243,"icon":244,"path":245,"stem":246,"children":247,"page":46},"Autocomplete","Query suggestions as the shopper types.","i-lucide-text-cursor-input","\u002Fdocs\u002Fautocomplete","docs\u002F6.autocomplete",[248],{"title":242,"path":249,"stem":250,"description":251,"icon":244},"\u002Fdocs\u002Fautocomplete\u002Fsuggestions","docs\u002F6.autocomplete\u002F1.suggestions","Set up query suggestions in the cabinet. They are built every hour from your shoppers' searches, field values and custom entries.",{"title":253,"description":254,"icon":255,"path":256,"stem":257,"children":258,"page":46},"Analytics","Searches, zero-result queries and latency.","i-lucide-chart-line","\u002Fdocs\u002Fanalytics","docs\u002F7.analytics",[259,264,270],{"title":260,"path":261,"stem":262,"description":263,"icon":255},"Search analytics","\u002Fdocs\u002Fanalytics\u002Fsearch-analytics","docs\u002F7.analytics\u002F1.search-analytics","What the analytics page counts, which traffic it leaves out, how the headline numbers are defined, how comparisons and retention work, and how to get the weekly digest.",{"title":265,"path":266,"stem":267,"description":268,"icon":269},"Reports","\u002Fdocs\u002Fanalytics\u002Freports","docs\u002F7.analytics\u002F2.reports","Every analytics report with the definition of each column, the opportunities list and its fix buttons, the per-query view with before and after, and the CSV download.","i-lucide-table",{"title":271,"path":272,"stem":273,"description":274,"icon":275},"Event tracking","\u002Fdocs\u002Fanalytics\u002Fevent-tracking","docs\u002F7.analytics\u002F3.event-tracking","Send clicks, add-to-cart, purchases and suggestion clicks from your storefront, tie them to the search with searchId, and a copy-paste script that does it.","i-lucide-mouse-pointer-click",{"title":277,"description":278,"icon":279,"path":280,"stem":281,"children":282,"page":46},"AI agents (MCP)","Connect Claude Code or any MCP client and manage search from an agent.","i-lucide-bot","\u002Fdocs\u002Fmcp","docs\u002F8.mcp",[283,289,295],{"title":284,"path":285,"stem":286,"description":287,"icon":288},"MCP setup","\u002Fdocs\u002Fmcp\u002Fsetup","docs\u002F8.mcp\u002F1.setup","Connect Claude Code or another MCP client to your project from the cabinet's MCP connection page, and let an agent manage indices, documents, profiles, synonyms and rules.","i-lucide-plug",{"title":290,"path":291,"stem":292,"description":293,"icon":294},"MCP tools","\u002Fdocs\u002Fmcp\u002Ftools","docs\u002F8.mcp\u002F2.tools","Every tool the Zaproo Search MCP server offers, what an agent can do with each group, and prompts to start from.","i-lucide-wrench",{"title":296,"path":297,"stem":298,"description":299,"icon":300},"Resources and prompts","\u002Fdocs\u002Fmcp\u002Fresources","docs\u002F8.mcp\u002F3.resources","The index resources an MCP client can read, the tune_relevance prompt, and the errors the MCP server answers.","i-lucide-library",{"title":302,"description":303,"icon":304,"path":305,"stem":306,"children":307,"page":46},"Reference","Every REST route, every limit, plans and billing, and status.","i-lucide-book-open","\u002Fdocs\u002Freference","docs\u002F9.reference",[308,314,319,325],{"title":309,"path":310,"stem":311,"description":312,"icon":313},"REST API","\u002Fdocs\u002Freference\u002Frest-api","docs\u002F9.reference\u002F1.rest-api","The routes of the Zaproo Search REST API, grouped by area, with who may call it.","i-lucide-list-tree",{"title":315,"path":316,"stem":317,"description":318,"icon":89},"Limits","\u002Fdocs\u002Freference\u002Flimits","docs\u002F9.reference\u002F2.limits","Every size limit, cap and default of the Zaproo Search API in one place, with what happens when you reach it.",{"title":320,"path":321,"stem":322,"description":323,"icon":324},"Plans and billing","\u002Fdocs\u002Freference\u002Fbilling","docs\u002F9.reference\u002F3.billing","Check your plan and usage on the Billing & usage page, change the plan, download invoices, and see how quotas and proration work.","i-lucide-credit-card",{"title":326,"path":327,"stem":328,"description":329,"icon":330},"Status","\u002Fdocs\u002Freference\u002Fstatus","docs\u002F9.reference\u002F4.status","The status page and the status route, what each service covers and how to use them in your own monitoring.","i-lucide-activity",{"id":332,"title":35,"body":333,"description":38,"extension":3961,"meta":3962,"navigation":3963,"path":36,"seo":3964,"stem":37,"__hash__":3965},"docs\u002Fdocs\u002F1.getting-started\u002F4.javascript-sdk.md",{"type":334,"value":335,"toc":3947},"minimark",[336,341,365,372,376,401,404,408,416,521,623,626,629,638,771,778,807,810,839,848,851,856,902,909,1079,1089,1211,1215,1229,1464,1477,1496,1506,1509,1512,1567,1570,1576,1580,1583,1612,3390,3393,3398,3453,3459,3463,3484,3598,3689,3702,3706,3745,3917,3921,3943],[337,338,340],"h2",{"id":339},"what-it-does","What it does",[342,343,344,348,349,352,353,356,357,360,361,364],"p",{},[345,346,347],"code",{},"@zaprooecommerce\u002Fsearch-js-sdk"," wraps the three routes a storefront calls: search, suggest and events. You create a client once with your keys, then call ",[345,350,351],{},"search",", ",[345,354,355],{},"suggest"," and ",[345,358,359],{},"track",". It has no dependencies and works anywhere ",[345,362,363],{},"fetch"," does: browsers, Node 18 and later, and edge runtimes. React, Vue, Nuxt, Next.js and plain JavaScript all use it the same way.",[342,366,367,368,371],{},"Answers are plain JSON. A search made while your server renders the page can be handed to the browser as is, and its ",[345,369,370],{},"searchId"," goes with it.",[337,373,375],{"id":374},"install","Install",[377,378,383],"pre",{"className":379,"code":380,"language":381,"meta":382,"style":382},"language-bash shiki shiki-themes github-light-high-contrast github-light-high-contrast github-dark-high-contrast","npm install @zaprooecommerce\u002Fsearch-js-sdk\n","bash","",[345,384,385],{"__ignoreMap":382},[386,387,390,394,398],"span",{"class":388,"line":389},"line",1,[386,391,393],{"class":392},"szw1H","npm",[386,395,397],{"class":396},"semJd"," install",[386,399,400],{"class":396}," @zaprooecommerce\u002Fsearch-js-sdk\n",[342,402,403],{},"The package also installs with pnpm, yarn or bun.",[337,405,407],{"id":406},"create-the-client","Create the client",[342,409,410,411,415],{},"You need the public API key, the search profile's key and, for autocomplete, the suggest key. ",[412,413,29],"a",{"href":414},"\u002Fdocs\u002Fgetting-started\u002Fstorefront#find-the-keys-in-the-cabinet"," shows where each one is in the cabinet.",[377,417,421],{"className":418,"code":419,"language":420,"meta":382,"style":382},"language-ts shiki shiki-themes github-light-high-contrast github-light-high-contrast github-dark-high-contrast","import { createZaprooSearch } from '@zaprooecommerce\u002Fsearch-js-sdk';\n\nexport const zaprooSearch = createZaprooSearch({\n  apiKey: 'zs_pk_...', \u002F\u002F public key, allowed on https:\u002F\u002Fshop.example.com\n  profileKey: 'Ab3dE9xQk2LmP0sT', \u002F\u002F the search profile\n  suggestKey: 'Zy8xWv7uTs6rQp5o', \u002F\u002F the autocomplete config\n});\n","ts",[345,422,423,442,449,472,487,501,515],{"__ignoreMap":382},[386,424,425,429,433,436,439],{"class":388,"line":389},[386,426,428],{"class":427},"sklAV","import",[386,430,432],{"class":431},"s7iLA"," { createZaprooSearch } ",[386,434,435],{"class":427},"from",[386,437,438],{"class":396}," '@zaprooecommerce\u002Fsearch-js-sdk'",[386,440,441],{"class":431},";\n",[386,443,445],{"class":388,"line":444},2,[386,446,448],{"emptyLinePlaceholder":447},true,"\n",[386,450,452,455,458,462,465,469],{"class":388,"line":451},3,[386,453,454],{"class":427},"export",[386,456,457],{"class":427}," const",[386,459,461],{"class":460},"ssYy9"," zaprooSearch",[386,463,464],{"class":427}," =",[386,466,468],{"class":467},"s6m-Y"," createZaprooSearch",[386,470,471],{"class":431},"({\n",[386,473,475,478,481,483],{"class":388,"line":474},4,[386,476,477],{"class":431},"  apiKey: ",[386,479,480],{"class":396},"'zs_pk_...'",[386,482,352],{"class":431},[386,484,486],{"class":485},"sq92B","\u002F\u002F public key, allowed on https:\u002F\u002Fshop.example.com\n",[386,488,490,493,496,498],{"class":388,"line":489},5,[386,491,492],{"class":431},"  profileKey: ",[386,494,495],{"class":396},"'Ab3dE9xQk2LmP0sT'",[386,497,352],{"class":431},[386,499,500],{"class":485},"\u002F\u002F the search profile\n",[386,502,504,507,510,512],{"class":388,"line":503},6,[386,505,506],{"class":431},"  suggestKey: ",[386,508,509],{"class":396},"'Zy8xWv7uTs6rQp5o'",[386,511,352],{"class":431},[386,513,514],{"class":485},"\u002F\u002F the autocomplete config\n",[386,516,518],{"class":388,"line":517},7,[386,519,520],{"class":431},"});\n",[522,523,524,542,548,560,575,586,596,614],"field-group",{},[525,526,530],"field",{"name":527,"type":528,":required":529},"apiKey","string","true",[342,531,532,533,536,537,541],{},"The API key. In the browser, a public key (",[345,534,535],{},"zs_pk_...",") whose ",[538,539,540],"strong",{},"Allowed origins"," list your shop's domains. On your server, a secret key with read access also works. Never put a secret key in browser code.",[525,543,545],{"name":544,"type":528,":required":529},"profileKey",[342,546,547],{},"The search profile to search with. Events go to this profile too.",[525,549,551],{"name":550,"type":528},"suggestKey",[342,552,553,554,556,557,559],{},"The suggest key from the index's ",[538,555,242],{}," page. Only ",[345,558,355],{}," needs it.",[525,561,563],{"name":562,"type":528},"baseUrl",[342,564,565,566,569,570,574],{},"The API address. Defaults to ",[345,567,568],{},"https:\u002F\u002Fapi.search.zaproo.cloud",". Set it to switch between staging and live, see ",[412,571,573],{"href":572},"#staging-and-live","Staging and live",".",[525,576,579],{"name":577,"type":578},"sessionId","string | null",[342,580,581,582,574],{},"The visitor's session id. See ",[412,583,585],{"href":584},"#sessions","Sessions",[525,587,589],{"name":588,"type":528},"origin",[342,590,591,592,595],{},"Server only. The shop's address, sent as the ",[345,593,594],{},"Origin"," header so a public key works from your server. The browser sets this header itself and ignores the option.",[525,597,600],{"name":598,"type":599},"headers","object",[342,601,602,603,606,607,356,610,613],{},"Server only. Extra request headers, such as the shopper's ",[345,604,605],{},"User-Agent",". The browser ignores them, because the API accepts only ",[345,608,609],{},"Authorization",[345,611,612],{},"Content-Type"," from a web page.",[525,615,617],{"name":363,"type":616},"function",[342,618,619,620,622],{},"Your own ",[345,621,363],{},", for runtimes without a global one or for tests.",[342,624,625],{},"Create one client and share it. A client holds no results and no state besides the session id, so the same one can serve every page.",[337,627,628],{"id":351},"Search",[342,630,631,633,634,637],{},[345,632,351],{}," takes the same body as ",[412,635,636],{"href":207},"the search route",": the query, the filters, the sort and the page. Everything else comes from the profile.",[377,639,641],{"className":418,"code":640,"language":420,"meta":382,"style":382},"const results = await zaprooSearch.search({\n  q: 'packing tape',\n  filters: { color: ['Brown', 'Clear'], price: { lte: 5 } },\n  sort: 'price:asc',\n  page: 1,\n  perPage: 24,\n});\n\nresults.total; \u002F\u002F 42\nresults.items; \u002F\u002F [{ id: 'tape-48', title: 'Brown packaging tape 48mm', price: 1.86, ... }]\nresults.facets; \u002F\u002F [{ type: 'terms', field: 'color', label: 'Color', items: [...] }]\nresults.searchId; \u002F\u002F '8f2Kq9xWv1pLmN3cT6yZ0a', keep it for event tracking\n",[345,642,643,663,674,696,706,716,726,730,735,744,753,762],{"__ignoreMap":382},[386,644,645,648,651,653,656,659,661],{"class":388,"line":389},[386,646,647],{"class":427},"const",[386,649,650],{"class":460}," results",[386,652,464],{"class":427},[386,654,655],{"class":427}," await",[386,657,658],{"class":431}," zaprooSearch.",[386,660,351],{"class":467},[386,662,471],{"class":431},[386,664,665,668,671],{"class":388,"line":444},[386,666,667],{"class":431},"  q: ",[386,669,670],{"class":396},"'packing tape'",[386,672,673],{"class":431},",\n",[386,675,676,679,682,684,687,690,693],{"class":388,"line":451},[386,677,678],{"class":431},"  filters: { color: [",[386,680,681],{"class":396},"'Brown'",[386,683,352],{"class":431},[386,685,686],{"class":396},"'Clear'",[386,688,689],{"class":431},"], price: { lte: ",[386,691,692],{"class":460},"5",[386,694,695],{"class":431}," } },\n",[386,697,698,701,704],{"class":388,"line":474},[386,699,700],{"class":431},"  sort: ",[386,702,703],{"class":396},"'price:asc'",[386,705,673],{"class":431},[386,707,708,711,714],{"class":388,"line":489},[386,709,710],{"class":431},"  page: ",[386,712,713],{"class":460},"1",[386,715,673],{"class":431},[386,717,718,721,724],{"class":388,"line":503},[386,719,720],{"class":431},"  perPage: ",[386,722,723],{"class":460},"24",[386,725,673],{"class":431},[386,727,728],{"class":388,"line":517},[386,729,520],{"class":431},[386,731,733],{"class":388,"line":732},8,[386,734,448],{"emptyLinePlaceholder":447},[386,736,738,741],{"class":388,"line":737},9,[386,739,740],{"class":431},"results.total; ",[386,742,743],{"class":485},"\u002F\u002F 42\n",[386,745,747,750],{"class":388,"line":746},10,[386,748,749],{"class":431},"results.items; ",[386,751,752],{"class":485},"\u002F\u002F [{ id: 'tape-48', title: 'Brown packaging tape 48mm', price: 1.86, ... }]\n",[386,754,756,759],{"class":388,"line":755},11,[386,757,758],{"class":431},"results.facets; ",[386,760,761],{"class":485},"\u002F\u002F [{ type: 'terms', field: 'color', label: 'Color', items: [...] }]\n",[386,763,765,768],{"class":388,"line":764},12,[386,766,767],{"class":431},"results.searchId; ",[386,769,770],{"class":485},"\u002F\u002F '8f2Kq9xWv1pLmN3cT6yZ0a', keep it for event tracking\n",[342,772,773,774,777],{},"An empty ",[345,775,776],{},"q"," returns every product that passes the filters, which is how a category page works:",[377,779,781],{"className":418,"code":780,"language":420,"meta":382,"style":382},"const category = await zaprooSearch.search({ filters: { categories: ['Tapes>Duct tapes'] } });\n",[345,782,783],{"__ignoreMap":382},[386,784,785,787,790,792,794,796,798,801,804],{"class":388,"line":389},[386,786,647],{"class":427},[386,788,789],{"class":460}," category",[386,791,464],{"class":427},[386,793,655],{"class":427},[386,795,658],{"class":431},[386,797,351],{"class":467},[386,799,800],{"class":431},"({ filters: { categories: [",[386,802,803],{"class":396},"'Tapes>Duct tapes'",[386,805,806],{"class":431},"] } });\n",[342,808,809],{},"To search with another profile for one call, pass its key as the second argument:",[377,811,813],{"className":418,"code":812,"language":420,"meta":382,"style":382},"await zaprooSearch.search({ q: 'tape' }, { profileKey: 'Pq7rS2tUv4WxY6zA' });\n",[345,814,815],{"__ignoreMap":382},[386,816,817,820,822,824,827,830,833,836],{"class":388,"line":389},[386,818,819],{"class":427},"await",[386,821,658],{"class":431},[386,823,351],{"class":467},[386,825,826],{"class":431},"({ q: ",[386,828,829],{"class":396},"'tape'",[386,831,832],{"class":431}," }, { profileKey: ",[386,834,835],{"class":396},"'Pq7rS2tUv4WxY6zA'",[386,837,838],{"class":431}," });\n",[342,840,841,844,845,847],{},[412,842,29],{"href":843},"\u002Fdocs\u002Fgetting-started\u002Fstorefront#search-results-page"," explains how to draw the results, the pager and the did-you-mean line. ",[412,846,218],{"href":219}," explains how each facet type turns into a filter.",[337,849,242],{"id":850},"autocomplete",[342,852,853,855],{},[345,854,355],{}," sends what the shopper has typed so far, up to 100 characters. An empty string returns the most searched queries, if autocomplete is set to show them.",[377,857,859],{"className":418,"code":858,"language":420,"meta":382,"style":382},"const { suggestions, searchProfileKey } = await zaprooSearch.suggest('ta');\n\u002F\u002F suggestions: [{ text: 'duct tape', kind: 'query', facetHint: { key: 'categories', value: 'Tapes>Duct tapes' } }, ...]\n",[345,860,861,897],{"__ignoreMap":382},[386,862,863,865,868,871,873,876,879,882,884,886,888,891,894],{"class":388,"line":389},[386,864,647],{"class":427},[386,866,867],{"class":431}," { ",[386,869,870],{"class":460},"suggestions",[386,872,352],{"class":431},[386,874,875],{"class":460},"searchProfileKey",[386,877,878],{"class":431}," } ",[386,880,881],{"class":427},"=",[386,883,655],{"class":427},[386,885,658],{"class":431},[386,887,355],{"class":467},[386,889,890],{"class":431},"(",[386,892,893],{"class":396},"'ta'",[386,895,896],{"class":431},");\n",[386,898,899],{"class":388,"line":444},[386,900,901],{"class":485},"\u002F\u002F suggestions: [{ text: 'duct tape', kind: 'query', facetHint: { key: 'categories', value: 'Tapes>Duct tapes' } }, ...]\n",[342,903,904,905,908],{},"When the shopper types fast, cancel the request that is still running. Every call takes an ",[345,906,907],{},"AbortSignal",":",[377,910,912],{"className":418,"code":911,"language":420,"meta":382,"style":382},"let controller: AbortController | undefined;\n\nasync function onInput(text: string) {\n  controller?.abort();\n  controller = new AbortController();\n  try {\n    const { suggestions } = await zaprooSearch.suggest(text, { signal: controller.signal });\n    showSuggestions(suggestions);\n  } catch (error) {\n    if ((error as Error).name !== 'AbortError') throw error;\n  }\n}\n",[345,913,914,935,939,963,974,988,996,1018,1026,1037,1069,1074],{"__ignoreMap":382},[386,915,916,919,922,924,927,930,933],{"class":388,"line":389},[386,917,918],{"class":427},"let",[386,920,921],{"class":431}," controller",[386,923,908],{"class":427},[386,925,926],{"class":392}," AbortController",[386,928,929],{"class":427}," |",[386,931,932],{"class":460}," undefined",[386,934,441],{"class":431},[386,936,937],{"class":388,"line":444},[386,938,448],{"emptyLinePlaceholder":447},[386,940,941,944,947,950,952,955,957,960],{"class":388,"line":451},[386,942,943],{"class":427},"async",[386,945,946],{"class":427}," function",[386,948,949],{"class":467}," onInput",[386,951,890],{"class":431},[386,953,954],{"class":392},"text",[386,956,908],{"class":427},[386,958,959],{"class":460}," string",[386,961,962],{"class":431},") {\n",[386,964,965,968,971],{"class":388,"line":474},[386,966,967],{"class":431},"  controller?.",[386,969,970],{"class":467},"abort",[386,972,973],{"class":431},"();\n",[386,975,976,979,981,984,986],{"class":388,"line":489},[386,977,978],{"class":431},"  controller ",[386,980,881],{"class":427},[386,982,983],{"class":427}," new",[386,985,926],{"class":467},[386,987,973],{"class":431},[386,989,990,993],{"class":388,"line":503},[386,991,992],{"class":427},"  try",[386,994,995],{"class":431}," {\n",[386,997,998,1001,1003,1005,1007,1009,1011,1013,1015],{"class":388,"line":517},[386,999,1000],{"class":427},"    const",[386,1002,867],{"class":431},[386,1004,870],{"class":460},[386,1006,878],{"class":431},[386,1008,881],{"class":427},[386,1010,655],{"class":427},[386,1012,658],{"class":431},[386,1014,355],{"class":467},[386,1016,1017],{"class":431},"(text, { signal: controller.signal });\n",[386,1019,1020,1023],{"class":388,"line":732},[386,1021,1022],{"class":467},"    showSuggestions",[386,1024,1025],{"class":431},"(suggestions);\n",[386,1027,1028,1031,1034],{"class":388,"line":737},[386,1029,1030],{"class":431},"  } ",[386,1032,1033],{"class":427},"catch",[386,1035,1036],{"class":431}," (error) {\n",[386,1038,1039,1042,1045,1048,1051,1054,1057,1060,1063,1066],{"class":388,"line":746},[386,1040,1041],{"class":427},"    if",[386,1043,1044],{"class":431}," ((error ",[386,1046,1047],{"class":427},"as",[386,1049,1050],{"class":392}," Error",[386,1052,1053],{"class":431},").name ",[386,1055,1056],{"class":427},"!==",[386,1058,1059],{"class":396}," 'AbortError'",[386,1061,1062],{"class":431},") ",[386,1064,1065],{"class":427},"throw",[386,1067,1068],{"class":431}," error;\n",[386,1070,1071],{"class":388,"line":755},[386,1072,1073],{"class":431},"  }\n",[386,1075,1076],{"class":388,"line":764},[386,1077,1078],{"class":431},"}\n",[342,1080,1081,1082,1084,1085,1088],{},"When the shopper picks a suggestion, search for its ",[345,1083,954],{}," with the profile the suggest answer named. If the suggestion has a ",[345,1086,1087],{},"facetHint",", add it as a filter:",[377,1090,1092],{"className":418,"code":1091,"language":420,"meta":382,"style":382},"import type { Suggestion } from '@zaprooecommerce\u002Fsearch-js-sdk';\n\nasync function onPick(pick: Suggestion, searchProfileKey: string | null) {\n  const filters = pick.facetHint ? { [pick.facetHint.key]: [pick.facetHint.value] } : {};\n  zaprooSearch.track({ type: 'suggestion_click', suggestion: pick.text });\n  return zaprooSearch.search({ q: pick.text, filters }, { profileKey: searchProfileKey ?? undefined });\n}\n",[345,1093,1094,1110,1114,1148,1172,1188,1207],{"__ignoreMap":382},[386,1095,1096,1098,1101,1104,1106,1108],{"class":388,"line":389},[386,1097,428],{"class":427},[386,1099,1100],{"class":427}," type",[386,1102,1103],{"class":431}," { Suggestion } ",[386,1105,435],{"class":427},[386,1107,438],{"class":396},[386,1109,441],{"class":431},[386,1111,1112],{"class":388,"line":444},[386,1113,448],{"emptyLinePlaceholder":447},[386,1115,1116,1118,1120,1123,1125,1128,1130,1133,1135,1137,1139,1141,1143,1146],{"class":388,"line":451},[386,1117,943],{"class":427},[386,1119,946],{"class":427},[386,1121,1122],{"class":467}," onPick",[386,1124,890],{"class":431},[386,1126,1127],{"class":392},"pick",[386,1129,908],{"class":427},[386,1131,1132],{"class":392}," Suggestion",[386,1134,352],{"class":431},[386,1136,875],{"class":392},[386,1138,908],{"class":427},[386,1140,959],{"class":460},[386,1142,929],{"class":427},[386,1144,1145],{"class":460}," null",[386,1147,962],{"class":431},[386,1149,1150,1153,1156,1158,1161,1164,1167,1169],{"class":388,"line":474},[386,1151,1152],{"class":427},"  const",[386,1154,1155],{"class":460}," filters",[386,1157,464],{"class":427},[386,1159,1160],{"class":431}," pick.facetHint ",[386,1162,1163],{"class":427},"?",[386,1165,1166],{"class":431}," { [pick.facetHint.key]: [pick.facetHint.value] } ",[386,1168,908],{"class":427},[386,1170,1171],{"class":431}," {};\n",[386,1173,1174,1177,1179,1182,1185],{"class":388,"line":489},[386,1175,1176],{"class":431},"  zaprooSearch.",[386,1178,359],{"class":467},[386,1180,1181],{"class":431},"({ type: ",[386,1183,1184],{"class":396},"'suggestion_click'",[386,1186,1187],{"class":431},", suggestion: pick.text });\n",[386,1189,1190,1193,1195,1197,1200,1203,1205],{"class":388,"line":503},[386,1191,1192],{"class":427},"  return",[386,1194,658],{"class":431},[386,1196,351],{"class":467},[386,1198,1199],{"class":431},"({ q: pick.text, filters }, { profileKey: searchProfileKey ",[386,1201,1202],{"class":427},"??",[386,1204,932],{"class":460},[386,1206,838],{"class":431},[386,1208,1209],{"class":388,"line":517},[386,1210,1078],{"class":431},[337,1212,1214],{"id":1213},"track-what-shoppers-do","Track what shoppers do",[342,1216,1217,1218,1221,1222,1224,1225,1228],{},"Events tell the ",[412,1219,1220],{"href":266},"reports"," which results got clicked, put in the cart and bought. Send each event with the ",[345,1223,370],{}," of the search that showed the product. ",[345,1226,1227],{},"position"," is the result's place on the page, starting at 1.",[377,1230,1232],{"className":418,"code":1231,"language":420,"meta":382,"style":382},"const { searchId, items } = await zaprooSearch.search({ q: 'packing tape' });\n\n\u002F\u002F The shopper opens the second result.\nawait zaprooSearch.track({ type: 'click', searchId: searchId!, itemId: items[1].id, position: 2 });\n\n\u002F\u002F They put it in the cart. price is one unit.\nawait zaprooSearch.track({ type: 'add_to_cart', searchId: searchId!, itemId: 'tape-48', quantity: 3, price: 1.86, currency: 'EUR' });\n\n\u002F\u002F They place the order. Send every order, also those that did not come from search.\nawait zaprooSearch.track({\n  type: 'purchase',\n  orderId: '100042',\n  currency: 'EUR',\n  items: [\n    { itemId: 'tape-48', quantity: 3, price: 1.86, searchId: searchId! },\n    { itemId: 'box-300', quantity: 2, price: 0.32 },\n  ],\n});\n",[345,1233,1234,1263,1267,1272,1304,1308,1313,1356,1360,1365,1375,1385,1395,1405,1411,1434,1453,1459],{"__ignoreMap":382},[386,1235,1236,1238,1240,1242,1244,1247,1249,1251,1253,1255,1257,1259,1261],{"class":388,"line":389},[386,1237,647],{"class":427},[386,1239,867],{"class":431},[386,1241,370],{"class":460},[386,1243,352],{"class":431},[386,1245,1246],{"class":460},"items",[386,1248,878],{"class":431},[386,1250,881],{"class":427},[386,1252,655],{"class":427},[386,1254,658],{"class":431},[386,1256,351],{"class":467},[386,1258,826],{"class":431},[386,1260,670],{"class":396},[386,1262,838],{"class":431},[386,1264,1265],{"class":388,"line":444},[386,1266,448],{"emptyLinePlaceholder":447},[386,1268,1269],{"class":388,"line":451},[386,1270,1271],{"class":485},"\u002F\u002F The shopper opens the second result.\n",[386,1273,1274,1276,1278,1280,1282,1285,1288,1291,1294,1296,1299,1302],{"class":388,"line":474},[386,1275,819],{"class":427},[386,1277,658],{"class":431},[386,1279,359],{"class":467},[386,1281,1181],{"class":431},[386,1283,1284],{"class":396},"'click'",[386,1286,1287],{"class":431},", searchId: searchId",[386,1289,1290],{"class":427},"!",[386,1292,1293],{"class":431},", itemId: items[",[386,1295,713],{"class":460},[386,1297,1298],{"class":431},"].id, position: ",[386,1300,1301],{"class":460},"2",[386,1303,838],{"class":431},[386,1305,1306],{"class":388,"line":489},[386,1307,448],{"emptyLinePlaceholder":447},[386,1309,1310],{"class":388,"line":503},[386,1311,1312],{"class":485},"\u002F\u002F They put it in the cart. price is one unit.\n",[386,1314,1315,1317,1319,1321,1323,1326,1328,1330,1333,1336,1339,1342,1345,1348,1351,1354],{"class":388,"line":517},[386,1316,819],{"class":427},[386,1318,658],{"class":431},[386,1320,359],{"class":467},[386,1322,1181],{"class":431},[386,1324,1325],{"class":396},"'add_to_cart'",[386,1327,1287],{"class":431},[386,1329,1290],{"class":427},[386,1331,1332],{"class":431},", itemId: ",[386,1334,1335],{"class":396},"'tape-48'",[386,1337,1338],{"class":431},", quantity: ",[386,1340,1341],{"class":460},"3",[386,1343,1344],{"class":431},", price: ",[386,1346,1347],{"class":460},"1.86",[386,1349,1350],{"class":431},", currency: ",[386,1352,1353],{"class":396},"'EUR'",[386,1355,838],{"class":431},[386,1357,1358],{"class":388,"line":732},[386,1359,448],{"emptyLinePlaceholder":447},[386,1361,1362],{"class":388,"line":737},[386,1363,1364],{"class":485},"\u002F\u002F They place the order. Send every order, also those that did not come from search.\n",[386,1366,1367,1369,1371,1373],{"class":388,"line":746},[386,1368,819],{"class":427},[386,1370,658],{"class":431},[386,1372,359],{"class":467},[386,1374,471],{"class":431},[386,1376,1377,1380,1383],{"class":388,"line":755},[386,1378,1379],{"class":431},"  type: ",[386,1381,1382],{"class":396},"'purchase'",[386,1384,673],{"class":431},[386,1386,1387,1390,1393],{"class":388,"line":764},[386,1388,1389],{"class":431},"  orderId: ",[386,1391,1392],{"class":396},"'100042'",[386,1394,673],{"class":431},[386,1396,1398,1401,1403],{"class":388,"line":1397},13,[386,1399,1400],{"class":431},"  currency: ",[386,1402,1353],{"class":396},[386,1404,673],{"class":431},[386,1406,1408],{"class":388,"line":1407},14,[386,1409,1410],{"class":431},"  items: [\n",[386,1412,1414,1417,1419,1421,1423,1425,1427,1429,1431],{"class":388,"line":1413},15,[386,1415,1416],{"class":431},"    { itemId: ",[386,1418,1335],{"class":396},[386,1420,1338],{"class":431},[386,1422,1341],{"class":460},[386,1424,1344],{"class":431},[386,1426,1347],{"class":460},[386,1428,1287],{"class":431},[386,1430,1290],{"class":427},[386,1432,1433],{"class":431}," },\n",[386,1435,1437,1439,1442,1444,1446,1448,1451],{"class":388,"line":1436},16,[386,1438,1416],{"class":431},[386,1440,1441],{"class":396},"'box-300'",[386,1443,1338],{"class":431},[386,1445,1301],{"class":460},[386,1447,1344],{"class":431},[386,1449,1450],{"class":460},"0.32",[386,1452,1433],{"class":431},[386,1454,1456],{"class":388,"line":1455},17,[386,1457,1458],{"class":431},"  ],\n",[386,1460,1462],{"class":388,"line":1461},18,[386,1463,520],{"class":431},[342,1465,1466,1468,1469,1472,1473,1476],{},[345,1467,359],{}," takes one event or an array of them and resolves to ",[345,1470,1471],{},"{ accepted }",", the number of events the API took. A long array goes out in batches of 100. The request is sent with ",[345,1474,1475],{},"keepalive",", so a click that opens another page still arrives.",[342,1478,1479,1481,1482,1485,1486,1489,1490,1492,1493,1495],{},[345,1480,370],{}," is ",[345,1483,1484],{},"null"," for a search that is not logged, such as one with ",[345,1487,1488],{},"analytics: false",". The ",[345,1491,1290],{}," in the examples assumes a logged search; check for ",[345,1494,1484],{}," if you turn analytics off.",[342,1497,1498,1499,1501,1502,1505],{},"The cart and the checkout usually come long after the search, when its id is gone. Send the events anyway, with the same session id. The API ties an event without a ",[345,1500,370],{}," to the latest search of its session in the last 24 hours. ",[412,1503,271],{"href":1504},"\u002Fdocs\u002Fanalytics\u002Fevent-tracking#searchid-and-the-session-fallback"," explains how events are matched to searches.",[337,1507,585],{"id":1508},"sessions",[342,1510,1511],{},"The session id groups one visitor's searches and events. It keeps paging stable and lets the cart and the order find the search that led to them.",[1513,1514,1515,1532],"table",{},[1516,1517,1518],"thead",{},[1519,1520,1521,1526,1529],"tr",{},[1522,1523,1524],"th",{},[345,1525,577],{},[1522,1527,1528],{},"In the browser",[1522,1530,1531],{},"On the server",[1533,1534,1535,1547,1557],"tbody",{},[1519,1536,1537,1541,1544],{},[1538,1539,1540],"td",{},"left out",[1538,1542,1543],{},"A random id made when the client is created, kept in memory. A full page reload starts a new one.",[1538,1545,1546],{},"None.",[1519,1548,1549,1552,1555],{},[1538,1550,1551],{},"a string",[1538,1553,1554],{},"Sent with every search and event.",[1538,1556,1554],{},[1519,1558,1559,1563,1565],{},[1538,1560,1561],{},[345,1562,1484],{},[1538,1564,1546],{},[1538,1566,1546],{},[342,1568,1569],{},"The SDK never writes cookies or browser storage. A visitor id that survives page loads is an analytics identifier, and in many countries storing one needs the visitor's consent. Your shop decides when to store it: set a first-party cookie after the visitor agrees, and pass its value to the client in the browser and on the server. The Nuxt example below does this.",[342,1571,1572,1573,1575],{},"A ",[345,1574,577],{}," you put in a search body or an event yourself is never replaced.",[337,1577,1579],{"id":1578},"server-rendering","Server rendering",[342,1581,1582],{},"Searching while the server renders the page puts the results in the HTML, which helps search engines and the first paint. Two things differ from the browser:",[1584,1585,1586,1600],"ul",{},[1587,1588,1589,1590,1592,1593,1596,1597,1599],"li",{},"A server sends no ",[345,1591,594],{}," header. Use a secret key with read access, limited to the shop's index (see ",[412,1594,80],{"href":1595},"\u002Fdocs\u002Fkeys\u002Fapi-keys#index-scope","). If you prefer the public key, set ",[345,1598,588],{}," to your shop's address instead.",[1587,1601,1602,1603,1605,1606,1608,1609,574],{},"The API sees your server, not the shopper. Pass the shopper's ",[345,1604,605],{}," in ",[345,1607,598],{}," so reports count the right device. Rate limits per client IP count your server as one client, see ",[412,1610,1611],{"href":86},"Rate limits",[1613,1614,1615,2238,2907],"tabs",{},[1616,1617,1620,1627,1731,2027,2229],"tabs-item",{"icon":1618,"label":1619},"i-lucide-triangle","Nuxt",[342,1621,1622,1623,1626],{},"Keep the keys in runtime config. ",[345,1624,1625],{},"NUXT_PUBLIC_ZAPROO_SEARCH_BASE_URL"," then switches the environment without a rebuild.",[377,1628,1630],{"className":418,"code":1629,"language":420,"meta":382,"style":382},"\u002F\u002F nuxt.config.ts\nexport default defineNuxtConfig({\n  runtimeConfig: {\n    zaprooSearchServerKey: '', \u002F\u002F NUXT_ZAPROO_SEARCH_SERVER_KEY, a secret key with read access\n    public: {\n      zaprooSearchApiKey: '', \u002F\u002F the public key\n      zaprooSearchProfileKey: '',\n      zaprooSearchSuggestKey: '',\n      zaprooSearchBaseUrl: 'https:\u002F\u002Fapi.search.zaproo.cloud',\n    },\n  },\n});\n",[345,1631,1632,1637,1649,1654,1667,1672,1684,1693,1702,1712,1717,1724],{"__ignoreMap":382},[386,1633,1634],{"class":388,"line":389},[386,1635,1636],{"class":485},"\u002F\u002F nuxt.config.ts\n",[386,1638,1639,1641,1644,1647],{"class":388,"line":444},[386,1640,454],{"class":427},[386,1642,1643],{"class":427}," default",[386,1645,1646],{"class":467}," defineNuxtConfig",[386,1648,471],{"class":392},[386,1650,1651],{"class":388,"line":451},[386,1652,1653],{"class":431},"  runtimeConfig: {\n",[386,1655,1656,1659,1662,1664],{"class":388,"line":474},[386,1657,1658],{"class":431},"    zaprooSearchServerKey: ",[386,1660,1661],{"class":396},"''",[386,1663,352],{"class":431},[386,1665,1666],{"class":485},"\u002F\u002F NUXT_ZAPROO_SEARCH_SERVER_KEY, a secret key with read access\n",[386,1668,1669],{"class":388,"line":489},[386,1670,1671],{"class":431},"    public: {\n",[386,1673,1674,1677,1679,1681],{"class":388,"line":503},[386,1675,1676],{"class":431},"      zaprooSearchApiKey: ",[386,1678,1661],{"class":396},[386,1680,352],{"class":431},[386,1682,1683],{"class":485},"\u002F\u002F the public key\n",[386,1685,1686,1689,1691],{"class":388,"line":517},[386,1687,1688],{"class":431},"      zaprooSearchProfileKey: ",[386,1690,1661],{"class":396},[386,1692,673],{"class":431},[386,1694,1695,1698,1700],{"class":388,"line":732},[386,1696,1697],{"class":431},"      zaprooSearchSuggestKey: ",[386,1699,1661],{"class":396},[386,1701,673],{"class":431},[386,1703,1704,1707,1710],{"class":388,"line":737},[386,1705,1706],{"class":431},"      zaprooSearchBaseUrl: ",[386,1708,1709],{"class":396},"'https:\u002F\u002Fapi.search.zaproo.cloud'",[386,1711,673],{"class":431},[386,1713,1714],{"class":388,"line":746},[386,1715,1716],{"class":431},"    },\n",[386,1718,1719,1722],{"class":388,"line":755},[386,1720,1721],{"class":431},"  }",[386,1723,673],{"class":392},[386,1725,1726,1729],{"class":388,"line":764},[386,1727,1728],{"class":392},"})",[386,1730,441],{"class":431},[377,1732,1734],{"className":418,"code":1733,"language":420,"meta":382,"style":382},"\u002F\u002F composables\u002FuseZaprooSearch.ts\nimport { createZaprooSearch } from '@zaprooecommerce\u002Fsearch-js-sdk';\n\nexport function useZaprooSearch() {\n  const config = useRuntimeConfig();\n  const sid = useCookie\u003Cstring | null>('zs_sid');\n  return createZaprooSearch({\n    apiKey: import.meta.server ? config.zaprooSearchServerKey : config.public.zaprooSearchApiKey,\n    profileKey: config.public.zaprooSearchProfileKey,\n    suggestKey: config.public.zaprooSearchSuggestKey,\n    baseUrl: config.public.zaprooSearchBaseUrl,\n    sessionId: sid.value ?? null,\n    headers: import.meta.server ? useRequestHeaders(['user-agent']) : undefined,\n  });\n}\n\n\u002F\u002F Call the returned function from your consent banner once the visitor agrees.\nexport function useZaprooSearchConsent() {\n  const sid = useCookie\u003Cstring | null>('zs_sid', { maxAge: 60 * 60 * 24 * 30, sameSite: 'lax' });\n  return () => {\n    sid.value ??= crypto.randomUUID();\n  };\n}\n",[345,1735,1736,1741,1753,1757,1769,1783,1812,1820,1845,1850,1855,1860,1871,1904,1909,1913,1917,1922,1933,1986,1999,2016,2022],{"__ignoreMap":382},[386,1737,1738],{"class":388,"line":389},[386,1739,1740],{"class":485},"\u002F\u002F composables\u002FuseZaprooSearch.ts\n",[386,1742,1743,1745,1747,1749,1751],{"class":388,"line":444},[386,1744,428],{"class":427},[386,1746,432],{"class":431},[386,1748,435],{"class":427},[386,1750,438],{"class":396},[386,1752,441],{"class":431},[386,1754,1755],{"class":388,"line":451},[386,1756,448],{"emptyLinePlaceholder":447},[386,1758,1759,1761,1763,1766],{"class":388,"line":474},[386,1760,454],{"class":427},[386,1762,946],{"class":427},[386,1764,1765],{"class":467}," useZaprooSearch",[386,1767,1768],{"class":431},"() {\n",[386,1770,1771,1773,1776,1778,1781],{"class":388,"line":489},[386,1772,1152],{"class":427},[386,1774,1775],{"class":460}," config",[386,1777,464],{"class":427},[386,1779,1780],{"class":467}," useRuntimeConfig",[386,1782,973],{"class":431},[386,1784,1785,1787,1790,1792,1795,1798,1800,1802,1804,1807,1810],{"class":388,"line":503},[386,1786,1152],{"class":427},[386,1788,1789],{"class":460}," sid",[386,1791,464],{"class":427},[386,1793,1794],{"class":467}," useCookie",[386,1796,1797],{"class":431},"\u003C",[386,1799,528],{"class":460},[386,1801,929],{"class":427},[386,1803,1145],{"class":460},[386,1805,1806],{"class":431},">(",[386,1808,1809],{"class":396},"'zs_sid'",[386,1811,896],{"class":431},[386,1813,1814,1816,1818],{"class":388,"line":517},[386,1815,1192],{"class":427},[386,1817,468],{"class":467},[386,1819,471],{"class":431},[386,1821,1822,1825,1827,1829,1832,1835,1837,1840,1842],{"class":388,"line":732},[386,1823,1824],{"class":431},"    apiKey: ",[386,1826,428],{"class":427},[386,1828,574],{"class":431},[386,1830,1831],{"class":460},"meta",[386,1833,1834],{"class":431},".server ",[386,1836,1163],{"class":427},[386,1838,1839],{"class":431}," config.zaprooSearchServerKey ",[386,1841,908],{"class":427},[386,1843,1844],{"class":431}," config.public.zaprooSearchApiKey,\n",[386,1846,1847],{"class":388,"line":737},[386,1848,1849],{"class":431},"    profileKey: config.public.zaprooSearchProfileKey,\n",[386,1851,1852],{"class":388,"line":746},[386,1853,1854],{"class":431},"    suggestKey: config.public.zaprooSearchSuggestKey,\n",[386,1856,1857],{"class":388,"line":755},[386,1858,1859],{"class":431},"    baseUrl: config.public.zaprooSearchBaseUrl,\n",[386,1861,1862,1865,1867,1869],{"class":388,"line":764},[386,1863,1864],{"class":431},"    sessionId: sid.value ",[386,1866,1202],{"class":427},[386,1868,1145],{"class":460},[386,1870,673],{"class":431},[386,1872,1873,1876,1878,1880,1882,1884,1886,1889,1892,1895,1898,1900,1902],{"class":388,"line":1397},[386,1874,1875],{"class":431},"    headers: ",[386,1877,428],{"class":427},[386,1879,574],{"class":431},[386,1881,1831],{"class":460},[386,1883,1834],{"class":431},[386,1885,1163],{"class":427},[386,1887,1888],{"class":467}," useRequestHeaders",[386,1890,1891],{"class":431},"([",[386,1893,1894],{"class":396},"'user-agent'",[386,1896,1897],{"class":431},"]) ",[386,1899,908],{"class":427},[386,1901,932],{"class":460},[386,1903,673],{"class":431},[386,1905,1906],{"class":388,"line":1407},[386,1907,1908],{"class":431},"  });\n",[386,1910,1911],{"class":388,"line":1413},[386,1912,1078],{"class":431},[386,1914,1915],{"class":388,"line":1436},[386,1916,448],{"emptyLinePlaceholder":447},[386,1918,1919],{"class":388,"line":1455},[386,1920,1921],{"class":485},"\u002F\u002F Call the returned function from your consent banner once the visitor agrees.\n",[386,1923,1924,1926,1928,1931],{"class":388,"line":1461},[386,1925,454],{"class":427},[386,1927,946],{"class":427},[386,1929,1930],{"class":467}," useZaprooSearchConsent",[386,1932,1768],{"class":431},[386,1934,1936,1938,1940,1942,1944,1946,1948,1950,1952,1954,1956,1959,1962,1965,1968,1970,1973,1975,1978,1981,1984],{"class":388,"line":1935},19,[386,1937,1152],{"class":427},[386,1939,1789],{"class":460},[386,1941,464],{"class":427},[386,1943,1794],{"class":467},[386,1945,1797],{"class":431},[386,1947,528],{"class":460},[386,1949,929],{"class":427},[386,1951,1145],{"class":460},[386,1953,1806],{"class":431},[386,1955,1809],{"class":396},[386,1957,1958],{"class":431},", { maxAge: ",[386,1960,1961],{"class":460},"60",[386,1963,1964],{"class":427}," *",[386,1966,1967],{"class":460}," 60",[386,1969,1964],{"class":427},[386,1971,1972],{"class":460}," 24",[386,1974,1964],{"class":427},[386,1976,1977],{"class":460}," 30",[386,1979,1980],{"class":431},", sameSite: ",[386,1982,1983],{"class":396},"'lax'",[386,1985,838],{"class":431},[386,1987,1989,1991,1994,1997],{"class":388,"line":1988},20,[386,1990,1192],{"class":427},[386,1992,1993],{"class":431}," () ",[386,1995,1996],{"class":427},"=>",[386,1998,995],{"class":431},[386,2000,2002,2005,2008,2011,2014],{"class":388,"line":2001},21,[386,2003,2004],{"class":431},"    sid.value ",[386,2006,2007],{"class":427},"??=",[386,2009,2010],{"class":431}," crypto.",[386,2012,2013],{"class":467},"randomUUID",[386,2015,973],{"class":431},[386,2017,2019],{"class":388,"line":2018},22,[386,2020,2021],{"class":431},"  };\n",[386,2023,2025],{"class":388,"line":2024},23,[386,2026,1078],{"class":431},[377,2028,2032],{"className":2029,"code":2030,"language":2031,"meta":382,"style":382},"language-vue shiki shiki-themes github-light-high-contrast github-light-high-contrast github-dark-high-contrast","\u003C!-- pages\u002Fsearch.vue -->\n\u003Cscript setup lang=\"ts\">\nconst route = useRoute();\nconst zaprooSearch = useZaprooSearch();\nconst { data } = await useAsyncData('search', () => zaprooSearch.search({ q: String(route.query.q ?? '') }), {\n  watch: [() => route.query.q],\n});\n\nfunction open(itemId: string, position: number) {\n  if (data.value?.searchId) zaprooSearch.track({ type: 'click', searchId: data.value.searchId, itemId, position });\n  return navigateTo(`\u002Fproduct\u002F${itemId}`);\n}\n\u003C\u002Fscript>\n","vue",[345,2033,2034,2039,2061,2075,2087,2135,2145,2149,2153,2180,2197,2216,2220],{"__ignoreMap":382},[386,2035,2036],{"class":388,"line":389},[386,2037,2038],{"class":485},"\u003C!-- pages\u002Fsearch.vue -->\n",[386,2040,2041,2043,2047,2050,2053,2055,2058],{"class":388,"line":444},[386,2042,1797],{"class":431},[386,2044,2046],{"class":2045},"sb7M8","script",[386,2048,2049],{"class":460}," setup",[386,2051,2052],{"class":460}," lang",[386,2054,881],{"class":431},[386,2056,2057],{"class":396},"\"ts\"",[386,2059,2060],{"class":431},">\n",[386,2062,2063,2065,2068,2070,2073],{"class":388,"line":451},[386,2064,647],{"class":427},[386,2066,2067],{"class":460}," route",[386,2069,464],{"class":427},[386,2071,2072],{"class":467}," useRoute",[386,2074,973],{"class":431},[386,2076,2077,2079,2081,2083,2085],{"class":388,"line":474},[386,2078,647],{"class":427},[386,2080,461],{"class":460},[386,2082,464],{"class":427},[386,2084,1765],{"class":467},[386,2086,973],{"class":431},[386,2088,2089,2091,2093,2096,2098,2100,2102,2105,2107,2110,2113,2115,2117,2119,2121,2124,2127,2129,2132],{"class":388,"line":489},[386,2090,647],{"class":427},[386,2092,867],{"class":431},[386,2094,2095],{"class":460},"data",[386,2097,878],{"class":431},[386,2099,881],{"class":427},[386,2101,655],{"class":427},[386,2103,2104],{"class":467}," useAsyncData",[386,2106,890],{"class":431},[386,2108,2109],{"class":396},"'search'",[386,2111,2112],{"class":431},", () ",[386,2114,1996],{"class":427},[386,2116,658],{"class":431},[386,2118,351],{"class":467},[386,2120,826],{"class":431},[386,2122,2123],{"class":467},"String",[386,2125,2126],{"class":431},"(route.query.q ",[386,2128,1202],{"class":427},[386,2130,2131],{"class":396}," ''",[386,2133,2134],{"class":431},") }), {\n",[386,2136,2137,2140,2142],{"class":388,"line":503},[386,2138,2139],{"class":431},"  watch: [() ",[386,2141,1996],{"class":427},[386,2143,2144],{"class":431}," route.query.q],\n",[386,2146,2147],{"class":388,"line":517},[386,2148,520],{"class":431},[386,2150,2151],{"class":388,"line":732},[386,2152,448],{"emptyLinePlaceholder":447},[386,2154,2155,2157,2160,2162,2165,2167,2169,2171,2173,2175,2178],{"class":388,"line":737},[386,2156,616],{"class":427},[386,2158,2159],{"class":467}," open",[386,2161,890],{"class":431},[386,2163,2164],{"class":392},"itemId",[386,2166,908],{"class":427},[386,2168,959],{"class":460},[386,2170,352],{"class":431},[386,2172,1227],{"class":392},[386,2174,908],{"class":427},[386,2176,2177],{"class":460}," number",[386,2179,962],{"class":431},[386,2181,2182,2185,2188,2190,2192,2194],{"class":388,"line":746},[386,2183,2184],{"class":427},"  if",[386,2186,2187],{"class":431}," (data.value?.searchId) zaprooSearch.",[386,2189,359],{"class":467},[386,2191,1181],{"class":431},[386,2193,1284],{"class":396},[386,2195,2196],{"class":431},", searchId: data.value.searchId, itemId, position });\n",[386,2198,2199,2201,2204,2206,2209,2211,2214],{"class":388,"line":755},[386,2200,1192],{"class":427},[386,2202,2203],{"class":467}," navigateTo",[386,2205,890],{"class":431},[386,2207,2208],{"class":396},"`\u002Fproduct\u002F${",[386,2210,2164],{"class":431},[386,2212,2213],{"class":396},"}`",[386,2215,896],{"class":431},[386,2217,2218],{"class":388,"line":764},[386,2219,1078],{"class":431},[386,2221,2222,2225,2227],{"class":388,"line":1397},[386,2223,2224],{"class":431},"\u003C\u002F",[386,2226,2046],{"class":2045},[386,2228,2060],{"class":431},[342,2230,2231,2232,2234,2235,2237],{},"The server renders the first results. In the browser, ",[345,2233,2095],{}," already holds them, ",[345,2236,370],{}," included, so the click is tracked against the search the shopper saw.",[1616,2239,2242,2245,2509,2512],{"icon":2240,"label":2241},"i-lucide-circle","Next.js",[342,2243,2244],{},"Create the client per request in a server component, with the shopper's cookie and user agent:",[377,2246,2250],{"className":2247,"code":2248,"language":2249,"meta":382,"style":382},"language-tsx shiki shiki-themes github-light-high-contrast github-light-high-contrast github-dark-high-contrast","\u002F\u002F app\u002Fsearch\u002Fpage.tsx\nimport { createZaprooSearch } from '@zaprooecommerce\u002Fsearch-js-sdk';\nimport { cookies, headers } from 'next\u002Fheaders';\nimport { Results } from '.\u002Fresults';\n\nexport default async function SearchPage({ searchParams }: { searchParams: Promise\u003C{ q?: string }> }) {\n  const zaprooSearch = createZaprooSearch({\n    apiKey: process.env.ZAPROO_SEARCH_SERVER_KEY!, \u002F\u002F a secret key with read access\n    profileKey: process.env.NEXT_PUBLIC_ZAPROO_SEARCH_PROFILE_KEY!,\n    baseUrl: process.env.NEXT_PUBLIC_ZAPROO_SEARCH_BASE_URL,\n    sessionId: (await cookies()).get('zs_sid')?.value ?? null,\n    headers: { 'User-Agent': (await headers()).get('user-agent') ?? '' },\n  });\n  const results = await zaprooSearch.search({ q: (await searchParams).q ?? '' });\n  return \u003CResults results={results} \u002F>;\n}\n","tsx",[345,2251,2252,2257,2269,2283,2297,2301,2339,2351,2366,2378,2388,2417,2449,2453,2481,2505],{"__ignoreMap":382},[386,2253,2254],{"class":388,"line":389},[386,2255,2256],{"class":485},"\u002F\u002F app\u002Fsearch\u002Fpage.tsx\n",[386,2258,2259,2261,2263,2265,2267],{"class":388,"line":444},[386,2260,428],{"class":427},[386,2262,432],{"class":431},[386,2264,435],{"class":427},[386,2266,438],{"class":396},[386,2268,441],{"class":431},[386,2270,2271,2273,2276,2278,2281],{"class":388,"line":451},[386,2272,428],{"class":427},[386,2274,2275],{"class":431}," { cookies, headers } ",[386,2277,435],{"class":427},[386,2279,2280],{"class":396}," 'next\u002Fheaders'",[386,2282,441],{"class":431},[386,2284,2285,2287,2290,2292,2295],{"class":388,"line":474},[386,2286,428],{"class":427},[386,2288,2289],{"class":431}," { Results } ",[386,2291,435],{"class":427},[386,2293,2294],{"class":396}," '.\u002Fresults'",[386,2296,441],{"class":431},[386,2298,2299],{"class":388,"line":489},[386,2300,448],{"emptyLinePlaceholder":447},[386,2302,2303,2305,2307,2310,2312,2315,2318,2320,2323,2325,2328,2331,2333,2336],{"class":388,"line":503},[386,2304,454],{"class":427},[386,2306,1643],{"class":427},[386,2308,2309],{"class":427}," async",[386,2311,946],{"class":427},[386,2313,2314],{"class":467}," SearchPage",[386,2316,2317],{"class":392},"({ searchParams }",[386,2319,908],{"class":427},[386,2321,2322],{"class":392}," { searchParams",[386,2324,908],{"class":427},[386,2326,2327],{"class":392}," Promise\u003C{ q",[386,2329,2330],{"class":427},"?:",[386,2332,959],{"class":460},[386,2334,2335],{"class":392}," }> }) ",[386,2337,2338],{"class":431},"{\n",[386,2340,2341,2343,2345,2347,2349],{"class":388,"line":517},[386,2342,1152],{"class":427},[386,2344,461],{"class":460},[386,2346,464],{"class":427},[386,2348,468],{"class":467},[386,2350,471],{"class":431},[386,2352,2353,2356,2359,2361,2363],{"class":388,"line":732},[386,2354,2355],{"class":431},"    apiKey: process.env.",[386,2357,2358],{"class":460},"ZAPROO_SEARCH_SERVER_KEY",[386,2360,1290],{"class":427},[386,2362,352],{"class":431},[386,2364,2365],{"class":485},"\u002F\u002F a secret key with read access\n",[386,2367,2368,2371,2374,2376],{"class":388,"line":737},[386,2369,2370],{"class":431},"    profileKey: process.env.",[386,2372,2373],{"class":460},"NEXT_PUBLIC_ZAPROO_SEARCH_PROFILE_KEY",[386,2375,1290],{"class":427},[386,2377,673],{"class":431},[386,2379,2380,2383,2386],{"class":388,"line":746},[386,2381,2382],{"class":431},"    baseUrl: process.env.",[386,2384,2385],{"class":460},"NEXT_PUBLIC_ZAPROO_SEARCH_BASE_URL",[386,2387,673],{"class":431},[386,2389,2390,2393,2395,2398,2401,2404,2406,2408,2411,2413,2415],{"class":388,"line":755},[386,2391,2392],{"class":431},"    sessionId: (",[386,2394,819],{"class":427},[386,2396,2397],{"class":467}," cookies",[386,2399,2400],{"class":431},"()).",[386,2402,2403],{"class":467},"get",[386,2405,890],{"class":431},[386,2407,1809],{"class":396},[386,2409,2410],{"class":431},")?.value ",[386,2412,1202],{"class":427},[386,2414,1145],{"class":460},[386,2416,673],{"class":431},[386,2418,2419,2422,2425,2428,2430,2433,2435,2437,2439,2441,2443,2445,2447],{"class":388,"line":764},[386,2420,2421],{"class":431},"    headers: { ",[386,2423,2424],{"class":396},"'User-Agent'",[386,2426,2427],{"class":431},": (",[386,2429,819],{"class":427},[386,2431,2432],{"class":467}," headers",[386,2434,2400],{"class":431},[386,2436,2403],{"class":467},[386,2438,890],{"class":431},[386,2440,1894],{"class":396},[386,2442,1062],{"class":431},[386,2444,1202],{"class":427},[386,2446,2131],{"class":396},[386,2448,1433],{"class":431},[386,2450,2451],{"class":388,"line":1397},[386,2452,1908],{"class":431},[386,2454,2455,2457,2459,2461,2463,2465,2467,2470,2472,2475,2477,2479],{"class":388,"line":1407},[386,2456,1152],{"class":427},[386,2458,650],{"class":460},[386,2460,464],{"class":427},[386,2462,655],{"class":427},[386,2464,658],{"class":431},[386,2466,351],{"class":467},[386,2468,2469],{"class":431},"({ q: (",[386,2471,819],{"class":427},[386,2473,2474],{"class":431}," searchParams).q ",[386,2476,1202],{"class":427},[386,2478,2131],{"class":396},[386,2480,838],{"class":431},[386,2482,2483,2485,2488,2491,2493,2496,2499,2502],{"class":388,"line":1413},[386,2484,1192],{"class":427},[386,2486,2487],{"class":431}," \u003C",[386,2489,2490],{"class":2045},"Results",[386,2492,650],{"class":460},[386,2494,2495],{"class":427},"={",[386,2497,2498],{"class":431},"results",[386,2500,2501],{"class":427},"}",[386,2503,2504],{"class":431}," \u002F>;\n",[386,2506,2507],{"class":388,"line":1436},[386,2508,1078],{"class":431},[342,2510,2511],{},"Track clicks from a client component with a browser client:",[377,2513,2515],{"className":2247,"code":2514,"language":2249,"meta":382,"style":382},"\u002F\u002F app\u002Fsearch\u002Fresults.tsx\n'use client';\nimport { createZaprooSearch, type SearchResponse } from '@zaprooecommerce\u002Fsearch-js-sdk';\n\nconst zaprooSearch = createZaprooSearch({\n  apiKey: process.env.NEXT_PUBLIC_ZAPROO_SEARCH_API_KEY!,\n  profileKey: process.env.NEXT_PUBLIC_ZAPROO_SEARCH_PROFILE_KEY!,\n  baseUrl: process.env.NEXT_PUBLIC_ZAPROO_SEARCH_BASE_URL,\n  \u002F\u002F client components also render on the server, where there is no document\n  sessionId: typeof document === 'undefined' ? null : (document.cookie.match(\u002F(?:^|; )zs_sid=([^;]+)\u002F)?.[1] ?? null),\n});\n\nexport function Results({ results }: { results: SearchResponse }) {\n  return (\n    \u003Cul>\n      {results.items.map((hit, i) => (\n        \u003Cli key={hit.id}>\n          \u003Ca\n            href={`\u002Fproduct\u002F${hit.id}`}\n            onClick={() => results.searchId && zaprooSearch.track({ type: 'click', searchId: results.searchId, itemId: hit.id, position: i + 1 })}\n          >\n            {String(hit.title)}\n          \u003C\u002Fa>\n        \u003C\u002Fli>\n      ))}\n    \u003C\u002Ful>\n  );\n}\n",[345,2516,2517,2522,2529,2548,2552,2564,2576,2587,2596,2601,2673,2677,2681,2712,2719,2728,2756,2775,2783,2803,2842,2847,2859,2868,2878,2886,2896,2902],{"__ignoreMap":382},[386,2518,2519],{"class":388,"line":389},[386,2520,2521],{"class":485},"\u002F\u002F app\u002Fsearch\u002Fresults.tsx\n",[386,2523,2524,2527],{"class":388,"line":444},[386,2525,2526],{"class":396},"'use client'",[386,2528,441],{"class":431},[386,2530,2531,2533,2536,2539,2542,2544,2546],{"class":388,"line":451},[386,2532,428],{"class":427},[386,2534,2535],{"class":431}," { createZaprooSearch, ",[386,2537,2538],{"class":427},"type",[386,2540,2541],{"class":431}," SearchResponse } ",[386,2543,435],{"class":427},[386,2545,438],{"class":396},[386,2547,441],{"class":431},[386,2549,2550],{"class":388,"line":474},[386,2551,448],{"emptyLinePlaceholder":447},[386,2553,2554,2556,2558,2560,2562],{"class":388,"line":489},[386,2555,647],{"class":427},[386,2557,461],{"class":460},[386,2559,464],{"class":427},[386,2561,468],{"class":467},[386,2563,471],{"class":431},[386,2565,2566,2569,2572,2574],{"class":388,"line":503},[386,2567,2568],{"class":431},"  apiKey: process.env.",[386,2570,2571],{"class":460},"NEXT_PUBLIC_ZAPROO_SEARCH_API_KEY",[386,2573,1290],{"class":427},[386,2575,673],{"class":431},[386,2577,2578,2581,2583,2585],{"class":388,"line":517},[386,2579,2580],{"class":431},"  profileKey: process.env.",[386,2582,2373],{"class":460},[386,2584,1290],{"class":427},[386,2586,673],{"class":431},[386,2588,2589,2592,2594],{"class":388,"line":732},[386,2590,2591],{"class":431},"  baseUrl: process.env.",[386,2593,2385],{"class":460},[386,2595,673],{"class":431},[386,2597,2598],{"class":388,"line":737},[386,2599,2600],{"class":485},"  \u002F\u002F client components also render on the server, where there is no document\n",[386,2602,2603,2606,2609,2612,2615,2618,2621,2623,2626,2629,2632,2634,2637,2640,2643,2646,2649,2652,2655,2658,2661,2663,2666,2668,2670],{"class":388,"line":746},[386,2604,2605],{"class":431},"  sessionId: ",[386,2607,2608],{"class":427},"typeof",[386,2610,2611],{"class":431}," document ",[386,2613,2614],{"class":427},"===",[386,2616,2617],{"class":396}," 'undefined'",[386,2619,2620],{"class":427}," ?",[386,2622,1145],{"class":460},[386,2624,2625],{"class":427}," :",[386,2627,2628],{"class":431}," (document.cookie.",[386,2630,2631],{"class":467},"match",[386,2633,890],{"class":431},[386,2635,2636],{"class":396},"\u002F(?:",[386,2638,2639],{"class":427},"^|",[386,2641,2642],{"class":396},"; )zs_sid=(",[386,2644,2645],{"class":460},"[",[386,2647,2648],{"class":427},"^",[386,2650,2651],{"class":460},";]",[386,2653,2654],{"class":427},"+",[386,2656,2657],{"class":396},")\u002F",[386,2659,2660],{"class":431},")?.[",[386,2662,713],{"class":460},[386,2664,2665],{"class":431},"] ",[386,2667,1202],{"class":427},[386,2669,1145],{"class":460},[386,2671,2672],{"class":431},"),\n",[386,2674,2675],{"class":388,"line":755},[386,2676,520],{"class":431},[386,2678,2679],{"class":388,"line":764},[386,2680,448],{"emptyLinePlaceholder":447},[386,2682,2683,2685,2687,2690,2693,2695,2698,2700,2702,2704,2706,2709],{"class":388,"line":1397},[386,2684,454],{"class":427},[386,2686,946],{"class":427},[386,2688,2689],{"class":467}," Results",[386,2691,2692],{"class":431},"({ ",[386,2694,2498],{"class":392},[386,2696,2697],{"class":431}," }",[386,2699,908],{"class":427},[386,2701,867],{"class":431},[386,2703,2498],{"class":392},[386,2705,908],{"class":427},[386,2707,2708],{"class":392}," SearchResponse",[386,2710,2711],{"class":431}," }) {\n",[386,2713,2714,2716],{"class":388,"line":1407},[386,2715,1192],{"class":427},[386,2717,2718],{"class":431}," (\n",[386,2720,2721,2724,2726],{"class":388,"line":1413},[386,2722,2723],{"class":431},"    \u003C",[386,2725,1584],{"class":2045},[386,2727,2060],{"class":431},[386,2729,2730,2733,2736,2739,2742,2745,2747,2750,2752,2754],{"class":388,"line":1436},[386,2731,2732],{"class":427},"      {",[386,2734,2735],{"class":431},"results.items.",[386,2737,2738],{"class":467},"map",[386,2740,2741],{"class":431},"((",[386,2743,2744],{"class":392},"hit",[386,2746,352],{"class":431},[386,2748,2749],{"class":392},"i",[386,2751,1062],{"class":431},[386,2753,1996],{"class":427},[386,2755,2718],{"class":431},[386,2757,2758,2761,2763,2766,2768,2771,2773],{"class":388,"line":1455},[386,2759,2760],{"class":431},"        \u003C",[386,2762,1587],{"class":2045},[386,2764,2765],{"class":460}," key",[386,2767,2495],{"class":427},[386,2769,2770],{"class":431},"hit.id",[386,2772,2501],{"class":427},[386,2774,2060],{"class":431},[386,2776,2777,2780],{"class":388,"line":1461},[386,2778,2779],{"class":431},"          \u003C",[386,2781,2782],{"class":2045},"a\n",[386,2784,2785,2788,2790,2792,2794,2796,2799,2801],{"class":388,"line":1935},[386,2786,2787],{"class":460},"            href",[386,2789,2495],{"class":427},[386,2791,2208],{"class":396},[386,2793,2744],{"class":431},[386,2795,574],{"class":396},[386,2797,2798],{"class":431},"id",[386,2800,2213],{"class":396},[386,2802,1078],{"class":427},[386,2804,2805,2808,2810,2813,2815,2818,2821,2823,2825,2827,2829,2832,2834,2837,2840],{"class":388,"line":1988},[386,2806,2807],{"class":460},"            onClick",[386,2809,2495],{"class":427},[386,2811,2812],{"class":431},"() ",[386,2814,1996],{"class":427},[386,2816,2817],{"class":431}," results.searchId ",[386,2819,2820],{"class":427},"&&",[386,2822,658],{"class":431},[386,2824,359],{"class":467},[386,2826,1181],{"class":431},[386,2828,1284],{"class":396},[386,2830,2831],{"class":431},", searchId: results.searchId, itemId: hit.id, position: i ",[386,2833,2654],{"class":427},[386,2835,2836],{"class":460}," 1",[386,2838,2839],{"class":431}," })",[386,2841,1078],{"class":427},[386,2843,2844],{"class":388,"line":2001},[386,2845,2846],{"class":431},"          >\n",[386,2848,2849,2852,2854,2857],{"class":388,"line":2018},[386,2850,2851],{"class":427},"            {",[386,2853,2123],{"class":467},[386,2855,2856],{"class":431},"(hit.title)",[386,2858,1078],{"class":427},[386,2860,2861,2864,2866],{"class":388,"line":2024},[386,2862,2863],{"class":431},"          \u003C\u002F",[386,2865,412],{"class":2045},[386,2867,2060],{"class":431},[386,2869,2871,2874,2876],{"class":388,"line":2870},24,[386,2872,2873],{"class":431},"        \u003C\u002F",[386,2875,1587],{"class":2045},[386,2877,2060],{"class":431},[386,2879,2881,2884],{"class":388,"line":2880},25,[386,2882,2883],{"class":431},"      ))",[386,2885,1078],{"class":427},[386,2887,2889,2892,2894],{"class":388,"line":2888},26,[386,2890,2891],{"class":431},"    \u003C\u002F",[386,2893,1584],{"class":2045},[386,2895,2060],{"class":431},[386,2897,2899],{"class":388,"line":2898},27,[386,2900,2901],{"class":431},"  );\n",[386,2903,2905],{"class":388,"line":2904},28,[386,2906,1078],{"class":431},[1616,2908,2911,2914],{"icon":2909,"label":2910},"i-lucide-atom","React",[342,2912,2913],{},"A search box in a single-page React app, with suggestions that cancel the previous request:",[377,2915,2917],{"className":2247,"code":2916,"language":2249,"meta":382,"style":382},"import { createZaprooSearch, type Suggestion } from '@zaprooecommerce\u002Fsearch-js-sdk';\nimport { useEffect, useState } from 'react';\n\nconst zaprooSearch = createZaprooSearch({\n  apiKey: import.meta.env.VITE_ZAPROO_SEARCH_API_KEY,\n  profileKey: import.meta.env.VITE_ZAPROO_SEARCH_PROFILE_KEY,\n  suggestKey: import.meta.env.VITE_ZAPROO_SEARCH_SUGGEST_KEY,\n  baseUrl: import.meta.env.VITE_ZAPROO_SEARCH_BASE_URL,\n});\n\nexport function SearchBox() {\n  const [q, setQ] = useState('');\n  const [suggestions, setSuggestions] = useState\u003CSuggestion[]>([]);\n\n  useEffect(() => {\n    const controller = new AbortController();\n    const timer = setTimeout(() => {\n      zaprooSearch.suggest(q, { signal: controller.signal }).then((r) => setSuggestions(r.suggestions), () => {});\n    }, 150);\n    return () => {\n      clearTimeout(timer);\n      controller.abort();\n    };\n  }, [q]);\n\n  return (\n    \u003C>\n      \u003Cinput value={q} onChange={(e) => setQ(e.target.value)} placeholder=\"Search\" \u002F>\n      \u003Cul>\n        {suggestions.map((s) => \u003Cli key={s.text}>{s.text}\u003C\u002Fli>)}\n      \u003C\u002Ful>\n    \u003C\u002F>\n  );\n}\n",[345,2918,2919,2936,2950,2954,2966,2984,3001,3018,3036,3040,3044,3055,3082,3109,3113,3125,3139,3157,3190,3200,3211,3219,3228,3233,3238,3242,3248,3253,3303,3312,3364,3374,3380,3385],{"__ignoreMap":382},[386,2920,2921,2923,2925,2927,2930,2932,2934],{"class":388,"line":389},[386,2922,428],{"class":427},[386,2924,2535],{"class":431},[386,2926,2538],{"class":427},[386,2928,2929],{"class":431}," Suggestion } ",[386,2931,435],{"class":427},[386,2933,438],{"class":396},[386,2935,441],{"class":431},[386,2937,2938,2940,2943,2945,2948],{"class":388,"line":444},[386,2939,428],{"class":427},[386,2941,2942],{"class":431}," { useEffect, useState } ",[386,2944,435],{"class":427},[386,2946,2947],{"class":396}," 'react'",[386,2949,441],{"class":431},[386,2951,2952],{"class":388,"line":451},[386,2953,448],{"emptyLinePlaceholder":447},[386,2955,2956,2958,2960,2962,2964],{"class":388,"line":474},[386,2957,647],{"class":427},[386,2959,461],{"class":460},[386,2961,464],{"class":427},[386,2963,468],{"class":467},[386,2965,471],{"class":431},[386,2967,2968,2970,2972,2974,2976,2979,2982],{"class":388,"line":489},[386,2969,477],{"class":431},[386,2971,428],{"class":427},[386,2973,574],{"class":431},[386,2975,1831],{"class":460},[386,2977,2978],{"class":431},".env.",[386,2980,2981],{"class":460},"VITE_ZAPROO_SEARCH_API_KEY",[386,2983,673],{"class":431},[386,2985,2986,2988,2990,2992,2994,2996,2999],{"class":388,"line":503},[386,2987,492],{"class":431},[386,2989,428],{"class":427},[386,2991,574],{"class":431},[386,2993,1831],{"class":460},[386,2995,2978],{"class":431},[386,2997,2998],{"class":460},"VITE_ZAPROO_SEARCH_PROFILE_KEY",[386,3000,673],{"class":431},[386,3002,3003,3005,3007,3009,3011,3013,3016],{"class":388,"line":517},[386,3004,506],{"class":431},[386,3006,428],{"class":427},[386,3008,574],{"class":431},[386,3010,1831],{"class":460},[386,3012,2978],{"class":431},[386,3014,3015],{"class":460},"VITE_ZAPROO_SEARCH_SUGGEST_KEY",[386,3017,673],{"class":431},[386,3019,3020,3023,3025,3027,3029,3031,3034],{"class":388,"line":732},[386,3021,3022],{"class":431},"  baseUrl: ",[386,3024,428],{"class":427},[386,3026,574],{"class":431},[386,3028,1831],{"class":460},[386,3030,2978],{"class":431},[386,3032,3033],{"class":460},"VITE_ZAPROO_SEARCH_BASE_URL",[386,3035,673],{"class":431},[386,3037,3038],{"class":388,"line":737},[386,3039,520],{"class":431},[386,3041,3042],{"class":388,"line":746},[386,3043,448],{"emptyLinePlaceholder":447},[386,3045,3046,3048,3050,3053],{"class":388,"line":755},[386,3047,454],{"class":427},[386,3049,946],{"class":427},[386,3051,3052],{"class":467}," SearchBox",[386,3054,1768],{"class":431},[386,3056,3057,3059,3062,3064,3066,3069,3071,3073,3076,3078,3080],{"class":388,"line":764},[386,3058,1152],{"class":427},[386,3060,3061],{"class":431}," [",[386,3063,776],{"class":460},[386,3065,352],{"class":431},[386,3067,3068],{"class":460},"setQ",[386,3070,2665],{"class":431},[386,3072,881],{"class":427},[386,3074,3075],{"class":467}," useState",[386,3077,890],{"class":431},[386,3079,1661],{"class":396},[386,3081,896],{"class":431},[386,3083,3084,3086,3088,3090,3092,3095,3097,3099,3101,3103,3106],{"class":388,"line":1397},[386,3085,1152],{"class":427},[386,3087,3061],{"class":431},[386,3089,870],{"class":460},[386,3091,352],{"class":431},[386,3093,3094],{"class":460},"setSuggestions",[386,3096,2665],{"class":431},[386,3098,881],{"class":427},[386,3100,3075],{"class":467},[386,3102,1797],{"class":431},[386,3104,3105],{"class":392},"Suggestion",[386,3107,3108],{"class":431},"[]>([]);\n",[386,3110,3111],{"class":388,"line":1407},[386,3112,448],{"emptyLinePlaceholder":447},[386,3114,3115,3118,3121,3123],{"class":388,"line":1413},[386,3116,3117],{"class":467},"  useEffect",[386,3119,3120],{"class":431},"(() ",[386,3122,1996],{"class":427},[386,3124,995],{"class":431},[386,3126,3127,3129,3131,3133,3135,3137],{"class":388,"line":1436},[386,3128,1000],{"class":427},[386,3130,921],{"class":460},[386,3132,464],{"class":427},[386,3134,983],{"class":427},[386,3136,926],{"class":467},[386,3138,973],{"class":431},[386,3140,3141,3143,3146,3148,3151,3153,3155],{"class":388,"line":1455},[386,3142,1000],{"class":427},[386,3144,3145],{"class":460}," timer",[386,3147,464],{"class":427},[386,3149,3150],{"class":467}," setTimeout",[386,3152,3120],{"class":431},[386,3154,1996],{"class":427},[386,3156,995],{"class":431},[386,3158,3159,3162,3164,3167,3170,3172,3175,3177,3179,3182,3185,3187],{"class":388,"line":1461},[386,3160,3161],{"class":431},"      zaprooSearch.",[386,3163,355],{"class":467},[386,3165,3166],{"class":431},"(q, { signal: controller.signal }).",[386,3168,3169],{"class":467},"then",[386,3171,2741],{"class":431},[386,3173,3174],{"class":392},"r",[386,3176,1062],{"class":431},[386,3178,1996],{"class":427},[386,3180,3181],{"class":467}," setSuggestions",[386,3183,3184],{"class":431},"(r.suggestions), () ",[386,3186,1996],{"class":427},[386,3188,3189],{"class":431}," {});\n",[386,3191,3192,3195,3198],{"class":388,"line":1935},[386,3193,3194],{"class":431},"    }, ",[386,3196,3197],{"class":460},"150",[386,3199,896],{"class":431},[386,3201,3202,3205,3207,3209],{"class":388,"line":1988},[386,3203,3204],{"class":427},"    return",[386,3206,1993],{"class":431},[386,3208,1996],{"class":427},[386,3210,995],{"class":431},[386,3212,3213,3216],{"class":388,"line":2001},[386,3214,3215],{"class":467},"      clearTimeout",[386,3217,3218],{"class":431},"(timer);\n",[386,3220,3221,3224,3226],{"class":388,"line":2018},[386,3222,3223],{"class":431},"      controller.",[386,3225,970],{"class":467},[386,3227,973],{"class":431},[386,3229,3230],{"class":388,"line":2024},[386,3231,3232],{"class":431},"    };\n",[386,3234,3235],{"class":388,"line":2870},[386,3236,3237],{"class":431},"  }, [q]);\n",[386,3239,3240],{"class":388,"line":2880},[386,3241,448],{"emptyLinePlaceholder":447},[386,3243,3244,3246],{"class":388,"line":2888},[386,3245,1192],{"class":427},[386,3247,2718],{"class":431},[386,3249,3250],{"class":388,"line":2898},[386,3251,3252],{"class":431},"    \u003C>\n",[386,3254,3255,3258,3261,3264,3266,3268,3270,3273,3275,3277,3280,3282,3284,3287,3290,3292,3295,3297,3300],{"class":388,"line":2904},[386,3256,3257],{"class":431},"      \u003C",[386,3259,3260],{"class":2045},"input",[386,3262,3263],{"class":460}," value",[386,3265,2495],{"class":427},[386,3267,776],{"class":431},[386,3269,2501],{"class":427},[386,3271,3272],{"class":460}," onChange",[386,3274,2495],{"class":427},[386,3276,890],{"class":431},[386,3278,3279],{"class":392},"e",[386,3281,1062],{"class":431},[386,3283,1996],{"class":427},[386,3285,3286],{"class":467}," setQ",[386,3288,3289],{"class":431},"(e.target.value)",[386,3291,2501],{"class":427},[386,3293,3294],{"class":460}," placeholder",[386,3296,881],{"class":427},[386,3298,3299],{"class":396},"\"Search\"",[386,3301,3302],{"class":431}," \u002F>\n",[386,3304,3306,3308,3310],{"class":388,"line":3305},29,[386,3307,3257],{"class":431},[386,3309,1584],{"class":2045},[386,3311,2060],{"class":431},[386,3313,3315,3318,3321,3323,3325,3328,3330,3332,3334,3336,3338,3340,3343,3345,3348,3351,3353,3355,3357,3359,3362],{"class":388,"line":3314},30,[386,3316,3317],{"class":427},"        {",[386,3319,3320],{"class":431},"suggestions.",[386,3322,2738],{"class":467},[386,3324,2741],{"class":431},[386,3326,3327],{"class":392},"s",[386,3329,1062],{"class":431},[386,3331,1996],{"class":427},[386,3333,2487],{"class":431},[386,3335,1587],{"class":2045},[386,3337,2765],{"class":460},[386,3339,2495],{"class":427},[386,3341,3342],{"class":431},"s.text",[386,3344,2501],{"class":427},[386,3346,3347],{"class":431},">",[386,3349,3350],{"class":427},"{",[386,3352,3342],{"class":431},[386,3354,2501],{"class":427},[386,3356,2224],{"class":431},[386,3358,1587],{"class":2045},[386,3360,3361],{"class":431},">)",[386,3363,1078],{"class":427},[386,3365,3367,3370,3372],{"class":388,"line":3366},31,[386,3368,3369],{"class":431},"      \u003C\u002F",[386,3371,1584],{"class":2045},[386,3373,2060],{"class":431},[386,3375,3377],{"class":388,"line":3376},32,[386,3378,3379],{"class":431},"    \u003C\u002F>\n",[386,3381,3383],{"class":388,"line":3382},33,[386,3384,2901],{"class":431},[386,3386,3388],{"class":388,"line":3387},34,[386,3389,1078],{"class":431},[337,3391,573],{"id":3392},"staging-and-live",[342,3394,3395,3397],{},[345,3396,562],{}," decides which Zaproo Search instance the client talks to. Read it from an environment variable, so the same code runs against staging in your test shop and against live in production:",[377,3399,3401],{"className":418,"code":3400,"language":420,"meta":382,"style":382},"const zaprooSearch = createZaprooSearch({\n  apiKey: process.env.ZAPROO_SEARCH_API_KEY!,\n  profileKey: process.env.ZAPROO_SEARCH_PROFILE_KEY!,\n  baseUrl: process.env.ZAPROO_SEARCH_BASE_URL, \u002F\u002F left empty, the client uses https:\u002F\u002Fapi.search.zaproo.cloud\n});\n",[345,3402,3403,3415,3426,3437,3449],{"__ignoreMap":382},[386,3404,3405,3407,3409,3411,3413],{"class":388,"line":389},[386,3406,647],{"class":427},[386,3408,461],{"class":460},[386,3410,464],{"class":427},[386,3412,468],{"class":467},[386,3414,471],{"class":431},[386,3416,3417,3419,3422,3424],{"class":388,"line":444},[386,3418,2568],{"class":431},[386,3420,3421],{"class":460},"ZAPROO_SEARCH_API_KEY",[386,3423,1290],{"class":427},[386,3425,673],{"class":431},[386,3427,3428,3430,3433,3435],{"class":388,"line":451},[386,3429,2580],{"class":431},[386,3431,3432],{"class":460},"ZAPROO_SEARCH_PROFILE_KEY",[386,3434,1290],{"class":427},[386,3436,673],{"class":431},[386,3438,3439,3441,3444,3446],{"class":388,"line":474},[386,3440,2591],{"class":431},[386,3442,3443],{"class":460},"ZAPROO_SEARCH_BASE_URL",[386,3445,352],{"class":431},[386,3447,3448],{"class":485},"\u002F\u002F left empty, the client uses https:\u002F\u002Fapi.search.zaproo.cloud\n",[386,3450,3451],{"class":388,"line":489},[386,3452,520],{"class":431},[342,3454,3455,3456,3458],{},"Keys, profiles and suggest keys belong to one instance. When you switch ",[345,3457,562],{},", switch the keys with it.",[337,3460,3462],{"id":3461},"errors","Errors",[342,3464,3465,3466,3469,3470,3473,3474,3476,3477,3480,3481,908],{},"A request the API refuses rejects with a ",[345,3467,3468],{},"ZaprooSearchError",". It carries the HTTP ",[345,3471,3472],{},"status",", the API's error ",[345,3475,345],{},", the ",[345,3478,3479],{},"message"," and the ",[345,3482,3483],{},"details",[377,3485,3487],{"className":418,"code":3486,"language":420,"meta":382,"style":382},"import { ZaprooSearchError } from '@zaprooecommerce\u002Fsearch-js-sdk';\n\ntry {\n  await zaprooSearch.search({ q: 'tape', sort: 'weight:asc' });\n} catch (error) {\n  if (error instanceof ZaprooSearchError && error.code === 'SORT_NOT_ALLOWED') {\n    \u002F\u002F fall back to the profile's default sort\n  } else {\n    throw error;\n  }\n}\n",[345,3488,3489,3502,3506,3513,3534,3543,3569,3574,3583,3590,3594],{"__ignoreMap":382},[386,3490,3491,3493,3496,3498,3500],{"class":388,"line":389},[386,3492,428],{"class":427},[386,3494,3495],{"class":431}," { ZaprooSearchError } ",[386,3497,435],{"class":427},[386,3499,438],{"class":396},[386,3501,441],{"class":431},[386,3503,3504],{"class":388,"line":444},[386,3505,448],{"emptyLinePlaceholder":447},[386,3507,3508,3511],{"class":388,"line":451},[386,3509,3510],{"class":427},"try",[386,3512,995],{"class":431},[386,3514,3515,3518,3520,3522,3524,3526,3529,3532],{"class":388,"line":474},[386,3516,3517],{"class":427},"  await",[386,3519,658],{"class":431},[386,3521,351],{"class":467},[386,3523,826],{"class":431},[386,3525,829],{"class":396},[386,3527,3528],{"class":431},", sort: ",[386,3530,3531],{"class":396},"'weight:asc'",[386,3533,838],{"class":431},[386,3535,3536,3539,3541],{"class":388,"line":489},[386,3537,3538],{"class":431},"} ",[386,3540,1033],{"class":427},[386,3542,1036],{"class":431},[386,3544,3545,3547,3550,3553,3556,3559,3562,3564,3567],{"class":388,"line":503},[386,3546,2184],{"class":427},[386,3548,3549],{"class":431}," (error ",[386,3551,3552],{"class":427},"instanceof",[386,3554,3555],{"class":392}," ZaprooSearchError",[386,3557,3558],{"class":427}," &&",[386,3560,3561],{"class":431}," error.code ",[386,3563,2614],{"class":427},[386,3565,3566],{"class":396}," 'SORT_NOT_ALLOWED'",[386,3568,962],{"class":431},[386,3570,3571],{"class":388,"line":517},[386,3572,3573],{"class":485},"    \u002F\u002F fall back to the profile's default sort\n",[386,3575,3576,3578,3581],{"class":388,"line":732},[386,3577,1030],{"class":431},[386,3579,3580],{"class":427},"else",[386,3582,995],{"class":431},[386,3584,3585,3588],{"class":388,"line":737},[386,3586,3587],{"class":427},"    throw",[386,3589,1068],{"class":431},[386,3591,3592],{"class":388,"line":746},[386,3593,1073],{"class":431},[386,3595,3596],{"class":388,"line":755},[386,3597,1078],{"class":431},[1513,3599,3600,3611],{},[1516,3601,3602],{},[1519,3603,3604,3608],{},[1522,3605,3606],{},[345,3607,345],{},[1522,3609,3610],{},"When",[1533,3612,3613,3626,3641,3654,3666,3677],{},[1519,3614,3615,3620],{},[1538,3616,3617],{},[345,3618,3619],{},"VALIDATION_FAILED",[1538,3621,3622,3623,3625],{},"A field in the body is wrong. ",[345,3624,3483],{}," names it.",[1519,3627,3628,3633],{},[1538,3629,3630],{},[345,3631,3632],{},"ORIGIN_NOT_ALLOWED",[1538,3634,3635,3636,3638,3639,574],{},"A public key from a domain that is not on its ",[538,3637,540],{},", or from a server without ",[345,3640,588],{},[1519,3642,3643,3651],{},[1538,3644,3645,352,3648],{},[345,3646,3647],{},"SORT_NOT_ALLOWED",[345,3649,3650],{},"FILTER_NOT_ALLOWED",[1538,3652,3653],{},"A sort or filter the profile does not offer.",[1519,3655,3656,3661],{},[1538,3657,3658],{},[345,3659,3660],{},"RATE_LIMITED",[1538,3662,3663,3664,574],{},"Too many requests, see ",[412,3665,1611],{"href":86},[1519,3667,3668,3674],{},[1538,3669,3670,3673],{},[345,3671,3672],{},"HTTP_502"," and the like",[1538,3675,3676],{},"The answer was not an API error, for example a proxy's error page.",[1519,3678,3679,3684],{},[1538,3680,3681],{},[345,3682,3683],{},"NO_SUGGEST_KEY",[1538,3685,3686,3688],{},[345,3687,355],{}," was called without a suggest key. Nothing was sent.",[342,3690,3691,3692,3694,3695,3698,3699,3701],{},"A request you cancel with an ",[345,3693,907],{}," rejects with the runtime's ",[345,3696,3697],{},"AbortError",", not a ",[345,3700,3468],{},". A network failure rejects with the runtime's own error as well.",[337,3703,3705],{"id":3704},"types","Types",[342,3707,3708,3709,352,3712,352,3715,352,3718,352,3721,352,3724,352,3727,356,3729,3732,3733,356,3735,3737,3738,3740,3741,3744],{},"The package ships TypeScript types for every request and answer: ",[345,3710,3711],{},"SearchParams",[345,3713,3714],{},"SearchResponse",[345,3716,3717],{},"SearchHit",[345,3719,3720],{},"FacetResult",[345,3722,3723],{},"Filters",[345,3725,3726],{},"SuggestResponse",[345,3728,3105],{},[345,3730,3731],{},"AnalyticsEvent",". ",[345,3734,3720],{},[345,3736,3731],{}," are unions on ",[345,3739,2538],{},", so a ",[345,3742,3743],{},"switch"," on it narrows the fields:",[377,3746,3748],{"className":418,"code":3747,"language":420,"meta":382,"style":382},"import type { FacetResult } from '@zaprooecommerce\u002Fsearch-js-sdk';\n\nfunction facetValues(facet: FacetResult) {\n  switch (facet.type) {\n    case 'terms':\n    case 'range':\n    case 'hierarchy':\n      return facet.items.map((item) => `${item.key} (${item.count})`);\n    case 'stats':\n      return [`${facet.min} to ${facet.max}`];\n  }\n}\n",[345,3749,3750,3765,3769,3788,3796,3807,3816,3825,3869,3878,3909,3913],{"__ignoreMap":382},[386,3751,3752,3754,3756,3759,3761,3763],{"class":388,"line":389},[386,3753,428],{"class":427},[386,3755,1100],{"class":427},[386,3757,3758],{"class":431}," { FacetResult } ",[386,3760,435],{"class":427},[386,3762,438],{"class":396},[386,3764,441],{"class":431},[386,3766,3767],{"class":388,"line":444},[386,3768,448],{"emptyLinePlaceholder":447},[386,3770,3771,3773,3776,3778,3781,3783,3786],{"class":388,"line":451},[386,3772,616],{"class":427},[386,3774,3775],{"class":467}," facetValues",[386,3777,890],{"class":431},[386,3779,3780],{"class":392},"facet",[386,3782,908],{"class":427},[386,3784,3785],{"class":392}," FacetResult",[386,3787,962],{"class":431},[386,3789,3790,3793],{"class":388,"line":474},[386,3791,3792],{"class":427},"  switch",[386,3794,3795],{"class":431}," (facet.type) {\n",[386,3797,3798,3801,3804],{"class":388,"line":489},[386,3799,3800],{"class":427},"    case",[386,3802,3803],{"class":396}," 'terms'",[386,3805,3806],{"class":431},":\n",[386,3808,3809,3811,3814],{"class":388,"line":503},[386,3810,3800],{"class":427},[386,3812,3813],{"class":396}," 'range'",[386,3815,3806],{"class":431},[386,3817,3818,3820,3823],{"class":388,"line":517},[386,3819,3800],{"class":427},[386,3821,3822],{"class":396}," 'hierarchy'",[386,3824,3806],{"class":431},[386,3826,3827,3830,3833,3835,3837,3840,3842,3844,3847,3849,3851,3854,3857,3859,3861,3864,3867],{"class":388,"line":732},[386,3828,3829],{"class":427},"      return",[386,3831,3832],{"class":431}," facet.items.",[386,3834,2738],{"class":467},[386,3836,2741],{"class":431},[386,3838,3839],{"class":392},"item",[386,3841,1062],{"class":431},[386,3843,1996],{"class":427},[386,3845,3846],{"class":396}," `${",[386,3848,3839],{"class":431},[386,3850,574],{"class":396},[386,3852,3853],{"class":431},"key",[386,3855,3856],{"class":396},"} (${",[386,3858,3839],{"class":431},[386,3860,574],{"class":396},[386,3862,3863],{"class":431},"count",[386,3865,3866],{"class":396},"})`",[386,3868,896],{"class":431},[386,3870,3871,3873,3876],{"class":388,"line":737},[386,3872,3800],{"class":427},[386,3874,3875],{"class":396}," 'stats'",[386,3877,3806],{"class":431},[386,3879,3880,3882,3884,3887,3889,3891,3894,3897,3899,3901,3904,3906],{"class":388,"line":746},[386,3881,3829],{"class":427},[386,3883,3061],{"class":431},[386,3885,3886],{"class":396},"`${",[386,3888,3780],{"class":431},[386,3890,574],{"class":396},[386,3892,3893],{"class":431},"min",[386,3895,3896],{"class":396},"} to ${",[386,3898,3780],{"class":431},[386,3900,574],{"class":396},[386,3902,3903],{"class":431},"max",[386,3905,2213],{"class":396},[386,3907,3908],{"class":431},"];\n",[386,3910,3911],{"class":388,"line":755},[386,3912,1073],{"class":431},[386,3914,3915],{"class":388,"line":764},[386,3916,1078],{"class":431},[337,3918,3920],{"id":3919},"related","Related",[1584,3922,3923,3927,3931,3935,3939],{},[1587,3924,3925],{},[412,3926,29],{"href":30},[1587,3928,3929],{},[412,3930,206],{"href":207},[1587,3932,3933],{},[412,3934,242],{"href":249},[1587,3936,3937],{},[412,3938,271],{"href":272},[1587,3940,3941],{},[412,3942,80],{"href":81},[3944,3945,3946],"style",{},"html pre.shiki code .szw1H, html code.shiki .szw1H{--shiki-light:#702C00;--shiki-default:#702C00;--shiki-dark:#FFB757}html pre.shiki code .semJd, html code.shiki .semJd{--shiki-light:#032563;--shiki-default:#032563;--shiki-dark:#ADDCFF}html .light .shiki span {color: var(--shiki-light);background: var(--shiki-light-bg);font-style: var(--shiki-light-font-style);font-weight: var(--shiki-light-font-weight);text-decoration: var(--shiki-light-text-decoration);}html.light .shiki span {color: var(--shiki-light);background: var(--shiki-light-bg);font-style: var(--shiki-light-font-style);font-weight: var(--shiki-light-font-weight);text-decoration: var(--shiki-light-text-decoration);}html .default .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}html.dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}html pre.shiki code .sklAV, html code.shiki .sklAV{--shiki-light:#A0111F;--shiki-default:#A0111F;--shiki-dark:#FF9492}html pre.shiki code .s7iLA, html code.shiki .s7iLA{--shiki-light:#0E1116;--shiki-default:#0E1116;--shiki-dark:#F0F3F6}html pre.shiki code .ssYy9, html code.shiki .ssYy9{--shiki-light:#023B95;--shiki-default:#023B95;--shiki-dark:#91CBFF}html pre.shiki code .s6m-Y, html code.shiki .s6m-Y{--shiki-light:#622CBC;--shiki-default:#622CBC;--shiki-dark:#DBB7FF}html pre.shiki code .sq92B, html code.shiki .sq92B{--shiki-light:#66707B;--shiki-default:#66707B;--shiki-dark:#BDC4CC}html pre.shiki code .sb7M8, html code.shiki .sb7M8{--shiki-light:#024C1A;--shiki-default:#024C1A;--shiki-dark:#72F088}",{"title":382,"searchDepth":444,"depth":444,"links":3948},[3949,3950,3951,3952,3953,3954,3955,3956,3957,3958,3959,3960],{"id":339,"depth":444,"text":340},{"id":374,"depth":444,"text":375},{"id":406,"depth":444,"text":407},{"id":351,"depth":444,"text":628},{"id":850,"depth":444,"text":242},{"id":1213,"depth":444,"text":1214},{"id":1508,"depth":444,"text":585},{"id":1578,"depth":444,"text":1579},{"id":3392,"depth":444,"text":573},{"id":3461,"depth":444,"text":3462},{"id":3704,"depth":444,"text":3705},{"id":3919,"depth":444,"text":3920},"md",{},{"icon":39},{"title":35,"description":38},"JG852sD4TRnDewa8BPI0cJ8BlaLg9Jonb_i3th6A9O8",[3967,3968],{"title":29,"path":30,"stem":31,"description":32,"icon":33,"children":-1},{"title":41,"path":42,"stem":43,"description":44,"icon":45,"children":-1},1793717706298]