react-semaphor 0.1.287 → 0.1.289

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.
Files changed (30) hide show
  1. package/dist/chunks/{dashboard-controls-B8xnCPTZ.js → dashboard-controls-BZpyFg-k.js} +4 -4
  2. package/dist/chunks/{dashboard-controls-C25JMBLV.js → dashboard-controls-Dsh15H8E.js} +1 -1
  3. package/dist/chunks/{dashboard-filter-controls-button-D-o6ofi2.js → dashboard-filter-controls-button-CG5DgZpQ.js} +3 -3
  4. package/dist/chunks/{dashboard-filter-controls-button-BOJUiKGk.js → dashboard-filter-controls-button-DJvp8skg.js} +1 -1
  5. package/dist/chunks/{dashboard-json-DFuRB4cG.js → dashboard-json-CPhdiaLF.js} +1 -1
  6. package/dist/chunks/{dashboard-json-BYCWtm_z.js → dashboard-json-cootX4Nq.js} +1 -1
  7. package/dist/chunks/{dashboard-summary-settings-dialog-CsnHeIhi.js → dashboard-summary-settings-dialog-DOaMWikr.js} +1 -1
  8. package/dist/chunks/{dashboard-summary-settings-dialog-CFTJNcmp.js → dashboard-summary-settings-dialog-F6Dl15za.js} +1 -1
  9. package/dist/chunks/{edit-dashboard-visual-YmESbDUP.js → edit-dashboard-visual-DIpn7oJy.js} +4354 -4315
  10. package/dist/chunks/edit-dashboard-visual-fAiZdiCV.js +188 -0
  11. package/dist/chunks/{index-Bz0-3JKw.js → index-Cab2h5Fi.js} +1917 -1915
  12. package/dist/chunks/{index-BDE8cMG8.js → index-CnmC-NR5.js} +38 -38
  13. package/dist/chunks/{resource-management-panel-Lxjcn4i0.js → resource-management-panel-AZ46U35q.js} +2 -2
  14. package/dist/chunks/{resource-management-panel-C6qnO0ID.js → resource-management-panel-gJirpIDQ.js} +1 -1
  15. package/dist/chunks/{use-create-flow-overlay-state-AXNDXDqV.js → use-create-flow-overlay-state-3oPHFeIs.js} +1 -1
  16. package/dist/chunks/{use-create-flow-overlay-state-CJiyn4FY.js → use-create-flow-overlay-state-B6yjr4UZ.js} +2 -2
  17. package/dist/chunks/use-visual-utils-CyzOMb7j.js +334 -0
  18. package/dist/chunks/use-visual-utils-DmENJikx.js +1 -0
  19. package/dist/dashboard/index.cjs +1 -1
  20. package/dist/dashboard/index.js +1 -1
  21. package/dist/index.cjs +1 -1
  22. package/dist/index.js +5 -5
  23. package/dist/surfboard/index.cjs +1 -1
  24. package/dist/surfboard/index.js +2 -2
  25. package/dist/types/main.d.ts +5 -0
  26. package/dist/types/types.d.ts +5 -0
  27. package/package.json +1 -1
  28. package/dist/chunks/edit-dashboard-visual-DU3NzdD5.js +0 -193
  29. package/dist/chunks/use-visual-utils-BygqTxyR.js +0 -1
  30. package/dist/chunks/use-visual-utils-CWVz-eYg.js +0 -353
@@ -1,14 +1,14 @@
1
1
  import { jsxs as o, jsx as e, Fragment as I } from "react/jsx-runtime";
2
- import { bM as ce, dp as qs, u as D, cC as ta, cD as ra, B as A, cF as na, cG as Q, dq as oa, N as qa, b as $, d as ia, dr as Hs, ct as la, e as ca, f as da, g as ua, h as Ha, L as Ke, I as le, v as zs, a7 as K, ds as Ce, cK as Qe, dt as js, du as Pa, dv as za, c as Y, dw as ja, dx as Bs, c$ as ma, dy as Ks, dz as Qs, dA as Ws, dB as Js, dC as Xs, dD as Ys, H as Ae, W as Le, x as k, dE as ke, dF as Ba, dG as Ka, d8 as Zs, dH as et, w as Z, cJ as J, dI as at, dJ as st, dK as We, dL as tt, dM as rt, dN as Qa, dO as Wa, dP as Ee, dQ as Me, d4 as Je, cP as Xe, dR as Ye, ch as Ja, dS as Ze, cc as Xa, dT as nt, cS as Ya, cT as Za, cU as es, cV as as, cW as ss, cX as ts, cY as rs, cZ as ea, dU as ns, cB as ot, dV as it, ag as lt, U as Ua, af as we, dW as ct, am as dt, ah as He, dX as ut, dY as mt, dZ as ht, aB as pt, d_ as ft, d$ as gt, bT as vt, bU as bt, bV as yt, e0 as Nt, bW as St, cH as Dt, at as xt, e1 as wt, e2 as Ct, dn as Et, e3 as Mt, e4 as At, cE as Lt, a9 as kt, cM as It, e5 as Ot, al as Tt, aa as _t, as as Pt, e6 as Ut } from "./index-Bz0-3JKw.js";
2
+ import { bM as ce, dp as qs, u as D, cC as ta, cD as ra, B as A, cF as na, cG as Q, dq as oa, N as qa, b as $, d as ia, dr as Hs, ct as la, e as ca, f as da, g as ua, h as Ha, L as Ke, I as le, v as zs, a7 as K, ds as Ce, cK as Qe, dt as js, du as Pa, dv as za, c as Y, dw as ja, dx as Bs, c$ as ma, dy as Ks, dz as Qs, dA as Ws, dB as Js, dC as Xs, dD as Ys, H as Ae, W as Le, x as k, dE as ke, dF as Ba, dG as Ka, d8 as Zs, dH as et, w as Z, cJ as J, dI as at, dJ as st, dK as We, dL as tt, dM as rt, dN as Qa, dO as Wa, dP as Ee, dQ as Me, d4 as Je, cP as Xe, dR as Ye, ch as Ja, dS as Ze, cc as Xa, dT as nt, cS as Ya, cT as Za, cU as es, cV as as, cW as ss, cX as ts, cY as rs, cZ as ea, dU as ns, cB as ot, dV as it, ag as lt, U as Ua, af as we, dW as ct, am as dt, ah as He, dX as ut, dY as mt, dZ as ht, aB as pt, d_ as ft, d$ as gt, bT as vt, bU as bt, bV as yt, e0 as Nt, bW as St, cH as Dt, at as xt, e1 as wt, e2 as Ct, dn as Et, e3 as Mt, e4 as At, cE as Lt, a9 as kt, cM as It, e5 as Ot, al as Tt, aa as _t, as as Pt, e6 as Ut } from "./index-Cab2h5Fi.js";
3
3
  import * as M from "react";
