/*
All material copyright Esri, All Rights Reserved, unless otherwise specified.
See https://js.arcgis.com/5.0/esri/copyright.txt for details.
*/
import{toConst as t}from"../../../core/compilerUtils.js";async function n(n,l){if(!n)return null;const u=l.featureAdapter,{startTimeField:r,endTimeField:e}=n;let i=Number.POSITIVE_INFINITY,o=Number.NEGATIVE_INFINITY;if(r&&e)await l.forEach(n=>{const l=u.getAttribute(t(n),r),s=u.getAttribute(t(n),e);null==l||isNaN(l)||(i=Math.min(i,l)),null==s||isNaN(s)||(o=Math.max(o,s))});else{const n=r||e;await l.forEach(l=>{const r=u.getAttribute(t(l),n);null==r||isNaN(r)||(i=Math.min(i,r),o=Math.max(o,r))})}return{start:i,end:o}}function l(t,n,l){if(!n||!t)return null;const{startTimeField:i,endTimeField:o}=t;if(!i&&!o)return null;const{start:s,end:a}=n;if(null===s&&null===a)return null;if(void 0===s&&void 0===a)return e();const c=l.getAttributeAsTimestamp?.bind(l)??l.getAttribute.bind(l);return i&&o?u(c,i,o,s,a):r(c,i||o,s,a)}function u(t,n,l,u,r){return null!=u&&null!=r?e=>{const i=t(e,n),o=t(e,l);return(null==i||i<=r)&&(null==o||o>=u)}:null!=u?n=>{const r=t(n,l);return null==r||r>=u}:null!=r?l=>{const u=t(l,n);return null==u||u<=r}:void 0}function r(t,n,l,u){return null!=l&&null!=u&&l===u?u=>t(u,n)===l:null!=l&&null!=u?r=>{const e=t(r,n);return null!=e&&e>=l&&e<=u}:null!=l?u=>{const r=t(u,n);return null!=r&&r>=l}:null!=u?l=>{const r=t(l,n);return null!=r&&r<=u}:void 0}function e(){return()=>!1}export{n as getTimeExtent,l as getTimeOperator};
