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AAKpB,MACvGsC,cACC,UACFlC,EAAS,cACTsB,EAAa,iBACba,EAAgB,uBAChBC,EAAsB,kBACtBC,EAAiB,oBACjBC,EAAmB,sBACnBC,EAAqB,YACrBC,GACAxB,KAAKpB,MAAM+B,OAEf,IAAKX,KAAKE,4BAA4BuB,KAAKb,OACvC,OAAO,KAGX,MACIa,MAAM,mBACFC,EAAkB,gBAClBC,EAAe,iBACfC,EAAgB,cAChBC,EAAa,0BACbC,IAEJ9B,KAAKE,4BAEH6B,EAAmC,IAApBJ,GAA2BV,EAA8BA,EAA8BD,EAE5G,YAA4B,IAArBY,EACH,gBAAClC,EAAA,CAAcV,UAAWW,EAAyB,eAAc,MAC5DmC,GACG,gBAAC3C,EAAA,CACGC,gBAAiB0C,EAA0B1C,gBAC3CC,eAAgByC,EAA0BzC,iBAGlD,gBAAC2C,EAAA,GACGhD,YACAsB,gBACAQ,mBACAC,0BACAkB,mBAAoBZ,EACpBD,yBACAc,iBAAkBZ,EAClBH,mBACAgB,eAAgBZ,EAChBa,oBAAqBV,EACrBzB,mBAAoBD,KAAKD,wBACzB6B,mBACApB,cAAemB,EACfE,gBACAL,cACAR,mBAAoBe,KAG5B,IACR,GA9FSnC,E,iIAAN,GAFN,OAAU,CAAC,mBAAoB,0BAA2B,qBAAsB,gCACjF,YACaA,GAiGb,S,uIClKO,MAAMyC,EAA6B,6BAC7BC,EAAiB,iBACjBC,EAAiB,iBACjBC,EAAkB,kBAClBC,EAAyC,yCACzCC,EAAsB,sBACtBC,EAAU,UACVC,EAAoB,mB,sHCJ1B,MAAMC,EAAU,CAACC,KAAsBC,IAC1C,IAAW,OAAOD,IAAa,MAAMA,IAAaC,E","sources":["webpack://elc-service-ratings-reviews/./src/internal/views/SocialProofReview.tsx","webpack://elc-service-ratings-reviews/./src/internal/views/SocialProofReviewResponsiveWrapper.tsx","webpack://elc-service-ratings-reviews/./src/exported/product-rating/ProductRating.tsx","webpack://elc-service-ratings-reviews/./src/internal/constants/DataTestIds.ts","webpack://elc-service-ratings-reviews/./src/internal/utils/Classes.ts"],"sourcesContent":["import * as React from 'react';\nimport { observer } from 'mobx-react';\nimport { classes } from '~utils/Classes';\nimport { SOCIAL_PROOF_REVIEW } from '../constants/DataTestIds';\n\nexport interface ISocialProofReview {\n    reviewHeadline: string;\n}\n\nexport const SocialProofReview = observer(function SocialProofReview(props: ISocialProofReview) {\n    const { reviewHeadline } = props;\n\n    if (!reviewHeadline) {\n        return null;\n    }\n\n    const socialProofReviewClassNames = classes(SOCIAL_PROOF_REVIEW);\n    const formattedReview = `\"${reviewHeadline}\"`;\n\n    return (\n        <span data-test-id={SOCIAL_PROOF_REVIEW} className={socialProofReviewClassNames}>\n            {formattedReview}\n        </span>\n    );\n});\n","import * as React from 'react';\nimport { observer } from 'mobx-react';\nimport { Breakpoints, ContentSpacing } from '@estee/elc-base-theme';\nimport { Desktop, Mobile } from '@estee/elc-layouts';\nimport styled from 'styled-components';\nimport { SocialProofReview } from './SocialProofReview';\nimport { SOCIAL_PROOF_REVIEW_RESPONSIVE_WRAPPER } from '../constants/DataTestIds';\nimport { classes } from '~utils/Classes';\n\nconst SocialProofReviewWrapper = styled.span`\n    margin-right: ${ContentSpacing.space8};\n`;\nexport interface ISocialProofReviewResponsiveWrapperProps {\n    desktopHeadline: string;\n    mobileHeadline: string;\n}\n\nexport const SocialProofReviewResponsiveWrapper = observer(\n    function SocialProofReviewResponsiveWrapper({\n        desktopHeadline,\n        mobileHeadline\n    }: ISocialProofReviewResponsiveWrapperProps) {\n        if (!desktopHeadline && !mobileHeadline) {\n            return null;\n        }\n        const socialProofReviewResponsiveWrapperClassNames = classes(\n            SOCIAL_PROOF_REVIEW_RESPONSIVE_WRAPPER\n        );\n\n        return (\n            <SocialProofReviewWrapper\n                data-test-id={SOCIAL_PROOF_REVIEW_RESPONSIVE_WRAPPER}\n                className={socialProofReviewResponsiveWrapperClassNames}\n            >\n                <Desktop minWidth={Breakpoints.desktop}>\n                    {() => <SocialProofReview reviewHeadline={desktopHeadline} />}\n                </Desktop>\n                <Mobile maxWidth={Breakpoints.desktop - 1}>\n                    {() => <SocialProofReview reviewHeadline={mobileHeadline} />}\n                </Mobile>\n            </SocialProofReviewWrapper>\n        );\n    }\n);\n","import * as React from 'react';\nimport styled from 'styled-components';\nimport { observer } from 'mobx-react';\nimport { Rating } from '@estee/elc-rating';\nimport { translate } from '@estee/elc-service';\nimport { ProductRatingViewController } from '~controllers/ProductRatingViewController';\nimport { IProduct } from '~interfaces/IRating';\nimport { classes } from '~utils/Classes';\nimport { PRODUCT_RATING } from '../../internal/constants/DataTestIds';\nimport { SocialProofReviewResponsiveWrapper } from '~views/SocialProofReviewResponsiveWrapper';\n\nexport interface ITranslation {\n    readReviewsLabel: string;\n    firstToWriteReviewLabel: string;\n    reviewsNumberLabel: string;\n    serviceReviewNumberSingular?: string;\n}\n\nexport interface IProductRatingConfig {\n    averageRating: number;\n    className?: string;\n    hideReadReviewsLink?: boolean;\n    hideReviewsNumber?: boolean;\n    hideReviewsLabel?: boolean;\n    showReviewsNumberLabel?: boolean;\n    showEmptyRatingsStars: boolean;\n    numberOfStars: number;\n    productId: string;\n    reviewsNumberLabel?: string;\n    productRating?: number;\n    reviewsNumber?: number;\n    isClickable: boolean;\n    product: IProduct;\n    socialProofReviews: ISocialProofReviewConfig;\n}\n\ninterface ISocialProofReviewMaxNumberOfCharacters {\n    longHeadline: number;\n    shortHeadline: number;\n}\n\nexport interface ISocialProofReviewConfig {\n    enabled: boolean;\n    minNumberOfStars: number;\n    maxNumberOfCharacters: ISocialProofReviewMaxNumberOfCharacters;\n}\n\nexport interface IProductRating {\n    translations?: ITranslation;\n    onReadReviewsClick?(): void;\n    config: IProductRatingConfig;\n    viewController: ProductRatingViewController;\n}\n\nconst RatingWrapper = styled.div`\n    width: 100%;\n    justify-content: flex-end;\n    align-items: center;\n    display: flex;\n`;\n\nconst ratingWrapperClassnames = classes('product-rating-wrapper');\n\n@translate(['readReviewsLabel', 'firstToWriteReviewLabel', 'reviewsNumberLabel', 'serviceReviewNumberSingular'])\n@observer\nexport class ProductRating extends React.Component<IProductRating> {\n    private productRatingViewController: ProductRatingViewController;\n\n    constructor(props: IProductRating) {\n        super(props);\n        this.productRatingViewController = props.viewController;\n    }\n\n    public async componentDidMount() {\n        const {\n            productId,\n            numberOfStars,\n            productRating,\n            reviewsNumber,\n            product,\n            socialProofReviews\n        } = this.props.config || {};\n\n        await this.productRatingViewController.loaded({\n            productId,\n            numberOfStars,\n            productRating,\n            reviewsNumber,\n            product,\n            socialProofReviews\n        });\n    }\n\n    private readReviewsClickHandler = async () => {\n        if (this.props.onReadReviewsClick) {\n            this.props.onReadReviewsClick();\n        } else {\n            this.productRatingViewController.onReadReviewsClick();\n        }\n    };\n\n    public render() {\n        const { readReviewsLabel, firstToWriteReviewLabel, reviewsNumberLabel, serviceReviewNumberSingular } = this.props\n            .translations as ITranslation;\n        const {\n            className,\n            numberOfStars,\n            hideReviewsLabel,\n            showReviewsNumberLabel,\n            hideReviewsNumber,\n            hideReadReviewsLink,\n            showEmptyRatingsStars,\n            isClickable\n        } = this.props.config;\n\n        if (!this.productRatingViewController.data.loaded) {\n            return null;\n        }\n\n        const {\n            data: {\n                onWriteReviewClick,\n                numberOfReviews,\n                percentageRating,\n                averageRating,\n                filteredSocialProofReview\n            }\n        } = this.productRatingViewController;\n\n        const reviewsLabel = numberOfReviews === 1 && !!serviceReviewNumberSingular ? serviceReviewNumberSingular : reviewsNumberLabel;\n\n        return percentageRating !== undefined ? (\n            <RatingWrapper className={ratingWrapperClassnames} data-test-id={PRODUCT_RATING}>\n                {filteredSocialProofReview && (\n                    <SocialProofReviewResponsiveWrapper\n                        desktopHeadline={filteredSocialProofReview.desktopHeadline}\n                        mobileHeadline={filteredSocialProofReview.mobileHeadline}\n                    />\n                )}\n                <Rating\n                    className={className}\n                    numberOfStars={numberOfStars}\n                    readReviewsLabel={readReviewsLabel}\n                    firstToWriteReviewLabel={firstToWriteReviewLabel}\n                    showReviewsNumber={!hideReviewsNumber}\n                    showReviewsNumberLabel={showReviewsNumberLabel}\n                    showReadReviews={!hideReadReviewsLink}\n                    hideReviewsLabel={hideReviewsLabel}\n                    showEmptyStars={showEmptyRatingsStars}\n                    onWriteReviewsClick={onWriteReviewClick}\n                    onReadReviewsClick={this.readReviewsClickHandler}\n                    percentageRating={percentageRating}\n                    reviewsNumber={numberOfReviews}\n                    averageRating={averageRating}\n                    isClickable={isClickable}\n                    reviewsNumberLabel={reviewsLabel}\n                />\n            </RatingWrapper>\n        ) : null;\n    }\n}\n// tslint:disable-next-line:no-default-export\nexport default ProductRating;\n","export const REVIEW_OVERLAY_REMOVE_ICON = 'review-overlay-remove-icon';\nexport const REVIEW_DETAILS = 'review-details';\nexport const PRODUCT_RATING = 'product-rating';\nexport const REVIEWS_WRAPPER = 'reviews-wrapper';\nexport const SOCIAL_PROOF_REVIEW_RESPONSIVE_WRAPPER = 'social-proof-review-responsive-wrapper';\nexport const SOCIAL_PROOF_REVIEW = 'social-proof-review';\nexport const REVIEWS = 'reviews';\nexport const SPINNER_CONTAINER = 'spinner-container';\nexport const RATING_CLICKABLE = 'rating-clickable';\n","import classnames from 'classnames';\n\n// tslint:disable-next-line:export-name\nexport const classes = (component: string, ...classNames: (string | undefined)[]) =>\n    classnames(`elc-${component}`, `js-${component}`, classNames);\n"],"names":["SocialProofReview","observer","props","reviewHeadline","socialProofReviewClassNames","formattedReview","className","SocialProofReviewWrapper","ContentSpacing","SocialProofReviewResponsiveWrapper","desktopHeadline","mobileHeadline","socialProofReviewResponsiveWrapperClassNames","minWidth","Breakpoints","maxWidth","RatingWrapper","ratingWrapperClassnames","ProductRating","constructor","super","readReviewsClickHandler","this","onReadReviewsClick","productRatingViewController","viewController","componentDidMount","productId","numberOfStars","productRating","reviewsNumber","product","socialProofReviews","config","loaded","render","readReviewsLabel","firstToWriteReviewLabel","reviewsNumberLabel","serviceReviewNumberSingular","translations","hideReviewsLabel","showReviewsNumberLabel","hideReviewsNumber","hideReadReviewsLink","showEmptyRatingsStars","isClickable","data","onWriteReviewClick","numberOfReviews","percentageRating","averageRating","filteredSocialProofReview","reviewsLabel","Rating","showReviewsNumber","showReadReviews","showEmptyStars","onWriteReviewsClick","REVIEW_OVERLAY_REMOVE_ICON","REVIEW_DETAILS","PRODUCT_RATING","REVIEWS_WRAPPER","SOCIAL_PROOF_REVIEW_RESPONSIVE_WRAPPER","SOCIAL_PROOF_REVIEW","REVIEWS","SPINNER_CONTAINER","classes","component","classNames"],"sourceRoot":""}