iobroker.lovelace
Version:
With this adapter you can build visualization for ioBroker with Home Assistant Lovelace UI
1 lines • 26.7 kB
JavaScript
;(self.rspackChunkhome_assistant_frontend=self.rspackChunkhome_assistant_frontend||[]).push([[80827],{69255:function(e,t,n){n.d(t,{_:function(){return o}});n(16280);function o(e,t){if(!Object.prototype.hasOwnProperty.call(e,t))throw new TypeError("attempted to use private field on non-instance");return e}},81787:function(e,t,n){n.d(t,{_:function(){return r}});var o=0;function r(e){return"__private_"+o+++"_"+e}},97686:function(e,t,n){n.a(e,async function(e,t){try{var o=n(86518),r=n(74487),a=(n(89463),n(16280),n(18107),n(44114),n(72712),n(55081),n(18111),n(7588),n(61701),n(18237),n(13579),n(69112),n(33110),n(45367),n(92731),n(3362),n(27495),n(17642),n(58004),n(33853),n(45876),n(32475),n(15024),n(31698),n(67357),n(25440),n(42762),n(62953),n(69255)),s=n(81787),i=e([r]);r=(i.then?(await i)():i)[0];let d,h,p,f,m=e=>e;const y=["type","base"];var l=(0,s._)("_t"),c=(0,s._)("_e");class b{get current(){return(0,a._)(this,l)[l]}set current(e){(0,a._)(this,l)[l]!=e&&((0,a._)(this,l)[l]=e,(0,a._)(this,c)[c].forEach(t=>t(e)))}on(e){return(0,a._)(this,c)[c].add(e),()=>(0,a._)(this,c)[c].delete(e)}constructor(e){Object.defineProperty(this,l,{writable:!0,value:void 0}),Object.defineProperty(this,c,{writable:!0,value:void 0}),(0,a._)(this,c)[c]=new Set,(0,a._)(this,l)[l]=e}}const g=e=>new b(e),v=Symbol.for("atomico.hooks");globalThis[v]=globalThis[v]||{};let w=globalThis[v];const k=Symbol.for("Atomico.suspense"),D=Symbol.for("Atomico.effect"),S=Symbol.for("Atomico.layoutEffect"),C=Symbol.for("Atomico.insertionEffect"),x=(e,t,n)=>{const{i:o,hooks:r}=w.c,a=r[o]=r[o]||{};return a.value=e(a.value),a.effect=t,a.tag=n,w.c.i++,r[o].value},T=e=>x((t=g(e))=>t),O=()=>x((e=g(w.c.host))=>e),j=()=>w.c.update,E=(e,t,n=0)=>{let o={},r=!1;const a=(e,t)=>{for(const n in o){const r=o[n];r.effect&&r.tag===e&&(r.value=r.effect(r.value,t))}};return{load:a=>{let s;w.c={host:t,hooks:o,update:e,i:0,id:n};try{r=!1,s=a()}catch(i){if(i!==k)throw i;r=!0}finally{w.c=null}return s},cleanEffects:e=>(a(C,e),()=>(a(S,e),()=>{a(D,e)})),isSuspense:()=>r}},N=Symbol.for;function M(e,t){const n=e.length;if(n!==t.length)return!1;for(let o=0;o<n;o++){if(e[o]!==t[o])return!1}return!0}const _=e=>"function"==typeof e,P=e=>"object"==typeof e,{isArray:U}=Array,$=(e,t)=>(!t||e instanceof HTMLStyleElement)&&"hydrate"in((null==e?void 0:e.dataset)||{});function A(e,t){let n;const o=e=>{let{length:r}=e;for(let a=0;a<r;a++){const r=e[a];if(r&&Array.isArray(r))o(r);else{const e=typeof r;if(null==r||"function"===e||"boolean"===e)continue;"string"===e||"number"===e?(null==n&&(n=""),n+=r):(null!=n&&(t(n),n=null),t(r))}}};o(e),null!=n&&t(n)}const F=(e,t,n)=>(e.addEventListener(t,n),()=>e.removeEventListener(t,n));class Y{constructor(e,t,n){this.message=t,this.target=e,this.value=n}}class q extends Y{}class z extends Y{}const B="Custom",L=null,I={true:1,"":1,1:1};function W(e,t,n,o,r){const{type:a,reflect:s,event:i,value:l,attr:c=R(t)}=(null==n?void 0:n.name)!=B&&P(n)&&n!=L?n:{type:n},u=(null==a?void 0:a.name)===B&&a.map,d=null!=l?a!=Function&&_(l)?l:()=>l:null;Object.defineProperty(e,t,{configurable:!0,set(e){const n=this[t];d&&a!=Boolean&&null==e&&(e=d());const{error:o,value:r}=(u?K:Z)(a,e);if(o&&null!=r)throw new q(this,`The value defined for prop '${t}' must be of type '${a.name}'`,r);n!=r&&(this._props[t]=null!=r?r:void 0,this.update(),i&&H(this,i),this.updated.then(()=>{s&&(this._ignoreAttr=c,V(this,a,c,this[t]),this._ignoreAttr=null)}))},get(){return this._props[t]}}),d&&(r[t]=d()),o[c]={prop:t,type:a}}const H=(e,t)=>{let{type:n,base:r=CustomEvent}=t,a=(0,o.A)(t,y);return e.dispatchEvent(new r(n,a))},R=e=>e.replace(/([A-Z])/g,"-$1").toLowerCase(),V=(e,t,n,o)=>null==o||t==Boolean&&!o?e.removeAttribute(n):e.setAttribute(n,(null==t?void 0:t.name)===B&&null!=t&&t.serialize?null==t?void 0:t.serialize(o):P(o)?JSON.stringify(o):t==Boolean?"":o),J=(e,t)=>e==Boolean?!!I[t]:e==Number?Number(t):e==String?t:e==Array||e==Object?JSON.parse(t):e.name==B?t:new e(t),K=({map:e},t)=>{try{return{value:e(t),error:!1}}catch(n){return{value:t,error:!0}}},Z=(e,t)=>null==e||null==t?{value:t,error:!1}:e!=String&&""===t?{value:void 0,error:!1}:e==Object||e==Array||e==Symbol?{value:t,error:{}.toString.call(t)!==`[object ${e.name}]`}:t instanceof e?{value:t,error:e==Number&&Number.isNaN(t.valueOf())}:e==String||e==Number||e==Boolean?{value:t,error:e==Number?"number"!=typeof t||Number.isNaN(t):e==String?"string"!=typeof t:"boolean"!=typeof t}:{value:t,error:!0};let G=0;const Q=e=>{var t;return(null===(t=(null==e?void 0:e.dataset)||{})||void 0===t?void 0:t.hydrate)||""||"c"+G++},X=(e,t=HTMLElement)=>{const n={},o={},r="prototype"in t&&t.prototype instanceof Element,a=r?t:"base"in t?t.base:HTMLElement,{props:s,styles:i}=r?e:t;return class extends a{static get styles(){return[super.styles,i]}async _setup(){if(this._props)return;let e,t;this._props={},this.mounted=new Promise(n=>this.mount=()=>{n(),e!=this.parentNode&&(t!=e?this.unmounted.then(this.update):this.update()),e=this.parentNode}),this.unmounted=new Promise(o=>this.unmount=()=>{o(),(e!=this.parentNode||!this.isConnected)&&(n.cleanEffects(!0)()(),t=this.parentNode,e=null)}),this.symbolId=this.symbolId||Symbol(),this.symbolIdParent=Symbol();const n=E(()=>this.update(),this,Q(this));let o,r=!0;const a=$(this);this.update=()=>(o||(o=!0,this.updated=(this.updated||this.mounted).then(()=>{try{const e=n.load(this._render),t=n.cleanEffects();return e&&e.render(this,this.symbolId,a),o=!1,r&&!n.isSuspense()&&(r=!1,!a&&ee(this)),t()}finally{o=!1}}).then(e=>{e&&e()})),this.updated),this.update()}connectedCallback(){this.mount(),super.connectedCallback&&super.connectedCallback()}disconnectedCallback(){super.disconnectedCallback&&super.disconnectedCallback(),this.unmount()}attributeChangedCallback(e,t,o){if(n[e]){if(e===this._ignoreAttr||t===o)return;const{prop:a,type:s}=n[e];try{this[a]=J(s,o)}catch(r){throw new z(this,`The value defined as attr '${e}' cannot be parsed by type '${s.name}'`,o)}}else super.attributeChangedCallback(e,t,o)}static get props(){return Object.assign(Object.assign({},super.props),s)}static get observedAttributes(){const e=super.observedAttributes||[];for(const t in s)W(this.prototype,t,s[t],n,o);return Object.keys(n).concat(e)}constructor(){super(),this._setup(),this._render=()=>e(Object.assign({},this._props));for(const e in o)this[e]=o[e]}}};function ee(e){const{styles:t}=e.constructor,{shadowRoot:n}=e;if(n&&t.length){const e=[];A(t,t=>{t&&(t instanceof Element?n.appendChild(t.cloneNode(!0)):e.push(t))}),e.length&&(n.adoptedStyleSheets=e)}}const te=e=>(t,n)=>{x(([e,t]=[])=>((t||!t)&&(t&&M(t,n)?e=e||!0:(_(e)&&e(),e=null)),[e,n]),([e,n],o)=>o?(_(e)&&e(),[]):[e||t(),n],e)},ne=te(D),oe=te(C);class re extends Array{constructor(e,t){let n=!0;const o=e=>{try{t(e,this,n)}finally{n=!1}};super(void 0,o,t),o(e)}}const ae=e=>{const t=j();return x((n=new re(e,(e,n,o)=>{(e=_(e)?e(n[0]):e)!==n[0]&&(n[0]=e,o||t())}))=>n)},se=(e,t)=>{const[n]=x(([n,o,r=0]=[])=>((!o||o&&!M(o,t))&&(n=e()),[n,t,r]));return n},ie=e=>{const{current:t}=O();if(!(e in t))throw new q(t,`For useProp("${e}"), the prop does not exist on the host.`,e);return x((n=new re(t[e],(n,o)=>{n=_(n)?n(t[e]):n,t[e]=n}))=>(n[0]=t[e],n))},le=(e,t={})=>{const n=O();return n[e]||(n[e]=(o=t.detail)=>H(n.current,Object.assign(Object.assign({type:e},t),{},{detail:o}))),n[e]},ce=N("atomico/options");globalThis[ce]=globalThis[ce]||{sheet:!!document.adoptedStyleSheets};const ue=globalThis[ce],de=new Promise(e=>{ue.ssr||("loading"===document.readyState?F(document,"DOMContentLoaded",e):e())}),he={checked:1,value:1,selected:1},pe={list:1,type:1,size:1,form:1,width:1,height:1,src:1,href:1,slot:1},fe={shadowDom:1,staticNode:1,cloneNode:1,children:1,key:1},me={},ye=[];class be extends Text{}const ge=N("atomico/id"),ve=N("atomico/type"),we=N("atomico/ref"),ke=N("atomico/vnode"),De=()=>{};function Se(e,t,n){return xe(this,e,t,n)}const Ce=(e,t,...n)=>{const o=t||me;let{children:r}=o;if(r=null!=r?r:n.length?n:ye,e===De)return r;const a=e?e instanceof Node?1:e.prototype instanceof HTMLElement&&2:0;if(!1===a&&e instanceof Function)return e(r!=ye?Object.assign({children:r},o):o);const s=ue.render||Se;return{[ve]:ke,type:e,props:o,children:r,key:o.key,shadow:o.shadowDom,static:o.staticNode,raw:a,is:o.is,clone:o.cloneNode,render:s}};function xe(e,t,n=ge,o,r){let a;if(t&&t[n]&&t[n].vnode==e||e[ve]!=ke)return t;(e||!t)&&(r=r||"svg"==e.type,a="host"!=e.type&&(1==e.raw?(t&&e.clone?t[we]:t)!=e.type:2==e.raw?!(t instanceof e.type):t?t[we]||t.localName!=e.type:!t),a&&null!=e.type&&(1==e.raw&&e.clone?(o=!0,(t=e.type.cloneNode(!0))[we]=e.type):t=1==e.raw?e.type:2==e.raw?new e.type:r?document.createElementNS("http://www.w3.org/2000/svg",e.type):document.createElement(e.type,e.is?{is:e.is}:void 0)));const s=t[n]?t[n]:me,{vnode:i=me,cycle:l=0}=s;let{fragment:c,handlers:u}=s;const{children:d=ye,props:h=me}=i;if(u=a?{}:u||{},e.static&&!a)return t;if(e.shadow&&!t.shadowRoot&&t.attachShadow(Object.assign({mode:"open"},e.shadow)),e.props!=h&&je(t,h,e.props,u,r),e.children!==d){const a=e.shadow?t.shadowRoot:t;c=Oe(e.children,c,a,n,!l&&o,(!r||"foreignObject"!=e.type)&&r)}return t[n]={vnode:e,handlers:u,fragment:c,cycle:l+1},t}function Te(e,t){const n=new be(""),o=new be("");let r;if(e[t?"prepend":"append"](n),t){let{lastElementChild:t}=e;for(;t;){const{previousElementSibling:e}=t;if($(t,!0)&&!$(e,!0)){r=t;break}t=e}}return r?r.before(o):e.append(o),{markStart:n,markEnd:o}}function Oe(e,t,n,o,r,a){e=null==e?null:U(e)?e:[e];const s=t||Te(n,r),{markStart:i,markEnd:l,keyes:c}=s;let u;const d=c&&new Set;let h=i;if(e&&A(e,e=>{if("object"==typeof e&&!e[ve])return;const t=e[ve]&&e.key,s=c&&null!=t&&c.get(t);h!=l&&h===s?d.delete(h):h=h==l?l:h.nextSibling;const i=c?s:h;let p=i;if(e[ve])p=xe(e,i,o,r,a);else{const t=e+"";!(p instanceof Text)||p instanceof be?p=new Text(t):p.data!=t&&(p.data=t)}p!=h&&(c&&d.delete(p),!i||c?(n.insertBefore(p,h),c&&h!=l&&d.add(h)):i==l?n.insertBefore(p,l):(n.replaceChild(p,i),h=p)),null!=t&&(u=u||new Map,u.set(t,p))}),h=h==l?l:h.nextSibling,t&&h!=l)for(;h!=l;){const e=h;h=h.nextSibling,e.remove()}return d&&d.forEach(e=>e.remove()),s.keyes=u,s}function je(e,t,n,o,r){for(const a in t)!(a in n)&&Ee(e,a,t[a],null,r,o);for(const a in n)Ee(e,a,t[a],n[a],r,o)}function Ee(e,t,n,o,r,a){if(n=null!=n?n:null,o=null!=o?o:null,(t="class"!=t||r?t:"className")in e&&he[t]&&(n=e[t]),o!==n&&!fe[t]&&"_"!=t[0])if("slot"===e.localName&&"assignNode"===t&&"assign"in e)e.assign(o);else if("o"==t[0]&&"n"==t[1]&&(_(o)||_(n)))Ne(e,t.slice(2),o,a);else if("ref"==t)o&&(_(o)?o(e):o.current=e);else if("style"==t){const{style:t}=e;o=o||"";const r=P(n=n||""),a=P(o);if(r)for(const e in n){if(!a)break;!(e in o)&&Me(t,e,null)}if(a)for(const e in o){const a=o[e];r&&n[e]===a||Me(t,e,a)}else t.cssText=o}else{const a="$"==t[0]?t.slice(1):t;a===t&&(!r&&!pe[t]&&t in e||_(o)||_(n))?e[t]=null!=o?o:"":null==o?e.removeAttribute(a):e.setAttribute(a,P(o)?JSON.stringify(o):o)}}function Ne(e,t,n,o){if(o.handleEvent||(o.handleEvent=t=>o[t.type].call(e,t)),n){if(!o[t]){const r=n.capture||n.once||n.passive?Object.assign({},n):null;e.addEventListener(t,o,r)}o[t]=n}else o[t]&&(e.removeEventListener(t,o),delete o[t])}function Me(e,t,n){let o="setProperty";null==n&&(o="removeProperty",n=null),~t.indexOf("-")?e[o](t,n):e[t]=n}const _e=Ce("host",{style:"display: contents"}),Pe="value",Ue=(e,t)=>{const n=O(),o=T();oe(()=>F(n.current,"ConnectContext",t=>{t.composedPath().at(0)!==t.currentTarget&&e===t.detail.id&&(t.stopPropagation(),t.detail.connect(o))}),[e]),o.current=t},$e=e=>{const t=le("ConnectContext",{bubbles:!0,composed:!0}),[n,o]=ae(()=>{if(ue.ssr)return;let n;return t({id:e,connect(e){n=e}}),n}),r=j();return ne(()=>{de.then(()=>t({id:e,connect:o}))},[e]),ne(()=>{if(n)return n.on(r)},[n]),(null==n?void 0:n.current)||e[Pe]},Ae=e=>{const t=X(({value:e})=>(Ue(t,e),_e),{props:{value:{type:Object,value:()=>e}}});return t[Pe]=e,t};Ae({dispatch(e,t){}});const Fe={};function Ye(e,...t){const n=(e.raw||e).reduce((e,n,o)=>e+n+(t[o]||""),"");return Fe[n]=Fe[n]||qe(n)}function qe(e){if(ue.sheet){const t=new CSSStyleSheet;return t.replaceSync(e),t}{const t=document.createElement("style");return t.textContent=e,t}}const ze=(e,t,n)=>(null==t?t={key:n}:t.key=n,Ce(e,t)),Be=ze,Le=Ye(d||(d=m`*,*:before,*:after{box-sizing:border-box}button{padding:0;touch-action:manipulation;cursor:pointer;user-select:none}`)),Ie=Ye(h||(h=m`.vh{position:absolute;transform:scale(0)}`));function We(){const e=new Date;return new nt(e.getFullYear(),e.getMonth()+1,e.getDate())}const He=864e5;function Re(e){const t=Xe(e);t.setUTCDate(t.getUTCDate()+3-(t.getUTCDay()+6)%7);const n=new Date(Date.UTC(t.getUTCFullYear(),0,4));return 1+Math.round(((t.getTime()-n.getTime())/He-3+(n.getUTCDay()+6)%7)/7)}function Ve(e,t=0){const n=Xe(e),o=n.getUTCDay(),r=(o<t?7:0)+o-t;return n.setUTCDate(n.getUTCDate()-r),nt.from(n)}function Je(e,t=0){return Ve(e,t).add({days:6})}function Ke(e){return nt.from(new Date(Date.UTC(e.year,e.month,0)))}function Ze(e,t,n){return t&&nt.compare(e,t)<0?t:n&&nt.compare(e,n)>0?n:e}const Ge={days:1};function Qe(e,t=0){let n=Ve(e.toPlainDate(),t);const o=Je(Ke(e),t),r=[];for(;nt.compare(n,o)<0;){const e=[];for(let t=0;t<7;t++)e.push(n),n=n.add(Ge);r.push(e)}return r}function Xe(e){var t;return new Date(Date.UTC(e.year,e.month-1,null!==(t=e.day)&&void 0!==t?t:1))}const et=/^(\d{4})-(0[1-9]|1[0-2])-(0[1-9]|[12][0-9]|3[0-1])$/,tt=(e,t)=>e.toString().padStart(t,"0");class nt{add(e){const t=Xe(this);if("days"in e)return t.setUTCDate(this.day+e.days),nt.from(t);let{year:n,month:o}=this;"months"in e?(o=this.month+e.months,t.setUTCMonth(o-1)):(n=this.year+e.years,t.setUTCFullYear(n));const r=nt.from(Xe({year:n,month:o,day:1}));return Ze(nt.from(t),r,Ke(r))}toString(){return`${tt(this.year,4)}-${tt(this.month,2)}-${tt(this.day,2)}`}toPlainYearMonth(){return new ot(this.year,this.month)}equals(e){return 0===nt.compare(this,e)}static compare(e,t){return e.year<t.year?-1:e.year>t.year?1:e.month<t.month?-1:e.month>t.month?1:e.day<t.day?-1:e.day>t.day?1:0}static from(e){if("string"==typeof e){const t=e.match(et);if(!t)throw new TypeError(e);const[,n,o,r]=t;return new nt(parseInt(n,10),parseInt(o,10),parseInt(r,10))}return new nt(e.getUTCFullYear(),e.getUTCMonth()+1,e.getUTCDate())}constructor(e,t,n){this.year=e,this.month=t,this.day=n}}class ot{add(e){var t,n;const o=Xe(this),r=(null!==(t=e.months)&&void 0!==t?t:0)+12*(null!==(n=e.years)&&void 0!==n?n:0);return o.setUTCMonth(o.getUTCMonth()+r),new ot(o.getUTCFullYear(),o.getUTCMonth()+1)}equals(e){return this.year===e.year&&this.month===e.month}toPlainDate(){return new nt(this.year,this.month,1)}static compare(e,t){return e.year<t.year?-1:e.year>t.year?1:e.month<t.month?-1:e.month>t.month?1:0}constructor(e,t){this.year=e,this.month=t}}function rt(e,t){if(t)try{return e.from(t)}catch(n){}}function at(e){const[t,n]=ie(e);return[se(()=>rt(nt,t),[t]),e=>n(null==e?void 0:e.toString())]}function st(e){const[t="",n]=ie(e);return[se(()=>{const[e,n]=t.split("/"),o=rt(nt,e),r=rt(nt,n);return o&&r?[o,r]:[]},[t]),e=>n(`${e[0]}/${e[1]}`)]}function it(e){const[t="",n]=ie(e);return[se(()=>{const e=[];for(const n of t.trim().split(/\s+/)){const t=rt(nt,n);t&&e.push(t)}return e},[t]),e=>n(e.join(" "))]}function lt(e,t){return se(()=>new Intl.DateTimeFormat(t,Object.assign({timeZone:"UTC"},e)),[t,e])}function ct(e,t,n){const o=lt(e,n);return se(()=>{const e=[],n=new Date;for(var r=0;r<7;r++){e[(n.getUTCDay()-t+7)%7]=o.format(n),n.setUTCDate(n.getUTCDate()+1)}return e},[t,o])}const ut=(e,t,n)=>Ze(e,t,n)===e,dt=e=>e.target.matches(":dir(ltr)"),ht={month:"long",day:"numeric"},pt={month:"long"},ft={weekday:"long"},mt={bubbles:!0};function yt({props:e,context:t}){const{offset:n}=e,{firstDayOfWeek:o,isDateDisallowed:r,min:a,max:s,today:i,page:l,locale:c,focusedDate:u,formatWeekday:d}=t,h=null!=i?i:We(),p=ct(ft,o,c),f=ct(se(()=>({weekday:d}),[d]),o,c),m=lt(ht,c),y=lt(pt,c),b=se(()=>l.start.add({months:n}),[l,n]),g=se(()=>Qe(b,o),[b,o]),v=le("focusday",mt),w=le("selectday",mt),k=le("hoverday",mt);function D(e){v(Ze(e,a,s))}function S(e){let t;switch(e.key){case"ArrowRight":t=u.add({days:dt(e)?1:-1});break;case"ArrowLeft":t=u.add({days:dt(e)?-1:1});break;case"ArrowDown":t=u.add({days:7});break;case"ArrowUp":t=u.add({days:-7});break;case"PageUp":t=u.add(e.shiftKey?{years:-1}:{months:-1});break;case"PageDown":t=u.add(e.shiftKey?{years:1}:{months:1});break;case"Home":t=Ve(u,o);break;case"End":t=Je(u,o);break;default:return}D(t),e.preventDefault()}return{weeks:g,yearMonth:b,daysLong:p,daysVisible:f,formatter:y,getDayProps:function(e){var n,o,i;const l=b.equals(e);if(!t.showOutsideDays&&!l)return;const c=e.equals(u),d=e.equals(h),p=Xe(e),f=null==r?void 0:r(p),y=!ut(e,a,s);let g,v="";if("range"===t.type){const[n,o]=t.value,r=null==n?void 0:n.equals(e),a=null==o?void 0:o.equals(e);g=n&&o&&ut(e,n,o),v=`${r?"range-start":""} ${a?"range-end":""} ${!g||r||a?"":"range-inner"}`}else g="multi"===t.type?t.value.some(t=>t.equals(e)):null===(n=t.value)||void 0===n?void 0:n.equals(e);return{part:`button day day-${p.getUTCDay()} ${l?g?"selected":"":"outside"} ${f?"disallowed":""} ${d?"today":""} ${null!==(o=null===(i=t.getDayParts)||void 0===i?void 0:i.call(t,p))&&void 0!==o?o:""} ${v}`,tabindex:l&&c?0:-1,disabled:y,"aria-disabled":f?"true":void 0,"aria-pressed":l&&g,"aria-current":d?"date":void 0,"aria-label":m.format(p),onkeydown:S,onclick(){f||w(e),D(e)},onmouseover(){!f&&!y&&k(e)}}}}}const bt=We(),gt=Ae({type:"date",firstDayOfWeek:1,focusedDate:bt,page:{start:bt.toPlainYearMonth(),end:bt.toPlainYearMonth()}});customElements.define("calendar-ctx",gt);const vt=(e,t)=>(t+e)%7,wt=X(e=>{const t=$e(gt),n=T(),o=yt({props:e,context:t});return Be("host",{shadowDom:!0,focus:function(){var e;null===(e=n.current.querySelector("button[tabindex='0']"))||void 0===e||e.focus()},children:[ze("div",{id:"h",part:"heading",children:o.formatter.format(Xe(o.yearMonth))}),Be("table",{ref:n,"aria-labelledby":"h",part:"table",children:[Be("colgroup",{children:[t.showWeekNumbers&&ze("col",{part:"col-weeknumber"}),ze("col",{part:"col-1"}),ze("col",{part:"col-2"}),ze("col",{part:"col-3"}),ze("col",{part:"col-4"}),ze("col",{part:"col-5"}),ze("col",{part:"col-6"}),ze("col",{part:"col-7"})]}),ze("thead",{children:Be("tr",{part:"tr head",children:[t.showWeekNumbers&&ze("th",{part:"th weeknumber",children:Be("slot",{name:"weeknumber",children:[ze("span",{class:"vh",children:"Week"}),ze("span",{"aria-hidden":"true",children:"#"})]})}),o.daysLong.map((e,n)=>Be("th",{part:`th day day-${vt(t.firstDayOfWeek,n)}`,scope:"col",children:[ze("span",{class:"vh",children:e}),ze("span",{"aria-hidden":"true",children:o.daysVisible[n]})]}))]})}),ze("tbody",{children:o.weeks.map((e,n)=>Be("tr",{part:"tr week",children:[t.showWeekNumbers&&ze("th",{class:"num",part:"th weeknumber",scope:"row",children:Re(e[0])}),e.map((e,t)=>{const n=o.getDayProps(e);return ze("td",{part:"td",children:n&&ze("button",Object.assign(Object.assign({class:"num"},n),{},{children:e.day}))},t)})]},n))})]})]})},{props:{offset:{type:Number,value:0}},styles:[Le,Ie,Ye(p||(p=m`:host{--color-accent: black;--color-text-on-accent: white;display:flex;flex-direction:column;gap:.25rem;text-align:center;inline-size:fit-content}table{border-collapse:collapse;font-size:.875rem}th{inline-size:2.25rem;block-size:2.25rem}td{padding-inline:0}.num{font-variant-numeric:tabular-nums}button{color:inherit;font-size:inherit;background:transparent;border:0;block-size:2.25rem;inline-size:2.25rem}button:hover:where(:not(:disabled,[aria-disabled])){background:#0000000d}button:is([aria-pressed=true],:focus-visible){background:var(--color-accent);color:var(--color-text-on-accent)}button:focus-visible{outline:1px solid var(--color-text-on-accent);outline-offset:-2px}button:disabled,:host::part(outside),:host::part(disallowed){cursor:default;opacity:.5}`))]});function kt(e){return ze("button",{part:`button ${e.name} ${e.onclick?"":"disabled"}`,onclick:e.onclick,"aria-disabled":e.onclick?null:"true",children:ze("slot",{name:e.name,children:e.children})})}function Dt(e){const t=Xe(e.page.start),n=Xe(e.page.end);return ze(gt,{value:e,onselectday:e.onSelect,onfocusday:e.onFocus,onhoverday:e.onHover,children:Be("div",{role:"group","aria-labelledby":"h",part:"container",children:[ze("div",{id:"h",class:"vh","aria-live":"polite","aria-atomic":"true",children:e.formatVerbose.formatRange(t,n)}),Be("div",{part:"header",children:[ze(kt,{name:"previous",onclick:e.previous,children:"Previous"}),ze("slot",{part:"heading",name:"heading",children:ze("div",{"aria-hidden":"true",children:e.format.formatRange(t,n)})}),ze(kt,{name:"next",onclick:e.next,children:"Next"})]}),ze("slot",{part:"months"})]})})}customElements.define("calendar-month",wt);const St={value:{type:String,value:""},min:{type:String,value:""},max:{type:String,value:""},today:{type:String,value:""},isDateDisallowed:{type:Function,value:e=>!1},formatWeekday:{type:String,value:()=>"narrow"},getDayParts:{type:Function,value:e=>""},firstDayOfWeek:{type:Number,value:()=>1},showOutsideDays:{type:Boolean,value:!1},locale:{type:String,value:()=>{}},months:{type:Number,value:1},focusedDate:{type:String,value:()=>{}},pageBy:{type:String,value:()=>"months"},showWeekNumbers:{type:Boolean,value:!1}},Ct=[Le,Ie,Ye(f||(f=m`:host{display:block;inline-size:fit-content}:host::part(container){display:flex;flex-direction:column;gap:1em}:host::part(header){display:flex;align-items:center;justify-content:space-between}:host::part(heading){font-weight:700;font-size:1.25em}:host::part(button){display:flex;align-items:center;justify-content:center}:host::part(button disabled){cursor:default;opacity:.5}`))],xt={year:"numeric"},Tt={year:"numeric",month:"long"};function Ot(e,t){return 12*(t.year-e.year)+t.month-e.month}const jt=(e,t)=>({start:e=12===t?new ot(e.year,1):e,end:e.add({months:t-1})});function Et({pageBy:e,focusedDate:t,months:n,max:o,min:r,goto:a}){const s="single"===e?1:n,[i,l]=ae(()=>jt(t.toPlainYearMonth(),n)),c=e=>l(jt(i.start.add({months:e}),n)),u=e=>{const t=Ot(i.start,e.toPlainYearMonth());return t>=0&&t<n};return ne(()=>{if(u(t))return;const e=Ot(t.toPlainYearMonth(),i.start);a(t.add({months:e}))},[i.start]),ne(()=>{if(u(t))return;const e=Ot(i.start,t.toPlainYearMonth());c(-1===e?-s:e===n?s:Math.floor(e/n)*n)},[t,s,n]),{page:i,previous:r&&u(r)?void 0:()=>c(-s),next:o&&u(o)?void 0:()=>c(s)}}function Nt({months:e,pageBy:t,locale:n,focusedDate:o,setFocusedDate:r}){const[a]=at("min"),[s]=at("max"),[i]=at("today"),l=le("focusday"),c=le("change"),u=se(()=>{var e;return Ze(null!==(e=null!=o?o:i)&&void 0!==e?e:We(),a,s)},[o,i,a,s]);function d(e){r(e),l(Xe(e))}const{next:h,previous:p,page:f}=Et({pageBy:t,focusedDate:u,months:e,min:a,max:s,goto:d}),m=O();function y(e){var t;const n=null!==(t=null==e?void 0:e.target)&&void 0!==t?t:"day";"day"===n?m.current.querySelectorAll("calendar-month").forEach(t=>t.focus(e)):m.current.shadowRoot.querySelector(`[part~='${n}']`).focus(e)}return{format:lt(xt,n),formatVerbose:lt(Tt,n),page:f,focusedDate:u,dispatch:c,onFocus(e){e.stopPropagation(),d(e.detail),setTimeout(y)},min:a,max:s,today:i,next:h,previous:p,focus:y}}const Mt=X(e=>{const[t,n]=at("value"),[o=t,r]=at("focusedDate"),a=Nt(Object.assign(Object.assign({},e),{},{focusedDate:o,setFocusedDate:r}));return ze("host",{shadowDom:!0,focus:a.focus,children:ze(Dt,Object.assign(Object.assign(Object.assign({},e),a),{},{type:"date",value:t,onSelect:function(e){n(e.detail),a.dispatch()}}))})},{props:St,styles:Ct});function _t(e){return Be(De,{children:[ze("label",{part:"label",for:"s",children:ze("slot",{name:"label",children:e.label})}),ze("select",{id:"s",part:"select",onchange:e.onChange,children:e.options.map(e=>ze("option",Object.assign({part:"option"},e)))})]})}customElements.define("calendar-date",Mt);const Pt=[Le,Ie];function Ut(e,t){return Array.from({length:e},(e,n)=>t(n))}function $t(e){var t,n;const{min:o,max:r,focusedDate:a}=$e(gt),s=le("focusday",{bubbles:!0}),i=a.toPlainYearMonth(),l=i.year,c=Math.floor(e.maxYears/2),u=l-c,d=l+(e.maxYears-c-1),h=Math.max(u,null!==(t=null==o?void 0:o.year)&&void 0!==t?t:-1/0);return{options:Ut(Math.min(d,null!==(n=null==r?void 0:r.year)&&void 0!==n?n:1/0)-h+1,e=>{const t=h+e;return{label:`${t}`,value:`${t}`,selected:t===i.year}}),onChange:function(e){const t=parseInt(e.currentTarget.value)-i.year;s(a.add({years:t}))}}}const At=X(e=>{const t=$t(e);return ze("host",{shadowDom:!0,children:ze(_t,Object.assign({label:"Year"},t))})},{props:{maxYears:{type:Number,value:20}},styles:Pt});function Ft(e){const{min:t,max:n,focusedDate:o,locale:r}=$e(gt),a=le("focusday",{bubbles:!0}),s=lt(se(()=>({month:e.formatMonth}),[e.formatMonth]),r),i=se(()=>{const e=[],t=new Date;t.setUTCDate(1);for(var n=0;n<12;n++){e[(t.getUTCMonth()+12)%12]=s.format(t),t.setUTCMonth(t.getUTCMonth()+1)}return e},[s]),l=o.toPlainYearMonth();return{options:i.map((e,o)=>{const r=o+1,a=l.add({months:r-l.month});return{label:e,value:`${r}`,disabled:null!=t&&ot.compare(a,t)<0||null!=n&&ot.compare(a,n)>0,selected:r===l.month}}),onChange:function(e){const t=parseInt(e.currentTarget.value)-l.month;a(o.add({months:t}))}}}customElements.define("calendar-select-year",At);const Yt=X(e=>{const t=Ft(e);return ze("host",{shadowDom:!0,children:ze(_t,Object.assign({label:"Month"},t))})},{props:{formatMonth:{type:String,value:()=>"long"}},styles:Pt});customElements.define("calendar-select-month",Yt);const qt=(e,t)=>nt.compare(e,t)<0?[e,t]:[t,e],zt=X(e=>{const[t,n]=st("value"),[o=t[0],r]=at("focusedDate"),a=Nt(Object.assign(Object.assign({},e),{},{focusedDate:o,setFocusedDate:r})),s=le("rangestart"),i=le("rangeend"),[l,c]=at("tentative"),[u,d]=ae();function h(e){e.stopPropagation(),l&&d(e.detail)}ne(()=>d(void 0),[l]);const p=l?qt(l,null!=u?u:l):t;return ze("host",{shadowDom:!0,focus:a.focus,children:ze(Dt,Object.assign(Object.assign(Object.assign({},e),a),{},{type:"range",value:p,onFocus:function(e){a.onFocus(e),h(e)},onHover:h,onSelect:function(e){const t=e.detail;e.stopPropagation(),l?(n(qt(l,t)),c(void 0),i(Xe(t)),a.dispatch()):(c(t),s(Xe(t)))}}))})},{props:Object.assign(Object.assign({},St),{},{tentative:{type:String,value:""}}),styles:Ct});customElements.define("calendar-range",zt);const Bt=X(e=>{const[t,n]=it("value"),[o=t[0],r]=at("focusedDate"),a=Nt(Object.assign(Object.assign({},e),{},{focusedDate:o,setFocusedDate:r}));return ze("host",{shadowDom:!0,focus:a.focus,children:ze(Dt,Object.assign(Object.assign(Object.assign({},e),a),{},{type:"multi",value:t,onSelect:function(e){const o=[...t],r=t.findIndex(t=>t.equals(e.detail));r<0?o.push(e.detail):o.splice(r,1),n(o),a.dispatch()}}))})},{props:St,styles:Ct});customElements.define("calendar-multi",Bt),t()}catch(u){t(u)}})}}]);