import{i18n as t}from"./translation.js";const e=[];let i;function a(){e.forEach((t=>t._triggerUpdate()))}class n extends HTMLElement{static get observedAttributes(){return["datetime"]}constructor(){super(),this.datetime=null}get datetime(){return this.getAttribute("datetime")}set datetime(t){null!=t&&this.setAttribute("datetime",t)}attributeChangedCallback(e,i,a){"datetime"===e&&(this.title=t("cc-datetime-relative.title",{date:a}),this._triggerUpdate())}connectedCallback(){e.push(this),null==i&&(a(),i=window.setInterval(a,1e4))}disconnectedCallback(){const t=e.indexOf(this);-1!==t&&e.splice(t,1),e.length>0&&null!=i&&(clearInterval(i),i=null)}_triggerUpdate(){const e=this.getAttribute("datetime"),i=t("cc-datetime-relative.distance",{date:e});this.textContent!==i&&(this.textContent=i)}}window.customElements.define("cc-datetime-relative",n);export{n as CcDatetimeRelative};
//# sourceMappingURL=cc-datetime-relative.js.map
