timepicker-ui 3.0.0 → 3.1.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/dist/index.js CHANGED
@@ -1,75 +1,77 @@
1
- var se=(a,e)=>({...e,...a}),re=()=>{let a=document.createElement("div");a.className="timepicker-ui-measure",document.body.appendChild(a);let e=a.getBoundingClientRect().width-a.clientWidth;return document.body.removeChild(a),e},ne=a=>a*(Math.PI/180),G=(a,e)=>{let{touches:t}=a,{clientX:i,clientY:s}=a;if(!e)return;let{left:r,top:o}=e.getBoundingClientRect(),n={x:0,y:0};if(t===void 0)n={x:i-r,y:s-o};else if(t!==void 0&&t.length>0&&Object.keys(t).length>0){let{clientX:c,clientY:u}=t[0];n={x:c-r,y:u-o}}if(!(Object.keys(n).length===0&&n.constructor===Object))return n},he=(a,e)=>Math.round(a/e)*e,p=(a,e)=>a?a.classList.contains(e):!1;var _=(a,e,t,i,s)=>{if(!a)return;let r=new CustomEvent(t,{detail:i,bubbles:!0,cancelable:!0});try{if(a.dispatchEvent(r)&&e!==t){let n=new CustomEvent(e,{detail:i,bubbles:!0,cancelable:!0});a.dispatchEvent(n)}}catch(o){console.warn(`TimepickerUI: Error dispatching event ${t}:`,o)}if(s&&typeof s=="function")try{s(i)}catch(o){console.warn(`TimepickerUI: Error in ${t} callback:`,o)}},oe=()=>/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent),z=(a,e,t)=>he(a,e*t),ae=a=>{if(!a)return;let e=JSON.parse(JSON.stringify(a)),t=Object.keys(e);return Object.values(e).reduce((i,s,r)=>(Number(s)?i[t[r]]=Number(s):s==="true"||s==="false"?i[t[r]]=JSON.parse(s):i[t[r]]=s,i),{})},$=(a,e)=>Array.from({length:Number(e)-Number(a)+1},(t,i)=>Number(a)+i),j=(a,e)=>Array.from({length:Number(e)-Number(a)+1},(t,i)=>Number(e)-i).reverse(),D=a=>{a&&typeof a=="function"&&a()},K=(a="")=>{let e=a.replace(/(AM|PM|am|pm)/,r=>` ${r}`),t=new Date(`September 20, 2000 ${e}`),i=t.getHours().toString().padStart(2,"0"),s=t.getMinutes().toString().padStart(2,"0");return`${i}:${s}`},ce=()=>typeof window<"u"&&window.crypto&&typeof window.crypto.randomUUID=="function"?window.crypto.randomUUID():"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,a=>{let e=Math.random()*16|0;return(a==="x"?e:e&3|8).toString(16)});var y=(a,e,t,i)=>{let s={hour:"12",minutes:"00",type:e==="24h"?void 0:"PM"};if(!a)return s;let r=a.value.trim();if(!t&&r==="")return s;if(typeof t=="boolean"&&t){let l=new Date,[g,E]=l.toLocaleTimeString().split(":"),h=Number(g)<=9?`0${Number(g)}`:g;if(/[a-z]/i.test(E)&&e==="12h"){let[T,C]=E.split(" ");return{hour:h,minutes:T,type:C}}return{hour:h,minutes:E,type:void 0}}if(typeof t=="object"){let{time:l,locales:g,preventClockType:E}=t,h=l??new Date;if(E&&i){let[M,A]=new Date(h).toLocaleTimeString().split(":");if(/[a-z]/i.test(A)){let[X,de]=A.split(" ");return{hour:M,minutes:X,type:de}}return{hour:Number(M)<=9?`0${Number(M)}`:M,minutes:A,type:void 0}}let[T,C]=new Date(h).toLocaleTimeString(g,{timeStyle:"short"}).split(":"),I=Number(T)<=9?`0${Number(T)}`:T;if(/[a-z]/i.test(C)&&e==="12h"){let[M,A]=C.split(" ");return{hour:I,minutes:M,type:A}}if(e==="12h"){let[M,A]=new Date(`1970-01-01T${T}:${C}Z`).toLocaleTimeString("en-US",{timeZone:"UTC",hour12:!0,hour:"numeric",minute:"numeric"}).split(":"),[te,X]=A.split(" ");return{hour:Number(M)<=9?`0${Number(M)}`:M,minutes:te,type:X}}return{hour:I,minutes:C,type:void 0}}let[o,n]=r.split(" "),[c="",u=""]=o.split(":"),v=c.replace(/\D/g,""),d=u.replace(/\D/g,""),b={hour:v.padStart(2,"0"),minutes:d.padStart(2,"0"),type:e==="12h"?n:void 0};if(v.length>2||d.length>2)return{...b,error:"Invalid input: too many digits.",currentHour:c,currentMin:u};if(/[a-z]/i.test(o))return{...b,error:"Input contains invalid letters."};if(r.includes(" ")&&(!n||r.length>8||n!=="AM"&&n!=="PM"))return{...b,error:"Invalid AM/PM format or length.",currentLength:r.length,currentType:n};let f=Number(v),m=Number(d);if(e==="12h"){if(f<1||f>12||m<0||m>59||n!=="AM"&&n!=="PM")return{...b,error:"Invalid 12h time.",currentHour:f,currentMin:m,currentType:n}}else if(f<0||f>23||m<0||m>59)return{...b,error:"Invalid 24h time.",currentHour:f,currentMin:m};return b},L=(a,e,t)=>{let i=Number(a);if(Number.isNaN(i))return!1;switch(e){case"hour":return t==="24h"?i>=0&&i<=23:i>0&&i<=12;case"minutes":return i>=0&&i<=59;default:return}};var Q={amLabel:"AM",animation:!0,appendModalSelector:"",backdrop:!0,cancelLabel:"CANCEL",editable:!1,enableScrollbar:!1,enableSwitchIcon:!1,mobileTimeLabel:"Enter Time",focusInputAfterCloseModal:!1,hourMobileLabel:"Hour",iconTemplate:'<i class="material-icons timepicker-ui-keyboard-icon">keyboard</i>',iconTemplateMobile:'<i class="material-icons timepicker-ui-keyboard-icon">schedule</i>',incrementHours:1,incrementMinutes:1,minuteMobileLabel:"Minute",mobile:!1,okLabel:"OK",pmLabel:"PM",timeLabel:"Select Time",switchToMinutesAfterSelectHour:!1,theme:"basic",clockType:"12h",disabledTime:void 0,currentTime:void 0,focusTrap:!0,delayHandler:300,inline:void 0,cssClass:void 0};var ee="timepicker-ui",ke="mousedown mouseup mousemove mouseleave mouseover",ve="touchstart touchmove touchend",O=`${ke} ${ve}`,k="active";var Y=(a,e)=>{let t;return(...i)=>{clearTimeout(t),t=setTimeout(()=>{a(...i)},e)}};var Z=["00","13","14","15","16","17","18","19","20","21","22","23"],w=["12","1","2","3","4","5","6","7","8","9","10","11"],x=["00","05","10","15","20","25","30","35","40","45","50","55"],le=(a,e)=>{let{iconTemplate:t,timeLabel:i,amLabel:s,pmLabel:r,cancelLabel:o,okLabel:n,enableSwitchIcon:c,animation:u,clockType:v,editable:d,theme:b}=a;return`
2
- <div class="timepicker-ui-modal normalize ${b}" role="dialog" data-owner-id="${e}" style='transition:${u?"opacity 0.15s linear":"none"}'>
1
+ var fe=Object.defineProperty;var De=Object.getOwnPropertyDescriptor;var Se=Object.getOwnPropertyNames;var $e=Object.prototype.hasOwnProperty;var Ue=(n,e)=>()=>(n&&(e=n(n=0)),e);var Fe=(n,e)=>{for(var t in e)fe(n,t,{get:e[t],enumerable:!0})},Oe=(n,e,t,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let r of Se(e))!$e.call(n,r)&&r!==t&&fe(n,r,{get:()=>e[r],enumerable:!(i=De(e,r))||i.enumerable});return n};var Pe=n=>Oe(fe({},"__esModule",{value:!0}),n);var we={};Fe(we,{getMobileModalTemplate:()=>Re,getModalTemplate:()=>qe,getNumberOfHours12:()=>q,getNumberOfHours24:()=>V,getNumberOfMinutes:()=>R});var V,q,R,qe,Re,ve=Ue(()=>{"use strict";V=["00","13","14","15","16","17","18","19","20","21","22","23"],q=["12","1","2","3","4","5","6","7","8","9","10","11"],R=["00","05","10","15","20","25","30","35","40","45","50","55"],qe=(n,e)=>{let{iconTemplate:t,timeLabel:i,amLabel:r,pmLabel:s,cancelLabel:a,okLabel:o,enableSwitchIcon:c,animation:l,clockType:h,editable:p,theme:v}=n;return`
2
+ <div class="timepicker-ui-modal normalize ${v}" role="dialog" aria-modal="true" aria-labelledby="timepicker-ui-label-${e}" data-owner-id="${e}" style='transition:${l?"opacity 0.15s linear":"none"}'>
3
3
  <div class="timepicker-ui-wrapper" tabindex="0">
4
4
  <div class="timepicker-ui-header">
5
- <div class="timepicker-ui-select-time">${i}</div>
6
- <div class="timepicker-ui-wrapper-time ${v==="24h"?"timepicker-ui-wrapper-time-24h":""}">
7
- <input name="hour" ${d?"":"readonly"} class="timepicker-ui-hour" tabindex="0" type="number" min="0" max="${v==="12h"?"12":"23"}" />
8
- <div class="timepicker-ui-dots">
5
+ <div class="timepicker-ui-select-time" id="timepicker-ui-label-${e}">${i}</div>
6
+ <div class="timepicker-ui-wrapper-time ${h==="24h"?"timepicker-ui-wrapper-time-24h":""}" role="group" aria-label="${i}">
7
+ <input name="hour" ${p?"":"readonly"} class="timepicker-ui-hour" tabindex="0" type="number" min="0" max="${h==="12h"?"12":"23"}" aria-label="Hour" role="spinbutton" aria-valuenow="12" />
8
+ <div class="timepicker-ui-dots" aria-hidden="true">
9
9
  <span></span>
10
10
  <span></span>
11
11
  </div>
12
- <input name="minutes" ${d?"":"readonly"} class="timepicker-ui-minutes" tabindex="0" type="number" min="0" max="59" />
12
+ <input name="minutes" ${p?"":"readonly"} class="timepicker-ui-minutes" tabindex="0" type="number" min="0" max="59" aria-label="Minute" role="spinbutton" aria-valuenow="0" />
13
13
  </div>
14
- ${v!=="24h"?`
15
- <div class="timepicker-ui-wrapper-type-time">
16
- <div class="timepicker-ui-type-mode timepicker-ui-am" tabindex="0" role="button" data-type="AM">${s}</div>
17
- <div class="timepicker-ui-type-mode timepicker-ui-pm" tabindex="0" role="button" data-type="PM">${r}</div>
14
+ ${h!=="24h"?`
15
+ <div class="timepicker-ui-wrapper-type-time" role="group" aria-label="Time period">
16
+ <div class="timepicker-ui-type-mode timepicker-ui-am" tabindex="0" role="button" aria-label="${r}" aria-pressed="false" data-type="AM">${r}</div>
17
+ <div class="timepicker-ui-type-mode timepicker-ui-pm" tabindex="0" role="button" aria-label="${s}" aria-pressed="false" data-type="PM">${s}</div>
18
18
  </div>
19
19
  `:""}
20
20
  </div>
21
21
  <div class="timepicker-ui-wrapper-landspace">
22
22
  <div class="timepicker-ui-body">
23
- <div class="timepicker-ui-clock-face">
24
- <div class="timepicker-ui-dot"></div>
25
- <div class="timepicker-ui-clock-hand">
23
+ <div class="timepicker-ui-clock-face" role="group" aria-label="Clock face">
24
+ <div class="timepicker-ui-dot" aria-hidden="true"></div>
25
+ <div class="timepicker-ui-clock-hand" aria-hidden="true">
26
26
  <div class="timepicker-ui-circle-hand"></div>
27
27
  </div>
28
- <div class="timepicker-ui-tips-wrapper"></div>
29
- ${v==="24h"?'<div class="timepicker-ui-tips-wrapper-24h"></div>':""}
28
+ <div class="timepicker-ui-tips-wrapper" role="listbox" aria-label="Time values"></div>
29
+ ${h==="24h"?'<div class="timepicker-ui-tips-wrapper-24h" role="listbox" aria-label="24-hour time values"></div>':""}
30
30
  </div>
31
31
  </div>
32
32
  <div class="timepicker-ui-footer">
33
33
  ${c?`
34
- <div class="timepicker-ui-keyboard-icon-wrapper" tabindex="0" role="button" aria-pressed="false" data-view="desktop">
34
+ <div class="timepicker-ui-keyboard-icon-wrapper" tabindex="0" role="button" aria-pressed="false" aria-label="Toggle keyboard mode" data-view="desktop">
35
35
  ${t}
36
36
  </div>`:""}
37
37
  <div class="timepicker-ui-wrapper-btn" >
38
- <div class="timepicker-ui-cancel-btn" tabindex="0" role="button" aria-pressed="false">${o}</div>
39
- <div class="timepicker-ui-ok-btn" tabindex="0" role="button" aria-pressed="false">${n}</div>
38
+ <div class="timepicker-ui-cancel-btn" tabindex="0" role="button" aria-pressed="false" aria-label="${a}">${a}</div>
39
+ <div class="timepicker-ui-ok-btn" tabindex="0" role="button" aria-pressed="false" aria-label="${o}">${o}</div>
40
40
  </div>
41
41
  </div>
42
42
  </div>
43
- </div>
44
- </div>`},me=(a,e)=>{let{mobileTimeLabel:t,amLabel:i,pmLabel:s,cancelLabel:r,okLabel:o,iconTemplateMobile:n,minuteMobileLabel:c,hourMobileLabel:u,enableSwitchIcon:v,animation:d,clockType:b,theme:f}=a;return`
45
- <div class="timepicker-ui-modal normalize mobile ${f}" role="dialog" data-owner-id="${e}" style='transition:${d?"opacity 0.15s linear":"none"}'>
43
+ </div>
44
+ <div class="timepicker-announcer sr-only" role="status" aria-live="polite" aria-atomic="true"></div>
45
+ </div>`},Re=(n,e)=>{let{mobileTimeLabel:t,amLabel:i,pmLabel:r,cancelLabel:s,okLabel:a,iconTemplateMobile:o,minuteMobileLabel:c,hourMobileLabel:l,enableSwitchIcon:h,animation:p,clockType:v,theme:g}=n;return`
46
+ <div class="timepicker-ui-modal normalize mobile ${g}" role="dialog" aria-modal="true" aria-labelledby="timepicker-ui-label-mobile-${e}" data-owner-id="${e}" style='transition:${p?"opacity 0.15s linear":"none"}'>
46
47
  <div class="timepicker-ui-wrapper mobile" tabindex="0">
47
48
  <div class="timepicker-ui-header mobile">
48
- <div class="timepicker-ui-select-time mobile">${t}</div>
49
- <div class="timepicker-ui-wrapper-time mobile">
50
- <input class="timepicker-ui-hour mobile" tabindex="0" type="number" min="0" max="${b==="12h"?"12":"23"}" />
51
- <div class="timepicker-ui-hour-text mobile">${u}</div>
52
- <div class="timepicker-ui-dots mobile">
49
+ <div class="timepicker-ui-select-time mobile" id="timepicker-ui-label-mobile-${e}">${t}</div>
50
+ <div class="timepicker-ui-wrapper-time mobile" role="group" aria-label="${t}">
51
+ <input class="timepicker-ui-hour mobile" tabindex="0" type="number" min="0" max="${v==="12h"?"12":"23"}" aria-label="${l}" role="spinbutton" aria-valuenow="12" />
52
+ <div class="timepicker-ui-hour-text mobile">${l}</div>
53
+ <div class="timepicker-ui-dots mobile" aria-hidden="true">
53
54
  <span></span>
54
55
  <span></span>
55
56
  </div>
56
57
  <div class="timepicker-ui-minute-text mobile">${c}</div>
57
- <input class="timepicker-ui-minutes mobile" tabindex="0" type="number" min="0" max="59" />
58
+ <input class="timepicker-ui-minutes mobile" tabindex="0" type="number" min="0" max="59" aria-label="${c}" role="spinbutton" aria-valuenow="0" />
58
59
  </div>
59
- ${b!=="24h"?`<div class="timepicker-ui-wrapper-type-time mobile">
60
- <div class="timepicker-ui-type-mode timepicker-ui-am mobile" data-type="AM" tabindex="0">${i}</div>
61
- <div class="timepicker-ui-type-mode timepicker-ui-pm mobile" data-type="PM" tabindex="0">${s}</div>
60
+ ${v!=="24h"?`<div class="timepicker-ui-wrapper-type-time mobile" role="group" aria-label="Time period">
61
+ <div class="timepicker-ui-type-mode timepicker-ui-am mobile" data-type="AM" tabindex="0" role="button" aria-label="${i}" aria-pressed="false">${i}</div>
62
+ <div class="timepicker-ui-type-mode timepicker-ui-pm mobile" data-type="PM" tabindex="0" role="button" aria-label="${r}" aria-pressed="false">${r}</div>
62
63
  </div>`:""}
63
64
  </div>
64
65
  <div class="timepicker-ui-footer mobile" data-view="mobile">
65
- ${v?`
66
- <div class="timepicker-ui-keyboard-icon-wrapper mobile" role="button" aria-pressed="false" data-view="desktop" tabindex="0">
67
- ${n}
66
+ ${h?`
67
+ <div class="timepicker-ui-keyboard-icon-wrapper mobile" role="button" aria-pressed="false" aria-label="Toggle keyboard mode" data-view="desktop" tabindex="0">
68
+ ${o}
68
69
  </div>`:""}
69
70
  <div class="timepicker-ui-wrapper-btn mobile">
70
- <div class="timepicker-ui-cancel-btn mobile" role="button" aria-pressed="false" tabindex="0">${r}</div>
71
- <div class="timepicker-ui-ok-btn mobile" role="button" aria-pressed="false" tabindex="0">${o}</div>
71
+ <div class="timepicker-ui-cancel-btn mobile" role="button" aria-pressed="false" aria-label="${s}" tabindex="0">${s}</div>
72
+ <div class="timepicker-ui-ok-btn mobile" role="button" aria-pressed="false" aria-label="${a}" tabindex="0">${a}</div>
72
73
  </div>
73
74
  </div>
74
- </div>
75
- </div>`};var H=class{array;classToAdd;clockFace;tipsWrapper;theme;clockType;disabledTime;hour;constructor(e){this.array=e?.array,this.classToAdd=e?.classToAdd,this.clockFace=e?.clockFace,this.tipsWrapper=e?.tipsWrapper,this.theme=e?.theme,this.clockType=e?.clockType,this.disabledTime=e?.disabledTime,this.hour=e?.hour}clean=()=>{let e=this.tipsWrapper?.querySelectorAll("span.timepicker-ui-hour-time-12"),t=this.tipsWrapper?.querySelectorAll("span.timepicker-ui-minutes-time");this._removeClasses(e),this._removeClasses(t)};create=()=>{if(!this.clockFace||!this.array||!this.classToAdd||!this.tipsWrapper)return;let e=(this.clockFace.offsetWidth-32)/2,t=(this.clockFace.offsetHeight-32)/2,i=e-9;this.tipsWrapper.innerHTML="",this.array?.forEach((s,r)=>{let o=ne(r*(360/this.array.length)),n=document.createElement("span"),c=document.createElement("span");c.innerHTML=s,this.disabledTime&&(Array.isArray(this.disabledTime)&&this.disabledTime?.includes(s)&&(c.classList.add("timepicker-ui-tips-disabled"),n.classList.add("timepicker-ui-tips-disabled")),this.hour===this.disabledTime.removedStartedHour&&this.disabledTime?.startMinutes?.includes(s)&&(c.classList.add("timepicker-ui-tips-disabled"),n.classList.add("timepicker-ui-tips-disabled"),c.tabIndex=-1),this.hour===this.disabledTime.removedEndHour&&this.disabledTime?.endMinutes?.includes(s)&&(c.classList.add("timepicker-ui-tips-disabled"),n.classList.add("timepicker-ui-tips-disabled"),c.tabIndex=-1)),this.clockType==="24h"?(c.classList.add("timepicker-ui-value-tips-24h"),p(c,"timepicker-ui-tips-disabled")||(c.tabIndex=0)):(c.classList.add("timepicker-ui-value-tips"),p(c,"timepicker-ui-tips-disabled")||(c.tabIndex=0)),n.classList.add(this.classToAdd),this.theme==="crane-straight"&&(n.classList.add("crane-straight"),c.classList.add("crane-straight")),this.theme==="m3"&&(n.classList.add("m3"),c.classList.add("m3")),this.theme==="dark"&&(n.classList.add("dark"),c.classList.add("dark")),this.theme==="glassmorphic"&&(n.classList.add("glassmorphic"),c.classList.add("glassmorphic")),this.theme==="pastel"&&(n.classList.add("pastel"),c.classList.add("pastel")),this.theme==="ai"&&(n.classList.add("ai"),c.classList.add("ai")),this.theme==="cyberpunk"&&(n.classList.add("cyberpunk"),c.classList.add("cyberpunk")),n.style.left=`${e+Math.sin(o)*i-n.offsetWidth}px`,n.style.bottom=`${t+Math.cos(o)*i-n.offsetHeight}px`,n.appendChild(c),this.tipsWrapper?.appendChild(n)})};updateDisable=e=>{let t=this.tipsWrapper?.querySelectorAll("span.timepicker-ui-hour-time-12"),i=this.tipsWrapper?.querySelectorAll("span.timepicker-ui-minutes-time");if(this._removeClasses(t),this._removeClasses(i),e?.hoursToUpdate&&t&&this._addClassesWithIncludes(t,e.hoursToUpdate),e?.minutesToUpdate&&i){let{actualHour:s,removedEndHour:r,removedStartedHour:o,startMinutes:n,endMinutes:c}=e.minutesToUpdate;r===s&&c.length>0?this._addClassesWithIncludes(i,c):Number(s)>Number(o)&&Number(s)<Number(r)&&this._addClasses(i),o===s&&n.length>0?this._addClassesWithIncludes(i,n):Number(s)>Number(o)&&Number(s)<Number(r)&&this._addClasses(i)}if(e){let{amHours:s,pmHours:r,activeMode:o,startMinutes:n,endMinutes:c,removedAmHour:u,removedPmHour:v,actualHour:d}=e.minutesToUpdate;if(!s||!r)return;t&&(s&&o==="AM"&&this._addClassesWithIncludes(t,s),r&&o==="PM"&&this._addClassesWithIncludes(t,r)),i&&n&&c&&(o==="AM"&&(c[0]==="00"&&c.length===1&&n.length===0&&Number(d)>=Number(s[0])&&this._addClasses(i),n.length===0&&c.length>1&&Number(d)>=Number(u)&&this._addClasses(i),n.length>0&&c.length>1&&c[0]==="00"&&(Number(u)===Number(d)?this._addClassesWithIncludes(i,n):Number(d)>Number(u)&&this._addClasses(i)),c[0]==="00"&&c.length===1&&n.length>0&&(Number(u)===Number(d)?this._addClassesWithIncludes(i,n):Number(d)>Number(u)&&this._addClasses(i))),o==="PM"&&(d<Number(v)&&this._addClasses(i),d===v&&this._addClassesWithIncludes(i,c),c.length>0&&Number(d)===v-1&&this._addClassesWithIncludes(i,c)))}};_removeClasses=e=>{e?.forEach(({classList:t,children:i})=>{t.remove("timepicker-ui-tips-disabled"),i[0].classList.remove("timepicker-ui-tips-disabled"),i[0].tabIndex=0})};_addClasses=e=>{e?.forEach(({classList:t,children:i})=>{t.add("timepicker-ui-tips-disabled"),i[0].classList.add("timepicker-ui-tips-disabled"),i[0].tabIndex=-1})};_addClassesWithIncludes=(e,t)=>{e?.forEach(({classList:i,children:s,textContent:r})=>{t?.includes(r)&&(i.add("timepicker-ui-tips-disabled"),s[0].classList.add("timepicker-ui-tips-disabled"),s[0].tabIndex=-1)})}};var pe=a=>{if(!a)return;let{disabledTime:e,clockType:t}=a;if(!e||Object.keys(e).length<=0||e.constructor.name!=="Object")return;let{hours:i,interval:s,minutes:r}=e;if(s){delete e.hours,delete e.minutes;let[o,n]=s.toString().split("-"),{hour:c,minutes:u,type:v}=y({value:o.trimEnd()},t),{hour:d,minutes:b,type:f}=y({value:n.trimEnd().trimStart()},t),m=$(c,d).map(h=>h==="00"||Number(h)===0?`0${Number(h)}`:`${Number(h)}`),l=[],g=Number(u),E=Number(b);if(f===v)return g>0&&E<=0?(l.push(m[0],m[m.length-1]),m=m.slice(1,-1)):E<59&&E>0&&g<=0?(l.push(void 0,m[m.length-1]),m=m.slice(0,-1)):E>0&&g>0?(l.push(m[0],m[m.length-1]),m=m.slice(1,-1)):E===0&&g===0&&(l.push(void 0,m[m.length-1]),m.pop()),{value:{removedStartedHour:Number(l[0])<=9?`0${l[0]}`:l[0],removedEndHour:Number(l[1])<=9?`0${l[1]}`:l[1],rangeArrHour:m,isInterval:!0,startMinutes:$(u,59).map(h=>Number(h)<=9?`0${h}`:`${h}`),endMinutes:j(0,b).map(h=>Number(h)<=9?`0${h}`:`${h}`),endType:f,startType:v}};{let h=$(c,12).map(String),T=j(1,d).map(String),C=[],I=[];return g>0&&E<=0?(C.push(T[T.length-1]),I.push(h[0]),T.splice(-1,1),h.splice(0,1)):E<59&&E>0&&g<=0?(I.push(h[0]),C.push(T[T.length-1]),T.splice(-1,1)):E>0&&g>0?(C.push(T[T.length-1]),I.push(h[0]),T.splice(-1,1),h.splice(0,1)):E===0&&g===0&&(C.push(T[T.length-1]),I.push(h[0]),T.pop()),{value:{isInterval:!0,endType:f,startType:v,pmHours:T,amHours:h,startMinutes:Number(u)===0?[]:$(u,59).map(M=>Number(M)<=9?`0${M}`:`${M}`),endMinutes:j(0,b).map(M=>Number(M)<=9?`0${M}`:`${M}`),removedAmHour:Number(I[0])<=9?`0${I[0]}`:I[0],removedPmHour:Number(C[0])<=9?`0${C[0]}`:C[0]}}}}else return i?.forEach(o=>{if(t==="12h"&&Number(o)>12)throw new Error("The disabled hours value has to be less than 13");if(t==="24h"&&Number(o)>23)throw new Error("The disabled hours value has to be less than 24")}),r?.forEach(o=>{if(Number(o)>59)throw new Error("The disabled minutes value has to be less than 60")}),{value:{hours:i?.map(o=>o==="00"||Number(o)===0?`0${Number(o)}`:`${Number(o)}`),minutes:r?.map(o=>Number(o)<=9?`0${o}`:`${o}`)}}},N=(a,e,t,i)=>{if(a){if(Array.isArray(a)&&a.length>0)return!a.map(r=>L(r,e,t)).some(r=>r===!1);if(typeof a=="string"||typeof a=="number"){let s=L(a,e,t),r=i?.map(Number).includes(Number(a));return!!(s&&!r)}}},ue=(a,e,t,i)=>{let s=t?K(`${a}:${e} ${t}`.trim()):`${a}:${e}`.trim(),r,o;if(t){let[n,c]=i.trim().split("-").map(u=>u.trim());r=K(n),o=K(c)}else{let[n,c]=i.trim().split("-"),u=v=>v.trim().split(":").map(d=>Number(d)<=9?`0${Number(d)}`:d).join(":");r=u(n),o=u(c)}return s<r||s>o};var U=class{timepicker;constructor(e){this.timepicker=e}handleOpenOnClick=()=>{this.timepicker.openElement.forEach(e=>e?.addEventListener("click",()=>this.timepicker._eventsBundle()))};handleOpenOnEnterFocus=()=>{this.timepicker.input.addEventListener("keydown",({target:e,key:t})=>{e.disabled||t==="Enter"&&this.timepicker.open()})};handleCancelButton=()=>{this.timepicker.cancelButton.addEventListener("click",()=>{let e=y(this.timepicker.input,this.timepicker._options.clockType);_(this.timepicker._element,"cancel","timepicker:cancel",{...e,hourNotAccepted:this.timepicker.hour.value,minutesNotAccepted:this.timepicker.minutes.value,type:this.timepicker.activeTypeMode?.dataset.type,degreesHours:this.timepicker._degreesHours,degreesMinutes:this.timepicker._degreesMinutes},this.timepicker._options.onCancel),this.timepicker.close()()})};handleOkButton=()=>{this.timepicker.okButton?.addEventListener("click",()=>{let{clockType:e,disabledTime:t}=this.timepicker._options,i=L(this.timepicker.hour.value,"hour",e),s=L(this.timepicker.minutes.value,"minutes",e),r,o=N(this.timepicker.hour.value,"hour",e,t?.hours),n=N(this.timepicker.minutes.value,"minutes",e,t?.minutes);if(t?.interval&&(r=ue(this.timepicker.hour.value,this.timepicker.minutes.value,this.timepicker.activeTypeMode?.textContent,t.interval)),r===!1||i===!1||s===!1||o===!1||n===!1){(r===!1||!s||!n)&&this.timepicker.minutes.classList.add("invalid-value"),(r===!1||!i||!o)&&this.timepicker.hour.classList.add("invalid-value");return}this.timepicker.input.value=`${this.timepicker.hour.value}:${this.timepicker.minutes.value} ${this.timepicker._options.clockType==="24h"?"":this.timepicker.activeTypeMode?.dataset.type}`.trimEnd(),_(this.timepicker._element,"accept","timepicker:confirm",{hour:this.timepicker.hour.value,minutes:this.timepicker.minutes.value,type:this.timepicker.activeTypeMode?.dataset.type,degreesHours:this.timepicker._degreesHours,degreesMinutes:this.timepicker._degreesMinutes},this.timepicker._options.onConfirm),this.timepicker.close()()})};handleBackdropClick=()=>{this.timepicker.modalElement?.addEventListener("click",e=>{let t=e.target;if(!p(t,"timepicker-ui-modal"))return;let i=y(this.timepicker.input,this.timepicker._options.clockType);_(this.timepicker._element,"cancel","timepicker:cancel",{...i,hourNotAccepted:this.timepicker.hour.value,minutesNotAccepted:this.timepicker.minutes.value,type:this.timepicker.activeTypeMode?.dataset.type,degreesHours:this.timepicker._degreesHours,degreesMinutes:this.timepicker._degreesMinutes},this.timepicker._options.onCancel),this.timepicker.close()()})};getDestructuringObj(e){let{endMinutes:t,removedEndHour:i,removedStartedHour:s,startMinutes:r,pmHours:o,amHours:n,removedAmHour:c,removedPmHour:u}=this.timepicker._disabledTime.value;return e?{minutesToUpdate:{actualHour:this.timepicker.hour.value,pmHours:o,amHours:n,activeMode:this.timepicker.activeTypeMode?.textContent,startMinutes:r,endMinutes:t,removedAmHour:c,removedPmHour:u}}:{minutesToUpdate:{endMinutes:t,removedEndHour:i,removedStartedHour:s,actualHour:this.timepicker.hour.value,startMinutes:r}}}handleAmClick=()=>{this.timepicker._clickTouchEvents.forEach(e=>{this.timepicker.AM.addEventListener(e,t=>{if(t.target.classList.add(k),this.timepicker.PM.classList.remove(k),this.timepicker._options.clockType==="12h"&&this.timepicker._options.disabledTime?.interval){let s=new H({clockFace:this.timepicker.clockFace,tipsWrapper:this.timepicker.tipsWrapper,array:p(this.timepicker.hour,k)?w:x});this.timepicker._disabledTime?.value.startType===this.timepicker._disabledTime?.value.endType?setTimeout(()=>{this.timepicker._disabledTime?.value.startType===this.timepicker.activeTypeMode?.textContent?s.updateDisable({hoursToUpdate:this.timepicker._disabledTime?.value?.rangeArrHour,...this.getDestructuringObj()}):s.clean()},300):setTimeout(()=>{s.updateDisable({...this.getDestructuringObj(!0)})},300),s.updateDisable()}_(this.timepicker._element,"selectamtypemode","timepicker:select-am",{hour:this.timepicker.hour.value,minutes:this.timepicker.minutes.value,type:this.timepicker.activeTypeMode?.dataset.type,degreesHours:this.timepicker._degreesHours,degreesMinutes:this.timepicker._degreesMinutes},this.timepicker._options.onSelectAM)})})};handlePmClick=()=>{this.timepicker._clickTouchEvents.forEach(e=>{this.timepicker.PM.addEventListener(e,t=>{if(t.target.classList.add(k),this.timepicker.AM.classList.remove(k),this.timepicker._options.clockType==="12h"&&this.timepicker._options.disabledTime?.interval){let s=new H({clockFace:this.timepicker.clockFace,tipsWrapper:this.timepicker.tipsWrapper,array:p(this.timepicker.hour,k)?w:x});this.timepicker._disabledTime?.value.startType===this.timepicker._disabledTime?.value.endType?setTimeout(()=>{this.timepicker._disabledTime?.value.startType===this.timepicker.activeTypeMode?.textContent?s.updateDisable({hoursToUpdate:this.timepicker._disabledTime?.value?.rangeArrHour,...this.getDestructuringObj()}):s.clean()},300):setTimeout(()=>{s.updateDisable({...this.getDestructuringObj(!0)})},300)}_(this.timepicker._element,"selectpmtypemode","timepicker:select-pm",{hour:this.timepicker.hour.value,minutes:this.timepicker.minutes.value,type:this.timepicker.activeTypeMode?.dataset.type,degreesHours:this.timepicker._degreesHours,degreesMinutes:this.timepicker._degreesMinutes},this.timepicker._options.onSelectPM)})})};handleClasses24h=(e,t)=>{let i=e.target;this.timepicker.hourTips&&this.timepicker._options.clockType==="24h"&&(Number(i.textContent)>12||Number(i.textContent)===0?this.timepicker.clockManager.setCircleClockClasses24h():this.timepicker.clockManager.removeCircleClockClasses24h(),this.timepicker._options.mobile||this.timepicker.tipsWrapperFor24h?.classList.remove("timepicker-ui-tips-wrapper-24h-disabled")),!(!i||!t)&&(t.value=i.value.replace(/\D+/g,""),t.click())};handleHourEvents=()=>{this.timepicker._inputEvents.forEach(e=>{this.timepicker.hour?.addEventListener(e,t=>{let i=t.target;if(this.timepicker.clockFace!==null&&this.timepicker.animationManager.handleAnimationSwitchTipsMode(),this.timepicker._options.clockType==="24h"&&this.timepicker.clockFace!==null&&(Number(this.timepicker.hour.value)>12||this.timepicker.hour.value==="00"?this.timepicker.clockManager.setCircleClockClasses24h():this.timepicker.clockManager.removeCircleClockClasses24h(),this.timepicker._options.mobile||this.timepicker.tipsWrapperFor24h?.classList.remove("timepicker-ui-tips-wrapper-24h-disabled")),this.timepicker.clockManager.setHoursToClock(i.value),this.timepicker.minutes.classList.remove(k),this.timepicker.hour.classList.add(k),this.timepicker._options.clockType==="12h"&&this.timepicker._options.disabledTime?.interval){let s=new H({clockFace:this.timepicker.clockFace,tipsWrapper:this.timepicker.tipsWrapper,array:p(this.timepicker.hour,k)?w:x});this.timepicker._disabledTime?.value.startType===this.timepicker._disabledTime?.value.endType?setTimeout(()=>{this.timepicker._disabledTime?.value.startType===this.timepicker.activeTypeMode?.textContent?s.updateDisable({hoursToUpdate:this.timepicker._disabledTime?.value?.rangeArrHour,...this.getDestructuringObj()}):s.clean()},300):setTimeout(()=>{s.updateDisable({...this.getDestructuringObj(!0)})},300)}_(this.timepicker._element,"selecthourmode","timepicker:select-hour",{hour:this.timepicker.hour.value,minutes:this.timepicker.minutes.value,type:this.timepicker.activeTypeMode?.dataset.type,degreesHours:this.timepicker._degreesHours,degreesMinutes:this.timepicker._degreesMinutes},this.timepicker._options.onSelectHour),this.timepicker.clockFace!==null&&this.timepicker.circle.classList.remove("small-circle")})}),this.timepicker.hour?.addEventListener("blur",e=>this.handleClasses24h(e,this.timepicker.hour)),this.timepicker.hour?.addEventListener("focus",e=>this.handleClasses24h(e,this.timepicker.hour))};handleMinutesEvents=()=>{this.timepicker._inputEvents.forEach(e=>{this.timepicker.minutes.addEventListener(e,t=>{let i=t.target;if(this.timepicker.clockFace!==null&&(this.timepicker.animationManager.handleAnimationSwitchTipsMode(),this.timepicker.clockManager.setMinutesToClock(i.value)),this.timepicker._options.clockType==="24h"&&(this.timepicker.clockManager.removeCircleClockClasses24h(),this.timepicker._options.mobile||this.timepicker.tipsWrapperFor24h?.classList.add("timepicker-ui-tips-wrapper-24h-disabled")),this.timepicker.hour.classList.remove(k),this.timepicker.minutes.classList.add(k),this.timepicker._options.clockType==="12h"&&this.timepicker._options.disabledTime?.interval){let s=new H({clockFace:this.timepicker.clockFace,tipsWrapper:this.timepicker.tipsWrapper,array:p(this.timepicker.hour,k)?w:x});this.timepicker._disabledTime?.value.startType===this.timepicker._disabledTime?.value.endType?setTimeout(()=>{this.timepicker._disabledTime?.value.startType===this.timepicker.activeTypeMode?.textContent?s.updateDisable({hoursToUpdate:this.timepicker._disabledTime?.value?.rangeArrHour,...this.getDestructuringObj()}):s.clean()},300):setTimeout(()=>{s.updateDisable({...this.getDestructuringObj(!0)})},300)}_(this.timepicker._element,"selectminutemode","timepicker:select-minute",{hour:this.timepicker.hour.value,minutes:this.timepicker.minutes.value,type:this.timepicker.activeTypeMode?.dataset.type,degreesHours:this.timepicker._degreesHours,degreesMinutes:this.timepicker._degreesMinutes},this.timepicker._options.onSelectMinute)})}),this.timepicker.minutes?.addEventListener("blur",e=>this.handleClasses24h(e,this.timepicker.minutes)),this.timepicker.minutes?.addEventListener("focus",e=>this.handleClasses24h(e,this.timepicker.minutes))};handleEventToMoveHand=e=>{let{target:t,type:i,touches:s}=e,r=t,{incrementMinutes:o,incrementHours:n,switchToMinutesAfterSelectHour:c}=this.timepicker._options;if(!G(e,this.timepicker.clockFace))return;let u=G(e,this.timepicker.clockFace),v=this.timepicker.clockFace.offsetWidth/2,d=u&&Math.atan2(u.y-v,u.x-v);if(i==="mouseup"||i==="touchend"){this.timepicker._isTouchMouseMove=!1,c&&(p(r,"timepicker-ui-value-tips")||p(r,"timepicker-ui-value-tips-24h")||p(r,"timepicker-ui-tips-wrapper"))&&this.timepicker.minutes.click();return}if((i==="mousedown"||i==="mousemove"||i==="touchmove"||i==="touchstart")&&(i==="mousedown"||i==="touchstart"||i==="touchmove")&&((p(r,"timepicker-ui-clock-face")||p(r,"timepicker-ui-circle-hand")||p(r,"timepicker-ui-hour-time-12")||p(r,"timepicker-ui-minutes-time")||p(r,"timepicker-ui-clock-hand")||p(r,"timepicker-ui-value-tips")||p(r,"timepicker-ui-value-tips-24h")||p(r,"timepicker-ui-tips-wrapper")||p(r,"timepicker-ui-tips-wrapper-24h"))&&!p(r,"timepicker-ui-tips-disabled")?(e.preventDefault(),this.timepicker._isTouchMouseMove=!0):this.timepicker._isTouchMouseMove=!1),!this.timepicker._isTouchMouseMove)return;if(this.timepicker.minutesTips!==null){this.timepicker.minutes.classList.add(k);let m=d&&z(Math.trunc(d*180/Math.PI)+90,o,6);if(m===void 0)return;let l;if(m<0?(l=Math.round(360+m/6)%60,m=360+Math.round(m/6)*6):(l=Math.round(m/6)%60,m=Math.round(m/6)*6),this.timepicker._disabledTime?.value.isInterval){if(this.timepicker._disabledTime?.value.endType===this.timepicker._disabledTime?.value.startType){if(this.timepicker._disabledTime?.value?.endMinutes?.includes(l<=9?`0${l}`:`${l}`)&&this.timepicker.hour.value===this.timepicker._disabledTime?.value?.removedEndHour&&this.timepicker._disabledTime?.value.endType===this.timepicker.activeTypeMode?.textContent||this.timepicker._disabledTime?.value?.startMinutes?.includes(l<=9?`0${l}`:`${l}`)&&this.timepicker.hour.value===this.timepicker._disabledTime?.value?.removedStartedHour&&this.timepicker._disabledTime?.value.startType===this.timepicker.activeTypeMode?.textContent)return}else if(this.timepicker.activeTypeMode?.textContent===this.timepicker._disabledTime?.value.endType&&(this.timepicker._disabledTime?.value?.endMinutes?.includes(l<=9?`0${l}`:`${l}`)&&this.timepicker._disabledTime?.value.removedPmHour===this.timepicker.hour.value||this.timepicker._disabledTime?.value.pmHours.map(Number).includes(Number(this.timepicker.hour.value)))||this.timepicker.activeTypeMode?.textContent===this.timepicker._disabledTime?.value.startType&&(this.timepicker._disabledTime?.value?.startMinutes?.includes(l<=9?`0${l}`:`${l}`)&&this.timepicker._disabledTime?.value.removedAmHour===this.timepicker.hour.value||this.timepicker._disabledTime?.value.amHours.map(Number).includes(Number(this.timepicker.hour.value))))return}else if(this.timepicker._disabledTime?.value?.minutes?.includes(l<=9?`0${l}`:`${l}`))return;this.timepicker.minutes.value=l>=10?`${l}`:`0${l}`,this.timepicker.clockHand.style.transform=`rotateZ(${m}deg)`,this.timepicker._degreesMinutes=m,this.timepicker.clockManager.toggleClassActiveToValueTips(this.timepicker.minutes.value),this.timepicker.clockManager.removeBgColorToCirleWithMinutesTips(),this.timepicker.clockManager.setBgColorToCircleWithMinutesTips(),_(this.timepicker._element,"update","timepicker:update",{...y(this.timepicker.input,this.timepicker._options.clockType),degreesHours:this.timepicker._degreesHours,degreesMinutes:this.timepicker._degreesMinutes,eventType:i,type:this.timepicker.activeTypeMode?.dataset.type},this.timepicker._options.onUpdate)}let b=s?s[0]:void 0,f=s&&b?document.elementFromPoint(b.clientX,b.clientY):null;if(this.timepicker.hourTips!==null){if(this.timepicker.hour?.classList.add(k),!p(f||r,"timepicker-ui-value-tips-24h")&&!p(f||r,"timepicker-ui-tips-disabled")&&(p(f||r,"timepicker-ui-value-tips")||p(f||r,"timepicker-ui-tips-wrapper"))){let m=d&&z(Math.trunc(d*180/Math.PI)+90,n,30);if(this.timepicker._degreesHours=m,m===void 0)return;let l;m<0?(l=Math.round(360+m/30)%12,m=360+m):(l=Math.round(m/30)%12,(l===0||l>12)&&(l=12));let g=this.timepicker._disabledTime?.value.isInterval?"rangeArrHour":"hours";if(this.timepicker._disabledTime?.value.endType===this.timepicker._disabledTime?.value?.startType){if(typeof this.timepicker._disabledTime?.value?.endType=="string"){if(this.timepicker._disabledTime?.value?.endType===this.timepicker.activeTypeMode?.textContent&&this.timepicker._disabledTime?.value?.startType===this.timepicker.activeTypeMode?.textContent&&this.timepicker._disabledTime?.value[g]?.includes(l.toString()))return}else if(this.timepicker._disabledTime?.value[g]?.includes(l.toString()))return}else if(this.timepicker._disabledTime?.value.startType===this.timepicker.activeTypeMode?.textContent&&this.timepicker._disabledTime?.value.amHours.includes(l.toString())||this.timepicker._disabledTime?.value.endType===this.timepicker.activeTypeMode?.textContent&&this.timepicker._disabledTime?.value.pmHours.includes(l.toString()))return;this.timepicker.clockHand.style.transform=`rotateZ(${m}deg)`,this.timepicker.hour.value=l>9?`${l}`:`0${l}`,this.timepicker.clockManager.removeCircleClockClasses24h(),this.timepicker.clockManager.toggleClassActiveToValueTips(l)}if((p(f||r,"timepicker-ui-value-tips-24h")||p(f||r,"timepicker-ui-tips-wrapper-24h"))&&!p(f||r,"timepicker-ui-tips-disabled")){let m=d&&z(Math.trunc(d*180/Math.PI)+90,n,30);this.timepicker._degreesHours=m;let l;if(m===void 0)return;m<0?(l=Math.round(360+m/30)%24,m=360+m):(l=Math.round(m/30)+12,l===12&&(l="00"));let g=this.timepicker._disabledTime?.value.isInterval?"rangeArrHour":"hours";if(this.timepicker._disabledTime?.value[g]?.includes(l.toString()))return;this.timepicker.clockManager.setCircleClockClasses24h(),this.timepicker.clockHand.style.transform=`rotateZ(${m}deg)`,this.timepicker.hour.value=`${l}`,this.timepicker.clockManager.toggleClassActiveToValueTips(l)}_(this.timepicker._element,"update","timepicker:update",{...y(this.timepicker.input,this.timepicker._options.clockType),degreesHours:this.timepicker._degreesHours,degreesMinutes:this.timepicker._degreesMinutes,eventType:i,type:this.timepicker.activeTypeMode?.dataset.type},this.timepicker._options.onUpdate)}};handleMoveHand=()=>{this.timepicker._options.mobile||this.timepicker._isMobileView||O.split(" ").forEach(e=>{e==="touchstart"||e==="touchmove"||e==="touchend"?document.addEventListener(e,this.timepicker._mutliEventsMoveHandler,{passive:!1}):document.addEventListener(e,this.timepicker._mutliEventsMoveHandler,!1)})};handleClickOnHourMobile=()=>{document.addEventListener("mousedown",this.timepicker._eventsClickMobileHandler),document.addEventListener("touchstart",this.timepicker._eventsClickMobileHandler)};handlerClickHourMinutes=async e=>{if(!this.timepicker.modalElement)return;let{clockType:t,editable:i}=this.timepicker._options,s=e.target,r=L(this.timepicker.hour.value,"hour",t),o=L(this.timepicker.minutes.value,"minutes",t);i&&(!p(s,"timepicker-ui-hour")&&!p(s,"timepicker-ui-minutes")?r===!0&&o===!0&&(o&&this.timepicker.minutes.classList.remove("invalid-value"),r&&this.timepicker.hour?.classList.remove("invalid-value")):(r===!1||o===!1)&&(o||this.timepicker.minutes.classList.add("invalid-value"),r||this.timepicker.hour?.classList.add("invalid-value")))};handleIconChangeView=async()=>{this.timepicker._options.enableSwitchIcon&&(oe()?this.timepicker.keyboardClockIcon.addEventListener("touchstart",this.timepicker.configManager.handlerViewChange()):this.timepicker.keyboardClockIcon.addEventListener("click",this.timepicker.configManager.handlerViewChange()))};handleKeyPress=e=>{if(e.key==="Escape"&&this.timepicker.modalElement){let t=y(this.timepicker.input,this.timepicker._options.clockType);_(this.timepicker._element,"cancel","timepicker:cancel",{...t,hourNotAccepted:this.timepicker.hour.value,minutesNotAccepted:this.timepicker.minutes.value,type:this.timepicker.activeTypeMode?.dataset.type,degreesHours:this.timepicker._degreesHours,degreesMinutes:this.timepicker._degreesMinutes},this.timepicker._options.onCancel),this.timepicker.close()()}};handleEscClick=()=>{document.addEventListener("keydown",this.handleKeyPress)};focusTrapHandler=()=>{setTimeout(()=>{let e=this.timepicker.wrapper?.querySelectorAll('div[tabindex="0"]:not([disabled])'),t=this.timepicker.wrapper?.querySelectorAll('input[tabindex="0"]:not([disabled])');if(!e||e.length<=0||t.length<=0)return;let i=[...t,...e],s=i[0],r=i[i.length-1];this.timepicker.wrapper.focus(),this.timepicker.wrapper.addEventListener("keydown",({key:o,shiftKey:n,target:c})=>{let u=c;o==="Tab"&&(n?document.activeElement===s&&r.focus():document.activeElement===r&&s.focus()),o==="Enter"&&(p(u,"timepicker-ui-minutes")&&this.timepicker.minutes.click(),p(u,"timepicker-ui-hour")&&this.timepicker.hour.click(),p(u,"timepicker-ui-am")&&this.timepicker.AM.click(),p(u,"timepicker-ui-pm")&&this.timepicker.PM.click(),p(u,"timepicker-ui-ok-btn")&&this.timepicker.okButton.click(),p(u,"timepicker-ui-cancel-btn")&&this.timepicker.cancelButton.click(),p(u,"timepicker-ui-keyboard-icon-wrapper")&&this.timepicker.keyboardClockIcon.click())})},100)};handleInlineAutoUpdate=()=>{if(!this.timepicker._options.inline?.enabled||this.timepicker._options.inline.autoUpdate===!1)return;let e=()=>{let i=this.timepicker.hour?.value,s=this.timepicker.minutes?.value,r=this.timepicker.activeTypeMode?.textContent;if(i&&s){let o="";if(this.timepicker._options.clockType==="24h"){let n=i.padStart(2,"0"),c=s.padStart(2,"0");o=`${n}:${c}`}else{let n=i,c=s.padStart(2,"0");o=`${n}:${c} ${r||"AM"}`}if(this.timepicker.input){this.timepicker.input.value=o;let n=new Event("change",{bubbles:!0});this.timepicker.input.dispatchEvent(n),_(this.timepicker._element,"accept","timepicker:confirm",{hour:i,minutes:s,type:r,degreesHours:this.timepicker._degreesHours,degreesMinutes:this.timepicker._degreesMinutes},this.timepicker._options.onConfirm)}}};["input","change"].forEach(i=>{this.timepicker.hour?.addEventListener(i,()=>{setTimeout(e,50)}),this.timepicker.minutes?.addEventListener(i,()=>{setTimeout(e,50)})}),this.timepicker._options.clockType!=="24h"&&this.timepicker._clickTouchEvents.forEach(i=>{this.timepicker.AM?.addEventListener(i,()=>{setTimeout(e,50)}),this.timepicker.PM?.addEventListener(i,()=>{setTimeout(e,50)})}),this.timepicker.clockFace?.addEventListener("click",()=>{setTimeout(e,100)})}};var F=class{timepicker;constructor(e){this.timepicker=e}setModalTemplate=()=>{if(!this.timepicker._options)return;if(this.timepicker._options.inline?.enabled){let t=document.getElementById(this.timepicker._options.inline.containerId);if(t){t.innerHTML="",t.insertAdjacentHTML("beforeend",this.timepicker.modalTemplate);let i=t.querySelector(".timepicker-ui-modal");if(i&&(i.classList.add("timepicker-ui--inline"),this.timepicker._options.inline.showButtons===!1||this.timepicker._options.inline.showButtons===void 0)){let s=i.querySelector(".timepicker-ui-wrapper-btn");s&&(s.style.display="none");let r=i.querySelector(".timepicker-ui-wrapper-btn.mobile");r&&(r.style.display="none")}}return}let{appendModalSelector:e}=this.timepicker._options;e===""||!e?document.body.insertAdjacentHTML("afterend",this.timepicker.modalTemplate):document?.querySelector(e)?.insertAdjacentHTML("beforeend",this.timepicker.modalTemplate)};setScrollbarOrNot=()=>{this.timepicker._options.inline?.enabled||(this.timepicker._options.enableScrollbar?setTimeout(()=>{document.body.style.overflowY="",document.body.style.paddingRight=""},400):(document.body.style.paddingRight=`${re()}px`,document.body.style.overflowY="hidden"))};removeBackdrop=()=>{this.timepicker._options.inline?.enabled||this.timepicker._options.backdrop||(this.timepicker.modalElement?.classList.add("removed"),this.timepicker.openElement.forEach(e=>e?.classList.add("disabled")))};setNormalizeClass=()=>{let e=this.timepicker.modalElement?.querySelectorAll("div");this.timepicker.modalElement?.classList.add("timepicker-ui-normalize"),e?.forEach(t=>t.classList.add("timepicker-ui-normalize"))};setShowClassToBackdrop=()=>{if(this.timepicker._options.inline?.enabled){this.timepicker.modalElement?.classList.add("show");return}this.timepicker._options.backdrop&&setTimeout(()=>{this.timepicker.modalElement.classList.add("show")},300)};setFlexEndToFooterIfNoKeyboardIcon=()=>{!this.timepicker._options.enableSwitchIcon&&this.timepicker.footer&&(this.timepicker.footer.style.justifyContent="flex-end")}};var W=class{timepicker;constructor(e){this.timepicker=e}setAnimationToOpen(){this.timepicker.modalElement?.classList.add("opacity"),this.timepicker._options.animation?setTimeout(()=>{this.timepicker.modalElement?.classList.add("show")},150):this.timepicker.modalElement?.classList.add("show")}removeAnimationToClose(){this.timepicker.modalElement&&(this.timepicker._options.animation?setTimeout(()=>{this.timepicker.modalElement?.classList.remove("show")},150):this.timepicker.modalElement?.classList.remove("show"))}handleAnimationClock(){this.timepicker._options.animation&&setTimeout(()=>{this.timepicker.clockFace?.classList.add("timepicker-ui-clock-animation"),setTimeout(()=>{this.timepicker.clockFace?.classList.remove("timepicker-ui-clock-animation")},600)},150)}handleAnimationSwitchTipsMode(){this.timepicker.clockHand.classList.add("timepicker-ui-tips-animation"),setTimeout(()=>{this.timepicker.clockHand?.classList.remove("timepicker-ui-tips-animation")},401)}};var V={cranepurple800:"#5c1349",cranepurple900:"#4e0d3a",cranepurple700:"#71135c",cranered400:"#f7363e",white:"#fff",purple:"#6200ee",redtovalid:"#d50000"},ie={"crane-straight":["crane-straight"],"crane-radius":["crane-straight","radius"],m3:["m3"],dark:["dark"],glassmorphic:["glassmorphic"],pastel:["pastel"],ai:["ai"],cyberpunk:["cyberpunk"]};var P=class{timepicker;constructor(e){this.timepicker=e}removeCircleClockClasses24h(){this.timepicker.circle?.classList.remove("timepicker-ui-circle-hand-24h"),this.timepicker.clockHand?.classList.remove("timepicker-ui-clock-hand-24h")}setCircleClockClasses24h(){this.timepicker.circle&&this.timepicker.circle?.classList.add("timepicker-ui-circle-hand-24h"),this.timepicker.clockHand&&this.timepicker.clockHand?.classList.add("timepicker-ui-clock-hand-24h")}setOnStartCSSClassesIfClockType24h(){if(this.timepicker._options.clockType==="24h"){let{hour:e}=this.timepicker.configManager.getInputValue(this.timepicker.input,this.timepicker._options.clockType,this.timepicker._options.currentTime);this.timepicker.input.value.length>0&&(e=this.timepicker.input.value.split(":")[0]),(Number(e)>12||Number(e)===0)&&this.setCircleClockClasses24h()}}setBgColorToCirleWithHourTips=()=>{if(!this.timepicker._options)return;let{mobile:e,theme:t}=this.timepicker._options;e||this.timepicker.circle===null||(t==="crane-straight"||t==="crane-radius"?this.timepicker.circle.style.backgroundColor=V.cranered400:this.timepicker.circle.style.backgroundColor=V.purple)};setBgColorToCircleWithMinutesTips=()=>{let{theme:e}=this.timepicker._options;this.timepicker.minutes.value&&x.includes(this.timepicker.minutes.value)&&(e==="crane-straight"||e==="crane-radius"?this.timepicker.circle.style.backgroundColor=V.cranered400:this.timepicker.circle.style.backgroundColor=V.purple,this.timepicker.circle.classList.remove("small-circle"))};removeBgColorToCirleWithMinutesTips=()=>{this.timepicker.minutes.value&&x.includes(this.timepicker.minutes.value)||(this.timepicker.circle.style.backgroundColor="",this.timepicker.circle.classList.add("small-circle"))};setClassActiveToHourOnOpen=()=>{this.timepicker._options.mobile||this.timepicker._isMobileView||this.timepicker.hour?.classList.add(k)};setMinutesToClock=e=>{this.timepicker.clockFace!==null&&this.setTransformToCircleWithSwitchesMinutes(e),this.removeBgColorToCirleWithMinutesTips();let t=this.timepicker._disabledTime?.value?.minutes?this.timepicker._disabledTime?.value?.minutes:this.timepicker._disabledTime?.value,i=new H({array:x,classToAdd:"timepicker-ui-minutes-time",clockFace:this.timepicker.clockFace,tipsWrapper:this.timepicker.tipsWrapper,theme:this.timepicker._options.theme,disabledTime:t,hour:this.timepicker.hour.value,clockType:this.timepicker._options.clockType});i.create(),this.timepicker._options.clockType==="12h"&&i.updateDisable(),this.toggleClassActiveToValueTips(e),this.timepicker._options.clockType==="24h"&&(this.timepicker.tipsWrapperFor24h.innerHTML="")};setHoursToClock=e=>{if(this.timepicker.clockFace!==null){this.setTransformToCircleWithSwitchesHour(e),this.setBgColorToCirleWithHourTips();let t=this.timepicker._disabledTime?.value?.isInterval?this.timepicker._disabledTime?.value.rangeArrHour:this.timepicker._disabledTime?.value?.hours,i=new H({array:w,classToAdd:"timepicker-ui-hour-time-12",clockFace:this.timepicker.clockFace,tipsWrapper:this.timepicker.tipsWrapper,theme:this.timepicker._options.theme,disabledTime:t,clockType:"12h",hour:this.timepicker.hour.value});i.create(),this.timepicker._options.clockType==="24h"?new H({array:Z,classToAdd:"timepicker-ui-hour-time-24",clockFace:this.timepicker.tipsWrapperFor24h,tipsWrapper:this.timepicker.tipsWrapperFor24h,theme:this.timepicker._options.theme,clockType:"24h",disabledTime:t,hour:this.timepicker.hour.value}).create():i.updateDisable(),this.toggleClassActiveToValueTips(e)}};setTransformToCircleWithSwitchesHour=e=>{if(!this.timepicker.clockHand)return;let t=Number(e),i=t>12?t*30-360:t*30;i===360&&(i=0),!(i>360)&&(this.timepicker.clockHand.style.transform=`rotateZ(${i}deg)`)};setTransformToCircleWithSwitchesMinutes=e=>{if(!this.timepicker.clockHand)return;let t=Number(e)*6;t>360||(this.timepicker.clockHand.style.transform=`rotateZ(${t}deg)`)};toggleClassActiveToValueTips=e=>{let t=this.timepicker.allValueTips.find(i=>Number(i.innerText)===Number(e));this.timepicker.allValueTips.map(i=>i.classList.remove(k)),t!==void 0&&t.classList.add(k)}};var B=class{timepicker;constructor(e){this.timepicker=e}setErrorHandler(){let{error:e,currentHour:t,currentMin:i,currentType:s,currentLength:r}=y(this.timepicker.input,this.timepicker._options.clockType);if(e){let o=document.createElement("div");throw this.timepicker.input?.classList.add("timepicker-ui-invalid-format"),o.classList.add("timepicker-ui-invalid-text"),o.innerHTML="<b>Invalid Time Format</b>",this.timepicker.input?.parentElement&&this.timepicker.input?.parentElement.querySelector(".timepicker-ui-invalid-text")===null&&this.timepicker.input?.after(o),_(this.timepicker._element,"geterror","timepicker:error",{error:e,currentHour:t,currentMin:i,currentType:s,currentLength:r},this.timepicker._options.onError),new Error(`Invalid Time Format: ${e}`)}}removeErrorHandler(){this.timepicker.input?.classList.remove("timepicker-ui-invalid-format");let e=this.timepicker._element?.querySelector(".timepicker-ui-invalid-text");e&&e.remove()}checkDisabledValuesOnStart(){if(!this.timepicker._options.disabledTime||this.timepicker._options.disabledTime.interval)return;let{disabledTime:{hours:e,minutes:t},clockType:i}=this.timepicker._options,s=e?N(e,"hour",i):!0,r=t?N(t,"minutes",i):!0;if(!s||!r)throw new Error("You set wrong hours or minutes in disabled option")}};var q=class{timepicker;constructor(e){this.timepicker=e}setTheme=()=>{let e=[...this.timepicker.modalElement?.querySelectorAll("input")??[],...this.timepicker.modalElement?.querySelectorAll("div")??[]],{theme:t}=this.timepicker._options??{};t&&ie[t]&&e.forEach(i=>i.classList.add(...ie[t]))};setInputClassToInputElement=()=>{p(this.timepicker.input,"timepicker-ui-input")||this.timepicker.input?.classList.add("timepicker-ui-input")};setDataOpenToInputIfDosentExistInWrapper=()=>{this.timepicker.openElementData===null&&this.timepicker.input?.setAttribute("data-open","timepicker-ui-input")};setClassTopOpenElement=()=>{this.timepicker.openElement.forEach(e=>e?.classList.add("timepicker-ui-open-element"))};setTimepickerClassToElement=()=>{this.timepicker._element?.classList.add(ee),this.timepicker._options.cssClass&&this.timepicker._options.cssClass!==ee&&this.timepicker._element?.classList.add(this.timepicker._options.cssClass)}};var R=class{timepicker;constructor(e){this.timepicker=e}preventClockTypeByCurrentTime=()=>{if(typeof this.timepicker._options?.currentTime!="boolean"&&this.timepicker._options?.currentTime?.preventClockType||typeof this.timepicker._options?.currentTime=="boolean"&&this.timepicker._options?.currentTime){let{currentTime:e,clockType:t}=this.timepicker._options,{type:i}=y(this.timepicker.input,t,e,!0);this.timepicker._options.clockType=i?"12h":"24h"}};updateInputValueWithCurrentTimeOnStart=()=>{if(typeof this.timepicker._options?.currentTime!="boolean"&&this.timepicker._options?.currentTime?.updateInput||typeof this.timepicker._options?.currentTime=="boolean"&&this.timepicker._options?.currentTime){let{hour:e,minutes:t,type:i}=y(this.timepicker.input,this.timepicker._options.clockType,this.timepicker._options.currentTime);this.timepicker.input.value=i?`${e}:${t} ${i}`:`${e}:${t}`}};checkMobileOption(){this.timepicker._isMobileView=!!this.timepicker._options.mobile,this.timepicker._options.mobile&&(this.timepicker._options.editable=!0)}getDisableTime(){this.timepicker._disabledTime=pe(this.timepicker._options)}getInputValueOnOpenAndSet=()=>{let e=y(this.timepicker.input,this.timepicker._options.clockType,this.timepicker._options.currentTime);if(e===void 0){this.timepicker.hour.value="12",this.timepicker.minutes.value="00",_(this.timepicker._element,"show","timepicker:open",{hour:this.timepicker.hour.value,minutes:this.timepicker.minutes.value,type:this.timepicker.activeTypeMode?.dataset.type,degreesHours:this.timepicker._degreesHours,degreesMinutes:this.timepicker._degreesMinutes},this.timepicker._options.onOpen),this.timepicker._options.clockType!=="24h"&&this.timepicker.AM.classList.add(k);return}let[t,i,s]=this.timepicker.input.value.split(":").join(" ").split(" ");this.timepicker.input.value.length===0&&(t=e.hour,i=e.minutes,s=e.type),this.timepicker.hour.value=t,this.timepicker.minutes.value=i;let r=this.timepicker.modalElement?.querySelector(`[data-type='${s}']`);this.timepicker._options.clockType!=="24h"&&r&&r.classList.add(k),_(this.timepicker._element,"show","timepicker:open",{...e,type:this.timepicker.activeTypeMode?.dataset.type,degreesHours:this.timepicker._degreesHours,degreesMinutes:this.timepicker._degreesMinutes},this.timepicker._options.onOpen)};handlerViewChange=()=>Y(()=>{let{clockType:e}=this.timepicker._options;if(this.timepicker.modalElement?.classList.contains("mobile")){let t=L(this.timepicker.hour.value,"hour",e),i=L(this.timepicker.minutes.value,"minutes",e);if(t===!1||i===!1){i||this.timepicker.minutes.classList.add("invalid-value"),t||this.timepicker.hour?.classList.add("invalid-value");return}t===!0&&i===!0&&(i&&this.timepicker.minutes.classList.remove("invalid-value"),t&&this.timepicker.hour?.classList.remove("invalid-value")),this.timepicker.close()(),this.timepicker._isMobileView=!1,this.timepicker._options.mobile=!1;let s=this.timepicker.hour.value,r=this.timepicker.minutes.value,o=this.timepicker.activeTypeMode?.dataset.type;setTimeout(()=>{this.timepicker.destroy(),this.timepicker.update({options:{mobile:!1}}),setTimeout(()=>{if(this.timepicker.open(),this.timepicker.hour.value=s,this.timepicker.minutes.value=r,this.timepicker._options.clockType==="12h"){let n=o==="PM"?"PM":"AM",c=o==="PM"?"AM":"PM";this.timepicker[n].classList.add(k),this.timepicker[c].classList.remove(k)}this.timepicker.clockManager.setTransformToCircleWithSwitchesHour(this.timepicker.hour.value),this.timepicker.clockManager.toggleClassActiveToValueTips(this.timepicker.hour.value),Number(this.timepicker.hour.value)>12||Number(this.timepicker.hour.value)===0?this.timepicker.clockManager.setCircleClockClasses24h():this.timepicker.clockManager.removeCircleClockClasses24h()},300)},300)}else{this.timepicker.close()(),this.timepicker._isMobileView=!0,this.timepicker._options.mobile=!0;let t=this.timepicker.hour.value,i=this.timepicker.minutes.value,s=this.timepicker.activeTypeMode?.dataset.type;setTimeout(()=>{this.timepicker.destroy(),this.timepicker.update({options:{mobile:!0}}),setTimeout(()=>{if(this.timepicker.open(),this.timepicker.hour.value=t,this.timepicker.minutes.value=i,this.timepicker._options.clockType==="12h"){let r=s==="PM"?"PM":"AM",o=s==="PM"?"AM":"PM";this.timepicker[r].classList.add(k),this.timepicker[o].classList.remove(k)}},300)},300)}},this.timepicker._options.delayHandler||300);getInputValue=y};var S=new Map,J=class{_degreesHours=null;_degreesMinutes=null;_options;_eventsClickMobile=()=>Promise.resolve();_eventsClickMobileHandler=()=>{};_mutliEventsMove=()=>{};_mutliEventsMoveHandler;_clickTouchEvents;_element;_instanceId;_isMobileView;_isTouchMouseMove;_disabledTime;_cloned;_inputEvents;_isModalRemove;_isInitialized=!1;_customId;_eventHandlersRegistered=!1;_isDestroyed=!1;eventManager;modalManager;animationManager;clockManager;validationManager;themeManager;configManager;constructor(e,t){if(typeof window>"u")throw new Error("TimepickerUI: Cannot initialize in non-browser environment (SSR/Node.js)");let i=t?.id;if(this._customId=i,this._instanceId=i||`timepicker-ui-${ce()}`,i&&S.has(i))throw new Error(`TimepickerUI: Instance with ID "${i}" already exists`);let s=null;if(typeof e=="string"){if(s=document.querySelector(e),!s)throw new Error(`TimepickerUI: Element with selector "${e}" not found`)}else if(e instanceof HTMLElement)s=e;else throw new Error("TimepickerUI: First parameter must be a string selector or HTMLElement");let r=null;if(s.tagName==="INPUT"?r=s:r=s.querySelector("input"),!r){let n=typeof e=="string"?`selector "${e}"`:"provided element";throw new Error(`TimepickerUI: No input element found for ${n}`)}if(s.tagName==="INPUT"){let n=document.createElement("div");n.className="timepicker-ui",s.parentNode?.insertBefore(n,s),n.appendChild(s),this._element=n}else this._element=s,this._element.classList.contains("timepicker-ui")||this._element.classList.add("timepicker-ui");this._cloned=null;let o=ae(this._element?.dataset);if(this._options={...se({...Q,...t,...o},Q)},this._options.inline?.enabled&&typeof t?.focusTrap>"u"&&(this._options.focusTrap=!1),this._isTouchMouseMove=!1,this._degreesHours=Number(y(this._element?.querySelector("input"),this._options.clockType).hour)*30,this._degreesMinutes=Number(y(this._element?.querySelector("input"),this._options.clockType).minutes)*6,this._isMobileView=!1,this._mutliEventsMove=n=>this.eventManager.handleEventToMoveHand(n),this._mutliEventsMoveHandler=this._mutliEventsMove.bind(this),this._eventsClickMobile=n=>this.eventManager.handlerClickHourMinutes(n),this._eventsClickMobileHandler=this._eventsClickMobile.bind(this),this.eventManager=new U(this),this.modalManager=new F(this),this.animationManager=new W(this),this.clockManager=new P(this),this.validationManager=new B(this),this.themeManager=new q(this),this.configManager=new R(this),this.configManager.checkMobileOption(),this._clickTouchEvents=["click","mousedown","touchstart"],this._inputEvents=["change",...this._clickTouchEvents],this._disabledTime=null,this.configManager.preventClockTypeByCurrentTime(),this._isModalRemove=!0,this._isInitialized=!1,this._options.inline?.enabled){if(!this._options.inline.containerId)throw console.error("TimepickerUI: containerId is required when inline mode is enabled"),new Error("TimepickerUI: containerId is required when inline mode is enabled");if(!document.getElementById(this._options.inline.containerId))throw console.error(`TimepickerUI: Container element with ID "${this._options.inline.containerId}" not found`),new Error(`TimepickerUI: Container element with ID "${this._options.inline.containerId}" not found`)}S.set(this._instanceId,this)}static getById(e){return S.get(e)}static getAllInstances(){return Array.from(S.values())}static isAvailable(e){return typeof window>"u"?!1:typeof e=="string"?document.querySelector(e)!==null:e instanceof HTMLElement?document.contains(e):!1}static destroyAll(){Array.from(S.values()).forEach(t=>t.destroy()),S.clear()}get modalTemplate(){return!this._options.mobile||!this._isMobileView?le(this._options,this._instanceId):me(this._options,this._instanceId)}get modalElement(){return document.querySelector(`[data-owner-id="${this._instanceId}"]`)}get clockFace(){return this.modalElement?.querySelector(".timepicker-ui-clock-face")}get input(){return this._element?.querySelector("input")}get clockHand(){return this.modalElement?.querySelector(".timepicker-ui-clock-hand")}get circle(){return this.modalElement?.querySelector(".timepicker-ui-circle-hand")}get tipsWrapper(){return this.modalElement?.querySelector(".timepicker-ui-tips-wrapper")}get tipsWrapperFor24h(){return this.modalElement?.querySelector(".timepicker-ui-tips-wrapper-24h")}get minutes(){return this.modalElement?.querySelector(".timepicker-ui-minutes")}get hour(){return this.modalElement?.querySelector(".timepicker-ui-hour")}get AM(){return this.modalElement?.querySelector(".timepicker-ui-am")}get PM(){return this.modalElement?.querySelector(".timepicker-ui-pm")}get minutesTips(){return this.modalElement?.querySelector(".timepicker-ui-minutes-time")}get hourTips(){return this.modalElement?.querySelector(".timepicker-ui-hour-time-12")}get allValueTips(){let e=this.modalElement;return e?[...e.querySelectorAll(".timepicker-ui-value-tips"),...e.querySelectorAll(".timepicker-ui-value-tips-24h")]:[]}get openElementData(){let e=this._element?.querySelectorAll("[data-open]");if(e?.length>0){let t=[];return e.forEach(({dataset:i})=>t.push(i.open??"")),[...new Set(t)]}return null}get openElement(){return this.openElementData===null?(this.input?.setAttribute("data-open","timepicker-ui-input"),[this.input]):this.openElementData.map(e=>this._element?.querySelectorAll(`[data-open='${e}']`))[0]??""}get cancelButton(){return this.modalElement?.querySelector(".timepicker-ui-cancel-btn")}get okButton(){return this.modalElement?.querySelector(".timepicker-ui-ok-btn")}get activeTypeMode(){return this.modalElement?.querySelector(".timepicker-ui-type-mode.active")}get keyboardClockIcon(){return this.modalElement?.querySelector(".timepicker-ui-keyboard-icon-wrapper")}get footer(){return this.modalElement?.querySelector(".timepicker-ui-footer")}get wrapper(){return this.modalElement?.querySelector(".timepicker-ui-wrapper")}getElement(){return this._element}create=()=>{if(this._isInitialized){console.warn("TimepickerUI: Instance is already initialized");return}this.configManager.updateInputValueWithCurrentTimeOnStart(),this.validationManager.checkDisabledValuesOnStart(),this.themeManager.setTimepickerClassToElement(),this.themeManager.setInputClassToInputElement(),this.themeManager.setDataOpenToInputIfDosentExistInWrapper(),this.themeManager.setClassTopOpenElement(),this._options.inline?.enabled?(this.eventManager.handleOpenOnEnterFocus(),this._eventsBundle()):(this.eventManager.handleOpenOnEnterFocus(),this.eventManager.handleOpenOnClick()),this.configManager.getDisableTime(),this._isInitialized=!0};open=e=>{this._isInitialized||this.create(),this._eventsBundle(),D(e)};close=()=>Y((...e)=>{if(e.length>2||!this.modalElement)return;let[t]=e.filter(s=>typeof s=="boolean"),[i]=e.filter(s=>typeof s=="function");t&&(this.eventManager.handleOkButton(),this.okButton?.click()),this._isTouchMouseMove=!1,O.split(" ").map(s=>document.removeEventListener(s,this._mutliEventsMoveHandler,!1)),document.removeEventListener("mousedown",this._eventsClickMobileHandler),document.removeEventListener("touchstart",this._eventsClickMobileHandler),document.removeEventListener("keypress",this.eventManager.handleEscClick),this.wrapper.removeEventListener("keydown",this.eventManager.focusTrapHandler),this._options.enableSwitchIcon&&(this.keyboardClockIcon.removeEventListener("touchstart",this.configManager.handlerViewChange()),this.keyboardClockIcon.removeEventListener("mousedown",this.configManager.handlerViewChange())),this.animationManager.removeAnimationToClose(),this.openElement.forEach(s=>s?.classList.remove("disabled")),setTimeout(()=>{document.body.style.overflowY="",document.body.style.paddingRight=""},400),this.openElement.forEach(s=>s?.classList.remove("disabled")),setTimeout(()=>{this._options.focusInputAfterCloseModal&&this.input?.focus(),this.modalElement!==null&&(this.modalElement.remove(),this._isModalRemove=!0)},300),D(i)},this._options.delayHandler||300);destroy=e=>{if(this._isDestroyed){console.warn("TimepickerUI: Instance is already destroyed");return}let t=typeof e=="function"?{callback:e}:e||{},{keepInputValue:i=!1,callback:s}=t,r=i?this.input?.value:null;O.split(" ").forEach(n=>{document.removeEventListener(n,this._mutliEventsMoveHandler,!1)}),document.removeEventListener("mousedown",this._eventsClickMobileHandler),document.removeEventListener("touchstart",this._eventsClickMobileHandler),document.removeEventListener("keypress",this.eventManager.handleEscClick),this._options.enableSwitchIcon&&this.keyboardClockIcon&&(this.keyboardClockIcon.removeEventListener("touchstart",this.configManager.handlerViewChange()),this.keyboardClockIcon.removeEventListener("mousedown",this.configManager.handlerViewChange())),this.input&&this._inputEvents.forEach(n=>{this.input.removeEventListener(n,()=>{})}),this.modalElement?.remove(),this.openElement?.forEach(n=>{n&&(n.classList.remove("disabled","active","timepicker-ui-open-element"),n.classList.remove("basic","crane-straight","crane-radius","m3"))}),this.input&&(this.input.classList.remove("timepicker-ui-invalid-format","invalid-value","error","active","timepicker-ui-input"),this.input.removeAttribute("data-open"),this.input.removeAttribute("data-owner-id"),i&&r!==null&&(this.input.value=r)),this._element&&(this._element.classList.remove("basic","crane-straight","crane-radius","m3"),this._element.classList.remove("error","active","disabled"),this._element.removeAttribute("data-owner-id"),this._element.removeAttribute("data-open"),this._options.cssClass&&this._element.classList.remove(this._options.cssClass)),this._element?.querySelectorAll(".timepicker-ui-invalid-text")?.forEach(n=>n.remove()),this._mutliEventsMoveHandler=null,this._eventsClickMobileHandler=null,this._mutliEventsMove=()=>{},this._eventsClickMobile=()=>Promise.resolve(),this._isModalRemove=!0,this._isTouchMouseMove=!1,this._disabledTime=null,this._cloned=null,this._degreesHours=null,this._degreesMinutes=null,this._isInitialized=!1,this._isDestroyed=!0,typeof document<"u"&&(document.body.style.overflowY="",document.body.style.paddingRight=""),S.delete(this._instanceId),D(s)};update=(e,t)=>{if(this._isDestroyed){console.warn("TimepickerUI: Instance is destroyed");return}this._options={...this._options,...e.options},this.configManager.checkMobileOption(),e.create&&this.create(),D(t)};getValue=()=>{if(this._isDestroyed)return console.warn("TimepickerUI: Instance is destroyed"),{hour:"",minutes:"",time:"",degreesHours:null,degreesMinutes:null};let e=this.hour?.value||"12",t=this.minutes?.value||"00",i=this._options.clockType==="24h"?void 0:this.activeTypeMode?.textContent||"AM",s="";return this._options.clockType==="24h"?s=`${e.padStart(2,"0")}:${t.padStart(2,"0")}`:s=`${e}:${t.padStart(2,"0")} ${i}`,{hour:e,minutes:t,type:i,time:s,degreesHours:this._degreesHours,degreesMinutes:this._degreesMinutes}};setValue=(e,t=!0)=>{if(this._isDestroyed){console.warn("TimepickerUI: Instance is destroyed");return}if(!e||typeof e!="string")throw new Error("TimepickerUI: setValue requires a valid time string");let i=e.trim(),s="12",r="00",o="AM";try{if(this._options.clockType==="24h"){let n=i.match(/^([0-1]?[0-9]|2[0-3]):([0-5][0-9])$/);if(!n)throw new Error("Invalid 24h format. Expected HH:MM");s=n[1].padStart(2,"0"),r=n[2]}else{let n=i.match(/^(1[0-2]|[1-9]):([0-5][0-9])\s*(AM|PM)$/i);if(!n)throw new Error("Invalid 12h format. Expected HH:MM AM/PM");s=n[1],r=n[2],o=n[3].toUpperCase()}this.hour&&(this.hour.value=s,this._degreesHours=Number(s)*30),this.minutes&&(this.minutes.value=r,this._degreesMinutes=Number(r)*6),this._options.clockType!=="24h"&&this.AM&&this.PM&&(o==="AM"?(this.AM.classList.add("active"),this.PM.classList.remove("active")):(this.PM.classList.add("active"),this.AM.classList.remove("active"))),t&&this.input&&(this.input.value=i),this.clockHand&&(this.clockHand.style.transform=`rotateZ(${this._degreesHours||0}deg)`)}catch(n){throw new Error(`TimepickerUI: ${n instanceof Error?n.message:"Invalid time format"}`)}};_eventsBundle=()=>{if(this._isDestroyed){console.warn("TimepickerUI: Instance is destroyed");return}if(this._isModalRemove){if(this._options.inline?.enabled||this.eventManager.handleEscClick(),this.validationManager.setErrorHandler(),this.validationManager.removeErrorHandler(),this._options.inline?.enabled||(this.openElement.forEach(e=>e?.classList.add("disabled")),this.input?.blur()),this.modalManager.setScrollbarOrNot(),this.modalManager.setModalTemplate(),this.modalManager.setNormalizeClass(),this.modalManager.removeBackdrop(),this.clockManager.setBgColorToCirleWithHourTips(),this.clockManager.setOnStartCSSClassesIfClockType24h(),this.clockManager.setClassActiveToHourOnOpen(),this.clockFace!==null){let e=new H({array:w,classToAdd:"timepicker-ui-hour-time-12",clockFace:this.clockFace,tipsWrapper:this.tipsWrapper,theme:this._options.theme,disabledTime:this._disabledTime?.value?.isInterval?this._disabledTime?.value.rangeArrHour:this._disabledTime?.value?.hours,clockType:"12h",hour:this.hour.value});e.create(),this._options.clockType==="24h"?new H({array:Z,classToAdd:"timepicker-ui-hour-time-24",clockFace:this.tipsWrapperFor24h,tipsWrapper:this.tipsWrapperFor24h,theme:this._options.theme,clockType:"24h",disabledTime:this._disabledTime?.value?.isInterval?this._disabledTime?.value.rangeArrHour:this._disabledTime?.value?.hours,hour:this.hour.value}).create():(this._disabledTime?.value.startType===this._disabledTime?.value.endType?setTimeout(()=>{this._disabledTime?.value.startType===this.activeTypeMode?.textContent&&e.updateDisable({hoursToUpdate:this._disabledTime?.value?.rangeArrHour,minutesToUpdate:{endMinutes:this._disabledTime?.value.endMinutes,removedEndHour:this._disabledTime?.value.removedEndHour,removedStartedHour:this._disabledTime?.value.removedStartedHour,actualHour:this.hour.value,startMinutes:this._disabledTime?.value.startMinutes}})},300):setTimeout(()=>{e.updateDisable({minutesToUpdate:{actualHour:this.hour.value,pmHours:this._disabledTime?.value.pmHours,amHours:this._disabledTime?.value.amHours,activeMode:this.activeTypeMode?.textContent}})},300),e.updateDisable())}this.modalManager.setFlexEndToFooterIfNoKeyboardIcon(),setTimeout(()=>{this.themeManager.setTheme()},0),this.animationManager.setAnimationToOpen(),this.configManager.getInputValueOnOpenAndSet(),this.clockManager.toggleClassActiveToValueTips(this.hour.value),this._isMobileView||(this.clockManager.setTransformToCircleWithSwitchesHour(this.hour.value),this.animationManager.handleAnimationClock()),this.eventManager.handleMinutesEvents(),this.eventManager.handleHourEvents(),this._options.clockType!=="24h"&&(this.eventManager.handleAmClick(),this.eventManager.handlePmClick()),this.clockFace&&this.eventManager.handleMoveHand(),this.eventManager.handleCancelButton(),this.eventManager.handleOkButton(),this.modalElement&&(this.modalManager.setShowClassToBackdrop(),this._options.inline?.enabled||this.eventManager.handleBackdropClick()),this.eventManager.handleIconChangeView(),this.eventManager.handleClickOnHourMobile(),this._options.focusTrap&&this.eventManager.focusTrapHandler(),this._options.inline?.enabled&&this._options.inline.autoUpdate!==!1&&this.eventManager.handleInlineAutoUpdate()}}};export{J as TimepickerUI};
75
+ </div>
76
+ <div class="timepicker-announcer sr-only" role="status" aria-live="polite" aria-atomic="true"></div>
77
+ </div>`}});var Me=(n,e)=>({...e,...n}),Ee=()=>{let n=document.createElement("div");n.className="timepicker-ui-measure",document.body.appendChild(n);let e=n.getBoundingClientRect().width-n.clientWidth;return document.body.removeChild(n),e},_e=n=>n*(Math.PI/180),ge=(n,e)=>{let{touches:t}=n,{clientX:i,clientY:r}=n;if(!e)return;let{left:s,top:a}=e.getBoundingClientRect(),o={x:0,y:0};if(t===void 0)o={x:i-s,y:r-a};else if(t!==void 0&&t.length>0&&Object.keys(t).length>0){let{clientX:c,clientY:l}=t[0];o={x:c-s,y:l-a}}if(!(Object.keys(o).length===0&&o.constructor===Object))return o},Ne=(n,e)=>Math.round(n/e)*e,m=(n,e)=>n?n.classList.contains(e):!1;var _=(n,e,t,i,r,s)=>{if(!n)return;let a=new CustomEvent(t,{detail:i,bubbles:!0,cancelable:!0});try{if(n.dispatchEvent(a)&&e!==t){let c=new CustomEvent(e,{detail:i,bubbles:!0,cancelable:!0});n.dispatchEvent(c)}if(s&&"emit"in s&&typeof s.emit=="function"){let c=t.replace("timepicker:","").replace(/-/g,":");s.emit(c,i)}}catch(o){console.warn(`TimepickerUI: Error dispatching event ${t}:`,o)}if(r&&typeof r=="function")try{r(i)}catch(o){console.warn(`TimepickerUI: Error in ${t} callback:`,o)}},He=()=>/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent),ue=(n,e,t)=>Ne(n,e*t),Ie=n=>{if(!n)return;let e=JSON.parse(JSON.stringify(n)),t=Object.keys(e);return Object.values(e).reduce((i,r,s)=>(Number(r)?i[t[s]]=Number(r):r==="true"||r==="false"?i[t[s]]=JSON.parse(r):i[t[s]]=r,i),{})},W=(n,e)=>Array.from({length:Number(e)-Number(n)+1},(t,i)=>Number(n)+i),de=(n,e)=>Array.from({length:Number(e)-Number(n)+1},(t,i)=>Number(e)-i).reverse(),O=n=>{n&&typeof n=="function"&&n()},U=(n="")=>{let e=n.replace(/(AM|PM|am|pm)/,s=>` ${s}`),t=new Date(`September 20, 2000 ${e}`),i=t.getHours().toString().padStart(2,"0"),r=t.getMinutes().toString().padStart(2,"0");return`${i}:${r}`},F=n=>{let[e,t]=n.split(":"),i=Number(e),r=Number(t);return`${i<=9?"0"+i:i}:${r<=9?"0"+r:r}`},he=(n,e)=>{if(n.length<2)return!1;let t=n.map(i=>{let[r,s]=i.trim().split("-"),a,o;if(e==="12h"){if(!/\s?(AM|PM|am|pm)\s?$/.test(r.trim())||!/\s?(AM|PM|am|pm)\s?$/.test(s.trim()))throw new Error(`Invalid 12h format in interval: "${i}". AM/PM is required for 12h clock type.`);a=U(r.trim()),o=U(s.trim())}else{if(/\s?(AM|PM|am|pm)\s?/.test(r.trim())||/\s?(AM|PM|am|pm)\s?/.test(s.trim()))throw new Error(`Invalid 24h format in interval: "${i}". AM/PM is not allowed for 24h clock type.`);a=F(r.trim()),o=F(s.trim())}return{start:a,end:o,original:i}});for(let i=0;i<t.length;i++)for(let r=i+1;r<t.length;r++){let s=t[i],a=t[r];if(s.start<=a.end&&s.end>=a.start||a.start<=s.end&&a.end>=s.start)throw new Error(`Overlapping time intervals detected: "${s.original}" overlaps with "${a.original}"`)}return!1},Ce=()=>typeof window<"u"&&window.crypto&&typeof window.crypto.randomUUID=="function"?window.crypto.randomUUID():"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,n=>{let e=Math.random()*16|0;return(n==="x"?e:e&3|8).toString(16)});var ke=(n,e)=>{let t;return(...i)=>{clearTimeout(t),t=setTimeout(()=>{n(...i)},e)}};var Te="timepicker-ui",We="mousedown mouseup mousemove mouseleave mouseover",Ve="touchstart touchmove touchend",Le=`${We} ${Ve}`,H="active";ve();var C=(n,e,t,i)=>{let r={hour:"12",minutes:"00",type:e==="24h"?void 0:"PM"};if(!n)return r;let s=n.value.trim();if(!t&&s==="")return r;if(typeof t=="boolean"&&t){let u=new Date,[d,y]=u.toLocaleTimeString().split(":"),k=Number(d)<=9?`0${Number(d)}`:d;if(/[a-z]/i.test(y)&&e==="12h"){let[f,M]=y.split(" ");return{hour:k,minutes:f,type:M}}return{hour:k,minutes:y,type:void 0}}if(typeof t=="object"){let{time:u,locales:d,preventClockType:y}=t,k=u??new Date;if(y&&i){let[T,E]=new Date(k).toLocaleTimeString().split(":");if(/[a-z]/i.test(E)){let[L,x]=E.split(" ");return{hour:T,minutes:L,type:x}}return{hour:Number(T)<=9?`0${Number(T)}`:T,minutes:E,type:void 0}}let[f,M]=new Date(k).toLocaleTimeString(d,{timeStyle:"short"}).split(":"),I=Number(f)<=9?`0${Number(f)}`:f;if(/[a-z]/i.test(M)&&e==="12h"){let[T,E]=M.split(" ");return{hour:I,minutes:T,type:E}}if(e==="12h"){let[T,E]=new Date(`1970-01-01T${f}:${M}Z`).toLocaleTimeString("en-US",{timeZone:"UTC",hour12:!0,hour:"numeric",minute:"numeric"}).split(":"),[A,L]=E.split(" ");return{hour:Number(T)<=9?`0${Number(T)}`:T,minutes:A,type:L}}return{hour:I,minutes:M,type:void 0}}let[a,o]=s.split(" "),[c="",l=""]=a.split(":"),h=c.replace(/\D/g,""),p=l.replace(/\D/g,""),v={hour:h.padStart(2,"0"),minutes:p.padStart(2,"0"),type:e==="12h"?o:void 0};if(h.length>2||p.length>2)return{...v,error:"Invalid input: too many digits.",currentHour:c,currentMin:l};if(/[a-z]/i.test(a))return{...v,error:"Input contains invalid letters."};if(s.includes(" ")&&(!o||s.length>8||o!=="AM"&&o!=="PM"))return{...v,error:"Invalid AM/PM format or length.",currentLength:s.length,currentType:o};let g=Number(h),b=Number(p);if(e==="12h"){if(g<1||g>12||b<0||b>59||o!=="AM"&&o!=="PM")return{...v,error:"Invalid 12h time.",currentHour:g,currentMin:b,currentType:o}}else if(g<0||g>23||b<0||b>59)return{...v,error:"Invalid 24h time.",currentHour:g,currentMin:b};return v},D=(n,e,t)=>{let i=Number(n);if(Number.isNaN(i))return!1;switch(e){case"hour":return t==="24h"?i>=0&&i<=23:i>0&&i<=12;case"minutes":return i>=0&&i<=59;default:return}};var be={amLabel:"AM",animation:!0,appendModalSelector:"",backdrop:!0,cancelLabel:"CANCEL",editable:!1,enableScrollbar:!1,enableSwitchIcon:!1,mobileTimeLabel:"Enter Time",focusInputAfterCloseModal:!1,hourMobileLabel:"Hour",iconTemplate:'<i class="material-icons timepicker-ui-keyboard-icon">keyboard</i>',iconTemplateMobile:'<i class="material-icons timepicker-ui-keyboard-icon">schedule</i>',incrementHours:1,incrementMinutes:1,minuteMobileLabel:"Minute",mobile:!1,okLabel:"OK",pmLabel:"PM",timeLabel:"Select Time",switchToMinutesAfterSelectHour:!1,theme:"basic",clockType:"12h",disabledTime:void 0,currentTime:void 0,focusTrap:!0,delayHandler:300,inline:void 0,cssClass:void 0};var Ae=n=>{if(!n)return;let{disabledTime:e,clockType:t}=n;if(!e||Object.keys(e).length<=0||e.constructor.name!=="Object")return;let{hours:i,minutes:r,interval:s}=e;if(s){delete e.hours,delete e.minutes;let a=Array.isArray(s)?s:[s];if(!t)throw new Error("clockType is required when using disabledTime.interval");try{he(a,t)}catch(l){throw l}return{value:a.map(l=>{let[h,p]=l.trim().split("-"),{hour:v,minutes:g,type:b}=C({value:h.trim()},t),{hour:u,minutes:d,type:y}=C({value:p.trim()},t),k=W(v,u).map(T=>T==="00"||Number(T)===0?`0${Number(T)}`:`${Number(T)}`),f=[],M=Number(g),I=Number(d);if(y===b)return M>0&&I<=0?(f.push(k[0],k[k.length-1]),k=k.slice(1,-1)):I<59&&I>0&&M<=0?(f.push(void 0,k[k.length-1]),k=k.slice(0,-1)):I>0&&M>0?(f.push(k[0],k[k.length-1]),k=k.slice(1,-1)):I===0&&M===0&&(f.push(void 0,k[k.length-1]),k.pop()),{removedStartedHour:f[0]!==void 0&&Number(f[0])<=9?`0${f[0]}`:f[0],removedEndHour:f[1]!==void 0&&Number(f[1])<=9?`0${f[1]}`:f[1],rangeArrHour:k,startMinutes:W(g,59).map(T=>Number(T)<=9?`0${T}`:`${T}`),endMinutes:de(0,d).map(T=>Number(T)<=9?`0${T}`:`${T}`),startType:b,endType:y};{let T=W(v,12).map(String),E=de(1,u).map(String),A=[],L=[];return M>0&&I<=0?(L.push(E[E.length-1]),A.push(T[0]),E.pop(),T.shift()):I<59&&I>0&&M<=0?(A.push(T[0]),L.push(E[E.length-1]),E.pop()):I>0&&M>0?(L.push(E[E.length-1]),A.push(T[0]),E.pop(),T.shift()):I===0&&M===0&&(L.push(E[E.length-1]),A.push(T[0]),E.pop()),{startType:b,endType:y,amHours:T,pmHours:E,removedAmHour:A[0]&&Number(A[0])<=9?`0${A[0]}`:A[0],removedPmHour:L[0]&&Number(L[0])<=9?`0${L[0]}`:L[0],startMinutes:Number(g)===0?[]:W(g,59).map(x=>Number(x)<=9?`0${x}`:`${x}`),endMinutes:de(0,d).map(x=>Number(x)<=9?`0${x}`:`${x}`)}}}).reduce((l,h)=>(Object.entries(h).forEach(([p,v])=>{Array.isArray(v)?l[p]=Array.isArray(l[p])?[...l[p],...v]:[...v]:l[p]=v}),l),{isInterval:!0,clockType:t,intervals:a})}}return i?.forEach(a=>{if(t==="12h"&&Number(a)>12)throw new Error("The disabled hours value has to be less than 13");if(t==="24h"&&Number(a)>23)throw new Error("The disabled hours value has to be less than 24")}),r?.forEach(a=>{if(Number(a)>59)throw new Error("The disabled minutes value has to be less than 60")}),{value:{hours:i?.map(a=>a==="00"||Number(a)===0?`0${Number(a)}`:`${Number(a)}`),minutes:r?.map(a=>Number(a)<=9?`0${a}`:`${a}`)}}},P=(n,e,t,i)=>{if(n){if(Array.isArray(n)&&n.length>0)return!n.map(s=>D(s,e,t)).some(s=>s===!1);if(typeof n=="string"||typeof n=="number"){let r=D(n,e,t),s=i?.map(Number).includes(Number(n));return!!(r&&!s)}}},w=(n,e,t,i,r)=>{if(!n||!e||!i||!r)return!1;let s=r==="12h"?U(`${n}:${e} ${t||""}`.trim()):F(`${n}:${e}`),a=Array.isArray(i)?i:[i];for(let o of a){let[c,l]=o.trim().split("-"),h,p;if(r==="12h"){let v=c.trim(),g=l.trim();if(!/\s?(AM|PM|am|pm)\s?$/.test(v)||!/\s?(AM|PM|am|pm)\s?$/.test(g)){console.warn(`Invalid 12h format in interval: "${o}". AM/PM is required for 12h clock type.`);continue}h=U(v),p=U(g)}else{let v=c.trim(),g=l.trim();if(/\s?(AM|PM|am|pm)\s?/.test(v)||/\s?(AM|PM|am|pm)\s?/.test(g)){console.warn(`Invalid 24h format in interval: "${o}". AM/PM is not allowed for 24h clock type.`);continue}h=F(v),p=F(g)}if(s>=h&&s<=p)return!1}return!0};var B=class{array;classToAdd;clockFace;tipsWrapper;theme;clockType;disabledTime;hour;activeTypeMode;constructor(e){Object.assign(this,e)}clean=()=>{let e=this.tipsWrapper?.querySelectorAll("span.timepicker-ui-hour-time-12"),t=this.tipsWrapper?.querySelectorAll("span.timepicker-ui-minutes-time");this._removeClasses(e),this._removeClasses(t)};create=()=>{if(!this.clockFace||!this.array||!this.classToAdd||!this.tipsWrapper)return;let e=(this.clockFace.offsetWidth-32)/2,t=(this.clockFace.offsetHeight-32)/2,i=e-9;this.tipsWrapper.innerHTML="";let r=document.createDocumentFragment();this.array.forEach((s,a,o)=>{let c=_e(a*(360/o.length)),l=document.createElement("span"),h=document.createElement("span");if(h.innerHTML=s,this.disabledTime&&(Array.isArray(this.disabledTime)&&this.disabledTime.includes(s)&&(h.classList.add("timepicker-ui-tips-disabled"),l.classList.add("timepicker-ui-tips-disabled"),h.setAttribute("aria-disabled","true")),this.disabledTime.isInterval&&this.disabledTime.clockType)){let v=this.classToAdd?.includes("minutes"),g=this.classToAdd?.includes("hour");if(v&&this.hour)!w(this.hour,s,this.activeTypeMode||"",this.disabledTime.intervals||[],this.disabledTime.clockType)&&(h.classList.add("timepicker-ui-tips-disabled"),l.classList.add("timepicker-ui-tips-disabled"),h.tabIndex=-1,h.setAttribute("aria-disabled","true"));else if(g){let b=!0;for(let u=0;u<60;u++){let d=u.toString().padStart(2,"0");if(w(s,d,this.activeTypeMode||"",this.disabledTime.intervals||[],this.disabledTime.clockType)){b=!1;break}}b&&(h.classList.add("timepicker-ui-tips-disabled"),l.classList.add("timepicker-ui-tips-disabled"),h.tabIndex=-1,h.setAttribute("aria-disabled","true"))}}let p=this.clockType==="24h"?"timepicker-ui-value-tips-24h":"timepicker-ui-value-tips";h.classList.add(p),h.setAttribute("role","option"),h.setAttribute("aria-selected","false"),h.tabIndex=0,l.classList.add(this.classToAdd||""),this.theme&&(l.classList.add(this.theme),h.classList.add(this.theme)),l.style.left=`${e+Math.sin(c)*i}px`,l.style.bottom=`${t+Math.cos(c)*i}px`,l.appendChild(h),r.appendChild(l)}),this.tipsWrapper.appendChild(r)};updateDisable=(e,t)=>{let i=this.tipsWrapper?.querySelectorAll("span.timepicker-ui-hour-time-12"),r=this.tipsWrapper?.querySelectorAll("span.timepicker-ui-minutes-time");if(this._removeClasses(i),this._removeClasses(r),!this.disabledTime?.isInterval||!this.disabledTime?.intervals)return;let s=this.disabledTime.intervals,a=this.disabledTime.clockType,o=t||this.activeTypeMode||"";i?.forEach(c=>{let l=c.querySelector(".timepicker-ui-value-tips");if(!l)return;let h=l.innerHTML,p=!0;for(let v=0;v<60;v++){let g=v.toString().padStart(2,"0");if(w(h,g,o,s,a)){p=!1;break}}p&&(c.classList.add("timepicker-ui-tips-disabled"),l.classList.add("timepicker-ui-tips-disabled"),l.setAttribute("aria-disabled","true"),l.tabIndex=-1)}),r&&e&&r.forEach(c=>{let l=c.querySelector(".timepicker-ui-value-tips");if(!l)return;let h=l.innerHTML;!w(e,h,o,s,a)&&(c.classList.add("timepicker-ui-tips-disabled"),l.classList.add("timepicker-ui-tips-disabled"),l.setAttribute("aria-disabled","true"),l.tabIndex=-1)})};_removeClasses=e=>{e?.forEach(t=>{let i=t.children[0];t.classList.remove("timepicker-ui-tips-disabled"),i&&(i.classList.remove("timepicker-ui-tips-disabled"),i.removeAttribute("aria-disabled"),i.tabIndex=0)})};destroy(){this.tipsWrapper&&(this.tipsWrapper.innerHTML=""),this.array=this.classToAdd=this.theme=this.clockType=void 0,this.disabledTime=this.hour=this.activeTypeMode=void 0,this.clockFace=this.tipsWrapper=void 0}};var K=class{pool=[];maxSize=5;acquire(e){let t=this.pool.pop();return t?(Object.assign(t,e),t):new B(e)}release(e){this.pool.length<this.maxSize&&this.pool.push(e)}clear(){this.pool=[]}};var z=class{timepicker;cleanupHandlers;constructor(e,t){this.timepicker=e,this.cleanupHandlers=t}handleCancelButton=()=>{let e=()=>{let t=C(this.timepicker.input,this.timepicker._options.clockType);_(this.timepicker._element,"cancel","timepicker:cancel",{...t,hourNotAccepted:this.timepicker.hour.value,minutesNotAccepted:this.timepicker.minutes.value,type:this.timepicker.activeTypeMode?.dataset.type,degreesHours:this.timepicker._degreesHours,degreesMinutes:this.timepicker._degreesMinutes},this.timepicker._options.onCancel,this.timepicker),this.timepicker.close()()};this.timepicker.cancelButton.addEventListener("click",e),this.cleanupHandlers.push(()=>{this.timepicker.cancelButton?.removeEventListener("click",e)})};handleOkButton=()=>{let e=()=>{let{clockType:t,disabledTime:i}=this.timepicker._options,r=D(this.timepicker.hour.value,"hour",t),s=D(this.timepicker.minutes.value,"minutes",t),a,o=P(this.timepicker.hour.value,"hour",t,i?.hours),c=P(this.timepicker.minutes.value,"minutes",t,i?.minutes);if(i?.interval&&(a=w(this.timepicker.hour.value,this.timepicker.minutes.value,this.timepicker.activeTypeMode?.textContent||"",i.interval,t)),a===!1||r===!1||s===!1||o===!1||c===!1){(a===!1||!s||!c)&&this.timepicker.minutes.classList.add("invalid-value"),(a===!1||!r||!o)&&this.timepicker.hour.classList.add("invalid-value");return}this.timepicker.input.value=`${this.timepicker.hour.value}:${this.timepicker.minutes.value} ${this.timepicker._options.clockType==="24h"?"":this.timepicker.activeTypeMode?.dataset.type}`.trimEnd(),_(this.timepicker._element,"","timepicker:confirm",{hour:this.timepicker.hour.value,minutes:this.timepicker.minutes.value,type:this.timepicker.activeTypeMode?.dataset.type,degreesHours:this.timepicker._degreesHours,degreesMinutes:this.timepicker._degreesMinutes},this.timepicker._options.onConfirm,this.timepicker),this.timepicker.close()()};this.timepicker.okButton?.addEventListener("click",e),this.cleanupHandlers.push(()=>{this.timepicker.okButton?.removeEventListener("click",e)})};handleBackdropClick=()=>{let e=t=>{let i=t.target;if(!m(i,"timepicker-ui-modal"))return;let r=C(this.timepicker.input,this.timepicker._options.clockType);_(this.timepicker._element,"","timepicker:cancel",{...r,hourNotAccepted:this.timepicker.hour.value,minutesNotAccepted:this.timepicker.minutes.value,type:this.timepicker.activeTypeMode?.dataset.type,degreesHours:this.timepicker._degreesHours,degreesMinutes:this.timepicker._degreesMinutes},this.timepicker._options.onCancel,this.timepicker),this.timepicker.close()()};this.timepicker.modalElement?.addEventListener("click",e),this.cleanupHandlers.push(()=>{this.timepicker.modalElement?.removeEventListener("click",e)})}};var j=class{timepicker;_isDragging=!1;_animationFrameId=null;_pendingUpdate=!1;updateHandPosition;constructor(e,t){this.timepicker=e,this.updateHandPosition=t}get isDragging(){return this._isDragging}get animationFrameId(){return this._animationFrameId}cleanup(){document.removeEventListener("mousedown",this._onDragStart,!1),document.removeEventListener("touchstart",this._onDragStart),document.removeEventListener("mousemove",this._onDragMove,!1),document.removeEventListener("mouseup",this._onDragEnd,!1),document.removeEventListener("touchmove",this._onDragMove),document.removeEventListener("touchend",this._onDragEnd,!1),document.removeEventListener("mouseleave",this._onDragEnd,!1),this._animationFrameId&&(cancelAnimationFrame(this._animationFrameId),this._animationFrameId=null),this._isDragging=!1,this._pendingUpdate=!1}_onDragStart=e=>{let t=e.target;(m(t,"timepicker-ui-clock-face")||m(t,"timepicker-ui-circle-hand")||m(t,"timepicker-ui-hour-time-12")||m(t,"timepicker-ui-minutes-time")||m(t,"timepicker-ui-clock-hand")||m(t,"timepicker-ui-value-tips")||m(t,"timepicker-ui-value-tips-24h")||m(t,"timepicker-ui-tips-wrapper")||m(t,"timepicker-ui-tips-wrapper-24h"))&&!m(t,"timepicker-ui-tips-disabled")&&(e.preventDefault(),this._isDragging=!0,this.timepicker._isTouchMouseMove=!0,document.addEventListener("mousemove",this._onDragMove,!1),document.addEventListener("mouseup",this._onDragEnd,!1),document.addEventListener("touchmove",this._onDragMove,{passive:!1}),document.addEventListener("touchend",this._onDragEnd,!1),document.addEventListener("mouseleave",this._onDragEnd,!1),this._scheduleUpdate(e))};_onDragMove=e=>{this._isDragging&&(e.preventDefault(),this._scheduleUpdate(e))};_onDragEnd=e=>{if(!this._isDragging)return;this._isDragging=!1,this.timepicker._isTouchMouseMove=!1,document.removeEventListener("mousemove",this._onDragMove,!1),document.removeEventListener("mouseup",this._onDragEnd,!1),document.removeEventListener("touchmove",this._onDragMove),document.removeEventListener("touchend",this._onDragEnd,!1),document.removeEventListener("mouseleave",this._onDragEnd,!1),this._animationFrameId&&(cancelAnimationFrame(this._animationFrameId),this._animationFrameId=null,this._pendingUpdate=!1);let t=e.target,{switchToMinutesAfterSelectHour:i}=this.timepicker._options;i&&(m(t,"timepicker-ui-value-tips")||m(t,"timepicker-ui-value-tips-24h")||m(t,"timepicker-ui-tips-wrapper"))&&this.timepicker.minutes.click()};_scheduleUpdate=e=>{this._pendingUpdate||(this._pendingUpdate=!0,this._animationFrameId=requestAnimationFrame(()=>{this._pendingUpdate=!1,this.updateHandPosition(e)}))};handleEventToMoveHand=e=>{let{type:t}=e;t==="mousedown"||t==="touchstart"?this._onDragStart(e):t==="mouseup"||t==="touchend"?this._onDragEnd(e):(t==="mousemove"||t==="touchmove")&&this._isDragging&&this._onDragMove(e)};handleMoveHand=()=>{this.timepicker._options.mobile||this.timepicker._isMobileView||(document.addEventListener("mousedown",this._onDragStart,!1),document.addEventListener("touchstart",this._onDragStart,{passive:!1}))}};var S=(n,e)=>{if(!n)return;let t=n.querySelector(".timepicker-announcer");t&&(t.textContent="",setTimeout(()=>{t.textContent=e},100))},Y=(n,e)=>{n&&n.setAttribute("aria-pressed",String(e))};var Z=class{timepicker;cleanupHandlers;constructor(e,t){this.timepicker=e,this.cleanupHandlers=t}handleAmClick=()=>{this.timepicker._clickTouchEvents.forEach(e=>{let t=i=>{let r=i.target;r.classList.add(H),this.timepicker.PM.classList.remove(H),Y(r,!0),Y(this.timepicker.PM,!1),S(this.timepicker.modalElement,"AM selected"),this.timepicker._options.clockType==="12h"&&this.timepicker._options.disabledTime?.interval&&setTimeout(()=>{let s=this.timepicker.clockFacePool.acquire({clockFace:this.timepicker.clockFace,tipsWrapper:this.timepicker.tipsWrapper,disabledTime:this.timepicker._disabledTime?.value,clockType:this.timepicker._options.clockType,activeTypeMode:"AM"});s.updateDisable(this.timepicker.hour.value,"AM"),this.timepicker.clockFacePool.release(s)},300),_(this.timepicker._element,"","timepicker:select-am",{hour:this.timepicker.hour.value,minutes:this.timepicker.minutes.value,type:this.timepicker.activeTypeMode?.dataset.type,degreesHours:this.timepicker._degreesHours,degreesMinutes:this.timepicker._degreesMinutes},this.timepicker._options.onSelectAM,this.timepicker)};this.timepicker.AM.addEventListener(e,t),this.cleanupHandlers.push(()=>{this.timepicker.AM?.removeEventListener(e,t)})})};handlePmClick=()=>{this.timepicker._clickTouchEvents.forEach(e=>{let t=i=>{let r=i.target;r.classList.add(H),this.timepicker.AM.classList.remove(H),Y(r,!0),Y(this.timepicker.AM,!1),S(this.timepicker.modalElement,"PM selected"),this.timepicker._options.clockType==="12h"&&this.timepicker._options.disabledTime?.interval&&setTimeout(()=>{let s=this.timepicker.clockFacePool.acquire({clockFace:this.timepicker.clockFace,tipsWrapper:this.timepicker.tipsWrapper,disabledTime:this.timepicker._disabledTime?.value,clockType:this.timepicker._options.clockType,activeTypeMode:"PM"});s.updateDisable(this.timepicker.hour.value,"PM"),this.timepicker.clockFacePool.release(s)},300),_(this.timepicker._element,"","timepicker:select-pm",{hour:this.timepicker.hour.value,minutes:this.timepicker.minutes.value,type:this.timepicker.activeTypeMode?.dataset.type,degreesHours:this.timepicker._degreesHours,degreesMinutes:this.timepicker._degreesMinutes},this.timepicker._options.onSelectPM,this.timepicker)};this.timepicker.PM.addEventListener(e,t),this.cleanupHandlers.push(()=>{this.timepicker.PM?.removeEventListener(e,t)})})}};var J=class{timepicker;cleanupHandlers;constructor(e,t){this.timepicker=e,this.cleanupHandlers=t}handleClasses24h=(e,t,i=!1)=>{let r=e.target,s=e.relatedTarget;this.timepicker.hourTips&&this.timepicker._options.clockType==="24h"&&(Number(r.textContent)>12||Number(r.textContent)===0?this.timepicker.clockManager&&this.timepicker.clockManager.setCircleClockClasses24h():this.timepicker.clockManager&&this.timepicker.clockManager.removeCircleClockClasses24h(),this.timepicker._options.mobile||this.timepicker.tipsWrapperFor24h?.classList.remove("timepicker-ui-tips-wrapper-24h-disabled")),!(!r||!t)&&(t.value=r.value.replace(/\D+/g,""),i&&s?s.classList.contains("timepicker-ui-am")||s.classList.contains("timepicker-ui-pm")||t.click():i&&t.click())};handleHourEvents=()=>{this.timepicker._inputEvents.forEach(i=>{let r=s=>{let a=s.target;this.timepicker.clockFace!==null&&this.timepicker.animationManager&&this.timepicker.animationManager.handleAnimationSwitchTipsMode(),this.timepicker._options.clockType==="24h"&&this.timepicker.clockFace!==null&&(Number(this.timepicker.hour.value)>12||this.timepicker.hour.value==="00"?this.timepicker.clockManager&&this.timepicker.clockManager.setCircleClockClasses24h():this.timepicker.clockManager&&this.timepicker.clockManager.removeCircleClockClasses24h(),this.timepicker._options.mobile||this.timepicker.tipsWrapperFor24h?.classList.remove("timepicker-ui-tips-wrapper-24h-disabled")),this.timepicker.clockManager&&this.timepicker.clockManager.setHoursToClock(a.value),this.timepicker.minutes.classList.remove(H),this.timepicker.hour.classList.add(H),this.timepicker._options.clockType==="12h"&&this.timepicker._options.disabledTime?.interval&&setTimeout(()=>{let o=this.timepicker.clockFacePool.acquire({clockFace:this.timepicker.clockFace,tipsWrapper:this.timepicker.tipsWrapper,disabledTime:this.timepicker._disabledTime?.value,clockType:this.timepicker._options.clockType,activeTypeMode:this.timepicker.activeTypeMode?.textContent||""});o.updateDisable(this.timepicker.hour.value,this.timepicker.activeTypeMode?.textContent||""),this.timepicker.clockFacePool.release(o)},300),_(this.timepicker._element,"","timepicker:select-hour",{hour:this.timepicker.hour.value,minutes:this.timepicker.minutes.value,type:this.timepicker.activeTypeMode?.dataset.type,degreesHours:this.timepicker._degreesHours,degreesMinutes:this.timepicker._degreesMinutes},this.timepicker._options.onSelectHour,this.timepicker),this.timepicker.clockFace!==null&&this.timepicker.circle.classList.remove("small-circle")};this.timepicker.hour?.addEventListener(i,r),this.cleanupHandlers.push(()=>{this.timepicker.hour?.removeEventListener(i,r)})});let e=i=>this.handleClasses24h(i,this.timepicker.hour,!0),t=i=>this.handleClasses24h(i,this.timepicker.hour,!1);this.timepicker.hour?.addEventListener("blur",e),this.timepicker.hour?.addEventListener("focus",t),this.cleanupHandlers.push(()=>{this.timepicker.hour?.removeEventListener("blur",e),this.timepicker.hour?.removeEventListener("focus",t)})};handleMinutesEvents=()=>{this.timepicker._inputEvents.forEach(i=>{let r=s=>{let a=s.target;this.timepicker.clockFace!==null&&(this.timepicker.animationManager&&this.timepicker.animationManager.handleAnimationSwitchTipsMode(),this.timepicker.clockManager&&this.timepicker.clockManager.setMinutesToClock(a.value)),this.timepicker._options.clockType==="24h"&&(this.timepicker.clockManager&&this.timepicker.clockManager.removeCircleClockClasses24h(),this.timepicker._options.mobile||this.timepicker.tipsWrapperFor24h?.classList.add("timepicker-ui-tips-wrapper-24h-disabled")),this.timepicker.hour.classList.remove(H),this.timepicker.minutes.classList.add(H),this.timepicker._options.clockType==="12h"&&this.timepicker._options.disabledTime?.interval&&setTimeout(()=>{let o=this.timepicker.clockFacePool.acquire({clockFace:this.timepicker.clockFace,tipsWrapper:this.timepicker.tipsWrapper,disabledTime:this.timepicker._disabledTime?.value,clockType:this.timepicker._options.clockType,activeTypeMode:this.timepicker.activeTypeMode?.textContent||""});o.updateDisable(this.timepicker.hour.value,this.timepicker.activeTypeMode?.textContent||""),this.timepicker.clockFacePool.release(o)},300),_(this.timepicker._element,"","timepicker:select-minute",{hour:this.timepicker.hour.value,minutes:this.timepicker.minutes.value,type:this.timepicker.activeTypeMode?.dataset.type,degreesHours:this.timepicker._degreesHours,degreesMinutes:this.timepicker._degreesMinutes},this.timepicker._options.onSelectMinute,this.timepicker)};this.timepicker.minutes.addEventListener(i,r),this.cleanupHandlers.push(()=>{this.timepicker.minutes?.removeEventListener(i,r)})});let e=i=>this.handleClasses24h(i,this.timepicker.minutes,!0),t=i=>this.handleClasses24h(i,this.timepicker.minutes,!1);this.timepicker.minutes?.addEventListener("blur",e),this.timepicker.minutes?.addEventListener("focus",t),this.cleanupHandlers.push(()=>{this.timepicker.minutes?.removeEventListener("blur",e),this.timepicker.minutes?.removeEventListener("focus",t)})}};var X=class{timepicker;constructor(e){this.timepicker=e}updateHandPosition=e=>{let{target:t,type:i}=e,r=t,{incrementMinutes:s,incrementHours:a}=this.timepicker._options;if(!ge(e,this.timepicker.clockFace))return;let o=ge(e,this.timepicker.clockFace),c=this.timepicker.clockFace.offsetWidth/2,l=o&&Math.atan2(o.y-c,o.x-c);if(this.timepicker.minutesTips!==null){this.timepicker.minutes.classList.add(H);let g=l&&ue(Math.trunc(l*180/Math.PI)+90,s,6);if(g===void 0)return;let b;if(g<0?(b=Math.round(360+g/6)%60,g=360+Math.round(g/6)*6):(b=Math.round(g/6)%60,g=Math.round(g/6)*6),this.timepicker?._disabledTime?.value?.isInterval){let u=b<=9?`0${b}`:`${b}`,d=this.timepicker.hour.value,y=this.timepicker.activeTypeMode?.textContent||"";if(!w(d,u,y,this.timepicker._disabledTime.value.intervals,this.timepicker._options.clockType))return}else{let u=this.timepicker._disabledTime?.value?.minutes;if(u&&Array.isArray(u)&&u.includes(b<=9?`0${b}`:`${b}`))return}this.timepicker.minutes.value=b>=10?`${b}`:`0${b}`,this.timepicker.minutes.setAttribute("aria-valuenow",this.timepicker.minutes.value),this.timepicker.clockHand.style.transform=`rotateZ(${g}deg)`,this.timepicker._degreesMinutes=g,this.timepicker.clockManager&&(this.timepicker.clockManager.toggleClassActiveToValueTips(this.timepicker.minutes.value),this.timepicker.clockManager.removeBgColorToCirleWithMinutesTips(),this.timepicker.clockManager.setBgColorToCircleWithMinutesTips()),S(this.timepicker.modalElement,`Minute ${this.timepicker.minutes.value}`),_(this.timepicker._element,"update","timepicker:update",{...C(this.timepicker.input,this.timepicker._options.clockType),degreesHours:this.timepicker._degreesHours,degreesMinutes:this.timepicker._degreesMinutes,eventType:i,type:this.timepicker.activeTypeMode?.dataset.type},this.timepicker._options.onUpdate,this.timepicker)}let h=e.touches,p=h?h[0]:void 0,v=h&&p?document.elementFromPoint(p.clientX,p.clientY):null;if(this.timepicker.hourTips!==null){this.timepicker.hour?.classList.add(H);let g=this.timepicker._options.clockType==="24h",b=!1;if(g){let u=this.timepicker.clockFace.offsetWidth/2,d=o?Math.sqrt(Math.pow(o.x-u,2)+Math.pow(o.y-u,2)):0,y=u*.6;b=d<y}if(!m(v||r,"timepicker-ui-tips-disabled")&&(!g||!b)&&(m(v||r,"timepicker-ui-value-tips")||m(v||r,"timepicker-ui-tips-wrapper")||m(v||r,"timepicker-ui-value-tips-24h")||m(v||r,"timepicker-ui-tips-wrapper-24h"))){let u=l&&ue(Math.trunc(l*180/Math.PI)+90,a,30);if(this.timepicker._degreesHours=u,u===void 0)return;let d;if(u<0?(d=Math.round(360+u/30)%12,u=360+u):(d=Math.round(u/30)%12,(d===0||d>12)&&(d=12)),this.timepicker._disabledTime?.value?.isInterval){let y=d>9?`${d}`:`0${d}`,k=this.timepicker.activeTypeMode?.textContent||"",f=!0;for(let M=0;M<60;M++){let I=M<=9?`0${M}`:`${M}`;if(w(y,I,k,this.timepicker._disabledTime.value.intervals,this.timepicker._options.clockType)){f=!1;break}}if(f)return}else{let y=this.timepicker._disabledTime?.value?.hours;if(y&&Array.isArray(y)&&y.includes(d.toString()))return}this.timepicker.clockHand.style.transform=`rotateZ(${u}deg)`,this.timepicker.hour.value=d>9?`${d}`:`0${d}`,this.timepicker.hour.setAttribute("aria-valuenow",this.timepicker.hour.value),this.timepicker.clockManager&&(this.timepicker.clockManager.removeCircleClockClasses24h(),this.timepicker.clockManager.toggleClassActiveToValueTips(d)),S(this.timepicker.modalElement,`Hour ${this.timepicker.hour.value}`)}if(g&&!m(v||r,"timepicker-ui-tips-disabled")&&b&&(m(v||r,"timepicker-ui-value-tips-24h")||m(v||r,"timepicker-ui-tips-wrapper-24h")||m(v||r,"timepicker-ui-value-tips")||m(v||r,"timepicker-ui-tips-wrapper"))){let u=l&&ue(Math.trunc(l*180/Math.PI)+90,a,30);this.timepicker._degreesHours=u;let d;if(u===void 0)return;if(u<0?(d=Math.round(360+u/30)%24,u=360+u):(d=Math.round(u/30)+12,d===12&&(d="00")),this.timepicker._disabledTime?.value?.isInterval){let y=typeof d=="number"?d<=9?`0${d}`:`${d}`:d,k=!0;for(let f=0;f<60;f++){let M=f<=9?`0${f}`:`${f}`;if(w(y,M,"",this.timepicker._disabledTime.value.intervals,this.timepicker._options.clockType)){k=!1;break}}if(k)return}else{let y=this.timepicker._disabledTime?.value?.hours;if(y&&Array.isArray(y)&&y.includes(d.toString()))return}this.timepicker.clockManager&&this.timepicker.clockManager.setCircleClockClasses24h(),this.timepicker.clockHand.style.transform=`rotateZ(${u}deg)`,this.timepicker.hour.value=`${d}`,this.timepicker.hour.setAttribute("aria-valuenow",this.timepicker.hour.value),this.timepicker.clockManager&&this.timepicker.clockManager.toggleClassActiveToValueTips(d),S(this.timepicker.modalElement,`Hour ${this.timepicker.hour.value}`)}_(this.timepicker._element,"","timepicker:update",{...C(this.timepicker.input,this.timepicker._options.clockType),degreesHours:this.timepicker._degreesHours,degreesMinutes:this.timepicker._degreesMinutes,eventType:i,type:this.timepicker.activeTypeMode?.dataset.type},this.timepicker._options.onUpdate,this.timepicker)}}};var G=class{timepicker;cleanupHandlers;constructor(e,t){this.timepicker=e,this.cleanupHandlers=t}handleOpenOnClick=()=>{this.timepicker.openElement.forEach(e=>{let t=()=>this.timepicker._eventsBundle();e?.addEventListener("click",t),this.cleanupHandlers.push(()=>{e?.removeEventListener("click",t)})})};handleOpenOnEnterFocus=()=>{let e=({target:t,key:i})=>{t.disabled||i==="Enter"&&this.timepicker.open()};this.timepicker.input.addEventListener("keydown",e),this.cleanupHandlers.push(()=>{this.timepicker.input.removeEventListener("keydown",e)})};handleClickOnHourMobile=()=>{document.addEventListener("mousedown",this.timepicker._eventsClickMobileHandler),document.addEventListener("touchstart",this.timepicker._eventsClickMobileHandler),this.cleanupHandlers.push(()=>{document.removeEventListener("mousedown",this.timepicker._eventsClickMobileHandler),document.removeEventListener("touchstart",this.timepicker._eventsClickMobileHandler)})};handlerClickHourMinutes=async e=>{if(!this.timepicker.modalElement)return;let{clockType:t,editable:i}=this.timepicker._options,r=e.target,s=D(this.timepicker.hour.value,"hour",t),a=D(this.timepicker.minutes.value,"minutes",t);i&&(!m(r,"timepicker-ui-hour")&&!m(r,"timepicker-ui-minutes")?s===!0&&a===!0&&(a&&this.timepicker.minutes.classList.remove("invalid-value"),s&&this.timepicker.hour?.classList.remove("invalid-value")):(s===!1||a===!1)&&(a||this.timepicker.minutes.classList.add("invalid-value"),s||this.timepicker.hour?.classList.add("invalid-value")))};handleIconChangeView=async()=>{if(this.timepicker._options.enableSwitchIcon&&this.timepicker.configManager){let e=this.timepicker.configManager.handlerViewChange();He()?(this.timepicker.keyboardClockIcon.addEventListener("touchstart",e),this.cleanupHandlers.push(()=>{this.timepicker.keyboardClockIcon?.removeEventListener("touchstart",e)})):(this.timepicker.keyboardClockIcon.addEventListener("click",e),this.cleanupHandlers.push(()=>{this.timepicker.keyboardClockIcon?.removeEventListener("click",e)}))}};handleKeyPress=e=>{if(e.key==="Escape"&&this.timepicker.modalElement){let t=C(this.timepicker.input,this.timepicker._options.clockType);_(this.timepicker._element,"","timepicker:cancel",{...t,hourNotAccepted:this.timepicker.hour.value,minutesNotAccepted:this.timepicker.minutes.value,type:this.timepicker.activeTypeMode?.dataset.type,degreesHours:this.timepicker._degreesHours,degreesMinutes:this.timepicker._degreesMinutes},this.timepicker._options.onCancel,this.timepicker),this.timepicker.close()()}};handleEscClick=()=>{document.addEventListener("keydown",this.handleKeyPress),this.cleanupHandlers.push(()=>{document.removeEventListener("keydown",this.handleKeyPress)})};focusTrapHandler=()=>{setTimeout(()=>{let e=this.timepicker.wrapper?.querySelectorAll('div[tabindex="0"]:not([disabled])'),t=this.timepicker.wrapper?.querySelectorAll('input[tabindex="0"]:not([disabled])');if(!e||e.length<=0||t.length<=0)return;let i=[...t,...e],r=i[0],s=i[i.length-1];this.timepicker.wrapper.focus();let a=o=>{let{key:c,shiftKey:l,target:h}=o,p=h;if(c==="Tab"&&(l?document.activeElement===r&&(s.focus(),o.preventDefault()):document.activeElement===s&&(r.focus(),o.preventDefault())),c==="ArrowUp"||c==="ArrowDown"||c==="ArrowLeft"||c==="ArrowRight"){let v=m(p,"timepicker-ui-value-tips")||m(p,"timepicker-ui-value-tips-24h"),g=m(p,"timepicker-ui-hour"),b=m(p,"timepicker-ui-minutes");if(v){let u=p.parentElement,d=m(u,"timepicker-ui-minutes-time"),y=m(u,"timepicker-ui-hour-time-12")||m(u,"timepicker-ui-hour-time-24");if(d){let k=parseInt(this.timepicker.minutes.value||"0"),f=k;c==="ArrowUp"||c==="ArrowRight"?f=k>=59?0:k+1:(c==="ArrowDown"||c==="ArrowLeft")&&(f=k<=0?59:k-1);let M=f<10?`0${f}`:`${f}`,I=this.timepicker.hour.value,T=this.timepicker.activeTypeMode?.textContent||"";if(this.timepicker._disabledTime?.value?.isInterval&&this.timepicker._disabledTime?.value?.intervals&&!w(I,M,T,this.timepicker._disabledTime.value.intervals,this.timepicker._options.clockType))return;this.timepicker.minutes.value=M,this.timepicker.minutes.setAttribute("aria-valuenow",this.timepicker.minutes.value),this.timepicker.clockManager&&(this.timepicker.clockManager.setTransformToCircleWithSwitchesMinutes(this.timepicker.minutes.value),this.timepicker.clockManager.toggleClassActiveToValueTips(f))}else if(y){let k=parseInt(this.timepicker.hour.value||"0"),f=this.timepicker._options.clockType==="24h",M=f?23:12,I=f?0:1,T=k;c==="ArrowUp"||c==="ArrowRight"?T=k>=M?I:k+1:(c==="ArrowDown"||c==="ArrowLeft")&&(T=k<=I?M:k-1);let E=T<10?`0${T}`:`${T}`,A=this.timepicker.activeTypeMode?.textContent||"";if(this.timepicker._disabledTime?.value?.isInterval&&this.timepicker._disabledTime?.value?.intervals){let L=!0;for(let x=0;x<60;x++){let xe=x.toString().padStart(2,"0");if(w(E,xe,A,this.timepicker._disabledTime.value.intervals,this.timepicker._options.clockType)){L=!1;break}}if(L)return}this.timepicker.hour.value=E,this.timepicker.hour.setAttribute("aria-valuenow",this.timepicker.hour.value),this.timepicker.clockManager&&(this.timepicker.clockManager.setTransformToCircleWithSwitchesHour(this.timepicker.hour.value),this.timepicker.clockManager.toggleClassActiveToValueTips(T))}}if(g||b){let u=parseInt(p.value)||0,d=g,y=d?this.timepicker._options.clockType==="12h"?12:23:59,k=d&&this.timepicker._options.clockType==="12h"?1:0,f=u;c==="ArrowUp"?f=u>=y?k:u+1:c==="ArrowDown"&&(f=u<=k?y:u-1),p.value=f<10?`0${f}`:`${f}`,p.setAttribute("aria-valuenow",p.value)}}(c==="a"||c==="A")&&this.timepicker.AM&&!m(p,"timepicker-ui-hour")&&!m(p,"timepicker-ui-minutes")&&this.timepicker.AM.click(),(c==="p"||c==="P")&&this.timepicker.PM&&!m(p,"timepicker-ui-hour")&&!m(p,"timepicker-ui-minutes")&&this.timepicker.PM.click(),c==="Enter"&&(m(p,"timepicker-ui-minutes")&&this.timepicker.minutes.click(),m(p,"timepicker-ui-hour")&&this.timepicker.hour.click(),m(p,"timepicker-ui-am")&&this.timepicker.AM.click(),m(p,"timepicker-ui-pm")&&this.timepicker.PM.click(),m(p,"timepicker-ui-ok-btn")&&this.timepicker.okButton.click(),m(p,"timepicker-ui-cancel-btn")&&this.timepicker.cancelButton.click(),m(p,"timepicker-ui-keyboard-icon-wrapper")&&this.timepicker.keyboardClockIcon.click())};this.timepicker.wrapper.addEventListener("keydown",a),this.cleanupHandlers.push(()=>{this.timepicker.wrapper?.removeEventListener("keydown",a)})},100)}};var Q=class{timepicker;cleanupHandlers;constructor(e,t){this.timepicker=e,this.cleanupHandlers=t}handleInlineAutoUpdate=()=>{if(!this.timepicker._options.inline?.enabled||this.timepicker._options.inline.autoUpdate===!1)return;let e=()=>{let r=this.timepicker.hour?.value,s=this.timepicker.minutes?.value,a=this.timepicker.activeTypeMode?.textContent;if(r&&s){let o="";if(this.timepicker._options.clockType==="24h"){let c=r.padStart(2,"0"),l=s.padStart(2,"0");o=`${c}:${l}`}else{let c=r,l=s.padStart(2,"0");o=`${c}:${l} ${a||"AM"}`}if(this.timepicker.input){this.timepicker.input.value=o;let c=new Event("change",{bubbles:!0});this.timepicker.input.dispatchEvent(c),_(this.timepicker._element,"","timepicker:confirm",{hour:r,minutes:s,type:a,degreesHours:this.timepicker._degreesHours,degreesMinutes:this.timepicker._degreesMinutes},this.timepicker._options.onConfirm,this.timepicker)}}};["input","change"].forEach(r=>{let s=()=>setTimeout(e,50),a=()=>setTimeout(e,50);this.timepicker.hour?.addEventListener(r,s),this.timepicker.minutes?.addEventListener(r,a),this.cleanupHandlers.push(()=>{this.timepicker.hour?.removeEventListener(r,s),this.timepicker.minutes?.removeEventListener(r,a)})}),this.timepicker._options.clockType!=="24h"&&this.timepicker._clickTouchEvents.forEach(r=>{let s=()=>setTimeout(e,50),a=()=>setTimeout(e,50);this.timepicker.AM?.addEventListener(r,s),this.timepicker.PM?.addEventListener(r,a),this.cleanupHandlers.push(()=>{this.timepicker.AM?.removeEventListener(r,s),this.timepicker.PM?.removeEventListener(r,a)})});let i=()=>setTimeout(e,100);this.timepicker.clockFace?.addEventListener("click",i),this.cleanupHandlers.push(()=>{this.timepicker.clockFace?.removeEventListener("click",i)})}};var ee=class{_cleanupHandlers=[];buttonHandlers;dragHandlers;typeModeHandlers;inputHandlers;clockHandPositionUpdater;miscHandlers;inlineHandlers;constructor(e){this.clockHandPositionUpdater=new X(e),this.dragHandlers=new j(e,this.clockHandPositionUpdater.updateHandPosition),this.buttonHandlers=new z(e,this._cleanupHandlers),this.typeModeHandlers=new Z(e,this._cleanupHandlers),this.inputHandlers=new J(e,this._cleanupHandlers),this.miscHandlers=new G(e,this._cleanupHandlers),this.inlineHandlers=new Q(e,this._cleanupHandlers)}destroy(){this._cleanupHandlers.forEach(e=>{try{e()}catch(t){console.error("EventManager cleanup error:",t)}}),this._cleanupHandlers=[],this.dragHandlers.cleanup()}handleOpenOnClick=()=>this.miscHandlers.handleOpenOnClick();handleOpenOnEnterFocus=()=>this.miscHandlers.handleOpenOnEnterFocus();handleCancelButton=()=>this.buttonHandlers.handleCancelButton();handleOkButton=()=>this.buttonHandlers.handleOkButton();handleBackdropClick=()=>this.buttonHandlers.handleBackdropClick();handleAmClick=()=>this.typeModeHandlers.handleAmClick();handlePmClick=()=>this.typeModeHandlers.handlePmClick();handleHourEvents=()=>this.inputHandlers.handleHourEvents();handleMinutesEvents=()=>this.inputHandlers.handleMinutesEvents();handleEventToMoveHand=e=>this.dragHandlers.handleEventToMoveHand(e);handleMoveHand=()=>this.dragHandlers.handleMoveHand();handleClickOnHourMobile=()=>this.miscHandlers.handleClickOnHourMobile();handlerClickHourMinutes=e=>this.miscHandlers.handlerClickHourMinutes(e);handleIconChangeView=()=>this.miscHandlers.handleIconChangeView();handleEscClick=()=>this.miscHandlers.handleEscClick();focusTrapHandler=()=>this.miscHandlers.focusTrapHandler();handleInlineAutoUpdate=()=>this.inlineHandlers.handleInlineAutoUpdate();get _isDragging(){return this.dragHandlers.isDragging}get _animationFrameId(){return this.dragHandlers.animationFrameId}_onDragStart=e=>this.dragHandlers._onDragStart(e);_onDragMove=e=>this.dragHandlers._onDragMove(e);_onDragEnd=e=>this.dragHandlers._onDragEnd(e)};var te=class{timepicker;timeouts=[];originalOverflow;originalPaddingRight;constructor(e){this.timepicker=e}runWithTimeout(e,t=300){let i=setTimeout(e,t);this.timeouts.push(i)}clearAllTimeouts(){this.timeouts.forEach(clearTimeout),this.timeouts=[]}clearExistingModal(){let e=document.querySelector(".timepicker-ui-modal");e&&e.remove()}setModalTemplate=()=>{if(!this.timepicker._options)return;if(this.clearExistingModal(),this.timepicker._options.inline?.enabled){let t=document.getElementById(this.timepicker._options.inline.containerId);if(!t)return;t.innerHTML="",t.insertAdjacentHTML("beforeend",this.timepicker.modalTemplate);let i=t.querySelector(".timepicker-ui-modal");if(i){i.classList.add("timepicker-ui--inline");let{showButtons:r}=this.timepicker._options.inline;(r===!1||r===void 0)&&i.querySelectorAll(".timepicker-ui-wrapper-btn, .timepicker-ui-wrapper-btn.mobile").forEach(s=>s.style.display="none")}return}let{appendModalSelector:e}=this.timepicker._options;e?document.querySelector(e)?.insertAdjacentHTML("beforeend",this.timepicker.modalTemplate):document.body.insertAdjacentHTML("beforeend",this.timepicker.modalTemplate)};setScrollbarOrNot=()=>{this.timepicker._options.inline?.enabled||(this.timepicker._options.enableScrollbar?this.runWithTimeout(()=>{document.body.style.overflowY=this.originalOverflow||"",document.body.style.paddingRight=this.originalPaddingRight||""},400):(this.originalOverflow=document.body.style.overflowY,this.originalPaddingRight=document.body.style.paddingRight,document.body.style.paddingRight=`${Ee()}px`,document.body.style.overflowY="hidden"))};removeBackdrop=()=>{this.timepicker._options.inline?.enabled||this.timepicker._options.backdrop||(this.timepicker.modalElement?.classList.add("removed"),this.timepicker.openElement.forEach(e=>e?.classList.add("disabled")))};setNormalizeClass=()=>{let e=this.timepicker.modalElement;if(!e)return;e.classList.add("timepicker-ui-normalize"),e.querySelectorAll(":scope > div").forEach(i=>i.classList.add("timepicker-ui-normalize"))};setShowClassToBackdrop=()=>{if(this.timepicker._options.inline?.enabled){this.timepicker.modalElement?.classList.add("show");return}this.timepicker._options.backdrop&&this.runWithTimeout(()=>{this.timepicker.modalElement?.classList.add("show")},300)};setFlexEndToFooterIfNoKeyboardIcon=()=>{!this.timepicker._options.enableSwitchIcon&&this.timepicker.footer&&(this.timepicker.footer.style.justifyContent="flex-end")};destroy(){this.clearAllTimeouts(),this.timepicker._options.inline?.enabled||(document.body.style.overflowY=this.originalOverflow||"",document.body.style.paddingRight=this.originalPaddingRight||""),this.clearExistingModal()}};var ye={MODAL:150,CLOCK:600,TIPS:401},ie=class{timepicker;timeouts=[];constructor(e){this.timepicker=e}runWithAnimation(e,t=ye.MODAL){if(this.timepicker._options.animation){let i=setTimeout(e,t);this.timeouts.push(i)}else e()}clearAllTimeouts(){this.timeouts.forEach(clearTimeout),this.timeouts=[]}setAnimationToOpen(){this.clearAllTimeouts(),this.timepicker.modalElement?.classList.add("opacity"),this.runWithAnimation(()=>{this.timepicker.modalElement?.classList.add("show")})}removeAnimationToClose(){this.clearAllTimeouts(),this.timepicker.modalElement&&this.runWithAnimation(()=>{this.timepicker.modalElement?.classList.remove("show"),this.timepicker.modalElement?.classList.remove("opacity")})}handleAnimationClock(){this.timepicker._options.animation&&this.runWithAnimation(()=>{this.timepicker.clockFace?.classList.add("timepicker-ui-clock-animation");let e=setTimeout(()=>{this.timepicker.clockFace?.classList.remove("timepicker-ui-clock-animation")},ye.CLOCK);this.timeouts.push(e)})}handleAnimationSwitchTipsMode(){let{clockHand:e}=this.timepicker;if(!e)return;e.classList.add("timepicker-ui-tips-animation");let t=setTimeout(()=>{e.classList.remove("timepicker-ui-tips-animation")},ye.TIPS);this.timeouts.push(t)}destroy(){this.clearAllTimeouts()}};ve();var re=class{timepicker;constructor(e){this.timepicker=e}removeCircleClockClasses24h(){this.timepicker.circle?.classList.remove("timepicker-ui-circle-hand-24h"),this.timepicker.clockHand?.classList.remove("timepicker-ui-clock-hand-24h")}setCircleClockClasses24h(){this.timepicker.circle&&this.timepicker.circle?.classList.add("timepicker-ui-circle-hand-24h"),this.timepicker.clockHand&&this.timepicker.clockHand?.classList.add("timepicker-ui-clock-hand-24h")}setOnStartCSSClassesIfClockType24h(){if(this.timepicker._options.clockType==="24h"){let t=this.timepicker?.configManager?.getInputValue(this.timepicker.input,this.timepicker._options.clockType,this.timepicker._options.currentTime)?.hour;this.timepicker.input.value.length>0&&(t=this.timepicker.input.value.split(":")[0]),(Number(t)>12||Number(t)===0)&&this.setCircleClockClasses24h()}}setBgColorToCircleWithMinutesTips=()=>{if(this.timepicker.minutes.value&&R.includes(this.timepicker.minutes.value)){let e=getComputedStyle(this.timepicker.circle).getPropertyValue("--timepicker-primary").trim();e&&(this.timepicker.circle.style.backgroundColor=e),this.timepicker.circle.classList.remove("small-circle")}};removeBgColorToCirleWithMinutesTips=()=>{this.timepicker.minutes.value&&R.includes(this.timepicker.minutes.value)||(this.timepicker.circle.style.backgroundColor="",this.timepicker.circle.classList.add("small-circle"))};setClassActiveToHourOnOpen=()=>{this.timepicker._options.mobile||this.timepicker._isMobileView||this.timepicker.hour?.classList.add(H)};setMinutesToClock=e=>{this.timepicker.clockFace!==null&&this.setTransformToCircleWithSwitchesMinutes(e),this.removeBgColorToCirleWithMinutesTips();let t=this.timepicker._disabledTime?.value||null,i=this.timepicker.clockFacePool.acquire({array:R,classToAdd:"timepicker-ui-minutes-time",clockFace:this.timepicker.clockFace,tipsWrapper:this.timepicker.tipsWrapper,theme:this.timepicker._options.theme,disabledTime:t,hour:this.timepicker.hour.value,clockType:this.timepicker._options.clockType});i.create(),this.timepicker._options.clockType==="12h"&&i.updateDisable(),this.timepicker.clockFacePool.release(i),this.toggleClassActiveToValueTips(e),this.timepicker._options.clockType==="24h"&&(this.timepicker.tipsWrapperFor24h.innerHTML="")};setHoursToClock=e=>{if(this.timepicker.clockFace!==null){this.setTransformToCircleWithSwitchesHour(e);let t=this.timepicker._disabledTime?.value||null,i=this.timepicker.clockFacePool.acquire({array:q,classToAdd:"timepicker-ui-hour-time-12",clockFace:this.timepicker.clockFace,tipsWrapper:this.timepicker.tipsWrapper,theme:this.timepicker._options.theme,disabledTime:t,clockType:"12h",hour:this.timepicker.hour.value});if(i.create(),this.timepicker._options.clockType==="24h"){let r=this.timepicker.clockFacePool.acquire({array:V,classToAdd:"timepicker-ui-hour-time-24",clockFace:this.timepicker.tipsWrapperFor24h,tipsWrapper:this.timepicker.tipsWrapperFor24h,theme:this.timepicker._options.theme,clockType:"24h",disabledTime:t,hour:this.timepicker.hour.value});r.create(),this.timepicker.clockFacePool.release(r)}else i.updateDisable();this.timepicker.clockFacePool.release(i),this.toggleClassActiveToValueTips(e)}};setTransformToCircleWithSwitchesHour=e=>{if(!this.timepicker.clockHand)return;let t=Number(e),i=t>12?t*30-360:t*30;i===360&&(i=0),!(i>360)&&(this.timepicker.clockHand.style.transform=`rotateZ(${i}deg)`)};setTransformToCircleWithSwitchesMinutes=e=>{if(!this.timepicker.clockHand)return;let t=Number(e)*6;t>360||(this.timepicker.clockHand.style.transform=`rotateZ(${t}deg)`)};toggleClassActiveToValueTips=e=>{let t=this.timepicker.allValueTips.find(i=>Number(i.innerText)===Number(e));this.timepicker.allValueTips.map(i=>{i.classList.remove(H),i.setAttribute("aria-selected","false")}),t!==void 0&&(t.classList.add(H),t.setAttribute("aria-selected","true"))}};var se=class{timepicker;constructor(e){this.timepicker=e}setErrorHandler(){let e=this.timepicker.input;if(!e)return;let{error:t,currentHour:i,currentMin:r,currentType:s,currentLength:a}=C(e,this.timepicker._options.clockType);if(this.removeErrorHandler(),t){let o=document.createElement("div");return o.classList.add("timepicker-ui-invalid-text"),o.innerHTML="<b>Invalid Time Format</b>",e.classList.add("timepicker-ui-invalid-format"),e.nextElementSibling?.classList.contains("timepicker-ui-invalid-text")||e.after(o),_(this.timepicker._element,"","timepicker:error",{error:t,currentHour:i,currentMin:r,currentType:s,currentLength:a},this.timepicker._options.onError,this.timepicker),console.error(`Invalid Time Format: ${t}`),!1}return!0}removeErrorHandler(){let e=this.timepicker.input;if(!e)return;e.classList.remove("timepicker-ui-invalid-format");let t=e.nextElementSibling;t?.classList.contains("timepicker-ui-invalid-text")&&t.remove()}checkDisabledValuesOnStart(){if(!this.timepicker._options.disabledTime)return;let{disabledTime:e,clockType:t}=this.timepicker._options;if(e.interval){if(!t)throw new Error("clockType is required when using disabledTime.interval");let o=Array.isArray(e.interval)?e.interval:[e.interval];try{he(o,t)}catch(c){throw new Error(`Invalid disabledTime.interval: ${c.message}`)}return}let{hours:i,minutes:r}=e,s=i?P(i,"hour",t):!0,a=r?P(r,"minutes",t):!0;if(!s||!a)throw new Error("You set wrong hours or minutes in disabled option")}destroy(){this.removeErrorHandler()}};var ne={"crane-straight":["crane-straight"],"crane-radius":["crane-straight","radius"],m3:["m3"],dark:["dark"],glassmorphic:["glassmorphic"],pastel:["pastel"],ai:["ai"],cyberpunk:["cyberpunk"],custom:["custom"]};var oe=class{timepicker;constructor(e){this.timepicker=e}setTheme=()=>{let e=this.timepicker.modalElement;if(!e||!this.timepicker._options)return;let{theme:t}=this.timepicker._options;if(!t||!ne[t])return;e.querySelectorAll("input, div").forEach(r=>{Object.values(ne).forEach(s=>r.classList.remove(...s)),r.classList.add(...ne[t])})};setInputClassToInputElement=()=>{let e=this.timepicker.input;e&&(m(e,"timepicker-ui-input")||e.classList.add("timepicker-ui-input"))};setDataOpenToInputIfDoesntExistInWrapper=()=>{this.timepicker.openElementData===null&&this.timepicker.input&&this.timepicker.input.setAttribute("data-open","timepicker-ui-input")};setClassTopOpenElement=()=>{for(let e of this.timepicker.openElement)e&&e.classList.add("timepicker-ui-open-element")};setTimepickerClassToElement=()=>{let e=this.timepicker._element;if(!e)return;e.classList.add(Te);let t=this.timepicker._options?.cssClass;t&&t!==Te&&e.classList.add(t)};destroy(){let e=this.timepicker.modalElement;if(!e)return;e.querySelectorAll("input, div").forEach(i=>{Object.values(ne).forEach(r=>i.classList.remove(...r))})}};var ae=class{timepicker;timeouts=[];debouncedHandler;constructor(e){this.timepicker=e}clearAllTimeouts(){this.timeouts.forEach(clearTimeout),this.timeouts=[]}runWithTimeout(e,t){let i=setTimeout(e,t);this.timeouts.push(i)}isCurrentTimeEnabled(e){let t=this.timepicker._options?.currentTime;return typeof t=="boolean"?t:!!t?.[e]}preventClockTypeByCurrentTime=()=>{if(!this.isCurrentTimeEnabled("preventClockType"))return;let{currentTime:e,clockType:t}=this.timepicker._options,{type:i}=C(this.timepicker.input,t,e,!0);this.timepicker._options.clockType=i?"12h":"24h"};updateInputValueWithCurrentTimeOnStart=()=>{if(!this.isCurrentTimeEnabled("updateInput"))return;let{hour:e,minutes:t,type:i}=C(this.timepicker.input,this.timepicker._options.clockType,this.timepicker._options.currentTime);this.timepicker.input.value=i?`${e}:${t} ${i}`:`${e}:${t}`};checkMobileOption(){this.timepicker._isMobileView=!!this.timepicker._options.mobile,this.timepicker._options.mobile&&(this.timepicker._options.editable=!0)}getDisableTime(){let e=Ae(this.timepicker._options);this.timepicker._disabledTime=e||null}getInputValueOnOpenAndSet=()=>{let e=C(this.timepicker.input,this.timepicker._options.clockType,this.timepicker._options.currentTime);if(e===void 0){this.timepicker.hour.value="12",this.timepicker.minutes.value="00",_(this.timepicker._element,"show","timepicker:open",{hour:this.timepicker.hour.value,minutes:this.timepicker.minutes.value,type:this.timepicker.activeTypeMode?.dataset.type,degreesHours:this.timepicker._degreesHours,degreesMinutes:this.timepicker._degreesMinutes},this.timepicker._options.onOpen),this.timepicker._options.clockType!=="24h"&&this.timepicker.AM.classList.add(H);return}let[t,i,r]=this.timepicker.input.value.split(":").join(" ").split(" ");this.timepicker.input.value.length===0&&(t=e.hour,i=e.minutes,r=e.type),this.timepicker.hour.value=t,this.timepicker.minutes.value=i;let s=this.timepicker.modalElement?.querySelector(`[data-type='${r}']`);this.timepicker._options.clockType!=="24h"&&s&&s.classList.add(H),_(this.timepicker._element,"show","timepicker:open",{...e,type:this.timepicker.activeTypeMode?.dataset.type,degreesHours:this.timepicker._degreesHours,degreesMinutes:this.timepicker._degreesMinutes},this.timepicker._options.onOpen)};handleModeSwitch(e){this.clearAllTimeouts();let t=this.timepicker.hour.value,i=this.timepicker.minutes.value,r=this.timepicker.activeTypeMode?.dataset.type;this.timepicker.close()(),this.timepicker._isMobileView=e,this.timepicker._options.mobile=e,this.runWithTimeout(()=>{this.timepicker.update({options:{mobile:e}}),this.runWithTimeout(()=>{if(this.timepicker.open(),this.timepicker.hour.value=t,this.timepicker.minutes.value=i,this.timepicker._options.clockType==="12h"){let s=r==="PM"?"PM":"AM",a=r==="PM"?"AM":"PM";this.timepicker[s].classList.add(H),this.timepicker[a].classList.remove(H)}this.timepicker.clockManager&&(this.timepicker.clockManager.setTransformToCircleWithSwitchesHour(this.timepicker.hour.value),this.timepicker.clockManager.toggleClassActiveToValueTips(this.timepicker.hour.value),Number(this.timepicker.hour.value)>12||Number(this.timepicker.hour.value)===0?this.timepicker.clockManager.setCircleClockClasses24h():this.timepicker.clockManager.removeCircleClockClasses24h())},300)},300)}handlerViewChange=()=>{let e=this.timepicker._options.delayHandler||300;return this.debouncedHandler=ke(()=>{let{clockType:t}=this.timepicker._options;if(!this.timepicker.modalElement?.classList.contains("mobile"))this.handleModeSwitch(!0);else{let i=D(this.timepicker.hour.value,"hour",t),r=D(this.timepicker.minutes.value,"minutes",t);if(!i||!r){r||this.timepicker.minutes.classList.add("invalid-value"),i||this.timepicker.hour.classList.add("invalid-value");return}this.timepicker.minutes.classList.remove("invalid-value"),this.timepicker.hour.classList.remove("invalid-value"),this.handleModeSwitch(!1)}},e),this.debouncedHandler};getInputValue=C;destroy(){this.clearAllTimeouts(),this.debouncedHandler&&"cancel"in this.debouncedHandler&&this.debouncedHandler.cancel?.()}};var ce=class{events=new Map;on(e,t){this.events.has(e)||this.events.set(e,new Set),this.events.get(e).add(t)}once(e,t){let i=r=>{t(r),this.off(e,i)};this.on(e,i)}off(e,t){t?this.events.get(e)?.delete(t):this.events.delete(e)}emit(e,t){this.events.get(e)?.forEach(i=>{try{i(t)}catch(r){console.error(`EventEmitter: Error in handler for "${String(e)}":`,r)}})}clear(){this.events.clear()}hasListeners(e){return(this.events.get(e)?.size??0)>0}};var le=class{_degreesHours=null;_degreesMinutes=null;_options;_eventsClickMobile=()=>Promise.resolve();_eventsClickMobileHandler=()=>{};_mutliEventsMove=()=>{};_mutliEventsMoveHandler;_clickTouchEvents;_element;_instanceId;_isMobileView;_isTouchMouseMove;_disabledTime;_cloned;_inputEvents;_isModalRemove;_isInitialized=!1;_customId;_eventHandlersRegistered=!1;_isDestroyed=!1;_pendingThemeConfig;clockFacePool;eventManager;modalManager;animationManager;clockManager;validationManager;themeManager;configManager;_eventEmitter;constructor(e,t){if(typeof window>"u")throw new Error("TimepickerUI: Cannot initialize in non-browser environment (SSR/Node.js)");this._eventEmitter=new ce;let i=t?.id;this._customId=i,this._instanceId=i||`timepicker-ui-${Ce()}`;let r=null;if(typeof e=="string"){if(r=document.querySelector(e),!r){console.error(`TimepickerUI: Element with selector "${e}" not found`),this._isDestroyed=!0;return}}else if(e instanceof HTMLElement)r=e;else{console.error("TimepickerUI: First parameter must be a string selector or HTMLElement"),this._isDestroyed=!0;return}let s=null;if(r.tagName==="INPUT"?s=r:s=r.querySelector("input"),!s){let o=typeof e=="string"?`selector "${e}"`:"provided element";throw new Error(`TimepickerUI: No input element found for ${o}`)}if(r.tagName==="INPUT"){let o=document.createElement("div");o.className="timepicker-ui",r.parentNode?.insertBefore(o,r),o.appendChild(r),this._element=o}else this._element=r,this._element.classList.contains("timepicker-ui")||this._element.classList.add("timepicker-ui");this._cloned=null;let a=Ie(this._element?.dataset);if(this._options={...Me({...be,...t,...a},be)},this._options.inline?.enabled&&typeof t?.focusTrap>"u"&&(this._options.focusTrap=!1),this._isTouchMouseMove=!1,this._degreesHours=Number(C(this._element?.querySelector("input"),this._options.clockType).hour)*30,this._degreesMinutes=Number(C(this._element?.querySelector("input"),this._options.clockType).minutes)*6,this._isMobileView=!1,this._mutliEventsMove=o=>this.eventManager.handleEventToMoveHand(o),this._mutliEventsMoveHandler=this._mutliEventsMove.bind(this),this._eventsClickMobile=o=>this.eventManager.handlerClickHourMinutes(o),this._eventsClickMobileHandler=this._eventsClickMobile.bind(this),this.clockFacePool=new K,this.eventManager=new ee(this),this.modalManager=new te(this),this.animationManager=new ie(this),this.clockManager=new re(this),this.validationManager=new se(this),this.themeManager=new oe(this),this.configManager=new ae(this),this.configManager.checkMobileOption(),this._clickTouchEvents=["click","mousedown","touchstart"],this._inputEvents=["change",...this._clickTouchEvents],this._disabledTime=null,this.configManager.preventClockTypeByCurrentTime(),this._isModalRemove=!0,this._isInitialized=!1,this._options.inline?.enabled){if(!this._options.inline.containerId)throw console.error("TimepickerUI: containerId is required when inline mode is enabled"),new Error("TimepickerUI: containerId is required when inline mode is enabled");if(!document.getElementById(this._options.inline.containerId))throw console.error(`TimepickerUI: Container element with ID "${this._options.inline.containerId}" not found`),new Error(`TimepickerUI: Container element with ID "${this._options.inline.containerId}" not found`)}}get modalTemplate(){let{getMobileModalTemplate:e,getModalTemplate:t}=(ve(),Pe(we));return!this._options.mobile||!this._isMobileView?t(this._options,this._instanceId):e(this._options,this._instanceId)}get modalElement(){return document.querySelector(`[data-owner-id="${this._instanceId}"]`)}get clockFace(){return this.modalElement?.querySelector(".timepicker-ui-clock-face")}get input(){return this._element?.querySelector("input")}get clockHand(){return this.modalElement?.querySelector(".timepicker-ui-clock-hand")}get circle(){return this.modalElement?.querySelector(".timepicker-ui-circle-hand")}get tipsWrapper(){return this.modalElement?.querySelector(".timepicker-ui-tips-wrapper")}get tipsWrapperFor24h(){return this.modalElement?.querySelector(".timepicker-ui-tips-wrapper-24h")}get minutes(){return this.modalElement?.querySelector(".timepicker-ui-minutes")}get hour(){return this.modalElement?.querySelector(".timepicker-ui-hour")}get AM(){return this.modalElement?.querySelector(".timepicker-ui-am")}get PM(){return this.modalElement?.querySelector(".timepicker-ui-pm")}get minutesTips(){return this.modalElement?.querySelector(".timepicker-ui-minutes-time")}get hourTips(){return this.modalElement?.querySelector(".timepicker-ui-hour-time-12")}get allValueTips(){let e=this.modalElement;return e?[...e.querySelectorAll(".timepicker-ui-value-tips"),...e.querySelectorAll(".timepicker-ui-value-tips-24h")]:[]}get openElementData(){let e=this._element?.querySelectorAll("[data-open]");if(e?.length>0){let t=[];return e.forEach(({dataset:i})=>t.push(i.open??"")),[...new Set(t)]}return null}get openElement(){return this.openElementData===null?(this.input?.setAttribute("data-open","timepicker-ui-input"),[this.input]):this.openElementData.map(e=>this._element?.querySelectorAll(`[data-open='${e}']`))[0]??""}get cancelButton(){return this.modalElement?.querySelector(".timepicker-ui-cancel-btn")}get okButton(){return this.modalElement?.querySelector(".timepicker-ui-ok-btn")}get activeTypeMode(){return this.modalElement?.querySelector(".timepicker-ui-type-mode.active")}get keyboardClockIcon(){return this.modalElement?.querySelector(".timepicker-ui-keyboard-icon-wrapper")}get footer(){return this.modalElement?.querySelector(".timepicker-ui-footer")}get wrapper(){return this.modalElement?.querySelector(".timepicker-ui-wrapper")}getElement(){return this._element}on(e,t){if(this._isDestroyed){console.warn("TimepickerUI: Cannot add event listener - instance failed to initialize");return}this._eventEmitter.on(e,t)}once(e,t){if(this._isDestroyed){console.warn("TimepickerUI: Cannot add event listener - instance failed to initialize");return}this._eventEmitter.once(e,t)}off(e,t){if(this._isDestroyed){console.warn("TimepickerUI: Cannot remove event listener - instance failed to initialize");return}this._eventEmitter.off(e,t)}emit(e,t){this._eventEmitter.emit(e,t)}_applyThemeToWrapper(e){if(!this._pendingThemeConfig)return;let t={primaryColor:"--timepicker-primary",backgroundColor:"--timepicker-bg",surfaceColor:"--timepicker-surface",surfaceHoverColor:"--timepicker-surface-hover",textColor:"--timepicker-text",secondaryTextColor:"--timepicker-secondary-text",disabledTextColor:"--timepicker-disabled-text",onPrimaryColor:"--timepicker-on-primary",borderColor:"--timepicker-border",shadow:"--timepicker-shadow",borderRadius:"--timepicker-border-radius",fontFamily:"--timepicker-font-family"};Object.entries(this._pendingThemeConfig).forEach(([i,r])=>{r&&t[i]&&e.style.setProperty(t[i],r)})}};var pe=class extends le{create=()=>{if(this._isDestroyed){console.warn("TimepickerUI: Cannot create - instance failed to initialize");return}if(this._isInitialized){console.warn("TimepickerUI: Instance is already initialized");return}this.configManager.updateInputValueWithCurrentTimeOnStart(),this.validationManager.checkDisabledValuesOnStart(),this.themeManager.setTimepickerClassToElement(),this.themeManager.setInputClassToInputElement(),this.themeManager.setDataOpenToInputIfDoesntExistInWrapper(),this.themeManager.setClassTopOpenElement(),this._options.inline?.enabled?(this.eventManager.handleOpenOnEnterFocus(),this._eventsBundle()):(this.eventManager.handleOpenOnEnterFocus(),this.eventManager.handleOpenOnClick()),this.configManager.getDisableTime(),this._isInitialized=!0};open=e=>{if(this._isDestroyed){console.warn("TimepickerUI: Cannot open - instance failed to initialize");return}this._isInitialized||this.create(),this._eventsBundle(),O(e)};close=()=>ke((...e)=>{if(e.length>2||!this.modalElement)return;let[t]=e.filter(r=>typeof r=="boolean"),[i]=e.filter(r=>typeof r=="function");t&&(this.eventManager.handleOkButton(),this.okButton?.click()),this._isTouchMouseMove=!1,document.removeEventListener("mousedown",this.eventManager._onDragStart,!1),document.removeEventListener("touchstart",this.eventManager._onDragStart),document.removeEventListener("mousemove",this.eventManager._onDragMove,!1),document.removeEventListener("mouseup",this.eventManager._onDragEnd,!1),document.removeEventListener("touchmove",this.eventManager._onDragMove),document.removeEventListener("touchend",this.eventManager._onDragEnd,!1),document.removeEventListener("mouseleave",this.eventManager._onDragEnd,!1),document.removeEventListener("mousedown",this._eventsClickMobileHandler),document.removeEventListener("touchstart",this._eventsClickMobileHandler),document.removeEventListener("keypress",this.eventManager.handleEscClick),this.wrapper.removeEventListener("keydown",this.eventManager.focusTrapHandler),this._options.enableSwitchIcon&&(this.keyboardClockIcon.removeEventListener("touchstart",this.configManager.handlerViewChange()),this.keyboardClockIcon.removeEventListener("mousedown",this.configManager.handlerViewChange())),this.animationManager.removeAnimationToClose(),this.openElement.forEach(r=>r?.classList.remove("disabled")),setTimeout(()=>{document.body.style.overflowY="",document.body.style.paddingRight=""},400),this.openElement.forEach(r=>r?.classList.remove("disabled")),setTimeout(()=>{this._options.focusInputAfterCloseModal&&this.input?.focus(),this.modalElement!==null&&(this.modalElement.remove(),this._isModalRemove=!0)},300),O(i)},this._options.delayHandler||300);destroy=e=>{if(this._isDestroyed){console.warn("TimepickerUI: Instance is already destroyed");return}let t=typeof e=="function"?{callback:e}:e||{},{keepInputValue:i=!1,callback:r}=t,s=i?this.input?.value:null;this.clockFacePool.clear(),Le.split(" ").forEach(o=>{document.removeEventListener(o,this._mutliEventsMoveHandler,!1)}),document.removeEventListener("mousedown",this.eventManager._onDragStart,!1),document.removeEventListener("touchstart",this.eventManager._onDragStart),document.removeEventListener("mousemove",this.eventManager._onDragMove,!1),document.removeEventListener("mouseup",this.eventManager._onDragEnd,!1),document.removeEventListener("touchmove",this.eventManager._onDragMove),document.removeEventListener("touchend",this.eventManager._onDragEnd,!1),document.removeEventListener("mouseleave",this.eventManager._onDragEnd,!1),document.removeEventListener("mousedown",this._eventsClickMobileHandler),document.removeEventListener("touchstart",this._eventsClickMobileHandler),this.modalElement?.remove(),this.openElement?.forEach(o=>{o&&(o.classList.remove("disabled","active","timepicker-ui-open-element"),o.classList.remove("basic","crane-straight","crane-radius","m3"))}),this.input&&(this.input.classList.remove("timepicker-ui-invalid-format","invalid-value","error","active","timepicker-ui-input"),this.input.removeAttribute("data-open"),this.input.removeAttribute("data-owner-id"),i&&s!==null&&(this.input.value=s)),this._element&&(this._element.classList.remove("basic","crane-straight","crane-radius","m3"),this._element.classList.remove("error","active","disabled"),this._element.removeAttribute("data-owner-id"),this._element.removeAttribute("data-open"),this._options.cssClass&&this._element.classList.remove(this._options.cssClass)),this._element?.querySelectorAll(".timepicker-ui-invalid-text")?.forEach(o=>o.remove()),this._mutliEventsMoveHandler=()=>{},this._eventsClickMobileHandler=()=>{},this._mutliEventsMove=()=>{},this._eventsClickMobile=()=>Promise.resolve(),this._isModalRemove=!0,this._isTouchMouseMove=!1,this._disabledTime=null,this._cloned=null,this._degreesHours=null,this._degreesMinutes=null,this._isInitialized=!1,this._isDestroyed=!0,typeof document<"u"&&(document.body.style.overflowY="",document.body.style.paddingRight=""),this.onDestroy?.(),O(r)};onDestroy;_eventsBundle=()=>{if(this._isDestroyed){console.warn("TimepickerUI: Instance is destroyed");return}if(this._isModalRemove){if(this._options.inline?.enabled||this.eventManager.handleEscClick(),this.validationManager.setErrorHandler(),this.validationManager.removeErrorHandler(),this._options.inline?.enabled||(this.openElement.forEach(e=>e?.classList.add("disabled")),this.input?.blur()),this.modalManager.setScrollbarOrNot(),this.modalManager.setModalTemplate(),this.modalManager.setNormalizeClass(),this.modalManager.removeBackdrop(),this.clockManager.setOnStartCSSClassesIfClockType24h(),this.clockManager.setClassActiveToHourOnOpen(),this.clockFace!==null){let e=this.clockFacePool.acquire({array:q,classToAdd:"timepicker-ui-hour-time-12",clockFace:this.clockFace,tipsWrapper:this.tipsWrapper,theme:this._options.theme,disabledTime:this._disabledTime?.value?.isInterval?this._disabledTime?.value:this._disabledTime?.value?.hours,clockType:this._options.clockType,hour:this.hour.value,activeTypeMode:this.activeTypeMode?.textContent||""});if(e.create(),this._options.clockType==="24h"){let t=this.clockFacePool.acquire({array:V,classToAdd:"timepicker-ui-hour-time-24",clockFace:this.tipsWrapperFor24h,tipsWrapper:this.tipsWrapperFor24h,theme:this._options.theme,clockType:"24h",disabledTime:this._disabledTime?.value?.isInterval?this._disabledTime?.value:this._disabledTime?.value?.hours,hour:this.hour.value});t.create(),this.clockFacePool.release(t)}else this._options.clockType==="12h"&&this._disabledTime?.value?.isInterval&&setTimeout(()=>{e.updateDisable(this.hour.value,this.activeTypeMode?.textContent||"")},300);this.clockFacePool.release(e)}this.modalManager.setFlexEndToFooterIfNoKeyboardIcon(),setTimeout(()=>{this.themeManager.setTheme();let e=this.modalElement?.querySelector(".timepicker-ui-wrapper");e&&(this._options.cssClass&&e.classList.add(this._options.cssClass),this._pendingThemeConfig&&this._applyThemeToWrapper(e))},0),this.animationManager.setAnimationToOpen(),this.configManager.getInputValueOnOpenAndSet(),this.clockManager.toggleClassActiveToValueTips(this.hour.value),this._isMobileView||(this.clockManager.setTransformToCircleWithSwitchesHour(this.hour.value),this.animationManager.handleAnimationClock()),this.eventManager.handleMinutesEvents(),this.eventManager.handleHourEvents(),this._options.clockType!=="24h"&&(this.eventManager.handleAmClick(),this.eventManager.handlePmClick()),this.clockFace&&this.eventManager.handleMoveHand(),this.eventManager.handleCancelButton(),this.eventManager.handleOkButton(),this.modalElement&&(this.modalManager.setShowClassToBackdrop(),this._options.inline?.enabled||this.eventManager.handleBackdropClick()),this.eventManager.handleIconChangeView(),this.eventManager.handleClickOnHourMobile(),this._options.focusTrap&&this.eventManager.focusTrapHandler(),this._options.inline?.enabled&&this._options.inline.autoUpdate!==!1&&this.eventManager.handleInlineAutoUpdate()}}};var me=class extends pe{getValue=()=>{if(this._isDestroyed)return console.warn("TimepickerUI: Instance is destroyed"),{hour:"",minutes:"",time:"",degreesHours:null,degreesMinutes:null};let e=this.hour?.value||"12",t=this.minutes?.value||"00",i=this._options.clockType==="24h"?void 0:this.activeTypeMode?.textContent||"AM",r="";return this._options.clockType==="24h"?r=`${e.padStart(2,"0")}:${t.padStart(2,"0")}`:r=`${e}:${t.padStart(2,"0")} ${i}`,{hour:e,minutes:t,type:i,time:r,degreesHours:this._degreesHours,degreesMinutes:this._degreesMinutes}};setValue=(e,t=!0)=>{if(this._isDestroyed){console.warn("TimepickerUI: Instance is destroyed");return}if(!e||typeof e!="string")throw new Error("TimepickerUI: setValue requires a valid time string");let i=e.trim(),r="12",s="00",a="AM";try{if(this._options.clockType==="24h"){let o=i.match(/^([0-1]?[0-9]|2[0-3]):([0-5][0-9])$/);if(!o)throw new Error("Invalid 24h format. Expected HH:MM");r=o[1].padStart(2,"0"),s=o[2]}else{let o=i.match(/^(1[0-2]|[1-9]):([0-5][0-9])\s*(AM|PM)$/i);if(!o)throw new Error("Invalid 12h format. Expected HH:MM AM/PM");r=o[1],s=o[2],a=o[3].toUpperCase()}this.hour&&(this.hour.value=r,this.hour.setAttribute("aria-valuenow",r),this._degreesHours=Number(r)*30),this.minutes&&(this.minutes.value=s,this.minutes.setAttribute("aria-valuenow",s),this._degreesMinutes=Number(s)*6),this._options.clockType!=="24h"&&this.AM&&this.PM&&(a==="AM"?(this.AM.classList.add("active"),this.PM.classList.remove("active")):(this.PM.classList.add("active"),this.AM.classList.remove("active"))),t&&this.input&&(this.input.value=i),this.clockHand&&(this.clockHand.style.transform=`rotateZ(${this._degreesHours||0}deg)`)}catch(o){throw new Error(`TimepickerUI: ${o instanceof Error?o.message:"Invalid time format"}`)}};update=(e,t)=>{if(this._isDestroyed){console.warn("TimepickerUI: Instance is destroyed");return}this._options={...this._options,...e.options},this.configManager.checkMobileOption(),e.create&&this.create(),O(t)};setTheme(e){if(this._isDestroyed){console.warn("TimepickerUI: Cannot set theme on destroyed instance");return}this._pendingThemeConfig=e;let t=this.modalElement?.querySelector(".timepicker-ui-wrapper");t&&this._applyThemeToWrapper(t)}};var $=new Map,N=class extends me{constructor(e,t){if(super(e,t),this._isDestroyed)return;let i=t?.id;if(i&&$.has(i)){console.error(`TimepickerUI: Instance with ID "${i}" already exists`),this._isDestroyed=!0;return}$.set(this._instanceId,this),this.onDestroy=()=>{$.delete(this._instanceId)}}static getById(e){return $.get(e)}static getAllInstances(){return Array.from($.values())}static isAvailable(e){return typeof window>"u"?!1:typeof e=="string"?document.querySelector(e)!==null:e instanceof HTMLElement?document.contains(e):!1}static destroyAll(){Array.from($.values()).forEach(t=>t.destroy()),$.clear()}};var Oi=N;export{ce as EventEmitter,N as TimepickerUI,Oi as default};