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AAMC,mBAAqBD,EAAME,eAErC,CACdrE,KAAK6D,8BACL7D,KAAKsE,aACL,KACF,CACF,CACF,EACAX,0BAAAA,GACE3D,KAAK0D,sBAAwB,IAAIa,qBAAqBvE,KAAK+D,yBAA0B,CACnFS,UAAW,CAAE,EAAG,GAChBC,WAAY,wBAEdzE,KAAK0D,sBAAsBgB,QAAQ1E,KAAKO,IAC1C,EACAsD,2BAAAA,GACM7D,KAAK0D,wBACP1D,KAAK0D,sBAAsBiB,aAC3B3E,KAAK0D,sBAAwB,KAEjC,EACA,gBAAMY,GACJ,IACE,MAAM,KAAEzE,SAAe+E,EAAAA,EAAMC,KAAK,gCAAiC,CACjEC,GAAI9E,KAAK2B,kBAGX3B,KAAKsC,eAAiBzC,CACxB,CACA,MAAOkF,GACJC,EAAAA,EACH,CACF,EACAC,oBAAAA,GACEjF,KAAKuC,kBAAmB,CAC1B,GAEFb,SAAU,gzE","sources":["webpack:///./Onlia/Scripts/onlia/one-onlia/components/trust-pilot-review-text.js","webpack:///./Onlia/Scripts/onlia/one-onlia/components/trust-pilot-widget.js"],"sourcesContent":["import windowSize from '@Shared/mixins/window-size';\r\n\r\nexport default {\r\n name: 'trust-pilot-review-text',\r\n mixins: [ windowSize ],\r\n props: {\r\n title: {\r\n type: String,\r\n required: true\r\n },\r\n body: {\r\n type: String,\r\n required: true\r\n },\r\n maxLines: {\r\n type: Number,\r\n default: 3\r\n },\r\n maxLinesPhone: {\r\n type: Number,\r\n default: 5\r\n }\r\n },\r\n data() {\r\n return {\r\n truncatedBody: `\"${this.body}\"`\r\n };\r\n },\r\n created() {\r\n this._initialText = '';\r\n },\r\n watch: {\r\n isPhone: {\r\n handler: 'truncateBodyText'\r\n }\r\n },\r\n mounted() {\r\n this._initialText = this.$el.innerText;\r\n this.truncateBodyText();\r\n },\r\n methods: {\r\n calculateNumberOfLines() {\r\n const height = this.$el.offsetHeight;\r\n\r\n const lineHeight = getComputedStyle(this.$el)\r\n .getPropertyValue('line-height')\r\n .replace(/(px)$/, '');\r\n\r\n return Math.ceil(height / Number(lineHeight));\r\n },\r\n truncateBodyText() {\r\n const numberOfLines = this.calculateNumberOfLines();\r\n const maxLines = this.isPhone ? this.maxLinesPhone : this.maxLines;\r\n \r\n if (numberOfLines > maxLines) {\r\n const charactersPerLine = Math.floor(this._initialText.length / numberOfLines);\r\n \r\n const shortenedText = this._initialText\r\n .slice(0, charactersPerLine * maxLines - 4)\r\n .replace(this.title, '')\r\n .replace(/^\\s?\"/, '') // remove opening quote\r\n .replace(/\\s*$/, ''); // remove trailing whitespaces\r\n\r\n this.truncatedBody = `\"${shortenedText}...\"`; // manually add open/close quotes and ellipsis '...'\r\n }\r\n else {\r\n this.truncatedBody = `\"${this.body}\"`;\r\n }\r\n }\r\n },\r\n template: `\r\n

\r\n {{ title }}\r\n {{ truncatedBody }}\r\n

