/**! @license handlebars v4.7.7 Copyright (C) 2011-2019 by Yehuda Katz Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ !function(a,b){"object"==typeof exports&&"object"==typeof module?module.exports=b():"function"==typeof define&&define.amd?define([],b):"object"==typeof exports?exports.Handlebars=b():a.Handlebars=b()}(this,function(){return function(a){function b(d){if(c[d])return c[d].exports;var e=c[d]={exports:{},id:d,loaded:!1};return a[d].call(e.exports,e,e.exports,b),e.loaded=!0,e.exports}var c={};return b.m=a,b.c=c,b.p="",b(0)}([function(a,b,c){"use strict";function d(){var a=r();return a.compile=function(b,c){return k.compile(b,c,a)},a.precompile=function(b,c){return k.precompile(b,c,a)},a.AST=i["default"],a.Compiler=k.Compiler,a.JavaScriptCompiler=m["default"],a.Parser=j.parser,a.parse=j.parse,a.parseWithoutProcessing=j.parseWithoutProcessing,a}var e=c(1)["default"];b.__esModule=!0;var f=c(2),g=e(f),h=c(45),i=e(h),j=c(46),k=c(51),l=c(52),m=e(l),n=c(49),o=e(n),p=c(44),q=e(p),r=g["default"].create,s=d();s.create=d,q["default"](s),s.Visitor=o["default"],s["default"]=s,b["default"]=s,a.exports=b["default"]},function(a,b){"use strict";b["default"]=function(a){return a&&a.__esModule?a:{"default":a}},b.__esModule=!0},function(a,b,c){"use strict";function d(){var a=new h.HandlebarsEnvironment;return n.extend(a,h),a.SafeString=j["default"],a.Exception=l["default"],a.Utils=n,a.escapeExpression=n.escapeExpression,a.VM=p,a.template=function(b){return p.template(b,a)},a}var e=c(3)["default"],f=c(1)["default"];b.__esModule=!0;var g=c(4),h=e(g),i=c(37),j=f(i),k=c(6),l=f(k),m=c(5),n=e(m),o=c(38),p=e(o),q=c(44),r=f(q),s=d();s.create=d,r["default"](s),s["default"]=s,b["default"]=s,a.exports=b["default"]},function(a,b){"use strict";b["default"]=function(a){if(a&&a.__esModule)return a;var b={};if(null!=a)for(var c in a)Object.prototype.hasOwnProperty.call(a,c)&&(b[c]=a[c]);return b["default"]=a,b},b.__esModule=!0},function(a,b,c){"use strict";function d(a,b,c){this.helpers=a||{},this.partials=b||{},this.decorators=c||{},i.registerDefaultHelpers(this),j.registerDefaultDecorators(this)}var e=c(1)["default"];b.__esModule=!0,b.HandlebarsEnvironment=d;var f=c(5),g=c(6),h=e(g),i=c(10),j=c(30),k=c(32),l=e(k),m=c(33),n="4.7.7";b.VERSION=n;var o=8;b.COMPILER_REVISION=o;var p=7;b.LAST_COMPATIBLE_COMPILER_REVISION=p;var q={1:"<= 1.0.rc.2",2:"== 1.0.0-rc.3",3:"== 1.0.0-rc.4",4:"== 1.x.x",5:"== 2.0.0-alpha.x",6:">= 2.0.0-beta.1",7:">= 4.0.0 <4.3.0",8:">= 4.3.0"};b.REVISION_CHANGES=q;var r="[object Object]";d.prototype={constructor:d,logger:l["default"],log:l["default"].log,registerHelper:function(a,b){if(f.toString.call(a)===r){if(b)throw new h["default"]("Arg not supported with multiple helpers");f.extend(this.helpers,a)}else this.helpers[a]=b},unregisterHelper:function(a){delete this.helpers[a]},registerPartial:function(a,b){if(f.toString.call(a)===r)f.extend(this.partials,a);else{if("undefined"==typeof b)throw new h["default"]('Attempting to register a partial called "'+a+'" as undefined');this.partials[a]=b}},unregisterPartial:function(a){delete this.partials[a]},registerDecorator:function(a,b){if(f.toString.call(a)===r){if(b)throw new h["default"]("Arg not supported with multiple decorators");f.extend(this.decorators,a)}else this.decorators[a]=b},unregisterDecorator:function(a){delete this.decorators[a]},resetLoggedPropertyAccesses:function(){m.resetLoggedProperties()}};var s=l["default"].log;b.log=s,b.createFrame=f.createFrame,b.logger=l["default"]},function(a,b){"use strict";function c(a){return k[a]}function d(a){for(var b=1;b":">",'"':""","'":"'","`":"`","=":"="},l=/[&<>"'`=]/g,m=/[&<>"'`=]/,n=Object.prototype.toString;b.toString=n;var o=function(a){return"function"==typeof a};o(/x/)&&(b.isFunction=o=function(a){return"function"==typeof a&&"[object Function]"===n.call(a)}),b.isFunction=o;var p=Array.isArray||function(a){return!(!a||"object"!=typeof a)&&"[object Array]"===n.call(a)};b.isArray=p},function(a,b,c){"use strict";function d(a,b){var c=b&&b.loc,g=void 0,h=void 0,i=void 0,j=void 0;c&&(g=c.start.line,h=c.end.line,i=c.start.column,j=c.end.column,a+=" - "+g+":"+i);for(var k=Error.prototype.constructor.call(this,a),l=0;l0?(c.ids&&(c.ids=[c.name]),a.helpers.each(b,c)):e(this);if(c.data&&c.ids){var g=d.createFrame(c.data);g.contextPath=d.appendContextPath(c.data.contextPath,c.name),c={data:g}}return f(b,c)})},a.exports=b["default"]},function(a,b,c){(function(d){"use strict";var e=c(13)["default"],f=c(1)["default"];b.__esModule=!0;var g=c(5),h=c(6),i=f(h);b["default"]=function(a){a.registerHelper("each",function(a,b){function c(b,c,d){l&&(l.key=b,l.index=c,l.first=0===c,l.last=!!d,m&&(l.contextPath=m+b)),k+=f(a[b],{data:l,blockParams:g.blockParams([a[b],b],[m+b,null])})}if(!b)throw new i["default"]("Must pass iterator to #each");var f=b.fn,h=b.inverse,j=0,k="",l=void 0,m=void 0;if(b.data&&b.ids&&(m=g.appendContextPath(b.data.contextPath,b.ids[0])+"."),g.isFunction(a)&&(a=a.call(this)),b.data&&(l=g.createFrame(b.data)),a&&"object"==typeof a)if(g.isArray(a))for(var n=a.length;j=0?b:parseInt(a,10)}return a},log:function(a){if(a=e.lookupLevel(a),"undefined"!=typeof console&&e.lookupLevel(e.level)<=a){var b=e.methodMap[a];console[b]||(b="log");for(var c=arguments.length,d=Array(c>1?c-1:0),f=1;f=v.LAST_COMPATIBLE_COMPILER_REVISION&&b<=v.COMPILER_REVISION)){if(b2&&v.push("'"+this.terminals_[s]+"'");x=this.lexer.showPosition?"Parse error on line "+(i+1)+":\n"+this.lexer.showPosition()+"\nExpecting "+v.join(", ")+", got '"+(this.terminals_[n]||n)+"'":"Parse error on line "+(i+1)+": Unexpected "+(1==n?"end of input":"'"+(this.terminals_[n]||n)+"'"),this.parseError(x,{text:this.lexer.match,token:this.terminals_[n]||n,line:this.lexer.yylineno,loc:l,expected:v})}}if(q[0]instanceof Array&&q.length>1)throw new Error("Parse Error: multiple actions possible at state: "+p+", token: "+n);switch(q[0]){case 1:d.push(n),e.push(this.lexer.yytext),f.push(this.lexer.yylloc),d.push(q[1]),n=null,o?(n=o,o=null):(j=this.lexer.yyleng,h=this.lexer.yytext,i=this.lexer.yylineno,l=this.lexer.yylloc,k>0&&k--);break;case 2:if(t=this.productions_[q[1]][1],w.$=e[e.length-t],w._$={first_line:f[f.length-(t||1)].first_line,last_line:f[f.length-1].last_line,first_column:f[f.length-(t||1)].first_column,last_column:f[f.length-1].last_column},m&&(w._$.range=[f[f.length-(t||1)].range[0],f[f.length-1].range[1]]),r=this.performAction.call(w,h,j,i,this.yy,q[1],e,f),"undefined"!=typeof r)return r;t&&(d=d.slice(0,-1*t*2),e=e.slice(0,-1*t),f=f.slice(0,-1*t)),d.push(this.productions_[q[1]][0]),e.push(w.$),f.push(w._$),u=g[d[d.length-2]][d[d.length-1]],d.push(u);break;case 3:return!0}}return!0}},c=function(){var a={EOF:1,parseError:function(a,b){if(!this.yy.parser)throw new Error(a);this.yy.parser.parseError(a,b)},setInput:function(a){return this._input=a,this._more=this._less=this.done=!1,this.yylineno=this.yyleng=0,this.yytext=this.matched=this.match="",this.conditionStack=["INITIAL"],this.yylloc={first_line:1,first_column:0,last_line:1,last_column:0},this.options.ranges&&(this.yylloc.range=[0,0]),this.offset=0,this},input:function(){var a=this._input[0];this.yytext+=a,this.yyleng++,this.offset++,this.match+=a,this.matched+=a;var b=a.match(/(?:\r\n?|\n).*/g);return b?(this.yylineno++,this.yylloc.last_line++):this.yylloc.last_column++,this.options.ranges&&this.yylloc.range[1]++,this._input=this._input.slice(1),a},unput:function(a){var b=a.length,c=a.split(/(?:\r\n?|\n)/g);this._input=a+this._input,this.yytext=this.yytext.substr(0,this.yytext.length-b-1),this.offset-=b;var d=this.match.split(/(?:\r\n?|\n)/g);this.match=this.match.substr(0,this.match.length-1),this.matched=this.matched.substr(0,this.matched.length-1),c.length-1&&(this.yylineno-=c.length-1);var e=this.yylloc.range;return this.yylloc={first_line:this.yylloc.first_line,last_line:this.yylineno+1,first_column:this.yylloc.first_column,last_column:c?(c.length===d.length?this.yylloc.first_column:0)+d[d.length-c.length].length-c[0].length:this.yylloc.first_column-b},this.options.ranges&&(this.yylloc.range=[e[0],e[0]+this.yyleng-b]),this},more:function(){return this._more=!0,this},less:function(a){this.unput(this.match.slice(a))},pastInput:function(){var a=this.matched.substr(0,this.matched.length-this.match.length);return(a.length>20?"...":"")+a.substr(-20).replace(/\n/g,"")},upcomingInput:function(){var a=this.match;return a.length<20&&(a+=this._input.substr(0,20-a.length)),(a.substr(0,20)+(a.length>20?"...":"")).replace(/\n/g,"")},showPosition:function(){var a=this.pastInput(),b=new Array(a.length+1).join("-");return a+this.upcomingInput()+"\n"+b+"^"},next:function(){if(this.done)return this.EOF;this._input||(this.done=!0);var a,b,c,d,e;this._more||(this.yytext="",this.match="");for(var f=this._currentRules(),g=0;gb[0].length)||(b=c,d=g,this.options.flex));g++);return b?(e=b[0].match(/(?:\r\n?|\n).*/g),e&&(this.yylineno+=e.length),this.yylloc={first_line:this.yylloc.last_line,last_line:this.yylineno+1,first_column:this.yylloc.last_column,last_column:e?e[e.length-1].length-e[e.length-1].match(/\r?\n?/)[0].length:this.yylloc.last_column+b[0].length},this.yytext+=b[0],this.match+=b[0],this.matches=b,this.yyleng=this.yytext.length,this.options.ranges&&(this.yylloc.range=[this.offset,this.offset+=this.yyleng]),this._more=!1,this._input=this._input.slice(b[0].length),this.matched+=b[0],a=this.performAction.call(this,this.yy,this,f[d],this.conditionStack[this.conditionStack.length-1]),this.done&&this._input&&(this.done=!1),a?a:void 0):""===this._input?this.EOF:this.parseError("Lexical error on line "+(this.yylineno+1)+". Unrecognized text.\n"+this.showPosition(),{text:"",token:null,line:this.yylineno})},lex:function(){var a=this.next();return"undefined"!=typeof a?a:this.lex()},begin:function(a){this.conditionStack.push(a)},popState:function(){return this.conditionStack.pop()},_currentRules:function(){return this.conditions[this.conditionStack[this.conditionStack.length-1]].rules},topState:function(){return this.conditionStack[this.conditionStack.length-2]},pushState:function(a){this.begin(a)}};return a.options={},a.performAction=function(a,b,c,d){function e(a,c){return b.yytext=b.yytext.substring(a,b.yyleng-c+a)}switch(c){case 0:if("\\\\"===b.yytext.slice(-2)?(e(0,1),this.begin("mu")):"\\"===b.yytext.slice(-1)?(e(0,1),this.begin("emu")):this.begin("mu"),b.yytext)return 15;break;case 1:return 15;case 2:return this.popState(),15;case 3:return this.begin("raw"),15;case 4:return this.popState(),"raw"===this.conditionStack[this.conditionStack.length-1]?15:(e(5,9),"END_RAW_BLOCK");case 5:return 15;case 6:return this.popState(),14;case 7:return 65;case 8:return 68;case 9:return 19;case 10:return this.popState(),this.begin("raw"),23;case 11:return 55;case 12:return 60;case 13:return 29;case 14:return 47;case 15:return this.popState(),44;case 16:return this.popState(),44;case 17:return 34;case 18:return 39;case 19:return 51;case 20:return 48;case 21:this.unput(b.yytext),this.popState(),this.begin("com");break;case 22:return this.popState(),14;case 23:return 48;case 24:return 73;case 25:return 72;case 26:return 72;case 27:return 87;case 28:break;case 29:return this.popState(),54;case 30:return this.popState(),33;case 31:return b.yytext=e(1,2).replace(/\\"/g,'"'),80;case 32:return b.yytext=e(1,2).replace(/\\'/g,"'"),80;case 33:return 85;case 34:return 82;case 35:return 82;case 36:return 83;case 37:return 84;case 38:return 81;case 39:return 75;case 40:return 77;case 41:return 72;case 42:return b.yytext=b.yytext.replace(/\\([\\\]])/g,"$1"),72;case 43:return"INVALID";case 44:return 5}},a.rules=[/^(?:[^\x00]*?(?=(\{\{)))/,/^(?:[^\x00]+)/,/^(?:[^\x00]{2,}?(?=(\{\{|\\\{\{|\\\\\{\{|$)))/,/^(?:\{\{\{\{(?=[^\/]))/,/^(?:\{\{\{\{\/[^\s!"#%-,\.\/;->@\[-\^`\{-~]+(?=[=}\s\/.])\}\}\}\})/,/^(?:[^\x00]+?(?=(\{\{\{\{)))/,/^(?:[\s\S]*?--(~)?\}\})/,/^(?:\()/,/^(?:\))/,/^(?:\{\{\{\{)/,/^(?:\}\}\}\})/,/^(?:\{\{(~)?>)/,/^(?:\{\{(~)?#>)/,/^(?:\{\{(~)?#\*?)/,/^(?:\{\{(~)?\/)/,/^(?:\{\{(~)?\^\s*(~)?\}\})/,/^(?:\{\{(~)?\s*else\s*(~)?\}\})/,/^(?:\{\{(~)?\^)/,/^(?:\{\{(~)?\s*else\b)/,/^(?:\{\{(~)?\{)/,/^(?:\{\{(~)?&)/,/^(?:\{\{(~)?!--)/,/^(?:\{\{(~)?![\s\S]*?\}\})/,/^(?:\{\{(~)?\*?)/,/^(?:=)/,/^(?:\.\.)/,/^(?:\.(?=([=~}\s\/.)|])))/,/^(?:[\/.])/,/^(?:\s+)/,/^(?:\}(~)?\}\})/,/^(?:(~)?\}\})/,/^(?:"(\\["]|[^"])*")/,/^(?:'(\\[']|[^'])*')/,/^(?:@)/,/^(?:true(?=([~}\s)])))/,/^(?:false(?=([~}\s)])))/,/^(?:undefined(?=([~}\s)])))/,/^(?:null(?=([~}\s)])))/,/^(?:-?[0-9]+(?:\.[0-9]+)?(?=([~}\s)])))/,/^(?:as\s+\|)/,/^(?:\|)/,/^(?:([^\s!"#%-,\.\/;->@\[-\^`\{-~]+(?=([=~}\s\/.)|]))))/,/^(?:\[(\\\]|[^\]])*\])/,/^(?:.)/,/^(?:$)/],a.conditions={mu:{rules:[7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44],inclusive:!1},emu:{rules:[2],inclusive:!1},com:{rules:[6],inclusive:!1},raw:{rules:[3,4,5],inclusive:!1},INITIAL:{rules:[0,1,44],inclusive:!0}},a}();return b.lexer=c,a.prototype=b,b.Parser=a,new a}();b["default"]=c,a.exports=b["default"]},function(a,b,c){"use strict";function d(){var a=arguments.length<=0||void 0===arguments[0]?{}:arguments[0];this.options=a}function e(a,b,c){void 0===b&&(b=a.length);var d=a[b-1],e=a[b-2];return d?"ContentStatement"===d.type?(e||!c?/\r?\n\s*?$/:/(^|\r?\n)\s*?$/).test(d.original):void 0:c}function f(a,b,c){void 0===b&&(b=-1);var d=a[b+1],e=a[b+2];return d?"ContentStatement"===d.type?(e||!c?/^\s*?\r?\n/:/^\s*?(\r?\n|$)/).test(d.original):void 0:c}function g(a,b,c){var d=a[null==b?0:b+1];if(d&&"ContentStatement"===d.type&&(c||!d.rightStripped)){var e=d.value;d.value=d.value.replace(c?/^\s+/:/^[ \t]*\r?\n?/,""),d.rightStripped=d.value!==e}}function h(a,b,c){var d=a[null==b?a.length-1:b-1];if(d&&"ContentStatement"===d.type&&(c||!d.leftStripped)){var e=d.value;return d.value=d.value.replace(c?/\s+$/:/[ \t]+$/,""),d.leftStripped=d.value!==e,d.leftStripped}}var i=c(1)["default"];b.__esModule=!0;var j=c(49),k=i(j);d.prototype=new k["default"],d.prototype.Program=function(a){var b=!this.options.ignoreStandalone,c=!this.isRootSeen;this.isRootSeen=!0;for(var d=a.body,i=0,j=d.length;i0)throw new q["default"]("Invalid path: "+d,{loc:c});".."===i&&f++}}return{type:"PathExpression",data:a,depth:f,parts:e,original:d,loc:c}}function j(a,b,c,d,e,f){var g=d.charAt(3)||d.charAt(2),h="{"!==g&&"&"!==g,i=/\*/.test(d);return{type:i?"Decorator":"MustacheStatement",path:a,params:b,hash:c,escaped:h,strip:e,loc:this.locInfo(f)}}function k(a,b,c,e){d(a,c),e=this.locInfo(e);var f={type:"Program",body:b,strip:{},loc:e};return{type:"BlockStatement",path:a.path,params:a.params,hash:a.hash,program:f,openStrip:{},inverseStrip:{},closeStrip:{},loc:e}}function l(a,b,c,e,f,g){e&&e.path&&d(a,e);var h=/\*/.test(a.open);b.blockParams=a.blockParams;var i=void 0,j=void 0;if(c){if(h)throw new q["default"]("Unexpected inverse block on decorator",c);c.chain&&(c.program.body[0].closeStrip=e.strip),j=c.strip,i=c.program}return f&&(f=i,i=b,b=f),{type:h?"DecoratorBlock":"BlockStatement",path:a.path,params:a.params,hash:a.hash,program:b,inverse:i,openStrip:a.strip,inverseStrip:j,closeStrip:e&&e.strip,loc:this.locInfo(g)}}function m(a,b){if(!b&&a.length){var c=a[0].loc,d=a[a.length-1].loc;c&&d&&(b={source:c.source,start:{line:c.start.line,column:c.start.column},end:{line:d.end.line,column:d.end.column}})}return{type:"Program",body:a,strip:{},loc:b}}function n(a,b,c,e){return d(a,c),{type:"PartialBlockStatement",name:a.path,params:a.params,hash:a.hash,program:b,openStrip:a.strip,closeStrip:c&&c.strip,loc:this.locInfo(e)}}var o=c(1)["default"];b.__esModule=!0,b.SourceLocation=e,b.id=f,b.stripFlags=g,b.stripComment=h,b.preparePath=i,b.prepareMustache=j,b.prepareRawBlock=k,b.prepareBlock=l,b.prepareProgram=m,b.preparePartialBlock=n;var p=c(6),q=o(p)},function(a,b,c){"use strict";function d(){}function e(a,b,c){if(null==a||"string"!=typeof a&&"Program"!==a.type)throw new l["default"]("You must pass a string or Handlebars AST to Handlebars.precompile. You passed "+a);b=b||{},"data"in b||(b.data=!0),b.compat&&(b.useDepths=!0);var d=c.parse(a,b),e=(new c.Compiler).compile(d,b);return(new c.JavaScriptCompiler).compile(e,b)}function f(a,b,c){function d(){var d=c.parse(a,b),e=(new c.Compiler).compile(d,b),f=(new c.JavaScriptCompiler).compile(e,b,void 0,!0);return c.template(f)}function e(a,b){return f||(f=d()),f.call(this,a,b)}if(void 0===b&&(b={}),null==a||"string"!=typeof a&&"Program"!==a.type)throw new l["default"]("You must pass a string or Handlebars AST to Handlebars.compile. You passed "+a);b=m.extend({},b),"data"in b||(b.data=!0),b.compat&&(b.useDepths=!0);var f=void 0;return e._setup=function(a){return f||(f=d()),f._setup(a)},e._child=function(a,b,c,e){return f||(f=d()),f._child(a,b,c,e)},e}function g(a,b){if(a===b)return!0;if(m.isArray(a)&&m.isArray(b)&&a.length===b.length){for(var c=0;c1)throw new l["default"]("Unsupported number of partial arguments: "+c.length,a);c.length||(this.options.explicitPartialContext?this.opcode("pushLiteral","undefined"):c.push({type:"PathExpression",parts:[],depth:0}));var d=a.name.original,e="SubExpression"===a.name.type;e&&this.accept(a.name),this.setupFullMustacheParams(a,b,void 0,!0);var f=a.indent||"";this.options.preventIndent&&f&&(this.opcode("appendContent",f),f=""),this.opcode("invokePartial",e,d,f),this.opcode("append")},PartialBlockStatement:function(a){this.PartialStatement(a)},MustacheStatement:function(a){this.SubExpression(a),a.escaped&&!this.options.noEscape?this.opcode("appendEscaped"):this.opcode("append")},Decorator:function(a){this.DecoratorBlock(a)},ContentStatement:function(a){a.value&&this.opcode("appendContent",a.value)},CommentStatement:function(){},SubExpression:function(a){h(a);var b=this.classifySexpr(a);"simple"===b?this.simpleSexpr(a):"helper"===b?this.helperSexpr(a):this.ambiguousSexpr(a)},ambiguousSexpr:function(a,b,c){var d=a.path,e=d.parts[0],f=null!=b||null!=c;this.opcode("getContext",d.depth),this.opcode("pushProgram",b),this.opcode("pushProgram",c),d.strict=!0,this.accept(d),this.opcode("invokeAmbiguous",e,f)},simpleSexpr:function(a){var b=a.path;b.strict=!0,this.accept(b),this.opcode("resolvePossibleLambda")},helperSexpr:function(a,b,c){var d=this.setupFullMustacheParams(a,b,c),e=a.path,f=e.parts[0];if(this.options.knownHelpers[f])this.opcode("invokeKnownHelper",d.length,f);else{if(this.options.knownHelpersOnly)throw new l["default"]("You specified knownHelpersOnly, but used the unknown helper "+f,a);e.strict=!0,e.falsy=!0,this.accept(e),this.opcode("invokeHelper",d.length,e.original,o["default"].helpers.simpleId(e))}},PathExpression:function(a){this.addDepth(a.depth),this.opcode("getContext",a.depth);var b=a.parts[0],c=o["default"].helpers.scopedId(a),d=!a.depth&&!c&&this.blockParamIndex(b);d?this.opcode("lookupBlockParam",d,a.parts):b?a.data?(this.options.data=!0,this.opcode("lookupData",a.depth,a.parts,a.strict)):this.opcode("lookupOnContext",a.parts,a.falsy,a.strict,c):this.opcode("pushContext")},StringLiteral:function(a){this.opcode("pushString",a.value)},NumberLiteral:function(a){this.opcode("pushLiteral",a.value)},BooleanLiteral:function(a){this.opcode("pushLiteral",a.value)},UndefinedLiteral:function(){this.opcode("pushLiteral","undefined")},NullLiteral:function(){this.opcode("pushLiteral","null")},Hash:function(a){var b=a.pairs,c=0,d=b.length;for(this.opcode("pushHash");c=0)return[b,e]}}}},function(a,b,c){"use strict";function d(a){this.value=a}function e(){}function f(a,b,c,d){var e=b.popStack(),f=0,g=c.length;for(a&&g--;f0&&(c+=", "+d.join(", "));var e=0;g(this.aliases).forEach(function(a){var d=b.aliases[a];d.children&&d.referenceCount>1&&(c+=", alias"+ ++e+"="+a,d.children[0]="alias"+e)}),this.lookupPropertyFunctionIsUsed&&(c+=", "+this.lookupPropertyFunctionVarDeclaration());var f=["container","depth0","helpers","partials","data"];(this.useBlockParams||this.useDepths)&&f.push("blockParams"),this.useDepths&&f.push("depths");var h=this.mergeSource(c);return a?(f.push(h),Function.apply(this,f)):this.source.wrap(["function(",f.join(","),") {\n ",h,"}"])},mergeSource:function(a){var b=this.environment.isSimple,c=!this.forceBuffer,d=void 0,e=void 0,f=void 0,g=void 0;return this.source.each(function(a){a.appendToBuffer?(f?a.prepend(" + "):f=a,g=a):(f&&(e?f.prepend("buffer += "):d=!0,g.add(";"),f=g=void 0),e=!0,b||(c=!1))}),c?f?(f.prepend("return "),g.add(";")):e||this.source.push('return "";'):(a+=", buffer = "+(d?"":this.initializeBuffer()),f?(f.prepend("return buffer + "),g.add(";")):this.source.push("return buffer;")),a&&this.source.prepend("var "+a.substring(2)+(d?"":";\n")),this.source.merge()},lookupPropertyFunctionVarDeclaration:function(){return"\n lookupProperty = container.lookupProperty || function(parent, propertyName) {\n if (Object.prototype.hasOwnProperty.call(parent, propertyName)) {\n return parent[propertyName];\n }\n return undefined\n }\n ".trim()},blockValue:function(a){var b=this.aliasable("container.hooks.blockHelperMissing"),c=[this.contextName(0)];this.setupHelperArgs(a,0,c);var d=this.popStack();c.splice(1,0,d),this.push(this.source.functionCall(b,"call",c))},ambiguousBlockValue:function(){var a=this.aliasable("container.hooks.blockHelperMissing"),b=[this.contextName(0)];this.setupHelperArgs("",0,b,!0),this.flushInline();var c=this.topStack();b.splice(1,0,c),this.pushSource(["if (!",this.lastHelper,") { ",c," = ",this.source.functionCall(a,"call",b),"}"])},appendContent:function(a){this.pendingContent?a=this.pendingContent+a:this.pendingLocation=this.source.currentLocation,this.pendingContent=a},append:function(){if(this.isInline())this.replaceStack(function(a){return[" != null ? ",a,' : ""']}),this.pushSource(this.appendToBuffer(this.popStack()));else{var a=this.popStack();this.pushSource(["if (",a," != null) { ",this.appendToBuffer(a,void 0,!0)," }"]),this.environment.isSimple&&this.pushSource(["else { ",this.appendToBuffer("''",void 0,!0)," }"])}},appendEscaped:function(){this.pushSource(this.appendToBuffer([this.aliasable("container.escapeExpression"),"(",this.popStack(),")"]))},getContext:function(a){this.lastContext=a},pushContext:function(){this.pushStackLiteral(this.contextName(this.lastContext))},lookupOnContext:function(a,b,c,d){var e=0;d||!this.options.compat||this.lastContext?this.pushContext():this.push(this.depthedLookup(a[e++])),this.resolvePath("context",a,e,b,c)},lookupBlockParam:function(a,b){this.useBlockParams=!0,this.push(["blockParams[",a[0],"][",a[1],"]"]),this.resolvePath("context",b,1)},lookupData:function(a,b,c){a?this.pushStackLiteral("container.data(data, "+a+")"):this.pushStackLiteral("data"),this.resolvePath("data",b,0,!0,c)},resolvePath:function(a,b,c,d,e){var g=this;if(this.options.strict||this.options.assumeObjects)return void this.push(f(this.options.strict&&e,this,b,a));for(var h=b.length;cthis.stackVars.length&&this.stackVars.push("stack"+this.stackSlot),this.topStackName()},topStackName:function(){return"stack"+this.stackSlot},flushInline:function(){var a=this.inlineStack;this.inlineStack=[];for(var b=0,c=a.length;b { let propValue = objectToScrub[key]; if (typeof propValue === 'string') { let strValue = propValue.toLowerCase(); switch(strValue) { case "true": objectToScrub[key] = true; break; case "false": objectToScrub[key] = false; break; case "inherit": delete objectToScrub[key]; break; } } }); } return objectToScrub; }; this.getChatConfiguration = async function() { let defaultChatConfig = this.scrubOffInheritedValues(this.getJsonConfig(chatDefaultConfigSel)); let defaultSiteTypeChatConfig = this.scrubOffInheritedValues(this.getJsonConfig(chatDefaultSiteTypeConfigSel)); let llccGeneralChatConfig = this.scrubOffInheritedValues(this.getJsonConfig(chatDefaultLocaleConfigSel)); let llccSpecificChatConfig = this.scrubOffInheritedValues(this.getJsonConfig(chatSpecificSiteTypeLocaleSel)); return Object.assign( defaultChatConfig, defaultSiteTypeChatConfig, llccGeneralChatConfig, llccSpecificChatConfig ); }; this.logDebugMessage = function(message) { opts.logDebugMessage(message); }; this.getLlcc = function() { return opts.llcc; }; this.getSiteType = function() { return opts.siteType; }; } window.chat.main = function (opts) { const selectors = { chatButtonSelector: '[data-oc-chat], [data-ow-chat]', contactSalesID: '#oc-contact-sales', ariaHiddenAttrName: 'aria-hidden', multiFlyoutButton: '.ow-chat', multiFlyoutButtonGlyph: '.ow-glyph', viewportMeta: 'meta[name=viewport]', iframeCloseButton: '.lp-iframe-close', owProactiveMetaTag: "meta[name='ow.isChatProactive']", pmgProactiveMetaTag: "meta[name='pmg.chatproactive']", secondaryChatButtonSelector: '[data-oc-chat]:not([data-oc-chat="true"]), [data-ow-chat]:not([data-ow-chat="true"])', submarketAjaxButtonId: 'owAjaxUpdate', contactUsList: '.ow-contactsale-list' }; const chatDialogOpenedPrevKey = "chatDialogOpenedPreviously"; let wasSendPageSent = false; let wasLpcUrlSent = false; let isOpened = false; let wasTopicSent = false; let outerContainer = false; let innerContainer = false; let closeButton = false; let iframe = false; let secondaryChatLinks = false; let buttonReadyReceived = false; let telemetryMapping = false; this.getUtils = function() { return window.chat.Utils; }; this.getContactUsList = function() { return document.querySelector(opts.contactUsListSelector ? opts.contactUsListSelector : selectors.contactUsList); }; this.getSubmarketAjaxButton = function() { return document.getElementById(opts.submarketAjaxButtonId ? opts.submarketAjaxButtonId : selectors.submarketAjaxButtonId); }; this.getSiteId = function() { return opts.siteId; }; this.getTelemetryMappings = function() { let ret = false; if (telemetryMapping) { ret = telemetryMapping; } else { ret = JSON.parse(opts.telemetryMapping); telemetryMapping = ret; } return ret; }; this.getTelemetryChatId = function() { return opts.telemetryChatId; }; this.getTelemetryChatAn = function() { return opts.telemetryChatAn; }; this.getTopicName = function () { return opts.topic; }; this.setTopicName = function (topic) { opts.topic = topic; this.setDebugInfo("LP Topic", topic); }; this.getSectionId = function() { return opts.sectionId; }; this.getProactiveSuppressionFlag = function() { return opts.suppressProactive; }; this.getLlcc = function() { return opts.llcc; }; this.getProactiveChat = function() { return opts.proactiveChatDialog; }; this.getSrcFmt = function() { return opts.srcFmt; }; this.getTargetDomain = function() { return opts.domainUrl; }; this.getMarket = function() { return opts.market; }; this.getIframeClassList = function() { return opts.classList ? opts.classList : ["lp-iframe-window"]; }; this.getOuterContainer = function() { let ret = null; if (outerContainer) { ret = outerContainer; } else { ret = document.createElement('div'); ret.classList.add('lp-live-person'); outerContainer = ret; } return ret; }; this.getInnerContainerClassList = function() { return opts.innerContainerClasses ? opts.innerContainerClasses : ["c-flyout", "flyout-nohide"]; }; this.getInnerContainerId = function() { return opts.innerContainerId; }; this.getInnerContainer = function() { let ret = null; if (innerContainer) { ret = innerContainer; } else { ret = document.createElement('div'); ret.classList.add(...this.getInnerContainerClassList()); ret.setAttribute('id', this.getInnerContainerId()); ret.setAttribute('role', 'dialog'); ret.setAttribute('aria-hidden', 'true'); ret.setAttribute('aria-description', opts.chatDialogDescription); ret.dataset.jsFlyoutPlacement = 'top'; ret.dataset.jsFlyoutDismissible = 'false'; innerContainer = ret; } return ret; }; this.getCloseButtonClasses = function() { return opts.closeButtonClasses ? opts.closeButtonClasses : ["c-glyph", "glyph-cancel", "lp-iframe-close", "x-hidden"]; }; this.getCloseButton = function() { let ret = null; if (closeButton) { ret = closeButton; } else { ret = document.createElement('button'); ret.classList.add(...this.getCloseButtonClasses()); closeButton = ret; } return ret; }; this.setDebugInfo = function(infoname, info) { if (this.isDebugArgumentPresent()) { this.getDebugDialog().setDebugInfo(infoname, info); } }; this.getIframe = function() { let ret = null; if (iframe) { ret = iframe; } else { ret = document.createElement('iframe'); ret.setAttribute('src', this.getSrcFmt().format(this.getSiteId(), this.getSectionId())); this.setDebugInfo("LP Site ID", this.getSiteId()); this.setDebugInfo("LP Section ID", this.getSectionId()); ret.setAttribute('allow', 'camera;microphone'); ret.setAttribute('aria-live', 'assertive'); ret.setAttribute('aria-label', opts.chatDialogDescription); ret.classList.add(...this.getIframeClassList()); iframe = ret; } return ret; }; this.getChatButton = function() { return document.querySelector(selectors.chatButtonSelector); }; /** Gets if the WCP Consent library is available for use. */ this.getIsWcpConsentAvailable = function() { return ( typeof WcpConsent === "function" && typeof WcpConsent.siteConsent === "object" && typeof WcpConsent.siteConsent.getConsent === "function" ); }; this.getChatMessage = function(event) { return event.data.action || event.data.window || event.data.engagement || event.data.button || event.data.invite || event.data.analyticsChatWindowClick || event.data.analyticsUIClick || event.data.analyticsUIRender; }; this.isChatMessage = function(event) { return event && event.data && event.origin === this.getTargetDomain(); }; this.getProactiveMetaTag = function() { return document.querySelector(selectors.owProactiveMetaTag) || document.querySelector(selectors.pmgProactiveMetaTag); }; this.isProactiveDialogOff = function(metaChatProactive) { let metaChatProactiveContent = metaChatProactive.getAttribute("content").toLowerCase(); return metaChatProactiveContent === 'off' || metaChatProactiveContent === 'false' || this.getProactiveSuppressionFlag(); }; this.isExcludeProactive = function() { let ret = false; let metaChatProactive = this.getProactiveMetaTag(); if (this.getProactiveSuppressionFlag()) { ret = true; } else if (metaChatProactive) { ret = this.isProactiveDialogOff(metaChatProactive); } return ret; }; this.isMobile = function() { return opts.isMobile; }; this.isDebugArgumentPresent = function() { return opts.isDebug; }; this.getDebugDialog = function() { return opts.debugDialog; }; this.isGeoExclusionDisabled = function() { return !opts.geoExclusion; }; this.logIFrameMessages = function(wasSent, message) { if (this.isDebugArgumentPresent()) { this.getDebugDialog().appendMessage(`📨 Chat VNext iFrame message ${wasSent ? "sent" : "received"}: ${JSON.stringify(message)}`); } }; this.logFinishedStep = function(stepName) { let debugDialog = this.getDebugDialog(); if (this.isDebugArgumentPresent() && debugDialog) { debugDialog.finishedStep(stepName); } }; this.bindGlobalEvents = function() { window.addEventListener("message", this.receiveMessage.bind(this), false); window.addEventListener("resize", this.sendParentSizeMessages.bind(this), false); this.logFinishedStep("Attach window events"); }; //TODO: When contact sales is done, tie this to an event that fires when the module is done loading. this.bindPrimaryChatButtonEvents = function() { let utils = this.getUtils(); (new utils.throttledCallback({ callback: function (intervalHandle) { let chatButton = this.getChatButton(); if (chatButton) { clearInterval(intervalHandle); chatButton.addEventListener('click', this.openChatIFrame.bind(this)); chatButton.addEventListener('keydown', this.openChatIFrameByEnter.bind(this)); } }.bind(this) })).run(); }; /** * Wait for the contact sales widget to be ready, then bind (singular) chat button inside that widget. */ this.waitForContactSalesRightRailWidget = function() { OneCloudUtil.waitForElement(selectors.contactSalesID, document).then(() => { let button = document.querySelector(selectors.contactSalesID).querySelector(selectors.chatButtonSelector); this.bindChatButton(button); }); }; /** * Binds a button to open the chat iFrame. * @param {htmlElement} button to add a click binding for the open chat IFrame */ this.bindChatButton = function(button) { button.addEventListener('click', this.openChatIFrame.bind(this)); }; this.bindSecondaryChatButtonEvents = function() { let secondaryChatButtons = this.getSecondaryChatLinks(); for (const element of secondaryChatButtons) { element.addEventListener('click', this.openChatIFrame.bind(this)); } }; this.checkForContactUsListAndBind = function (intervalHandle) { let cList = this.getContactUsList(); if (cList && !cList.dataset.isOldOne) { this.bindChatButtons(); clearInterval(intervalHandle); } }; this.waitForSubmarketContactUsToLoadThenBindButtons = function() { let cList = this.getContactUsList(); if (cList) { let utils = this.getUtils(); cList.dataset.isOldOne = true; (new utils.throttledCallback({ callback: this.checkForContactUsListAndBind.bind(this) })).run(); } }; this.bindChatButtons = function () { this.bindPrimaryChatButtonEvents(); this.bindSecondaryChatButtonEvents(); }; this.sendDomParentReadyMessage = function () { if (!buttonReadyReceived) { setTimeout(() => { this.sendIFrameMessage({ action: 'DOMParentReady' }); }, 3000); } }; this.isPageDoneLoading = function () { return document.readyState === "complete" || document.readyState === "interactive"; }; this.bindEvents = function() { this.bindChatButtons(); this.bindGlobalEvents(); this.bindProactiveChat(); // If the contact sales widget hasn't loaded yet, we'll wait for it. if (!document.querySelector(selectors.contactSalesID)) { this.waitForContactSalesRightRailWidget(); } this.logFinishedStep("Attach iFrame and Button events"); }; /** * Gets and caches the secondary chat links. */ this.getSecondaryChatLinks = function() { let ret = false; if (secondaryChatLinks) { ret = secondaryChatLinks; } else { ret = document.querySelectorAll(selectors.secondaryChatButtonSelector); secondaryChatLinks = ret; } return ret; }; this.onStatusChange = function (height, width) { let iframeWindowStyle = this.getIframe().style; this.getInnerContainer().setAttribute('style', `height:${height} !important;min-width:${width};max-width:${width};`); iframeWindowStyle.height = height; iframeWindowStyle.width = width; }; this.setTopicWasSentOnOldSession = function(isOldSession) { if (isOldSession) { wasTopicSent = true; isOpened = true; this.setLpcUrlSent(true); } } this.onOpened = function (isOldSession) { let chatButton = this.getChatButton(); if (chatButton) { this.setTopicWasSentOnOldSession(isOldSession); chatButton.click(); } this.sendParentSizeMessagesInMobileCanvasOnly(); }; this.bindProactiveChat = function() { let proactiveDialog = this.getProactiveChat(); if (proactiveDialog) { proactiveDialog.bindEvents(this.onChatEngagementClick.bind(this), this.onChatDisengagementClick.bind(this)); } }; this.onButtonReady = function() { this.toggleButton(true); if (this.isMobile()) { document.querySelector(selectors.viewportMeta).setAttribute('content', 'width=device-width,initial-scale=1.0,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no'); } this.sendLpcUrl(); if (!this.getIsWcpConsentAvailable()) { this.initializeLpIframe(); } this.logFinishedStep("Received buttonReady message"); }; this.onButtonNotReady = function() { this.toggleButton(false); }; this.onClose = function() { let closeButton = document.querySelector(selectors.iframeCloseButton); closeButton.click(); this.getInnerContainer().setAttribute(selectors.ariaHiddenAttrName, true); isOpened = false; this.setLpcUrlSent(false); }; this.onFailed = function(message) { console.error(message); }; this.onChatEngagementClick = function() { this.sendInviteAcceptedMessage(); this.getChatButton().dispatchEvent(new Event('click')); this.getProactiveChat().toggle(false); }; this.sendInviteAcceptedMessage = function() { if (!isOpened) { this.sendIFrameMessage({ invite: 'accepted' }); isOpened = true; } }; this.onChatDisengagementClick = function() { this.getProactiveChat().toggle(false); this.sendIFrameMessage({ invite: 'declined' }); }; this.initializeLpIframe = function() { let iframe = this.getIframe(); if (!iframe.dataset.islpinitialized) { this.sendIFrameMessage({ action: 'initializeLP' }); iframe.dataset.islpinitialized = true; } }; this.openChatIFrame = function () { let iframeInnerContainer = this.getInnerContainer(); iframeInnerContainer.setAttribute(selectors.ariaHiddenAttrName, 'false'); if(this.getIsWcpConsentAvailable()){ this.sendLpcUrl(); this.initializeLpIframe(); } this.setLpcUrlSent(true); this.sendOpenMessage(); this.sendTopicNameMessages(); this.sendParentSizeMessages(); }; this.openChatIFrameByEnter = function (e){ if(e.keyCode == 13){ this.openChatIFrame(); } } this.disposeIframe = function () { let iframe = this.getIframe(); if (iframe) { iframe.remove(); } }; this.sendOpenMessage = function() { if (!isOpened) { this.sendIFrameMessage({ action: 'open' }); isOpened = true; } }; this.sendIFrameMessage = function(message) { this.logIFrameMessages(true, message); this.getIframe().contentWindow.postMessage(message, this.getTargetDomain()); }; this.sendParentSizeMessagesInMobileCanvasOnly = function() { if (this.isMobile()) { this.sendParentSizeMessages(); } }; this.togglePrimaryChatButton = function (isShown) { let utils = this.getUtils(); (new utils.throttledCallback({ callback: function (intervalHandle) { let chatLi = document.querySelector(selectors.multiFlyoutButton); if (chatLi) { let chatButton = chatLi.querySelector('button'); let chatGlyph = chatLi.querySelector(selectors.multiFlyoutButtonGlyph); if (chatGlyph) { if (isShown) { chatLi.style.removeProperty('display'); chatButton.style.removeProperty('display'); chatGlyph.setAttribute('aria-hidden', 'false'); } else { chatLi.setAttribute('style', 'display: none !important;'); chatButton.setAttribute('style', 'display: none !important;'); chatGlyph.setAttribute('aria-hidden', 'true'); } clearInterval(intervalHandle); } } }.bind(this) })).run(); }; this.toggleSecondaryChatButton = function(isShown) { let secondaryChatButtons = this.getSecondaryChatLinks(); for (let i = 0, len = secondaryChatButtons.length; i < len; i++) { let secondaryChatButton = secondaryChatButtons[i]; if (isShown) { secondaryChatButton.style.removeProperty('display'); } else { secondaryChatButton.setAttribute('style', 'display: none !important;'); } } }; this.toggleSideRailChatButton = function(isShown) { let sideRailButton = document.querySelector("[data-oc-chat-siderail]"); if (sideRailButton) { if (isShown) { sideRailButton.style.removeProperty('display'); } else { sideRailButton.setAttribute('style', 'display: none !important;'); } } }; this.toggleButton = function (isShown) { this.togglePrimaryChatButton(isShown); this.toggleSecondaryChatButton(isShown); this.toggleSideRailChatButton(isShown); }; this.sendPageName = function(pageName) { if (!wasSendPageSent) { this.sendIFrameMessage({ lppagename: pageName }); wasSendPageSent = true; } }; this.wasLpcUrlSent = function() { let ret = false; if (wasLpcUrlSent) { ret = true; } else { let wasChatOpenPrev = localStorage.getItem(chatDialogOpenedPrevKey); if (wasChatOpenPrev && typeof wasChatOpenPrev === 'string' && wasChatOpenPrev.toLowerCase() === 'true') { ret = true; } } return ret; }; this.setLpcUrlSent = function(wasSent) { if (wasSent) { wasLpcUrlSent = true; localStorage.setItem(chatDialogOpenedPrevKey, true); } else { wasLpcUrlSent = false; localStorage.setItem(chatDialogOpenedPrevKey, false); } }; this.sendLpcUrl = function () { if (!this.wasLpcUrlSent()) { this.sendIFrameMessage({ lpcurl: location.href }); // Commented out to prevent cookie from loading on site. // this.sendPageName(location.href); this.logFinishedStep("Sent LPCUrl"); wasLpcUrlSent = true; } }; this.isTelemetryGlobalDefined = function () { return typeof telemetry !== "undefined" && typeof telemetry.webAnalyticsPlugin !== "undefined"; }; this.isAwaGlobalDefined = function () { return typeof awa !== "undefined"; }; this.recordThatChatInviteDisplayed = function () { let analytics = false; if (this.isTelemetryGlobalDefined()) { analytics = telemetry.webAnalyticsPlugin; } else if (this.isAwaGlobalDefined()) { analytics = awa.ct; } if (analytics) { this.logIFrameMessages(true, "Sent telemetry for opening chat invite"); analytics.capturePageAction(null, { behavior: 14, actionType: "A", contentTags: { containerName: "ChatInvite" } }); } }; this.onReady = function() { this.sendLpcUrl(); this.logFinishedStep("Received ready message"); }; this.onDisplayed = function () { this.logFinishedStep("Received displayed message"); if (!this.isExcludeProactive()) { this.recordThatChatInviteDisplayed(); this.getProactiveChat().toggle(true); } }; this.isTelemetryRecordingEnabled = function() { return this.getTelemetryChatAn() && this.getTelemetryChatId(); }; this.receiveMessage = function(event) { if (this.isChatMessage(event)) { let message = this.getChatMessage(event); this.logIFrameMessages(false, message); switch (message) { case 'ready': this.onReady(); break; case 'maximized': case 'loading': case 'minimized': this.onStatusChange(event.data.height, event.data.width); break; case 'opened': this.onOpened(true); break; case 'displayed': this.onDisplayed(); break; case 'buttonReady': this.onButtonReady(); break; case 'buttonNotReady': this.onButtonNotReady(); break; case 'closed': this.onClose(); break; case 'failed': this.onFailed(event.data.msg); break; } if (this.isTelemetryRecordingEnabled()) { this.processTelemetryMessage(message); } } }; this.processTelemetryMessage = function(message) { let telemetryMapping = this.getTelemetryMappings()[message]; if (telemetryMapping && telemetryMapping.length === 2) { this.fireOneDs(telemetryMapping[0], telemetryMapping[1]); } }; this.isOneDsAnalyticsLoaded = function() { return window.oneDsAnalytics && window.oneDsAnalytics.capturePageAction; }; /** * Fire a custom page action event in 1DS analytics * @param {number} behavior Numeric identifier that represents a behavior * @param {string} id Identifier within the DOM */ this.fireOneDs = function(behavior, id) { let content = {}; if (this.isOneDsAnalyticsLoaded()) { content.chtid = this.getTelemetryChatId(); content.chtnm = this.isExcludeProactive() ? 'live person chat' : 'live person proactive chat'; content.an = this.getTelemetryChatAn(); if (id) { content.id = id; } window.oneDsAnalytics.capturePageAction(null, { behavior: behavior, content: content }); } }; this.sendParentSizeMessages = function() { // is needed mainly for mobile browsers so that LP can adjust its size based on the parent window dimensions. this.sendIFrameMessage({ action: 'parentsize', Width: window.innerWidth, Height: window.innerHeight, PixelRatio: 1 }); this.setDebugInfo("Parent Size", `Width: ${window.innerWidth} Height: ${window.innerHeight}`); }; this.sendTopicNameMessages = function() { if (!wasTopicSent) { this.sendIFrameMessage({ action: 'Topic', Topic: this.getTopicName() }); this.setDebugInfo("LP Topic", this.getTopicName()); wasTopicSent = true; } }; this.sendDomParentReadyMessageWhenReady = function() { if (!this.isPageDoneLoading()) { document.addEventListener("DOMContentLoaded", this.sendDomParentReadyMessage.bind(this)); } else { this.sendDomParentReadyMessage(); } } this.addChatIframeToPage = function() { if (this.getLlcc() === this.getMarket() && !this.isMobile()) { let outerContainer = this.getOuterContainer(); let innerContainer = this.getInnerContainer(); this.toggleButton(false); outerContainer.append(innerContainer); innerContainer.append(this.getCloseButton(), this.getIframe()); document.body.append(outerContainer); this.logFinishedStep("Append iFrame"); this.bindEvents(); this.sendDomParentReadyMessageWhenReady(); } }; this.debugProactiveChatInvite = function () { if (!this.isExcludeProactive()) { this.getProactiveChat().toggle(true); } }; this.shouldCheckForAgentAvailability = function() { let ret = false; if (typeof opts.checkForAgentAvailability === 'string') { ret = opts.checkForAgentAvailability.toLowerCase() === 'true'; } else { ret = opts.checkForAgentAvailability; } return ret; }; this.getAgentAvailabilityUrl = function() { return opts.agentAvailabilityUrl; }; this.getAgentSkillId = function() { return opts.agentSkillId; }; this.includedGeoLocatedCountries = function() { return opts.geoIncludedMarkets; }; this.isAgentAvailableViaApi = async function() { let ret = false; let agentResp = await agentReq.json(); if (agentResp.availability && typeof agentResp.availability === 'string' && agentResp.availability.toLowerCase() === 'yes') { ret = true; } return ret; }; this.getGeoLocatedCountry = function() { return opts.geoLocatedCountry; }; this.initialize = function() { if (this.shouldCheckForAgentAvailability()) { this.isAgentAvailableViaApi().then(areAgentsAvailable => { if (areAgentsAvailable) { this.addChatIframeToPage(); } }); } else { this.addChatIframeToPage(); } this.setDebugInfo("Checking for Agent Availability", this.shouldCheckForAgentAvailability()); }; if (this.isGeoExclusionDisabled()) { this.setDebugInfo("GeoExcluded?", "false"); this.setDebugInfo("GeoExcluded Enabled?", "false"); this.initialize(); } else { this.setDebugInfo("GeoExcluded Enabled?", "true"); this.setDebugInfo("GeoInclude Countries", opts.geoIncludedMarkets); let isExcluded = this.getUtils().isGeoExcluded(this.getLlcc(), this.getGeoLocatedCountry(), this.includedGeoLocatedCountries()); if (!isExcluded) { this.setDebugInfo("GeoExcluded?", "false"); this.initialize(); } else { this.setDebugInfo("GeoExcluded?", "true"); this.toggleButton(false); } } }; window.chat.proactive = function (opts) { let selectors = { proactiveChatDialogId: "proactive-chat-dialog", chatEngagementId: "#chatEngagement", chatDisengagementId: "#chatDisengagement", hiddenClass: "proactive-chat-hidden" }; let proactiveChatDialog = false; this.getUtils = function() { return window.chat.Utils; }; this.isDebug = function() { return opts.isDebug; }; this.getHandleBarSrc = function() { return opts.handleBarsSrc; }; this.getTemplateMarkup = function() { return opts.templateMarkup; }; this.getContent = function() { return opts.content; }; this.getDebugDialog = function() { return opts.debugDialog; }; this.isGeoExclusionDisabled = function() { return !opts.geoExclusion; }; this.getLlcc = function() { return opts.llcc; }; this.getGeoLocatedCountry = function() { return opts.geoLocatedCountry; }; this.getProactiveInvite = async function() { let ret = false; if (!proactiveChatDialog) { if(typeof Handlebars !== 'undefined' && Handlebars.compile) { ret = this.buildAndAppendProactiveChatDialog(Handlebars.compile(this.getTemplateMarkup())); } else { let proactiveChatTemplate = await this.loadHandleBarTemplate(); ret = this.buildAndAppendProactiveChatDialog(proactiveChatTemplate); } proactiveChatDialog = ret; } else { ret = proactiveChatDialog; } return ret; }; this.buildAndAppendProactiveChatDialog = function(proactiveChatTemplate) { let proactiveChatDialogAndStyle = document.createRange().createContextualFragment(proactiveChatTemplate(this.getContent())); document.body.append(proactiveChatDialogAndStyle); return document.getElementById(selectors.proactiveChatDialogId); }; this.loadHandleBarTemplate = function() { return new Promise(resolve => { let handleBarScript = document.createElement("script"); handleBarScript.setAttribute('src', this.getHandleBarSrc()); handleBarScript.addEventListener('load', () => { require(["handlebars"], Handlebars => { let debugDialog = this.getDebugDialog(); if (this.isDebug() && debugDialog) { debugDialog.finishedStep("Load Handlebars Dependency"); } resolve(Handlebars.compile(this.getTemplateMarkup())); }); }); document.body.append(handleBarScript); }); }; this.getGeoLocatedCountry = function() { return opts.geoLocatedCountry; }; this.includedGeoLocatedCountries = function() { return opts.geoIncludedMarkets; }; this.initialize = async function () { if (this.isGeoExclusionDisabled()) { document.body.append(await this.getProactiveInvite()); } else { if (!this.getUtils().isGeoExcluded(this.getLlcc(), this.getGeoLocatedCountry(), this.includedGeoLocatedCountries())) { document.body.append(await this.getProactiveInvite()); } } }; this.bindEvents = async function (onChatEngagementClick, onChatDisengagementClick) { let proactiveChatDialog = await this.getProactiveInvite(); let chatEngagementButton = proactiveChatDialog.querySelector(selectors.chatEngagementId); let chatDisengagementButton = proactiveChatDialog.querySelector(selectors.chatDisengagementId); chatEngagementButton.addEventListener('click', function () { onChatEngagementClick(proactiveChatDialog); }.bind(this)); chatDisengagementButton.addEventListener('click', function () { onChatDisengagementClick(proactiveChatDialog); }.bind(this)); }; this.toggle = async function (show) { let proactiveChatDialog = await this.getProactiveInvite(); if (show) { proactiveChatDialog.classList.remove(selectors.hiddenClass); proactiveChatDialog.setAttribute('aria-hidden', 'false'); } else { proactiveChatDialog.classList.add(selectors.hiddenClass); proactiveChatDialog.setAttribute('aria-hidden', 'true'); } }; }; window.chat.debugDialog = function (opts) { let dialog = false; let stages = {}; let info = {}; let messageTextbox = false; let closeLink = false; let header = false; const headerLevel = "h2"; const subHeaderLevel = "h3"; this.chatVNextDebugHeaderExpandControl = function(itemOpts){ let expandControl = false; let isHidden = true; this.getExpandControl = function() { let ret = false; if (expandControl) { ret = expandControl; } else { ret = document.createElement('span'); ret.innerText = "+"; ret.style.float = "right"; ret.style.marginTop = "3px"; expandControl = ret; } return ret; }; this.getChildContainer = function() { return itemOpts.childContainer; }; this.getHeaderLevel = function() { return itemOpts.headerLevel; }; this.getHeaderText = function() { return itemOpts.text; } this.onClick = function() { this.getChildContainer().style.display = isHidden ? 'block' : 'none'; this.getExpandControl().innerText = isHidden ? '-' : '+'; isHidden = !isHidden; } this.toElementNode = function() { let headerContainer = document.createElement('div'); let header = document.createElement(this.getHeaderLevel()); let expandControl = this.getExpandControl(); header.innerText = this.getHeaderText(); header.style.display = "inline-block"; header.style.width = "50%"; headerContainer.addEventListener('click', this.onClick.bind(this)); headerContainer.append(header, expandControl); return headerContainer; }; }; this.chatVNextDebugStepInfo = function(itemOpts) { let container = false; let span = false; let checkbox = false; this.getContainer = function() { let ret = false; if (container) { ret = container; } else { ret = document.createElement('div'); ret.style.display = "flex"; ret.style.flexDirection = "row"; ret.style.flexWrap = "wrap"; ret.style.padding = "7px"; ret.style.border = "1px solid black"; container = ret; } return ret; }; this.setElementAsColumn = function(elem, flex) { elem.style.display = "flex"; elem.style.flex = flex; elem.style.flexDirection = "column"; elem.style.appearance = "revert"; }; this.getSpan = function() { let ret = false; if (span) { ret = span; } else { ret = document.createElement('span'); ret.innerText = itemOpts.stepTitle; this.setElementAsColumn(ret, "2"); span = ret; } return ret; }; this.getCheckbox = function() { let ret = false; if (checkbox) { ret = checkbox; } else { ret = document.createElement('input'); ret.setAttribute('type', 'checkbox'); ret.setAttribute('disabled', true); this.setElementAsColumn(ret, "1"); checkbox = ret; } return ret; }; this.setToCompleted = function () { this.getCheckbox().setAttribute('checked', true); }; this.initialize = function () { this.getContainer().append(this.getSpan(), this.getCheckbox()); }; this.toElementNode = function () { return this.getContainer(); }; }; this.chatVNextDebugInfo = function(itemOpts) { let container = false; let nameSpan = false; let valueSpan = false; this.getContainer = function() { let ret = false; if (container) { ret = container; } else { ret = document.createElement('div'); ret.style.display = "flex"; ret.style.flexDirection = "row"; ret.style.flexWrap = "wrap"; ret.style.padding = "7px"; ret.style.border = "1px solid black"; container = ret; } return ret; }; this.setElementAsColumn = function(elem, flex) { elem.style.display = "flex"; elem.style.flex = flex; elem.style.flexDirection = "column"; elem.style.appearance = "revert"; }; this.getNameSpan = function() { let ret = false; if (nameSpan) { ret = nameSpan; } else { ret = document.createElement('span'); this.setElementAsColumn(ret, "2"); ret.innerText = itemOpts.name; nameSpan = ret; } return ret; }; this.getValueSpan = function() { let ret = false; if (valueSpan) { ret = valueSpan; } else { ret = document.createElement('span'); this.setElementAsColumn(ret, "1"); valueSpan = ret; } return ret; }; this.setValue = function (value) { this.getValueSpan().innerText = value; }; this.initialize = function () { this.getContainer().append(this.getNameSpan(), this.getValueSpan()); }; this.toElementNode = function () { return this.getContainer(); }; }; this.getCloseLinx = function() { let ret = false; if (closeLink) { ret = closeLink; } else { ret = document.createElement('a'); ret.setAttribute('href', '#'); ret.innerText = "x"; ret.style.display = "block"; ret.style.position = "absolute"; ret.style.top = "0"; ret.style.right = "7px"; ret.style.cursor = "pointer"; closeLink = ret; } return ret; }; this.getDialog = function() { let ret = false; if (dialog) { ret = dialog; } else { ret = document.createElement('dialog'); ret.style.position = 'fixed'; ret.style.display = "flex"; ret.style.flexDirection = "column"; ret.style.top = "0"; ret.style.left = "0"; ret.style.right = "auto"; ret.style.zIndex = "3000002"; ret.style.width = "300px"; ret.style.height = "100vh"; ret.style.overflow = "scroll"; ret.setAttribute('open', true); dialog = ret; } return ret; }; this.getMessageTextbox = function() { let ret = false; if (messageTextbox) { ret = messageTextbox; } else { ret = document.createElement('textarea'); ret.style.width = "100%"; messageTextbox = ret; } return ret; }; this.getMessageTextboxHeader = function(childContainer) { return new this.chatVNextDebugHeaderExpandControl({ text: "iFrame Message Logs", headerLevel: subHeaderLevel, childContainer: childContainer }).toElementNode(); }; this.initializeSteps = function() { let container = document.createElement('div'); let dialog = this.getDialog(); let header = new this.chatVNextDebugHeaderExpandControl({ text: "Completed steps", headerLevel: subHeaderLevel, childContainer: container }).toElementNode(); stages = { "Load Configuration": new this.chatVNextDebugStepInfo({ stepTitle: 'Load Configuration', debugDialog: dialog }), "Load Proactive Invite Content": new this.chatVNextDebugStepInfo({ stepTitle: 'Load Proactive Invite Content', debugDialog: dialog }), "Load Proactive Invite Template": new this.chatVNextDebugStepInfo({ stepTitle: 'Load Proactive Invite Template', debugDialog: dialog }), "Load Handlebars Dependency": new this.chatVNextDebugStepInfo({ stepTitle: 'Load Handlebars Dependency', debugDialog: dialog }), "Append iFrame": new this.chatVNextDebugStepInfo({ stepTitle: 'Appended iFrame', debugDialog: dialog }), "Attach iFrame and Button events": new this.chatVNextDebugStepInfo({ stepTitle: "Attached iFrame and Button events", debugDialog: dialog }), "Attach window events": new this.chatVNextDebugStepInfo({ stepTitle: "Attached window events", debugDialog: dialog }), "Received buttonReady message": new this.chatVNextDebugStepInfo({ stepTitle: "Received buttonReady message", debugDialog: dialog }), "Sent LPCUrl": new this.chatVNextDebugStepInfo({stepTitle: "Sent LPCUrl", debugDialog: dialog}), "Received ready message": new this.chatVNextDebugStepInfo({stepTitle: "Received ready message", debugDialog: dialog}), "Received displayed message": new this.chatVNextDebugStepInfo({ stepTitle: "Received displayed message", debugDialog: dialog }), "Received agent availability": new this.chatVNextDebugStepInfo({ stepTitle: "Received agent availability", debugDialog: dialog }) }; container.style.display = "none"; dialog.append(header, container); this.initAndAppend(stages, container); }; this.initAndAppend = function(chatVNextObjs, container) { for (const name in chatVNextObjs) { if (Object.hasOwnProperty.call(chatVNextObjs, name)) { const chatVNextObj = chatVNextObjs[name]; chatVNextObj.initialize(); container.append(chatVNextObj.toElementNode()); } } }; this.initializeInfo = function() { let dialog = this.getDialog(); let container = document.createElement('div'); let header = new this.chatVNextDebugHeaderExpandControl({ text: "LP Info", headerLevel: subHeaderLevel, childContainer: container }).toElementNode(); info = { "LP Site ID": new this.chatVNextDebugInfo({ name: "LP Site ID", debugDialog: dialog }), "LP Section ID": new this.chatVNextDebugInfo({ name: "LP Section ID", debugDialog: dialog }), "LP Topic": new this.chatVNextDebugInfo({ name: "LP Topic", debugDialog: dialog }), "Parent Size": new this.chatVNextDebugInfo({ name: "Parent Size", debugDialog: dialog }), "Checking for Agent Availability": new this.chatVNextDebugInfo({ name: "Checking for Agent Availability", debugDialog: dialog}), "Agent Skill Id": new this.chatVNextDebugInfo({ name: "Agent Skill Id", debugDialog: dialog}), "Agent Api Url": new this.chatVNextDebugInfo({ name: "Agent Api Url", debugDialog: dialog}), "GeoExcluded?": new this.chatVNextDebugInfo({ name: "GeoExcluded?", debugDialog: dialog}), "GeoExcluded Enabled?": new this.chatVNextDebugInfo({ name: "GeoExcluded Enabled?", debugDialog: dialog}), "GeoInclude Countries": new this.chatVNextDebugInfo({ name: "GeoInclude Countries", debugDialog: dialog}) }; container.style.display = 'none'; dialog.append(header, container); this.initAndAppend(info, container); }; this.initializeMessageLog = function() { let messageContainer = document.createElement('div'); messageContainer.append(this.getMessageTextbox()); messageContainer.style.display = "none"; this.getDialog().append(this.getMessageTextboxHeader(messageContainer), messageContainer); }; this.onClose = function() { this.getDialog().remove(); }; this.getTitle = function() { let ret = false; if (header) { ret = header; } else { ret = document.createElement(headerLevel); ret.innerText = opts.debugTitleText; header = ret; } return ret; }; this.initialize = function () { let d = this.getDialog(); let cLink = this.getCloseLinx(); d.append(this.getTitle(), cLink); this.initializeSteps(); this.initializeInfo(); this.initializeMessageLog(); cLink.addEventListener('click', this.onClose.bind(this)); document.body.append(d); }; this.appendMessage = function (message) { let textbox = this.getMessageTextbox(); textbox.value = `${textbox.value}\r\n${message}`; }; this.finishedStep = function (stepName) { stages[stepName].setToCompleted(); }; this.setDebugInfo = function (infoName, value) { info[infoName].setValue(value); }; }; window.chat.config = function (opts) { const selectors = { chatTypeMetaTag: "meta[name='ow.chatType']", chatGeoLocMetaTag: "meta[name='chat-oc-geo']", contactUsList: '.ow-contactsale-list', chatButtonSelector: '[data-oc-chat], [data-ow-chat]' }; let llcc = false; let proactiveChatDialog = false; let debugDialog = false; let marketOverride = false; let siteType = false; let prevChatConfig = false; let configAdapter = false; let geoExclusion = false; let isChatDisabled = opts.isChatDisabled; this.getConfigAdapter = function(){ let ret = false; if (configAdapter) { ret = configAdapter; } else { ret = new window.chat.adapters.aem({ proactiveChat: opts.proactiveChat, proactiveInvite: opts.proactiveInvite, chatConfigFileName: opts.chatConfigFileName, isIntEnv: this.isIntEnv(), logDebugMessage: this.logDebugMessage.bind(this), llcc: this.getLlcc(), siteType: this.getSiteType() }); configAdapter = ret; } return ret; }; this.getDebugDialog = function() { let ret = false; if (debugDialog) { ret = debugDialog; } else { ret = new window.chat.debugDialog({ debugTitleText: "LP Chat Debug Info" }); debugDialog = ret; debugDialog.initialize(); } return ret; }; this.getLlcc = function() { let ret = null; if (llcc) { ret = llcc; } else { if (typeof document.URL.GetLocale === 'function') { ret = document.URL.GetLocale(); } else { ret = document.getElementsByTagName('html')[0].getAttribute('lang'); } if (this.isMarketQspPresent()) { ret = this.getLlccFromMarketQsp(ret); } llcc = ret.toLocaleLowerCase(); } return ret; }; this.isIntEnv = function() { return (new window.URLSearchParams(window.location.search)).get("debug") === "1" || opts.debugHostNames.indexOf(document.location.hostname) !== -1; }; this.isDebug = function () { let params = new URLSearchParams(window.location.search); let ret = false; if (params && params.get("debugLpChat")) { ret = true; } return ret; }; this.getMarketQsp = function() { let ret = false; if (marketOverride) { ret = marketOverride; } else { ret = (new window.URLSearchParams(window.location.search)).get("market"); marketOverride = ret; } return ret; }; this.isMarketQspPresent = function() { let market = this.getMarketQsp(); return typeof market === 'string' && market.length !== 0; }; this.getLlccFromMarketQsp = function(llcc) { return llcc.split('-')[0] + "-" + this.getMarketQsp(); }; this.getAkamaiEndpoint = function(){ let prefix = this.isDebug() || this.isIntEnv() ? "wwwqa" : "www"; return `https://${prefix}.microsoft.com/aemapi/akamaiApi.akamaiEdgeScape.json`; } this.isNullOrWhiteSpace = function (str) { return str === undefined || str === null || typeof str !== 'string' || str.match(/^ *$/) !== null; } this.getUtils = function() { return window.chat.Utils; }; this.getChatTypeFromMeta = function() { let ret = false; let chatTypeMetaTag = document.querySelector(selectors.chatTypeMetaTag); if (chatTypeMetaTag) { ret = chatTypeMetaTag.getAttribute("content"); } return ret; }; this.getSiteTypeFromQueryString = function() { let params = new URLSearchParams(window.location.search); let ret = false; if (params && params.get("debugLpChatSiteType")) { ret = params.get("debugLpChatSiteType"); } return ret; }; this.getSiteType = function() { let ret = false; let debugSiteType = this.getSiteTypeFromQueryString(); if (debugSiteType) { ret = debugSiteType; } else if (siteType) { ret = siteType; } else { ret = opts.siteType ? opts.siteType : this.getChatTypeFromMeta(); if (typeof ret === "string") { ret = ret.toLocaleLowerCase(); } siteType = ret; } return ret; }; this.getIsProactiveChatDisabled = async function() { let ret = false; if (opts.disableProactiveChat) { if (typeof opts.disableProactiveChat === 'string') { ret = opts.disableProactiveChat.toLocaleLowerCase() === 'true'; } else if (typeof opts.disableProactiveChat === 'boolean') { ret = opts.disableProactiveChat; } } if (!ret && !(await this.getConfigAdapter().isProactiveTemplateAvailable())) { ret = true; } return ret; }; this.logStepAsDone = function(stepName) { try { if (this.isDebug()) { let debugDialog = this.getDebugDialog(); debugDialog.finishedStep(stepName); } } catch (error) { console.log("Error in trying to log debugging info: ", error); } }; this.isUpdateMarketEvent = function(eventDetails) { return eventDetails.eventName === 'update-market'; }; this.wasDynamicModuleUpdated = function(modulesRefreshed, moduleName) { for (const element of modulesRefreshed) { if (element.toLocaleLowerCase().indexOf(moduleName) !== -1) { return true; } } return false; }; this.loadProactiveChat = async function (geoIncludedMarkets) { let configAdapter = this.getConfigAdapter(); let proactiveContentObj = await configAdapter.getProactiveContentObj(); this.logStepAsDone("Load Proactive Invite Template"); if (proactiveContentObj) { proactiveChatDialog = new window.chat.proactive({ templateMarkup: await configAdapter.getTemplateText(), content: proactiveContentObj, debugDialog: (this.isDebug()) ? this.getDebugDialog() : false, isDebug: this.isDebug() || this.isIntEnv(), geoExclusion: geoExclusion, geoLocatedCountry: opts.geoLocatedCountry, geoIncludedMarkets: geoIncludedMarkets, llcc: this.getLlcc() }); proactiveChatDialog.initialize(); this.logStepAsDone("Load Proactive Invite Content"); } }; this.initializeChat = async function(chatConfigObj) { if (chatConfigObj.geoExclusion) { geoExclusion = true; } if (!await this.getIsProactiveChatDisabled()) { await this.loadProactiveChat(chatConfigObj.geoIncludedMarkets); } if (chatConfigObj.sectionId) { chatConfigObj.sectionId = chatConfigObj.sectionId.format(this.getLlcc()); } else if (chatConfigObj.isDebug) { this.getDebugDialog().appendMessage("⚠️ WARNING: section id is missing from configuration. May cause further issues."); } chatConfigObj.proactiveChatDialog = proactiveChatDialog; chatConfigObj.chatType = this.getSiteType(); chatConfigObj.llcc = this.getLlcc(); chatConfigObj.isDebug = this.isDebug(); chatConfigObj.geoLocatedCountry = opts.geoLocatedCountry; chatConfigObj.chatDialogDescription = opts.chatDialogDescription; if (chatConfigObj.isDebug) { chatConfigObj.debugDialog = this.getDebugDialog(); } window.chatInst = new window.chat.main(chatConfigObj); prevChatConfig = chatConfigObj; this.logStepAsDone("Load Configuration"); }; this.logDebugMessage = function(message) { if (this.isDebug()) { this.getDebugDialog().appendMessage(message); } if (this.isIntEnv()) { console.log(message); } }; this.initialize = async function () { if (this.getSiteType() && isChatDisabled !== "true") { this.initializeChat(await this.getConfigAdapter().getChatConfiguration()); } else { document.querySelectorAll(selectors.chatButtonSelector).forEach(elem => elem.style.display = "none"); } }; }; (new window.chat.config( JSON.parse( document.querySelector("meta[name='chat-oc-opts']").getAttribute("value") ) )).initialize(); (function(){ let targetWidget = document.getElementById('oc-contact-sales'); let headers = ['universalheader','azure-header']; let targetPosition; function moveChatWidget (){ targetPosition[0].parentNode.insertBefore(targetWidget, targetPosition[0].nextSibling); } for (const element of headers){ targetPosition = document.getElementsByClassName(element); if (targetPosition.length )break; } if( targetPosition.length && targetWidget) moveChatWidget(); })();