"use strict";

function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }

function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }

function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }

function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }

var Instruments =
/*#__PURE__*/
function () {
  function Instruments() {
    var _this = this;

    _classCallCheck(this, Instruments);

    this._iOSDevice = !!navigator.platform.match(/iPhone|iPod|iPad/);
    this.activeData = {};
    this.formsFieldsRecords = {};
    this.loggedin = false; //console.log(dayStringArray)

    console.log('Browser Instruments Loaded', getMentorId(), this.daysTotal); //console.log('Browser Instruments Loaded',getMentor())

    this.mentorDetails = getMentor();
    this.mentorId = getMentorId(); //this.getModal(this.mentorDetails,dayStringArray)

    this.bookNowClicks = [];
    this.randomFinanceFacts = ["It costs more money to make pennies and nickels than they're actually worth!", "Coins stay in circulation for about 30 years before they get melted down and repurposed", "Two separate agencies create coins and paper money!", "Congress creates \u201Ccoin programs\u201D to encourage families to collect coins", "Nickels weren\u2019t always made of nickel"];
    this.db = firebase.firestore();
    this.userTimezone = moment.tz.guess();
    console.log(this.userTimezone);
    this.db.collection('Booking Sets').doc(getMentor().MentorUserRef).get().then(function (doc) {
      if (doc.exists) {
        _this.bookingSet = doc.data();

        if (document.getElementById('timezone-view')) {
          document.getElementById('timezone-view').innerHTML = '<p>' + ' Converted To->' + _this.userTimezone + '</p>';
        }
      } else {
        _this.bookingSet = false;
      }
    });
    var offset = new Date().getTimezoneOffset();
    this.timezoneOffsetUser = offset;
    this.timezoneUser = Intl.DateTimeFormat().resolvedOptions().timeZone;
    firebase.auth().onAuthStateChanged(function (user) {
      if (user) {
        _this.displayName = user.displayName;
        _this.loggedin = true;
      } else {}
    });
  }

  _createClass(Instruments, [{
    key: "getBase64",
    value: function getBase64(file) {
      var reader = new FileReader();
      reader.readAsDataURL(file);

      reader.onload = function () {
        instruments.formsFieldsRecords.CVFILE = reader.result;
      };

      reader.onerror = function (error) {
        console.log('Error: ', error);
      };
    }
  }, {
    key: "getModal",
    value: function getModal(data, dayStringArray) {
      var dayString = '';
      dayStringArray.map(function (ele) {
        dayString = dayString + ele;
      });
      var monthsArray = ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December'];
      this.modal = "<div class=\"modal fade\" id=\"wizard-modal1\" tabindex=\"-1\" aria-labelledby=\"exampleModalLabel\" aria-hidden=\"true\">\n        <div class=\"modal-dialog modal-dialog-centered\">\n            <div class=\"modal-content\">\n                <!-- <button type=\"button\" class=\"btn-close\" data-bs-dismiss=\"modal\" aria-label=\"Close\"></button> -->\n                <div class=\"modal-body\">\n                    <div class=\"form-wizard\">\n                        <form action=\"\" method=\"post\" role=\"form\">\n                            <div class=\"form-wizard-header\">\n                                <ul class=\"form-wizard-steps\">\n                                    <li class=\"active\">\n                                        <span>1</span>\n                                        Book Slot\n                                    </li>\n                                    <li>\n                                        <span>2</span>\n                                        Details\n                                    </li>\n                                </ul>\n                            </div>\n\n                            <fieldset class=\"wizard-fieldset show\">\n                                <div class=\"wizard-block\">\n                                    <h2>Book 1:1 call with ".concat(data.MentorFName, " ").concat(data.MentorLName, "</h2>\n\n                                    <div class=\"calendar-block\" id=\"calendar-block\">\n                                        <div class=\"form-group\">\n                                            <select class=\"form-control\" onchange='displayDays()' id=\"month-selector\">\n                                            ").concat(monthsArray.slice(new Date().getMonth(), monthsArray.length).map(function (ele) {
        return "<option value=\"".concat(new Date().getMonth(), "\">").concat(ele, ", ").concat(new Date().getFullYear(), "</option>");
      }).join(" "), "\n                                               \n                                            </select>\n\n                                            \n                                        </div>\n\n                                        <div class=\"slider multiple-items\" id=\"multiple-items\">\n                                           ").concat(dayString, "\n                                        </div>\n\n                                    <div class=\"time-block\">\n                                        <h2>Select Your Preferred Time</h2>\n\n                                        <ul>\n                                            <li>\n                                                <div>\n                                                    <h3>09:00 AM</h3>\n                                                    <input type=\"radio\" id=\"time1\" name=\"radio-group2\" />\n                                                </div>\n                                            </li>\n                                            <li>\n                                                <div>\n                                                    <h3>10:00 AM</h3>\n                                                    <input type=\"radio\" id=\"time2\" name=\"radio-group2\" />\n                                                </div>\n                                            </li>\n                                            <li>\n                                                <div>\n                                                    <h3>11:00 AM</h3>\n                                                    <input type=\"radio\" id=\"time3\" name=\"radio-group2\" />\n                                                </div>\n                                            </li>\n                                            <li class=\"selected\">\n                                                <div>\n                                                    <h3>12:00 AM</h3>\n                                                    <input type=\"radio\" id=\"time4\" name=\"radio-group2\" />\n                                                </div>\n                                            </li>\n                                            <li>\n                                                <div>\n                                                    <h3>01:00 AM</h3>\n                                                    <input type=\"radio\" id=\"time5\" name=\"radio-group2\" />\n                                                </div>\n                                            </li>\n                                            <li>\n                                                <div>\n                                                    <h3>02:00 AM</h3>\n                                                    <input type=\"radio\" id=\"time6\" name=\"radio-group2\" />\n                                                </div>\n                                            </li>\n                                            <li>\n                                                <div>\n                                                    <h3>03:00 AM</h3>\n                                                    <input type=\"radio\" id=\"time7\" name=\"radio-group2\" />\n                                                </div>\n                                            </li>\n                                            <li>\n                                                <div>\n                                                    <h3>04:00 AM</h3>\n                                                    <input type=\"radio\" id=\"time8\" name=\"radio-group2\" />\n                                                </div>\n                                            </li>\n                                        </ul>\n                                    </div>\n                                </div>\n\n                                <div class=\"modal-footer\">\n                                    <div class=\"row\">\n                                        <div class=\"col-md-6 col-sm-12\">\n                                            <h6>You\u2019re saving \u20B92000 by booking your first mentor!</h6>\n                                            <h2>\u20B92000</h2>\n                                            <p>*Inclusive of all taxes</p>\n                                        </div>\n                                        <div class=\"col-md-6 col-sm-12\">\n                                            <ul>\n                                                <li><span>Time : 45 mins</span></li>\n                                                <li><a href=\"javascript:void(0);\" class=\"form-wizard-next-btn btn-main\">Next</a></li>\n                                            </ul>\n                                        </div>\n                                    </div>\n                                </div>\n                            </fieldset>\n                            <fieldset class=\"wizard-fieldset\">\n                                <div class=\"wizard-block\">\n                                    <h2>Book 1:1 call with John Doe</h2>\n\n                                    <div class=\"info-form\">\n                                        <div class=\"form-group\">\n                                            <label>Job Role*</label>\n                                            <input type=\"text\" class=\"form-control\" />\n                                        </div>\n                                        <div class=\"form-group\">\n                                            <label>Where are you currently working ?*</label>\n                                            <input type=\"text\" class=\"form-control\" />\n                                        </div>\n                                        <div class=\"form-group\">\n                                            <label>Goal*</label>\n                                            <input type=\"text\" class=\"form-control\" />\n                                        </div>\n                                        <div class=\"form-group\">\n                                            <label>How can we help?* </label>\n                                            <input type=\"text\" class=\"form-control\" />\n                                        </div>\n                                        <div class=\"upload-group\">\n                                            <img src=\"images/upload-icon.svg\" alt=\"\" />\n                                            Upload your CV\n                                            <input type=\"file\" class=\"form-control\" />\n                                        </div>\n                                    </div>\n                                </div>\n                                <div class=\"modal-footer\">\n                                    <div class=\"row\">\n                                        <div class=\"col-md-6 col-sm-12\">\n                                            <h6>You\u2019re saving \u20B92000 by booking your first mentor!</h6>\n                                            <h2>\u20B92000</h2>\n                                            <p>*Inclusive of all taxes</p>\n                                        </div>\n                                        <div class=\"col-md-6 col-sm-12\">\n                                            <ul>\n                                                <li><span>Time : 45 mins</span></li>\n                                                <li><a href=\"javascript:void(0);\" class=\"form-wizard-submit btn-main\">pay</a></li>\n                                            </ul>\n                                        </div>\n                                    </div>\n                                </div>\n                            </fieldset>\n                        </form>\n                    </div>\n                </div>\n            </div>\n        </div>\n        </div>");
      $("body").append(this.modal);
      this.sliderInit();
    }
  }, {
    key: "sliderInit",
    value: function sliderInit() {
      var _$$slick;

      $("#calendar-block #multiple-items").slick((_$$slick = {
        customPaging: function customPaging(slider, i) {
          console.log('Slider', slider);
          return i + 1 + '/' + slider.slideCount;
        },
        arrows: false,
        loop: true,
        dots: false,
        autoplay: true,
        infinite: true,
        slidesToShow: 6,
        slidesToScroll: 5,
        autoplaySpeed: 3000,
        speed: 1000
      }, _defineProperty(_$$slick, "autoplay", true), _defineProperty(_$$slick, "responsive", [{
        breakpoint: 1600,
        settings: {
          slidesToShow: 6,
          slidesToScroll: 5
        }
      }, {
        breakpoint: 1199,
        settings: {
          slidesToShow: 6,
          slidesToScroll: 5
        }
      }, {
        breakpoint: 991,
        settings: {
          slidesToShow: 5,
          slidesToScroll: 4
        }
      }, {
        breakpoint: 767,
        settings: {
          slidesToShow: 5,
          slidesToScroll: 4
        }
      }, {
        breakpoint: 575,
        settings: {
          slidesToShow: 4,
          slidesToScroll: 3
        }
      }, {
        breakpoint: 447,
        settings: {
          slidesToShow: 2,
          slidesToScroll: 1
        }
      }]), _$$slick));
    }
  }, {
    key: "fireModalTest",
    value: function fireModalTest() {
      // console.log('hh')
      $('#wizard-modal1').modal('show'); // firebase.auth().onAuthStateChanged((user) => {
      //     if (user) {
      //     } else {
      //       // User is signed out
      //       // ...
      //       window.location.href='./login'
      //     }
      //   });
    }
  }, {
    key: "getAuth",
    value: function getAuth() {
      var _this2 = this;

      var formAuth = ['Job Role', 'Currently Working Company', 'Goal', 'How Can We Help'];

      if (this.bookNowClicks[this.bookNowClicks.length - 1] == '') {
        return false;
      }

      var flag = true;
      formAuth.map(function (ele) {
        if (_this2.formsFieldsRecords[ele]) {
          if (_this2.formsFieldsRecords[ele] == '') {
            flag = false;
          }
        } else {
          flag = false;
        }
      });

      if (this.activeData['selectedDate']) {
        if (this.activeData['selectedDate'] == '') {
          flag = false;
        }
      } else {
        flag = false;
      }

      if (this.activeData['selectedTime']) {
        if (this.activeData['selectedTime'] == '') {
          flag = false;
        }
      } else {
        flag = false;
      }

      return flag;
    }
  }, {
    key: "payButtonAction",
    value: function payButtonAction() {
      var _this3 = this;

      //check
      var auth = this.getAuth(this.formsFieldsRecords);
      console.debug(this.formsFieldsRecords);
      console.debug(this.activeData);
      console.debug(auth);

      if (auth) {
        this.callAPI();
        var timerInterval;
        Swal.fire({
          title: 'Please Wait While We Resolve Your Order',
          html: 'Do You Know <b></b> .',
          timer: 20000,
          timerProgressBar: true,
          didOpen: function didOpen() {
            Swal.showLoading();
            var b = Swal.getHtmlContainer().querySelector('b');
            b.textContent = _this3.randomFinanceFacts[Math.floor(Math.random() * (_this3.randomFinanceFacts.length - 1 - 0 + 1)) + 0];
            timerInterval = setInterval(function () {
              var rand = Math.floor(Math.random() * (_this3.randomFinanceFacts.length - 1 - 0 + 1)) + 0;
              console.log(rand);
              b.textContent = _this3.randomFinanceFacts[rand]; //b.textContent = Swal.getTimerLeft()
            }, 5000);
          },
          willClose: function willClose() {
            clearInterval(timerInterval);
          }
        }).then(function (result) {
          /* Read more about handling dismissals below */
          if (result.dismiss === Swal.DismissReason.timer) {
            console.log('I was closed by the timer');
          }
        }); //this.callAPI()
      } else {}
    }
  }, {
    key: "callAPI",
    value: function callAPI() {
      var _this4 = this;

      firebase.auth().onAuthStateChanged(function (user) {
        if (user) {
          var settings = {
            "url": "https://api-financementorbox.web.app/hamiltonianfunctions/CREATE_ORDER_MENTOR?mentorId=".concat(getMentorId(), "&type=").concat(_this4.bookNowClicks[_this4.bookNowClicks.length - 1], "&userId=").concat(user.uid),
            "method": "GET",
            "timeout": 0,
            "headers": {
              "userId": user.uid,
              "Authorization": user.uid
            }
          };
          $.ajax(settings).done(function (response) {
            console.log(response); //error check

            instruments.callRazorpay(response);
          });
        } else {
          window.location.href = '../sign-in';
        }
      });
    }
  }, {
    key: "callRazorpay",
    value: function callRazorpay(response) {
      var db, options, rzp1;
      return regeneratorRuntime.async(function callRazorpay$(_context) {
        while (1) {
          switch (_context.prev = _context.next) {
            case 0:
              db = firebase.firestore();
              console.log(response);
              console.log(new URL(window.location.href).origin + "/paymentsuccess/");
              _context.next = 5;
              return regeneratorRuntime.awrap(db.collection('Order Entities').doc(response.id).set({
                cstDt: this.activeData,
                formDt: this.formsFieldsRecords
              }, {
                merge: true
              }));

            case 5:
              options = {
                key: "rzp_live_NZ0J06Kg2ssCLU",
                // Enter the Key ID generated from the Dashboard
                // Amount is in currency subunits. Default currency is INR. Hence, 50000 refers to 50000 paise
                currency: "USD",
                name: "Finance Mentor Box",
                description: 'CRM BOOKING',
                redirect: true,
                image: "/images/logo.svg",
                order_id: response.id,
                //This is a sample Order ID. Pass the `id` obtained in the response of Step 1
                callback_url: new URL(window.location.href).origin + "/paymentsuccess/",
                prefill: {
                  name: firebase.auth().currentUser.displayName ? firebase.auth().currentUser.displayName : '',
                  email: firebase.auth().currentUser.email,
                  contact: firebase.auth().currentUser.phoneNumber ? firebase.auth().currentUser.phoneNumber : ''
                },
                theme: {
                  color: "#3399cc"
                }
              };
              rzp1 = new Razorpay(options);
              rzp1.open();

            case 8:
            case "end":
              return _context.stop();
          }
        }
      }, null, this);
    }
  }, {
    key: "fireModal",
    value: function fireModal(ele) {
      console.log(ele.id);
      this.bookNowClicks.push(ele.id);
      var price = this.mentorDetails[ele.id];
      console.log(price);
      document.getElementById('price-modal').innerHTML = "$".concat(price);
      document.getElementById('price-modal2').innerHTML = "$".concat(price);
    }
  }, {
    key: "getUser",
    value: function getUser() {
      var user = firebase.auth().currentUser;
      firebase.auth().onAuthStateChanged(function (user) {
        if (user) {
          // User is signed in, see docs for a list of available properties
          // https://firebase.google.com/docs/reference/js/firebase.User
          var uid = user.uid;
          return uid;
        } else {
          window.location.href = '../sign-in';
        }
      });
    }
  }, {
    key: "showError",
    value: function showError() {
      Swal.fire({
        icon: 'error',
        title: 'Required Fields Missing',
        text: 'Please Choose the Date and Time',
        footer: ''
      });
    }
  }, {
    key: "loadOpportunityModal",
    value: function loadOpportunityModal(ele) {}
  }, {
    key: "getUserTimezone",
    value: function getUserTimezone() {}
  }, {
    key: "tConvert",
    value: function tConvert(time) {
      // Check correct time format and split into components
      time = time.toString().match(/^([01]\d|2[0-3])(:)([0-5]\d)(:[0-5]\d)?$/) || [time];

      if (time.length > 1) {
        // If time format correct
        time = time.slice(1); // Remove full string match value

        time[5] = +time[0] < 12 ? 'AM' : 'PM'; // Set AM/PM

        time[0] = +time[0] % 12 || 12; // Adjust hours
      }

      return time.join(''); // return adjusted time or original string
    }
  }, {
    key: "renderTimeSlots",
    value: function renderTimeSlots(timeSlots, date) {
      console.log(date);
      var str = "<li onclick=\"instruments.loadOpportunityModal(this)\" id=\"".concat(date, "\">\n                    <div>\n                        <h3>No Time Slots Found</h3><h3></h3>\n                        <input type=\"radio\" name=\"radio-group2\">\n                    </div>\n                </li>");
      var blockedFlag = false;
      var blockedDates = []; //For retro fitting

      if (!this.bookingSet.blockedDates) {
        this.bookingSet.blockedDates = [];
      }

      if (this.bookingSet.blockedDates) {
        blockedDates = this.bookingSet.blockedDates.map(function (ele) {
          if (new Date(ele).setHours(0, 0, 0, 0) == date.setHours(0, 0, 0, 0)) {
            blockedFlag = true;
          }

          return new Date(ele);
        });
      } else {
        blockedFlag = true;
      }

      var totalDays = this.bookingSet.bookingPeriod;
      var totalDaysGant = 1;

      if (totalDays) {
        var daysStr = totalDays.id.split('*').map(function (ele) {
          totalDaysGant = parseInt(ele) * totalDaysGant;
          return parseInt(ele);
        });
        var startPeriod = this.bookingSet.lastUpdated != null ? this.bookingSet.lastUpdated.toDate() : null;
        var endPeriod = new Date(startPeriod.setDate(startPeriod.getDate() + totalDaysGant));
        startPeriod = this.bookingSet.lastUpdated != null ? this.bookingSet.lastUpdated.toDate() : null;

        if (startPeriod) {
          if (date > startPeriod && date <= endPeriod) {} else {
            blockedFlag = true;
          }
        }
      } else {
        blockedFlag = true;
      }

      if (!this.bookingSet.bookedSet) {
        this.bookingSet.bookedSet = {};
      }

      console.log('Booking Set-->📅', this.bookingSet, 'Blocked Arr', blockedDates, 'Blocked Date Flag--->❌', blockedFlag, 'Total Extra Gant-->🧭', totalDaysGant, ''); //moment.tz.setDefault(this.bookingSet.timezone.FIELD2);

      if (!blockedFlag) {
        if (timeSlots) {
          str = '';

          for (var _i in timeSlots) {
            var formatteddate = void 0; //formatteddate-1

            formatteddate = date.getDate() > 9 ? date.getDate() : '0' + date.getDate(); // let startTimePeriod = moment(date.getFullYear()+'-'+(date.getMonth()+1)+'-'+ formatteddate+''+timeSlots[i].startBias, "YYYY-MM-DDHH:mma").tz(this.bookingSet.timezone.FIELD2)
            // let endTimePeriod = moment(date.getFullYear()+'-'+(date.getMonth()+1)+'-'+ formatteddate+''+timeSlots[i].endBias, "YYYY-MM-DDHH:mma").tz(this.bookingSet.timezone.FIELD2)
            // console.log('Converted End To->',this.bookingSet.timezone.FIELD2,new Date(moment.tz(endTimePeriod, this.bookingSet.timezone.FIELD2).utc().format()))

            var startTimePeriod = moment.tz(date.getFullYear() + '-' + (date.getMonth() + 1) + '-' + formatteddate + '' + timeSlots[_i].startBias, "YYYY-MM-DDHH:mma", this.bookingSet.timezone.FIELD2); //.toString().split(' '))//.format()))

            var endTimePeriod = moment.tz(date.getFullYear() + '-' + (date.getMonth() + 1) + '-' + formatteddate + '' + timeSlots[_i].endBias, "YYYY-MM-DDHH:mma", this.bookingSet.timezone.FIELD2); //.toString().split(' ')//.format()))
            //Converting to Locale

            var convertedStart = new Date(startTimePeriod).toTimeString().split(' ')[0];
            var convertedEnd = new Date(endTimePeriod).toTimeString().split(' ')[0];
            convertedStart = convertedStart.split(':')[0] + ":" + convertedStart.split(':')[1];
            convertedEnd = convertedEnd.split(':')[0] + ":" + convertedEnd.split(':')[1]; //console.log('Start Time Converted->',new Date(startTimePeriod).getDay()==date.getDate(),'End Time Converted ->',convertedEnd)

            if (new Date(startTimePeriod).getDay() == date.getDate()) {
              console.log('Chances of Error');
            }

            if (this.bookingSet.bookedSet) {
              if (this.bookingSet.bookedSet[_i]) {
                var flag_Booking = true;

                this.bookingSet.bookedSet[_i].map(function (ele) {
                  //console.log('ele.toDate()==',date==ele.toDate(),date,'ele date',ele.toDate())
                  if (ele.toDate().getTime() == date.getTime()) {
                    flag_Booking = false;
                  }
                });

                if (flag_Booking) {
                  //document.getElementById('upper-block').hidden=true
                  //document.getElementById('slider-item').hidden=true
                  str = str + "\n                                <li onclick=\"selectTime(this)\" id=\"".concat(_i + '$HAM$' + date + '$HAM$' + (timeSlots[_i].startBias + '-' + timeSlots[_i].endBias), "\">\n                                    <div>\n                                        <h3>").concat(convertedStart, " - ").concat(convertedEnd, "</h3>\n                                        <input type=\"radio\" name=\"radio-group2\">\n                                    </div>\n                                </li>");
                }
              } else {
                // document.getElementById('upper-block').hidden=true
                // document.getElementById('slider-item').hidden=true
                str = str + "\n                                <li onclick=\"selectTime(this)\" id=\"".concat(_i + '$HAM$' + date + '$HAM$' + (timeSlots[_i].startBias + '-' + timeSlots[_i].endBias), "\">\n                                    <div>\n                                        <h3>").concat(convertedStart, " - ").concat(convertedEnd, "</h3>\n                                        <input type=\"radio\" name=\"radio-group2\">\n                                    </div>\n                                </li>");
              }
            } else {
              // document.getElementById('upper-block').hidden=true
              // document.getElementById('slider-item').hidden=true
              str = str + "\n                        <li onclick=\"selectTime(this)\" id=\"".concat(_i + '$HAM$' + date + '$HAM$' + (timeSlots[_i].startBias + '-' + timeSlots[_i].endBias), "\">\n                            <div>\n                                <h3>").concat(convertedStart, " - ").concat(convertedEnd, "</h3>\n                                <input type=\"radio\" name=\"radio-group2\">\n                            </div>\n                        </li>");
            }
          }

          if (str == '') {
            str = " <li onclick=\"instruments.loadOpportunityModal(this)\" id=\"".concat(date, "\">\n                        <div>\n                            <h3>No Time Slots Found **published</h3><h3></h3>\n                            <input type=\"radio\" name=\"radio-group2\">\n                        </div>\n                    </li>");
          }
        } else {//console.log('No Slots Found')
        }
      } else {
        str = "<li onclick=\"instruments.loadOpportunityModal(this)\" id=\"".concat(date, "\">\n                    <div>\n                        <h3>Not Available on this Date</h3>\n                    </div>\n                </li>");
      }

      document.getElementById('time-components').innerHTML = str;
    }
  }, {
    key: "rearrangeSlick",
    value: function rearrangeSlick(setIndex, start, end) {
      for (var index = start; index < end; index++) {
        if (index != setIndex) {
          if (document.getElementById(index)) {
            document.getElementById(index).className = 'slider-box';
          }
        } else {
          if (document.getElementById(index)) {
            document.getElementById(index).className = 'slider-box selected';
          }
        }
      }
    }
  }, {
    key: "getUlList",
    value: function getUlList(itemId, setEle) {
      var lis = document.getElementById(itemId).getElementsByTagName('li');
      var idArray = [];

      for (var counter = 0; counter < lis.length; counter++) {
        idArray.push(lis[counter].id);
        document.getElementById(lis[counter].id).className = '';

        if (setEle == document.getElementById(lis[counter].id)) {
          document.getElementById(lis[counter].id).className = 'selected';
        }
      } //console.log(idArray)


      return idArray;
    }
  }, {
    key: "rearrangeTimeSlots",
    value: function rearrangeTimeSlots(setEle) {
      this.getUlList('time-components', setEle); // for (let index = start; index < end; index++) {
      //     if(index!=setIndex)
      //     {
      //         if(document.getElementById(index))
      //         {
      //             document.getElementById(index).className=''
      //         }
      //     }else{
      //         if(document.getElementById(index))
      //         {
      //             document.getElementById(index).className='selected'
      //         }
      //     }          
      // }
    }
  }]);

  return Instruments;
}();

