@soma-vertical-web/multi-lib 0.0.50 → 0.0.51

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 (45) hide show
  1. package/cms/Sections/Newsletter/Component.d.ts +5 -0
  2. package/cms/index.d.ts +3 -0
  3. package/contexts/contexts/newsletter/Context.d.ts +6 -0
  4. package/contexts/contexts/pdp/PDPDataContext.d.ts +1 -1
  5. package/contexts/hooks/useDisableZoom.d.ts +1 -0
  6. package/contexts/hooks/useLocalStorage.d.ts +1 -0
  7. package/contexts/hooks/useSentinel.d.ts +11 -0
  8. package/contexts/hooks/useTouchZoomPan.d.ts +8 -0
  9. package/contexts/index.d.ts +29 -1
  10. package/data/api/checkout/order-form/attachments/marketing-data/index.d.ts +1 -1
  11. package/data/api/checkout/order-form/seller-code/index.d.ts +1 -1
  12. package/data/api/master-data/index.d.ts +3 -0
  13. package/data/api/master-data/masterdata/index.d.ts +26 -0
  14. package/data/api/master-data/search/index.d.ts +61 -0
  15. package/data/api/master-data/update/index.d.ts +29 -0
  16. package/data/helpers/events/index.d.ts +1 -1
  17. package/data/helpers/product/thumb.d.ts +2 -2
  18. package/index-CkcBCfzG.js +1 -0
  19. package/index-catAI5a3.mjs +258 -0
  20. package/index.js +26 -26
  21. package/index.mjs +5787 -5069
  22. package/index2.js +1 -1
  23. package/index2.mjs +789 -692
  24. package/layout/index.d.ts +4 -0
  25. package/layout/team-component/Newsletter/Composite/Form.d.ts +7 -0
  26. package/layout/team-component/Newsletter/Composite/FormFields.d.ts +7 -0
  27. package/layout/team-component/Newsletter/Composite/Input.d.ts +7 -0
  28. package/layout/team-component/Newsletter/Composite/SubmitButton.d.ts +8 -0
  29. package/layout/team-component/Newsletter/Composite/Success.d.ts +10 -0
  30. package/layout/team-component/Newsletter/Composite/Terms.d.ts +7 -0
  31. package/layout/team-component/Newsletter/helpers.d.ts +21 -0
  32. package/layout/team-component/Newsletter/index.d.ts +7 -0
  33. package/layout/template/PDP/Composite/Gallery/Wrapper.d.ts +1 -1
  34. package/layout/template/PDP/Composite/Gallery/index.d.ts +1 -1
  35. package/package.json +1 -1
  36. package/server.d.ts +4 -1
  37. package/style.css +1 -1
  38. package/types/cms/ContentTypes/Tipbar/index.d.ts +1 -0
  39. package/types/constants.d.ts +34 -0
  40. package/types/contexts/contexts/pdp.d.ts +3 -1
  41. package/types/contexts/store/cart.d.ts +3 -0
  42. package/types/data/events/index.d.ts +1 -0
  43. package/types/data/helpers/index.d.ts +5 -1
  44. package/types/layout/team-components/Newsletter/index.d.ts +13 -2
  45. package/types/layout/templates/PDP/index.d.ts +1 -0
@@ -0,0 +1,5 @@
1
+ import { NewsLetterSectionType } from '../../../types/cms/Sections/Newsletter';
2
+
3
+ export declare const NewsletterSection: ({ data: { componentIndex, ...props }, ClientNewsletterSection, }: NewsLetterSectionType & {
4
+ ClientNewsletterSection: React.ComponentType<any>;
5
+ }) => import("react/jsx-runtime").JSX.Element;
package/cms/index.d.ts CHANGED
@@ -16,6 +16,9 @@ export declare const clientCMS: {
16
16
  ImageGrid: (data: import('../types/cms/Sections/ImageGrid').ImageGridSectionType) => import("react/jsx-runtime").JSX.Element;
17
17
  SearchPageScreening: ({ children, data, SectionZone, className, }: import('../types/cms/ContentTypes/Search').SearchPageScrenningProps) => import("react/jsx-runtime").JSX.Element;
18
18
  SearchContent: ({ SectionZone, CMS_PROJECT_NAME, storeId, previewId }: import('../types/cms/ContentTypes/Search').SearchContentProps) => import("react/jsx-runtime").JSX.Element;
19
+ NewsletterSection: ({ data: { componentIndex, ...props }, ClientNewsletterSection, }: import('../types/cms/Sections/Newsletter').NewsLetterSectionType & {
20
+ ClientNewsletterSection: React.ComponentType<any>;
21
+ }) => import("react/jsx-runtime").JSX.Element;
19
22
  };
20
23
  helpers: typeof helpers;
21
24
  };
