react-semaphor 0.1.605 → 0.1.606
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/assistant-context/index.js +1 -1
- package/dist/brand-studio/index.js +1 -1
- package/dist/briefings/index.js +1 -1
- package/dist/chunks/{appearance-provider-CfoAVQuG.js → appearance-provider-fIhJSX6y.js} +106 -101
- package/dist/chunks/{assistant-chat-DgUaCE9k.js → assistant-chat-SBKSrrEA.js} +1 -1
- package/dist/chunks/{bookmark-impact-BAtemeyK.js → bookmark-impact-BW30cm5E.js} +1 -1
- package/dist/chunks/{brand-C9APUFaP.js → brand-CL5xDiFH.js} +1 -1
- package/dist/chunks/{card-filter-builder-ClWrXB7P.js → card-filter-builder-CzScSOQY.js} +1 -1
- package/dist/chunks/{dashboard-ChIcbVTx.js → dashboard-Cyhj9EOl.js} +1 -1
- package/dist/chunks/{dashboard-briefing-launcher-CwMlhkxV.js → dashboard-briefing-launcher-CyOFddmD.js} +1 -1
- package/dist/chunks/{dashboard-controls-UCSAFCGA.js → dashboard-controls-DpADfhr0.js} +1 -1
- package/dist/chunks/{dashboard-json-B120hYDa.js → dashboard-json-4xMChR2q.js} +1 -1
- package/dist/chunks/{dashboard-temporal-snapshot-BFJKbp_6.js → dashboard-temporal-snapshot-w3SMiPKj.js} +1 -1
- package/dist/chunks/{edit-dashboard-visual-DvHp03h_.js → edit-dashboard-visual-DlvY7au4.js} +3 -3
- package/dist/chunks/{filter-reach-preview-C5M5_hf_.js → filter-reach-preview-DAEIyrEG.js} +1 -1
- package/dist/chunks/{kpi-trend-rule-B87LNzcz.js → kpi-trend-rule-N1Xkwe_u.js} +1 -1
- package/dist/chunks/{layout-grid-CFzqJ7GC.js → layout-grid-Dtsioq4h.js} +1 -1
- package/dist/chunks/{palette-NvEIuXHN.js → palette-565cA0nh.js} +1 -1
- package/dist/chunks/{report-preferences-dialog-Bseb2Rlg.js → report-preferences-dialog-B2ZGPS9t.js} +1 -1
- package/dist/chunks/resolve-dashboard-input-context-SlAAe4GF.js +8 -0
- package/dist/chunks/{saved-dashboard-context-C3lWc4Dx.js → saved-dashboard-context-Bc2SVDr-.js} +1 -1
- package/dist/chunks/{semaphor-ready-indicator-BQarSo6S.js → semaphor-ready-indicator-Bj-cjkz-.js} +134 -134
- package/dist/chunks/{set-6mOnfQeH.js → set-CACXVM2A.js} +1 -1
- package/dist/chunks/{slider-BPnHdMGq.js → slider-CWze9OEM.js} +1 -1
- package/dist/chunks/{stored-dashboard-DfrxDLhR.js → stored-dashboard-CcNdU-mG.js} +1 -1
- package/dist/chunks/{variable-draft-B4_xqr4Y.js → variable-draft-CRbSYdB6.js} +1 -1
- package/dist/dashboard/index.js +1 -1
- package/dist/dashboard-authoring/index.js +1 -1
- package/dist/index.js +1 -1
- package/dist/style.css +1 -1
- package/dist/surfboard/index.js +1 -1
- package/dist/types/shared/dashboard-authoring/measure-calculations/index.d.ts +1 -1
- package/dist/types/shared/dashboard-authoring/measure-calculations/window-transforms.d.ts +2 -0
- package/package.json +1 -1
- package/dist/chunks/resolve-dashboard-input-context-BDY7KwRe.js +0 -8
|
@@ -1 +1 @@
|
|
|
1
|
-
import{m as a}from"./resolve-dashboard-input-context-
|
|
1
|
+
import{m as a}from"./resolve-dashboard-input-context-SlAAe4GF.js";import{b as d}from"./filter-reach-preview-DAEIyrEG.js";function T(n,o,t){const e=n.findIndex(s=>s.id===o);if(e===-1)return n;const i=n.filter((s,c)=>c!==e),r=Math.max(0,Math.min(Math.trunc(t),i.length));return r===e?n:[...i.slice(0,r),n[e],...i.slice(r)];}const u=/* @__PURE__ */new Set(["bar","line","pie","doughnut","table","detailTable","stackedBar","stackedLine","horizontalBar","radar","polarArea","scatter","bubble","funnel","custom"]);function _(n){return!!(n&&u.has(n));}const l=250;function g(n){return{id:n.id,...a(n.field,{dataSource:n.dataSource,connectionId:n.connectionId}),width:l};}function I(n,o,t){const e=n.flatMap(i=>{if(t!==void 0&&i.id!==t)return[];const r=(i.inlineFilters??[]).findIndex(s=>s.id===o);return r===-1?[]:[{card:i,filter:i.inlineFilters[r],index:r}];});return e.length===1?{kind:"found",...e[0]}:e.length>1?{kind:"ambiguous",cards:e.map(i=>i.card)}:{kind:"none"};}const m=["hour","day","week","month","quarter","year"],F=12,f={automatic:"Automatic",card:"Set on this card",trend_by:"From Trend By"};function P(n,o,t={}){if(!n)return;const e=n.granularity;if(n.skipped)return{head:`Too many points by ${e}`,detail:n.grainSource==="trend_by"?"Pick a coarser grain on the Trend By.":"Pick a coarser grain, or Automatic."};const i=f[n.grainSource],r=n.span==="recent"?`The last 12 ${e}s: no date range`:n.span==="history"?`The 12 ${e}s ending with this one`:n.window?d({...n.window,timezone:n.calendar.tz},t.now):void 0;return{head:`By ${e} · ${o} ${o===1?"point":"points"}`,detail:r?`${r} · ${i}`:i};}export{m as K,F as a,g as b,_ as c,P as d,I as f,T as m};
|
package/dist/chunks/{report-preferences-dialog-Bseb2Rlg.js → report-preferences-dialog-B2ZGPS9t.js}
RENAMED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{jsx as r,Fragment as M,jsxs as d}from"react/jsx-runtime";import He,{useMemo as B,useState as I,useEffect as j,lazy as te,Suspense as Q,useRef as L,useLayoutEffect as ee,useCallback as P,useId as $}from"react";import{at as be,u as k,B as z,b3 as Ke,b4 as qe,b5 as Ge,b6 as Xe,b7 as Je,b8 as Ze,b9 as Ye,ba as Qe,r as X,q as ea,t as ge,v as aa,E as ta,S as ra,bb as na,bc as sa,aS as la,bd as ve,be as ne,aQ as G,P as ia,b as oa,e as da,g as ye,bf as pe,ag as ze,bg as O,a4 as de,a5 as ce,a6 as ue,a7 as me,a8 as F,bh as ca,bi as ua,bj as ma,bk as ha,bl as fa,bm as ba,bn as pa,bo as Se,bp as we}from"./appearance-provider-CfoAVQuG.js";import{a as ga,aX as va,aY as ya,aZ as Le,H as Sa,E as wa,a_ as xa,a$ as Ca,b0 as J,b1 as Re,b2 as xe,b3 as Ta,b4 as Na,b5 as Ea,b6 as Ia,F as Aa,B as ka,S as Da,U as _a,D as Pa,A as za,C as La,b7 as Ra,f as Ua,g as Oa,h as Fa,i as Ba,j as Ce,k as Te,b8 as ja}from"./semaphor-ready-indicator-BQarSo6S.js";import{E as Ma,bs as Va,k as U}from"./resolve-dashboard-input-context-BDY7KwRe.js";import{L as Wa}from"./bookmark-state-DScd31KT.js";import{r as $a,a as Ue}from"./availability-3AIOf6Z-.js";import"./validators-Dg2kyF4_.js";import"./matrix-operation-contract-CWvcEsQ0.js";import"./analytics-base-schemas-DMFrDqn_.js";import{parseValueFormatPreferencesResponse as Ha,canonicalizeSupportedLocale as Oe,getSupportedCurrencyCodes as Ka,canonicalizeSupportedCurrencyCode as qa}from"../value-format-preferences/index.js";import{k as Ga}from"./filter-reach-preview-C5M5_hf_.js";import{a as Xa}from"./report-runtime-context-Cd1b5pku.js";import{at as Z,aA as H}from"./pivot-result-contract-expectations-BNWhS8mv.js";function Ja(){return/* @__PURE__ */r("div",{role:"dashboard-plus-main",className:"flex min-h-0 grow basis-0 overflow-hidden",children:/* @__PURE__ */r("section",{className:"flex min-h-0 grow basis-0 flex-col overflow-hidden",children:/* @__PURE__ */r(ga,{})})});}const Za=/* @__PURE__ */new Set(["iat","exp","nbf","jti"]);function Ya(e){return Ma(Object.fromEntries(Object.entries(e??{}).filter(([t])=>!Za.has(t))));}function Qa(e){var a;const t=e==null?void 0:e.config;return $a({features:((a=t==null?void 0:t.projectFeatures)==null?void 0:a.features)??{},config:{enabled:Ue(t).enabled},identity:{orgUserId:e==null?void 0:e.orgUserId,tenantId:e==null?void 0:e.tenantId,endUserId:e==null?void 0:e.endUserId},modelConfigured:!0});}let Ne=0;function Ee(e,t){Ne+=1;const{name:a,layout:n}=Ue(t==null?void 0:t.config);return{...ya(n),id:Ne,callerKey:e,assistantName:a};}function et({children:e,authToken:t}){const a=be(),n=B(()=>t===void 0?a.tokenProps:tt(t),[t,a.tokenProps]),s=B(()=>Ya(n),[n]),i=B(()=>Qa(n).available,[n]),[l,o]=I(()=>Ee(s,n));l.callerKey!==s&&o(Ee(s,n)),rt(l);const h=B(()=>({instance:l,available:i}),[l,i]);return/* @__PURE__ */r(va.Provider,{value:h,children:e});}function at({children:e}){return Le()?/* @__PURE__ */r(M,{children:e}):/* @__PURE__ */r(et,{children:e});}function tt(e){if(!(e!=null&&e.accessToken))return{};try{return Va(e.accessToken);}catch{return{};}}function rt(e){j(()=>{const t=(n,s)=>{const i=e.store.getState().focus;i&&!nt(i,n,s)&&e.clearFocus();},a=k.getState();return t(a.selectedSheetId,a.dashboard),k.subscribe((n,s)=>{(n.selectedSheetId!==s.selectedSheetId||n.dashboard!==s.dashboard)&&t(n.selectedSheetId,n.dashboard),n.isVisualEditing&&!s.isVisualEditing&&e.leaveBeside();});},[e]);}function nt(e,t,a){if((t??null)!==e.sheetId)return!1;const n=a?Wa(a,e.cardId):void 0;return!!n&&n.sheet.id===e.sheetId;}const st=te(()=>import("./assistant-chat-DgUaCE9k.js"));function Yt(){const e=Sa(),t=wa();if(!e.available)return null;const a=t!=="lg";return/* @__PURE__ */d(z,{variant:e.isOpen?"secondary":"outline",size:"xs","aria-pressed":e.isOpen,"aria-label":e.assistantName,title:a?e.assistantName:void 0,onClick:e.toggle,className:a?"w-7 px-0":void 0,children:[/* @__PURE__ */r(xa,{className:"h-3.5 w-3.5"}),!a&&e.assistantName]});}const lt={"docked-right":"relative shrink-0 border-l border-border","docked-left":"relative order-first shrink-0 border-r border-border",centered:"absolute left-1/2 top-1/2 z-30 h-[min(80%,760px)] w-[min(640px,calc(100%-2rem))] -translate-x-1/2 -translate-y-1/2 rounded-card border border-border shadow-lg","full-page":"absolute inset-0 z-30"},it="absolute left-0 top-0 z-30 max-h-[var(--assistant-beside-max-h)] max-w-[var(--assistant-beside-max-w)] rounded-card border border-border shadow-lg",ot=640,q=8;function dt({surface:e="dashboard"}={}){const t=Le(),{isOpen:a,mounted:n,storedLayout:s,width:i,beside:l,besideSize:o,focusCardId:h,askCount:w}=Ke((t==null?void 0:t.instance.store)??Ca,qe(f=>{var v;return{isOpen:f.isOpen,mounted:f.mounted,storedLayout:f.layout,width:f.width,beside:f.beside,besideSize:f.besideSize,focusCardId:(v=f.focus)==null?void 0:v.cardId,askCount:f.askCount};})),x=e==="none",u=k(f=>l&&a&&h&&!x?ct(f.dashboard,f.selectedSheetId,h):void 0),b=ut(u,w);if(!(t!=null&&t.available)||!n&&!x)return null;const c=x?"full-page":b.shown?"beside-card":s,S=x||a,m=c==="docked-right"||c==="docked-left";return/* @__PURE__ */d("aside",{ref:b.setFloating,"aria-label":t.instance.assistantName,"data-testid":"assistant-panel","data-layout":c,"data-beside-frame":c==="beside-card"?u:void 0,"data-beside-side":c==="beside-card"?b.side:void 0,className:U("flex-col bg-background",c==="beside-card"?it:lt[c],S?"flex":"hidden"),style:c==="beside-card"?{...b.style,width:o.width,height:o.height}:m?{width:i,maxWidth:`${Fe*100}%`}:void 0,onKeyDown:c==="beside-card"?f=>{if(f.key!=="Escape"||f.defaultPrevented||!(f.target instanceof Node)||!f.currentTarget.contains(f.target))return;f.preventDefault();const v=b.cardActions();t.instance.close(),v==null||v.focus();}:void 0,children:[m?/* @__PURE__ */r(ft,{instance:t.instance,side:c==="docked-left"?"right":"left",width:i}):null,c==="beside-card"?/* @__PURE__ */r(ht,{instance:t.instance,size:o,side:b.handleSide}):null,/* @__PURE__ */r(Q,{fallback:null,children:/* @__PURE__ */r(st,{instance:t.instance,surface:e,placement:c},t.instance.id)})]});}function ct(e,t,a){var s,i,l;const n=(s=e.sheets)==null?void 0:s.find(o=>o.id===t);return(l=(i=n==null?void 0:n.frames)==null?void 0:i.find(o=>{var h;return(h=o.cards)==null?void 0:h.some(w=>w.id===a);}))==null?void 0:l.id;}function ut(e,t){var S;const[a,n]=I(void 0),[s,i]=I(void 0),l=L(t);ee(()=>{l.current=t;});const o=s===t?null:a,{refs:h,elements:w,floatingStyles:x,middlewareData:u,isPositioned:b}=Ge({strategy:"absolute",placement:o??"right-start",middleware:[Xe(q),Je({padding:q}),Ze({padding:q,apply:({availableWidth:m,availableHeight:f,elements:v})=>{v.floating.style.setProperty("--assistant-beside-max-w",`${Math.max(0,m)}px`),v.floating.style.setProperty("--assistant-beside-max-h",`${Math.max(0,f)}px`);}}),Ye()],whileElementsMounted:(m,f,v)=>Qe(m,f,()=>{const E=mt(m,f);n(E),E===null&&i(l.current),v();})}),c=w.floating;return ee(()=>{h.setReference(e?Ie(c==null?void 0:c.parentElement,e):null);},[e,c,h]),{shown:e!==void 0&&o!==null&&w.reference!==null,setFloating:h.setFloating,style:{...x,...(!b||(S=u.hide)!=null&&S.referenceHidden?{visibility:"hidden"}:{})},side:o??void 0,handleSide:o==="left-start"?"left":"right",cardActions:()=>{var m;return e?(m=Ie(c==null?void 0:c.parentElement,e))==null?void 0:m.querySelector("[data-card-actions]"):null;}};}function Ie(e,t){return e?Array.from(e.querySelectorAll("[data-frame-id]")).find(a=>a.dataset.frameId===t)??null:null;}function mt(e,t){const a=t.parentElement;if(!a||!e.isConnected)return null;const n=a.getBoundingClientRect();if(n.width<ot)return null;const s=e.getBoundingClientRect(),{min:i}=Re,l=(o,h)=>o>=i.width+2*q&&h>=i.height+2*q;return l(n.right-s.right,n.height)?"right-start":l(s.left-n.left,n.height)?"left-start":l(n.width,n.bottom-s.bottom)?"bottom-start":null;}function ht({instance:e,size:t,side:a}){const n=L(void 0),s=a==="left"?-1:1,i=l=>{const o=n.current;return{width:o.start.width+s*(l.clientX-o.x),height:o.start.height+(l.clientY-o.y)};};return/* @__PURE__ */r("div",{role:"separator","aria-label":"Resize assistant",tabIndex:0,title:"Drag to resize. Double-click to reset.",onPointerDown:l=>{var o,h;l.preventDefault(),(h=(o=l.currentTarget).setPointerCapture)==null||h.call(o,l.pointerId),n.current={x:l.clientX,y:l.clientY,start:t};},onPointerMove:l=>{n.current&&e.setBesideSize(i(l));},onPointerUp:l=>{n.current&&(e.setBesideSize(i(l),{save:!0}),n.current=void 0);},onPointerCancel:()=>{n.current=void 0;},onKeyDown:l=>{const o={ArrowLeft:{width:-s*W,height:0},ArrowRight:{width:s*W,height:0},ArrowUp:{width:0,height:-W},ArrowDown:{width:0,height:W}}[l.key];o&&(l.preventDefault(),e.setBesideSize({width:t.width+o.width,height:t.height+o.height},{save:!0}));},onDoubleClick:()=>e.setBesideSize(Re.default,{save:!0}),className:U("absolute bottom-0 z-10 h-3 w-3 touch-none outline-none hover:bg-primary/30 focus-visible:bg-primary/40",a==="left"?"left-0 cursor-nesw-resize rounded-bl-card":"right-0 cursor-nwse-resize rounded-br-card")});}const W=16,Fe=0.6;function ft({instance:e,side:t,width:a}){const n=L(void 0),s=u=>{var c,S;const b=(S=(c=u.closest("aside"))==null?void 0:c.parentElement)==null?void 0:S.clientWidth;return b?b*Fe:J.max;},i=u=>{var b;return((b=u.closest("aside"))==null?void 0:b.getBoundingClientRect().width)||a;},l=u=>{const b=n.current;if(!b)return a;const c=u-b.startX;return xe(b.startWidth+(t==="left"?-c:c),b.maxForArea);},o=u=>{var b,c;u.preventDefault(),(c=(b=u.currentTarget).setPointerCapture)==null||c.call(b,u.pointerId),n.current={startX:u.clientX,startWidth:i(u.currentTarget),maxForArea:s(u.currentTarget)};},h=u=>{n.current&&e.setWidth(l(u.clientX));},w=u=>{n.current&&(e.setWidth(l(u.clientX),{save:!0}),n.current=void 0);},x=u=>{if(u.key!=="ArrowLeft"&&u.key!=="ArrowRight")return;u.preventDefault();const b=u.key==="ArrowLeft"==(t==="left");e.setWidth(xe(i(u.currentTarget)+(b?W:-W),s(u.currentTarget)),{save:!0});};return/* @__PURE__ */r("div",{role:"separator","aria-orientation":"vertical","aria-label":"Resize assistant","aria-valuenow":a,"aria-valuemin":J.min,"aria-valuemax":J.max,tabIndex:0,title:"Drag to resize. Double-click to reset.",onPointerDown:o,onPointerMove:h,onPointerUp:w,onPointerCancel:w,onKeyDown:x,onDoubleClick:()=>e.setWidth(J.default,{save:!0}),className:U("absolute inset-y-0 z-10 w-1.5 cursor-col-resize touch-none outline-none hover:bg-primary/30 focus-visible:bg-primary/40",t==="left"?"-left-[3px]":"-right-[3px]")});}function bt(e){const t=Ta();return P(async(a,n)=>{const s=k.getState();if(s.isVisualEditing)return{ok:!1,reason:"not_editable",message:X.not_editable};if(!e())return{ok:!1,reason:"not_editable",message:X.no_save};if(s.dashboard!==a.basedOn)return{ok:!1,reason:"dashboard_changed",message:X.dashboard_changed};const i=Ga(a.basedOn,a.operations,a.context);if(!i.ok)return{ok:!1,reason:"refused",message:i.failedAt.message};const l={domainsById:{}};for(const o of i.queryFrames){const h=await t(o,{reuseLoaded:!0}).catch(w=>{console.warn("Applying the change without refreshed semantic metadata:",w);});ea(l,h);}return n!=null&&n.stillWanted&&!n.stillWanted()?{ok:!1,reason:"dropped"}:e()?k.getState().actions.applyProposal({...a,semanticExecutionPayload:l}):{ok:!1,reason:"not_editable",message:X.no_save};},[e,t]);}function pt(e){const{canEditDashboard:t,isInspectionMode:a}=Na(),n=Ea(),s=k(ge),i=e&&n&&t===!0&&!a,l=L(i);ee(()=>{l.current=i;});const o=P(()=>l.current&&ge(k.getState()),[]);return{canChange:i&&s,canChangeNow:o};}const Be={dashboard_changed:"Not applied: the dashboard on screen changed after this change was prepared.",not_editable:"Not applied: the dashboard can't be changed on screen right now (the editor is open, or Save isn't shown).",expired:"Not applied: it arrived after the time it had to land.",refused:"Not applied: the change no longer fits the dashboard."},K={changed:"Changed by your assistant",undo:"Undo",changedSince:"Changed since. Cancel discards every unsaved change.",closeEditorToUndo:"Close the editor to undo."};function gt({port:e,onLifecycleEvent:t}){const{canChange:a,canChangeNow:n}=pt(!0),s=k(c=>{var S;return(S=c.dashboard)==null?void 0:S.id;}),i=bt(n),[l,o]=I(null),h=L(/* @__PURE__ */new Map()),w=L(/* @__PURE__ */new Map()),x=L(Promise.resolve()),u=L({apply:i,onLifecycleEvent:t});ee(()=>{u.current={apply:i,onLifecycleEvent:t};}),j(()=>{e.setScreenState({eligible:a,...(s?{dashboardId:s}:{})});},[e,a,s]),j(()=>k.subscribe((c,S)=>{if(c.editSessionEpoch!==S.editSessionEpoch){h.current.clear(),o(null);return;}if(c.dashboard!==S.dashboard)for(const[m,f]of h.current)f!==c.dashboard&&h.current.delete(m);}),[]),j(()=>{const c=m=>{const f=k.getState().dashboard;if(!f||f.id!==m.dashboardId)return;const v=St();h.current.set(v,f),e.answerCopyRequest({kind:"uploaded",screenId:e.screenId,requestId:m.requestId,revisionId:v,dashboard:f});},S=async(m,f)=>{var p,y,T;const v=w.current.get(m.deliveryId);if(v){e.reportOutcome({screenId:e.screenId,deliveryId:m.deliveryId,outcome:v});return;}const E=h.current.get(m.revisionId),A=()=>!E||h.current.get(m.revisionId)!==E?"dashboard_changed":performance.now()<f+m.applyWithinMs?null:"expired",_=A();let D;if(_||!E)D=Y(_??"dashboard_changed");else{let g="expired";const V=await u.current.apply({proposalId:m.proposalId,operations:m.operations,context:m.context,basedOn:E},{stillWanted:()=>{const R=A();return R&&(g=R),R===null;}});D=yt(V,g);}if(w.current.set(m.deliveryId,D),e.reportOutcome({screenId:e.screenId,deliveryId:m.deliveryId,outcome:D}),D.status!=="applied")return;const N=((p=k.getState().dashboard)==null?void 0:p.id)??"";o({deliveryId:m.deliveryId,proposalId:m.proposalId,summary:m.summary,dashboardId:N,words:null}),(T=(y=u.current).onLifecycleEvent)==null||T.call(y,{type:"dashboard:change-applied",dashboardId:N,payload:{deliveryId:m.deliveryId,summary:m.summary}});};return e.subscribe(m=>{if(m.type==="copy_request"){c(m);return;}const f=performance.now();x.current=x.current.then(()=>S(m,f).catch(v=>console.error("[live-screen] a delivery failed",v)));});},[e]);const b=P(()=>{var S,m;if(!l)return;const c=k.getState().actions.undoProposal(l.proposalId);c.ok?((m=(S=u.current).onLifecycleEvent)==null||m.call(S,{type:"dashboard:change-undone",dashboardId:l.dashboardId,payload:{deliveryId:l.deliveryId,summary:l.summary}}),o(null)):c.reason==="changed_since"?o({...l,words:"changed_since"}):c.reason==="not_editable"?o({...l,words:"not_editable"}):o(null);},[l]);return l?/* @__PURE__ */r(vt,{note:l,onUndo:b}):null;}function vt({note:e,onUndo:t}){const a=k(l=>aa(l,e.proposalId)),n=k(l=>l.isVisualEditing);if(a==="none"&&e.words===null)return null;const s=e.words==="changed_since"||a==="changed_since",i=s?"changed_since":e.words==="not_editable"?"not_editable":a;return/* @__PURE__ */d("div",{className:"flex min-h-8 items-center gap-2 border-b border-border bg-muted/40 px-3 py-1 text-xs text-muted-foreground","data-testid":"live-change-note","data-note-state":i,role:"status",children:[/* @__PURE__ */d("span",{className:"truncate",title:e.summary.join(" "),children:[K.changed,s?`. ${K.changedSince}`:e.words==="not_editable"?`. ${K.closeEditorToUndo}`:""]}),!s&&a==="undoable"?/* @__PURE__ */d(M,{children:[/* @__PURE__ */r("span",{"aria-hidden":"true",children:"·"}),/* @__PURE__ */d(z,{variant:"outline",size:"xs",className:"h-6 gap-1 px-2 text-[11.5px]",disabled:n,title:n?K.closeEditorToUndo:void 0,onClick:t,children:[/* @__PURE__ */r(Ia,{className:"h-3 w-3"}),K.undo]})]}):null]});}function yt(e,t){if(e.ok)return{status:"applied"};switch(e.reason){case"dashboard_changed":case"not_editable":return Y(e.reason);case"refused":return{status:"not_applied",reason:"refused",message:(e.message||Be.refused).slice(0,500)};case"dropped":return Y(t);case"previous_not_applied":return Y("refused");}}function Y(e){return{status:"not_applied",reason:e,message:Be[e]};}function St(){return globalThis.crypto.randomUUID();}const wt=te(()=>import("./dashboard-controls-UCSAFCGA.js")),xt=te(()=>import("./edit-dashboard-visual-DvHp03h_.js")),Ct=te(()=>import("./dashboard-json-B120hYDa.js"));function Qt({showControls:e=!1,showFooter:t=!0,liveScreen:a,...n}){const s=k(o=>o.showDashboardJSON),{appearance:i,preferences:l}=n;return/* @__PURE__ */r(ta,{FallbackComponent:Aa,children:/* @__PURE__ */r(ra,{dashboardProps:n,children:/* @__PURE__ */d(ka,{children:[/* @__PURE__ */r(Da,{componentType:"surfboard",componentId:n.id}),/* @__PURE__ */d(_a,{appearance:i,children:[/* @__PURE__ */r(na,{toastOptions:{classNames:{toast:"max-w-[calc(100vw-2rem)] overflow-x-hidden !items-start [--toast-close-button-end:0.5rem] [--toast-close-button-start:auto] [--toast-close-button-transform:translate(0,0)] sm:max-w-[44rem]",content:"min-w-0 flex-1",icon:"mt-0.5 shrink-0",title:"max-w-full break-words pr-8",description:"max-w-full break-words",closeButton:"!top-2 h-6 w-6 rounded-md border-border bg-background text-muted-foreground hover:bg-muted hover:text-foreground"}}}),/* @__PURE__ */d(Pa,{preferences:l,children:[s&&/* @__PURE__ */r(Q,{fallback:null,children:/* @__PURE__ */r(Ct,{})}),/* @__PURE__ */r(za,{children:/* @__PURE__ */r(at,{children:/* @__PURE__ */d("main",{className:"relative flex h-full w-full flex-col overflow-hidden",children:[e&&/* @__PURE__ */r(Q,{fallback:null,children:/* @__PURE__ */r(wt,{})}),a&&/* @__PURE__ */r(gt,{port:a,onLifecycleEvent:n.onDashboardLifecycleEvent}),/* @__PURE__ */d("div",{className:"relative flex grow overflow-hidden",children:[/* @__PURE__ */r("div",{className:"flex min-w-0 flex-1",children:/* @__PURE__ */r(La,{...n,type:"dashboard",children:/* @__PURE__ */r(Tt,{})})}),/* @__PURE__ */r(dt,{})]})]})})})]})]})]})})});}function Tt(){const e=k(a=>a.isVisualEditing),t=B(()=>/* @__PURE__ */r(sa.Provider,{value:!0,children:/* @__PURE__ */r(Ja,{})}),[]);return/* @__PURE__ */d("div",{className:"relative flex min-h-0 min-w-0 grow basis-0 flex-col",children:[/* @__PURE__ */r("div",{className:"flex min-h-0 grow basis-0 flex-col",style:e?{visibility:"hidden"}:void 0,inert:e||void 0,"aria-hidden":e||void 0,"data-dashboard-hidden":e||void 0,children:t}),e&&/* @__PURE__ */r("div",{className:"absolute inset-0 z-10 flex flex-col",children:/* @__PURE__ */r(Q,{fallback:null,children:/* @__PURE__ */r(xt,{})})})]});}function Nt(e={}){const{authToken:t,tokenProps:a}=be(),n=k(N=>N.actions.applyResolvedCalendarPreferences),s=e.enabled??!0,i=(t==null?void 0:t.accessToken)??null,l=(a==null?void 0:a.apiServiceUrl)??null,[o,h]=I(!1),[w,x]=I(!1),[u,b]=I(!1),[c,S]=I(null),[m,f]=I(null),v=L(i);v.current=i,j(()=>{f(null),S(null),h(!1),x(!1),b(!1);},[i]);const E=P(async N=>{const p=Xa(await N.json());if(!p.ok)throw new Error("Calendar preferences response is invalid");return p.value;},[]),A=P(async()=>{if(!s||!i||!l)return;const N=i;h(!0),S(null);try{const p=await fetch(`${l}/v1/user-preferences/calendar`,{method:"GET",headers:{Authorization:`Bearer ${i}`}});if(!p.ok){const T=await p.json().catch(()=>({}));throw new Error(T.error||"Failed to fetch preferences");}const y=await E(p);v.current===N&&f(y);}catch(p){v.current===N&&S(p instanceof Error?p.message:"Unknown error");}finally{v.current===N&&h(!1);}},[i,l,s,E]);j(()=>{s&&A();},[s,A]);const _=P(async N=>{if(!i||!l)return S("Not authenticated"),!1;const p=i;x(!0),S(null);try{const y=await fetch(`${l}/v1/user-preferences/calendar`,{method:"PATCH",headers:{"Content-Type":"application/json",Authorization:`Bearer ${i}`},body:JSON.stringify(N)});if(!y.ok){const g=await y.json().catch(()=>({}));throw new Error(g.error||"Failed to update preferences");}const T=await E(y);return v.current!==p?!1:(f(T),n(T.resolved,T.sources),!0);}catch(y){return v.current===p&&S(y instanceof Error?y.message:"Unknown error"),!1;}finally{v.current===p&&x(!1);}},[i,l,n,E]),D=P(async()=>{if(!i||!l)return S("Not authenticated"),!1;const N=i;b(!0),S(null);try{const p=await fetch(`${l}/v1/user-preferences/calendar`,{method:"DELETE",headers:{Authorization:`Bearer ${i}`}});if(!p.ok){const T=await p.json().catch(()=>({}));throw new Error(T.error||"Failed to clear preferences");}const y=await E(p);return v.current!==N?!1:(f(y),n(y.resolved,y.sources),!0);}catch(p){return v.current===N&&S(p instanceof Error?p.message:"Unknown error"),!1;}finally{v.current===N&&b(!1);}},[i,l,n,E]);return{preferences:m,isLoading:o,isSaving:w,isClearing:u,error:c,updatePreferences:_,clearPreferences:D,refetch:A};}const ae=[{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"}],je=[{value:0,label:"Sunday"},{value:1,label:"Monday"},{value:6,label:"Saturday"}],Ae="text-[10px] font-medium uppercase tracking-[0.08em] text-muted-foreground";function Et(){try{const e=Intl;if(e.supportedValuesOf)return e.supportedValuesOf("timeZone");}catch{}return ae.map(e=>e.value);}function It(e){if(!e)return"default";if(e.tz!==e.weekStart)return"inherited";switch(e.tz){case"viewer_tenant":return"tenant";case"viewer_organization":return"organization";case"system_default":return"system";case"session_initial":return"embedded";default:return"default";}}function ke(e){const t=ae.find(a=>a.value===e);return t?t.label:e;}function At(e){const t=je.find(a=>a.value===e);return t?t.label:String(e);}function kt({active:e,onClose:t}){const{preferences:a,isLoading:n,isSaving:s,isClearing:i,updatePreferences:l,clearPreferences:o}=Nt({enabled:e}),h=la(),w=(a==null?void 0:a.resolved.tz)||(h==null?void 0:h.tz)||"UTC",x=(a==null?void 0:a.resolved.weekStart)??(h==null?void 0:h.weekStart)??1,[u,b]=I((a==null?void 0:a.stored)===null),[c,S]=I(!1),[m,f]=I(w),[v,E]=I(x),[A,_]=I(!1),D=B(()=>Et(),[]),N=B(()=>D.filter(C=>!ae.some($e=>$e.value===C)),[D]),p=B(()=>ke(m),[m]),y=a!=null&&a.inherited?ke(a.inherited.tz):"UTC",T=a!=null&&a.inherited?At(a.inherited.weekStart):"Monday",g=It(a==null?void 0:a.inheritedSources);He.useEffect(()=>{if(!e){S(!1);return;}c||(a&&b(a.stored===null),f(w),E(x));},[e,c,a,w,x]);const V=async()=>{if(n){O.error("Preferences are still loading. Please try again.");return;}u?(await o())?(O.success("Now using default settings."),t()):O.error("Failed to save preferences. Please try again."):(await l({tz:m,weekStart:v}))?(O.success("Preferences saved."),t()):O.error("Failed to save preferences. Please try again.");},R=()=>{t();},re=s||i,We=re||n;return/* @__PURE__ */d(M,{children:[/* @__PURE__ */d("div",{className:"space-y-4 py-1",children:[/* @__PURE__ */d(ve,{value:u?"defaults":"custom",onValueChange:C=>{S(!0),b(C==="defaults");},className:"space-y-0.5",children:[/* @__PURE__ */d("label",{htmlFor:"mode-defaults",className:U("flex cursor-pointer items-start gap-2 rounded-control px-2 py-1.5 hover:bg-muted/50",u&&"bg-muted/50"),onClick:()=>{S(!0),b(!0);},children:[/* @__PURE__ */r(ne,{value:"defaults",id:"mode-defaults",className:"mt-0.5"}),/* @__PURE__ */d("div",{className:"flex-1 min-w-0",children:[/* @__PURE__ */d("p",{className:"text-[13px] font-medium text-foreground",children:["Use ",g," defaults"]}),/* @__PURE__ */d("p",{className:"text-[12px] text-muted-foreground",children:[y,", week starts ",T]})]})]}),/* @__PURE__ */d("label",{htmlFor:"mode-custom",className:U("flex cursor-pointer items-start gap-2 rounded-control px-2 py-1.5 hover:bg-muted/50",!u&&"bg-muted/50"),onClick:()=>{S(!0),b(!1);},children:[/* @__PURE__ */r(ne,{value:"custom",id:"mode-custom",className:"mt-0.5"}),/* @__PURE__ */r("p",{className:"flex-1 text-[13px] font-medium text-foreground",children:"Use custom settings"})]})]}),/* @__PURE__ */d("div",{className:U("space-y-4 border-t border-border/60 pt-4 transition-opacity",u&&"pointer-events-none opacity-50"),children:[/* @__PURE__ */d("div",{className:"space-y-1.5",children:[/* @__PURE__ */r(G,{className:Ae,children:"Timezone"}),/* @__PURE__ */d(ia,{open:A,onOpenChange:_,modal:!0,children:[/* @__PURE__ */r(oa,{asChild:!0,children:/* @__PURE__ */d(z,{variant:"outline",size:"xs",role:"combobox","aria-expanded":A,className:"w-full justify-between text-[12px] font-normal",disabled:u,children:[/* @__PURE__ */r("span",{className:"truncate",children:p}),/* @__PURE__ */r(Ra,{className:"ml-2 h-3.5 w-3.5 shrink-0 opacity-50"})]})}),/* @__PURE__ */r(da,{className:"z-50 w-[--radix-popover-trigger-width] p-0",align:"start",children:/* @__PURE__ */d(Ua,{className:"overflow-visible",children:[/* @__PURE__ */r(Oa,{placeholder:"Search timezones…"}),/* @__PURE__ */d(Fa,{children:[/* @__PURE__ */r(Ba,{children:"No timezone found."}),/* @__PURE__ */r(Ce,{heading:"Common",children:ae.map(C=>/* @__PURE__ */d(Te,{value:`${C.value} ${C.label}`,onSelect:()=>{S(!0),f(C.value),_(!1);},children:[/* @__PURE__ */r(ye,{className:U("h-3.5 w-3.5",m===C.value?"opacity-100":"opacity-0")}),/* @__PURE__ */r("span",{className:"flex-1",children:C.label}),/* @__PURE__ */r("span",{className:"text-[11px] text-muted-foreground",children:C.value})]},C.value))}),/* @__PURE__ */r(ja,{}),/* @__PURE__ */r(Ce,{heading:"All timezones",children:N.map(C=>/* @__PURE__ */d(Te,{value:C,onSelect:()=>{S(!0),f(C),_(!1);},children:[/* @__PURE__ */r(ye,{className:U("h-3.5 w-3.5",m===C?"opacity-100":"opacity-0")}),C]},C))})]})]})})]})]}),/* @__PURE__ */d("div",{className:"space-y-1.5",children:[/* @__PURE__ */r(G,{className:Ae,children:"Week starts on"}),/* @__PURE__ */r(ve,{value:String(v),onValueChange:C=>{S(!0),E(Number(C));},className:"flex gap-4",disabled:u,children:je.map(C=>/* @__PURE__ */d("label",{htmlFor:`week-start-${C.value}`,className:U("flex cursor-pointer items-center gap-2 text-[13px]",u&&"cursor-not-allowed"),children:[/* @__PURE__ */r(ne,{value:String(C.value),id:`week-start-${C.value}`,disabled:u}),C.label]},C.value))})]})]})]}),/* @__PURE__ */d(pe,{children:[/* @__PURE__ */r(z,{variant:"outline",size:"xs",onClick:R,disabled:re,children:"Cancel"}),/* @__PURE__ */r(z,{size:"xs",onClick:V,disabled:We,children:re?/* @__PURE__ */d(M,{children:[/* @__PURE__ */r(ze,{className:"h-3.5 w-3.5 animate-spin"}),"Saving…"]}):"Save"})]})]});}function Dt(e={}){const{authToken:t,tokenProps:a}=be(),n=k(p=>p.actions.applyResolvedValueFormatPreferences),s=e.enabled??!0,i=(t==null?void 0:t.accessToken)??null,l=(a==null?void 0:a.apiServiceUrl)??null,o=L(i);o.current=i;const[h,w]=I(null),[x,u]=I(!1),[b,c]=I(!1),[S,m]=I(!1),[f,v]=I(null);j(()=>{w(null),v(null),u(!1),c(!1),m(!1);},[i]);const E=P(async p=>{const y=Ha(await p.json());if(!y.ok)throw new Error("Value format preferences response is invalid");return y.value;},[]),A=P(async(p,y)=>{if(!i||!l)throw new Error("Not authenticated");const T=await fetch(`${l}/v1/user-preferences/value-format`,{method:p,headers:{Authorization:`Bearer ${i}`,...(y?{"Content-Type":"application/json"}:{})},body:y?JSON.stringify(y):void 0});if(!T.ok){const g=await T.json().catch(()=>({}));throw new Error(g.error||"Failed to update preferences");}return E(T);},[i,l,E]),_=P(async()=>{if(!s||!i||!l)return;const p=i;u(!0),v(null);try{const y=await A("GET");o.current===p&&w(y);}catch(y){o.current===p&&v(y instanceof Error?y.message:"Unknown error");}finally{o.current===p&&u(!1);}},[i,l,s,A]);j(()=>{s&&_();},[s,_]);const D=P(async p=>{const y=i;c(!0),v(null);try{const T=await A("PATCH",p);return o.current!==y?!1:(w(T),n(T.resolved,T.sources),!0);}catch(T){return o.current===y&&v(T instanceof Error?T.message:"Unknown error"),!1;}finally{o.current===y&&c(!1);}},[i,n,A]),N=P(async()=>{const p=i;m(!0),v(null);try{const y=await A("DELETE");return o.current!==p?!1:(w(y),n(y.resolved,y.sources),!0);}catch(y){return o.current===p&&v(y instanceof Error?y.message:"Unknown error"),!1;}finally{o.current===p&&m(!1);}},[i,n,A]);return{preferences:h,isLoading:x,isSaving:b,isClearing:S,error:f,updatePreferences:D,clearPreferences:N,refetch:_};}const he=[{value:"en-US",label:"English (United States)"},{value:"en-GB",label:"English (United Kingdom)"},{value:"de-DE",label:"German (Germany)"},{value:"fr-FR",label:"French (France)"},{value:"es-ES",label:"Spanish (Spain)"},{value:"it-IT",label:"Italian (Italy)"},{value:"nl-NL",label:"Dutch (Netherlands)"},{value:"pt-BR",label:"Portuguese (Brazil)"},{value:"ja-JP",label:"Japanese (Japan)"},{value:"en-IN",label:"English (India)"},{value:"en-AU",label:"English (Australia)"},{value:"en-NZ",label:"English (New Zealand)"},{value:"mi-NZ",label:"Māori (New Zealand)"}],Me=/* @__PURE__ */new Set(["USD","EUR","GBP","CAD","AUD","JPY","CHF","INR","BRL","KWD"]),_t=Ka(),Pt=_t.filter(e=>!Me.has(e)),Ve=[{value:"short",label:"Short"},{value:"medium",label:"Medium"},{value:"long",label:"Long"}],De="2026-07-31",se="2026-07-31T14:30:45";function fe(e){switch(e){case"viewer_user":return"user";case"viewer_tenant_user":return"tenant user";case"viewer_tenant":return"tenant";case"viewer_organization":return"organization";case"session_initial":return"embedded session";case"system_default":return"system";default:return"another preference level";}}function le(e){var t;return((t=Ve.find(a=>a.value===e))==null?void 0:t.label)??e;}function zt(e){const t=he.find(a=>a.value===e);return t?`${t.label} — ${t.value}`:e;}function ie(e){return{short:e("short"),medium:e("medium"),long:e("long")};}function oe({id:e,label:t,value:a,inherited:n,inheritedSource:s,examples:i,disabled:l,onValueChange:o}){const h=a===void 0?`Inherited · ${le(n)}`:le(a);return/* @__PURE__ */d("div",{className:"space-y-1.5",children:[/* @__PURE__ */r(G,{htmlFor:e,className:"text-[11px] text-muted-foreground",children:t}),/* @__PURE__ */d(de,{value:a??"inherit",disabled:l,onValueChange:o,children:[/* @__PURE__ */r(ce,{id:e,size:"xs",children:/* @__PURE__ */r(ue,{children:h})}),/* @__PURE__ */d(me,{children:[/* @__PURE__ */r(F,{value:"inherit",className:"[&>span:last-child]:w-full",children:/* @__PURE__ */d("span",{className:"flex w-full min-w-0 items-center justify-between gap-4",children:[/* @__PURE__ */d("span",{children:["Inherited from ",fe(s)," ·"," ",le(n)]}),/* @__PURE__ */r("span",{className:"shrink-0 tabular-nums text-muted-foreground",children:i[n]})]})}),Ve.map(w=>/* @__PURE__ */r(F,{value:w.value,className:"[&>span:last-child]:w-full",children:/* @__PURE__ */d("span",{className:"flex w-full min-w-0 items-center justify-between gap-4",children:[/* @__PURE__ */r("span",{children:w.label}),/* @__PURE__ */r("span",{className:"shrink-0 tabular-nums text-muted-foreground",children:i[w.value]})]})},w.value))]})]})]});}function Lt({value:e,inherited:t,inheritedSources:a,onChange:n,disabled:s}){var N,p,y,T;const i=$(),l=$(),o=$(),h=$(),w=$(),u=(e.locale===void 0?void 0:Oe(e.locale))??t.locale,b=e.defaultCurrency??t.defaultCurrency,c={locale:u,dateStyle:e.dateStyle??t.dateStyle,dateTime:{dateStyle:((N=e.dateTime)==null?void 0:N.dateStyle)??t.dateTime.dateStyle,timeStyle:((p=e.dateTime)==null?void 0:p.timeStyle)??t.dateTime.timeStyle},defaultCurrency:b},S=new Intl.NumberFormat(u,{style:"currency",currency:b}).format(1e3),m=Z({preferences:c,calendar:{tz:"UTC"}}),f=H({value:De,metadata:{kind:"raw_temporal",valueKind:"date"},format:m}).text,v=H({value:se,metadata:{kind:"raw_temporal",valueKind:"wall_datetime"},format:m}).text,E=ie(g=>H({value:De,metadata:{kind:"raw_temporal",valueKind:"date"},format:Z({preferences:{...c,dateStyle:g},calendar:{tz:"UTC"}})}).text),A=ie(g=>H({value:se,metadata:{kind:"raw_temporal",valueKind:"wall_datetime"},format:Z({preferences:{...c,dateTime:{...c.dateTime,dateStyle:g}},calendar:{tz:"UTC"}})}).text),_=ie(g=>H({value:se,metadata:{kind:"raw_temporal",valueKind:"wall_datetime"},format:Z({preferences:{...c,dateTime:{...c.dateTime,timeStyle:g}},calendar:{tz:"UTC"}})}).text),D=(g,V)=>{const R={...e.dateTime,[g]:V==="inherit"?void 0:V};n({...e,dateTime:R.dateStyle===void 0&&R.timeStyle===void 0?void 0:R});};return/* @__PURE__ */d("div",{className:"space-y-4",children:[/* @__PURE__ */d("div",{className:"space-y-1.5",children:[/* @__PURE__ */r(G,{htmlFor:i,className:"text-[10px] font-medium uppercase tracking-[0.08em] text-muted-foreground",children:"Locale"}),/* @__PURE__ */d(de,{value:e.locale??"inherit",disabled:s,onValueChange:g=>n({...e,locale:g==="inherit"?void 0:g}),children:[/* @__PURE__ */r(ce,{id:i,size:"xs",children:/* @__PURE__ */r(ue,{children:e.locale===void 0?`Inherited · ${t.locale}`:zt(e.locale)})}),/* @__PURE__ */d(me,{children:[/* @__PURE__ */d(F,{value:"inherit",children:["Inherited from ",fe(a.locale)," ·"," ",t.locale]}),e.locale&&!he.some(g=>g.value===e.locale)&&/* @__PURE__ */r(F,{value:e.locale,children:e.locale}),he.map(g=>/* @__PURE__ */d(F,{value:g.value,children:[g.label," — ",g.value]},g.value))]})]})]}),/* @__PURE__ */d("fieldset",{className:"space-y-2",children:[/* @__PURE__ */r("legend",{className:"text-[10px] font-medium uppercase tracking-[0.08em] text-muted-foreground",children:"Date values"}),/* @__PURE__ */r(oe,{id:o,label:"Format",value:e.dateStyle,inherited:t.dateStyle,inheritedSource:a.dateStyle,examples:E,disabled:s,onValueChange:g=>n({...e,dateStyle:g==="inherit"?void 0:g})})]}),/* @__PURE__ */d("fieldset",{className:"space-y-2",children:[/* @__PURE__ */r("legend",{className:"text-[10px] font-medium uppercase tracking-[0.08em] text-muted-foreground",children:"Date & time values"}),/* @__PURE__ */r(oe,{id:h,label:"Date",value:(y=e.dateTime)==null?void 0:y.dateStyle,inherited:t.dateTime.dateStyle,inheritedSource:a.dateTime.dateStyle,examples:A,disabled:s,onValueChange:g=>D("dateStyle",g)}),/* @__PURE__ */r(oe,{id:w,label:"Time",value:(T=e.dateTime)==null?void 0:T.timeStyle,inherited:t.dateTime.timeStyle,inheritedSource:a.dateTime.timeStyle,examples:_,disabled:s,onValueChange:g=>D("timeStyle",g)})]}),/* @__PURE__ */d("div",{className:"space-y-1.5",children:[/* @__PURE__ */r(G,{htmlFor:l,className:"text-[10px] font-medium uppercase tracking-[0.08em] text-muted-foreground",children:"Default currency"}),/* @__PURE__ */d(de,{value:e.defaultCurrency??"inherit",disabled:s,onValueChange:g=>n({...e,defaultCurrency:g==="inherit"?void 0:g}),children:[/* @__PURE__ */r(ce,{id:l,size:"xs",children:/* @__PURE__ */r(ue,{children:e.defaultCurrency===void 0?`Inherited · ${t.defaultCurrency}`:e.defaultCurrency})}),/* @__PURE__ */d(me,{children:[/* @__PURE__ */d(F,{value:"inherit",children:["Inherited from ",fe(a.defaultCurrency)," ·"," ",t.defaultCurrency]}),[...Me].map(g=>/* @__PURE__ */r(F,{value:g,children:g},g)),Pt.map(g=>/* @__PURE__ */r(F,{value:g,children:g},g))]})]})]}),/* @__PURE__ */d("div",{className:"rounded-control border border-border/60 bg-muted/30 px-3 py-2",children:[/* @__PURE__ */r("p",{className:"text-[10px] font-medium uppercase tracking-[0.08em] text-muted-foreground",children:"Preview"}),/* @__PURE__ */d("dl",{className:"mt-1.5 space-y-1 text-[12px]",children:[/* @__PURE__ */d("div",{className:"flex items-baseline justify-between gap-4",children:[/* @__PURE__ */r("dt",{className:"text-muted-foreground",children:"Date"}),/* @__PURE__ */r("dd",{className:"text-right font-medium text-foreground",children:f})]}),/* @__PURE__ */d("div",{className:"flex items-baseline justify-between gap-4",children:[/* @__PURE__ */r("dt",{className:"text-muted-foreground",children:"Date & time"}),/* @__PURE__ */r("dd",{className:"text-right font-medium text-foreground",children:v})]}),/* @__PURE__ */d("div",{className:"flex items-baseline justify-between gap-4",children:[/* @__PURE__ */r("dt",{className:"text-muted-foreground",children:"Currency"}),/* @__PURE__ */r("dd",{className:"text-right font-medium text-foreground",children:S})]})]})]}),/* @__PURE__ */r("p",{className:"text-[11px] text-muted-foreground",children:"Currency values are not converted. Date examples use a fixed reference value and the Gregorian calendar."})]});}const _e=["locale","dateStyle","dateTime.dateStyle","dateTime.timeStyle","defaultCurrency"];function Pe(e,t){var a,n;switch(t){case"locale":return e==null?void 0:e.locale;case"dateStyle":return e==null?void 0:e.dateStyle;case"dateTime.dateStyle":return(a=e==null?void 0:e.dateTime)==null?void 0:a.dateStyle;case"dateTime.timeStyle":return(n=e==null?void 0:e.dateTime)==null?void 0:n.timeStyle;case"defaultCurrency":return e==null?void 0:e.defaultCurrency;}}function Rt(e){var n,s;const t=(n=e==null?void 0:e.dateTime)==null?void 0:n.dateStyle,a=(s=e==null?void 0:e.dateTime)==null?void 0:s.timeStyle;return{locale:e==null?void 0:e.locale,dateStyle:e==null?void 0:e.dateStyle,dateTime:t===void 0&&a===void 0?void 0:{dateStyle:t,timeStyle:a},defaultCurrency:e==null?void 0:e.defaultCurrency};}function Ut({active:e,onClose:t}){var o,h,w,x,u,b,c;const{preferences:a,isLoading:n,isSaving:s,updatePreferences:i}=Dt({enabled:e});if(!e)return null;if(!a)return/* @__PURE__ */d(M,{children:[/* @__PURE__ */r("div",{className:"py-2",children:/* @__PURE__ */r("div",{className:"flex min-h-36 items-center justify-center text-[12px] text-muted-foreground",children:n?"Loading preferences…":"Preferences unavailable."})}),/* @__PURE__ */d(pe,{className:"justify-between sm:justify-between",children:[/* @__PURE__ */r(z,{variant:"ghost",size:"xs",disabled:!0,children:"Reset display formats"}),/* @__PURE__ */d("div",{className:"flex gap-2",children:[/* @__PURE__ */r(z,{variant:"outline",size:"xs",onClick:t,children:"Cancel"}),/* @__PURE__ */r(z,{size:"xs",disabled:!0,children:"Save"})]})]})]});const l=[((o=a.stored)==null?void 0:o.locale)??"",((h=a.stored)==null?void 0:h.dateStyle)??"",((x=(w=a.stored)==null?void 0:w.dateTime)==null?void 0:x.dateStyle)??"",((b=(u=a.stored)==null?void 0:u.dateTime)==null?void 0:b.timeStyle)??"",((c=a.stored)==null?void 0:c.defaultCurrency)??""].join(":");return/* @__PURE__ */r(Ot,{preferences:a,isSaving:s,updatePreferences:i,onClose:t},l);}function Ot({preferences:e,isSaving:t,updatePreferences:a,onClose:n}){var w,x;const[s,i]=I(()=>Rt(e.stored)),l=(s.locale===void 0||Oe(s.locale)!==void 0)&&(s.defaultCurrency===void 0||qa(s.defaultCurrency)!==void 0)&&(s.dateStyle===void 0||["short","medium","long"].includes(s.dateStyle))&&(((w=s.dateTime)==null?void 0:w.dateStyle)===void 0||["short","medium","long"].includes(s.dateTime.dateStyle))&&(((x=s.dateTime)==null?void 0:x.timeStyle)===void 0||["short","medium","long"].includes(s.dateTime.timeStyle)),o=async()=>{const u={...(s.locale!==void 0?{locale:s.locale}:{}),...(s.dateStyle!==void 0?{dateStyle:s.dateStyle}:{}),...(s.dateTime?{dateTime:{...s.dateTime}}:{}),...(s.defaultCurrency!==void 0?{defaultCurrency:s.defaultCurrency}:{})},b=_e.filter(m=>Pe(s,m)===void 0&&Pe(e.stored,m)!==void 0),c={...(Object.keys(u).length>0?{set:u}:{}),...(b.length>0?{clear:b}:{})};(Object.keys(c).length===0?!0:await a(c))?(O.success("Display format preferences saved."),n()):O.error("Failed to save preferences. Please try again.");},h=async()=>{(await a({clear:[..._e]}))?(O.success("Display format preferences reset."),n()):O.error("Failed to reset display format preferences. Please try again.");};return/* @__PURE__ */d(M,{children:[/* @__PURE__ */r("div",{className:"py-2",children:/* @__PURE__ */r(Lt,{value:s,inherited:e.inherited,inheritedSources:e.inheritedSources,onChange:i,disabled:t})}),/* @__PURE__ */d(pe,{className:"justify-between sm:justify-between",children:[/* @__PURE__ */r(z,{variant:"ghost",size:"xs",onClick:h,disabled:t||e.stored===null,children:"Reset display formats"}),/* @__PURE__ */d("div",{className:"flex gap-2",children:[/* @__PURE__ */r(z,{variant:"outline",size:"xs",onClick:n,disabled:t,children:"Cancel"}),/* @__PURE__ */r(z,{size:"xs",onClick:o,disabled:t||!l,children:t?/* @__PURE__ */d(M,{children:[/* @__PURE__ */r(ze,{className:"h-3.5 w-3.5 animate-spin"}),"Saving…"]}):"Save"})]})]})]});}function er({open:e,onOpenChange:t}){const[a,n]=I("display"),s=()=>t(!1);return/* @__PURE__ */r(ca,{open:e,onOpenChange:t,children:/* @__PURE__ */d(ua,{className:"rounded-control border-border/60 sm:max-w-[440px] sm:rounded-control",children:[/* @__PURE__ */d(ma,{children:[/* @__PURE__ */r(ha,{className:"text-[15px]",children:"Report preferences"}),/* @__PURE__ */r(fa,{className:"text-[13px] leading-5",children:"Set how values and Calendar periods appear for you."})]}),/* @__PURE__ */d(ba,{value:a,onValueChange:n,children:[/* @__PURE__ */d(pa,{variant:"underline",className:"w-full justify-start",children:[/* @__PURE__ */r(Se,{value:"display",children:"Display formats"}),/* @__PURE__ */r(Se,{value:"calendar",children:"Calendar"})]}),/* @__PURE__ */r(we,{value:"display",children:/* @__PURE__ */r(Ut,{active:e&&a==="display",onClose:s})}),/* @__PURE__ */r(we,{value:"calendar",children:/* @__PURE__ */r(kt,{active:e&&a==="calendar",onClose:s})})]})]})});}export{et as A,Qt as D,er as R,Lt as a,dt as b,Yt as c,bt as d,pt as u};
|
|
1
|
+
import{jsx as r,Fragment as M,jsxs as d}from"react/jsx-runtime";import He,{useMemo as B,useState as I,useEffect as j,lazy as te,Suspense as Q,useRef as L,useLayoutEffect as ee,useCallback as P,useId as $}from"react";import{at as be,u as k,B as z,b3 as Ke,b4 as qe,b5 as Ge,b6 as Xe,b7 as Je,b8 as Ze,b9 as Ye,ba as Qe,r as X,q as ea,t as ge,v as aa,E as ta,S as ra,bb as na,bc as sa,aS as la,bd as ve,be as ne,aQ as G,P as ia,b as oa,e as da,g as ye,bf as pe,ag as ze,bg as O,a4 as de,a5 as ce,a6 as ue,a7 as me,a8 as F,bh as ca,bi as ua,bj as ma,bk as ha,bl as fa,bm as ba,bn as pa,bo as Se,bp as we}from"./appearance-provider-fIhJSX6y.js";import{a as ga,aX as va,aY as ya,aZ as Le,H as Sa,E as wa,a_ as xa,a$ as Ca,b0 as J,b1 as Re,b2 as xe,b3 as Ta,b4 as Na,b5 as Ea,b6 as Ia,F as Aa,B as ka,S as Da,U as _a,D as Pa,A as za,C as La,b7 as Ra,f as Ua,g as Oa,h as Fa,i as Ba,j as Ce,k as Te,b8 as ja}from"./semaphor-ready-indicator-Bj-cjkz-.js";import{E as Ma,bs as Va,k as U}from"./resolve-dashboard-input-context-SlAAe4GF.js";import{L as Wa}from"./bookmark-state-DScd31KT.js";import{r as $a,a as Ue}from"./availability-3AIOf6Z-.js";import"./validators-Dg2kyF4_.js";import"./matrix-operation-contract-CWvcEsQ0.js";import"./analytics-base-schemas-DMFrDqn_.js";import{parseValueFormatPreferencesResponse as Ha,canonicalizeSupportedLocale as Oe,getSupportedCurrencyCodes as Ka,canonicalizeSupportedCurrencyCode as qa}from"../value-format-preferences/index.js";import{k as Ga}from"./filter-reach-preview-DAEIyrEG.js";import{a as Xa}from"./report-runtime-context-Cd1b5pku.js";import{at as Z,aA as H}from"./pivot-result-contract-expectations-BNWhS8mv.js";function Ja(){return/* @__PURE__ */r("div",{role:"dashboard-plus-main",className:"flex min-h-0 grow basis-0 overflow-hidden",children:/* @__PURE__ */r("section",{className:"flex min-h-0 grow basis-0 flex-col overflow-hidden",children:/* @__PURE__ */r(ga,{})})});}const Za=/* @__PURE__ */new Set(["iat","exp","nbf","jti"]);function Ya(e){return Ma(Object.fromEntries(Object.entries(e??{}).filter(([t])=>!Za.has(t))));}function Qa(e){var a;const t=e==null?void 0:e.config;return $a({features:((a=t==null?void 0:t.projectFeatures)==null?void 0:a.features)??{},config:{enabled:Ue(t).enabled},identity:{orgUserId:e==null?void 0:e.orgUserId,tenantId:e==null?void 0:e.tenantId,endUserId:e==null?void 0:e.endUserId},modelConfigured:!0});}let Ne=0;function Ee(e,t){Ne+=1;const{name:a,layout:n}=Ue(t==null?void 0:t.config);return{...ya(n),id:Ne,callerKey:e,assistantName:a};}function et({children:e,authToken:t}){const a=be(),n=B(()=>t===void 0?a.tokenProps:tt(t),[t,a.tokenProps]),s=B(()=>Ya(n),[n]),i=B(()=>Qa(n).available,[n]),[l,o]=I(()=>Ee(s,n));l.callerKey!==s&&o(Ee(s,n)),rt(l);const h=B(()=>({instance:l,available:i}),[l,i]);return/* @__PURE__ */r(va.Provider,{value:h,children:e});}function at({children:e}){return Le()?/* @__PURE__ */r(M,{children:e}):/* @__PURE__ */r(et,{children:e});}function tt(e){if(!(e!=null&&e.accessToken))return{};try{return Va(e.accessToken);}catch{return{};}}function rt(e){j(()=>{const t=(n,s)=>{const i=e.store.getState().focus;i&&!nt(i,n,s)&&e.clearFocus();},a=k.getState();return t(a.selectedSheetId,a.dashboard),k.subscribe((n,s)=>{(n.selectedSheetId!==s.selectedSheetId||n.dashboard!==s.dashboard)&&t(n.selectedSheetId,n.dashboard),n.isVisualEditing&&!s.isVisualEditing&&e.leaveBeside();});},[e]);}function nt(e,t,a){if((t??null)!==e.sheetId)return!1;const n=a?Wa(a,e.cardId):void 0;return!!n&&n.sheet.id===e.sheetId;}const st=te(()=>import("./assistant-chat-SBKSrrEA.js"));function Yt(){const e=Sa(),t=wa();if(!e.available)return null;const a=t!=="lg";return/* @__PURE__ */d(z,{variant:e.isOpen?"secondary":"outline",size:"xs","aria-pressed":e.isOpen,"aria-label":e.assistantName,title:a?e.assistantName:void 0,onClick:e.toggle,className:a?"w-7 px-0":void 0,children:[/* @__PURE__ */r(xa,{className:"h-3.5 w-3.5"}),!a&&e.assistantName]});}const lt={"docked-right":"relative shrink-0 border-l border-border","docked-left":"relative order-first shrink-0 border-r border-border",centered:"absolute left-1/2 top-1/2 z-30 h-[min(80%,760px)] w-[min(640px,calc(100%-2rem))] -translate-x-1/2 -translate-y-1/2 rounded-card border border-border shadow-lg","full-page":"absolute inset-0 z-30"},it="absolute left-0 top-0 z-30 max-h-[var(--assistant-beside-max-h)] max-w-[var(--assistant-beside-max-w)] rounded-card border border-border shadow-lg",ot=640,q=8;function dt({surface:e="dashboard"}={}){const t=Le(),{isOpen:a,mounted:n,storedLayout:s,width:i,beside:l,besideSize:o,focusCardId:h,askCount:w}=Ke((t==null?void 0:t.instance.store)??Ca,qe(f=>{var v;return{isOpen:f.isOpen,mounted:f.mounted,storedLayout:f.layout,width:f.width,beside:f.beside,besideSize:f.besideSize,focusCardId:(v=f.focus)==null?void 0:v.cardId,askCount:f.askCount};})),x=e==="none",u=k(f=>l&&a&&h&&!x?ct(f.dashboard,f.selectedSheetId,h):void 0),b=ut(u,w);if(!(t!=null&&t.available)||!n&&!x)return null;const c=x?"full-page":b.shown?"beside-card":s,S=x||a,m=c==="docked-right"||c==="docked-left";return/* @__PURE__ */d("aside",{ref:b.setFloating,"aria-label":t.instance.assistantName,"data-testid":"assistant-panel","data-layout":c,"data-beside-frame":c==="beside-card"?u:void 0,"data-beside-side":c==="beside-card"?b.side:void 0,className:U("flex-col bg-background",c==="beside-card"?it:lt[c],S?"flex":"hidden"),style:c==="beside-card"?{...b.style,width:o.width,height:o.height}:m?{width:i,maxWidth:`${Fe*100}%`}:void 0,onKeyDown:c==="beside-card"?f=>{if(f.key!=="Escape"||f.defaultPrevented||!(f.target instanceof Node)||!f.currentTarget.contains(f.target))return;f.preventDefault();const v=b.cardActions();t.instance.close(),v==null||v.focus();}:void 0,children:[m?/* @__PURE__ */r(ft,{instance:t.instance,side:c==="docked-left"?"right":"left",width:i}):null,c==="beside-card"?/* @__PURE__ */r(ht,{instance:t.instance,size:o,side:b.handleSide}):null,/* @__PURE__ */r(Q,{fallback:null,children:/* @__PURE__ */r(st,{instance:t.instance,surface:e,placement:c},t.instance.id)})]});}function ct(e,t,a){var s,i,l;const n=(s=e.sheets)==null?void 0:s.find(o=>o.id===t);return(l=(i=n==null?void 0:n.frames)==null?void 0:i.find(o=>{var h;return(h=o.cards)==null?void 0:h.some(w=>w.id===a);}))==null?void 0:l.id;}function ut(e,t){var S;const[a,n]=I(void 0),[s,i]=I(void 0),l=L(t);ee(()=>{l.current=t;});const o=s===t?null:a,{refs:h,elements:w,floatingStyles:x,middlewareData:u,isPositioned:b}=Ge({strategy:"absolute",placement:o??"right-start",middleware:[Xe(q),Je({padding:q}),Ze({padding:q,apply:({availableWidth:m,availableHeight:f,elements:v})=>{v.floating.style.setProperty("--assistant-beside-max-w",`${Math.max(0,m)}px`),v.floating.style.setProperty("--assistant-beside-max-h",`${Math.max(0,f)}px`);}}),Ye()],whileElementsMounted:(m,f,v)=>Qe(m,f,()=>{const E=mt(m,f);n(E),E===null&&i(l.current),v();})}),c=w.floating;return ee(()=>{h.setReference(e?Ie(c==null?void 0:c.parentElement,e):null);},[e,c,h]),{shown:e!==void 0&&o!==null&&w.reference!==null,setFloating:h.setFloating,style:{...x,...(!b||(S=u.hide)!=null&&S.referenceHidden?{visibility:"hidden"}:{})},side:o??void 0,handleSide:o==="left-start"?"left":"right",cardActions:()=>{var m;return e?(m=Ie(c==null?void 0:c.parentElement,e))==null?void 0:m.querySelector("[data-card-actions]"):null;}};}function Ie(e,t){return e?Array.from(e.querySelectorAll("[data-frame-id]")).find(a=>a.dataset.frameId===t)??null:null;}function mt(e,t){const a=t.parentElement;if(!a||!e.isConnected)return null;const n=a.getBoundingClientRect();if(n.width<ot)return null;const s=e.getBoundingClientRect(),{min:i}=Re,l=(o,h)=>o>=i.width+2*q&&h>=i.height+2*q;return l(n.right-s.right,n.height)?"right-start":l(s.left-n.left,n.height)?"left-start":l(n.width,n.bottom-s.bottom)?"bottom-start":null;}function ht({instance:e,size:t,side:a}){const n=L(void 0),s=a==="left"?-1:1,i=l=>{const o=n.current;return{width:o.start.width+s*(l.clientX-o.x),height:o.start.height+(l.clientY-o.y)};};return/* @__PURE__ */r("div",{role:"separator","aria-label":"Resize assistant",tabIndex:0,title:"Drag to resize. Double-click to reset.",onPointerDown:l=>{var o,h;l.preventDefault(),(h=(o=l.currentTarget).setPointerCapture)==null||h.call(o,l.pointerId),n.current={x:l.clientX,y:l.clientY,start:t};},onPointerMove:l=>{n.current&&e.setBesideSize(i(l));},onPointerUp:l=>{n.current&&(e.setBesideSize(i(l),{save:!0}),n.current=void 0);},onPointerCancel:()=>{n.current=void 0;},onKeyDown:l=>{const o={ArrowLeft:{width:-s*W,height:0},ArrowRight:{width:s*W,height:0},ArrowUp:{width:0,height:-W},ArrowDown:{width:0,height:W}}[l.key];o&&(l.preventDefault(),e.setBesideSize({width:t.width+o.width,height:t.height+o.height},{save:!0}));},onDoubleClick:()=>e.setBesideSize(Re.default,{save:!0}),className:U("absolute bottom-0 z-10 h-3 w-3 touch-none outline-none hover:bg-primary/30 focus-visible:bg-primary/40",a==="left"?"left-0 cursor-nesw-resize rounded-bl-card":"right-0 cursor-nwse-resize rounded-br-card")});}const W=16,Fe=0.6;function ft({instance:e,side:t,width:a}){const n=L(void 0),s=u=>{var c,S;const b=(S=(c=u.closest("aside"))==null?void 0:c.parentElement)==null?void 0:S.clientWidth;return b?b*Fe:J.max;},i=u=>{var b;return((b=u.closest("aside"))==null?void 0:b.getBoundingClientRect().width)||a;},l=u=>{const b=n.current;if(!b)return a;const c=u-b.startX;return xe(b.startWidth+(t==="left"?-c:c),b.maxForArea);},o=u=>{var b,c;u.preventDefault(),(c=(b=u.currentTarget).setPointerCapture)==null||c.call(b,u.pointerId),n.current={startX:u.clientX,startWidth:i(u.currentTarget),maxForArea:s(u.currentTarget)};},h=u=>{n.current&&e.setWidth(l(u.clientX));},w=u=>{n.current&&(e.setWidth(l(u.clientX),{save:!0}),n.current=void 0);},x=u=>{if(u.key!=="ArrowLeft"&&u.key!=="ArrowRight")return;u.preventDefault();const b=u.key==="ArrowLeft"==(t==="left");e.setWidth(xe(i(u.currentTarget)+(b?W:-W),s(u.currentTarget)),{save:!0});};return/* @__PURE__ */r("div",{role:"separator","aria-orientation":"vertical","aria-label":"Resize assistant","aria-valuenow":a,"aria-valuemin":J.min,"aria-valuemax":J.max,tabIndex:0,title:"Drag to resize. Double-click to reset.",onPointerDown:o,onPointerMove:h,onPointerUp:w,onPointerCancel:w,onKeyDown:x,onDoubleClick:()=>e.setWidth(J.default,{save:!0}),className:U("absolute inset-y-0 z-10 w-1.5 cursor-col-resize touch-none outline-none hover:bg-primary/30 focus-visible:bg-primary/40",t==="left"?"-left-[3px]":"-right-[3px]")});}function bt(e){const t=Ta();return P(async(a,n)=>{const s=k.getState();if(s.isVisualEditing)return{ok:!1,reason:"not_editable",message:X.not_editable};if(!e())return{ok:!1,reason:"not_editable",message:X.no_save};if(s.dashboard!==a.basedOn)return{ok:!1,reason:"dashboard_changed",message:X.dashboard_changed};const i=Ga(a.basedOn,a.operations,a.context);if(!i.ok)return{ok:!1,reason:"refused",message:i.failedAt.message};const l={domainsById:{}};for(const o of i.queryFrames){const h=await t(o,{reuseLoaded:!0}).catch(w=>{console.warn("Applying the change without refreshed semantic metadata:",w);});ea(l,h);}return n!=null&&n.stillWanted&&!n.stillWanted()?{ok:!1,reason:"dropped"}:e()?k.getState().actions.applyProposal({...a,semanticExecutionPayload:l}):{ok:!1,reason:"not_editable",message:X.no_save};},[e,t]);}function pt(e){const{canEditDashboard:t,isInspectionMode:a}=Na(),n=Ea(),s=k(ge),i=e&&n&&t===!0&&!a,l=L(i);ee(()=>{l.current=i;});const o=P(()=>l.current&&ge(k.getState()),[]);return{canChange:i&&s,canChangeNow:o};}const Be={dashboard_changed:"Not applied: the dashboard on screen changed after this change was prepared.",not_editable:"Not applied: the dashboard can't be changed on screen right now (the editor is open, or Save isn't shown).",expired:"Not applied: it arrived after the time it had to land.",refused:"Not applied: the change no longer fits the dashboard."},K={changed:"Changed by your assistant",undo:"Undo",changedSince:"Changed since. Cancel discards every unsaved change.",closeEditorToUndo:"Close the editor to undo."};function gt({port:e,onLifecycleEvent:t}){const{canChange:a,canChangeNow:n}=pt(!0),s=k(c=>{var S;return(S=c.dashboard)==null?void 0:S.id;}),i=bt(n),[l,o]=I(null),h=L(/* @__PURE__ */new Map()),w=L(/* @__PURE__ */new Map()),x=L(Promise.resolve()),u=L({apply:i,onLifecycleEvent:t});ee(()=>{u.current={apply:i,onLifecycleEvent:t};}),j(()=>{e.setScreenState({eligible:a,...(s?{dashboardId:s}:{})});},[e,a,s]),j(()=>k.subscribe((c,S)=>{if(c.editSessionEpoch!==S.editSessionEpoch){h.current.clear(),o(null);return;}if(c.dashboard!==S.dashboard)for(const[m,f]of h.current)f!==c.dashboard&&h.current.delete(m);}),[]),j(()=>{const c=m=>{const f=k.getState().dashboard;if(!f||f.id!==m.dashboardId)return;const v=St();h.current.set(v,f),e.answerCopyRequest({kind:"uploaded",screenId:e.screenId,requestId:m.requestId,revisionId:v,dashboard:f});},S=async(m,f)=>{var p,y,T;const v=w.current.get(m.deliveryId);if(v){e.reportOutcome({screenId:e.screenId,deliveryId:m.deliveryId,outcome:v});return;}const E=h.current.get(m.revisionId),A=()=>!E||h.current.get(m.revisionId)!==E?"dashboard_changed":performance.now()<f+m.applyWithinMs?null:"expired",_=A();let D;if(_||!E)D=Y(_??"dashboard_changed");else{let g="expired";const V=await u.current.apply({proposalId:m.proposalId,operations:m.operations,context:m.context,basedOn:E},{stillWanted:()=>{const R=A();return R&&(g=R),R===null;}});D=yt(V,g);}if(w.current.set(m.deliveryId,D),e.reportOutcome({screenId:e.screenId,deliveryId:m.deliveryId,outcome:D}),D.status!=="applied")return;const N=((p=k.getState().dashboard)==null?void 0:p.id)??"";o({deliveryId:m.deliveryId,proposalId:m.proposalId,summary:m.summary,dashboardId:N,words:null}),(T=(y=u.current).onLifecycleEvent)==null||T.call(y,{type:"dashboard:change-applied",dashboardId:N,payload:{deliveryId:m.deliveryId,summary:m.summary}});};return e.subscribe(m=>{if(m.type==="copy_request"){c(m);return;}const f=performance.now();x.current=x.current.then(()=>S(m,f).catch(v=>console.error("[live-screen] a delivery failed",v)));});},[e]);const b=P(()=>{var S,m;if(!l)return;const c=k.getState().actions.undoProposal(l.proposalId);c.ok?((m=(S=u.current).onLifecycleEvent)==null||m.call(S,{type:"dashboard:change-undone",dashboardId:l.dashboardId,payload:{deliveryId:l.deliveryId,summary:l.summary}}),o(null)):c.reason==="changed_since"?o({...l,words:"changed_since"}):c.reason==="not_editable"?o({...l,words:"not_editable"}):o(null);},[l]);return l?/* @__PURE__ */r(vt,{note:l,onUndo:b}):null;}function vt({note:e,onUndo:t}){const a=k(l=>aa(l,e.proposalId)),n=k(l=>l.isVisualEditing);if(a==="none"&&e.words===null)return null;const s=e.words==="changed_since"||a==="changed_since",i=s?"changed_since":e.words==="not_editable"?"not_editable":a;return/* @__PURE__ */d("div",{className:"flex min-h-8 items-center gap-2 border-b border-border bg-muted/40 px-3 py-1 text-xs text-muted-foreground","data-testid":"live-change-note","data-note-state":i,role:"status",children:[/* @__PURE__ */d("span",{className:"truncate",title:e.summary.join(" "),children:[K.changed,s?`. ${K.changedSince}`:e.words==="not_editable"?`. ${K.closeEditorToUndo}`:""]}),!s&&a==="undoable"?/* @__PURE__ */d(M,{children:[/* @__PURE__ */r("span",{"aria-hidden":"true",children:"·"}),/* @__PURE__ */d(z,{variant:"outline",size:"xs",className:"h-6 gap-1 px-2 text-[11.5px]",disabled:n,title:n?K.closeEditorToUndo:void 0,onClick:t,children:[/* @__PURE__ */r(Ia,{className:"h-3 w-3"}),K.undo]})]}):null]});}function yt(e,t){if(e.ok)return{status:"applied"};switch(e.reason){case"dashboard_changed":case"not_editable":return Y(e.reason);case"refused":return{status:"not_applied",reason:"refused",message:(e.message||Be.refused).slice(0,500)};case"dropped":return Y(t);case"previous_not_applied":return Y("refused");}}function Y(e){return{status:"not_applied",reason:e,message:Be[e]};}function St(){return globalThis.crypto.randomUUID();}const wt=te(()=>import("./dashboard-controls-DpADfhr0.js")),xt=te(()=>import("./edit-dashboard-visual-DlvY7au4.js")),Ct=te(()=>import("./dashboard-json-4xMChR2q.js"));function Qt({showControls:e=!1,showFooter:t=!0,liveScreen:a,...n}){const s=k(o=>o.showDashboardJSON),{appearance:i,preferences:l}=n;return/* @__PURE__ */r(ta,{FallbackComponent:Aa,children:/* @__PURE__ */r(ra,{dashboardProps:n,children:/* @__PURE__ */d(ka,{children:[/* @__PURE__ */r(Da,{componentType:"surfboard",componentId:n.id}),/* @__PURE__ */d(_a,{appearance:i,children:[/* @__PURE__ */r(na,{toastOptions:{classNames:{toast:"max-w-[calc(100vw-2rem)] overflow-x-hidden !items-start [--toast-close-button-end:0.5rem] [--toast-close-button-start:auto] [--toast-close-button-transform:translate(0,0)] sm:max-w-[44rem]",content:"min-w-0 flex-1",icon:"mt-0.5 shrink-0",title:"max-w-full break-words pr-8",description:"max-w-full break-words",closeButton:"!top-2 h-6 w-6 rounded-md border-border bg-background text-muted-foreground hover:bg-muted hover:text-foreground"}}}),/* @__PURE__ */d(Pa,{preferences:l,children:[s&&/* @__PURE__ */r(Q,{fallback:null,children:/* @__PURE__ */r(Ct,{})}),/* @__PURE__ */r(za,{children:/* @__PURE__ */r(at,{children:/* @__PURE__ */d("main",{className:"relative flex h-full w-full flex-col overflow-hidden",children:[e&&/* @__PURE__ */r(Q,{fallback:null,children:/* @__PURE__ */r(wt,{})}),a&&/* @__PURE__ */r(gt,{port:a,onLifecycleEvent:n.onDashboardLifecycleEvent}),/* @__PURE__ */d("div",{className:"relative flex grow overflow-hidden",children:[/* @__PURE__ */r("div",{className:"flex min-w-0 flex-1",children:/* @__PURE__ */r(La,{...n,type:"dashboard",children:/* @__PURE__ */r(Tt,{})})}),/* @__PURE__ */r(dt,{})]})]})})})]})]})]})})});}function Tt(){const e=k(a=>a.isVisualEditing),t=B(()=>/* @__PURE__ */r(sa.Provider,{value:!0,children:/* @__PURE__ */r(Ja,{})}),[]);return/* @__PURE__ */d("div",{className:"relative flex min-h-0 min-w-0 grow basis-0 flex-col",children:[/* @__PURE__ */r("div",{className:"flex min-h-0 grow basis-0 flex-col",style:e?{visibility:"hidden"}:void 0,inert:e||void 0,"aria-hidden":e||void 0,"data-dashboard-hidden":e||void 0,children:t}),e&&/* @__PURE__ */r("div",{className:"absolute inset-0 z-10 flex flex-col",children:/* @__PURE__ */r(Q,{fallback:null,children:/* @__PURE__ */r(xt,{})})})]});}function Nt(e={}){const{authToken:t,tokenProps:a}=be(),n=k(N=>N.actions.applyResolvedCalendarPreferences),s=e.enabled??!0,i=(t==null?void 0:t.accessToken)??null,l=(a==null?void 0:a.apiServiceUrl)??null,[o,h]=I(!1),[w,x]=I(!1),[u,b]=I(!1),[c,S]=I(null),[m,f]=I(null),v=L(i);v.current=i,j(()=>{f(null),S(null),h(!1),x(!1),b(!1);},[i]);const E=P(async N=>{const p=Xa(await N.json());if(!p.ok)throw new Error("Calendar preferences response is invalid");return p.value;},[]),A=P(async()=>{if(!s||!i||!l)return;const N=i;h(!0),S(null);try{const p=await fetch(`${l}/v1/user-preferences/calendar`,{method:"GET",headers:{Authorization:`Bearer ${i}`}});if(!p.ok){const T=await p.json().catch(()=>({}));throw new Error(T.error||"Failed to fetch preferences");}const y=await E(p);v.current===N&&f(y);}catch(p){v.current===N&&S(p instanceof Error?p.message:"Unknown error");}finally{v.current===N&&h(!1);}},[i,l,s,E]);j(()=>{s&&A();},[s,A]);const _=P(async N=>{if(!i||!l)return S("Not authenticated"),!1;const p=i;x(!0),S(null);try{const y=await fetch(`${l}/v1/user-preferences/calendar`,{method:"PATCH",headers:{"Content-Type":"application/json",Authorization:`Bearer ${i}`},body:JSON.stringify(N)});if(!y.ok){const g=await y.json().catch(()=>({}));throw new Error(g.error||"Failed to update preferences");}const T=await E(y);return v.current!==p?!1:(f(T),n(T.resolved,T.sources),!0);}catch(y){return v.current===p&&S(y instanceof Error?y.message:"Unknown error"),!1;}finally{v.current===p&&x(!1);}},[i,l,n,E]),D=P(async()=>{if(!i||!l)return S("Not authenticated"),!1;const N=i;b(!0),S(null);try{const p=await fetch(`${l}/v1/user-preferences/calendar`,{method:"DELETE",headers:{Authorization:`Bearer ${i}`}});if(!p.ok){const T=await p.json().catch(()=>({}));throw new Error(T.error||"Failed to clear preferences");}const y=await E(p);return v.current!==N?!1:(f(y),n(y.resolved,y.sources),!0);}catch(p){return v.current===N&&S(p instanceof Error?p.message:"Unknown error"),!1;}finally{v.current===N&&b(!1);}},[i,l,n,E]);return{preferences:m,isLoading:o,isSaving:w,isClearing:u,error:c,updatePreferences:_,clearPreferences:D,refetch:A};}const ae=[{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"}],je=[{value:0,label:"Sunday"},{value:1,label:"Monday"},{value:6,label:"Saturday"}],Ae="text-[10px] font-medium uppercase tracking-[0.08em] text-muted-foreground";function Et(){try{const e=Intl;if(e.supportedValuesOf)return e.supportedValuesOf("timeZone");}catch{}return ae.map(e=>e.value);}function It(e){if(!e)return"default";if(e.tz!==e.weekStart)return"inherited";switch(e.tz){case"viewer_tenant":return"tenant";case"viewer_organization":return"organization";case"system_default":return"system";case"session_initial":return"embedded";default:return"default";}}function ke(e){const t=ae.find(a=>a.value===e);return t?t.label:e;}function At(e){const t=je.find(a=>a.value===e);return t?t.label:String(e);}function kt({active:e,onClose:t}){const{preferences:a,isLoading:n,isSaving:s,isClearing:i,updatePreferences:l,clearPreferences:o}=Nt({enabled:e}),h=la(),w=(a==null?void 0:a.resolved.tz)||(h==null?void 0:h.tz)||"UTC",x=(a==null?void 0:a.resolved.weekStart)??(h==null?void 0:h.weekStart)??1,[u,b]=I((a==null?void 0:a.stored)===null),[c,S]=I(!1),[m,f]=I(w),[v,E]=I(x),[A,_]=I(!1),D=B(()=>Et(),[]),N=B(()=>D.filter(C=>!ae.some($e=>$e.value===C)),[D]),p=B(()=>ke(m),[m]),y=a!=null&&a.inherited?ke(a.inherited.tz):"UTC",T=a!=null&&a.inherited?At(a.inherited.weekStart):"Monday",g=It(a==null?void 0:a.inheritedSources);He.useEffect(()=>{if(!e){S(!1);return;}c||(a&&b(a.stored===null),f(w),E(x));},[e,c,a,w,x]);const V=async()=>{if(n){O.error("Preferences are still loading. Please try again.");return;}u?(await o())?(O.success("Now using default settings."),t()):O.error("Failed to save preferences. Please try again."):(await l({tz:m,weekStart:v}))?(O.success("Preferences saved."),t()):O.error("Failed to save preferences. Please try again.");},R=()=>{t();},re=s||i,We=re||n;return/* @__PURE__ */d(M,{children:[/* @__PURE__ */d("div",{className:"space-y-4 py-1",children:[/* @__PURE__ */d(ve,{value:u?"defaults":"custom",onValueChange:C=>{S(!0),b(C==="defaults");},className:"space-y-0.5",children:[/* @__PURE__ */d("label",{htmlFor:"mode-defaults",className:U("flex cursor-pointer items-start gap-2 rounded-control px-2 py-1.5 hover:bg-muted/50",u&&"bg-muted/50"),onClick:()=>{S(!0),b(!0);},children:[/* @__PURE__ */r(ne,{value:"defaults",id:"mode-defaults",className:"mt-0.5"}),/* @__PURE__ */d("div",{className:"flex-1 min-w-0",children:[/* @__PURE__ */d("p",{className:"text-[13px] font-medium text-foreground",children:["Use ",g," defaults"]}),/* @__PURE__ */d("p",{className:"text-[12px] text-muted-foreground",children:[y,", week starts ",T]})]})]}),/* @__PURE__ */d("label",{htmlFor:"mode-custom",className:U("flex cursor-pointer items-start gap-2 rounded-control px-2 py-1.5 hover:bg-muted/50",!u&&"bg-muted/50"),onClick:()=>{S(!0),b(!1);},children:[/* @__PURE__ */r(ne,{value:"custom",id:"mode-custom",className:"mt-0.5"}),/* @__PURE__ */r("p",{className:"flex-1 text-[13px] font-medium text-foreground",children:"Use custom settings"})]})]}),/* @__PURE__ */d("div",{className:U("space-y-4 border-t border-border/60 pt-4 transition-opacity",u&&"pointer-events-none opacity-50"),children:[/* @__PURE__ */d("div",{className:"space-y-1.5",children:[/* @__PURE__ */r(G,{className:Ae,children:"Timezone"}),/* @__PURE__ */d(ia,{open:A,onOpenChange:_,modal:!0,children:[/* @__PURE__ */r(oa,{asChild:!0,children:/* @__PURE__ */d(z,{variant:"outline",size:"xs",role:"combobox","aria-expanded":A,className:"w-full justify-between text-[12px] font-normal",disabled:u,children:[/* @__PURE__ */r("span",{className:"truncate",children:p}),/* @__PURE__ */r(Ra,{className:"ml-2 h-3.5 w-3.5 shrink-0 opacity-50"})]})}),/* @__PURE__ */r(da,{className:"z-50 w-[--radix-popover-trigger-width] p-0",align:"start",children:/* @__PURE__ */d(Ua,{className:"overflow-visible",children:[/* @__PURE__ */r(Oa,{placeholder:"Search timezones…"}),/* @__PURE__ */d(Fa,{children:[/* @__PURE__ */r(Ba,{children:"No timezone found."}),/* @__PURE__ */r(Ce,{heading:"Common",children:ae.map(C=>/* @__PURE__ */d(Te,{value:`${C.value} ${C.label}`,onSelect:()=>{S(!0),f(C.value),_(!1);},children:[/* @__PURE__ */r(ye,{className:U("h-3.5 w-3.5",m===C.value?"opacity-100":"opacity-0")}),/* @__PURE__ */r("span",{className:"flex-1",children:C.label}),/* @__PURE__ */r("span",{className:"text-[11px] text-muted-foreground",children:C.value})]},C.value))}),/* @__PURE__ */r(ja,{}),/* @__PURE__ */r(Ce,{heading:"All timezones",children:N.map(C=>/* @__PURE__ */d(Te,{value:C,onSelect:()=>{S(!0),f(C),_(!1);},children:[/* @__PURE__ */r(ye,{className:U("h-3.5 w-3.5",m===C?"opacity-100":"opacity-0")}),C]},C))})]})]})})]})]}),/* @__PURE__ */d("div",{className:"space-y-1.5",children:[/* @__PURE__ */r(G,{className:Ae,children:"Week starts on"}),/* @__PURE__ */r(ve,{value:String(v),onValueChange:C=>{S(!0),E(Number(C));},className:"flex gap-4",disabled:u,children:je.map(C=>/* @__PURE__ */d("label",{htmlFor:`week-start-${C.value}`,className:U("flex cursor-pointer items-center gap-2 text-[13px]",u&&"cursor-not-allowed"),children:[/* @__PURE__ */r(ne,{value:String(C.value),id:`week-start-${C.value}`,disabled:u}),C.label]},C.value))})]})]})]}),/* @__PURE__ */d(pe,{children:[/* @__PURE__ */r(z,{variant:"outline",size:"xs",onClick:R,disabled:re,children:"Cancel"}),/* @__PURE__ */r(z,{size:"xs",onClick:V,disabled:We,children:re?/* @__PURE__ */d(M,{children:[/* @__PURE__ */r(ze,{className:"h-3.5 w-3.5 animate-spin"}),"Saving…"]}):"Save"})]})]});}function Dt(e={}){const{authToken:t,tokenProps:a}=be(),n=k(p=>p.actions.applyResolvedValueFormatPreferences),s=e.enabled??!0,i=(t==null?void 0:t.accessToken)??null,l=(a==null?void 0:a.apiServiceUrl)??null,o=L(i);o.current=i;const[h,w]=I(null),[x,u]=I(!1),[b,c]=I(!1),[S,m]=I(!1),[f,v]=I(null);j(()=>{w(null),v(null),u(!1),c(!1),m(!1);},[i]);const E=P(async p=>{const y=Ha(await p.json());if(!y.ok)throw new Error("Value format preferences response is invalid");return y.value;},[]),A=P(async(p,y)=>{if(!i||!l)throw new Error("Not authenticated");const T=await fetch(`${l}/v1/user-preferences/value-format`,{method:p,headers:{Authorization:`Bearer ${i}`,...(y?{"Content-Type":"application/json"}:{})},body:y?JSON.stringify(y):void 0});if(!T.ok){const g=await T.json().catch(()=>({}));throw new Error(g.error||"Failed to update preferences");}return E(T);},[i,l,E]),_=P(async()=>{if(!s||!i||!l)return;const p=i;u(!0),v(null);try{const y=await A("GET");o.current===p&&w(y);}catch(y){o.current===p&&v(y instanceof Error?y.message:"Unknown error");}finally{o.current===p&&u(!1);}},[i,l,s,A]);j(()=>{s&&_();},[s,_]);const D=P(async p=>{const y=i;c(!0),v(null);try{const T=await A("PATCH",p);return o.current!==y?!1:(w(T),n(T.resolved,T.sources),!0);}catch(T){return o.current===y&&v(T instanceof Error?T.message:"Unknown error"),!1;}finally{o.current===y&&c(!1);}},[i,n,A]),N=P(async()=>{const p=i;m(!0),v(null);try{const y=await A("DELETE");return o.current!==p?!1:(w(y),n(y.resolved,y.sources),!0);}catch(y){return o.current===p&&v(y instanceof Error?y.message:"Unknown error"),!1;}finally{o.current===p&&m(!1);}},[i,n,A]);return{preferences:h,isLoading:x,isSaving:b,isClearing:S,error:f,updatePreferences:D,clearPreferences:N,refetch:_};}const he=[{value:"en-US",label:"English (United States)"},{value:"en-GB",label:"English (United Kingdom)"},{value:"de-DE",label:"German (Germany)"},{value:"fr-FR",label:"French (France)"},{value:"es-ES",label:"Spanish (Spain)"},{value:"it-IT",label:"Italian (Italy)"},{value:"nl-NL",label:"Dutch (Netherlands)"},{value:"pt-BR",label:"Portuguese (Brazil)"},{value:"ja-JP",label:"Japanese (Japan)"},{value:"en-IN",label:"English (India)"},{value:"en-AU",label:"English (Australia)"},{value:"en-NZ",label:"English (New Zealand)"},{value:"mi-NZ",label:"Māori (New Zealand)"}],Me=/* @__PURE__ */new Set(["USD","EUR","GBP","CAD","AUD","JPY","CHF","INR","BRL","KWD"]),_t=Ka(),Pt=_t.filter(e=>!Me.has(e)),Ve=[{value:"short",label:"Short"},{value:"medium",label:"Medium"},{value:"long",label:"Long"}],De="2026-07-31",se="2026-07-31T14:30:45";function fe(e){switch(e){case"viewer_user":return"user";case"viewer_tenant_user":return"tenant user";case"viewer_tenant":return"tenant";case"viewer_organization":return"organization";case"session_initial":return"embedded session";case"system_default":return"system";default:return"another preference level";}}function le(e){var t;return((t=Ve.find(a=>a.value===e))==null?void 0:t.label)??e;}function zt(e){const t=he.find(a=>a.value===e);return t?`${t.label} — ${t.value}`:e;}function ie(e){return{short:e("short"),medium:e("medium"),long:e("long")};}function oe({id:e,label:t,value:a,inherited:n,inheritedSource:s,examples:i,disabled:l,onValueChange:o}){const h=a===void 0?`Inherited · ${le(n)}`:le(a);return/* @__PURE__ */d("div",{className:"space-y-1.5",children:[/* @__PURE__ */r(G,{htmlFor:e,className:"text-[11px] text-muted-foreground",children:t}),/* @__PURE__ */d(de,{value:a??"inherit",disabled:l,onValueChange:o,children:[/* @__PURE__ */r(ce,{id:e,size:"xs",children:/* @__PURE__ */r(ue,{children:h})}),/* @__PURE__ */d(me,{children:[/* @__PURE__ */r(F,{value:"inherit",className:"[&>span:last-child]:w-full",children:/* @__PURE__ */d("span",{className:"flex w-full min-w-0 items-center justify-between gap-4",children:[/* @__PURE__ */d("span",{children:["Inherited from ",fe(s)," ·"," ",le(n)]}),/* @__PURE__ */r("span",{className:"shrink-0 tabular-nums text-muted-foreground",children:i[n]})]})}),Ve.map(w=>/* @__PURE__ */r(F,{value:w.value,className:"[&>span:last-child]:w-full",children:/* @__PURE__ */d("span",{className:"flex w-full min-w-0 items-center justify-between gap-4",children:[/* @__PURE__ */r("span",{children:w.label}),/* @__PURE__ */r("span",{className:"shrink-0 tabular-nums text-muted-foreground",children:i[w.value]})]})},w.value))]})]})]});}function Lt({value:e,inherited:t,inheritedSources:a,onChange:n,disabled:s}){var N,p,y,T;const i=$(),l=$(),o=$(),h=$(),w=$(),u=(e.locale===void 0?void 0:Oe(e.locale))??t.locale,b=e.defaultCurrency??t.defaultCurrency,c={locale:u,dateStyle:e.dateStyle??t.dateStyle,dateTime:{dateStyle:((N=e.dateTime)==null?void 0:N.dateStyle)??t.dateTime.dateStyle,timeStyle:((p=e.dateTime)==null?void 0:p.timeStyle)??t.dateTime.timeStyle},defaultCurrency:b},S=new Intl.NumberFormat(u,{style:"currency",currency:b}).format(1e3),m=Z({preferences:c,calendar:{tz:"UTC"}}),f=H({value:De,metadata:{kind:"raw_temporal",valueKind:"date"},format:m}).text,v=H({value:se,metadata:{kind:"raw_temporal",valueKind:"wall_datetime"},format:m}).text,E=ie(g=>H({value:De,metadata:{kind:"raw_temporal",valueKind:"date"},format:Z({preferences:{...c,dateStyle:g},calendar:{tz:"UTC"}})}).text),A=ie(g=>H({value:se,metadata:{kind:"raw_temporal",valueKind:"wall_datetime"},format:Z({preferences:{...c,dateTime:{...c.dateTime,dateStyle:g}},calendar:{tz:"UTC"}})}).text),_=ie(g=>H({value:se,metadata:{kind:"raw_temporal",valueKind:"wall_datetime"},format:Z({preferences:{...c,dateTime:{...c.dateTime,timeStyle:g}},calendar:{tz:"UTC"}})}).text),D=(g,V)=>{const R={...e.dateTime,[g]:V==="inherit"?void 0:V};n({...e,dateTime:R.dateStyle===void 0&&R.timeStyle===void 0?void 0:R});};return/* @__PURE__ */d("div",{className:"space-y-4",children:[/* @__PURE__ */d("div",{className:"space-y-1.5",children:[/* @__PURE__ */r(G,{htmlFor:i,className:"text-[10px] font-medium uppercase tracking-[0.08em] text-muted-foreground",children:"Locale"}),/* @__PURE__ */d(de,{value:e.locale??"inherit",disabled:s,onValueChange:g=>n({...e,locale:g==="inherit"?void 0:g}),children:[/* @__PURE__ */r(ce,{id:i,size:"xs",children:/* @__PURE__ */r(ue,{children:e.locale===void 0?`Inherited · ${t.locale}`:zt(e.locale)})}),/* @__PURE__ */d(me,{children:[/* @__PURE__ */d(F,{value:"inherit",children:["Inherited from ",fe(a.locale)," ·"," ",t.locale]}),e.locale&&!he.some(g=>g.value===e.locale)&&/* @__PURE__ */r(F,{value:e.locale,children:e.locale}),he.map(g=>/* @__PURE__ */d(F,{value:g.value,children:[g.label," — ",g.value]},g.value))]})]})]}),/* @__PURE__ */d("fieldset",{className:"space-y-2",children:[/* @__PURE__ */r("legend",{className:"text-[10px] font-medium uppercase tracking-[0.08em] text-muted-foreground",children:"Date values"}),/* @__PURE__ */r(oe,{id:o,label:"Format",value:e.dateStyle,inherited:t.dateStyle,inheritedSource:a.dateStyle,examples:E,disabled:s,onValueChange:g=>n({...e,dateStyle:g==="inherit"?void 0:g})})]}),/* @__PURE__ */d("fieldset",{className:"space-y-2",children:[/* @__PURE__ */r("legend",{className:"text-[10px] font-medium uppercase tracking-[0.08em] text-muted-foreground",children:"Date & time values"}),/* @__PURE__ */r(oe,{id:h,label:"Date",value:(y=e.dateTime)==null?void 0:y.dateStyle,inherited:t.dateTime.dateStyle,inheritedSource:a.dateTime.dateStyle,examples:A,disabled:s,onValueChange:g=>D("dateStyle",g)}),/* @__PURE__ */r(oe,{id:w,label:"Time",value:(T=e.dateTime)==null?void 0:T.timeStyle,inherited:t.dateTime.timeStyle,inheritedSource:a.dateTime.timeStyle,examples:_,disabled:s,onValueChange:g=>D("timeStyle",g)})]}),/* @__PURE__ */d("div",{className:"space-y-1.5",children:[/* @__PURE__ */r(G,{htmlFor:l,className:"text-[10px] font-medium uppercase tracking-[0.08em] text-muted-foreground",children:"Default currency"}),/* @__PURE__ */d(de,{value:e.defaultCurrency??"inherit",disabled:s,onValueChange:g=>n({...e,defaultCurrency:g==="inherit"?void 0:g}),children:[/* @__PURE__ */r(ce,{id:l,size:"xs",children:/* @__PURE__ */r(ue,{children:e.defaultCurrency===void 0?`Inherited · ${t.defaultCurrency}`:e.defaultCurrency})}),/* @__PURE__ */d(me,{children:[/* @__PURE__ */d(F,{value:"inherit",children:["Inherited from ",fe(a.defaultCurrency)," ·"," ",t.defaultCurrency]}),[...Me].map(g=>/* @__PURE__ */r(F,{value:g,children:g},g)),Pt.map(g=>/* @__PURE__ */r(F,{value:g,children:g},g))]})]})]}),/* @__PURE__ */d("div",{className:"rounded-control border border-border/60 bg-muted/30 px-3 py-2",children:[/* @__PURE__ */r("p",{className:"text-[10px] font-medium uppercase tracking-[0.08em] text-muted-foreground",children:"Preview"}),/* @__PURE__ */d("dl",{className:"mt-1.5 space-y-1 text-[12px]",children:[/* @__PURE__ */d("div",{className:"flex items-baseline justify-between gap-4",children:[/* @__PURE__ */r("dt",{className:"text-muted-foreground",children:"Date"}),/* @__PURE__ */r("dd",{className:"text-right font-medium text-foreground",children:f})]}),/* @__PURE__ */d("div",{className:"flex items-baseline justify-between gap-4",children:[/* @__PURE__ */r("dt",{className:"text-muted-foreground",children:"Date & time"}),/* @__PURE__ */r("dd",{className:"text-right font-medium text-foreground",children:v})]}),/* @__PURE__ */d("div",{className:"flex items-baseline justify-between gap-4",children:[/* @__PURE__ */r("dt",{className:"text-muted-foreground",children:"Currency"}),/* @__PURE__ */r("dd",{className:"text-right font-medium text-foreground",children:S})]})]})]}),/* @__PURE__ */r("p",{className:"text-[11px] text-muted-foreground",children:"Currency values are not converted. Date examples use a fixed reference value and the Gregorian calendar."})]});}const _e=["locale","dateStyle","dateTime.dateStyle","dateTime.timeStyle","defaultCurrency"];function Pe(e,t){var a,n;switch(t){case"locale":return e==null?void 0:e.locale;case"dateStyle":return e==null?void 0:e.dateStyle;case"dateTime.dateStyle":return(a=e==null?void 0:e.dateTime)==null?void 0:a.dateStyle;case"dateTime.timeStyle":return(n=e==null?void 0:e.dateTime)==null?void 0:n.timeStyle;case"defaultCurrency":return e==null?void 0:e.defaultCurrency;}}function Rt(e){var n,s;const t=(n=e==null?void 0:e.dateTime)==null?void 0:n.dateStyle,a=(s=e==null?void 0:e.dateTime)==null?void 0:s.timeStyle;return{locale:e==null?void 0:e.locale,dateStyle:e==null?void 0:e.dateStyle,dateTime:t===void 0&&a===void 0?void 0:{dateStyle:t,timeStyle:a},defaultCurrency:e==null?void 0:e.defaultCurrency};}function Ut({active:e,onClose:t}){var o,h,w,x,u,b,c;const{preferences:a,isLoading:n,isSaving:s,updatePreferences:i}=Dt({enabled:e});if(!e)return null;if(!a)return/* @__PURE__ */d(M,{children:[/* @__PURE__ */r("div",{className:"py-2",children:/* @__PURE__ */r("div",{className:"flex min-h-36 items-center justify-center text-[12px] text-muted-foreground",children:n?"Loading preferences…":"Preferences unavailable."})}),/* @__PURE__ */d(pe,{className:"justify-between sm:justify-between",children:[/* @__PURE__ */r(z,{variant:"ghost",size:"xs",disabled:!0,children:"Reset display formats"}),/* @__PURE__ */d("div",{className:"flex gap-2",children:[/* @__PURE__ */r(z,{variant:"outline",size:"xs",onClick:t,children:"Cancel"}),/* @__PURE__ */r(z,{size:"xs",disabled:!0,children:"Save"})]})]})]});const l=[((o=a.stored)==null?void 0:o.locale)??"",((h=a.stored)==null?void 0:h.dateStyle)??"",((x=(w=a.stored)==null?void 0:w.dateTime)==null?void 0:x.dateStyle)??"",((b=(u=a.stored)==null?void 0:u.dateTime)==null?void 0:b.timeStyle)??"",((c=a.stored)==null?void 0:c.defaultCurrency)??""].join(":");return/* @__PURE__ */r(Ot,{preferences:a,isSaving:s,updatePreferences:i,onClose:t},l);}function Ot({preferences:e,isSaving:t,updatePreferences:a,onClose:n}){var w,x;const[s,i]=I(()=>Rt(e.stored)),l=(s.locale===void 0||Oe(s.locale)!==void 0)&&(s.defaultCurrency===void 0||qa(s.defaultCurrency)!==void 0)&&(s.dateStyle===void 0||["short","medium","long"].includes(s.dateStyle))&&(((w=s.dateTime)==null?void 0:w.dateStyle)===void 0||["short","medium","long"].includes(s.dateTime.dateStyle))&&(((x=s.dateTime)==null?void 0:x.timeStyle)===void 0||["short","medium","long"].includes(s.dateTime.timeStyle)),o=async()=>{const u={...(s.locale!==void 0?{locale:s.locale}:{}),...(s.dateStyle!==void 0?{dateStyle:s.dateStyle}:{}),...(s.dateTime?{dateTime:{...s.dateTime}}:{}),...(s.defaultCurrency!==void 0?{defaultCurrency:s.defaultCurrency}:{})},b=_e.filter(m=>Pe(s,m)===void 0&&Pe(e.stored,m)!==void 0),c={...(Object.keys(u).length>0?{set:u}:{}),...(b.length>0?{clear:b}:{})};(Object.keys(c).length===0?!0:await a(c))?(O.success("Display format preferences saved."),n()):O.error("Failed to save preferences. Please try again.");},h=async()=>{(await a({clear:[..._e]}))?(O.success("Display format preferences reset."),n()):O.error("Failed to reset display format preferences. Please try again.");};return/* @__PURE__ */d(M,{children:[/* @__PURE__ */r("div",{className:"py-2",children:/* @__PURE__ */r(Lt,{value:s,inherited:e.inherited,inheritedSources:e.inheritedSources,onChange:i,disabled:t})}),/* @__PURE__ */d(pe,{className:"justify-between sm:justify-between",children:[/* @__PURE__ */r(z,{variant:"ghost",size:"xs",onClick:h,disabled:t||e.stored===null,children:"Reset display formats"}),/* @__PURE__ */d("div",{className:"flex gap-2",children:[/* @__PURE__ */r(z,{variant:"outline",size:"xs",onClick:n,disabled:t,children:"Cancel"}),/* @__PURE__ */r(z,{size:"xs",onClick:o,disabled:t||!l,children:t?/* @__PURE__ */d(M,{children:[/* @__PURE__ */r(ze,{className:"h-3.5 w-3.5 animate-spin"}),"Saving…"]}):"Save"})]})]})]});}function er({open:e,onOpenChange:t}){const[a,n]=I("display"),s=()=>t(!1);return/* @__PURE__ */r(ca,{open:e,onOpenChange:t,children:/* @__PURE__ */d(ua,{className:"rounded-control border-border/60 sm:max-w-[440px] sm:rounded-control",children:[/* @__PURE__ */d(ma,{children:[/* @__PURE__ */r(ha,{className:"text-[15px]",children:"Report preferences"}),/* @__PURE__ */r(fa,{className:"text-[13px] leading-5",children:"Set how values and Calendar periods appear for you."})]}),/* @__PURE__ */d(ba,{value:a,onValueChange:n,children:[/* @__PURE__ */d(pa,{variant:"underline",className:"w-full justify-start",children:[/* @__PURE__ */r(Se,{value:"display",children:"Display formats"}),/* @__PURE__ */r(Se,{value:"calendar",children:"Calendar"})]}),/* @__PURE__ */r(we,{value:"display",children:/* @__PURE__ */r(Ut,{active:e&&a==="display",onClose:s})}),/* @__PURE__ */r(we,{value:"calendar",children:/* @__PURE__ */r(kt,{active:e&&a==="calendar",onClose:s})})]})]})});}export{et as A,Qt as D,er as R,Lt as a,dt as b,Yt as c,bt as d,pt as u};
|