calkit 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,517 @@
1
+ (function(b,v){typeof exports=="object"&&typeof module<"u"?v(exports):typeof define=="function"&&define.amd?define(["exports"],v):(b=typeof globalThis<"u"?globalThis:b||self,v(b.CalTimepicker={}))})(this,(function(b){"use strict";class v extends HTMLElement{constructor(){super(),this.attachShadow({mode:"open"}),this._initialized=!1}static get styles(){return[]}connectedCallback(){this._initialized||(this._adoptStyles(),this._initialized=!0),this.render()}_adoptStyles(){const e=this.constructor.styles;if(e.length)if("adoptedStyleSheets"in this.shadowRoot)this.shadowRoot.adoptedStyleSheets=e.map(s=>{if(s instanceof CSSStyleSheet)return s;const t=new CSSStyleSheet;return t.replaceSync(s),t});else for(const s of e){const t=document.createElement("style");t.textContent=s instanceof CSSStyleSheet?"":s,this.shadowRoot.prepend(t)}}render(){}emit(e,s={}){this.dispatchEvent(new CustomEvent(e,{detail:s,bubbles:!0,composed:!0}))}showStatus(e,s,t={}){if(!this._store)return;const{autoDismiss:a,dismissible:i=!0}=t;clearTimeout(this._statusTimer),this._store.set({statusType:e,statusMessage:s,statusDismissible:i}),this.emit("cal:status",{type:e,message:s}),a&&a>0&&(this._statusTimer=setTimeout(()=>this.clearStatus(),a))}clearStatus(){this._store&&(clearTimeout(this._statusTimer),this._store.set({statusType:null,statusMessage:null,statusDismissible:!0}),this.emit("cal:status",{type:null,message:null}))}$(e){return this.shadowRoot.querySelector(e)}$$(e){return this.shadowRoot.querySelectorAll(e)}}function E(r){let e={...r};const s=new Set;return{get(t){return e[t]},set(t){const a=e;e={...e,...t};let i=!1;for(const l of Object.keys(t))if(a[l]!==e[l]){i=!0;break}if(i)for(const l of s)l(e,a)},getState(){return e},subscribe(t){return s.add(t),()=>s.delete(t)}}}function x(r){if(!r||typeof r!="string")return null;const e=r.trim().toUpperCase(),s=e.match(/^(\d{1,2}):(\d{2})\s*(AM|PM)$/);if(s){let a=parseInt(s[1],10);const i=parseInt(s[2],10),l=s[3];return l==="AM"&&a===12&&(a=0),l==="PM"&&a!==12&&(a+=12),{hours:a,minutes:i}}const t=e.match(/^(\d{1,2}):(\d{2})$/);return t?{hours:parseInt(t[1],10),minutes:parseInt(t[2],10)}:null}function _(r,e,s="24h"){const t=String(e).padStart(2,"0");if(s==="12h"){const a=r>=12?"PM":"AM";return`${r%12||12}:${t} ${a}`}return`${String(r).padStart(2,"0")}:${t}`}function g(r){const e=x(r);return e?e.hours*60+e.minutes:0}function S(r){const e=Math.floor(r/60)%24,s=r%60;return`${String(e).padStart(2,"0")}:${String(s).padStart(2,"0")}`}function M(r,e,s){const t=[],a=g(r),i=g(e);for(let l=a;l<=i;l+=s)t.push(S(l));return t}function z(r,e,s,t="24h"){const a=[],i=g(r),l=g(e);for(let c=i;c<=l;c+=s){const u=S(c),h=c+s,m=S(Math.min(h,l+s)),d=x(u),n=x(m),o=d?_(d.hours,d.minutes,t):u,p=n?_(n.hours,n.minutes,t):m;a.push({time:u,displayText:`${o}–${p}`})}return a}function w(r,e,s){const t=g(r),a=g(e),i=g(s),l=Math.min(a,i),c=Math.max(a,i);return t>=l&&t<=c}const $=`
2
+ :host {
3
+ /* Light theme (default) */
4
+ --cal-bg: 0 0% 100%;
5
+ --cal-bg-muted: 240 5% 96%;
6
+ --cal-fg: 240 6% 10%;
7
+ --cal-fg-muted: 240 4% 46%;
8
+ --cal-border: 240 6% 90%;
9
+ --cal-accent: 240 6% 10%;
10
+ --cal-accent-fg: 0 0% 100%;
11
+ --cal-accent-subtle: 240 5% 96%;
12
+ --cal-hover: 240 5% 93%;
13
+ --cal-ring: 240 6% 10%;
14
+ --cal-radius: 8px;
15
+ --cal-radius-sm: 6px;
16
+ --cal-cell-size: 36px;
17
+ --cal-transition: 150ms ease;
18
+
19
+ /* Booking color palette (softer / less saturated) */
20
+ --cal-booking-blue-bg: 217 55% 94%;
21
+ --cal-booking-blue-fg: 217 60% 35%;
22
+ --cal-booking-green-bg: 152 45% 93%;
23
+ --cal-booking-green-fg: 152 55% 28%;
24
+ --cal-booking-red-bg: 4 50% 94%;
25
+ --cal-booking-red-fg: 4 55% 40%;
26
+ --cal-booking-orange-bg: 30 55% 93%;
27
+ --cal-booking-orange-fg: 30 60% 35%;
28
+ --cal-booking-gray-bg: 240 8% 94%;
29
+ --cal-booking-gray-fg: 240 8% 38%;
30
+
31
+ /* Booking hover tokens */
32
+ --cal-booking-blue-hover: 217 55% 88%;
33
+ --cal-booking-green-hover: 152 45% 87%;
34
+ --cal-booking-red-hover: 4 50% 88%;
35
+ --cal-booking-orange-hover: 30 55% 87%;
36
+ --cal-booking-gray-hover: 240 8% 88%;
37
+
38
+ /* Scheduler tokens */
39
+ --cal-sched-grid-line: 240 6% 94%;
40
+ --cal-sched-now-line: 4 70% 55%;
41
+ --cal-sched-slot-hover: 240 5% 97%;
42
+ --cal-sched-header-bg: 240 5% 98%;
43
+
44
+ /* Status tokens */
45
+ --cal-status-error-bg: 4 50% 95%;
46
+ --cal-status-error-fg: 4 55% 40%;
47
+ --cal-status-error-border: 4 50% 85%;
48
+ --cal-status-warning-bg: 40 55% 95%;
49
+ --cal-status-warning-fg: 40 60% 35%;
50
+ --cal-status-warning-border: 40 50% 85%;
51
+ --cal-status-info-bg: 217 55% 95%;
52
+ --cal-status-info-fg: 217 60% 35%;
53
+ --cal-status-info-border: 217 50% 85%;
54
+ --cal-status-success-bg: 152 45% 95%;
55
+ --cal-status-success-fg: 152 55% 28%;
56
+ --cal-status-success-border: 152 45% 85%;
57
+ }
58
+
59
+ :host([theme="dark"]) {
60
+ --cal-bg: 240 6% 10%;
61
+ --cal-bg-muted: 240 4% 16%;
62
+ --cal-fg: 0 0% 98%;
63
+ --cal-fg-muted: 240 4% 54%;
64
+ --cal-border: 240 4% 20%;
65
+ --cal-accent: 0 0% 98%;
66
+ --cal-accent-fg: 240 6% 10%;
67
+ --cal-accent-subtle: 240 4% 16%;
68
+ --cal-hover: 240 4% 20%;
69
+ --cal-ring: 0 0% 98%;
70
+
71
+ --cal-booking-blue-bg: 217 50% 25%;
72
+ --cal-booking-blue-fg: 217 80% 75%;
73
+ --cal-booking-green-bg: 142 40% 22%;
74
+ --cal-booking-green-fg: 142 70% 70%;
75
+ --cal-booking-red-bg: 4 45% 25%;
76
+ --cal-booking-red-fg: 4 70% 75%;
77
+ --cal-booking-orange-bg: 30 45% 25%;
78
+ --cal-booking-orange-fg: 30 80% 75%;
79
+ --cal-booking-gray-bg: 240 5% 22%;
80
+ --cal-booking-gray-fg: 240 5% 65%;
81
+
82
+ --cal-booking-blue-hover: 217 50% 30%;
83
+ --cal-booking-green-hover: 142 40% 27%;
84
+ --cal-booking-red-hover: 4 45% 30%;
85
+ --cal-booking-orange-hover: 30 45% 30%;
86
+ --cal-booking-gray-hover: 240 5% 27%;
87
+
88
+ --cal-sched-grid-line: 240 4% 18%;
89
+ --cal-sched-now-line: 4 55% 55%;
90
+ --cal-sched-slot-hover: 240 4% 14%;
91
+ --cal-sched-header-bg: 240 5% 12%;
92
+
93
+ --cal-status-error-bg: 4 45% 20%;
94
+ --cal-status-error-fg: 4 70% 75%;
95
+ --cal-status-error-border: 4 45% 30%;
96
+ --cal-status-warning-bg: 40 45% 20%;
97
+ --cal-status-warning-fg: 40 80% 75%;
98
+ --cal-status-warning-border: 40 45% 30%;
99
+ --cal-status-info-bg: 217 50% 20%;
100
+ --cal-status-info-fg: 217 80% 75%;
101
+ --cal-status-info-border: 217 50% 30%;
102
+ --cal-status-success-bg: 152 40% 18%;
103
+ --cal-status-success-fg: 152 70% 70%;
104
+ --cal-status-success-border: 152 40% 28%;
105
+ }
106
+
107
+ :host([theme="auto"]) {
108
+ --cal-bg: 0 0% 100%;
109
+ --cal-bg-muted: 240 5% 96%;
110
+ --cal-fg: 240 6% 10%;
111
+ --cal-fg-muted: 240 4% 46%;
112
+ --cal-border: 240 6% 90%;
113
+ --cal-accent: 240 6% 10%;
114
+ --cal-accent-fg: 0 0% 100%;
115
+ --cal-accent-subtle: 240 5% 96%;
116
+ --cal-hover: 240 5% 93%;
117
+ --cal-ring: 240 6% 10%;
118
+ }
119
+
120
+ @media (prefers-color-scheme: dark) {
121
+ :host([theme="auto"]) {
122
+ --cal-bg: 240 6% 10%;
123
+ --cal-bg-muted: 240 4% 16%;
124
+ --cal-fg: 0 0% 98%;
125
+ --cal-fg-muted: 240 4% 54%;
126
+ --cal-border: 240 4% 20%;
127
+ --cal-accent: 0 0% 98%;
128
+ --cal-accent-fg: 240 6% 10%;
129
+ --cal-accent-subtle: 240 4% 16%;
130
+ --cal-hover: 240 4% 20%;
131
+ --cal-ring: 0 0% 98%;
132
+
133
+ --cal-booking-blue-bg: 217 50% 25%;
134
+ --cal-booking-blue-fg: 217 80% 75%;
135
+ --cal-booking-green-bg: 142 40% 22%;
136
+ --cal-booking-green-fg: 142 70% 70%;
137
+ --cal-booking-red-bg: 4 45% 25%;
138
+ --cal-booking-red-fg: 4 70% 75%;
139
+ --cal-booking-orange-bg: 30 45% 25%;
140
+ --cal-booking-orange-fg: 30 80% 75%;
141
+ --cal-booking-gray-bg: 240 5% 22%;
142
+ --cal-booking-gray-fg: 240 5% 65%;
143
+
144
+ --cal-booking-blue-hover: 217 50% 30%;
145
+ --cal-booking-green-hover: 142 40% 27%;
146
+ --cal-booking-red-hover: 4 45% 30%;
147
+ --cal-booking-orange-hover: 30 45% 30%;
148
+ --cal-booking-gray-hover: 240 5% 27%;
149
+
150
+ --cal-sched-grid-line: 240 4% 18%;
151
+ --cal-sched-now-line: 4 55% 55%;
152
+ --cal-sched-slot-hover: 240 4% 14%;
153
+ --cal-sched-header-bg: 240 5% 12%;
154
+
155
+ --cal-status-error-bg: 4 45% 20%;
156
+ --cal-status-error-fg: 4 70% 75%;
157
+ --cal-status-error-border: 4 45% 30%;
158
+ --cal-status-warning-bg: 40 45% 20%;
159
+ --cal-status-warning-fg: 40 80% 75%;
160
+ --cal-status-warning-border: 40 45% 30%;
161
+ --cal-status-info-bg: 217 50% 20%;
162
+ --cal-status-info-fg: 217 80% 75%;
163
+ --cal-status-info-border: 217 50% 30%;
164
+ --cal-status-success-bg: 152 40% 18%;
165
+ --cal-status-success-fg: 152 70% 70%;
166
+ --cal-status-success-border: 152 40% 28%;
167
+ }
168
+ }
169
+ `,O=`
170
+ :host {
171
+ display: inline-block;
172
+ font-family: inherit;
173
+ font-size: 14px;
174
+ line-height: 1.5;
175
+ color: hsl(var(--cal-fg));
176
+ -webkit-font-smoothing: antialiased;
177
+ -moz-osx-font-smoothing: grayscale;
178
+ }
179
+
180
+ :host([display="inline"]) {
181
+ display: inline-block;
182
+ }
183
+
184
+ *,
185
+ *::before,
186
+ *::after {
187
+ box-sizing: border-box;
188
+ }
189
+
190
+ button {
191
+ font: inherit;
192
+ color: inherit;
193
+ background: none;
194
+ border: none;
195
+ padding: 0;
196
+ margin: 0;
197
+ cursor: pointer;
198
+ -webkit-tap-highlight-color: transparent;
199
+ }
200
+
201
+ button:focus-visible {
202
+ outline: 2px solid hsl(var(--cal-ring));
203
+ outline-offset: 2px;
204
+ border-radius: var(--cal-radius-sm);
205
+ }
206
+
207
+ [hidden] {
208
+ display: none !important;
209
+ }
210
+ `,B=`
211
+ @keyframes cal-fade-in {
212
+ from { opacity: 0; }
213
+ to { opacity: 1; }
214
+ }
215
+
216
+ @keyframes cal-slide-up {
217
+ from {
218
+ opacity: 0;
219
+ transform: translateY(4px);
220
+ }
221
+ to {
222
+ opacity: 1;
223
+ transform: translateY(0);
224
+ }
225
+ }
226
+
227
+ @keyframes cal-slide-left {
228
+ from {
229
+ opacity: 0;
230
+ transform: translateX(16px);
231
+ }
232
+ to {
233
+ opacity: 1;
234
+ transform: translateX(0);
235
+ }
236
+ }
237
+
238
+ @keyframes cal-slide-right {
239
+ from {
240
+ opacity: 0;
241
+ transform: translateX(-16px);
242
+ }
243
+ to {
244
+ opacity: 1;
245
+ transform: translateX(0);
246
+ }
247
+ }
248
+
249
+ .cal-animate-fade { animation: cal-fade-in 150ms cubic-bezier(0.16, 1, 0.3, 1); }
250
+ .cal-animate-slide-up { animation: cal-slide-up 200ms cubic-bezier(0.16, 1, 0.3, 1); }
251
+ .cal-animate-slide-left { animation: cal-slide-left 200ms cubic-bezier(0.16, 1, 0.3, 1); }
252
+ .cal-animate-slide-right { animation: cal-slide-right 200ms cubic-bezier(0.16, 1, 0.3, 1); }
253
+
254
+ @keyframes cal-shimmer {
255
+ 0% { background-position: -200% 0; }
256
+ 100% { background-position: 200% 0; }
257
+ }
258
+
259
+ .cal-skeleton {
260
+ background: linear-gradient(
261
+ 90deg,
262
+ hsl(var(--cal-bg-muted)) 25%,
263
+ hsl(var(--cal-hover)) 50%,
264
+ hsl(var(--cal-bg-muted)) 75%
265
+ );
266
+ background-size: 200% 100%;
267
+ animation: cal-shimmer 1.5s infinite ease-in-out;
268
+ border-radius: 999px;
269
+ }
270
+
271
+ .cal-skeleton--rect {
272
+ border-radius: var(--cal-radius-sm);
273
+ }
274
+ `;function R({trigger:r,content:e,onClose:s}){const t=document.createElement("div");t.classList.add("cal-popover"),t.setAttribute("role","dialog"),t.setAttribute("aria-modal","false"),t.style.display="none",t.appendChild(e);let a=!1;function i(){t.classList.remove("cal-popover--above");const d=r.getBoundingClientRect(),n=t.offsetHeight,o=window.innerHeight-d.bottom,p=d.top;o<n+8&&p>o?(t.classList.add("cal-popover--above"),t.style.top="auto",t.style.bottom="100%",t.style.marginBottom="4px",t.style.marginTop="0"):(t.style.top="100%",t.style.bottom="auto",t.style.marginTop="4px",t.style.marginBottom="0")}function l(){a||(a=!0,t.style.display="",t.classList.add("cal-animate-slide-up"),requestAnimationFrame(()=>i()),document.addEventListener("click",u,!0),document.addEventListener("keydown",h,!0))}function c(){a&&(a=!1,t.style.display="none",t.classList.remove("cal-animate-slide-up"),document.removeEventListener("click",u,!0),document.removeEventListener("keydown",h,!0),s==null||s())}function u(d){var o;const n=(o=r.getRootNode())==null?void 0:o.host;n&&!n.contains(d.target)&&d.target!==n&&c()}function h(d){d.key==="Escape"&&(d.stopPropagation(),c())}function m(){a&&(a=!1,t.style.display="none",t.classList.remove("cal-animate-slide-up")),document.removeEventListener("click",u,!0),document.removeEventListener("keydown",h,!0)}return{panel:t,open:l,close:c,destroy:m,get isOpen(){return a}}}const j=`
275
+ .cal-popover-wrapper {
276
+ position: relative;
277
+ display: inline-block;
278
+ }
279
+
280
+ .cal-popover {
281
+ position: absolute;
282
+ left: 0;
283
+ z-index: 50;
284
+ background: hsl(var(--cal-bg));
285
+ border: 1px solid hsl(var(--cal-border));
286
+ border-radius: var(--cal-radius);
287
+ box-shadow: 0 4px 16px -2px rgba(0, 0, 0, 0.08), 0 2px 6px -2px rgba(0, 0, 0, 0.04);
288
+ padding: 12px;
289
+ }
290
+
291
+ .cal-trigger {
292
+ display: inline-flex;
293
+ align-items: center;
294
+ gap: 8px;
295
+ height: 36px;
296
+ padding: 0 12px;
297
+ font-size: 14px;
298
+ border: 1px solid hsl(var(--cal-border));
299
+ border-radius: var(--cal-radius-sm);
300
+ background: hsl(var(--cal-bg));
301
+ color: hsl(var(--cal-fg));
302
+ cursor: pointer;
303
+ transition: border-color var(--cal-transition);
304
+ white-space: nowrap;
305
+ }
306
+
307
+ .cal-trigger:hover {
308
+ border-color: hsl(var(--cal-fg-muted));
309
+ }
310
+
311
+ .cal-trigger--placeholder {
312
+ color: hsl(var(--cal-fg-muted));
313
+ }
314
+
315
+ .cal-trigger__icon {
316
+ display: flex;
317
+ color: hsl(var(--cal-fg-muted));
318
+ }
319
+ `;function H(r){const{slots:e=[],mode:s="single",format:t="24h",selected:a,hoverTime:i,rangeStart:l,unavailableTimes:c=[],onSelect:u,onHover:h,durationLabels:m=!1}=r,d=document.createElement("div");d.classList.add("cal-time-grid"),m&&d.classList.add("cal-time-grid--duration"),d.setAttribute("role","listbox"),s==="multi"&&d.setAttribute("aria-multiselectable","true");for(const n of e){const o=document.createElement("button");o.classList.add("cal-time-slot"),o.setAttribute("role","option"),o.dataset.time=n.time;const p=x(n.time),F=n.displayText?n.displayText:p?_(p.hours,p.minutes,t):n.time,T=document.createElement("span");if(T.classList.add("cal-time-slot__time"),T.textContent=F,o.appendChild(T),n.label){const f=document.createElement("span");f.classList.add("cal-time-slot__label"),f.textContent=n.label,o.appendChild(f)}const A=n.available===!1||c.includes(n.time);if(A&&(o.classList.add("cal-time-slot--unavailable"),o.disabled=!0,o.setAttribute("aria-disabled","true")),I(n.time,a,s)?(o.classList.add("cal-time-slot--selected"),o.setAttribute("aria-selected","true")):o.setAttribute("aria-selected","false"),s==="range"&&l&&!P(a)&&i){const f=w(n.time,l,i),k=n.time===l,y=n.time===i;f&&!k&&!y&&o.classList.add("cal-time-slot--in-range"),k&&o.classList.add("cal-time-slot--range-start"),y&&o.classList.add("cal-time-slot--range-end")}else if(s==="range"&&a&&typeof a=="object"&&a.start&&a.end){const f=w(n.time,a.start,a.end),k=n.time===a.start,y=n.time===a.end;k&&o.classList.add("cal-time-slot--range-start","cal-time-slot--selected"),y&&o.classList.add("cal-time-slot--range-end","cal-time-slot--selected"),f&&!k&&!y&&o.classList.add("cal-time-slot--in-range")}A||(o.addEventListener("click",()=>u==null?void 0:u(n.time)),o.addEventListener("mouseenter",()=>h==null?void 0:h(n.time))),d.appendChild(o)}return d.addEventListener("mouseleave",()=>h==null?void 0:h(null)),d}function I(r,e,s){return e?s==="single"?e===r:s==="multi"?Array.isArray(e)&&e.includes(r):s==="range"&&typeof e=="object"&&e.start&&e.end?e.start===r||e.end===r:!1:!1}function P(r){return r&&typeof r=="object"&&r.start&&r.end}const D=`
320
+ .cal-time-grid {
321
+ display: grid;
322
+ grid-template-columns: repeat(auto-fill, minmax(80px, 1fr));
323
+ gap: 6px;
324
+ max-height: 280px;
325
+ overflow-y: auto;
326
+ padding: 4px;
327
+ }
328
+
329
+ .cal-time-grid::-webkit-scrollbar {
330
+ width: 6px;
331
+ }
332
+
333
+ .cal-time-grid::-webkit-scrollbar-track {
334
+ background: transparent;
335
+ }
336
+
337
+ .cal-time-grid::-webkit-scrollbar-thumb {
338
+ background: hsl(var(--cal-border));
339
+ border-radius: 3px;
340
+ }
341
+
342
+ .cal-time-slot {
343
+ display: flex;
344
+ flex-direction: column;
345
+ align-items: center;
346
+ justify-content: center;
347
+ height: 40px;
348
+ padding: 0 8px;
349
+ border-radius: 999px;
350
+ font-size: 13px;
351
+ background: hsl(var(--cal-bg-muted));
352
+ color: hsl(var(--cal-fg));
353
+ transition: background var(--cal-transition), color var(--cal-transition);
354
+ gap: 1px;
355
+ }
356
+
357
+ .cal-time-slot:not(.cal-time-slot--unavailable):not(.cal-time-slot--selected):hover {
358
+ background: hsl(var(--cal-hover));
359
+ }
360
+
361
+ .cal-time-slot__time {
362
+ font-weight: 500;
363
+ line-height: 1;
364
+ }
365
+
366
+ .cal-time-slot__label {
367
+ font-size: 9px;
368
+ opacity: 0.7;
369
+ line-height: 1;
370
+ }
371
+
372
+ .cal-time-slot--selected {
373
+ background: hsl(var(--cal-accent));
374
+ color: hsl(var(--cal-accent-fg));
375
+ font-weight: 600;
376
+ }
377
+
378
+ .cal-time-slot--in-range {
379
+ background: hsl(var(--cal-accent-subtle));
380
+ }
381
+
382
+ .cal-time-slot--range-start,
383
+ .cal-time-slot--range-end {
384
+ background: hsl(var(--cal-accent));
385
+ color: hsl(var(--cal-accent-fg));
386
+ font-weight: 600;
387
+ }
388
+
389
+ .cal-time-slot--unavailable {
390
+ opacity: 0.3;
391
+ cursor: not-allowed;
392
+ }
393
+
394
+ .cal-time-grid--duration {
395
+ grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
396
+ }
397
+
398
+ .cal-time-grid--duration .cal-time-slot {
399
+ font-size: 12px;
400
+ }
401
+ `;function X({columns:r=3,rows:e=4,durationLabels:s=!1}={}){const t=document.createElement("div");t.setAttribute("role","status"),t.setAttribute("aria-label","Loading..."),t.classList.add("cal-skeleton-time-grid"),s&&t.classList.add("cal-skeleton-time-grid--duration");const a=r*e;for(let i=0;i<a;i++){const l=document.createElement("div");l.classList.add("cal-skeleton"),t.appendChild(l)}return t}const q=`
402
+ .cal-skeleton-time-grid {
403
+ display: grid;
404
+ grid-template-columns: repeat(auto-fill, minmax(80px, 1fr));
405
+ gap: 6px;
406
+ padding: 4px;
407
+ }
408
+
409
+ .cal-skeleton-time-grid--duration {
410
+ grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
411
+ }
412
+
413
+ .cal-skeleton-time-grid .cal-skeleton {
414
+ height: 40px;
415
+ }
416
+
417
+ .cal-skeleton-calendar-grid {
418
+ display: grid;
419
+ grid-template-columns: repeat(7, 1fr);
420
+ gap: 2px;
421
+ padding: 4px;
422
+ }
423
+
424
+ .cal-skeleton-calendar-grid__header {
425
+ height: 20px;
426
+ margin-bottom: 4px;
427
+ }
428
+
429
+ .cal-skeleton-calendar-grid__day {
430
+ height: var(--cal-cell-size, 36px);
431
+ aspect-ratio: 1;
432
+ border-radius: var(--cal-radius-sm) !important;
433
+ }
434
+ `,L={error:'<svg width="14" height="14" viewBox="0 0 14 14" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round"><circle cx="7" cy="7" r="6"/><path d="M7 4v3M7 9.5v.01"/></svg>',warning:'<svg width="14" height="14" viewBox="0 0 14 14" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round"><path d="M7 1.5L1 12.5h12L7 1.5zM7 6v2.5M7 10.5v.01"/></svg>',info:'<svg width="14" height="14" viewBox="0 0 14 14" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round"><circle cx="7" cy="7" r="6"/><path d="M7 6.5V10M7 4.5v.01"/></svg>',success:'<svg width="14" height="14" viewBox="0 0 14 14" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round"><circle cx="7" cy="7" r="6"/><path d="M4.5 7l2 2L9.5 5"/></svg>'};function G({type:r="info",message:e,dismissible:s=!0,onDismiss:t}){const a=document.createElement("div");a.classList.add("cal-status",`cal-status--${r}`,"cal-animate-slide-up"),a.setAttribute("role",r==="error"?"alert":"status"),a.setAttribute("aria-live",r==="error"?"assertive":"polite");const i=document.createElement("span");i.classList.add("cal-status__icon"),i.innerHTML=L[r]||L.info,a.appendChild(i);const l=document.createElement("span");if(l.classList.add("cal-status__text"),l.textContent=e,a.appendChild(l),s){const c=document.createElement("button");c.classList.add("cal-status__close"),c.setAttribute("aria-label","Dismiss"),c.innerHTML='<svg width="12" height="12" viewBox="0 0 12 12" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round"><path d="M3 3l6 6M9 3l-6 6"/></svg>',c.addEventListener("click",()=>t==null?void 0:t()),a.appendChild(c)}return a}const N=`
435
+ .cal-status {
436
+ display: flex;
437
+ align-items: center;
438
+ gap: 8px;
439
+ padding: 8px 12px;
440
+ border-radius: var(--cal-radius-sm);
441
+ font-size: 12px;
442
+ line-height: 1.4;
443
+ margin-bottom: 8px;
444
+ }
445
+
446
+ .cal-status__icon {
447
+ flex-shrink: 0;
448
+ display: flex;
449
+ }
450
+
451
+ .cal-status__text {
452
+ flex: 1;
453
+ min-width: 0;
454
+ }
455
+
456
+ .cal-status__close {
457
+ flex-shrink: 0;
458
+ display: flex;
459
+ align-items: center;
460
+ justify-content: center;
461
+ width: 20px;
462
+ height: 20px;
463
+ border-radius: 4px;
464
+ cursor: pointer;
465
+ opacity: 0.7;
466
+ transition: opacity var(--cal-transition);
467
+ }
468
+
469
+ .cal-status__close:hover {
470
+ opacity: 1;
471
+ }
472
+
473
+ .cal-status--error {
474
+ background: hsl(var(--cal-status-error-bg));
475
+ color: hsl(var(--cal-status-error-fg));
476
+ border: 1px solid hsl(var(--cal-status-error-border));
477
+ }
478
+
479
+ .cal-status--warning {
480
+ background: hsl(var(--cal-status-warning-bg));
481
+ color: hsl(var(--cal-status-warning-fg));
482
+ border: 1px solid hsl(var(--cal-status-warning-border));
483
+ }
484
+
485
+ .cal-status--info {
486
+ background: hsl(var(--cal-status-info-bg));
487
+ color: hsl(var(--cal-status-info-fg));
488
+ border: 1px solid hsl(var(--cal-status-info-border));
489
+ }
490
+
491
+ .cal-status--success {
492
+ background: hsl(var(--cal-status-success-bg));
493
+ color: hsl(var(--cal-status-success-fg));
494
+ border: 1px solid hsl(var(--cal-status-success-border));
495
+ }
496
+ `,Y='<svg width="16" height="16" viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"><circle cx="8" cy="8" r="6"/><path d="M8 4.5V8l2.5 1.5"/></svg>',U=`
497
+ .cal-timepicker {
498
+ background: hsl(var(--cal-bg));
499
+ border-radius: var(--cal-radius);
500
+ user-select: none;
501
+ min-width: 200px;
502
+ }
503
+
504
+ :host([display="inline"]) .cal-timepicker {
505
+ border: 1px solid hsl(var(--cal-border));
506
+ padding: 12px;
507
+ }
508
+
509
+ .cal-timepicker__header {
510
+ font-size: 14px;
511
+ font-weight: 600;
512
+ color: hsl(var(--cal-fg));
513
+ margin-bottom: 8px;
514
+ padding: 0 4px;
515
+ }
516
+ `;class C extends v{static get styles(){return[$,O,B,D,j,q,N,U]}static get observedAttributes(){return["mode","display","theme","start-time","end-time","interval","format","placeholder","value","duration-labels","loading"]}constructor(){super(),this._store=E({selected:null,rangeStart:null,hoverTime:null,isOpen:!1,statusType:null,statusMessage:null,statusDismissible:!0}),this._slots=null,this._unavailableTimes=[],this._popover=null,this._unsubscribe=null,this._rendering=!1}get mode(){return this.getAttribute("mode")||"single"}get display(){return this.getAttribute("display")||"inline"}get placeholder(){return this.getAttribute("placeholder")||"Select time"}get startTime(){return this.getAttribute("start-time")||"09:00"}get endTime(){return this.getAttribute("end-time")||"17:00"}get interval(){return parseInt(this.getAttribute("interval")||"30",10)}get format(){return this.getAttribute("format")||"24h"}get durationLabels(){return this.hasAttribute("duration-labels")}get loading(){return this.hasAttribute("loading")}set loading(e){e?this.setAttribute("loading",""):this.removeAttribute("loading")}get slots(){return this._slots}set slots(e){this._slots=Array.isArray(e)?e:null,this._initialized&&this.render()}get unavailableTimes(){return this._unavailableTimes}set unavailableTimes(e){this._unavailableTimes=Array.isArray(e)?e:[],this._initialized&&this.render()}get value(){return this._store.getState().selected}set value(e){this.mode==="single"&&typeof e=="string"?this._store.set({selected:e,rangeStart:null}):this.mode==="multi"&&Array.isArray(e)?this._store.set({selected:[...e].sort((s,t)=>g(s)-g(t)),rangeStart:null}):this.mode==="range"&&e&&typeof e=="object"?this._store.set({selected:{start:e.start,end:e.end},rangeStart:null}):this._store.set({selected:null,rangeStart:null})}_getEffectiveSlots(){return this._slots?this._slots:this.durationLabels?z(this.startTime,this.endTime,this.interval,this.format).map(t=>({...t,available:!this._unavailableTimes.includes(t.time)})):M(this.startTime,this.endTime,this.interval).map(s=>({time:s,available:!this._unavailableTimes.includes(s)}))}connectedCallback(){super.connectedCallback(),this._unsubscribe=this._store.subscribe((s,t)=>{if(this._rendering)return;s.hoverTime!==t.hoverTime&&s.selected===t.selected&&s.rangeStart===t.rangeStart&&s.isOpen===t.isOpen?this._updateSlotHighlight(s):this.render()});const e=this.getAttribute("value");if(e)if(this.mode==="multi"&&e.includes(","))this.value=e.split(",").map(s=>s.trim());else if(this.mode==="range"&&e.includes("/")){const[s,t]=e.split("/");this.value={start:s.trim(),end:t.trim()}}else this.value=e}disconnectedCallback(){var e,s;(e=this._unsubscribe)==null||e.call(this),(s=this._popover)==null||s.destroy(),clearTimeout(this._statusTimer)}attributeChangedCallback(e,s,t){if(s!==t){if(e==="value"&&this._initialized)if(this.mode==="multi"&&t&&t.includes(","))this.value=t.split(",").map(a=>a.trim());else if(this.mode==="range"&&t&&t.includes("/")){const[a,i]=t.split("/");this.value={start:a.trim(),end:i.trim()}}else this.value=t;this._initialized&&this.render()}}_handleSelect(e){const s=this._store.getState();if(this.mode==="single")this._store.set({selected:e}),this.emit("cal:time-change",{value:e}),this.display==="popover"&&this.close();else if(this.mode==="multi"){const t=Array.isArray(s.selected)?[...s.selected]:[],a=t.indexOf(e);a>=0?t.splice(a,1):t.push(e),t.sort((i,l)=>g(i)-g(l)),this._store.set({selected:t}),this.emit("cal:time-change",{value:t})}else if(this.mode==="range")if(!s.rangeStart||s.selected&&typeof s.selected=="object"&&s.selected.start&&s.selected.end)this._store.set({rangeStart:e,selected:null,hoverTime:null});else{let t=s.rangeStart,a=e;g(t)>g(a)&&([t,a]=[a,t]);const i={start:t,end:a};this._store.set({selected:i,rangeStart:null,hoverTime:null}),this.emit("cal:time-change",{value:i}),this.display==="popover"&&this.close()}}_handleHover(e){this.mode==="range"&&this._store.set({hoverTime:e})}_updateSlotHighlight(e){const s=this.$$(".cal-time-slot"),{rangeStart:t,hoverTime:a,selected:i}=e,l=i&&typeof i=="object"&&i.start&&i.end;for(const c of s){const u=c.dataset.time;if(!(!u||c.disabled))if(t&&!l&&a){const h=g(t)<g(a)?t:a,m=g(t)<g(a)?a:t,d=g(u),n=d>g(h)&&d<g(m),o=u===t,p=u===a;c.classList.toggle("cal-time-slot--range-start",o),c.classList.toggle("cal-time-slot--range-end",p),c.classList.toggle("cal-time-slot--in-range",n)}else t||c.classList.remove("cal-time-slot--range-start","cal-time-slot--range-end","cal-time-slot--in-range")}}open(){this._popover&&(this._popover.open(),this._store.set({isOpen:!0}),this.emit("cal:open"))}close(){this._popover&&(this._popover.close(),this._store.set({isOpen:!1}),this.emit("cal:close"))}_renderTimepickerContent(){const e=this._store.getState(),s=document.createElement("div");s.classList.add("cal-timepicker"),e.statusType&&e.statusMessage&&s.appendChild(G({type:e.statusType,message:e.statusMessage,dismissible:e.statusDismissible,onDismiss:()=>this.clearStatus()}));const t=document.createElement("div");if(t.classList.add("cal-timepicker__header"),t.textContent="Select Time",s.appendChild(t),this.loading)s.appendChild(X({durationLabels:this.durationLabels}));else{const a=this._getEffectiveSlots(),i=H({slots:a,mode:this.mode,format:this.format,selected:e.selected,hoverTime:e.hoverTime,rangeStart:e.rangeStart,unavailableTimes:this._unavailableTimes,onSelect:l=>this._handleSelect(l),onHover:l=>this._handleHover(l),durationLabels:this.durationLabels});s.appendChild(i)}return s}_formatTriggerText(){const e=this._store.getState();return e.selected?this.mode==="single"&&typeof e.selected=="string"?e.selected:this.mode==="multi"&&Array.isArray(e.selected)&&e.selected.length?`${e.selected.length} time${e.selected.length>1?"s":""} selected`:this.mode==="range"&&typeof e.selected=="object"&&e.selected.start?`${e.selected.start} – ${e.selected.end}`:null:null}render(){var t;if(this._rendering)return;this._rendering=!0;const e=this.shadowRoot,s=[...e.childNodes];for(const a of s)a.nodeName!=="STYLE"&&!(a instanceof CSSStyleSheet)&&e.removeChild(a);if((t=this._popover)==null||t.destroy(),this._popover=null,this.display==="popover"){const a=document.createElement("div");a.classList.add("cal-popover-wrapper");const i=document.createElement("button");i.classList.add("cal-trigger");const l=document.createElement("span");l.classList.add("cal-trigger__icon"),l.innerHTML=Y,i.appendChild(l);const c=this._formatTriggerText(),u=document.createElement("span");c?u.textContent=c:(u.textContent=this.placeholder,u.classList.add("cal-trigger--placeholder")),i.appendChild(u),a.appendChild(i);const h=this._renderTimepickerContent(),m=R({trigger:i,content:h,onClose:()=>{this._store.set({isOpen:!1}),this.emit("cal:close")}});a.appendChild(m.panel),e.appendChild(a),i.addEventListener("click",d=>{d.stopPropagation(),m.isOpen?this.close():this.open()}),this._popover=m,this._store.get("isOpen")&&m.open()}else e.appendChild(this._renderTimepickerContent());this._rendering=!1}}customElements.get("cal-timepicker")||customElements.define("cal-timepicker",C),b.CalTimepicker=C,Object.defineProperty(b,Symbol.toStringTag,{value:"Module"})}));
517
+ //# sourceMappingURL=timepicker.umd.js.map