timepicker-ui 4.1.0 → 4.1.2

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.cjs CHANGED
@@ -1,8 +1,8 @@
1
- "use strict";var ve=Object.defineProperty;var $e=Object.getOwnPropertyDescriptor;var Ne=Object.getOwnPropertyNames;var Ve=Object.prototype.hasOwnProperty;var Fe=(a,e)=>{for(var t in e)ve(a,t,{get:e[t],enumerable:!0})},qe=(a,e,t,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of Ne(e))!Ve.call(a,n)&&n!==t&&ve(a,n,{get:()=>e[n],enumerable:!(i=$e(e,n))||i.enumerable});return a};var ze=a=>qe(ve({},"__esModule",{value:!0}),a);var Ge={};Fe(Ge,{EventEmitter:()=>q,PluginRegistry:()=>ce,TimepickerUI:()=>he,default:()=>Ze});module.exports=ze(Ge);var S=()=>typeof window>"u",f=()=>typeof document<"u";var ee=class{state;constructor(e,t,i,n){this.state={degreesHours:null,degreesMinutes:null,options:t,element:e,instanceId:i,isMobileView:!1,isTouchMouseMove:!1,disabledTime:null,cloned:null,isModalRemove:!0,isInitialized:!1,customId:n,eventHandlersRegistered:!1,isDestroyed:!1}}get degreesHours(){return this.state.degreesHours}get degreesMinutes(){return this.state.degreesMinutes}get options(){return this.state.options}get element(){return this.state.element}get instanceId(){return this.state.instanceId}get isMobileView(){return this.state.isMobileView}get isTouchMouseMove(){return this.state.isTouchMouseMove}get disabledTime(){return this.state.disabledTime}get cloned(){return this.state.cloned}get isModalRemove(){return this.state.isModalRemove}get isInitialized(){return this.state.isInitialized}get customId(){return this.state.customId}get eventHandlersRegistered(){return this.state.eventHandlersRegistered}get isDestroyed(){return this.state.isDestroyed}setDegreesHours(e){this.state={...this.state,degreesHours:e}}setDegreesMinutes(e){this.state={...this.state,degreesMinutes:e}}setOptions(e){this.state={...this.state,options:e}}setIsMobileView(e){this.state={...this.state,isMobileView:e}}setIsTouchMouseMove(e){this.state={...this.state,isTouchMouseMove:e}}setDisabledTime(e){this.state={...this.state,disabledTime:e}}setCloned(e){this.state={...this.state,cloned:e}}setIsModalRemove(e){this.state={...this.state,isModalRemove:e}}setIsInitialized(e){this.state={...this.state,isInitialized:e}}setEventHandlersRegistered(e){this.state={...this.state,eventHandlersRegistered:e}}setIsDestroyed(e){this.state={...this.state,isDestroyed:e}}updateOptions(e){this.state={...this.state,options:{...this.state.options,clock:{...this.state.options.clock,...e.clock||{}},ui:{...this.state.options.ui,...e.ui||{}},labels:{...this.state.options.labels,...e.labels||{}},behavior:{...this.state.options.behavior,...e.behavior||{}},callbacks:{...this.state.options.callbacks,...e.callbacks||{}}}}}reset(){this.state={...this.state,degreesHours:null,degreesMinutes:null,isTouchMouseMove:!1,disabledTime:null,cloned:null,isModalRemove:!0,isInitialized:!1,isDestroyed:!0,eventHandlersRegistered:!1}}getModalElement(){return f()===!1?null:document.querySelector(`[data-owner-id="${this.state.instanceId}"]`)}getInput(){return this.state.element?.querySelector("input")}getClockFace(){let e=this.getModalElement();return e?this.state.isMobileView?e.querySelector(".tp-ui-clock-face.mobile"):e.querySelector(".tp-ui-clock-face:not(.mobile)"):null}getClockHand(){let e=this.getModalElement();return e?this.state.isMobileView?e.querySelector(".tp-ui-mobile-clock-wrapper .tp-ui-clock-hand"):e.querySelector(".tp-ui-clock-hand:not(.mobile)"):null}getCircle(){let e=this.getModalElement();return e?this.state.isMobileView?e.querySelector(".tp-ui-mobile-clock-wrapper .tp-ui-circle-hand"):e.querySelector(".tp-ui-circle-hand:not(.mobile)"):null}getTipsWrapper(){let e=this.getModalElement();return e?this.state.isMobileView?e.querySelector(".tp-ui-mobile-clock-wrapper .tp-ui-tips-wrapper"):e.querySelector(".tp-ui-tips-wrapper:not(.mobile)"):null}getTipsWrapperFor24h(){let e=this.getModalElement();return e?this.state.isMobileView?e.querySelector(".tp-ui-mobile-clock-wrapper .tp-ui-tips-wrapper-24h"):e.querySelector(".tp-ui-tips-wrapper-24h:not(.mobile)"):null}getMinutes(){return this.getModalElement()?.querySelector(".tp-ui-minutes")||null}getHour(){return this.getModalElement()?.querySelector(".tp-ui-hour")||null}getAM(){return this.getModalElement()?.querySelector(".tp-ui-am")||null}getPM(){return this.getModalElement()?.querySelector(".tp-ui-pm")||null}getHourText(){return this.getModalElement()?.querySelector(".tp-ui-hour-text")||null}getMinutesText(){return this.getModalElement()?.querySelector(".tp-ui-minute-text")||null}getHeader(){return this.getModalElement()?.querySelector(".tp-ui-header")||null}getInputWrappers(){return this.getModalElement()?.querySelectorAll(".tp-ui-input-wrapper")||null}getDots(){return this.getModalElement()?.querySelector(".tp-ui-dots")||null}getMinutesTips(){return this.getModalElement()?.querySelector(".tp-ui-minutes-time")||null}getHourTips(){return this.getModalElement()?.querySelector(".tp-ui-hour-time-12")||null}getAllValueTips(){let e=this.getModalElement();return e?[...e.querySelectorAll(".tp-ui-value-tips"),...e.querySelectorAll(".tp-ui-value-tips-24h")]:[]}getOpenElementData(){let e=this.state.element?.querySelectorAll("[data-open]");if(e?.length>0){let t=[];return e.forEach(({dataset:i})=>t.push(i.open??"")),[...new Set(t)]}return null}getOpenElement(){let e=this.getInput(),t=this.getOpenElementData();return t===null?(e?.setAttribute("data-open","tp-ui-input"),[e]):t.map(i=>this.state.element?.querySelectorAll(`[data-open='${i}']`))[0]??""}getCancelButton(){return this.getModalElement()?.querySelector(".tp-ui-cancel-btn")||null}getOkButton(){return this.getModalElement()?.querySelector(".tp-ui-ok-btn")||null}getActiveTypeMode(){return this.getModalElement()?.querySelector(".tp-ui-type-mode.active")||null}getKeyboardClockIcon(){return this.getModalElement()?.querySelector(".tp-ui-keyboard-icon-wrapper")||null}getFooter(){return this.getModalElement()?.querySelector(".tp-ui-footer")||null}getWrapper(){return this.getModalElement()?.querySelector(".tp-ui-wrapper")||null}};var C={DEFAULT_DELAY:300,MODAL_ANIMATION:150,SCROLLBAR_RESTORE:400,MODAL_REMOVE:300,CLOCK_ANIMATION:600,TIPS_ANIMATION:401,MOBILE_TOGGLE:450,CLOCK_SCALE_DELAY:150,DROPDOWN_CLICK_DELAY:10};var B=class{core;emitter;timeouts=[];constructor(e,t){this.core=e,this.emitter=t,this.setupEventListeners()}setupEventListeners(){this.emitter.on("animation:clock",()=>{this.handleAnimationSwitchTipsMode()})}runWithAnimation(e,t=C.MODAL_ANIMATION){if(this.core.options.ui.animation){let i=setTimeout(e,t);this.timeouts.push(i)}else e()}clearAllTimeouts(){this.timeouts.forEach(clearTimeout),this.timeouts=[]}setAnimationToOpen(){this.clearAllTimeouts(),this.core.getModalElement()?.classList.add("opacity"),this.runWithAnimation(()=>{this.core.getModalElement()?.classList.add("show")})}removeAnimationToClose(){this.clearAllTimeouts(),this.core.getModalElement()&&this.runWithAnimation(()=>{let t=this.core.getModalElement();t?.classList.remove("show"),t?.classList.remove("opacity")})}handleAnimationClock(){this.core.options.ui.animation&&this.runWithAnimation(()=>{this.core.getClockFace()?.classList.add("tp-ui-clock-animation");let t=setTimeout(()=>{this.core.getClockFace()?.classList.remove("tp-ui-clock-animation")},C.CLOCK_ANIMATION);this.timeouts.push(t)})}handleAnimationSwitchTipsMode(){let e=this.core.getClockHand();if(!e)return;this.emitter.emit("animation:start",{}),e.classList.add("tp-ui-tips-animation");let t=setTimeout(()=>{this.core.getClockHand()?.classList.remove("tp-ui-tips-animation"),this.emitter.emit("animation:end",{})},C.TIPS_ANIMATION);this.timeouts.push(t)}destroy(){this.clearAllTimeouts()}};var Ce=()=>{if(f()===!1)return 0;let a=document.createElement("div");a.className="tp-ui-measure",document.body.appendChild(a);let e=a.getBoundingClientRect().width-a.clientWidth;return document.body.removeChild(a),e};var Le=(a,e)=>a?a.classList.contains(e):!1,_=(a,e)=>Array.from({length:Number(e)-Number(a)+1},(t,i)=>Number(a)+i),te=(a,e)=>Array.from({length:Number(e)-Number(a)+1},(t,i)=>Number(e)-i).reverse();var fe=(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"),n=t.getMinutes().toString().padStart(2,"0");return`${i}:${n}`},ge=a=>{let[e,t]=a.split(":");return`${e.padStart(2,"0")}:${t.padStart(2,"0")}`},ie=(a,e)=>{if(a.length<2)return!1;let t=a.map(i=>{let[n,r]=i.trim().split("-"),s,o;if(e==="12h"){if(!/\s?(AM|PM|am|pm)\s?$/.test(n.trim())||!/\s?(AM|PM|am|pm)\s?$/.test(r.trim()))throw new Error(`Invalid 12h format: "${i}"`);s=fe(n.trim()),o=fe(r.trim())}else{if(/\s?(AM|PM|am|pm)\s?/.test(n.trim())||/\s?(AM|PM|am|pm)\s?/.test(r.trim()))throw new Error(`Invalid 24h format: "${i}"`);s=ge(n.trim()),o=ge(r.trim())}return{start:s,end:o,original:i}});for(let i=0;i<t.length;i++)for(let n=i+1;n<t.length;n++){let r=t[i],s=t[n];if(r.start<=s.end&&r.end>=s.start||s.start<=r.end&&s.end>=r.start)throw new Error(`Overlapping intervals: "${r.original}" and "${s.original}"`)}return!1},Ae=()=>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 ne='<svg xmlns="http://www.w3.org/2000/svg" height="24px" viewBox="0 -960 960 960" width="24px" fill="#e3e3e3"><path d="M160-200q-33 0-56.5-23.5T80-280v-400q0-33 23.5-56.5T160-760h640q33 0 56.5 23.5T880-680v400q0 33-23.5 56.5T800-200H160Zm0-80h640v-400H160v400Zm160-40h320v-80H320v80ZM200-440h80v-80h-80v80Zm120 0h80v-80h-80v80Zm120 0h80v-80h-80v80Zm120 0h80v-80h-80v80Zm120 0h80v-80h-80v80ZM200-560h80v-80h-80v80Zm120 0h80v-80h-80v80Zm120 0h80v-80h-80v80Zm120 0h80v-80h-80v80Zm120 0h80v-80h-80v80ZM160-280v-400 400Z"/></svg>';var re='<svg xmlns="http://www.w3.org/2000/svg" height="24px" viewBox="0 -960 960 960" width="24px" fill="#e3e3e3"><path d="m612-292 56-56-148-148v-184h-80v216l172 172ZM480-80q-83 0-156-31.5T197-197q-54-54-85.5-127T80-480q0-83 31.5-156T197-763q54-54 127-85.5T480-880q83 0 156 31.5T763-763q54 54 85.5 127T880-480q0 83-31.5 156T763-197q-54 54-127 85.5T480-80Zm0-400Zm0 320q133 0 226.5-93.5T800-480q0-133-93.5-226.5T480-800q-133 0-226.5 93.5T160-480q0 133 93.5 226.5T480-160Z"/></svg>';var He=["00","13","14","15","16","17","18","19","20","21","22","23"],be=["12","1","2","3","4","5","6","7","8","9","10","11"],W=["00","05","10","15","20","25","30","35","40","45","50","55"],Se=(a,e)=>{let{ui:{iconTemplate:t,enableSwitchIcon:i,animation:n,theme:r,mobile:s,editable:o,iconTemplateMobile:c},labels:{time:l,mobileTime:u,am:d,pm:p,cancel:g,ok:E,mobileMinute:L,mobileHour:T},clock:{type:k},timezone:{enabled:h,label:b},range:{enabled:y,fromLabel:M,toLabel:v}}=a,m=s?"mobile":"",A=`<button aria-label="Keyboard" type="button" class="tp-ui-keyboard-icon">${t||ne}</button>`,H=c||`<button aria-label="Clock" type="button" class="tp-ui-keyboard-icon">${c||re}</button>`,P=h?`<div class="tp-ui-timezone ${m}">
2
- <span class="tp-ui-timezone-label" id="tp-tz-label-${e}">${b}</span>
1
+ "use strict";var Se=Object.defineProperty;var je=Object.getOwnPropertyDescriptor;var Xe=Object.getOwnPropertyNames;var Je=Object.prototype.hasOwnProperty;var Qe=(a,e)=>{for(var t in e)Se(a,t,{get:e[t],enumerable:!0})},et=(a,e,t,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of Xe(e))!Je.call(a,n)&&n!==t&&Se(a,n,{get:()=>e[n],enumerable:!(i=je(e,n))||i.enumerable});return a};var tt=a=>et(Se({},"__esModule",{value:!0}),a);var ct={};Qe(ct,{EventEmitter:()=>q,PluginRegistry:()=>ye,TimepickerUI:()=>He,default:()=>lt});module.exports=tt(ct);var L=()=>typeof window>"u",f=()=>typeof document<"u";var ne=class{state;constructor(e,t,i,n){this.state={degreesHours:null,degreesMinutes:null,options:t,element:e,instanceId:i,isMobileView:!1,isTouchMouseMove:!1,disabledTime:null,cloned:null,isModalRemove:!0,isInitialized:!1,customId:n,eventHandlersRegistered:!1,isDestroyed:!1}}get degreesHours(){return this.state.degreesHours}get degreesMinutes(){return this.state.degreesMinutes}get options(){return this.state.options}get element(){return this.state.element}get instanceId(){return this.state.instanceId}get isMobileView(){return this.state.isMobileView}get isTouchMouseMove(){return this.state.isTouchMouseMove}get disabledTime(){return this.state.disabledTime}get cloned(){return this.state.cloned}get isModalRemove(){return this.state.isModalRemove}get isInitialized(){return this.state.isInitialized}get customId(){return this.state.customId}get eventHandlersRegistered(){return this.state.eventHandlersRegistered}get isDestroyed(){return this.state.isDestroyed}setDegreesHours(e){this.state={...this.state,degreesHours:e}}setDegreesMinutes(e){this.state={...this.state,degreesMinutes:e}}setOptions(e){this.state={...this.state,options:e}}setIsMobileView(e){this.state={...this.state,isMobileView:e}}setIsTouchMouseMove(e){this.state={...this.state,isTouchMouseMove:e}}setDisabledTime(e){this.state={...this.state,disabledTime:e}}setCloned(e){this.state={...this.state,cloned:e}}setIsModalRemove(e){this.state={...this.state,isModalRemove:e}}setIsInitialized(e){this.state={...this.state,isInitialized:e}}setEventHandlersRegistered(e){this.state={...this.state,eventHandlersRegistered:e}}setIsDestroyed(e){this.state={...this.state,isDestroyed:e}}updateOptions(e){this.state={...this.state,options:{...this.state.options,clock:{...this.state.options.clock,...e.clock||{}},ui:{...this.state.options.ui,...e.ui||{}},labels:{...this.state.options.labels,...e.labels||{}},behavior:{...this.state.options.behavior,...e.behavior||{}},callbacks:{...this.state.options.callbacks,...e.callbacks||{}}}}}reset(){this.state={...this.state,degreesHours:null,degreesMinutes:null,isTouchMouseMove:!1,disabledTime:null,cloned:null,isModalRemove:!0,isInitialized:!1,isDestroyed:!0,eventHandlersRegistered:!1}}getModalElement(){return f()===!1?null:document.querySelector(`[data-owner-id="${this.state.instanceId}"]`)}getInput(){return this.state.element?.querySelector("input")}getClockFace(){let e=this.getModalElement();return e?this.state.isMobileView?e.querySelector(".tp-ui-clock-face.mobile"):e.querySelector(".tp-ui-clock-face:not(.mobile)"):null}getClockHand(){let e=this.getModalElement();return e?this.state.isMobileView?e.querySelector(".tp-ui-mobile-clock-wrapper .tp-ui-clock-hand"):e.querySelector(".tp-ui-clock-hand:not(.mobile)"):null}getCircle(){let e=this.getModalElement();return e?this.state.isMobileView?e.querySelector(".tp-ui-mobile-clock-wrapper .tp-ui-circle-hand"):e.querySelector(".tp-ui-circle-hand:not(.mobile)"):null}getTipsWrapper(){let e=this.getModalElement();return e?this.state.isMobileView?e.querySelector(".tp-ui-mobile-clock-wrapper .tp-ui-tips-wrapper"):e.querySelector(".tp-ui-tips-wrapper:not(.mobile)"):null}getTipsWrapperFor24h(){let e=this.getModalElement();return e?this.state.isMobileView?e.querySelector(".tp-ui-mobile-clock-wrapper .tp-ui-tips-wrapper-24h"):e.querySelector(".tp-ui-tips-wrapper-24h:not(.mobile)"):null}getMinutes(){return this.getModalElement()?.querySelector(".tp-ui-minutes")||null}getHour(){return this.getModalElement()?.querySelector(".tp-ui-hour")||null}getAM(){return this.getModalElement()?.querySelector(".tp-ui-am")||null}getPM(){return this.getModalElement()?.querySelector(".tp-ui-pm")||null}getHourText(){return this.getModalElement()?.querySelector(".tp-ui-hour-text")||null}getMinutesText(){return this.getModalElement()?.querySelector(".tp-ui-minute-text")||null}getHeader(){return this.getModalElement()?.querySelector(".tp-ui-header")||null}getInputWrappers(){return this.getModalElement()?.querySelectorAll(".tp-ui-input-wrapper")||null}getDots(){return this.getModalElement()?.querySelector(".tp-ui-dots")||null}getMinutesTips(){return this.getModalElement()?.querySelector(".tp-ui-minutes-time")||null}getHourTips(){return this.getModalElement()?.querySelector(".tp-ui-hour-time-12")||null}getAllValueTips(){let e=this.getModalElement();return e?[...e.querySelectorAll(".tp-ui-value-tips"),...e.querySelectorAll(".tp-ui-value-tips-24h")]:[]}getOpenElementData(){let e=this.state.element?.querySelectorAll("[data-open]");if(e?.length>0){let t=[];return e.forEach(({dataset:i})=>t.push(i.open??"")),[...new Set(t)]}return null}getOpenElement(){let e=this.getInput(),t=this.getOpenElementData();return t===null?(e?.setAttribute("data-open","tp-ui-input"),[e]):t.map(i=>this.state.element?.querySelectorAll(`[data-open='${i}']`))[0]??""}getCancelButton(){return this.getModalElement()?.querySelector(".tp-ui-cancel-btn")||null}getOkButton(){return this.getModalElement()?.querySelector(".tp-ui-ok-btn")||null}getActiveTypeMode(){return this.getModalElement()?.querySelector(".tp-ui-type-mode.active")||null}getKeyboardClockIcon(){return this.getModalElement()?.querySelector(".tp-ui-keyboard-icon-wrapper")||null}getFooter(){return this.getModalElement()?.querySelector(".tp-ui-footer")||null}getWrapper(){return this.getModalElement()?.querySelector(".tp-ui-wrapper")||null}};var C={DEFAULT_DELAY:300,MODAL_ANIMATION:150,SCROLLBAR_RESTORE:400,MODAL_REMOVE:300,CLOCK_ANIMATION:600,TIPS_ANIMATION:401,MOBILE_TOGGLE:450,CLOCK_SCALE_DELAY:150,DROPDOWN_CLICK_DELAY:10};var B=class{core;emitter;timeouts=[];constructor(e,t){this.core=e,this.emitter=t,this.setupEventListeners()}setupEventListeners(){this.emitter.on("animation:clock",()=>{this.handleAnimationSwitchTipsMode()})}runWithAnimation(e,t=C.MODAL_ANIMATION){if(this.core.options.ui.animation){let i=setTimeout(e,t);this.timeouts.push(i)}else e()}clearAllTimeouts(){this.timeouts.forEach(clearTimeout),this.timeouts=[]}setAnimationToOpen(){this.clearAllTimeouts(),this.core.getModalElement()?.classList.add("opacity"),this.runWithAnimation(()=>{this.core.getModalElement()?.classList.add("show")})}removeAnimationToClose(){this.clearAllTimeouts(),this.core.getModalElement()&&this.runWithAnimation(()=>{let t=this.core.getModalElement();t?.classList.remove("show"),t?.classList.remove("opacity")})}handleAnimationClock(){this.core.options.ui.animation&&this.runWithAnimation(()=>{this.core.getClockFace()?.classList.add("tp-ui-clock-animation");let t=setTimeout(()=>{this.core.getClockFace()?.classList.remove("tp-ui-clock-animation")},C.CLOCK_ANIMATION);this.timeouts.push(t)})}handleAnimationSwitchTipsMode(){let e=this.core.getClockHand();if(!e)return;this.emitter.emit("animation:start",{}),e.classList.add("tp-ui-tips-animation");let t=setTimeout(()=>{this.core.getClockHand()?.classList.remove("tp-ui-tips-animation"),this.emitter.emit("animation:end",{})},C.TIPS_ANIMATION);this.timeouts.push(t)}destroy(){this.clearAllTimeouts()}};var Re=()=>{if(f()===!1)return 0;let a=document.createElement("div");a.className="tp-ui-measure",document.body.appendChild(a);let e=a.getBoundingClientRect().width-a.clientWidth;return document.body.removeChild(a),e};var Ne=(a,e)=>a?a.classList.contains(e):!1,W=(a,e)=>Array.from({length:Number(e)-Number(a)+1},(t,i)=>Number(a)+i),re=(a,e)=>Array.from({length:Number(e)-Number(a)+1},(t,i)=>Number(e)-i).reverse();var Ae=(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"),n=t.getMinutes().toString().padStart(2,"0");return`${i}:${n}`},Le=a=>{let[e,t]=a.split(":");return`${e.padStart(2,"0")}:${t.padStart(2,"0")}`},se=(a,e)=>{if(a.length<2)return!1;let t=a.map(i=>{let[n,r]=i.trim().split("-"),s,o;if(e==="12h"){if(!/\s?(AM|PM|am|pm)\s?$/.test(n.trim())||!/\s?(AM|PM|am|pm)\s?$/.test(r.trim()))throw new Error(`Invalid 12h format: "${i}"`);s=Ae(n.trim()),o=Ae(r.trim())}else{if(/\s?(AM|PM|am|pm)\s?/.test(n.trim())||/\s?(AM|PM|am|pm)\s?/.test(r.trim()))throw new Error(`Invalid 24h format: "${i}"`);s=Le(n.trim()),o=Le(r.trim())}return{start:s,end:o,original:i}});for(let i=0;i<t.length;i++)for(let n=i+1;n<t.length;n++){let r=t[i],s=t[n];if(r.start<=s.end&&r.end>=s.start||s.start<=r.end&&s.end>=r.start)throw new Error(`Overlapping intervals: "${r.original}" and "${s.original}"`)}return!1},Ve=()=>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 oe='<svg xmlns="http://www.w3.org/2000/svg" height="24px" viewBox="0 -960 960 960" width="24px" fill="#e3e3e3"><path d="M160-200q-33 0-56.5-23.5T80-280v-400q0-33 23.5-56.5T160-760h640q33 0 56.5 23.5T880-680v400q0 33-23.5 56.5T800-200H160Zm0-80h640v-400H160v400Zm160-40h320v-80H320v80ZM200-440h80v-80h-80v80Zm120 0h80v-80h-80v80Zm120 0h80v-80h-80v80Zm120 0h80v-80h-80v80Zm120 0h80v-80h-80v80ZM200-560h80v-80h-80v80Zm120 0h80v-80h-80v80Zm120 0h80v-80h-80v80Zm120 0h80v-80h-80v80Zm120 0h80v-80h-80v80ZM160-280v-400 400Z"/></svg>';var ae='<svg xmlns="http://www.w3.org/2000/svg" height="24px" viewBox="0 -960 960 960" width="24px" fill="#e3e3e3"><path d="m612-292 56-56-148-148v-184h-80v216l172 172ZM480-80q-83 0-156-31.5T197-197q-54-54-85.5-127T80-480q0-83 31.5-156T197-763q54-54 127-85.5T480-880q83 0 156 31.5T763-763q54 54 85.5 127T880-480q0 83-31.5 156T763-197q-54 54-127 85.5T480-80Zm0-400Zm0 320q133 0 226.5-93.5T800-480q0-133-93.5-226.5T480-800q-133 0-226.5 93.5T160-480q0 133 93.5 226.5T480-160Z"/></svg>';var $e=["00","13","14","15","16","17","18","19","20","21","22","23"],Ie=["12","1","2","3","4","5","6","7","8","9","10","11"],_=["00","05","10","15","20","25","30","35","40","45","50","55"],Fe=(a,e)=>{let{ui:{iconTemplate:t,enableSwitchIcon:i,animation:n,theme:r,mobile:s,editable:o,iconTemplateMobile:c},labels:{time:l,mobileTime:u,am:d,pm:p,cancel:g,ok:b,mobileMinute:H,mobileHour:T},clock:{type:k},timezone:{enabled:h,label:E},range:{enabled:y,fromLabel:M,toLabel:v}}=a,m=s?"mobile":"",S=`<button aria-label="Keyboard" type="button" class="tp-ui-keyboard-icon">${t||oe}</button>`,A=c||`<button aria-label="Clock" type="button" class="tp-ui-keyboard-icon">${c||ae}</button>`,P=h?`<div class="tp-ui-timezone ${m}">
2
+ <span class="tp-ui-timezone-label" id="tp-tz-label-${e}">${E}</span>
3
3
  <div class="tp-ui-timezone-dropdown" role="combobox" aria-expanded="false" aria-haspopup="listbox" aria-labelledby="tp-tz-label-${e}" tabindex="0" data-tz-id="${e}">
4
- <div class="tp-ui-timezone-selected" data-placeholder="${b}...">${b}...</div>
4
+ <div class="tp-ui-timezone-selected" data-placeholder="${E}...">${E}...</div>
5
5
  <svg class="tp-ui-timezone-arrow" width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><polyline points="6 9 12 15 18 9"></polyline></svg>
6
6
  <div class="tp-ui-timezone-menu" role="listbox" aria-labelledby="tp-tz-label-${e}"></div>
7
7
  </div>
8
- </div>`:"",Re=y?`<div class="tp-ui-range-header" role="tablist" aria-label="Range selection"><button type="button" class="tp-ui-range-tab tp-ui-range-from active" role="tab" tabindex="0" aria-selected="true"><span class="tp-ui-range-tab-label">${M}</span><span class="tp-ui-range-tab-value tp-ui-range-from-time">--:--</span></button><button type="button" class="tp-ui-range-tab tp-ui-range-to" role="tab" tabindex="-1" aria-selected="false"><span class="tp-ui-range-tab-label">${v}</span><span class="tp-ui-range-tab-value tp-ui-range-to-time">--:--</span></button></div>`:"";return`<div class="tp-ui-modal normalize ${m}${y?" tp-ui-range-mode":""}" data-theme="${r}" role="dialog" aria-modal="true" aria-labelledby="tp-ui-label-${e}" data-owner-id="${e}" style='transition:${n?"opacity 0.15s linear":"none"}'><div class="tp-ui-wrapper ${m}" tabindex="0">${Re}<div class="tp-ui-select-time ${m}" id="tp-ui-label-${e}">${m?u:l}</div><div class="tp-ui-header ${m}"><div class="tp-ui-wrapper-time ${m} ${k==="24h"?"tp-ui-wrapper-time-24h":""}" role="group" aria-label="${m?u:l}"><div class="tp-ui-input-wrapper ${m}"><div class="tp-ui-input-ripple-wrapper ${m}" data-md3-ripple><input name="hour" ${!o&&!m?"readonly":""} class="tp-ui-hour ${m}" tabindex="0" type="number" min="0" max="${k==="12h"?"12":"23"}" aria-label="${m?T:"Hour"}" role="spinbutton" aria-valuenow="12"></div><div class="tp-ui-hour-text ${m}">${T}</div></div><div class="tp-ui-dots ${m}" aria-hidden="true"><span></span><span></span></div><div class="tp-ui-input-wrapper ${m}"><div class="tp-ui-input-ripple-wrapper ${m}" data-md3-ripple><input name="minutes" ${!o&&!m?"readonly":""} class="tp-ui-minutes ${m}" tabindex="0" type="number" min="0" max="59" aria-label="${m?L:"Minute"}" role="spinbutton" aria-valuenow="0"></div><div class="tp-ui-minute-text ${m}">${L}</div></div></div>${k!=="24h"?`<div class="tp-ui-wrapper-type-time ${m}" role="group" aria-label="Period"><div class="tp-ui-type-mode tp-ui-am ${m?"mobile":"tp-ui-ripple"}" data-md3-ripple tabindex="0" role="button" aria-label="${d}" aria-pressed="false" data-type="AM">${d}</div><div class="tp-ui-type-mode tp-ui-pm ${m?"mobile":"tp-ui-ripple"}" data-md3-ripple tabindex="0" role="button" aria-label="${p}" aria-pressed="false" data-type="PM">${p}</div></div>`:""}</div>${P}<div class="tp-ui-mobile-clock-wrapper ${m}"><div class="tp-ui-body ${m}"><div class="tp-ui-clock-face ${m}" role="group" aria-label="Clock"><div class="tp-ui-dot ${m}" aria-hidden="true"></div><div class="tp-ui-clock-hand ${m}" aria-hidden="true"><div class="tp-ui-circle-hand ${m}"></div></div><div class="tp-ui-tips-wrapper ${m}" role="listbox" aria-label="Time"></div>${k==="24h"?`<div class="tp-ui-tips-wrapper-24h ${m}" role="listbox" aria-label="24h"></div>`:""}</div></div></div><div class="tp-ui-footer ${m}" ${m?'data-view="mobile"':""}>${i?`<div class="tp-ui-keyboard-icon-wrapper ${m}" tabindex="0" role="button" aria-pressed="false" aria-label="Toggle" data-view="desktop">${m?H:A}</div>`:""}<div class="tp-ui-wrapper-btn ${m}"><div class="tp-ui-cancel-btn ${m}" data-md3-ripple tabindex="0" role="button" aria-pressed="false" aria-label="${g}">${g}</div><div class="tp-ui-ok-btn ${m}" data-md3-ripple tabindex="0" role="button" aria-pressed="false" aria-label="${E}">${E}</div></div></div></div><div class="timepicker-announcer sr-only" role="status" aria-live="polite" aria-atomic="true"></div></div>`};var U=class{core;emitter;timeouts=[];originalOverflow;originalPaddingRight;constructor(e,t){this.core=e,this.emitter=t}runWithTimeout(e,t=C.DEFAULT_DELAY){let i=setTimeout(e,t);this.timeouts.push(i)}clearAllTimeouts(){this.timeouts.forEach(clearTimeout),this.timeouts=[]}clearExistingModal(){if(f()===!1)return;let e=document.querySelector(".tp-ui-modal");e&&e.remove()}setModalTemplate(){if(f()===!1)return;this.clearExistingModal();let e=Se(this.core.options,this.core.instanceId);if(this.core.options.ui.inline?.enabled){let i=document.getElementById(this.core.options.ui.inline.containerId);if(!i)return;i.innerHTML="",i.insertAdjacentHTML("beforeend",e);let n=i.querySelector(".tp-ui-modal");if(n){n.classList.add("tp-ui--inline");let{showButtons:r}=this.core.options.ui.inline;(r===!1||r===void 0)&&n.querySelectorAll(".tp-ui-wrapper-btn, .tp-ui-wrapper-btn.mobile").forEach(s=>s.style.display="none")}return}let{appendModalSelector:t}=this.core.options.ui;t?document.querySelector(t)?.insertAdjacentHTML("beforeend",e):document.body.insertAdjacentHTML("beforeend",e)}setScrollbarOrNot(){f()!==!1&&(this.core.options.ui.inline?.enabled||(this.core.options.ui.enableScrollbar?this.runWithTimeout(()=>{S()||this.runWithTimeout(()=>{typeof document<"u"&&(document.body.style.overflowY=this.originalOverflow||"",document.body.style.paddingRight=this.originalPaddingRight||"")},C.SCROLLBAR_RESTORE)},400):(this.originalOverflow=document.body.style.overflowY,this.originalPaddingRight=document.body.style.paddingRight,document.body.style.paddingRight=`${Ce()}px`,document.body.style.overflowY="hidden")))}removeBackdrop(){if(this.core.options.ui.inline?.enabled||this.core.options.ui.backdrop)return;let e=this.core.getModalElement(),t=this.core.getOpenElement();e?.classList.add("removed"),t.forEach(i=>i?.classList.add("disabled"))}setNormalizeClass(){let e=this.core.getModalElement();if(!e)return;e.classList.add("tp-ui-normalize"),e.querySelectorAll(":scope > div").forEach(i=>i.classList.add("tp-ui-normalize"))}setShowClassToBackdrop(){if(this.core.options.ui.inline?.enabled){this.core.getModalElement()?.classList.add("show"),this.setInitialFocus();return}this.core.options.ui.backdrop&&this.runWithTimeout(()=>{this.core.getModalElement()?.classList.add("show"),this.setInitialFocus()},C.MODAL_ANIMATION)}setInitialFocus(){if(!this.core.options.behavior.focusTrap)return;let e=this.core.getWrapper();e&&typeof requestAnimationFrame<"u"&&requestAnimationFrame(()=>{e.focus()})}setFlexEndToFooterIfNoKeyboardIcon(){let e=this.core.getFooter();!this.core.options.ui.enableSwitchIcon&&e&&(e.style.justifyContent="flex-end")}destroy(){this.clearAllTimeouts(),!S()&&!this.core.options.ui.inline?.enabled&&(document.body.style.overflowY=this.originalOverflow||"",document.body.style.paddingRight=this.originalPaddingRight||""),this.clearExistingModal()}};var D=(a,e,t,i)=>{let n={hour:"12",minutes:"00",type:e==="24h"?void 0:"PM"};if(!a)return n;let r=a.value.trim();if(!t&&!r)return n;if(typeof t=="boolean"&&t){let L=new Date,[T,k]=L.toLocaleTimeString().split(":"),h=T.padStart(2,"0");if(/[a-z]/i.test(k)&&e==="12h"){let[b,y]=k.split(" ");return{hour:h,minutes:b,type:y}}return{hour:h,minutes:k,type:void 0}}if(typeof t=="object"){let{time:L,locales:T,preventClockType:k}=t,h=L??new Date;if(k&&i){let[v,m]=new Date(h).toLocaleTimeString().split(":");if(/[a-z]/i.test(m)){let[A,H]=m.split(" ");return{hour:v,minutes:A,type:H}}return{hour:v.padStart(2,"0"),minutes:m,type:void 0}}let b=new Date(h).toLocaleTimeString(T||"en-US",{hour:"2-digit",minute:"2-digit",hour12:e==="12h"}),[y,M]=b.split(":");if(e==="12h"&&/[a-z]/i.test(M)){let v=M.trim().split(" "),m=v[0],A=v[1]||"AM";return{hour:y,minutes:m,type:A}}return{hour:y,minutes:M.replace(/\D/g,""),type:void 0}}let[s,o]=r.split(" "),[c="",l=""]=s.split(":"),u=c.replace(/\D/g,""),d=l.replace(/\D/g,""),p={hour:u.padStart(2,"0"),minutes:d.padStart(2,"0"),type:e==="12h"?o:void 0};if(u.length>2||d.length>2)return{...p,error:"Invalid input: too many digits.",currentHour:c,currentMin:l};if(/[a-z]/i.test(s))return{...p,error:"Input contains invalid letters."};if(r.includes(" ")&&(!o||r.length>8||o!=="AM"&&o!=="PM"))return{...p,error:"Invalid AM/PM format or length.",currentLength:r.length,currentType:o};let g=Number(u),E=Number(d);if(e==="12h"){if(g<1||g>12||E<0||E>59||o!=="AM"&&o!=="PM")return{...p,error:"Invalid 12h time.",currentHour:g,currentMin:E,currentType:o}}else if(g<0||g>23||E<0||E>59)return{...p,error:"Invalid 24h time.",currentHour:g,currentMin:E};return p},Ee=(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 De=a=>{if(!a)return;let{disabledTime:e,type:t}=a.clock;if(!e||!Object.keys(e).length)return;let{hours:i,minutes:n,interval:r}=e;if(r){delete e.hours,delete e.minutes;let s=Array.isArray(r)?r:[r];if(!t)throw new Error("clockType required for interval");return ie(s,t),{value:s.map(l=>{let[u,d]=l.trim().split("-"),{hour:p,minutes:g,type:E}=D({value:u.trim()},t),{hour:L,minutes:T,type:k}=D({value:d.trim()},t),h=_(p,L).map(v=>Number(v)===0?"00":String(Number(v))),b=[],y=Number(g),M=Number(T);if(k===E)return y>0&&M<=0?(b.push(h[0],h[h.length-1]),h=h.slice(1,-1)):M<59&&M>0&&y<=0?(b.push(void 0,h[h.length-1]),h=h.slice(0,-1)):M>0&&y>0?(b.push(h[0],h[h.length-1]),h=h.slice(1,-1)):M===0&&y===0&&(b.push(void 0,h[h.length-1]),h.pop()),{removedStartedHour:b[0]!==void 0&&Number(b[0])<=9?`0${b[0]}`:b[0],removedEndHour:b[1]!==void 0&&Number(b[1])<=9?`0${b[1]}`:b[1],rangeArrHour:h,startMinutes:_(g,59).map(v=>Number(v)<=9?`0${v}`:`${v}`),endMinutes:te(0,T).map(v=>Number(v)<=9?`0${v}`:`${v}`),startType:E,endType:k};{let v=_(p,12).map(String),m=te(1,L).map(String),A=[],H=[];return y>0&&M<=0?(H.push(m[m.length-1]),A.push(v[0]),m.pop(),v.shift()):M<59&&M>0&&y<=0?(A.push(v[0]),H.push(m[m.length-1]),m.pop()):M>0&&y>0?(H.push(m[m.length-1]),A.push(v[0]),m.pop(),v.shift()):M===0&&y===0&&(H.push(m[m.length-1]),A.push(v[0]),m.pop()),{startType:E,endType:k,amHours:v,pmHours:m,removedAmHour:A[0]&&Number(A[0])<=9?`0${A[0]}`:A[0],removedPmHour:H[0]&&Number(H[0])<=9?`0${H[0]}`:H[0],startMinutes:Number(g)===0?[]:_(g,59).map(P=>Number(P)<=9?`0${P}`:`${P}`),endMinutes:te(0,T).map(P=>Number(P)<=9?`0${P}`:`${P}`)}}}).reduce((l,u)=>(Object.entries(u).forEach(([d,p])=>{Array.isArray(p)?l[d]=Array.isArray(l[d])?[...l[d],...p]:[...p]:l[d]=p}),l),{isInterval:!0,clockType:t,intervals:s})}}return i?.forEach(s=>{if(t==="12h"&&Number(s)>12)throw new Error("The disabled hours value has to be less than 13");if(t==="24h"&&Number(s)>23)throw new Error("The disabled hours value has to be less than 24")}),n?.forEach(s=>{if(Number(s)>59)throw new Error("The disabled minutes value has to be less than 60")}),{value:{hours:i?.map(s=>s==="00"||Number(s)===0?`0${Number(s)}`:`${Number(s)}`),minutes:n?.map(s=>Number(s)<=9?`0${s}`:`${s}`)}}},ye=(a,e,t,i)=>{if(a){if(Array.isArray(a)&&a.length>0)return!a.map(r=>Ee(r,e,t)).some(r=>r===!1);if(typeof a=="string"||typeof a=="number"){let n=Ee(a,e,t),r=i?.map(Number).includes(Number(a));return!!(n&&!r)}}};var Te="tp-ui",We="mousedown mouseup mousemove mouseleave mouseover",Ue="touchstart touchmove touchend",Ie=`${We} ${Ue}`,$="active";var K=class{core;emitter;isAnimating=!1;constructor(e,t){this.core=e,this.emitter=t,this.setupEventListeners()}setupEventListeners(){this.emitter.on("switch:view",()=>{this.toggleMobileClockFace()})}isCurrentTimeEnabled(e){let t=this.core.options.clock.currentTime;return typeof t=="boolean"?t:!!t?.[e]}preventClockTypeByCurrentTime(){if(!this.isCurrentTimeEnabled("preventClockType"))return;let e=this.core.getInput();if(!e)return;let{currentTime:t,clockType:i}={currentTime:this.core.options.clock.currentTime,clockType:this.core.options.clock.type},{type:n}=D(e,i,t,!0);this.core.updateOptions({clock:{type:n?"12h":"24h"}})}updateInputValueWithCurrentTimeOnStart(){if(!this.isCurrentTimeEnabled("updateInput"))return;let e=this.core.getInput();if(!e)return;let{hour:t,minutes:i,type:n}=D(e,this.core.options.clock.type,this.core.options.clock.currentTime);e.value=n?`${t}:${i} ${n}`:`${t}:${i}`}checkMobileOption(){this.core.setIsMobileView(!!this.core.options.ui.mobile),this.core.options.ui.mobile&&this.core.updateOptions({ui:{editable:!0}})}getDisableTime(){let e=De(this.core.options);this.core.setDisabledTime(e||null)}getInputValueOnOpenAndSet(){let e=this.core.getInput();if(!e)return;let t=D(e,this.core.options.clock.type,this.core.options.clock.currentTime),i=this.core.getHour(),n=this.core.getMinutes(),r=this.core.getActiveTypeMode(),s=this.core.getAM();if(t===void 0){i&&(i.value="12"),n&&(n.value="00");let g={hour:i?.value||"12",minutes:n?.value||"00",type:r?.dataset.type,degreesHours:this.core.degreesHours,degreesMinutes:this.core.degreesMinutes};this.emitter.emit("open",g);let E=this.core.options.range?.enabled===!0;this.core.options.clock.type!=="24h"&&s&&!E&&s.classList.add($);return}let[o,c,l]=e.value.split(":").join(" ").split(" ");e.value.length===0&&(o=t.hour,c=t.minutes,l=t.type),i&&(i.value=o.padStart(2,"0")),n&&(n.value=c.padStart(2,"0"));let d=this.core.getModalElement()?.querySelector(`[data-type='${l}']`);this.core.options.clock.type!=="24h"&&d&&d.classList.add($);let p={...t,type:r?.dataset.type,degreesHours:this.core.degreesHours,degreesMinutes:this.core.degreesMinutes};this.emitter.emit("open",p)}getInputValue(e,t,i){return D(e,t,i)}toggleMobileClockFace(){if(this.isAnimating)return;let e=this.core.getModalElement();if(!e)return;let t=e.querySelector(".tp-ui-wrapper"),i=this.core.getKeyboardClockIcon(),n=e.querySelector(".tp-ui-mobile-clock-wrapper"),r=e.querySelectorAll("*"),s=e.querySelector(".tp-ui-select-time"),o=this.core.getHour(),c=this.core.getMinutes(),l=this.core.getClockFace();if(!t)return;let u=t.classList.contains("expanded"),d=this.core.isMobileView;u?this.collapseClockFace(t,n,r,i,s,o,c,l,d):this.expandClockFace(t,n,r,i,s,o,c,l)}collapseClockFace(e,t,i,n,r,s,o,c,l){this.isAnimating=!0,this.switchView(r,n,s,o,!0),i.forEach(u=>{u!==t&&u!==e&&u!==r&&(u.classList.remove("expanded"),l&&u.classList.add("mobile"))}),r&&(r.classList.remove("expanded"),l&&r.classList.add("mobile")),typeof requestAnimationFrame<"u"?requestAnimationFrame(()=>{t?.classList.remove("expanded"),l&&t?.classList.add("mobile"),e?.classList.remove("expanded"),l&&e?.classList.add("mobile"),l?c?.classList.remove("scale-in"):c?.classList.add("scale-in"),setTimeout(()=>{this.isAnimating=!1},C.MOBILE_TOGGLE)}):this.isAnimating=!1,n?.setAttribute("aria-label","Show clock face"),n?.setAttribute("aria-pressed","false")}expandClockFace(e,t,i,n,r,s,o,c){this.isAnimating=!0,o?.classList.contains("active")&&o?this.emitter.emit("select:minute",{minutes:o.value}):s&&this.emitter.emit("select:hour",{hour:s.value}),i.forEach(u=>{u!==t&&u!==e&&u!==r&&(u.classList.remove("mobile"),u.classList.add("expanded"))}),r&&(r.classList.remove("mobile"),r.classList.add("expanded")),this.switchView(r,n,s,o,!1),typeof requestAnimationFrame<"u"?requestAnimationFrame(()=>{e.classList.remove("mobile"),e.classList.add("expanded"),requestAnimationFrame(()=>{t&&(t.classList.remove("mobile"),t.classList.add("expanded")),c&&c.classList.remove("scale-in"),setTimeout(()=>{c&&c.classList.add("scale-in")},C.CLOCK_SCALE_DELAY),setTimeout(()=>{this.isAnimating=!1},C.MOBILE_TOGGLE)})}):this.isAnimating=!1,n?.setAttribute("aria-label","Hide clock face"),n?.setAttribute("aria-pressed","true")}switchView(e,t,i,n,r){let s=this.core.getModalElement(),o=s?.querySelector(".tp-ui-hour-text"),c=s?.querySelector(".tp-ui-minute-text"),l=t?.querySelector(".tp-ui-keyboard-icon"),u=this.core.getInputWrappers(),d=this.core.getHeader(),{iconTemplate:p,iconTemplateMobile:g}=this.core.options.ui,{time:E,mobileTime:L}=this.core.options.labels;r?(e?.classList.add("mobile"),t?.classList.add("mobile"),i?.classList.add("mobile"),n?.classList.add("mobile"),o?.classList.add("mobile"),c?.classList.add("mobile"),d?.classList.add("mobile"),u?.forEach(T=>{T.classList.add("mobile")}),e&&L&&(e.textContent=L),l&&(l.innerHTML=g||re),this.updateClockFaceAccessibility(!0)):(e?.classList.remove("mobile"),t?.classList.remove("mobile"),i?.classList.remove("mobile"),n?.classList.remove("mobile"),o?.classList.remove("mobile"),c?.classList.remove("mobile"),d?.classList.remove("mobile"),u?.forEach(T=>{T.classList.remove("mobile")}),e&&E&&(e.textContent=E),l&&(l.innerHTML=p||ne),this.updateClockFaceAccessibility(!1))}updateClockFaceAccessibility(e){let t=this.core.getClockFace();if(!t)return;let i=t.querySelector(".tp-ui-tips-wrapper"),n=t.querySelector(".tp-ui-tips-wrapper-24h"),r=t.querySelectorAll(".tp-ui-tip");e?(t.setAttribute("aria-hidden","true"),i?.setAttribute("aria-hidden","true"),n?.setAttribute("aria-hidden","true"),r.forEach(s=>{s.setAttribute("tabindex","-1"),s.setAttribute("aria-hidden","true")})):(t.removeAttribute("aria-hidden"),i?.removeAttribute("aria-hidden"),n?.removeAttribute("aria-hidden"),r.forEach(s=>{s.setAttribute("tabindex","0"),s.removeAttribute("aria-hidden")}))}destroy(){}};var Y=class{core;emitter;constructor(e,t){this.core=e,this.emitter=t}setTheme(){let e=this.core.getModalElement();if(!e)return;let{theme:t}=this.core.options.ui;t&&e.setAttribute("data-theme",t)}setInputClassToInputElement(){let e=this.core.getInput();e&&(Le(e,"tp-ui-input")||e.classList.add("tp-ui-input"))}setDataOpenToInputIfDoesntExistInWrapper(){let e=this.core.getOpenElementData(),t=this.core.getInput();e===null&&t&&t.setAttribute("data-open","tp-ui-input")}setClassTopOpenElement(){let e=this.core.getOpenElement();for(let t of e)t&&t.classList.add("tp-ui-open-element")}setTimepickerClassToElement(){let e=this.core.element;if(!e)return;e.classList.add(Te);let t=this.core.options.ui.cssClass;t&&t!==Te&&e.classList.add(t)}destroy(){let e=this.core.getModalElement();e&&e.removeAttribute("data-theme")}};var N=class a extends Error{constructor(t,i){super(`[TimepickerUI] ${t}`);this.code=i;this.name="TimepickerError",Object.setPrototypeOf(this,a.prototype)}},se={ELEMENT_NOT_FOUND:"ELEMENT_NOT_FOUND",INVALID_PARAMETER:"INVALID_PARAMETER",NO_INPUT_ELEMENT:"NO_INPUT_ELEMENT",INSTANCE_DESTROYED:"INSTANCE_DESTROYED",NOT_INITIALIZED:"NOT_INITIALIZED",INVALID_TIME_FORMAT:"INVALID_TIME_FORMAT",INLINE_CONFIG_ERROR:"INLINE_CONFIG_ERROR",CONTAINER_NOT_FOUND:"CONTAINER_NOT_FOUND",SSR_ENVIRONMENT:"SSR_ENVIRONMENT"};var Z=class{core;emitter;constructor(e,t){this.core=e,this.emitter=t}setErrorHandler(){let e=this.core.getInput();if(!e)return!0;let{error:t,currentHour:i,currentMin:n,currentType:r,currentLength:s}=D(e,this.core.options.clock.type);if(this.removeErrorHandler(),t){if(f()===!1)return!1;let o=document.createElement("div");o.classList.add("tp-ui-invalid-text"),o.innerHTML="<b>Invalid Time Format</b>",e.classList.add("tp-ui-invalid-format"),e.nextElementSibling?.classList.contains("tp-ui-invalid-text")||e.after(o);let c={error:t,rejectedHour:void 0,rejectedMinute:void 0,inputHour:i,inputMinute:n,inputType:r,inputLength:s};return this.emitter.emit("error",c),!1}return!0}removeErrorHandler(){let e=this.core.getInput();if(!e)return;e.classList.remove("tp-ui-invalid-format");let t=e.nextElementSibling;t?.classList.contains("tp-ui-invalid-text")&&t.remove()}checkDisabledValuesOnStart(){if(!this.core.options.clock.disabledTime)return;let{disabledTime:e,type:t}=this.core.options.clock;if(e.interval){if(!t)throw new N("clockType is required when using disabledTime.interval",se.INVALID_PARAMETER);let o=Array.isArray(e.interval)?e.interval:[e.interval];try{ie(o,t)}catch(c){throw new N(`Invalid disabledTime.interval: ${c.message}`,se.INVALID_PARAMETER)}return}let{hours:i,minutes:n}=e,r=i?ye(i,"hour",t):!0,s=n?ye(n,"minutes",t):!0;if(!r||!s)throw new N("Invalid hours or minutes in disabledTime option",se.INVALID_PARAMETER)}destroy(){this.removeErrorHandler()}};var O=(a,e)=>{if(!a)return;let t=a.querySelector(".timepicker-announcer");t&&(t.textContent="",setTimeout(()=>{t.textContent=e},100))},G=(a,e)=>{a&&a.setAttribute("aria-pressed",String(e))};var j=class{core;emitter;cleanupHandlers=[];constructor(e,t){this.core=e,this.emitter=t}handleOpenOnClick(){let e=this.core.getOpenElement();if(!e)return;let t=()=>{this.core.isDestroyed||this.emitter.emit("show",{})};e.forEach(i=>{i.addEventListener("click",t),this.cleanupHandlers.push(()=>i.removeEventListener("click",t))})}handleOpenOnEnterFocus(){let e=this.core.getInput();if(!e)return;let t=i=>{i.key==="Enter"&&!this.core.isDestroyed&&this.emitter.emit("show",{})};e.addEventListener("keydown",t),this.cleanupHandlers.push(()=>e.removeEventListener("keydown",t))}handleCancelButton(){let e=this.core.getCancelButton();if(!e)return;let t=()=>{this.core.isDestroyed||this.emitter.emit("cancel",{})};e.addEventListener("click",t),this.cleanupHandlers.push(()=>e.removeEventListener("click",t))}handleOkButton(){let e=this.core.getOkButton();if(!e)return;let t=()=>{if(this.core.isDestroyed)return;let i=this.core.getHour(),n=this.core.getMinutes(),r=this.core.getActiveTypeMode();this.emitter.emit("confirm",{hour:i?.value,minutes:n?.value,type:r?.textContent||void 0})};e.addEventListener("click",t),this.cleanupHandlers.push(()=>e.removeEventListener("click",t))}handleBackdropClick(){let e=this.core.getModalElement();if(!e)return;let t=i=>{this.core.isDestroyed||i.target===e&&this.emitter.emit("cancel",{})};e.addEventListener("click",t),this.cleanupHandlers.push(()=>e.removeEventListener("click",t))}handleEscClick(){if(f()===!1)return;let e=t=>{this.core.isDestroyed||t.key==="Escape"&&this.emitter.emit("cancel",{})};document.addEventListener("keydown",e),this.cleanupHandlers.push(()=>document.removeEventListener("keydown",e))}handleAmClick(){let e=this.core.getAM();if(!e)return;let t=()=>{if(this.core.isDestroyed)return;let i=this.core.getPM();e.classList.add("active"),i?.classList.remove("active"),G(e,!0),G(i,!1);let n=this.core.getModalElement();O(n,"AM selected"),this.emitter.emit("select:am",{});let r=this.core.getHour(),s=this.core.getMinutes();this.emitter.emit("update",{hour:r?.value,minutes:s?.value,type:"AM"})};e.addEventListener("click",t),this.cleanupHandlers.push(()=>e.removeEventListener("click",t))}handlePmClick(){let e=this.core.getPM();if(!e)return;let t=()=>{if(this.core.isDestroyed)return;let i=this.core.getAM();e.classList.add("active"),i?.classList.remove("active"),G(e,!0),G(i,!1);let n=this.core.getModalElement();O(n,"PM selected"),this.emitter.emit("select:pm",{});let r=this.core.getHour(),s=this.core.getMinutes();this.emitter.emit("update",{hour:r?.value,minutes:s?.value,type:"PM"})};e.addEventListener("click",t),this.cleanupHandlers.push(()=>e.removeEventListener("click",t))}handleHourEvents(){let e=this.core.getHour();if(!e)return;let t=()=>{if(this.core.isDestroyed)return;e.classList.add("active");let i=this.core.getMinutes();i?.classList.remove("active"),this.emitter.emit("select:hour",{hour:e.value});let n=this.core.getActiveTypeMode();this.emitter.emit("update",{hour:e.value,minutes:i?.value,type:n?.textContent||void 0})};if(e.addEventListener("click",t),this.cleanupHandlers.push(()=>e.removeEventListener("click",t)),this.core.options.ui.editable){let i=e.value,n=()=>{if(!this.core.isDestroyed&&e.value!==i){i=e.value,this.emitter.emit("animation:clock",{}),this.emitter.emit("select:hour",{hour:e.value});let r=this.core.getMinutes(),s=this.core.getActiveTypeMode();this.emitter.emit("update",{hour:e.value,minutes:r?.value,type:s?.textContent||void 0})}};e.addEventListener("blur",n),this.cleanupHandlers.push(()=>e.removeEventListener("blur",n))}}handleMinutesEvents(){let e=this.core.getMinutes();if(!e)return;let t=()=>{if(this.core.isDestroyed)return;e.classList.add("active");let i=this.core.getHour();i?.classList.remove("active"),this.emitter.emit("select:minute",{minutes:e.value});let n=this.core.getActiveTypeMode();this.emitter.emit("update",{hour:i?.value,minutes:e.value,type:n?.textContent||void 0})};e.addEventListener("click",t),this.cleanupHandlers.push(()=>e.removeEventListener("click",t))}handleKeyboardInput(){let e=this.core.getHour(),t=this.core.getMinutes();if(e){let i=n=>{if(this.core.isDestroyed||n.key!=="ArrowUp"&&n.key!=="ArrowDown")return;n.preventDefault();let r=parseInt(e.value)||0,s=parseInt(e.getAttribute("max")||"23"),o=parseInt(e.getAttribute("min")||"0"),c=this.core.options.clock.type==="12h",l;n.key==="ArrowUp"?c?l=r>=12?1:r+1:l=r>=s?0:r+1:c?l=r<=1?12:r-1:l=r<=0?s:r-1,e.value=l.toString().padStart(2,"0"),e.setAttribute("aria-valuenow",e.value);let u=this.core.getModalElement();O(u,`Hour: ${e.value}`),this.emitter.emit("animation:clock",{}),this.emitter.emit("select:hour",{hour:e.value});let d=this.core.getMinutes(),p=this.core.getActiveTypeMode();this.emitter.emit("update",{hour:e.value,minutes:d?.value,type:p?.textContent||void 0})};e.addEventListener("keydown",i),this.cleanupHandlers.push(()=>e.removeEventListener("keydown",i))}if(t){let i=n=>{if(this.core.isDestroyed||n.key!=="ArrowUp"&&n.key!=="ArrowDown")return;n.preventDefault();let r=parseInt(t.value)||0,s=59,o=0,c;n.key==="ArrowUp"?c=r>=s?o:r+1:c=r<=o?s:r-1,t.value=c.toString().padStart(2,"0"),t.setAttribute("aria-valuenow",t.value);let l=this.core.getModalElement();O(l,`Minutes: ${t.value}`),this.emitter.emit("animation:clock",{}),this.emitter.emit("select:minute",{minutes:t.value});let u=this.core.getHour(),d=this.core.getActiveTypeMode();this.emitter.emit("update",{hour:u?.value,minutes:t.value,type:d?.textContent||void 0})};t.addEventListener("keydown",i),this.cleanupHandlers.push(()=>t.removeEventListener("keydown",i))}}focusTrapHandler(){if(f()===!1)return;let e=this.core.getWrapper();if(!e)return;let t=i=>{if(this.core.isDestroyed||i.key!=="Tab")return;let n=e.querySelectorAll('button, [href], input, select, textarea, [tabindex]:not([tabindex="-1"])'),r=n[0],s=n[n.length-1];i.shiftKey&&document.activeElement===r?(s?.focus(),i.preventDefault()):!i.shiftKey&&document.activeElement===s&&(r?.focus(),i.preventDefault())};e.addEventListener("keydown",t),this.cleanupHandlers.push(()=>e.removeEventListener("keydown",t))}handleMoveHand(){if(f()===!1)return;let e=t=>{this.core.isDestroyed||t.preventDefault()};document.addEventListener("mousedown",e,!1),document.addEventListener("touchstart",e,{passive:!1}),this.cleanupHandlers.push(()=>{document.removeEventListener("mousedown",e),document.removeEventListener("touchstart",e)})}handleSwitchViewButton(){let e=this.core.getKeyboardClockIcon();if(!e)return;let t=()=>{this.core.isDestroyed||this.emitter.emit("switch:view",{})};e.addEventListener("click",t),this.cleanupHandlers.push(()=>e.removeEventListener("click",t))}destroy(){this.cleanupHandlers.forEach(e=>e()),this.cleanupHandlers=[]}};var I=class{static angleToIndex(e,t,i){let n=Math.round(e/30)%12;if(t==="24h")if(i){let r=n+12;return r===12?0:r}else return n===0?12:n;return n===0?12:n}static indexToValue(e,t,i){if(t==="24h")return e.toString().padStart(2,"0");let n=e;return n===0&&(n=12),n>12&&(n=n-12),n.toString().padStart(2,"0")}static indexToAngle(e,t){return t==="24h"?e>=12?(e-12)%12*30:e%12*30:(e===0?12:e)%12*30}static isDisabled(e,t,i){return i?i.isInterval&&i.intervals&&i.clockType?this.isDisabledByInterval(e,t,i):i.rangeFromType!==void 0&&i.rangeFromHour!==void 0?this.isDisabledForRange12h(e,t,i):i.hours?i.hours.some(n=>String(n)===e||Number(n)===Number(e)||n===e):!1:!1}static isDisabledForRange12h(e,t,i){let n=i.rangeFromType,r=i.rangeFromHour,s=parseInt(e,10);return n===null||r===void 0?!1:t==="AM"&&n==="PM"?!0:t==="AM"&&n==="AM"?r===12?!1:s===12?!0:s<r:t==="PM"&&n==="AM"?!1:t==="PM"&&n==="PM"?r===12?!1:s===12?!0:s<r:!1}static isDisabledByInterval(e,t,i){if(!i.intervals)return!1;for(let n=0;n<60;n++){let r=n.toString().padStart(2,"0");if(!this.isTimeInIntervals(e,r,t,i.intervals,i.clockType))return!1}return!0}static isTimeInIntervals(e,t,i,n,r){let s=r==="12h"?`${e}:${t} ${i}`:`${e}:${t}`;for(let o of n){let[c,l]=o.split("-").map(u=>u.trim());if(this.isTimeBetween(s,c,l,r))return!0}return!1}static isTimeBetween(e,t,i,n){let r=this.timeToMinutes(e,n),s=this.timeToMinutes(t,n),o=this.timeToMinutes(i,n);return r>=s&&r<=o}static timeToMinutes(e,t){if(t==="12h"){let i=e.match(/(\d{1,2}):(\d{2})\s*(AM|PM)/i);if(!i)return 0;let n=parseInt(i[1]),r=parseInt(i[2]),s=i[3].toUpperCase();return s==="PM"&&n!==12&&(n+=12),s==="AM"&&n===12&&(n=0),n*60+r}else{let[i,n]=e.split(":").map(Number);return i*60+n}}static findNearestValid(e,t,i,n,r){let s=t==="24h"?23:12;for(let o=0;o<=s;o++){let c=o===0?[e]:[e+o,e-o];for(let l of c){let u=l;u<0&&(u+=s+1),u>s&&(u=u%(s+1));let d=this.indexToValue(u,t,i);if(!this.isDisabled(d,i,n))return u}}return e}};var w=class{static angleToIndex(e){return Math.round(e/6)%60}static indexToValue(e){return e.toString().padStart(2,"0")}static indexToAngle(e){return e%60*6}static isDisabled(e,t,i,n,r){return n?n.isInterval&&n.intervals?this.isDisabledByInterval(e,t,i,n,r):n.rangeFromType!==void 0&&n.rangeFromHour!==void 0?this.isDisabledForRange12h(e,t,i,n):n.minutes?n.minutes.some(s=>String(s)===e||Number(s)===Number(e)||s===e):!1:!1}static isDisabledForRange12h(e,t,i,n){let r=n.rangeFromType,s=n.rangeFromHour,o=parseInt(t,10),c=parseInt(e,10);if(r===null||s===void 0)return!1;let l=n.minutes||[],u=l.length>0?parseInt(l[l.length-1],10)+1:0;return i==="AM"&&r==="PM"?!0:i==="PM"&&r==="AM"?!1:o===s||o===12&&s===12||i===r&&o===s?c<u:!1}static isDisabledByInterval(e,t,i,n,r){if(!n.intervals)return!1;let s=r==="12h"?`${t}:${e} ${i}`:`${t}:${e}`;for(let o of n.intervals){let[c,l]=o.split("-").map(u=>u.trim());if(this.isTimeBetween(s,c,l,r))return!0}return!1}static isTimeBetween(e,t,i,n){let r=this.timeToMinutes(e,n),s=this.timeToMinutes(t,n),o=this.timeToMinutes(i,n);return r>=s&&r<=o}static timeToMinutes(e,t){if(t==="12h"){let i=e.match(/(\d{1,2}):(\d{2})\s*(AM|PM)/i);if(!i)return 0;let n=parseInt(i[1]),r=parseInt(i[2]),s=i[3].toUpperCase();return s==="PM"&&n!==12&&(n+=12),s==="AM"&&n===12&&(n=0),n*60+r}else{let[i,n]=e.split(":").map(Number);return i*60+n}}static findNearestValid(e,t,i,n,r){for(let s=0;s<60;s++){let o=s===0?[e]:[e+s,e-s];for(let c of o){let l=c;l<0&&(l+=60),l>=60&&(l=l%60);let u=this.indexToValue(l);if(!this.isDisabled(u,t,i,n,r))return l}}return e}};var x=class{static normalizeAngle(e){let t=e%360;return t<0&&(t+=360),t}static calculateRawAngle(e,t){let i=e.x-t.x,n=e.y-t.y,s=Math.atan2(n,i)*180/Math.PI+90;return this.normalizeAngle(s)}static snapToIncrement(e,t){let i=Math.round(e/t)*t;return this.normalizeAngle(i)}static calculateDistance(e,t){let i=e.x-t.x,n=e.y-t.y;return Math.sqrt(i*i+n*n)}static isInnerCircle(e,t){return e<t*.75}static calculateShortestPath(e,t){let i=this.normalizeAngle(e),r=this.normalizeAngle(t)-i,s=r>=0?r:r+360,o=r<=0?r:r-360,c=Math.abs(s)<Math.abs(o)?s:o;return e+c}};var oe=class{config;currentAngle=0;tipsCache=new Map;cachedDimensions=new Map;constructor(e){this.config=e}getCachedDimensions(e){let t=this.cachedDimensions.get(e);if(!t){let i=(e.offsetWidth-32)/2,n=(e.offsetHeight-32)/2,r=i-9;t={width:i,height:n,radius:r},this.cachedDimensions.set(e,t)}return t}setHandAngle(e){let t=x.calculateShortestPath(this.currentAngle,e);Math.abs(this.currentAngle-t)<.01||(this.currentAngle=t,this.config.clockHand.style.transform=`rotateZ(${t}deg)`)}animateToAngle(e){let t=x.calculateShortestPath(this.currentAngle,e);this.currentAngle=t,this.config.tipsWrapper.classList.add("tp-ui-tips-animation"),this.config.clockHand.style.transform=`rotateZ(${t}deg)`,setTimeout(()=>{this.config.tipsWrapper.classList.remove("tp-ui-tips-animation")},401)}setActiveValue(e){let t=[this.config.tipsWrapper];this.config.tipsWrapperFor24h&&t.push(this.config.tipsWrapperFor24h),t.forEach(i=>{i.querySelectorAll(".tp-ui-value-tips, .tp-ui-value-tips-24h").forEach(r=>{let s=r;s.textContent===e||Number(s.textContent)===Number(e)?(s.classList.add("active"),s.setAttribute("aria-selected","true")):(s.classList.remove("active"),s.setAttribute("aria-selected","false"))})})}renderTips(e,t,i,n,r,s=!0,o,c="",l="12"){if(f()===!1)return;let u=o||this.config.tipsWrapper;s&&(u.innerHTML="",this.tipsCache.clear());let{width:d,height:p,radius:g}=this.getCachedDimensions(u),E=document.createDocumentFragment(),L=`${t}-${this.config.theme||"default"}`;e.forEach((T,k)=>{let h=`${L}-${T}`,b=this.tipsCache.get(h);b||(b=this.createTip(T,t,r),this.tipsCache.set(h,b));let{wrapper:y,tip:M}=b;this.updateTipState(y,M,T,i,n,r,c,l);let v=k*(360/e.length)*(Math.PI/180);y.style.left=`${d+Math.sin(v)*g}px`,y.style.bottom=`${p+Math.cos(v)*g}px`,E.appendChild(y)}),u.appendChild(E)}createTip(e,t,i){if(f()===!1){let o={};return{wrapper:o,tip:o}}let n=document.createElement("span"),r=document.createElement("span");r.textContent=e,r.setAttribute("role","option"),r.setAttribute("aria-selected","false"),r.tabIndex=0;let s=i==="24h"&&t.includes("24")?"tp-ui-value-tips-24h":"tp-ui-value-tips";return r.classList.add(s),n.classList.add(t),this.config.theme&&(n.classList.add(this.config.theme),r.classList.add(this.config.theme)),n.appendChild(r),{wrapper:n,tip:r}}updateTipState(e,t,i,n,r,s,o,c){e.classList.remove("tp-ui-tips-disabled"),t.classList.remove("tp-ui-tips-disabled"),t.removeAttribute("aria-disabled"),t.tabIndex=0,this.checkIfDisabled(i,n,r,s,o,c)&&(e.classList.add("tp-ui-tips-disabled"),t.classList.add("tp-ui-tips-disabled"),t.setAttribute("aria-disabled","true"),t.tabIndex=-1)}checkIfDisabled(e,t,i,n,r,s){return i?t==="hours"?I.isDisabled(e,r,i):t==="minutes"?w.isDisabled(e,s,r,i,n):!1:!1}setCircleSize(e){e?this.config.circle.classList.remove("small-circle"):this.config.circle.classList.add("small-circle")}setCircle24hMode(e){e?(this.config.circle.classList.add("tp-ui-circle-hand-24h"),this.config.clockHand.classList.add("tp-ui-clock-hand-24h")):(this.config.circle.classList.remove("tp-ui-circle-hand-24h"),this.config.clockHand.classList.remove("tp-ui-clock-hand-24h"))}destroy(){this.tipsCache.clear(),this.cachedDimensions.clear(),this.config.tipsWrapper.innerHTML=""}};var V=class{static processPointerInput(e){let t=x.calculateRawAngle(e.pointerPosition,e.clockCenter);return e.mode==="hours"?this.processHours(t,e):this.processMinutes(t,e)}static processHours(e,t){let i=t.smoothHourSnap??!0,n;if(i)n=e;else{let p=t.incrementHours*30;n=x.snapToIncrement(e,p)}let r=x.calculateDistance(t.pointerPosition,t.clockCenter),s=t.clockType==="24h"&&x.isInnerCircle(r,t.clockRadius),o=I.angleToIndex(n,t.clockType,s),c=I.indexToValue(o,t.clockType,t.amPm),l=I.isDisabled(c,t.amPm,t.disabledTime);l&&(o=I.findNearestValid(o,t.clockType,t.amPm,t.disabledTime,s));let u=I.indexToValue(o,t.clockType,t.amPm),d;return i?d=e:d=I.indexToAngle(o,t.clockType),{angle:d,value:u,index:o,isValid:!l,isInnerCircle:t.clockType==="24h"?s:void 0}}static processMinutes(e,t){let i=t.incrementMinutes*6,n=x.snapToIncrement(e,i),r=w.angleToIndex(n),s=w.indexToValue(r),o=t.currentHour||"00",c=w.isDisabled(s,o,t.amPm,t.disabledTime,t.clockType);c&&(r=w.findNearestValid(r,o,t.amPm,t.disabledTime,t.clockType));let l=w.indexToValue(r);return{angle:w.indexToAngle(r),value:l,index:r,isValid:!c}}static valueToAngle(e,t,i){let n=parseInt(e,10);return t==="hours"?I.indexToAngle(n,i):w.indexToAngle(n)}};var ae=class{state;renderer;clockType;disabledTime;incrementHours;incrementMinutes;smoothHourSnap;isDragging=!1;callbacks;lastProcessedX=null;lastProcessedY=null;constructor(e,t,i,n,r=1,s=1,o=!0,c={}){this.renderer=e,this.state={...t},this.clockType=i,this.disabledTime=n,this.incrementHours=r,this.incrementMinutes=s,this.smoothHourSnap=o,this.callbacks=c}handlePointerMove(e,t,i){if(this.isDragging=!0,this.lastProcessedX===e.x&&this.lastProcessedY===e.y)return;this.lastProcessedX=e.x,this.lastProcessedY=e.y;let n={pointerPosition:e,clockCenter:t,clockRadius:i,mode:this.state.mode,clockType:this.clockType,amPm:this.state.amPm,disabledTime:this.disabledTime,incrementHours:this.incrementHours,incrementMinutes:this.incrementMinutes,smoothHourSnap:this.smoothHourSnap,currentHour:this.state.hour},r=V.processPointerInput(n);if(r.isValid){if(this.state.mode==="hours"){let s=this.state.hour;this.state.hour=r.value,this.state.hourAngle=r.angle,this.clockType==="24h"&&r.isInnerCircle!==void 0&&(this.renderer.setCircleSize(!0),this.renderer.setCircle24hMode(r.isInnerCircle)),this.callbacks.onHourChange&&s!==r.value&&this.callbacks.onHourChange(r.value)}else{let s=this.state.minute;this.state.minute=r.value,this.state.minuteAngle=r.angle,this.renderer.setCircleSize(!0),this.renderer.setCircle24hMode(!1),this.callbacks.onMinuteChange&&s!==r.value&&this.callbacks.onMinuteChange(r.value)}this.renderer.setHandAngle(r.angle),this.renderer.setActiveValue(r.value)}}handlePointerUp(){this.isDragging=!1,this.lastProcessedX=null,this.lastProcessedY=null}snapToNearestHour(){if(this.state.mode!=="hours")return;let e=V.valueToAngle(this.state.hour,"hours",this.clockType);this.state.hourAngle=e,this.renderer.animateToAngle(e)}switchMode(e){this.state.mode=e;let t=e==="hours"?this.state.hourAngle:this.state.minuteAngle,i=e==="hours"?this.state.hour:this.state.minute;if(e==="hours"&&this.clockType==="24h"){let n=parseInt(i,10),r=n===0||n>=13;this.renderer.setCircleSize(!0),this.renderer.setCircle24hMode(r)}else this.renderer.setCircleSize(!0),this.renderer.setCircle24hMode(!1);this.renderer.setHandAngle(t),this.renderer.setActiveValue(i)}setValue(e,t){let i=V.valueToAngle(t,e,this.clockType);if(e==="hours")if(this.state.hour=t,this.state.hourAngle=i,this.clockType==="24h"){let n=parseInt(t,10),r=n===0||n>=13;this.renderer.setCircleSize(!0),this.renderer.setCircle24hMode(r)}else this.renderer.setCircle24hMode(!1);else this.state.minute=t,this.state.minuteAngle=i,this.renderer.setCircleSize(!0),this.renderer.setCircle24hMode(!1);this.state.mode===e&&(this.renderer.setHandAngle(i),this.renderer.setActiveValue(t))}setAmPm(e){this.state.amPm=e}getState(){return{...this.state}}getHour(){return this.state.hour}getMinute(){return this.state.minute}getAmPm(){return this.state.amPm}updateDisabledTime(e){this.disabledTime=e}destroy(){this.renderer.destroy()}};var le=class{controller;clockFace;isActive=!1;isBlocked=!1;config;cachedRect=null;cachedCenter=null;cachedRadius=null;rafId=null;constructor(e,t,i={}){this.controller=e,this.clockFace=t,this.config=i}attach(){this.clockFace.addEventListener("mousedown",this.handlePointerDown),this.clockFace.addEventListener("touchstart",this.handlePointerDown,{passive:!1})}detach(){this.clockFace.removeEventListener("mousedown",this.handlePointerDown),this.clockFace.removeEventListener("touchstart",this.handlePointerDown),this.removeGlobalListeners()}block(){this.isBlocked=!0}unblock(){this.isBlocked=!1}handlePointerDown=e=>{if(S()||this.isBlocked)return;let t=e.target;t&&t.classList&&t.classList.contains("tp-ui-tips-disabled")||(e.preventDefault(),this.isActive=!0,this.cachedRect=this.clockFace.getBoundingClientRect(),this.cachedCenter=this.getClockCenter(),this.cachedRadius=this.getClockRadius(),this.processPointerEvent(e),document.addEventListener("mousemove",this.handlePointerMove),document.addEventListener("touchmove",this.handlePointerMove,{passive:!1}),document.addEventListener("mouseup",this.handlePointerUp),document.addEventListener("touchend",this.handlePointerUp))};handlePointerMove=e=>{if(!this.isActive||this.isBlocked)return;let t=this.getTargetElement(e);t&&t.classList&&t.classList.contains("tp-ui-tips-disabled")||(e.preventDefault(),this.rafId===null&&(this.rafId=requestAnimationFrame(()=>{this.rafId=null,this.processPointerEvent(e)})))};handlePointerUp=()=>{if(!this.isActive)return;this.rafId!==null&&(cancelAnimationFrame(this.rafId),this.rafId=null),this.isActive=!1,this.cachedRect=null,this.cachedCenter=null,this.cachedRadius=null,this.controller.handlePointerUp();let{autoSwitchToMinutes:e,isMobileView:t,smoothHourSnap:i,hourElement:n,minutesElement:r}=this.config;i&&n?.classList.contains("active")&&this.controller.snapToNearestHour(),this.removeGlobalListeners(),e&&n?.classList.contains("active")&&!t?(r?.click(),r?.focus()):r?.classList.contains("active")&&this.config.onMinuteCommit&&this.config.onMinuteCommit()};processPointerEvent(e){let t=this.getPointerPosition(e),i=this.cachedCenter||this.getClockCenter(),n=this.cachedRadius||this.getClockRadius();this.controller.handlePointerMove(t,i,n)}getPointerPosition(e){let t=this.cachedRect||this.clockFace.getBoundingClientRect();if("touches"in e){let i=e.touches[0]||e.changedTouches[0];return{x:i.clientX-t.left,y:i.clientY-t.top}}else return{x:e.clientX-t.left,y:e.clientY-t.top}}getTargetElement(e){if("touches"in e){let t=e.touches[0]||e.changedTouches[0];if(t&&!S())return document.elementFromPoint(t.clientX,t.clientY)}return e.target}getClockCenter(){let e=this.clockFace.offsetWidth,t=this.clockFace.offsetHeight;return{x:e/2,y:t/2}}getClockRadius(){return this.clockFace.offsetWidth/2}removeGlobalListeners(){f()!==!1&&(document.removeEventListener("mousemove",this.handlePointerMove),document.removeEventListener("touchmove",this.handlePointerMove),document.removeEventListener("mouseup",this.handlePointerUp),document.removeEventListener("touchend",this.handlePointerUp))}};var X=class{renderer;controller;dragHandlers;clockType;disabledTime;tipsWrapper;tipsWrapperFor24h;constructor(e){this.clockType=e.clockType,this.disabledTime=e.disabledTime,this.tipsWrapper=e.tipsWrapper,this.tipsWrapperFor24h=e.tipsWrapperFor24h;let t={clockFace:e.clockFace,tipsWrapper:e.tipsWrapper,tipsWrapperFor24h:e.tipsWrapperFor24h,clockHand:e.clockHand,circle:e.circle,theme:e.theme};this.renderer=new oe(t);let i={hour:e.initialHour,minute:e.initialMinute,amPm:e.initialAmPm,hourAngle:this.calculateInitialAngle("hours",e.initialHour),minuteAngle:this.calculateInitialAngle("minutes",e.initialMinute),mode:"hours"},n={onHourChange:e.onHourChange,onMinuteChange:e.onMinuteChange};this.controller=new ae(this.renderer,i,e.clockType,e.disabledTime,e.incrementHours||1,e.incrementMinutes||1,e.smoothHourSnap??!0,n),this.dragHandlers=new le(this.controller,e.clockFace,e.dragConfig||{})}initialize(){this.dragHandlers.attach(),this.switchToHours()}switchToHours(){this.controller.switchMode("hours"),this.clockType==="24h"&&this.tipsWrapperFor24h&&this.tipsWrapperFor24h.classList.remove("none"),this.renderHourTips();let e=this.controller.getState();this.renderer.setActiveValue(e.hour)}switchToMinutes(){this.controller.switchMode("minutes"),this.tipsWrapperFor24h&&this.tipsWrapperFor24h.classList.add("none"),this.renderMinuteTips();let e=this.controller.getState();this.renderer.setActiveValue(e.minute)}setHour(e){this.controller.setValue("hours",e)}setMinute(e){this.controller.setValue("minutes",e)}setAmPm(e){this.controller.setAmPm(e);let t=this.controller.getState();t.mode==="hours"?(this.renderHourTips(),this.renderer.setHandAngle(t.hourAngle),this.renderer.setActiveValue(t.hour)):(this.renderMinuteTips(),this.renderer.setHandAngle(t.minuteAngle),this.renderer.setActiveValue(t.minute))}getHour(){return this.controller.getHour()}getMinute(){return this.controller.getMinute()}getAmPm(){return this.controller.getAmPm()}updateDisabledTime(e){this.disabledTime=e,this.controller.updateDisabledTime(e),this.controller.getState().mode==="hours"?this.renderHourTips():this.renderMinuteTips()}renderHourTips(){let t=this.controller.getState().amPm;this.clockType==="24h"?(this.renderer.renderTips(be,"tp-ui-hour-time-12","hours",this.disabledTime,this.clockType,!0,this.tipsWrapper,t),this.tipsWrapperFor24h&&this.renderer.renderTips(He,"tp-ui-hour-time-24","hours",this.disabledTime,this.clockType,!0,this.tipsWrapperFor24h,t)):this.renderer.renderTips(be,"tp-ui-hour-time-12","hours",this.disabledTime,this.clockType,!0,void 0,t)}renderMinuteTips(){let e=this.controller.getState(),t=e.amPm,i=e.hour;this.renderer.renderTips(W,"tp-ui-minutes-time","minutes",this.disabledTime,this.clockType,!0,void 0,t,i)}calculateInitialAngle(e,t){let i=parseInt(t,10);return e==="hours"?i%12*30:i*6}destroy(){this.dragHandlers.detach(),this.controller.destroy()}blockInteractions(){this.dragHandlers.block()}unblockInteractions(){this.dragHandlers.unblock()}};var J=class{core;emitter;clockSystem=null;constructor(e,t){this.core=e,this.emitter=t,this.setupEventListeners()}setupEventListeners(){this.emitter.on("select:hour",({hour:e})=>{this.emitter.emit("animation:clock",{}),this.setHoursToClock(e||null)}),this.emitter.on("select:minute",({minutes:e})=>{this.emitter.emit("animation:clock",{}),this.setMinutesToClock(e||null)}),this.emitter.on("select:am",()=>{this.updateAmPm()}),this.emitter.on("select:pm",()=>{this.updateAmPm()}),this.emitter.on("animation:start",()=>{this.clockSystem?.blockInteractions()}),this.emitter.on("animation:end",()=>{this.clockSystem?.unblockInteractions()}),this.emitter.on("range:switch",e=>{this.refreshDisabledTimeForRange(e.disabledTime)})}refreshDisabledTimeForRange(e){if(!this.clockSystem)return;let t=this.convertDisabledTime(),i=t;if(e){let n=[...t?.hours||[],...e.hours||[]],r=[...t?.minutes||[],...e.minutes||[]];i={...t,hours:n.length>0?n:void 0,minutes:r.length>0?r:void 0,rangeFromType:e.fromType,rangeFromHour:e.fromHour}}this.clockSystem.updateDisabledTime(i)}initializeClockSystem(){let e=this.core.getClockFace(),t=this.core.getClockHand(),i=this.core.getCircle();if(!e||!t||!i)return;let n=this.core.options.clock.type==="24h",r=this.core.getTipsWrapper();if(!r)return;let s=this.core.getHour(),o=this.core.getMinutes(),c={clockFace:e,tipsWrapper:r,tipsWrapperFor24h:n&&this.core.getTipsWrapperFor24h()||void 0,clockHand:t,circle:i,clockType:this.core.options.clock.type||"12h",disabledTime:this.convertDisabledTime(),initialHour:s?.value||"12",initialMinute:o?.value||"00",initialAmPm:this.getAmPmValue(),theme:this.core.options.ui.theme,incrementHours:this.core.options.clock.incrementHours||1,incrementMinutes:this.core.options.clock.incrementMinutes||1,smoothHourSnap:this.core.options.clock.smoothHourSnap??!0,timepicker:null,dragConfig:{autoSwitchToMinutes:this.core.options.clock.autoSwitchToMinutes,isMobileView:this.core.isMobileView,smoothHourSnap:this.core.options.clock.smoothHourSnap??!0,hourElement:s,minutesElement:o,onMinuteCommit:()=>{let l=this.core.getMinutes(),u=this.core.getHour(),d=this.core.getActiveTypeMode();this.emitter.emit("range:minute:commit",{hour:u?.value??"12",minutes:l?.value??"00",type:d?.textContent??void 0})}},onHourChange:l=>{let u=this.core.getHour();u&&(u.value=l,u.setAttribute("aria-valuenow",l));let d=this.core.getModalElement();O(d,`Hour: ${l}`);let p=this.core.getMinutes(),g=this.core.getActiveTypeMode();this.emitter.emit("update",{hour:l,minutes:p?.value,type:g?.textContent||void 0})},onMinuteChange:l=>{let u=this.core.getMinutes();u&&(u.value=l,u.setAttribute("aria-valuenow",l));let d=this.core.getModalElement();O(d,`Minutes: ${l}`);let p=this.core.getHour(),g=this.core.getActiveTypeMode();this.emitter.emit("update",{hour:p?.value,minutes:l,type:g?.textContent||void 0})}};this.clockSystem=new X(c),this.clockSystem.initialize()}convertDisabledTime(){let e=this.core.disabledTime?.value;if(!e)return null;let t;return e.intervals&&(t=Array.isArray(e.intervals)?e.intervals:[e.intervals]),{hours:e.hours,minutes:e.minutes,isInterval:e.isInterval,intervals:t,clockType:e.clockType}}getAmPmValue(){if(this.core.options.clock.type==="24h")return"";let e=this.core.getActiveTypeMode();if(e){let n=e.textContent?.trim();if(n==="AM"||n==="PM")return n}let t=this.core.getAM();return this.core.options.range?.enabled===!0?t?.classList.contains("active")?"AM":"":t?.classList.contains("active")?"AM":"PM"}destroyClockSystem(){this.clockSystem&&(this.clockSystem.destroy(),this.clockSystem=null)}removeCircleClockClasses24h(){let e=this.core.getCircle(),t=this.core.getClockHand();e?.classList.remove("tp-ui-circle-hand-24h"),t?.classList.remove("tp-ui-clock-hand-24h")}setCircleClockClasses24h(){let e=this.core.getCircle(),t=this.core.getClockHand();e&&e.classList.add("tp-ui-circle-hand-24h"),t&&t.classList.add("tp-ui-clock-hand-24h")}setOnStartCSSClassesIfClockType24h(){if(this.core.options.clock.type==="24h"){let e=this.core.getInput();if(!e)return;let t;e.value.length>0&&(t=e.value.split(":")[0]),t&&(Number(t)>12||Number(t)===0)&&this.setCircleClockClasses24h()}}setBgColorToCircleWithMinutesTips=()=>{let e=this.core.getMinutes(),t=this.core.getCircle();if(!(!e||!t)&&e.value&&W.includes(e.value)){let i=getComputedStyle(t).getPropertyValue("--timepicker-primary").trim();i&&(t.style.backgroundColor=i),t.classList.remove("small-circle")}};removeBgColorToCirleWithMinutesTips=()=>{let e=this.core.getMinutes(),t=this.core.getCircle();!e||!t||e.value&&W.includes(e.value)||(t.style.backgroundColor="",t.classList.add("small-circle"))};setClassActiveToHourOnOpen=()=>{if(this.core.options.ui.mobile||this.core.isMobileView)return;this.core.getHour()?.classList.add($)};setMinutesToClock=e=>{this.clockSystem&&(this.removeBgColorToCirleWithMinutesTips(),e&&this.clockSystem.setMinute(e),this.clockSystem.switchToMinutes())};setHoursToClock=e=>{this.clockSystem&&(e&&this.clockSystem.setHour(e),this.clockSystem.switchToHours())};setTransformToCircleWithSwitchesHour=e=>{!this.clockSystem||!e||this.clockSystem.setHour(e)};setTransformToCircleWithSwitchesMinutes=e=>{!this.clockSystem||!e||this.clockSystem.setMinute(e)};updateAmPm=()=>{if(!this.clockSystem||this.core.options.clock.type==="24h")return;let e=this.getAmPmValue();e!==""&&this.clockSystem.setAmPm(e)};toggleClassActiveToValueTips=e=>{if(this.clockSystem)return;let t=this.core.getAllValueTips();if(!t)return;let i=t.find(n=>Number(n.innerText)===Number(e));t.forEach(n=>{n.classList.remove($),n.setAttribute("aria-selected","false")}),i!==void 0&&(i.classList.add($),i.setAttribute("aria-selected","true"))};destroy(){this.destroyClockSystem()}};var Me=class{plugins=new Map;register(e){this.plugins.has(e.name)||this.plugins.set(e.name,e)}getAll(){return Array.from(this.plugins.values())}has(e){return this.plugins.has(e)}get(e){return this.plugins.get(e)}},ce=new Me;var ue=class{animation;modal;config;theme;validation;events;clock;plugins=new Map;constructor(e,t){this.animation=new B(e,t),this.modal=new U(e,t),this.config=new K(e,t),this.theme=new Y(e,t),this.validation=new Z(e,t),this.events=new j(e,t),this.clock=new J(e,t),ce.getAll().forEach(n=>{let r=n.factory(e,t);this.plugins.set(n.name,r)})}getPlugin(e){return this.plugins.get(e)}destroy(){this.animation.destroy(),this.modal.destroy(),this.config.destroy(),this.theme.destroy(),this.validation.destroy(),this.events.destroy(),this.clock.destroy(),this.plugins.forEach(e=>e.destroy()),this.plugins.clear()}};var me="is-rippling",de="ripple-hold",F=null;function Ke(a){let e=a.target,t=e.hasAttribute("data-md3-ripple")?e:e.closest("[data-md3-ripple]");if(!t||a.button!==0&&a.pointerType==="mouse")return;let i=t.getBoundingClientRect(),r=Math.max(i.width,i.height)*2,s=a.clientX-i.left,o=a.clientY-i.top;t.style.setProperty("--ripple-size",`${r}px`),t.style.setProperty("--ripple-x",`${s}px`),t.style.setProperty("--ripple-y",`${o}px`),t.classList.remove(me,de),t.offsetWidth,t.classList.add(me,de),t._rippleHold=!0,F=t}function we(a){let e=a.target,i=(e.hasAttribute("data-md3-ripple")?e:e.closest("[data-md3-ripple]"))||F;i&&(i._rippleHold=!1,i.classList.remove(de),setTimeout(()=>{i.classList.remove(me),F===i&&(F=null)},1e3))}function Ye(a){let e=a.currentTarget;!e||!e._rippleHold||(e._rippleHold=!1,e.classList.remove(de),setTimeout(()=>{e.classList.remove(me),F===e&&(F=null)},1e3))}function xe(a){if(f()===!1)return;let e=a||document;e.addEventListener("pointerdown",Ke),e.addEventListener("pointerup",we),e.addEventListener("pointercancel",we),e.querySelectorAll("[data-md3-ripple]").forEach(i=>{i.addEventListener("mouseleave",Ye)})}var Pe=(a,e)=>{let t;return(...i)=>{clearTimeout(t),t=setTimeout(()=>{a(...i)},e)}};var pe=class{core;managers;emitter;eventsClickMobileHandler=()=>{};mutliEventsMoveHandler=()=>{};constructor(e,t,i){this.core=e,this.managers=t,this.emitter=i}init(){if(!this.core.isDestroyed&&!this.core.isInitialized){try{this.managers.config.updateInputValueWithCurrentTimeOnStart(),this.managers.validation.checkDisabledValuesOnStart()}catch{this.core.setIsDestroyed(!0);return}this.managers.theme.setTimepickerClassToElement(),this.managers.theme.setInputClassToInputElement(),this.managers.theme.setDataOpenToInputIfDoesntExistInWrapper(),this.managers.theme.setClassTopOpenElement(),this.managers.config.getDisableTime(),this.core.options.ui.inline?.enabled||this.managers.events.handleOpenOnClick(),this.managers.events.handleOpenOnEnterFocus(),this.setupCallbackBridge(),this.core.setIsInitialized(!0)}}setupCallbackBridge(){let{callbacks:e}=this.core.options;e.onOpen&&this.emitter.on("open",e.onOpen),e.onCancel&&this.emitter.on("cancel",e.onCancel),e.onConfirm&&this.emitter.on("confirm",e.onConfirm),e.onUpdate&&this.emitter.on("update",e.onUpdate),e.onSelectHour&&this.emitter.on("select:hour",e.onSelectHour),e.onSelectMinute&&this.emitter.on("select:minute",e.onSelectMinute),e.onSelectAM&&this.emitter.on("select:am",e.onSelectAM),e.onSelectPM&&this.emitter.on("select:pm",e.onSelectPM),e.onError&&this.emitter.on("error",e.onError),e.onTimezoneChange&&this.emitter.on("timezone:change",e.onTimezoneChange),e.onRangeConfirm&&this.emitter.on("range:confirm",e.onRangeConfirm),e.onRangeSwitch&&this.emitter.on("range:switch",e.onRangeSwitch),e.onRangeValidation&&this.emitter.on("range:validation",e.onRangeValidation)}mount(){this.core.isDestroyed||(this.core.isInitialized||this.init(),this.eventsBundle())}unmount(e){let t=Pe((...i)=>{if(i.length>2||!this.core.getModalElement())return;let[n]=i.filter(o=>typeof o=="boolean"),[r]=i.filter(o=>typeof o=="function");this.core.setIsMobileView(!!this.core.options.ui.mobile),n&&this.core.getOkButton()?.click(),this.core.setIsTouchMouseMove(!1),this.removeEventListeners(),this.managers.animation.removeAnimationToClose(),this.core.getOpenElement().forEach(o=>o?.classList.remove("disabled")),setTimeout(()=>{f()&&(document.body.style.overflowY="",document.body.style.paddingRight="")},C.SCROLLBAR_RESTORE),setTimeout(()=>{let o=this.core.getInput();this.core.options.behavior.focusInputAfterClose&&o?.focus();let c=this.core.getModalElement();c!==null&&(c.remove(),this.core.setIsModalRemove(!0))},C.MODAL_REMOVE),r&&r()},this.core.options.behavior.delayHandler||C.DEFAULT_DELAY);e?t(e):t()}destroy(e){if(this.core.isDestroyed)return;let t=typeof e=="function"?{callback:e}:e||{},{keepInputValue:i=!1,callback:n}=t,r=this.core.getInput(),s=i?r?.value:null;this.removeEventListeners(),this.core.getModalElement()?.remove(),this.core.getOpenElement()?.forEach(d=>{d&&(d.classList.remove("disabled","active","tp-ui-open-element"),d.classList.remove("basic","crane-straight","crane","m2","m3-green"))}),r&&(r.classList.remove("tp-ui-invalid-format","invalid-value","error","active","tp-ui-input"),r.removeAttribute("data-open"),r.removeAttribute("data-owner-id"),i&&s&&(r.value=s));let l=this.core.element;l&&(l.classList.remove("basic","crane-straight","crane","m2","m3-green"),l.classList.remove("error","active","disabled"),l.removeAttribute("data-owner-id"),l.removeAttribute("data-open"),this.core.options.ui.cssClass&&l.classList.remove(this.core.options.ui.cssClass)),l?.querySelectorAll(".tp-ui-invalid-text")?.forEach(d=>d.remove()),this.mutliEventsMoveHandler=()=>{},this.eventsClickMobileHandler=()=>{},this.core.reset(),this.managers.destroy(),this.emitter.clear(),S()||(document.body.style.overflowY="",document.body.style.paddingRight=""),n&&n()}eventsBundle(){if(this.core.isDestroyed||!this.core.isModalRemove)return;if(this.managers.validation.setErrorHandler(),this.managers.validation.removeErrorHandler(),!this.core.options.ui.inline?.enabled){let r=this.core.getOpenElement(),s=this.core.getInput();r.forEach(o=>o?.classList.add("disabled")),s?.blur()}if(this.managers.modal.setScrollbarOrNot(),this.managers.modal.setModalTemplate(),this.managers.modal.setNormalizeClass(),this.managers.modal.removeBackdrop(),this.core.isMobileView)this.managers.config.updateClockFaceAccessibility(!0);else{let r=this.core.getModalElement(),s=r?.querySelector(".tp-ui-mobile-clock-wrapper"),o=r?.querySelector(".tp-ui-wrapper"),c=r?.querySelectorAll("*");s?.classList.add("expanded"),o?.classList.add("expanded"),c?.forEach(l=>{!l.classList.contains("tp-ui-select-time")&&!l.classList.contains("tp-ui-mobile-clock-wrapper")&&!l.classList.contains("tp-ui-wrapper")&&l.classList.add("expanded")})}this.managers.modal.setFlexEndToFooterIfNoKeyboardIcon(),setTimeout(()=>{this.managers.theme.setTheme();let r=this.core.getWrapper();r&&this.core.options.ui.cssClass&&r.classList.add(this.core.options.ui.cssClass)},0),this.managers.animation.setAnimationToOpen(),this.managers.config.getInputValueOnOpenAndSet(),this.managers.clock.initializeClockSystem(),this.managers.clock.setOnStartCSSClassesIfClockType24h(),this.managers.clock.setClassActiveToHourOnOpen();let e=this.managers.getPlugin("timezone");e&&e.init();let t=this.managers.getPlugin("range");t&&t.init(),this.managers.events.handleCancelButton(),this.managers.events.handleOkButton(),this.managers.events.handleHourEvents(),this.managers.events.handleMinutesEvents(),this.managers.events.handleKeyboardInput(),this.core.options.ui.enableSwitchIcon&&this.managers.events.handleSwitchViewButton(),this.core.options.clock.type!=="24h"&&(this.managers.events.handleAmClick(),this.managers.events.handlePmClick()),this.core.options.behavior.focusTrap&&this.managers.events.focusTrapHandler(),this.core.options.ui.inline?.enabled||(this.managers.events.handleEscClick(),this.managers.events.handleBackdropClick());let i=this.core.getModalElement();i&&xe(i);let n=this.core.getClockFace();n&&typeof requestAnimationFrame<"u"&&requestAnimationFrame(()=>{requestAnimationFrame(()=>{n?.classList.add("scale-in")})}),this.managers.modal.setShowClassToBackdrop()}removeEventListeners(){if(f()===!1)return;Ie.split(" ").forEach(t=>{document.removeEventListener(t,this.mutliEventsMoveHandler,!1)}),document.removeEventListener("mousedown",this.eventsClickMobileHandler)}};var q=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=n=>{t(n),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=>{i(t)})}clear(){this.events.clear()}hasListeners(e){return(this.events.get(e)?.size??0)>0}};var R={clock:{type:"12h",incrementHours:1,incrementMinutes:1,autoSwitchToMinutes:!0,disabledTime:void 0,currentTime:void 0},ui:{theme:"basic",animation:!0,backdrop:!0,mobile:!1,enableSwitchIcon:!1,editable:!1,enableScrollbar:!1,cssClass:void 0,appendModalSelector:"",iconTemplate:"",iconTemplateMobile:"",inline:void 0},labels:{am:"AM",pm:"PM",ok:"OK",cancel:"Cancel",time:"Select time",mobileTime:"Enter Time",mobileHour:"Hour",mobileMinute:"Minute"},behavior:{focusInputAfterClose:!1,focusTrap:!0,delayHandler:300,id:void 0},callbacks:{onOpen:void 0,onCancel:void 0,onConfirm:void 0,onUpdate:void 0,onSelectHour:void 0,onSelectMinute:void 0,onSelectAM:void 0,onSelectPM:void 0,onError:void 0,onTimezoneChange:void 0,onRangeConfirm:void 0,onRangeSwitch:void 0,onRangeValidation:void 0},timezone:{enabled:!1,default:void 0,whitelist:void 0,label:"Timezone"},range:{enabled:!1,minDuration:void 0,maxDuration:void 0,fromLabel:"From",toLabel:"To"}};function ke(a={}){return{clock:{...R.clock,...a.clock||{}},ui:{...R.ui,...a.ui||{}},labels:{...R.labels,...a.labels||{}},behavior:{...R.behavior,...a.behavior||{}},callbacks:{...R.callbacks,...a.callbacks||{}},timezone:{...R.timezone,...a.timezone||{}},range:{...R.range,...a.range||{}}}}var Oe=a=>a.replace(/[^0-9:APMapm\s]/g,"");var z=new Map,Q=class{core;managers;lifecycle;emitter;constructor(e,t){if(S())throw new Error("TimepickerUI requires browser environment");let i=this.resolveInputElement(e);if(!i)throw new Error("Input element not found");let n=t?.behavior?.id,r=n||`tp-ui-${Ae()}`,s=this.createWrapperElement(i),o=ke(t||{});if(o.ui.inline?.enabled&&typeof t?.behavior?.focusTrap>"u"&&(o.behavior.focusTrap=!1),o.ui.inline?.enabled){if(!o.ui.inline.containerId)throw new Error("inline.containerId is required when inline mode is enabled");if(!S()&&!document.getElementById(o.ui.inline.containerId))throw new Error(`Container element with id "${o.ui.inline.containerId}" not found`)}this.emitter=new q,this.core=new ee(s,o,r,n);let c=this.core.getInput();if(c){let l=D(c,o.clock.type),u=Number(l.hour)*30,d=Number(l.minutes)*6;this.core.setDegreesHours(u),this.core.setDegreesMinutes(d)}this.managers=new ue(this.core,this.emitter),this.lifecycle=new pe(this.core,this.managers,this.emitter),this.managers.config.checkMobileOption(),this.managers.config.preventClockTypeByCurrentTime(),this.setupInternalEventListeners(),z.set(this.core.instanceId,this)}setupInternalEventListeners(){this.emitter.on("show",()=>{this.core.isDestroyed||this.lifecycle.mount()}),this.emitter.on("cancel",()=>{this.core.isDestroyed||this.lifecycle.unmount()}),this.emitter.on("confirm",e=>{if(!this.core.isDestroyed){if(this.core.options.range?.enabled)return;let t=this.core.getInput();if(t&&e.hour&&e.minutes){let i=e.type?` ${e.type}`:"";t.value=`${e.hour}:${e.minutes}${i}`}this.lifecycle.unmount()}}),this.emitter.on("range:confirm",e=>{if(this.core.isDestroyed)return;let t=this.core.getInput();t&&(t.value=`${e.from} - ${e.to}`),this.lifecycle.unmount()})}create(){this.lifecycle.init(),this.core.options.ui.inline?.enabled&&this.lifecycle.mount()}open(e){this.lifecycle.mount(),e&&e()}close(e,t){this.lifecycle.unmount(e?t:void 0),!e&&t&&t()}destroy(e){z.delete(this.core.instanceId),this.lifecycle.destroy(e)}update(e,t){this.core.isDestroyed||(this.core.updateOptions(e.options),this.managers.config.checkMobileOption(),e.create&&this.create(),t&&t())}getValue(){if(this.core.isDestroyed)return{hour:"",minutes:"",type:void 0,time:"",degreesHours:null,degreesMinutes:null};let e=this.core.getHour(),t=this.core.getMinutes(),i=this.core.getActiveTypeMode(),n=e?.value||"12",r=t?.value||"00",s=this.core.options.clock.type==="24h"?void 0:i?.textContent||"AM",o="";return this.core.options.clock.type==="24h"?o=`${n.padStart(2,"0")}:${r.padStart(2,"0")}`:o=`${n}:${r.padStart(2,"0")} ${s}`,{hour:n,minutes:r,type:s,time:o,degreesHours:this.core.degreesHours,degreesMinutes:this.core.degreesMinutes}}setValue(e,t=!0){if(this.core.isDestroyed||!e||typeof e!="string")return;this.core.isInitialized||this.create();let i=Oe(e.trim()),n="12",r="00",s="AM";try{if(this.core.options.clock.type==="24h"){let p=i.match(/^([0-1]?[0-9]|2[0-3]):([0-5][0-9])$/);if(!p)throw new Error("Invalid 24h format. Expected HH:MM");n=p[1].padStart(2,"0"),r=p[2]}else{let p=i.match(/^(1[0-2]|[1-9]):([0-5][0-9])\s*(AM|PM)$/i);if(!p)throw new Error("Invalid 12h format. Expected HH:MM AM/PM");n=p[1],r=p[2],s=p[3].toUpperCase()}let o=this.core.getHour(),c=this.core.getMinutes(),l=this.core.getAM(),u=this.core.getPM();if(o&&(o.value=n,o.setAttribute("aria-valuenow",n),this.core.setDegreesHours(Number(n)*30)),c&&(c.value=r,c.setAttribute("aria-valuenow",r),this.core.setDegreesMinutes(Number(r)*6)),this.core.options.clock.type!=="24h"&&l&&u&&(s==="AM"?(l.classList.add("active"),u.classList.remove("active")):(u.classList.add("active"),l.classList.remove("active"))),t){let p=this.core.getInput();p&&(p.value=i)}let d=this.core.getClockHand();d&&(d.style.transform=`rotateZ(${this.core.degreesHours||0}deg)`)}catch{return}}getElement(){return this.core.element}get instanceId(){return this.core.instanceId}get options(){return this.core.options}get isInitialized(){return this.core.isInitialized}get isDestroyed(){return this.core.isDestroyed}get hour(){return this.core.getHour()}get minutes(){return this.core.getMinutes()}get okButton(){return this.core.getOkButton()}get cancelButton(){return this.core.getCancelButton()}get clockHand(){return this.core.getClockHand()}on(e,t){this.core.isDestroyed||this.emitter.on(e,t)}once(e,t){this.core.isDestroyed||this.emitter.once(e,t)}off(e,t){this.core.isDestroyed||this.emitter.off(e,t)}resolveInputElement(e){if(f()===!1)return null;let t=null;if(typeof e=="string"){if(t=document.querySelector(e),!t)return null}else if(e instanceof HTMLElement)t=e;else return null;return t.tagName==="INPUT"?t:t.querySelector("input")}createWrapperElement(e){if(f()===!1)return e;let t=e.parentElement;if(e.tagName==="INPUT"&&!t?.classList.contains("tp-ui")){let i=document.createElement("div");return i.className="tp-ui",e.parentNode?.insertBefore(i,e),i.appendChild(e),i}return t&&!t.classList.contains("tp-ui")&&t.classList.add("tp-ui"),t||e}static getById(e){return z.get(e)}static getAllInstances(){return Array.from(z.values())}static isAvailable(e){return S()?!1:typeof e=="string"?document.querySelector(e)!==null:e instanceof HTMLElement?document.contains(e):!1}static destroyAll(){Array.from(z.values()).forEach(t=>t.destroy()),z.clear()}};var he=Q;var Ze=he;0&&(module.exports={EventEmitter,PluginRegistry,TimepickerUI});
8
+ </div>`:"",Ge=y?`<div class="tp-ui-range-header" role="tablist" aria-label="Range selection"><button type="button" class="tp-ui-range-tab tp-ui-range-from active" role="tab" tabindex="0" aria-selected="true"><span class="tp-ui-range-tab-label">${M}</span><span class="tp-ui-range-tab-value tp-ui-range-from-time">--:--</span></button><button type="button" class="tp-ui-range-tab tp-ui-range-to" role="tab" tabindex="-1" aria-selected="false"><span class="tp-ui-range-tab-label">${v}</span><span class="tp-ui-range-tab-value tp-ui-range-to-time">--:--</span></button></div>`:"";return`<div class="tp-ui-modal normalize ${m}${y?" tp-ui-range-mode":""}" data-theme="${r}" role="dialog" aria-modal="true" aria-labelledby="tp-ui-label-${e}" data-owner-id="${e}" style='transition:${n?"opacity 0.15s linear":"none"}'><div class="tp-ui-wrapper ${m}" tabindex="0">${Ge}<div class="tp-ui-select-time ${m}" id="tp-ui-label-${e}">${m?u:l}</div><div class="tp-ui-header ${m}"><div class="tp-ui-wrapper-time ${m} ${k==="24h"?"tp-ui-wrapper-time-24h":""}" role="group" aria-label="${m?u:l}"><div class="tp-ui-input-wrapper ${m}"><div class="tp-ui-input-ripple-wrapper ${m}" data-md3-ripple><input name="hour" ${!o&&!m?"readonly":""} class="tp-ui-hour ${m}" tabindex="0" type="number" min="0" max="${k==="12h"?"12":"23"}" aria-label="${m?T:"Hour"}" role="spinbutton" aria-valuenow="12"></div><div class="tp-ui-hour-text ${m}">${T}</div></div><div class="tp-ui-dots ${m}" aria-hidden="true"><span></span><span></span></div><div class="tp-ui-input-wrapper ${m}"><div class="tp-ui-input-ripple-wrapper ${m}" data-md3-ripple><input name="minutes" ${!o&&!m?"readonly":""} class="tp-ui-minutes ${m}" tabindex="0" type="number" min="0" max="59" aria-label="${m?H:"Minute"}" role="spinbutton" aria-valuenow="0"></div><div class="tp-ui-minute-text ${m}">${H}</div></div></div>${k!=="24h"?`<div class="tp-ui-wrapper-type-time ${m}" role="group" aria-label="Period"><div class="tp-ui-type-mode tp-ui-am ${m?"mobile":"tp-ui-ripple"}" data-md3-ripple tabindex="0" role="button" aria-label="${d}" aria-pressed="false" data-type="AM">${d}</div><div class="tp-ui-type-mode tp-ui-pm ${m?"mobile":"tp-ui-ripple"}" data-md3-ripple tabindex="0" role="button" aria-label="${p}" aria-pressed="false" data-type="PM">${p}</div></div>`:""}</div>${P}<div class="tp-ui-mobile-clock-wrapper ${m}"><div class="tp-ui-body ${m}"><div class="tp-ui-clock-face ${m}" role="group" aria-label="Clock"><div class="tp-ui-dot ${m}" aria-hidden="true"></div><div class="tp-ui-clock-hand ${m}" aria-hidden="true"><div class="tp-ui-circle-hand ${m}"></div></div><div class="tp-ui-tips-wrapper ${m}" role="listbox" aria-label="Time"></div>${k==="24h"?`<div class="tp-ui-tips-wrapper-24h ${m}" role="listbox" aria-label="24h"></div>`:""}</div></div></div><div class="tp-ui-footer ${m}" ${m?'data-view="mobile"':""}>${i?`<div class="tp-ui-keyboard-icon-wrapper ${m}" tabindex="0" role="button" aria-pressed="false" aria-label="Toggle" data-view="desktop">${m?A:S}</div>`:""}<div class="tp-ui-wrapper-btn ${m}"><div class="tp-ui-cancel-btn ${m}" data-md3-ripple tabindex="0" role="button" aria-pressed="false" aria-label="${g}">${g}</div><div class="tp-ui-ok-btn ${m}" data-md3-ripple tabindex="0" role="button" aria-pressed="false" aria-label="${b}">${b}</div></div></div></div><div class="timepicker-announcer sr-only" role="status" aria-live="polite" aria-atomic="true"></div></div>`};var U=class{core;emitter;timeouts=[];originalOverflow;originalPaddingRight;constructor(e,t){this.core=e,this.emitter=t}runWithTimeout(e,t=C.DEFAULT_DELAY){let i=setTimeout(e,t);this.timeouts.push(i)}clearAllTimeouts(){this.timeouts.forEach(clearTimeout),this.timeouts=[]}clearExistingModal(){if(f()===!1)return;let e=document.querySelector(".tp-ui-modal");e&&e.remove()}setModalTemplate(){if(f()===!1)return;this.clearExistingModal();let e=Fe(this.core.options,this.core.instanceId);if(this.core.options.ui.inline?.enabled){let i=document.getElementById(this.core.options.ui.inline.containerId);if(!i)return;i.innerHTML="",i.insertAdjacentHTML("beforeend",e);let n=i.querySelector(".tp-ui-modal");if(n){n.classList.add("tp-ui--inline");let{showButtons:r}=this.core.options.ui.inline;(r===!1||r===void 0)&&n.querySelectorAll(".tp-ui-wrapper-btn, .tp-ui-wrapper-btn.mobile").forEach(s=>s.style.display="none")}return}let{appendModalSelector:t}=this.core.options.ui;t?document.querySelector(t)?.insertAdjacentHTML("beforeend",e):document.body.insertAdjacentHTML("beforeend",e)}setScrollbarOrNot(){f()!==!1&&(this.core.options.ui.inline?.enabled||(this.core.options.ui.enableScrollbar?this.runWithTimeout(()=>{L()||this.runWithTimeout(()=>{typeof document<"u"&&(document.body.style.overflowY=this.originalOverflow||"",document.body.style.paddingRight=this.originalPaddingRight||"")},C.SCROLLBAR_RESTORE)},400):(this.originalOverflow=document.body.style.overflowY,this.originalPaddingRight=document.body.style.paddingRight,document.body.style.paddingRight=`${Re()}px`,document.body.style.overflowY="hidden")))}removeBackdrop(){if(this.core.options.ui.inline?.enabled||this.core.options.ui.backdrop)return;let e=this.core.getModalElement(),t=this.core.getOpenElement();e?.classList.add("removed"),t.forEach(i=>i?.classList.add("disabled"))}setNormalizeClass(){let e=this.core.getModalElement();if(!e)return;e.classList.add("tp-ui-normalize"),e.querySelectorAll(":scope > div").forEach(i=>i.classList.add("tp-ui-normalize"))}setShowClassToBackdrop(){if(this.core.options.ui.inline?.enabled){this.core.getModalElement()?.classList.add("show"),this.setInitialFocus();return}this.core.options.ui.backdrop&&this.runWithTimeout(()=>{this.core.getModalElement()?.classList.add("show"),this.setInitialFocus()},C.MODAL_ANIMATION)}setInitialFocus(){if(!this.core.options.behavior.focusTrap)return;let e=this.core.getWrapper();e&&typeof requestAnimationFrame<"u"&&requestAnimationFrame(()=>{e.focus()})}setFlexEndToFooterIfNoKeyboardIcon(){let e=this.core.getFooter();!this.core.options.ui.enableSwitchIcon&&e&&(e.style.justifyContent="flex-end")}destroy(){this.clearAllTimeouts(),!L()&&!this.core.options.ui.inline?.enabled&&(document.body.style.overflowY=this.originalOverflow||"",document.body.style.paddingRight=this.originalPaddingRight||""),this.clearExistingModal()}};var I=(a,e,t,i)=>{let n={hour:"12",minutes:"00",type:e==="24h"?void 0:"PM"};if(!a)return n;let r=a.value.trim();if(!t&&!r)return n;if(typeof t=="boolean"&&t){let H=new Date,[T,k]=H.toLocaleTimeString().split(":"),h=T.padStart(2,"0");if(/[a-z]/i.test(k)&&e==="12h"){let[E,y]=k.split(" ");return{hour:h,minutes:E,type:y}}return{hour:h,minutes:k,type:void 0}}if(typeof t=="object"){let{time:H,locales:T,preventClockType:k}=t,h=H??new Date;if(k&&i){let[v,m]=new Date(h).toLocaleTimeString().split(":");if(/[a-z]/i.test(m)){let[S,A]=m.split(" ");return{hour:v,minutes:S,type:A}}return{hour:v.padStart(2,"0"),minutes:m,type:void 0}}let E=new Date(h).toLocaleTimeString(T||"en-US",{hour:"2-digit",minute:"2-digit",hour12:e==="12h"}),[y,M]=E.split(":");if(e==="12h"&&/[a-z]/i.test(M)){let v=M.trim().split(" "),m=v[0],S=v[1]||"AM";return{hour:y,minutes:m,type:S}}return{hour:y,minutes:M.replace(/\D/g,""),type:void 0}}let[s,o]=r.split(" "),[c="",l=""]=s.split(":"),u=c.replace(/\D/g,""),d=l.replace(/\D/g,""),p={hour:u.padStart(2,"0"),minutes:d.padStart(2,"0"),type:e==="12h"?o:void 0};if(u.length>2||d.length>2)return{...p,error:"Invalid input: too many digits.",currentHour:c,currentMin:l};if(/[a-z]/i.test(s))return{...p,error:"Input contains invalid letters."};if(r.includes(" ")&&(!o||r.length>8||o!=="AM"&&o!=="PM"))return{...p,error:"Invalid AM/PM format or length.",currentLength:r.length,currentType:o};let g=Number(u),b=Number(d);if(e==="12h"){if(g<1||g>12||b<0||b>59||o!=="AM"&&o!=="PM")return{...p,error:"Invalid 12h time.",currentHour:g,currentMin:b,currentType:o}}else if(g<0||g>23||b<0||b>59)return{...p,error:"Invalid 24h time.",currentHour:g,currentMin:b};return p},we=(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 De="tp-ui",rt="mousedown mouseup mousemove mouseleave mouseover",st="touchstart touchmove touchend",qe=`${rt} ${st}`,N="active";var le=class{core;emitter;constructor(e,t){this.core=e,this.emitter=t}isCurrentTimeEnabled(e){let t=this.core.options.clock.currentTime;return typeof t=="boolean"?t:!!t?.[e]}preventClockTypeByCurrentTime(){if(!this.isCurrentTimeEnabled("preventClockType"))return;let e=this.core.getInput();if(!e)return;let{currentTime:t,clockType:i}={currentTime:this.core.options.clock.currentTime,clockType:this.core.options.clock.type},{type:n}=I(e,i,t,!0);this.core.updateOptions({clock:{type:n?"12h":"24h"}})}updateInputValueWithCurrentTimeOnStart(){if(!this.isCurrentTimeEnabled("updateInput"))return;let e=this.core.getInput();if(!e)return;let{hour:t,minutes:i,type:n}=I(e,this.core.options.clock.type,this.core.options.clock.currentTime);e.value=n?`${t}:${i} ${n}`:`${t}:${i}`}getInputValueOnOpenAndSet(){let e=this.core.getInput();if(!e)return;let t=I(e,this.core.options.clock.type,this.core.options.clock.currentTime),i=this.core.getHour(),n=this.core.getMinutes(),r=this.core.getActiveTypeMode(),s=this.core.getAM();if(t===void 0){i&&(i.value="12"),n&&(n.value="00");let g={hour:i?.value||"12",minutes:n?.value||"00",type:r?.dataset.type,degreesHours:this.core.degreesHours,degreesMinutes:this.core.degreesMinutes};this.emitter.emit("open",g);let b=this.core.options.range?.enabled===!0;this.core.options.clock.type!=="24h"&&s&&!b&&s.classList.add(N);return}let[o,c,l]=e.value.split(":").join(" ").split(" ");e.value.length===0&&(o=t.hour,c=t.minutes,l=t.type),i&&(i.value=o.padStart(2,"0")),n&&(n.value=c.padStart(2,"0"));let d=this.core.getModalElement()?.querySelector(`[data-type='${l}']`);this.core.options.clock.type!=="24h"&&d&&d.classList.add(N);let p={...t,type:r?.dataset.type,degreesHours:this.core.degreesHours,degreesMinutes:this.core.degreesMinutes};this.emitter.emit("open",p)}getInputValue(e,t,i){return I(e,t,i)}destroy(){}};var ce=class{core;emitter;isAnimating=!1;constructor(e,t){this.core=e,this.emitter=t,this.setupEventListeners()}setupEventListeners(){this.emitter.on("switch:view",()=>{this.toggleMobileClockFace()})}checkMobileOption(){this.core.setIsMobileView(!!this.core.options.ui.mobile),this.core.options.ui.mobile&&this.core.updateOptions({ui:{editable:!0}})}toggleMobileClockFace(){if(this.isAnimating)return;let e=this.core.getModalElement();if(!e)return;let t=e.querySelector(".tp-ui-wrapper"),i=this.core.getKeyboardClockIcon(),n=e.querySelector(".tp-ui-mobile-clock-wrapper"),r=e.querySelectorAll("*"),s=e.querySelector(".tp-ui-select-time"),o=this.core.getHour(),c=this.core.getMinutes(),l=this.core.getClockFace();if(!t)return;let u=t.classList.contains("expanded"),d=this.core.isMobileView;u?this.collapseClockFace(t,n,r,i,s,o,c,l,d):this.expandClockFace(t,n,r,i,s,o,c,l)}collapseClockFace(e,t,i,n,r,s,o,c,l){this.isAnimating=!0,this.switchView(r,n,s,o,!0),i.forEach(u=>{u!==t&&u!==e&&u!==r&&(u.classList.remove("expanded"),l&&u.classList.add("mobile"))}),r&&(r.classList.remove("expanded"),l&&r.classList.add("mobile")),typeof requestAnimationFrame<"u"?requestAnimationFrame(()=>{t?.classList.remove("expanded"),l&&t?.classList.add("mobile"),e?.classList.remove("expanded"),l&&e?.classList.add("mobile"),l?c?.classList.remove("scale-in"):c?.classList.add("scale-in"),setTimeout(()=>{this.isAnimating=!1},C.MOBILE_TOGGLE)}):this.isAnimating=!1,n?.setAttribute("aria-label","Show clock face"),n?.setAttribute("aria-pressed","false")}expandClockFace(e,t,i,n,r,s,o,c){this.isAnimating=!0,o?.classList.contains("active")&&o?this.emitter.emit("select:minute",{minutes:o.value}):s&&this.emitter.emit("select:hour",{hour:s.value}),i.forEach(u=>{u!==t&&u!==e&&u!==r&&(u.classList.remove("mobile"),u.classList.add("expanded"))}),r&&(r.classList.remove("mobile"),r.classList.add("expanded")),this.switchView(r,n,s,o,!1),typeof requestAnimationFrame<"u"?requestAnimationFrame(()=>{e.classList.remove("mobile"),e.classList.add("expanded"),requestAnimationFrame(()=>{t&&(t.classList.remove("mobile"),t.classList.add("expanded")),c&&c.classList.remove("scale-in"),setTimeout(()=>{c&&c.classList.add("scale-in")},C.CLOCK_SCALE_DELAY),setTimeout(()=>{this.isAnimating=!1},C.MOBILE_TOGGLE)})}):this.isAnimating=!1,n?.setAttribute("aria-label","Hide clock face"),n?.setAttribute("aria-pressed","true")}switchView(e,t,i,n,r){let s=this.core.getModalElement(),o=s?.querySelector(".tp-ui-hour-text"),c=s?.querySelector(".tp-ui-minute-text"),l=t?.querySelector(".tp-ui-keyboard-icon"),u=this.core.getInputWrappers(),d=this.core.getHeader(),{iconTemplate:p,iconTemplateMobile:g}=this.core.options.ui,{time:b,mobileTime:H}=this.core.options.labels;r?(e?.classList.add("mobile"),t?.classList.add("mobile"),i?.classList.add("mobile"),n?.classList.add("mobile"),o?.classList.add("mobile"),c?.classList.add("mobile"),d?.classList.add("mobile"),u?.forEach(T=>{T.classList.add("mobile")}),e&&H&&(e.textContent=H),l&&(l.innerHTML=g||ae),this.updateClockFaceAccessibility(!0)):(e?.classList.remove("mobile"),t?.classList.remove("mobile"),i?.classList.remove("mobile"),n?.classList.remove("mobile"),o?.classList.remove("mobile"),c?.classList.remove("mobile"),d?.classList.remove("mobile"),u?.forEach(T=>{T.classList.remove("mobile")}),e&&b&&(e.textContent=b),l&&(l.innerHTML=p||oe),this.updateClockFaceAccessibility(!1))}updateClockFaceAccessibility(e){let t=this.core.getClockFace();if(!t)return;let i=t.querySelector(".tp-ui-tips-wrapper"),n=t.querySelector(".tp-ui-tips-wrapper-24h"),r=t.querySelectorAll(".tp-ui-tip");e?(t.setAttribute("aria-hidden","true"),i?.setAttribute("aria-hidden","true"),n?.setAttribute("aria-hidden","true"),r.forEach(s=>{s.setAttribute("tabindex","-1"),s.setAttribute("aria-hidden","true")})):(t.removeAttribute("aria-hidden"),i?.removeAttribute("aria-hidden"),n?.removeAttribute("aria-hidden"),r.forEach(s=>{s.setAttribute("tabindex","0"),s.removeAttribute("aria-hidden")}))}destroy(){}};var ze=a=>{if(!a)return;let{disabledTime:e,type:t}=a.clock;if(!e||!Object.keys(e).length)return;let{hours:i,minutes:n,interval:r}=e;if(r){delete e.hours,delete e.minutes;let s=Array.isArray(r)?r:[r];if(!t)throw new Error("clockType required for interval");return se(s,t),{value:s.map(l=>{let[u,d]=l.trim().split("-"),{hour:p,minutes:g,type:b}=I({value:u.trim()},t),{hour:H,minutes:T,type:k}=I({value:d.trim()},t),h=W(p,H).map(v=>Number(v)===0?"00":String(Number(v))),E=[],y=Number(g),M=Number(T);if(k===b)return y>0&&M<=0?(E.push(h[0],h[h.length-1]),h=h.slice(1,-1)):M<59&&M>0&&y<=0?(E.push(void 0,h[h.length-1]),h=h.slice(0,-1)):M>0&&y>0?(E.push(h[0],h[h.length-1]),h=h.slice(1,-1)):M===0&&y===0&&(E.push(void 0,h[h.length-1]),h.pop()),{removedStartedHour:E[0]!==void 0&&Number(E[0])<=9?`0${E[0]}`:E[0],removedEndHour:E[1]!==void 0&&Number(E[1])<=9?`0${E[1]}`:E[1],rangeArrHour:h,startMinutes:W(g,59).map(v=>Number(v)<=9?`0${v}`:`${v}`),endMinutes:re(0,T).map(v=>Number(v)<=9?`0${v}`:`${v}`),startType:b,endType:k};{let v=W(p,12).map(String),m=re(1,H).map(String),S=[],A=[];return y>0&&M<=0?(A.push(m[m.length-1]),S.push(v[0]),m.pop(),v.shift()):M<59&&M>0&&y<=0?(S.push(v[0]),A.push(m[m.length-1]),m.pop()):M>0&&y>0?(A.push(m[m.length-1]),S.push(v[0]),m.pop(),v.shift()):M===0&&y===0&&(A.push(m[m.length-1]),S.push(v[0]),m.pop()),{startType:b,endType:k,amHours:v,pmHours:m,removedAmHour:S[0]&&Number(S[0])<=9?`0${S[0]}`:S[0],removedPmHour:A[0]&&Number(A[0])<=9?`0${A[0]}`:A[0],startMinutes:Number(g)===0?[]:W(g,59).map(P=>Number(P)<=9?`0${P}`:`${P}`),endMinutes:re(0,T).map(P=>Number(P)<=9?`0${P}`:`${P}`)}}}).reduce((l,u)=>(Object.entries(u).forEach(([d,p])=>{Array.isArray(p)?l[d]=Array.isArray(l[d])?[...l[d],...p]:[...p]:l[d]=p}),l),{isInterval:!0,clockType:t,intervals:s})}}return i?.forEach(s=>{if(t==="12h"&&Number(s)>12)throw new Error("The disabled hours value has to be less than 13");if(t==="24h"&&Number(s)>23)throw new Error("The disabled hours value has to be less than 24")}),n?.forEach(s=>{if(Number(s)>59)throw new Error("The disabled minutes value has to be less than 60")}),{value:{hours:i?.map(s=>s==="00"||Number(s)===0?`0${Number(s)}`:`${Number(s)}`),minutes:n?.map(s=>Number(s)<=9?`0${s}`:`${s}`)}}},xe=(a,e,t,i)=>{if(a){if(Array.isArray(a)&&a.length>0)return!a.map(r=>we(r,e,t)).some(r=>r===!1);if(typeof a=="string"||typeof a=="number"){let n=we(a,e,t),r=i?.map(Number).includes(Number(a));return!!(n&&!r)}}};var ue=class{core;constructor(e){this.core=e}getDisableTime(){let e=ze(this.core.options);this.core.setDisabledTime(e||null)}destroy(){}};var K=class{inputValueHandler;mobileViewHandler;disabledTimeHandler;core;constructor(e,t){this.core=e,this.inputValueHandler=new le(e,t),this.mobileViewHandler=new ce(e,t),this.disabledTimeHandler=new ue(e)}preventClockTypeByCurrentTime(){this.inputValueHandler.preventClockTypeByCurrentTime()}updateInputValueWithCurrentTimeOnStart(){this.inputValueHandler.updateInputValueWithCurrentTimeOnStart()}getInputValueOnOpenAndSet(){this.inputValueHandler.getInputValueOnOpenAndSet()}getInputValue(e,t,i){return this.inputValueHandler.getInputValue(e,t,i)}checkMobileOption(){this.mobileViewHandler.checkMobileOption()}toggleMobileClockFace(){this.mobileViewHandler.toggleMobileClockFace()}updateClockFaceAccessibility(e){this.mobileViewHandler.updateClockFaceAccessibility(e)}getDisableTime(){this.disabledTimeHandler.getDisableTime()}destroy(){this.inputValueHandler.destroy(),this.mobileViewHandler.destroy(),this.disabledTimeHandler.destroy()}};var Y=class{core;emitter;constructor(e,t){this.core=e,this.emitter=t}setTheme(){let e=this.core.getModalElement();if(!e)return;let{theme:t}=this.core.options.ui;t&&e.setAttribute("data-theme",t)}setInputClassToInputElement(){let e=this.core.getInput();e&&(Ne(e,"tp-ui-input")||e.classList.add("tp-ui-input"))}setDataOpenToInputIfDoesntExistInWrapper(){let e=this.core.getOpenElementData(),t=this.core.getInput();e===null&&t&&t.setAttribute("data-open","tp-ui-input")}setClassTopOpenElement(){let e=this.core.getOpenElement();for(let t of e)t&&t.classList.add("tp-ui-open-element")}setTimepickerClassToElement(){let e=this.core.element;if(!e)return;e.classList.add(De);let t=this.core.options.ui.cssClass;t&&t!==De&&e.classList.add(t)}destroy(){let e=this.core.getModalElement();e&&e.removeAttribute("data-theme")}};var V=class a extends Error{constructor(t,i){super(`[TimepickerUI] ${t}`);this.code=i;this.name="TimepickerError",Object.setPrototypeOf(this,a.prototype)}},me={ELEMENT_NOT_FOUND:"ELEMENT_NOT_FOUND",INVALID_PARAMETER:"INVALID_PARAMETER",NO_INPUT_ELEMENT:"NO_INPUT_ELEMENT",INSTANCE_DESTROYED:"INSTANCE_DESTROYED",NOT_INITIALIZED:"NOT_INITIALIZED",INVALID_TIME_FORMAT:"INVALID_TIME_FORMAT",INLINE_CONFIG_ERROR:"INLINE_CONFIG_ERROR",CONTAINER_NOT_FOUND:"CONTAINER_NOT_FOUND",SSR_ENVIRONMENT:"SSR_ENVIRONMENT"};var Z=class{core;emitter;constructor(e,t){this.core=e,this.emitter=t}setErrorHandler(){let e=this.core.getInput();if(!e)return!0;let{error:t,currentHour:i,currentMin:n,currentType:r,currentLength:s}=I(e,this.core.options.clock.type);if(this.removeErrorHandler(),t){if(f()===!1)return!1;let o=document.createElement("div");o.classList.add("tp-ui-invalid-text"),o.innerHTML="<b>Invalid Time Format</b>",e.classList.add("tp-ui-invalid-format"),e.nextElementSibling?.classList.contains("tp-ui-invalid-text")||e.after(o);let c={error:t,rejectedHour:void 0,rejectedMinute:void 0,inputHour:i,inputMinute:n,inputType:r,inputLength:s};return this.emitter.emit("error",c),!1}return!0}removeErrorHandler(){let e=this.core.getInput();if(!e)return;e.classList.remove("tp-ui-invalid-format");let t=e.nextElementSibling;t?.classList.contains("tp-ui-invalid-text")&&t.remove()}checkDisabledValuesOnStart(){if(!this.core.options.clock.disabledTime)return;let{disabledTime:e,type:t}=this.core.options.clock;if(e.interval){if(!t)throw new V("clockType is required when using disabledTime.interval",me.INVALID_PARAMETER);let o=Array.isArray(e.interval)?e.interval:[e.interval];try{se(o,t)}catch(c){throw new V(`Invalid disabledTime.interval: ${c.message}`,me.INVALID_PARAMETER)}return}let{hours:i,minutes:n}=e,r=i?xe(i,"hour",t):!0,s=n?xe(n,"minutes",t):!0;if(!r||!s)throw new V("Invalid hours or minutes in disabledTime option",me.INVALID_PARAMETER)}destroy(){this.removeErrorHandler()}};var O=(a,e)=>{if(!a)return;let t=a.querySelector(".timepicker-announcer");t&&(t.textContent="",setTimeout(()=>{t.textContent=e},100))},G=(a,e)=>{a&&a.setAttribute("aria-pressed",String(e))};var de=class{core;emitter;cleanupHandlers=[];constructor(e,t){this.core=e,this.emitter=t}handleOpenOnClick(){let e=this.core.getOpenElement();if(!e)return;let t=()=>{this.core.isDestroyed||this.emitter.emit("show",{})};e.forEach(i=>{i.addEventListener("click",t),this.cleanupHandlers.push(()=>i.removeEventListener("click",t))})}handleCancelButton(){let e=this.core.getCancelButton();if(!e)return;let t=()=>{this.core.isDestroyed||this.emitter.emit("cancel",{})};e.addEventListener("click",t),this.cleanupHandlers.push(()=>e.removeEventListener("click",t))}handleOkButton(){let e=this.core.getOkButton();if(!e)return;let t=()=>{if(this.core.isDestroyed)return;let i=this.core.getHour(),n=this.core.getMinutes(),r=this.core.getActiveTypeMode();this.emitter.emit("confirm",{hour:i?.value,minutes:n?.value,type:r?.textContent||void 0})};e.addEventListener("click",t),this.cleanupHandlers.push(()=>e.removeEventListener("click",t))}handleAmClick(){let e=this.core.getAM();if(!e)return;let t=()=>{if(this.core.isDestroyed)return;let i=this.core.getPM();e.classList.add("active"),i?.classList.remove("active"),G(e,!0),G(i,!1);let n=this.core.getModalElement();O(n,"AM selected"),this.emitter.emit("select:am",{});let r=this.core.getHour(),s=this.core.getMinutes();this.emitter.emit("update",{hour:r?.value,minutes:s?.value,type:"AM"})};e.addEventListener("click",t),this.cleanupHandlers.push(()=>e.removeEventListener("click",t))}handlePmClick(){let e=this.core.getPM();if(!e)return;let t=()=>{if(this.core.isDestroyed)return;let i=this.core.getAM();e.classList.add("active"),i?.classList.remove("active"),G(e,!0),G(i,!1);let n=this.core.getModalElement();O(n,"PM selected"),this.emitter.emit("select:pm",{});let r=this.core.getHour(),s=this.core.getMinutes();this.emitter.emit("update",{hour:r?.value,minutes:s?.value,type:"PM"})};e.addEventListener("click",t),this.cleanupHandlers.push(()=>e.removeEventListener("click",t))}handleSwitchViewButton(){let e=this.core.getKeyboardClockIcon();if(!e)return;let t=()=>{this.core.isDestroyed||this.emitter.emit("switch:view",{})};e.addEventListener("click",t),this.cleanupHandlers.push(()=>e.removeEventListener("click",t))}destroy(){this.cleanupHandlers.forEach(e=>e()),this.cleanupHandlers=[]}};var Be=(a,e,t)=>Math.max(e,Math.min(t,a)),We=(a,e)=>{if(a==="")return"";let t=parseInt(a,10);return Number.isNaN(t)?"":Be(t,e?1:0,e?12:23).toString().padStart(2,"0")},_e=a=>{if(a==="")return"";let e=parseInt(a,10);return Number.isNaN(e)?"":Be(e,0,59).toString().padStart(2,"0")};var pe=class{core;emitter;cleanupHandlers=[];constructor(e,t){this.core=e,this.emitter=t}handleHourEvents(){let e=this.core.getHour();if(!e)return;let t=()=>{if(this.core.isDestroyed)return;e.classList.add("active");let i=this.core.getMinutes();i?.classList.remove("active"),this.emitter.emit("select:hour",{hour:e.value});let n=this.core.getActiveTypeMode();this.emitter.emit("update",{hour:e.value,minutes:i?.value,type:n?.textContent||void 0})};if(e.addEventListener("click",t),this.cleanupHandlers.push(()=>e.removeEventListener("click",t)),this.core.options.ui.editable||this.core.options.ui.mobile){let i=e.value,n=()=>{if(this.core.isDestroyed)return;let r=this.core.options.clock.type==="12h",s=We(e.value,r);if(e.value=s,e.setAttribute("aria-valuenow",s),e.value!==i){i=e.value,this.emitter.emit("animation:clock",{}),this.emitter.emit("select:hour",{hour:e.value});let o=this.core.getMinutes(),c=this.core.getActiveTypeMode();this.emitter.emit("update",{hour:e.value,minutes:o?.value,type:c?.textContent||void 0})}};e.addEventListener("blur",n),this.cleanupHandlers.push(()=>e.removeEventListener("blur",n))}}handleMinutesEvents(){let e=this.core.getMinutes();if(!e)return;let t=()=>{if(this.core.isDestroyed)return;e.classList.add("active");let i=this.core.getHour();i?.classList.remove("active"),this.emitter.emit("select:minute",{minutes:e.value});let n=this.core.getActiveTypeMode();this.emitter.emit("update",{hour:i?.value,minutes:e.value,type:n?.textContent||void 0})};if(e.addEventListener("click",t),this.cleanupHandlers.push(()=>e.removeEventListener("click",t)),this.core.options.ui.editable||this.core.options.ui.mobile){let i=e.value,n=()=>{if(this.core.isDestroyed)return;let r=_e(e.value);if(e.value=r,e.setAttribute("aria-valuenow",r),e.value!==i){i=e.value,this.emitter.emit("animation:clock",{}),this.emitter.emit("select:minute",{minutes:e.value});let s=this.core.getHour(),o=this.core.getActiveTypeMode();this.emitter.emit("update",{hour:s?.value,minutes:e.value,type:o?.textContent||void 0})}};e.addEventListener("blur",n),this.cleanupHandlers.push(()=>e.removeEventListener("blur",n))}}destroy(){this.cleanupHandlers.forEach(e=>e()),this.cleanupHandlers=[]}};var he=class{core;emitter;cleanupHandlers=[];constructor(e,t){this.core=e,this.emitter=t}handleOpenOnEnterFocus(){let e=this.core.getInput();if(!e)return;let t=i=>{i.key==="Enter"&&!this.core.isDestroyed&&this.emitter.emit("show",{})};e.addEventListener("keydown",t),this.cleanupHandlers.push(()=>e.removeEventListener("keydown",t))}handleEscClick(){if(f()===!1)return;let e=t=>{this.core.isDestroyed||t.key==="Escape"&&this.emitter.emit("cancel",{})};document.addEventListener("keydown",e),this.cleanupHandlers.push(()=>document.removeEventListener("keydown",e))}handleKeyboardInput(){let e=this.core.getHour(),t=this.core.getMinutes();if(e){let i=n=>{if(this.core.isDestroyed||n.key!=="ArrowUp"&&n.key!=="ArrowDown")return;n.preventDefault();let r=parseInt(e.value)||0,s=parseInt(e.getAttribute("max")||"23"),o=parseInt(e.getAttribute("min")||"0"),c=this.core.options.clock.type==="12h",l;n.key==="ArrowUp"?c?l=r>=12?1:r+1:l=r>=s?0:r+1:c?l=r<=1?12:r-1:l=r<=0?s:r-1,e.value=l.toString().padStart(2,"0"),e.setAttribute("aria-valuenow",e.value);let u=this.core.getModalElement();O(u,`Hour: ${e.value}`),this.emitter.emit("animation:clock",{}),this.emitter.emit("select:hour",{hour:e.value});let d=this.core.getMinutes(),p=this.core.getActiveTypeMode();this.emitter.emit("update",{hour:e.value,minutes:d?.value,type:p?.textContent||void 0})};e.addEventListener("keydown",i),this.cleanupHandlers.push(()=>e.removeEventListener("keydown",i))}if(t){let i=n=>{if(this.core.isDestroyed||n.key!=="ArrowUp"&&n.key!=="ArrowDown")return;n.preventDefault();let r=parseInt(t.value)||0,s=59,o=0,c;n.key==="ArrowUp"?c=r>=s?o:r+1:c=r<=o?s:r-1,t.value=c.toString().padStart(2,"0"),t.setAttribute("aria-valuenow",t.value);let l=this.core.getModalElement();O(l,`Minutes: ${t.value}`),this.emitter.emit("animation:clock",{}),this.emitter.emit("select:minute",{minutes:t.value});let u=this.core.getHour(),d=this.core.getActiveTypeMode();this.emitter.emit("update",{hour:u?.value,minutes:t.value,type:d?.textContent||void 0})};t.addEventListener("keydown",i),this.cleanupHandlers.push(()=>t.removeEventListener("keydown",i))}}focusTrapHandler(){if(f()===!1)return;let e=this.core.getWrapper();if(!e)return;let t=i=>{if(this.core.isDestroyed||i.key!=="Tab")return;let n=e.querySelectorAll('button, [href], input, select, textarea, [tabindex]:not([tabindex="-1"])'),r=n[0],s=n[n.length-1];i.shiftKey&&document.activeElement===r?(s?.focus(),i.preventDefault()):!i.shiftKey&&document.activeElement===s&&(r?.focus(),i.preventDefault())};e.addEventListener("keydown",t),this.cleanupHandlers.push(()=>e.removeEventListener("keydown",t))}destroy(){this.cleanupHandlers.forEach(e=>e()),this.cleanupHandlers=[]}};var ve=class{core;emitter;cleanupHandlers=[];constructor(e,t){this.core=e,this.emitter=t}handleBackdropClick(){let e=this.core.getModalElement();if(!e)return;let t=i=>{this.core.isDestroyed||i.target===e&&this.emitter.emit("cancel",{})};e.addEventListener("click",t),this.cleanupHandlers.push(()=>e.removeEventListener("click",t))}handleMoveHand(){if(f()===!1)return;let e=t=>{this.core.isDestroyed||t.preventDefault()};document.addEventListener("mousedown",e,!1),document.addEventListener("touchstart",e,{passive:!1}),this.cleanupHandlers.push(()=>{document.removeEventListener("mousedown",e),document.removeEventListener("touchstart",e)})}destroy(){this.cleanupHandlers.forEach(e=>e()),this.cleanupHandlers=[]}};var j=class{buttonHandlers;inputHandlers;keyboardHandlers;modalHandlers;constructor(e,t){this.buttonHandlers=new de(e,t),this.inputHandlers=new pe(e,t),this.keyboardHandlers=new he(e,t),this.modalHandlers=new ve(e,t)}handleOpenOnClick(){this.buttonHandlers.handleOpenOnClick()}handleOpenOnEnterFocus(){this.keyboardHandlers.handleOpenOnEnterFocus()}handleCancelButton(){this.buttonHandlers.handleCancelButton()}handleOkButton(){this.buttonHandlers.handleOkButton()}handleBackdropClick(){this.modalHandlers.handleBackdropClick()}handleEscClick(){this.keyboardHandlers.handleEscClick()}handleAmClick(){this.buttonHandlers.handleAmClick()}handlePmClick(){this.buttonHandlers.handlePmClick()}handleHourEvents(){this.inputHandlers.handleHourEvents()}handleMinutesEvents(){this.inputHandlers.handleMinutesEvents()}handleKeyboardInput(){this.keyboardHandlers.handleKeyboardInput()}focusTrapHandler(){this.keyboardHandlers.focusTrapHandler()}handleMoveHand(){this.modalHandlers.handleMoveHand()}handleSwitchViewButton(){this.buttonHandlers.handleSwitchViewButton()}destroy(){this.buttonHandlers.destroy(),this.inputHandlers.destroy(),this.keyboardHandlers.destroy(),this.modalHandlers.destroy()}};var X=class{emitter;getClockSystem;setHoursToClock;setMinutesToClock;updateAmPm;convertDisabledTime;constructor(e,t,i,n,r,s){this.emitter=e,this.getClockSystem=t,this.setHoursToClock=i,this.setMinutesToClock=n,this.updateAmPm=r,this.convertDisabledTime=s}setup(){this.emitter.on("select:hour",({hour:e})=>{this.emitter.emit("animation:clock",{}),this.setHoursToClock(e||null)}),this.emitter.on("select:minute",({minutes:e})=>{this.emitter.emit("animation:clock",{}),this.setMinutesToClock(e||null)}),this.emitter.on("select:am",()=>{this.updateAmPm()}),this.emitter.on("select:pm",()=>{this.updateAmPm()}),this.emitter.on("animation:start",()=>{this.getClockSystem()?.blockInteractions()}),this.emitter.on("animation:end",()=>{this.getClockSystem()?.unblockInteractions()}),this.emitter.on("range:switch",e=>{this.refreshDisabledTimeForRange(e.disabledTime)})}refreshDisabledTimeForRange(e){let t=this.getClockSystem();if(!t)return;let i=this.convertDisabledTime(),n=i;if(e){let r=[...i?.hours||[],...e.hours||[]],s=[...i?.minutes||[],...e.minutes||[]];n={...i,hours:r.length>0?r:void 0,minutes:s.length>0?s:void 0,rangeFromType:e.fromType,rangeFromHour:e.fromHour}}t.updateDisabledTime(n)}};var w=class{static angleToIndex(e,t,i){let n=Math.round(e/30)%12;if(t==="24h")if(i){let r=n+12;return r===12?0:r}else return n===0?12:n;return n===0?12:n}static indexToValue(e,t,i){if(t==="24h")return e.toString().padStart(2,"0");let n=e;return n===0&&(n=12),n>12&&(n=n-12),n.toString().padStart(2,"0")}static indexToAngle(e,t){return t==="24h"?e>=12?(e-12)%12*30:e%12*30:(e===0?12:e)%12*30}static isDisabled(e,t,i){return i?i.isInterval&&i.intervals&&i.clockType?this.isDisabledByInterval(e,t,i):i.rangeFromType!==void 0&&i.rangeFromHour!==void 0?this.isDisabledForRange12h(e,t,i):i.hours?i.hours.some(n=>String(n)===e||Number(n)===Number(e)||n===e):!1:!1}static isDisabledForRange12h(e,t,i){let n=i.rangeFromType,r=i.rangeFromHour,s=parseInt(e,10);return n===null||r===void 0?!1:t==="AM"&&n==="PM"?!0:t==="AM"&&n==="AM"?r===12?!1:s===12?!0:s<r:t==="PM"&&n==="AM"?!1:t==="PM"&&n==="PM"?r===12?!1:s===12?!0:s<r:!1}static isDisabledByInterval(e,t,i){if(!i.intervals)return!1;for(let n=0;n<60;n++){let r=n.toString().padStart(2,"0");if(!this.isTimeInIntervals(e,r,t,i.intervals,i.clockType))return!1}return!0}static isTimeInIntervals(e,t,i,n,r){let s=r==="12h"?`${e}:${t} ${i}`:`${e}:${t}`;for(let o of n){let[c,l]=o.split("-").map(u=>u.trim());if(this.isTimeBetween(s,c,l,r))return!0}return!1}static isTimeBetween(e,t,i,n){let r=this.timeToMinutes(e,n),s=this.timeToMinutes(t,n),o=this.timeToMinutes(i,n);return r>=s&&r<=o}static timeToMinutes(e,t){if(t==="12h"){let i=e.match(/(\d{1,2}):(\d{2})\s*(AM|PM)/i);if(!i)return 0;let n=parseInt(i[1]),r=parseInt(i[2]),s=i[3].toUpperCase();return s==="PM"&&n!==12&&(n+=12),s==="AM"&&n===12&&(n=0),n*60+r}else{let[i,n]=e.split(":").map(Number);return i*60+n}}static findNearestValid(e,t,i,n,r){let s=t==="24h"?23:12;for(let o=0;o<=s;o++){let c=o===0?[e]:[e+o,e-o];for(let l of c){let u=l;u<0&&(u+=s+1),u>s&&(u=u%(s+1));let d=this.indexToValue(u,t,i);if(!this.isDisabled(d,i,n))return u}}return e}};var D=class{static angleToIndex(e){return Math.round(e/6)%60}static indexToValue(e){return e.toString().padStart(2,"0")}static indexToAngle(e){return e%60*6}static isDisabled(e,t,i,n,r){return n?n.isInterval&&n.intervals?this.isDisabledByInterval(e,t,i,n,r):n.rangeFromType!==void 0&&n.rangeFromHour!==void 0?this.isDisabledForRange12h(e,t,i,n):n.minutes?n.minutes.some(s=>String(s)===e||Number(s)===Number(e)||s===e):!1:!1}static isDisabledForRange12h(e,t,i,n){let r=n.rangeFromType,s=n.rangeFromHour,o=parseInt(t,10),c=parseInt(e,10);if(r===null||s===void 0)return!1;let l=n.minutes||[],u=l.length>0?parseInt(l[l.length-1],10)+1:0;return i==="AM"&&r==="PM"?!0:i==="PM"&&r==="AM"?!1:o===s||o===12&&s===12||i===r&&o===s?c<u:!1}static isDisabledByInterval(e,t,i,n,r){if(!n.intervals)return!1;let s=r==="12h"?`${t}:${e} ${i}`:`${t}:${e}`;for(let o of n.intervals){let[c,l]=o.split("-").map(u=>u.trim());if(this.isTimeBetween(s,c,l,r))return!0}return!1}static isTimeBetween(e,t,i,n){let r=this.timeToMinutes(e,n),s=this.timeToMinutes(t,n),o=this.timeToMinutes(i,n);return r>=s&&r<=o}static timeToMinutes(e,t){if(t==="12h"){let i=e.match(/(\d{1,2}):(\d{2})\s*(AM|PM)/i);if(!i)return 0;let n=parseInt(i[1]),r=parseInt(i[2]),s=i[3].toUpperCase();return s==="PM"&&n!==12&&(n+=12),s==="AM"&&n===12&&(n=0),n*60+r}else{let[i,n]=e.split(":").map(Number);return i*60+n}}static findNearestValid(e,t,i,n,r){for(let s=0;s<60;s++){let o=s===0?[e]:[e+s,e-s];for(let c of o){let l=c;l<0&&(l+=60),l>=60&&(l=l%60);let u=this.indexToValue(l);if(!this.isDisabled(u,t,i,n,r))return l}}return e}};var x=class{static normalizeAngle(e){let t=e%360;return t<0&&(t+=360),t}static calculateRawAngle(e,t){let i=e.x-t.x,n=e.y-t.y,s=Math.atan2(n,i)*180/Math.PI+90;return this.normalizeAngle(s)}static snapToIncrement(e,t){let i=Math.round(e/t)*t;return this.normalizeAngle(i)}static calculateDistance(e,t){let i=e.x-t.x,n=e.y-t.y;return Math.sqrt(i*i+n*n)}static isInnerCircle(e,t){return e<t*.75}static calculateShortestPath(e,t){let i=this.normalizeAngle(e),r=this.normalizeAngle(t)-i,s=r>=0?r:r+360,o=r<=0?r:r-360,c=Math.abs(s)<Math.abs(o)?s:o;return e+c}};var fe=class{config;currentAngle=0;tipsCache=new Map;cachedDimensions=new Map;constructor(e){this.config=e}getCachedDimensions(e){let t=this.cachedDimensions.get(e);if(!t){let i=(e.offsetWidth-32)/2,n=(e.offsetHeight-32)/2,r=i-9;t={width:i,height:n,radius:r},this.cachedDimensions.set(e,t)}return t}setHandAngle(e){let t=x.calculateShortestPath(this.currentAngle,e);Math.abs(this.currentAngle-t)<.01||(this.currentAngle=t,this.config.clockHand.style.transform=`rotateZ(${t}deg)`)}animateToAngle(e){let t=x.calculateShortestPath(this.currentAngle,e);this.currentAngle=t,this.config.tipsWrapper.classList.add("tp-ui-tips-animation"),this.config.clockHand.style.transform=`rotateZ(${t}deg)`,setTimeout(()=>{this.config.tipsWrapper.classList.remove("tp-ui-tips-animation")},401)}setActiveValue(e){let t=[this.config.tipsWrapper];this.config.tipsWrapperFor24h&&t.push(this.config.tipsWrapperFor24h),t.forEach(i=>{i.querySelectorAll(".tp-ui-value-tips, .tp-ui-value-tips-24h").forEach(r=>{let s=r;s.textContent===e||Number(s.textContent)===Number(e)?(s.classList.add("active"),s.setAttribute("aria-selected","true")):(s.classList.remove("active"),s.setAttribute("aria-selected","false"))})})}renderTips(e,t,i,n,r,s=!0,o,c="",l="12"){if(f()===!1)return;let u=o||this.config.tipsWrapper;s&&(u.innerHTML="",this.tipsCache.clear());let{width:d,height:p,radius:g}=this.getCachedDimensions(u),b=document.createDocumentFragment(),H=`${t}-${this.config.theme||"default"}`;e.forEach((T,k)=>{let h=`${H}-${T}`,E=this.tipsCache.get(h);E||(E=this.createTip(T,t,r),this.tipsCache.set(h,E));let{wrapper:y,tip:M}=E;this.updateTipState(y,M,T,i,n,r,c,l);let v=k*(360/e.length)*(Math.PI/180);y.style.left=`${d+Math.sin(v)*g}px`,y.style.bottom=`${p+Math.cos(v)*g}px`,b.appendChild(y)}),u.appendChild(b)}createTip(e,t,i){if(f()===!1){let o={};return{wrapper:o,tip:o}}let n=document.createElement("span"),r=document.createElement("span");r.textContent=e,r.setAttribute("role","option"),r.setAttribute("aria-selected","false"),r.tabIndex=0;let s=i==="24h"&&t.includes("24")?"tp-ui-value-tips-24h":"tp-ui-value-tips";return r.classList.add(s),n.classList.add(t),this.config.theme&&(n.classList.add(this.config.theme),r.classList.add(this.config.theme)),n.appendChild(r),{wrapper:n,tip:r}}updateTipState(e,t,i,n,r,s,o,c){e.classList.remove("tp-ui-tips-disabled"),t.classList.remove("tp-ui-tips-disabled"),t.removeAttribute("aria-disabled"),t.tabIndex=0,this.checkIfDisabled(i,n,r,s,o,c)&&(e.classList.add("tp-ui-tips-disabled"),t.classList.add("tp-ui-tips-disabled"),t.setAttribute("aria-disabled","true"),t.tabIndex=-1)}checkIfDisabled(e,t,i,n,r,s){return i?t==="hours"?w.isDisabled(e,r,i):t==="minutes"?D.isDisabled(e,s,r,i,n):!1:!1}setCircleSize(e){e?this.config.circle.classList.remove("small-circle"):this.config.circle.classList.add("small-circle")}setCircle24hMode(e){e?(this.config.circle.classList.add("tp-ui-circle-hand-24h"),this.config.clockHand.classList.add("tp-ui-clock-hand-24h")):(this.config.circle.classList.remove("tp-ui-circle-hand-24h"),this.config.clockHand.classList.remove("tp-ui-clock-hand-24h"))}destroy(){this.tipsCache.clear(),this.cachedDimensions.clear(),this.config.tipsWrapper.innerHTML=""}};var $=class{static processPointerInput(e){let t=x.calculateRawAngle(e.pointerPosition,e.clockCenter);return e.mode==="hours"?this.processHours(t,e):this.processMinutes(t,e)}static processHours(e,t){let i=t.smoothHourSnap??!0,n;if(i)n=e;else{let p=t.incrementHours*30;n=x.snapToIncrement(e,p)}let r=x.calculateDistance(t.pointerPosition,t.clockCenter),s=t.clockType==="24h"&&x.isInnerCircle(r,t.clockRadius),o=w.angleToIndex(n,t.clockType,s),c=w.indexToValue(o,t.clockType,t.amPm),l=w.isDisabled(c,t.amPm,t.disabledTime);l&&(o=w.findNearestValid(o,t.clockType,t.amPm,t.disabledTime,s));let u=w.indexToValue(o,t.clockType,t.amPm),d;return i?d=e:d=w.indexToAngle(o,t.clockType),{angle:d,value:u,index:o,isValid:!l,isInnerCircle:t.clockType==="24h"?s:void 0}}static processMinutes(e,t){let i=t.incrementMinutes*6,n=x.snapToIncrement(e,i),r=D.angleToIndex(n),s=D.indexToValue(r),o=t.currentHour||"00",c=D.isDisabled(s,o,t.amPm,t.disabledTime,t.clockType);c&&(r=D.findNearestValid(r,o,t.amPm,t.disabledTime,t.clockType));let l=D.indexToValue(r);return{angle:D.indexToAngle(r),value:l,index:r,isValid:!c}}static valueToAngle(e,t,i){let n=parseInt(e,10);return t==="hours"?w.indexToAngle(n,i):D.indexToAngle(n)}};var ge=class{state;renderer;clockType;disabledTime;incrementHours;incrementMinutes;smoothHourSnap;isDragging=!1;callbacks;lastProcessedX=null;lastProcessedY=null;constructor(e,t,i,n,r=1,s=1,o=!0,c={}){this.renderer=e,this.state={...t},this.clockType=i,this.disabledTime=n,this.incrementHours=r,this.incrementMinutes=s,this.smoothHourSnap=o,this.callbacks=c}handlePointerMove(e,t,i){if(this.isDragging=!0,this.lastProcessedX===e.x&&this.lastProcessedY===e.y)return;this.lastProcessedX=e.x,this.lastProcessedY=e.y;let n={pointerPosition:e,clockCenter:t,clockRadius:i,mode:this.state.mode,clockType:this.clockType,amPm:this.state.amPm,disabledTime:this.disabledTime,incrementHours:this.incrementHours,incrementMinutes:this.incrementMinutes,smoothHourSnap:this.smoothHourSnap,currentHour:this.state.hour},r=$.processPointerInput(n);if(r.isValid){if(this.state.mode==="hours"){let s=this.state.hour;this.state.hour=r.value,this.state.hourAngle=r.angle,this.clockType==="24h"&&r.isInnerCircle!==void 0&&(this.renderer.setCircleSize(!0),this.renderer.setCircle24hMode(r.isInnerCircle)),this.callbacks.onHourChange&&s!==r.value&&this.callbacks.onHourChange(r.value)}else{let s=this.state.minute;this.state.minute=r.value,this.state.minuteAngle=r.angle,this.renderer.setCircleSize(!0),this.renderer.setCircle24hMode(!1),this.callbacks.onMinuteChange&&s!==r.value&&this.callbacks.onMinuteChange(r.value)}this.renderer.setHandAngle(r.angle),this.renderer.setActiveValue(r.value)}}handlePointerUp(){this.isDragging=!1,this.lastProcessedX=null,this.lastProcessedY=null}snapToNearestHour(){if(this.state.mode!=="hours")return;let e=$.valueToAngle(this.state.hour,"hours",this.clockType);this.state.hourAngle=e,this.renderer.animateToAngle(e)}switchMode(e){this.state.mode=e;let t=e==="hours"?this.state.hourAngle:this.state.minuteAngle,i=e==="hours"?this.state.hour:this.state.minute;if(e==="hours"&&this.clockType==="24h"){let n=parseInt(i,10),r=n===0||n>=13;this.renderer.setCircleSize(!0),this.renderer.setCircle24hMode(r)}else this.renderer.setCircleSize(!0),this.renderer.setCircle24hMode(!1);this.renderer.setHandAngle(t),this.renderer.setActiveValue(i)}setValue(e,t){let i=$.valueToAngle(t,e,this.clockType);if(e==="hours")if(this.state.hour=t,this.state.hourAngle=i,this.clockType==="24h"){let n=parseInt(t,10),r=n===0||n>=13;this.renderer.setCircleSize(!0),this.renderer.setCircle24hMode(r)}else this.renderer.setCircle24hMode(!1);else this.state.minute=t,this.state.minuteAngle=i,this.renderer.setCircleSize(!0),this.renderer.setCircle24hMode(!1);this.state.mode===e&&(this.renderer.setHandAngle(i),this.renderer.setActiveValue(t))}setAmPm(e){this.state.amPm=e}getState(){return{...this.state}}getHour(){return this.state.hour}getMinute(){return this.state.minute}getAmPm(){return this.state.amPm}updateDisabledTime(e){this.disabledTime=e}destroy(){this.renderer.destroy()}};var Ee=class{controller;clockFace;isActive=!1;isBlocked=!1;config;cachedRect=null;cachedCenter=null;cachedRadius=null;rafId=null;constructor(e,t,i={}){this.controller=e,this.clockFace=t,this.config=i}attach(){this.clockFace.addEventListener("mousedown",this.handlePointerDown),this.clockFace.addEventListener("touchstart",this.handlePointerDown,{passive:!1})}detach(){this.clockFace.removeEventListener("mousedown",this.handlePointerDown),this.clockFace.removeEventListener("touchstart",this.handlePointerDown),this.removeGlobalListeners()}block(){this.isBlocked=!0}unblock(){this.isBlocked=!1}handlePointerDown=e=>{if(L()||this.isBlocked)return;let t=e.target;t&&t.classList&&t.classList.contains("tp-ui-tips-disabled")||(e.preventDefault(),this.isActive=!0,this.cachedRect=this.clockFace.getBoundingClientRect(),this.cachedCenter=this.getClockCenter(),this.cachedRadius=this.getClockRadius(),this.processPointerEvent(e),document.addEventListener("mousemove",this.handlePointerMove),document.addEventListener("touchmove",this.handlePointerMove,{passive:!1}),document.addEventListener("mouseup",this.handlePointerUp),document.addEventListener("touchend",this.handlePointerUp))};handlePointerMove=e=>{if(!this.isActive||this.isBlocked)return;let t=this.getTargetElement(e);t&&t.classList&&t.classList.contains("tp-ui-tips-disabled")||(e.preventDefault(),this.rafId===null&&(this.rafId=requestAnimationFrame(()=>{this.rafId=null,this.processPointerEvent(e)})))};handlePointerUp=()=>{if(!this.isActive)return;this.rafId!==null&&(cancelAnimationFrame(this.rafId),this.rafId=null),this.isActive=!1,this.cachedRect=null,this.cachedCenter=null,this.cachedRadius=null,this.controller.handlePointerUp();let{autoSwitchToMinutes:e,isMobileView:t,smoothHourSnap:i,hourElement:n,minutesElement:r}=this.config;i&&n?.classList.contains("active")&&this.controller.snapToNearestHour(),this.removeGlobalListeners(),e&&n?.classList.contains("active")&&!t?(n.classList.remove("active"),r?.classList.add("active"),r?.click(),r?.focus()):r?.classList.contains("active")&&this.config.onMinuteCommit&&this.config.onMinuteCommit()};processPointerEvent(e){let t=this.getPointerPosition(e),i=this.cachedCenter||this.getClockCenter(),n=this.cachedRadius||this.getClockRadius();this.controller.handlePointerMove(t,i,n)}getPointerPosition(e){let t=this.cachedRect||this.clockFace.getBoundingClientRect();if("touches"in e){let i=e.touches[0]||e.changedTouches[0];return{x:i.clientX-t.left,y:i.clientY-t.top}}else return{x:e.clientX-t.left,y:e.clientY-t.top}}getTargetElement(e){if("touches"in e){let t=e.touches[0]||e.changedTouches[0];if(t&&!L())return document.elementFromPoint(t.clientX,t.clientY)}return e.target}getClockCenter(){let e=this.clockFace.offsetWidth,t=this.clockFace.offsetHeight;return{x:e/2,y:t/2}}getClockRadius(){return this.clockFace.offsetWidth/2}removeGlobalListeners(){f()!==!1&&(document.removeEventListener("mousemove",this.handlePointerMove),document.removeEventListener("touchmove",this.handlePointerMove),document.removeEventListener("mouseup",this.handlePointerUp),document.removeEventListener("touchend",this.handlePointerUp))}};var be=class{renderer;controller;dragHandlers;clockType;disabledTime;tipsWrapper;tipsWrapperFor24h;constructor(e){this.clockType=e.clockType,this.disabledTime=e.disabledTime,this.tipsWrapper=e.tipsWrapper,this.tipsWrapperFor24h=e.tipsWrapperFor24h;let t={clockFace:e.clockFace,tipsWrapper:e.tipsWrapper,tipsWrapperFor24h:e.tipsWrapperFor24h,clockHand:e.clockHand,circle:e.circle,theme:e.theme};this.renderer=new fe(t);let i={hour:e.initialHour,minute:e.initialMinute,amPm:e.initialAmPm,hourAngle:this.calculateInitialAngle("hours",e.initialHour),minuteAngle:this.calculateInitialAngle("minutes",e.initialMinute),mode:"hours"},n={onHourChange:e.onHourChange,onMinuteChange:e.onMinuteChange};this.controller=new ge(this.renderer,i,e.clockType,e.disabledTime,e.incrementHours||1,e.incrementMinutes||1,e.smoothHourSnap??!0,n),this.dragHandlers=new Ee(this.controller,e.clockFace,e.dragConfig||{})}initialize(){this.dragHandlers.attach(),this.switchToHours()}switchToHours(){this.controller.switchMode("hours"),this.clockType==="24h"&&this.tipsWrapperFor24h&&this.tipsWrapperFor24h.classList.remove("none"),this.renderHourTips();let e=this.controller.getState();this.renderer.setActiveValue(e.hour)}switchToMinutes(){this.controller.switchMode("minutes"),this.tipsWrapperFor24h&&this.tipsWrapperFor24h.classList.add("none"),this.renderMinuteTips();let e=this.controller.getState();this.renderer.setActiveValue(e.minute)}setHour(e){this.controller.setValue("hours",e)}setMinute(e){this.controller.setValue("minutes",e)}setAmPm(e){this.controller.setAmPm(e);let t=this.controller.getState();t.mode==="hours"?(this.renderHourTips(),this.renderer.setHandAngle(t.hourAngle),this.renderer.setActiveValue(t.hour)):(this.renderMinuteTips(),this.renderer.setHandAngle(t.minuteAngle),this.renderer.setActiveValue(t.minute))}getHour(){return this.controller.getHour()}getMinute(){return this.controller.getMinute()}getAmPm(){return this.controller.getAmPm()}updateDisabledTime(e){this.disabledTime=e,this.controller.updateDisabledTime(e),this.controller.getState().mode==="hours"?this.renderHourTips():this.renderMinuteTips()}renderHourTips(){let t=this.controller.getState().amPm;this.clockType==="24h"?(this.renderer.renderTips(Ie,"tp-ui-hour-time-12","hours",this.disabledTime,this.clockType,!0,this.tipsWrapper,t),this.tipsWrapperFor24h&&this.renderer.renderTips($e,"tp-ui-hour-time-24","hours",this.disabledTime,this.clockType,!0,this.tipsWrapperFor24h,t)):this.renderer.renderTips(Ie,"tp-ui-hour-time-12","hours",this.disabledTime,this.clockType,!0,void 0,t)}renderMinuteTips(){let e=this.controller.getState(),t=e.amPm,i=e.hour;this.renderer.renderTips(_,"tp-ui-minutes-time","minutes",this.disabledTime,this.clockType,!0,void 0,t,i)}calculateInitialAngle(e,t){let i=parseInt(t,10);return e==="hours"?i%12*30:i*6}destroy(){this.dragHandlers.detach(),this.controller.destroy()}blockInteractions(){this.dragHandlers.block()}unblockInteractions(){this.dragHandlers.unblock()}};var J=class{core;emitter;clockSystem=null;constructor(e,t){this.core=e,this.emitter=t}getClockSystem(){return this.clockSystem}initialize(){let e=this.core.getClockFace(),t=this.core.getClockHand(),i=this.core.getCircle();if(!e||!t||!i)return;let n=this.core.options.clock.type==="24h",r=this.core.getTipsWrapper();if(!r)return;let s=this.core.getHour(),o=this.core.getMinutes(),c={clockFace:e,tipsWrapper:r,tipsWrapperFor24h:n&&this.core.getTipsWrapperFor24h()||void 0,clockHand:t,circle:i,clockType:this.core.options.clock.type||"12h",disabledTime:this.convertDisabledTime(),initialHour:s?.value||"12",initialMinute:o?.value||"00",initialAmPm:this.getAmPmValue(),theme:this.core.options.ui.theme,incrementHours:this.core.options.clock.incrementHours||1,incrementMinutes:this.core.options.clock.incrementMinutes||1,smoothHourSnap:this.core.options.clock.smoothHourSnap??!0,timepicker:null,dragConfig:{autoSwitchToMinutes:this.core.options.clock.autoSwitchToMinutes,isMobileView:this.core.isMobileView,smoothHourSnap:this.core.options.clock.smoothHourSnap??!0,hourElement:s,minutesElement:o,onMinuteCommit:()=>{let l=this.core.getMinutes(),u=this.core.getHour(),d=this.core.getActiveTypeMode();this.emitter.emit("range:minute:commit",{hour:u?.value??"12",minutes:l?.value??"00",type:d?.textContent??void 0})}},onHourChange:l=>{let u=this.core.getHour();u&&(u.value=l,u.setAttribute("aria-valuenow",l));let d=this.core.getModalElement();O(d,`Hour: ${l}`);let p=this.core.getMinutes(),g=this.core.getActiveTypeMode();this.emitter.emit("update",{hour:l,minutes:p?.value,type:g?.textContent||void 0})},onMinuteChange:l=>{let u=this.core.getMinutes();u&&(u.value=l,u.setAttribute("aria-valuenow",l));let d=this.core.getModalElement();O(d,`Minutes: ${l}`);let p=this.core.getHour(),g=this.core.getActiveTypeMode();this.emitter.emit("update",{hour:p?.value,minutes:l,type:g?.textContent||void 0})}};this.clockSystem=new be(c),this.clockSystem.initialize()}convertDisabledTime(){let e=this.core.disabledTime?.value;if(!e)return null;let t;return e.intervals&&(t=Array.isArray(e.intervals)?e.intervals:[e.intervals]),{hours:e.hours,minutes:e.minutes,isInterval:e.isInterval,intervals:t,clockType:e.clockType}}getAmPmValue(){if(this.core.options.clock.type==="24h")return"";let e=this.core.getActiveTypeMode();if(e){let n=e.textContent?.trim();if(n==="AM"||n==="PM")return n}let t=this.core.getAM();return this.core.options.range?.enabled===!0?t?.classList.contains("active")?"AM":"":t?.classList.contains("active")?"AM":"PM"}destroy(){this.clockSystem&&(this.clockSystem.destroy(),this.clockSystem=null)}};var Q=class{core;constructor(e){this.core=e}removeCircleClockClasses24h(){let e=this.core.getCircle(),t=this.core.getClockHand();e?.classList.remove("tp-ui-circle-hand-24h"),t?.classList.remove("tp-ui-clock-hand-24h")}setCircleClockClasses24h(){let e=this.core.getCircle(),t=this.core.getClockHand();e&&e.classList.add("tp-ui-circle-hand-24h"),t&&t.classList.add("tp-ui-clock-hand-24h")}setOnStartCSSClassesIfClockType24h(){if(this.core.options.clock.type==="24h"){let e=this.core.getInput();if(!e)return;let t;e.value.length>0&&(t=e.value.split(":")[0]),t&&(Number(t)>12||Number(t)===0)&&this.setCircleClockClasses24h()}}setBgColorToCircleWithMinutesTips(){let e=this.core.getMinutes(),t=this.core.getCircle();if(!(!e||!t)&&e.value&&_.includes(e.value)){let i=getComputedStyle(t).getPropertyValue("--timepicker-primary").trim();i&&(t.style.backgroundColor=i),t.classList.remove("small-circle")}}removeBgColorToCirleWithMinutesTips(){let e=this.core.getMinutes(),t=this.core.getCircle();!e||!t||e.value&&_.includes(e.value)||(t.style.backgroundColor="",t.classList.add("small-circle"))}setClassActiveToHourOnOpen(){if(this.core.options.ui.mobile||this.core.isMobileView)return;this.core.getHour()?.classList.add(N)}toggleClassActiveToValueTips(e,t){if(e)return;let i=this.core.getAllValueTips();if(!i)return;let n=i.find(r=>Number(r.innerText)===Number(t));i.forEach(r=>{r.classList.remove(N),r.setAttribute("aria-selected","false")}),n!==void 0&&(n.classList.add(N),n.setAttribute("aria-selected","true"))}};var ee=class{getClockSystem;styleHandler;getAmPmValue;clockType;constructor(e,t,i,n){this.getClockSystem=e,this.styleHandler=t,this.getAmPmValue=i,this.clockType=n}setMinutesToClock(e){let t=this.getClockSystem();t&&(this.styleHandler.removeBgColorToCirleWithMinutesTips(),e&&t.setMinute(e),t.switchToMinutes())}setHoursToClock(e){let t=this.getClockSystem();t&&(e&&t.setHour(e),t.switchToHours())}setTransformToCircleWithSwitchesHour(e){let t=this.getClockSystem();!t||!e||t.setHour(e)}setTransformToCircleWithSwitchesMinutes(e){let t=this.getClockSystem();!t||!e||t.setMinute(e)}updateAmPm(){let e=this.getClockSystem();if(!e||this.clockType==="24h")return;let t=this.getAmPmValue();t!==""&&e.setAmPm(t)}};var te=class{systemInitializer;styleHandler;timeHandler;eventHandler;constructor(e,t){this.systemInitializer=new J(e,t),this.styleHandler=new Q(e);let i=e.options.clock.type||"12h";this.timeHandler=new ee(()=>this.systemInitializer.getClockSystem(),this.styleHandler,()=>this.systemInitializer.getAmPmValue(),i),this.eventHandler=new X(t,()=>this.systemInitializer.getClockSystem(),n=>this.timeHandler.setHoursToClock(n),n=>this.timeHandler.setMinutesToClock(n),()=>this.timeHandler.updateAmPm(),()=>this.systemInitializer.convertDisabledTime()),this.eventHandler.setup()}initializeClockSystem(){this.systemInitializer.initialize()}destroyClockSystem(){this.systemInitializer.destroy()}removeCircleClockClasses24h(){this.styleHandler.removeCircleClockClasses24h()}setCircleClockClasses24h(){this.styleHandler.setCircleClockClasses24h()}setOnStartCSSClassesIfClockType24h(){this.styleHandler.setOnStartCSSClassesIfClockType24h()}setBgColorToCircleWithMinutesTips=()=>{this.styleHandler.setBgColorToCircleWithMinutesTips()};removeBgColorToCirleWithMinutesTips=()=>{this.styleHandler.removeBgColorToCirleWithMinutesTips()};setClassActiveToHourOnOpen=()=>{this.styleHandler.setClassActiveToHourOnOpen()};setMinutesToClock=e=>{this.timeHandler.setMinutesToClock(e)};setHoursToClock=e=>{this.timeHandler.setHoursToClock(e)};setTransformToCircleWithSwitchesHour=e=>{this.timeHandler.setTransformToCircleWithSwitchesHour(e)};setTransformToCircleWithSwitchesMinutes=e=>{this.timeHandler.setTransformToCircleWithSwitchesMinutes(e)};updateAmPm=()=>{this.timeHandler.updateAmPm()};toggleClassActiveToValueTips=e=>{let t=this.systemInitializer.getClockSystem()!==null;this.styleHandler.toggleClassActiveToValueTips(t,e)};destroy(){this.destroyClockSystem()}};var Pe=class{plugins=new Map;register(e){this.plugins.has(e.name)||this.plugins.set(e.name,e)}getAll(){return Array.from(this.plugins.values())}has(e){return this.plugins.has(e)}get(e){return this.plugins.get(e)}},ye=new Pe;var Te=class{animation;modal;config;theme;validation;events;clock;plugins=new Map;constructor(e,t){this.animation=new B(e,t),this.modal=new U(e,t),this.config=new K(e,t),this.theme=new Y(e,t),this.validation=new Z(e,t),this.events=new j(e,t),this.clock=new te(e,t),ye.getAll().forEach(n=>{let r=n.factory(e,t);this.plugins.set(n.name,r)})}getPlugin(e){return this.plugins.get(e)}destroy(){this.animation.destroy(),this.modal.destroy(),this.config.destroy(),this.theme.destroy(),this.validation.destroy(),this.events.destroy(),this.clock.destroy(),this.plugins.forEach(e=>e.destroy()),this.plugins.clear()}};var Me="is-rippling",ke="ripple-hold",F=null;function ot(a){let e=a.target,t=e.hasAttribute("data-md3-ripple")?e:e.closest("[data-md3-ripple]");if(!t||a.button!==0&&a.pointerType==="mouse")return;let i=t.getBoundingClientRect(),r=Math.max(i.width,i.height)*2,s=a.clientX-i.left,o=a.clientY-i.top;t.style.setProperty("--ripple-size",`${r}px`),t.style.setProperty("--ripple-x",`${s}px`),t.style.setProperty("--ripple-y",`${o}px`),t.classList.remove(Me,ke),t.offsetWidth,t.classList.add(Me,ke),t._rippleHold=!0,F=t}function Ue(a){let e=a.target,i=(e.hasAttribute("data-md3-ripple")?e:e.closest("[data-md3-ripple]"))||F;i&&(i._rippleHold=!1,i.classList.remove(ke),setTimeout(()=>{i.classList.remove(Me),F===i&&(F=null)},1e3))}function at(a){let e=a.currentTarget;!e||!e._rippleHold||(e._rippleHold=!1,e.classList.remove(ke),setTimeout(()=>{e.classList.remove(Me),F===e&&(F=null)},1e3))}function Ke(a){if(f()===!1)return;let e=a||document;e.addEventListener("pointerdown",ot),e.addEventListener("pointerup",Ue),e.addEventListener("pointercancel",Ue),e.querySelectorAll("[data-md3-ripple]").forEach(i=>{i.addEventListener("mouseleave",at)})}var Ye=(a,e)=>{let t;return(...i)=>{clearTimeout(t),t=setTimeout(()=>{a(...i)},e)}};var Ce=class{core;managers;emitter;eventsClickMobileHandler=()=>{};mutliEventsMoveHandler=()=>{};constructor(e,t,i){this.core=e,this.managers=t,this.emitter=i}init(){if(!this.core.isDestroyed&&!this.core.isInitialized){try{this.managers.config.updateInputValueWithCurrentTimeOnStart(),this.managers.validation.checkDisabledValuesOnStart()}catch{this.core.setIsDestroyed(!0);return}this.managers.theme.setTimepickerClassToElement(),this.managers.theme.setInputClassToInputElement(),this.managers.theme.setDataOpenToInputIfDoesntExistInWrapper(),this.managers.theme.setClassTopOpenElement(),this.managers.config.getDisableTime(),this.core.options.ui.inline?.enabled||this.managers.events.handleOpenOnClick(),this.managers.events.handleOpenOnEnterFocus(),this.setupCallbackBridge(),this.core.setIsInitialized(!0)}}setupCallbackBridge(){let{callbacks:e}=this.core.options;e.onOpen&&this.emitter.on("open",e.onOpen),e.onCancel&&this.emitter.on("cancel",e.onCancel),e.onConfirm&&this.emitter.on("confirm",e.onConfirm),e.onUpdate&&this.emitter.on("update",e.onUpdate),e.onSelectHour&&this.emitter.on("select:hour",e.onSelectHour),e.onSelectMinute&&this.emitter.on("select:minute",e.onSelectMinute),e.onSelectAM&&this.emitter.on("select:am",e.onSelectAM),e.onSelectPM&&this.emitter.on("select:pm",e.onSelectPM),e.onError&&this.emitter.on("error",e.onError),e.onTimezoneChange&&this.emitter.on("timezone:change",e.onTimezoneChange),e.onRangeConfirm&&this.emitter.on("range:confirm",e.onRangeConfirm),e.onRangeSwitch&&this.emitter.on("range:switch",e.onRangeSwitch),e.onRangeValidation&&this.emitter.on("range:validation",e.onRangeValidation)}mount(){this.core.isDestroyed||(this.core.isInitialized||this.init(),this.eventsBundle())}unmount(e){let t=Ye((...i)=>{if(i.length>2||!this.core.getModalElement())return;let[n]=i.filter(o=>typeof o=="boolean"),[r]=i.filter(o=>typeof o=="function");this.core.setIsMobileView(!!this.core.options.ui.mobile),n&&this.core.getOkButton()?.click(),this.core.setIsTouchMouseMove(!1),this.removeEventListeners(),this.managers.animation.removeAnimationToClose(),this.core.getOpenElement().forEach(o=>o?.classList.remove("disabled")),setTimeout(()=>{f()&&(document.body.style.overflowY="",document.body.style.paddingRight="")},C.SCROLLBAR_RESTORE),setTimeout(()=>{let o=this.core.getInput();this.core.options.behavior.focusInputAfterClose&&o?.focus();let c=this.core.getModalElement();c!==null&&(c.remove(),this.core.setIsModalRemove(!0))},C.MODAL_REMOVE),r&&r()},this.core.options.behavior.delayHandler||C.DEFAULT_DELAY);e?t(e):t()}destroy(e){if(this.core.isDestroyed)return;let t=typeof e=="function"?{callback:e}:e||{},{keepInputValue:i=!1,callback:n}=t,r=this.core.getInput(),s=i?r?.value:null;this.removeEventListeners(),this.core.getModalElement()?.remove(),this.core.getOpenElement()?.forEach(d=>{d&&(d.classList.remove("disabled","active","tp-ui-open-element"),d.classList.remove("basic","crane-straight","crane","m2","m3-green"))}),r&&(r.classList.remove("tp-ui-invalid-format","invalid-value","error","active","tp-ui-input"),r.removeAttribute("data-open"),r.removeAttribute("data-owner-id"),i&&s&&(r.value=s));let l=this.core.element;l&&(l.classList.remove("basic","crane-straight","crane","m2","m3-green"),l.classList.remove("error","active","disabled"),l.removeAttribute("data-owner-id"),l.removeAttribute("data-open"),this.core.options.ui.cssClass&&l.classList.remove(this.core.options.ui.cssClass)),l?.querySelectorAll(".tp-ui-invalid-text")?.forEach(d=>d.remove()),this.mutliEventsMoveHandler=()=>{},this.eventsClickMobileHandler=()=>{},this.core.reset(),this.managers.destroy(),this.emitter.clear(),L()||(document.body.style.overflowY="",document.body.style.paddingRight=""),n&&n()}eventsBundle(){if(this.core.isDestroyed||!this.core.isModalRemove)return;if(this.managers.validation.setErrorHandler(),this.managers.validation.removeErrorHandler(),!this.core.options.ui.inline?.enabled){let r=this.core.getOpenElement(),s=this.core.getInput();r.forEach(o=>o?.classList.add("disabled")),s?.blur()}if(this.managers.modal.setScrollbarOrNot(),this.managers.modal.setModalTemplate(),this.managers.modal.setNormalizeClass(),this.managers.modal.removeBackdrop(),this.core.isMobileView)this.managers.config.updateClockFaceAccessibility(!0);else{let r=this.core.getModalElement(),s=r?.querySelector(".tp-ui-mobile-clock-wrapper"),o=r?.querySelector(".tp-ui-wrapper"),c=r?.querySelectorAll("*");s?.classList.add("expanded"),o?.classList.add("expanded"),c?.forEach(l=>{!l.classList.contains("tp-ui-select-time")&&!l.classList.contains("tp-ui-mobile-clock-wrapper")&&!l.classList.contains("tp-ui-wrapper")&&l.classList.add("expanded")})}this.managers.modal.setFlexEndToFooterIfNoKeyboardIcon(),setTimeout(()=>{this.managers.theme.setTheme();let r=this.core.getWrapper();r&&this.core.options.ui.cssClass&&r.classList.add(this.core.options.ui.cssClass)},0),this.managers.animation.setAnimationToOpen(),this.managers.config.getInputValueOnOpenAndSet(),this.managers.clock.initializeClockSystem(),this.managers.clock.setOnStartCSSClassesIfClockType24h(),this.managers.clock.setClassActiveToHourOnOpen();let e=this.managers.getPlugin("timezone");e&&e.init();let t=this.managers.getPlugin("range");t&&t.init(),this.managers.events.handleCancelButton(),this.managers.events.handleOkButton(),this.managers.events.handleHourEvents(),this.managers.events.handleMinutesEvents(),this.managers.events.handleKeyboardInput(),this.core.options.ui.enableSwitchIcon&&this.managers.events.handleSwitchViewButton(),this.core.options.clock.type!=="24h"&&(this.managers.events.handleAmClick(),this.managers.events.handlePmClick()),this.core.options.behavior.focusTrap&&this.managers.events.focusTrapHandler(),this.core.options.ui.inline?.enabled||(this.managers.events.handleEscClick(),this.managers.events.handleBackdropClick());let i=this.core.getModalElement();i&&Ke(i);let n=this.core.getClockFace();n&&typeof requestAnimationFrame<"u"&&requestAnimationFrame(()=>{requestAnimationFrame(()=>{n?.classList.add("scale-in")})}),this.managers.modal.setShowClassToBackdrop()}removeEventListeners(){if(f()===!1)return;qe.split(" ").forEach(t=>{document.removeEventListener(t,this.mutliEventsMoveHandler,!1)}),document.removeEventListener("mousedown",this.eventsClickMobileHandler)}};var q=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=n=>{t(n),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=>{i(t)})}clear(){this.events.clear()}hasListeners(e){return(this.events.get(e)?.size??0)>0}};var R={clock:{type:"12h",incrementHours:1,incrementMinutes:1,autoSwitchToMinutes:!0,disabledTime:void 0,currentTime:void 0},ui:{theme:"basic",animation:!0,backdrop:!0,mobile:!1,enableSwitchIcon:!1,editable:!1,enableScrollbar:!1,cssClass:void 0,appendModalSelector:"",iconTemplate:"",iconTemplateMobile:"",inline:void 0},labels:{am:"AM",pm:"PM",ok:"OK",cancel:"Cancel",time:"Select time",mobileTime:"Enter Time",mobileHour:"Hour",mobileMinute:"Minute"},behavior:{focusInputAfterClose:!1,focusTrap:!0,delayHandler:300,id:void 0},callbacks:{onOpen:void 0,onCancel:void 0,onConfirm:void 0,onUpdate:void 0,onSelectHour:void 0,onSelectMinute:void 0,onSelectAM:void 0,onSelectPM:void 0,onError:void 0,onTimezoneChange:void 0,onRangeConfirm:void 0,onRangeSwitch:void 0,onRangeValidation:void 0},timezone:{enabled:!1,default:void 0,whitelist:void 0,label:"Timezone"},range:{enabled:!1,minDuration:void 0,maxDuration:void 0,fromLabel:"From",toLabel:"To"}};function Oe(a={}){return{clock:{...R.clock,...a.clock||{}},ui:{...R.ui,...a.ui||{}},labels:{...R.labels,...a.labels||{}},behavior:{...R.behavior,...a.behavior||{}},callbacks:{...R.callbacks,...a.callbacks||{}},timezone:{...R.timezone,...a.timezone||{}},range:{...R.range,...a.range||{}}}}var Ze=a=>a.replace(/[^0-9:APMapm\s]/g,"");var z=new Map,ie=class{core;managers;lifecycle;emitter;constructor(e,t){if(L())throw new Error("TimepickerUI requires browser environment");let i=this.resolveInputElement(e);if(!i)throw new Error("Input element not found");let n=t?.behavior?.id,r=n||`tp-ui-${Ve()}`,s=this.createWrapperElement(i),o=Oe(t||{});if(o.ui.inline?.enabled&&typeof t?.behavior?.focusTrap>"u"&&(o.behavior.focusTrap=!1),o.ui.inline?.enabled){if(!o.ui.inline.containerId)throw new Error("inline.containerId is required when inline mode is enabled");if(!L()&&!document.getElementById(o.ui.inline.containerId))throw new Error(`Container element with id "${o.ui.inline.containerId}" not found`)}this.emitter=new q,this.core=new ne(s,o,r,n);let c=this.core.getInput();if(c){let l=I(c,o.clock.type),u=Number(l.hour)*30,d=Number(l.minutes)*6;this.core.setDegreesHours(u),this.core.setDegreesMinutes(d)}this.managers=new Te(this.core,this.emitter),this.lifecycle=new Ce(this.core,this.managers,this.emitter),this.managers.config.checkMobileOption(),this.managers.config.preventClockTypeByCurrentTime(),this.setupInternalEventListeners(),z.set(this.core.instanceId,this)}setupInternalEventListeners(){this.emitter.on("show",()=>{this.core.isDestroyed||this.lifecycle.mount()}),this.emitter.on("cancel",()=>{this.core.isDestroyed||this.lifecycle.unmount()}),this.emitter.on("confirm",e=>{if(!this.core.isDestroyed){if(this.core.options.range?.enabled)return;let t=this.core.getInput();if(t&&e.hour&&e.minutes){let i=e.type?` ${e.type}`:"";t.value=`${e.hour}:${e.minutes}${i}`}this.lifecycle.unmount()}}),this.emitter.on("range:confirm",e=>{if(this.core.isDestroyed)return;let t=this.core.getInput();t&&(t.value=`${e.from} - ${e.to}`),this.lifecycle.unmount()})}create(){this.lifecycle.init(),this.core.options.ui.inline?.enabled&&this.lifecycle.mount()}open(e){this.lifecycle.mount(),e&&e()}close(e,t){this.lifecycle.unmount(e?t:void 0),!e&&t&&t()}destroy(e){z.delete(this.core.instanceId),this.lifecycle.destroy(e)}update(e,t){this.core.isDestroyed||(this.core.updateOptions(e.options),this.managers.config.checkMobileOption(),e.create&&this.create(),t&&t())}getValue(){if(this.core.isDestroyed)return{hour:"",minutes:"",type:void 0,time:"",degreesHours:null,degreesMinutes:null};let e=this.core.getHour(),t=this.core.getMinutes(),i=this.core.getActiveTypeMode(),n=e?.value||"12",r=t?.value||"00",s=this.core.options.clock.type==="24h"?void 0:i?.textContent||"AM",o="";return this.core.options.clock.type==="24h"?o=`${n.padStart(2,"0")}:${r.padStart(2,"0")}`:o=`${n}:${r.padStart(2,"0")} ${s}`,{hour:n,minutes:r,type:s,time:o,degreesHours:this.core.degreesHours,degreesMinutes:this.core.degreesMinutes}}setValue(e,t=!0){if(this.core.isDestroyed||!e||typeof e!="string")return;this.core.isInitialized||this.create();let i=Ze(e.trim()),n="12",r="00",s="AM";try{if(this.core.options.clock.type==="24h"){let p=i.match(/^([0-1]?[0-9]|2[0-3]):([0-5][0-9])$/);if(!p)throw new Error("Invalid 24h format. Expected HH:MM");n=p[1].padStart(2,"0"),r=p[2]}else{let p=i.match(/^(1[0-2]|[1-9]):([0-5][0-9])\s*(AM|PM)$/i);if(!p)throw new Error("Invalid 12h format. Expected HH:MM AM/PM");n=p[1],r=p[2],s=p[3].toUpperCase()}let o=this.core.getHour(),c=this.core.getMinutes(),l=this.core.getAM(),u=this.core.getPM();if(o&&(o.value=n,o.setAttribute("aria-valuenow",n),this.core.setDegreesHours(Number(n)*30)),c&&(c.value=r,c.setAttribute("aria-valuenow",r),this.core.setDegreesMinutes(Number(r)*6)),this.core.options.clock.type!=="24h"&&l&&u&&(s==="AM"?(l.classList.add("active"),u.classList.remove("active")):(u.classList.add("active"),l.classList.remove("active"))),t){let p=this.core.getInput();p&&(p.value=i)}let d=this.core.getClockHand();d&&(d.style.transform=`rotateZ(${this.core.degreesHours||0}deg)`)}catch{return}}getElement(){return this.core.element}get instanceId(){return this.core.instanceId}get options(){return this.core.options}get isInitialized(){return this.core.isInitialized}get isDestroyed(){return this.core.isDestroyed}get hour(){return this.core.getHour()}get minutes(){return this.core.getMinutes()}get okButton(){return this.core.getOkButton()}get cancelButton(){return this.core.getCancelButton()}get clockHand(){return this.core.getClockHand()}on(e,t){this.core.isDestroyed||this.emitter.on(e,t)}once(e,t){this.core.isDestroyed||this.emitter.once(e,t)}off(e,t){this.core.isDestroyed||this.emitter.off(e,t)}resolveInputElement(e){if(f()===!1)return null;let t=null;if(typeof e=="string"){if(t=document.querySelector(e),!t)return null}else if(e instanceof HTMLElement)t=e;else return null;return t.tagName==="INPUT"?t:t.querySelector("input")}createWrapperElement(e){if(f()===!1)return e;let t=e.parentElement;if(e.tagName==="INPUT"&&!t?.classList.contains("tp-ui")){let i=document.createElement("div");return i.className="tp-ui",e.parentNode?.insertBefore(i,e),i.appendChild(e),i}return t&&!t.classList.contains("tp-ui")&&t.classList.add("tp-ui"),t||e}static getById(e){return z.get(e)}static getAllInstances(){return Array.from(z.values())}static isAvailable(e){return L()?!1:typeof e=="string"?document.querySelector(e)!==null:e instanceof HTMLElement?document.contains(e):!1}static destroyAll(){Array.from(z.values()).forEach(t=>t.destroy()),z.clear()}};var He=ie;var lt=He;0&&(module.exports={EventEmitter,PluginRegistry,TimepickerUI});
package/dist/index.d.ts CHANGED
@@ -62,7 +62,12 @@ type RangeConfirmEventData = {
62
62
 
63
63
  type RangeSwitchEventData = {
64
64
  active: 'from' | 'to';
65
- disabledTime?: { hours: string[]; minutes: string[] } | null;
65
+ disabledTime?: {
66
+ hours: string[];
67
+ minutes: string[];
68
+ fromType?: string;
69
+ fromHour?: number;
70
+ } | null;
66
71
  };
67
72
 
68
73
  type RangeValidationEventData = {
@@ -75,7 +80,7 @@ type RangeValidationEventData = {
75
80
  type RangeMinuteCommitEventData = {
76
81
  hour: string;
77
82
  minutes: string;
78
- type?: string | null;
83
+ type?: string;
79
84
  };
80
85
 
81
86
  type RangeGetDisabledTimeEventData = Record<string, never>;