@vertesia/ui 1.4.0-dev.20260615.042549Z → 1.4.0-dev.20260629.130134Z
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/lib/core/components/shadcn/dropdown.d.ts.map +1 -1
- package/lib/core/components/shadcn/dropdown.js +6 -2
- package/lib/core/components/shadcn/dropdown.js.map +1 -1
- package/lib/core/components/shadcn/filters/filterBar.d.ts.map +1 -1
- package/lib/core/components/shadcn/filters/filterBar.js +9 -2
- package/lib/core/components/shadcn/filters/filterBar.js.map +1 -1
- package/lib/core/components/shadcn/modal/ConfirmModal.d.ts +16 -1
- package/lib/core/components/shadcn/modal/ConfirmModal.d.ts.map +1 -1
- package/lib/core/components/shadcn/modal/ConfirmModal.js +25 -3
- package/lib/core/components/shadcn/modal/ConfirmModal.js.map +1 -1
- package/lib/core/components/shadcn/modal/dialog.js +1 -1
- package/lib/core/components/shadcn/modal/dialog.js.map +1 -1
- package/lib/core/components/shadcn/popover.d.ts.map +1 -1
- package/lib/core/components/shadcn/popover.js +3 -1
- package/lib/core/components/shadcn/popover.js.map +1 -1
- package/lib/core/components/shadcn/switch.js +3 -3
- package/lib/core/components/shadcn/switch.js.map +1 -1
- package/lib/core/components/shadcn/tabs.js +1 -1
- package/lib/core/components/shadcn/tabs.js.map +1 -1
- package/lib/core/components/shadcn/tooltip.d.ts.map +1 -1
- package/lib/core/components/shadcn/tooltip.js +3 -1
- package/lib/core/components/shadcn/tooltip.js.map +1 -1
- package/lib/env/index.d.ts +0 -19
- package/lib/env/index.d.ts.map +1 -1
- package/lib/env/index.js +0 -6
- package/lib/env/index.js.map +1 -1
- package/lib/features/agent/PayloadBuilder.d.ts +4 -0
- package/lib/features/agent/PayloadBuilder.d.ts.map +1 -1
- package/lib/features/agent/PayloadBuilder.js +16 -0
- package/lib/features/agent/PayloadBuilder.js.map +1 -1
- package/lib/features/agent/chat/AgentApprovalModeSelector.d.ts +10 -0
- package/lib/features/agent/chat/AgentApprovalModeSelector.d.ts.map +1 -0
- package/lib/features/agent/chat/AgentApprovalModeSelector.js +50 -0
- package/lib/features/agent/chat/AgentApprovalModeSelector.js.map +1 -0
- package/lib/features/agent/chat/AgentChatFixtureReplay.d.ts +2 -1
- package/lib/features/agent/chat/AgentChatFixtureReplay.d.ts.map +1 -1
- package/lib/features/agent/chat/AgentChatFixtureReplay.js +3 -3
- package/lib/features/agent/chat/AgentChatFixtureReplay.js.map +1 -1
- package/lib/features/agent/chat/AgentRequestInputOverlay.d.ts +5 -2
- package/lib/features/agent/chat/AgentRequestInputOverlay.d.ts.map +1 -1
- package/lib/features/agent/chat/AgentRequestInputOverlay.js +41 -7
- package/lib/features/agent/chat/AgentRequestInputOverlay.js.map +1 -1
- package/lib/features/agent/chat/AgentRightPanel.d.ts.map +1 -1
- package/lib/features/agent/chat/AgentRightPanel.js +133 -12
- package/lib/features/agent/chat/AgentRightPanel.js.map +1 -1
- package/lib/features/agent/chat/AnimatedThinkingDots.js +1 -1
- package/lib/features/agent/chat/AnimatedThinkingDots.js.map +1 -1
- package/lib/features/agent/chat/ArtifactsTab.d.ts.map +1 -1
- package/lib/features/agent/chat/ArtifactsTab.js +11 -65
- package/lib/features/agent/chat/ArtifactsTab.js.map +1 -1
- package/lib/features/agent/chat/AskUserWidget.d.ts +3 -1
- package/lib/features/agent/chat/AskUserWidget.d.ts.map +1 -1
- package/lib/features/agent/chat/AskUserWidget.js +4 -3
- package/lib/features/agent/chat/AskUserWidget.js.map +1 -1
- package/lib/features/agent/chat/ModernAgentConversation.d.ts +10 -2
- package/lib/features/agent/chat/ModernAgentConversation.d.ts.map +1 -1
- package/lib/features/agent/chat/ModernAgentConversation.js +526 -117
- package/lib/features/agent/chat/ModernAgentConversation.js.map +1 -1
- package/lib/features/agent/chat/ModernAgentOutput/ActiveWorkstreamsSummary.d.ts +8 -0
- package/lib/features/agent/chat/ModernAgentOutput/ActiveWorkstreamsSummary.d.ts.map +1 -0
- package/lib/features/agent/chat/ModernAgentOutput/ActiveWorkstreamsSummary.js +19 -0
- package/lib/features/agent/chat/ModernAgentOutput/ActiveWorkstreamsSummary.js.map +1 -0
- package/lib/features/agent/chat/ModernAgentOutput/AllMessagesMixed.d.ts +8 -2
- package/lib/features/agent/chat/ModernAgentOutput/AllMessagesMixed.d.ts.map +1 -1
- package/lib/features/agent/chat/ModernAgentOutput/AllMessagesMixed.js +551 -92
- package/lib/features/agent/chat/ModernAgentOutput/AllMessagesMixed.js.map +1 -1
- package/lib/features/agent/chat/ModernAgentOutput/AttachmentPreview.d.ts.map +1 -1
- package/lib/features/agent/chat/ModernAgentOutput/AttachmentPreview.js +7 -6
- package/lib/features/agent/chat/ModernAgentOutput/AttachmentPreview.js.map +1 -1
- package/lib/features/agent/chat/ModernAgentOutput/Header.js +2 -2
- package/lib/features/agent/chat/ModernAgentOutput/Header.js.map +1 -1
- package/lib/features/agent/chat/ModernAgentOutput/MessageDeliveryStatus.d.ts +8 -0
- package/lib/features/agent/chat/ModernAgentOutput/MessageDeliveryStatus.d.ts.map +1 -0
- package/lib/features/agent/chat/ModernAgentOutput/MessageDeliveryStatus.js +61 -0
- package/lib/features/agent/chat/ModernAgentOutput/MessageDeliveryStatus.js.map +1 -0
- package/lib/features/agent/chat/ModernAgentOutput/MessageInput.d.ts +15 -2
- package/lib/features/agent/chat/ModernAgentOutput/MessageInput.d.ts.map +1 -1
- package/lib/features/agent/chat/ModernAgentOutput/MessageInput.js +28 -38
- package/lib/features/agent/chat/ModernAgentOutput/MessageInput.js.map +1 -1
- package/lib/features/agent/chat/ModernAgentOutput/MessageItem.d.ts +1 -1
- package/lib/features/agent/chat/ModernAgentOutput/MessageItem.d.ts.map +1 -1
- package/lib/features/agent/chat/ModernAgentOutput/MessageItem.js +3 -2
- package/lib/features/agent/chat/ModernAgentOutput/MessageItem.js.map +1 -1
- package/lib/features/agent/chat/ModernAgentOutput/SlideInPanel.js +2 -1
- package/lib/features/agent/chat/ModernAgentOutput/SlideInPanel.js.map +1 -1
- package/lib/features/agent/chat/ModernAgentOutput/SlidingMessages.js +1 -1
- package/lib/features/agent/chat/ModernAgentOutput/SlidingMessages.js.map +1 -1
- package/lib/features/agent/chat/ModernAgentOutput/SummaryConversation.d.ts +5 -0
- package/lib/features/agent/chat/ModernAgentOutput/SummaryConversation.d.ts.map +1 -1
- package/lib/features/agent/chat/ModernAgentOutput/SummaryConversation.js +59 -4
- package/lib/features/agent/chat/ModernAgentOutput/SummaryConversation.js.map +1 -1
- package/lib/features/agent/chat/ModernAgentOutput/WorkstreamTabs.js +2 -2
- package/lib/features/agent/chat/ModernAgentOutput/WorkstreamTabs.js.map +1 -1
- package/lib/features/agent/chat/ModernAgentOutput/requestInputMessages.d.ts +9 -0
- package/lib/features/agent/chat/ModernAgentOutput/requestInputMessages.d.ts.map +1 -1
- package/lib/features/agent/chat/ModernAgentOutput/requestInputMessages.js +180 -0
- package/lib/features/agent/chat/ModernAgentOutput/requestInputMessages.js.map +1 -1
- package/lib/features/agent/chat/ModernAgentOutput/utils.d.ts +6 -0
- package/lib/features/agent/chat/ModernAgentOutput/utils.d.ts.map +1 -1
- package/lib/features/agent/chat/ModernAgentOutput/utils.js +92 -2
- package/lib/features/agent/chat/ModernAgentOutput/utils.js.map +1 -1
- package/lib/features/agent/chat/clipboardFiles.d.ts +15 -0
- package/lib/features/agent/chat/clipboardFiles.d.ts.map +1 -0
- package/lib/features/agent/chat/clipboardFiles.js +35 -0
- package/lib/features/agent/chat/clipboardFiles.js.map +1 -0
- package/lib/features/agent/chat/hooks/useAgentStream.d.ts +6 -0
- package/lib/features/agent/chat/hooks/useAgentStream.d.ts.map +1 -1
- package/lib/features/agent/chat/hooks/useAgentStream.js +218 -37
- package/lib/features/agent/chat/hooks/useAgentStream.js.map +1 -1
- package/lib/features/agent/chat/hooks/useArtifacts.d.ts +1 -8
- package/lib/features/agent/chat/hooks/useArtifacts.d.ts.map +1 -1
- package/lib/features/agent/chat/hooks/useArtifacts.js +10 -28
- package/lib/features/agent/chat/hooks/useArtifacts.js.map +1 -1
- package/lib/features/agent/chat/index.d.ts +2 -1
- package/lib/features/agent/chat/index.d.ts.map +1 -1
- package/lib/features/agent/chat/index.js +2 -1
- package/lib/features/agent/chat/index.js.map +1 -1
- package/lib/features/agent/chat/workstreams.d.ts +1 -0
- package/lib/features/agent/chat/workstreams.d.ts.map +1 -1
- package/lib/features/agent/chat/workstreams.js +28 -0
- package/lib/features/agent/chat/workstreams.js.map +1 -1
- package/lib/features/facets/AgentRunnerFacetsNav.d.ts +10 -1
- package/lib/features/facets/AgentRunnerFacetsNav.d.ts.map +1 -1
- package/lib/features/facets/AgentRunnerFacetsNav.js +6 -3
- package/lib/features/facets/AgentRunnerFacetsNav.js.map +1 -1
- package/lib/features/facets/CollectionsFacetsNav.d.ts +10 -1
- package/lib/features/facets/CollectionsFacetsNav.d.ts.map +1 -1
- package/lib/features/facets/CollectionsFacetsNav.js +14 -5
- package/lib/features/facets/CollectionsFacetsNav.js.map +1 -1
- package/lib/features/facets/PromptsFacetsNav.d.ts +10 -1
- package/lib/features/facets/PromptsFacetsNav.d.ts.map +1 -1
- package/lib/features/facets/PromptsFacetsNav.js +14 -5
- package/lib/features/facets/PromptsFacetsNav.js.map +1 -1
- package/lib/features/facets/RunsFacetsNav.d.ts +10 -1
- package/lib/features/facets/RunsFacetsNav.d.ts.map +1 -1
- package/lib/features/facets/RunsFacetsNav.js +14 -5
- package/lib/features/facets/RunsFacetsNav.js.map +1 -1
- package/lib/features/index.d.ts +0 -1
- package/lib/features/index.d.ts.map +1 -1
- package/lib/features/index.js +0 -1
- package/lib/features/index.js.map +1 -1
- package/lib/features/oauth/McpConnectionsButton.d.ts +30 -0
- package/lib/features/oauth/McpConnectionsButton.d.ts.map +1 -0
- package/lib/features/oauth/McpConnectionsButton.js +70 -0
- package/lib/features/oauth/McpConnectionsButton.js.map +1 -0
- package/lib/features/oauth/McpConnectionsDialog.d.ts +25 -0
- package/lib/features/oauth/McpConnectionsDialog.d.ts.map +1 -0
- package/lib/features/oauth/McpConnectionsDialog.js +26 -0
- package/lib/features/oauth/McpConnectionsDialog.js.map +1 -0
- package/lib/features/oauth/RemoteMcpConnectionButton.d.ts.map +1 -1
- package/lib/features/oauth/RemoteMcpConnectionButton.js +14 -6
- package/lib/features/oauth/RemoteMcpConnectionButton.js.map +1 -1
- package/lib/features/oauth/index.d.ts +3 -0
- package/lib/features/oauth/index.d.ts.map +1 -1
- package/lib/features/oauth/index.js +3 -0
- package/lib/features/oauth/index.js.map +1 -1
- package/lib/features/oauth/useMcpConnections.d.ts +44 -0
- package/lib/features/oauth/useMcpConnections.d.ts.map +1 -0
- package/lib/features/oauth/useMcpConnections.js +168 -0
- package/lib/features/oauth/useMcpConnections.js.map +1 -0
- package/lib/features/permissions/UserPermissionsProvider.d.ts +4 -6
- package/lib/features/permissions/UserPermissionsProvider.d.ts.map +1 -1
- package/lib/features/permissions/UserPermissionsProvider.js +40 -42
- package/lib/features/permissions/UserPermissionsProvider.js.map +1 -1
- package/lib/features/store/objects/DocumentPreviewPanel.d.ts.map +1 -1
- package/lib/features/store/objects/DocumentPreviewPanel.js +2 -1
- package/lib/features/store/objects/DocumentPreviewPanel.js.map +1 -1
- package/lib/features/store/objects/DocumentQuickFilter.d.ts +23 -0
- package/lib/features/store/objects/DocumentQuickFilter.d.ts.map +1 -0
- package/lib/features/store/objects/DocumentQuickFilter.js +30 -0
- package/lib/features/store/objects/DocumentQuickFilter.js.map +1 -0
- package/lib/features/store/objects/DocumentSearchResults.d.ts.map +1 -1
- package/lib/features/store/objects/DocumentSearchResults.js +17 -1
- package/lib/features/store/objects/DocumentSearchResults.js.map +1 -1
- package/lib/features/store/objects/components/ContentOverview.d.ts.map +1 -1
- package/lib/features/store/objects/components/ContentOverview.js +17 -74
- package/lib/features/store/objects/components/ContentOverview.js.map +1 -1
- package/lib/features/store/objects/layout/DocumentTableColumn.d.ts +7 -1
- package/lib/features/store/objects/layout/DocumentTableColumn.d.ts.map +1 -1
- package/lib/features/store/objects/layout/DocumentTableColumn.js +27 -3
- package/lib/features/store/objects/layout/DocumentTableColumn.js.map +1 -1
- package/lib/features/store/objects/layout/documentLayout.js +1 -1
- package/lib/features/store/objects/layout/renderers.d.ts +2 -1
- package/lib/features/store/objects/layout/renderers.d.ts.map +1 -1
- package/lib/features/store/objects/layout/renderers.js +27 -20
- package/lib/features/store/objects/layout/renderers.js.map +1 -1
- package/lib/features/store/types/ContentObjectTypesSearch.d.ts.map +1 -1
- package/lib/features/store/types/ContentObjectTypesSearch.js +4 -1
- package/lib/features/store/types/ContentObjectTypesSearch.js.map +1 -1
- package/lib/features/store/types/ContentObjectTypesTable.d.ts +2 -1
- package/lib/features/store/types/ContentObjectTypesTable.d.ts.map +1 -1
- package/lib/features/store/types/ContentObjectTypesTable.js +8 -3
- package/lib/features/store/types/ContentObjectTypesTable.js.map +1 -1
- package/lib/i18n/instance.d.ts.map +1 -1
- package/lib/i18n/instance.js +1 -0
- package/lib/i18n/instance.js.map +1 -1
- package/lib/i18n/locales/ar.json +72 -45
- package/lib/i18n/locales/de.json +65 -34
- package/lib/i18n/locales/en.json +63 -47
- package/lib/i18n/locales/es.json +65 -35
- package/lib/i18n/locales/fr.json +65 -35
- package/lib/i18n/locales/it.json +72 -42
- package/lib/i18n/locales/ja.json +72 -41
- package/lib/i18n/locales/ko.json +72 -41
- package/lib/i18n/locales/pt.json +72 -42
- package/lib/i18n/locales/ru.json +72 -43
- package/lib/i18n/locales/tr.json +72 -41
- package/lib/i18n/locales/zh-TW.json +72 -41
- package/lib/i18n/locales/zh.json +72 -41
- package/lib/session/UserSession.d.ts +0 -6
- package/lib/session/UserSession.d.ts.map +1 -1
- package/lib/session/UserSession.js +0 -15
- package/lib/session/UserSession.js.map +1 -1
- package/lib/session/UserSessionProvider.d.ts.map +1 -1
- package/lib/session/UserSessionProvider.js +39 -98
- package/lib/session/UserSessionProvider.js.map +1 -1
- package/lib/session/auth/composable.d.ts.map +1 -1
- package/lib/session/auth/composable.js +3 -33
- package/lib/session/auth/composable.js.map +1 -1
- package/lib/shell/login/SignInPrimitives.d.ts.map +1 -1
- package/lib/shell/login/SignInPrimitives.js +3 -2
- package/lib/shell/login/SignInPrimitives.js.map +1 -1
- package/lib/vertesia-ui-core.js +1 -1
- package/lib/vertesia-ui-core.js.map +1 -1
- package/lib/vertesia-ui-env.js +1 -1
- package/lib/vertesia-ui-env.js.map +1 -1
- package/lib/vertesia-ui-features.js +1 -1
- package/lib/vertesia-ui-features.js.map +1 -1
- package/lib/vertesia-ui-i18n.js +1 -1
- package/lib/vertesia-ui-i18n.js.map +1 -1
- package/lib/vertesia-ui-session.js +1 -1
- package/lib/vertesia-ui-session.js.map +1 -1
- package/lib/vertesia-ui-shell.js +1 -1
- package/lib/vertesia-ui-shell.js.map +1 -1
- package/lib/vertesia-ui-widgets.js +1 -1
- package/lib/vertesia-ui-widgets.js.map +1 -1
- package/lib/widgets/schema-editor/editor/Editable.js +1 -1
- package/lib/widgets/schema-editor/editor/Editable.js.map +1 -1
- package/llms.txt +70 -70
- package/package.json +35 -32
- package/src/core/components/shadcn/dropdown.tsx +2 -0
- package/src/core/components/shadcn/filters/filterBar.tsx +9 -2
- package/src/core/components/shadcn/modal/ConfirmModal.tsx +65 -3
- package/src/core/components/shadcn/modal/dialog.tsx +1 -1
- package/src/core/components/shadcn/popover.tsx +1 -0
- package/src/core/components/shadcn/switch.tsx +4 -4
- package/src/core/components/shadcn/tabs.tsx +1 -1
- package/src/core/components/shadcn/tooltip.tsx +1 -0
- package/src/env/index.ts +0 -24
- package/src/features/agent/PayloadBuilder.tsx +18 -0
- package/src/features/agent/chat/AgentApprovalModeSelector.tsx +130 -0
- package/src/features/agent/chat/AgentChatFixtureReplay.test.tsx +22 -2
- package/src/features/agent/chat/AgentChatFixtureReplay.tsx +33 -27
- package/src/features/agent/chat/AgentRequestInputOverlay.test.tsx +122 -0
- package/src/features/agent/chat/AgentRequestInputOverlay.tsx +91 -17
- package/src/features/agent/chat/AgentRightPanel.tsx +238 -50
- package/src/features/agent/chat/AnimatedThinkingDots.tsx +1 -1
- package/src/features/agent/chat/ArtifactsTab.tsx +21 -155
- package/src/features/agent/chat/AskUserWidget.tsx +6 -2
- package/src/features/agent/chat/ModernAgentConversation.test.tsx +1157 -47
- package/src/features/agent/chat/ModernAgentConversation.tsx +703 -136
- package/src/features/agent/chat/ModernAgentOutput/ActiveWorkstreamsSummary.tsx +74 -0
- package/src/features/agent/chat/ModernAgentOutput/AllMessagesMixed.test.tsx +1420 -126
- package/src/features/agent/chat/ModernAgentOutput/AllMessagesMixed.tsx +934 -111
- package/src/features/agent/chat/ModernAgentOutput/AttachmentPreview.tsx +31 -40
- package/src/features/agent/chat/ModernAgentOutput/Header.tsx +28 -28
- package/src/features/agent/chat/ModernAgentOutput/MessageDeliveryStatus.tsx +83 -0
- package/src/features/agent/chat/ModernAgentOutput/MessageInput.test.tsx +38 -2
- package/src/features/agent/chat/ModernAgentOutput/MessageInput.tsx +121 -98
- package/src/features/agent/chat/ModernAgentOutput/MessageItem.tsx +7 -1
- package/src/features/agent/chat/ModernAgentOutput/SlideInPanel.tsx +3 -3
- package/src/features/agent/chat/ModernAgentOutput/SlidingMessages.tsx +1 -1
- package/src/features/agent/chat/ModernAgentOutput/SummaryConversation.ts +82 -2
- package/src/features/agent/chat/ModernAgentOutput/WorkstreamTabs.tsx +2 -2
- package/src/features/agent/chat/ModernAgentOutput/requestInputMessages.ts +216 -0
- package/src/features/agent/chat/ModernAgentOutput/utils.test.ts +149 -0
- package/src/features/agent/chat/ModernAgentOutput/utils.ts +103 -2
- package/src/features/agent/chat/clipboardFiles.ts +33 -0
- package/src/features/agent/chat/hooks/useAgentStream.test.tsx +355 -4
- package/src/features/agent/chat/hooks/useAgentStream.ts +270 -43
- package/src/features/agent/chat/hooks/useArtifacts.ts +11 -44
- package/src/features/agent/chat/index.ts +10 -1
- package/src/features/agent/chat/workstreams.ts +42 -0
- package/src/features/facets/AgentRunnerFacetsNav.tsx +23 -3
- package/src/features/facets/CollectionsFacetsNav.tsx +30 -5
- package/src/features/facets/PromptsFacetsNav.tsx +30 -5
- package/src/features/facets/RunsFacetsNav.tsx +32 -5
- package/src/features/index.ts +0 -1
- package/src/features/oauth/McpConnectionsButton.test.tsx +248 -0
- package/src/features/oauth/McpConnectionsButton.tsx +269 -0
- package/src/features/oauth/McpConnectionsDialog.tsx +142 -0
- package/src/features/oauth/RemoteMcpConnectionButton.tsx +37 -14
- package/src/features/oauth/index.ts +3 -0
- package/src/features/oauth/useMcpConnections.test.ts +94 -0
- package/src/features/oauth/useMcpConnections.ts +210 -0
- package/src/features/permissions/UserPermissionsProvider.tsx +41 -59
- package/src/features/store/objects/DocumentPreviewPanel.tsx +4 -2
- package/src/features/store/objects/DocumentQuickFilter.tsx +72 -0
- package/src/features/store/objects/DocumentSearchResults.tsx +30 -11
- package/src/features/store/objects/components/ContentOverview.tsx +30 -99
- package/src/features/store/objects/layout/DocumentTableColumn.tsx +29 -4
- package/src/features/store/objects/layout/documentLayout.tsx +1 -1
- package/src/features/store/objects/layout/renderers.tsx +80 -20
- package/src/features/store/types/ContentObjectTypesSearch.tsx +7 -1
- package/src/features/store/types/ContentObjectTypesTable.tsx +34 -4
- package/src/i18n/instance.ts +1 -0
- package/src/i18n/locales/ar.json +72 -45
- package/src/i18n/locales/de.json +65 -34
- package/src/i18n/locales/en.json +63 -47
- package/src/i18n/locales/es.json +65 -35
- package/src/i18n/locales/fr.json +65 -35
- package/src/i18n/locales/it.json +72 -42
- package/src/i18n/locales/ja.json +72 -41
- package/src/i18n/locales/ko.json +72 -41
- package/src/i18n/locales/pt.json +72 -42
- package/src/i18n/locales/ru.json +72 -43
- package/src/i18n/locales/tr.json +72 -41
- package/src/i18n/locales/zh-TW.json +72 -41
- package/src/i18n/locales/zh.json +72 -41
- package/src/i18n/rtl.test.ts +57 -1
- package/src/session/UserSession.ts +0 -16
- package/src/session/UserSessionProvider.tsx +51 -123
- package/src/session/auth/composable.ts +3 -34
- package/src/shell/login/SignInPrimitives.tsx +3 -2
- package/src/widgets/schema-editor/editor/Editable.tsx +1 -1
- package/lib/features/document-viewer/UniversalDocumentViewer.d.ts +0 -73
- package/lib/features/document-viewer/UniversalDocumentViewer.d.ts.map +0 -1
- package/lib/features/document-viewer/UniversalDocumentViewer.js +0 -415
- package/lib/features/document-viewer/UniversalDocumentViewer.js.map +0 -1
- package/lib/features/document-viewer/index.d.ts +0 -2
- package/lib/features/document-viewer/index.d.ts.map +0 -1
- package/lib/features/document-viewer/index.js +0 -2
- package/lib/features/document-viewer/index.js.map +0 -1
- package/src/features/document-viewer/UniversalDocumentViewer.test.tsx +0 -123
- package/src/features/document-viewer/UniversalDocumentViewer.tsx +0 -746
- package/src/features/document-viewer/index.ts +0 -1
- package/src/session/auth/composable.test.ts +0 -79
package/lib/vertesia-ui-shell.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{jsx as e,jsxs as t,Fragment as n}from"react/jsx-runtime";import{createContext as i,useContext as r,useState as a,useEffect as o,useMemo as l,useRef as c,useCallback as s}from"react";import{useFetch as d,errorMessage as u,SelectBox as m,Center as p,Button as h,Modal as g,ModalTitle as f,ModalBody as v,Spinner as x,RadioGroup as b,Input as y,useToast as N,ErrorBox as w,ModalFooter as k,Tabs as C,TabsBar as S,TabsPanel as j,VTooltip as z,Popover as I,PopoverTrigger as P,Avatar as A,PopoverContent as L,ModeToggle as T,MenuList as O,ToastProvider as B,ThemeProvider as R}from"@vertesia/ui/core";import{useUserSession as E,LastSelectedAccountId_KEY as D,LastSelectedProjectId_KEY as _,getFirebaseAuth as $,setFirebaseTenant as q,useUXTracking as F,UserNotFoundError as M,getCurrentVertesiaToken as W,fetchComposableTokenFromVertesiaToken as V,fetchComposableTokenFromFirebaseToken as U,UserSessionProvider as H}from"@vertesia/ui/session";import{useUITranslation as J,LanguageProvider as Y,LanguageBoundI18nProvider as G}from"@vertesia/ui/i18n";import{LockIcon as K,LockKeyhole as Q,ArrowRight as X,Mail as Z,ShieldOff as ee,Check as te,CopyIcon as ne}from"lucide-react";import{Env as ie}from"@vertesia/ui/env";import{RegionTag as re}from"@vertesia/ui/layout";import{signOut as ae,signInWithRedirect as oe,OAuthProvider as le,GithubAuthProvider as ce,GoogleAuthProvider as se}from"firebase/auth";import{useLocation as de,useNavigate as ue}from"@vertesia/ui/router";import{getTenantIdFromProject as me,Permission as pe}from"@vertesia/common";import{useUserPermissions as he,TypeRegistryProvider as ge,UserPermissionProvider as fe}from"@vertesia/ui/features";import ve from"clsx";import{AnimatePresence as xe,motion as be}from"framer-motion";const ye=i(null);function Ne({installation:t,children:n}){return e(ye.Provider,{value:t,children:n})}function we(){return r(ye)}function ke({app:n,onChange:i,placeholder:r}){const{client:a,project:o}=E(),{data:l,error:c}=d(()=>a.apps.getAppInstallationProjects(n),[n.id,n.name]);return c?t("span",{className:"text-red-600",children:["Error: failed to fetch projects: ",u(c)]}):e(Ce,{placeholder:r,initialValue:o?.id,projects:l||[],onChange:e=>{i&&!i(e)||(localStorage.setItem(D,e.account),localStorage.setItem(`${_}-${e.account}`,e.id),window.location.reload())}})}function Ce({initialValue:t,projects:n,onChange:i,placeholder:r="Select Project"}){const[o,l]=a(),c=!o&&t?n.find(e=>e.id===t):o;return e(m,{by:"id",value:c,options:n,optionLabel:e=>e.name,placeholder:r,onChange:e=>{l(e),i(e)}})}function Se({name:t,AccessDenied:n=ze,children:i}){return t?e(je,{name:t,AccessDenied:n,children:i}):e(Ie,{})}function je({name:t,AccessDenied:n=ze,children:i}){const{authToken:r,client:l}=E(),[c,s]=a(null),[d,u]=a("loading");return o(()=>{if(r){r.apps.includes(t)?l.apps.getAppInstallationByName(t).then(e=>{e?(u("loaded"),s(e)):(console.log(`App ${t} not found!`),u("error"))}):u("error")}else u("loading")},[t,r,l.apps.getAppInstallationByName]),"loading"===d?null:"error"===d?e(n,{name:t}):c?e(Ne,{installation:c,children:i}):void 0}function ze({name:n}){const{project:i,accounts:r,client:c}=E(),{t:s}=J(),[u,h]=a(),{data:g}=d(()=>c.apps.getAppInstallationProjects({name:n}),[n]),{projectsByOrg:f,orgOptions:v}=l(()=>{if(!g||!r)return{projectsByOrg:{},orgOptions:[]};const e={};for(const t of g)e[t.account]||(e[t.account]=[]),e[t.account].push(t);const t=r.filter(t=>e[t.id]?.length>0);return{projectsByOrg:e,orgOptions:t}},[g,r]);o(()=>{!u&&v.length>0&&h(v[0].id)},[v,u]);const x=u&&f[u]||[],b=v.find(e=>e.id===u);return t(p,{className:"pt-10 flex flex-col items-center text-center text-gray-700",children:[e(K,{className:"w-10 h-10 mb-4 text-gray-500"}),e("div",{className:"text-xl font-semibold",children:s("shell.accessDenied")}),t("div",{className:"mt-2 text-sm text-gray-500",children:["You don't have permission to view the ",e("span",{className:"font-semibold",children:n})," app in project:"," ",t("span",{className:"font-semibold",children:["«",i?.name,"»"]}),"."]}),0===v.length&&void 0!==g&&e("div",{className:"mt-4 text-sm text-gray-500",children:"This app is not installed in any project you have access to."}),v.length>0&&t("div",{className:"mt-4 flex flex-row gap-4 items-end",children:[v.length>1&&t("div",{children:[e("div",{className:"text-sm text-gray-500 mb-2",children:s("shell.organization")}),e(m,{by:"id",value:b,options:v,optionLabel:e=>e.name,placeholder:s("shell.selectOrganization"),onChange:e=>h(e.id)})]}),t("div",{children:[v.length>1&&e("div",{className:"text-sm text-gray-500 mb-2",children:s("login.terminal.project")}),e(m,{by:"id",value:void 0,options:x,optionLabel:e=>e.name,placeholder:s("shell.selectProject"),onChange:e=>{localStorage.setItem(D,e.account),localStorage.setItem(`${_}-${e.account}`,e.id),window.location.reload()}})]})]})]})}function Ie(){const{t:n}=J();return t(p,{className:"pt-10 flex flex-col items-center text-center text-gray-700",children:[e(K,{className:"w-10 h-10 mb-4 text-gray-500"}),e("div",{className:"text-xl font-semibold",children:n("shell.applicationNotRegistered")}),t("div",{className:"mt-2 text-sm text-gray-500",children:["Before starting to code a Vertesia application you must register an application manifest in Vertesia Studio then install it in one or more projects.",e("p",{}),"Then use the created app name as a parameter to"," ",e("code",{children:'<StandaloneApp name="your-app-name">'})," in the ",e("code",{children:"src/main.tsx"})," file."]})]})}function Pe(){const n=E(),{client:i}=n,{t:r}=J(),[l,c]=a(!1),[s,d]=a([]);o(()=>{i.account.listInvites().then(e=>{if(e.length>0){const t=e.filter(e=>e.data.account);if(0===t.length)return void console.log("No valid invites found, closing modal");console.log("Found valid invites",t.length),c(!0),d(t)}else console.log("No invites found, closing modal"),c(!1)}).catch(e=>{console.error("Error fetching invites",e)})},[i.account.listInvites]);const u=()=>c(!1),m=s.map(a=>a.data.account?t("div",{className:"flex flex-row w-full justify-between border rounded-sm px-2 py-2 ",children:[t("div",{className:"flex flex-col",children:[e("div",{className:"w-full font-semibold",children:a.data.account.name??a.data.account}),a.data.project&&t("div",{className:"w-full text-base",children:["- ",a.data.project.name]}),t("div",{className:"text-xs",children:["Role: ",a.data.role]}),a.data.invited_by&&t("div",{className:"text-xs",children:["by ",a.data.invited_by.name??a.data.invited_by]})]}),t("div",{className:"flex flex-col gap-4",children:[e(h,{size:"xs",onClick:()=>(async e=>{await i.account.acceptInvite(e.id),await n.authCallback,await n.fetchAccounts(),await n.fetchProjects(e.data.account.id);const t=s.filter(t=>t.id!==e.id).filter(e=>e.data.account);t.length>0?d(t):u()})(a),children:r("login.accept")})," ",e(h,{size:"xs",variant:"secondary",onClick:()=>(async e=>{await i.account.rejectInvite(e.id);const t=s.filter(t=>t.id!==e.id);d(t),0===t.length&&u()})(a),children:r("login.reject")})]})]},a.id):(console.warn("Invite has no account data",a),null));return e("div",{children:t(g,{isOpen:l,onClose:u,children:[e(f,{children:r("login.reviewInvites")}),t(v,{children:[e("div",{className:"text-sm pb-4",children:"You have received the following invites to join other accounts. Please review and accept or declined them."}),m]})]})})}const Ae=Q,Le={google:function(n){return t("svg",{viewBox:"0 0 48 48","aria-hidden":"true",...n,children:[e("path",{fill:"#FFC107",d:"M43.6 20.5H42V20H24v8h11.3c-1.6 4.7-6.1 8-11.3 8a12 12 0 0 1 0-24c3 0 5.8 1.1 7.9 3l5.7-5.7A20 20 0 1 0 24 44c11 0 20-9 20-20 0-1.2-.1-2.3-.4-3.5z"}),e("path",{fill:"#FF3D00",d:"M6.3 14.7l6.6 4.8A12 12 0 0 1 24 12c3 0 5.8 1.1 7.9 3l5.7-5.7A20 20 0 0 0 6.3 14.7z"}),e("path",{fill:"#4CAF50",d:"M24 44c5.2 0 10-2 13.6-5.2l-6.3-5.3A12 12 0 0 1 12.7 28.5l-6.6 5.1A20 20 0 0 0 24 44z"}),e("path",{fill:"#1976D2",d:"M43.6 20.5H42V20H24v8h11.3a12 12 0 0 1-4 5.5l6.3 5.3C37.9 36.6 44 31 44 24c0-1.2-.1-2.3-.4-3.5z"})]})},github:function(t){return e("svg",{viewBox:"0 0 24 24","aria-hidden":"true",...t,children:e("path",{fill:"currentColor",fillRule:"evenodd",clipRule:"evenodd",d:"M12 2C6.48 2 2 6.58 2 12.25c0 4.54 2.87 8.39 6.84 9.75.5.09.68-.22.68-.49v-1.7c-2.78.62-3.37-1.36-3.37-1.36-.46-1.18-1.11-1.5-1.11-1.5-.91-.63.07-.62.07-.62 1 .07 1.53 1.05 1.53 1.05.89 1.57 2.34 1.12 2.91.86.09-.66.35-1.12.63-1.38-2.22-.26-4.56-1.14-4.56-5.07 0-1.12.39-2.03 1.03-2.75-.1-.26-.45-1.3.1-2.7 0 0 .84-.28 2.76 1.05A9.4 9.4 0 0 1 12 7.07c.85 0 1.71.12 2.51.34 1.91-1.33 2.75-1.05 2.75-1.05.55 1.4.2 2.44.1 2.7.64.72 1.03 1.63 1.03 2.75 0 3.94-2.34 4.81-4.57 5.06.36.32.68.94.68 1.9v2.81c0 .27.18.59.69.49C19.13 20.64 22 16.78 22 12.25 22 6.58 17.52 2 12 2z"})})},microsoft:function(n){return t("svg",{viewBox:"0 0 24 24","aria-hidden":"true",...n,children:[e("path",{fill:"#F25022",d:"M2 2h9.5v9.5H2z"}),e("path",{fill:"#7FBA00",d:"M12.5 2H22v9.5h-9.5z"}),e("path",{fill:"#00A4EF",d:"M2 12.5h9.5V22H2z"}),e("path",{fill:"#FFB900",d:"M12.5 12.5H22V22h-9.5z"})]})},oidc:Ae};function Te(e){return e&&e in Le?Le[e]:Ae}function Oe({children:t,centered:n=!1}){return e("div",{className:n?"w-full max-w-[420px] flex flex-col gap-6 items-center text-center":"w-full max-w-[420px] flex flex-col gap-6",children:t})}function Be({eyebrow:n,title:i,body:r,variant:a="info"}){return t("div",{children:[n&&e("div",{className:`${"destructive"===a?"text-destructive":"text-info"} text-[12.5px] font-medium mb-2`,children:n}),e("h1",{className:"text-foreground text-[22px] font-semibold tracking-tight leading-tight mb-1.5",children:i}),r&&e("p",{className:"text-muted text-sm leading-relaxed",children:r})]})}const Re={primary:"h-[42px] gap-2.5 rounded-md bg-foreground text-background hover:opacity-90 disabled:opacity-50 disabled:cursor-not-allowed",loading:"h-[42px] gap-2.5 rounded-md bg-foreground text-background opacity-90",ghost:"h-9 text-muted hover:text-foreground"};function Ee({variant:t="primary",className:n="",type:i="button",disabled:r,...a}){return e(h,{variant:"unstyled",size:"none",type:i,disabled:"loading"===t||r,className:`cursor-pointer inline-flex items-center justify-center text-sm font-medium transition ${Re[t]} ${n}`.trim(),...a})}function De({size:t="xs",className:n="",type:i="button",...r}){const a=`cursor-pointer ${"smaller"===t?"!text-[11px]":"!text-xs"} text-muted hover:text-foreground !transition px-2 py-1 !rounded underline decoration-transparent hover:decoration-current underline-offset-[3px]`;return e(h,{variant:"unstyled",size:"none",type:i,className:n?`${a} ${n}`:a,...r})}const _e={circle:"size-9 rounded-full text-sm ring-4 ring-background ring-offset-1 ring-offset-border",square:"size-[30px] rounded-md text-[11px]"};function $e({initials:t,shape:n="circle"}){return e("span",{className:`bg-info text-info-foreground grid place-items-center font-semibold shrink-0 ${_e[n]}`,children:t})}function qe({children:t}){return e("div",{className:"inline-grid place-items-center size-14 rounded-xl bg-info-background border border-info/15 mb-3.5",children:t})}function Fe({title:n,subtitle:i,titleClass:r,subtitleClass:a}){return t("div",{className:"flex-1 min-w-0",children:[e("div",{className:r,children:n}),e("div",{className:a,children:i})]})}const Me={tenant:{topRow:"flex items-center gap-2.5 px-3 py-2.5",title:"text-[13.5px] font-semibold text-foreground leading-tight",subtitle:"text-[11.5px] text-muted leading-tight mt-0.5",bottomRow:"flex items-center gap-2.5 px-3 py-1.5 border-t border-border bg-muted-background",mailBox:"size-[30px] grid place-items-center shrink-0",mailIcon:"size-4 text-muted",email:"text-sm text-foreground/80 flex-1 truncate",actionSize:"xs"},returning:{topRow:"flex items-center gap-3 px-3.5 py-2.5",title:"text-sm font-semibold text-foreground truncate",subtitle:"text-xs text-foreground/80 truncate",bottomRow:"flex items-center gap-3 px-3.5 py-1 border-t border-border bg-muted-background",mailBox:"w-9 h-6 grid place-items-center shrink-0",mailIcon:"size-3.5 text-muted",email:"text-xs text-foreground/80 flex-1 truncate",actionSize:"smaller"}};function We({variant:n="returning",badge:i,title:r,subtitle:a,email:o,actionLabel:l,onAction:c}){const s=Me[n];return t("div",{className:"rounded-md border border-border bg-background overflow-hidden",children:[t("div",{className:s.topRow,children:[i,e(Fe,{title:r,subtitle:a,titleClass:s.title,subtitleClass:s.subtitle})]}),t("div",{className:s.bottomRow,children:[e("div",{className:s.mailBox,children:e(Z,{className:s.mailIcon})}),e("span",{className:s.email,children:o}),e(De,{size:s.actionSize,onClick:c,children:l})]})]})}function Ve({badge:n,title:i,subtitle:r,actionLabel:a,onAction:o}){return t("div",{className:"flex items-center gap-3 px-3.5 py-2.5 rounded-md border border-border bg-muted-background",children:[n,e(Fe,{title:i,subtitle:r,titleClass:"text-sm font-semibold text-foreground truncate",subtitleClass:"text-xs text-muted truncate"}),e(De,{onClick:o,children:a})]})}function Ue({email:n,actionLabel:i,onAction:r}){return t("div",{className:"flex items-center gap-2 px-3 py-2 rounded-md border border-border bg-muted-background",children:[e(Z,{className:"size-4 text-muted shrink-0"}),e("span",{className:"text-sm text-foreground/80 flex-1 truncate",children:n}),e(De,{onClick:r,children:i})]})}function He({provider:n,label:i,onClick:r,variant:a="outline"}){const o=Te(n);if("arrow"===a){const n="!size-3.5 text-muted opacity-0 group-hover:opacity-100 group-hover:translate-x-0.5 transition";return t(h,{variant:"unstyled",size:"none",onClick:r,className:"cursor-pointer group h-[42px] w-full inline-flex items-center gap-3 ps-3.5 pe-3 rounded-md border border-border bg-background text-sm font-medium text-foreground transition hover:bg-muted-background",children:[e(o,{className:"!size-[18px] shrink-0"}),e("span",{className:"flex-1 text-start",children:i}),e(X,{className:n})]})}return t(h,{variant:"outline",onClick:r,className:`w-full py-5 flex rounded-lg transition duration-150 text-center ${"filled"===a?"!bg-foreground text-background hover:!bg-foreground/90":"hover:shadow-sm"}`,children:[e(o,{className:"!size-[18px]"}),e("span",{className:"text-sm font-medium",children:i})]})}function Je({icon:n,title:i,meta:r}){return t("div",{className:"flex items-center gap-2.5 px-3 py-2.5 rounded-md bg-destructive-background border border-destructive/20",children:[e(n,{className:"size-5 text-destructive shrink-0"}),t("div",{className:"flex-1 min-w-0 text-sm",children:[e("div",{className:"font-semibold text-destructive",children:i}),e("div",{className:"text-xs text-destructive/80",children:r})]})]})}function Ye({inputRef:n,label:i,placeholder:r,value:a,onChange:o,invalid:l=!1,error:c}){return t("div",{className:"flex flex-col gap-1.5",children:[e("label",{htmlFor:"vt-login-email",className:"text-xs font-medium text-foreground/80",children:i}),e("input",{ref:n,id:"vt-login-email",name:"vt-login-email",type:"email",className:"h-[42px] px-3.5 rounded-md border border-border bg-background text-sm text-foreground placeholder:text-muted-foreground outline-none transition focus:border-info focus:ring-4 focus:ring-info/15 aria-[invalid=true]:border-destructive aria-[invalid=true]:ring-destructive/15",placeholder:r,value:a,onChange:e=>o(e.target.value),"aria-invalid":l,autoComplete:"off",autoCorrect:"off",autoCapitalize:"off",spellCheck:!1,"data-1p-ignore":!0,"data-lpignore":"true","data-form-type":"other"}),c&&e("div",{role:"alert",className:"text-xs text-destructive",children:c})]})}const Ge="vt.lastSuccessfulLogin",Ke="vt.pendingSignin";function Qe(){try{const e=localStorage.getItem(Ge);if(!e)return null;const t=JSON.parse(e);return t?.email&&t?.lastProvider?t:null}catch{return null}}function Xe(){try{localStorage.removeItem(Ge)}catch{}}function Ze(){try{const e=sessionStorage.getItem(Ke);return e?JSON.parse(e):null}catch{return null}}function et(){try{sessionStorage.removeItem(Ke)}catch{}}async function tt(){Xe(),et();try{await ae($())}catch{}}function nt(e){let t=e||window.location.pathname||"/";return"/"!==t[0]&&(t=`/${t}`),t}const it={google:(e,t)=>{const n=new se;return n.addScope("profile"),n.addScope("email"),n.setCustomParameters({redirect_uri:window.location.origin+nt(t),...e?{login_hint:e}:{prompt:"select_account"}}),n},github:e=>{const t=new ce;return t.addScope("profile"),t.addScope("email"),e&&t.setCustomParameters({login:e}),t},microsoft:e=>{const t=new le("microsoft.com");return t.addScope("profile"),t.addScope("email"),e&&t.setCustomParameters({login_hint:e}),t},oidc:e=>{const t=new le("oidc.main");return e&&t.setCustomParameters({login_hint:e}),t}};function rt(e,t,n){return it[e](t,n)}async function at(e,t,n){if(!t)return{ok:!1,reason:"no-email"};const i=await q(t),r=$();let a,o=e;return i?(i.provider&&(o=i.provider),a=i.label||i.name||void 0,localStorage.setItem("tenantName",a??"")):(localStorage.removeItem("tenantName"),r.tenantId&&(r.tenantId=null)),function(e){try{sessionStorage.setItem(Ke,JSON.stringify(e))}catch{}}({email:t,provider:o,tenantName:a}),oe(r,rt(o,t,n)),{ok:!0}}function ot(e){return"google"===e?"Google":"github"===e?"GitHub":"microsoft"===e?"Microsoft":"Sign In"}function lt(e){const t=function(e){if(!e)return"";const t=e.lastIndexOf("@");return t>0?e.slice(0,t):e}(e),n=t.split(/[._-]+/).filter(Boolean)[0]||"friend";return n.charAt(0).toUpperCase()+n.slice(1).toLowerCase()}function ct(e){let t=e;for(let e=0;null!=t&&e<8;e++){if((t instanceof Error?t.message:String(t)).includes("Customer-domain user requires an invite to join"))return!0;t=t instanceof Error?t.cause:void 0}return!1}function st({provider:n,onCancel:i}){const{t:r}=J(),a=Te(n),o="oidc"===n?r("auth.pending.genericProvider"):ot(n);return t(Oe,{centered:!0,children:[t("div",{children:[e(qe,{children:e(a,{className:"oidc"===n?"size-6 text-info":"size-6"})}),e(Be,{title:r("auth.pending.title",{provider:o}),body:r("auth.pending.body")})]}),t("div",{className:"w-full flex flex-col gap-2",children:[t(Ee,{variant:"loading",children:[e(x,{}),e("span",{children:r("auth.pending.authenticating")})]}),i&&e(Ee,{variant:"ghost",onClick:i,children:r("auth.pending.cancel")})]})]})}function dt({initialEmail:i,onProceed:r}){const{t:l}=J(),[s,d]=a(i??""),[u,m]=a(!1),[p,h]=a(!1),g=c(null);o(()=>{g.current?.focus()},[]);return t(Oe,{children:[e(Be,{eyebrow:l("auth.email.eyebrow"),title:l("auth.email.title"),body:l("auth.email.body")}),t("form",{onSubmit:async e=>{if(e.preventDefault(),!p)if(function(e){return/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test((e||"").trim())}(s)){m(!1),h(!0);try{const e=await q(s.trim().toLowerCase());r(s.trim().toLowerCase(),e??void 0)}catch{r(s.trim().toLowerCase(),void 0)}finally{h(!1)}}else m(!0)},noValidate:!0,className:"flex flex-col "+(u?"gap-2":"gap-6"),children:[e(Ye,{inputRef:g,label:l("auth.email.label"),placeholder:l("auth.email.placeholder"),value:s,onChange:e=>{d(e),u&&m(!1)},invalid:u,error:u?l("auth.email.invalidError"):void 0}),e(Ee,{type:"submit",disabled:p,children:p?e(x,{}):t(n,{children:[e("span",{children:l("auth.continue")}),e(X,{className:"!size-3.5"})]})})]})]})}const ut=["google","github","microsoft"];function mt({email:n,onBack:i,onProviderClicked:r,redirectTo:a}){const{t:o}=J();return t(Oe,{children:[e(Be,{eyebrow:o("auth.providers.eyebrow"),title:o("auth.providers.title"),body:o("auth.providers.bodyConsumer")}),e(Ue,{email:n,actionLabel:o("auth.change"),onAction:i}),e("div",{className:"flex flex-col gap-2",children:ut.map(t=>e(He,{provider:t,label:o("auth.continueWithProvider",{provider:ot(t)}),onClick:()=>(async e=>{r(e),await at(e,n,a)})(t),variant:"arrow"},t))})]})}function pt({session:n,onNotYou:i,onProviderClicked:r,redirectTo:a}){const{t:o}=J(),l=n.name?n.name.split(" ")[0]||n.name:lt(n.email),c=n.name||lt(n.email),s=e($e,{initials:(d=n.email,(d||"?").charAt(0).toUpperCase())});var d;const u=!!n.tenantName,m="oidc"===n.lastProvider?o("auth.continueWithSignIn"):o("auth.continueWithProvider",{provider:ot(n.lastProvider)});return t(Oe,{children:[e(Be,{eyebrow:o("auth.returning.eyebrow"),title:o("auth.returning.title",{name:l}),body:o("auth.returning.body")}),u&&n.tenantName?e(We,{variant:"returning",badge:s,title:c,subtitle:n.tenantName,email:n.email,actionLabel:o("auth.returning.notYou"),onAction:i}):e(Ve,{badge:s,title:c,subtitle:n.email,actionLabel:o("auth.returning.notYou"),onAction:i}),t("div",{className:"flex flex-col gap-2",children:[e(He,{provider:n.lastProvider,label:m,onClick:()=>(async e=>{r(e),await at(e,n.email,a)})(n.lastProvider),variant:"filled"}),e(Ee,{variant:"ghost",onClick:i,children:o("auth.returning.useDifferent")})]})]})}function ht({email:n,tenantName:i,onBack:r}){const{t:a}=J(),o=i||a("auth.blocked.tenantFallback"),l=function(e){if(!e)return"";const t=e.lastIndexOf("@");return t>0?e.slice(t+1):""}(n),c=i||(l?a("auth.blocked.teamFromDomain",{domain:(s=l,s?s.charAt(0).toUpperCase()+s.slice(1):s)}):a("auth.blocked.tenantFallback"));var s;return t(Oe,{children:[e(Be,{variant:"destructive",eyebrow:a("auth.blocked.eyebrow"),title:a("auth.blocked.title"),body:a("auth.blocked.body",{name:o,email:n})}),t("div",{className:"flex flex-col gap-2",children:[e(Je,{icon:ee,title:c,meta:a("auth.blocked.tenantMeta",{email:n})}),e(Ee,{variant:"ghost",onClick:r,children:a("auth.blocked.useDifferent")})]})]})}function gt({provider:t,email:n,redirectTo:i,variant:r="outline",onClick:a}){const{t:o}=J(),l="oidc"===t?o("auth.continueWithSignIn"):o("auth.continueWithProvider",{provider:ot(t)});return e(He,{provider:t,label:l,onClick:()=>{a?.(),n?at(t,n,i):function(e,t){const n=$();localStorage.removeItem("tenantName"),n.tenantId&&(n.tenantId=null),oe(n,rt(e,void 0,t))}(t,i)},variant:r})}function ft({email:n,tenant:i,onBack:r,onProviderClicked:a,redirectTo:o}){const{t:l}=J(),c=i.label||i.name||l("auth.blocked.tenantFallback"),s="google"===i.provider||"github"===i.provider||"microsoft"===i.provider?i.provider:"oidc",d="oidc"===s?l("auth.tenant.viaIdpFallback"):ot(s);return t(Oe,{children:[e(Be,{eyebrow:l("auth.tenant.eyebrow"),title:l("auth.tenant.title",{name:c}),body:l("auth.tenant.body")}),e(We,{variant:"tenant",badge:e($e,{initials:(u=c,u.split(/\s+/).filter(Boolean).slice(0,2).map(e=>e.charAt(0).toUpperCase()).join("")),shape:"square"}),title:c,subtitle:l("auth.tenant.viaIdp",{idp:d}),email:n,actionLabel:l("auth.change"),onAction:r}),t("div",{className:"flex flex-col gap-2",children:[e(gt,{provider:s,email:n,redirectTo:o,variant:"filled",onClick:a}),e(Ee,{variant:"ghost",onClick:r,children:l("auth.tenant.notPartOf",{name:c})})]})]});var u}function vt({onSignup:i,goBack:r}){const{t:l}=J(),[c,s]=a(void 0),[d,u]=a(void 0),[p,g]=a(void 0),[f,v]=a(void 0),[x,N]=a(void 0),[w,k]=a(void 0),[C,S]=a(void 0),j="company"===c,z=[{id:1,label:l("signup.size1to10")},{id:11,label:l("signup.size11to100")},{id:101,label:l("signup.size101to1000")},{id:1001,label:l("signup.size1001to5000")},{id:5001,label:l("signup.size5000plus")}],I=[{id:"personal",label:l("signup.personal"),description:l("signup.personalDescription")},{id:"company",label:l("signup.company"),description:l("signup.companyDescription")}],P=[{id:"testing",label:l("signup.justTesting")},{id:"exploring",label:l("signup.activelyExploring")},{id:"using",label:l("signup.alreadyUsing")},{id:"migrating",label:l("signup.migratingLLMs")},{id:"other",label:l("signup.other")}];o(()=>{const e=$().currentUser;e?k(e):console.error("No user found")},[]);return t("div",{className:"flex flex-col space-y-2",children:[t("div",{className:"prose",children:[e("p",{className:"prose text-sm text-muted pt-4",children:l("signup.welcomeMessage",{name:w?.displayName,email:w?.email})}),C&&e("div",{className:"text-destructive",children:C})]}),e(xt,{label:l("signup.accountType"),children:e(b,{options:I,selected:I.find(e=>e.id===c),onSelect:e=>s(e.id)})}),j&&t(n,{children:[e(xt,{label:l("signup.companySize"),children:e(m,{className:"w-full border border-accent bg-muted",value:d,options:z,onChange:u,optionLabel:e=>e?.label,placeholder:l("signup.selectCompanySize")})}),e(xt,{label:l("signup.companyName"),children:e(y,{value:p,onChange:g,type:"text",required:!0})}),e(xt,{label:l("signup.companyWebsite"),children:e(y,{value:f,onChange:v,type:"text"})})]}),e(xt,{label:l("signup.projectMaturity"),children:e(m,{className:"w-full border border-accent bg-muted",options:P,value:P.find(e=>e.id===x),optionLabel:e=>e?.label,placeholder:l("signup.selectProjectMaturity"),onChange:e=>N(e?.id)})}),t("div",{className:"pt-8 flex flex-col",children:[e(h,{variant:"primary",onClick:async()=>{if(!(c?j&&!p?(S(l("signup.pleaseEnterOrgName")),0):!j||d||(S(l("signup.pleaseSelectCompanySize")),0):(S(l("signup.pleaseSelectAccountType")),0)))return;if(!c)return;const e={accountType:c,companyName:p,companySize:d?.id,companyWebsite:f,maturity:x};window.localStorage.setItem("composableSignupData",JSON.stringify(e));const t=await($().currentUser?.getIdToken());console.log("Got firebase token",$(),t),t?i(e,t):console.error("No firebase token found")},size:"xl",children:e("span",{className:"text-lg",children:l("signup.signUp")})}),e(h,{variant:"ghost",size:"xl",className:"mt-4",onClick:r,children:e("span",{className:"",children:l("signup.wrongAccountGoBack")})})]})]})}function xt({label:n,children:i}){return t("div",{className:"flex flex-col space-y-2 pt-4",children:[e("div",{className:"text-sm text-muted",children:n}),i]})}function bt({allowedPrefix:t,isNested:n=!1,lightLogo:i,darkLogo:r,preservePath:a,suppressAuthErrorPrefix:o}){const l="undefined"==typeof window?"":window.location.pathname,c=yt(l,t),s=yt(l,o);return c?null:e(Nt,{isNested:n,lightLogo:i,darkLogo:r,preservePath:a,suppressAuthError:s})}function yt(e,t){return(Array.isArray(t)?t:t?[t]:[]).some(t=>e===t||e.startsWith(t.endsWith("/")?t:`${t}/`))}function Nt({isNested:n=!1,lightLogo:i,darkLogo:r,preservePath:l,suppressAuthError:c}){const{t:d}=J(),{isLoading:u,user:m,authError:p,signOut:h}=E(),{trackEvent:g}=F(),[f,v]=a(()=>Qe()),[x,b]=a(()=>Qe()?"returning":"email"),[y,N]=a(""),[w,k]=a(void 0),[C,S]=a(null);o(()=>{l||history.replaceState({},"","/")},[l]),o(()=>{if(p)if(p instanceof M)b("signup");else if(ct(p)){const e=Ze();e&&N(e.email),b("blocked")}},[p]),o(()=>{if(!m)return;const e=Ze();e&&(!function(e){try{localStorage.setItem(Ge,JSON.stringify(e))}catch{}}({email:e.email,lastProvider:e.provider,tenantName:e.tenantName,name:m.name||void 0}),et())},[m]);const j=s((e,t)=>{N(e),k(t),b(t?"tenant":"providers")},[]),z=s(()=>{b("email"),k(void 0)},[]),I=s(()=>{Xe(),et(),v(null),N(""),k(void 0),b("email"),h()},[h]),P=s(e=>{(!!w||!!f?.tenantName)&&g("enterprise_signin",{provider:e}),S(e),b("pending")},[g,f?.tenantName,w]),A=s(()=>{v(null),N(""),k(void 0),b("email"),tt()},[]),L=(e,t)=>{const n={signupData:e,firebaseToken:t};fetch(`${ie.endpoints.studio}/auth/signup`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(n)}).then(()=>{g("sign_up"),window.location.href="/"})};if(u||m||c&&void 0!==p&&!(p instanceof M))return null;let T=null;return T="pending"===x&&C?e(st,{provider:C}):"blocked"===x?e(ht,{email:y||f?.email||"",tenantName:w?.label||w?.name||f?.tenantName||void 0,onBack:A}):"signup"!==x||localStorage.getItem("tenantName")?"tenant"===x&&w?e(ft,{email:y,tenant:w,onBack:z,onProviderClicked:()=>P(w.provider??"oidc")}):"providers"===x?e(mt,{email:y,onBack:z,onProviderClicked:P}):"returning"===x&&f?e(pt,{session:f,onNotYou:I,onProviderClicked:P}):e(dt,{initialEmail:y,onProceed:j}):e(vt,{onSignup:L,goBack:A}),e("div",{style:{zIndex:999998},className:(n?"absolute":"fixed")+" inset-0 overflow-y-auto bg-background",children:e("div",{className:"min-h-full flex flex-col items-center justify-center py-12 px-4",children:t("div",{className:"flex flex-col items-center w-full",children:[(i||r)&&t("div",{className:"mb-7",children:[i&&e("img",{src:i,alt:"Vertesia",className:"h-10 block dark:hidden"}),r&&e("img",{src:r,alt:"Vertesia",className:"h-10 hidden dark:block"})]}),T,p&&!(p instanceof M)&&!ct(p)&&e("div",{className:"mt-6 max-w-[420px] text-center text-sm text-muted",children:t("div",{children:[d("auth.signInError"),e("br",{}),d("auth.signInErrorContact"),e("a",{className:"text-info mx-1",href:"mailto:support@vertesiahq.com",children:"support@vertesiahq.com"}),d("auth.signInErrorPersists"),e("pre",{className:"mt-2 text-xs",children:d("auth.error",{message:p.message})})]})}),t("div",{className:"flex items-center gap-5 mt-10 text-xs text-muted-foreground",children:[e("a",{href:"https://vertesiahq.com/privacy",className:"hover:text-foreground transition",children:d("auth.privacyPolicy")}),e("span",{className:"text-border",children:"·"}),e("a",{href:"https://vertesiahq.com/terms",className:"hover:text-foreground transition",children:d("auth.termsOfService")}),e("span",{className:"text-border",children:"·"}),e(re,{className:"cursor-default"})]})]})})})}const wt=new Set(["127.0.0.1","localhost"]);function kt(e){const t=new URLSearchParams(e.search),n=function(e){if(!e)return null;let t,n;try{t=decodeURIComponent(e)}catch{return null}try{n=new URL(t)}catch{return null}return"http:"!==n.protocol?null:n.port?n.username||n.password?null:wt.has(n.hostname)?n.toString():null:null}(t.get("redirect_uri")),i=t.get("code");if(!n||!i)return null;return{redirect:n,code:i,profile:t.get("profile")??"default",project:t.get("project")??void 0,account:t.get("account")??void 0}}function Ct(){const[t,n]=a(),[i,r]=a(),o=kt(de()),l=N(),{t:c}=J(),s=async e=>{if(!o)return;if(!e.profile)return void l({title:c("login.terminal.profileRequired"),description:c("login.terminal.profileRequiredDesc"),status:"error",duration:2e3});if(!e.account)return void l({title:c("login.terminal.accountRequired"),description:c("login.terminal.accountRequiredDesc"),status:"error",duration:2e3});if(!e.project)return void l({title:c("login.terminal.projectRequired"),description:c("login.terminal.projectRequiredDesc"),status:"error",duration:2e3});let t;try{const i=W(),r=i?await V(i,e.account,e.project,86400):await U(e.account,e.project,86400);r?(t={...e,studio_server_url:ie.endpoints.studio,zeno_server_url:ie.endpoints.zeno,token:r},await fetch(o.redirect,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)}),n(t)):l({title:c("login.terminal.failedToGetToken"),status:"error",duration:5e3})}catch(e){t?(r(e instanceof Error?e:new Error(u(e))),n(t)):l({title:c("login.terminal.errorAuthorizingClient"),description:u(e),status:"error",duration:5e3})}},d=o?t?e(jt,{payload:t,error:i}):e(St,{clientInfo:o,onAccept:s}):e(w,{title:c("login.terminal.invalidRequest"),children:c("login.terminal.invalidRequestDesc")});return e("div",{className:"w-full flex flex-col items-center gap-4 mt-24",children:d})}function St({onAccept:i,clientInfo:r}){const{client:a,user:o}=E(),{data:l,error:c}=d(()=>o?a.projects.list():Promise.resolve([]),[o]),{t:s}=J();if(c)return e(w,{title:s("login.terminal.errorLoadingProjects"),children:u(c)});const m=ie.isLocalDev?s("login.terminal.envLocalDev"):ie.isDev?s("login.terminal.envStaging"):s("login.terminal.envProduction");return o&&l?t(n,{children:[t("div",{className:"w-1/3",children:[t("div",{className:"mb-4 text-xl font-semibold text-info",children:["Authorizing client on ",m," environment."]}),t("div",{className:"mb-2 text-md text-muted-foreground",children:[e("div",{children:s("login.terminal.clientWantsAuth")}),t("div",{children:["The client app code is ",e("b",{className:"text-foreground",children:r.code}),". You can check if the code is correct in the terminal."]})]}),t("div",{className:"mb-2 text-sm text-muted-foreground",children:[e("div",{children:s("login.terminal.chooseAccountProject")}),e("div",{children:s("login.terminal.profileNameNote")})]})]}),e(zt,{onAccept:i,allProjects:l,data:r})]}):e(x,{size:"lg"})}function jt({payload:n,error:i}){const r=N(),{t:a}=J();return t("div",{children:[e("div",i?{children:e(w,{title:a("login.terminal.failedToSendToken"),children:a("login.terminal.failedToSendTokenDesc",{error:i.message})})}:{children:a("login.terminal.clientAuthenticated")}),e(p,{className:"mt-4",children:e(h,{variant:"secondary",onClick:()=>{n&&(navigator.clipboard.writeText(JSON.stringify(n)),r({title:a("login.terminal.authPayloadCopied"),description:i?a("login.terminal.authPayloadCopiedWithError",{error:i.message}):a("login.terminal.authPayloadCopiedSuccess"),status:"success",duration:5e3}))},children:a("login.terminal.copyAuthPayload")})})]})}function zt({allProjects:n,data:i,onAccept:r}){const{accounts:o,account:l,project:c}=E(),{t:s}=J(),[d,u]=a(()=>({profile:i.profile,account:i.account??l?.id,project:i.project??c?.id})),m=n.filter(e=>e.account===d.account);return t("div",{className:"w-1/3",children:[t("div",{className:"mb-4 flex flex-col gap-2",children:[e("span",{className:"font-semibold text-muted-foreground",children:s("login.terminal.profileName")}),e(y,{type:"text",value:d.profile,onChange:e=>{u({...d,profile:e})}})]}),t("div",{className:"mb-4 flex flex-col gap-2",children:[e("span",{className:"font-semibold text-muted-foreground",children:s("login.terminal.account")}),e(It,{value:d.account,onChange:e=>{u({...d,account:e.id,project:void 0})},accounts:o||[]})]}),t("div",{className:"mb-4 flex flex-col gap-2",children:[e("span",{className:"font-semibold text-muted-foreground",children:s("login.terminal.project")}),e(Pt,{value:d.project,onChange:e=>{u({...d,project:e.id})},projects:m})]}),e("div",{className:"mb-4 text-sm text-attention",children:s("login.terminal.browserPermissionNote")}),e("div",{children:e(h,{size:"xl",onClick:()=>r(d),children:s("login.terminal.authorizeClient")})})]})}function It({value:t,accounts:n,onChange:i}){const{t:r}=J();return e(m,{options:n,value:n?.find(e=>e.id===t),onChange:e=>{i(e)},by:"id",optionLabel:e=>e.name,placeholder:r("login.terminal.selectAccount")})}function Pt({value:t,projects:n,onChange:i}){const{t:r}=J();return e(m,{by:"id",value:n.find(e=>e.id===t),options:n,optionLabel:e=>e.name,placeholder:r("login.terminal.selectProject"),onChange:e=>{i(e)}})}function At({isOpen:n,onClose:i}){return t(g,{isOpen:n,onClose:i,children:[e(f,{children:"Sign In"}),t(v,{className:"flex flex-col gap-2",children:[e(gt,{provider:"google"}),e(gt,{provider:"github"}),e(gt,{provider:"microsoft"})]}),e(k,{align:"right",children:e(h,{variant:"ghost",onClick:i,children:"Cancel"})})]})}function Lt({title:n,value:i}){const[r,o]=a(!1);return t("div",{className:"w-full flex justify-between items-center mb-1",children:[t("div",{className:"flex flex-col w-[calc(100%-3rem)]",children:[e("div",{className:"text-sm px-2 dark:text-slate-200",children:n}),e(z,{description:i,size:"xs",placement:"left",children:t("div",{className:"text-xs truncate text-muted w-full text-start px-2",children:[i," "]})})]}),r?e(te,{className:"size-4 cursor-pointer text-success"}):e(ne,{className:"size-4 cursor-pointer text-gray-400 dark:text-slate-400",onClick:()=>function(e){navigator.clipboard.writeText(e),o(!0),setTimeout(()=>o(!1),2e3)}(i)})]})}function Tt(){const{t:n}=J(),i=E(),{account:r,project:a,client:o,authToken:l}=i,c=o.baseUrl,s=o.store.baseUrl,d=s.replace(/\/+$/,"")!==c.replace(/\/+$/,""),u=ie.endpoints.mcp??n("user.unknown"),m=a?me(a):"",p=[{name:"user",label:n("user.user"),content:t("div",{className:"space-y-1 p-2",children:[e(Lt,{title:n("user.organizationId"),value:r?.id??n("user.unknown")}),e(Lt,{title:n("user.projectId"),value:a?.id??n("user.unknown")}),e(Lt,{title:n("user.userId"),value:l?.sub??n("user.unknown")}),e(Lt,{title:n("user.organizationRoles"),value:l?.account_roles?.join(",")??n("user.unknown")}),e(Lt,{title:n("user.projectRoles"),value:l?.project_roles?.join(",")??n("user.unknown")})]})},{name:"environment",label:n("user.environment"),content:t("div",{className:"space-y-1 p-2",children:[e(Lt,{title:n("user.tenantId"),value:m}),e(Lt,{title:n("user.environment"),value:ie.type}),e(Lt,{title:n("user.server"),value:c}),d&&e(Lt,{title:n("user.store"),value:s}),e(Lt,{title:n("user.mcpServer"),value:u}),e(Lt,{title:n("user.appVersion"),value:ie.version}),e(Lt,{title:n("user.sdkVersion"),value:ie.sdkVersion||n("user.unknown")})]})}];return e("div",{className:"w-full",children:t(C,{defaultValue:"user",tabs:p,fullWidth:!0,updateHash:!1,children:[e(S,{}),e(j,{})]})})}function Ot(i){const{user:r,isLoading:o}=E(),[l,c]=a(!1);return o?e(x,{}):r?e("div",{className:"px-3",children:e(Bt,{asMenuTrigger:!0})}):t(n,{children:[e(h,{onClick:()=>c(!0),children:"Sign In"}),e(At,{isOpen:l,onClose:()=>c(!1)})]})}function Bt({className:n,asMenuTrigger:i=!1}){const r=E(),a=ue(),o=he(),{user:l}=r;if(!r||!l)return null;const c=o.hasPermission(pe.project_admin);return t(I,{click:!0,children:[e(P,{children:e("div",{className:ve(n,"flex items-center justify-start",i&&"cursor-pointer"),children:e(A,{size:"sm",color:"bg-amber-500",shape:"circle",name:l?.name})})}),e(L,{align:"start",className:"w-[280px] mx-2 my-1 p-0",children:t("div",{className:"divide-y divide-gray-200 dark:divide-slate-700",children:[t("div",{className:"py-2 ps-2",children:[e("p",{className:"px-4 dark:text-white mb-1",children:l?.name??"Unknown"}),e("p",{className:"px-4 text-xs text-gray-500",children:l?.email??""})]}),e("div",{className:"w-full p-1",children:e(Tt,{})}),e("div",{className:"py-2 ps-2",children:e(T,{})}),e("div",{className:"py-2",children:t(O,{children:[c&&e(O.Item,{className:"px-2",onClick:()=>a("/settings",{replace:!0}),children:"Settings"}),e(O.Item,{className:"px-2",onClick:()=>r.logout(),children:"Sign out"})]})})]})})]})}function Rt(e){return!!e&&(e.endsWith("@vertesiahq.com")||e.endsWith("@becomposable.com")||e.endsWith("@composableprompts.com"))}function Et({icon:t}){const{isLoading:n}=E(),[i,r]=a(!0);return o(()=>{n||r(!1)},[n]),e(xe,{children:i&&e(be.div,{style:{zIndex:999999,position:"fixed",inset:0},className:"fixed inset-x-0 inset-y-0",initial:{opacity:1},exit:{opacity:0},transition:{ease:"easeIn",duration:.5},children:e("div",{style:{display:"flex",width:"100%",height:"100%",alignItems:"center",justifyContent:"center"},className:"flex w-full h-full items-center justify-center",children:e("div",{className:"animate-[spin_4s_linear_infinite]",children:e("div",{className:"animate-pulse rounded-full bg-transparent",children:t||e(Dt,{})})})})})})}function Dt(){return t("svg",{width:"32",height:"32",className:"w-8 h-8 text-indigo-600",viewBox:"0 0 50 50",xmlns:"http://www.w3.org/2000/svg",role:"img","aria-label":"Loading",children:[e("title",{children:"Loading"}),e("defs",{children:t("linearGradient",{id:"spinner-gradient",x1:"1",y1:"0",x2:"0",y2:"1",children:[e("stop",{offset:"0%",stopColor:"currentColor",stopOpacity:"1"}),e("stop",{offset:"100%",stopColor:"currentColor",stopOpacity:"0"})]})}),e("circle",{cx:"25",cy:"25",r:"20",stroke:"url(#spinner-gradient)",strokeWidth:"5",fill:"none",strokeLinecap:"round"})]})}function _t({children:n,lightLogo:i,darkLogo:r,loadingIcon:a,loadOnboardingStatus:o,preserveSignInPath:l,suppressSignInErrorPrefixes:c,defaultLanguage:s}){return e(B,{children:e(H,{loadOnboardingStatus:o,children:e(ge,{children:e(R,{defaultTheme:"system",storageKey:"vite-ui-theme",children:e(Y,{defaultLanguage:s,children:t(G,{children:[e(Et,{icon:a}),e(bt,{allowedPrefix:"/shared/",darkLogo:r,lightLogo:i,preservePath:l,suppressAuthErrorPrefix:c}),e(fe,{children:n})]})})})})})})}export{ye as AppInstallationContext,Ne as AppInstallationProvider,ke as AppProjectSelector,Pe as InviteAcceptModal,bt as SigninScreen,Se as StandaloneApp,je as StandaloneAppImpl,Ct as TerminalLogin,Ot as UserSessionMenu,_t as VertesiaShell,Rt as isVertesiaEmail,we as useAppInstallation};
|
|
1
|
+
import{jsx as e,jsxs as t,Fragment as n}from"react/jsx-runtime";import{createContext as i,useContext as r,useState as a,useEffect as o,useMemo as l,useRef as c,useCallback as s}from"react";import{useFetch as d,errorMessage as u,SelectBox as m,Center as p,Button as h,Modal as g,ModalTitle as f,ModalBody as v,Spinner as x,RadioGroup as b,Input as y,useToast as N,ErrorBox as w,ModalFooter as k,Tabs as C,TabsBar as S,TabsPanel as j,VTooltip as z,Popover as I,PopoverTrigger as P,Avatar as A,PopoverContent as L,ModeToggle as T,MenuList as O,ToastProvider as B,ThemeProvider as R}from"@vertesia/ui/core";import{useUserSession as E,LastSelectedAccountId_KEY as D,LastSelectedProjectId_KEY as _,getFirebaseAuth as $,setFirebaseTenant as q,useUXTracking as F,UserNotFoundError as M,getCurrentVertesiaToken as W,fetchComposableTokenFromVertesiaToken as V,fetchComposableTokenFromFirebaseToken as U,UserSessionProvider as H}from"@vertesia/ui/session";import{useUITranslation as J,LanguageProvider as Y,LanguageBoundI18nProvider as G}from"@vertesia/ui/i18n";import{LockIcon as K,LockKeyhole as Q,ArrowRight as X,Mail as Z,ShieldOff as ee,Check as te,CopyIcon as ne}from"lucide-react";import{Env as ie}from"@vertesia/ui/env";import{RegionTag as re}from"@vertesia/ui/layout";import{signOut as ae,signInWithRedirect as oe,OAuthProvider as le,GithubAuthProvider as ce,GoogleAuthProvider as se}from"firebase/auth";import{useLocation as de,useNavigate as ue}from"@vertesia/ui/router";import{getTenantIdFromProject as me,Permission as pe}from"@vertesia/common";import{useUserPermissions as he,TypeRegistryProvider as ge,UserPermissionProvider as fe}from"@vertesia/ui/features";import ve from"clsx";import{AnimatePresence as xe,motion as be}from"framer-motion";const ye=i(null);function Ne({installation:t,children:n}){return e(ye.Provider,{value:t,children:n})}function we(){return r(ye)}function ke({app:n,onChange:i,placeholder:r}){const{client:a,project:o}=E(),{data:l,error:c}=d(()=>a.apps.getAppInstallationProjects(n),[n.id,n.name]);return c?t("span",{className:"text-red-600",children:["Error: failed to fetch projects: ",u(c)]}):e(Ce,{placeholder:r,initialValue:o?.id,projects:l||[],onChange:e=>{i&&!i(e)||(localStorage.setItem(D,e.account),localStorage.setItem(`${_}-${e.account}`,e.id),window.location.reload())}})}function Ce({initialValue:t,projects:n,onChange:i,placeholder:r="Select Project"}){const[o,l]=a(),c=!o&&t?n.find(e=>e.id===t):o;return e(m,{by:"id",value:c,options:n,optionLabel:e=>e.name,placeholder:r,onChange:e=>{l(e),i(e)}})}function Se({name:t,AccessDenied:n=ze,children:i}){return t?e(je,{name:t,AccessDenied:n,children:i}):e(Ie,{})}function je({name:t,AccessDenied:n=ze,children:i}){const{authToken:r,client:l}=E(),[c,s]=a(null),[d,u]=a("loading");return o(()=>{if(r){r.apps.includes(t)?l.apps.getAppInstallationByName(t).then(e=>{e?(u("loaded"),s(e)):(console.log(`App ${t} not found!`),u("error"))}):u("error")}else u("loading")},[t,r,l.apps.getAppInstallationByName]),"loading"===d?null:"error"===d?e(n,{name:t}):c?e(Ne,{installation:c,children:i}):void 0}function ze({name:n}){const{project:i,accounts:r,client:c}=E(),{t:s}=J(),[u,h]=a(),{data:g}=d(()=>c.apps.getAppInstallationProjects({name:n}),[n]),{projectsByOrg:f,orgOptions:v}=l(()=>{if(!g||!r)return{projectsByOrg:{},orgOptions:[]};const e={};for(const t of g)e[t.account]||(e[t.account]=[]),e[t.account].push(t);const t=r.filter(t=>e[t.id]?.length>0);return{projectsByOrg:e,orgOptions:t}},[g,r]);o(()=>{!u&&v.length>0&&h(v[0].id)},[v,u]);const x=u&&f[u]||[],b=v.find(e=>e.id===u);return t(p,{className:"pt-10 flex flex-col items-center text-center text-gray-700",children:[e(K,{className:"w-10 h-10 mb-4 text-gray-500"}),e("div",{className:"text-xl font-semibold",children:s("shell.accessDenied")}),t("div",{className:"mt-2 text-sm text-gray-500",children:["You don't have permission to view the ",e("span",{className:"font-semibold",children:n})," app in project:"," ",t("span",{className:"font-semibold",children:["«",i?.name,"»"]}),"."]}),0===v.length&&void 0!==g&&e("div",{className:"mt-4 text-sm text-gray-500",children:"This app is not installed in any project you have access to."}),v.length>0&&t("div",{className:"mt-4 flex flex-row gap-4 items-end",children:[v.length>1&&t("div",{children:[e("div",{className:"text-sm text-gray-500 mb-2",children:s("shell.organization")}),e(m,{by:"id",value:b,options:v,optionLabel:e=>e.name,placeholder:s("shell.selectOrganization"),onChange:e=>h(e.id)})]}),t("div",{children:[v.length>1&&e("div",{className:"text-sm text-gray-500 mb-2",children:s("login.terminal.project")}),e(m,{by:"id",value:void 0,options:x,optionLabel:e=>e.name,placeholder:s("shell.selectProject"),onChange:e=>{localStorage.setItem(D,e.account),localStorage.setItem(`${_}-${e.account}`,e.id),window.location.reload()}})]})]})]})}function Ie(){const{t:n}=J();return t(p,{className:"pt-10 flex flex-col items-center text-center text-gray-700",children:[e(K,{className:"w-10 h-10 mb-4 text-gray-500"}),e("div",{className:"text-xl font-semibold",children:n("shell.applicationNotRegistered")}),t("div",{className:"mt-2 text-sm text-gray-500",children:["Before starting to code a Vertesia application you must register an application manifest in Vertesia Studio then install it in one or more projects.",e("p",{}),"Then use the created app name as a parameter to"," ",e("code",{children:'<StandaloneApp name="your-app-name">'})," in the ",e("code",{children:"src/main.tsx"})," file."]})]})}function Pe(){const n=E(),{client:i}=n,{t:r}=J(),[l,c]=a(!1),[s,d]=a([]);o(()=>{i.account.listInvites().then(e=>{if(e.length>0){const t=e.filter(e=>e.data.account);if(0===t.length)return void console.log("No valid invites found, closing modal");console.log("Found valid invites",t.length),c(!0),d(t)}else console.log("No invites found, closing modal"),c(!1)}).catch(e=>{console.error("Error fetching invites",e)})},[i.account.listInvites]);const u=()=>c(!1),m=s.map(a=>a.data.account?t("div",{className:"flex flex-row w-full justify-between border rounded-sm px-2 py-2 ",children:[t("div",{className:"flex flex-col",children:[e("div",{className:"w-full font-semibold",children:a.data.account.name??a.data.account}),a.data.project&&t("div",{className:"w-full text-base",children:["- ",a.data.project.name]}),t("div",{className:"text-xs",children:["Role: ",a.data.role]}),a.data.invited_by&&t("div",{className:"text-xs",children:["by ",a.data.invited_by.name??a.data.invited_by]})]}),t("div",{className:"flex flex-col gap-4",children:[e(h,{size:"xs",onClick:()=>(async e=>{await i.account.acceptInvite(e.id),await n.authCallback,await n.fetchAccounts(),await n.fetchProjects(e.data.account.id);const t=s.filter(t=>t.id!==e.id).filter(e=>e.data.account);t.length>0?d(t):u()})(a),children:r("login.accept")})," ",e(h,{size:"xs",variant:"secondary",onClick:()=>(async e=>{await i.account.rejectInvite(e.id);const t=s.filter(t=>t.id!==e.id);d(t),0===t.length&&u()})(a),children:r("login.reject")})]})]},a.id):(console.warn("Invite has no account data",a),null));return e("div",{children:t(g,{isOpen:l,onClose:u,children:[e(f,{children:r("login.reviewInvites")}),t(v,{children:[e("div",{className:"text-sm pb-4",children:"You have received the following invites to join other accounts. Please review and accept or declined them."}),m]})]})})}const Ae=Q,Le={google:function(n){return t("svg",{viewBox:"0 0 48 48","aria-hidden":"true",...n,children:[e("path",{fill:"#FFC107",d:"M43.6 20.5H42V20H24v8h11.3c-1.6 4.7-6.1 8-11.3 8a12 12 0 0 1 0-24c3 0 5.8 1.1 7.9 3l5.7-5.7A20 20 0 1 0 24 44c11 0 20-9 20-20 0-1.2-.1-2.3-.4-3.5z"}),e("path",{fill:"#FF3D00",d:"M6.3 14.7l6.6 4.8A12 12 0 0 1 24 12c3 0 5.8 1.1 7.9 3l5.7-5.7A20 20 0 0 0 6.3 14.7z"}),e("path",{fill:"#4CAF50",d:"M24 44c5.2 0 10-2 13.6-5.2l-6.3-5.3A12 12 0 0 1 12.7 28.5l-6.6 5.1A20 20 0 0 0 24 44z"}),e("path",{fill:"#1976D2",d:"M43.6 20.5H42V20H24v8h11.3a12 12 0 0 1-4 5.5l6.3 5.3C37.9 36.6 44 31 44 24c0-1.2-.1-2.3-.4-3.5z"})]})},github:function(t){return e("svg",{viewBox:"0 0 24 24","aria-hidden":"true",...t,children:e("path",{fill:"currentColor",fillRule:"evenodd",clipRule:"evenodd",d:"M12 2C6.48 2 2 6.58 2 12.25c0 4.54 2.87 8.39 6.84 9.75.5.09.68-.22.68-.49v-1.7c-2.78.62-3.37-1.36-3.37-1.36-.46-1.18-1.11-1.5-1.11-1.5-.91-.63.07-.62.07-.62 1 .07 1.53 1.05 1.53 1.05.89 1.57 2.34 1.12 2.91.86.09-.66.35-1.12.63-1.38-2.22-.26-4.56-1.14-4.56-5.07 0-1.12.39-2.03 1.03-2.75-.1-.26-.45-1.3.1-2.7 0 0 .84-.28 2.76 1.05A9.4 9.4 0 0 1 12 7.07c.85 0 1.71.12 2.51.34 1.91-1.33 2.75-1.05 2.75-1.05.55 1.4.2 2.44.1 2.7.64.72 1.03 1.63 1.03 2.75 0 3.94-2.34 4.81-4.57 5.06.36.32.68.94.68 1.9v2.81c0 .27.18.59.69.49C19.13 20.64 22 16.78 22 12.25 22 6.58 17.52 2 12 2z"})})},microsoft:function(n){return t("svg",{viewBox:"0 0 24 24","aria-hidden":"true",...n,children:[e("path",{fill:"#F25022",d:"M2 2h9.5v9.5H2z"}),e("path",{fill:"#7FBA00",d:"M12.5 2H22v9.5h-9.5z"}),e("path",{fill:"#00A4EF",d:"M2 12.5h9.5V22H2z"}),e("path",{fill:"#FFB900",d:"M12.5 12.5H22V22h-9.5z"})]})},oidc:Ae};function Te(e){return e&&e in Le?Le[e]:Ae}function Oe({children:t,centered:n=!1}){return e("div",{className:n?"w-full max-w-[420px] flex flex-col gap-6 items-center text-center":"w-full max-w-[420px] flex flex-col gap-6",children:t})}function Be({eyebrow:n,title:i,body:r,variant:a="info"}){return t("div",{children:[n&&e("div",{className:`${"destructive"===a?"text-destructive":"text-info"} text-[12.5px] font-medium mb-2`,children:n}),e("h1",{className:"text-foreground text-[22px] font-semibold tracking-tight leading-tight mb-1.5",children:i}),r&&e("p",{className:"text-muted text-sm leading-relaxed",children:r})]})}const Re={primary:"h-[42px] gap-2.5 rounded-md bg-foreground text-background hover:opacity-90 disabled:opacity-50 disabled:cursor-not-allowed",loading:"h-[42px] gap-2.5 rounded-md bg-foreground text-background opacity-90",ghost:"h-9 text-muted hover:text-foreground"};function Ee({variant:t="primary",className:n="",type:i="button",disabled:r,...a}){return e(h,{variant:"unstyled",size:"none",type:i,disabled:"loading"===t||r,className:`cursor-pointer inline-flex items-center justify-center text-sm font-medium transition ${Re[t]} ${n}`.trim(),...a})}function De({size:t="xs",className:n="",type:i="button",...r}){const a=`cursor-pointer ${"smaller"===t?"!text-[11px]":"!text-xs"} text-muted hover:text-foreground !transition px-2 py-1 !rounded underline decoration-transparent hover:decoration-current underline-offset-[3px]`;return e(h,{variant:"unstyled",size:"none",type:i,className:n?`${a} ${n}`:a,...r})}const _e={circle:"size-9 rounded-full text-sm ring-4 ring-background ring-offset-1 ring-offset-border",square:"size-[30px] rounded-md text-[11px]"};function $e({initials:t,shape:n="circle"}){return e("span",{className:`bg-info text-info-foreground grid place-items-center font-semibold shrink-0 ${_e[n]}`,children:t})}function qe({children:t}){return e("div",{className:"inline-grid place-items-center size-14 rounded-xl bg-info-background border border-info/15 mb-3.5",children:t})}function Fe({title:n,subtitle:i,titleClass:r,subtitleClass:a}){return t("div",{className:"flex-1 min-w-0",children:[e("div",{className:r,children:n}),e("div",{className:a,children:i})]})}const Me={tenant:{topRow:"flex items-center gap-2.5 px-3 py-2.5",title:"text-[13.5px] font-semibold text-foreground leading-tight",subtitle:"text-[11.5px] text-muted leading-tight mt-0.5",bottomRow:"flex items-center gap-2.5 px-3 py-1.5 border-t border-border bg-muted-background",mailBox:"size-[30px] grid place-items-center shrink-0",mailIcon:"size-4 text-muted",email:"text-sm text-foreground/80 flex-1 truncate",actionSize:"xs"},returning:{topRow:"flex items-center gap-3 px-3.5 py-2.5",title:"text-sm font-semibold text-foreground truncate",subtitle:"text-xs text-foreground/80 truncate",bottomRow:"flex items-center gap-3 px-3.5 py-1 border-t border-border bg-muted-background",mailBox:"w-9 h-6 grid place-items-center shrink-0",mailIcon:"size-3.5 text-muted",email:"text-xs text-foreground/80 flex-1 truncate",actionSize:"smaller"}};function We({variant:n="returning",badge:i,title:r,subtitle:a,email:o,actionLabel:l,onAction:c}){const s=Me[n];return t("div",{className:"rounded-md border border-border bg-background overflow-hidden",children:[t("div",{className:s.topRow,children:[i,e(Fe,{title:r,subtitle:a,titleClass:s.title,subtitleClass:s.subtitle})]}),t("div",{className:s.bottomRow,children:[e("div",{className:s.mailBox,children:e(Z,{className:s.mailIcon})}),e("span",{className:s.email,children:o}),e(De,{size:s.actionSize,onClick:c,children:l})]})]})}function Ve({badge:n,title:i,subtitle:r,actionLabel:a,onAction:o}){return t("div",{className:"flex items-center gap-3 px-3.5 py-2.5 rounded-md border border-border bg-muted-background",children:[n,e(Fe,{title:i,subtitle:r,titleClass:"text-sm font-semibold text-foreground truncate",subtitleClass:"text-xs text-muted truncate"}),e(De,{onClick:o,children:a})]})}function Ue({email:n,actionLabel:i,onAction:r}){return t("div",{className:"flex items-center gap-2 px-3 py-2 rounded-md border border-border bg-muted-background",children:[e(Z,{className:"size-4 text-muted shrink-0"}),e("span",{className:"text-sm text-foreground/80 flex-1 truncate",children:n}),e(De,{onClick:r,children:i})]})}function He({provider:n,label:i,onClick:r,variant:a="outline"}){const o=Te(n);if("arrow"===a){const n="!size-3.5 text-muted opacity-0 group-hover:opacity-100 group-hover:translate-x-0.5 rtl:group-hover:-translate-x-0.5 transition";return t(h,{variant:"unstyled",size:"none",onClick:r,className:"cursor-pointer group h-[42px] w-full inline-flex items-center gap-3 ps-3.5 pe-3 rounded-md border border-border bg-background text-sm font-medium text-foreground transition hover:bg-muted-background",children:[e(o,{className:"!size-[18px] shrink-0"}),e("span",{className:"flex-1 text-start",children:i}),e(X,{className:n})]})}return t(h,{variant:"outline",onClick:r,className:`w-full py-5 flex rounded-lg transition duration-150 text-center ${"filled"===a?"!bg-foreground text-background hover:!bg-foreground/90":"hover:shadow-sm"}`,children:[e(o,{className:"!size-[18px]"}),e("span",{className:"text-sm font-medium",children:i})]})}function Je({icon:n,title:i,meta:r}){return t("div",{className:"flex items-center gap-2.5 px-3 py-2.5 rounded-md bg-destructive-background border border-destructive/20",children:[e(n,{className:"size-5 text-destructive shrink-0"}),t("div",{className:"flex-1 min-w-0 text-sm",children:[e("div",{className:"font-semibold text-destructive",children:i}),e("div",{className:"text-xs text-destructive/80",children:r})]})]})}function Ye({inputRef:n,label:i,placeholder:r,value:a,onChange:o,invalid:l=!1,error:c}){return t("div",{className:"flex flex-col gap-1.5",children:[e("label",{htmlFor:"vt-login-email",className:"text-xs font-medium text-foreground/80",children:i}),e("input",{ref:n,id:"vt-login-email",name:"vt-login-email",type:"email",className:"h-[42px] px-3.5 rounded-md border border-border bg-background text-sm text-foreground placeholder:text-muted-foreground outline-none transition focus:border-info focus:ring-4 focus:ring-info/15 aria-[invalid=true]:border-destructive aria-[invalid=true]:ring-destructive/15",placeholder:r,value:a,onChange:e=>o(e.target.value),"aria-invalid":l,autoComplete:"off",autoCorrect:"off",autoCapitalize:"off",spellCheck:!1,"data-1p-ignore":!0,"data-lpignore":"true","data-form-type":"other"}),c&&e("div",{role:"alert",className:"text-xs text-destructive",children:c})]})}const Ge="vt.lastSuccessfulLogin",Ke="vt.pendingSignin";function Qe(){try{const e=localStorage.getItem(Ge);if(!e)return null;const t=JSON.parse(e);return t?.email&&t?.lastProvider?t:null}catch{return null}}function Xe(){try{localStorage.removeItem(Ge)}catch{}}function Ze(){try{const e=sessionStorage.getItem(Ke);return e?JSON.parse(e):null}catch{return null}}function et(){try{sessionStorage.removeItem(Ke)}catch{}}async function tt(){Xe(),et();try{await ae($())}catch{}}function nt(e){let t=e||window.location.pathname||"/";return"/"!==t[0]&&(t=`/${t}`),t}const it={google:(e,t)=>{const n=new se;return n.addScope("profile"),n.addScope("email"),n.setCustomParameters({redirect_uri:window.location.origin+nt(t),...e?{login_hint:e}:{prompt:"select_account"}}),n},github:e=>{const t=new ce;return t.addScope("profile"),t.addScope("email"),e&&t.setCustomParameters({login:e}),t},microsoft:e=>{const t=new le("microsoft.com");return t.addScope("profile"),t.addScope("email"),e&&t.setCustomParameters({login_hint:e}),t},oidc:e=>{const t=new le("oidc.main");return e&&t.setCustomParameters({login_hint:e}),t}};function rt(e,t,n){return it[e](t,n)}async function at(e,t,n){if(!t)return{ok:!1,reason:"no-email"};const i=await q(t),r=$();let a,o=e;return i?(i.provider&&(o=i.provider),a=i.label||i.name||void 0,localStorage.setItem("tenantName",a??"")):(localStorage.removeItem("tenantName"),r.tenantId&&(r.tenantId=null)),function(e){try{sessionStorage.setItem(Ke,JSON.stringify(e))}catch{}}({email:t,provider:o,tenantName:a}),oe(r,rt(o,t,n)),{ok:!0}}function ot(e){return"google"===e?"Google":"github"===e?"GitHub":"microsoft"===e?"Microsoft":"Sign In"}function lt(e){const t=function(e){if(!e)return"";const t=e.lastIndexOf("@");return t>0?e.slice(0,t):e}(e),n=t.split(/[._-]+/).filter(Boolean)[0]||"friend";return n.charAt(0).toUpperCase()+n.slice(1).toLowerCase()}function ct(e){let t=e;for(let e=0;null!=t&&e<8;e++){if((t instanceof Error?t.message:String(t)).includes("Customer-domain user requires an invite to join"))return!0;t=t instanceof Error?t.cause:void 0}return!1}function st({provider:n,onCancel:i}){const{t:r}=J(),a=Te(n),o="oidc"===n?r("auth.pending.genericProvider"):ot(n);return t(Oe,{centered:!0,children:[t("div",{children:[e(qe,{children:e(a,{className:"oidc"===n?"size-6 text-info":"size-6"})}),e(Be,{title:r("auth.pending.title",{provider:o}),body:r("auth.pending.body")})]}),t("div",{className:"w-full flex flex-col gap-2",children:[t(Ee,{variant:"loading",children:[e(x,{}),e("span",{children:r("auth.pending.authenticating")})]}),i&&e(Ee,{variant:"ghost",onClick:i,children:r("auth.pending.cancel")})]})]})}function dt({initialEmail:i,onProceed:r}){const{t:l}=J(),[s,d]=a(i??""),[u,m]=a(!1),[p,h]=a(!1),g=c(null);o(()=>{g.current?.focus()},[]);return t(Oe,{children:[e(Be,{eyebrow:l("auth.email.eyebrow"),title:l("auth.email.title"),body:l("auth.email.body")}),t("form",{onSubmit:async e=>{if(e.preventDefault(),!p)if(function(e){return/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test((e||"").trim())}(s)){m(!1),h(!0);try{const e=await q(s.trim().toLowerCase());r(s.trim().toLowerCase(),e??void 0)}catch{r(s.trim().toLowerCase(),void 0)}finally{h(!1)}}else m(!0)},noValidate:!0,className:"flex flex-col "+(u?"gap-2":"gap-6"),children:[e(Ye,{inputRef:g,label:l("auth.email.label"),placeholder:l("auth.email.placeholder"),value:s,onChange:e=>{d(e),u&&m(!1)},invalid:u,error:u?l("auth.email.invalidError"):void 0}),e(Ee,{type:"submit",disabled:p,children:p?e(x,{}):t(n,{children:[e("span",{children:l("auth.continue")}),e(X,{className:"!size-3.5"})]})})]})]})}const ut=["google","github","microsoft"];function mt({email:n,onBack:i,onProviderClicked:r,redirectTo:a}){const{t:o}=J();return t(Oe,{children:[e(Be,{eyebrow:o("auth.providers.eyebrow"),title:o("auth.providers.title"),body:o("auth.providers.bodyConsumer")}),e(Ue,{email:n,actionLabel:o("auth.change"),onAction:i}),e("div",{className:"flex flex-col gap-2",children:ut.map(t=>e(He,{provider:t,label:o("auth.continueWithProvider",{provider:ot(t)}),onClick:()=>(async e=>{r(e),await at(e,n,a)})(t),variant:"arrow"},t))})]})}function pt({session:n,onNotYou:i,onProviderClicked:r,redirectTo:a}){const{t:o}=J(),l=n.name?n.name.split(" ")[0]||n.name:lt(n.email),c=n.name||lt(n.email),s=e($e,{initials:(d=n.email,(d||"?").charAt(0).toUpperCase())});var d;const u=!!n.tenantName,m="oidc"===n.lastProvider?o("auth.continueWithSignIn"):o("auth.continueWithProvider",{provider:ot(n.lastProvider)});return t(Oe,{children:[e(Be,{eyebrow:o("auth.returning.eyebrow"),title:o("auth.returning.title",{name:l}),body:o("auth.returning.body")}),u&&n.tenantName?e(We,{variant:"returning",badge:s,title:c,subtitle:n.tenantName,email:n.email,actionLabel:o("auth.returning.notYou"),onAction:i}):e(Ve,{badge:s,title:c,subtitle:n.email,actionLabel:o("auth.returning.notYou"),onAction:i}),t("div",{className:"flex flex-col gap-2",children:[e(He,{provider:n.lastProvider,label:m,onClick:()=>(async e=>{r(e),await at(e,n.email,a)})(n.lastProvider),variant:"filled"}),e(Ee,{variant:"ghost",onClick:i,children:o("auth.returning.useDifferent")})]})]})}function ht({email:n,tenantName:i,onBack:r}){const{t:a}=J(),o=i||a("auth.blocked.tenantFallback"),l=function(e){if(!e)return"";const t=e.lastIndexOf("@");return t>0?e.slice(t+1):""}(n),c=i||(l?a("auth.blocked.teamFromDomain",{domain:(s=l,s?s.charAt(0).toUpperCase()+s.slice(1):s)}):a("auth.blocked.tenantFallback"));var s;return t(Oe,{children:[e(Be,{variant:"destructive",eyebrow:a("auth.blocked.eyebrow"),title:a("auth.blocked.title"),body:a("auth.blocked.body",{name:o,email:n})}),t("div",{className:"flex flex-col gap-2",children:[e(Je,{icon:ee,title:c,meta:a("auth.blocked.tenantMeta",{email:n})}),e(Ee,{variant:"ghost",onClick:r,children:a("auth.blocked.useDifferent")})]})]})}function gt({provider:t,email:n,redirectTo:i,variant:r="outline",onClick:a}){const{t:o}=J(),l="oidc"===t?o("auth.continueWithSignIn"):o("auth.continueWithProvider",{provider:ot(t)});return e(He,{provider:t,label:l,onClick:()=>{a?.(),n?at(t,n,i):function(e,t){const n=$();localStorage.removeItem("tenantName"),n.tenantId&&(n.tenantId=null),oe(n,rt(e,void 0,t))}(t,i)},variant:r})}function ft({email:n,tenant:i,onBack:r,onProviderClicked:a,redirectTo:o}){const{t:l}=J(),c=i.label||i.name||l("auth.blocked.tenantFallback"),s="google"===i.provider||"github"===i.provider||"microsoft"===i.provider?i.provider:"oidc",d="oidc"===s?l("auth.tenant.viaIdpFallback"):ot(s);return t(Oe,{children:[e(Be,{eyebrow:l("auth.tenant.eyebrow"),title:l("auth.tenant.title",{name:c}),body:l("auth.tenant.body")}),e(We,{variant:"tenant",badge:e($e,{initials:(u=c,u.split(/\s+/).filter(Boolean).slice(0,2).map(e=>e.charAt(0).toUpperCase()).join("")),shape:"square"}),title:c,subtitle:l("auth.tenant.viaIdp",{idp:d}),email:n,actionLabel:l("auth.change"),onAction:r}),t("div",{className:"flex flex-col gap-2",children:[e(gt,{provider:s,email:n,redirectTo:o,variant:"filled",onClick:a}),e(Ee,{variant:"ghost",onClick:r,children:l("auth.tenant.notPartOf",{name:c})})]})]});var u}function vt({onSignup:i,goBack:r}){const{t:l}=J(),[c,s]=a(void 0),[d,u]=a(void 0),[p,g]=a(void 0),[f,v]=a(void 0),[x,N]=a(void 0),[w,k]=a(void 0),[C,S]=a(void 0),j="company"===c,z=[{id:1,label:l("signup.size1to10")},{id:11,label:l("signup.size11to100")},{id:101,label:l("signup.size101to1000")},{id:1001,label:l("signup.size1001to5000")},{id:5001,label:l("signup.size5000plus")}],I=[{id:"personal",label:l("signup.personal"),description:l("signup.personalDescription")},{id:"company",label:l("signup.company"),description:l("signup.companyDescription")}],P=[{id:"testing",label:l("signup.justTesting")},{id:"exploring",label:l("signup.activelyExploring")},{id:"using",label:l("signup.alreadyUsing")},{id:"migrating",label:l("signup.migratingLLMs")},{id:"other",label:l("signup.other")}];o(()=>{const e=$().currentUser;e?k(e):console.error("No user found")},[]);return t("div",{className:"flex flex-col space-y-2",children:[t("div",{className:"prose",children:[e("p",{className:"prose text-sm text-muted pt-4",children:l("signup.welcomeMessage",{name:w?.displayName,email:w?.email})}),C&&e("div",{className:"text-destructive",children:C})]}),e(xt,{label:l("signup.accountType"),children:e(b,{options:I,selected:I.find(e=>e.id===c),onSelect:e=>s(e.id)})}),j&&t(n,{children:[e(xt,{label:l("signup.companySize"),children:e(m,{className:"w-full border border-accent bg-muted",value:d,options:z,onChange:u,optionLabel:e=>e?.label,placeholder:l("signup.selectCompanySize")})}),e(xt,{label:l("signup.companyName"),children:e(y,{value:p,onChange:g,type:"text",required:!0})}),e(xt,{label:l("signup.companyWebsite"),children:e(y,{value:f,onChange:v,type:"text"})})]}),e(xt,{label:l("signup.projectMaturity"),children:e(m,{className:"w-full border border-accent bg-muted",options:P,value:P.find(e=>e.id===x),optionLabel:e=>e?.label,placeholder:l("signup.selectProjectMaturity"),onChange:e=>N(e?.id)})}),t("div",{className:"pt-8 flex flex-col",children:[e(h,{variant:"primary",onClick:async()=>{if(!(c?j&&!p?(S(l("signup.pleaseEnterOrgName")),0):!j||d||(S(l("signup.pleaseSelectCompanySize")),0):(S(l("signup.pleaseSelectAccountType")),0)))return;if(!c)return;const e={accountType:c,companyName:p,companySize:d?.id,companyWebsite:f,maturity:x};window.localStorage.setItem("composableSignupData",JSON.stringify(e));const t=await($().currentUser?.getIdToken());console.log("Got firebase token",$(),t),t?i(e,t):console.error("No firebase token found")},size:"xl",children:e("span",{className:"text-lg",children:l("signup.signUp")})}),e(h,{variant:"ghost",size:"xl",className:"mt-4",onClick:r,children:e("span",{className:"",children:l("signup.wrongAccountGoBack")})})]})]})}function xt({label:n,children:i}){return t("div",{className:"flex flex-col space-y-2 pt-4",children:[e("div",{className:"text-sm text-muted",children:n}),i]})}function bt({allowedPrefix:t,isNested:n=!1,lightLogo:i,darkLogo:r,preservePath:a,suppressAuthErrorPrefix:o}){const l="undefined"==typeof window?"":window.location.pathname,c=yt(l,t),s=yt(l,o);return c?null:e(Nt,{isNested:n,lightLogo:i,darkLogo:r,preservePath:a,suppressAuthError:s})}function yt(e,t){return(Array.isArray(t)?t:t?[t]:[]).some(t=>e===t||e.startsWith(t.endsWith("/")?t:`${t}/`))}function Nt({isNested:n=!1,lightLogo:i,darkLogo:r,preservePath:l,suppressAuthError:c}){const{t:d}=J(),{isLoading:u,user:m,authError:p,signOut:h}=E(),{trackEvent:g}=F(),[f,v]=a(()=>Qe()),[x,b]=a(()=>Qe()?"returning":"email"),[y,N]=a(""),[w,k]=a(void 0),[C,S]=a(null);o(()=>{l||history.replaceState({},"","/")},[l]),o(()=>{if(p)if(p instanceof M)b("signup");else if(ct(p)){const e=Ze();e&&N(e.email),b("blocked")}},[p]),o(()=>{if(!m)return;const e=Ze();e&&(!function(e){try{localStorage.setItem(Ge,JSON.stringify(e))}catch{}}({email:e.email,lastProvider:e.provider,tenantName:e.tenantName,name:m.name||void 0}),et())},[m]);const j=s((e,t)=>{N(e),k(t),b(t?"tenant":"providers")},[]),z=s(()=>{b("email"),k(void 0)},[]),I=s(()=>{Xe(),et(),v(null),N(""),k(void 0),b("email"),h()},[h]),P=s(e=>{(!!w||!!f?.tenantName)&&g("enterprise_signin",{provider:e}),S(e),b("pending")},[g,f?.tenantName,w]),A=s(()=>{v(null),N(""),k(void 0),b("email"),tt()},[]),L=(e,t)=>{const n={signupData:e,firebaseToken:t};fetch(`${ie.endpoints.studio}/auth/signup`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(n)}).then(()=>{g("sign_up"),window.location.href="/"})};if(u||m||c&&void 0!==p&&!(p instanceof M))return null;let T=null;return T="pending"===x&&C?e(st,{provider:C}):"blocked"===x?e(ht,{email:y||f?.email||"",tenantName:w?.label||w?.name||f?.tenantName||void 0,onBack:A}):"signup"!==x||localStorage.getItem("tenantName")?"tenant"===x&&w?e(ft,{email:y,tenant:w,onBack:z,onProviderClicked:()=>P(w.provider??"oidc")}):"providers"===x?e(mt,{email:y,onBack:z,onProviderClicked:P}):"returning"===x&&f?e(pt,{session:f,onNotYou:I,onProviderClicked:P}):e(dt,{initialEmail:y,onProceed:j}):e(vt,{onSignup:L,goBack:A}),e("div",{style:{zIndex:999998},className:(n?"absolute":"fixed")+" inset-0 overflow-y-auto bg-background",children:e("div",{className:"min-h-full flex flex-col items-center justify-center py-12 px-4",children:t("div",{className:"flex flex-col items-center w-full",children:[(i||r)&&t("div",{className:"mb-7",children:[i&&e("img",{src:i,alt:"Vertesia",className:"h-10 block dark:hidden"}),r&&e("img",{src:r,alt:"Vertesia",className:"h-10 hidden dark:block"})]}),T,p&&!(p instanceof M)&&!ct(p)&&e("div",{className:"mt-6 max-w-[420px] text-center text-sm text-muted",children:t("div",{children:[d("auth.signInError"),e("br",{}),d("auth.signInErrorContact"),e("a",{className:"text-info mx-1",href:"mailto:support@vertesiahq.com",children:"support@vertesiahq.com"}),d("auth.signInErrorPersists"),e("pre",{className:"mt-2 text-xs",children:d("auth.error",{message:p.message})})]})}),t("div",{className:"flex items-center gap-5 mt-10 text-xs text-muted-foreground",children:[e("a",{href:"https://vertesiahq.com/privacy",className:"hover:text-foreground transition",children:d("auth.privacyPolicy")}),e("span",{className:"text-border",children:"·"}),e("a",{href:"https://vertesiahq.com/terms",className:"hover:text-foreground transition",children:d("auth.termsOfService")}),e("span",{className:"text-border",children:"·"}),e(re,{className:"cursor-default"})]})]})})})}const wt=new Set(["127.0.0.1","localhost"]);function kt(e){const t=new URLSearchParams(e.search),n=function(e){if(!e)return null;let t,n;try{t=decodeURIComponent(e)}catch{return null}try{n=new URL(t)}catch{return null}return"http:"!==n.protocol?null:n.port?n.username||n.password?null:wt.has(n.hostname)?n.toString():null:null}(t.get("redirect_uri")),i=t.get("code");if(!n||!i)return null;return{redirect:n,code:i,profile:t.get("profile")??"default",project:t.get("project")??void 0,account:t.get("account")??void 0}}function Ct(){const[t,n]=a(),[i,r]=a(),o=kt(de()),l=N(),{t:c}=J(),s=async e=>{if(!o)return;if(!e.profile)return void l({title:c("login.terminal.profileRequired"),description:c("login.terminal.profileRequiredDesc"),status:"error",duration:2e3});if(!e.account)return void l({title:c("login.terminal.accountRequired"),description:c("login.terminal.accountRequiredDesc"),status:"error",duration:2e3});if(!e.project)return void l({title:c("login.terminal.projectRequired"),description:c("login.terminal.projectRequiredDesc"),status:"error",duration:2e3});let t;try{const i=W(),r=i?await V(i,e.account,e.project,86400):await U(e.account,e.project,86400);r?(t={...e,studio_server_url:ie.endpoints.studio,zeno_server_url:ie.endpoints.zeno,token:r},await fetch(o.redirect,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)}),n(t)):l({title:c("login.terminal.failedToGetToken"),status:"error",duration:5e3})}catch(e){t?(r(e instanceof Error?e:new Error(u(e))),n(t)):l({title:c("login.terminal.errorAuthorizingClient"),description:u(e),status:"error",duration:5e3})}},d=o?t?e(jt,{payload:t,error:i}):e(St,{clientInfo:o,onAccept:s}):e(w,{title:c("login.terminal.invalidRequest"),children:c("login.terminal.invalidRequestDesc")});return e("div",{className:"w-full flex flex-col items-center gap-4 mt-24",children:d})}function St({onAccept:i,clientInfo:r}){const{client:a,user:o}=E(),{data:l,error:c}=d(()=>o?a.projects.list():Promise.resolve([]),[o]),{t:s}=J();if(c)return e(w,{title:s("login.terminal.errorLoadingProjects"),children:u(c)});const m=ie.isLocalDev?s("login.terminal.envLocalDev"):ie.isDev?s("login.terminal.envStaging"):s("login.terminal.envProduction");return o&&l?t(n,{children:[t("div",{className:"w-1/3",children:[t("div",{className:"mb-4 text-xl font-semibold text-info",children:["Authorizing client on ",m," environment."]}),t("div",{className:"mb-2 text-md text-muted-foreground",children:[e("div",{children:s("login.terminal.clientWantsAuth")}),t("div",{children:["The client app code is ",e("b",{className:"text-foreground",children:r.code}),". You can check if the code is correct in the terminal."]})]}),t("div",{className:"mb-2 text-sm text-muted-foreground",children:[e("div",{children:s("login.terminal.chooseAccountProject")}),e("div",{children:s("login.terminal.profileNameNote")})]})]}),e(zt,{onAccept:i,allProjects:l,data:r})]}):e(x,{size:"lg"})}function jt({payload:n,error:i}){const r=N(),{t:a}=J();return t("div",{children:[e("div",i?{children:e(w,{title:a("login.terminal.failedToSendToken"),children:a("login.terminal.failedToSendTokenDesc",{error:i.message})})}:{children:a("login.terminal.clientAuthenticated")}),e(p,{className:"mt-4",children:e(h,{variant:"secondary",onClick:()=>{n&&(navigator.clipboard.writeText(JSON.stringify(n)),r({title:a("login.terminal.authPayloadCopied"),description:i?a("login.terminal.authPayloadCopiedWithError",{error:i.message}):a("login.terminal.authPayloadCopiedSuccess"),status:"success",duration:5e3}))},children:a("login.terminal.copyAuthPayload")})})]})}function zt({allProjects:n,data:i,onAccept:r}){const{accounts:o,account:l,project:c}=E(),{t:s}=J(),[d,u]=a(()=>({profile:i.profile,account:i.account??l?.id,project:i.project??c?.id})),m=n.filter(e=>e.account===d.account);return t("div",{className:"w-1/3",children:[t("div",{className:"mb-4 flex flex-col gap-2",children:[e("span",{className:"font-semibold text-muted-foreground",children:s("login.terminal.profileName")}),e(y,{type:"text",value:d.profile,onChange:e=>{u({...d,profile:e})}})]}),t("div",{className:"mb-4 flex flex-col gap-2",children:[e("span",{className:"font-semibold text-muted-foreground",children:s("login.terminal.account")}),e(It,{value:d.account,onChange:e=>{u({...d,account:e.id,project:void 0})},accounts:o||[]})]}),t("div",{className:"mb-4 flex flex-col gap-2",children:[e("span",{className:"font-semibold text-muted-foreground",children:s("login.terminal.project")}),e(Pt,{value:d.project,onChange:e=>{u({...d,project:e.id})},projects:m})]}),e("div",{className:"mb-4 text-sm text-attention",children:s("login.terminal.browserPermissionNote")}),e("div",{children:e(h,{size:"xl",onClick:()=>r(d),children:s("login.terminal.authorizeClient")})})]})}function It({value:t,accounts:n,onChange:i}){const{t:r}=J();return e(m,{options:n,value:n?.find(e=>e.id===t),onChange:e=>{i(e)},by:"id",optionLabel:e=>e.name,placeholder:r("login.terminal.selectAccount")})}function Pt({value:t,projects:n,onChange:i}){const{t:r}=J();return e(m,{by:"id",value:n.find(e=>e.id===t),options:n,optionLabel:e=>e.name,placeholder:r("login.terminal.selectProject"),onChange:e=>{i(e)}})}function At({isOpen:n,onClose:i}){return t(g,{isOpen:n,onClose:i,children:[e(f,{children:"Sign In"}),t(v,{className:"flex flex-col gap-2",children:[e(gt,{provider:"google"}),e(gt,{provider:"github"}),e(gt,{provider:"microsoft"})]}),e(k,{align:"right",children:e(h,{variant:"ghost",onClick:i,children:"Cancel"})})]})}function Lt({title:n,value:i}){const[r,o]=a(!1);return t("div",{className:"w-full flex justify-between items-center mb-1",children:[t("div",{className:"flex flex-col w-[calc(100%-3rem)]",children:[e("div",{className:"text-sm px-2 dark:text-slate-200",children:n}),e(z,{description:i,size:"xs",placement:"left",children:t("div",{className:"text-xs truncate text-muted w-full text-start px-2",children:[i," "]})})]}),r?e(te,{className:"size-4 cursor-pointer text-success"}):e(ne,{className:"size-4 cursor-pointer text-gray-400 dark:text-slate-400",onClick:()=>function(e){navigator.clipboard.writeText(e),o(!0),setTimeout(()=>o(!1),2e3)}(i)})]})}function Tt(){const{t:n}=J(),i=E(),{account:r,project:a,client:o,authToken:l}=i,c=o.baseUrl,s=o.store.baseUrl,d=s.replace(/\/+$/,"")!==c.replace(/\/+$/,""),u=ie.endpoints.mcp??n("user.unknown"),m=a?me(a):"",p=[{name:"user",label:n("user.user"),content:t("div",{className:"space-y-1 p-2",children:[e(Lt,{title:n("user.organizationId"),value:r?.id??n("user.unknown")}),e(Lt,{title:n("user.projectId"),value:a?.id??n("user.unknown")}),e(Lt,{title:n("user.userId"),value:l?.sub??n("user.unknown")}),e(Lt,{title:n("user.organizationRoles"),value:l?.account_roles?.join(",")??n("user.unknown")}),e(Lt,{title:n("user.projectRoles"),value:l?.project_roles?.join(",")??n("user.unknown")})]})},{name:"environment",label:n("user.environment"),content:t("div",{className:"space-y-1 p-2",children:[e(Lt,{title:n("user.tenantId"),value:m}),e(Lt,{title:n("user.environment"),value:ie.type}),e(Lt,{title:n("user.server"),value:c}),d&&e(Lt,{title:n("user.store"),value:s}),e(Lt,{title:n("user.mcpServer"),value:u}),e(Lt,{title:n("user.appVersion"),value:ie.version}),e(Lt,{title:n("user.sdkVersion"),value:ie.sdkVersion||n("user.unknown")})]})}];return e("div",{className:"w-full",children:t(C,{defaultValue:"user",tabs:p,fullWidth:!0,updateHash:!1,children:[e(S,{}),e(j,{})]})})}function Ot(i){const{user:r,isLoading:o}=E(),[l,c]=a(!1);return o?e(x,{}):r?e("div",{className:"px-3",children:e(Bt,{asMenuTrigger:!0})}):t(n,{children:[e(h,{onClick:()=>c(!0),children:"Sign In"}),e(At,{isOpen:l,onClose:()=>c(!1)})]})}function Bt({className:n,asMenuTrigger:i=!1}){const r=E(),a=ue(),o=he(),{user:l}=r;if(!r||!l)return null;const c=o.hasPermission(pe.project_admin);return t(I,{click:!0,children:[e(P,{children:e("div",{className:ve(n,"flex items-center justify-start",i&&"cursor-pointer"),children:e(A,{size:"sm",color:"bg-amber-500",shape:"circle",name:l?.name})})}),e(L,{align:"start",className:"w-[280px] mx-2 my-1 p-0",children:t("div",{className:"divide-y divide-gray-200 dark:divide-slate-700",children:[t("div",{className:"py-2 ps-2",children:[e("p",{className:"px-4 dark:text-white mb-1",children:l?.name??"Unknown"}),e("p",{className:"px-4 text-xs text-gray-500",children:l?.email??""})]}),e("div",{className:"w-full p-1",children:e(Tt,{})}),e("div",{className:"py-2 ps-2",children:e(T,{})}),e("div",{className:"py-2",children:t(O,{children:[c&&e(O.Item,{className:"px-2",onClick:()=>a("/settings",{replace:!0}),children:"Settings"}),e(O.Item,{className:"px-2",onClick:()=>r.logout(),children:"Sign out"})]})})]})})]})}function Rt(e){return!!e&&(e.endsWith("@vertesiahq.com")||e.endsWith("@becomposable.com")||e.endsWith("@composableprompts.com"))}function Et({icon:t}){const{isLoading:n}=E(),[i,r]=a(!0);return o(()=>{n||r(!1)},[n]),e(xe,{children:i&&e(be.div,{style:{zIndex:999999,position:"fixed",inset:0},className:"fixed inset-x-0 inset-y-0",initial:{opacity:1},exit:{opacity:0},transition:{ease:"easeIn",duration:.5},children:e("div",{style:{display:"flex",width:"100%",height:"100%",alignItems:"center",justifyContent:"center"},className:"flex w-full h-full items-center justify-center",children:e("div",{className:"animate-[spin_4s_linear_infinite]",children:e("div",{className:"animate-pulse rounded-full bg-transparent",children:t||e(Dt,{})})})})})})}function Dt(){return t("svg",{width:"32",height:"32",className:"w-8 h-8 text-indigo-600",viewBox:"0 0 50 50",xmlns:"http://www.w3.org/2000/svg",role:"img","aria-label":"Loading",children:[e("title",{children:"Loading"}),e("defs",{children:t("linearGradient",{id:"spinner-gradient",x1:"1",y1:"0",x2:"0",y2:"1",children:[e("stop",{offset:"0%",stopColor:"currentColor",stopOpacity:"1"}),e("stop",{offset:"100%",stopColor:"currentColor",stopOpacity:"0"})]})}),e("circle",{cx:"25",cy:"25",r:"20",stroke:"url(#spinner-gradient)",strokeWidth:"5",fill:"none",strokeLinecap:"round"})]})}function _t({children:n,lightLogo:i,darkLogo:r,loadingIcon:a,loadOnboardingStatus:o,preserveSignInPath:l,suppressSignInErrorPrefixes:c,defaultLanguage:s}){return e(B,{children:e(H,{loadOnboardingStatus:o,children:e(ge,{children:e(R,{defaultTheme:"system",storageKey:"vite-ui-theme",children:e(Y,{defaultLanguage:s,children:t(G,{children:[e(Et,{icon:a}),e(bt,{allowedPrefix:"/shared/",darkLogo:r,lightLogo:i,preservePath:l,suppressAuthErrorPrefix:c}),e(fe,{children:n})]})})})})})})}export{ye as AppInstallationContext,Ne as AppInstallationProvider,ke as AppProjectSelector,Pe as InviteAcceptModal,bt as SigninScreen,Se as StandaloneApp,je as StandaloneAppImpl,Ct as TerminalLogin,Ot as UserSessionMenu,_t as VertesiaShell,Rt as isVertesiaEmail,we as useAppInstallation};
|
|
2
2
|
//# sourceMappingURL=vertesia-ui-shell.js.map
|