import{t as e}from"./cache-DUthuMSu.mjs";import{a as t,i as n,n as r,o as i,r as a,t as o}from"./util-BmoDgX52.mjs";const s={path:`/search/:query`,categories:[`shopping`],example:`/mercari/search/keyword=シャツ&7bd3eacc-ae45-4d73-bc57-a611c9432014=340258ac-e220-4722-8c35-7f73b7382831`,parameters:{query:`Search parameters in URL query string format.`},features:{requireConfig:!1,requirePuppeteer:!1,antiCrawler:!1,supportBT:!1,supportPodcast:!1,supportScihub:!1},name:`Search`,maintainers:[`yana9i`,`Tsuyumi25`],url:`jp.mercari.com`,handler:l,description:"::: warning\n此路由僅支援 `jp.mercari.com`，不支援 `tw.mercari.com` 和 `hk.mercari.com`。\n\n**注意：** 不同站點的查詢參數格式不同\n- 日本: `keyword=シャツ&order=desc&sort=created_time&status=on_sale`\n- 台灣: `keyword=シャツ&sort=new&status=in-stock&availability=1`\n:::"};function c(e){let t=new URLSearchParams(e),n=t.get(`keyword`)||``,i=r[t.get(`sort`)]||r.default,s=o[t.get(`order`)]||o.desc,c={on_sale:`onsale`,"sold_out|trading":`soldout`},l=t.get(`status`)?.split(`,`).map(e=>a[c[e]]).filter(Boolean)||[],u=[`7bd3eacc-ae45-4d73-bc57-a611c9432014`,`47295d80-5839-4237-bbfc-deb44b4e7999`,`f42ae390-04ff-46ea-808b-f5d97cb45db4`,`d664efe3-ae5a-4824-b729-e789bf93aba9`],d=[];for(let e of u){let n=t.get(e);n&&d.push({id:e,values:n.split(`,`)})}return{keyword:n,sort:i,order:s,status:l,options:{categoryId:t.get(`category_id`)?.split(`,`).map(Number),brandId:t.get(`brand_id`)?.split(`,`).map(Number),priceMin:t.get(`price_min`)?Number(t.get(`price_min`)):void 0,priceMax:t.get(`price_max`)?Number(t.get(`price_max`)):void 0,itemConditionId:t.get(`item_condition_id`)?.split(`,`).map(Number),excludeKeyword:t.get(`exclude_keyword`)||void 0,itemTypes:t.get(`item_types`)?.split(`,`).map(e=>e===`mercari`?`ITEM_TYPE_MERCARI`:e===`beyond`?`ITEM_TYPE_BEYOND`:e),attributes:d}}}async function l(r){let a=r.req.param(`query`),{keyword:o,sort:s,order:l,status:u,options:d}=c(a),f=(await t(s,l,u,o,d)).items,p=await Promise.all(f.map(t=>e.tryGet(`mercari:${t.id}:${t.updated}`,async()=>await n(t.id,t.itemType).then(e=>i(e)))));return{title:`${o} の検索結果`,link:`https://jp.mercari.com/search?${a}`,description:`Mercari advanced search results for: ${a}`,item:p}}export{s as route};