@soma-vertical-web/multi-lib 0.0.32 → 0.0.34

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (53) hide show
  1. package/__vite-browser-external-CpdIDx9o.mjs +79 -0
  2. package/__vite-browser-external-DDWPeg5L.js +1 -0
  3. package/constants.d.ts +32 -0
  4. package/contexts/contexts/search/Facets.d.ts +5 -0
  5. package/contexts/contexts/search/Products.d.ts +5 -0
  6. package/contexts/contexts/search/Root.d.ts +5 -0
  7. package/contexts/contexts/search/Search.d.ts +5 -0
  8. package/contexts/contexts/search/SuggestedTerms.d.ts +5 -0
  9. package/contexts/contexts/search/TopSearches.d.ts +6 -0
  10. package/contexts/index.d.ts +24 -0
  11. package/data/api/fetchVtex.d.ts +2 -1
  12. package/data/api/search/autoCompleteSuggestions/index.d.ts +11 -0
  13. package/data/api/search/crosseling/index.d.ts +91 -0
  14. package/data/api/search/facets/index.d.ts +4 -0
  15. package/data/api/search/index.d.ts +6 -0
  16. package/data/api/search/product/index.d.ts +3 -0
  17. package/data/api/search/searchFetch.d.ts +3 -0
  18. package/data/api/search/suggestedTerms/index.d.ts +12 -0
  19. package/data/api/search/topSearch/index.d.ts +3 -0
  20. package/data/helpers/search/facets.d.ts +48 -0
  21. package/data/helpers/search/index.d.ts +12 -0
  22. package/data/helpers/search/product/index.d.ts +279 -0
  23. package/data/helpers/search/product/utils/canonical.d.ts +1 -0
  24. package/data/helpers/search/product/utils/enhanceSku.d.ts +9 -0
  25. package/data/helpers/search/product/utils/images.d.ts +7 -0
  26. package/data/helpers/search/product/utils/index.d.ts +8 -0
  27. package/data/helpers/search/product/utils/productStock.d.ts +7 -0
  28. package/data/helpers/search/product/utils/propertyValue.d.ts +20 -0
  29. package/data/helpers/search/product/utils/sanitizeHtml.d.ts +18 -0
  30. package/data/helpers/search/product/utils/sku.d.ts +5 -0
  31. package/data/helpers/search/product/utils/slugify.d.ts +1 -0
  32. package/data/helpers/search/root.d.ts +11 -0
  33. package/data/helpers/search/search.d.ts +7 -0
  34. package/index.js +19 -19
  35. package/index.mjs +4336 -3979
  36. package/index2.js +1 -1
  37. package/index2.mjs +891 -400
  38. package/package.json +1 -1
  39. package/server.d.ts +13 -0
  40. package/types/constants.d.ts +9 -15
  41. package/types/contexts/contexts/plp.d.ts +13 -0
  42. package/types/contexts/contexts/search.d.ts +10 -4
  43. package/types/data/api/index.d.ts +5 -2
  44. package/types/data/api/search/facets/index.d.ts +13 -13
  45. package/types/data/api/search/index.d.ts +25 -12
  46. package/types/data/api/search/product/index.d.ts +1 -8
  47. package/types/data/events/index.d.ts +0 -4
  48. package/types/data/helpers/index.d.ts +9 -1
  49. package/types/global/product/index.d.ts +5 -4
  50. package/types/layout/team-components/AddToCart/index.d.ts +2 -2
  51. package/types/layout/team-components/Sort/index.d.ts +2 -3
  52. package/types/data/api/search/autoCompleteSuggestions/index.d.ts +0 -7
  53. package/types/data/api/search/suggestedTerms/index.d.ts +0 -7
