import{strftime as e,makeFormatter as t,isDayFirst as n}from"./utils.js";import i from"./extended-time-element.js";const o=new WeakMap;export default class LocalTimeElement extends i{attributeChangedCallback(e,t,n){"hour"!==e&&"minute"!==e&&"second"!==e&&"time-zone-name"!==e||o.delete(this),super.attributeChangedCallback(e,t,n)}getFormattedDate(){const i=this.date;if(!i)return;const r=function formatDate(t,i){const o={weekday:{short:"%a",long:"%A"},day:{numeric:"%e","2-digit":"%d"},month:{short:"%b",long:"%B"},year:{numeric:"%Y","2-digit":"%y"}};let r=n()?"weekday day month year":"weekday month day, year";for(const e in o){const n=o[e][t.getAttribute(e)||""];r=r.replace(e,n||"")}return r=r.replace(/(\s,)|(,\s$)/,""),e(i,r).replace(/\s+/," ").trim()}(this,i)||"",m=function formatTime(n,i){const r={},m=n.getAttribute("hour");"numeric"!==m&&"2-digit"!==m||(r.hour=m);const a=n.getAttribute("minute");"numeric"!==a&&"2-digit"!==a||(r.minute=a);const s=n.getAttribute("second");"numeric"!==s&&"2-digit"!==s||(r.second=s);const c=n.getAttribute("time-zone-name");"short"!==c&&"long"!==c||(r.timeZoneName=c);if(0===Object.keys(r).length)return;let l=o.get(n);l||(l=t(r),o.set(n,l));const u=l();if(u)return u.format(i);{const t=r.second?"%H:%M:%S":"%H:%M";return e(i,t)}}(this,i)||"";return`${r} ${m}`.trim()}}window.customElements.get("local-time")||(window.LocalTimeElement=LocalTimeElement,window.customElements.define("local-time",LocalTimeElement));