1import{d as i,u as h,t as l}from"./timezone.BFeNnjAo.js";import{f as c}from"./flatpickr.B_JH6AFf.js";import"./dayjs.BDSE_uUf.js";i.extend(h);i.extend(l);const n=10,d=100,D=o=>({allEvents:[],visibleCount:n,loading:!0,error:null,search:"",startDate:"",endDate:"",datePicker:null,debounceTimer:null,init(){const e=new URLSearchParams(window.location.search);this.search=e.get("search")||"",this.startDate=e.get("start")||"",this.endDate=e.get("end")||"";const r=[this.startDate,this.endDate].filter(Boolean).map(a=>i(a).toDate()),t=a=>a?i(a).format("YYYY-MM-DD"):"",s=this.datePicker=c(this.$refs.dateRangeInput,{mode:"range",dateFormat:"m/d/Y",allowInput:!0,disableMobile:!0,defaultDate:r.length?r:null,onClose:a=>{if(a.length===1){s.setDate([a[0],a[0]],!1),this.startDate=t(a[0]),this.endDate=t(a[0]);return}this.startDate=t(a[0]),this.endDate=t(a[1])}});this.fetchEvents(),this.$watch("search",()=>{this.updateUrl(),this.debouncedFetch()}),this.$watch("startDate",()=>{this.updateUrl(),this.debouncedFetch()}),this.$watch("endDate",()=>{this.updateUrl(),this.resetVisibleCount()})},updateUrl(){const e=new URLSearchParams;this.search&&e.set("search",this.search),this.startDate&&e.set("start",this.startDate),this.endDate&&e.set("end",this.endDate);const r=e.toString(),t=r?`${window.location.pathname}?${r}`:window.location.pathname;window.history.replaceState({},"",t)},debouncedFetch(){clearTimeout(this.debounceTimer),this.debounceTimer=setTimeout(()=>{this.visibleCount=n,this.fetchEvents()},300)},get filteredEvents(){let e=this.allEvents;if(this.endDate){const r=i(this.endDate).endOf("day");e=e.filter(t=>i(t.startDateTime).isBefore(r)||i(t.startDateTime).isSame(r,"day"))}return e},get displayedEvents(){return this.filteredEvents.slice(0,this.visibleCount)},get hasMore(){return this.visibleCount<this.filteredEvents.length},loadMore(){this.visibleCount+=n},resetVisibleCount(){this.visibleCount=n},clearFilters(){var e;this.search="",this.startDate="",this.endDate="",(e=this.datePicker)==null||e.clear()},formatDate(e,r){const t=i(e),s=i(r);return t.isSame(s,"day")?t.format("MMMM D, YYYY"):t.isSame(s,"month")&&t.isSame(s,"year")?`${t.format("MMMM D")}â${s.format("D, YYYY")}`:t.isSame(s,"year")?`${t.format("MMMM D")}â${s.format("MMMM D, YYYY")}`:`${t.format("MMMM D, YYYY")}â${s.format("MMMM D, YYYY")}`},formatTime(e){return i(e).format("h:mm A")},formatTimeRange(e,r,t){if(t)return"";const s=i(e).format("h:mm A"),a=i(r).format("h:mm A");return s===a?s:`${s} to ${a}`},async fetchEvents(){this.loading=!0,this.error=null;const e=this.startDate?i(this.startDate).format("YYYYMMDD"):i().tz("America/New_York").format("YYYYMMDD"),r=`https://template.aws.emory.edu/shared-assets/feed/trumba.php?calendar=${encodeURIComponent(o)}&events=${d}&previousweeks=0&startdate=${e}&search=${encodeURIComponent(this.search)}`;try{const t=await fetch(r);if(!t.ok)throw new Error(`HTTP error: ${t.status}`);const s=await t.json();this.allEvents=Array.isArray(s)?s:[]}catch(t){this.error=t.message,console.error("Failed to fetch events:",t),this.allEvents=[]}finally{this.loading=!1}}});export{D as default};
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.