@@ -0,0 +1,6 @@
1
+ import { NewsletterContextProps, NewsletterProviderProps } from '../../../types/layout/team-components/Newsletter';
2
+
3
+ declare const NewsletterContext: import('react').Context<NewsletterContextProps>;
4
+ declare const NewsletterProvider: ({ children, masterDataEmailField, fields, variant, CONSTANTS: { MASTER_DATA_ENTITY, NEWSLETTER_CONFIGS }, }: NewsletterProviderProps) => import("react/jsx-runtime").JSX.Element;
5
+ declare const useNewsletterContext: () => NewsletterContextProps;
6
+ export { NewsletterContext, NewsletterProvider, useNewsletterContext };
@@ -1,4 +1,4 @@
1
1
  import { PDPDataContextProps, PDPDataProviderProps } from '../../../types/contexts/contexts/pdp';
2
2
 
3
- export declare const PDPDataProvider: ({ children, productData, isKit, PDP_INFO, NAME_SPLIT_SYMBOL }: PDPDataProviderProps) => import("react/jsx-runtime").JSX.Element;
3
+ export declare const PDPDataProvider: ({ children, productData, isKit, PDP_INFO, NAME_SPLIT_SYMBOL, TEXTURE_IMAGE, }: PDPDataProviderProps) => import("react/jsx-runtime").JSX.Element;
4
4
  export declare const usePDPDataContext: () => PDPDataContextProps;
@@ -0,0 +1 @@
1
+ export declare const useDisableZoom: () => void;
@@ -0,0 +1 @@
1
+ export declare const useLocalStorage: (key: any, defaultValue: any) => any[];
@@ -0,0 +1,11 @@
1
+ export declare const useSentinel: ({ callback, onEnterViewportOnce, options, }: {
2
+ callback: Function;
3
+ onEnterViewportOnce?: boolean;
4
+ options: {
5
+ root?: Element | Document | null;
6
+ rootMargin?: string;
7
+ threshold?: number | number[];
8
+ };
9
+ }) => {
10
+ element: import('react').RefObject<HTMLDivElement | null>;
11
+ };
@@ -0,0 +1,8 @@
1
+ export declare const useTouchZoomPan: ({ defaultScale, maxScale, }: {
2
+ defaultScale?: number | undefined;
3
+ maxScale?: number | undefined;
4
+ }) => {
5
+ containerRef: import('react').RefObject<HTMLDivElement | null>;
6
+ imgRef: import('react').RefObject<HTMLImageElement | null>;
7
+ scale: number;
8
+ };
@@ -1,3 +1,4 @@
1
+ import { useOnScreen } from './hooks/useOnScreen';
1
2
  import { Mediator } from './contexts/GlobalContext';
2
3
 
3
4
  import * as cart from './store/cart';
@@ -41,6 +42,10 @@ export declare const contexts: {
41
42
  provider: ({ data, children, }: import('../types/contexts/contexts/cms/FlagsAndTags').FlagsAndTagsProviderProps) => import("react/jsx-runtime").JSX.Element;
42
43
  };
43
44
  };
