| 
									
										
										
										
											2024-04-08 18:51:46 +08:00
										 |  |  | import { createStore } from 'zustand' | 
					
						
							|  |  |  | import type { Features } from './types' | 
					
						
							| 
									
										
										
										
											2024-10-21 10:32:37 +08:00
										 |  |  | import { Resolution, TransferMethod } from '@/types/app' | 
					
						
							| 
									
										
										
										
											2024-04-08 18:51:46 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2025-03-21 17:41:03 +08:00
										 |  |  | export type FeaturesModal = { | 
					
						
							| 
									
										
										
										
											2024-04-08 18:51:46 +08:00
										 |  |  |   showFeaturesModal: boolean | 
					
						
							|  |  |  |   setShowFeaturesModal: (showFeaturesModal: boolean) => void | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2025-03-21 17:41:03 +08:00
										 |  |  | export type FeaturesState = { | 
					
						
							| 
									
										
										
										
											2024-04-08 18:51:46 +08:00
										 |  |  |   features: Features | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2025-03-21 17:41:03 +08:00
										 |  |  | export type FeaturesAction = { | 
					
						
							| 
									
										
										
										
											2024-04-08 18:51:46 +08:00
										 |  |  |   setFeatures: (features: Features) => void | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | export type FeatureStoreState = FeaturesState & FeaturesAction & FeaturesModal | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | export type FeaturesStore = ReturnType<typeof createFeaturesStore> | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | export const createFeaturesStore = (initProps?: Partial<FeaturesState>) => { | 
					
						
							|  |  |  |   const DEFAULT_PROPS: FeaturesState = { | 
					
						
							|  |  |  |     features: { | 
					
						
							| 
									
										
										
										
											2024-10-21 10:32:37 +08:00
										 |  |  |       moreLikeThis: { | 
					
						
							|  |  |  |         enabled: false, | 
					
						
							|  |  |  |       }, | 
					
						
							| 
									
										
										
										
											2024-04-08 18:51:46 +08:00
										 |  |  |       opening: { | 
					
						
							|  |  |  |         enabled: false, | 
					
						
							|  |  |  |       }, | 
					
						
							|  |  |  |       suggested: { | 
					
						
							|  |  |  |         enabled: false, | 
					
						
							|  |  |  |       }, | 
					
						
							|  |  |  |       text2speech: { | 
					
						
							|  |  |  |         enabled: false, | 
					
						
							|  |  |  |       }, | 
					
						
							|  |  |  |       speech2text: { | 
					
						
							|  |  |  |         enabled: false, | 
					
						
							|  |  |  |       }, | 
					
						
							|  |  |  |       citation: { | 
					
						
							|  |  |  |         enabled: false, | 
					
						
							|  |  |  |       }, | 
					
						
							|  |  |  |       moderation: { | 
					
						
							|  |  |  |         enabled: false, | 
					
						
							|  |  |  |       }, | 
					
						
							|  |  |  |       file: { | 
					
						
							|  |  |  |         image: { | 
					
						
							|  |  |  |           enabled: false, | 
					
						
							| 
									
										
										
										
											2024-10-21 10:32:37 +08:00
										 |  |  |           detail: Resolution.high, | 
					
						
							| 
									
										
										
										
											2024-04-08 18:51:46 +08:00
										 |  |  |           number_limits: 3, | 
					
						
							|  |  |  |           transfer_methods: [TransferMethod.local_file, TransferMethod.remote_url], | 
					
						
							|  |  |  |         }, | 
					
						
							|  |  |  |       }, | 
					
						
							| 
									
										
										
										
											2024-10-21 10:32:37 +08:00
										 |  |  |       annotationReply: { | 
					
						
							|  |  |  |         enabled: false, | 
					
						
							|  |  |  |       }, | 
					
						
							| 
									
										
										
										
											2024-04-08 18:51:46 +08:00
										 |  |  |     }, | 
					
						
							|  |  |  |   } | 
					
						
							|  |  |  |   return createStore<FeatureStoreState>()(set => ({ | 
					
						
							|  |  |  |     ...DEFAULT_PROPS, | 
					
						
							|  |  |  |     ...initProps, | 
					
						
							|  |  |  |     setFeatures: features => set(() => ({ features })), | 
					
						
							|  |  |  |     showFeaturesModal: false, | 
					
						
							|  |  |  |     setShowFeaturesModal: showFeaturesModal => set(() => ({ showFeaturesModal })), | 
					
						
							|  |  |  |   })) | 
					
						
							|  |  |  | } |