1document.addEventListener("alpine:init",()=>{window.Alpine.data("calendarTimePicker",()=>({currentDate:new Date,selectedDate:new Date,selectedTime:null,scheduleAt:"",minDate:new Date(new Date().setHours(0,0,0,0)),maxDate:new Date(new Date().setDate(new Date().getDate()+2)),holidays:[new Date(2026,0,1),new Date(2026,11,25),new Date(2026,10,26)],init:function(){this.selectedDate=this.getFirstAvailableDate(),this.currentDate=new Date(this.selectedDate),this.renderCalendar(),this.attachEventListeners(),this.regenerateTimeSlots(),this.updateTimeSlots(),this.updateDisplay(),window.Alpine.effect(()=>{this.$store.form.response?.needsCallTime&&window.Alpine.nextTick(()=>{this.scrollToCurrentTime()})})},renderCalendar(){const e=this.currentDate.getFullYear(),s=this.currentDate.getMonth(),t=document.querySelector(".current-month");t&&(t.textContent=new Date(e,s).toLocaleDateString("en-US",{month:"long",year:"numeric"}));const n=new Date(e,s,1).getDay(),a=new Date(e,s+1,0).getDate(),i=new Date(e,s,0).getDate(),o=document.querySelector(".calendar-grid");if(!o)return;o.innerHTML="";for(let c=n-1;c>=0;c--){const d=i-c,u=new Date(e,s-1,d),m=this.createDayButton(d,!0,u);o.appendChild(m)}for(let c=1;c<=a;c++){const d=new Date(e,s,c),u=this.createDayButton(c,!1,d);o.appendChild(u)}const r=42-o.children.length;for(let c=1;c<=r;c++){const d=new Date(e,s+1,c),u=this.createDayButton(c,!0,d);o.appendChild(u)}},createDayButton(e,s,t){const n=document.createElement("button");if(n.type="button",n.textContent=e.toString(),n.className=`calendar-day ac:cursor-pointer ac:p-2 ac:rounded-full ac:text-sm ac:font-medium ac:transition-all ac:duration-200 ${s?"ac:text-gray-300 ac:hover:bg-gray-50":"ac:text-gray-700 ac:hover:bg-gray-100"}`,t){const a=new Date;a.setHours(0,0,0,0),t.setHours(0,0,0,0);const i=t<a,o=this.isHoliday(t),l=this.hasAvailableTimeSlots(t);t.getTime()===a.getTime()&&n.classList.add("today"),t<this.minDate||t>this.maxDate?(n.classList.add("disabled"),n.disabled=!0):i?(n.classList.add("past"),n.disabled=!0):o?(n.classList.add("disabled","holiday"),n.disabled=!0,n.title="Holiday - Unavailable"):l?s||n.addEventListener("click",()=>this.selectDate(t,n)):(n.classList.add("disabled"),n.disabled=!0,n.title="Unavailable"),this.selectedDate&&t.getTime()===this.selectedDate.getTime()&&n.classList.add("selected")}return n},isHoliday(e){return this.holidays.some(s=>{const t=new Date(s);t.setHours(0,0,0,0);const n=new Date(e);return n.setHours(0,0,0,0),t.getTime()===n.getTime()})},getBusinessHours(e){const s=new Date(e.getFullYear(),e.getMonth(),e.getDate(),0,0,0,0),t=new Date(e.getFullYear(),e.getMonth(),e.getDate()+1,0,0,0,0),n=this.getTimeZoneDateParts(new Date(e.getFullYear(),e.getMonth(),e.getDate(),12,0,0,0),"America/Los_Angeles");return[-1,0,1].map(a=>this.shiftDateParts(n,a)).map(({year:a,month:i,day:o})=>({start:this.createDateInTimeZone(a,i,o,5,0,"America/Los_Angeles"),end:this.createDateInTimeZone(a,i,o,20,0,"America/Los_Angeles")})).filter(({start:a,end:i})=>a<t&&i>s)},getSlotStartTimes(e){const s=this.getBusinessHours(e),t=new Date(e.getFullYear(),e.getMonth(),e.getDate(),0,0,0,0),n=new Date(e.getFullYear(),e.getMonth(),e.getDate()+1,0,0,0,0),a=30;return s.flatMap(({start:i,end:o})=>{const l=[];let r=new Date(i);for(;r<o;){const c=new Date(r.getTime()+a*60*1e3);if(c>o)break;r>=t&&r<n&&l.push(new Date(r)),r=c}return l}).sort((i,o)=>i.getTime()-o.getTime())},hasAvailableTimeSlots(e){const s=this.getSlotStartTimes(e);if(s.length===0)return!1;const t=new Date;t.setHours(0,0,0,0);const n=new Date(e);if(n.setHours(0,0,0,0),n.getTime()!==t.getTime())return!0;const a=Date.now();return s.some(i=>i.getTime()>a)},getFirstAvailableDate(){const e=new Date(this.minDate);e.setHours(0,0,0,0);const s=new Date(this.maxDate);s.setHours(0,0,0,0);for(const t=new Date(e);t<=s;t.setDate(t.getDate()+1))if(!this.isHoliday(t)&&this.hasAvailableTimeSlots(t))return new Date(t);return e},regenerateTimeSlots(){if(!this.selectedDate)return;const e=document.querySelector(".time-slots-container"),s=document.getElementById("mobile-time-slots");if(!e)return;if(e.innerHTML="",s){s.innerHTML="";const a=document.createElement("option");a.value="",a.textContent="Select a time",s.appendChild(a)}const t=30;
1this.getSlotStartTimes(this.selectedDate).forEach(a=>{const i=new Date(a.getTime()+t*60*1e3),o=this.formatLocalTime(a),l=`${o} - ${this.formatLocalTime(i)}`,r=document.createElement("button");if(r.type="button",r.className="time-slot ac:cursor-pointer ac:w-full ac:px-4 ac:py-2 ac:md:py-3 ac:text-sm ac:text-left ac:border ac:border-gray-200 ac:rounded-lg ac:hover:border-blue-500 ac:hover:bg-blue-50 ac:transition-all ac:duration-200 ac:text-gray-700 ac:font-medium",r.dataset.time=o,r.textContent=l,r.addEventListener("click",c=>{this.selectTime(c.currentTarget)}),e.appendChild(r),s){const c=document.createElement("option");c.value=o,c.textContent=l,s.appendChild(c)}}),s&&(s.disabled=s.options.length<=1)},getTimeZoneDateParts(e,s){const t=new Intl.DateTimeFormat("en-CA",{timeZone:s,year:"numeric",month:"2-digit",day:"2-digit"}).formatToParts(e);return{year:Number(t.find(n=>n.type==="year")?.value),month:Number(t.find(n=>n.type==="month")?.value),day:Number(t.find(n=>n.type==="day")?.value)}},shiftDateParts(e,s){const t=new Date(Date.UTC(e.year,e.month-1,e.day+s));return{year:t.getUTCFullYear(),month:t.getUTCMonth()+1,day:t.getUTCDate()}},createDateInTimeZone(e,s,t,n,a,i){const o=new Date(Date.UTC(e,s-1,t,n,a,0,0)),l=this.getTimeZoneOffsetMinutes(o,i);return new Date(o.getTime()-l*60*1e3)},getTimeZoneOffsetMinutes(e,s){const t=new Intl.DateTimeFormat("en-US",{timeZone:s,timeZoneName:"shortOffset"}).formatToParts(e).find(r=>r.type==="timeZoneName")?.value;if(!t||t==="GMT"||t==="UTC")return 0;const n=t.match(/^GMT([+-])(\d{1,2})(?::?(\d{2}))?$/);if(!n)return 0;const[,a,i,o]=n,l=Number(i)*60+Number(o||0);return a==="-"?-l:l},updateTimeSlots(){const e=document.querySelectorAll(".time-slot"),s=document.getElementById("mobile-time-slots"),t=new Date;t.setHours(0,0,0,0);const n=this.selectedDate&&this.selectedDate.getFullYear()===t.getFullYear()&&this.selectedDate.getMonth()===t.getMonth()&&this.selectedDate.getDate()===t.getDate();if(e.forEach(a=>{const i=a,o=i.dataset.time,l=s?.querySelector(`option[value="${o}"]`);o&&(n&&this.isTimePast(o)?(i.disabled=!0,l&&(l.disabled=!0),i.classList.add("ac:opacity-40","ac:cursor-not-allowed","ac:hover:bg-transparent","ac:hover:border-gray-200"),i.classList.remove("ac:hover:border-blue-500","ac:hover:bg-blue-50")):(i.disabled=!1,l&&(l.disabled=!1),i.classList.remove("ac:opacity-40","ac:cursor-not-allowed","ac:hover:bg-transparent"),i.classList.add("ac:hover:border-blue-500","ac:hover:bg-blue-50")))}),s){const a=Array.from(s.options).some((i,o)=>o>0&&!i.disabled);s.disabled=!a}},isTimePast(e){const s=new Date,[t,n]=e.split(" "),[a,i]=t.split(":").map(Number);let o=a;n==="PM"&&a!==12?o=a+12:n==="AM"&&a===12&&(o=0);const l=s.getHours(),r=s.getMinutes();return o<l||o===l&&i<=r},scrollToCurrentTime(){const e=new Date,s=e.getHours(),t=e.getMinutes(),n=document.querySelectorAll(".time-slot");let a=null;for(const i of n){const l=i.dataset.time;if(!l)continue;const[r,c]=l.split(" "),[d,u]=r.split(":").map(Number);let m=d;if(c==="PM"&&d!==12?m=d+12:c==="AM"&&d===12&&(m=0),m>s||m===s&&u>t){a=i;break}}if(a){const i=document.querySelector(".time-slots-container");if(i){const o=i.getBoundingClientRect().top,r=a.getBoundingClientRect().top-o-20;i.scrollTop=i.scrollTop+r}}},selectDate(e,s){this.selectedDate=e,this.selectedTime=null,document.querySelectorAll(".calendar-day").forEach(t=>{t.classList.remove("selected")}),s.classList.add("selected"),this.regenerateTimeSlots(),this.updateTimeSlots(),this.updateDisplay(),this.dispatchSelectionChange(),document.querySelector(".timepicker-section")?.scrollIntoView({behavior:"smooth",block:"start"})},attachEventListeners(){const e=document.querySelector(".prev-month"),s=document.querySelector(".next-month"),t=document.getElementById("mobile-time-slots");e?.addEventListener("click",()=>{this.currentDate.setMonth(this.currentDate.getMonth()-1),this.renderCalendar()}),s?.addEventListener("click",()=>{this.currentDate.setMonth(this.currentDate.getMonth()+1),this.renderCalendar()}),document.querySelectorAll(".time-slot").forEach(n=>{n.addEventListener("click",a=>{const i=a.currentTarget;this.selectTime(i)})}),t?.addEventListener("change",n=>{const a=n.currentTarget;this.selectTimeValue(a.value||null)})},selectTime(e){e.disabled||this.selectTimeValue(e.dataset.time||null,e)},selectTimeValue(e,s){this.selectedTime=e,document.querySelectorAll(".time-slot").forEach(n=>
1{n.classList.remove("selected")});const t=s||document.querySelector(`.time-slot[data-time="${e}"]`);t&&t.classList.add("selected"),this.updateDisplay(),this.dispatchSelectionChange()},updateDisplay(){const e=document.querySelector(".selected-date-text"),s=document.querySelector(".selected-time-text"),t=document.querySelector(".selected-full-text"),n=document.querySelector(".submit-btn"),a=document.getElementById("time-picker-title");a&&this.selectedDate?a.textContent=this.selectedDate.toLocaleDateString("en-US",{weekday:"long",month:"long",day:"numeric"}):a&&(a.textContent="Select Time");const i=document.getElementById("selected-date"),o=document.getElementById("selected-time"),l=document.getElementById("scheduleAt"),r=document.getElementById("mobile-time-slots"),c=this.getSelectedDateTime();i&&this.selectedDate&&(i.value=this.formatLocalDate(this.selectedDate)),o&&(o.value=this.selectedTime||""),l&&c?(this.scheduleAt=this.formatLocalDateTime(c),l.value=this.scheduleAt):l&&(this.scheduleAt="",l.value=""),r&&(r.value=this.selectedTime||""),n&&(n.disabled=!(this.selectedDate&&this.selectedTime)),e&&(e.textContent=this.selectedDate?this.selectedDate.toLocaleDateString("en-US",{weekday:"long",year:"numeric",month:"long",day:"numeric"}):"No date selected"),s&&(s.textContent=this.selectedTime||"No time selected"),t&&(this.selectedDate&&this.selectedTime?(t.textContent=`${this.selectedDate.toLocaleDateString("en-US",{month:"long",day:"numeric",year:"numeric"})} at ${this.selectedTime}`,t.classList.remove("ac:text-blue-700"),t.classList.add("ac:text-green-700")):(t.textContent="Please select a date and time",t.classList.remove("ac:text-green-700"),t.classList.add("ac:text-blue-700")))},dispatchSelectionChange(){if(this.selectedDate&&this.selectedTime){const e=this.getSelectedDateTime(),s=new CustomEvent("datetime-selected",{detail:{date:this.selectedDate,time:this.selectedTime,datetime:e?this.formatLocalDateTime(e):""}});document.querySelector(".calendar-timepicker")?.dispatchEvent(s)}},getSelectedDateTime(){if(!this.selectedDate||!this.selectedTime)return null;const[e,s]=this.selectedTime.split(" ");if(!e||!s)return null;const[t,n]=e.split(":").map(Number);if(Number.isNaN(t)||Number.isNaN(n))return null;let a=t;return s==="PM"&&t!==12?a=t+12:s==="AM"&&t===12&&(a=0),new Date(this.selectedDate.getFullYear(),this.selectedDate.getMonth(),this.selectedDate.getDate(),a,n,0,0)},formatLocalDate(e){const s=e.getFullYear(),t=String(e.getMonth()+1).padStart(2,"0"),n=String(e.getDate()).padStart(2,"0");return`${s}-${t}-${n}`},formatLocalDateTime(e){const s=e.getFullYear(),t=String(e.getMonth()+1).padStart(2,"0"),n=String(e.getDate()).padStart(2,"0"),a=String(e.getHours()).padStart(2,"0"),i=String(e.getMinutes()).padStart(2,"0"),o=String(e.getSeconds()).padStart(2,"0");return`${s}-${t}-${n} ${a}:${i}:${o}`},formatLocalTime(e){return e.toLocaleTimeString("en-US",{hour:"numeric",minute:"2-digit"})}}))});
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.