45
+ newsletter: {
46
+ hook: () => import('../types/layout/team-components/Newsletter').NewsletterContextProps;
47
+ provider: ({ children, masterDataEmailField, fields, variant, CONSTANTS: { MASTER_DATA_ENTITY, NEWSLETTER_CONFIGS }, }: import('../types/layout/team-components/Newsletter').NewsletterProviderProps) => import("react/jsx-runtime").JSX.Element;
48
+ };
44
49
  events: {
45
50
  hook: () => import('../types/data/events').EventContextProps;
46
51
  provider: ({ children, evtFunctionsConfigs }: import('../types/data/events').EventProviderProps) => import("react/jsx-runtime").JSX.Element;
@@ -94,7 +99,7 @@ export declare const contexts: {
94
99
  };
95
100
  pdpdata: {
96
101
  hook: () => import('../types/contexts/contexts/pdp').PDPDataContextProps;
97
- provider: ({ children, productData, isKit, PDP_INFO, NAME_SPLIT_SYMBOL }: import('../types/contexts/contexts/pdp').PDPDataProviderProps) => import("react/jsx-runtime").JSX.Element;
102
+ provider: ({ children, productData, isKit, PDP_INFO, NAME_SPLIT_SYMBOL, TEXTURE_IMAGE, }: import('../types/contexts/contexts/pdp').PDPDataProviderProps) => import("react/jsx-runtime").JSX.Element;
98
103
  };
99
104
  searchFacets: {
100
105
  hook: () => import('../types/contexts/contexts/search').FacetsContextProps;
@@ -131,6 +136,29 @@ export declare const contexts: {
131
136
  };
132
137
  hooks: {
133
138
  useBackPDC: ({ gridScrollBack }: import('../types/contexts/hooks').UseBackPDCProps) => void;
139
+ useClipboard: () => [string | null, (text: string) => Promise<boolean>];
140
+ useDisableZoom: () => void;
141
+ useLocalStorage: (key: any, defaultValue: any) => any[];
142
+ useOnScreen: typeof useOnScreen;
143
+ useSentinel: ({ callback, onEnterViewportOnce, options, }: {
144
+ callback: Function;
145
+ onEnterViewportOnce?: boolean;
146
+ options: {
147
+ root?: Element | Document | null;
148
+ rootMargin?: string;
149
+ threshold?: number | number[];
150
+ };
151
+ }) => {
152
+ element: import('react').RefObject<HTMLDivElement | null>;
153
+ };
154
+ useTouchZoomPan: ({ defaultScale, maxScale, }: {
155
+ defaultScale?: number | undefined;
156
+ maxScale?: number | undefined;
157
+ }) => {
158
+ containerRef: import('react').RefObject<HTMLDivElement | null>;
159
+ imgRef: import('react').RefObject<HTMLImageElement | null>;
160
+ scale: number;
161
+ };
134
162
  };
135
163
  stores: {
136
164
  cart: typeof cart;
@@ -17,5 +17,5 @@ type SchemaType = yup.InferType<typeof schemaMarketingData>;
17
17
  * @returns A list of sellers that cater to the specified region or address.
18
18
  * This endpoint provides flexibility in accessing seller information based on region or address, allowing you to choose between path parameters or query parameters.
19
19
  */
20
- export declare function postOrderFormAttachmentsMarketingData({ apiUrl, body, fetchOptions }: FetchFunctionsProps<SchemaType>): Promise<any>;
20
+ export declare function postOrderFormAttachmentsMarketingData({ apiUrl, body, extraData, fetchOptions, }: FetchFunctionsProps<SchemaType>): Promise<any>;
21
21
  export {};
@@ -9,5 +9,5 @@ type SchemaType = yup.InferType<typeof schemaSellerCode>;
9
9
  /**
10
10
  * Fetch seller code data from VTEX data entities.
11
11
  */
12
- export declare function getMasterDataSellerCode({ apiUrl, body, fetchOptions, }: FetchFunctionsProps<SchemaType>): Promise<any>;
12
+ export declare function getMasterDataSellerCode({ apiUrl, body, extraData, fetchOptions, }: FetchFunctionsProps<SchemaType>): Promise<any>;
13
13
  export {};
@@ -0,0 +1,3 @@
1
+ export * from './masterdata';
2
+ export * from './search';
3
+ export * from './update';
@@ -0,0 +1,26 @@
1
+ import { FetchFunctionsProps } from '../../../../types/data/api';
2
+ import * as yup from 'yup';
3
+ declare const schemaMasterData: yup.ObjectSchema<{
4
+ masterDataEntity: string | undefined;
5
+ payload: {} | null;
6
+ }, yup.AnyObject, {
7
+ masterDataEntity: undefined;
8
+ payload: {};
9
+ }, "">;
10
+ type SchemaType = yup.InferType<typeof schemaMasterData>;
11
+ /**
12
+ * Updates existing documents within a specified data entity.
13
+ * [https://developers.vtex.com/docs/api-reference/master-data-api-v2#patch-/api/dataentities/-dataEntityName-/documents?endpoint=patch-/api/dataentities/-dataEntityName-/documents](https://developers.vtex.com/docs/api-reference/master-data-api-v2#patch-/api/dataentities/-dataEntityName-/documents?endpoint=patch-/api/dataentities/-dataEntityName-/documents)
14
+ *
15
+ * The data entity (dataEntityName) is a collection of documents, similar to a database table,
16
+ * and the documents are the individual records within that collection.
17
+ *
18
+ * @param dataEntityName The name of the data entity containing the documents to be updated.
19
+ * @param documents An array of objects, where each object represents a document to be updated. Each object must contain the 'id' field to identify the document.
20
+ * @returns This request allows updating existing documents within a specified data entity.
21
+ * The dataEntityName parameter specifies the data entity where the documents will be updated.
22
+ * The documents array allows you to update multiple documents in a single request.
23
+ * Each document must contain the 'id' to identify the document to be updated, and the fields you want to modify.
24
+ */
25
+ export declare function postMasterdata({ apiUrl, body, fetchOptions, }: FetchFunctionsProps<SchemaType>): Promise<any>;
26
+ export {};
@@ -0,0 +1,61 @@
1
+ import { FetchFunctionsProps } from '../../../../types/data/api';
2
+ import * as yup from 'yup';
3
+ declare const searchFieldsSchema: yup.ObjectSchema<{
4
+ _where: string | undefined;
5
+ _fields: string | undefined;
6
+ _sort: string | undefined;
7
+ _from: number | undefined;
8
+ _to: number | undefined;
9
+ _keyword: string | undefined;
10
+ }, yup.AnyObject, {
11
+ _where: undefined;
12
+ _fields: undefined;
13
+ _sort: undefined;
14
+ _from: undefined;
15
+ _to: undefined;
16
+ _keyword: undefined;
17
+ }, "">;
18
+ declare const schemaMasterData: yup.ObjectSchema<{
19
+ masterDataEntity: string;
20
+ searchFields: {
21
+ _where?: string | undefined;
22
+ _fields?: string | undefined;
23
+ _sort?: string | undefined;
24
+ _from?: number | undefined;
25
+ _to?: number | undefined;
26
+ _keyword?: string | undefined;
27
+ };
28
+ headers: {
29
+ "REST-Range"?: yup.Maybe<string | undefined>;
30
+ };
31
+ }, yup.AnyObject, {
32
+ masterDataEntity: undefined;
33
+ searchFields: {
34
+ _where: undefined;
35
+ _fields: undefined;
36
+ _sort: undefined;
37
+ _from: undefined;
38
+ _to: undefined;
39
+ _keyword: undefined;
40
+ };
41
+ headers: {
42
+ 'REST-Range': undefined;
43
+ };
44
+ }, "">;
45
+ type SchemaType = yup.InferType<typeof schemaMasterData>;
46
+ export type SearchFieldsMasterData = yup.InferType<typeof searchFieldsSchema>;
47
+ /**
48
+ * Searches for documents within a specified data entity based on provided query parameters.
49
+ * [https://developers.vtex.com/docs/api-reference/master-data-api-v2#get-/api/dataentities/-dataEntityName-/search?endpoint=get-/api/dataentities/-dataEntityName-/search](https://developers.vtex.com/docs/api-reference/master-data-api-v2#get-/api/dataentities/-dataEntityName-/search?endpoint=get-/api/dataentities/-dataEntityName-/search)
50
+ *
51
+ * The data entity (dataEntityName) is a collection of documents, similar to a database table,
52
+ * and this endpoint allows searching for documents within that collection.
53
+ *
54
+ * @param dataEntityName The name of the data entity to search within.
55
+ * @param queryParams An object containing query parameters to filter the search.
56
+ * @returns This request allows searching for documents within a specified data entity using query parameters.
57
+ * The dataEntityName parameter specifies the data entity to search.
58
+ * The queryParams object allows you to filter the search based on various criteria.
59
+ */
60
+ export declare function getSearchMasterdata({ apiUrl, body, fetchOptions, }: FetchFunctionsProps<SchemaType>): Promise<any>;
61
+ export {};
@@ -0,0 +1,29 @@
1
+ import { FetchFunctionsProps } from '../../../../types/data/api';
2
+ import * as yup from 'yup';
3
+ declare const schemaMasterData: yup.ObjectSchema<{
4
+ dataEntityName: string;
5
+ id: string;
6
+ fieldsToBeUpdated: {};
7
+ }, yup.AnyObject, {
8
+ dataEntityName: undefined;
9
+ id: undefined;
10
+ fieldsToBeUpdated: {};
11
+ }, "">;
12
+ type SchemaType = yup.InferType<typeof schemaMasterData>;
13
+ /**
14
+ * Updates an existing document within a specified data entity, identified by its ID.
15
+ * [https://developers.vtex.com/docs/api-reference/master-data-api-v2#patch-/api/dataentities/-dataEntityName-/documents/-id-?endpoint=patch-/api/dataentities/-dataEntityName-/documents/-id-](https://developers.vtex.com/docs/api-reference/master-data-api-v2#patch-/api/dataentities/-dataEntityName-/documents/-id-?endpoint=patch-/api/dataentities/-dataEntityName-/documents/-id-)
16
+ *
17
+ * The data entity (dataEntityName) is a collection of documents, similar to a database table,
18
+ * and the documents are the individual records within that collection.
19
+ *
20
+ * @param dataEntityName The name of the data entity containing the document to be updated.
21
+ * @param id The unique identifier of the document to be updated.
22
+ * @param document An object representing the document with the fields to be updated.
23
+ * @returns This request allows updating an existing document within a specified data entity using its ID.
24
+ * The dataEntityName parameter specifies the data entity where the document will be updated.
25
+ * The id parameter specifies the unique identifier of the document to be updated.
26
+ * The document object contains the fields and their updated values.
27
+ */
28
+ export declare function patchUpdateMasterdata({ apiUrl, body, fetchOptions, }: FetchFunctionsProps<SchemaType>): Promise<any>;
29
+ export {};
@@ -1,7 +1,7 @@
1
1
  import { EventsFunctionType, ProductsPersisteDataType, PersistedDataType } from '../../../types/data/events';
2
2
  import { SizeInfoType } from '../../../types/global/product';
3
3
 
4
- export declare const pushDatalayer: ({ event, data }: {
4
+ export declare const pushDatalayer: ({ event, data, }: {
5
5
  event?: string;
6
6
  data?: any;
7
7
  }) => void;
@@ -1,3 +1,3 @@
1
- import { ImageType } from '../../../types/global/product';
1
+ import { GetThumbImageProps } from '../../../types/data/helpers';
2
2
 
3
- export declare const getThumbImage: (images: ImageType[]) => ImageType | undefined;
3
+ export declare const getThumbImage: ({ images, TEXTURE_IMAGE }: GetThumbImageProps) => import('../../../types/global/product').ImageType;
@@ -0,0 +1 @@
1
+ "use strict";const p=require("react/jsx-runtime"),x=require("@soma-vertical-web/core-components"),b="fuzzy",_="operator",C=e=>({isDepartment:e!=null&&e.length?e[0].key==="category-1":!1}),R=(e,t)=>{const s=decodeURIComponent(t??"").slice(1).split("/");return e.map(o=>{if(o.key==="category-2"&&o.__typename==="FacetBoolean"){const r=o.values;return{...o,values:r.filter(a=>!s.find(n=>n.toLowerCase()===a.value||n.toLowerCase()===a.name.toLowerCase()))}}return o})},j=(e,t)=>t?e==="category-1":!1,k=e=>e.key==="operator"&&(e.value==="and"||e.value==="or"),w=e=>e.type==="TEXT",I=e=>e.key==="fuzzy"&&(e.value==="0"||e.value==="1"||e.value==="auto"),E=e=>{const{key:t,name:s,values:o}=e;return{__typename:"FacetBoolean",key:t,label:s,values:o.slice().sort((r,a)=>r.name.localeCompare(a.name))}},O=({key:e,values:t})=>({__typename:"FacetRange",key:e,values:t}),F=(e,t,s)=>{if(!(e instanceof Object)||!("facets"in e))return[];const{facets:o=[]}=e,r=t!=null&&t.length?t[0].key==="category-1":!1;return o.filter(n=>!s||!j(n.key,r)).map(n=>w(n)?E(n):O(n))},T=(e,t)=>{const s=e.find(({key:r})=>r===b)??null,o=e.find(({key:r})=>r===_)??null;s&&I(s)&&t.append(b,s.value),o&&k(o)&&t.append(_,o.value)},z=e=>e.map(t=>{const[s,o]=t.split("/");return{key:s,value:o}}),A=(e,t)=>{const s=decodeURIComponent(t??"").slice(1).split("/"),o=e.filter(({value:a})=>!s.includes(decodeURIComponent(a))).map(a=>({...a,value:decodeURIComponent(a.value)})),{isDepartment:r}=C(o);return o==null?void 0:o.filter(a=>!j(a.key,r))},B=({pathname:e,searchParams:t},s)=>{const o=t.get("sort")??"",r=t.get("query")??null,a=parseInt(t.get("page")??"1",10);return{sort:o,facets:z(s),term:r,base:r?"":e,page:a}},U=e=>{const t=new URLSearchParams;return Object.entries(e).forEach(([s,o])=>{Array.isArray(o)?o.forEach(r=>t.append(s,r)):o!==void 0&&t.append(s,o)}),t},S=async(e,t={})=>{const{method:s="GET",body:o,headers:r={},priority:a="auto",cache:n="default"}=t;return fetch(e,{method:s,headers:{...r,Accept:"application/json","Content-Type":"application/json"},priority:a,cache:n,...o?{body:JSON.stringify(o)}:{}}).then(i=>i.json()).catch(i=>{console.error("[ERROR FETCH VTEX]",i)})},g=new Map;async function D(e,t={}){var s;try{const{abort:o=!1}=t,r=new AbortController;o&&(g.has(e)&&((s=g.get(e))==null||s.abort(),g.delete(e)),g.set(e,r));const a=S(e,{...t,...o?{signal:r.signal}:{}});return o&&g.delete(e),a}catch(o){if(o.name==="AbortError"){console.log(`[REQUEST CANCELLED]: ${e}`);return}throw console.error(`[ERROR API]: ${o.message}`),o}}const y={"responsive-mobile-flex":"_responsive-mobile-flex_t5bry_2","responsive-desktop-flex":"_responsive-desktop-flex_t5bry_13","responsive-mobile-block":"_responsive-mobile-block_t5bry_24","responsive-desktop-block":"_responsive-desktop-block_t5bry_35"},$={},N=Object.freeze(Object.defineProperty({__proto__:null,default:$},Symbol.toStringTag,{value:"Module"})),V=({children:e,data:t,SectionZone:s,className:o})=>{var m,u;const r=((m=t==null?void 0:t.filter(l=>{var c,h;return((h=(c=l.config)==null?void 0:c.responsive)==null?void 0:h.deviceType)==="mobile"})[0])==null?void 0:m.sections)||[],a=((u=t==null?void 0:t.filter(l=>{var c,h;return((h=(c=l.config)==null?void 0:c.responsive)==null?void 0:h.deviceType)==="desktop"})[0])==null?void 0:u.sections)||[],n=r.slice(0,1),i=r.slice(1,r.length),d=a.slice(0,1),f=a.slice(1,a.length);return p.jsxs(p.Fragment,{children:[p.jsxs("div",{className:o,children:[p.jsx("div",{className:y["responsive-mobile-flex"],children:p.jsx(s,{data:n??[]})}),p.jsx("div",{className:y["responsive-desktop-flex"],children:p.jsx(s,{data:d??[]})})]}),e,p.jsx("div",{className:y["responsive-mobile-flex"],children:p.jsx(s,{data:i??[]})}),p.jsx("div",{className:y["responsive-desktop-flex"],children:p.jsx(s,{data:f??[]})}),p.jsx(x.Utils.Divider,{})]})};async function L({contentType:e,storeId:t,CMS_PROJECT_NAME:s,NextCookies:o}){const r=await v({contentType:e,storeId:t,CMS_PROJECT_NAME:s,NextCookies:o});if(r.status===200){const a={timestamp:new Date().toISOString(),contentType:e,data:r.data};console.log("Resultado da chamada:",r);const n=`backup-${e}-${Date.now()}.json`;return await $.writeFile(`./backups/${n}`,JSON.stringify(a,null,2),"utf-8"),{success:!0,fileName:n}}return{success:!1,error:r.error||"No data to backup"}}async function M(e){return L(e)}async function P({contentType:e,documentId:t,versionId:s,storeId:o,CMS_PROJECT_NAME:r}){const a=t&&t.length?`/${t}`:"",n=s&&s.length?`?versionId=${s}`:"";return fetch(`https://${o}.myvtex.com/_v/cms/api/${r}/${e}${a}${n}`,{cache:"no-cache"})}async function q({contentType:e,documents:t,NextCookies:s,previewId:o,CMS_PROJECT_NAME:r,storeId:a}){var i;const n=JSON.parse(o??((i=s==null?void 0:s().get("cms_preview_data"))==null?void 0:i.value)??"{}");if(n&&(n==null?void 0:n.contentType)===e){const d=n.documentId&&n.documentId.length?`/${n.documentId}`:"",f=n!=null&&n.versionId&&(n!=null&&n.versionId.length)?`?versionId=${n==null?void 0:n.versionId}`:"",u=await(await fetch(`https://${a}.myvtex.com/_v/cms/api/${r}/${e}${d}${f}`,{cache:"no-store"})).json(),l=t.filter(c=>u.id!==c.documentId);return l.unshift(u),l}return t}async function v({contentType:e,NextCookies:t,CMS_PROJECT_NAME:s,storeId:o,previewId:r}){var m,u;const a=JSON.parse(r??((m=t==null?void 0:t().get("cms_preview_data"))==null?void 0:m.value)??"{}"),n=[];let i=1,d=0,f=!0;try{do{const c=await(await fetch(`https://${o}.myvtex.com/_v/cms/api/${s}/${e}?page=${i}`)).json();i===1&&(d=c.totalItems),(u=c==null?void 0:c.data)!=null&&u.length&&n.push(...c.data),f=c.hasNextPage,i++}while(f&&n.length<d);if(a.previewMode&&n.length){const l=await q({contentType:e,documents:n,NextCookies:t,CMS_PROJECT_NAME:s,storeId:o});return{status:l.length>0?200:404,data:l??[]}}return{status:n.length?200:404,data:n}}catch(l){return{status:"error",data:[],error:l}}}const J=Object.freeze(Object.defineProperty({__proto__:null,cmsBackup:M,getCMSContentType:P,getContentType:v},Symbol.toStringTag,{value:"Module"}));exports.SearchPageScreening=V;exports.__viteBrowserExternal=N;exports.addSearchParamsFacets=T;exports.cms=J;exports.convertSearchParams=U;exports.fetchVtex=S;exports.fetchVtexWithAbortController=D;exports.filterNonCategorySelected=R;exports.filterNonRootFacets=A;exports.formattedFacets=F;exports.getContentType=v;exports.parseSearchState=B;exports.responsive=y;
@@ -0,0 +1,258 @@
1
+ import { jsxs as v, Fragment as R, jsx as p } from "react/jsx-runtime";
2
+ import { Utils as w } from "@soma-vertical-web/core-components";
3
+ const b = "fuzzy", _ = "operator", S = (e) => ({
4
+ isDepartment: e != null && e.length ? e[0].key === "category-1" : !1
5
+ }), M = (e, t) => {
6
+ const s = decodeURIComponent(t ?? "").slice(1).split("/");
7
+ return e.map((o) => {
8
+ if (o.key === "category-2" && o.__typename === "FacetBoolean") {
9
+ const r = o.values;
10
+ return {
11
+ ...o,
12
+ values: r.filter(
13
+ (a) => !s.find(
14
+ (n) => n.toLowerCase() === a.value || n.toLowerCase() === a.name.toLowerCase()
15
+ )
16
+ )
17
+ };
18
+ }
19
+ return o;
20
+ });
21
+ }, $ = (e, t) => t ? e === "category-1" : !1, C = (e) => e.key === "operator" && (e.value === "and" || e.value === "or"), E = (e) => e.type === "TEXT", O = (e) => e.key === "fuzzy" && (e.value === "0" || e.value === "1" || e.value === "auto"), j = (e) => {
22
+ const { key: t, name: s, values: o } = e;
23
+ return {
24
+ __typename: "FacetBoolean",
25
+ key: t,
26
+ label: s,
27
+ values: o.slice().sort((r, a) => r.name.localeCompare(a.name))
28
+ };
29
+ }, T = ({ key: e, values: t }) => ({
30
+ __typename: "FacetRange",
31
+ key: e,
32
+ values: t
33
+ }), N = (e, t, s) => {
34
+ if (!(e instanceof Object) || !("facets" in e))
35
+ return [];
36
+ const { facets: o = [] } = e, r = t != null && t.length ? t[0].key === "category-1" : !1;
37
+ return o.filter(
38
+ (n) => !s || !$(n.key, r)
39
+ ).map(
40
+ (n) => E(n) ? j(n) : T(n)
41
+ );
42
+ }, V = (e, t) => {
43
+ const s = e.find(({ key: r }) => r === b) ?? null, o = e.find(({ key: r }) => r === _) ?? null;
44
+ s && O(s) && t.append(b, s.value), o && C(o) && t.append(_, o.value);
45
+ }, F = (e) => e.map((t) => {
46
+ const [s, o] = t.split("/");
47
+ return { key: s, value: o };
48
+ }), J = (e, t) => {
49
+ const s = decodeURIComponent(t ?? "").slice(1).split("/"), o = e.filter(({ value: a }) => !s.includes(decodeURIComponent(a))).map((a) => ({
50
+ ...a,
51
+ value: decodeURIComponent(a.value)
52
+ })), { isDepartment: r } = S(o);
53
+ return o == null ? void 0 : o.filter((a) => !$(a.key, r));
54
+ }, Y = ({ pathname: e, searchParams: t }, s) => {
55
+ const o = t.get("sort") ?? "", r = t.get("query") ?? null, a = parseInt(t.get("page") ?? "1", 10);
56
+ return {
57
+ sort: o,
58
+ facets: F(s),
59
+ term: r,
60
+ base: r ? "" : e,
61
+ page: a
62
+ };
63
+ }, K = (e) => {
64
+ const t = new URLSearchParams();
65
+ return Object.entries(e).forEach(([s, o]) => {
66
+ Array.isArray(o) ? o.forEach((r) => t.append(s, r)) : o !== void 0 && t.append(s, o);
67
+ }), t;
68
+ }, x = async (e, t = {}) => {
69
+ const { method: s = "GET", body: o, headers: r = {}, priority: a = "auto", cache: n = "default" } = t;
70
+ return fetch(e, {
71
+ method: s,
72
+ headers: {
73
+ ...r,
74
+ Accept: "application/json",
75
+ "Content-Type": "application/json"
76
+ },
77
+ priority: a,
78
+ cache: n,
79
+ ...o ? { body: JSON.stringify(o) } : {}
80
+ // not body in get
81
+ }).then((i) => i.json()).catch((i) => {
82
+ console.error("[ERROR FETCH VTEX]", i);
83
+ });
84
+ }, h = /* @__PURE__ */ new Map();
85
+ async function P(e, t = {}) {
86
+ var s;
87
+ try {
88
+ const { abort: o = !1 } = t, r = new AbortController();
89
+ o && (h.has(e) && ((s = h.get(e)) == null || s.abort(), h.delete(e)), h.set(e, r));
90
+ const a = x(e, {
91
+ ...t,
92
+ ...o ? { signal: r.signal } : {}
93
+ });
94
+ return o && h.delete(e), a;
95
+ } catch (o) {
96
+ if (o.name === "AbortError") {
97
+ console.log(`[REQUEST CANCELLED]: ${e}`);
98
+ return;
99
+ }
100
+ throw console.error(`[ERROR API]: ${o.message}`), o;
101
+ }
102
+ }
103
+ const y = {
104
+ "responsive-mobile-flex": "_responsive-mobile-flex_t5bry_2",
105
+ "responsive-desktop-flex": "_responsive-desktop-flex_t5bry_13",
106
+ "responsive-mobile-block": "_responsive-mobile-block_t5bry_24",
107
+ "responsive-desktop-block": "_responsive-desktop-block_t5bry_35"
108
+ }, k = {}, X = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
109
+ __proto__: null,
110
+ default: k
111
+ }, Symbol.toStringTag, { value: "Module" })), q = ({
112
+ children: e,
113
+ data: t,
114
+ SectionZone: s,
115
+ className: o
116
+ }) => {
117
+ var m, u;
118
+ const r = ((m = t == null ? void 0 : t.filter((l) => {
119
+ var c, g;
120
+ return ((g = (c = l.config) == null ? void 0 : c.responsive) == null ? void 0 : g.deviceType) === "mobile";
121
+ })[0]) == null ? void 0 : m.sections) || [], a = ((u = t == null ? void 0 : t.filter((l) => {
122
+ var c, g;
123
+ return ((g = (c = l.config) == null ? void 0 : c.responsive) == null ? void 0 : g.deviceType) === "desktop";
124
+ })[0]) == null ? void 0 : u.sections) || [], n = r.slice(0, 1), i = r.slice(1, r.length), d = a.slice(0, 1), f = a.slice(1, a.length);
125
+ return /* @__PURE__ */ v(R, { children: [
126
+ /* @__PURE__ */ v("div", { className: o, children: [
127
+ /* @__PURE__ */ p("div", { className: y["responsive-mobile-flex"], children: /* @__PURE__ */ p(s, { data: n ?? [] }) }),
128
+ /* @__PURE__ */ p("div", { className: y["responsive-desktop-flex"], children: /* @__PURE__ */ p(s, { data: d ?? [] }) })
129
+ ] }),
130
+ e,
131
+ /* @__PURE__ */ p("div", { className: y["responsive-mobile-flex"], children: /* @__PURE__ */ p(s, { data: i ?? [] }) }),
132
+ /* @__PURE__ */ p("div", { className: y["responsive-desktop-flex"], children: /* @__PURE__ */ p(s, { data: f ?? [] }) }),
133
+ /* @__PURE__ */ p(w.Divider, {})
134
+ ] });
135
+ };
136
+ async function z({ contentType: e, storeId: t, CMS_PROJECT_NAME: s, NextCookies: o }) {
137
+ const r = await I({
138
+ contentType: e,
139
+ storeId: t,
140
+ CMS_PROJECT_NAME: s,
141
+ NextCookies: o
142
+ });
143
+ if (r.status === 200) {
144
+ const a = {
145
+ timestamp: (/* @__PURE__ */ new Date()).toISOString(),
146
+ contentType: e,
147
+ data: r.data
148
+ };
149
+ console.log("Resultado da chamada:", r);
150
+ const n = `backup-${e}-${Date.now()}.json`;
151
+ return await k.writeFile(
152
+ `./backups/${n}`,
153
+ JSON.stringify(a, null, 2),
154
+ "utf-8"
155
+ ), { success: !0, fileName: n };
156
+ }
157
+ return { success: !1, error: r.error || "No data to backup" };
158
+ }
159
+ async function A(e) {
160
+ return z(e);
161
+ }
162
+ async function B({
163
+ contentType: e,
164
+ documentId: t,
165
+ versionId: s,
166
+ storeId: o,
167
+ CMS_PROJECT_NAME: r
168
+ }) {
169
+ const a = t && t.length ? `/${t}` : "", n = s && s.length ? `?versionId=${s}` : "";
170
+ return fetch(
171
+ `https://${o}.myvtex.com/_v/cms/api/${r}/${e}${a}${n}`,
172
+ { cache: "no-cache" }
173
+ );
174
+ }
175
+ async function U({
176
+ contentType: e,
177
+ documents: t,
178
+ NextCookies: s,
179
+ previewId: o,
180
+ CMS_PROJECT_NAME: r,
181
+ storeId: a
182
+ }) {
183
+ var i;
184
+ const n = JSON.parse(
185
+ o ?? ((i = s == null ? void 0 : s().get("cms_preview_data")) == null ? void 0 : i.value) ?? "{}"
186
+ );
187
+ if (n && (n == null ? void 0 : n.contentType) === e) {
188
+ const d = n.documentId && n.documentId.length ? `/${n.documentId}` : "", f = n != null && n.versionId && (n != null && n.versionId.length) ? `?versionId=${n == null ? void 0 : n.versionId}` : "", u = await (await fetch(
189
+ `https://${a}.myvtex.com/_v/cms/api/${r}/${e}${d}${f}`,
190
+ { cache: "no-store" }
191
+ )).json(), l = t.filter(
192
+ (c) => u.id !== c.documentId
193
+ );
194
+ return l.unshift(u), l;
195
+ }
196
+ return t;
197
+ }
198
+ async function I({
199
+ contentType: e,
200
+ NextCookies: t,
201
+ CMS_PROJECT_NAME: s,
202
+ storeId: o,
203
+ previewId: r
204
+ }) {
205
+ var m, u;
206
+ const a = JSON.parse(
207
+ r ?? ((m = t == null ? void 0 : t().get("cms_preview_data")) == null ? void 0 : m.value) ?? "{}"
208
+ ), n = [];
209
+ let i = 1, d = 0, f = !0;
210
+ try {
211
+ do {
212
+ const c = await (await fetch(
213
+ `https://${o}.myvtex.com/_v/cms/api/${s}/${e}?page=${i}`
214
+ )).json();
215
+ i === 1 && (d = c.totalItems), (u = c == null ? void 0 : c.data) != null && u.length && n.push(...c.data), f = c.hasNextPage, i++;
216
+ } while (f && n.length < d);
217
+ if (a.previewMode && n.length) {
218
+ const l = await U({
219
+ contentType: e,
220
+ documents: n,
221
+ NextCookies: t,
222
+ CMS_PROJECT_NAME: s,
223
+ storeId: o
224
+ });
225
+ return {
226
+ status: l.length > 0 ? 200 : 404,
227
+ data: l ?? []
228
+ };
229
+ }
230
+ return {
231
+ status: n.length ? 200 : 404,
232
+ data: n
233
+ };
234
+ } catch (l) {
235
+ return { status: "error", data: [], error: l };
236
+ }
237
+ }
238
+ const G = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
239
+ __proto__: null,
240
+ cmsBackup: A,
241
+ getCMSContentType: B,
242
+ getContentType: I
243
+ }, Symbol.toStringTag, { value: "Module" }));
244
+ export {
245
+ q as S,
246
+ X as _,
247
+ V as a,
248
+ P as b,
249
+ K as c,
250
+ N as d,
251
+ M as e,
252
+ x as f,
253
+ I as g,
254
+ J as h,
255
+ G as i,
256
+ Y as p,
257
+ y as r
258
+ };