react-semaphor 0.1.300 → 0.1.302
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/appearance/index.cjs +1 -0
- package/dist/appearance/index.js +9 -0
- package/dist/brand-studio/index.cjs +21 -0
- package/dist/brand-studio/index.js +1512 -0
- package/dist/chunks/{braces-BAdE5PE0.js → braces-CpOcaBNm.js} +1 -1
- package/dist/chunks/{braces-C0YourPb.js → braces-TYclg8Hl.js} +1 -1
- package/dist/chunks/dashboard-controls-BkuB9TQX.js +47 -0
- package/dist/chunks/dashboard-controls-CZuC_QjN.js +2227 -0
- package/dist/chunks/dashboard-filter-controls-button-2I1ltWQ9.js +11 -0
- package/dist/chunks/{dashboard-filter-controls-button-K4hL7KCc.js → dashboard-filter-controls-button-kfb_T18o.js} +205 -216
- package/dist/chunks/dashboard-json-C3v6rBdp.js +1 -0
- package/dist/chunks/{dashboard-json-CDj4ps7k.js → dashboard-json-Df6v2Jem.js} +14 -12
- package/dist/chunks/dashboard-summary-settings-dialog-BBALEHJQ.js +1 -0
- package/dist/chunks/{dashboard-summary-settings-dialog-Ci9neBCE.js → dashboard-summary-settings-dialog-DKAaWq-G.js} +64 -63
- package/dist/chunks/date-formatter-D9Bvw5Qk.js +1 -0
- package/dist/chunks/date-formatter-DyIOb6uC.js +333 -0
- package/dist/chunks/edit-dashboard-visual-CGBYahAK.js +183 -0
- package/dist/chunks/{edit-dashboard-visual-Baklmbnn.js → edit-dashboard-visual-D8L0cl_U.js} +8086 -8094
- package/dist/chunks/{index-k2nUr51g.js → index-BmoR3VQT.js} +86152 -103963
- package/dist/chunks/index-Cxb9UUro.js +4 -0
- package/dist/chunks/index-D7KJindZ.js +1 -0
- package/dist/chunks/index-DFOb_6HB.js +1657 -0
- package/dist/chunks/index-eM6MU4q_.js +1361 -0
- package/dist/chunks/index-uRJmUpof.js +2555 -0
- package/dist/chunks/palette-326-dgn0.js +6 -0
- package/dist/chunks/palette-jd7xiGTg.js +23 -0
- package/dist/chunks/{resource-management-panel-CzAaiI_M.js → resource-management-panel-C_c-BwrC.js} +116 -115
- package/dist/chunks/resource-management-panel-DrcEEARD.js +6 -0
- package/dist/chunks/rotate-ccw-BugHcM1w.js +6 -0
- package/dist/chunks/rotate-ccw-yFwqBFJZ.js +14 -0
- package/dist/chunks/save-CaybXtdd.js +6 -0
- package/dist/chunks/save-DU0FXUlM.js +21 -0
- package/dist/chunks/switch-AmoR1YIA.js +163 -0
- package/dist/chunks/switch-CZtMtqEj.js +19725 -0
- package/dist/chunks/{use-create-flow-overlay-state-CJo92SfT.js → use-create-flow-overlay-state-84Xe8VrP.js} +396 -412
- package/dist/chunks/use-create-flow-overlay-state-CiKVJGWF.js +16 -0
- package/dist/chunks/use-visual-utils-lp5DfmvL.js +1 -0
- package/dist/chunks/{use-visual-utils-BVz7bp1V.js → use-visual-utils-z3ifg6Fd.js} +54 -53
- package/dist/dashboard/index.cjs +1 -1
- package/dist/dashboard/index.js +1 -1
- package/dist/format-utils/index.cjs +1 -1
- package/dist/format-utils/index.js +2 -2
- package/dist/index.cjs +1 -1
- package/dist/index.js +210 -207
- package/dist/style.css +1 -1
- package/dist/surfboard/index.cjs +1 -1
- package/dist/surfboard/index.js +2 -2
- package/dist/types/appearance.d.ts +176 -0
- package/dist/types/brand-studio.d.ts +245 -0
- package/dist/types/dashboard.d.ts +134 -0
- package/dist/types/main.d.ts +141 -1
- package/dist/types/surfboard.d.ts +134 -0
- package/dist/types/types.d.ts +139 -0
- package/package.json +13 -1
- package/dist/chunks/dashboard-controls-CfQ3VOdS.js +0 -47
- package/dist/chunks/dashboard-controls-M1pEBMUQ.js +0 -2219
- package/dist/chunks/dashboard-filter-controls-button-Dy_rukRc.js +0 -11
- package/dist/chunks/dashboard-json-Dux0R9T3.js +0 -1
- package/dist/chunks/dashboard-summary-settings-dialog-FCGGq0QT.js +0 -1
- package/dist/chunks/date-formatter-CqXdM6JO.js +0 -1
- package/dist/chunks/date-formatter-vkCj9Ct-.js +0 -1982
- package/dist/chunks/edit-dashboard-visual-B0nk13zW.js +0 -193
- package/dist/chunks/index-u9HF3DLf.js +0 -1528
- package/dist/chunks/resource-management-panel-Sb9b4R-f.js +0 -6
- package/dist/chunks/use-create-flow-overlay-state-nT9AdiH1.js +0 -21
- package/dist/chunks/use-visual-utils-BlLzFtMt.js +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const r=require("react/jsx-runtime"),o=require("react"),s=require("./switch-AmoR1YIA.js");require("./index-eM6MU4q_.js");require("./index-Cxb9UUro.js");require("react-dom");function b(){const t=s.useDashboardStore(e=>e.dashboard),c=s.useDashboardStore(e=>e.actions.setDashboard),u=s.useDashboardStore(e=>e.showDashboardJSON),h=s.useDashboardStore(e=>e.actions.setShowDashboardJSON),a=o.useMemo(()=>t?JSON.stringify(t,null,2):"",[t]),[l,d]=o.useState(a),n=o.useRef(a);return o.useEffect(()=>{a!==n.current&&(d(a),n.current=a)},[a]),r.jsxs("div",{className:s.cn("relative p-2",{hidden:!u}),children:[r.jsxs(s.Button,{variant:"secondary",size:"sm",className:"absolute right-2 top-2 z-10 h-8",onClick:()=>h(!1),children:[r.jsx(s.X,{className:"mr-2 h-4 w-4"}),"Close"]}),r.jsx("div",{className:"h-[550px] overflow-hidden",children:r.jsx(s.CodeEditor,{value:l,onValueChange:e=>{d(e);try{const i=JSON.parse(e);n.current=JSON.stringify(i,null,2),c(i)}catch{}},language:"json"})})]})}exports.default=b;
|
|
@@ -1,16 +1,18 @@
|
|
|
1
1
|
import { jsxs as i, jsx as t } from "react/jsx-runtime";
|
|
2
|
-
import { useMemo as
|
|
3
|
-
import { u as
|
|
2
|
+
import { useMemo as m, useState as b, useRef as f, useEffect as S } from "react";
|
|
3
|
+
import { u as o, a as N, B as p, X as D, C as J } from "./switch-CZtMtqEj.js";
|
|
4
|
+
import "./index-BmoR3VQT.js";
|
|
5
|
+
import "./index-uRJmUpof.js";
|
|
4
6
|
import "react-dom";
|
|
5
|
-
function
|
|
6
|
-
const
|
|
7
|
+
function C() {
|
|
8
|
+
const e = o((s) => s.dashboard), c = o((s) => s.actions.setDashboard), h = o(
|
|
7
9
|
(s) => s.showDashboardJSON
|
|
8
|
-
), l =
|
|
10
|
+
), l = o(
|
|
9
11
|
(s) => s.actions.setShowDashboardJSON
|
|
10
|
-
), a =
|
|
11
|
-
() =>
|
|
12
|
-
[
|
|
13
|
-
), [u, n] =
|
|
12
|
+
), a = m(
|
|
13
|
+
() => e ? JSON.stringify(e, null, 2) : "",
|
|
14
|
+
[e]
|
|
15
|
+
), [u, n] = b(a), r = f(a);
|
|
14
16
|
return S(() => {
|
|
15
17
|
a !== r.current && (n(a), r.current = a);
|
|
16
18
|
}, [a]), /* @__PURE__ */ i(
|
|
@@ -21,14 +23,14 @@ function x() {
|
|
|
21
23
|
}),
|
|
22
24
|
children: [
|
|
23
25
|
/* @__PURE__ */ i(
|
|
24
|
-
|
|
26
|
+
p,
|
|
25
27
|
{
|
|
26
28
|
variant: "secondary",
|
|
27
29
|
size: "sm",
|
|
28
30
|
className: "absolute right-2 top-2 z-10 h-8",
|
|
29
31
|
onClick: () => l(!1),
|
|
30
32
|
children: [
|
|
31
|
-
/* @__PURE__ */ t(
|
|
33
|
+
/* @__PURE__ */ t(D, { className: "mr-2 h-4 w-4" }),
|
|
32
34
|
"Close"
|
|
33
35
|
]
|
|
34
36
|
}
|
|
@@ -57,5 +59,5 @@ function x() {
|
|
|
57
59
|
);
|
|
58
60
|
}
|
|
59
61
|
export {
|
|
60
|
-
|
|
62
|
+
C as default
|
|
61
63
|
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";const e=require("react/jsx-runtime"),o=require("react"),a=require("./index-eM6MU4q_.js"),s=require("./switch-AmoR1YIA.js");function q(n={}){var k,P,A,E;const{authToken:c,tokenProps:t}=a.useSemaphorContext(),S=n.enabled??!0,u=(c==null?void 0:c.accessToken)??null,f=(t==null?void 0:t.apiServiceUrl)??null,[N,j]=o.useState(!1),[v,b]=o.useState(!1),[h,l]=o.useState(!1),[y,d]=o.useState(null),[p,w]=o.useState(null),T=p||{tz:((P=(k=t==null?void 0:t.params)==null?void 0:k.calendarContext)==null?void 0:P.tz)||null,weekStart:((E=(A=t==null?void 0:t.params)==null?void 0:A.calendarContext)==null?void 0:E.weekStart)??null},g=o.useCallback(async()=>{if(!(!S||!u||!f)){j(!0),d(null);try{const m=await fetch(`${f}/v1/user-preferences/calendar`,{method:"GET",headers:{Authorization:`Bearer ${u}`}});if(!m.ok){const x=await m.json().catch(()=>({}));throw new Error(x.error||"Failed to fetch preferences")}const i=await m.json();w({tz:i.tz,weekStart:i.weekStart,source:i.source,isInherited:i.isInherited,userHasPrefs:i.userHasPrefs,inherited:i.inherited})}catch(m){const i=m instanceof Error?m.message:"Unknown error";d(i)}finally{j(!1)}}},[u,f,S]);o.useEffect(()=>{S&&g()},[S,g]);const I=o.useCallback(async m=>{if(!u||!f)return d("Not authenticated"),!1;b(!0),d(null);try{const i=await fetch(`${f}/v1/user-preferences/calendar`,{method:"PATCH",headers:{"Content-Type":"application/json",Authorization:`Bearer ${u}`},body:JSON.stringify(m)});if(!i.ok){const x=await i.json().catch(()=>({}));throw new Error(x.error||"Failed to update preferences")}return await g(),!0}catch(i){const x=i instanceof Error?i.message:"Unknown error";return d(x),!1}finally{b(!1)}},[u,f,g]),C=o.useCallback(async()=>{if(!u||!f)return d("Not authenticated"),!1;l(!0),d(null);try{const m=await fetch(`${f}/v1/user-preferences/calendar`,{method:"DELETE",headers:{Authorization:`Bearer ${u}`}});if(!m.ok){const x=await m.json().catch(()=>({}));throw new Error(x.error||"Failed to clear preferences")}const i=await m.text();if(i)try{const x=JSON.parse(i);return w({tz:x.tz,weekStart:x.weekStart,source:x.source,isInherited:x.isInherited??!0,userHasPrefs:!1,inherited:x.inherited}),!0}catch{}return await g(),!0}catch(m){const i=m instanceof Error?m.message:"Unknown error";return d(i),!1}finally{l(!1)}},[u,f,g]);return{preferences:T,isLoading:N,isSaving:v,isClearing:h,error:y,updatePreferences:I,clearPreferences:C,refetch:g}}const D=[{value:"America/New_York",label:"Eastern Time (US & Canada)"},{value:"America/Chicago",label:"Central Time (US & Canada)"},{value:"America/Denver",label:"Mountain Time (US & Canada)"},{value:"America/Los_Angeles",label:"Pacific Time (US & Canada)"},{value:"America/Phoenix",label:"Arizona"},{value:"America/Anchorage",label:"Alaska"},{value:"Pacific/Honolulu",label:"Hawaii"},{value:"Europe/London",label:"London"},{value:"Europe/Paris",label:"Paris, Berlin, Rome"},{value:"Asia/Tokyo",label:"Tokyo"},{value:"Asia/Shanghai",label:"Beijing, Shanghai"},{value:"Asia/Kolkata",label:"Mumbai, New Delhi"},{value:"Australia/Sydney",label:"Sydney"},{value:"UTC",label:"UTC"}],$=[{value:0,label:"Sunday"},{value:1,label:"Monday"},{value:6,label:"Saturday"}],B="text-[10px] font-medium uppercase tracking-[0.08em] text-muted-foreground";function X(){try{const n=Intl;if(n.supportedValuesOf)return n.supportedValuesOf("timeZone")}catch{}return D.map(n=>n.value)}function Z(n){switch(n){case"tenant":return"tenant";case"organization":return"organization";case"system":return"system";default:return"default"}}function _(n){const c=D.find(t=>t.value===n);return c?c.label:n}function J(n){const c=$.find(t=>t.value===n);return c?c.label:String(n)}function K({open:n,onOpenChange:c}){var M,F,U;const{preferences:t,isLoading:S,isSaving:u,isClearing:f,updatePreferences:N,clearPreferences:j}=q({enabled:n}),v=t.tz||((M=t.inherited)==null?void 0:M.tz)||Intl.DateTimeFormat().resolvedOptions().timeZone,b=t.weekStart??((F=t.inherited)==null?void 0:F.weekStart)??1,[h,l]=o.useState(!t.userHasPrefs),[y,d]=o.useState(!1),[p,w]=o.useState(v),[T,g]=o.useState(b),[I,C]=o.useState(!1),k=o.useMemo(()=>X(),[]),P=o.useMemo(()=>k.filter(r=>!D.some(V=>V.value===r)),[k]),A=o.useMemo(()=>_(p),[p]),E=t.inherited?_(t.inherited.tz):"UTC",m=t.inherited?J(t.inherited.weekStart):"Monday",i=Z((U=t.inherited)==null?void 0:U.source);o.useEffect(()=>{if(!n){d(!1);return}y||(t.userHasPrefs!==void 0&&l(!t.userHasPrefs),w(v),g(b))},[n,y,t.userHasPrefs,v,b]);const x=async()=>{if(S){a.ue.error("Preferences are still loading. Please try again.");return}h?await j()?(a.ue.success("Now using default settings. Please refresh the page to apply changes.",{duration:5e3}),c(!1)):a.ue.error("Failed to save preferences. Please try again."):await N({tz:p,weekStart:T})?(a.ue.success("Preferences saved. Please refresh the page to apply changes.",{duration:5e3}),c(!1)):a.ue.error("Failed to save preferences. Please try again.")},G=()=>{c(!1)},L=u||f,W=L||S;return e.jsx(a.Dialog,{open:n,onOpenChange:c,children:e.jsxs(a.DialogContent,{className:"rounded-control border-border/60 sm:max-w-[440px] sm:rounded-control",children:[e.jsxs(a.DialogHeader,{children:[e.jsx(a.DialogTitle,{className:"text-[15px]",children:"Calendar preferences"}),e.jsx(a.DialogDescription,{className:"text-[13px] leading-5",children:"Set your timezone and week-start for date calculations and displays."})]}),e.jsxs("div",{className:"space-y-4 py-1",children:[e.jsxs(a.RadioGroup,{value:h?"defaults":"custom",onValueChange:r=>{d(!0),l(r==="defaults")},className:"space-y-0.5",children:[e.jsxs("label",{htmlFor:"mode-defaults",className:s.cn("flex cursor-pointer items-start gap-2 rounded-control px-2 py-1.5 hover:bg-muted/50",h&&"bg-muted/50"),onClick:()=>{d(!0),l(!0)},children:[e.jsx(a.RadioGroupItem,{value:"defaults",id:"mode-defaults",className:"mt-0.5"}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("p",{className:"text-[13px] font-medium text-foreground",children:["Use ",i," defaults"]}),e.jsxs("p",{className:"text-[12px] text-muted-foreground",children:[E,", week starts ",m]})]})]}),e.jsxs("label",{htmlFor:"mode-custom",className:s.cn("flex cursor-pointer items-start gap-2 rounded-control px-2 py-1.5 hover:bg-muted/50",!h&&"bg-muted/50"),onClick:()=>{d(!0),l(!1)},children:[e.jsx(a.RadioGroupItem,{value:"custom",id:"mode-custom",className:"mt-0.5"}),e.jsx("p",{className:"flex-1 text-[13px] font-medium text-foreground",children:"Use custom settings"})]})]}),e.jsxs("div",{className:s.cn("space-y-4 border-t border-border/60 pt-4 transition-opacity",h&&"pointer-events-none opacity-50"),children:[e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(s.Label,{className:B,children:"Timezone"}),e.jsxs(s.Popover,{open:I,onOpenChange:C,modal:!0,children:[e.jsx(s.PopoverTrigger,{asChild:!0,children:e.jsxs(s.Button,{variant:"outline",size:"xs",role:"combobox","aria-expanded":I,className:"w-full justify-between text-[12px] font-normal",disabled:h,children:[e.jsx("span",{className:"truncate",children:A}),e.jsx(a.ChevronsUpDown,{className:"ml-2 h-3.5 w-3.5 shrink-0 opacity-50"})]})}),e.jsx(s.PopoverContent,{className:"z-50 w-[--radix-popover-trigger-width] p-0",align:"start",children:e.jsxs(a.Command,{className:"overflow-visible",children:[e.jsx(a.CommandInput,{placeholder:"Search timezones…"}),e.jsxs(a.CommandList,{children:[e.jsx(a.CommandEmpty,{children:"No timezone found."}),e.jsx(a.CommandGroup,{heading:"Common",children:D.map(r=>e.jsxs(a.CommandItem,{value:`${r.value} ${r.label}`,onSelect:()=>{d(!0),w(r.value),C(!1)},children:[e.jsx(s.Check,{className:s.cn("h-3.5 w-3.5",p===r.value?"opacity-100":"opacity-0")}),e.jsx("span",{className:"flex-1",children:r.label}),e.jsx("span",{className:"text-[11px] text-muted-foreground",children:r.value})]},r.value))}),e.jsx(a.CommandSeparator,{}),e.jsx(a.CommandGroup,{heading:"All timezones",children:P.map(r=>e.jsxs(a.CommandItem,{value:r,onSelect:()=>{d(!0),w(r),C(!1)},children:[e.jsx(s.Check,{className:s.cn("h-3.5 w-3.5",p===r?"opacity-100":"opacity-0")}),r]},r))})]})]})})]})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(s.Label,{className:B,children:"Week starts on"}),e.jsx(a.RadioGroup,{value:String(T),onValueChange:r=>{d(!0),g(Number(r))},className:"flex gap-4",disabled:h,children:$.map(r=>e.jsxs("label",{htmlFor:`week-start-${r.value}`,className:s.cn("flex cursor-pointer items-center gap-2 text-[13px]",h&&"cursor-not-allowed"),children:[e.jsx(a.RadioGroupItem,{value:String(r.value),id:`week-start-${r.value}`,disabled:h}),r.label]},r.value))})]})]})]}),e.jsxs(a.DialogFooter,{children:[e.jsx(s.Button,{variant:"outline",size:"xs",onClick:G,disabled:L,children:"Cancel"}),e.jsx(s.Button,{size:"xs",onClick:x,disabled:W,children:L?e.jsxs(e.Fragment,{children:[e.jsx(s.LoaderCircle,{className:"h-3.5 w-3.5 animate-spin"}),"Saving…"]}):"Save"})]})]})})}const z=6,O=1,R=20,H="text-[10px] font-medium uppercase tracking-[0.08em] text-muted-foreground";function Y(n){return Number.isNaN(n)?z:Math.min(R,Math.max(O,n))}function Q({open:n,onOpenChange:c,dashboard:t,onApply:S,disabled:u=!1}){const[f,N]=o.useState(!1),[j,v]=o.useState("top"),[b,h]=o.useState(String(z)),l=t.summary;o.useEffect(()=>{n&&(N((l==null?void 0:l.enabled)===!0),v((l==null?void 0:l.position)==="bottom"?"bottom":"top"),h(String((l==null?void 0:l.maxItems)??z)))},[n,l==null?void 0:l.enabled,l==null?void 0:l.position,l==null?void 0:l.maxItems]);const y=o.useMemo(()=>Y(Number.parseInt(b||`${z}`,10)),[b]),d=()=>{S({enabled:f,position:j,maxItems:y}),c(!1)};return e.jsx(a.Dialog,{open:n,onOpenChange:c,children:e.jsxs(a.DialogContent,{className:"rounded-control border-border/60 sm:max-w-[420px] sm:rounded-control",children:[e.jsxs(a.DialogHeader,{children:[e.jsx(a.DialogTitle,{className:"text-[15px]",children:"Summary Settings"}),e.jsx(a.DialogDescription,{className:"text-[13px] leading-5",children:"Configure dashboard-level summary display. Card-level summary settings still control which cards contribute."})]}),e.jsxs("div",{className:"space-y-4 py-1",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(s.Label,{htmlFor:"dashboard-summary-enabled",className:"text-[13px]",children:"Enable dashboard summary"}),e.jsx(s.Switch,{size:"xs",id:"dashboard-summary-enabled",checked:f,disabled:u,onCheckedChange:N})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(s.Label,{htmlFor:"dashboard-summary-position",className:H,children:"Position"}),e.jsxs(s.Select,{value:j,disabled:u,onValueChange:p=>v(p),children:[e.jsx(s.SelectTrigger,{id:"dashboard-summary-position",size:"xs",children:e.jsx(s.SelectValue,{placeholder:"Select position"})}),e.jsxs(s.SelectContent,{children:[e.jsx(s.SelectItem,{value:"top",children:"Top"}),e.jsx(s.SelectItem,{value:"bottom",children:"Bottom"})]})]})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(s.Label,{htmlFor:"dashboard-summary-max-items",className:H,children:"Max items"}),e.jsx(s.Input,{size:"xs",id:"dashboard-summary-max-items",type:"number",min:O,max:R,disabled:u,value:b,onChange:p=>h(p.target.value),onBlur:()=>h(String(y))}),e.jsx("p",{className:"text-[12px] text-muted-foreground",children:"Display limit only. Computation is unchanged."})]}),u&&e.jsx("p",{className:"text-[12px] text-amber-700",children:"Enter dashboard edit mode to modify summary settings."})]}),e.jsxs(a.DialogFooter,{children:[e.jsx(s.Button,{variant:"outline",size:"xs",onClick:()=>c(!1),children:"Cancel"}),e.jsx(s.Button,{size:"xs",onClick:d,disabled:u,children:"Apply"})]})]})})}exports.CalendarPreferencesDialog=K;exports.DashboardSummarySettingsDialog=Q;
|
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
import { jsx as e, jsxs as a, Fragment as ue } from "react/jsx-runtime";
|
|
2
|
-
import me, { useState as f, useCallback as
|
|
3
|
-
import {
|
|
2
|
+
import me, { useState as f, useCallback as H, useEffect as q, useMemo as U } from "react";
|
|
3
|
+
import { u as he, b as Q, c as ee, d as ae, e as te, f as se, R, g as $, C as fe, h as pe, i as be, j as ve, k as ge, l as V, m as G, n as xe, o as re, p as I } from "./index-BmoR3VQT.js";
|
|
4
|
+
import { a as k, L as P, P as Se, b as ye, B as A, d as Ne, e as X, f as we, S as ke, g as Ce, h as Te, i as Ie, j as Pe, k as Z, I as Ae } from "./switch-CZtMtqEj.js";
|
|
4
5
|
function ze(r = {}) {
|
|
5
6
|
var T, L, D, M;
|
|
6
|
-
const { authToken: i, tokenProps: t } = he(),
|
|
7
|
+
const { authToken: i, tokenProps: t } = he(), g = r.enabled ?? !0, o = (i == null ? void 0 : i.accessToken) ?? null, h = (t == null ? void 0 : t.apiServiceUrl) ?? null, [N, S] = f(!1), [x, b] = f(!1), [u, n] = f(!1), [y, c] = f(null), [p, w] = f(null), z = p || {
|
|
7
8
|
tz: ((L = (T = t == null ? void 0 : t.params) == null ? void 0 : T.calendarContext) == null ? void 0 : L.tz) || null,
|
|
8
9
|
weekStart: ((M = (D = t == null ? void 0 : t.params) == null ? void 0 : D.calendarContext) == null ? void 0 : M.weekStart) ?? null
|
|
9
|
-
},
|
|
10
|
-
if (!(!
|
|
10
|
+
}, v = H(async () => {
|
|
11
|
+
if (!(!g || !o || !h)) {
|
|
11
12
|
S(!0), c(null);
|
|
12
13
|
try {
|
|
13
14
|
const d = await fetch(`${h}/v1/user-preferences/calendar`, {
|
|
@@ -36,15 +37,15 @@ function ze(r = {}) {
|
|
|
36
37
|
S(!1);
|
|
37
38
|
}
|
|
38
39
|
}
|
|
39
|
-
}, [o, h,
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
}, [
|
|
43
|
-
const E =
|
|
40
|
+
}, [o, h, g]);
|
|
41
|
+
q(() => {
|
|
42
|
+
g && v();
|
|
43
|
+
}, [g, v]);
|
|
44
|
+
const E = H(
|
|
44
45
|
async (d) => {
|
|
45
46
|
if (!o || !h)
|
|
46
47
|
return c("Not authenticated"), !1;
|
|
47
|
-
|
|
48
|
+
b(!0), c(null);
|
|
48
49
|
try {
|
|
49
50
|
const l = await fetch(`${h}/v1/user-preferences/calendar`, {
|
|
50
51
|
method: "PATCH",
|
|
@@ -58,16 +59,16 @@ function ze(r = {}) {
|
|
|
58
59
|
const m = await l.json().catch(() => ({}));
|
|
59
60
|
throw new Error(m.error || "Failed to update preferences");
|
|
60
61
|
}
|
|
61
|
-
return await
|
|
62
|
+
return await v(), !0;
|
|
62
63
|
} catch (l) {
|
|
63
64
|
const m = l instanceof Error ? l.message : "Unknown error";
|
|
64
65
|
return c(m), !1;
|
|
65
66
|
} finally {
|
|
66
|
-
|
|
67
|
+
b(!1);
|
|
67
68
|
}
|
|
68
69
|
},
|
|
69
|
-
[o, h,
|
|
70
|
-
), C =
|
|
70
|
+
[o, h, v]
|
|
71
|
+
), C = H(async () => {
|
|
71
72
|
if (!o || !h)
|
|
72
73
|
return c("Not authenticated"), !1;
|
|
73
74
|
n(!0), c(null);
|
|
@@ -96,23 +97,23 @@ function ze(r = {}) {
|
|
|
96
97
|
}), !0;
|
|
97
98
|
} catch {
|
|
98
99
|
}
|
|
99
|
-
return await
|
|
100
|
+
return await v(), !0;
|
|
100
101
|
} catch (d) {
|
|
101
102
|
const l = d instanceof Error ? d.message : "Unknown error";
|
|
102
103
|
return c(l), !1;
|
|
103
104
|
} finally {
|
|
104
105
|
n(!1);
|
|
105
106
|
}
|
|
106
|
-
}, [o, h,
|
|
107
|
+
}, [o, h, v]);
|
|
107
108
|
return {
|
|
108
109
|
preferences: z,
|
|
109
110
|
isLoading: N,
|
|
110
|
-
isSaving:
|
|
111
|
+
isSaving: x,
|
|
111
112
|
isClearing: u,
|
|
112
113
|
error: y,
|
|
113
114
|
updatePreferences: E,
|
|
114
115
|
clearPreferences: C,
|
|
115
|
-
refetch:
|
|
116
|
+
refetch: v
|
|
116
117
|
};
|
|
117
118
|
}
|
|
118
119
|
const _ = [
|
|
@@ -171,21 +172,21 @@ function He({
|
|
|
171
172
|
var B, O, W;
|
|
172
173
|
const {
|
|
173
174
|
preferences: t,
|
|
174
|
-
isLoading:
|
|
175
|
+
isLoading: g,
|
|
175
176
|
isSaving: o,
|
|
176
177
|
isClearing: h,
|
|
177
178
|
updatePreferences: N,
|
|
178
179
|
clearPreferences: S
|
|
179
|
-
} = ze({ enabled: r }),
|
|
180
|
-
g
|
|
181
|
-
), [z, b] = f(
|
|
180
|
+
} = ze({ enabled: r }), x = t.tz || ((B = t.inherited) == null ? void 0 : B.tz) || Intl.DateTimeFormat().resolvedOptions().timeZone, b = t.weekStart ?? ((O = t.inherited) == null ? void 0 : O.weekStart) ?? 1, [u, n] = f(!t.userHasPrefs), [y, c] = f(!1), [p, w] = f(
|
|
182
181
|
x
|
|
183
|
-
), [
|
|
182
|
+
), [z, v] = f(
|
|
183
|
+
b
|
|
184
|
+
), [E, C] = f(!1), T = U(() => Ee(), []), L = U(
|
|
184
185
|
() => T.filter(
|
|
185
186
|
(s) => !_.some((de) => de.value === s)
|
|
186
187
|
),
|
|
187
188
|
[T]
|
|
188
|
-
), D =
|
|
189
|
+
), D = U(() => K(p), [p]), M = t.inherited ? K(t.inherited.tz) : "UTC", d = t.inherited ? De(t.inherited.weekStart) : "Monday", l = Le(
|
|
189
190
|
(W = t.inherited) == null ? void 0 : W.source
|
|
190
191
|
);
|
|
191
192
|
me.useEffect(() => {
|
|
@@ -193,16 +194,16 @@ function He({
|
|
|
193
194
|
c(!1);
|
|
194
195
|
return;
|
|
195
196
|
}
|
|
196
|
-
y || (t.userHasPrefs !== void 0 && n(!t.userHasPrefs), w(
|
|
197
|
+
y || (t.userHasPrefs !== void 0 && n(!t.userHasPrefs), w(x), v(b));
|
|
197
198
|
}, [
|
|
198
199
|
r,
|
|
199
200
|
y,
|
|
200
201
|
t.userHasPrefs,
|
|
201
|
-
|
|
202
|
-
|
|
202
|
+
x,
|
|
203
|
+
b
|
|
203
204
|
]);
|
|
204
205
|
const m = async () => {
|
|
205
|
-
if (
|
|
206
|
+
if (g) {
|
|
206
207
|
I.error("Preferences are still loading. Please try again.");
|
|
207
208
|
return;
|
|
208
209
|
}
|
|
@@ -218,8 +219,8 @@ function He({
|
|
|
218
219
|
), i(!1)) : I.error("Failed to save preferences. Please try again.");
|
|
219
220
|
}, oe = () => {
|
|
220
221
|
i(!1);
|
|
221
|
-
},
|
|
222
|
-
return /* @__PURE__ */ e(Q, { open: r, onOpenChange: i, children: /* @__PURE__ */ a(ee, { className: "rounded-
|
|
222
|
+
}, j = o || h, ce = j || g;
|
|
223
|
+
return /* @__PURE__ */ e(Q, { open: r, onOpenChange: i, children: /* @__PURE__ */ a(ee, { className: "rounded-control border-border/60 sm:max-w-[440px] sm:rounded-control", children: [
|
|
223
224
|
/* @__PURE__ */ a(ae, { children: [
|
|
224
225
|
/* @__PURE__ */ e(te, { className: "text-[15px]", children: "Calendar preferences" }),
|
|
225
226
|
/* @__PURE__ */ e(se, { className: "text-[13px] leading-5", children: "Set your timezone and week-start for date calculations and displays." })
|
|
@@ -239,7 +240,7 @@ function He({
|
|
|
239
240
|
{
|
|
240
241
|
htmlFor: "mode-defaults",
|
|
241
242
|
className: k(
|
|
242
|
-
"flex cursor-pointer items-start gap-2 rounded-
|
|
243
|
+
"flex cursor-pointer items-start gap-2 rounded-control px-2 py-1.5 hover:bg-muted/50",
|
|
243
244
|
u && "bg-muted/50"
|
|
244
245
|
),
|
|
245
246
|
onClick: () => {
|
|
@@ -247,7 +248,7 @@ function He({
|
|
|
247
248
|
},
|
|
248
249
|
children: [
|
|
249
250
|
/* @__PURE__ */ e(
|
|
250
|
-
|
|
251
|
+
$,
|
|
251
252
|
{
|
|
252
253
|
value: "defaults",
|
|
253
254
|
id: "mode-defaults",
|
|
@@ -274,7 +275,7 @@ function He({
|
|
|
274
275
|
{
|
|
275
276
|
htmlFor: "mode-custom",
|
|
276
277
|
className: k(
|
|
277
|
-
"flex cursor-pointer items-start gap-2 rounded-
|
|
278
|
+
"flex cursor-pointer items-start gap-2 rounded-control px-2 py-1.5 hover:bg-muted/50",
|
|
278
279
|
!u && "bg-muted/50"
|
|
279
280
|
),
|
|
280
281
|
onClick: () => {
|
|
@@ -282,7 +283,7 @@ function He({
|
|
|
282
283
|
},
|
|
283
284
|
children: [
|
|
284
285
|
/* @__PURE__ */ e(
|
|
285
|
-
|
|
286
|
+
$,
|
|
286
287
|
{
|
|
287
288
|
value: "custom",
|
|
288
289
|
id: "mode-custom",
|
|
@@ -307,13 +308,13 @@ function He({
|
|
|
307
308
|
/* @__PURE__ */ a("div", { className: "space-y-1.5", children: [
|
|
308
309
|
/* @__PURE__ */ e(P, { className: J, children: "Timezone" }),
|
|
309
310
|
/* @__PURE__ */ a(
|
|
310
|
-
|
|
311
|
+
Se,
|
|
311
312
|
{
|
|
312
313
|
open: E,
|
|
313
314
|
onOpenChange: C,
|
|
314
315
|
modal: !0,
|
|
315
316
|
children: [
|
|
316
|
-
/* @__PURE__ */ e(
|
|
317
|
+
/* @__PURE__ */ e(ye, { asChild: !0, children: /* @__PURE__ */ a(
|
|
317
318
|
A,
|
|
318
319
|
{
|
|
319
320
|
variant: "outline",
|
|
@@ -324,19 +325,19 @@ function He({
|
|
|
324
325
|
disabled: u,
|
|
325
326
|
children: [
|
|
326
327
|
/* @__PURE__ */ e("span", { className: "truncate", children: D }),
|
|
327
|
-
/* @__PURE__ */ e(
|
|
328
|
+
/* @__PURE__ */ e(fe, { className: "ml-2 h-3.5 w-3.5 shrink-0 opacity-50" })
|
|
328
329
|
]
|
|
329
330
|
}
|
|
330
331
|
) }),
|
|
331
332
|
/* @__PURE__ */ e(
|
|
332
|
-
|
|
333
|
+
Ne,
|
|
333
334
|
{
|
|
334
335
|
className: "z-50 w-[--radix-popover-trigger-width] p-0",
|
|
335
336
|
align: "start",
|
|
336
|
-
children: /* @__PURE__ */ a(
|
|
337
|
-
/* @__PURE__ */ e(
|
|
338
|
-
/* @__PURE__ */ a(
|
|
339
|
-
/* @__PURE__ */ e(
|
|
337
|
+
children: /* @__PURE__ */ a(pe, { className: "overflow-visible", children: [
|
|
338
|
+
/* @__PURE__ */ e(be, { placeholder: "Search timezones…" }),
|
|
339
|
+
/* @__PURE__ */ a(ve, { children: [
|
|
340
|
+
/* @__PURE__ */ e(ge, { children: "No timezone found." }),
|
|
340
341
|
/* @__PURE__ */ e(V, { heading: "Common", children: _.map((s) => /* @__PURE__ */ a(
|
|
341
342
|
G,
|
|
342
343
|
{
|
|
@@ -360,7 +361,7 @@ function He({
|
|
|
360
361
|
},
|
|
361
362
|
s.value
|
|
362
363
|
)) }),
|
|
363
|
-
/* @__PURE__ */ e(
|
|
364
|
+
/* @__PURE__ */ e(xe, {}),
|
|
364
365
|
/* @__PURE__ */ e(V, { heading: "All timezones", children: L.map((s) => /* @__PURE__ */ a(
|
|
365
366
|
G,
|
|
366
367
|
{
|
|
@@ -398,7 +399,7 @@ function He({
|
|
|
398
399
|
{
|
|
399
400
|
value: String(z),
|
|
400
401
|
onValueChange: (s) => {
|
|
401
|
-
c(!0),
|
|
402
|
+
c(!0), v(Number(s));
|
|
402
403
|
},
|
|
403
404
|
className: "flex gap-4",
|
|
404
405
|
disabled: u,
|
|
@@ -412,7 +413,7 @@ function He({
|
|
|
412
413
|
),
|
|
413
414
|
children: [
|
|
414
415
|
/* @__PURE__ */ e(
|
|
415
|
-
|
|
416
|
+
$,
|
|
416
417
|
{
|
|
417
418
|
value: String(s.value),
|
|
418
419
|
id: `week-start-${s.value}`,
|
|
@@ -438,37 +439,37 @@ function He({
|
|
|
438
439
|
variant: "outline",
|
|
439
440
|
size: "xs",
|
|
440
441
|
onClick: oe,
|
|
441
|
-
disabled:
|
|
442
|
+
disabled: j,
|
|
442
443
|
children: "Cancel"
|
|
443
444
|
}
|
|
444
445
|
),
|
|
445
|
-
/* @__PURE__ */ e(A, { size: "xs", onClick: m, disabled: ce, children:
|
|
446
|
+
/* @__PURE__ */ e(A, { size: "xs", onClick: m, disabled: ce, children: j ? /* @__PURE__ */ a(ue, { children: [
|
|
446
447
|
/* @__PURE__ */ e(we, { className: "h-3.5 w-3.5 animate-spin" }),
|
|
447
448
|
"Saving…"
|
|
448
449
|
] }) : "Save" })
|
|
449
450
|
] })
|
|
450
451
|
] }) });
|
|
451
452
|
}
|
|
452
|
-
const
|
|
453
|
+
const F = 6, le = 1, ie = 20, Y = "text-[10px] font-medium uppercase tracking-[0.08em] text-muted-foreground";
|
|
453
454
|
function Me(r) {
|
|
454
|
-
return Number.isNaN(r) ?
|
|
455
|
+
return Number.isNaN(r) ? F : Math.min(ie, Math.max(le, r));
|
|
455
456
|
}
|
|
456
457
|
function $e({
|
|
457
458
|
open: r,
|
|
458
459
|
onOpenChange: i,
|
|
459
460
|
dashboard: t,
|
|
460
|
-
onApply:
|
|
461
|
+
onApply: g,
|
|
461
462
|
disabled: o = !1
|
|
462
463
|
}) {
|
|
463
|
-
const [h, N] = f(!1), [S,
|
|
464
|
-
|
|
465
|
-
r && (N((n == null ? void 0 : n.enabled) === !0),
|
|
464
|
+
const [h, N] = f(!1), [S, x] = f("top"), [b, u] = f(String(F)), n = t.summary;
|
|
465
|
+
q(() => {
|
|
466
|
+
r && (N((n == null ? void 0 : n.enabled) === !0), x((n == null ? void 0 : n.position) === "bottom" ? "bottom" : "top"), u(String((n == null ? void 0 : n.maxItems) ?? F)));
|
|
466
467
|
}, [r, n == null ? void 0 : n.enabled, n == null ? void 0 : n.position, n == null ? void 0 : n.maxItems]);
|
|
467
|
-
const y =
|
|
468
|
-
() => Me(Number.parseInt(
|
|
469
|
-
[
|
|
468
|
+
const y = U(
|
|
469
|
+
() => Me(Number.parseInt(b || `${F}`, 10)),
|
|
470
|
+
[b]
|
|
470
471
|
);
|
|
471
|
-
return /* @__PURE__ */ e(Q, { open: r, onOpenChange: i, children: /* @__PURE__ */ a(ee, { className: "rounded-
|
|
472
|
+
return /* @__PURE__ */ e(Q, { open: r, onOpenChange: i, children: /* @__PURE__ */ a(ee, { className: "rounded-control border-border/60 sm:max-w-[420px] sm:rounded-control", children: [
|
|
472
473
|
/* @__PURE__ */ a(ae, { children: [
|
|
473
474
|
/* @__PURE__ */ e(te, { className: "text-[15px]", children: "Summary Settings" }),
|
|
474
475
|
/* @__PURE__ */ e(se, { className: "text-[13px] leading-5", children: "Configure dashboard-level summary display. Card-level summary settings still control which cards contribute." })
|
|
@@ -488,13 +489,13 @@ function $e({
|
|
|
488
489
|
)
|
|
489
490
|
] }),
|
|
490
491
|
/* @__PURE__ */ a("div", { className: "space-y-1.5", children: [
|
|
491
|
-
/* @__PURE__ */ e(P, { htmlFor: "dashboard-summary-position", className:
|
|
492
|
+
/* @__PURE__ */ e(P, { htmlFor: "dashboard-summary-position", className: Y, children: "Position" }),
|
|
492
493
|
/* @__PURE__ */ a(
|
|
493
494
|
Ce,
|
|
494
495
|
{
|
|
495
496
|
value: S,
|
|
496
497
|
disabled: o,
|
|
497
|
-
onValueChange: (p) =>
|
|
498
|
+
onValueChange: (p) => x(p),
|
|
498
499
|
children: [
|
|
499
500
|
/* @__PURE__ */ e(Te, { id: "dashboard-summary-position", size: "xs", children: /* @__PURE__ */ e(Ie, { placeholder: "Select position" }) }),
|
|
500
501
|
/* @__PURE__ */ a(Pe, { children: [
|
|
@@ -506,7 +507,7 @@ function $e({
|
|
|
506
507
|
)
|
|
507
508
|
] }),
|
|
508
509
|
/* @__PURE__ */ a("div", { className: "space-y-1.5", children: [
|
|
509
|
-
/* @__PURE__ */ e(P, { htmlFor: "dashboard-summary-max-items", className:
|
|
510
|
+
/* @__PURE__ */ e(P, { htmlFor: "dashboard-summary-max-items", className: Y, children: "Max items" }),
|
|
510
511
|
/* @__PURE__ */ e(
|
|
511
512
|
Ae,
|
|
512
513
|
{
|
|
@@ -516,7 +517,7 @@ function $e({
|
|
|
516
517
|
min: le,
|
|
517
518
|
max: ie,
|
|
518
519
|
disabled: o,
|
|
519
|
-
value:
|
|
520
|
+
value: b,
|
|
520
521
|
onChange: (p) => u(p.target.value),
|
|
521
522
|
onBlur: () => u(String(y))
|
|
522
523
|
}
|
|
@@ -528,7 +529,7 @@ function $e({
|
|
|
528
529
|
/* @__PURE__ */ a(re, { children: [
|
|
529
530
|
/* @__PURE__ */ e(A, { variant: "outline", size: "xs", onClick: () => i(!1), children: "Cancel" }),
|
|
530
531
|
/* @__PURE__ */ e(A, { size: "xs", onClick: () => {
|
|
531
|
-
|
|
532
|
+
g({
|
|
532
533
|
enabled: h,
|
|
533
534
|
position: S,
|
|
534
535
|
maxItems: y
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";const u=require("./index-D7KJindZ.js");function x(r,e){const t=u.toDate(r),a=u.toDate(e),c=t.getTime()-a.getTime();return c<0?-1:c>0?1:c}function Z(r){return u.constructFrom(r,Date.now())}function O(r,e){const t=u.toDate(r),a=u.toDate(e),c=t.getFullYear()-a.getFullYear(),f=t.getMonth()-a.getMonth();return c*12+f}function _(r){return e=>{const a=(r?Math[r]:Math.trunc)(e);return a===0?0:a}}function v(r,e){return+u.toDate(r)-+u.toDate(e)}function C(r){const e=u.toDate(r);return e.setHours(23,59,59,999),e}function X(r){const e=u.toDate(r),t=e.getMonth();return e.setFullYear(e.getFullYear(),t+1,0),e.setHours(23,59,59,999),e}function R(r){const e=u.toDate(r);return+C(e)==+X(e)}function U(r,e){const t=u.toDate(r),a=u.toDate(e),c=x(t,a),f=Math.abs(O(t,a));let n;if(f<1)n=0;else{t.getMonth()===1&&t.getDate()>27&&t.setDate(30),t.setMonth(t.getMonth()-c*f);let i=x(t,a)===-c;R(u.toDate(r))&&f===1&&x(r,a)===1&&(i=!1),n=c*(f-Number(i))}return n===0?0:n}function A(r,e,t){const a=v(r,e)/1e3;return _(t==null?void 0:t.roundingMethod)(a)}function W(r,e,t){const a=u.getDefaultOptions(),c=(t==null?void 0:t.locale)??a.locale??u.enUS,f=2520,n=x(r,e);if(isNaN(n))throw new RangeError("Invalid time value");const i=Object.assign({},t,{addSuffix:t==null?void 0:t.addSuffix,comparison:n});let s,D;n>0?(s=u.toDate(e),D=u.toDate(r)):(s=u.toDate(r),D=u.toDate(e));const m=A(D,s),T=(u.getTimezoneOffsetInMilliseconds(D)-u.getTimezoneOffsetInMilliseconds(s))/1e3,l=Math.round((m-T)/60);let d;if(l<2)return t!=null&&t.includeSeconds?m<5?c.formatDistance("lessThanXSeconds",5,i):m<10?c.formatDistance("lessThanXSeconds",10,i):m<20?c.formatDistance("lessThanXSeconds",20,i):m<40?c.formatDistance("halfAMinute",0,i):m<60?c.formatDistance("lessThanXMinutes",1,i):c.formatDistance("xMinutes",1,i):l===0?c.formatDistance("lessThanXMinutes",1,i):c.formatDistance("xMinutes",l,i);if(l<45)return c.formatDistance("xMinutes",l,i);if(l<90)return c.formatDistance("aboutXHours",1,i);if(l<u.minutesInDay){const g=Math.round(l/60);return c.formatDistance("aboutXHours",g,i)}else{if(l<f)return c.formatDistance("xDays",1,i);if(l<u.minutesInMonth){const g=Math.round(l/u.minutesInDay);return c.formatDistance("xDays",g,i)}else if(l<u.minutesInMonth*2)return d=Math.round(l/u.minutesInMonth),c.formatDistance("aboutXMonths",d,i)}if(d=U(D,s),d<12){const g=Math.round(l/u.minutesInMonth);return c.formatDistance("xMonths",g,i)}else{const g=d%12,M=Math.trunc(d/12);return g<3?c.formatDistance("aboutXYears",M,i):g<9?c.formatDistance("overXYears",M,i):c.formatDistance("almostXYears",M+1,i)}}function L(r,e){return W(r,Z(r),e)}function $(r){if(!r)return!1;const e=r.toLowerCase().replace("_","-");return e==="en-in"||e.startsWith("en-in-")}function G(r,e){const t=Math.abs(r);return t>=1e12?{divisor:1e12,suffix:"T"}:t>=1e9?{divisor:1e9,suffix:"B"}:$(e)&&t>=1e7?{divisor:1e7,suffix:"Cr"}:t>=1e6?{divisor:1e6,suffix:"M"}:$(e)&&t>=1e5?{divisor:1e5,suffix:"L"}:t>=1e3?{divisor:1e3,suffix:"K"}:{divisor:1,suffix:""}}function y(r,e){try{const t=h(e);return G(r,t)}catch{return G(r,"en-US")}}function V(r){try{return new Intl.NumberFormat(r),!0}catch{return!1}}function h(r){return r&&V(r)?r:"en-US"}function N(r,e){if(r==null||isNaN(r))return"";const t=h(e==null?void 0:e.locale);let a=r;if(e!=null&&e.multiplyBy&&(a*=e.multiplyBy),e!=null&&e.useSuffix){const{divisor:f,suffix:n}=y(a,t);a=a/f;const i=new Intl.NumberFormat(t,{minimumFractionDigits:(e==null?void 0:e.minimumFractionDigits)??0,maximumFractionDigits:(e==null?void 0:e.maximumFractionDigits)??2,useGrouping:(e==null?void 0:e.useGrouping)??!0}).format(a);return`${(e==null?void 0:e.prefix)??""}${i}${n}${(e==null?void 0:e.suffix)??""}`}const c=new Intl.NumberFormat(t,{minimumFractionDigits:(e==null?void 0:e.minimumFractionDigits)??0,maximumFractionDigits:(e==null?void 0:e.maximumFractionDigits)??2,useGrouping:(e==null?void 0:e.useGrouping)??!0}).format(a);if(e!=null&&e.negativeInParentheses&&a<0){const f=c.replace("-","");return`(${(e==null?void 0:e.prefix)??""}${f}${(e==null?void 0:e.suffix)??""})`}return`${(e==null?void 0:e.prefix)??""}${c}${(e==null?void 0:e.suffix)??""}`}function P(r,e){if(r==null||isNaN(r))return"";const t=h(e==null?void 0:e.locale),a=(e==null?void 0:e.currency)||"USD",c=r<0,f=!!(e!=null&&e.negativeInParentheses&&c),n=f?Math.abs(r):r;try{if(e!=null&&e.useSuffix){const{divisor:s,suffix:D}=y(n,t),m=n/s,l=`${new Intl.NumberFormat(t,{style:"currency",currency:a,minimumFractionDigits:(e==null?void 0:e.minimumFractionDigits)??0,maximumFractionDigits:(e==null?void 0:e.maximumFractionDigits)??2,useGrouping:(e==null?void 0:e.useGrouping)??!0}).format(m)}${D}`;return f?`(${l})`:l}const i=new Intl.NumberFormat(t,{style:"currency",currency:a,minimumFractionDigits:(e==null?void 0:e.minimumFractionDigits)??0,maximumFractionDigits:(e==null?void 0:e.maximumFractionDigits)??2,useGrouping:(e==null?void 0:e.useGrouping)??!0}).format(n);return f?`(${i})`:i}catch{const i=Math.abs(r),s=e!=null&&e.useSuffix?y(i,t):{divisor:1,suffix:""},D=N(i/s.divisor,{locale:t,minimumFractionDigits:(e==null?void 0:e.minimumFractionDigits)??0,maximumFractionDigits:(e==null?void 0:e.maximumFractionDigits)??2,useGrouping:(e==null?void 0:e.useGrouping)??!0}),m=`${a} ${D}${s.suffix}`;return c?e!=null&&e.negativeInParentheses?`(${m})`:`-${m}`:m}}function S(r,e){if(r==null||isNaN(r))return"";const t=h(e==null?void 0:e.locale),c=(e==null?void 0:e.alreadyPercent)??(e==null?void 0:e.percentValueMode)==="whole"?r/100:r;return new Intl.NumberFormat(t,{style:"percent",minimumFractionDigits:(e==null?void 0:e.minimumFractionDigits)??0,maximumFractionDigits:(e==null?void 0:e.maximumFractionDigits)??2,useGrouping:(e==null?void 0:e.useGrouping)??!0}).format(c)}function w(r,e){if(r==null||isNaN(r))return"";const t=h(e==null?void 0:e.locale);return new Intl.NumberFormat(t,{notation:"scientific",minimumFractionDigits:(e==null?void 0:e.minimumFractionDigits)??0,maximumFractionDigits:(e==null?void 0:e.maximumFractionDigits)??2}).format(r)}function Y(r,e,t="en-US"){if(r==null||isNaN(r))return"";const a=h((e==null?void 0:e.locale)||t),c=(e==null?void 0:e.style)||"decimal";if(c==="percent"){const n=((e==null?void 0:e.percentValueMode)??"whole")==="whole"?r/100:r;return new Intl.NumberFormat(a,{style:"percent",minimumFractionDigits:(e==null?void 0:e.minimumFractionDigits)??0,maximumFractionDigits:(e==null?void 0:e.maximumFractionDigits)??2,useGrouping:(e==null?void 0:e.useGrouping)??!0}).format(n)}return c==="currency"?new Intl.NumberFormat(a,{style:"currency",currency:(e==null?void 0:e.currency)||"USD",minimumFractionDigits:(e==null?void 0:e.minimumFractionDigits)??0,maximumFractionDigits:(e==null?void 0:e.maximumFractionDigits)??2,useGrouping:(e==null?void 0:e.useGrouping)??!0}).format(r):c==="scientific"?w(r,{locale:a,minimumFractionDigits:(e==null?void 0:e.minimumFractionDigits)??0,maximumFractionDigits:(e==null?void 0:e.maximumFractionDigits)??2}):new Intl.NumberFormat(a,{minimumFractionDigits:(e==null?void 0:e.minimumFractionDigits)??0,maximumFractionDigits:(e==null?void 0:e.maximumFractionDigits)??2,useGrouping:(e==null?void 0:e.useGrouping)??!0}).format(r)}function B(r,e,t){const a={style:e==="currency"?"currency":e==="percent"?"percent":"decimal",locale:t==null?void 0:t.locale,currency:t==null?void 0:t.currency,minimumFractionDigits:t==null?void 0:t.decimalPlaces,maximumFractionDigits:t==null?void 0:t.decimalPlaces,useSuffix:t==null?void 0:t.useSuffix,prefix:t==null?void 0:t.prefix,suffix:t==null?void 0:t.suffix,negativeInParentheses:t==null?void 0:t.negativeInParentheses,multiplyBy:t==null?void 0:t.multiplyBy};switch(e){case"currency":return P(r,a);case"percent":return S(r,a);case"scientific":return w(r,a);default:return N(r,a)}}function k(r,e){return r&&r!=="auto"?r:e}function H(r,e=new Date){try{const t={timeZone:r,timeZoneName:"short"},c=new Intl.DateTimeFormat("en-US",t).formatToParts(e).find(f=>f.type==="timeZoneName");return(c==null?void 0:c.value)||r}catch{return r}}function E(r){try{const e={timeZone:r,timeZoneName:"long"},a=new Intl.DateTimeFormat("en-US",e).formatToParts(new Date).find(c=>c.type==="timeZoneName");return(a==null?void 0:a.value)||r}catch{return r}}function I(r,e="auto"){if(!r)return new Date(NaN);const t=r.endsWith("Z"),a=/[+-]\d{2}:?\d{2}$/.test(r),c=/\([A-Z]{3,4}\)$/.test(r);if(e==="auto")return t||a||c?new Date(r):new Date(r+"Z");if(e==="local"){if(t||a){const f=r.replace(/Z$/,"").replace(/[+-]\d{2}:?\d{2}$/,"");return new Date(f)}return new Date(r)}else return e==="UTC"?t?new Date(r):a?new Date(r):new Date(r+"Z"):t||a||c?new Date(r):u.fromZonedTime(r,e)}const j="MM/dd/yyyy",q=(r,e,t,a="auto")=>{if(!r)return"";try{const c=I(r,a);if(isNaN(c.getTime()))return r;const n=(e&&e.trim()?e:j).replace(/LLLL/g,"MMMM").replace(/LLL/g,"MMM");return t&&t!=="auto"?u.formatInTimeZone(c,t,n):u.format(c,n)}catch(c){return console.error("Date formatting error:",c),r}},K=(r,e="auto")=>{if(!r)return"";try{const t=I(r,e);return isNaN(t.getTime())?r:L(t,{addSuffix:!0})}catch(t){return console.error("Relative time formatting error:",t),r}};exports.formatCurrency=P;exports.formatDate=q;exports.formatDistanceToNow=L;exports.formatNumber=N;exports.formatNumberCustom=B;exports.formatNumberWithColumnSettings=Y;exports.formatPercent=S;exports.formatRelativeTime=K;exports.formatScientific=w;exports.getTimezoneAbbreviation=H;exports.getTimezoneName=E;exports.parseWithSourceTimezone=I;exports.resolveTimezone=k;
|