\r\n `\r\n};\r\n","import axios from 'axios';\r\nimport { IS_DEV, MAIN_CAROUSEL } from '@Shared/settings';\r\nimport TrustPilotReviewText from './trust-pilot-review-text';\r\n\r\nexport default {\r\n name: 'trust-pilot-widget',\r\n components: { TrustPilotReviewText },\r\n props: {\r\n configurationId: {\r\n type: String,\r\n required: true\r\n },\r\n\r\n bgThemeClass: {\r\n type: String,\r\n required: true\r\n },\r\n\r\n /**\r\n * Time interval between changing slides. Value should be in SECONDS.\r\n */\r\n slideChangeInterval: {\r\n type: Number,\r\n default: MAIN_CAROUSEL.defaults.slideChangeInterval\r\n },\r\n\r\n /**\r\n * Time to pause slide change interval. Value should be in MILLISECONDS.\r\n */\r\n slidePauseDuration: {\r\n type: Number,\r\n default: MAIN_CAROUSEL.defaults.pauseDuration\r\n },\r\n \r\n tpLogoAriaLabel: {\r\n type: String\r\n },\r\n\r\n /**\r\n * Variant that fills the entire width of the grid container\r\n */\r\n wide: {\r\n type: Boolean,\r\n default: false\r\n }\r\n },\r\n data() {\r\n return {\r\n scriptHasError: false,\r\n trustPilotData: null,\r\n isCarouselLoaded: false\r\n };\r\n },\r\n computed: {\r\n /**\r\n * Static title that does not change per review. It is a requirement from Trust Pilot.\r\n * See documentation for more details:\r\n * https://support.trustpilot.com/hc/en-us/articles/202319278-Trustpilot-API-Integrations-Guidelines#do-1\r\n */\r\n reviewTypeTitle() {\r\n if (!this.trustPilotData) return '';\r\n\r\n return this.trustPilotData.Title;\r\n },\r\n\r\n /**\r\n * This is the overall Trust Pilot rating for the entire website\r\n */\r\n overallScore() {\r\n if (!this.trustPilotData) return null;\r\n\r\n return {\r\n value: this.trustPilotData.OveralScore,\r\n image: this.trustPilotData.OveralScoreImage,\r\n title: `Overall Score: ${this.trustPilotData.OveralScore} out of 5\\nbased on ${this.totalReviews} reviews`\r\n };\r\n },\r\n\r\n reviews() {\r\n if (!this.trustPilotData) return [];\r\n\r\n return this.trustPilotData.Reviews;\r\n },\r\n\r\n totalReviews() {\r\n if (!this.trustPilotData) return 0;\r\n\r\n return this.trustPilotData.TotalReviewsCount;\r\n },\r\n\r\n tpLogo() {\r\n if (!this.trustPilotData) return '';\r\n\r\n return this.bgThemeClass === '-light' ? this.trustPilotData.LogoLight : this.trustPilotData.LogoDark;\r\n },\r\n\r\n isPhone() {\r\n return this.$store.getters.breakpointPhone;\r\n }\r\n },\r\n created() {\r\n this._intersectionObserver = null;\r\n },\r\n mounted() {\r\n this.createIntersectionObserver();\r\n },\r\n beforeDestroy() {\r\n this.destroyIntersectionObserver();\r\n },\r\n methods: {\r\n handleError() {\r\n this.scriptHasError = true;\r\n },\r\n handleIntersectionChange(entries = []) {\r\n // Need to iterate over the entire array. There is some strange behaviour where the target element appears\r\n // multiple times as an entry.\r\n for (const entry of entries) {\r\n const inViewPort = (entry.intersectionRatio || entry.isIntersecting);\r\n\r\n if (inViewPort) {\r\n this.destroyIntersectionObserver();\r\n this.getReviews();\r\n break;\r\n }\r\n }\r\n },\r\n createIntersectionObserver() {\r\n this._intersectionObserver = new IntersectionObserver(this.handleIntersectionChange, {\r\n threshold: [ 0, 1 ],\r\n rootMargin: '150px 0px 150px 0px'\r\n });\r\n this._intersectionObserver.observe(this.$el);\r\n },\r\n destroyIntersectionObserver() {\r\n if (this._intersectionObserver) {\r\n this._intersectionObserver.disconnect();\r\n this._intersectionObserver = null;\r\n }\r\n },\r\n async getReviews() {\r\n try {\r\n const { data } = await axios.post('/api/onlia/trustpilot/reviews', {\r\n Id: this.configurationId\r\n });\r\n\r\n this.trustPilotData = data;\r\n }\r\n catch (error) {\r\n (IS_DEV && console.error('getReviews error:', error));\r\n }\r\n },\r\n handleCarouselLoaded() {\r\n this.isCarouselLoaded = true;\r\n }\r\n },\r\n template: `\r\n
\r\n
\r\n \r\n \r\n \r\n
\r\n
\r\n `\r\n};\r\n"],"names":["name","components","TrustPilotReviewText","mixins","windowSize","props","title","type","String","required","body","maxLines","Number","default","maxLinesPhone","data","truncatedBody","concat","this","created","_initialText","watch","isPhone","handler","mounted","$el","innerText","truncateBodyText","methods","calculateNumberOfLines","height","offsetHeight","lineHeight","getComputedStyle","getPropertyValue","replace","Math","ceil","numberOfLines","charactersPerLine","floor","length","shortenedText","slice","template","configurationId","bgThemeClass","slideChangeInterval","MAIN_CAROUSEL","defaults","slidePauseDuration","pauseDuration","tpLogoAriaLabel","wide","Boolean","scriptHasError","trustPilotData","isCarouselLoaded","computed","reviewTypeTitle","Title","overallScore","value","OveralScore","image","OveralScoreImage","totalReviews","reviews","Reviews","TotalReviewsCount","tpLogo","LogoLight","LogoDark","$store","getters","breakpointPhone","_intersectionObserver","createIntersectionObserver","beforeDestroy","destroyIntersectionObserver","handleError","handleIntersectionChange","entries","arguments","undefined","entry","intersectionRatio","isIntersecting","getReviews","IntersectionObserver","threshold","rootMargin","observe","disconnect","axios","post","Id","error","IS_DEV","handleCarouselLoaded"],"sourceRoot":""}