Some checks failed
Build & Deploy / 🔍 Prepare (push) Successful in 20s
Build & Deploy / 🧪 QA (push) Failing after 34s
Build & Deploy / 🏗️ Build (push) Has started running
Build & Deploy / 🚀 Deploy (push) Has been cancelled
Build & Deploy / 🧪 Smoke Test (push) Has been cancelled
Build & Deploy / ⚡ Lighthouse (push) Has been cancelled
Build & Deploy / 🔔 Notify (push) Has been cancelled
2 lines
2.2 KiB
Plaintext
2 lines
2.2 KiB
Plaintext
import{createContext as e,useContext as r,useMemo as t,useState as o,useEffect as n}from"react";import{b as a,c as s,I as c,a as i}from"./formatters-CJcico0N.js";import{i as m,r as f,a as u,c as l}from"./initializeConfig-Brh10fyG.js";import{jsx as g}from"react/jsx-runtime";const d=e(void 0);function v({children:e,formats:o,getMessageFallback:n,locale:c,messages:i,now:f,onError:u,timeZone:l}){const v=r(d),w=t((()=>v?.cache||a()),[c,v?.cache]),p=t((()=>v?.formatters||s(w)),[w,v?.formatters]),h=t((()=>({...m({locale:c,formats:void 0===o?v?.formats:o,getMessageFallback:n||v?.getMessageFallback,messages:void 0===i?v?.messages:i,now:f||v?.now,onError:u||v?.onError,timeZone:l||v?.timeZone}),formatters:p,cache:w})),[w,o,p,n,c,i,f,u,v,l]);return g(d.Provider,{value:h,children:e})}function w(){const e=r(d);if(!e)throw new Error(void 0);return e}let p=!1;const h="undefined"==typeof window;function E(e){return function(e,r,o){const{cache:n,formats:a,formatters:s,getMessageFallback:m,locale:l,onError:g,timeZone:d}=w(),v=e[o],E=f(r,o);return d||p||!h||(p=!0,g(new c(i.ENVIRONMENT_FALLBACK,void 0))),t((()=>u({cache:n,formatters:s,getMessageFallback:m,messages:v,namespace:E,onError:g,formats:a,locale:l,timeZone:d})),[n,s,m,v,E,g,a,l,d])}({"!":w().messages},e?`!.${e}`:"!","!")}function Z(){return w().locale}function k(){return new Date}function b(e){const r=e?.updateInterval,{now:t}=w(),[a,s]=o(t||k());return n((()=>{if(!r)return;const e=setInterval((()=>{s(k())}),r);return()=>{clearInterval(e)}}),[t,r]),null==r&&t?t:a}function F(){return w().timeZone}function M(){const e=w();if(!e.messages)throw new Error(void 0);return e.messages}function I(){const{formats:e,formatters:r,locale:o,now:n,onError:a,timeZone:s}=w();return t((()=>l({formats:e,locale:o,now:n,onError:a,timeZone:s,_formatters:r})),[e,r,n,o,a,s])}function j(e,...r){let t,o;return"string"==typeof e?(t=r[0],o=r[1]):(t=e.values,o=e.formats),[void 0,t,o,void 0]}function x(e){const r=E(e);function t(...e){return r(...j(...e))}return t.rich=(...e)=>r.rich(...j(...e)),t.markup=(...e)=>r.markup(...j(...e)),t.has=function(e){return!0},t}export{v as IntlProvider,x as _useExtracted,I as useFormatter,Z as useLocale,M as useMessages,b as useNow,F as useTimeZone,E as useTranslations};
|