{"version":3,"sources":["webpack:///./assets/javascripts/modules/components/ChatComponent.js"],"names":["ChatComponent","_classCallCheck","this","_possibleConstructorReturn","__proto__","Object","getPrototypeOf","call","Component","$on","e","$","each","ctx","select2","minimumResultsForSearch","Infinity","on","sselect","document","querySelector","sselectWrapper","closest","style","e0","originalEvent","delta","wheelDelta","detail","scrollTop","preventDefault","subjectSelect","data","params","args","id","value","evt","createEvent","initEvent","dispatchEvent","chatButton","removeClass","addClass","_this2","log","bindEvents","script","ChatUtils","getValue","moduleLoader","loadExternalScript","then","subjects","chatLabelSubject","chatLabelSubjectOptionOD","chatLabelSubjectOptionPay","chatLabelSubjectOptionCS","chatLabelSubjectOptionPAv","chatLabelSubjectOptionSt","chatLabelSubjectOptionRR","chatLabelSubjectOptionTA","addToObject","options","selectors","startChatLink","personalStylistCloseBtn","setEnvironment","updatePath","initializeChat","runsNewChat","checkReappearancePersonalStylistPopUp"],"mappings":"4XAMqBA,cAEnB,SAAAA,IAAc,mGAAAC,CAAAC,KAAAF,oKAAAG,CAAAD,MAAAF,EAAAI,WAAAC,OAAAC,eAAAN,IAAAO,KAAAL,0UAF2BM,gDAUvCN,KAAKO,IAAI,gBAAiB,SAACC,GAEPC,EAAE,yBACVC,KAAK,WACb,IAAIC,EAAOF,EAAET,MACbW,EAAIC,SACFC,wBAAyBC,MAE3BH,EAAII,GAAG,eAAgB,SAASP,GAE9B,IAAIQ,EAAUC,SAASC,cAAc,qBACrC,GAAe,MAAXF,EAAiB,CACnB,IAAIG,EAAiBH,EAAQI,QAAQ,uBACf,MAAlBD,IACFA,EAAeE,MAAM,WAAa,QAItCZ,EAAE,6BAA6BM,GAAI,4BAA6B,SAAUP,GACxE,IAAIc,EAAKd,EAAEe,cACPC,EAAQF,EAAGG,aAAeH,EAAGI,OACjC1B,KAAK2B,WAAsC,IAAvBH,EAAQ,EAAI,GAAK,GACrChB,EAAEoB,qBAINjB,EAAII,GAAG,oBAAqB,SAASP,GAEnC,IAAIqB,EAAgBZ,SAASC,cAAc,2DACtB,MAAjBW,IACFA,EAAgBZ,SAASC,cAAc,6CAEpB,MAAjBW,IACFA,EAAgBZ,SAASC,cAAc,gDAGzC,IAAIY,EAAOtB,EAAEuB,OAAOC,KAAKF,KAAKG,GAC9BJ,EAAcK,MAAQJ,EAEtB,IAAIK,EAAMlB,SAASmB,YAAY,UAC/BD,EAAIE,UAAU,UAAU,GAAM,GAC9BR,EAAcS,cAAcH,SAQlC,IAAII,EAAa9B,EAAE,0BAEnBT,KAAKO,IAAI,oBAAqB,SAACC,GAC7B+B,EAAWC,YAAY,iBAAiBC,SAAS,eAGnDzC,KAAKO,IAAI,qBAAsB,SAACC,GAC9B+B,EAAWC,YAAY,aAAaC,SAAS,oDAQxC,IAAAC,EAAA1C,KAOP,GANAA,KAAK2C,IAAI,gBAET3C,KAAK4C,aAIc,SAF0C,MAA1C3B,SAASC,cAAc,iBAA2BD,SAASC,cAAc,gBAAgBgB,OAEjF,CAEzB,IAAIW,EAASC,IAAUC,SAAS,oBAAoB,kCAEpD/C,KAAKgD,aAAaC,mBAAmBJ,GAAQK,KAAK,WAChDR,EAAKC,IAAI,cAET,IAAIQ,GACFC,iBAAkB,GAClBC,yBAA0B,wBAC1BC,0BAA2B,qCAC3BC,yBAA0B,2BAC1BC,0BAA2B,uCAC3BC,yBAA0B,SAC1BC,yBAA0B,sBAC1BC,yBAA0B,wBAGxBb,IAAUC,SAAS,+BACrBI,EAAWL,IAAUc,YAAYT,EAAS,2BAA2B,mBAAmB,IAG1F,IAAIU,GACFC,WACEC,cAAe,0BACfC,wBAAyB,+CAE3Bb,SAAUA,GAGZL,IAAUmB,eAAeJ,GAEzBf,IAAUoB,aAEVpB,IAAUqB,iBAEVrB,IAAUsB,cAEVtB,IAAUuB,oDAvHGvE","file":"components-ChatComponent.chunks.js","sourcesContent":["import Component from '../abstracts/Component';\nimport ChatUtils from '../utils/ChatUtils';\n\n/**\n Chat component\n */\nexport default class ChatComponent extends Component {\n\n constructor() {\n super();\n }\n\n bindEvents() {\n // listen to events\n\n // prechatOpened\n this.$on('prechatOpened', (e) => {\n // launch select2 js\n const $selectEl = $('.subjectSelect select');\n $selectEl.each(function () {\n let ctx = $(this);\n ctx.select2({\n minimumResultsForSearch: Infinity\n });\n ctx.on(\"select2:open\", function(e) {\n // i need the z-index\n let sselect = document.querySelector('.select2-dropdown');\n if (sselect != null) {\n let sselectWrapper = sselect.closest('.select2-container ');\n if (sselectWrapper != null) {\n sselectWrapper.style['z-index'] = '9999';\n }\n }\n // prevent body scrolling\n $('body .select2-dropdown ul').on( 'mousewheel DOMMouseScroll', function (e) {\n var e0 = e.originalEvent;\n var delta = e0.wheelDelta || -e0.detail;\n this.scrollTop += ( delta < 0 ? 1 : -1 ) * 30;\n e.preventDefault();\n });\n });\n // change the subject\n ctx.on(\"select2:selecting\", function(e) {\n // target\n let subjectSelect = document.querySelector('.embeddedServiceSidebar .fieldList #LiveChat_Subject__c');\n if (subjectSelect == null) {\n subjectSelect = document.querySelector('.embeddedServiceSidebar .fieldList #Type');\n }\n if (subjectSelect == null) {\n subjectSelect = document.querySelector('.embeddedServiceSidebar .fieldList #Subject');\n }\n // value\n var data = e.params.args.data.id;\n subjectSelect.value = data;\n // launch event\n var evt = document.createEvent(\"Events\");\n evt.initEvent(\"change\", true, true);\n subjectSelect.dispatchEvent(evt);\n });\n\n });\n\n });\n\n //\n var chatButton = $('a[data-name=live-chat]');\n // button online\n this.$on('chatButtonEnabled', (e) => {\n chatButton.removeClass('not-available').addClass('available');\n });\n // button offline\n this.$on('chatButtonDisabled', (e) => {\n chatButton.removeClass('available').addClass('not-available');\n });\n\n\n }\n\n\n /////\n render() {\n this.log('rendering...');\n // some events\n this.bindEvents();\n // check if new chat is enabled\n let chatEnabled = (document.querySelector('#chatEnabled') != null) ? document.querySelector('#chatEnabled').value : false;\n // if is enabled let's launch it\n if (chatEnabled == 'true') {\n // script call\n let script = ChatUtils.getValue('urlEnvironmentSF')+'/embeddedservice/5.0/esw.min.js';\n // get script and initialize chat\n this.moduleLoader.loadExternalScript(script).then(() => {\n this.log('loading...');\n // subjects\n let subjects = {\n chatLabelSubject: '',\n chatLabelSubjectOptionOD: 'Orders and deliveries',\n chatLabelSubjectOptionPay: 'Payment, promotions and Gift Cards',\n chatLabelSubjectOptionCS: 'Comments and Suggestions',\n chatLabelSubjectOptionPAv: 'Product information and availability',\n chatLabelSubjectOptionSt: 'Stores',\n chatLabelSubjectOptionRR: 'Refunds and Returns',\n chatLabelSubjectOptionTA: 'Technical assistance'\n }\n // if is present the conf, i add the PS\n if (ChatUtils.getValue('personalStylistSnapConfig')) {\n subjects = ChatUtils.addToObject(subjects,'chatLabelSubjectOptionPS','Personal Stylist',1);\n }\n // general options\n let options = {\n selectors: {\n startChatLink: '[data-name=live-chat] a',\n personalStylistCloseBtn: '.live-chat-personal-stylist-cta .icon-close',\n },\n subjects: subjects\n }\n // setup env\n ChatUtils.setEnvironment(options);\n // update cookie path\n ChatUtils.updatePath();\n // init the chat\n ChatUtils.initializeChat();\n // new chat modifier\n ChatUtils.runsNewChat();\n //\n ChatUtils.checkReappearancePersonalStylistPopUp();\n });\n }\n }\n}\n"],"sourceRoot":""}