@rolldate/mcp 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/AGENTS.md +27 -0
- package/LICENSE +21 -0
- package/README.md +84 -0
- package/bin/rolldate-mcp.js +2 -0
- package/package.json +52 -0
- package/src/catalog.js +284 -0
- package/src/index.js +358 -0
- package/templates/AGENTS.md +27 -0
- package/templates/rolldate-mcp.mdc +16 -0
- package/vendor/rolldate/rolldate.css +548 -0
- package/vendor/rolldate/rolldate.js +2429 -0
- package/vendor/rolldate/rolldate.min.css +1 -0
- package/vendor/rolldate/rolldate.min.js +1 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
.RollDate__container{display:flex;flex-direction:column;padding:6px 11px;width:360px;--rd-bg: #323232;--rd-border: #626262;--rd-text-primary: #e6e6e6;--rd-text-secondary: #848685;--rd-text-disabled: #515252;--rd-text-disabled-contrast: #a2a2a2;--rd-header-muted: #848685;--rd-weekday: #f7f7f7;--rd-hover-bg: #3e3e3e;--rd-hover-border: #686868;--rd-accent: #609ef1;--rd-accent-strong: #368cfd;--rd-accent-dark: #1e5093;--rd-accent-muted: #375985;--rd-button-icon: #fff;background:var(--rd-bg);border:1px solid var(--rd-border);box-sizing:border-box;font-family:"Segoe UI",Arial,sans-serif;overscroll-behavior:contain;border-radius:8px}.RollDate__container *{box-sizing:border-box}.RollDate__container.RollDate__theme_dark{--rd-bg: #323232;--rd-border: #626262;--rd-text-primary: #e6e6e6;--rd-text-secondary: #848685;--rd-text-disabled: #515252;--rd-text-disabled-contrast: #a2a2a2;--rd-header-muted: #848685;--rd-weekday: #f7f7f7;--rd-hover-bg: #3e3e3e;--rd-hover-border: #686868;--rd-accent: #609ef1;--rd-accent-strong: #368cfd;--rd-accent-dark: #1e5093;--rd-accent-muted: #375985;--rd-button-icon: #fff}.RollDate__container.RollDate__theme_light{--rd-bg: #ffffff;--rd-border: #d8dde6;--rd-text-primary: #1f2937;--rd-text-secondary: #5f6b7a;--rd-text-disabled: #a1aab8;--rd-text-disabled-contrast: #8c97a8;--rd-header-muted: #9aa3b2;--rd-weekday: #334155;--rd-hover-bg: #f3f6fb;--rd-hover-border: #ccd5e3;--rd-accent: #4f8ff7;--rd-accent-strong: #2d7cff;--rd-accent-dark: #1f5dc1;--rd-accent-muted: #d9e8ff;--rd-button-icon: #334155}.RollDate__container.RollDate__calendar__type--days .RollDate__calendar__header{display:flex}.RollDate__container.RollDate__calendar__type--days .RollDate__calendar__days{display:grid;transform:scale(1, 1);opacity:1;pointer-events:auto}.RollDate__container.RollDate__calendar__type--days .RollDate__header__month{display:inline-flex}.RollDate__container.RollDate__calendar__type--months .RollDate__calendar__months{display:grid;transform:scale(1, 1);opacity:1;pointer-events:auto}.RollDate__container.RollDate__calendar__type--years .RollDate__calendar__years{display:grid;transform:scale(1, 1);opacity:1;pointer-events:auto}.RollDate__container.RollDate__calendar__type--years .RollDate__calendar__switcher{color:var(--rd-header-muted);cursor:default}.RollDate__container.RollDate__calendar__type--years .RollDate__calendar__switcher:hover{background-color:rgba(0,0,0,0)}.RollDate__container.RollDate__calendar__type--years .RollDate__header__year,.RollDate__container.RollDate__calendar__type--years .RollDate__header__month{color:var(--rd-header-muted)}.RollDate__header{flex:0 0 auto;display:flex;align-items:center;margin-bottom:10px;height:36px}.RollDate__header__year,.RollDate__header__month{flex:0 0 auto;display:inline-flex;align-items:center;font-size:14px;font-weight:600;color:var(--rd-text-primary)}.RollDate__header__month{display:none;margin-left:4px}.RollDate__calendar{flex:1 0 auto;display:flex;flex-direction:column;height:283px}.RollDate__calendar__switcher{display:flex;padding:4px 12px;height:30px;cursor:pointer;border-radius:4px;transition:all .3s}.RollDate__calendar__switcher:hover{background:var(--rd-hover-bg)}.RollDate__calendar__header{display:none;flex:0 0 auto;grid-template-columns:repeat(7, 1fr);margin-bottom:8px;color:var(--rd-weekday)}.RollDate__calendar__header__weekday{display:flex;justify-content:center;align-items:center;width:100%;min-width:0;height:24px;font-size:12px}.RollDate__calendar__body{flex:1 0 0;overflow:hidden;touch-action:none}.RollDate__calendar__days{grid-template-columns:repeat(7, 1fr);gap:2px;opacity:0;pointer-events:none;transition:transform .3s,opacity .3s}.RollDate__calendar__months,.RollDate__calendar__years{grid-template-columns:repeat(4, 1fr);gap:4px;opacity:0;pointer-events:none;transition:transform .3s,opacity .3s}.RollDate__calendar__day{display:flex;align-items:center;justify-content:center;height:40px;font-size:14px;color:var(--rd-text-secondary);cursor:pointer;transition:all .3s;border-radius:4px;border:2px solid rgba(0,0,0,0)}.RollDate__calendar__day:hover{border-color:var(--rd-hover-border)}.RollDate__calendar__day--selected{border-color:var(--rd-accent-dark)}.RollDate__calendar__day--selected:hover{border-color:var(--rd-accent-strong)}.RollDate__calendar__day--range-first{border-color:var(--rd-accent-dark);border-right-color:rgba(0,0,0,0)}.RollDate__calendar__day--range-first:hover{border-color:var(--rd-accent-strong);border-right-color:rgba(0,0,0,0)}.RollDate__calendar__day--range-selected{border-color:var(--rd-accent-dark) rgba(0,0,0,0) var(--rd-accent-dark) rgba(0,0,0,0)}.RollDate__calendar__day--range-selected:hover{border-color:var(--rd-accent-strong) rgba(0,0,0,0) var(--rd-accent-strong) rgba(0,0,0,0)}.RollDate__calendar__day--range-last{border-color:var(--rd-accent-dark);border-left-color:rgba(0,0,0,0)}.RollDate__calendar__day--range-last:hover{border-color:var(--rd-accent-strong);border-left-color:rgba(0,0,0,0)}.RollDate__calendar__day--active{color:var(--rd-text-primary)}.RollDate__calendar__day--active.RollDate__calendar__day--disabled{color:var(--rd-text-disabled)}.RollDate__calendar__day--today{background:var(--rd-accent);color:#fff}.RollDate__calendar__day--today:hover{border-color:var(--rd-accent-strong);background:var(--rd-accent-strong)}.RollDate__calendar__day--disabled{color:var(--rd-text-disabled);cursor:default}.RollDate__calendar__day--disabled:hover{border-color:rgba(0,0,0,0)}.RollDate__calendar__day--disabled.RollDate__calendar__day--today{color:var(--rd-text-disabled-contrast);background:var(--rd-accent-muted)}.RollDate__calendar__month,.RollDate__calendar__year{display:flex;align-items:center;justify-content:center;height:67px;font-size:14px;color:var(--rd-text-secondary);cursor:pointer;transition:all .3s;border-radius:4px}.RollDate__calendar__month:hover,.RollDate__calendar__year:hover{border:2px solid var(--rd-hover-border)}.RollDate__calendar__month--active,.RollDate__calendar__year--active{color:var(--rd-text-primary)}.RollDate__calendar__month--current,.RollDate__calendar__year--current{background:var(--rd-accent);color:#fff}.RollDate__calendar__month--current:hover,.RollDate__calendar__year--current:hover{border:2px solid var(--rd-accent-strong);background:var(--rd-accent-strong)}.RollDate__calendar__month--disabled,.RollDate__calendar__year--disabled{color:var(--rd-text-disabled);cursor:default}.RollDate__calendar__month--disabled:hover,.RollDate__calendar__year--disabled:hover{border:none}.RollDate__calendar__month--disabled.RollDate__calendar__month--current{color:var(--rd-text-disabled-contrast);background:var(--rd-accent-muted)}.RollDate__calendar__year--disabled.RollDate__calendar__year--current{color:var(--rd-text-disabled-contrast);background:var(--rd-accent-muted)}.RollDate__calendar__buttons{display:flex;align-items:center;margin-left:auto}.RollDate__calendar__button{display:flex;align-items:center;justify-content:center;margin-left:2px;width:30px;height:30px;border-radius:4px;transition:background-color .3s;background:none;border:none;cursor:pointer}.RollDate__calendar__button:hover{background:var(--rd-hover-bg)}.RollDate__calendar__button svg{width:6px;height:5px;fill:var(--rd-button-icon)}.RollDate__calendar__button[data-direction=next]{transform:rotate(-180deg)}.RollDate__footer{flex:0 0 auto;margin-top:10px;padding-top:10px;border-top:1px solid var(--rd-border);display:flex;flex-direction:column;gap:10px}.RollDate__footer__buttons{display:flex;flex-wrap:wrap;gap:8px;justify-content:flex-end}.RollDate__footer__button{border:1px solid var(--rd-border);background:var(--rd-hover-bg);color:var(--rd-text-primary);border-radius:6px;padding:7px 12px;font-size:12px;font-weight:600;cursor:pointer;transition:background-color .2s,border-color .2s}.RollDate__footer__button:hover{border-color:var(--rd-accent);background:var(--rd-accent-muted)}.RollDate__time{display:flex;flex-direction:row;align-items:center;justify-content:center;gap:10px;padding:4px 0 2px;user-select:none}.RollDate__time__picker{display:flex;align-items:center;justify-content:center;gap:4px;flex:1 1 auto;min-width:0}.RollDate__time__display{flex:0 0 auto;font-size:17px;font-weight:700;font-variant-numeric:tabular-nums;color:var(--rd-text-primary);letter-spacing:.03em;line-height:1;padding:6px 10px;border-left:1px solid var(--rd-border);min-width:4.5em;text-align:center}.RollDate__time__field{flex:0 0 auto;width:auto}.RollDate__time__field--period .RollDate__time__viewport{width:40px}.RollDate__time__column{display:flex;flex-direction:row;align-items:center;gap:2px}.RollDate__time__arrow{display:flex;align-items:center;justify-content:center;width:20px;height:84px;padding:0;border:none;border-radius:4px;background:none;cursor:pointer;flex-shrink:0;transition:opacity .2s}.RollDate__time__arrow svg{width:7px;height:6px;fill:var(--rd-text-secondary);transition:fill .2s}.RollDate__time__arrow:hover svg{fill:var(--rd-text-primary)}.RollDate__time__arrow--prev svg{transform:rotate(-90deg)}.RollDate__time__arrow--next svg{transform:rotate(90deg)}.RollDate__time__viewport{position:relative;width:46px;height:84px;overflow:hidden;border-radius:4px;touch-action:none}.RollDate__time__viewport::before{content:"";position:absolute;left:0;right:0;top:50%;transform:translateY(-50%);height:28px;border:2px solid var(--rd-hover-border);border-radius:4px;background:rgba(0,0,0,0);pointer-events:none;z-index:2;box-sizing:border-box}.RollDate__time__viewport::after{content:"";position:absolute;inset:0;pointer-events:none;z-index:1;background:linear-gradient(to bottom, var(--rd-bg) 0%, transparent 32%, transparent 68%, var(--rd-bg) 100%)}.RollDate__time__list{will-change:transform;position:relative;z-index:0}.RollDate__time__item{height:28px;display:flex;align-items:center;justify-content:center;font-size:14px;font-weight:600;color:var(--rd-text-disabled);transition:color .15s ease,font-size .15s ease}.RollDate__time__item--active{color:var(--rd-text-primary);font-size:15px;font-weight:700}.RollDate__time__sep{font-size:20px;font-weight:700;color:var(--rd-text-primary);line-height:1;padding-bottom:2px;align-self:center;margin-top:0}.RollDate__time--12h{flex-wrap:wrap;gap:6px;padding-top:2px}.RollDate__time--12h .RollDate__time__display{order:-1;width:100%;flex:1 1 100%;border-left:none;padding:0 0 4px;min-width:0;font-size:22px;letter-spacing:.04em}.RollDate__time--12h .RollDate__time__picker{width:100%;flex:1 1 100%;justify-content:center;gap:2px}.RollDate__time--12h .RollDate__time__arrow{width:18px}.RollDate__time--12h .RollDate__time__viewport{width:42px}.RollDate__time--12h .RollDate__time__field--period .RollDate__time__viewport{width:36px}.RollDate__time--12h .RollDate__time__sep{font-size:18px}.RollDate__has-footer .RollDate__calendar{height:260px}.RollDate__has-time .RollDate__calendar{height:258px}.RollDate__has-footer.RollDate__has-time .RollDate__calendar{height:230px}@media(max-width: 380px){.RollDate__container{width:min(100vw - 16px,360px);padding:6px 8px}.RollDate__header{margin-bottom:8px;height:34px}.RollDate__header__year,.RollDate__header__month{font-size:13px}.RollDate__calendar{height:268px}.RollDate__calendar__header{margin-bottom:6px}.RollDate__calendar__header__weekday{height:22px;font-size:11px}.RollDate__calendar__day{height:36px;font-size:13px}.RollDate__calendar__month,.RollDate__calendar__year{height:60px;font-size:13px}.RollDate__calendar__button{width:28px;height:28px}}/*# sourceMappingURL=rolldate.min.css.map */
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var RollDate=function(){"use strict";function t(t){return t}function e(t){return 10*Math.floor(t/10)}let s=0,i=null;function a(t=!0){if(!t||"undefined"==typeof window)return;const e="undefined"!=typeof performance?performance.now():Date.now();if(!(e-s<28)){s=e;try{if("undefined"!=typeof navigator&&"function"==typeof navigator.vibrate)return void navigator.vibrate(10)}catch{}!function(){try{const t=window.AudioContext||window.webkitAudioContext;if(!t)return;i||(i=new t),"suspended"===i.state&&i.resume().catch(()=>{});const e=i.currentTime,s=i.createOscillator(),a=i.createGain();s.type="triangle",s.frequency.value=180,a.gain.setValueAtTime(1e-4,e),a.gain.exponentialRampToValueAtTime(.045,e+.008),a.gain.exponentialRampToValueAtTime(1e-4,e+.04),s.connect(a),a.connect(i.destination),s.start(e),s.stop(e+.045)}catch{}}()}}function n(t,e="auto"){if(!t)return null;const s=t.trim();if(!s)return null;if(t instanceof Date)return t;if(/^\d{4}-\d{2}-\d{2}$/.test(s))return new Date(s);if("auto"===e){const t=s.match(/[-/.]/)?.[0]||".",e=s.split(t).map(Number);if(3!==e.length)return null;const[i,a,n]=e;let o,r,l;return i>=1e3?[o,r,l]=[i,a,n]:[l,r,o]=[i,a,n],new Date(o,r-1,l)}const i={"YYYY-MM-DD":/^(\d{4})[-/\.](\d{1,2})[-/\.](\d{1,2})$/,"DD/MM/YYYY":/^(\d{1,2})[-/\.](\d{1,2})[-/\.](\d{4})$/,"MM/DD/YYYY":/^(\d{1,2})[-/\.](\d{1,2})[-/\.](\d{4})$/,"DD.MM.YYYY":/^(\d{1,2})\.(\d{1,2})\.(\d{4})$/,"MM.DD.YYYY":/^(\d{1,2})\.(\d{1,2})\.(\d{4})$/}[e];if(!i)return console.warn(`RollDate: unknown format "${e}". Using auto-detect.`),n(t,"auto");const a=s.match(i);if(!a)return null;let o,r,l;switch(e){case"YYYY-MM-DD":[,o,r,l]=a;break;case"DD/MM/YYYY":case"DD.MM.YYYY":[,l,r,o]=a;break;case"MM/DD/YYYY":case"MM.DD.YYYY":[,r,l,o]=a}return new Date(Number(o),Number(r)-1,Number(l))}function o(t,e){return"string"==typeof t?n(t,e):t}function r(t,e){const s=(t.getDay()-Number(e)+7)%7;return new Date(t.getFullYear(),t.getMonth(),t.getDate()-s)}function l(t,e){const s=(6-t.getDay()+Number(e)+7)%7;return new Date(t.getFullYear(),t.getMonth(),t.getDate()+s)}class h{constructor(t){this.$container=t,this.intersecting=new Map,this.init()}init(){return this.observe=new IntersectionObserver(t=>{t.forEach(t=>{const e=`${t.target.dataset.year}${t.target.dataset?.month?"_"+t.target.dataset.month:""}${t.target.dataset?.day?"_"+t.target.dataset.day:""}`;t.isIntersecting?this.intersecting.set(e,t):this.intersecting.delete(e)})},{threshold:.5})}on(t,e){this.$container.querySelectorAll(`.RollDate__calendar__${t}`).forEach(t=>{e&&e(t),this.observe.observe(t)})}un(){this.intersecting.clear(),this.$container.querySelectorAll(".RollDate__calendar__day, .RollDate__calendar__month, .RollDate__calendar__year").forEach(t=>{this.observe.unobserve(t)})}dominant(){if(0===this.intersecting.size)return null;const t={};let e=[];this.intersecting.forEach(s=>{const i={};e=JSON.parse(s.target.dataset.bind);for(const t of e)i[t]=s.target.dataset[t];const a=Object.values(i).join("-");t[a]=(t[a]||0)+1});const s=Object.keys(t).reduce((e,s)=>t[e]>t[s]?e:s).split("-").map(Number);return Object.fromEntries(e.map((t,e)=>[t,s[e]]))}disconnect(){this.observe?.disconnect()}}class d{up_date=null;down_date=null;current_year;current_month;current_decade;constructor(t){this.options=t,this.current_year=this.options.startDate.getFullYear(),this.current_month=this.options.startDate.getMonth(),this.current_decade=e(this.current_year)}get currentPeriod(){return{year:this.current_year,month:this.current_month,decade:this.current_decade}}setPeriod(t){"year"in t&&(this.current_year=t.year),"month"in t&&(this.current_month=t.month),"decade"in t&&(this.current_decade=t.decade)}getDates(){let t=new Date(this.current_year,this.current_month-3,1),e=new Date(this.current_year,this.current_month+3,0);if(this.options.minDate&&this.options.minDate>t&&(t=new Date(this.options.minDate.getFullYear(),this.options.minDate.getMonth(),1)),this.options.maxDate&&this.options.maxDate<e&&(e=new Date(this.options.maxDate.getFullYear(),this.options.maxDate.getMonth()+1,0)),this.options.minDate&&this.options.maxDate&&this.options.minDate.getFullYear()===this.options.maxDate.getFullYear()&&this.options.minDate.getMonth()===this.options.maxDate.getMonth()){const s=this.options.minDate.getFullYear(),i=this.options.minDate.getMonth();t=new Date(s,i,1),e=new Date(s,i+1,1)}t=r(t,this.options.startWeekFromMonday),e=l(e,this.options.startWeekFromMonday);const s=Math.floor((e-t)/864e5)+1;if(s<42){const i=42-s,a=Math.ceil(i/2),n=Math.floor(i/2);t.setDate(t.getDate()-a),e.setDate(e.getDate()+n),t=r(t,this.options.startWeekFromMonday),e=l(e,this.options.startWeekFromMonday)}this.up_date=new Date(t),this.down_date=new Date(e);const i=[];for(let s=new Date(t);s<=e;s.setDate(s.getDate()+1)){const t=!!this.options.isDateDisabled&&this.options.isDateDisabled(s),e=this.options.minDate&&s<this.options.minDate||this.options.maxDate&&s>this.options.maxDate||t;i.push({date:new Date(s),disabled:e})}return i}getMonthsOrYears(t){let e=this.current_year-("month"===t?5:18),s=this.current_year+("month"===t?5:18);if(this.options.minDate){const t=this.options.minDate.getFullYear();t>e&&(e=t)}if(this.options.maxDate){const t=this.options.maxDate.getFullYear();t<s&&(s=t)}if("month"===t&&this.options.minDate&&this.options.maxDate&&this.options.minDate.getFullYear()===this.options.maxDate.getFullYear()){const t=this.options.minDate.getFullYear();e=t-2,s=t+2}this.up_date=new Date(e,0,1),this.down_date=new Date(s+1,0,0);const i=[];for(let a=e;a<=s;a++)if("month"===t)for(let t=0;t<12;t++){const e=new Date(a,t,1),s=new Date(a,t+1,0);let n=!1;(this.options.minDate&&s<this.options.minDate||this.options.maxDate&&e>this.options.maxDate)&&(n=!0),i.push({date:e,disabled:n})}else{const t=new Date(a,0,1);let e=!1;(this.options.minDate&&a<this.options.minDate.getFullYear()||this.options.maxDate&&a>this.options.maxDate.getFullYear())&&(e=!0),i.push({date:t,disabled:e})}if(i.length<16){let e=s+1;for(;i.length<16;){if("month"===t)for(let t=0;t<12&&i.length<16;t++)i.push({date:new Date(e,t,1),disabled:!0});else i.push({date:new Date(e,0,1),disabled:!0});e++}}return i}}class c{constructor(t){this.$container=t.container,this.$trigger=t.trigger,this.startWeekFromMonday=t.startWeekFromMonday,this.monthsNames=t.monthsNames,this.monthsShortNames=t.monthsShortNames,this.enableTime=Boolean(t.enableTime),this.hasFooter=Boolean(t.enableTime||t.footerButtons&&t.footerButtons.length),this.init()}init(){const t=this.hasFooter?`\n <div class="RollDate__footer">\n ${this.enableTime?'<div class="RollDate__time"></div>':""}\n <div class="RollDate__footer__buttons"></div>\n </div>\n `:"";this.$container.innerHTML=`\n <div class="RollDate__header">\n <div class="RollDate__calendar__switcher">\n <div class="RollDate__header__year"></div>\n <div class="RollDate__header__month"></div>\n </div>\n <div class="RollDate__calendar__buttons">\n <button class="RollDate__calendar__button" data-direction="prev">\n <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 61 55" width="55" height="50">\n <path id="Форма 2" fill-rule="evenodd" class="s0" d="m52.76 54.67l-44.73 0.12c-6.16 0.02-10.02-6.64-6.96-11.98l22.26-38.79c3.07-5.35 10.76-5.37 13.86-0.04l22.47 38.67c3.09 5.33-0.74 12.01-6.9 12.02z"/>\n </svg>\n </button>\n <button class="RollDate__calendar__button" data-direction="next">\n <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 61 55" width="55" height="50">\n <path id="Форма 2" fill-rule="evenodd" class="s0" d="m52.76 54.67l-44.73 0.12c-6.16 0.02-10.02-6.64-6.96-11.98l22.26-38.79c3.07-5.35 10.76-5.37 13.86-0.04l22.47 38.67c3.09 5.33-0.74 12.01-6.9 12.02z" />\n </svg>\n </button>\n </div>\n </div>\n <div class="RollDate__calendar">\n <div class="RollDate__calendar__header">\n ${this.#t()}\n </div>\n <div class="RollDate__calendar__body">\n <div class="RollDate__calendar__scrollblock">\n <div class="RollDate__calendar__days"></div>\n <div class="RollDate__calendar__months"></div>\n <div class="RollDate__calendar__years"></div>\n </div>\n </div>\n </div>\n ${t}\n `,"DIV"===this.$trigger.nodeName||"SPAN"===this.$trigger.nodeName||"SECTION"===this.$trigger.nodeName?this.$trigger.append(this.$container):document.body.append(this.$container)}#t(){const e=["Sun","Mon","Tue","Wed","Thu","Fri","Sat"];let s="";const i=Number(this.startWeekFromMonday);for(let a=i;a<7+i;a++)s+=`<div class="RollDate__calendar__header__weekday">${t(e[a%7])}</div>`;return s}dates(t,e=[],s="single"){let i="";const a=new Date;for(let n=0;n<t.length;n++){const o=t[n].date,r=t[n].disabled?"RollDate__calendar__day--disabled":"",l=o.toDateString()===a.toDateString();let h="";if("single"===s||"multi"===s){e.some(t=>t.getTime()===o.getTime())&&(h="RollDate__calendar__day--selected")}else if("range"===s&&2===e.length){const[t,s]=e,i=o.getTime();i===t.getTime()?h="RollDate__calendar__day--range-first":i===s.getTime()?h="RollDate__calendar__day--range-last":i>t.getTime()&&i<s.getTime()&&(h="RollDate__calendar__day--range-selected")}i+=`<div class="RollDate__calendar__day ${r} ${l?"RollDate__calendar__day--today":""} ${h}" \n data-bind='["year", "month"]'\n data-year="${o.getFullYear()}"\n data-month="${o.getMonth()}" \n data-day="${o.getDate()}">${o.getDate()}</div>`}return i}months(t){let e="";for(let s=0;s<t.length;s++){const i=new Date(t[s].date),a=t[s].disabled,n=i.getMonth();let o="";i.getFullYear()===(new Date).getFullYear()&&n===(new Date).getMonth()&&(o="RollDate__calendar__month--current"),e+=`<div class="RollDate__calendar__month${a?" RollDate__calendar__month--disabled":""} ${o}" \n data-bind='["year"]'\n data-month="${n}" \n data-year="${i.getFullYear()}"\n data-click="day">\n ${this.monthsShortNames[n]} \n </div>`}return e}years(t){let e="";for(let s=0;s<t.length;s++){const i=new Date(t[s].date),a=t[s].disabled,n=i.getFullYear();let o="";n===(new Date).getFullYear()&&(o="RollDate__calendar__year--current"),e+=`<div class="RollDate__calendar__year${a?" RollDate__calendar__year--disabled":""} ${o}" \n data-bind='["decade"]'\n data-decade="${10*Math.floor(n/10)}"\n data-month="0" \n data-year="${n}"\n data-click="month">\n ${n} \n </div>`}return e}clear(t){t.innerHTML=""}}class u{#e=null;#s=25;#i=75;#a;#n=0;#o;#r;#l;#h;#d;#c=!1;#u=!1;#m=0;#p=!1;#_=0;#D=0;#g=0;#y=null;constructor(t,e={dominant:()=>console.error('Function "dominant" is not found'),updatePeriod:()=>console.error('Function "updatePeriod" is not found')}){this.$body=t,this.$scroll_block=this.$body.querySelector(".RollDate__calendar__scrollblock"),this.dominant=e.dominant,this.updatePeriod=e.updatePeriod,this.offset=0,this.init()}init(){this.#r=this.wheelHandler.bind(this),this.$body.addEventListener("wheel",this.#r,{passive:!1}),this.#l=this.touchStartHandler.bind(this),this.#h=this.touchMoveHandler.bind(this),this.#d=this.touchEndHandler.bind(this),this.$body.addEventListener("touchstart",this.#l,{passive:!0}),this.$body.addEventListener("touchmove",this.#h,{passive:!1}),this.$body.addEventListener("touchend",this.#d,{passive:!0}),this.$body.addEventListener("touchcancel",this.#d,{passive:!0})}wheelHandler(t){t.preventDefault(),t.stopPropagation();const e=.85*t.deltaY,s=Math.abs(e)>50?20:1,i=e/s,a=e>0?"down":"up";this.#c=!0,this.#u=!1;let n=0;const o=()=>{if(n>=s)return this.#c=!1,void(this.#u=!1);this.offset-=i,requestAnimationFrame(()=>{this.dominant(),this.checkEdge(a),n++,o()})};o()}touchStartHandler(t){t.touches&&1===t.touches.length&&(this.#f(),this.#p=!0,this.#_=t.touches[0].clientY,this.#D=performance.now(),this.#g=0,this.#u=!1)}touchMoveHandler(t){if(!this.#p||!t.touches||1!==t.touches.length)return;t.preventDefault();const e=t.touches[0].clientY,s=e-this.#_,i=performance.now(),a=i-this.#D;if(a>0&&a<120){const t=s/a;this.#g=.65*this.#g+.35*t}if(this.#_=e,this.#D=i,Math.abs(s)<1)return;this.offset+=s,this.dominant();const n=s<0?"down":"up";this.checkEdge(n)}touchEndHandler(){this.#p=!1,this.#u=!1;const t=16*this.#g;Math.abs(t)>=.4&&this.#b(t)}#f(){null!==this.#y&&(cancelAnimationFrame(this.#y),this.#y=null)}#b(t){this.#f();const e=()=>{if(Math.abs(t)<.35||this.blocked)return this.#y=null,void(this.#u=!1);this.offset+=t,t*=.92,this.dominant();const s=t<0?"down":"up";if(this.checkEdge(s),this.blocked)return this.#y=null,void(this.#u=!1);this.#y=requestAnimationFrame(e)};this.#y=requestAnimationFrame(e)}apply(){this.$scroll_block.style.transform=`translateY(${this.offset+this.#n}px)`}get offset(){return this.#a}set offset(t){this.#a=t,null!==this.#e&&(t>=0?this.#a=0:t<=this.#e&&(this.#a=this.#e)),this.apply()}get blocked(){return this.#o}set blocked(t){this.#o=t}get minScroll(){return null===this.#e&&this.checkMinScroll(),this.#e??0}checkEdge(t){if(null===this.#e&&this.checkMinScroll(),0===this.#e||this.blocked)return;if(this.#c&&this.#u)return;const e=100*Math.abs(this.offset/this.#e),s=Date.now();if(!(s-this.#m<60))if(e<this.#s){if("up"!==t)return;this.#m=s,this.#u=!0,this.blocked=!0,this.updatePeriod("up")}else if(e>this.#i){if("down"!==t)return;this.#m=s,this.#u=!0,this.blocked=!0,this.updatePeriod("down")}}checkMinScroll(){const t=this.$scroll_block.clientHeight,e=this.$body.clientHeight;this.#e=t>e?-(t-e):0}setBaseOffset(t=0){this.#n=t,this.apply()}resetMinScroll(){this.#e=null}destroy(){this.#f(),this.#r&&this.$body.removeEventListener("wheel",this.#r),this.#l&&this.$body.removeEventListener("touchstart",this.#l),this.#h&&this.$body.removeEventListener("touchmove",this.#h),this.#d&&(this.$body.removeEventListener("touchend",this.#d),this.$body.removeEventListener("touchcancel",this.#d))}}class m{constructor(t){this.ctx=t}#v(t){const e=t instanceof Date?t:new Date(t);return!!(this.ctx.options.minDate&&e<this.ctx.options.minDate)||(!!(this.ctx.options.maxDate&&e>this.ctx.options.maxDate)||"function"==typeof this.ctx.isDateDisabled&&this.ctx.isDateDisabled(e))}update(t){const e=this.ctx.period,s="up"===t;if(s){if("year"===e){if(this.ctx.data.up_date.getFullYear()<=this.ctx.options.minDate.getFullYear())return void(this.ctx.scroll.blocked=!1)}else if(this.ctx.data.up_date<=this.ctx.options.minDate)return void(this.ctx.scroll.blocked=!1)}else if("year"===e){if(this.ctx.data.down_date.getFullYear()>=this.ctx.options.maxDate.getFullYear())return void(this.ctx.scroll.blocked=!1)}else if(this.ctx.data.down_date>=this.ctx.options.maxDate)return void(this.ctx.scroll.blocked=!1);const i={day:{count:35,getNewItems:(t,e)=>{const i=[];if(s){let e=new Date(t);if(e.setDate(t.getDate()-35),e<this.ctx.options.minDate){const t=this.ctx.options.minDate;e=r(new Date(t.getFullYear(),t.getMonth(),1),this.ctx.options.startWeekFromMonday)}for(let s=new Date(e);s<t;s.setDate(s.getDate()+1))i.push({date:new Date(s),disabled:this.#v(s)});return{items:i,newBound:e}}{let t=new Date(e);t.setDate(e.getDate()+35);const s=new Date(e);if(s.setDate(e.getDate()+1),t>this.ctx.options.maxDate){const e=this.ctx.options.maxDate;t=l(new Date(e.getFullYear(),e.getMonth()+1,0),this.ctx.options.startWeekFromMonday)}for(let e=s;e<=t;e.setDate(e.getDate()+1))i.push({date:new Date(e),disabled:this.#v(e)});return{items:i,newBound:t}}},render:t=>this.ctx.render.dates(t,this.ctx.selectedDates,this.ctx.options.selectType),block:this.ctx.dom.$days_block},month:{count:36,ctx:this.ctx,getNewItems:function(t,e){const i=[],a=(t,e)=>{const s=new Date(t,e,1),i=new Date(t,e+1,0);return!!(this.ctx.options.minDate&&i<this.ctx.options.minDate)||!!(this.ctx.options.maxDate&&s>this.ctx.options.maxDate)};if(s){let e=new Date(t);for(let t=0;t<this.count;t++)e.setMonth(e.getMonth()-1),i.unshift({date:new Date(e.getFullYear(),e.getMonth(),1),disabled:a(e.getFullYear(),e.getMonth())});return{items:i,newBound:i.length?i[0].date:t}}{let t=new Date(e);t.setMonth(t.getMonth()+1);for(let e=0;e<this.count;e++)i.push({date:new Date(t.getFullYear(),t.getMonth(),1),disabled:a(t.getFullYear(),t.getMonth())}),t.setMonth(t.getMonth()+1);return{items:i,newBound:i.length?i[i.length-1].date:e}}},render:t=>this.ctx.render.months(t),block:this.ctx.dom.$months_block},year:{count:16,ctx:this.ctx,getNewItems:function(t,e){const i=[];if(s){for(let e=t.getFullYear()-this.count;e<t.getFullYear();e++)e<this.ctx.options.minDate.getFullYear()||i.push({date:new Date(e,0,1),disabled:this.ctx.options.minDate.getFullYear()>e});return{items:i,newBound:i.length?i[0].date:t}}{const t=e.getFullYear()+1;for(let e=t;e<t+this.count&&!(e>this.ctx.options.maxDate.getFullYear());e++)i.push({date:new Date(e,0,1),disabled:this.ctx.options.maxDate.getFullYear()<e});return{items:i,newBound:i.length?i[i.length-1].date:e}}},render:t=>this.ctx.render.years(t),block:this.ctx.dom.$years_block}}[e];if(!i)return;const{items:a,newBound:n}=i.getNewItems(this.ctx.data.up_date,this.ctx.data.down_date);a.length&&i.block.insertAdjacentHTML(s?"afterbegin":"beforeend",i.render(a)),this.ctx.data[`${t}_date`]=n,this.ctx.observe.un();const o="year"===e?Math.min(4,a.length):a.length;this.trim(t,o),this.ctx.observe.on(e),this.ctx.scroll.blocked=!1}trim(t,e){const s=this.ctx.period,i=this.ctx.dom[`$${s}s_block`],a="up"===t,n="year"===s?28:0,o=i.scrollHeight,r=Array.from(i.querySelectorAll(`.RollDate__calendar__${s}`));if(!e||r.length<=2*e)return;if(n&&r.length-e<n)return;a?r.slice(-e).forEach(t=>t.remove()):r.slice(0,e).forEach(t=>t.remove());const l=Array.from(i.querySelectorAll(`.RollDate__calendar__${s}`)),h=l[0],d=l[l.length-1],c=t=>{if(!t)return null;const e=Number(t.dataset.year),i=Number(t.dataset.month)||0,a="day"===s?Number(t.dataset.day):1;return new Date(e,i,a)},u=c(h),m=c(d);u&&(this.ctx.data.up_date=u),m&&(this.ctx.data.down_date=m);const p=o-i.scrollHeight;this.ctx.scroll.checkMinScroll(),a?this.ctx.scroll.offset-=p:this.ctx.scroll.offset+=p}}const p=28,_='<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 61 55" width="55" height="50" aria-hidden="true">\n <path fill-rule="evenodd" d="m52.76 54.67l-44.73 0.12c-6.16 0.02-10.02-6.64-6.96-11.98l22.26-38.79c3.07-5.35 10.76-5.37 13.86-0.04l22.47 38.67c3.09 5.33-0.74 12.01-6.9 12.02z"/>\n</svg>';class D{#$=0;#w=0;#T=!1;#M="AM";#S=1;#x=[];#Y=null;constructor(t,e={}){this.root=t,this.#T=Boolean(e.use12Hour),this.#S=Math.max(1,Number(e.minuteStep)||1),this.#$=this.#R(e.hours??0),this.#w=this.#N(e.minutes??0),this.#T&&(this.#M=this.#$>=12?"PM":"AM"),this.onChange=e.onChange||(()=>{}),this.hapticFeedback=!1!==e.hapticFeedback,this.#k()}#R(t){const e=Number(t);return Number.isNaN(e)?0:Math.min(23,Math.max(0,e))}#F(){if(!this.#T)return this.#$;const t=this.#$%12;return 0===t?12:t}#N(t){const e=this.#S,s=Math.round(Number(t)/e)*e;return Math.min(59,Math.max(0,Number.isNaN(s)?0:s))}#k(){const t=this.#T?Array.from({length:12},(t,e)=>e+1):Array.from({length:24},(t,e)=>e),e=[];for(let t=0;t<60;t+=this.#S)e.push(t);this.root.innerHTML=`\n <div class="RollDate__time__picker">\n <div class="RollDate__time__field" data-unit="hour">\n <div class="RollDate__time__column">\n <button type="button" class="RollDate__time__arrow RollDate__time__arrow--prev" data-dir="prev" aria-label="Earlier hour">${_}</button>\n <div class="RollDate__time__viewport">\n <div class="RollDate__time__list"></div>\n </div>\n <button type="button" class="RollDate__time__arrow RollDate__time__arrow--next" data-dir="next" aria-label="Later hour">${_}</button>\n </div>\n </div>\n <span class="RollDate__time__sep">:</span>\n <div class="RollDate__time__field" data-unit="minute">\n <div class="RollDate__time__column">\n <button type="button" class="RollDate__time__arrow RollDate__time__arrow--prev" data-dir="prev" aria-label="Earlier minute">${_}</button>\n <div class="RollDate__time__viewport">\n <div class="RollDate__time__list"></div>\n </div>\n <button type="button" class="RollDate__time__arrow RollDate__time__arrow--next" data-dir="next" aria-label="Later minute">${_}</button>\n </div>\n </div>\n ${this.#T?`\n <div class="RollDate__time__field RollDate__time__field--period" data-unit="period">\n <div class="RollDate__time__column">\n <button type="button" class="RollDate__time__arrow RollDate__time__arrow--prev" data-dir="prev" aria-label="Earlier period">${_}</button>\n <div class="RollDate__time__viewport">\n <div class="RollDate__time__list"></div>\n </div>\n <button type="button" class="RollDate__time__arrow RollDate__time__arrow--next" data-dir="next" aria-label="Later period">${_}</button>\n </div>\n </div>`:""}\n </div>\n <div class="RollDate__time__display" aria-live="polite"></div>\n `,this.#Y=this.root.querySelector(".RollDate__time__display"),this.#T&&this.root.classList.add("RollDate__time--12h"),this.#x.push(this.#H("hour",t,this.#F())),this.#x.push(this.#H("minute",e,this.#w)),this.#T&&this.#x.push(this.#H("period",["AM","PM"],this.#M)),this.#E()}#I(){const t=String(this.#$).padStart(2,"0"),e=String(this.#w).padStart(2,"0");return this.#T?`${String(this.#F()).padStart(2,"0")}:${e} ${this.#M}`:`${t}:${e}`}#E(){this.#Y&&(this.#Y.textContent=this.#I())}#H(t,e,s){const i=this.root.querySelector(`[data-unit="${t}"]`),n=i.querySelector(".RollDate__time__viewport"),o=i.querySelector(".RollDate__time__list");o.innerHTML=e.map(e=>`<div class="RollDate__time__item" data-value="${e}">${"minute"===t?String(e).padStart(2,"0"):String(e)}</div>`).join(""),o.style.paddingTop="28px",o.style.paddingBottom="28px";const r={unit:t,viewport:n,list:o,values:e,offset:0};return r.updateActive=()=>{const t=r.indexFromOffset();r._lastIndex!==t&&(void 0!==r._lastIndex&&a(this.hapticFeedback),r._lastIndex=t),o.querySelectorAll(".RollDate__time__item").forEach((e,s)=>{e.classList.toggle("RollDate__time__item--active",s===t)})},r.indexFromOffset=()=>{const t=Math.round(-r.offset/p);return Math.min(e.length-1,Math.max(0,t))},r.getValue=()=>e[r.indexFromOffset()],r.apply=t=>{o.style.transition=t?"transform 0.2s ease":"none",o.style.transform=`translateY(${r.offset}px)`,r.updateActive()},r.snap=()=>{const t=r.indexFromOffset();r.offset=-t*p,r.apply(!0),this.#L(),this.#E(),this.onChange(this.getTime())},r.scrollToValue=(t,s=!0)=>{const i=e.indexOf(t);i<0||(r.offset=-i*p,r.apply(s))},r.stepBy=t=>{const s=Math.min(e.length-1,Math.max(0,r.indexFromOffset()+t));r.offset=-s*p,r.apply(!0),this.#L(),this.#E(),this.onChange(this.getTime())},r.scrollToValue(s,!1),this.#A(r),this.#C(r),this.#O(i,r),r}#O(t,e){t.querySelector('[data-dir="prev"]')?.addEventListener("click",t=>{t.preventDefault(),e.stepBy(-1)}),t.querySelector('[data-dir="next"]')?.addEventListener("click",t=>{t.preventDefault(),e.stepBy(1)})}#A(t){t.viewport.addEventListener("wheel",e=>{e.preventDefault(),e.stopPropagation(),t.list.style.transition="none",t.offset-=.35*e.deltaY;const s=-(t.values.length-1)*p;t.offset=Math.max(s,Math.min(0,t.offset)),t.list.style.transform=`translateY(${t.offset}px)`,t.updateActive(),clearTimeout(t._snapTimer),t._snapTimer=setTimeout(()=>t.snap(),90)},{passive:!1})}#C(t){let e=0,s=0;t.viewport.addEventListener("touchstart",i=>{i.touches&&1===i.touches.length&&(e=i.touches[0].clientY,s=t.offset,t.list.style.transition="none")},{passive:!0}),t.viewport.addEventListener("touchmove",i=>{if(!i.touches||1!==i.touches.length)return;i.preventDefault(),t.offset=s+(i.touches[0].clientY-e);const a=-(t.values.length-1)*p;t.offset=Math.max(a,Math.min(0,t.offset)),t.list.style.transform=`translateY(${t.offset}px)`,t.updateActive()},{passive:!1}),t.viewport.addEventListener("touchend",()=>t.snap())}#L(){const t=this.#x.find(t=>"hour"===t.unit),e=this.#x.find(t=>"minute"===t.unit),s=this.#x.find(t=>"period"===t.unit),i=t.getValue();this.#w=e.getValue(),this.#T&&s?(this.#M=s.getValue(),"AM"===this.#M?this.#$=12===i?0:i:this.#$=12===i?12:i+12):this.#$=i}getTime(){return{hours:this.#$,minutes:this.#w}}setTime(t,e){this.#$=this.#R(t),this.#w=this.#N(e),this.#T?(this.#M=this.#$>=12?"PM":"AM",this.#x.find(t=>"hour"===t.unit)?.scrollToValue(this.#F()),this.#x.find(t=>"period"===t.unit)?.scrollToValue(this.#M)):this.#x.find(t=>"hour"===t.unit)?.scrollToValue(this.#$),this.#x.find(t=>"minute"===t.unit)?.scrollToValue(this.#w),this.#E()}destroy(){this.#x=[],this.root.innerHTML=""}}class g{static#V=new Set;#P;#q=0;#W=["day","month","year"];#B=[];#z=!0;#j=new Set;#J=null;#U=[];#G(t,e,s){return t instanceof Date&&!Number.isNaN(t.getTime())?t<e?new Date(e):t>s?new Date(s):t:e}#X(t){return new Date(t.getFullYear(),t.getMonth(),t.getDate()).getTime()}#K(t){const e=o(t,this.options.dateFormat);return e instanceof Date&&!Number.isNaN(e.getTime())?new Date(e.getFullYear(),e.getMonth(),e.getDate()):null}#Q(t=[]){const e=new Set;return t.forEach(t=>{const s=this.#K(t);s&&e.add(this.#X(s))}),e}#Z(t){t&&"INPUT"===t.tagName&&(t.setAttribute("autocomplete","off"),t.setAttribute("autocorrect","off"),t.setAttribute("autocapitalize","off"),t.setAttribute("spellcheck","false"))}#tt(t){return this.#j.has(this.#X(t))}#et(){"single"!==this.options.selectType?this.options.selectDate([...this.#B]):this.options.selectDate(this.#B[0]||null)}#st(){const t=this.#B.length;this.#B=this.#B.filter(t=>!this.#tt(t)),t!==this.#B.length&&(this.#et(),this.#it())}#at(t){const e=new Date(t);if(!this.options.enableTime)return e;const s=this.timePicker?.getTime()||{hours:this.options.startDate.getHours(),minutes:this.options.startDate.getMinutes()};return e.setHours(s.hours,s.minutes,0,0),e}#nt(t){const e=function(t,e="YYYY-MM-DD"){if(!t||!(t instanceof Date)||isNaN(t))return"";const s=t.getFullYear(),i=String(t.getMonth()+1).padStart(2,"0"),a=String(t.getDate()).padStart(2,"0"),n={YYYY:s,YY:String(s).slice(-2),MM:i,M:t.getMonth()+1,DD:a,D:t.getDate()};return e.replace(/YYYY|YY|MM|M|DD|D/g,t=>n[t]||t)}(t,this.options.dateFormat);if(!this.options.enableTime)return e;return`${e} ${String(t.getHours()).padStart(2,"0")}:${String(t.getMinutes()).padStart(2,"0")}`}#ot(){if(!this.dom.$footer_buttons)return;const t=Array.isArray(this.options.footerButtons)?this.options.footerButtons:[];this.dom.$footer_buttons.innerHTML="",t.forEach(t=>{if(!t?.text)return;const e=document.createElement("button");e.type="button",e.className="RollDate__footer__button",e.textContent=t.text,e.addEventListener("click",e=>{e.preventDefault(),e.stopPropagation(),this.#rt(t)}),this.dom.$footer_buttons.append(e)})}#rt(t){"today"!==t.action?"clear"!==t.action?"function"==typeof t.onClick&&t.onClick(this):this.clearSelection():this.selectToday()}#lt(){const t=this.options.startDate;this.timePicker=new D(this.dom.$time,{hours:t.getHours(),minutes:t.getMinutes(),use12Hour:this.options.use12Hour,minuteStep:this.options.timeStep,hapticFeedback:!1!==this.options.hapticFeedback,onChange:()=>{this.#B.length&&(this.#B=this.#B.map(t=>this.#at(t)),this.#et(),this.#it())}})}constructor(t,e={}){null==e&&(e={}),this.triggerSelector=e.triggerSelector,Array.isArray(t)?(this.$startInput=document.querySelector(t[0]),this.$endInput=document.querySelector(t[1]),this.$trigger=this.$startInput,this.mode="popup"):(this.$trigger=document.querySelector(t),this.triggerSelector?(this.$openTrigger=document.querySelector(this.triggerSelector),this.mode="popup"):"INPUT"===this.$trigger.tagName?this.mode="popup":this.mode="inline");const s=new Date,i={mode:"auto",theme:"dark",startWeekFromMonday:!0,selectType:"single",monthsNames:["January","February","March","April","May","June","July","August","September","October","November","December"],monthsShortNames:["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],weekDaysNames:["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],selectDate:t=>console.log(t),onOpen:()=>{},onClose:()=>{},onViewChange:()=>{},onHoverDate:()=>{},disabledDates:[],closeOnSelect:!0,enableTime:!1,use12Hour:!1,timeStep:1,footerButtons:[],hapticFeedback:!0,...e};"default"===i.theme&&(i.theme="dark");const a=i.locale||("undefined"!=typeof navigator?navigator.language:void 0);i.dateFormat=i.dateFormat||function(t){const e=t||("undefined"!=typeof navigator&&navigator.language?navigator.language:"en-US");try{return new Intl.DateTimeFormat(e,{year:"numeric",month:"2-digit",day:"2-digit"}).formatToParts(new Date(2023,5,15)).map(t=>"year"===t.type?"YYYY":"month"===t.type?"MM":"day"===t.type?"DD":t.value).join("")}catch{return"MM/DD/YYYY"}}(a);const n={startDate:o(void 0!==e.startDate?e.startDate:s,i.dateFormat),minDate:o(void 0!==e.minDate?e.minDate:new Date(s.getFullYear()-100,s.getMonth(),1),i.dateFormat),maxDate:o(void 0!==e.maxDate?e.maxDate:new Date(s.getFullYear()+100,s.getMonth()+1,0),i.dateFormat)};this.options={...i,...n},this.options.minDate>this.options.maxDate&&console.error("Date Error: maxDate is less than minDate!"),this.options.startDate=this.#G(this.options.startDate,this.options.minDate,this.options.maxDate),this.#j=this.#Q(this.options.disabledDates),this.#tt(this.options.startDate)&&(this.options.startDate=new Date(this.options.minDate)),this.#ht(),g.#V.add(this)}#dt(){for(const t of g.#V)t!==this&&"popup"===t.mode&&t.close()}#ht(){"object"==typeof this.options&&null!==this.options?(this.$container=document.createElement("div"),this.$container.className=`RollDate__container RollDate__calendar__type--days RollDate__theme_${this.options.theme}`,this.#Z(this.$trigger),this.#Z(this.$startInput),this.#Z(this.$endInput),"popup"===this.mode?(document.body.appendChild(this.$container),this.$container.style.display="none"):"DIV"===this.$trigger.nodeName||"SPAN"===this.$trigger.nodeName||"SECTION"===this.$trigger.nodeName?this.$trigger.append(this.$container):document.body.append(this.$container),this.options.enableTime&&this.$container.classList.add("RollDate__has-time"),(this.options.footerButtons?.length||this.options.enableTime)&&this.$container.classList.add("RollDate__has-footer"),this.render=new c({container:this.$container,trigger:this.$trigger,startWeekFromMonday:this.options.startWeekFromMonday,monthsNames:this.options.monthsNames,monthsShortNames:this.options.monthsShortNames,weekDays:this.options.weekDaysNames,enableTime:this.options.enableTime,footerButtons:this.options.footerButtons}),this.dom={$year:this.$container.querySelector(".RollDate__header__year"),$month:this.$container.querySelector(".RollDate__header__month"),$years_block:this.$container.querySelector(".RollDate__calendar__years"),$months_block:this.$container.querySelector(".RollDate__calendar__months"),$days_block:this.$container.querySelector(".RollDate__calendar__days"),$body:this.$container.querySelector(".RollDate__calendar__body"),$type_switcher:this.$container.querySelector(".RollDate__calendar__switcher"),$page_switcher:this.$container.querySelectorAll(".RollDate__calendar__button"),$footer_buttons:this.$container.querySelector(".RollDate__footer__buttons"),$time:this.$container.querySelector(".RollDate__time")},this.#ot(),this.options.enableTime&&this.dom.$time&&this.#lt(),this.virtualizer=new m(this),this.#ct(),this.observe=new h(this.$container),this.data=new d({startDate:this.options.startDate,minDate:this.options.minDate,maxDate:this.options.maxDate,startWeekFromMonday:this.options.startWeekFromMonday,isDateDisabled:t=>this.#tt(t)}),this.#ut(this.#q)):console.error("RollDate: options is not an object!")}#mt(){if("popup"!==this.mode)return;if(window.innerWidth<=380)return this.$container.style.position="fixed",this.$container.style.left="8px",this.$container.style.right="8px",this.$container.style.top="auto",this.$container.style.bottom="8px",this.$container.style.width="auto",this.$container.style.maxHeight="min(80vh, 560px)",void(this.$container.style.zIndex="10000");const t=(this.$endInput?this.$startInput:(this.$openTrigger,this.$trigger)).getBoundingClientRect(),e=window.innerHeight-t.bottom;this.$container.style.top=e<300?t.top+window.scrollY-this.$container.offsetHeight+"px":`${t.bottom+window.scrollY}px`,this.$container.style.left=`${t.left+window.scrollX}px`,this.$container.style.right="auto",this.$container.style.bottom="auto",this.$container.style.width="",this.$container.style.maxHeight="",this.$container.style.position="absolute",this.$container.style.zIndex="10000"}#ut(){if(this.#pt(),this.scroll.blocked=!1,this.observe.un(this.period),this.#_t(this.period),"day"===this.period){const t=this.data.getDates();this.dom.$days_block.innerHTML=this.render.dates(t,this.#B,this.options.selectType)}else{const t=this.data.getMonthsOrYears(this.period);this.dom[`$${this.period}s_block`].innerHTML=this.render[`${this.period}s`](t)}const t={day:`.RollDate__calendar__day[data-year="${this.data.current_year}"][data-month="${this.data.current_month}"]`,month:`.RollDate__calendar__month[data-year="${this.data.current_year}"][data-month="0"]`,year:`.RollDate__calendar__year[data-decade="${this.data.current_decade}"][data-year="${this.data.current_year}"]`};let e=this.$container.querySelector(t[this.period]);if(!e){const t={day:`.RollDate__calendar__day[data-year="${this.data.current_year}"]`,month:`.RollDate__calendar__month[data-year="${this.data.current_year}"]`,year:`.RollDate__calendar__year[data-decade="${this.data.current_decade}"]`};e=this.$container.querySelector(t[this.period])}e&&setTimeout(()=>{const t=this.dom.$body.querySelector(".RollDate__calendar__scrollblock"),s=this.dom.$body.clientHeight,i=t.clientHeight;if(i<=s)return this.scroll.setBaseOffset(s-i),void(this.scroll.offset=0);this.scroll.setBaseOffset(0);const a=t.getBoundingClientRect(),n=-(e.getBoundingClientRect().top-a.top),o=this.scroll.minScroll;this.scroll.offset=Math.max(n,o)},0),this.observe.on(this.period,t=>{JSON.parse(t.dataset.bind).every(e=>Number(t.dataset[e])===this.data[`current_${e}`])&&t.classList.add(`RollDate__calendar__${this.period}--active`)})}#pt(){"year"!==this.period?(this.dom.$year.innerText=this.data.current_year,this.dom.$month.innerText=this.options.monthsNames[this.data.current_month]):this.dom.$year.innerText=Number(this.data.current_decade)+"-"+(Number(this.data.current_decade)+9);this.$container.querySelectorAll(`.RollDate__calendar__${this.period}`).forEach(t=>{for(const e of JSON.parse(t.dataset.bind)){JSON.parse(t.dataset.bind).every(e=>Number(t.dataset[e])===this.data[`current_${e}`])?t.classList.add(`RollDate__calendar__${this.period}--active`):t.classList.remove(`RollDate__calendar__${this.period}--active`)}})}#ct(){if("popup"===this.mode){const t=[];this.triggerSelector?(this.$openTrigger=document.querySelector(this.triggerSelector),t.push(this.$openTrigger)):this.$endInput?t.push(this.$startInput,this.$endInput):t.push(this.$trigger),this.#U=t.filter(Boolean),this.#U.forEach(t=>{t.addEventListener("click",t=>{t.stopPropagation(),this.open()}),"INPUT"===t.tagName&&t.addEventListener("focus",()=>this.open())}),this.#J=t=>{this.$container.contains(t.target)||this.#U.some(e=>e.contains(t.target))||this.close()},document.addEventListener("click",this.#J);(this.$endInput?[this.$startInput,this.$endInput]:[this.$trigger]).forEach(t=>{"INPUT"===t?.tagName&&t.addEventListener("input",t=>{this.#Dt(t.target.value)})})}this.scroll=new u(this.dom.$body,{dominant:()=>{const t=this.observe.dominant();if(t)for(const s of Object.keys(t))if(this.data[`current_${s}`]!==t[s]){(t.hasOwnProperty("year")||t.hasOwnProperty("month"))&&(this.data.current_year=t.year,this.data.current_month=t.month,this.data.current_decade=e(t.year)),t.hasOwnProperty("decade")&&(this.data.current_decade=t.decade),a(!1!==this.options.hapticFeedback),this.#pt();break}},updatePeriod:t=>this.virtualizer.update(t)}),this.dom.$type_switcher.addEventListener("click",t=>{t.preventDefault(),t.stopPropagation(),this.#gt(++this.#q)}),this.dom.$body.addEventListener("click",t=>{t.preventDefault(),t.stopPropagation();const s=t.target.closest("[data-click]"),i=t.target.closest("[data-day]");if(s){if(s.classList.contains("RollDate__calendar__month--disabled")||s.classList.contains("RollDate__calendar__year--disabled"))return;this.data.current_month=Number(s.dataset.month),this.data.current_year=Number(s.dataset.year),this.data.current_decade=e(this.data.current_year);const t=s.dataset.click;this.#gt(this.#W.indexOf(t))}if(i){if(i.classList.contains("RollDate__calendar__day--disabled"))return;const t=this.#at(new Date(Number(i.dataset.year),Number(i.dataset.month),Number(i.dataset.day)));if("single"===this.options.selectType&&(this.$container.querySelectorAll("[data-day]").forEach(t=>{t.classList.remove("RollDate__calendar__day--selected")}),i.classList.add("RollDate__calendar__day--selected"),this.#B=[t],this.options.selectDate(t),this.#it(),"popup"===this.mode&&this.options.closeOnSelect&&this.close()),"range"===this.options.selectType){const e=2===this.#B.length&&t.getTime()>=this.#B[0].getTime()&&t.getTime()<=this.#B[1].getTime();if(2!==this.#B.length||e||this.#yt(),0===this.#B.length)this.#B=[t],i.classList.add("RollDate__calendar__day--range-first");else{const e=this.#B[0];t.getTime()>e.getTime()?(this.#B=[e,t],this.$container.querySelectorAll("[data-day]").forEach(s=>{const i=new Date(Number(s.dataset.year),Number(s.dataset.month),Number(s.dataset.day)).getTime();i===e.getTime()?s.classList.add("RollDate__calendar__day--range-first"):i===t.getTime()?s.classList.add("RollDate__calendar__day--range-last"):i>e.getTime()&&i<t.getTime()&&s.classList.add("RollDate__calendar__day--range-selected")})):t.getTime()<e.getTime()&&(this.#B=[t],i.classList.add("RollDate__calendar__day--range-first"),this.$container.querySelector('.RollDate__calendar__day--range-first:not([data-day="'+t.getDate()+'"])')?.classList.remove("RollDate__calendar__day--range-first"))}this.options.selectDate([...this.#B]),this.#it(),"popup"===this.mode&&2===this.#B.length&&this.options.closeOnSelect&&this.close()}if("multi"===this.options.selectType){this.#B.some(e=>e.getTime()===t.getTime())?(this.#B=this.#B.filter(e=>e.getTime()!==t.getTime()),i.classList.remove("RollDate__calendar__day--selected")):(this.#B.push(t),i.classList.add("RollDate__calendar__day--selected")),this.options.selectDate(this.#B),this.#it(),"popup"===this.mode&&this.options.closeOnSelect&&this.close()}}this.scroll.resetMinScroll()}),this.dom.$body.addEventListener("mousemove",t=>{const e=t.target.closest("[data-day]");if(!e)return;if(e.classList.contains("RollDate__calendar__day--disabled"))return;const s=new Date(Number(e.dataset.year),Number(e.dataset.month),Number(e.dataset.day));this.options.onHoverDate(s,{period:this.period,selectedDates:[...this.#B]})}),this.dom.$body.addEventListener("mouseleave",()=>{this.options.onHoverDate(null,{period:this.period,selectedDates:[...this.#B]})}),this.dom.$page_switcher.forEach(t=>{t.addEventListener("click",t=>{t.preventDefault(),t.stopPropagation();const s=t.currentTarget?.dataset?.direction;if("prev"!==s&&"next"!==s)return;const i="prev"===s?-1:1,n=this.options.minDate.getFullYear(),o=this.options.maxDate.getFullYear();if("day"===this.period){const t=new Date(this.data.current_year,this.data.current_month,1),s=new Date(this.data.current_year,this.data.current_month+i,1),a=new Date(this.options.minDate.getFullYear(),this.options.minDate.getMonth(),1),n=new Date(this.options.maxDate.getFullYear(),this.options.maxDate.getMonth(),1);if(s<a||s>n)return;if(s.getTime()===t.getTime())return;this.data.current_year=s.getFullYear(),this.data.current_month=s.getMonth(),this.data.current_decade=e(this.data.current_year)}else if("month"===this.period){const t=this.data.current_year+i;if(t<n||t>o)return;this.data.current_year=t,this.data.current_decade=e(t)}else if("year"===this.period){const t=e(this.data.current_year)+10*i,s=e(n),a=e(o);if(t<s||t>a)return;this.data.current_year=t,this.data.current_decade=t}a(!1!==this.options.hapticFeedback),this.#ut(this.#q)})})}#gt(t){const e=this.period;if(t>2)t=this.period=2;else{this.scroll.resetMinScroll(),this.period=t,this.#ut(this.period);for(const t of this.#W)this.$container.classList.remove("RollDate__calendar__type--"+t+"s");this.$container.classList.add("RollDate__calendar__type--"+this.#W[t]+"s"),this.options.onViewChange({from:e,to:this.period,current:{year:this.data.current_year,month:this.data.current_month,decade:this.data.current_decade}})}}#_t(t){2!==t&&(this.dom.$years_block.innerHTML=""),1!==t&&(this.dom.$months_block.innerHTML=""),0!==t&&(this.dom.$days_block.innerHTML="")}#ft(){requestAnimationFrame(()=>{this.scroll.checkMinScroll();const t=this.options.startDate,e=this.$container.querySelector(`[data-year="${t.getFullYear()}"][data-month="${t.getMonth()}"]`);if(e){const t=this.dom.$body.querySelector(".RollDate__calendar__scrollblock").getBoundingClientRect(),s=-(e.getBoundingClientRect().top-t.top);this.scroll.offset=s}})}get period(){return this.#W[this.#q]}set period(t){this.#q=t}get selectedDates(){return this.#B}setDisabledDates(t=[]){this.options.disabledDates=Array.isArray(t)?t:[],this.#j=this.#Q(this.options.disabledDates),this.#st(),this.#ut(this.#q)}disableDate(t){const e=this.#K(t);e&&(this.#j.add(this.#X(e)),this.options.disabledDates=[...this.#j].map(t=>new Date(t)),this.#st(),this.#ut(this.#q))}enableDate(t){const e=this.#K(t);e&&(this.#j.delete(this.#X(e)),this.options.disabledDates=[...this.#j].map(t=>new Date(t)),this.#ut(this.#q))}isDateDisabled(t){const e=this.#K(t);return!!e&&this.#tt(e)}#yt(){this.#B=[],this.$container.querySelectorAll("[data-day]").forEach(t=>{t.classList.remove("RollDate__calendar__day--range-first","RollDate__calendar__day--range-last","RollDate__calendar__day--range-selected")})}#bt(){this.#B=[],this.$container.querySelectorAll("[data-day].RollDate__calendar__day--selected").forEach(t=>t.classList.remove("RollDate__calendar__day--selected"))}#it(){if("popup"!==this.mode)return;const t=t=>this.#nt(t);if(this.$endInput)this.#B.length>=1?this.$startInput.value=t(this.#B[0]):this.$startInput.value="",2===this.#B.length?this.$endInput.value=t(this.#B[1]):this.$endInput.value="";else{const e=this.$trigger;"INPUT"===e.tagName&&("single"===this.options.selectType&&this.#B.length>0?e.value=t(this.#B[0]):"range"===this.options.selectType?1===this.#B.length?e.value=`${t(this.#B[0])} - `:2===this.#B.length?e.value=`${t(this.#B[0])} - ${t(this.#B[1])}`:e.value="":"multi"===this.options.selectType&&this.#B.length>0?e.value=this.#B.map(t).join(", "):e.value="")}}#Dt(t){if(!t)return this.#B=[],void this.#ut(this.#q);try{if("single"===this.options.selectType){const e=n(t,this.options.dateFormat);e&&!this.#tt(e)&&(this.#B=[e],this.data.current_year=e.getFullYear(),this.data.current_month=e.getMonth(),this.#ut(this.#q))}else if("range"===this.options.selectType){const e=t.split(/\s+-\s+/).map(t=>t.trim()).filter(t=>t).map(t=>n(t,this.options.dateFormat)).filter(t=>!this.#tt(t)).filter(t=>t);e.length>0&&(this.#B=e,e.length>=1&&(this.data.current_year=e[0].getFullYear(),this.data.current_month=e[0].getMonth()),this.#ut(this.#q))}else if("multi"===this.options.selectType){const e=t.split(",").map(t=>t.trim()).filter(t=>t).map(t=>n(t,this.options.dateFormat)).filter(t=>!this.#tt(t)).filter(t=>t);e.length>0&&(this.#B=e,this.data.current_year=e[0].getFullYear(),this.data.current_month=e[0].getMonth(),this.#ut(this.#q))}}catch(e){console.warn("Invalid date format:",t)}}open(){"popup"===this.mode&&this.#dt();const t="none"!==this.$container.style.display;this.$container.style.display="block","popup"===this.mode?(this.#mt(),this.#z?(this.#ft(),this.#z=!1):this.#ut(this.#q)):this.dom?.$body||this.#ut(this.#q),t||this.options.onOpen({period:this.period,selectedDates:[...this.#B]})}close(){const t="none"!==this.$container.style.display;if(this.$container.style.display="none","popup"===this.mode){(this.$endInput?[this.$startInput,this.$endInput]:this.$openTrigger?[this.$openTrigger]:[this.$trigger]).forEach(t=>{t&&"function"==typeof t.blur&&t.blur()})}t&&this.options.onClose({period:this.period,selectedDates:[...this.#B]})}selectToday(){const t=new Date,s=new Date(t.getFullYear(),t.getMonth(),t.getDate());if(this.#tt(s))return;this.data.current_year=t.getFullYear(),this.data.current_month=t.getMonth(),this.data.current_decade=e(t.getFullYear());const i=this.#at(t);if("single"===this.options.selectType)this.#B=[i];else if("range"===this.options.selectType)this.#B=[i];else if("multi"===this.options.selectType){this.#B.some(t=>t.getTime()===i.getTime())||this.#B.push(i)}this.#ut(this.#q),this.#et(),this.#it(),"popup"===this.mode&&this.options.closeOnSelect&&"single"===this.options.selectType&&this.close()}clearSelection(){"range"===this.options.selectType?this.#yt():"multi"===this.options.selectType?this.#bt():this.#B=[],this.#ut(this.#q),this.#et(),this.#it()}destroy(){this.#J&&(document.removeEventListener("click",this.#J),this.#J=null),g.#V.delete(this),this.observe.disconnect(),this.scroll?.destroy(),this.timePicker?.destroy(),this.$container.parentNode&&this.$container.parentNode.removeChild(this.$container)}}return"undefined"!=typeof window&&(window.RollDate=g),g}();
|