react-semaphor 0.1.180 → 0.1.181
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/chunks/{dashboard-controls-CS3pAVZi.js → dashboard-controls-aSc1zv9H.js} +4 -4
- package/dist/chunks/{dashboard-controls-Baw7eUyM.js → dashboard-controls-uTcIgnwr.js} +1 -1
- package/dist/chunks/{dashboard-json-ClalWYi4.js → dashboard-json-4ck1yXt7.js} +1 -1
- package/dist/chunks/{dashboard-json-Cz4bNnCC.js → dashboard-json-Yy1p-xw4.js} +1 -1
- package/dist/chunks/{edit-dashboard-visual-BMElXt-n.js → edit-dashboard-visual-DEedEtg4.js} +1 -1
- package/dist/chunks/{edit-dashboard-visual-DFJ5FJ7y.js → edit-dashboard-visual-K-yosg4h.js} +2 -2
- package/dist/chunks/{editor-action-buttons-MtNYw1Bb.js → editor-action-buttons-D5zidD5p.js} +2 -2
- package/dist/chunks/{editor-action-buttons-DVWnnC_r.js → editor-action-buttons-WLwpPoSo.js} +1 -1
- package/dist/chunks/{index-CAeKp6K8.js → index-TF2KfLGc.js} +4 -4
- package/dist/chunks/{index-CfPKTeUk.js → index-tt1rwTc8.js} +1 -1
- package/dist/chunks/{notification-bell-2dZI5OV0.js → notification-bell-CWYeyuXL.js} +2 -2
- package/dist/chunks/{notification-bell-YZ8VqdwA.js → notification-bell-DNxWG0YY.js} +119 -102
- package/dist/chunks/{resource-management-panel-Buhi-kvP.js → resource-management-panel-CihSUDmt.js} +1 -1
- package/dist/chunks/{resource-management-panel-pxL28GXq.js → resource-management-panel-Dda1VGgq.js} +3 -3
- package/dist/chunks/{use-role-aware-display-preferences-B_i2f9tn.js → use-role-aware-display-preferences-CpROR4Gx.js} +1 -1
- package/dist/chunks/{use-role-aware-display-preferences-JljRcjrP.js → use-role-aware-display-preferences-DgsVnRKz.js} +1 -1
- package/dist/chunks/{use-visual-utils-DPEHcmFT.js → use-visual-utils-BkmyEMSD.js} +1 -1
- package/dist/chunks/{use-visual-utils-D3HjbsKO.js → use-visual-utils-Dwmrgj6E.js} +1 -1
- package/dist/dashboard/index.cjs +1 -1
- package/dist/dashboard/index.js +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.js +5 -5
- package/dist/surfboard/index.cjs +1 -1
- package/dist/surfboard/index.js +1 -1
- package/package.json +1 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";const f=require("react"),t=require("./index-
|
|
1
|
+
"use strict";const f=require("react"),t=require("./index-tt1rwTc8.js"),e=require("react/jsx-runtime"),N=require("./editor-action-buttons-WLwpPoSo.js"),T=require("./use-visual-utils-BkmyEMSD.js"),I=require("./index-8Crk3ROJ.js");/**
|
|
2
2
|
* @license lucide-react v0.453.0 - ISC
|
|
3
3
|
*
|
|
4
4
|
* This source code is licensed under the ISC license.
|
|
@@ -18,4 +18,4 @@
|
|
|
18
18
|
*
|
|
19
19
|
* This source code is licensed under the ISC license.
|
|
20
20
|
* See the LICENSE file in the root directory of this source tree.
|
|
21
|
-
*/const M=t.createLucideIcon("RefreshCw",[["path",{d:"M3 12a9 9 0 0 1 9-9 9.75 9.75 0 0 1 6.74 2.74L21 8",key:"v9h5vc"}],["path",{d:"M21 3v5h-5",key:"1q7to0"}],["path",{d:"M21 12a9 9 0 0 1-9 9 9.75 9.75 0 0 1-6.74-2.74L3 16",key:"3uifl3"}],["path",{d:"M8 16H3v5",key:"1cv678"}]]),R=1e4,B=15e3,z=3e4,O=3e4,$=12e4,U=2*60*60*1e3;function q(s){const r=Date.now()-s.getTime();return r<O?R:r<$?B:z}function H(){const{authToken:s,tokenProps:r}=t.useSemaphorContext(),c=t.useExportStore(v=>v.activeExports),[o,h]=f.useState(typeof document<"u"?!document.hidden:!0),i=f.useRef(null),n=f.useRef(!1),a=f.useRef(void 0),m=r==null?void 0:r.apiServiceUrl,d=s==null?void 0:s.accessToken,g=f.useCallback(()=>{const v=t.useExportStore.getState().activeExports;return Array.from(v.values()).filter(b=>t.isExportInProgress(b.status))},[]);f.useEffect(()=>{if(typeof document>"u")return;const v=()=>{h(!document.hidden)};return document.addEventListener("visibilitychange",v),()=>{document.removeEventListener("visibilitychange",v)}},[]);const C=f.useCallback(async()=>{if(!m||!d){n.current=!1;return}const v=g();if(v.length===0){n.current=!1;return}const b=Date.now(),E=v.filter(x=>b-x.startedAt.getTime()>U);if(E.length>0){const{updateExport:x}=t.useExportStore.getState().actions;for(const l of E)x(l.id,{status:"failed",error:"Export timed out. Please try again or contact support.",lastUpdatedAt:new Date})}const p=v.filter(x=>b-x.startedAt.getTime()<=U);if(p.length===0){n.current=!1;return}const j=await Promise.allSettled(p.map(async x=>{try{const l=await t.getExportStatus(m,d,x.id);let w;if(l.status==="completed")try{w=await t.getDownloadUrl(m,d,x.id)}catch(D){console.error(`[useExportPolling] Failed to get download URL for ${x.id}:`,D)}return{id:x.id,status:l.status,progress:l.progress,completedChunks:l.completedChunks,completedAt:l.completedAt?new Date(l.completedAt):void 0,lastUpdatedAt:new Date,fileSize:l.fileSize,error:l.error,downloadUrl:w}}catch(l){return console.error(`[useExportPolling] Failed to poll export ${x.id}:`,l),null}})),{updateExport:S}=t.useExportStore.getState().actions;for(const x of j)x.status==="fulfilled"&&x.value&&S(x.value.id,x.value);const u=g();if(u.length>0&&!document.hidden){const x=u.reduce((w,D)=>D.startedAt<w?D.startedAt:w,u[0].startedAt),l=q(x);i.current&&clearTimeout(i.current),i.current=setTimeout(()=>{var w;(w=a.current)==null||w.call(a)},l)}else n.current=!1},[m,d,g]);return f.useEffect(()=>{a.current=C},[C]),f.useEffect(()=>{var b;g().length>0&&o&&!n.current&&(n.current=!0,(b=a.current)==null||b.call(a))},[c,o,g]),f.useEffect(()=>{var b;const v=g();o&&v.length>0&&!n.current&&(n.current=!0,(b=a.current)==null||b.call(a))},[o,g]),f.useEffect(()=>{!o&&i.current&&(clearTimeout(i.current),i.current=null,n.current=!1)},[o]),f.useEffect(()=>()=>{i.current&&(clearTimeout(i.current),i.current=null)},[]),{isPolling:n.current,isTabVisible:o,inProgressCount:g().length}}function _(){const{authToken:s,tokenProps:r}=t.useSemaphorContext(),c=t.useExportStore(a=>a.activeExports),{addExport:o}=t.useExportActions(),h=f.useRef(!1),i=r==null?void 0:r.apiServiceUrl,n=s==null?void 0:s.accessToken;f.useEffect(()=>{if(h.current||!i||!n)return;(async()=>{try{const{exports:m}=await t.getExports(i,n,{status:["pending","processing","chunking","compacting","completed","failed"],limit:20});for(const d of m){if(c.has(d.id))continue;const g=d.totalChunks?Math.round(d.completedChunks/d.totalChunks*100):0;let C;if(d.status==="completed")try{C=await t.getDownloadUrl(i,n,d.id)}catch(b){console.error(`[useExportRecovery] Failed to get download URL for ${d.id}:`,b)}const v={id:d.id,status:d.status,progress:g,title:X(d),totalRows:d.totalRows,totalChunks:d.totalChunks,completedChunks:d.completedChunks,startedAt:new Date(d.createdAt),lastUpdatedAt:new Date,completedAt:d.completedAt?new Date(d.completedAt):void 0,fileSize:d.fileSize,error:d.error,expiresAt:new Date(d.expiresAt),downloadUrl:C};o(v)}h.current=!0}catch(m){console.error("[useExportRecovery] Failed to recover exports:",m),h.current=!0}})()},[i,n,o,c])}function X(s){return s.title?s.title:t.isExportInProgress(s.status)?"Export in progress...":s.status==="completed"?"Export completed":s.status==="failed"?"Export failed":"Export"}function G({open:s,onOpenChange:r,isLibraryVisual:c,currentVisualName:o,isSaving:h=!1,onConfirm:i}){const[n,a]=f.useState(c&&o?`Copy of ${o}`:o||""),[m,d]=f.useState(""),[g,C]=f.useState(!c),[v,b]=f.useState(!0);f.useEffect(()=>{s&&(a(c&&o?`Copy of ${o}`:o||""),d(""),C(!c),b(!0))},[s,c,o]);const E=()=>{n.trim()&&(!g&&!v||i({name:n.trim(),description:m.trim()||void 0,saveToLibrary:g,saveToCurrentDashboard:v}))},p=n.trim()&&(g||v);return e.jsx(t.Dialog,{open:s,onOpenChange:r,children:e.jsxs(t.DialogContent,{className:"sm:max-w-[425px]",children:[e.jsxs(t.DialogHeader,{children:[e.jsx(t.DialogTitle,{children:"Save Visual As"}),e.jsx(t.DialogDescription,{children:c?"Create a copy of this visual with a new name":"Save this visual to make it reusable"})]}),e.jsxs("div",{className:"grid gap-4 py-4",children:[e.jsxs("div",{className:"grid gap-2",children:[e.jsx(t.Label,{htmlFor:"name",children:"Name"}),e.jsx(t.Input,{id:"name",value:n,onChange:j=>a(j.target.value),placeholder:"Enter visual name",disabled:h})]}),e.jsxs("div",{className:"grid gap-2",children:[e.jsx(t.Label,{htmlFor:"description",children:"Description (optional)"}),e.jsx(t.Textarea,{id:"description",value:m,onChange:j=>d(j.target.value),placeholder:"Enter visual description",rows:3,disabled:h})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsx(t.Label,{children:"Save to:"}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx(t.Checkbox,{id:"save-to-dashboard",checked:v,onCheckedChange:j=>b(!!j),disabled:h}),e.jsxs("label",{htmlFor:"save-to-dashboard",className:"text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70",children:["Current Dashboard",e.jsx("span",{className:"ml-2 text-xs text-muted-foreground",children:c?"(add copy to this dashboard)":"(keep as local visual)"})]})]}),e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx(t.Checkbox,{id:"save-to-library",checked:g,onCheckedChange:j=>C(!!j),disabled:h}),e.jsxs("label",{htmlFor:"save-to-library",className:"text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70",children:["Visual Library",e.jsx("span",{className:"ml-2 text-xs text-muted-foreground",children:c?"(save as new reusable visual)":"(make available to all dashboards)"})]})]})]}),!g&&!v&&e.jsx("p",{className:"text-sm text-destructive",children:"Please select at least one destination"})]})]}),e.jsxs(t.DialogFooter,{children:[e.jsx(t.Button,{variant:"outline",onClick:()=>r(!1),disabled:h,children:"Cancel"}),e.jsxs(t.Button,{onClick:E,disabled:!p||h,children:[h&&e.jsx(t.LoaderCircle,{className:"mr-2 h-4 w-4 animate-spin"}),h?"Saving...":"Save"]})]})]})})}function W(){const[s,r]=f.useState(!1),[c,o]=f.useState(!1),[h,i]=f.useState(null),n=t.useEditorStore(l=>l.frame),a=t.useEditorStore(l=>l.card),m=t.useSelectedVisual(),d=t.useDashboardStore(l=>l.selectedSheetId),g=t.useDashboardStore(l=>l.actions.setIsDashboardPanelOpen),{getUpdatedFrame:C}=T.useVisualUtils(),{selectVisual:v}=t.useManagementActions(),{addFrame:b,setSelectedFrameId:E,setIsVisualEditing:p}=t.useDashboardActions(),j=!!(n!=null&&n.visualId),S=(()=>{var l,w;return((l=n==null?void 0:n.cards)==null?void 0:l.length)===1&&((w=n.cards[0])!=null&&w.title)?n.cards[0].title:m!=null&&m.title?m.title:(a==null?void 0:a.title)||"Untitled Visual"})(),u=t.useCreateVisualWithFrame(l=>{if(l!=null&&l.id){if(v(l),c&&h&&d){const w={...h,id:t.v4(),visualId:l.id};b(d,w,"end"),E(w.id),o(!1),i(null),p(!1)}g(!0),r(!1)}});return{saveAsDialogOpen:s,setSaveAsDialogOpen:r,handleSaveAs:async l=>{if(!d){t.ue.error("No sheet selected");return}const w=C(),A=w.cards.length===1?{...w,cards:w.cards.map(y=>({...y,title:l.name}))}:w;if(l.saveToLibrary){o(l.saveToCurrentDashboard),i(A);const y={title:l.name,description:l.description,frameObject:A,isPrivate:!1};u.mutate(y)}else if(l.saveToCurrentDashboard){const y={...A,id:t.v4(),visualId:void 0};b(d,y,"end"),E(y.id),t.ue.success("Visual saved to dashboard"),r(!1),p(!1)}},isLibraryVisual:j,currentVisualName:S,isSaving:u.isPending}}function Q({className:s}){const r=t.useEditorStore(u=>u.frame),c=t.useEditorStore(u=>u.card),o=t.useManagementStore(u=>u.selectedVisual),h=t.useDashboardStore(u=>u.selectedFrameId),i=t.useDashboardStore(u=>u.selectedSheetId),{setIsVisualEditing:n}=t.useDashboardActions(),a=!!(r!=null&&r.visualId||o!=null&&o.id),m=!!(r!=null&&r.visualId&&h),d=a&&!m,{saveAsDialogOpen:g,setSaveAsDialogOpen:C,handleSaveAs:v,isLibraryVisual:b,currentVisualName:E,isSaving:p}=W(),{handleAddLibraryVisual:j}=T.useVisualUtils(),S=async()=>{if(!i){t.ue.error("No dashboard sheet selected");return}if(!o){t.ue.error("No visual selected");return}const u=await j(o);u.success?(t.ue.success("Visual added to dashboard"),n(!1)):t.ue.error(u.error||"Failed to add visual to dashboard")};return e.jsxs(e.Fragment,{children:[!a&&e.jsx(N.EditorAcceptButton,{className:s,variant:"default"}),a&&e.jsxs(e.Fragment,{children:[m&&e.jsx(N.VisualApplyLocalButton,{className:s}),d&&i&&c&&(c.sql||t.hasValidCardConfig(c.config))&&e.jsxs(t.Button,{onClick:S,className:t.cn(s),size:"sm",variant:"outline",children:[e.jsx(V,{className:"mr-2 size-4 font-bold"}),"Add to Dashboard"]}),d&&e.jsx(N.VisualSaveButton,{className:s,variant:"default"}),m&&e.jsx(N.VisualSaveAndApplyButton,{className:s}),e.jsxs(t.DropdownMenu,{modal:!1,children:[e.jsx(t.DropdownMenuTrigger,{asChild:!0,children:e.jsx(t.Button,{variant:"outline",size:"sm",className:t.cn(s,"w-8 p-0"),children:e.jsx(t.EllipsisVertical,{className:"h-4 w-4"})})}),e.jsx(t.DropdownMenuContent,{align:"end",children:e.jsxs(t.DropdownMenuItem,{onClick:u=>{u.stopPropagation(),C(!0)},children:[e.jsx(N.Save,{className:"mr-2 h-4 w-4"}),"Save As..."]})})]})]}),!a&&e.jsxs(t.DropdownMenu,{modal:!1,children:[e.jsx(t.DropdownMenuTrigger,{asChild:!0,children:e.jsx(t.Button,{variant:"outline",size:"sm",className:t.cn(s,"w-8 p-0"),children:e.jsx(t.EllipsisVertical,{className:"h-4 w-4"})})}),e.jsx(t.DropdownMenuContent,{align:"end",children:e.jsxs(t.DropdownMenuItem,{onClick:()=>C(!0),children:[e.jsx(N.Save,{className:"mr-2 h-4 w-4"}),"Save As..."]})})]}),e.jsx(N.EditorCancelButton,{className:s}),e.jsx(G,{open:g,onOpenChange:u=>{p||C(u)},isLibraryVisual:b,currentVisualName:E,isSaving:p,onConfirm:v})]})}function Y({className:s,switchClassName:r}){const c=t.useEditorStore(a=>a.isDevMode),o=t.useDashboardStore(a=>a.isVisualEditing),{setIsDevMode:h}=t.useEditorActions(),{config:i}=f.useContext(t.SemaphorContext).tokenProps,n=(i==null?void 0:i.showAdvancedMode)!==!1;return!o||!n?null:e.jsxs("div",{className:t.cn("flex items-center space-x-2",s),children:[e.jsx(t.DevModeSwitch,{className:t.cn("",r),checked:c,onCheckedChange:()=>h(!c),id:"advanced-mode",icon:e.jsx(t.CodeXml,{className:"h-4 w-4"}),tooltip:"Advanced Mode"}),e.jsx("label",{htmlFor:"advanced-mode",className:"sr-only",children:"Advanced Mode"})]})}function Z({open:s,onOpenChange:r,onSave:c,onDiscard:o,isSaving:h}){const i=n=>{!n&&h||r(n)};return e.jsx(t.AlertDialog,{open:s,onOpenChange:i,children:e.jsxs(t.AlertDialogContent,{className:"max-w-md",children:[e.jsxs(t.AlertDialogHeader,{children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"flex h-10 w-10 items-center justify-center rounded-full bg-amber-100",children:e.jsx(t.TriangleAlert,{className:"h-5 w-5 text-amber-600"})}),e.jsx(t.AlertDialogTitle,{className:"text-xl",children:"Unsaved Changes"})]}),e.jsx(t.AlertDialogDescription,{className:"pt-2 text-base leading-relaxed",children:"You have unsaved changes to this dashboard. What would you like to do?"})]}),e.jsxs(t.AlertDialogFooter,{className:"flex-col gap-2 sm:flex-row sm:gap-2",children:[e.jsx(t.AlertDialogCancel,{disabled:h,className:"order-1 m-0 border-border/50 sm:order-1",children:"Cancel"}),e.jsx("button",{onClick:o,disabled:h,className:"order-2 rounded-md border border-destructive/20 bg-destructive/10 px-4 py-2 text-sm font-medium text-destructive transition-colors hover:bg-destructive/20 disabled:pointer-events-none disabled:opacity-50 sm:order-2",children:"Discard"}),e.jsx(t.AlertDialogAction,{onClick:c,disabled:h,className:"order-3 m-0 bg-primary text-primary-foreground hover:bg-primary/90 sm:order-3",children:h?e.jsxs(e.Fragment,{children:[e.jsx(t.LoaderCircle,{className:"mr-2 h-4 w-4 animate-spin"}),"Saving..."]}):"Save & Close"})]})]})})}function J(s,r,c,o){f.useEffect(()=>{s&&!c&&r&&o(t.cloneDeep(r))},[s,c,r,o])}function K({triggerButtonClassName:s}){const[r,c]=f.useState(!1),o=t.useDashboardStore(a=>{var m;return(m=a.dashboard)==null?void 0:m.id}),h=t.useDashboardStore(a=>{var m;return(m=a.dashboard)==null?void 0:m.title}),i=t.useDashboardStore(a=>{var m;return(m=a.dashboard)==null?void 0:m.sheets}),n=t.useDashboardStore(a=>a.selectedSheetId);return i==null||i.find(a=>a.id===n),o?e.jsxs(e.Fragment,{children:[e.jsx(t.IconButton,{tooltip:"Schedule Dashboard",className:t.cn("h-7 p-2",s),onClick:()=>c(!0),children:e.jsx(t.Clock,{className:"size-4"})}),e.jsx(t.EmailScheduleDialog,{open:r,onOpenChange:c,dashboardId:o,dashboardName:h})]}):null}function F({export:s,onRemove:r}){const c=()=>{s.downloadUrl&&window.open(s.downloadUrl,"_blank")},o=a=>{a.stopPropagation(),r==null||r(s.id)},h=()=>{switch(s.status){case"completed":return e.jsx(P,{className:"mt-0.5 h-5 w-5 shrink-0 text-green-600"});case"failed":return e.jsx(N.CircleX,{className:"mt-0.5 h-5 w-5 shrink-0 text-destructive"});default:return e.jsx(t.LoaderCircle,{className:"text-foreground-muted mt-0.5 h-5 w-5 shrink-0 animate-spin"})}},i=t.isExportInProgress(s.status),n=(()=>{switch(s.status){case"pending":return"Queued...";case"processing":return"Processing...";case"chunking":return"Processing...";case"compacting":return"Finalizing...";default:return"Processing..."}})();return e.jsxs("div",{className:"group p-4 transition-colors hover:bg-muted/50",children:[e.jsxs("div",{className:"mb-2 flex items-start justify-between gap-3",children:[e.jsxs("div",{className:"flex min-w-0 flex-1 items-start gap-3",children:[h(),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("h4",{className:"mb-1 truncate text-sm font-medium",children:s.title}),s.status==="completed"&&e.jsxs("div",{className:"flex items-center gap-2 text-xs text-muted-foreground",children:[e.jsxs("span",{children:[s.totalRows.toLocaleString()," rows"]}),s.fileSize&&e.jsxs(e.Fragment,{children:[e.jsx("span",{children:"•"}),e.jsx("span",{children:t.formatFileSize(s.fileSize)})]})]}),i&&e.jsx("div",{className:"text-xs text-muted-foreground",children:n}),s.status==="failed"&&e.jsx("div",{className:"line-clamp-2 text-xs text-destructive",children:s.error||"Export failed"})]})]}),e.jsx(t.Button,{variant:"ghost",size:"icon",className:"h-6 w-6 shrink-0 opacity-0 transition-opacity group-hover:opacity-100",onClick:o,"aria-label":"Remove notification",children:e.jsx(t.X,{className:"h-4 w-4"})})]}),e.jsxs("div",{className:"ml-8",children:[s.status==="completed"&&e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{className:"text-xs text-muted-foreground",children:I.formatDistanceToNow(s.startedAt,{addSuffix:!0})}),s.downloadUrl&&e.jsxs(t.Button,{size:"sm",variant:"outline",className:"h-8 bg-transparent",onClick:c,children:[e.jsx(t.Download,{className:"mr-1.5 h-3.5 w-3.5"}),"Download"]})]}),i&&e.jsxs("div",{children:[e.jsx(t.Progress,{value:s.progress,className:"h-1.5"}),e.jsxs("span",{className:"mt-1 block text-xs text-muted-foreground",children:[s.progress,"% complete"]})]}),s.status==="failed"&&e.jsx("span",{className:"text-xs text-muted-foreground",children:I.formatDistanceToNow(s.startedAt,{addSuffix:!0})})]})]})}function L(){const{authToken:s,tokenProps:r}=t.useSemaphorContext(),c=t.useExportStore(p=>p.activeExports),{clearCompleted:o,removeExport:h,updateExport:i}=t.useExportActions(),[n,a]=f.useState(!1),[m,d]=f.useState(!1),g=Array.from(c.values()).sort((p,j)=>j.startedAt.getTime()-p.startedAt.getTime()),C=g.some(p=>p.status==="completed"||p.status==="failed"),v=f.useCallback(async()=>{const p=r==null?void 0:r.apiServiceUrl,j=s==null?void 0:s.accessToken;if(!(!p||!j)){a(!0);try{const S=Array.from(c.values());await Promise.all(S.map(async u=>{try{const x=await t.getExportStatus(p,j,u.id);let l;if(x.status==="completed")try{l=await t.getDownloadUrl(p,j,u.id)}catch(w){console.error(`Failed to get download URL for ${u.id}:`,w)}i(u.id,{status:x.status,progress:x.progress,completedChunks:x.completedChunks,completedAt:x.completedAt?new Date(x.completedAt):void 0,lastUpdatedAt:new Date,fileSize:x.fileSize,error:x.error,downloadUrl:l})}catch(x){console.error(`Failed to refresh export ${u.id}:`,x)}}))}finally{a(!1)}}},[c,s==null?void 0:s.accessToken,r==null?void 0:r.apiServiceUrl,i]),b=f.useCallback(async()=>{const p=r==null?void 0:r.apiServiceUrl,j=s==null?void 0:s.accessToken;if(!p||!j){o();return}d(!0);try{const S=g.filter(u=>u.status==="completed"||u.status==="failed");await Promise.all(S.map(u=>t.cancelExport(p,j,u.id).catch(x=>console.error(`Failed to delete export ${u.id}:`,x)))),o()}finally{d(!1)}},[g,r==null?void 0:r.apiServiceUrl,s==null?void 0:s.accessToken,o]),E=f.useCallback(async p=>{const j=r==null?void 0:r.apiServiceUrl,S=s==null?void 0:s.accessToken;if(j&&S)try{await t.cancelExport(j,S,p)}catch(u){console.error(`Failed to cancel export ${p}:`,u)}h(p)},[r==null?void 0:r.apiServiceUrl,s==null?void 0:s.accessToken,h]);return g.length===0?e.jsxs("div",{className:"p-6 text-center",children:[e.jsx(k,{className:"h-8 w-8 text-muted-foreground mx-auto mb-2"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"No active exports"}),e.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:"Large exports will appear here"})]}):e.jsxs("div",{className:"flex flex-col",children:[e.jsxs("div",{className:"px-4 py-3 border-b flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(k,{className:"h-5 w-5 text-muted-foreground"}),e.jsx("h4",{className:"font-semibold",children:"Exports"})]}),e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(t.Button,{variant:"ghost",size:"sm",className:"h-7 w-7 p-0",onClick:v,disabled:n,title:"Refresh status",children:e.jsx(M,{className:`h-4 w-4 ${n?"animate-spin":""}`})}),C&&e.jsx(t.Button,{variant:"ghost",size:"sm",className:"h-7 text-sm px-2",onClick:b,disabled:m,children:m?"Clearing...":"Clear all"})]})]}),e.jsx("div",{className:"max-h-[350px] overflow-y-auto",children:e.jsx("div",{className:"divide-y",children:g.map(p=>e.jsx(F,{export:p,onRemove:E},p.id))})}),e.jsxs("div",{className:"px-4 py-2 border-t text-sm text-muted-foreground text-center",children:[g.length," total export",g.length!==1?"s":""]})]})}function ee(){const s=t.useExportStore(a=>a.activeExports),r=t.useInProgressExportsCount(),c=s.size>0,o=Array.from(s.values()).some(a=>a.status==="completed"||a.status==="failed"),i=r>0?r>9?"9+":String(r):null,n=c;return e.jsxs(t.Popover,{children:[e.jsx(t.PopoverTrigger,{asChild:!0,children:e.jsxs(t.Button,{variant:"ghost",size:"icon",className:"relative h-8 w-8","aria-label":"Export notifications",children:[e.jsx(t.Bell,{className:"h-4 w-4"}),n&&e.jsx("span",{className:`absolute flex items-center justify-center rounded-full bg-primary text-primary-foreground ${i?"-right-0.5 -top-0.5 h-4 min-w-4 px-0.5 text-[10px] font-semibold":"right-0.5 top-0.5 h-2 w-2"}`,children:i})]})}),e.jsx(t.PopoverContent,{className:"w-80 p-0",align:"end",sideOffset:8,children:e.jsx(L,{})})]})}exports.AdvancedModeToggle=Y;exports.ExportNotificationItem=F;exports.ExportNotificationList=L;exports.NotificationBell=ee;exports.RefreshCw=M;exports.ScheduleDashboard=K;exports.UnsavedChangesAlert=Z;exports.VisualEditingControls=Q;exports.useExportPolling=H;exports.useExportRecovery=_;exports.usePristineSnapshotInitializer=J;
|
|
21
|
+
*/const M=t.createLucideIcon("RefreshCw",[["path",{d:"M3 12a9 9 0 0 1 9-9 9.75 9.75 0 0 1 6.74 2.74L21 8",key:"v9h5vc"}],["path",{d:"M21 3v5h-5",key:"1q7to0"}],["path",{d:"M21 12a9 9 0 0 1-9 9 9.75 9.75 0 0 1-6.74-2.74L3 16",key:"3uifl3"}],["path",{d:"M8 16H3v5",key:"1cv678"}]]),R=1e4,B=15e3,z=3e4,O=3e4,$=12e4,U=2*60*60*1e3;function q(s){const r=Date.now()-s.getTime();return r<O?R:r<$?B:z}function H(){const{authToken:s,tokenProps:r}=t.useSemaphorContext(),c=t.useExportStore(g=>g.activeExports),[o,h]=f.useState(typeof document<"u"?!document.hidden:!0),i=f.useRef(null),n=f.useRef(!1),a=f.useRef(void 0),m=r==null?void 0:r.apiServiceUrl,d=s==null?void 0:s.accessToken,v=f.useCallback(()=>{const g=t.useExportStore.getState().activeExports;return Array.from(g.values()).filter(b=>t.isExportInProgress(b.status))},[]);f.useEffect(()=>{if(typeof document>"u")return;const g=()=>{h(!document.hidden)};return document.addEventListener("visibilitychange",g),()=>{document.removeEventListener("visibilitychange",g)}},[]);const C=f.useCallback(async()=>{if(!m||!d){n.current=!1;return}const g=v();if(g.length===0){n.current=!1;return}const b=Date.now(),E=g.filter(x=>b-x.startedAt.getTime()>U);if(E.length>0){const{updateExport:x}=t.useExportStore.getState().actions;for(const l of E)x(l.id,{status:"failed",error:"Export timed out. Please try again or contact support.",lastUpdatedAt:new Date})}const p=g.filter(x=>b-x.startedAt.getTime()<=U);if(p.length===0){n.current=!1;return}const j=await Promise.allSettled(p.map(async x=>{try{const l=await t.getExportStatus(m,d,x.id);let w;if(l.status==="completed")try{w=await t.getDownloadUrl(m,d,x.id)}catch(D){console.error(`[useExportPolling] Failed to get download URL for ${x.id}:`,D)}return{id:x.id,status:l.status,progress:l.progress,completedChunks:l.completedChunks,completedAt:l.completedAt?new Date(l.completedAt):void 0,lastUpdatedAt:new Date,fileSize:l.fileSize,error:l.error,downloadUrl:w}}catch(l){return console.error(`[useExportPolling] Failed to poll export ${x.id}:`,l),null}})),{updateExport:S}=t.useExportStore.getState().actions;for(const x of j)x.status==="fulfilled"&&x.value&&S(x.value.id,x.value);const u=v();if(u.length>0&&!document.hidden){const x=u.reduce((w,D)=>D.startedAt<w?D.startedAt:w,u[0].startedAt),l=q(x);i.current&&clearTimeout(i.current),i.current=setTimeout(()=>{var w;(w=a.current)==null||w.call(a)},l)}else n.current=!1},[m,d,v]);return f.useEffect(()=>{a.current=C},[C]),f.useEffect(()=>{var b;v().length>0&&o&&!n.current&&(n.current=!0,(b=a.current)==null||b.call(a))},[c,o,v]),f.useEffect(()=>{var b;const g=v();o&&g.length>0&&!n.current&&(n.current=!0,(b=a.current)==null||b.call(a))},[o,v]),f.useEffect(()=>{!o&&i.current&&(clearTimeout(i.current),i.current=null,n.current=!1)},[o]),f.useEffect(()=>()=>{i.current&&(clearTimeout(i.current),i.current=null)},[]),{isPolling:n.current,isTabVisible:o,inProgressCount:v().length}}function _(){const{authToken:s,tokenProps:r}=t.useSemaphorContext(),c=t.useExportStore(a=>a.activeExports),{addExport:o}=t.useExportActions(),h=f.useRef(!1),i=r==null?void 0:r.apiServiceUrl,n=s==null?void 0:s.accessToken;f.useEffect(()=>{if(h.current||!i||!n)return;(async()=>{try{const{exports:m}=await t.getExports(i,n,{status:["pending","processing","chunking","compacting","completed","failed"],limit:20});for(const d of m){if(c.has(d.id))continue;const v=d.totalChunks?Math.round(d.completedChunks/d.totalChunks*100):0;let C;if(d.status==="completed")try{C=await t.getDownloadUrl(i,n,d.id)}catch(b){console.error(`[useExportRecovery] Failed to get download URL for ${d.id}:`,b)}const g={id:d.id,status:d.status,progress:v,title:X(d),totalRows:d.totalRows,totalChunks:d.totalChunks,completedChunks:d.completedChunks,startedAt:new Date(d.createdAt),lastUpdatedAt:new Date,completedAt:d.completedAt?new Date(d.completedAt):void 0,fileSize:d.fileSize,error:d.error,expiresAt:new Date(d.expiresAt),downloadUrl:C};o(g)}h.current=!0}catch(m){console.error("[useExportRecovery] Failed to recover exports:",m),h.current=!0}})()},[i,n,o,c])}function X(s){return s.title?s.title:t.isExportInProgress(s.status)?"Export in progress...":s.status==="completed"?"Export completed":s.status==="failed"?"Export failed":"Export"}function G({open:s,onOpenChange:r,isLibraryVisual:c,currentVisualName:o,isSaving:h=!1,onConfirm:i}){const[n,a]=f.useState(c&&o?`Copy of ${o}`:o||""),[m,d]=f.useState(""),[v,C]=f.useState(!c),[g,b]=f.useState(!0);f.useEffect(()=>{s&&(a(c&&o?`Copy of ${o}`:o||""),d(""),C(!c),b(!0))},[s,c,o]);const E=()=>{n.trim()&&(!v&&!g||i({name:n.trim(),description:m.trim()||void 0,saveToLibrary:v,saveToCurrentDashboard:g}))},p=n.trim()&&(v||g);return e.jsx(t.Dialog,{open:s,onOpenChange:r,children:e.jsxs(t.DialogContent,{className:"sm:max-w-[425px]",children:[e.jsxs(t.DialogHeader,{children:[e.jsx(t.DialogTitle,{children:"Save Visual As"}),e.jsx(t.DialogDescription,{children:c?"Create a copy of this visual with a new name":"Save this visual to make it reusable"})]}),e.jsxs("div",{className:"grid gap-4 py-4",children:[e.jsxs("div",{className:"grid gap-2",children:[e.jsx(t.Label,{htmlFor:"name",children:"Name"}),e.jsx(t.Input,{id:"name",value:n,onChange:j=>a(j.target.value),placeholder:"Enter visual name",disabled:h})]}),e.jsxs("div",{className:"grid gap-2",children:[e.jsx(t.Label,{htmlFor:"description",children:"Description (optional)"}),e.jsx(t.Textarea,{id:"description",value:m,onChange:j=>d(j.target.value),placeholder:"Enter visual description",rows:3,disabled:h})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsx(t.Label,{children:"Save to:"}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx(t.Checkbox,{id:"save-to-dashboard",checked:g,onCheckedChange:j=>b(!!j),disabled:h}),e.jsxs("label",{htmlFor:"save-to-dashboard",className:"text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70",children:["Current Dashboard",e.jsx("span",{className:"ml-2 text-xs text-muted-foreground",children:c?"(add copy to this dashboard)":"(keep as local visual)"})]})]}),e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx(t.Checkbox,{id:"save-to-library",checked:v,onCheckedChange:j=>C(!!j),disabled:h}),e.jsxs("label",{htmlFor:"save-to-library",className:"text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70",children:["Visual Library",e.jsx("span",{className:"ml-2 text-xs text-muted-foreground",children:c?"(save as new reusable visual)":"(make available to all dashboards)"})]})]})]}),!v&&!g&&e.jsx("p",{className:"text-sm text-destructive",children:"Please select at least one destination"})]})]}),e.jsxs(t.DialogFooter,{children:[e.jsx(t.Button,{variant:"outline",onClick:()=>r(!1),disabled:h,children:"Cancel"}),e.jsxs(t.Button,{onClick:E,disabled:!p||h,children:[h&&e.jsx(t.LoaderCircle,{className:"mr-2 h-4 w-4 animate-spin"}),h?"Saving...":"Save"]})]})]})})}function W(){const[s,r]=f.useState(!1),[c,o]=f.useState(!1),[h,i]=f.useState(null),n=t.useEditorStore(l=>l.frame),a=t.useEditorStore(l=>l.card),m=t.useSelectedVisual(),d=t.useDashboardStore(l=>l.selectedSheetId),v=t.useDashboardStore(l=>l.actions.setIsDashboardPanelOpen),{getUpdatedFrame:C}=T.useVisualUtils(),{selectVisual:g}=t.useManagementActions(),{addFrame:b,setSelectedFrameId:E,setIsVisualEditing:p}=t.useDashboardActions(),j=!!(n!=null&&n.visualId),S=(()=>{var l,w;return((l=n==null?void 0:n.cards)==null?void 0:l.length)===1&&((w=n.cards[0])!=null&&w.title)?n.cards[0].title:m!=null&&m.title?m.title:(a==null?void 0:a.title)||"Untitled Visual"})(),u=t.useCreateVisualWithFrame(l=>{if(l!=null&&l.id){if(g(l),c&&h&&d){const w={...h,id:t.v4(),visualId:l.id};b(d,w,"end"),E(w.id),o(!1),i(null),p(!1)}v(!0),r(!1)}});return{saveAsDialogOpen:s,setSaveAsDialogOpen:r,handleSaveAs:async l=>{if(!d){t.ue.error("No sheet selected");return}const w=C(),A=w.cards.length===1?{...w,cards:w.cards.map(y=>({...y,title:l.name}))}:w;if(l.saveToLibrary){o(l.saveToCurrentDashboard),i(A);const y={title:l.name,description:l.description,frameObject:A,isPrivate:!1};u.mutate(y)}else if(l.saveToCurrentDashboard){const y={...A,id:t.v4(),visualId:void 0};b(d,y,"end"),E(y.id),t.ue.success("Visual saved to dashboard"),r(!1),p(!1)}},isLibraryVisual:j,currentVisualName:S,isSaving:u.isPending}}function Q({className:s}){const r=t.useEditorStore(u=>u.frame),c=t.useEditorStore(u=>u.card),o=t.useManagementStore(u=>u.selectedVisual),h=t.useDashboardStore(u=>u.selectedFrameId),i=t.useDashboardStore(u=>u.selectedSheetId),{setIsVisualEditing:n}=t.useDashboardActions(),a=!!(r!=null&&r.visualId||o!=null&&o.id),m=!!(r!=null&&r.visualId&&h),d=a&&!m,{saveAsDialogOpen:v,setSaveAsDialogOpen:C,handleSaveAs:g,isLibraryVisual:b,currentVisualName:E,isSaving:p}=W(),{handleAddLibraryVisual:j}=T.useVisualUtils(),S=async()=>{if(!i){t.ue.error("No dashboard sheet selected");return}if(!o){t.ue.error("No visual selected");return}const u=await j(o);u.success?(t.ue.success("Visual added to dashboard"),n(!1)):t.ue.error(u.error||"Failed to add visual to dashboard")};return e.jsxs(e.Fragment,{children:[!a&&e.jsx(N.EditorAcceptButton,{className:s,variant:"default"}),a&&e.jsxs(e.Fragment,{children:[m&&e.jsx(N.VisualApplyLocalButton,{className:s}),d&&i&&c&&(c.sql||t.hasValidCardConfig(c.config))&&e.jsxs(t.Button,{onClick:S,className:t.cn(s),size:"sm",variant:"outline",children:[e.jsx(V,{className:"mr-2 size-4 font-bold"}),"Add to Dashboard"]}),d&&e.jsx(N.VisualSaveButton,{className:s,variant:"default"}),m&&e.jsx(N.VisualSaveAndApplyButton,{className:s}),e.jsxs(t.DropdownMenu,{modal:!1,children:[e.jsx(t.DropdownMenuTrigger,{asChild:!0,children:e.jsx(t.Button,{variant:"outline",size:"sm",className:t.cn(s,"w-8 p-0"),children:e.jsx(t.EllipsisVertical,{className:"h-4 w-4"})})}),e.jsx(t.DropdownMenuContent,{align:"end",children:e.jsxs(t.DropdownMenuItem,{onClick:u=>{u.stopPropagation(),C(!0)},children:[e.jsx(N.Save,{className:"mr-2 h-4 w-4"}),"Save As..."]})})]})]}),!a&&e.jsxs(t.DropdownMenu,{modal:!1,children:[e.jsx(t.DropdownMenuTrigger,{asChild:!0,children:e.jsx(t.Button,{variant:"outline",size:"sm",className:t.cn(s,"w-8 p-0"),children:e.jsx(t.EllipsisVertical,{className:"h-4 w-4"})})}),e.jsx(t.DropdownMenuContent,{align:"end",children:e.jsxs(t.DropdownMenuItem,{onClick:()=>C(!0),children:[e.jsx(N.Save,{className:"mr-2 h-4 w-4"}),"Save As..."]})})]}),e.jsx(N.EditorCancelButton,{className:s}),e.jsx(G,{open:v,onOpenChange:u=>{p||C(u)},isLibraryVisual:b,currentVisualName:E,isSaving:p,onConfirm:g})]})}function Y({className:s,switchClassName:r}){const c=t.useEditorStore(a=>a.isDevMode),o=t.useDashboardStore(a=>a.isVisualEditing),{setIsDevMode:h}=t.useEditorActions(),{config:i}=f.useContext(t.SemaphorContext).tokenProps,n=(i==null?void 0:i.showAdvancedMode)!==!1;return!o||!n?null:e.jsxs("div",{className:t.cn("flex items-center space-x-2",s),children:[e.jsx(t.DevModeSwitch,{className:t.cn("",r),checked:c,onCheckedChange:()=>h(!c),id:"advanced-mode",icon:e.jsx(t.CodeXml,{className:"h-4 w-4"}),tooltip:"Advanced Mode"}),e.jsx("label",{htmlFor:"advanced-mode",className:"sr-only",children:"Advanced Mode"})]})}function Z({open:s,onOpenChange:r,onSave:c,onDiscard:o,isSaving:h}){const i=n=>{!n&&h||r(n)};return e.jsx(t.AlertDialog,{open:s,onOpenChange:i,children:e.jsxs(t.AlertDialogContent,{className:"max-w-md",children:[e.jsxs(t.AlertDialogHeader,{children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"flex h-10 w-10 items-center justify-center rounded-full bg-amber-100",children:e.jsx(t.TriangleAlert,{className:"h-5 w-5 text-amber-600"})}),e.jsx(t.AlertDialogTitle,{className:"text-xl",children:"Unsaved Changes"})]}),e.jsx(t.AlertDialogDescription,{className:"pt-2 text-base leading-relaxed",children:"You have unsaved changes to this dashboard. What would you like to do?"})]}),e.jsxs(t.AlertDialogFooter,{className:"flex-col gap-2 sm:flex-row sm:gap-2",children:[e.jsx(t.AlertDialogCancel,{disabled:h,className:"order-1 m-0 border-border/50 sm:order-1",children:"Cancel"}),e.jsx("button",{onClick:o,disabled:h,className:"order-2 rounded-md border border-destructive/20 bg-destructive/10 px-4 py-2 text-sm font-medium text-destructive transition-colors hover:bg-destructive/20 disabled:pointer-events-none disabled:opacity-50 sm:order-2",children:"Discard"}),e.jsx(t.AlertDialogAction,{onClick:c,disabled:h,className:"order-3 m-0 bg-primary text-primary-foreground hover:bg-primary/90 sm:order-3",children:h?e.jsxs(e.Fragment,{children:[e.jsx(t.LoaderCircle,{className:"mr-2 h-4 w-4 animate-spin"}),"Saving..."]}):"Save & Close"})]})]})})}function J(s,r,c,o){f.useEffect(()=>{s&&!c&&r&&o(t.cloneDeep(r))},[s,c,r,o])}function K({triggerButtonClassName:s}){const[r,c]=f.useState(!1),o=t.useDashboardStore(a=>{var m;return(m=a.dashboard)==null?void 0:m.id}),h=t.useDashboardStore(a=>{var m;return(m=a.dashboard)==null?void 0:m.title}),i=t.useDashboardStore(a=>{var m;return(m=a.dashboard)==null?void 0:m.sheets}),n=t.useDashboardStore(a=>a.selectedSheetId);return i==null||i.find(a=>a.id===n),o?e.jsxs(e.Fragment,{children:[e.jsx(t.IconButton,{tooltip:"Schedule Dashboard",className:t.cn("h-7 p-2",s),onClick:()=>c(!0),children:e.jsx(t.Clock,{className:"size-4"})}),e.jsx(t.EmailScheduleDialog,{open:r,onOpenChange:c,dashboardId:o,dashboardName:h})]}):null}function F({export:s,onRemove:r}){const c=()=>{s.downloadUrl&&window.open(s.downloadUrl,"_blank")},o=a=>{a.stopPropagation(),r==null||r(s.id)},h=()=>{switch(s.status){case"completed":return e.jsx(P,{className:"mt-0.5 h-5 w-5 shrink-0 text-green-600"});case"failed":return e.jsx(N.CircleX,{className:"mt-0.5 h-5 w-5 shrink-0 text-destructive"});default:return e.jsx(t.LoaderCircle,{className:"text-foreground-muted mt-0.5 h-5 w-5 shrink-0 animate-spin"})}},i=t.isExportInProgress(s.status),n=(()=>{switch(s.status){case"pending":return"Queued...";case"processing":return"Processing...";case"chunking":return"Processing...";case"compacting":return"Finalizing...";default:return"Processing..."}})();return e.jsxs("div",{className:"group p-4 transition-colors hover:bg-muted/50",children:[e.jsxs("div",{className:"mb-2 flex items-start justify-between gap-3",children:[e.jsxs("div",{className:"flex min-w-0 flex-1 items-start gap-3",children:[h(),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("h4",{className:"mb-1 truncate text-sm font-medium",children:s.title}),s.status==="completed"&&e.jsxs("div",{className:"flex items-center gap-2 text-xs text-muted-foreground",children:[e.jsxs("span",{children:[s.totalRows.toLocaleString()," rows"]}),s.fileSize&&e.jsxs(e.Fragment,{children:[e.jsx("span",{children:"•"}),e.jsx("span",{children:t.formatFileSize(s.fileSize)})]})]}),i&&e.jsx("div",{className:"text-xs text-muted-foreground",children:n}),s.status==="failed"&&e.jsx("div",{className:"line-clamp-2 text-xs text-destructive",children:s.error||"Export failed"})]})]}),e.jsx(t.Button,{variant:"ghost",size:"icon",className:"h-6 w-6 shrink-0 opacity-0 transition-opacity group-hover:opacity-100",onClick:o,"aria-label":"Remove notification",children:e.jsx(t.X,{className:"h-4 w-4"})})]}),e.jsxs("div",{className:"ml-8",children:[s.status==="completed"&&e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{className:"text-xs text-muted-foreground",children:I.formatDistanceToNow(s.startedAt,{addSuffix:!0})}),s.downloadUrl&&e.jsxs(t.Button,{size:"sm",variant:"outline",className:"h-8 bg-transparent",onClick:c,children:[e.jsx(t.Download,{className:"mr-1.5 h-3.5 w-3.5"}),"Download"]})]}),i&&e.jsxs("div",{children:[e.jsx(t.Progress,{value:s.progress,className:"h-1.5"}),e.jsxs("span",{className:"mt-1 block text-xs text-muted-foreground",children:[s.progress,"% complete"]})]}),s.status==="failed"&&e.jsx("span",{className:"text-xs text-muted-foreground",children:I.formatDistanceToNow(s.startedAt,{addSuffix:!0})})]})]})}function L(){const{authToken:s,tokenProps:r}=t.useSemaphorContext(),c=t.useExportStore(p=>p.activeExports),{clearCompleted:o,removeExport:h,updateExport:i}=t.useExportActions(),[n,a]=f.useState(!1),[m,d]=f.useState(!1),v=Array.from(c.values()).sort((p,j)=>j.startedAt.getTime()-p.startedAt.getTime()),C=v.some(p=>p.status==="completed"||p.status==="failed"),g=f.useCallback(async()=>{const p=r==null?void 0:r.apiServiceUrl,j=s==null?void 0:s.accessToken;if(!(!p||!j)){a(!0);try{const S=Array.from(c.values());await Promise.all(S.map(async u=>{try{const x=await t.getExportStatus(p,j,u.id);let l;if(x.status==="completed")try{l=await t.getDownloadUrl(p,j,u.id)}catch(w){console.error(`Failed to get download URL for ${u.id}:`,w)}i(u.id,{status:x.status,progress:x.progress,completedChunks:x.completedChunks,completedAt:x.completedAt?new Date(x.completedAt):void 0,lastUpdatedAt:new Date,fileSize:x.fileSize,error:x.error,downloadUrl:l})}catch(x){console.error(`Failed to refresh export ${u.id}:`,x)}}))}finally{a(!1)}}},[c,s==null?void 0:s.accessToken,r==null?void 0:r.apiServiceUrl,i]),b=f.useCallback(async()=>{const p=r==null?void 0:r.apiServiceUrl,j=s==null?void 0:s.accessToken;if(!p||!j){o();return}d(!0);try{const S=v.filter(u=>u.status==="completed"||u.status==="failed");await Promise.all(S.map(u=>t.cancelExport(p,j,u.id).catch(x=>console.error(`Failed to delete export ${u.id}:`,x)))),o()}finally{d(!1)}},[v,r==null?void 0:r.apiServiceUrl,s==null?void 0:s.accessToken,o]),E=f.useCallback(async p=>{const j=r==null?void 0:r.apiServiceUrl,S=s==null?void 0:s.accessToken;if(j&&S)try{await t.cancelExport(j,S,p)}catch(u){console.error(`Failed to cancel export ${p}:`,u)}h(p)},[r==null?void 0:r.apiServiceUrl,s==null?void 0:s.accessToken,h]);return v.length===0?e.jsxs("div",{className:"p-6 text-center",children:[e.jsx(k,{className:"mx-auto mb-2 h-8 w-8 text-muted-foreground"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"No active exports"}),e.jsx("p",{className:"mt-1 text-xs text-muted-foreground",children:"Large exports will appear here"})]}):e.jsxs("div",{className:"flex flex-col",children:[e.jsxs("div",{className:"flex items-center justify-between border-b px-4 py-3",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(k,{className:"h-5 w-5 text-muted-foreground"}),e.jsx("h4",{className:"font-semibold",children:"Exports"})]}),e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(t.Button,{variant:"ghost",size:"sm",className:"h-7 w-7 p-0",onClick:g,disabled:n,title:"Refresh status",children:e.jsx(M,{className:`h-4 w-4 ${n?"animate-spin":""}`})}),C&&e.jsx(t.Button,{variant:"ghost",size:"sm",className:"h-7 px-2 text-sm",onClick:b,disabled:m,children:m?"Clearing...":"Clear all"})]})]}),e.jsx("div",{className:"max-h-[350px] overflow-y-auto",children:e.jsx("div",{className:"divide-y",children:v.map(p=>e.jsx(F,{export:p,onRemove:E},p.id))})})]})}function ee(){const s=t.useExportStore(a=>a.activeExports),r=t.useInProgressExportsCount(),c=s.size>0,o=Array.from(s.values()).some(a=>a.status==="completed"||a.status==="failed"),i=r>0?r>9?"9+":String(r):null,n=c;return e.jsxs(t.Popover,{children:[e.jsx(t.PopoverTrigger,{asChild:!0,children:e.jsxs(t.Button,{variant:"ghost",size:"icon",className:"relative h-8 w-8","aria-label":"Export notifications",children:[e.jsx(t.Bell,{className:"h-4 w-4"}),n&&e.jsx("span",{className:`absolute flex items-center justify-center rounded-full bg-primary text-primary-foreground ${i?"-right-0.5 -top-0.5 h-4 min-w-4 px-0.5 text-[10px] font-semibold":"right-0.5 top-0.5 h-2 w-2"}`,children:i})]})}),e.jsx(t.PopoverContent,{className:"w-80 p-0",align:"end",sideOffset:8,children:e.jsx(L,{})})]})}exports.AdvancedModeToggle=Y;exports.ExportNotificationItem=F;exports.ExportNotificationList=L;exports.NotificationBell=ee;exports.RefreshCw=M;exports.ScheduleDashboard=K;exports.UnsavedChangesAlert=Z;exports.VisualEditingControls=Q;exports.useExportPolling=H;exports.useExportRecovery=_;exports.usePristineSnapshotInitializer=J;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import oe, { useState as A, useRef as V, useCallback as M, useEffect as D, useContext as ie } from "react";
|
|
2
|
-
import { aF as z, aN as B, a0 as I, aC as $, ay as ae, az as _, a1 as se, ax as le, bu as ce, bv as de, bw as ue, bx as me, by as he, bz as O, bA as pe, bG as fe, bH as j, bB as ge, B as S, aG as H, au as P, aI as ve, u as E, aO as
|
|
2
|
+
import { aF as z, aN as B, a0 as I, aC as $, ay as ae, az as _, a1 as se, ax as le, bu as ce, bv as de, bw as ue, bx as me, by as he, bz as O, bA as pe, bG as fe, bH as j, bB as ge, B as S, aG as H, au as P, aI as ve, u as E, aO as be, as as re, bI as xe, bJ as G, aL as T, A as we, bK as Ce, c as U, aV as X, aW as q, aX as W, aY as Q, aZ as Y, av as Ne, bL as ye, bM as Ae, bN as Se, bb as Ee, bc as De, bd as Ie, bO as ke, be as Te, bf as Ue, bg as Fe, bh as Me, bi as Pe, W as Le, I as Ve, bP as ze, bQ as Re, aE as Oe, X as Be, bR as $e, bS as _e, aA as Z, a3 as He, P as je, p as Ge, bT as Xe, r as qe } from "./index-TF2KfLGc.js";
|
|
3
3
|
import { jsx as t, jsxs as r, Fragment as L } from "react/jsx-runtime";
|
|
4
|
-
import { E as We, V as Qe, a as Ye, b as Ze, S as J, c as Je, C as Ke } from "./editor-action-buttons-
|
|
5
|
-
import { a as ne } from "./use-visual-utils-
|
|
4
|
+
import { E as We, V as Qe, a as Ye, b as Ze, S as J, c as Je, C as Ke } from "./editor-action-buttons-D5zidD5p.js";
|
|
5
|
+
import { a as ne } from "./use-visual-utils-Dwmrgj6E.js";
|
|
6
6
|
import { a as K } from "./index-B4EhQdS9.js";
|
|
7
7
|
/**
|
|
8
8
|
* @license lucide-react v0.453.0 - ISC
|
|
@@ -54,21 +54,21 @@ function lt(e) {
|
|
|
54
54
|
return a < ot ? st : a < it ? rt : nt;
|
|
55
55
|
}
|
|
56
56
|
function wt() {
|
|
57
|
-
const { authToken: e, tokenProps: a } = B(), c = I((
|
|
57
|
+
const { authToken: e, tokenProps: a } = B(), c = I((g) => g.activeExports), [n, m] = A(
|
|
58
58
|
typeof document < "u" ? !document.hidden : !0
|
|
59
|
-
), l = V(null), o = V(!1), s = V(void 0), h = a == null ? void 0 : a.apiServiceUrl, d = e == null ? void 0 : e.accessToken,
|
|
60
|
-
const
|
|
61
|
-
return Array.from(
|
|
62
|
-
(
|
|
59
|
+
), l = V(null), o = V(!1), s = V(void 0), h = a == null ? void 0 : a.apiServiceUrl, d = e == null ? void 0 : e.accessToken, v = M(() => {
|
|
60
|
+
const g = I.getState().activeExports;
|
|
61
|
+
return Array.from(g.values()).filter(
|
|
62
|
+
(x) => $(x.status)
|
|
63
63
|
);
|
|
64
64
|
}, []);
|
|
65
65
|
D(() => {
|
|
66
66
|
if (typeof document > "u") return;
|
|
67
|
-
const
|
|
67
|
+
const g = () => {
|
|
68
68
|
m(!document.hidden);
|
|
69
69
|
};
|
|
70
|
-
return document.addEventListener("visibilitychange",
|
|
71
|
-
document.removeEventListener("visibilitychange",
|
|
70
|
+
return document.addEventListener("visibilitychange", g), () => {
|
|
71
|
+
document.removeEventListener("visibilitychange", g);
|
|
72
72
|
};
|
|
73
73
|
}, []);
|
|
74
74
|
const C = M(async () => {
|
|
@@ -76,13 +76,13 @@ function wt() {
|
|
|
76
76
|
o.current = !1;
|
|
77
77
|
return;
|
|
78
78
|
}
|
|
79
|
-
const
|
|
80
|
-
if (
|
|
79
|
+
const g = v();
|
|
80
|
+
if (g.length === 0) {
|
|
81
81
|
o.current = !1;
|
|
82
82
|
return;
|
|
83
83
|
}
|
|
84
|
-
const
|
|
85
|
-
(p) =>
|
|
84
|
+
const x = Date.now(), y = g.filter(
|
|
85
|
+
(p) => x - p.startedAt.getTime() > te
|
|
86
86
|
);
|
|
87
87
|
if (y.length > 0) {
|
|
88
88
|
const { updateExport: p } = I.getState().actions;
|
|
@@ -93,14 +93,14 @@ function wt() {
|
|
|
93
93
|
lastUpdatedAt: /* @__PURE__ */ new Date()
|
|
94
94
|
});
|
|
95
95
|
}
|
|
96
|
-
const f =
|
|
97
|
-
(p) =>
|
|
96
|
+
const f = g.filter(
|
|
97
|
+
(p) => x - p.startedAt.getTime() <= te
|
|
98
98
|
);
|
|
99
99
|
if (f.length === 0) {
|
|
100
100
|
o.current = !1;
|
|
101
101
|
return;
|
|
102
102
|
}
|
|
103
|
-
const
|
|
103
|
+
const b = await Promise.allSettled(
|
|
104
104
|
f.map(async (p) => {
|
|
105
105
|
try {
|
|
106
106
|
const i = await ae(h, d, p.id);
|
|
@@ -133,9 +133,9 @@ function wt() {
|
|
|
133
133
|
}
|
|
134
134
|
})
|
|
135
135
|
), { updateExport: N } = I.getState().actions;
|
|
136
|
-
for (const p of
|
|
136
|
+
for (const p of b)
|
|
137
137
|
p.status === "fulfilled" && p.value && N(p.value.id, p.value);
|
|
138
|
-
const u =
|
|
138
|
+
const u = v();
|
|
139
139
|
if (u.length > 0 && !document.hidden) {
|
|
140
140
|
const p = u.reduce(
|
|
141
141
|
(w, F) => F.startedAt < w ? F.startedAt : w,
|
|
@@ -147,24 +147,24 @@ function wt() {
|
|
|
147
147
|
}, i);
|
|
148
148
|
} else
|
|
149
149
|
o.current = !1;
|
|
150
|
-
}, [h, d,
|
|
150
|
+
}, [h, d, v]);
|
|
151
151
|
return D(() => {
|
|
152
152
|
s.current = C;
|
|
153
153
|
}, [C]), D(() => {
|
|
154
|
-
var
|
|
155
|
-
|
|
156
|
-
}, [c, n,
|
|
157
|
-
var
|
|
158
|
-
const
|
|
159
|
-
n &&
|
|
160
|
-
}, [n,
|
|
154
|
+
var x;
|
|
155
|
+
v().length > 0 && n && !o.current && (o.current = !0, (x = s.current) == null || x.call(s));
|
|
156
|
+
}, [c, n, v]), D(() => {
|
|
157
|
+
var x;
|
|
158
|
+
const g = v();
|
|
159
|
+
n && g.length > 0 && !o.current && (o.current = !0, (x = s.current) == null || x.call(s));
|
|
160
|
+
}, [n, v]), D(() => {
|
|
161
161
|
!n && l.current && (clearTimeout(l.current), l.current = null, o.current = !1);
|
|
162
162
|
}, [n]), D(() => () => {
|
|
163
163
|
l.current && (clearTimeout(l.current), l.current = null);
|
|
164
164
|
}, []), {
|
|
165
165
|
isPolling: o.current,
|
|
166
166
|
isTabVisible: n,
|
|
167
|
-
inProgressCount:
|
|
167
|
+
inProgressCount: v().length
|
|
168
168
|
};
|
|
169
169
|
}
|
|
170
170
|
function Ct() {
|
|
@@ -180,21 +180,21 @@ function Ct() {
|
|
|
180
180
|
});
|
|
181
181
|
for (const d of h) {
|
|
182
182
|
if (c.has(d.id)) continue;
|
|
183
|
-
const
|
|
183
|
+
const v = d.totalChunks ? Math.round(d.completedChunks / d.totalChunks * 100) : 0;
|
|
184
184
|
let C;
|
|
185
185
|
if (d.status === "completed")
|
|
186
186
|
try {
|
|
187
187
|
C = await _(l, o, d.id);
|
|
188
|
-
} catch (
|
|
188
|
+
} catch (x) {
|
|
189
189
|
console.error(
|
|
190
190
|
`[useExportRecovery] Failed to get download URL for ${d.id}:`,
|
|
191
|
-
|
|
191
|
+
x
|
|
192
192
|
);
|
|
193
193
|
}
|
|
194
|
-
const
|
|
194
|
+
const g = {
|
|
195
195
|
id: d.id,
|
|
196
196
|
status: d.status,
|
|
197
|
-
progress:
|
|
197
|
+
progress: v,
|
|
198
198
|
title: ct(d),
|
|
199
199
|
totalRows: d.totalRows,
|
|
200
200
|
totalChunks: d.totalChunks,
|
|
@@ -207,7 +207,7 @@ function Ct() {
|
|
|
207
207
|
expiresAt: new Date(d.expiresAt),
|
|
208
208
|
downloadUrl: C
|
|
209
209
|
};
|
|
210
|
-
n(
|
|
210
|
+
n(g);
|
|
211
211
|
}
|
|
212
212
|
m.current = !0;
|
|
213
213
|
} catch (h) {
|
|
@@ -231,20 +231,20 @@ function dt({
|
|
|
231
231
|
}) {
|
|
232
232
|
const [o, s] = A(
|
|
233
233
|
c && n ? `Copy of ${n}` : n || ""
|
|
234
|
-
), [h, d] = A(""), [
|
|
234
|
+
), [h, d] = A(""), [v, C] = A(!c), [g, x] = A(!0);
|
|
235
235
|
oe.useEffect(() => {
|
|
236
236
|
e && (s(
|
|
237
237
|
c && n ? `Copy of ${n}` : n || ""
|
|
238
|
-
), d(""), C(!c),
|
|
238
|
+
), d(""), C(!c), x(!0));
|
|
239
239
|
}, [e, c, n]);
|
|
240
240
|
const y = () => {
|
|
241
|
-
o.trim() && (!
|
|
241
|
+
o.trim() && (!v && !g || l({
|
|
242
242
|
name: o.trim(),
|
|
243
243
|
description: h.trim() || void 0,
|
|
244
|
-
saveToLibrary:
|
|
245
|
-
saveToCurrentDashboard:
|
|
244
|
+
saveToLibrary: v,
|
|
245
|
+
saveToCurrentDashboard: g
|
|
246
246
|
}));
|
|
247
|
-
}, f = o.trim() && (
|
|
247
|
+
}, f = o.trim() && (v || g);
|
|
248
248
|
return /* @__PURE__ */ t(ce, { open: e, onOpenChange: a, children: /* @__PURE__ */ r(de, { className: "sm:max-w-[425px]", children: [
|
|
249
249
|
/* @__PURE__ */ r(ue, { children: [
|
|
250
250
|
/* @__PURE__ */ t(me, { children: "Save Visual As" }),
|
|
@@ -258,7 +258,7 @@ function dt({
|
|
|
258
258
|
{
|
|
259
259
|
id: "name",
|
|
260
260
|
value: o,
|
|
261
|
-
onChange: (
|
|
261
|
+
onChange: (b) => s(b.target.value),
|
|
262
262
|
placeholder: "Enter visual name",
|
|
263
263
|
disabled: m
|
|
264
264
|
}
|
|
@@ -271,7 +271,7 @@ function dt({
|
|
|
271
271
|
{
|
|
272
272
|
id: "description",
|
|
273
273
|
value: h,
|
|
274
|
-
onChange: (
|
|
274
|
+
onChange: (b) => d(b.target.value),
|
|
275
275
|
placeholder: "Enter visual description",
|
|
276
276
|
rows: 3,
|
|
277
277
|
disabled: m
|
|
@@ -286,8 +286,8 @@ function dt({
|
|
|
286
286
|
j,
|
|
287
287
|
{
|
|
288
288
|
id: "save-to-dashboard",
|
|
289
|
-
checked:
|
|
290
|
-
onCheckedChange: (
|
|
289
|
+
checked: g,
|
|
290
|
+
onCheckedChange: (b) => x(!!b),
|
|
291
291
|
disabled: m
|
|
292
292
|
}
|
|
293
293
|
),
|
|
@@ -308,8 +308,8 @@ function dt({
|
|
|
308
308
|
j,
|
|
309
309
|
{
|
|
310
310
|
id: "save-to-library",
|
|
311
|
-
checked:
|
|
312
|
-
onCheckedChange: (
|
|
311
|
+
checked: v,
|
|
312
|
+
onCheckedChange: (b) => C(!!b),
|
|
313
313
|
disabled: m
|
|
314
314
|
}
|
|
315
315
|
),
|
|
@@ -326,7 +326,7 @@ function dt({
|
|
|
326
326
|
)
|
|
327
327
|
] })
|
|
328
328
|
] }),
|
|
329
|
-
!
|
|
329
|
+
!v && !g && /* @__PURE__ */ t("p", { className: "text-sm text-destructive", children: "Please select at least one destination" })
|
|
330
330
|
] })
|
|
331
331
|
] }),
|
|
332
332
|
/* @__PURE__ */ r(ge, { children: [
|
|
@@ -347,23 +347,23 @@ function dt({
|
|
|
347
347
|
] }) });
|
|
348
348
|
}
|
|
349
349
|
function ut() {
|
|
350
|
-
const [e, a] = A(!1), [c, n] = A(!1), [m, l] = A(null), o = P((i) => i.frame), s = P((i) => i.card), h = ve(), d = E((i) => i.selectedSheetId),
|
|
350
|
+
const [e, a] = A(!1), [c, n] = A(!1), [m, l] = A(null), o = P((i) => i.frame), s = P((i) => i.card), h = ve(), d = E((i) => i.selectedSheetId), v = E(
|
|
351
351
|
(i) => i.actions.setIsDashboardPanelOpen
|
|
352
|
-
), { getUpdatedFrame: C } = ne(), { selectVisual:
|
|
352
|
+
), { getUpdatedFrame: C } = ne(), { selectVisual: g } = be(), { addFrame: x, setSelectedFrameId: y, setIsVisualEditing: f } = re(), b = !!(o != null && o.visualId), N = (() => {
|
|
353
353
|
var i, w;
|
|
354
354
|
return ((i = o == null ? void 0 : o.cards) == null ? void 0 : i.length) === 1 && ((w = o.cards[0]) != null && w.title) ? o.cards[0].title : h != null && h.title ? h.title : (s == null ? void 0 : s.title) || "Untitled Visual";
|
|
355
|
-
})(), u =
|
|
355
|
+
})(), u = xe((i) => {
|
|
356
356
|
if (i != null && i.id) {
|
|
357
|
-
if (
|
|
357
|
+
if (g(i), c && m && d) {
|
|
358
358
|
const w = {
|
|
359
359
|
...m,
|
|
360
360
|
id: G(),
|
|
361
361
|
visualId: i.id
|
|
362
362
|
// Link to the newly created library visual
|
|
363
363
|
};
|
|
364
|
-
|
|
364
|
+
x(d, w, "end"), y(w.id), n(!1), l(null), f(!1);
|
|
365
365
|
}
|
|
366
|
-
|
|
366
|
+
v(!0), a(!1);
|
|
367
367
|
}
|
|
368
368
|
});
|
|
369
369
|
return {
|
|
@@ -400,10 +400,10 @@ function ut() {
|
|
|
400
400
|
visualId: void 0
|
|
401
401
|
// Explicitly no visualId for local visuals
|
|
402
402
|
};
|
|
403
|
-
|
|
403
|
+
x(d, k, "end"), y(k.id), T.success("Visual saved to dashboard"), a(!1), f(!1);
|
|
404
404
|
}
|
|
405
405
|
},
|
|
406
|
-
isLibraryVisual:
|
|
406
|
+
isLibraryVisual: b,
|
|
407
407
|
currentVisualName: N,
|
|
408
408
|
isSaving: u.isPending
|
|
409
409
|
};
|
|
@@ -412,13 +412,13 @@ function Nt({
|
|
|
412
412
|
className: e
|
|
413
413
|
}) {
|
|
414
414
|
const a = P((u) => u.frame), c = P((u) => u.card), n = we((u) => u.selectedVisual), m = E((u) => u.selectedFrameId), l = E((u) => u.selectedSheetId), { setIsVisualEditing: o } = re(), s = !!(a != null && a.visualId || n != null && n.id), h = !!(a != null && a.visualId && m), d = s && !h, {
|
|
415
|
-
saveAsDialogOpen:
|
|
415
|
+
saveAsDialogOpen: v,
|
|
416
416
|
setSaveAsDialogOpen: C,
|
|
417
|
-
handleSaveAs:
|
|
418
|
-
isLibraryVisual:
|
|
417
|
+
handleSaveAs: g,
|
|
418
|
+
isLibraryVisual: x,
|
|
419
419
|
currentVisualName: y,
|
|
420
420
|
isSaving: f
|
|
421
|
-
} = ut(), { handleAddLibraryVisual:
|
|
421
|
+
} = ut(), { handleAddLibraryVisual: b } = ne(), N = async () => {
|
|
422
422
|
if (!l) {
|
|
423
423
|
T.error("No dashboard sheet selected");
|
|
424
424
|
return;
|
|
@@ -427,7 +427,7 @@ function Nt({
|
|
|
427
427
|
T.error("No visual selected");
|
|
428
428
|
return;
|
|
429
429
|
}
|
|
430
|
-
const u = await
|
|
430
|
+
const u = await b(n);
|
|
431
431
|
u.success ? (T.success("Visual added to dashboard"), o(!1)) : T.error(u.error || "Failed to add visual to dashboard");
|
|
432
432
|
};
|
|
433
433
|
return /* @__PURE__ */ r(L, { children: [
|
|
@@ -492,14 +492,14 @@ function Nt({
|
|
|
492
492
|
/* @__PURE__ */ t(
|
|
493
493
|
dt,
|
|
494
494
|
{
|
|
495
|
-
open:
|
|
495
|
+
open: v,
|
|
496
496
|
onOpenChange: (u) => {
|
|
497
497
|
f || C(u);
|
|
498
498
|
},
|
|
499
|
-
isLibraryVisual:
|
|
499
|
+
isLibraryVisual: x,
|
|
500
500
|
currentVisualName: y,
|
|
501
501
|
isSaving: f,
|
|
502
|
-
onConfirm:
|
|
502
|
+
onConfirm: g
|
|
503
503
|
}
|
|
504
504
|
)
|
|
505
505
|
] });
|
|
@@ -706,24 +706,28 @@ function mt({
|
|
|
706
706
|
] });
|
|
707
707
|
}
|
|
708
708
|
function ht() {
|
|
709
|
-
const { authToken: e, tokenProps: a } = B(), c = I((f) => f.activeExports), { clearCompleted: n, removeExport: m, updateExport: l } = se(), [o, s] = A(!1), [h, d] = A(!1),
|
|
710
|
-
(f,
|
|
711
|
-
), C =
|
|
709
|
+
const { authToken: e, tokenProps: a } = B(), c = I((f) => f.activeExports), { clearCompleted: n, removeExport: m, updateExport: l } = se(), [o, s] = A(!1), [h, d] = A(!1), v = Array.from(c.values()).sort(
|
|
710
|
+
(f, b) => b.startedAt.getTime() - f.startedAt.getTime()
|
|
711
|
+
), C = v.some(
|
|
712
712
|
(f) => f.status === "completed" || f.status === "failed"
|
|
713
|
-
),
|
|
714
|
-
const f = a == null ? void 0 : a.apiServiceUrl,
|
|
715
|
-
if (!(!f || !
|
|
713
|
+
), g = M(async () => {
|
|
714
|
+
const f = a == null ? void 0 : a.apiServiceUrl, b = e == null ? void 0 : e.accessToken;
|
|
715
|
+
if (!(!f || !b)) {
|
|
716
716
|
s(!0);
|
|
717
717
|
try {
|
|
718
718
|
const N = Array.from(c.values());
|
|
719
719
|
await Promise.all(
|
|
720
720
|
N.map(async (u) => {
|
|
721
721
|
try {
|
|
722
|
-
const p = await ae(f,
|
|
722
|
+
const p = await ae(f, b, u.id);
|
|
723
723
|
let i;
|
|
724
724
|
if (p.status === "completed")
|
|
725
725
|
try {
|
|
726
|
-
i = await _(
|
|
726
|
+
i = await _(
|
|
727
|
+
f,
|
|
728
|
+
b,
|
|
729
|
+
u.id
|
|
730
|
+
);
|
|
727
731
|
} catch (w) {
|
|
728
732
|
console.error(`Failed to get download URL for ${u.id}:`, w);
|
|
729
733
|
}
|
|
@@ -746,20 +750,25 @@ function ht() {
|
|
|
746
750
|
s(!1);
|
|
747
751
|
}
|
|
748
752
|
}
|
|
749
|
-
}, [
|
|
750
|
-
|
|
751
|
-
|
|
753
|
+
}, [
|
|
754
|
+
c,
|
|
755
|
+
e == null ? void 0 : e.accessToken,
|
|
756
|
+
a == null ? void 0 : a.apiServiceUrl,
|
|
757
|
+
l
|
|
758
|
+
]), x = M(async () => {
|
|
759
|
+
const f = a == null ? void 0 : a.apiServiceUrl, b = e == null ? void 0 : e.accessToken;
|
|
760
|
+
if (!f || !b) {
|
|
752
761
|
n();
|
|
753
762
|
return;
|
|
754
763
|
}
|
|
755
764
|
d(!0);
|
|
756
765
|
try {
|
|
757
|
-
const N =
|
|
766
|
+
const N = v.filter(
|
|
758
767
|
(u) => u.status === "completed" || u.status === "failed"
|
|
759
768
|
);
|
|
760
769
|
await Promise.all(
|
|
761
770
|
N.map(
|
|
762
|
-
(u) => Z(f,
|
|
771
|
+
(u) => Z(f, b, u.id).catch(
|
|
763
772
|
(p) => console.error(`Failed to delete export ${u.id}:`, p)
|
|
764
773
|
)
|
|
765
774
|
)
|
|
@@ -767,22 +776,30 @@ function ht() {
|
|
|
767
776
|
} finally {
|
|
768
777
|
d(!1);
|
|
769
778
|
}
|
|
770
|
-
}, [
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
779
|
+
}, [
|
|
780
|
+
v,
|
|
781
|
+
a == null ? void 0 : a.apiServiceUrl,
|
|
782
|
+
e == null ? void 0 : e.accessToken,
|
|
783
|
+
n
|
|
784
|
+
]), y = M(
|
|
785
|
+
async (f) => {
|
|
786
|
+
const b = a == null ? void 0 : a.apiServiceUrl, N = e == null ? void 0 : e.accessToken;
|
|
787
|
+
if (b && N)
|
|
788
|
+
try {
|
|
789
|
+
await Z(b, N, f);
|
|
790
|
+
} catch (u) {
|
|
791
|
+
console.error(`Failed to cancel export ${f}:`, u);
|
|
792
|
+
}
|
|
793
|
+
m(f);
|
|
794
|
+
},
|
|
795
|
+
[a == null ? void 0 : a.apiServiceUrl, e == null ? void 0 : e.accessToken, m]
|
|
796
|
+
);
|
|
797
|
+
return v.length === 0 ? /* @__PURE__ */ r("div", { className: "p-6 text-center", children: [
|
|
798
|
+
/* @__PURE__ */ t(ee, { className: "mx-auto mb-2 h-8 w-8 text-muted-foreground" }),
|
|
782
799
|
/* @__PURE__ */ t("p", { className: "text-sm text-muted-foreground", children: "No active exports" }),
|
|
783
|
-
/* @__PURE__ */ t("p", { className: "text-xs text-muted-foreground
|
|
800
|
+
/* @__PURE__ */ t("p", { className: "mt-1 text-xs text-muted-foreground", children: "Large exports will appear here" })
|
|
784
801
|
] }) : /* @__PURE__ */ r("div", { className: "flex flex-col", children: [
|
|
785
|
-
/* @__PURE__ */ r("div", { className: "
|
|
802
|
+
/* @__PURE__ */ r("div", { className: "flex items-center justify-between border-b px-4 py-3", children: [
|
|
786
803
|
/* @__PURE__ */ r("div", { className: "flex items-center gap-2", children: [
|
|
787
804
|
/* @__PURE__ */ t(ee, { className: "h-5 w-5 text-muted-foreground" }),
|
|
788
805
|
/* @__PURE__ */ t("h4", { className: "font-semibold", children: "Exports" })
|
|
@@ -794,10 +811,15 @@ function ht() {
|
|
|
794
811
|
variant: "ghost",
|
|
795
812
|
size: "sm",
|
|
796
813
|
className: "h-7 w-7 p-0",
|
|
797
|
-
onClick:
|
|
814
|
+
onClick: g,
|
|
798
815
|
disabled: o,
|
|
799
816
|
title: "Refresh status",
|
|
800
|
-
children: /* @__PURE__ */ t(
|
|
817
|
+
children: /* @__PURE__ */ t(
|
|
818
|
+
at,
|
|
819
|
+
{
|
|
820
|
+
className: `h-4 w-4 ${o ? "animate-spin" : ""}`
|
|
821
|
+
}
|
|
822
|
+
)
|
|
801
823
|
}
|
|
802
824
|
),
|
|
803
825
|
C && /* @__PURE__ */ t(
|
|
@@ -805,27 +827,22 @@ function ht() {
|
|
|
805
827
|
{
|
|
806
828
|
variant: "ghost",
|
|
807
829
|
size: "sm",
|
|
808
|
-
className: "h-7 text-sm
|
|
809
|
-
onClick:
|
|
830
|
+
className: "h-7 px-2 text-sm",
|
|
831
|
+
onClick: x,
|
|
810
832
|
disabled: h,
|
|
811
833
|
children: h ? "Clearing..." : "Clear all"
|
|
812
834
|
}
|
|
813
835
|
)
|
|
814
836
|
] })
|
|
815
837
|
] }),
|
|
816
|
-
/* @__PURE__ */ t("div", { className: "max-h-[350px] overflow-y-auto", children: /* @__PURE__ */ t("div", { className: "divide-y", children:
|
|
838
|
+
/* @__PURE__ */ t("div", { className: "max-h-[350px] overflow-y-auto", children: /* @__PURE__ */ t("div", { className: "divide-y", children: v.map((f) => /* @__PURE__ */ t(
|
|
817
839
|
mt,
|
|
818
840
|
{
|
|
819
841
|
export: f,
|
|
820
842
|
onRemove: y
|
|
821
843
|
},
|
|
822
844
|
f.id
|
|
823
|
-
)) }) })
|
|
824
|
-
/* @__PURE__ */ r("div", { className: "px-4 py-2 border-t text-sm text-muted-foreground text-center", children: [
|
|
825
|
-
g.length,
|
|
826
|
-
" total export",
|
|
827
|
-
g.length !== 1 ? "s" : ""
|
|
828
|
-
] })
|
|
845
|
+
)) }) })
|
|
829
846
|
] });
|
|
830
847
|
}
|
|
831
848
|
function Dt() {
|
package/dist/chunks/{resource-management-panel-Buhi-kvP.js → resource-management-panel-CihSUDmt.js}
RENAMED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),t=require("./index-
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),t=require("./index-tt1rwTc8.js"),c=require("react"),de=require("./use-visual-utils-BkmyEMSD.js"),pe=require("./use-role-aware-display-preferences-DgsVnRKz.js");/**
|
|
2
2
|
* @license lucide-react v0.453.0 - ISC
|
|
3
3
|
*
|
|
4
4
|
* This source code is licensed under the ISC license.
|
package/dist/chunks/{resource-management-panel-pxL28GXq.js → resource-management-panel-Dda1VGgq.js}
RENAMED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { jsx as e, jsxs as a, Fragment as ge } from "react/jsx-runtime";
|
|
2
|
-
import { aF as Ze, u as me, au as $e, aO as re, aS as Je, aT as Qe, c as J, aU as ke, aV as et, aW as tt, B as _, aX as st, aY as at, aZ as W, a_ as pe, aG as oe, a$ as nt, b0 as it, b1 as rt, b2 as ve, b3 as De, b4 as ot, b5 as lt, I as dt, b6 as ye, e as le, b7 as Se, b8 as Ee, b9 as ct, L as Ve, R as Le, ba as Ae, bb as Te, bc as Oe, bd as Re, be as Pe, bf as Ue, bg as Ie, bh as je, bi as Fe, bj as ut, bk as ht, bl as Me, bm as ze, bn as Be, bo as mt, bp as He, bq as pt, A as ne, aN as ft, br as _e, bs as gt, bt as Dt, bu as xt, bv as bt, bw as Nt, bx as wt, by as vt, bz as Ce, bA as fe, bB as Ct, bC as yt, bD as St, bE as Et, bF as Vt } from "./index-
|
|
2
|
+
import { aF as Ze, u as me, au as $e, aO as re, aS as Je, aT as Qe, c as J, aU as ke, aV as et, aW as tt, B as _, aX as st, aY as at, aZ as W, a_ as pe, aG as oe, a$ as nt, b0 as it, b1 as rt, b2 as ve, b3 as De, b4 as ot, b5 as lt, I as dt, b6 as ye, e as le, b7 as Se, b8 as Ee, b9 as ct, L as Ve, R as Le, ba as Ae, bb as Te, bc as Oe, bd as Re, be as Pe, bf as Ue, bg as Ie, bh as je, bi as Fe, bj as ut, bk as ht, bl as Me, bm as ze, bn as Be, bo as mt, bp as He, bq as pt, A as ne, aN as ft, br as _e, bs as gt, bt as Dt, bu as xt, bv as bt, bw as Nt, bx as wt, by as vt, bz as Ce, bA as fe, bB as Ct, bC as yt, bD as St, bE as Et, bF as Vt } from "./index-TF2KfLGc.js";
|
|
3
3
|
import Lt, { useRef as At, useEffect as ie, useState as x } from "react";
|
|
4
|
-
import { a as Ge } from "./use-visual-utils-
|
|
5
|
-
import { u as Tt } from "./use-role-aware-display-preferences-
|
|
4
|
+
import { a as Ge } from "./use-visual-utils-Dwmrgj6E.js";
|
|
5
|
+
import { u as Tt } from "./use-role-aware-display-preferences-CpROR4Gx.js";
|
|
6
6
|
/**
|
|
7
7
|
* @license lucide-react v0.453.0 - ISC
|
|
8
8
|
*
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { b as m, e as t, g as D, f as U, h as b, i as u, j as E, k as g } from "./index-
|
|
1
|
+
import { b as m, e as t, g as D, f as U, h as b, i as u, j as E, k as g } from "./index-TF2KfLGc.js";
|
|
2
2
|
import { useMemo as i } from "react";
|
|
3
3
|
function S() {
|
|
4
4
|
const { displayPreferences: n, shouldShowElement: c } = m(), { currentUser: a, userContext: s } = t(), r = i(
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";const a=require("./index-
|
|
1
|
+
"use strict";const a=require("./index-tt1rwTc8.js"),n=require("react");function f(){const{displayPreferences:c,shouldShowElement:o}=a.useDisplayPreferences(),{currentUser:e,userContext:s}=a.useCurrentUserInfo(),i=n.useMemo(()=>a.getRoleBasedDisplayOverrides(e),[e]),t=n.useMemo(()=>r=>i&&i[r]!==void 0&&i[r]===!1?!1:o(r),[i,o,c]),p=n.useMemo(()=>{var r,d,l,u,h;return{canEdit:((r=s==null?void 0:s.permissions)==null?void 0:r.canEdit)??a.canUserEdit(e),canUseFilters:((d=s==null?void 0:s.permissions)==null?void 0:d.canEdit)??a.canUserUseFilters(e),canManageDashboards:((l=s==null?void 0:s.permissions)==null?void 0:l.canCreateDashboard)??a.canUserManageDashboards(e),canCreateDashboards:((u=s==null?void 0:s.permissions)==null?void 0:u.canCreateDashboard)??a.canUserCreateDashboards(e),canAccessVisuals:((h=s==null?void 0:s.permissions)==null?void 0:h.canEdit)??a.canUserAccessVisuals(e)}},[e,s]);return{displayPreferences:c,shouldShowElement:t,permissions:p,currentUser:e}}exports.useRoleAwareDisplayPreferences=f;
|