function e(e){if(!e)return null;let t=e.trim();return/[+-]\d{2}:\d{2}$/.test(t)||t.endsWith(`Z`)?t:t.replace(` `,`T`)+`Z`}function t(t){let n=e(t);return n?new Date(n):null}function n(e,t){return typeof e==`string`?{dateFormat:e,options:t}:{dateFormat:`auto`,options:e}}function r(e){if(e===`mdy`)return[`month`,`day`,`year`];if(e===`dmy`)return[`day`,`month`,`year`];if(e===`ymd`)return[`year`,`month`,`day`];let t=new Intl.DateTimeFormat(void 0,{year:`numeric`,month:`numeric`,day:`numeric`}).formatToParts(new Date(Date.UTC(2006,10,22))).map(e=>e.type).filter(e=>e===`month`||e===`day`||e===`year`),n=[...new Set(t)];return n.length===3?n:[`month`,`day`,`year`]}function i(e,t,n){let r=new Intl.DateTimeFormat(`en-US`,{timeZone:t,year:`numeric`,month:`2-digit`,day:`2-digit`}).formatToParts(e),i=Object.fromEntries(r.map(e=>[e.type,e.value])),a=i.year,o=i.month,s=i.day;return n===`mdy`?`${o}/${s}/${a}`:n===`dmy`?`${s}/${o}/${a}`:`${a}-${o}-${s}`}function a(e){if(!e)return;let t={},n=!1;return e.hour!==void 0&&(t.hour=e.hour,n=!0),e.minute!==void 0&&(t.minute=e.minute,n=!0),e.second!==void 0&&(t.second=e.second,n=!0),e.fractionalSecondDigits!==void 0&&(t.fractionalSecondDigits=e.fractionalSecondDigits,n=!0),e.hour12!==void 0&&(t.hour12=e.hour12,n=!0),e.hourCycle!==void 0&&(t.hourCycle=e.hourCycle,n=!0),e.timeZoneName!==void 0&&(t.timeZoneName=e.timeZoneName,n=!0),n?t:void 0}function o(e,t,n){return e.toLocaleTimeString(void 0,{timeZone:t,...a(n)})}function s(e,t,r,a){if(!e)return`-`;let s=new Date(e);if(Number.isNaN(s.getTime()))return`-`;let c=n(r,a);return c.dateFormat===`auto`?s.toLocaleString(void 0,{timeZone:t,...c.options}):`${i(s,t,c.dateFormat)}, ${o(s,t,c.options)}`}function c(e,t,r,a){if(!e)return`-`;let o=new Date(e);if(Number.isNaN(o.getTime()))return`-`;let s=n(r,a);return s.dateFormat===`auto`?o.toLocaleDateString(void 0,{timeZone:t,...s.options}):i(o,t,s.dateFormat)}function l(e,t,n=`auto`){if(!e)return`-`;let r=new Date(e);if(Number.isNaN(r.getTime()))return`-`;let i=new Date,a=new Intl.DateTimeFormat(`en-CA`,{timeZone:t}),o=a.format(r),s=a.format(i),l=new Date(i.getTime()-864e5),u=a.format(l),d=r.toLocaleTimeString(void 0,{timeZone:t,hour:`numeric`,minute:`2-digit`,hour12:!0});return o===s?`Today, ${d}`:o===u?`Yesterday, ${d}`:`${c(e,t,n,{month:`short`,day:`numeric`})}, ${d}`}function u(e){if(!e)return`-`;let t=new Date(e);if(Number.isNaN(t.getTime()))return`-`;let n=t.getTime()-Date.now(),r=Math.abs(n),i=n<0,a=Math.floor(r/1e3),o=Math.floor(a/60),s=Math.floor(o/60),c=Math.floor(s/24);return a<10?`just now`:c>0?i?`${c}d ago`:`in ${c}d`:s>0?i?`${s}h ago`:`in ${s}h`:o>0?i?`${o}m ago`:`in ${o}m`:i?`${a}s ago`:`in ${a}s`}export{r as a,l as i,s as n,t as o,u as r,c as t};