var DEBUG = false;

if (!DEBUG) {
  if (!window.console) window.console = {};
  var methods = ["log", "debug", "warn", "info"];

  for (var i = 0; i < methods.length; i++) {
    console[methods[i]] = function () {};
  }
}

var instruments = new Instruments();
displayDays();

function converTimezone() {
  return regeneratorRuntime.async(function converTimezone$(_context2) {
    while (1) {
      switch (_context2.prev = _context2.next) {
        case 0:
        case "end":
          return _context2.stop();
      }
    }
  });
}

function displayDays() {
  _iOSDevice = !!navigator.platform.match(/iPhone|iPod|iPad/);
  var ele2 = document.getElementById("month-selector");
  var year = ele2.options[ele2.selectedIndex].text.split(' ')[1];
  var selectedMonth = ele2.value;
  selectedMonth = parseInt(selectedMonth) + 1;
  console.log(year); // console.log('SELECTIONS',selectedMonth,year,ele2.innerHTML)
  //$('.calendar-block .multiple-items').slick('slickAdd','<div><h3>' + slideIndex + '</h3></div>');

  var getDays = function getDays(year, month) {
    return new Date(year, month, 0).getDate();
  };

  this.daysTotal = getDays(year, parseInt(selectedMonth));
  var dayStringArray = [];
  var dayString = '';
  var weekdays = ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"];
  var startDate = ele2.value == new Date().getMonth() && year == new Date().getFullYear() ? new Date().getDate() : 1;
  selectedMonth = selectedMonth > 12 ? selectedMonth - 12 : selectedMonth;
  var totalSlickIndex = 0;
  console.log('Month', selectedMonth, 'Year', year, this.daysTotal, 'Start Date', startDate); //window.alert(new Date((parseInt(ele2.value)+1)+'-'+i+'-'+new Date().getFullYear()).getDay(),i)
  // window.alert(weekdays[new Date((parseInt(ele2.value)+1)+'-'+10+'-'+year).getDay()],10)

  for (var _i2 = startDate; _i2 <= this.daysTotal; _i2++) {
    var dateStr = parseInt(ele2.value) + 1 + '-' + _i2 + '-' + year + ' 00:00:00'; // if(_iOSDevice)
    //     {
    //     window.alert(moment(dateStr,'MM-DD-YYYY hh:mm:ss a').format('dddd a'))
    //     }
    // window.alert((parseInt(ele2.value)+1)+'-'+i+'-'+year);
    //console.log(moment((parseInt(ele2.value)+1)+'-'+i+'-'+new Date().getFullYear()).format('dddd'))

    totalSlickIndex = totalSlickIndex + 1;
    dayStringArray.push("<div class=\"slider-box\" onclick=\"selectDate(this)\" id=\"".concat(_i2, "\"><div><h3>").concat(_i2, "</h3><h6>").concat(weekdays[new Date(parseInt(ele2.value) + 1 + '-' + _i2 + '-' + new Date().getFullYear()).getDay()], "</h6><input type=\"radio\" id=\"calendar").concat(_i2, "\"  name=\"radio-group\" /></div></div>"));
    dayString = dayString + "<div><div class=\"slider-box\" onclick=\"selectDate(this)\" id=\"".concat(_i2, "\"><div><h3>").concat(_i2, "</h3><h6>").concat(moment(dateStr, 'MM-DD-YYYY hh:mm:ss a').format('dddd a').split(' ')[0], "</h6><input type=\"radio\" id=\"calendar").concat(_i2, "\" name=\"radio-group\" /></div></div></div>");
  }

  instruments.bookingDayOffsetCalendar = totalSlickIndex;
  instruments.startDayId = startDate;
  instruments.endDayId = this.daysTotal;
  var days = ['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday'];
  $('.calendar-block .multiple-items').slick('unslick');
  document.getElementById('slider-item').innerHTML = '';
  $('.calendar-block .multiple-items').slick('slickAdd', dayString, {
    arrows: false,
    loop: false,
    dots: false,
    autoplay: false,
    draggable: true,
    infinite: false,
    slidesToShow: 6,
    slidesToScroll: 5,
    autoplaySpeed: 3000,
    speed: 1000,
    responsive: [{
      breakpoint: 1600,
      settings: {
        slidesToShow: 6,
        slidesToScroll: 5
      }
    }, {
      breakpoint: 1199,
      settings: {
        slidesToShow: 6,
        slidesToScroll: 5
      }
    }, {
      breakpoint: 991,
      settings: {
        slidesToShow: 5,
        slidesToScroll: 4
      }
    }, {
      breakpoint: 767,
      settings: {
        slidesToShow: 5,
        slidesToScroll: 4
      }
    }, {
      breakpoint: 575,
      settings: {
        slidesToShow: 4,
        slidesToScroll: 3
      }
    }, {
      breakpoint: 447,
      settings: {
        slidesToShow: 2,
        slidesToScroll: 1
      }
    }]
  }); //$('.calendar-block .multiple-items').slick('slickAdd',dayString);
} // $('.slide').on('click', function() {
//     console.log('fr')
//     $('.calendar-block .multiple-items').slick('slickRemove', $('.slick-slide').index(this) - 1);
//   });


