Spaces:
Running
Running
| import"./index-B6LgHwxl.js";import{r as s}from"./vendor-C1HQAMsB.js";Intl.DateTimeFormat().resolvedOptions().timeZone;const h=()=>{try{const t=Intl;if(t.supportedValuesOf){const e=t.supportedValuesOf("timeZone"),r=["America/","Europe/","Asia/","Australia/","Pacific/","Africa/"];return e.filter(o=>r.some(n=>o.startsWith(n))||o==="UTC").sort()}throw new Error("supportedValuesOf not available")}catch{return["UTC","America/New_York","America/Chicago","America/Denver","America/Los_Angeles","America/Sao_Paulo","Europe/London","Europe/Paris","Europe/Berlin","Asia/Tokyo","Asia/Shanghai","Asia/Singapore","Asia/Dubai","Australia/Sydney","Pacific/Auckland"]}},c=()=>Intl.DateTimeFormat().resolvedOptions().timeZone;c();const l=s.createContext(void 0),f=()=>{const t=s.useContext(l);if(t===void 0)throw new Error("useLocale must be used within a LocaleProvider");return t},p=()=>{const{settings:t}=f();return s.useMemo(()=>({formatCurrency:(e,r="USD")=>{try{return new Intl.NumberFormat(t.locale,{style:"currency",currency:r.toUpperCase(),minimumFractionDigits:2,maximumFractionDigits:2}).format(e)}catch{return`${r} ${e.toFixed(2)}`}},formatDate:e=>{const r=typeof e=="string"||typeof e=="number"?new Date(e):e;if(isNaN(r.getTime()))return"Invalid date";const o={short:{month:"numeric",day:"numeric",year:"2-digit"},medium:{month:"short",day:"numeric",year:"numeric"},long:{month:"long",day:"numeric",year:"numeric"}};return new Intl.DateTimeFormat(t.locale,{...o[t.dateFormat],timeZone:t.timezone}).format(r)},formatDateTime:(e,r=!1)=>{const o=typeof e=="string"||typeof e=="number"?new Date(e):e;return isNaN(o.getTime())?"Invalid date":new Intl.DateTimeFormat(t.locale,{month:"short",day:"numeric",year:"numeric",hour:"numeric",minute:"2-digit",second:r?"2-digit":void 0,timeZone:t.timezone,hour12:t.locale.startsWith("en")}).format(o)},formatTime:(e,r=!1)=>{const o=typeof e=="string"||typeof e=="number"?new Date(e):e;return isNaN(o.getTime())?"Invalid time":new Intl.DateTimeFormat(t.locale,{hour:"numeric",minute:"2-digit",second:r?"2-digit":void 0,timeZone:t.timezone,hour12:t.locale.startsWith("en")}).format(o)},formatRelativeTime:e=>{const r=typeof e=="string"||typeof e=="number"?new Date(e):e;if(isNaN(r.getTime()))return"Invalid date";const o=new Date,n=r.getTime()-o.getTime(),i=Math.round(n/6e4),a=Math.round(i/60),u=Math.round(a/24),m=new Intl.RelativeTimeFormat(t.locale,{numeric:"auto"});return Math.abs(i)<60?m.format(i,"minute"):Math.abs(a)<24?m.format(a,"hour"):m.format(u,"day")},formatNumber:(e,r=0)=>new Intl.NumberFormat(t.locale,{minimumFractionDigits:r,maximumFractionDigits:r}).format(e)}),[t])};export{f as a,c as b,h as g,p as u}; | |