{"version":3,"file":"index-D6e37i5s.js","sources":["../../../app/javascript/src/explore/compositions/RecommendedProducts/index.tsx","../../../app/javascript/src/explore/scenes/RecommendedProducts/index.tsx"],"sourcesContent":["import React from 'react';\nimport { useSelector } from 'react-redux';\n\nimport { ProductCarousel } from 'src/explore/compositions/ProductCarousel';\nimport { Recombee } from 'src/explore/services/recommendations/Recombee';\nimport { useShopConfig } from 'src/explore/hooks/useShopConfig';\nimport { IStore } from 'src/explore/types/store';\n\ninterface Props {\n clickRef?: string;\n hideLove?: boolean;\n hideMerchant?: boolean;\n pageType?: string;\n}\n\nexport const RecommendedProducts: React.FC = ({\n clickRef,\n hideLove,\n hideMerchant,\n pageType,\n}) => {\n const [ loaded, setLoaded ] = React.useState( false );\n const [ products, setProducts ] = React.useState();\n const [ recommId, setRecommId ] = React.useState();\n const { isWhitelabel } = useShopConfig();\n const accountPristine = useSelector(( state: IStore ) => state.data.account.pristine );\n const accountId = useSelector(\n ( state: IStore ) => state.data.account.data && state.data.account.data.hashed_id\n );\n const visitorId = useSelector(\n ( state: IStore ) => state.data.account.meta && state.data.account.meta.visitor_id\n );\n const identity = accountId || visitorId;\n\n const recombee = React.useMemo(() => new Recombee(), []);\n\n React.useEffect(() => {\n const searchParams = new URLSearchParams( window.location.search );\n\n setRecommId( searchParams.get( 'recomm_id' ));\n }, []);\n\n React.useEffect(() => {\n if ( loaded || accountPristine || !identity ) return;\n\n let request = null;\n\n switch ( pageType ) {\n case 'home': {\n request = recombee.getItemsForUser( identity, 15, { scenario: 'homepage' });\n\n break;\n }\n case 'also_bought': {\n const filter = isWhitelabel\n ? `'is_sold_out' == false and 'whitelabel_visible' == true and 'merchant_id' == ${\n ( window as any ).__data.whitelabelMerchantId\n }`\n : \"'is_sold_out' == false and 'visible' == true\";\n const scenario = isWhitelabel ? 'also_bought_whitelabel' : 'also_bought';\n\n request = recombee.getItemsForItem( identity, ( window as any ).__data.productId, 15, {\n filter,\n scenario,\n userImpact: 0.2,\n rotationRate: 0.2,\n rotationTime: 7200,\n booster: '(if \\'price_in_cents\\' > context_item[\"price_in_cents\"] then 1.1 else 1)',\n });\n\n break;\n }\n default:\n }\n\n setLoaded( true );\n\n request.then( async ( res: any ) => {\n const recommendedProducts = await Recombee.extractJson( res );\n setProducts( recommendedProducts );\n setRecommId( res.recommId );\n });\n }, [ accountPristine, identity, isWhitelabel, loaded, pageType, recombee ]);\n\n if ( !products ) return null;\n\n return (\n \n );\n};\n","import React from 'react';\n\nimport { RecommendedProducts as Products } from 'src/explore/compositions/RecommendedProducts';\n\ninterface Props {\n clickRef?: string;\n hideLove?: boolean;\n hideMerchant?: boolean;\n pageType?: string;\n}\n\nconst RecommendedProducts: React.FC = ({ clickRef, hideLove, hideMerchant, pageType }) => (\n \n);\n\nexport default RecommendedProducts;\n"],"names":["RecommendedProducts","clickRef","hideLove","hideMerchant","pageType","loaded","setLoaded","React","products","setProducts","recommId","setRecommId","isWhitelabel","useShopConfig","accountPristine","useSelector","state","accountId","visitorId","identity","recombee","Recombee","searchParams","request","filter","scenario","res","recommendedProducts","ProductCarousel","Products"],"mappings":"8qCAeO,MAAMA,EAAuC,CAAC,CACnD,SAAAC,EACA,SAAAC,EACA,aAAAC,EACA,SAAAC,CACF,IAAM,CACJ,KAAM,CAAEC,EAAQC,CAAU,EAAIC,EAAM,SAAmB,EAAM,EACvD,CAAEC,EAAUC,CAAY,EAAIF,EAAM,SAAgB,EAClD,CAAEG,EAAUC,CAAY,EAAIJ,EAAM,SAAiB,EACnD,CAAE,aAAAK,CAAa,EAAIC,EAAc,EACjCC,EAAkBC,EAAcC,GAAmBA,EAAM,KAAK,QAAQ,QAAS,EAC/EC,EAAYF,EACdC,GAAmBA,EAAM,KAAK,QAAQ,MAAQA,EAAM,KAAK,QAAQ,KAAK,SAC1E,EACME,EAAYH,EACdC,GAAmBA,EAAM,KAAK,QAAQ,MAAQA,EAAM,KAAK,QAAQ,KAAK,UAC1E,EACMG,EAAWF,GAAaC,EAExBE,EAAWb,EAAM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