4
4
  import os, { useState as N, useMemo as W, useCallback as Ra, useEffect as Rt } from "react";
5
5
  import "react-dom";
6
- import { b as Gt, u as Ft, d as $t, A as Vt, V as qt, N as Ht, c as zt, D as jt, U as Bt } from "./dashboard-filter-controls-button-D-o6ofi2.js";
6
+ import { b as Gt, u as Ft, d as $t, A as Vt, V as qt, N as Ht, c as zt, D as jt, U as Bt } from "./dashboard-filter-controls-button-CG5DgZpQ.js";
7
7
  import { l as Kt } from "./date-formatter-vkCj9Ct-.js";
8
- import { C as Qt, D as Wt } from "./dashboard-summary-settings-dialog-CFTJNcmp.js";
8
+ import { C as Qt, D as Wt } from "./dashboard-summary-settings-dialog-F6Dl15za.js";
9
9
  import { u as Jt } from "./use-debounced-dirty-check-BwAbnX_5.js";
10
10
  import { s as ze } from "./normalize-dashboard-for-dirty-check-5KpZN8xr.js";
11
- import { S as Ga } from "./use-create-flow-overlay-state-CJiyn4FY.js";
11
+ import { S as Ga } from "./use-create-flow-overlay-state-B6yjr4UZ.js";
12
12
  /**
13
13
  * @license lucide-react v0.453.0 - ISC
14
14
  *
@@ -1,4 +1,4 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),s=require("./index-BDE8cMG8.js"),x=require("react");require("react-dom");const P=require("./dashboard-filter-controls-button-BOJUiKGk.js"),_s=require("./date-formatter-CqXdM6JO.js"),Xe=require("./dashboard-summary-settings-dialog-CsnHeIhi.js"),Us=require("./use-debounced-dirty-check-XHSwAefL.js"),Ne=require("./normalize-dashboard-for-dirty-check-BXRUMVb2.js"),Ye=require("./use-create-flow-overlay-state-AXNDXDqV.js");function Rs(t){const o=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(t){for(const a in t)if(a!=="default"){const r=Object.getOwnPropertyDescriptor(t,a);Object.defineProperty(o,a,r.get?r:{enumerable:!0,get:()=>t[a]})}}return o.default=t,Object.freeze(o)}const C=Rs(x);/**
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),s=require("./index-CnmC-NR5.js"),x=require("react");require("react-dom");const P=require("./dashboard-filter-controls-button-DJvp8skg.js"),_s=require("./date-formatter-CqXdM6JO.js"),Xe=require("./dashboard-summary-settings-dialog-DOaMWikr.js"),Us=require("./use-debounced-dirty-check-XHSwAefL.js"),Ne=require("./normalize-dashboard-for-dirty-check-BXRUMVb2.js"),Ye=require("./use-create-flow-overlay-state-3oPHFeIs.js");function Rs(t){const o=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(t){for(const a in t)if(a!=="default"){const r=Object.getOwnPropertyDescriptor(t,a);Object.defineProperty(o,a,r.get?r:{enumerable:!0,get:()=>t[a]})}}return o.default=t,Object.freeze(o)}const C=Rs(x);/**
2
2
  * @license lucide-react v0.453.0 - ISC
3
3
  *
4
4
  * This source code is licensed under the ISC license.
@@ -1,8 +1,8 @@
1
1
  import ge, { useState as L, useRef as O, useCallback as M, useEffect as F, useContext as be } from "react";
2
- import { bM as ee, b as _, aC as k, bJ as $, bF as te, bG as j, aD as ae, bE as xe, d as se, e as re, f as oe, g as ne, h as ie, L as K, I as Ce, d8 as we, v as ye, B as S, w as H, U as R, J as Ne, u as z, K as De, N as X, d9 as Ae, da as W, x as P, b_ as le, af as Se, cC as de, cD as ce, a6 as ue, cF as he, cG as U, s as Ee, cK as Ie, ct as Le, M as Fe, db as Te, c as V, dc as G, dd as ke, cS as Ue, cT as Ve, cU as Me, cV as Pe, cW as ze, cX as Be, cY as Oe, as as Re, bL as _e, X as $e, de as je, df as He, cz as Xe, bH as q, a8 as Ge, aF as Ke, P as me, j as pe, dg as We, l as fe, dh as qe, di as Je, dj as Qe, dk as Ye, dl as Ze, dm as J, dn as et } from "./index-Bz0-3JKw.js";
2
+ import { bM as ee, b as _, aC as k, bJ as $, bF as te, bG as j, aD as ae, bE as xe, d as se, e as re, f as oe, g as ne, h as ie, L as K, I as Ce, d8 as we, v as ye, B as S, w as H, U as R, J as Ne, u as z, K as De, N as X, d9 as Ae, da as W, x as P, b_ as le, af as Se, cC as de, cD as ce, a6 as ue, cF as he, cG as U, s as Ee, cK as Ie, ct as Le, M as Fe, db as Te, c as V, dc as G, dd as ke, cS as Ue, cT as Ve, cU as Me, cV as Pe, cW as ze, cX as Be, cY as Oe, as as Re, bL as _e, X as $e, de as je, df as He, cz as Xe, bH as q, a8 as Ge, aF as Ke, P as me, j as pe, dg as We, l as fe, dh as qe, di as Je, dj as Qe, dk as Ye, dl as Ze, dm as J, dn as et } from "./index-Cab2h5Fi.js";
3
3
  import { jsx as t, jsxs as s, Fragment as B } from "react/jsx-runtime";
4
- import { V as tt, E as at, a as st, b as rt, L as ot, c as nt, d as it, C as lt, u as dt, e as ct } from "./use-create-flow-overlay-state-CJiyn4FY.js";
5
- import { u as ve } from "./use-visual-utils-CWVz-eYg.js";
4
+ import { V as tt, E as at, a as st, b as rt, L as ot, c as nt, d as it, C as lt, u as dt, e as ct } from "./use-create-flow-overlay-state-B6yjr4UZ.js";
5
+ import { u as ve } from "./use-visual-utils-CyzOMb7j.js";
6
6
  import { k as Q } from "./date-formatter-vkCj9Ct-.js";
7
7
  /**
8
8
  * @license lucide-react v0.453.0 - ISC
@@ -1,4 +1,4 @@
1
- "use strict";const g=require("react"),e=require("./index-BDE8cMG8.js"),t=require("react/jsx-runtime"),I=require("./use-create-flow-overlay-state-AXNDXDqV.js"),M=require("./use-visual-utils-BygqTxyR.js"),L=require("./date-formatter-CqXdM6JO.js");/**
1
+ "use strict";const g=require("react"),e=require("./index-CnmC-NR5.js"),t=require("react/jsx-runtime"),I=require("./use-create-flow-overlay-state-3oPHFeIs.js"),M=require("./use-visual-utils-DmENJikx.js"),L=require("./date-formatter-CqXdM6JO.js");/**
2
2
  * @license lucide-react v0.453.0 - ISC
3
3
  *
4
4
  * This source code is licensed under the ISC license.
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const o=require("react/jsx-runtime"),r=require("react"),s=require("./index-BDE8cMG8.js");require("react-dom");function b(){const t=s.useDashboardStore(e=>e.dashboard),i=s.useDashboardStore(e=>e.actions.setDashboard),h=s.useDashboardStore(e=>e.showDashboardJSON),u=s.useDashboardStore(e=>e.actions.setShowDashboardJSON),a=r.useMemo(()=>t?JSON.stringify(t,null,2):"",[t]),[l,d]=r.useState(a),n=r.useRef(a);return r.useEffect(()=>{a!==n.current&&(d(a),n.current=a)},[a]),o.jsxs("div",{className:s.cn("relative p-2",{hidden:!h}),children:[o.jsxs(s.Button,{variant:"secondary",size:"sm",className:"absolute right-2 top-2 z-10 h-8",onClick:()=>u(!1),children:[o.jsx(s.X,{className:"mr-2 h-4 w-4"}),"Close"]}),o.jsx("div",{className:"h-[550px] overflow-hidden",children:o.jsx(s.CodeEditor,{value:l,onValueChange:e=>{d(e);try{const c=JSON.parse(e);n.current=JSON.stringify(c,null,2),i(c)}catch{}},language:"json"})})]})}exports.default=b;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const o=require("react/jsx-runtime"),r=require("react"),s=require("./index-CnmC-NR5.js");require("react-dom");function b(){const t=s.useDashboardStore(e=>e.dashboard),i=s.useDashboardStore(e=>e.actions.setDashboard),h=s.useDashboardStore(e=>e.showDashboardJSON),u=s.useDashboardStore(e=>e.actions.setShowDashboardJSON),a=r.useMemo(()=>t?JSON.stringify(t,null,2):"",[t]),[l,d]=r.useState(a),n=r.useRef(a);return r.useEffect(()=>{a!==n.current&&(d(a),n.current=a)},[a]),o.jsxs("div",{className:s.cn("relative p-2",{hidden:!h}),children:[o.jsxs(s.Button,{variant:"secondary",size:"sm",className:"absolute right-2 top-2 z-10 h-8",onClick:()=>u(!1),children:[o.jsx(s.X,{className:"mr-2 h-4 w-4"}),"Close"]}),o.jsx("div",{className:"h-[550px] overflow-hidden",children:o.jsx(s.CodeEditor,{value:l,onValueChange:e=>{d(e);try{const c=JSON.parse(e);n.current=JSON.stringify(c,null,2),i(c)}catch{}},language:"json"})})]})}exports.default=b;
@@ -1,6 +1,6 @@
1
1
  import { jsxs as c, jsx as t } from "react/jsx-runtime";
2
2
  import { useMemo as b, useState as f, useRef as m, useEffect as S } from "react";
3
- import { u as e, c as N, B as D, X as p, C as J } from "./index-Bz0-3JKw.js";
3
+ import { u as e, c as N, B as D, X as p, C as J } from "./index-Cab2h5Fi.js";
4
4
  import "react-dom";
5
5
  function x() {
6
6
  const o = e((s) => s.dashboard), i = e((s) => s.actions.setDashboard), h = e(
@@ -1 +1 @@
1
- "use strict";const e=require("react/jsx-runtime"),l=require("react"),a=require("./index-BDE8cMG8.js");function W(r={}){var C,I,P,D;const{authToken:o,tokenProps:s}=a.useSemaphorContext(),v=r.enabled??!0,d=(o==null?void 0:o.accessToken)??null,f=(s==null?void 0:s.apiServiceUrl)??null,[y,g]=l.useState(!1),[S,p]=l.useState(!1),[m,n]=l.useState(!1),[j,c]=l.useState(null),[x,w]=l.useState(null),k=x||{tz:((I=(C=s==null?void 0:s.params)==null?void 0:C.calendarContext)==null?void 0:I.tz)||null,weekStart:((D=(P=s==null?void 0:s.params)==null?void 0:P.calendarContext)==null?void 0:D.weekStart)??null},b=l.useCallback(async()=>{if(!(!v||!d||!f)){g(!0),c(null);try{const u=await fetch(`${f}/v1/user-preferences/calendar`,{method:"GET",headers:{Authorization:`Bearer ${d}`}});if(!u.ok){const h=await u.json().catch(()=>({}));throw new Error(h.error||"Failed to fetch preferences")}const i=await u.json();w({tz:i.tz,weekStart:i.weekStart,source:i.source,isInherited:i.isInherited,userHasPrefs:i.userHasPrefs,inherited:i.inherited})}catch(u){const i=u instanceof Error?u.message:"Unknown error";c(i)}finally{g(!1)}}},[d,f,v]);l.useEffect(()=>{v&&b()},[v,b]);const T=l.useCallback(async u=>{if(!d||!f)return c("Not authenticated"),!1;p(!0),c(null);try{const i=await fetch(`${f}/v1/user-preferences/calendar`,{method:"PATCH",headers:{"Content-Type":"application/json",Authorization:`Bearer ${d}`},body:JSON.stringify(u)});if(!i.ok){const h=await i.json().catch(()=>({}));throw new Error(h.error||"Failed to update preferences")}return await b(),!0}catch(i){const h=i instanceof Error?i.message:"Unknown error";return c(h),!1}finally{p(!1)}},[d,f,b]),N=l.useCallback(async()=>{if(!d||!f)return c("Not authenticated"),!1;n(!0),c(null);try{const u=await fetch(`${f}/v1/user-preferences/calendar`,{method:"DELETE",headers:{Authorization:`Bearer ${d}`}});if(!u.ok){const h=await u.json().catch(()=>({}));throw new Error(h.error||"Failed to clear preferences")}const i=await u.text();if(i)try{const h=JSON.parse(i);return w({tz:h.tz,weekStart:h.weekStart,source:h.source,isInherited:h.isInherited??!0,userHasPrefs:!1,inherited:h.inherited}),!0}catch{}return await b(),!0}catch(u){const i=u instanceof Error?u.message:"Unknown error";return c(i),!1}finally{n(!1)}},[d,f,b]);return{preferences:k,isLoading:y,isSaving:S,isClearing:m,error:j,updatePreferences:T,clearPreferences:N,refetch:b}}const A=[{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"}],H=[{value:0,label:"Sunday"},{value:1,label:"Monday"},{value:6,label:"Saturday"}];function G(){try{const r=Intl;if(r.supportedValuesOf)return r.supportedValuesOf("timeZone")}catch{}return A.map(r=>r.value)}function V(r){switch(r){case"tenant":return"tenant";case"organization":return"organization";case"system":return"system";default:return"default"}}function U(r){const o=A.find(s=>s.value===r);return o?o.label:r}function X(r){const o=H.find(s=>s.value===r);return o?o.label:String(r)}function q({open:r,onOpenChange:o}){var M,z,F;const{preferences:s,isLoading:v,isSaving:d,isClearing:f,updatePreferences:y,clearPreferences:g}=W({enabled:r}),S=s.tz||((M=s.inherited)==null?void 0:M.tz)||Intl.DateTimeFormat().resolvedOptions().timeZone,p=s.weekStart??((z=s.inherited)==null?void 0:z.weekStart)??1,[m,n]=l.useState(!s.userHasPrefs),[j,c]=l.useState(!1),[x,w]=l.useState(S),[k,b]=l.useState(p),[T,N]=l.useState(!1),C=l.useMemo(()=>G(),[]),I=l.useMemo(()=>C.filter(t=>!A.some(R=>R.value===t)),[C]),P=l.useMemo(()=>U(x),[x]),D=s.inherited?U(s.inherited.tz):"UTC",u=s.inherited?X(s.inherited.weekStart):"Monday",i=V((F=s.inherited)==null?void 0:F.source);l.useEffect(()=>{if(!r){c(!1);return}j||(s.userHasPrefs!==void 0&&n(!s.userHasPrefs),w(S),b(p))},[r,j,s.userHasPrefs,S,p]);const h=async()=>{if(v){a.ue.error("Preferences are still loading. Please try again.");return}m?await g()?(a.ue.success("Now using default settings. Please refresh the page to apply changes.",{duration:5e3}),o(!1)):a.ue.error("Failed to save preferences. Please try again."):await y({tz:x,weekStart:k})?(a.ue.success("Preferences saved. Please refresh the page to apply changes.",{duration:5e3}),o(!1)):a.ue.error("Failed to save preferences. Please try again.")},$=()=>{o(!1)},L=d||f,O=L||v;return e.jsx(a.Dialog,{open:r,onOpenChange:o,children:e.jsxs(a.DialogContent,{className:"sm:max-w-[425px]",children:[e.jsxs(a.DialogHeader,{children:[e.jsx(a.DialogTitle,{children:"Calendar Preferences"}),e.jsx(a.DialogDescription,{children:"Set your timezone and week start preferences for date calculations and displays."})]}),e.jsxs("div",{className:"space-y-6 py-4",children:[e.jsxs(a.RadioGroup,{value:m?"defaults":"custom",onValueChange:t=>{c(!0),n(t==="defaults")},className:"space-y-3",children:[e.jsxs("div",{className:a.cn("flex items-start space-x-3 rounded-lg border p-4 cursor-pointer transition-colors",m?"border-primary bg-primary/5":"border-border hover:border-muted-foreground/50"),onClick:()=>{c(!0),n(!0)},children:[e.jsx(a.RadioGroupItem,{value:"defaults",id:"mode-defaults"}),e.jsxs("div",{className:"flex-1 space-y-1",children:[e.jsxs(a.Label,{htmlFor:"mode-defaults",className:"cursor-pointer font-medium",children:["Use ",i," defaults"]}),e.jsxs("p",{className:"text-sm text-muted-foreground",children:[D,", Week starts ",u]})]})]}),e.jsxs("div",{className:a.cn("flex items-start space-x-3 rounded-lg border p-4 cursor-pointer transition-colors",m?"border-border hover:border-muted-foreground/50":"border-primary bg-primary/5"),onClick:()=>{c(!0),n(!1)},children:[e.jsx(a.RadioGroupItem,{value:"custom",id:"mode-custom"}),e.jsx(a.Label,{htmlFor:"mode-custom",className:"cursor-pointer font-medium",children:"Use custom settings"})]})]}),e.jsxs("div",{className:a.cn("space-y-6 transition-opacity",m&&"opacity-50 pointer-events-none"),children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(a.Label,{children:"Timezone"}),e.jsxs(a.Popover,{open:T,onOpenChange:N,modal:!0,children:[e.jsx(a.PopoverTrigger,{asChild:!0,children:e.jsxs(a.Button,{variant:"outline",role:"combobox","aria-expanded":T,className:"w-full justify-between",disabled:m,children:[P,e.jsx(a.ChevronsUpDown,{className:"ml-2 h-4 w-4 shrink-0 opacity-50"})]})}),e.jsx(a.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:A.map(t=>e.jsxs(a.CommandItem,{value:`${t.value} ${t.label}`,onSelect:()=>{c(!0),w(t.value),N(!1)},children:[e.jsx(a.Check,{className:a.cn("mr-2 h-4 w-4",x===t.value?"opacity-100":"opacity-0")}),e.jsx("span",{className:"flex-1",children:t.label}),e.jsx("span",{className:"text-xs text-muted-foreground",children:t.value})]},t.value))}),e.jsx(a.CommandSeparator,{}),e.jsx(a.CommandGroup,{heading:"All Timezones",children:I.map(t=>e.jsxs(a.CommandItem,{value:t,onSelect:()=>{c(!0),w(t),N(!1)},children:[e.jsx(a.Check,{className:a.cn("mr-2 h-4 w-4",x===t?"opacity-100":"opacity-0")}),t]},t))})]})]})})]})]}),e.jsxs("div",{className:"space-y-3",children:[e.jsx(a.Label,{children:"Week Starts On"}),e.jsx(a.RadioGroup,{value:String(k),onValueChange:t=>{c(!0),b(Number(t))},className:"flex gap-4",disabled:m,children:H.map(t=>e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx(a.RadioGroupItem,{value:String(t.value),id:`week-start-${t.value}`,disabled:m}),e.jsx(a.Label,{htmlFor:`week-start-${t.value}`,className:a.cn("cursor-pointer font-normal",m&&"cursor-not-allowed"),children:t.label})]},t.value))})]})]})]}),e.jsxs(a.DialogFooter,{children:[e.jsx(a.Button,{variant:"outline",onClick:$,disabled:L,children:"Cancel"}),e.jsx(a.Button,{onClick:h,disabled:O,children:L?e.jsxs(e.Fragment,{children:[e.jsx(a.LoaderCircle,{className:"mr-2 h-4 w-4 animate-spin"}),"Saving..."]}):"Save"})]})]})})}const E=6,B=1,_=20;function Z(r){return Number.isNaN(r)?E:Math.min(_,Math.max(B,r))}function J({open:r,onOpenChange:o,dashboard:s,onApply:v,disabled:d=!1}){const[f,y]=l.useState(!1),[g,S]=l.useState("top"),[p,m]=l.useState(String(E)),n=s.summary;l.useEffect(()=>{r&&(y((n==null?void 0:n.enabled)===!0),S((n==null?void 0:n.position)==="bottom"?"bottom":"top"),m(String((n==null?void 0:n.maxItems)??E)))},[r,n==null?void 0:n.enabled,n==null?void 0:n.position,n==null?void 0:n.maxItems]);const j=l.useMemo(()=>Z(Number.parseInt(p||`${E}`,10)),[p]),c=()=>{v({enabled:f,position:g,maxItems:j}),o(!1)};return e.jsx(a.Dialog,{open:r,onOpenChange:o,children:e.jsxs(a.DialogContent,{className:"sm:max-w-[420px]",children:[e.jsxs(a.DialogHeader,{children:[e.jsx(a.DialogTitle,{children:"Summary Settings"}),e.jsx(a.DialogDescription,{children:"Configure dashboard-level summary display. Card-level summary settings still control which cards contribute."})]}),e.jsxs("div",{className:"space-y-4 py-2",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(a.Label,{htmlFor:"dashboard-summary-enabled",children:"Enable Dashboard Summary"}),e.jsx(a.Switch,{size:"sm",id:"dashboard-summary-enabled",checked:f,disabled:d,onCheckedChange:y})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(a.Label,{htmlFor:"dashboard-summary-position",children:"Position"}),e.jsxs(a.Select,{value:g,disabled:d,onValueChange:x=>S(x),children:[e.jsx(a.SelectTrigger,{id:"dashboard-summary-position",children:e.jsx(a.SelectValue,{placeholder:"Select position"})}),e.jsxs(a.SelectContent,{children:[e.jsx(a.SelectItem,{value:"top",children:"Top"}),e.jsx(a.SelectItem,{value:"bottom",children:"Bottom"})]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(a.Label,{htmlFor:"dashboard-summary-max-items",children:"Max Items"}),e.jsx(a.Input,{id:"dashboard-summary-max-items",type:"number",min:B,max:_,disabled:d,value:p,onChange:x=>m(x.target.value),onBlur:()=>m(String(j))}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Display limit only. Computation is unchanged."})]}),d&&e.jsx("p",{className:"text-xs text-amber-700",children:"Enter dashboard edit mode to modify summary settings."})]}),e.jsxs(a.DialogFooter,{children:[e.jsx(a.Button,{variant:"outline",onClick:()=>o(!1),children:"Cancel"}),e.jsx(a.Button,{onClick:c,disabled:d,children:"Apply"})]})]})})}exports.CalendarPreferencesDialog=q;exports.DashboardSummarySettingsDialog=J;
1
+ "use strict";const e=require("react/jsx-runtime"),l=require("react"),a=require("./index-CnmC-NR5.js");function W(r={}){var C,I,P,D;const{authToken:o,tokenProps:s}=a.useSemaphorContext(),v=r.enabled??!0,d=(o==null?void 0:o.accessToken)??null,f=(s==null?void 0:s.apiServiceUrl)??null,[y,g]=l.useState(!1),[S,p]=l.useState(!1),[m,n]=l.useState(!1),[j,c]=l.useState(null),[x,w]=l.useState(null),k=x||{tz:((I=(C=s==null?void 0:s.params)==null?void 0:C.calendarContext)==null?void 0:I.tz)||null,weekStart:((D=(P=s==null?void 0:s.params)==null?void 0:P.calendarContext)==null?void 0:D.weekStart)??null},b=l.useCallback(async()=>{if(!(!v||!d||!f)){g(!0),c(null);try{const u=await fetch(`${f}/v1/user-preferences/calendar`,{method:"GET",headers:{Authorization:`Bearer ${d}`}});if(!u.ok){const h=await u.json().catch(()=>({}));throw new Error(h.error||"Failed to fetch preferences")}const i=await u.json();w({tz:i.tz,weekStart:i.weekStart,source:i.source,isInherited:i.isInherited,userHasPrefs:i.userHasPrefs,inherited:i.inherited})}catch(u){const i=u instanceof Error?u.message:"Unknown error";c(i)}finally{g(!1)}}},[d,f,v]);l.useEffect(()=>{v&&b()},[v,b]);const T=l.useCallback(async u=>{if(!d||!f)return c("Not authenticated"),!1;p(!0),c(null);try{const i=await fetch(`${f}/v1/user-preferences/calendar`,{method:"PATCH",headers:{"Content-Type":"application/json",Authorization:`Bearer ${d}`},body:JSON.stringify(u)});if(!i.ok){const h=await i.json().catch(()=>({}));throw new Error(h.error||"Failed to update preferences")}return await b(),!0}catch(i){const h=i instanceof Error?i.message:"Unknown error";return c(h),!1}finally{p(!1)}},[d,f,b]),N=l.useCallback(async()=>{if(!d||!f)return c("Not authenticated"),!1;n(!0),c(null);try{const u=await fetch(`${f}/v1/user-preferences/calendar`,{method:"DELETE",headers:{Authorization:`Bearer ${d}`}});if(!u.ok){const h=await u.json().catch(()=>({}));throw new Error(h.error||"Failed to clear preferences")}const i=await u.text();if(i)try{const h=JSON.parse(i);return w({tz:h.tz,weekStart:h.weekStart,source:h.source,isInherited:h.isInherited??!0,userHasPrefs:!1,inherited:h.inherited}),!0}catch{}return await b(),!0}catch(u){const i=u instanceof Error?u.message:"Unknown error";return c(i),!1}finally{n(!1)}},[d,f,b]);return{preferences:k,isLoading:y,isSaving:S,isClearing:m,error:j,updatePreferences:T,clearPreferences:N,refetch:b}}const A=[{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"}],H=[{value:0,label:"Sunday"},{value:1,label:"Monday"},{value:6,label:"Saturday"}];function G(){try{const r=Intl;if(r.supportedValuesOf)return r.supportedValuesOf("timeZone")}catch{}return A.map(r=>r.value)}function V(r){switch(r){case"tenant":return"tenant";case"organization":return"organization";case"system":return"system";default:return"default"}}function U(r){const o=A.find(s=>s.value===r);return o?o.label:r}function X(r){const o=H.find(s=>s.value===r);return o?o.label:String(r)}function q({open:r,onOpenChange:o}){var M,z,F;const{preferences:s,isLoading:v,isSaving:d,isClearing:f,updatePreferences:y,clearPreferences:g}=W({enabled:r}),S=s.tz||((M=s.inherited)==null?void 0:M.tz)||Intl.DateTimeFormat().resolvedOptions().timeZone,p=s.weekStart??((z=s.inherited)==null?void 0:z.weekStart)??1,[m,n]=l.useState(!s.userHasPrefs),[j,c]=l.useState(!1),[x,w]=l.useState(S),[k,b]=l.useState(p),[T,N]=l.useState(!1),C=l.useMemo(()=>G(),[]),I=l.useMemo(()=>C.filter(t=>!A.some(R=>R.value===t)),[C]),P=l.useMemo(()=>U(x),[x]),D=s.inherited?U(s.inherited.tz):"UTC",u=s.inherited?X(s.inherited.weekStart):"Monday",i=V((F=s.inherited)==null?void 0:F.source);l.useEffect(()=>{if(!r){c(!1);return}j||(s.userHasPrefs!==void 0&&n(!s.userHasPrefs),w(S),b(p))},[r,j,s.userHasPrefs,S,p]);const h=async()=>{if(v){a.ue.error("Preferences are still loading. Please try again.");return}m?await g()?(a.ue.success("Now using default settings. Please refresh the page to apply changes.",{duration:5e3}),o(!1)):a.ue.error("Failed to save preferences. Please try again."):await y({tz:x,weekStart:k})?(a.ue.success("Preferences saved. Please refresh the page to apply changes.",{duration:5e3}),o(!1)):a.ue.error("Failed to save preferences. Please try again.")},$=()=>{o(!1)},L=d||f,O=L||v;return e.jsx(a.Dialog,{open:r,onOpenChange:o,children:e.jsxs(a.DialogContent,{className:"sm:max-w-[425px]",children:[e.jsxs(a.DialogHeader,{children:[e.jsx(a.DialogTitle,{children:"Calendar Preferences"}),e.jsx(a.DialogDescription,{children:"Set your timezone and week start preferences for date calculations and displays."})]}),e.jsxs("div",{className:"space-y-6 py-4",children:[e.jsxs(a.RadioGroup,{value:m?"defaults":"custom",onValueChange:t=>{c(!0),n(t==="defaults")},className:"space-y-3",children:[e.jsxs("div",{className:a.cn("flex items-start space-x-3 rounded-lg border p-4 cursor-pointer transition-colors",m?"border-primary bg-primary/5":"border-border hover:border-muted-foreground/50"),onClick:()=>{c(!0),n(!0)},children:[e.jsx(a.RadioGroupItem,{value:"defaults",id:"mode-defaults"}),e.jsxs("div",{className:"flex-1 space-y-1",children:[e.jsxs(a.Label,{htmlFor:"mode-defaults",className:"cursor-pointer font-medium",children:["Use ",i," defaults"]}),e.jsxs("p",{className:"text-sm text-muted-foreground",children:[D,", Week starts ",u]})]})]}),e.jsxs("div",{className:a.cn("flex items-start space-x-3 rounded-lg border p-4 cursor-pointer transition-colors",m?"border-border hover:border-muted-foreground/50":"border-primary bg-primary/5"),onClick:()=>{c(!0),n(!1)},children:[e.jsx(a.RadioGroupItem,{value:"custom",id:"mode-custom"}),e.jsx(a.Label,{htmlFor:"mode-custom",className:"cursor-pointer font-medium",children:"Use custom settings"})]})]}),e.jsxs("div",{className:a.cn("space-y-6 transition-opacity",m&&"opacity-50 pointer-events-none"),children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(a.Label,{children:"Timezone"}),e.jsxs(a.Popover,{open:T,onOpenChange:N,modal:!0,children:[e.jsx(a.PopoverTrigger,{asChild:!0,children:e.jsxs(a.Button,{variant:"outline",role:"combobox","aria-expanded":T,className:"w-full justify-between",disabled:m,children:[P,e.jsx(a.ChevronsUpDown,{className:"ml-2 h-4 w-4 shrink-0 opacity-50"})]})}),e.jsx(a.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:A.map(t=>e.jsxs(a.CommandItem,{value:`${t.value} ${t.label}`,onSelect:()=>{c(!0),w(t.value),N(!1)},children:[e.jsx(a.Check,{className:a.cn("mr-2 h-4 w-4",x===t.value?"opacity-100":"opacity-0")}),e.jsx("span",{className:"flex-1",children:t.label}),e.jsx("span",{className:"text-xs text-muted-foreground",children:t.value})]},t.value))}),e.jsx(a.CommandSeparator,{}),e.jsx(a.CommandGroup,{heading:"All Timezones",children:I.map(t=>e.jsxs(a.CommandItem,{value:t,onSelect:()=>{c(!0),w(t),N(!1)},children:[e.jsx(a.Check,{className:a.cn("mr-2 h-4 w-4",x===t?"opacity-100":"opacity-0")}),t]},t))})]})]})})]})]}),e.jsxs("div",{className:"space-y-3",children:[e.jsx(a.Label,{children:"Week Starts On"}),e.jsx(a.RadioGroup,{value:String(k),onValueChange:t=>{c(!0),b(Number(t))},className:"flex gap-4",disabled:m,children:H.map(t=>e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx(a.RadioGroupItem,{value:String(t.value),id:`week-start-${t.value}`,disabled:m}),e.jsx(a.Label,{htmlFor:`week-start-${t.value}`,className:a.cn("cursor-pointer font-normal",m&&"cursor-not-allowed"),children:t.label})]},t.value))})]})]})]}),e.jsxs(a.DialogFooter,{children:[e.jsx(a.Button,{variant:"outline",onClick:$,disabled:L,children:"Cancel"}),e.jsx(a.Button,{onClick:h,disabled:O,children:L?e.jsxs(e.Fragment,{children:[e.jsx(a.LoaderCircle,{className:"mr-2 h-4 w-4 animate-spin"}),"Saving..."]}):"Save"})]})]})})}const E=6,B=1,_=20;function Z(r){return Number.isNaN(r)?E:Math.min(_,Math.max(B,r))}function J({open:r,onOpenChange:o,dashboard:s,onApply:v,disabled:d=!1}){const[f,y]=l.useState(!1),[g,S]=l.useState("top"),[p,m]=l.useState(String(E)),n=s.summary;l.useEffect(()=>{r&&(y((n==null?void 0:n.enabled)===!0),S((n==null?void 0:n.position)==="bottom"?"bottom":"top"),m(String((n==null?void 0:n.maxItems)??E)))},[r,n==null?void 0:n.enabled,n==null?void 0:n.position,n==null?void 0:n.maxItems]);const j=l.useMemo(()=>Z(Number.parseInt(p||`${E}`,10)),[p]),c=()=>{v({enabled:f,position:g,maxItems:j}),o(!1)};return e.jsx(a.Dialog,{open:r,onOpenChange:o,children:e.jsxs(a.DialogContent,{className:"sm:max-w-[420px]",children:[e.jsxs(a.DialogHeader,{children:[e.jsx(a.DialogTitle,{children:"Summary Settings"}),e.jsx(a.DialogDescription,{children:"Configure dashboard-level summary display. Card-level summary settings still control which cards contribute."})]}),e.jsxs("div",{className:"space-y-4 py-2",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(a.Label,{htmlFor:"dashboard-summary-enabled",children:"Enable Dashboard Summary"}),e.jsx(a.Switch,{size:"sm",id:"dashboard-summary-enabled",checked:f,disabled:d,onCheckedChange:y})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(a.Label,{htmlFor:"dashboard-summary-position",children:"Position"}),e.jsxs(a.Select,{value:g,disabled:d,onValueChange:x=>S(x),children:[e.jsx(a.SelectTrigger,{id:"dashboard-summary-position",children:e.jsx(a.SelectValue,{placeholder:"Select position"})}),e.jsxs(a.SelectContent,{children:[e.jsx(a.SelectItem,{value:"top",children:"Top"}),e.jsx(a.SelectItem,{value:"bottom",children:"Bottom"})]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(a.Label,{htmlFor:"dashboard-summary-max-items",children:"Max Items"}),e.jsx(a.Input,{id:"dashboard-summary-max-items",type:"number",min:B,max:_,disabled:d,value:p,onChange:x=>m(x.target.value),onBlur:()=>m(String(j))}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Display limit only. Computation is unchanged."})]}),d&&e.jsx("p",{className:"text-xs text-amber-700",children:"Enter dashboard edit mode to modify summary settings."})]}),e.jsxs(a.DialogFooter,{children:[e.jsx(a.Button,{variant:"outline",onClick:()=>o(!1),children:"Cancel"}),e.jsx(a.Button,{onClick:c,disabled:d,children:"Apply"})]})]})})}exports.CalendarPreferencesDialog=q;exports.DashboardSummarySettingsDialog=J;
@@ -1,6 +1,6 @@
1
1
  import { jsx as e, jsxs as a, Fragment as ce } from "react/jsx-runtime";
2
2
  import de, { useState as f, useCallback as j, useEffect as K, useMemo as F } from "react";
3
- import { b as ue, d as q, e as Y, f as Q, g as ee, h as ae, R, c as C, i as $, L as y, P as me, j as he, B as E, k as fe, l as pe, m as ve, n as be, o as Se, p as ge, q as V, r as G, s as X, t as ye, v as re, w as we, x as P, S as xe, y as Ne, z as ke, A as Ce, E as Te, F as Z, I as Ie } from "./index-Bz0-3JKw.js";
3
+ import { b as ue, d as q, e as Y, f as Q, g as ee, h as ae, R, c as C, i as $, L as y, P as me, j as he, B as E, k as fe, l as pe, m as ve, n as be, o as Se, p as ge, q as V, r as G, s as X, t as ye, v as re, w as we, x as P, S as xe, y as Ne, z as ke, A as Ce, E as Te, F as Z, I as Ie } from "./index-Cab2h5Fi.js";
4
4
  function Pe(s = {}) {
5
5
  var I, D, M, L;
6
6
  const { authToken: i, tokenProps: r } = ue(), S = s.enabled ?? !0, o = (i == null ? void 0 : i.accessToken) ?? null, h = (r == null ? void 0 : r.apiServiceUrl) ?? null, [N, w] = f(!1), [g, v] = f(!1), [u, n] = f(!1), [x, c] = f(null), [p, k] = f(null), A = p || {