var AtlasSpecialist=function(){var t=this;this.refs={},this.opts={appUrl:"https://app.atlashelp.net"},this.utils={ajaxCall:function(a,e,s){return jQuery.ajax({async:!0,dataType:"json",type:s||"POST",data:"object"==typeof e?JSON.stringify(e):e,url:t.opts.appUrl+"/public/call/"+a,contentType:"application/json; charset=utf-8"})},saveToLocalStorage:function(t,a){if("undefined"!=typeof localStorage)try{localStorage.setItem(t,JSON.stringify(a))}catch(t){console.log("No local storage")}},getFromLocalStorage:function(t){var a;try{a=localStorage.getItem(t)}catch(t){console.log("No local storage")}return a?JSON.parse(a):{}}},"0"!==atlasSpecialistOptions.chatEnable&&this.addAtlasSpecialistChat(),this.displaySpecialistCalendar()};AtlasSpecialist.prototype.addAtlasSpecialistChat=function(){var t,a,e,s,o=this,l=!1,i=jQuery(window).width();function n(){var t=jQuery(window).width();(l=t<801)&&!a?jQuery(document.body).addClass("atlas-chat-body-owr"):jQuery(document.body).removeClass("atlas-chat-body-owr")}l=i<801,a=o.utils.getFromLocalStorage("atlas-chat").collapsed||!!l,n(),jQuery(document.body).append('
\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t
');var r=jQuery("head").find('meta[name="viewport"]');r.length?r.attr("content","width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0"):jQuery("head").append(''),(t=jQuery("#atlas-specialist-chat")).hasClass("atlas-chat-collapsed")&&t.css("bottom","-"+(t.height()-(l?41:27))+"px"),t.find(".asc-header").on("click",function(){t.hasClass("atlas-chat-collapsed")?(t.removeClass("atlas-chat-collapsed"),t.css("bottom",""),t.find(".atlas-collapse-trigger").removeClass("atlas-icon-up-open").addClass("atlas-icon-down-open"),l&&jQuery(document.body).addClass("atlas-chat-body-owr"),a=!1):(t.addClass("atlas-chat-collapsed"),t.css("bottom","-"+(t.height()-(l?41:27))+"px"),t.find(".atlas-collapse-trigger").removeClass("atlas-icon-down-open").addClass("atlas-icon-up-open"),l&&jQuery(document.body).removeClass("atlas-chat-body-owr"),a=!0),o.utils.saveToLocalStorage("atlas-chat",{collapsed:a})}),e=t.width(),s=t.height(),window.addEventListener("message",function(a){if(a.origin===o.opts.appUrl&&a.data){if(jQuery(window).width()<801)return;"expand"===a.data?t.css({width:e+100,height:s+200}):t.css({width:e,height:s})}},!1),jQuery(window).on("resize",function(){n()}),setTimeout(function(){"body"!==t.parent()[0].nodeName.toLowerCase()&&jQuery(document.body).append(t)},2e3)},AtlasSpecialist.prototype.displaySpecialistCalendar=function(){var t=this,a=["January","February","March","April","May","June","July","August","September","October","November","December"],e=new Date,s=jQuery(".atlas-app-calendar");if(!s.length)return!1;t.utils.ajaxCall("getAllForProvider",{data:e.getFullYear()+" "+a[e.getMonth()],url:atlasSpecialistOptions.url}).done(function(e){if(e&&e.obj){function o(t){var a,e,s,o,l,i,n,r,c,d,p=[],u={};for(l=0;l9?c:"0"+c)+"-"+(d>9?d:"0"+d),s=a.getHours()+":"+(a.getMinutes()>9?a.getMinutes():"0"+a.getMinutes())+" - "+e.getHours()+":"+(e.getMinutes()>9?e.getMinutes():"0"+e.getMinutes()),u.hasOwnProperty(o)?u[o].title=u[o].title+" \n"+t.obj[l].title+" "+s:u[o]={date:o,badge:!0,title:t.obj[l].title+" "+s,classname:"atlas-appointment"};for(i in u)p.push(u[i]);return p}s.zabuto_calendar({language:atlasSpecialistOptions.locale,today:!0,data:o(e),action_nav:function(e,l){var i=jQuery(this).data(),n=i.to.year+" "+a[i.to.month-1];t.utils.ajaxCall("getAllForProvider",{data:n,url:atlasSpecialistOptions.url}).done(function(t){s.data("jsonData",o(t)).trigger("zabutoChangeData")})},action:function(){var a=jQuery("#"+this.id).data("hasEvent"),e=t.opts.appUrl+"/"+atlasSpecialistOptions.url;a&&window.open(e,"_blank")}})}})},jQuery(function(){new AtlasSpecialist});