/* All material copyright ESRI, All Rights Reserved, unless otherwise specified. See https://js.arcgis.com/4.24/esri/copyright.txt for details. */ import{_ as t}from"./chunks/tslib.es6.js";import{JSONSupport as e}from"./core/JSONSupport.js";import{isSome as r,applySome as s,mapOr as i}from"./core/maybe.js";import{truncateDate as n,offsetDate as o}from"./core/timeUtils.js";import{property as l}from"./core/accessorSupport/decorators/property.js";import"./core/arrayUtils.js";import"./core/has.js";import"./core/accessorSupport/ensureType.js";import{reader as a}from"./core/accessorSupport/decorators/reader.js";import{subclass as m}from"./core/accessorSupport/decorators/subclass.js";import{writer as p}from"./core/accessorSupport/decorators/writer.js";var u;let d=u=class extends e{constructor(t){super(t),this.end=null,this.start=null}static get allTime(){return c}static get empty(){return h}readEnd(t,e){return null!=e.end?new Date(e.end):null}writeEnd(t,e){e.end=t?t.getTime():null}get isAllTime(){return this.equals(u.allTime)}get isEmpty(){return this.equals(u.empty)}readStart(t,e){return null!=e.start?new Date(e.start):null}writeStart(t,e){e.start=t?t.getTime():null}clone(){return new u({end:this.end,start:this.start})}equals(t){if(!t)return!1;const e=r(this.start)?this.start.getTime():this.start,s=r(this.end)?this.end.getTime():this.end,i=r(t.start)?t.start.getTime():t.start,n=r(t.end)?t.end.getTime():t.end;return e===i&&s===n}expandTo(t){if(this.isEmpty||this.isAllTime)return this.clone();const e=s(this.start,(e=>n(e,t))),r=s(this.end,(e=>o(n(e,t),1,t)));return new u({start:e,end:r})}intersection(t){if(!t)return this.clone();if(this.isEmpty||t.isEmpty)return u.empty;if(this.isAllTime)return t.clone();if(t.isAllTime)return this.clone();const e=i(this.start,-1/0,(t=>t.getTime())),r=i(this.end,1/0,(t=>t.getTime())),s=i(t.start,-1/0,(t=>t.getTime())),n=i(t.end,1/0,(t=>t.getTime()));let o,l;if(s>=e&&s<=r?o=s:e>=s&&e<=n&&(o=e),r>=s&&r<=n?l=r:n>=e&&n<=r&&(l=n),!isNaN(o)&&!isNaN(l)){const t=new u;return t.start=o===-1/0?null:new Date(o),t.end=l===1/0?null:new Date(l),t}return u.empty}offset(t,e){if(this.isEmpty||this.isAllTime)return this.clone();const s=new u,{start:i,end:n}=this;return r(i)&&(s.start=o(i,t,e)),r(n)&&(s.end=o(n,t,e)),s}union(t){if(!t||t.isEmpty)return this.clone();if(this.isEmpty)return t.clone();if(this.isAllTime||t.isAllTime)return c.clone();const e=r(this.start)&&r(t.start)?new Date(Math.min(this.start.getTime(),t.start.getTime())):null,s=r(this.end)&&r(t.end)?new Date(Math.max(this.end.getTime(),t.end.getTime())):null;return new u({start:e,end:s})}};t([l({type:Date,json:{write:{allowNull:!0}}})],d.prototype,"end",void 0),t([a("end")],d.prototype,"readEnd",null),t([p("end")],d.prototype,"writeEnd",null),t([l({readOnly:!0,json:{read:!1}})],d.prototype,"isAllTime",null),t([l({readOnly:!0,json:{read:!1}})],d.prototype,"isEmpty",null),t([l({type:Date,json:{write:{allowNull:!0}}})],d.prototype,"start",void 0),t([a("start")],d.prototype,"readStart",null),t([p("start")],d.prototype,"writeStart",null),d=u=t([m("esri.TimeExtent")],d);const c=new d,h=new d({start:void 0,end:void 0}),y=d;export{y as default};