function selectDate(ele) {
  console.log(ele.id);
  instruments.rearrangeSlick(parseInt(ele.id), instruments.startDayId, instruments.endDayId);
  var ele2 = document.getElementById("month-selector");
  var year = ele2.options[ele2.selectedIndex].text.split(' ')[1]; //$('.calendar-block .multiple-items').slick('slickPause');
  //ele.className=ele.className+' selected'

  var weekdays = ["Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday"];
  instruments.activeData.selectMonth = ele2.value;
  instruments.activeData.selectedDate = ele.id;
  instruments.activeData.selectYear = year; //console.log(instruments.activeData.selectMonth,instruments.activeData.selectedDate,ele.id)

  var date = new Date(parseInt(ele2.value) + 1 + '-' + ele.id + '-' + new Date().getFullYear());
  var day = date.getDay();

  if (instruments.bookingSet) {
    var availability = instruments.bookingSet.availability;
    var availableSlots = availability[day];
    instruments.renderTimeSlots(availableSlots, date);
  } //$('.calendar-block .multiple-items').slick('slickAdd','<div><h3>' + slideIndex + '</h3></div>');
  // const getDays = (year, month) => new Date(year, month, 0).getDate()
  // this.daysTotal = getDays(new Date().getFullYear(), parseInt(ele2.value)+1)
  // let dayStringArray=[]
  // let dayString=''
  // let startDate=ele2.value==new Date().getMonth()?new Date().getDate():1  
  // for(let i=startDate;i<=this.daysTotal;i++)
  // {
  //    console.log(day,i)
  //     dayStringArray.push(`<div class="slider-box" onclick="selectDate(this)" id="${i}"><div><h3>${i}</h3><h6>${weekdays[new Date((parseInt(ele2.value)+1)+'-'+i+'-'+new Date().getFullYear()).getDay()]}</h6><input type="radio" id="calendar${i}"  name="radio-group" /></div></div>`)
  //     dayString=dayString+`<div><div class="slider-box" onclick="selectDate(this)" id="${i}"><div><h3>${i}</h3><h6>${weekdays[new Date((parseInt(ele2.value)+1)+'-'+i+'-'+new Date().getFullYear()).getDay()]}</h6><input type="radio" id="calendar${i}" name="radio-group" /></div></div></div>`
  //     if(day==i)
  //     {      
  //         console.log('here',i)      
  //         dayString=dayString+`<div><div class="slider-box selected" onclick="selectDate(this)" id="${i}"><div><h3>${i}</h3><h6>${weekdays[new Date((parseInt(ele2.value)+1)+'-'+i+'-'+new Date().getFullYear()).getDay()]}</h6><input type="radio" id="calendar${i}" name="radio-group" /></div></div></div>`
  //     }
  // }
  //$('.calendar-block .multiple-items').slick('unslick');
  //document.getElementById('upper-block').innerHTML=`<div><div class="slider-box selected" id="${ele.id}" onclick="selectDate(this)" ><div><h3>${ele.id}</h3><h6>${weekdays[new Date((parseInt(ele2.value)+1)+'-'+ele.id+'-'+new Date().getFullYear()).getDay()]}</h6><input type="radio" id="calendar${ele.id}" name="radio-group" /></div></div></div>`
  //$('.calendar-block .multiple-items').slick();

}

