libre-webui 0.25.0 → 0.26.0
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/README.md +32 -22
- package/backend/dist/index.d.ts.map +1 -1
- package/backend/dist/index.js +26 -4
- package/backend/dist/index.js.map +1 -1
- package/backend/dist/middleware/auth.d.ts +7 -0
- package/backend/dist/middleware/auth.d.ts.map +1 -1
- package/backend/dist/middleware/auth.js +26 -0
- package/backend/dist/middleware/auth.js.map +1 -1
- package/backend/dist/middleware/index.d.ts +20 -0
- package/backend/dist/middleware/index.d.ts.map +1 -1
- package/backend/dist/middleware/index.js +105 -2
- package/backend/dist/middleware/index.js.map +1 -1
- package/backend/dist/models/personaModel.d.ts.map +1 -1
- package/backend/dist/models/personaModel.js +2 -0
- package/backend/dist/models/personaModel.js.map +1 -1
- package/backend/dist/observability/otel.d.ts +40 -0
- package/backend/dist/observability/otel.d.ts.map +1 -0
- package/backend/dist/observability/otel.js +337 -0
- package/backend/dist/observability/otel.js.map +1 -0
- package/backend/dist/observability/requestContext.d.ts +14 -0
- package/backend/dist/observability/requestContext.d.ts.map +1 -0
- package/backend/dist/observability/requestContext.js +21 -0
- package/backend/dist/observability/requestContext.js.map +1 -0
- package/backend/dist/persistence/chatGenerationTypes.d.ts +9 -0
- package/backend/dist/persistence/chatGenerationTypes.d.ts.map +1 -1
- package/backend/dist/persistence/extensionTypes.d.ts +13 -0
- package/backend/dist/persistence/extensionTypes.d.ts.map +1 -1
- package/backend/dist/persistence/extensionTypes.js.map +1 -1
- package/backend/dist/persistence/index.d.ts +1 -1
- package/backend/dist/persistence/index.d.ts.map +1 -1
- package/backend/dist/persistence/index.js.map +1 -1
- package/backend/dist/persistence/postgresAgentFoundationMigration.d.ts +9 -0
- package/backend/dist/persistence/postgresAgentFoundationMigration.d.ts.map +1 -0
- package/backend/dist/persistence/postgresAgentFoundationMigration.js +164 -0
- package/backend/dist/persistence/postgresAgentFoundationMigration.js.map +1 -0
- package/backend/dist/persistence/postgresExtensionRepositories.d.ts.map +1 -1
- package/backend/dist/persistence/postgresExtensionRepositories.js +46 -2
- package/backend/dist/persistence/postgresExtensionRepositories.js.map +1 -1
- package/backend/dist/persistence/postgresMediaEnterpriseOpsMigration.d.ts +10 -0
- package/backend/dist/persistence/postgresMediaEnterpriseOpsMigration.d.ts.map +1 -0
- package/backend/dist/persistence/postgresMediaEnterpriseOpsMigration.js +148 -0
- package/backend/dist/persistence/postgresMediaEnterpriseOpsMigration.js.map +1 -0
- package/backend/dist/persistence/postgresMigrationRegistry.d.ts.map +1 -1
- package/backend/dist/persistence/postgresMigrationRegistry.js +10 -0
- package/backend/dist/persistence/postgresMigrationRegistry.js.map +1 -1
- package/backend/dist/persistence/postgresNotesV2Migration.d.ts +4 -0
- package/backend/dist/persistence/postgresNotesV2Migration.d.ts.map +1 -0
- package/backend/dist/persistence/postgresNotesV2Migration.js +57 -0
- package/backend/dist/persistence/postgresNotesV2Migration.js.map +1 -0
- package/backend/dist/persistence/postgresResourceRepositories.d.ts.map +1 -1
- package/backend/dist/persistence/postgresResourceRepositories.js +1646 -11
- package/backend/dist/persistence/postgresResourceRepositories.js.map +1 -1
- package/backend/dist/persistence/postgresSkillFilesMigration.d.ts +9 -0
- package/backend/dist/persistence/postgresSkillFilesMigration.d.ts.map +1 -0
- package/backend/dist/persistence/postgresSkillFilesMigration.js +50 -0
- package/backend/dist/persistence/postgresSkillFilesMigration.js.map +1 -0
- package/backend/dist/persistence/postgresTeamCollaborationMigration.d.ts +10 -0
- package/backend/dist/persistence/postgresTeamCollaborationMigration.d.ts.map +1 -0
- package/backend/dist/persistence/postgresTeamCollaborationMigration.js +161 -0
- package/backend/dist/persistence/postgresTeamCollaborationMigration.js.map +1 -0
- package/backend/dist/persistence/resourceTypes.d.ts +541 -3
- package/backend/dist/persistence/resourceTypes.d.ts.map +1 -1
- package/backend/dist/persistence/resourceTypes.js.map +1 -1
- package/backend/dist/persistence/sqliteExtensionRepositories.d.ts.map +1 -1
- package/backend/dist/persistence/sqliteExtensionRepositories.js +26 -4
- package/backend/dist/persistence/sqliteExtensionRepositories.js.map +1 -1
- package/backend/dist/persistence/sqliteMigrations.d.ts +9 -0
- package/backend/dist/persistence/sqliteMigrations.d.ts.map +1 -1
- package/backend/dist/persistence/sqliteMigrations.js +1196 -29
- package/backend/dist/persistence/sqliteMigrations.js.map +1 -1
- package/backend/dist/persistence/sqliteResourceRepositories.d.ts.map +1 -1
- package/backend/dist/persistence/sqliteResourceRepositories.js +1523 -134
- package/backend/dist/persistence/sqliteResourceRepositories.js.map +1 -1
- package/backend/dist/persistence/sqliteToPostgresMigration.d.ts.map +1 -1
- package/backend/dist/persistence/sqliteToPostgresMigration.js +257 -3
- package/backend/dist/persistence/sqliteToPostgresMigration.js.map +1 -1
- package/backend/dist/platform/jobs/domainJobContracts.d.ts +8 -0
- package/backend/dist/platform/jobs/domainJobContracts.d.ts.map +1 -1
- package/backend/dist/platform/jobs/domainJobContracts.js +8 -0
- package/backend/dist/platform/jobs/domainJobContracts.js.map +1 -1
- package/backend/dist/platform/jobs/domainJobHandlers.d.ts.map +1 -1
- package/backend/dist/platform/jobs/domainJobHandlers.js +310 -3
- package/backend/dist/platform/jobs/domainJobHandlers.js.map +1 -1
- package/backend/dist/platform/jobs/embeddedDurableJobWorker.d.ts.map +1 -1
- package/backend/dist/platform/jobs/embeddedDurableJobWorker.js +4 -2
- package/backend/dist/platform/jobs/embeddedDurableJobWorker.js.map +1 -1
- package/backend/dist/platform/jobs/postgresDurableJobWorker.d.ts.map +1 -1
- package/backend/dist/platform/jobs/postgresDurableJobWorker.js +4 -2
- package/backend/dist/platform/jobs/postgresDurableJobWorker.js.map +1 -1
- package/backend/dist/platform/storage/pgVectorStore.d.ts +2 -1
- package/backend/dist/platform/storage/pgVectorStore.d.ts.map +1 -1
- package/backend/dist/platform/storage/pgVectorStore.js +51 -0
- package/backend/dist/platform/storage/pgVectorStore.js.map +1 -1
- package/backend/dist/platform/storage/platformDomainRepositories.d.ts +8 -2
- package/backend/dist/platform/storage/platformDomainRepositories.d.ts.map +1 -1
- package/backend/dist/platform/storage/postgresPlatformDomainRepositories.d.ts.map +1 -1
- package/backend/dist/platform/storage/postgresPlatformDomainRepositories.js +25 -4
- package/backend/dist/platform/storage/postgresPlatformDomainRepositories.js.map +1 -1
- package/backend/dist/platform/storage/sqliteEncryptedVectorStore.d.ts +2 -1
- package/backend/dist/platform/storage/sqliteEncryptedVectorStore.d.ts.map +1 -1
- package/backend/dist/platform/storage/sqliteEncryptedVectorStore.js +35 -0
- package/backend/dist/platform/storage/sqliteEncryptedVectorStore.js.map +1 -1
- package/backend/dist/platform/storage/sqlitePlatformDomainRepositories.d.ts.map +1 -1
- package/backend/dist/platform/storage/sqlitePlatformDomainRepositories.js +26 -3
- package/backend/dist/platform/storage/sqlitePlatformDomainRepositories.js.map +1 -1
- package/backend/dist/platform/storage/vectorStore.d.ts +14 -0
- package/backend/dist/platform/storage/vectorStore.d.ts.map +1 -1
- package/backend/dist/platform/storage/vectorStore.js.map +1 -1
- package/backend/dist/routes/access.d.ts.map +1 -1
- package/backend/dist/routes/access.js +84 -3
- package/backend/dist/routes/access.js.map +1 -1
- package/backend/dist/routes/calendar.d.ts.map +1 -1
- package/backend/dist/routes/calendar.js +125 -22
- package/backend/dist/routes/calendar.js.map +1 -1
- package/backend/dist/routes/channels.d.ts +3 -0
- package/backend/dist/routes/channels.d.ts.map +1 -0
- package/backend/dist/routes/channels.js +447 -0
- package/backend/dist/routes/channels.js.map +1 -0
- package/backend/dist/routes/chat.d.ts.map +1 -1
- package/backend/dist/routes/chat.js +195 -7
- package/backend/dist/routes/chat.js.map +1 -1
- package/backend/dist/routes/costs.d.ts +3 -0
- package/backend/dist/routes/costs.d.ts.map +1 -0
- package/backend/dist/routes/costs.js +191 -0
- package/backend/dist/routes/costs.js.map +1 -0
- package/backend/dist/routes/documents.d.ts.map +1 -1
- package/backend/dist/routes/documents.js +64 -21
- package/backend/dist/routes/documents.js.map +1 -1
- package/backend/dist/routes/evaluations.d.ts +3 -0
- package/backend/dist/routes/evaluations.d.ts.map +1 -0
- package/backend/dist/routes/evaluations.js +352 -0
- package/backend/dist/routes/evaluations.js.map +1 -0
- package/backend/dist/routes/imageGen.d.ts.map +1 -1
- package/backend/dist/routes/imageGen.js +2 -1
- package/backend/dist/routes/imageGen.js.map +1 -1
- package/backend/dist/routes/media.d.ts.map +1 -1
- package/backend/dist/routes/media.js +228 -7
- package/backend/dist/routes/media.js.map +1 -1
- package/backend/dist/routes/notes.d.ts.map +1 -1
- package/backend/dist/routes/notes.js +149 -36
- package/backend/dist/routes/notes.js.map +1 -1
- package/backend/dist/routes/notifications.d.ts +3 -0
- package/backend/dist/routes/notifications.d.ts.map +1 -0
- package/backend/dist/routes/notifications.js +213 -0
- package/backend/dist/routes/notifications.js.map +1 -0
- package/backend/dist/routes/openaiCompat.d.ts +3 -0
- package/backend/dist/routes/openaiCompat.d.ts.map +1 -0
- package/backend/dist/routes/openaiCompat.js +314 -0
- package/backend/dist/routes/openaiCompat.js.map +1 -0
- package/backend/dist/routes/personas.js +1 -1
- package/backend/dist/routes/personas.js.map +1 -1
- package/backend/dist/routes/prompts.d.ts +3 -0
- package/backend/dist/routes/prompts.d.ts.map +1 -0
- package/backend/dist/routes/prompts.js +173 -0
- package/backend/dist/routes/prompts.js.map +1 -0
- package/backend/dist/routes/search.d.ts.map +1 -1
- package/backend/dist/routes/search.js +29 -1
- package/backend/dist/routes/search.js.map +1 -1
- package/backend/dist/routes/skills.d.ts +3 -0
- package/backend/dist/routes/skills.d.ts.map +1 -0
- package/backend/dist/routes/skills.js +246 -0
- package/backend/dist/routes/skills.js.map +1 -0
- package/backend/dist/routes/stt.d.ts.map +1 -1
- package/backend/dist/routes/stt.js +2 -1
- package/backend/dist/routes/stt.js.map +1 -1
- package/backend/dist/routes/tools.d.ts +3 -0
- package/backend/dist/routes/tools.d.ts.map +1 -0
- package/backend/dist/routes/tools.js +359 -0
- package/backend/dist/routes/tools.js.map +1 -0
- package/backend/dist/routes/tts.d.ts.map +1 -1
- package/backend/dist/routes/tts.js +63 -8
- package/backend/dist/routes/tts.js.map +1 -1
- package/backend/dist/routes/voiceAccess.d.ts +3 -0
- package/backend/dist/routes/voiceAccess.d.ts.map +1 -0
- package/backend/dist/routes/voiceAccess.js +102 -0
- package/backend/dist/routes/voiceAccess.js.map +1 -0
- package/backend/dist/services/apiTokenService.d.ts +2 -2
- package/backend/dist/services/apiTokenService.d.ts.map +1 -1
- package/backend/dist/services/apiTokenService.js +7 -0
- package/backend/dist/services/apiTokenService.js.map +1 -1
- package/backend/dist/services/authorizationService.d.ts +8 -4
- package/backend/dist/services/authorizationService.d.ts.map +1 -1
- package/backend/dist/services/authorizationService.js +31 -1
- package/backend/dist/services/authorizationService.js.map +1 -1
- package/backend/dist/services/automationSchedulerService.d.ts.map +1 -1
- package/backend/dist/services/automationSchedulerService.js +33 -3
- package/backend/dist/services/automationSchedulerService.js.map +1 -1
- package/backend/dist/services/automationService.d.ts +4 -1
- package/backend/dist/services/automationService.d.ts.map +1 -1
- package/backend/dist/services/automationService.js +25 -2
- package/backend/dist/services/automationService.js.map +1 -1
- package/backend/dist/services/builtinToolsService.d.ts +20 -0
- package/backend/dist/services/builtinToolsService.d.ts.map +1 -0
- package/backend/dist/services/builtinToolsService.js +661 -0
- package/backend/dist/services/builtinToolsService.js.map +1 -0
- package/backend/dist/services/calendarService.d.ts +74 -0
- package/backend/dist/services/calendarService.d.ts.map +1 -0
- package/backend/dist/services/calendarService.js +339 -0
- package/backend/dist/services/calendarService.js.map +1 -0
- package/backend/dist/services/channelService.d.ts +195 -0
- package/backend/dist/services/channelService.d.ts.map +1 -0
- package/backend/dist/services/channelService.js +1057 -0
- package/backend/dist/services/channelService.js.map +1 -0
- package/backend/dist/services/chatRequestService.d.ts.map +1 -1
- package/backend/dist/services/chatRequestService.js +29 -1
- package/backend/dist/services/chatRequestService.js.map +1 -1
- package/backend/dist/services/chatService.d.ts +61 -1
- package/backend/dist/services/chatService.d.ts.map +1 -1
- package/backend/dist/services/chatService.js +218 -1
- package/backend/dist/services/chatService.js.map +1 -1
- package/backend/dist/services/chatToolRuntimeService.d.ts +55 -0
- package/backend/dist/services/chatToolRuntimeService.d.ts.map +1 -0
- package/backend/dist/services/chatToolRuntimeService.js +389 -0
- package/backend/dist/services/chatToolRuntimeService.js.map +1 -0
- package/backend/dist/services/costGovernanceService.d.ts +102 -0
- package/backend/dist/services/costGovernanceService.d.ts.map +1 -0
- package/backend/dist/services/costGovernanceService.js +463 -0
- package/backend/dist/services/costGovernanceService.js.map +1 -0
- package/backend/dist/services/dataArchiveService.d.ts +6 -0
- package/backend/dist/services/dataArchiveService.d.ts.map +1 -1
- package/backend/dist/services/dataArchiveService.js +23 -4
- package/backend/dist/services/dataArchiveService.js.map +1 -1
- package/backend/dist/services/documentService.d.ts +58 -1
- package/backend/dist/services/documentService.d.ts.map +1 -1
- package/backend/dist/services/documentService.js +289 -84
- package/backend/dist/services/documentService.js.map +1 -1
- package/backend/dist/services/durableChatGenerationService.d.ts +9 -0
- package/backend/dist/services/durableChatGenerationService.d.ts.map +1 -1
- package/backend/dist/services/durableChatGenerationService.js +152 -11
- package/backend/dist/services/durableChatGenerationService.js.map +1 -1
- package/backend/dist/services/evaluationService.d.ts +111 -0
- package/backend/dist/services/evaluationService.d.ts.map +1 -0
- package/backend/dist/services/evaluationService.js +403 -0
- package/backend/dist/services/evaluationService.js.map +1 -0
- package/backend/dist/services/galleryService.d.ts +6 -0
- package/backend/dist/services/galleryService.d.ts.map +1 -1
- package/backend/dist/services/galleryService.js +26 -0
- package/backend/dist/services/galleryService.js.map +1 -1
- package/backend/dist/services/mcpClientService.d.ts +29 -0
- package/backend/dist/services/mcpClientService.d.ts.map +1 -0
- package/backend/dist/services/mcpClientService.js +189 -0
- package/backend/dist/services/mcpClientService.js.map +1 -0
- package/backend/dist/services/noteService.d.ts +71 -0
- package/backend/dist/services/noteService.d.ts.map +1 -0
- package/backend/dist/services/noteService.js +397 -0
- package/backend/dist/services/noteService.js.map +1 -0
- package/backend/dist/services/notificationService.d.ts +55 -0
- package/backend/dist/services/notificationService.d.ts.map +1 -0
- package/backend/dist/services/notificationService.js +308 -0
- package/backend/dist/services/notificationService.js.map +1 -0
- package/backend/dist/services/openApiToolService.d.ts +38 -0
- package/backend/dist/services/openApiToolService.d.ts.map +1 -0
- package/backend/dist/services/openApiToolService.js +254 -0
- package/backend/dist/services/openApiToolService.js.map +1 -0
- package/backend/dist/services/personaService.d.ts +18 -2
- package/backend/dist/services/personaService.d.ts.map +1 -1
- package/backend/dist/services/personaService.js +113 -4
- package/backend/dist/services/personaService.js.map +1 -1
- package/backend/dist/services/pluginImageGenerationService.d.ts +19 -0
- package/backend/dist/services/pluginImageGenerationService.d.ts.map +1 -1
- package/backend/dist/services/pluginImageGenerationService.js +121 -0
- package/backend/dist/services/pluginImageGenerationService.js.map +1 -1
- package/backend/dist/services/pluginService.d.ts +7 -0
- package/backend/dist/services/pluginService.d.ts.map +1 -1
- package/backend/dist/services/pluginService.js +8 -2
- package/backend/dist/services/pluginService.js.map +1 -1
- package/backend/dist/services/promptService.d.ts +74 -0
- package/backend/dist/services/promptService.d.ts.map +1 -0
- package/backend/dist/services/promptService.js +513 -0
- package/backend/dist/services/promptService.js.map +1 -0
- package/backend/dist/services/resourceGrantService.d.ts.map +1 -1
- package/backend/dist/services/resourceGrantService.js +62 -17
- package/backend/dist/services/resourceGrantService.js.map +1 -1
- package/backend/dist/services/searchService.d.ts +29 -0
- package/backend/dist/services/searchService.d.ts.map +1 -0
- package/backend/dist/services/searchService.js +0 -0
- package/backend/dist/services/searchService.js.map +1 -0
- package/backend/dist/services/securityAuditService.d.ts.map +1 -1
- package/backend/dist/services/securityAuditService.js +2 -1
- package/backend/dist/services/securityAuditService.js.map +1 -1
- package/backend/dist/services/sharedResourceAccess.d.ts +25 -0
- package/backend/dist/services/sharedResourceAccess.d.ts.map +1 -0
- package/backend/dist/services/sharedResourceAccess.js +59 -0
- package/backend/dist/services/sharedResourceAccess.js.map +1 -0
- package/backend/dist/services/skillService.d.ts +137 -0
- package/backend/dist/services/skillService.d.ts.map +1 -0
- package/backend/dist/services/skillService.js +852 -0
- package/backend/dist/services/skillService.js.map +1 -0
- package/backend/dist/services/toolAccessService.d.ts +9 -0
- package/backend/dist/services/toolAccessService.d.ts.map +1 -0
- package/backend/dist/services/toolAccessService.js +60 -0
- package/backend/dist/services/toolAccessService.js.map +1 -0
- package/backend/dist/services/toolApprovalService.d.ts +34 -0
- package/backend/dist/services/toolApprovalService.d.ts.map +1 -0
- package/backend/dist/services/toolApprovalService.js +188 -0
- package/backend/dist/services/toolApprovalService.js.map +1 -0
- package/backend/dist/services/toolGatewayService.d.ts +53 -0
- package/backend/dist/services/toolGatewayService.d.ts.map +1 -0
- package/backend/dist/services/toolGatewayService.js +249 -0
- package/backend/dist/services/toolGatewayService.js.map +1 -0
- package/backend/dist/services/toolServerService.d.ts +57 -0
- package/backend/dist/services/toolServerService.d.ts.map +1 -0
- package/backend/dist/services/toolServerService.js +521 -0
- package/backend/dist/services/toolServerService.js.map +1 -0
- package/backend/dist/services/voiceAccessService.d.ts +10 -0
- package/backend/dist/services/voiceAccessService.d.ts.map +1 -0
- package/backend/dist/services/voiceAccessService.js +74 -0
- package/backend/dist/services/voiceAccessService.js.map +1 -0
- package/backend/dist/services/voiceProfileService.d.ts +20 -0
- package/backend/dist/services/voiceProfileService.d.ts.map +1 -1
- package/backend/dist/services/voiceProfileService.js +60 -0
- package/backend/dist/services/voiceProfileService.js.map +1 -1
- package/backend/dist/storage.d.ts +28 -1
- package/backend/dist/storage.d.ts.map +1 -1
- package/backend/dist/storage.js +100 -1
- package/backend/dist/storage.js.map +1 -1
- package/backend/dist/storageMappers.d.ts +2 -2
- package/backend/dist/storageMappers.d.ts.map +1 -1
- package/backend/dist/storageMappers.js.map +1 -1
- package/backend/dist/types/index.d.ts +197 -2
- package/backend/dist/types/index.d.ts.map +1 -1
- package/backend/dist/types/index.js.map +1 -1
- package/backend/dist/types/tools.d.ts +137 -0
- package/backend/dist/types/tools.d.ts.map +1 -0
- package/backend/dist/types/tools.js +25 -0
- package/backend/dist/types/tools.js.map +1 -0
- package/backend/dist/utils/chatDocumentContext.d.ts +26 -1
- package/backend/dist/utils/chatDocumentContext.d.ts.map +1 -1
- package/backend/dist/utils/chatDocumentContext.js +87 -18
- package/backend/dist/utils/chatDocumentContext.js.map +1 -1
- package/backend/dist/utils/documentExtraction.d.ts +69 -0
- package/backend/dist/utils/documentExtraction.d.ts.map +1 -0
- package/backend/dist/utils/documentExtraction.js +545 -0
- package/backend/dist/utils/documentExtraction.js.map +1 -0
- package/backend/dist/utils/hybridRetrieval.d.ts +34 -0
- package/backend/dist/utils/hybridRetrieval.d.ts.map +1 -0
- package/backend/dist/utils/hybridRetrieval.js +119 -0
- package/backend/dist/utils/hybridRetrieval.js.map +1 -0
- package/backend/dist/utils/icsCalendar.d.ts +27 -0
- package/backend/dist/utils/icsCalendar.d.ts.map +1 -0
- package/backend/dist/utils/icsCalendar.js +313 -0
- package/backend/dist/utils/icsCalendar.js.map +1 -0
- package/backend/dist/utils/imageEditUpload.d.ts +29 -0
- package/backend/dist/utils/imageEditUpload.d.ts.map +1 -0
- package/backend/dist/utils/imageEditUpload.js +82 -0
- package/backend/dist/utils/imageEditUpload.js.map +1 -0
- package/backend/dist/utils/logRedaction.d.ts +2 -0
- package/backend/dist/utils/logRedaction.d.ts.map +1 -0
- package/backend/dist/utils/logRedaction.js +66 -0
- package/backend/dist/utils/logRedaction.js.map +1 -0
- package/backend/dist/utils/logger.d.ts +3 -0
- package/backend/dist/utils/logger.d.ts.map +1 -1
- package/backend/dist/utils/logger.js +63 -20
- package/backend/dist/utils/logger.js.map +1 -1
- package/backend/dist/utils/pluginChatAdapter.d.ts +5 -1
- package/backend/dist/utils/pluginChatAdapter.d.ts.map +1 -1
- package/backend/dist/utils/pluginChatAdapter.js +83 -0
- package/backend/dist/utils/pluginChatAdapter.js.map +1 -1
- package/backend/dist/utils/pluginDefinitionTrust.js +1 -1
- package/backend/dist/utils/resourceLimits.d.ts +61 -2
- package/backend/dist/utils/resourceLimits.d.ts.map +1 -1
- package/backend/dist/utils/resourceLimits.js +59 -0
- package/backend/dist/utils/resourceLimits.js.map +1 -1
- package/backend/dist/utils/toolEgress.d.ts +22 -0
- package/backend/dist/utils/toolEgress.d.ts.map +1 -0
- package/backend/dist/utils/toolEgress.js +157 -0
- package/backend/dist/utils/toolEgress.js.map +1 -0
- package/backend/dist/utils/websocketMessages.d.ts +6 -0
- package/backend/dist/utils/websocketMessages.d.ts.map +1 -1
- package/backend/dist/utils/websocketMessages.js +8 -0
- package/backend/dist/utils/websocketMessages.js.map +1 -1
- package/backend/dist/utils/zipArchive.d.ts +32 -0
- package/backend/dist/utils/zipArchive.d.ts.map +1 -0
- package/backend/dist/utils/zipArchive.js +171 -0
- package/backend/dist/utils/zipArchive.js.map +1 -0
- package/backend/dist/websocketServer.d.ts.map +1 -1
- package/backend/dist/websocketServer.js +142 -35
- package/backend/dist/websocketServer.js.map +1 -1
- package/backend/package.json +1 -1
- package/frontend/dist/artifact-runtime/.build-fingerprint +1 -1
- package/frontend/dist/assets/index-BPsH9FII.js +80 -0
- package/frontend/dist/assets/index-BtXF0Oxa.css +1 -0
- package/frontend/dist/index.html +18 -18
- package/frontend/dist/js/{ArtifactContainer-CpUi6ekF.js → ArtifactContainer-CIoFoMv8.js} +1 -1
- package/frontend/dist/js/{ArtifactDemoPage-BeNs3gHp.js → ArtifactDemoPage-D0JEIAbZ.js} +1 -1
- package/frontend/dist/js/{ArtifactSandboxFrame-qsj_Y3LV.js → ArtifactSandboxFrame-REazyIrx.js} +2 -2
- package/frontend/dist/js/ArtifactSlideOutPanel-A-i94ghF.js +1 -0
- package/frontend/dist/js/AutomationsPage-Dow_lbIf.js +1 -0
- package/frontend/dist/js/{Button-BPf_pOxH.js → Button-C0r3J9G_.js} +1 -1
- package/frontend/dist/js/CalendarPage-DLjasZOd.js +1 -0
- package/frontend/dist/js/ChannelsPage-C8hvTD7J.js +1 -0
- package/frontend/dist/js/ChatPage-BAgBHUES.js +16 -0
- package/frontend/dist/js/EvaluationsPage-Bm8FRoeX.js +2 -0
- package/frontend/dist/js/{FirstTimeSetup-Df0YJni3.js → FirstTimeSetup-BxJapNul.js} +1 -1
- package/frontend/dist/js/GalleryPage-DHz9DkK7.js +1 -0
- package/frontend/dist/js/HomePage-BqNy-FWX.js +1 -0
- package/frontend/dist/js/LibreClawPage-BDzDILjY.js +1 -0
- package/frontend/dist/js/{ModelManagerModals-DcLGYN3l.js → ModelManagerModals-DX9eT5r2.js} +1 -1
- package/frontend/dist/js/ModelSelector-ol8mK2ja.js +1 -0
- package/frontend/dist/js/NotesPage-DzHEx2O4.js +3 -0
- package/frontend/dist/js/{OptimizedSyntaxHighlighter-Dz7D1LPB.js → OptimizedSyntaxHighlighter-CZNPwN0i.js} +1 -1
- package/frontend/dist/js/PersonasPage-M_WKH2a9.js +13 -0
- package/frontend/dist/js/PluginUsagePage-Ctoka6JZ.js +1 -0
- package/frontend/dist/js/RichMessageContent-BqgafH4p.js +3 -0
- package/frontend/dist/js/SettingsModal-R9EDadAV.js +19 -0
- package/frontend/dist/js/{SettingsToggle-woG_WebF.js → SettingsToggle-BIVyfGjl.js} +1 -1
- package/frontend/dist/js/SystemPage-aOkrSuY7.js +1 -0
- package/frontend/dist/js/UserManagementPage-BOuaX3ay.js +1 -0
- package/frontend/dist/js/WorkPage-DxZISerQ.js +6 -0
- package/frontend/dist/js/api-6bSMtSNh.js +14 -0
- package/frontend/dist/js/{appStore-0JnCUlEq.js → appStore-CdObhQBb.js} +2 -2
- package/frontend/dist/js/ar-DT_VLBO3.js +2 -0
- package/frontend/dist/js/{authStore-DbMdvNgJ.js → authStore-DbqqrfZv.js} +3 -3
- package/frontend/dist/js/{babel-BsYoxD-7.js → babel-DSqqk5kt.js} +1 -1
- package/frontend/dist/js/bn-BrvEqhGA.js +2 -0
- package/frontend/dist/js/chatStore-DbZPJNsu.js +3 -0
- package/frontend/dist/js/{config-DSOYQ9a3.js → config-8KdgjtEx.js} +1 -1
- package/frontend/dist/js/cs-BthnM_YI.js +2 -0
- package/frontend/dist/js/da-DCth-6_j.js +2 -0
- package/frontend/dist/js/de-BBWt0gJ_.js +2 -0
- package/frontend/dist/js/es-DuslOPqM.js +2 -0
- package/frontend/dist/js/{estree-BcnBcOAx.js → estree-BU5-LV_1.js} +3 -3
- package/frontend/dist/js/evaluationsApi-CwZJsgeG.js +1 -0
- package/frontend/dist/js/fr-DZAeg46S.js +2 -0
- package/frontend/dist/js/hi-ijDSiY77.js +2 -0
- package/frontend/dist/js/{html-DkY55Jys.js → html-DeoAy2bo.js} +2 -2
- package/frontend/dist/js/id-BS6qS0oq.js +2 -0
- package/frontend/dist/js/is-CO2PMDte.js +2 -0
- package/frontend/dist/js/it-ChhxT4hs.js +2 -0
- package/frontend/dist/js/ja-cyeqUeJN.js +2 -0
- package/frontend/dist/js/ko-CfqHTLXj.js +2 -0
- package/frontend/dist/js/{markdown-IZSI9DXw.js → markdown-DOLsYkBY.js} +3 -3
- package/frontend/dist/js/markdown-core-BK7WVOb7.js +32 -0
- package/frontend/dist/js/{markdown-math-DK846gXU.js → markdown-math-e1ByS3KY.js} +5 -5
- package/frontend/dist/js/{messageCodeStyles-BFNR9Wv6.js → messageCodeStyles-DhVgizF-.js} +2 -2
- package/frontend/dist/js/ms-DZ5pACe1.js +2 -0
- package/frontend/dist/js/nl-BsRsnOVp.js +2 -0
- package/frontend/dist/js/pl-DXSTAW4M.js +2 -0
- package/frontend/dist/js/{postcss-BJ0okz7n.js → postcss-Bg15EcFE.js} +1 -1
- package/frontend/dist/js/pt-DmDx0JxB.js +2 -0
- package/frontend/dist/js/{react-vendor-C5yShNlM.js → react-vendor-BG_HPV6X.js} +1 -1
- package/frontend/dist/js/router-vendor-CbexJIsv.js +1 -0
- package/frontend/dist/js/ru-d2g8EWfY.js +2 -0
- package/frontend/dist/js/{standalone-Csw3jfJ_.js → standalone-BO5pzI8_.js} +3 -3
- package/frontend/dist/js/sv-CIhYUTVQ.js +2 -0
- package/frontend/dist/js/{syntax-highlight-3EEX6CGL.js → syntax-highlight-DcR9Vhb7.js} +3 -3
- package/frontend/dist/js/th-B3wSxanB.js +2 -0
- package/frontend/dist/js/tr-R4UGgPOY.js +2 -0
- package/frontend/dist/js/{typescript-CnF4UVx7.js → typescript-6GJ8APmn.js} +1 -1
- package/frontend/dist/js/ui-CV0LYmkM.js +2 -0
- package/frontend/dist/js/ui-vendor-CWjIBW-z.js +177 -0
- package/frontend/dist/js/uk-BzUF4Vkt.js +2 -0
- package/frontend/dist/js/{useTranslation-Bho4HCyg.js → useTranslation-5b5UhAc9.js} +1 -1
- package/frontend/dist/js/{utils-D9W1Lnkn.js → utils-BGrdX9ie.js} +1 -1
- package/frontend/dist/js/{utils-vendor-DWh39_3x.js → utils-vendor-9bQ62WeD.js} +1 -1
- package/frontend/dist/js/vi-CKc6Fg4h.js +2 -0
- package/frontend/dist/js/{workApi-C3uy9EDT.js → workApi-BruWTlHM.js} +3 -3
- package/frontend/dist/js/{yaml-DzT5hBSH.js → yaml-DUeWcOOH.js} +2 -2
- package/frontend/dist/js/zh-CXL-kDe8.js +2 -0
- package/package.json +2 -2
- package/plugins/openai.json +52 -9
- package/frontend/dist/assets/index-6o-Hc2wS.js +0 -41
- package/frontend/dist/assets/index-D-pM957b.css +0 -1
- package/frontend/dist/js/ArtifactSlideOutPanel-CSFRluWA.js +0 -1
- package/frontend/dist/js/AutomationsPage-KUeWoZNv.js +0 -1
- package/frontend/dist/js/CalendarPage-D9I972w8.js +0 -1
- package/frontend/dist/js/ChatPage-CmBx4oAL.js +0 -16
- package/frontend/dist/js/GalleryPage-bLCrdJN_.js +0 -1
- package/frontend/dist/js/HomePage-Uc6PEg-U.js +0 -1
- package/frontend/dist/js/LibreClawPage-CG63DHg1.js +0 -1
- package/frontend/dist/js/ModelSelector-yxJC64rM.js +0 -1
- package/frontend/dist/js/ModelsPage-1R_TxgmJ.js +0 -2
- package/frontend/dist/js/NotesPage-L65j5HoW.js +0 -1
- package/frontend/dist/js/PersonasPage-CKeBpHIH.js +0 -13
- package/frontend/dist/js/PluginUsagePage-BX1SKMbW.js +0 -1
- package/frontend/dist/js/RichMessageContent-DiySVYGB.js +0 -3
- package/frontend/dist/js/SettingsModal-68SG1uZ2.js +0 -1
- package/frontend/dist/js/SystemPage-CytpZiQV.js +0 -1
- package/frontend/dist/js/UserManagementPage-BzJBvZiS.js +0 -1
- package/frontend/dist/js/WorkPage-C8gr0QJe.js +0 -6
- package/frontend/dist/js/api-BDtqBtqw.js +0 -14
- package/frontend/dist/js/ar-CSpi37Gr.js +0 -2
- package/frontend/dist/js/bn-CyH1BeDD.js +0 -2
- package/frontend/dist/js/chatStore-CHQ2uINS.js +0 -3
- package/frontend/dist/js/cs-Cv2NfRK5.js +0 -2
- package/frontend/dist/js/da-D6D6IvPK.js +0 -2
- package/frontend/dist/js/de-BNoJJTrT.js +0 -2
- package/frontend/dist/js/es-kzo9C7q_.js +0 -2
- package/frontend/dist/js/fr-CjHYvJRp.js +0 -2
- package/frontend/dist/js/hi-BU98AdCQ.js +0 -2
- package/frontend/dist/js/id-CpdedejX.js +0 -2
- package/frontend/dist/js/is-Cp5dDWBH.js +0 -2
- package/frontend/dist/js/it-CuH_cK4U.js +0 -2
- package/frontend/dist/js/ja-BWXXXiHn.js +0 -2
- package/frontend/dist/js/ko-DQgv2M1t.js +0 -2
- package/frontend/dist/js/markdown-core-BmPPZiuD.js +0 -31
- package/frontend/dist/js/ms-DCcRoIcX.js +0 -2
- package/frontend/dist/js/nl-CbKR1_EU.js +0 -2
- package/frontend/dist/js/pl-CRyJZccn.js +0 -2
- package/frontend/dist/js/pt-BXYmHFGH.js +0 -2
- package/frontend/dist/js/router-vendor-DGFGM3EP.js +0 -1
- package/frontend/dist/js/ru-M9SyZG4b.js +0 -2
- package/frontend/dist/js/sv-DJ486LTU.js +0 -2
- package/frontend/dist/js/th-Ch7gKtZv.js +0 -2
- package/frontend/dist/js/tr-ClehWhSC.js +0 -2
- package/frontend/dist/js/ui-CC-K19wO.js +0 -2
- package/frontend/dist/js/ui-vendor-B1UgO3vd.js +0 -177
- package/frontend/dist/js/uk-BqAd5zHF.js +0 -2
- package/frontend/dist/js/vi-D9gjlDVB.js +0 -2
- package/frontend/dist/js/zh-DKTyHkiR.js +0 -2
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{r as e}from"./rolldown-runtime-hePW80VL.js";import{m as t,p as n}from"./markdown-core-BmPPZiuD.js";import{n as r}from"./react-vendor-C5yShNlM.js";import{d as i}from"./router-vendor-DGFGM3EP.js";import{t as a}from"./useTranslation-Bho4HCyg.js";import{t as o}from"./utils-D9W1Lnkn.js";import{p as s,s as c,t as l}from"./chatStore-CHQ2uINS.js";import{Cn as u,D as d,Dn as f,Et as p,F as m,Jt as h,Qt as g,Rn as _,U as v,V as y,Xt as b,_n as x,b as ee,c as te,gn as ne,n as S,pt as C,rn as w,t as T,wt as re,xt as ie}from"./ui-vendor-B1UgO3vd.js";import{t as ae}from"./logger-DSXjF4ye.js";import{h as E,y as oe}from"./api-BDtqBtqw.js";import{n as se}from"./authStore-DbMdvNgJ.js";import{x as ce}from"../assets/index-6o-Hc2wS.js";var D=e(t(),1),le=r(),O=n();function k(e){return e>=1e6?`${(e/1e6).toFixed(1)}M`:e>=1e3?`${(e/1e3).toFixed(1)}K`:e.toString()}function ue({hfTask:e,hfSort:t,canInstallModels:n,loadingHf:r,hfModels:i,expandedHfModel:s,hfGgufFiles:c,loadingGguf:l,pullingModel:u,pullProgress:d,setHfTask:f,setHfSort:p,onToggleHfModel:m,onPullHfGguf:g,onCancelPull:_,onRefreshHfModels:v}){let{t:x}=a();return(0,O.jsxs)(`div`,{className:`flex-1 flex flex-col overflow-hidden`,children:[(0,O.jsx)(`div`,{className:`px-3 py-2 border-b border-gray-200 dark:border-dark-300 flex-shrink-0 space-y-2`,children:(0,O.jsxs)(`div`,{className:`flex gap-2`,children:[(0,O.jsxs)(`select`,{value:e,onChange:e=>f(e.target.value),onMouseDown:e=>e.stopPropagation(),className:`flex-1 px-2 py-1.5 rounded-lg border text-xs bg-gray-50 dark:bg-dark-50 border-gray-200 dark:border-dark-300 text-gray-900 dark:text-gray-100`,children:[(0,O.jsx)(`option`,{value:`text-generation`,children:x(`modelManager.huggingface.taskTextGeneration`)}),(0,O.jsx)(`option`,{value:`text-to-speech`,children:x(`modelManager.huggingface.taskTextToSpeech`)}),(0,O.jsx)(`option`,{value:`text-to-image`,children:x(`modelManager.huggingface.taskTextToImage`)}),(0,O.jsx)(`option`,{value:`automatic-speech-recognition`,children:x(`modelManager.huggingface.taskSpeechRecognition`)})]}),(0,O.jsxs)(`select`,{value:t,onChange:e=>p(e.target.value),onMouseDown:e=>e.stopPropagation(),className:`px-2 py-1.5 rounded-lg border text-xs bg-gray-50 dark:bg-dark-50 border-gray-200 dark:border-dark-300 text-gray-900 dark:text-gray-100`,children:[(0,O.jsx)(`option`,{value:`downloads`,children:x(`modelManager.huggingface.sortDownloads`)}),(0,O.jsx)(`option`,{value:`likes`,children:x(`modelManager.huggingface.sortLikes`)}),(0,O.jsx)(`option`,{value:`lastModified`,children:x(`modelManager.huggingface.sortRecent`)})]})]})}),(0,O.jsxs)(`div`,{className:`scroll-region min-h-0 flex-1 scrollbar-thin`,children:[!n&&(0,O.jsx)(`div`,{className:`mx-3 mb-1 mt-3 rounded-lg border border-amber-200 bg-amber-500/10 px-3 py-2 text-xs text-ink dark:border-amber-800 dark:bg-amber-900/20`,children:x(`modelSelector.pullRestricted`)}),r?(0,O.jsx)(`div`,{className:`flex items-center justify-center py-12`,children:(0,O.jsx)(C,{className:`h-6 w-6 animate-spin text-gray-400`})}):i.length===0?(0,O.jsxs)(`div`,{className:`px-4 py-8 text-center text-gray-500 dark:text-gray-400`,children:[(0,O.jsx)(T,{className:`h-8 w-8 mx-auto mb-2 text-gray-300 dark:text-gray-600`}),(0,O.jsx)(`p`,{className:`text-sm`,children:x(`modelManager.huggingface.noModelsFound`)})]}):(0,O.jsx)(`div`,{className:`divide-y divide-gray-100 dark:divide-dark-200`,children:i.map(e=>{let t=s===e.id,r=c[e.id]||[],i=l===e.id;return(0,O.jsxs)(`div`,{className:`bg-white dark:bg-dark-100`,children:[(0,O.jsx)(`div`,{className:`px-3 py-3 cursor-pointer hover:bg-gray-50 dark:hover:bg-dark-200`,onMouseDown:t=>{t.preventDefault(),t.stopPropagation(),m(e.id)},children:(0,O.jsxs)(`div`,{className:`flex items-start gap-3`,children:[(0,O.jsx)(`div`,{className:`flex-shrink-0 rounded-lg bg-yellow-500/20 p-2 dark:bg-yellow-900/30`,children:(0,O.jsx)(T,{className:`h-4 w-4 text-yellow-600 dark:text-yellow-400`})}),(0,O.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,O.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,O.jsx)(`h4`,{dir:`ltr`,className:`text-sm font-medium text-gray-900 dark:text-gray-100 truncate`,children:e.id}),e.gated&&(0,O.jsx)(`span`,{className:`rounded bg-yellow-500/20 px-1.5 py-0.5 text-xs text-ink dark:bg-yellow-900/30`,children:`Gated`})]}),(0,O.jsxs)(`p`,{className:`text-xs text-gray-500 dark:text-gray-400 mt-0.5`,children:[`by `,e.author]}),(0,O.jsxs)(`div`,{className:`flex items-center gap-3 mt-1.5 text-xs text-gray-400 dark:text-gray-500`,children:[(0,O.jsxs)(`span`,{className:`flex items-center gap-1`,children:[(0,O.jsx)(b,{className:`h-3 w-3`}),k(e.downloads)]}),(0,O.jsxs)(`span`,{className:`flex items-center gap-1`,children:[(0,O.jsx)(re,{className:`h-3 w-3`}),k(e.likes)]}),e.pipeline_tag&&(0,O.jsx)(`span`,{className:`px-1.5 py-0.5 rounded bg-gray-100 dark:bg-dark-200`,children:e.pipeline_tag})]})]}),(0,O.jsxs)(`div`,{className:`flex items-center gap-2 flex-shrink-0`,children:[(0,O.jsx)(`a`,{href:`https://huggingface.co/${e.id}`,target:`_blank`,rel:`noopener noreferrer`,onMouseDown:e=>e.stopPropagation(),className:`p-1.5 rounded-lg hover:bg-gray-100 dark:hover:bg-dark-200`,children:(0,O.jsx)(h,{className:`h-4 w-4 text-gray-400`})}),(0,O.jsx)(ne,{className:o(`h-4 w-4 text-gray-400 transition-transform`,t&&`rotate-180`)})]})]})}),t&&(0,O.jsx)(`div`,{className:`px-3 pb-3 pt-1 border-t border-gray-100 dark:border-dark-200 bg-gray-50 dark:bg-dark-200`,children:i?(0,O.jsxs)(`div`,{className:`flex items-center justify-center py-4`,children:[(0,O.jsx)(C,{className:`h-4 w-4 animate-spin text-gray-400`}),(0,O.jsx)(`span`,{className:`ml-2 text-xs text-gray-500`,children:x(`modelManager.huggingface.checkingGguf`)})]}):r.length===0?(0,O.jsx)(`div`,{className:`py-4 text-center text-xs text-gray-500 dark:text-gray-400`,children:x(`modelManager.huggingface.noGgufAvailable`)}):(0,O.jsxs)(`div`,{className:`space-y-2`,children:[(0,O.jsx)(`div`,{className:`text-xs font-medium text-gray-600 dark:text-gray-300 mb-2`,children:x(`modelManager.huggingface.ggufFilesCount`,{count:r.length})}),r.map(e=>{let t=u===e.ollamaCommand;return(0,O.jsxs)(`div`,{className:`flex items-center gap-2 p-2 rounded-lg bg-white dark:bg-dark-100 border border-gray-200 dark:border-dark-300`,children:[(0,O.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,O.jsx)(`div`,{className:`text-xs font-medium text-gray-800 dark:text-gray-200 truncate`,children:e.filename}),(0,O.jsxs)(`div`,{className:`flex items-center gap-2 mt-0.5 text-xs text-gray-500 dark:text-gray-400`,children:[(0,O.jsx)(`span`,{children:e.sizeFormatted}),e.quantization&&(0,O.jsx)(`span`,{className:`px-1.5 py-0.5 rounded bg-purple-100 dark:bg-purple-900/30 text-purple-700 dark:text-purple-400`,children:e.quantization})]})]}),t?(0,O.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,O.jsx)(`div`,{className:`text-xs text-gray-500 w-12 text-right`,children:d?.percent===void 0?`...`:`${d.percent}%`}),(0,O.jsx)(`button`,{onMouseDown:e=>{e.preventDefault(),e.stopPropagation(),_()},className:`p-1.5 rounded-lg text-red-500 hover:bg-red-50 dark:hover:bg-red-900/20`,children:(0,O.jsx)(S,{className:`h-4 w-4`})})]}):n?(0,O.jsxs)(`button`,{onMouseDown:t=>{t.preventDefault(),t.stopPropagation(),g(e.ollamaCommand,e.filename)},disabled:!!u,className:o(`px-3 py-1.5 rounded-lg text-xs font-medium`,`bg-primary-100 dark:bg-primary-900/30`,`text-primary-700 dark:text-primary-400`,`hover:bg-primary-200 dark:hover:bg-primary-900/50`,`disabled:opacity-50 disabled:cursor-not-allowed`),children:[(0,O.jsx)(b,{className:`h-3 w-3 inline mr-1`}),x(`models.pull`)]}):(0,O.jsx)(`span`,{className:`rounded bg-amber-500/20 px-2 py-1 text-[11px] font-medium text-ink dark:bg-amber-900/30`,children:x(`modelSelector.adminOnlyPull`)})]},e.filename)}),u?.startsWith(`hf.co/`)&&u.includes(e.id)&&d?.percent!==void 0&&(0,O.jsx)(`div`,{className:`w-full bg-gray-200 dark:bg-dark-300 rounded-full h-1.5 overflow-hidden mt-2`,children:(0,O.jsx)(`div`,{className:`h-1.5 rounded-full bg-primary-500 transition-all duration-300`,style:{width:`${d.percent}%`}})})]})})]},e.id)})})]}),(0,O.jsxs)(`div`,{className:`px-3 py-2 border-t border-gray-200 dark:border-dark-300 flex items-center justify-between flex-shrink-0`,children:[(0,O.jsxs)(`a`,{href:`https://huggingface.co/models`,target:`_blank`,rel:`noopener noreferrer`,onMouseDown:e=>e.stopPropagation(),className:`text-xs text-primary-600 dark:text-primary-400 hover:underline flex items-center gap-1`,children:[(0,O.jsx)(h,{className:`h-3 w-3`}),x(`modelManager.huggingface.browseAllLink`)]}),(0,O.jsx)(`button`,{onMouseDown:e=>{e.preventDefault(),e.stopPropagation(),v()},className:`p-1.5 rounded-lg hover:bg-gray-100 dark:hover:bg-dark-200`,children:(0,O.jsx)(y,{className:o(`h-3.5 w-3.5 text-gray-400`,r&&`animate-spin`)})})]})]})}function de({filteredGroups:e,selectedModel:t,showImageGen:n,getModelValue:r,getModelIcon:i,getModelLabel:s,getModelSubLabel:c,onModelSelect:l,onOpenGallery:u}){let{t:d}=a();return(0,O.jsxs)(`div`,{className:`scroll-region min-h-0 flex-1 scrollbar-thin scrollbar-thumb-gray-300 dark:scrollbar-thumb-dark-400`,children:[e.length>0?e.map(e=>(0,O.jsxs)(`div`,{children:[(0,O.jsx)(`div`,{className:`px-3 py-2 text-xs font-semibold text-gray-500 dark:text-gray-400 bg-gray-100 dark:bg-dark-300 border-b border-gray-200 dark:border-dark-400 sticky top-0`,children:(0,O.jsxs)(`div`,{className:`flex items-center gap-2`,children:[e.icon,e.label,` (`,e.models.length,`)`]})}),e.models.map(e=>{let n=r(e);return(0,O.jsx)(`button`,{type:`button`,"data-testid":`model-selector-option`,"data-model-value":n,"aria-pressed":t===n,onClick:()=>l(n),className:o(`block w-full cursor-pointer border-b border-gray-100 px-3 py-3 text-start last:border-b-0 dark:border-dark-200`,`hover:bg-gray-50 dark:hover:bg-dark-200`,`bg-white dark:bg-dark-100 transition-colors`,`focus-visible:relative focus-visible:z-10 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-primary-500/50`,t===n&&`bg-primary-50 dark:bg-primary-900/30`),children:(0,O.jsxs)(`div`,{className:`flex items-center gap-3`,children:[i(e),(0,O.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,O.jsx)(`div`,{dir:e.isPersona?`auto`:`ltr`,className:`text-sm font-medium text-gray-900 dark:text-gray-100 truncate`,children:s(e)}),c(e)&&(0,O.jsx)(`div`,{dir:`auto`,className:`text-xs text-gray-500 dark:text-gray-400 truncate`,children:c(e)})]}),t===n&&(0,O.jsx)(x,{className:`h-4 w-4 text-primary-600 dark:text-primary-400 flex-shrink-0`})]})},n)})]},e.type)):(0,O.jsxs)(`div`,{className:`px-4 py-8 text-center text-gray-500 dark:text-gray-400`,children:[(0,O.jsx)(g,{className:`h-8 w-8 mx-auto mb-2 text-gray-300 dark:text-gray-600`}),(0,O.jsx)(`p`,{className:`text-sm`,children:d(`models.noModelsFound`)})]}),n&&(0,O.jsxs)(`div`,{className:`border-t border-gray-200 dark:border-dark-300`,children:[(0,O.jsx)(`div`,{className:`px-3 py-2 text-xs font-semibold text-gray-500 dark:text-gray-400 bg-gray-100 dark:bg-dark-300`,children:(0,O.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,O.jsx)(v,{className:`h-4 w-4 text-blue-600 dark:text-blue-400`}),d(`modelSelector.actions`)]})}),(0,O.jsx)(`div`,{onMouseDown:e=>{e.preventDefault(),u()},className:`px-3 py-3 cursor-pointer hover:bg-blue-50 dark:hover:bg-blue-900/20 bg-white dark:bg-dark-100`,children:(0,O.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,O.jsx)(ie,{className:`h-4 w-4 text-blue-600 dark:text-blue-400`}),(0,O.jsxs)(`div`,{className:`flex-1`,children:[(0,O.jsx)(`div`,{className:`text-sm font-medium text-gray-900 dark:text-gray-100`,children:d(`gallery.generate`)}),(0,O.jsx)(`div`,{className:`text-xs text-gray-500 dark:text-gray-400`,children:d(`gallery.generateDescription`)})]})]})})]})]})}function fe({libraryCategories:e,libraryCategory:t,canInstallModels:n,loadingLibrary:r,filteredLibraryModels:i,pullingModel:s,pullProgress:c,setLibraryCategory:l,isModelInstalled:u,onModelSelect:d,onPullModel:f,onCancelPull:p,onRefreshLibrary:m}){let{t:g}=a();return(0,O.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col overflow-hidden`,children:[(0,O.jsx)(`div`,{className:`px-3 py-2 border-b border-gray-200 dark:border-dark-300 flex-shrink-0`,children:(0,O.jsx)(`div`,{className:`flex flex-wrap gap-1.5`,children:e.map(e=>(0,O.jsx)(`button`,{onMouseDown:t=>{t.preventDefault(),t.stopPropagation(),l(e)},className:o(`px-2.5 py-1 rounded-full text-xs font-medium transition-colors`,t===e?`bg-primary-100 dark:bg-primary-900/30 text-primary-700 dark:text-primary-400`:`bg-gray-100 dark:bg-dark-200 text-gray-600 dark:text-gray-400 hover:bg-gray-200 dark:hover:bg-dark-300`),children:e.charAt(0).toUpperCase()+e.slice(1)},e))})}),(0,O.jsxs)(`div`,{className:`scroll-region min-h-0 flex-1 scrollbar-thin`,children:[!n&&(0,O.jsx)(`div`,{className:`mx-3 mb-1 mt-3 rounded-lg border border-amber-200 bg-amber-500/10 px-3 py-2 text-xs text-ink dark:border-amber-800 dark:bg-amber-900/20`,children:g(`modelSelector.pullRestricted`)}),r?(0,O.jsx)(`div`,{className:`flex items-center justify-center py-12`,children:(0,O.jsx)(C,{className:`h-6 w-6 animate-spin text-gray-400`})}):i.length===0?(0,O.jsxs)(`div`,{className:`px-4 py-8 text-center text-gray-500 dark:text-gray-400`,children:[(0,O.jsx)(w,{className:`h-8 w-8 mx-auto mb-2 text-gray-300 dark:text-gray-600`}),(0,O.jsx)(`p`,{className:`text-sm`,children:g(`models.noModelsFound`)})]}):(0,O.jsx)(`div`,{className:`divide-y divide-gray-100 dark:divide-dark-200`,children:i.map(e=>{let t=u(e.name),r=s===e.name;return(0,O.jsxs)(`div`,{className:o(`px-3 py-3 bg-white dark:bg-dark-100`,t&&`bg-green-50/50 dark:bg-green-900/10`),children:[(0,O.jsxs)(`div`,{className:`flex items-start gap-3`,children:[(0,O.jsx)(`div`,{className:`p-2 rounded-lg bg-blue-100 dark:bg-blue-900/30 flex-shrink-0`,children:(0,O.jsx)(w,{className:`h-4 w-4 text-blue-600 dark:text-blue-400`})}),(0,O.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,O.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,O.jsx)(`h4`,{dir:`ltr`,className:`text-sm font-medium text-gray-900 dark:text-gray-100 truncate`,children:e.name}),t&&(0,O.jsx)(`span`,{className:`px-1.5 py-0.5 rounded text-xs bg-green-100 dark:bg-green-900/30 text-green-700 dark:text-green-400`,children:g(`modelSelector.installed`)}),(e.category===`cloud`||e.tags?.includes(`cloud`))&&(0,O.jsxs)(`span`,{className:`px-1.5 py-0.5 rounded text-xs bg-blue-100 dark:bg-blue-900/30 text-blue-700 dark:text-blue-400 flex items-center gap-1`,children:[(0,O.jsx)(w,{className:`h-3 w-3`}),`Cloud`]})]}),(0,O.jsx)(`p`,{className:`text-xs text-gray-500 dark:text-gray-400 line-clamp-1 mt-0.5`,children:e.description}),(0,O.jsxs)(`div`,{className:`flex items-center gap-2 mt-1.5`,children:[e.sizes.slice(0,3).map(e=>(0,O.jsx)(`span`,{className:`px-1.5 py-0.5 rounded text-xs bg-gray-100 dark:bg-dark-200 text-gray-600 dark:text-gray-400`,children:e},e)),e.pulls&&(0,O.jsxs)(`span`,{className:`text-xs text-gray-400 dark:text-gray-500 flex items-center gap-1`,children:[(0,O.jsx)(b,{className:`h-3 w-3`}),e.pulls]})]})]}),(0,O.jsx)(`div`,{className:`flex-shrink-0`,children:r?(0,O.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,O.jsx)(`div`,{className:`text-xs text-gray-500 w-12 text-right`,children:c?.percent===void 0?`...`:`${c.percent}%`}),(0,O.jsx)(`button`,{onClick:p,className:`p-1.5 rounded-lg text-red-500 hover:bg-red-50 dark:hover:bg-red-900/20`,children:(0,O.jsx)(S,{className:`h-4 w-4`})})]}):t?(0,O.jsx)(`button`,{onClick:()=>d(e.name),className:`px-3 py-1.5 rounded-lg text-xs font-medium bg-green-100 dark:bg-green-900/30 text-green-700 dark:text-green-400 hover:bg-green-200 dark:hover:bg-green-900/50`,children:g(`modelSelector.use`)}):n?(0,O.jsxs)(`button`,{onClick:()=>f(e.name),className:`px-3 py-1.5 rounded-lg text-xs font-medium bg-primary-100 dark:bg-primary-900/30 text-primary-700 dark:text-primary-400 hover:bg-primary-200 dark:hover:bg-primary-900/50`,children:[(0,O.jsx)(b,{className:`h-3 w-3 inline mr-1`}),g(`modelSelector.pull`)]}):(0,O.jsx)(`span`,{className:`rounded bg-amber-500/20 px-2 py-1 text-[11px] font-medium text-ink dark:bg-amber-900/30`,children:g(`modelSelector.adminOnlyPull`)})})]}),r&&c?.percent!==void 0&&(0,O.jsx)(`div`,{className:`mt-2 w-full bg-gray-200 dark:bg-dark-300 rounded-full h-1.5 overflow-hidden`,children:(0,O.jsx)(`div`,{className:`h-1.5 rounded-full bg-primary-500 transition-all duration-300`,style:{width:`${c.percent}%`}})})]},e.name)})})]}),(0,O.jsxs)(`div`,{className:`px-3 py-2 border-t border-gray-200 dark:border-dark-300 flex items-center justify-between flex-shrink-0`,children:[(0,O.jsxs)(`a`,{href:`https://ollama.com/library`,target:`_blank`,rel:`noopener noreferrer`,onMouseDown:e=>e.stopPropagation(),className:`text-xs text-primary-600 dark:text-primary-400 hover:underline flex items-center gap-1`,children:[(0,O.jsx)(h,{className:`h-3 w-3`}),g(`modelManager.huggingface.browseAllLink`)]}),(0,O.jsx)(`button`,{onMouseDown:e=>{e.preventDefault(),e.stopPropagation(),m()},className:`p-1.5 rounded-lg hover:bg-gray-100 dark:hover:bg-dark-200`,children:(0,O.jsx)(y,{className:o(`h-3.5 w-3.5 text-gray-400`,r&&`animate-spin`)})})]})]})}var pe=ae(`components:model-selector`),A=({models:e,selectedModel:t,onModelChange:n,currentPersona:r,className:h,disabled:g=!1,compact:v=!1,showImageGen:y=!1,onModelsRefresh:b,getModelValue:x,getModelLabel:C,getModelTitle:re,triggerRef:ie,triggerTestId:ae,selectTestId:k,ariaLabel:A})=>{let{t:j}=a(),[M,me]=(0,D.useState)(!1),[N,he]=(0,D.useState)(``),[P,F]=(0,D.useState)(`installed`),ge=(0,D.useRef)(null),I=(0,D.useRef)(null),L=(0,D.useRef)(null),R=(0,D.useRef)(null),_e=i(),{user:ve,systemInfo:ye}=se(),z=ve?.role===`admin`||ye?.requiresAuth===!1,[B,be]=(0,D.useState)(`all`),[xe,Se]=(0,D.useState)(``),[V,Ce]=(0,D.useState)(`text-generation`),[H,we]=(0,D.useState)(`downloads`),[Te,Ee]=(0,D.useState)(``),[U,De]=(0,D.useState)(null),[W,Oe]=(0,D.useState)({}),[ke,Ae]=(0,D.useState)(null),[G,K]=(0,D.useState)(null),[je,q]=(0,D.useState)(null),[Me,J]=(0,D.useState)(null),Ne=[`all`,`general`,`coding`,`reasoning`,`vision`,`embedding`,`cloud`],Pe=[{type:`legacy`,label:j(`modelSelector.providerNotRecorded`,`Provider not recorded`),icon:(0,O.jsx)(u,{className:`h-4 w-4 text-gray-500 dark:text-dark-600`}),models:e.filter(e=>e.isLegacySelection),color:`gray`},{type:`unavailable`,label:j(`modelSelector.unavailableSelections`,`Unavailable selections`),icon:(0,O.jsx)(S,{className:`h-4 w-4 text-gray-500 dark:text-dark-600`}),models:e.filter(e=>e.isUnavailable&&!e.isLegacySelection),color:`gray`},{type:`personas`,label:j(`modelSelector.personas`),icon:(0,O.jsx)(te,{className:`h-4 w-4 text-gray-500 dark:text-dark-600`}),models:e.filter(e=>e.isPersona&&!e.isUnavailable),color:`purple`},{type:`agents`,label:j(`modelSelector.agentModels`,`Agents`),icon:(0,O.jsx)(ee,{className:`h-4 w-4 text-gray-500 dark:text-dark-600`}),models:e.filter(e=>e.isAgent&&!e.isUnavailable),color:`green`},{type:`ollama`,label:j(`modelSelector.ollamaModels`),icon:(0,O.jsx)(f,{className:`h-4 w-4 text-gray-500 dark:text-dark-600`}),models:e.filter(e=>s(e)&&!e.name.includes(`embed`)),color:`green`},{type:`plugins`,label:j(`modelSelector.pluginModels`),icon:(0,O.jsx)(T,{className:`h-4 w-4 text-gray-500 dark:text-dark-600`}),models:e.filter(e=>e.isPlugin&&!e.isUnavailable),color:`green`}].filter(e=>e.models.length>0).map(e=>({...e,models:e.models.filter(e=>e.name.toLowerCase().includes(N.toLowerCase())||e.personaName&&e.personaName.toLowerCase().includes(N.toLowerCase())||e.pluginName&&e.pluginName.toLowerCase().includes(N.toLowerCase()))})).filter(e=>e.models.length>0),Y=e=>x?.(e)??e.name,Fe=l(e=>e.modelMetadata),X=e.find(e=>Y(e)===t);(0,D.useImperativeHandle)(ie,()=>L.current);let Z=(0,D.useCallback)((e=!0)=>{me(!1),he(``),e&&window.requestAnimationFrame(()=>L.current?.focus())},[]),{data:Ie=[],isLoading:Le,refetch:Re}=ce({queryKey:[`ollama-library-selector`,xe,B===`cloud`?`cloud`:`all`],queryFn:async()=>{let e=await E.getLibraryModels({search:xe||void 0,sort:`popular`,category:B===`cloud`?`cloud`:void 0});return e.success&&e.data?e.data:[]},enabled:M&&P===`ollama`}),{data:ze=[],isLoading:Be,refetch:Ve}=ce({queryKey:[`hf-models-selector`,V,Te,H],queryFn:async()=>{let e=await oe.getModels({task:V,search:Te||void 0,sort:H,limit:30});return e.success&&e.data?e.data:[]},enabled:M&&P===`huggingface`}),He=Ie.filter(e=>{let t=!N||e.name.toLowerCase().includes(N.toLowerCase())||e.description.toLowerCase().includes(N.toLowerCase()),n=B===`all`||e.category===B;return t&&n}),Ue=(0,D.useCallback)(async e=>{let[t,n]=e.split(`/`);if(!(!t||!n)){Ae(e);try{let r=await oe.getGgufFiles(t,n);r.success&&r.data&&Oe(t=>({...t,[e]:r.data}))}catch(e){pe.error(`Failed to load GGUF files:`,e)}finally{Ae(null)}}},[]),We=(0,D.useCallback)(e=>{U===e?De(null):(De(e),W[e]||Ue(e))},[U,W,Ue]),Ge=(0,D.useCallback)((e,t)=>{if(!z){_.error(j(`modelSelector.pullRestricted`));return}if(!G){K(e),q({status:`starting`});try{let n=E.pullModelStream(e,e=>{q(e)},()=>{q(null),K(null),J(null),_.success(`Downloaded ${t}`),b?.()},e=>{q(null),K(null),J(null),_.error(`Failed to download: ${e}`)});J(()=>n)}catch{q(null),K(null),_.error(`Failed to start download`)}}},[z,b,G,j]);(0,D.useEffect)(()=>{let e=setTimeout(()=>{P===`huggingface`?Ee(N):P===`ollama`&&Se(N)},300);return()=>clearTimeout(e)},[N,P]),(0,D.useEffect)(()=>{if(!M)return;let e=e=>{if(e.key===`Escape`){e.preventDefault(),Z();return}if(e.key===`Tab`&&I.current){let t=Array.from(I.current.querySelectorAll(`button:not([disabled]), input:not([disabled]), [tabindex]:not([tabindex="-1"])`)).filter(e=>e.offsetParent!==null),n=t[0],r=t[t.length-1];if(!n||!r)return;e.shiftKey&&document.activeElement===n?(e.preventDefault(),r.focus()):!e.shiftKey&&document.activeElement===r&&(e.preventDefault(),n.focus())}};return document.addEventListener(`keydown`,e),()=>document.removeEventListener(`keydown`,e)},[Z,M]),(0,D.useEffect)(()=>{M&&R.current&&R.current.focus()},[M]);let Ke=async t=>{let r=e.find(e=>Y(e)===t)??e.find(e=>!e.isPlugin&&!e.isPersona&&e.name===t),i=r?Y(r):t,a=r?.name??t;Z();try{let e=await E.listRunningModels();if(e.success&&e.data){let t=e.data;t.length>0&&(r?.isPlugin!==!0&&t.some(e=>e.name===a||a.startsWith(`persona:`))||await E.unloadAllModels())}}catch(e){pe.warn(`Failed to unload models before switch:`,e)}n({target:{value:i}})},qe=async e=>{if(!z){_.error(j(`modelSelector.pullRestricted`));return}if(!G){K(e),q({status:`starting`});try{let t=E.pullModelStream(e,e=>{q(e)},()=>{q(null),K(null),J(null),_.success(`Downloaded ${e}`),b?.()},e=>{q(null),K(null),J(null),_.error(`Failed to download: ${e}`)});J(()=>t)}catch{q(null),K(null),_.error(`Failed to start download`)}}},Je=()=>{Me&&(Me(),J(null),K(null),q(null),_.success(`Download cancelled`))},Ye=t=>e.some(e=>s(e)&&(e.name===t||e.name.startsWith(t+`:`))),Q=e=>{let t=Fe[c(e)]?.avatar;return t&&!e.isPersona?(0,O.jsx)(`img`,{src:t,alt:``,className:`h-4 w-4 shrink-0 rounded-full object-cover`}):e.isLegacySelection?(0,O.jsx)(u,{className:`h-4 w-4 text-gray-500 dark:text-dark-600`}):e.isPersona?(0,O.jsx)(te,{className:`h-4 w-4 text-gray-500 dark:text-dark-600`}):e.isPlugin?(0,O.jsx)(T,{className:`h-4 w-4 text-gray-500 dark:text-dark-600`}):(0,O.jsx)(f,{className:`h-4 w-4 text-gray-500 dark:text-dark-600`})},$=e=>{if(C)return C(e);let t=Fe[c(e)]?.label;return t&&!e.isPersona?t:e.isLegacySelection?`${e.name} (${j(`modelSelector.legacyProvider`,`provider not recorded`)})`:e.isPersona?e.personaName||e.name:e.isAgent?e.isUnavailable?`${e.agentName||e.name} (${j(`modelSelector.unavailable`,`unavailable`)})`:e.agentName||e.name:(e.isPlugin,e.isUnavailable?`${e.name} (${j(`modelSelector.unavailable`,`unavailable`)})`:e.name)},Xe=e=>e.isLegacySelection?e.isUnavailable?j(`modelSelector.providerUnavailable`,`provider unavailable`):j(`modelSelector.reselectProvider`,`reselect a provider to pin this model`):e.isPersona?`via ${e.model}`:e.isPlugin?e.isUnavailable?`via ${e.pluginName||e.pluginId} · ${j(`modelSelector.providerUnavailable`,`provider unavailable`)}`:`via ${e.pluginName}`:e.isUnavailable?j(`modelSelector.providerUnavailable`,`provider unavailable`):null;return(0,O.jsxs)(`div`,{className:o(`relative`,h),ref:ge,children:[(0,O.jsxs)(`button`,{ref:L,"data-testid":ae,type:`button`,onClick:()=>!g&&me(!M),disabled:g,"aria-haspopup":`dialog`,"aria-expanded":M,"aria-label":A&&X?`${A}: ${$(X)}`:A,className:o(v?`h-9 sm:h-10 px-2.5 flex items-center justify-between text-start w-full`:`w-full flex items-center justify-between gap-2 px-3 py-2.5 text-start`,`border border-black/[0.06] bg-gray-100/70 dark:border-white/[0.06] dark:bg-dark-300/70`,`rounded-xl text-sm hover:bg-gray-100 dark:hover:bg-dark-300`,`transition-colors duration-150 focus:outline-none focus:ring-2 focus:ring-primary-500/20 focus:border-primary-500/40`,g?`opacity-50 cursor-not-allowed`:`cursor-pointer`),title:v?X?re?.(X)??$(X):j(`modelSelector.selectModel`):void 0,children:[(()=>{if(!X)return v?(0,O.jsxs)(`div`,{className:`flex items-center gap-2 min-w-0`,children:[(0,O.jsx)(f,{className:`h-4 w-4`}),(0,O.jsx)(`span`,{className:`text-xs font-medium text-gray-400 dark:text-gray-500 truncate`,children:j(`modelSelector.selectModel`)})]}):j(`modelSelector.selectModel`);if(v){let e=$(X);return(0,O.jsxs)(`div`,{className:`flex items-center gap-2 min-w-0`,children:[Q(X),(0,O.jsx)(`span`,{dir:X.isPersona?`auto`:`ltr`,className:`text-xs font-medium text-gray-700 dark:text-gray-200 truncate`,children:e})]})}let e=$(X),t=Xe(X);return(0,O.jsxs)(`div`,{className:`flex items-center gap-2 min-w-0`,children:[Q(X),(0,O.jsxs)(`div`,{className:`flex flex-col min-w-0`,children:[(0,O.jsx)(`span`,{dir:X.isPersona?`auto`:`ltr`,className:`text-sm font-medium truncate`,children:e}),t&&(0,O.jsx)(`span`,{dir:`auto`,className:`text-xs text-gray-500 dark:text-gray-400 truncate`,children:t})]}),X.isPersona&&r&&(0,O.jsxs)(`div`,{className:`flex items-center gap-1 ms-auto`,children:[(0,O.jsx)(u,{className:`h-3 w-3 text-gray-500 dark:text-dark-600`}),r.embedding_model&&(0,O.jsx)(d,{className:`h-3 w-3 text-gray-400 dark:text-dark-500`})]})]})})(),(0,O.jsx)(ne,{className:o(v?`h-3 w-3`:`h-4 w-4`,`text-gray-400 flex-shrink-0 transition-transform duration-150`,M&&`rotate-180`)})]}),M&&(0,le.createPortal)((0,O.jsxs)(`div`,{className:`fixed inset-0 z-[999999] flex items-center justify-center p-3 sm:p-6`,children:[(0,O.jsx)(`div`,{className:`absolute inset-0 bg-gray-950/55 backdrop-blur-md`,onClick:()=>Z()}),(0,O.jsxs)(`div`,{ref:I,role:`dialog`,"aria-modal":`true`,"aria-label":j(`modelSelector.selectModel`),className:o(`relative flex w-full max-w-xl flex-col overflow-hidden bg-white/[0.98] dark:bg-dark-25/[0.98]`,`h-[min(620px,88vh)] rounded-[1.5rem] border border-black/[0.08] dark:border-white/[0.09]`,`shadow-[0_30px_100px_rgba(0,0,0,0.28)] backdrop-blur-xl animate-scale-in`),onClick:e=>e.stopPropagation(),children:[(0,O.jsxs)(`div`,{className:`flex-shrink-0`,children:[(0,O.jsxs)(`div`,{className:`flex items-center justify-between px-4 pb-2 pt-4 sm:px-5 sm:pt-5`,children:[(0,O.jsx)(`h2`,{className:`text-lg font-medium tracking-[-0.025em] text-gray-950 dark:text-dark-950 rtl:tracking-normal`,children:j(`modelSelector.selectModel`)}),(0,O.jsx)(`button`,{type:`button`,onClick:()=>Z(),className:`flex h-9 w-9 items-center justify-center rounded-full text-gray-400 transition-colors hover:bg-gray-100 hover:text-gray-950 dark:text-dark-500 dark:hover:bg-dark-200 dark:hover:text-dark-950`,title:j(`common.close`),children:(0,O.jsx)(S,{className:`h-4 w-4`})})]}),(0,O.jsx)(`div`,{className:`px-4 pb-3 sm:px-5`,children:(0,O.jsxs)(`div`,{className:`relative`,children:[(0,O.jsx)(m,{className:`absolute start-3 top-1/2 -translate-y-1/2 h-4 w-4 text-gray-400`}),(0,O.jsx)(`input`,{ref:R,type:`text`,placeholder:j(P===`installed`?`modelSelector.searchInstalled`:P===`ollama`?`modelSelector.searchOllama`:`modelSelector.searchHuggingFace`),value:N,onChange:e=>he(e.target.value),className:o(`w-full rounded-xl border border-black/[0.07] bg-gray-100/70 py-2.5 ps-10 pe-4 text-sm dark:border-white/[0.07] dark:bg-dark-200/70`,`focus:outline-none focus:ring-2 focus:ring-primary-500/20`,`text-gray-900 dark:text-dark-900 placeholder:text-gray-400 dark:placeholder:text-dark-500`)})]})}),(0,O.jsxs)(`div`,{className:`mx-4 mb-3 flex rounded-xl bg-gray-100/70 p-1 dark:bg-dark-200/70 sm:mx-5`,children:[(0,O.jsxs)(`button`,{onClick:()=>{F(`installed`)},className:o(`flex-1 rounded-lg px-2 py-2 text-xs font-medium transition-colors sm:px-4`,P===`installed`?`bg-white text-gray-950 shadow-sm dark:bg-dark-300 dark:text-dark-950`:`text-gray-500 hover:text-gray-800 dark:text-dark-500 dark:hover:text-dark-800`),"aria-pressed":P===`installed`,children:[(0,O.jsx)(p,{className:`h-4 w-4 inline me-1.5`}),j(`modelSelector.installed`)]}),(0,O.jsxs)(`button`,{onClick:()=>{F(`ollama`)},className:o(`flex-1 rounded-lg px-2 py-2 text-xs font-medium transition-colors sm:px-4`,P===`ollama`?`bg-white text-gray-950 shadow-sm dark:bg-dark-300 dark:text-dark-950`:`text-gray-500 hover:text-gray-800 dark:text-dark-500 dark:hover:text-dark-800`),"aria-pressed":P===`ollama`,children:[(0,O.jsx)(w,{className:`h-4 w-4 inline me-1.5`}),`Ollama`]}),(0,O.jsxs)(`button`,{onClick:()=>{F(`huggingface`)},className:o(`flex-1 rounded-lg px-2 py-2 text-xs font-medium transition-colors sm:px-4`,P===`huggingface`?`bg-white text-gray-950 shadow-sm dark:bg-dark-300 dark:text-dark-950`:`text-gray-500 hover:text-gray-800 dark:text-dark-500 dark:hover:text-dark-800`),"aria-pressed":P===`huggingface`,children:[(0,O.jsx)(T,{className:`h-4 w-4 inline me-1.5`}),`HuggingFace`]})]})]}),P===`installed`&&(0,O.jsx)(de,{filteredGroups:Pe,selectedModel:t,showImageGen:y,getModelValue:Y,getModelIcon:Q,getModelLabel:$,getModelSubLabel:Xe,onModelSelect:Ke,onOpenGallery:()=>{Z(!1),_e(`/gallery`)}}),P===`ollama`&&(0,O.jsx)(fe,{libraryCategories:Ne,libraryCategory:B,canInstallModels:z,loadingLibrary:Le,filteredLibraryModels:He,pullingModel:G,pullProgress:je,setLibraryCategory:be,isModelInstalled:Ye,onModelSelect:Ke,onPullModel:qe,onCancelPull:Je,onRefreshLibrary:()=>{Re()}}),P===`huggingface`&&(0,O.jsx)(ue,{hfTask:V,hfSort:H,canInstallModels:z,loadingHf:Be,hfModels:ze,expandedHfModel:U,hfGgufFiles:W,loadingGguf:ke,pullingModel:G,pullProgress:je,setHfTask:Ce,setHfSort:we,onToggleHfModel:We,onPullHfGguf:Ge,onCancelPull:Je,onRefreshHfModels:()=>{Ve()}})]})]}),document.body),(0,O.jsx)(`select`,{"data-testid":k,"aria-label":A,"aria-hidden":`true`,dir:`ltr`,value:t,onChange:n,className:`hidden`,tabIndex:-1,children:e.map(e=>(0,O.jsx)(`option`,{value:Y(e),children:$(e)},`${e.isLegacySelection?`legacy`:e.isPersona?`persona`:e.isPlugin?`plugin`:`ollama`}:${e.pluginId||``}:${Y(e)}`))})]})};export{A as t};
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["js/ModelManagerModals-DcLGYN3l.js","js/rolldown-runtime-hePW80VL.js","js/markdown-core-BmPPZiuD.js","js/react-vendor-C5yShNlM.js","js/useTranslation-Bho4HCyg.js","js/utils-D9W1Lnkn.js","js/utils-vendor-DWh39_3x.js","js/ui-vendor-B1UgO3vd.js","js/Button-BPf_pOxH.js"])))=>i.map(i=>d[i]);
|
|
2
|
-
import{r as e}from"./rolldown-runtime-hePW80VL.js";import{m as t,p as n}from"./markdown-core-BmPPZiuD.js";import{i as r}from"./router-vendor-DGFGM3EP.js";import{t as i}from"./useTranslation-Bho4HCyg.js";import{t as a}from"./utils-D9W1Lnkn.js";import{$t as o,Et as s,F as c,Fn as l,Ft as u,Gt as d,Jt as f,M as p,N as m,Pt as h,Qt as g,Rn as _,Tt as v,V as y,Xt as b,_n as x,bt as S,g as C,gn as w,gt as ee,in as T,lt as te,n as ne,pn as E,pt as D,rn as O,t as re,wt as k,y as ie}from"./ui-vendor-B1UgO3vd.js";import{t as ae}from"./logger-DSXjF4ye.js";import{h as A,y as oe}from"./api-BDtqBtqw.js";import{n as se}from"./authStore-DbMdvNgJ.js";import{t as j}from"./Button-BPf_pOxH.js";import{n as ce,t as le}from"./ui-CC-K19wO.js";import{C as ue,x as M}from"../assets/index-6o-Hc2wS.js";var N=e(t(),1),P=n();function de({expanded:e,models:t,search:n,task:r,sort:o,loadingModels:s,canInstallModels:l,expandedModelId:u,loadingGgufModelId:d,ggufFiles:p,pullingModel:m,pullProgress:h,setSearch:g,setTask:_,setSort:v,onToggle:b,onToggleModel:x,onPullGguf:S,onCancelPull:C,onRefresh:ee}){let{t:T}=i();return(0,P.jsxs)(`div`,{className:a(`overflow-hidden rounded-2xl border`,`bg-white/60 dark:bg-white/[0.03]`,`border-gray-200/80 dark:border-white/10`),children:[(0,P.jsxs)(`button`,{onClick:b,"aria-expanded":e,className:a(`w-full flex items-center justify-between p-4`,`hover:bg-gray-50 dark:hover:bg-dark-50`,`transition-colors`),children:[(0,P.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,P.jsx)(re,{className:`h-4 w-4 text-gray-500 dark:text-dark-500`}),(0,P.jsx)(`h3`,{className:`text-lg font-semibold text-gray-900 dark:text-dark-800`,children:T(`modelManager.sections.huggingface`,`HuggingFace Hub`)}),t.length>0&&(0,P.jsxs)(`span`,{className:a(`px-2 py-0.5 rounded-full text-xs font-medium`,`bg-gray-100 dark:bg-dark-200`,`text-gray-600 dark:text-gray-400`),children:[t.length,` `,T(`modelManager.library.available`,`available`)]})]}),e?(0,P.jsx)(E,{className:`h-5 w-5 text-gray-500`}):(0,P.jsx)(w,{className:`h-5 w-5 text-gray-500`})]}),e&&(0,P.jsxs)(`div`,{className:`p-4 pt-0 space-y-4`,children:[(0,P.jsxs)(`div`,{className:`flex flex-col sm:flex-row gap-3`,children:[(0,P.jsxs)(`div`,{className:`relative flex-1`,children:[(0,P.jsx)(c,{className:`absolute start-3 top-1/2 h-4 w-4 -translate-y-1/2 text-gray-400 dark:text-gray-500`}),(0,P.jsx)(`input`,{type:`text`,value:n,onChange:e=>g(e.target.value),placeholder:T(`modelManager.huggingface.search`,`Search HuggingFace models...`),className:a(`w-full rounded-xl border py-2 pe-4 ps-10 text-sm`,`bg-gray-50 dark:bg-dark-50`,`border-gray-200 dark:border-dark-300`,`text-gray-900 dark:text-dark-700`,`placeholder-gray-500 dark:placeholder-gray-400`,`focus:outline-none focus:ring-2 focus:ring-primary-500/20`,`focus:border-primary-500`)})]}),(0,P.jsxs)(`select`,{value:r,onChange:e=>_(e.target.value),className:a(`px-3 py-2 rounded-lg border text-sm min-w-[160px]`,`bg-gray-50 dark:bg-dark-50`,`border-gray-200 dark:border-dark-300`,`text-gray-900 dark:text-dark-700`,`focus:outline-none focus:ring-2 focus:ring-primary-500/20`),children:[(0,P.jsx)(`option`,{value:`text-generation`,children:T(`modelManager.huggingface.tasks.textGen`,`Text Generation`)}),(0,P.jsx)(`option`,{value:`text-to-speech`,children:T(`modelManager.huggingface.tasks.tts`,`Text to Speech`)}),(0,P.jsx)(`option`,{value:`text-to-image`,children:T(`modelManager.huggingface.tasks.image`,`Text to Image`)}),(0,P.jsx)(`option`,{value:`automatic-speech-recognition`,children:T(`modelManager.huggingface.tasks.stt`,`Speech Recognition`)})]}),(0,P.jsxs)(`select`,{value:o,onChange:e=>v(e.target.value),className:a(`px-3 py-2 rounded-lg border text-sm min-w-[140px]`,`bg-gray-50 dark:bg-dark-50`,`border-gray-200 dark:border-dark-300`,`text-gray-900 dark:text-dark-700`,`focus:outline-none focus:ring-2 focus:ring-primary-500/20`),children:[(0,P.jsx)(`option`,{value:`downloads`,children:T(`modelManager.huggingface.sort.downloads`,`Most Downloads`)}),(0,P.jsx)(`option`,{value:`likes`,children:T(`modelManager.huggingface.sort.likes`,`Most Liked`)}),(0,P.jsx)(`option`,{value:`lastModified`,children:T(`modelManager.huggingface.sort.recent`,`Recently Updated`)})]})]}),!l&&(0,P.jsx)(`p`,{className:`text-xs text-ink`,children:T(`modelManager.pull.restricted`)}),s?(0,P.jsx)(`div`,{className:`flex items-center justify-center py-8`,children:(0,P.jsx)(D,{className:`h-5 w-5 animate-spin text-gray-400`})}):t.length===0?(0,P.jsx)(`div`,{className:`text-center py-8 text-gray-500`,children:T(`modelManager.huggingface.noResults`,`No models found. Try adjusting your search or filters.`)}):(0,P.jsx)(`div`,{className:`grid grid-cols-1 sm:grid-cols-2 gap-3`,children:t.map(e=>(0,P.jsx)(fe,{model:e,expanded:u===e.id,loadingGguf:d===e.id,ggufFiles:p[e.id]||[],pullingModel:m,pullProgress:h,canInstallModels:l,onToggle:()=>x(e.id),onPullGguf:S,onCancelPull:C},e.id))}),(0,P.jsxs)(`div`,{className:`flex items-center justify-between pt-2`,children:[(0,P.jsxs)(`a`,{href:`https://huggingface.co/models`,target:`_blank`,rel:`noopener noreferrer`,className:a(`inline-flex items-center gap-1.5 text-xs`,`text-primary-600 dark:text-primary-400`,`hover:underline`),children:[(0,P.jsx)(f,{className:`h-3 w-3`}),T(`modelManager.huggingface.browseAll`,`Browse all on HuggingFace`)]}),(0,P.jsxs)(j,{onClick:ee,variant:`outline`,size:`sm`,disabled:s,className:a(`gap-1.5`,``,``),children:[(0,P.jsx)(y,{className:a(`h-3.5 w-3.5`,s&&`animate-spin`)}),T(`modelManager.library.refresh`,`Refresh`)]})]})]})]})}function fe({model:e,expanded:t,loadingGguf:n,ggufFiles:r,pullingModel:o,pullProgress:s,canInstallModels:c,onToggle:l,onPullGguf:u,onCancelPull:d}){let{t:p}=i();return(0,P.jsxs)(`div`,{className:a(`rounded-lg border transition-all overflow-hidden`,`bg-gray-50 dark:bg-dark-50`,`border-gray-200 dark:border-dark-300`,`hover:shadow-md hover:border-gray-300 dark:hover:border-dark-400`),children:[(0,P.jsxs)(`div`,{className:`p-4 cursor-pointer`,onClick:l,children:[(0,P.jsxs)(`div`,{className:`flex items-start justify-between gap-2 mb-2`,children:[(0,P.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,P.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,P.jsx)(`h4`,{className:`font-medium text-gray-900 dark:text-dark-800 truncate`,children:e.id}),e.gated&&(0,P.jsx)(`span`,{className:a(`px-1.5 py-0.5 rounded text-xs`,`bg-yellow-500/20 dark:bg-yellow-900/30`,`text-ink`),children:p(`modelManager.huggingface.gated`,`Gated`)})]}),(0,P.jsxs)(`p`,{className:`text-xs text-gray-500 dark:text-dark-600 mt-0.5`,children:[p(`modelManager.huggingface.by`,`by`),` `,e.author]})]}),(0,P.jsxs)(`div`,{className:`flex items-center gap-2 flex-shrink-0`,children:[(0,P.jsx)(`a`,{href:`https://huggingface.co/${e.id}`,target:`_blank`,rel:`noopener noreferrer`,onClick:e=>e.stopPropagation(),className:`p-1.5 rounded-lg hover:bg-gray-200 dark:hover:bg-dark-300 transition-colors`,title:p(`modelManager.huggingface.viewOnHF`,`View on HuggingFace`),children:(0,P.jsx)(f,{className:`h-4 w-4 text-gray-400 dark:text-gray-500`})}),(0,P.jsx)(w,{className:a(`h-4 w-4 text-gray-400 transition-transform`,t&&`rotate-180`)})]})]}),(0,P.jsxs)(`div`,{className:`flex items-center gap-3 text-xs text-gray-500 dark:text-dark-600`,children:[(0,P.jsxs)(`span`,{className:`flex items-center gap-1`,children:[(0,P.jsx)(b,{className:`h-3.5 w-3.5`}),he(e.downloads)]}),(0,P.jsxs)(`span`,{className:`flex items-center gap-1`,children:[(0,P.jsx)(k,{className:`h-3.5 w-3.5`}),he(e.likes)]}),e.pipeline_tag&&(0,P.jsx)(`span`,{className:a(`px-1.5 py-0.5 rounded`,`bg-gray-200 dark:bg-dark-300`),children:e.pipeline_tag})]})]}),t&&(0,P.jsx)(pe,{modelId:e.id,loading:n,files:r,pullingModel:o,pullProgress:s,canInstallModels:c,onPullGguf:u,onCancelPull:d})]})}function pe({modelId:e,loading:t,files:n,pullingModel:r,pullProgress:a,canInstallModels:o,onPullGguf:s,onCancelPull:c}){let{t:l}=i();return(0,P.jsx)(`div`,{className:`px-4 pb-4 pt-1 border-t border-gray-200 dark:border-dark-300 bg-white dark:bg-dark-100`,children:t?(0,P.jsxs)(`div`,{className:`flex items-center justify-center py-4`,children:[(0,P.jsx)(D,{className:`h-4 w-4 animate-spin text-gray-400`}),(0,P.jsx)(`span`,{className:`ml-2 text-xs text-gray-500`,children:l(`modelManager.huggingface.checkingGguf`)})]}):n.length===0?(0,P.jsx)(`div`,{className:`py-4 text-center text-xs text-gray-500 dark:text-gray-400`,children:l(`modelManager.huggingface.noGgufAvailable`)}):(0,P.jsxs)(`div`,{className:`space-y-2`,children:[(0,P.jsx)(`div`,{className:`text-xs font-medium text-gray-600 dark:text-gray-300 mb-2`,children:l(`modelManager.huggingface.ggufFilesCount`,{count:n.length})}),n.map(e=>(0,P.jsx)(me,{file:e,pulling:r===e.ollamaCommand,pullProgress:a,canInstallModels:o,disabled:!!r||!o,onPullGguf:s,onCancelPull:c},e.filename)),r?.startsWith(`hf.co/`)&&r.includes(e)&&a?.percent!==void 0&&(0,P.jsx)(`div`,{className:`w-full bg-gray-200 dark:bg-dark-300 rounded-full h-1.5 overflow-hidden mt-2`,children:(0,P.jsx)(`div`,{className:`h-1.5 rounded-full bg-primary-500 transition-all duration-300`,style:{width:`${a.percent}%`}})})]})})}function me({file:e,pulling:t,disabled:n,pullProgress:r,onPullGguf:o,onCancelPull:s}){let{t:c}=i();return(0,P.jsxs)(`div`,{className:`flex items-center gap-2 p-2 rounded-lg bg-gray-50 dark:bg-dark-50 border border-gray-200 dark:border-dark-300`,children:[(0,P.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,P.jsx)(`div`,{className:`text-xs font-medium text-gray-800 dark:text-gray-200 truncate`,children:e.filename}),(0,P.jsxs)(`div`,{className:`flex items-center gap-2 mt-0.5 text-xs text-gray-500 dark:text-gray-400`,children:[(0,P.jsx)(`span`,{children:e.sizeFormatted}),e.quantization&&(0,P.jsx)(`span`,{className:`px-1.5 py-0.5 rounded bg-purple-100 dark:bg-purple-900/30 text-purple-700 dark:text-purple-400`,children:e.quantization})]})]}),t?(0,P.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,P.jsx)(`div`,{className:`text-xs text-gray-500 w-12 text-right`,children:r?.percent===void 0?`...`:`${r.percent}%`}),(0,P.jsx)(`button`,{onClick:e=>{e.stopPropagation(),s()},className:`p-1.5 rounded-lg text-red-500 hover:bg-red-50 dark:hover:bg-red-900/20`,children:(0,P.jsx)(ne,{className:`h-4 w-4`})})]}):(0,P.jsxs)(`button`,{onClick:t=>{t.stopPropagation(),o(e.ollamaCommand,e.filename)},disabled:n,className:a(`px-3 py-1.5 rounded-lg text-xs font-medium`,`bg-primary-100 dark:bg-primary-900/30`,`text-primary-700 dark:text-primary-400`,`hover:bg-primary-200 dark:hover:bg-primary-900/50`,`disabled:opacity-50 disabled:cursor-not-allowed`),children:[(0,P.jsx)(b,{className:`h-3 w-3 inline mr-1`}),c(`models.pull`)]})]})}function he(e){return e>=1e6?`${(e/1e6).toFixed(1)}M`:e>=1e3?`${(e/1e3).toFixed(1)}K`:e}function ge({expanded:e,models:t,onToggle:n,isModelRunning:r,formatSize:o,onShowModel:c,onCopyModel:l,onDeleteModel:u}){let{t:d}=i();return(0,P.jsxs)(`div`,{className:a(`overflow-hidden rounded-2xl border`,`bg-white/60 dark:bg-white/[0.03]`,`border-gray-200/80 dark:border-white/10`),children:[(0,P.jsxs)(`button`,{onClick:n,"aria-expanded":e,className:a(`w-full flex items-center justify-between p-4`,`hover:bg-gray-50 dark:hover:bg-dark-50`,`transition-colors`),children:[(0,P.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,P.jsx)(s,{className:`h-4 w-4 text-gray-500 dark:text-dark-500`}),(0,P.jsx)(`h3`,{className:`text-lg font-semibold text-gray-900 dark:text-dark-800`,children:d(`modelManager.sections.local`)}),(0,P.jsxs)(`span`,{className:a(`px-2 py-0.5 rounded-full text-xs font-medium`,`bg-gray-100 dark:bg-dark-200`,`text-gray-600 dark:text-gray-400`),children:[t.length,` `,d(`modelManager.local.installed`)]})]}),e?(0,P.jsx)(E,{className:`h-5 w-5 text-gray-500`}):(0,P.jsx)(w,{className:`h-5 w-5 text-gray-500`})]}),e&&(0,P.jsx)(`div`,{className:`p-4 pt-0`,children:t.length===0?(0,P.jsxs)(`div`,{className:a(`text-center py-12 rounded-lg border-2 border-dashed`,`border-gray-200 dark:border-dark-300`),children:[(0,P.jsx)(s,{className:`h-12 w-12 mx-auto mb-3 text-gray-300 dark:text-gray-600`}),(0,P.jsx)(`p`,{className:`text-gray-600 dark:text-dark-600 mb-2`,children:d(`modelManager.local.noModels`)}),(0,P.jsx)(`p`,{className:`text-sm text-gray-500 dark:text-gray-500`,children:d(`modelManager.local.pullToStart`)})]}):(0,P.jsx)(`div`,{className:`space-y-3`,children:t.map(e=>(0,P.jsx)(_e,{model:e,running:r(e.name),formatSize:o,onShowModel:c,onCopyModel:l,onDeleteModel:u},e.name))})})]})}function _e({model:e,running:t,formatSize:n,onShowModel:r,onCopyModel:c,onDeleteModel:l}){let{t:u}=i();return(0,P.jsx)(`div`,{className:a(`p-4 rounded-lg border transition-colors`,`bg-gray-50 dark:bg-dark-50`,`border-gray-200 dark:border-dark-300`,`hover:bg-gray-100 dark:hover:bg-dark-200`),children:(0,P.jsxs)(`div`,{className:`flex items-start justify-between gap-4`,children:[(0,P.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,P.jsxs)(`div`,{className:`flex items-center gap-2 flex-wrap`,children:[(0,P.jsx)(`h4`,{className:`font-medium text-gray-900 dark:text-dark-800`,children:e.name}),t&&(0,P.jsxs)(`span`,{className:a(`inline-flex items-center gap-1 px-2 py-0.5 rounded-full text-xs font-medium`,`bg-green-100 dark:bg-green-900/30`,`text-green-700 dark:text-green-400`),children:[(0,P.jsx)(`span`,{className:`w-1.5 h-1.5 rounded-full bg-green-500 animate-pulse`}),u(`modelManager.local.running`)]})]}),(0,P.jsxs)(`div`,{className:`flex flex-wrap gap-x-4 gap-y-1 text-sm text-gray-600 dark:text-dark-600 mt-2`,children:[(0,P.jsxs)(`span`,{className:`flex items-center gap-1`,children:[(0,P.jsx)(s,{className:`h-3.5 w-3.5`}),n(e.size)]}),e.details?.parameter_size&&(0,P.jsxs)(`span`,{className:`flex items-center gap-1`,children:[(0,P.jsx)(g,{className:`h-3.5 w-3.5`}),e.details.parameter_size]}),e.details?.quantization_level&&(0,P.jsx)(`span`,{className:a(`px-1.5 py-0.5 rounded text-xs`,`bg-gray-200 dark:bg-dark-300`,`text-gray-600 dark:text-gray-400`),children:e.details.quantization_level}),e.details?.family&&(0,P.jsx)(`span`,{className:`text-gray-500 dark:text-gray-500`,children:e.details.family})]}),(0,P.jsxs)(`div`,{className:`flex items-center gap-3 text-xs text-gray-400 dark:text-dark-500 mt-2`,children:[(0,P.jsxs)(`span`,{className:`flex items-center gap-1`,children:[(0,P.jsx)(T,{className:`h-3 w-3`}),new Date(e.modified_at).toLocaleDateString()]}),(0,P.jsxs)(`span`,{className:`flex items-center gap-1 font-mono truncate max-w-[200px]`,title:e.digest,children:[(0,P.jsx)(v,{className:`h-3 w-3`}),e.digest.slice(0,12),`...`]})]})]}),(0,P.jsxs)(`div`,{className:`flex gap-2 flex-shrink-0`,children:[(0,P.jsxs)(j,{onClick:()=>r(e.name),variant:`outline`,size:`sm`,className:a(`gap-1.5`,``,``),children:[(0,P.jsx)(S,{className:`h-3.5 w-3.5`}),u(`modelManager.local.info`)]}),(0,P.jsxs)(j,{onClick:()=>c(e.name),variant:`outline`,size:`sm`,className:a(`gap-1.5`,``,``),children:[(0,P.jsx)(o,{className:`h-3.5 w-3.5`}),u(`modelManager.local.copy`)]}),(0,P.jsxs)(j,{onClick:()=>l(e.name),variant:`outline`,size:`sm`,className:a(`gap-1.5`,`text-red-600 hover:text-red-700 dark:text-red-400 dark:hover:text-red-300`,``,``),children:[(0,P.jsx)(C,{className:`h-3.5 w-3.5`}),u(`modelManager.local.delete`)]})]})]})})}function ve({expanded:e,models:t,totalAvailable:n,categories:r,filter:o,search:s,loading:l,pulling:d,canInstallModels:f,pullSectionExpanded:p,setFilter:m,setSearch:h,isModelInstalled:g,normalizeCloudPullName:_,onToggle:v,onTogglePullSection:b,onPullModel:x,onRefresh:S}){let{t:C}=i();return(0,P.jsxs)(`div`,{className:a(`overflow-hidden rounded-2xl border`,`bg-white/60 dark:bg-white/[0.03]`,`border-gray-200/80 dark:border-white/10`),children:[(0,P.jsxs)(`button`,{onClick:v,"aria-expanded":e,className:a(`w-full flex items-center justify-between p-4`,`hover:bg-gray-50 dark:hover:bg-dark-50`,`transition-colors`),children:[(0,P.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,P.jsx)(O,{className:`h-4 w-4 text-gray-500 dark:text-dark-500`}),(0,P.jsx)(`h3`,{className:`text-lg font-semibold text-gray-900 dark:text-dark-800`,children:C(`modelManager.sections.library`)}),(0,P.jsxs)(`span`,{className:a(`px-2 py-0.5 rounded-full text-xs font-medium`,`bg-gray-100 dark:bg-dark-200`,`text-gray-600 dark:text-gray-400`),children:[n,` `,C(`modelManager.library.available`)]})]}),e?(0,P.jsx)(E,{className:`h-5 w-5 text-gray-500`}):(0,P.jsx)(w,{className:`h-5 w-5 text-gray-500`})]}),e&&(0,P.jsxs)(`div`,{className:`p-4 pt-0 space-y-4`,children:[(0,P.jsxs)(`div`,{className:`flex flex-col sm:flex-row gap-3`,children:[(0,P.jsxs)(`div`,{className:`relative flex-1`,children:[(0,P.jsx)(c,{className:`absolute start-3 top-1/2 h-4 w-4 -translate-y-1/2 text-gray-400 dark:text-gray-500`}),(0,P.jsx)(`input`,{type:`text`,value:s,onChange:e=>h(e.target.value),placeholder:C(`modelManager.library.search`),className:a(`w-full rounded-xl border py-2 pe-4 ps-10 text-sm`,`bg-gray-50 dark:bg-dark-50`,`border-gray-200 dark:border-dark-300`,`text-gray-900 dark:text-dark-700`,`placeholder-gray-500 dark:placeholder-gray-400`,`focus:outline-none focus:ring-2 focus:ring-primary-500/20`,`focus:border-primary-500`)})]}),(0,P.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,P.jsx)(u,{className:`h-4 w-4 text-gray-400`}),(0,P.jsx)(`div`,{className:`flex flex-wrap gap-1`,children:r.map(e=>(0,P.jsx)(`button`,{onClick:()=>m(e),className:a(`px-2.5 py-1 rounded-full text-xs font-medium transition-colors`,o===e?`bg-primary-100 dark:bg-primary-900/30 text-primary-700 dark:text-primary-400`:`bg-gray-100 dark:bg-dark-200 text-gray-600 dark:text-gray-400 hover:bg-gray-200 dark:hover:bg-dark-300`),children:e.charAt(0).toUpperCase()+e.slice(1)},e))})]})]}),l?(0,P.jsx)(`div`,{className:`flex items-center justify-center py-8`,children:(0,P.jsx)(y,{className:`h-5 w-5 animate-spin text-gray-400`})}):t.length===0?(0,P.jsx)(`div`,{className:`text-center py-8 text-gray-500`,children:C(`modelManager.library.noResults`)}):(0,P.jsx)(`div`,{className:`grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 gap-3`,children:t.map(e=>{let t=e.category===`cloud`?_(e.name):e.name,n=g(e.name)||g(t);return(0,P.jsx)(ye,{model:e,installed:n,pulling:d,canInstallModels:f,pullSectionExpanded:p,onTogglePullSection:b,onPullModel:x},e.name)})}),(0,P.jsx)(`div`,{className:`flex justify-center`,children:(0,P.jsxs)(j,{onClick:S,variant:`outline`,size:`sm`,disabled:l,className:a(`gap-1.5`,``,``),children:[(0,P.jsx)(y,{className:a(`h-3.5 w-3.5`,l&&`animate-spin`)}),C(`modelManager.library.refresh`)]})})]})]})}function ye({model:e,installed:t,pulling:n,canInstallModels:r,pullSectionExpanded:o,onTogglePullSection:s,onPullModel:c}){let{t:l}=i();return(0,P.jsxs)(`div`,{"data-testid":`library-model-card-${e.name}`,className:a(`p-4 rounded-lg border transition-all`,`bg-gray-50 dark:bg-dark-50`,t?`border-green-200 dark:border-green-800/50`:`border-gray-200 dark:border-dark-300`,`hover:shadow-md hover:border-gray-300 dark:hover:border-dark-400`),children:[(0,P.jsxs)(`div`,{className:`flex items-start justify-between gap-2 mb-2`,children:[(0,P.jsx)(`h4`,{className:`font-medium text-gray-900 dark:text-dark-800`,children:e.name}),t&&(0,P.jsxs)(`span`,{className:a(`flex items-center gap-1 px-1.5 py-0.5 rounded text-xs`,`bg-green-100 dark:bg-green-900/30`,`text-green-700 dark:text-green-400`),children:[(0,P.jsx)(x,{className:`h-3 w-3`}),l(`modelManager.library.installed`)]})]}),(0,P.jsx)(`p`,{className:`text-xs text-gray-600 dark:text-dark-600 mb-3 line-clamp-2`,children:e.description}),(0,P.jsxs)(`div`,{className:`flex flex-wrap gap-1.5 mb-3`,children:[e.sizes.slice(0,4).map(e=>(0,P.jsx)(`span`,{className:a(`px-1.5 py-0.5 rounded text-xs`,`bg-gray-200 dark:bg-dark-300`,`text-gray-600 dark:text-gray-400`),children:e},e)),e.sizes.length>4&&(0,P.jsx)(`span`,{className:`text-xs text-gray-400`,children:l(`modelManager.library.more`,{count:e.sizes.length-4})})]}),(0,P.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,P.jsxs)(`div`,{className:`flex items-center gap-2 text-xs text-gray-500`,children:[e.pulls&&(0,P.jsxs)(`span`,{className:`flex items-center gap-1`,children:[(0,P.jsx)(b,{className:`h-3 w-3`}),e.pulls]}),(0,P.jsx)(`span`,{className:a(`px-1.5 py-0.5 rounded capitalize`,e.category===`cloud`?`bg-blue-100 dark:bg-blue-900/30 text-blue-700 dark:text-blue-400`:`bg-gray-100 dark:bg-dark-200`),children:e.category})]}),(0,P.jsxs)(j,{"data-testid":`library-model-install-${e.name}`,onClick:()=>{o||s(),c(e.name,e.category)},variant:`outline`,size:`sm`,disabled:n||!r,className:a(`gap-1 text-xs`,``,``),children:[(0,P.jsx)(b,{className:`h-3 w-3`}),l(`modelManager.pull.button`)]})]})]})}function be({expanded:e,modelName:t,setModelName:n,pulling:r,progress:o,canInstallModels:s,popularModels:l,onToggle:u,onPull:d,onCancelPull:p,formatSize:m}){let{t:h}=i();return(0,P.jsxs)(`div`,{className:a(`overflow-hidden rounded-2xl border`,`bg-white/60 dark:bg-white/[0.03]`,`border-gray-200/80 dark:border-white/10`),children:[(0,P.jsxs)(`button`,{onClick:u,"aria-expanded":e,className:a(`w-full flex items-center justify-between p-4`,`hover:bg-gray-50 dark:hover:bg-dark-50`,`transition-colors`),children:[(0,P.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,P.jsx)(b,{className:`h-4 w-4 text-primary-600 dark:text-primary-400`}),(0,P.jsx)(`h3`,{className:`text-lg font-semibold text-gray-900 dark:text-dark-800`,children:h(`modelManager.sections.pull`)})]}),e?(0,P.jsx)(E,{className:`h-5 w-5 text-gray-500`}):(0,P.jsx)(w,{className:`h-5 w-5 text-gray-500`})]}),e&&(0,P.jsxs)(`div`,{className:`p-4 pt-0 space-y-4`,children:[(0,P.jsxs)(`div`,{className:`flex gap-2`,children:[(0,P.jsxs)(`div`,{className:`relative flex-1`,children:[(0,P.jsx)(c,{className:`absolute start-3 top-1/2 h-4 w-4 -translate-y-1/2 text-gray-400 dark:text-gray-500`}),(0,P.jsx)(`input`,{type:`text`,value:t,onChange:e=>n(e.target.value),placeholder:h(`modelManager.pull.placeholder`),className:a(`w-full rounded-xl border py-2.5 pe-4 ps-10 text-sm`,`bg-gray-50 dark:bg-dark-50`,`border-gray-200 dark:border-dark-300`,`text-gray-900 dark:text-dark-700`,`placeholder-gray-500 dark:placeholder-gray-400`,`focus:outline-none focus:ring-2 focus:ring-primary-500/20`,`focus:border-primary-500`),disabled:r||!s,onKeyDown:e=>{e.key===`Enter`&&!r&&s&&d()}})]}),r?(0,P.jsxs)(j,{onClick:p,variant:`outline`,className:a(`px-4 py-2.5 gap-2`,`text-red-600 hover:text-red-700 dark:text-red-400 dark:hover:text-red-300`,``,``),children:[(0,P.jsx)(ne,{className:`h-4 w-4`}),h(`modelManager.pull.cancel`)]}):(0,P.jsxs)(j,{onClick:d,disabled:!t.trim()||!s,className:a(`px-4 py-2.5 gap-2`,``),children:[(0,P.jsx)(b,{className:`h-4 w-4`}),h(`modelManager.pull.button`)]})]}),r&&o&&(0,P.jsx)(F,{progress:o,formatSize:m}),!s&&(0,P.jsx)(`p`,{className:`text-xs text-ink-muted`,children:h(`modelManager.pull.restricted`)}),(0,P.jsxs)(`div`,{children:[(0,P.jsx)(`p`,{className:`text-xs font-medium text-gray-500 dark:text-gray-400 mb-2`,children:h(`modelManager.pull.popular`)}),(0,P.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:l.map(e=>(0,P.jsxs)(`button`,{onClick:()=>n(e.name),disabled:r||!s,className:a(`px-3 py-1.5 rounded-full text-xs font-medium transition-colors`,`bg-gray-100 dark:bg-dark-200`,`text-gray-700 dark:text-gray-300`,`hover:bg-gray-200 dark:hover:bg-dark-300`,`border border-gray-200 dark:border-dark-300`,`disabled:opacity-50 disabled:cursor-not-allowed`),children:[e.name,(0,P.jsx)(`span`,{className:`ml-1 text-gray-400 dark:text-gray-500`,children:e.size})]},e.name))})]}),(0,P.jsxs)(`a`,{href:`https://ollama.com/library`,target:`_blank`,rel:`noopener noreferrer`,className:a(`inline-flex items-center gap-1.5 text-xs`,`text-primary-600 dark:text-primary-400`,`hover:underline`),children:[(0,P.jsx)(f,{className:`h-3 w-3`}),h(`modelManager.pull.browseAll`)]})]})]})}function F({progress:e,formatSize:t}){let{t:n}=i(),r=e.status===`starting`?n(`modelManager.progress.starting`):e.status.startsWith(`pulling`)?`${n(`modelManager.progress.pullingLayer`)} ${e.status.replace(`pulling `,``)}`:e.status.startsWith(`verifying sha256`)?n(`modelManager.progress.verifyingDigest`):e.status===`writing manifest`?n(`modelManager.progress.writing`):e.status===`removing any unused layers`?n(`modelManager.progress.cleaning`):e.status;return(0,P.jsxs)(`div`,{className:a(`p-4 rounded-lg border`,`bg-gray-50 dark:bg-dark-200`,`border-gray-200 dark:border-dark-300`),children:[(0,P.jsxs)(`div`,{className:`flex items-center justify-between mb-2`,children:[(0,P.jsx)(`span`,{className:`text-sm font-medium text-gray-800 dark:text-dark-700`,children:r}),e.percent!==void 0&&(0,P.jsxs)(`span`,{className:`text-sm font-mono text-gray-600 dark:text-dark-600`,children:[e.percent,`%`]})]}),e.percent!==void 0&&(0,P.jsx)(`div`,{className:`w-full bg-gray-200 dark:bg-dark-400 rounded-full h-2 overflow-hidden`,children:(0,P.jsx)(`div`,{className:a(`h-2 rounded-full transition-all duration-300`,`bg-primary-500 dark:bg-primary-400`),style:{width:`${e.percent}%`}})}),e.total&&e.completed&&(0,P.jsxs)(`div`,{className:`mt-2 text-xs text-gray-600 dark:text-dark-600`,children:[t(e.completed),` / `,t(e.total)]})]})}var xe=ae(`components:model-manager`),Se=N.lazy(()=>r(()=>import(`./ModelManagerModals-DcLGYN3l.js`),__vite__mapDeps([0,1,2,3,4,5,6,7,8]))),I=e=>{let t=e.split(`:`).pop()?.toLowerCase();return t===`cloud`||t?.endsWith(`-cloud`)===!0},Ce=e=>{let t=e.trim();if(!t||I(t))return t;let n=t.lastIndexOf(`:`);return n===-1?`${t}:cloud`:`${t.slice(0,n)}:${t.slice(n+1)}-cloud`},L=()=>{let{t:e}=i(),{user:t,systemInfo:n}=se(),{data:r}=M({queryKey:[`model-download-access`],queryFn:async()=>{let e=await A.getModelAccess();return e.success&&e.data?e.data:null},staleTime:6e4}),c=t?.role===`admin`||n?.requiresAuth===!1||r?.allowed===!0,u=ue(),[f,g]=(0,N.useState)(`all`),[v,b]=(0,N.useState)(``),[x,S]=(0,N.useState)(``),[C,T]=(0,N.useState)(!1),[ne,D]=(0,N.useState)(null),[O,k]=(0,N.useState)(null),[ae,ce]=(0,N.useState)(null),[le,fe]=(0,N.useState)(``),[pe,me]=(0,N.useState)(!1),[he,_e]=(0,N.useState)(!1),[ye,F]=(0,N.useState)(!1),[I,L]=(0,N.useState)(``),[R,we]=(0,N.useState)(``),[Te,Ee]=(0,N.useState)(!1),[De,Oe]=(0,N.useState)(!1),[z,ke]=(0,N.useState)(``),[Ae,je]=(0,N.useState)(``),[Me,Ne]=(0,N.useState)(!1),[Pe,Fe]=(0,N.useState)(!1),[Ie,Le]=(0,N.useState)(``),[Re,ze]=(0,N.useState)(``),[Be,Ve]=(0,N.useState)(null),[He,Ue]=(0,N.useState)(!1),[We,Ge]=(0,N.useState)(``),[Ke,qe]=(0,N.useState)(``),[B,Je]=(0,N.useState)(`text-generation`),[V,Ye]=(0,N.useState)(`downloads`),[Xe,Ze]=(0,N.useState)(null),[Qe,$e]=(0,N.useState)({}),[et,tt]=(0,N.useState)(null),[nt,H]=(0,N.useState)(null),[rt,U]=(0,N.useState)(null),[it,W]=(0,N.useState)(null),[G,at]=(0,N.useState)(new Set([`pull`,`local`])),K=e=>{at(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},{data:q,isLoading:ot,refetch:J}=M({queryKey:[`ollama-state`],queryFn:async()=>{let[e,t,n,r]=await Promise.all([A.getModels(),A.listRunningModels(),A.getVersion(),A.checkHealth()]);return{models:e.success&&e.data||[],runningModels:t.success&&Array.isArray(t.data)?t.data:[],ollamaVersion:n.success&&n.data?n.data.version:null,isHealthy:r.success}}}),Y=q?.models??[],X=q?.runningModels??[],st=q?.ollamaVersion??null,ct=q?.isHealthy??null,Z=(0,N.useCallback)(async()=>{await J()},[J]),{data:Q=[],isLoading:lt}=M({queryKey:[`ollama-library`],queryFn:async()=>{let e=await A.getLibraryModels();return e.success&&e.data?e.data:[]}}),{data:ut=[],isLoading:dt}=M({queryKey:[`ollama-library`,`cloud`],queryFn:async()=>{let e=await A.getLibraryModels({category:`cloud`});return e.success&&e.data?e.data:[]},enabled:f===`cloud`}),ft=()=>u.invalidateQueries({queryKey:[`ollama-library`]});(0,N.useEffect)(()=>{let e=setTimeout(()=>{qe(We)},300);return()=>clearTimeout(e)},[We]);let pt=G.has(`huggingface`),{data:mt=[],isLoading:ht}=M({queryKey:[`hf-models`,B,Ke,V],queryFn:async()=>{let e=await oe.getModels({task:B,search:Ke||void 0,sort:V,limit:30});return e.success&&e.data?e.data:[]},enabled:pt}),gt=()=>u.invalidateQueries({queryKey:[`hf-models`,B,Ke,V]}),_t=(0,N.useCallback)(async e=>{let[t,n]=e.split(`/`);if(!(!t||!n)){tt(e);try{let r=await oe.getGgufFiles(t,n);r.success&&r.data&&$e(t=>({...t,[e]:r.data}))}catch(e){xe.error(`Failed to load GGUF files:`,e)}finally{tt(null)}}},[]),vt=(0,N.useCallback)(e=>{Xe===e?Ze(null):(Ze(e),Qe[e]||_t(e))},[Xe,Qe,_t]),yt=(0,N.useCallback)((t,n)=>{if(!c){_.error(e(`modelManager.pull.restricted`));return}if(!nt){H(t),U({status:`starting`});try{let e=A.pullModelStream(t,e=>{U(e)},()=>{U(null),H(null),W(null),_.success(`Downloaded ${n}`),Z()},e=>{U(null),H(null),W(null),_.error(`Failed to download: ${e}`)});W(()=>e)}catch{U(null),H(null),_.error(`Failed to start download`)}}},[c,nt,Z,e]),bt=(0,N.useCallback)(()=>{it&&(it(),W(null),H(null),U(null))},[it]),xt=async(t,n)=>{if(!c){_.error(e(`modelManager.pull.restricted`));return}let r=t||x.trim(),i=n===`cloud`||!t&&f===`cloud`?Ce(r):r;if(!i){_.error(e(`modelManager.pull.enterName`));return}t&&S(i),T(!0),D({status:`starting`});try{let t=A.pullModelStream(i,e=>{D(e)},()=>{D(null),T(!1),k(null),_.success(e(`modelManager.pull.success`,{name:i})),S(``),Z()},t=>{D(null),T(!1),k(null),_.error(e(`modelManager.pull.failed`)+`: `+t)});k(()=>t)}catch(t){let n=t instanceof Error?t.message:String(t);_.error(e(`modelManager.pull.failed`)+`: `+n),D(null),T(!1),k(null)}},St=()=>{O&&(O(),k(null),T(!1),D(null),_.success(e(`modelManager.pull.cancelled`)))},Ct=async t=>{if(confirm(e(`modelManager.local.deleteConfirm`,{name:t})))try{await A.deleteModel(t),_.success(e(`modelManager.local.deleteSuccess`,{name:t})),await Z()}catch(t){let n=t instanceof Error?t.message:String(t);_.error(e(`modelManager.local.deleteFailed`)+`: `+n)}},wt=async t=>{_e(!0),fe(t),me(!0);try{let n=await A.showModel(t,!0);n.success&&n.data?ce(n.data):_.error(e(`modelManager.modals.details.noDetails`))}catch(t){let n=t instanceof Error?t.message:String(t);_.error(e(`modelManager.modals.details.noDetails`)+`: `+n)}finally{_e(!1)}},Tt=async()=>{if(!I.trim()||!R.trim()){_.error(e(`modelManager.modals.copy.enterBoth`));return}Ee(!0);try{await A.copyModel(I.trim(),R.trim()),_.success(e(`modelManager.modals.copy.success`,{name:R})),F(!1),L(``),we(``),await Z()}catch(t){let n=t instanceof Error?t.message:String(t);_.error(e(`modelManager.modals.copy.failed`)+`: `+n)}finally{Ee(!1)}},Et=async()=>{if(!z.trim()||!Ae.trim()){_.error(e(`modelManager.modals.create.enterBoth`));return}Ne(!0);try{await A.createModel({model:z.trim(),modelfile:Ae.trim()}),_.success(e(`modelManager.modals.create.success`,{name:z})),Oe(!1),ke(``),je(``),await Z()}catch(t){let n=t instanceof Error?t.message:String(t);_.error(e(`modelManager.modals.create.failed`)+`: `+n)}finally{Ne(!1)}},Dt=async()=>{if(!Ie.trim()||!Re.trim()){_.error(e(`modelManager.modals.embeddings.enterBoth`));return}Ue(!0),Ve(null);try{let t=await A.generateEmbeddings({model:Ie.trim(),input:Re.trim()});if(t.success&&t.data){let n=t.data.embeddings?.[0]||[];Ve(n),_.success(e(`modelManager.modals.embeddings.success`,{count:n.length}))}}catch(t){let n=t instanceof Error?t.message:String(t);_.error(e(`modelManager.modals.embeddings.failed`)+`: `+n)}finally{Ue(!1)}},$=e=>{let t=e/1073741824;return t>=1?`${t.toFixed(2)} GB`:`${(e/1048576).toFixed(1)} MB`},Ot=e=>Array.isArray(X)&&X.some(t=>t.name===e),kt=()=>Y.reduce((e,t)=>e+t.size,0),At=()=>X.reduce((e,t)=>e+(t.size_vram||0),0),jt=e=>Y.some(t=>t.name===e||t.name.startsWith(e+`:`)),Mt=(f===`cloud`?ut:Q).filter(e=>{let t=f===`all`||f===`cloud`||e.category===f,n=!v||e.name.toLowerCase().includes(v.toLowerCase())||e.description.toLowerCase().includes(v.toLowerCase());return t&&n}),Nt=[`all`,...new Set([...Q.map(e=>e.category),`cloud`])],Pt=(0,N.useMemo)(()=>Q.length>0?Q.slice(0,10).map(e=>({name:e.name,category:e.category,size:e.sizes?.[0]||``})):[{name:`deepseek-r1`,category:`reasoning`,size:`7B`},{name:`llama3.2`,category:`general`,size:`3B`},{name:`gemma3`,category:`general`,size:`4B`},{name:`qwen2.5`,category:`general`,size:`7B`},{name:`mistral`,category:`general`,size:`7B`},{name:`codellama`,category:`coding`,size:`7B`},{name:`nomic-embed-text`,category:`embedding`,size:`137M`},{name:`llava`,category:`vision`,size:`7B`},{name:`phi3`,category:`general`,size:`3.8B`},{name:`gemma2`,category:`general`,size:`9B`}],[Q]),Ft=pe||ye||De||Pe;return ot?(0,P.jsx)(`div`,{className:`flex items-center justify-center p-8`,children:(0,P.jsxs)(`div`,{className:`flex items-center gap-3 text-gray-600 dark:text-dark-600`,children:[(0,P.jsx)(y,{className:`h-5 w-5 animate-spin`}),e(`modelManager.loading`)]})}):(0,P.jsxs)(`div`,{className:`space-y-4`,children:[(0,P.jsx)(`div`,{className:a(`rounded-2xl border px-4 py-3`,`bg-white/60 dark:bg-white/[0.03]`,`border-gray-200/80 dark:border-white/10`),children:(0,P.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-4`,children:[(0,P.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-6 gap-y-2`,children:[(0,P.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,P.jsx)(`div`,{className:a(`w-2.5 h-2.5 rounded-full`,ct?`bg-green-500`:`bg-red-500`)}),(0,P.jsx)(`span`,{className:`text-sm font-medium text-gray-700 dark:text-gray-300`,children:e(ct?`modelManager.systemStatus.online`:`modelManager.systemStatus.offline`)})]}),st&&(0,P.jsxs)(`div`,{className:`flex items-center gap-2 text-sm text-gray-600 dark:text-gray-400`,children:[(0,P.jsx)(m,{className:`h-4 w-4`}),(0,P.jsxs)(`span`,{children:[`v`,st]})]}),(0,P.jsxs)(`div`,{className:`flex items-center gap-2 text-sm text-gray-600 dark:text-gray-400`,children:[(0,P.jsx)(s,{className:`h-4 w-4`}),(0,P.jsxs)(`span`,{children:[Y.length,` `,Y.length===1?e(`modelManager.systemStatus.models`):e(`modelManager.systemStatus.models_plural`)]})]}),(0,P.jsxs)(`div`,{className:`flex items-center gap-2 text-sm text-gray-600 dark:text-gray-400`,children:[(0,P.jsx)(ee,{className:`h-4 w-4`}),(0,P.jsx)(`span`,{children:$(kt())})]}),X.length>0&&(0,P.jsxs)(`div`,{className:`flex items-center gap-2 text-sm text-green-600 dark:text-green-400`,children:[(0,P.jsx)(l,{className:`h-4 w-4`}),(0,P.jsxs)(`span`,{children:[X.length,` `,e(`modelManager.systemStatus.running`),` (`,$(At()),` `,e(`modelManager.systemStatus.vram`),`)`]})]})]}),(0,P.jsx)(`div`,{className:`flex items-center gap-2`,children:(0,P.jsxs)(j,{onClick:Z,variant:`outline`,size:`sm`,className:a(`gap-1.5`,``,``),children:[(0,P.jsx)(y,{className:`h-3.5 w-3.5`}),e(`common.refresh`)]})})]})}),(0,P.jsx)(be,{expanded:G.has(`pull`),modelName:x,setModelName:S,pulling:C,progress:ne,canInstallModels:c,popularModels:Pt,onToggle:()=>K(`pull`),onPull:()=>xt(),onCancelPull:St,formatSize:$}),(0,P.jsx)(ve,{expanded:G.has(`library`),models:Mt,totalAvailable:Q.length,categories:Nt,filter:f,search:v,loading:lt||dt,pulling:C,canInstallModels:c,pullSectionExpanded:G.has(`pull`),setFilter:g,setSearch:b,isModelInstalled:jt,normalizeCloudPullName:Ce,onToggle:()=>K(`library`),onTogglePullSection:()=>K(`pull`),onPullModel:xt,onRefresh:ft}),(0,P.jsx)(de,{expanded:G.has(`huggingface`),models:mt,search:We,task:B,sort:V,loadingModels:ht,canInstallModels:c,expandedModelId:Xe,loadingGgufModelId:et,ggufFiles:Qe,pullingModel:nt,pullProgress:rt,setSearch:Ge,setTask:Je,setSort:Ye,onToggle:()=>K(`huggingface`),onToggleModel:vt,onPullGguf:yt,onCancelPull:bt,onRefresh:gt}),Array.isArray(X)&&X.length>0&&(0,P.jsxs)(`div`,{className:a(`rounded-2xl border p-4`,`bg-white/60 dark:bg-white/[0.03]`,`border-gray-200/80 dark:border-white/10`),children:[(0,P.jsxs)(`div`,{className:`flex items-center gap-3 mb-4`,children:[(0,P.jsx)(l,{className:`h-4 w-4 text-gray-500 dark:text-dark-500`}),(0,P.jsx)(`h3`,{className:`text-lg font-semibold text-gray-900 dark:text-dark-800`,children:e(`modelManager.sections.running`)}),(0,P.jsxs)(`span`,{className:a(`ms-auto rounded-full px-2 py-0.5 text-xs font-medium`,`border border-gray-200 bg-gray-50 dark:border-white/10 dark:bg-white/[0.04]`,`text-gray-600 dark:text-dark-600`),children:[X.length,` `,e(`modelManager.systemStatus.running`)]})]}),(0,P.jsx)(`div`,{className:`space-y-2`,children:X.map(t=>(0,P.jsxs)(`div`,{className:a(`flex items-center justify-between p-4 rounded-lg border`,`bg-white/50 dark:bg-white/[0.025]`,`border-gray-200/80 dark:border-white/[0.08]`),children:[(0,P.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,P.jsx)(`div`,{className:a(`w-2 h-2 rounded-full animate-pulse`,`bg-green-500`)}),(0,P.jsxs)(`div`,{children:[(0,P.jsx)(`div`,{className:`font-medium text-gray-900 dark:text-dark-800`,children:t.name}),(0,P.jsxs)(`div`,{className:`flex items-center gap-3 text-sm text-gray-500 dark:text-dark-500`,children:[(0,P.jsxs)(`span`,{className:`flex items-center gap-1`,children:[(0,P.jsx)(te,{className:`h-3 w-3`}),e(`modelManager.systemStatus.vram`),`:`,` `,$(t.size_vram||0)]}),t.size&&(0,P.jsxs)(`span`,{className:`flex items-center gap-1`,children:[(0,P.jsx)(s,{className:`h-3 w-3`}),e(`models.size`),`: `,$(t.size)]})]})]})]}),(0,P.jsxs)(`div`,{className:a(`flex items-center gap-1.5 px-2 py-1 rounded-full text-xs font-medium`,`border border-gray-200 bg-gray-50 dark:border-white/10 dark:bg-white/[0.04]`,`text-gray-600 dark:text-dark-600`),children:[(0,P.jsx)(re,{className:`h-3 w-3`}),e(`modelManager.local.running`)]})]},t.name))})]}),(0,P.jsx)(ge,{expanded:G.has(`local`),models:Y,onToggle:()=>K(`local`),isModelRunning:Ot,formatSize:$,onShowModel:wt,onCopyModel:e=>{L(e),F(!0)},onDeleteModel:Ct}),(0,P.jsxs)(`div`,{className:a(`overflow-hidden rounded-2xl border`,`bg-white/60 dark:bg-white/[0.03]`,`border-gray-200/80 dark:border-white/10`),children:[(0,P.jsxs)(`button`,{onClick:()=>K(`advanced`),"aria-expanded":G.has(`advanced`),className:a(`w-full flex items-center justify-between p-4`,`hover:bg-gray-50 dark:hover:bg-dark-50`,`transition-colors`),children:[(0,P.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,P.jsx)(p,{className:`h-4 w-4 text-gray-500 dark:text-dark-500`}),(0,P.jsx)(`h3`,{className:`text-lg font-semibold text-gray-900 dark:text-dark-800`,children:e(`modelManager.sections.advanced`)})]}),G.has(`advanced`)?(0,P.jsx)(E,{className:`h-5 w-5 text-gray-500`}):(0,P.jsx)(w,{className:`h-5 w-5 text-gray-500`})]}),G.has(`advanced`)&&(0,P.jsx)(`div`,{className:`p-4 pt-0`,children:(0,P.jsxs)(`div`,{className:`grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-4 gap-3`,children:[(0,P.jsxs)(j,{onClick:()=>Oe(!0),variant:`outline`,className:a(`w-full gap-2 justify-start h-auto py-3 px-4`,``,``),children:[(0,P.jsx)(d,{className:`h-5 w-5 text-gray-500 dark:text-dark-500`}),(0,P.jsxs)(`div`,{className:`text-start`,children:[(0,P.jsx)(`div`,{className:`font-medium`,children:e(`modelManager.advanced.createModel`)}),(0,P.jsx)(`div`,{className:`text-xs opacity-70`,children:e(`modelManager.advanced.fromModelfile`)})]})]}),(0,P.jsxs)(j,{onClick:()=>F(!0),variant:`outline`,className:a(`w-full gap-2 justify-start h-auto py-3 px-4`,``,``),children:[(0,P.jsx)(o,{className:`h-5 w-5 text-gray-500 dark:text-dark-500`}),(0,P.jsxs)(`div`,{className:`text-start`,children:[(0,P.jsx)(`div`,{className:`font-medium`,children:e(`modelManager.advanced.copyModel`)}),(0,P.jsx)(`div`,{className:`text-xs opacity-70`,children:e(`modelManager.advanced.duplicateExisting`)})]})]}),(0,P.jsxs)(j,{onClick:()=>Fe(!0),variant:`outline`,className:a(`w-full gap-2 justify-start h-auto py-3 px-4`,``,``),children:[(0,P.jsx)(ie,{className:`h-5 w-5 text-gray-500 dark:text-dark-500`}),(0,P.jsxs)(`div`,{className:`text-start`,children:[(0,P.jsx)(`div`,{className:`font-medium`,children:e(`modelManager.advanced.testEmbeddings`)}),(0,P.jsx)(`div`,{className:`text-xs opacity-70`,children:e(`modelManager.advanced.generateVectors`)})]})]}),(0,P.jsxs)(j,{onClick:async()=>{try{(await A.checkHealth()).success&&(await J(),_.success(e(`modelManager.advanced.healthy`)))}catch{await J(),_.error(e(`modelManager.systemStatus.offline`))}},variant:`outline`,className:a(`w-full gap-2 justify-start h-auto py-3 px-4`,``,``),children:[(0,P.jsx)(h,{className:`h-5 w-5 text-gray-500 dark:text-dark-500`}),(0,P.jsxs)(`div`,{className:`text-start`,children:[(0,P.jsx)(`div`,{className:`font-medium`,children:e(`modelManager.advanced.healthCheck`)}),(0,P.jsx)(`div`,{className:`text-xs opacity-70`,children:e(`modelManager.advanced.testConnection`)})]})]})]})})]}),Ft&&(0,P.jsx)(N.Suspense,{fallback:null,children:(0,P.jsx)(Se,{models:Y,showDetailsModal:pe,setShowDetailsModal:me,selectedModelName:le,selectedModelDetails:ae,loadingDetails:he,showCopyModal:ye,setShowCopyModal:F,copySource:I,setCopySource:L,copyDestination:R,setCopyDestination:we,copying:Te,handleCopyModel:Tt,showCreateModal:De,setShowCreateModal:Oe,createModelName:z,setCreateModelName:ke,createModelfile:Ae,setCreateModelfile:je,creating:Me,handleCreateModel:Et,showEmbeddingsModal:Pe,setShowEmbeddingsModal:Fe,embeddingsModel:Ie,setEmbeddingsModel:Le,embeddingsInput:Re,setEmbeddingsInput:ze,embeddingsResult:Be,generatingEmbeddings:He,handleGenerateEmbeddings:Dt})})]})},R=()=>{let{t:e}=i();return(0,P.jsxs)(ce,{children:[(0,P.jsx)(le,{title:e(`models.title`),description:e(`models.subtitle`)}),(0,P.jsx)(L,{})]})};export{R as ModelsPage,R as default};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{r as e}from"./rolldown-runtime-hePW80VL.js";import{m as t,p as n}from"./markdown-core-BmPPZiuD.js";import{t as r}from"./useTranslation-Bho4HCyg.js";import{r as i,t as a}from"./utils-D9W1Lnkn.js";import{F as o,Kt as s,Rn as c,U as l,g as u,jn as d,q as f,tt as p}from"./ui-vendor-B1UgO3vd.js";import{t as m}from"./logger-DSXjF4ye.js";import{C as h}from"./api-BDtqBtqw.js";import{t as g}from"./Button-BPf_pOxH.js";import"./ui-CC-K19wO.js";import{t as _}from"./RichMessageContent-DiySVYGB.js";var v=e(t(),1),y=n(),b=m(`pages:notes`),x=800,S=()=>{let{t:e,i18n:t}=r(),[n,m]=(0,v.useState)([]),[S,C]=(0,v.useState)(!0),[w,T]=(0,v.useState)(null),[E,D]=(0,v.useState)(``),[O,k]=(0,v.useState)(``),[A,j]=(0,v.useState)(``),[M,N]=(0,v.useState)(!0),[P,F]=(0,v.useState)(`idle`),I=(0,v.useRef)(null),L=(0,v.useMemo)(()=>n.find(e=>e.id===w)??null,[n,w]);(0,v.useEffect)(()=>{let e=!1;return h.getNotes().then(t=>{e||t.success&&t.data&&m(t.data)}).catch(e=>b.error(`Failed to load notes:`,e)).finally(()=>{e||C(!1)}),()=>{e=!0}},[]);let R=(e,t=`preview`)=>{V(),T(e.id),k(e.title),j(e.content),N(t===`preview`),F(`idle`)},z=(e,t,n)=>{I.current!==null&&window.clearTimeout(I.current),F(`saving`),I.current=window.setTimeout(()=>{I.current=null,B(e,t,n)},x)},B=async(t,n,r)=>{try{let e=await h.updateNote(t,{title:n,content:r});if(e.success&&e.data){let n=e.data;m(e=>[n,...e.filter(e=>e.id!==t)].sort((e,t)=>t.updatedAt-e.updatedAt)),F(`saved`)}}catch(t){b.error(`Failed to save note:`,t),c.error(e(`notes.saveFailed`)),F(`idle`)}},V=()=>{I.current!==null&&w&&(window.clearTimeout(I.current),I.current=null,B(w,O,A))};(0,v.useEffect)(()=>()=>{I.current!==null&&window.clearTimeout(I.current)},[]);let H=async()=>{try{let e=await h.createNote(``,``);if(e.success&&e.data){let t=e.data;m(e=>[t,...e]),R(t,`edit`)}}catch(t){b.error(`Failed to create note:`,t),c.error(e(`notes.createFailed`))}},U=async t=>{if(window.confirm(e(`notes.deleteConfirm`)))try{(await h.deleteNote(t)).success&&(m(e=>e.filter(e=>e.id!==t)),w===t&&T(null))}catch(t){b.error(`Failed to delete note:`,t),c.error(e(`notes.deleteFailed`))}},W=(0,v.useMemo)(()=>{let e=E.trim().toLowerCase();return e?n.filter(t=>t.title.toLowerCase().includes(e)||t.content.toLowerCase().includes(e)):n},[n,E]);return(0,y.jsxs)(`div`,{className:`flex h-full min-h-0 overflow-hidden`,"data-testid":`notes-page`,children:[(0,y.jsxs)(`div`,{"data-testid":`notes-list`,className:a(`min-h-0 w-full shrink-0 flex-col border-e border-black/[0.06] dark:border-white/[0.07] md:w-72`,L?`hidden md:flex`:`flex`),children:[(0,y.jsxs)(`div`,{className:`flex items-center justify-between px-4 pb-2 pt-4`,children:[(0,y.jsx)(`h1`,{className:`text-sm font-semibold text-gray-900 dark:text-dark-900`,children:e(`notes.title`)}),(0,y.jsx)(g,{size:`sm`,variant:`ghost`,onClick:()=>void H(),className:`h-7 w-7 p-0`,title:e(`notes.new`),children:(0,y.jsx)(l,{className:`h-4 w-4`})})]}),(0,y.jsxs)(`div`,{className:`relative mx-3 mb-2`,children:[(0,y.jsx)(o,{className:`pointer-events-none absolute start-2.5 top-1/2 h-3.5 w-3.5 -translate-y-1/2 text-gray-400 dark:text-dark-500`}),(0,y.jsx)(`input`,{type:`search`,value:E,onChange:e=>D(e.target.value),placeholder:e(`common.search`),className:`w-full rounded-lg border border-transparent bg-black/[0.04] py-1.5 pe-2.5 ps-8 text-base text-gray-900 placeholder:text-gray-400 focus:border-primary-500/40 focus:outline-none dark:bg-white/[0.05] dark:text-dark-900 dark:placeholder:text-dark-500 sm:text-[13px]`})]}),(0,y.jsx)(`div`,{className:`scroll-region min-h-0 flex-1 overflow-y-auto px-2 pb-3 scrollbar-thin`,children:S?null:W.length===0?(0,y.jsxs)(`div`,{className:`px-3 py-10 text-center`,children:[(0,y.jsx)(p,{className:`mx-auto mb-2 h-6 w-6 text-gray-300 dark:text-dark-400`}),(0,y.jsx)(`p`,{className:`text-xs text-gray-400 dark:text-dark-500`,children:e(`notes.empty`)})]}):(0,y.jsx)(`div`,{className:`space-y-0.5`,children:W.map(n=>(0,y.jsxs)(`div`,{"data-testid":`note-list-item`,onClick:()=>R(n),className:a(`group cursor-pointer rounded-lg px-2.5 py-2 transition-colors`,w===n.id?`bg-white ring-1 ring-black/[0.04] dark:bg-dark-200 dark:ring-white/[0.05]`:`hover:bg-white/60 dark:hover:bg-dark-200/60`),children:[(0,y.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,y.jsx)(`p`,{className:`truncate text-[13px] font-medium text-gray-900 dark:text-dark-900`,children:n.title||e(`notes.untitled`)}),(0,y.jsx)(`button`,{onClick:e=>{e.stopPropagation(),U(n.id)},className:`shrink-0 rounded-md p-1 text-red-500 opacity-100 transition-opacity hover:bg-red-50 sm:opacity-0 sm:group-hover:opacity-100 sm:group-focus-within:opacity-100 dark:hover:bg-red-900/20`,title:e(`common.delete`),children:(0,y.jsx)(u,{className:`h-3 w-3`})})]}),(0,y.jsxs)(`p`,{className:`mt-0.5 truncate text-[11px] text-gray-400 dark:text-dark-500`,children:[i(n.updatedAt,t.language),n.content.trim()&&(0,y.jsxs)(y.Fragment,{children:[` · `,n.content.trim().slice(0,60)]})]})]},n.id))})})]}),(0,y.jsx)(`div`,{"data-testid":`notes-editor`,className:a(`min-w-0 flex-1 flex-col`,L?`flex`:`hidden md:flex`),children:L?(0,y.jsxs)(y.Fragment,{children:[(0,y.jsxs)(`div`,{className:`flex min-w-0 items-center gap-1.5 border-b border-black/[0.06] px-2.5 py-2.5 dark:border-white/[0.07] sm:gap-2 sm:px-5 sm:py-3`,children:[(0,y.jsx)(g,{size:`sm`,variant:`ghost`,onClick:()=>{V(),T(null),N(!0)},className:`h-9 w-9 shrink-0 p-0 md:hidden`,title:`${e(`common.back`)}: ${e(`notes.title`)}`,"aria-label":`${e(`common.back`)}: ${e(`notes.title`)}`,"data-testid":`notes-mobile-back`,children:(0,y.jsx)(d,{className:`h-4 w-4 rtl:rotate-180`})}),M?(0,y.jsx)(`h2`,{"data-testid":`notes-title-preview`,dir:`auto`,className:`min-w-0 flex-1 truncate text-base font-semibold text-gray-950 dark:text-dark-950 sm:text-lg`,children:O||e(`notes.untitled`)}):(0,y.jsxs)(y.Fragment,{children:[(0,y.jsx)(`input`,{"data-testid":`notes-title-editor`,dir:`auto`,value:O,onChange:e=>{k(e.target.value),z(L.id,e.target.value,A)},placeholder:e(`notes.untitled`),className:`min-w-0 flex-1 bg-transparent text-base font-semibold text-gray-950 placeholder:text-gray-400 focus:outline-none dark:text-dark-950 dark:placeholder:text-dark-500 sm:text-lg`}),(0,y.jsx)(`span`,{className:`hidden shrink-0 text-[11px] text-gray-400 dark:text-dark-500 sm:inline`,"aria-live":`polite`,children:P===`saving`?e(`common.saving`):P===`saved`?e(`notes.saved`):``})]}),(0,y.jsx)(g,{size:`sm`,variant:`ghost`,onClick:()=>{M||V(),N(e=>!e)},className:`h-9 w-9 shrink-0 gap-1.5 p-0 text-xs sm:h-8 sm:w-auto sm:px-2.5`,title:e(M?`common.edit`:`artifacts.preview`),"aria-label":e(M?`common.edit`:`artifacts.preview`),"data-testid":`notes-preview-toggle`,children:M?(0,y.jsxs)(y.Fragment,{children:[(0,y.jsx)(f,{className:`h-3.5 w-3.5`}),(0,y.jsx)(`span`,{className:`hidden sm:inline`,children:e(`common.edit`)})]}):(0,y.jsxs)(y.Fragment,{children:[(0,y.jsx)(s,{className:`h-3.5 w-3.5`}),(0,y.jsx)(`span`,{className:`hidden sm:inline`,children:e(`artifacts.preview`)})]})})]}),M?(0,y.jsx)(`div`,{"data-testid":`notes-preview`,className:`scroll-region min-h-0 flex-1 overflow-y-auto px-4 py-3 scrollbar-thin sm:px-5 sm:py-4`,children:(0,y.jsx)(_,{content:A,className:`mx-auto w-full max-w-5xl pb-12`})}):(0,y.jsx)(`textarea`,{"data-testid":`notes-content-editor`,dir:`auto`,value:A,onChange:e=>{j(e.target.value),z(L.id,O,e.target.value)},onBlur:V,placeholder:e(`notes.contentPlaceholder`),className:`min-h-0 flex-1 resize-none bg-transparent px-4 py-3 font-mono text-base leading-relaxed text-gray-900 placeholder:text-gray-400 focus:outline-none dark:text-dark-900 dark:placeholder:text-dark-500 sm:px-5 sm:py-4 sm:text-[13.5px]`})]}):(0,y.jsx)(`div`,{className:`flex flex-1 items-center justify-center`,children:(0,y.jsxs)(`div`,{className:`text-center`,children:[(0,y.jsx)(p,{className:`mx-auto mb-3 h-8 w-8 text-gray-300 dark:text-dark-400`}),(0,y.jsx)(`p`,{className:`text-sm text-gray-500 dark:text-dark-600`,children:e(`notes.selectOrCreate`)}),(0,y.jsxs)(g,{size:`sm`,onClick:()=>void H(),className:`mt-4 gap-1.5`,children:[(0,y.jsx)(l,{className:`h-3.5 w-3.5`}),e(`notes.new`)]})]})})})]})};export{S as NotesPage,S as default};
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import{r as e}from"./rolldown-runtime-hePW80VL.js";import{m as t,p as n}from"./markdown-core-BmPPZiuD.js";import{t as r}from"./useTranslation-Bho4HCyg.js";import{t as i}from"./utils-D9W1Lnkn.js";import{t as a}from"./chatStore-CHQ2uINS.js";import{Cn as o,D as s,E as c,Et as l,Nn as u,O as d,P as f,Rn as p,S as m,Ut as h,V as g,W as _,Xt as v,Yt as y,Zt as b,_n as x,bt as S,c as C,ct as w,f as T,g as E,h as D,in as O,m as k,n as A,t as j,xt as M}from"./ui-vendor-B1UgO3vd.js";import{t as N}from"./logger-DSXjF4ye.js";import{T as P,d as F,f as I,p as L}from"./api-BDtqBtqw.js";import{t as R}from"./appStore-0JnCUlEq.js";import{t as z}from"./Button-BPf_pOxH.js";import{n as B,t as V}from"./ui-CC-K19wO.js";import{C as H,b as U,x as W}from"../assets/index-6o-Hc2wS.js";var G=e(t(),1),K=n(),q=N(`components:persona-card`),J=({persona:e,onEdit:t,onDelete:n,onDownload:a,onSelect:l,onToggleFavorite:d,isSelected:g=!1,compact:x=!1})=>{let{t:S}=r(),C=H(),[T,D]=(0,G.useState)(!1),[O,A]=(0,G.useState)(!1),M=!!(e.memory_settings?.enabled||e.mutation_settings?.enabled),{data:N=null}=W({queryKey:[`persona-memory-status`,e.id],queryFn:async()=>{let t=await F.getMemoryStatus(e.id);return t.success&&t.data?t.data:null},enabled:M}),P=()=>C.invalidateQueries({queryKey:[`persona-memory-status`,e.id]}),R=async()=>{if(confirm(S(`personaCard.wipeConfirm`))){A(!0);try{let t=await F.wipeMemories(e.id);t.success?(p.success(S(`personaCard.wipeSuccess`,{count:t.data?.deleted_count||0})),await P()):p.error(S(`personaCard.failed`,{action:`wipe memories`}))}catch(e){p.error(S(`personaCard.failed`,{action:`wipe memories`})),q.error(e)}finally{A(!1),D(!1)}}},B=async()=>{A(!0);try{let t=await F.backupPersona(e.id),n=window.URL.createObjectURL(t),r=document.createElement(`a`);r.href=n,r.download=`${e.name.toLowerCase().replace(/\s+/g,`-`)}-backup.json`,document.body.appendChild(r),r.click(),window.URL.revokeObjectURL(n),document.body.removeChild(r),p.success(S(`personaCard.backupSuccess`))}catch(e){p.error(S(`personaCard.failed`,{action:`backup persona`})),q.error(e)}finally{A(!1),D(!1)}},V=async()=>{A(!0);try{let t=await F.exportPersonaDNA(e.id),n=window.URL.createObjectURL(t),r=document.createElement(`a`);r.href=n,r.download=`${e.name.toLowerCase().replace(/\s+/g,`-`)}-dna.json`,document.body.appendChild(r),r.click(),window.URL.revokeObjectURL(n),document.body.removeChild(r),p.success(S(`personaCard.dnaSuccess`))}catch(e){p.error(S(`personaCard.failed`,{action:`export persona DNA`})),q.error(e)}finally{A(!1),D(!1)}},U=(t=128)=>I(e,t),J=(t=128)=>n=>{L(n.currentTarget,e.name,t)};return x?(0,K.jsxs)(`div`,{className:i(`group relative flex items-center gap-3 p-3 rounded-xl cursor-pointer transition-all duration-200`,`border border-transparent`,`hover:bg-gray-50 dark:hover:bg-dark-100`,g&&[`bg-primary-50 dark:bg-primary-900/20`,`border-primary-200 dark:border-primary-700`]),onClick:()=>l?.(e),children:[(0,K.jsxs)(`div`,{className:`relative flex-shrink-0`,children:[(0,K.jsx)(`img`,{src:U(64),alt:e.name,className:`w-10 h-10 rounded-full object-cover ring-2 ring-white dark:ring-dark-100`,onError:J(64)}),M&&(0,K.jsx)(`div`,{className:`absolute -bottom-0.5 -end-0.5 flex h-4 w-4 items-center justify-center rounded-full bg-primary-600`,children:(0,K.jsx)(s,{className:`h-2.5 w-2.5 text-white`})})]}),(0,K.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,K.jsx)(`h4`,{className:`font-medium text-sm text-gray-900 dark:text-gray-100 truncate`,children:e.name}),e.is_favorite&&(0,K.jsx)(m,{className:`h-3 w-3 text-amber-500 fill-amber-500 flex-shrink-0`})]}),(0,K.jsx)(`p`,{className:`text-xs text-gray-500 dark:text-gray-400 truncate`,children:e.model})]}),g&&(0,K.jsx)(`div`,{className:`flex-shrink-0`,children:(0,K.jsx)(`div`,{className:`w-6 h-6 rounded-full bg-primary-500 dark:bg-primary-600 flex items-center justify-center`,children:(0,K.jsx)(_,{className:`h-3 w-3 text-white rtl:rotate-180`})})})]}):(0,K.jsxs)(`div`,{className:i(`group relative overflow-hidden rounded-2xl transition-[border-color,background-color] duration-200`,`bg-white/70 dark:bg-white/[0.035]`,`border border-gray-200/80 dark:border-white/10`,`hover:border-gray-300 dark:hover:border-white/20`,g&&[`ring-2 ring-primary-500 dark:ring-primary-400`,`border-primary-300 dark:border-primary-600`]),children:[(0,K.jsxs)(`div`,{className:`relative h-24`,children:[e.background?(0,K.jsx)(`div`,{className:`absolute inset-0 bg-cover bg-center`,style:{backgroundImage:`url(${e.background})`}}):(0,K.jsx)(`div`,{className:`absolute inset-0 bg-gray-200 dark:bg-dark-200`}),e.background&&(0,K.jsx)(`div`,{className:`absolute inset-0 bg-black/15 dark:bg-black/25`}),(0,K.jsxs)(`div`,{className:`absolute inset-x-3 top-3 flex items-start justify-between`,children:[(0,K.jsx)(`button`,{onClick:t=>{t.stopPropagation(),d?.(e)},className:i(`p-1.5 rounded-full transition-all duration-200`,`border border-white/30 bg-black/20 text-white backdrop-blur-sm hover:bg-black/30`,e.is_favorite&&`bg-amber-500/80 hover:bg-amber-500`),children:(0,K.jsx)(m,{className:i(`h-4 w-4`,e.is_favorite?`fill-ink text-ink dark:fill-ink-inverse dark:text-ink-inverse`:`text-white/80 hover:text-white`)})}),M&&(0,K.jsxs)(`div`,{className:`flex items-center gap-1 rounded-full border border-white/30 bg-black/20 px-2 py-1 text-[10px] font-medium text-white backdrop-blur-sm`,children:[(0,K.jsx)(s,{className:`h-3 w-3`}),S(`personaCard.enhanced`)]})]})]}),(0,K.jsx)(`div`,{className:`relative -mt-8 px-4`,children:(0,K.jsxs)(`div`,{className:`relative inline-block`,children:[(0,K.jsx)(`img`,{src:U(128),alt:e.name,className:`h-16 w-16 rounded-xl object-cover ring-4 ring-white dark:ring-dark-100`,onError:J(128)}),M&&(0,K.jsx)(`div`,{className:`absolute -bottom-1 -end-1 flex h-6 w-6 items-center justify-center rounded-lg bg-primary-600 ring-2 ring-white dark:ring-dark-100`,children:(0,K.jsx)(o,{className:`h-3.5 w-3.5 text-white`})})]})}),(0,K.jsxs)(`div`,{className:`px-4 pt-3 pb-4`,children:[(0,K.jsxs)(`div`,{className:`mb-3`,children:[(0,K.jsx)(`h3`,{className:`text-lg font-semibold text-gray-900 dark:text-gray-100 leading-tight`,children:e.name}),(0,K.jsxs)(`p`,{className:`text-sm text-gray-500 dark:text-gray-400 flex items-center gap-1.5 mt-0.5`,children:[(0,K.jsx)(f,{className:`h-3.5 w-3.5`}),e.model]})]}),e.description&&(0,K.jsx)(`p`,{className:`text-sm text-gray-600 dark:text-gray-400 line-clamp-2 mb-3`,children:e.description}),e.parameters.system_prompt&&(0,K.jsxs)(`div`,{className:`mb-3 rounded-xl border border-gray-200/70 bg-gray-50/70 p-2.5 dark:border-white/[0.08] dark:bg-white/[0.025]`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-1.5 mb-1`,children:[(0,K.jsx)(w,{className:`h-3 w-3 text-gray-400 dark:text-gray-500`}),(0,K.jsx)(`span`,{className:`text-[10px] uppercase tracking-wider font-medium text-gray-400 dark:text-gray-500`,children:S(`personaCard.systemPrompt`)})]}),(0,K.jsxs)(`p`,{className:`line-clamp-2 text-xs leading-5 text-gray-600 dark:text-gray-400`,children:[`“`,e.parameters.system_prompt,`”`]})]}),(0,K.jsxs)(`div`,{className:`flex flex-wrap gap-1.5 mb-3`,children:[(0,K.jsxs)(`span`,{className:`inline-flex items-center gap-1 rounded-lg border border-gray-200/70 px-2 py-1 text-[11px] font-medium text-gray-600 dark:border-white/[0.08] dark:text-gray-400`,children:[(0,K.jsx)(j,{className:`h-3 w-3`}),e.parameters.temperature?.toFixed(1)||`0.7`]}),(0,K.jsxs)(`span`,{className:`inline-flex items-center rounded-lg border border-gray-200/70 px-2 py-1 text-[11px] font-medium text-gray-600 dark:border-white/[0.08] dark:text-gray-400`,children:[`Top-P `,e.parameters.top_p?.toFixed(1)||`0.9`]}),(0,K.jsxs)(`span`,{className:`inline-flex items-center rounded-lg border border-gray-200/70 px-2 py-1 text-[11px] font-medium text-gray-600 dark:border-white/[0.08] dark:text-gray-400`,children:[(e.parameters.context_window||4096).toLocaleString(),` ctx`]})]}),M&&N&&(0,K.jsx)(`div`,{className:`mb-3 rounded-xl border border-primary-200/70 bg-primary-50/50 p-2.5 dark:border-primary-800/40 dark:bg-primary-900/10`,children:(0,K.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,K.jsx)(b,{className:`h-4 w-4 text-primary-600 dark:text-primary-400`}),(0,K.jsxs)(`div`,{children:[(0,K.jsxs)(`span`,{className:`text-xs font-medium text-primary-700 dark:text-primary-300`,children:[N.memory_count,` `,S(`personaCard.memories`)]}),(0,K.jsx)(`span`,{className:`ms-2 text-[10px] text-primary-600/70 dark:text-primary-400/70`,children:(e=>e<1?`${(e*1024).toFixed(0)} KB`:`${e.toFixed(1)} MB`)(N.size_mb)})]})]}),N.status&&(0,K.jsx)(`span`,{className:i(`text-[10px] px-1.5 py-0.5 rounded-full font-medium`,N.status===`active`?`bg-green-100 dark:bg-green-900/30 text-green-700 dark:text-green-400`:`bg-gray-100 dark:bg-dark-200 text-gray-600 dark:text-gray-400`),children:N.status})]})}),(0,K.jsxs)(`div`,{className:`flex items-center justify-between border-t border-gray-200/70 pt-3 dark:border-white/[0.08]`,children:[l&&(0,K.jsxs)(z,{onClick:()=>l(e),size:`sm`,className:`px-4`,children:[(0,K.jsx)(_,{className:`me-1.5 h-3.5 w-3.5 rtl:rotate-180`}),S(`personaCard.use`)]}),(0,K.jsxs)(`div`,{className:`ms-auto flex items-center gap-1`,children:[(0,K.jsx)(`button`,{onClick:()=>t(e),className:`p-2 rounded-lg text-gray-500 hover:text-gray-700 dark:text-gray-400 dark:hover:text-gray-200 hover:bg-gray-100 dark:hover:bg-dark-200 transition-colors`,title:S(`personaCard.editTooltip`),children:(0,K.jsx)(c,{className:`h-4 w-4`})}),(0,K.jsx)(`button`,{onClick:()=>a(e),className:`p-2 rounded-lg text-gray-500 hover:text-gray-700 dark:text-gray-400 dark:hover:text-gray-200 hover:bg-gray-100 dark:hover:bg-dark-200 transition-colors`,title:S(`personaCard.downloadTooltip`),children:(0,K.jsx)(v,{className:`h-4 w-4`})}),(0,K.jsxs)(`div`,{className:`relative`,children:[(0,K.jsx)(`button`,{onClick:()=>D(!T),className:`p-2 rounded-lg text-gray-500 hover:text-gray-700 dark:text-gray-400 dark:hover:text-gray-200 hover:bg-gray-100 dark:hover:bg-dark-200 transition-colors`,title:S(`common.more`,{defaultValue:`More`}),children:(0,K.jsx)(y,{className:`h-4 w-4`})}),T&&(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`div`,{className:`fixed inset-0 z-10`,onClick:()=>D(!1)}),(0,K.jsxs)(`div`,{className:`absolute end-0 bottom-full z-20 mb-1 w-44 rounded-xl border border-gray-200 bg-white py-1 shadow-lg dark:border-white/10 dark:bg-dark-100`,children:[M&&(0,K.jsxs)(K.Fragment,{children:[(0,K.jsxs)(`button`,{onClick:B,disabled:O,className:`w-full flex items-center gap-2 px-3 py-2 text-sm text-gray-700 dark:text-gray-300 hover:bg-gray-50 dark:hover:bg-dark-50 disabled:opacity-50`,children:[(0,K.jsx)(u,{className:`h-4 w-4`}),S(`personaCard.backup`)]}),(0,K.jsxs)(`button`,{onClick:V,disabled:O,className:`w-full flex items-center gap-2 px-3 py-2 text-sm text-gray-700 dark:text-gray-300 hover:bg-gray-50 dark:hover:bg-dark-50 disabled:opacity-50`,children:[(0,K.jsx)(h,{className:`h-4 w-4`}),S(`personaCard.exportDNA`)]}),N&&N.memory_count>0&&(0,K.jsxs)(`button`,{onClick:R,disabled:O,className:`w-full flex items-center gap-2 px-3 py-2 text-sm text-red-600 dark:text-red-400 hover:bg-red-50 dark:hover:bg-red-900/20 disabled:opacity-50`,children:[(0,K.jsx)(k,{className:`h-4 w-4`}),S(`personaCard.wipeMemories`)]}),(0,K.jsx)(`div`,{className:`my-1 border-t border-gray-100 dark:border-dark-200`})]}),(0,K.jsxs)(`button`,{onClick:()=>{n(e),D(!1)},className:`w-full flex items-center gap-2 px-3 py-2 text-sm text-red-600 dark:text-red-400 hover:bg-red-50 dark:hover:bg-red-900/20`,children:[(0,K.jsx)(E,{className:`h-4 w-4`}),S(`common.delete`)]})]})]})]})]})]})]})]})},Y={name:``,description:``,model:``,parameters:{temperature:.7,top_p:.9,top_k:40,context_window:4096,max_tokens:1024,system_prompt:``,repeat_penalty:1.1,presence_penalty:0,frequency_penalty:0},avatar:``,background:``,embedding_model:``,memory_settings:{enabled:!1,max_memories:1e3,auto_cleanup:!0,retention_days:90},mutation_settings:{enabled:!1,sensitivity:`medium`,auto_adapt:!0}};function ee({embeddingModel:e,embeddingModels:t,onEmbeddingModelChange:n}){let{t:i}=r(),a=t.filter(e=>e.isDetectedEmbedding),o=t.filter(e=>!e.isDetectedEmbedding);return(0,K.jsxs)(`div`,{className:`space-y-6`,children:[(0,K.jsxs)(`div`,{className:`rounded-xl p-5 bg-gradient-to-br from-primary-50 to-primary-100/50 dark:from-primary-900/30 dark:to-primary-800/20 border border-primary-200/50 dark:border-primary-700/30`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-2 mb-4`,children:[(0,K.jsx)(b,{className:`h-5 w-5 text-primary-600 dark:text-primary-400`}),(0,K.jsx)(`h3`,{className:`font-semibold text-primary-900 dark:text-primary-100`,children:i(`personaForm.advanced.embeddingModel`)})]}),(0,K.jsx)(`p`,{className:`text-xs text-primary-600 dark:text-primary-400 mb-3`,children:i(`personaForm.advanced.embeddingHint`)}),(0,K.jsx)(`select`,{value:e,onChange:e=>n(e.target.value),className:`w-full px-3 py-2.5 border border-primary-200 dark:border-primary-700 rounded-lg bg-white dark:bg-dark-50 text-gray-900 dark:text-dark-800 focus:ring-2 focus:ring-primary-500/20`,children:t.length===0?(0,K.jsx)(`option`,{value:``,disabled:!0,children:i(`personaForm.advanced.noModels`)}):(0,K.jsxs)(K.Fragment,{children:[a.length>0&&(0,K.jsx)(`optgroup`,{label:i(`personaForm.advanced.embeddingModels`),children:a.map(e=>(0,K.jsxs)(`option`,{value:e.id,children:[e.name,` - `,e.description]},e.id))}),o.length>0&&(0,K.jsx)(`optgroup`,{label:i(`personaForm.advanced.otherModels`),children:o.map(e=>(0,K.jsxs)(`option`,{value:e.id,children:[e.name,` - `,e.description]},e.id))})]})}),t.length===0&&(0,K.jsx)(`div`,{className:`mt-3 rounded-lg border border-amber-200 bg-amber-500/10 p-3 dark:border-amber-700/50 dark:bg-amber-900/20`,children:(0,K.jsxs)(`p`,{className:`text-sm text-ink`,children:[i(`personaForm.advanced.installHint`),` `,(0,K.jsx)(`code`,{className:`rounded bg-amber-500/20 px-1.5 py-0.5 text-xs dark:bg-amber-900/40`,children:`ollama pull nomic-embed-text`})]})}),(0,K.jsx)(`p`,{className:`text-[10px] text-primary-500 dark:text-primary-500 mt-2`,children:i(`personaForm.advanced.recommended`)})]}),(0,K.jsx)(`div`,{className:`p-4 bg-gray-50 dark:bg-dark-50 rounded-xl border border-gray-200 dark:border-dark-300`,children:(0,K.jsxs)(`div`,{className:`flex items-start gap-3`,children:[(0,K.jsx)(S,{className:`h-5 w-5 text-gray-400 mt-0.5 flex-shrink-0`}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`p`,{className:`text-sm font-medium text-gray-700 dark:text-gray-300`,children:i(`personaForm.advanced.aboutTitle`)}),(0,K.jsx)(`p`,{className:`text-xs text-gray-500 dark:text-gray-400 mt-1`,children:i(`personaForm.advanced.aboutDescription`)})]})]})})]})}var X=N(`components:persona-background-upload`),Z=({value:e,onChange:t,className:n=``})=>{let{t:i}=r(),a=(0,G.useRef)(null),[o,s]=(0,G.useState)(!1),[c,l]=(0,G.useState)(!1),u=async e=>{if(!e.type.startsWith(`image/`)){p.error(i(`personaBackground.invalidFile`));return}if(e.size>5242880){p.error(i(`personaBackground.fileTooLarge`));return}s(!0);try{let n=new FileReader;n.onload=e=>{let n=e.target?.result;t(n),p.success(i(`personaBackground.uploaded`))},n.onerror=()=>{p.error(i(`personaBackground.readFailed`))},n.readAsDataURL(e)}catch(e){X.error(`Failed to upload background:`,e),p.error(i(`personaBackground.uploadFailed`))}finally{s(!1)}};return(0,K.jsx)(`div`,{className:`space-y-4 ${n}`,children:(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`label`,{className:`block text-sm font-medium text-gray-700 dark:text-dark-600 mb-2`,children:i(`personaBackground.label`)}),(0,K.jsxs)(`div`,{className:`space-y-3`,children:[e?(0,K.jsxs)(`div`,{className:`space-y-3`,children:[(0,K.jsx)(`div`,{className:`w-full h-32 rounded-lg bg-cover bg-center border-2 border-gray-300 dark:border-dark-300`,style:{backgroundImage:`url(${e})`}}),(0,K.jsxs)(`div`,{className:`flex items-center gap-3 p-3 bg-gray-50 dark:bg-dark-200 rounded-lg`,children:[(0,K.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,K.jsx)(`p`,{className:`text-sm font-medium text-gray-900 dark:text-gray-100 truncate`,children:i(`personaBackground.customBackground`)}),(0,K.jsx)(`p`,{className:`text-xs text-gray-500 dark:text-gray-400`,children:i(`personaBackground.clickToChange`)})]}),(0,K.jsx)(z,{variant:`ghost`,size:`sm`,onClick:()=>{t(``),p.success(i(`personaBackground.removed`))},className:`text-red-600 hover:text-red-700 hover:bg-red-50 dark:text-red-400 dark:hover:text-red-300 dark:hover:bg-red-900/20`,children:(0,K.jsx)(A,{className:`h-4 w-4`})})]})]}):(0,K.jsxs)(`div`,{className:`border-2 border-dashed rounded-lg p-6 text-center cursor-pointer transition-colors ${c?`border-primary-500 bg-primary-50 dark:bg-primary-900/20`:`border-gray-300 dark:border-gray-600 hover:border-gray-400 dark:hover:border-gray-500`}`,onDragOver:e=>{e.preventDefault(),l(!0)},onDragLeave:e=>{e.preventDefault(),l(!1)},onDrop:e=>{e.preventDefault(),l(!1);let t=e.dataTransfer.files?.[0];t&&u(t)},onClick:()=>a.current?.click(),children:[(0,K.jsx)(M,{className:`h-12 w-12 mx-auto text-gray-400 dark:text-gray-500 mb-4`}),(0,K.jsx)(`p`,{className:`text-sm font-medium text-gray-900 dark:text-gray-100 mb-2`,children:i(`personaBackground.uploadBackgroundImage`)}),(0,K.jsx)(`p`,{className:`text-xs text-gray-500 dark:text-gray-400 mb-4`,children:i(`personaBackground.dragAndDrop`)}),(0,K.jsxs)(z,{variant:`outline`,size:`sm`,disabled:o,className:`mx-auto`,children:[(0,K.jsx)(T,{className:`h-4 w-4 mr-2`}),i(o?`personaBackground.uploading`:`personaBackground.chooseImage`)]})]}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`label`,{className:`block text-xs font-medium text-gray-600 dark:text-gray-400 mb-1`,children:i(`personaBackground.enterImageUrl`)}),(0,K.jsx)(`input`,{type:`url`,value:e,onChange:e=>t(e.target.value),className:`w-full px-3 py-2 text-sm border border-gray-300 dark:border-dark-300 rounded-md bg-white dark:bg-dark-50 text-gray-900 dark:text-dark-800`,placeholder:`https://example.com/background.jpg`})]})]}),(0,K.jsx)(`input`,{ref:a,type:`file`,accept:`image/*`,onChange:e=>{let t=e.target.files?.[0];t&&u(t)},className:`hidden`}),(0,K.jsx)(`p`,{className:`text-xs text-gray-500 dark:text-gray-400 mt-2`,children:i(`personaBackground.supportedFormats`)})]})})};function te({formData:e,availableModels:t,onFieldChange:n,onParameterChange:i}){let{t:a}=r(),o=(0,G.useMemo)(()=>t.filter(e=>!e.isPlugin),[t]),s=(0,G.useMemo)(()=>{let e=new Map;for(let n of t){if(!n.isPlugin)continue;let t=n.pluginName||n.pluginId||`Provider`,r=e.get(t);r?r.push(n):e.set(t,[n])}return[...e.entries()].sort(([e],[t])=>e.localeCompare(t))},[t]);return(0,K.jsxs)(`div`,{className:`space-y-6`,children:[(0,K.jsxs)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 gap-4`,children:[(0,K.jsxs)(`div`,{children:[(0,K.jsxs)(`label`,{className:`block text-sm font-medium text-gray-700 dark:text-dark-600 mb-2`,children:[a(`personaForm.basic.name`),` *`]}),(0,K.jsx)(`input`,{type:`text`,value:e.name,onChange:e=>n(`name`,e.target.value),className:`w-full px-3 py-2 border border-gray-300 dark:border-dark-300 rounded-lg bg-white dark:bg-dark-50 text-gray-900 dark:text-dark-800 focus:ring-2 focus:ring-primary-500/20 focus:border-primary-500 transition-colors`,placeholder:a(`personaForm.basic.namePlaceholder`),required:!0})]}),(0,K.jsxs)(`div`,{children:[(0,K.jsxs)(`label`,{className:`block text-sm font-medium text-gray-700 dark:text-dark-600 mb-2`,children:[a(`personaForm.basic.model`),` *`]}),(0,K.jsxs)(`select`,{value:e.model,onChange:e=>n(`model`,e.target.value),className:`w-full px-3 py-2 border border-gray-300 dark:border-dark-300 rounded-lg bg-white dark:bg-dark-50 text-gray-900 dark:text-dark-800 focus:ring-2 focus:ring-primary-500/20 focus:border-primary-500 transition-colors`,required:!0,children:[(0,K.jsx)(`option`,{value:``,children:a(`personaForm.basic.selectModel`)}),e.model&&!t.some(t=>t.name===e.model)&&(0,K.jsx)(`option`,{value:e.model,children:e.model}),o.length>0&&(0,K.jsx)(`optgroup`,{label:`Ollama`,children:o.map(e=>(0,K.jsx)(`option`,{value:e.name,children:e.name},e.name))}),s.map(([e,t])=>(0,K.jsx)(`optgroup`,{label:e,children:t.map(e=>(0,K.jsx)(`option`,{value:e.name,children:e.name},e.name))},e))]})]})]}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`label`,{className:`block text-sm font-medium text-gray-700 dark:text-dark-600 mb-2`,children:a(`personaForm.basic.description`)}),(0,K.jsx)(`textarea`,{value:e.description,onChange:e=>n(`description`,e.target.value),className:`w-full px-3 py-2 border border-gray-300 dark:border-dark-300 rounded-lg bg-white dark:bg-dark-50 text-gray-900 dark:text-dark-800 focus:ring-2 focus:ring-primary-500/20 focus:border-primary-500 transition-colors resize-none`,rows:3,placeholder:a(`personaForm.basic.descriptionPlaceholder`)})]}),(0,K.jsxs)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 gap-6`,children:[(0,K.jsx)(U,{value:e.avatar||``,onChange:e=>n(`avatar`,e)}),(0,K.jsx)(Z,{value:e.background||``,onChange:e=>n(`background`,e)})]}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`label`,{className:`block text-sm font-medium text-gray-700 dark:text-dark-600 mb-2`,children:a(`personaForm.basic.systemPrompt`)}),(0,K.jsx)(`textarea`,{value:e.parameters.system_prompt,onChange:e=>i(`system_prompt`,e.target.value),className:`w-full px-3 py-2 border border-gray-300 dark:border-dark-300 rounded-lg bg-white dark:bg-dark-50 text-gray-900 dark:text-dark-800 focus:ring-2 focus:ring-primary-500/20 focus:border-primary-500 transition-colors resize-none font-mono text-sm`,rows:6,placeholder:a(`personaForm.basic.systemPromptPlaceholder`)}),(0,K.jsx)(`p`,{className:`text-xs text-gray-500 dark:text-dark-600 mt-2`,children:a(`personaForm.basic.systemPromptHint`)})]})]})}function ne({persona:e,submitting:t,saveAndClose:n,lastSaved:i,onCancel:a,onSave:o,onSaveAndClose:s}){let{t:c}=r();return(0,K.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,K.jsx)(z,{type:`button`,variant:`ghost`,onClick:a,disabled:t,className:`text-gray-600 dark:text-gray-400`,children:c(`personaForm.actions.cancel`)}),(0,K.jsxs)(`div`,{className:`flex items-center gap-3`,children:[i&&(0,K.jsxs)(`div`,{className:`flex items-center gap-1.5 text-sm text-emerald-600 dark:text-emerald-400`,children:[(0,K.jsx)(x,{className:`h-4 w-4`}),(0,K.jsx)(`span`,{children:c(`personaForm.saved`)})]}),(0,K.jsx)(z,{type:`button`,variant:`outline`,onClick:o,disabled:t,children:c(t&&!n?`personaForm.actions.saving`:`personaForm.actions.save`)}),(0,K.jsx)(z,{type:`button`,onClick:s,disabled:t,children:c(t&&n?`personaForm.actions.saving`:e?`personaForm.actions.saveClose`:`personaForm.actions.create`)})]})]})}var Q=({label:e,value:t,min:n,max:r,step:a,onChange:o,hint:s,format:c=e=>String(e),colorClass:l=`text-gray-700 dark:text-dark-600`})=>{let u=(t-n)/(r-n)*100;return(0,K.jsxs)(`div`,{children:[(0,K.jsxs)(`div`,{className:`flex items-center justify-between mb-2`,children:[(0,K.jsx)(`label`,{className:i(`block text-sm font-medium`,l),children:e}),(0,K.jsx)(`input`,{type:`number`,min:n,max:r,step:a,value:c(t),onChange:e=>{let t=parseFloat(e.target.value);isNaN(t)||o(Math.min(r,Math.max(n,t)))},className:`w-20 px-2 py-1 text-sm text-right bg-gray-100 dark:bg-dark-200 border border-gray-300 dark:border-dark-300 rounded focus:outline-none focus:ring-1 focus:ring-primary-500 dark:text-dark-600`})]}),(0,K.jsx)(`input`,{type:`range`,min:n,max:r,step:a,value:t,onChange:e=>o(parseFloat(e.target.value)),className:`w-full h-2 bg-gray-200 dark:bg-dark-200 rounded-lg appearance-none cursor-pointer slider`,style:{"--progress":`${u}%`}}),s&&(0,K.jsx)(`p`,{className:i(`text-xs mt-1`,l.replace(`700`,`500`).replace(`600`,`400`)),children:s})]})},$=({label:e,checked:t,onChange:n,colorClass:r=`text-gray-700 dark:text-dark-600`})=>(0,K.jsxs)(`label`,{className:`flex items-center gap-3 cursor-pointer`,children:[(0,K.jsx)(`div`,{className:i(`relative w-10 h-5 rounded-full transition-colors`,t?`bg-primary-500 dark:bg-primary-600`:`bg-gray-300 dark:bg-dark-300`),onClick:()=>n(!t),children:(0,K.jsx)(`div`,{className:i(`absolute top-0.5 start-0.5 w-4 h-4 rounded-full bg-white shadow transition-transform`,t&&`translate-x-5 rtl:-translate-x-5`)})}),(0,K.jsx)(`span`,{className:i(`text-sm font-medium`,r),children:e})]});function re({formData:e,persona:t,memoryStatus:n,loadingMemoryStatus:a,wipingMemories:c,onSettingsChange:u,onWipeMemories:d}){let{t:f}=r();return(0,K.jsxs)(`div`,{className:`space-y-6`,children:[(0,K.jsxs)(`div`,{className:`rounded-xl overflow-hidden border border-emerald-200/50 dark:border-emerald-700/30`,children:[(0,K.jsx)(`div`,{className:`px-5 py-4 bg-gradient-to-r from-emerald-500 to-teal-500 dark:from-emerald-600 dark:to-teal-600`,children:(0,K.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,K.jsx)(`div`,{className:`w-10 h-10 rounded-lg bg-white/20 flex items-center justify-center`,children:(0,K.jsx)(b,{className:`h-5 w-5 text-white`})}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`h3`,{className:`font-semibold text-white`,children:f(`personaForm.memory.title`)}),(0,K.jsx)(`p`,{className:`text-xs text-white/80`,children:f(`personaForm.memory.subtitle`)})]})]}),(0,K.jsx)($,{label:``,checked:e.memory_settings?.enabled||!1,onChange:e=>u(`memory_settings`,{enabled:e})})]})}),e.memory_settings?.enabled&&t?.id&&(0,K.jsx)(`div`,{className:`px-5 py-4 bg-emerald-50 dark:bg-emerald-900/20 border-b border-emerald-100 dark:border-emerald-800/30`,children:a?(0,K.jsxs)(`div`,{className:`flex items-center gap-2 text-sm text-emerald-600 dark:text-emerald-400`,children:[(0,K.jsx)(g,{className:`h-4 w-4 animate-spin`}),f(`personaForm.memory.loading`)]}):n?(0,K.jsxs)(`div`,{className:`grid grid-cols-3 gap-4`,children:[(0,K.jsxs)(`div`,{className:`text-center`,children:[(0,K.jsxs)(`div`,{className:`flex items-center justify-center gap-1 text-2xl font-bold text-emerald-700 dark:text-emerald-300`,children:[(0,K.jsx)(b,{className:`h-5 w-5`}),n.memory_count.toLocaleString()]}),(0,K.jsx)(`p`,{className:`text-xs text-emerald-600 dark:text-emerald-400`,children:f(`personaForm.memory.memories`)})]}),(0,K.jsxs)(`div`,{className:`text-center`,children:[(0,K.jsxs)(`div`,{className:`flex items-center justify-center gap-1 text-2xl font-bold text-emerald-700 dark:text-emerald-300`,children:[(0,K.jsx)(l,{className:`h-5 w-5`}),n.size_mb.toFixed(1)]}),(0,K.jsx)(`p`,{className:`text-xs text-emerald-600 dark:text-emerald-400`,children:f(`personaForm.memory.mbUsed`)})]}),(0,K.jsxs)(`div`,{className:`text-center`,children:[(0,K.jsxs)(`div`,{className:`flex items-center justify-center gap-1 text-2xl font-bold text-emerald-700 dark:text-emerald-300`,children:[(0,K.jsx)(O,{className:`h-5 w-5`}),n.last_backup?new Date(n.last_backup).toLocaleDateString():f(`personaForm.memory.never`)]}),(0,K.jsx)(`p`,{className:`text-xs text-emerald-600 dark:text-emerald-400`,children:f(`personaForm.memory.lastBackup`)})]})]}):(0,K.jsx)(`p`,{className:`text-sm text-emerald-600 dark:text-emerald-400`,children:f(`personaForm.memory.noData`)})}),e.memory_settings?.enabled&&(0,K.jsxs)(`div`,{className:`p-5 bg-white dark:bg-dark-100 space-y-4`,children:[(0,K.jsx)(Q,{label:f(`personaForm.memory.maxMemories`),value:e.memory_settings.max_memories,min:100,max:1e4,step:100,hint:f(`personaForm.memory.maxMemoriesHint`),format:e=>e.toLocaleString(),colorClass:`text-emerald-700 dark:text-emerald-300`,onChange:e=>u(`memory_settings`,{max_memories:e})}),(0,K.jsx)(Q,{label:f(`personaForm.memory.retention`),value:e.memory_settings.retention_days,min:7,max:365,step:7,hint:f(`personaForm.memory.retentionHint`),format:e=>`${Math.round(e)} days`,colorClass:`text-emerald-700 dark:text-emerald-300`,onChange:e=>u(`memory_settings`,{retention_days:e})}),(0,K.jsx)($,{label:f(`personaForm.memory.autoCleanup`),checked:e.memory_settings.auto_cleanup,onChange:e=>u(`memory_settings`,{auto_cleanup:e}),colorClass:`text-emerald-700 dark:text-emerald-300`}),t?.id&&n&&n.memory_count>0&&(0,K.jsx)(`div`,{className:`pt-4 border-t border-gray-200 dark:border-dark-300`,children:(0,K.jsxs)(`div`,{className:`flex items-center justify-between p-3 bg-red-50 dark:bg-red-900/20 rounded-lg border border-red-200 dark:border-red-800/30`,children:[(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`p`,{className:`text-sm font-medium text-red-700 dark:text-red-300`,children:f(`personaForm.memory.wipeAll`)}),(0,K.jsx)(`p`,{className:`text-xs text-red-600 dark:text-red-400`,children:f(`personaForm.memory.wipeCannot`)})]}),(0,K.jsxs)(`button`,{type:`button`,onClick:d,disabled:c,className:`px-3 py-1.5 bg-red-500 hover:bg-red-600 text-white text-sm font-medium rounded-lg transition-colors disabled:opacity-50 flex items-center gap-1.5`,children:[c?(0,K.jsx)(g,{className:`h-3.5 w-3.5 animate-spin`}):(0,K.jsx)(E,{className:`h-3.5 w-3.5`}),f(c?`personaForm.memory.wiping`:`personaForm.memory.wipeButton`)]})]})})]}),!e.memory_settings?.enabled&&(0,K.jsx)(`div`,{className:`p-5 bg-gray-50 dark:bg-dark-50`,children:(0,K.jsx)(`p`,{className:`text-sm text-gray-500 dark:text-gray-400 text-center`,children:f(`personaForm.memory.enableHint`)})})]}),(0,K.jsxs)(`div`,{className:`rounded-xl overflow-hidden border border-primary-200/50 dark:border-primary-700/30`,children:[(0,K.jsx)(`div`,{className:`px-5 py-4 bg-primary-600 dark:bg-primary-600`,children:(0,K.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,K.jsx)(`div`,{className:`w-10 h-10 rounded-lg bg-white/20 flex items-center justify-center`,children:(0,K.jsx)(D,{className:`h-5 w-5 text-white`})}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`h3`,{className:`font-semibold text-white`,children:f(`personaForm.learning.title`)}),(0,K.jsx)(`p`,{className:`text-xs text-white/80`,children:f(`personaForm.learning.subtitle`)})]})]}),(0,K.jsx)($,{label:``,checked:e.mutation_settings?.enabled||!1,onChange:e=>u(`mutation_settings`,{enabled:e})})]})}),e.mutation_settings?.enabled&&(0,K.jsxs)(`div`,{className:`p-5 bg-white dark:bg-dark-100 space-y-5`,children:[(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`label`,{className:`block text-sm font-medium text-primary-700 dark:text-primary-300 mb-3`,children:f(`personaForm.learning.speed`)}),(0,K.jsx)(`div`,{className:`grid grid-cols-3 gap-3`,children:[{level:`low`,icon:j,label:f(`personaForm.learning.slow`),desc:f(`personaForm.learning.slowDesc`)},{level:`medium`,icon:D,label:f(`personaForm.learning.balanced`),desc:f(`personaForm.learning.balancedDesc`)},{level:`high`,icon:s,label:f(`personaForm.learning.fast`),desc:f(`personaForm.learning.fastDesc`)}].map(({level:t,icon:n,label:r,desc:a})=>(0,K.jsxs)(`button`,{type:`button`,onClick:()=>u(`mutation_settings`,{sensitivity:t}),className:i(`p-3 rounded-xl text-center transition-all border`,e.mutation_settings?.sensitivity===t?`bg-primary-600 border-primary-600 text-white shadow-lg`:`bg-primary-50 dark:bg-primary-900/20 border-primary-200 dark:border-primary-700/30 text-primary-700 dark:text-primary-300 hover:bg-primary-100 dark:hover:bg-primary-900/30`),children:[(0,K.jsx)(n,{className:`h-5 w-5 mx-auto mb-1`}),(0,K.jsx)(`p`,{className:`text-sm font-medium`,children:r}),(0,K.jsx)(`p`,{className:`text-[10px] opacity-70`,children:a})]},t))})]}),(0,K.jsx)($,{label:f(`personaForm.learning.autoAdapt`),checked:e.mutation_settings.auto_adapt,onChange:e=>u(`mutation_settings`,{auto_adapt:e}),colorClass:`text-primary-700 dark:text-primary-300`}),(0,K.jsxs)(`div`,{className:`p-4 bg-primary-50 dark:bg-primary-900/20 rounded-xl`,children:[(0,K.jsxs)(`p`,{className:`text-xs font-medium text-primary-700 dark:text-primary-300 mb-2 flex items-center gap-1.5`,children:[(0,K.jsx)(o,{className:`h-3.5 w-3.5`}),f(`personaForm.learning.whatLearns`)]}),(0,K.jsxs)(`div`,{className:`grid grid-cols-2 gap-2 text-xs text-primary-600 dark:text-primary-400`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,K.jsx)(`div`,{className:`w-1 h-1 rounded-full bg-primary-400`}),f(`personaForm.learning.conversationTone`)]}),(0,K.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,K.jsx)(`div`,{className:`w-1 h-1 rounded-full bg-primary-400`}),f(`personaForm.learning.responseStyle`)]}),(0,K.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,K.jsx)(`div`,{className:`w-1 h-1 rounded-full bg-primary-400`}),f(`personaForm.learning.userPreferences`)]}),(0,K.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,K.jsx)(`div`,{className:`w-1 h-1 rounded-full bg-primary-400`}),f(`personaForm.learning.topicInterests`)]})]})]})]}),!e.mutation_settings?.enabled&&(0,K.jsx)(`div`,{className:`p-5 bg-gray-50 dark:bg-dark-50`,children:(0,K.jsx)(`p`,{className:`text-sm text-gray-500 dark:text-gray-400 text-center`,children:f(`personaForm.learning.enableHint`)})})]})]})}function ie({parameters:e,onParameterChange:t}){let{t:n}=r(),i=(0,G.useMemo)(()=>[{key:`temperature`,label:n(`personaForm.parameters.temperature`),min:0,max:2,step:.1,hint:n(`personaForm.parameters.temperatureHint`),format:e=>e.toFixed(1)},{key:`top_p`,label:n(`personaForm.parameters.topP`),min:0,max:1,step:.1,hint:n(`personaForm.parameters.topPHint`),format:e=>e.toFixed(1)},{key:`top_k`,label:n(`personaForm.parameters.topK`),min:1,max:100,step:1,hint:n(`personaForm.parameters.topKHint`),format:e=>String(Math.round(e))},{key:`context_window`,label:n(`personaForm.parameters.contextWindow`),min:128,max:131072,step:128,hint:n(`personaForm.parameters.contextWindowHint`),format:e=>String(Math.round(e))},{key:`max_tokens`,label:n(`personaForm.parameters.maxTokens`),min:1,max:8192,step:1,hint:n(`personaForm.parameters.maxTokensHint`),format:e=>String(Math.round(e))},{key:`repeat_penalty`,label:n(`personaForm.parameters.repeatPenalty`),min:.5,max:2,step:.1,hint:n(`personaForm.parameters.repeatPenaltyHint`),format:e=>e.toFixed(1)}],[n]);return(0,K.jsx)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 gap-6`,children:i.map(({key:n,label:r,min:i,max:a,step:o,hint:s,format:c})=>(0,K.jsx)(Q,{label:r,value:e[n]||0,min:i,max:a,step:o,hint:s,format:c,onChange:e=>t(n,e)},n))})}var ae=N(`components:persona-form`),oe=({persona:e,onSubmit:t,onCancel:n})=>{let{preferences:c}=R(),{t:l}=r(),[u,f]=(0,G.useState)(Y),m=a(e=>e.models),h=a(e=>e.loadModels),g=(0,G.useMemo)(()=>m.filter(e=>!e.isPersona&&!e.isAgent&&!e.isUnavailable&&!e.isLegacySelection),[m]),[_,v]=(0,G.useState)([]),[y,b]=(0,G.useState)(!1),[x,S]=(0,G.useState)(!1),[w,T]=(0,G.useState)(!1),[E,D]=(0,G.useState)(null),[O,k]=(0,G.useState)(`basic`),[A,j]=(0,G.useState)(!1),M=(0,G.useRef)(!1),N=(0,G.useCallback)((e,t)=>{f(n=>({...n,[e]:t})),D(null)},[]),I=(0,G.useCallback)((e,t)=>{f(n=>({...n,parameters:{...n.parameters,[e]:t}})),D(null)},[]),L=(0,G.useCallback)((e,t)=>{f(n=>({...n,[e]:{...n[e],...t}})),D(null)},[]),z=(0,G.useCallback)(e=>{let t=e.reduce((e,t)=>(e.find(e=>e.id===t.id)||e.push(t),e),[]);return t.length>0?t:[{id:`nomic-embed-text`,name:`nomic-embed-text`,description:`Ollama - Default embedding model`,provider:`ollama`,dimensions:0,isDetectedEmbedding:!0}]},[]),B=e?.id,V=!!u.memory_settings?.enabled,U=H(),{data:q=null,isLoading:J}=W({queryKey:[`persona-memory-status`,B],queryFn:async()=>{if(!B)return null;let e=await F.getMemoryStatus(B);return e.success&&e.data?e.data:null},enabled:!!B&&V}),X=()=>U.invalidateQueries({queryKey:[`persona-memory-status`,B]}),Z=async()=>{if(e?.id&&confirm(l(`personaForm.memory.wipeConfirm`))){j(!0);try{let t=await F.wipeMemories(e.id);t.success?(p.success(l(`personaForm.memory.wipeSuccess`,{count:t.data?.deleted_count||0})),await X()):p.error(l(`personaForm.error.saveFailed`))}catch{p.error(l(`personaForm.error.saveFailed`))}finally{j(!1)}}};(0,G.useEffect)(()=>{M.current||(M.current=!0,(async()=>{b(!0);try{let[t,n]=await Promise.all([P.getModels(),e?Promise.resolve(null):F.getDefaultParameters(),a.getState().models.length===0?h({quiet:!0}):Promise.resolve()]),r=z(t.success&&t.data?t.data:[]);v(r);let i=r.find(e=>e.id===c.embeddingSettings?.model||e.rawModel===c.embeddingSettings?.model)?.id||r[0]?.id||``,o=r.find(t=>t.id===e?.embedding_model||t.rawModel===e?.embedding_model)?.id||e?.embedding_model||r[0]?.id||``;if(e)f({name:e.name,description:e.description||``,model:e.model,parameters:e.parameters,avatar:e.avatar||``,background:e.background||``,embedding_model:o,memory_settings:e.memory_settings||Y.memory_settings,mutation_settings:e.mutation_settings||Y.mutation_settings}),e.embedding_model&&!r.find(t=>t.id===e.embedding_model||t.rawModel===e.embedding_model)&&v(t=>z([...t,{id:e.embedding_model,name:e.embedding_model,description:`Previously selected model (not currently available)`,provider:`openai`,dimensions:0}]));else{let e=n?.success?n.data:{};f(t=>({...t,parameters:{...t.parameters,...e},embedding_model:i}))}}catch(e){ae.error(`Error loading data:`,e)}finally{b(!1)}})())},[e,z,h,c.embeddingSettings?.model]);let Q=async n=>{S(!0),T(n);try{let r={name:u.name,description:u.description,model:u.model,parameters:u.parameters,avatar:u.avatar,background:u.background,embedding_model:u.embedding_model,memory_settings:u.memory_settings,mutation_settings:u.mutation_settings},i=e?await F.updatePersona(e.id,r):await F.createPersona(u);i.success?(p.success(l(e?`personaForm.success.updated`:`personaForm.success.created`)),D(new Date),n&&t()):p.error(`${l(`personaForm.error.saveFailed`)}: ${i.error}`)}catch(e){p.error(`${l(`personaForm.error.saveFailed`)}: ${e instanceof Error?e.message:String(e)}`)}finally{S(!1),T(!1)}},$=(0,G.useMemo)(()=>[{id:`basic`,label:l(`personaForm.tabs.basic`),icon:C},{id:`parameters`,label:l(`personaForm.tabs.parameters`),icon:d},{id:`memory`,label:l(`personaForm.tabs.memory`),icon:s},{id:`advanced`,label:l(`personaForm.tabs.advanced`),icon:o}],[l]);return y?(0,K.jsx)(`div`,{className:`flex items-center justify-center p-8`,children:(0,K.jsxs)(`div`,{className:`animate-pulse flex items-center gap-3`,children:[(0,K.jsx)(`div`,{className:`w-5 h-5 border-2 border-primary-500 border-t-transparent rounded-full animate-spin`}),(0,K.jsx)(`span`,{className:`text-gray-600 dark:text-gray-400`,children:l(`personaForm.loading`)})]})}):(0,K.jsxs)(`div`,{className:`max-w-4xl mx-auto`,children:[(0,K.jsxs)(`div`,{className:`mb-6`,children:[(0,K.jsx)(`h1`,{className:`text-2xl font-bold text-gray-900 dark:text-dark-800`,children:l(e?`personaForm.title.edit`:`personaForm.title.create`)}),(0,K.jsxs)(`div`,{className:`flex items-center gap-4 mt-1`,children:[(0,K.jsx)(`p`,{className:`text-gray-600 dark:text-dark-600`,children:l(e?`personaForm.subtitle.edit`:`personaForm.subtitle.create`)}),E&&(0,K.jsxs)(`div`,{className:`flex items-center gap-2 text-sm text-green-600 dark:text-green-400`,children:[(0,K.jsx)(`div`,{className:`w-2 h-2 bg-green-500 rounded-full`}),l(`personaForm.saved`),` `,E.toLocaleTimeString()]})]})]}),(0,K.jsxs)(`form`,{onSubmit:e=>e.preventDefault(),className:`space-y-6`,children:[(0,K.jsxs)(`div`,{className:`bg-white dark:bg-dark-100 rounded-lg shadow-sm border border-gray-200 dark:border-dark-300`,children:[(0,K.jsx)(`div`,{className:`flex border-b border-gray-200 dark:border-dark-300`,children:$.map(e=>(0,K.jsxs)(`button`,{type:`button`,onClick:()=>k(e.id),className:i(`flex items-center gap-2 px-6 py-4 text-sm font-medium transition-colors`,O===e.id?`border-b-2 border-primary-500 text-primary-600 dark:text-primary-400 bg-primary-50 dark:bg-primary-900/20`:`text-gray-500 dark:text-dark-600 hover:text-gray-700 dark:hover:text-dark-800`),children:[(0,K.jsx)(e.icon,{className:`h-4 w-4`}),e.label]},e.id))}),(0,K.jsxs)(`div`,{className:`p-6`,children:[O===`basic`&&(0,K.jsx)(te,{formData:u,availableModels:g,onFieldChange:N,onParameterChange:I}),O===`parameters`&&(0,K.jsx)(ie,{parameters:u.parameters,onParameterChange:I}),O===`memory`&&(0,K.jsx)(re,{formData:u,persona:e,memoryStatus:q,loadingMemoryStatus:J,wipingMemories:A,onSettingsChange:L,onWipeMemories:Z}),O===`advanced`&&(0,K.jsx)(ee,{embeddingModel:u.embedding_model,embeddingModels:_,onEmbeddingModelChange:e=>N(`embedding_model`,e)})]})]}),(0,K.jsx)(ne,{persona:e,submitting:x,saveAndClose:w,lastSaved:E,onCancel:n,onSave:()=>Q(!1),onSaveAndClose:()=>Q(!0)})]})]})},se=N(`components:persona-import-export`),ce=({personas:e,onImport:t,onClose:n})=>{let{t:i}=r(),[a,o]=(0,G.useState)(!1),[s,c]=(0,G.useState)(``),l=async e=>{try{let t=await F.exportPersona(e.id),n=new Blob([JSON.stringify(t,null,2)],{type:`application/json`}),r=URL.createObjectURL(n),a=document.createElement(`a`);a.href=r,a.download=`${e.name}.json`,document.body.appendChild(a),a.click(),document.body.removeChild(a),URL.revokeObjectURL(r),p.success(i(`personaImportExport.exportSuccess`,{name:e.name}))}catch(e){let t=e instanceof Error?e.message:String(e);p.error(i(`personaImportExport.exportFailed`)+`: `+t)}};return(0,K.jsxs)(`div`,{className:`max-w-4xl mx-auto`,children:[(0,K.jsxs)(`div`,{className:`mb-6`,children:[(0,K.jsx)(`h1`,{className:`text-2xl font-bold text-gray-900 dark:text-dark-800`,children:i(`personaImportExport.title`)}),(0,K.jsx)(`p`,{className:`text-gray-600 dark:text-dark-600 mt-1`,children:i(`personaImportExport.description`)})]}),(0,K.jsxs)(`div`,{className:`grid grid-cols-1 lg:grid-cols-2 gap-6`,children:[(0,K.jsxs)(`div`,{className:`bg-white dark:bg-dark-100 rounded-lg p-6 shadow-sm border border-gray-200 dark:border-dark-300`,children:[(0,K.jsx)(`h3`,{className:`text-lg font-semibold text-gray-900 dark:text-dark-800 mb-4`,children:i(`personaImportExport.exportPersonas`)}),e.length===0?(0,K.jsx)(`p`,{className:`text-gray-600 dark:text-dark-600 text-center py-8`,children:i(`personaImportExport.noPersonasToExport`)}):(0,K.jsxs)(`div`,{className:`space-y-4`,children:[(0,K.jsxs)(`div`,{className:`flex justify-between items-center`,children:[(0,K.jsx)(`span`,{className:`text-sm text-gray-600 dark:text-dark-600`,children:i(`personaImportExport.personasAvailable`,{count:e.length})}),(0,K.jsx)(z,{onClick:async()=>{try{let t=e.map(e=>F.exportPersona(e.id)),n=await Promise.all(t),r={personas:n,exportedAt:Date.now(),version:`1.0.0`,count:n.length},a=new Blob([JSON.stringify(r,null,2)],{type:`application/json`}),o=URL.createObjectURL(a),s=document.createElement(`a`);s.href=o,s.download=`personas-export-${new Date().toISOString().split(`T`)[0]}.json`,document.body.appendChild(s),s.click(),document.body.removeChild(s),URL.revokeObjectURL(o),p.success(i(`personaImportExport.exportAllSuccess`,{count:e.length}))}catch(e){let t=e instanceof Error?e.message:String(e);p.error(i(`personaImportExport.exportAllFailed`)+`: `+t)}},variant:`outline`,size:`sm`,className:`px-3 py-1`,children:i(`personaImportExport.exportAll`)})]}),(0,K.jsx)(`div`,{className:`space-y-2 max-h-80 overflow-y-auto`,children:e.map(e=>(0,K.jsxs)(`div`,{className:`flex items-center justify-between p-3 bg-gray-50 dark:bg-dark-200 rounded-md`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,K.jsx)(`img`,{src:I(e,32),alt:e.name,className:`w-8 h-8 rounded-full`,onError:t=>L(t.currentTarget,e.name,32)}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`div`,{className:`font-medium text-gray-900 dark:text-dark-800`,children:e.name}),(0,K.jsx)(`div`,{className:`text-sm text-gray-500 dark:text-dark-500`,children:e.model})]})]}),(0,K.jsx)(z,{onClick:()=>l(e),variant:`outline`,size:`sm`,className:`px-3 py-1`,children:i(`common.export`)})]},e.id))})]})]}),(0,K.jsxs)(`div`,{className:`bg-white dark:bg-dark-100 rounded-lg p-6 shadow-sm border border-gray-200 dark:border-dark-300`,children:[(0,K.jsx)(`h3`,{className:`text-lg font-semibold text-gray-900 dark:text-dark-800 mb-4`,children:i(`personaImportExport.importPersonas`)}),(0,K.jsxs)(`div`,{className:`space-y-4`,children:[(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`label`,{className:`block text-sm font-medium text-gray-700 dark:text-dark-700 mb-2`,children:i(`personaImportExport.uploadJsonFile`)}),(0,K.jsx)(`input`,{type:`file`,accept:`.json`,onChange:e=>{let t=e.target.files?.[0];if(t){let e=new FileReader;e.onload=e=>{let t=e.target?.result;typeof t==`string`&&c(t)},e.readAsText(t)}},className:`w-full px-3 py-2 border border-gray-300 dark:border-dark-300 rounded-md bg-white dark:bg-dark-50 text-gray-900 dark:text-dark-700`})]}),(0,K.jsx)(`div`,{className:`text-center text-gray-500 dark:text-dark-500`,children:i(`common.or`).toUpperCase()}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`label`,{className:`block text-sm font-medium text-gray-700 dark:text-dark-700 mb-2`,children:i(`personaImportExport.pasteJsonLabel`)}),(0,K.jsx)(`textarea`,{value:s,onChange:e=>c(e.target.value),className:`w-full px-3 py-2 border border-gray-300 dark:border-dark-300 rounded-md bg-white dark:bg-dark-50 text-gray-900 dark:text-dark-700`,rows:8,placeholder:i(`personaImportExport.pasteJsonPlaceholder`)})]}),(0,K.jsx)(z,{onClick:async()=>{if(!s.trim()){p.error(i(`personaImportExport.pasteJsonData`));return}o(!0);try{let e=JSON.parse(s);if(e.personas&&Array.isArray(e.personas)){let t=0,n=0;for(let r of e.personas)try{await F.importPersona(r),t++}catch(e){n++,se.error(`Failed to import persona:`,e)}t>0?(p.success(i(`personaImportExport.importMultipleSuccess`,{count:t})),n>0&&p.error(i(`personaImportExport.importMultipleFailed`,{count:n}))):p.error(i(`personaImportExport.importNoneFailed`))}else await F.importPersona(e),p.success(i(`personaImportExport.importSuccess`));c(``),t()}catch(e){let t=e instanceof Error?e.message:String(e);p.error(i(`personaImportExport.importFailed`)+`: `+t)}finally{o(!1)}},disabled:!s.trim()||a,className:`w-full`,children:i(a?`personaImportExport.importing`:`personaImportExport.importButton`)})]})]})]}),(0,K.jsxs)(`div`,{className:`mt-6 bg-gray-50 dark:bg-dark-200 rounded-lg p-4`,children:[(0,K.jsx)(`h4`,{className:`text-sm font-medium text-gray-900 dark:text-dark-800 mb-2`,children:i(`personaImportExport.expectedFormat`)}),(0,K.jsx)(`pre`,{className:`text-xs text-gray-600 dark:text-dark-600 overflow-x-auto`,children:`{
|
|
2
|
-
"name": "Assistant Name",
|
|
3
|
-
"description": "Brief description of the assistant's personality",
|
|
4
|
-
"model": "model-name:version",
|
|
5
|
-
"params": {
|
|
6
|
-
"temperature": 0.8,
|
|
7
|
-
"top_p": 0.9,
|
|
8
|
-
"context_window": 4096,
|
|
9
|
-
"system_prompt": "You are a helpful assistant with specific traits..."
|
|
10
|
-
},
|
|
11
|
-
"avatar": "/path/to/avatar.png",
|
|
12
|
-
"background": "/path/to/background.png"
|
|
13
|
-
}`})]}),(0,K.jsx)(`div`,{className:`mt-6 flex justify-end`,children:(0,K.jsx)(z,{onClick:n,variant:`outline`,children:i(`common.close`)})})]})},le=()=>{let{t:e}=r(),t=H(),[n,i]=(0,G.useState)(!1),[a,o]=(0,G.useState)(null),[s,c]=(0,G.useState)(!1),{data:l=[],isLoading:u,refetch:d}=W({queryKey:[`personas`],queryFn:async()=>{let e=await F.getPersonas();if(!e.success)throw Error(e.error||`Failed to load personas`);return e.data||[]}}),f=async()=>{await t.invalidateQueries({queryKey:[`personas`]}),await d()},m=()=>{o(null),i(!0)},h=e=>{o(e),i(!0)},g=async t=>{if(confirm(e(`personaManager.deleteConfirm`,{name:t.name})))try{let n=await F.deletePersona(t.id);n.success?(p.success(e(`personaManager.deleteSuccess`,{name:t.name})),await f()):p.error(e(`personaManager.failed`,{action:`delete`})+`: `+n.error)}catch(t){let n=t instanceof Error?t.message:String(t);p.error(e(`personaManager.failed`,{action:`delete`})+`: `+n)}},_=async t=>{try{await F.downloadPersona(t.id,t.name),p.success(e(`personaManager.downloadSuccess`,{name:t.name}))}catch(t){let n=t instanceof Error?t.message:String(t);p.error(e(`personaManager.failed`,{action:`download`})+`: `+n)}};return u?(0,K.jsx)(`div`,{className:`flex items-center justify-center p-8`,children:(0,K.jsx)(`div`,{className:`text-gray-600 dark:text-dark-600`,children:e(`personaManager.loading`)})}):n?(0,K.jsx)(oe,{persona:a,onSubmit:async()=>{i(!1),o(null),await f()},onCancel:()=>{i(!1),o(null)}}):s?(0,K.jsx)(ce,{personas:l,onImport:f,onClose:()=>c(!1)}):(0,K.jsxs)(`div`,{className:`space-y-6`,children:[(0,K.jsxs)(`div`,{className:`flex flex-col gap-4 sm:flex-row sm:items-center sm:justify-between`,children:[(0,K.jsxs)(`div`,{className:`text-sm text-gray-500 dark:text-dark-500`,children:[(0,K.jsx)(`span`,{className:`font-medium text-gray-900 dark:text-dark-800`,children:e(`personaManager.stats.title`)}),` `,`· `,e(`personaManager.stats.count`,{count:l.length})]}),(0,K.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,K.jsx)(z,{onClick:()=>c(!0),variant:`outline`,className:`px-4`,children:e(`personaManager.importExport`)}),(0,K.jsx)(z,{onClick:m,className:`px-4`,children:e(`personaManager.createButton`)})]})]}),l.length===0?(0,K.jsxs)(`div`,{className:`rounded-2xl border border-dashed border-gray-300 bg-white/40 p-12 text-center dark:border-white/15 dark:bg-white/[0.025]`,children:[(0,K.jsx)(`div`,{className:`text-gray-400 dark:text-dark-500 mb-4`,children:(0,K.jsx)(`svg`,{className:`w-16 h-16 mx-auto`,fill:`none`,stroke:`currentColor`,viewBox:`0 0 24 24`,xmlns:`http://www.w3.org/2000/svg`,children:(0,K.jsx)(`path`,{strokeLinecap:`round`,strokeLinejoin:`round`,strokeWidth:2,d:`M16 7a4 4 0 11-8 0 4 4 0 018 0zM12 14a7 7 0 00-7 7h14a7 7 0 00-7-7z`})})}),(0,K.jsx)(`h3`,{className:`text-lg font-semibold text-gray-900 dark:text-dark-800 mb-2`,children:e(`personaManager.empty.title`)}),(0,K.jsx)(`p`,{className:`text-gray-600 dark:text-dark-600 mb-6`,children:e(`personaManager.empty.description`)}),(0,K.jsx)(z,{onClick:m,className:`px-6 py-2`,children:e(`personaManager.empty.button`)})]}):(0,K.jsx)(`div`,{className:`grid grid-cols-1 gap-4 md:grid-cols-2 lg:grid-cols-3`,children:l.map(e=>(0,K.jsx)(J,{persona:e,onEdit:h,onDelete:g,onDownload:_},e.id))})]})},ue=()=>{let{t:e}=r();return(0,K.jsxs)(B,{children:[(0,K.jsx)(V,{title:e(`personaManager.title`),description:e(`personaManager.subtitle`)}),(0,K.jsx)(le,{})]})};export{ue as PersonasPage,ue as default};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{r as e}from"./rolldown-runtime-hePW80VL.js";import{m as t,p as n}from"./markdown-core-BmPPZiuD.js";import{t as r}from"./useTranslation-Bho4HCyg.js";import{t as i}from"./utils-D9W1Lnkn.js";import{Dn as a,Fn as o,Pt as s,V as c,an as l,cn as u,m as d,mt as f,s as p}from"./ui-vendor-B1UgO3vd.js";import{u as m}from"./api-BDtqBtqw.js";import{t as h}from"./Button-BPf_pOxH.js";import{n as g,t as _}from"./ui-CC-K19wO.js";import{x as v}from"../assets/index-6o-Hc2wS.js";var y=e(t(),1),b=n(),x=new Intl.NumberFormat(void 0,{maximumFractionDigits:0}),S=new Intl.NumberFormat(void 0,{notation:`compact`,maximumFractionDigits:1}),C=e=>e>=1e4?S.format(e):x.format(e),w=e=>e?e<1e3?`${x.format(e)} ms`:`${(e/1e3).toFixed(+(e<1e4))} s`:`—`,T=(e,t)=>e===0?0:(e-t)/e*100,E=({analytics:e,metric:t,onMetricChange:n})=>{let{t:a}=r(),o={top:22,right:18,bottom:42,left:52},s=e.series.map(e=>e[t]),c=Math.max(1,...s),l=960-o.left-o.right,u=280-o.top-o.bottom,d=t=>o.left+(e.series.length<=1?l/2:t/(e.series.length-1)*l),f=e=>o.top+u-e/c*u,p=e.series.map((e,n)=>({x:d(n),y:f(e[t]),point:e})),m=p.map(({x:e,y:t},n)=>`${n===0?`M`:`L`} ${e} ${t}`).join(` `),h=p.length?`${m} L ${p[p.length-1].x} ${o.top+u} L ${p[0].x} ${o.top+u} Z`:``,g=new Intl.DateTimeFormat(void 0,{month:`short`,day:`numeric`,timeZone:`UTC`}),_=Array.from(new Set([0,Math.floor((e.series.length-1)/2),e.series.length-1])).filter(e=>e>=0);return(0,b.jsxs)(`div`,{"data-testid":`plugin-usage-chart`,className:`overflow-hidden rounded-2xl border border-gray-200/80 bg-white/80 shadow-subtle backdrop-blur-md dark:border-white/[0.08] dark:bg-dark-100/75`,children:[(0,b.jsxs)(`div`,{className:`flex flex-col gap-3 border-b border-gray-200/70 px-4 py-3 dark:border-white/[0.07] sm:flex-row sm:items-center sm:justify-between sm:px-5`,children:[(0,b.jsxs)(`div`,{children:[(0,b.jsx)(`h2`,{className:`text-sm font-medium text-gray-950 dark:text-dark-950`,children:a(`usageAnalytics.activity.title`)}),(0,b.jsx)(`p`,{className:`mt-1 text-xs text-gray-500 dark:text-dark-500`,children:a(t===`calls`?`usageAnalytics.activity.callsDescription`:`usageAnalytics.activity.tokensDescription`)})]}),(0,b.jsx)(`div`,{className:`inline-flex w-fit rounded-xl bg-gray-100 p-1 dark:bg-dark-200/80`,children:[`calls`,`tokens`].map(e=>(0,b.jsx)(`button`,{type:`button`,"aria-pressed":t===e,className:i(`rounded-lg px-3 py-1.5 text-xs font-medium transition-colors`,t===e?`bg-white text-gray-950 shadow-sm dark:bg-dark-300 dark:text-dark-950`:`text-gray-500 hover:text-gray-800 dark:text-dark-500 dark:hover:text-dark-800`),onClick:()=>n(e),children:a(`usageAnalytics.metrics.${e}`)},e))})]}),(0,b.jsx)(`div`,{className:`px-2 pb-3 pt-4 sm:px-5 sm:pt-6`,children:(0,b.jsxs)(`svg`,{viewBox:`0 0 960 280`,className:`h-auto w-full overflow-visible`,role:`img`,"aria-label":a(`usageAnalytics.activity.chartLabel`,{metric:a(`usageAnalytics.metrics.${t}`)}),children:[(0,b.jsx)(`defs`,{children:(0,b.jsxs)(`linearGradient`,{id:`plugin-usage-area`,x1:`0`,y1:`0`,x2:`0`,y2:`1`,children:[(0,b.jsx)(`stop`,{offset:`0%`,stopColor:`rgb(var(--color-primary-500))`,stopOpacity:`0.28`}),(0,b.jsx)(`stop`,{offset:`100%`,stopColor:`rgb(var(--color-primary-500))`,stopOpacity:`0.015`})]})}),[0,.25,.5,.75,1].map(e=>{let t=o.top+u*e,n=Math.round(c*(1-e));return(0,b.jsxs)(`g`,{children:[(0,b.jsx)(`line`,{x1:o.left,x2:960-o.right,y1:t,y2:t,className:`stroke-gray-200 dark:stroke-white/[0.07]`,strokeDasharray:e===1?void 0:`4 8`}),(0,b.jsx)(`text`,{x:o.left-12,y:t+4,textAnchor:`end`,className:`fill-gray-400 text-[11px] dark:fill-dark-500`,children:C(n)})]},e)}),h&&(0,b.jsx)(`path`,{d:h,fill:`url(#plugin-usage-area)`}),m&&(0,b.jsx)(`path`,{d:m,fill:`none`,className:`stroke-primary-500 dark:stroke-primary-400`,strokeWidth:`3`,strokeLinecap:`round`,strokeLinejoin:`round`}),(e.series.length<=31?p:[]).map(({x:e,y:n,point:r})=>(0,b.jsx)(`circle`,{cx:e,cy:n,r:`4`,className:`fill-white stroke-primary-500 dark:fill-dark-100 dark:stroke-primary-400`,strokeWidth:`2.5`,children:(0,b.jsx)(`title`,{children:`${g.format(r.timestamp)}: ${C(r[t])} ${a(`usageAnalytics.metrics.${t}`).toLocaleLowerCase()}`})},r.timestamp)),_.map(t=>{let n=e.series[t];if(!n)return null;let r=t===0?`start`:t===e.series.length-1?`end`:`middle`;return(0,b.jsx)(`text`,{x:d(t),y:270,textAnchor:r,className:`fill-gray-500 text-[12px] dark:fill-dark-500`,children:g.format(n.timestamp)},n.timestamp)})]})})]})},D=864e5,O=10,k=12,A=30,j=16,M=[`fill-blue-500`,`fill-emerald-500 dark:fill-emerald-600`,`fill-amber-500 dark:fill-amber-600`,`fill-violet-500`,`fill-rose-500`],N=[`bg-blue-500`,`bg-emerald-500 dark:bg-emerald-600`,`bg-amber-500 dark:bg-amber-600`,`bg-violet-500`,`bg-rose-500`],P=`fill-gray-400 dark:fill-gray-500`,F=`bg-gray-400 dark:bg-gray-500`,I=`fill-gray-950/[0.06] dark:fill-white/[0.07]`,L=[0,.35,.55,.75,1],R=({heatmap:e})=>{let{t,i18n:n}=r(),[a,o]=(0,y.useState)(null),{weeks:s,firstColStart:c,cellsByDay:l,maxCalls:u,modelRank:d,totalCalls:f}=(0,y.useMemo)(()=>{let t=new Map(e.cells.map(e=>[e.timestamp,e])),n=e.from,r=e.from+(e.days-1)*D,i=n-new Date(n).getUTCDay()*D;return{weeks:Math.ceil((r-i+D)/(7*D)),firstColStart:i,cellsByDay:t,maxCalls:Math.max(1,...e.cells.map(e=>e.calls)),modelRank:new Map(e.models.map((e,t)=>[e,t])),totalCalls:e.cells.reduce((e,t)=>e+t.calls,0)}},[e]),p=new Intl.DateTimeFormat(n.language,{month:`short`,timeZone:`UTC`}),m=new Intl.DateTimeFormat(n.language,{weekday:`short`,timeZone:`UTC`}),h=new Intl.DateTimeFormat(n.language,{dateStyle:`medium`,timeZone:`UTC`}),g=e.from,_=e.from+(e.days-1)*D,v=A+s*k,x=[],S=-1;for(let e=0;e<s;e++){let t=c+e*7*D,n=Math.max(t,g),r=new Date(n).getUTCMonth();r!==S&&t>=g-6*D&&((S!==-1||t>=g)&&x.push({x:A+e*k,label:p.format(n)}),S=r)}let w=e=>e<=0?0:Math.min(4,Math.max(1,Math.ceil(e/u*4))),T=e=>{let t=e.models[0]?.model,n=t===void 0?void 0:d.get(t);return n===void 0?P:M[n]},E=(e,t,n)=>{let r=e.currentTarget.closest(`[data-heatmap-wrapper]`);if(!r)return;let i=r.getBoundingClientRect(),a=e.currentTarget.getBoundingClientRect(),s=a.left-i.left+a.width/2;o({x:Math.min(Math.max(s,96),Math.max(i.width-96,96)),y:a.top-i.top,timestamp:t,calls:n.calls,models:n.models})};return(0,b.jsxs)(`section`,{"data-testid":`usage-heatmap`,className:`overflow-hidden rounded-2xl border border-gray-200/80 bg-white/80 shadow-subtle backdrop-blur-md dark:border-white/[0.08] dark:bg-dark-100/75`,children:[(0,b.jsxs)(`div`,{className:`flex flex-col gap-1 border-b border-gray-200/70 px-4 py-3 dark:border-white/[0.07] sm:flex-row sm:items-center sm:justify-between sm:px-5`,children:[(0,b.jsxs)(`div`,{children:[(0,b.jsx)(`h2`,{className:`text-sm font-medium text-gray-950 dark:text-dark-950`,children:t(`usageAnalytics.heatmap.title`)}),(0,b.jsx)(`p`,{className:`mt-1 text-xs text-gray-500 dark:text-dark-500`,children:t(`usageAnalytics.heatmap.description`)})]}),(0,b.jsx)(`span`,{className:`shrink-0 text-xs tabular-nums text-gray-500 dark:text-dark-500`,children:t(`usageAnalytics.heatmap.yearTotal`,{count:f,formatted:C(f)})})]}),(0,b.jsxs)(`div`,{className:`relative p-4 sm:px-5`,"data-heatmap-wrapper":!0,children:[(0,b.jsx)(`div`,{className:`overflow-x-auto`,children:(0,b.jsxs)(`svg`,{viewBox:`0 0 ${v} 100`,className:`h-auto w-full min-w-[640px]`,role:`img`,"aria-label":t(`usageAnalytics.heatmap.title`),onMouseLeave:()=>o(null),children:[x.map(({x:e,label:t})=>(0,b.jsx)(`text`,{x:e,y:10,className:`fill-gray-400 text-[8px] dark:fill-dark-500`,children:t},`${e}-${t}`)),[1,3,5].map(e=>(0,b.jsx)(`text`,{x:0,y:j+e*k+O-2,className:`fill-gray-400 text-[8px] dark:fill-dark-500`,children:m.format(new Date(Date.UTC(2023,0,1+e)))},e)),Array.from({length:s},(e,t)=>Array.from({length:7},(e,n)=>{let r=c+(t*7+n)*D;if(r<g||r>_)return null;let o=l.get(r),s=o?.calls??0,u=w(s);return(0,b.jsx)(`rect`,{x:A+t*k,y:j+n*k,width:O,height:O,rx:2,fillOpacity:u===0?1:L[u],strokeWidth:+(a?.timestamp===r),className:i(`transition-opacity`,u===0||!o?I:T(o),a?.timestamp===r?`stroke-gray-500 dark:stroke-white/60`:`stroke-transparent`),onMouseEnter:e=>E(e,r,{calls:s,models:o?.models??[]}),children:(0,b.jsx)(`title`,{children:`${h.format(r)} — ${C(s)}`})},r)}))]})}),a&&(0,b.jsxs)(`div`,{className:`pointer-events-none absolute z-10 min-w-[10rem] -translate-x-1/2 -translate-y-full rounded-lg border border-gray-200/80 bg-white/95 px-3 py-2 shadow-card backdrop-blur-md dark:border-white/[0.1] dark:bg-dark-100/95`,style:{left:a.x,top:a.y-6},children:[(0,b.jsx)(`div`,{className:`text-[11px] font-medium text-gray-900 dark:text-dark-900`,children:h.format(a.timestamp)}),(0,b.jsx)(`div`,{className:`mt-0.5 text-[11px] text-gray-500 dark:text-dark-500`,children:a.calls===0?t(`usageAnalytics.heatmap.noCalls`):`${C(a.calls)} ${t(`usageAnalytics.heatmap.calls`)}`}),a.models.slice(0,3).map(e=>(0,b.jsxs)(`div`,{className:`mt-1 flex items-center justify-between gap-3 text-[11px]`,children:[(0,b.jsxs)(`span`,{className:`flex min-w-0 items-center gap-1.5`,children:[(0,b.jsx)(`span`,{className:i(`h-2 w-2 shrink-0 rounded-[3px]`,d.has(e.model)?N[d.get(e.model)]:F)}),(0,b.jsx)(`span`,{className:`truncate font-mono text-gray-700 dark:text-dark-700`,dir:`ltr`,children:e.model})]}),(0,b.jsx)(`span`,{className:`tabular-nums text-gray-500 dark:text-dark-500`,children:C(e.calls)})]},e.model))]}),(0,b.jsxs)(`div`,{className:`mt-3 flex flex-wrap items-center justify-between gap-3`,children:[(0,b.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-4 gap-y-1.5`,children:[e.models.map((e,t)=>(0,b.jsxs)(`span`,{className:`flex items-center gap-1.5 text-[11px] text-gray-600 dark:text-dark-600`,children:[(0,b.jsx)(`span`,{className:i(`h-2.5 w-2.5 rounded-[3px]`,N[t])}),(0,b.jsx)(`span`,{className:`font-mono`,dir:`ltr`,children:e})]},e)),(0,b.jsxs)(`span`,{className:`flex items-center gap-1.5 text-[11px] text-gray-600 dark:text-dark-600`,children:[(0,b.jsx)(`span`,{className:i(`h-2.5 w-2.5 rounded-[3px]`,F)}),t(`usageAnalytics.heatmap.other`)]})]}),(0,b.jsxs)(`div`,{className:`flex items-center gap-1.5 text-[11px] text-gray-500 dark:text-dark-500`,children:[t(`usageAnalytics.heatmap.less`),(0,b.jsx)(`span`,{className:`h-2.5 w-2.5 rounded-[3px] bg-gray-950/[0.06] dark:bg-white/[0.07]`}),L.slice(1).map(e=>(0,b.jsx)(`span`,{className:`h-2.5 w-2.5 rounded-[3px] bg-primary-500`,style:{opacity:e}},e)),t(`usageAnalytics.heatmap.more`)]})]})]})]})},z=()=>{let{t:e}=r(),[t,n]=(0,y.useState)(30),[x,S]=(0,y.useState)(`calls`),{data:D,error:O,isLoading:k,isFetching:A,refetch:j}=v({queryKey:[`plugin-usage`,t],queryFn:async()=>{let n=await m.getUsage(t);if(!n.success||!n.data)throw Error(n.error||e(`usageAnalytics.loadFailed`));return n.data}}),M=O?O instanceof Error?O.message:e(`usageAnalytics.loadFailed`):null,N=D?.totals,P=(0,y.useMemo)(()=>[{label:e(`usageAnalytics.cards.calls`),value:C(N?.calls??0),detail:e(`usageAnalytics.cards.callsDetail`,{count:N?.uniqueUsers??0}),icon:o},{label:e(`usageAnalytics.cards.tokens`),value:C(N?.reportedTokens??0),detail:e(`usageAnalytics.cards.tokensDetail`,{count:N?.meteredCalls??0}),icon:s},{label:e(`usageAnalytics.cards.success`),value:`${T(N?.calls??0,(N?.failedCalls??0)+(N?.cancelledCalls??0)).toFixed(1)}%`,detail:e(`usageAnalytics.cards.successDetail`,{count:N?.failedCalls??0}),icon:u},{label:e(`usageAnalytics.cards.latency`),value:w(N?.averageLatencyMs??0),detail:e(`usageAnalytics.cards.latencyDetail`),icon:l}],[e,N]);return k&&!D?(0,b.jsx)(g,{width:`wide`,children:(0,b.jsx)(`div`,{className:`flex min-h-[50vh] items-center justify-center`,children:(0,b.jsx)(f,{className:`h-7 w-7 animate-spin text-primary-500`})})}):(0,b.jsxs)(g,{width:`wide`,children:[(0,b.jsx)(_,{eyebrow:e(`usageAnalytics.eyebrow`),title:e(`usageAnalytics.title`),description:e(`usageAnalytics.description`),actions:(0,b.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,b.jsx)(`div`,{className:`inline-flex rounded-xl border border-gray-200 bg-white/70 p-1 dark:border-white/[0.08] dark:bg-dark-100/70`,children:[7,30,90].map(r=>(0,b.jsx)(`button`,{type:`button`,className:i(`rounded-lg px-3 py-1.5 text-xs font-medium transition-colors`,t===r?`bg-gray-950 text-white dark:bg-white dark:text-gray-950`:`text-gray-500 hover:text-gray-900 dark:text-dark-500 dark:hover:text-dark-900`),onClick:()=>n(r),children:e(`usageAnalytics.days`,{count:r})},r))}),(0,b.jsxs)(h,{variant:`outline`,size:`sm`,onClick:()=>void j(),disabled:A,children:[(0,b.jsx)(c,{className:i(`h-4 w-4`,A&&`animate-spin`)}),(0,b.jsx)(`span`,{className:`sr-only`,children:e(`usageAnalytics.refresh`)})]})]})}),M&&(0,b.jsxs)(`div`,{className:`mb-6 flex items-center gap-3 rounded-2xl border border-red-200 bg-red-50 px-4 py-3 text-sm text-red-700 dark:border-red-900/40 dark:bg-red-950/30 dark:text-red-300`,children:[(0,b.jsx)(d,{className:`h-4 w-4 shrink-0`}),(0,b.jsx)(`span`,{children:M})]}),D&&(0,b.jsxs)(`div`,{className:`space-y-4`,children:[(0,b.jsx)(`div`,{className:`grid gap-3 sm:grid-cols-2 xl:grid-cols-4`,children:P.map(e=>{let t=e.icon;return(0,b.jsxs)(`section`,{className:`rounded-2xl border border-gray-200/80 bg-white/75 p-4 shadow-subtle backdrop-blur-md dark:border-white/[0.08] dark:bg-dark-100/70`,children:[(0,b.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,b.jsx)(`span`,{className:`text-xs font-medium uppercase tracking-[0.12em] text-gray-500 dark:text-dark-500`,children:e.label}),(0,b.jsx)(t,{className:`h-4 w-4 text-primary-500 dark:text-primary-400`})]}),(0,b.jsx)(`div`,{className:`mt-2 text-2xl font-normal tracking-[-0.04em] text-gray-950 dark:text-dark-950`,children:e.value}),(0,b.jsx)(`p`,{className:`mt-1.5 text-xs text-gray-500 dark:text-dark-500`,children:e.detail})]},e.label)})}),D.heatmap&&D.heatmap.cells.length>0&&(0,b.jsx)(R,{heatmap:D.heatmap}),(0,b.jsx)(E,{analytics:D,metric:x,onMetricChange:S}),D.totals.calls===0?(0,b.jsxs)(`div`,{className:`rounded-2xl border border-dashed border-gray-300 px-6 py-10 text-center dark:border-white/[0.12]`,children:[(0,b.jsx)(a,{className:`mx-auto h-8 w-8 text-gray-400 dark:text-dark-500`}),(0,b.jsx)(`h2`,{className:`mt-4 text-base font-medium text-gray-900 dark:text-dark-900`,children:e(`usageAnalytics.empty.title`)}),(0,b.jsx)(`p`,{className:`mx-auto mt-2 max-w-md text-sm leading-6 text-gray-500 dark:text-dark-500`,children:e(`usageAnalytics.empty.description`)})]}):(0,b.jsxs)(`div`,{className:`grid gap-4 xl:grid-cols-[1.15fr_0.85fr]`,children:[(0,b.jsxs)(`section`,{className:`overflow-hidden rounded-2xl border border-gray-200/80 bg-white/80 shadow-subtle backdrop-blur-md dark:border-white/[0.08] dark:bg-dark-100/75`,children:[(0,b.jsxs)(`div`,{className:`border-b border-gray-200/70 px-4 py-3 dark:border-white/[0.07] sm:px-5`,children:[(0,b.jsx)(`h2`,{className:`text-sm font-medium text-gray-950 dark:text-dark-950`,children:e(`usageAnalytics.models.title`)}),(0,b.jsx)(`p`,{className:`mt-1 text-xs text-gray-500 dark:text-dark-500`,children:e(`usageAnalytics.models.description`)})]}),(0,b.jsx)(`div`,{className:`overflow-x-auto`,children:(0,b.jsxs)(`table`,{className:`w-full min-w-[620px] text-start text-sm`,children:[(0,b.jsx)(`thead`,{className:`text-[11px] uppercase tracking-[0.1em] text-gray-400 dark:text-dark-500`,children:(0,b.jsxs)(`tr`,{children:[(0,b.jsx)(`th`,{className:`px-5 py-2 text-start font-medium`,children:e(`usageAnalytics.models.model`)}),(0,b.jsx)(`th`,{className:`px-4 py-2 text-end font-medium`,children:e(`usageAnalytics.metrics.calls`)}),(0,b.jsx)(`th`,{className:`px-4 py-2 text-end font-medium`,children:e(`usageAnalytics.metrics.tokens`)}),(0,b.jsx)(`th`,{className:`px-4 py-2 text-end font-medium`,children:e(`usageAnalytics.models.success`)}),(0,b.jsx)(`th`,{className:`px-5 py-2 text-end font-medium`,children:e(`usageAnalytics.models.latency`)})]})}),(0,b.jsx)(`tbody`,{className:`divide-y divide-gray-100 dark:divide-white/[0.06]`,children:D.models.slice(0,12).map(e=>(0,b.jsxs)(`tr`,{children:[(0,b.jsxs)(`td`,{className:`px-5 py-2.5`,children:[(0,b.jsx)(`div`,{className:`max-w-[260px] truncate font-medium text-gray-900 dark:text-dark-900`,title:e.model,children:e.model}),(0,b.jsx)(`div`,{className:`mt-0.5 text-xs text-gray-500 dark:text-dark-500`,children:e.pluginName})]}),(0,b.jsx)(`td`,{className:`px-4 py-2.5 text-end tabular-nums text-gray-700 dark:text-dark-700`,children:C(e.calls)}),(0,b.jsx)(`td`,{className:`px-4 py-2.5 text-end tabular-nums text-gray-700 dark:text-dark-700`,children:e.tokens?C(e.tokens):`—`}),(0,b.jsxs)(`td`,{className:`px-4 py-2.5 text-end tabular-nums text-gray-700 dark:text-dark-700`,children:[T(e.calls,e.errors).toFixed(1),`%`]}),(0,b.jsx)(`td`,{className:`px-5 py-2.5 text-end tabular-nums text-gray-500 dark:text-dark-500`,children:w(e.averageLatencyMs)})]},`${e.pluginId}:${e.model}`))})]})})]}),(0,b.jsxs)(`div`,{className:`space-y-4`,children:[(0,b.jsxs)(`section`,{className:`rounded-2xl border border-gray-200/80 bg-white/80 p-4 shadow-subtle backdrop-blur-md dark:border-white/[0.08] dark:bg-dark-100/75 sm:p-5`,children:[(0,b.jsx)(`h2`,{className:`text-sm font-medium text-gray-950 dark:text-dark-950`,children:e(`usageAnalytics.providers.title`)}),(0,b.jsx)(`div`,{className:`mt-5 space-y-4`,children:D.plugins.slice(0,8).map(t=>{let n=D.totals.calls?t.calls/D.totals.calls*100:0;return(0,b.jsxs)(`div`,{children:[(0,b.jsxs)(`div`,{className:`flex items-center justify-between gap-4 text-sm`,children:[(0,b.jsxs)(`div`,{className:`min-w-0`,children:[(0,b.jsx)(`div`,{className:`truncate font-medium text-gray-900 dark:text-dark-900`,children:t.pluginName}),(0,b.jsxs)(`div`,{className:`mt-0.5 text-xs text-gray-500 dark:text-dark-500`,children:[C(t.tokens),` `,e(`usageAnalytics.metrics.tokens`).toLocaleLowerCase()]})]}),(0,b.jsx)(`span`,{className:`shrink-0 tabular-nums text-gray-600 dark:text-dark-600`,children:C(t.calls)})]}),(0,b.jsx)(`div`,{className:`mt-2 h-1.5 overflow-hidden rounded-full bg-gray-100 dark:bg-dark-300`,children:(0,b.jsx)(`div`,{className:`h-full rounded-full bg-primary-500 dark:bg-primary-400`,style:{width:`${Math.max(2,n)}%`}})})]},t.pluginId)})})]}),(0,b.jsxs)(`section`,{className:`rounded-2xl border border-gray-200/80 bg-white/80 p-4 shadow-subtle backdrop-blur-md dark:border-white/[0.08] dark:bg-dark-100/75 sm:p-5`,children:[(0,b.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,b.jsx)(p,{className:`h-4 w-4 text-primary-500 dark:text-primary-400`}),(0,b.jsx)(`h2`,{className:`text-sm font-medium text-gray-950 dark:text-dark-950`,children:e(`usageAnalytics.capabilities.title`)})]}),(0,b.jsx)(`div`,{className:`mt-5 grid grid-cols-2 gap-3`,children:D.capabilities.map(t=>(0,b.jsxs)(`div`,{className:`rounded-xl bg-gray-50 px-3 py-2.5 dark:bg-dark-200/70`,children:[(0,b.jsx)(`div`,{className:`text-xs font-medium capitalize text-gray-500 dark:text-dark-500`,children:t.capability}),(0,b.jsx)(`div`,{className:`mt-1 text-xl text-gray-950 dark:text-dark-950`,children:C(t.calls)}),(0,b.jsx)(`div`,{className:`mt-1 text-[11px] text-gray-500 dark:text-dark-500`,children:t.capability===`tts`?e(`usageAnalytics.capabilities.characters`,{count:C(t.inputUnits)}):t.capability===`stt`?e(`usageAnalytics.capabilities.bytes`,{count:C(t.inputUnits)}):t.capability===`image`?e(`usageAnalytics.capabilities.images`,{count:C(t.outputUnits)}):t.capability===`video`?e(`usageAnalytics.capabilities.jobs`,{count:C(t.calls)}):t.capability===`embedding`?e(`usageAnalytics.capabilities.inputs`,{count:C(t.inputUnits)}):e(`usageAnalytics.capabilities.reportedTokens`,{count:C(t.tokens)})})]},t.capability))})]})]})]}),(0,b.jsx)(`p`,{className:`px-1 text-xs leading-5 text-gray-500 dark:text-dark-500`,children:e(`usageAnalytics.privacyNote`)})]})]})};export{z as default};
|
|
@@ -1,3 +0,0 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["js/OptimizedSyntaxHighlighter-Dz7D1LPB.js","js/rolldown-runtime-hePW80VL.js","js/markdown-core-BmPPZiuD.js","js/syntax-highlight-3EEX6CGL.js"])))=>i.map(i=>d[i]);
|
|
2
|
-
import{n as e,r as t}from"./rolldown-runtime-hePW80VL.js";import{m as n,o as r,p as i,r as a}from"./markdown-core-BmPPZiuD.js";import{i as o}from"./router-vendor-DGFGM3EP.js";import{t as s}from"./utils-D9W1Lnkn.js";import{t as c}from"./appStore-0JnCUlEq.js";import{a as l,i as u,n as d,r as f,s as p,t as m}from"./messageCodeStyles-BFNR9Wv6.js";import{n as h,t as g}from"./markdown-math-DK846gXU.js";var _=e({RichMessageContent:()=>S,default:()=>S}),v=t(n(),1),y=i(),b=v.lazy(()=>o(()=>import(`./OptimizedSyntaxHighlighter-Dz7D1LPB.js`).then(e=>e.n),__vite__mapDeps([0,1,2,3])));function x({children:e,className:t}){return(0,y.jsx)(`pre`,{dir:`ltr`,className:s(f,`rounded-lg`,t),children:(0,y.jsx)(`code`,{children:e})})}var S=({content:e,className:t})=>{let n=c(e=>e.theme.mode===`dark`),i=v.useMemo(()=>p(e),[e]);return(0,y.jsx)(`div`,{dir:`auto`,className:s(`prose prose-sm max-w-none dark:prose-invert prose-gray`,`[&_.katex-display]:overflow-x-auto [&_.katex-display]:overflow-y-hidden [&_.katex-display]:py-2`,`[&_.katex]:text-inherit`,t),children:(0,y.jsx)(r,{remarkPlugins:[a,h],rehypePlugins:[g],components:{code({className:e,children:t,node:r,...i}){let a=/language-([^\s]+)/.exec(e||``),o=String(t),c=o.replace(/\n$/,``),f=a?a[1]:null;return f||o.includes(`
|
|
3
|
-
`)?(0,y.jsx)(l,{code:c,language:f,state:`complete`,children:(0,y.jsx)(`div`,{className:`overflow-x-auto`,children:(0,y.jsx)(v.Suspense,{fallback:(0,y.jsx)(x,{className:`!m-0 !rounded-none !border-none`,children:c}),children:(0,y.jsx)(b,{language:f||`text`,isDark:n,backgroundColor:n?m:d,borderRadius:0,customStyle:u,className:`!m-0 !rounded-none !border-none`,showLineNumbers:!0,children:c})})})}):(0,y.jsx)(`code`,{dir:`ltr`,className:s(`px-1.5 py-0.5 rounded-md bg-gray-100 dark:bg-dark-200 text-gray-800 dark:text-dark-800`,`font-mono text-[0.85em] border border-gray-200 dark:border-dark-300`,e),...i,children:t})},pre({children:e}){return(0,y.jsx)(y.Fragment,{children:e})},p({children:e,...t}){return(0,y.jsx)(`div`,{dir:`auto`,className:`mb-2.5 last:mb-0 leading-relaxed`,...t,children:e})},ul({children:e,...t}){return(0,y.jsx)(`ul`,{dir:`auto`,className:`list-disc list-inside mb-2.5 space-y-1 ps-4`,...t,children:e})},ol({children:e,...t}){return(0,y.jsx)(`ol`,{dir:`auto`,className:`list-decimal list-inside mb-2.5 space-y-1 ps-4`,...t,children:e})},li({children:e,...t}){return(0,y.jsx)(`li`,{dir:`auto`,className:`text-gray-700 dark:text-dark-700 leading-relaxed`,...t,children:e})},blockquote({children:e,...t}){return(0,y.jsx)(`blockquote`,{dir:`auto`,className:`border-s-2 border-primary-400 dark:border-primary-500 bg-primary-25 dark:bg-primary-950/30 ps-3 py-2 my-3 rounded-e-lg italic text-gray-700 dark:text-dark-700`,...t,children:e})},h1({children:e,...t}){return(0,y.jsx)(`h1`,{dir:`auto`,className:`text-xl font-bold mb-3 mt-5 first:mt-0 text-gray-900 dark:text-dark-800 border-b border-gray-200 dark:border-dark-300 pb-1.5`,...t,children:e})},h2({children:e,...t}){return(0,y.jsx)(`h2`,{dir:`auto`,className:`text-lg font-semibold mb-2 mt-5 first:mt-0 text-gray-900 dark:text-dark-800`,...t,children:e})},h3({children:e,...t}){return(0,y.jsx)(`h3`,{dir:`auto`,className:`text-base font-medium mb-2 mt-4 first:mt-0 text-gray-900 dark:text-dark-800`,...t,children:e})},table({children:e,node:t,...n}){return(0,y.jsx)(`div`,{className:s(`my-4 w-full overflow-x-auto rounded-xl border border-line bg-surface shadow-subtle`,`focus:outline-none focus-visible:ring-2 focus-visible:ring-primary-500/40`),tabIndex:0,children:(0,y.jsx)(`table`,{dir:`auto`,className:`w-full min-w-[42rem] border-separate border-spacing-0 text-start text-sm`,...n,children:e})})},thead({children:e,node:t,...n}){return(0,y.jsx)(`thead`,{className:`bg-surface-subtle`,...n,children:e})},tbody({children:e,node:t,...n}){return(0,y.jsx)(`tbody`,{...n,children:e})},tr({children:e,node:t,...n}){return(0,y.jsx)(`tr`,{className:`transition-colors hover:bg-black/[0.025] last:[&>td]:border-b-0 dark:hover:bg-white/[0.025]`,...n,children:e})},th({align:e,children:t,node:n,...r}){return(0,y.jsx)(`th`,{className:s(`border-b border-e border-line-strong px-3 py-2.5 align-bottom font-semibold text-ink last:border-e-0`,e===`center`?`text-center`:e===`right`?`text-right`:e===`left`?`text-left`:`text-start`),...r,children:t})},td({align:e,children:t,node:n,...r}){return(0,y.jsx)(`td`,{className:s(`min-w-40 border-b border-e border-line px-3 py-2.5 align-top leading-relaxed text-ink last:border-e-0`,e===`center`?`text-center`:e===`right`?`text-right`:e===`left`?`text-left`:`text-start`),...r,children:t})}},children:i})})};export{_ as n,S as t};
|