import{DateFormatter as t}from"./lib/date/date-formatter.js";import{MemoryCache as e}from"./lib/memory-cache.js";const i=["date","separator","time","millisecond","timezone"],s=["none","datetime-iso","time-iso","datetime-short","time-short"],a=["local","UTC"];class r{constructor(i,s){this._display=i,this._timezone=s,this._isDateIncluded="datetime-iso"===this.display||"datetime-short"===this.display;const a="datetime-iso"===this.display||"time-iso"===this.display?"datetime-iso":"datetime-short";this._dateFormatter=new t(a,this.timezone),this._cache=new e((t=>this._getFormatToParts(t)),1e3,(t=>t.getTime()))}get display(){return this._display}get timezone(){return this._timezone}format(t){if("none"===this.display)return"";const e=this.formatToParts(t);return i.map((t=>e[t])).filter((t=>null!=t)).join("")}formatAndMapParts(t,e){if("none"===this.display)return[];const s=this.formatToParts(t);return i.map((t=>[t,s[t]])).filter((([t,e])=>null!=e)).map((([t,i])=>e(t,i)))}formatToParts(t){return"none"===this._display?{}:this._cache.get(t)}_getFormatToParts(t){const e=this._dateFormatter.formatToParts(t);return this._isDateIncluded||(delete e.date,delete e.separator),e}}export{s as DATE_DISPLAYS,r as DateDisplayer,a as TIMEZONES};
//# sourceMappingURL=date-displayer.js.map