function selectTime(ele) {
  instruments.rearrangeTimeSlots(ele);
  instruments.activeData.selectedTime = ele.id;
  instruments.activeData.selectedTimeSlotDate = new Date(ele.id.split('$HAM$')[1]);
  var selectedDate = parseInt(instruments.activeData.selectedDate) > 9 ? parseInt(instruments.activeData.selectedDate) : '0' + parseInt(instruments.activeData.selectedDate);
  var selectMonth = parseInt(instruments.activeData.selectMonth) + 1 > 9 ? parseInt(instruments.activeData.selectMonth) + 1 : '0' + (parseInt(instruments.activeData.selectMonth) + 1);
  var selectYear = instruments.activeData.selectYear;
  var dateString = selectMonth + '-' + selectedDate + '-' + selectYear;
  var dateOb = new Date(dateString);
  var bookedSlotId = instruments.activeData.selectedTime.split('$HAM$')[0];
  var dayId = dateOb.getDay();
  var slotDetails = instruments.bookingSet.availability[dayId][bookedSlotId];
  var startTimePeriodMentor = moment.tz(dateOb.getFullYear() + '-' + selectMonth + '-' + selectedDate + '' + slotDetails.startBias, "YYYY-MM-DDHH:mma", instruments.bookingSet.timezone.FIELD2); //.toString().split(' '))//.format()))

  var endTimePeriodMentor = moment.tz(dateOb.getFullYear() + '-' + selectMonth + '-' + selectedDate + '' + slotDetails.endBias, "YYYY-MM-DDHH:mma", instruments.bookingSet.timezone.FIELD2); //.toString().split(' ')//.format()))

  var startTimePeriodMentee = new Date(startTimePeriodMentor).toTimeString();
  var endTimePeriodMentee = new Date(endTimePeriodMentor).toTimeString();
  var startTimePeriodMenteeTS = new Date(startTimePeriodMentor);
  var endTimePeriodMenteeTS = new Date(endTimePeriodMentor);
  instruments.activeData.startTimePeriodMentor = startTimePeriodMentor.format("MM/DD/YYYY HH:mm a");
  instruments.activeData.endTimePeriodMentor = endTimePeriodMentor.format("MM/DD/YYYY HH:mm a");
  instruments.activeData.startTimePeriodMentee = startTimePeriodMentee;
  instruments.activeData.endTimePeriodMentee = endTimePeriodMentee;
  instruments.activeData.startTimePeriodMenteeTS = startTimePeriodMenteeTS;
  instruments.activeData.endTimePeriodMenteeTS = endTimePeriodMenteeTS;
}

function recordFormItems(ele) {
  if (ele.type != 'file') {
    instruments.formsFieldsRecords[ele.id] = ele.value;
  } else {
    var file = ele.files[0];
    instruments.getBase64(file);
    console.log(file);
    document.getElementById('cv-img-src').innerHTML = " <label>Your CV is uploaded  ".concat(file.name, "</label><br>*donot refresh this window");
  }
}

$(document).ready(function () {
  $(document).ready(function () {
    if (window.location.href.indexOf('#CallRequest') != -1) {
      var dom = document.getElementById('MentorMentoringPrice');
      console.log(dom.click()); //$('#wizard-modal').modal('show');
    }
  });
});