package/index2.js CHANGED
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const O=require("yup"),$=require("./__vite-browser-external-Cjz79hOw.js");function y(t){const e=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(t){for(const o in t)if(o!=="default"){const n=Object.getOwnPropertyDescriptor(t,o);Object.defineProperty(e,o,n.get?n:{enumerable:!0,get:()=>t[o]})}}return e.default=t,Object.freeze(e)}const r=y(O),l=async(t,e={})=>{const{method:o="GET",body:n,headers:s={},priority:a="auto"}=e;return fetch(t,{method:o,headers:{...s,Accept:"application/json","Content-Type":"application/json"},priority:a,...n?{body:JSON.stringify(n)}:{}}).then(i=>i.json()).catch(i=>{console.error("[ERROR FETCH VTEX]",i)})},R=r.object({country:r.string().length(3,"Country code must be 3 characters long").required("Country is required"),postalCode:r.string().nullable()});async function q({apiUrl:t,body:e,fetchOptions:o}){if(!e){console.error("[ERROR FETCHING] Body is required");return}await R.validate(e);const{country:n,postalCode:s}=e;return await l(`${t}/api/checkout/pub/postal-code/${n}/${s}`,{method:"POST",body:e,...o})}const T=r.object({orderFormId:r.string().nullable(),sellerCode:r.string().nullable(),sellerName:r.string().nullable()});async function I({apiUrl:t,body:e,fetchOptions:o}){if(!e){console.error("[ERROR FETCHING] Body is required");return}await T.validate(e);const{orderFormId:n,sellerCode:s,sellerName:a}=e,i=s?`${s.trim()} - ${a}`:null;return l(`${t}/api/checkout/pub/orderForm/${n}/attachments/openTextField`,{method:"POST",body:{value:i},...o})}const S=r.object({orderFormId:r.string().nullable(),sellerCode:r.string().nullable(),marketingData:r.object()});async function F({apiUrl:t,body:e,fetchOptions:o}){if(!e){console.error("[ERROR FETCHING] Body is required");return}await S.validate(e);const{orderFormId:n,sellerCode:s,marketingData:a}=e,i=s?{utmCampaign:s?s.toUpperCase():"",utmiCampaign:s?"codigodavendedora":"semcodigo"}:{};return l(`${t}/api/checkout/pub/orderForm/${n}/attachments/marketingData`,{method:"POST",body:{...a,...i},...o})}const v=r.object({orderFormId:r.string().nullable(),sellerCode:r.string().nullable(),sellerName:r.string().nullable()});async function j({apiUrl:t,body:e,fetchOptions:o}){if(!e){console.error("[ERROR FETCHING] Body is required");return}await v.validate(e);const n=await I({apiUrl:t,body:e,fetchOptions:o});return F({apiUrl:t,body:{...e,marketingData:n==null?void 0:n.marketingData},fetchOptions:o})}const E=r.object({orderFormId:r.string().nullable(),coupon:r.string().nullable()});async function w({apiUrl:t,body:e,fetchOptions:o}){if(!e){console.error("[ERROR FETCHING] Body is required");return}await E.validate(e);const{coupon:n="",orderFormId:s}=e;return l(`${t}/api/checkout/pub/orderForm/${s}/coupons`,{method:"POST",body:{text:n},...o})}const k=r.object({appId:r.string().required("App ID is required"),orderFormId:r.string().nullable(),key:r.array().of(r.string())});async function A({apiUrl:t,body:e,fetchOptions:o}){if(!e){console.error("[ERROR FETCHING] Body is required");return}await k.validate(e);const{appId:n="faststore",orderFormId:s,key:a}=e;return l(`${t}/api/checkout/pub/orderForm/${s}/customData/${n}/${a}`,{method:"PUT",...o})}const N=r.object().shape({name:r.string().required("Attachment name is required"),content:r.object().nullable()});var f;const D=r.object().shape({attachments:(f=r.array().of(N))==null?void 0:f.nullable(),id:r.string().required("ID of SKU is required"),index:r.number().integer().nullable(),quantity:r.number().integer().nullable(),seller:r.string().required("Seller is required"),price:r.number().integer()}),P=r.object({orderFormId:r.string().required("OrderFormId is required"),orderItems:r.array().of(D)});async function _({apiUrl:t,body:e,fetchOptions:o}){if(!e){console.error("[ERROR FETCHING] Body is required");return}await P.validate(e);const{orderFormId:n,orderItems:s}=e;return l(`${t}/api/checkout/pub/orderForm/${n}/items`,{method:"POST",body:{orderItems:s},...o})}const G=r.object({orderFormId:r.string().nullable()});async function B({apiUrl:t,body:e,fetchOptions:o}){if(!e){console.error("[ERROR FETCHING] Body is required");return}await G.validate(e);const{orderFormId:n}=e;return l(`${t}/api/checkout/pub/orderForm/${n}/items/removeAll`,{method:"POST",...o})}const H=r.object().shape({name:r.string().required("Attachment name is required"),content:r.object().nullable()});var b;const M=r.object().shape({attachments:(b=r.array().of(H))==null?void 0:b.nullable(),id:r.string().required("ID of SKU is required"),index:r.number().integer().nullable(),quantity:r.number().integer().nullable(),seller:r.string().required("Seller is required"),price:r.number().integer()}),U=r.object({orderFormId:r.string().nullable(),orderItems:r.array().of(M)});async function x({apiUrl:t,body:e,fetchOptions:o}){if(!e){console.error("[ERROR FETCHING] Body is required");return}await U.validate(e);const{orderFormId:n,orderItems:s}=e;return l(`${t}/api/checkout/pub/orderForm/${n}/items/update`,{method:"POST",body:{orderItems:s},...o})}const z=r.object({orderFormId:r.string().nullable()});async function L({apiUrl:t,body:e,fetchOptions:o}){if(!e){console.error("[ERROR FETCHING] Body is required");return}await z.validate(e);const{orderFormId:n}=e;return l(`${t}/api/checkout/pub/orderForm/${n}/messages/clear`,{method:"POST",...o})}const V=r.object({id:r.string().nullable(),itemIndex:r.number().nullable(),orderFormId:r.string().nullable(),remove:r.boolean().nullable()});async function J({apiUrl:t,body:e,fetchOptions:o}){if(!e){console.error("[ERROR FETCHING] Body is required");return}await V.validate(e);const{itemIndex:n,orderFormId:s,id:a,remove:i}=e,c=i?`/${a}/remove`:"",m=`${t}/api/checkout/pub/orderForm/${s}/items/${n}/offerings${c}`;return l(m,{method:"POST",body:{id:a},...o})}const K=r.object({orderFormId:r.string().nullable()});async function Y({apiUrl:t,body:e,fetchOptions:o,extraData:n}){var i;if(!e){console.error("[ERROR FETCHING] Body is required");return}await K.validate(e);const s=new URLSearchParams({refreshOutdatedData:"true"}),a=e.orderFormId&&((i=n.orderFormPurchaseId)==null?void 0:i.value)!==e.orderFormId?`${t}/api/checkout/pub/orderForm/${e.orderFormId}?${String(s)}`:`${t}/api/checkout/pub/orderForm`;return l(a,{method:"GET",...o})}const Q=r.object({orderFormId:r.string().nullable(),email:r.string().email().required(),firstName:r.string().required(),lastName:r.string().required(),documentType:r.string().required(),document:r.string().required(),phone:r.string().matches(/^\+\d{1,3}\d{10,11}$/)});async function X({apiUrl:t,body:e,fetchOptions:o}){if(!e){console.error("[ERROR FETCHING] Body is required");return}await Q.validate(e);const{orderFormId:n,...s}=e;return l(`${t}/api/checkout/pub/orderForm/${n}/attachments/clientProfileData`,{method:"POST",body:{...s},...o})}const W=r.object({sellerCode:r.string().nullable()});async function Z({apiUrl:t,body:e,fetchOptions:o}){if(!e){console.error("[ERROR FETCHING] Body is required");return}await W.validate(e);const{sellerCode:n=""}=e;return l(`${t}/api/dataentities/VD/search?_fields=id,cod,name,ativo&cod=${n}`,{method:"GET",headers:{Accept:"application/vnd.vtex.ds.v10+json"},...o})}const ee=r.object().shape({country:r.string().length(3,"Country code must be 3 characters long").required("Country is required"),orderFormId:r.string().nullable(),postalCode:r.string().nullable()});async function re({apiUrl:t,body:e,fetchOptions:o}){if(!e){console.error("[ERROR FETCHING] Body is required");return}await ee.validate(e);const{country:n,orderFormId:s,postalCode:a}=e,i=a?{address:{addressType:"residential",postalCode:a,country:n}}:{logisticsInfo:[],clearAddressIfPostalCodeNotFound:!0};return l(`${t}/api/checkout/pub/orderForm/${s}/attachments/shippingData`,{method:"POST",body:i,...o})}const te=r.object().shape({orderFormId:r.string().nullable(),options:r.array().of(r.object().shape({itemIndex:r.number(),selectedDeliveryChannel:r.string(),selectedSla:r.string()})),selectedAddresses:r.array().of(r.object().shape({addressId:r.string().required(),addressType:r.string().required(),city:r.string().nullable(),complement:r.string().nullable(),country:r.string().required().length(3),geoCoordinates:r.array().of(r.number()).required().min(0),isDisposable:r.boolean().required(),neighborhood:r.string().nullable(),number:r.string().nullable(),postalCode:r.string().required(),receiverName:r.string().nullable(),reference:r.string().nullable(),state:r.string().nullable(),street:r.string().nullable()}))});async function oe({apiUrl:t,body:e,fetchOptions:o}){if(!e){console.error("[ERROR FETCHING] Body is required");return}await te.validate(e);const{orderFormId:n,options:s,selectedAddresses:a}=e;return l(`${t}/api/checkout/pub/orderForm/${n}/attachments/shippingData`,{method:"POST",body:{selectedAddresses:a,clearAddressIfPostalCodeNotFound:!1,logisticsInfo:s},...o})}const ne=r.object({country:r.string().length(3,"Country code must be 3 characters long").required("Country is required"),postalCode:r.string().nullable(),geoCoordinates:r.object().shape({longitude:r.number().required(),latitude:r.number().required()})});async function ae({apiUrl:t,body:e,fetchOptions:o}){if(!e){console.error("[ERROR FETCHING] Body is required");return}await ne.validate(e);const{country:n="",geoCoordinates:s,postalCode:a=""}=e,i=new URLSearchParams({country:String(n)});return a?i.append("postalCode",a):i.append("geoCoordinates",`${s==null?void 0:s.longitude};${s==null?void 0:s.latitude}`),await l(`${t}/api/checkout/pub/regions/?${i.toString()}`,{method:"GET",...o})}const se=r.object({id:r.string().required("ID of SKU is required"),quantity:r.number().integer().required("Quantity of item is required"),seller:r.string()}),ie=r.object({items:r.array().of(se),country:r.string().length(3,"Country code must be 3 characters long").required("Country is required"),postalCode:r.string().nullable(),geoCoordinates:r.array().nullable().of(r.number()).length(2)});async function le({apiUrl:t,body:e,fetchOptions:o}){if(!e){console.error("[ERROR FETCHING] Body is required");return}return await ie.validate(e),l(`${t}/api/checkout/pub/orderForms/simulation`,{method:"POST",body:e,...o})}const ce=Object.freeze(Object.defineProperty({__proto__:null,getMasterDataSellerCode:Z,getOrderForm:Y,postOrderFormAddCoupon:w,postOrderFormAttachClientProfileData:X,postOrderFormAttachOrderFormData:j,postOrderFormAttachShippingData:re,postOrderFormAttachmentsMarketingData:F,postOrderFormAttachmentsOpenTextField:I,postOrderFormClearMessages:L,postOrderFormFreightSimulation:le,postOrderFormItems:_,postOrderFormRegion:ae,postOrderFormRemoveAllItems:B,postOrderFormUpdateItems:x,postOrderFormUpdateShippingData:oe,postOrderformAddress:q,putOrderFormCustomData:A,updateOrderFormOffering:J},Symbol.toStringTag,{value:"Module"})),de=r.object({skuId:r.string()});async function ue({apiUrl:t,body:e,fetchOptions:o}){if(!e){console.error("[ERROR FETCHING] Body is required");return}await de.validate(e);const{skuId:n}=e;return l(`${t}/api/catalog/pvt/stockkeepingunitkit?parentSkuId=${n}`,{...o})}const me=r.object({ids:r.array().of(r.string().required("ID are required")).required("IDs are required")});async function pe({apiUrl:t,body:e,fetchOptions:o}){if(!e){console.error("[ERROR FETCHING] Body is required");return}await me.validate(e);const{ids:n}=e;return l(`${t}/api/catalog_system/pub/products/search?fq=${n.map(s=>`productId:${s}`).join("&fq=")}`,{...o})}const ge=r.object({productId:r.number().required("Product ID is required")});async function he({apiUrl:t,body:e,fetchOptions:o}){if(!e){console.error("[ERROR FETCHING] Body is required");return}await ge.validate(e);const{productId:n}=e;return l(`${t}/api/catalog_system/pub/products/crossselling/similars/${n.toString()}`,{...o})}const fe=Object.freeze(Object.defineProperty({__proto__:null,getCatalogKitProducts:ue,getCatalogProducts:pe,getCatalogSimilars:he},Symbol.toStringTag,{value:"Module"})),be=(t="")=>t.charAt(0).toUpperCase()+t.slice(1),h=(t,e=" ")=>!t||typeof t=="string"&&t.length===0?t:(Array.isArray(t)?t:t.split("-")).map(be).join(e),Ie=({canonical:t,seo:e,slug:o})=>{const n=Array.isArray(o)?o.join(", "):o;return{id:0,Title:`${Array.isArray(o)?o.map(a=>h(a)).join(","):h(o)} - ${e.title}`,MetaTagDescription:e.description,name:n,hasChildren:!1,url:t,children:[]}},Fe=({canonical:t,category:e,previousImages:o,seo:n})=>({category:String(e==null?void 0:e.id),title:(e==null?void 0:e.Title)??n.title,description:(e==null?void 0:e.MetaTagDescription)??n.description,alternates:{canonical:t},openGraph:{type:"website",title:(e==null?void 0:e.Title)??n.title,description:(e==null?void 0:e.MetaTagDescription)??n.description,images:Array.isArray(o)?[...o]:[]}}),Ce=({items:t,parent:e,apiUrl:o,find:n})=>{const s=t.find(i=>i.url.replace(o,"")===decodeURIComponent(e.toLowerCase()));return(s==null?void 0:s.children.find(i=>i.name.toLowerCase()===decodeURIComponent(String(n))))??s},Oe=t=>{t instanceof Error?(console.error(`[ERROR CATEGORY INFO]: ${t.message}`),console.error(t.stack)):console.error("[ERROR CATEGORY INFO]: Unknown error",t)},$e=new Set(["brand","category","department","subcategory","collection","cluster"]),ye=t=>typeof(t==null?void 0:t.pageType)=="string"&&$e.has(t==null?void 0:t.pageType.toLowerCase()),Re=t=>({collection:t.Coleção,categoryId:t.categoryId,current_collection:t["Coleção Atual"],items:t.items}),qe=(t,e)=>t.reduce((o,n)=>{if(n.items.filter(i=>i.sellers.find(c=>c.commertialOffer.IsAvailable)).length===0||(o==null?void 0:o.find(i=>(i==null?void 0:i.productId)===(n==null?void 0:n.productId)))!==void 0)return o;const a=n.items[0].images.find(i=>e.includes(i.imageLabel));return o.push({slug:`/${n.linkText}/p`,productId:n==null?void 0:n.productId,textureImage:(a==null?void 0:a.imageUrl)??"",textureAlt:(a==null?void 0:a.imageText)??""}),o},[]),Te=Object.freeze(Object.defineProperty({__proto__:null,createEmptySeoCategory:Ie,createSeoCategory:Fe,findCategory:Ce,formattedSimilars:qe,isCollectionPageType:ye,notFindCategoryError:Oe,responseAdapter:Re},Symbol.toStringTag,{value:"Module"}));async function Se({contentType:t,storeId:e,CMS_PROJECT_NAME:o,NextCookies:n}){const s=await C({contentType:t,storeId:e,CMS_PROJECT_NAME:o,NextCookies:n});if(s.status===200){const a={timestamp:new Date().toISOString(),contentType:t,data:s.data};console.log("Resultado da chamada:",s);const i=`backup-${t}-${Date.now()}.json`;return await $.fs.writeFile(`./backups/${i}`,JSON.stringify(a,null,2),"utf-8"),{success:!0,fileName:i}}return{success:!1,error:s.error||"No data to backup"}}async function ve(t){return Se(t)}async function je({contentType:t,documentId:e,versionId:o,storeId:n,CMS_PROJECT_NAME:s}){const a=e&&e.length?`/${e}`:"",i=o&&o.length?`?versionId=${o}`:"";return fetch(`https://${n}.myvtex.com/_v/cms/api/${s}/${t}${a}${i}`,{cache:"no-cache"})}async function Ee({contentType:t,documents:e,NextCookies:o,CMS_PROJECT_NAME:n,storeId:s}){var i;const a=JSON.parse(((i=o().get("cms_preview_data"))==null?void 0:i.value)??"{}");if(a&&(a==null?void 0:a.contentType)===t){const c=a.documentId&&a.documentId.length?`/${a.documentId}`:"",m=a!=null&&a.versionId&&(a!=null&&a.versionId.length)?`?versionId=${a==null?void 0:a.versionId}`:"",p=await(await fetch(`https://${s}.myvtex.com/_v/cms/api/${n}/${t}${c}${m}`,{cache:"no-store"})).json(),d=e.filter(u=>p.id!==u.documentId);return d.unshift(p),d}return e}async function C({contentType:t,NextCookies:e,CMS_PROJECT_NAME:o,storeId:n}){var g,p;const s=JSON.parse(((g=e().get("cms_preview_data"))==null?void 0:g.value)??"{}"),a=[];let i=1,c=0,m=!0;try{do{const u=await(await fetch(`https://${n}.myvtex.com/_v/cms/api/${o}/${t}?page=${i}`)).json();i===1&&(c=u.totalItems),(p=u==null?void 0:u.data)!=null&&p.length&&a.push(...u.data),m=u.hasNextPage,i++}while(m&&a.length<c);if(s.previewMode&&a.length){const d=await Ee({contentType:t,documents:a,NextCookies:e,CMS_PROJECT_NAME:o,storeId:n});return{status:d.length>0?200:404,data:d??[]}}return{status:a.length?200:404,data:a}}catch(d){return{status:"error",data:[],error:d}}}const we=Object.freeze(Object.defineProperty({__proto__:null,cmsBackup:ve,getCMSContentType:je,getContentType:C},Symbol.toStringTag,{value:"Module"})),ke={checkout:ce,catalog:fe,cms:we},Ae={catalog:Te};exports.serverAPIs=ke;exports.serverHelpers=Ae;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const ee=require("yup"),C=require("./__vite-browser-external-DDWPeg5L.js"),te=require("sanitize-html");function re(e){const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const r in e)if(r!=="default"){const n=Object.getOwnPropertyDescriptor(e,r);Object.defineProperty(t,r,n.get?n:{enumerable:!0,get:()=>e[r]})}}return t.default=e,Object.freeze(t)}const o=re(ee),u=async(e,t={})=>{const{method:r="GET",body:n,headers:s={},priority:a="auto",cache:i="default"}=t;return fetch(e,{method:r,headers:{...s,Accept:"application/json","Content-Type":"application/json"},priority:a,cache:i,...n?{body:JSON.stringify(n)}:{}}).then(c=>c.json()).catch(c=>{console.error("[ERROR FETCH VTEX]",c)})},v=new Map;async function ne(e,t={}){var r;try{const{abort:n=!1}=t,s=new AbortController;n&&(v.has(e)&&((r=v.get(e))==null||r.abort(),v.delete(e)),v.set(e,s));const a=u(e,{...t,...n?{signal:s.signal}:{}});return n&&v.delete(e),a}catch(n){if(n.name==="AbortError"){console.log(`[REQUEST CANCELLED]: ${e}`);return}throw console.error(`[ERROR API]: ${n.message}`),n}}const oe=o.object({country:o.string().length(3,"Country code must be 3 characters long").required("Country is required"),postalCode:o.string().nullable()});async function ae({apiUrl:e,body:t,fetchOptions:r}){if(!t){console.error("[ERROR FETCHING] Body is required");return}await oe.validate(t);const{country:n,postalCode:s}=t;return await u(`${e}/api/checkout/pub/postal-code/${n}/${s}`,{method:"POST",body:t,...r})}const se=o.object({orderFormId:o.string().nullable(),sellerCode:o.string().nullable(),sellerName:o.string().nullable()});async function U({apiUrl:e,body:t,fetchOptions:r}){if(!t){console.error("[ERROR FETCHING] Body is required");return}await se.validate(t);const{orderFormId:n,sellerCode:s,sellerName:a}=t,i=s?`${s.trim()} - ${a}`:null;return u(`${e}/api/checkout/pub/orderForm/${n}/attachments/openTextField`,{method:"POST",body:{value:i},...r})}const ie=o.object({orderFormId:o.string().nullable(),sellerCode:o.string().nullable(),marketingData:o.object()});async function V({apiUrl:e,body:t,fetchOptions:r}){if(!t){console.error("[ERROR FETCHING] Body is required");return}await ie.validate(t);const{orderFormId:n,sellerCode:s,marketingData:a}=t,i=s?{utmCampaign:s?s.toUpperCase():"",utmiCampaign:s?"codigodavendedora":"semcodigo"}:{};return u(`${e}/api/checkout/pub/orderForm/${n}/attachments/marketingData`,{method:"POST",body:{...a,...i},...r})}const ce=o.object({orderFormId:o.string().nullable(),sellerCode:o.string().nullable(),sellerName:o.string().nullable()});async function le({apiUrl:e,body:t,fetchOptions:r}){if(!t){console.error("[ERROR FETCHING] Body is required");return}await ce.validate(t);const n=await U({apiUrl:e,body:t,fetchOptions:r});return V({apiUrl:e,body:{...t,marketingData:n==null?void 0:n.marketingData},fetchOptions:r})}const ue=o.object({orderFormId:o.string().nullable(),coupon:o.string().nullable()});async function de({apiUrl:e,body:t,fetchOptions:r}){if(!t){console.error("[ERROR FETCHING] Body is required");return}await ue.validate(t);const{coupon:n="",orderFormId:s}=t;return u(`${e}/api/checkout/pub/orderForm/${s}/coupons`,{method:"POST",body:{text:n},...r})}const me=o.object({appId:o.string().required("App ID is required"),orderFormId:o.string().nullable(),key:o.array().of(o.string())});async function pe({apiUrl:e,body:t,fetchOptions:r}){if(!t){console.error("[ERROR FETCHING] Body is required");return}await me.validate(t);const{appId:n="faststore",orderFormId:s,key:a}=t;return u(`${e}/api/checkout/pub/orderForm/${s}/customData/${n}/${a}`,{method:"PUT",...r})}const ge=o.object().shape({name:o.string().required("Attachment name is required"),content:o.object().nullable()});var G;const fe=o.object().shape({attachments:(G=o.array().of(ge))==null?void 0:G.nullable(),id:o.string().required("ID of SKU is required"),index:o.number().integer().nullable(),quantity:o.number().integer().nullable(),seller:o.string().required("Seller is required"),price:o.number().integer()}),he=o.object({orderFormId:o.string().required("OrderFormId is required"),orderItems:o.array().of(fe)});async function Ie({apiUrl:e,body:t,fetchOptions:r}){if(!t){console.error("[ERROR FETCHING] Body is required");return}await he.validate(t);const{orderFormId:n,orderItems:s}=t;return u(`${e}/api/checkout/pub/orderForm/${n}/items`,{method:"POST",body:{orderItems:s},...r})}const be=o.object({orderFormId:o.string().nullable()});async function ye({apiUrl:e,body:t,fetchOptions:r}){if(!t){console.error("[ERROR FETCHING] Body is required");return}await be.validate(t);const{orderFormId:n}=t;return u(`${e}/api/checkout/pub/orderForm/${n}/items/removeAll`,{method:"POST",...r})}const Ce=o.object().shape({name:o.string().required("Attachment name is required"),content:o.object().nullable()});var B;const Re=o.object().shape({attachments:(B=o.array().of(Ce))==null?void 0:B.nullable(),id:o.string().required("ID of SKU is required"),index:o.number().integer().nullable(),quantity:o.number().integer().nullable(),seller:o.string().required("Seller is required"),price:o.number().integer()}),Oe=o.object({orderFormId:o.string().nullable(),orderItems:o.array().of(Re)});async function Fe({apiUrl:e,body:t,fetchOptions:r}){if(!t){console.error("[ERROR FETCHING] Body is required");return}await Oe.validate(t);const{orderFormId:n,orderItems:s}=t;return u(`${e}/api/checkout/pub/orderForm/${n}/items/update`,{method:"POST",body:{orderItems:s},...r})}const ve=o.object({orderFormId:o.string().nullable()});async function Se({apiUrl:e,body:t,fetchOptions:r}){if(!t){console.error("[ERROR FETCHING] Body is required");return}await ve.validate(t);const{orderFormId:n}=t;return u(`${e}/api/checkout/pub/orderForm/${n}/messages/clear`,{method:"POST",...r})}const $e=o.object({id:o.string().nullable(),itemIndex:o.number().nullable(),orderFormId:o.string().nullable(),remove:o.boolean().nullable()});async function Ee({apiUrl:e,body:t,fetchOptions:r}){if(!t){console.error("[ERROR FETCHING] Body is required");return}await $e.validate(t);const{itemIndex:n,orderFormId:s,id:a,remove:i}=t,c=i?`/${a}/remove`:"",l=`${e}/api/checkout/pub/orderForm/${s}/items/${n}/offerings${c}`;return u(l,{method:"POST",body:{id:a},...r})}const qe=o.object({orderFormId:o.string().nullable()});async function Te({apiUrl:e,body:t,fetchOptions:r,extraData:n}){var i;if(!t){console.error("[ERROR FETCHING] Body is required");return}await qe.validate(t);const s=new URLSearchParams({refreshOutdatedData:"true"}),a=t.orderFormId&&((i=n.orderFormPurchaseId)==null?void 0:i.value)!==t.orderFormId?`${e}/api/checkout/pub/orderForm/${t.orderFormId}?${String(s)}`:`${e}/api/checkout/pub/orderForm`;return u(a,{method:"GET",...r})}const Pe=o.object({orderFormId:o.string().nullable(),email:o.string().email().required(),firstName:o.string().required(),lastName:o.string().required(),documentType:o.string().required(),document:o.string().required(),phone:o.string().matches(/^\+\d{1,3}\d{10,11}$/)});async function Ae({apiUrl:e,body:t,fetchOptions:r}){if(!t){console.error("[ERROR FETCHING] Body is required");return}await Pe.validate(t);const{orderFormId:n,...s}=t;return u(`${e}/api/checkout/pub/orderForm/${n}/attachments/clientProfileData`,{method:"POST",body:{...s},...r})}const Ne=o.object({sellerCode:o.string().nullable()});async function je({apiUrl:e,body:t,fetchOptions:r}){if(!t){console.error("[ERROR FETCHING] Body is required");return}await Ne.validate(t);const{sellerCode:n=""}=t;return u(`${e}/api/dataentities/VD/search?_fields=id,cod,name,ativo&cod=${n}`,{method:"GET",headers:{Accept:"application/vnd.vtex.ds.v10+json"},...r})}const ke=o.object().shape({country:o.string().length(3,"Country code must be 3 characters long").required("Country is required"),orderFormId:o.string().nullable(),postalCode:o.string().nullable()});async function we({apiUrl:e,body:t,fetchOptions:r}){if(!t){console.error("[ERROR FETCHING] Body is required");return}await ke.validate(t);const{country:n,orderFormId:s,postalCode:a}=t,i=a?{address:{addressType:"residential",postalCode:a,country:n}}:{logisticsInfo:[],clearAddressIfPostalCodeNotFound:!0};return u(`${e}/api/checkout/pub/orderForm/${s}/attachments/shippingData`,{method:"POST",body:i,...r})}const _e=o.object().shape({orderFormId:o.string().nullable(),options:o.array().of(o.object().shape({itemIndex:o.number(),selectedDeliveryChannel:o.string(),selectedSla:o.string()})),selectedAddresses:o.array().of(o.object().shape({addressId:o.string().required(),addressType:o.string().required(),city:o.string().nullable(),complement:o.string().nullable(),country:o.string().required().length(3),geoCoordinates:o.array().of(o.number()).required().min(0),isDisposable:o.boolean().required(),neighborhood:o.string().nullable(),number:o.string().nullable(),postalCode:o.string().required(),receiverName:o.string().nullable(),reference:o.string().nullable(),state:o.string().nullable(),street:o.string().nullable()}))});async function De({apiUrl:e,body:t,fetchOptions:r}){if(!t){console.error("[ERROR FETCHING] Body is required");return}await _e.validate(t);const{orderFormId:n,options:s,selectedAddresses:a}=t;return u(`${e}/api/checkout/pub/orderForm/${n}/attachments/shippingData`,{method:"POST",body:{selectedAddresses:a,clearAddressIfPostalCodeNotFound:!1,logisticsInfo:s},...r})}const He=o.object({country:o.string().length(3,"Country code must be 3 characters long").required("Country is required"),postalCode:o.string().nullable(),geoCoordinates:o.object().shape({longitude:o.number().required(),latitude:o.number().required()})});async function Ge({apiUrl:e,body:t,fetchOptions:r}){if(!t){console.error("[ERROR FETCHING] Body is required");return}await He.validate(t);const{country:n="",geoCoordinates:s,postalCode:a=""}=t,i=new URLSearchParams({country:String(n)});return a?i.append("postalCode",a):i.append("geoCoordinates",`${s==null?void 0:s.longitude};${s==null?void 0:s.latitude}`),await u(`${e}/api/checkout/pub/regions/?${i.toString()}`,{method:"GET",...r})}const Be=o.object({id:o.string().required("ID of SKU is required"),quantity:o.number().integer().required("Quantity of item is required"),seller:o.string()}),Ue=o.object({items:o.array().of(Be),country:o.string().length(3,"Country code must be 3 characters long").required("Country is required"),postalCode:o.string().nullable(),geoCoordinates:o.array().nullable().of(o.number()).length(2)});async function Ve({apiUrl:e,body:t,fetchOptions:r}){if(!t){console.error("[ERROR FETCHING] Body is required");return}return await Ue.validate(t),u(`${e}/api/checkout/pub/orderForms/simulation`,{method:"POST",body:t,...r})}const Le=Object.freeze(Object.defineProperty({__proto__:null,getMasterDataSellerCode:je,getOrderForm:Te,postOrderFormAddCoupon:de,postOrderFormAttachClientProfileData:Ae,postOrderFormAttachOrderFormData:le,postOrderFormAttachShippingData:we,postOrderFormAttachmentsMarketingData:V,postOrderFormAttachmentsOpenTextField:U,postOrderFormClearMessages:Se,postOrderFormFreightSimulation:Ve,postOrderFormItems:Ie,postOrderFormRegion:Ge,postOrderFormRemoveAllItems:ye,postOrderFormUpdateItems:Fe,postOrderFormUpdateShippingData:De,postOrderformAddress:ae,putOrderFormCustomData:pe,updateOrderFormOffering:Ee},Symbol.toStringTag,{value:"Module"})),Me=o.object({skuId:o.string()});async function xe({apiUrl:e,body:t,fetchOptions:r}){if(!t){console.error("[ERROR FETCHING] Body is required");return}await Me.validate(t);const{skuId:n}=t;return u(`${e}/api/catalog/pvt/stockkeepingunitkit?parentSkuId=${n}`,{...r})}const ze=o.object({ids:o.array().of(o.string().required("ID are required")).required("IDs are required")});async function Qe({apiUrl:e,body:t,fetchOptions:r}){if(!t){console.error("[ERROR FETCHING] Body is required");return}await ze.validate(t);const{ids:n}=t;return u(`${e}/api/catalog_system/pub/products/search?fq=${n.map(s=>`productId:${s}`).join("&fq=")}`,{...r})}const Je=o.object({productId:o.number().required("Product ID is required")});async function Ke({apiUrl:e,body:t,fetchOptions:r}){if(!t){console.error("[ERROR FETCHING] Body is required");return}await Je.validate(t);const{productId:n}=t;return u(`${e}/api/catalog_system/pub/products/crossselling/similars/${n.toString()}`,{...r})}const Ye=Object.freeze(Object.defineProperty({__proto__:null,getCatalogKitProducts:xe,getCatalogProducts:Qe,getCatalogSimilars:Ke},Symbol.toStringTag,{value:"Module"})),We=(e="")=>e.charAt(0).toUpperCase()+e.slice(1),_=(e,t=" ")=>!e||typeof e=="string"&&e.length===0?e:(Array.isArray(e)?e:e.split("-")).map(We).join(t),Xe=({canonical:e,seo:t,slug:r})=>{const n=Array.isArray(r)?r.join(", "):r;return{id:0,Title:`${Array.isArray(r)?r.map(a=>_(a)).join(","):_(r)} - ${t.title}`,MetaTagDescription:t.description,name:n,hasChildren:!1,url:e,children:[]}},Ze=({canonical:e,category:t,previousImages:r,seo:n})=>({category:String(t==null?void 0:t.id),title:(t==null?void 0:t.Title)??n.title,description:(t==null?void 0:t.MetaTagDescription)??n.description,alternates:{canonical:e},openGraph:{type:"website",title:(t==null?void 0:t.Title)??n.title,description:(t==null?void 0:t.MetaTagDescription)??n.description,images:Array.isArray(r)?[...r]:[]}}),et=({items:e,parent:t,apiUrl:r,find:n})=>{const s=e.find(i=>i.url.replace(r,"")===decodeURIComponent(t.toLowerCase()));return(s==null?void 0:s.children.find(i=>i.name.toLowerCase()===decodeURIComponent(String(n))))??s},tt=e=>{e instanceof Error?(console.error(`[ERROR CATEGORY INFO]: ${e.message}`),console.error(e.stack)):console.error("[ERROR CATEGORY INFO]: Unknown error",e)},rt=new Set(["brand","category","department","subcategory","collection","cluster"]),nt=e=>typeof(e==null?void 0:e.pageType)=="string"&&rt.has(e==null?void 0:e.pageType.toLowerCase()),ot=e=>({collection:e.Coleção,categoryId:e.categoryId,current_collection:e["Coleção Atual"],items:e.items}),at=(e,t)=>e.reduce((r,n)=>{if(n.items.filter(i=>i.sellers.find(c=>c.commertialOffer.IsAvailable)).length===0||(r==null?void 0:r.find(i=>(i==null?void 0:i.productId)===(n==null?void 0:n.productId)))!==void 0)return r;const a=n.items[0].images.find(i=>t.includes(i.imageLabel));return r.push({slug:`/${n.linkText}/p`,productId:n==null?void 0:n.productId,textureImage:(a==null?void 0:a.imageUrl)??"",textureAlt:(a==null?void 0:a.imageText)??""}),r},[]),st=Object.freeze(Object.defineProperty({__proto__:null,createEmptySeoCategory:Xe,createSeoCategory:Ze,findCategory:et,formattedSimilars:at,isCollectionPageType:nt,notFindCategoryError:tt,responseAdapter:ot},Symbol.toStringTag,{value:"Module"}));async function it({contentType:e,storeId:t,CMS_PROJECT_NAME:r,NextCookies:n}){const s=await L({contentType:e,storeId:t,CMS_PROJECT_NAME:r,NextCookies:n});if(s.status===200){const a={timestamp:new Date().toISOString(),contentType:e,data:s.data};console.log("Resultado da chamada:",s);const i=`backup-${e}-${Date.now()}.json`;return await C.fs.writeFile(`./backups/${i}`,JSON.stringify(a,null,2),"utf-8"),{success:!0,fileName:i}}return{success:!1,error:s.error||"No data to backup"}}async function ct(e){return it(e)}async function lt({contentType:e,documentId:t,versionId:r,storeId:n,CMS_PROJECT_NAME:s}){const a=t&&t.length?`/${t}`:"",i=r&&r.length?`?versionId=${r}`:"";return fetch(`https://${n}.myvtex.com/_v/cms/api/${s}/${e}${a}${i}`,{cache:"no-cache"})}async function ut({contentType:e,documents:t,NextCookies:r,CMS_PROJECT_NAME:n,storeId:s}){var i;const a=JSON.parse(((i=r().get("cms_preview_data"))==null?void 0:i.value)??"{}");if(a&&(a==null?void 0:a.contentType)===e){const c=a.documentId&&a.documentId.length?`/${a.documentId}`:"",l=a!=null&&a.versionId&&(a!=null&&a.versionId.length)?`?versionId=${a==null?void 0:a.versionId}`:"",p=await(await fetch(`https://${s}.myvtex.com/_v/cms/api/${n}/${e}${c}${l}`,{cache:"no-store"})).json(),d=t.filter(m=>p.id!==m.documentId);return d.unshift(p),d}return t}async function L({contentType:e,NextCookies:t,CMS_PROJECT_NAME:r,storeId:n}){var g,p;const s=JSON.parse(((g=t().get("cms_preview_data"))==null?void 0:g.value)??"{}"),a=[];let i=1,c=0,l=!0;try{do{const m=await(await fetch(`https://${n}.myvtex.com/_v/cms/api/${r}/${e}?page=${i}`)).json();i===1&&(c=m.totalItems),(p=m==null?void 0:m.data)!=null&&p.length&&a.push(...m.data),l=m.hasNextPage,i++}while(l&&a.length<c);if(s.previewMode&&a.length){const d=await ut({contentType:e,documents:a,NextCookies:t,CMS_PROJECT_NAME:r,storeId:n});return{status:d.length>0?200:404,data:d??[]}}return{status:a.length?200:404,data:a}}catch(d){return{status:"error",data:[],error:d}}}const dt=Object.freeze(Object.defineProperty({__proto__:null,cmsBackup:ct,getCMSContentType:lt,getContentType:L},Symbol.toStringTag,{value:"Module"})),mt=o.object({query:o.string()});async function pt({apiUrl:e,body:t,fetchOptions:r}){if(!t){console.error("[ERROR FETCHING] Body is required");return}await mt.validate(t);const{query:n=""}=t,s=new URLSearchParams({query:n});return u(`${e}/api/io/_v/api/intelligent-search/autocomplete_suggestions?${s.toString()}`,{...r})}const gt=(e,t)=>te(e,t),ft=e=>({...e,description:e.description?gt(e.description):e.description}),ht=({offer:e,seller:t,product:r})=>({...e,product:r,seller:t}),M=(e,t)=>({...e,isVariantOf:ft(t)}),It=e=>e?"https://schema.org/InStock":"https://schema.org/OutOfStock",E=e=>e.AvailableQuantity>0,D=e=>e.spotPrice??0,bt=e=>e.Price??0,x=(e,t)=>E(e)&&!E(t)?-1:!E(e)&&E(t)?1:D(e)-D(t),yt=(e,t)=>{let r=0;for(let n=1;n<e.length;n++)t(e[r],e[n])>0&&(r=n);return e[r]},z=e=>{const t=e.flatMap(n=>n.sellers.map(s=>({offer:s.commertialOffer,sku:n}))),r=yt(t,({offer:n},{offer:s})=>x(n,s));return r?r.sku:e[0]},Q=e=>e.map(({imageUrl:t,imageText:r,imageLabel:n})=>({alternateName:r??"",url:t.replace("vteximg.com.br","vtexassets.com"),keywords:n})),q={attachment:"ATTACHMENT",specification:"SPECIFICATION",attribute:"ATTRIBUTE"},Ct=e=>({name:e.name,value:e.content,valueReference:q.attachment}),Rt=e=>({propertyID:e.id,name:e.name,value:e.value,valueReference:{valueReference:q.attribute,visible:e.visible}}),T=(e,t,r)=>{const n=e.flatMap(({name:i,values:c})=>c?c.map(l=>({name:i,value:l,valueReference:q.specification})):{name:i,value:"",valueReference:q.specification}),s=Array.isArray(r)?r.map(Ct):[],a=t?t.map(Rt):[];return[...n,...s,...a]},H="ÁÄÂÀÃÅČÇĆĎÉĚËÈÊẼĔȆÍÌÎÏŇÑÓÖÒÔÕØŘŔŠŤÚŮÜÙÛÝŸŽáäâàãåčçćďéěëèêẽĕȇíìîïňñóöòôõøðřŕšťúůüùûýÿžþÞĐđ߯a",Ot="AAAAAACCCDEEEEEEEEIIIINNOOOOOORRSTUUUUUYYZaaaaaacccdeeeeeeeeiiiinnooooooorrstuuuuuyyzbBDdBAa",Ft=e=>{let t=e.slice(0);for(let r=0;r<H.length;r++)t=t.replace(new RegExp(H.charAt(r),"g"),Ot.charAt(r));return t},vt=e=>e.replace(/[·/_,:]/,"-"),J=e=>{const r=e.replace(/,/g,"").replace(/[*+~.()'"!:@&\[\]`/ %$#?{}|><=_^]/g,"-");return vt(Ft(r)).toLowerCase()},K=e=>`/${e}/p`,Y=e=>{const t=Math.max(...e.map(n=>n.NumberOfInstallments)),r=e.find(n=>n.NumberOfInstallments===t);return{count:(r==null?void 0:r.NumberOfInstallments)??0,value:(r==null?void 0:r.Value)??0}},W=(e,t)=>{const r={price:0,listPrice:0,sellerDefault:!1},s=e.map(a=>ht({offer:a.commertialOffer,seller:a,product:t})).sort(x).map(a=>(a.seller.sellerId==="1"&&a.AvailableQuantity>0&&(r.price=a.Price,r.listPrice=a.ListPrice,r.sellerDefault=!0),{availability:a.AvailableQuantity>0,listPrice:a.ListPrice,price:bt(a),priceValidUntil:a.PriceValidUntil,priceCurrency:"BRL",installments:a.Installments,lowPrice:a.spotPrice,quantity:a.AvailableQuantity,seller:{identifier:a.seller.sellerId}}));return{lowPrice:r.sellerDefault?r.price:s[0].price,highPrice:r.sellerDefault?r.listPrice:s[0].listPrice,offers:s}},X=e=>{const{attributes:t,itemId:r,name:n,sellers:s,variations:a}=e;return{additionalProperty:T(a,t,[]),name:n,offers:{offers:s.map(({sellerId:i,commertialOffer:c})=>({availability:It(c.AvailableQuantity>0),listPrice:c.ListPrice,price:c.Price,quantity:c.AvailableQuantity,seller:{identifier:i}}))},sku:r}},St=e=>{var O;const{attributes:t,referenceId:r,isVariantOf:n,images:s,itemId:a,name:i,sellers:c,videos:l,variations:g}=e,{brand:p,categories:d,categoriesIds:m,description:b,linkText:f,productClusters:P,clusterHighlights:S,productName:$,properties:A,productId:N}=n,j=d.slice().reverse(),y=W(c,e.isVariantOf),k=Y(y.offers[0].installments);return{sku:a,gtin:((O=r[0])==null?void 0:O.Value)??"",name:$??i,description:b,releaseDate:n.releaseDate??"",slug:f,video:l[0],categories:d,categoriesIds:m,id:N,brand:{name:p,brandName:p},seo:{description:b,title:$,canonical:K(f)},cluster:{generals:P,highlights:S},properties:A,availability:{status:y.offers[0].availability},breadcrumbList:{itemListElement:[...j.map((h,F)=>{const I=h.split("/"),R=I[I.length-2],w=I.map(J).join("/");return{name:R,item:w,position:F+1}}),{name:n.productName,item:f,position:d.length+1}],numberOfItems:d.length},image:Q(s),offers:y,additionalProperty:T(g,t,[]),isVariantOf:{productGroupID:n.productId,hasVariant:n.items.map(h=>X(h))},installments:k}},$t=e=>{var O;const{attributes:t,referenceId:r,isVariantOf:n,images:s,itemId:a,name:i,sellers:c,Videos:l,variations:g}=e,{brand:p,categories:d,categoriesIds:m,description:b,linkText:f,productClusters:P,productName:S,Coleção:$,"ID Coleção":A,productId:N}=n,j=d.slice().reverse(),y=W(c,e.isVariantOf),k=Y(y.offers[0].installments);return{sku:a,gtin:((O=r[0])==null?void 0:O.Value)??"",name:S??i,description:b,releaseDate:n.releaseDate??"",slug:f,video:l[0],categories:d,categoriesIds:m,collection:$,collectionId:A,id:N,brand:{name:p,brandName:p},seo:{description:b,title:S,canonical:K(f)},cluster:{generals:P,highlights:[]},availability:{status:y.offers[0].availability},breadcrumbList:{itemListElement:[...j.map((h,F)=>{const I=h.split("/"),R=I[I.length-2],w=I.map(J).join("/");return{name:R,item:w,position:F+1}}),{name:n.productName,item:f,position:d.length+1}],numberOfItems:d.length},image:Q(s),offers:y,additionalProperty:T(g,t,[]),isVariantOf:{productGroupID:n.productId,hasVariant:n.items.map(h=>{const{variations:F}=h,I=F.map(R=>({name:R,values:h[R]}));return{...X(h),additionalProperty:T(I,t,[])}})},installments:k}},Et=o.array().of(o.object({key:o.string().required(),value:o.string().required()})).required("Facets are required");async function qt({apiUrl:e,body:t,fetchOptions:r}){if(!t){console.error("[ERROR FETCHING] Body is required");return}await Et.validate(t);const n=new URLSearchParams({}),s=t.map(({key:i,value:c})=>`${i}/${c}`).join("/");C.addSearchParamsFacets(t,n);const a=`${e}/api/catalog_system/pub/products/crossselling/${s}`;return u(a,{cache:"no-store",...r}).then(i=>i.map(l=>{const g=z(l.items);return g&&M(g,l)}).filter(l=>!!l).map(l=>({node:$t(l)})))}const Z=({apiUrl:e,body:t,fetchOptions:r,extraData:n})=>{if(!t){console.error("[ERROR FETCHING] Body is required");return}const{query:s="",page:a=1,count:i,sort:c="",facets:l=[],type:g,hideUnavailableItems:p=!0,locale:d=""}=t,m=new URLSearchParams({page:a.toString(),count:(i==null?void 0:i.toString())??(n==null?void 0:n.ITEMS_PER_PAGE)??24,query:s,sort:c,locale:d});p!==void 0&&m.append("hideUnavailableItems",p.toString());const b=l.map(f=>`${f.key}/${f.value}`).join("/")??"";return ne(`${e}/api/io/_v/api/intelligent-search/${g}/${b}?${m.toString()}`,{headers:{Accept:"application/json","content-type":"application/json"},...r})};async function Tt({body:e,extraData:t,...r}){if(!e){console.error("[ERROR FETCHING] Body is required");return}const n=await Z({body:{...e,type:"product_search"},extraData:t,...r}),s=(n==null?void 0:n.products.map(c=>{const l=z(c.items);return l&&M(l,c)}).filter(c=>!!c))??[],{pagination:a,recordsFiltered:i}=n;return{data:{pagination:{nextPage:a.after.length>0,previousPage:a.before.length>0,startCursor:"0",endCursor:i.toString(),count:i,total:a.count},products:s.map((c,l)=>({node:St(c),cursor:l.toString()}))}}}async function Pt({body:e,extraData:t,...r}){if(!e){console.error("[ERROR FETCHING] Body is required");return}const n=await Z({body:{...e,type:"facets"},extraData:t,...r});return!n||!n.facets?(console.error("[ERROR FETCHING] No facets found"),{data:{facets:[]}}):{data:{...n,facets:C.formattedFacets(n,e==null?void 0:e.selectedFacets,(e==null?void 0:e.query)??"")}}}const At=o.object({query:o.string().optional(),locale:o.string().optional()});async function Nt({apiUrl:e,body:t,fetchOptions:r}){if(!t){console.error("[ERROR FETCHING] Body is required");return}await At.validate(t);const{query:n="",locale:s="default_locale"}=t,a=new URLSearchParams({query:n,locale:s});return u(`${e}/api/io/_v/api/intelligent-search/search_suggestions?${a.toString()}`,{...r})}async function jt({apiUrl:e}){return u(`${e}/api/io/_v/api/intelligent-search/top_searches`)}const kt=Object.freeze(Object.defineProperty({__proto__:null,getSearchAutoCompleteSuggestions:pt,getSearchCrossellingProducts:qt,getSearchFacets:Pt,getSearchProducts:Tt,getSearchSuggestedTerms:Nt,getSearchTopSearchs:jt},Symbol.toStringTag,{value:"Module"})),wt={parseSearchState:C.parseSearchState,convertSearchParams:C.convertSearchParams,filterNonRootFacets:C.filterNonRootFacets,filterNonCategorySelected:C.filterNonCategorySelected},_t={checkout:Le,catalog:Ye,cms:dt,search:kt},Dt={catalog:st,search:wt};exports.serverAPIs=_t;exports.serverHelpers=Dt;