From 7efbb1fc58ea4ab8124d4d9c0bd747af366e7726 Mon Sep 17 00:00:00 2001 From: Matteo Parenti Date: Tue, 17 Feb 2026 17:25:04 +0100 Subject: [PATCH 1/8] Show remaining spool weigth instead of used --- frontend/src/components/AssignSpoolModal.tsx | 2 +- frontend/src/components/FilamentHoverCard.tsx | 8 ++++++-- frontend/src/i18n/locales/it.ts | 4 ++-- frontend/src/pages/PrintersPage.tsx | 3 +++ 4 files changed, 12 insertions(+), 5 deletions(-) diff --git a/frontend/src/components/AssignSpoolModal.tsx b/frontend/src/components/AssignSpoolModal.tsx index 10011af81..d899435dc 100644 --- a/frontend/src/components/AssignSpoolModal.tsx +++ b/frontend/src/components/AssignSpoolModal.tsx @@ -177,7 +177,7 @@ export function AssignSpoolModal({ isOpen, onClose, printerId, amsId, trayId, tr

{spool.color_name || ''} {spool.label_weight ? ` - ${spool.label_weight}g` : ''} - {spool.weight_used > 0 ? ` (${Math.round(spool.weight_used)}g used)` : ''} + {spool.label_weight ? ` (${Math.max(0, Math.round(spool.label_weight - spool.weight_used))}g remaining)` : ''}

{selectedSpoolId === spool.id && ( diff --git a/frontend/src/components/FilamentHoverCard.tsx b/frontend/src/components/FilamentHoverCard.tsx index f1adb160c..503d02868 100644 --- a/frontend/src/components/FilamentHoverCard.tsx +++ b/frontend/src/components/FilamentHoverCard.tsx @@ -24,7 +24,7 @@ interface SpoolmanConfig { interface InventoryConfig { onAssignSpool?: () => void; onUnassignSpool?: () => void; - assignedSpool?: { id: number; material: string; brand: string | null; color_name: string | null } | null; + assignedSpool?: { id: number; material: string; brand: string | null; color_name: string | null; remainingWeightGrams?: number | null } | null; } interface ConfigureSlotConfig { @@ -148,6 +148,7 @@ export function FilamentHoverCard({ data, children, disabled, className = '', sp }; const colorHex = data.colorHex ? `#${data.colorHex.replace('#', '')}` : null; + const assignedRemainingWeight = inventory?.assignedSpool?.remainingWeightGrams ?? null; return (
- {data.fillLevel !== null ? `${data.fillLevel}%` : '—'} + {data.fillLevel !== null ? `${data.fillLevel}%` : '—'} + {assignedRemainingWeight !== null && data.fillLevel !== null && ( + • {assignedRemainingWeight}g + )} {data.fillSource === 'spoolman' && data.fillLevel !== null && ( {t('spoolman.fillSourceLabel')} )} diff --git a/frontend/src/i18n/locales/it.ts b/frontend/src/i18n/locales/it.ts index 1afc233be..3fbe22252 100644 --- a/frontend/src/i18n/locales/it.ts +++ b/frontend/src/i18n/locales/it.ts @@ -2347,7 +2347,7 @@ export default { kProfiles: 'K-Profiles', addKProfile: 'Aggiungi K-Profile', assignSpool: 'Assegna Bobina', - unassignSpool: 'Deassegna', + unassignSpool: 'Scollega', assignSuccess: 'Bobina assegnata e slot AMS configurato', assignFailed: 'Assegnazione bobina fallita', selectSpool: 'Seleziona una bobina da assegnare a questo slot', @@ -2397,7 +2397,7 @@ export default { externalSpool: 'Bobina esterna', profile: 'Profilo', kFactor: 'K Factor', - fill: 'Riempi', + fill: 'Residuo', configure: 'Configura', }, diff --git a/frontend/src/pages/PrintersPage.tsx b/frontend/src/pages/PrintersPage.tsx index fc0f705ac..932273a66 100644 --- a/frontend/src/pages/PrintersPage.tsx +++ b/frontend/src/pages/PrintersPage.tsx @@ -2906,6 +2906,7 @@ function PrinterCard({ material: assignment.spool.material, brand: assignment.spool.brand, color_name: assignment.spool.color_name, + remainingWeightGrams: Math.max(0, Math.round(assignment.spool.label_weight - assignment.spool.weight_used)), } : null, onAssignSpool: filamentData.vendor !== 'Bambu Lab' ? () => setAssignSpoolModal({ printerId: printer.id, @@ -3144,6 +3145,7 @@ function PrinterCard({ material: assignment.spool.material, brand: assignment.spool.brand, color_name: assignment.spool.color_name, + remainingWeightGrams: Math.max(0, Math.round(assignment.spool.label_weight - assignment.spool.weight_used)), } : null, onAssignSpool: filamentData.vendor !== 'Bambu Lab' ? () => setAssignSpoolModal({ printerId: printer.id, @@ -3330,6 +3332,7 @@ function PrinterCard({ material: assignment.spool.material, brand: assignment.spool.brand, color_name: assignment.spool.color_name, + remainingWeightGrams: Math.max(0, Math.round(assignment.spool.label_weight - assignment.spool.weight_used)), } : null, onAssignSpool: () => setAssignSpoolModal({ printerId: printer.id, From 3291e8c6f9bbcab6b37c6eeac719ce2d62d17b33 Mon Sep 17 00:00:00 2001 From: Wesley Silva Date: Tue, 17 Feb 2026 19:49:08 +0000 Subject: [PATCH 2/8] Added translation to Brazilian Portuguese on existing strings. --- CONTRIBUTING.md | 1 + frontend/src/i18n/index.ts | 5 +- frontend/src/i18n/locales/pt-BR.ts | 3442 ++++++++++++++++++++++++++++ 3 files changed, 3447 insertions(+), 1 deletion(-) create mode 100644 frontend/src/i18n/locales/pt-BR.ts diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index c3a92023e..2dcb7ad16 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -168,6 +168,7 @@ Translations live in `frontend/src/i18n/locales/`: | `de.ts` | German | | `fr.ts` | French | | `ja.ts` | Japanese | +| `pt-BR.ts` | Brazilian Portguese | ### Adding New Strings diff --git a/frontend/src/i18n/index.ts b/frontend/src/i18n/index.ts index a16b4f24b..b961913ca 100644 --- a/frontend/src/i18n/index.ts +++ b/frontend/src/i18n/index.ts @@ -8,6 +8,7 @@ import de from './locales/de'; import fr from './locales/fr'; import ja from './locales/ja'; import it from './locales/it'; +import ptBR from './locales/pt-BR'; const resources = { en: { translation: en }, @@ -15,6 +16,7 @@ const resources = { fr: { translation: fr }, ja: { translation: ja }, it: { translation: it }, + 'pt-BR': { translation: ptBR }, }; i18n @@ -23,7 +25,7 @@ i18n .init({ resources, fallbackLng: 'en', - supportedLngs: ['en', 'de', 'fr', 'ja', 'it'], + supportedLngs: ['en', 'de', 'fr', 'ja', 'it', 'pt-BR'], detection: { // Order of detection methods @@ -52,4 +54,5 @@ export const availableLanguages = [ { code: 'fr', name: 'French', nativeName: 'Français' }, { code: 'ja', name: 'Japanese', nativeName: '日本語' }, { code: 'it', name: 'Italian', nativeName: 'Italiano' }, + { code: 'pt-BR', name: 'Portuguese (Brazil)', nativeName: 'Português (Brasil)' }, ]; diff --git a/frontend/src/i18n/locales/pt-BR.ts b/frontend/src/i18n/locales/pt-BR.ts new file mode 100644 index 000000000..9bf280604 --- /dev/null +++ b/frontend/src/i18n/locales/pt-BR.ts @@ -0,0 +1,3442 @@ +export default { + // Navigation + nav: { + printers: 'Impressoras', + archives: 'Arquivos', + queue: 'Fila', + stats: 'Estatísticas', + profiles: 'Perfis', + maintenance: 'Manutenção', + projects: 'Projetos', + inventory: 'Inventário', + files: 'Gerenciador de Arquivos', + settings: 'Configurações', + system: 'Sistema', + collapseSidebar: 'Recolher barra lateral', + expandSidebar: 'Expandir barra lateral', + update: 'Atualizar', + updateAvailable: 'Atualização disponível: v{{version}}', + updateAvailableBanner: 'Versão {{version}} está disponível!', + viewUpdate: 'Ver atualização', + viewOnGithub: 'Ver no GitHub', + keyboardShortcuts: 'Atalhos de teclado (?)', + switchToLight: 'Mudar para modo claro', + switchToDark: 'Mudar para modo escuro', + smartSwitches: 'Interruptores inteligentes', + logout: 'Sair', + }, + + // Common + common: { + save: 'Salvar', + saving: 'Salvando...', + cancel: 'Cancelar', + delete: 'Excluir', + edit: 'Editar', + add: 'Adicionar', + close: 'Fechar', + confirm: 'Confirmar', + loading: 'Carregando...', + error: 'Erro', + success: 'Sucesso', + warning: 'Aviso', + enabled: 'Ativado', + disabled: 'Desativado', + yes: 'Sim', + no: 'ão', + on: 'Ligado', + off: 'Desligado', + all: 'Todos', + none: 'Nenhum', + search: 'Pesquisar', + filter: 'Filtrar', + sort: 'Ordenar', + refresh: 'Atualizar', + download: 'Baixar', + upload: 'Enviar', + actions: 'Ações', + status: 'Status', + name: 'Nome', + description: 'Descrição', + date: 'Data', + time: 'Hora', + hours: 'Horas', + minutes: 'Minutos', + seconds: 'Segundos', + days: 'Dias', + enable: 'Ativar', + disable: 'Desativar', + permissions: 'Permissões', + noPrinters: 'Nenhuma impressora configurada', + noData: 'Nenhum dado disponível', + linkNotFound: 'Link não encontrado', + required: 'Obrigatório', + optional: 'Opcional', + dismiss: 'Dispensar', + apply: 'Aplicar', + reset: 'Redefinir', + export: 'Exportar', + import: 'Importar', + clear: 'Limpar', + selectAll: 'Selecionar tudo', + deselectAll: 'Desmarcar tudo', + noChange: '— Sem alterações —', + unchanged: 'Inalterado', + unassigned: 'Não atribuído', + unknown: 'Desconhecido', + unknownError: 'Erro desconhecido', + today: 'Hoje', + tomorrow: 'Amanhã', + asap: 'O mais rápido possível', + overdue: 'Atrasado', + now: 'Agora', + collapse: 'Recolher', + expand: 'Expandir', + viewArchive: 'Ver arquivo', + viewInFileManager: 'Ver no Gerenciador de Arquivos', + addedBy: 'Adicionado por {{username}}', + prints: 'impressões', + more: '+{{count}} mais', + ascending: 'Crescente', + descending: 'Decrescente', + printer: 'Impressora', + remove: 'Remover', + type: 'Tipo', + print: 'Imprimir', + rename: 'Renomear', + move: 'Mover', + create: 'Criar', + duplicate: 'Duplicar', + left: 'Esquerda', + right: 'Direita', + }, + + // Printers page + printers: { + title: 'Impressoras', + addPrinter: 'Adicionar Impressora', + editPrinter: 'Editar Impressora', + deletePrinter: 'Excluir Impressora', + printerName: 'Nome da Impressora', + serialNumber: 'Número de Série', + ipAddress: 'Endereço IP / Nome do Host', + accessCode: 'Código de Acesso', + model: 'Modelo', + nozzleCount: 'Número de Bicos', + autoArchive: 'Arquivamento Automático', + status: { + available: 'Disponível', + idle: 'Ocioso', + printing: 'Imprimindo', + paused: 'Pausado', + offline: 'Offline', + error: 'Erro', + finished: 'Concluído', + unknown: 'Desconhecido', + }, + temperatures: { + nozzle: 'Bico', + bed: 'Cama', + chamber: 'Câmara', + }, + progress: '{{percent}}% concluído', + timeRemaining: '{{time}} restante', + deleteConfirm: 'Tem certeza de que deseja excluir "{{name}}"?', + maintenanceOk: 'Manutenção OK', + maintenanceWarning: '{{count}} aviso', + maintenanceWarning_plural: '{{count}} avisos', + maintenanceDue: '{{count}} devido', + maintenanceDue_plural: '{{count}} devido', + // Sort options + sort: { + name: 'Nome', + status: 'Status', + model: 'Modelo', + location: 'Localização', + ascending: 'Ordem crescente', + descending: 'Ordem decrescente', + }, + // Card size + cardSize: { + small: 'Cartões pequenos', + medium: 'Cartões médios', + large: 'Cartões grandes', + extraLarge: 'Cartões extra grandes', + }, + // Controls + hideOffline: 'Ocultar offline', + nextAvailable: 'Próximo disponível', + powerOn: 'Ligar', + offlinePrintersWithPlugs: 'Impressoras offline com tomadas inteligentes', + noPrintersConfigured: 'Nenhuma impressora configurada ainda', + // Printer card + readyToPrint: 'Pronto para imprimir', + external: 'Externo', + extL: 'Ext-L', + extR: 'Ext-R', + deleteArchives: 'Excluir arquivos de impressão', + noLabel: 'Sem etiqueta', + printPreview: 'Pré-visualização de impressão', + width: 'Largura', + height: 'Altura', + noObjectsFound: 'Nenhum objeto encontrado', + objectsLoadedOnPrintStart: 'Objetos são carregados quando uma impressão começa', + willBeSkipped: 'Será ignorado', + name: 'Nome', + serialCannotBeChanged: 'Número de série não pode ser alterado', + locationHelp: 'Usado para agrupar impressoras e filtrar trabalhos na fila', + // WiFi signal strength + wifiSignal: { + veryWeak: 'Muito fraco', + weak: 'Fraco', + fair: 'Regular', + good: 'Bom', + excellent: 'Excelente', + }, + // Maintenance + maintenanceUpToDate: 'Toda a manutenção está em dia - Clique para ver', + // Chamber light + chamberLightOn: 'Ligar luz da câmara', + chamberLightOff: 'Desligar luz da câmara', + // Files + browseFiles: 'Procurar arquivos da impressora', + // Smart plug + autoOffAfterPrint: 'Desligamento automático após impressão', + autoOffExecuted: 'Desligamento automático executado - ligue a impressora para reiniciar', + // HMS errors + hmsErrors: 'Erros HMS', + viewHmsErrors: 'Ver {{count}} erro(s) HMS', + // Actions + resume: 'Retomar', + pause: 'Pausar', + stop: 'Parar', + camera: 'âmera', + skipObject: 'Ignorar objeto', + reconnect: 'Reconectar', + mqttDebug: 'Depuração MQTT', + activeNozzle: 'Ativo: {{nozzle}} bico', + nozzleRack: 'Suporte de bicos', + nozzleDocked: 'Acoplado', + nozzleMounted: 'Montado', + nozzleActive: 'Ativo', + nozzleIdle: 'Ocioso', + nozzleDiameter: 'Diâmetro', + nozzleType: 'Tipo', + nozzleStatus: 'Status', + nozzleFilament: 'Filamento', + nozzleWear: 'Desgaste', + nozzleMaxTemp: 'Temp Máx', + nozzleSerial: 'Serial', + nozzleHardenedSteel: 'Aço Endurecido', + nozzleStainlessSteel: 'Aço Inoxidável', + nozzleTungstenCarbide: 'Carboneto de Tungstênio', + nozzleFlow: 'Fluxo', + nozzleHighFlow: 'Alto Fluxo', + nozzleStandardFlow: 'Fluxo Padrão', + // Firmware + firmwareUpdate: 'Atualização de Firmware', + firmwareInstructions: 'No visor da impressora, vá para', + firmwareNav: 'Navegar para', + settings: 'Configurações', + firmware: 'Firmware', + // Discovery + discoverPrinters: 'Descobrir Impressoras', + searching: 'Procurando...', + manualEntry: 'Entrada Manual', + addFromCloud: 'Adicionar da Nuvem', + // Toast messages + toast: { + printerDeleted: 'Impressora excluída', + printerAdded: 'Impressora adicionada', + printerUpdated: 'Impressora atualizada', + failedToDelete: 'Falha ao excluir impressora', + failedToAdd: 'Falha ao adicionar impressora', + failedToUpdate: 'Falha ao atualizar impressora', + commandSent: 'Comando enviado', + failedToSendCommand: 'Falha ao enviar comando', + turnedOn: '{{name}} ligado', + failedToPowerOn: 'Falha ao ligar {{name}}', + scriptTriggered: 'Script acionado', + printStopped: 'Impressão parada', + printPaused: 'Impressão pausada', + printResumed: 'Impressão retomada', + referenceDeleted: 'Referência excluída', + detectionAreaSaved: 'Área de detecção salva', + failedToRunScript: 'Falha ao executar script', + failedToStopPrint: 'Falha ao parar impressão', + failedToPausePrint: 'Falha ao pausar impressão', + failedToResumePrint: 'Falha ao retomar impressão', + failedToControlChamberLight: 'Falha ao controlar a luz da câmara', + failedToUpdateSetting: 'Falha ao atualizar configuração', + failedToSkipObjects: 'Falha ao ignorar objetos', + failedToRereadRfid: 'Falha ao reler RFID', + failedToCheckPlate: 'Falha ao verificar a placa', + failedToUpdateLabel: 'Falha ao atualizar etiqueta', + failedToDeleteReference: 'Falha ao excluir referência', + failedToSaveDetectionArea: 'Falha ao salvar área de detecção', + plateCheckEnabled: 'Verificação da placa ativada', + plateCheckDisabled: 'Verificação da placa desativada', + calibrationSaved: 'Calibração salva!', + calibrationFailed: 'Falha na calibração', + rfidRereadInitiated: 'Releitura de RFID iniciada', + }, + // Connection status + connection: { + connected: 'Conectado', + offline: 'Offline', + }, + // Queue info + queue: { + inQueue: '{{count}} impressão na fila', + inQueue_plural: '{{count}} impressões na fila', + }, + // Controls section + controls: 'Controles', + // RFID + rfid: { + reread: 'Releitura de RFID', + }, + // Permissions + permission: { + noAdd: 'Você não tem permissão para adicionar impressoras', + noEdit: 'Você não tem permissão para editar impressoras', + noDelete: 'Você não tem permissão para excluir impressoras', + noControl: 'Você não tem permissão para controlar impressoras', + noFiles: 'Você não tem permissão para acessar arquivos de impressora', + noAmsRfid: 'Você não tem permissão para reler RFID AMS', + noSmartPlugControl: 'Você não tem permissão para controlar tomadas inteligentes', + }, + // Add/Edit modal + modal: { + addTitle: 'Adicionar Impressora', + editTitle: 'Editar Impressora', + myPrinter: 'Minha Impressora', + selectModel: 'Selecionar modelo...', + locationGroup: 'Localização / Grupo (opcional)', + locationPlaceholder: 'ex.: Oficina, Escritório, Porão', + autoArchiveLabel: 'Arquivar automaticamente impressões concluídas', + fromPrinterSettings: 'A partir das configurações da impressora', + modelOptional: 'Modelo (opcional)', + saveChanges: 'Salvar alterações', + }, + // Skip objects + skipObjects: { + tooltip: 'Ignorar objetos', + onlyWhilePrinting: 'Ignorar objetos (apenas durante a impressão)', + requiresMultiple: 'Ignorar objetos (requer 2+ objetos)', + title: 'Ignorar Objetos', + matchIdsInfo: 'Correspondência de IDs com o display da sua impressora', + printerShowsIds: 'A tela da impressora mostra os IDs dos objetos na placa de construção', + skipSelected: 'Ignorar Selecionados', + skipping: 'Ignorando...', + noObjectsSelected: 'Nenhum objeto selecionado', + selectObjectsToSkip: 'Selecione os objetos que deseja ignorar na impressão atual', + skipped: 'Ignorado', + objectsSkipped: 'Objetos ignorados', + activeCount: '{{count}} ativo', + waitForLayer: 'Aguarde a camada 2+ para ignorar objetos (atualmente na camada {{layer}})', + skip: 'Ignorar', + confirmTitle: 'Ignorar Objeto?', + confirmMessage: 'Tem certeza de que deseja ignorar "{{name}}"? Isso não pode ser desfeito.', + }, + // Confirm modals + confirm: { + deleteTitle: 'Excluir Impressora', + deleteMessage: 'Tem certeza de que deseja excluir "{{name}}"? Isso removerá todas as configurações de conexão.', + deleteArchivesNote: 'Todo o histórico de impressão desta impressora será permanentemente excluído.', + keepArchivesNote: 'O histórico de impressão será mantido, mas não estará mais associado a esta impressora.', + stopTitle: 'Parar Impressão', + stopMessage: 'Tem certeza de que deseja parar a impressão atual em "{{name}}"? Isso cancelará o trabalho de impressão.', + stopButton: 'Parar Impressão', + pauseTitle: 'Pausar Impressão', + pauseMessage: 'Tem certeza de que deseja pausar a impressão atual em "{{name}}"?', + pauseButton: 'Pausar Impressão', + resumeTitle: 'Retomar Impressão', + resumeMessage: 'Tem certeza de que deseja retomar a impressão em "{{name}}"?', + resumeButton: 'Retomar Impressão', + powerOnTitle: 'Ligar Impressora', + powerOnMessage: 'Tem certeza de que deseja ligar a impressora "{{name}}"?', + powerOnButton: 'Ligar', + powerOffTitle: 'Desligar Impressora', + powerOffMessage: 'Tem certeza de que deseja desligar a impressora "{{name}}"?', + powerOffWarning: 'AVISO: "{{name}}" está imprimindo no momento! Tem certeza de que deseja desligar a impressora? Isso interromperá a impressão e pode danificar a impressora.', + powerOffButton: 'Desligar', + }, + // Discovery + discovery: { + title: 'Descobrir Impressoras', + searching: 'Procurando...', + scanning: 'Escaneando...', + scanProgress: 'Escaneando... {{scanned}}/{{total}}', + foundPrinters: '{{count}} impressora(s) encontrada(s)', + noPrintersFound: 'Nenhuma impressora encontrada', + noPrintersFoundSubnet: 'Nenhuma impressora encontrada na sub-rede especificada.', + noPrintersFoundNetwork: 'Nenhuma impressora encontrada na rede.', + allConfigured: 'Todas as impressoras descobertas já estão configuradas.', + alreadyAdded: 'Já adicionada', + select: 'Selecionar', + manualEntry: 'Entrada Manual', + addFromCloud: 'Adicionar da Nuvem', + subnetToScan: 'Sub-rede para escanear', + dockerNote: 'Docker detectado. Insira a sub-rede da sua impressora em notação CIDR. Requer network_mode: host no docker-compose.yml.', + scanSubnet: 'Escanear Sub-rede para Impressoras', + discoverNetwork: 'Descobrir Impressoras na Rede', + scanningSubnet: 'Escaneando sub-rede para impressoras Bambu...', + scanningNetwork: 'Escaneando rede...', + serialRequired: 'Serial necessário', + unknown: 'Desconhecido', + failedToStart: 'Falha ao iniciar a descoberta', + }, + // Filaments section + filaments: 'Filamentos', + // Camera + openCameraOverlay: 'Abrir sobreposição da câmera', + openCameraWindow: 'Abrir câmera em nova janela', + // Firmware + firmwareUpdateAvailable: 'Atualização de firmware disponível: {{current}} → {{latest}}', + firmwareUpToDate: 'Firmware {{version}} — Atualizado', + firmwareUpdateButton: 'Atualizar', + // Plate detection + plateDetection: { + noPermission: 'Você não tem permissão para atualizar impressoras', + enabledClick: 'Verificação da placa ativada - Clique para desativar', + disabledClick: 'Verificação da placa desativada - Clique para ativar', + manageCalibration: 'Gerenciar calibração da detecção da placa', + calibrationRequired: 'Calibração necessária', + calibrationInstructions: 'Certifique-se de que a placa de construção esteja completamente vazia, em seguida clique em Calibrar.', + calibrationDescription: 'A calibração captura uma imagem de referência da placa vazia. Verificações futuras compararão com esta referência para detectar objetos.', + calibrationTip: 'Dica: Você pode armazenar até 5 calibrações para diferentes placas. O sistema usa automaticamente a melhor correspondência ao verificar.', + plateEmpty: 'A placa parece vazia', + objectsDetected: 'Objetos detectados na placa', + confidence: 'Confiança', + difference: 'Diferença', + analysisPreview: 'Pré-visualização da análise:', + analysisLegend: 'Caixa verde = área de detecção, Sobreposição vermelha = diferenças em relação à calibração', + savedReferences: 'Referências salvas ({{count}}/{{max}})', + deleteReference: 'Excluir referência', + labelPlaceholder: 'Etiqueta...', + clickToEdit: '{{label}} - Clique para editar', + clickToAddLabel: 'Clique para adicionar etiqueta', + }, + // Fans + fans: { + partCooling: 'Ventilador de resfriamento da peça', + auxiliary: 'Ventilador auxiliar', + chamber: 'Ventilador da câmara', + }, + // HMS errors + clickToViewHmsErrors: 'Clique para ver erros do HMS', + estimatedCompletion: 'Tempo estimado de conclusão', + slotOptions: 'Opções de slot', + // Firmware modal + firmwareModal: { + title: 'Atualização de Firmware', + titleUpToDate: 'Informações do Firmware', + currentVersion: 'Atual:', + latestVersion: 'Última:', + releaseNotes: 'Notas de Lançamento', + checkingPrereqs: 'Verificando pré-requisitos...', + sdCardReady: 'Cartão SD pronto. Clique abaixo para enviar o firmware.', + uploadedSuccess: 'Firmware enviado para o cartão SD!', + applyInstructions: 'Para aplicar a atualização na sua impressora:', + step1: 'Na tela sensível ao toque da impressora, vá para Configurações', + step2: 'Navegue até Firmware', + step3: 'Selecione Atualizar a partir do cartão SD', + step4: 'A atualização levará de 10 a 20 minutos', + done: 'Concluído', + starting: 'Iniciando...', + uploadFirmware: 'Enviar Firmware', + uploadFailed: 'Falha ao iniciar o envio: {{error}}', + uploadedToast: 'Firmware enviado! Inicie a atualização na tela da impressora.', + }, + accessCodePlaceholder: 'Deixe vazio para manter o atual', + // ROI editor + roi: { + title: 'Área de Detecção (ROI)', + xStart: 'Início X', + yStart: 'Início Y', + width: 'Largura', + height: 'Altura', + instruction: 'Ajuste a área de detecção para focar na placa de construção. A caixa verde na pré-visualização mostra a área atual.', + }, + }, + + // Archives page + archives: { + title: 'Arquivos de Impressão', + searchPlaceholder: 'Pesquisar arquivos...', + filterByPrinter: 'Filtrar por impressora', + filterByStatus: 'Filtrar por status', + sortBy: 'Ordenar por', + sortNewest: 'Mais recentes primeiro', + sortOldest: 'Mais antigos primeiro', + sortName: 'Nome', + sortDuration: 'Duração', + sortLargest: 'Maiores primeiro', + sortSmallest: 'Menores primeiro', + sortSize: 'Tamanho', + noArchives: 'Nenhum arquivo encontrado', + noArchivesSearch: 'Nenhum arquivo corresponde à sua pesquisa', + noArchivesYet: 'Ainda não há arquivos', + loadingArchives: 'Carregando arquivos...', + releaseToUpload: 'Solte para enviar', + showAll: 'Mostrar todos', + showFavoritesOnly: 'Mostrar apenas favoritos', + gridView: 'Visualização em grade', + listView: 'Visualização em lista', + calendarView: 'Visualização em calendário', + logView: 'Registro de impressão', + manageTags: 'Gerenciar etiquetas', + showFailedPrints: 'Mostrar impressões falhas', + hideFailedPrints: 'Ocultar impressões falhas', + printTime: 'Tempo de impressão', + filamentUsed: 'Filamento usado', + cost: 'Custo', + reprint: 'Reimprimir', + preview: 'Pré-visualizar', + deleteArchive: 'Excluir arquivo', + deleteConfirm: 'Tem certeza de que deseja excluir este arquivo?', + favorite: 'Favorito', + unfavorite: 'Remover dos favoritos', + viewDetails: 'Ver detalhes', + status: { + completed: 'Concluído', + failed: 'Falhou', + stopped: 'Parado', + }, + toast: { + source3mfAttached: 'Arquivo de origem 3MF anexado: {{filename}}', + failedUploadSource3mf: 'Falha ao enviar arquivo de origem 3MF', + source3mfRemoved: 'Arquivo de origem 3MF removido', + failedRemoveSource3mf: 'Falha ao remover arquivo de origem 3MF', + f3dAttached: 'F3D anexado: {{filename}}', + failedUploadF3d: 'Falha ao enviar F3D', + f3dRemoved: 'F3D removido', + failedRemoveF3d: 'Falha ao remover F3D', + timelapseAttached: 'Timelapse anexado: {{filename}}', + timelapseAlreadyAttached: 'Timelapse já anexado', + noMatchingTimelapse: 'Nenhum timelapse correspondente encontrado', + failedScanTimelapse: 'Falha ao escanear timelapse', + failedAttachTimelapse: 'Falha ao anexar timelapse', + timelapseRemoved: 'Timelapse removido', + failedRemoveTimelapse: 'Falha ao remover timelapse', + timelapseUploaded: 'Timelapse enviado: {{filename}}', + failedUploadTimelapse: 'Falha ao enviar timelapse', + archiveDeleted: 'Arquivo excluído', + failedDeleteArchive: 'Falha ao excluir arquivo', + addedToFavorites: 'Adicionado aos favoritos', + removedFromFavorites: 'Removido dos favoritos', + projectUpdated: 'Projeto atualizado', + failedUpdateProject: 'Falha ao atualizar projeto', + linkCopied: 'Link copiado para a área de transferência', + failedCopyLink: 'Falha ao copiar link', + photoDeleted: 'Foto excluída', + failedDeletePhoto: 'Falha ao excluir foto', + failedDeleteArchives: 'Falha ao excluir arquivos', + failedUpdateFavorites: 'Falha ao atualizar favoritos', + exportDownloaded: 'Exportação baixada', + exportFailed: 'Falha na exportação', + }, + menu: { + print: 'Imprimir', + schedule: 'Agendar', + openInBambuStudio: 'Abrir no Slicer', + slice: 'Fatiar', + externalLink: 'Link externo', + viewOnMakerWorld: 'Ver no MakerWorld', + preview3d: 'Pré-visualização 3D', + viewTimelapse: 'Ver Timelapse', + scanForTimelapse: 'Escanear Timelapse', + uploadTimelapse: 'Enviar Timelapse', + removeTimelapse: 'Remover Timelapse', + downloadSource3mf: 'Baixar Source 3MF', + uploadSource3mf: 'Enviar Source 3MF', + replaceSource3mf: 'Substituir Source 3MF', + removeSource3mf: 'Remover Source 3MF', + uploadF3d: 'Enviar F3D', + replaceF3d: 'Substituir F3D', + downloadF3d: 'Baixar F3D', + removeF3d: 'Remover F3D', + download: 'Baixar', + copyDownloadLink: 'Copiar link de download', + qrCode: 'Qr Code', + viewPhotos: 'Ver fotos', + viewPhotosCount: 'Ver fotos ({{count}})', + projectPage: 'Página do projeto', + addToFavorites: 'Adicionar aos favoritos', + removeFromFavorites: 'Remover dos favoritos', + edit: 'Editar', + goToProject: 'Ir para o projeto: {{name}}', + addToProject: 'Adicionar ao projeto', + removeFromProject: 'Remover do projeto', + loading: 'Carregando...', + noProjectsAvailable: 'Nenhum projeto disponível', + select: 'Selecionar', + deselect: 'Desmarcar', + delete: 'Excluir', + }, + permission: { + noReprint: 'Você não tem permissão para reimprimir este arquivo', + noAddToQueue: 'Você não tem permissão para adicionar à fila', + noUpdateArchives: 'Você não tem permissão para atualizar arquivos', + noUploadFiles: 'Você não tem permissão para enviar arquivos', + noDownload: 'Você não tem permissão para baixar arquivos', + noCopyLink: 'Você não tem permissão para copiar links de download', + noDelete: 'Você não tem permissão para excluir este arquivo', + noCreate: 'Você não tem permissão para criar arquivos', + }, + card: { + previousPlate: 'Placa anterior', + nextPlate: 'Próxima placa', + plateNumber: 'Placa {{index}}', + moreOptions: 'Clique com o botão direito para mais opções', + addToFavorites: 'Adicionar aos favoritos', + removeFromFavorites: 'Remover dos favoritos', + cancelled: 'cancelado', + failed: 'falha', + duplicate: 'duplicado', + duplicateTitle: 'Este modelo já foi impresso antes', + openSource3mf: 'Abrir source 3MF no Bambu Studio (clique com o botão direito para mais opções)', + downloadF3d: 'Baixar arquivo de design do Fusion 360', + viewTimelapse: 'Ver timelapse', + viewPhoto: 'Ver 1 foto', + viewPhotos: 'Ver {{count}} fotos', + openFolder: 'Abrir pasta: {{name}}', + slicedFile: 'Arquivo fatiado - pronto para imprimir', + sourceFile: 'Apenas arquivo fonte - nenhum mapeamento AMS disponível', + gcode: 'GCODE', + source: 'SOURCE', + project: 'Projeto: {{name}}', + estimated: 'Estimado: {{time}}', + actual: 'Real: {{time}}', + accuracy: 'Precisão: {{percent}}%', + filament: '{{weight}}g', + layer: '{{count}} camada', + layers: '{{count}} camadas', + object: '{{count}} objeto', + objects: '{{count}} objetos', + slicedFor: 'Fatiado para {{model}}', + uploadedBy: 'Enviado por', + noPermissionReprint: 'Você não tem permissão para reimprimir', + noFileForReprint: 'Nenhum arquivo 3MF disponível — o arquivo não pôde ser baixado da impressora quando a impressão foi registrada', + noPermissionEdit: 'Você não tem permissão para editar arquivos', + noPermissionDelete: 'Você não tem permissão para excluir arquivos', + reprint: 'Reimprimir', + schedulePrint: 'Agendar impressão', + schedule: 'Agendar', + openInBambuStudio: 'Abrir no Bambu Studio', + openInBambuStudioToSlice: 'Abrir no Bambu Studio para fatiar', + slice: 'Fatiar', + externalLink: 'Link externo', + makerWorld: 'MakerWorld: {{designer}}', + viewProject: 'Ver projeto', + noExternalLink: 'Nenhum link externo', + preview3d: 'Visualização 3D', + download: 'Baixar', + edit: 'Editar', + delete: 'Excluir', + }, + modal: { + deleteArchive: 'Excluir Arquivo', + deleteConfirm: 'Tem certeza de que deseja excluir "{{name}}"? Esta ação não pode ser desfeita.', + deleteButton: 'Excluir', + removeSource3mf: 'Remover Source 3MF', + removeSource3mfConfirm: 'Tem certeza de que deseja remover o arquivo source 3MF de "{{name}}"? Isso excluirá o arquivo original do projeto do fatiador.', + removeButton: 'Remover', + removeF3d: 'Remover F3D', + removeF3dConfirm: 'Tem certeza de que deseja remover o arquivo de design do Fusion 360 de "{{name}}"?', + removeTimelapse: 'Remover Timelapse', + removeTimelapseConfirm: 'Tem certeza de que deseja remover o vídeo timelapse de "{{name}}"?', + timelapse: '{{name}} - Timelapse', + selectTimelapse: 'Selecionar Timelapse', + selectTimelapseDesc: 'Nenhuma correspondência automática encontrada. Selecione o timelapse para esta impressão:', + deleteArchives: 'Excluir Arquivos', + deleteArchivesConfirm: 'Tem certeza de que deseja excluir {{count}} arquivo(s)? Esta ação não pode ser desfeita.', + deleteCount: 'Excluir {{count}}', + }, + page: { + title: 'Arquivos', + printsCount: '{{filtered}} de {{total}} impressões', + dropFilesHere: 'Solte arquivos .3mf aqui', + releaseToUpload: 'Solte para enviar', + only3mfSupported: 'Apenas arquivos .3mf são suportados', + close: 'Fechar', + selected: '{{count}} selecionado(s)', + selectAll: 'Selecionar Todos', + tags: 'Tags', + project: 'Projeto', + favorite: 'Favorito', + delete: 'Excluir', + toggledFavorites: 'Favoritos alternados para {{count}} arquivo(s)', + failedUpdateFavorites: 'Falha ao atualizar favoritos', + archivesDeleted: '{{count}} arquivo(s) excluído(s)', + failedDeleteArchives: 'Falha ao excluir arquivos', + photoDeleted: 'Foto excluída', + failedDeletePhoto: 'Falha ao excluir foto', + }, + list: { + name: 'Nome', + printer: 'Impressora', + date: 'Data', + size: 'Tamanho', + actions: 'Ações', + hasTimelapse: 'Possui timelapse', + }, + log: { + date: 'Data', + printName: 'Nome da Impressão', + printer: 'Impressora', + user: 'Usuário', + status: 'Status', + duration: 'Duração', + filament: 'Filamento', + allPrinters: 'Todas as Impressoras', + allUsers: 'Todos os Usuários', + allStatuses: 'Todos os Status', + cancelled: 'Cancelado', + skipped: 'Ignorado', + dateFrom: 'De', + dateTo: 'Até', + noEntries: 'Nenhuma entrada de registro de impressão encontrada', + showing: 'Mostrando {{count}} de {{total}} entradas', + rowsPerPage: 'Linhas', + page: 'Página', + prev: 'Anterior', + next: 'Próxima', + clearLog: 'Limpar Registro', + clearLogTitle: 'Limpar Registro de Impressão', + clearLogConfirm: 'Todas as entradas do registro de impressão serão permanentemente excluídas. Arquivos e itens da fila não serão afetados. Esta ação não pode ser desfeita. Tem certeza?', + clearLogButton: 'Limpar Tudo', + cleared: '{{count}} entradas do registro de impressão limpas', + clearFailed: 'Falha ao limpar o registro de impressão', + }, + }, + + // Queue page + queue: { + title: 'Fila de Impressão', + subtitle: 'Agende e gerencie seus trabalhos de impressão', + addToQueue: 'Adicionar à Fila', + // Print modal + print: 'Imprimir', + reprint: 'Reimprimir', + schedulePrint: 'Agendar Impressão', + editQueueItem: 'Editar Item da Fila', + printToPrinters: 'Imprimir para {{count}} Impressoras', + queueToPrinters: 'Adicionar à Fila para {{count}} Impressoras', + sending: 'Enviando...', + sendingProgress: 'Enviando {{current}}/{{total}}...', + adding: 'Adicionando...', + addingProgress: 'Adicionando {{current}}/{{total}}...', + savingProgress: 'Salvando {{current}}/{{total}}...', + clearQueue: 'Limpar Fila', + clearHistory: 'Limpar Histórico', + emptyQueue: 'Fila vazia', + position: 'Posição', + scheduledTime: 'Hora Agendada', + moveUp: 'Mover para Cima', + moveDown: 'Mover para Baixo', + startNow: 'Iniciar Agora', + printingInProgress: 'Impressão em andamento...', + viewArchive: 'Ver Arquivo', + viewInFileManager: 'Ver no Gerenciador de Arquivos', + itemCount: '{{count}} item', + itemCount_plural: '{{count}} items', + dragToReorder: 'Arraste para reordenar (apenas ASAP)', + reorderHint: 'A posição afeta apenas itens ASAP. Itens agendados são executados no horário definido.', + addedBy: 'Adicionado por {{name}}', + nextInQueue: 'Próximo na fila', + clearPlate: 'Limpar Placa e Iniciar Próximo', + clearPlateSuccess: 'Placa limpa — pronta para a próxima impressão', + plateReady: 'Placa limpa — pronta para a próxima impressão', + plateNumber: 'Placa {{index}}', + // Sections + sections: { + currentlyPrinting: 'Imprimindo Atualmente', + queued: 'Na Fila', + history: 'Histórico', + }, + // Status + status: { + pending: 'Pendente', + waiting: 'Aguardando', + printing: 'Imprimindo', + paused: 'Pausado', + completed: 'Concluído', + failed: 'Falhou', + skipped: 'Ignorado', + cancelled: 'Cancelado', + }, + // Summary cards + summary: { + printing: 'Imprimindo', + queued: 'Na Fila', + totalTime: 'Tempo Total da Fila', + totalWeight: 'Peso Total da Fila', + history: 'Histórico', + }, + // Filters + filter: { + allPrinters: 'Todas as Impressoras', + unassigned: 'Não Atribuído', + allStatus: 'Todos os Status', + allLocations: 'Todos os Locais', + any: 'Qualquer', + }, + // Sort + sort: { + byPosition: 'Ordenar por Posição', + byName: 'Ordenar por Nome', + byPrinter: 'Ordenar por Impressora', + bySchedule: 'Ordenar por Agendamento', + byDate: 'Ordenar por Data', + ascendingOldest: 'Crescente (mais antigo primeiro)', + descendingNewest: 'Decrescente (mais recente primeiro)', + }, + // Badges + badges: { + staged: 'Preparado (início manual)', + requiresPrevious: 'Requer sucesso anterior', + autoPowerOff: 'Desligamento automático', + }, + // Empty state + empty: { + title: 'Nenhuma impressão agendada', + description: 'Agende uma impressão a partir da página de Arquivos usando a opção "Agendar" no menu de contexto, ou arraste e solte arquivos para começar.', + }, + // Time + time: { + asap: 'ASAP', + overdue: 'Atrasado', + now: 'Agora', + lessThanMinute: 'Em menos de um minuto', + inMinutes: 'Em {{count}} min', + inHours: 'Em {{count}} horas', + }, + // Actions + actions: { + stopPrint: 'Parar Impressão', + startPrint: 'Iniciar Impressão', + requeue: 'Reenfileirar', + }, + // Bulk edit + bulkEdit: { + title: 'Editar {{count}} Item', + title_plural: 'Editar {{count}} Items', + description: 'Apenas as configurações alteradas serão aplicadas aos itens selecionados.', + printer: 'Impressora', + noChange: '— Sem alterações —', + queueOptions: 'Opções de Fila', + staged: 'Preparado (início manual)', + autoPowerOff: 'Desligamento automático após impressão', + requirePrevious: 'Requer sucesso anterior', + printOptions: 'Opções de Impressão', + bedLevelling: 'Nivelamento da Mesa', + flowCalibration: 'Calibração de Fluxo', + vibrationCalibration: 'Calibração de Vibração', + layerInspection: 'Inspeção da Primeira Camada', + timelapse: 'Timelapse', + useAms: 'Usar AMS', + applyChanges: 'Aplicar Alterações', + selectAll: 'Selecionar Todos', + deselectAll: 'Desmarcar Todos', + selected: '{{count}} selecionado(s)', + editSelected: 'Editar Selecionados', + cancelSelected: 'Cancelar Selecionados', + }, + // Confirmations + confirm: { + cancelTitle: 'Cancelar Impressão Agendada', + cancelMessage: 'Tem certeza de que deseja cancelar "{{name}}"?', + stopTitle: 'Parar Impressão', + stopMessage: 'Tem certeza de que deseja parar a impressão atual "{{name}}"? Isso cancelará o trabalho de impressão na impressora.', + removeTitle: 'Remover do Histórico', + removeMessage: 'Tem certeza de que deseja remover "{{name}}" do histórico da fila?', + clearHistoryTitle: 'Limpar Histórico', + clearHistoryMessage: 'Tem certeza de que deseja remover todos os {{count}} itens do histórico?', + cancelButton: 'Cancelar Impressão', + stopButton: 'Parar Impressão', + thisPrint: 'esta impressão', + thisItem: 'este item', + }, + // Toast messages + toast: { + cancelled: 'Item da fila cancelado', + cancelFailed: 'Falha ao cancelar item', + removed: 'Item da fila removido', + removeFailed: 'Falha ao remover item', + stopped: 'Impressão parada', + stopFailed: 'Falha ao parar impressão', + released: 'Impressão liberada para a fila', + startFailed: 'Falha ao iniciar impressão', + reorderFailed: 'Falha ao reordenar fila', + historyCleared: 'Limpar {{count}} item(s) do histórico', + clearHistoryFailed: 'Falha ao limpar histórico', + updateFailed: 'Falha ao atualizar itens', + bulkCancelled: 'Cancelado {{count}} item(s)', + bulkCancelFailed: 'Falha ao cancelar itens', + }, + // Permissions + permissions: { + noStopPrint: 'Você não tem permissão para parar impressões', + noStartPrint: 'Você não tem permissão para iniciar impressões', + noEdit: 'Você não tem permissão para editar este item da fila', + noCancel: 'Você não tem permissão para cancelar este item da fila', + noRequeue: 'Você não tem permissão para reenfileirar itens', + noRemove: 'Você não tem permissão para remover este item da fila', + noClearHistory: 'Você não tem permissão para limpar todo o histórico', + noEditItems: 'Você não tem permissão para editar itens da fila', + noCancelItems: 'Você não tem permissão para cancelar itens da fila', + }, + }, + + // Statistics page + stats: { + title: 'Dashboard', + subtitle: 'Arraste os widgets para reorganizar. Clique no ícone de olho para ocultar.', + overview: 'Visão Geral', + totalPrints: 'Total de Impressões', + successRate: 'Taxa de Sucesso', + totalPrintTime: 'Tempo Total de Impressão', + printTime: 'Tempo de Impressão', + totalFilament: 'Filamento Total Utilizado', + filamentUsed: 'Filamento Utilizado', + filamentCost: 'Custo do Filamento', + totalCost: 'Custo Total', + energyUsed: 'Energia Utilizada', + energyCost: 'Custo da Energia', + averagePrintTime: 'Tempo Médio de Impressão', + printsPerDay: 'Impressões por Dia', + byPrinter: 'Por Impressora', + printsByPrinter: 'Impressões por Impressora', + byMaterial: 'Por Material', + byMonth: 'Por Mês', + last7Days: 'Últimos 7 Dias', + last30Days: 'Últimos 30 Dias', + last90Days: 'Últimos 90 Dias', + allTime: 'Todo o Tempo', + // Widgets + quickStats: 'Estatísticas Rápidas', + printActivity: 'Atividade de Impressão', + filamentTypes: 'Tipos de Filamento', + filamentTrends: 'Tendências de Filamento', + failureAnalysis: 'Análise de Falhas', + timeAccuracy: 'Precisão do Tempo', + successful: 'Bem-sucedido:', + failed: 'Falhou:', + perfectEstimate: '100% = estimativa perfeita', + noTimeAccuracyData: 'Nenhum dado de precisão de tempo disponível', + noFilamentData: 'Nenhum dado de filamento disponível', + noPrinterData: 'Nenhum dado de impressora disponível', + noPrintData: 'Nenhum dado de impressão disponível', + noPrintDataLast30Days: 'Nenhum dado de impressão nos últimos 30 dias', + failureReasons: 'Razões de Falha', + topFailureReasons: 'Principais Razões de Falha', + failedPrintsCount: '{{failed}} / {{total}} impressões falharam', + lastWeekRate: 'Última semana: {{rate}}%', + // Actions + resetLayout: 'Redefinir Layout', + recalculateCosts: 'Recalcular Custos', + recalculateCostsHint: 'Recalcular todos os custos do arquivo usando os preços atuais do filamento', + exportStats: 'Exportar Estatísticas', + exportAsCsv: 'Exportar como CSV', + exportAsExcel: 'Exportar como Excel', + hiddenCount: '{{count}} Oculto', + // Toast + exportDownloaded: 'Exportação baixada', + exportFailed: 'Falha na exportação', + layoutReset: 'Layout redefinido', + recalculatedCosts: 'Custos recalculados para {{count}} arquivos', + recalculateFailed: 'Falha ao recalcular custos', + // Loading + loadingStats: 'Carregando estatísticas...', + // Permissions + noPermissionResetLayout: 'Você não tem permissão para redefinir o layout', + noPermissionRecalculate: 'Você não tem permissão para recalcular custos', + }, + + // Maintenance page + maintenance: { + title: 'Manutenção', + overview: 'Visão Geral', + allOk: 'Todas as manutenções estão em dia', + dueCount: '{{count}} item pendente', + dueCount_plural: '{{count}} itens pendentes', + warningCount: '{{count}} aviso', + warningCount_plural: '{{count}} avisos', + totalPrintTime: 'Tempo Total de Impressão', + nextMaintenance: 'Próxima Manutenção', + nothingDue: 'Nada pendente', + tasks: 'Tarefas', + lastPerformed: 'Última execução', + interval: 'Intervalo', + hoursRemaining: '{{hours}}h restantes', + hoursOverdue: '{{hours}}h atrasadas', + markDone: 'Marcar como Concluída', + performMaintenance: 'Realizar Manutenção', + history: 'Histórico', + noHistory: 'Nenhum histórico de manutenção', + editPrintHours: 'Editar Horas de Impressão', + currentHours: 'Horas Atuais', + // Tabs + statusTab: 'Status', + settingsTab: 'Configurações', + // Status + overdueCount: '{{count}} atrasado', + dueSoonCount: '{{count}} prestes a vencer', + dueSoon: 'Prestes a vencer', + allGood: 'Tudo certo', + overdueBy: 'Atrasado por {{duration}}', + dueIn: 'Vence em {{duration}}', + timeLeft: '{{duration}} restantes', + // Duration formats + day: '1 dia', + days: '{{count}} dias', + week: '1 semana', + weeks: '{{count}} semanas', + month: '1 mês', + months: '{{count}} meses', + year: '1 ano', + years: '{{count}} anos', + // Settings + maintenanceTypes: 'Tipos de Manutenção', + maintenanceTypesDescription: 'Tipos de sistema e suas tarefas de manutenção personalizadas', + addCustomType: 'Adicionar Tipo Personalizado', + restoreDefaults: 'Restaurar Tarefas Padrão', + intervalType: 'Tipo de Intervalo', + intervalValue: 'Intervalo ({{type}})', + icon: 'Icon', + documentationLink: 'Link da Documentação (opcional)', + assignToPrinters: 'Atribuir a Impressoras', + selectAtLeastOnePrinter: 'Selecione pelo menos uma impressora', + addType: 'Adicionar Tipo', + custom: 'Personalizado', + printHours: 'Horas de Impressão', + calendarDays: 'Dias de Calendário', + exampleName: 'ex., Substituir Filtro HEPA', + viewDocumentation: 'Ver documentação', + timeBasedInterval: 'Intervalo baseado em tempo', + // Interval overrides + intervalOverrides: 'Substituições de Intervalo', + intervalOverridesDescription: 'Personalize os intervalos para impressoras específicas', + // Printer assignment + assignedToPrinters: 'Atribuído a impressoras:', + noPrintersAssigned: 'Nenhuma impressora atribuída', + addPrinterShort: 'Adicionar:', + printersAssignedClick: '{{count}} impressora(s) atribuída(s) - clique para gerenciar', + removeFromPrinter: 'Remover desta impressora', + // Types + types: { + lubricateCarbonRods: 'Lubricar Barras de Carbono', + lubricateRails: 'Lubricar Trilhos Lineares', + cleanNozzle: 'Limpar Bico/Hotend', + checkBelts: 'Verificar Tensão das Correias', + cleanBuildPlate: 'Limpar Plataforma de Impressão', + checkExtruder: 'Verificar Engrenagens do Extrusor', + checkCooling: 'Verificar Ventiladores de Resfriamento', + generalInspection: 'Inspeção Geral', + cleanCarbonRods: 'Limpar Barras de Carbono', + cleanLinearRails: 'Limpar Trilhos Lineares', + checkPtfeTube: 'Verificar Tubo PTFE', + replaceHepaFilter: 'Substituir Filtro HEPA', + replaceCarbonFilter: 'Substituir Filtro de Carbono', + lubricateLeftNozzleRail: 'Lubrificar Trilho do Bico Esquerdo', + }, + // Toast + maintenanceComplete: 'Manutenção marcada como concluída', + typeUpdated: 'Tipo de manutenção atualizado', + typeDeleted: 'Tipo de manutenção excluído', + defaultsRestored: 'Restauradas {{count}} tarefa(s) padrão', + printHoursUpdated: 'Horas de impressão atualizadas', + printerAssigned: 'Impressora atribuída', + printerRemoved: 'Impressora removida', + // Confirmation + deleteTypeConfirm: 'Excluir "{{name}}"?', + deleteSystemTypeTitle: 'Excluir tarefa de manutenção padrão?', + deleteSystemTypeMessage: 'Tem certeza de que deseja excluir a tarefa de manutenção padrão "{{name}}"?', + // Permissions + noPermissionUpdate: 'Você não tem permissão para atualizar itens de manutenção', + noPermissionPerform: 'Você não tem permissão para realizar manutenção', + noPermissionEditTypes: 'Você não tem permissão para editar tipos de manutenção', + noPermissionDeleteTypes: 'Você não tem permissão para excluir tipos de manutenção', + noPermissionEditHours: 'Você não tem permissão para editar horas de impressão', + noPermissionRemovePrinter: 'Você não tem permissão para remover atribuições de impressora', + noPermissionAssignPrinter: 'Você não tem permissão para atribuir impressoras', + noPermissionEditIntervals: 'Você não tem permissão para editar intervalos', + // Configure link + configureSettings: 'Configure tipos de manutenção e intervalos', + }, + + // Settings page + settings: { + title: 'Configurações', + general: 'Geral', + // Tab names + tabs: { + general: 'Geral', + smartPlugs: 'Tomadas Inteligentes', + notifications: 'Notificações', + filament: 'Filamento', + network: 'Rede', + apiKeys: 'Chaves API', + virtualPrinter: 'Impressora Virtual', + users: 'Autenticação', + backup: 'Backup', + emailAuth: 'Autenticação por Email', + }, + // Email settings + email: { + smtpSettings: 'Configuração SMTP', + smtpHost: 'Servidor SMTP', + smtpPort: 'Porta SMTP', + security: 'Segurança', + authentication: 'Autenticação', + username: 'Nome de Usuário', + password: 'Senha', + fromEmail: 'Email de Remetente', + fromName: 'Nome de Remetente', + testConnection: 'Testar Conexão SMTP', + testRecipient: 'Email de Teste', + sendTest: 'Enviar Email de Teste', + sending: 'Enviando...', + save: 'Salvar Configurações', + saving: 'Salvando...', + advancedAuth: 'Autenticação Avançada', + advancedAuthEnabled: 'Autenticação Avançada está habilitada', + advancedAuthEnabledDesc: 'Recursos de gerenciamento de usuários baseados em email estão ativos. Novos usuários receberão senhas geradas automaticamente por email, e os usuários podem redefinir suas senhas através do recurso de esqueci minha senha.', + advancedAuthDisabled: 'Autenticação Avançada está desabilitada', + advancedAuthDisabledDesc: 'Habilite a autenticação avançada para ativar recursos baseados em email para gerenciamento de usuários.', + enable: 'Habilitar', + disable: 'Desabilitar', + feature1: 'Senhas são geradas automaticamente e enviadas por email para novos usuários', + feature2: 'Usuários podem fazer login com nome de usuário ou email', + feature3: 'Recurso de esqueci minha senha está disponível', + feature4: 'Administradores podem redefinir senhas de usuários via email', + // Error messages + errors: { + requiredFields: 'Por favor, preencha todos os campos obrigatórios', + usernameRequired: 'Nome de usuário é obrigatório quando a autenticação está habilitada', + enterTestEmail: 'Por favor, insira um endereço de email de teste', + smtpServerAndEmail: 'Por favor, preencha o servidor SMTP e o email de remetente antes de testar', + usernamePasswordRequired: 'Nome de usuário e senha são obrigatórios quando a autenticação está habilitada', + configureSmtpFirst: 'Por favor, configure e teste as configurações SMTP primeiro', + }, + // Success messages + success: { + settingsSaved: 'Configurações SMTP salvas com sucesso', + }, + // Security options + securityOptions: { + starttls: 'STARTTLS (Port 587)', + ssl: 'SSL/TLS (Port 465)', + none: 'None (Port 25)', + }, + // Authentication options + authOptions: { + enabled: 'Habilitado', + disabled: 'Desabilitado', + }, + }, + appearance: 'Aparência', + notifications: 'Notificações', + smartPlugs: 'Tomadas Inteligentes', + spoolman: 'Spoolman', + updates: 'Atualizações', + language: 'Idioma', + languageDescription: 'Selecione seu idioma preferido', + theme: 'Tema', + themeLight: 'Claro', + themeDark: 'Escuro', + themeSystem: 'Sistema', + defaultView: 'Visualização Padrão', + defaultViewDescription: 'Página a ser exibida ao abrir o aplicativo', + checkForUpdates: 'Verificar Atualizações', + autoUpdate: 'Atualização Automática', + currentVersion: 'Versão Atual', + latestVersion: 'Última Versão', + upToDate: 'Você está atualizado', + updateAvailable: 'Atualização disponível', + // Notifications + notificationLanguage: 'Idioma das Notificações', + notificationLanguageDescription: 'Idioma para notificações push', + bedCooledThreshold: 'Limite de Resfriamento da Cama', + bedCooledThresholdDescription: 'Temperatura abaixo da qual a cama é considerada resfriada após uma impressão', + notificationProviders: 'Provedores de Notificação', + addProvider: 'Adicionar Provedor', + editProvider: 'Editar Provedor', + providerType: 'Tipo de Provedor', + testNotification: 'Testar Notificação', + testSuccess: 'Notificação de teste enviada com sucesso', + testFailed: 'Falha ao enviar notificação de teste', + quietHours: 'Horas de Silêncio', + quietHoursDescription: 'Não perturbe durante essas horas', + quietHoursStart: 'Início', + quietHoursEnd: 'Fim', + events: { + title: 'Eventos de Notificação', + printStart: 'Impressão Iniciada', + printComplete: 'Impressão Concluída', + printFailed: 'Falha na Impressão', + printStopped: 'Impressão Interrompida', + printProgress: 'Marcos de Progresso', + printProgressDescription: 'Notificar em 25%, 50%, 75%', + printerOffline: 'Impressora Offline', + printerError: 'Erro na Impressora', + filamentLow: 'Filamento Baixo', + maintenanceDue: 'Manutenção Pendente', + maintenanceDueDescription: 'Notificar quando a manutenção for necessária', + }, + // Smart Plugs + smartPlug: { + title: 'Tomadas Inteligentes', + add: 'Adicionar Tomada Inteligente', + edit: 'Editar Tomada Inteligente', + name: 'Nome', + ipAddress: 'Endereço IP', + linkedPrinter: 'Impressora Vinculada', + autoOn: 'Ligar Automaticamente', + autoOnDescription: 'Ligar quando a impressão começar', + autoOff: 'Desligar Automaticamente', + autoOffDescription: 'Desligar após a conclusão da impressão', + offDelay: 'Atraso para Desligar', + offDelayMinutes: 'Minutos após a impressão', + offDelayTemp: 'Quando o bico estiver abaixo da temperatura', + currentState: 'Estado Atual', + turnOn: 'Ligar', + turnOff: 'Desligar', + }, + // Filament Tracking Mode + filamentTracking: 'Rastreamento de Filamento', + filamentTrackingDesc: 'Escolha como rastrear seus rolos de filamento. Você pode usar o inventário interno ou conectar a um servidor Spoolman externo.', + trackingModeBuiltIn: 'Inventário Interno', + trackingModeBuiltInDesc: 'Correspondência automática de RFID e rastreamento de uso incluídos', + trackingModeSpoolmanDesc: 'Servidor de gerenciamento de filamento externo', + builtInFeatureRfid: 'Detecta automaticamente rolos RFID da Bambu Lab no AMS', + builtInFeatureUsage: 'Rastreia o consumo de filamento por impressão', + builtInFeatureCatalog: 'Gerencia rolos, cores e perfis de fator K', + builtInFeatureThirdParty: 'Rolos de terceiros podem ser atribuídos aos rolos do inventário', + amsSyncButton: 'Sincronizar Pesos do AMS', + amsSyncTitle: 'Sincronizar Pesos dos Rolos do AMS', + amsSyncMessage: 'Isso substituirá todos os pesos dos rolos do inventário pelos valores atuais de % restante do AMS das impressoras conectadas. Use isso para recuperar dados de peso corrompidos. As impressoras devem estar online.', + amsSyncing: 'Sincronizando...', + amsSyncSuccess: '{{synced}} rolo(s) sincronizado(s), {{skipped}} ignorado(s)', + amsSyncError: 'Falha ao sincronizar pesos do AMS', + // Spoolman settings + spoolmanUrl: 'Spoolman URL', + spoolmanUrlHint: 'URL do seu servidor Spoolman (por exemplo, http://localhost:7912)', + spoolmanConnected: 'Conectado', + spoolmanDisconnected: 'Desconectado', + status: 'Status', + connect: 'Conectar', + disconnect: 'Desconectar', + howSyncWorks: 'Como a Sincronização Funciona', + syncInfoRfidOnly: 'Apenas rolos oficiais da Bambu Lab com RFID são sincronizados', + syncInfoAutoCreate: 'Novos rolos são criados automaticamente no Spoolman na primeira sincronização', + syncInfoThirdPartySkipped: 'Rolos não oficiais da Bambu Lab (terceiros, reabastecidos) são ignorados', + linkingExistingSpools: 'Vinculando Rolos Existentes', + linkingExistingSpoolsDesc: 'Para vincular rolos existentes do Spoolman ao seu AMS, passe o mouse sobre um slot do AMS e clique em "Vincular ao Spoolman".', + syncMode: 'Modo de Sincronização', + syncModeAuto: 'Automático', + syncModeManual: 'Apenas Manual', + syncModeAutoDesc: 'Os dados do AMS são sincronizados automaticamente quando alterações são detectadas', + syncModeManualDesc: 'Somente sincronize quando acionado manualmente', + syncAmsData: 'Sincronizar Dados do AMS', + syncAmsDataDesc: 'Sincronize manualmente os dados do AMS da impressora com o Spoolman', + allPrinters: 'Todas as Impressoras', + // Default printer + noDefaultPrinter: 'Sem padrão (perguntar a cada vez)', + // Sidebar + sidebarOrder: 'Ordem da barra lateral', + // Camera + saveThumbnails: 'Salvar miniaturas', + captureFinishPhoto: 'Capturar foto de conclusão', + noPrintersConfigured: 'Nenhuma impressora configurada', + // Archive settings + archiveMode: { + always: 'Sempre criar entrada de arquivo', + never: 'Nunca criar entrada de arquivo', + ask: 'Perguntar a cada vez', + }, + // Updates + checkForUpdatesLabel: 'Verificar atualizações', + checkPrinterFirmware: 'Verificar firmware da impressora', + // Queue + enableRetry: 'Habilitar tentativa', + // Home Assistant + homeAssistantDescription: 'Controlar tomadas inteligentes via Home Assistant', + environmentManagedLabel: '(Gerenciado pelo Ambiente)', + autoEnabledViaEnv: 'Habilitado automaticamente via variáveis de ambiente', + urlFromEnvReadOnly: 'Valor definido pela variável de ambiente HA_URL (somente leitura)', + tokenFromEnvReadOnly: 'Valor definido pela variável de ambiente HA_TOKEN (somente leitura)', + // MQTT + mqttConnectedTo: 'Conectado a', + // Prometheus + prometheusDescription: 'Expor dados da impressora no formato Prometheus', + // Smart plugs empty state + noSmartPlugsTitle: 'Nenhuma tomada inteligente configurada', + noSmartPlugsDescription: 'Adicione uma tomada inteligente baseada em Tasmota para monitorar o consumo de energia e automatizar o controle de energia.', + // Notifications empty state + noProvidersTitle: 'Nenhum provedor configurado', + noProvidersDescription: 'Adicione um provedor para receber alertas.', + noTemplatesAvailable: 'Nenhum modelo disponível. Reinicie o backend para gerar os modelos padrão.', + // API permissions + apiPermissionView: 'Visualizar status da impressora e fila', + apiPermissionEdit: 'Adicionar e remover itens da fila de impressão', + // API keys + apiKeysEmptyTitle: 'Nenhuma chave API', + apiKeysEmptyDescription: 'Crie uma chave API para integrar com serviços externos.', + // Users + noUsersFound: 'Nenhum usuário encontrado', + noGroupsFound: 'Nenhum grupo encontrado', + noGroupsAvailable: 'Nenhum grupo disponível', + passwordsDoNotMatch: 'As senhas não coincidem', + systemGroupWarning: 'Os nomes dos grupos do sistema não podem ser alterados', + // Auth disabled + authDisabledTitle: 'Autenticação Desativada', + authDisabledFeature1: 'Exigir login para acessar o sistema', + authDisabledFeature2: 'Criar múltiplos usuários com permissões baseadas em grupos', + authDisabledFeature3: 'Controlar acesso com mais de 50 permissões granulares', + // User deletion + userHasCreated: 'Este usuário criou:', + userItemsQuestion: 'O que você gostaria de fazer com esses itens?', + deleteUserConfirm: 'Tem certeza de que deseja excluir este usuário?', + actionCannotBeUndone: 'Esta ação não pode ser desfeita.', + // Smart plugs + addFirstSmartPlug: 'Adicione sua primeira tomada inteligente', + // Notifications + providers: 'Provedores', + log: 'Registro', + testAll: 'Testar tudo', + testResults: 'Resultados do teste', + testPassedCount: '{{count}} aprovado', + testFailedCount: '{{count}} falhou', + messageTemplates: 'Modelos de mensagem', + messageTemplatesDescription: 'Personalize as mensagens de notificação para cada evento.', + // API Keys section + apiKeys: 'Chaves API', + apiKeysDescription: 'Crie chaves API para integrações externas e webhooks.', + createKey: 'Criar Chave', + apiKeyCreated: 'Chave API criada com sucesso', + apiKeyCopyWarning: "Copie esta chave agora - ela não será exibida novamente!", + useInApiBrowser: 'Usar no Navegador API', + createNewApiKey: 'Criar Nova Chave API', + keyName: 'Nome da Chave', + keyNamePlaceholder: 'e.g., Home Assistant, OctoPrint', + readStatus: 'Status de Leitura', + readStatusDescription: 'Visualizar status da impressora e fila', + manageQueue: 'Gerenciar Fila', + manageQueueDescription: 'Adicionar e remover itens da fila de impressão', + controlPrinter: 'Controlar Impressora', + controlPrinterDescription: 'Pausar, retomar e parar impressões', + unnamedKey: 'Chave Sem Nome', + lastUsed: 'Último uso', + read: 'Ler', + control: 'Controlar', + createFirstKey: 'Crie sua primeira chave', + webhookEndpoints: 'Endpoints de Webhook', + webhookApiKeyHint: 'Use sua chave API no cabeçalho X-API-Key.', + webhook: { + getAllStatus: 'Obter status de todas as impressoras', + getSpecificStatus: 'Obter status de uma impressora específica', + addToQueue: 'Adicionar à fila de impressão', + pausePrint: 'Pausar impressão', + resumePrint: 'Retomar impressão', + stopPrint: 'Parar impressão', + }, + apiBrowser: 'Navegador API', + apiBrowserDescription: 'Explore e teste todos os endpoints de API disponíveis.', + apiKeyForTesting: 'Chave API para Teste', + apiKeyPlaceholder: 'Cole sua chave API aqui para testar endpoints autenticados...', + apiKeyHint: 'Esta chave será enviada como cabeçalho X-API-Key nas solicitações.', + deleteApiKeyTitle: 'Excluir Chave API', + deleteApiKeyMessage: 'Tem certeza de que deseja excluir esta chave API? Quaisquer integrações usando esta chave deixarão de funcionar.', + deleteKey: 'Excluir Chave', + // Filament tab + amsDisplayThresholds: 'Limiares de Exibição AMS', + amsThresholdsDescription: 'Configure os limiares de cores para os indicadores de umidade e temperatura do AMS.', + humidity: 'Umidade', + goodGreen: 'Bom (verde)', + fairOrange: 'Razoável (laranja)', + aboveFairBad: 'Acima do limiar razoável mostra como vermelho (ruim)', + temperature: 'Temperatura', + goodBlue: 'Bom (azul)', + aboveFairHot: 'Acima do limiar razoável mostra como vermelho (quente)', + historyRetention: 'Retenção de Histórico', + keepSensorHistory: 'Manter histórico do sensor por', + historyRetentionDescription: 'Dados antigos de umidade e temperatura serão automaticamente excluídos', + printModal: 'Modal de Impressão', + expandCustomMapping: 'Expandir mapeamento personalizado por padrão', + expandCustomMappingDescription: 'Ao imprimir em várias impressoras, mostrar o mapeamento AMS por impressora expandido', + // User management + authentication: 'Autenticação', + authEnabledDescription: 'Sua instância está protegida com autenticação de usuário', + authDisabledDescription: 'Ative para exigir login e gerenciar o acesso dos usuários', + authDisabledMessage: 'Ative a autenticação para criar contas de usuário, gerenciar permissões e proteger sua instância do Bambuddy.', + enableAuthentication: 'Ativar Autenticação', + currentUser: 'Usuário Atual', + changePassword: 'Alterar Senha', + admin: 'Administrador', + users: 'Usuários', + addUser: 'Adicionar Usuário', + groups: 'Grupos', + addGroup: 'Adicionar Grupo', + system: 'Sistema', + noDescription: 'Sem descrição', + userCount: '{{count}} usuários', + permissionCount: '{{count}} permissões', + createUser: 'Criar Usuário', + username: 'Nome de Usuário', + enterUsername: 'Digite o nome de usuário', + password: 'Senha', + enterPassword: 'Digite a senha (mínimo 6 caracteres)', + confirmPassword: 'Confirmar Senha', + confirmPasswordPlaceholder: 'Confirme a senha', + // Title tooltips + viewReleaseOnGitHub: 'Ver lançamento no GitHub', + turnAllPlugsOn: 'Ligar todas as tomadas', + turnAllPlugsOff: 'Desligar todas as tomadas', + // Modal: Clear logs + clearNotificationLogs: 'Limpar Logs de Notificação', + clearLogsMessage: 'Isso excluirá permanentemente todos os logs de notificação com mais de 30 dias. Esta ação não pode ser desfeita.', + clearLogs: 'Limpar Logs', + // Modal: Reset UI + resetUiPreferences: 'Redefinir Preferências de UI', + resetUiPreferencesMessage: 'Isso redefinirá todas as preferências de UI para os padrões: ordem da barra lateral, tema, layout do painel, modos de exibição e preferências de classificação. Suas impressoras, arquivos e configurações do servidor NÃO serão afetados. A página será recarregada após a limpeza.', + resetPreferences: 'Redefinir Preferências', + // Modal: Delete group + deleteGroupTitle: 'Excluir Grupo', + deleteGroupMessage: 'Tem certeza de que deseja excluir este grupo? Usuários neste grupo perderão essas permissões.', + deleteGroup: 'Excluir Grupo', + // Modal: Disable auth + disableAuthenticationTitle: 'Desativar Autenticação', + disableAuthenticationMessage: 'Tem certeza de que deseja desativar a autenticação? Isso tornará sua instância do Bambuddy acessível sem login. Todos os usuários permanecerão no banco de dados, mas a autenticação será desativada.', + disableAuthentication: 'Desativar Autenticação', + // Additional settings + configureBambuddy: 'Configurar Bambuddy', + systemDefault: 'Padrão do Sistema', + archiveSettings: 'Configurações de Arquivo', + newWindow: 'Nova Janela', + embeddedOverlay: 'Sobreposição Incorporada', + preferredSlicer: 'Fatiador Preferido', + preferredSlicerDescription: 'Escolha qual aplicativo de fatiamento abrirá os arquivos', + externalCameras: 'Câmeras Externas', + costTracking: 'Rastreamento de Custos', + printsOnly: 'Apenas Impressões', + totalConsumption: 'Consumo Total', + dataManagement: 'Gerenciamento de Dados', + storageUsage: 'Uso de Armazenamento', + storageUsageDescription: 'Detalhamento do uso de dados por categoria', + storageUsageTotal: 'Total', + storageUsageErrors: 'Erros', + storageUsageOtherBreakdown: 'Outros (inclui ativos estáticos, scripts e arquivos de configuração)', + storageUsageSystem: 'Sistema', + storageUsageData: 'Dados', + storageUsageUnavailable: 'Informações de uso de armazenamento indisponíveis', + clearNotificationLogsDescription: 'Excluir logs de notificação com mais de 30 dias', + resetUiPreferencesDescription: 'Redefinir ordem da barra lateral, tema, modos de exibição e preferências de layout. Impressoras, arquivos e configurações não são afetados.', + enableHomeAssistant: 'Ativar Home Assistant', + enableMqtt: 'Ativar MQTT', + useTls: 'Usar TLS', + enableMetricsEndpoint: 'Ativar Endpoint de Métricas', + availableMetrics: 'Métricas Disponíveis', + editUser: 'Editar Usuário', + deleteUserTitle: 'Excluir Usuário', + groupName: 'Nome do Grupo', + // Placeholders + leaveEmptyForAnonymous: 'Deixe vazio para anônimo', + leaveEmptyForNoAuth: 'Deixe vazio para sem autenticação', + enterNewPassword: 'Digite a nova senha', + confirmNewPassword: 'Confirme a nova senha', + enterGroupName: 'Digite o nome do grupo', + enterDescriptionOptional: 'Digite a descrição (opcional)', + enterCurrentPassword: 'Digite a senha atual', + enterNewPasswordMin6: 'Digite a nova senha (mínimo 6 caracteres)', + toast: { + keyCopied: 'Chave copiada para a área de transferência', + copyFailed: 'Falha ao copiar a chave', + keyAddedToBrowser: 'Chave adicionada ao Navegador de API', + clearLogsFailed: 'Falha ao limpar logs', + uiPreferencesReset: 'Preferências de UI redefinidas. Atualizando...', + authDisabled: 'Autenticação desativada com sucesso', + authDisableFailed: 'Falha ao desativar a autenticação', + apiKeyCreated: 'Chave de API criada', + apiKeyDeleted: 'Chave de API excluída', + userCreated: 'Usuário criado com sucesso', + userUpdated: 'Usuário atualizado com sucesso', + userDeleted: 'Usuário excluído com sucesso', + groupCreated: 'Grupo criado com sucesso', + groupUpdated: 'Grupo atualizado com sucesso', + groupDeleted: 'Grupo excluído com sucesso', + fillRequiredFields: 'Por favor, preencha todos os campos obrigatórios', + passwordsDoNotMatch: 'As senhas não coincidem', + passwordTooShort: 'A senha deve ter pelo menos 6 caracteres', + enterGroupName: 'Por favor, insira um nome de grupo', + settingsSaved: 'Configurações salvas', + cameraSettingsSaved: 'Configurações da câmera salvas', + enterCameraUrl: 'Por favor, insira a URL da câmera', + passwordChanged: 'Senha alterada com sucesso', + connectionFailed: 'Falha na conexão', + testFailed: 'Falha no teste', + cameraConnected: 'Câmera conectada{{resolution}}', + }, + testConnection: 'Testar Conexão', + catalog: { + spoolCatalog: 'Catálogo de Carretéis', + spoolCatalogDescription: 'Pesos de carretéis vazios por marca/tipo. Usado para pesquisa automática de peso ao adicionar carretéis.', + searchCatalog: 'Pesquisar no catálogo...', + addNewEntry: 'Adicionar Nova Entrada', + namePlaceholder: 'Nome (ex.: Bambu Lab - Plástico)', + weight: 'Peso', + type: 'Tipo', + default: 'Padrão', + custom: 'Personalizado', + noMatch: 'Nenhuma entrada corresponde à sua pesquisa', + empty: 'Nenhuma entrada no catálogo', + deleteEntry: 'Excluir Entrada', + deleteConfirm: 'Tem certeza de que deseja excluir "{{name}}"?', + resetCatalog: 'Redefinir Catálogo', + resetConfirm: 'Redefinir catálogo para os padrões? Isso removerá todas as entradas personalizadas.', + loadFailed: 'Falha ao carregar o catálogo de carretéis', + nameWeightRequired: 'Nome e peso são obrigatórios', + entryAdded: 'Entrada adicionada', + addFailed: 'Falha ao adicionar entrada', + entryUpdated: 'Entrada atualizada', + updateFailed: 'Falha ao atualizar entrada', + entryDeleted: 'Entrada excluída', + deleteFailed: 'Falha ao excluir entrada', + resetSuccess: 'Catálogo redefinido para os padrões', + resetFailed: 'Falha ao redefinir catálogo', + exported: 'Exportadas {{count}} entradas', + imported: 'Importadas {{added}} entradas ({{skipped}} ignoradas)', + importFailed: 'Falha ao importar: formato JSON inválido', + exportTooltip: 'Exportar catálogo para JSON', + importTooltip: 'Importar catálogo de JSON', + resetTooltip: 'Redefinir para os padrões', + }, + colorCatalog: { + title: 'Catálogo de Cores', + description: 'Cores de filamento por fabricante/material. Usado para pesquisa automática de cores ao adicionar carretéis.', + searchColors: 'Pesquisar cores...', + allManufacturers: 'Todos os fabricantes', + addNewColor: 'Adicionar Nova Cor', + manufacturer: 'Fabricante', + colorName: 'Nome da Cor', + hex: 'Hex', + materialOptional: 'Material (opcional)', + showing: 'Mostrando {{filtered}} de {{total}} cores', + noMatch: 'Nenhuma cor corresponde à sua pesquisa', + empty: 'Nenhuma cor no catálogo', + deleteColor: 'Excluir Cor', + deleteConfirm: 'Tem certeza de que deseja excluir "{{name}}"?', + resetCatalog: 'Redefinir Catálogo de Cores', + resetConfirm: 'Redefinir catálogo para os padrões? Isso removerá todas as cores personalizadas.', + sync: 'Sincronizar', + starting: 'Iniciando...', + syncTooltip: 'Sincronizar do FilamentColors.xyz (2000+ cores, pode levar um minuto)', + loadFailed: 'Falha ao carregar o catálogo de cores', + fieldsRequired: 'Fabricante, nome da cor e cor hex são obrigatórios', + colorAdded: 'Cor adicionada', + addFailed: 'Falha ao adicionar cor', + colorUpdated: 'Cor atualizada', + updateFailed: 'Falha ao atualizar cor', + colorDeleted: 'Cor excluída', + deleteFailed: 'Falha ao excluir cor', + resetSuccess: 'Catálogo de cores redefinido para os padrões', + resetFailed: 'Falha ao redefinir catálogo', + syncUpToDate: 'Já está atualizado ({{count}} cores verificadas)', + syncComplete: 'Adicionadas {{added}} novas cores ({{skipped}} já existiam)', + syncError: 'Erro de sincronização', + syncFailed: 'Falha ao sincronizar do FilamentColors.xyz', + exported: 'Exportadas {{count}} cores', + imported: 'Importadas {{added}} cores ({{skipped}} ignoradas)', + importFailed: 'Falha ao importar: formato JSON inválido', + }, + }, + + // Notifications (for push notifications) + notification: { + printStarted: { + title: 'Impressão Iniciada', + body: '{{printer}}: {{filename}} iniciou a impressão', + }, + printCompleted: { + title: 'Impressão Concluída', + body: '{{printer}}: {{filename}} foi concluída com sucesso', + }, + printFailed: { + title: 'Falha na Impressão', + body: '{{printer}}: {{filename}} falhou', + }, + printStopped: { + title: 'Impressão Interrompida', + body: '{{printer}}: {{filename}} foi interrompida', + }, + printProgress: { + title: 'Progresso da Impressão', + body: '{{printer}}: {{filename}} está {{percent}}% concluída', + }, + printerOffline: { + title: 'Impressora Offline', + body: '{{printer}} está offline', + }, + printerError: { + title: 'Erro na Impressora', + body: '{{printer}}: {{error}}', + }, + filamentLow: { + title: 'Filamento Baixo', + body: '{{printer}}: O filamento está acabando', + }, + maintenanceDue: { + title: 'Manutenção Pendente', + body: '{{printer}}: {{items}} precisam de atenção', + }, + }, + + // Errors + errors: { + generic: 'Algo deu errado', + networkError: 'Erro de rede. Por favor, verifique sua conexão.', + notFound: 'Não encontrado', + unauthorized: 'Não autorizado', + serverError: 'Erro no servidor', + validationError: 'Por favor, verifique sua entrada', + printerConnectionFailed: 'Falha ao conectar à impressora', + saveFailed: 'Falha ao salvar alterações', + deleteFailed: 'Falha ao excluir', + loadFailed: 'Falha ao carregar dados', + }, + + // HMS Errors modal + hmsErrors: { + title: 'Erros - {{name}}', + noErrors: 'Nenhum erro', + viewOnWiki: 'Ver no Bambu Lab Wiki', + clearInstructions: 'Limpe os erros na impressora para descartá-los aqui.', + clearErrors: 'Limpar Erros', + clearSuccess: 'Erros HMS limpos', + clearFailed: 'Falha ao limpar erros HMS', + }, + + // MQTT Debug modal + mqttDebug: { + title: 'MQTT Log de Depuração', + searchPlaceholder: 'Pesquisar tópico ou payload...', + noMessages: 'Nenhuma mensagem registrada ainda', + startLoggingHint: 'Clique em "Iniciar Registro" para começar a capturar mensagens MQTT', + noMessagesMatch: 'Nenhuma mensagem corresponde ao seu filtro', + adjustFilterHint: 'Tente ajustar seus critérios de pesquisa ou filtro', + incoming: 'Entrada', + outgoing: 'Saída', + loggingStopped: 'Registro interrompido', + loggingActive: 'Registro ativo - as mensagens serão atualizadas automaticamente', + startLogging: 'Iniciar Registro', + stopLogging: 'Parar Registro', + clearLog: 'Limpar Registro', + topic: 'ópico', + timestamp: 'Carimbo de Data/Hora', + direction: 'Direção', + all: 'Todos', + }, + + // Printer File Manager modal (printer internal storage) + printerFiles: { + title: 'Gerenciador de Arquivos', + storageUsed: 'Usado:', + storageFree: 'Livre:', + filterPlaceholder: 'Filtrar arquivos...', + deleteButton: 'Excluir', + deleteFiles: 'Excluir {{count}} arquivos', + deleteFileConfirm: 'Excluir "{{name}}"? Isso não pode ser desfeito.', + deleteFilesConfirm: 'Excluir {{count}} arquivos selecionados? Isso não pode ser desfeito.', + noFiles: 'Nenhum arquivo na impressora', + loadingFiles: 'Carregando arquivos...', + failedToLoad: 'Falha ao carregar arquivos', + toast: { + filesDeleted: 'Arquivos excluídos: {{count}}', + deleteFailed: 'Falha ao excluir: {{error}}', + }, + }, + + // Confirmations + confirm: { + delete: 'Tem certeza de que deseja excluir isso?', + unsavedChanges: 'Você tem alterações não salvas. Tem certeza de que deseja sair?', + clearQueue: 'Tem certeza de que deseja limpar a fila?', + }, + + // Login page + login: { + title: 'Bambuddy Login', + subtitle: 'Faça login na sua conta', + username: 'Nome de usuário', + usernamePlaceholder: 'Digite seu nome de usuário', + usernameOrEmail: 'Nome de usuário ou Email', + usernameOrEmailPlaceholder: 'Nome de usuário ou Email', + password: 'Senha', + passwordPlaceholder: 'Digite sua senha', + signIn: 'Entrar', + signingIn: 'Entrando...', + forgotPassword: 'Esqueceu sua senha?', + loginSuccess: 'Login realizado com sucesso', + loginFailed: 'Falha no login', + enterCredentials: 'Por favor, insira nome de usuário e senha', + forgotPasswordTitle: 'Esqueceu a Senha', + forgotPasswordMessage: "Se você esqueceu sua senha, entre em contato com o administrador do sistema para redefini-la.", + forgotPasswordEmailMessage: "Digite seu endereço de email e enviaremos uma nova senha.", + emailAddress: 'Endereço de Email', + emailPlaceholder: 'seu.email@exemplo.com', + cancel: 'Cancelar', + sending: 'Enviando...', + sendResetEmail: 'Enviar Email de Redefinição', + howToReset: 'Como redefinir sua senha:', + resetStep1: 'Entre em contato com o administrador do Bambuddy', + resetStep2: 'Peça para redefinir sua senha na Gestão de Usuários', + resetStep3: 'Eles podem definir uma nova senha temporária para você', + resetStep4: 'Faça login com a nova senha e altere-a nas Configurações', + gotIt: 'Entendi', + }, + + // Setup page + setup: { + title: 'Bambuddy Configuração', + subtitle: 'Configure a autenticação para sua instância do Bambuddy', + enableAuth: 'Ativar Autenticação', + adminAccount: 'Conta de Administrador', + adminAccountDesc: 'Se usuários administradores já existirem, a autenticação será ativada usando as contas de administrador existentes. Deixe os campos abaixo vazios para usar os administradores existentes ou insira novas credenciais para criar um novo usuário administrador.', + adminUsername: 'Nome de usuário do administrador', + adminPassword: 'Senha do administrador', + optionalIfAdminExists: '(opcional se usuários administradores existirem)', + adminUsernamePlaceholder: 'Digite o nome de usuário do administrador (opcional)', + adminPasswordPlaceholder: 'Digite a senha do administrador (opcional)', + confirmPassword: 'Confirmar Senha', + confirmPasswordPlaceholder: 'Confirme a senha do administrador', + settingUp: 'Configurando...', + completeSetup: 'Concluir Configuração', + toast: { + authEnabledAdminCreated: 'Autenticação ativada e usuário administrador criado', + authEnabledExistingAdmins: 'Autenticação ativada usando usuários administradores existentes', + setupCompleted: 'Configuração concluída', + enterBothCredentials: 'Por favor, insira o nome de usuário e a senha do administrador, ou deixe ambos vazios para usar os usuários administradores existentes', + passwordsDoNotMatch: 'As senhas não coincidem', + passwordTooShort: 'A senha deve ter pelo menos 6 caracteres', + }, + }, + + // Password change + changePassword: { + title: 'Alterar Senha', + currentPassword: 'Senha Atual', + currentPasswordPlaceholder: 'Digite a senha atual', + newPassword: 'Nova Senha', + newPasswordPlaceholder: 'Digite a nova senha (mínimo 6 caracteres)', + confirmPassword: 'Confirmar Senha', + confirmPasswordPlaceholder: 'Confirme a nova senha', + passwordsDoNotMatch: 'As senhas não coincidem', + passwordTooShort: 'A senha deve ter pelo menos 6 caracteres', + changing: 'Alterando...', + success: 'Senha alterada com sucesso', + failed: 'Falha ao alterar a senha', + }, + + // Plate detection alert + plateAlert: { + title: 'Impressão Pausada!', + message: 'Objetos detectados na mesa de impressão. A impressão foi automaticamente pausada. Por favor, limpe a mesa e retome a impressão.', + understand: 'Entendi', + }, + + // Camera page + camera: { + title: 'Visualização da Câmera', + invalidPrinterId: 'ID da impressora inválido', + live: 'Ao Vivo', + snapshot: 'Captura', + restartStream: 'Reiniciar transmissão', + refreshSnapshot: 'Atualizar captura', + fullscreen: 'Tela Cheia', + exitFullscreen: 'Sair da Tela Cheia', + connectingToCamera: 'Conectando à câmera...', + capturingSnapshot: 'Capturando imagem...', + connectionLost: 'Conexão perdida', + connectionFailed: 'Falha na conexão com a câmera', + reconnecting: 'Reconectando em {{countdown}}s... (tentativa {{attempt}}/{{max}})', + reconnectNow: 'Reconectar agora', + cameraUnavailable: 'Câmera indisponível', + cameraUnavailableDesc: 'Certifique-se de que a impressora está ligada e conectada.', + noCamera: 'Nenhuma câmera disponível', + retry: 'Tentar novamente', + cameraStream: 'Transmissão da câmera', + zoomOut: 'Reduzir zoom', + zoomIn: 'Aumentar zoom', + resetZoom: 'Redefinir zoom', + recording: 'Gravando', + startRecording: 'Iniciar gravação', + stopRecording: 'Parar gravação', + chamberLight: 'Alternar luz da câmara', + }, + + // Groups management + groups: { + title: 'Gerenciamento de Grupos', + subtitle: 'Gerenciar grupos de permissão para controle de acesso', + backToSettings: 'Voltar para Configurações', + createGroup: 'Criar Grupo', + noPermission: 'Você não tem permissão para acessar esta página.', + system: 'Sistema', + noDescription: 'Sem descrição', + usersCount: '{{count}} usuários', + permissionsCount: '{{count}} permissões', + edit: 'Editar', + delete: 'Excluir', + toast: { + created: 'Grupo criado com sucesso', + updated: 'Grupo atualizado com sucesso', + deleted: 'Grupo excluído com sucesso', + enterGroupName: 'Por favor, insira um nome para o grupo', + }, + modal: { + editGroup: 'Editar Grupo', + createGroup: 'Criar Grupo', + cancel: 'Cancelar', + saving: 'Salvando...', + creating: 'Criando...', + saveChanges: 'Salvar Alterações', + }, + form: { + groupName: 'Nome do Grupo', + groupNamePlaceholder: 'Insira o nome do grupo', + systemGroupWarning: 'Os nomes dos grupos do sistema não podem ser alterados', + description: 'Descrição', + descriptionPlaceholder: 'Insira a descrição (opcional)', + permissions: 'Permissões ({{count}} selecionadas)', + }, + deleteModal: { + title: 'Excluir Grupo', + message: 'Tem certeza de que deseja excluir este grupo? Os usuários deste grupo perderão essas permissões.', + confirm: 'Excluir Grupo', + }, + }, + + // Users management + users: { + title: 'Gerenciamento de Usuários', + subtitle: 'Gerenciar usuários e seu acesso à sua instância do Bambuddy', + backToSettings: 'Voltar para Configurações', + createUser: 'Criar Usuário', + noPermission: 'Você não tem permissão para acessar esta página.', + admin: 'Admin', + noGroups: 'Sem grupos', + active: 'Ativo', + inactive: 'Inativo', + edit: 'Editar', + delete: 'Excluir', + system: 'Sistema', + noGroupsAvailable: 'Nenhum grupo disponível', + table: { + username: 'Nome de Usuário', + groups: 'Grupos', + status: 'Status', + actions: 'Ações', + }, + toast: { + created: 'Usuário criado com sucesso', + updated: 'Usuário atualizado com sucesso', + deleted: 'Usuário excluído com sucesso', + fillRequired: 'Por favor, preencha todos os campos obrigatórios', + passwordsDoNotMatch: 'As senhas não coincidem', + passwordTooShort: 'A senha deve ter pelo menos 6 caracteres', + }, + modal: { + createUser: 'Criar Usuário', + editUser: 'Editar Usuário', + cancel: 'Cancelar', + creating: 'Criando...', + saving: 'Salvando...', + saveChanges: 'Salvar Alterações', + advancedAuthSubtitle: 'com Autenticação Avançada', + }, + form: { + username: 'Nome de Usuário', + usernamePlaceholder: 'Insira o nome de usuário', + email: 'Email', + emailPlaceholder: 'user@example.com', + password: 'Senha', + passwordPlaceholder: 'Insira a senha', + confirmPassword: 'Confirmar Senha', + confirmPasswordPlaceholder: 'Confirme a senha', + newPasswordPlaceholder: 'Insira a nova senha', + confirmNewPasswordPlaceholder: 'Confirme a nova senha', + leaveBlankToKeep: 'deixe em branco para manter a atual', + groups: 'Grupos', + optional: 'opcional', + autoGeneratedPassword: 'Uma senha segura será gerada automaticamente e enviada por e-mail ao usuário.', + passwordManagedByAdvancedAuth: 'A senha é gerenciada pela Autenticação Avançada. Use "Redefinir Senha" para enviar uma nova senha ao usuário por e-mail.', + resetPassword: 'Redefinir Senha', + resettingPassword: 'Redefinindo Senha...', + }, + deleteModal: { + title: 'Excluir Usuário', + message: 'Tem certeza de que deseja excluir este usuário? Esta ação não pode ser desfeita.', + confirm: 'Excluir Usuário', + }, + }, + + // Stream overlay + streamOverlay: { + title: 'Stream Overlay', + invalidPrinterId: 'ID da impressora inválido', + cameraStream: 'Transmissão da câmera', + progress: 'Progresso da impressão', + eta: 'ETA', + printerIdle: 'Impressora ociosa', + printerOffline: 'Impressora offline', + status: { + printing: 'Imprimindo', + paused: 'Pausado', + finished: 'Concluído', + failed: 'Falhou', + idle: 'Ocioso', + unknown: 'Desconhecido', + }, + }, + + // Profiles + profiles: { + title: 'Perfis', + subtitle: 'Gerencie seus presets de fatiador e calibrações de avanço de pressão', + tabs: { + cloud: 'Perfis na Nuvem', + local: 'Perfis Locais', + kprofiles: 'K-Perfis', + }, + localProfiles: { + title: 'Perfis Locais', + subtitle: 'Importe e gerencie presets de fatiador do OrcaSlicer', + import: 'Importar Perfis', + importDesc: 'Solte arquivos .bbscfg, .bbsflmt, .orca_filament, .zip ou .json aqui', + importing: 'Importando...', + search: 'Pesquisar presets locais...', + noPresets: 'Nenhum preset local ainda', + badge: 'Local', + edit: 'Editar', + delete: 'Excluir', + cancel: 'Cancelar', + deleteConfirmTitle: 'Excluir Preset', + deleteConfirm: 'Tem certeza de que deseja excluir este preset? Esta ação não pode ser desfeita.', + source: 'Fonte', + inheritsFrom: 'Herdado de', + filamentType: 'Tipo', + vendor: 'Fornecedor', + compatiblePrinters: 'Impressoras Compatíveis', + nozzleTemp: 'Temperatura do Bico', + cost: 'Custo', + density: 'Densidade', + pressureAdvance: 'Avanço de Pressão', + filament: 'Filamento', + process: 'Processo', + printer: 'Impressora', + toast: { + importSuccess: '{{count}} preset(s) importada(s)', + importSkipped: '{{count}} preset(s) ignorada(s) (duplicadas)', + importError: '{{count}} erro(s) durante a importação', + deleted: 'Preset excluído', + updated: 'Preset atualizado', + }, + }, + connectedAs: 'Conectado como', + logout: 'Sair', + noLogoutPermission: 'Você não tem permissão para sair', + failedToLoad: 'Falha ao carregar perfis', + retry: 'Tentar novamente', + time: { + justNow: 'Agora mesmo', + minsAgo: 'há {{count}} minutos', + hoursAgo: 'há {{count}} horas', + daysAgo: 'há {{count}} dias', + }, + toast: { + loggedOut: 'Desconectado', + }, + login: { + title: 'Conectar ao Bambu Cloud', + subtitle: 'Sincronize seus presets de fatiador entre dispositivos', + email: 'Email', + password: 'Senha', + region: 'Região', + regionGlobal: 'Global', + regionChina: 'China', + verificationCode: 'Código de Verificação', + totpCode: 'Código do Autenticador', + checkEmail: 'Verifique seu email ({{email}}) para um código de 6 dígitos', + enterTotpHint: 'Digite o código de 6 dígitos do seu aplicativo autenticador', + accessToken: 'Token de Acesso', + accessTokenHint: 'Cole seu token de acesso Bambu Lab (do Bambu Studio)', + back: 'Voltar', + loginButton: 'Entrar', + verifyButton: 'Verificar', + setTokenButton: 'Definir Token', + useToken: 'Usar token de acesso em vez disso', + useEmail: 'Entrar com email em vez disso', + toast: { + loggedIn: 'Conectado com sucesso', + codeSent: 'Código de verificação enviado para seu email', + enterTotp: 'Digite o código do seu aplicativo autenticador', + tokenSet: 'Token definido com sucesso', + }, + }, + presets: { + myPreset: 'Meu preset (editável)', + duplicate: 'Duplicar', + editable: 'Editável', + failedToLoadDetails: 'Falha ao carregar detalhes do preset', + deleteConfirm: 'Excluir este preset?', + deleteWarning: 'Isso excluirá permanentemente "{{name}}" do Bambu Cloud. Esta ação não pode ser desfeita.', + noDuplicatePermission: 'Você não tem permissão para duplicar presets', + noEditPermission: 'Você não tem permissão para editar presets', + noDeletePermission: 'Você não tem permissão para excluir presets', + types: { + filament: 'Preset de filamento', + printer: 'Preset de impressora', + process: 'Preset de processo', + }, + toast: { + deleted: 'Preset excluído', + created: 'Preset criado', + updated: 'Preset atualizado', + duplicated: 'Preset duplicado', + fieldAdded: 'Campo "{{key}}" adicionado', + exported: 'Preset exportado', + }, + baseLabel: 'Base: {{name}}', + currentLabel: 'Atual: {{name}}', + newPreset: 'Novo Preset', + editPreset: 'Editar Preset', + duplicatePreset: 'Duplicar Preset', + createNewPreset: 'Criar Novo Preset', + customizeSettings: 'Personalizar configurações para seu novo preset', + compareWithBase: 'Comparar com o preset base', + compare: 'Comparar', + // CreatePresetModal - Basic Info + basePreset: 'Preset Base', + selectBasePreset: 'Selecionar preset base...', + presetName: 'Nome do Preset', + myCustomPreset: 'Meu preset personalizado', + inheritsFrom: 'Herdado de', + dropJsonToImport: 'Solte o arquivo JSON para importar', + // CreatePresetModal - Tabs + tabs: { + common: 'Comum', + allFields: 'Todos os Campos', + }, + // CreatePresetModal - All Fields Tab + availableFields: 'Campos Disponíveis', + searchFieldsPlaceholder: 'Pesquisar campos...', + noMatchingFields: 'Nenhum campo correspondente', + allFieldsAdded: 'Todos os campos adicionados', + addCustomField: 'Adicionar campo personalizado', + yourOverrides: 'Suas Substituições', + noOverridesYet: 'Nenhuma substituição ainda', + clickFieldsToAdd: 'Clique nos campos à esquerda para adicioná-los', + saveAsTemplate: 'Salvar como modelo', + jsonTip: 'Dica: Arraste e solte um arquivo .json em qualquer lugar deste modal para importar configurações', + }, + cloudView: { + searchPlaceholder: 'Pesquisar presets...', + templates: 'Modelos', + refresh: 'Atualizar', + newPreset: 'Novo Preset', + clearFilters: 'Limpar filtros', + // Compare mode + compareMode: 'Modo de Comparação', + selectAnotherPreset: 'Selecionar outro preset {{type}}', + clickTwoPresets: 'Clique em dois presets do mesmo tipo para comparar', + selectFirst: '1. Selecionar primeiro', + selectSecond: '2. Selecionar segundo', + compareNow: 'Comparar Agora', + // Status row + lastSynced: 'Última sincronização:', + showingCount: 'Mostrando {{showing}} de {{total}} presets', + noPresetsFound: 'Nenhum preset encontrado', + // Column headers + columns: { + filament: 'Filamento', + process: 'Processo', + printer: 'Impressora', + }, + noFilamentPresets: 'Nenhum preset de filamento', + noProcessPresets: 'Nenhum preset de processo', + noPrinterPresets: 'Nenhum preset de impressora', + // Filters + filters: { + type: 'Tipo', + owner: 'Proprietário', + printer: 'Impressora', + nozzle: 'Bico', + filament: 'Filamento', + layer: 'Camada', + all: 'Todos', + myPresets: 'Meus Presets', + builtIn: 'Integrado', + process: 'Processo', + }, + // Permissions + noTemplatesPermission: 'Você não tem permissão para gerenciar modelos', + noRefreshPermission: 'Você não tem permissão para atualizar perfis', + noCreatePermission: 'Você não tem permissão para criar presets', + }, + templates: { + title: 'Modelos Rápidos', + noTemplates: 'Nenhum modelo ainda', + createFirst: 'Crie modelos a partir do editor de presets', + typeFilter: 'Tipo:', + deleteTitle: 'Excluir Modelo', + deleteWarning: 'Esta ação não pode ser desfeita', + deleteConfirm: 'Tem certeza de que deseja excluir "{{name}}"?', + namePlaceholder: 'Nome do modelo', + descriptionPlaceholder: 'Descrição', + settingsJson: 'Configurações (JSON)', + fieldsCount: '{{count}} campos', + shownInModals: 'Exibido em modais', + hiddenInModals: 'Oculto em modais', + apply: 'Aplicar', + toast: { + deleted: 'Modelo excluído', + updated: 'Modelo atualizado', + created: 'Modelo criado', + applied: 'Modelo aplicado', + }, + }, + }, + + // Support/Debug + support: { + debugLoggingActive: 'Registro de depuração ativo', + manageLogs: 'Gerenciar', + collectItem7: 'Conectividade da impressora e versões de firmware', + collectItem8: 'Status de integração (Spoolman, MQTT, HA)', + collectItem9: 'Interfaces de rede (somente sub-redes)', + collectItem10: 'Versões de pacotes Python', + collectItem11: 'Verificações de integridade do banco de dados', + collectItem12: 'Detalhes do ambiente Docker', + }, + + // File manager + fileManager: { + title: 'Gerenciador de Arquivos', + subtitle: 'Organize e gerencie seus arquivos de impressão', + uploadFiles: 'Enviar Arquivos', + newFolder: 'Nova Pasta', + folderName: 'Nome da Pasta', + folderNamePlaceholder: 'ex.: Peças Funcionais', + renameFile: 'Renomear Arquivo', + renameFolder: 'Renomear Pasta', + moveFiles: 'Mover {{count}} Arquivo(s)', + rootNoFolder: 'Raiz (Sem Pasta)', + current: 'Atual', + linkFolder: 'Vincular Pasta', + linkFolderDescription: 'Vincular "{{name}}" a um projeto ou arquivo para acesso rápido.', + project: 'Projeto', + archive: 'Arquivo', + noProjectsFound: 'Nenhum projeto encontrado', + noArchivesFound: 'Nenhum arquivo encontrado', + unlink: 'Desvincular', + link: 'Vincular', + dragDropFiles: 'Arraste e solte os arquivos aqui', + dropFilesHere: 'Solte os arquivos aqui', + orClickToBrowse: 'ou clique para procurar', + allFileTypesSupported: 'Todos os tipos de arquivos são suportados. Arquivos ZIP serão extraídos.', + zipFilesDetected: 'Arquivos ZIP detectados', + zipExtractOptions: 'Arquivos ZIP serão extraídos. Escolha como lidar com a estrutura de pastas:', + preserveZipStructure: 'Preservar estrutura de pastas do ZIP', + createFolderFromZip: 'Criar pasta a partir do nome do arquivo ZIP', + stlThumbnailGeneration: 'Geração de miniaturas STL', + zipMayContainStl: 'Arquivos ZIP podem conter arquivos STL. Miniaturas podem ser geradas durante a extração.', + thumbnailsCanBeGenerated: 'Miniaturas podem ser geradas para arquivos STL. Modelos grandes podem levar mais tempo para processar.', + generateThumbnailsForStl: 'Gerar miniaturas para arquivos STL', + threemfDetected: 'Arquivos 3MF detectados', + threemfExtractionInfo: 'Modelo da impressora, material, cor e configurações de impressão serão extraídos automaticamente dos arquivos 3MF.', + willBeExtracted: 'Será extraído', + filesExtracted: '{{count}} arquivos extraídos', + uploadComplete: 'Upload concluído: {{succeeded}} bem-sucedidos', + uploadFailed: '{{count}} falhou', + uploading: 'Enviando...', + changeLink: 'Alterar link...', + linkTo: 'Vincular a...', + linkToProjectOrArchive: 'Vincular a projeto ou arquivo', + addToQueue: 'Adicionar à fila', + schedulePrint: 'Agendar impressão', + generateThumbnail: 'Gerar miniatura', + generateThumbnails: 'Gerar miniaturas', + generateThumbnailsForMissing: 'Gerar miniaturas para arquivos STL que não possuem', + gridView: 'Visualização em grade', + listView: 'Visualização em lista', + lowDiskSpaceWarning: 'Aviso de pouco espaço em disco', + lowDiskSpaceDetails: 'Apenas {{free}} livres de {{total}} no total. O limite está definido para {{threshold}} GB nas configurações.', + files: 'Arquivos', + folders: 'Pastas', + size: 'Tamanho', + free: 'Livre', + allFiles: 'Todos os arquivos', + wrap: 'Quebrar texto', + enableTextWrapping: 'Ativar quebra de texto', + disableTextWrapping: 'Desativar quebra de texto', + dragToResizeTooltip: 'Arraste para redimensionar, clique duas vezes para redefinir', + searchFiles: 'Pesquisar arquivos...', + allTypes: 'Todos os tipos', + prints: 'Impressões', + ascending: 'Crescente', + descending: 'Decrescente', + resultsCount: '{{showing}} de {{total}} arquivos', + selectAll: 'Selecionar tudo', + deselectAll: 'Desmarcar tudo', + selected: '{{count}} selecionado(s)', + adding: 'Adicionando...', + loadingFiles: 'Carregando arquivos...', + folderIsEmpty: 'A pasta está vazia', + noFilesYet: 'Nenhum arquivo ainda', + folderEmptyDescription: 'Envie arquivos ou mova arquivos para esta pasta para começar.', + noFilesDescription: 'Envie arquivos para começar a organizar seus arquivos relacionados à impressão.', + noMatchingFiles: 'Nenhum arquivo correspondente', + noMatchingFilesDescription: 'Nenhum arquivo corresponde aos seus critérios de pesquisa ou filtro.', + clearFilters: 'Limpar filtros', + printedCount: 'Impresso {{count}}x', + uploadedBy: 'Enviado por', + deleteFolder: 'Excluir pasta', + deleteFile: 'Excluir arquivo', + deleteFilesCount: 'Excluir {{count}} arquivos', + deleteFolderConfirm: 'Tem certeza de que deseja excluir esta pasta? Todos os arquivos dentro também serão excluídos.', + deleteFileConfirm: 'Tem certeza de que deseja excluir este arquivo?', + deleteFilesConfirm: 'Tem certeza de que deseja excluir {{count}} arquivos selecionados? Esta ação não pode ser desfeita.', + deleting: 'Excluindo...', + noPermissionRenameFolder: 'Você não tem permissão para renomear pastas', + noPermissionLinkFolder: 'Você não tem permissão para vincular pastas', + noPermissionDeleteFolder: 'Você não tem permissão para excluir pastas', + noPermissionPrint: 'Você não tem permissão para imprimir', + noPermissionAddToQueue: 'Você não tem permissão para adicionar à fila', + noPermissionDownload: 'Você não tem permissão para baixar arquivos', + noPermissionRenameFile: 'Você não tem permissão para renomear este arquivo', + noPermissionGenerateThumbnail: 'Você não tem permissão para gerar miniaturas', + noPermissionDeleteFile: 'Você não tem permissão para excluir este arquivo', + noPermissionCreateFolder: 'Você não tem permissão para criar pastas', + noPermissionUpload: 'Você não tem permissão para enviar arquivos', + noPermissionMoveFiles: 'Você não tem permissão para mover arquivos', + noPermissionDeleteFiles: 'Você não tem permissão para excluir arquivos', + toast: { + folderCreated: 'Pasta criada', + folderDeleted: 'Pasta excluída', + fileDeleted: 'Arquivo excluído', + filesDeleted: 'Excluídos {{count}} arquivos', + filesMoved: 'Arquivos movidos', + folderLinked: 'Pasta vinculada', + folderUnlinked: 'Pasta desvinculada', + addedToQueue: 'Adicionado {{count}} arquivo(s) à fila', + addedToQueuePartial: 'Adicionado {{added}} arquivo(s), {{failed}} falharam', + failedToAddToQueue: 'Falha ao adicionar arquivos: {{error}}', + fileRenamed: 'Arquivo renomeado', + folderRenamed: 'Pasta renomeada', + thumbnailsGenerated: 'Geradas {{count}} miniatura(s)', + thumbnailsGeneratedPartial: 'Geradas {{succeeded}} miniatura(s), {{failed}} falharam', + noStlMissingThumbnails: 'Nenhum arquivo STL sem miniatura', + failedToGenerateThumbnails: 'Falha ao gerar miniaturas: {{error}}', + thumbnailGenerated: 'Miniatura gerada', + failedToGenerateThumbnail: 'Falha ao gerar miniatura: {{error}}', + }, + }, + + // Projects + projects: { + title: 'Projetos', + subtitle: 'Organize e acompanhe seus projetos de impressão 3D', + newProject: 'Novo Projeto', + editProject: 'Editar Projeto', + deleteProject: 'Excluir Projeto', + projectName: 'Nome do Projeto', + description: 'Descrição', + noProjects: 'Nenhum projeto ainda', + noProjectsFiltered: 'Nenhum projeto {{status}}', + noProjectsFilteredHelp: "Você não tem nenhum projeto {{status}}. Os projetos aparecerão aqui quando seu status mudar.", + createFirst: 'Crie seu primeiro projeto para começar a organizar impressões relacionadas, acompanhar o progresso e gerenciar suas construções.', + createFirstButton: 'Crie Seu Primeiro Projeto', + create: 'Criar', + files: 'Arquivos', + prints: 'Impressões', + plates: 'Placas', + parts: 'Peças', + lastModified: 'Última Modificação', + deleteConfirm: 'Tem certeza de que deseja excluir este projeto? Arquivos e itens da fila serão desvinculados, mas não excluídos.', + addFiles: 'Adicionar Arquivos', + removeFile: 'Remover Arquivo', + viewDetails: 'Ver Detalhes', + // Modal fields + namePlaceholder: 'ex., Voron 2.4 Build', + descriptionPlaceholder: 'Descrição opcional...', + color: 'Cor', + targetPlates: 'Placas Alvo', + targetPlatesPlaceholder: 'ex., 25', + targetPlatesHelp: 'Número de trabalhos de impressão', + targetParts: 'Peças Alvo', + targetPartsPlaceholder: 'ex., 150', + targetPartsHelp: 'Total de objetos necessários', + tagsLabel: 'Tags (separadas por vírgula)', + tagsPlaceholder: 'ex., voron, funcional, presente', + dueDate: 'Data de Vencimento', + priority: 'Prioridade', + priorityLow: 'Baixa', + priorityNormal: 'Normal', + priorityHigh: 'Alta', + priorityUrgent: 'Urgente', + // Status + statusActive: 'Ativo', + statusCompleted: 'Concluído', + statusArchived: 'Arquivado', + done: 'Concluído', + completed: 'Concluído', + failed: 'Falhou', + inQueue: 'Na fila', + noPrintsYet: 'Nenhuma impressão ainda', + // Footer stats + printJobs: 'Trabalhos de impressão (placas)', + partsPrinted: 'Peças impressas', + failedParts: 'Peças falhadas', + // Actions + import: 'Importar', + export: 'Exportar', + importProject: 'Importar projeto', + exportAll: 'Exportar todos os projetos', + loading: 'Carregando projetos...', + // Permissions + noEditPermission: 'Você não tem permissão para editar projetos', + noDeletePermission: 'Você não tem permissão para excluir projetos', + noCreatePermission: 'Você não tem permissão para criar projetos', + noImportPermission: 'Você não tem permissão para importar projetos', + noExportPermission: 'Você não tem permissão para exportar projetos', + // Toast + toast: { + created: 'Projeto criado', + updated: 'Projeto atualizado', + deleted: 'Projeto excluído', + imported: 'Projeto importado', + multipleImported: '{{count}} projetos importados', + importFailed: 'Falha na importação', + exported: 'Projetos exportados (apenas metadados)', + }, + }, + + // Project detail page + projectDetail: { + notFound: 'Projeto não encontrado', + backToProjects: 'Voltar para Projetos', + export: 'Exportar', + exportProject: 'Exportar projeto', + noExportPermission: 'Você não tem permissão para exportar projetos', + noEditPermission: 'Você não tem permissão para editar projetos', + partOf: 'Parte de:', + priorityLabel: 'Prioridade:', + noPrints: 'Nenhuma impressão neste projeto ainda', + status: { + active: 'Ativo', + completed: 'Concluído', + archived: 'Arquivado', + }, + priority: { + low: 'Baixa', + normal: 'Normal', + high: 'Alta', + urgent: 'Urgente', + }, + dueDate: { + overdue: 'Atrasado', + today: 'Vence hoje', + daysLeft: '{{count}} dias restantes', + }, + progress: { + platesProgress: 'Progresso das Placas', + partsProgress: 'Progresso das Peças', + printJobs: 'Trabalhos de Impressão', + parts: 'Peças', + percentComplete: '{{percent}}% concluído', + remaining: '{{count}} restantes', + }, + stats: { + printJobs: 'Trabalhos de Impressão', + total: 'total', + failed: '{{count}} falhou', + partsPrinted: '{{count}} peças impressas', + printTime: 'Tempo de Impressão', + filamentUsed: 'Filamento Usado', + }, + cost: { + title: 'Rastreamento de Custos', + filamentCost: 'Custo do Filamento', + energy: 'Energia', + budget: 'Orçamento', + remaining: 'Restante', + }, + subProjects: { + title: 'Sub-projetos ({{count}})', + }, + notes: { + title: 'Notas', + noEditPermission: 'Você não tem permissão para editar notas', + placeholder: 'Adicione notas sobre este projeto...', + empty: 'Nenhuma nota ainda. Clique em Editar para adicionar notas.', + }, + files: { + title: 'Arquivos', + linkFolders: 'Vincular pastas do Gerenciador de Arquivos', + forQuickAccess: 'a este projeto para acesso rápido.', + fileCount: '{{count}} arquivo(s)', + empty: 'Nenhuma pasta vinculada. Vá para o Gerenciador de Arquivos e vincule uma pasta a este projeto.', + }, + bom: { + title: 'Lista de Materiais', + acquired: '{{completed}}/{{total}} adquiridos', + showAll: 'Mostrar todos', + hideDone: 'Ocultar concluídos', + addPart: 'Adicionar Peça', + noAddPermission: 'Você não tem permissão para adicionar peças', + partNamePlaceholder: 'Nome da peça (ex.: parafusos M3x8)', + partName: 'Nome da peça', + qty: 'Quantidade', + price: 'Preço ({{currency}})', + sourcingUrlPlaceholder: 'URL de fornecimento (opcional)', + remarksPlaceholder: 'Observações (opcional)', + deletePart: 'Excluir Peça', + deleteConfirm: 'Tem certeza de que deseja excluir "{{name}}"?', + noUpdatePermission: 'Você não tem permissão para atualizar peças', + noEditPermission: 'Você não tem permissão para editar peças', + noDeletePermission: 'Você não tem permissão para excluir peças', + totalCost: 'Custo total:', + empty: 'Nenhuma peça na lista de materiais. Adicione hardware, eletrônicos ou outros componentes para rastrear o que precisa ser adquirido.', + }, + timeline: { + title: 'Linha do Tempo de Atividades', + empty: 'Nenhuma atividade ainda.', + }, + template: { + saveAsTemplate: 'Salvar como Modelo', + noCreatePermission: 'Você não tem permissão para criar modelos', + }, + queue: { + title: 'Fila', + viewAll: 'Ver todos', + printing: '{{count}} imprimindo', + queued: '{{count}} na fila', + }, + prints: { + title: 'Impressões ({{count}})', + }, + toast: { + projectUpdated: 'Projeto atualizado', + partAdded: 'Peça adicionada', + partRemoved: 'Peça removida', + exportFailed: 'Falha na exportação', + projectExported: 'Projeto exportado', + templateCreated: 'Modelo criado', + }, + }, + + // System info + system: { + title: 'Informações do Sistema', + version: 'Versão', + uptime: 'Tempo de Atividade', + cpuUsage: 'Uso da CPU', + memoryUsage: 'Uso da Memória', + diskUsage: 'Uso do Disco', + networkInfo: 'Informações de Rede', + logs: 'Logs', + debugMode: 'Modo de Depuração', + enableDebug: 'Ativar Registro de Depuração', + disableDebug: 'Desativar Registro de Depuração', + downloadLogs: 'Baixar Logs', + clearLogs: 'Limpar Logs', + dockerInfo: 'Informações do Docker', + containerName: 'Nome do Contêiner', + imageName: 'Nome da Imagem', + platform: 'Plataforma', + architecture: 'Arquitetura', + }, + + // Library (K Profiles) + library: { + title: 'Biblioteca de Filamentos', + addFilament: 'Adicionar Filamento', + editFilament: 'Editar Filamento', + deleteFilament: 'Excluir Filamento', + vendor: 'Fornecedor', + material: 'Material', + color: 'Cor', + kFactor: 'Fator K', + temperature: 'Temperatura', + noFilaments: 'Nenhum filamento na biblioteca', + deleteConfirm: 'Tem certeza de que deseja excluir este filamento?', + importFromPrinter: 'Importar da Impressora', + exportToFile: 'Exportar para Arquivo', + }, + + // Spoolman + spoolman: { + title: 'Integração com Spoolman', + enabled: 'Spoolman Ativado', + url: 'URL do Spoolman', + connected: 'Conectado', + disconnected: 'Não Conectado', + testConnection: 'Testar Conexão', + sync: 'Sincronizar', + syncing: 'Sincronizando...', + lastSync: 'Última Sincronização', + linkToSpoolman: 'Vincular ao Spoolman', + openInSpoolman: 'Abrir no Spoolman', + unlinkSpool: 'Desvincular Carretel', + selectSpool: 'Selecionar Carretel', + noUnlinkedSpools: 'Nenhum carretel desvinculado disponível', + linkSuccess: 'Carretel vinculado ao Spoolman com sucesso', + linkFailed: 'Falha ao vincular carretel', + spoolId: 'Carretel ID (Spool ID)', + fillSourceLabel: '(Spoolman)', + weight: 'Peso', + remaining: 'Restante', + disableWeightSync: 'Desativar Sincronização de Peso Estimado do AMS', + disableWeightSyncDesc: "Não atualize a capacidade restante a partir das estimativas do AMS. Use isso se preferir o rastreamento de uso do Spoolman em vez das estimativas baseadas em porcentagem do AMS. Novos carretéis ainda usarão a estimativa do AMS como seu peso inicial.", + reportPartialUsage: 'Relatar Uso Parcial para Impressões Falhadas', + reportPartialUsageDesc: 'Quando uma impressão falha ou é cancelada, relate o filamento estimado usado até aquele ponto com base no progresso das camadas.', + }, + + // Inventory + inventory: { + title: 'Inventário de Carretéis', + addSpool: 'Adicionar Carretel', + editSpool: 'Editar Carretel', + material: 'Material', + selectMaterial: 'Selecionar material...', + subtype: 'Subtipo', + brand: 'Marca', + searchBrand: 'Pesquisar marca...', + useCustomBrand: 'Usar "{{brand}}"', + colorName: 'Nome da Cor', + colorNamePlaceholder: 'Jade White, Fire Red...', + color: 'Cor', + hexColor: 'Cor Hexadecimal', + pickColor: 'Escolher cor personalizada', + labelWeight: 'Peso da Etiqueta', + coreWeight: 'Peso do Carretel Vazio', + searchSpoolWeight: 'Pesquisar peso do carretel...', + weightUsed: 'Usado', + currentWeight: 'Peso Restante', + measuredWeight: 'Peso Medido', + measuredWeightError: 'O peso medido deve estar entre {{min}}g e {{max}}g.', + slicerFilament: 'Filamento do Fatiador', + slicerFilamentName: 'Nome do Predefinido do Fatiador', + slicerPreset: 'Predefinido do Fatiador', + searchPresets: 'Pesquisar predefinições de filamento...', + selectedPreset: 'Selecionado', + noPresetsFound: 'Nenhuma predefinição encontrada', + tempOverrides: 'Substituições de Temperatura', + note: 'Nota', + notePlaceholder: 'Quaisquer notas adicionais sobre este spool...', + archive: 'Arquivar', + restore: 'Restaurar', + noSpools: 'Nenhum carretel ainda. Adicione seu primeiro carretel para começar.', + noManualSpools: 'Nenhum carretel adicionado manualmente disponível. Adicione um carretel ao seu inventário primeiro.', + kProfiles: 'K-Perfis', + addKProfile: 'Adicionar K-Perfil', + assignSpool: 'Atribuir Carretel', + unassignSpool: 'Desatribuir', + assignSuccess: 'Carretel atribuído e slot AMS configurado', + assignFailed: 'Falha ao atribuir carretel', + selectSpool: 'Selecione um carretel para atribuir a este slot', + assigned: 'Atribuído', + assigning: 'Atribuindo...', + searchSpools: 'Pesquisar carretéis...', + allMaterials: 'Todos os Materiais', + filterByBrand: 'Filtrar por marca...', + showArchived: 'Mostrar arquivados', + spoolCreated: 'Carretel criado', + spoolUpdated: 'Carretel atualizado', + spoolDeleted: 'Carretel excluído', + spoolArchived: 'Carretel arquivado', + spoolRestored: 'Carretel restaurado', + deleteConfirm: 'Tem certeza de que deseja excluir este carretel? Esta ação não pode ser desfeita.', + archiveConfirm: 'Tem certeza de que deseja arquivar este carretel?', + advancedSettings: 'Configurações Avançadas', + // Tabs + filamentInfoTab: 'Informações do Filamento', + paProfileTab: 'Perfil PA', + filamentInfo: 'Filamento', + additional: 'Adicional', + // Cloud + loadingPresets: 'Carregando predefinições da nuvem...', + cloudConnected: 'Nuvem conectada', + cloudNotConnected: 'Nuvem não conectada (usando padrões)', + // Colors + recentColors: 'Recentes', + searchColors: 'Pesquisar cores...', + searchResults: 'Resultados da pesquisa', + allColors: 'Todas as cores', + commonColors: 'Cores comuns', + showLess: 'Mostrar menos', + showAll: 'Mostrar tudo', + noColorsFound: 'Nenhuma cor corresponde à sua pesquisa', + noResults: 'Nenhum resultado encontrado', + // PA Profiles + selectMaterialFirst: 'Por favor, selecione um material primeiro na aba Informações do Filamento.', + noPrintersConfigured: 'Nenhuma impressora configurada. Adicione impressoras para usar perfis PA.', + matchingFilter: 'Correspondente', + anyBrand: 'Qualquer marca', + anyVariant: 'Qualquer variante', + autoSelect: 'Seleção automática', + matches: 'correspondências', + match: 'correspondência', + noMatches: 'Nenhuma correspondência', + connected: 'Conectado', + offline: 'Offline', + printerOffline: 'A impressora está offline. Conecte-se para visualizar os perfis de calibração.', + noKProfilesMatch: 'Nenhum K-perfil corresponde ao filamento selecionado.', + leftNozzle: 'Bico Esquerdo', + rightNozzle: 'Bico Direito', + profilesSelected: 'perfil(is) de calibração selecionado(s)', + // Stats & enhanced table + totalInventory: 'Inventário Total', + totalConsumed: 'Total Consumido', + byMaterial: 'Por Material', + inPrinter: 'Na Impressora', + lowStock: 'Estoque Baixo', + sinceTracking: 'Desde o início do rastreamento', + loadedInAms: 'Carregado no AMS/Ext', + remaining: 'Restante', + lowStockThreshold: '<20% restante', + search: 'Pesquisar carretéis...', + showing: 'Mostrando', + to: 'até', + of: 'de', + show: 'Mostrar', + spools: 'carretéis', + spool: 'carretel', + page: 'Página', + noSpoolsMatch: 'Nenhum resultado encontrado', + noSpoolsMatchDesc: 'Tente ajustar sua pesquisa ou filtros para encontrar o que você está procurando.', + active: 'Ativo', + archived: 'Arquivado', + all: 'Todos', + used: 'Usado', + new: 'Novo', + clearFilters: 'Limpar filtros', + table: 'Tabela', + cards: 'Cartões', + net: 'Líquido', + // Column config + columns: 'Colunas', + configureColumns: 'Configurar Colunas', + configureColumnsDesc: 'Arraste para reordenar as colunas ou use as setas. Alterne a visibilidade com o ícone de olho.', + visible: 'Visível', + reset: 'Redefinir', + cancel: 'Cancelar', + applyChanges: 'Aplicar Alterações', + moveUp: 'Mover para cima', + moveDown: 'Mover para baixo', + hideColumn: 'Ocultar coluna', + showColumn: 'Mostrar coluna', + // Tag linking + linkToSpool: 'Vincular ao Carretel', + tagLinked: 'Tag vinculada ao carretel', + tagLinkFailed: 'Falha ao vincular tag', + tagAlreadyLinked: 'Tag já vinculada a outro carretel', + unknownTag: 'Tag RFID desconhecida detectada', + // Usage history + usageHistory: 'Histórico de Uso', + noUsageHistory: 'Nenhum uso registrado ainda', + printName: 'Nome da Impressão', + weightConsumed: 'Peso Consumido', + clearHistory: 'Limpar', + historyCleared: 'Histórico de uso limpo', + fillSourceLabel: '(Inv)', + }, + + // Timelapse + timelapse: { + title: 'Timelapse', + create: 'Criar Timelapse', + download: 'Baixar', + delete: 'Excluir', + preview: 'Visualizar', + frameRate: 'Taxa de Quadros', + quality: 'Qualidade', + processing: 'Processando...', + noTimelapses: 'Nenhum timelapse disponível', + }, + + // AMS + ams: { + title: 'AMS', + slot: 'Slot', + empty: 'Vazio', + emptySlot: 'Slot vazio', + unknown: 'Desconhecido', + humidity: 'Umidade', + temperature: 'Temperatura', + filamentType: 'Tipo de Filamento', + filamentColor: 'Cor', + remaining: 'Restante', + history: 'Histórico do AMS', + noHistory: 'Nenhum histórico disponível', + configureSlot: 'Configurar Slot', + externalSpool: 'Carretel Externo', + profile: 'Perfil', + kFactor: 'Fator K', + fill: 'Preencher', + configure: 'Configurar', + }, + + // Print modal + printModal: { + title: 'Iniciar Impressão', + selectPrinter: 'Selecionar Impressora', + selectPlate: 'Selecionar Placa', + filamentMapping: 'Mapeamento de Filamento', + printSettings: 'Configurações de Impressão', + bedLeveling: 'Nivelamento da Mesa', + flowCalibration: 'Calibração de Fluxo', + vibrationCalibration: 'Calibração de Vibração', + layerInspection: 'Inspeção da Primeira Camada', + timelapse: 'Timelapse', + startPrint: 'Iniciar Impressão', + addToQueue: 'Adicionar à Fila', + cancel: 'Cancelar', + noPrintersAvailable: 'Nenhuma impressora disponível', + printerBusy: 'Impressora ocupada', + printerOffline: 'Impressora offline', + sameTypeDifferentColor: 'Mesmo tipo, cor diferente', + filamentTypeNotLoaded: 'Tipo de filamento não carregado', + openCalendar: 'Abrir calendário', + leftNozzle: 'L', + rightNozzle: 'R', + leftNozzleTooltip: 'Bico esquerdo', + rightNozzleTooltip: 'Bico direito', + }, + + // Backup + backup: { + title: 'Bakup e Restauração', + createBackup: 'Criar Backup', + restoreBackup: 'Restaurar Backup', + restoreDescription: 'Substituir todos os dados a partir de um arquivo de backup', + downloadBackup: 'Baixar Backup', + uploadBackup: 'Enviar Backup', + lastBackup: 'Último Backup', + autoBackup: 'Auto Backup', + backupNow: 'Fazer Backup Agora', + restoreWarning: 'Aviso: Restaurar um backup substituirá todos os dados atuais.', + includeArchives: 'Incluir Arquivos', + includeSettings: 'Incluir Configurações', + includeProfiles: 'Incluir Perfis', + backupSuccess: 'Backup criado com sucesso', + restoreSuccess: 'Backup restaurado com sucesso', + backupFailed: 'Falha ao criar backup', + restoreFailed: 'Falha ao restaurar backup', + restoreNote: 'A impressora virtual será parada durante a restauração', + }, + + // Tags + tags: { + title: 'Tags', + addTag: 'Adicionar Tag', + editTag: 'Editar Tag', + deleteTag: 'Excluir Tag', + tagName: 'Nome da Tag', + tagColor: 'Cor da Tag', + noTags: 'Nenhuma tag', + deleteConfirm: 'Tem certeza de que deseja excluir esta tag?', + manageTags: 'Gerenciar Tags', + }, + + // Upload modal (archives) + uploadModal: { + title: 'Upload Arquivos 3MF', + dragDrop: 'Arraste e solte arquivos .3mf aqui', + or: 'ou', + browseFiles: 'Procurar Arquivos', + extractionInfo: 'O modelo da impressora será extraído automaticamente dos metadados do arquivo 3MF.', + uploaded: 'enviado', + failed: 'falhou', + uploading: 'Enviando...', + upload: 'Enviar', + uploadFailed: 'Falha no envio', + }, + + // Edit archive modal + // Edit Archive Modal + editArchive: { + title: 'Editar Arquivo', + name: 'Nome', + namePlaceholder: 'Nome da impressão', + printer: 'Impressora', + noPrinter: 'Nenhuma impressora', + project: 'Projeto', + noProject: 'Nenhum projeto', + itemsPrinted: 'Itens Impressos', + itemsPrintedHelp: 'Número de itens produzidos neste trabalho de impressão', + notes: 'Notas', + notesPlaceholder: 'Adicione notas sobre esta impressão...', + externalLink: 'Link Externo', + externalLinkPlaceholder: 'https://printables.com/model/...', + externalLinkHelp: 'Link para Printables, Thingiverse ou outra fonte', + tags: 'Tags', + tagsPlaceholder: 'Adicionar tags...', + addMoreTags: 'Adicionar mais tags...', + matchingTags: 'Correspondendo "{{query}}"', + existingTags: 'Tags existentes', + clickToAdd: '(clique para adicionar)', + status: 'Status', + failureReason: 'Motivo da Falha', + selectReason: 'Selecione o motivo...', + photos: 'Fotos do Resultado da Impressão', + photosHelp: 'Clique em + para adicionar fotos do seu resultado impresso', + printResult: 'Resultado da Impressão', + saving: 'Salvando...', + // Failure reasons + failureReasons: { + adhesionFailure: 'Falha de adesão', + spaghettiDetached: 'Spaghetti / Destacado', + layerShift: 'Deslocamento de camada', + cloggedNozzle: 'Bico entupido', + filamentRunout: 'Fim do filamento', + warping: 'Warping', + stringing: 'Stringing', + underExtrusion: 'Under-extrusion', + powerFailure: 'Falha de energia', + userCancelled: 'Cancelado pelo usuário', + other: 'Outro', + }, + // Archive statuses + statuses: { + completed: 'Concluído', + failed: 'Falhou', + aborted: 'Cancelado', + printing: 'Imprimindo', + }, + }, + + // K-Profiles + kProfiles: { + title: 'K-Profiles', + noPrintersConfigured: 'Nenhuma impressora configurada', + addPrinterInSettings: 'Adicione uma impressora nas Configurações para gerenciar K-profiles', + noActivePrinters: 'Nenhuma impressora ativa', + enablePrinterConnection: 'Ative a conexão da impressora para visualizar seus K-profiles', + loadingProfiles: 'Carregando K-Profiles...', + printerOffline: 'Impressora Offline', + printerOfflineDesc: 'A impressora selecionada não está conectada. Ligue-a para visualizar os K-profiles.', + noMatchingProfiles: 'Nenhum Perfil Correspondente', + noMatchingProfilesDesc: 'Nenhum perfil corresponde aos seus critérios de pesquisa', + noKProfiles: 'Nenhum K-Profile', + noKProfilesDesc: 'Nenhum perfil de avanço de pressão encontrado para bico de {{diameter}}mm', + createFirstProfile: 'Criar Primeiro Perfil', + // Controls + printer: 'Impressora', + nozzle: 'Bico', + refresh: 'Atualizar', + addProfile: 'Adicionar Perfil', + export: 'Exportar', + import: 'Importar', + select: 'Selecionar', + selectAll: 'Selecionar Todos', + delete: 'Excluir', + // Filters + searchPlaceholder: 'Pesquisar por nome ou filamento...', + allExtruders: 'Todos os Extrusores', + leftOnly: 'Apenas Esquerdo', + rightOnly: 'Apenas Direito', + allFlow: 'Todo Fluxo', + hfOnly: 'Apenas HF', + sOnly: 'Apenas S', + sortName: 'Ordenar: Nome', + sortKValue: 'Ordenar: Valor K', + sortFilament: 'Ordenar: Filamento', + // Dual extruder labels + leftExtruder: 'Extrusor Esquerdo', + rightExtruder: 'Extrusor Direito', + // Modal + modal: { + addTitle: 'Adicionar K-Profile', + editTitle: 'Editar K-Profile', + profileName: 'Nome do Perfil', + profileNamePlaceholder: 'Meu Perfil PLA', + kValue: 'Valor K', + kValuePlaceholder: '0.020', + kValueHelp: 'Faixa típica: 0.01 - 0.06 para PLA, 0.02 - 0.10 para PETG', + filament: 'Filamento', + selectFilament: 'Selecionar filamento...', + noFilamentsHelp: 'Nenhum filamento encontrado. Crie um K-profile no Bambu Studio primeiro.', + flowType: 'Tipo de Fluxo', + highFlow: 'Alto Fluxo', + standard: 'Padrão', + nozzleSize: 'Tamanho do Bico', + extruder: 'Extrusor', + extruders: 'Extrusores', + left: 'Esquerdo', + right: 'Direito', + notes: 'Notas (armazenadas localmente)', + notesPlaceholder: 'Adicione notas sobre este perfil...', + notesHelp: 'As notas são salvas no Bambuddy, não na impressora', + syncing: 'Sincronizando com a impressora...', + savingExtruder: 'Salvando no extrusor {{current}}/{{total}}...', + pleaseWait: 'Por favor, aguarde', + }, + // Delete confirmation + deleteConfirm: { + title: 'Excluir Perfil', + cannotUndo: 'Isso não pode ser desfeito', + message: 'Tem certeza de que deseja excluir "{{name}}" da impressora?', + }, + // Bulk delete + bulkDelete: { + title: 'Excluir Perfis', + cannotUndo: 'Isso não pode ser desfeito', + message: 'Tem certeza de que deseja excluir {{count}} perfis selecionados da impressora?', + }, + // Toast + toast: { + profileSaved: 'K-profile salvo', + profilesSaved: 'K-profile salvo em {{count}} extrusores', + selectAtLeastOneExtruder: 'Por favor, selecione pelo menos um extrusor', + profileDeleted: 'K-profile excluído', + profilesDeleted: '{{count}} perfis excluídos', + exportedProfiles: '{{count}} perfis exportados', + importedProfiles: '{{count}} de {{total}} perfis importados', + noProfilesToExport: 'Nenhum perfil para exportar', + invalidFileFormat: 'Formato de arquivo inválido', + failedToParseImport: 'Falha ao analisar o arquivo de importação', + failedToSaveBatch: 'Falha ao salvar K-profiles', + noteSaved: 'Nota salva', + failedToSaveNote: 'Falha ao salvar nota', + }, + // Permissions + permission: { + noRead: 'Você não tem permissão para atualizar perfis', + noCreate: 'Você não tem permissão para adicionar perfis', + noUpdate: 'Você não tem permissão para atualizar K-profiles', + noDelete: 'Você não tem permissão para excluir K-profiles', + noExport: 'Você não tem permissão para exportar perfis', + noImport: 'Você não tem permissão para importar perfis', + }, + }, + + // Virtual Printer + virtualPrinter: { + title: 'Impressora Virtual', + running: 'Em execução', + stopped: 'Parada', + description: { + default: 'Ative uma impressora virtual que aparece no Bambu Studio e no OrcaSlicer. Os arquivos enviados para esta impressora serão arquivados diretamente sem impressão.', + proxy: 'Ative um proxy que retransmite o tráfego do slicer para uma impressora real, permitindo impressão remota em qualquer rede.', + }, + enable: { + title: 'Ativar Impressora Virtual', + visibleInSlicer: 'Visível como "Bambuddy" na descoberta do slicer', + proxyingTo: 'Proxy para {{name}}', + notActive: 'Não ativo', + }, + model: { + title: 'Modelo da Impressora', + description: 'Selecione qual modelo de impressora emular.', + restartWarning: 'Alterar o modelo reiniciará a impressora virtual', + }, + accessCode: { + title: 'Código de acesso', + isSet: 'O código de acesso está definido', + notSet: 'Nenhum código de acesso definido — necessário para ativar.', + placeholder: 'Digite um código de 8 caracteres', + placeholderChange: 'Digite um novo código para alterar', + hint: 'Deve ter exatamente 8 caracteres. Usado pelos slicers para autenticação.', + charCount: '({{count}}/8)', + }, + targetPrinter: { + title: 'Impressora Alvo', + configured: 'Proxy alvo configurado', + notConfigured: 'Nenhuma impressora alvo selecionada - necessário para o modo proxy', + placeholder: 'Selecione uma impressora...', + hint: 'Selecione a impressora para a qual o tráfego do slicer será enviado. A impressora deve estar no modo LAN.', + noPrinters: 'Nenhuma impressora configurada. Adicione uma impressora primeiro para usar o modo proxy.', + }, + remoteInterface: { + title: 'Substituição da Interface de Rede', + configured: 'Substituição da interface ativa', + optional: 'Opcional - use se o IP detectado automaticamente estiver errado (por exemplo, várias NICs, Docker, VPN)', + placeholder: 'Detecção automática (padrão)...', + hint: 'Substitua o endereço IP anunciado via SSDP e usado no certificado TLS. Útil quando o Bambuddy possui várias interfaces de rede.', + }, + mode: { + title: 'Modo', + archive: 'Arquivar', + archiveDesc: 'Arquivar arquivos imediatamente', + review: 'Revisar', + reviewDesc: 'Revisar antes de arquivar', + queue: 'Fila', + queueDesc: 'Arquivar e adicionar à fila', + proxy: 'Proxy', + proxyDesc: 'Retransmitir para impressora real', + }, + setupRequired: { + title: 'Configuração Necessária', + description: 'O recurso de impressora virtual requer configuração adicional do sistema antes de funcionar. Isso inclui encaminhamento de portas, regras de firewall e configurações específicas da plataforma.', + readGuide: 'Leia o guia de configuração antes de ativar', + }, + howItWorks: { + title: 'Como funciona', + titleProxy: 'Como funciona (Modo Proxy)', + step1: 'Complete o guia de configuração para sua plataforma', + step2: 'Ative a impressora virtual e defina um código de acesso', + step3: 'No Bambu Studio ou OrcaSlicer, vá para "Adicionar Impressora"', + step4: 'A impressora "Bambuddy" deve aparecer na lista de descoberta', + step5: 'Conecte-se usando o código de acesso que você definiu', + step6: 'Quando você "imprimir" para o Bambuddy, o arquivo 3MF será arquivado em vez disso', + proxyStep1: 'Selecione a impressora alvo (deve estar no modo LAN)', + proxyStep2: 'Para rede cruzada: selecione a interface de rede do slicer', + proxyStep3: 'Ative o proxy - a impressora aparece na descoberta do slicer via SSDP', + proxyStep4: 'Conecte-se usando o código de acesso da impressora', + proxyStep5: 'Imprima normalmente - o tráfego é retransmitido pelo Bambuddy', + proxyStep6: 'O streaming da câmera requer NAT/encaminhamento de IP (veja a documentação)', + }, + status: { + title: 'Detalhes do Status', + printerName: 'Nome da Impressora', + model: 'Modelo', + serialNumber: 'Número de Série', + mode: 'Modo', + pendingFiles: 'Arquivos Pendentes', + targetPrinter: 'Impressora Alvo', + ftpPort: 'Porta FTP', + mqttPort: 'Porta MQTT', + ftpConnections: 'Conexões FTP', + mqttConnections: 'Conexões MQTT', + }, + toast: { + updated: 'Configurações da impressora virtual atualizadas', + failedToUpdate: 'Falha ao atualizar as configurações', + accessCodeRequired: 'Defina um código de acesso primeiro', + targetPrinterRequired: 'Selecione uma impressora alvo primeiro', + accessCodeEmpty: 'O código de acesso não pode estar vazio', + accessCodeLength: 'O código de acesso deve ter exatamente 8 caracteres', + }, + }, + + // Model Viewer + modelViewer: { + openInSlicer: 'Abrir no Slicer', + tabs: { + model: 'Modelo 3D', + gcode: 'Pré-visualização G-code', + }, + notAvailable: 'Não disponível', + notSliced: 'Não fatiado', + plates: 'Placas', + allPlates: 'Todas as Placas', + plateNumber: 'Placa {{number}}', + plateCount: '{{count}} placa', + plateCount_other: '{{count}} placas', + objectCount: '{{count}} objeto', + objectCount_other: '{{count}} objetos', + filamentCount: '{{count}} filamento', + filamentCount_other: '{{count}} filamentos', + eta: 'ETA {{minutes}} min', + noPreview: 'Pré-visualização não disponível para este arquivo', + pagination: { + pageOf: 'Página {{current}} de {{total}}', + prev: 'Anterior', + next: 'Próximo', + }, + errors: { + failedToLoad: 'Falha ao carregar o arquivo', + noMeshes: 'Nenhuma malha encontrada no arquivo 3MF', + unsupportedFormat: 'Formato de arquivo não suportado', + }, + }, + + // Maintenance type descriptions (built-in) + maintenanceDescriptions: { + lubricateCarbonRods: 'Aplique lubrificante nos eixos de carbono para um movimento suave', + lubricateRails: 'Aplique lubrificante nos trilhos lineares para um movimento suave', + cleanNozzle: 'Limpe o hotend e o bico para evitar entupimentos', + checkBelts: 'Verifique a tensão das correias para impressões precisas', + cleanBuildPlate: 'Limpe a placa de construção para melhor adesão', + checkExtruder: 'Verifique as engrenagens do extrusor quanto ao desgaste', + checkCooling: 'Verifique se os ventiladores de resfriamento estão funcionando corretamente', + generalInspection: 'Inspeção geral da impressora', + cleanCarbonRods: 'Limpe os eixos de carbono para reduzir o atrito', + cleanLinearRails: 'Limpe os trilhos lineares para remover poeira e detritos', + checkPtfeTube: 'Verifique o tubo PTFE quanto ao desgaste ou danos', + replaceHepaFilter: 'Substitua o filtro HEPA para qualidade do ar', + replaceCarbonFilter: 'Substitua o filtro de carbono ativado', + lubricateLeftNozzleRail: 'Lubrifique o trilho do bico esquerdo (série H2)', + }, + + // Smart Plugs + smartPlugs: { + offline: 'Offline', + admin: 'Admin', + openPlugAdminPage: 'Abrir o painel de administração da tomada inteligente', + deleteSmartPlug: 'Excluir Tomada Inteligente', + turnOnSmartPlug: 'Ligar Tomada Inteligente', + turnOffSmartPlug: 'Desligar Tomada Inteligente', + turnOn: 'Ligar', + turnOff: 'Desligar', + addSmartPlug: { + scanningNetwork: 'Procurando na rede...', + chooseEntity: 'Escolha uma entidade...', + connectionFailed: 'Falha na conexão', + searchEntities: 'Pesquisar entidades...', + searchPowerSensors: 'Pesquisar sensores de energia...', + searchEnergySensors: 'Pesquisar sensores de energia...', + placeholders: { + plugName: 'Tomada da Sala', + mqttStateOnValue: 'ON, true, 1', + mqttSameAsPower: 'Mesmo que o tópico de energia, ou diferente', + }, + }, + }, + + // Rich Text Editor + richTextEditor: { + bold: 'Negrito', + italic: 'Itálico', + underline: 'Sublinhado', + bulletList: 'Lista com marcadores', + numberedList: 'Lista numerada', + alignLeft: 'Alinhar à esquerda', + alignCenter: 'Centralizar', + alignRight: 'Alinhar à direita', + addLink: 'Adicionar link', + removeLink: 'Remover link', + }, + + // External Links + externalLinks: { + noLinksConfigured: 'Nenhum link externo configurado', + deleteLink: 'Excluir link', + removeCustomIcon: 'Remover ícone personalizado', + openInNewTab: 'Abrir em nova aba', + placeholders: { + linkName: 'Meu Link', + }, + }, + + // Keyboard Shortcuts Modal + keyboardShortcuts: { + title: 'Atalhos de Teclado', + navigation: 'Navegação', + archivesSection: 'Arquivos', + kProfilesSection: 'K-Profiles', + generalSection: 'Geral', + shortcuts: { + goToPrinters: 'Ir para Impressoras', + goToArchives: 'Ir para Arquivos', + goToQueue: 'Ir para Fila', + goToStats: 'Ir para Estatísticas', + goToProfiles: 'Ir para Perfis na Nuvem', + goToSettings: 'Ir para Configurações', + focusSearch: 'Focar na pesquisa', + openUploadModal: 'Abrir modal de upload', + clearSelection: 'Limpar seleção / desfocar input', + contextMenu: 'Menu de contexto nos cartões', + refreshProfiles: 'Atualizar perfis', + newProfile: 'Novo perfil', + exitSelectionMode: 'Sair do modo de seleção', + showHelp: 'Mostrar esta ajuda', + }, + footer: 'Pressione Esc ou clique fora para fechar', + }, + + // Notification Log + notificationLog: { + title: 'Registro de Notificações', + events: { + printStarted: 'Impressão Iniciada', + printComplete: 'Impressão Concluída', + printFailed: 'Impressão Falhou', + printStopped: 'Impressão Interrompida', + progress: 'Progresso', + printerOffline: 'Impressora Offline', + printerError: 'Erro na Impressora', + lowFilament: 'Filamento Baixo', + maintenanceDue: 'Manutenção Pendente', + test: 'Teste', + }, + timeAgo: { + justNow: 'Agora mesmo', + minutesAgo: 'há {{minutes}} minutos', + hoursAgo: 'há {{hours}} horas', + }, + }, + + // Restore/Backup Modal + restoreBackup: { + title: 'Restaurar Backup', + restoring: 'Restaurando...', + restoreComplete: 'Restauração Concluída', + restoreFailed: 'Falha na Restauração', + importSettings: 'Importar configurações de um arquivo de backup', + pleaseWait: 'Aguarde enquanto seus dados estão sendo restaurados', + clickToSelect: 'Clique para selecionar o arquivo de backup (.json ou .zip)', + howDuplicateHandling: 'Como funciona o tratamento de duplicatas:', + categories: { + printers: 'Impressoras', + smartPlugs: 'Tomadas Inteligentes', + notificationProviders: 'Provedores de Notificação', + filaments: 'Filamentos', + archives: 'Arquivos', + pendingUploads: 'Uploads Pendentes', + settingsTemplates: 'Configurações e Modelos', + }, + matchingInfo: { + printers: 'correspondem pelo número de série', + smartPlugs: 'correspondem pelo endereço IP', + notificationProviders: 'correspondem pelo nome', + filaments: 'correspondem pelo nome + tipo + marca', + archives: 'correspondem pelo hash do conteúdo', + pendingUploads: 'correspondem pelo nome do arquivo', + settingsTemplates: 'sempre sobrescrito', + }, + replaceExisting: 'Substituir dados existentes', + keepExisting: 'Manter dados existentes', + replaceDescription: 'Substituir itens que já existem com os dados do backup', + keepDescription: 'Restaurar apenas itens que não existem', + caution: 'Atenção:', + cautionText: 'Sobrescrever substituirá suas configurações atuais pelos dados do backup. Os códigos de acesso da impressora nunca são sobrescritos por segurança.', + itemsRestored: 'Itens Restaurados', + itemsSkipped: 'Itens Ignorados', + restored: 'Restaurado', + skipped: 'Ignorado (já existe)', + filesLabel: 'Arquivos (3MF, miniaturas, etc.)', + newApiKeysGenerated: 'Novas Chaves API Geradas', + newApiKeysWarning: 'Essas chaves são exibidas apenas uma vez. Copie-as agora!', + processingBackup: 'Processando arquivo de backup...', + noDataFound: 'Nenhum dado foi encontrado para restaurar no arquivo de backup.', + failedToRestore: 'Falha ao restaurar o backup. Verifique o formato do arquivo.', + }, + + // Backup Export Modal + backupExport: { + title: 'Exportar Backup', + selectData: 'Selecione os dados a incluir', + selectAll: 'Selecionar Todos', + selectNone: 'Selecionar Nenhum', + categoryDescriptions: { + settings: 'Idioma, tema, preferências de atualização', + notifications: 'ntfy, Pushover, Discord, etc.', + templates: 'Modelos de mensagens personalizadas', + smartPlugs: 'Configurações de tomadas Tasmota', + externalLinks: 'Links da barra lateral para serviços externos', + printers: 'Informações da impressora (códigos de acesso excluídos)', + plateDetection: 'Imagens de referência de placa vazia', + filaments: 'Tipos e custos de filamento', + maintenance: 'Cronogramas de manutenção personalizados', + archives: 'Todos os dados de impressão + arquivos (3MF, miniaturas, fotos)', + projects: 'Projetos, itens de BOM e anexos', + pendingUploads: 'Uploads de impressora virtual aguardando revisão', + apiKeys: 'Chaves API de webhook (novas chaves geradas na importação)', + }, + requiresPrinters: 'Requer que as impressoras sejam selecionadas', + zipFileWarning: 'Um arquivo ZIP será criado.', + zipFileDescription: 'Inclui todos os arquivos 3MF, miniaturas, timelapses e fotos. Isso pode levar algum tempo e resultar em um arquivo grande.', + includeAccessCodes: 'Incluir Códigos de Acesso', + includeAccessCodesDescription: 'Para transferir para outra máquina', + includeAccessCodesWarning: 'Os códigos de acesso serão incluídos em texto simples. Mantenha este arquivo de backup seguro!', + categoriesSelected: '{{selectedCount}} categorias selecionadas', + }, + + // Pending Uploads Panel + pendingUploads: { + placeholders: { + notes: 'Adicione notas sobre esta impressão...', + }, + discardUpload: 'Descartar Upload', + archiveAllUploads: 'Arquivar Todos os Uploads', + discardAllUploads: 'Descartar Todos os Uploads', + archive: 'Arquivar', + timeAgo: { + justNow: 'Agora mesmo', + minutesAgo: 'há {{minutes}} minutos', + hoursAgo: 'há {{hours}} horas', + daysAgo: 'há {{days}} dias', + }, + }, + + // API Browser + apiBrowser: { + placeholders: { + requestBody: 'Corpo da requisição JSON...', + searchEndpoints: 'Pesquisar endpoints...', + }, + }, + + // Configure AMS Slot Modal + configureAmsSlot: { + title: 'Configurar Slot AMS', + slotConfigured: 'Slot Configurado!', + configuringSlot: 'Configurando slot:', + slotLabel: '{{ams}} Slot {{slot}}', + searchPresets: 'Pesquisar predefinições...', + colorPlaceholder: 'Nome da cor ou hex (ex.: marrom, FF8800)', + clearCustomColor: 'Limpar cor personalizada', + noCloudPresets: 'Nenhuma predefinição na nuvem. Faça login no Bambu Cloud para sincronizar.', + noPresetsAvailable: 'Nenhuma predefinição disponível. Faça login no Bambu Cloud ou importe perfis locais.', + noMatchingPresets: 'Nenhuma predefinição correspondente encontrada.', + custom: 'Personalizado', + builtin: 'Integrado', + settingsSentToPrinter: 'Configurações enviadas para a impressora', + filamentProfile: 'Perfil de Filamento', + kProfileLabel: 'Perfil K (Avanço de Pressão)', + filteringFor: 'Filtrando por: {{material}}', + noKProfile: 'Nenhum perfil K (usar padrão 0.020)', + noMatchingKProfiles: 'Nenhum perfil K correspondente encontrado. O K padrão=0.020 será usado.', + selectFilamentFirst: 'Selecione um perfil de filamento primeiro', + kFromCalibration: 'K={{value}} da calibração da impressora', + customColorLabel: 'Cor Personalizada (opcional)', + presetColors: 'Cores de {{name}}:', + showLessColors: 'Mostrar menos cores', + showMoreColors: 'Mostrar mais cores', + clear: 'Limpar', + hexLabel: 'Hex: #{{hex}}', + resetting: 'Redefinindo...', + resetSlot: 'Redefinir Slot', + cancel: 'Cancelar', + configuring: 'Configurando...', + configureSlot: 'Configurar Slot', + }, + + // GitHub Backup Settings + githubBackup: { + title: 'Backup do GitHub', + history: 'Histórico', + downloadBackup: 'Baixar Backup', + restoreBackup: 'Restaurar Backup', + noBackupsYet: 'Nenhum backup ainda', + }, + + // Email Settings + emailSettings: { + placeholders: { + fromName: 'BamBuddy', + }, + }, + + // Tag Management Modal + tagManagement: { + searchTags: 'Pesquisar tags...', + renameTag: 'Renomear tag', + deleteTag: 'Excluir tag', + }, + + // Notification Template Editor + notificationTemplates: { + placeholders: { + title: 'Título da notificação...', + body: 'Corpo da notificação...', + }, + }, + + // Batch Tag Modal + batchTag: { + placeholders: { + newTag: 'Digite uma nova tag...', + }, + }, + + // Photo Gallery Modal + photoGallery: { + deletePhoto: 'Excluir foto', + }, + + // Filament Hover Card + filamentHoverCard: { + copySpoolUuid: 'Copiar UUID do carretel', + }, + + // K Profiles View + kProfilesView: { + hasNote: 'Possui nota', + copyProfile: 'Copiar perfil', + }, + + // Layout/Navigation + layout: { + openMenu: 'Abrir menu', + noPermissionSystemInfo: 'Você não tem permissão para visualizar informações do sistema', + }, + + // Dashboard + dashboard: { + dragToReorder: 'Arrastar para reordenar', + hideWidget: 'Ocultar widget', + }, + + // Notification Provider Card + notificationProviderCard: { + deleteNotificationProvider: 'Excluir provedor de notificação', + }, + + // File Manager Modal + fileManagerModal: { + closeFileManager: 'Fechar gerenciador de arquivos', + sortFiles: 'Ordenar arquivos', + goToParentFolder: 'Ir para a pasta pai', + threeView: 'Visualização 3D', + }, + + // Embedded Camera Viewer + embeddedCameraViewer: { + refreshStream: 'Atualizar stream', + close: 'Fechar', + zoomOut: 'Reduzir zoom', + resetZoom: 'Redefinir zoom', + zoomIn: 'Aumentar zoom', + dragToResize: 'Arrastar para redimensionar', + }, + + // Timelapse Viewer + timelapseViewer: { + skipBack5s: 'Voltar 5s', + skipForward5s: 'Avançar 5s', + }, + + // Notification Providers + notificationProviders: { + descriptions: { + email: 'Notificações por email SMTP', + telegram: 'Notificações via bot do Telegram', + discord: 'Enviar para canal do Discord via webhook', + ntfy: 'Notificações push gratuitas e auto-hospedáveis', + pushover: 'Notificações push simples e confiáveis', + callmebot: 'Notificações gratuitas via WhatsApp pelo CallMeBot', + webhook: 'POST HTTP genérico para qualquer URL', + }, + }, + + // Log Viewer + logViewer: { + searchPlaceholder: 'Pesquisar mensagem ou nome do logger...', + noLogEntries: 'Nenhuma entrada de log encontrada', + }, + + // Switchbar Popover + switchbarPopover: { + noSwitchesInSwitchbar: 'Nenhum switch na barra de switches', + }, + + // Project Page Modal + projectPageModal: { + placeholders: { + title: 'Título', + designer: 'Designer', + license: 'Licença', + description: 'Digite a descrição...', + profileTitle: 'Título do perfil', + profileDescription: 'Descrição do perfil...', + }, + }, + + // Spoolman Settings + spoolmanSettings: {}, +}; From 7ce2048e09c944c779053daa3d69b73cdd35471a Mon Sep 17 00:00:00 2001 From: Wesley Silva Date: Tue, 17 Feb 2026 20:09:33 +0000 Subject: [PATCH 3/8] Fixing typo on CONTRIBUTING.md --- CONTRIBUTING.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 2dcb7ad16..750f1b89c 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -168,7 +168,7 @@ Translations live in `frontend/src/i18n/locales/`: | `de.ts` | German | | `fr.ts` | French | | `ja.ts` | Japanese | -| `pt-BR.ts` | Brazilian Portguese | +| `pt-BR.ts` | Brazilian Portuguese | ### Adding New Strings From 07015a7f8fdb070ff83aa8bcba0907df00fe826e Mon Sep 17 00:00:00 2001 From: Matteo Parenti Date: Wed, 18 Feb 2026 14:16:03 +0100 Subject: [PATCH 4/8] fix(i18n): update remaining filament labels in multiple languages --- frontend/src/components/AssignSpoolModal.tsx | 2 +- frontend/src/i18n/locales/de.ts | 2 ++ frontend/src/i18n/locales/en.ts | 2 ++ frontend/src/i18n/locales/fr.ts | 2 ++ frontend/src/i18n/locales/it.ts | 4 +++- frontend/src/i18n/locales/ja.ts | 2 ++ 6 files changed, 12 insertions(+), 2 deletions(-) diff --git a/frontend/src/components/AssignSpoolModal.tsx b/frontend/src/components/AssignSpoolModal.tsx index d899435dc..222e84391 100644 --- a/frontend/src/components/AssignSpoolModal.tsx +++ b/frontend/src/components/AssignSpoolModal.tsx @@ -177,7 +177,7 @@ export function AssignSpoolModal({ isOpen, onClose, printerId, amsId, trayId, tr

{spool.color_name || ''} {spool.label_weight ? ` - ${spool.label_weight}g` : ''} - {spool.label_weight ? ` (${Math.max(0, Math.round(spool.label_weight - spool.weight_used))}g remaining)` : ''} + {spool.label_weight ? ` (${Math.max(0, Math.round(spool.label_weight - spool.weight_used))}g ${t('ams.remainingUnit')})` : ''}

{selectedSpoolId === spool.id && ( diff --git a/frontend/src/i18n/locales/de.ts b/frontend/src/i18n/locales/de.ts index 2c4b87003..90ed1151d 100644 --- a/frontend/src/i18n/locales/de.ts +++ b/frontend/src/i18n/locales/de.ts @@ -2682,6 +2682,8 @@ export default { kFactor: 'K-Faktor', fill: 'Füllstand', configure: 'Konfigurieren', + used: 'verwendet', + remainingUnit: 'verbleibend', }, // Print modal diff --git a/frontend/src/i18n/locales/en.ts b/frontend/src/i18n/locales/en.ts index 36a4a9f43..4a60844a7 100644 --- a/frontend/src/i18n/locales/en.ts +++ b/frontend/src/i18n/locales/en.ts @@ -2686,6 +2686,8 @@ export default { kFactor: 'K Factor', fill: 'Fill', configure: 'Configure', + used: 'used', + remainingUnit: 'remaining', }, // Print modal diff --git a/frontend/src/i18n/locales/fr.ts b/frontend/src/i18n/locales/fr.ts index 08e10d7d8..f176a0fb6 100644 --- a/frontend/src/i18n/locales/fr.ts +++ b/frontend/src/i18n/locales/fr.ts @@ -2674,6 +2674,8 @@ export default { kFactor: 'Facteur K', fill: 'Remplir', configure: 'Configurer', + used: 'utilisé', + remainingUnit: 'restant', }, // Print modal diff --git a/frontend/src/i18n/locales/it.ts b/frontend/src/i18n/locales/it.ts index 3fbe22252..e9ca369e6 100644 --- a/frontend/src/i18n/locales/it.ts +++ b/frontend/src/i18n/locales/it.ts @@ -2397,8 +2397,10 @@ export default { externalSpool: 'Bobina esterna', profile: 'Profilo', kFactor: 'K Factor', - fill: 'Residuo', + fill: 'Livello', configure: 'Configura', + used: 'utilizzato', + remainingUnit: 'rimanente', }, // Print modal diff --git a/frontend/src/i18n/locales/ja.ts b/frontend/src/i18n/locales/ja.ts index 390012f88..2637cd2e1 100644 --- a/frontend/src/i18n/locales/ja.ts +++ b/frontend/src/i18n/locales/ja.ts @@ -2604,6 +2604,8 @@ export default { kFactor: 'K値', fill: '充填率', configure: '設定', + used: '使用済み', + remainingUnit: '残り', }, printModal: { flowCalibration: 'フローキャリブレーション', From 5415593951ba91380852bdc8f0da59717bf958fa Mon Sep 17 00:00:00 2001 From: Wesley Silva Date: Wed, 18 Feb 2026 13:27:14 +0000 Subject: [PATCH 5/8] Complying with PR --- frontend/src/i18n/locales/pt-BR.ts | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/frontend/src/i18n/locales/pt-BR.ts b/frontend/src/i18n/locales/pt-BR.ts index 9bf280604..d137cb214 100644 --- a/frontend/src/i18n/locales/pt-BR.ts +++ b/frontend/src/i18n/locales/pt-BR.ts @@ -43,7 +43,7 @@ export default { enabled: 'Ativado', disabled: 'Desativado', yes: 'Sim', - no: 'ão', + no: 'Não', on: 'Ligado', off: 'Desligado', all: 'Todos', @@ -741,7 +741,7 @@ export default { viewArchive: 'Ver Arquivo', viewInFileManager: 'Ver no Gerenciador de Arquivos', itemCount: '{{count}} item', - itemCount_plural: '{{count}} items', + itemCount_plural: '{{count}} itens', dragToReorder: 'Arraste para reordenar (apenas ASAP)', reorderHint: 'A posição afeta apenas itens ASAP. Itens agendados são executados no horário definido.', addedBy: 'Adicionado por {{name}}', @@ -822,7 +822,7 @@ export default { // Bulk edit bulkEdit: { title: 'Editar {{count}} Item', - title_plural: 'Editar {{count}} Items', + title_plural: 'Editar {{count}} Itens', description: 'Apenas as configurações alteradas serão aplicadas aos itens selecionados.', printer: 'Impressora', noChange: '— Sem alterações —', @@ -997,7 +997,6 @@ export default { month: '1 mês', months: '{{count}} meses', year: '1 ano', - years: '{{count}} anos', // Settings maintenanceTypes: 'Tipos de Manutenção', maintenanceTypesDescription: 'Tipos de sistema e suas tarefas de manutenção personalizadas', @@ -1127,9 +1126,9 @@ export default { }, // Security options securityOptions: { - starttls: 'STARTTLS (Port 587)', - ssl: 'SSL/TLS (Port 465)', - none: 'None (Port 25)', + starttls: 'STARTTLS (Porta 587)', + ssl: 'SSL/TLS (Porta 465)', + none: 'Nenhuma (Porta 25)', }, // Authentication options authOptions: { From 11d9c98b55e8db334937afc736e0c2311f6e7282 Mon Sep 17 00:00:00 2001 From: maziggy Date: Wed, 18 Feb 2026 14:59:03 +0100 Subject: [PATCH 6/8] fix(inventory): require brand and subtype in spool form (#417) The spool add/edit modal allowed saving without brand or subtype, causing incomplete tray_sub_brands when assigned to AMS slots. BambuStudio then failed to recognize the filament profile. Brand and Subtype are now mandatory with validation errors on submit. --- CHANGELOG.md | 1 + frontend/src/components/SpoolFormModal.tsx | 8 +++++++- .../src/components/spool-form/FilamentSection.tsx | 4 ++-- frontend/src/components/spool-form/types.ts | 8 ++++++++ frontend/src/pages/QueuePage.tsx | 1 - .../assets/{index-DmiEmqVo.js => index-BLcYYvbZ.js} | 12 +++++++----- static/assets/index-EqFdfChN.css | 1 + static/assets/index-tulFiIvt.css | 1 - static/index.html | 4 ++-- 9 files changed, 28 insertions(+), 12 deletions(-) rename static/assets/{index-DmiEmqVo.js => index-BLcYYvbZ.js} (94%) create mode 100644 static/assets/index-EqFdfChN.css delete mode 100644 static/assets/index-tulFiIvt.css diff --git a/CHANGELOG.md b/CHANGELOG.md index b3d20d3b0..c5b0a0578 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -19,6 +19,7 @@ All notable changes to Bambuddy will be documented in this file. - **Usage Tracking Wrong Spool on Dual-Nozzle / Multi-AMS Printers** ([#364](https://github.com/maziggy/bambuddy/issues/364)) — On H2C, H2D Pro, and other dual-nozzle printers with multiple AMS units, the usage tracker attributed filament consumption to the wrong spools. The MQTT `mapping` field — a per-print array that maps slicer filament slots to physical AMS trays — was preserved in state but never parsed or used. The tracker fell back to `slot_id - 1` as the global tray ID, which is incorrect when AMS hardware IDs differ from sequential indices (e.g., AMS-HT units with ID 128). Now decodes the MQTT mapping field from its snow encoding (`ams_hw_id * 256 + local_slot`) into bambuddy global tray IDs and uses it as a universal mapping source — working for all printer models and all print sources (slicer, queue, reprint) without relying on `tray_now` disambiguation. - **npm audit: suppress moderate ajv ReDoS finding** — Added `audit-level=high` to `frontend/.npmrc` so `npm audit` exits cleanly. The ajv@6 ReDoS (GHSA-2g4f-4pwh-qvx6) is a transitive dependency of eslint@9 with no patched v6 release; ajv@8 override breaks eslint. The vulnerability requires crafted `$data` schema input — not an attack vector in a linting config. +- **Spool Form Allows Empty Brand & Subtype** ([#417](https://github.com/maziggy/bambuddy/issues/417)) — The spool add/edit modal did not require Brand or Subtype fields, allowing spools to be saved without them. When such a spool was assigned to an AMS slot, the `tray_sub_brands` sent to the printer was incomplete (e.g., just "PETG" instead of "PETG Basic"), causing BambuStudio to not recognize the filament profile. Brand and Subtype are now mandatory fields with validation errors shown on submit. ### Changed - **Filament Catalog API Renamed** ([#427](https://github.com/maziggy/bambuddy/issues/427)) — Renamed `/api/v1/filaments/` to `/api/v1/filament-catalog/` to avoid confusion with the inventory spools page (labeled "Filament" in the UI). The old endpoint managed material type definitions (cost, temperature, density), not physical spools — the shared name caused users to expect the API to return their spool inventory. diff --git a/frontend/src/components/SpoolFormModal.tsx b/frontend/src/components/SpoolFormModal.tsx index 11988349c..0b25c4ecc 100644 --- a/frontend/src/components/SpoolFormModal.tsx +++ b/frontend/src/components/SpoolFormModal.tsx @@ -320,7 +320,7 @@ export function SpoolFormModal({ isOpen, onClose, spool, printersWithCalibration if (!validation.isValid) { setErrors(validation.errors); // Switch to filament tab if there are errors there - if (validation.errors.slicer_filament || validation.errors.material) { + if (validation.errors.slicer_filament || validation.errors.material || validation.errors.brand || validation.errors.subtype) { setActiveTab('filament'); } return; @@ -438,6 +438,12 @@ export function SpoolFormModal({ isOpen, onClose, spool, printersWithCalibration {errors.material && (

{errors.material}

)} + {errors.brand && ( +

{errors.brand}

+ )} + {errors.subtype && ( +

{errors.subtype}

+ )} {/* Color Section */} diff --git a/frontend/src/components/spool-form/FilamentSection.tsx b/frontend/src/components/spool-form/FilamentSection.tsx index cc5748d8c..297aa9e32 100644 --- a/frontend/src/components/spool-form/FilamentSection.tsx +++ b/frontend/src/components/spool-form/FilamentSection.tsx @@ -161,7 +161,7 @@ export function FilamentSection({ {/* Brand (dropdown with search) */}
- +
- +
{/* Status badge + Actions */} - {/* eslint-disable-next-line jsx-a11y/click-events-have-key-events, jsx-a11y/no-static-element-interactions */}
e.stopPropagation()}> diff --git a/static/assets/index-DmiEmqVo.js b/static/assets/index-BLcYYvbZ.js similarity index 94% rename from static/assets/index-DmiEmqVo.js rename to static/assets/index-BLcYYvbZ.js index 00a3b329d..b6f3945b1 100644 --- a/static/assets/index-DmiEmqVo.js +++ b/static/assets/index-BLcYYvbZ.js @@ -8661,12 +8661,14 @@ Accuracy: ${t.time_accuracy.toFixed(0)}%`:t.actual_time_seconds?`Actual: ${Zs(t. To pick up a draggable item, press the space bar. While dragging, use the arrow keys to move the item. Press space again to drop the item in its new position, or press escape to cancel. - `},tYe={onDragStart(t){let{active:e}=t;return"Picked up draggable item "+e.id+"."},onDragOver(t){let{active:e,over:n}=t;return n?"Draggable item "+e.id+" was moved over droppable area "+n.id+".":"Draggable item "+e.id+" is no longer over a droppable area."},onDragEnd(t){let{active:e,over:n}=t;return n?"Draggable item "+e.id+" was dropped over droppable area "+n.id:"Draggable item "+e.id+" was dropped."},onDragCancel(t){let{active:e}=t;return"Dragging was cancelled. Draggable item "+e.id+" was dropped."}};function nYe(t){let{announcements:e=tYe,container:n,hiddenTextDescribedById:r,screenReaderInstructions:i=eYe}=t;const{announce:s,announcement:o}=QXe(),l=Jv("DndLiveRegion"),[c,u]=w.useState(!1);if(w.useEffect(()=>{u(!0)},[]),ZXe(w.useMemo(()=>({onDragStart(h){let{active:f}=h;s(e.onDragStart({active:f}))},onDragMove(h){let{active:f,over:p}=h;e.onDragMove&&s(e.onDragMove({active:f,over:p}))},onDragOver(h){let{active:f,over:p}=h;s(e.onDragOver({active:f,over:p}))},onDragEnd(h){let{active:f,over:p}=h;s(e.onDragEnd({active:f,over:p}))},onDragCancel(h){let{active:f,over:p}=h;s(e.onDragCancel({active:f,over:p}))}}),[s,e])),!c)return null;const d=$r.createElement($r.Fragment,null,$r.createElement(XXe,{id:r,value:i.draggable}),$r.createElement(YXe,{id:l,announcement:o}));return n?Ou.createPortal(d,n):d}var da;(function(t){t.DragStart="dragStart",t.DragMove="dragMove",t.DragEnd="dragEnd",t.DragCancel="dragCancel",t.DragOver="dragOver",t.RegisterDroppable="registerDroppable",t.SetDroppableDisabled="setDroppableDisabled",t.UnregisterDroppable="unregisterDroppable"})(da||(da={}));function $k(){}function Vk(t,e){return w.useMemo(()=>({sensor:t,options:e??{}}),[t,e])}function xae(){for(var t=arguments.length,e=new Array(t),n=0;n[...e].filter(r=>r!=null),[...e])}const Jl=Object.freeze({x:0,y:0});function yae(t,e){return Math.sqrt(Math.pow(t.x-e.x,2)+Math.pow(t.y-e.y,2))}function vae(t,e){let{data:{value:n}}=t,{data:{value:r}}=e;return n-r}function rYe(t,e){let{data:{value:n}}=t,{data:{value:r}}=e;return r-n}function WW(t){let{left:e,top:n,height:r,width:i}=t;return[{x:e,y:n},{x:e+i,y:n},{x:e,y:n+r},{x:e+i,y:n+r}]}function wae(t,e){if(!t||t.length===0)return null;const[n]=t;return n[e]}function KW(t,e,n){return e===void 0&&(e=t.left),n===void 0&&(n=t.top),{x:e+t.width*.5,y:n+t.height*.5}}const _ae=t=>{let{collisionRect:e,droppableRects:n,droppableContainers:r}=t;const i=KW(e,e.left,e.top),s=[];for(const o of r){const{id:l}=o,c=n.get(l);if(c){const u=yae(KW(c),i);s.push({id:l,data:{droppableContainer:o,value:u}})}}return s.sort(vae)},iYe=t=>{let{collisionRect:e,droppableRects:n,droppableContainers:r}=t;const i=WW(e),s=[];for(const o of r){const{id:l}=o,c=n.get(l);if(c){const u=WW(c),d=i.reduce((f,p,x)=>f+yae(u[x],p),0),h=Number((d/4).toFixed(4));s.push({id:l,data:{droppableContainer:o,value:h}})}}return s.sort(vae)};function aYe(t,e){const n=Math.max(e.top,t.top),r=Math.max(e.left,t.left),i=Math.min(e.left+e.width,t.left+t.width),s=Math.min(e.top+e.height,t.top+t.height),o=i-r,l=s-n;if(r{let{collisionRect:e,droppableRects:n,droppableContainers:r}=t;const i=[];for(const s of r){const{id:o}=s,l=n.get(o);if(l){const c=aYe(l,e);c>0&&i.push({id:o,data:{droppableContainer:s,value:c}})}}return i.sort(rYe)};function oYe(t,e,n){return{...t,scaleX:e&&n?e.width/n.width:1,scaleY:e&&n?e.height/n.height:1}}function Sae(t,e){return t&&e?{x:t.left-e.left,y:t.top-e.top}:Jl}function lYe(t){return function(n){for(var r=arguments.length,i=new Array(r>1?r-1:0),s=1;s({...o,top:o.top+t*l.y,bottom:o.bottom+t*l.y,left:o.left+t*l.x,right:o.right+t*l.x}),{...n})}}const cYe=lYe(1);function uYe(t){if(t.startsWith("matrix3d(")){const e=t.slice(9,-1).split(/, /);return{x:+e[12],y:+e[13],scaleX:+e[0],scaleY:+e[5]}}else if(t.startsWith("matrix(")){const e=t.slice(7,-1).split(/, /);return{x:+e[4],y:+e[5],scaleX:+e[0],scaleY:+e[3]}}return null}function dYe(t,e,n){const r=uYe(e);if(!r)return t;const{scaleX:i,scaleY:s,x:o,y:l}=r,c=t.left-o-(1-i)*parseFloat(n),u=t.top-l-(1-s)*parseFloat(n.slice(n.indexOf(" ")+1)),d=i?t.width/i:t.width,h=s?t.height/s:t.height;return{width:d,height:h,top:u,right:c+d,bottom:u+h,left:c}}const hYe={ignoreTransform:!1};function mx(t,e){e===void 0&&(e=hYe);let n=t.getBoundingClientRect();if(e.ignoreTransform){const{transform:u,transformOrigin:d}=uo(t).getComputedStyle(t);u&&(n=dYe(n,u,d))}const{top:r,left:i,width:s,height:o,bottom:l,right:c}=n;return{top:r,left:i,width:s,height:o,bottom:l,right:c}}function XW(t){return mx(t,{ignoreTransform:!0})}function mYe(t){const e=t.innerWidth,n=t.innerHeight;return{top:0,left:0,right:e,bottom:n,width:e,height:n}}function fYe(t,e){return e===void 0&&(e=uo(t).getComputedStyle(t)),e.position==="fixed"}function pYe(t,e){e===void 0&&(e=uo(t).getComputedStyle(t));const n=/(auto|scroll|overlay)/;return["overflow","overflowX","overflowY"].some(i=>{const s=e[i];return typeof s=="string"?n.test(s):!1})}function FM(t,e){const n=[];function r(i){if(e!=null&&n.length>=e||!i)return n;if(hI(i)&&i.scrollingElement!=null&&!n.includes(i.scrollingElement))return n.push(i.scrollingElement),n;if(!Qv(i)||pae(i)||n.includes(i))return n;const s=uo(t).getComputedStyle(i);return i!==t&&pYe(i,s)&&n.push(i),fYe(i,s)?n:r(i.parentNode)}return t?r(t):n}function Nae(t){const[e]=FM(t,1);return e??null}function Oj(t){return!RM||!t?null:dx(t)?t:dI(t)?hI(t)||t===hx(t).scrollingElement?window:Qv(t)?t:null:null}function kae(t){return dx(t)?t.scrollX:t.scrollLeft}function Cae(t){return dx(t)?t.scrollY:t.scrollTop}function dF(t){return{x:kae(t),y:Cae(t)}}var Ra;(function(t){t[t.Forward=1]="Forward",t[t.Backward=-1]="Backward"})(Ra||(Ra={}));function Mae(t){return!RM||!t?!1:t===document.scrollingElement}function Aae(t){const e={x:0,y:0},n=Mae(t)?{height:window.innerHeight,width:window.innerWidth}:{height:t.clientHeight,width:t.clientWidth},r={x:t.scrollWidth-n.width,y:t.scrollHeight-n.height},i=t.scrollTop<=e.y,s=t.scrollLeft<=e.x,o=t.scrollTop>=r.y,l=t.scrollLeft>=r.x;return{isTop:i,isLeft:s,isBottom:o,isRight:l,maxScroll:r,minScroll:e}}const gYe={x:.2,y:.2};function bYe(t,e,n,r,i){let{top:s,left:o,right:l,bottom:c}=n;r===void 0&&(r=10),i===void 0&&(i=gYe);const{isTop:u,isBottom:d,isLeft:h,isRight:f}=Aae(t),p={x:0,y:0},x={x:0,y:0},y={height:e.height*i.y,width:e.width*i.x};return!u&&s<=e.top+y.height?(p.y=Ra.Backward,x.y=r*Math.abs((e.top+y.height-s)/y.height)):!d&&c>=e.bottom-y.height&&(p.y=Ra.Forward,x.y=r*Math.abs((e.bottom-y.height-c)/y.height)),!f&&l>=e.right-y.width?(p.x=Ra.Forward,x.x=r*Math.abs((e.right-y.width-l)/y.width)):!h&&o<=e.left+y.width&&(p.x=Ra.Backward,x.x=r*Math.abs((e.left+y.width-o)/y.width)),{direction:p,speed:x}}function xYe(t){if(t===document.scrollingElement){const{innerWidth:s,innerHeight:o}=window;return{top:0,left:0,right:s,bottom:o,width:s,height:o}}const{top:e,left:n,right:r,bottom:i}=t.getBoundingClientRect();return{top:e,left:n,right:r,bottom:i,width:t.clientWidth,height:t.clientHeight}}function Tae(t){return t.reduce((e,n)=>ub(e,dF(n)),Jl)}function yYe(t){return t.reduce((e,n)=>e+kae(n),0)}function vYe(t){return t.reduce((e,n)=>e+Cae(n),0)}function wYe(t,e){if(e===void 0&&(e=mx),!t)return;const{top:n,left:r,bottom:i,right:s}=e(t);Nae(t)&&(i<=0||s<=0||n>=window.innerHeight||r>=window.innerWidth)&&t.scrollIntoView({block:"center",inline:"center"})}const _Ye=[["x",["left","right"],yYe],["y",["top","bottom"],vYe]];class pI{constructor(e,n){this.rect=void 0,this.width=void 0,this.height=void 0,this.top=void 0,this.bottom=void 0,this.right=void 0,this.left=void 0;const r=FM(n),i=Tae(r);this.rect={...e},this.width=e.width,this.height=e.height;for(const[s,o,l]of _Ye)for(const c of o)Object.defineProperty(this,c,{get:()=>{const u=l(r),d=i[s]-u;return this.rect[c]+d},enumerable:!0});Object.defineProperty(this,"rect",{enumerable:!1})}}class p0{constructor(e){this.target=void 0,this.listeners=[],this.removeAll=()=>{this.listeners.forEach(n=>{var r;return(r=this.target)==null?void 0:r.removeEventListener(...n)})},this.target=e}add(e,n,r){var i;(i=this.target)==null||i.addEventListener(e,n,r),this.listeners.push([e,n,r])}}function SYe(t){const{EventTarget:e}=uo(t);return t instanceof e?t:hx(t)}function Ij(t,e){const n=Math.abs(t.x),r=Math.abs(t.y);return typeof e=="number"?Math.sqrt(n**2+r**2)>e:"x"in e&&"y"in e?n>e.x&&r>e.y:"x"in e?n>e.x:"y"in e?r>e.y:!1}var il;(function(t){t.Click="click",t.DragStart="dragstart",t.Keydown="keydown",t.ContextMenu="contextmenu",t.Resize="resize",t.SelectionChange="selectionchange",t.VisibilityChange="visibilitychange"})(il||(il={}));function YW(t){t.preventDefault()}function NYe(t){t.stopPropagation()}var ir;(function(t){t.Space="Space",t.Down="ArrowDown",t.Right="ArrowRight",t.Left="ArrowLeft",t.Up="ArrowUp",t.Esc="Escape",t.Enter="Enter",t.Tab="Tab"})(ir||(ir={}));const Eae={start:[ir.Space,ir.Enter],cancel:[ir.Esc],end:[ir.Space,ir.Enter,ir.Tab]},kYe=(t,e)=>{let{currentCoordinates:n}=e;switch(t.code){case ir.Right:return{...n,x:n.x+25};case ir.Left:return{...n,x:n.x-25};case ir.Down:return{...n,y:n.y+25};case ir.Up:return{...n,y:n.y-25}}};class LM{constructor(e){this.props=void 0,this.autoScrollEnabled=!1,this.referenceCoordinates=void 0,this.listeners=void 0,this.windowListeners=void 0,this.props=e;const{event:{target:n}}=e;this.props=e,this.listeners=new p0(hx(n)),this.windowListeners=new p0(uo(n)),this.handleKeyDown=this.handleKeyDown.bind(this),this.handleCancel=this.handleCancel.bind(this),this.attach()}attach(){this.handleStart(),this.windowListeners.add(il.Resize,this.handleCancel),this.windowListeners.add(il.VisibilityChange,this.handleCancel),setTimeout(()=>this.listeners.add(il.Keydown,this.handleKeyDown))}handleStart(){const{activeNode:e,onStart:n}=this.props,r=e.node.current;r&&wYe(r),n(Jl)}handleKeyDown(e){if(fI(e)){const{active:n,context:r,options:i}=this.props,{keyboardCodes:s=Eae,coordinateGetter:o=kYe,scrollBehavior:l="smooth"}=i,{code:c}=e;if(s.end.includes(c)){this.handleEnd(e);return}if(s.cancel.includes(c)){this.handleCancel(e);return}const{collisionRect:u}=r.current,d=u?{x:u.left,y:u.top}:Jl;this.referenceCoordinates||(this.referenceCoordinates=d);const h=o(e,{active:n,context:r.current,currentCoordinates:d});if(h){const f=dv(h,d),p={x:0,y:0},{scrollableAncestors:x}=r.current;for(const y of x){const b=e.code,{isTop:v,isRight:S,isLeft:N,isBottom:A,maxScroll:C,minScroll:T}=Aae(y),k=xYe(y),j={x:Math.min(b===ir.Right?k.right-k.width/2:k.right,Math.max(b===ir.Right?k.left:k.left+k.width/2,h.x)),y:Math.min(b===ir.Down?k.bottom-k.height/2:k.bottom,Math.max(b===ir.Down?k.top:k.top+k.height/2,h.y))},E=b===ir.Right&&!S||b===ir.Left&&!N,P=b===ir.Down&&!A||b===ir.Up&&!v;if(E&&j.x!==h.x){const U=y.scrollLeft+f.x,O=b===ir.Right&&U<=C.x||b===ir.Left&&U>=T.x;if(O&&!f.y){y.scrollTo({left:U,behavior:l});return}O?p.x=y.scrollLeft-U:p.x=b===ir.Right?y.scrollLeft-C.x:y.scrollLeft-T.x,p.x&&y.scrollBy({left:-p.x,behavior:l});break}else if(P&&j.y!==h.y){const U=y.scrollTop+f.y,O=b===ir.Down&&U<=C.y||b===ir.Up&&U>=T.y;if(O&&!f.x){y.scrollTo({top:U,behavior:l});return}O?p.y=y.scrollTop-U:p.y=b===ir.Down?y.scrollTop-C.y:y.scrollTop-T.y,p.y&&y.scrollBy({top:-p.y,behavior:l});break}}this.handleMove(e,ub(dv(h,this.referenceCoordinates),p))}}}handleMove(e,n){const{onMove:r}=this.props;e.preventDefault(),r(n)}handleEnd(e){const{onEnd:n}=this.props;e.preventDefault(),this.detach(),n()}handleCancel(e){const{onCancel:n}=this.props;e.preventDefault(),this.detach(),n()}detach(){this.listeners.removeAll(),this.windowListeners.removeAll()}}LM.activators=[{eventName:"onKeyDown",handler:(t,e,n)=>{let{keyboardCodes:r=Eae,onActivation:i}=e,{active:s}=n;const{code:o}=t.nativeEvent;if(r.start.includes(o)){const l=s.activatorNode.current;return l&&t.target!==l?!1:(t.preventDefault(),i?.({event:t.nativeEvent}),!0)}return!1}}];function QW(t){return!!(t&&"distance"in t)}function ZW(t){return!!(t&&"delay"in t)}class gI{constructor(e,n,r){var i;r===void 0&&(r=SYe(e.event.target)),this.props=void 0,this.events=void 0,this.autoScrollEnabled=!0,this.document=void 0,this.activated=!1,this.initialCoordinates=void 0,this.timeoutId=null,this.listeners=void 0,this.documentListeners=void 0,this.windowListeners=void 0,this.props=e,this.events=n;const{event:s}=e,{target:o}=s;this.props=e,this.events=n,this.document=hx(o),this.documentListeners=new p0(this.document),this.listeners=new p0(r),this.windowListeners=new p0(uo(o)),this.initialCoordinates=(i=uF(s))!=null?i:Jl,this.handleStart=this.handleStart.bind(this),this.handleMove=this.handleMove.bind(this),this.handleEnd=this.handleEnd.bind(this),this.handleCancel=this.handleCancel.bind(this),this.handleKeydown=this.handleKeydown.bind(this),this.removeTextSelection=this.removeTextSelection.bind(this),this.attach()}attach(){const{events:e,props:{options:{activationConstraint:n,bypassActivationConstraint:r}}}=this;if(this.listeners.add(e.move.name,this.handleMove,{passive:!1}),this.listeners.add(e.end.name,this.handleEnd),e.cancel&&this.listeners.add(e.cancel.name,this.handleCancel),this.windowListeners.add(il.Resize,this.handleCancel),this.windowListeners.add(il.DragStart,YW),this.windowListeners.add(il.VisibilityChange,this.handleCancel),this.windowListeners.add(il.ContextMenu,YW),this.documentListeners.add(il.Keydown,this.handleKeydown),n){if(r!=null&&r({event:this.props.event,activeNode:this.props.activeNode,options:this.props.options}))return this.handleStart();if(ZW(n)){this.timeoutId=setTimeout(this.handleStart,n.delay),this.handlePending(n);return}if(QW(n)){this.handlePending(n);return}}this.handleStart()}detach(){this.listeners.removeAll(),this.windowListeners.removeAll(),setTimeout(this.documentListeners.removeAll,50),this.timeoutId!==null&&(clearTimeout(this.timeoutId),this.timeoutId=null)}handlePending(e,n){const{active:r,onPending:i}=this.props;i(r,e,this.initialCoordinates,n)}handleStart(){const{initialCoordinates:e}=this,{onStart:n}=this.props;e&&(this.activated=!0,this.documentListeners.add(il.Click,NYe,{capture:!0}),this.removeTextSelection(),this.documentListeners.add(il.SelectionChange,this.removeTextSelection),n(e))}handleMove(e){var n;const{activated:r,initialCoordinates:i,props:s}=this,{onMove:o,options:{activationConstraint:l}}=s;if(!i)return;const c=(n=uF(e))!=null?n:Jl,u=dv(i,c);if(!r&&l){if(QW(l)){if(l.tolerance!=null&&Ij(u,l.tolerance))return this.handleCancel();if(Ij(u,l.distance))return this.handleStart()}if(ZW(l)&&Ij(u,l.tolerance))return this.handleCancel();this.handlePending(l,u);return}e.cancelable&&e.preventDefault(),o(c)}handleEnd(){const{onAbort:e,onEnd:n}=this.props;this.detach(),this.activated||e(this.props.active),n()}handleCancel(){const{onAbort:e,onCancel:n}=this.props;this.detach(),this.activated||e(this.props.active),n()}handleKeydown(e){e.code===ir.Esc&&this.handleCancel()}removeTextSelection(){var e;(e=this.document.getSelection())==null||e.removeAllRanges()}}const CYe={cancel:{name:"pointercancel"},move:{name:"pointermove"},end:{name:"pointerup"}};class OM extends gI{constructor(e){const{event:n}=e,r=hx(n.target);super(e,CYe,r)}}OM.activators=[{eventName:"onPointerDown",handler:(t,e)=>{let{nativeEvent:n}=t,{onActivation:r}=e;return!n.isPrimary||n.button!==0?!1:(r?.({event:n}),!0)}}];const MYe={move:{name:"mousemove"},end:{name:"mouseup"}};var hF;(function(t){t[t.RightClick=2]="RightClick"})(hF||(hF={}));class AYe extends gI{constructor(e){super(e,MYe,hx(e.event.target))}}AYe.activators=[{eventName:"onMouseDown",handler:(t,e)=>{let{nativeEvent:n}=t,{onActivation:r}=e;return n.button===hF.RightClick?!1:(r?.({event:n}),!0)}}];const zj={cancel:{name:"touchcancel"},move:{name:"touchmove"},end:{name:"touchend"}};class TYe extends gI{constructor(e){super(e,zj)}static setup(){return window.addEventListener(zj.move.name,e,{capture:!1,passive:!1}),function(){window.removeEventListener(zj.move.name,e)};function e(){}}}TYe.activators=[{eventName:"onTouchStart",handler:(t,e)=>{let{nativeEvent:n}=t,{onActivation:r}=e;const{touches:i}=n;return i.length>1?!1:(r?.({event:n}),!0)}}];var g0;(function(t){t[t.Pointer=0]="Pointer",t[t.DraggableRect=1]="DraggableRect"})(g0||(g0={}));var Gk;(function(t){t[t.TreeOrder=0]="TreeOrder",t[t.ReversedTreeOrder=1]="ReversedTreeOrder"})(Gk||(Gk={}));function EYe(t){let{acceleration:e,activator:n=g0.Pointer,canScroll:r,draggingRect:i,enabled:s,interval:o=5,order:l=Gk.TreeOrder,pointerCoordinates:c,scrollableAncestors:u,scrollableAncestorRects:d,delta:h,threshold:f}=t;const p=jYe({delta:h,disabled:!s}),[x,y]=VXe(),b=w.useRef({x:0,y:0}),v=w.useRef({x:0,y:0}),S=w.useMemo(()=>{switch(n){case g0.Pointer:return c?{top:c.y,bottom:c.y,left:c.x,right:c.x}:null;case g0.DraggableRect:return i}},[n,i,c]),N=w.useRef(null),A=w.useCallback(()=>{const T=N.current;if(!T)return;const k=b.current.x*v.current.x,j=b.current.y*v.current.y;T.scrollBy(k,j)},[]),C=w.useMemo(()=>l===Gk.TreeOrder?[...u].reverse():u,[l,u]);w.useEffect(()=>{if(!s||!u.length||!S){y();return}for(const T of C){if(r?.(T)===!1)continue;const k=u.indexOf(T),j=d[k];if(!j)continue;const{direction:E,speed:P}=bYe(T,j,S,e,f);for(const U of["x","y"])p[U][E[U]]||(P[U]=0,E[U]=0);if(P.x>0||P.y>0){y(),N.current=T,x(A,o),b.current=P,v.current=E;return}}b.current={x:0,y:0},v.current={x:0,y:0},y()},[e,A,r,y,s,o,JSON.stringify(S),JSON.stringify(p),x,u,C,d,JSON.stringify(f)])}const PYe={x:{[Ra.Backward]:!1,[Ra.Forward]:!1},y:{[Ra.Backward]:!1,[Ra.Forward]:!1}};function jYe(t){let{delta:e,disabled:n}=t;const r=cF(e);return Zv(i=>{if(n||!r||!i)return PYe;const s={x:Math.sign(e.x-r.x),y:Math.sign(e.y-r.y)};return{x:{[Ra.Backward]:i.x[Ra.Backward]||s.x===-1,[Ra.Forward]:i.x[Ra.Forward]||s.x===1},y:{[Ra.Backward]:i.y[Ra.Backward]||s.y===-1,[Ra.Forward]:i.y[Ra.Forward]||s.y===1}}},[n,e,r])}function DYe(t,e){const n=e!=null?t.get(e):void 0,r=n?n.node.current:null;return Zv(i=>{var s;return e==null?null:(s=r??i)!=null?s:null},[r,e])}function RYe(t,e){return w.useMemo(()=>t.reduce((n,r)=>{const{sensor:i}=r,s=i.activators.map(o=>({eventName:o.eventName,handler:e(o.handler,r)}));return[...n,...s]},[]),[t,e])}var hv;(function(t){t[t.Always=0]="Always",t[t.BeforeDragging=1]="BeforeDragging",t[t.WhileDragging=2]="WhileDragging"})(hv||(hv={}));var mF;(function(t){t.Optimized="optimized"})(mF||(mF={}));const JW=new Map;function FYe(t,e){let{dragging:n,dependencies:r,config:i}=e;const[s,o]=w.useState(null),{frequency:l,measure:c,strategy:u}=i,d=w.useRef(t),h=b(),f=uv(h),p=w.useCallback(function(v){v===void 0&&(v=[]),!f.current&&o(S=>S===null?v:S.concat(v.filter(N=>!S.includes(N))))},[f]),x=w.useRef(null),y=Zv(v=>{if(h&&!n)return JW;if(!v||v===JW||d.current!==t||s!=null){const S=new Map;for(let N of t){if(!N)continue;if(s&&s.length>0&&!s.includes(N.id)&&N.rect.current){S.set(N.id,N.rect.current);continue}const A=N.node.current,C=A?new pI(c(A),A):null;N.rect.current=C,C&&S.set(N.id,C)}return S}return v},[t,s,n,h,c]);return w.useEffect(()=>{d.current=t},[t]),w.useEffect(()=>{h||p()},[n,h]),w.useEffect(()=>{s&&s.length>0&&o(null)},[JSON.stringify(s)]),w.useEffect(()=>{h||typeof l!="number"||x.current!==null||(x.current=setTimeout(()=>{p(),x.current=null},l))},[l,h,p,...r]),{droppableRects:y,measureDroppableContainers:p,measuringScheduled:s!=null};function b(){switch(u){case hv.Always:return!1;case hv.BeforeDragging:return n;default:return!n}}}function Pae(t,e){return Zv(n=>t?n||(typeof e=="function"?e(t):t):null,[e,t])}function LYe(t,e){return Pae(t,e)}function OYe(t){let{callback:e,disabled:n}=t;const r=mI(e),i=w.useMemo(()=>{if(n||typeof window>"u"||typeof window.MutationObserver>"u")return;const{MutationObserver:s}=window;return new s(r)},[r,n]);return w.useEffect(()=>()=>i?.disconnect(),[i]),i}function IM(t){let{callback:e,disabled:n}=t;const r=mI(e),i=w.useMemo(()=>{if(n||typeof window>"u"||typeof window.ResizeObserver>"u")return;const{ResizeObserver:s}=window;return new s(r)},[n]);return w.useEffect(()=>()=>i?.disconnect(),[i]),i}function IYe(t){return new pI(mx(t),t)}function eK(t,e,n){e===void 0&&(e=IYe);const[r,i]=w.useState(null);function s(){i(c=>{if(!t)return null;if(t.isConnected===!1){var u;return(u=c??n)!=null?u:null}const d=e(t);return JSON.stringify(c)===JSON.stringify(d)?c:d})}const o=OYe({callback(c){if(t)for(const u of c){const{type:d,target:h}=u;if(d==="childList"&&h instanceof HTMLElement&&h.contains(t)){s();break}}}}),l=IM({callback:s});return Bc(()=>{s(),t?(l?.observe(t),o?.observe(document.body,{childList:!0,subtree:!0})):(l?.disconnect(),o?.disconnect())},[t]),r}function zYe(t){const e=Pae(t);return Sae(t,e)}const tK=[];function UYe(t){const e=w.useRef(t),n=Zv(r=>t?r&&r!==tK&&t&&e.current&&t.parentNode===e.current.parentNode?r:FM(t):tK,[t]);return w.useEffect(()=>{e.current=t},[t]),n}function BYe(t){const[e,n]=w.useState(null),r=w.useRef(t),i=w.useCallback(s=>{const o=Oj(s.target);o&&n(l=>l?(l.set(o,dF(o)),new Map(l)):null)},[]);return w.useEffect(()=>{const s=r.current;if(t!==s){o(s);const l=t.map(c=>{const u=Oj(c);return u?(u.addEventListener("scroll",i,{passive:!0}),[u,dF(u)]):null}).filter(c=>c!=null);n(l.length?new Map(l):null),r.current=t}return()=>{o(t),o(s)};function o(l){l.forEach(c=>{const u=Oj(c);u?.removeEventListener("scroll",i)})}},[i,t]),w.useMemo(()=>t.length?e?Array.from(e.values()).reduce((s,o)=>ub(s,o),Jl):Tae(t):Jl,[t,e])}function nK(t,e){e===void 0&&(e=[]);const n=w.useRef(null);return w.useEffect(()=>{n.current=null},e),w.useEffect(()=>{const r=t!==Jl;r&&!n.current&&(n.current=t),!r&&n.current&&(n.current=null)},[t]),n.current?dv(t,n.current):Jl}function HYe(t){w.useEffect(()=>{if(!RM)return;const e=t.map(n=>{let{sensor:r}=n;return r.setup==null?void 0:r.setup()});return()=>{for(const n of e)n?.()}},t.map(e=>{let{sensor:n}=e;return n}))}function $Ye(t,e){return w.useMemo(()=>t.reduce((n,r)=>{let{eventName:i,handler:s}=r;return n[i]=o=>{s(o,e)},n},{}),[t,e])}function jae(t){return w.useMemo(()=>t?mYe(t):null,[t])}const rK=[];function VYe(t,e){e===void 0&&(e=mx);const[n]=t,r=jae(n?uo(n):null),[i,s]=w.useState(rK);function o(){s(()=>t.length?t.map(c=>Mae(c)?r:new pI(e(c),c)):rK)}const l=IM({callback:o});return Bc(()=>{l?.disconnect(),o(),t.forEach(c=>l?.observe(c))},[t]),i}function GYe(t){if(!t)return null;if(t.children.length>1)return t;const e=t.children[0];return Qv(e)?e:t}function qYe(t){let{measure:e}=t;const[n,r]=w.useState(null),i=w.useCallback(u=>{for(const{target:d}of u)if(Qv(d)){r(h=>{const f=e(d);return h?{...h,width:f.width,height:f.height}:f});break}},[e]),s=IM({callback:i}),o=w.useCallback(u=>{const d=GYe(u);s?.disconnect(),d&&s?.observe(d),r(d?e(d):null)},[e,s]),[l,c]=Hk(o);return w.useMemo(()=>({nodeRef:l,rect:n,setRef:c}),[n,l,c])}const WYe=[{sensor:OM,options:{}},{sensor:LM,options:{}}],KYe={current:{}},_1={draggable:{measure:XW},droppable:{measure:XW,strategy:hv.WhileDragging,frequency:mF.Optimized},dragOverlay:{measure:mx}};class b0 extends Map{get(e){var n;return e!=null&&(n=super.get(e))!=null?n:void 0}toArray(){return Array.from(this.values())}getEnabled(){return this.toArray().filter(e=>{let{disabled:n}=e;return!n})}getNodeFor(e){var n,r;return(n=(r=this.get(e))==null?void 0:r.node.current)!=null?n:void 0}}const XYe={activatorEvent:null,active:null,activeNode:null,activeNodeRect:null,collisions:null,containerNodeRect:null,draggableNodes:new Map,droppableRects:new Map,droppableContainers:new b0,over:null,dragOverlay:{nodeRef:{current:null},rect:null,setRef:$k},scrollableAncestors:[],scrollableAncestorRects:[],measuringConfiguration:_1,measureDroppableContainers:$k,windowRect:null,measuringScheduled:!1},YYe={activatorEvent:null,activators:[],active:null,activeNodeRect:null,ariaDescribedById:{draggable:""},dispatch:$k,draggableNodes:new Map,over:null,measureDroppableContainers:$k},zM=w.createContext(YYe),Dae=w.createContext(XYe);function QYe(){return{draggable:{active:null,initialCoordinates:{x:0,y:0},nodes:new Map,translate:{x:0,y:0}},droppable:{containers:new b0}}}function ZYe(t,e){switch(e.type){case da.DragStart:return{...t,draggable:{...t.draggable,initialCoordinates:e.initialCoordinates,active:e.active}};case da.DragMove:return t.draggable.active==null?t:{...t,draggable:{...t.draggable,translate:{x:e.coordinates.x-t.draggable.initialCoordinates.x,y:e.coordinates.y-t.draggable.initialCoordinates.y}}};case da.DragEnd:case da.DragCancel:return{...t,draggable:{...t.draggable,active:null,initialCoordinates:{x:0,y:0},translate:{x:0,y:0}}};case da.RegisterDroppable:{const{element:n}=e,{id:r}=n,i=new b0(t.droppable.containers);return i.set(r,n),{...t,droppable:{...t.droppable,containers:i}}}case da.SetDroppableDisabled:{const{id:n,key:r,disabled:i}=e,s=t.droppable.containers.get(n);if(!s||r!==s.key)return t;const o=new b0(t.droppable.containers);return o.set(n,{...s,disabled:i}),{...t,droppable:{...t.droppable,containers:o}}}case da.UnregisterDroppable:{const{id:n,key:r}=e,i=t.droppable.containers.get(n);if(!i||r!==i.key)return t;const s=new b0(t.droppable.containers);return s.delete(n),{...t,droppable:{...t.droppable,containers:s}}}default:return t}}function JYe(t){let{disabled:e}=t;const{active:n,activatorEvent:r,draggableNodes:i}=w.useContext(zM),s=cF(r),o=cF(n?.id);return w.useEffect(()=>{if(!e&&!r&&s&&o!=null){if(!fI(s)||document.activeElement===s.target)return;const l=i.get(o);if(!l)return;const{activatorNode:c,node:u}=l;if(!c.current&&!u.current)return;requestAnimationFrame(()=>{for(const d of[c.current,u.current]){if(!d)continue;const h=WXe(d);if(h){h.focus();break}}})}},[r,e,i,o,s]),null}function eQe(t,e){let{transform:n,...r}=e;return t!=null&&t.length?t.reduce((i,s)=>s({transform:i,...r}),n):n}function tQe(t){return w.useMemo(()=>({draggable:{..._1.draggable,...t?.draggable},droppable:{..._1.droppable,...t?.droppable},dragOverlay:{..._1.dragOverlay,...t?.dragOverlay}}),[t?.draggable,t?.droppable,t?.dragOverlay])}function nQe(t){let{activeNode:e,measure:n,initialRect:r,config:i=!0}=t;const s=w.useRef(!1),{x:o,y:l}=typeof i=="boolean"?{x:i,y:i}:i;Bc(()=>{if(!o&&!l||!e){s.current=!1;return}if(s.current||!r)return;const u=e?.node.current;if(!u||u.isConnected===!1)return;const d=n(u),h=Sae(d,r);if(o||(h.x=0),l||(h.y=0),s.current=!0,Math.abs(h.x)>0||Math.abs(h.y)>0){const f=Nae(u);f&&f.scrollBy({top:h.y,left:h.x})}},[e,o,l,r,n])}const Rae=w.createContext({...Jl,scaleX:1,scaleY:1});var ph;(function(t){t[t.Uninitialized=0]="Uninitialized",t[t.Initializing=1]="Initializing",t[t.Initialized=2]="Initialized"})(ph||(ph={}));const Fae=w.memo(function(e){var n,r,i,s;let{id:o,accessibility:l,autoScroll:c=!0,children:u,sensors:d=WYe,collisionDetection:h=sYe,measuring:f,modifiers:p,...x}=e;const y=w.useReducer(ZYe,void 0,QYe),[b,v]=y,[S,N]=JXe(),[A,C]=w.useState(ph.Uninitialized),T=A===ph.Initialized,{draggable:{active:k,nodes:j,translate:E},droppable:{containers:P}}=b,U=k!=null?j.get(k):null,O=w.useRef({initial:null,translated:null}),B=w.useMemo(()=>{var Xe;return k!=null?{id:k,data:(Xe=U?.data)!=null?Xe:KYe,rect:O}:null},[k,U]),R=w.useRef(null),[G,q]=w.useState(null),[z,K]=w.useState(null),Y=uv(x,Object.values(x)),oe=Jv("DndDescribedBy",o),$=w.useMemo(()=>P.getEnabled(),[P]),X=tQe(f),{droppableRects:ee,measureDroppableContainers:J,measuringScheduled:_e}=FYe($,{dragging:T,dependencies:[E.x,E.y],config:X.droppable}),pe=DYe(j,k),me=w.useMemo(()=>z?uF(z):null,[z]),je=Pe(),de=LYe(pe,X.draggable.measure);nQe({activeNode:k!=null?j.get(k):null,config:je.layoutShiftCompensation,initialRect:de,measure:X.draggable.measure});const ce=eK(pe,X.draggable.measure,de),Se=eK(pe?pe.parentElement:null),ie=w.useRef({activatorEvent:null,active:null,activeNode:pe,collisionRect:null,collisions:null,droppableRects:ee,draggableNodes:j,draggingNode:null,draggingNodeRect:null,droppableContainers:P,over:null,scrollableAncestors:[],scrollAdjustedTranslate:null}),Fe=P.getNodeFor((n=ie.current.over)==null?void 0:n.id),V=qYe({measure:X.dragOverlay.measure}),W=(r=V.nodeRef.current)!=null?r:pe,ue=T?(i=V.rect)!=null?i:ce:null,Q=!!(V.nodeRef.current&&V.rect),se=zYe(Q?null:ce),Z=jae(W?uo(W):null),Ne=UYe(T?Fe??pe:null),ve=VYe(Ne),fe=eQe(p,{transform:{x:E.x-se.x,y:E.y-se.y,scaleX:1,scaleY:1},activatorEvent:z,active:B,activeNodeRect:ce,containerNodeRect:Se,draggingNodeRect:ue,over:ie.current.over,overlayNodeRect:V.rect,scrollableAncestors:Ne,scrollableAncestorRects:ve,windowRect:Z}),L=me?ub(me,E):null,D=BYe(Ne),H=nK(D),he=nK(D,[ce]),xe=ub(fe,H),be=ue?cYe(ue,fe):null,Ue=B&&be?h({active:B,collisionRect:be,droppableRects:ee,droppableContainers:$,pointerCoordinates:L}):null,Oe=wae(Ue,"id"),[Qe,rt]=w.useState(null),we=Q?fe:ub(fe,he),ye=oYe(we,(s=Qe?.rect)!=null?s:null,ce),le=w.useRef(null),Le=w.useCallback((Xe,De)=>{let{sensor:Re,options:qe}=De;if(R.current==null)return;const pt=j.get(R.current);if(!pt)return;const At=Xe.nativeEvent,Rt=new Re({active:R.current,activeNode:pt,event:At,options:qe,context:ie,onAbort(Tt){if(!j.get(Tt))return;const{onDragAbort:xt}=Y.current,wt={id:Tt};xt?.(wt),S({type:"onDragAbort",event:wt})},onPending(Tt,Ie,xt,wt){if(!j.get(Tt))return;const{onDragPending:Tn}=Y.current,fr={id:Tt,constraint:Ie,initialCoordinates:xt,offset:wt};Tn?.(fr),S({type:"onDragPending",event:fr})},onStart(Tt){const Ie=R.current;if(Ie==null)return;const xt=j.get(Ie);if(!xt)return;const{onDragStart:wt}=Y.current,Bt={activatorEvent:At,active:{id:Ie,data:xt.data,rect:O}};Ou.unstable_batchedUpdates(()=>{wt?.(Bt),C(ph.Initializing),v({type:da.DragStart,initialCoordinates:Tt,active:Ie}),S({type:"onDragStart",event:Bt}),q(le.current),K(At)})},onMove(Tt){v({type:da.DragMove,coordinates:Tt})},onEnd:Wt(da.DragEnd),onCancel:Wt(da.DragCancel)});le.current=Rt;function Wt(Tt){return async function(){const{active:xt,collisions:wt,over:Bt,scrollAdjustedTranslate:Tn}=ie.current;let fr=null;if(xt&&Tn){const{cancelDrop:Zn}=Y.current;fr={activatorEvent:At,active:xt,collisions:wt,delta:Tn,over:Bt},Tt===da.DragEnd&&typeof Zn=="function"&&await Promise.resolve(Zn(fr))&&(Tt=da.DragCancel)}R.current=null,Ou.unstable_batchedUpdates(()=>{v({type:Tt}),C(ph.Uninitialized),rt(null),q(null),K(null),le.current=null;const Zn=Tt===da.DragEnd?"onDragEnd":"onDragCancel";if(fr){const Jn=Y.current[Zn];Jn?.(fr),S({type:Zn,event:fr})}})}}},[j]),Me=w.useCallback((Xe,De)=>(Re,qe)=>{const pt=Re.nativeEvent,At=j.get(qe);if(R.current!==null||!At||pt.dndKit||pt.defaultPrevented)return;const Rt={active:At};Xe(Re,De.options,Rt)===!0&&(pt.dndKit={capturedBy:De.sensor},R.current=qe,Le(Re,De))},[j,Le]),$e=RYe(d,Me);HYe(d),Bc(()=>{ce&&A===ph.Initializing&&C(ph.Initialized)},[ce,A]),w.useEffect(()=>{const{onDragMove:Xe}=Y.current,{active:De,activatorEvent:Re,collisions:qe,over:pt}=ie.current;if(!De||!Re)return;const At={active:De,activatorEvent:Re,collisions:qe,delta:{x:xe.x,y:xe.y},over:pt};Ou.unstable_batchedUpdates(()=>{Xe?.(At),S({type:"onDragMove",event:At})})},[xe.x,xe.y]),w.useEffect(()=>{const{active:Xe,activatorEvent:De,collisions:Re,droppableContainers:qe,scrollAdjustedTranslate:pt}=ie.current;if(!Xe||R.current==null||!De||!pt)return;const{onDragOver:At}=Y.current,Rt=qe.get(Oe),Wt=Rt&&Rt.rect.current?{id:Rt.id,rect:Rt.rect.current,data:Rt.data,disabled:Rt.disabled}:null,Tt={active:Xe,activatorEvent:De,collisions:Re,delta:{x:pt.x,y:pt.y},over:Wt};Ou.unstable_batchedUpdates(()=>{rt(Wt),At?.(Tt),S({type:"onDragOver",event:Tt})})},[Oe]),Bc(()=>{ie.current={activatorEvent:z,active:B,activeNode:pe,collisionRect:be,collisions:Ue,droppableRects:ee,draggableNodes:j,draggingNode:W,draggingNodeRect:ue,droppableContainers:P,over:Qe,scrollableAncestors:Ne,scrollAdjustedTranslate:xe},O.current={initial:ue,translated:be}},[B,pe,Ue,be,j,W,ue,ee,P,Qe,Ne,xe]),EYe({...je,delta:E,draggingRect:be,pointerCoordinates:L,scrollableAncestors:Ne,scrollableAncestorRects:ve});const Ae=w.useMemo(()=>({active:B,activeNode:pe,activeNodeRect:ce,activatorEvent:z,collisions:Ue,containerNodeRect:Se,dragOverlay:V,draggableNodes:j,droppableContainers:P,droppableRects:ee,over:Qe,measureDroppableContainers:J,scrollableAncestors:Ne,scrollableAncestorRects:ve,measuringConfiguration:X,measuringScheduled:_e,windowRect:Z}),[B,pe,ce,z,Ue,Se,V,j,P,ee,Qe,J,Ne,ve,X,_e,Z]),Je=w.useMemo(()=>({activatorEvent:z,activators:$e,active:B,activeNodeRect:ce,ariaDescribedById:{draggable:oe},dispatch:v,draggableNodes:j,over:Qe,measureDroppableContainers:J}),[z,$e,B,ce,v,oe,j,Qe,J]);return $r.createElement(bae.Provider,{value:N},$r.createElement(zM.Provider,{value:Je},$r.createElement(Dae.Provider,{value:Ae},$r.createElement(Rae.Provider,{value:ye},u)),$r.createElement(JYe,{disabled:l?.restoreFocus===!1})),$r.createElement(nYe,{...l,hiddenTextDescribedById:oe}));function Pe(){const Xe=G?.autoScrollEnabled===!1,De=typeof c=="object"?c.enabled===!1:c===!1,Re=T&&!Xe&&!De;return typeof c=="object"?{...c,enabled:Re}:{enabled:Re}}}),rQe=w.createContext(null),iK="button",iQe="Draggable";function aQe(t){let{id:e,data:n,disabled:r=!1,attributes:i}=t;const s=Jv(iQe),{activators:o,activatorEvent:l,active:c,activeNodeRect:u,ariaDescribedById:d,draggableNodes:h,over:f}=w.useContext(zM),{role:p=iK,roleDescription:x="draggable",tabIndex:y=0}=i??{},b=c?.id===e,v=w.useContext(b?Rae:rQe),[S,N]=Hk(),[A,C]=Hk(),T=$Ye(o,e),k=uv(n);Bc(()=>(h.set(e,{id:e,key:s,node:S,activatorNode:A,data:k}),()=>{const E=h.get(e);E&&E.key===s&&h.delete(e)}),[h,e]);const j=w.useMemo(()=>({role:p,tabIndex:y,"aria-disabled":r,"aria-pressed":b&&p===iK?!0:void 0,"aria-roledescription":x,"aria-describedby":d.draggable}),[r,p,y,b,x,d.draggable]);return{active:c,activatorEvent:l,activeNodeRect:u,attributes:j,isDragging:b,listeners:r?void 0:T,node:S,over:f,setNodeRef:N,setActivatorNodeRef:C,transform:v}}function sQe(){return w.useContext(Dae)}const oQe="Droppable",lQe={timeout:25};function cQe(t){let{data:e,disabled:n=!1,id:r,resizeObserverConfig:i}=t;const s=Jv(oQe),{active:o,dispatch:l,over:c,measureDroppableContainers:u}=w.useContext(zM),d=w.useRef({disabled:n}),h=w.useRef(!1),f=w.useRef(null),p=w.useRef(null),{disabled:x,updateMeasurementsFor:y,timeout:b}={...lQe,...i},v=uv(y??r),S=w.useCallback(()=>{if(!h.current){h.current=!0;return}p.current!=null&&clearTimeout(p.current),p.current=setTimeout(()=>{u(Array.isArray(v.current)?v.current:[v.current]),p.current=null},b)},[b]),N=IM({callback:S,disabled:x||!o}),A=w.useCallback((j,E)=>{N&&(E&&(N.unobserve(E),h.current=!1),j&&N.observe(j))},[N]),[C,T]=Hk(A),k=uv(e);return w.useEffect(()=>{!N||!C.current||(N.disconnect(),h.current=!1,N.observe(C.current))},[C,N]),w.useEffect(()=>(l({type:da.RegisterDroppable,element:{id:r,key:s,disabled:n,node:C,rect:f,data:k}}),()=>l({type:da.UnregisterDroppable,key:s,id:r})),[r]),w.useEffect(()=>{n!==d.current.disabled&&(l({type:da.SetDroppableDisabled,id:r,key:s,disabled:n}),d.current.disabled=n)},[r,s,n,l]),{active:o,rect:f,isOver:c?.id===r,node:C,over:c,setNodeRef:T}}function UM(t,e,n){const r=t.slice();return r.splice(n<0?r.length+n:n,0,r.splice(e,1)[0]),r}function uQe(t,e){return t.reduce((n,r,i)=>{const s=e.get(r);return s&&(n[i]=s),n},Array(t.length))}function GS(t){return t!==null&&t>=0}function dQe(t,e){if(t===e)return!0;if(t.length!==e.length)return!1;for(let n=0;n{let{rects:e,activeIndex:n,overIndex:r,index:i}=t;const s=UM(e,r,n),o=e[i],l=s[i];return!l||!o?null:{x:l.left-o.left,y:l.top-o.top,scaleX:l.width/o.width,scaleY:l.height/o.height}},qS={scaleX:1,scaleY:1},mQe=t=>{var e;let{activeIndex:n,activeNodeRect:r,index:i,rects:s,overIndex:o}=t;const l=(e=s[n])!=null?e:r;if(!l)return null;if(i===n){const u=s[o];return u?{x:0,y:nn&&i<=o?{x:0,y:-l.height-c,...qS}:i=o?{x:0,y:l.height+c,...qS}:{x:0,y:0,...qS}};function fQe(t,e,n){const r=t[e],i=t[e-1],s=t[e+1];return r?nr.map(T=>typeof T=="object"&&"id"in T?T.id:T),[r]),x=o!=null,y=o?p.indexOf(o.id):-1,b=u?p.indexOf(u.id):-1,v=w.useRef(p),S=!dQe(p,v.current),N=b!==-1&&y===-1||S,A=hQe(s);Bc(()=>{S&&x&&d(p)},[S,p,x,d]),w.useEffect(()=>{v.current=p},[p]);const C=w.useMemo(()=>({activeIndex:y,containerId:h,disabled:A,disableTransforms:N,items:p,overIndex:b,useDragOverlay:f,sortedRects:uQe(p,c),strategy:i}),[y,h,A.draggable,A.droppable,N,p,b,c,f,i]);return $r.createElement(Oae.Provider,{value:C},e)}const pQe=t=>{let{id:e,items:n,activeIndex:r,overIndex:i}=t;return UM(n,r,i).indexOf(e)},gQe=t=>{let{containerId:e,isSorting:n,wasDragging:r,index:i,items:s,newIndex:o,previousItems:l,previousContainerId:c,transition:u}=t;return!u||!r||l!==s&&i===o?!1:n?!0:o!==i&&e===c},bQe={duration:200,easing:"ease"},zae="transform",xQe=Ub.Transition.toString({property:zae,duration:0,easing:"linear"}),yQe={roleDescription:"sortable"};function vQe(t){let{disabled:e,index:n,node:r,rect:i}=t;const[s,o]=w.useState(null),l=w.useRef(n);return Bc(()=>{if(!e&&n!==l.current&&r.current){const c=i.current;if(c){const u=mx(r.current,{ignoreTransform:!0}),d={x:c.left-u.left,y:c.top-u.top,scaleX:c.width/u.width,scaleY:c.height/u.height};(d.x||d.y)&&o(d)}}n!==l.current&&(l.current=n)},[e,n,r,i]),w.useEffect(()=>{s&&o(null)},[s]),s}function Uae(t){let{animateLayoutChanges:e=gQe,attributes:n,disabled:r,data:i,getNewIndex:s=pQe,id:o,strategy:l,resizeObserverConfig:c,transition:u=bQe}=t;const{items:d,containerId:h,activeIndex:f,disabled:p,disableTransforms:x,sortedRects:y,overIndex:b,useDragOverlay:v,strategy:S}=w.useContext(Oae),N=wQe(r,p),A=d.indexOf(o),C=w.useMemo(()=>({sortable:{containerId:h,index:A,items:d},...i}),[h,i,A,d]),T=w.useMemo(()=>d.slice(d.indexOf(o)),[d,o]),{rect:k,node:j,isOver:E,setNodeRef:P}=cQe({id:o,data:C,disabled:N.droppable,resizeObserverConfig:{updateMeasurementsFor:T,...c}}),{active:U,activatorEvent:O,activeNodeRect:B,attributes:R,setNodeRef:G,listeners:q,isDragging:z,over:K,setActivatorNodeRef:Y,transform:oe}=aQe({id:o,data:C,attributes:{...yQe,...n},disabled:N.draggable}),$=$Xe(P,G),X=!!U,ee=X&&!x&&GS(f)&&GS(b),J=!v&&z,_e=J&&ee?oe:null,me=ee?_e??(l??S)({rects:y,activeNodeRect:B,activeIndex:f,overIndex:b,index:A}):null,je=GS(f)&&GS(b)?s({id:o,items:d,activeIndex:f,overIndex:b}):A,de=U?.id,ce=w.useRef({activeId:de,items:d,newIndex:je,containerId:h}),Se=d!==ce.current.items,ie=e({active:U,containerId:h,isDragging:z,isSorting:X,id:o,index:A,items:d,newIndex:ce.current.newIndex,previousItems:ce.current.items,previousContainerId:ce.current.containerId,transition:u,wasDragging:ce.current.activeId!=null}),Fe=vQe({disabled:!ie,index:A,node:j,rect:k});return w.useEffect(()=>{X&&ce.current.newIndex!==je&&(ce.current.newIndex=je),h!==ce.current.containerId&&(ce.current.containerId=h),d!==ce.current.items&&(ce.current.items=d)},[X,je,h,d]),w.useEffect(()=>{if(de===ce.current.activeId)return;if(de!=null&&ce.current.activeId==null){ce.current.activeId=de;return}const W=setTimeout(()=>{ce.current.activeId=de},50);return()=>clearTimeout(W)},[de]),{active:U,activeIndex:f,attributes:R,data:C,rect:k,index:A,newIndex:je,items:d,isOver:E,isSorting:X,isDragging:z,listeners:q,node:j,overIndex:b,over:K,setNodeRef:$,setActivatorNodeRef:Y,setDroppableNodeRef:P,setDraggableNodeRef:G,transform:Fe??me,transition:V()};function V(){if(Fe||Se&&ce.current.newIndex===A)return xQe;if(!(J&&!fI(O)||!u)&&(X||ie))return Ub.Transition.toString({...u,property:zae})}}function wQe(t,e){var n,r;return typeof t=="boolean"?{draggable:t,droppable:!1}:{draggable:(n=t?.draggable)!=null?n:e.draggable,droppable:(r=t?.droppable)!=null?r:e.droppable}}function qk(t){if(!t)return!1;const e=t.data.current;return!!(e&&"sortable"in e&&typeof e.sortable=="object"&&"containerId"in e.sortable&&"items"in e.sortable&&"index"in e.sortable)}const _Qe=[ir.Down,ir.Right,ir.Up,ir.Left],Bae=(t,e)=>{let{context:{active:n,collisionRect:r,droppableRects:i,droppableContainers:s,over:o,scrollableAncestors:l}}=e;if(_Qe.includes(t.code)){if(t.preventDefault(),!n||!r)return;const c=[];s.getEnabled().forEach(h=>{if(!h||h!=null&&h.disabled)return;const f=i.get(h.id);if(f)switch(t.code){case ir.Down:r.topf.top&&c.push(h);break;case ir.Left:r.left>f.left&&c.push(h);break;case ir.Right:r.left1&&(d=u[1].id),d!=null){const h=s.get(n.id),f=s.get(d),p=f?i.get(f.id):null,x=f?.node.current;if(x&&p&&h&&f){const b=FM(x).some((T,k)=>l[k]!==T),v=Hae(h,f),S=SQe(h,f),N=b||!v?{x:0,y:0}:{x:S?r.width-p.width:0,y:S?r.height-p.height:0},A={x:p.left,y:p.top};return N.x&&N.y?A:dv(A,N)}}}};function Hae(t,e){return!qk(t)||!qk(e)?!1:t.data.current.sortable.containerId===e.data.current.sortable.containerId}function SQe(t,e){return!qk(t)||!qk(e)||!Hae(t,e)?!1:t.data.current.sortable.index=1e3?`${(t/1e3).toFixed(1)}kg`:`${Math.round(t)}g`}function NQe(t,e="system",n){if(!t)return n?.("queue.time.asap")??"ASAP";const r=Zi(t);if(!r)return n?.("queue.time.asap")??"ASAP";const i=new Date,s=r.getTime()-i.getTime();return s<-6e4?n?.("queue.time.overdue")??"Overdue":s<0?n?.("queue.time.now")??"Now":s<6e4?n?.("queue.time.lessThanMinute")??"In less than a minute":s<36e5?n?.("queue.time.inMinutes",{count:Math.round(s/6e4)})??`In ${Math.round(s/6e4)} min`:s<864e5?n?.("queue.time.inHours",{count:Math.round(s/36e5)})??`In ${Math.round(s/36e5)} hours`:Lf(t,e)}function kQe({status:t,waitingReason:e,printerState:n,t:r}){if(t==="pending"&&e)return a.jsxs("span",{className:"inline-flex items-center gap-1.5 px-2.5 py-1 rounded-full text-xs font-medium border text-purple-400 bg-purple-400/10 border-purple-400/20",children:[a.jsx(Wn,{className:"w-3.5 h-3.5"}),r("queue.status.waiting")]});if(t==="printing"&&(n==="PAUSE"||n==="PAUSED"))return a.jsxs("span",{className:"inline-flex items-center gap-1.5 px-2.5 py-1 rounded-full text-xs font-medium border text-yellow-400 bg-yellow-400/10 border-yellow-400/20",children:[a.jsx(sC,{className:"w-3.5 h-3.5"}),r("queue.status.paused")]});const i={pending:{icon:Wn,color:"text-status-warning bg-status-warning/10 border-status-warning/20",label:r("queue.status.pending")},printing:{icon:so,color:"text-blue-400 bg-blue-400/10 border-blue-400/20",label:r("queue.status.printing")},completed:{icon:gr,color:"text-status-ok bg-status-ok/10 border-status-ok/20",label:r("queue.status.completed")},failed:{icon:ha,color:"text-status-error bg-status-error/10 border-status-error/20",label:r("queue.status.failed")},skipped:{icon:IF,color:"text-orange-400 bg-orange-400/10 border-orange-400/20",label:r("queue.status.skipped")},cancelled:{icon:Ft,color:"text-gray-400 bg-gray-400/10 border-gray-400/20",label:r("queue.status.cancelled")}},{icon:s,color:o,label:l}=i[t];return a.jsxs("span",{className:`inline-flex items-center gap-1.5 px-2.5 py-1 rounded-full text-xs font-medium border ${o}`,children:[a.jsx(s,{className:"w-3.5 h-3.5"}),l]})}function CQe({selectedCount:t,printers:e,onSave:n,onClose:r,isSaving:i,t:s}){const[o,l]=w.useState("unchanged"),[c,u]=w.useState("unchanged"),[d,h]=w.useState("unchanged"),[f,p]=w.useState("unchanged"),[x,y]=w.useState("unchanged"),[b,v]=w.useState("unchanged"),[S,N]=w.useState("unchanged"),[A,C]=w.useState("unchanged"),[T,k]=w.useState("unchanged"),[j,E]=w.useState("unchanged"),P=()=>{const O={};o!=="unchanged"&&(O.printer_id=o),c!=="unchanged"&&(O.manual_start=c),d!=="unchanged"&&(O.auto_off_after=d),f!=="unchanged"&&(O.require_previous_success=f),x!=="unchanged"&&(O.bed_levelling=x),b!=="unchanged"&&(O.flow_cali=b),S!=="unchanged"&&(O.vibration_cali=S),A!=="unchanged"&&(O.layer_inspect=A),T!=="unchanged"&&(O.timelapse=T),j!=="unchanged"&&(O.use_ams=j),n(O)},U=o!=="unchanged"||c!=="unchanged"||d!=="unchanged"||f!=="unchanged"||x!=="unchanged"||b!=="unchanged"||S!=="unchanged"||A!=="unchanged"||T!=="unchanged"||j!=="unchanged";return a.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center p-4 bg-black/50 backdrop-blur-sm",children:a.jsxs("div",{className:"bg-bambu-dark-secondary rounded-xl border border-bambu-dark-tertiary w-full max-w-lg max-h-[90vh] overflow-y-auto",children:[a.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-bambu-dark-tertiary",children:[a.jsx("h2",{className:"text-lg font-semibold text-white",children:s("queue.bulkEdit.title",{count:t})}),a.jsx("button",{onClick:r,className:"p-1 hover:bg-bambu-dark rounded",children:a.jsx(Ft,{className:"w-5 h-5 text-bambu-gray"})})]}),a.jsxs("div",{className:"p-4 space-y-4",children:[a.jsx("p",{className:"text-sm text-bambu-gray",children:s("queue.bulkEdit.description")}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm font-medium text-white mb-2",children:s("queue.bulkEdit.printer")}),a.jsxs("select",{value:o===null?"null":o==="unchanged"?"unchanged":String(o),onChange:O=>{const B=O.target.value;l(B==="unchanged"?"unchanged":B==="null"?null:Number(B))},className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",children:[a.jsx("option",{value:"unchanged",children:s("queue.bulkEdit.noChange")}),a.jsx("option",{value:"null",children:s("queue.filter.unassigned")}),e.map(O=>a.jsx("option",{value:O.id,children:O.name},O.id))]})]}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm font-medium text-white mb-2",children:s("queue.bulkEdit.queueOptions")}),a.jsxs("div",{className:"space-y-2",children:[a.jsx(Mu,{label:s("queue.bulkEdit.staged"),value:c,onChange:u,t:s}),a.jsx(Mu,{label:s("queue.bulkEdit.autoPowerOff"),value:d,onChange:h,t:s}),a.jsx(Mu,{label:s("queue.bulkEdit.requirePrevious"),value:f,onChange:p,t:s})]})]}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm font-medium text-white mb-2",children:s("queue.bulkEdit.printOptions")}),a.jsxs("div",{className:"space-y-2",children:[a.jsx(Mu,{label:s("queue.bulkEdit.bedLevelling"),value:x,onChange:y,t:s}),a.jsx(Mu,{label:s("queue.bulkEdit.flowCalibration"),value:b,onChange:v,t:s}),a.jsx(Mu,{label:s("queue.bulkEdit.vibrationCalibration"),value:S,onChange:N,t:s}),a.jsx(Mu,{label:s("queue.bulkEdit.layerInspection"),value:A,onChange:C,t:s}),a.jsx(Mu,{label:s("queue.bulkEdit.timelapse"),value:T,onChange:k,t:s}),a.jsx(Mu,{label:s("queue.bulkEdit.useAms"),value:j,onChange:E,t:s})]})]})]}),a.jsxs("div",{className:"flex justify-end gap-3 p-4 border-t border-bambu-dark-tertiary",children:[a.jsx(Ce,{variant:"secondary",onClick:r,children:s("common.cancel")}),a.jsx(Ce,{onClick:P,disabled:!U||i,children:s(i?"common.saving":"queue.bulkEdit.applyChanges")})]})]})})}function Mu({label:t,value:e,onChange:n,t:r}){return a.jsxs("div",{className:"flex items-center justify-between py-1",children:[a.jsx("span",{className:"text-sm text-bambu-gray",children:t}),a.jsxs("div",{className:"flex items-center gap-1 bg-bambu-dark rounded-lg p-0.5",children:[a.jsx("button",{onClick:()=>n("unchanged"),className:`px-2 py-1 text-xs rounded ${e==="unchanged"?"bg-bambu-dark-tertiary text-white":"text-bambu-gray hover:text-white"}`,children:"—"}),a.jsx("button",{onClick:()=>n(!1),className:`px-2 py-1 text-xs rounded ${e===!1?"bg-red-500/20 text-red-400":"text-bambu-gray hover:text-white"}`,children:r("common.off")}),a.jsx("button",{onClick:()=>n(!0),className:`px-2 py-1 text-xs rounded ${e===!0?"bg-bambu-green/20 text-bambu-green":"text-bambu-gray hover:text-white"}`,children:r("common.on")})]})]})}function Uj({item:t,position:e,onEdit:n,onCancel:r,onRemove:i,onStop:s,onRequeue:o,onStart:l,timeFormat:c="system",isSelected:u=!1,onToggleSelect:d,hasPermission:h,canModify:f,printerState:p,t:x}){const{data:y}=Ze({queryKey:["printerStatus",t.printer_id],queryFn:()=>re.getPrinterStatus(t.printer_id),refetchInterval:3e4,enabled:t.printer_id!=null&&p==="printing"}),b=!!t.library_file_id&&!t.archive_id,{data:v}=Ze({queryKey:["archive-plates",t.archive_id],queryFn:()=>re.getArchivePlates(t.archive_id),enabled:!!t.archive_id&&!b}),{data:S}=Ze({queryKey:["library-file-plates",t.library_file_id],queryFn:()=>re.getLibraryFilePlates(t.library_file_id),enabled:b&&!!t.library_file_id}),N=b?S:v,A=N?.plates??[],C=h("queue:reorder"),{attributes:T,listeners:k,setNodeRef:j,transform:E,transition:P,isDragging:U}=Uae({id:t.id,disabled:t.status!=="pending"||!C}),O={transform:Ub.Transform.toString(E),transition:P},B=t.status==="printing",R=t.status==="pending",G=["completed","failed","skipped","cancelled"].includes(t.status);return a.jsx("div",{ref:j,style:O,className:` - group relative bg-bambu-dark-secondary rounded-xl border border-bambu-dark-tertiary - transition-all duration-200 hover:border-bambu-dark-tertiary/80 + `},tYe={onDragStart(t){let{active:e}=t;return"Picked up draggable item "+e.id+"."},onDragOver(t){let{active:e,over:n}=t;return n?"Draggable item "+e.id+" was moved over droppable area "+n.id+".":"Draggable item "+e.id+" is no longer over a droppable area."},onDragEnd(t){let{active:e,over:n}=t;return n?"Draggable item "+e.id+" was dropped over droppable area "+n.id:"Draggable item "+e.id+" was dropped."},onDragCancel(t){let{active:e}=t;return"Dragging was cancelled. Draggable item "+e.id+" was dropped."}};function nYe(t){let{announcements:e=tYe,container:n,hiddenTextDescribedById:r,screenReaderInstructions:i=eYe}=t;const{announce:s,announcement:o}=QXe(),l=Jv("DndLiveRegion"),[c,u]=w.useState(!1);if(w.useEffect(()=>{u(!0)},[]),ZXe(w.useMemo(()=>({onDragStart(h){let{active:f}=h;s(e.onDragStart({active:f}))},onDragMove(h){let{active:f,over:p}=h;e.onDragMove&&s(e.onDragMove({active:f,over:p}))},onDragOver(h){let{active:f,over:p}=h;s(e.onDragOver({active:f,over:p}))},onDragEnd(h){let{active:f,over:p}=h;s(e.onDragEnd({active:f,over:p}))},onDragCancel(h){let{active:f,over:p}=h;s(e.onDragCancel({active:f,over:p}))}}),[s,e])),!c)return null;const d=$r.createElement($r.Fragment,null,$r.createElement(XXe,{id:r,value:i.draggable}),$r.createElement(YXe,{id:l,announcement:o}));return n?Ou.createPortal(d,n):d}var da;(function(t){t.DragStart="dragStart",t.DragMove="dragMove",t.DragEnd="dragEnd",t.DragCancel="dragCancel",t.DragOver="dragOver",t.RegisterDroppable="registerDroppable",t.SetDroppableDisabled="setDroppableDisabled",t.UnregisterDroppable="unregisterDroppable"})(da||(da={}));function $k(){}function Vk(t,e){return w.useMemo(()=>({sensor:t,options:e??{}}),[t,e])}function xae(){for(var t=arguments.length,e=new Array(t),n=0;n[...e].filter(r=>r!=null),[...e])}const Jl=Object.freeze({x:0,y:0});function yae(t,e){return Math.sqrt(Math.pow(t.x-e.x,2)+Math.pow(t.y-e.y,2))}function vae(t,e){let{data:{value:n}}=t,{data:{value:r}}=e;return n-r}function rYe(t,e){let{data:{value:n}}=t,{data:{value:r}}=e;return r-n}function WW(t){let{left:e,top:n,height:r,width:i}=t;return[{x:e,y:n},{x:e+i,y:n},{x:e,y:n+r},{x:e+i,y:n+r}]}function wae(t,e){if(!t||t.length===0)return null;const[n]=t;return n[e]}function KW(t,e,n){return e===void 0&&(e=t.left),n===void 0&&(n=t.top),{x:e+t.width*.5,y:n+t.height*.5}}const _ae=t=>{let{collisionRect:e,droppableRects:n,droppableContainers:r}=t;const i=KW(e,e.left,e.top),s=[];for(const o of r){const{id:l}=o,c=n.get(l);if(c){const u=yae(KW(c),i);s.push({id:l,data:{droppableContainer:o,value:u}})}}return s.sort(vae)},iYe=t=>{let{collisionRect:e,droppableRects:n,droppableContainers:r}=t;const i=WW(e),s=[];for(const o of r){const{id:l}=o,c=n.get(l);if(c){const u=WW(c),d=i.reduce((f,p,x)=>f+yae(u[x],p),0),h=Number((d/4).toFixed(4));s.push({id:l,data:{droppableContainer:o,value:h}})}}return s.sort(vae)};function aYe(t,e){const n=Math.max(e.top,t.top),r=Math.max(e.left,t.left),i=Math.min(e.left+e.width,t.left+t.width),s=Math.min(e.top+e.height,t.top+t.height),o=i-r,l=s-n;if(r{let{collisionRect:e,droppableRects:n,droppableContainers:r}=t;const i=[];for(const s of r){const{id:o}=s,l=n.get(o);if(l){const c=aYe(l,e);c>0&&i.push({id:o,data:{droppableContainer:s,value:c}})}}return i.sort(rYe)};function oYe(t,e,n){return{...t,scaleX:e&&n?e.width/n.width:1,scaleY:e&&n?e.height/n.height:1}}function Sae(t,e){return t&&e?{x:t.left-e.left,y:t.top-e.top}:Jl}function lYe(t){return function(n){for(var r=arguments.length,i=new Array(r>1?r-1:0),s=1;s({...o,top:o.top+t*l.y,bottom:o.bottom+t*l.y,left:o.left+t*l.x,right:o.right+t*l.x}),{...n})}}const cYe=lYe(1);function uYe(t){if(t.startsWith("matrix3d(")){const e=t.slice(9,-1).split(/, /);return{x:+e[12],y:+e[13],scaleX:+e[0],scaleY:+e[5]}}else if(t.startsWith("matrix(")){const e=t.slice(7,-1).split(/, /);return{x:+e[4],y:+e[5],scaleX:+e[0],scaleY:+e[3]}}return null}function dYe(t,e,n){const r=uYe(e);if(!r)return t;const{scaleX:i,scaleY:s,x:o,y:l}=r,c=t.left-o-(1-i)*parseFloat(n),u=t.top-l-(1-s)*parseFloat(n.slice(n.indexOf(" ")+1)),d=i?t.width/i:t.width,h=s?t.height/s:t.height;return{width:d,height:h,top:u,right:c+d,bottom:u+h,left:c}}const hYe={ignoreTransform:!1};function mx(t,e){e===void 0&&(e=hYe);let n=t.getBoundingClientRect();if(e.ignoreTransform){const{transform:u,transformOrigin:d}=uo(t).getComputedStyle(t);u&&(n=dYe(n,u,d))}const{top:r,left:i,width:s,height:o,bottom:l,right:c}=n;return{top:r,left:i,width:s,height:o,bottom:l,right:c}}function XW(t){return mx(t,{ignoreTransform:!0})}function mYe(t){const e=t.innerWidth,n=t.innerHeight;return{top:0,left:0,right:e,bottom:n,width:e,height:n}}function fYe(t,e){return e===void 0&&(e=uo(t).getComputedStyle(t)),e.position==="fixed"}function pYe(t,e){e===void 0&&(e=uo(t).getComputedStyle(t));const n=/(auto|scroll|overlay)/;return["overflow","overflowX","overflowY"].some(i=>{const s=e[i];return typeof s=="string"?n.test(s):!1})}function FM(t,e){const n=[];function r(i){if(e!=null&&n.length>=e||!i)return n;if(hI(i)&&i.scrollingElement!=null&&!n.includes(i.scrollingElement))return n.push(i.scrollingElement),n;if(!Qv(i)||pae(i)||n.includes(i))return n;const s=uo(t).getComputedStyle(i);return i!==t&&pYe(i,s)&&n.push(i),fYe(i,s)?n:r(i.parentNode)}return t?r(t):n}function Nae(t){const[e]=FM(t,1);return e??null}function Oj(t){return!RM||!t?null:dx(t)?t:dI(t)?hI(t)||t===hx(t).scrollingElement?window:Qv(t)?t:null:null}function kae(t){return dx(t)?t.scrollX:t.scrollLeft}function Cae(t){return dx(t)?t.scrollY:t.scrollTop}function dF(t){return{x:kae(t),y:Cae(t)}}var Ra;(function(t){t[t.Forward=1]="Forward",t[t.Backward=-1]="Backward"})(Ra||(Ra={}));function Mae(t){return!RM||!t?!1:t===document.scrollingElement}function Aae(t){const e={x:0,y:0},n=Mae(t)?{height:window.innerHeight,width:window.innerWidth}:{height:t.clientHeight,width:t.clientWidth},r={x:t.scrollWidth-n.width,y:t.scrollHeight-n.height},i=t.scrollTop<=e.y,s=t.scrollLeft<=e.x,o=t.scrollTop>=r.y,l=t.scrollLeft>=r.x;return{isTop:i,isLeft:s,isBottom:o,isRight:l,maxScroll:r,minScroll:e}}const gYe={x:.2,y:.2};function bYe(t,e,n,r,i){let{top:s,left:o,right:l,bottom:c}=n;r===void 0&&(r=10),i===void 0&&(i=gYe);const{isTop:u,isBottom:d,isLeft:h,isRight:f}=Aae(t),p={x:0,y:0},x={x:0,y:0},y={height:e.height*i.y,width:e.width*i.x};return!u&&s<=e.top+y.height?(p.y=Ra.Backward,x.y=r*Math.abs((e.top+y.height-s)/y.height)):!d&&c>=e.bottom-y.height&&(p.y=Ra.Forward,x.y=r*Math.abs((e.bottom-y.height-c)/y.height)),!f&&l>=e.right-y.width?(p.x=Ra.Forward,x.x=r*Math.abs((e.right-y.width-l)/y.width)):!h&&o<=e.left+y.width&&(p.x=Ra.Backward,x.x=r*Math.abs((e.left+y.width-o)/y.width)),{direction:p,speed:x}}function xYe(t){if(t===document.scrollingElement){const{innerWidth:s,innerHeight:o}=window;return{top:0,left:0,right:s,bottom:o,width:s,height:o}}const{top:e,left:n,right:r,bottom:i}=t.getBoundingClientRect();return{top:e,left:n,right:r,bottom:i,width:t.clientWidth,height:t.clientHeight}}function Tae(t){return t.reduce((e,n)=>ub(e,dF(n)),Jl)}function yYe(t){return t.reduce((e,n)=>e+kae(n),0)}function vYe(t){return t.reduce((e,n)=>e+Cae(n),0)}function wYe(t,e){if(e===void 0&&(e=mx),!t)return;const{top:n,left:r,bottom:i,right:s}=e(t);Nae(t)&&(i<=0||s<=0||n>=window.innerHeight||r>=window.innerWidth)&&t.scrollIntoView({block:"center",inline:"center"})}const _Ye=[["x",["left","right"],yYe],["y",["top","bottom"],vYe]];class pI{constructor(e,n){this.rect=void 0,this.width=void 0,this.height=void 0,this.top=void 0,this.bottom=void 0,this.right=void 0,this.left=void 0;const r=FM(n),i=Tae(r);this.rect={...e},this.width=e.width,this.height=e.height;for(const[s,o,l]of _Ye)for(const c of o)Object.defineProperty(this,c,{get:()=>{const u=l(r),d=i[s]-u;return this.rect[c]+d},enumerable:!0});Object.defineProperty(this,"rect",{enumerable:!1})}}class p0{constructor(e){this.target=void 0,this.listeners=[],this.removeAll=()=>{this.listeners.forEach(n=>{var r;return(r=this.target)==null?void 0:r.removeEventListener(...n)})},this.target=e}add(e,n,r){var i;(i=this.target)==null||i.addEventListener(e,n,r),this.listeners.push([e,n,r])}}function SYe(t){const{EventTarget:e}=uo(t);return t instanceof e?t:hx(t)}function Ij(t,e){const n=Math.abs(t.x),r=Math.abs(t.y);return typeof e=="number"?Math.sqrt(n**2+r**2)>e:"x"in e&&"y"in e?n>e.x&&r>e.y:"x"in e?n>e.x:"y"in e?r>e.y:!1}var il;(function(t){t.Click="click",t.DragStart="dragstart",t.Keydown="keydown",t.ContextMenu="contextmenu",t.Resize="resize",t.SelectionChange="selectionchange",t.VisibilityChange="visibilitychange"})(il||(il={}));function YW(t){t.preventDefault()}function NYe(t){t.stopPropagation()}var ir;(function(t){t.Space="Space",t.Down="ArrowDown",t.Right="ArrowRight",t.Left="ArrowLeft",t.Up="ArrowUp",t.Esc="Escape",t.Enter="Enter",t.Tab="Tab"})(ir||(ir={}));const Eae={start:[ir.Space,ir.Enter],cancel:[ir.Esc],end:[ir.Space,ir.Enter,ir.Tab]},kYe=(t,e)=>{let{currentCoordinates:n}=e;switch(t.code){case ir.Right:return{...n,x:n.x+25};case ir.Left:return{...n,x:n.x-25};case ir.Down:return{...n,y:n.y+25};case ir.Up:return{...n,y:n.y-25}}};class LM{constructor(e){this.props=void 0,this.autoScrollEnabled=!1,this.referenceCoordinates=void 0,this.listeners=void 0,this.windowListeners=void 0,this.props=e;const{event:{target:n}}=e;this.props=e,this.listeners=new p0(hx(n)),this.windowListeners=new p0(uo(n)),this.handleKeyDown=this.handleKeyDown.bind(this),this.handleCancel=this.handleCancel.bind(this),this.attach()}attach(){this.handleStart(),this.windowListeners.add(il.Resize,this.handleCancel),this.windowListeners.add(il.VisibilityChange,this.handleCancel),setTimeout(()=>this.listeners.add(il.Keydown,this.handleKeyDown))}handleStart(){const{activeNode:e,onStart:n}=this.props,r=e.node.current;r&&wYe(r),n(Jl)}handleKeyDown(e){if(fI(e)){const{active:n,context:r,options:i}=this.props,{keyboardCodes:s=Eae,coordinateGetter:o=kYe,scrollBehavior:l="smooth"}=i,{code:c}=e;if(s.end.includes(c)){this.handleEnd(e);return}if(s.cancel.includes(c)){this.handleCancel(e);return}const{collisionRect:u}=r.current,d=u?{x:u.left,y:u.top}:Jl;this.referenceCoordinates||(this.referenceCoordinates=d);const h=o(e,{active:n,context:r.current,currentCoordinates:d});if(h){const f=dv(h,d),p={x:0,y:0},{scrollableAncestors:x}=r.current;for(const y of x){const b=e.code,{isTop:v,isRight:S,isLeft:N,isBottom:A,maxScroll:C,minScroll:T}=Aae(y),k=xYe(y),j={x:Math.min(b===ir.Right?k.right-k.width/2:k.right,Math.max(b===ir.Right?k.left:k.left+k.width/2,h.x)),y:Math.min(b===ir.Down?k.bottom-k.height/2:k.bottom,Math.max(b===ir.Down?k.top:k.top+k.height/2,h.y))},E=b===ir.Right&&!S||b===ir.Left&&!N,P=b===ir.Down&&!A||b===ir.Up&&!v;if(E&&j.x!==h.x){const U=y.scrollLeft+f.x,O=b===ir.Right&&U<=C.x||b===ir.Left&&U>=T.x;if(O&&!f.y){y.scrollTo({left:U,behavior:l});return}O?p.x=y.scrollLeft-U:p.x=b===ir.Right?y.scrollLeft-C.x:y.scrollLeft-T.x,p.x&&y.scrollBy({left:-p.x,behavior:l});break}else if(P&&j.y!==h.y){const U=y.scrollTop+f.y,O=b===ir.Down&&U<=C.y||b===ir.Up&&U>=T.y;if(O&&!f.x){y.scrollTo({top:U,behavior:l});return}O?p.y=y.scrollTop-U:p.y=b===ir.Down?y.scrollTop-C.y:y.scrollTop-T.y,p.y&&y.scrollBy({top:-p.y,behavior:l});break}}this.handleMove(e,ub(dv(h,this.referenceCoordinates),p))}}}handleMove(e,n){const{onMove:r}=this.props;e.preventDefault(),r(n)}handleEnd(e){const{onEnd:n}=this.props;e.preventDefault(),this.detach(),n()}handleCancel(e){const{onCancel:n}=this.props;e.preventDefault(),this.detach(),n()}detach(){this.listeners.removeAll(),this.windowListeners.removeAll()}}LM.activators=[{eventName:"onKeyDown",handler:(t,e,n)=>{let{keyboardCodes:r=Eae,onActivation:i}=e,{active:s}=n;const{code:o}=t.nativeEvent;if(r.start.includes(o)){const l=s.activatorNode.current;return l&&t.target!==l?!1:(t.preventDefault(),i?.({event:t.nativeEvent}),!0)}return!1}}];function QW(t){return!!(t&&"distance"in t)}function ZW(t){return!!(t&&"delay"in t)}class gI{constructor(e,n,r){var i;r===void 0&&(r=SYe(e.event.target)),this.props=void 0,this.events=void 0,this.autoScrollEnabled=!0,this.document=void 0,this.activated=!1,this.initialCoordinates=void 0,this.timeoutId=null,this.listeners=void 0,this.documentListeners=void 0,this.windowListeners=void 0,this.props=e,this.events=n;const{event:s}=e,{target:o}=s;this.props=e,this.events=n,this.document=hx(o),this.documentListeners=new p0(this.document),this.listeners=new p0(r),this.windowListeners=new p0(uo(o)),this.initialCoordinates=(i=uF(s))!=null?i:Jl,this.handleStart=this.handleStart.bind(this),this.handleMove=this.handleMove.bind(this),this.handleEnd=this.handleEnd.bind(this),this.handleCancel=this.handleCancel.bind(this),this.handleKeydown=this.handleKeydown.bind(this),this.removeTextSelection=this.removeTextSelection.bind(this),this.attach()}attach(){const{events:e,props:{options:{activationConstraint:n,bypassActivationConstraint:r}}}=this;if(this.listeners.add(e.move.name,this.handleMove,{passive:!1}),this.listeners.add(e.end.name,this.handleEnd),e.cancel&&this.listeners.add(e.cancel.name,this.handleCancel),this.windowListeners.add(il.Resize,this.handleCancel),this.windowListeners.add(il.DragStart,YW),this.windowListeners.add(il.VisibilityChange,this.handleCancel),this.windowListeners.add(il.ContextMenu,YW),this.documentListeners.add(il.Keydown,this.handleKeydown),n){if(r!=null&&r({event:this.props.event,activeNode:this.props.activeNode,options:this.props.options}))return this.handleStart();if(ZW(n)){this.timeoutId=setTimeout(this.handleStart,n.delay),this.handlePending(n);return}if(QW(n)){this.handlePending(n);return}}this.handleStart()}detach(){this.listeners.removeAll(),this.windowListeners.removeAll(),setTimeout(this.documentListeners.removeAll,50),this.timeoutId!==null&&(clearTimeout(this.timeoutId),this.timeoutId=null)}handlePending(e,n){const{active:r,onPending:i}=this.props;i(r,e,this.initialCoordinates,n)}handleStart(){const{initialCoordinates:e}=this,{onStart:n}=this.props;e&&(this.activated=!0,this.documentListeners.add(il.Click,NYe,{capture:!0}),this.removeTextSelection(),this.documentListeners.add(il.SelectionChange,this.removeTextSelection),n(e))}handleMove(e){var n;const{activated:r,initialCoordinates:i,props:s}=this,{onMove:o,options:{activationConstraint:l}}=s;if(!i)return;const c=(n=uF(e))!=null?n:Jl,u=dv(i,c);if(!r&&l){if(QW(l)){if(l.tolerance!=null&&Ij(u,l.tolerance))return this.handleCancel();if(Ij(u,l.distance))return this.handleStart()}if(ZW(l)&&Ij(u,l.tolerance))return this.handleCancel();this.handlePending(l,u);return}e.cancelable&&e.preventDefault(),o(c)}handleEnd(){const{onAbort:e,onEnd:n}=this.props;this.detach(),this.activated||e(this.props.active),n()}handleCancel(){const{onAbort:e,onCancel:n}=this.props;this.detach(),this.activated||e(this.props.active),n()}handleKeydown(e){e.code===ir.Esc&&this.handleCancel()}removeTextSelection(){var e;(e=this.document.getSelection())==null||e.removeAllRanges()}}const CYe={cancel:{name:"pointercancel"},move:{name:"pointermove"},end:{name:"pointerup"}};class OM extends gI{constructor(e){const{event:n}=e,r=hx(n.target);super(e,CYe,r)}}OM.activators=[{eventName:"onPointerDown",handler:(t,e)=>{let{nativeEvent:n}=t,{onActivation:r}=e;return!n.isPrimary||n.button!==0?!1:(r?.({event:n}),!0)}}];const MYe={move:{name:"mousemove"},end:{name:"mouseup"}};var hF;(function(t){t[t.RightClick=2]="RightClick"})(hF||(hF={}));class AYe extends gI{constructor(e){super(e,MYe,hx(e.event.target))}}AYe.activators=[{eventName:"onMouseDown",handler:(t,e)=>{let{nativeEvent:n}=t,{onActivation:r}=e;return n.button===hF.RightClick?!1:(r?.({event:n}),!0)}}];const zj={cancel:{name:"touchcancel"},move:{name:"touchmove"},end:{name:"touchend"}};class TYe extends gI{constructor(e){super(e,zj)}static setup(){return window.addEventListener(zj.move.name,e,{capture:!1,passive:!1}),function(){window.removeEventListener(zj.move.name,e)};function e(){}}}TYe.activators=[{eventName:"onTouchStart",handler:(t,e)=>{let{nativeEvent:n}=t,{onActivation:r}=e;const{touches:i}=n;return i.length>1?!1:(r?.({event:n}),!0)}}];var g0;(function(t){t[t.Pointer=0]="Pointer",t[t.DraggableRect=1]="DraggableRect"})(g0||(g0={}));var Gk;(function(t){t[t.TreeOrder=0]="TreeOrder",t[t.ReversedTreeOrder=1]="ReversedTreeOrder"})(Gk||(Gk={}));function EYe(t){let{acceleration:e,activator:n=g0.Pointer,canScroll:r,draggingRect:i,enabled:s,interval:o=5,order:l=Gk.TreeOrder,pointerCoordinates:c,scrollableAncestors:u,scrollableAncestorRects:d,delta:h,threshold:f}=t;const p=jYe({delta:h,disabled:!s}),[x,y]=VXe(),b=w.useRef({x:0,y:0}),v=w.useRef({x:0,y:0}),S=w.useMemo(()=>{switch(n){case g0.Pointer:return c?{top:c.y,bottom:c.y,left:c.x,right:c.x}:null;case g0.DraggableRect:return i}},[n,i,c]),N=w.useRef(null),A=w.useCallback(()=>{const T=N.current;if(!T)return;const k=b.current.x*v.current.x,j=b.current.y*v.current.y;T.scrollBy(k,j)},[]),C=w.useMemo(()=>l===Gk.TreeOrder?[...u].reverse():u,[l,u]);w.useEffect(()=>{if(!s||!u.length||!S){y();return}for(const T of C){if(r?.(T)===!1)continue;const k=u.indexOf(T),j=d[k];if(!j)continue;const{direction:E,speed:P}=bYe(T,j,S,e,f);for(const U of["x","y"])p[U][E[U]]||(P[U]=0,E[U]=0);if(P.x>0||P.y>0){y(),N.current=T,x(A,o),b.current=P,v.current=E;return}}b.current={x:0,y:0},v.current={x:0,y:0},y()},[e,A,r,y,s,o,JSON.stringify(S),JSON.stringify(p),x,u,C,d,JSON.stringify(f)])}const PYe={x:{[Ra.Backward]:!1,[Ra.Forward]:!1},y:{[Ra.Backward]:!1,[Ra.Forward]:!1}};function jYe(t){let{delta:e,disabled:n}=t;const r=cF(e);return Zv(i=>{if(n||!r||!i)return PYe;const s={x:Math.sign(e.x-r.x),y:Math.sign(e.y-r.y)};return{x:{[Ra.Backward]:i.x[Ra.Backward]||s.x===-1,[Ra.Forward]:i.x[Ra.Forward]||s.x===1},y:{[Ra.Backward]:i.y[Ra.Backward]||s.y===-1,[Ra.Forward]:i.y[Ra.Forward]||s.y===1}}},[n,e,r])}function DYe(t,e){const n=e!=null?t.get(e):void 0,r=n?n.node.current:null;return Zv(i=>{var s;return e==null?null:(s=r??i)!=null?s:null},[r,e])}function RYe(t,e){return w.useMemo(()=>t.reduce((n,r)=>{const{sensor:i}=r,s=i.activators.map(o=>({eventName:o.eventName,handler:e(o.handler,r)}));return[...n,...s]},[]),[t,e])}var hv;(function(t){t[t.Always=0]="Always",t[t.BeforeDragging=1]="BeforeDragging",t[t.WhileDragging=2]="WhileDragging"})(hv||(hv={}));var mF;(function(t){t.Optimized="optimized"})(mF||(mF={}));const JW=new Map;function FYe(t,e){let{dragging:n,dependencies:r,config:i}=e;const[s,o]=w.useState(null),{frequency:l,measure:c,strategy:u}=i,d=w.useRef(t),h=b(),f=uv(h),p=w.useCallback(function(v){v===void 0&&(v=[]),!f.current&&o(S=>S===null?v:S.concat(v.filter(N=>!S.includes(N))))},[f]),x=w.useRef(null),y=Zv(v=>{if(h&&!n)return JW;if(!v||v===JW||d.current!==t||s!=null){const S=new Map;for(let N of t){if(!N)continue;if(s&&s.length>0&&!s.includes(N.id)&&N.rect.current){S.set(N.id,N.rect.current);continue}const A=N.node.current,C=A?new pI(c(A),A):null;N.rect.current=C,C&&S.set(N.id,C)}return S}return v},[t,s,n,h,c]);return w.useEffect(()=>{d.current=t},[t]),w.useEffect(()=>{h||p()},[n,h]),w.useEffect(()=>{s&&s.length>0&&o(null)},[JSON.stringify(s)]),w.useEffect(()=>{h||typeof l!="number"||x.current!==null||(x.current=setTimeout(()=>{p(),x.current=null},l))},[l,h,p,...r]),{droppableRects:y,measureDroppableContainers:p,measuringScheduled:s!=null};function b(){switch(u){case hv.Always:return!1;case hv.BeforeDragging:return n;default:return!n}}}function Pae(t,e){return Zv(n=>t?n||(typeof e=="function"?e(t):t):null,[e,t])}function LYe(t,e){return Pae(t,e)}function OYe(t){let{callback:e,disabled:n}=t;const r=mI(e),i=w.useMemo(()=>{if(n||typeof window>"u"||typeof window.MutationObserver>"u")return;const{MutationObserver:s}=window;return new s(r)},[r,n]);return w.useEffect(()=>()=>i?.disconnect(),[i]),i}function IM(t){let{callback:e,disabled:n}=t;const r=mI(e),i=w.useMemo(()=>{if(n||typeof window>"u"||typeof window.ResizeObserver>"u")return;const{ResizeObserver:s}=window;return new s(r)},[n]);return w.useEffect(()=>()=>i?.disconnect(),[i]),i}function IYe(t){return new pI(mx(t),t)}function eK(t,e,n){e===void 0&&(e=IYe);const[r,i]=w.useState(null);function s(){i(c=>{if(!t)return null;if(t.isConnected===!1){var u;return(u=c??n)!=null?u:null}const d=e(t);return JSON.stringify(c)===JSON.stringify(d)?c:d})}const o=OYe({callback(c){if(t)for(const u of c){const{type:d,target:h}=u;if(d==="childList"&&h instanceof HTMLElement&&h.contains(t)){s();break}}}}),l=IM({callback:s});return Bc(()=>{s(),t?(l?.observe(t),o?.observe(document.body,{childList:!0,subtree:!0})):(l?.disconnect(),o?.disconnect())},[t]),r}function zYe(t){const e=Pae(t);return Sae(t,e)}const tK=[];function UYe(t){const e=w.useRef(t),n=Zv(r=>t?r&&r!==tK&&t&&e.current&&t.parentNode===e.current.parentNode?r:FM(t):tK,[t]);return w.useEffect(()=>{e.current=t},[t]),n}function BYe(t){const[e,n]=w.useState(null),r=w.useRef(t),i=w.useCallback(s=>{const o=Oj(s.target);o&&n(l=>l?(l.set(o,dF(o)),new Map(l)):null)},[]);return w.useEffect(()=>{const s=r.current;if(t!==s){o(s);const l=t.map(c=>{const u=Oj(c);return u?(u.addEventListener("scroll",i,{passive:!0}),[u,dF(u)]):null}).filter(c=>c!=null);n(l.length?new Map(l):null),r.current=t}return()=>{o(t),o(s)};function o(l){l.forEach(c=>{const u=Oj(c);u?.removeEventListener("scroll",i)})}},[i,t]),w.useMemo(()=>t.length?e?Array.from(e.values()).reduce((s,o)=>ub(s,o),Jl):Tae(t):Jl,[t,e])}function nK(t,e){e===void 0&&(e=[]);const n=w.useRef(null);return w.useEffect(()=>{n.current=null},e),w.useEffect(()=>{const r=t!==Jl;r&&!n.current&&(n.current=t),!r&&n.current&&(n.current=null)},[t]),n.current?dv(t,n.current):Jl}function HYe(t){w.useEffect(()=>{if(!RM)return;const e=t.map(n=>{let{sensor:r}=n;return r.setup==null?void 0:r.setup()});return()=>{for(const n of e)n?.()}},t.map(e=>{let{sensor:n}=e;return n}))}function $Ye(t,e){return w.useMemo(()=>t.reduce((n,r)=>{let{eventName:i,handler:s}=r;return n[i]=o=>{s(o,e)},n},{}),[t,e])}function jae(t){return w.useMemo(()=>t?mYe(t):null,[t])}const rK=[];function VYe(t,e){e===void 0&&(e=mx);const[n]=t,r=jae(n?uo(n):null),[i,s]=w.useState(rK);function o(){s(()=>t.length?t.map(c=>Mae(c)?r:new pI(e(c),c)):rK)}const l=IM({callback:o});return Bc(()=>{l?.disconnect(),o(),t.forEach(c=>l?.observe(c))},[t]),i}function GYe(t){if(!t)return null;if(t.children.length>1)return t;const e=t.children[0];return Qv(e)?e:t}function qYe(t){let{measure:e}=t;const[n,r]=w.useState(null),i=w.useCallback(u=>{for(const{target:d}of u)if(Qv(d)){r(h=>{const f=e(d);return h?{...h,width:f.width,height:f.height}:f});break}},[e]),s=IM({callback:i}),o=w.useCallback(u=>{const d=GYe(u);s?.disconnect(),d&&s?.observe(d),r(d?e(d):null)},[e,s]),[l,c]=Hk(o);return w.useMemo(()=>({nodeRef:l,rect:n,setRef:c}),[n,l,c])}const WYe=[{sensor:OM,options:{}},{sensor:LM,options:{}}],KYe={current:{}},_1={draggable:{measure:XW},droppable:{measure:XW,strategy:hv.WhileDragging,frequency:mF.Optimized},dragOverlay:{measure:mx}};class b0 extends Map{get(e){var n;return e!=null&&(n=super.get(e))!=null?n:void 0}toArray(){return Array.from(this.values())}getEnabled(){return this.toArray().filter(e=>{let{disabled:n}=e;return!n})}getNodeFor(e){var n,r;return(n=(r=this.get(e))==null?void 0:r.node.current)!=null?n:void 0}}const XYe={activatorEvent:null,active:null,activeNode:null,activeNodeRect:null,collisions:null,containerNodeRect:null,draggableNodes:new Map,droppableRects:new Map,droppableContainers:new b0,over:null,dragOverlay:{nodeRef:{current:null},rect:null,setRef:$k},scrollableAncestors:[],scrollableAncestorRects:[],measuringConfiguration:_1,measureDroppableContainers:$k,windowRect:null,measuringScheduled:!1},YYe={activatorEvent:null,activators:[],active:null,activeNodeRect:null,ariaDescribedById:{draggable:""},dispatch:$k,draggableNodes:new Map,over:null,measureDroppableContainers:$k},zM=w.createContext(YYe),Dae=w.createContext(XYe);function QYe(){return{draggable:{active:null,initialCoordinates:{x:0,y:0},nodes:new Map,translate:{x:0,y:0}},droppable:{containers:new b0}}}function ZYe(t,e){switch(e.type){case da.DragStart:return{...t,draggable:{...t.draggable,initialCoordinates:e.initialCoordinates,active:e.active}};case da.DragMove:return t.draggable.active==null?t:{...t,draggable:{...t.draggable,translate:{x:e.coordinates.x-t.draggable.initialCoordinates.x,y:e.coordinates.y-t.draggable.initialCoordinates.y}}};case da.DragEnd:case da.DragCancel:return{...t,draggable:{...t.draggable,active:null,initialCoordinates:{x:0,y:0},translate:{x:0,y:0}}};case da.RegisterDroppable:{const{element:n}=e,{id:r}=n,i=new b0(t.droppable.containers);return i.set(r,n),{...t,droppable:{...t.droppable,containers:i}}}case da.SetDroppableDisabled:{const{id:n,key:r,disabled:i}=e,s=t.droppable.containers.get(n);if(!s||r!==s.key)return t;const o=new b0(t.droppable.containers);return o.set(n,{...s,disabled:i}),{...t,droppable:{...t.droppable,containers:o}}}case da.UnregisterDroppable:{const{id:n,key:r}=e,i=t.droppable.containers.get(n);if(!i||r!==i.key)return t;const s=new b0(t.droppable.containers);return s.delete(n),{...t,droppable:{...t.droppable,containers:s}}}default:return t}}function JYe(t){let{disabled:e}=t;const{active:n,activatorEvent:r,draggableNodes:i}=w.useContext(zM),s=cF(r),o=cF(n?.id);return w.useEffect(()=>{if(!e&&!r&&s&&o!=null){if(!fI(s)||document.activeElement===s.target)return;const l=i.get(o);if(!l)return;const{activatorNode:c,node:u}=l;if(!c.current&&!u.current)return;requestAnimationFrame(()=>{for(const d of[c.current,u.current]){if(!d)continue;const h=WXe(d);if(h){h.focus();break}}})}},[r,e,i,o,s]),null}function eQe(t,e){let{transform:n,...r}=e;return t!=null&&t.length?t.reduce((i,s)=>s({transform:i,...r}),n):n}function tQe(t){return w.useMemo(()=>({draggable:{..._1.draggable,...t?.draggable},droppable:{..._1.droppable,...t?.droppable},dragOverlay:{..._1.dragOverlay,...t?.dragOverlay}}),[t?.draggable,t?.droppable,t?.dragOverlay])}function nQe(t){let{activeNode:e,measure:n,initialRect:r,config:i=!0}=t;const s=w.useRef(!1),{x:o,y:l}=typeof i=="boolean"?{x:i,y:i}:i;Bc(()=>{if(!o&&!l||!e){s.current=!1;return}if(s.current||!r)return;const u=e?.node.current;if(!u||u.isConnected===!1)return;const d=n(u),h=Sae(d,r);if(o||(h.x=0),l||(h.y=0),s.current=!0,Math.abs(h.x)>0||Math.abs(h.y)>0){const f=Nae(u);f&&f.scrollBy({top:h.y,left:h.x})}},[e,o,l,r,n])}const Rae=w.createContext({...Jl,scaleX:1,scaleY:1});var ph;(function(t){t[t.Uninitialized=0]="Uninitialized",t[t.Initializing=1]="Initializing",t[t.Initialized=2]="Initialized"})(ph||(ph={}));const Fae=w.memo(function(e){var n,r,i,s;let{id:o,accessibility:l,autoScroll:c=!0,children:u,sensors:d=WYe,collisionDetection:h=sYe,measuring:f,modifiers:p,...x}=e;const y=w.useReducer(ZYe,void 0,QYe),[b,v]=y,[S,N]=JXe(),[A,C]=w.useState(ph.Uninitialized),T=A===ph.Initialized,{draggable:{active:k,nodes:j,translate:E},droppable:{containers:P}}=b,U=k!=null?j.get(k):null,O=w.useRef({initial:null,translated:null}),B=w.useMemo(()=>{var Xe;return k!=null?{id:k,data:(Xe=U?.data)!=null?Xe:KYe,rect:O}:null},[k,U]),R=w.useRef(null),[G,q]=w.useState(null),[z,K]=w.useState(null),Y=uv(x,Object.values(x)),oe=Jv("DndDescribedBy",o),$=w.useMemo(()=>P.getEnabled(),[P]),X=tQe(f),{droppableRects:ee,measureDroppableContainers:J,measuringScheduled:_e}=FYe($,{dragging:T,dependencies:[E.x,E.y],config:X.droppable}),pe=DYe(j,k),me=w.useMemo(()=>z?uF(z):null,[z]),je=Pe(),de=LYe(pe,X.draggable.measure);nQe({activeNode:k!=null?j.get(k):null,config:je.layoutShiftCompensation,initialRect:de,measure:X.draggable.measure});const ce=eK(pe,X.draggable.measure,de),Se=eK(pe?pe.parentElement:null),ie=w.useRef({activatorEvent:null,active:null,activeNode:pe,collisionRect:null,collisions:null,droppableRects:ee,draggableNodes:j,draggingNode:null,draggingNodeRect:null,droppableContainers:P,over:null,scrollableAncestors:[],scrollAdjustedTranslate:null}),Fe=P.getNodeFor((n=ie.current.over)==null?void 0:n.id),V=qYe({measure:X.dragOverlay.measure}),W=(r=V.nodeRef.current)!=null?r:pe,ue=T?(i=V.rect)!=null?i:ce:null,Q=!!(V.nodeRef.current&&V.rect),se=zYe(Q?null:ce),Z=jae(W?uo(W):null),Ne=UYe(T?Fe??pe:null),ve=VYe(Ne),fe=eQe(p,{transform:{x:E.x-se.x,y:E.y-se.y,scaleX:1,scaleY:1},activatorEvent:z,active:B,activeNodeRect:ce,containerNodeRect:Se,draggingNodeRect:ue,over:ie.current.over,overlayNodeRect:V.rect,scrollableAncestors:Ne,scrollableAncestorRects:ve,windowRect:Z}),L=me?ub(me,E):null,D=BYe(Ne),H=nK(D),he=nK(D,[ce]),xe=ub(fe,H),be=ue?cYe(ue,fe):null,Ue=B&&be?h({active:B,collisionRect:be,droppableRects:ee,droppableContainers:$,pointerCoordinates:L}):null,Oe=wae(Ue,"id"),[Qe,rt]=w.useState(null),we=Q?fe:ub(fe,he),ye=oYe(we,(s=Qe?.rect)!=null?s:null,ce),le=w.useRef(null),Le=w.useCallback((Xe,De)=>{let{sensor:Re,options:qe}=De;if(R.current==null)return;const pt=j.get(R.current);if(!pt)return;const At=Xe.nativeEvent,Rt=new Re({active:R.current,activeNode:pt,event:At,options:qe,context:ie,onAbort(Tt){if(!j.get(Tt))return;const{onDragAbort:xt}=Y.current,wt={id:Tt};xt?.(wt),S({type:"onDragAbort",event:wt})},onPending(Tt,Ie,xt,wt){if(!j.get(Tt))return;const{onDragPending:Tn}=Y.current,fr={id:Tt,constraint:Ie,initialCoordinates:xt,offset:wt};Tn?.(fr),S({type:"onDragPending",event:fr})},onStart(Tt){const Ie=R.current;if(Ie==null)return;const xt=j.get(Ie);if(!xt)return;const{onDragStart:wt}=Y.current,Bt={activatorEvent:At,active:{id:Ie,data:xt.data,rect:O}};Ou.unstable_batchedUpdates(()=>{wt?.(Bt),C(ph.Initializing),v({type:da.DragStart,initialCoordinates:Tt,active:Ie}),S({type:"onDragStart",event:Bt}),q(le.current),K(At)})},onMove(Tt){v({type:da.DragMove,coordinates:Tt})},onEnd:Wt(da.DragEnd),onCancel:Wt(da.DragCancel)});le.current=Rt;function Wt(Tt){return async function(){const{active:xt,collisions:wt,over:Bt,scrollAdjustedTranslate:Tn}=ie.current;let fr=null;if(xt&&Tn){const{cancelDrop:Zn}=Y.current;fr={activatorEvent:At,active:xt,collisions:wt,delta:Tn,over:Bt},Tt===da.DragEnd&&typeof Zn=="function"&&await Promise.resolve(Zn(fr))&&(Tt=da.DragCancel)}R.current=null,Ou.unstable_batchedUpdates(()=>{v({type:Tt}),C(ph.Uninitialized),rt(null),q(null),K(null),le.current=null;const Zn=Tt===da.DragEnd?"onDragEnd":"onDragCancel";if(fr){const Jn=Y.current[Zn];Jn?.(fr),S({type:Zn,event:fr})}})}}},[j]),Me=w.useCallback((Xe,De)=>(Re,qe)=>{const pt=Re.nativeEvent,At=j.get(qe);if(R.current!==null||!At||pt.dndKit||pt.defaultPrevented)return;const Rt={active:At};Xe(Re,De.options,Rt)===!0&&(pt.dndKit={capturedBy:De.sensor},R.current=qe,Le(Re,De))},[j,Le]),$e=RYe(d,Me);HYe(d),Bc(()=>{ce&&A===ph.Initializing&&C(ph.Initialized)},[ce,A]),w.useEffect(()=>{const{onDragMove:Xe}=Y.current,{active:De,activatorEvent:Re,collisions:qe,over:pt}=ie.current;if(!De||!Re)return;const At={active:De,activatorEvent:Re,collisions:qe,delta:{x:xe.x,y:xe.y},over:pt};Ou.unstable_batchedUpdates(()=>{Xe?.(At),S({type:"onDragMove",event:At})})},[xe.x,xe.y]),w.useEffect(()=>{const{active:Xe,activatorEvent:De,collisions:Re,droppableContainers:qe,scrollAdjustedTranslate:pt}=ie.current;if(!Xe||R.current==null||!De||!pt)return;const{onDragOver:At}=Y.current,Rt=qe.get(Oe),Wt=Rt&&Rt.rect.current?{id:Rt.id,rect:Rt.rect.current,data:Rt.data,disabled:Rt.disabled}:null,Tt={active:Xe,activatorEvent:De,collisions:Re,delta:{x:pt.x,y:pt.y},over:Wt};Ou.unstable_batchedUpdates(()=>{rt(Wt),At?.(Tt),S({type:"onDragOver",event:Tt})})},[Oe]),Bc(()=>{ie.current={activatorEvent:z,active:B,activeNode:pe,collisionRect:be,collisions:Ue,droppableRects:ee,draggableNodes:j,draggingNode:W,draggingNodeRect:ue,droppableContainers:P,over:Qe,scrollableAncestors:Ne,scrollAdjustedTranslate:xe},O.current={initial:ue,translated:be}},[B,pe,Ue,be,j,W,ue,ee,P,Qe,Ne,xe]),EYe({...je,delta:E,draggingRect:be,pointerCoordinates:L,scrollableAncestors:Ne,scrollableAncestorRects:ve});const Ae=w.useMemo(()=>({active:B,activeNode:pe,activeNodeRect:ce,activatorEvent:z,collisions:Ue,containerNodeRect:Se,dragOverlay:V,draggableNodes:j,droppableContainers:P,droppableRects:ee,over:Qe,measureDroppableContainers:J,scrollableAncestors:Ne,scrollableAncestorRects:ve,measuringConfiguration:X,measuringScheduled:_e,windowRect:Z}),[B,pe,ce,z,Ue,Se,V,j,P,ee,Qe,J,Ne,ve,X,_e,Z]),Je=w.useMemo(()=>({activatorEvent:z,activators:$e,active:B,activeNodeRect:ce,ariaDescribedById:{draggable:oe},dispatch:v,draggableNodes:j,over:Qe,measureDroppableContainers:J}),[z,$e,B,ce,v,oe,j,Qe,J]);return $r.createElement(bae.Provider,{value:N},$r.createElement(zM.Provider,{value:Je},$r.createElement(Dae.Provider,{value:Ae},$r.createElement(Rae.Provider,{value:ye},u)),$r.createElement(JYe,{disabled:l?.restoreFocus===!1})),$r.createElement(nYe,{...l,hiddenTextDescribedById:oe}));function Pe(){const Xe=G?.autoScrollEnabled===!1,De=typeof c=="object"?c.enabled===!1:c===!1,Re=T&&!Xe&&!De;return typeof c=="object"?{...c,enabled:Re}:{enabled:Re}}}),rQe=w.createContext(null),iK="button",iQe="Draggable";function aQe(t){let{id:e,data:n,disabled:r=!1,attributes:i}=t;const s=Jv(iQe),{activators:o,activatorEvent:l,active:c,activeNodeRect:u,ariaDescribedById:d,draggableNodes:h,over:f}=w.useContext(zM),{role:p=iK,roleDescription:x="draggable",tabIndex:y=0}=i??{},b=c?.id===e,v=w.useContext(b?Rae:rQe),[S,N]=Hk(),[A,C]=Hk(),T=$Ye(o,e),k=uv(n);Bc(()=>(h.set(e,{id:e,key:s,node:S,activatorNode:A,data:k}),()=>{const E=h.get(e);E&&E.key===s&&h.delete(e)}),[h,e]);const j=w.useMemo(()=>({role:p,tabIndex:y,"aria-disabled":r,"aria-pressed":b&&p===iK?!0:void 0,"aria-roledescription":x,"aria-describedby":d.draggable}),[r,p,y,b,x,d.draggable]);return{active:c,activatorEvent:l,activeNodeRect:u,attributes:j,isDragging:b,listeners:r?void 0:T,node:S,over:f,setNodeRef:N,setActivatorNodeRef:C,transform:v}}function sQe(){return w.useContext(Dae)}const oQe="Droppable",lQe={timeout:25};function cQe(t){let{data:e,disabled:n=!1,id:r,resizeObserverConfig:i}=t;const s=Jv(oQe),{active:o,dispatch:l,over:c,measureDroppableContainers:u}=w.useContext(zM),d=w.useRef({disabled:n}),h=w.useRef(!1),f=w.useRef(null),p=w.useRef(null),{disabled:x,updateMeasurementsFor:y,timeout:b}={...lQe,...i},v=uv(y??r),S=w.useCallback(()=>{if(!h.current){h.current=!0;return}p.current!=null&&clearTimeout(p.current),p.current=setTimeout(()=>{u(Array.isArray(v.current)?v.current:[v.current]),p.current=null},b)},[b]),N=IM({callback:S,disabled:x||!o}),A=w.useCallback((j,E)=>{N&&(E&&(N.unobserve(E),h.current=!1),j&&N.observe(j))},[N]),[C,T]=Hk(A),k=uv(e);return w.useEffect(()=>{!N||!C.current||(N.disconnect(),h.current=!1,N.observe(C.current))},[C,N]),w.useEffect(()=>(l({type:da.RegisterDroppable,element:{id:r,key:s,disabled:n,node:C,rect:f,data:k}}),()=>l({type:da.UnregisterDroppable,key:s,id:r})),[r]),w.useEffect(()=>{n!==d.current.disabled&&(l({type:da.SetDroppableDisabled,id:r,key:s,disabled:n}),d.current.disabled=n)},[r,s,n,l]),{active:o,rect:f,isOver:c?.id===r,node:C,over:c,setNodeRef:T}}function UM(t,e,n){const r=t.slice();return r.splice(n<0?r.length+n:n,0,r.splice(e,1)[0]),r}function uQe(t,e){return t.reduce((n,r,i)=>{const s=e.get(r);return s&&(n[i]=s),n},Array(t.length))}function GS(t){return t!==null&&t>=0}function dQe(t,e){if(t===e)return!0;if(t.length!==e.length)return!1;for(let n=0;n{let{rects:e,activeIndex:n,overIndex:r,index:i}=t;const s=UM(e,r,n),o=e[i],l=s[i];return!l||!o?null:{x:l.left-o.left,y:l.top-o.top,scaleX:l.width/o.width,scaleY:l.height/o.height}},qS={scaleX:1,scaleY:1},mQe=t=>{var e;let{activeIndex:n,activeNodeRect:r,index:i,rects:s,overIndex:o}=t;const l=(e=s[n])!=null?e:r;if(!l)return null;if(i===n){const u=s[o];return u?{x:0,y:nn&&i<=o?{x:0,y:-l.height-c,...qS}:i=o?{x:0,y:l.height+c,...qS}:{x:0,y:0,...qS}};function fQe(t,e,n){const r=t[e],i=t[e-1],s=t[e+1];return r?nr.map(T=>typeof T=="object"&&"id"in T?T.id:T),[r]),x=o!=null,y=o?p.indexOf(o.id):-1,b=u?p.indexOf(u.id):-1,v=w.useRef(p),S=!dQe(p,v.current),N=b!==-1&&y===-1||S,A=hQe(s);Bc(()=>{S&&x&&d(p)},[S,p,x,d]),w.useEffect(()=>{v.current=p},[p]);const C=w.useMemo(()=>({activeIndex:y,containerId:h,disabled:A,disableTransforms:N,items:p,overIndex:b,useDragOverlay:f,sortedRects:uQe(p,c),strategy:i}),[y,h,A.draggable,A.droppable,N,p,b,c,f,i]);return $r.createElement(Oae.Provider,{value:C},e)}const pQe=t=>{let{id:e,items:n,activeIndex:r,overIndex:i}=t;return UM(n,r,i).indexOf(e)},gQe=t=>{let{containerId:e,isSorting:n,wasDragging:r,index:i,items:s,newIndex:o,previousItems:l,previousContainerId:c,transition:u}=t;return!u||!r||l!==s&&i===o?!1:n?!0:o!==i&&e===c},bQe={duration:200,easing:"ease"},zae="transform",xQe=Ub.Transition.toString({property:zae,duration:0,easing:"linear"}),yQe={roleDescription:"sortable"};function vQe(t){let{disabled:e,index:n,node:r,rect:i}=t;const[s,o]=w.useState(null),l=w.useRef(n);return Bc(()=>{if(!e&&n!==l.current&&r.current){const c=i.current;if(c){const u=mx(r.current,{ignoreTransform:!0}),d={x:c.left-u.left,y:c.top-u.top,scaleX:c.width/u.width,scaleY:c.height/u.height};(d.x||d.y)&&o(d)}}n!==l.current&&(l.current=n)},[e,n,r,i]),w.useEffect(()=>{s&&o(null)},[s]),s}function Uae(t){let{animateLayoutChanges:e=gQe,attributes:n,disabled:r,data:i,getNewIndex:s=pQe,id:o,strategy:l,resizeObserverConfig:c,transition:u=bQe}=t;const{items:d,containerId:h,activeIndex:f,disabled:p,disableTransforms:x,sortedRects:y,overIndex:b,useDragOverlay:v,strategy:S}=w.useContext(Oae),N=wQe(r,p),A=d.indexOf(o),C=w.useMemo(()=>({sortable:{containerId:h,index:A,items:d},...i}),[h,i,A,d]),T=w.useMemo(()=>d.slice(d.indexOf(o)),[d,o]),{rect:k,node:j,isOver:E,setNodeRef:P}=cQe({id:o,data:C,disabled:N.droppable,resizeObserverConfig:{updateMeasurementsFor:T,...c}}),{active:U,activatorEvent:O,activeNodeRect:B,attributes:R,setNodeRef:G,listeners:q,isDragging:z,over:K,setActivatorNodeRef:Y,transform:oe}=aQe({id:o,data:C,attributes:{...yQe,...n},disabled:N.draggable}),$=$Xe(P,G),X=!!U,ee=X&&!x&&GS(f)&&GS(b),J=!v&&z,_e=J&&ee?oe:null,me=ee?_e??(l??S)({rects:y,activeNodeRect:B,activeIndex:f,overIndex:b,index:A}):null,je=GS(f)&&GS(b)?s({id:o,items:d,activeIndex:f,overIndex:b}):A,de=U?.id,ce=w.useRef({activeId:de,items:d,newIndex:je,containerId:h}),Se=d!==ce.current.items,ie=e({active:U,containerId:h,isDragging:z,isSorting:X,id:o,index:A,items:d,newIndex:ce.current.newIndex,previousItems:ce.current.items,previousContainerId:ce.current.containerId,transition:u,wasDragging:ce.current.activeId!=null}),Fe=vQe({disabled:!ie,index:A,node:j,rect:k});return w.useEffect(()=>{X&&ce.current.newIndex!==je&&(ce.current.newIndex=je),h!==ce.current.containerId&&(ce.current.containerId=h),d!==ce.current.items&&(ce.current.items=d)},[X,je,h,d]),w.useEffect(()=>{if(de===ce.current.activeId)return;if(de!=null&&ce.current.activeId==null){ce.current.activeId=de;return}const W=setTimeout(()=>{ce.current.activeId=de},50);return()=>clearTimeout(W)},[de]),{active:U,activeIndex:f,attributes:R,data:C,rect:k,index:A,newIndex:je,items:d,isOver:E,isSorting:X,isDragging:z,listeners:q,node:j,overIndex:b,over:K,setNodeRef:$,setActivatorNodeRef:Y,setDroppableNodeRef:P,setDraggableNodeRef:G,transform:Fe??me,transition:V()};function V(){if(Fe||Se&&ce.current.newIndex===A)return xQe;if(!(J&&!fI(O)||!u)&&(X||ie))return Ub.Transition.toString({...u,property:zae})}}function wQe(t,e){var n,r;return typeof t=="boolean"?{draggable:t,droppable:!1}:{draggable:(n=t?.draggable)!=null?n:e.draggable,droppable:(r=t?.droppable)!=null?r:e.droppable}}function qk(t){if(!t)return!1;const e=t.data.current;return!!(e&&"sortable"in e&&typeof e.sortable=="object"&&"containerId"in e.sortable&&"items"in e.sortable&&"index"in e.sortable)}const _Qe=[ir.Down,ir.Right,ir.Up,ir.Left],Bae=(t,e)=>{let{context:{active:n,collisionRect:r,droppableRects:i,droppableContainers:s,over:o,scrollableAncestors:l}}=e;if(_Qe.includes(t.code)){if(t.preventDefault(),!n||!r)return;const c=[];s.getEnabled().forEach(h=>{if(!h||h!=null&&h.disabled)return;const f=i.get(h.id);if(f)switch(t.code){case ir.Down:r.topf.top&&c.push(h);break;case ir.Left:r.left>f.left&&c.push(h);break;case ir.Right:r.left1&&(d=u[1].id),d!=null){const h=s.get(n.id),f=s.get(d),p=f?i.get(f.id):null,x=f?.node.current;if(x&&p&&h&&f){const b=FM(x).some((T,k)=>l[k]!==T),v=Hae(h,f),S=SQe(h,f),N=b||!v?{x:0,y:0}:{x:S?r.width-p.width:0,y:S?r.height-p.height:0},A={x:p.left,y:p.top};return N.x&&N.y?A:dv(A,N)}}}};function Hae(t,e){return!qk(t)||!qk(e)?!1:t.data.current.sortable.containerId===e.data.current.sortable.containerId}function SQe(t,e){return!qk(t)||!qk(e)||!Hae(t,e)?!1:t.data.current.sortable.index=1e3?`${(t/1e3).toFixed(1)}kg`:`${Math.round(t)}g`}function NQe(t,e="system",n){if(!t)return n?.("queue.time.asap")??"ASAP";const r=Zi(t);if(!r)return n?.("queue.time.asap")??"ASAP";const i=new Date,s=r.getTime()-i.getTime();return s<-6e4?n?.("queue.time.overdue")??"Overdue":s<0?n?.("queue.time.now")??"Now":s<6e4?n?.("queue.time.lessThanMinute")??"In less than a minute":s<36e5?n?.("queue.time.inMinutes",{count:Math.round(s/6e4)})??`In ${Math.round(s/6e4)} min`:s<864e5?n?.("queue.time.inHours",{count:Math.round(s/36e5)})??`In ${Math.round(s/36e5)} hours`:Lf(t,e)}function kQe({status:t,waitingReason:e,printerState:n,t:r}){if(t==="pending"&&e)return a.jsxs("span",{className:"inline-flex items-center gap-1.5 px-2.5 py-1 rounded-full text-xs font-medium border text-purple-400 bg-purple-400/10 border-purple-400/20",children:[a.jsx(Wn,{className:"w-3.5 h-3.5"}),r("queue.status.waiting")]});if(t==="printing"&&(n==="PAUSE"||n==="PAUSED"))return a.jsxs("span",{className:"inline-flex items-center gap-1.5 px-2.5 py-1 rounded-full text-xs font-medium border text-yellow-400 bg-yellow-400/10 border-yellow-400/20",children:[a.jsx(sC,{className:"w-3.5 h-3.5"}),r("queue.status.paused")]});const i={pending:{icon:Wn,color:"text-status-warning bg-status-warning/10 border-status-warning/20",label:r("queue.status.pending")},printing:{icon:so,color:"text-blue-400 bg-blue-400/10 border-blue-400/20",label:r("queue.status.printing")},completed:{icon:gr,color:"text-status-ok bg-status-ok/10 border-status-ok/20",label:r("queue.status.completed")},failed:{icon:ha,color:"text-status-error bg-status-error/10 border-status-error/20",label:r("queue.status.failed")},skipped:{icon:IF,color:"text-orange-400 bg-orange-400/10 border-orange-400/20",label:r("queue.status.skipped")},cancelled:{icon:Ft,color:"text-gray-400 bg-gray-400/10 border-gray-400/20",label:r("queue.status.cancelled")}},{icon:s,color:o,label:l}=i[t];return a.jsxs("span",{className:`inline-flex items-center gap-1.5 px-2.5 py-1 rounded-full text-xs font-medium border ${o}`,children:[a.jsx(s,{className:"w-3.5 h-3.5"}),l]})}function CQe({selectedCount:t,printers:e,onSave:n,onClose:r,isSaving:i,t:s}){const[o,l]=w.useState("unchanged"),[c,u]=w.useState("unchanged"),[d,h]=w.useState("unchanged"),[f,p]=w.useState("unchanged"),[x,y]=w.useState("unchanged"),[b,v]=w.useState("unchanged"),[S,N]=w.useState("unchanged"),[A,C]=w.useState("unchanged"),[T,k]=w.useState("unchanged"),[j,E]=w.useState("unchanged"),P=()=>{const O={};o!=="unchanged"&&(O.printer_id=o),c!=="unchanged"&&(O.manual_start=c),d!=="unchanged"&&(O.auto_off_after=d),f!=="unchanged"&&(O.require_previous_success=f),x!=="unchanged"&&(O.bed_levelling=x),b!=="unchanged"&&(O.flow_cali=b),S!=="unchanged"&&(O.vibration_cali=S),A!=="unchanged"&&(O.layer_inspect=A),T!=="unchanged"&&(O.timelapse=T),j!=="unchanged"&&(O.use_ams=j),n(O)},U=o!=="unchanged"||c!=="unchanged"||d!=="unchanged"||f!=="unchanged"||x!=="unchanged"||b!=="unchanged"||S!=="unchanged"||A!=="unchanged"||T!=="unchanged"||j!=="unchanged";return a.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center p-4 bg-black/50 backdrop-blur-sm",children:a.jsxs("div",{className:"bg-bambu-dark-secondary rounded-xl border border-bambu-dark-tertiary w-full max-w-lg max-h-[90vh] overflow-y-auto",children:[a.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-bambu-dark-tertiary",children:[a.jsx("h2",{className:"text-lg font-semibold text-white",children:s("queue.bulkEdit.title",{count:t})}),a.jsx("button",{onClick:r,className:"p-1 hover:bg-bambu-dark rounded",children:a.jsx(Ft,{className:"w-5 h-5 text-bambu-gray"})})]}),a.jsxs("div",{className:"p-4 space-y-4",children:[a.jsx("p",{className:"text-sm text-bambu-gray",children:s("queue.bulkEdit.description")}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm font-medium text-white mb-2",children:s("queue.bulkEdit.printer")}),a.jsxs("select",{value:o===null?"null":o==="unchanged"?"unchanged":String(o),onChange:O=>{const B=O.target.value;l(B==="unchanged"?"unchanged":B==="null"?null:Number(B))},className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",children:[a.jsx("option",{value:"unchanged",children:s("queue.bulkEdit.noChange")}),a.jsx("option",{value:"null",children:s("queue.filter.unassigned")}),e.map(O=>a.jsx("option",{value:O.id,children:O.name},O.id))]})]}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm font-medium text-white mb-2",children:s("queue.bulkEdit.queueOptions")}),a.jsxs("div",{className:"space-y-2",children:[a.jsx(Mu,{label:s("queue.bulkEdit.staged"),value:c,onChange:u,t:s}),a.jsx(Mu,{label:s("queue.bulkEdit.autoPowerOff"),value:d,onChange:h,t:s}),a.jsx(Mu,{label:s("queue.bulkEdit.requirePrevious"),value:f,onChange:p,t:s})]})]}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm font-medium text-white mb-2",children:s("queue.bulkEdit.printOptions")}),a.jsxs("div",{className:"space-y-2",children:[a.jsx(Mu,{label:s("queue.bulkEdit.bedLevelling"),value:x,onChange:y,t:s}),a.jsx(Mu,{label:s("queue.bulkEdit.flowCalibration"),value:b,onChange:v,t:s}),a.jsx(Mu,{label:s("queue.bulkEdit.vibrationCalibration"),value:S,onChange:N,t:s}),a.jsx(Mu,{label:s("queue.bulkEdit.layerInspection"),value:A,onChange:C,t:s}),a.jsx(Mu,{label:s("queue.bulkEdit.timelapse"),value:T,onChange:k,t:s}),a.jsx(Mu,{label:s("queue.bulkEdit.useAms"),value:j,onChange:E,t:s})]})]})]}),a.jsxs("div",{className:"flex justify-end gap-3 p-4 border-t border-bambu-dark-tertiary",children:[a.jsx(Ce,{variant:"secondary",onClick:r,children:s("common.cancel")}),a.jsx(Ce,{onClick:P,disabled:!U||i,children:s(i?"common.saving":"queue.bulkEdit.applyChanges")})]})]})})}function Mu({label:t,value:e,onChange:n,t:r}){return a.jsxs("div",{className:"flex items-center justify-between py-1",children:[a.jsx("span",{className:"text-sm text-bambu-gray",children:t}),a.jsxs("div",{className:"flex items-center gap-1 bg-bambu-dark rounded-lg p-0.5",children:[a.jsx("button",{onClick:()=>n("unchanged"),className:`px-2 py-1 text-xs rounded ${e==="unchanged"?"bg-bambu-dark-tertiary text-white":"text-bambu-gray hover:text-white"}`,children:"—"}),a.jsx("button",{onClick:()=>n(!1),className:`px-2 py-1 text-xs rounded ${e===!1?"bg-red-500/20 text-red-400":"text-bambu-gray hover:text-white"}`,children:r("common.off")}),a.jsx("button",{onClick:()=>n(!0),className:`px-2 py-1 text-xs rounded ${e===!0?"bg-bambu-green/20 text-bambu-green":"text-bambu-gray hover:text-white"}`,children:r("common.on")})]})]})}function Uj({item:t,position:e,onEdit:n,onCancel:r,onRemove:i,onStop:s,onRequeue:o,onStart:l,timeFormat:c="system",isSelected:u=!1,onToggleSelect:d,hasPermission:h,canModify:f,printerState:p,t:x}){const{data:y}=Ze({queryKey:["printerStatus",t.printer_id],queryFn:()=>re.getPrinterStatus(t.printer_id),refetchInterval:3e4,enabled:t.printer_id!=null&&p==="printing"}),b=!!t.library_file_id&&!t.archive_id,{data:v}=Ze({queryKey:["archive-plates",t.archive_id],queryFn:()=>re.getArchivePlates(t.archive_id),enabled:!!t.archive_id&&!b}),{data:S}=Ze({queryKey:["library-file-plates",t.library_file_id],queryFn:()=>re.getLibraryFilePlates(t.library_file_id),enabled:b&&!!t.library_file_id}),N=b?S:v,A=N?.plates??[],C=h("queue:reorder"),{attributes:T,listeners:k,setNodeRef:j,transform:E,transition:P,isDragging:U}=Uae({id:t.id,disabled:t.status!=="pending"||!C}),O={transform:Ub.Transform.toString(E),transition:P},B=t.status==="printing",R=t.status==="pending",G=["completed","failed","skipped","cancelled"].includes(t.status),q=R&&d;return a.jsxs("div",{ref:j,style:O,className:` + group relative bg-bambu-dark-secondary rounded-xl border transition-all duration-200 ${U?"opacity-50 scale-[1.02] shadow-xl z-50":""} ${B?"border-blue-500/30 bg-gradient-to-r from-blue-500/5 to-transparent":""} - `,children:a.jsxs("div",{className:"flex items-center gap-4 p-4",children:[R&&d&&a.jsx("button",{onClick:q=>{q.stopPropagation(),d()},className:`flex items-center justify-center w-6 h-6 rounded border transition-colors ${u?"bg-bambu-green border-bambu-green text-white":"border-white/30 bg-black/30 hover:border-bambu-green/50"}`,children:u&&a.jsx(Xr,{className:"w-4 h-4"})}),R?a.jsx("div",{...T,...k,className:"flex items-center justify-center w-10 h-10 md:w-8 md:h-8 rounded-lg bg-bambu-dark cursor-grab active:cursor-grabbing hover:bg-bambu-dark-tertiary transition-colors touch-manipulation",children:a.jsx(Dh,{className:"w-6 h-6 md:w-4 md:h-4 text-bambu-gray"})}):e!==void 0?a.jsxs("div",{className:"flex items-center justify-center w-8 h-8 rounded-lg bg-bambu-dark text-bambu-gray text-sm font-medium",children:["#",e]}):a.jsx("div",{className:"w-8"}),a.jsx("div",{className:"w-14 h-14 flex-shrink-0 bg-bambu-dark rounded-lg overflow-hidden",children:t.archive_thumbnail?a.jsx("img",{src:t.plate_id!=null?re.getArchivePlateThumbnail(t.archive_id,t.plate_id):re.getArchiveThumbnail(t.archive_id),alt:"",className:"w-full h-full object-cover"}):t.library_file_thumbnail?a.jsx("img",{src:t.plate_id!=null?re.getLibraryFilePlateThumbnail(t.library_file_id,t.plate_id):re.getLibraryFileThumbnailUrl(t.library_file_id),alt:"",className:"w-full h-full object-cover"}):a.jsx("div",{className:"w-full h-full flex items-center justify-center text-bambu-gray",children:a.jsx(ma,{className:"w-6 h-6"})})}),a.jsxs("div",{className:"flex-1 min-w-0",children:[a.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[a.jsxs("p",{className:"text-white font-medium truncate",children:[t.archive_name||t.library_file_name||`File #${t.archive_id||t.library_file_id}`,(N?.is_multi_plate??!1)&&t.plate_id!==void 0&&t.plate_id!==null&&` • ${A.find(q=>q.index===t.plate_id)?.name||x("queue.plateNumber",{index:t.plate_id})}`]}),t.archive_id?a.jsx(Xs,{to:`/archives?highlight=${t.archive_id}`,className:"text-bambu-gray hover:text-bambu-green transition-colors flex-shrink-0",title:x("queue.viewArchive"),children:a.jsx(Kr,{className:"w-3.5 h-3.5"})}):t.library_file_id?a.jsx(Xs,{to:`/library?highlight=${t.library_file_id}`,className:"text-bambu-gray hover:text-bambu-green transition-colors flex-shrink-0",title:x("queue.viewInFileManager"),children:a.jsx(Kr,{className:"w-3.5 h-3.5"})}):null]}),a.jsxs("div",{className:"flex items-center gap-3 text-sm text-bambu-gray",children:[a.jsxs("span",{className:`flex items-center gap-1.5 ${t.printer_id===null&&!t.target_model?"text-orange-400":""} ${t.target_model?"text-blue-400":""}`,children:[a.jsx(Cr,{className:"w-3.5 h-3.5"}),t.target_model?`${x("queue.filter.any")} ${t.target_model}${t.target_location?` @ ${t.target_location}`:""}${t.required_filament_types?.length?` (${t.required_filament_types.join(", ")})`:""}`:t.printer_id===null?x("queue.filter.unassigned"):t.printer_name||`${x("common.printer")} #${t.printer_id}`]}),t.print_time_seconds&&a.jsxs("span",{className:"flex items-center gap-1.5",children:[a.jsx(Iu,{className:"w-3.5 h-3.5"}),Zs(t.print_time_seconds)]}),t.filament_used_grams&&a.jsxs("span",{className:"flex items-center gap-1.5",children:[a.jsx(_X,{className:"w-3.5 h-3.5"}),$ae(t.filament_used_grams)]}),t.created_by_username&&a.jsxs("span",{className:"flex items-center gap-1.5",title:x("queue.addedBy",{name:t.created_by_username}),children:[a.jsx(rd,{className:"w-3.5 h-3.5"}),t.created_by_username]}),R&&!t.manual_start&&a.jsxs("span",{className:"flex items-center gap-1.5",children:[a.jsx(Wn,{className:"w-3.5 h-3.5"}),NQe(t.scheduled_time,c,x)]})]}),a.jsxs("div",{className:"flex items-center gap-2 mt-2",children:[t.manual_start&&a.jsxs("span",{className:"text-xs px-2 py-0.5 bg-purple-500/10 text-purple-400 rounded-full border border-purple-500/20 flex items-center gap-1",children:[a.jsx(fX,{className:"w-3 h-3"}),x("queue.badges.staged")]}),t.require_previous_success&&a.jsx("span",{className:"text-xs px-2 py-0.5 bg-orange-500/10 text-orange-400 rounded-full border border-orange-500/20",children:x("queue.badges.requiresPrevious")}),t.auto_off_after&&a.jsxs("span",{className:"text-xs px-2 py-0.5 bg-blue-500/10 text-blue-400 rounded-full border border-blue-500/20 flex items-center gap-1",children:[a.jsx(fd,{className:"w-3 h-3"}),x("queue.badges.autoPowerOff")]})]}),B&&y&&a.jsxs("div",{className:"mt-3",children:[a.jsxs("div",{className:"flex items-center justify-between text-sm",children:[a.jsx("div",{className:"flex-1 bg-bambu-dark-tertiary rounded-full h-2 mr-3",children:a.jsx("div",{className:"bg-bambu-green h-2 rounded-full transition-all",style:{width:`${y.progress||0}%`}})}),a.jsxs("span",{className:"text-white",children:[Math.round(y.progress||0),"%"]})]}),a.jsxs("div",{className:"flex items-center gap-3 mt-2 text-xs text-bambu-gray",children:[y.remaining_time!=null&&y.remaining_time>0&&a.jsxs(a.Fragment,{children:[a.jsxs("span",{className:"flex items-center gap-1",children:[a.jsx(Wn,{className:"w-3 h-3"}),Zs(y.remaining_time*60)]}),a.jsxs("span",{className:"text-bambu-green font-medium",title:x("printers.estimatedCompletion"),children:["ETA ",$F(y.remaining_time,c,x)]})]}),y.layer_num!=null&&y.total_layers!=null&&y.total_layers>0&&a.jsxs("span",{className:"flex items-center gap-1",children:[a.jsx(ma,{className:"w-3 h-3"}),y.layer_num,"/",y.total_layers]})]})]}),t.waiting_reason&&t.status==="pending"&&a.jsxs("p",{className:"text-xs text-purple-400 mt-2 flex items-start gap-1",children:[a.jsx(Hi,{className:"w-3 h-3 mt-0.5 flex-shrink-0"}),a.jsx("span",{children:t.waiting_reason})]}),t.error_message&&a.jsxs("p",{className:"text-xs text-red-400 mt-2 flex items-center gap-1",children:[a.jsx(Hi,{className:"w-3 h-3"}),t.error_message]})]}),a.jsx(kQe,{status:t.status,waitingReason:t.waiting_reason,printerState:p,t:x}),a.jsxs("div",{className:"flex items-center gap-1",children:[B&&a.jsx(Ce,{variant:"ghost",size:"sm",onClick:s,disabled:!h("printers:control"),title:h("printers:control")?x("queue.actions.stopPrint"):x("queue.permissions.noStopPrint"),className:"text-red-400 hover:text-red-300 hover:bg-red-500/10",children:a.jsx(ahe,{className:"w-4 h-4"})}),R&&a.jsxs(a.Fragment,{children:[t.manual_start&&a.jsx(Ce,{variant:"ghost",size:"sm",onClick:l,disabled:!h("printers:control"),title:h("printers:control")?x("queue.actions.startPrint"):x("queue.permissions.noStartPrint"),className:"text-bambu-green hover:text-bambu-green-light hover:bg-bambu-green/10",children:a.jsx(so,{className:"w-4 h-4"})}),a.jsx(Ce,{variant:"ghost",size:"sm",onClick:n,disabled:!f("queue","update",t.created_by_id),title:f("queue","update",t.created_by_id)?x("common.edit"):x("queue.permissions.noEdit"),children:a.jsx(Vi,{className:"w-4 h-4"})}),a.jsx(Ce,{variant:"ghost",size:"sm",onClick:r,disabled:!f("queue","delete",t.created_by_id),title:f("queue","delete",t.created_by_id)?x("common.cancel"):x("queue.permissions.noCancel"),className:"text-red-400 hover:text-red-300 hover:bg-red-500/10",children:a.jsx(Ft,{className:"w-4 h-4"})})]}),G&&a.jsxs(a.Fragment,{children:[a.jsx(Ce,{variant:"ghost",size:"sm",onClick:o,disabled:!h("queue:create"),title:h("queue:create")?x("queue.actions.requeue"):x("queue.permissions.noRequeue"),className:"text-bambu-green hover:text-bambu-green/80 hover:bg-bambu-green/10",children:a.jsx(kr,{className:"w-4 h-4"})}),a.jsx(Ce,{variant:"ghost",size:"sm",onClick:i,disabled:!f("queue","delete",t.created_by_id),title:f("queue","delete",t.created_by_id)?x("common.remove"):x("queue.permissions.noRemove"),children:a.jsx(Jt,{className:"w-4 h-4"})})]})]})]})})}function MQe(){const{t}=Vt(),e=tn(),{showToast:n}=hn(),{hasPermission:r,hasAnyPermission:i,canModify:s}=Ir(),[o,l]=w.useState(null),[c,u]=w.useState(""),[d,h]=w.useState(""),[f,p]=w.useState(!1),[x,y]=w.useState(null),[b,v]=w.useState(null),[S,N]=w.useState(null),[A,C]=w.useState([]),[T,k]=w.useState(!1),[j,E]=w.useState(()=>localStorage.getItem("queue.historySortBy")||"date"),[P,U]=w.useState(()=>{const L=localStorage.getItem("queue.historySortAsc");return L!==null?L==="true":!1}),[O,B]=w.useState(()=>localStorage.getItem("queue.pendingSortBy")||"position"),[R,G]=w.useState(()=>{const L=localStorage.getItem("queue.pendingSortAsc");return L!==null?L==="true":!0});w.useEffect(()=>{localStorage.setItem("queue.historySortBy",j)},[j]),w.useEffect(()=>{localStorage.setItem("queue.historySortAsc",String(P))},[P]),w.useEffect(()=>{localStorage.setItem("queue.pendingSortBy",O)},[O]),w.useEffect(()=>{localStorage.setItem("queue.pendingSortAsc",String(R))},[R]);const q=xae(Vk(OM,{activationConstraint:{distance:8}}),Vk(LM,{coordinateGetter:Bae})),{data:z}=Ze({queryKey:["settings"],queryFn:re.getSettings}),K=z?.time_format||"system",{data:Y,isLoading:oe}=Ze({queryKey:["queue",o,c],queryFn:()=>re.getQueue(o||void 0,c||void 0),refetchInterval:5e3}),{data:$}=Ze({queryKey:["printers"],queryFn:()=>re.getPrinters()}),X=ot({mutationFn:L=>re.cancelQueueItem(L),onSuccess:()=>{e.invalidateQueries({queryKey:["queue"]}),n(t("queue.toast.cancelled"))},onError:()=>n(t("queue.toast.cancelFailed"),"error")}),ee=ot({mutationFn:L=>re.removeFromQueue(L),onSuccess:()=>{e.invalidateQueries({queryKey:["queue"]}),n(t("queue.toast.removed"))},onError:()=>n(t("queue.toast.removeFailed"),"error")}),J=ot({mutationFn:L=>re.stopQueueItem(L),onSuccess:()=>{e.invalidateQueries({queryKey:["queue"]}),n(t("queue.toast.stopped"))},onError:()=>n(t("queue.toast.stopFailed"),"error")}),_e=ot({mutationFn:L=>re.startQueueItem(L),onSuccess:()=>{e.invalidateQueries({queryKey:["queue"]}),n(t("queue.toast.released"))},onError:()=>n(t("queue.toast.startFailed"),"error")}),pe=ot({mutationFn:L=>re.reorderQueue(L),onSuccess:()=>{e.invalidateQueries({queryKey:["queue"]})},onError:()=>n(t("queue.toast.reorderFailed"),"error")}),me=ot({mutationFn:async()=>{const L=Y?.filter(D=>["completed","failed","skipped","cancelled"].includes(D.status))||[];for(const D of L)await re.removeFromQueue(D.id);return L.length},onSuccess:L=>{e.invalidateQueries({queryKey:["queue"]}),n(t("queue.toast.historyCleared",{count:L}))},onError:()=>n(t("queue.toast.clearHistoryFailed"),"error")}),je=ot({mutationFn:L=>re.bulkUpdateQueue(L),onSuccess:L=>{e.invalidateQueries({queryKey:["queue"]}),C([]),k(!1),n(L.message)},onError:()=>n(t("queue.toast.updateFailed"),"error")}),de=ot({mutationFn:async L=>{for(const D of L)await re.cancelQueueItem(D);return L.length},onSuccess:L=>{e.invalidateQueries({queryKey:["queue"]}),C([]),n(t("queue.toast.bulkCancelled",{count:L}))},onError:()=>n(t("queue.toast.bulkCancelFailed"),"error")}),ce=L=>{C(D=>D.includes(L)?D.filter(H=>H!==L):[...D,L])},Se=w.useMemo(()=>{const L=new Set;return $?.forEach(D=>{D.location&&L.add(D.location)}),Y?.forEach(D=>{D.target_location&&L.add(D.target_location)}),Array.from(L).sort()},[$,Y]),ie=w.useCallback(L=>d?L.target_location?L.target_location===d:L.printer_id?$?.find(H=>H.id===L.printer_id)?.location===d:!1:!0,[d,$]),Fe=w.useMemo(()=>{let L=Y?.filter(H=>H.status==="pending")||[];d&&(L=L.filter(ie));const D=H=>{if(!H.scheduled_time)return 0;const he=new Date(H.scheduled_time).getTime(),xe=Date.now()+4320*60*60*1e3;return he>xe?0:he};return[...L].sort((H,he)=>{let xe;if(O==="name"){const be=H.archive_name||H.library_file_name||"",Ue=he.archive_name||he.library_file_name||"";xe=be.localeCompare(Ue)}else O==="printer"?xe=(H.printer_name||"").localeCompare(he.printer_name||""):O==="time"?xe=D(H)-D(he):xe=H.position-he.position;return R?xe:-xe})},[Y,O,R,ie,d]),V=()=>{const L=Fe.map(D=>D.id);A.length===L.length?C([]):C(L)},W=w.useMemo(()=>{let L=Y?.filter(D=>D.status==="printing")||[];return d&&(L=L.filter(ie)),L},[Y,d,ie]),ue=w.useMemo(()=>{const L=new Set;return W.forEach(D=>{D.printer_id&&L.add(D.printer_id)}),Array.from(L)},[W]),Q=DF({queries:ue.map(L=>({queryKey:["printerStatus",L],queryFn:()=>re.getPrinterStatus(L),refetchInterval:5e3}))}),se=w.useMemo(()=>{const L={};return ue.forEach((D,H)=>{const he=Q[H];he?.data?.state&&(L[D]=he.data.state)}),L},[ue,Q]),Z=w.useMemo(()=>{let L=Y?.filter(D=>["completed","failed","skipped","cancelled"].includes(D.status))||[];return d&&(L=L.filter(ie)),[...L].sort((D,H)=>{let he;if(j==="name"){const xe=D.archive_name||D.library_file_name||"",be=H.archive_name||H.library_file_name||"";he=xe.localeCompare(be)}else j==="printer"?he=(D.printer_name||"").localeCompare(H.printer_name||""):he=new Date(H.completed_at||H.created_at).getTime()-new Date(D.completed_at||D.created_at).getTime();return P?-he:he})},[Y,j,P,ie,d]),Ne=w.useMemo(()=>Fe.reduce((L,D)=>L+(D.print_time_seconds||0),0),[Fe]),ve=w.useMemo(()=>Fe.reduce((L,D)=>L+(D.filament_used_grams||0),0),[Fe]),fe=L=>{const{active:D,over:H}=L;if(!H||D.id===H.id)return;const he=Fe.findIndex(be=>be.id===D.id),xe=Fe.findIndex(be=>be.id===H.id);if(he!==-1&&xe!==-1){const Ue=UM(Fe,he,xe).map((Oe,Qe)=>({id:Oe.id,position:Qe+1}));pe.mutate(Ue)}};return a.jsxs("div",{className:"p-4 md:p-8",children:[a.jsx("div",{className:"flex items-center justify-between mb-8",children:a.jsxs("div",{children:[a.jsxs("h1",{className:"text-2xl font-bold text-white flex items-center gap-3",children:[a.jsx(pX,{className:"w-7 h-7 text-bambu-green"}),t("queue.title")]}),a.jsx("p",{className:"text-bambu-gray mt-1",children:t("queue.subtitle")})]})}),a.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-5 gap-4 mb-8",children:[a.jsx(vt,{className:"bg-gradient-to-br from-blue-500/10 to-transparent border-blue-500/20",children:a.jsx(Nt,{className:"p-4",children:a.jsxs("div",{className:"flex items-center gap-3",children:[a.jsx("div",{className:"w-10 h-10 rounded-lg bg-blue-500/20 flex items-center justify-center",children:a.jsx(so,{className:"w-5 h-5 text-blue-400"})}),a.jsxs("div",{children:[a.jsx("p",{className:"text-2xl font-bold text-white",children:W.length}),a.jsx("p",{className:"text-sm text-bambu-gray",children:t("queue.summary.printing")})]})]})})}),a.jsx(vt,{className:"bg-gradient-to-br from-yellow-500/10 to-transparent border-yellow-500/20",children:a.jsx(Nt,{className:"p-4",children:a.jsxs("div",{className:"flex items-center gap-3",children:[a.jsx("div",{className:"w-10 h-10 rounded-lg bg-yellow-500/20 flex items-center justify-center",children:a.jsx(Wn,{className:"w-5 h-5 text-yellow-400"})}),a.jsxs("div",{children:[a.jsx("p",{className:"text-2xl font-bold text-white",children:Fe.length}),a.jsx("p",{className:"text-sm text-bambu-gray",children:t("queue.summary.queued")})]})]})})}),a.jsx(vt,{className:"bg-gradient-to-br from-bambu-green/10 to-transparent border-bambu-green/20",children:a.jsx(Nt,{className:"p-4",children:a.jsxs("div",{className:"flex items-center gap-3",children:[a.jsx("div",{className:"w-10 h-10 rounded-lg bg-bambu-green/20 flex items-center justify-center",children:a.jsx(Iu,{className:"w-5 h-5 text-bambu-green"})}),a.jsxs("div",{children:[a.jsx("p",{className:"text-2xl font-bold text-white",children:Zs(Ne)}),a.jsx("p",{className:"text-sm text-bambu-gray",children:t("queue.summary.totalTime")})]})]})})}),a.jsx(vt,{className:"bg-gradient-to-br from-purple-500/10 to-transparent border-purple-500/20",children:a.jsx(Nt,{className:"p-4",children:a.jsxs("div",{className:"flex items-center gap-3",children:[a.jsx("div",{className:"w-10 h-10 rounded-lg bg-purple-500/20 flex items-center justify-center",children:a.jsx(_X,{className:"w-5 h-5 text-purple-500"})}),a.jsxs("div",{children:[a.jsx("p",{className:"text-2xl font-bold text-white",children:$ae(ve)}),a.jsx("p",{className:"text-sm text-bambu-gray",children:t("queue.summary.totalWeight")})]})]})})}),a.jsx(vt,{className:"bg-gradient-to-br from-gray-500/10 to-transparent border-gray-500/20",children:a.jsx(Nt,{className:"p-4",children:a.jsxs("div",{className:"flex items-center gap-3",children:[a.jsx("div",{className:"w-10 h-10 rounded-lg bg-gray-500/20 flex items-center justify-center",children:a.jsx(gr,{className:"w-5 h-5 text-gray-400"})}),a.jsxs("div",{children:[a.jsx("p",{className:"text-2xl font-bold text-white",children:Z.length}),a.jsx("p",{className:"text-sm text-bambu-gray",children:t("queue.summary.history")})]})]})})})]}),a.jsxs("div",{className:"flex items-center gap-4 mb-6",children:[a.jsxs("select",{className:"px-3 py-2 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",value:o===-1?"unassigned":o||"",onChange:L=>{const D=L.target.value;l(D==="unassigned"?-1:D===""?null:Number(D))},children:[a.jsx("option",{value:"",children:t("queue.filter.allPrinters")}),a.jsx("option",{value:"unassigned",children:t("queue.filter.unassigned")}),$?.map(L=>a.jsx("option",{value:L.id,children:L.name},L.id))]}),a.jsxs("select",{className:"px-3 py-2 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",value:c,onChange:L=>u(L.target.value),children:[a.jsx("option",{value:"",children:t("queue.filter.allStatus")}),a.jsx("option",{value:"pending",children:t("queue.status.pending")}),a.jsx("option",{value:"printing",children:t("queue.status.printing")}),a.jsx("option",{value:"completed",children:t("queue.status.completed")}),a.jsx("option",{value:"failed",children:t("queue.status.failed")}),a.jsx("option",{value:"skipped",children:t("queue.status.skipped")}),a.jsx("option",{value:"cancelled",children:t("queue.status.cancelled")})]}),Se.length>0&&a.jsxs("select",{className:"px-3 py-2 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",value:d,onChange:L=>h(L.target.value),children:[a.jsx("option",{value:"",children:t("queue.filter.allLocations")}),Se.map(L=>a.jsx("option",{value:L,children:L},L))]}),a.jsx("div",{className:"flex-1"}),Z.length>0&&a.jsxs(Ce,{variant:"secondary",size:"sm",onClick:()=>p(!0),disabled:!r("queue:delete_all"),title:r("queue:delete_all")?void 0:t("queue.permissions.noClearHistory"),children:[a.jsx(Jt,{className:"w-4 h-4"}),t("queue.clearHistory")]})]}),oe?a.jsx("div",{className:"text-center py-12 text-bambu-gray",children:t("common.loading")}):Y?.length===0?a.jsxs(vt,{className:"p-12 text-center border-dashed",children:[a.jsx(ii,{className:"w-16 h-16 text-bambu-gray mx-auto mb-4 opacity-50"}),a.jsx("h3",{className:"text-xl font-medium text-white mb-2",children:t("queue.empty.title")}),a.jsx("p",{className:"text-bambu-gray max-w-md mx-auto",children:t("queue.empty.description")})]}):a.jsxs("div",{className:"space-y-8",children:[W.length>0&&a.jsxs("div",{children:[a.jsxs("h2",{className:"text-lg font-semibold text-white mb-4 flex items-center gap-2",children:[a.jsx("div",{className:"w-2 h-2 rounded-full bg-blue-400 animate-pulse"}),t("queue.sections.currentlyPrinting")]}),a.jsx("div",{className:"space-y-3",children:W.map(L=>a.jsx(Uj,{item:L,onEdit:()=>{},onCancel:()=>{},onRemove:()=>{},onStop:()=>N({type:"stop",item:L}),onRequeue:()=>{},onStart:()=>{},timeFormat:K,hasPermission:r,canModify:s,printerState:L.printer_id?se[L.printer_id]:null,t},L.id))})]}),Fe.length>0&&a.jsxs("div",{children:[a.jsxs("div",{className:"flex items-center justify-between mb-4",children:[a.jsxs("h2",{className:"text-lg font-semibold text-white flex items-center gap-2",children:[a.jsx(Wn,{className:"w-5 h-5 text-yellow-400"}),t("queue.sections.queued"),a.jsxs("span",{className:"text-sm font-normal text-bambu-gray",children:["(",t("queue.itemCount",{count:Fe.length}),")"]}),a.jsx("span",{className:"text-xs text-bambu-gray ml-2",title:t("queue.reorderHint"),children:t("queue.dragToReorder")})]}),a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsxs("select",{className:"px-3 py-1.5 text-sm bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",value:O,onChange:L=>B(L.target.value),children:[a.jsx("option",{value:"position",children:t("queue.sort.byPosition")}),a.jsx("option",{value:"name",children:t("queue.sort.byName")}),a.jsx("option",{value:"printer",children:t("queue.sort.byPrinter")}),a.jsx("option",{value:"time",children:t("queue.sort.bySchedule")})]}),a.jsx(Ce,{variant:"ghost",size:"sm",onClick:()=>G(!R),title:t(R?"common.ascending":"common.descending"),className:"px-2",children:R?a.jsx(Pf,{className:"w-4 h-4"}):a.jsx(hb,{className:"w-4 h-4"})})]})]}),a.jsxs("div",{className:"flex items-center gap-3 mb-4 p-3 bg-bambu-dark rounded-lg",children:[a.jsxs(Ce,{variant:"ghost",size:"sm",onClick:V,className:"flex items-center gap-2",children:[A.length===Fe.length&&Fe.length>0?a.jsx(oo,{className:"w-4 h-4 text-bambu-green"}):a.jsx(bl,{className:"w-4 h-4"}),A.length===Fe.length&&Fe.length>0?t("queue.bulkEdit.deselectAll"):t("queue.bulkEdit.selectAll")]}),A.length>0&&a.jsxs(a.Fragment,{children:[a.jsx("span",{className:"text-sm text-bambu-gray",children:t("queue.bulkEdit.selected",{count:A.length})}),a.jsx("div",{className:"h-4 w-px bg-bambu-dark-tertiary"}),a.jsxs(Ce,{variant:"ghost",size:"sm",onClick:()=>k(!0),className:"flex items-center gap-2 text-bambu-green hover:text-bambu-green-light",disabled:!i("queue:update_own","queue:update_all"),title:i("queue:update_own","queue:update_all")?void 0:t("queue.permissions.noEditItems"),children:[a.jsx(Vi,{className:"w-4 h-4"}),t("queue.bulkEdit.editSelected")]}),a.jsxs(Ce,{variant:"ghost",size:"sm",onClick:()=>de.mutate(A),className:"flex items-center gap-2 text-red-400 hover:text-red-300",disabled:de.isPending||!i("queue:delete_own","queue:delete_all"),title:i("queue:delete_own","queue:delete_all")?void 0:t("queue.permissions.noCancelItems"),children:[a.jsx(Ft,{className:"w-4 h-4"}),t("queue.bulkEdit.cancelSelected")]})]})]}),a.jsx(Fae,{sensors:q,collisionDetection:_ae,onDragEnd:fe,children:a.jsx(Iae,{items:Fe.map(L=>L.id),strategy:mQe,children:a.jsx("div",{className:"space-y-3",children:Fe.map((L,D)=>a.jsx(Uj,{item:L,position:D+1,onEdit:()=>y(L),onCancel:()=>N({type:"cancel",item:L}),onRemove:()=>{},onStop:()=>{},onRequeue:()=>{},onStart:()=>_e.mutate(L.id),timeFormat:K,isSelected:A.includes(L.id),onToggleSelect:()=>ce(L.id),hasPermission:r,canModify:s,t},L.id))})})})]}),Z.length>0&&a.jsxs("div",{children:[a.jsxs("div",{className:"flex items-center justify-between mb-4",children:[a.jsxs("h2",{className:"text-lg font-semibold text-white flex items-center gap-2",children:[a.jsx(gr,{className:"w-5 h-5 text-bambu-gray"}),t("queue.sections.history"),a.jsxs("span",{className:"text-sm font-normal text-bambu-gray",children:["(",t("queue.itemCount",{count:Z.length}),")"]})]}),a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsxs("select",{className:"px-3 py-1.5 text-sm bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",value:j,onChange:L=>E(L.target.value),children:[a.jsx("option",{value:"date",children:t("queue.sort.byDate")}),a.jsx("option",{value:"name",children:t("queue.sort.byName")}),a.jsx("option",{value:"printer",children:t("queue.sort.byPrinter")})]}),a.jsx(Ce,{variant:"ghost",size:"sm",onClick:()=>U(!P),title:t(P?"queue.sort.ascendingOldest":"queue.sort.descendingNewest"),className:"px-2",children:P?a.jsx(Pf,{className:"w-4 h-4"}):a.jsx(hb,{className:"w-4 h-4"})})]})]}),a.jsx("div",{className:"space-y-3",children:Z.slice(0,20).map((L,D)=>a.jsx(Uj,{item:L,position:D+1,onEdit:()=>{},onCancel:()=>{},onRemove:()=>N({type:"remove",item:L}),onStop:()=>{},onRequeue:()=>v(L),onStart:()=>{},timeFormat:K,hasPermission:r,canModify:s,t},L.id))})]})]}),x&&a.jsx(Qu,{mode:"edit-queue-item",archiveId:x.archive_id??void 0,libraryFileId:x.library_file_id??void 0,archiveName:x.archive_name||x.library_file_name||`File #${x.archive_id||x.library_file_id}`,queueItem:x,onClose:()=>y(null)}),b&&a.jsx(Qu,{mode:"add-to-queue",archiveId:b.archive_id??void 0,libraryFileId:b.library_file_id??void 0,archiveName:b.archive_name||b.library_file_name||`File #${b.archive_id||b.library_file_id}`,onClose:()=>v(null)}),S&&a.jsx(vn,{title:S.type==="cancel"?t("queue.confirm.cancelTitle"):S.type==="stop"?t("queue.confirm.stopTitle"):t("queue.confirm.removeTitle"),message:S.type==="cancel"?t("queue.confirm.cancelMessage",{name:S.item.archive_name||S.item.library_file_name||t("queue.confirm.thisPrint")}):S.type==="stop"?t("queue.confirm.stopMessage",{name:S.item.archive_name||S.item.library_file_name||t("queue.confirm.thisPrint")}):t("queue.confirm.removeMessage",{name:S.item.archive_name||S.item.library_file_name||t("queue.confirm.thisItem")}),confirmText:S.type==="cancel"?t("queue.confirm.cancelButton"):S.type==="stop"?t("queue.confirm.stopButton"):t("common.remove"),variant:"danger",onConfirm:()=>{S.type==="cancel"?X.mutate(S.item.id):S.type==="stop"?J.mutate(S.item.id):ee.mutate(S.item.id),N(null)},onCancel:()=>N(null)}),f&&a.jsx(vn,{title:t("queue.confirm.clearHistoryTitle"),message:t("queue.confirm.clearHistoryMessage",{count:Z.length}),confirmText:t("queue.clearHistory"),variant:"danger",onConfirm:()=>{me.mutate(),p(!1)},onCancel:()=>p(!1)}),T&&a.jsx(CQe,{selectedCount:A.length,printers:$?.map(L=>({id:L.id,name:L.name}))||[],onSave:L=>{Object.keys(L).length>0&&je.mutate({item_ids:A,...L})},onClose:()=>k(!1),isSaving:je.isPending,t})]})}function AQe({printDates:t,months:e=3}){const n=w.useRef(null),[r,i]=w.useState(0);w.useEffect(()=>{const S=n.current;if(!S)return;const N=new ResizeObserver(A=>{const C=A[0]?.contentRect.width||0;i(C)});return N.observe(S),()=>N.disconnect()},[]);const{weeks:s,monthLabels:o,printCounts:l}=w.useMemo(()=>{const S={};t.forEach(U=>{const O=U.split("T")[0];S[O]=(S[O]||0)+1});const N=new Date,A=new Date(N);A.setMonth(A.getMonth()-e),A.setDate(A.getDate()-A.getDay());const C=[],T=[];let k=[],j=-1;const E=new Date(A);let P=0;for(;E<=N;)E.getDay()===0&&k.length>0&&(C.push(k),k=[],P++),E.getMonth()!==j&&(T.push({month:E.toLocaleDateString("en-US",{month:"short"}),weekIndex:P}),j=E.getMonth()),k.push(new Date(E)),E.setDate(E.getDate()+1);return k.length>0&&C.push(k),{weeks:C,monthLabels:T,printCounts:S}},[t,e]),c=Math.max(1,...Object.values(l)),u=S=>{if(S===0)return"bg-bambu-dark";const N=S/c;return N<=.25?"bg-bambu-green/30":N<=.5?"bg-bambu-green/50":N<=.75?"bg-bambu-green/75":"bg-bambu-green"},d=["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],h=s.length,f=32,p=2,x=r-f-16,y=h>0?Math.floor((x-(h-1)*p)/h):12,b=Math.max(8,Math.min(20,y)),v=b<=10?10:12;return a.jsx("div",{ref:n,className:"w-full flex justify-center",children:r>0&&a.jsxs("div",{children:[a.jsx("div",{className:"flex mb-1",style:{marginLeft:f+4},children:o.map(({month:S,weekIndex:N},A)=>a.jsx("div",{className:"text-bambu-gray",style:{fontSize:v,marginLeft:A===0?0:`${(N-(o[A-1]?.weekIndex||0))*(b+p)-24}px`},children:S},A))}),a.jsxs("div",{className:"flex",style:{gap:p},children:[a.jsx("div",{className:"flex flex-col",style:{gap:p,marginRight:4,width:f},children:d.map((S,N)=>a.jsx("div",{className:"text-bambu-gray flex items-center",style:{width:f,height:b,fontSize:v,visibility:N%2===1?"visible":"hidden"},children:S},S))}),s.map((S,N)=>a.jsx("div",{className:"flex flex-col",style:{gap:p},children:[0,1,2,3,4,5,6].map(A=>{const C=S.find(E=>E.getDay()===A);if(!C)return a.jsx("div",{style:{width:b,height:b}},A);const T=C.toISOString().split("T")[0],k=l[T]||0,j=T===new Date().toISOString().split("T")[0];return a.jsx("div",{className:`rounded-sm ${u(k)} ${j?"ring-1 ring-white":""}`,style:{width:b,height:b},title:`${C.toLocaleDateString()}: ${k} print${k!==1?"s":""}`},A)})},N))]}),a.jsxs("div",{className:"flex items-center gap-2 mt-3 text-bambu-gray",style:{fontSize:v},children:[a.jsx("span",{children:"Less"}),a.jsxs("div",{className:"flex",style:{gap:p},children:[a.jsx("div",{className:"rounded-sm bg-bambu-dark",style:{width:b,height:b}}),a.jsx("div",{className:"rounded-sm bg-bambu-green/30",style:{width:b,height:b}}),a.jsx("div",{className:"rounded-sm bg-bambu-green/50",style:{width:b,height:b}}),a.jsx("div",{className:"rounded-sm bg-bambu-green/75",style:{width:b,height:b}}),a.jsx("div",{className:"rounded-sm bg-bambu-green",style:{width:b,height:b}})]}),a.jsx("span",{children:"More"})]})]})})}const WS=["#00ae42","#3b82f6","#f59e0b","#ef4444","#8b5cf6","#ec4899","#14b8a6","#f97316"];function TQe(t){const e=new Date;switch(t){case"7d":return new Date(e.getTime()-10080*60*1e3);case"30d":return new Date(e.getTime()-720*60*60*1e3);case"90d":return new Date(e.getTime()-2160*60*60*1e3);case"365d":return new Date(e.getTime()-365*24*60*60*1e3);case"all":return new Date(0)}}function EQe({archives:t,currency:e="$"}){const[n,r]=w.useState("30d"),i=w.useMemo(()=>{const p=TQe(n);return t.filter(x=>(Zi(x.completed_at||x.created_at)||new Date(0))>=p)},[t,n]),s=w.useMemo(()=>{const p=new Map;return i.forEach(x=>{const y=Zi(x.completed_at||x.created_at)||new Date,b=`${y.getFullYear()}-${String(y.getMonth()+1).padStart(2,"0")}-${String(y.getDate()).padStart(2,"0")}`,v=p.get(b)||{date:b,filament:0,cost:0,prints:0};v.filament+=x.filament_used_grams||0,v.cost+=x.cost||0,v.prints+=x.quantity||1,p.set(b,v)}),Array.from(p.values()).sort((x,y)=>x.date.localeCompare(y.date)).map(x=>({...x,dateLabel:new Date(x.date).toLocaleDateString("en-US",{month:"short",day:"numeric"})}))},[i]),o=w.useMemo(()=>{if(n==="7d"||n==="30d")return s;const p=new Map;return i.forEach(x=>{const y=Zi(x.completed_at||x.created_at)||new Date,b=new Date(y);b.setDate(y.getDate()-y.getDay());const v=`${b.getFullYear()}-${String(b.getMonth()+1).padStart(2,"0")}-${String(b.getDate()).padStart(2,"0")}`,S=p.get(v)||{week:v,filament:0,cost:0,prints:0};S.filament+=x.filament_used_grams||0,S.cost+=x.cost||0,S.prints+=x.quantity||1,p.set(v,S)}),Array.from(p.values()).sort((x,y)=>x.week.localeCompare(y.week)).map(x=>({date:x.week,dateLabel:`Week of ${new Date(x.week).toLocaleDateString("en-US",{month:"short",day:"numeric"})}`,...x}))},[i,s,n]),l=w.useMemo(()=>{const p=new Map;return i.forEach(x=>{const b=(x.filament_type||"Unknown").split(", ");b.forEach(v=>{const S=(x.filament_used_grams||0)/b.length;p.set(v,(p.get(v)||0)+S)})}),Array.from(p.entries()).map(([x,y])=>({name:x,value:Math.round(y)})).sort((x,y)=>y.value-x.value)},[i]),c=w.useMemo(()=>{const p=new Date,x=[];for(let y=5;y>=0;y--){const b=new Date(p.getFullYear(),p.getMonth()-y,1),v=new Date(p.getFullYear(),p.getMonth()-y+1,0),S=b.toLocaleDateString("en-US",{month:"short",year:"2-digit"}),N=t.filter(A=>{const C=Zi(A.completed_at||A.created_at)||new Date(0);return C>=b&&C<=v});x.push({month:S,filament:Math.round(N.reduce((A,C)=>A+(C.filament_used_grams||0),0)),cost:N.reduce((A,C)=>A+(C.cost||0),0),prints:N.reduce((A,C)=>A+(C.quantity||1),0)})}return x},[t]),u=n==="7d"||n==="30d"?s:o,d=i.reduce((p,x)=>p+(x.filament_used_grams||0),0),h=i.reduce((p,x)=>p+(x.cost||0),0),f=i.reduce((p,x)=>p+(x.quantity||1),0);return a.jsxs("div",{className:"space-y-6",children:[a.jsxs("div",{className:"flex items-center justify-between max-[550px]:flex-col max-[550px]:items-start max-[550px]:gap-2",children:[a.jsx("h3",{className:"text-lg font-semibold text-white",children:"Filament Usage Trends"}),a.jsx("div",{className:"flex gap-1 bg-bambu-dark rounded-lg p-1",children:["7d","30d","90d","365d","all"].map(p=>a.jsx("button",{onClick:()=>r(p),className:`px-3 py-1 text-sm rounded-md transition-colors ${n===p?"bg-bambu-green text-white":"text-bambu-gray hover:text-white"}`,children:p==="all"?"All":p.replace("d","D")},p))})]}),a.jsxs("div",{className:"grid grid-cols-3 gap-4 max-[640px]:grid-cols-1",children:[a.jsxs("div",{className:"bg-bambu-dark rounded-lg p-4",children:[a.jsxs("div",{className:"flex items-center justify-between gap-3",children:[a.jsx("p",{className:"text-sm text-bambu-gray leading-none",children:"Period Filament"}),a.jsxs("p",{className:"text-2xl font-bold text-white leading-none",children:[(d/1e3).toFixed(2),"kg"]})]}),a.jsxs("p",{className:"text-xs text-bambu-gray",children:[d.toFixed(0),"g total"]})]}),a.jsxs("div",{className:"bg-bambu-dark rounded-lg p-4",children:[a.jsxs("div",{className:"flex items-center justify-between gap-3",children:[a.jsx("p",{className:"text-sm text-bambu-gray leading-none",children:"Period Cost"}),a.jsxs("p",{className:"text-2xl font-bold text-white leading-none",children:[e,h.toFixed(2)]})]}),a.jsxs("p",{className:"text-xs text-bambu-gray",children:[f," prints"]})]}),a.jsxs("div",{className:"bg-bambu-dark rounded-lg p-4",children:[a.jsxs("div",{className:"flex items-center justify-between gap-3",children:[a.jsx("p",{className:"text-sm text-bambu-gray leading-none",children:"Avg per Print"}),a.jsxs("p",{className:"text-2xl font-bold text-white leading-none",children:[f>0?(d/f).toFixed(0):0,"g"]})]}),a.jsxs("p",{className:"text-xs text-bambu-gray",children:[e,f>0?(h/f).toFixed(2):"0.00"," avg"]})]})]}),u.length>0?a.jsxs("div",{className:"bg-bambu-dark rounded-lg p-4",children:[a.jsx("h4",{className:"text-sm font-medium text-bambu-gray mb-4",children:"Usage Over Time"}),a.jsx(h1,{width:"100%",height:250,children:a.jsxs(kHe,{data:u,children:[a.jsx("defs",{children:a.jsxs("linearGradient",{id:"colorFilament",x1:"0",y1:"0",x2:"0",y2:"1",children:[a.jsx("stop",{offset:"5%",stopColor:"#00ae42",stopOpacity:.3}),a.jsx("stop",{offset:"95%",stopColor:"#00ae42",stopOpacity:0})]})}),a.jsx(BN,{strokeDasharray:"3 3",stroke:"#3d3d3d"}),a.jsx(GN,{dataKey:"dateLabel",stroke:"#9ca3af",tick:{fontSize:12},interval:"preserveStartEnd"}),a.jsx(qN,{stroke:"#9ca3af",tick:{fontSize:12},tickFormatter:p=>`${p}g`}),a.jsx(f1,{contentStyle:{backgroundColor:"#2d2d2d",border:"1px solid #3d3d3d",borderRadius:"8px"},labelStyle:{color:"#fff"},formatter:p=>[`${Number(p??0).toFixed(0)}g`,"Filament"]}),a.jsx(Vte,{type:"monotone",dataKey:"filament",stroke:"#00ae42",strokeWidth:2,fillOpacity:1,fill:"url(#colorFilament)"})]})})]}):a.jsx("div",{className:"bg-bambu-dark rounded-lg p-8 text-center text-bambu-gray",children:"No data for selected time range"}),a.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-6",children:[a.jsxs("div",{className:"bg-bambu-dark rounded-lg p-4",children:[a.jsx("h4",{className:"text-sm font-medium text-bambu-gray mb-4",children:"By Filament Type"}),l.length>0?a.jsxs("div",{className:"flex items-center gap-4",children:[a.jsx(h1,{width:160,height:160,children:a.jsxs(SHe,{children:[a.jsx(gte,{data:l,cx:"50%",cy:"50%",innerRadius:40,outerRadius:70,paddingAngle:2,dataKey:"value",children:l.map((p,x)=>a.jsx(Vv,{fill:WS[x%WS.length]},`cell-${x}`))}),a.jsx(f1,{contentStyle:{backgroundColor:"#2d2d2d",border:"1px solid #3d3d3d",borderRadius:"8px"},formatter:p=>[`${p??0}g`,"Usage"]})]})}),a.jsx("div",{className:"flex-1 space-y-2 overflow-hidden",children:l.map((p,x)=>{const y=l.reduce((v,S)=>v+S.value,0),b=y>0?(p.value/y*100).toFixed(0):0;return a.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[a.jsx("div",{className:"w-3 h-3 rounded-sm flex-shrink-0",style:{backgroundColor:WS[x%WS.length]}}),a.jsx("span",{className:"text-white truncate flex-1",children:p.name}),a.jsxs("span",{className:"text-bambu-gray flex-shrink-0",children:[b,"%"]})]},p.name)})})]}):a.jsx("div",{className:"h-[160px] flex items-center justify-center text-bambu-gray",children:"No filament data"})]}),a.jsxs("div",{className:"bg-bambu-dark rounded-lg p-4",children:[a.jsx("h4",{className:"text-sm font-medium text-bambu-gray mb-4",children:"Monthly Comparison"}),a.jsx(h1,{width:"100%",height:200,children:a.jsxs(dHe,{data:c,children:[a.jsx(BN,{strokeDasharray:"3 3",stroke:"#3d3d3d"}),a.jsx(GN,{dataKey:"month",stroke:"#9ca3af",tick:{fontSize:12}}),a.jsx(qN,{stroke:"#9ca3af",tick:{fontSize:12},tickFormatter:p=>`${p}g`}),a.jsx(f1,{contentStyle:{backgroundColor:"#2d2d2d",border:"1px solid #3d3d3d",borderRadius:"8px"},formatter:(p,x)=>[x==="filament"?`${p??0}g`:x==="cost"?`${e}${Number(p??0).toFixed(2)}`:p??0,x==="filament"?"Filament":x==="cost"?"Cost":"Prints"]}),a.jsx(WL,{}),a.jsx(Xte,{dataKey:"filament",name:"Filament (g)",fill:"#00ae42",radius:[4,4,0,0]})]})})]})]})]})}function PQe({id:t,title:e,component:n,isHidden:r,size:i,columnSpan:s,onToggleVisibility:o,onToggleSize:l}){const{attributes:c,listeners:u,setNodeRef:d,transform:h,transition:f,isDragging:p}=Uae({id:t}),x={transform:Ub.Transform.toString(h),transition:f,opacity:p?.5:1};return r?null:a.jsxs("div",{ref:d,style:{...x,gridColumn:`span ${s}`},className:`bg-bambu-dark-secondary rounded-xl border border-bambu-dark-tertiary overflow-hidden ${p?"ring-2 ring-bambu-green shadow-lg":""}`,children:[a.jsxs("div",{className:"flex items-center justify-between px-4 py-3 border-b border-bambu-dark-tertiary bg-bambu-dark/30",children:[a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx("button",{...c,...u,className:"cursor-grab active:cursor-grabbing p-1 hover:bg-bambu-dark-tertiary rounded transition-colors",title:"Drag to reorder",children:a.jsx(Dh,{className:"w-6 h-6 md:w-4 md:h-4 text-bambu-gray"})}),a.jsx("h3",{className:"text-sm font-medium text-white",children:e})]}),a.jsxs("div",{className:"flex items-center gap-1",children:[a.jsx("button",{onClick:l,className:"p-1 hover:bg-bambu-dark-tertiary rounded transition-colors",title:`Size: ${i===1?"1/4":i===2?"1/2":"Full"} - Click to cycle`,children:i===4?a.jsx(LF,{className:"w-4 h-4 text-bambu-gray hover:text-white"}):a.jsx(iC,{className:"w-4 h-4 text-bambu-gray hover:text-white"})}),a.jsx("button",{onClick:o,className:"p-1 hover:bg-bambu-dark-tertiary rounded transition-colors",title:"Hide widget",children:a.jsx(gv,{className:"w-4 h-4 text-bambu-gray hover:text-white"})})]})]}),a.jsx("div",{className:"p-4",children:typeof n=="function"?n(i):n})]})}function jQe({widgets:t,storageKey:e,columns:n=4,stackBelow:r,hideControls:i=!1,onResetLayout:s,renderControls:o}){const l=()=>{const j={};return t.forEach(E=>{j[E.id]=E.defaultSize||4}),j},[c,u]=w.useState(()=>{const j=localStorage.getItem(e);if(j)try{const E=JSON.parse(j);return E.sizes||(E.sizes=l()),E}catch{}return{order:t.map(E=>E.id),hidden:t.filter(E=>E.defaultVisible===!1).map(E=>E.id),sizes:l()}}),[d,h]=w.useState(!1),[f,p]=w.useState(!1);w.useEffect(()=>{if(!r)return;const j=window.matchMedia(`(max-width: ${r}px)`),E=U=>{p(U.matches)};E(j);const P=U=>E(U);return j.addEventListener?j.addEventListener("change",P):j.addListener(P),()=>{j.removeEventListener?j.removeEventListener("change",P):j.removeListener(P)}},[r]);const x=r&&f?1:n;w.useEffect(()=>{const j=()=>h(E=>!E);return window.addEventListener("toggle-hidden-panel",j),()=>window.removeEventListener("toggle-hidden-panel",j)},[]),w.useEffect(()=>{localStorage.setItem(e,JSON.stringify(c))},[c,e]),w.useEffect(()=>{const E=t.map(P=>P.id).filter(P=>!c.order.includes(P));E.length>0&&u(P=>({...P,order:[...P.order,...E]}))},[t,c.order]);const y=xae(Vk(OM,{activationConstraint:{distance:8}}),Vk(LM,{coordinateGetter:Bae})),b=j=>{const{active:E,over:P}=j;P&&E.id!==P.id&&u(U=>{const O=U.order.indexOf(E.id),B=U.order.indexOf(P.id);return{...U,order:UM(U.order,O,B)}})},v=j=>{u(E=>({...E,hidden:E.hidden.includes(j)?E.hidden.filter(P=>P!==j):[...E.hidden,j]}))},S=j=>{u(E=>{const P=E.sizes[j]||4,U=P===1?2:P===2?4:1;return{...E,sizes:{...E.sizes,[j]:U}}})},N=()=>{const j={order:t.map(E=>E.id),hidden:t.filter(E=>E.defaultVisible===!1).map(E=>E.id),sizes:l()};u(j),s?.()},A=c.order.map(j=>t.find(E=>E.id===j)).filter(Boolean),C=A.filter(j=>!c.hidden.includes(j.id)),T=A.filter(j=>c.hidden.includes(j.id)),k=o?.({hiddenCount:T.length,showHiddenPanel:d,setShowHiddenPanel:h,resetLayout:N});return a.jsxs("div",{className:"space-y-4",children:[k,!i&&!o&&a.jsxs("div",{className:"flex items-center justify-end gap-2",children:[a.jsxs(Ce,{variant:"secondary",size:"sm",onClick:N,children:[a.jsx(Ro,{className:"w-4 h-4"}),"Reset Layout"]}),T.length>0&&a.jsxs(Ce,{variant:"secondary",size:"sm",onClick:()=>h(!d),children:[a.jsx(Xl,{className:"w-4 h-4"}),T.length," Hidden"]})]}),d&&T.length>0&&a.jsxs("div",{className:"p-4 bg-bambu-dark rounded-xl border border-bambu-dark-tertiary",children:[a.jsx("p",{className:"text-sm text-bambu-gray mb-3",children:"Hidden widgets (click to show):"}),a.jsx("div",{className:"flex flex-wrap gap-2",children:T.map(j=>a.jsxs("button",{onClick:()=>v(j.id),className:"px-3 py-1.5 bg-bambu-dark-tertiary hover:bg-bambu-green/20 rounded-lg text-sm text-white transition-colors flex items-center gap-2",children:[a.jsx(Xl,{className:"w-3 h-3"}),j.title]},j.id))})]}),a.jsx(Fae,{sensors:y,collisionDetection:_ae,onDragEnd:b,children:a.jsx(Iae,{items:C.map(j=>j.id),strategy:bI,children:a.jsx("div",{className:"grid gap-6",style:{gridTemplateColumns:`repeat(${x}, minmax(0, 1fr))`},children:C.map(j=>{const E=c.sizes[j.id]||2,P=Math.min(E,x);return a.jsx(PQe,{id:j.id,title:j.title,component:j.component,isHidden:c.hidden.includes(j.id),size:E,columnSpan:P,onToggleVisibility:()=>v(j.id),onToggleSize:()=>S(j.id)},j.id)})})})}),C.length===0&&a.jsxs("div",{className:"text-center py-12 text-bambu-gray",children:[a.jsx("p",{children:"All widgets are hidden."}),a.jsx(Ce,{className:"mt-4",onClick:N,children:"Reset Layout"})]})]})}const DQe={USD:"$",EUR:"€",GBP:"£",CHF:"Fr.",JPY:"¥",CNY:"¥",CAD:"$",AUD:"$",INR:"₹",HKD:"HK$",KRW:"₩",SEK:"kr",NOK:"kr",DKK:"kr",PLN:"zł",BRL:"R$",TWD:"NT$",SGD:"S$",NZD:"NZ$",MXN:"MX$",CZK:"Kč",THB:"฿",ZAR:"R",TRY:"₺",RUB:"₽"};function ju(t){return DQe[t.toUpperCase()]||t}const RQe=[{code:"USD",label:"USD ($)"},{code:"EUR",label:"EUR (€)"},{code:"GBP",label:"GBP (£)"},{code:"CHF",label:"CHF (Fr.)"},{code:"JPY",label:"JPY (¥)"},{code:"CNY",label:"CNY (¥)"},{code:"CAD",label:"CAD ($)"},{code:"AUD",label:"AUD ($)"},{code:"INR",label:"INR (₹)"},{code:"HKD",label:"HKD (HK$)"},{code:"KRW",label:"KRW (₩)"},{code:"SEK",label:"SEK (kr)"},{code:"NOK",label:"NOK (kr)"},{code:"DKK",label:"DKK (kr)"},{code:"PLN",label:"PLN (zł)"},{code:"BRL",label:"BRL (R$)"},{code:"TWD",label:"TWD (NT$)"},{code:"SGD",label:"SGD (S$)"},{code:"NZD",label:"NZD (NZ$)"},{code:"MXN",label:"MXN (MX$)"},{code:"CZK",label:"CZK (Kč)"},{code:"THB",label:"THB (฿)"},{code:"ZAR",label:"ZAR (R)"},{code:"TRY",label:"TRY (₺)"},{code:"RUB",label:"RUB (₽)"}];function FQe({stats:t,currency:e,t:n}){return a.jsxs("div",{className:"grid grid-cols-2 sm:grid-cols-3 gap-4",children:[a.jsxs("div",{className:"flex items-start gap-3",children:[a.jsx("div",{className:"p-2 rounded-lg bg-bambu-dark text-bambu-green",children:a.jsx(fa,{className:"w-5 h-5"})}),a.jsxs("div",{children:[a.jsx("p",{className:"text-xs text-bambu-gray",children:n("stats.totalPrints")}),a.jsx("p",{className:"text-xl font-bold text-white",children:t?.total_prints||0})]})]}),a.jsxs("div",{className:"flex items-start gap-3",children:[a.jsx("div",{className:"p-2 rounded-lg bg-bambu-dark text-blue-400",children:a.jsx(Wn,{className:"w-5 h-5"})}),a.jsxs("div",{children:[a.jsx("p",{className:"text-xs text-bambu-gray",children:n("stats.printTime")}),a.jsxs("p",{className:"text-xl font-bold text-white",children:[t?.total_print_time_hours.toFixed(1)||0,"h"]})]})]}),a.jsxs("div",{className:"flex items-start gap-3",children:[a.jsx("div",{className:"p-2 rounded-lg bg-bambu-dark text-orange-400",children:a.jsx(fa,{className:"w-5 h-5"})}),a.jsxs("div",{children:[a.jsx("p",{className:"text-xs text-bambu-gray",children:n("stats.filamentUsed")}),a.jsxs("p",{className:"text-xl font-bold text-white",children:[((t?.total_filament_grams||0)/1e3).toFixed(2),"kg"]})]})]}),a.jsxs("div",{className:"flex items-start gap-3",children:[a.jsx("div",{className:"p-2 rounded-lg bg-bambu-dark text-green-400",children:a.jsx(f3,{className:"w-5 h-5"})}),a.jsxs("div",{children:[a.jsx("p",{className:"text-xs text-bambu-gray",children:n("stats.filamentCost")}),a.jsxs("p",{className:"text-xl font-bold text-white",children:[e," ",t?.total_cost.toFixed(2)||"0.00"]})]})]}),a.jsxs("div",{className:"flex items-start gap-3",children:[a.jsx("div",{className:"p-2 rounded-lg bg-bambu-dark text-yellow-400",children:a.jsx(Wh,{className:"w-5 h-5"})}),a.jsxs("div",{children:[a.jsx("p",{className:"text-xs text-bambu-gray",children:n("stats.energyUsed")}),a.jsxs("p",{className:"text-xl font-bold text-white",children:[t?.total_energy_kwh.toFixed(2)||"0.00"," kWh"]})]})]}),a.jsxs("div",{className:"flex items-start gap-3",children:[a.jsx("div",{className:"p-2 rounded-lg bg-bambu-dark text-yellow-500",children:a.jsx(f3,{className:"w-5 h-5"})}),a.jsxs("div",{children:[a.jsx("p",{className:"text-xs text-bambu-gray",children:n("stats.energyCost")}),a.jsxs("p",{className:"text-xl font-bold text-white",children:[e," ",t?.total_energy_cost.toFixed(2)||"0.00"]})]})]})]})}function LQe({stats:t,printerMap:e,size:n=1,t:r}){const i=t?.total_prints?Math.round(t.successful_prints/t.total_prints*100):0,s=n===1?112:n===2?128:144,o=s/2-8,l=o*2*Math.PI;return a.jsxs("div",{className:"flex items-center gap-6",children:[a.jsxs("div",{className:"relative flex-shrink-0",style:{width:s,height:s},children:[a.jsxs("svg",{className:"w-full h-full -rotate-90",children:[a.jsx("circle",{cx:s/2,cy:s/2,r:o,fill:"none",stroke:"#3d3d3d",strokeWidth:"10"}),a.jsx("circle",{cx:s/2,cy:s/2,r:o,fill:"none",stroke:"#00ae42",strokeWidth:"10",strokeLinecap:"round",strokeDasharray:`${i/100*l} ${l}`})]}),a.jsx("div",{className:"absolute inset-0 flex items-center justify-center",children:a.jsxs("span",{className:`font-bold text-white ${n>=2?"text-2xl":"text-xl"}`,children:[i,"%"]})})]}),a.jsxs("div",{className:"flex-1 min-w-0",children:[a.jsxs("div",{className:"space-y-2",children:[a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx(gr,{className:"w-4 h-4 text-status-ok flex-shrink-0"}),a.jsx("span",{className:"text-sm text-bambu-gray",children:r("stats.successful")}),a.jsx("span",{className:"text-sm text-white font-medium",children:t?.successful_prints||0})]}),a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx(ha,{className:"w-4 h-4 text-status-error flex-shrink-0"}),a.jsx("span",{className:"text-sm text-bambu-gray",children:r("stats.failed")}),a.jsx("span",{className:"text-sm text-white font-medium",children:t?.failed_prints||0})]})]}),n>=2&&t?.prints_by_printer&&Object.keys(t.prints_by_printer).length>0&&a.jsxs("div",{className:"mt-4 pt-4 border-t border-bambu-dark-tertiary",children:[a.jsx("p",{className:"text-xs text-bambu-gray font-medium mb-2",children:r("stats.printsByPrinter")}),a.jsx("div",{className:`grid gap-x-6 gap-y-1 ${n===4?"grid-cols-3":"grid-cols-2"}`,style:{width:"fit-content"},children:Object.entries(t.prints_by_printer).map(([c,u])=>a.jsxs("div",{className:"flex items-center gap-3 text-sm",children:[a.jsx("span",{className:"text-bambu-gray truncate max-w-[120px]",children:e.get(c)||`${r("common.printer")} ${c}`}),a.jsx("span",{className:"text-white font-medium",children:u})]},c))})]})]})]})}function OQe({stats:t,printerMap:e,size:n=1,t:r}){const i=t?.average_time_accuracy;if(i==null)return a.jsx("div",{className:"flex items-center justify-center h-full",children:a.jsx("p",{className:"text-bambu-gray text-center py-4",children:r("stats.noTimeAccuracyData")})});const o=(Math.min(150,Math.max(50,i))-50)/100*100,c=(y=>y>=95&&y<=105?"#00ae42":y>105?"#3b82f6":"#f97316")(i),u=i-100,d=n===1?112:n===2?128:144,h=d/2-8,f=h*2*Math.PI,p=n===1?3:n===2?6:999,x=t?.time_accuracy_by_printer?Object.entries(t.time_accuracy_by_printer).slice(0,p):[];return a.jsxs("div",{className:"flex items-center gap-6",children:[a.jsxs("div",{className:"relative flex-shrink-0",style:{width:d,height:d},children:[a.jsxs("svg",{className:"w-full h-full -rotate-90",children:[a.jsx("circle",{cx:d/2,cy:d/2,r:h,fill:"none",stroke:"#3d3d3d",strokeWidth:"10"}),a.jsx("circle",{cx:d/2,cy:d/2,r:h,fill:"none",stroke:c,strokeWidth:"10",strokeLinecap:"round",strokeDasharray:`${o/100*f} ${f}`})]}),a.jsxs("div",{className:"absolute inset-0 flex flex-col items-center justify-center",children:[a.jsxs("span",{className:`font-bold text-white ${n>=2?"text-2xl":"text-xl"}`,children:[i.toFixed(0),"%"]}),a.jsxs("span",{className:`text-xs ${u>=0?"text-blue-400":"text-orange-400"}`,children:[u>=0?"+":"",u.toFixed(0),"%"]})]})]}),a.jsxs("div",{className:"flex-1 min-w-0",children:[a.jsxs("div",{className:"flex items-center gap-2 text-xs text-bambu-gray",children:[a.jsx(vX,{className:"w-3 h-3 flex-shrink-0"}),a.jsx("span",{children:r("stats.perfectEstimate")})]}),x.length>0&&a.jsx("div",{className:`mt-2 ${n===4?"grid grid-cols-3 gap-x-6 gap-y-1":n===2?"grid grid-cols-2 gap-x-6 gap-y-1":"space-y-1"}`,style:{width:"fit-content"},children:x.map(([y,b])=>a.jsxs("div",{className:"flex items-center gap-2 text-xs",children:[a.jsx("span",{className:"text-bambu-gray truncate max-w-[100px]",children:e.get(y)||`${r("common.printer")} ${y}`}),a.jsxs("span",{className:`font-medium ${b>=95&&b<=105?"text-status-ok":b>105?"text-blue-400":"text-status-warning"}`,children:[b.toFixed(0),"%"]})]},y))})]})]})}function IQe({stats:t,size:e=1,t:n}){if(!t?.prints_by_filament_type||Object.keys(t.prints_by_filament_type).length===0)return a.jsx("p",{className:"text-bambu-gray text-center py-4",children:n("stats.noFilamentData")});const r=Object.entries(t.prints_by_filament_type).sort(([,l],[,c])=>c-l),i=e===1?5:e===2?8:999,s=r.slice(0,i),o=r.length>i;return e===4&&s.length>4?a.jsx("div",{className:"grid grid-cols-2 lg:grid-cols-3 gap-4",children:s.map(([l,c])=>{const u=Math.round(c/(t.total_prints||1)*100);return a.jsxs("div",{children:[a.jsxs("div",{className:"flex justify-between text-sm mb-1",children:[a.jsx("span",{className:"text-white truncate max-w-[120px]",children:l}),a.jsx("span",{className:"text-bambu-gray",children:c})]}),a.jsx("div",{className:"h-2 bg-bambu-dark rounded-full",children:a.jsx("div",{className:"h-full bg-bambu-green rounded-full transition-all",style:{width:`${u}%`}})})]},l)})}):a.jsxs("div",{className:"space-y-3",children:[s.map(([l,c])=>{const u=Math.round(c/(t.total_prints||1)*100);return a.jsxs("div",{children:[a.jsxs("div",{className:"flex justify-between text-sm mb-1",children:[a.jsx("span",{className:"text-white",children:l}),a.jsxs("span",{className:"text-bambu-gray",children:[c," ",n("common.prints")]})]}),a.jsx("div",{className:"h-2 bg-bambu-dark rounded-full",children:a.jsx("div",{className:"h-full bg-bambu-green rounded-full transition-all",style:{width:`${u}%`}})})]},l)}),o&&a.jsx("p",{className:"text-xs text-bambu-gray text-center pt-1",children:n("common.more",{count:r.length-i})})]})}function zQe({printDates:t,size:e=2}){const n=e===1?3:e===2?6:12;return a.jsx(AQe,{printDates:t,months:n})}function UQe({stats:t,printerMap:e,t:n}){return!t?.prints_by_printer||Object.keys(t.prints_by_printer).length===0?a.jsx("p",{className:"text-bambu-gray text-center py-4",children:n("stats.noPrinterData")}):a.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-3",children:Object.entries(t.prints_by_printer).map(([r,i])=>a.jsxs("div",{className:"flex items-center gap-3 p-3 bg-bambu-dark rounded-lg",children:[a.jsx("div",{className:"p-2 bg-bambu-dark-tertiary rounded-lg",children:a.jsx(Cr,{className:"w-4 h-4 text-bambu-green"})}),a.jsxs("div",{children:[a.jsx("p",{className:"text-white font-medium text-sm",children:e.get(r)||`${n("common.printer")} ${r}`}),a.jsxs("p",{className:"text-xs text-bambu-gray",children:[i," ",n("common.prints")]})]})]},r))})}function BQe({archives:t,currency:e,t:n}){return!t||t.length===0?a.jsx("p",{className:"text-bambu-gray text-center py-4",children:n("stats.noPrintData")}):a.jsx(EQe,{archives:t,currency:e})}function HQe({size:t=1,t:e}){const{data:n,isLoading:r}=Ze({queryKey:["failureAnalysis"],queryFn:()=>re.getFailureAnalysis({days:30})});if(r)return a.jsx("div",{className:"flex justify-center py-4",children:a.jsx(it,{className:"w-6 h-6 text-bambu-green animate-spin"})});if(!n||n.total_prints===0)return a.jsx("p",{className:"text-bambu-gray text-center py-4",children:e("stats.noPrintDataLast30Days")});const i=t===1?5:t===2?8:999,s=Object.entries(n.failures_by_reason).sort(([,c],[,u])=>u-c),o=s.slice(0,i),l=s.length>i;return a.jsxs("div",{className:`${t>=2?"flex gap-8":"space-y-4"}`,children:[a.jsxs("div",{className:t>=2?"flex-shrink-0":"",children:[a.jsx("div",{className:"flex items-center gap-4",children:a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx(Cn,{className:`w-5 h-5 ${n.failure_rate>20?"text-status-error":n.failure_rate>10?"text-status-warning":"text-status-ok"}`}),a.jsxs("span",{className:`font-bold text-white ${t>=2?"text-3xl":"text-2xl"}`,children:[n.failure_rate.toFixed(1),"%"]})]})}),a.jsx("div",{className:"text-sm text-bambu-gray mt-1",children:e("stats.failedPrintsCount",{failed:n.failed_prints,total:n.total_prints})}),n.trend&&n.trend.length>=2&&a.jsx("div",{className:`${t>=2?"mt-4":"mt-2 pt-2 border-t border-bambu-dark-tertiary"}`,children:a.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[a.jsx(zF,{className:`w-4 h-4 ${n.trend[n.trend.length-1].failure_rate0&&a.jsxs("div",{className:`flex-1 ${t>=2?"border-l border-bambu-dark-tertiary pl-8":"pt-2"}`,children:[a.jsx("p",{className:"text-xs text-bambu-gray font-medium mb-2",children:t>=2?e("stats.failureReasons"):e("stats.topFailureReasons")}),a.jsx("div",{className:`${t===4?"grid grid-cols-2 gap-x-6 gap-y-1":"space-y-1"}`,children:o.map(([c,u])=>a.jsxs("div",{className:"flex items-center justify-between text-sm",children:[a.jsx("span",{className:`text-white truncate ${t===4?"max-w-[200px]":"max-w-[160px]"}`,children:c||e("common.unknown")}),a.jsx("span",{className:"text-bambu-gray ml-2",children:u})]},c))}),l&&a.jsx("p",{className:"text-xs text-bambu-gray mt-2",children:e("common.more",{count:s.length-i})})]})]})}function $Qe(){const{t}=Vt(),{showToast:e}=hn(),{hasPermission:n}=Ir(),[r,i]=w.useState(!1),[s,o]=w.useState(!1),[l,c]=w.useState(0),[u,d]=w.useState(0),[h,f]=w.useState(!1);w.useEffect(()=>{const E=()=>{try{const U=localStorage.getItem("bambusy-dashboard-layout");if(U){const O=JSON.parse(U);d(O.hidden?.length||0)}}catch{d(0)}};E(),window.addEventListener("storage",E);const P=setInterval(E,500);return()=>{window.removeEventListener("storage",E),clearInterval(P)}},[l]);const{data:p,isLoading:x,refetch:y}=Ze({queryKey:["archiveStats"],queryFn:re.getArchiveStats}),{data:b}=Ze({queryKey:["printers"],queryFn:re.getPrinters}),{data:v}=Ze({queryKey:["archives"],queryFn:()=>re.getArchives(void 0,void 0,1e3,0)}),{data:S}=Ze({queryKey:["settings"],queryFn:re.getSettings}),N=async E=>{o(!1),i(!0);try{const{blob:P,filename:U}=await re.exportStats({format:E,days:90}),O=URL.createObjectURL(P),B=document.createElement("a");B.href=O,B.download=U,B.click(),URL.revokeObjectURL(O),e(t("stats.exportDownloaded"))}catch{e(t("stats.exportFailed"),"error")}finally{i(!1)}},A=async()=>{f(!0);try{const E=await re.recalculateCosts();await y(),e(t("stats.recalculatedCosts",{count:E.updated}))}catch{e(t("stats.recalculateFailed"),"error")}finally{f(!1)}},C=ju(S?.currency||"USD"),T=new Map(b?.map(E=>[String(E.id),E.name])||[]),k=v?.map(E=>E.created_at)||[];if(x)return a.jsx("div",{className:"p-4 md:p-8",children:a.jsx("div",{className:"text-center py-12 text-bambu-gray",children:t("stats.loadingStats")})});const j=[{id:"quick-stats",title:t("stats.quickStats"),component:a.jsx(FQe,{stats:p,currency:C,t}),defaultSize:2},{id:"success-rate",title:t("stats.successRate"),component:E=>a.jsx(LQe,{stats:p,printerMap:T,size:E,t}),defaultSize:1},{id:"time-accuracy",title:t("stats.timeAccuracy"),component:E=>a.jsx(OQe,{stats:p,printerMap:T,size:E,t}),defaultSize:1},{id:"filament-types",title:t("stats.filamentTypes"),component:E=>a.jsx(IQe,{stats:p,size:E,t}),defaultSize:1},{id:"failure-analysis",title:t("stats.failureAnalysis"),component:E=>a.jsx(HQe,{size:E,t}),defaultSize:1},{id:"print-activity",title:t("stats.printActivity"),component:E=>a.jsx(zQe,{printDates:k,size:E}),defaultSize:2},{id:"prints-by-printer",title:t("stats.printsByPrinter"),component:a.jsx(UQe,{stats:p,printerMap:T,t}),defaultSize:2},{id:"filament-trends",title:t("stats.filamentTrends"),component:a.jsx(BQe,{archives:v||[],currency:C,t}),defaultSize:4}];return a.jsxs("div",{className:"p-4 md:p-8",children:[a.jsxs("div",{className:"flex flex-col sm:flex-row sm:items-center sm:justify-between gap-4 mb-6",children:[a.jsxs("div",{children:[a.jsx("h1",{className:"text-2xl font-bold text-white",children:t("stats.title")}),a.jsx("p",{className:"text-bambu-gray",children:t("stats.subtitle")})]}),a.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[u>0&&a.jsxs(Ce,{variant:"secondary",onClick:()=>{window.dispatchEvent(new CustomEvent("toggle-hidden-panel"))},children:[a.jsx(Xl,{className:"w-4 h-4"}),t("stats.hiddenCount",{count:u})]}),a.jsxs(Ce,{variant:"secondary",onClick:()=>{localStorage.removeItem("bambusy-dashboard-layout"),c(E=>E+1),e(t("stats.layoutReset"))},disabled:!n("settings:update"),title:n("settings:update")?void 0:t("stats.noPermissionResetLayout"),children:[a.jsx(Ro,{className:"w-4 h-4"}),t("stats.resetLayout")]}),a.jsxs(Ce,{variant:"secondary",onClick:A,disabled:h||!n("archives:update_all"),title:n("archives:update_all")?t("stats.recalculateCostsHint"):t("stats.noPermissionRecalculate"),children:[h?a.jsx(it,{className:"w-4 h-4 animate-spin"}):a.jsx(Ide,{className:"w-4 h-4"}),t("stats.recalculateCosts")]}),a.jsxs("div",{className:"relative",children:[a.jsxs(Ce,{variant:"secondary",onClick:()=>o(!s),disabled:r,children:[r?a.jsx(it,{className:"w-4 h-4 animate-spin"}):a.jsx(P1,{className:"w-4 h-4"}),t("stats.exportStats")]}),s&&a.jsxs("div",{className:"absolute right-0 top-full mt-1 w-48 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg shadow-xl z-20",children:[a.jsxs("button",{className:"w-full px-4 py-2 text-left text-white hover:bg-bambu-dark-tertiary transition-colors flex items-center gap-2 rounded-t-lg",onClick:()=>N("csv"),children:[a.jsx(Ps,{className:"w-4 h-4"}),t("stats.exportAsCsv")]}),a.jsxs("button",{className:"w-full px-4 py-2 text-left text-white hover:bg-bambu-dark-tertiary transition-colors flex items-center gap-2 rounded-b-lg",onClick:()=>N("xlsx"),children:[a.jsx(P1,{className:"w-4 h-4"}),t("stats.exportAsExcel")]})]})]})]})]}),a.jsx(jQe,{widgets:j,storageKey:"bambusy-dashboard-layout",stackBelow:640,hideControls:!0},l)]})}function VQe({plug:t,onEdit:e}){const{t:n}=Vt(),r=tn(),{showToast:i}=hn(),[s,o]=w.useState(!1),[l,c]=w.useState(!1),[u,d]=w.useState(!1),[h,f]=w.useState(!1),{data:p,isLoading:x}=Ze({queryKey:["smart-plug-status",t.id],queryFn:()=>re.getSmartPlugStatus(t.id),refetchInterval:3e4}),{data:y}=Ze({queryKey:["printers"],queryFn:re.getPrinters}),b=y?.find(P=>P.id===t.printer_id),v=ot({mutationFn:P=>re.controlSmartPlug(t.id,P),onMutate:async P=>{await r.cancelQueries({queryKey:["smart-plug-status",t.id]});const U=r.getQueryData(["smart-plug-status",t.id]),O=P==="on"?"ON":P==="off"||p?.state==="ON"?"OFF":"ON";return r.setQueryData(["smart-plug-status",t.id],B=>({...B,state:O})),{previousStatus:U}},onError:(P,U,O)=>{O?.previousStatus&&r.setQueryData(["smart-plug-status",t.id],O.previousStatus),i(`Failed to turn ${U} "${t.name}"`,"error")},onSettled:()=>{setTimeout(()=>{r.invalidateQueries({queryKey:["smart-plug-status",t.id]}),r.invalidateQueries({queryKey:["smart-plugs"]})},1e3)}}),S=ot({mutationFn:P=>re.updateSmartPlug(t.id,P),onSuccess:()=>{r.invalidateQueries({queryKey:["smart-plugs"]}),t.printer_id&&(r.invalidateQueries({queryKey:["smartPlugByPrinter",t.printer_id]}),r.invalidateQueries({queryKey:["scriptPlugsByPrinter",t.printer_id]}))}}),N=ot({mutationFn:()=>re.deleteSmartPlug(t.id),onSuccess:()=>{r.invalidateQueries({queryKey:["smart-plugs"]}),t.printer_id&&r.invalidateQueries({queryKey:["scriptPlugsByPrinter",t.printer_id]})}}),A=p?.state==="ON",C=t.plug_type==="mqtt"&&p?.energy?.power!==null&&p?.energy?.power!==void 0,T=(p?.reachable??!1)||C,k=v.isPending,E=(()=>{if(t.plug_type!=="tasmota"||!t.ip_address)return null;const P=t.ip_address;return t.username&&t.password?`http://${encodeURIComponent(t.username)}:${encodeURIComponent(t.password)}@${P}/`:`http://${P}/`})();return a.jsxs(a.Fragment,{children:[a.jsx(vt,{className:"relative",children:a.jsxs(Nt,{className:"p-4",children:[a.jsxs("div",{className:"flex items-start justify-between gap-2 mb-3",children:[a.jsxs("div",{className:"flex items-center gap-3 min-w-0 flex-1",children:[a.jsx("div",{className:`p-2 rounded-lg flex-shrink-0 ${t.plug_type==="mqtt"?T?"bg-teal-500/20":"bg-red-500/20":T?A?"bg-bambu-green/20":"bg-bambu-dark":"bg-red-500/20"}`,children:t.plug_type==="mqtt"?a.jsx(OF,{className:`w-5 h-5 ${T?"text-teal-400":"text-red-400"}`}):t.plug_type==="homeassistant"?a.jsx(bv,{className:`w-5 h-5 ${T?A?"text-bambu-green":"text-bambu-gray":"text-red-400"}`}):a.jsx(hl,{className:`w-5 h-5 ${T?A?"text-bambu-green":"text-bambu-gray":"text-red-400"}`})}),a.jsxs("div",{className:"min-w-0",children:[a.jsx("h3",{className:"font-medium text-white truncate",children:t.name}),a.jsx("p",{className:"text-sm text-bambu-gray truncate",title:t.plug_type==="mqtt"?t.mqtt_topic??void 0:t.plug_type==="homeassistant"?t.ha_entity_id??void 0:t.ip_address??void 0,children:t.plug_type==="mqtt"?t.mqtt_topic:t.plug_type==="homeassistant"?t.ha_entity_id:t.ip_address})]})]}),a.jsxs("div",{className:"flex flex-col items-end gap-1 flex-shrink-0",children:[x?a.jsx(it,{className:"w-4 h-4 text-bambu-gray animate-spin"}):t.plug_type==="mqtt"?a.jsxs("div",{className:"flex items-center gap-1.5 text-sm whitespace-nowrap",children:[a.jsx("span",{className:"px-1.5 py-0.5 bg-teal-500/20 text-teal-400 text-[10px] font-medium rounded flex-shrink-0",children:"MQTT"}),T&&a.jsx("span",{className:"text-status-ok",children:"✓"})]}):t.plug_type==="homeassistant"?a.jsxs("div",{className:"flex items-center gap-1 text-sm",children:[a.jsx("span",{className:"px-1 py-0.5 bg-blue-500/20 text-blue-400 text-[10px] font-medium rounded",children:"HA"}),a.jsx("span",{className:T?A?"text-status-ok":"text-bambu-gray":"text-status-error",children:T?p?.state||"?":"Offline"})]}):T?a.jsxs("div",{className:"flex items-center gap-1 text-sm",children:[a.jsx(Qg,{className:"w-4 h-4 text-status-ok"}),a.jsx("span",{className:A?"text-status-ok":"text-bambu-gray",children:p?.state||"Unknown"})]}):a.jsxs("div",{className:"flex items-center gap-1 text-sm text-status-error",children:[a.jsx(Rf,{className:"w-4 h-4"}),a.jsx("span",{children:n("smartPlugs.offline")})]}),E&&a.jsxs("a",{href:E,target:"_blank",rel:"noopener noreferrer",className:"flex items-center gap-1 px-2 py-0.5 bg-bambu-dark hover:bg-bambu-dark-tertiary text-bambu-gray hover:text-white text-xs rounded-full transition-colors",title:n("smartPlugs.openPlugAdminPage"),children:[a.jsx(Kr,{className:"w-3 h-3"}),n("smartPlugs.admin")]})]})]}),b&&a.jsxs("div",{className:"mb-3 px-2 py-1.5 bg-bambu-dark rounded-lg",children:[a.jsx("span",{className:"text-xs text-bambu-gray",children:"Linked to: "}),a.jsx("span",{className:"text-sm text-white",children:b.name})]}),(t.power_alert_enabled||t.schedule_enabled||t.plug_type==="mqtt")&&a.jsxs("div",{className:"flex flex-wrap gap-1.5 mb-3",children:[t.plug_type==="mqtt"&&a.jsxs("span",{className:"flex items-center gap-1 px-2 py-0.5 bg-teal-500/20 text-teal-400 text-xs rounded-full",children:[a.jsx(Xl,{className:"w-3 h-3"}),"Monitor Only"]}),t.power_alert_enabled&&a.jsxs("span",{className:"flex items-center gap-1 px-2 py-0.5 bg-yellow-500/20 text-yellow-400 text-xs rounded-full",children:[a.jsx(Xg,{className:"w-3 h-3"}),"Alerts"]}),t.schedule_enabled&&a.jsxs("span",{className:"flex items-center gap-1 px-2 py-0.5 bg-blue-500/20 text-blue-400 text-xs rounded-full",children:[a.jsx(ii,{className:"w-3 h-3"}),t.schedule_on_time&&t.schedule_off_time?`${t.schedule_on_time} - ${t.schedule_off_time}`:t.schedule_on_time?`On ${t.schedule_on_time}`:`Off ${t.schedule_off_time}`]})]}),t.plug_type!=="mqtt"&&a.jsxs("div",{className:"flex gap-2 mb-3",children:[a.jsxs(Ce,{size:"sm",variant:A?"primary":"secondary",disabled:!T||k,onClick:()=>c(!0),className:"flex-1",children:[k?a.jsx(it,{className:"w-4 h-4 animate-spin"}):a.jsx(fd,{className:"w-4 h-4"}),"On"]}),a.jsxs(Ce,{size:"sm",variant:A?"secondary":"primary",disabled:!T||k,onClick:()=>d(!0),className:"flex-1",children:[k?a.jsx(it,{className:"w-4 h-4 animate-spin"}):a.jsx(oC,{className:"w-4 h-4"}),"Off"]})]}),t.plug_type==="mqtt"&&p?.energy&&a.jsxs("div",{className:"flex gap-2 mb-3 px-3 py-2 bg-bambu-dark rounded-lg",children:[p.energy.power!==null&&p.energy.power!==void 0&&a.jsxs("div",{className:"flex-1 text-center",children:[a.jsxs("p",{className:"text-lg font-semibold text-white",children:[Math.round(p.energy.power),"W"]}),a.jsx("p",{className:"text-xs text-bambu-gray",children:"Power"})]}),p.energy.today!==null&&p.energy.today!==void 0&&a.jsxs("div",{className:"flex-1 text-center border-l border-bambu-dark-tertiary",children:[a.jsx("p",{className:"text-lg font-semibold text-white",children:p.energy.today.toFixed(2)}),a.jsx("p",{className:"text-xs text-bambu-gray",children:"kWh Today"})]})]}),a.jsxs("button",{onClick:()=>f(!h),className:"w-full flex items-center justify-between py-2 text-sm text-bambu-gray hover:text-white transition-colors",children:[a.jsxs("span",{className:"flex items-center gap-2",children:[a.jsx(nd,{className:"w-4 h-4"}),t.plug_type==="mqtt"?"Settings":"Automation Settings"]}),a.jsx("span",{children:h?"-":"+"})]}),h&&a.jsxs("div",{className:"pt-3 border-t border-bambu-dark-tertiary space-y-4",children:[a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx(xv,{className:"w-4 h-4 text-bambu-green"}),a.jsxs("div",{children:[a.jsx("p",{className:"text-sm text-white",children:"Show in Switchbar"}),a.jsx("p",{className:"text-xs text-bambu-gray",children:"Quick access from sidebar"})]})]}),a.jsxs("label",{className:"relative inline-flex items-center cursor-pointer",children:[a.jsx("input",{type:"checkbox",checked:t.show_in_switchbar,onChange:P=>S.mutate({show_in_switchbar:P.target.checked}),className:"sr-only peer"}),a.jsx("div",{className:"w-9 h-5 bg-bambu-dark-tertiary peer-focus:outline-none rounded-full peer peer-checked:after:translate-x-full after:content-[''] after:absolute after:top-[2px] after:left-[2px] after:bg-white after:rounded-full after:h-4 after:w-4 after:transition-all peer-checked:bg-bambu-green"})]})]}),t.plug_type!=="mqtt"&&a.jsxs(a.Fragment,{children:[a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsxs("div",{children:[a.jsx("p",{className:"text-sm text-white",children:"Enabled"}),a.jsx("p",{className:"text-xs text-bambu-gray",children:"Enable automation for this plug"})]}),a.jsxs("label",{className:"relative inline-flex items-center cursor-pointer",children:[a.jsx("input",{type:"checkbox",checked:t.enabled,onChange:P=>S.mutate({enabled:P.target.checked}),className:"sr-only peer"}),a.jsx("div",{className:"w-9 h-5 bg-bambu-dark-tertiary peer-focus:outline-none rounded-full peer peer-checked:after:translate-x-full after:content-[''] after:absolute after:top-[2px] after:left-[2px] after:bg-white after:rounded-full after:h-4 after:w-4 after:transition-all peer-checked:bg-bambu-green"})]})]}),a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsxs("div",{children:[a.jsx("p",{className:"text-sm text-white",children:"Auto On"}),a.jsx("p",{className:"text-xs text-bambu-gray",children:"Turn on when print starts"})]}),a.jsxs("label",{className:"relative inline-flex items-center cursor-pointer",children:[a.jsx("input",{type:"checkbox",checked:t.auto_on,onChange:P=>S.mutate({auto_on:P.target.checked}),className:"sr-only peer"}),a.jsx("div",{className:"w-9 h-5 bg-bambu-dark-tertiary peer-focus:outline-none rounded-full peer peer-checked:after:translate-x-full after:content-[''] after:absolute after:top-[2px] after:left-[2px] after:bg-white after:rounded-full after:h-4 after:w-4 after:transition-all peer-checked:bg-bambu-green"})]})]}),a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsxs("div",{children:[a.jsx("p",{className:"text-sm text-white",children:"Auto Off"}),a.jsx("p",{className:"text-xs text-bambu-gray",children:"Turn off when print completes (one-shot)"})]}),a.jsxs("label",{className:"relative inline-flex items-center cursor-pointer",children:[a.jsx("input",{type:"checkbox",checked:t.auto_off,onChange:P=>S.mutate({auto_off:P.target.checked}),className:"sr-only peer"}),a.jsx("div",{className:"w-9 h-5 bg-bambu-dark-tertiary peer-focus:outline-none rounded-full peer peer-checked:after:translate-x-full after:content-[''] after:absolute after:top-[2px] after:left-[2px] after:bg-white after:rounded-full after:h-4 after:w-4 after:transition-all peer-checked:bg-bambu-green"})]})]}),t.auto_off&&a.jsxs("div",{className:"space-y-3 pl-4 border-l-2 border-bambu-dark-tertiary",children:[a.jsxs("div",{children:[a.jsx("p",{className:"text-sm text-white mb-2",children:"Turn Off Delay Mode"}),a.jsxs("div",{className:"flex gap-2",children:[a.jsxs("button",{onClick:()=>S.mutate({off_delay_mode:"time"}),className:`flex-1 flex items-center justify-center gap-2 px-3 py-2 rounded-lg text-sm transition-colors ${t.off_delay_mode==="time"?"bg-bambu-green text-white":"bg-bambu-dark text-bambu-gray hover:text-white"}`,children:[a.jsx(Wn,{className:"w-4 h-4"}),"Time"]}),a.jsxs("button",{onClick:()=>S.mutate({off_delay_mode:"temperature"}),className:`flex-1 flex items-center justify-center gap-2 px-3 py-2 rounded-lg text-sm transition-colors ${t.off_delay_mode==="temperature"?"bg-bambu-green text-white":"bg-bambu-dark text-bambu-gray hover:text-white"}`,children:[a.jsx(uC,{className:"w-4 h-4"}),"Temp"]})]})]}),t.off_delay_mode==="time"?a.jsxs("div",{children:[a.jsx("label",{className:"block text-xs text-bambu-gray mb-1",children:"Delay (minutes)"}),a.jsx("input",{type:"number",min:"1",max:"60",value:t.off_delay_minutes,onChange:P=>S.mutate({off_delay_minutes:parseInt(P.target.value)||5}),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white text-sm focus:border-bambu-green focus:outline-none"})]}):a.jsxs("div",{children:[a.jsx("label",{className:"block text-xs text-bambu-gray mb-1",children:"Temperature threshold (C)"}),a.jsx("input",{type:"number",min:"30",max:"100",value:t.off_temp_threshold,onChange:P=>S.mutate({off_temp_threshold:parseInt(P.target.value)||70}),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white text-sm focus:border-bambu-green focus:outline-none"}),a.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:"Turns off when nozzle cools below this temperature"})]})]})]}),a.jsxs("div",{className:"flex gap-2 pt-2",children:[a.jsxs(Ce,{size:"sm",variant:"secondary",onClick:()=>e(t),className:"flex-1",children:[a.jsx(af,{className:"w-4 h-4"}),"Edit"]}),a.jsx(Ce,{size:"sm",variant:"secondary",onClick:()=>o(!0),className:"text-red-400 hover:text-red-300",children:a.jsx(Jt,{className:"w-4 h-4"})})]})]})]})}),s&&a.jsx(vn,{title:n("smartPlugs.deleteSmartPlug"),message:`Are you sure you want to delete "${t.name}"? This cannot be undone.`,confirmText:"Delete",variant:"danger",onConfirm:()=>{N.mutate(),o(!1)},onCancel:()=>o(!1)}),l&&a.jsx(vn,{title:n("smartPlugs.turnOnSmartPlug"),message:`Are you sure you want to turn on "${t.name}"?`,confirmText:n("smartPlugs.turnOn"),variant:"default",onConfirm:()=>{v.mutate("on"),c(!1)},onCancel:()=>c(!1)}),u&&a.jsx(vn,{title:n("smartPlugs.turnOffSmartPlug"),message:`Are you sure you want to turn off "${t.name}"? This will cut power to the connected device.`,confirmText:n("smartPlugs.turnOff"),variant:"danger",onConfirm:()=>{v.mutate("off"),d(!1)},onCancel:()=>d(!1)})]})}function GQe({plug:t,onClose:e}){const{t:n}=Vt(),r=tn(),i=!!t,[s,o]=w.useState(t?.plug_type||"tasmota"),[l,c]=w.useState(t?.name||""),[u,d]=w.useState(t?.ip_address||""),[h,f]=w.useState(t?.username||""),[p,x]=w.useState(t?.password||""),[y,b]=w.useState(t?.ha_entity_id||""),[v,S]=w.useState(t?.mqtt_power_topic||t?.mqtt_topic||""),[N,A]=w.useState(t?.mqtt_power_path||""),[C,T]=w.useState((t?.mqtt_power_multiplier??t?.mqtt_multiplier??1).toString()),[k,j]=w.useState(t?.mqtt_energy_topic||""),[E,P]=w.useState(t?.mqtt_energy_path||""),[U,O]=w.useState((t?.mqtt_energy_multiplier??1).toString()),[B,R]=w.useState(t?.mqtt_state_topic||""),[G,q]=w.useState(t?.mqtt_state_path||""),[z,K]=w.useState(t?.mqtt_state_on_value||""),[Y,oe]=w.useState(t?.ha_power_entity||""),[$,X]=w.useState(t?.ha_energy_today_entity||""),[ee,J]=w.useState(t?.ha_energy_total_entity||""),[_e,pe]=w.useState(""),[me,je]=w.useState(""),[de,ce]=w.useState(!1),Se=w.useRef(null),[ie,Fe]=w.useState(""),[V,W]=w.useState(!1),ue=w.useRef(null),[Q,se]=w.useState(""),[Z,Ne]=w.useState(!1),ve=w.useRef(null),[fe,L]=w.useState(""),[D,H]=w.useState(!1),he=w.useRef(null),[xe,be]=w.useState(t?.printer_id||null),[Ue,Oe]=w.useState(null),[Qe,rt]=w.useState(null),[we,ye]=w.useState(t?.power_alert_enabled||!1),[le,Le]=w.useState(t?.power_alert_high?.toString()||""),[Me,$e]=w.useState(t?.power_alert_low?.toString()||""),[Ae,Je]=w.useState(t?.schedule_enabled||!1),[Pe,Xe]=w.useState(t?.schedule_on_time||""),[De,Re]=w.useState(t?.schedule_off_time||""),[qe,pt]=w.useState(t?.show_in_switchbar||!1),[At,Rt]=w.useState(t?.show_on_printer_card??!0),[Wt,Tt]=w.useState(!1),[Ie,xt]=w.useState({scanned:0,total:0}),[wt,Bt]=w.useState([]),Tn=w.useRef(null),{data:fr}=Ze({queryKey:["printers"],queryFn:re.getPrinters}),{data:Zn}=Ze({queryKey:["smart-plugs"],queryFn:re.getSmartPlugs}),{data:Jn}=Ze({queryKey:["settings"],queryFn:re.getSettings}),Pn=!!(Jn?.ha_enabled&&Jn?.ha_url&&Jn?.ha_token);w.useEffect(()=>{const Ee=setTimeout(()=>{je(_e)},300);return()=>clearTimeout(Ee)},[_e]),w.useEffect(()=>{const Ee=st=>{Se.current&&!Se.current.contains(st.target)&&ce(!1),ue.current&&!ue.current.contains(st.target)&&W(!1),ve.current&&!ve.current.contains(st.target)&&Ne(!1),he.current&&!he.current.contains(st.target)&&H(!1)};return document.addEventListener("mousedown",Ee),()=>document.removeEventListener("mousedown",Ee)},[]);const{data:cr,isLoading:jn,error:ai}=Ze({queryKey:["ha-entities",me],queryFn:()=>re.getHAEntities(me||void 0),enabled:s==="homeassistant"&&Pn,retry:!1,staleTime:0}),{data:ne}=Ze({queryKey:["ha-sensor-entities"],queryFn:re.getHASensorEntities,enabled:s==="homeassistant"&&Pn,retry:!1,staleTime:0});w.useEffect(()=>{const Ee=st=>{st.key==="Escape"&&e()};return window.addEventListener("keydown",Ee),()=>{window.removeEventListener("keydown",Ee),Tn.current&&clearInterval(Tn.current)}},[e]);const He=async()=>{Tt(!0),Bt([]),xt({scanned:0,total:0}),rt(null);try{await re.startTasmotaScan();const Ee=async()=>{try{const st=await re.getTasmotaScanStatus();xt({scanned:st.scanned,total:st.total});const tt=await re.getDiscoveredTasmotaDevices();Bt(tt),st.running||(Tt(!1),Tn.current&&(clearInterval(Tn.current),Tn.current=null))}catch(st){console.error("Polling error:",st)}};await Ee(),Tn.current=setInterval(Ee,500)}catch(Ee){Tt(!1);const st=Ee instanceof Error?Ee.message:typeof Ee=="string"?Ee:JSON.stringify(Ee);rt(st||"Failed to start scan")}},et=async()=>{try{await re.stopTasmotaScan()}catch{}Tt(!1),Tn.current&&(clearInterval(Tn.current),Tn.current=null)},lt=Ee=>{d(Ee.ip_address),c(Ee.name),Oe(null)},dt=ot({mutationFn:()=>re.testSmartPlugConnection(u,h||null,p||null),onSuccess:Ee=>{Oe(Ee),rt(null),!l&&Ee.device_name&&c(Ee.device_name)},onError:Ee=>{Oe(null),rt(Ee.message)}}),Lt=ot({mutationFn:Ee=>re.createSmartPlug(Ee),onSuccess:()=>{r.invalidateQueries({queryKey:["smart-plugs"]}),r.invalidateQueries({queryKey:["scriptPlugsByPrinter"]}),e()},onError:Ee=>{rt(Ee.message)}}),ge=ot({mutationFn:Ee=>re.updateSmartPlug(t.id,Ee),onSuccess:()=>{r.invalidateQueries({queryKey:["smart-plugs"]}),r.invalidateQueries({queryKey:["scriptPlugsByPrinter"]}),e()},onError:Ee=>{rt(Ee.message)}}),ze=fr?.filter(Ee=>s==="tasmota"?!Zn?.some(tt=>tt.printer_id===Ee.id&&tt.id!==t?.id&&tt.plug_type==="tasmota"):!0),Ge=Ee=>{if(Ee.preventDefault(),rt(null),!l.trim()){rt("Name is required");return}if(s==="tasmota"&&!u.trim()){rt("IP address is required for Tasmota plugs");return}if(s==="homeassistant"&&!y){rt("Entity is required for Home Assistant plugs");return}if(s==="mqtt"){const tt=v.trim(),at=k.trim(),Mt=B.trim();if(!tt&&!at&&!Mt){rt("At least one MQTT topic must be configured for power, energy, or state monitoring");return}}const st={name:l.trim(),plug_type:s,ip_address:s==="tasmota"?u.trim():null,ha_entity_id:s==="homeassistant"?y:null,ha_power_entity:s==="homeassistant"&&Y||null,ha_energy_today_entity:s==="homeassistant"&&$||null,ha_energy_total_entity:s==="homeassistant"&&ee||null,mqtt_power_topic:s==="mqtt"&&v.trim()||null,mqtt_power_path:s==="mqtt"&&N.trim()||null,mqtt_power_multiplier:s==="mqtt"&&parseFloat(C)||1,mqtt_energy_topic:s==="mqtt"&&k.trim()||null,mqtt_energy_path:s==="mqtt"&&E.trim()||null,mqtt_energy_multiplier:s==="mqtt"&&parseFloat(U)||1,mqtt_state_topic:s==="mqtt"&&B.trim()||null,mqtt_state_path:s==="mqtt"&&G.trim()||null,mqtt_state_on_value:s==="mqtt"&&z.trim()||null,username:s==="tasmota"&&h.trim()||null,password:s==="tasmota"&&p.trim()||null,printer_id:xe,power_alert_enabled:we,power_alert_high:le?parseFloat(le):null,power_alert_low:Me?parseFloat(Me):null,schedule_enabled:Ae,schedule_on_time:Pe||null,schedule_off_time:De||null,show_in_switchbar:qe,show_on_printer_card:At};i?ge.mutate(st):Lt.mutate(st)},Ve=Lt.isPending||ge.isPending;return a.jsx("div",{className:"fixed inset-0 bg-black/70 flex items-center justify-center z-50 p-4",onClick:e,children:a.jsxs("div",{className:"bg-bambu-dark-secondary rounded-xl border border-bambu-dark-tertiary w-full max-w-md max-h-[90vh] flex flex-col",onClick:Ee=>Ee.stopPropagation(),children:[a.jsxs("div",{className:"flex items-center justify-between px-6 py-4 border-b border-bambu-dark-tertiary flex-shrink-0",children:[a.jsx("h2",{className:"text-lg font-semibold text-white",children:i?"Edit Smart Plug":"Add Smart Plug"}),a.jsx("button",{onClick:e,className:"text-bambu-gray hover:text-white transition-colors",children:a.jsx(Ft,{className:"w-5 h-5"})})]}),a.jsxs("form",{onSubmit:Ge,className:"p-6 space-y-4 overflow-y-auto",children:[Qe&&a.jsx("div",{className:"p-3 bg-red-500/20 border border-red-500/50 rounded-lg text-sm text-red-400",children:Qe}),!i&&a.jsxs("div",{className:"flex gap-2 mb-2",children:[a.jsxs("button",{type:"button",onClick:()=>{o("tasmota"),Oe(null),rt(null)},className:`flex-1 flex items-center justify-center gap-2 px-3 py-2.5 rounded-lg font-medium transition-colors ${s==="tasmota"?"bg-bambu-green text-white":"bg-bambu-dark text-bambu-gray hover:text-white border border-bambu-dark-tertiary"}`,children:[a.jsx(hl,{className:"w-4 h-4"}),"Tasmota"]}),a.jsxs("button",{type:"button",onClick:()=>{o("homeassistant"),Oe(null),rt(null)},className:`flex-1 flex items-center justify-center gap-2 px-3 py-2.5 rounded-lg font-medium transition-colors ${s==="homeassistant"?"bg-bambu-green text-white":"bg-bambu-dark text-bambu-gray hover:text-white border border-bambu-dark-tertiary"}`,children:[a.jsx(bv,{className:"w-4 h-4"}),"HA"]}),a.jsxs("button",{type:"button",onClick:()=>{o("mqtt"),Oe(null),rt(null)},className:`flex-1 flex items-center justify-center gap-2 px-3 py-2.5 rounded-lg font-medium transition-colors ${s==="mqtt"?"bg-bambu-green text-white":"bg-bambu-dark text-bambu-gray hover:text-white border border-bambu-dark-tertiary"}`,children:[a.jsx(OF,{className:"w-4 h-4"}),"MQTT"]})]}),!i&&s==="tasmota"&&a.jsxs("div",{className:"space-y-3",children:[Wt?a.jsxs(Ce,{type:"button",variant:"secondary",onClick:et,className:"w-full",children:[a.jsx(Ft,{className:"w-4 h-4"}),"Stop Scanning"]}):a.jsxs(Ce,{type:"button",variant:"primary",onClick:He,className:"w-full",children:[a.jsx(Or,{className:"w-4 h-4"}),"Discover Tasmota Devices"]}),Wt&&Ie.total>0&&a.jsxs("div",{className:"space-y-1",children:[a.jsxs("div",{className:"flex justify-between text-xs text-bambu-gray",children:[a.jsx("span",{children:n("smartPlugs.addSmartPlug.scanningNetwork")}),a.jsxs("span",{children:[Ie.scanned," / ",Ie.total]})]}),a.jsx("div",{className:"w-full bg-bambu-dark-tertiary rounded-full h-2",children:a.jsx("div",{className:"bg-bambu-green h-2 rounded-full transition-all duration-300",style:{width:`${Ie.scanned/Ie.total*100}%`}})})]}),wt.length>0&&a.jsxs("div",{className:"space-y-2",children:[a.jsxs("p",{className:"text-xs text-bambu-gray",children:["Found ",wt.length," device(s) - click to select:"]}),a.jsx("div",{className:"max-h-40 overflow-y-auto space-y-1",children:wt.map(Ee=>a.jsxs("button",{type:"button",onClick:()=>lt(Ee),className:"w-full flex items-center justify-between p-2 bg-bambu-dark hover:bg-bambu-dark-tertiary rounded-lg transition-colors text-left border border-bambu-dark-tertiary",children:[a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx(hl,{className:"w-4 h-4 text-bambu-green"}),a.jsxs("div",{children:[a.jsx("p",{className:"text-sm text-white",children:Ee.name}),a.jsx("p",{className:"text-xs text-bambu-gray",children:Ee.ip_address})]})]}),Ee.state&&a.jsxs("span",{className:`flex items-center gap-1 text-xs ${Ee.state==="ON"?"text-bambu-green":"text-bambu-gray"}`,children:[a.jsx(fd,{className:"w-3 h-3"}),Ee.state]})]},Ee.ip_address))})]}),!Wt&&wt.length===0&&Ie.total>0&&a.jsx("p",{className:"text-xs text-bambu-gray text-center py-2",children:"No Tasmota devices found on your network"})]}),s==="homeassistant"&&a.jsxs("div",{className:"space-y-3",children:[!Pn&&a.jsxs("div",{className:"space-y-3",children:[a.jsxs("div",{className:"p-3 bg-yellow-500/20 border border-yellow-500/50 rounded-lg text-sm text-yellow-400",children:["Home Assistant is not configured. Set it up in"," ",a.jsx("span",{className:"font-medium",children:"Settings → Network → Home Assistant"})]}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm text-bambu-gray mb-1 opacity-50",children:"Select Entity *"}),a.jsx("select",{disabled:!0,className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-bambu-gray cursor-not-allowed opacity-50",children:a.jsx("option",{children:n("smartPlugs.addSmartPlug.chooseEntity")})})]})]}),Pn&&a.jsxs(a.Fragment,{children:[jn&&a.jsxs("div",{className:"flex items-center justify-center py-4 text-bambu-gray",children:[a.jsx(it,{className:"w-5 h-5 animate-spin mr-2"}),"Loading entities..."]}),ai&&a.jsxs("div",{className:"p-3 bg-red-500/20 border border-red-500/50 rounded-lg text-sm text-red-400",children:["Failed to load entities: ",ai.message]}),(()=>{const Ee=Zn?.filter(at=>at.ha_entity_id&&at.id!==t?.id).map(at=>at.ha_entity_id)||[],st=(cr||[]).filter(at=>!Ee.includes(at.entity_id)),tt=cr?.find(at=>at.entity_id===y);return a.jsxs("div",{ref:Se,className:"relative",children:[a.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Select Entity *"}),a.jsxs("div",{className:"relative",children:[a.jsx(Or,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray pointer-events-none"}),a.jsx("input",{type:"text",value:de?_e:tt?`${tt.friendly_name} (${tt.entity_id})`:"",onChange:at=>{pe(at.target.value),de||ce(!0)},onFocus:()=>{ce(!0),pe("")},placeholder:n("smartPlugs.addSmartPlug.placeholders.searchEntities"),className:"w-full pl-9 pr-8 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white placeholder-bambu-gray focus:border-bambu-green focus:outline-none"}),y&&!de&&a.jsx("button",{type:"button",onClick:()=>{b(""),pe("")},className:"absolute right-2 top-1/2 -translate-y-1/2 p-1 hover:bg-bambu-dark-tertiary rounded",children:a.jsx(Ft,{className:"w-4 h-4 text-bambu-gray hover:text-white"})}),jn&&a.jsx(it,{className:"absolute right-2 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray animate-spin"})]}),de&&a.jsxs("div",{className:"absolute z-50 w-full mt-1 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg shadow-lg max-h-60 overflow-y-auto",children:[jn&&a.jsxs("div",{className:"px-3 py-2 text-sm text-bambu-gray flex items-center gap-2",children:[a.jsx(it,{className:"w-4 h-4 animate-spin"}),"Loading..."]}),!jn&&st.length===0&&a.jsx("div",{className:"px-3 py-2 text-sm text-bambu-gray",children:me?`No entities found matching "${me}"`:"No entities available"}),!jn&&st.map(at=>a.jsxs("button",{type:"button",onClick:()=>{b(at.entity_id),ce(!1),pe(""),l||c(at.friendly_name)},className:`w-full px-3 py-2 text-left text-sm hover:bg-bambu-dark-tertiary transition-colors ${at.entity_id===y?"bg-bambu-green/20 text-bambu-green":"text-white"}`,children:[a.jsx("div",{className:"font-medium",children:at.friendly_name}),a.jsxs("div",{className:"text-xs text-bambu-gray flex items-center justify-between",children:[a.jsx("span",{children:at.entity_id}),a.jsx("span",{className:at.state==="on"?"text-bambu-green":"",children:at.state})]})]},at.entity_id))]}),a.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:me?`Searching all entities (${st.length} found)`:`Showing switch, light, input_boolean (${st.length} available)`})]})})(),y&&ne&&ne.length>0&&a.jsxs("div",{className:"border-t border-bambu-dark-tertiary pt-4 mt-4 space-y-3",children:[a.jsxs("div",{children:[a.jsx("p",{className:"text-white font-medium mb-1",children:"Energy Monitoring (Optional)"}),a.jsx("p",{className:"text-xs text-bambu-gray mb-3",children:"Search and select sensors that provide power/energy data."})]}),(()=>{const Ee=ne.filter(at=>at.unit_of_measurement==="W"||at.unit_of_measurement==="kW"||at.unit_of_measurement==="mW"),st=ie?Ee.filter(at=>at.entity_id.toLowerCase().includes(ie.toLowerCase())||at.friendly_name.toLowerCase().includes(ie.toLowerCase())):Ee,tt=ne.find(at=>at.entity_id===Y);return a.jsxs("div",{ref:ue,className:"relative",children:[a.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Power Sensor (W)"}),a.jsxs("div",{className:"relative",children:[a.jsx(Or,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray pointer-events-none"}),a.jsx("input",{type:"text",value:V?ie:tt?`${tt.friendly_name} (${tt.state} ${tt.unit_of_measurement})`:"",onChange:at=>{Fe(at.target.value),V||W(!0)},onFocus:()=>{W(!0),Fe("")},placeholder:n("smartPlugs.addSmartPlug.placeholders.searchPowerSensors"),className:"w-full pl-9 pr-8 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white placeholder-bambu-gray focus:border-bambu-green focus:outline-none"}),Y&&!V&&a.jsx("button",{type:"button",onClick:()=>{oe(""),Fe("")},className:"absolute right-2 top-1/2 -translate-y-1/2 p-1 hover:bg-bambu-dark-tertiary rounded",children:a.jsx(Ft,{className:"w-4 h-4 text-bambu-gray hover:text-white"})})]}),V&&a.jsxs("div",{className:"absolute z-50 w-full mt-1 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg shadow-lg max-h-48 overflow-y-auto",children:[a.jsx("button",{type:"button",onClick:()=>{oe(""),W(!1),Fe("")},className:"w-full px-3 py-2 text-left text-sm text-bambu-gray hover:bg-bambu-dark-tertiary",children:"None"}),st.map(at=>a.jsxs("button",{type:"button",onClick:()=>{oe(at.entity_id),W(!1),Fe("")},className:`w-full px-3 py-2 text-left text-sm hover:bg-bambu-dark-tertiary ${at.entity_id===Y?"bg-bambu-green/20 text-bambu-green":"text-white"}`,children:[a.jsx("div",{className:"font-medium",children:at.friendly_name}),a.jsxs("div",{className:"text-xs text-bambu-gray",children:[at.entity_id," • ",at.state," ",at.unit_of_measurement]})]},at.entity_id)),st.length===0&&a.jsx("div",{className:"px-3 py-2 text-sm text-bambu-gray",children:"No matching sensors"})]})]})})(),(()=>{const Ee=ne.filter(at=>at.unit_of_measurement==="kWh"||at.unit_of_measurement==="Wh"||at.unit_of_measurement==="MWh"),st=Q?Ee.filter(at=>at.entity_id.toLowerCase().includes(Q.toLowerCase())||at.friendly_name.toLowerCase().includes(Q.toLowerCase())):Ee,tt=ne.find(at=>at.entity_id===$);return a.jsxs("div",{ref:ve,className:"relative",children:[a.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Energy Today (kWh)"}),a.jsxs("div",{className:"relative",children:[a.jsx(Or,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray pointer-events-none"}),a.jsx("input",{type:"text",value:Z?Q:tt?`${tt.friendly_name} (${tt.state} ${tt.unit_of_measurement})`:"",onChange:at=>{se(at.target.value),Z||Ne(!0)},onFocus:()=>{Ne(!0),se("")},placeholder:n("smartPlugs.addSmartPlug.placeholders.searchEnergySensors"),className:"w-full pl-9 pr-8 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white placeholder-bambu-gray focus:border-bambu-green focus:outline-none"}),$&&!Z&&a.jsx("button",{type:"button",onClick:()=>{X(""),se("")},className:"absolute right-2 top-1/2 -translate-y-1/2 p-1 hover:bg-bambu-dark-tertiary rounded",children:a.jsx(Ft,{className:"w-4 h-4 text-bambu-gray hover:text-white"})})]}),Z&&a.jsxs("div",{className:"absolute z-50 w-full mt-1 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg shadow-lg max-h-48 overflow-y-auto",children:[a.jsx("button",{type:"button",onClick:()=>{X(""),Ne(!1),se("")},className:"w-full px-3 py-2 text-left text-sm text-bambu-gray hover:bg-bambu-dark-tertiary",children:"None"}),st.map(at=>a.jsxs("button",{type:"button",onClick:()=>{X(at.entity_id),Ne(!1),se("")},className:`w-full px-3 py-2 text-left text-sm hover:bg-bambu-dark-tertiary ${at.entity_id===$?"bg-bambu-green/20 text-bambu-green":"text-white"}`,children:[a.jsx("div",{className:"font-medium",children:at.friendly_name}),a.jsxs("div",{className:"text-xs text-bambu-gray",children:[at.entity_id," • ",at.state," ",at.unit_of_measurement]})]},at.entity_id)),st.length===0&&a.jsx("div",{className:"px-3 py-2 text-sm text-bambu-gray",children:"No matching sensors"})]})]})})(),(()=>{const Ee=ne.filter(at=>at.unit_of_measurement==="kWh"||at.unit_of_measurement==="Wh"||at.unit_of_measurement==="MWh"),st=fe?Ee.filter(at=>at.entity_id.toLowerCase().includes(fe.toLowerCase())||at.friendly_name.toLowerCase().includes(fe.toLowerCase())):Ee,tt=ne.find(at=>at.entity_id===ee);return a.jsxs("div",{ref:he,className:"relative",children:[a.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Total Energy (kWh)"}),a.jsxs("div",{className:"relative",children:[a.jsx(Or,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray pointer-events-none"}),a.jsx("input",{type:"text",value:D?fe:tt?`${tt.friendly_name} (${tt.state} ${tt.unit_of_measurement})`:"",onChange:at=>{L(at.target.value),D||H(!0)},onFocus:()=>{H(!0),L("")},placeholder:n("smartPlugs.addSmartPlug.placeholders.searchEnergySensors"),className:"w-full pl-9 pr-8 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white placeholder-bambu-gray focus:border-bambu-green focus:outline-none"}),ee&&!D&&a.jsx("button",{type:"button",onClick:()=>{J(""),L("")},className:"absolute right-2 top-1/2 -translate-y-1/2 p-1 hover:bg-bambu-dark-tertiary rounded",children:a.jsx(Ft,{className:"w-4 h-4 text-bambu-gray hover:text-white"})})]}),D&&a.jsxs("div",{className:"absolute z-50 w-full mt-1 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg shadow-lg max-h-48 overflow-y-auto",children:[a.jsx("button",{type:"button",onClick:()=>{J(""),H(!1),L("")},className:"w-full px-3 py-2 text-left text-sm text-bambu-gray hover:bg-bambu-dark-tertiary",children:"None"}),st.map(at=>a.jsxs("button",{type:"button",onClick:()=>{J(at.entity_id),H(!1),L("")},className:`w-full px-3 py-2 text-left text-sm hover:bg-bambu-dark-tertiary ${at.entity_id===ee?"bg-bambu-green/20 text-bambu-green":"text-white"}`,children:[a.jsx("div",{className:"font-medium",children:at.friendly_name}),a.jsxs("div",{className:"text-xs text-bambu-gray",children:[at.entity_id," • ",at.state," ",at.unit_of_measurement]})]},at.entity_id)),st.length===0&&a.jsx("div",{className:"px-3 py-2 text-sm text-bambu-gray",children:"No matching sensors"})]})]})})()]})]})]}),s==="mqtt"&&a.jsxs("div",{className:"space-y-3",children:[!Jn?.mqtt_broker&&a.jsxs("div",{className:"p-3 bg-yellow-500/20 border border-yellow-500/50 rounded-lg text-sm text-yellow-400",children:["MQTT broker not configured. Set broker address in"," ",a.jsx("span",{className:"font-medium",children:"Settings → Network → MQTT Publishing"})," ","(you don't need to enable publishing, just fill in the broker details)."]}),Jn?.mqtt_broker&&a.jsxs(a.Fragment,{children:[a.jsxs("div",{className:"p-3 bg-blue-500/10 border border-blue-500/30 rounded-lg text-sm text-blue-300",children:[a.jsx("p",{className:"font-medium mb-1",children:"Monitor Only"}),a.jsx("p",{className:"text-xs opacity-80",children:"MQTT plugs receive power/energy data via MQTT subscription. On/off control is not available - use your MQTT broker or home automation system."})]}),a.jsxs("div",{className:"space-y-3 p-3 bg-bambu-dark rounded-lg border border-bambu-dark-tertiary",children:[a.jsx("p",{className:"text-white font-medium text-sm",children:"Power Monitoring"}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Topic"}),a.jsx("input",{type:"text",value:v,onChange:Ee=>S(Ee.target.value),placeholder:"zigbee2mqtt/shelly-working-room",className:"w-full px-3 py-2 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg text-white placeholder-bambu-gray focus:border-bambu-green focus:outline-none"})]}),a.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"JSON Path"}),a.jsx("input",{type:"text",value:N,onChange:Ee=>A(Ee.target.value),placeholder:"power_l1",className:"w-full px-3 py-2 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg text-white placeholder-bambu-gray focus:border-bambu-green focus:outline-none"})]}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Multiplier"}),a.jsx("input",{type:"text",value:C,onChange:Ee=>T(Ee.target.value),placeholder:"1",className:"w-full px-3 py-2 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg text-white placeholder-bambu-gray focus:border-bambu-green focus:outline-none"})]})]}),a.jsxs("p",{className:"text-xs text-bambu-gray",children:['JSON path extracts value from JSON payload (e.g., "power_l1"). Leave empty if topic publishes raw numeric values.',a.jsx("br",{}),"Use multiplier 0.001 for mW→W, 1000 for kW→W."]})]}),a.jsxs("div",{className:"space-y-3 p-3 bg-bambu-dark rounded-lg border border-bambu-dark-tertiary",children:[a.jsxs("p",{className:"text-white font-medium text-sm",children:["Energy Monitoring ",a.jsx("span",{className:"text-bambu-gray font-normal",children:"(optional)"})]}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Topic"}),a.jsx("input",{type:"text",value:k,onChange:Ee=>j(Ee.target.value),placeholder:"Same as power topic, or different",className:"w-full px-3 py-2 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg text-white placeholder-bambu-gray focus:border-bambu-green focus:outline-none"})]}),a.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"JSON Path"}),a.jsx("input",{type:"text",value:E,onChange:Ee=>P(Ee.target.value),placeholder:"energy_l1",className:"w-full px-3 py-2 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg text-white placeholder-bambu-gray focus:border-bambu-green focus:outline-none"})]}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Multiplier"}),a.jsx("input",{type:"text",value:U,onChange:Ee=>O(Ee.target.value),placeholder:"1",className:"w-full px-3 py-2 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg text-white placeholder-bambu-gray focus:border-bambu-green focus:outline-none"})]})]}),a.jsxs("p",{className:"text-xs text-bambu-gray",children:["JSON path extracts value from JSON payload. Leave empty for raw values.",a.jsx("br",{}),"Use multiplier 0.001 for Wh→kWh, 1000 for MWh→kWh."]})]}),a.jsxs("div",{className:"space-y-3 p-3 bg-bambu-dark rounded-lg border border-bambu-dark-tertiary",children:[a.jsxs("p",{className:"text-white font-medium text-sm",children:["State Monitoring ",a.jsx("span",{className:"text-bambu-gray font-normal",children:"(optional)"})]}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Topic"}),a.jsx("input",{type:"text",value:B,onChange:Ee=>R(Ee.target.value),placeholder:"Same as power topic, or different",className:"w-full px-3 py-2 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg text-white placeholder-bambu-gray focus:border-bambu-green focus:outline-none"})]}),a.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"JSON Path"}),a.jsx("input",{type:"text",value:G,onChange:Ee=>q(Ee.target.value),placeholder:"state_l1",className:"w-full px-3 py-2 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg text-white placeholder-bambu-gray focus:border-bambu-green focus:outline-none"})]}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"ON Value"}),a.jsx("input",{type:"text",value:z,onChange:Ee=>K(Ee.target.value),placeholder:n("smartPlugs.addSmartPlug.placeholders.mqttStateOnValue"),className:"w-full px-3 py-2 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg text-white placeholder-bambu-gray focus:border-bambu-green focus:outline-none"})]})]}),a.jsxs("p",{className:"text-xs text-bambu-gray",children:["JSON path extracts value from JSON payload. Leave empty for raw values.",a.jsx("br",{}),'ON value: the exact string that means "ON". Leave empty for auto-detect (ON, true, 1).']})]})]})]}),s==="tasmota"&&a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"IP Address *"}),a.jsxs("div",{className:"flex gap-2",children:[a.jsx("input",{type:"text",value:u,onChange:Ee=>{d(Ee.target.value),Oe(null)},placeholder:"192.168.1.100",className:"flex-1 px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none"}),a.jsxs(Ce,{type:"button",variant:"secondary",onClick:()=>dt.mutate(),disabled:!u.trim()||dt.isPending,children:[dt.isPending?a.jsx(it,{className:"w-4 h-4 animate-spin"}):a.jsx(Qg,{className:"w-4 h-4"}),"Test"]})]})]}),s==="tasmota"&&Ue&&a.jsx("div",{className:`p-3 rounded-lg flex items-center gap-2 ${Ue.success?"bg-bambu-green/20 border border-bambu-green/50 text-bambu-green":"bg-red-500/20 border border-red-500/50 text-red-400"}`,children:Ue.success?a.jsxs(a.Fragment,{children:[a.jsx(gr,{className:"w-5 h-5"}),a.jsxs("div",{children:[a.jsx("p",{className:"font-medium",children:"Connected!"}),a.jsxs("p",{className:"text-sm opacity-80",children:[Ue.device_name&&`Device: ${Ue.device_name} - `,"State: ",Ue.state]})]})]}):a.jsxs(a.Fragment,{children:[a.jsx(Rf,{className:"w-5 h-5"}),a.jsx("span",{children:n("smartPlugs.addSmartPlug.connectionFailed")})]})}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Name *"}),a.jsx("input",{type:"text",value:l,onChange:Ee=>c(Ee.target.value),placeholder:n("smartPlugs.addSmartPlug.placeholders.plugName"),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none"})]}),s==="tasmota"&&a.jsxs(a.Fragment,{children:[a.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Username"}),a.jsx("input",{type:"text",value:h,onChange:Ee=>f(Ee.target.value),placeholder:"admin",className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none"})]}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Password"}),a.jsx("input",{type:"password",value:p,onChange:Ee=>x(Ee.target.value),placeholder:"********",className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none"})]})]}),a.jsx("p",{className:"text-xs text-bambu-gray -mt-2",children:"Leave empty if your Tasmota device doesn't require authentication"})]}),s!=="mqtt"&&a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Link to Printer"}),a.jsxs("select",{value:xe??"",onChange:Ee=>be(Ee.target.value?Number(Ee.target.value):null),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",children:[a.jsx("option",{value:"",children:"No printer (manual control only)"}),ze?.map(Ee=>a.jsx("option",{value:Ee.id,children:Ee.name},Ee.id))]}),a.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:"Linking enables automatic on/off when prints start/complete"})]}),a.jsxs("div",{className:"border-t border-bambu-dark-tertiary pt-4",children:[a.jsxs("div",{className:"flex items-center justify-between mb-3",children:[a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx(Xg,{className:"w-4 h-4 text-bambu-green"}),a.jsx("span",{className:"text-white font-medium",children:"Power Alerts"})]}),a.jsxs("label",{className:"relative inline-flex items-center cursor-pointer",children:[a.jsx("input",{type:"checkbox",checked:we,onChange:Ee=>ye(Ee.target.checked),className:"sr-only peer"}),a.jsx("div",{className:"w-11 h-6 bg-bambu-dark-tertiary peer-focus:outline-none rounded-full peer peer-checked:after:translate-x-full peer-checked:after:border-white after:content-[''] after:absolute after:top-[2px] after:left-[2px] after:bg-white after:rounded-full after:h-5 after:w-5 after:transition-all peer-checked:bg-bambu-green"})]})]}),we&&a.jsxs("div",{className:"space-y-3",children:[a.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Alert if above (W)"}),a.jsx("input",{type:"number",value:le,onChange:Ee=>Le(Ee.target.value),placeholder:"e.g. 200",min:"0",max:"5000",className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none"})]}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Alert if below (W)"}),a.jsx("input",{type:"number",value:Me,onChange:Ee=>$e(Ee.target.value),placeholder:"e.g. 10",min:"0",max:"5000",className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none"})]})]}),a.jsx("p",{className:"text-xs text-bambu-gray",children:"Get notified when power consumption crosses these thresholds. Leave empty to disable that direction."})]})]}),s!=="mqtt"&&a.jsxs("div",{className:"border-t border-bambu-dark-tertiary pt-4",children:[a.jsxs("div",{className:"flex items-center justify-between mb-3",children:[a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx(Wn,{className:"w-4 h-4 text-bambu-green"}),a.jsx("span",{className:"text-white font-medium",children:"Daily Schedule"})]}),a.jsxs("label",{className:"relative inline-flex items-center cursor-pointer",children:[a.jsx("input",{type:"checkbox",checked:Ae,onChange:Ee=>Je(Ee.target.checked),className:"sr-only peer"}),a.jsx("div",{className:"w-11 h-6 bg-bambu-dark-tertiary peer-focus:outline-none rounded-full peer peer-checked:after:translate-x-full peer-checked:after:border-white after:content-[''] after:absolute after:top-[2px] after:left-[2px] after:bg-white after:rounded-full after:h-5 after:w-5 after:transition-all peer-checked:bg-bambu-green"})]})]}),Ae&&a.jsxs("div",{className:"space-y-3",children:[a.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Turn On at"}),a.jsx("input",{type:"time",value:Pe,onChange:Ee=>Xe(Ee.target.value),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none"})]}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Turn Off at"}),a.jsx("input",{type:"time",value:De,onChange:Ee=>Re(Ee.target.value),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none"})]})]}),a.jsx("p",{className:"text-xs text-bambu-gray",children:"Automatically turn the plug on/off at these times daily. Leave empty to skip that action."})]})]}),a.jsx("div",{className:"border-t border-bambu-dark-tertiary pt-4",children:a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx(xv,{className:"w-4 h-4 text-bambu-green"}),a.jsxs("div",{children:[a.jsx("span",{className:"text-white font-medium",children:"Show in Switchbar"}),a.jsx("p",{className:"text-xs text-bambu-gray",children:"Quick access from sidebar"})]})]}),a.jsxs("label",{className:"relative inline-flex items-center cursor-pointer",children:[a.jsx("input",{type:"checkbox",checked:qe,onChange:Ee=>pt(Ee.target.checked),className:"sr-only peer"}),a.jsx("div",{className:"w-11 h-6 bg-bambu-dark-tertiary peer-focus:outline-none rounded-full peer peer-checked:after:translate-x-full peer-checked:after:border-white after:content-[''] after:absolute after:top-[2px] after:left-[2px] after:bg-white after:rounded-full after:h-5 after:w-5 after:transition-all peer-checked:bg-bambu-green"})]})]})}),s==="homeassistant"&&a.jsx("div",{className:"border-t border-bambu-dark-tertiary pt-4",children:a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx(Xl,{className:"w-4 h-4 text-bambu-green"}),a.jsxs("div",{children:[a.jsx("span",{className:"text-white font-medium",children:"Show on Printer Card"}),a.jsx("p",{className:"text-xs text-bambu-gray",children:"Display button on printer card"})]})]}),a.jsxs("label",{className:"relative inline-flex items-center cursor-pointer",children:[a.jsx("input",{type:"checkbox",checked:At,onChange:Ee=>Rt(Ee.target.checked),className:"sr-only peer"}),a.jsx("div",{className:"w-11 h-6 bg-bambu-dark-tertiary peer-focus:outline-none rounded-full peer peer-checked:after:translate-x-full peer-checked:after:border-white after:content-[''] after:absolute after:top-[2px] after:left-[2px] after:bg-white after:rounded-full after:h-5 after:w-5 after:transition-all peer-checked:bg-bambu-green"})]})]})}),a.jsxs("div",{className:"flex gap-3 pt-2",children:[a.jsx(Ce,{type:"button",variant:"secondary",onClick:e,className:"flex-1",children:"Cancel"}),a.jsxs(Ce,{type:"submit",disabled:Ve,className:"flex-1",children:[Ve?a.jsx(it,{className:"w-4 h-4 animate-spin"}):a.jsx(bs,{className:"w-4 h-4"}),i?"Save":"Add"]})]})]})]})})}function zn({checked:t,onChange:e,disabled:n}){const r=i=>{i.preventDefault(),i.stopPropagation(),n||e(!t)};return a.jsx("button",{type:"button",role:"switch","aria-checked":t,disabled:n,onClick:r,className:`relative inline-flex w-11 h-7 md:w-9 md:h-5 rounded-full transition-colors flex-shrink-0 focus:outline-none focus:ring-2 focus:ring-bambu-green focus:ring-offset-2 focus:ring-offset-bambu-dark ${n?"bg-bambu-dark-tertiary/50 cursor-not-allowed opacity-50":t?"bg-bambu-green cursor-pointer":"bg-bambu-dark-tertiary cursor-pointer hover:bg-bambu-dark-tertiary/80"}`,children:a.jsx("span",{className:`pointer-events-none absolute top-[3px] md:top-[2px] left-[3px] md:left-[2px] w-5 h-5 md:w-4 md:h-4 bg-white rounded-full shadow transition-transform duration-200 ease-in-out ${t?"translate-x-4":"translate-x-0"}`})})}const qQe={callmebot:"CallMeBot/WhatsApp",ntfy:"ntfy",pushover:"Pushover",telegram:"Telegram",email:"Email",discord:"Discord",webhook:"Webhook"};function WQe({provider:t,onEdit:e}){const n=tn(),[r,i]=w.useState(!1),[s,o]=w.useState(!1),[l,c]=w.useState(null),{data:u}=Ze({queryKey:["printers"],queryFn:re.getPrinters}),d=u?.find(y=>y.id===t.printer_id),h=ot({mutationFn:y=>re.updateNotificationProvider(t.id,y),onSuccess:()=>{n.invalidateQueries({queryKey:["notification-providers"]})}}),f=ot({mutationFn:()=>re.deleteNotificationProvider(t.id),onSuccess:()=>{n.invalidateQueries({queryKey:["notification-providers"]})}}),p=ot({mutationFn:()=>re.testNotificationProvider(t.id),onSuccess:y=>{c(y),n.invalidateQueries({queryKey:["notification-providers"]})},onError:y=>{c({success:!1,message:y.message})}}),x=y=>y||"";return a.jsxs(a.Fragment,{children:[a.jsx(vt,{className:"relative",children:a.jsxs(Nt,{className:"p-4",children:[a.jsxs("div",{className:"flex items-start justify-between mb-3",children:[a.jsxs("div",{className:"flex items-center gap-3",children:[a.jsx("div",{className:`p-2 rounded-lg ${t.enabled?"bg-bambu-green/20":"bg-bambu-dark"}`,children:a.jsx(Xg,{className:`w-5 h-5 ${t.enabled?"text-bambu-green":"text-bambu-gray"}`})}),a.jsxs("div",{children:[a.jsx("h3",{className:"font-medium text-white",children:t.name}),a.jsx("p",{className:"text-sm text-bambu-gray",children:qQe[t.provider_type]||t.provider_type})]})]}),a.jsxs("div",{className:"flex items-center gap-3",children:[t.last_success&&a.jsxs("span",{className:"text-xs text-status-ok hidden sm:inline",children:["Last: ",gb(t.last_success)]}),t.last_error&&t.last_error_at&&(!t.last_success||(Zi(t.last_error_at)?.getTime()||0)>(Zi(t.last_success)?.getTime()||0))&&a.jsx("span",{className:"text-xs text-status-error",title:t.last_error,children:"Error"}),a.jsx(zn,{checked:t.enabled,onChange:y=>h.mutate({enabled:y})})]})]}),d&&a.jsxs("div",{className:"mb-3 px-2 py-1.5 bg-bambu-dark rounded-lg",children:[a.jsx("span",{className:"text-xs text-bambu-gray",children:"Printer: "}),a.jsx("span",{className:"text-sm text-white",children:d.name})]}),!d&&!t.printer_id&&a.jsx("div",{className:"mb-3 px-2 py-1.5 bg-bambu-dark rounded-lg",children:a.jsx("span",{className:"text-xs text-bambu-gray",children:"All printers"})}),a.jsxs("div",{className:"mb-3 flex flex-wrap gap-1",children:[t.on_print_start&&a.jsx("span",{className:"px-2 py-0.5 bg-blue-500/20 text-blue-400 text-xs rounded",children:"Start"}),t.on_plate_not_empty&&a.jsx("span",{className:"px-2 py-0.5 bg-rose-600/20 text-rose-300 text-xs rounded",children:"Plate Check"}),t.on_print_complete&&a.jsx("span",{className:"px-2 py-0.5 bg-bambu-green/20 text-bambu-green text-xs rounded",children:"Complete"}),t.on_print_failed&&a.jsx("span",{className:"px-2 py-0.5 bg-red-500/20 text-red-400 text-xs rounded",children:"Failed"}),t.on_print_stopped&&a.jsx("span",{className:"px-2 py-0.5 bg-orange-500/20 text-orange-400 text-xs rounded",children:"Stopped"}),t.on_print_progress&&a.jsx("span",{className:"px-2 py-0.5 bg-yellow-500/20 text-yellow-400 text-xs rounded",children:"Progress"}),t.on_printer_offline&&a.jsx("span",{className:"px-2 py-0.5 bg-gray-500/20 text-gray-400 text-xs rounded",children:"Offline"}),t.on_printer_error&&a.jsx("span",{className:"px-2 py-0.5 bg-rose-500/20 text-rose-400 text-xs rounded",children:"Error"}),t.on_filament_low&&a.jsx("span",{className:"px-2 py-0.5 bg-cyan-500/20 text-cyan-400 text-xs rounded",children:"Low Filament"}),t.on_maintenance_due&&a.jsx("span",{className:"px-2 py-0.5 bg-purple-500/20 text-purple-400 text-xs rounded",children:"Maintenance"}),t.on_ams_humidity_high&&a.jsx("span",{className:"px-2 py-0.5 bg-blue-600/20 text-blue-300 text-xs rounded",children:"AMS Humidity"}),t.on_ams_temperature_high&&a.jsx("span",{className:"px-2 py-0.5 bg-orange-600/20 text-orange-300 text-xs rounded",children:"AMS Temp"}),t.on_ams_ht_humidity_high&&a.jsx("span",{className:"px-2 py-0.5 bg-cyan-600/20 text-cyan-300 text-xs rounded",children:"AMS-HT Humidity"}),t.on_ams_ht_temperature_high&&a.jsx("span",{className:"px-2 py-0.5 bg-amber-600/20 text-amber-300 text-xs rounded",children:"AMS-HT Temp"}),t.on_bed_cooled&&a.jsx("span",{className:"px-2 py-0.5 bg-teal-500/20 text-teal-400 text-xs rounded",children:"Bed Cooled"}),t.quiet_hours_enabled&&a.jsxs("span",{className:"px-2 py-0.5 bg-indigo-500/20 text-indigo-400 text-xs rounded flex items-center gap-1",children:[a.jsx(j1,{className:"w-3 h-3"}),"Quiet"]}),t.daily_digest_enabled&&a.jsxs("span",{className:"px-2 py-0.5 bg-emerald-500/20 text-emerald-400 text-xs rounded flex items-center gap-1",children:[a.jsx(ii,{className:"w-3 h-3"}),"Digest ",t.daily_digest_time]})]}),a.jsx("div",{className:"mb-3",children:a.jsxs(Ce,{size:"sm",variant:"secondary",disabled:p.isPending,onClick:()=>{c(null),p.mutate()},className:"w-full",children:[p.isPending?a.jsx(it,{className:"w-4 h-4 animate-spin"}):a.jsx(lC,{className:"w-4 h-4"}),"Send Test Notification"]})}),l&&a.jsxs("div",{className:`mb-3 p-2 rounded-lg flex items-center gap-2 text-sm ${l.success?"bg-bambu-green/20 text-bambu-green":"bg-red-500/20 text-red-400"}`,children:[l.success?a.jsx(gr,{className:"w-4 h-4"}):a.jsx(ha,{className:"w-4 h-4"}),a.jsx("span",{children:l.message})]}),a.jsxs("button",{onClick:()=>o(!s),className:"w-full flex items-center justify-between py-2 text-sm text-bambu-gray hover:text-white transition-colors border-t border-bambu-dark-tertiary",children:[a.jsxs("span",{className:"flex items-center gap-2",children:[a.jsx(nd,{className:"w-4 h-4"}),"Event Settings"]}),s?a.jsx(Wl,{className:"w-4 h-4"}):a.jsx(nr,{className:"w-4 h-4"})]}),s&&a.jsxs("div",{className:"pt-3 border-t border-bambu-dark-tertiary space-y-4",children:[a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsxs("div",{children:[a.jsx("p",{className:"text-sm text-white",children:"Enabled"}),a.jsx("p",{className:"text-xs text-bambu-gray",children:"Send notifications from this provider"})]}),a.jsx(zn,{checked:t.enabled,onChange:y=>h.mutate({enabled:y})})]}),a.jsxs("div",{className:"space-y-2",children:[a.jsx("p",{className:"text-xs text-bambu-gray uppercase tracking-wide",children:"Print Events"}),a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsx("p",{className:"text-sm text-white",children:"Print Started"}),a.jsx(zn,{checked:t.on_print_start,onChange:y=>h.mutate({on_print_start:y})})]}),a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsxs("div",{children:[a.jsx("p",{className:"text-sm text-white",children:"Plate Not Empty"}),a.jsx("p",{className:"text-xs text-bambu-gray",children:"Objects detected before print"})]}),a.jsx(zn,{checked:t.on_plate_not_empty??!0,onChange:y=>h.mutate({on_plate_not_empty:y})})]}),a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsx("p",{className:"text-sm text-white",children:"Print Completed"}),a.jsx(zn,{checked:t.on_print_complete,onChange:y=>h.mutate({on_print_complete:y})})]}),a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsxs("div",{children:[a.jsx("p",{className:"text-sm text-white",children:"Bed Cooled"}),a.jsx("p",{className:"text-xs text-bambu-gray",children:"Bed cooled below threshold after print"})]}),a.jsx(zn,{checked:t.on_bed_cooled??!1,onChange:y=>h.mutate({on_bed_cooled:y})})]}),a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsx("p",{className:"text-sm text-white",children:"Print Failed"}),a.jsx(zn,{checked:t.on_print_failed,onChange:y=>h.mutate({on_print_failed:y})})]}),a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsx("p",{className:"text-sm text-white",children:"Print Stopped"}),a.jsx(zn,{checked:t.on_print_stopped,onChange:y=>h.mutate({on_print_stopped:y})})]}),a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsxs("div",{children:[a.jsx("p",{className:"text-sm text-white",children:"Progress Milestones"}),a.jsx("p",{className:"text-xs text-bambu-gray",children:"Notify at 25%, 50%, 75%"})]}),a.jsx(zn,{checked:t.on_print_progress,onChange:y=>h.mutate({on_print_progress:y})})]})]}),a.jsxs("div",{className:"space-y-2",children:[a.jsx("p",{className:"text-xs text-bambu-gray uppercase tracking-wide",children:"Printer Status"}),a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsx("p",{className:"text-sm text-white",children:"Printer Offline"}),a.jsx(zn,{checked:t.on_printer_offline,onChange:y=>h.mutate({on_printer_offline:y})})]}),a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsx("p",{className:"text-sm text-white",children:"Printer Error"}),a.jsx(zn,{checked:t.on_printer_error,onChange:y=>h.mutate({on_printer_error:y})})]}),a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsx("p",{className:"text-sm text-white",children:"Low Filament"}),a.jsx(zn,{checked:t.on_filament_low,onChange:y=>h.mutate({on_filament_low:y})})]}),a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsxs("div",{children:[a.jsx("p",{className:"text-sm text-white",children:"Maintenance Due"}),a.jsx("p",{className:"text-xs text-bambu-gray",children:"Notify when maintenance is needed"})]}),a.jsx(zn,{checked:t.on_maintenance_due??!1,onChange:y=>h.mutate({on_maintenance_due:y})})]})]}),a.jsxs("div",{className:"space-y-2",children:[a.jsx("p",{className:"text-xs text-bambu-gray uppercase tracking-wide",children:"AMS Alarms"}),a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsxs("div",{children:[a.jsx("p",{className:"text-sm text-white",children:"AMS Humidity High"}),a.jsx("p",{className:"text-xs text-bambu-gray",children:"Regular AMS humidity exceeds threshold"})]}),a.jsx(zn,{checked:t.on_ams_humidity_high??!1,onChange:y=>h.mutate({on_ams_humidity_high:y})})]}),a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsxs("div",{children:[a.jsx("p",{className:"text-sm text-white",children:"AMS Temperature High"}),a.jsx("p",{className:"text-xs text-bambu-gray",children:"Regular AMS temperature exceeds threshold"})]}),a.jsx(zn,{checked:t.on_ams_temperature_high??!1,onChange:y=>h.mutate({on_ams_temperature_high:y})})]})]}),a.jsxs("div",{className:"space-y-2",children:[a.jsx("p",{className:"text-xs text-bambu-gray uppercase tracking-wide",children:"AMS-HT Alarms"}),a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsxs("div",{children:[a.jsx("p",{className:"text-sm text-white",children:"AMS-HT Humidity High"}),a.jsx("p",{className:"text-xs text-bambu-gray",children:"AMS-HT humidity exceeds threshold"})]}),a.jsx(zn,{checked:t.on_ams_ht_humidity_high??!1,onChange:y=>h.mutate({on_ams_ht_humidity_high:y})})]}),a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsxs("div",{children:[a.jsx("p",{className:"text-sm text-white",children:"AMS-HT Temperature High"}),a.jsx("p",{className:"text-xs text-bambu-gray",children:"AMS-HT temperature exceeds threshold"})]}),a.jsx(zn,{checked:t.on_ams_ht_temperature_high??!1,onChange:y=>h.mutate({on_ams_ht_temperature_high:y})})]})]}),a.jsxs("div",{className:"space-y-2",children:[a.jsx("p",{className:"text-xs text-bambu-gray uppercase tracking-wide",children:"Print Queue"}),a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsxs("div",{children:[a.jsx("p",{className:"text-sm text-white",children:"Job Added"}),a.jsx("p",{className:"text-xs text-bambu-gray",children:"Job added to queue"})]}),a.jsx(zn,{checked:t.on_queue_job_added??!1,onChange:y=>h.mutate({on_queue_job_added:y})})]}),a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsxs("div",{children:[a.jsx("p",{className:"text-sm text-white",children:"Job Assigned"}),a.jsx("p",{className:"text-xs text-bambu-gray",children:"Model-based job assigned to printer"})]}),a.jsx(zn,{checked:t.on_queue_job_assigned??!1,onChange:y=>h.mutate({on_queue_job_assigned:y})})]}),a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsxs("div",{children:[a.jsx("p",{className:"text-sm text-white",children:"Job Started"}),a.jsx("p",{className:"text-xs text-bambu-gray",children:"Queue job started printing"})]}),a.jsx(zn,{checked:t.on_queue_job_started??!1,onChange:y=>h.mutate({on_queue_job_started:y})})]}),a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsxs("div",{children:[a.jsx("p",{className:"text-sm text-white",children:"Job Waiting"}),a.jsx("p",{className:"text-xs text-bambu-gray",children:"Job waiting for filament"})]}),a.jsx(zn,{checked:t.on_queue_job_waiting??!0,onChange:y=>h.mutate({on_queue_job_waiting:y})})]}),a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsxs("div",{children:[a.jsx("p",{className:"text-sm text-white",children:"Job Skipped"}),a.jsx("p",{className:"text-xs text-bambu-gray",children:"Job skipped (previous failed)"})]}),a.jsx(zn,{checked:t.on_queue_job_skipped??!0,onChange:y=>h.mutate({on_queue_job_skipped:y})})]}),a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsxs("div",{children:[a.jsx("p",{className:"text-sm text-white",children:"Job Failed"}),a.jsx("p",{className:"text-xs text-bambu-gray",children:"Job failed to start"})]}),a.jsx(zn,{checked:t.on_queue_job_failed??!0,onChange:y=>h.mutate({on_queue_job_failed:y})})]}),a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsxs("div",{children:[a.jsx("p",{className:"text-sm text-white",children:"Queue Complete"}),a.jsx("p",{className:"text-xs text-bambu-gray",children:"All queue jobs finished"})]}),a.jsx(zn,{checked:t.on_queue_completed??!1,onChange:y=>h.mutate({on_queue_completed:y})})]})]}),a.jsxs("div",{className:"space-y-2",children:[a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx(j1,{className:"w-4 h-4 text-purple-400"}),a.jsx("p",{className:"text-sm text-white",children:"Quiet Hours"})]}),a.jsx(zn,{checked:t.quiet_hours_enabled,onChange:y=>h.mutate({quiet_hours_enabled:y})})]}),t.quiet_hours_enabled&&a.jsxs("div",{className:"pl-4 border-l-2 border-bambu-dark-tertiary space-y-2",children:[a.jsx("p",{className:"text-xs text-bambu-gray",children:"No notifications during these hours"}),a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx(Wn,{className:"w-4 h-4 text-bambu-gray"}),a.jsxs("span",{className:"text-sm text-white",children:[x(t.quiet_hours_start)||"22:00"," - ",x(t.quiet_hours_end)||"07:00"]})]}),a.jsx("p",{className:"text-xs text-bambu-gray",children:"Edit provider to change quiet hours"})]})]}),a.jsxs("div",{className:"space-y-2",children:[a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx(ii,{className:"w-4 h-4 text-emerald-400"}),a.jsx("p",{className:"text-sm text-white",children:"Daily Digest"})]}),a.jsx(zn,{checked:t.daily_digest_enabled,onChange:y=>h.mutate({daily_digest_enabled:y})})]}),t.daily_digest_enabled&&a.jsxs("div",{className:"pl-4 border-l-2 border-bambu-dark-tertiary space-y-2",children:[a.jsx("p",{className:"text-xs text-bambu-gray",children:"Batch notifications into a single daily summary"}),a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx(Wn,{className:"w-4 h-4 text-bambu-gray"}),a.jsxs("span",{className:"text-sm text-white",children:["Send at ",x(t.daily_digest_time)||"08:00"]})]}),a.jsx("p",{className:"text-xs text-bambu-gray",children:"Edit provider to change digest time"})]})]}),a.jsxs("div",{className:"flex gap-2 pt-2",children:[a.jsxs(Ce,{size:"sm",variant:"secondary",onClick:()=>e(t),className:"flex-1",children:[a.jsx(af,{className:"w-4 h-4"}),"Edit"]}),a.jsx(Ce,{size:"sm",variant:"secondary",onClick:()=>i(!0),className:"text-red-400 hover:text-red-300",children:a.jsx(Jt,{className:"w-4 h-4"})})]})]})]})}),r&&a.jsx(vn,{title:"Delete Notification Provider",message:`Are you sure you want to delete "${t.name}"? This cannot be undone.`,confirmText:"Delete",variant:"danger",onConfirm:()=>{f.mutate(),i(!1)},onCancel:()=>i(!1)})]})}const aK=[{value:"email",label:"Email",description:"SMTP email notifications"},{value:"telegram",label:"Telegram",description:"Notifications via Telegram bot"},{value:"discord",label:"Discord",description:"Send to Discord channel via webhook"},{value:"ntfy",label:"ntfy",description:"Free, self-hostable push notifications"},{value:"pushover",label:"Pushover",description:"Simple, reliable push notifications"},{value:"callmebot",label:"CallMeBot/WhatsApp",description:"Free WhatsApp notifications via CallMeBot"},{value:"webhook",label:"Webhook",description:"Generic HTTP POST to any URL"}];function KQe({provider:t,onClose:e}){const n=tn(),r=!!t,[i,s]=w.useState(t?.name||""),[o,l]=w.useState(t?.provider_type||"email"),[c,u]=w.useState(t?.printer_id||null),[d,h]=w.useState(t?.quiet_hours_enabled||!1),[f,p]=w.useState(t?.quiet_hours_start||"22:00"),[x,y]=w.useState(t?.quiet_hours_end||"07:00"),[b,v]=w.useState(t?.daily_digest_enabled||!1),[S,N]=w.useState(t?.daily_digest_time||"08:00"),[A,C]=w.useState(t?.on_print_start??!1),[T,k]=w.useState(t?.on_print_complete??!0),[j,E]=w.useState(t?.on_print_failed??!0),[P,U]=w.useState(t?.on_print_stopped??!0),[O,B]=w.useState(t?.on_print_progress??!1),[R,G]=w.useState(t?.on_printer_offline??!1),[q,z]=w.useState(t?.on_printer_error??!1),[K,Y]=w.useState(t?.on_filament_low??!1),[oe,$]=w.useState(t?.on_maintenance_due??!1),[X,ee]=w.useState(t?.on_bed_cooled??!1),[J,_e]=w.useState(t?.config?Object.fromEntries(Object.entries(t.config).map(([Z,Ne])=>[Z,String(Ne)])):{}),[pe,me]=w.useState(null),[je,de]=w.useState(null),{data:ce}=Ze({queryKey:["printers"],queryFn:re.getPrinters});w.useEffect(()=>{const Z=Ne=>{Ne.key==="Escape"&&e()};return window.addEventListener("keydown",Z),()=>window.removeEventListener("keydown",Z)},[e]);const Se=ot({mutationFn:()=>re.testNotificationConfig({provider_type:o,config:J}),onSuccess:Z=>{me(Z),de(null)},onError:Z=>{me({success:!1,message:Z.message})}}),ie=ot({mutationFn:Z=>re.createNotificationProvider(Z),onSuccess:()=>{n.invalidateQueries({queryKey:["notification-providers"]}),e()},onError:Z=>{de(Z.message)}}),Fe=ot({mutationFn:Z=>re.updateNotificationProvider(t.id,Z),onSuccess:()=>{n.invalidateQueries({queryKey:["notification-providers"]}),e()},onError:Z=>{de(Z.message)}}),V=Z=>{if(Z.preventDefault(),de(null),!i.trim()){de("Name is required");return}const Ne=Q(o);for(const fe of Ne)if(!J[fe.key]?.trim()){de(`${fe.label} is required`);return}const ve={name:i.trim(),provider_type:o,config:J,printer_id:c,quiet_hours_enabled:d,quiet_hours_start:d?f:null,quiet_hours_end:d?x:null,daily_digest_enabled:b,daily_digest_time:b?S:null,on_print_start:A,on_print_complete:T,on_print_failed:j,on_print_stopped:P,on_print_progress:O,on_printer_offline:R,on_printer_error:q,on_filament_low:K,on_maintenance_due:oe,on_bed_cooled:X};r?Fe.mutate(ve):ie.mutate(ve)},W=ie.isPending||Fe.isPending,ue=Z=>{switch(Z){case"callmebot":return[{key:"phone",label:"Phone Number",placeholder:"+1234567890",type:"text",required:!0},{key:"apikey",label:"API Key",placeholder:"Your CallMeBot API key",type:"text",required:!0}];case"ntfy":return[{key:"server",label:"Server URL",placeholder:"https://ntfy.sh",type:"text",required:!1},{key:"topic",label:"Topic",placeholder:"my-bambuddy",type:"text",required:!0},{key:"auth_token",label:"Auth Token",placeholder:"Optional authentication",type:"password",required:!1}];case"pushover":return[{key:"user_key",label:"User Key",placeholder:"Your Pushover user key",type:"text",required:!0},{key:"app_token",label:"App Token",placeholder:"Your Pushover app token",type:"text",required:!0},{key:"priority",label:"Priority",placeholder:"0 (normal)",type:"number",required:!1}];case"telegram":return[{key:"bot_token",label:"Bot Token",placeholder:"Bot token from @BotFather",type:"password",required:!0},{key:"chat_id",label:"Chat ID",placeholder:"Your chat or group ID",type:"text",required:!0}];case"email":return[{key:"smtp_server",label:"SMTP Server",placeholder:"smtp.gmail.com",type:"text",required:!0},{key:"smtp_port",label:"SMTP Port",placeholder:"587",type:"number",required:!1},{key:"security",label:"Security",type:"select",required:!1,options:[{value:"starttls",label:"STARTTLS (Port 587)"},{value:"ssl",label:"SSL/TLS (Port 465)"},{value:"none",label:"None (Port 25)"}]},{key:"auth_enabled",label:"Authentication",type:"select",required:!1,options:[{value:"true",label:"Enabled"},{value:"false",label:"Disabled"}]},{key:"username",label:"Username",placeholder:"your@email.com",type:"text",required:!1},{key:"password",label:"Password",placeholder:"App password",type:"password",required:!1},{key:"from_email",label:"From Email",placeholder:"your@email.com",type:"text",required:!0},{key:"to_email",label:"To Email",placeholder:"recipient@email.com",type:"text",required:!0}];case"discord":return[{key:"webhook_url",label:"Webhook URL",placeholder:"https://discord.com/api/webhooks/...",type:"text",required:!0}];case"webhook":return[{key:"webhook_url",label:"Webhook URL",placeholder:"https://example.com/webhook",type:"text",required:!0},{key:"payload_format",label:"Payload Format",type:"select",required:!1,options:[{value:"generic",label:"Generic JSON"},{value:"slack",label:"Slack / Mattermost"}]},{key:"auth_header",label:"Authorization",placeholder:"Bearer token (optional)",type:"password",required:!1},{key:"field_title",label:"Title Field Name",placeholder:"title",type:"text",required:!1,showIf:Ne=>Ne.payload_format!=="slack"},{key:"field_message",label:"Message Field Name",placeholder:"message",type:"text",required:!1,showIf:Ne=>Ne.payload_format!=="slack"}];default:return[]}},Q=Z=>ue(Z).filter(Ne=>Ne.required),se=ue(o);return a.jsx("div",{className:"fixed inset-0 bg-black/70 flex items-center justify-center z-50 p-4 overflow-y-auto",onClick:e,children:a.jsxs("div",{className:"bg-bambu-dark-secondary rounded-xl border border-bambu-dark-tertiary w-full max-w-lg my-8 max-h-[90vh] overflow-y-auto",onClick:Z=>Z.stopPropagation(),children:[a.jsxs("div",{className:"flex items-center justify-between px-6 py-4 border-b border-bambu-dark-tertiary",children:[a.jsx("h2",{className:"text-lg font-semibold text-white",children:r?"Edit Notification Provider":"Add Notification Provider"}),a.jsx("button",{onClick:e,className:"text-bambu-gray hover:text-white transition-colors",children:a.jsx(Ft,{className:"w-5 h-5"})})]}),a.jsxs("form",{onSubmit:V,className:"p-6 space-y-4",children:[je&&a.jsx("div",{className:"p-3 bg-red-500/20 border border-red-500/50 rounded-lg text-sm text-red-400",children:je}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Name *"}),a.jsx("input",{type:"text",value:i,onChange:Z=>s(Z.target.value),placeholder:"My Notifications",className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none"})]}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Provider Type *"}),a.jsx("select",{value:o,onChange:Z=>{l(Z.target.value),_e({}),me(null)},disabled:r,className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none disabled:opacity-50",children:aK.map(Z=>a.jsx("option",{value:Z.value,children:Z.label},Z.value))}),a.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:aK.find(Z=>Z.value===o)?.description})]}),a.jsxs("div",{className:"space-y-3",children:[a.jsx("p",{className:"text-sm text-bambu-gray",children:"Configuration"}),se.filter(Z=>!("showIf"in Z)||Z.showIf?.(J)!==!1).map(Z=>a.jsxs("div",{children:[a.jsxs("label",{className:"block text-sm text-bambu-gray mb-1",children:[Z.label," ",Z.required&&"*"]}),Z.type==="select"&&"options"in Z&&Z.options?a.jsx("select",{value:J[Z.key]||Z.options[0]?.value||"",onChange:Ne=>{_e({...J,[Z.key]:Ne.target.value}),me(null)},className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",children:Z.options.map(Ne=>a.jsx("option",{value:Ne.value,children:Ne.label},Ne.value))}):a.jsx("input",{type:Z.type,value:J[Z.key]||"",onChange:Ne=>{_e({...J,[Z.key]:Ne.target.value}),me(null)},placeholder:Z.placeholder,className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none"})]},Z.key))]}),a.jsx("div",{className:"flex gap-2",children:a.jsxs(Ce,{type:"button",variant:"secondary",onClick:()=>{me(null),Se.mutate()},disabled:Se.isPending||!J[Q(o)[0]?.key],className:"flex-1",children:[Se.isPending?a.jsx(it,{className:"w-4 h-4 animate-spin"}):a.jsx(lC,{className:"w-4 h-4"}),"Test Configuration"]})}),pe&&a.jsx("div",{className:`p-3 rounded-lg flex items-center gap-2 ${pe.success?"bg-bambu-green/20 border border-bambu-green/50 text-bambu-green":"bg-red-500/20 border border-red-500/50 text-red-400"}`,children:pe.success?a.jsxs(a.Fragment,{children:[a.jsx(gr,{className:"w-5 h-5"}),a.jsx("span",{children:pe.message})]}):a.jsxs(a.Fragment,{children:[a.jsx(ha,{className:"w-5 h-5"}),a.jsx("span",{children:pe.message})]})}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Printer Filter"}),a.jsxs("select",{value:c??"",onChange:Z=>u(Z.target.value?Number(Z.target.value):null),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",children:[a.jsx("option",{value:"",children:"All printers"}),ce?.map(Z=>a.jsx("option",{value:Z.id,children:Z.name},Z.id))]}),a.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:"Only send notifications for events from this printer"})]}),a.jsxs("div",{className:"space-y-2",children:[a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsx("label",{className:"text-sm text-white",children:"Quiet Hours (Do Not Disturb)"}),a.jsx(zn,{checked:d,onChange:h})]}),d&&a.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[a.jsxs("div",{children:[a.jsx("label",{className:"block text-xs text-bambu-gray mb-1",children:"Start"}),a.jsx("input",{type:"time",value:f,onChange:Z=>p(Z.target.value),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none"})]}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-xs text-bambu-gray mb-1",children:"End"}),a.jsx("input",{type:"time",value:x,onChange:Z=>y(Z.target.value),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none"})]})]})]}),a.jsxs("div",{className:"space-y-2",children:[a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsxs("div",{children:[a.jsx("label",{className:"text-sm text-white",children:"Daily Digest"}),a.jsx("p",{className:"text-xs text-bambu-gray",children:"Batch notifications into a single daily summary"})]}),a.jsx(zn,{checked:b,onChange:v})]}),b&&a.jsxs("div",{children:[a.jsx("label",{className:"block text-xs text-bambu-gray mb-1",children:"Send digest at"}),a.jsx("input",{type:"time",value:S,onChange:Z=>N(Z.target.value),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none"}),a.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:"Events will be collected and sent as a single summary at this time"})]})]}),a.jsxs("div",{className:"space-y-3",children:[a.jsx("p",{className:"text-sm text-bambu-gray",children:"Notification Events"}),a.jsxs("div",{className:"space-y-2 p-3 bg-bambu-dark rounded-lg",children:[a.jsx("p",{className:"text-xs text-bambu-gray uppercase tracking-wide mb-2",children:"Print Events"}),a.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsx("span",{className:"text-sm text-white",children:"Start"}),a.jsx(zn,{checked:A,onChange:C})]}),a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsx("span",{className:"text-sm text-white",children:"Complete"}),a.jsx(zn,{checked:T,onChange:k})]}),a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsx("span",{className:"text-sm text-white",children:"Failed"}),a.jsx(zn,{checked:j,onChange:E})]}),a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsx("span",{className:"text-sm text-white",children:"Stopped"}),a.jsx(zn,{checked:P,onChange:U})]}),a.jsxs("div",{className:"flex items-center justify-between col-span-2",children:[a.jsxs("div",{children:[a.jsx("span",{className:"text-sm text-white",children:"Progress"}),a.jsx("span",{className:"text-xs text-bambu-gray ml-1",children:"(25%, 50%, 75%)"})]}),a.jsx(zn,{checked:O,onChange:B})]}),a.jsxs("div",{className:"flex items-center justify-between col-span-2",children:[a.jsxs("div",{children:[a.jsx("span",{className:"text-sm text-white",children:"Bed Cooled"}),a.jsx("span",{className:"text-xs text-bambu-gray ml-1",children:"(after print completes)"})]}),a.jsx(zn,{checked:X,onChange:ee})]})]})]}),a.jsxs("div",{className:"space-y-2 p-3 bg-bambu-dark rounded-lg",children:[a.jsx("p",{className:"text-xs text-bambu-gray uppercase tracking-wide mb-2",children:"Printer Status"}),a.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsx("span",{className:"text-sm text-white",children:"Offline"}),a.jsx(zn,{checked:R,onChange:G})]}),a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsx("span",{className:"text-sm text-white",children:"Error"}),a.jsx(zn,{checked:q,onChange:z})]}),a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsx("span",{className:"text-sm text-white",children:"Low Filament"}),a.jsx(zn,{checked:K,onChange:Y})]}),a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsx("span",{className:"text-sm text-white",children:"Maintenance"}),a.jsx(zn,{checked:oe,onChange:$})]})]})]})]}),a.jsxs("div",{className:"flex gap-3 pt-2",children:[a.jsx(Ce,{type:"button",variant:"secondary",onClick:e,className:"flex-1",children:"Cancel"}),a.jsxs(Ce,{type:"submit",disabled:W,className:"flex-1",children:[W?a.jsx(it,{className:"w-4 h-4 animate-spin"}):a.jsx(bs,{className:"w-4 h-4"}),r?"Save":"Add"]})]})]})]})})}function XQe({template:t,onClose:e}){const n=tn(),r=w.useRef(null),[i,s]=w.useState(t.title_template),[o,l]=w.useState(t.body_template),[c,u]=w.useState(null),[d,h]=w.useState(!0),{data:f}=Ze({queryKey:["template-variables"],queryFn:re.getTemplateVariables}),p=f?.find(C=>C.event_type===t.event_type),{data:x,isLoading:y}=Ze({queryKey:["template-preview",t.event_type,i,o],queryFn:()=>re.previewTemplate({event_type:t.event_type,title_template:i,body_template:o}),enabled:d&&i.length>0&&o.length>0});w.useEffect(()=>{const C=T=>{T.key==="Escape"&&e()};return window.addEventListener("keydown",C),()=>window.removeEventListener("keydown",C)},[e]);const b=ot({mutationFn:C=>re.updateNotificationTemplate(t.id,C),onSuccess:()=>{n.invalidateQueries({queryKey:["notification-templates"]}),e()},onError:C=>{u(C.message)}}),v=ot({mutationFn:()=>re.resetNotificationTemplate(t.id),onSuccess:C=>{s(C.title_template),l(C.body_template),n.invalidateQueries({queryKey:["notification-templates"]})},onError:C=>{u(C.message)}}),S=C=>{if(C.preventDefault(),u(null),!i.trim()){u("Title is required");return}if(!o.trim()){u("Body is required");return}b.mutate({title_template:i,body_template:o})},N=C=>{const T=r.current;if(!T)return;const k=T.selectionStart,j=T.selectionEnd,E=o,P=E.substring(0,k),U=E.substring(j),O=P+`{${C}}`+U;l(O),setTimeout(()=>{T.focus();const B=k+C.length+2;T.setSelectionRange(B,B)},0)},A=i!==t.title_template||o!==t.body_template;return a.jsx("div",{className:"fixed inset-0 bg-black/80 flex items-center justify-center z-50 p-4",children:a.jsxs("div",{className:"bg-bambu-dark-secondary rounded-lg w-full max-w-2xl max-h-[90vh] flex flex-col",children:[a.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-bambu-dark-tertiary shrink-0",children:[a.jsxs("h2",{className:"text-lg font-semibold text-white",children:["Edit Template: ",t.name]}),a.jsx("button",{onClick:e,className:"p-1 hover:bg-bambu-dark-tertiary rounded transition-colors",children:a.jsx(Ft,{className:"w-5 h-5 text-bambu-gray"})})]}),a.jsxs("form",{onSubmit:S,className:"flex-1 overflow-y-auto p-4 space-y-4",children:[c&&a.jsx("div",{className:"p-3 bg-red-500/20 border border-red-500/50 rounded text-red-400 text-sm",children:c}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm font-medium text-bambu-gray mb-1",children:"Title"}),a.jsx("input",{type:"text",value:i,onChange:C=>s(C.target.value),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded text-white focus:outline-none focus:ring-1 focus:ring-bambu-green",placeholder:"Notification title..."})]}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm font-medium text-bambu-gray mb-1",children:"Body"}),a.jsx("textarea",{ref:r,value:o,onChange:C=>l(C.target.value),rows:4,className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded text-white focus:outline-none focus:ring-1 focus:ring-bambu-green font-mono text-sm resize-none",placeholder:"Notification body..."})]}),p&&a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm font-medium text-bambu-gray mb-2",children:"Available Variables"}),a.jsx("div",{className:"flex flex-wrap gap-2",children:p.variables.map(C=>a.jsxs("button",{type:"button",onClick:()=>N(C),className:"inline-flex items-center gap-1 px-2 py-1 bg-bambu-dark hover:bg-bambu-dark-tertiary border border-bambu-dark-tertiary rounded text-xs text-bambu-gray hover:text-white transition-colors",children:[a.jsx(ar,{className:"w-3 h-3"}),C]},C))}),a.jsx("p",{className:"text-xs text-bambu-gray/60 mt-1",children:"Click to insert at cursor position in body"})]}),a.jsxs("div",{children:[a.jsxs("div",{className:"flex items-center justify-between mb-2",children:[a.jsxs("label",{className:"text-sm font-medium text-bambu-gray flex items-center gap-2",children:[a.jsx(Xl,{className:"w-4 h-4"}),"Live Preview"]}),a.jsx("button",{type:"button",onClick:()=>h(!d),className:"text-xs text-bambu-green hover:text-bambu-green-light",children:d?"Hide":"Show"})]}),d&&a.jsx("div",{className:"bg-bambu-dark border border-bambu-dark-tertiary rounded p-3 space-y-2",children:y?a.jsxs("div",{className:"flex items-center gap-2 text-bambu-gray text-sm",children:[a.jsx(it,{className:"w-4 h-4 animate-spin"}),"Loading preview..."]}):x?a.jsxs(a.Fragment,{children:[a.jsxs("div",{children:[a.jsx("span",{className:"text-xs text-bambu-gray",children:"Title:"}),a.jsx("div",{className:"text-white font-medium",children:x.title})]}),a.jsxs("div",{children:[a.jsx("span",{className:"text-xs text-bambu-gray",children:"Body:"}),a.jsx("div",{className:"text-white whitespace-pre-wrap text-sm",children:x.body})]})]}):a.jsx("div",{className:"text-bambu-gray text-sm",children:"Enter template content to see preview"})})]})]}),a.jsxs("div",{className:"flex items-center justify-between p-4 border-t border-bambu-dark-tertiary shrink-0",children:[a.jsxs(Ce,{type:"button",variant:"ghost",onClick:()=>v.mutate(),disabled:v.isPending,className:"text-orange-400 hover:text-orange-300",children:[v.isPending?a.jsx(it,{className:"w-4 h-4 animate-spin mr-2"}):a.jsx(Ro,{className:"w-4 h-4 mr-2"}),"Reset to Default"]}),a.jsxs("div",{className:"flex gap-2",children:[a.jsx(Ce,{type:"button",variant:"secondary",onClick:e,children:"Cancel"}),a.jsxs(Ce,{onClick:S,disabled:b.isPending||!A,children:[b.isPending?a.jsx(it,{className:"w-4 h-4 animate-spin mr-2"}):a.jsx(bs,{className:"w-4 h-4 mr-2"}),"Save"]})]})]})]})})}const YQe={print_start:"Print Started",print_complete:"Print Complete",print_failed:"Print Failed",print_stopped:"Print Stopped",print_progress:"Progress",printer_offline:"Printer Offline",printer_error:"Printer Error",filament_low:"Low Filament",maintenance_due:"Maintenance Due",test:"Test"},QQe={print_start:"text-blue-400",print_complete:"text-bambu-green",print_failed:"text-red-400",print_stopped:"text-orange-400",print_progress:"text-yellow-400",printer_offline:"text-gray-400",printer_error:"text-rose-400",filament_low:"text-cyan-400",maintenance_due:"text-purple-400",test:"text-bambu-gray"};function ZQe({onClose:t}){const e=tn(),{showToast:n}=hn(),[r,i]=w.useState(7),[s,o]=w.useState(null),[l,c]=w.useState(!1),{data:u}=Ze({queryKey:["settings"],queryFn:re.getSettings}),d=u?.time_format||"system",{data:h,isLoading:f,refetch:p,isRefetching:x}=Ze({queryKey:["notification-logs",r,l],queryFn:()=>re.getNotificationLogs({days:r,limit:100,success:l?!1:void 0})}),{data:y}=Ze({queryKey:["notification-log-stats",r],queryFn:()=>re.getNotificationLogStats(r)}),b=ot({mutationFn:()=>re.clearNotificationLogs(30),onSuccess:S=>{n(S.message,"success"),e.invalidateQueries({queryKey:["notification-logs"]}),e.invalidateQueries({queryKey:["notification-log-stats"]})},onError:S=>{n(`Failed to clear logs: ${S.message}`,"error")}}),v=S=>{const N=Zi(S);if(!N)return"";const C=new Date().getTime()-N.getTime();return C<6e4?"Just now":C<36e5?`${Math.floor(C/6e4)}m ago`:C<864e5?`${Math.floor(C/36e5)}h ago`:N.toLocaleDateString()+" "+sge(N,d)};return a.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4",children:a.jsxs("div",{className:"bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg w-full max-w-3xl max-h-[85vh] flex flex-col",children:[a.jsxs("div",{className:"p-4 border-b border-bambu-dark-tertiary flex items-center justify-between",children:[a.jsxs("div",{className:"flex items-center gap-3",children:[a.jsx(N0,{className:"w-5 h-5 text-bambu-green"}),a.jsx("h2",{className:"text-lg font-semibold text-white",children:"Notification Log"})]}),a.jsx("button",{onClick:t,className:"text-bambu-gray hover:text-white transition-colors",children:"×"})]}),y&&a.jsx("div",{className:"px-4 py-3 border-b border-bambu-dark-tertiary bg-bambu-dark/50",children:a.jsxs("div",{className:"flex items-center gap-6 text-sm",children:[a.jsxs("span",{className:"text-bambu-gray",children:["Last ",r," days: ",a.jsx("span",{className:"text-white font-medium",children:y.total})," notifications"]}),a.jsxs("span",{className:"flex items-center gap-1 text-bambu-green",children:[a.jsx(gr,{className:"w-4 h-4"}),y.success_count," sent"]}),y.failure_count>0&&a.jsxs("span",{className:"flex items-center gap-1 text-red-400",children:[a.jsx(ha,{className:"w-4 h-4"}),y.failure_count," failed"]})]})}),a.jsxs("div",{className:"px-4 py-3 border-b border-bambu-dark-tertiary flex items-center gap-4",children:[a.jsxs("select",{value:r,onChange:S=>i(Number(S.target.value)),className:"px-3 py-1.5 bg-bambu-dark border border-bambu-dark-tertiary rounded text-white text-sm focus:outline-none focus:ring-1 focus:ring-bambu-green",children:[a.jsx("option",{value:1,children:"Last 24 hours"}),a.jsx("option",{value:7,children:"Last 7 days"}),a.jsx("option",{value:30,children:"Last 30 days"}),a.jsx("option",{value:90,children:"Last 90 days"})]}),a.jsxs("label",{className:"flex items-center gap-2 text-sm text-bambu-gray cursor-pointer",children:[a.jsx("input",{type:"checkbox",checked:l,onChange:S=>c(S.target.checked),className:"rounded border-bambu-dark-tertiary bg-bambu-dark text-bambu-green focus:ring-bambu-green"}),"Show failed only"]}),a.jsx("div",{className:"flex-1"}),a.jsxs(Ce,{size:"sm",variant:"secondary",onClick:()=>p(),disabled:x,children:[x?a.jsx(it,{className:"w-4 h-4 animate-spin"}):a.jsx(kr,{className:"w-4 h-4"}),"Refresh"]}),a.jsxs(Ce,{size:"sm",variant:"secondary",onClick:()=>b.mutate(),disabled:b.isPending,className:"text-red-400 hover:text-red-300",children:[b.isPending?a.jsx(it,{className:"w-4 h-4 animate-spin"}):a.jsx(Jt,{className:"w-4 h-4"}),"Clear Old"]})]}),a.jsx("div",{className:"flex-1 overflow-y-auto p-4",children:f?a.jsx("div",{className:"flex justify-center py-12",children:a.jsx(it,{className:"w-6 h-6 text-bambu-green animate-spin"})}):h&&h.length>0?a.jsx("div",{className:"space-y-2",children:h.map(S=>a.jsx(JQe,{log:S,isExpanded:s===S.id,onToggle:()=>o(s===S.id?null:S.id),formatDate:v,formatFullDate:N=>Lf(N,d)},S.id))}):a.jsxs("div",{className:"text-center py-12 text-bambu-gray",children:[a.jsx(N0,{className:"w-12 h-12 mx-auto mb-3 opacity-30"}),a.jsx("p",{className:"text-sm",children:l?"No failed notifications":"No notifications logged"})]})})]})})}function JQe({log:t,isExpanded:e,onToggle:n,formatDate:r,formatFullDate:i}){return a.jsxs("div",{className:`border rounded-lg overflow-hidden transition-colors ${t.success?"border-bambu-dark-tertiary bg-bambu-dark/30":"border-red-500/30 bg-red-500/5"}`,children:[a.jsxs("button",{className:"w-full px-3 py-2 flex items-center gap-3 text-left hover:bg-bambu-dark/50 transition-colors",onClick:n,children:[t.success?a.jsx(gr,{className:"w-4 h-4 text-bambu-green shrink-0"}):a.jsx(ha,{className:"w-4 h-4 text-red-400 shrink-0"}),a.jsx("span",{className:`text-xs font-medium ${QQe[t.event_type]||"text-bambu-gray"}`,children:YQe[t.event_type]||t.event_type}),a.jsx("span",{className:"text-sm text-white truncate flex-1",children:t.provider_name||"Unknown Provider"}),t.printer_name&&a.jsx("span",{className:"text-xs text-bambu-gray",children:t.printer_name}),a.jsx("span",{className:"text-xs text-bambu-gray shrink-0",children:r(t.created_at)}),e?a.jsx(Wl,{className:"w-4 h-4 text-bambu-gray shrink-0"}):a.jsx(nr,{className:"w-4 h-4 text-bambu-gray shrink-0"})]}),e&&a.jsxs("div",{className:"px-3 py-2 border-t border-bambu-dark-tertiary bg-bambu-dark/20 space-y-2",children:[a.jsxs("div",{children:[a.jsx("p",{className:"text-xs text-bambu-gray mb-1",children:"Title"}),a.jsx("p",{className:"text-sm text-white",children:t.title})]}),a.jsxs("div",{children:[a.jsx("p",{className:"text-xs text-bambu-gray mb-1",children:"Message"}),a.jsx("p",{className:"text-sm text-white whitespace-pre-wrap",children:t.message})]}),!t.success&&t.error_message&&a.jsxs("div",{children:[a.jsx("p",{className:"text-xs text-red-400 mb-1",children:"Error"}),a.jsx("p",{className:"text-sm text-red-300",children:t.error_message})]}),a.jsxs("div",{className:"flex gap-4 text-xs text-bambu-gray pt-1",children:[a.jsxs("span",{children:["Provider: ",t.provider_type]}),a.jsxs("span",{children:["Time: ",i(t.created_at)]})]})]})]})}function eZe({formData:t,setFormData:e,groups:n,onClose:r,onCreate:i,isCreating:s,isCreateButtonDisabled:o}){const{t:l}=Vt();w.useEffect(()=>{const u=d=>{d.key==="Escape"&&r()};return window.addEventListener("keydown",u),()=>window.removeEventListener("keydown",u)},[r]);const c=u=>{e({...t,group_ids:t.group_ids.includes(u)?t.group_ids.filter(d=>d!==u):[...t.group_ids,u]})};return a.jsx("div",{className:"fixed inset-0 bg-black/70 flex items-center justify-center z-50 p-4",onClick:r,children:a.jsxs(vt,{className:"w-full max-w-md",onClick:u=>u.stopPropagation(),children:[a.jsx(An,{children:a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsxs("div",{className:"flex flex-col gap-1",children:[a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx(gh,{className:"w-5 h-5 text-bambu-green"}),a.jsx("h2",{className:"text-lg font-semibold text-white",children:l("users.modal.createUser")})]}),a.jsx("p",{className:"text-sm text-bambu-gray ml-7",children:l("users.modal.advancedAuthSubtitle")||"with Advanced Authentication"})]}),a.jsx(Ce,{variant:"ghost",size:"sm",onClick:r,children:a.jsx(Ft,{className:"w-5 h-5"})})]})}),a.jsxs(Nt,{children:[a.jsxs("div",{className:"space-y-4",children:[a.jsxs("div",{children:[a.jsxs("label",{className:"block text-sm font-medium text-white mb-2",children:[l("users.form.username")," ",a.jsx("span",{className:"text-red-400",children:"*"})]}),a.jsx("input",{type:"text",value:t.username,onChange:u=>e({...t,username:u.target.value}),className:"w-full px-4 py-3 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg text-white placeholder-bambu-gray focus:outline-none focus:ring-2 focus:ring-bambu-green/50 focus:border-bambu-green transition-colors",placeholder:l("users.form.usernamePlaceholder"),autoComplete:"username",required:!0})]}),a.jsxs("div",{children:[a.jsxs("label",{className:"block text-sm font-medium text-white mb-2",children:[l("users.form.email")||"Email"," ",a.jsx("span",{className:"text-red-400",children:"*"})]}),a.jsx("input",{type:"email",value:t.email,onChange:u=>e({...t,email:u.target.value}),className:"w-full px-4 py-3 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg text-white placeholder-bambu-gray focus:outline-none focus:ring-2 focus:ring-bambu-green/50 focus:border-bambu-green transition-colors",placeholder:l("users.form.emailPlaceholder")||"user@example.com",required:!0})]}),a.jsx("div",{className:"bg-bambu-dark-secondary/50 border border-bambu-green/20 rounded-lg p-3",children:a.jsx("p",{className:"text-sm text-bambu-gray",children:l("users.form.autoGeneratedPassword")||"A secure password will be automatically generated and emailed to the user."})}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm font-medium text-white mb-2",children:l("users.form.groups")}),a.jsxs("div",{className:"space-y-2 max-h-40 overflow-y-auto p-2 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg",children:[n.map(u=>a.jsxs("label",{className:"flex items-center gap-3 px-2 py-1.5 rounded hover:bg-bambu-dark-tertiary cursor-pointer",children:[a.jsx("input",{type:"checkbox",checked:t.group_ids.includes(u.id),onChange:()=>c(u.id),className:"w-4 h-4 rounded border-bambu-gray text-bambu-green focus:ring-bambu-green focus:ring-offset-0 bg-bambu-dark"}),a.jsx("span",{className:"text-sm text-white",children:u.name}),u.is_system&&a.jsxs("span",{className:"text-xs text-yellow-400",children:["(",l("users.system"),")"]})]},u.id)),n.length===0&&a.jsx("p",{className:"text-sm text-bambu-gray",children:l("users.noGroupsAvailable")})]})]})]}),a.jsxs("div",{className:"mt-6 flex justify-end gap-3",children:[a.jsx(Ce,{variant:"secondary",onClick:r,children:l("users.modal.cancel")}),a.jsx(Ce,{onClick:i,disabled:o,children:s?a.jsxs(a.Fragment,{children:[a.jsx(it,{className:"w-4 h-4 animate-spin"}),l("users.modal.creating")]}):a.jsxs(a.Fragment,{children:[a.jsx(ar,{className:"w-4 h-4"}),l("users.modal.createUser")]})})]})]})]})})}function tZe(){const{t}=Vt(),e=tn(),{showToast:n}=hn(),[r,i]=w.useState(!1),[s,o]=w.useState(""),[l,c]=w.useState("auto"),[u,d]=w.useState(!1),[h,f]=w.useState(!0),[p,x]=w.useState("all"),[y,b]=w.useState(!1),[v,S]=w.useState(!1),[N,A]=w.useState(!1),{data:C,isLoading:T}=Ze({queryKey:["spoolman-settings"],queryFn:re.getSpoolmanSettings}),{data:k,isLoading:j,refetch:E}=Ze({queryKey:["spoolman-status"],queryFn:re.getSpoolmanStatus,refetchInterval:3e4}),{data:P}=Ze({queryKey:["printers"],queryFn:re.getPrinters});w.useEffect(()=>{C&&(i(C.spoolman_enabled==="true"),o(C.spoolman_url||""),c(C.spoolman_sync_mode||"auto"),d(C.spoolman_disable_weight_sync==="true"),f(C.spoolman_report_partial_usage!=="false"),b(!0))},[C]),w.useEffect(()=>{if(!y||!C)return;if(C.spoolman_enabled==="true"!==r||(C.spoolman_url||"")!==s||(C.spoolman_sync_mode||"auto")!==l||C.spoolman_disable_weight_sync==="true"!==u||C.spoolman_report_partial_usage!=="false"!==h){const X=setTimeout(()=>{U.mutate()},500);return()=>clearTimeout(X)}},[r,s,l,u,h,y]);const U=ot({mutationFn:()=>re.updateSpoolmanSettings({spoolman_enabled:r?"true":"false",spoolman_url:s,spoolman_sync_mode:l,spoolman_disable_weight_sync:u?"true":"false",spoolman_report_partial_usage:h?"true":"false"}),onSuccess:()=>{e.invalidateQueries({queryKey:["spoolman-settings"]}),e.invalidateQueries({queryKey:["spoolman-status"]}),e.invalidateQueries({queryKey:["spool-assignments"]}),n(t("settings.toast.settingsSaved"))}}),O=ot({mutationFn:re.connectSpoolman,onSuccess:()=>{E()}}),B=ot({mutationFn:re.disconnectSpoolman,onSuccess:()=>{E()}}),R=ot({mutationFn:re.syncAllPrintersAms,onSuccess:$=>{$.success}}),G=ot({mutationFn:$=>re.syncPrinterAms($),onSuccess:$=>{$.success}}),q=()=>{p==="all"?R.mutate():G.mutate(p)},z=ot({mutationFn:re.syncWeightsFromAms,onSuccess:$=>{e.invalidateQueries({queryKey:["spools"]}),e.invalidateQueries({queryKey:["inventory-spools"]}),n(t("settings.amsSyncSuccess",{synced:$.synced,skipped:$.skipped}),"success"),A(!1)},onError:()=>{n(t("settings.amsSyncError"),"error"),A(!1)}}),K=R.isPending||G.isPending,Y=p==="all"?R.data:G.data,oe=p==="all"?R.isSuccess:G.isSuccess;return T?a.jsxs(vt,{children:[a.jsx(An,{children:a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx(Tc,{className:"w-5 h-5 text-bambu-green"}),a.jsx("h2",{className:"text-lg font-semibold text-white",children:t("settings.filamentTracking")})]})}),a.jsx(Nt,{children:a.jsx("div",{className:"flex justify-center py-8",children:a.jsx(it,{className:"w-6 h-6 text-bambu-green animate-spin"})})})]}):a.jsxs(vt,{children:[a.jsx(An,{children:a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx(Tc,{className:"w-5 h-5 text-bambu-green"}),a.jsx("h2",{className:"text-lg font-semibold text-white",children:t("settings.filamentTracking")})]}),U.isPending&&a.jsx(it,{className:"w-4 h-4 text-bambu-green animate-spin"})]})}),a.jsxs(Nt,{className:"space-y-4",children:[a.jsx("p",{className:"text-sm text-bambu-gray",children:t("settings.filamentTrackingDesc")}),a.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[a.jsxs("button",{type:"button",onClick:()=>i(!1),className:`p-3 rounded-lg border-2 text-left transition-colors ${r?"border-bambu-dark-tertiary bg-bambu-dark hover:border-bambu-gray/50":"border-bambu-green bg-bambu-green/10"}`,children:[a.jsxs("div",{className:"flex items-center gap-2 mb-1.5",children:[a.jsx(fa,{className:`w-4 h-4 ${r?"text-bambu-gray":"text-bambu-green"}`}),a.jsx("span",{className:`text-sm font-medium ${r?"text-bambu-gray":"text-white"}`,children:t("settings.trackingModeBuiltIn")})]}),a.jsx("p",{className:`text-xs ${r?"text-bambu-gray/60":"text-bambu-gray"}`,children:t("settings.trackingModeBuiltInDesc")}),!r&&a.jsxs("div",{className:"flex items-center gap-1 mt-2",children:[a.jsx(Xr,{className:"w-3 h-3 text-bambu-green"}),a.jsx("span",{className:"text-xs text-bambu-green",children:t("common.enabled")})]})]}),a.jsxs("button",{type:"button",onClick:()=>i(!0),className:`p-3 rounded-lg border-2 text-left transition-colors ${r?"border-bambu-green bg-bambu-green/10":"border-bambu-dark-tertiary bg-bambu-dark hover:border-bambu-gray/50"}`,children:[a.jsxs("div",{className:"flex items-center gap-2 mb-1.5",children:[a.jsx(Kr,{className:`w-4 h-4 ${r?"text-bambu-green":"text-bambu-gray"}`}),a.jsx("span",{className:`text-sm font-medium ${r?"text-white":"text-bambu-gray"}`,children:"Spoolman"})]}),a.jsx("p",{className:`text-xs ${r?"text-bambu-gray":"text-bambu-gray/60"}`,children:t("settings.trackingModeSpoolmanDesc")}),r&&a.jsxs("div",{className:"flex items-center gap-1 mt-2",children:[a.jsx(Xr,{className:"w-3 h-3 text-bambu-green"}),a.jsx("span",{className:"text-xs text-bambu-green",children:t("common.enabled")})]})]})]}),!r&&a.jsxs("div",{className:"space-y-3",children:[a.jsx("div",{className:"p-3 bg-bambu-green/5 border border-bambu-green/20 rounded-lg",children:a.jsxs("div",{className:"flex gap-2",children:[a.jsx(Js,{className:"w-4 h-4 text-bambu-green flex-shrink-0 mt-0.5"}),a.jsx("div",{className:"text-xs text-bambu-gray",children:a.jsxs("ul",{className:"list-disc list-inside space-y-0.5",children:[a.jsx("li",{children:t("settings.builtInFeatureRfid")}),a.jsx("li",{children:t("settings.builtInFeatureUsage")}),a.jsx("li",{children:t("settings.builtInFeatureCatalog")}),a.jsx("li",{children:t("settings.builtInFeatureThirdParty")})]})})]})}),a.jsxs(Ce,{variant:"secondary",size:"sm",onClick:()=>A(!0),disabled:z.isPending,children:[z.isPending?a.jsx(it,{className:"w-4 h-4 mr-2 animate-spin"}):a.jsx(kr,{className:"w-4 h-4 mr-2"}),t("settings.amsSyncButton")]})]}),r&&a.jsxs("div",{className:"space-y-4",children:[a.jsx("div",{className:"p-3 bg-blue-500/10 border border-blue-500/30 rounded-lg",children:a.jsxs("div",{className:"flex gap-2",children:[a.jsx(Js,{className:"w-4 h-4 text-blue-400 flex-shrink-0 mt-0.5"}),a.jsxs("div",{className:"text-xs text-blue-300",children:[a.jsx("p",{className:"font-medium mb-1",children:t("settings.howSyncWorks")}),a.jsxs("ul",{className:"list-disc list-inside space-y-0.5 text-blue-300/80",children:[a.jsx("li",{children:t("settings.syncInfoRfidOnly")}),a.jsx("li",{children:t("settings.syncInfoAutoCreate")}),a.jsx("li",{children:t("settings.syncInfoThirdPartySkipped")})]}),a.jsx("p",{className:"font-medium mt-2 mb-1",children:t("settings.linkingExistingSpools")}),a.jsx("p",{className:"text-blue-300/80",children:t("settings.linkingExistingSpoolsDesc")})]})]})}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:t("settings.spoolmanUrl")}),a.jsx("input",{type:"text",placeholder:"http://192.168.1.100:7912",value:s,onChange:$=>o($.target.value),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white placeholder-bambu-gray/50 focus:border-bambu-green focus:outline-none"}),a.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:t("settings.spoolmanUrlHint")})]}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:t("settings.syncMode")}),a.jsxs("select",{value:l,onChange:$=>c($.target.value),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",children:[a.jsx("option",{value:"auto",children:t("settings.syncModeAuto")}),a.jsx("option",{value:"manual",children:t("settings.syncModeManual")})]}),a.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:t(l==="auto"?"settings.syncModeAutoDesc":"settings.syncModeManualDesc")})]}),l==="auto"&&a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsxs("div",{children:[a.jsx("p",{className:"text-white",children:t("spoolman.disableWeightSync")}),a.jsx("p",{className:"text-sm text-bambu-gray",children:t("spoolman.disableWeightSyncDesc")})]}),a.jsxs("label",{className:"relative inline-flex items-center cursor-pointer",children:[a.jsx("input",{type:"checkbox",checked:u,onChange:$=>d($.target.checked),className:"sr-only peer"}),a.jsx("div",{className:"w-11 h-6 bg-bambu-dark-tertiary peer-focus:outline-none rounded-full peer peer-checked:after:translate-x-full peer-checked:after:border-white after:content-[''] after:absolute after:top-[2px] after:left-[2px] after:bg-white after:rounded-full after:h-5 after:w-5 after:transition-all peer-checked:bg-bambu-green"})]})]}),u&&a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsxs("div",{children:[a.jsx("p",{className:"text-white",children:t("spoolman.reportPartialUsage")}),a.jsx("p",{className:"text-sm text-bambu-gray",children:t("spoolman.reportPartialUsageDesc")})]}),a.jsxs("label",{className:"relative inline-flex items-center cursor-pointer",children:[a.jsx("input",{type:"checkbox",checked:h,onChange:$=>f($.target.checked),className:"sr-only peer"}),a.jsx("div",{className:"w-11 h-6 bg-bambu-dark-tertiary peer-focus:outline-none rounded-full peer peer-checked:after:translate-x-full peer-checked:after:border-white after:content-[''] after:absolute after:top-[2px] after:left-[2px] after:bg-white after:rounded-full after:h-5 after:w-5 after:transition-all peer-checked:bg-bambu-green"})]})]}),a.jsxs("div",{className:"pt-2 border-t border-bambu-dark-tertiary",children:[a.jsxs("div",{className:"flex items-center justify-between mb-3",children:[a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsxs("span",{className:"text-sm text-bambu-gray",children:[t("settings.status"),":"]}),j?a.jsx(it,{className:"w-4 h-4 text-bambu-gray animate-spin"}):k?.connected?a.jsxs("span",{className:"flex items-center gap-1 text-sm text-green-500",children:[a.jsx(Xr,{className:"w-4 h-4"}),t("settings.spoolmanConnected")]}):a.jsxs("span",{className:"flex items-center gap-1 text-sm text-red-500",children:[a.jsx(Ft,{className:"w-4 h-4"}),t("settings.spoolmanDisconnected")]})]}),a.jsx("div",{className:"flex gap-2",children:k?.connected?a.jsxs(Ce,{variant:"secondary",size:"sm",onClick:()=>B.mutate(),disabled:B.isPending,children:[B.isPending?a.jsx(it,{className:"w-4 h-4 animate-spin"}):a.jsx(Rme,{className:"w-4 h-4"}),t("settings.disconnect")]}):a.jsxs(Ce,{size:"sm",onClick:()=>O.mutate(),disabled:O.isPending||!s,children:[O.isPending?a.jsx(it,{className:"w-4 h-4 animate-spin"}):a.jsx(Rh,{className:"w-4 h-4"}),t("settings.connect")]})})]}),O.isError&&a.jsx("div",{className:"mb-3 p-2 bg-red-500/20 border border-red-500/50 rounded text-sm text-red-400",children:O.error.message}),k?.connected&&a.jsxs("div",{className:"space-y-3",children:[a.jsxs("div",{children:[a.jsx("p",{className:"text-sm text-white",children:t("settings.syncAmsData")}),a.jsx("p",{className:"text-xs text-bambu-gray",children:t("settings.syncAmsDataDesc")})]}),a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsxs("div",{className:"relative flex-1",children:[a.jsxs("select",{value:p,onChange:$=>x($.target.value==="all"?"all":Number($.target.value)),className:"w-full px-3 py-2 pr-8 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white text-sm focus:border-bambu-green focus:outline-none appearance-none cursor-pointer",children:[a.jsx("option",{value:"all",children:t("settings.allPrinters")}),P?.map($=>a.jsx("option",{value:$.id,children:$.name},$.id))]}),a.jsx(nr,{className:"absolute right-2 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray pointer-events-none"})]}),a.jsxs(Ce,{variant:"secondary",size:"sm",onClick:q,disabled:K,children:[K?a.jsx(it,{className:"w-4 h-4 animate-spin"}):a.jsx(kr,{className:"w-4 h-4"}),t("spoolman.sync")]})]})]}),oe&&Y&&a.jsxs("div",{className:"mt-3 space-y-2",children:[a.jsx("div",{className:`p-2 rounded text-sm ${Y.success?"bg-green-500/20 border border-green-500/50 text-green-400":"bg-yellow-500/20 border border-yellow-500/50 text-yellow-400"}`,children:Y.success?`Synced ${Y.synced_count} spool${Y.synced_count!==1?"s":""} successfully`:`Synced ${Y.synced_count} spool${Y.synced_count!==1?"s":""} with ${Y.errors.length} error${Y.errors.length!==1?"s":""}`}),Y.skipped_count>0&&a.jsxs("div",{className:"p-2 bg-amber-500/10 border border-amber-500/30 rounded text-sm",children:[a.jsxs("div",{className:"flex items-center justify-between text-amber-400 mb-1",children:[a.jsxs("div",{className:"flex items-center gap-1.5",children:[a.jsx(Cn,{className:"w-3.5 h-3.5"}),a.jsxs("span",{className:"font-medium",children:[Y.skipped_count," spool",Y.skipped_count!==1?"s":""," skipped"]})]}),Y.skipped_count>5&&a.jsx("button",{onClick:()=>S(!v),className:"text-xs text-amber-400 hover:text-amber-300 underline",children:v?"Show less":"Show all"})]}),a.jsxs("ul",{className:"text-xs text-amber-300/80 space-y-0.5",children:[(v?Y.skipped:Y.skipped.slice(0,5)).map(($,X)=>a.jsxs("li",{className:"flex items-center gap-2",children:[$.color&&a.jsx("span",{className:"w-3 h-3 rounded-full border border-white/20",style:{backgroundColor:`#${$.color}`}}),a.jsx("span",{children:$.location}),a.jsxs("span",{className:"text-amber-300/60",children:["- ",$.reason]})]},X)),!v&&Y.skipped_count>5&&a.jsxs("li",{className:"text-amber-300/60 italic",children:["...and ",Y.skipped_count-5," more"]})]})]}),Y.errors.length>0&&a.jsxs("div",{className:"p-2 bg-red-500/10 border border-red-500/30 rounded text-sm",children:[a.jsx("div",{className:"text-red-400 font-medium mb-1",children:"Errors:"}),a.jsx("ul",{className:"text-xs text-red-300/80 space-y-0.5",children:Y.errors.map(($,X)=>a.jsx("li",{children:$},X))})]})]})]})]})]}),N&&a.jsx(vn,{title:t("settings.amsSyncTitle"),message:t("settings.amsSyncMessage"),confirmText:t("settings.amsSyncButton"),variant:"warning",isLoading:z.isPending,loadingText:t("settings.amsSyncing"),onConfirm:()=>z.mutate(),onCancel:()=>A(!1)})]})}function nZe(){const{t}=Vt(),{showToast:e}=hn(),[n,r]=w.useState([]),[i,s]=w.useState(!0),[o,l]=w.useState(""),c=w.useRef(null),[u,d]=w.useState(!1),[h,f]=w.useState(null),[p,x]=w.useState(""),[y,b]=w.useState(""),[v,S]=w.useState(!1),[N,A]=w.useState(null),[C,T]=w.useState(!1),k=w.useCallback(async()=>{try{const z=await re.getSpoolCatalog();r(z)}catch{e(t("settings.catalog.loadFailed"),"error")}finally{s(!1)}},[e,t]);w.useEffect(()=>{k()},[k]);const j=n.filter(z=>z.name.toLowerCase().includes(o.toLowerCase())),E=async()=>{if(!p.trim()||!y){e(t("settings.catalog.nameWeightRequired"),"error");return}S(!0);try{const z=await re.addCatalogEntry({name:p.trim(),weight:parseInt(y)});r(K=>[...K,z].sort((Y,oe)=>Y.name.localeCompare(oe.name))),d(!1),x(""),b(""),e(t("settings.catalog.entryAdded"),"success")}catch{e(t("settings.catalog.addFailed"),"error")}finally{S(!1)}},P=z=>{f(z.id),x(z.name),b(z.weight.toString())},U=()=>{f(null),x(""),b("")},O=async z=>{if(!p.trim()||!y){e(t("settings.catalog.nameWeightRequired"),"error");return}S(!0);try{const K=await re.updateCatalogEntry(z,{name:p.trim(),weight:parseInt(y)});r(Y=>Y.map(oe=>oe.id===z?K:oe).sort((oe,$)=>oe.name.localeCompare($.name))),f(null),x(""),b(""),e(t("settings.catalog.entryUpdated"),"success")}catch{e(t("settings.catalog.updateFailed"),"error")}finally{S(!1)}},B=async()=>{if(N)try{await re.deleteCatalogEntry(N.id),r(z=>z.filter(K=>K.id!==N.id)),e(t("settings.catalog.entryDeleted"),"success")}catch{e(t("settings.catalog.deleteFailed"),"error")}finally{A(null)}},R=async()=>{T(!1),s(!0);try{await re.resetSpoolCatalog(),await k(),e(t("settings.catalog.resetSuccess"),"success")}catch{e(t("settings.catalog.resetFailed"),"error"),s(!1)}},G=()=>{const z=n.map(({name:$,weight:X})=>({name:$,weight:X})),K=new Blob([JSON.stringify(z,null,2)],{type:"application/json"}),Y=URL.createObjectURL(K),oe=document.createElement("a");oe.href=Y,oe.download="spool-catalog.json",document.body.appendChild(oe),oe.click(),document.body.removeChild(oe),URL.revokeObjectURL(Y),e(t("settings.catalog.exported",{count:n.length}),"success")},q=async z=>{const K=z.target.files?.[0];if(K){try{const Y=await K.text(),oe=JSON.parse(Y);if(!Array.isArray(oe))throw new Error("Invalid format");let $=0,X=0;for(const ee of oe){if(!ee.name||typeof ee.weight!="number"){X++;continue}if(n.some(_e=>_e.name.toLowerCase()===ee.name.toLowerCase())){X++;continue}try{const _e=await re.addCatalogEntry({name:ee.name,weight:ee.weight});r(pe=>[...pe,_e].sort((me,je)=>me.name.localeCompare(je.name))),$++}catch{X++}}e(t("settings.catalog.imported",{added:$,skipped:X}),"success")}catch{e(t("settings.catalog.importFailed"),"error")}c.current&&(c.current.value="")}};return a.jsxs(vt,{children:[a.jsxs(An,{children:[a.jsxs("div",{className:"flex items-center gap-2 mb-3",children:[a.jsx(Tc,{className:"w-5 h-5 text-bambu-gray"}),a.jsx("h2",{className:"text-lg font-semibold text-white",children:t("settings.catalog.spoolCatalog")}),a.jsxs("span",{className:"text-sm text-bambu-gray",children:["(",n.length,")"]})]}),a.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[a.jsxs("button",{onClick:G,className:"px-3 py-1.5 text-sm bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-bambu-gray hover:text-white transition-colors flex items-center gap-1.5",title:t("settings.catalog.exportTooltip"),children:[a.jsx(di,{className:"w-4 h-4"}),a.jsx("span",{className:"hidden sm:inline",children:t("common.export")})]}),a.jsxs("button",{onClick:()=>c.current?.click(),className:"px-3 py-1.5 text-sm bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-bambu-gray hover:text-white transition-colors flex items-center gap-1.5",title:t("settings.catalog.importTooltip"),children:[a.jsx(Fi,{className:"w-4 h-4"}),a.jsx("span",{className:"hidden sm:inline",children:t("common.import")})]}),a.jsx("input",{ref:c,type:"file",accept:".json",className:"hidden",onChange:q}),a.jsxs("button",{onClick:()=>T(!0),className:"px-3 py-1.5 text-sm bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-bambu-gray hover:text-white transition-colors flex items-center gap-1.5",title:t("settings.catalog.resetTooltip"),children:[a.jsx(Ro,{className:"w-4 h-4"}),a.jsx("span",{className:"hidden sm:inline",children:t("common.reset")})]}),a.jsxs("button",{onClick:()=>d(!0),className:"px-3 py-1.5 text-sm bg-bambu-green text-white rounded-lg hover:bg-bambu-green/80 transition-colors flex items-center gap-1.5",children:[a.jsx(ar,{className:"w-4 h-4"}),a.jsx("span",{className:"hidden sm:inline",children:t("common.add")})]})]})]}),a.jsxs(Nt,{className:"space-y-4",children:[a.jsx("p",{className:"text-sm text-bambu-gray",children:t("settings.catalog.spoolCatalogDescription")}),a.jsxs("div",{className:"relative",children:[a.jsx(Or,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray"}),a.jsx("input",{type:"text",className:"w-full pl-10 pr-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white placeholder-bambu-gray focus:border-bambu-green focus:outline-none",placeholder:t("settings.catalog.searchCatalog"),value:o,onChange:z=>l(z.target.value)})]}),u&&a.jsxs("div",{className:"p-4 bg-bambu-dark rounded-lg border border-bambu-dark-tertiary",children:[a.jsx("h3",{className:"text-sm font-medium text-white mb-3",children:t("settings.catalog.addNewEntry")}),a.jsxs("div",{className:"flex gap-2 items-center",children:[a.jsx("div",{className:"flex-1 min-w-0",children:a.jsx("input",{type:"text",className:"w-full px-3 py-2 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg text-white placeholder-bambu-gray focus:border-bambu-green focus:outline-none",placeholder:t("settings.catalog.namePlaceholder"),value:p,onChange:z=>x(z.target.value)})}),a.jsx("input",{type:"number",className:"w-20 px-3 py-2 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg text-white text-center focus:border-bambu-green focus:outline-none",placeholder:"g",value:y,onChange:z=>b(z.target.value)}),a.jsx("span",{className:"text-bambu-gray shrink-0",children:"g"}),a.jsxs("button",{onClick:E,disabled:v,className:"px-3 py-2 bg-bambu-green text-white rounded-lg hover:bg-bambu-green/80 flex items-center gap-1 shrink-0",children:[v?a.jsx(it,{className:"w-4 h-4 animate-spin"}):a.jsx(Xr,{className:"w-4 h-4"}),t("common.add")]}),a.jsx("button",{onClick:()=>{d(!1),x(""),b("")},className:"p-2 rounded-lg text-bambu-gray hover:text-white hover:bg-bambu-dark-tertiary",children:a.jsx(Ft,{className:"w-4 h-4"})})]})]}),i?a.jsxs("div",{className:"flex items-center justify-center py-8 text-bambu-gray",children:[a.jsx(it,{className:"w-5 h-5 animate-spin mr-2"}),t("common.loading")]}):a.jsx("div",{className:"max-h-[600px] overflow-y-auto border border-bambu-dark-tertiary rounded-lg",children:a.jsxs("table",{className:"w-full text-sm",children:[a.jsx("thead",{className:"bg-bambu-dark sticky top-0",children:a.jsxs("tr",{children:[a.jsx("th",{className:"px-4 py-2 text-left text-bambu-gray font-medium",children:t("common.name")}),a.jsx("th",{className:"px-4 py-2 text-right text-bambu-gray font-medium w-24",children:t("settings.catalog.weight")}),a.jsx("th",{className:"px-4 py-2 text-center text-bambu-gray font-medium w-20",children:t("settings.catalog.type")}),a.jsx("th",{className:"px-4 py-2 w-24"})]})}),a.jsx("tbody",{children:j.length===0?a.jsx("tr",{children:a.jsx("td",{colSpan:4,className:"px-4 py-8 text-center text-bambu-gray",children:t(o?"settings.catalog.noMatch":"settings.catalog.empty")})}):j.map(z=>a.jsx("tr",{className:"border-t border-bambu-dark-tertiary hover:bg-bambu-dark",children:h===z.id?a.jsxs(a.Fragment,{children:[a.jsx("td",{className:"px-4 py-2",children:a.jsx("input",{type:"text",className:"w-full px-2 py-1 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded text-white focus:border-bambu-green focus:outline-none",value:p,onChange:K=>x(K.target.value)})}),a.jsx("td",{className:"px-4 py-2",children:a.jsx("input",{type:"number",className:"w-full px-2 py-1 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded text-white text-right focus:border-bambu-green focus:outline-none",value:y,onChange:K=>b(K.target.value)})}),a.jsx("td",{className:"px-4 py-2 text-center",children:a.jsx("span",{className:"text-xs text-bambu-gray",children:"-"})}),a.jsx("td",{className:"px-4 py-2",children:a.jsxs("div",{className:"flex justify-end gap-1",children:[a.jsx("button",{onClick:()=>O(z.id),disabled:v,className:"p-1.5 rounded hover:bg-green-500/20 text-green-500",children:v?a.jsx(it,{className:"w-4 h-4 animate-spin"}):a.jsx(Xr,{className:"w-4 h-4"})}),a.jsx("button",{onClick:U,className:"p-1.5 rounded hover:bg-bambu-dark-tertiary text-bambu-gray",children:a.jsx(Ft,{className:"w-4 h-4"})})]})})]}):a.jsxs(a.Fragment,{children:[a.jsx("td",{className:"px-4 py-2 text-white",children:z.name}),a.jsxs("td",{className:"px-4 py-2 text-right font-mono text-white",children:[z.weight,"g"]}),a.jsx("td",{className:"px-4 py-2 text-center",children:z.is_default?a.jsx("span",{className:"text-xs px-2 py-0.5 rounded bg-bambu-dark-tertiary text-bambu-gray",children:t("settings.catalog.default")}):a.jsx("span",{className:"text-xs px-2 py-0.5 rounded bg-bambu-green/20 text-bambu-green",children:t("settings.catalog.custom")})}),a.jsx("td",{className:"px-4 py-2",children:a.jsxs("div",{className:"flex justify-end gap-1",children:[a.jsx("button",{onClick:()=>P(z),className:"p-1.5 rounded hover:bg-bambu-dark-tertiary text-bambu-gray hover:text-white",children:a.jsx(Vi,{className:"w-4 h-4"})}),a.jsx("button",{onClick:()=>A(z),className:"p-1.5 rounded bg-red-500/10 hover:bg-red-500/20 text-red-500",children:a.jsx(Jt,{className:"w-4 h-4"})})]})})]})},z.id))})]})})]}),N&&a.jsx(vn,{title:t("settings.catalog.deleteEntry"),message:t("settings.catalog.deleteConfirm",{name:N.name}),confirmText:t("common.delete"),variant:"danger",onConfirm:B,onCancel:()=>A(null)}),C&&a.jsx(vn,{title:t("settings.catalog.resetCatalog"),message:t("settings.catalog.resetConfirm"),confirmText:t("common.reset"),variant:"danger",onConfirm:R,onCancel:()=>T(!1)})]})}function rZe(){const{t}=Vt(),{showToast:e}=hn(),[n,r]=w.useState([]),[i,s]=w.useState(!0),[o,l]=w.useState(""),[c,u]=w.useState("Bambu Lab"),d=w.useRef(null),[h,f]=w.useState(!1),[p,x]=w.useState(null),[y,b]=w.useState(""),[v,S]=w.useState(""),[N,A]=w.useState("#FFFFFF"),[C,T]=w.useState(""),[k,j]=w.useState(!1),[E,P]=w.useState(!1),[U,O]=w.useState(null),[B,R]=w.useState(null),[G,q]=w.useState(!1),z=w.useCallback(async()=>{try{const ce=await re.getColorCatalog();r(ce)}catch{e(t("settings.colorCatalog.loadFailed"),"error")}finally{s(!1)}},[e,t]);w.useEffect(()=>{z()},[z]);const K=[...new Set(n.map(ce=>ce.manufacturer))].sort(),Y=n.filter(ce=>{const Se=o===""||ce.manufacturer.toLowerCase().includes(o.toLowerCase())||ce.color_name.toLowerCase().includes(o.toLowerCase())||(ce.material?.toLowerCase().includes(o.toLowerCase())??!1),ie=c===""||ce.manufacturer===c;return Se&&ie}),oe=()=>{b(""),S(""),A("#FFFFFF"),T("")},$=async()=>{if(!y.trim()||!v.trim()||!N){e(t("settings.colorCatalog.fieldsRequired"),"error");return}j(!0);try{const ce=await re.addColorEntry({manufacturer:y.trim(),color_name:v.trim(),hex_color:N,material:C.trim()||null});r(Se=>[...Se,ce].sort((ie,Fe)=>ie.manufacturer.localeCompare(Fe.manufacturer)||(ie.material||"").localeCompare(Fe.material||"")||ie.color_name.localeCompare(Fe.color_name))),f(!1),oe(),e(t("settings.colorCatalog.colorAdded"),"success")}catch{e(t("settings.colorCatalog.addFailed"),"error")}finally{j(!1)}},X=ce=>{x(ce.id),b(ce.manufacturer),S(ce.color_name),A(ce.hex_color),T(ce.material||"")},ee=()=>{x(null),oe()},J=async ce=>{if(!y.trim()||!v.trim()||!N){e(t("settings.colorCatalog.fieldsRequired"),"error");return}j(!0);try{const Se=await re.updateColorEntry(ce,{manufacturer:y.trim(),color_name:v.trim(),hex_color:N,material:C.trim()||null});r(ie=>ie.map(Fe=>Fe.id===ce?Se:Fe).sort((Fe,V)=>Fe.manufacturer.localeCompare(V.manufacturer)||(Fe.material||"").localeCompare(V.material||"")||Fe.color_name.localeCompare(V.color_name))),x(null),oe(),e(t("settings.colorCatalog.colorUpdated"),"success")}catch{e(t("settings.colorCatalog.updateFailed"),"error")}finally{j(!1)}},_e=async()=>{if(B)try{await re.deleteColorEntry(B.id),r(ce=>ce.filter(Se=>Se.id!==B.id)),e(t("settings.colorCatalog.colorDeleted"),"success")}catch{e(t("settings.colorCatalog.deleteFailed"),"error")}finally{R(null)}},pe=async()=>{q(!1),s(!0);try{await re.resetColorCatalog(),await z(),e(t("settings.colorCatalog.resetSuccess"),"success")}catch{e(t("settings.colorCatalog.resetFailed"),"error"),s(!1)}},me=async()=>{P(!0),O(null);try{const ce={},Se=id();Se&&(ce.Authorization=`Bearer ${Se}`);const ie=await fetch("/api/v1/inventory/colors/sync",{method:"POST",headers:ce});if(!ie.ok)throw new Error("Failed to start sync");const Fe=ie.body?.getReader();if(!Fe)throw new Error("No response body");const V=new TextDecoder;let W="";for(;;){const{done:ue,value:Q}=await Fe.read();if(ue)break;W+=V.decode(Q,{stream:!0});const se=W.split(` + ${u&&q?"sm:border-bambu-dark-tertiary border-bambu-green/40":""} + ${!u&&!B?"border-bambu-dark-tertiary hover:border-bambu-dark-tertiary/80":""} + ${q?"sm:cursor-default":""} + `,onClick:q?()=>{window.innerWidth<640&&d()}:void 0,children:[q&&u&&a.jsx("div",{className:"sm:hidden absolute left-0 top-3 bottom-3 w-1 rounded-full bg-bambu-green"}),a.jsxs("div",{className:"flex items-start sm:items-center gap-2 sm:gap-4 p-3 sm:p-4",children:[R&&d&&a.jsx("button",{onClick:z=>{z.stopPropagation(),d()},className:`hidden sm:flex items-center justify-center w-6 h-6 rounded border transition-colors shrink-0 ${u?"bg-bambu-green border-bambu-green text-white":"border-white/30 bg-black/30 hover:border-bambu-green/50"}`,children:u&&a.jsx(Xr,{className:"w-4 h-4"})}),R?a.jsx("div",{...T,...k,className:"hidden sm:flex items-center justify-center w-8 h-8 rounded-lg bg-bambu-dark cursor-grab active:cursor-grabbing hover:bg-bambu-dark-tertiary transition-colors touch-manipulation shrink-0",children:a.jsx(Dh,{className:"w-4 h-4 text-bambu-gray"})}):e!==void 0?a.jsxs("div",{className:"hidden sm:flex items-center justify-center w-8 h-8 rounded-lg bg-bambu-dark text-bambu-gray text-sm font-medium shrink-0",children:["#",e]}):a.jsx("div",{className:"hidden sm:block w-8 shrink-0"}),a.jsx("div",{className:"w-10 h-10 sm:w-14 sm:h-14 flex-shrink-0 bg-bambu-dark rounded-lg overflow-hidden",children:t.archive_thumbnail?a.jsx("img",{src:t.plate_id!=null?re.getArchivePlateThumbnail(t.archive_id,t.plate_id):re.getArchiveThumbnail(t.archive_id),alt:"",className:"w-full h-full object-cover"}):t.library_file_thumbnail?a.jsx("img",{src:t.plate_id!=null?re.getLibraryFilePlateThumbnail(t.library_file_id,t.plate_id):re.getLibraryFileThumbnailUrl(t.library_file_id),alt:"",className:"w-full h-full object-cover"}):a.jsx("div",{className:"w-full h-full flex items-center justify-center text-bambu-gray",children:a.jsx(ma,{className:"w-5 h-5 sm:w-6 sm:h-6"})})}),a.jsxs("div",{className:"flex-1 min-w-0",children:[a.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[a.jsxs("p",{className:"text-sm sm:text-base text-white font-medium truncate",children:[t.archive_name||t.library_file_name||`File #${t.archive_id||t.library_file_id}`,(N?.is_multi_plate??!1)&&t.plate_id!==void 0&&t.plate_id!==null&&` • ${A.find(z=>z.index===t.plate_id)?.name||x("queue.plateNumber",{index:t.plate_id})}`]}),t.archive_id?a.jsx(Xs,{to:`/archives?highlight=${t.archive_id}`,className:"text-bambu-gray hover:text-bambu-green transition-colors flex-shrink-0",title:x("queue.viewArchive"),children:a.jsx(Kr,{className:"w-3.5 h-3.5"})}):t.library_file_id?a.jsx(Xs,{to:`/library?highlight=${t.library_file_id}`,className:"text-bambu-gray hover:text-bambu-green transition-colors flex-shrink-0",title:x("queue.viewInFileManager"),children:a.jsx(Kr,{className:"w-3.5 h-3.5"})}):null]}),a.jsxs("div",{className:"flex flex-wrap items-center gap-x-3 gap-y-1 text-xs sm:text-sm text-bambu-gray",children:[a.jsxs("span",{className:`flex items-center gap-1 sm:gap-1.5 ${t.printer_id===null&&!t.target_model?"text-orange-400":""} ${t.target_model?"text-blue-400":""}`,children:[a.jsx(Cr,{className:"w-3 h-3 sm:w-3.5 sm:h-3.5"}),a.jsx("span",{className:"truncate max-w-[120px] sm:max-w-none",children:t.target_model?`${x("queue.filter.any")} ${t.target_model}${t.target_location?` @ ${t.target_location}`:""}${t.required_filament_types?.length?` (${t.required_filament_types.join(", ")})`:""}`:t.printer_id===null?x("queue.filter.unassigned"):t.printer_name||`${x("common.printer")} #${t.printer_id}`})]}),t.print_time_seconds&&a.jsxs("span",{className:"flex items-center gap-1 sm:gap-1.5",children:[a.jsx(Iu,{className:"w-3 h-3 sm:w-3.5 sm:h-3.5"}),Zs(t.print_time_seconds)]}),t.filament_used_grams&&a.jsxs("span",{className:"flex items-center gap-1 sm:gap-1.5",children:[a.jsx(_X,{className:"w-3 h-3 sm:w-3.5 sm:h-3.5"}),$ae(t.filament_used_grams)]}),t.created_by_username&&a.jsxs("span",{className:"hidden sm:flex items-center gap-1.5",title:x("queue.addedBy",{name:t.created_by_username}),children:[a.jsx(rd,{className:"w-3.5 h-3.5"}),t.created_by_username]}),R&&!t.manual_start&&a.jsxs("span",{className:"flex items-center gap-1 sm:gap-1.5",children:[a.jsx(Wn,{className:"w-3 h-3 sm:w-3.5 sm:h-3.5"}),NQe(t.scheduled_time,c,x)]})]}),a.jsxs("div",{className:"flex flex-wrap items-center gap-1.5 sm:gap-2 mt-1.5 sm:mt-2",children:[t.manual_start&&a.jsxs("span",{className:"text-[10px] sm:text-xs px-1.5 sm:px-2 py-0.5 bg-purple-500/10 text-purple-400 rounded-full border border-purple-500/20 flex items-center gap-1",children:[a.jsx(fX,{className:"w-2.5 h-2.5 sm:w-3 sm:h-3"}),x("queue.badges.staged")]}),t.require_previous_success&&a.jsx("span",{className:"text-[10px] sm:text-xs px-1.5 sm:px-2 py-0.5 bg-orange-500/10 text-orange-400 rounded-full border border-orange-500/20",children:x("queue.badges.requiresPrevious")}),t.auto_off_after&&a.jsxs("span",{className:"text-[10px] sm:text-xs px-1.5 sm:px-2 py-0.5 bg-blue-500/10 text-blue-400 rounded-full border border-blue-500/20 flex items-center gap-1",children:[a.jsx(fd,{className:"w-2.5 h-2.5 sm:w-3 sm:h-3"}),x("queue.badges.autoPowerOff")]})]}),B&&y&&a.jsxs("div",{className:"mt-2 sm:mt-3",children:[a.jsxs("div",{className:"flex items-center justify-between text-xs sm:text-sm",children:[a.jsx("div",{className:"flex-1 bg-bambu-dark-tertiary rounded-full h-1.5 sm:h-2 mr-3",children:a.jsx("div",{className:"bg-bambu-green h-1.5 sm:h-2 rounded-full transition-all",style:{width:`${y.progress||0}%`}})}),a.jsxs("span",{className:"text-white",children:[Math.round(y.progress||0),"%"]})]}),a.jsxs("div",{className:"flex flex-wrap items-center gap-2 sm:gap-3 mt-1.5 sm:mt-2 text-[10px] sm:text-xs text-bambu-gray",children:[y.remaining_time!=null&&y.remaining_time>0&&a.jsxs(a.Fragment,{children:[a.jsxs("span",{className:"flex items-center gap-1",children:[a.jsx(Wn,{className:"w-3 h-3"}),Zs(y.remaining_time*60)]}),a.jsxs("span",{className:"text-bambu-green font-medium",title:x("printers.estimatedCompletion"),children:["ETA ",$F(y.remaining_time,c,x)]})]}),y.layer_num!=null&&y.total_layers!=null&&y.total_layers>0&&a.jsxs("span",{className:"flex items-center gap-1",children:[a.jsx(ma,{className:"w-3 h-3"}),y.layer_num,"/",y.total_layers]})]})]}),t.waiting_reason&&t.status==="pending"&&a.jsxs("p",{className:"text-[10px] sm:text-xs text-purple-400 mt-1.5 sm:mt-2 flex items-start gap-1",children:[a.jsx(Hi,{className:"w-3 h-3 mt-0.5 flex-shrink-0"}),a.jsx("span",{children:t.waiting_reason})]}),t.error_message&&a.jsxs("p",{className:"text-[10px] sm:text-xs text-red-400 mt-1.5 sm:mt-2 flex items-center gap-1",children:[a.jsx(Hi,{className:"w-3 h-3"}),t.error_message]})]}),a.jsxs("div",{className:"flex flex-col sm:flex-row items-end sm:items-center gap-2 sm:gap-1 shrink-0",onClick:z=>z.stopPropagation(),children:[a.jsx(kQe,{status:t.status,waitingReason:t.waiting_reason,printerState:p,t:x}),a.jsxs("div",{className:"flex items-center gap-0.5 sm:gap-1",children:[B&&a.jsx(Ce,{variant:"ghost",size:"sm",onClick:s,disabled:!h("printers:control"),title:h("printers:control")?x("queue.actions.stopPrint"):x("queue.permissions.noStopPrint"),className:"text-red-400 hover:text-red-300 hover:bg-red-500/10 p-1.5 sm:p-2",children:a.jsx(ahe,{className:"w-4 h-4"})}),R&&a.jsxs(a.Fragment,{children:[t.manual_start&&a.jsx(Ce,{variant:"ghost",size:"sm",onClick:l,disabled:!h("printers:control"),title:h("printers:control")?x("queue.actions.startPrint"):x("queue.permissions.noStartPrint"),className:"text-bambu-green hover:text-bambu-green-light hover:bg-bambu-green/10 p-1.5 sm:p-2",children:a.jsx(so,{className:"w-4 h-4"})}),a.jsx(Ce,{variant:"ghost",size:"sm",onClick:n,disabled:!f("queue","update",t.created_by_id),title:f("queue","update",t.created_by_id)?x("common.edit"):x("queue.permissions.noEdit"),className:"p-1.5 sm:p-2",children:a.jsx(Vi,{className:"w-4 h-4"})}),a.jsx(Ce,{variant:"ghost",size:"sm",onClick:r,disabled:!f("queue","delete",t.created_by_id),title:f("queue","delete",t.created_by_id)?x("common.cancel"):x("queue.permissions.noCancel"),className:"text-red-400 hover:text-red-300 hover:bg-red-500/10 p-1.5 sm:p-2",children:a.jsx(Ft,{className:"w-4 h-4"})})]}),G&&a.jsxs(a.Fragment,{children:[a.jsx(Ce,{variant:"ghost",size:"sm",onClick:o,disabled:!h("queue:create"),title:h("queue:create")?x("queue.actions.requeue"):x("queue.permissions.noRequeue"),className:"text-bambu-green hover:text-bambu-green/80 hover:bg-bambu-green/10 p-1.5 sm:p-2",children:a.jsx(kr,{className:"w-4 h-4"})}),a.jsx(Ce,{variant:"ghost",size:"sm",onClick:i,disabled:!f("queue","delete",t.created_by_id),title:f("queue","delete",t.created_by_id)?x("common.remove"):x("queue.permissions.noRemove"),className:"p-1.5 sm:p-2",children:a.jsx(Jt,{className:"w-4 h-4"})})]})]})]})]})]})}function MQe(){const{t}=Vt(),e=tn(),{showToast:n}=hn(),{hasPermission:r,hasAnyPermission:i,canModify:s}=Ir(),[o,l]=w.useState(null),[c,u]=w.useState(""),[d,h]=w.useState(""),[f,p]=w.useState(!1),[x,y]=w.useState(null),[b,v]=w.useState(null),[S,N]=w.useState(null),[A,C]=w.useState([]),[T,k]=w.useState(!1),[j,E]=w.useState(()=>localStorage.getItem("queue.historySortBy")||"date"),[P,U]=w.useState(()=>{const L=localStorage.getItem("queue.historySortAsc");return L!==null?L==="true":!1}),[O,B]=w.useState(()=>localStorage.getItem("queue.pendingSortBy")||"position"),[R,G]=w.useState(()=>{const L=localStorage.getItem("queue.pendingSortAsc");return L!==null?L==="true":!0});w.useEffect(()=>{localStorage.setItem("queue.historySortBy",j)},[j]),w.useEffect(()=>{localStorage.setItem("queue.historySortAsc",String(P))},[P]),w.useEffect(()=>{localStorage.setItem("queue.pendingSortBy",O)},[O]),w.useEffect(()=>{localStorage.setItem("queue.pendingSortAsc",String(R))},[R]);const q=xae(Vk(OM,{activationConstraint:{distance:8}}),Vk(LM,{coordinateGetter:Bae})),{data:z}=Ze({queryKey:["settings"],queryFn:re.getSettings}),K=z?.time_format||"system",{data:Y,isLoading:oe}=Ze({queryKey:["queue",o,c],queryFn:()=>re.getQueue(o||void 0,c||void 0),refetchInterval:5e3}),{data:$}=Ze({queryKey:["printers"],queryFn:()=>re.getPrinters()}),X=ot({mutationFn:L=>re.cancelQueueItem(L),onSuccess:()=>{e.invalidateQueries({queryKey:["queue"]}),n(t("queue.toast.cancelled"))},onError:()=>n(t("queue.toast.cancelFailed"),"error")}),ee=ot({mutationFn:L=>re.removeFromQueue(L),onSuccess:()=>{e.invalidateQueries({queryKey:["queue"]}),n(t("queue.toast.removed"))},onError:()=>n(t("queue.toast.removeFailed"),"error")}),J=ot({mutationFn:L=>re.stopQueueItem(L),onSuccess:()=>{e.invalidateQueries({queryKey:["queue"]}),n(t("queue.toast.stopped"))},onError:()=>n(t("queue.toast.stopFailed"),"error")}),_e=ot({mutationFn:L=>re.startQueueItem(L),onSuccess:()=>{e.invalidateQueries({queryKey:["queue"]}),n(t("queue.toast.released"))},onError:()=>n(t("queue.toast.startFailed"),"error")}),pe=ot({mutationFn:L=>re.reorderQueue(L),onSuccess:()=>{e.invalidateQueries({queryKey:["queue"]})},onError:()=>n(t("queue.toast.reorderFailed"),"error")}),me=ot({mutationFn:async()=>{const L=Y?.filter(D=>["completed","failed","skipped","cancelled"].includes(D.status))||[];for(const D of L)await re.removeFromQueue(D.id);return L.length},onSuccess:L=>{e.invalidateQueries({queryKey:["queue"]}),n(t("queue.toast.historyCleared",{count:L}))},onError:()=>n(t("queue.toast.clearHistoryFailed"),"error")}),je=ot({mutationFn:L=>re.bulkUpdateQueue(L),onSuccess:L=>{e.invalidateQueries({queryKey:["queue"]}),C([]),k(!1),n(L.message)},onError:()=>n(t("queue.toast.updateFailed"),"error")}),de=ot({mutationFn:async L=>{for(const D of L)await re.cancelQueueItem(D);return L.length},onSuccess:L=>{e.invalidateQueries({queryKey:["queue"]}),C([]),n(t("queue.toast.bulkCancelled",{count:L}))},onError:()=>n(t("queue.toast.bulkCancelFailed"),"error")}),ce=L=>{C(D=>D.includes(L)?D.filter(H=>H!==L):[...D,L])},Se=w.useMemo(()=>{const L=new Set;return $?.forEach(D=>{D.location&&L.add(D.location)}),Y?.forEach(D=>{D.target_location&&L.add(D.target_location)}),Array.from(L).sort()},[$,Y]),ie=w.useCallback(L=>d?L.target_location?L.target_location===d:L.printer_id?$?.find(H=>H.id===L.printer_id)?.location===d:!1:!0,[d,$]),Fe=w.useMemo(()=>{let L=Y?.filter(H=>H.status==="pending")||[];d&&(L=L.filter(ie));const D=H=>{if(!H.scheduled_time)return 0;const he=new Date(H.scheduled_time).getTime(),xe=Date.now()+4320*60*60*1e3;return he>xe?0:he};return[...L].sort((H,he)=>{let xe;if(O==="name"){const be=H.archive_name||H.library_file_name||"",Ue=he.archive_name||he.library_file_name||"";xe=be.localeCompare(Ue)}else O==="printer"?xe=(H.printer_name||"").localeCompare(he.printer_name||""):O==="time"?xe=D(H)-D(he):xe=H.position-he.position;return R?xe:-xe})},[Y,O,R,ie,d]),V=()=>{const L=Fe.map(D=>D.id);A.length===L.length?C([]):C(L)},W=w.useMemo(()=>{let L=Y?.filter(D=>D.status==="printing")||[];return d&&(L=L.filter(ie)),L},[Y,d,ie]),ue=w.useMemo(()=>{const L=new Set;return W.forEach(D=>{D.printer_id&&L.add(D.printer_id)}),Array.from(L)},[W]),Q=DF({queries:ue.map(L=>({queryKey:["printerStatus",L],queryFn:()=>re.getPrinterStatus(L),refetchInterval:5e3}))}),se=w.useMemo(()=>{const L={};return ue.forEach((D,H)=>{const he=Q[H];he?.data?.state&&(L[D]=he.data.state)}),L},[ue,Q]),Z=w.useMemo(()=>{let L=Y?.filter(D=>["completed","failed","skipped","cancelled"].includes(D.status))||[];return d&&(L=L.filter(ie)),[...L].sort((D,H)=>{let he;if(j==="name"){const xe=D.archive_name||D.library_file_name||"",be=H.archive_name||H.library_file_name||"";he=xe.localeCompare(be)}else j==="printer"?he=(D.printer_name||"").localeCompare(H.printer_name||""):he=new Date(H.completed_at||H.created_at).getTime()-new Date(D.completed_at||D.created_at).getTime();return P?-he:he})},[Y,j,P,ie,d]),Ne=w.useMemo(()=>Fe.reduce((L,D)=>L+(D.print_time_seconds||0),0),[Fe]),ve=w.useMemo(()=>Fe.reduce((L,D)=>L+(D.filament_used_grams||0),0),[Fe]),fe=L=>{const{active:D,over:H}=L;if(!H||D.id===H.id)return;const he=Fe.findIndex(be=>be.id===D.id),xe=Fe.findIndex(be=>be.id===H.id);if(he!==-1&&xe!==-1){const Ue=UM(Fe,he,xe).map((Oe,Qe)=>({id:Oe.id,position:Qe+1}));pe.mutate(Ue)}};return a.jsxs("div",{className:"p-4 md:p-8",children:[a.jsx("div",{className:"flex items-center justify-between mb-8",children:a.jsxs("div",{children:[a.jsxs("h1",{className:"text-2xl font-bold text-white flex items-center gap-3",children:[a.jsx(pX,{className:"w-7 h-7 text-bambu-green"}),t("queue.title")]}),a.jsx("p",{className:"text-bambu-gray mt-1",children:t("queue.subtitle")})]})}),a.jsxs("div",{className:"grid grid-cols-2 sm:grid-cols-3 lg:grid-cols-5 gap-2 sm:gap-3 lg:gap-4 mb-8",children:[a.jsx(vt,{className:"bg-gradient-to-br from-blue-500/10 to-transparent border-blue-500/20",children:a.jsx(Nt,{className:"p-3 sm:p-4",children:a.jsxs("div",{className:"flex items-center gap-2 sm:gap-3",children:[a.jsx("div",{className:"w-8 h-8 sm:w-10 sm:h-10 rounded-lg bg-blue-500/20 flex items-center justify-center shrink-0",children:a.jsx(so,{className:"w-4 h-4 sm:w-5 sm:h-5 text-blue-400"})}),a.jsxs("div",{className:"min-w-0",children:[a.jsx("p",{className:"text-xl sm:text-2xl font-bold text-white truncate",children:W.length}),a.jsx("p",{className:"text-xs sm:text-sm text-bambu-gray truncate",children:t("queue.summary.printing")})]})]})})}),a.jsx(vt,{className:"bg-gradient-to-br from-yellow-500/10 to-transparent border-yellow-500/20",children:a.jsx(Nt,{className:"p-3 sm:p-4",children:a.jsxs("div",{className:"flex items-center gap-2 sm:gap-3",children:[a.jsx("div",{className:"w-8 h-8 sm:w-10 sm:h-10 rounded-lg bg-yellow-500/20 flex items-center justify-center shrink-0",children:a.jsx(Wn,{className:"w-4 h-4 sm:w-5 sm:h-5 text-yellow-400"})}),a.jsxs("div",{className:"min-w-0",children:[a.jsx("p",{className:"text-xl sm:text-2xl font-bold text-white truncate",children:Fe.length}),a.jsx("p",{className:"text-xs sm:text-sm text-bambu-gray truncate",children:t("queue.summary.queued")})]})]})})}),a.jsx(vt,{className:"bg-gradient-to-br from-bambu-green/10 to-transparent border-bambu-green/20",children:a.jsx(Nt,{className:"p-3 sm:p-4",children:a.jsxs("div",{className:"flex items-center gap-2 sm:gap-3",children:[a.jsx("div",{className:"w-8 h-8 sm:w-10 sm:h-10 rounded-lg bg-bambu-green/20 flex items-center justify-center shrink-0",children:a.jsx(Iu,{className:"w-4 h-4 sm:w-5 sm:h-5 text-bambu-green"})}),a.jsxs("div",{className:"min-w-0",children:[a.jsx("p",{className:"text-xl sm:text-2xl font-bold text-white truncate",children:Zs(Ne)}),a.jsx("p",{className:"text-xs sm:text-sm text-bambu-gray truncate",children:t("queue.summary.totalTime")})]})]})})}),a.jsx(vt,{className:"bg-gradient-to-br from-purple-500/10 to-transparent border-purple-500/20",children:a.jsx(Nt,{className:"p-3 sm:p-4",children:a.jsxs("div",{className:"flex items-center gap-2 sm:gap-3",children:[a.jsx("div",{className:"w-8 h-8 sm:w-10 sm:h-10 rounded-lg bg-purple-500/20 flex items-center justify-center shrink-0",children:a.jsx(_X,{className:"w-4 h-4 sm:w-5 sm:h-5 text-purple-500"})}),a.jsxs("div",{className:"min-w-0",children:[a.jsx("p",{className:"text-xl sm:text-2xl font-bold text-white truncate",children:$ae(ve)}),a.jsx("p",{className:"text-xs sm:text-sm text-bambu-gray truncate",children:t("queue.summary.totalWeight")})]})]})})}),a.jsx(vt,{className:"col-span-2 sm:col-span-1 bg-gradient-to-br from-gray-500/10 to-transparent border-gray-500/20",children:a.jsx(Nt,{className:"p-3 sm:p-4",children:a.jsxs("div",{className:"flex items-center gap-2 sm:gap-3",children:[a.jsx("div",{className:"w-8 h-8 sm:w-10 sm:h-10 rounded-lg bg-gray-500/20 flex items-center justify-center shrink-0",children:a.jsx(gr,{className:"w-4 h-4 sm:w-5 sm:h-5 text-gray-400"})}),a.jsxs("div",{className:"min-w-0",children:[a.jsx("p",{className:"text-xl sm:text-2xl font-bold text-white truncate",children:Z.length}),a.jsx("p",{className:"text-xs sm:text-sm text-bambu-gray truncate",children:t("queue.summary.history")})]})]})})})]}),a.jsxs("div",{className:"flex flex-wrap items-center gap-2 sm:gap-4 mb-6",children:[a.jsxs("select",{className:"px-2 sm:px-3 py-2 text-sm sm:text-base bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none min-w-0 flex-1 sm:flex-none",value:o===-1?"unassigned":o||"",onChange:L=>{const D=L.target.value;l(D==="unassigned"?-1:D===""?null:Number(D))},children:[a.jsx("option",{value:"",children:t("queue.filter.allPrinters")}),a.jsx("option",{value:"unassigned",children:t("queue.filter.unassigned")}),$?.map(L=>a.jsx("option",{value:L.id,children:L.name},L.id))]}),a.jsxs("select",{className:"px-2 sm:px-3 py-2 text-sm sm:text-base bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none min-w-0 flex-1 sm:flex-none",value:c,onChange:L=>u(L.target.value),children:[a.jsx("option",{value:"",children:t("queue.filter.allStatus")}),a.jsx("option",{value:"pending",children:t("queue.status.pending")}),a.jsx("option",{value:"printing",children:t("queue.status.printing")}),a.jsx("option",{value:"completed",children:t("queue.status.completed")}),a.jsx("option",{value:"failed",children:t("queue.status.failed")}),a.jsx("option",{value:"skipped",children:t("queue.status.skipped")}),a.jsx("option",{value:"cancelled",children:t("queue.status.cancelled")})]}),Se.length>0&&a.jsxs("select",{className:"px-2 sm:px-3 py-2 text-sm sm:text-base bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none min-w-0 flex-1 sm:flex-none",value:d,onChange:L=>h(L.target.value),children:[a.jsx("option",{value:"",children:t("queue.filter.allLocations")}),Se.map(L=>a.jsx("option",{value:L,children:L},L))]}),a.jsx("div",{className:"hidden sm:block flex-1"}),Z.length>0&&a.jsxs(Ce,{className:"w-full sm:w-auto",variant:"secondary",size:"sm",onClick:()=>p(!0),disabled:!r("queue:delete_all"),title:r("queue:delete_all")?void 0:t("queue.permissions.noClearHistory"),children:[a.jsx(Jt,{className:"w-4 h-4"}),t("queue.clearHistory")]})]}),oe?a.jsx("div",{className:"text-center py-12 text-bambu-gray",children:t("common.loading")}):Y?.length===0?a.jsxs(vt,{className:"p-12 text-center border-dashed",children:[a.jsx(ii,{className:"w-16 h-16 text-bambu-gray mx-auto mb-4 opacity-50"}),a.jsx("h3",{className:"text-xl font-medium text-white mb-2",children:t("queue.empty.title")}),a.jsx("p",{className:"text-bambu-gray max-w-md mx-auto",children:t("queue.empty.description")})]}):a.jsxs("div",{className:"space-y-6 sm:space-y-8",children:[W.length>0&&a.jsxs("div",{children:[a.jsxs("h2",{className:"text-base sm:text-lg font-semibold text-white mb-3 sm:mb-4 flex items-center gap-2",children:[a.jsx("div",{className:"w-2 h-2 rounded-full bg-blue-400 animate-pulse"}),t("queue.sections.currentlyPrinting")]}),a.jsx("div",{className:"space-y-2 sm:space-y-3",children:W.map(L=>a.jsx(Uj,{item:L,onEdit:()=>{},onCancel:()=>{},onRemove:()=>{},onStop:()=>N({type:"stop",item:L}),onRequeue:()=>{},onStart:()=>{},timeFormat:K,hasPermission:r,canModify:s,printerState:L.printer_id?se[L.printer_id]:null,t},L.id))})]}),Fe.length>0&&a.jsxs("div",{children:[a.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2 mb-3 sm:mb-4",children:[a.jsxs("h2",{className:"text-base sm:text-lg font-semibold text-white flex items-center gap-2",children:[a.jsx(Wn,{className:"w-4 h-4 sm:w-5 sm:h-5 text-yellow-400"}),t("queue.sections.queued"),a.jsxs("span",{className:"text-xs sm:text-sm font-normal text-bambu-gray",children:["(",t("queue.itemCount",{count:Fe.length}),")"]}),a.jsx("span",{className:"hidden sm:inline text-xs text-bambu-gray ml-2",title:t("queue.reorderHint"),children:t("queue.dragToReorder")})]}),a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsxs("select",{className:"px-2 sm:px-3 py-1.5 text-xs sm:text-sm bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",value:O,onChange:L=>B(L.target.value),children:[a.jsx("option",{value:"position",children:t("queue.sort.byPosition")}),a.jsx("option",{value:"name",children:t("queue.sort.byName")}),a.jsx("option",{value:"printer",children:t("queue.sort.byPrinter")}),a.jsx("option",{value:"time",children:t("queue.sort.bySchedule")})]}),a.jsx(Ce,{variant:"ghost",size:"sm",onClick:()=>G(!R),title:t(R?"common.ascending":"common.descending"),className:"px-2",children:R?a.jsx(Pf,{className:"w-4 h-4"}):a.jsx(hb,{className:"w-4 h-4"})})]})]}),a.jsxs("div",{className:"flex flex-wrap items-center gap-2 sm:gap-3 mb-3 sm:mb-4 p-2 sm:p-3 bg-bambu-dark rounded-lg",children:[a.jsxs(Ce,{variant:"ghost",size:"sm",onClick:V,className:"flex items-center gap-1.5 sm:gap-2 text-xs sm:text-sm",children:[A.length===Fe.length&&Fe.length>0?a.jsx(oo,{className:"w-4 h-4 text-bambu-green"}):a.jsx(bl,{className:"w-4 h-4"}),A.length===Fe.length&&Fe.length>0?t("queue.bulkEdit.deselectAll"):t("queue.bulkEdit.selectAll")]}),A.length>0&&a.jsxs(a.Fragment,{children:[a.jsx("span",{className:"text-xs sm:text-sm text-bambu-gray",children:t("queue.bulkEdit.selected",{count:A.length})}),a.jsx("div",{className:"hidden sm:block h-4 w-px bg-bambu-dark-tertiary"}),a.jsxs(Ce,{variant:"ghost",size:"sm",onClick:()=>k(!0),className:"flex items-center gap-1.5 sm:gap-2 text-xs sm:text-sm text-bambu-green hover:text-bambu-green-light",disabled:!i("queue:update_own","queue:update_all"),title:i("queue:update_own","queue:update_all")?t("queue.bulkEdit.editSelected"):t("queue.permissions.noEditItems"),children:[a.jsx(Vi,{className:"w-3.5 h-3.5 sm:w-4 sm:h-4"}),a.jsx("span",{className:"hidden sm:inline",children:t("queue.bulkEdit.editSelected")})]}),a.jsxs(Ce,{variant:"ghost",size:"sm",onClick:()=>de.mutate(A),className:"flex items-center gap-1.5 sm:gap-2 text-xs sm:text-sm text-red-400 hover:text-red-300",disabled:de.isPending||!i("queue:delete_own","queue:delete_all"),title:i("queue:delete_own","queue:delete_all")?t("queue.bulkEdit.cancelSelected"):t("queue.permissions.noCancelItems"),children:[a.jsx(Ft,{className:"w-3.5 h-3.5 sm:w-4 sm:h-4"}),a.jsx("span",{className:"hidden sm:inline",children:t("queue.bulkEdit.cancelSelected")})]})]})]}),a.jsx(Fae,{sensors:q,collisionDetection:_ae,onDragEnd:fe,children:a.jsx(Iae,{items:Fe.map(L=>L.id),strategy:mQe,children:a.jsx("div",{className:"space-y-2 sm:space-y-3",children:Fe.map((L,D)=>a.jsx(Uj,{item:L,position:D+1,onEdit:()=>y(L),onCancel:()=>N({type:"cancel",item:L}),onRemove:()=>{},onStop:()=>{},onRequeue:()=>{},onStart:()=>_e.mutate(L.id),timeFormat:K,isSelected:A.includes(L.id),onToggleSelect:()=>ce(L.id),hasPermission:r,canModify:s,t},L.id))})})})]}),Z.length>0&&a.jsxs("div",{children:[a.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2 mb-3 sm:mb-4",children:[a.jsxs("h2",{className:"text-base sm:text-lg font-semibold text-white flex items-center gap-2",children:[a.jsx(gr,{className:"w-4 h-4 sm:w-5 sm:h-5 text-bambu-gray"}),t("queue.sections.history"),a.jsxs("span",{className:"text-xs sm:text-sm font-normal text-bambu-gray",children:["(",t("queue.itemCount",{count:Z.length}),")"]})]}),a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsxs("select",{className:"px-2 sm:px-3 py-1.5 text-xs sm:text-sm bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",value:j,onChange:L=>E(L.target.value),children:[a.jsx("option",{value:"date",children:t("queue.sort.byDate")}),a.jsx("option",{value:"name",children:t("queue.sort.byName")}),a.jsx("option",{value:"printer",children:t("queue.sort.byPrinter")})]}),a.jsx(Ce,{variant:"ghost",size:"sm",onClick:()=>U(!P),title:t(P?"queue.sort.ascendingOldest":"queue.sort.descendingNewest"),className:"px-2",children:P?a.jsx(Pf,{className:"w-4 h-4"}):a.jsx(hb,{className:"w-4 h-4"})})]})]}),a.jsx("div",{className:"space-y-2 sm:space-y-3",children:Z.slice(0,20).map((L,D)=>a.jsx(Uj,{item:L,position:D+1,onEdit:()=>{},onCancel:()=>{},onRemove:()=>N({type:"remove",item:L}),onStop:()=>{},onRequeue:()=>v(L),onStart:()=>{},timeFormat:K,hasPermission:r,canModify:s,t},L.id))})]})]}),x&&a.jsx(Qu,{mode:"edit-queue-item",archiveId:x.archive_id??void 0,libraryFileId:x.library_file_id??void 0,archiveName:x.archive_name||x.library_file_name||`File #${x.archive_id||x.library_file_id}`,queueItem:x,onClose:()=>y(null)}),b&&a.jsx(Qu,{mode:"add-to-queue",archiveId:b.archive_id??void 0,libraryFileId:b.library_file_id??void 0,archiveName:b.archive_name||b.library_file_name||`File #${b.archive_id||b.library_file_id}`,onClose:()=>v(null)}),S&&a.jsx(vn,{title:S.type==="cancel"?t("queue.confirm.cancelTitle"):S.type==="stop"?t("queue.confirm.stopTitle"):t("queue.confirm.removeTitle"),message:S.type==="cancel"?t("queue.confirm.cancelMessage",{name:S.item.archive_name||S.item.library_file_name||t("queue.confirm.thisPrint")}):S.type==="stop"?t("queue.confirm.stopMessage",{name:S.item.archive_name||S.item.library_file_name||t("queue.confirm.thisPrint")}):t("queue.confirm.removeMessage",{name:S.item.archive_name||S.item.library_file_name||t("queue.confirm.thisItem")}),confirmText:S.type==="cancel"?t("queue.confirm.cancelButton"):S.type==="stop"?t("queue.confirm.stopButton"):t("common.remove"),variant:"danger",onConfirm:()=>{S.type==="cancel"?X.mutate(S.item.id):S.type==="stop"?J.mutate(S.item.id):ee.mutate(S.item.id),N(null)},onCancel:()=>N(null)}),f&&a.jsx(vn,{title:t("queue.confirm.clearHistoryTitle"),message:t("queue.confirm.clearHistoryMessage",{count:Z.length}),confirmText:t("queue.clearHistory"),variant:"danger",onConfirm:()=>{me.mutate(),p(!1)},onCancel:()=>p(!1)}),T&&a.jsx(CQe,{selectedCount:A.length,printers:$?.map(L=>({id:L.id,name:L.name}))||[],onSave:L=>{Object.keys(L).length>0&&je.mutate({item_ids:A,...L})},onClose:()=>k(!1),isSaving:je.isPending,t})]})}function AQe({printDates:t,months:e=3}){const n=w.useRef(null),[r,i]=w.useState(0);w.useEffect(()=>{const S=n.current;if(!S)return;const N=new ResizeObserver(A=>{const C=A[0]?.contentRect.width||0;i(C)});return N.observe(S),()=>N.disconnect()},[]);const{weeks:s,monthLabels:o,printCounts:l}=w.useMemo(()=>{const S={};t.forEach(U=>{const O=U.split("T")[0];S[O]=(S[O]||0)+1});const N=new Date,A=new Date(N);A.setMonth(A.getMonth()-e),A.setDate(A.getDate()-A.getDay());const C=[],T=[];let k=[],j=-1;const E=new Date(A);let P=0;for(;E<=N;)E.getDay()===0&&k.length>0&&(C.push(k),k=[],P++),E.getMonth()!==j&&(T.push({month:E.toLocaleDateString("en-US",{month:"short"}),weekIndex:P}),j=E.getMonth()),k.push(new Date(E)),E.setDate(E.getDate()+1);return k.length>0&&C.push(k),{weeks:C,monthLabels:T,printCounts:S}},[t,e]),c=Math.max(1,...Object.values(l)),u=S=>{if(S===0)return"bg-bambu-dark";const N=S/c;return N<=.25?"bg-bambu-green/30":N<=.5?"bg-bambu-green/50":N<=.75?"bg-bambu-green/75":"bg-bambu-green"},d=["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],h=s.length,f=32,p=2,x=r-f-16,y=h>0?Math.floor((x-(h-1)*p)/h):12,b=Math.max(8,Math.min(20,y)),v=b<=10?10:12;return a.jsx("div",{ref:n,className:"w-full flex justify-center",children:r>0&&a.jsxs("div",{children:[a.jsx("div",{className:"flex mb-1",style:{marginLeft:f+4},children:o.map(({month:S,weekIndex:N},A)=>a.jsx("div",{className:"text-bambu-gray",style:{fontSize:v,marginLeft:A===0?0:`${(N-(o[A-1]?.weekIndex||0))*(b+p)-24}px`},children:S},A))}),a.jsxs("div",{className:"flex",style:{gap:p},children:[a.jsx("div",{className:"flex flex-col",style:{gap:p,marginRight:4,width:f},children:d.map((S,N)=>a.jsx("div",{className:"text-bambu-gray flex items-center",style:{width:f,height:b,fontSize:v,visibility:N%2===1?"visible":"hidden"},children:S},S))}),s.map((S,N)=>a.jsx("div",{className:"flex flex-col",style:{gap:p},children:[0,1,2,3,4,5,6].map(A=>{const C=S.find(E=>E.getDay()===A);if(!C)return a.jsx("div",{style:{width:b,height:b}},A);const T=C.toISOString().split("T")[0],k=l[T]||0,j=T===new Date().toISOString().split("T")[0];return a.jsx("div",{className:`rounded-sm ${u(k)} ${j?"ring-1 ring-white":""}`,style:{width:b,height:b},title:`${C.toLocaleDateString()}: ${k} print${k!==1?"s":""}`},A)})},N))]}),a.jsxs("div",{className:"flex items-center gap-2 mt-3 text-bambu-gray",style:{fontSize:v},children:[a.jsx("span",{children:"Less"}),a.jsxs("div",{className:"flex",style:{gap:p},children:[a.jsx("div",{className:"rounded-sm bg-bambu-dark",style:{width:b,height:b}}),a.jsx("div",{className:"rounded-sm bg-bambu-green/30",style:{width:b,height:b}}),a.jsx("div",{className:"rounded-sm bg-bambu-green/50",style:{width:b,height:b}}),a.jsx("div",{className:"rounded-sm bg-bambu-green/75",style:{width:b,height:b}}),a.jsx("div",{className:"rounded-sm bg-bambu-green",style:{width:b,height:b}})]}),a.jsx("span",{children:"More"})]})]})})}const WS=["#00ae42","#3b82f6","#f59e0b","#ef4444","#8b5cf6","#ec4899","#14b8a6","#f97316"];function TQe(t){const e=new Date;switch(t){case"7d":return new Date(e.getTime()-10080*60*1e3);case"30d":return new Date(e.getTime()-720*60*60*1e3);case"90d":return new Date(e.getTime()-2160*60*60*1e3);case"365d":return new Date(e.getTime()-365*24*60*60*1e3);case"all":return new Date(0)}}function EQe({archives:t,currency:e="$"}){const[n,r]=w.useState("30d"),i=w.useMemo(()=>{const p=TQe(n);return t.filter(x=>(Zi(x.completed_at||x.created_at)||new Date(0))>=p)},[t,n]),s=w.useMemo(()=>{const p=new Map;return i.forEach(x=>{const y=Zi(x.completed_at||x.created_at)||new Date,b=`${y.getFullYear()}-${String(y.getMonth()+1).padStart(2,"0")}-${String(y.getDate()).padStart(2,"0")}`,v=p.get(b)||{date:b,filament:0,cost:0,prints:0};v.filament+=x.filament_used_grams||0,v.cost+=x.cost||0,v.prints+=x.quantity||1,p.set(b,v)}),Array.from(p.values()).sort((x,y)=>x.date.localeCompare(y.date)).map(x=>({...x,dateLabel:new Date(x.date).toLocaleDateString("en-US",{month:"short",day:"numeric"})}))},[i]),o=w.useMemo(()=>{if(n==="7d"||n==="30d")return s;const p=new Map;return i.forEach(x=>{const y=Zi(x.completed_at||x.created_at)||new Date,b=new Date(y);b.setDate(y.getDate()-y.getDay());const v=`${b.getFullYear()}-${String(b.getMonth()+1).padStart(2,"0")}-${String(b.getDate()).padStart(2,"0")}`,S=p.get(v)||{week:v,filament:0,cost:0,prints:0};S.filament+=x.filament_used_grams||0,S.cost+=x.cost||0,S.prints+=x.quantity||1,p.set(v,S)}),Array.from(p.values()).sort((x,y)=>x.week.localeCompare(y.week)).map(x=>({date:x.week,dateLabel:`Week of ${new Date(x.week).toLocaleDateString("en-US",{month:"short",day:"numeric"})}`,...x}))},[i,s,n]),l=w.useMemo(()=>{const p=new Map;return i.forEach(x=>{const b=(x.filament_type||"Unknown").split(", ");b.forEach(v=>{const S=(x.filament_used_grams||0)/b.length;p.set(v,(p.get(v)||0)+S)})}),Array.from(p.entries()).map(([x,y])=>({name:x,value:Math.round(y)})).sort((x,y)=>y.value-x.value)},[i]),c=w.useMemo(()=>{const p=new Date,x=[];for(let y=5;y>=0;y--){const b=new Date(p.getFullYear(),p.getMonth()-y,1),v=new Date(p.getFullYear(),p.getMonth()-y+1,0),S=b.toLocaleDateString("en-US",{month:"short",year:"2-digit"}),N=t.filter(A=>{const C=Zi(A.completed_at||A.created_at)||new Date(0);return C>=b&&C<=v});x.push({month:S,filament:Math.round(N.reduce((A,C)=>A+(C.filament_used_grams||0),0)),cost:N.reduce((A,C)=>A+(C.cost||0),0),prints:N.reduce((A,C)=>A+(C.quantity||1),0)})}return x},[t]),u=n==="7d"||n==="30d"?s:o,d=i.reduce((p,x)=>p+(x.filament_used_grams||0),0),h=i.reduce((p,x)=>p+(x.cost||0),0),f=i.reduce((p,x)=>p+(x.quantity||1),0);return a.jsxs("div",{className:"space-y-6",children:[a.jsxs("div",{className:"flex items-center justify-between max-[550px]:flex-col max-[550px]:items-start max-[550px]:gap-2",children:[a.jsx("h3",{className:"text-lg font-semibold text-white",children:"Filament Usage Trends"}),a.jsx("div",{className:"flex gap-1 bg-bambu-dark rounded-lg p-1",children:["7d","30d","90d","365d","all"].map(p=>a.jsx("button",{onClick:()=>r(p),className:`px-3 py-1 text-sm rounded-md transition-colors ${n===p?"bg-bambu-green text-white":"text-bambu-gray hover:text-white"}`,children:p==="all"?"All":p.replace("d","D")},p))})]}),a.jsxs("div",{className:"grid grid-cols-3 gap-4 max-[640px]:grid-cols-1",children:[a.jsxs("div",{className:"bg-bambu-dark rounded-lg p-4",children:[a.jsxs("div",{className:"flex items-center justify-between gap-3",children:[a.jsx("p",{className:"text-sm text-bambu-gray leading-none",children:"Period Filament"}),a.jsxs("p",{className:"text-2xl font-bold text-white leading-none",children:[(d/1e3).toFixed(2),"kg"]})]}),a.jsxs("p",{className:"text-xs text-bambu-gray",children:[d.toFixed(0),"g total"]})]}),a.jsxs("div",{className:"bg-bambu-dark rounded-lg p-4",children:[a.jsxs("div",{className:"flex items-center justify-between gap-3",children:[a.jsx("p",{className:"text-sm text-bambu-gray leading-none",children:"Period Cost"}),a.jsxs("p",{className:"text-2xl font-bold text-white leading-none",children:[e,h.toFixed(2)]})]}),a.jsxs("p",{className:"text-xs text-bambu-gray",children:[f," prints"]})]}),a.jsxs("div",{className:"bg-bambu-dark rounded-lg p-4",children:[a.jsxs("div",{className:"flex items-center justify-between gap-3",children:[a.jsx("p",{className:"text-sm text-bambu-gray leading-none",children:"Avg per Print"}),a.jsxs("p",{className:"text-2xl font-bold text-white leading-none",children:[f>0?(d/f).toFixed(0):0,"g"]})]}),a.jsxs("p",{className:"text-xs text-bambu-gray",children:[e,f>0?(h/f).toFixed(2):"0.00"," avg"]})]})]}),u.length>0?a.jsxs("div",{className:"bg-bambu-dark rounded-lg p-4",children:[a.jsx("h4",{className:"text-sm font-medium text-bambu-gray mb-4",children:"Usage Over Time"}),a.jsx(h1,{width:"100%",height:250,children:a.jsxs(kHe,{data:u,children:[a.jsx("defs",{children:a.jsxs("linearGradient",{id:"colorFilament",x1:"0",y1:"0",x2:"0",y2:"1",children:[a.jsx("stop",{offset:"5%",stopColor:"#00ae42",stopOpacity:.3}),a.jsx("stop",{offset:"95%",stopColor:"#00ae42",stopOpacity:0})]})}),a.jsx(BN,{strokeDasharray:"3 3",stroke:"#3d3d3d"}),a.jsx(GN,{dataKey:"dateLabel",stroke:"#9ca3af",tick:{fontSize:12},interval:"preserveStartEnd"}),a.jsx(qN,{stroke:"#9ca3af",tick:{fontSize:12},tickFormatter:p=>`${p}g`}),a.jsx(f1,{contentStyle:{backgroundColor:"#2d2d2d",border:"1px solid #3d3d3d",borderRadius:"8px"},labelStyle:{color:"#fff"},formatter:p=>[`${Number(p??0).toFixed(0)}g`,"Filament"]}),a.jsx(Vte,{type:"monotone",dataKey:"filament",stroke:"#00ae42",strokeWidth:2,fillOpacity:1,fill:"url(#colorFilament)"})]})})]}):a.jsx("div",{className:"bg-bambu-dark rounded-lg p-8 text-center text-bambu-gray",children:"No data for selected time range"}),a.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-6",children:[a.jsxs("div",{className:"bg-bambu-dark rounded-lg p-4",children:[a.jsx("h4",{className:"text-sm font-medium text-bambu-gray mb-4",children:"By Filament Type"}),l.length>0?a.jsxs("div",{className:"flex items-center gap-4",children:[a.jsx(h1,{width:160,height:160,children:a.jsxs(SHe,{children:[a.jsx(gte,{data:l,cx:"50%",cy:"50%",innerRadius:40,outerRadius:70,paddingAngle:2,dataKey:"value",children:l.map((p,x)=>a.jsx(Vv,{fill:WS[x%WS.length]},`cell-${x}`))}),a.jsx(f1,{contentStyle:{backgroundColor:"#2d2d2d",border:"1px solid #3d3d3d",borderRadius:"8px"},formatter:p=>[`${p??0}g`,"Usage"]})]})}),a.jsx("div",{className:"flex-1 space-y-2 overflow-hidden",children:l.map((p,x)=>{const y=l.reduce((v,S)=>v+S.value,0),b=y>0?(p.value/y*100).toFixed(0):0;return a.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[a.jsx("div",{className:"w-3 h-3 rounded-sm flex-shrink-0",style:{backgroundColor:WS[x%WS.length]}}),a.jsx("span",{className:"text-white truncate flex-1",children:p.name}),a.jsxs("span",{className:"text-bambu-gray flex-shrink-0",children:[b,"%"]})]},p.name)})})]}):a.jsx("div",{className:"h-[160px] flex items-center justify-center text-bambu-gray",children:"No filament data"})]}),a.jsxs("div",{className:"bg-bambu-dark rounded-lg p-4",children:[a.jsx("h4",{className:"text-sm font-medium text-bambu-gray mb-4",children:"Monthly Comparison"}),a.jsx(h1,{width:"100%",height:200,children:a.jsxs(dHe,{data:c,children:[a.jsx(BN,{strokeDasharray:"3 3",stroke:"#3d3d3d"}),a.jsx(GN,{dataKey:"month",stroke:"#9ca3af",tick:{fontSize:12}}),a.jsx(qN,{stroke:"#9ca3af",tick:{fontSize:12},tickFormatter:p=>`${p}g`}),a.jsx(f1,{contentStyle:{backgroundColor:"#2d2d2d",border:"1px solid #3d3d3d",borderRadius:"8px"},formatter:(p,x)=>[x==="filament"?`${p??0}g`:x==="cost"?`${e}${Number(p??0).toFixed(2)}`:p??0,x==="filament"?"Filament":x==="cost"?"Cost":"Prints"]}),a.jsx(WL,{}),a.jsx(Xte,{dataKey:"filament",name:"Filament (g)",fill:"#00ae42",radius:[4,4,0,0]})]})})]})]})]})}function PQe({id:t,title:e,component:n,isHidden:r,size:i,columnSpan:s,onToggleVisibility:o,onToggleSize:l}){const{attributes:c,listeners:u,setNodeRef:d,transform:h,transition:f,isDragging:p}=Uae({id:t}),x={transform:Ub.Transform.toString(h),transition:f,opacity:p?.5:1};return r?null:a.jsxs("div",{ref:d,style:{...x,gridColumn:`span ${s}`},className:`bg-bambu-dark-secondary rounded-xl border border-bambu-dark-tertiary overflow-hidden ${p?"ring-2 ring-bambu-green shadow-lg":""}`,children:[a.jsxs("div",{className:"flex items-center justify-between px-4 py-3 border-b border-bambu-dark-tertiary bg-bambu-dark/30",children:[a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx("button",{...c,...u,className:"cursor-grab active:cursor-grabbing p-1 hover:bg-bambu-dark-tertiary rounded transition-colors",title:"Drag to reorder",children:a.jsx(Dh,{className:"w-6 h-6 md:w-4 md:h-4 text-bambu-gray"})}),a.jsx("h3",{className:"text-sm font-medium text-white",children:e})]}),a.jsxs("div",{className:"flex items-center gap-1",children:[a.jsx("button",{onClick:l,className:"p-1 hover:bg-bambu-dark-tertiary rounded transition-colors",title:`Size: ${i===1?"1/4":i===2?"1/2":"Full"} - Click to cycle`,children:i===4?a.jsx(LF,{className:"w-4 h-4 text-bambu-gray hover:text-white"}):a.jsx(iC,{className:"w-4 h-4 text-bambu-gray hover:text-white"})}),a.jsx("button",{onClick:o,className:"p-1 hover:bg-bambu-dark-tertiary rounded transition-colors",title:"Hide widget",children:a.jsx(gv,{className:"w-4 h-4 text-bambu-gray hover:text-white"})})]})]}),a.jsx("div",{className:"p-4",children:typeof n=="function"?n(i):n})]})}function jQe({widgets:t,storageKey:e,columns:n=4,stackBelow:r,hideControls:i=!1,onResetLayout:s,renderControls:o}){const l=()=>{const j={};return t.forEach(E=>{j[E.id]=E.defaultSize||4}),j},[c,u]=w.useState(()=>{const j=localStorage.getItem(e);if(j)try{const E=JSON.parse(j);return E.sizes||(E.sizes=l()),E}catch{}return{order:t.map(E=>E.id),hidden:t.filter(E=>E.defaultVisible===!1).map(E=>E.id),sizes:l()}}),[d,h]=w.useState(!1),[f,p]=w.useState(!1);w.useEffect(()=>{if(!r)return;const j=window.matchMedia(`(max-width: ${r}px)`),E=U=>{p(U.matches)};E(j);const P=U=>E(U);return j.addEventListener?j.addEventListener("change",P):j.addListener(P),()=>{j.removeEventListener?j.removeEventListener("change",P):j.removeListener(P)}},[r]);const x=r&&f?1:n;w.useEffect(()=>{const j=()=>h(E=>!E);return window.addEventListener("toggle-hidden-panel",j),()=>window.removeEventListener("toggle-hidden-panel",j)},[]),w.useEffect(()=>{localStorage.setItem(e,JSON.stringify(c))},[c,e]),w.useEffect(()=>{const E=t.map(P=>P.id).filter(P=>!c.order.includes(P));E.length>0&&u(P=>({...P,order:[...P.order,...E]}))},[t,c.order]);const y=xae(Vk(OM,{activationConstraint:{distance:8}}),Vk(LM,{coordinateGetter:Bae})),b=j=>{const{active:E,over:P}=j;P&&E.id!==P.id&&u(U=>{const O=U.order.indexOf(E.id),B=U.order.indexOf(P.id);return{...U,order:UM(U.order,O,B)}})},v=j=>{u(E=>({...E,hidden:E.hidden.includes(j)?E.hidden.filter(P=>P!==j):[...E.hidden,j]}))},S=j=>{u(E=>{const P=E.sizes[j]||4,U=P===1?2:P===2?4:1;return{...E,sizes:{...E.sizes,[j]:U}}})},N=()=>{const j={order:t.map(E=>E.id),hidden:t.filter(E=>E.defaultVisible===!1).map(E=>E.id),sizes:l()};u(j),s?.()},A=c.order.map(j=>t.find(E=>E.id===j)).filter(Boolean),C=A.filter(j=>!c.hidden.includes(j.id)),T=A.filter(j=>c.hidden.includes(j.id)),k=o?.({hiddenCount:T.length,showHiddenPanel:d,setShowHiddenPanel:h,resetLayout:N});return a.jsxs("div",{className:"space-y-4",children:[k,!i&&!o&&a.jsxs("div",{className:"flex items-center justify-end gap-2",children:[a.jsxs(Ce,{variant:"secondary",size:"sm",onClick:N,children:[a.jsx(Ro,{className:"w-4 h-4"}),"Reset Layout"]}),T.length>0&&a.jsxs(Ce,{variant:"secondary",size:"sm",onClick:()=>h(!d),children:[a.jsx(Xl,{className:"w-4 h-4"}),T.length," Hidden"]})]}),d&&T.length>0&&a.jsxs("div",{className:"p-4 bg-bambu-dark rounded-xl border border-bambu-dark-tertiary",children:[a.jsx("p",{className:"text-sm text-bambu-gray mb-3",children:"Hidden widgets (click to show):"}),a.jsx("div",{className:"flex flex-wrap gap-2",children:T.map(j=>a.jsxs("button",{onClick:()=>v(j.id),className:"px-3 py-1.5 bg-bambu-dark-tertiary hover:bg-bambu-green/20 rounded-lg text-sm text-white transition-colors flex items-center gap-2",children:[a.jsx(Xl,{className:"w-3 h-3"}),j.title]},j.id))})]}),a.jsx(Fae,{sensors:y,collisionDetection:_ae,onDragEnd:b,children:a.jsx(Iae,{items:C.map(j=>j.id),strategy:bI,children:a.jsx("div",{className:"grid gap-6",style:{gridTemplateColumns:`repeat(${x}, minmax(0, 1fr))`},children:C.map(j=>{const E=c.sizes[j.id]||2,P=Math.min(E,x);return a.jsx(PQe,{id:j.id,title:j.title,component:j.component,isHidden:c.hidden.includes(j.id),size:E,columnSpan:P,onToggleVisibility:()=>v(j.id),onToggleSize:()=>S(j.id)},j.id)})})})}),C.length===0&&a.jsxs("div",{className:"text-center py-12 text-bambu-gray",children:[a.jsx("p",{children:"All widgets are hidden."}),a.jsx(Ce,{className:"mt-4",onClick:N,children:"Reset Layout"})]})]})}const DQe={USD:"$",EUR:"€",GBP:"£",CHF:"Fr.",JPY:"¥",CNY:"¥",CAD:"$",AUD:"$",INR:"₹",HKD:"HK$",KRW:"₩",SEK:"kr",NOK:"kr",DKK:"kr",PLN:"zł",BRL:"R$",TWD:"NT$",SGD:"S$",NZD:"NZ$",MXN:"MX$",CZK:"Kč",THB:"฿",ZAR:"R",TRY:"₺",RUB:"₽"};function ju(t){return DQe[t.toUpperCase()]||t}const RQe=[{code:"USD",label:"USD ($)"},{code:"EUR",label:"EUR (€)"},{code:"GBP",label:"GBP (£)"},{code:"CHF",label:"CHF (Fr.)"},{code:"JPY",label:"JPY (¥)"},{code:"CNY",label:"CNY (¥)"},{code:"CAD",label:"CAD ($)"},{code:"AUD",label:"AUD ($)"},{code:"INR",label:"INR (₹)"},{code:"HKD",label:"HKD (HK$)"},{code:"KRW",label:"KRW (₩)"},{code:"SEK",label:"SEK (kr)"},{code:"NOK",label:"NOK (kr)"},{code:"DKK",label:"DKK (kr)"},{code:"PLN",label:"PLN (zł)"},{code:"BRL",label:"BRL (R$)"},{code:"TWD",label:"TWD (NT$)"},{code:"SGD",label:"SGD (S$)"},{code:"NZD",label:"NZD (NZ$)"},{code:"MXN",label:"MXN (MX$)"},{code:"CZK",label:"CZK (Kč)"},{code:"THB",label:"THB (฿)"},{code:"ZAR",label:"ZAR (R)"},{code:"TRY",label:"TRY (₺)"},{code:"RUB",label:"RUB (₽)"}];function FQe({stats:t,currency:e,t:n}){return a.jsxs("div",{className:"grid grid-cols-2 sm:grid-cols-3 gap-4",children:[a.jsxs("div",{className:"flex items-start gap-3",children:[a.jsx("div",{className:"p-2 rounded-lg bg-bambu-dark text-bambu-green",children:a.jsx(fa,{className:"w-5 h-5"})}),a.jsxs("div",{children:[a.jsx("p",{className:"text-xs text-bambu-gray",children:n("stats.totalPrints")}),a.jsx("p",{className:"text-xl font-bold text-white",children:t?.total_prints||0})]})]}),a.jsxs("div",{className:"flex items-start gap-3",children:[a.jsx("div",{className:"p-2 rounded-lg bg-bambu-dark text-blue-400",children:a.jsx(Wn,{className:"w-5 h-5"})}),a.jsxs("div",{children:[a.jsx("p",{className:"text-xs text-bambu-gray",children:n("stats.printTime")}),a.jsxs("p",{className:"text-xl font-bold text-white",children:[t?.total_print_time_hours.toFixed(1)||0,"h"]})]})]}),a.jsxs("div",{className:"flex items-start gap-3",children:[a.jsx("div",{className:"p-2 rounded-lg bg-bambu-dark text-orange-400",children:a.jsx(fa,{className:"w-5 h-5"})}),a.jsxs("div",{children:[a.jsx("p",{className:"text-xs text-bambu-gray",children:n("stats.filamentUsed")}),a.jsxs("p",{className:"text-xl font-bold text-white",children:[((t?.total_filament_grams||0)/1e3).toFixed(2),"kg"]})]})]}),a.jsxs("div",{className:"flex items-start gap-3",children:[a.jsx("div",{className:"p-2 rounded-lg bg-bambu-dark text-green-400",children:a.jsx(f3,{className:"w-5 h-5"})}),a.jsxs("div",{children:[a.jsx("p",{className:"text-xs text-bambu-gray",children:n("stats.filamentCost")}),a.jsxs("p",{className:"text-xl font-bold text-white",children:[e," ",t?.total_cost.toFixed(2)||"0.00"]})]})]}),a.jsxs("div",{className:"flex items-start gap-3",children:[a.jsx("div",{className:"p-2 rounded-lg bg-bambu-dark text-yellow-400",children:a.jsx(Wh,{className:"w-5 h-5"})}),a.jsxs("div",{children:[a.jsx("p",{className:"text-xs text-bambu-gray",children:n("stats.energyUsed")}),a.jsxs("p",{className:"text-xl font-bold text-white",children:[t?.total_energy_kwh.toFixed(2)||"0.00"," kWh"]})]})]}),a.jsxs("div",{className:"flex items-start gap-3",children:[a.jsx("div",{className:"p-2 rounded-lg bg-bambu-dark text-yellow-500",children:a.jsx(f3,{className:"w-5 h-5"})}),a.jsxs("div",{children:[a.jsx("p",{className:"text-xs text-bambu-gray",children:n("stats.energyCost")}),a.jsxs("p",{className:"text-xl font-bold text-white",children:[e," ",t?.total_energy_cost.toFixed(2)||"0.00"]})]})]})]})}function LQe({stats:t,printerMap:e,size:n=1,t:r}){const i=t?.total_prints?Math.round(t.successful_prints/t.total_prints*100):0,s=n===1?112:n===2?128:144,o=s/2-8,l=o*2*Math.PI;return a.jsxs("div",{className:"flex items-center gap-6",children:[a.jsxs("div",{className:"relative flex-shrink-0",style:{width:s,height:s},children:[a.jsxs("svg",{className:"w-full h-full -rotate-90",children:[a.jsx("circle",{cx:s/2,cy:s/2,r:o,fill:"none",stroke:"#3d3d3d",strokeWidth:"10"}),a.jsx("circle",{cx:s/2,cy:s/2,r:o,fill:"none",stroke:"#00ae42",strokeWidth:"10",strokeLinecap:"round",strokeDasharray:`${i/100*l} ${l}`})]}),a.jsx("div",{className:"absolute inset-0 flex items-center justify-center",children:a.jsxs("span",{className:`font-bold text-white ${n>=2?"text-2xl":"text-xl"}`,children:[i,"%"]})})]}),a.jsxs("div",{className:"flex-1 min-w-0",children:[a.jsxs("div",{className:"space-y-2",children:[a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx(gr,{className:"w-4 h-4 text-status-ok flex-shrink-0"}),a.jsx("span",{className:"text-sm text-bambu-gray",children:r("stats.successful")}),a.jsx("span",{className:"text-sm text-white font-medium",children:t?.successful_prints||0})]}),a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx(ha,{className:"w-4 h-4 text-status-error flex-shrink-0"}),a.jsx("span",{className:"text-sm text-bambu-gray",children:r("stats.failed")}),a.jsx("span",{className:"text-sm text-white font-medium",children:t?.failed_prints||0})]})]}),n>=2&&t?.prints_by_printer&&Object.keys(t.prints_by_printer).length>0&&a.jsxs("div",{className:"mt-4 pt-4 border-t border-bambu-dark-tertiary",children:[a.jsx("p",{className:"text-xs text-bambu-gray font-medium mb-2",children:r("stats.printsByPrinter")}),a.jsx("div",{className:`grid gap-x-6 gap-y-1 ${n===4?"grid-cols-3":"grid-cols-2"}`,style:{width:"fit-content"},children:Object.entries(t.prints_by_printer).map(([c,u])=>a.jsxs("div",{className:"flex items-center gap-3 text-sm",children:[a.jsx("span",{className:"text-bambu-gray truncate max-w-[120px]",children:e.get(c)||`${r("common.printer")} ${c}`}),a.jsx("span",{className:"text-white font-medium",children:u})]},c))})]})]})]})}function OQe({stats:t,printerMap:e,size:n=1,t:r}){const i=t?.average_time_accuracy;if(i==null)return a.jsx("div",{className:"flex items-center justify-center h-full",children:a.jsx("p",{className:"text-bambu-gray text-center py-4",children:r("stats.noTimeAccuracyData")})});const o=(Math.min(150,Math.max(50,i))-50)/100*100,c=(y=>y>=95&&y<=105?"#00ae42":y>105?"#3b82f6":"#f97316")(i),u=i-100,d=n===1?112:n===2?128:144,h=d/2-8,f=h*2*Math.PI,p=n===1?3:n===2?6:999,x=t?.time_accuracy_by_printer?Object.entries(t.time_accuracy_by_printer).slice(0,p):[];return a.jsxs("div",{className:"flex items-center gap-6",children:[a.jsxs("div",{className:"relative flex-shrink-0",style:{width:d,height:d},children:[a.jsxs("svg",{className:"w-full h-full -rotate-90",children:[a.jsx("circle",{cx:d/2,cy:d/2,r:h,fill:"none",stroke:"#3d3d3d",strokeWidth:"10"}),a.jsx("circle",{cx:d/2,cy:d/2,r:h,fill:"none",stroke:c,strokeWidth:"10",strokeLinecap:"round",strokeDasharray:`${o/100*f} ${f}`})]}),a.jsxs("div",{className:"absolute inset-0 flex flex-col items-center justify-center",children:[a.jsxs("span",{className:`font-bold text-white ${n>=2?"text-2xl":"text-xl"}`,children:[i.toFixed(0),"%"]}),a.jsxs("span",{className:`text-xs ${u>=0?"text-blue-400":"text-orange-400"}`,children:[u>=0?"+":"",u.toFixed(0),"%"]})]})]}),a.jsxs("div",{className:"flex-1 min-w-0",children:[a.jsxs("div",{className:"flex items-center gap-2 text-xs text-bambu-gray",children:[a.jsx(vX,{className:"w-3 h-3 flex-shrink-0"}),a.jsx("span",{children:r("stats.perfectEstimate")})]}),x.length>0&&a.jsx("div",{className:`mt-2 ${n===4?"grid grid-cols-3 gap-x-6 gap-y-1":n===2?"grid grid-cols-2 gap-x-6 gap-y-1":"space-y-1"}`,style:{width:"fit-content"},children:x.map(([y,b])=>a.jsxs("div",{className:"flex items-center gap-2 text-xs",children:[a.jsx("span",{className:"text-bambu-gray truncate max-w-[100px]",children:e.get(y)||`${r("common.printer")} ${y}`}),a.jsxs("span",{className:`font-medium ${b>=95&&b<=105?"text-status-ok":b>105?"text-blue-400":"text-status-warning"}`,children:[b.toFixed(0),"%"]})]},y))})]})]})}function IQe({stats:t,size:e=1,t:n}){if(!t?.prints_by_filament_type||Object.keys(t.prints_by_filament_type).length===0)return a.jsx("p",{className:"text-bambu-gray text-center py-4",children:n("stats.noFilamentData")});const r=Object.entries(t.prints_by_filament_type).sort(([,l],[,c])=>c-l),i=e===1?5:e===2?8:999,s=r.slice(0,i),o=r.length>i;return e===4&&s.length>4?a.jsx("div",{className:"grid grid-cols-2 lg:grid-cols-3 gap-4",children:s.map(([l,c])=>{const u=Math.round(c/(t.total_prints||1)*100);return a.jsxs("div",{children:[a.jsxs("div",{className:"flex justify-between text-sm mb-1",children:[a.jsx("span",{className:"text-white truncate max-w-[120px]",children:l}),a.jsx("span",{className:"text-bambu-gray",children:c})]}),a.jsx("div",{className:"h-2 bg-bambu-dark rounded-full",children:a.jsx("div",{className:"h-full bg-bambu-green rounded-full transition-all",style:{width:`${u}%`}})})]},l)})}):a.jsxs("div",{className:"space-y-3",children:[s.map(([l,c])=>{const u=Math.round(c/(t.total_prints||1)*100);return a.jsxs("div",{children:[a.jsxs("div",{className:"flex justify-between text-sm mb-1",children:[a.jsx("span",{className:"text-white",children:l}),a.jsxs("span",{className:"text-bambu-gray",children:[c," ",n("common.prints")]})]}),a.jsx("div",{className:"h-2 bg-bambu-dark rounded-full",children:a.jsx("div",{className:"h-full bg-bambu-green rounded-full transition-all",style:{width:`${u}%`}})})]},l)}),o&&a.jsx("p",{className:"text-xs text-bambu-gray text-center pt-1",children:n("common.more",{count:r.length-i})})]})}function zQe({printDates:t,size:e=2}){const n=e===1?3:e===2?6:12;return a.jsx(AQe,{printDates:t,months:n})}function UQe({stats:t,printerMap:e,t:n}){return!t?.prints_by_printer||Object.keys(t.prints_by_printer).length===0?a.jsx("p",{className:"text-bambu-gray text-center py-4",children:n("stats.noPrinterData")}):a.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-3",children:Object.entries(t.prints_by_printer).map(([r,i])=>a.jsxs("div",{className:"flex items-center gap-3 p-3 bg-bambu-dark rounded-lg",children:[a.jsx("div",{className:"p-2 bg-bambu-dark-tertiary rounded-lg",children:a.jsx(Cr,{className:"w-4 h-4 text-bambu-green"})}),a.jsxs("div",{children:[a.jsx("p",{className:"text-white font-medium text-sm",children:e.get(r)||`${n("common.printer")} ${r}`}),a.jsxs("p",{className:"text-xs text-bambu-gray",children:[i," ",n("common.prints")]})]})]},r))})}function BQe({archives:t,currency:e,t:n}){return!t||t.length===0?a.jsx("p",{className:"text-bambu-gray text-center py-4",children:n("stats.noPrintData")}):a.jsx(EQe,{archives:t,currency:e})}function HQe({size:t=1,t:e}){const{data:n,isLoading:r}=Ze({queryKey:["failureAnalysis"],queryFn:()=>re.getFailureAnalysis({days:30})});if(r)return a.jsx("div",{className:"flex justify-center py-4",children:a.jsx(it,{className:"w-6 h-6 text-bambu-green animate-spin"})});if(!n||n.total_prints===0)return a.jsx("p",{className:"text-bambu-gray text-center py-4",children:e("stats.noPrintDataLast30Days")});const i=t===1?5:t===2?8:999,s=Object.entries(n.failures_by_reason).sort(([,c],[,u])=>u-c),o=s.slice(0,i),l=s.length>i;return a.jsxs("div",{className:`${t>=2?"flex gap-8":"space-y-4"}`,children:[a.jsxs("div",{className:t>=2?"flex-shrink-0":"",children:[a.jsx("div",{className:"flex items-center gap-4",children:a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx(Cn,{className:`w-5 h-5 ${n.failure_rate>20?"text-status-error":n.failure_rate>10?"text-status-warning":"text-status-ok"}`}),a.jsxs("span",{className:`font-bold text-white ${t>=2?"text-3xl":"text-2xl"}`,children:[n.failure_rate.toFixed(1),"%"]})]})}),a.jsx("div",{className:"text-sm text-bambu-gray mt-1",children:e("stats.failedPrintsCount",{failed:n.failed_prints,total:n.total_prints})}),n.trend&&n.trend.length>=2&&a.jsx("div",{className:`${t>=2?"mt-4":"mt-2 pt-2 border-t border-bambu-dark-tertiary"}`,children:a.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[a.jsx(zF,{className:`w-4 h-4 ${n.trend[n.trend.length-1].failure_rate0&&a.jsxs("div",{className:`flex-1 ${t>=2?"border-l border-bambu-dark-tertiary pl-8":"pt-2"}`,children:[a.jsx("p",{className:"text-xs text-bambu-gray font-medium mb-2",children:t>=2?e("stats.failureReasons"):e("stats.topFailureReasons")}),a.jsx("div",{className:`${t===4?"grid grid-cols-2 gap-x-6 gap-y-1":"space-y-1"}`,children:o.map(([c,u])=>a.jsxs("div",{className:"flex items-center justify-between text-sm",children:[a.jsx("span",{className:`text-white truncate ${t===4?"max-w-[200px]":"max-w-[160px]"}`,children:c||e("common.unknown")}),a.jsx("span",{className:"text-bambu-gray ml-2",children:u})]},c))}),l&&a.jsx("p",{className:"text-xs text-bambu-gray mt-2",children:e("common.more",{count:s.length-i})})]})]})}function $Qe(){const{t}=Vt(),{showToast:e}=hn(),{hasPermission:n}=Ir(),[r,i]=w.useState(!1),[s,o]=w.useState(!1),[l,c]=w.useState(0),[u,d]=w.useState(0),[h,f]=w.useState(!1);w.useEffect(()=>{const E=()=>{try{const U=localStorage.getItem("bambusy-dashboard-layout");if(U){const O=JSON.parse(U);d(O.hidden?.length||0)}}catch{d(0)}};E(),window.addEventListener("storage",E);const P=setInterval(E,500);return()=>{window.removeEventListener("storage",E),clearInterval(P)}},[l]);const{data:p,isLoading:x,refetch:y}=Ze({queryKey:["archiveStats"],queryFn:re.getArchiveStats}),{data:b}=Ze({queryKey:["printers"],queryFn:re.getPrinters}),{data:v}=Ze({queryKey:["archives"],queryFn:()=>re.getArchives(void 0,void 0,1e3,0)}),{data:S}=Ze({queryKey:["settings"],queryFn:re.getSettings}),N=async E=>{o(!1),i(!0);try{const{blob:P,filename:U}=await re.exportStats({format:E,days:90}),O=URL.createObjectURL(P),B=document.createElement("a");B.href=O,B.download=U,B.click(),URL.revokeObjectURL(O),e(t("stats.exportDownloaded"))}catch{e(t("stats.exportFailed"),"error")}finally{i(!1)}},A=async()=>{f(!0);try{const E=await re.recalculateCosts();await y(),e(t("stats.recalculatedCosts",{count:E.updated}))}catch{e(t("stats.recalculateFailed"),"error")}finally{f(!1)}},C=ju(S?.currency||"USD"),T=new Map(b?.map(E=>[String(E.id),E.name])||[]),k=v?.map(E=>E.created_at)||[];if(x)return a.jsx("div",{className:"p-4 md:p-8",children:a.jsx("div",{className:"text-center py-12 text-bambu-gray",children:t("stats.loadingStats")})});const j=[{id:"quick-stats",title:t("stats.quickStats"),component:a.jsx(FQe,{stats:p,currency:C,t}),defaultSize:2},{id:"success-rate",title:t("stats.successRate"),component:E=>a.jsx(LQe,{stats:p,printerMap:T,size:E,t}),defaultSize:1},{id:"time-accuracy",title:t("stats.timeAccuracy"),component:E=>a.jsx(OQe,{stats:p,printerMap:T,size:E,t}),defaultSize:1},{id:"filament-types",title:t("stats.filamentTypes"),component:E=>a.jsx(IQe,{stats:p,size:E,t}),defaultSize:1},{id:"failure-analysis",title:t("stats.failureAnalysis"),component:E=>a.jsx(HQe,{size:E,t}),defaultSize:1},{id:"print-activity",title:t("stats.printActivity"),component:E=>a.jsx(zQe,{printDates:k,size:E}),defaultSize:2},{id:"prints-by-printer",title:t("stats.printsByPrinter"),component:a.jsx(UQe,{stats:p,printerMap:T,t}),defaultSize:2},{id:"filament-trends",title:t("stats.filamentTrends"),component:a.jsx(BQe,{archives:v||[],currency:C,t}),defaultSize:4}];return a.jsxs("div",{className:"p-4 md:p-8",children:[a.jsxs("div",{className:"flex flex-col sm:flex-row sm:items-center sm:justify-between gap-4 mb-6",children:[a.jsxs("div",{children:[a.jsx("h1",{className:"text-2xl font-bold text-white",children:t("stats.title")}),a.jsx("p",{className:"text-bambu-gray",children:t("stats.subtitle")})]}),a.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[u>0&&a.jsxs(Ce,{variant:"secondary",onClick:()=>{window.dispatchEvent(new CustomEvent("toggle-hidden-panel"))},children:[a.jsx(Xl,{className:"w-4 h-4"}),t("stats.hiddenCount",{count:u})]}),a.jsxs(Ce,{variant:"secondary",onClick:()=>{localStorage.removeItem("bambusy-dashboard-layout"),c(E=>E+1),e(t("stats.layoutReset"))},disabled:!n("settings:update"),title:n("settings:update")?void 0:t("stats.noPermissionResetLayout"),children:[a.jsx(Ro,{className:"w-4 h-4"}),t("stats.resetLayout")]}),a.jsxs(Ce,{variant:"secondary",onClick:A,disabled:h||!n("archives:update_all"),title:n("archives:update_all")?t("stats.recalculateCostsHint"):t("stats.noPermissionRecalculate"),children:[h?a.jsx(it,{className:"w-4 h-4 animate-spin"}):a.jsx(Ide,{className:"w-4 h-4"}),t("stats.recalculateCosts")]}),a.jsxs("div",{className:"relative",children:[a.jsxs(Ce,{variant:"secondary",onClick:()=>o(!s),disabled:r,children:[r?a.jsx(it,{className:"w-4 h-4 animate-spin"}):a.jsx(P1,{className:"w-4 h-4"}),t("stats.exportStats")]}),s&&a.jsxs("div",{className:"absolute right-0 top-full mt-1 w-48 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg shadow-xl z-20",children:[a.jsxs("button",{className:"w-full px-4 py-2 text-left text-white hover:bg-bambu-dark-tertiary transition-colors flex items-center gap-2 rounded-t-lg",onClick:()=>N("csv"),children:[a.jsx(Ps,{className:"w-4 h-4"}),t("stats.exportAsCsv")]}),a.jsxs("button",{className:"w-full px-4 py-2 text-left text-white hover:bg-bambu-dark-tertiary transition-colors flex items-center gap-2 rounded-b-lg",onClick:()=>N("xlsx"),children:[a.jsx(P1,{className:"w-4 h-4"}),t("stats.exportAsExcel")]})]})]})]})]}),a.jsx(jQe,{widgets:j,storageKey:"bambusy-dashboard-layout",stackBelow:640,hideControls:!0},l)]})}function VQe({plug:t,onEdit:e}){const{t:n}=Vt(),r=tn(),{showToast:i}=hn(),[s,o]=w.useState(!1),[l,c]=w.useState(!1),[u,d]=w.useState(!1),[h,f]=w.useState(!1),{data:p,isLoading:x}=Ze({queryKey:["smart-plug-status",t.id],queryFn:()=>re.getSmartPlugStatus(t.id),refetchInterval:3e4}),{data:y}=Ze({queryKey:["printers"],queryFn:re.getPrinters}),b=y?.find(P=>P.id===t.printer_id),v=ot({mutationFn:P=>re.controlSmartPlug(t.id,P),onMutate:async P=>{await r.cancelQueries({queryKey:["smart-plug-status",t.id]});const U=r.getQueryData(["smart-plug-status",t.id]),O=P==="on"?"ON":P==="off"||p?.state==="ON"?"OFF":"ON";return r.setQueryData(["smart-plug-status",t.id],B=>({...B,state:O})),{previousStatus:U}},onError:(P,U,O)=>{O?.previousStatus&&r.setQueryData(["smart-plug-status",t.id],O.previousStatus),i(`Failed to turn ${U} "${t.name}"`,"error")},onSettled:()=>{setTimeout(()=>{r.invalidateQueries({queryKey:["smart-plug-status",t.id]}),r.invalidateQueries({queryKey:["smart-plugs"]})},1e3)}}),S=ot({mutationFn:P=>re.updateSmartPlug(t.id,P),onSuccess:()=>{r.invalidateQueries({queryKey:["smart-plugs"]}),t.printer_id&&(r.invalidateQueries({queryKey:["smartPlugByPrinter",t.printer_id]}),r.invalidateQueries({queryKey:["scriptPlugsByPrinter",t.printer_id]}))}}),N=ot({mutationFn:()=>re.deleteSmartPlug(t.id),onSuccess:()=>{r.invalidateQueries({queryKey:["smart-plugs"]}),t.printer_id&&r.invalidateQueries({queryKey:["scriptPlugsByPrinter",t.printer_id]})}}),A=p?.state==="ON",C=t.plug_type==="mqtt"&&p?.energy?.power!==null&&p?.energy?.power!==void 0,T=(p?.reachable??!1)||C,k=v.isPending,E=(()=>{if(t.plug_type!=="tasmota"||!t.ip_address)return null;const P=t.ip_address;return t.username&&t.password?`http://${encodeURIComponent(t.username)}:${encodeURIComponent(t.password)}@${P}/`:`http://${P}/`})();return a.jsxs(a.Fragment,{children:[a.jsx(vt,{className:"relative",children:a.jsxs(Nt,{className:"p-4",children:[a.jsxs("div",{className:"flex items-start justify-between gap-2 mb-3",children:[a.jsxs("div",{className:"flex items-center gap-3 min-w-0 flex-1",children:[a.jsx("div",{className:`p-2 rounded-lg flex-shrink-0 ${t.plug_type==="mqtt"?T?"bg-teal-500/20":"bg-red-500/20":T?A?"bg-bambu-green/20":"bg-bambu-dark":"bg-red-500/20"}`,children:t.plug_type==="mqtt"?a.jsx(OF,{className:`w-5 h-5 ${T?"text-teal-400":"text-red-400"}`}):t.plug_type==="homeassistant"?a.jsx(bv,{className:`w-5 h-5 ${T?A?"text-bambu-green":"text-bambu-gray":"text-red-400"}`}):a.jsx(hl,{className:`w-5 h-5 ${T?A?"text-bambu-green":"text-bambu-gray":"text-red-400"}`})}),a.jsxs("div",{className:"min-w-0",children:[a.jsx("h3",{className:"font-medium text-white truncate",children:t.name}),a.jsx("p",{className:"text-sm text-bambu-gray truncate",title:t.plug_type==="mqtt"?t.mqtt_topic??void 0:t.plug_type==="homeassistant"?t.ha_entity_id??void 0:t.ip_address??void 0,children:t.plug_type==="mqtt"?t.mqtt_topic:t.plug_type==="homeassistant"?t.ha_entity_id:t.ip_address})]})]}),a.jsxs("div",{className:"flex flex-col items-end gap-1 flex-shrink-0",children:[x?a.jsx(it,{className:"w-4 h-4 text-bambu-gray animate-spin"}):t.plug_type==="mqtt"?a.jsxs("div",{className:"flex items-center gap-1.5 text-sm whitespace-nowrap",children:[a.jsx("span",{className:"px-1.5 py-0.5 bg-teal-500/20 text-teal-400 text-[10px] font-medium rounded flex-shrink-0",children:"MQTT"}),T&&a.jsx("span",{className:"text-status-ok",children:"✓"})]}):t.plug_type==="homeassistant"?a.jsxs("div",{className:"flex items-center gap-1 text-sm",children:[a.jsx("span",{className:"px-1 py-0.5 bg-blue-500/20 text-blue-400 text-[10px] font-medium rounded",children:"HA"}),a.jsx("span",{className:T?A?"text-status-ok":"text-bambu-gray":"text-status-error",children:T?p?.state||"?":"Offline"})]}):T?a.jsxs("div",{className:"flex items-center gap-1 text-sm",children:[a.jsx(Qg,{className:"w-4 h-4 text-status-ok"}),a.jsx("span",{className:A?"text-status-ok":"text-bambu-gray",children:p?.state||"Unknown"})]}):a.jsxs("div",{className:"flex items-center gap-1 text-sm text-status-error",children:[a.jsx(Rf,{className:"w-4 h-4"}),a.jsx("span",{children:n("smartPlugs.offline")})]}),E&&a.jsxs("a",{href:E,target:"_blank",rel:"noopener noreferrer",className:"flex items-center gap-1 px-2 py-0.5 bg-bambu-dark hover:bg-bambu-dark-tertiary text-bambu-gray hover:text-white text-xs rounded-full transition-colors",title:n("smartPlugs.openPlugAdminPage"),children:[a.jsx(Kr,{className:"w-3 h-3"}),n("smartPlugs.admin")]})]})]}),b&&a.jsxs("div",{className:"mb-3 px-2 py-1.5 bg-bambu-dark rounded-lg",children:[a.jsx("span",{className:"text-xs text-bambu-gray",children:"Linked to: "}),a.jsx("span",{className:"text-sm text-white",children:b.name})]}),(t.power_alert_enabled||t.schedule_enabled||t.plug_type==="mqtt")&&a.jsxs("div",{className:"flex flex-wrap gap-1.5 mb-3",children:[t.plug_type==="mqtt"&&a.jsxs("span",{className:"flex items-center gap-1 px-2 py-0.5 bg-teal-500/20 text-teal-400 text-xs rounded-full",children:[a.jsx(Xl,{className:"w-3 h-3"}),"Monitor Only"]}),t.power_alert_enabled&&a.jsxs("span",{className:"flex items-center gap-1 px-2 py-0.5 bg-yellow-500/20 text-yellow-400 text-xs rounded-full",children:[a.jsx(Xg,{className:"w-3 h-3"}),"Alerts"]}),t.schedule_enabled&&a.jsxs("span",{className:"flex items-center gap-1 px-2 py-0.5 bg-blue-500/20 text-blue-400 text-xs rounded-full",children:[a.jsx(ii,{className:"w-3 h-3"}),t.schedule_on_time&&t.schedule_off_time?`${t.schedule_on_time} - ${t.schedule_off_time}`:t.schedule_on_time?`On ${t.schedule_on_time}`:`Off ${t.schedule_off_time}`]})]}),t.plug_type!=="mqtt"&&a.jsxs("div",{className:"flex gap-2 mb-3",children:[a.jsxs(Ce,{size:"sm",variant:A?"primary":"secondary",disabled:!T||k,onClick:()=>c(!0),className:"flex-1",children:[k?a.jsx(it,{className:"w-4 h-4 animate-spin"}):a.jsx(fd,{className:"w-4 h-4"}),"On"]}),a.jsxs(Ce,{size:"sm",variant:A?"secondary":"primary",disabled:!T||k,onClick:()=>d(!0),className:"flex-1",children:[k?a.jsx(it,{className:"w-4 h-4 animate-spin"}):a.jsx(oC,{className:"w-4 h-4"}),"Off"]})]}),t.plug_type==="mqtt"&&p?.energy&&a.jsxs("div",{className:"flex gap-2 mb-3 px-3 py-2 bg-bambu-dark rounded-lg",children:[p.energy.power!==null&&p.energy.power!==void 0&&a.jsxs("div",{className:"flex-1 text-center",children:[a.jsxs("p",{className:"text-lg font-semibold text-white",children:[Math.round(p.energy.power),"W"]}),a.jsx("p",{className:"text-xs text-bambu-gray",children:"Power"})]}),p.energy.today!==null&&p.energy.today!==void 0&&a.jsxs("div",{className:"flex-1 text-center border-l border-bambu-dark-tertiary",children:[a.jsx("p",{className:"text-lg font-semibold text-white",children:p.energy.today.toFixed(2)}),a.jsx("p",{className:"text-xs text-bambu-gray",children:"kWh Today"})]})]}),a.jsxs("button",{onClick:()=>f(!h),className:"w-full flex items-center justify-between py-2 text-sm text-bambu-gray hover:text-white transition-colors",children:[a.jsxs("span",{className:"flex items-center gap-2",children:[a.jsx(nd,{className:"w-4 h-4"}),t.plug_type==="mqtt"?"Settings":"Automation Settings"]}),a.jsx("span",{children:h?"-":"+"})]}),h&&a.jsxs("div",{className:"pt-3 border-t border-bambu-dark-tertiary space-y-4",children:[a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx(xv,{className:"w-4 h-4 text-bambu-green"}),a.jsxs("div",{children:[a.jsx("p",{className:"text-sm text-white",children:"Show in Switchbar"}),a.jsx("p",{className:"text-xs text-bambu-gray",children:"Quick access from sidebar"})]})]}),a.jsxs("label",{className:"relative inline-flex items-center cursor-pointer",children:[a.jsx("input",{type:"checkbox",checked:t.show_in_switchbar,onChange:P=>S.mutate({show_in_switchbar:P.target.checked}),className:"sr-only peer"}),a.jsx("div",{className:"w-9 h-5 bg-bambu-dark-tertiary peer-focus:outline-none rounded-full peer peer-checked:after:translate-x-full after:content-[''] after:absolute after:top-[2px] after:left-[2px] after:bg-white after:rounded-full after:h-4 after:w-4 after:transition-all peer-checked:bg-bambu-green"})]})]}),t.plug_type!=="mqtt"&&a.jsxs(a.Fragment,{children:[a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsxs("div",{children:[a.jsx("p",{className:"text-sm text-white",children:"Enabled"}),a.jsx("p",{className:"text-xs text-bambu-gray",children:"Enable automation for this plug"})]}),a.jsxs("label",{className:"relative inline-flex items-center cursor-pointer",children:[a.jsx("input",{type:"checkbox",checked:t.enabled,onChange:P=>S.mutate({enabled:P.target.checked}),className:"sr-only peer"}),a.jsx("div",{className:"w-9 h-5 bg-bambu-dark-tertiary peer-focus:outline-none rounded-full peer peer-checked:after:translate-x-full after:content-[''] after:absolute after:top-[2px] after:left-[2px] after:bg-white after:rounded-full after:h-4 after:w-4 after:transition-all peer-checked:bg-bambu-green"})]})]}),a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsxs("div",{children:[a.jsx("p",{className:"text-sm text-white",children:"Auto On"}),a.jsx("p",{className:"text-xs text-bambu-gray",children:"Turn on when print starts"})]}),a.jsxs("label",{className:"relative inline-flex items-center cursor-pointer",children:[a.jsx("input",{type:"checkbox",checked:t.auto_on,onChange:P=>S.mutate({auto_on:P.target.checked}),className:"sr-only peer"}),a.jsx("div",{className:"w-9 h-5 bg-bambu-dark-tertiary peer-focus:outline-none rounded-full peer peer-checked:after:translate-x-full after:content-[''] after:absolute after:top-[2px] after:left-[2px] after:bg-white after:rounded-full after:h-4 after:w-4 after:transition-all peer-checked:bg-bambu-green"})]})]}),a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsxs("div",{children:[a.jsx("p",{className:"text-sm text-white",children:"Auto Off"}),a.jsx("p",{className:"text-xs text-bambu-gray",children:"Turn off when print completes (one-shot)"})]}),a.jsxs("label",{className:"relative inline-flex items-center cursor-pointer",children:[a.jsx("input",{type:"checkbox",checked:t.auto_off,onChange:P=>S.mutate({auto_off:P.target.checked}),className:"sr-only peer"}),a.jsx("div",{className:"w-9 h-5 bg-bambu-dark-tertiary peer-focus:outline-none rounded-full peer peer-checked:after:translate-x-full after:content-[''] after:absolute after:top-[2px] after:left-[2px] after:bg-white after:rounded-full after:h-4 after:w-4 after:transition-all peer-checked:bg-bambu-green"})]})]}),t.auto_off&&a.jsxs("div",{className:"space-y-3 pl-4 border-l-2 border-bambu-dark-tertiary",children:[a.jsxs("div",{children:[a.jsx("p",{className:"text-sm text-white mb-2",children:"Turn Off Delay Mode"}),a.jsxs("div",{className:"flex gap-2",children:[a.jsxs("button",{onClick:()=>S.mutate({off_delay_mode:"time"}),className:`flex-1 flex items-center justify-center gap-2 px-3 py-2 rounded-lg text-sm transition-colors ${t.off_delay_mode==="time"?"bg-bambu-green text-white":"bg-bambu-dark text-bambu-gray hover:text-white"}`,children:[a.jsx(Wn,{className:"w-4 h-4"}),"Time"]}),a.jsxs("button",{onClick:()=>S.mutate({off_delay_mode:"temperature"}),className:`flex-1 flex items-center justify-center gap-2 px-3 py-2 rounded-lg text-sm transition-colors ${t.off_delay_mode==="temperature"?"bg-bambu-green text-white":"bg-bambu-dark text-bambu-gray hover:text-white"}`,children:[a.jsx(uC,{className:"w-4 h-4"}),"Temp"]})]})]}),t.off_delay_mode==="time"?a.jsxs("div",{children:[a.jsx("label",{className:"block text-xs text-bambu-gray mb-1",children:"Delay (minutes)"}),a.jsx("input",{type:"number",min:"1",max:"60",value:t.off_delay_minutes,onChange:P=>S.mutate({off_delay_minutes:parseInt(P.target.value)||5}),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white text-sm focus:border-bambu-green focus:outline-none"})]}):a.jsxs("div",{children:[a.jsx("label",{className:"block text-xs text-bambu-gray mb-1",children:"Temperature threshold (C)"}),a.jsx("input",{type:"number",min:"30",max:"100",value:t.off_temp_threshold,onChange:P=>S.mutate({off_temp_threshold:parseInt(P.target.value)||70}),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white text-sm focus:border-bambu-green focus:outline-none"}),a.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:"Turns off when nozzle cools below this temperature"})]})]})]}),a.jsxs("div",{className:"flex gap-2 pt-2",children:[a.jsxs(Ce,{size:"sm",variant:"secondary",onClick:()=>e(t),className:"flex-1",children:[a.jsx(af,{className:"w-4 h-4"}),"Edit"]}),a.jsx(Ce,{size:"sm",variant:"secondary",onClick:()=>o(!0),className:"text-red-400 hover:text-red-300",children:a.jsx(Jt,{className:"w-4 h-4"})})]})]})]})}),s&&a.jsx(vn,{title:n("smartPlugs.deleteSmartPlug"),message:`Are you sure you want to delete "${t.name}"? This cannot be undone.`,confirmText:"Delete",variant:"danger",onConfirm:()=>{N.mutate(),o(!1)},onCancel:()=>o(!1)}),l&&a.jsx(vn,{title:n("smartPlugs.turnOnSmartPlug"),message:`Are you sure you want to turn on "${t.name}"?`,confirmText:n("smartPlugs.turnOn"),variant:"default",onConfirm:()=>{v.mutate("on"),c(!1)},onCancel:()=>c(!1)}),u&&a.jsx(vn,{title:n("smartPlugs.turnOffSmartPlug"),message:`Are you sure you want to turn off "${t.name}"? This will cut power to the connected device.`,confirmText:n("smartPlugs.turnOff"),variant:"danger",onConfirm:()=>{v.mutate("off"),d(!1)},onCancel:()=>d(!1)})]})}function GQe({plug:t,onClose:e}){const{t:n}=Vt(),r=tn(),i=!!t,[s,o]=w.useState(t?.plug_type||"tasmota"),[l,c]=w.useState(t?.name||""),[u,d]=w.useState(t?.ip_address||""),[h,f]=w.useState(t?.username||""),[p,x]=w.useState(t?.password||""),[y,b]=w.useState(t?.ha_entity_id||""),[v,S]=w.useState(t?.mqtt_power_topic||t?.mqtt_topic||""),[N,A]=w.useState(t?.mqtt_power_path||""),[C,T]=w.useState((t?.mqtt_power_multiplier??t?.mqtt_multiplier??1).toString()),[k,j]=w.useState(t?.mqtt_energy_topic||""),[E,P]=w.useState(t?.mqtt_energy_path||""),[U,O]=w.useState((t?.mqtt_energy_multiplier??1).toString()),[B,R]=w.useState(t?.mqtt_state_topic||""),[G,q]=w.useState(t?.mqtt_state_path||""),[z,K]=w.useState(t?.mqtt_state_on_value||""),[Y,oe]=w.useState(t?.ha_power_entity||""),[$,X]=w.useState(t?.ha_energy_today_entity||""),[ee,J]=w.useState(t?.ha_energy_total_entity||""),[_e,pe]=w.useState(""),[me,je]=w.useState(""),[de,ce]=w.useState(!1),Se=w.useRef(null),[ie,Fe]=w.useState(""),[V,W]=w.useState(!1),ue=w.useRef(null),[Q,se]=w.useState(""),[Z,Ne]=w.useState(!1),ve=w.useRef(null),[fe,L]=w.useState(""),[D,H]=w.useState(!1),he=w.useRef(null),[xe,be]=w.useState(t?.printer_id||null),[Ue,Oe]=w.useState(null),[Qe,rt]=w.useState(null),[we,ye]=w.useState(t?.power_alert_enabled||!1),[le,Le]=w.useState(t?.power_alert_high?.toString()||""),[Me,$e]=w.useState(t?.power_alert_low?.toString()||""),[Ae,Je]=w.useState(t?.schedule_enabled||!1),[Pe,Xe]=w.useState(t?.schedule_on_time||""),[De,Re]=w.useState(t?.schedule_off_time||""),[qe,pt]=w.useState(t?.show_in_switchbar||!1),[At,Rt]=w.useState(t?.show_on_printer_card??!0),[Wt,Tt]=w.useState(!1),[Ie,xt]=w.useState({scanned:0,total:0}),[wt,Bt]=w.useState([]),Tn=w.useRef(null),{data:fr}=Ze({queryKey:["printers"],queryFn:re.getPrinters}),{data:Zn}=Ze({queryKey:["smart-plugs"],queryFn:re.getSmartPlugs}),{data:Jn}=Ze({queryKey:["settings"],queryFn:re.getSettings}),Pn=!!(Jn?.ha_enabled&&Jn?.ha_url&&Jn?.ha_token);w.useEffect(()=>{const Ee=setTimeout(()=>{je(_e)},300);return()=>clearTimeout(Ee)},[_e]),w.useEffect(()=>{const Ee=st=>{Se.current&&!Se.current.contains(st.target)&&ce(!1),ue.current&&!ue.current.contains(st.target)&&W(!1),ve.current&&!ve.current.contains(st.target)&&Ne(!1),he.current&&!he.current.contains(st.target)&&H(!1)};return document.addEventListener("mousedown",Ee),()=>document.removeEventListener("mousedown",Ee)},[]);const{data:cr,isLoading:jn,error:ai}=Ze({queryKey:["ha-entities",me],queryFn:()=>re.getHAEntities(me||void 0),enabled:s==="homeassistant"&&Pn,retry:!1,staleTime:0}),{data:ne}=Ze({queryKey:["ha-sensor-entities"],queryFn:re.getHASensorEntities,enabled:s==="homeassistant"&&Pn,retry:!1,staleTime:0});w.useEffect(()=>{const Ee=st=>{st.key==="Escape"&&e()};return window.addEventListener("keydown",Ee),()=>{window.removeEventListener("keydown",Ee),Tn.current&&clearInterval(Tn.current)}},[e]);const He=async()=>{Tt(!0),Bt([]),xt({scanned:0,total:0}),rt(null);try{await re.startTasmotaScan();const Ee=async()=>{try{const st=await re.getTasmotaScanStatus();xt({scanned:st.scanned,total:st.total});const tt=await re.getDiscoveredTasmotaDevices();Bt(tt),st.running||(Tt(!1),Tn.current&&(clearInterval(Tn.current),Tn.current=null))}catch(st){console.error("Polling error:",st)}};await Ee(),Tn.current=setInterval(Ee,500)}catch(Ee){Tt(!1);const st=Ee instanceof Error?Ee.message:typeof Ee=="string"?Ee:JSON.stringify(Ee);rt(st||"Failed to start scan")}},et=async()=>{try{await re.stopTasmotaScan()}catch{}Tt(!1),Tn.current&&(clearInterval(Tn.current),Tn.current=null)},lt=Ee=>{d(Ee.ip_address),c(Ee.name),Oe(null)},dt=ot({mutationFn:()=>re.testSmartPlugConnection(u,h||null,p||null),onSuccess:Ee=>{Oe(Ee),rt(null),!l&&Ee.device_name&&c(Ee.device_name)},onError:Ee=>{Oe(null),rt(Ee.message)}}),Lt=ot({mutationFn:Ee=>re.createSmartPlug(Ee),onSuccess:()=>{r.invalidateQueries({queryKey:["smart-plugs"]}),r.invalidateQueries({queryKey:["scriptPlugsByPrinter"]}),e()},onError:Ee=>{rt(Ee.message)}}),ge=ot({mutationFn:Ee=>re.updateSmartPlug(t.id,Ee),onSuccess:()=>{r.invalidateQueries({queryKey:["smart-plugs"]}),r.invalidateQueries({queryKey:["scriptPlugsByPrinter"]}),e()},onError:Ee=>{rt(Ee.message)}}),ze=fr?.filter(Ee=>s==="tasmota"?!Zn?.some(tt=>tt.printer_id===Ee.id&&tt.id!==t?.id&&tt.plug_type==="tasmota"):!0),Ge=Ee=>{if(Ee.preventDefault(),rt(null),!l.trim()){rt("Name is required");return}if(s==="tasmota"&&!u.trim()){rt("IP address is required for Tasmota plugs");return}if(s==="homeassistant"&&!y){rt("Entity is required for Home Assistant plugs");return}if(s==="mqtt"){const tt=v.trim(),at=k.trim(),Mt=B.trim();if(!tt&&!at&&!Mt){rt("At least one MQTT topic must be configured for power, energy, or state monitoring");return}}const st={name:l.trim(),plug_type:s,ip_address:s==="tasmota"?u.trim():null,ha_entity_id:s==="homeassistant"?y:null,ha_power_entity:s==="homeassistant"&&Y||null,ha_energy_today_entity:s==="homeassistant"&&$||null,ha_energy_total_entity:s==="homeassistant"&&ee||null,mqtt_power_topic:s==="mqtt"&&v.trim()||null,mqtt_power_path:s==="mqtt"&&N.trim()||null,mqtt_power_multiplier:s==="mqtt"&&parseFloat(C)||1,mqtt_energy_topic:s==="mqtt"&&k.trim()||null,mqtt_energy_path:s==="mqtt"&&E.trim()||null,mqtt_energy_multiplier:s==="mqtt"&&parseFloat(U)||1,mqtt_state_topic:s==="mqtt"&&B.trim()||null,mqtt_state_path:s==="mqtt"&&G.trim()||null,mqtt_state_on_value:s==="mqtt"&&z.trim()||null,username:s==="tasmota"&&h.trim()||null,password:s==="tasmota"&&p.trim()||null,printer_id:xe,power_alert_enabled:we,power_alert_high:le?parseFloat(le):null,power_alert_low:Me?parseFloat(Me):null,schedule_enabled:Ae,schedule_on_time:Pe||null,schedule_off_time:De||null,show_in_switchbar:qe,show_on_printer_card:At};i?ge.mutate(st):Lt.mutate(st)},Ve=Lt.isPending||ge.isPending;return a.jsx("div",{className:"fixed inset-0 bg-black/70 flex items-center justify-center z-50 p-4",onClick:e,children:a.jsxs("div",{className:"bg-bambu-dark-secondary rounded-xl border border-bambu-dark-tertiary w-full max-w-md max-h-[90vh] flex flex-col",onClick:Ee=>Ee.stopPropagation(),children:[a.jsxs("div",{className:"flex items-center justify-between px-6 py-4 border-b border-bambu-dark-tertiary flex-shrink-0",children:[a.jsx("h2",{className:"text-lg font-semibold text-white",children:i?"Edit Smart Plug":"Add Smart Plug"}),a.jsx("button",{onClick:e,className:"text-bambu-gray hover:text-white transition-colors",children:a.jsx(Ft,{className:"w-5 h-5"})})]}),a.jsxs("form",{onSubmit:Ge,className:"p-6 space-y-4 overflow-y-auto",children:[Qe&&a.jsx("div",{className:"p-3 bg-red-500/20 border border-red-500/50 rounded-lg text-sm text-red-400",children:Qe}),!i&&a.jsxs("div",{className:"flex gap-2 mb-2",children:[a.jsxs("button",{type:"button",onClick:()=>{o("tasmota"),Oe(null),rt(null)},className:`flex-1 flex items-center justify-center gap-2 px-3 py-2.5 rounded-lg font-medium transition-colors ${s==="tasmota"?"bg-bambu-green text-white":"bg-bambu-dark text-bambu-gray hover:text-white border border-bambu-dark-tertiary"}`,children:[a.jsx(hl,{className:"w-4 h-4"}),"Tasmota"]}),a.jsxs("button",{type:"button",onClick:()=>{o("homeassistant"),Oe(null),rt(null)},className:`flex-1 flex items-center justify-center gap-2 px-3 py-2.5 rounded-lg font-medium transition-colors ${s==="homeassistant"?"bg-bambu-green text-white":"bg-bambu-dark text-bambu-gray hover:text-white border border-bambu-dark-tertiary"}`,children:[a.jsx(bv,{className:"w-4 h-4"}),"HA"]}),a.jsxs("button",{type:"button",onClick:()=>{o("mqtt"),Oe(null),rt(null)},className:`flex-1 flex items-center justify-center gap-2 px-3 py-2.5 rounded-lg font-medium transition-colors ${s==="mqtt"?"bg-bambu-green text-white":"bg-bambu-dark text-bambu-gray hover:text-white border border-bambu-dark-tertiary"}`,children:[a.jsx(OF,{className:"w-4 h-4"}),"MQTT"]})]}),!i&&s==="tasmota"&&a.jsxs("div",{className:"space-y-3",children:[Wt?a.jsxs(Ce,{type:"button",variant:"secondary",onClick:et,className:"w-full",children:[a.jsx(Ft,{className:"w-4 h-4"}),"Stop Scanning"]}):a.jsxs(Ce,{type:"button",variant:"primary",onClick:He,className:"w-full",children:[a.jsx(Or,{className:"w-4 h-4"}),"Discover Tasmota Devices"]}),Wt&&Ie.total>0&&a.jsxs("div",{className:"space-y-1",children:[a.jsxs("div",{className:"flex justify-between text-xs text-bambu-gray",children:[a.jsx("span",{children:n("smartPlugs.addSmartPlug.scanningNetwork")}),a.jsxs("span",{children:[Ie.scanned," / ",Ie.total]})]}),a.jsx("div",{className:"w-full bg-bambu-dark-tertiary rounded-full h-2",children:a.jsx("div",{className:"bg-bambu-green h-2 rounded-full transition-all duration-300",style:{width:`${Ie.scanned/Ie.total*100}%`}})})]}),wt.length>0&&a.jsxs("div",{className:"space-y-2",children:[a.jsxs("p",{className:"text-xs text-bambu-gray",children:["Found ",wt.length," device(s) - click to select:"]}),a.jsx("div",{className:"max-h-40 overflow-y-auto space-y-1",children:wt.map(Ee=>a.jsxs("button",{type:"button",onClick:()=>lt(Ee),className:"w-full flex items-center justify-between p-2 bg-bambu-dark hover:bg-bambu-dark-tertiary rounded-lg transition-colors text-left border border-bambu-dark-tertiary",children:[a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx(hl,{className:"w-4 h-4 text-bambu-green"}),a.jsxs("div",{children:[a.jsx("p",{className:"text-sm text-white",children:Ee.name}),a.jsx("p",{className:"text-xs text-bambu-gray",children:Ee.ip_address})]})]}),Ee.state&&a.jsxs("span",{className:`flex items-center gap-1 text-xs ${Ee.state==="ON"?"text-bambu-green":"text-bambu-gray"}`,children:[a.jsx(fd,{className:"w-3 h-3"}),Ee.state]})]},Ee.ip_address))})]}),!Wt&&wt.length===0&&Ie.total>0&&a.jsx("p",{className:"text-xs text-bambu-gray text-center py-2",children:"No Tasmota devices found on your network"})]}),s==="homeassistant"&&a.jsxs("div",{className:"space-y-3",children:[!Pn&&a.jsxs("div",{className:"space-y-3",children:[a.jsxs("div",{className:"p-3 bg-yellow-500/20 border border-yellow-500/50 rounded-lg text-sm text-yellow-400",children:["Home Assistant is not configured. Set it up in"," ",a.jsx("span",{className:"font-medium",children:"Settings → Network → Home Assistant"})]}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm text-bambu-gray mb-1 opacity-50",children:"Select Entity *"}),a.jsx("select",{disabled:!0,className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-bambu-gray cursor-not-allowed opacity-50",children:a.jsx("option",{children:n("smartPlugs.addSmartPlug.chooseEntity")})})]})]}),Pn&&a.jsxs(a.Fragment,{children:[jn&&a.jsxs("div",{className:"flex items-center justify-center py-4 text-bambu-gray",children:[a.jsx(it,{className:"w-5 h-5 animate-spin mr-2"}),"Loading entities..."]}),ai&&a.jsxs("div",{className:"p-3 bg-red-500/20 border border-red-500/50 rounded-lg text-sm text-red-400",children:["Failed to load entities: ",ai.message]}),(()=>{const Ee=Zn?.filter(at=>at.ha_entity_id&&at.id!==t?.id).map(at=>at.ha_entity_id)||[],st=(cr||[]).filter(at=>!Ee.includes(at.entity_id)),tt=cr?.find(at=>at.entity_id===y);return a.jsxs("div",{ref:Se,className:"relative",children:[a.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Select Entity *"}),a.jsxs("div",{className:"relative",children:[a.jsx(Or,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray pointer-events-none"}),a.jsx("input",{type:"text",value:de?_e:tt?`${tt.friendly_name} (${tt.entity_id})`:"",onChange:at=>{pe(at.target.value),de||ce(!0)},onFocus:()=>{ce(!0),pe("")},placeholder:n("smartPlugs.addSmartPlug.placeholders.searchEntities"),className:"w-full pl-9 pr-8 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white placeholder-bambu-gray focus:border-bambu-green focus:outline-none"}),y&&!de&&a.jsx("button",{type:"button",onClick:()=>{b(""),pe("")},className:"absolute right-2 top-1/2 -translate-y-1/2 p-1 hover:bg-bambu-dark-tertiary rounded",children:a.jsx(Ft,{className:"w-4 h-4 text-bambu-gray hover:text-white"})}),jn&&a.jsx(it,{className:"absolute right-2 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray animate-spin"})]}),de&&a.jsxs("div",{className:"absolute z-50 w-full mt-1 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg shadow-lg max-h-60 overflow-y-auto",children:[jn&&a.jsxs("div",{className:"px-3 py-2 text-sm text-bambu-gray flex items-center gap-2",children:[a.jsx(it,{className:"w-4 h-4 animate-spin"}),"Loading..."]}),!jn&&st.length===0&&a.jsx("div",{className:"px-3 py-2 text-sm text-bambu-gray",children:me?`No entities found matching "${me}"`:"No entities available"}),!jn&&st.map(at=>a.jsxs("button",{type:"button",onClick:()=>{b(at.entity_id),ce(!1),pe(""),l||c(at.friendly_name)},className:`w-full px-3 py-2 text-left text-sm hover:bg-bambu-dark-tertiary transition-colors ${at.entity_id===y?"bg-bambu-green/20 text-bambu-green":"text-white"}`,children:[a.jsx("div",{className:"font-medium",children:at.friendly_name}),a.jsxs("div",{className:"text-xs text-bambu-gray flex items-center justify-between",children:[a.jsx("span",{children:at.entity_id}),a.jsx("span",{className:at.state==="on"?"text-bambu-green":"",children:at.state})]})]},at.entity_id))]}),a.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:me?`Searching all entities (${st.length} found)`:`Showing switch, light, input_boolean (${st.length} available)`})]})})(),y&&ne&&ne.length>0&&a.jsxs("div",{className:"border-t border-bambu-dark-tertiary pt-4 mt-4 space-y-3",children:[a.jsxs("div",{children:[a.jsx("p",{className:"text-white font-medium mb-1",children:"Energy Monitoring (Optional)"}),a.jsx("p",{className:"text-xs text-bambu-gray mb-3",children:"Search and select sensors that provide power/energy data."})]}),(()=>{const Ee=ne.filter(at=>at.unit_of_measurement==="W"||at.unit_of_measurement==="kW"||at.unit_of_measurement==="mW"),st=ie?Ee.filter(at=>at.entity_id.toLowerCase().includes(ie.toLowerCase())||at.friendly_name.toLowerCase().includes(ie.toLowerCase())):Ee,tt=ne.find(at=>at.entity_id===Y);return a.jsxs("div",{ref:ue,className:"relative",children:[a.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Power Sensor (W)"}),a.jsxs("div",{className:"relative",children:[a.jsx(Or,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray pointer-events-none"}),a.jsx("input",{type:"text",value:V?ie:tt?`${tt.friendly_name} (${tt.state} ${tt.unit_of_measurement})`:"",onChange:at=>{Fe(at.target.value),V||W(!0)},onFocus:()=>{W(!0),Fe("")},placeholder:n("smartPlugs.addSmartPlug.placeholders.searchPowerSensors"),className:"w-full pl-9 pr-8 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white placeholder-bambu-gray focus:border-bambu-green focus:outline-none"}),Y&&!V&&a.jsx("button",{type:"button",onClick:()=>{oe(""),Fe("")},className:"absolute right-2 top-1/2 -translate-y-1/2 p-1 hover:bg-bambu-dark-tertiary rounded",children:a.jsx(Ft,{className:"w-4 h-4 text-bambu-gray hover:text-white"})})]}),V&&a.jsxs("div",{className:"absolute z-50 w-full mt-1 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg shadow-lg max-h-48 overflow-y-auto",children:[a.jsx("button",{type:"button",onClick:()=>{oe(""),W(!1),Fe("")},className:"w-full px-3 py-2 text-left text-sm text-bambu-gray hover:bg-bambu-dark-tertiary",children:"None"}),st.map(at=>a.jsxs("button",{type:"button",onClick:()=>{oe(at.entity_id),W(!1),Fe("")},className:`w-full px-3 py-2 text-left text-sm hover:bg-bambu-dark-tertiary ${at.entity_id===Y?"bg-bambu-green/20 text-bambu-green":"text-white"}`,children:[a.jsx("div",{className:"font-medium",children:at.friendly_name}),a.jsxs("div",{className:"text-xs text-bambu-gray",children:[at.entity_id," • ",at.state," ",at.unit_of_measurement]})]},at.entity_id)),st.length===0&&a.jsx("div",{className:"px-3 py-2 text-sm text-bambu-gray",children:"No matching sensors"})]})]})})(),(()=>{const Ee=ne.filter(at=>at.unit_of_measurement==="kWh"||at.unit_of_measurement==="Wh"||at.unit_of_measurement==="MWh"),st=Q?Ee.filter(at=>at.entity_id.toLowerCase().includes(Q.toLowerCase())||at.friendly_name.toLowerCase().includes(Q.toLowerCase())):Ee,tt=ne.find(at=>at.entity_id===$);return a.jsxs("div",{ref:ve,className:"relative",children:[a.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Energy Today (kWh)"}),a.jsxs("div",{className:"relative",children:[a.jsx(Or,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray pointer-events-none"}),a.jsx("input",{type:"text",value:Z?Q:tt?`${tt.friendly_name} (${tt.state} ${tt.unit_of_measurement})`:"",onChange:at=>{se(at.target.value),Z||Ne(!0)},onFocus:()=>{Ne(!0),se("")},placeholder:n("smartPlugs.addSmartPlug.placeholders.searchEnergySensors"),className:"w-full pl-9 pr-8 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white placeholder-bambu-gray focus:border-bambu-green focus:outline-none"}),$&&!Z&&a.jsx("button",{type:"button",onClick:()=>{X(""),se("")},className:"absolute right-2 top-1/2 -translate-y-1/2 p-1 hover:bg-bambu-dark-tertiary rounded",children:a.jsx(Ft,{className:"w-4 h-4 text-bambu-gray hover:text-white"})})]}),Z&&a.jsxs("div",{className:"absolute z-50 w-full mt-1 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg shadow-lg max-h-48 overflow-y-auto",children:[a.jsx("button",{type:"button",onClick:()=>{X(""),Ne(!1),se("")},className:"w-full px-3 py-2 text-left text-sm text-bambu-gray hover:bg-bambu-dark-tertiary",children:"None"}),st.map(at=>a.jsxs("button",{type:"button",onClick:()=>{X(at.entity_id),Ne(!1),se("")},className:`w-full px-3 py-2 text-left text-sm hover:bg-bambu-dark-tertiary ${at.entity_id===$?"bg-bambu-green/20 text-bambu-green":"text-white"}`,children:[a.jsx("div",{className:"font-medium",children:at.friendly_name}),a.jsxs("div",{className:"text-xs text-bambu-gray",children:[at.entity_id," • ",at.state," ",at.unit_of_measurement]})]},at.entity_id)),st.length===0&&a.jsx("div",{className:"px-3 py-2 text-sm text-bambu-gray",children:"No matching sensors"})]})]})})(),(()=>{const Ee=ne.filter(at=>at.unit_of_measurement==="kWh"||at.unit_of_measurement==="Wh"||at.unit_of_measurement==="MWh"),st=fe?Ee.filter(at=>at.entity_id.toLowerCase().includes(fe.toLowerCase())||at.friendly_name.toLowerCase().includes(fe.toLowerCase())):Ee,tt=ne.find(at=>at.entity_id===ee);return a.jsxs("div",{ref:he,className:"relative",children:[a.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Total Energy (kWh)"}),a.jsxs("div",{className:"relative",children:[a.jsx(Or,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray pointer-events-none"}),a.jsx("input",{type:"text",value:D?fe:tt?`${tt.friendly_name} (${tt.state} ${tt.unit_of_measurement})`:"",onChange:at=>{L(at.target.value),D||H(!0)},onFocus:()=>{H(!0),L("")},placeholder:n("smartPlugs.addSmartPlug.placeholders.searchEnergySensors"),className:"w-full pl-9 pr-8 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white placeholder-bambu-gray focus:border-bambu-green focus:outline-none"}),ee&&!D&&a.jsx("button",{type:"button",onClick:()=>{J(""),L("")},className:"absolute right-2 top-1/2 -translate-y-1/2 p-1 hover:bg-bambu-dark-tertiary rounded",children:a.jsx(Ft,{className:"w-4 h-4 text-bambu-gray hover:text-white"})})]}),D&&a.jsxs("div",{className:"absolute z-50 w-full mt-1 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg shadow-lg max-h-48 overflow-y-auto",children:[a.jsx("button",{type:"button",onClick:()=>{J(""),H(!1),L("")},className:"w-full px-3 py-2 text-left text-sm text-bambu-gray hover:bg-bambu-dark-tertiary",children:"None"}),st.map(at=>a.jsxs("button",{type:"button",onClick:()=>{J(at.entity_id),H(!1),L("")},className:`w-full px-3 py-2 text-left text-sm hover:bg-bambu-dark-tertiary ${at.entity_id===ee?"bg-bambu-green/20 text-bambu-green":"text-white"}`,children:[a.jsx("div",{className:"font-medium",children:at.friendly_name}),a.jsxs("div",{className:"text-xs text-bambu-gray",children:[at.entity_id," • ",at.state," ",at.unit_of_measurement]})]},at.entity_id)),st.length===0&&a.jsx("div",{className:"px-3 py-2 text-sm text-bambu-gray",children:"No matching sensors"})]})]})})()]})]})]}),s==="mqtt"&&a.jsxs("div",{className:"space-y-3",children:[!Jn?.mqtt_broker&&a.jsxs("div",{className:"p-3 bg-yellow-500/20 border border-yellow-500/50 rounded-lg text-sm text-yellow-400",children:["MQTT broker not configured. Set broker address in"," ",a.jsx("span",{className:"font-medium",children:"Settings → Network → MQTT Publishing"})," ","(you don't need to enable publishing, just fill in the broker details)."]}),Jn?.mqtt_broker&&a.jsxs(a.Fragment,{children:[a.jsxs("div",{className:"p-3 bg-blue-500/10 border border-blue-500/30 rounded-lg text-sm text-blue-300",children:[a.jsx("p",{className:"font-medium mb-1",children:"Monitor Only"}),a.jsx("p",{className:"text-xs opacity-80",children:"MQTT plugs receive power/energy data via MQTT subscription. On/off control is not available - use your MQTT broker or home automation system."})]}),a.jsxs("div",{className:"space-y-3 p-3 bg-bambu-dark rounded-lg border border-bambu-dark-tertiary",children:[a.jsx("p",{className:"text-white font-medium text-sm",children:"Power Monitoring"}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Topic"}),a.jsx("input",{type:"text",value:v,onChange:Ee=>S(Ee.target.value),placeholder:"zigbee2mqtt/shelly-working-room",className:"w-full px-3 py-2 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg text-white placeholder-bambu-gray focus:border-bambu-green focus:outline-none"})]}),a.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"JSON Path"}),a.jsx("input",{type:"text",value:N,onChange:Ee=>A(Ee.target.value),placeholder:"power_l1",className:"w-full px-3 py-2 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg text-white placeholder-bambu-gray focus:border-bambu-green focus:outline-none"})]}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Multiplier"}),a.jsx("input",{type:"text",value:C,onChange:Ee=>T(Ee.target.value),placeholder:"1",className:"w-full px-3 py-2 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg text-white placeholder-bambu-gray focus:border-bambu-green focus:outline-none"})]})]}),a.jsxs("p",{className:"text-xs text-bambu-gray",children:['JSON path extracts value from JSON payload (e.g., "power_l1"). Leave empty if topic publishes raw numeric values.',a.jsx("br",{}),"Use multiplier 0.001 for mW→W, 1000 for kW→W."]})]}),a.jsxs("div",{className:"space-y-3 p-3 bg-bambu-dark rounded-lg border border-bambu-dark-tertiary",children:[a.jsxs("p",{className:"text-white font-medium text-sm",children:["Energy Monitoring ",a.jsx("span",{className:"text-bambu-gray font-normal",children:"(optional)"})]}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Topic"}),a.jsx("input",{type:"text",value:k,onChange:Ee=>j(Ee.target.value),placeholder:"Same as power topic, or different",className:"w-full px-3 py-2 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg text-white placeholder-bambu-gray focus:border-bambu-green focus:outline-none"})]}),a.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"JSON Path"}),a.jsx("input",{type:"text",value:E,onChange:Ee=>P(Ee.target.value),placeholder:"energy_l1",className:"w-full px-3 py-2 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg text-white placeholder-bambu-gray focus:border-bambu-green focus:outline-none"})]}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Multiplier"}),a.jsx("input",{type:"text",value:U,onChange:Ee=>O(Ee.target.value),placeholder:"1",className:"w-full px-3 py-2 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg text-white placeholder-bambu-gray focus:border-bambu-green focus:outline-none"})]})]}),a.jsxs("p",{className:"text-xs text-bambu-gray",children:["JSON path extracts value from JSON payload. Leave empty for raw values.",a.jsx("br",{}),"Use multiplier 0.001 for Wh→kWh, 1000 for MWh→kWh."]})]}),a.jsxs("div",{className:"space-y-3 p-3 bg-bambu-dark rounded-lg border border-bambu-dark-tertiary",children:[a.jsxs("p",{className:"text-white font-medium text-sm",children:["State Monitoring ",a.jsx("span",{className:"text-bambu-gray font-normal",children:"(optional)"})]}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Topic"}),a.jsx("input",{type:"text",value:B,onChange:Ee=>R(Ee.target.value),placeholder:"Same as power topic, or different",className:"w-full px-3 py-2 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg text-white placeholder-bambu-gray focus:border-bambu-green focus:outline-none"})]}),a.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"JSON Path"}),a.jsx("input",{type:"text",value:G,onChange:Ee=>q(Ee.target.value),placeholder:"state_l1",className:"w-full px-3 py-2 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg text-white placeholder-bambu-gray focus:border-bambu-green focus:outline-none"})]}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"ON Value"}),a.jsx("input",{type:"text",value:z,onChange:Ee=>K(Ee.target.value),placeholder:n("smartPlugs.addSmartPlug.placeholders.mqttStateOnValue"),className:"w-full px-3 py-2 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg text-white placeholder-bambu-gray focus:border-bambu-green focus:outline-none"})]})]}),a.jsxs("p",{className:"text-xs text-bambu-gray",children:["JSON path extracts value from JSON payload. Leave empty for raw values.",a.jsx("br",{}),'ON value: the exact string that means "ON". Leave empty for auto-detect (ON, true, 1).']})]})]})]}),s==="tasmota"&&a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"IP Address *"}),a.jsxs("div",{className:"flex gap-2",children:[a.jsx("input",{type:"text",value:u,onChange:Ee=>{d(Ee.target.value),Oe(null)},placeholder:"192.168.1.100",className:"flex-1 px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none"}),a.jsxs(Ce,{type:"button",variant:"secondary",onClick:()=>dt.mutate(),disabled:!u.trim()||dt.isPending,children:[dt.isPending?a.jsx(it,{className:"w-4 h-4 animate-spin"}):a.jsx(Qg,{className:"w-4 h-4"}),"Test"]})]})]}),s==="tasmota"&&Ue&&a.jsx("div",{className:`p-3 rounded-lg flex items-center gap-2 ${Ue.success?"bg-bambu-green/20 border border-bambu-green/50 text-bambu-green":"bg-red-500/20 border border-red-500/50 text-red-400"}`,children:Ue.success?a.jsxs(a.Fragment,{children:[a.jsx(gr,{className:"w-5 h-5"}),a.jsxs("div",{children:[a.jsx("p",{className:"font-medium",children:"Connected!"}),a.jsxs("p",{className:"text-sm opacity-80",children:[Ue.device_name&&`Device: ${Ue.device_name} - `,"State: ",Ue.state]})]})]}):a.jsxs(a.Fragment,{children:[a.jsx(Rf,{className:"w-5 h-5"}),a.jsx("span",{children:n("smartPlugs.addSmartPlug.connectionFailed")})]})}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Name *"}),a.jsx("input",{type:"text",value:l,onChange:Ee=>c(Ee.target.value),placeholder:n("smartPlugs.addSmartPlug.placeholders.plugName"),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none"})]}),s==="tasmota"&&a.jsxs(a.Fragment,{children:[a.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Username"}),a.jsx("input",{type:"text",value:h,onChange:Ee=>f(Ee.target.value),placeholder:"admin",className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none"})]}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Password"}),a.jsx("input",{type:"password",value:p,onChange:Ee=>x(Ee.target.value),placeholder:"********",className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none"})]})]}),a.jsx("p",{className:"text-xs text-bambu-gray -mt-2",children:"Leave empty if your Tasmota device doesn't require authentication"})]}),s!=="mqtt"&&a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Link to Printer"}),a.jsxs("select",{value:xe??"",onChange:Ee=>be(Ee.target.value?Number(Ee.target.value):null),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",children:[a.jsx("option",{value:"",children:"No printer (manual control only)"}),ze?.map(Ee=>a.jsx("option",{value:Ee.id,children:Ee.name},Ee.id))]}),a.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:"Linking enables automatic on/off when prints start/complete"})]}),a.jsxs("div",{className:"border-t border-bambu-dark-tertiary pt-4",children:[a.jsxs("div",{className:"flex items-center justify-between mb-3",children:[a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx(Xg,{className:"w-4 h-4 text-bambu-green"}),a.jsx("span",{className:"text-white font-medium",children:"Power Alerts"})]}),a.jsxs("label",{className:"relative inline-flex items-center cursor-pointer",children:[a.jsx("input",{type:"checkbox",checked:we,onChange:Ee=>ye(Ee.target.checked),className:"sr-only peer"}),a.jsx("div",{className:"w-11 h-6 bg-bambu-dark-tertiary peer-focus:outline-none rounded-full peer peer-checked:after:translate-x-full peer-checked:after:border-white after:content-[''] after:absolute after:top-[2px] after:left-[2px] after:bg-white after:rounded-full after:h-5 after:w-5 after:transition-all peer-checked:bg-bambu-green"})]})]}),we&&a.jsxs("div",{className:"space-y-3",children:[a.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Alert if above (W)"}),a.jsx("input",{type:"number",value:le,onChange:Ee=>Le(Ee.target.value),placeholder:"e.g. 200",min:"0",max:"5000",className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none"})]}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Alert if below (W)"}),a.jsx("input",{type:"number",value:Me,onChange:Ee=>$e(Ee.target.value),placeholder:"e.g. 10",min:"0",max:"5000",className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none"})]})]}),a.jsx("p",{className:"text-xs text-bambu-gray",children:"Get notified when power consumption crosses these thresholds. Leave empty to disable that direction."})]})]}),s!=="mqtt"&&a.jsxs("div",{className:"border-t border-bambu-dark-tertiary pt-4",children:[a.jsxs("div",{className:"flex items-center justify-between mb-3",children:[a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx(Wn,{className:"w-4 h-4 text-bambu-green"}),a.jsx("span",{className:"text-white font-medium",children:"Daily Schedule"})]}),a.jsxs("label",{className:"relative inline-flex items-center cursor-pointer",children:[a.jsx("input",{type:"checkbox",checked:Ae,onChange:Ee=>Je(Ee.target.checked),className:"sr-only peer"}),a.jsx("div",{className:"w-11 h-6 bg-bambu-dark-tertiary peer-focus:outline-none rounded-full peer peer-checked:after:translate-x-full peer-checked:after:border-white after:content-[''] after:absolute after:top-[2px] after:left-[2px] after:bg-white after:rounded-full after:h-5 after:w-5 after:transition-all peer-checked:bg-bambu-green"})]})]}),Ae&&a.jsxs("div",{className:"space-y-3",children:[a.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Turn On at"}),a.jsx("input",{type:"time",value:Pe,onChange:Ee=>Xe(Ee.target.value),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none"})]}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Turn Off at"}),a.jsx("input",{type:"time",value:De,onChange:Ee=>Re(Ee.target.value),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none"})]})]}),a.jsx("p",{className:"text-xs text-bambu-gray",children:"Automatically turn the plug on/off at these times daily. Leave empty to skip that action."})]})]}),a.jsx("div",{className:"border-t border-bambu-dark-tertiary pt-4",children:a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx(xv,{className:"w-4 h-4 text-bambu-green"}),a.jsxs("div",{children:[a.jsx("span",{className:"text-white font-medium",children:"Show in Switchbar"}),a.jsx("p",{className:"text-xs text-bambu-gray",children:"Quick access from sidebar"})]})]}),a.jsxs("label",{className:"relative inline-flex items-center cursor-pointer",children:[a.jsx("input",{type:"checkbox",checked:qe,onChange:Ee=>pt(Ee.target.checked),className:"sr-only peer"}),a.jsx("div",{className:"w-11 h-6 bg-bambu-dark-tertiary peer-focus:outline-none rounded-full peer peer-checked:after:translate-x-full peer-checked:after:border-white after:content-[''] after:absolute after:top-[2px] after:left-[2px] after:bg-white after:rounded-full after:h-5 after:w-5 after:transition-all peer-checked:bg-bambu-green"})]})]})}),s==="homeassistant"&&a.jsx("div",{className:"border-t border-bambu-dark-tertiary pt-4",children:a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx(Xl,{className:"w-4 h-4 text-bambu-green"}),a.jsxs("div",{children:[a.jsx("span",{className:"text-white font-medium",children:"Show on Printer Card"}),a.jsx("p",{className:"text-xs text-bambu-gray",children:"Display button on printer card"})]})]}),a.jsxs("label",{className:"relative inline-flex items-center cursor-pointer",children:[a.jsx("input",{type:"checkbox",checked:At,onChange:Ee=>Rt(Ee.target.checked),className:"sr-only peer"}),a.jsx("div",{className:"w-11 h-6 bg-bambu-dark-tertiary peer-focus:outline-none rounded-full peer peer-checked:after:translate-x-full peer-checked:after:border-white after:content-[''] after:absolute after:top-[2px] after:left-[2px] after:bg-white after:rounded-full after:h-5 after:w-5 after:transition-all peer-checked:bg-bambu-green"})]})]})}),a.jsxs("div",{className:"flex gap-3 pt-2",children:[a.jsx(Ce,{type:"button",variant:"secondary",onClick:e,className:"flex-1",children:"Cancel"}),a.jsxs(Ce,{type:"submit",disabled:Ve,className:"flex-1",children:[Ve?a.jsx(it,{className:"w-4 h-4 animate-spin"}):a.jsx(bs,{className:"w-4 h-4"}),i?"Save":"Add"]})]})]})]})})}function zn({checked:t,onChange:e,disabled:n}){const r=i=>{i.preventDefault(),i.stopPropagation(),n||e(!t)};return a.jsx("button",{type:"button",role:"switch","aria-checked":t,disabled:n,onClick:r,className:`relative inline-flex w-11 h-7 md:w-9 md:h-5 rounded-full transition-colors flex-shrink-0 focus:outline-none focus:ring-2 focus:ring-bambu-green focus:ring-offset-2 focus:ring-offset-bambu-dark ${n?"bg-bambu-dark-tertiary/50 cursor-not-allowed opacity-50":t?"bg-bambu-green cursor-pointer":"bg-bambu-dark-tertiary cursor-pointer hover:bg-bambu-dark-tertiary/80"}`,children:a.jsx("span",{className:`pointer-events-none absolute top-[3px] md:top-[2px] left-[3px] md:left-[2px] w-5 h-5 md:w-4 md:h-4 bg-white rounded-full shadow transition-transform duration-200 ease-in-out ${t?"translate-x-4":"translate-x-0"}`})})}const qQe={callmebot:"CallMeBot/WhatsApp",ntfy:"ntfy",pushover:"Pushover",telegram:"Telegram",email:"Email",discord:"Discord",webhook:"Webhook"};function WQe({provider:t,onEdit:e}){const n=tn(),[r,i]=w.useState(!1),[s,o]=w.useState(!1),[l,c]=w.useState(null),{data:u}=Ze({queryKey:["printers"],queryFn:re.getPrinters}),d=u?.find(y=>y.id===t.printer_id),h=ot({mutationFn:y=>re.updateNotificationProvider(t.id,y),onSuccess:()=>{n.invalidateQueries({queryKey:["notification-providers"]})}}),f=ot({mutationFn:()=>re.deleteNotificationProvider(t.id),onSuccess:()=>{n.invalidateQueries({queryKey:["notification-providers"]})}}),p=ot({mutationFn:()=>re.testNotificationProvider(t.id),onSuccess:y=>{c(y),n.invalidateQueries({queryKey:["notification-providers"]})},onError:y=>{c({success:!1,message:y.message})}}),x=y=>y||"";return a.jsxs(a.Fragment,{children:[a.jsx(vt,{className:"relative",children:a.jsxs(Nt,{className:"p-4",children:[a.jsxs("div",{className:"flex items-start justify-between mb-3",children:[a.jsxs("div",{className:"flex items-center gap-3",children:[a.jsx("div",{className:`p-2 rounded-lg ${t.enabled?"bg-bambu-green/20":"bg-bambu-dark"}`,children:a.jsx(Xg,{className:`w-5 h-5 ${t.enabled?"text-bambu-green":"text-bambu-gray"}`})}),a.jsxs("div",{children:[a.jsx("h3",{className:"font-medium text-white",children:t.name}),a.jsx("p",{className:"text-sm text-bambu-gray",children:qQe[t.provider_type]||t.provider_type})]})]}),a.jsxs("div",{className:"flex items-center gap-3",children:[t.last_success&&a.jsxs("span",{className:"text-xs text-status-ok hidden sm:inline",children:["Last: ",gb(t.last_success)]}),t.last_error&&t.last_error_at&&(!t.last_success||(Zi(t.last_error_at)?.getTime()||0)>(Zi(t.last_success)?.getTime()||0))&&a.jsx("span",{className:"text-xs text-status-error",title:t.last_error,children:"Error"}),a.jsx(zn,{checked:t.enabled,onChange:y=>h.mutate({enabled:y})})]})]}),d&&a.jsxs("div",{className:"mb-3 px-2 py-1.5 bg-bambu-dark rounded-lg",children:[a.jsx("span",{className:"text-xs text-bambu-gray",children:"Printer: "}),a.jsx("span",{className:"text-sm text-white",children:d.name})]}),!d&&!t.printer_id&&a.jsx("div",{className:"mb-3 px-2 py-1.5 bg-bambu-dark rounded-lg",children:a.jsx("span",{className:"text-xs text-bambu-gray",children:"All printers"})}),a.jsxs("div",{className:"mb-3 flex flex-wrap gap-1",children:[t.on_print_start&&a.jsx("span",{className:"px-2 py-0.5 bg-blue-500/20 text-blue-400 text-xs rounded",children:"Start"}),t.on_plate_not_empty&&a.jsx("span",{className:"px-2 py-0.5 bg-rose-600/20 text-rose-300 text-xs rounded",children:"Plate Check"}),t.on_print_complete&&a.jsx("span",{className:"px-2 py-0.5 bg-bambu-green/20 text-bambu-green text-xs rounded",children:"Complete"}),t.on_print_failed&&a.jsx("span",{className:"px-2 py-0.5 bg-red-500/20 text-red-400 text-xs rounded",children:"Failed"}),t.on_print_stopped&&a.jsx("span",{className:"px-2 py-0.5 bg-orange-500/20 text-orange-400 text-xs rounded",children:"Stopped"}),t.on_print_progress&&a.jsx("span",{className:"px-2 py-0.5 bg-yellow-500/20 text-yellow-400 text-xs rounded",children:"Progress"}),t.on_printer_offline&&a.jsx("span",{className:"px-2 py-0.5 bg-gray-500/20 text-gray-400 text-xs rounded",children:"Offline"}),t.on_printer_error&&a.jsx("span",{className:"px-2 py-0.5 bg-rose-500/20 text-rose-400 text-xs rounded",children:"Error"}),t.on_filament_low&&a.jsx("span",{className:"px-2 py-0.5 bg-cyan-500/20 text-cyan-400 text-xs rounded",children:"Low Filament"}),t.on_maintenance_due&&a.jsx("span",{className:"px-2 py-0.5 bg-purple-500/20 text-purple-400 text-xs rounded",children:"Maintenance"}),t.on_ams_humidity_high&&a.jsx("span",{className:"px-2 py-0.5 bg-blue-600/20 text-blue-300 text-xs rounded",children:"AMS Humidity"}),t.on_ams_temperature_high&&a.jsx("span",{className:"px-2 py-0.5 bg-orange-600/20 text-orange-300 text-xs rounded",children:"AMS Temp"}),t.on_ams_ht_humidity_high&&a.jsx("span",{className:"px-2 py-0.5 bg-cyan-600/20 text-cyan-300 text-xs rounded",children:"AMS-HT Humidity"}),t.on_ams_ht_temperature_high&&a.jsx("span",{className:"px-2 py-0.5 bg-amber-600/20 text-amber-300 text-xs rounded",children:"AMS-HT Temp"}),t.on_bed_cooled&&a.jsx("span",{className:"px-2 py-0.5 bg-teal-500/20 text-teal-400 text-xs rounded",children:"Bed Cooled"}),t.quiet_hours_enabled&&a.jsxs("span",{className:"px-2 py-0.5 bg-indigo-500/20 text-indigo-400 text-xs rounded flex items-center gap-1",children:[a.jsx(j1,{className:"w-3 h-3"}),"Quiet"]}),t.daily_digest_enabled&&a.jsxs("span",{className:"px-2 py-0.5 bg-emerald-500/20 text-emerald-400 text-xs rounded flex items-center gap-1",children:[a.jsx(ii,{className:"w-3 h-3"}),"Digest ",t.daily_digest_time]})]}),a.jsx("div",{className:"mb-3",children:a.jsxs(Ce,{size:"sm",variant:"secondary",disabled:p.isPending,onClick:()=>{c(null),p.mutate()},className:"w-full",children:[p.isPending?a.jsx(it,{className:"w-4 h-4 animate-spin"}):a.jsx(lC,{className:"w-4 h-4"}),"Send Test Notification"]})}),l&&a.jsxs("div",{className:`mb-3 p-2 rounded-lg flex items-center gap-2 text-sm ${l.success?"bg-bambu-green/20 text-bambu-green":"bg-red-500/20 text-red-400"}`,children:[l.success?a.jsx(gr,{className:"w-4 h-4"}):a.jsx(ha,{className:"w-4 h-4"}),a.jsx("span",{children:l.message})]}),a.jsxs("button",{onClick:()=>o(!s),className:"w-full flex items-center justify-between py-2 text-sm text-bambu-gray hover:text-white transition-colors border-t border-bambu-dark-tertiary",children:[a.jsxs("span",{className:"flex items-center gap-2",children:[a.jsx(nd,{className:"w-4 h-4"}),"Event Settings"]}),s?a.jsx(Wl,{className:"w-4 h-4"}):a.jsx(nr,{className:"w-4 h-4"})]}),s&&a.jsxs("div",{className:"pt-3 border-t border-bambu-dark-tertiary space-y-4",children:[a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsxs("div",{children:[a.jsx("p",{className:"text-sm text-white",children:"Enabled"}),a.jsx("p",{className:"text-xs text-bambu-gray",children:"Send notifications from this provider"})]}),a.jsx(zn,{checked:t.enabled,onChange:y=>h.mutate({enabled:y})})]}),a.jsxs("div",{className:"space-y-2",children:[a.jsx("p",{className:"text-xs text-bambu-gray uppercase tracking-wide",children:"Print Events"}),a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsx("p",{className:"text-sm text-white",children:"Print Started"}),a.jsx(zn,{checked:t.on_print_start,onChange:y=>h.mutate({on_print_start:y})})]}),a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsxs("div",{children:[a.jsx("p",{className:"text-sm text-white",children:"Plate Not Empty"}),a.jsx("p",{className:"text-xs text-bambu-gray",children:"Objects detected before print"})]}),a.jsx(zn,{checked:t.on_plate_not_empty??!0,onChange:y=>h.mutate({on_plate_not_empty:y})})]}),a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsx("p",{className:"text-sm text-white",children:"Print Completed"}),a.jsx(zn,{checked:t.on_print_complete,onChange:y=>h.mutate({on_print_complete:y})})]}),a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsxs("div",{children:[a.jsx("p",{className:"text-sm text-white",children:"Bed Cooled"}),a.jsx("p",{className:"text-xs text-bambu-gray",children:"Bed cooled below threshold after print"})]}),a.jsx(zn,{checked:t.on_bed_cooled??!1,onChange:y=>h.mutate({on_bed_cooled:y})})]}),a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsx("p",{className:"text-sm text-white",children:"Print Failed"}),a.jsx(zn,{checked:t.on_print_failed,onChange:y=>h.mutate({on_print_failed:y})})]}),a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsx("p",{className:"text-sm text-white",children:"Print Stopped"}),a.jsx(zn,{checked:t.on_print_stopped,onChange:y=>h.mutate({on_print_stopped:y})})]}),a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsxs("div",{children:[a.jsx("p",{className:"text-sm text-white",children:"Progress Milestones"}),a.jsx("p",{className:"text-xs text-bambu-gray",children:"Notify at 25%, 50%, 75%"})]}),a.jsx(zn,{checked:t.on_print_progress,onChange:y=>h.mutate({on_print_progress:y})})]})]}),a.jsxs("div",{className:"space-y-2",children:[a.jsx("p",{className:"text-xs text-bambu-gray uppercase tracking-wide",children:"Printer Status"}),a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsx("p",{className:"text-sm text-white",children:"Printer Offline"}),a.jsx(zn,{checked:t.on_printer_offline,onChange:y=>h.mutate({on_printer_offline:y})})]}),a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsx("p",{className:"text-sm text-white",children:"Printer Error"}),a.jsx(zn,{checked:t.on_printer_error,onChange:y=>h.mutate({on_printer_error:y})})]}),a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsx("p",{className:"text-sm text-white",children:"Low Filament"}),a.jsx(zn,{checked:t.on_filament_low,onChange:y=>h.mutate({on_filament_low:y})})]}),a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsxs("div",{children:[a.jsx("p",{className:"text-sm text-white",children:"Maintenance Due"}),a.jsx("p",{className:"text-xs text-bambu-gray",children:"Notify when maintenance is needed"})]}),a.jsx(zn,{checked:t.on_maintenance_due??!1,onChange:y=>h.mutate({on_maintenance_due:y})})]})]}),a.jsxs("div",{className:"space-y-2",children:[a.jsx("p",{className:"text-xs text-bambu-gray uppercase tracking-wide",children:"AMS Alarms"}),a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsxs("div",{children:[a.jsx("p",{className:"text-sm text-white",children:"AMS Humidity High"}),a.jsx("p",{className:"text-xs text-bambu-gray",children:"Regular AMS humidity exceeds threshold"})]}),a.jsx(zn,{checked:t.on_ams_humidity_high??!1,onChange:y=>h.mutate({on_ams_humidity_high:y})})]}),a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsxs("div",{children:[a.jsx("p",{className:"text-sm text-white",children:"AMS Temperature High"}),a.jsx("p",{className:"text-xs text-bambu-gray",children:"Regular AMS temperature exceeds threshold"})]}),a.jsx(zn,{checked:t.on_ams_temperature_high??!1,onChange:y=>h.mutate({on_ams_temperature_high:y})})]})]}),a.jsxs("div",{className:"space-y-2",children:[a.jsx("p",{className:"text-xs text-bambu-gray uppercase tracking-wide",children:"AMS-HT Alarms"}),a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsxs("div",{children:[a.jsx("p",{className:"text-sm text-white",children:"AMS-HT Humidity High"}),a.jsx("p",{className:"text-xs text-bambu-gray",children:"AMS-HT humidity exceeds threshold"})]}),a.jsx(zn,{checked:t.on_ams_ht_humidity_high??!1,onChange:y=>h.mutate({on_ams_ht_humidity_high:y})})]}),a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsxs("div",{children:[a.jsx("p",{className:"text-sm text-white",children:"AMS-HT Temperature High"}),a.jsx("p",{className:"text-xs text-bambu-gray",children:"AMS-HT temperature exceeds threshold"})]}),a.jsx(zn,{checked:t.on_ams_ht_temperature_high??!1,onChange:y=>h.mutate({on_ams_ht_temperature_high:y})})]})]}),a.jsxs("div",{className:"space-y-2",children:[a.jsx("p",{className:"text-xs text-bambu-gray uppercase tracking-wide",children:"Print Queue"}),a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsxs("div",{children:[a.jsx("p",{className:"text-sm text-white",children:"Job Added"}),a.jsx("p",{className:"text-xs text-bambu-gray",children:"Job added to queue"})]}),a.jsx(zn,{checked:t.on_queue_job_added??!1,onChange:y=>h.mutate({on_queue_job_added:y})})]}),a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsxs("div",{children:[a.jsx("p",{className:"text-sm text-white",children:"Job Assigned"}),a.jsx("p",{className:"text-xs text-bambu-gray",children:"Model-based job assigned to printer"})]}),a.jsx(zn,{checked:t.on_queue_job_assigned??!1,onChange:y=>h.mutate({on_queue_job_assigned:y})})]}),a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsxs("div",{children:[a.jsx("p",{className:"text-sm text-white",children:"Job Started"}),a.jsx("p",{className:"text-xs text-bambu-gray",children:"Queue job started printing"})]}),a.jsx(zn,{checked:t.on_queue_job_started??!1,onChange:y=>h.mutate({on_queue_job_started:y})})]}),a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsxs("div",{children:[a.jsx("p",{className:"text-sm text-white",children:"Job Waiting"}),a.jsx("p",{className:"text-xs text-bambu-gray",children:"Job waiting for filament"})]}),a.jsx(zn,{checked:t.on_queue_job_waiting??!0,onChange:y=>h.mutate({on_queue_job_waiting:y})})]}),a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsxs("div",{children:[a.jsx("p",{className:"text-sm text-white",children:"Job Skipped"}),a.jsx("p",{className:"text-xs text-bambu-gray",children:"Job skipped (previous failed)"})]}),a.jsx(zn,{checked:t.on_queue_job_skipped??!0,onChange:y=>h.mutate({on_queue_job_skipped:y})})]}),a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsxs("div",{children:[a.jsx("p",{className:"text-sm text-white",children:"Job Failed"}),a.jsx("p",{className:"text-xs text-bambu-gray",children:"Job failed to start"})]}),a.jsx(zn,{checked:t.on_queue_job_failed??!0,onChange:y=>h.mutate({on_queue_job_failed:y})})]}),a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsxs("div",{children:[a.jsx("p",{className:"text-sm text-white",children:"Queue Complete"}),a.jsx("p",{className:"text-xs text-bambu-gray",children:"All queue jobs finished"})]}),a.jsx(zn,{checked:t.on_queue_completed??!1,onChange:y=>h.mutate({on_queue_completed:y})})]})]}),a.jsxs("div",{className:"space-y-2",children:[a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx(j1,{className:"w-4 h-4 text-purple-400"}),a.jsx("p",{className:"text-sm text-white",children:"Quiet Hours"})]}),a.jsx(zn,{checked:t.quiet_hours_enabled,onChange:y=>h.mutate({quiet_hours_enabled:y})})]}),t.quiet_hours_enabled&&a.jsxs("div",{className:"pl-4 border-l-2 border-bambu-dark-tertiary space-y-2",children:[a.jsx("p",{className:"text-xs text-bambu-gray",children:"No notifications during these hours"}),a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx(Wn,{className:"w-4 h-4 text-bambu-gray"}),a.jsxs("span",{className:"text-sm text-white",children:[x(t.quiet_hours_start)||"22:00"," - ",x(t.quiet_hours_end)||"07:00"]})]}),a.jsx("p",{className:"text-xs text-bambu-gray",children:"Edit provider to change quiet hours"})]})]}),a.jsxs("div",{className:"space-y-2",children:[a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx(ii,{className:"w-4 h-4 text-emerald-400"}),a.jsx("p",{className:"text-sm text-white",children:"Daily Digest"})]}),a.jsx(zn,{checked:t.daily_digest_enabled,onChange:y=>h.mutate({daily_digest_enabled:y})})]}),t.daily_digest_enabled&&a.jsxs("div",{className:"pl-4 border-l-2 border-bambu-dark-tertiary space-y-2",children:[a.jsx("p",{className:"text-xs text-bambu-gray",children:"Batch notifications into a single daily summary"}),a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx(Wn,{className:"w-4 h-4 text-bambu-gray"}),a.jsxs("span",{className:"text-sm text-white",children:["Send at ",x(t.daily_digest_time)||"08:00"]})]}),a.jsx("p",{className:"text-xs text-bambu-gray",children:"Edit provider to change digest time"})]})]}),a.jsxs("div",{className:"flex gap-2 pt-2",children:[a.jsxs(Ce,{size:"sm",variant:"secondary",onClick:()=>e(t),className:"flex-1",children:[a.jsx(af,{className:"w-4 h-4"}),"Edit"]}),a.jsx(Ce,{size:"sm",variant:"secondary",onClick:()=>i(!0),className:"text-red-400 hover:text-red-300",children:a.jsx(Jt,{className:"w-4 h-4"})})]})]})]})}),r&&a.jsx(vn,{title:"Delete Notification Provider",message:`Are you sure you want to delete "${t.name}"? This cannot be undone.`,confirmText:"Delete",variant:"danger",onConfirm:()=>{f.mutate(),i(!1)},onCancel:()=>i(!1)})]})}const aK=[{value:"email",label:"Email",description:"SMTP email notifications"},{value:"telegram",label:"Telegram",description:"Notifications via Telegram bot"},{value:"discord",label:"Discord",description:"Send to Discord channel via webhook"},{value:"ntfy",label:"ntfy",description:"Free, self-hostable push notifications"},{value:"pushover",label:"Pushover",description:"Simple, reliable push notifications"},{value:"callmebot",label:"CallMeBot/WhatsApp",description:"Free WhatsApp notifications via CallMeBot"},{value:"webhook",label:"Webhook",description:"Generic HTTP POST to any URL"}];function KQe({provider:t,onClose:e}){const n=tn(),r=!!t,[i,s]=w.useState(t?.name||""),[o,l]=w.useState(t?.provider_type||"email"),[c,u]=w.useState(t?.printer_id||null),[d,h]=w.useState(t?.quiet_hours_enabled||!1),[f,p]=w.useState(t?.quiet_hours_start||"22:00"),[x,y]=w.useState(t?.quiet_hours_end||"07:00"),[b,v]=w.useState(t?.daily_digest_enabled||!1),[S,N]=w.useState(t?.daily_digest_time||"08:00"),[A,C]=w.useState(t?.on_print_start??!1),[T,k]=w.useState(t?.on_print_complete??!0),[j,E]=w.useState(t?.on_print_failed??!0),[P,U]=w.useState(t?.on_print_stopped??!0),[O,B]=w.useState(t?.on_print_progress??!1),[R,G]=w.useState(t?.on_printer_offline??!1),[q,z]=w.useState(t?.on_printer_error??!1),[K,Y]=w.useState(t?.on_filament_low??!1),[oe,$]=w.useState(t?.on_maintenance_due??!1),[X,ee]=w.useState(t?.on_bed_cooled??!1),[J,_e]=w.useState(t?.config?Object.fromEntries(Object.entries(t.config).map(([Z,Ne])=>[Z,String(Ne)])):{}),[pe,me]=w.useState(null),[je,de]=w.useState(null),{data:ce}=Ze({queryKey:["printers"],queryFn:re.getPrinters});w.useEffect(()=>{const Z=Ne=>{Ne.key==="Escape"&&e()};return window.addEventListener("keydown",Z),()=>window.removeEventListener("keydown",Z)},[e]);const Se=ot({mutationFn:()=>re.testNotificationConfig({provider_type:o,config:J}),onSuccess:Z=>{me(Z),de(null)},onError:Z=>{me({success:!1,message:Z.message})}}),ie=ot({mutationFn:Z=>re.createNotificationProvider(Z),onSuccess:()=>{n.invalidateQueries({queryKey:["notification-providers"]}),e()},onError:Z=>{de(Z.message)}}),Fe=ot({mutationFn:Z=>re.updateNotificationProvider(t.id,Z),onSuccess:()=>{n.invalidateQueries({queryKey:["notification-providers"]}),e()},onError:Z=>{de(Z.message)}}),V=Z=>{if(Z.preventDefault(),de(null),!i.trim()){de("Name is required");return}const Ne=Q(o);for(const fe of Ne)if(!J[fe.key]?.trim()){de(`${fe.label} is required`);return}const ve={name:i.trim(),provider_type:o,config:J,printer_id:c,quiet_hours_enabled:d,quiet_hours_start:d?f:null,quiet_hours_end:d?x:null,daily_digest_enabled:b,daily_digest_time:b?S:null,on_print_start:A,on_print_complete:T,on_print_failed:j,on_print_stopped:P,on_print_progress:O,on_printer_offline:R,on_printer_error:q,on_filament_low:K,on_maintenance_due:oe,on_bed_cooled:X};r?Fe.mutate(ve):ie.mutate(ve)},W=ie.isPending||Fe.isPending,ue=Z=>{switch(Z){case"callmebot":return[{key:"phone",label:"Phone Number",placeholder:"+1234567890",type:"text",required:!0},{key:"apikey",label:"API Key",placeholder:"Your CallMeBot API key",type:"text",required:!0}];case"ntfy":return[{key:"server",label:"Server URL",placeholder:"https://ntfy.sh",type:"text",required:!1},{key:"topic",label:"Topic",placeholder:"my-bambuddy",type:"text",required:!0},{key:"auth_token",label:"Auth Token",placeholder:"Optional authentication",type:"password",required:!1}];case"pushover":return[{key:"user_key",label:"User Key",placeholder:"Your Pushover user key",type:"text",required:!0},{key:"app_token",label:"App Token",placeholder:"Your Pushover app token",type:"text",required:!0},{key:"priority",label:"Priority",placeholder:"0 (normal)",type:"number",required:!1}];case"telegram":return[{key:"bot_token",label:"Bot Token",placeholder:"Bot token from @BotFather",type:"password",required:!0},{key:"chat_id",label:"Chat ID",placeholder:"Your chat or group ID",type:"text",required:!0}];case"email":return[{key:"smtp_server",label:"SMTP Server",placeholder:"smtp.gmail.com",type:"text",required:!0},{key:"smtp_port",label:"SMTP Port",placeholder:"587",type:"number",required:!1},{key:"security",label:"Security",type:"select",required:!1,options:[{value:"starttls",label:"STARTTLS (Port 587)"},{value:"ssl",label:"SSL/TLS (Port 465)"},{value:"none",label:"None (Port 25)"}]},{key:"auth_enabled",label:"Authentication",type:"select",required:!1,options:[{value:"true",label:"Enabled"},{value:"false",label:"Disabled"}]},{key:"username",label:"Username",placeholder:"your@email.com",type:"text",required:!1},{key:"password",label:"Password",placeholder:"App password",type:"password",required:!1},{key:"from_email",label:"From Email",placeholder:"your@email.com",type:"text",required:!0},{key:"to_email",label:"To Email",placeholder:"recipient@email.com",type:"text",required:!0}];case"discord":return[{key:"webhook_url",label:"Webhook URL",placeholder:"https://discord.com/api/webhooks/...",type:"text",required:!0}];case"webhook":return[{key:"webhook_url",label:"Webhook URL",placeholder:"https://example.com/webhook",type:"text",required:!0},{key:"payload_format",label:"Payload Format",type:"select",required:!1,options:[{value:"generic",label:"Generic JSON"},{value:"slack",label:"Slack / Mattermost"}]},{key:"auth_header",label:"Authorization",placeholder:"Bearer token (optional)",type:"password",required:!1},{key:"field_title",label:"Title Field Name",placeholder:"title",type:"text",required:!1,showIf:Ne=>Ne.payload_format!=="slack"},{key:"field_message",label:"Message Field Name",placeholder:"message",type:"text",required:!1,showIf:Ne=>Ne.payload_format!=="slack"}];default:return[]}},Q=Z=>ue(Z).filter(Ne=>Ne.required),se=ue(o);return a.jsx("div",{className:"fixed inset-0 bg-black/70 flex items-center justify-center z-50 p-4 overflow-y-auto",onClick:e,children:a.jsxs("div",{className:"bg-bambu-dark-secondary rounded-xl border border-bambu-dark-tertiary w-full max-w-lg my-8 max-h-[90vh] overflow-y-auto",onClick:Z=>Z.stopPropagation(),children:[a.jsxs("div",{className:"flex items-center justify-between px-6 py-4 border-b border-bambu-dark-tertiary",children:[a.jsx("h2",{className:"text-lg font-semibold text-white",children:r?"Edit Notification Provider":"Add Notification Provider"}),a.jsx("button",{onClick:e,className:"text-bambu-gray hover:text-white transition-colors",children:a.jsx(Ft,{className:"w-5 h-5"})})]}),a.jsxs("form",{onSubmit:V,className:"p-6 space-y-4",children:[je&&a.jsx("div",{className:"p-3 bg-red-500/20 border border-red-500/50 rounded-lg text-sm text-red-400",children:je}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Name *"}),a.jsx("input",{type:"text",value:i,onChange:Z=>s(Z.target.value),placeholder:"My Notifications",className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none"})]}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Provider Type *"}),a.jsx("select",{value:o,onChange:Z=>{l(Z.target.value),_e({}),me(null)},disabled:r,className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none disabled:opacity-50",children:aK.map(Z=>a.jsx("option",{value:Z.value,children:Z.label},Z.value))}),a.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:aK.find(Z=>Z.value===o)?.description})]}),a.jsxs("div",{className:"space-y-3",children:[a.jsx("p",{className:"text-sm text-bambu-gray",children:"Configuration"}),se.filter(Z=>!("showIf"in Z)||Z.showIf?.(J)!==!1).map(Z=>a.jsxs("div",{children:[a.jsxs("label",{className:"block text-sm text-bambu-gray mb-1",children:[Z.label," ",Z.required&&"*"]}),Z.type==="select"&&"options"in Z&&Z.options?a.jsx("select",{value:J[Z.key]||Z.options[0]?.value||"",onChange:Ne=>{_e({...J,[Z.key]:Ne.target.value}),me(null)},className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",children:Z.options.map(Ne=>a.jsx("option",{value:Ne.value,children:Ne.label},Ne.value))}):a.jsx("input",{type:Z.type,value:J[Z.key]||"",onChange:Ne=>{_e({...J,[Z.key]:Ne.target.value}),me(null)},placeholder:Z.placeholder,className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none"})]},Z.key))]}),a.jsx("div",{className:"flex gap-2",children:a.jsxs(Ce,{type:"button",variant:"secondary",onClick:()=>{me(null),Se.mutate()},disabled:Se.isPending||!J[Q(o)[0]?.key],className:"flex-1",children:[Se.isPending?a.jsx(it,{className:"w-4 h-4 animate-spin"}):a.jsx(lC,{className:"w-4 h-4"}),"Test Configuration"]})}),pe&&a.jsx("div",{className:`p-3 rounded-lg flex items-center gap-2 ${pe.success?"bg-bambu-green/20 border border-bambu-green/50 text-bambu-green":"bg-red-500/20 border border-red-500/50 text-red-400"}`,children:pe.success?a.jsxs(a.Fragment,{children:[a.jsx(gr,{className:"w-5 h-5"}),a.jsx("span",{children:pe.message})]}):a.jsxs(a.Fragment,{children:[a.jsx(ha,{className:"w-5 h-5"}),a.jsx("span",{children:pe.message})]})}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Printer Filter"}),a.jsxs("select",{value:c??"",onChange:Z=>u(Z.target.value?Number(Z.target.value):null),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",children:[a.jsx("option",{value:"",children:"All printers"}),ce?.map(Z=>a.jsx("option",{value:Z.id,children:Z.name},Z.id))]}),a.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:"Only send notifications for events from this printer"})]}),a.jsxs("div",{className:"space-y-2",children:[a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsx("label",{className:"text-sm text-white",children:"Quiet Hours (Do Not Disturb)"}),a.jsx(zn,{checked:d,onChange:h})]}),d&&a.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[a.jsxs("div",{children:[a.jsx("label",{className:"block text-xs text-bambu-gray mb-1",children:"Start"}),a.jsx("input",{type:"time",value:f,onChange:Z=>p(Z.target.value),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none"})]}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-xs text-bambu-gray mb-1",children:"End"}),a.jsx("input",{type:"time",value:x,onChange:Z=>y(Z.target.value),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none"})]})]})]}),a.jsxs("div",{className:"space-y-2",children:[a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsxs("div",{children:[a.jsx("label",{className:"text-sm text-white",children:"Daily Digest"}),a.jsx("p",{className:"text-xs text-bambu-gray",children:"Batch notifications into a single daily summary"})]}),a.jsx(zn,{checked:b,onChange:v})]}),b&&a.jsxs("div",{children:[a.jsx("label",{className:"block text-xs text-bambu-gray mb-1",children:"Send digest at"}),a.jsx("input",{type:"time",value:S,onChange:Z=>N(Z.target.value),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none"}),a.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:"Events will be collected and sent as a single summary at this time"})]})]}),a.jsxs("div",{className:"space-y-3",children:[a.jsx("p",{className:"text-sm text-bambu-gray",children:"Notification Events"}),a.jsxs("div",{className:"space-y-2 p-3 bg-bambu-dark rounded-lg",children:[a.jsx("p",{className:"text-xs text-bambu-gray uppercase tracking-wide mb-2",children:"Print Events"}),a.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsx("span",{className:"text-sm text-white",children:"Start"}),a.jsx(zn,{checked:A,onChange:C})]}),a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsx("span",{className:"text-sm text-white",children:"Complete"}),a.jsx(zn,{checked:T,onChange:k})]}),a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsx("span",{className:"text-sm text-white",children:"Failed"}),a.jsx(zn,{checked:j,onChange:E})]}),a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsx("span",{className:"text-sm text-white",children:"Stopped"}),a.jsx(zn,{checked:P,onChange:U})]}),a.jsxs("div",{className:"flex items-center justify-between col-span-2",children:[a.jsxs("div",{children:[a.jsx("span",{className:"text-sm text-white",children:"Progress"}),a.jsx("span",{className:"text-xs text-bambu-gray ml-1",children:"(25%, 50%, 75%)"})]}),a.jsx(zn,{checked:O,onChange:B})]}),a.jsxs("div",{className:"flex items-center justify-between col-span-2",children:[a.jsxs("div",{children:[a.jsx("span",{className:"text-sm text-white",children:"Bed Cooled"}),a.jsx("span",{className:"text-xs text-bambu-gray ml-1",children:"(after print completes)"})]}),a.jsx(zn,{checked:X,onChange:ee})]})]})]}),a.jsxs("div",{className:"space-y-2 p-3 bg-bambu-dark rounded-lg",children:[a.jsx("p",{className:"text-xs text-bambu-gray uppercase tracking-wide mb-2",children:"Printer Status"}),a.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsx("span",{className:"text-sm text-white",children:"Offline"}),a.jsx(zn,{checked:R,onChange:G})]}),a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsx("span",{className:"text-sm text-white",children:"Error"}),a.jsx(zn,{checked:q,onChange:z})]}),a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsx("span",{className:"text-sm text-white",children:"Low Filament"}),a.jsx(zn,{checked:K,onChange:Y})]}),a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsx("span",{className:"text-sm text-white",children:"Maintenance"}),a.jsx(zn,{checked:oe,onChange:$})]})]})]})]}),a.jsxs("div",{className:"flex gap-3 pt-2",children:[a.jsx(Ce,{type:"button",variant:"secondary",onClick:e,className:"flex-1",children:"Cancel"}),a.jsxs(Ce,{type:"submit",disabled:W,className:"flex-1",children:[W?a.jsx(it,{className:"w-4 h-4 animate-spin"}):a.jsx(bs,{className:"w-4 h-4"}),r?"Save":"Add"]})]})]})]})})}function XQe({template:t,onClose:e}){const n=tn(),r=w.useRef(null),[i,s]=w.useState(t.title_template),[o,l]=w.useState(t.body_template),[c,u]=w.useState(null),[d,h]=w.useState(!0),{data:f}=Ze({queryKey:["template-variables"],queryFn:re.getTemplateVariables}),p=f?.find(C=>C.event_type===t.event_type),{data:x,isLoading:y}=Ze({queryKey:["template-preview",t.event_type,i,o],queryFn:()=>re.previewTemplate({event_type:t.event_type,title_template:i,body_template:o}),enabled:d&&i.length>0&&o.length>0});w.useEffect(()=>{const C=T=>{T.key==="Escape"&&e()};return window.addEventListener("keydown",C),()=>window.removeEventListener("keydown",C)},[e]);const b=ot({mutationFn:C=>re.updateNotificationTemplate(t.id,C),onSuccess:()=>{n.invalidateQueries({queryKey:["notification-templates"]}),e()},onError:C=>{u(C.message)}}),v=ot({mutationFn:()=>re.resetNotificationTemplate(t.id),onSuccess:C=>{s(C.title_template),l(C.body_template),n.invalidateQueries({queryKey:["notification-templates"]})},onError:C=>{u(C.message)}}),S=C=>{if(C.preventDefault(),u(null),!i.trim()){u("Title is required");return}if(!o.trim()){u("Body is required");return}b.mutate({title_template:i,body_template:o})},N=C=>{const T=r.current;if(!T)return;const k=T.selectionStart,j=T.selectionEnd,E=o,P=E.substring(0,k),U=E.substring(j),O=P+`{${C}}`+U;l(O),setTimeout(()=>{T.focus();const B=k+C.length+2;T.setSelectionRange(B,B)},0)},A=i!==t.title_template||o!==t.body_template;return a.jsx("div",{className:"fixed inset-0 bg-black/80 flex items-center justify-center z-50 p-4",children:a.jsxs("div",{className:"bg-bambu-dark-secondary rounded-lg w-full max-w-2xl max-h-[90vh] flex flex-col",children:[a.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-bambu-dark-tertiary shrink-0",children:[a.jsxs("h2",{className:"text-lg font-semibold text-white",children:["Edit Template: ",t.name]}),a.jsx("button",{onClick:e,className:"p-1 hover:bg-bambu-dark-tertiary rounded transition-colors",children:a.jsx(Ft,{className:"w-5 h-5 text-bambu-gray"})})]}),a.jsxs("form",{onSubmit:S,className:"flex-1 overflow-y-auto p-4 space-y-4",children:[c&&a.jsx("div",{className:"p-3 bg-red-500/20 border border-red-500/50 rounded text-red-400 text-sm",children:c}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm font-medium text-bambu-gray mb-1",children:"Title"}),a.jsx("input",{type:"text",value:i,onChange:C=>s(C.target.value),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded text-white focus:outline-none focus:ring-1 focus:ring-bambu-green",placeholder:"Notification title..."})]}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm font-medium text-bambu-gray mb-1",children:"Body"}),a.jsx("textarea",{ref:r,value:o,onChange:C=>l(C.target.value),rows:4,className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded text-white focus:outline-none focus:ring-1 focus:ring-bambu-green font-mono text-sm resize-none",placeholder:"Notification body..."})]}),p&&a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm font-medium text-bambu-gray mb-2",children:"Available Variables"}),a.jsx("div",{className:"flex flex-wrap gap-2",children:p.variables.map(C=>a.jsxs("button",{type:"button",onClick:()=>N(C),className:"inline-flex items-center gap-1 px-2 py-1 bg-bambu-dark hover:bg-bambu-dark-tertiary border border-bambu-dark-tertiary rounded text-xs text-bambu-gray hover:text-white transition-colors",children:[a.jsx(ar,{className:"w-3 h-3"}),C]},C))}),a.jsx("p",{className:"text-xs text-bambu-gray/60 mt-1",children:"Click to insert at cursor position in body"})]}),a.jsxs("div",{children:[a.jsxs("div",{className:"flex items-center justify-between mb-2",children:[a.jsxs("label",{className:"text-sm font-medium text-bambu-gray flex items-center gap-2",children:[a.jsx(Xl,{className:"w-4 h-4"}),"Live Preview"]}),a.jsx("button",{type:"button",onClick:()=>h(!d),className:"text-xs text-bambu-green hover:text-bambu-green-light",children:d?"Hide":"Show"})]}),d&&a.jsx("div",{className:"bg-bambu-dark border border-bambu-dark-tertiary rounded p-3 space-y-2",children:y?a.jsxs("div",{className:"flex items-center gap-2 text-bambu-gray text-sm",children:[a.jsx(it,{className:"w-4 h-4 animate-spin"}),"Loading preview..."]}):x?a.jsxs(a.Fragment,{children:[a.jsxs("div",{children:[a.jsx("span",{className:"text-xs text-bambu-gray",children:"Title:"}),a.jsx("div",{className:"text-white font-medium",children:x.title})]}),a.jsxs("div",{children:[a.jsx("span",{className:"text-xs text-bambu-gray",children:"Body:"}),a.jsx("div",{className:"text-white whitespace-pre-wrap text-sm",children:x.body})]})]}):a.jsx("div",{className:"text-bambu-gray text-sm",children:"Enter template content to see preview"})})]})]}),a.jsxs("div",{className:"flex items-center justify-between p-4 border-t border-bambu-dark-tertiary shrink-0",children:[a.jsxs(Ce,{type:"button",variant:"ghost",onClick:()=>v.mutate(),disabled:v.isPending,className:"text-orange-400 hover:text-orange-300",children:[v.isPending?a.jsx(it,{className:"w-4 h-4 animate-spin mr-2"}):a.jsx(Ro,{className:"w-4 h-4 mr-2"}),"Reset to Default"]}),a.jsxs("div",{className:"flex gap-2",children:[a.jsx(Ce,{type:"button",variant:"secondary",onClick:e,children:"Cancel"}),a.jsxs(Ce,{onClick:S,disabled:b.isPending||!A,children:[b.isPending?a.jsx(it,{className:"w-4 h-4 animate-spin mr-2"}):a.jsx(bs,{className:"w-4 h-4 mr-2"}),"Save"]})]})]})]})})}const YQe={print_start:"Print Started",print_complete:"Print Complete",print_failed:"Print Failed",print_stopped:"Print Stopped",print_progress:"Progress",printer_offline:"Printer Offline",printer_error:"Printer Error",filament_low:"Low Filament",maintenance_due:"Maintenance Due",test:"Test"},QQe={print_start:"text-blue-400",print_complete:"text-bambu-green",print_failed:"text-red-400",print_stopped:"text-orange-400",print_progress:"text-yellow-400",printer_offline:"text-gray-400",printer_error:"text-rose-400",filament_low:"text-cyan-400",maintenance_due:"text-purple-400",test:"text-bambu-gray"};function ZQe({onClose:t}){const e=tn(),{showToast:n}=hn(),[r,i]=w.useState(7),[s,o]=w.useState(null),[l,c]=w.useState(!1),{data:u}=Ze({queryKey:["settings"],queryFn:re.getSettings}),d=u?.time_format||"system",{data:h,isLoading:f,refetch:p,isRefetching:x}=Ze({queryKey:["notification-logs",r,l],queryFn:()=>re.getNotificationLogs({days:r,limit:100,success:l?!1:void 0})}),{data:y}=Ze({queryKey:["notification-log-stats",r],queryFn:()=>re.getNotificationLogStats(r)}),b=ot({mutationFn:()=>re.clearNotificationLogs(30),onSuccess:S=>{n(S.message,"success"),e.invalidateQueries({queryKey:["notification-logs"]}),e.invalidateQueries({queryKey:["notification-log-stats"]})},onError:S=>{n(`Failed to clear logs: ${S.message}`,"error")}}),v=S=>{const N=Zi(S);if(!N)return"";const C=new Date().getTime()-N.getTime();return C<6e4?"Just now":C<36e5?`${Math.floor(C/6e4)}m ago`:C<864e5?`${Math.floor(C/36e5)}h ago`:N.toLocaleDateString()+" "+sge(N,d)};return a.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4",children:a.jsxs("div",{className:"bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg w-full max-w-3xl max-h-[85vh] flex flex-col",children:[a.jsxs("div",{className:"p-4 border-b border-bambu-dark-tertiary flex items-center justify-between",children:[a.jsxs("div",{className:"flex items-center gap-3",children:[a.jsx(N0,{className:"w-5 h-5 text-bambu-green"}),a.jsx("h2",{className:"text-lg font-semibold text-white",children:"Notification Log"})]}),a.jsx("button",{onClick:t,className:"text-bambu-gray hover:text-white transition-colors",children:"×"})]}),y&&a.jsx("div",{className:"px-4 py-3 border-b border-bambu-dark-tertiary bg-bambu-dark/50",children:a.jsxs("div",{className:"flex items-center gap-6 text-sm",children:[a.jsxs("span",{className:"text-bambu-gray",children:["Last ",r," days: ",a.jsx("span",{className:"text-white font-medium",children:y.total})," notifications"]}),a.jsxs("span",{className:"flex items-center gap-1 text-bambu-green",children:[a.jsx(gr,{className:"w-4 h-4"}),y.success_count," sent"]}),y.failure_count>0&&a.jsxs("span",{className:"flex items-center gap-1 text-red-400",children:[a.jsx(ha,{className:"w-4 h-4"}),y.failure_count," failed"]})]})}),a.jsxs("div",{className:"px-4 py-3 border-b border-bambu-dark-tertiary flex items-center gap-4",children:[a.jsxs("select",{value:r,onChange:S=>i(Number(S.target.value)),className:"px-3 py-1.5 bg-bambu-dark border border-bambu-dark-tertiary rounded text-white text-sm focus:outline-none focus:ring-1 focus:ring-bambu-green",children:[a.jsx("option",{value:1,children:"Last 24 hours"}),a.jsx("option",{value:7,children:"Last 7 days"}),a.jsx("option",{value:30,children:"Last 30 days"}),a.jsx("option",{value:90,children:"Last 90 days"})]}),a.jsxs("label",{className:"flex items-center gap-2 text-sm text-bambu-gray cursor-pointer",children:[a.jsx("input",{type:"checkbox",checked:l,onChange:S=>c(S.target.checked),className:"rounded border-bambu-dark-tertiary bg-bambu-dark text-bambu-green focus:ring-bambu-green"}),"Show failed only"]}),a.jsx("div",{className:"flex-1"}),a.jsxs(Ce,{size:"sm",variant:"secondary",onClick:()=>p(),disabled:x,children:[x?a.jsx(it,{className:"w-4 h-4 animate-spin"}):a.jsx(kr,{className:"w-4 h-4"}),"Refresh"]}),a.jsxs(Ce,{size:"sm",variant:"secondary",onClick:()=>b.mutate(),disabled:b.isPending,className:"text-red-400 hover:text-red-300",children:[b.isPending?a.jsx(it,{className:"w-4 h-4 animate-spin"}):a.jsx(Jt,{className:"w-4 h-4"}),"Clear Old"]})]}),a.jsx("div",{className:"flex-1 overflow-y-auto p-4",children:f?a.jsx("div",{className:"flex justify-center py-12",children:a.jsx(it,{className:"w-6 h-6 text-bambu-green animate-spin"})}):h&&h.length>0?a.jsx("div",{className:"space-y-2",children:h.map(S=>a.jsx(JQe,{log:S,isExpanded:s===S.id,onToggle:()=>o(s===S.id?null:S.id),formatDate:v,formatFullDate:N=>Lf(N,d)},S.id))}):a.jsxs("div",{className:"text-center py-12 text-bambu-gray",children:[a.jsx(N0,{className:"w-12 h-12 mx-auto mb-3 opacity-30"}),a.jsx("p",{className:"text-sm",children:l?"No failed notifications":"No notifications logged"})]})})]})})}function JQe({log:t,isExpanded:e,onToggle:n,formatDate:r,formatFullDate:i}){return a.jsxs("div",{className:`border rounded-lg overflow-hidden transition-colors ${t.success?"border-bambu-dark-tertiary bg-bambu-dark/30":"border-red-500/30 bg-red-500/5"}`,children:[a.jsxs("button",{className:"w-full px-3 py-2 flex items-center gap-3 text-left hover:bg-bambu-dark/50 transition-colors",onClick:n,children:[t.success?a.jsx(gr,{className:"w-4 h-4 text-bambu-green shrink-0"}):a.jsx(ha,{className:"w-4 h-4 text-red-400 shrink-0"}),a.jsx("span",{className:`text-xs font-medium ${QQe[t.event_type]||"text-bambu-gray"}`,children:YQe[t.event_type]||t.event_type}),a.jsx("span",{className:"text-sm text-white truncate flex-1",children:t.provider_name||"Unknown Provider"}),t.printer_name&&a.jsx("span",{className:"text-xs text-bambu-gray",children:t.printer_name}),a.jsx("span",{className:"text-xs text-bambu-gray shrink-0",children:r(t.created_at)}),e?a.jsx(Wl,{className:"w-4 h-4 text-bambu-gray shrink-0"}):a.jsx(nr,{className:"w-4 h-4 text-bambu-gray shrink-0"})]}),e&&a.jsxs("div",{className:"px-3 py-2 border-t border-bambu-dark-tertiary bg-bambu-dark/20 space-y-2",children:[a.jsxs("div",{children:[a.jsx("p",{className:"text-xs text-bambu-gray mb-1",children:"Title"}),a.jsx("p",{className:"text-sm text-white",children:t.title})]}),a.jsxs("div",{children:[a.jsx("p",{className:"text-xs text-bambu-gray mb-1",children:"Message"}),a.jsx("p",{className:"text-sm text-white whitespace-pre-wrap",children:t.message})]}),!t.success&&t.error_message&&a.jsxs("div",{children:[a.jsx("p",{className:"text-xs text-red-400 mb-1",children:"Error"}),a.jsx("p",{className:"text-sm text-red-300",children:t.error_message})]}),a.jsxs("div",{className:"flex gap-4 text-xs text-bambu-gray pt-1",children:[a.jsxs("span",{children:["Provider: ",t.provider_type]}),a.jsxs("span",{children:["Time: ",i(t.created_at)]})]})]})]})}function eZe({formData:t,setFormData:e,groups:n,onClose:r,onCreate:i,isCreating:s,isCreateButtonDisabled:o}){const{t:l}=Vt();w.useEffect(()=>{const u=d=>{d.key==="Escape"&&r()};return window.addEventListener("keydown",u),()=>window.removeEventListener("keydown",u)},[r]);const c=u=>{e({...t,group_ids:t.group_ids.includes(u)?t.group_ids.filter(d=>d!==u):[...t.group_ids,u]})};return a.jsx("div",{className:"fixed inset-0 bg-black/70 flex items-center justify-center z-50 p-4",onClick:r,children:a.jsxs(vt,{className:"w-full max-w-md",onClick:u=>u.stopPropagation(),children:[a.jsx(An,{children:a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsxs("div",{className:"flex flex-col gap-1",children:[a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx(gh,{className:"w-5 h-5 text-bambu-green"}),a.jsx("h2",{className:"text-lg font-semibold text-white",children:l("users.modal.createUser")})]}),a.jsx("p",{className:"text-sm text-bambu-gray ml-7",children:l("users.modal.advancedAuthSubtitle")||"with Advanced Authentication"})]}),a.jsx(Ce,{variant:"ghost",size:"sm",onClick:r,children:a.jsx(Ft,{className:"w-5 h-5"})})]})}),a.jsxs(Nt,{children:[a.jsxs("div",{className:"space-y-4",children:[a.jsxs("div",{children:[a.jsxs("label",{className:"block text-sm font-medium text-white mb-2",children:[l("users.form.username")," ",a.jsx("span",{className:"text-red-400",children:"*"})]}),a.jsx("input",{type:"text",value:t.username,onChange:u=>e({...t,username:u.target.value}),className:"w-full px-4 py-3 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg text-white placeholder-bambu-gray focus:outline-none focus:ring-2 focus:ring-bambu-green/50 focus:border-bambu-green transition-colors",placeholder:l("users.form.usernamePlaceholder"),autoComplete:"username",required:!0})]}),a.jsxs("div",{children:[a.jsxs("label",{className:"block text-sm font-medium text-white mb-2",children:[l("users.form.email")||"Email"," ",a.jsx("span",{className:"text-red-400",children:"*"})]}),a.jsx("input",{type:"email",value:t.email,onChange:u=>e({...t,email:u.target.value}),className:"w-full px-4 py-3 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg text-white placeholder-bambu-gray focus:outline-none focus:ring-2 focus:ring-bambu-green/50 focus:border-bambu-green transition-colors",placeholder:l("users.form.emailPlaceholder")||"user@example.com",required:!0})]}),a.jsx("div",{className:"bg-bambu-dark-secondary/50 border border-bambu-green/20 rounded-lg p-3",children:a.jsx("p",{className:"text-sm text-bambu-gray",children:l("users.form.autoGeneratedPassword")||"A secure password will be automatically generated and emailed to the user."})}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm font-medium text-white mb-2",children:l("users.form.groups")}),a.jsxs("div",{className:"space-y-2 max-h-40 overflow-y-auto p-2 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg",children:[n.map(u=>a.jsxs("label",{className:"flex items-center gap-3 px-2 py-1.5 rounded hover:bg-bambu-dark-tertiary cursor-pointer",children:[a.jsx("input",{type:"checkbox",checked:t.group_ids.includes(u.id),onChange:()=>c(u.id),className:"w-4 h-4 rounded border-bambu-gray text-bambu-green focus:ring-bambu-green focus:ring-offset-0 bg-bambu-dark"}),a.jsx("span",{className:"text-sm text-white",children:u.name}),u.is_system&&a.jsxs("span",{className:"text-xs text-yellow-400",children:["(",l("users.system"),")"]})]},u.id)),n.length===0&&a.jsx("p",{className:"text-sm text-bambu-gray",children:l("users.noGroupsAvailable")})]})]})]}),a.jsxs("div",{className:"mt-6 flex justify-end gap-3",children:[a.jsx(Ce,{variant:"secondary",onClick:r,children:l("users.modal.cancel")}),a.jsx(Ce,{onClick:i,disabled:o,children:s?a.jsxs(a.Fragment,{children:[a.jsx(it,{className:"w-4 h-4 animate-spin"}),l("users.modal.creating")]}):a.jsxs(a.Fragment,{children:[a.jsx(ar,{className:"w-4 h-4"}),l("users.modal.createUser")]})})]})]})]})})}function tZe(){const{t}=Vt(),e=tn(),{showToast:n}=hn(),[r,i]=w.useState(!1),[s,o]=w.useState(""),[l,c]=w.useState("auto"),[u,d]=w.useState(!1),[h,f]=w.useState(!0),[p,x]=w.useState("all"),[y,b]=w.useState(!1),[v,S]=w.useState(!1),[N,A]=w.useState(!1),{data:C,isLoading:T}=Ze({queryKey:["spoolman-settings"],queryFn:re.getSpoolmanSettings}),{data:k,isLoading:j,refetch:E}=Ze({queryKey:["spoolman-status"],queryFn:re.getSpoolmanStatus,refetchInterval:3e4}),{data:P}=Ze({queryKey:["printers"],queryFn:re.getPrinters});w.useEffect(()=>{C&&(i(C.spoolman_enabled==="true"),o(C.spoolman_url||""),c(C.spoolman_sync_mode||"auto"),d(C.spoolman_disable_weight_sync==="true"),f(C.spoolman_report_partial_usage!=="false"),b(!0))},[C]),w.useEffect(()=>{if(!y||!C)return;if(C.spoolman_enabled==="true"!==r||(C.spoolman_url||"")!==s||(C.spoolman_sync_mode||"auto")!==l||C.spoolman_disable_weight_sync==="true"!==u||C.spoolman_report_partial_usage!=="false"!==h){const X=setTimeout(()=>{U.mutate()},500);return()=>clearTimeout(X)}},[r,s,l,u,h,y]);const U=ot({mutationFn:()=>re.updateSpoolmanSettings({spoolman_enabled:r?"true":"false",spoolman_url:s,spoolman_sync_mode:l,spoolman_disable_weight_sync:u?"true":"false",spoolman_report_partial_usage:h?"true":"false"}),onSuccess:()=>{e.invalidateQueries({queryKey:["spoolman-settings"]}),e.invalidateQueries({queryKey:["spoolman-status"]}),e.invalidateQueries({queryKey:["spool-assignments"]}),n(t("settings.toast.settingsSaved"))}}),O=ot({mutationFn:re.connectSpoolman,onSuccess:()=>{E()}}),B=ot({mutationFn:re.disconnectSpoolman,onSuccess:()=>{E()}}),R=ot({mutationFn:re.syncAllPrintersAms,onSuccess:$=>{$.success}}),G=ot({mutationFn:$=>re.syncPrinterAms($),onSuccess:$=>{$.success}}),q=()=>{p==="all"?R.mutate():G.mutate(p)},z=ot({mutationFn:re.syncWeightsFromAms,onSuccess:$=>{e.invalidateQueries({queryKey:["spools"]}),e.invalidateQueries({queryKey:["inventory-spools"]}),n(t("settings.amsSyncSuccess",{synced:$.synced,skipped:$.skipped}),"success"),A(!1)},onError:()=>{n(t("settings.amsSyncError"),"error"),A(!1)}}),K=R.isPending||G.isPending,Y=p==="all"?R.data:G.data,oe=p==="all"?R.isSuccess:G.isSuccess;return T?a.jsxs(vt,{children:[a.jsx(An,{children:a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx(Tc,{className:"w-5 h-5 text-bambu-green"}),a.jsx("h2",{className:"text-lg font-semibold text-white",children:t("settings.filamentTracking")})]})}),a.jsx(Nt,{children:a.jsx("div",{className:"flex justify-center py-8",children:a.jsx(it,{className:"w-6 h-6 text-bambu-green animate-spin"})})})]}):a.jsxs(vt,{children:[a.jsx(An,{children:a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx(Tc,{className:"w-5 h-5 text-bambu-green"}),a.jsx("h2",{className:"text-lg font-semibold text-white",children:t("settings.filamentTracking")})]}),U.isPending&&a.jsx(it,{className:"w-4 h-4 text-bambu-green animate-spin"})]})}),a.jsxs(Nt,{className:"space-y-4",children:[a.jsx("p",{className:"text-sm text-bambu-gray",children:t("settings.filamentTrackingDesc")}),a.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[a.jsxs("button",{type:"button",onClick:()=>i(!1),className:`p-3 rounded-lg border-2 text-left transition-colors ${r?"border-bambu-dark-tertiary bg-bambu-dark hover:border-bambu-gray/50":"border-bambu-green bg-bambu-green/10"}`,children:[a.jsxs("div",{className:"flex items-center gap-2 mb-1.5",children:[a.jsx(fa,{className:`w-4 h-4 ${r?"text-bambu-gray":"text-bambu-green"}`}),a.jsx("span",{className:`text-sm font-medium ${r?"text-bambu-gray":"text-white"}`,children:t("settings.trackingModeBuiltIn")})]}),a.jsx("p",{className:`text-xs ${r?"text-bambu-gray/60":"text-bambu-gray"}`,children:t("settings.trackingModeBuiltInDesc")}),!r&&a.jsxs("div",{className:"flex items-center gap-1 mt-2",children:[a.jsx(Xr,{className:"w-3 h-3 text-bambu-green"}),a.jsx("span",{className:"text-xs text-bambu-green",children:t("common.enabled")})]})]}),a.jsxs("button",{type:"button",onClick:()=>i(!0),className:`p-3 rounded-lg border-2 text-left transition-colors ${r?"border-bambu-green bg-bambu-green/10":"border-bambu-dark-tertiary bg-bambu-dark hover:border-bambu-gray/50"}`,children:[a.jsxs("div",{className:"flex items-center gap-2 mb-1.5",children:[a.jsx(Kr,{className:`w-4 h-4 ${r?"text-bambu-green":"text-bambu-gray"}`}),a.jsx("span",{className:`text-sm font-medium ${r?"text-white":"text-bambu-gray"}`,children:"Spoolman"})]}),a.jsx("p",{className:`text-xs ${r?"text-bambu-gray":"text-bambu-gray/60"}`,children:t("settings.trackingModeSpoolmanDesc")}),r&&a.jsxs("div",{className:"flex items-center gap-1 mt-2",children:[a.jsx(Xr,{className:"w-3 h-3 text-bambu-green"}),a.jsx("span",{className:"text-xs text-bambu-green",children:t("common.enabled")})]})]})]}),!r&&a.jsxs("div",{className:"space-y-3",children:[a.jsx("div",{className:"p-3 bg-bambu-green/5 border border-bambu-green/20 rounded-lg",children:a.jsxs("div",{className:"flex gap-2",children:[a.jsx(Js,{className:"w-4 h-4 text-bambu-green flex-shrink-0 mt-0.5"}),a.jsx("div",{className:"text-xs text-bambu-gray",children:a.jsxs("ul",{className:"list-disc list-inside space-y-0.5",children:[a.jsx("li",{children:t("settings.builtInFeatureRfid")}),a.jsx("li",{children:t("settings.builtInFeatureUsage")}),a.jsx("li",{children:t("settings.builtInFeatureCatalog")}),a.jsx("li",{children:t("settings.builtInFeatureThirdParty")})]})})]})}),a.jsxs(Ce,{variant:"secondary",size:"sm",onClick:()=>A(!0),disabled:z.isPending,children:[z.isPending?a.jsx(it,{className:"w-4 h-4 mr-2 animate-spin"}):a.jsx(kr,{className:"w-4 h-4 mr-2"}),t("settings.amsSyncButton")]})]}),r&&a.jsxs("div",{className:"space-y-4",children:[a.jsx("div",{className:"p-3 bg-blue-500/10 border border-blue-500/30 rounded-lg",children:a.jsxs("div",{className:"flex gap-2",children:[a.jsx(Js,{className:"w-4 h-4 text-blue-400 flex-shrink-0 mt-0.5"}),a.jsxs("div",{className:"text-xs text-blue-300",children:[a.jsx("p",{className:"font-medium mb-1",children:t("settings.howSyncWorks")}),a.jsxs("ul",{className:"list-disc list-inside space-y-0.5 text-blue-300/80",children:[a.jsx("li",{children:t("settings.syncInfoRfidOnly")}),a.jsx("li",{children:t("settings.syncInfoAutoCreate")}),a.jsx("li",{children:t("settings.syncInfoThirdPartySkipped")})]}),a.jsx("p",{className:"font-medium mt-2 mb-1",children:t("settings.linkingExistingSpools")}),a.jsx("p",{className:"text-blue-300/80",children:t("settings.linkingExistingSpoolsDesc")})]})]})}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:t("settings.spoolmanUrl")}),a.jsx("input",{type:"text",placeholder:"http://192.168.1.100:7912",value:s,onChange:$=>o($.target.value),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white placeholder-bambu-gray/50 focus:border-bambu-green focus:outline-none"}),a.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:t("settings.spoolmanUrlHint")})]}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:t("settings.syncMode")}),a.jsxs("select",{value:l,onChange:$=>c($.target.value),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",children:[a.jsx("option",{value:"auto",children:t("settings.syncModeAuto")}),a.jsx("option",{value:"manual",children:t("settings.syncModeManual")})]}),a.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:t(l==="auto"?"settings.syncModeAutoDesc":"settings.syncModeManualDesc")})]}),l==="auto"&&a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsxs("div",{children:[a.jsx("p",{className:"text-white",children:t("spoolman.disableWeightSync")}),a.jsx("p",{className:"text-sm text-bambu-gray",children:t("spoolman.disableWeightSyncDesc")})]}),a.jsxs("label",{className:"relative inline-flex items-center cursor-pointer",children:[a.jsx("input",{type:"checkbox",checked:u,onChange:$=>d($.target.checked),className:"sr-only peer"}),a.jsx("div",{className:"w-11 h-6 bg-bambu-dark-tertiary peer-focus:outline-none rounded-full peer peer-checked:after:translate-x-full peer-checked:after:border-white after:content-[''] after:absolute after:top-[2px] after:left-[2px] after:bg-white after:rounded-full after:h-5 after:w-5 after:transition-all peer-checked:bg-bambu-green"})]})]}),u&&a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsxs("div",{children:[a.jsx("p",{className:"text-white",children:t("spoolman.reportPartialUsage")}),a.jsx("p",{className:"text-sm text-bambu-gray",children:t("spoolman.reportPartialUsageDesc")})]}),a.jsxs("label",{className:"relative inline-flex items-center cursor-pointer",children:[a.jsx("input",{type:"checkbox",checked:h,onChange:$=>f($.target.checked),className:"sr-only peer"}),a.jsx("div",{className:"w-11 h-6 bg-bambu-dark-tertiary peer-focus:outline-none rounded-full peer peer-checked:after:translate-x-full peer-checked:after:border-white after:content-[''] after:absolute after:top-[2px] after:left-[2px] after:bg-white after:rounded-full after:h-5 after:w-5 after:transition-all peer-checked:bg-bambu-green"})]})]}),a.jsxs("div",{className:"pt-2 border-t border-bambu-dark-tertiary",children:[a.jsxs("div",{className:"flex items-center justify-between mb-3",children:[a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsxs("span",{className:"text-sm text-bambu-gray",children:[t("settings.status"),":"]}),j?a.jsx(it,{className:"w-4 h-4 text-bambu-gray animate-spin"}):k?.connected?a.jsxs("span",{className:"flex items-center gap-1 text-sm text-green-500",children:[a.jsx(Xr,{className:"w-4 h-4"}),t("settings.spoolmanConnected")]}):a.jsxs("span",{className:"flex items-center gap-1 text-sm text-red-500",children:[a.jsx(Ft,{className:"w-4 h-4"}),t("settings.spoolmanDisconnected")]})]}),a.jsx("div",{className:"flex gap-2",children:k?.connected?a.jsxs(Ce,{variant:"secondary",size:"sm",onClick:()=>B.mutate(),disabled:B.isPending,children:[B.isPending?a.jsx(it,{className:"w-4 h-4 animate-spin"}):a.jsx(Rme,{className:"w-4 h-4"}),t("settings.disconnect")]}):a.jsxs(Ce,{size:"sm",onClick:()=>O.mutate(),disabled:O.isPending||!s,children:[O.isPending?a.jsx(it,{className:"w-4 h-4 animate-spin"}):a.jsx(Rh,{className:"w-4 h-4"}),t("settings.connect")]})})]}),O.isError&&a.jsx("div",{className:"mb-3 p-2 bg-red-500/20 border border-red-500/50 rounded text-sm text-red-400",children:O.error.message}),k?.connected&&a.jsxs("div",{className:"space-y-3",children:[a.jsxs("div",{children:[a.jsx("p",{className:"text-sm text-white",children:t("settings.syncAmsData")}),a.jsx("p",{className:"text-xs text-bambu-gray",children:t("settings.syncAmsDataDesc")})]}),a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsxs("div",{className:"relative flex-1",children:[a.jsxs("select",{value:p,onChange:$=>x($.target.value==="all"?"all":Number($.target.value)),className:"w-full px-3 py-2 pr-8 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white text-sm focus:border-bambu-green focus:outline-none appearance-none cursor-pointer",children:[a.jsx("option",{value:"all",children:t("settings.allPrinters")}),P?.map($=>a.jsx("option",{value:$.id,children:$.name},$.id))]}),a.jsx(nr,{className:"absolute right-2 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray pointer-events-none"})]}),a.jsxs(Ce,{variant:"secondary",size:"sm",onClick:q,disabled:K,children:[K?a.jsx(it,{className:"w-4 h-4 animate-spin"}):a.jsx(kr,{className:"w-4 h-4"}),t("spoolman.sync")]})]})]}),oe&&Y&&a.jsxs("div",{className:"mt-3 space-y-2",children:[a.jsx("div",{className:`p-2 rounded text-sm ${Y.success?"bg-green-500/20 border border-green-500/50 text-green-400":"bg-yellow-500/20 border border-yellow-500/50 text-yellow-400"}`,children:Y.success?`Synced ${Y.synced_count} spool${Y.synced_count!==1?"s":""} successfully`:`Synced ${Y.synced_count} spool${Y.synced_count!==1?"s":""} with ${Y.errors.length} error${Y.errors.length!==1?"s":""}`}),Y.skipped_count>0&&a.jsxs("div",{className:"p-2 bg-amber-500/10 border border-amber-500/30 rounded text-sm",children:[a.jsxs("div",{className:"flex items-center justify-between text-amber-400 mb-1",children:[a.jsxs("div",{className:"flex items-center gap-1.5",children:[a.jsx(Cn,{className:"w-3.5 h-3.5"}),a.jsxs("span",{className:"font-medium",children:[Y.skipped_count," spool",Y.skipped_count!==1?"s":""," skipped"]})]}),Y.skipped_count>5&&a.jsx("button",{onClick:()=>S(!v),className:"text-xs text-amber-400 hover:text-amber-300 underline",children:v?"Show less":"Show all"})]}),a.jsxs("ul",{className:"text-xs text-amber-300/80 space-y-0.5",children:[(v?Y.skipped:Y.skipped.slice(0,5)).map(($,X)=>a.jsxs("li",{className:"flex items-center gap-2",children:[$.color&&a.jsx("span",{className:"w-3 h-3 rounded-full border border-white/20",style:{backgroundColor:`#${$.color}`}}),a.jsx("span",{children:$.location}),a.jsxs("span",{className:"text-amber-300/60",children:["- ",$.reason]})]},X)),!v&&Y.skipped_count>5&&a.jsxs("li",{className:"text-amber-300/60 italic",children:["...and ",Y.skipped_count-5," more"]})]})]}),Y.errors.length>0&&a.jsxs("div",{className:"p-2 bg-red-500/10 border border-red-500/30 rounded text-sm",children:[a.jsx("div",{className:"text-red-400 font-medium mb-1",children:"Errors:"}),a.jsx("ul",{className:"text-xs text-red-300/80 space-y-0.5",children:Y.errors.map(($,X)=>a.jsx("li",{children:$},X))})]})]})]})]})]}),N&&a.jsx(vn,{title:t("settings.amsSyncTitle"),message:t("settings.amsSyncMessage"),confirmText:t("settings.amsSyncButton"),variant:"warning",isLoading:z.isPending,loadingText:t("settings.amsSyncing"),onConfirm:()=>z.mutate(),onCancel:()=>A(!1)})]})}function nZe(){const{t}=Vt(),{showToast:e}=hn(),[n,r]=w.useState([]),[i,s]=w.useState(!0),[o,l]=w.useState(""),c=w.useRef(null),[u,d]=w.useState(!1),[h,f]=w.useState(null),[p,x]=w.useState(""),[y,b]=w.useState(""),[v,S]=w.useState(!1),[N,A]=w.useState(null),[C,T]=w.useState(!1),k=w.useCallback(async()=>{try{const z=await re.getSpoolCatalog();r(z)}catch{e(t("settings.catalog.loadFailed"),"error")}finally{s(!1)}},[e,t]);w.useEffect(()=>{k()},[k]);const j=n.filter(z=>z.name.toLowerCase().includes(o.toLowerCase())),E=async()=>{if(!p.trim()||!y){e(t("settings.catalog.nameWeightRequired"),"error");return}S(!0);try{const z=await re.addCatalogEntry({name:p.trim(),weight:parseInt(y)});r(K=>[...K,z].sort((Y,oe)=>Y.name.localeCompare(oe.name))),d(!1),x(""),b(""),e(t("settings.catalog.entryAdded"),"success")}catch{e(t("settings.catalog.addFailed"),"error")}finally{S(!1)}},P=z=>{f(z.id),x(z.name),b(z.weight.toString())},U=()=>{f(null),x(""),b("")},O=async z=>{if(!p.trim()||!y){e(t("settings.catalog.nameWeightRequired"),"error");return}S(!0);try{const K=await re.updateCatalogEntry(z,{name:p.trim(),weight:parseInt(y)});r(Y=>Y.map(oe=>oe.id===z?K:oe).sort((oe,$)=>oe.name.localeCompare($.name))),f(null),x(""),b(""),e(t("settings.catalog.entryUpdated"),"success")}catch{e(t("settings.catalog.updateFailed"),"error")}finally{S(!1)}},B=async()=>{if(N)try{await re.deleteCatalogEntry(N.id),r(z=>z.filter(K=>K.id!==N.id)),e(t("settings.catalog.entryDeleted"),"success")}catch{e(t("settings.catalog.deleteFailed"),"error")}finally{A(null)}},R=async()=>{T(!1),s(!0);try{await re.resetSpoolCatalog(),await k(),e(t("settings.catalog.resetSuccess"),"success")}catch{e(t("settings.catalog.resetFailed"),"error"),s(!1)}},G=()=>{const z=n.map(({name:$,weight:X})=>({name:$,weight:X})),K=new Blob([JSON.stringify(z,null,2)],{type:"application/json"}),Y=URL.createObjectURL(K),oe=document.createElement("a");oe.href=Y,oe.download="spool-catalog.json",document.body.appendChild(oe),oe.click(),document.body.removeChild(oe),URL.revokeObjectURL(Y),e(t("settings.catalog.exported",{count:n.length}),"success")},q=async z=>{const K=z.target.files?.[0];if(K){try{const Y=await K.text(),oe=JSON.parse(Y);if(!Array.isArray(oe))throw new Error("Invalid format");let $=0,X=0;for(const ee of oe){if(!ee.name||typeof ee.weight!="number"){X++;continue}if(n.some(_e=>_e.name.toLowerCase()===ee.name.toLowerCase())){X++;continue}try{const _e=await re.addCatalogEntry({name:ee.name,weight:ee.weight});r(pe=>[...pe,_e].sort((me,je)=>me.name.localeCompare(je.name))),$++}catch{X++}}e(t("settings.catalog.imported",{added:$,skipped:X}),"success")}catch{e(t("settings.catalog.importFailed"),"error")}c.current&&(c.current.value="")}};return a.jsxs(vt,{children:[a.jsxs(An,{children:[a.jsxs("div",{className:"flex items-center gap-2 mb-3",children:[a.jsx(Tc,{className:"w-5 h-5 text-bambu-gray"}),a.jsx("h2",{className:"text-lg font-semibold text-white",children:t("settings.catalog.spoolCatalog")}),a.jsxs("span",{className:"text-sm text-bambu-gray",children:["(",n.length,")"]})]}),a.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[a.jsxs("button",{onClick:G,className:"px-3 py-1.5 text-sm bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-bambu-gray hover:text-white transition-colors flex items-center gap-1.5",title:t("settings.catalog.exportTooltip"),children:[a.jsx(di,{className:"w-4 h-4"}),a.jsx("span",{className:"hidden sm:inline",children:t("common.export")})]}),a.jsxs("button",{onClick:()=>c.current?.click(),className:"px-3 py-1.5 text-sm bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-bambu-gray hover:text-white transition-colors flex items-center gap-1.5",title:t("settings.catalog.importTooltip"),children:[a.jsx(Fi,{className:"w-4 h-4"}),a.jsx("span",{className:"hidden sm:inline",children:t("common.import")})]}),a.jsx("input",{ref:c,type:"file",accept:".json",className:"hidden",onChange:q}),a.jsxs("button",{onClick:()=>T(!0),className:"px-3 py-1.5 text-sm bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-bambu-gray hover:text-white transition-colors flex items-center gap-1.5",title:t("settings.catalog.resetTooltip"),children:[a.jsx(Ro,{className:"w-4 h-4"}),a.jsx("span",{className:"hidden sm:inline",children:t("common.reset")})]}),a.jsxs("button",{onClick:()=>d(!0),className:"px-3 py-1.5 text-sm bg-bambu-green text-white rounded-lg hover:bg-bambu-green/80 transition-colors flex items-center gap-1.5",children:[a.jsx(ar,{className:"w-4 h-4"}),a.jsx("span",{className:"hidden sm:inline",children:t("common.add")})]})]})]}),a.jsxs(Nt,{className:"space-y-4",children:[a.jsx("p",{className:"text-sm text-bambu-gray",children:t("settings.catalog.spoolCatalogDescription")}),a.jsxs("div",{className:"relative",children:[a.jsx(Or,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray"}),a.jsx("input",{type:"text",className:"w-full pl-10 pr-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white placeholder-bambu-gray focus:border-bambu-green focus:outline-none",placeholder:t("settings.catalog.searchCatalog"),value:o,onChange:z=>l(z.target.value)})]}),u&&a.jsxs("div",{className:"p-4 bg-bambu-dark rounded-lg border border-bambu-dark-tertiary",children:[a.jsx("h3",{className:"text-sm font-medium text-white mb-3",children:t("settings.catalog.addNewEntry")}),a.jsxs("div",{className:"flex gap-2 items-center",children:[a.jsx("div",{className:"flex-1 min-w-0",children:a.jsx("input",{type:"text",className:"w-full px-3 py-2 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg text-white placeholder-bambu-gray focus:border-bambu-green focus:outline-none",placeholder:t("settings.catalog.namePlaceholder"),value:p,onChange:z=>x(z.target.value)})}),a.jsx("input",{type:"number",className:"w-20 px-3 py-2 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg text-white text-center focus:border-bambu-green focus:outline-none",placeholder:"g",value:y,onChange:z=>b(z.target.value)}),a.jsx("span",{className:"text-bambu-gray shrink-0",children:"g"}),a.jsxs("button",{onClick:E,disabled:v,className:"px-3 py-2 bg-bambu-green text-white rounded-lg hover:bg-bambu-green/80 flex items-center gap-1 shrink-0",children:[v?a.jsx(it,{className:"w-4 h-4 animate-spin"}):a.jsx(Xr,{className:"w-4 h-4"}),t("common.add")]}),a.jsx("button",{onClick:()=>{d(!1),x(""),b("")},className:"p-2 rounded-lg text-bambu-gray hover:text-white hover:bg-bambu-dark-tertiary",children:a.jsx(Ft,{className:"w-4 h-4"})})]})]}),i?a.jsxs("div",{className:"flex items-center justify-center py-8 text-bambu-gray",children:[a.jsx(it,{className:"w-5 h-5 animate-spin mr-2"}),t("common.loading")]}):a.jsx("div",{className:"max-h-[600px] overflow-y-auto border border-bambu-dark-tertiary rounded-lg",children:a.jsxs("table",{className:"w-full text-sm",children:[a.jsx("thead",{className:"bg-bambu-dark sticky top-0",children:a.jsxs("tr",{children:[a.jsx("th",{className:"px-4 py-2 text-left text-bambu-gray font-medium",children:t("common.name")}),a.jsx("th",{className:"px-4 py-2 text-right text-bambu-gray font-medium w-24",children:t("settings.catalog.weight")}),a.jsx("th",{className:"px-4 py-2 text-center text-bambu-gray font-medium w-20",children:t("settings.catalog.type")}),a.jsx("th",{className:"px-4 py-2 w-24"})]})}),a.jsx("tbody",{children:j.length===0?a.jsx("tr",{children:a.jsx("td",{colSpan:4,className:"px-4 py-8 text-center text-bambu-gray",children:t(o?"settings.catalog.noMatch":"settings.catalog.empty")})}):j.map(z=>a.jsx("tr",{className:"border-t border-bambu-dark-tertiary hover:bg-bambu-dark",children:h===z.id?a.jsxs(a.Fragment,{children:[a.jsx("td",{className:"px-4 py-2",children:a.jsx("input",{type:"text",className:"w-full px-2 py-1 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded text-white focus:border-bambu-green focus:outline-none",value:p,onChange:K=>x(K.target.value)})}),a.jsx("td",{className:"px-4 py-2",children:a.jsx("input",{type:"number",className:"w-full px-2 py-1 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded text-white text-right focus:border-bambu-green focus:outline-none",value:y,onChange:K=>b(K.target.value)})}),a.jsx("td",{className:"px-4 py-2 text-center",children:a.jsx("span",{className:"text-xs text-bambu-gray",children:"-"})}),a.jsx("td",{className:"px-4 py-2",children:a.jsxs("div",{className:"flex justify-end gap-1",children:[a.jsx("button",{onClick:()=>O(z.id),disabled:v,className:"p-1.5 rounded hover:bg-green-500/20 text-green-500",children:v?a.jsx(it,{className:"w-4 h-4 animate-spin"}):a.jsx(Xr,{className:"w-4 h-4"})}),a.jsx("button",{onClick:U,className:"p-1.5 rounded hover:bg-bambu-dark-tertiary text-bambu-gray",children:a.jsx(Ft,{className:"w-4 h-4"})})]})})]}):a.jsxs(a.Fragment,{children:[a.jsx("td",{className:"px-4 py-2 text-white",children:z.name}),a.jsxs("td",{className:"px-4 py-2 text-right font-mono text-white",children:[z.weight,"g"]}),a.jsx("td",{className:"px-4 py-2 text-center",children:z.is_default?a.jsx("span",{className:"text-xs px-2 py-0.5 rounded bg-bambu-dark-tertiary text-bambu-gray",children:t("settings.catalog.default")}):a.jsx("span",{className:"text-xs px-2 py-0.5 rounded bg-bambu-green/20 text-bambu-green",children:t("settings.catalog.custom")})}),a.jsx("td",{className:"px-4 py-2",children:a.jsxs("div",{className:"flex justify-end gap-1",children:[a.jsx("button",{onClick:()=>P(z),className:"p-1.5 rounded hover:bg-bambu-dark-tertiary text-bambu-gray hover:text-white",children:a.jsx(Vi,{className:"w-4 h-4"})}),a.jsx("button",{onClick:()=>A(z),className:"p-1.5 rounded bg-red-500/10 hover:bg-red-500/20 text-red-500",children:a.jsx(Jt,{className:"w-4 h-4"})})]})})]})},z.id))})]})})]}),N&&a.jsx(vn,{title:t("settings.catalog.deleteEntry"),message:t("settings.catalog.deleteConfirm",{name:N.name}),confirmText:t("common.delete"),variant:"danger",onConfirm:B,onCancel:()=>A(null)}),C&&a.jsx(vn,{title:t("settings.catalog.resetCatalog"),message:t("settings.catalog.resetConfirm"),confirmText:t("common.reset"),variant:"danger",onConfirm:R,onCancel:()=>T(!1)})]})}function rZe(){const{t}=Vt(),{showToast:e}=hn(),[n,r]=w.useState([]),[i,s]=w.useState(!0),[o,l]=w.useState(""),[c,u]=w.useState("Bambu Lab"),d=w.useRef(null),[h,f]=w.useState(!1),[p,x]=w.useState(null),[y,b]=w.useState(""),[v,S]=w.useState(""),[N,A]=w.useState("#FFFFFF"),[C,T]=w.useState(""),[k,j]=w.useState(!1),[E,P]=w.useState(!1),[U,O]=w.useState(null),[B,R]=w.useState(null),[G,q]=w.useState(!1),z=w.useCallback(async()=>{try{const ce=await re.getColorCatalog();r(ce)}catch{e(t("settings.colorCatalog.loadFailed"),"error")}finally{s(!1)}},[e,t]);w.useEffect(()=>{z()},[z]);const K=[...new Set(n.map(ce=>ce.manufacturer))].sort(),Y=n.filter(ce=>{const Se=o===""||ce.manufacturer.toLowerCase().includes(o.toLowerCase())||ce.color_name.toLowerCase().includes(o.toLowerCase())||(ce.material?.toLowerCase().includes(o.toLowerCase())??!1),ie=c===""||ce.manufacturer===c;return Se&&ie}),oe=()=>{b(""),S(""),A("#FFFFFF"),T("")},$=async()=>{if(!y.trim()||!v.trim()||!N){e(t("settings.colorCatalog.fieldsRequired"),"error");return}j(!0);try{const ce=await re.addColorEntry({manufacturer:y.trim(),color_name:v.trim(),hex_color:N,material:C.trim()||null});r(Se=>[...Se,ce].sort((ie,Fe)=>ie.manufacturer.localeCompare(Fe.manufacturer)||(ie.material||"").localeCompare(Fe.material||"")||ie.color_name.localeCompare(Fe.color_name))),f(!1),oe(),e(t("settings.colorCatalog.colorAdded"),"success")}catch{e(t("settings.colorCatalog.addFailed"),"error")}finally{j(!1)}},X=ce=>{x(ce.id),b(ce.manufacturer),S(ce.color_name),A(ce.hex_color),T(ce.material||"")},ee=()=>{x(null),oe()},J=async ce=>{if(!y.trim()||!v.trim()||!N){e(t("settings.colorCatalog.fieldsRequired"),"error");return}j(!0);try{const Se=await re.updateColorEntry(ce,{manufacturer:y.trim(),color_name:v.trim(),hex_color:N,material:C.trim()||null});r(ie=>ie.map(Fe=>Fe.id===ce?Se:Fe).sort((Fe,V)=>Fe.manufacturer.localeCompare(V.manufacturer)||(Fe.material||"").localeCompare(V.material||"")||Fe.color_name.localeCompare(V.color_name))),x(null),oe(),e(t("settings.colorCatalog.colorUpdated"),"success")}catch{e(t("settings.colorCatalog.updateFailed"),"error")}finally{j(!1)}},_e=async()=>{if(B)try{await re.deleteColorEntry(B.id),r(ce=>ce.filter(Se=>Se.id!==B.id)),e(t("settings.colorCatalog.colorDeleted"),"success")}catch{e(t("settings.colorCatalog.deleteFailed"),"error")}finally{R(null)}},pe=async()=>{q(!1),s(!0);try{await re.resetColorCatalog(),await z(),e(t("settings.colorCatalog.resetSuccess"),"success")}catch{e(t("settings.colorCatalog.resetFailed"),"error"),s(!1)}},me=async()=>{P(!0),O(null);try{const ce={},Se=id();Se&&(ce.Authorization=`Bearer ${Se}`);const ie=await fetch("/api/v1/inventory/colors/sync",{method:"POST",headers:ce});if(!ie.ok)throw new Error("Failed to start sync");const Fe=ie.body?.getReader();if(!Fe)throw new Error("No response body");const V=new TextDecoder;let W="";for(;;){const{done:ue,value:Q}=await Fe.read();if(ue)break;W+=V.decode(Q,{stream:!0});const se=W.split(` `);W=se.pop()||"";for(const Z of se)if(Z.startsWith("data: "))try{const Ne=JSON.parse(Z.slice(6));Ne.type==="progress"?O({fetched:Ne.total_fetched,total:Ne.total_available}):Ne.type==="complete"?Ne.added===0?e(t("settings.colorCatalog.syncUpToDate",{count:Ne.total_fetched}),"success"):e(t("settings.colorCatalog.syncComplete",{added:Ne.added,skipped:Ne.skipped}),"success"):Ne.type==="error"&&e(`${t("settings.colorCatalog.syncError")}: ${Ne.error}`,"error")}catch{}}await z()}catch{e(t("settings.colorCatalog.syncFailed"),"error")}finally{P(!1),O(null)}},je=()=>{const ce=n.map(({manufacturer:V,color_name:W,hex_color:ue,material:Q})=>({manufacturer:V,color_name:W,hex_color:ue,material:Q})),Se=new Blob([JSON.stringify(ce,null,2)],{type:"application/json"}),ie=URL.createObjectURL(Se),Fe=document.createElement("a");Fe.href=ie,Fe.download="color-catalog.json",document.body.appendChild(Fe),Fe.click(),document.body.removeChild(Fe),URL.revokeObjectURL(ie),e(t("settings.colorCatalog.exported",{count:n.length}),"success")},de=async ce=>{const Se=ce.target.files?.[0];if(Se){try{const ie=await Se.text(),Fe=JSON.parse(ie);if(!Array.isArray(Fe))throw new Error("Invalid format");let V=0,W=0;for(const ue of Fe){if(!ue.manufacturer||!ue.color_name||!ue.hex_color){W++;continue}if(n.some(se=>se.manufacturer.toLowerCase()===ue.manufacturer.toLowerCase()&&se.color_name.toLowerCase()===ue.color_name.toLowerCase()&&(se.material||"").toLowerCase()===(ue.material||"").toLowerCase())){W++;continue}try{const se=await re.addColorEntry({manufacturer:ue.manufacturer,color_name:ue.color_name,hex_color:ue.hex_color,material:ue.material||null});r(Z=>[...Z,se].sort((Ne,ve)=>Ne.manufacturer.localeCompare(ve.manufacturer)||(Ne.material||"").localeCompare(ve.material||"")||Ne.color_name.localeCompare(ve.color_name))),V++}catch{W++}}e(t("settings.colorCatalog.imported",{added:V,skipped:W}),"success")}catch{e(t("settings.colorCatalog.importFailed"),"error")}d.current&&(d.current.value="")}};return a.jsxs(vt,{children:[a.jsxs(An,{children:[a.jsxs("div",{className:"flex items-center gap-2 mb-3",children:[a.jsx(aC,{className:"w-5 h-5 text-bambu-gray"}),a.jsx("h2",{className:"text-lg font-semibold text-white",children:t("settings.colorCatalog.title")}),a.jsxs("span",{className:"text-sm text-bambu-gray",children:["(",n.length,")"]})]}),a.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[a.jsxs("button",{onClick:je,className:"px-3 py-1.5 text-sm bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-bambu-gray hover:text-white transition-colors flex items-center gap-1.5",children:[a.jsx(di,{className:"w-4 h-4"}),a.jsx("span",{className:"hidden sm:inline",children:t("common.export")})]}),a.jsxs("button",{onClick:()=>d.current?.click(),className:"px-3 py-1.5 text-sm bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-bambu-gray hover:text-white transition-colors flex items-center gap-1.5",children:[a.jsx(Fi,{className:"w-4 h-4"}),a.jsx("span",{className:"hidden sm:inline",children:t("common.import")})]}),a.jsx("input",{ref:d,type:"file",accept:".json",className:"hidden",onChange:de}),a.jsxs("button",{onClick:me,disabled:E,className:"px-3 py-1.5 text-sm bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-bambu-gray hover:text-white transition-colors flex items-center gap-1.5",title:t("settings.colorCatalog.syncTooltip"),children:[E?a.jsx(it,{className:"w-4 h-4 animate-spin"}):a.jsx(Gb,{className:"w-4 h-4"}),a.jsx("span",{className:"hidden sm:inline",children:E?U?`${Math.min(U.fetched,U.total)} / ${U.total}`:t("settings.colorCatalog.starting"):t("settings.colorCatalog.sync")})]}),a.jsxs("button",{onClick:()=>q(!0),className:"px-3 py-1.5 text-sm bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-bambu-gray hover:text-white transition-colors flex items-center gap-1.5",children:[a.jsx(Ro,{className:"w-4 h-4"}),a.jsx("span",{className:"hidden sm:inline",children:t("common.reset")})]}),a.jsxs("button",{onClick:()=>f(!0),className:"px-3 py-1.5 text-sm bg-bambu-green text-white rounded-lg hover:bg-bambu-green/80 transition-colors flex items-center gap-1.5",children:[a.jsx(ar,{className:"w-4 h-4"}),a.jsx("span",{className:"hidden sm:inline",children:t("common.add")})]})]})]}),a.jsxs(Nt,{className:"space-y-4",children:[a.jsx("p",{className:"text-sm text-bambu-gray",children:t("settings.colorCatalog.description")}),a.jsxs("div",{className:"flex gap-2 flex-wrap",children:[a.jsxs("div",{className:"relative flex-1 min-w-[200px]",children:[a.jsx(Or,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray"}),a.jsx("input",{type:"text",className:"w-full pl-10 pr-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white placeholder-bambu-gray focus:border-bambu-green focus:outline-none",placeholder:t("settings.colorCatalog.searchColors"),value:o,onChange:ce=>l(ce.target.value)})]}),a.jsxs("select",{className:"px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",value:c,onChange:ce=>u(ce.target.value),children:[a.jsx("option",{value:"",children:t("settings.colorCatalog.allManufacturers")}),K.map(ce=>a.jsx("option",{value:ce,children:ce},ce))]})]}),h&&a.jsxs("div",{className:"p-4 bg-bambu-dark rounded-lg border border-bambu-dark-tertiary",children:[a.jsx("h3",{className:"text-sm font-medium text-white mb-3",children:t("settings.colorCatalog.addNewColor")}),a.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-5 gap-2 items-end",children:[a.jsx("input",{type:"text",className:"px-3 py-2 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg text-white placeholder-bambu-gray focus:border-bambu-green focus:outline-none",placeholder:t("settings.colorCatalog.manufacturer"),value:y,onChange:ce=>b(ce.target.value)}),a.jsx("input",{type:"text",className:"px-3 py-2 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg text-white placeholder-bambu-gray focus:border-bambu-green focus:outline-none",placeholder:t("settings.colorCatalog.colorName"),value:v,onChange:ce=>S(ce.target.value)}),a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx("input",{type:"color",className:"w-10 h-10 rounded cursor-pointer border border-bambu-dark-tertiary",value:N,onChange:ce=>A(ce.target.value)}),a.jsx("input",{type:"text",className:"flex-1 px-3 py-2 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg text-white placeholder-bambu-gray focus:border-bambu-green focus:outline-none",placeholder:"#FFFFFF",value:N,onChange:ce=>A(ce.target.value)})]}),a.jsx("input",{type:"text",className:"px-3 py-2 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg text-white placeholder-bambu-gray focus:border-bambu-green focus:outline-none",placeholder:t("settings.colorCatalog.materialOptional"),value:C,onChange:ce=>T(ce.target.value)}),a.jsxs("div",{className:"flex gap-2",children:[a.jsxs("button",{onClick:$,disabled:k,className:"flex-1 px-3 py-2 bg-bambu-green text-white rounded-lg hover:bg-bambu-green/80 flex items-center justify-center gap-1",children:[k?a.jsx(it,{className:"w-4 h-4 animate-spin"}):a.jsx(Xr,{className:"w-4 h-4"}),t("common.add")]}),a.jsx("button",{onClick:()=>{f(!1),oe()},className:"p-2 rounded-lg text-bambu-gray hover:text-white hover:bg-bambu-dark-tertiary",children:a.jsx(Ft,{className:"w-4 h-4"})})]})]})]}),(o||c)&&a.jsx("div",{className:"text-xs text-bambu-gray",children:t("settings.colorCatalog.showing",{filtered:Y.length,total:n.length})}),i?a.jsxs("div",{className:"flex items-center justify-center py-8 text-bambu-gray",children:[a.jsx(it,{className:"w-5 h-5 animate-spin mr-2"}),t("common.loading")]}):a.jsx("div",{className:"max-h-[600px] overflow-auto border border-bambu-dark-tertiary rounded-lg",children:a.jsxs("table",{className:"w-full text-sm",children:[a.jsx("thead",{className:"bg-bambu-dark sticky top-0",children:a.jsxs("tr",{children:[a.jsx("th",{className:"px-3 py-2 text-left text-bambu-gray font-medium w-12"}),a.jsx("th",{className:"px-3 py-2 text-left text-bambu-gray font-medium",children:t("settings.colorCatalog.manufacturer")}),a.jsx("th",{className:"px-3 py-2 text-left text-bambu-gray font-medium",children:t("inventory.material")}),a.jsx("th",{className:"px-3 py-2 text-left text-bambu-gray font-medium",children:t("settings.colorCatalog.colorName")}),a.jsx("th",{className:"px-3 py-2 text-left text-bambu-gray font-medium w-24",children:t("settings.colorCatalog.hex")}),a.jsx("th",{className:"px-3 py-2 w-16"})]})}),a.jsx("tbody",{children:Y.length===0?a.jsx("tr",{children:a.jsx("td",{colSpan:6,className:"px-3 py-8 text-center text-bambu-gray",children:t(o||c?"settings.colorCatalog.noMatch":"settings.colorCatalog.empty")})}):Y.map(ce=>a.jsx("tr",{className:"border-t border-bambu-dark-tertiary hover:bg-bambu-dark",children:p===ce.id?a.jsxs(a.Fragment,{children:[a.jsx("td",{className:"px-3 py-2",children:a.jsx("input",{type:"color",className:"w-8 h-8 rounded cursor-pointer border border-bambu-dark-tertiary",value:N,onChange:Se=>A(Se.target.value)})}),a.jsx("td",{className:"px-3 py-2",children:a.jsx("input",{type:"text",className:"w-full px-2 py-1 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded text-white text-sm focus:border-bambu-green focus:outline-none",value:y,onChange:Se=>b(Se.target.value)})}),a.jsx("td",{className:"px-3 py-2",children:a.jsx("input",{type:"text",className:"w-full px-2 py-1 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded text-white text-sm focus:border-bambu-green focus:outline-none",value:C,onChange:Se=>T(Se.target.value)})}),a.jsx("td",{className:"px-3 py-2",children:a.jsx("input",{type:"text",className:"w-full px-2 py-1 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded text-white text-sm focus:border-bambu-green focus:outline-none",value:v,onChange:Se=>S(Se.target.value)})}),a.jsx("td",{className:"px-3 py-2",children:a.jsx("input",{type:"text",className:"w-full px-2 py-1 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded text-white text-sm focus:border-bambu-green focus:outline-none",value:N,onChange:Se=>A(Se.target.value)})}),a.jsx("td",{className:"px-3 py-2",children:a.jsxs("div",{className:"flex justify-end gap-1",children:[a.jsx("button",{onClick:()=>J(ce.id),disabled:k,className:"p-1.5 rounded hover:bg-green-500/20 text-green-500",children:k?a.jsx(it,{className:"w-4 h-4 animate-spin"}):a.jsx(Xr,{className:"w-4 h-4"})}),a.jsx("button",{onClick:ee,className:"p-1.5 rounded hover:bg-bambu-dark-tertiary text-bambu-gray",children:a.jsx(Ft,{className:"w-4 h-4"})})]})})]}):a.jsxs(a.Fragment,{children:[a.jsx("td",{className:"px-3 py-2",children:a.jsx("div",{className:"w-8 h-8 rounded border border-bambu-dark-tertiary",style:{backgroundColor:ce.hex_color},title:ce.hex_color})}),a.jsx("td",{className:"px-3 py-2 text-white",children:ce.manufacturer}),a.jsx("td",{className:"px-3 py-2 text-bambu-gray",children:ce.material||"-"}),a.jsx("td",{className:"px-3 py-2 text-white",children:ce.color_name}),a.jsx("td",{className:"px-3 py-2 font-mono text-xs text-bambu-gray",children:ce.hex_color}),a.jsx("td",{className:"px-3 py-2",children:a.jsxs("div",{className:"flex justify-end gap-1",children:[a.jsx("button",{onClick:()=>X(ce),className:"p-1.5 rounded hover:bg-bambu-dark-tertiary text-bambu-gray hover:text-white",children:a.jsx(Vi,{className:"w-4 h-4"})}),a.jsx("button",{onClick:()=>R(ce),className:"p-1.5 rounded bg-red-500/10 hover:bg-red-500/20 text-red-500",children:a.jsx(Jt,{className:"w-4 h-4"})})]})})]})},ce.id))})]})})]}),B&&a.jsx(vn,{title:t("settings.colorCatalog.deleteColor"),message:t("settings.colorCatalog.deleteConfirm",{name:`${B.manufacturer} - ${B.color_name}`}),confirmText:t("common.delete"),variant:"danger",onConfirm:_e,onCancel:()=>R(null)}),G&&a.jsx(vn,{title:t("settings.colorCatalog.resetCatalog"),message:t("settings.colorCatalog.resetConfirm"),confirmText:t("common.reset"),variant:"danger",onConfirm:pe,onCancel:()=>q(!1)})]})}function iZe({link:t,onClose:e}){const{t:n}=Vt(),r=tn(),i=!!t,s=w.useRef(null),[o,l]=w.useState(t?.name||""),[c,u]=w.useState(t?.url||""),[d,h]=w.useState(t?.icon||"link"),[f,p]=w.useState(t?.open_in_new_tab||!1),[x,y]=w.useState(!!t?.custom_icon),[b,v]=w.useState(t?.custom_icon?re.getExternalLinkIconUrl(t.id):null),[S,N]=w.useState(null),[A,C]=w.useState(null);w.useEffect(()=>{const B=R=>{R.key==="Escape"&&e()};return window.addEventListener("keydown",B),()=>window.removeEventListener("keydown",B)},[e]);const T=ot({mutationFn:async B=>{const R=await re.createExternalLink(B);return S?await re.uploadExternalLinkIcon(R.id,S):R},onSuccess:()=>{r.invalidateQueries({queryKey:["external-links"]}),e()},onError:B=>{C(B.message)}}),k=ot({mutationFn:async B=>{let R=await re.updateExternalLink(t.id,B);return S?R=await re.uploadExternalLinkIcon(t.id,S):!x&&t?.custom_icon&&(R=await re.deleteExternalLinkIcon(t.id)),R},onSuccess:()=>{r.invalidateQueries({queryKey:["external-links"]}),e()},onError:B=>{C(B.message)}}),j=B=>{const R=B.target.files?.[0];if(R){if(!["image/png","image/jpeg","image/gif","image/svg+xml","image/webp","image/x-icon"].includes(R.type)){C("Please select a valid image file (PNG, JPG, GIF, SVG, WebP, or ICO)");return}if(R.size>1024*1024){C("Image file must be less than 1MB");return}N(R),y(!0);const q=new FileReader;q.onload=z=>{v(z.target?.result)},q.readAsDataURL(R)}},E=()=>{N(null),v(null),y(!1),s.current&&(s.current.value="")},P=B=>{if(B.preventDefault(),C(null),!o.trim()){C("Name is required");return}if(!c.trim()){C("URL is required");return}if(!c.startsWith("http://")&&!c.startsWith("https://")){C("URL must start with http:// or https://");return}const R={name:o.trim(),url:c.trim(),icon:d,open_in_new_tab:f};i?k.mutate(R):T.mutate(R)},U=T.isPending||k.isPending,O=hC(d);return a.jsx("div",{className:"fixed inset-0 bg-black/70 flex items-center justify-center z-50 p-4",onClick:e,children:a.jsxs("div",{className:"bg-bambu-dark-secondary rounded-xl border border-bambu-dark-tertiary w-full max-w-md",onClick:B=>B.stopPropagation(),children:[a.jsxs("div",{className:"flex items-center justify-between px-6 py-4 border-b border-bambu-dark-tertiary",children:[a.jsxs("div",{className:"flex items-center gap-3",children:[a.jsx("div",{className:"p-2 rounded-full bg-bambu-green/20 text-bambu-green",children:x&&b?a.jsx("img",{src:b,alt:"",className:"w-5 h-5 rounded"}):a.jsx(O,{className:"w-5 h-5"})}),a.jsx("h2",{className:"text-lg font-semibold text-white",children:i?"Edit Link":"Add External Link"})]}),a.jsx("button",{onClick:e,className:"text-bambu-gray hover:text-white transition-colors",children:a.jsx(Ft,{className:"w-5 h-5"})})]}),a.jsxs("form",{onSubmit:P,className:"p-6 space-y-4",children:[A&&a.jsx("div",{className:"p-3 bg-red-500/20 border border-red-500/50 rounded-lg text-sm text-red-400",children:A}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Name *"}),a.jsx("input",{type:"text",value:o,onChange:B=>l(B.target.value),placeholder:"My Link",maxLength:50,className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none"})]}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"URL *"}),a.jsx("input",{type:"text",value:c,onChange:B=>u(B.target.value),placeholder:"https://example.com",className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none"})]}),a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsx("label",{className:"text-sm text-bambu-gray",children:n("externalLinks.openInNewTab")}),a.jsx("button",{type:"button",onClick:()=>p(!f),className:`relative inline-flex h-6 w-11 items-center rounded-full transition-colors ${f?"bg-bambu-green":"bg-bambu-dark-tertiary"}`,children:a.jsx("span",{className:`inline-block h-4 w-4 transform rounded-full bg-white transition-transform ${f?"translate-x-6":"translate-x-1"}`})})]}),a.jsxs("div",{className:"space-y-3",children:[a.jsx("label",{className:"block text-sm text-bambu-gray",children:"Icon"}),a.jsxs("div",{className:"p-3 rounded-lg bg-bambu-dark border border-bambu-dark-tertiary",children:[a.jsxs("div",{className:"flex items-center justify-between mb-2",children:[a.jsx("span",{className:"text-sm text-white",children:"Custom Icon"}),a.jsx("input",{ref:s,type:"file",accept:"image/png,image/jpeg,image/gif,image/svg+xml,image/webp,image/x-icon",className:"hidden",onChange:j}),x&&b?a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx("img",{src:b,alt:"Custom icon",className:"w-8 h-8 rounded border border-bambu-dark-tertiary"}),a.jsx("button",{type:"button",onClick:E,className:"p-1 text-red-400 hover:text-red-300 transition-colors",title:"Remove custom icon",children:a.jsx(Jt,{className:"w-4 h-4"})})]}):a.jsxs(Ce,{type:"button",variant:"secondary",size:"sm",onClick:()=>s.current?.click(),children:[a.jsx(Fi,{className:"w-4 h-4"}),"Upload"]})]}),a.jsx("p",{className:"text-xs text-bambu-gray",children:"PNG, JPG, GIF, SVG, WebP, or ICO. Max 1MB."})]}),!x&&a.jsxs("div",{children:[a.jsx("span",{className:"text-sm text-bambu-gray block mb-2",children:"Or choose a preset icon"}),a.jsx(qpe,{value:d,onChange:h})]})]}),a.jsxs("div",{className:"flex gap-3 pt-2",children:[a.jsx(Ce,{type:"button",variant:"secondary",onClick:e,className:"flex-1",children:"Cancel"}),a.jsxs(Ce,{type:"submit",disabled:U,className:"flex-1",children:[U?a.jsx(it,{className:"w-4 h-4 animate-spin"}):a.jsx(bs,{className:"w-4 h-4"}),i?"Save":"Add"]})]})]})]})})}function aZe(){const{t}=Vt(),e=tn(),[n,r]=w.useState(!1),[i,s]=w.useState(null),[o,l]=w.useState(null),[c,u]=w.useState(null),{data:d,isLoading:h}=Ze({queryKey:["external-links"],queryFn:re.getExternalLinks}),f=ot({mutationFn:N=>re.deleteExternalLink(N),onSuccess:()=>{e.invalidateQueries({queryKey:["external-links"]})}}),p=ot({mutationFn:N=>re.reorderExternalLinks(N),onSuccess:()=>{e.invalidateQueries({queryKey:["external-links"]})}}),x=(N,A)=>{u(A),N.dataTransfer.effectAllowed="move"},y=N=>{N.preventDefault(),N.dataTransfer.dropEffect="move"},b=(N,A)=>{if(N.preventDefault(),c===null||c===A||!d)return;const C=d.map(E=>E.id),T=C.indexOf(c),k=C.indexOf(A);if(T===-1||k===-1)return;const j=[...C];j.splice(T,1),j.splice(k,0,c),p.mutate(j),u(null)},v=N=>{l(N)},S=()=>{o&&(f.mutate(o.id),l(null))};return a.jsxs(a.Fragment,{children:[a.jsxs(vt,{children:[a.jsx(An,{children:a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx(Rh,{className:"w-5 h-5 text-bambu-green"}),a.jsx("h2",{className:"text-lg font-semibold text-white",children:"Sidebar Links"})]}),a.jsxs(Ce,{size:"sm",onClick:()=>r(!0),children:[a.jsx(ar,{className:"w-4 h-4"}),"Add Link"]})]})}),a.jsxs(Nt,{children:[a.jsx("p",{className:"text-sm text-bambu-gray mb-4",children:"Add external links to the sidebar navigation. Drag to reorder."}),h?a.jsx("div",{className:"flex justify-center py-8",children:a.jsx(it,{className:"w-6 h-6 text-bambu-green animate-spin"})}):d&&d.length>0?a.jsx("div",{className:"space-y-2",children:d.map(N=>{const A=hC(N.icon);return a.jsxs("div",{draggable:!0,onDragStart:C=>x(C,N.id),onDragOver:y,onDrop:C=>b(C,N.id),className:`flex items-center gap-3 p-3 rounded-lg bg-bambu-dark border border-bambu-dark-tertiary transition-colors ${c===N.id?"opacity-50":""}`,children:[a.jsx(Dh,{className:"w-6 h-6 md:w-4 md:h-4 text-bambu-gray cursor-grab flex-shrink-0"}),a.jsx("div",{className:"p-2 rounded-lg bg-bambu-dark-tertiary text-bambu-gray",children:a.jsx(A,{className:"w-4 h-4"})}),a.jsxs("div",{className:"flex-1 min-w-0",children:[a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx("span",{className:"text-white font-medium truncate",children:N.name}),a.jsx(Kr,{className:"w-3 h-3 text-bambu-gray flex-shrink-0"})]}),a.jsx("span",{className:"text-sm text-bambu-gray truncate block",children:N.url})]}),a.jsxs("div",{className:"flex items-center gap-1 flex-shrink-0",children:[a.jsx("button",{onClick:()=>s(N),className:"p-2 rounded-lg hover:bg-bambu-dark-tertiary text-bambu-gray hover:text-white transition-colors",title:t("common.edit"),children:a.jsx(Vi,{className:"w-4 h-4"})}),a.jsx("button",{onClick:()=>v(N),disabled:f.isPending,className:"p-2 rounded-lg hover:bg-red-500/20 text-bambu-gray hover:text-red-400 transition-colors disabled:opacity-50",title:t("externalLinks.deleteLink"),children:a.jsx(Jt,{className:"w-4 h-4"})})]})]},N.id)})}):a.jsxs("div",{className:"text-center py-8 text-bambu-gray",children:[a.jsx(Rh,{className:"w-8 h-8 mx-auto mb-2 opacity-50"}),a.jsx("p",{children:t("externalLinks.noLinksConfigured")}),a.jsx("p",{className:"text-sm",children:'Click "Add Link" to add one'})]})]})]}),(n||i)&&a.jsx(iZe,{link:i,onClose:()=>{r(!1),s(null)}}),o&&a.jsx(vn,{title:"Delete Link",message:`Are you sure you want to delete "${o.name}"? This action cannot be undone.`,confirmText:"Delete",cancelText:"Cancel",variant:"danger",onConfirm:S,onCancel:()=>l(null)})]})}function sZe(){const{t}=Vt(),e=tn(),{showToast:n}=hn(),[r,i]=w.useState(!1),[s,o]=w.useState(""),[l,c]=w.useState("immediate"),[u,d]=w.useState("3DPrinter-X1-Carbon"),[h,f]=w.useState(null),[p,x]=w.useState(""),[y,b]=w.useState(!1),[v,S]=w.useState(null),{data:N,isLoading:A}=Ze({queryKey:["virtual-printer-settings"],queryFn:ZS.getSettings,refetchInterval:1e4}),{data:C}=Ze({queryKey:["virtual-printer-models"],queryFn:ZS.getModels}),{data:T}=Ze({queryKey:["printers"],queryFn:re.getPrinters}),{data:k}=Ze({queryKey:["network-interfaces"],queryFn:()=>re.getNetworkInterfaces().then(z=>z.interfaces),enabled:r});w.useEffect(()=>{if(N){i(N.enabled);let z=N.mode==="queue"?"review":N.mode;z!=="immediate"&&z!=="review"&&z!=="print_queue"&&z!=="proxy"&&(z="immediate"),c(z),d(N.model),f(N.target_printer_id),x(N.remote_interface_ip||"")}},[N]);const j=ot({mutationFn:z=>ZS.updateSettings(z),onSuccess:()=>{e.invalidateQueries({queryKey:["virtual-printer-settings"]}),n(t("virtualPrinter.toast.updated")),S(null)},onError:z=>{if(n(z.message||t("virtualPrinter.toast.failedToUpdate"),"error"),N){i(N.enabled);const K=N.mode==="queue"?"review":N.mode;c(["immediate","review","print_queue","proxy"].includes(K)?K:"immediate"),d(N.model),f(N.target_printer_id)}S(null)}}),E=()=>{const z=!r;if(z){if(l==="proxy"){if(!h){n(t("virtualPrinter.toast.targetPrinterRequired"),"error");return}}else if(!s&&!N?.access_code_set){n(t("virtualPrinter.toast.accessCodeRequired"),"error");return}}i(z),S("toggle"),j.mutate({enabled:z,access_code:l!=="proxy"&&s||void 0,mode:l,target_printer_id:l==="proxy"?h??void 0:void 0})},P=()=>{if(!s){n(t("virtualPrinter.toast.accessCodeEmpty"),"error");return}if(s.length!==8){n(t("virtualPrinter.toast.accessCodeLength"),"error");return}S("accessCode"),j.mutate({access_code:s}),o("")},U=z=>{c(z),S("mode"),j.mutate({mode:z})},O=z=>{f(z),S("targetPrinter"),j.mutate({target_printer_id:z})},B=z=>{d(z),S("model"),j.mutate({model:z})},R=z=>{x(z),S("remoteInterface"),j.mutate({remote_interface_ip:z})};if(A)return a.jsx(vt,{children:a.jsx(Nt,{className:"py-8 flex justify-center",children:a.jsx(it,{className:"w-6 h-6 animate-spin text-bambu-green"})})});const G=N?.status,q=G?.running||!1;return a.jsxs("div",{className:"flex flex-col lg:flex-row gap-6 lg:gap-8",children:[a.jsx("div",{className:"space-y-6 lg:w-[480px] lg:flex-shrink-0",children:a.jsxs(vt,{children:[a.jsx(An,{children:a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx(Cr,{className:"w-5 h-5 text-bambu-green"}),a.jsx("h2",{className:"text-lg font-semibold text-white",children:t("virtualPrinter.title")})]}),G&&a.jsxs("div",{className:`flex items-center gap-2 text-sm ${q?"text-green-400":"text-bambu-gray"}`,children:[a.jsx("span",{className:`w-2 h-2 rounded-full ${q?"bg-green-400 animate-pulse":"bg-gray-500"}`}),t(q?"virtualPrinter.running":"virtualPrinter.stopped")]})]})}),a.jsxs(Nt,{className:"space-y-4",children:[a.jsx("p",{className:"text-sm text-bambu-gray",children:t(l==="proxy"?"virtualPrinter.description.proxy":"virtualPrinter.description.default")}),a.jsxs("div",{className:"flex items-center justify-between py-3 border-t border-bambu-dark-tertiary",children:[a.jsxs("div",{children:[a.jsx("div",{className:"text-white font-medium",children:t("virtualPrinter.enable.title")}),a.jsx("div",{className:"text-sm text-bambu-gray",children:q?l==="proxy"?t("virtualPrinter.enable.proxyingTo",{name:T?.find(z=>z.id===h)?.name||"printer"}):t("virtualPrinter.enable.visibleInSlicer"):t("virtualPrinter.enable.notActive")})]}),a.jsx("button",{onClick:E,disabled:v==="toggle",className:`relative w-12 h-6 rounded-full transition-colors ${r?"bg-bambu-green":"bg-bambu-dark-tertiary"} ${v==="toggle"?"opacity-50":""}`,children:a.jsx("span",{className:`absolute top-1 left-1 w-4 h-4 bg-white rounded-full transition-transform ${r?"translate-x-6":""}`})})]}),l!=="proxy"&&a.jsxs("div",{className:"py-3 border-t border-bambu-dark-tertiary",children:[a.jsx("div",{className:"text-white font-medium mb-2",children:t("virtualPrinter.model.title")}),a.jsx("div",{className:"text-sm text-bambu-gray mb-3",children:t("virtualPrinter.model.description")}),a.jsxs("div",{className:"relative",children:[a.jsx("select",{value:u,onChange:z=>B(z.target.value),disabled:v==="model",className:"w-full bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-md px-3 py-2 text-white appearance-none cursor-pointer disabled:opacity-50 disabled:cursor-not-allowed pr-10",children:C?.models&&Object.entries(C.models).sort(([,z],[,K])=>z.localeCompare(K)).map(([z,K])=>a.jsx("option",{value:z,children:K},z))}),a.jsx(nr,{className:"absolute right-3 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray pointer-events-none"})]}),r&&q&&a.jsxs("p",{className:"text-xs text-bambu-gray mt-2",children:[a.jsx(Js,{className:"w-3 h-3 inline mr-1"}),t("virtualPrinter.model.restartWarning")]})]}),l!=="proxy"&&a.jsxs("div",{className:"py-3 border-t border-bambu-dark-tertiary",children:[a.jsx("div",{className:"text-white font-medium mb-2",children:t("virtualPrinter.accessCode.title")}),a.jsx("div",{className:"text-sm text-bambu-gray mb-3",children:N?.access_code_set?a.jsxs("span",{className:"flex items-center gap-1 text-green-400",children:[a.jsx(Xr,{className:"w-4 h-4"}),t("virtualPrinter.accessCode.isSet")]}):a.jsxs("span",{className:"flex items-center gap-1 text-yellow-400",children:[a.jsx(Cn,{className:"w-4 h-4"}),t("virtualPrinter.accessCode.notSet")]})}),a.jsxs("div",{className:"flex gap-2",children:[a.jsxs("div",{className:"relative flex-1",children:[a.jsx("input",{type:y?"text":"password",value:s,onChange:z=>o(z.target.value),placeholder:N?.access_code_set?t("virtualPrinter.accessCode.placeholderChange"):t("virtualPrinter.accessCode.placeholder"),maxLength:8,className:"w-full bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-md px-3 py-2 text-white placeholder-bambu-gray pr-10 font-mono"}),a.jsx("button",{onClick:()=>b(!y),className:"absolute right-2 top-1/2 -translate-y-1/2 text-bambu-gray hover:text-white",children:y?a.jsx(gv,{className:"w-4 h-4"}):a.jsx(Xl,{className:"w-4 h-4"})})]}),a.jsx(Ce,{onClick:P,disabled:!s||v==="accessCode",variant:"primary",children:v==="accessCode"?a.jsx(it,{className:"w-4 h-4 animate-spin"}):t("common.save")})]}),a.jsxs("p",{className:"text-xs text-bambu-gray mt-2",children:[t("virtualPrinter.accessCode.hint"),s&&a.jsxs("span",{className:s.length===8?"text-green-400":"text-yellow-400",children:[" ",t("virtualPrinter.accessCode.charCount",{count:s.length})]})]})]}),l==="proxy"&&a.jsxs("div",{className:"py-3 border-t border-bambu-dark-tertiary",children:[a.jsx("div",{className:"text-white font-medium mb-2",children:t("virtualPrinter.targetPrinter.title")}),a.jsx("div",{className:"text-sm text-bambu-gray mb-3",children:h?a.jsxs("span",{className:"flex items-center gap-1 text-green-400",children:[a.jsx(Xr,{className:"w-4 h-4"}),t("virtualPrinter.targetPrinter.configured")]}):a.jsxs("span",{className:"flex items-center gap-1 text-yellow-400",children:[a.jsx(Cn,{className:"w-4 h-4"}),t("virtualPrinter.targetPrinter.notConfigured")]})}),a.jsxs("div",{className:"relative",children:[a.jsxs("select",{value:h??"",onChange:z=>{const K=parseInt(z.target.value,10);isNaN(K)||O(K)},disabled:v==="targetPrinter",className:"w-full bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-md px-3 py-2 text-white appearance-none cursor-pointer disabled:opacity-50 disabled:cursor-not-allowed pr-10",children:[a.jsx("option",{value:"",children:t("virtualPrinter.targetPrinter.placeholder")}),T?.map(z=>a.jsxs("option",{value:z.id,children:[z.name," (",z.ip_address,")"]},z.id))]}),a.jsx(nr,{className:"absolute right-3 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray pointer-events-none"})]}),a.jsx("p",{className:"text-xs text-bambu-gray mt-2",children:t("virtualPrinter.targetPrinter.hint")}),!T?.length&&a.jsxs("p",{className:"text-xs text-yellow-400 mt-2",children:[a.jsx(Cn,{className:"w-3 h-3 inline mr-1"}),t("virtualPrinter.targetPrinter.noPrinters")]})]}),r&&a.jsxs("div",{className:"py-3 border-t border-bambu-dark-tertiary",children:[a.jsx("div",{className:"text-white font-medium mb-2",children:t("virtualPrinter.remoteInterface.title")}),a.jsx("div",{className:"text-sm text-bambu-gray mb-3",children:p?a.jsxs("span",{className:"flex items-center gap-1 text-green-400",children:[a.jsx(Xr,{className:"w-4 h-4"}),t("virtualPrinter.remoteInterface.configured")]}):a.jsxs("span",{className:"flex items-center gap-1 text-bambu-gray",children:[a.jsx(Js,{className:"w-4 h-4"}),t("virtualPrinter.remoteInterface.optional")]})}),a.jsxs("div",{className:"relative",children:[a.jsxs("select",{value:p,onChange:z=>R(z.target.value),disabled:v==="remoteInterface",className:"w-full bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-md px-3 py-2 text-white appearance-none cursor-pointer disabled:opacity-50 disabled:cursor-not-allowed pr-10",children:[a.jsx("option",{value:"",children:t("virtualPrinter.remoteInterface.placeholder")}),k?.map(z=>a.jsxs("option",{value:z.ip,children:[z.name," (",z.ip,") - ",z.subnet]},z.ip))]}),a.jsx(nr,{className:"absolute right-3 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray pointer-events-none"})]}),a.jsx("p",{className:"text-xs text-bambu-gray mt-2",children:t("virtualPrinter.remoteInterface.hint")})]}),a.jsxs("div",{className:"py-3 border-t border-bambu-dark-tertiary",children:[a.jsx("div",{className:"text-white font-medium mb-2",children:t("virtualPrinter.mode.title")}),a.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[a.jsxs("button",{onClick:()=>U("immediate"),disabled:v==="mode",className:`p-3 rounded-lg border text-left transition-colors ${l==="immediate"?"border-bambu-green bg-bambu-green/10":"border-bambu-dark-tertiary hover:border-bambu-gray"}`,children:[a.jsx("div",{className:"text-white font-medium",children:t("virtualPrinter.mode.archive")}),a.jsx("div",{className:"text-xs text-bambu-gray",children:t("virtualPrinter.mode.archiveDesc")})]}),a.jsxs("button",{onClick:()=>U("review"),disabled:v==="mode",className:`p-3 rounded-lg border text-left transition-colors ${l==="review"?"border-bambu-green bg-bambu-green/10":"border-bambu-dark-tertiary hover:border-bambu-gray"}`,children:[a.jsx("div",{className:"text-white font-medium",children:t("virtualPrinter.mode.review")}),a.jsx("div",{className:"text-xs text-bambu-gray",children:t("virtualPrinter.mode.reviewDesc")})]}),a.jsxs("button",{onClick:()=>U("print_queue"),disabled:v==="mode",className:`p-3 rounded-lg border text-left transition-colors ${l==="print_queue"?"border-bambu-green bg-bambu-green/10":"border-bambu-dark-tertiary hover:border-bambu-gray"}`,children:[a.jsx("div",{className:"text-white font-medium",children:t("virtualPrinter.mode.queue")}),a.jsx("div",{className:"text-xs text-bambu-gray",children:t("virtualPrinter.mode.queueDesc")})]}),a.jsxs("button",{onClick:()=>U("proxy"),disabled:v==="mode",className:`p-3 rounded-lg border text-left transition-colors ${l==="proxy"?"border-blue-500 bg-blue-500/10":"border-bambu-dark-tertiary hover:border-bambu-gray"}`,children:[a.jsxs("div",{className:"flex items-center gap-1.5 text-white font-medium",children:[a.jsx(BB,{className:"w-4 h-4"}),t("virtualPrinter.mode.proxy")]}),a.jsx("div",{className:"text-xs text-bambu-gray",children:t("virtualPrinter.mode.proxyDesc")})]})]})]})]})]})}),a.jsxs("div",{className:"space-y-6 lg:w-[480px] lg:flex-shrink-0",children:[a.jsx(vt,{className:"border-l-4 border-l-yellow-500",children:a.jsx(Nt,{className:"py-4",children:a.jsxs("div",{className:"flex items-start gap-3",children:[a.jsx(Cn,{className:"w-5 h-5 text-yellow-500 flex-shrink-0 mt-0.5"}),a.jsxs("div",{className:"text-sm",children:[a.jsx("p",{className:"text-white font-medium mb-2",children:t("virtualPrinter.setupRequired.title")}),a.jsx("p",{className:"text-bambu-gray mb-3",children:t("virtualPrinter.setupRequired.description")}),a.jsxs("a",{href:"https://wiki.bambuddy.cool/features/virtual-printer/",target:"_blank",rel:"noopener noreferrer",className:"inline-flex items-center gap-2 px-4 py-2 bg-yellow-500/20 border border-yellow-500/50 rounded-md text-yellow-400 hover:bg-yellow-500/30 transition-colors",children:[a.jsx(Kr,{className:"w-4 h-4"}),t("virtualPrinter.setupRequired.readGuide")]})]})]})})}),a.jsx(vt,{children:a.jsx(Nt,{className:"py-4",children:a.jsxs("div",{className:"flex items-start gap-3",children:[a.jsx(Js,{className:"w-5 h-5 text-blue-400 flex-shrink-0 mt-0.5"}),a.jsxs("div",{className:"text-sm text-bambu-gray",children:[a.jsx("p",{className:"mb-2",children:a.jsxs("strong",{className:"text-white",children:[t(l==="proxy"?"virtualPrinter.howItWorks.titleProxy":"virtualPrinter.howItWorks.title"),":"]})}),l==="proxy"?a.jsxs("ol",{className:"list-decimal list-inside space-y-1",children:[a.jsx("li",{children:t("virtualPrinter.howItWorks.proxyStep1")}),a.jsx("li",{children:t("virtualPrinter.howItWorks.proxyStep2")}),a.jsx("li",{children:t("virtualPrinter.howItWorks.proxyStep3")}),a.jsx("li",{children:t("virtualPrinter.howItWorks.proxyStep4")}),a.jsx("li",{children:t("virtualPrinter.howItWorks.proxyStep5")})]}):a.jsxs("ol",{className:"list-decimal list-inside space-y-1",children:[a.jsx("li",{children:t("virtualPrinter.howItWorks.step1")}),a.jsx("li",{children:t("virtualPrinter.howItWorks.step2")}),a.jsx("li",{children:t("virtualPrinter.howItWorks.step3")}),a.jsx("li",{children:t("virtualPrinter.howItWorks.step4")}),a.jsx("li",{children:t("virtualPrinter.howItWorks.step5")}),a.jsx("li",{children:t("virtualPrinter.howItWorks.step6")})]})]})]})})}),G&&q&&a.jsxs(vt,{children:[a.jsx(An,{children:a.jsx("h3",{className:"text-md font-semibold text-white",children:t("virtualPrinter.status.title")})}),a.jsx(Nt,{children:G.mode==="proxy"&&G.proxy?a.jsxs("div",{className:"grid grid-cols-2 gap-4 text-sm",children:[a.jsxs("div",{children:[a.jsx("div",{className:"text-bambu-gray",children:t("virtualPrinter.status.targetPrinter")}),a.jsx("div",{className:"text-white",children:T?.find(z=>z.id===h)?.name||G.proxy.target_host}),a.jsx("div",{className:"text-xs text-bambu-gray font-mono",children:G.proxy.target_host})]}),a.jsxs("div",{children:[a.jsx("div",{className:"text-bambu-gray",children:t("virtualPrinter.status.mode")}),a.jsxs("div",{className:"text-white flex items-center gap-1.5",children:[a.jsx(BB,{className:"w-4 h-4"}),t("virtualPrinter.mode.proxy")]})]}),a.jsxs("div",{children:[a.jsx("div",{className:"text-bambu-gray",children:t("virtualPrinter.status.ftpPort")}),a.jsx("div",{className:"text-white font-mono",children:G.proxy.ftp_port})]}),a.jsxs("div",{children:[a.jsx("div",{className:"text-bambu-gray",children:t("virtualPrinter.status.mqttPort")}),a.jsx("div",{className:"text-white font-mono",children:G.proxy.mqtt_port})]}),a.jsxs("div",{children:[a.jsx("div",{className:"text-bambu-gray",children:t("virtualPrinter.status.ftpConnections")}),a.jsx("div",{className:"text-white",children:G.proxy.ftp_connections??0})]}),a.jsxs("div",{children:[a.jsx("div",{className:"text-bambu-gray",children:t("virtualPrinter.status.mqttConnections")}),a.jsx("div",{className:"text-white",children:G.proxy.mqtt_connections??0})]})]}):a.jsxs("div",{className:"grid grid-cols-2 gap-4 text-sm",children:[a.jsxs("div",{children:[a.jsx("div",{className:"text-bambu-gray",children:t("virtualPrinter.status.printerName")}),a.jsx("div",{className:"text-white",children:G.name})]}),a.jsxs("div",{children:[a.jsx("div",{className:"text-bambu-gray",children:t("virtualPrinter.status.model")}),a.jsx("div",{className:"text-white",children:G.model_name||G.model})]}),a.jsxs("div",{children:[a.jsx("div",{className:"text-bambu-gray",children:t("virtualPrinter.status.serialNumber")}),a.jsx("div",{className:"text-white font-mono",children:G.serial})]}),a.jsxs("div",{children:[a.jsx("div",{className:"text-bambu-gray",children:t("virtualPrinter.status.mode")}),a.jsx("div",{className:"text-white capitalize",children:G.mode})]}),a.jsxs("div",{children:[a.jsx("div",{className:"text-bambu-gray",children:t("virtualPrinter.status.pendingFiles")}),a.jsx("div",{className:"text-white",children:G.pending_files})]})]})})]})]})]})}function sK({status:t}){if(!t)return null;const e={success:"bg-green-500/20 text-green-400",failed:"bg-red-500/20 text-red-400",skipped:"bg-yellow-500/20 text-yellow-400",running:"bg-blue-500/20 text-blue-400"},n={success:a.jsx(gr,{className:"w-3 h-3"}),failed:a.jsx(ha,{className:"w-3 h-3"}),skipped:a.jsx(IF,{className:"w-3 h-3"}),running:a.jsx(it,{className:"w-3 h-3 animate-spin"})};return a.jsxs("span",{className:`inline-flex items-center gap-1 px-2 py-0.5 rounded text-xs font-medium ${e[t]||"bg-gray-500/20 text-gray-400"}`,children:[n[t],t.charAt(0).toUpperCase()+t.slice(1)]})}function oZe(t){return t?new Date(t).toLocaleString():"-"}function oK(t){if(!t)return"-";const e=new Date(t),n=new Date,r=e.getTime()-n.getTime(),i=Math.round(r/6e4);if(i<0){const s=Math.abs(i);if(s<60)return`${s}m ago`;const o=Math.floor(s/60);return o<24?`${o}h ago`:`${Math.floor(o/24)}d ago`}else{if(i<60)return`in ${i}m`;const s=Math.floor(i/60);return s<24?`in ${s}h`:`in ${Math.floor(s/24)}d`}}function lZe(){const t=tn(),{showToast:e}=hn(),{t:n}=Vt(),[r,i]=w.useState(""),[s,o]=w.useState(""),[l,c]=w.useState("main"),[u,d]=w.useState(!1),[h,f]=w.useState("daily"),[p,x]=w.useState(!0),[y,b]=w.useState(!0),[v,S]=w.useState(!1),[N,A]=w.useState(!0),[C,T]=w.useState(!1),[k,j]=w.useState(!1),[E,P]=w.useState(""),[U,O]=w.useState(!1),[B,R]=w.useState(null),[G,q]=w.useState(null),z=w.useRef(null);w.useEffect(()=>{if(C||k){const L=D=>(D.preventDefault(),D.returnValue="A backup operation is in progress. Are you sure you want to leave?",D.returnValue);return window.addEventListener("beforeunload",L),()=>window.removeEventListener("beforeunload",L)}},[C,k]);const[K,Y]=w.useState(!1),[oe,$]=w.useState(null),X=w.useRef(null),ee=w.useRef(!1),{data:J,isLoading:_e}=Ze({queryKey:["github-backup-config"],queryFn:re.getGitHubBackupConfig}),{data:pe}=Ze({queryKey:["github-backup-status"],queryFn:re.getGitHubBackupStatus,refetchInterval:fe=>fe.state.data?.is_running?500:1e4}),{data:me}=Ze({queryKey:["github-backup-logs"],queryFn:()=>re.getGitHubBackupLogs(20)}),{data:je}=Ze({queryKey:["cloud-status"],queryFn:re.getCloudStatus}),{data:de}=Ze({queryKey:["printers"],queryFn:re.getPrinters}),ce=DF({queries:(de??[]).map(fe=>({queryKey:["printerStatus",fe.id],queryFn:()=>re.getPrinterStatus(fe.id),staleTime:1e4,refetchInterval:3e4}))}),Se=(de??[]).map((fe,L)=>({printer:fe,connected:ce[L]?.data?.connected??!1})),ie=Se.length,Fe=Se.filter(fe=>fe.connected).length,V=ie>0&&Fe===0,W=Fe>0&&Fe{J&&(i(J.repository_url),c(J.branch),d(J.schedule_enabled),f(J.schedule_type),x(J.backup_kprofiles),b(J.backup_cloud_profiles),S(J.backup_settings),A(J.enabled),o(""),setTimeout(()=>{ee.current=!0},100))},[J]);const ue=w.useCallback(async(fe=!1)=>{if(J?.has_token)try{fe&&s?(await re.saveGitHubBackupConfig({repository_url:r,access_token:s,branch:l,schedule_enabled:u,schedule_type:h,backup_kprofiles:p,backup_cloud_profiles:y,backup_settings:v,enabled:N}),o(""),e("Token updated")):(await re.updateGitHubBackupConfig({repository_url:r,branch:l,schedule_enabled:u,schedule_type:h,backup_kprofiles:p,backup_cloud_profiles:y,backup_settings:v,enabled:N}),e("Settings saved")),t.invalidateQueries({queryKey:["github-backup-config"]}),t.invalidateQueries({queryKey:["github-backup-status"]})}catch(L){e(`Failed to save: ${L.message}`,"error")}},[J?.has_token,r,s,l,u,h,p,y,v,N,t,e]);w.useEffect(()=>{if(!(!ee.current||!J?.has_token))return X.current&&clearTimeout(X.current),X.current=setTimeout(()=>{ue(!1)},500),()=>{X.current&&clearTimeout(X.current)}},[r,l,u,h,p,y,v,N,ue,J?.has_token]),w.useEffect(()=>{if(!(!ee.current||!J?.has_token||!s))return X.current&&clearTimeout(X.current),X.current=setTimeout(()=>{ue(!0)},1e3),()=>{X.current&&clearTimeout(X.current)}},[s,ue,J?.has_token]);const Q=ot({mutationFn:fe=>re.saveGitHubBackupConfig(fe),onSuccess:()=>{t.invalidateQueries({queryKey:["github-backup-config"]}),t.invalidateQueries({queryKey:["github-backup-status"]}),e("GitHub backup enabled"),o(""),ee.current=!0},onError:fe=>{e(`Failed to save: ${fe.message}`,"error")}}),se=ot({mutationFn:re.triggerGitHubBackup,onSuccess:fe=>{t.invalidateQueries({queryKey:["github-backup-status"]}),t.invalidateQueries({queryKey:["github-backup-logs"]}),fe.success?fe.files_changed>0?e(`Backup complete - ${fe.files_changed} files updated`):e("Backup skipped - no changes"):e(`Backup failed: ${fe.message}`,"error")},onError:fe=>{e(`Backup failed: ${fe.message}`,"error")}}),Z=ot({mutationFn:()=>re.clearGitHubBackupLogs(0),onSuccess:fe=>{t.invalidateQueries({queryKey:["github-backup-logs"]}),e(`Cleared ${fe.deleted} logs`)},onError:fe=>{e(`Failed to clear logs: ${fe.message}`,"error")}}),Ne=async()=>{Y(!0),$(null);try{let fe;if(s){if(!r){e("Enter repository URL","error"),Y(!1);return}fe=await re.testGitHubConnection(r,s)}else if(J?.has_token)fe=await re.testGitHubStoredConnection();else{e("Enter repository URL and access token","error"),Y(!1);return}$({success:fe.success,message:fe.message})}catch(fe){$({success:!1,message:fe.message})}finally{Y(!1)}},ve=()=>{if(!r){e("Repository URL is required","error");return}if(!s){e("Access token is required","error");return}Q.mutate({repository_url:r,access_token:s,branch:l,schedule_enabled:u,schedule_type:h,backup_kprofiles:p,backup_cloud_profiles:y,backup_settings:v,enabled:N})};return _e?a.jsx("div",{className:"flex items-center justify-center py-12",children:a.jsx(it,{className:"w-8 h-8 animate-spin text-bambu-green"})}):a.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-6",children:[a.jsxs("div",{className:"space-y-6",children:[a.jsxs(vt,{children:[a.jsx(An,{children:a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx(p3,{className:"w-5 h-5 text-gray-400"}),a.jsx("h2",{className:"text-lg font-semibold text-white",children:"GitHub Backup"})]}),J&&je?.is_authenticated&&a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx("span",{className:"text-sm text-bambu-gray",children:"Enabled"}),a.jsx(zn,{checked:N,onChange:A})]})]})}),a.jsx(Nt,{className:"space-y-4",children:je?.is_authenticated?a.jsxs(a.Fragment,{children:[a.jsx("p",{className:"text-sm text-bambu-gray",children:"Automatically sync your profiles to a private GitHub repository for backup and version history."}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Repository URL"}),a.jsx("input",{type:"text",value:r,onChange:fe=>{i(fe.target.value),$(null)},placeholder:"https://github.com/username/bambuddy-backup",className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none"})]}),a.jsxs("div",{children:[a.jsxs("label",{className:"block text-sm text-bambu-gray mb-1",children:["Personal Access Token ",J?.has_token&&a.jsx("span",{className:"text-green-400",children:"(saved)"})]}),a.jsx("input",{type:"password",value:s,onChange:fe=>{o(fe.target.value),$(null)},placeholder:J?.has_token?"Enter new token to update":"ghp_xxxxxxxxxxxx",className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none"}),a.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:"Fine-grained token with Contents read/write permission"})]}),a.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Branch"}),a.jsx("input",{type:"text",value:l,onChange:fe=>c(fe.target.value),placeholder:"main",className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none"})]}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Auto-backup"}),a.jsxs("select",{value:u?h:"disabled",onChange:fe=>{fe.target.value==="disabled"?d(!1):(d(!0),f(fe.target.value))},className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",children:[a.jsx("option",{value:"disabled",children:"Manual only"}),a.jsx("option",{value:"hourly",children:"Hourly"}),a.jsx("option",{value:"daily",children:"Daily"}),a.jsx("option",{value:"weekly",children:"Weekly"})]})]})]}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm text-bambu-gray mb-2",children:"Include in backup"}),a.jsxs("div",{className:"space-y-2",children:[a.jsxs("label",{className:`flex items-start gap-2 ${V?"cursor-not-allowed opacity-60":"cursor-pointer"}`,children:[a.jsx("input",{type:"checkbox",checked:p,onChange:fe=>x(fe.target.checked),className:"w-4 h-4 mt-0.5 rounded border-bambu-dark-tertiary bg-bambu-dark text-bambu-green focus:ring-bambu-green",disabled:V}),a.jsxs("div",{className:"flex-1",children:[a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx("span",{className:`text-sm ${V?"text-bambu-gray":"text-white"}`,children:"K-Profiles"}),V&&a.jsxs("span",{className:"inline-flex items-center gap-1 px-1.5 py-0.5 rounded text-xs bg-yellow-500/20 text-yellow-400",children:[a.jsx(Cn,{className:"w-3 h-3"}),"No printers connected"]}),W&&a.jsxs("span",{className:"inline-flex items-center gap-1 px-1.5 py-0.5 rounded text-xs bg-yellow-500/20 text-yellow-400",children:[a.jsx(Cn,{className:"w-3 h-3"}),Fe,"/",ie," connected"]})]}),a.jsx("p",{className:"text-xs text-bambu-gray",children:"Pressure advance calibration from connected printers"})]})]}),a.jsxs("label",{className:"flex items-start gap-2 cursor-pointer",children:[a.jsx("input",{type:"checkbox",checked:y,onChange:fe=>b(fe.target.checked),className:"w-4 h-4 mt-0.5 rounded border-bambu-dark-tertiary bg-bambu-dark text-bambu-green focus:ring-bambu-green",disabled:!je?.is_authenticated}),a.jsxs("div",{children:[a.jsx("span",{className:`text-sm ${je?.is_authenticated?"text-white":"text-bambu-gray"}`,children:"Cloud Profiles"}),a.jsx("p",{className:"text-xs text-bambu-gray",children:"Filament, printer, and process presets from Bambu Cloud"})]})]}),a.jsxs("label",{className:"flex items-start gap-2 cursor-pointer",children:[a.jsx("input",{type:"checkbox",checked:v,onChange:fe=>S(fe.target.checked),className:"w-4 h-4 mt-0.5 rounded border-bambu-dark-tertiary bg-bambu-dark text-bambu-green focus:ring-bambu-green"}),a.jsxs("div",{children:[a.jsx("span",{className:"text-white text-sm",children:"App Settings"}),a.jsx("p",{className:"text-xs text-bambu-gray",children:"Bambuddy configuration (complete database)"})]})]})]})]}),a.jsxs("div",{className:"border-t border-bambu-dark-tertiary pt-4 space-y-3",children:[pe?.configured&&a.jsxs("div",{className:"flex items-center justify-between text-sm",children:[a.jsx("div",{className:"flex items-center gap-2 text-bambu-gray",children:pe.last_backup_at?a.jsxs(a.Fragment,{children:[a.jsxs("span",{children:["Last backup: ",oK(pe.last_backup_at)]}),a.jsx(sK,{status:pe.last_backup_status})]}):a.jsx("span",{children:"No backups yet"})}),pe.next_scheduled_run&&a.jsxs("span",{className:"text-bambu-gray",children:[a.jsx(Wn,{className:"w-3 h-3 inline mr-1"}),"Next: ",oK(pe.next_scheduled_run)]})]}),oe&&a.jsxs("div",{className:`text-sm flex items-center gap-1 ${oe.success?"text-green-400":"text-red-400"}`,children:[oe.success?a.jsx(gr,{className:"w-4 h-4"}):a.jsx(ha,{className:"w-4 h-4"}),oe.message]}),a.jsx("div",{className:"flex flex-wrap items-center gap-2",children:pe?.configured?a.jsx(a.Fragment,{children:se.isPending||pe.is_running?a.jsxs("div",{className:"flex items-center gap-2 text-bambu-green",children:[a.jsx(it,{className:"w-4 h-4 animate-spin"}),a.jsx("span",{className:"text-sm",children:pe.progress||"Starting backup..."})]}):a.jsxs(a.Fragment,{children:[a.jsxs(Ce,{variant:"primary",size:"sm",onClick:()=>se.mutate(),disabled:!J?.enabled,children:[a.jsx(so,{className:"w-4 h-4"}),"Backup Now"]}),a.jsxs(Ce,{variant:"secondary",size:"sm",onClick:Ne,disabled:K,children:[K?a.jsx(it,{className:"w-4 h-4 animate-spin"}):a.jsx(kr,{className:"w-4 h-4"}),"Test"]})]})}):a.jsxs(a.Fragment,{children:[a.jsxs(Ce,{variant:"primary",size:"sm",onClick:ve,disabled:Q.isPending||!r||!s,children:[Q.isPending?a.jsx(it,{className:"w-4 h-4 animate-spin"}):a.jsx(gr,{className:"w-4 h-4"}),"Enable Backup"]}),a.jsxs(Ce,{variant:"secondary",size:"sm",onClick:Ne,disabled:K||!r||!s,children:[K?a.jsx(it,{className:"w-4 h-4 animate-spin"}):a.jsx(kr,{className:"w-4 h-4"}),"Test Connection"]})]})})]})]}):a.jsxs("div",{className:"flex items-start gap-2 p-3 bg-yellow-500/10 border border-yellow-500/30 rounded-lg",children:[a.jsx(Cn,{className:"w-4 h-4 text-yellow-400 mt-0.5 flex-shrink-0"}),a.jsx("p",{className:"text-sm text-yellow-400",children:"Bambu Cloud login required. Sign in under Profiles → Cloud Profiles to enable GitHub backup."})]})})]}),me&&me.length>0&&a.jsxs(vt,{children:[a.jsx(An,{children:a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx(N0,{className:"w-5 h-5 text-gray-400"}),a.jsx("h2",{className:"text-lg font-semibold text-white",children:"History"})]}),a.jsxs(Ce,{variant:"ghost",size:"sm",onClick:()=>Z.mutate(),disabled:Z.isPending,children:[a.jsx(Jt,{className:"w-4 h-4"}),"Clear"]})]})}),a.jsx(Nt,{children:a.jsx("div",{className:"overflow-x-auto",children:a.jsxs("table",{className:"w-full text-sm",children:[a.jsx("thead",{children:a.jsxs("tr",{className:"text-bambu-gray border-b border-bambu-dark-tertiary",children:[a.jsx("th",{className:"text-left py-2 px-2",children:"Date"}),a.jsx("th",{className:"text-left py-2 px-2",children:"Status"}),a.jsx("th",{className:"text-left py-2 px-2",children:"Commit"})]})}),a.jsx("tbody",{children:me.slice(0,10).map(fe=>a.jsxs("tr",{className:"border-b border-bambu-dark-tertiary/50 hover:bg-bambu-dark-secondary",children:[a.jsx("td",{className:"py-2 px-2 text-white",children:oZe(fe.started_at)}),a.jsx("td",{className:"py-2 px-2",children:a.jsx(sK,{status:fe.status})}),a.jsx("td",{className:"py-2 px-2",children:fe.commit_sha?a.jsxs("a",{href:`${J?.repository_url}/commit/${fe.commit_sha}`,target:"_blank",rel:"noopener noreferrer",className:"text-bambu-green hover:underline inline-flex items-center gap-1",children:[fe.commit_sha.substring(0,7),a.jsx(Kr,{className:"w-3 h-3"})]}):a.jsx("span",{className:"text-bambu-gray",children:"-"})})]},fe.id))})]})})})]})]}),a.jsx("div",{className:"space-y-6",children:a.jsxs(vt,{children:[a.jsx(An,{children:a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx(Tc,{className:"w-5 h-5 text-gray-400"}),a.jsx("h2",{className:"text-lg font-semibold text-white",children:"Local Backup"})]})}),a.jsxs(Nt,{className:"space-y-4",children:[a.jsx("p",{className:"text-sm text-bambu-gray",children:"Create a complete backup of your Bambuddy data including the database, archives, uploads, and all files."}),a.jsxs("div",{className:"flex items-center justify-between py-3 border-b border-bambu-dark-tertiary",children:[a.jsxs("div",{children:[a.jsx("p",{className:"text-white",children:"Download Backup"}),a.jsx("p",{className:"text-sm text-bambu-gray",children:"Complete backup: database + all files (ZIP)"})]}),a.jsxs(Ce,{variant:"secondary",size:"sm",disabled:C||k,onClick:async()=>{T(!0),P("Preparing backup...");try{P("Creating backup archive... This may take a while for large archives.");const{blob:fe,filename:L}=await re.exportBackup();P("Downloading backup file...");const D=URL.createObjectURL(fe),H=document.createElement("a");H.href=D,H.download=L,H.click(),URL.revokeObjectURL(D),e("Backup downloaded successfully")}catch(fe){e(`Failed to create backup: ${fe instanceof Error?fe.message:"Unknown error"}`,"error")}finally{T(!1),P("")}},children:[a.jsx(di,{className:"w-4 h-4"}),"Download"]})]}),a.jsxs("div",{className:"flex items-center justify-between py-3 border-b border-bambu-dark-tertiary",children:[a.jsxs("div",{children:[a.jsx("p",{className:"text-white",children:n("backup.restoreBackup")}),a.jsx("p",{className:"text-sm text-bambu-gray",children:n("backup.restoreDescription")}),a.jsx("p",{className:"text-xs text-bambu-gray-light mt-1",children:n("backup.restoreNote")})]}),a.jsx("input",{ref:z,type:"file",accept:".zip",className:"hidden",onChange:fe=>{const L=fe.target.files?.[0];L&&(R(L),O(!0)),fe.target.value=""}}),a.jsxs(Ce,{variant:"secondary",size:"sm",disabled:k||C,onClick:()=>z.current?.click(),children:[a.jsx(Fi,{className:"w-4 h-4"}),"Restore"]})]}),G&&a.jsx("div",{className:`p-3 rounded-lg ${G.success?"bg-green-500/10 border border-green-500/30":"bg-red-500/10 border border-red-500/30"}`,children:a.jsxs("div",{className:"flex items-start gap-2 text-sm",children:[G.success?a.jsx(gr,{className:"w-4 h-4 text-green-400 mt-0.5 flex-shrink-0"}):a.jsx(ha,{className:"w-4 h-4 text-red-400 mt-0.5 flex-shrink-0"}),a.jsxs("div",{className:G.success?"text-green-200":"text-red-200",children:[G.message,G.success&&a.jsx("div",{className:"mt-2",children:a.jsxs(Ce,{size:"sm",onClick:()=>window.location.reload(),children:[a.jsx(Ro,{className:"w-3 h-3"}),"Reload Now"]})})]})]})}),a.jsx("div",{className:"p-3 rounded-lg bg-yellow-500/10 border border-yellow-500/30",children:a.jsxs("div",{className:"flex items-start gap-2 text-sm",children:[a.jsx(Cn,{className:"w-4 h-4 text-yellow-400 mt-0.5 flex-shrink-0"}),a.jsxs("div",{className:"text-yellow-200",children:[a.jsx("span",{className:"font-medium",children:"Restore replaces all data."})," ",a.jsx("span",{className:"text-yellow-200/70",children:"Your current database and files will be completely replaced. A restart is required after restore."})]})]})})]})]})}),U&&B&&a.jsx(vn,{title:"Restore Backup",message:`Are you sure you want to restore from "${B.name}"? This will completely replace your current database and all files. The application will need to be restarted after restore.`,confirmText:"Restore Backup",variant:"danger",onConfirm:async()=>{O(!1),j(!0),q(null);try{P("Uploading backup file...");const fe=await re.importBackup(B);q(fe),fe.success?e("Backup restored. Please restart Bambuddy.","success"):e(fe.message,"error")}catch(fe){const L=fe instanceof Error?fe.message:"Failed to restore backup";q({success:!1,message:L}),e(L,"error")}finally{j(!1),P(""),R(null)}},onCancel:()=>{O(!1),R(null)}}),(C||k)&&a.jsx("div",{className:"fixed inset-0 bg-black/80 flex items-center justify-center z-[100]",children:a.jsxs("div",{className:"bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-xl p-8 max-w-md w-full mx-4 text-center",children:[a.jsx("div",{className:"flex justify-center mb-4",children:a.jsxs("div",{className:"relative",children:[a.jsx("div",{className:"w-16 h-16 border-4 border-bambu-dark-tertiary rounded-full"}),a.jsx("div",{className:"w-16 h-16 border-4 border-bambu-green border-t-transparent rounded-full absolute inset-0 animate-spin"})]})}),a.jsx("h3",{className:"text-xl font-semibold text-white mb-2",children:C?"Creating Backup":"Restoring Backup"}),a.jsx("p",{className:"text-bambu-gray mb-4",children:E||(C?"Preparing...":"Processing...")}),a.jsx("div",{className:"p-3 rounded-lg bg-yellow-500/10 border border-yellow-500/30",children:a.jsxs("div",{className:"flex items-start gap-2 text-sm",children:[a.jsx(Cn,{className:"w-4 h-4 text-yellow-400 mt-0.5 flex-shrink-0"}),a.jsx("p",{className:"text-yellow-200 text-left",children:"Please do not close this page or navigate away. This operation may take several minutes for large backups."})]})})]})})]})}function cZe(){const{t}=Vt(),{showToast:e}=hn(),n=tn(),[r,i]=w.useState({smtp_host:"",smtp_port:587,smtp_username:"",smtp_password:"",smtp_security:"starttls",smtp_auth_enabled:!0,smtp_from_email:"",smtp_from_name:"BamBuddy"}),[s,o]=w.useState(""),{data:l,isLoading:c}=Ze({queryKey:["smtpSettings"],queryFn:()=>re.getSMTPSettings()}),{data:u}=Ze({queryKey:["advancedAuthStatus"],queryFn:()=>re.getAdvancedAuthStatus()});w.useEffect(()=>{l&&i({...l,smtp_password:""})},[l]);const d=ot({mutationFn:b=>re.saveSMTPSettings(b),onSuccess:()=>{n.invalidateQueries({queryKey:["smtpSettings"]}),n.invalidateQueries({queryKey:["advancedAuthStatus"]}),e(t("settings.email.success.settingsSaved"),"success")},onError:b=>{e(b.message,"error")}}),h=ot({mutationFn:b=>re.testSMTP(b),onSuccess:b=>{e(b.message,b.success?"success":"error")},onError:b=>{e(b.message,"error")}}),f=ot({mutationFn:b=>b?re.enableAdvancedAuth():re.disableAdvancedAuth(),onSuccess:b=>{n.invalidateQueries({queryKey:["advancedAuthStatus"]}),e(b.message,"success")},onError:b=>{e(b.message,"error")}}),p=()=>{if(!r.smtp_host||!r.smtp_from_email){e(t("settings.email.errors.requiredFields"),"error");return}if(r.smtp_auth_enabled&&!r.smtp_username){e(t("settings.email.errors.usernameRequired"),"error");return}d.mutate(r)},x=()=>{if(!s){e(t("settings.email.errors.enterTestEmail"),"error");return}if(!r.smtp_host||!r.smtp_from_email){e(t("settings.email.errors.smtpServerAndEmail"),"error");return}if(r.smtp_auth_enabled&&(!r.smtp_username||!r.smtp_password)){e(t("settings.email.errors.usernamePasswordRequired"),"error");return}h.mutate({smtp_host:r.smtp_host,smtp_port:r.smtp_port,smtp_username:r.smtp_username,smtp_password:r.smtp_password,smtp_security:r.smtp_security,smtp_auth_enabled:r.smtp_auth_enabled,smtp_from_email:r.smtp_from_email,test_recipient:s})},y=()=>{if(!u?.advanced_auth_enabled&&!u?.smtp_configured){e(t("settings.email.errors.configureSmtpFirst"),"error");return}f.mutate(!u?.advanced_auth_enabled)};return c?a.jsx("div",{className:"flex items-center justify-center p-12",children:a.jsx(it,{className:"w-8 h-8 animate-spin text-bambu-green"})}):a.jsxs("div",{className:"space-y-6",children:[u?.smtp_configured&&a.jsxs(vt,{children:[a.jsx(An,{children:a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx(k0,{className:"w-5 h-5 text-bambu-green"}),a.jsx("h2",{className:"text-lg font-semibold text-white",children:t("settings.email.advancedAuth")||"Advanced Authentication"})]}),a.jsx(Ce,{onClick:y,disabled:f.isPending,variant:u?.advanced_auth_enabled?"danger":"primary",children:u?.advanced_auth_enabled?a.jsxs(a.Fragment,{children:[a.jsx(QS,{className:"w-4 h-4"}),t("settings.email.disable")||"Disable"]}):a.jsxs(a.Fragment,{children:[a.jsx(Vm,{className:"w-4 h-4"}),t("settings.email.enable")||"Enable"]})})]})}),a.jsx(Nt,{children:a.jsx("div",{className:"space-y-4",children:u?.advanced_auth_enabled?a.jsx("div",{className:"bg-green-500/10 border border-green-500/30 rounded-lg p-4",children:a.jsxs("div",{className:"flex items-start gap-3",children:[a.jsx(gr,{className:"w-5 h-5 text-green-400 mt-0.5 flex-shrink-0"}),a.jsxs("div",{className:"space-y-2",children:[a.jsx("p",{className:"text-white font-medium",children:t("settings.email.advancedAuthEnabled")||"Advanced Authentication is enabled"}),a.jsxs("ul",{className:"text-sm text-green-300 space-y-1 list-disc list-inside",children:[a.jsx("li",{children:t("settings.email.feature1")||"Passwords are auto-generated and emailed to new users"}),a.jsx("li",{children:t("settings.email.feature2")||"Users can login with username or email"}),a.jsx("li",{children:t("settings.email.feature3")||"Forgot password feature is available"}),a.jsx("li",{children:t("settings.email.feature4")||"Admins can reset user passwords via email"})]})]})]})}):a.jsx("div",{className:"bg-yellow-500/10 border border-yellow-500/30 rounded-lg p-4",children:a.jsxs("div",{className:"flex items-start gap-3",children:[a.jsx(Cn,{className:"w-5 h-5 text-yellow-400 mt-0.5 flex-shrink-0"}),a.jsxs("div",{className:"space-y-2",children:[a.jsx("p",{className:"text-white font-medium",children:t("settings.email.advancedAuthDisabled")||"Advanced Authentication is disabled"}),a.jsx("p",{className:"text-sm text-yellow-300",children:t("settings.email.advancedAuthDisabledDesc")||"Enable advanced authentication to activate email-based features for user management."})]})]})})})})]}),a.jsxs(vt,{children:[a.jsx(An,{children:a.jsx("h2",{className:"text-lg font-semibold text-white",children:t("settings.email.smtpSettings")||"SMTP Configuration"})}),a.jsx(Nt,{children:a.jsxs("div",{className:"space-y-4",children:[a.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[a.jsxs("div",{children:[a.jsxs("label",{className:"block text-sm font-medium text-white mb-2",children:[t("settings.email.smtpHost")||"SMTP Server"," *"]}),a.jsx("input",{type:"text",value:r.smtp_host,onChange:b=>i({...r,smtp_host:b.target.value}),placeholder:"smtp.gmail.com",className:"w-full px-4 py-3 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg text-white placeholder-bambu-gray focus:outline-none focus:ring-2 focus:ring-bambu-green/50 focus:border-bambu-green transition-colors"})]}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm font-medium text-white mb-2",children:t("settings.email.smtpPort")||"SMTP Port"}),a.jsx("input",{type:"number",value:r.smtp_port,onChange:b=>i({...r,smtp_port:parseInt(b.target.value)||587}),placeholder:"587",className:"w-full px-4 py-3 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg text-white placeholder-bambu-gray focus:outline-none focus:ring-2 focus:ring-bambu-green/50 focus:border-bambu-green transition-colors"})]})]}),a.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm font-medium text-white mb-2",children:t("settings.email.security")||"Security"}),a.jsxs("select",{value:r.smtp_security,onChange:b=>i({...r,smtp_security:b.target.value}),className:"w-full px-4 py-3 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg text-white focus:outline-none focus:ring-2 focus:ring-bambu-green/50 focus:border-bambu-green transition-colors",children:[a.jsx("option",{value:"starttls",children:t("settings.email.securityOptions.starttls")}),a.jsx("option",{value:"ssl",children:t("settings.email.securityOptions.ssl")}),a.jsx("option",{value:"none",children:t("settings.email.securityOptions.none")})]})]}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm font-medium text-white mb-2",children:t("settings.email.authentication")||"Authentication"}),a.jsxs("select",{value:r.smtp_auth_enabled?"true":"false",onChange:b=>i({...r,smtp_auth_enabled:b.target.value==="true"}),className:"w-full px-4 py-3 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg text-white focus:outline-none focus:ring-2 focus:ring-bambu-green/50 focus:border-bambu-green transition-colors",children:[a.jsx("option",{value:"true",children:t("settings.email.authOptions.enabled")}),a.jsx("option",{value:"false",children:t("settings.email.authOptions.disabled")})]})]})]}),r.smtp_auth_enabled&&a.jsxs(a.Fragment,{children:[a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm font-medium text-white mb-2",children:t("settings.email.username")||"Username"}),a.jsx("input",{type:"text",value:r.smtp_username||"",onChange:b=>i({...r,smtp_username:b.target.value}),placeholder:"your.email@gmail.com",className:"w-full px-4 py-3 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg text-white placeholder-bambu-gray focus:outline-none focus:ring-2 focus:ring-bambu-green/50 focus:border-bambu-green transition-colors"})]}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm font-medium text-white mb-2",children:t("settings.email.password")||"Password"}),a.jsx("input",{type:"password",value:r.smtp_password||"",onChange:b=>i({...r,smtp_password:b.target.value}),placeholder:l?"••••••••":"App password",className:"w-full px-4 py-3 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg text-white placeholder-bambu-gray focus:outline-none focus:ring-2 focus:ring-bambu-green/50 focus:border-bambu-green transition-colors"})]})]}),a.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[a.jsxs("div",{children:[a.jsxs("label",{className:"block text-sm font-medium text-white mb-2",children:[t("settings.email.fromEmail")||"From Email"," *"]}),a.jsx("input",{type:"email",value:r.smtp_from_email,onChange:b=>i({...r,smtp_from_email:b.target.value}),placeholder:"your@email.com",className:"w-full px-4 py-3 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg text-white placeholder-bambu-gray focus:outline-none focus:ring-2 focus:ring-bambu-green/50 focus:border-bambu-green transition-colors"})]}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm font-medium text-white mb-2",children:t("settings.email.fromName")||"From Name"}),a.jsx("input",{type:"text",value:r.smtp_from_name,onChange:b=>i({...r,smtp_from_name:b.target.value}),placeholder:"BamBuddy",className:"w-full px-4 py-3 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg text-white placeholder-bambu-gray focus:outline-none focus:ring-2 focus:ring-bambu-green/50 focus:border-bambu-green transition-colors"})]})]}),a.jsx("div",{className:"flex gap-2",children:a.jsx(Ce,{onClick:p,disabled:d.isPending,className:"flex-1",children:d.isPending?a.jsxs(a.Fragment,{children:[a.jsx(it,{className:"w-4 h-4 animate-spin"}),t("settings.email.saving")||"Saving..."]}):t("settings.email.save")||"Save Settings"})})]})})]}),a.jsxs(vt,{children:[a.jsx(An,{children:a.jsx("h2",{className:"text-lg font-semibold text-white",children:t("settings.email.testConnection")||"Test SMTP Connection"})}),a.jsx(Nt,{children:a.jsxs("div",{className:"space-y-4",children:[a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm font-medium text-white mb-2",children:t("settings.email.testRecipient")||"Test Recipient Email"}),a.jsx("input",{type:"email",value:s,onChange:b=>o(b.target.value),placeholder:"test@example.com",className:"w-full px-4 py-3 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg text-white placeholder-bambu-gray focus:outline-none focus:ring-2 focus:ring-bambu-green/50 focus:border-bambu-green transition-colors"})]}),a.jsx(Ce,{onClick:x,disabled:h.isPending,variant:"secondary",children:h.isPending?a.jsxs(a.Fragment,{children:[a.jsx(it,{className:"w-4 h-4 animate-spin"}),t("settings.email.sending")||"Sending..."]}):a.jsxs(a.Fragment,{children:[a.jsx(lC,{className:"w-4 h-4"}),t("settings.email.sendTest")||"Send Test Email"]})})]})})]})]})}const uZe={get:"bg-blue-500/20 text-blue-400 border-blue-500/30",post:"bg-green-500/20 text-green-400 border-green-500/30",put:"bg-yellow-500/20 text-yellow-400 border-yellow-500/30",patch:"bg-orange-500/20 text-orange-400 border-orange-500/30",delete:"bg-red-500/20 text-red-400 border-red-500/30"};function dZe(t,e){const n=e.replace("#/","").split("/");let r=t;for(const i of n)r=r[i];return r}function Wy(t,e,n=0){if(n>5)return"...";if(e.$ref)return Wy(t,dZe(t,e.$ref),n+1);if(e.allOf){const r={};for(const i of e.allOf){const s=Wy(t,i,n+1);typeof s=="object"&&s!==null&&Object.assign(r,s)}return r}if(e.example!==void 0)return e.example;if(e.default!==void 0)return e.default;switch(e.type){case"string":return e.enum?e.enum[0]:"string";case"integer":case"number":return 0;case"boolean":return!1;case"array":return e.items?[Wy(t,e.items,n+1)]:[];case"object":if(e.properties){const r={};for(const[i,s]of Object.entries(e.properties))r[i]=Wy(t,s,n+1);return r}return{};default:return null}}function hZe({path:t,method:e,spec:n,schema:r,apiKey:i}){const[s,o]=w.useState(!1),[l,c]=w.useState({}),[u,d]=w.useState(""),[h,f]=w.useState(null),[p,x]=w.useState(!1),[y,b]=w.useState(!1);w.useEffect(()=>{if(s&&n.parameters){const j={};for(const E of n.parameters)E.schema?.default!==void 0&&(j[E.name]=String(E.schema.default));c(E=>({...j,...E}))}},[s,n.parameters]),w.useEffect(()=>{if(s&&n.requestBody?.content?.["application/json"]?.schema&&!u){const j=n.requestBody.content["application/json"].schema,E=Wy(r,j);d(JSON.stringify(E,null,2))}},[s,n.requestBody,r,u]);const S=(()=>{const j=[];for(const E of n.parameters||[])if(E.in==="path"||E.required){const P=l[E.name];(P===void 0||P==="")&&j.push(E.name)}return j})(),N=async()=>{if(S.length>0){f({status:0,statusText:"Validation Error",headers:{},body:`Missing required parameters: ${S.join(", ")}`,duration:0});return}x(!0),f(null);try{let j=t;const E=new URLSearchParams;for(const oe of n.parameters||[]){const $=l[oe.name];$!==void 0&&$!==""&&(oe.in==="path"?j=j.replace(`{${oe.name}}`,encodeURIComponent($)):oe.in==="query"&&E.append(oe.name,$))}const P=E.toString(),U=`${j}${P?`?${P}`:""}`,O={"Content-Type":"application/json"};i&&(O["X-API-Key"]=i);const B={method:e.toUpperCase(),headers:O};["post","put","patch"].includes(e)&&u&&(B.body=u);const R=performance.now(),G=await fetch(U,B),q=Math.round(performance.now()-R),z={};G.headers.forEach((oe,$)=>{z[$]=oe});let K;G.headers.get("content-type")?.includes("application/json")?K=await G.json():K=await G.text(),f({status:G.status,statusText:G.statusText,headers:z,body:K,duration:q})}catch(j){f({status:0,statusText:"Network Error",headers:{},body:j instanceof Error?j.message:"Unknown error",duration:0})}finally{x(!1)}},A=async()=>{if(h){const j=typeof h.body=="string"?h.body:JSON.stringify(h.body,null,2);try{await navigator.clipboard.writeText(j),b(!0),setTimeout(()=>b(!1),2e3)}catch{const E=document.createElement("textarea");E.value=j,E.style.position="fixed",E.style.left="-999999px",document.body.appendChild(E),E.select(),document.execCommand("copy"),document.body.removeChild(E),b(!0),setTimeout(()=>b(!1),2e3)}}},C=(n.parameters||[]).filter(j=>j.in==="path"),T=(n.parameters||[]).filter(j=>j.in==="query"),k=["post","put","patch"].includes(e)&&n.requestBody;return a.jsxs("div",{className:"border border-bambu-dark-tertiary rounded-lg overflow-hidden",children:[a.jsxs("button",{onClick:()=>o(!s),className:"w-full flex items-center gap-3 p-3 hover:bg-bambu-dark-tertiary/50 transition-colors text-left",children:[s?a.jsx(nr,{className:"w-4 h-4 text-bambu-gray flex-shrink-0"}):a.jsx(pa,{className:"w-4 h-4 text-bambu-gray flex-shrink-0"}),a.jsx("span",{className:`px-2 py-0.5 text-xs font-mono font-semibold uppercase rounded border ${uZe[e]||"bg-gray-500/20 text-gray-400"}`,children:e}),a.jsx("code",{className:"text-sm text-white font-mono flex-1 truncate",children:t}),n.summary&&a.jsx("span",{className:"text-sm text-bambu-gray truncate max-w-[40%]",children:n.summary})]}),s&&a.jsxs("div",{className:"border-t border-bambu-dark-tertiary p-4 space-y-4 bg-bambu-dark/50",children:[n.description&&a.jsx("p",{className:"text-sm text-bambu-gray",children:n.description}),C.length>0&&a.jsxs("div",{className:"space-y-2",children:[a.jsx("h4",{className:"text-sm font-medium text-white",children:"Path Parameters"}),a.jsx("div",{className:"space-y-2",children:C.map(j=>a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsxs("label",{className:"text-sm text-bambu-gray w-32 flex-shrink-0",children:[j.name,j.required&&a.jsx("span",{className:"text-red-400 ml-1",children:"*"})]}),a.jsx("input",{type:"text",value:l[j.name]||"",onChange:E=>c(P=>({...P,[j.name]:E.target.value})),placeholder:j.description||j.schema?.type||"value",className:"flex-1 px-2 py-1 bg-bambu-dark border border-bambu-dark-tertiary rounded text-white text-sm font-mono focus:border-bambu-green focus:outline-none"})]},j.name))})]}),T.length>0&&a.jsxs("div",{className:"space-y-2",children:[a.jsx("h4",{className:"text-sm font-medium text-white",children:"Query Parameters"}),a.jsx("div",{className:"space-y-2",children:T.map(j=>a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsxs("label",{className:"text-sm text-bambu-gray w-32 flex-shrink-0",children:[j.name,j.required&&a.jsx("span",{className:"text-red-400 ml-1",children:"*"})]}),j.schema?.enum?a.jsxs("select",{value:l[j.name]||"",onChange:E=>c(P=>({...P,[j.name]:E.target.value})),className:"flex-1 px-2 py-1 bg-bambu-dark border border-bambu-dark-tertiary rounded text-white text-sm focus:border-bambu-green focus:outline-none",children:[a.jsx("option",{value:"",children:"-- Select --"}),j.schema.enum.map(E=>a.jsx("option",{value:E,children:E},E))]}):a.jsx("input",{type:"text",value:l[j.name]||"",onChange:E=>c(P=>({...P,[j.name]:E.target.value})),placeholder:j.description||j.schema?.type||"value",className:"flex-1 px-2 py-1 bg-bambu-dark border border-bambu-dark-tertiary rounded text-white text-sm font-mono focus:border-bambu-green focus:outline-none"})]},j.name))})]}),k&&a.jsxs("div",{className:"space-y-2",children:[a.jsx("h4",{className:"text-sm font-medium text-white",children:"Request Body"}),a.jsx("textarea",{value:u,onChange:j=>d(j.target.value),rows:8,className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white text-sm font-mono focus:border-bambu-green focus:outline-none resize-y",placeholder:"JSON request body..."})]}),a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsxs(Ce,{onClick:N,disabled:p,children:[p?a.jsx(it,{className:"w-4 h-4 animate-spin"}):a.jsx(so,{className:"w-4 h-4"}),"Execute"]}),S.length>0&&a.jsxs("span",{className:"text-xs text-yellow-400 flex items-center gap-1",children:[a.jsx(Hi,{className:"w-3 h-3"}),"Fill in: ",S.join(", ")]})]}),h&&a.jsxs("div",{className:"space-y-2",children:[a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsxs("h4",{className:"text-sm font-medium text-white flex items-center gap-2",children:["Response",a.jsxs("span",{className:`px-2 py-0.5 text-xs rounded ${h.status>=200&&h.status<300?"bg-green-500/20 text-green-400":h.status>=400?"bg-red-500/20 text-red-400":"bg-yellow-500/20 text-yellow-400"}`,children:[h.status," ",h.statusText]}),a.jsxs("span",{className:"text-xs text-bambu-gray",children:[h.duration,"ms"]})]}),a.jsx(Ce,{variant:"secondary",size:"sm",onClick:A,children:y?a.jsx(gr,{className:"w-3 h-3 text-green-400"}):a.jsx(Kl,{className:"w-3 h-3"})})]}),a.jsx("pre",{className:"p-3 bg-bambu-dark rounded-lg text-sm font-mono text-white overflow-auto max-h-96 border border-bambu-dark-tertiary",children:typeof h.body=="string"?h.body:JSON.stringify(h.body,null,2)})]})]})]})}function mZe({apiKey:t=""}){const[e,n]=w.useState(null),[r,i]=w.useState(!0),[s,o]=w.useState(null),[l,c]=w.useState(new Set),[u,d]=w.useState("");if(w.useEffect(()=>{async function b(){try{const v=await fetch("/openapi.json");if(!v.ok)throw new Error("Failed to fetch OpenAPI schema");const S=await v.json();n(S)}catch(v){o(v instanceof Error?v.message:"Unknown error")}finally{i(!1)}}b()},[]),r)return a.jsx("div",{className:"flex justify-center py-12",children:a.jsx(it,{className:"w-8 h-8 text-bambu-green animate-spin"})});if(s||!e)return a.jsx(vt,{children:a.jsx(Nt,{className:"py-8",children:a.jsxs("div",{className:"text-center text-red-400",children:[a.jsx(Hi,{className:"w-12 h-12 mx-auto mb-3 opacity-50"}),a.jsx("p",{children:"Failed to load API schema"}),a.jsx("p",{className:"text-sm text-bambu-gray mt-1",children:s})]})})});const h={};for(const[b,v]of Object.entries(e.paths))for(const[S,N]of Object.entries(v)){if(S==="parameters")continue;const A=N.tags||["Other"];for(const C of A)h[C]||(h[C]=[]),h[C].push({path:b,method:S,spec:N})}const f=Object.entries(h).map(([b,v])=>{if(!u)return{tag:b,endpoints:v};const S=v.filter(({path:N,method:A,spec:C})=>{const T=u.toLowerCase();return N.toLowerCase().includes(T)||A.toLowerCase().includes(T)||(C.summary?.toLowerCase()||"").includes(T)||(C.description?.toLowerCase()||"").includes(T)});return{tag:b,endpoints:S}}).filter(({endpoints:b})=>b.length>0).sort((b,v)=>b.tag.localeCompare(v.tag)),p=b=>{c(v=>{const S=new Set(v);return S.has(b)?S.delete(b):S.add(b),S})},x=()=>{c(new Set(f.map(b=>b.tag)))},y=()=>{c(new Set)};return a.jsxs("div",{className:"space-y-4",children:[a.jsxs("div",{className:"flex items-center justify-between gap-4",children:[a.jsx("div",{className:"flex-1",children:a.jsx("input",{type:"text",value:u,onChange:b=>d(b.target.value),placeholder:"Search endpoints...",className:"w-full max-w-md px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none"})}),a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx(Ce,{variant:"secondary",size:"sm",onClick:x,children:"Expand All"}),a.jsx(Ce,{variant:"secondary",size:"sm",onClick:y,children:"Collapse All"}),a.jsxs("a",{href:"/docs",target:"_blank",rel:"noopener noreferrer",className:"flex items-center gap-1 text-sm text-bambu-green hover:underline",children:[a.jsx(Kr,{className:"w-4 h-4"}),"Swagger UI"]})]})]}),a.jsxs("p",{className:"text-sm text-bambu-gray",children:[f.reduce((b,v)=>b+v.endpoints.length,0)," endpoints in ",f.length," categories"]}),a.jsx("div",{className:"space-y-3",children:f.map(({tag:b,endpoints:v})=>a.jsxs(vt,{children:[a.jsx("button",{onClick:()=>p(b),className:"w-full flex items-center justify-between p-4 hover:bg-bambu-dark-tertiary/30 transition-colors text-left",children:a.jsxs("div",{className:"flex items-center gap-2",children:[l.has(b)?a.jsx(nr,{className:"w-5 h-5 text-bambu-gray"}):a.jsx(pa,{className:"w-5 h-5 text-bambu-gray"}),a.jsx("h3",{className:"text-base font-semibold text-white capitalize",children:b.replace(/-/g," ")}),a.jsx("span",{className:"text-xs bg-bambu-dark-tertiary px-2 py-0.5 rounded-full text-bambu-gray",children:v.length})]})}),l.has(b)&&a.jsx(Nt,{className:"pt-0 space-y-2",children:v.map(({path:S,method:N,spec:A})=>a.jsx(hZe,{path:S,method:N,spec:A,schema:e,apiKey:t},`${N}-${S}`))})]},b))})]})}const fZe=["general","network","plugs","notifications","filament","apikeys","virtual-printer","users","backup"],pZe={database:"bg-blue-600",library_files:"bg-green-500",library_thumbnails:"bg-teal-500",library_other:"bg-emerald-700",archive_timelapses:"bg-red-500",archive_thumbnails:"bg-amber-500",archive_files:"bg-sky-500",virtual_printer_uploads:"bg-purple-500",virtual_printer_upload_cache:"bg-fuchsia-500",virtual_printer_certs:"bg-violet-500",virtual_printer_other:"bg-purple-700",downloads:"bg-cyan-500",plate_calibration:"bg-lime-500",logs:"bg-orange-500",other_data:"bg-yellow-500"},lK=["bg-blue-500","bg-green-500","bg-yellow-500","bg-red-500","bg-orange-500","bg-teal-500","bg-cyan-500","bg-purple-500"],cK=(t,e)=>pZe[t]||lK[e%lK.length];function gZe(){const t=tn(),e=$c(),[n,r]=kF(),{t:i,i18n:s}=Vt(),{showToast:o}=hn(),{authEnabled:l,user:c,refreshAuth:u}=Ir(),{mode:d,darkStyle:h,darkBackground:f,darkAccent:p,lightStyle:x,lightBackground:y,lightAccent:b,setDarkStyle:v,setDarkBackground:S,setDarkAccent:N,setLightStyle:A,setLightBackground:C,setLightAccent:T}=rp(),[k,j]=w.useState(null),[E,P]=w.useState(!1),[U,O]=w.useState(null),[B,R]=w.useState(!1),[G,q]=w.useState(null),[z,K]=w.useState(null),[Y,oe]=w.useState(!1),[$,X]=w.useState(AX()),ee=n.get("tab"),J=ee==="email",_e=J?"users":ee&&fZe.includes(ee)?ee:"general",[pe,me]=w.useState(_e),[je,de]=w.useState(J?"email":"users"),ce=ae=>{me(ae),ae==="users"&&de("users"),ae==="general"?n.delete("tab"):n.set("tab",ae),r(n,{replace:!0})},[Se,ie]=w.useState(!1),[Fe,V]=w.useState(""),[W,ue]=w.useState({can_queue:!0,can_control_printer:!1,can_read_status:!0}),[Q,se]=w.useState(null),[Z,Ne]=w.useState(null),[ve,fe]=w.useState(""),[L,D]=w.useState(!1),[H,he]=w.useState(!1),[xe,be]=w.useState(null),[Ue,Oe]=w.useState(!1),[Qe,rt]=w.useState(!1),[we,ye]=w.useState(!1),[le,Le]=w.useState({currentPassword:"",newPassword:"",confirmPassword:""}),[Me,$e]=w.useState(!1),[Ae,Je]=w.useState(!1),[Pe,Xe]=w.useState(!1),[De,Re]=w.useState(!1),[qe,pt]=w.useState(null),[At,Rt]=w.useState(null),[Wt,Tt]=w.useState(null),[Ie,xt]=w.useState(!1),[wt,Bt]=w.useState({username:"",password:"",email:"",confirmPassword:"",role:"user",group_ids:[]}),[Tn,fr]=w.useState(!1),[Zn,Jn]=w.useState(null),[Pn,cr]=w.useState(null),[jn,ai]=w.useState({name:"",description:"",permissions:[]}),[ne,He]=w.useState(new Set),[et,lt]=w.useState(null),[dt,Lt]=w.useState(!1),[ge,ze]=w.useState({}),[Ge,Ve]=w.useState({}),Ee=ae=>{X(ae),ege(ae),o(i("settings.toast.settingsSaved"),"success")},st=()=>{localStorage.removeItem("sidebarOrder"),window.location.reload()},{data:tt,isLoading:at}=Ze({queryKey:["settings"],queryFn:re.getSettings}),{data:Mt,isLoading:Kt,isFetching:Ot}=Ze({queryKey:["storage-usage"],queryFn:()=>re.getStorageUsage(),enabled:pe==="general",staleTime:1/0,refetchInterval:!1,refetchOnWindowFocus:!1,refetchOnReconnect:!1}),jt=async()=>{Je(!0);try{const ae=await re.getStorageUsage({refresh:!0});t.setQueryData(["storage-usage"],ae)}catch(ae){const _t=ae instanceof Error?ae.message:"Failed to refresh storage usage";o(_t,"error")}finally{Je(!1)}},{data:Ht,isLoading:Zt}=Ze({queryKey:["smart-plugs"],queryFn:re.getSmartPlugs}),{data:nn,isLoading:Mn}=Ze({queryKey:["smart-plugs-energy",Ht?.map(ae=>ae.id)],queryFn:async()=>{if(!Ht||Ht.length===0)return null;const ae=await Promise.all(Ht.filter(Ns=>Ns.enabled).map(async Ns=>{try{const ks=await re.getSmartPlugStatus(Ns.id);return{plug:Ns,status:ks}}catch{return{plug:Ns,status:null}}}));let _t=0,Gn=0,lr=0,Io=0,_d=0;for(const{plug:Ns,status:ks}of ae){const VM=Ns.plug_type==="mqtt"&&ks?.energy?.power!=null;(ks?.reachable||VM)&&ks?.energy&&(_d++,ks.energy?.power!=null&&(_t+=ks.energy.power),ks.energy?.today!=null&&(Gn+=ks.energy.today),ks.energy?.yesterday!=null&&(lr+=ks.energy.yesterday),ks.energy?.total!=null&&(Io+=ks.energy.total))}return{totalPower:_t,totalToday:Gn,totalYesterday:lr,totalLifetime:Io,reachableCount:_d,totalPlugs:Ht.filter(Ns=>Ns.enabled).length}},enabled:pe==="plugs"&&!!Ht&&Ht.length>0,refetchInterval:pe==="plugs"?1e4:!1}),{data:pn,isLoading:Xt}=Ze({queryKey:["notification-providers"],queryFn:re.getNotificationProviders}),{data:sn,isLoading:fn}=Ze({queryKey:["api-keys"],queryFn:re.getAPIKeys}),Mr=ot({mutationFn:ae=>re.createAPIKey(ae),onSuccess:ae=>{se(ae.key||null),ie(!1),V(""),t.invalidateQueries({queryKey:["api-keys"]}),o(i("settings.toast.apiKeyCreated"))},onError:ae=>{o(`Failed to create API key: ${ae.message}`,"error")}}),Qr=ot({mutationFn:ae=>re.deleteAPIKey(ae),onSuccess:()=>{t.invalidateQueries({queryKey:["api-keys"]}),o(i("settings.toast.apiKeyDeleted"))},onError:ae=>{o(`Failed to delete API key: ${ae.message}`,"error")}}),{data:gn}=Ze({queryKey:["printers"],queryFn:re.getPrinters}),{data:Zr,isLoading:Kn}=Ze({queryKey:["notification-templates"],queryFn:re.getNotificationTemplates}),{data:vi}=Ze({queryKey:["virtual-printer-settings"],queryFn:ZS.getSettings,refetchInterval:1e4}),mi=vi?.status?.running??!1,{data:fi}=Ze({queryKey:["ffmpeg-status"],queryFn:re.checkFfmpeg}),{data:bt}=Ze({queryKey:["version"],queryFn:re.getVersion}),{data:Et,refetch:Hn,isRefetching:kt}=Ze({queryKey:["updateCheck"],queryFn:re.checkForUpdates,enabled:tt?.check_updates!==!1,staleTime:300*1e3}),{data:Nn,refetch:si}=Ze({queryKey:["updateStatus"],queryFn:re.getUpdateStatus,refetchInterval:ae=>{const _t=ae.state.data;return _t?.status==="downloading"||_t?.status==="installing"?1e3:!1}}),{data:Fn}=Ze({queryKey:["mqtt-status"],queryFn:re.getMQTTStatus,refetchInterval:pe==="network"?5e3:!1}),{data:sa}=Ze({queryKey:["github-backup-status"],queryFn:re.getGitHubBackupStatus}),{data:ka}=Ze({queryKey:["cloud-status"],queryFn:re.getCloudStatus}),{data:zt={advanced_auth_enabled:!1,smtp_configured:!1}}=Ze({queryKey:["advancedAuthStatus"],queryFn:()=>re.getAdvancedAuthStatus()}),{hasPermission:dn}=Ir(),{data:as=[],isLoading:Ca}=Ze({queryKey:["users"],queryFn:()=>re.getUsers(),enabled:l&&dn("users:read")}),{data:Gi=[],isLoading:kl}=Ze({queryKey:["groups"],queryFn:()=>re.getGroups(),enabled:l&&dn("groups:read")}),{data:Ba}=Ze({queryKey:["permissions"],queryFn:()=>re.getPermissions(),enabled:l&&dn("groups:read")}),wi=ot({mutationFn:ae=>re.createUser(ae),onSuccess:()=>{t.invalidateQueries({queryKey:["users"]}),t.invalidateQueries({queryKey:["groups"]}),Xe(!1),Bt({username:"",password:"",email:"",confirmPassword:"",role:"user",group_ids:[]}),o(i("settings.toast.userCreated"))},onError:ae=>{o(ae.message,"error")}}),_i=ot({mutationFn:({id:ae,data:_t})=>re.updateUser(ae,_t),onSuccess:()=>{t.invalidateQueries({queryKey:["users"]}),t.invalidateQueries({queryKey:["groups"]}),Re(!1),pt(null),Bt({username:"",password:"",email:"",confirmPassword:"",role:"user",group_ids:[]}),o(i("settings.toast.userUpdated"))},onError:ae=>{o(ae.message,"error")}}),Ur=ot({mutationFn:({id:ae,deleteItems:_t})=>re.deleteUser(ae,_t),onSuccess:()=>{t.invalidateQueries({queryKey:["users"]}),o(i("settings.toast.userDeleted")),Rt(null),Tt(null)},onError:ae=>{o(ae.message,"error")}}),vr=ot({mutationFn:ae=>re.resetUserPassword({user_id:ae}),onSuccess:ae=>{o(ae.message,"success")},onError:ae=>{o(ae.message,"error")}}),Cl=async ae=>{Rt(ae),xt(!0);try{const _t=await re.getUserItemsCount(ae);Tt(_t)}catch{Tt({archives:0,queue_items:0,library_files:0})}finally{xt(!1)}},Ma=ot({mutationFn:ae=>re.createGroup(ae),onSuccess:()=>{t.invalidateQueries({queryKey:["groups"]}),fr(!1),Dn(),o(i("settings.toast.groupCreated"))},onError:ae=>{o(ae.message,"error")}}),oa=ot({mutationFn:({id:ae,data:_t})=>re.updateGroup(ae,_t),onSuccess:()=>{t.invalidateQueries({queryKey:["groups"]}),Jn(null),Dn(),o(i("settings.toast.groupUpdated"))},onError:ae=>{o(ae.message,"error")}}),ic=ot({mutationFn:ae=>re.deleteGroup(ae),onSuccess:()=>{t.invalidateQueries({queryKey:["groups"]}),o(i("settings.toast.groupDeleted"))},onError:ae=>{o(ae.message,"error")}}),Br=()=>{const ae=zt?.advanced_auth_enabled||!1;if(!wt.username){o(i("settings.toast.fillRequiredFields"),"error");return}if(ae&&!wt.email){o("Email is required when advanced authentication is enabled","error");return}if(!ae){if(!wt.password){o(i("settings.toast.fillRequiredFields"),"error");return}if(wt.password!==wt.confirmPassword){o(i("settings.toast.passwordsDoNotMatch"),"error");return}if(wt.password.length<6){o(i("settings.toast.passwordTooShort"),"error");return}}wi.mutate({username:wt.username,password:ae?void 0:wt.password,email:wt.email||void 0,role:wt.role,group_ids:wt.group_ids.length>0?wt.group_ids:void 0})},Si=ae=>{if(wt.password){if(wt.password!==wt.confirmPassword){o(i("settings.toast.passwordsDoNotMatch"),"error");return}if(wt.password.length<6){o(i("settings.toast.passwordTooShort"),"error");return}}const _t={username:wt.username||void 0,password:wt.password||void 0,role:wt.role,group_ids:wt.group_ids};_t.password||delete _t.password,_i.mutate({id:ae,data:_t})},ho=ae=>{pt(ae.id),Bt({username:ae.username,password:"",email:ae.email||"",confirmPassword:"",role:ae.role,group_ids:ae.groups?.map(_t=>_t.id)||[]}),Re(!0)},br=ae=>{Bt(_t=>({..._t,group_ids:_t.group_ids.includes(ae)?_t.group_ids.filter(Gn=>Gn!==ae):[..._t.group_ids,ae]}))},Dn=()=>{ai({name:"",description:"",permissions:[]}),He(new Set)},Kc=()=>{if(!jn.name.trim()){o(i("settings.toast.enterGroupName"),"error");return}Ma.mutate({name:jn.name,description:jn.description||void 0,permissions:jn.permissions})},up=()=>{if(Zn){if(!jn.name.trim()){o(i("settings.toast.enterGroupName"),"error");return}oa.mutate({id:Zn.id,data:{name:jn.name!==Zn.name?jn.name:void 0,description:jn.description,permissions:jn.permissions}})}},mm=ae=>{Jn(ae),ai({name:ae.name,description:ae.description||"",permissions:ae.permissions});const _t=new Set;Ba?.categories.forEach(Gn=>{Gn.permissions.some(lr=>ae.permissions.includes(lr.value))&&_t.add(Gn.name)}),He(_t)},BM=ae=>{He(_t=>{const Gn=new Set(_t);return Gn.has(ae)?Gn.delete(ae):Gn.add(ae),Gn})},fx=ae=>{ai(_t=>{const Gn=_t.permissions.includes(ae)?_t.permissions.filter(lr=>lr!==ae):[..._t.permissions,ae];return{..._t,permissions:Gn}})},px=(ae,_t)=>{ai(Gn=>{const lr=ae.permissions.map(Ns=>Ns.value),Io=Gn.permissions.filter(Ns=>!lr.includes(Ns)),_d=_t?[...Io,...lr]:Io;return{...Gn,permissions:_d}})},Xc=ae=>ae.permissions.every(_t=>jn.permissions.includes(_t.value)),fm=ae=>{const _t=ae.permissions.filter(Gn=>jn.permissions.includes(Gn.value));return _t.length>0&&_t.length{ae.is_docker?o(ae.message,"error"):si()}}),[wd,gx]=w.useState(null),bx=ot({mutationFn:re.testAllNotificationProviders,onSuccess:ae=>{gx(ae),t.invalidateQueries({queryKey:["notification-providers"]}),ae.failed===0?o(`All ${ae.tested} providers tested successfully!`,"success"):o(`${ae.success}/${ae.tested} providers succeeded`,ae.failed>0?"error":"success")},onError:ae=>{o(`Failed to test providers: ${ae.message}`,"error")}}),Yc=ot({mutationFn:async ae=>{if(!Ht)return{success:0,failed:0};const _t=Ht.filter(lr=>lr.enabled),Gn=await Promise.all(_t.map(async lr=>{try{return await re.controlSmartPlug(lr.id,ae),{success:!0}}catch{return{success:!1}}}));return{success:Gn.filter(lr=>lr.success).length,failed:Gn.filter(lr=>!lr.success).length}},onSuccess:(ae,_t)=>{t.invalidateQueries({queryKey:["smart-plugs"]}),t.invalidateQueries({queryKey:["smart-plugs-energy"]}),ae.failed===0?o(`All ${ae.success} plugs turned ${_t}`,"success"):o(`${ae.success} plugs turned ${_t}, ${ae.failed} failed`,"error")},onError:ae=>{o(`Failed: ${ae.message}`,"error")}}),pm=w.useRef(null),hp=w.useRef(!1),ew=w.useRef(!0);w.useEffect(()=>{if(tt&&!k){const ae={...tt,external_url:tt.external_url||window.location.origin};j(ae),setTimeout(()=>{ew.current=!1},100)}},[tt,k]);const tw=ot({mutationFn:re.updateSettings,onSuccess:ae=>{t.setQueryData(["settings"],ae),j(ae),t.invalidateQueries({queryKey:["archiveStats"]}),o(i("settings.toast.settingsSaved"),"success")},onError:ae=>{o(`Failed to save: ${ae.message}`,"error")},onSettled:()=>{hp.current=!1}}),nw=ot({mutationFn:({id:ae,data:_t})=>re.updatePrinter(ae,_t),onSuccess:()=>{t.invalidateQueries({queryKey:["printers"]}),o(i("settings.toast.cameraSettingsSaved"),"success")},onError:ae=>{o(`Failed to update printer: ${ae.message}`,"error")}});w.useEffect(()=>{if(!(ew.current||!k||!tt||!(tt.auto_archive!==k.auto_archive||tt.save_thumbnails!==k.save_thumbnails||tt.capture_finish_photo!==k.capture_finish_photo||tt.default_filament_cost!==k.default_filament_cost||tt.currency!==k.currency||tt.energy_cost_per_kwh!==k.energy_cost_per_kwh||tt.energy_tracking_mode!==k.energy_tracking_mode||tt.check_updates!==k.check_updates||(tt.check_printer_firmware??!0)!==(k.check_printer_firmware??!0)||tt.notification_language!==k.notification_language||(tt.bed_cooled_threshold??35)!==(k.bed_cooled_threshold??35)||tt.ams_humidity_good!==k.ams_humidity_good||tt.ams_humidity_fair!==k.ams_humidity_fair||tt.ams_temp_good!==k.ams_temp_good||tt.ams_temp_fair!==k.ams_temp_fair||tt.ams_history_retention_days!==k.ams_history_retention_days||tt.per_printer_mapping_expanded!==k.per_printer_mapping_expanded||tt.date_format!==k.date_format||tt.time_format!==k.time_format||tt.default_printer_id!==k.default_printer_id||tt.ftp_retry_enabled!==k.ftp_retry_enabled||tt.ftp_retry_count!==k.ftp_retry_count||tt.ftp_retry_delay!==k.ftp_retry_delay||tt.ftp_timeout!==k.ftp_timeout||tt.mqtt_enabled!==k.mqtt_enabled||tt.mqtt_broker!==k.mqtt_broker||tt.mqtt_port!==k.mqtt_port||tt.mqtt_username!==k.mqtt_username||tt.mqtt_password!==k.mqtt_password||tt.mqtt_topic_prefix!==k.mqtt_topic_prefix||tt.mqtt_use_tls!==k.mqtt_use_tls||tt.external_url!==k.external_url||tt.ha_enabled!==k.ha_enabled||tt.ha_url!==k.ha_url||tt.ha_token!==k.ha_token||(tt.library_archive_mode??"ask")!==(k.library_archive_mode??"ask")||Number(tt.library_disk_warning_gb??5)!==Number(k.library_disk_warning_gb??5)||(tt.camera_view_mode??"window")!==(k.camera_view_mode??"window")||(tt.preferred_slicer??"bambu_studio")!==(k.preferred_slicer??"bambu_studio")||tt.prometheus_enabled!==k.prometheus_enabled||tt.prometheus_token!==k.prometheus_token))&&!hp.current)return pm.current&&clearTimeout(pm.current),pm.current=setTimeout(()=>{if(hp.current)return;hp.current=!0;const _t={auto_archive:k.auto_archive,save_thumbnails:k.save_thumbnails,capture_finish_photo:k.capture_finish_photo,default_filament_cost:k.default_filament_cost,currency:k.currency,energy_cost_per_kwh:k.energy_cost_per_kwh,energy_tracking_mode:k.energy_tracking_mode,check_updates:k.check_updates,check_printer_firmware:k.check_printer_firmware,notification_language:k.notification_language,bed_cooled_threshold:k.bed_cooled_threshold,ams_humidity_good:k.ams_humidity_good,ams_humidity_fair:k.ams_humidity_fair,ams_temp_good:k.ams_temp_good,ams_temp_fair:k.ams_temp_fair,ams_history_retention_days:k.ams_history_retention_days,per_printer_mapping_expanded:k.per_printer_mapping_expanded,date_format:k.date_format,time_format:k.time_format,default_printer_id:k.default_printer_id,ftp_retry_enabled:k.ftp_retry_enabled,ftp_retry_count:k.ftp_retry_count,ftp_retry_delay:k.ftp_retry_delay,ftp_timeout:k.ftp_timeout,mqtt_enabled:k.mqtt_enabled,mqtt_broker:k.mqtt_broker,mqtt_port:k.mqtt_port,mqtt_username:k.mqtt_username,mqtt_password:k.mqtt_password,mqtt_topic_prefix:k.mqtt_topic_prefix,mqtt_use_tls:k.mqtt_use_tls,external_url:k.external_url,ha_enabled:k.ha_enabled,ha_url:k.ha_url,ha_token:k.ha_token,library_archive_mode:k.library_archive_mode,library_disk_warning_gb:k.library_disk_warning_gb,camera_view_mode:k.camera_view_mode,preferred_slicer:k.preferred_slicer,prometheus_enabled:k.prometheus_enabled,prometheus_token:k.prometheus_token};tw.mutate(_t)},500),()=>{pm.current&&clearTimeout(pm.current)}},[k,tt,tw]);const bn=w.useCallback((ae,_t)=>{j(Gn=>Gn?{...Gn,[ae]:_t}:null)},[]),HM=async(ae,_t,Gn)=>{if(!_t){o(i("settings.toast.enterCameraUrl"),"error");return}Ve(lr=>({...lr,[ae]:!0})),ze(lr=>({...lr,[ae]:null}));try{const lr=await re.testExternalCamera(ae,_t,Gn);ze(Io=>({...Io,[ae]:lr})),lr.success?o(i("settings.toast.cameraConnected",{resolution:lr.resolution||""}),"success"):o(lr.error||i("settings.toast.connectionFailed"),"error")}catch(lr){const Io=lr instanceof Error?lr.message:i("settings.toast.testFailed");ze(_d=>({..._d,[ae]:{success:!1,error:Io}})),o(Io,"error")}finally{Ve(lr=>({...lr,[ae]:!1}))}},[xx,rw]=w.useState({}),yx=w.useRef({}),mp=w.useRef(new Set);w.useEffect(()=>{if(gn){const ae={};gn.forEach(_t=>{_t.external_camera_url&&!mp.current.has(_t.id)&&(ae[_t.id]=_t.external_camera_url,mp.current.add(_t.id))}),Object.keys(ae).length>0&&rw(_t=>({..._t,...ae}))}},[gn]);const $M=(ae,_t)=>{rw(Gn=>({...Gn,[ae]:_t})),yx.current[ae]&&clearTimeout(yx.current[ae]),yx.current[ae]=setTimeout(()=>{nw.mutate({id:ae,data:{external_camera_url:_t||null}})},800)},iw=(ae,_t)=>{const Gn={};_t.type!==void 0&&(Gn.external_camera_type=_t.type||null),_t.enabled!==void 0&&(Gn.external_camera_enabled=_t.enabled),nw.mutate({id:ae,data:Gn})};return at||!k?a.jsx("div",{className:"p-4 md:p-8 flex justify-center",children:a.jsx(it,{className:"w-8 h-8 text-bambu-green animate-spin"})}):a.jsxs("div",{className:"p-4 md:p-8",children:[a.jsxs("div",{className:"mb-8",children:[a.jsx("h1",{className:"text-2xl font-bold text-white",children:i("settings.title")}),a.jsx("p",{className:"text-bambu-gray",children:i("settings.configureBambuddy")})]}),a.jsxs("div",{className:"flex flex-wrap gap-1 mb-6 border-b border-bambu-dark-tertiary",children:[a.jsx("button",{onClick:()=>ce("general"),className:`px-4 py-2 text-sm font-medium transition-colors border-b-2 -mb-px ${pe==="general"?"text-bambu-green border-bambu-green":"text-bambu-gray hover:text-gray-900 dark:hover:text-white border-transparent"}`,children:i("settings.tabs.general")}),a.jsxs("button",{onClick:()=>ce("plugs"),className:`px-4 py-2 text-sm font-medium transition-colors border-b-2 -mb-px flex items-center gap-2 ${pe==="plugs"?"text-bambu-green border-bambu-green":"text-bambu-gray hover:text-gray-900 dark:hover:text-white border-transparent"}`,children:[a.jsx(hl,{className:"w-4 h-4"}),i("settings.tabs.smartPlugs"),Ht&&Ht.length>0&&a.jsx("span",{className:"text-xs bg-bambu-dark-tertiary px-1.5 py-0.5 rounded-full",children:Ht.length})]}),a.jsxs("button",{onClick:()=>ce("notifications"),className:`px-4 py-2 text-sm font-medium transition-colors border-b-2 -mb-px flex items-center gap-2 ${pe==="notifications"?"text-bambu-green border-bambu-green":"text-bambu-gray hover:text-gray-900 dark:hover:text-white border-transparent"}`,children:[a.jsx(Xg,{className:"w-4 h-4"}),i("settings.tabs.notifications"),pn&&pn.length>0&&a.jsx("span",{className:"text-xs bg-bambu-dark-tertiary px-1.5 py-0.5 rounded-full",children:pn.length})]}),a.jsxs("button",{onClick:()=>ce("filament"),className:`px-4 py-2 text-sm font-medium transition-colors border-b-2 -mb-px flex items-center gap-2 ${pe==="filament"?"text-bambu-green border-bambu-green":"text-bambu-gray hover:text-gray-900 dark:hover:text-white border-transparent"}`,children:[a.jsx(Ahe,{className:"w-4 h-4"}),i("settings.tabs.filament")]}),a.jsxs("button",{onClick:()=>ce("network"),className:`px-4 py-2 text-sm font-medium transition-colors border-b-2 -mb-px flex items-center gap-2 ${pe==="network"?"text-bambu-green border-bambu-green":"text-bambu-gray hover:text-gray-900 dark:hover:text-white border-transparent"}`,children:[a.jsx(Qg,{className:"w-4 h-4"}),i("settings.tabs.network"),a.jsx("span",{className:`w-2 h-2 rounded-full ${Fn?.enabled?"bg-green-400":"bg-gray-500"}`})]}),a.jsxs("button",{onClick:()=>ce("apikeys"),className:`px-4 py-2 text-sm font-medium transition-colors border-b-2 -mb-px flex items-center gap-2 ${pe==="apikeys"?"text-bambu-green border-bambu-green":"text-bambu-gray hover:text-gray-900 dark:hover:text-white border-transparent"}`,children:[a.jsx(nl,{className:"w-4 h-4"}),i("settings.tabs.apiKeys"),sn&&sn.length>0&&a.jsx("span",{className:"text-xs bg-bambu-dark-tertiary px-1.5 py-0.5 rounded-full",children:sn.length})]}),a.jsxs("button",{onClick:()=>ce("virtual-printer"),className:`px-4 py-2 text-sm font-medium transition-colors border-b-2 -mb-px flex items-center gap-2 ${pe==="virtual-printer"?"text-bambu-green border-bambu-green":"text-bambu-gray hover:text-gray-900 dark:hover:text-white border-transparent"}`,children:[a.jsx(Cr,{className:"w-4 h-4"}),i("settings.tabs.virtualPrinter"),a.jsx("span",{className:`w-2 h-2 rounded-full ${mi?"bg-green-400":"bg-gray-500"}`})]}),a.jsxs("button",{onClick:()=>ce("users"),className:`px-4 py-2 text-sm font-medium transition-colors border-b-2 -mb-px flex items-center gap-2 ${pe==="users"?"text-bambu-green border-bambu-green":"text-bambu-gray hover:text-gray-900 dark:hover:text-white border-transparent"}`,children:[a.jsx(gh,{className:"w-4 h-4"}),i("settings.tabs.users"),l&&a.jsx("span",{className:"w-2 h-2 rounded-full bg-green-400"})]}),a.jsxs("button",{onClick:()=>ce("backup"),className:`px-4 py-2 text-sm font-medium transition-colors border-b-2 -mb-px flex items-center gap-2 ${pe==="backup"?"text-bambu-green border-bambu-green":"text-bambu-gray hover:text-gray-900 dark:hover:text-white border-transparent"}`,children:[a.jsx(Tc,{className:"w-4 h-4"}),i("settings.tabs.backup"),a.jsx("span",{className:`w-2 h-2 rounded-full ${ka?.is_authenticated&&sa?.configured&&sa?.enabled?"bg-green-400":"bg-gray-500"}`})]})]}),pe==="general"&&a.jsxs("div",{className:"flex flex-col lg:flex-row gap-6 lg:gap-8",children:[a.jsxs("div",{className:"space-y-6 flex-1 lg:max-w-xl",children:[a.jsxs(vt,{children:[a.jsx(An,{children:a.jsx("h2",{className:"text-lg font-semibold text-white",children:i("settings.general")})}),a.jsxs(Nt,{className:"space-y-4",children:[a.jsxs("div",{children:[a.jsxs("label",{className:"block text-sm text-bambu-gray mb-1",children:[a.jsx(jh,{className:"w-4 h-4 inline mr-1"}),i("settings.language")]}),a.jsxs("div",{className:"relative",children:[a.jsx("select",{value:s.language,onChange:ae=>{s.changeLanguage(ae.target.value),o(i("settings.toast.settingsSaved"),"success")},className:"w-full px-3 py-2 pr-10 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none appearance-none cursor-pointer",children:_B.map(ae=>a.jsxs("option",{value:ae.code,children:[ae.nativeName," (",ae.name,")"]},ae.code))}),a.jsx(nr,{className:"absolute right-3 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray pointer-events-none"})]}),a.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:i("settings.languageDescription")})]}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:i("settings.defaultView")}),a.jsxs("div",{className:"relative",children:[a.jsx("select",{value:$,onChange:ae=>Ee(ae.target.value),className:"w-full px-3 py-2 pr-10 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none appearance-none cursor-pointer",children:C0.map(ae=>a.jsx("option",{value:ae.to,children:i(ae.labelKey)},ae.id))}),a.jsx(nr,{className:"absolute right-3 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray pointer-events-none"})]}),a.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:i("settings.defaultViewDescription")})]}),a.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Date Format"}),a.jsxs("div",{className:"relative",children:[a.jsxs("select",{value:k.date_format||"system",onChange:ae=>bn("date_format",ae.target.value),className:"w-full px-3 py-2 pr-10 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none appearance-none cursor-pointer",children:[a.jsx("option",{value:"system",children:i("settings.systemDefault")}),a.jsx("option",{value:"us",children:"US (MM/DD/YYYY)"}),a.jsx("option",{value:"eu",children:"EU (DD/MM/YYYY)"}),a.jsx("option",{value:"iso",children:"ISO (YYYY-MM-DD)"})]}),a.jsx(nr,{className:"absolute right-3 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray pointer-events-none"})]})]}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Time Format"}),a.jsxs("div",{className:"relative",children:[a.jsxs("select",{value:k.time_format||"system",onChange:ae=>bn("time_format",ae.target.value),className:"w-full px-3 py-2 pr-10 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none appearance-none cursor-pointer",children:[a.jsx("option",{value:"system",children:i("settings.systemDefault")}),a.jsx("option",{value:"12h",children:"12-hour (3:30 PM)"}),a.jsx("option",{value:"24h",children:"24-hour (15:30)"})]}),a.jsx(nr,{className:"absolute right-3 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray pointer-events-none"})]})]})]}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Default Printer"}),a.jsxs("div",{className:"relative",children:[a.jsxs("select",{value:k.default_printer_id??"",onChange:ae=>bn("default_printer_id",ae.target.value?Number(ae.target.value):null),className:"w-full px-3 py-2 pr-10 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none appearance-none cursor-pointer",children:[a.jsx("option",{value:"",children:i("settings.noDefaultPrinter")}),gn?.map(ae=>a.jsx("option",{value:ae.id,children:ae.name},ae.id))]}),a.jsx(nr,{className:"absolute right-3 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray pointer-events-none"})]}),a.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:"Pre-select this printer for uploads, reprints, and other operations."})]}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:i("settings.preferredSlicer")}),a.jsxs("div",{className:"relative",children:[a.jsxs("select",{value:k.preferred_slicer??"bambu_studio",onChange:ae=>bn("preferred_slicer",ae.target.value),className:"w-full px-3 py-2 pr-10 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none appearance-none cursor-pointer",children:[a.jsx("option",{value:"bambu_studio",children:"Bambu Studio"}),a.jsx("option",{value:"orcaslicer",children:"OrcaSlicer"})]}),a.jsx(nr,{className:"absolute right-3 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray pointer-events-none"})]}),a.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:i("settings.preferredSlicerDescription")})]}),a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsxs("div",{children:[a.jsx("p",{className:"text-white",children:i("settings.sidebarOrder")}),a.jsx("p",{className:"text-sm text-bambu-gray",children:"Drag items in the sidebar to reorder. Reset to default order here."})]}),a.jsxs(Ce,{variant:"secondary",size:"sm",onClick:st,children:[a.jsx(Ro,{className:"w-4 h-4"}),"Reset"]})]})]})]}),a.jsxs(vt,{children:[a.jsx(An,{children:a.jsxs("h2",{className:"text-lg font-semibold text-white flex items-center gap-2",children:[a.jsx(aC,{className:"w-5 h-5"}),"Appearance"]})}),a.jsxs(Nt,{className:"space-y-6",children:[a.jsxs("div",{className:`space-y-3 p-4 rounded-lg border ${d==="dark"?"border-bambu-green bg-bambu-green/5":"border-bambu-dark-tertiary"}`,children:[a.jsxs("h3",{className:"text-sm font-medium text-white flex items-center gap-2",children:["Dark Mode",d==="dark"&&a.jsx("span",{className:"text-xs text-bambu-green",children:"(active)"})]}),a.jsxs("div",{className:"grid grid-cols-3 gap-3",children:[a.jsxs("div",{children:[a.jsx("label",{className:"block text-xs text-bambu-gray mb-1",children:"Background"}),a.jsxs("select",{value:f,onChange:ae=>{S(ae.target.value),o(i("settings.toast.settingsSaved"),"success")},className:"w-full px-2 py-1.5 text-sm bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",children:[a.jsx("option",{value:"neutral",children:"Neutral"}),a.jsx("option",{value:"warm",children:"Warm"}),a.jsx("option",{value:"cool",children:"Cool"}),a.jsx("option",{value:"oled",children:"OLED Black"}),a.jsx("option",{value:"slate",children:"Slate Blue"}),a.jsx("option",{value:"forest",children:"Forest Green"})]})]}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-xs text-bambu-gray mb-1",children:"Accent"}),a.jsxs("select",{value:p,onChange:ae=>{N(ae.target.value),o(i("settings.toast.settingsSaved"),"success")},className:"w-full px-2 py-1.5 text-sm bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",children:[a.jsx("option",{value:"green",children:"Green"}),a.jsx("option",{value:"teal",children:"Teal"}),a.jsx("option",{value:"blue",children:"Blue"}),a.jsx("option",{value:"orange",children:"Orange"}),a.jsx("option",{value:"purple",children:"Purple"}),a.jsx("option",{value:"red",children:"Red"})]})]}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-xs text-bambu-gray mb-1",children:"Style"}),a.jsxs("select",{value:h,onChange:ae=>{v(ae.target.value),o(i("settings.toast.settingsSaved"),"success")},className:"w-full px-2 py-1.5 text-sm bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",children:[a.jsx("option",{value:"classic",children:"Classic"}),a.jsx("option",{value:"glow",children:"Glow"}),a.jsx("option",{value:"vibrant",children:"Vibrant"})]})]})]})]}),a.jsxs("div",{className:`space-y-3 p-4 rounded-lg border ${d==="light"?"border-bambu-green bg-bambu-green/5":"border-bambu-dark-tertiary"}`,children:[a.jsxs("h3",{className:"text-sm font-medium text-white flex items-center gap-2",children:["Light Mode",d==="light"&&a.jsx("span",{className:"text-xs text-bambu-green",children:"(active)"})]}),a.jsxs("div",{className:"grid grid-cols-3 gap-3",children:[a.jsxs("div",{children:[a.jsx("label",{className:"block text-xs text-bambu-gray mb-1",children:"Background"}),a.jsxs("select",{value:y,onChange:ae=>{C(ae.target.value),o(i("settings.toast.settingsSaved"),"success")},className:"w-full px-2 py-1.5 text-sm bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",children:[a.jsx("option",{value:"neutral",children:"Neutral"}),a.jsx("option",{value:"warm",children:"Warm"}),a.jsx("option",{value:"cool",children:"Cool"})]})]}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-xs text-bambu-gray mb-1",children:"Accent"}),a.jsxs("select",{value:b,onChange:ae=>{T(ae.target.value),o(i("settings.toast.settingsSaved"),"success")},className:"w-full px-2 py-1.5 text-sm bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",children:[a.jsx("option",{value:"green",children:"Green"}),a.jsx("option",{value:"teal",children:"Teal"}),a.jsx("option",{value:"blue",children:"Blue"}),a.jsx("option",{value:"orange",children:"Orange"}),a.jsx("option",{value:"purple",children:"Purple"}),a.jsx("option",{value:"red",children:"Red"})]})]}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-xs text-bambu-gray mb-1",children:"Style"}),a.jsxs("select",{value:x,onChange:ae=>{A(ae.target.value),o(i("settings.toast.settingsSaved"),"success")},className:"w-full px-2 py-1.5 text-sm bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",children:[a.jsx("option",{value:"classic",children:"Classic"}),a.jsx("option",{value:"glow",children:"Glow"}),a.jsx("option",{value:"vibrant",children:"Vibrant"})]})]})]})]}),a.jsx("p",{className:"text-xs text-bambu-gray",children:"Toggle between dark and light mode using the sun/moon icon in the sidebar."})]})]}),a.jsxs(vt,{children:[a.jsx(An,{children:a.jsx("h2",{className:"text-lg font-semibold text-white",children:i("settings.archiveSettings")})}),a.jsxs(Nt,{className:"space-y-4",children:[a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsxs("div",{children:[a.jsx("p",{className:"text-white",children:"Auto-archive prints"}),a.jsx("p",{className:"text-sm text-bambu-gray",children:"Automatically save 3MF files when prints complete"})]}),a.jsxs("label",{className:"relative inline-flex items-center cursor-pointer",children:[a.jsx("input",{type:"checkbox",checked:k.auto_archive,onChange:ae=>bn("auto_archive",ae.target.checked),className:"sr-only peer"}),a.jsx("div",{className:"w-11 h-6 bg-bambu-dark-tertiary peer-focus:outline-none rounded-full peer peer-checked:after:translate-x-full peer-checked:after:border-white after:content-[''] after:absolute after:top-[2px] after:left-[2px] after:bg-white after:rounded-full after:h-5 after:w-5 after:transition-all peer-checked:bg-bambu-green"})]})]}),a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsxs("div",{children:[a.jsx("p",{className:"text-white",children:i("settings.saveThumbnails")}),a.jsx("p",{className:"text-sm text-bambu-gray",children:"Extract and save preview images from 3MF files"})]}),a.jsxs("label",{className:"relative inline-flex items-center cursor-pointer",children:[a.jsx("input",{type:"checkbox",checked:k.save_thumbnails,onChange:ae=>bn("save_thumbnails",ae.target.checked),className:"sr-only peer"}),a.jsx("div",{className:"w-11 h-6 bg-bambu-dark-tertiary peer-focus:outline-none rounded-full peer peer-checked:after:translate-x-full peer-checked:after:border-white after:content-[''] after:absolute after:top-[2px] after:left-[2px] after:bg-white after:rounded-full after:h-5 after:w-5 after:transition-all peer-checked:bg-bambu-green"})]})]}),a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsxs("div",{children:[a.jsx("p",{className:"text-white",children:i("settings.captureFinishPhoto")}),a.jsx("p",{className:"text-sm text-bambu-gray",children:"Take a photo from printer camera when print completes"})]}),a.jsxs("label",{className:"relative inline-flex items-center cursor-pointer",children:[a.jsx("input",{type:"checkbox",checked:k.capture_finish_photo,onChange:ae=>bn("capture_finish_photo",ae.target.checked),className:"sr-only peer"}),a.jsx("div",{className:"w-11 h-6 bg-bambu-dark-tertiary peer-focus:outline-none rounded-full peer peer-checked:after:translate-x-full peer-checked:after:border-white after:content-[''] after:absolute after:top-[2px] after:left-[2px] after:bg-white after:rounded-full after:h-5 after:w-5 after:transition-all peer-checked:bg-bambu-green"})]})]}),k.capture_finish_photo&&fi&&!fi.installed&&a.jsxs("div",{className:"flex items-start gap-2 p-3 bg-yellow-500/10 border border-yellow-500/30 rounded-lg",children:[a.jsx(Cn,{className:"w-5 h-5 text-yellow-500 flex-shrink-0 mt-0.5"}),a.jsxs("div",{className:"text-sm",children:[a.jsx("p",{className:"text-yellow-500 font-medium",children:"ffmpeg not installed"}),a.jsxs("p",{className:"text-bambu-gray mt-1",children:["Camera capture requires ffmpeg. Install it via"," ",a.jsx("code",{className:"bg-bambu-dark-tertiary px-1 rounded",children:"brew install ffmpeg"})," (macOS) or"," ",a.jsx("code",{className:"bg-bambu-dark-tertiary px-1 rounded",children:"apt install ffmpeg"})," (Linux)."]})]})]})]})]})]}),a.jsxs("div",{className:"space-y-6 flex-1 lg:max-w-md",children:[a.jsxs(vt,{children:[a.jsx(An,{children:a.jsxs("h2",{className:"text-lg font-semibold text-white flex items-center gap-2",children:[a.jsx(UF,{className:"w-5 h-5 text-bambu-green"}),"Camera"]})}),a.jsxs(Nt,{className:"space-y-4",children:[a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Camera View Mode"}),a.jsxs("select",{value:k.camera_view_mode??"window",onChange:ae=>bn("camera_view_mode",ae.target.value),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",children:[a.jsx("option",{value:"window",children:i("settings.newWindow")}),a.jsx("option",{value:"embedded",children:i("settings.embeddedOverlay")})]}),a.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:k.camera_view_mode==="embedded"?"Camera opens in a resizable overlay on the main screen":"Camera opens in a separate browser window"})]}),a.jsxs("div",{className:"border-t border-bambu-dark-tertiary pt-4 mt-4",children:[a.jsx("h3",{className:"text-sm font-medium text-white mb-2",children:i("settings.externalCameras")}),a.jsx("p",{className:"text-xs text-bambu-gray mb-3",children:"Configure external cameras to replace the built-in printer camera. Supports MJPEG streams, RTSP, HTTP snapshots, and USB cameras (V4L2). When enabled, the external camera is used for live view and finish photos."}),gn&&gn.length>0?a.jsx("div",{className:"space-y-3",children:gn.map(ae=>a.jsxs("div",{className:"p-3 bg-bambu-dark rounded-lg",children:[a.jsxs("div",{className:"flex items-center justify-between mb-2",children:[a.jsx("span",{className:"text-white font-medium text-sm",children:ae.name}),a.jsxs("label",{className:"relative inline-flex items-center cursor-pointer",children:[a.jsx("input",{type:"checkbox",checked:ae.external_camera_enabled,onChange:_t=>iw(ae.id,{enabled:_t.target.checked}),className:"sr-only peer"}),a.jsx("div",{className:"w-9 h-5 bg-bambu-dark-tertiary peer-focus:outline-none rounded-full peer peer-checked:after:translate-x-full peer-checked:after:border-white after:content-[''] after:absolute after:top-[2px] after:left-[2px] after:bg-white after:border-gray-300 after:border after:rounded-full after:h-4 after:w-4 after:transition-all peer-checked:bg-bambu-green"})]})]}),ae.external_camera_enabled&&a.jsxs("div",{className:"space-y-2 mt-2",children:[a.jsx("input",{type:"text",placeholder:ae.external_camera_type==="usb"?"Device path (/dev/video0)":"Camera URL (rtsp://... or http://...)",value:xx[ae.id]??ae.external_camera_url??"",onChange:_t=>$M(ae.id,_t.target.value),className:"w-full px-3 py-2 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded text-white text-sm focus:border-bambu-green focus:outline-none"}),a.jsxs("div",{className:"flex gap-2",children:[a.jsxs("select",{value:ae.external_camera_type||"mjpeg",onChange:_t=>iw(ae.id,{type:_t.target.value}),className:"flex-1 px-3 py-2 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded text-white text-sm focus:border-bambu-green focus:outline-none",children:[a.jsx("option",{value:"mjpeg",children:"MJPEG Stream"}),a.jsx("option",{value:"rtsp",children:"RTSP Stream"}),a.jsx("option",{value:"snapshot",children:"HTTP Snapshot"}),a.jsx("option",{value:"usb",children:"USB Camera (V4L2)"})]}),a.jsx(Ce,{size:"sm",variant:"secondary",onClick:()=>HM(ae.id,xx[ae.id]??ae.external_camera_url??"",ae.external_camera_type||"mjpeg"),disabled:Ge[ae.id]||!(xx[ae.id]??ae.external_camera_url),children:Ge[ae.id]?a.jsx(it,{className:"w-4 h-4 animate-spin"}):"Test"})]}),ge[ae.id]&&a.jsx("div",{className:`text-xs flex items-center gap-1 ${ge[ae.id]?.success?"text-green-500":"text-red-500"}`,children:ge[ae.id]?.success?a.jsxs(a.Fragment,{children:[a.jsx(gr,{className:"w-3 h-3"}),"Connected",ge[ae.id]?.resolution&&` (${ge[ae.id]?.resolution})`]}):a.jsxs(a.Fragment,{children:[a.jsx(ha,{className:"w-3 h-3"}),ge[ae.id]?.error||i("settings.toast.connectionFailed")]})})]})]},ae.id))}):a.jsx("p",{className:"text-xs text-bambu-gray italic",children:i("settings.noPrintersConfigured")})]})]})]}),a.jsxs(vt,{children:[a.jsx(An,{children:a.jsx("h2",{className:"text-lg font-semibold text-white",children:i("settings.costTracking")})}),a.jsxs(Nt,{className:"space-y-4",children:[a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Currency"}),a.jsx("select",{value:k.currency,onChange:ae=>bn("currency",ae.target.value),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",children:RQe.map(ae=>a.jsx("option",{value:ae.code,children:ae.label},ae.code))})]}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Default filament cost (per kg)"}),a.jsxs("div",{className:"relative",children:[a.jsx("span",{className:"absolute left-3 top-1/2 -translate-y-1/2 text-bambu-gray text-sm pointer-events-none",children:ju(k.currency)}),a.jsx("input",{type:"number",step:"0.01",min:"0",value:k.default_filament_cost,onChange:ae=>bn("default_filament_cost",parseFloat(ae.target.value)||0),style:{paddingLeft:`${Math.max(2,ju(k.currency).length*.6+1)}rem`},className:"w-full pr-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none"})]})]}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Electricity cost per kWh"}),a.jsxs("div",{className:"relative",children:[a.jsx("span",{className:"absolute left-3 top-1/2 -translate-y-1/2 text-bambu-gray text-sm pointer-events-none",children:ju(k.currency)}),a.jsx("input",{type:"number",step:"0.01",min:"0",value:k.energy_cost_per_kwh,onChange:ae=>bn("energy_cost_per_kwh",parseFloat(ae.target.value)||0),style:{paddingLeft:`${Math.max(2,ju(k.currency).length*.6+1)}rem`},className:"w-full pr-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none"})]})]}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Energy display mode"}),a.jsxs("select",{value:k.energy_tracking_mode||"total",onChange:ae=>bn("energy_tracking_mode",ae.target.value),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",children:[a.jsx("option",{value:"print",children:i("settings.printsOnly")}),a.jsx("option",{value:"total",children:i("settings.totalConsumption")})]}),a.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:k.energy_tracking_mode==="print"?"Dashboard shows sum of energy used during prints":"Dashboard shows lifetime energy from smart plugs"})]})]})]}),a.jsxs(vt,{children:[a.jsx(An,{children:a.jsxs("h2",{className:"text-lg font-semibold text-white flex items-center gap-2",children:[a.jsx(Ps,{className:"w-5 h-5 text-bambu-green"}),"File Manager"]})}),a.jsxs(Nt,{className:"space-y-4",children:[a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Create Archive Entry When Printing"}),a.jsxs("select",{value:k.library_archive_mode??"ask",onChange:ae=>bn("library_archive_mode",ae.target.value),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",children:[a.jsx("option",{value:"always",children:i("settings.archiveMode.always")}),a.jsx("option",{value:"never",children:i("settings.archiveMode.never")}),a.jsx("option",{value:"ask",children:i("settings.archiveMode.ask")})]}),a.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:"When printing from File Manager, optionally create an archive entry"})]}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Low Disk Space Warning"}),a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx("input",{type:"number",min:"0.5",max:"100",step:"0.5",value:k.library_disk_warning_gb??5,onChange:ae=>bn("library_disk_warning_gb",parseFloat(ae.target.value)||5),className:"w-24 px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none"}),a.jsx("span",{className:"text-bambu-gray",children:"GB"})]}),a.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:"Show warning when free disk space falls below this threshold"})]})]})]})]}),a.jsxs("div",{className:"space-y-6 flex-1 lg:max-w-sm",children:[a.jsx(aZe,{}),a.jsxs(vt,{children:[a.jsx(An,{children:a.jsx("h2",{className:"text-lg font-semibold text-white",children:"Updates"})}),a.jsxs(Nt,{className:"space-y-4",children:[a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsxs("div",{children:[a.jsx("p",{className:"text-white",children:i("settings.checkForUpdatesLabel")}),a.jsx("p",{className:"text-sm text-bambu-gray",children:"Automatically check for new versions on startup"})]}),a.jsxs("label",{className:"relative inline-flex items-center cursor-pointer",children:[a.jsx("input",{type:"checkbox",checked:k.check_updates,onChange:ae=>bn("check_updates",ae.target.checked),className:"sr-only peer"}),a.jsx("div",{className:"w-11 h-6 bg-bambu-dark-tertiary peer-focus:outline-none rounded-full peer peer-checked:after:translate-x-full peer-checked:after:border-white after:content-[''] after:absolute after:top-[2px] after:left-[2px] after:bg-white after:rounded-full after:h-5 after:w-5 after:transition-all peer-checked:bg-bambu-green"})]})]}),a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsxs("div",{children:[a.jsx("p",{className:"text-white",children:i("settings.checkPrinterFirmware")}),a.jsx("p",{className:"text-sm text-bambu-gray",children:"Check for printer firmware updates from Bambu Lab"})]}),a.jsxs("label",{className:"relative inline-flex items-center cursor-pointer",children:[a.jsx("input",{type:"checkbox",checked:k.check_printer_firmware??!0,onChange:ae=>bn("check_printer_firmware",ae.target.checked),className:"sr-only peer"}),a.jsx("div",{className:"w-11 h-6 bg-bambu-dark-tertiary peer-focus:outline-none rounded-full peer peer-checked:after:translate-x-full peer-checked:after:border-white after:content-[''] after:absolute after:top-[2px] after:left-[2px] after:bg-white after:rounded-full after:h-5 after:w-5 after:transition-all peer-checked:bg-bambu-green"})]})]}),a.jsxs("div",{className:"border-t border-bambu-dark-tertiary pt-4",children:[a.jsxs("div",{className:"flex items-center justify-between mb-2",children:[a.jsxs("div",{children:[a.jsx("p",{className:"text-white",children:i("settings.currentVersion")}),a.jsxs("p",{className:"text-sm text-bambu-gray",children:["v",bt?.version||"..."]})]}),a.jsxs(Ce,{variant:"secondary",size:"sm",onClick:()=>Hn(),disabled:kt,children:[kt?a.jsx(it,{className:"w-4 h-4 animate-spin"}):a.jsx(kr,{className:"w-4 h-4"}),"Check now"]})]}),Et?.update_available?a.jsxs("div",{className:"mt-4 p-3 bg-bambu-green/10 border border-bambu-green/30 rounded-lg",children:[a.jsxs("div",{className:"flex items-start justify-between",children:[a.jsxs("div",{children:[a.jsxs("p",{className:"text-bambu-green font-medium",children:["Update available: v",Et.latest_version]}),Et.release_name&&Et.release_name!==Et.latest_version&&a.jsx("p",{className:"text-sm text-bambu-gray mt-1",children:Et.release_name})]}),a.jsxs("div",{className:"flex items-center gap-2",children:[Et.release_notes&&a.jsx("button",{onClick:()=>Oe(!0),className:"text-bambu-gray hover:text-white transition-colors text-sm underline",children:"Release Notes"}),Et.release_url&&a.jsx("a",{href:Et.release_url,target:"_blank",rel:"noopener noreferrer",className:"text-bambu-gray hover:text-white transition-colors",title:i("settings.viewReleaseOnGitHub"),children:a.jsx(Kr,{className:"w-4 h-4"})})]})]}),Nn?.status==="downloading"||Nn?.status==="installing"?a.jsxs("div",{className:"mt-3",children:[a.jsxs("div",{className:"flex items-center gap-2 text-sm text-bambu-gray",children:[a.jsx(it,{className:"w-4 h-4 animate-spin"}),a.jsx("span",{children:Nn.message})]}),a.jsx("div",{className:"mt-2 w-full bg-bambu-dark-tertiary rounded-full h-2",children:a.jsx("div",{className:"bg-bambu-green h-2 rounded-full transition-all duration-300",style:{width:`${Nn.progress}%`}})})]}):Nn?.status==="complete"?a.jsx("div",{className:"mt-3 p-2 bg-bambu-green/20 rounded text-sm text-bambu-green",children:Nn.message}):Nn?.status==="error"?a.jsx("div",{className:"mt-3 p-2 bg-red-500/20 rounded text-sm text-red-400",children:Nn.error||Nn.message}):Et?.is_docker?a.jsxs("div",{className:"mt-3 p-3 bg-bambu-dark-tertiary rounded-lg",children:[a.jsx("p",{className:"text-sm text-bambu-gray mb-2",children:"Update via Docker Compose:"}),a.jsx("code",{className:"block text-xs bg-bambu-dark p-2 rounded text-bambu-green font-mono",children:"docker compose pull && docker compose up -d"})]}):a.jsxs(Ce,{className:"mt-3",onClick:()=>dp.mutate(),disabled:dp.isPending,children:[dp.isPending?a.jsx(it,{className:"w-4 h-4 animate-spin"}):a.jsx(di,{className:"w-4 h-4"}),"Install Update"]})]}):Et?.error?a.jsxs("div",{className:"mt-2 p-2 bg-red-500/10 border border-red-500/30 rounded text-sm text-red-400",children:["Failed to check for updates: ",Et.error]}):Et&&!Et.update_available?a.jsx("p",{className:"mt-2 text-sm text-bambu-gray",children:"You're running the latest version"}):null]})]})]}),a.jsxs(vt,{children:[a.jsx(An,{children:a.jsx("h2",{className:"text-lg font-semibold text-white",children:i("settings.dataManagement")})}),a.jsxs(Nt,{className:"space-y-4",children:[a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsxs("div",{children:[a.jsx("p",{className:"text-white",children:i("settings.clearNotificationLogs")}),a.jsx("p",{className:"text-sm text-bambu-gray",children:i("settings.clearNotificationLogsDescription")})]}),a.jsxs(Ce,{variant:"secondary",size:"sm",onClick:()=>D(!0),children:[a.jsx(Jt,{className:"w-4 h-4"}),i("common.clear")]})]}),a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsxs("div",{children:[a.jsx("p",{className:"text-white",children:i("settings.resetUiPreferences")}),a.jsx("p",{className:"text-sm text-bambu-gray",children:i("settings.resetUiPreferencesDescription")})]}),a.jsxs(Ce,{variant:"secondary",size:"sm",onClick:()=>he(!0),children:[a.jsx(Jt,{className:"w-4 h-4"}),"Reset"]})]}),a.jsxs("div",{className:"pt-4 border-t border-bambu-dark-tertiary",children:[a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsxs("div",{children:[a.jsx("p",{className:"text-white",children:i("settings.storageUsage","Storage Usage")}),a.jsx("p",{className:"text-sm text-bambu-gray",children:i("settings.storageUsageDescription","Breakdown of data usage by category")})]}),a.jsxs(Ce,{variant:"secondary",size:"sm",onClick:jt,disabled:Ot||Ae,children:[a.jsx(kr,{className:`w-4 h-4 ${Ot||Ae?"animate-spin":""}`}),i("common.refresh","Refresh")]})]}),a.jsx("div",{className:"mt-3",children:Kt?a.jsxs("div",{className:"flex items-center gap-2 text-sm text-bambu-gray",children:[a.jsx(it,{className:"w-4 h-4 animate-spin"}),i("common.loading","Loading")]}):Mt?a.jsxs(a.Fragment,{children:[a.jsx("div",{className:"w-full h-3 bg-bambu-dark rounded-full overflow-hidden flex",children:Mt.categories.filter(ae=>ae.bytes>0).map((ae,_t)=>a.jsx("div",{className:`${cK(ae.key,_t)} h-full`,style:{width:`${ae.percent_of_total}%`},title:`${ae.label}: ${ae.formatted}`},ae.key))}),a.jsx("div",{className:"mt-3 flex flex-wrap gap-3",children:Mt.categories.filter(ae=>ae.bytes>0).map((ae,_t)=>a.jsxs("div",{className:"flex items-center gap-2 text-xs",children:[a.jsx("span",{className:`w-3 h-3 rounded-full ${cK(ae.key,_t)}`}),a.jsx("span",{className:"text-bambu-gray",children:ae.label}),a.jsx("span",{className:"text-white",children:ae.formatted}),a.jsxs("span",{className:"text-bambu-gray",children:["(",ae.percent_of_total.toFixed(1),"%)"]})]},ae.key))}),a.jsxs("div",{className:"mt-2 text-xs text-bambu-gray",children:[i("settings.storageUsageTotal","Total"),": ",a.jsx("span",{className:"text-white",children:Mt.total_formatted}),Mt.scan_errors>0&&a.jsxs("span",{className:"ml-2 text-amber-400",children:[i("settings.storageUsageErrors","Scan errors"),": ",Mt.scan_errors]})]}),Mt.other_breakdown?.length>0&&a.jsxs("div",{className:"mt-4",children:[a.jsx("p",{className:"text-xs text-bambu-gray mb-2",children:i("settings.storageUsageOtherBreakdown","Other breakdown")}),a.jsx("div",{className:"space-y-2",children:Mt.other_breakdown.map(ae=>a.jsxs("div",{className:"flex items-center justify-between text-xs",children:[a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx("span",{className:"text-white",children:ae.label}),a.jsx("span",{className:`px-2 py-0.5 rounded-full border ${ae.kind==="system"?"border-slate-500 text-slate-300":"border-bambu-green text-bambu-green"}`,children:ae.kind==="system"?i("settings.storageUsageSystem","System"):i("settings.storageUsageData","Data")})]}),a.jsxs("div",{className:"flex items-center gap-2 text-bambu-gray",children:[a.jsx("span",{className:"text-white",children:ae.formatted}),a.jsxs("span",{children:["(",ae.percent_of_total.toFixed(1),"%)"]})]})]},`${ae.bucket}-${ae.kind}`))})]})]}):a.jsx("p",{className:"text-sm text-bambu-gray",children:i("settings.storageUsageUnavailable","Storage usage data is unavailable")})})]}),a.jsxs("div",{className:"flex items-center justify-between pt-4 border-t border-bambu-dark-tertiary",children:[a.jsxs("div",{children:[a.jsx("p",{className:"text-white",children:"Backup & Restore"}),a.jsx("p",{className:"text-sm text-bambu-gray",children:"Export/import settings and configure GitHub backup"})]}),a.jsxs(Ce,{variant:"secondary",size:"sm",onClick:()=>ce("backup"),children:[a.jsx(Tc,{className:"w-4 h-4"}),"Go to Backup"]})]})]})]})]})]}),pe==="network"&&k&&a.jsxs("div",{className:"flex flex-col lg:flex-row gap-6",children:[a.jsxs("div",{className:"flex-1 lg:max-w-xl space-y-4",children:[a.jsxs(vt,{children:[a.jsx(An,{children:a.jsxs("h2",{className:"text-lg font-semibold text-white flex items-center gap-2",children:[a.jsx(jh,{className:"w-5 h-5 text-blue-400"}),"External URL"]})}),a.jsxs(Nt,{className:"space-y-4",children:[a.jsx("p",{className:"text-sm text-bambu-gray",children:"The external URL where Bambuddy is accessible. Used for notification images and external integrations."}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Bambuddy URL"}),a.jsx("input",{type:"text",value:k.external_url??"",onChange:ae=>bn("external_url",ae.target.value),placeholder:"http://192.168.1.100:8000",className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none"}),a.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:"Include protocol and port (e.g., http://192.168.1.100:8000)"})]})]})]}),a.jsxs(vt,{children:[a.jsx(An,{children:a.jsxs("h2",{className:"text-lg font-semibold text-white flex items-center gap-2",children:[a.jsx(kr,{className:"w-5 h-5 text-blue-400"}),"FTP Retry"]})}),a.jsxs(Nt,{className:"space-y-4",children:[a.jsx("p",{className:"text-sm text-bambu-gray",children:"Retry FTP operations when printer WiFi is unreliable. Applies to 3MF downloads, print uploads, timelapse downloads, and firmware updates."}),a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsxs("div",{children:[a.jsx("p",{className:"text-white",children:i("settings.enableRetry")}),a.jsx("p",{className:"text-sm text-bambu-gray",children:"Automatically retry failed FTP operations"})]}),a.jsxs("label",{className:"relative inline-flex items-center cursor-pointer",children:[a.jsx("input",{type:"checkbox",checked:k.ftp_retry_enabled??!0,onChange:ae=>bn("ftp_retry_enabled",ae.target.checked),className:"sr-only peer"}),a.jsx("div",{className:"w-11 h-6 bg-bambu-dark-tertiary peer-focus:outline-none rounded-full peer peer-checked:after:translate-x-full peer-checked:after:border-white after:content-[''] after:absolute after:top-[2px] after:left-[2px] after:bg-white after:rounded-full after:h-5 after:w-5 after:transition-all peer-checked:bg-bambu-green"})]})]}),k.ftp_retry_enabled&&a.jsxs("div",{className:"space-y-4 pt-2 border-t border-bambu-dark-tertiary",children:[a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Retry attempts"}),a.jsxs("div",{className:"relative w-44",children:[a.jsx("select",{value:k.ftp_retry_count??3,onChange:ae=>bn("ftp_retry_count",parseInt(ae.target.value)),className:"w-full px-3 py-2 pr-10 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none appearance-none cursor-pointer",children:[1,2,3,4,5,6,7,8,9,10].map(ae=>a.jsxs("option",{value:ae,children:[ae," ",ae===1?"time":"times"]},ae))}),a.jsx(nr,{className:"absolute right-3 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray pointer-events-none"})]})]}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Retry delay"}),a.jsxs("div",{className:"relative w-44",children:[a.jsx("select",{value:k.ftp_retry_delay??2,onChange:ae=>bn("ftp_retry_delay",parseInt(ae.target.value)),className:"w-full px-3 py-2 pr-10 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none appearance-none cursor-pointer",children:[1,2,3,5,10,15,20,30].map(ae=>a.jsxs("option",{value:ae,children:[ae," ",ae===1?"second":"seconds"]},ae))}),a.jsx(nr,{className:"absolute right-3 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray pointer-events-none"})]})]}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Connection timeout"}),a.jsxs("div",{className:"relative w-44",children:[a.jsx("select",{value:k.ftp_timeout??30,onChange:ae=>bn("ftp_timeout",parseInt(ae.target.value)),className:"w-full px-3 py-2 pr-10 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none appearance-none cursor-pointer",children:[10,15,20,30,45,60,90,120].map(ae=>a.jsxs("option",{value:ae,children:[ae," seconds"]},ae))}),a.jsx(nr,{className:"absolute right-3 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray pointer-events-none"})]}),a.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:"Increase for printers with weak WiFi"})]})]})]})]})]}),a.jsxs("div",{className:"flex-1 lg:max-w-xl space-y-4",children:[a.jsxs(vt,{children:[a.jsx(An,{children:a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsxs("h2",{className:"text-lg font-semibold text-white flex items-center gap-2",children:[a.jsx(bv,{className:"w-5 h-5 text-bambu-green"}),"Home Assistant"]}),k.ha_enabled&&et&&a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx("span",{className:`w-2.5 h-2.5 rounded-full ${et.success?"bg-green-400":"bg-red-400"}`}),a.jsx("span",{className:`text-sm ${et.success?"text-green-400":"text-red-400"}`,children:et.success?"Connected":"Disconnected"})]})]})}),a.jsxs(Nt,{className:"space-y-4",children:[a.jsx("p",{className:"text-sm text-bambu-gray",children:"Connect to Home Assistant to control smart plugs via HA's REST API. Supports switch, light, input_boolean, and script entities."}),a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsxs("div",{className:"flex-1",children:[a.jsx("p",{className:"text-white",children:i("settings.enableHomeAssistant")}),a.jsx("p",{className:"text-xs text-bambu-gray",children:i("settings.homeAssistantDescription")}),k.ha_env_managed&&a.jsxs("div",{className:"flex items-center gap-1 mt-1",children:[a.jsx(Vm,{className:"w-3 h-3 text-bambu-green"}),a.jsx("span",{className:"text-xs text-bambu-green",children:i("settings.autoEnabledViaEnv")})]})]}),a.jsxs("label",{className:"relative inline-flex items-center cursor-pointer",children:[a.jsx("input",{type:"checkbox",checked:k.ha_enabled??!1,onChange:ae=>bn("ha_enabled",ae.target.checked),disabled:k.ha_env_managed,className:"sr-only peer"}),a.jsx("div",{className:`w-11 h-6 bg-bambu-dark-tertiary peer-focus:outline-none rounded-full peer peer-checked:after:translate-x-full peer-checked:after:border-white after:content-[''] after:absolute after:top-[2px] after:left-[2px] after:bg-white after:rounded-full after:h-5 after:w-5 after:transition-all peer-checked:bg-bambu-green ${k.ha_env_managed?"opacity-60 cursor-not-allowed":""}`})]})]}),k.ha_enabled&&a.jsxs(a.Fragment,{children:[a.jsxs("div",{children:[a.jsxs("label",{className:"block text-sm text-bambu-gray mb-1",children:["Home Assistant URL",k.ha_url_from_env&&a.jsx("span",{className:"ml-2 text-xs text-bambu-green",children:i("settings.environmentManagedLabel")})]}),a.jsxs("div",{className:"relative",children:[a.jsx("input",{type:"text",value:k.ha_url??"",onChange:ae=>bn("ha_url",ae.target.value),placeholder:"http://192.168.1.100:8123",disabled:k.ha_url_from_env,className:`w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none ${k.ha_url_from_env?"opacity-60 cursor-not-allowed":""}`}),k.ha_url_from_env&&a.jsx(Vm,{className:"absolute right-3 top-2.5 w-4 h-4 text-bambu-gray"})]}),k.ha_url_from_env&&a.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:i("settings.urlFromEnvReadOnly")})]}),a.jsxs("div",{children:[a.jsxs("label",{className:"block text-sm text-bambu-gray mb-1",children:["Long-Lived Access Token",k.ha_token_from_env&&a.jsx("span",{className:"ml-2 text-xs text-bambu-green",children:i("settings.environmentManagedLabel")})]}),a.jsxs("div",{className:"relative",children:[a.jsx("input",{type:"password",value:k.ha_token??"",onChange:ae=>bn("ha_token",ae.target.value),placeholder:"eyJ0eXAiOiJKV1QiLC...",disabled:k.ha_token_from_env,className:`w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none ${k.ha_token_from_env?"opacity-60 cursor-not-allowed":""}`}),k.ha_token_from_env&&a.jsx(Vm,{className:"absolute right-3 top-2.5 w-4 h-4 text-bambu-gray"})]}),k.ha_token_from_env?a.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:i("settings.tokenFromEnvReadOnly")}):a.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:"Create a token in HA: Profile → Long-Lived Access Tokens → Create Token"})]}),k.ha_url&&k.ha_token&&a.jsx("div",{className:"pt-2 border-t border-bambu-dark-tertiary",children:a.jsxs(Ce,{variant:"secondary",size:"sm",disabled:dt,onClick:async()=>{Lt(!0),lt(null);try{const ae=await re.testHAConnection(k.ha_url,k.ha_token);lt(ae)}catch(ae){lt({success:!1,message:null,error:ae instanceof Error?ae.message:i("common.unknownError")})}finally{Lt(!1)}},children:[dt?a.jsx(it,{className:"w-4 h-4 animate-spin"}):a.jsx(Qg,{className:"w-4 h-4"}),i("settings.testConnection")]})})]})]})]}),a.jsxs(vt,{children:[a.jsx(An,{children:a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsxs("h2",{className:"text-lg font-semibold text-white flex items-center gap-2",children:[a.jsx(Qg,{className:"w-5 h-5 text-blue-400"}),"MQTT Publishing"]}),Fn?.enabled&&a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx("span",{className:`w-2.5 h-2.5 rounded-full ${Fn.connected?"bg-green-400":"bg-red-400"}`}),a.jsx("span",{className:`text-sm ${Fn.connected?"text-green-400":"text-red-400"}`,children:Fn.connected?"Connected":"Disconnected"})]})]})}),a.jsxs(Nt,{className:"space-y-4",children:[a.jsx("p",{className:"text-sm text-bambu-gray",children:"Publish BamBuddy events to an external MQTT broker for integration with Node-RED, Home Assistant, and other automation systems."}),a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsxs("div",{children:[a.jsx("p",{className:"text-white",children:i("settings.enableMqtt")}),a.jsx("p",{className:"text-sm text-bambu-gray",children:"Publish events to external MQTT broker"})]}),a.jsxs("label",{className:"relative inline-flex items-center cursor-pointer",children:[a.jsx("input",{type:"checkbox",checked:k.mqtt_enabled??!1,onChange:ae=>bn("mqtt_enabled",ae.target.checked),className:"sr-only peer"}),a.jsx("div",{className:"w-11 h-6 bg-bambu-dark-tertiary peer-focus:outline-none rounded-full peer peer-checked:after:translate-x-full peer-checked:after:border-white after:content-[''] after:absolute after:top-[2px] after:left-[2px] after:bg-white after:rounded-full after:h-5 after:w-5 after:transition-all peer-checked:bg-bambu-green"})]})]}),k.mqtt_enabled&&a.jsxs("div",{className:"space-y-4 pt-2 border-t border-bambu-dark-tertiary",children:[a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Broker hostname"}),a.jsx("input",{type:"text",value:k.mqtt_broker??"",onChange:ae=>bn("mqtt_broker",ae.target.value),placeholder:"mqtt.example.com or 192.168.1.100",className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none"})]}),a.jsxs("div",{className:"flex items-end gap-4",children:[a.jsxs("div",{className:"flex-1",children:[a.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Port"}),a.jsx("input",{type:"number",min:"1",max:"65535",value:k.mqtt_port??1883,onChange:ae=>bn("mqtt_port",Math.min(65535,Math.max(1,parseInt(ae.target.value)||1883))),className:"w-24 px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none"})]}),a.jsxs("div",{className:"flex items-center gap-3 pb-2",children:[a.jsxs("label",{className:"relative inline-flex items-center cursor-pointer",children:[a.jsx("input",{type:"checkbox",checked:k.mqtt_use_tls??!1,onChange:ae=>{const _t=ae.target.checked;bn("mqtt_use_tls",_t);const Gn=k.mqtt_port??1883;_t&&Gn===1883?bn("mqtt_port",8883):!_t&&Gn===8883&&bn("mqtt_port",1883)},className:"sr-only peer"}),a.jsx("div",{className:"w-11 h-6 bg-bambu-dark-tertiary peer-focus:outline-none rounded-full peer peer-checked:after:translate-x-full peer-checked:after:border-white after:content-[''] after:absolute after:top-[2px] after:left-[2px] after:bg-white after:rounded-full after:h-5 after:w-5 after:transition-all peer-checked:bg-bambu-green"})]}),a.jsx("span",{className:"text-white text-sm",children:i("settings.useTls")})]})]}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Username (optional)"}),a.jsx("input",{type:"text",value:k.mqtt_username??"",onChange:ae=>bn("mqtt_username",ae.target.value),placeholder:i("settings.leaveEmptyForAnonymous"),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none"})]}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Password (optional)"}),a.jsx("input",{type:"password",value:k.mqtt_password??"",onChange:ae=>bn("mqtt_password",ae.target.value),placeholder:i("settings.leaveEmptyForAnonymous"),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none"})]}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Topic prefix"}),a.jsx("input",{type:"text",value:k.mqtt_topic_prefix??"bambuddy",onChange:ae=>bn("mqtt_topic_prefix",ae.target.value),placeholder:"bambuddy",className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none"}),a.jsxs("p",{className:"text-xs text-bambu-gray mt-1",children:["Topics will be: ",k.mqtt_topic_prefix||"bambuddy","/printers//status, etc."]})]}),Fn&&a.jsx("div",{className:"pt-3 mt-3 border-t border-bambu-dark-tertiary",children:a.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[a.jsx("span",{className:`w-2 h-2 rounded-full ${Fn.connected?"bg-green-400":"bg-red-400"}`}),a.jsx("span",{className:"text-bambu-gray",children:Fn.connected?a.jsxs(a.Fragment,{children:[i("settings.mqttConnectedTo")," ",a.jsxs("span",{className:"text-white",children:[Fn.broker,":",Fn.port]})]}):i("settings.spoolmanDisconnected")})]})})]})]})]})]}),a.jsx("div",{className:"flex-1 lg:max-w-md space-y-4",children:a.jsxs(vt,{children:[a.jsx(An,{children:a.jsxs("h2",{className:"text-lg font-semibold text-white flex items-center gap-2",children:[a.jsx(w3,{className:"w-5 h-5 text-orange-400"}),"Prometheus Metrics"]})}),a.jsxs(Nt,{className:"space-y-4",children:[a.jsxs("p",{className:"text-sm text-bambu-gray",children:["Expose printer metrics at ",a.jsx("code",{className:"bg-bambu-dark px-1 rounded",children:"/api/v1/metrics"})," for Prometheus/Grafana monitoring."]}),a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsxs("div",{children:[a.jsx("p",{className:"text-white",children:i("settings.enableMetricsEndpoint")}),a.jsx("p",{className:"text-xs text-bambu-gray",children:i("settings.prometheusDescription")})]}),a.jsxs("label",{className:"relative inline-flex items-center cursor-pointer",children:[a.jsx("input",{type:"checkbox",checked:k.prometheus_enabled??!1,onChange:ae=>bn("prometheus_enabled",ae.target.checked),className:"sr-only peer"}),a.jsx("div",{className:"w-11 h-6 bg-bambu-dark-tertiary peer-focus:outline-none rounded-full peer peer-checked:after:translate-x-full peer-checked:after:border-white after:content-[''] after:absolute after:top-[2px] after:left-[2px] after:bg-white after:rounded-full after:h-5 after:w-5 after:transition-all peer-checked:bg-bambu-green"})]})]}),k.prometheus_enabled&&a.jsxs("div",{className:"space-y-4 pt-2 border-t border-bambu-dark-tertiary",children:[a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Bearer Token (optional)"}),a.jsx("input",{type:"password",value:k.prometheus_token??"",onChange:ae=>bn("prometheus_token",ae.target.value),placeholder:i("settings.leaveEmptyForNoAuth"),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none"}),a.jsxs("p",{className:"text-xs text-bambu-gray mt-1",children:["If set, requests must include ",a.jsx("code",{className:"bg-bambu-dark px-1 rounded",children:"Authorization: Bearer "})]})]}),a.jsxs("div",{className:"pt-2 border-t border-bambu-dark-tertiary",children:[a.jsx("p",{className:"text-sm text-white mb-2",children:i("settings.availableMetrics")}),a.jsxs("div",{className:"text-xs text-bambu-gray space-y-1",children:[a.jsxs("p",{children:[a.jsx("code",{className:"text-orange-400",children:"bambuddy_printer_connected"})," - Connection status"]}),a.jsxs("p",{children:[a.jsx("code",{className:"text-orange-400",children:"bambuddy_printer_state"})," - Printer state (idle/printing/etc)"]}),a.jsxs("p",{children:[a.jsx("code",{className:"text-orange-400",children:"bambuddy_print_progress"})," - Print progress 0-100%"]}),a.jsxs("p",{children:[a.jsx("code",{className:"text-orange-400",children:"bambuddy_bed_temp_celsius"})," - Bed temperature"]}),a.jsxs("p",{children:[a.jsx("code",{className:"text-orange-400",children:"bambuddy_nozzle_temp_celsius"})," - Nozzle temperature"]}),a.jsxs("p",{children:[a.jsx("code",{className:"text-orange-400",children:"bambuddy_prints_total"})," - Total prints by result"]}),a.jsx("p",{className:"text-bambu-gray/70 italic",children:"...and more (layers, fans, queue, filament usage)"})]})]})]})]})]})})]}),et&&a.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50",children:a.jsxs("div",{className:"bg-bambu-dark-secondary rounded-lg p-6 max-w-md w-full mx-4",children:[a.jsxs("div",{className:"flex items-center gap-3 mb-4",children:[et.success?a.jsx(gr,{className:"w-8 h-8 text-green-400"}):a.jsx(ha,{className:"w-8 h-8 text-red-400"}),a.jsx("h3",{className:"text-lg font-medium text-white",children:et.success?"Connection Successful":"Connection Failed"})]}),a.jsx("p",{className:"text-bambu-gray mb-6",children:et.success?et.message||"Successfully connected to Home Assistant.":et.error||"Failed to connect to Home Assistant."}),a.jsx("div",{className:"flex justify-end",children:a.jsx(Ce,{variant:"primary",onClick:()=>lt(null),children:"OK"})})]})}),pe==="plugs"&&a.jsxs("div",{className:"max-w-4xl",children:[a.jsxs("div",{className:"flex items-start justify-between mb-6",children:[a.jsxs("div",{children:[a.jsxs("h2",{className:"text-lg font-semibold text-white flex items-center gap-2",children:[a.jsx(hl,{className:"w-5 h-5 text-bambu-green"}),"Smart Plugs"]}),a.jsx("p",{className:"text-sm text-bambu-gray mt-1",children:"Connect smart plugs (Tasmota or Home Assistant) to automate power control and track energy usage for your printers."})]}),a.jsxs("div",{className:"flex items-center gap-2 pt-1 shrink-0",children:[Ht&&Ht.filter(ae=>ae.enabled).length>1&&a.jsxs(a.Fragment,{children:[a.jsxs(Ce,{variant:"secondary",size:"sm",className:"whitespace-nowrap",onClick:()=>be("on"),disabled:Yc.isPending,title:i("settings.turnAllPlugsOn"),children:[Yc.isPending?a.jsx(it,{className:"w-4 h-4 animate-spin"}):a.jsx(fd,{className:"w-4 h-4 text-bambu-green"}),"All On"]}),a.jsxs(Ce,{variant:"secondary",size:"sm",className:"whitespace-nowrap",onClick:()=>be("off"),disabled:Yc.isPending,title:i("settings.turnAllPlugsOff"),children:[Yc.isPending?a.jsx(it,{className:"w-4 h-4 animate-spin"}):a.jsx(oC,{className:"w-4 h-4 text-red-400"}),"All Off"]})]}),a.jsxs(Ce,{className:"whitespace-nowrap",onClick:()=>{O(null),P(!0)},children:[a.jsx(ar,{className:"w-4 h-4"}),"Add Smart Plug"]})]})]}),Ht&&Ht.length>0&&a.jsxs(vt,{className:"mb-6",children:[a.jsx(An,{children:a.jsxs("h3",{className:"text-base font-semibold text-white flex items-center gap-2",children:[a.jsx(Wh,{className:"w-4 h-4 text-yellow-400"}),"Energy Summary",Mn&&a.jsx(it,{className:"w-4 h-4 animate-spin text-bambu-gray ml-2"})]})}),a.jsx(Nt,{children:nn?a.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-4",children:[a.jsxs("div",{className:"bg-bambu-dark rounded-lg p-3",children:[a.jsxs("div",{className:"flex items-center gap-2 text-bambu-gray text-xs mb-1",children:[a.jsx(Wh,{className:"w-3 h-3"}),"Current Power"]}),a.jsxs("div",{className:"text-xl font-bold text-white",children:[nn.totalPower.toFixed(1),a.jsx("span",{className:"text-sm font-normal text-bambu-gray ml-1",children:"W"})]}),a.jsxs("div",{className:"text-xs text-bambu-gray mt-1",children:[nn.reachableCount,"/",nn.totalPlugs," plugs online"]})]}),a.jsxs("div",{className:"bg-bambu-dark rounded-lg p-3",children:[a.jsxs("div",{className:"flex items-center gap-2 text-bambu-gray text-xs mb-1",children:[a.jsx(ii,{className:"w-3 h-3"}),"Today"]}),a.jsxs("div",{className:"text-xl font-bold text-white",children:[nn.totalToday.toFixed(2),a.jsx("span",{className:"text-sm font-normal text-bambu-gray ml-1",children:"kWh"})]}),(k?.energy_cost_per_kwh??0)>0&&a.jsxs("div",{className:"text-xs text-bambu-gray mt-1",children:["~",(nn.totalToday*(k?.energy_cost_per_kwh??0)).toFixed(2)," ",ju(k?.currency||"USD")]})]}),a.jsxs("div",{className:"bg-bambu-dark rounded-lg p-3",children:[a.jsxs("div",{className:"flex items-center gap-2 text-bambu-gray text-xs mb-1",children:[a.jsx(w3,{className:"w-3 h-3"}),"Yesterday"]}),a.jsxs("div",{className:"text-xl font-bold text-white",children:[nn.totalYesterday.toFixed(2),a.jsx("span",{className:"text-sm font-normal text-bambu-gray ml-1",children:"kWh"})]}),(k?.energy_cost_per_kwh??0)>0&&a.jsxs("div",{className:"text-xs text-bambu-gray mt-1",children:["~",(nn.totalYesterday*(k?.energy_cost_per_kwh??0)).toFixed(2)," ",ju(k?.currency||"USD")]})]}),a.jsxs("div",{className:"bg-bambu-dark rounded-lg p-3",children:[a.jsxs("div",{className:"flex items-center gap-2 text-bambu-gray text-xs mb-1",children:[a.jsx(f3,{className:"w-3 h-3"}),"Total"]}),a.jsxs("div",{className:"text-xl font-bold text-white",children:[nn.totalLifetime.toFixed(1),a.jsx("span",{className:"text-sm font-normal text-bambu-gray ml-1",children:"kWh"})]}),(k?.energy_cost_per_kwh??0)>0&&a.jsxs("div",{className:"text-xs text-bambu-gray mt-1",children:["~",(nn.totalLifetime*(k?.energy_cost_per_kwh??0)).toFixed(2)," ",ju(k?.currency||"USD")]})]})]}):Mn?null:a.jsx("p",{className:"text-sm text-bambu-gray",children:"Enable plugs to see energy summary"})})]}),Zt?a.jsx("div",{className:"flex justify-center py-12",children:a.jsx(it,{className:"w-8 h-8 text-bambu-green animate-spin"})}):Ht&&Ht.length>0?a.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4",children:Ht.map(ae=>a.jsx(VQe,{plug:ae,onEdit:_t=>{O(_t),P(!0)}},ae.id))}):a.jsx(vt,{children:a.jsx(Nt,{className:"py-12",children:a.jsxs("div",{className:"text-center text-bambu-gray",children:[a.jsx(hl,{className:"w-16 h-16 mx-auto mb-4 opacity-30"}),a.jsx("p",{className:"text-lg font-medium text-white mb-2",children:i("settings.noSmartPlugsTitle")}),a.jsx("p",{className:"text-sm mb-4",children:i("settings.noSmartPlugsDescription")}),a.jsxs(Ce,{onClick:()=>{O(null),P(!0)},children:[a.jsx(ar,{className:"w-4 h-4"}),i("settings.addFirstSmartPlug")]})]})})})]}),pe==="notifications"&&a.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-8",children:[a.jsxs("div",{children:[a.jsxs("div",{className:"flex items-center justify-between mb-4",children:[a.jsxs("h2",{className:"text-lg font-semibold text-white flex items-center gap-2",children:[a.jsx(Xg,{className:"w-5 h-5 text-bambu-green"}),i("settings.providers")]}),a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsxs(Ce,{size:"sm",variant:"secondary",onClick:()=>oe(!0),children:[a.jsx(N0,{className:"w-4 h-4"}),i("settings.log")]}),pn&&pn.length>0&&a.jsxs(Ce,{size:"sm",variant:"secondary",onClick:()=>{gx(null),bx.mutate()},disabled:bx.isPending,children:[bx.isPending?a.jsx(it,{className:"w-4 h-4 animate-spin"}):a.jsx(lC,{className:"w-4 h-4"}),i("settings.testAll")]}),a.jsxs(Ce,{size:"sm",onClick:()=>{q(null),R(!0)},children:[a.jsx(ar,{className:"w-4 h-4"}),"Add"]})]})]}),a.jsx(vt,{className:"mb-4",children:a.jsx(Nt,{className:"py-3",children:a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsxs("div",{children:[a.jsx("p",{className:"text-white text-sm font-medium",children:i("settings.notificationLanguage")}),a.jsx("p",{className:"text-xs text-bambu-gray",children:i("settings.notificationLanguageDescription")})]}),a.jsx("select",{value:k.notification_language||"en",onChange:ae=>bn("notification_language",ae.target.value),className:"px-2 py-1.5 bg-bambu-dark border border-bambu-dark-tertiary rounded text-white text-sm focus:outline-none focus:ring-1 focus:ring-bambu-green",children:_B.map(ae=>a.jsx("option",{value:ae.code,children:ae.nativeName},ae.code))})]})})}),a.jsx(vt,{className:"mb-4",children:a.jsx(Nt,{className:"py-3",children:a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsxs("div",{children:[a.jsx("p",{className:"text-white text-sm font-medium",children:i("settings.bedCooledThreshold")}),a.jsx("p",{className:"text-xs text-bambu-gray",children:i("settings.bedCooledThresholdDescription")})]}),a.jsxs("div",{className:"flex items-center gap-1",children:[a.jsx("input",{type:"number",min:20,max:80,step:1,value:k.bed_cooled_threshold??35,onChange:ae=>bn("bed_cooled_threshold",Number(ae.target.value)),className:"w-16 px-2 py-1.5 bg-bambu-dark border border-bambu-dark-tertiary rounded text-white text-sm text-center focus:outline-none focus:ring-1 focus:ring-bambu-green"}),a.jsx("span",{className:"text-sm text-bambu-gray",children:"°C"})]})]})})}),wd&&a.jsx(vt,{className:"mb-4",children:a.jsxs(Nt,{className:"py-3",children:[a.jsxs("div",{className:"flex items-center justify-between mb-2",children:[a.jsx("span",{className:"text-sm font-medium text-white",children:i("settings.testResults")}),a.jsx("button",{onClick:()=>gx(null),className:"text-bambu-gray hover:text-white text-xs",children:i("common.dismiss")})]}),a.jsxs("div",{className:"flex items-center gap-4 text-sm mb-2",children:[a.jsxs("span",{className:"flex items-center gap-1 text-bambu-green",children:[a.jsx(gr,{className:"w-4 h-4"}),i("settings.testPassedCount",{count:wd.success})]}),wd.failed>0&&a.jsxs("span",{className:"flex items-center gap-1 text-red-400",children:[a.jsx(ha,{className:"w-4 h-4"}),i("settings.testFailedCount",{count:wd.failed})]})]}),wd.results.filter(ae=>!ae.success).length>0&&a.jsx("div",{className:"space-y-1 mt-2 pt-2 border-t border-bambu-dark-tertiary",children:wd.results.filter(ae=>!ae.success).map(ae=>a.jsxs("div",{className:"text-xs text-red-400",children:[a.jsxs("span",{className:"font-medium",children:[ae.provider_name,":"]})," ",ae.message]},ae.provider_id))})]})}),Xt?a.jsx("div",{className:"flex justify-center py-12",children:a.jsx(it,{className:"w-6 h-6 text-bambu-green animate-spin"})}):pn&&pn.length>0?a.jsx("div",{className:"space-y-3",children:pn.map(ae=>a.jsx(WQe,{provider:ae,onEdit:_t=>{q(_t),R(!0)}},ae.id))}):a.jsx(vt,{children:a.jsx(Nt,{className:"py-8",children:a.jsxs("div",{className:"text-center text-bambu-gray",children:[a.jsx(Xg,{className:"w-12 h-12 mx-auto mb-3 opacity-30"}),a.jsx("p",{className:"text-sm font-medium text-white mb-2",children:i("settings.noProvidersTitle")}),a.jsx("p",{className:"text-xs mb-3",children:i("settings.noProvidersDescription")}),a.jsxs(Ce,{size:"sm",onClick:()=>{q(null),R(!0)},children:[a.jsx(ar,{className:"w-4 h-4"}),i("settings.addProvider")]})]})})})]}),a.jsxs("div",{children:[a.jsxs("h2",{className:"text-lg font-semibold text-white flex items-center gap-2 mb-4",children:[a.jsx(Ps,{className:"w-5 h-5 text-bambu-green"}),i("settings.messageTemplates")]}),a.jsx("p",{className:"text-sm text-bambu-gray mb-4",children:i("settings.messageTemplatesDescription")}),Kn?a.jsx("div",{className:"flex justify-center py-8",children:a.jsx(it,{className:"w-6 h-6 text-bambu-green animate-spin"})}):Zr&&Zr.length>0?a.jsx("div",{className:"space-y-2",children:[...Zr].sort((ae,_t)=>ae.name.localeCompare(_t.name)).map(ae=>a.jsx(vt,{className:"cursor-pointer hover:border-bambu-green/50 transition-colors",onClick:()=>K(ae),children:a.jsx(Nt,{className:"py-2.5 px-3",children:a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsxs("div",{className:"min-w-0 flex-1",children:[a.jsx("p",{className:"text-white font-medium text-sm truncate",children:ae.name}),a.jsx("p",{className:"text-bambu-gray text-xs truncate mt-0.5",children:ae.title_template})]}),a.jsx("button",{className:"p-1.5 hover:bg-bambu-dark-tertiary rounded transition-colors shrink-0 ml-2",onClick:_t=>{_t.stopPropagation(),K(ae)},children:a.jsx(af,{className:"w-4 h-4 text-bambu-gray"})})]})})},ae.id))}):a.jsx(vt,{children:a.jsx(Nt,{className:"py-8",children:a.jsxs("div",{className:"text-center text-bambu-gray",children:[a.jsx(Ps,{className:"w-12 h-12 mx-auto mb-3 opacity-30"}),a.jsx("p",{className:"text-sm",children:i("settings.noTemplatesAvailable")})]})})})]})]}),pe==="apikeys"&&a.jsxs("div",{className:"grid grid-cols-1 xl:grid-cols-2 gap-8",children:[a.jsxs("div",{children:[a.jsxs("div",{className:"flex items-start justify-between gap-4 mb-6",children:[a.jsxs("div",{className:"flex-1",children:[a.jsxs("h2",{className:"text-lg font-semibold text-white flex items-center gap-2",children:[a.jsx(nl,{className:"w-5 h-5 text-bambu-green"}),i("settings.apiKeys")]}),a.jsx("p",{className:"text-sm text-bambu-gray mt-1",children:i("settings.apiKeysDescription")})]}),a.jsxs(Ce,{size:"sm",onClick:()=>ie(!0),className:"flex-shrink-0",children:[a.jsx(ar,{className:"w-4 h-4"}),i("settings.createKey")]})]}),Q&&a.jsx(vt,{className:"mb-6 border-bambu-green",children:a.jsx(Nt,{className:"py-4",children:a.jsxs("div",{className:"flex items-start gap-3",children:[a.jsx(gr,{className:"w-5 h-5 text-bambu-green flex-shrink-0 mt-0.5"}),a.jsxs("div",{className:"flex-1",children:[a.jsx("p",{className:"text-white font-medium mb-1",children:i("settings.apiKeyCreated")}),a.jsx("p",{className:"text-sm text-bambu-gray mb-2",children:i("settings.apiKeyCopyWarning")}),a.jsxs("div",{className:"flex items-center gap-2 bg-bambu-dark rounded-lg p-2",children:[a.jsx("code",{className:"flex-1 text-sm text-bambu-green font-mono break-all",children:Q}),a.jsx(Ce,{variant:"secondary",size:"sm",onClick:async()=>{try{if(navigator.clipboard&&navigator.clipboard.writeText)await navigator.clipboard.writeText(Q);else{const ae=document.createElement("textarea");ae.value=Q,ae.style.position="fixed",ae.style.left="-999999px",document.body.appendChild(ae),ae.select(),document.execCommand("copy"),document.body.removeChild(ae)}o(i("settings.toast.keyCopied"))}catch{o(i("settings.toast.copyFailed"),"error")}},children:a.jsx(Kl,{className:"w-4 h-4"})})]}),a.jsxs("div",{className:"flex gap-2 mt-3",children:[a.jsx(Ce,{variant:"secondary",size:"sm",onClick:()=>{fe(Q),o(i("settings.toast.keyAddedToBrowser"))},children:i("settings.useInApiBrowser")}),a.jsx(Ce,{variant:"secondary",size:"sm",onClick:()=>se(null),children:i("common.dismiss")})]})]})]})})}),Se&&a.jsxs(vt,{className:"mb-6",children:[a.jsx(An,{children:a.jsx("h3",{className:"text-base font-semibold text-white",children:i("settings.createNewApiKey")})}),a.jsxs(Nt,{className:"space-y-4",children:[a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:i("settings.keyName")}),a.jsx("input",{type:"text",value:Fe,onChange:ae=>V(ae.target.value),placeholder:i("settings.keyNamePlaceholder"),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none"})]}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm text-bambu-gray mb-2",children:i("common.permissions")}),a.jsxs("div",{className:"space-y-2",children:[a.jsxs("label",{className:"flex items-center gap-3 cursor-pointer",children:[a.jsx("input",{type:"checkbox",checked:W.can_read_status,onChange:ae=>ue(_t=>({..._t,can_read_status:ae.target.checked})),className:"w-4 h-4 text-bambu-green rounded border-bambu-dark-tertiary bg-bambu-dark focus:ring-bambu-green"}),a.jsxs("div",{children:[a.jsx("span",{className:"text-white",children:i("settings.readStatus")}),a.jsx("p",{className:"text-xs text-bambu-gray",children:i("settings.readStatusDescription")})]})]}),a.jsxs("label",{className:"flex items-center gap-3 cursor-pointer",children:[a.jsx("input",{type:"checkbox",checked:W.can_queue,onChange:ae=>ue(_t=>({..._t,can_queue:ae.target.checked})),className:"w-4 h-4 text-bambu-green rounded border-bambu-dark-tertiary bg-bambu-dark focus:ring-bambu-green"}),a.jsxs("div",{children:[a.jsx("span",{className:"text-white",children:i("settings.manageQueue")}),a.jsx("p",{className:"text-xs text-bambu-gray",children:i("settings.manageQueueDescription")})]})]}),a.jsxs("label",{className:"flex items-center gap-3 cursor-pointer",children:[a.jsx("input",{type:"checkbox",checked:W.can_control_printer,onChange:ae=>ue(_t=>({..._t,can_control_printer:ae.target.checked})),className:"w-4 h-4 text-bambu-green rounded border-bambu-dark-tertiary bg-bambu-dark focus:ring-bambu-green"}),a.jsxs("div",{children:[a.jsx("span",{className:"text-white",children:i("settings.controlPrinter")}),a.jsx("p",{className:"text-xs text-bambu-gray",children:i("settings.controlPrinterDescription")})]})]})]})]}),a.jsxs("div",{className:"flex items-center gap-2 pt-2",children:[a.jsxs(Ce,{onClick:()=>Mr.mutate({name:Fe||i("settings.unnamedKey"),...W}),disabled:Mr.isPending,children:[Mr.isPending?a.jsx(it,{className:"w-4 h-4 animate-spin"}):a.jsx(ar,{className:"w-4 h-4"}),i("settings.createKey")]}),a.jsx(Ce,{variant:"secondary",onClick:()=>ie(!1),children:i("common.cancel")})]})]})]}),fn?a.jsx("div",{className:"flex justify-center py-12",children:a.jsx(it,{className:"w-8 h-8 text-bambu-green animate-spin"})}):sn&&sn.length>0?a.jsx("div",{className:"space-y-3",children:sn.map(ae=>a.jsx(vt,{children:a.jsx(Nt,{className:"py-3",children:a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsxs("div",{className:"flex items-center gap-3",children:[a.jsx(nl,{className:`w-5 h-5 ${ae.enabled?"text-bambu-green":"text-bambu-gray"}`}),a.jsxs("div",{children:[a.jsx("p",{className:"text-white font-medium",children:ae.name}),a.jsxs("p",{className:"text-xs text-bambu-gray",children:[ae.key_prefix,"••••••••",ae.last_used&&` · ${i("settings.lastUsed")}: ${gb(ae.last_used)}`]})]})]}),a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsxs("div",{className:"flex gap-1 text-xs",children:[ae.can_read_status&&a.jsx("span",{className:"px-1.5 py-0.5 bg-blue-500/20 text-blue-400 rounded",children:i("settings.read")}),ae.can_queue&&a.jsx("span",{className:"px-1.5 py-0.5 bg-green-500/20 text-green-400 rounded",children:i("queue.title")}),ae.can_control_printer&&a.jsx("span",{className:"px-1.5 py-0.5 bg-orange-500/20 text-orange-400 rounded",children:i("settings.control")})]}),a.jsx(Ce,{variant:"secondary",size:"sm",onClick:()=>Ne(ae.id),children:a.jsx(Jt,{className:"w-4 h-4 text-red-400"})})]})]})})},ae.id))}):a.jsx(vt,{children:a.jsx(Nt,{className:"py-12",children:a.jsxs("div",{className:"text-center text-bambu-gray",children:[a.jsx(nl,{className:"w-16 h-16 mx-auto mb-4 opacity-30"}),a.jsx("p",{className:"text-lg font-medium text-white mb-2",children:i("settings.apiKeysEmptyTitle")}),a.jsx("p",{className:"text-sm mb-4",children:i("settings.apiKeysEmptyDescription")}),a.jsxs(Ce,{onClick:()=>ie(!0),children:[a.jsx(ar,{className:"w-4 h-4"}),i("settings.createFirstKey")]})]})})}),a.jsxs(vt,{className:"mt-6",children:[a.jsx(An,{children:a.jsx("h3",{className:"text-base font-semibold text-white",children:i("settings.webhookEndpoints")})}),a.jsxs(Nt,{className:"space-y-3 text-sm",children:[a.jsx("p",{className:"text-bambu-gray",children:i("settings.webhookApiKeyHint")}),a.jsxs("div",{className:"space-y-2 font-mono text-xs",children:[a.jsxs("div",{className:"p-2 bg-bambu-dark rounded",children:[a.jsx("span",{className:"text-blue-400",children:"GET"})," ",a.jsx("span",{className:"text-white",children:"/api/v1/webhook/status"}),a.jsxs("span",{className:"text-bambu-gray",children:[" - ",i("settings.webhook.getAllStatus")]})]}),a.jsxs("div",{className:"p-2 bg-bambu-dark rounded",children:[a.jsx("span",{className:"text-blue-400",children:"GET"})," ",a.jsx("span",{className:"text-white",children:"/api/v1/webhook/status/:id"}),a.jsxs("span",{className:"text-bambu-gray",children:[" - ",i("settings.webhook.getSpecificStatus")]})]}),a.jsxs("div",{className:"p-2 bg-bambu-dark rounded",children:[a.jsx("span",{className:"text-green-400",children:"POST"})," ",a.jsx("span",{className:"text-white",children:"/api/v1/webhook/queue"}),a.jsxs("span",{className:"text-bambu-gray",children:[" - ",i("settings.webhook.addToQueue")]})]}),a.jsxs("div",{className:"p-2 bg-bambu-dark rounded",children:[a.jsx("span",{className:"text-orange-400",children:"POST"})," ",a.jsx("span",{className:"text-white",children:"/api/v1/webhook/printer/:id/pause"}),a.jsxs("span",{className:"text-bambu-gray",children:[" - ",i("settings.webhook.pausePrint")]})]}),a.jsxs("div",{className:"p-2 bg-bambu-dark rounded",children:[a.jsx("span",{className:"text-orange-400",children:"POST"})," ",a.jsx("span",{className:"text-white",children:"/api/v1/webhook/printer/:id/resume"}),a.jsxs("span",{className:"text-bambu-gray",children:[" - ",i("settings.webhook.resumePrint")]})]}),a.jsxs("div",{className:"p-2 bg-bambu-dark rounded",children:[a.jsx("span",{className:"text-red-400",children:"POST"})," ",a.jsx("span",{className:"text-white",children:"/api/v1/webhook/printer/:id/stop"}),a.jsxs("span",{className:"text-bambu-gray",children:[" - ",i("settings.webhook.stopPrint")]})]})]})]})]})]}),a.jsxs("div",{children:[a.jsxs("div",{className:"mb-6",children:[a.jsxs("h2",{className:"text-lg font-semibold text-white flex items-center gap-2",children:[a.jsx(jh,{className:"w-5 h-5 text-bambu-green"}),i("settings.apiBrowser")]}),a.jsx("p",{className:"text-sm text-bambu-gray mt-1",children:i("settings.apiBrowserDescription")})]}),a.jsx(vt,{className:"mb-4",children:a.jsxs(Nt,{className:"py-3",children:[a.jsx("label",{className:"block text-sm text-bambu-gray mb-2",children:i("settings.apiKeyForTesting")}),a.jsx("input",{type:"text",value:ve,onChange:ae=>fe(ae.target.value),placeholder:i("settings.apiKeyPlaceholder"),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white font-mono text-sm focus:border-bambu-green focus:outline-none"}),a.jsx("p",{className:"text-xs text-bambu-gray mt-2",children:i("settings.apiKeyHint")})]})}),a.jsx(mZe,{apiKey:ve})]})]}),pe==="virtual-printer"&&a.jsx(sZe,{}),pe==="filament"&&k&&a.jsx(a.Fragment,{children:a.jsxs("div",{className:"flex flex-col lg:flex-row gap-6 lg:gap-8",children:[a.jsxs("div",{className:"lg:w-1/3 space-y-6",children:[a.jsx(tZe,{}),a.jsxs(vt,{children:[a.jsx(An,{children:a.jsx("h2",{className:"text-lg font-semibold text-white",children:i("settings.amsDisplayThresholds")})}),a.jsxs(Nt,{className:"space-y-4",children:[a.jsx("p",{className:"text-sm text-bambu-gray",children:i("settings.amsThresholdsDescription")}),a.jsxs("div",{className:"space-y-3",children:[a.jsxs("div",{className:"flex items-center gap-2 text-white",children:[a.jsx(FF,{className:"w-4 h-4 text-blue-400"}),a.jsx("span",{className:"font-medium",children:i("settings.humidity")})]}),a.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[a.jsxs("div",{children:[a.jsxs("label",{className:"block text-sm text-bambu-gray mb-1",children:[i("settings.goodGreen")," ≤"]}),a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx("input",{type:"number",min:"0",max:"100",value:k.ams_humidity_good??40,onChange:ae=>bn("ams_humidity_good",parseInt(ae.target.value)||40),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none"}),a.jsx("span",{className:"text-bambu-gray",children:"%"})]})]}),a.jsxs("div",{children:[a.jsxs("label",{className:"block text-sm text-bambu-gray mb-1",children:[i("settings.fairOrange")," ≤"]}),a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx("input",{type:"number",min:"0",max:"100",value:k.ams_humidity_fair??60,onChange:ae=>bn("ams_humidity_fair",parseInt(ae.target.value)||60),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none"}),a.jsx("span",{className:"text-bambu-gray",children:"%"})]})]})]}),a.jsx("p",{className:"text-xs text-bambu-gray",children:i("settings.aboveFairBad")})]}),a.jsxs("div",{className:"space-y-3 pt-2 border-t border-bambu-dark-tertiary",children:[a.jsxs("div",{className:"flex items-center gap-2 text-white",children:[a.jsx(uC,{className:"w-4 h-4 text-orange-400"}),a.jsx("span",{className:"font-medium",children:i("settings.temperature")})]}),a.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[a.jsxs("div",{children:[a.jsxs("label",{className:"block text-sm text-bambu-gray mb-1",children:[i("settings.goodBlue")," ≤"]}),a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx("input",{type:"number",step:"0.5",min:"0",max:"60",value:k.ams_temp_good??28,onChange:ae=>bn("ams_temp_good",parseFloat(ae.target.value)||28),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none"}),a.jsx("span",{className:"text-bambu-gray",children:"°C"})]})]}),a.jsxs("div",{children:[a.jsxs("label",{className:"block text-sm text-bambu-gray mb-1",children:[i("settings.fairOrange")," ≤"]}),a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx("input",{type:"number",step:"0.5",min:"0",max:"60",value:k.ams_temp_fair??35,onChange:ae=>bn("ams_temp_fair",parseFloat(ae.target.value)||35),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none"}),a.jsx("span",{className:"text-bambu-gray",children:"°C"})]})]})]}),a.jsx("p",{className:"text-xs text-bambu-gray",children:i("settings.aboveFairHot")})]}),a.jsxs("div",{className:"space-y-3 pt-4 border-t border-bambu-dark-tertiary",children:[a.jsxs("div",{className:"flex items-center gap-2 text-white",children:[a.jsx(Tc,{className:"w-4 h-4 text-purple-400"}),a.jsx("span",{className:"font-medium",children:i("settings.historyRetention")})]}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:i("settings.keepSensorHistory")}),a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx("input",{type:"number",min:"1",max:"365",value:k.ams_history_retention_days??30,onChange:ae=>bn("ams_history_retention_days",parseInt(ae.target.value)||30),className:"w-24 px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none"}),a.jsx("span",{className:"text-bambu-gray",children:i("common.days")})]})]}),a.jsx("p",{className:"text-xs text-bambu-gray",children:i("settings.historyRetentionDescription")})]}),a.jsxs("div",{className:"space-y-3 pt-4 border-t border-bambu-dark-tertiary",children:[a.jsxs("div",{className:"flex items-center gap-2 text-white",children:[a.jsx(Cr,{className:"w-4 h-4 text-bambu-green"}),a.jsx("span",{className:"font-medium",children:i("settings.printModal")})]}),a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm text-white",children:i("settings.expandCustomMapping")}),a.jsx("p",{className:"text-xs text-bambu-gray mt-0.5",children:i("settings.expandCustomMappingDescription")})]}),a.jsxs("label",{className:"relative inline-flex items-center cursor-pointer",children:[a.jsx("input",{type:"checkbox",checked:k.per_printer_mapping_expanded??!1,onChange:ae=>bn("per_printer_mapping_expanded",ae.target.checked),className:"sr-only peer"}),a.jsx("div",{className:"w-11 h-6 bg-bambu-dark-tertiary peer-focus:outline-none rounded-full peer peer-checked:after:translate-x-full peer-checked:after:border-white after:content-[''] after:absolute after:top-[2px] after:left-[2px] after:bg-white after:rounded-full after:h-5 after:w-5 after:transition-all peer-checked:bg-bambu-green"})]})]})]})]})]})]}),a.jsxs("div",{className:"lg:w-2/3 space-y-6",children:[a.jsx(nZe,{}),a.jsx(rZe,{})]})]})}),Z!==null&&a.jsx(vn,{title:i("settings.deleteApiKeyTitle"),message:i("settings.deleteApiKeyMessage"),confirmText:i("settings.deleteKey"),variant:"danger",onConfirm:()=>{Qr.mutate(Z),Ne(null)},onCancel:()=>Ne(null)}),E&&a.jsx(GQe,{plug:U,onClose:()=>{P(!1),O(null)}}),B&&a.jsx(KQe,{provider:G,onClose:()=>{R(!1),q(null)}}),z&&a.jsx(XQe,{template:z,onClose:()=>K(null)}),Y&&a.jsx(ZQe,{onClose:()=>oe(!1)}),L&&a.jsx(vn,{title:i("settings.clearNotificationLogs"),message:i("settings.clearLogsMessage"),confirmText:i("settings.clearLogs"),variant:"warning",onConfirm:async()=>{D(!1);try{const ae=await re.clearNotificationLogs(30);o(ae.message,"success")}catch{o(i("settings.toast.clearLogsFailed"),"error")}},onCancel:()=>D(!1)}),H&&a.jsx(vn,{title:i("settings.resetUiPreferences"),message:i("settings.resetUiPreferencesMessage"),confirmText:i("settings.resetPreferences"),variant:"default",onConfirm:()=>{he(!1),localStorage.clear(),o(i("settings.toast.uiPreferencesReset"),"success"),setTimeout(()=>window.location.reload(),1e3)},onCancel:()=>he(!1)}),xe&&a.jsx(vn,{title:`Turn All Plugs ${xe==="on"?"On":"Off"}`,message:`This will turn ${xe==="on"?"ON":"OFF"} all ${Ht?.filter(ae=>ae.enabled).length||0} enabled smart plugs. ${xe==="off"?"Any running printers may be affected!":""}`,confirmText:`Turn All ${xe==="on"?"On":"Off"}`,variant:xe==="off"?"danger":"warning",onConfirm:()=>{const ae=xe;be(null),Yc.mutate(ae)},onCancel:()=>be(null)}),Ue&&Et?.release_notes&&a.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4",onClick:()=>Oe(!1),children:a.jsxs(vt,{className:"w-full max-w-2xl max-h-[80vh] flex flex-col",onClick:ae=>ae.stopPropagation(),children:[a.jsxs(An,{className:"flex flex-row items-center justify-between shrink-0",children:[a.jsxs("div",{children:[a.jsxs("h2",{className:"text-lg font-semibold text-white",children:["Release Notes - v",Et.latest_version]}),Et.release_name&&Et.release_name!==Et.latest_version&&a.jsx("p",{className:"text-sm text-bambu-gray",children:Et.release_name})]}),a.jsx("button",{onClick:()=>Oe(!1),className:"p-1 rounded hover:bg-bambu-dark-tertiary text-bambu-gray hover:text-white",children:a.jsx(Ft,{className:"w-5 h-5"})})]}),a.jsx(Nt,{className:"overflow-y-auto flex-1",children:a.jsx("pre",{className:"text-sm text-bambu-gray whitespace-pre-wrap font-sans",children:Et.release_notes})}),a.jsxs("div",{className:"p-4 border-t border-bambu-dark-tertiary shrink-0 flex gap-2",children:[Et.release_url&&a.jsx("a",{href:Et.release_url,target:"_blank",rel:"noopener noreferrer",className:"flex-1",children:a.jsxs(Ce,{variant:"secondary",className:"w-full",children:[a.jsx(Kr,{className:"w-4 h-4"}),"View on GitHub"]})}),a.jsx(Ce,{onClick:()=>Oe(!1),className:"flex-1",children:"Close"})]})]})}),pe==="users"&&a.jsxs("div",{className:"space-y-6",children:[a.jsxs("div",{className:"flex gap-1 border-b border-bambu-dark-tertiary",children:[a.jsxs("button",{onClick:()=>de("users"),className:`px-4 py-2 text-sm font-medium transition-colors border-b-2 -mb-px flex items-center gap-2 ${je==="users"?"text-bambu-green border-bambu-green":"text-bambu-gray hover:text-gray-900 dark:hover:text-white border-transparent"}`,children:[a.jsx(gh,{className:"w-4 h-4"}),i("settings.tabs.users")]}),a.jsxs("button",{onClick:()=>de("email"),className:`px-4 py-2 text-sm font-medium transition-colors border-b-2 -mb-px flex items-center gap-2 ${je==="email"?"text-bambu-green border-bambu-green":"text-bambu-gray hover:text-gray-900 dark:hover:text-white border-transparent"}`,children:[a.jsx(k0,{className:"w-4 h-4"}),i("settings.tabs.emailAuth")||"Email Authentication",zt?.advanced_auth_enabled&&a.jsx("span",{className:"w-2 h-2 rounded-full bg-green-400"})]})]}),je==="users"&&a.jsxs(a.Fragment,{children:[a.jsx(vt,{children:a.jsx(Nt,{className:"py-4",children:a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsxs("div",{className:"flex items-center gap-3",children:[a.jsx("div",{className:`w-10 h-10 rounded-full flex items-center justify-center ${l?"bg-green-500/20":"bg-gray-500/20"}`,children:l?a.jsx(Vm,{className:"w-5 h-5 text-green-400"}):a.jsx(QS,{className:"w-5 h-5 text-gray-400"})}),a.jsxs("div",{children:[a.jsx("h3",{className:"text-white font-medium",children:i("settings.authentication")}),a.jsx("p",{className:"text-sm text-bambu-gray",children:i(l?"settings.authEnabledDescription":"settings.authDisabledDescription")})]})]}),l?c?.is_admin&&a.jsxs(Ce,{variant:"secondary",onClick:()=>rt(!0),children:[a.jsx(QS,{className:"w-4 h-4"}),i("common.disable")]}):a.jsxs(Ce,{onClick:()=>e("/setup"),children:[a.jsx(Vm,{className:"w-4 h-4"}),i("common.enable")]})]})})}),zt?.advanced_auth_enabled&&a.jsx(vt,{className:"border-blue-500/30 bg-blue-500/5",children:a.jsx(Nt,{className:"py-4",children:a.jsxs("div",{className:"flex items-start gap-3",children:[a.jsx("div",{className:"w-10 h-10 rounded-full flex items-center justify-center bg-blue-500/20 flex-shrink-0",children:a.jsx(k0,{className:"w-5 h-5 text-blue-400"})}),a.jsxs("div",{children:[a.jsx("h3",{className:"text-white font-medium",children:i("settings.email.advancedAuthEnabled")}),a.jsx("p",{className:"text-sm text-bambu-gray mt-1",children:i("settings.email.advancedAuthEnabledDesc")})]})]})})}),l&&a.jsxs("div",{className:"grid grid-cols-1 xl:grid-cols-2 gap-6",children:[a.jsxs("div",{className:"space-y-6",children:[c&&a.jsxs(vt,{children:[a.jsx(An,{children:a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsxs("h3",{className:"text-lg font-semibold text-white flex items-center gap-2",children:[a.jsx(gh,{className:"w-5 h-5 text-bambu-green"}),i("settings.currentUser")]}),a.jsxs(Ce,{size:"sm",variant:"ghost",onClick:()=>ye(!0),children:[a.jsx(nl,{className:"w-4 h-4"}),i("settings.changePassword")]})]})}),a.jsx(Nt,{children:a.jsx("div",{className:"flex items-center justify-between",children:a.jsxs("div",{children:[a.jsx("p",{className:"text-white font-medium text-lg",children:c.username}),a.jsxs("div",{className:"flex flex-wrap gap-1 mt-2",children:[c.is_admin&&a.jsx("span",{className:"px-2 py-0.5 rounded-full text-xs font-medium bg-purple-500/20 text-purple-300",children:i("settings.admin")}),c.groups?.map(ae=>a.jsx("span",{className:`px-2 py-0.5 rounded-full text-xs font-medium ${ae.name==="Administrators"?"bg-purple-500/20 text-purple-300":ae.name==="Operators"?"bg-blue-500/20 text-blue-300":ae.name==="Viewers"?"bg-green-500/20 text-green-300":"bg-gray-500/20 text-gray-300"}`,children:ae.name},ae.id))]})]})})})]}),a.jsxs(vt,{children:[a.jsx(An,{children:a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsxs("h3",{className:"text-lg font-semibold text-white flex items-center gap-2",children:[a.jsx(gh,{className:"w-5 h-5 text-bambu-green"}),i("settings.users")]}),dn("users:create")&&a.jsxs(Ce,{size:"sm",onClick:()=>{Xe(!0),Bt({username:"",password:"",email:"",confirmPassword:"",role:"user",group_ids:[]})},children:[a.jsx(ar,{className:"w-4 h-4"}),i("settings.addUser")]})]})}),a.jsx(Nt,{children:Ca?a.jsx("div",{className:"flex items-center justify-center py-8",children:a.jsx(it,{className:"w-6 h-6 text-bambu-green animate-spin"})}):as.length===0?a.jsx("p",{className:"text-center text-bambu-gray py-8",children:i("settings.noUsersFound")}):a.jsx("div",{className:"divide-y divide-bambu-dark-tertiary",children:as.map(ae=>a.jsxs("div",{className:"py-3 flex items-center justify-between",children:[a.jsxs("div",{className:"flex-1 min-w-0",children:[a.jsx("p",{className:"text-white font-medium truncate",children:ae.username}),a.jsxs("div",{className:"flex flex-wrap gap-1 mt-1",children:[ae.is_admin&&a.jsx("span",{className:"px-2 py-0.5 rounded-full text-xs font-medium bg-purple-500/20 text-purple-300",children:i("settings.admin")}),ae.groups?.map(_t=>a.jsx("span",{className:`px-2 py-0.5 rounded-full text-xs font-medium ${_t.name==="Administrators"?"bg-purple-500/20 text-purple-300":_t.name==="Operators"?"bg-blue-500/20 text-blue-300":_t.name==="Viewers"?"bg-green-500/20 text-green-300":"bg-gray-500/20 text-gray-300"}`,children:_t.name},_t.id))]})]}),a.jsxs("div",{className:"flex items-center gap-1 ml-4",children:[dn("users:update")&&a.jsx(Ce,{size:"sm",variant:"ghost",onClick:()=>ho(ae),children:a.jsx(af,{className:"w-4 h-4"})}),dn("users:delete")&&ae.id!==c?.id&&a.jsx(Ce,{size:"sm",variant:"ghost",onClick:()=>Cl(ae.id),children:a.jsx(Jt,{className:"w-4 h-4"})})]})]},ae.id))})})]})]}),a.jsx("div",{children:a.jsxs(vt,{children:[a.jsx(An,{children:a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsxs("h3",{className:"text-lg font-semibold text-white flex items-center gap-2",children:[a.jsx(eE,{className:"w-5 h-5 text-bambu-green"}),i("settings.groups")]}),dn("groups:create")&&a.jsxs(Ce,{size:"sm",onClick:()=>{fr(!0),Dn()},children:[a.jsx(ar,{className:"w-4 h-4"}),i("settings.addGroup")]})]})}),a.jsx(Nt,{children:kl?a.jsx("div",{className:"flex items-center justify-center py-8",children:a.jsx(it,{className:"w-6 h-6 text-bambu-green animate-spin"})}):Gi.length===0?a.jsx("p",{className:"text-center text-bambu-gray py-8",children:i("settings.noGroupsFound")}):a.jsx("div",{className:"divide-y divide-bambu-dark-tertiary",children:Gi.map(ae=>a.jsxs("div",{className:"py-3",children:[a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx(eE,{className:`w-4 h-4 ${ae.name==="Administrators"?"text-purple-400":ae.name==="Operators"?"text-blue-400":ae.name==="Viewers"?"text-green-400":"text-bambu-gray"}`}),a.jsx("span",{className:"text-white font-medium",children:ae.name}),ae.is_system&&a.jsx("span",{className:"px-2 py-0.5 rounded text-xs bg-yellow-500/20 text-yellow-400",children:i("settings.system")})]}),a.jsxs("div",{className:"flex items-center gap-1",children:[dn("groups:update")&&a.jsx(Ce,{size:"sm",variant:"ghost",onClick:()=>mm(ae),children:a.jsx(af,{className:"w-4 h-4"})}),dn("groups:delete")&&!ae.is_system&&a.jsx(Ce,{size:"sm",variant:"ghost",onClick:()=>cr(ae.id),children:a.jsx(Jt,{className:"w-4 h-4"})})]})]}),a.jsx("p",{className:"text-sm text-bambu-gray mt-1 ml-6",children:ae.description||i("settings.noDescription")}),a.jsxs("div",{className:"flex items-center gap-4 mt-2 ml-6 text-xs text-bambu-gray",children:[a.jsx("span",{children:i("settings.userCount",{count:ae.user_count})}),a.jsx("span",{children:i("settings.permissionCount",{count:ae.permissions.length})})]})]},ae.id))})})]})})]}),!l&&a.jsx(vt,{children:a.jsx(Nt,{className:"py-6",children:a.jsxs("div",{className:"text-center",children:[a.jsx(QS,{className:"w-12 h-12 text-bambu-gray mx-auto mb-4"}),a.jsx("h3",{className:"text-lg font-medium text-white mb-2",children:i("settings.authDisabledTitle")}),a.jsx("p",{className:"text-sm text-bambu-gray mb-4 max-w-md mx-auto",children:i("settings.authDisabledMessage")}),a.jsxs("ul",{className:"space-y-2 text-sm text-bambu-gray mb-6 text-left max-w-xs mx-auto",children:[a.jsxs("li",{className:"flex items-start gap-2",children:[a.jsx(gr,{className:"w-4 h-4 text-bambu-green mt-0.5 flex-shrink-0"}),a.jsx("span",{children:i("settings.authDisabledFeature1")})]}),a.jsxs("li",{className:"flex items-start gap-2",children:[a.jsx(gr,{className:"w-4 h-4 text-bambu-green mt-0.5 flex-shrink-0"}),a.jsx("span",{children:i("settings.authDisabledFeature2")})]}),a.jsxs("li",{className:"flex items-start gap-2",children:[a.jsx(gr,{className:"w-4 h-4 text-bambu-green mt-0.5 flex-shrink-0"}),a.jsx("span",{children:i("settings.authDisabledFeature3")})]})]}),a.jsxs(Ce,{onClick:()=>e("/setup"),children:[a.jsx(Vm,{className:"w-4 h-4"}),i("settings.enableAuthentication")]})]})})})]}),je==="email"&&a.jsx("div",{className:"max-w-2xl",children:a.jsx(cZe,{})})]}),Pe&&!zt?.advanced_auth_enabled&&a.jsx("div",{className:"fixed inset-0 bg-black flex items-center justify-center z-50 p-4",onClick:()=>{Xe(!1),Bt({username:"",password:"",email:"",confirmPassword:"",role:"user",group_ids:[]})},children:a.jsxs(vt,{className:"w-full max-w-md",onClick:ae=>ae.stopPropagation(),children:[a.jsx(An,{children:a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx(gh,{className:"w-5 h-5 text-bambu-green"}),a.jsx("h2",{className:"text-lg font-semibold text-white",children:i("settings.createUser")})]}),a.jsx(Ce,{variant:"ghost",size:"sm",onClick:()=>{Xe(!1),Bt({username:"",password:"",email:"",confirmPassword:"",role:"user",group_ids:[]})},children:a.jsx(Ft,{className:"w-5 h-5"})})]})}),a.jsxs(Nt,{children:[a.jsxs("div",{className:"space-y-4",children:[a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm font-medium text-white mb-2",children:i("settings.username")}),a.jsx("input",{type:"text",value:wt.username,onChange:ae=>Bt({...wt,username:ae.target.value}),className:"w-full px-4 py-3 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg text-white placeholder-bambu-gray focus:outline-none focus:ring-2 focus:ring-bambu-green/50 focus:border-bambu-green transition-colors",placeholder:i("settings.enterUsername"),autoComplete:"username"})]}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm font-medium text-white mb-2",children:i("settings.password")}),a.jsx("input",{type:"password",value:wt.password,onChange:ae=>Bt({...wt,password:ae.target.value}),className:"w-full px-4 py-3 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg text-white placeholder-bambu-gray focus:outline-none focus:ring-2 focus:ring-bambu-green/50 focus:border-bambu-green transition-colors",placeholder:i("settings.enterPassword"),autoComplete:"new-password",minLength:6})]}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm font-medium text-white mb-2",children:i("settings.confirmPassword")}),a.jsx("input",{type:"password",value:wt.confirmPassword,onChange:ae=>Bt({...wt,confirmPassword:ae.target.value}),className:`w-full px-4 py-3 bg-bambu-dark-secondary border rounded-lg text-white placeholder-bambu-gray focus:outline-none focus:ring-2 focus:ring-bambu-green/50 focus:border-bambu-green transition-colors ${wt.confirmPassword&&wt.password!==wt.confirmPassword?"border-red-500":"border-bambu-dark-tertiary"}`,placeholder:i("settings.confirmPasswordPlaceholder"),autoComplete:"new-password",minLength:6}),wt.confirmPassword&&wt.password!==wt.confirmPassword&&a.jsx("p",{className:"text-red-400 text-xs mt-1",children:i("settings.passwordsDoNotMatch")})]}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm font-medium text-white mb-2",children:"Groups"}),a.jsxs("div",{className:"space-y-2 max-h-40 overflow-y-auto p-2 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg",children:[Gi.map(ae=>a.jsxs("label",{className:"flex items-center gap-3 px-2 py-1.5 rounded hover:bg-bambu-dark-tertiary cursor-pointer",children:[a.jsx("input",{type:"checkbox",checked:wt.group_ids.includes(ae.id),onChange:()=>br(ae.id),className:"w-4 h-4 rounded border-bambu-gray text-bambu-green focus:ring-bambu-green focus:ring-offset-0 bg-bambu-dark"}),a.jsx("span",{className:"text-sm text-white",children:ae.name}),ae.is_system&&a.jsx("span",{className:"text-xs text-yellow-400",children:"(System)"})]},ae.id)),Gi.length===0&&a.jsx("p",{className:"text-sm text-bambu-gray",children:i("settings.noGroupsAvailable")})]})]})]}),a.jsxs("div",{className:"mt-6 flex justify-end gap-3",children:[a.jsx(Ce,{variant:"secondary",onClick:()=>{Xe(!1),Bt({username:"",password:"",email:"",confirmPassword:"",role:"user",group_ids:[]})},children:"Cancel"}),a.jsx(Ce,{onClick:Br,disabled:wi.isPending||!wt.username||!wt.password||wt.password!==wt.confirmPassword||wt.password.length<6,children:wi.isPending?a.jsxs(a.Fragment,{children:[a.jsx(it,{className:"w-4 h-4 animate-spin"}),"Creating..."]}):a.jsxs(a.Fragment,{children:[a.jsx(ar,{className:"w-4 h-4"}),"Create User"]})})]})]})]})}),Pe&&zt?.advanced_auth_enabled&&a.jsx(eZe,{formData:wt,setFormData:Bt,groups:Gi,onClose:()=>{Xe(!1),Bt({username:"",password:"",email:"",confirmPassword:"",role:"user",group_ids:[]})},onCreate:Br,isCreating:wi.isPending,isCreateButtonDisabled:wi.isPending||!wt.username||!wt.email}),De&&qe!==null&&a.jsx("div",{className:"fixed inset-0 bg-black flex items-center justify-center z-50 p-4",onClick:()=>{Re(!1),pt(null),Bt({username:"",password:"",email:"",confirmPassword:"",role:"user",group_ids:[]})},children:a.jsxs(vt,{className:"w-full max-w-md",onClick:ae=>ae.stopPropagation(),children:[a.jsx(An,{children:a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx(af,{className:"w-5 h-5 text-bambu-green"}),a.jsx("h2",{className:"text-lg font-semibold text-white",children:i("settings.editUser")})]}),a.jsx(Ce,{variant:"ghost",size:"sm",onClick:()=>{Re(!1),pt(null),Bt({username:"",password:"",email:"",confirmPassword:"",role:"user",group_ids:[]})},children:a.jsx(Ft,{className:"w-5 h-5"})})]})}),a.jsxs(Nt,{children:[a.jsxs("div",{className:"space-y-4",children:[a.jsxs("div",{children:[a.jsxs("label",{className:"block text-sm font-medium text-white mb-2",children:[i("settings.username")," ",zt?.advanced_auth_enabled&&a.jsx("span",{className:"text-red-400",children:"*"})]}),a.jsx("input",{type:"text",value:wt.username,onChange:ae=>Bt({...wt,username:ae.target.value}),className:"w-full px-4 py-3 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg text-white placeholder-bambu-gray focus:outline-none focus:ring-2 focus:ring-bambu-green/50 focus:border-bambu-green transition-colors",placeholder:i("settings.enterUsername"),autoComplete:"username"})]}),a.jsxs("div",{children:[a.jsxs("label",{className:"block text-sm font-medium text-white mb-2",children:[i("users.form.email")||"Email"," ",zt?.advanced_auth_enabled?a.jsx("span",{className:"text-red-400",children:"*"}):a.jsxs("span",{className:"text-bambu-gray font-normal",children:["(",i("users.form.optional")||"optional",")"]})]}),a.jsx("input",{type:"email",value:wt.email,onChange:ae=>Bt({...wt,email:ae.target.value}),className:"w-full px-4 py-3 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg text-white placeholder-bambu-gray focus:outline-none focus:ring-2 focus:ring-bambu-green/50 focus:border-bambu-green transition-colors",placeholder:i("users.form.emailPlaceholder")||"user@example.com",required:zt?.advanced_auth_enabled})]}),!zt?.advanced_auth_enabled&&a.jsxs(a.Fragment,{children:[a.jsxs("div",{children:[a.jsxs("label",{className:"block text-sm font-medium text-white mb-2",children:[i("users.form.password")||"Password"," ",a.jsxs("span",{className:"text-bambu-gray font-normal",children:["(",i("users.form.leaveBlankToKeep")||"leave blank to keep current",")"]})]}),a.jsx("input",{type:"password",value:wt.password,onChange:ae=>Bt({...wt,password:ae.target.value,confirmPassword:""}),className:"w-full px-4 py-3 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg text-white placeholder-bambu-gray focus:outline-none focus:ring-2 focus:ring-bambu-green/50 focus:border-bambu-green transition-colors",placeholder:i("settings.enterNewPassword"),autoComplete:"new-password",minLength:6})]}),wt.password&&a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm font-medium text-white mb-2",children:i("settings.confirmPassword")}),a.jsx("input",{type:"password",value:wt.confirmPassword,onChange:ae=>Bt({...wt,confirmPassword:ae.target.value}),className:`w-full px-4 py-3 bg-bambu-dark-secondary border rounded-lg text-white placeholder-bambu-gray focus:outline-none focus:ring-2 focus:ring-bambu-green/50 focus:border-bambu-green transition-colors ${wt.confirmPassword&&wt.password!==wt.confirmPassword?"border-red-500":"border-bambu-dark-tertiary"}`,placeholder:i("settings.confirmNewPassword"),autoComplete:"new-password",minLength:6}),wt.confirmPassword&&wt.password!==wt.confirmPassword&&a.jsx("p",{className:"text-red-400 text-xs mt-1",children:i("settings.passwordsDoNotMatch")})]})]}),zt?.advanced_auth_enabled&&a.jsxs("div",{className:"bg-bambu-dark-secondary/50 border border-bambu-green/20 rounded-lg p-3 space-y-3",children:[a.jsx("p",{className:"text-sm text-bambu-gray",children:i("users.form.passwordManagedByAdvancedAuth")||'Password is managed by Advanced Authentication. Use "Reset Password" to send a new password to the user via email.'}),a.jsx(Ce,{variant:"secondary",size:"sm",onClick:()=>qe&&vr.mutate(qe),disabled:vr.isPending||!wt.email,className:"w-full",children:vr.isPending?a.jsxs(a.Fragment,{children:[a.jsx(it,{className:"w-4 h-4 animate-spin"}),i("users.form.resettingPassword")||"Resetting Password..."]}):a.jsxs(a.Fragment,{children:[a.jsx(Ro,{className:"w-4 h-4"}),i("users.form.resetPassword")||"Reset Password"]})})]}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm font-medium text-white mb-2",children:i("users.form.groups")||"Groups"}),a.jsx("div",{className:"space-y-2 max-h-40 overflow-y-auto p-2 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg",children:Gi.map(ae=>a.jsxs("label",{className:"flex items-center gap-3 px-2 py-1.5 rounded hover:bg-bambu-dark-tertiary cursor-pointer",children:[a.jsx("input",{type:"checkbox",checked:wt.group_ids.includes(ae.id),onChange:()=>br(ae.id),className:"w-4 h-4 rounded border-bambu-gray text-bambu-green focus:ring-bambu-green focus:ring-offset-0 bg-bambu-dark"}),a.jsx("span",{className:"text-sm text-white",children:ae.name}),ae.is_system&&a.jsxs("span",{className:"text-xs text-yellow-400",children:["(",i("users.system")||"System",")"]})]},ae.id))})]})]}),a.jsxs("div",{className:"mt-6 flex justify-end gap-3",children:[a.jsx(Ce,{variant:"secondary",onClick:()=>{Re(!1),pt(null),Bt({username:"",password:"",email:"",confirmPassword:"",role:"user",group_ids:[]})},children:i("users.modal.cancel")||"Cancel"}),a.jsx(Ce,{onClick:()=>Si(qe),disabled:_i.isPending||!wt.username||zt?.advanced_auth_enabled&&!wt.email||!!(!zt?.advanced_auth_enabled&&wt.password&&(wt.password!==wt.confirmPassword||wt.password.length<6)),children:_i.isPending?a.jsxs(a.Fragment,{children:[a.jsx(it,{className:"w-4 h-4 animate-spin"}),i("users.modal.saving")||"Saving..."]}):a.jsxs(a.Fragment,{children:[a.jsx(bs,{className:"w-4 h-4"}),i("users.modal.saveChanges")||"Save Changes"]})})]})]})]})}),At!==null&&a.jsx("div",{className:"fixed inset-0 bg-black/80 flex items-center justify-center z-50 p-4",onClick:()=>{Rt(null),Tt(null)},children:a.jsxs(vt,{className:"w-full max-w-md",onClick:ae=>ae.stopPropagation(),children:[a.jsx(An,{children:a.jsxs("div",{className:"flex items-center gap-2 text-red-400",children:[a.jsx(Jt,{className:"w-5 h-5"}),a.jsx("h3",{className:"text-lg font-semibold",children:i("settings.deleteUserTitle")})]})}),a.jsx(Nt,{className:"space-y-4",children:Ie?a.jsx("div",{className:"flex items-center justify-center py-4",children:a.jsx("div",{className:"animate-spin rounded-full h-6 w-6 border-2 border-bambu-green border-t-transparent"})}):Wt&&Wt.archives+Wt.queue_items+Wt.library_files>0?a.jsxs(a.Fragment,{children:[a.jsx("p",{className:"text-white",children:i("settings.userHasCreated")}),a.jsxs("ul",{className:"list-disc list-inside text-bambu-gray space-y-1",children:[Wt.archives>0&&a.jsxs("li",{children:[Wt.archives," archive",Wt.archives!==1?"s":""]}),Wt.queue_items>0&&a.jsxs("li",{children:[Wt.queue_items," queue item",Wt.queue_items!==1?"s":""]}),Wt.library_files>0&&a.jsxs("li",{children:[Wt.library_files," library file",Wt.library_files!==1?"s":""]})]}),a.jsx("p",{className:"text-bambu-gray text-sm",children:i("settings.userItemsQuestion")}),a.jsxs("div",{className:"flex flex-col gap-2",children:[a.jsx(Ce,{variant:"danger",onClick:()=>Ur.mutate({id:At,deleteItems:!0}),disabled:Ur.isPending,className:"justify-center",children:"Delete user AND their items"}),a.jsx(Ce,{variant:"secondary",onClick:()=>Ur.mutate({id:At,deleteItems:!1}),disabled:Ur.isPending,className:"justify-center",children:"Delete user, keep items (become ownerless)"}),a.jsx(Ce,{variant:"ghost",onClick:()=>{Rt(null),Tt(null)},disabled:Ur.isPending,className:"justify-center",children:"Cancel"})]})]}):a.jsxs(a.Fragment,{children:[a.jsx("p",{className:"text-white",children:i("settings.deleteUserConfirm")}),a.jsx("p",{className:"text-bambu-gray text-sm",children:i("settings.actionCannotBeUndone")}),a.jsxs("div",{className:"flex gap-2 justify-end",children:[a.jsx(Ce,{variant:"ghost",onClick:()=>{Rt(null),Tt(null)},disabled:Ur.isPending,children:"Cancel"}),a.jsx(Ce,{variant:"danger",onClick:()=>Ur.mutate({id:At,deleteItems:!1}),disabled:Ur.isPending,children:"Delete User"})]})]})})]})}),(Tn||Zn)&&a.jsx("div",{className:"fixed inset-0 bg-black flex items-center justify-center z-50 p-4",onClick:()=>{fr(!1),Jn(null),Dn()},children:a.jsxs(vt,{className:"w-full max-w-2xl max-h-[90vh] overflow-y-auto",onClick:ae=>ae.stopPropagation(),children:[a.jsx(An,{children:a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx(eE,{className:"w-5 h-5 text-bambu-green"}),a.jsx("h2",{className:"text-lg font-semibold text-white",children:Zn?"Edit Group":"Create Group"})]}),a.jsx(Ce,{variant:"ghost",size:"sm",onClick:()=>{fr(!1),Jn(null),Dn()},children:a.jsx(Ft,{className:"w-5 h-5"})})]})}),a.jsxs(Nt,{children:[a.jsxs("div",{className:"space-y-4",children:[a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm font-medium text-white mb-2",children:i("settings.groupName")}),a.jsx("input",{type:"text",value:jn.name,onChange:ae=>ai({...jn,name:ae.target.value}),disabled:Zn?.is_system,className:"w-full px-4 py-3 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg text-white placeholder-bambu-gray focus:outline-none focus:ring-2 focus:ring-bambu-green/50 focus:border-bambu-green transition-colors disabled:opacity-50",placeholder:i("settings.enterGroupName")}),Zn?.is_system&&a.jsx("p",{className:"text-xs text-yellow-400 mt-1",children:i("settings.systemGroupWarning")})]}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm font-medium text-white mb-2",children:"Description"}),a.jsx("textarea",{value:jn.description,onChange:ae=>ai({...jn,description:ae.target.value}),rows:2,className:"w-full px-4 py-3 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg text-white placeholder-bambu-gray focus:outline-none focus:ring-2 focus:ring-bambu-green/50 focus:border-bambu-green transition-colors resize-none",placeholder:i("settings.enterDescriptionOptional")})]}),a.jsxs("div",{children:[a.jsxs("label",{className:"block text-sm font-medium text-white mb-2",children:["Permissions (",jn.permissions.length," selected)"]}),a.jsx("div",{className:"space-y-2 max-h-96 overflow-y-auto",children:Ba?.categories.map(ae=>a.jsxs("div",{className:"border border-bambu-dark-tertiary rounded-lg overflow-hidden",children:[a.jsxs("div",{className:"flex items-center justify-between px-4 py-2 bg-bambu-dark-secondary cursor-pointer hover:bg-bambu-dark-tertiary transition-colors",onClick:()=>BM(ae.name),children:[a.jsxs("div",{className:"flex items-center gap-3",children:[a.jsx("button",{type:"button",onClick:_t=>{_t.stopPropagation(),px(ae,!Xc(ae))},className:`w-5 h-5 rounded border flex items-center justify-center transition-colors ${Xc(ae)?"bg-bambu-green border-bambu-green":fm(ae)?"bg-bambu-green/50 border-bambu-green":"border-bambu-gray hover:border-white"}`,children:(Xc(ae)||fm(ae))&&a.jsx(Xr,{className:"w-3 h-3 text-white"})}),a.jsx("span",{className:"text-white font-medium",children:ae.name}),a.jsxs("span",{className:"text-xs text-bambu-gray",children:["(",ae.permissions.filter(_t=>jn.permissions.includes(_t.value)).length,"/",ae.permissions.length,")"]})]}),ne.has(ae.name)?a.jsx(nr,{className:"w-4 h-4 text-bambu-gray"}):a.jsx(pa,{className:"w-4 h-4 text-bambu-gray"})]}),ne.has(ae.name)&&a.jsx("div",{className:"p-3 bg-bambu-dark space-y-2",children:ae.permissions.map(_t=>a.jsxs("label",{className:"flex items-center gap-3 px-2 py-1.5 rounded hover:bg-bambu-dark-secondary cursor-pointer",children:[a.jsx("input",{type:"checkbox",checked:jn.permissions.includes(_t.value),onChange:()=>fx(_t.value),className:"w-4 h-4 rounded border-bambu-gray text-bambu-green focus:ring-bambu-green focus:ring-offset-0 bg-bambu-dark-secondary"}),a.jsx("span",{className:"text-sm text-bambu-gray",children:_t.label})]},_t.value))})]},ae.name))})]})]}),a.jsxs("div",{className:"mt-6 flex justify-end gap-3",children:[a.jsx(Ce,{variant:"secondary",onClick:()=>{fr(!1),Jn(null),Dn()},children:"Cancel"}),a.jsx(Ce,{onClick:Zn?up:Kc,disabled:Ma.isPending||oa.isPending||!jn.name.trim(),children:Ma.isPending||oa.isPending?a.jsxs(a.Fragment,{children:[a.jsx(it,{className:"w-4 h-4 animate-spin"}),Zn?"Saving...":"Creating..."]}):a.jsxs(a.Fragment,{children:[a.jsx(bs,{className:"w-4 h-4"}),Zn?"Save Changes":"Create Group"]})})]})]})]})}),Pn!==null&&a.jsx(vn,{title:i("settings.deleteGroupTitle"),message:i("settings.deleteGroupMessage"),confirmText:i("settings.deleteGroup"),variant:"danger",onConfirm:()=>{ic.mutate(Pn),cr(null)},onCancel:()=>cr(null)}),pe==="backup"&&a.jsx(lZe,{}),Qe&&a.jsx(vn,{title:i("settings.disableAuthenticationTitle"),message:i("settings.disableAuthenticationMessage"),confirmText:i("settings.disableAuthentication"),variant:"danger",onConfirm:async()=>{try{await re.disableAuth(),o(i("settings.toast.authDisabled"),"success"),await u(),rt(!1),window.location.href="/"}catch(ae){const _t=ae instanceof Error?ae.message:i("settings.toast.authDisableFailed");o(_t,"error")}},onCancel:()=>rt(!1)}),we&&a.jsx("div",{className:"fixed inset-0 bg-black/70 flex items-center justify-center z-50 p-4",onClick:()=>{ye(!1),Le({currentPassword:"",newPassword:"",confirmPassword:""})},children:a.jsxs(vt,{className:"w-full max-w-md",onClick:ae=>ae.stopPropagation(),children:[a.jsx(An,{children:a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx(nl,{className:"w-5 h-5 text-bambu-green"}),a.jsx("h2",{className:"text-lg font-semibold text-white",children:i("settings.changePassword")})]}),a.jsx(Ce,{variant:"ghost",size:"sm",onClick:()=>{ye(!1),Le({currentPassword:"",newPassword:"",confirmPassword:""})},children:a.jsx(Ft,{className:"w-5 h-5"})})]})}),a.jsxs(Nt,{children:[a.jsxs("div",{className:"space-y-4",children:[a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm font-medium text-white mb-2",children:"Current Password"}),a.jsx("input",{type:"password",value:le.currentPassword,onChange:ae=>Le({...le,currentPassword:ae.target.value}),className:"w-full px-4 py-3 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg text-white placeholder-bambu-gray focus:outline-none focus:ring-2 focus:ring-bambu-green/50 focus:border-bambu-green transition-colors",placeholder:i("settings.enterCurrentPassword"),autoComplete:"current-password"})]}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm font-medium text-white mb-2",children:"New Password"}),a.jsx("input",{type:"password",value:le.newPassword,onChange:ae=>Le({...le,newPassword:ae.target.value}),className:"w-full px-4 py-3 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg text-white placeholder-bambu-gray focus:outline-none focus:ring-2 focus:ring-bambu-green/50 focus:border-bambu-green transition-colors",placeholder:i("settings.enterNewPasswordMin6"),autoComplete:"new-password",minLength:6})]}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm font-medium text-white mb-2",children:"Confirm New Password"}),a.jsx("input",{type:"password",value:le.confirmPassword,onChange:ae=>Le({...le,confirmPassword:ae.target.value}),className:`w-full px-4 py-3 bg-bambu-dark-secondary border rounded-lg text-white placeholder-bambu-gray focus:outline-none focus:ring-2 focus:ring-bambu-green/50 focus:border-bambu-green transition-colors ${le.confirmPassword&&le.newPassword!==le.confirmPassword?"border-red-500":"border-bambu-dark-tertiary"}`,placeholder:i("settings.confirmNewPassword"),autoComplete:"new-password",minLength:6}),le.confirmPassword&&le.newPassword!==le.confirmPassword&&a.jsx("p",{className:"text-red-400 text-xs mt-1",children:i("settings.passwordsDoNotMatch")})]})]}),a.jsxs("div",{className:"mt-6 flex justify-end gap-3",children:[a.jsx(Ce,{variant:"secondary",onClick:()=>{ye(!1),Le({currentPassword:"",newPassword:"",confirmPassword:""})},children:"Cancel"}),a.jsx(Ce,{onClick:async()=>{if(le.newPassword!==le.confirmPassword){o(i("settings.toast.passwordsDoNotMatch"),"error");return}if(le.newPassword.length<6){o(i("settings.toast.passwordTooShort"),"error");return}$e(!0);try{await re.changePassword(le.currentPassword,le.newPassword),o(i("settings.toast.passwordChanged"),"success"),ye(!1),Le({currentPassword:"",newPassword:"",confirmPassword:""})}catch(ae){const _t=ae instanceof Error?ae.message:"Failed to change password";o(_t,"error")}finally{$e(!1)}},disabled:Me||!le.currentPassword||!le.newPassword||le.newPassword!==le.confirmPassword||le.newPassword.length<6,children:Me?a.jsxs(a.Fragment,{children:[a.jsx(it,{className:"w-4 h-4 animate-spin"}),"Changing..."]}):a.jsxs(a.Fragment,{children:[a.jsx(nl,{className:"w-4 h-4"}),"Change Password"]})})]})]})]})})]})}const Vae=t=>{const e=parseFloat(t);return(Math.trunc(e*1e3)/1e3).toFixed(3)},bZe=t=>t.startsWith("HH")?"HF":"S",xZe=t=>{const e=t.match(/^([A-Z]{2}\d{2})/);return e?e[1]:"HH00"},Gae=t=>{const e=["High Flow_","High Flow ","Standard_","Standard ","HF_","HF ","S_","S "];for(const r of e)if(t.startsWith(r))return t.slice(r.length);const n=t.indexOf("_");return n>0?t.slice(n+1):t};function Bj({profile:t,onEdit:e,onCopy:n,selectionMode:r,isSelected:i,onToggleSelect:s,note:o}){const l=bZe(t.nozzle_id),c=t.nozzle_diameter,u=()=>{r&&s?s():e()};return a.jsxs("div",{className:"flex items-center gap-2",children:[r&&a.jsx("button",{onClick:s,className:"text-bambu-gray hover:text-white transition-colors p-1",children:i?a.jsx(oo,{className:"w-4 h-4 text-bambu-green"}):a.jsx(bl,{className:"w-4 h-4"})}),a.jsxs("button",{onClick:u,className:`flex-1 text-left px-3 py-2 bg-bambu-dark rounded hover:bg-bambu-dark-tertiary transition-colors ${i?"ring-1 ring-bambu-green":""}`,children:[a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx("span",{className:"text-bambu-green font-mono text-sm font-bold whitespace-nowrap",children:Vae(t.k_value)}),a.jsx("span",{className:"text-white text-sm truncate flex-1",title:t.name,children:t.name||"Unnamed"}),o&&a.jsx("span",{title:"Has note",children:a.jsx(yX,{className:"w-3 h-3 text-yellow-500"})}),a.jsxs("span",{className:"text-xs text-bambu-gray whitespace-nowrap",children:[l," ",c]})]}),o&&a.jsxs("div",{className:"text-xs mt-0.5 truncate text-yellow-500/70",title:o,children:["Note: ",o.length>50?o.substring(0,50)+"...":o]})]}),!r&&n&&a.jsx("button",{onClick:d=>{d.stopPropagation(),n()},className:"text-bambu-gray hover:text-white transition-colors p-1",title:"Copy profile",children:a.jsx(Kl,{className:"w-4 h-4"})})]})}function Hj({profile:t,printerId:e,nozzleDiameter:n,existingProfiles:r=[],builtinFilaments:i=[],isDualNozzle:s=!1,initialNote:o="",initialNoteKey:l=null,onClose:c,onSave:u,onSaveNote:d,hasPermission:h}){const{t:f}=Vt(),{showToast:p}=hn(),[x,y]=w.useState(t?.name||""),[b,v]=w.useState(t?.k_value?Vae(t.k_value):"0.020"),[S,N]=w.useState(t?.filament_id||""),[A,C]=w.useState(t?.nozzle_id?xZe(t.nozzle_id):"HH00"),[T,k]=w.useState(t?.nozzle_diameter||n),[j,E]=w.useState(t?[t.extruder_id]:s?[0,1]:[0]),[P,U]=w.useState(!1),[O,B]=w.useState({current:0,total:0}),[R,G]=w.useState(o),q=$r.useMemo(()=>{const ee=new Map;for(const _e of i)ee.set(_e.filament_id,_e.name);const J=new Map;for(const _e of r)if(_e.filament_id&&!J.has(_e.filament_id)){const me=ee.get(_e.filament_id)||Gae(_e.name||"");J.set(_e.filament_id,{id:_e.filament_id,name:me||_e.filament_id})}return Array.from(J.values()).sort((_e,pe)=>_e.name.localeCompare(pe.name))},[r,i]),z=ot({mutationFn:ee=>(console.log("[KProfile] Calling API..."),re.setKProfile(e,ee)),onSuccess:ee=>{if(console.log("[KProfile] Save success:",ee),p(f("kProfiles.toast.profileSaved")),d&&R!==o){let J;R===""&&l?J=l:t&&t.slot_id>0?J=t.setting_id||`slot_${t.slot_id}_${t.filament_id}_${t.extruder_id}`:J=`name_${x}_${S}`,d(J,R)}U(!0),setTimeout(()=>{U(!1),u()},2500)},onError:ee=>{console.error("[KProfile] Save error:",ee),p(ee.message,"error"),U(!1)}}),K=ot({mutationFn:ee=>(console.log("[KProfile] Deleting profile..."),re.deleteKProfile(e,ee)),onSuccess:ee=>{console.log("[KProfile] Delete success:",ee),p(f("kProfiles.toast.profileDeleted")),U(!0),setTimeout(()=>{U(!1),c()},4e3)},onError:ee=>{console.error("[KProfile] Delete error:",ee),p(ee.message,"error"),U(!1)}}),[Y,oe]=w.useState(!1),$=()=>{t&&K.mutate({slot_id:t.slot_id,extruder_id:t.extruder_id,nozzle_id:t.nozzle_id,nozzle_diameter:t.nozzle_diameter,filament_id:t.filament_id,setting_id:t.setting_id})},X=async ee=>{if(ee.preventDefault(),s&&!t&&j.length===0){p(f("kProfiles.toast.selectAtLeastOneExtruder"),"error");return}const J=parseFloat(b).toFixed(6),_e=`${A}-${T}`;if(t||j.length===1){const me={name:x,k_value:J,filament_id:S,nozzle_id:_e,nozzle_diameter:T,extruder_id:t?t.extruder_id:j[0],setting_id:t?.setting_id,slot_id:t?.slot_id??0};console.log("[KProfile] Saving profile:",me),z.mutate(me);return}U(!0),B({current:1,total:j.length});const pe=j.map(me=>({name:x,k_value:J,filament_id:S,nozzle_id:_e,nozzle_diameter:T,extruder_id:me,setting_id:void 0,slot_id:0}));console.log(`[KProfile] Saving ${pe.length} profiles in batch:`,pe);try{if(await re.setKProfilesBatch(e,pe),p(f("kProfiles.toast.profilesSaved",{count:j.length})),d&&R){const me=`name_${x}_${S}`;d(me,R)}}catch(me){console.error("[KProfile] Failed to save batch:",me),p(f("kProfiles.toast.failedToSaveBatch"),"error"),U(!1),B({current:0,total:0});return}B({current:j.length,total:j.length}),setTimeout(()=>{U(!1),B({current:0,total:0}),u()},3e3)};return a.jsxs("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4",children:[a.jsxs(vt,{className:"w-full max-w-md relative",children:[P&&a.jsxs("div",{className:"absolute inset-0 bg-bambu-dark-secondary/90 flex flex-col items-center justify-center z-10 rounded-lg",children:[a.jsx(it,{className:"w-8 h-8 text-bambu-green animate-spin mb-3"}),a.jsx("p",{className:"text-white font-medium",children:O.total>1?f("kProfiles.modal.savingExtruder",{current:O.current,total:O.total}):f("kProfiles.modal.syncing")}),a.jsx("p",{className:"text-bambu-gray text-sm mt-1",children:f("kProfiles.modal.pleaseWait")})]}),a.jsxs(Nt,{className:"p-0",children:[a.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-bambu-dark-tertiary",children:[a.jsx("h2",{className:"text-xl font-semibold text-white",children:f(t?"kProfiles.modal.editTitle":"kProfiles.modal.addTitle")}),a.jsx("button",{onClick:c,className:"text-bambu-gray hover:text-white transition-colors",disabled:P,children:a.jsx(Ft,{className:"w-5 h-5"})})]}),a.jsxs("form",{onSubmit:X,className:"p-4 space-y-4",children:[a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:f("kProfiles.modal.profileName")}),a.jsx("input",{type:"text",value:x,onChange:ee=>y(ee.target.value),disabled:!!t,className:`w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none ${t?"opacity-60 cursor-not-allowed":""}`,placeholder:f("kProfiles.modal.profileNamePlaceholder"),required:!t})]}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:f("kProfiles.modal.kValue")}),a.jsx("input",{type:"text",inputMode:"decimal",value:b,onChange:ee=>{const J=ee.target.value;(J===""||/^\d*\.?\d*$/.test(J))&&v(J)},onBlur:ee=>{const J=parseFloat(ee.target.value);isNaN(J)||v((Math.trunc(J*1e3)/1e3).toFixed(3))},className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none font-mono",placeholder:f("kProfiles.modal.kValuePlaceholder"),required:!0}),a.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:f("kProfiles.modal.kValueHelp")})]}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:f("kProfiles.modal.filament")}),a.jsxs("select",{value:S,onChange:ee=>{const J=ee.target.value;if(N(J),!t&&J&&!x){const _e=q.find(pe=>pe.id===J);_e&&y(`${A==="HH00"?"HF":"S"} ${_e.name}`)}},disabled:!!t,className:`w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none ${t?"opacity-60 cursor-not-allowed":""}`,required:!t,children:[a.jsx("option",{value:"",children:f("kProfiles.modal.selectFilament")}),t?.filament_id&&a.jsx("option",{value:t.filament_id,children:q.find(ee=>ee.id===t.filament_id)?.name||t.filament_id},t.filament_id),!t&&q.map(ee=>a.jsx("option",{value:ee.id,children:ee.name},ee.id))]}),!t&&q.length===0&&a.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:f("kProfiles.modal.noFilamentsHelp")})]}),a.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:f("kProfiles.modal.flowType")}),a.jsxs("select",{value:A,onChange:ee=>{const J=ee.target.value;if(C(J),!t&&S&&!x){const _e=q.find(pe=>pe.id===S);_e&&y(`${J==="HS00"?"HF":"S"} ${_e.name}`)}},disabled:!!t,className:`w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none ${t?"opacity-60 cursor-not-allowed":""}`,children:[a.jsx("option",{value:"HH00",children:f("kProfiles.modal.highFlow")}),a.jsx("option",{value:"HS00",children:f("kProfiles.modal.standard")})]})]}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:f("kProfiles.modal.nozzleSize")}),a.jsxs("select",{value:T,onChange:ee=>k(ee.target.value),disabled:!!t,className:`w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none ${t?"opacity-60 cursor-not-allowed":""}`,children:[a.jsx("option",{value:"0.2",children:"0.2mm"}),a.jsx("option",{value:"0.4",children:"0.4mm"}),a.jsx("option",{value:"0.6",children:"0.6mm"}),a.jsx("option",{value:"0.8",children:"0.8mm"})]})]})]}),s&&a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:f(t?"kProfiles.modal.extruder":"kProfiles.modal.extruders")}),t?a.jsx("div",{className:"px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white opacity-60",children:t.extruder_id===1?f("kProfiles.modal.left"):f("kProfiles.modal.right")}):a.jsxs("div",{className:"flex gap-4",children:[a.jsxs("label",{className:"flex items-center gap-2 cursor-pointer",children:[a.jsx("input",{type:"checkbox",checked:j.includes(1),onChange:ee=>{ee.target.checked?E([...j,1]):E(j.filter(J=>J!==1))},className:"w-4 h-4 rounded border-bambu-dark-tertiary bg-bambu-dark text-bambu-green focus:ring-bambu-green focus:ring-offset-0 accent-bambu-green"}),a.jsx("span",{className:"text-white",children:f("kProfiles.modal.left")})]}),a.jsxs("label",{className:"flex items-center gap-2 cursor-pointer",children:[a.jsx("input",{type:"checkbox",checked:j.includes(0),onChange:ee=>{ee.target.checked?E([...j,0]):E(j.filter(J=>J!==0))},className:"w-4 h-4 rounded border-bambu-dark-tertiary bg-bambu-dark text-bambu-green focus:ring-bambu-green focus:ring-offset-0 accent-bambu-green"}),a.jsx("span",{className:"text-white",children:f("kProfiles.modal.right")})]})]})]}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:f("kProfiles.modal.notes")}),a.jsx("textarea",{value:R,onChange:ee=>G(ee.target.value),placeholder:f("kProfiles.modal.notesPlaceholder"),rows:2,className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white placeholder-bambu-gray focus:border-bambu-green focus:outline-none resize-none"}),a.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:f("kProfiles.modal.notesHelp")})]}),a.jsxs("div",{className:"flex gap-2 pt-4",children:[t&&a.jsx(Ce,{type:"button",variant:"secondary",onClick:()=>oe(!0),disabled:K.isPending||P||!h("kprofiles:delete"),title:h("kprofiles:delete")?void 0:f("kProfiles.permission.noDelete"),className:"text-red-500 hover:bg-red-500/10",children:K.isPending?a.jsx(it,{className:"w-4 h-4 animate-spin"}):a.jsx(Jt,{className:"w-4 h-4"})}),a.jsx(Ce,{type:"button",variant:"secondary",onClick:c,disabled:P,className:"flex-1",children:f("common.cancel")}),a.jsxs(Ce,{type:"submit",disabled:z.isPending||P||!h(t?"kprofiles:update":"kprofiles:create"),title:h(t?"kprofiles:update":"kprofiles:create")?void 0:f(t?"kProfiles.permission.noUpdate":"kProfiles.permission.noCreate"),className:"flex-1",children:[z.isPending?a.jsx(it,{className:"w-4 h-4 animate-spin"}):a.jsx(nC,{className:"w-4 h-4"}),f("common.save")]})]})]})]})]}),Y&&a.jsx("div",{className:"fixed inset-0 bg-black/70 flex items-center justify-center z-[60]",children:a.jsx(vt,{className:"w-full max-w-sm",children:a.jsxs(Nt,{className:"p-6",children:[a.jsxs("div",{className:"flex items-center gap-3 mb-4",children:[a.jsx("div",{className:"w-10 h-10 rounded-full bg-red-500/20 flex items-center justify-center",children:a.jsx(Jt,{className:"w-5 h-5 text-red-500"})}),a.jsxs("div",{children:[a.jsx("h3",{className:"text-lg font-semibold text-white",children:f("kProfiles.deleteConfirm.title")}),a.jsx("p",{className:"text-sm text-bambu-gray",children:f("kProfiles.deleteConfirm.cannotUndo")})]})]}),a.jsx("p",{className:"text-bambu-gray mb-6",children:f("kProfiles.deleteConfirm.message",{name:t?.name})}),a.jsxs("div",{className:"flex gap-3",children:[a.jsx(Ce,{variant:"secondary",onClick:()=>oe(!1),className:"flex-1",children:f("common.cancel")}),a.jsxs(Ce,{onClick:()=>{oe(!1),$()},disabled:K.isPending,className:"flex-1 bg-red-500 hover:bg-red-600 text-white",children:[K.isPending?a.jsx(it,{className:"w-4 h-4 animate-spin"}):a.jsx(Jt,{className:"w-4 h-4"}),f("common.delete")]})]})]})})})]})}const KS={NOZZLE_DIAMETER:"bambusy_kprofiles_nozzle",SORT_OPTION:"bambusy_kprofiles_sort"};function yZe(){const{t}=Vt(),{showToast:e}=hn(),{hasPermission:n}=Ir(),[r,i]=w.useState(null),[s,o]=w.useState(()=>localStorage.getItem(KS.NOZZLE_DIAMETER)||"0.4"),[l,c]=w.useState(null),[u,d]=w.useState(!1),[h,f]=w.useState(null),[p,x]=w.useState(""),[y,b]=w.useState("all"),[v,S]=w.useState("all"),[N,A]=w.useState(()=>localStorage.getItem(KS.SORT_OPTION)||"name"),[C,T]=w.useState(!1),[k,j]=w.useState(new Set),[E,P]=w.useState(!1),[U,O]=w.useState(!1),B=w.useCallback(D=>`${D.slot_id}_${D.extruder_id}`,[]);w.useEffect(()=>{localStorage.setItem(KS.NOZZLE_DIAMETER,s)},[s]),w.useEffect(()=>{localStorage.setItem(KS.SORT_OPTION,N)},[N]);const{data:R,isLoading:G}=Ze({queryKey:["printers"],queryFn:re.getPrinters}),{data:q,isLoading:z,isFetching:K,error:Y,refetch:oe}=Ze({queryKey:["kprofiles",r,s],queryFn:async()=>{console.log("[KProfiles] Fetching profiles for printer",r,"nozzle",s);const D=await re.getKProfiles(r,s);return console.log("[KProfiles] Received profiles:",D?.profiles?.length||0,"profiles"),D},enabled:!!r,retry:!1,staleTime:0,gcTime:0,refetchOnMount:"always"}),{data:$}=Ze({queryKey:["kprofiles",r,"0.4"],queryFn:()=>re.getKProfiles(r,"0.4"),enabled:!!r,staleTime:6e4}),{data:X}=Ze({queryKey:["builtinFilaments"],queryFn:()=>re.getBuiltinFilaments(),staleTime:3e5}),{data:ee}=Ze({queryKey:["filamentIdMap"],queryFn:()=>re.getFilamentIdMap(),staleTime:3e5}),{data:J,refetch:_e}=Ze({queryKey:["kprofile-notes",r],queryFn:()=>re.getKProfileNotes(r),enabled:!!r,staleTime:3e4}),pe=Y?.message?.includes("not connected");w.useEffect(()=>{if(!r&&R&&R.length>0){const D=R.find(H=>H.is_active);D&&i(D.id)}},[r,R]),w.useEffect(()=>{if(r){const D=setTimeout(()=>{oe()},150);return()=>clearTimeout(D)}},[r,s]);const me=R?.filter(D=>D.is_active)||[],je=$r.useMemo(()=>{const D=new Map;if(X)for(const H of X)D.set(H.filament_id,H.name);if(ee)for(const[H,he]of Object.entries(ee))D.has(H)||D.set(H,he);return D},[X,ee]),de=$r.useMemo(()=>Array.from(je.entries()).map(([D,H])=>({filament_id:D,name:H})),[je]),ce=$r.useCallback(D=>je.get(D.filament_id)||Gae(D.name),[je]),Se=$r.useMemo(()=>q?.profiles?q.profiles.filter(H=>{const he=p.toLowerCase(),xe=!he||H.name.toLowerCase().includes(he)||H.filament_id.toLowerCase().includes(he),be=y==="all"||y==="left"&&H.extruder_id===1||y==="right"&&H.extruder_id===0,Ue=v==="all"||v==="hf"&&H.nozzle_id.startsWith("HH")||v==="s"&&H.nozzle_id.startsWith("HS");return xe&&be&&Ue}).sort((H,he)=>{switch(N){case"k_value":return parseFloat(H.k_value)-parseFloat(he.k_value);case"filament":return ce(H).localeCompare(ce(he));default:return H.name.localeCompare(he.name)}}):[],[q?.profiles,p,y,v,N,ce]),ie=R?.find(D=>D.id===r),Fe=ie?.nozzle_count===2;w.useEffect(()=>{const D=H=>{H.target instanceof HTMLInputElement||H.target instanceof HTMLTextAreaElement||H.target instanceof HTMLSelectElement||l||u||h||(H.key==="r"||H.key==="R"?(H.preventDefault(),oe()):H.key==="n"||H.key==="N"?(H.preventDefault(),d(!0)):H.key==="Escape"&&C&&(H.preventDefault(),T(!1),j(new Set)))};return window.addEventListener("keydown",D),()=>window.removeEventListener("keydown",D)},[l,u,h,C,oe]);const V=w.useCallback(()=>{if(!q?.profiles||q.profiles.length===0){e(t("kProfiles.toast.noProfilesToExport"),"error");return}const D={version:1,exported_at:new Date().toISOString(),printer:ie?.name||"Unknown",nozzle_diameter:s,profiles:q.profiles.map(be=>({name:be.name,k_value:be.k_value,filament_id:be.filament_id,nozzle_id:be.nozzle_id,nozzle_diameter:be.nozzle_diameter,extruder_id:be.extruder_id}))},H=new Blob([JSON.stringify(D,null,2)],{type:"application/json"}),he=URL.createObjectURL(H),xe=document.createElement("a");xe.href=he,xe.download=`kprofiles_${ie?.name||"printer"}_${s}mm_${new Date().toISOString().split("T")[0]}.json`,document.body.appendChild(xe),xe.click(),document.body.removeChild(xe),URL.revokeObjectURL(he),e(t("kProfiles.toast.exportedProfiles",{count:q.profiles.length}))},[q?.profiles,ie,s,e,t]),W=w.useCallback(()=>{const D=document.createElement("input");D.type="file",D.accept=".json",D.onchange=async H=>{const he=H.target.files?.[0];if(he)try{const xe=await he.text(),be=JSON.parse(xe);if(!be.profiles||!Array.isArray(be.profiles)){e(t("kProfiles.toast.invalidFileFormat"),"error");return}let Ue=0;for(const Oe of be.profiles)if(!(!Oe.name||!Oe.k_value||!Oe.filament_id))try{await re.setKProfile(r,{name:Oe.name,k_value:parseFloat(Oe.k_value).toFixed(6),filament_id:Oe.filament_id,nozzle_id:Oe.nozzle_id||`HH00-${s}`,nozzle_diameter:Oe.nozzle_diameter||s,extruder_id:Oe.extruder_id??0,slot_id:0}),Ue++,await new Promise(Qe=>setTimeout(Qe,500))}catch(Qe){console.error("Failed to import profile:",Oe.name,Qe)}e(t("kProfiles.toast.importedProfiles",{count:Ue,total:be.profiles.length})),oe()}catch(xe){console.error("Import error:",xe),e(t("kProfiles.toast.failedToParseImport"),"error")}},D.click()},[r,s,e,oe,t]),ue=w.useCallback(D=>{j(H=>{const he=new Set(H);return he.has(D)?he.delete(D):he.add(D),he})},[]),Q=w.useCallback(()=>{j(new Set(Se.map(D=>B(D))))},[Se,B]),se=w.useCallback(()=>{k.size!==0&&P(!0)},[k.size]),Z=w.useCallback(async()=>{const D=Se.filter(he=>k.has(B(he)));O(!0);let H=0;for(const he of D)try{await re.deleteKProfile(r,{slot_id:he.slot_id,extruder_id:he.extruder_id,nozzle_id:he.nozzle_id,nozzle_diameter:he.nozzle_diameter,filament_id:he.filament_id,setting_id:he.setting_id}),H++,await new Promise(xe=>setTimeout(xe,300))}catch(xe){console.error("Failed to delete profile:",he.name,xe)}e(t("kProfiles.toast.profilesDeleted",{count:H})),O(!1),P(!1),T(!1),j(new Set),oe()},[r,k,Se,e,oe,B,t]),Ne=w.useCallback(D=>{const H=[];return D.setting_id&&H.push(D.setting_id),H.push(`slot_${D.slot_id}_${D.filament_id}_${D.extruder_id}`),H.push(`name_${D.name}_${D.filament_id}`),H},[]),ve=w.useCallback(async(D,H)=>{if(r)try{await re.setKProfileNote(r,D,H),_e()}catch(he){console.error("Failed to save note:",he),e(t("kProfiles.toast.failedToSaveNote"),"error")}},[r,_e,e,t]),fe=w.useCallback(D=>{if(!J?.notes)return{note:"",key:null};const H=Ne(D);for(const he of H)if(J.notes[he])return{note:J.notes[he],key:he};return{note:"",key:null}},[J,Ne]),L=w.useCallback(D=>fe(D).note,[fe]);return G?a.jsx("div",{className:"flex justify-center py-12",children:a.jsx(it,{className:"w-8 h-8 text-bambu-green animate-spin"})}):!R||R.length===0?a.jsx(vt,{children:a.jsxs(Nt,{className:"py-12 text-center",children:[a.jsx(Hi,{className:"w-12 h-12 text-bambu-gray mx-auto mb-4"}),a.jsx("h3",{className:"text-lg font-semibold text-white mb-2",children:t("kProfiles.noPrintersConfigured")}),a.jsx("p",{className:"text-bambu-gray",children:t("kProfiles.addPrinterInSettings")})]})}):me.length===0?a.jsx(vt,{children:a.jsxs(Nt,{className:"py-12 text-center",children:[a.jsx(Cr,{className:"w-12 h-12 text-bambu-gray mx-auto mb-4"}),a.jsx("h3",{className:"text-lg font-semibold text-white mb-2",children:t("kProfiles.noActivePrinters")}),a.jsx("p",{className:"text-bambu-gray",children:t("kProfiles.enablePrinterConnection")})]})}):a.jsxs(a.Fragment,{children:[K&&!z&&a.jsxs("div",{className:"fixed inset-0 bg-black/50 flex flex-col items-center justify-center z-40",children:[a.jsx(it,{className:"w-10 h-10 text-bambu-green animate-spin mb-3"}),a.jsx("p",{className:"text-white font-medium",children:t("kProfiles.loadingProfiles")})]}),a.jsxs("div",{className:"flex flex-wrap gap-4 mb-6",children:[a.jsxs("div",{className:"flex-1 min-w-48",children:[a.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:t("kProfiles.printer")}),a.jsx("select",{value:r||"",onChange:D=>i(parseInt(D.target.value)),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",children:me.map(D=>a.jsx("option",{value:D.id,children:D.name},D.id))})]}),a.jsxs("div",{className:"w-32",children:[a.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:t("kProfiles.nozzle")}),a.jsxs("select",{value:s,onChange:D=>o(D.target.value),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",children:[a.jsx("option",{value:"0.2",children:"0.2mm"}),a.jsx("option",{value:"0.4",children:"0.4mm"}),a.jsx("option",{value:"0.6",children:"0.6mm"}),a.jsx("option",{value:"0.8",children:"0.8mm"})]})]}),a.jsxs("div",{className:"flex items-end gap-2",children:[a.jsxs(Ce,{variant:"secondary",onClick:()=>oe(),disabled:K||!n("kprofiles:read"),title:n("kprofiles:read")?void 0:t("kProfiles.permission.noRead"),children:[a.jsx(kr,{className:`w-4 h-4 ${K?"animate-spin":""}`}),t("kProfiles.refresh")]}),a.jsxs(Ce,{onClick:()=>d(!0),disabled:!n("kprofiles:create"),title:n("kprofiles:create")?void 0:t("kProfiles.permission.noCreate"),children:[a.jsx(ar,{className:"w-4 h-4"}),t("kProfiles.addProfile")]})]})]}),a.jsxs("div",{className:"flex flex-wrap gap-4 mb-4",children:[a.jsxs("div",{className:"flex-1 min-w-48 relative",children:[a.jsx(Or,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray"}),a.jsx("input",{type:"text",value:p,onChange:D=>x(D.target.value),placeholder:t("kProfiles.searchPlaceholder"),className:"w-full pl-10 pr-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white placeholder-bambu-gray focus:border-bambu-green focus:outline-none"})]}),Fe&&a.jsx("div",{className:"w-36",children:a.jsxs("select",{value:y,onChange:D=>b(D.target.value),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",children:[a.jsx("option",{value:"all",children:t("kProfiles.allExtruders")}),a.jsx("option",{value:"left",children:t("kProfiles.leftOnly")}),a.jsx("option",{value:"right",children:t("kProfiles.rightOnly")})]})}),a.jsx("div",{className:"w-32",children:a.jsxs("select",{value:v,onChange:D=>S(D.target.value),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",children:[a.jsx("option",{value:"all",children:t("kProfiles.allFlow")}),a.jsx("option",{value:"hf",children:t("kProfiles.hfOnly")}),a.jsx("option",{value:"s",children:t("kProfiles.sOnly")})]})}),a.jsx("div",{className:"w-32",children:a.jsxs("select",{value:N,onChange:D=>A(D.target.value),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",children:[a.jsx("option",{value:"name",children:t("kProfiles.sortName")}),a.jsx("option",{value:"k_value",children:t("kProfiles.sortKValue")}),a.jsx("option",{value:"filament",children:t("kProfiles.sortFilament")})]})})]}),a.jsxs("div",{className:"flex flex-wrap gap-2 mb-6",children:[a.jsxs(Ce,{variant:"secondary",onClick:V,disabled:!q?.profiles?.length||!n("kprofiles:read"),title:n("kprofiles:read")?void 0:t("kProfiles.permission.noExport"),children:[a.jsx(di,{className:"w-4 h-4"}),t("kProfiles.export")]}),a.jsxs(Ce,{variant:"secondary",onClick:W,disabled:!n("kprofiles:create"),title:n("kprofiles:create")?void 0:t("kProfiles.permission.noImport"),children:[a.jsx(Fi,{className:"w-4 h-4"}),t("kProfiles.import")]}),a.jsx("div",{className:"flex-1"}),C?a.jsxs(a.Fragment,{children:[a.jsxs(Ce,{variant:"secondary",onClick:Q,children:[a.jsx(oo,{className:"w-4 h-4"}),t("kProfiles.selectAll")]}),a.jsxs(Ce,{variant:"secondary",onClick:se,disabled:k.size===0||!n("kprofiles:delete"),className:"text-red-500 hover:bg-red-500/10",title:n("kprofiles:delete")?void 0:t("kProfiles.permission.noDelete"),children:[a.jsx(Jt,{className:"w-4 h-4"}),t("kProfiles.delete")," (",k.size,")"]}),a.jsxs(Ce,{variant:"secondary",onClick:()=>{T(!1),j(new Set)},children:[a.jsx(Ft,{className:"w-4 h-4"}),t("common.cancel")]})]}):a.jsxs(Ce,{variant:"secondary",onClick:()=>T(!0),disabled:!Se.length||!n("kprofiles:delete"),title:n("kprofiles:delete")?void 0:t("kProfiles.permission.noDelete"),children:[a.jsx(oo,{className:"w-4 h-4"}),t("kProfiles.select")]})]}),z?a.jsx("div",{className:"flex justify-center py-12",children:a.jsx(it,{className:"w-8 h-8 text-bambu-green animate-spin"})}):pe?a.jsx(vt,{children:a.jsxs(Nt,{className:"py-12 text-center",children:[a.jsx(Rf,{className:"w-12 h-12 text-bambu-gray mx-auto mb-4"}),a.jsx("h3",{className:"text-lg font-semibold text-white mb-2",children:t("kProfiles.printerOffline")}),a.jsx("p",{className:"text-bambu-gray mb-4",children:t("kProfiles.printerOfflineDesc")}),a.jsxs(Ce,{variant:"secondary",onClick:()=>oe(),children:[a.jsx(kr,{className:"w-4 h-4"}),t("common.refresh")]})]})}):Se.length>0?Fe?a.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[a.jsxs("div",{children:[a.jsx("h3",{className:"text-sm font-medium text-bambu-gray mb-2 px-1",children:t("kProfiles.leftExtruder")}),a.jsx("div",{className:"space-y-1",children:Se.filter(D=>D.extruder_id===1).map(D=>a.jsx(Bj,{profile:D,onEdit:()=>c(D),onCopy:()=>f(D),selectionMode:C,isSelected:k.has(B(D)),onToggleSelect:()=>ue(B(D)),note:L(D)},B(D)))})]}),a.jsxs("div",{children:[a.jsx("h3",{className:"text-sm font-medium text-bambu-gray mb-2 px-1",children:t("kProfiles.rightExtruder")}),a.jsx("div",{className:"space-y-1",children:Se.filter(D=>D.extruder_id===0).map(D=>a.jsx(Bj,{profile:D,onEdit:()=>c(D),onCopy:()=>f(D),selectionMode:C,isSelected:k.has(B(D)),onToggleSelect:()=>ue(B(D)),note:L(D)},B(D)))})]})]}):a.jsx("div",{className:"space-y-1",children:Se.map(D=>a.jsx(Bj,{profile:D,onEdit:()=>c(D),onCopy:()=>f(D),selectionMode:C,isSelected:k.has(B(D)),onToggleSelect:()=>ue(B(D)),note:L(D)},B(D)))}):p||y!=="all"||v!=="all"?a.jsx(vt,{children:a.jsxs(Nt,{className:"py-12 text-center",children:[a.jsx(Or,{className:"w-12 h-12 text-bambu-gray mx-auto mb-4"}),a.jsx("h3",{className:"text-lg font-semibold text-white mb-2",children:t("kProfiles.noMatchingProfiles")}),a.jsx("p",{className:"text-bambu-gray",children:t("kProfiles.noMatchingProfilesDesc")})]})}):a.jsx(vt,{children:a.jsxs(Nt,{className:"py-12 text-center",children:[a.jsx(nC,{className:"w-12 h-12 text-bambu-gray mx-auto mb-4"}),a.jsx("h3",{className:"text-lg font-semibold text-white mb-2",children:t("kProfiles.noKProfiles")}),a.jsx("p",{className:"text-bambu-gray mb-4",children:t("kProfiles.noKProfilesDesc",{diameter:s})}),a.jsxs(Ce,{onClick:()=>d(!0),children:[a.jsx(ar,{className:"w-4 h-4"}),t("kProfiles.createFirstProfile")]})]})}),l&&r&&(()=>{const{note:D,key:H}=fe(l);return a.jsx(Hj,{profile:l,printerId:r,nozzleDiameter:s,existingProfiles:$?.profiles||q?.profiles,builtinFilaments:de,isDualNozzle:Fe,initialNote:D,initialNoteKey:H,onSaveNote:ve,hasPermission:n,onClose:()=>{console.log("[KProfiles] Edit modal onClose - refetching profiles..."),c(null),oe()},onSave:()=>{c(null),oe()}})})(),u&&r&&a.jsx(Hj,{printerId:r,nozzleDiameter:s,existingProfiles:$?.profiles||q?.profiles,builtinFilaments:de,isDualNozzle:Fe,onSaveNote:ve,hasPermission:n,onClose:()=>{d(!1),oe()},onSave:()=>{d(!1),oe()}}),h&&r&&a.jsx(Hj,{printerId:r,nozzleDiameter:s,existingProfiles:$?.profiles||q?.profiles,builtinFilaments:de,isDualNozzle:Fe,onSaveNote:ve,hasPermission:n,profile:{...h,slot_id:0,name:`${h.name} (Copy)`},onClose:()=>{f(null),oe()},onSave:()=>{f(null),oe()}}),E&&a.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4",children:a.jsx(vt,{className:"w-full max-w-sm",children:a.jsxs(Nt,{className:"p-6",children:[a.jsxs("div",{className:"flex items-center gap-3 mb-4",children:[a.jsx("div",{className:"w-10 h-10 rounded-full bg-red-500/20 flex items-center justify-center",children:a.jsx(Jt,{className:"w-5 h-5 text-red-500"})}),a.jsxs("div",{children:[a.jsx("h3",{className:"text-lg font-semibold text-white",children:t("kProfiles.bulkDelete.title")}),a.jsx("p",{className:"text-sm text-bambu-gray",children:t("kProfiles.bulkDelete.cannotUndo")})]})]}),a.jsx("p",{className:"text-bambu-gray mb-6",children:t("kProfiles.bulkDelete.message",{count:k.size})}),a.jsxs("div",{className:"flex gap-3",children:[a.jsx(Ce,{variant:"secondary",onClick:()=>P(!1),disabled:U,className:"flex-1",children:t("common.cancel")}),a.jsxs(Ce,{onClick:Z,disabled:U,className:"flex-1 bg-red-500 hover:bg-red-600 text-white",children:[U?a.jsx(it,{className:"w-4 h-4 animate-spin"}):a.jsx(Jt,{className:"w-4 h-4"}),t("common.delete")]})]})]})})})]})}const qae=["PLA","PETG","ABS","ASA","TPU","PC","PA","PVA","HIPS","PP","PET","NYLON"],vZe={PLA:"E8E8E8",PETG:"4A90D9",ABS:"E67E22",ASA:"D35400",TPU:"9B59B6",PC:"BDC3C7",PA:"2ECC71",NYLON:"2ECC71",PVA:"F1C40F",HIPS:"95A5A6",PP:"ECF0F1",PET:"3498DB"};function wZe(t){const e=t.toUpperCase();for(const n of qae)if(new RegExp(`\\b${n}\\b`).test(e))return n;return null}function _Ze(t){const e=t.replace(/@.+$/,"").trim(),n=e.toUpperCase();for(const r of qae){const i=n.indexOf(r);if(i>0){const s=e.slice(0,i).trim();if(s&&s.length>1)return s}}return null}function $j({preset:t,onDelete:e,onExpand:n,isExpanded:r}){const{t:i}=Vt(),{hasPermission:s}=Ir(),o=t.filament_type||wZe(t.name),l=t.filament_vendor||_Ze(t.name);let c=null,u=!1;if(t.default_filament_colour)try{const d=JSON.parse(t.default_filament_colour),h=Array.isArray(d)?d[0]:d;typeof h=="string"&&/^#?[0-9a-fA-F]{6,8}$/.test(h.replace("#",""))&&(c=h.replace("#","").slice(0,6),u=!0)}catch{const d=t.default_filament_colour;/^#?[0-9a-fA-F]{6,8}$/.test(d.replace("#",""))&&(c=d.replace("#","").slice(0,6),u=!0)}return!c&&o&&(c=vZe[o.toUpperCase()]||null),a.jsx(vt,{className:"bg-bambu-dark border-bambu-dark-tertiary hover:border-bambu-dark-tertiary/80 transition-colors",children:a.jsxs(Nt,{className:"p-3",children:[a.jsxs("div",{className:"flex items-start justify-between gap-2",children:[a.jsxs("div",{className:"flex-1 min-w-0",children:[a.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[t.preset_type==="filament"&&a.jsx("div",{className:`w-4 h-4 rounded-full border border-white/20 flex-shrink-0 ${!u&&!c?"opacity-25":u?"":"opacity-50"}`,style:{backgroundColor:c?`#${c}`:"#666"}}),a.jsx("span",{className:"text-sm font-medium text-white truncate",children:t.name})]}),a.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[o&&a.jsx("span",{className:"text-xs px-1.5 py-0.5 rounded bg-bambu-green/20 text-bambu-green",children:o}),l&&a.jsx("span",{className:"text-xs text-bambu-gray",children:l}),a.jsx("span",{className:"text-xs px-1.5 py-0.5 rounded bg-blue-500/20 text-blue-400",children:i("profiles.localProfiles.badge")})]})]}),a.jsxs("div",{className:"flex items-center gap-1 flex-shrink-0",children:[s("settings:update")&&a.jsx("button",{onClick:()=>e(t.id),className:"p-1 text-bambu-gray hover:text-red-400 transition-colors",title:i("profiles.localProfiles.delete"),children:a.jsx(Jt,{className:"w-3.5 h-3.5"})}),a.jsx("button",{onClick:()=>n(r?null:t.id),className:"p-1 text-bambu-gray hover:text-white transition-colors",children:r?a.jsx(Wl,{className:"w-3.5 h-3.5"}):a.jsx(nr,{className:"w-3.5 h-3.5"})})]})]}),r&&a.jsxs("div",{className:"mt-3 pt-3 border-t border-bambu-dark-tertiary text-xs space-y-1.5",children:[o&&a.jsxs("div",{className:"flex justify-between",children:[a.jsx("span",{className:"text-bambu-gray",children:i("profiles.localProfiles.filamentType")}),a.jsx("span",{className:"text-white",children:o})]}),l&&a.jsxs("div",{className:"flex justify-between",children:[a.jsx("span",{className:"text-bambu-gray",children:i("profiles.localProfiles.vendor")}),a.jsx("span",{className:"text-white",children:l})]}),t.nozzle_temp_min!=null&&t.nozzle_temp_max!=null&&a.jsxs("div",{className:"flex justify-between",children:[a.jsx("span",{className:"text-bambu-gray",children:i("profiles.localProfiles.nozzleTemp")}),a.jsxs("span",{className:"text-white",children:[t.nozzle_temp_min,"–",t.nozzle_temp_max,"°C"]})]}),t.filament_cost&&a.jsxs("div",{className:"flex justify-between",children:[a.jsx("span",{className:"text-bambu-gray",children:i("profiles.localProfiles.cost")}),a.jsx("span",{className:"text-white",children:t.filament_cost})]}),t.filament_density&&a.jsxs("div",{className:"flex justify-between",children:[a.jsx("span",{className:"text-bambu-gray",children:i("profiles.localProfiles.density")}),a.jsxs("span",{className:"text-white",children:[t.filament_density," g/cm³"]})]}),t.pressure_advance&&a.jsxs("div",{className:"flex justify-between",children:[a.jsx("span",{className:"text-bambu-gray",children:i("profiles.localProfiles.pressureAdvance")}),a.jsx("span",{className:"text-white",children:t.pressure_advance})]}),t.compatible_printers&&a.jsxs("div",{className:"flex justify-between",children:[a.jsx("span",{className:"text-bambu-gray",children:i("profiles.localProfiles.compatiblePrinters")}),a.jsx("span",{className:"text-white truncate ml-2",children:(()=>{try{return JSON.parse(t.compatible_printers).join(", ")}catch{return t.compatible_printers}})()})]}),t.inherits&&t.inherits!==t.name&&a.jsxs("div",{className:"flex justify-between",children:[a.jsx("span",{className:"text-bambu-gray",children:i("profiles.localProfiles.inheritsFrom")}),a.jsx("span",{className:"text-white truncate ml-2",children:t.inherits})]}),a.jsxs("div",{className:"flex justify-between",children:[a.jsx("span",{className:"text-bambu-gray",children:i("profiles.localProfiles.source")}),a.jsx("span",{className:"text-white capitalize",children:t.source})]})]})]})})}function SZe(){const{t}=Vt(),{hasPermission:e}=Ir(),n=tn(),{showToast:r}=hn(),[i,s]=w.useState(""),[o,l]=w.useState(null),[c,u]=w.useState(!1),[d,h]=w.useState(null),{data:f,isLoading:p}=Ze({queryKey:["localPresets"],queryFn:()=>re.getLocalPresets()}),x=ot({mutationFn:async k=>{const j=[];for(const E of Array.from(k)){const P=new FormData;P.append("file",E),j.push(await re.importLocalPresets(P))}return j},onSuccess:k=>{n.invalidateQueries({queryKey:["localPresets"]});let j=0,E=0,P=0;for(const U of k)j+=U.imported,E+=U.skipped,P+=U.errors.length;j>0&&r(t("profiles.localProfiles.toast.importSuccess",{count:j})),E>0&&r(t("profiles.localProfiles.toast.importSkipped",{count:E}),"warning"),P>0&&r(t("profiles.localProfiles.toast.importError",{count:P}),"error")},onError:k=>{r(k.message,"error")}}),y=ot({mutationFn:k=>re.deleteLocalPreset(k),onSuccess:()=>{n.invalidateQueries({queryKey:["localPresets"]}),h(null),r(t("profiles.localProfiles.toast.deleted"))}}),b=w.useCallback(k=>{!k||k.length===0||x.mutate(k)},[x]),v=w.useCallback(k=>{k.preventDefault(),u(!1),b(k.dataTransfer.files)},[b]),S=w.useCallback(k=>{if(!i)return k;const j=i.toLowerCase();return k.filter(E=>E.name.toLowerCase().includes(j)||E.filament_type?.toLowerCase().includes(j)||E.filament_vendor?.toLowerCase().includes(j))},[i]),N=w.useMemo(()=>S(f?.filament||[]),[f?.filament,S]),A=w.useMemo(()=>S(f?.printer||[]),[f?.printer,S]),C=w.useMemo(()=>S(f?.process||[]),[f?.process,S]),T=N.length+A.length+C.length;return p?a.jsx("div",{className:"flex items-center justify-center py-16",children:a.jsx(it,{className:"w-8 h-8 text-bambu-green animate-spin"})}):a.jsxs("div",{className:"space-y-6",children:[e("settings:update")&&a.jsxs("div",{onDragOver:k=>{k.preventDefault(),u(!0)},onDragLeave:()=>u(!1),onDrop:v,className:`relative border-2 border-dashed rounded-lg p-6 text-center transition-colors ${c?"border-bambu-green bg-bambu-green/10":"border-bambu-dark-tertiary hover:border-bambu-gray"}`,children:[a.jsx("input",{type:"file",accept:".json,.zip,.orca_filament,.bbscfg,.bbsflmt",multiple:!0,className:"absolute inset-0 w-full h-full opacity-0 cursor-pointer",onChange:k=>b(k.target.files)}),x.isPending?a.jsxs("div",{className:"flex items-center justify-center gap-2",children:[a.jsx(it,{className:"w-5 h-5 text-bambu-green animate-spin"}),a.jsx("span",{className:"text-bambu-gray",children:t("profiles.localProfiles.importing")})]}):a.jsxs(a.Fragment,{children:[a.jsx(Fi,{className:"w-8 h-8 text-bambu-gray mx-auto mb-2"}),a.jsx("p",{className:"text-sm text-white font-medium",children:t("profiles.localProfiles.import")}),a.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:t("profiles.localProfiles.importDesc")})]})]}),T>0&&a.jsxs("div",{className:"relative",children:[a.jsx(Or,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray"}),a.jsx("input",{type:"text",value:i,onChange:k=>s(k.target.value),placeholder:t("profiles.localProfiles.search"),className:"w-full pl-9 pr-4 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-sm text-white placeholder-bambu-gray focus:outline-none focus:border-bambu-green"})]}),T===0&&!p&&a.jsxs("div",{className:"text-center py-12",children:[a.jsx(qb,{className:"w-12 h-12 text-bambu-gray mx-auto mb-3 opacity-50"}),a.jsx("p",{className:"text-bambu-gray",children:t("profiles.localProfiles.noPresets")}),a.jsx("p",{className:"text-xs text-bambu-gray/60 mt-1",children:t("profiles.localProfiles.importDesc")})]}),T>0&&a.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-6",children:[N.length>0&&a.jsxs("div",{children:[a.jsxs("div",{className:"flex items-center gap-2 mb-3",children:[a.jsx(Jk,{className:"w-4 h-4 text-bambu-green"}),a.jsx("h3",{className:"text-sm font-medium text-white",children:t("profiles.localProfiles.filament")}),a.jsxs("span",{className:"text-xs text-bambu-gray",children:["(",N.length,")"]})]}),a.jsx("div",{className:"space-y-2",children:N.map(k=>a.jsx($j,{preset:k,onDelete:j=>h(j),onExpand:l,isExpanded:o===k.id},k.id))})]}),C.length>0&&a.jsxs("div",{children:[a.jsxs("div",{className:"flex items-center gap-2 mb-3",children:[a.jsx(ma,{className:"w-4 h-4 text-blue-400"}),a.jsx("h3",{className:"text-sm font-medium text-white",children:t("profiles.localProfiles.process")}),a.jsxs("span",{className:"text-xs text-bambu-gray",children:["(",C.length,")"]})]}),a.jsx("div",{className:"space-y-2",children:C.map(k=>a.jsx($j,{preset:k,onDelete:j=>h(j),onExpand:l,isExpanded:o===k.id},k.id))})]}),A.length>0&&a.jsxs("div",{children:[a.jsxs("div",{className:"flex items-center gap-2 mb-3",children:[a.jsx(nd,{className:"w-4 h-4 text-orange-400"}),a.jsx("h3",{className:"text-sm font-medium text-white",children:t("profiles.localProfiles.printer")}),a.jsxs("span",{className:"text-xs text-bambu-gray",children:["(",A.length,")"]})]}),a.jsx("div",{className:"space-y-2",children:A.map(k=>a.jsx($j,{preset:k,onDelete:j=>h(j),onExpand:l,isExpanded:o===k.id},k.id))})]})]}),d!==null&&a.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50",children:a.jsxs("div",{className:"bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg p-6 max-w-sm mx-4",children:[a.jsxs("div",{className:"flex items-center gap-2 mb-3",children:[a.jsx(Hi,{className:"w-5 h-5 text-red-400"}),a.jsx("h3",{className:"text-white font-medium",children:t("profiles.localProfiles.deleteConfirmTitle")})]}),a.jsx("p",{className:"text-sm text-bambu-gray mb-4",children:t("profiles.localProfiles.deleteConfirm")}),a.jsxs("div",{className:"flex justify-end gap-2",children:[a.jsx(Ce,{variant:"secondary",size:"sm",onClick:()=>h(null),children:t("profiles.localProfiles.cancel")}),a.jsxs(Ce,{variant:"danger",size:"sm",onClick:()=>y.mutate(d),disabled:y.isPending,children:[y.isPending?a.jsx(it,{className:"w-4 h-4 animate-spin"}):a.jsx(Jt,{className:"w-4 h-4"}),t("profiles.localProfiles.delete")]})]})]})})]})}function xI(t,e){const n=`${t} ${e||""}`,r=n.match(/@?\s*(?:BBL\s+)?(?:Bambu\s+Lab\s+)?([XPAH][1-9][A-Z]?(?:\s*(?:Carbon|mini))?|H2D)/i),i=r?r[1].trim():null,s=n.match(/(\d+\.?\d*)\s*(?:mm\s*)?nozzle|nozzle\s*(\d+\.?\d*)/i),o=s?(s[1]||s[2])+"mm":null,l=n.match(/(\d+\.?\d*)mm\s*(?:Standard|Fine|Extra Fine|Draft|Quality)?/i),c=l?l[1]+"mm":null,u=n.match(/\b(PLA|PETG|ABS|ASA|TPU|PC|PA|PVA|HIPS|PP|PET(?:-?CF)?|PA(?:-?CF)?|PLA(?:-?CF)?)\b/i),d=u?u[1].toUpperCase():null;return{printer:i,nozzle:o,layerHeight:c,filamentType:d}}function mv(t){return/^(P[FPM]US|PF\d|PP\d)/.test(t)}function NZe(t,e){const n=Zi(t);if(!n)return"";const i=new Date().getTime()-n.getTime(),s=Math.floor(i/6e4),o=Math.floor(i/36e5),l=Math.floor(i/864e5);return s<1?e("profiles.time.justNow"):s<60?e("profiles.time.minsAgo",{count:s}):o<24?e("profiles.time.hoursAgo",{count:o}):l<7?e("profiles.time.daysAgo",{count:l}):n.toLocaleDateString()}function kZe({onSuccess:t,t:e}){const{showToast:n}=hn(),[r,i]=w.useState("email"),[s,o]=w.useState(""),[l,c]=w.useState(""),[u,d]=w.useState(""),[h,f]=w.useState(""),[p,x]=w.useState("global"),[y,b]=w.useState(null),[v,S]=w.useState(null),N=ot({mutationFn:()=>re.cloudLogin(s,l,p),onSuccess:j=>{j.success?(n(e("profiles.login.toast.loggedIn")),t()):j.needs_verification?(b(j.verification_type||"email"),S(j.tfa_key||null),j.verification_type==="totp"?n(e("profiles.login.toast.enterTotp")):n(e("profiles.login.toast.codeSent")),i("code")):n(j.message,"error")},onError:j=>n(j.message,"error")}),A=ot({mutationFn:()=>re.cloudVerify(s,u,v||void 0),onSuccess:j=>{j.success?(n(e("profiles.login.toast.loggedIn")),t()):n(j.message,"error")},onError:j=>n(j.message,"error")}),C=ot({mutationFn:()=>re.cloudSetToken(h),onSuccess:()=>{n(e("profiles.login.toast.tokenSet")),t()},onError:j=>n(j.message,"error")}),T=j=>{j.preventDefault(),r==="email"?N.mutate():r==="code"?A.mutate():r==="token"&&C.mutate()},k=N.isPending||A.isPending||C.isPending;return a.jsx(vt,{className:"max-w-md mx-auto",children:a.jsxs(Nt,{children:[a.jsxs("div",{className:"text-center mb-6",children:[a.jsx("div",{className:"inline-flex items-center justify-center w-12 h-12 rounded-xl bg-bambu-green/20 mb-3",children:a.jsx(Gb,{className:"w-6 h-6 text-bambu-green"})}),a.jsx("h2",{className:"text-xl font-semibold text-white",children:e("profiles.login.title")}),a.jsx("p",{className:"text-sm text-bambu-gray mt-1",children:e("profiles.login.subtitle")})]}),a.jsxs("form",{onSubmit:T,className:"space-y-4",children:[r==="email"&&a.jsxs(a.Fragment,{children:[a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:e("profiles.login.email")}),a.jsx("input",{type:"email",value:s,onChange:j=>o(j.target.value),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white placeholder-bambu-gray-dark focus:border-bambu-green focus:outline-none",placeholder:"your@email.com",required:!0})]}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:e("profiles.login.password")}),a.jsx("input",{type:"password",value:l,onChange:j=>c(j.target.value),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white placeholder-bambu-gray-dark focus:border-bambu-green focus:outline-none",placeholder:"••••••••",required:!0})]}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:e("profiles.login.region")}),a.jsxs("select",{value:p,onChange:j=>x(j.target.value),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",children:[a.jsx("option",{value:"global",children:e("profiles.login.regionGlobal")}),a.jsx("option",{value:"china",children:e("profiles.login.regionChina")})]})]})]}),r==="code"&&a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:e(y==="totp"?"profiles.login.totpCode":"profiles.login.verificationCode")}),a.jsx("p",{className:"text-xs text-bambu-gray mb-2",children:y==="totp"?e("profiles.login.enterTotpHint"):e("profiles.login.checkEmail",{email:s})}),a.jsx("input",{type:"text",value:u,onChange:j=>d(j.target.value.replace(/\D/g,"").slice(0,6)),className:"w-full px-3 py-3 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white text-center text-2xl tracking-widest font-mono focus:border-bambu-green focus:outline-none",placeholder:"000000",maxLength:6,required:!0})]}),r==="token"&&a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:e("profiles.login.accessToken")}),a.jsx("p",{className:"text-xs text-bambu-gray mb-2",children:e("profiles.login.accessTokenHint")}),a.jsx("textarea",{value:h,onChange:j=>f(j.target.value),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white text-xs font-mono placeholder-bambu-gray-dark focus:border-bambu-green focus:outline-none resize-none",placeholder:"eyJ...",rows:4,required:!0})]}),a.jsxs("div",{className:"flex gap-2 max-[550px]:flex-wrap max-[550px]:items-center",children:[r==="code"&&a.jsx(Ce,{type:"button",variant:"secondary",onClick:()=>i("email"),className:"flex-1",children:e("profiles.login.back")}),a.jsxs(Ce,{type:"submit",disabled:k,className:"flex-1",children:[k?a.jsx(it,{className:"w-4 h-4 animate-spin"}):a.jsx(HB,{className:"w-4 h-4"}),e(r==="email"?"profiles.login.loginButton":r==="code"?"profiles.login.verifyButton":"profiles.login.setTokenButton")]})]}),r==="email"&&a.jsx("div",{className:"pt-4 border-t border-bambu-dark-tertiary",children:a.jsxs("button",{type:"button",onClick:()=>i("token"),className:"text-sm text-bambu-gray hover:text-white flex items-center gap-2 transition-colors",children:[a.jsx(nl,{className:"w-4 h-4"}),e("profiles.login.useToken")]})}),r==="token"&&a.jsx("div",{className:"pt-4 border-t border-bambu-dark-tertiary",children:a.jsxs("button",{type:"button",onClick:()=>i("email"),className:"text-sm text-bambu-gray hover:text-white flex items-center gap-2 transition-colors",children:[a.jsx(HB,{className:"w-4 h-4"}),e("profiles.login.useEmail")]})})]})]})})}function Dg({label:t,value:e,options:n,onChange:r}){const[i,s]=w.useState(!1),o=n.find(l=>l.value===e);return a.jsxs("div",{className:"relative",children:[a.jsxs("button",{onClick:()=>s(!i),className:"flex items-center gap-2 px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-sm text-white hover:border-bambu-gray-dark transition-colors",children:[a.jsxs("span",{className:"text-bambu-gray",children:[t,":"]}),a.jsx("span",{children:o?.label||"All"}),a.jsx(nr,{className:`w-4 h-4 text-bambu-gray transition-transform ${i?"rotate-180":""}`})]}),i&&a.jsxs(a.Fragment,{children:[a.jsx("div",{className:"fixed inset-0 z-10",onClick:()=>s(!1)}),a.jsx("div",{className:"absolute top-full left-0 mt-1 min-w-[160px] bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg shadow-xl z-20 py-1 max-h-60 overflow-y-auto",children:n.map(l=>a.jsxs("button",{onClick:()=>{r(l.value),s(!1)},className:`w-full px-3 py-2 text-left text-sm flex items-center justify-between hover:bg-bambu-dark-tertiary transition-colors ${e===l.value?"text-bambu-green":"text-white"}`,children:[a.jsx("span",{children:l.label}),l.count!==void 0&&a.jsx("span",{className:"text-bambu-gray text-xs",children:l.count})]},l.value))})]})]})}function CZe(){const[t,e]=w.useState(!1);w.useEffect(()=>{const r=()=>{e(window.scrollY>300)};return window.addEventListener("scroll",r),()=>window.removeEventListener("scroll",r)},[]);const n=()=>{window.scrollTo({top:0,behavior:"smooth"})};return t?a.jsx("button",{onClick:n,className:"fixed bottom-6 right-6 p-3 bg-bambu-green hover:bg-bambu-green-light text-white rounded-full shadow-lg shadow-bambu-green/25 transition-all z-40","aria-label":"Scroll to top",children:a.jsx(Pf,{className:"w-5 h-5"})}):null}function Vj({setting:t,onClick:e,onDuplicate:n,compareMode:r,isCompareSelected:i,compareIndex:s,compareDisabled:o,t:l}){const c=xI(t.name),u=mv(t.setting_id);return a.jsxs("div",{className:"flex items-center gap-2 group",children:[a.jsx("button",{onClick:e,disabled:o,className:`flex-1 text-left px-3 py-2 rounded transition-colors ${i?"bg-blue-500/20 border border-blue-500/50":o?"bg-bambu-dark/50 opacity-40 cursor-not-allowed":"bg-bambu-dark hover:bg-bambu-dark-tertiary"} ${r&&!o?"cursor-pointer":""}`,children:a.jsxs("div",{className:"flex items-center gap-2",children:[i&&s!==void 0&&a.jsx("span",{className:"flex-shrink-0 w-5 h-5 rounded-full bg-blue-500 text-white text-xs flex items-center justify-center font-medium",children:s+1}),!i&&u&&a.jsx("span",{className:"flex-shrink-0 w-1.5 h-1.5 rounded-full bg-bambu-green",title:l("profiles.presets.myPreset")}),a.jsx("span",{className:"text-white text-sm truncate flex-1",title:t.name,children:t.name}),c.filamentType&&t.type==="filament"&&a.jsx("span",{className:"text-xs text-bambu-gray whitespace-nowrap",children:c.filamentType}),c.layerHeight&&t.type==="process"&&a.jsx("span",{className:"text-xs text-bambu-gray whitespace-nowrap",children:c.layerHeight}),c.printer&&a.jsx("span",{className:"text-xs text-bambu-gray whitespace-nowrap",children:c.printer})]})}),a.jsx("button",{onClick:d=>{d.stopPropagation(),n()},className:"opacity-0 group-hover:opacity-100 text-bambu-gray hover:text-white transition-all p-1",title:l("profiles.presets.duplicate"),children:a.jsx(Kl,{className:"w-4 h-4"})})]})}function fF(t,e=0){const n=" ".repeat(e);if(t===null)return"null";if(t===void 0)return"undefined";if(typeof t=="string"){if(t.includes("\\n")||t.includes(` `)){const i=t.replace(/\\n/g,` `).replace(/\\"/g,'"').replace(/\\t/g," ").split(` @@ -8679,6 +8681,6 @@ Accuracy: ${t.time_accuracy.toFixed(0)}%`:t.actual_time_seconds?`Actual: ${Zs(t. `+n+"]";if(typeof t=="object"){const r=Object.entries(t);return r.length===0?"{}":`{ `+r.map(([s,o])=>n+" "+JSON.stringify(s)+": "+fF(o,e+1)).join(`, `)+` -`+n+"}"}return String(t)}function MZe({setting:t,onClose:e,onDeleted:n,onDuplicate:r,onEdit:i,hasPermission:s,t:o}){const{showToast:l}=hn(),c=tn(),[u,d]=w.useState(!1),{data:h,isLoading:f}=Ze({queryKey:["cloudSettingDetail",t.setting_id],queryFn:()=>re.getCloudSettingDetail(t.setting_id)}),p=ot({mutationFn:()=>re.deleteCloudSetting(t.setting_id),onSuccess:()=>{l(o("profiles.presets.toast.deleted")),c.invalidateQueries({queryKey:["cloudSettings"]}),n()},onError:b=>l(b.message,"error")}),x=mv(t.setting_id),y=xI(t.name,h?.setting?.inherits);return a.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4",children:a.jsx(vt,{className:"w-full max-w-3xl max-h-[90vh] flex flex-col overflow-hidden",children:a.jsxs(Nt,{className:"p-0 flex flex-col min-h-0 flex-1",children:[a.jsxs("div",{className:"flex-shrink-0 flex items-center justify-between p-4 border-b border-bambu-dark-tertiary",children:[a.jsxs("div",{className:"flex-1 min-w-0",children:[a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx("h2",{className:"text-xl font-semibold text-white truncate",children:t.name}),x&&a.jsx("span",{className:"px-2 py-0.5 text-xs font-medium bg-bambu-green/20 text-bambu-green rounded-full",children:o("profiles.presets.editable")})]}),a.jsxs("div",{className:"flex items-center gap-2 mt-1 text-sm text-bambu-gray",children:[a.jsx("span",{className:"capitalize",children:o(`profiles.presets.types.${t.type}`)}),y.printer&&a.jsxs(a.Fragment,{children:[a.jsx("span",{children:"•"}),a.jsx("span",{children:y.printer})]})]})]}),a.jsx("button",{onClick:e,className:"p-2 text-bambu-gray hover:text-white hover:bg-bambu-dark-tertiary rounded-lg transition-colors",children:a.jsx(Ft,{className:"w-5 h-5"})})]}),a.jsx("div",{className:"flex-1 min-h-0 overflow-y-auto p-4",children:f?a.jsx("div",{className:"flex items-center justify-center py-16",children:a.jsx(it,{className:"w-8 h-8 text-bambu-green animate-spin"})}):h?a.jsx("pre",{className:"text-xs text-bambu-gray font-mono whitespace-pre-wrap break-all bg-bambu-dark p-4 rounded-lg border border-bambu-dark-tertiary overflow-x-auto max-w-full",children:fF(h)}):a.jsx("div",{className:"text-center py-16 text-bambu-gray",children:o("profiles.presets.failedToLoadDetails")})}),u?a.jsxs("div",{className:"flex-shrink-0 p-4 border-t border-bambu-dark-tertiary bg-red-500/5",children:[a.jsxs("div",{className:"flex items-center gap-2 mb-3 text-red-400",children:[a.jsx(Cn,{className:"w-5 h-5"}),a.jsx("span",{className:"font-medium",children:o("profiles.presets.deleteConfirm")})]}),a.jsx("p",{className:"text-sm text-bambu-gray mb-4",children:o("profiles.presets.deleteWarning",{name:t.name})}),a.jsxs("div",{className:"flex gap-2",children:[a.jsx(Ce,{variant:"secondary",onClick:()=>d(!1),disabled:p.isPending,className:"flex-1",children:o("common.cancel")}),a.jsxs(Ce,{variant:"danger",onClick:()=>p.mutate(),disabled:p.isPending,className:"flex-1",children:[p.isPending?a.jsx(it,{className:"w-4 h-4 animate-spin"}):a.jsx(Jt,{className:"w-4 h-4"}),o("common.delete")]})]})]}):a.jsx("div",{className:"flex-shrink-0 p-4 border-t border-bambu-dark-tertiary",children:a.jsxs("div",{className:"flex gap-2",children:[a.jsx(Ce,{variant:"secondary",onClick:e,className:"flex-1",children:o("common.close")}),a.jsxs(Ce,{variant:"secondary",onClick:r,disabled:!s("cloud:auth"),title:s("cloud:auth")?void 0:o("profiles.presets.noDuplicatePermission"),children:[a.jsx(Kl,{className:"w-4 h-4"}),o("profiles.presets.duplicate")]}),x&&a.jsxs(a.Fragment,{children:[a.jsxs(Ce,{variant:"secondary",onClick:i,disabled:f||!h||!s("cloud:auth"),title:s("cloud:auth")?void 0:o("profiles.presets.noEditPermission"),children:[a.jsx(Vi,{className:"w-4 h-4"}),o("common.edit")]}),a.jsx(Ce,{variant:"danger",onClick:()=>d(!0),disabled:!s("cloud:auth"),title:s("cloud:auth")?void 0:o("profiles.presets.noDeletePermission"),children:a.jsx(Jt,{className:"w-4 h-4"})})]})]})})]})})})}function Wae(){try{const t=localStorage.getItem("bambusy_preset_templates");return t?JSON.parse(t):[]}catch{return[]}}function Kae(t){localStorage.setItem("bambusy_preset_templates",JSON.stringify(t))}function AZe({onClose:t,onApply:e,t:n}){const{showToast:r}=hn(),[i,s]=w.useState(Wae),[o,l]=w.useState("all"),[c,u]=w.useState(null),[d,h]=w.useState(""),[f,p]=w.useState(""),[x,y]=w.useState("{}"),[b,v]=w.useState(null),[S,N]=w.useState(null),A=o==="all"?i:i.filter(B=>B.type===o),C=B=>{s(B),Kae(B)},T=B=>{const R=i.filter(G=>G.id!==B);C(R),N(null),r(n("profiles.templates.toast.deleted"))},k=B=>{u(B.id),h(B.name),p(B.description),y(JSON.stringify(B.settings,null,2)),v(null)},j=()=>{if(!(!c||!d.trim()))try{const B=JSON.parse(x),R=i.map(G=>G.id===c?{...G,name:d.trim(),description:f.trim(),settings:B}:G);C(R),u(null),r(n("profiles.templates.toast.updated"))}catch(B){v(B.message)}},E=()=>{u(null),h(""),p(""),y("{}"),v(null)},P=B=>{const R=i.map(G=>G.id===B?{...G,showInModal:!G.showInModal}:G);C(R)},U={filament:{label:n("profiles.presets.types.filament"),icon:Jk,color:"text-amber-400"},print:{label:n("profiles.presets.types.process"),icon:nd,color:"text-blue-400"},printer:{label:n("profiles.presets.types.printer"),icon:Cr,color:"text-purple-400"}},O=S?i.find(B=>B.id===S):null;return w.useEffect(()=>{const B=R=>{R.key==="Escape"&&(S?N(null):c?E():t())};return window.addEventListener("keydown",B),()=>window.removeEventListener("keydown",B)},[S,c,t]),a.jsxs("div",{className:"fixed inset-0 bg-black/70 flex items-center justify-center z-50 p-4",children:[O&&a.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-60",children:a.jsx(vt,{className:"w-full max-w-md",children:a.jsxs(Nt,{className:"p-6",children:[a.jsxs("div",{className:"flex items-center gap-3 mb-4",children:[a.jsx("div",{className:"p-2 bg-red-500/20 rounded-lg",children:a.jsx(Cn,{className:"w-6 h-6 text-red-400"})}),a.jsxs("div",{children:[a.jsx("h3",{className:"text-lg font-semibold text-white",children:n("profiles.templates.deleteTitle")}),a.jsx("p",{className:"text-sm text-bambu-gray",children:n("profiles.templates.deleteWarning")})]})]}),a.jsx("p",{className:"text-white mb-6",children:n("profiles.templates.deleteConfirm",{name:O.name})}),a.jsxs("div",{className:"flex gap-2",children:[a.jsx(Ce,{variant:"secondary",onClick:()=>N(null),className:"flex-1",children:n("common.cancel")}),a.jsxs(Ce,{onClick:()=>T(S),className:"flex-1 bg-red-500 hover:bg-red-600",children:[a.jsx(Jt,{className:"w-4 h-4"}),n("common.delete")]})]})]})})}),a.jsx(vt,{className:"w-full max-w-2xl max-h-[80vh] flex flex-col",children:a.jsxs(Nt,{className:"p-0 flex flex-col h-full",children:[a.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-bambu-dark-tertiary",children:[a.jsxs("h2",{className:"text-lg font-semibold text-white flex items-center gap-2",children:[a.jsx(pb,{className:"w-5 h-5 text-amber-400"}),n("profiles.templates.title")]}),a.jsx("button",{onClick:t,className:"text-bambu-gray hover:text-white",children:a.jsx(Ft,{className:"w-5 h-5"})})]}),a.jsxs("div",{className:"flex items-center gap-2 p-4 border-b border-bambu-dark-tertiary",children:[a.jsx("span",{className:"text-sm text-bambu-gray",children:n("profiles.templates.typeFilter")}),["all","filament","print","printer"].map(B=>a.jsx("button",{onClick:()=>l(B),className:`px-3 py-1 text-sm rounded-lg transition-colors ${o===B?"bg-bambu-green text-white":"bg-bambu-dark text-bambu-gray hover:text-white"}`,children:B==="all"?n("common.all"):U[B].label},B))]}),a.jsx("div",{className:"flex-1 overflow-y-auto p-4",children:A.length===0?a.jsxs("div",{className:"text-center py-12 text-bambu-gray",children:[a.jsx(pb,{className:"w-12 h-12 mx-auto mb-4 opacity-30"}),a.jsx("p",{children:n("profiles.templates.noTemplates")}),a.jsx("p",{className:"text-sm mt-1",children:n("profiles.templates.createFirst")})]}):a.jsx("div",{className:"space-y-2",children:A.map(B=>{const R=U[B.type],G=R.icon;return c===B.id?a.jsxs("div",{className:"p-4 bg-bambu-dark rounded-lg border border-bambu-green",children:[a.jsxs("div",{className:"grid grid-cols-2 gap-3 mb-3",children:[a.jsx("input",{type:"text",value:d,onChange:q=>h(q.target.value),placeholder:n("profiles.templates.namePlaceholder"),className:"px-3 py-2 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded text-white text-sm focus:border-bambu-green focus:outline-none",autoFocus:!0}),a.jsx("input",{type:"text",value:f,onChange:q=>p(q.target.value),placeholder:n("profiles.templates.descriptionPlaceholder"),className:"px-3 py-2 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded text-white text-sm focus:border-bambu-green focus:outline-none"})]}),a.jsxs("div",{className:"mb-3",children:[a.jsx("label",{className:"text-xs text-bambu-gray mb-1 block",children:n("profiles.templates.settingsJson")}),a.jsx("textarea",{value:x,onChange:q=>{y(q.target.value),v(null)},rows:6,className:`w-full px-3 py-2 bg-bambu-dark-secondary border rounded text-white text-sm font-mono focus:outline-none ${b?"border-red-500":"border-bambu-dark-tertiary focus:border-bambu-green"}`}),b&&a.jsx("p",{className:"text-xs text-red-400 mt-1",children:b})]}),a.jsxs("div",{className:"flex gap-2",children:[a.jsxs(Ce,{size:"sm",onClick:j,disabled:!d.trim(),children:[a.jsx(bs,{className:"w-4 h-4"}),"Save"]}),a.jsx(Ce,{size:"sm",variant:"secondary",onClick:E,children:"Cancel"})]})]},B.id):a.jsxs("div",{className:"flex items-center gap-3 p-3 bg-bambu-dark rounded-lg border border-bambu-dark-tertiary hover:border-bambu-gray-dark transition-colors",children:[a.jsx(G,{className:`w-5 h-5 ${R.color} flex-shrink-0`}),a.jsxs("div",{className:"flex-1 min-w-0",children:[a.jsx("p",{className:"text-sm font-medium text-white",children:B.name}),a.jsx("p",{className:"text-xs text-bambu-gray truncate",children:B.description})]}),a.jsx("span",{className:"text-xs text-bambu-gray-dark px-2 py-1 bg-bambu-dark-secondary rounded",children:n("profiles.templates.fieldsCount",{count:Object.keys(B.settings).length})}),a.jsx("button",{onClick:()=>P(B.id),className:`p-1 transition-colors ${B.showInModal?"text-bambu-green hover:text-bambu-green/70":"text-bambu-gray hover:text-white"}`,title:B.showInModal?n("profiles.templates.shownInModals"):n("profiles.templates.hiddenInModals"),children:B.showInModal?a.jsx(Xl,{className:"w-4 h-4"}):a.jsx(gv,{className:"w-4 h-4"})}),a.jsx("button",{onClick:()=>e(B),className:"px-3 py-1 text-xs bg-bambu-green/20 text-bambu-green rounded hover:bg-bambu-green/30 transition-colors",children:n("profiles.templates.apply")}),a.jsx("button",{onClick:()=>k(B),className:"p-1 text-bambu-gray hover:text-white",title:n("common.edit"),children:a.jsx(Vi,{className:"w-4 h-4"})}),a.jsx("button",{onClick:()=>N(B.id),className:"p-1 text-bambu-gray hover:text-red-400",title:n("common.delete"),children:a.jsx(Jt,{className:"w-4 h-4"})})]},B.id)})})})]})})]})}function Xae({onClose:t,leftPreset:e,rightPreset:n,leftLabel:r,rightLabel:i,t:s}){const[o,l]=w.useState("changes"),[c,u]=w.useState(""),d=w.useMemo(()=>{const x=new Set([...Object.keys(e),...Object.keys(n)]),y=[];for(const b of x){if(b==="inherits"||b==="version")continue;const v=e[b],S=n[b],N=b in e,A=b in n;let C;!N&&A?C="added":N&&!A?C="removed":JSON.stringify(v)!==JSON.stringify(S)?C="changed":C="same",y.push({key:b,left:v,right:S,status:C})}return y.sort((b,v)=>{const S={changed:0,added:1,removed:2,same:3};return S[b.status]!==S[v.status]?S[b.status]-S[v.status]:b.key.localeCompare(v.key)})},[e,n]),h=w.useMemo(()=>{let x=[...d];if(o==="changes"&&(x=x.filter(y=>y.status!=="same")),c){const y=c.toLowerCase();x=x.filter(b=>b.key.toLowerCase().includes(y)||String(b.left).toLowerCase().includes(y)||String(b.right).toLowerCase().includes(y))}return x},[d,o,c]),f=w.useMemo(()=>({added:d.filter(x=>x.status==="added").length,removed:d.filter(x=>x.status==="removed").length,changed:d.filter(x=>x.status==="changed").length,same:d.filter(x=>x.status==="same").length}),[d]),p=x=>{if(x===void 0)return"—";if(x===null)return"null";if(Array.isArray(x))return x.length===0?"[]":x.length===1?String(x[0]):x.join(", ");if(typeof x=="object")return JSON.stringify(x);const y=String(x);if(y.includes("\\n")||y.length>100){const b=y.split("\\n").length;if(b>1)return`[${b} lines of G-code/script]`;if(y.length>100)return y.substring(0,100)+"…"}return y};return w.useEffect(()=>{const x=y=>{y.key==="Escape"&&t()};return window.addEventListener("keydown",x),()=>window.removeEventListener("keydown",x)},[t]),a.jsx("div",{className:"fixed inset-0 bg-black/70 flex items-center justify-center z-50 p-4",children:a.jsx(vt,{className:"w-full max-w-4xl max-h-[85vh] flex flex-col overflow-hidden",children:a.jsxs(Nt,{className:"p-0 flex flex-col min-h-0 flex-1",children:[a.jsxs("div",{className:"flex-shrink-0 flex items-center justify-between p-4 border-b border-bambu-dark-tertiary",children:[a.jsxs("h2",{className:"text-lg font-semibold text-white flex items-center gap-2",children:[a.jsx(Yg,{className:"w-5 h-5 text-blue-400"}),s("profiles.diff.title")]}),a.jsx("button",{onClick:t,className:"text-bambu-gray hover:text-white",children:a.jsx(Ft,{className:"w-5 h-5"})})]}),a.jsxs("div",{className:"flex-shrink-0 grid grid-cols-2 gap-4 p-4 border-b border-bambu-dark-tertiary bg-bambu-dark",children:[a.jsxs("div",{className:"text-center",children:[a.jsx("span",{className:"text-sm text-bambu-gray",children:s("profiles.diff.left")}),a.jsx("p",{className:"text-white font-medium truncate",children:r})]}),a.jsxs("div",{className:"text-center",children:[a.jsx("span",{className:"text-sm text-bambu-gray",children:s("profiles.diff.right")}),a.jsx("p",{className:"text-white font-medium truncate",children:i})]})]}),a.jsxs("div",{className:"flex-shrink-0 flex items-center justify-between p-4 border-b border-bambu-dark-tertiary",children:[a.jsxs("div",{className:"flex items-center gap-4 text-sm",children:[a.jsxs("span",{className:"flex items-center gap-1 text-green-400",children:[a.jsx(ar,{className:"w-3.5 h-3.5"}),f.added," ",s("profiles.diff.added")]}),a.jsxs("span",{className:"flex items-center gap-1 text-red-400",children:[a.jsx(y3,{className:"w-3.5 h-3.5"}),f.removed," ",s("profiles.diff.removed")]}),a.jsxs("span",{className:"flex items-center gap-1 text-amber-400",children:[a.jsx(h3,{className:"w-3.5 h-3.5"}),f.changed," ",s("profiles.diff.changed")]}),a.jsxs("span",{className:"flex items-center gap-1 text-bambu-gray",children:[a.jsx(JT,{className:"w-3.5 h-3.5"}),f.same," ",s("profiles.diff.same")]})]}),a.jsxs("div",{className:"flex items-center gap-3",children:[a.jsxs("div",{className:"relative",children:[a.jsx(Or,{className:"absolute left-2 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray"}),a.jsx("input",{type:"text",value:c,onChange:x=>u(x.target.value),placeholder:s("profiles.diff.searchFields"),className:"pl-8 pr-3 py-1.5 bg-bambu-dark border border-bambu-dark-tertiary rounded text-white text-sm focus:border-bambu-green focus:outline-none w-48"})]}),f.same>0&&a.jsxs("div",{className:"flex rounded overflow-hidden border border-bambu-dark-tertiary",children:[a.jsx("button",{onClick:()=>l("changes"),className:`px-3 py-1.5 text-sm transition-colors ${o==="changes"?"bg-bambu-green text-white":"bg-bambu-dark text-bambu-gray hover:text-white"}`,children:s("profiles.diff.changes")}),a.jsx("button",{onClick:()=>l("all"),className:`px-3 py-1.5 text-sm transition-colors ${o==="all"?"bg-bambu-green text-white":"bg-bambu-dark text-bambu-gray hover:text-white"}`,children:s("common.all")})]})]})]}),a.jsx("div",{className:"flex-1 min-h-0 overflow-y-auto",children:h.length===0?a.jsxs("div",{className:"text-center py-12 text-bambu-gray",children:[a.jsx(JT,{className:"w-12 h-12 mx-auto mb-4 opacity-30"}),a.jsx("p",{children:s(o==="changes"?"profiles.diff.noDifferences":"profiles.diff.noFieldsMatch")})]}):a.jsxs("table",{className:"w-full",children:[a.jsx("thead",{className:"sticky top-0 bg-bambu-dark-secondary",children:a.jsxs("tr",{className:"text-sm text-bambu-gray border-b border-bambu-dark-tertiary",children:[a.jsx("th",{className:"text-left p-3 w-1/3",children:s("profiles.diff.field")}),a.jsx("th",{className:"text-left p-3 w-1/3",children:r}),a.jsx("th",{className:"text-left p-3 w-1/3",children:i})]})}),a.jsx("tbody",{children:h.map(x=>{const y={added:"bg-green-500/10",removed:"bg-red-500/10",changed:"bg-amber-500/10",same:""}[x.status],b={added:a.jsx(ar,{className:"w-3.5 h-3.5 text-green-400"}),removed:a.jsx(y3,{className:"w-3.5 h-3.5 text-red-400"}),changed:a.jsx(h3,{className:"w-3.5 h-3.5 text-amber-400"}),same:a.jsx(JT,{className:"w-3.5 h-3.5 text-bambu-gray-dark"})}[x.status];return a.jsxs("tr",{className:`border-b border-bambu-dark-tertiary ${y}`,children:[a.jsx("td",{className:"p-3",children:a.jsxs("div",{className:"flex items-center gap-2",children:[b,a.jsx("span",{className:"text-sm text-white font-mono",children:x.key})]})}),a.jsx("td",{className:"p-3",children:a.jsx("span",{className:`text-sm font-mono break-all ${x.status==="removed"?"text-red-300":x.status==="changed"?"text-white":"text-bambu-gray"}`,children:p(x.left)})}),a.jsx("td",{className:"p-3",children:a.jsx("span",{className:`text-sm font-mono break-all ${x.status==="added"?"text-green-300":x.status==="changed"?"text-white":"text-bambu-gray"}`,children:p(x.right)})})]},x.key)})})]})})]})})})}function TZe({onClose:t,initialData:e,allPresets:n,t:r}){const{showToast:i}=hn(),s=tn(),o=!!e?.setting_id,[l,c]=w.useState("common"),[u,d]=w.useState(e?.type||"filament"),[h,f]=w.useState(e?.name?o?e.name:`${e.name} (Copy)`:""),[p,x]=w.useState(e?.base_id||""),[y,b]=w.useState(""),[v,S]=w.useState(e?.setting||{inherits:""}),[N,A]=w.useState(JSON.stringify(e?.setting||{inherits:""},null,2)),[C,T]=w.useState(null),[k,j]=w.useState(""),[E,P]=w.useState(!1),[U,O]=w.useState(""),[B,R]=w.useState(!1),[G,q]=w.useState(Wae),[z,K]=w.useState(!1),[Y,oe]=w.useState(""),[$,X]=w.useState(""),[ee,J]=w.useState(!0),[_e,pe]=w.useState(null),[me,je]=w.useState(!1),de=w.useMemo(()=>({filament:n.filament,print:n.process,printer:n.printer})[u]||[],[n,u]),ce=w.useMemo(()=>de.filter(le=>mv(le.setting_id)),[de]),{data:Se}=Ze({queryKey:["cloudFields",u],queryFn:()=>re.getCloudFields(u==="print"?"process":u),staleTime:1e3*60*60}),{data:ie}=Ze({queryKey:["allPresetDetails",u,ce.map(le=>le.setting_id).join(",")],queryFn:async()=>{const le={};for(let Me=0;Me{try{const Pe=await re.getCloudSettingDetail(Je.setting_id);return{id:Je.setting_id,detail:Pe}}catch{return null}}))).forEach(Je=>{Je&&(le[Je.id]=Je.detail)})}return le},enabled:ce.length>0,staleTime:1e3*60*10}),{data:Fe,isLoading:V}=Ze({queryKey:["cloudSettingDetail",p],queryFn:()=>re.getCloudSettingDetail(p),enabled:!!p});w.useEffect(()=>{l!=="json"&&A(JSON.stringify(v,null,2))},[v,l]);const W=w.useMemo(()=>({filament:n.filament,print:n.process,printer:n.printer}[u]||[]).filter(Le=>!mv(Le.setting_id)).sort((Le,Me)=>Le.name.localeCompare(Me.name)),[n,u]);w.useEffect(()=>{if(!p)return;const le=W.find(Le=>Le.setting_id===p);le&&(b(le.name),o||(S({inherits:le.name}),A(JSON.stringify({inherits:le.name},null,2))))},[p,W,o]);const ue=w.useMemo(()=>{const le=Se?.fields||[],Le=new Set(le.map(Je=>Je.key)),Me=new Set,$e=new Set(["inherits","updated_time","compatible_printers","compatible_prints"]);ie&&Object.values(ie).forEach(Je=>{Je?.setting&&Object.keys(Je.setting).forEach(Pe=>{!Le.has(Pe)&&!$e.has(Pe)&&Me.add(Pe)})}),Object.keys(v).forEach(Je=>{!Le.has(Je)&&!$e.has(Je)&&Me.add(Je)});const Ae=Array.from(Me).sort().map(Je=>({key:Je,label:Je.replace(/_/g," ").replace(/\b\w/g,Pe=>Pe.toUpperCase()),type:"text",category:"discovered",description:r("profiles.presets.discoveredFromPresets")}));return[...le,...Ae]},[Se,ie,v,r]),Q=ue.filter(le=>le.label.toLowerCase().includes(k.toLowerCase())||le.key.toLowerCase().includes(k.toLowerCase())),se=()=>{if(U.trim()){const le=U.trim().toLowerCase().replace(/\s+/g,"_");Z(le,""),O(""),R(!1),i(r("profiles.presets.toast.fieldAdded",{key:le}))}},Z=(le,Le)=>{S(Me=>{const $e={...Me};return Le===""||Le===void 0?delete $e[le]:$e[le]=Le,$e})},Ne=le=>{S(Le=>({...Le,...le.settings})),pe(le.name),i(r("profiles.templates.toast.applied"))},ve=()=>{if(!Y.trim())return;const le={...v};if(delete le.inherits,Object.keys(le).length===0){i(r("profiles.presets.noOverridesToSave"),"error");return}const Le={id:Date.now().toString(),name:Y.trim(),description:$.trim()||r("profiles.presets.customTemplate"),type:u,settings:le,showInModal:ee},Me=[...G,Le];q(Me),Kae(Me),K(!1),oe(""),X(""),J(!0),i(r("profiles.templates.toast.created"))},fe=w.useMemo(()=>G.filter(le=>le.type===u&&le.showInModal),[u,G]),L=le=>{A(le);try{const Le=JSON.parse(le);S(Le),T(null)}catch(Le){T(Le.message)}},D=le=>{le.preventDefault(),P(!1);const Le=le.dataTransfer.files[0];if(Le&&Le.name.endsWith(".json")){const Me=new FileReader;Me.onload=$e=>{try{const Ae=$e.target?.result,Je=JSON.parse(Ae),Pe=Je.setting||Je;S(Xe=>({...Xe,...Pe})),A(JSON.stringify({...v,...Pe},null,2)),i(r("profiles.presets.fileImported"))}catch{i(r("profiles.presets.invalidJsonFile"),"error")}},Me.readAsText(Le)}},H=ot({mutationFn:()=>{const le={...v},Le=u==="filament"?"filament_settings_id":u==="print"?"print_settings_id":"printer_settings_id";le[Le]=`"${h}"`;const Me={type:u,name:h,base_id:p,setting:le};return re.createCloudSetting(Me)},onSuccess:async()=>{i(r("profiles.presets.toast.created")),await s.refetchQueries({queryKey:["cloudSettings"]}),t()},onError:le=>i(le.message,"error")}),he=ot({mutationFn:()=>{if(!e?.setting_id)throw new Error(r("profiles.presets.noSettingId"));return re.updateCloudSetting(e.setting_id,{name:h,setting:v})},onSuccess:async()=>{i(r("profiles.presets.toast.updated")),s.removeQueries({queryKey:["cloudSettingDetail"]}),await s.refetchQueries({queryKey:["cloudSettings"]}),t()},onError:le=>i(le.message,"error")}),xe=o?he:H,be=Fe?.setting?.inherits,Ue=be?W.find(le=>le.name===be):void 0,{data:Oe}=Ze({queryKey:["cloudSettingDetail",Ue?.setting_id],queryFn:()=>re.getCloudSettingDetail(Ue.setting_id),enabled:!!Ue?.setting_id}),Qe=w.useMemo(()=>{const le=Oe?.setting||{},Le=Fe?.setting||{},Me=p&&ie?.[p]?.setting?ie[p].setting:{};return{...le,...Le,...Me}},[p,Fe,Oe,ie]),rt=le=>{if(le==null)return"";if(Array.isArray(le)){const Le=[...new Set(le.map(Me=>String(Me)))];return Le.length===1?Le[0]:le.join(", ")}return String(le)},we=le=>{const Le=v[le.key],Me=Qe[le.key],$e=rt(Me),Ae=V?r("common.loading"):$e||"",Je="w-full px-3 py-1.5 bg-bambu-dark border border-bambu-dark-tertiary rounded text-white text-sm focus:border-bambu-green focus:outline-none";if(le.type==="boolean"){const Pe=Le==="1"||Le===void 0&&Me==="1";return a.jsx("button",{type:"button",onClick:()=>Z(le.key,Le==="1"?"0":"1"),className:`w-8 h-5 rounded-full transition-colors ${Pe?"bg-bambu-green":"bg-bambu-dark-tertiary"}`,children:a.jsx("div",{className:`w-4 h-4 rounded-full bg-white shadow transition-transform ${Pe?"translate-x-3.5":"translate-x-0.5"}`})})}return le.type==="select"?a.jsxs("select",{value:Le||"",onChange:Pe=>Z(le.key,Pe.target.value),className:Je,children:[a.jsx("option",{value:"",children:Ae}),le.options?.map(Pe=>a.jsx("option",{value:Pe.value,children:Pe.label},Pe.value))]}):a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx("input",{type:le.type==="number"?"number":"text",value:Le!==void 0?String(Le):"",onChange:Pe=>Z(le.key,Pe.target.value),step:le.step,min:le.min,max:le.max,placeholder:Ae,className:Je}),le.unit&&a.jsx("span",{className:"text-xs text-bambu-gray whitespace-nowrap",children:le.unit})]})},ye=w.useMemo(()=>Fe?.setting?Fe.setting:{},[Fe]);return a.jsxs("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4",onDragOver:le=>{le.preventDefault(),P(!0)},onDragLeave:()=>P(!1),onDrop:D,children:[me&&p&&a.jsx(Xae,{onClose:()=>je(!1),leftPreset:ye,rightPreset:v,leftLabel:r("profiles.presets.baseLabel",{name:y||p}),rightLabel:r("profiles.presets.currentLabel",{name:h||r("profiles.presets.newPreset")}),t:r}),a.jsx(vt,{className:"w-full max-w-6xl max-h-[90vh] flex flex-col overflow-y-auto",children:a.jsxs(Nt,{className:"p-0 flex flex-col h-full",children:[a.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-bambu-dark-tertiary",children:[a.jsxs("div",{children:[a.jsx("h2",{className:"text-xl font-semibold text-white",children:r(o?"profiles.presets.editPreset":e?"profiles.presets.duplicatePreset":"profiles.presets.createNewPreset")}),a.jsx("p",{className:"text-sm text-bambu-gray mt-1",children:r("profiles.presets.customizeSettings")})]}),a.jsxs("div",{className:"flex items-center gap-2",children:[p&&a.jsxs("button",{onClick:()=>je(!0),className:"flex items-center gap-2 px-3 py-2 text-sm text-bambu-gray hover:text-white hover:bg-bambu-dark-tertiary rounded-lg transition-colors",title:r("profiles.presets.compareWithBase"),children:[a.jsx(Yg,{className:"w-4 h-4"}),r("profiles.presets.compare")]}),a.jsx("button",{onClick:t,className:"p-2 text-bambu-gray hover:text-white hover:bg-bambu-dark-tertiary rounded-lg transition-colors",children:a.jsx(Ft,{className:"w-5 h-5"})})]})]}),E&&a.jsx("div",{className:"absolute inset-0 bg-bambu-green/10 border-2 border-dashed border-bambu-green rounded-lg flex items-center justify-center z-10",children:a.jsxs("div",{className:"text-center",children:[a.jsx(Fi,{className:"w-12 h-12 text-bambu-green mx-auto mb-2"}),a.jsx("p",{className:"text-bambu-green font-medium",children:r("profiles.presets.dropJsonToImport")})]})}),a.jsxs("div",{className:"p-4 border-b border-bambu-dark-tertiary space-y-3",children:[a.jsxs("div",{className:"grid grid-cols-3 gap-4 max-[640px]:grid-cols-1",children:[a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:r("common.type")}),a.jsxs("select",{value:u,onChange:le=>{d(le.target.value),x("")},className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",children:[a.jsx("option",{value:"filament",children:r("profiles.presets.types.filament")}),a.jsx("option",{value:"print",children:r("profiles.presets.types.process")}),a.jsx("option",{value:"printer",children:r("profiles.presets.types.printer")})]})]}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:r("profiles.presets.basePreset")}),a.jsxs("select",{value:p,onChange:le=>x(le.target.value),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white text-sm focus:border-bambu-green focus:outline-none",children:[a.jsx("option",{value:"",children:r("profiles.presets.selectBasePreset")}),W.map(le=>a.jsx("option",{value:le.setting_id,children:le.name},le.setting_id))]})]}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:r("profiles.presets.presetName")}),a.jsx("input",{type:"text",value:h,onChange:le=>f(le.target.value),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",placeholder:r("profiles.presets.myCustomPreset")})]})]}),y&&a.jsx("div",{className:"text-xs text-bambu-gray",children:a.jsxs("p",{className:"flex items-center gap-1",children:[a.jsx(Xr,{className:"w-3 h-3 text-bambu-green"}),r("profiles.presets.inheritsFrom")," ",a.jsx("span",{className:"text-white",children:y}),V&&a.jsx(it,{className:"w-3 h-3 animate-spin ml-1"})]})})]}),a.jsxs("div",{className:"flex border-b border-bambu-dark-tertiary max-[640px]:flex-wrap max-[640px]:items-center",children:[a.jsxs("button",{onClick:()=>c("common"),className:`flex items-center gap-2 px-4 py-3 text-sm font-medium transition-colors border-b-2 -mb-px ${l==="common"?"text-bambu-green border-bambu-green":"text-bambu-gray hover:text-white border-transparent"}`,children:[a.jsx($B,{className:"w-4 h-4"}),r("profiles.presets.tabs.common")]}),a.jsxs("button",{onClick:()=>c("fields"),className:`flex items-center gap-2 px-4 py-3 text-sm font-medium transition-colors border-b-2 -mb-px ${l==="fields"?"text-bambu-green border-bambu-green":"text-bambu-gray hover:text-white border-transparent"}`,children:[a.jsx(rC,{className:"w-4 h-4"}),r("profiles.presets.tabs.allFields")]}),a.jsxs("button",{onClick:()=>c("json"),className:`flex items-center gap-2 px-4 py-3 text-sm font-medium transition-colors border-b-2 -mb-px ${l==="json"?"text-bambu-green border-bambu-green":"text-bambu-gray hover:text-white border-transparent"}`,children:[a.jsx(dX,{className:"w-4 h-4"}),"JSON",C&&a.jsx(Hi,{className:"w-3 h-3 text-red-400"})]}),a.jsx("div",{className:"flex-1 max-[640px]:hidden"}),a.jsxs("button",{onClick:()=>{const le={name:h,type:u,base_id:p,setting:v},Le=new Blob([JSON.stringify(le,null,2)],{type:"application/json"}),Me=URL.createObjectURL(Le),$e=document.createElement("a");$e.href=Me,$e.download=`${h||"preset"}.json`,document.body.appendChild($e),$e.click(),document.body.removeChild($e),URL.revokeObjectURL(Me),i(r("profiles.presets.toast.exported"))},className:"flex items-center gap-2 px-4 py-3 text-sm text-bambu-gray hover:text-white transition-colors",title:r("profiles.presets.exportToJson"),children:[a.jsx(di,{className:"w-4 h-4"}),r("common.download")]}),a.jsxs("button",{onClick:()=>document.getElementById("file-import")?.click(),className:"flex items-center gap-2 px-4 py-3 text-sm text-bambu-gray hover:text-white transition-colors",title:r("profiles.presets.importFromJson"),children:[a.jsx(Fi,{className:"w-4 h-4"}),r("common.upload")]}),a.jsx("input",{id:"file-import",type:"file",accept:".json",className:"hidden",onChange:le=>{const Le=le.target.files?.[0];if(Le){const Me=new FileReader;Me.onload=$e=>{try{const Ae=JSON.parse($e.target?.result),Je=Ae.setting||Ae;S(Pe=>({...Pe,...Je})),i(r("profiles.presets.fileImported"))}catch{i(r("profiles.presets.invalidJson"),"error")}},Me.readAsText(Le)}}})]}),a.jsxs("div",{className:"flex-1 p-4",children:[l==="common"&&a.jsxs("div",{className:"space-y-6",children:[a.jsxs("div",{children:[a.jsxs("div",{className:"flex items-center justify-between mb-3",children:[a.jsxs("h3",{className:"text-sm font-medium text-white flex items-center gap-2",children:[a.jsx(pb,{className:"w-4 h-4 text-amber-400"}),r("profiles.templates.title")]}),Object.keys(v).filter(le=>le!=="inherits").length>0&&a.jsxs("button",{onClick:()=>K(!z),className:"text-xs text-bambu-gray hover:text-white flex items-center gap-1 transition-colors",children:[a.jsx(bs,{className:"w-3 h-3"}),r("profiles.presets.saveAsTemplate")]})]}),z&&a.jsxs("div",{className:"mb-3 p-3 bg-bambu-dark rounded-lg border border-bambu-dark-tertiary",children:[a.jsxs("div",{className:"grid grid-cols-2 gap-2 mb-2",children:[a.jsx("input",{type:"text",value:Y,onChange:le=>oe(le.target.value),placeholder:r("profiles.templates.namePlaceholder"),className:"px-3 py-1.5 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded text-white text-sm focus:border-bambu-green focus:outline-none",autoFocus:!0}),a.jsx("input",{type:"text",value:$,onChange:le=>X(le.target.value),placeholder:r("profiles.templates.descriptionPlaceholder"),className:"px-3 py-1.5 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded text-white text-sm focus:border-bambu-green focus:outline-none"})]}),a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsxs("div",{className:"flex gap-2",children:[a.jsxs(Ce,{size:"sm",onClick:ve,disabled:!Y.trim(),children:[a.jsx(bs,{className:"w-3 h-3"}),r("common.save")]}),a.jsx(Ce,{size:"sm",variant:"secondary",onClick:()=>K(!1),children:r("common.cancel")})]}),a.jsxs("button",{onClick:()=>J(!ee),className:`flex items-center gap-1.5 text-xs transition-colors ${ee?"text-bambu-green":"text-bambu-gray hover:text-white"}`,children:[ee?a.jsx(Xl,{className:"w-3.5 h-3.5"}):a.jsx(gv,{className:"w-3.5 h-3.5"}),r(ee?"profiles.templates.shownInModals":"profiles.templates.hiddenInModals")]})]})]}),_e&&a.jsxs("div",{className:"mb-3 px-3 py-2 bg-bambu-green/10 border border-bambu-green/30 rounded-lg flex items-center gap-2",children:[a.jsx(Xr,{className:"w-4 h-4 text-bambu-green"}),a.jsxs("span",{className:"text-sm text-bambu-green",children:[r("profiles.presets.templateApplied")," ",a.jsx("span",{className:"font-medium",children:_e})]}),a.jsx("button",{onClick:()=>pe(null),className:"ml-auto text-bambu-green/70 hover:text-bambu-green",children:a.jsx(Ft,{className:"w-4 h-4"})})]}),a.jsxs("div",{className:"grid grid-cols-3 gap-2",children:[fe.map(le=>a.jsxs("button",{onClick:()=>Ne(le),className:"p-3 text-left bg-bambu-dark border border-bambu-dark-tertiary rounded-lg hover:border-bambu-gray-dark transition-colors",children:[a.jsx("p",{className:"text-sm font-medium text-white",children:le.name}),a.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:le.description})]},le.id)),fe.length===0&&a.jsx("p",{className:"col-span-3 text-center text-bambu-gray text-sm py-4",children:r("profiles.presets.noTemplatesSelected")})]}),a.jsx("p",{className:"text-xs text-bambu-gray-dark mt-2 text-center",children:r("profiles.presets.manageTemplatesHint")})]}),a.jsxs("div",{children:[a.jsx("h3",{className:"text-sm font-medium text-white mb-3",children:r("profiles.presets.commonSettings")}),a.jsx("div",{className:"grid grid-cols-2 gap-x-6 gap-y-3",children:ue.slice(0,10).map(le=>a.jsxs("div",{className:"flex items-center justify-between gap-4 max-[640px]:flex-col max-[640px]:items-start",children:[a.jsx("label",{className:"text-sm text-bambu-gray flex-shrink-0",children:le.label}),a.jsx("div",{className:"w-48 max-[640px]:w-full",children:we(le)})]},le.key))})]}),Object.keys(v).length>1&&a.jsxs("div",{children:[a.jsx("h3",{className:"text-sm font-medium text-white mb-3",children:r("profiles.presets.currentOverrides")}),a.jsx("div",{className:"flex flex-wrap gap-2",children:Object.entries(v).filter(([le])=>le!=="inherits").map(([le,Le])=>a.jsxs("span",{className:"inline-flex items-center gap-1 px-2 py-1 bg-bambu-green/10 text-bambu-green text-xs rounded",children:[le,": ",String(Le).slice(0,20),a.jsx("button",{onClick:()=>Z(le,void 0),className:"hover:text-white",children:a.jsx(Ft,{className:"w-3 h-3"})})]},le))})]})]}),l==="fields"&&a.jsxs("div",{className:"grid grid-cols-2 gap-6",style:{height:"400px"},children:[a.jsxs("div",{className:"flex flex-col h-full overflow-hidden",children:[a.jsxs("div",{className:"flex items-center justify-between mb-3 flex-shrink-0",children:[a.jsx("h3",{className:"text-sm font-medium text-white",children:r("profiles.presets.availableFields")}),a.jsx("span",{className:"text-xs text-bambu-gray",children:ie?r("profiles.templates.fieldsCount",{count:ue.length}):r("common.loading")})]}),a.jsxs("div",{className:"relative mb-3 flex-shrink-0",children:[a.jsx(Or,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray"}),a.jsx("input",{type:"text",value:k,onChange:le=>j(le.target.value),placeholder:r("profiles.presets.searchFieldsPlaceholder"),className:"w-full pl-10 pr-4 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white text-sm placeholder-bambu-gray-dark focus:border-bambu-green focus:outline-none"})]}),a.jsxs("div",{className:"flex-1 overflow-y-auto space-y-1 pr-2 min-h-0",children:[Q.filter(le=>!(le.key in v)).map(le=>{const Le=Qe[le.key],Me=rt(Le);return a.jsxs("div",{onClick:()=>{S($e=>({...$e,[le.key]:Me||""}))},className:"flex items-center justify-between gap-2 p-2 rounded-lg hover:bg-bambu-dark-tertiary transition-colors cursor-pointer group",children:[a.jsxs("div",{className:"min-w-0 flex-1",children:[a.jsx("p",{className:"text-sm text-white truncate",children:le.label}),a.jsx("p",{className:"text-xs text-bambu-gray-dark truncate",children:le.key})]}),a.jsxs("div",{className:"flex items-center gap-2 flex-shrink-0",children:[Me&&a.jsxs("span",{className:"text-xs text-bambu-gray bg-bambu-dark px-2 py-0.5 rounded max-w-32 truncate",title:Me,children:[Me.slice(0,20),Me.length>20?"...":""]}),a.jsx("div",{className:"w-6 h-6 flex items-center justify-center rounded bg-bambu-dark-tertiary group-hover:bg-bambu-green/20 transition-colors",children:a.jsx(ar,{className:"w-4 h-4 text-bambu-gray group-hover:text-bambu-green transition-colors"})})]})]},le.key)}),Q.filter(le=>!(le.key in v)).length===0&&a.jsx("p",{className:"text-center text-bambu-gray py-4 text-sm",children:r(k?"profiles.presets.noMatchingFields":"profiles.presets.allFieldsAdded")})]}),a.jsx("div",{className:"pt-3 mt-3 border-t border-bambu-dark-tertiary flex-shrink-0",children:B?a.jsxs("div",{className:"flex gap-2",children:[a.jsx("input",{type:"text",value:U,onChange:le=>O(le.target.value),onKeyDown:le=>le.key==="Enter"&&se(),placeholder:"custom_field_name",className:"flex-1 px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white font-mono text-sm placeholder-bambu-gray-dark focus:border-bambu-green focus:outline-none",autoFocus:!0}),a.jsx(Ce,{size:"sm",onClick:se,disabled:!U.trim(),children:a.jsx(ar,{className:"w-4 h-4"})}),a.jsx(Ce,{size:"sm",variant:"secondary",onClick:()=>{R(!1),O("")},children:a.jsx(Ft,{className:"w-4 h-4"})})]}):a.jsxs("button",{onClick:()=>R(!0),className:"w-full flex items-center justify-center gap-2 p-2 text-sm text-bambu-gray hover:text-white border border-dashed border-bambu-dark-tertiary hover:border-bambu-gray-dark rounded-lg transition-colors",children:[a.jsx(ar,{className:"w-4 h-4"}),r("profiles.presets.addCustomField")]})})]}),a.jsxs("div",{className:"flex flex-col h-full overflow-hidden",children:[a.jsxs("div",{className:"flex items-center justify-between mb-3 flex-shrink-0",children:[a.jsx("h3",{className:"text-sm font-medium text-white",children:r("profiles.presets.yourOverrides")}),a.jsx("span",{className:"text-xs text-bambu-gray",children:r("profiles.templates.fieldsCount",{count:Object.keys(v).filter(le=>le!=="inherits").length})})]}),a.jsxs("div",{className:"flex-1 overflow-y-auto space-y-2 pr-2 min-h-0",children:[Object.entries(v).filter(([le])=>le!=="inherits").map(([le,Le])=>{const Me=ue.find($e=>$e.key===le);return a.jsxs("div",{className:"p-3 bg-bambu-dark rounded-lg border border-bambu-dark-tertiary",children:[a.jsxs("div",{className:"flex items-center justify-between mb-2",children:[a.jsxs("div",{children:[a.jsx("p",{className:"text-sm font-medium text-white",children:Me?.label||le}),a.jsx("p",{className:"text-xs text-bambu-gray-dark",children:le})]}),a.jsx("button",{onClick:()=>Z(le,void 0),className:"p-1 text-bambu-gray hover:text-red-400 transition-colors",children:a.jsx(Ft,{className:"w-4 h-4"})})]}),Me?we(Me):a.jsx("input",{type:"text",value:String(Le),onChange:$e=>Z(le,$e.target.value),className:"w-full px-3 py-1.5 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded text-white text-sm focus:border-bambu-green focus:outline-none"})]},le)}),Object.keys(v).filter(le=>le!=="inherits").length===0&&a.jsxs("div",{className:"text-center py-8 text-bambu-gray",children:[a.jsx($B,{className:"w-8 h-8 mx-auto mb-2 opacity-50"}),a.jsx("p",{className:"text-sm",children:r("profiles.presets.noOverridesYet")}),a.jsx("p",{className:"text-xs mt-1",children:r("profiles.presets.clickFieldsToAdd")})]})]}),Object.keys(v).filter(le=>le!=="inherits").length>0&&a.jsx("div",{className:"pt-3 mt-3 border-t border-bambu-dark-tertiary flex-shrink-0",children:a.jsxs("button",{onClick:()=>{K(!0),c("common")},className:"w-full flex items-center justify-center gap-2 p-2 text-sm text-bambu-gray hover:text-white border border-dashed border-bambu-dark-tertiary hover:border-bambu-gray-dark rounded-lg transition-colors",children:[a.jsx(bs,{className:"w-4 h-4"}),r("profiles.presets.saveAsTemplate")]})})]})]}),l==="json"&&a.jsxs("div",{className:"space-y-2",children:[C&&a.jsxs("div",{className:"flex items-center gap-2 text-red-400 text-sm",children:[a.jsx(Hi,{className:"w-4 h-4"}),C]}),a.jsx("textarea",{value:N,onChange:le=>L(le.target.value),className:`w-full h-80 px-3 py-2 bg-bambu-dark border rounded-lg text-white text-xs font-mono focus:outline-none resize-none ${C?"border-red-500 focus:border-red-500":"border-bambu-dark-tertiary focus:border-bambu-green"}`,spellCheck:!1}),a.jsx("p",{className:"text-xs text-bambu-gray",children:r("profiles.presets.jsonTip")})]})]}),a.jsxs("div",{className:"p-4 border-t border-bambu-dark-tertiary flex gap-2",children:[a.jsx(Ce,{variant:"secondary",onClick:t,className:"flex-1",children:r("common.cancel")}),a.jsxs(Ce,{onClick:()=>xe.mutate(),disabled:xe.isPending||!h.trim()||!o&&!p||!!C,className:"flex-1",children:[xe.isPending?a.jsx(it,{className:"w-4 h-4 animate-spin"}):o?a.jsx(bs,{className:"w-4 h-4"}):a.jsx(ar,{className:"w-4 h-4"}),r(o?"common.save":e?"common.duplicate":"common.create")]})]})]})})]})}function EZe({settings:t,lastSyncTime:e,onRefresh:n,isRefreshing:r,printers:i,hasPermission:s,t:o}){const[l,c]=w.useState(""),[u,d]=w.useState("all"),[h,f]=w.useState("all"),[p,x]=w.useState("all"),[y,b]=w.useState("all"),[v,S]=w.useState("all"),[N,A]=w.useState("all"),[C,T]=w.useState(null),[k,j]=w.useState(!1),[E,P]=w.useState(!1),[U,O]=w.useState(null),[B,R]=w.useState(null),[G,q]=w.useState(null),[z,K]=w.useState(!1),[Y,oe]=w.useState([null,null]),[$,X]=w.useState(!1),[ee,J]=w.useState(null),_e=tn(),pe=w.useMemo(()=>[...t.filament.map(se=>({...se,type:"filament"})),...t.printer.map(se=>({...se,type:"printer"})),...t.process.map(se=>({...se,type:"process"}))].map(se=>({...se,meta:xI(se.name)})),[t]),me=w.useMemo(()=>{const Q=new Set,se=new Set,Z=new Set;return pe.forEach(Ne=>{Ne.meta.nozzle&&Q.add(Ne.meta.nozzle),Ne.meta.filamentType&&se.add(Ne.meta.filamentType),Ne.meta.layerHeight&&Z.add(Ne.meta.layerHeight)}),{printers:i.map(Ne=>({id:Ne.id.toString(),name:Ne.name})),nozzles:Array.from(Q).sort((Ne,ve)=>parseFloat(Ne)-parseFloat(ve)),filaments:Array.from(se).sort(),layerHeights:Array.from(Z).sort((Ne,ve)=>parseFloat(Ne)-parseFloat(ve))}},[pe,i]),je=w.useMemo(()=>p==="all"?null:i.find(se=>se.id.toString()===p)?.model||null,[p,i]),de=w.useMemo(()=>pe.filter(Q=>u==="all"||Q.type===u).filter(Q=>{if(h==="all")return!0;const se=mv(Q.setting_id);return h==="custom"?se:!se}).filter(Q=>{if(p==="all"||!je)return!0;const se=Q.meta.printer?.toLowerCase()||"",Z=je.toLowerCase();return se.includes(Z)||Z.includes(se)}).filter(Q=>y==="all"||Q.meta.nozzle===y).filter(Q=>v==="all"||Q.meta.filamentType===v).filter(Q=>N==="all"||Q.meta.layerHeight===N).filter(Q=>l===""||Q.name.toLowerCase().includes(l.toLowerCase())).sort((Q,se)=>Q.name.localeCompare(se.name)),[pe,u,h,p,je,y,v,N,l]),ce=Q=>{if(z){const se=Y[0]?.setting_id===Q.setting_id,Z=Y[1]?.setting_id===Q.setting_id;if(se)oe([Y[1],null]);else if(Z)oe([Y[0],null]);else if(!Y[0])oe([Q,null]);else if(Y[1]){if(Y[0].type!==Q.type)return;oe([Y[0],Q])}else{if(Y[0].type!==Q.type)return;oe([Y[0],Q])}}else T(Q)},Se=Q=>{if(Y[0]?.setting_id===Q.setting_id)return 0;if(Y[1]?.setting_id===Q.setting_id)return 1},ie=async Q=>{try{const se=await re.getCloudSettingDetail(Q.setting_id),Z=Q.type==="process"?"print":Q.type;O({type:Z,name:Q.name,base_id:se.base_id||"GFSA00",setting:se.setting||{}}),T(null)}catch(se){console.error("Failed to fetch preset details for duplication:",se)}},Fe=async Q=>{try{_e.removeQueries({queryKey:["cloudSettingDetail",Q.setting_id]});const se=await re.getCloudSettingDetail(Q.setting_id),Z=Q.type==="process"?"print":Q.type;R({type:Z,name:Q.name,base_id:se.base_id||"GFSA00",setting:se.setting||{},setting_id:Q.setting_id}),T(null)}catch(se){console.error("Failed to fetch preset details for editing:",se)}},V=()=>{d("all"),f("all"),x("all"),b("all"),S("all"),A("all"),c("")},W=u!=="all"||h!=="all"||p!=="all"||y!=="all"||v!=="all"||N!=="all"||l!=="",ue=t.filament.length+t.printer.length+t.process.length;return a.jsxs(a.Fragment,{children:[a.jsxs("div",{className:"space-y-4 mb-6",children:[a.jsxs("div",{className:"flex flex-col sm:flex-row gap-3",children:[a.jsxs("div",{className:"relative flex-1",children:[a.jsx(Or,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray"}),a.jsx("input",{type:"text",value:l,onChange:Q=>c(Q.target.value),placeholder:o("profiles.cloudView.searchPlaceholder"),className:"w-full pl-10 pr-4 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white placeholder-bambu-gray-dark focus:border-bambu-green focus:outline-none"})]}),a.jsxs("div",{className:"flex gap-2 max-[550px]:flex-wrap max-[550px]:items-center",children:[a.jsxs(Ce,{variant:z?"primary":"secondary",onClick:()=>{z?(K(!1),oe([null,null])):K(!0)},children:[a.jsx(Yg,{className:"w-4 h-4"}),o(z?"common.cancel":"profiles.presets.compare")]}),a.jsxs(Ce,{variant:"secondary",onClick:()=>P(!0),disabled:!s("cloud:auth"),title:s("cloud:auth")?void 0:o("profiles.cloudView.noTemplatesPermission"),children:[a.jsx(pb,{className:"w-4 h-4"}),o("profiles.cloudView.templates")]}),a.jsxs(Ce,{variant:"secondary",onClick:n,disabled:r||!s("cloud:auth"),title:s("cloud:auth")?void 0:o("profiles.cloudView.noRefreshPermission"),children:[a.jsx(kr,{className:`w-4 h-4 ${r?"animate-spin":""}`}),o("profiles.cloudView.refresh")]}),a.jsxs(Ce,{onClick:()=>j(!0),disabled:!s("cloud:auth"),title:s("cloud:auth")?void 0:o("profiles.cloudView.noCreatePermission"),children:[a.jsx(ar,{className:"w-4 h-4"}),o("profiles.cloudView.newPreset")]})]})]}),a.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[a.jsx(tC,{className:"w-4 h-4 text-bambu-gray"}),a.jsx(Dg,{label:o("profiles.cloudView.filters.type"),value:u,options:[{value:"all",label:o("profiles.cloudView.filters.all"),count:ue},{value:"filament",label:o("profiles.cloudView.filters.filament"),count:t.filament.length},{value:"printer",label:o("profiles.cloudView.filters.printer"),count:t.printer.length},{value:"process",label:o("profiles.cloudView.filters.process"),count:t.process.length}],onChange:Q=>d(Q)}),a.jsx(Dg,{label:o("profiles.cloudView.filters.owner"),value:h,options:[{value:"all",label:o("profiles.cloudView.filters.all")},{value:"custom",label:o("profiles.cloudView.filters.myPresets")},{value:"builtin",label:o("profiles.cloudView.filters.builtIn")}],onChange:Q=>f(Q)}),me.printers.length>0&&a.jsx(Dg,{label:o("profiles.cloudView.filters.printer"),value:p,options:[{value:"all",label:o("profiles.cloudView.filters.all")},...me.printers.map(Q=>({value:Q.id,label:Q.name}))],onChange:x}),me.nozzles.length>0&&a.jsx(Dg,{label:o("profiles.cloudView.filters.nozzle"),value:y,options:[{value:"all",label:o("profiles.cloudView.filters.all")},...me.nozzles.map(Q=>({value:Q,label:Q}))],onChange:b}),me.filaments.length>0&&(u==="all"||u==="filament")&&a.jsx(Dg,{label:o("profiles.cloudView.filters.filament"),value:v,options:[{value:"all",label:o("profiles.cloudView.filters.all")},...me.filaments.map(Q=>({value:Q,label:Q}))],onChange:S}),me.layerHeights.length>0&&(u==="all"||u==="process")&&a.jsx(Dg,{label:o("profiles.cloudView.filters.layer"),value:N,options:[{value:"all",label:o("profiles.cloudView.filters.all")},...me.layerHeights.map(Q=>({value:Q,label:Q}))],onChange:A}),W&&a.jsx("button",{onClick:V,className:"px-3 py-2 text-sm text-bambu-gray hover:text-white transition-colors",children:o("profiles.cloudView.clearFilters")})]})]}),z&&a.jsx("div",{className:"mb-4 p-3 bg-blue-500/10 border border-blue-500/30 rounded-lg",children:a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsxs("div",{className:"flex items-center gap-4",children:[a.jsx(Yg,{className:"w-5 h-5 text-blue-400"}),a.jsx("span",{className:"text-white font-medium",children:o("profiles.cloudView.compareMode")}),a.jsx("span",{className:"text-bambu-gray",children:Y[0]?o("profiles.cloudView.selectAnotherPreset",{type:Y[0].type}):o("profiles.cloudView.clickTwoPresets")})]}),a.jsxs("div",{className:"flex items-center gap-3",children:[a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx("span",{className:`px-2 py-1 text-sm rounded truncate max-w-[200px] ${Y[0]?"bg-blue-500/30 text-blue-700 dark:text-blue-300":"bg-bambu-dark text-bambu-gray"}`,children:Y[0]?Y[0].name:o("profiles.cloudView.selectFirst")}),a.jsx(h3,{className:"w-4 h-4 text-bambu-gray"}),a.jsx("span",{className:`px-2 py-1 text-sm rounded truncate max-w-[200px] ${Y[1]?"bg-blue-500/30 text-blue-700 dark:text-blue-300":"bg-bambu-dark text-bambu-gray"}`,children:Y[1]?Y[1].name:o("profiles.cloudView.selectSecond")})]}),Y[0]&&Y[1]&&a.jsxs(Ce,{size:"sm",onClick:async()=>{try{const[Q,se]=await Promise.all([re.getCloudSettingDetail(Y[0].setting_id),re.getCloudSettingDetail(Y[1].setting_id)]);J([Q.setting||{},se.setting||{}]),X(!0)}catch{}},children:[a.jsx(Yg,{className:"w-4 h-4"}),o("profiles.cloudView.compareNow")]})]})]})}),a.jsxs("div",{className:"flex flex-wrap items-center gap-4 mb-4 text-sm text-bambu-gray",children:[e&&a.jsxs("div",{className:"flex items-center gap-1",children:[a.jsx(Wn,{className:"w-3 h-3"}),o("profiles.cloudView.lastSynced")," ",NZe(e.toISOString(),o)]}),a.jsx("span",{children:o("profiles.cloudView.showingCount",{showing:de.length,total:ue})}),a.jsxs("div",{className:"flex items-center gap-1",children:[a.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-bambu-green"}),a.jsxs("span",{children:["= ",o("profiles.presets.myPreset")]})]})]}),de.length===0?a.jsxs("div",{className:"text-center py-16",children:[a.jsx(ma,{className:"w-12 h-12 text-bambu-gray-dark mx-auto mb-4"}),a.jsx("p",{className:"text-bambu-gray",children:o("profiles.cloudView.noPresetsFound")}),W&&a.jsx("button",{onClick:V,className:"mt-2 text-sm text-bambu-green hover:text-bambu-green-light",children:o("profiles.cloudView.clearFilters")})]}):a.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-6",children:[a.jsxs("div",{children:[a.jsxs("div",{className:"flex items-center gap-2 mb-3 px-1",children:[a.jsx(Jk,{className:"w-4 h-4 text-amber-400"}),a.jsx("h3",{className:"text-sm font-medium text-bambu-gray",children:o("profiles.cloudView.columns.filament")}),a.jsxs("span",{className:"text-xs text-bambu-gray-dark",children:["(",de.filter(Q=>Q.type==="filament").length,")"]})]}),a.jsxs("div",{className:"space-y-1 max-h-[calc(100vh-320px)] overflow-y-auto pr-1",children:[de.filter(Q=>Q.type==="filament").map(Q=>a.jsx(Vj,{setting:Q,onClick:()=>ce(Q),onDuplicate:()=>ie(Q),compareMode:z,isCompareSelected:Se(Q)!==void 0,compareIndex:Se(Q),compareDisabled:z&&!!Y[0]&&Y[0].type!==Q.type,t:o},Q.setting_id)),de.filter(Q=>Q.type==="filament").length===0&&a.jsx("p",{className:"text-xs text-bambu-gray-dark px-3 py-2",children:o("profiles.cloudView.noFilamentPresets")})]})]}),a.jsxs("div",{children:[a.jsxs("div",{className:"flex items-center gap-2 mb-3 px-1",children:[a.jsx(nd,{className:"w-4 h-4 text-blue-400"}),a.jsx("h3",{className:"text-sm font-medium text-bambu-gray",children:o("profiles.cloudView.columns.process")}),a.jsxs("span",{className:"text-xs text-bambu-gray-dark",children:["(",de.filter(Q=>Q.type==="process").length,")"]})]}),a.jsxs("div",{className:"space-y-1 max-h-[calc(100vh-320px)] overflow-y-auto pr-1",children:[de.filter(Q=>Q.type==="process").map(Q=>a.jsx(Vj,{setting:Q,onClick:()=>ce(Q),onDuplicate:()=>ie(Q),compareMode:z,isCompareSelected:Se(Q)!==void 0,compareIndex:Se(Q),compareDisabled:z&&!!Y[0]&&Y[0].type!==Q.type,t:o},Q.setting_id)),de.filter(Q=>Q.type==="process").length===0&&a.jsx("p",{className:"text-xs text-bambu-gray-dark px-3 py-2",children:o("profiles.cloudView.noProcessPresets")})]})]}),a.jsxs("div",{children:[a.jsxs("div",{className:"flex items-center gap-2 mb-3 px-1",children:[a.jsx(Cr,{className:"w-4 h-4 text-purple-400"}),a.jsx("h3",{className:"text-sm font-medium text-bambu-gray",children:o("profiles.cloudView.columns.printer")}),a.jsxs("span",{className:"text-xs text-bambu-gray-dark",children:["(",de.filter(Q=>Q.type==="printer").length,")"]})]}),a.jsxs("div",{className:"space-y-1 max-h-[calc(100vh-320px)] overflow-y-auto pr-1",children:[de.filter(Q=>Q.type==="printer").map(Q=>a.jsx(Vj,{setting:Q,onClick:()=>ce(Q),onDuplicate:()=>ie(Q),compareMode:z,isCompareSelected:Se(Q)!==void 0,compareIndex:Se(Q),compareDisabled:z&&!!Y[0]&&Y[0].type!==Q.type,t:o},Q.setting_id)),de.filter(Q=>Q.type==="printer").length===0&&a.jsx("p",{className:"text-xs text-bambu-gray-dark px-3 py-2",children:o("profiles.cloudView.noPrinterPresets")})]})]})]}),C&&a.jsx(MZe,{setting:C,onClose:()=>T(null),onDeleted:()=>T(null),onDuplicate:()=>ie(C),onEdit:()=>Fe(C),hasPermission:s,t:o}),(k||U||B||G)&&a.jsx(TZe,{onClose:()=>{j(!1),O(null),R(null),q(null)},initialData:B||U||(G?{type:G.type,name:"",base_id:"",setting:G.setting}:void 0),allPresets:t,t:o}),E&&a.jsx(AZe,{onClose:()=>P(!1),onApply:Q=>{q({type:Q.type,setting:Q.settings}),P(!1)},t:o}),$&&ee&&Y[0]&&Y[1]&&a.jsx(Xae,{onClose:()=>{X(!1),J(null)},leftPreset:ee[0],rightPreset:ee[1],leftLabel:Y[0].name,rightLabel:Y[1].name,t:o})]})}function PZe(){const{t}=Vt(),e=tn(),{showToast:n}=hn(),{hasPermission:r}=Ir(),[i,s]=w.useState("cloud"),[o,l]=w.useState(),{data:c,isLoading:u}=Ze({queryKey:["cloudStatus"],queryFn:re.getCloudStatus}),{data:d=[]}=Ze({queryKey:["printers"],queryFn:re.getPrinters}),{data:h,isLoading:f,refetch:p,dataUpdatedAt:x}=Ze({queryKey:["cloudSettings"],queryFn:()=>re.getCloudSettings(),enabled:!!c?.is_authenticated,retry:!1,staleTime:1e3*60*5});w.useEffect(()=>{x&&l(new Date(x))},[x]);const y=ot({mutationFn:re.cloudLogout,onSuccess:()=>{e.invalidateQueries({queryKey:["cloudStatus"]}),e.removeQueries({queryKey:["cloudSettings"]}),n(t("profiles.toast.loggedOut"))}}),b=()=>{e.invalidateQueries({queryKey:["cloudStatus"]})};return u?a.jsx("div",{className:"p-4 md:p-8 flex items-center justify-center min-h-[400px]",children:a.jsx(it,{className:"w-8 h-8 text-bambu-green animate-spin"})}):a.jsxs("div",{className:"p-6 lg:p-8",children:[a.jsxs("div",{className:"mb-6",children:[a.jsx("h1",{className:"text-2xl font-bold text-white",children:t("profiles.title")}),a.jsx("p",{className:"text-bambu-gray",children:t("profiles.subtitle")})]}),a.jsxs("div",{className:"flex border-b border-bambu-dark-tertiary mb-6",children:[a.jsxs("button",{onClick:()=>s("cloud"),className:`flex items-center gap-2 px-4 py-3 text-sm font-medium transition-colors border-b-2 -mb-px ${i==="cloud"?"text-bambu-green border-bambu-green":"text-bambu-gray hover:text-white border-transparent"}`,children:[a.jsx(Gb,{className:"w-4 h-4"}),t("profiles.tabs.cloud")]}),a.jsxs("button",{onClick:()=>s("local"),className:`flex items-center gap-2 px-4 py-3 text-sm font-medium transition-colors border-b-2 -mb-px ${i==="local"?"text-bambu-green border-bambu-green":"text-bambu-gray hover:text-white border-transparent"}`,children:[a.jsx(qb,{className:"w-4 h-4"}),t("profiles.tabs.local")]}),a.jsxs("button",{onClick:()=>s("kprofiles"),className:`flex items-center gap-2 px-4 py-3 text-sm font-medium transition-colors border-b-2 -mb-px ${i==="kprofiles"?"text-bambu-green border-bambu-green":"text-bambu-gray hover:text-white border-transparent"}`,children:[a.jsx(nC,{className:"w-4 h-4"}),t("profiles.tabs.kprofiles")]})]}),i==="cloud"&&a.jsxs(a.Fragment,{children:[c?.is_authenticated&&a.jsxs("div",{className:"flex items-center justify-between p-3 mb-6 bg-bambu-dark rounded-lg border border-bambu-dark-tertiary",children:[a.jsxs("div",{className:"flex items-center gap-3",children:[a.jsx("div",{className:"w-2 h-2 rounded-full bg-bambu-green animate-pulse"}),a.jsxs("span",{className:"text-sm text-bambu-gray",children:[t("profiles.connectedAs")," ",a.jsx("span",{className:"text-white",children:c.email})]})]}),a.jsxs(Ce,{variant:"secondary",size:"sm",onClick:()=>y.mutate(),disabled:y.isPending||!r("cloud:auth"),title:r("cloud:auth")?void 0:t("profiles.noLogoutPermission"),children:[a.jsx(x3,{className:"w-4 h-4"}),t("profiles.logout")]})]}),c?.is_authenticated?f?a.jsx("div",{className:"flex items-center justify-center py-16",children:a.jsx(it,{className:"w-8 h-8 text-bambu-green animate-spin"})}):h?a.jsx(EZe,{settings:h,lastSyncTime:o,onRefresh:()=>p(),isRefreshing:f,printers:d,hasPermission:r,t}):a.jsxs("div",{className:"text-center py-16",children:[a.jsx("p",{className:"text-bambu-gray mb-4",children:t("profiles.failedToLoad")}),a.jsx(Ce,{onClick:()=>p(),children:t("profiles.retry")})]}):a.jsx(kZe,{onSuccess:b,t})]}),i==="local"&&a.jsx(SZe,{}),i==="kprofiles"&&a.jsx(yZe,{}),a.jsx(CZe,{})]})}const Ky={Droplet:Jk,Flame:Qhe,Ruler:Tfe,Sparkles:pb,Square:bl,Cable:Lde,Wrench:Ff,Calendar:ii,Timer:Iu,Cog:vhe,Fan:hX,Zap:Wh,Wind:SX,Thermometer:uC,Layers:ma,Box:ea,Target:vX,RefreshCw:kr,Settings:cC,Filter:tC,CircleDot:rhe};function x0(t){return t&&Ky[t]||Ff}function Rg(t,e,n){if(e==="days"){if(t<1)return n?n("common.today"):"Today";if(t===1)return n?n("maintenance.day"):"1 day";if(t<7){const i=Math.round(t);return n?n("maintenance.days",{count:i}):`${i} days`}if(t<180){const i=Math.round(t/7);return i===1?n?n("maintenance.week"):"1 week":n?n("maintenance.weeks",{count:i}):`${i} weeks`}const r=Math.round(t/30);return r===1?n?n("maintenance.month"):"1 month":n?n("maintenance.months",{count:r}):`${r} months`}else{if(t<1)return`${Math.round(t*60)}m`;if(t<24)return`${t<10?t.toFixed(1):Math.round(t)}h`;const r=t/24;if(r<7)return`${r<2?r.toFixed(1):Math.round(r)}d`;const i=r/7;return i<12?`${i<2?i.toFixed(1):Math.round(i)}w`:`${Math.round(i/4)}mo`}}function Gj(t,e,n){return e==="days"?t===1?n?n("maintenance.day"):"1 day":t===7?n?n("maintenance.week"):"1 week":t===14?n?n("maintenance.weeks",{count:2}):"2 weeks":t===30?n?n("maintenance.month"):"1 month":t===60?n?n("maintenance.months",{count:2}):"2 months":t===90?n?n("maintenance.months",{count:3}):"3 months":t===180?n?n("maintenance.months",{count:6}):"6 months":t===365?n?n("maintenance.year"):"1 year":n?n("maintenance.days",{count:t}):`${t} days`:`${t}h`}function jZe(t,e){const n=(e||"").toUpperCase().replace(/[- ]/g,""),r=n.includes("X1"),i=n.includes("P1"),s=n.includes("A1MINI"),o=n.includes("A1")&&!s,l=n.includes("H2D"),c=n.includes("H2C"),u=n.includes("H2S"),d=l||c||u,h=n.includes("P2S");switch(t){case"Lubricate Carbon Rods":return r?"https://wiki.bambulab.com/en/x1/maintenance/basic-maintenance":i?"https://wiki.bambulab.com/en/p1/maintenance/p1p-maintenance":h?"https://wiki.bambulab.com/en/p2s/maintenance/belt-tension":null;case"Lubricate Linear Rails":return s?"https://wiki.bambulab.com/en/a1-mini/maintenance/lubricate-y-axis":o?"https://wiki.bambulab.com/en/a1/maintenance/lubricate-y-axis":d?"https://wiki.bambulab.com/en/h2/maintenance/x-axis-lubrication":null;case"Clean Nozzle/Hotend":return r||i?"https://wiki.bambulab.com/en/x1/troubleshooting/nozzle-clog":s||o?"https://wiki.bambulab.com/en/a1-mini/troubleshooting/nozzle-clog":d?"https://wiki.bambulab.com/en/h2/maintenance/nozzl-cold-pull-maintenance-and-cleaning":h?"https://wiki.bambulab.com/en/p2s/maintenance/cold-pull-maintenance-hotend":"https://wiki.bambulab.com/en/x1/troubleshooting/nozzle-clog";case"Check Belt Tension":return r?"https://wiki.bambulab.com/en/x1/maintenance/belt-tension":i?"https://wiki.bambulab.com/en/p1/maintenance/p1p-maintenance":s?"https://wiki.bambulab.com/en/a1-mini/maintenance/belt_tension":o?"https://wiki.bambulab.com/en/a1/maintenance/belt_tension":l?"https://wiki.bambulab.com/en/h2/maintenance/belt-tension":c?"https://wiki.bambulab.com/en/h2c/maintenance/belt-tension":u?"https://wiki.bambulab.com/en/h2s/maintenance/belt-tension":h?"https://wiki.bambulab.com/en/p2s/maintenance/belt-tension":"https://wiki.bambulab.com/en/x1/maintenance/belt-tension";case"Clean Carbon Rods":return r||i||h?"https://wiki.bambulab.com/en/general/carbon-rods-clearance":null;case"Clean Linear Rails":return s?"https://wiki.bambulab.com/en/a1-mini/maintenance/lubricate-y-axis":o?"https://wiki.bambulab.com/en/a1/maintenance/lubricate-y-axis":d?"https://wiki.bambulab.com/en/h2/maintenance/x-axis-lubrication":null;case"Clean Build Plate":return"https://wiki.bambulab.com/en/filament-acc/acc/pei-plate-clean-guide";case"Check PTFE Tube":return r||i?"https://wiki.bambulab.com/en/x1/maintenance/replace-ptfe-tube":s||o?"https://wiki.bambulab.com/en/a1-mini/maintenance/ptfe-tube":l?"https://wiki.bambulab.com/en/h2/maintenance/replace-ptfe-tube-on-h2d-printer":u?"https://wiki.bambulab.com/en/h2s/maintenance/replace-ptfe-tube-on-h2s-printer":c?"https://wiki.bambulab.com/en/h2/maintenance/replace-ptfe-tube-on-h2d-printer":"https://wiki.bambulab.com/en/x1/maintenance/replace-ptfe-tube";case"Replace HEPA Filter":case"HEPA Filter":case"Replace Carbon Filter":case"Carbon Filter":return d?"https://wiki.bambulab.com/en/h2/maintenance/replace-smoke-purifier-air-filte":"https://wiki.bambulab.com/en/x1/maintenance/replace-carbon-filter";case"Lubricate Left Nozzle Rail":case"Left Nozzle Rail":return d?"https://wiki.bambulab.com/en/h2/maintenance/x-axis-lubrication":null;default:return null}}function DZe({item:t,onPerform:e,onToggle:n,hasPermission:r,t:i}){const s=x0(t.maintenance_type_icon),o=t.interval_type||"hours",c=(()=>{if(o==="days"){const p=t.days_since_maintenance??0;return Math.max(0,Math.min(100,p/t.interval_hours*100))}return Math.max(0,Math.min(100,(t.interval_hours-t.hours_until_due)/t.interval_hours*100))})(),u=()=>t.enabled?t.is_due?"text-red-400":t.is_warning?"text-amber-400":"text-bambu-green":"text-bambu-gray",d=()=>t.enabled?t.is_due?"bg-red-500":t.is_warning?"bg-amber-500":"bg-bambu-green":"bg-bambu-gray/30",h=()=>t.enabled?t.is_due?"bg-red-500/5 border-red-500/20":t.is_warning?"bg-amber-500/5 border-amber-500/20":"bg-bambu-dark-secondary border-bambu-dark-tertiary":"bg-bambu-dark-secondary/50",f=()=>{if(!t.enabled)return i("common.disabled");if(o==="days"){const p=t.days_until_due??0;return t.is_due?i("maintenance.overdueBy",{duration:Rg(Math.abs(p),"days",i)}):t.is_warning?i("maintenance.dueIn",{duration:Rg(p,"days",i)}):i("maintenance.timeLeft",{duration:Rg(p,"days",i)})}else return t.is_due?i("maintenance.overdueBy",{duration:Rg(Math.abs(t.hours_until_due),"hours",i)}):t.is_warning?i("maintenance.dueIn",{duration:Rg(t.hours_until_due,"hours",i)}):i("maintenance.timeLeft",{duration:Rg(t.hours_until_due,"hours",i)})};return a.jsx("div",{className:`rounded-xl border p-4 transition-all ${h()}`,children:a.jsxs("div",{className:"flex items-start gap-3 max-[550px]:flex-wrap",children:[a.jsxs("div",{className:`relative p-2.5 rounded-lg shrink-0 ${t.is_due?"bg-red-500/20":t.is_warning?"bg-amber-500/20":t.enabled?"bg-bambu-dark":"bg-bambu-dark/50"}`,children:[a.jsx(s,{className:`w-5 h-5 ${u()}`}),t.enabled&&(t.is_due||t.is_warning)&&a.jsx("span",{className:`absolute -top-1 -right-1 w-2.5 h-2.5 rounded-full ${t.is_due?"bg-red-500":"bg-amber-500"} animate-pulse`})]}),a.jsxs("div",{className:"flex-1 min-w-0",children:[a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx("h3",{className:`font-medium truncate ${t.enabled?"text-white":"text-bambu-gray"}`,children:t.maintenance_type_name}),o==="days"&&a.jsx("span",{title:i("maintenance.timeBasedInterval"),children:a.jsx(ii,{className:"w-3.5 h-3.5 text-bambu-gray shrink-0"})}),(()=>{const p=t.maintenance_type_wiki_url||jZe(t.maintenance_type_name,t.printer_model);return p?a.jsx("a",{href:p,target:"_blank",rel:"noopener noreferrer",className:"text-bambu-gray hover:text-bambu-green transition-colors shrink-0",title:i("maintenance.viewDocumentation"),onClick:x=>x.stopPropagation(),children:a.jsx(Kr,{className:"w-3.5 h-3.5"})}):null})()]}),a.jsx("div",{className:"mt-2 mb-1.5",children:a.jsx("div",{className:"w-full h-1.5 bg-bambu-dark rounded-full overflow-hidden",children:a.jsx("div",{className:`h-full rounded-full transition-all duration-500 ${d()}`,style:{width:`${c}%`}})})}),a.jsxs("div",{className:`text-xs flex items-center gap-1 ${u()}`,children:[t.is_due&&a.jsx(Cn,{className:"w-3 h-3"}),t.is_warning&&!t.is_due&&a.jsx(Wn,{className:"w-3 h-3"}),!t.is_due&&!t.is_warning&&t.enabled&&a.jsx(Xr,{className:"w-3 h-3"}),f()]})]}),a.jsxs("div",{className:"flex items-center gap-2 shrink-0 max-[550px]:w-full max-[550px]:justify-end max-[550px]:mt-1",children:[a.jsx("span",{title:r("maintenance:update")?void 0:i("maintenance.noPermissionUpdate"),children:a.jsx(zn,{checked:t.enabled,onChange:p=>n(t.id,p),disabled:!r("maintenance:update")})}),a.jsxs(Ce,{size:"sm",variant:t.is_due?"primary":"secondary",onClick:()=>e(t.id),disabled:!t.enabled||!r("maintenance:update"),title:r("maintenance:update")?void 0:i("maintenance.noPermissionPerform"),className:"!px-3",children:[a.jsx(Ro,{className:"w-3.5 h-3.5"}),i("common.reset")]})]})]})})}function RZe({overview:t,onPerform:e,onToggle:n,onSetHours:r,hasPermission:i,t:s}){const[o,l]=w.useState(!1),[c,u]=w.useState(!1),[d,h]=w.useState(t.total_print_hours.toFixed(1)),f=[...t.maintenance_items].sort((y,b)=>y.is_due&&!b.is_due?-1:!y.is_due&&b.is_due?1:y.is_warning&&!b.is_warning?-1:!y.is_warning&&b.is_warning?1:y.maintenance_type_id-b.maintenance_type_id),p=f.find(y=>y.enabled&&(y.is_due||y.is_warning)),x=()=>{const y=parseFloat(d);!isNaN(y)&&y>=0&&(r(t.printer_id,y),u(!1))};return a.jsxs(vt,{className:"overflow-hidden",children:[a.jsxs("div",{className:"p-5",children:[a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsxs("div",{className:"flex items-center gap-4",children:[a.jsx("h2",{className:"text-xl font-semibold text-white",children:t.printer_name}),a.jsxs("div",{className:"flex items-center gap-2",children:[t.due_count>0&&a.jsxs("span",{className:"px-2.5 py-1 bg-red-500/20 text-red-400 text-xs font-medium rounded-full flex items-center gap-1.5",children:[a.jsx(Cn,{className:"w-3 h-3"}),s("maintenance.overdueCount",{count:t.due_count})]}),t.warning_count>0&&a.jsxs("span",{className:"px-2.5 py-1 bg-amber-500/20 text-amber-400 text-xs font-medium rounded-full flex items-center gap-1.5",children:[a.jsx(Wn,{className:"w-3 h-3"}),s("maintenance.dueSoonCount",{count:t.warning_count})]}),t.due_count===0&&t.warning_count===0&&a.jsxs("span",{className:"px-2.5 py-1 bg-bambu-green/20 text-bambu-green text-xs font-medium rounded-full flex items-center gap-1.5",children:[a.jsx(Xr,{className:"w-3 h-3"}),s("maintenance.allGood")]})]})]}),a.jsxs("button",{onClick:()=>l(!o),className:"flex items-center gap-1.5 px-3 py-1.5 text-sm text-bambu-gray hover:text-white hover:bg-bambu-dark rounded-lg transition-colors",children:[o?a.jsx(Wl,{className:"w-4 h-4"}):a.jsx(nr,{className:"w-4 h-4"}),s(o?"common.collapse":"common.expand")]})]}),a.jsxs("div",{className:"flex items-center gap-6 mt-4",children:[a.jsxs("div",{className:"flex items-center gap-3",children:[a.jsx("div",{className:"p-2 bg-bambu-dark/50 rounded-lg",children:a.jsx(Iu,{className:"w-4 h-4 text-bambu-gray"})}),c?a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx("input",{type:"number",value:d,onChange:y=>h(y.target.value),onKeyDown:y=>{y.key==="Enter"&&x(),y.key==="Escape"&&u(!1)},className:"w-24 px-2 py-1 bg-bambu-dark border border-bambu-dark-tertiary rounded text-white text-sm",min:"0",step:"1",autoFocus:!0}),a.jsx("span",{className:"text-xs text-bambu-gray",children:s("common.hours")}),a.jsx(Ce,{size:"sm",onClick:x,children:s("common.save")}),a.jsx(Ce,{size:"sm",variant:"secondary",onClick:()=>u(!1),children:s("common.cancel")})]}):a.jsxs("button",{onClick:()=>{i("maintenance:update")&&(h(Math.round(t.total_print_hours).toString()),u(!0))},className:`group ${i("maintenance:update")?"":"cursor-not-allowed opacity-60"}`,title:i("maintenance:update")?void 0:s("maintenance.noPermissionEditHours"),children:[a.jsxs("div",{className:`text-sm font-medium text-white ${i("maintenance:update")?"group-hover:text-bambu-green":""} transition-colors flex items-center gap-1`,children:[Math.round(t.total_print_hours)," ",s("common.hours"),a.jsx(jf,{className:`w-3 h-3 text-bambu-gray ${i("maintenance:update")?"group-hover:text-bambu-green":""}`})]}),a.jsx("div",{className:"text-xs text-bambu-gray",children:s("maintenance.totalPrintTime")})]})]}),a.jsx("div",{className:"w-px h-10 bg-bambu-dark-tertiary"}),p&&a.jsxs("div",{className:"flex items-center gap-3",children:[a.jsx("div",{className:`p-2 rounded-lg ${p.is_due?"bg-red-500/20":"bg-amber-500/20"}`,children:(()=>{const y=x0(p.maintenance_type_icon);return a.jsx(y,{className:`w-4 h-4 ${p.is_due?"text-red-400":"text-amber-400"}`})})()}),a.jsxs("div",{children:[a.jsx("div",{className:`text-sm font-medium ${p.is_due?"text-red-400":"text-amber-400"}`,children:p.maintenance_type_name}),a.jsx("div",{className:`text-xs ${p.is_due?"text-red-400/70":"text-amber-400/70"}`,children:p.is_due?s("common.overdue"):s("maintenance.dueSoon")})]})]})]})]}),o&&a.jsx(Nt,{className:"pt-0 border-t border-bambu-dark-tertiary",children:a.jsx("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-3 pt-4",children:f.map(y=>a.jsx(DZe,{item:y,onPerform:e,onToggle:n,hasPermission:i,t:s},y.id))})})]})}function FZe({overview:t,types:e,onUpdateInterval:n,onAddType:r,onUpdateType:i,onDeleteType:s,onRestoreDefaults:o,isRestoringDefaults:l,onAssignType:c,onRemoveItem:u,hasPermission:d,t:h}){const[f,p]=w.useState(null),[x,y]=w.useState(""),[b,v]=w.useState("hours"),[S,N]=w.useState(!1),[A,C]=w.useState(""),[T,k]=w.useState("100"),[j,E]=w.useState("hours"),[P,U]=w.useState("Wrench"),[O,B]=w.useState(""),[R,G]=w.useState(new Set),[q,z]=w.useState(null),[K,Y]=w.useState(null),oe=w.useMemo(()=>t?t.map(L=>({id:L.printer_id,name:L.printer_name})):[],[t]),$=L=>t?t.filter(D=>D.maintenance_items.some(H=>H.maintenance_type_id===L)).map(D=>({printerId:D.printer_id,printerName:D.printer_name,itemId:D.maintenance_items.find(H=>H.maintenance_type_id===L)?.id})):[],X=L=>{if(!t)return[];const D=new Set($(L).map(H=>H.printerId));return oe.filter(H=>!D.has(H.id))},[ee,J]=w.useState(null),[_e,pe]=w.useState(""),[me,je]=w.useState(""),[de,ce]=w.useState("hours"),[Se,ie]=w.useState("Wrench"),[Fe,V]=w.useState(""),W=L=>{J(L),pe(L.name),je(L.default_interval_hours.toString()),ce(L.interval_type||"hours"),ie(L.icon||"Wrench"),V(L.wiki_url||"")},ue=()=>{ee&&_e.trim()&&parseFloat(me)>0&&(i(ee.id,{name:_e.trim(),default_interval_hours:parseFloat(me),interval_type:de,icon:Se,wiki_url:Fe.trim()||null}),J(null))},Q=(L,D,H)=>{const he=parseFloat(x);if(!isNaN(he)&&he>0){const xe=Math.abs(he-D)<.01?null:he;n(L,{custom_interval_hours:xe,custom_interval_type:b!==H?b:null})}p(null)},se=L=>{L.preventDefault(),A.trim()&&parseFloat(T)>0&&R.size>0&&(r({name:A.trim(),default_interval_hours:parseFloat(T),interval_type:j,icon:P,wiki_url:O.trim()||null},Array.from(R)),C(""),k("100"),E("hours"),B(""),G(new Set),N(!1))},Z=L=>{G(D=>{const H=new Set(D);return H.has(L)?H.delete(L):H.add(L),H})},Ne=t?.map(L=>({printerId:L.printer_id,printerName:L.printer_name,items:L.maintenance_items.sort((D,H)=>D.maintenance_type_id-H.maintenance_type_id)})).sort((L,D)=>L.printerName.localeCompare(D.printerName))||[],ve=e.filter(L=>L.is_system),fe=e.filter(L=>!L.is_system);return a.jsxs("div",{className:"space-y-8",children:[a.jsxs("div",{children:[a.jsxs("div",{className:"flex items-center justify-between mb-4",children:[a.jsxs("div",{children:[a.jsx("h2",{className:"text-lg font-semibold text-white",children:h("maintenance.maintenanceTypes")}),a.jsx("p",{className:"text-sm text-bambu-gray mt-1",children:h("maintenance.maintenanceTypesDescription")})]}),a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx(Ce,{variant:"secondary",onClick:o,disabled:!d("maintenance:delete")||l,title:d("maintenance:delete")?void 0:h("maintenance.noPermissionDeleteTypes"),children:h("maintenance.restoreDefaults")}),a.jsxs(Ce,{onClick:()=>N(!S),disabled:!d("maintenance:create"),title:d("maintenance:create")?void 0:h("maintenance.noPermissionEditTypes"),children:[a.jsx(ar,{className:"w-4 h-4"}),h("maintenance.addCustomType")]})]})]}),S&&a.jsx(vt,{className:"mb-6",children:a.jsx(Nt,{className:"py-4",children:a.jsxs("form",{onSubmit:se,children:[a.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-4 gap-4",children:[a.jsxs("div",{className:"lg:col-span-2",children:[a.jsx("label",{className:"block text-xs text-bambu-gray mb-1.5",children:h("common.name")}),a.jsx("input",{type:"text",value:A,onChange:L=>C(L.target.value),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white text-sm focus:border-bambu-green focus:outline-none",placeholder:h("maintenance.exampleName"),autoFocus:!0})]}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-xs text-bambu-gray mb-1.5",children:h("maintenance.intervalType")}),a.jsxs("select",{value:j,onChange:L=>{E(L.target.value),L.target.value==="days"?k("30"):k("100")},className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white text-sm focus:border-bambu-green focus:outline-none",children:[a.jsx("option",{value:"hours",children:h("maintenance.printHours")}),a.jsx("option",{value:"days",children:h("maintenance.calendarDays")})]})]}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-xs text-bambu-gray mb-1.5",children:h("maintenance.intervalValue",{type:j==="days"?h("maintenance.calendarDays").toLowerCase():h("common.hours")})}),a.jsx("input",{type:"number",value:T,onChange:L=>k(L.target.value),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white text-sm focus:border-bambu-green focus:outline-none",min:"1"})]})]}),a.jsx("div",{className:"mt-4 flex items-end justify-between",children:a.jsxs("div",{children:[a.jsx("label",{className:"block text-xs text-bambu-gray mb-1.5",children:h("maintenance.icon")}),a.jsx("div",{className:"flex gap-1",children:Object.keys(Ky).map(L=>{const D=Ky[L];return a.jsx("button",{type:"button",onClick:()=>U(L),className:`p-2 rounded-lg transition-colors ${P===L?"bg-bambu-green text-white":"bg-bambu-dark text-bambu-gray hover:text-white hover:bg-bambu-dark-tertiary"}`,children:a.jsx(D,{className:"w-4 h-4"})},L)})})]})}),a.jsxs("div",{className:"mt-4",children:[a.jsx("label",{className:"block text-xs text-bambu-gray mb-1.5",children:h("maintenance.documentationLink")}),a.jsx("input",{type:"url",value:O,onChange:L=>B(L.target.value),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white text-sm focus:border-bambu-green focus:outline-none",placeholder:"https://wiki.bambulab.com/..."})]}),a.jsxs("div",{className:"mt-4",children:[a.jsx("label",{className:"block text-xs text-bambu-gray mb-1.5",children:h("maintenance.assignToPrinters")}),a.jsx("div",{className:"flex flex-wrap gap-2",children:oe.map(L=>a.jsx("button",{type:"button",onClick:()=>Z(L.id),className:`px-3 py-1.5 rounded-lg text-sm transition-colors ${R.has(L.id)?"bg-bambu-green text-white":"bg-bambu-dark text-bambu-gray hover:text-white hover:bg-bambu-dark-tertiary"}`,children:L.name},L.id))}),R.size===0&&a.jsx("p",{className:"text-xs text-orange-400 mt-1",children:h("maintenance.selectAtLeastOnePrinter")})]}),a.jsxs("div",{className:"mt-4 flex justify-end gap-2",children:[a.jsx(Ce,{type:"button",variant:"secondary",onClick:()=>{N(!1),G(new Set)},children:h("common.cancel")}),a.jsx(Ce,{type:"submit",disabled:!A.trim()||R.size===0,children:h("maintenance.addType")})]})]})})}),a.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-3",children:[ve.map(L=>{const D=x0(L.icon),H=L.interval_type||"hours";return a.jsx("div",{className:"bg-bambu-dark-secondary rounded-xl p-4 border border-bambu-dark-tertiary",children:a.jsxs("div",{className:"flex items-center gap-3",children:[a.jsx("div",{className:"p-2.5 bg-bambu-dark rounded-lg",children:a.jsx(D,{className:"w-5 h-5 text-bambu-gray"})}),a.jsxs("div",{className:"flex-1 min-w-0",children:[a.jsx("div",{className:"text-sm font-medium text-white truncate",children:L.name}),a.jsxs("div",{className:"text-xs text-bambu-gray mt-0.5 flex items-center gap-1",children:[H==="days"?a.jsx(ii,{className:"w-3 h-3"}):a.jsx(Iu,{className:"w-3 h-3"}),Gj(L.default_interval_hours,H,h)]})]}),a.jsx("button",{onClick:()=>{d("maintenance:delete")&&Y(L)},disabled:!d("maintenance:delete"),title:d("maintenance:delete")?void 0:h("maintenance.noPermissionDeleteTypes"),className:`p-2 rounded-lg hover:bg-bambu-dark text-bambu-gray hover:text-red-400 transition-colors ${d("maintenance:delete")?"":"opacity-50 cursor-not-allowed"}`,children:a.jsx(Jt,{className:"w-4 h-4"})})]})},L.id)}),fe.map(L=>{const D=x0(L.icon),H=L.interval_type||"hours";if(ee?.id===L.id)return a.jsx("div",{className:"bg-bambu-dark-secondary rounded-xl p-4 border border-bambu-green",children:a.jsxs("div",{className:"space-y-3",children:[a.jsx("input",{type:"text",value:_e,onChange:Oe=>pe(Oe.target.value),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white text-sm focus:border-bambu-green focus:outline-none",placeholder:h("common.name"),autoFocus:!0}),a.jsxs("div",{className:"flex gap-2",children:[a.jsxs("select",{value:de,onChange:Oe=>ce(Oe.target.value),className:"flex-1 px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white text-sm focus:border-bambu-green focus:outline-none",children:[a.jsx("option",{value:"hours",children:h("maintenance.printHours")}),a.jsx("option",{value:"days",children:h("maintenance.calendarDays")})]}),a.jsx("input",{type:"number",value:me,onChange:Oe=>je(Oe.target.value),className:"w-24 px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white text-sm focus:border-bambu-green focus:outline-none",min:"1"})]}),a.jsx("div",{className:"flex flex-wrap gap-1",children:Object.keys(Ky).map(Oe=>{const Qe=Ky[Oe];return a.jsx("button",{type:"button",onClick:()=>ie(Oe),className:`p-1.5 rounded transition-colors ${Se===Oe?"bg-bambu-green text-white":"bg-bambu-dark text-bambu-gray hover:text-white"}`,children:a.jsx(Qe,{className:"w-3.5 h-3.5"})},Oe)})}),a.jsx("input",{type:"url",value:Fe,onChange:Oe=>V(Oe.target.value),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white text-sm focus:border-bambu-green focus:outline-none",placeholder:h("maintenance.documentationLink")}),a.jsxs("div",{className:"flex gap-2",children:[a.jsx(Ce,{size:"sm",onClick:ue,disabled:!_e.trim(),children:h("common.save")}),a.jsx(Ce,{size:"sm",variant:"secondary",onClick:()=>J(null),children:h("common.cancel")})]})]})},L.id);const xe=$(L.id),be=X(L.id),Ue=q===L.id;return a.jsxs("div",{className:"bg-bambu-dark-secondary rounded-xl p-4 border border-bambu-green/30",children:[a.jsxs("div",{className:"flex items-center gap-3",children:[a.jsx("div",{className:"p-2.5 bg-bambu-green/20 rounded-lg",children:a.jsx(D,{className:"w-5 h-5 text-bambu-green"})}),a.jsxs("div",{className:"flex-1 min-w-0",children:[a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx("span",{className:"text-sm font-medium text-white truncate",children:L.name}),a.jsx("span",{className:"px-1.5 py-0.5 bg-bambu-green/20 text-bambu-green text-[10px] font-medium rounded",children:h("maintenance.custom")})]}),a.jsxs("div",{className:"text-xs text-bambu-gray mt-0.5 flex items-center gap-1",children:[H==="days"?a.jsx(ii,{className:"w-3 h-3"}):a.jsx(Iu,{className:"w-3 h-3"}),Gj(L.default_interval_hours,H,h)]})]}),a.jsxs("button",{onClick:()=>z(Ue?null:L.id),className:`px-2 py-1 rounded-lg border transition-colors flex items-center gap-1 ${xe.length>0?"border-bambu-green/50 bg-bambu-green/10 text-bambu-green hover:bg-bambu-green/20":"border-orange-400/50 bg-orange-400/10 text-orange-400 hover:bg-orange-400/20"}`,title:h("maintenance.printersAssignedClick",{count:xe.length}),children:[a.jsx(Cr,{className:"w-3 h-3"}),a.jsx("span",{className:"text-xs font-medium",children:xe.length}),a.jsx(nr,{className:`w-3 h-3 transition-transform ${Ue?"rotate-180":""}`})]}),a.jsx("button",{onClick:()=>W(L),disabled:!d("maintenance:update"),title:d("maintenance:update")?void 0:h("maintenance.noPermissionEditTypes"),className:`p-2 rounded-lg hover:bg-bambu-dark text-bambu-gray hover:text-white transition-colors ${d("maintenance:update")?"":"opacity-50 cursor-not-allowed"}`,children:a.jsx(jf,{className:"w-4 h-4"})}),a.jsx("button",{onClick:()=>{confirm(h("maintenance.deleteTypeConfirm",{name:L.name}))&&s(L.id)},disabled:!d("maintenance:delete"),title:d("maintenance:delete")?void 0:h("maintenance.noPermissionDeleteTypes"),className:`p-2 rounded-lg hover:bg-bambu-dark text-bambu-gray hover:text-red-400 transition-colors ${d("maintenance:delete")?"":"opacity-50 cursor-not-allowed"}`,children:a.jsx(Jt,{className:"w-4 h-4"})})]}),Ue&&a.jsxs("div",{className:"mt-3 pt-3 border-t border-bambu-dark-tertiary",children:[a.jsx("p",{className:"text-xs text-bambu-gray mb-2",children:h("maintenance.assignedToPrinters")}),xe.length===0?a.jsx("p",{className:"text-xs text-orange-400",children:h("maintenance.noPrintersAssigned")}):a.jsx("div",{className:"flex flex-wrap gap-1 mb-2",children:xe.map(Oe=>a.jsxs("span",{className:"inline-flex items-center gap-1 px-2 py-1 bg-bambu-dark rounded text-xs text-white",children:[Oe.printerName,a.jsx("button",{onClick:()=>Oe.itemId&&u(Oe.itemId),disabled:!d("maintenance:delete"),title:d("maintenance:delete")?h("maintenance.removeFromPrinter"):h("maintenance.noPermissionRemovePrinter"),className:`ml-1 ${d("maintenance:delete")?"hover:text-red-400":"opacity-50 cursor-not-allowed"}`,children:"×"})]},Oe.printerId))}),be.length>0&&a.jsxs("div",{className:"flex flex-wrap gap-1",children:[a.jsx("span",{className:"text-xs text-bambu-gray mr-1",children:h("maintenance.addPrinterShort")}),be.map(Oe=>a.jsxs("button",{onClick:()=>c(Oe.id,L.id),disabled:!d("maintenance:create"),title:d("maintenance:create")?void 0:h("maintenance.noPermissionAssignPrinter"),className:`px-2 py-1 bg-bambu-dark rounded text-xs transition-colors ${d("maintenance:create")?"hover:bg-bambu-green/20 text-bambu-gray hover:text-bambu-green":"opacity-50 cursor-not-allowed text-bambu-gray"}`,children:["+ ",Oe.name]},Oe.id))]})]})]},L.id)})]})]}),Ne.length>0&&a.jsxs("div",{children:[a.jsxs("div",{className:"mb-4",children:[a.jsx("h2",{className:"text-lg font-semibold text-white",children:h("maintenance.intervalOverrides")}),a.jsx("p",{className:"text-sm text-bambu-gray mt-1",children:h("maintenance.intervalOverridesDescription")})]}),a.jsx("div",{className:"space-y-4",children:Ne.map(L=>a.jsx(vt,{children:a.jsxs(Nt,{className:"py-4",children:[a.jsx("h3",{className:"text-sm font-medium text-white mb-3",children:L.printerName}),a.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-2",children:L.items.map(D=>{const H=x0(D.maintenance_type_icon),he=e.find(Qe=>Qe.id===D.maintenance_type_id),xe=he?.default_interval_hours||D.interval_hours,be=he?.interval_type||"hours",Ue=D.interval_type||"hours",Oe=f===D.id;return a.jsxs("div",{className:"flex items-center gap-2 p-2.5 bg-bambu-dark rounded-lg",children:[a.jsx(H,{className:"w-4 h-4 text-bambu-gray shrink-0"}),a.jsx("span",{className:"text-xs text-bambu-gray flex-1 truncate",children:D.maintenance_type_name}),Oe?a.jsxs("div",{className:"flex items-center gap-1",children:[b==="days"?a.jsx(ii,{className:"w-3.5 h-3.5 text-bambu-gray shrink-0"}):a.jsx(Iu,{className:"w-3.5 h-3.5 text-bambu-gray shrink-0"}),a.jsxs("select",{value:b,onChange:Qe=>v(Qe.target.value),className:"px-1.5 py-1 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded text-white text-xs",children:[a.jsx("option",{value:"hours",children:h("maintenance.printHours")}),a.jsx("option",{value:"days",children:h("maintenance.calendarDays")})]}),a.jsx("input",{type:"number",value:x,onChange:Qe=>y(Qe.target.value),onKeyDown:Qe=>{Qe.key==="Enter"&&Q(D.id,xe,be),Qe.key==="Escape"&&p(null)},className:"w-16 px-2 py-1 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded text-white text-xs",min:"1"}),a.jsx(Ce,{size:"sm",onClick:()=>Q(D.id,xe,be),children:"OK"})]}):a.jsxs("button",{onClick:()=>{d("maintenance:update")&&(p(D.id),y(D.interval_hours.toString()),v(Ue))},disabled:!d("maintenance:update"),title:d("maintenance:update")?void 0:h("maintenance.noPermissionEditIntervals"),className:`px-2 py-1 bg-bambu-dark-tertiary border border-bambu-dark-tertiary rounded text-xs font-medium text-white transition-colors flex items-center gap-1 ${d("maintenance:update")?"hover:bg-bambu-dark-secondary hover:border-bambu-green":"opacity-50 cursor-not-allowed"}`,children:[Ue==="days"?a.jsx(ii,{className:"w-3 h-3"}):a.jsx(Iu,{className:"w-3 h-3"}),Gj(D.interval_hours,Ue,h),a.jsx(jf,{className:"w-3 h-3 text-bambu-gray"})]})]},D.id)})})]})},L.printerId))})]}),Ne.length===0&&a.jsx(vt,{children:a.jsxs(Nt,{className:"text-center py-12",children:[a.jsx(Wn,{className:"w-12 h-12 mx-auto mb-4 text-bambu-gray/30"}),a.jsx("p",{className:"text-bambu-gray",children:h("common.noPrinters")}),a.jsx("p",{className:"text-sm text-bambu-gray/70 mt-1",children:h("maintenance.intervalOverridesDescription")})]})}),K&&a.jsx(vn,{title:h("maintenance.deleteSystemTypeTitle"),message:h("maintenance.deleteSystemTypeMessage",{name:K.name}),confirmText:h("common.delete"),cancelText:h("common.cancel"),variant:"danger",cancelVariant:"primary",cardClassName:"bg-red-950/70 border border-red-800/70",onConfirm:()=>{s(K.id),Y(null)},onCancel:()=>Y(null)})]})}function LZe(){const{t}=Vt(),e=tn(),{showToast:n}=hn(),{hasPermission:r}=Ir(),[i,s]=w.useState("status"),{data:o,isLoading:l}=Ze({queryKey:["maintenanceOverview"],queryFn:re.getMaintenanceOverview}),{data:c}=Ze({queryKey:["maintenanceTypes"],queryFn:re.getMaintenanceTypes}),u=ot({mutationFn:({id:T,notes:k})=>re.performMaintenance(T,k),onSuccess:()=>{e.invalidateQueries({queryKey:["maintenanceOverview"]}),e.invalidateQueries({queryKey:["maintenanceSummary"]}),n(t("maintenance.maintenanceComplete"))},onError:T=>{n(T.message,"error")}}),d=ot({mutationFn:({id:T,data:k})=>re.updateMaintenanceItem(T,k),onSuccess:()=>{e.invalidateQueries({queryKey:["maintenanceOverview"]})},onError:T=>{n(T.message,"error")}}),h=ot({mutationFn:({id:T,data:k})=>re.updateMaintenanceType(T,k),onSuccess:()=>{e.invalidateQueries({queryKey:["maintenanceTypes"]}),e.invalidateQueries({queryKey:["maintenanceOverview"]}),n(t("maintenance.typeUpdated"))},onError:T=>{n(T.message,"error")}}),f=ot({mutationFn:re.deleteMaintenanceType,onSuccess:()=>{e.invalidateQueries({queryKey:["maintenanceTypes"]}),e.invalidateQueries({queryKey:["maintenanceOverview"]}),n(t("maintenance.typeDeleted"))},onError:T=>{n(T.message,"error")}}),p=ot({mutationFn:re.restoreDefaultMaintenanceTypes,onSuccess:T=>{e.invalidateQueries({queryKey:["maintenanceTypes"]}),e.invalidateQueries({queryKey:["maintenanceOverview"]}),n(t("maintenance.defaultsRestored",{count:T.restored}))},onError:T=>{n(T.message,"error")}}),x=ot({mutationFn:({printerId:T,hours:k})=>re.setPrinterHours(T,k),onSuccess:()=>{e.invalidateQueries({queryKey:["maintenanceOverview"]}),e.invalidateQueries({queryKey:["maintenanceSummary"]}),n(t("maintenance.printHoursUpdated"))},onError:T=>{n(T.message,"error")}}),y=ot({mutationFn:({printerId:T,typeId:k})=>re.assignMaintenanceType(T,k),onSuccess:()=>{e.invalidateQueries({queryKey:["maintenanceOverview"]}),n(t("maintenance.printerAssigned"))},onError:T=>{n(T.message,"error")}}),b=ot({mutationFn:re.removeMaintenanceItem,onSuccess:()=>{e.invalidateQueries({queryKey:["maintenanceOverview"]}),n(t("maintenance.printerRemoved"))},onError:T=>{n(T.message,"error")}}),v=T=>{u.mutate({id:T})},S=(T,k)=>{d.mutate({id:T,data:{enabled:k}})},N=(T,k)=>{x.mutate({printerId:T,hours:k})};if(l)return a.jsx("div",{className:"p-4 md:p-8 flex justify-center",children:a.jsx(it,{className:"w-8 h-8 text-bambu-green animate-spin"})});const A=o?.reduce((T,k)=>T+k.due_count,0)||0,C=o?.reduce((T,k)=>T+k.warning_count,0)||0;return a.jsxs("div",{className:"p-4 md:p-8",children:[a.jsxs("div",{className:"mb-6",children:[a.jsx("h1",{className:"text-2xl font-bold text-white",children:t("maintenance.title")}),a.jsx("p",{className:"text-bambu-gray text-sm mt-1",children:i==="status"?a.jsxs(a.Fragment,{children:[A>0&&a.jsx("span",{className:"text-red-400",children:t("maintenance.dueCount",{count:A})}),A>0&&C>0&&" · ",C>0&&a.jsx("span",{className:"text-amber-400",children:t("maintenance.warningCount",{count:C})}),A===0&&C===0&&a.jsx("span",{className:"text-bambu-green",children:t("maintenance.allOk")})]}):t("maintenance.configureSettings")})]}),a.jsxs("div",{className:"flex gap-1 mb-6 border-b border-bambu-dark-tertiary",children:[a.jsx("button",{onClick:()=>s("status"),className:`px-4 py-2 text-sm font-medium border-b-2 -mb-px transition-colors ${i==="status"?"text-bambu-green border-bambu-green":"text-bambu-gray border-transparent hover:text-white"}`,children:t("maintenance.statusTab")}),a.jsx("button",{onClick:()=>s("settings"),className:`px-4 py-2 text-sm font-medium border-b-2 -mb-px transition-colors ${i==="settings"?"text-bambu-green border-bambu-green":"text-bambu-gray border-transparent hover:text-white"}`,children:t("maintenance.settingsTab")})]}),i==="status"?a.jsx("div",{className:"space-y-6",children:o&&o.length>0?[...o].sort((T,k)=>{const j=T.due_count*10+T.warning_count,E=k.due_count*10+k.warning_count;return j!==E?E-j:T.printer_name.localeCompare(k.printer_name)}).map(T=>a.jsx(RZe,{overview:T,onPerform:v,onToggle:S,onSetHours:N,hasPermission:r,t},T.printer_id)):a.jsx(vt,{children:a.jsxs(Nt,{className:"text-center py-16",children:[a.jsx(Ff,{className:"w-16 h-16 mx-auto mb-4 text-bambu-gray/30"}),a.jsx("p",{className:"text-lg font-medium text-white mb-2",children:t("common.noPrinters")}),a.jsx("p",{className:"text-bambu-gray",children:t("maintenance.configureSettings")})]})})}):a.jsx(FZe,{overview:o,types:c||[],onUpdateInterval:(T,k)=>d.mutate({id:T,data:k}),onAddType:async(T,k)=>{const j=await re.createMaintenanceType(T);for(const E of k)await re.assignMaintenanceType(E,j.id);e.invalidateQueries({queryKey:["maintenanceTypes"]}),e.invalidateQueries({queryKey:["maintenanceOverview"]}),n(t("maintenance.typeUpdated"))},onUpdateType:(T,k)=>h.mutate({id:T,data:k}),onDeleteType:T=>f.mutate(T),onRestoreDefaults:()=>p.mutate(),isRestoringDefaults:p.isPending,onAssignType:(T,k)=>y.mutate({printerId:T,typeId:k}),onRemoveItem:T=>b.mutate(T),hasPermission:r,t})]})}const uK=["#ef4444","#f97316","#eab308","#22c55e","#06b6d4","#3b82f6","#8b5cf6","#ec4899","#6b7280"];function Yae({project:t,onClose:e,onSave:n,isLoading:r,t:i}){const[s,o]=w.useState(t?.name||""),[l,c]=w.useState(t?.description||""),[u,d]=w.useState(t?.color||uK[0]),[h,f]=w.useState(t?.target_count?.toString()||""),[p,x]=w.useState(t?.target_parts_count?.toString()||""),[y,b]=w.useState(t?.status||"active"),[v,S]=w.useState(t?.tags||""),[N,A]=w.useState(t?.due_date?.split("T")[0]||""),[C,T]=w.useState(t?.priority||"normal"),k=j=>{j.preventDefault(),n({name:s.trim(),description:l.trim()||void 0,color:u,target_count:h?parseInt(h,10):void 0,target_parts_count:p?parseInt(p,10):void 0,tags:v.trim()||void 0,due_date:N||void 0,priority:C,...t&&{status:y}})};return a.jsx("div",{className:"fixed inset-0 bg-black/70 flex items-center justify-center z-50 p-4",children:a.jsxs("div",{className:"bg-bambu-dark-secondary rounded-lg w-full max-w-md border border-bambu-dark-tertiary",children:[a.jsx("div",{className:"p-4 border-b border-bambu-dark-tertiary",children:a.jsx("h2",{className:"text-lg font-semibold text-white",children:i(t?"projects.editProject":"projects.newProject")})}),a.jsxs("form",{onSubmit:k,className:"p-4 space-y-4",children:[a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm font-medium text-white mb-1",children:i("common.name")}),a.jsx("input",{type:"text",value:s,onChange:j=>o(j.target.value),className:"w-full bg-bambu-dark border border-bambu-dark-tertiary rounded px-3 py-2 text-white placeholder-bambu-gray focus:outline-none focus:border-bambu-green",placeholder:i("projects.namePlaceholder"),required:!0})]}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm font-medium text-white mb-1",children:i("common.description")}),a.jsx("textarea",{value:l,onChange:j=>c(j.target.value),className:"w-full bg-bambu-dark border border-bambu-dark-tertiary rounded px-3 py-2 text-white placeholder-bambu-gray focus:outline-none focus:border-bambu-green resize-none",placeholder:i("projects.descriptionPlaceholder"),rows:2})]}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm font-medium text-white mb-1",children:i("projects.color")}),a.jsx("div",{className:"flex gap-2 flex-wrap",children:uK.map(j=>a.jsx("button",{type:"button",onClick:()=>d(j),className:`w-8 h-8 rounded-full transition-transform ${u===j?"ring-2 ring-white ring-offset-2 ring-offset-bambu-dark-secondary scale-110":""}`,style:{backgroundColor:j}},j))})]}),a.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm font-medium text-white mb-1",children:i("projects.targetPlates")}),a.jsx("input",{type:"number",value:h,onChange:j=>f(j.target.value),className:"w-full bg-bambu-dark border border-bambu-dark-tertiary rounded px-3 py-2 text-white placeholder-bambu-gray focus:outline-none focus:border-bambu-green",placeholder:i("projects.targetPlatesPlaceholder"),min:"1"}),a.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:i("projects.targetPlatesHelp")})]}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm font-medium text-white mb-1",children:i("projects.targetParts")}),a.jsx("input",{type:"number",value:p,onChange:j=>x(j.target.value),className:"w-full bg-bambu-dark border border-bambu-dark-tertiary rounded px-3 py-2 text-white placeholder-bambu-gray focus:outline-none focus:border-bambu-green",placeholder:i("projects.targetPartsPlaceholder"),min:"1"}),a.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:i("projects.targetPartsHelp")})]})]}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm font-medium text-white mb-1",children:i("projects.tagsLabel")}),a.jsx("input",{type:"text",value:v,onChange:j=>S(j.target.value),className:"w-full bg-bambu-dark border border-bambu-dark-tertiary rounded px-3 py-2 text-white placeholder-bambu-gray focus:outline-none focus:border-bambu-green",placeholder:i("projects.tagsPlaceholder")})]}),a.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm font-medium text-white mb-1",children:i("projects.dueDate")}),a.jsx("input",{type:"date",value:N,onChange:j=>A(j.target.value),className:"w-full bg-bambu-dark border border-bambu-dark-tertiary rounded px-3 py-2 text-white focus:outline-none focus:border-bambu-green"})]}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm font-medium text-white mb-1",children:i("projects.priority")}),a.jsxs("select",{value:C,onChange:j=>T(j.target.value),className:"w-full bg-bambu-dark border border-bambu-dark-tertiary rounded px-3 py-2 text-white focus:outline-none focus:border-bambu-green",children:[a.jsx("option",{value:"low",children:i("projects.priorityLow")}),a.jsx("option",{value:"normal",children:i("projects.priorityNormal")}),a.jsx("option",{value:"high",children:i("projects.priorityHigh")}),a.jsx("option",{value:"urgent",children:i("projects.priorityUrgent")})]})]})]}),t&&a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm font-medium text-white mb-1",children:i("common.status")}),a.jsxs("select",{value:y,onChange:j=>b(j.target.value),className:"w-full bg-bambu-dark border border-bambu-dark-tertiary rounded px-3 py-2 text-white focus:outline-none focus:border-bambu-green",children:[a.jsx("option",{value:"active",children:i("projects.statusActive")}),a.jsx("option",{value:"completed",children:i("projects.statusCompleted")}),a.jsx("option",{value:"archived",children:i("projects.statusArchived")})]})]}),a.jsxs("div",{className:"flex justify-end gap-2 pt-2",children:[a.jsx(Ce,{type:"button",variant:"secondary",onClick:e,children:i("common.cancel")}),a.jsx(Ce,{type:"submit",disabled:!s.trim()||r,children:r?a.jsx(it,{className:"w-4 h-4 animate-spin"}):i(t?"common.save":"projects.create")})]})]})]})})}function OZe({project:t,onClick:e,onEdit:n,onDelete:r,hasPermission:i,t:s}){const o=t.target_count?Math.round(t.archive_count/t.target_count*100):0,l=t.target_parts_count?Math.round(t.completed_count/t.target_parts_count*100):0,c=t.status==="completed",u=t.status==="archived",[d,h]=w.useState(!1),p=c?{icon:fb,color:"text-bambu-green",bg:"bg-bambu-green/10"}:u?{icon:Rs,color:"text-bambu-gray",bg:"bg-bambu-gray/10"}:t.queue_count>0?{icon:Wn,color:"text-blue-400",bg:"bg-blue-400/10"}:{icon:xs,color:"text-bambu-gray",bg:"bg-bambu-gray/10"};return a.jsxs("div",{className:"group relative bg-gradient-to-br from-bambu-card to-bambu-dark-secondary rounded-xl border border-bambu-dark-tertiary hover:border-bambu-green/50 hover:shadow-lg hover:shadow-bambu-green/5 transition-all duration-300 cursor-pointer overflow-hidden",onClick:e,children:[a.jsx("div",{className:"absolute top-0 left-0 w-1.5 h-full",style:{backgroundColor:t.color||"#6b7280",boxShadow:`0 0 12px ${t.color||"#6b7280"}40`}}),a.jsxs("div",{className:"p-5 pl-6",children:[a.jsxs("div",{className:"flex items-start justify-between mb-4",children:[a.jsxs("div",{className:"flex items-center gap-3 min-w-0 flex-1",children:[a.jsx("div",{className:`p-2 rounded-lg ${p.bg} flex-shrink-0`,children:a.jsx(p.icon,{className:`w-5 h-5 ${p.color}`})}),a.jsxs("div",{className:"min-w-0 flex-1",children:[a.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[a.jsx("h3",{className:"font-semibold text-white truncate",children:t.name}),t.target_parts_count?a.jsxs("span",{className:`text-xs px-2 py-0.5 rounded-full whitespace-nowrap font-medium ${l>=100?"bg-bambu-green/20 text-bambu-green":"bg-bambu-dark text-bambu-gray"}`,children:[t.completed_count,"/",t.target_parts_count," ",s("projects.parts")]}):t.target_count?a.jsxs("span",{className:`text-xs px-2 py-0.5 rounded-full whitespace-nowrap font-medium ${o>=100?"bg-bambu-green/20 text-bambu-green":"bg-bambu-dark text-bambu-gray"}`,children:[t.archive_count,"/",t.target_count," ",s("projects.plates")]}):t.completed_count>0?a.jsxs("span",{className:"text-xs px-2 py-0.5 rounded-full whitespace-nowrap font-medium bg-bambu-dark text-bambu-gray",children:[t.completed_count," ",s("projects.parts")]}):null,c&&a.jsx("span",{className:"text-xs bg-bambu-green/20 text-bambu-green px-2 py-0.5 rounded-full whitespace-nowrap",children:s("projects.done")}),u&&a.jsx("span",{className:"text-xs bg-bambu-gray/20 text-bambu-gray px-2 py-0.5 rounded-full whitespace-nowrap",children:s("projects.statusArchived")})]}),t.description&&a.jsx("p",{className:"text-sm text-bambu-gray/70 mt-1 line-clamp-1",children:t.description}),t.archives&&t.archives.length>0&&(()=>{const x=t.archives.map(S=>S.filament_type).filter(Boolean).flatMap(S=>S.split(",").map(N=>N.trim())).filter(Boolean),y=[...new Set(x)],b=t.archives.map(S=>S.filament_color).filter(Boolean).flatMap(S=>S.split(",").map(N=>N.trim())).filter(S=>S.startsWith("#")||/^[0-9A-Fa-f]{6}$/.test(S)),v=[...new Set(b)];return y.length===0&&v.length===0?null:a.jsxs("div",{className:"flex items-center gap-2 mt-1.5",children:[y.slice(0,3).map(S=>a.jsx("span",{className:"text-[10px] px-1.5 py-0.5 bg-bambu-dark text-bambu-gray rounded",children:S},S)),v.length>0&&a.jsxs("div",{className:"flex items-center gap-0.5",children:[v.slice(0,5).map(S=>a.jsx("div",{className:"w-3 h-3 rounded-full border border-white/20",style:{backgroundColor:S.startsWith("#")?S:`#${S}`},title:S},S)),v.length>5&&a.jsxs("span",{className:"text-[10px] text-bambu-gray ml-0.5",children:["+",v.length-5]})]})]})})()]})]}),a.jsxs("div",{className:"relative",onClick:x=>x.stopPropagation(),children:[a.jsx("button",{className:"p-1.5 rounded-lg hover:bg-bambu-dark text-bambu-gray hover:text-white transition-colors opacity-0 group-hover:opacity-100",onClick:()=>h(!d),children:a.jsx(Eh,{className:"w-4 h-4"})}),d&&a.jsxs(a.Fragment,{children:[a.jsx("div",{className:"fixed inset-0 z-10",onClick:()=>h(!1)}),a.jsxs("div",{className:"absolute right-0 top-8 z-20 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg shadow-xl py-1 min-w-[120px]",children:[a.jsxs("button",{className:`w-full px-3 py-2 text-left text-sm flex items-center gap-2 ${i("projects:update")?"text-white hover:bg-bambu-dark":"text-bambu-gray cursor-not-allowed"}`,onClick:()=>{i("projects:update")&&(n(),h(!1))},disabled:!i("projects:update"),title:i("projects:update")?void 0:s("projects.noEditPermission"),children:[a.jsx(jf,{className:"w-4 h-4"}),s("common.edit")]}),a.jsxs("button",{className:`w-full px-3 py-2 text-left text-sm flex items-center gap-2 ${i("projects:delete")?"text-red-400 hover:bg-bambu-dark":"text-bambu-gray cursor-not-allowed"}`,onClick:()=>{i("projects:delete")&&(r(),h(!1))},disabled:!i("projects:delete"),title:i("projects:delete")?void 0:s("projects.noDeletePermission"),children:[a.jsx(Jt,{className:"w-4 h-4"}),s("common.delete")]})]})]})]})]}),a.jsx("div",{className:"mb-4",children:t.target_count||t.target_parts_count?a.jsxs("div",{className:"space-y-3",children:[t.target_count&&a.jsxs("div",{children:[a.jsxs("div",{className:"flex items-center justify-between text-xs mb-1",children:[a.jsx("span",{className:"text-bambu-gray",children:s("projects.plates")}),a.jsxs("span",{className:o>=100?"text-bambu-green font-medium":"text-white",children:[t.archive_count," / ",t.target_count]})]}),a.jsx("div",{className:"h-2 bg-bambu-dark/80 rounded-full overflow-hidden backdrop-blur-sm",children:a.jsx("div",{className:"h-full transition-all duration-500 ease-out rounded-full relative",style:{width:`${Math.min(o,100)}%`,background:o>=100?"linear-gradient(90deg, #22c55e, #4ade80)":`linear-gradient(90deg, ${t.color||"#6b7280"}, ${t.color||"#6b7280"}cc)`,boxShadow:`0 0 8px ${o>=100?"#22c55e":t.color||"#6b7280"}60`}})})]}),t.target_parts_count&&a.jsxs("div",{children:[a.jsxs("div",{className:"flex items-center justify-between text-xs mb-1",children:[a.jsx("span",{className:"text-bambu-gray",children:s("projects.parts")}),a.jsxs("span",{className:l>=100?"text-bambu-green font-medium":"text-white",children:[t.completed_count," / ",t.target_parts_count]})]}),a.jsx("div",{className:"h-2 bg-bambu-dark/80 rounded-full overflow-hidden backdrop-blur-sm",children:a.jsx("div",{className:"h-full transition-all duration-500 ease-out rounded-full relative",style:{width:`${Math.min(l,100)}%`,background:l>=100?"linear-gradient(90deg, #22c55e, #4ade80)":`linear-gradient(90deg, ${t.color||"#6b7280"}, ${t.color||"#6b7280"}cc)`,boxShadow:`0 0 8px ${l>=100?"#22c55e":t.color||"#6b7280"}60`}})})]}),t.failed_count>0&&a.jsxs("div",{className:"text-xs text-red-400",children:[t.failed_count," ",s("projects.failed")]})]}):t.completed_count>0||t.failed_count>0?a.jsxs("div",{className:"flex items-center gap-4 text-xs",children:[t.completed_count>0&&a.jsxs("div",{className:"flex items-center gap-1.5 text-bambu-gray",children:[a.jsx(Rs,{className:"w-3.5 h-3.5"}),a.jsxs("span",{children:[t.completed_count," ",s("projects.completed")]})]}),t.failed_count>0&&a.jsxs("div",{className:"flex items-center gap-1.5 text-red-400",children:[a.jsx(Cn,{className:"w-3.5 h-3.5"}),a.jsxs("span",{children:[t.failed_count," ",s("projects.failed")]})]}),t.queue_count>0&&a.jsxs("div",{className:"flex items-center gap-1.5 text-blue-400",children:[a.jsx(Wn,{className:"w-3.5 h-3.5"}),a.jsxs("span",{children:[t.queue_count," ",s("projects.inQueue")]})]})]}):a.jsx("div",{className:"text-xs text-bambu-gray/60 italic",children:s("projects.noPrintsYet")})}),t.archives&&t.archives.length>0&&a.jsxs("div",{className:"mb-4",children:[a.jsx("div",{className:"grid grid-cols-4 gap-1.5",children:t.archives.slice(0,4).map(x=>a.jsxs("div",{className:"relative aspect-square rounded-lg bg-bambu-dark overflow-hidden border border-bambu-dark-tertiary",title:x.print_name||"Unknown",children:[x.thumbnail_path?a.jsx("img",{src:re.getArchiveThumbnail(x.id),alt:x.print_name||"",className:"w-full h-full object-cover"}):a.jsx("div",{className:"w-full h-full flex items-center justify-center text-bambu-gray/50",children:a.jsx(fa,{className:"w-6 h-6"})}),x.status==="failed"&&a.jsx("div",{className:"absolute inset-0 bg-red-500/40 flex items-center justify-center",children:a.jsx(Cn,{className:"w-4 h-4 text-white"})})]},x.id))}),t.archive_count>4&&a.jsx("p",{className:"text-xs text-bambu-gray mt-1.5 text-center",children:s("common.more",{count:t.archive_count-4})})]}),a.jsxs("div",{className:"flex items-center justify-between pt-3 border-t border-bambu-dark-tertiary",children:[a.jsxs("div",{className:"flex items-center gap-4 text-xs text-bambu-gray",children:[a.jsxs("div",{className:"flex items-center gap-1.5",title:s("projects.printJobs"),children:[a.jsx(ma,{className:"w-3.5 h-3.5 text-blue-400"}),a.jsxs("span",{children:[t.archive_count," ",s("projects.plates")]})]}),a.jsxs("div",{className:"flex items-center gap-1.5",title:s("projects.partsPrinted"),children:[a.jsx(fa,{className:"w-3.5 h-3.5 text-bambu-green"}),a.jsxs("span",{children:[t.completed_count," ",s("projects.parts")]})]}),t.failed_count>0&&a.jsxs("div",{className:"flex items-center gap-1.5 text-red-400",title:s("projects.failedParts"),children:[a.jsx(Cn,{className:"w-3.5 h-3.5"}),a.jsx("span",{children:t.failed_count})]}),t.queue_count>0&&a.jsxs("div",{className:"flex items-center gap-1.5 text-yellow-400",title:s("projects.inQueue"),children:[a.jsx(b3,{className:"w-3.5 h-3.5"}),a.jsx("span",{children:t.queue_count})]})]}),a.jsx(pa,{className:"w-4 h-4 text-bambu-gray/50 group-hover:text-bambu-gray transition-colors"})]})]})]})}function IZe(){const{t}=Vt(),e=$c(),n=tn(),{showToast:r}=hn(),{hasPermission:i}=Ir(),[s,o]=w.useState(!1),[l,c]=w.useState(),[u,d]=w.useState("active"),[h,f]=w.useState(null),{data:p,isLoading:x}=Ze({queryKey:["projects",u==="all"?void 0:u],queryFn:()=>re.getProjects(u==="all"?void 0:u)}),y=ot({mutationFn:B=>re.createProject(B),onSuccess:()=>{n.invalidateQueries({queryKey:["projects"]}),o(!1),r(t("projects.toast.created"),"success")},onError:B=>{r(B.message,"error")}}),b=ot({mutationFn:({id:B,data:R})=>re.updateProject(B,R),onSuccess:()=>{n.invalidateQueries({queryKey:["projects"]}),o(!1),c(void 0),r(t("projects.toast.updated"),"success")},onError:B=>{r(B.message,"error")}}),v=ot({mutationFn:B=>re.deleteProject(B),onSuccess:()=>{f(null),r(t("projects.toast.deleted"),"success"),setTimeout(()=>window.location.reload(),100)},onError:B=>{f(null),r(B.message,"error")}}),S=ot({mutationFn:B=>re.importProject(B),onSuccess:()=>{n.invalidateQueries({queryKey:["projects"]}),r(t("projects.toast.imported"),"success")},onError:B=>{r(B.message,"error")}}),N=w.useRef(null),A=async()=>{try{const B=await re.getProjects(),R=await Promise.all(B.map(async K=>await re.exportProjectJson(K.id))),G=new Blob([JSON.stringify(R,null,2)],{type:"application/json"}),q=URL.createObjectURL(G),z=document.createElement("a");z.href=q,z.download=`bambuddy_projects_${new Date().toISOString().split("T")[0]}.json`,z.click(),URL.revokeObjectURL(q),r(t("projects.toast.exported"),"success")}catch(B){r(B.message,"error")}},C=()=>{N.current?.click()},T=async B=>{const R=B.target.files?.[0];if(R){try{if(R.name.toLowerCase().endsWith(".zip"))await re.importProjectFile(R),n.invalidateQueries({queryKey:["projects"]}),r(t("projects.toast.imported"),"success");else{const q=await R.text(),z=JSON.parse(q),K=Array.isArray(z)?z:[z];for(const Y of K)await S.mutateAsync(Y);K.length>1&&r(t("projects.toast.multipleImported",{count:K.length}),"success")}}catch(G){r(`${t("projects.toast.importFailed")}: ${G.message}`,"error")}B.target.value=""}},k=B=>{l?b.mutate({id:l.id,data:B}):y.mutate(B)},j=B=>{c(B),o(!0)},E=B=>{e(`/projects/${B.id}`)},P=B=>{f(B)},U=()=>{h!==null&&v.mutate(h)},O=p?.reduce((B,R)=>(B[R.status]=(B[R.status]||0)+1,B.all=(B.all||0)+1,B),{})||{};return a.jsxs("div",{className:"p-4 md:p-8 space-y-8",children:[a.jsx("input",{ref:N,type:"file",accept:".json,.zip",onChange:T,className:"hidden"}),a.jsxs("div",{className:"flex flex-col sm:flex-row sm:items-center justify-between gap-4",children:[a.jsxs("div",{children:[a.jsxs("h1",{className:"text-2xl font-bold text-white flex items-center gap-3",children:[a.jsx("div",{className:"p-2.5 bg-bambu-green/10 rounded-xl",children:a.jsx(xs,{className:"w-6 h-6 text-bambu-green"})}),t("projects.title")]}),a.jsx("p",{className:"text-sm text-bambu-gray mt-2 ml-14",children:t("projects.subtitle")})]}),a.jsxs("div",{className:"flex gap-2",children:[a.jsxs(Ce,{variant:"secondary",onClick:C,disabled:!i("projects:create"),title:i("projects:create")?t("projects.importProject"):t("projects.noImportPermission"),children:[a.jsx(Fi,{className:"w-4 h-4 mr-2"}),t("projects.import")]}),a.jsxs(Ce,{variant:"secondary",onClick:A,disabled:!i("projects:read"),title:i("projects:read")?t("projects.exportAll"):t("projects.noExportPermission"),children:[a.jsx(di,{className:"w-4 h-4 mr-2"}),t("projects.export")]}),a.jsxs(Ce,{onClick:()=>o(!0),className:"sm:w-auto w-full",disabled:!i("projects:create"),title:i("projects:create")?void 0:t("projects.noCreatePermission"),children:[a.jsx(ar,{className:"w-4 h-4 mr-2"}),t("projects.newProject")]})]})]}),a.jsx("div",{className:"flex gap-1 p-1 bg-bambu-dark rounded-xl w-fit",children:[{key:"active",label:t("projects.statusActive"),icon:Wn},{key:"completed",label:t("projects.statusCompleted"),icon:fb},{key:"archived",label:t("projects.statusArchived"),icon:Rs},{key:"all",label:t("common.all"),icon:xs}].map(({key:B,label:R,icon:G})=>a.jsxs("button",{onClick:()=>d(B),className:`flex items-center gap-2 px-4 py-2 text-sm rounded-lg transition-all ${u===B?"bg-bambu-card text-white shadow-sm":"text-bambu-gray hover:text-white"}`,children:[a.jsx(G,{className:"w-4 h-4"}),a.jsx("span",{children:R}),O[B]>0&&a.jsx("span",{className:`text-xs px-1.5 py-0.5 rounded-full ${u===B?"bg-bambu-green/20 text-bambu-green":"bg-bambu-dark-tertiary"}`,children:O[B]})]},B))}),x?a.jsx("div",{className:"flex items-center justify-center py-20",children:a.jsxs("div",{className:"flex flex-col items-center gap-3",children:[a.jsx(it,{className:"w-8 h-8 animate-spin text-bambu-green"}),a.jsx("p",{className:"text-sm text-bambu-gray",children:t("projects.loading")})]})}):p?.length===0?a.jsxs("div",{className:"flex flex-col items-center justify-center py-20 px-4",children:[a.jsx("div",{className:"p-4 bg-bambu-dark rounded-2xl mb-4",children:a.jsx(xs,{className:"w-12 h-12 text-bambu-gray/50"})}),a.jsx("h3",{className:"text-lg font-medium text-white mb-2",children:u==="all"?t("projects.noProjects"):t("projects.noProjectsFiltered",{status:u})}),a.jsx("p",{className:"text-bambu-gray text-center max-w-md mb-6",children:u==="all"?t("projects.createFirst"):t("projects.noProjectsFilteredHelp",{status:u})}),u==="all"&&a.jsxs(Ce,{onClick:()=>o(!0),disabled:!i("projects:create"),title:i("projects:create")?void 0:t("projects.noCreatePermission"),children:[a.jsx(ar,{className:"w-4 h-4 mr-2"}),t("projects.createFirstButton")]})]}):a.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 xl:grid-cols-3 gap-8",children:p?.map(B=>a.jsx(OZe,{project:B,onClick:()=>E(B),onEdit:()=>j(B),onDelete:()=>P(B.id),hasPermission:i,t},B.id))}),h!==null&&a.jsx(vn,{title:t("projects.deleteProject"),message:t("projects.deleteConfirm"),confirmText:t("projects.deleteProject"),variant:"danger",onConfirm:U,onCancel:()=>f(null)}),s&&a.jsx(Yae,{project:l,onClose:()=>{o(!1),c(void 0)},onSave:k,isLoading:y.isPending||b.isPending,t})]})}function zZe(t){if(t<1)return`${Math.round(t*60)}m`;const e=Math.floor(t),n=Math.round((t-e)*60);return n>0?`${e}h ${n}m`:`${e}h`}function UZe(t){return t>=1e3?`${(t/1e3).toFixed(2)}kg`:`${Math.round(t)}g`}function BZe({status:t,t:e}){const n={active:"bg-bambu-green/20 text-bambu-green",completed:"bg-blue-500/20 text-blue-400",archived:"bg-bambu-gray/20 text-bambu-gray"},r=n[t]||n.active,i={active:e("projectDetail.status.active"),completed:e("projectDetail.status.completed"),archived:e("projectDetail.status.archived")};return a.jsx("span",{className:`px-2 py-1 rounded text-sm font-medium ${r}`,children:i[t]||t.charAt(0).toUpperCase()+t.slice(1)})}function dK({icon:t,label:e,value:n,subValue:r,hint:i,color:s="text-bambu-gray"}){return a.jsx(vt,{children:a.jsx(Nt,{className:"p-4",children:a.jsxs("div",{className:"flex items-center gap-3",title:i,children:[a.jsx("div",{className:`p-2 rounded-lg bg-bambu-dark ${s}`,children:a.jsx(t,{className:"w-5 h-5"})}),a.jsxs("div",{children:[a.jsx("p",{className:"text-sm text-bambu-gray",children:e}),a.jsx("p",{className:"text-xl font-semibold text-white",children:n}),r&&a.jsx("p",{className:"text-xs text-bambu-gray/70",children:r})]})]})})})}function HZe({archives:t,t:e}){return t.length===0?a.jsxs("div",{className:"text-center py-8 text-bambu-gray",children:[a.jsx(fa,{className:"w-12 h-12 mx-auto mb-2 opacity-50"}),a.jsx("p",{children:e("projectDetail.noPrints")})]}):a.jsx("div",{className:"grid grid-cols-2 sm:grid-cols-3 md:grid-cols-4 lg:grid-cols-5 xl:grid-cols-6 gap-3",children:t.map(n=>a.jsxs(Xs,{to:`/archives?search=${encodeURIComponent(n.print_name||"")}`,className:"group relative aspect-square rounded-lg bg-bambu-dark border border-bambu-dark-tertiary overflow-hidden hover:border-bambu-green transition-colors",children:[n.thumbnail_path?a.jsx("img",{src:re.getArchiveThumbnail(n.id),alt:n.print_name||"Print",className:"w-full h-full object-cover"}):a.jsx("div",{className:"w-full h-full flex items-center justify-center text-bambu-gray",children:a.jsx(fa,{className:"w-8 h-8"})}),n.status==="failed"&&a.jsx("div",{className:"absolute inset-0 bg-red-500/30 flex items-center justify-center",children:a.jsx(ha,{className:"w-8 h-8 text-white"})}),n.status==="completed"&&a.jsx("div",{className:"absolute top-1 right-1",children:a.jsx(gr,{className:"w-4 h-4 text-bambu-green"})}),a.jsx("div",{className:"absolute inset-x-0 bottom-0 bg-gradient-to-t from-black/80 to-transparent p-2 opacity-0 group-hover:opacity-100 transition-opacity",children:a.jsx("p",{className:"text-xs text-white truncate",children:n.print_name||"Unknown"})})]},n.id))})}function $Ze({priority:t,t:e}){const n={low:{color:"bg-gray-500/20 text-gray-400",label:e("projectDetail.priority.low")},normal:{color:"bg-blue-500/20 text-blue-400",label:e("projectDetail.priority.normal")},high:{color:"bg-orange-500/20 text-orange-400",label:e("projectDetail.priority.high")},urgent:{color:"bg-red-500/20 text-red-400",label:e("projectDetail.priority.urgent")}},{color:r,label:i}=n[t]||n.normal;return a.jsxs("span",{className:`px-2 py-1 rounded text-xs font-medium flex items-center gap-1 ${r}`,children:[t==="urgent"&&a.jsx(Cn,{className:"w-3 h-3"}),i]})}function VZe(t){return t?gb(t,{year:"numeric",month:"short",day:"numeric"}):""}function qj(t,e){if(!t)return null;const n=Zi(t);if(!n)return null;const r=new Date,i=Math.ceil((n.getTime()-r.getTime())/(1e3*60*60*24));return i<0?{color:"text-red-400",label:e("projectDetail.dueDate.overdue")}:i===0?{color:"text-orange-400",label:e("projectDetail.dueDate.today")}:i<=3?{color:"text-yellow-400",label:e("projectDetail.dueDate.daysLeft",{count:i})}:{color:"text-bambu-gray",label:e("projectDetail.dueDate.daysLeft",{count:i})}}function GZe(){const{id:t}=Yk(),e=$c(),{t:n}=Vt(),r=tn(),{showToast:i}=hn(),{hasPermission:s}=Ir(),[o,l]=w.useState(!1),[c,u]=w.useState(!1),[d,h]=w.useState(""),f=parseInt(t||"0",10),{data:p,isLoading:x,error:y}=Ze({queryKey:["project",f],queryFn:()=>re.getProject(f),enabled:f>0}),{data:b,isLoading:v}=Ze({queryKey:["project-archives",f],queryFn:()=>re.getProjectArchives(f),enabled:f>0}),{data:S,isLoading:N}=Ze({queryKey:["project-bom",f],queryFn:()=>re.getProjectBOM(f),enabled:f>0}),{data:A,isLoading:C}=Ze({queryKey:["project-timeline",f],queryFn:()=>re.getProjectTimeline(f,20),enabled:f>0}),{data:T}=Ze({queryKey:["settings"],queryFn:re.getSettings}),{data:k}=Ze({queryKey:["project-folders",f],queryFn:()=>re.getLibraryFoldersByProject(f),enabled:f>0}),j=ju(T?.currency||"USD"),E=T?.time_format||"system",P=ot({mutationFn:Me=>re.updateProject(f,Me),onSuccess:()=>{r.invalidateQueries({queryKey:["project",f]}),r.invalidateQueries({queryKey:["projects"]}),l(!1),u(!1),i(n("projectDetail.toast.projectUpdated"),"success")},onError:Me=>{i(Me.message,"error")}}),U=()=>{h(p?.notes||""),u(!0)},O=()=>{P.mutate({notes:d})},B=()=>{u(!1),h("")},[R,G]=w.useState(""),[q,z]=w.useState(1),[K,Y]=w.useState(""),[oe,$]=w.useState(""),[X,ee]=w.useState(""),[J,_e]=w.useState(!1),[pe,me]=w.useState(!1),[je,de]=w.useState(null),[ce,Se]=w.useState(""),[ie,Fe]=w.useState(1),[V,W]=w.useState(""),[ue,Q]=w.useState(""),[se,Z]=w.useState(""),[Ne,ve]=w.useState({isOpen:!1,title:"",message:"",onConfirm:()=>{}}),fe=ot({mutationFn:Me=>re.createBOMItem(f,Me),onSuccess:()=>{r.invalidateQueries({queryKey:["project-bom",f]}),r.invalidateQueries({queryKey:["project",f]}),G(""),z(1),Y(""),$(""),ee(""),_e(!1),i(n("projectDetail.toast.partAdded"),"success")},onError:Me=>i(Me.message,"error")}),L=ot({mutationFn:({itemId:Me,data:$e})=>re.updateBOMItem(f,Me,$e),onSuccess:()=>{r.invalidateQueries({queryKey:["project-bom",f]}),r.invalidateQueries({queryKey:["project",f]}),de(null)},onError:Me=>i(Me.message,"error")}),D=ot({mutationFn:Me=>re.deleteBOMItem(f,Me),onSuccess:()=>{r.invalidateQueries({queryKey:["project-bom",f]}),r.invalidateQueries({queryKey:["project",f]}),i(n("projectDetail.toast.partRemoved"),"success")},onError:Me=>i(Me.message,"error")}),H=Me=>{Me.preventDefault(),R.trim()&&fe.mutate({name:R.trim(),quantity_needed:q,unit_price:K?parseFloat(K):void 0,sourcing_url:oe.trim()||void 0,remarks:X.trim()||void 0})},he=Me=>{const $e=Me.is_complete?0:Me.quantity_needed;L.mutate({itemId:Me.id,data:{quantity_acquired:$e}})},xe=(Me,$e)=>{ve({isOpen:!0,title:n("projectDetail.bom.deletePart"),message:n("projectDetail.bom.deleteConfirm",{name:$e}),onConfirm:()=>{ve(Ae=>({...Ae,isOpen:!1})),D.mutate(Me)}})},be=Me=>{de(Me),Se(Me.name),Fe(Me.quantity_needed),W(Me.unit_price?.toString()||""),Q(Me.sourcing_url||""),Z(Me.remarks||"")},Ue=Me=>{Me.preventDefault(),!(!je||!ce.trim())&&L.mutate({itemId:je.id,data:{name:ce.trim(),quantity_needed:ie,unit_price:V?parseFloat(V):void 0,sourcing_url:ue.trim()||void 0,remarks:se.trim()||void 0}})},Oe=()=>{de(null)},Qe=async()=>{try{const{blob:Me,filename:$e}=await re.exportProjectZip(Number(f)),Ae=URL.createObjectURL(Me),Je=document.createElement("a");Je.href=Ae,Je.download=$e||`${p?.name||"project"}_${new Date().toISOString().split("T")[0]}.zip`,Je.click(),URL.revokeObjectURL(Ae),i(n("projectDetail.toast.projectExported"),"success")}catch(Me){i(Me.message,"error")}},rt=ot({mutationFn:()=>re.createTemplateFromProject(f),onSuccess:()=>{r.invalidateQueries({queryKey:["projects"]}),i(n("projectDetail.toast.templateCreated"),"success")},onError:Me=>i(Me.message,"error")}),we=Me=>Lf(Me,E,{month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"});if(x)return a.jsx("div",{className:"flex items-center justify-center py-24",children:a.jsx(it,{className:"w-8 h-8 animate-spin text-bambu-green"})});if(y||!p)return a.jsxs("div",{className:"text-center py-24",children:[a.jsx("p",{className:"text-bambu-gray",children:y?`${n("common.error")}: ${y.message}`:n("projectDetail.notFound")}),a.jsx(Ce,{variant:"secondary",className:"mt-4",onClick:()=>e("/projects"),children:n("projectDetail.backToProjects")})]});const ye=p.stats,le=ye?.progress_percent??0,Le=ye?.parts_progress_percent??0;return a.jsxs("div",{className:"p-4 md:p-8 space-y-8",children:[a.jsxs("div",{className:"flex items-center gap-2 text-sm text-bambu-gray",children:[a.jsx(Xs,{to:"/projects",className:"hover:text-white transition-colors",children:n("navigation.projects")}),a.jsx(pa,{className:"w-4 h-4"}),a.jsx("span",{className:"text-white",children:p.name})]}),a.jsxs("div",{className:"flex items-start justify-between",children:[a.jsxs("div",{className:"flex items-center gap-4",children:[a.jsx("button",{onClick:()=>e("/projects"),className:"p-2 rounded-lg bg-bambu-card hover:bg-bambu-dark-tertiary transition-colors",children:a.jsx(gde,{className:"w-5 h-5 text-bambu-gray"})}),a.jsxs("div",{className:"flex items-center gap-3",children:[a.jsx("div",{className:"w-4 h-4 rounded-full flex-shrink-0",style:{backgroundColor:p.color||"#6b7280"}}),a.jsxs("div",{children:[a.jsx("h1",{className:"text-2xl font-bold text-white",children:p.name}),p.description&&a.jsx("p",{className:"text-bambu-gray mt-1",children:p.description})]})]}),a.jsx(BZe,{status:p.status,t:n})]}),a.jsxs("div",{className:"flex gap-2",children:[a.jsxs(Ce,{variant:"secondary",onClick:Qe,disabled:!s("projects:read"),title:s("projects:read")?n("projectDetail.exportProject"):n("projectDetail.noExportPermission"),children:[a.jsx(di,{className:"w-4 h-4 mr-2"}),n("projectDetail.export")]}),a.jsxs(Ce,{onClick:()=>l(!0),disabled:!s("projects:update"),title:s("projects:update")?void 0:n("projectDetail.noEditPermission"),children:[a.jsx(jf,{className:"w-4 h-4 mr-2"}),n("common.edit")]})]})]}),(p.target_count||p.target_parts_count)&&a.jsx(vt,{children:a.jsxs(Nt,{className:"p-4 space-y-4",children:[p.target_count&&a.jsxs("div",{children:[a.jsxs("div",{className:"flex items-center justify-between mb-2",children:[a.jsx("span",{className:"text-sm text-bambu-gray",children:n("projectDetail.progress.platesProgress")}),a.jsxs("span",{className:"text-sm font-medium text-white",children:[ye?.total_archives||0," / ",p.target_count," ",n("projectDetail.progress.printJobs")]})]}),a.jsx("div",{className:"h-3 bg-bambu-dark rounded-full overflow-hidden",children:a.jsx("div",{className:"h-full transition-all duration-500",style:{width:`${Math.min(le,100)}%`,backgroundColor:le>=100?"#22c55e":p.color||"#6b7280"}})}),a.jsxs("div",{className:"flex justify-between mt-1",children:[a.jsx("span",{className:"text-xs text-bambu-gray/70",children:n("projectDetail.progress.percentComplete",{percent:le.toFixed(0)})}),ye?.remaining_prints!=null&&ye.remaining_prints>0&&a.jsx("span",{className:"text-xs text-bambu-gray/70",children:n("projectDetail.progress.remaining",{count:ye.remaining_prints})})]})]}),p.target_parts_count&&a.jsxs("div",{children:[a.jsxs("div",{className:"flex items-center justify-between mb-2",children:[a.jsx("span",{className:"text-sm text-bambu-gray",children:n("projectDetail.progress.partsProgress")}),a.jsxs("span",{className:"text-sm font-medium text-white",children:[ye?.completed_prints||0," / ",p.target_parts_count," ",n("projectDetail.progress.parts")]})]}),a.jsx("div",{className:"h-3 bg-bambu-dark rounded-full overflow-hidden",children:a.jsx("div",{className:"h-full transition-all duration-500",style:{width:`${Math.min(Le,100)}%`,backgroundColor:Le>=100?"#22c55e":p.color||"#6b7280"}})}),a.jsxs("div",{className:"flex justify-between mt-1",children:[a.jsx("span",{className:"text-xs text-bambu-gray/70",children:n("projectDetail.progress.percentComplete",{percent:Le.toFixed(0)})}),ye?.remaining_parts!=null&&ye.remaining_parts>0&&a.jsx("span",{className:"text-xs text-bambu-gray/70",children:n("projectDetail.progress.remaining",{count:ye.remaining_parts})})]})]})]})}),ye&&a.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-4",children:[a.jsx(vt,{children:a.jsx(Nt,{className:"p-4",children:a.jsxs("div",{className:"flex items-center gap-3",children:[a.jsx("div",{className:"p-2 rounded-lg bg-bambu-dark text-bambu-green",children:a.jsx(fa,{className:"w-5 h-5"})}),a.jsxs("div",{children:[a.jsx("p",{className:"text-sm text-bambu-gray",children:n("projectDetail.stats.printJobs")}),a.jsxs("p",{className:"text-xl font-semibold text-white",children:[ye.total_archives," ",a.jsx("span",{className:"text-sm font-normal text-bambu-gray",children:n("projectDetail.stats.total")})]}),ye.failed_prints>0&&a.jsx("p",{className:"text-sm text-status-error",children:n("projectDetail.stats.failed",{count:ye.failed_prints})}),a.jsx("p",{className:"text-sm text-bambu-gray",children:n("projectDetail.stats.partsPrinted",{count:ye.completed_prints})})]})]})})}),a.jsx(dK,{icon:Wn,label:n("projectDetail.stats.printTime"),value:zZe(ye.total_print_time_hours),color:"text-yellow-400"}),a.jsx(dK,{icon:Cr,label:n("projectDetail.stats.filamentUsed"),value:UZe(ye.total_filament_grams),color:"text-purple-400"})]}),ye&&(ye.estimated_cost>0||p.budget)&&a.jsx(vt,{children:a.jsxs(Nt,{className:"p-4",children:[a.jsx("h2",{className:"text-lg font-semibold text-white mb-3",children:n("projectDetail.cost.title")}),a.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-4",children:[a.jsxs("div",{children:[a.jsx("p",{className:"text-xs text-bambu-gray uppercase",children:n("projectDetail.cost.filamentCost")}),a.jsxs("p",{className:"text-lg font-semibold text-white",children:[j,ye.estimated_cost.toFixed(2)]})]}),ye.total_energy_kwh>0&&a.jsxs("div",{children:[a.jsx("p",{className:"text-xs text-bambu-gray uppercase",children:n("projectDetail.cost.energy")}),a.jsxs("p",{className:"text-lg font-semibold text-white",children:[ye.total_energy_kwh.toFixed(2)," kWh",ye.total_energy_cost>0&&a.jsxs("span",{className:"text-sm text-bambu-gray ml-1",children:["(",j,ye.total_energy_cost.toFixed(2),")"]})]})]}),p.budget&&a.jsxs(a.Fragment,{children:[a.jsxs("div",{children:[a.jsx("p",{className:"text-xs text-bambu-gray uppercase",children:n("projectDetail.cost.budget")}),a.jsxs("p",{className:"text-lg font-semibold text-white",children:[j,p.budget.toFixed(2)]})]}),a.jsxs("div",{children:[a.jsx("p",{className:"text-xs text-bambu-gray uppercase",children:n("projectDetail.cost.remaining")}),a.jsxs("p",{className:`text-lg font-semibold ${p.budget-ye.estimated_cost>=0?"text-bambu-green":"text-red-400"}`,children:[j,(p.budget-ye.estimated_cost).toFixed(2)]})]})]})]})]})}),p.children&&p.children.length>0&&a.jsx(vt,{children:a.jsxs(Nt,{className:"p-4",children:[a.jsxs("h2",{className:"text-lg font-semibold text-white flex items-center gap-2 mb-3",children:[a.jsx(rme,{className:"w-5 h-5"}),n("projectDetail.subProjects.title",{count:p.children.length})]}),a.jsx("div",{className:"space-y-2",children:p.children.map(Me=>a.jsxs(Xs,{to:`/projects/${Me.id}`,className:"flex items-center justify-between p-3 bg-bambu-dark rounded-lg hover:bg-bambu-dark-tertiary transition-colors",children:[a.jsxs("div",{className:"flex items-center gap-3",children:[a.jsx("div",{className:"w-3 h-3 rounded-full",style:{backgroundColor:Me.color||"#6b7280"}}),a.jsx("span",{className:"text-white",children:Me.name}),a.jsx("span",{className:`text-xs px-2 py-0.5 rounded ${Me.status==="completed"?"bg-status-ok/20 text-status-ok":Me.status==="archived"?"bg-bambu-gray/20 text-bambu-gray":"bg-blue-500/20 text-blue-400"}`,children:Me.status})]}),Me.progress_percent!==null&&a.jsxs("span",{className:"text-sm text-bambu-gray",children:[Me.progress_percent.toFixed(0),"%"]})]},Me.id))})]})}),p.parent_id&&p.parent_name&&a.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[a.jsx(ma,{className:"w-4 h-4 text-bambu-gray"}),a.jsx("span",{className:"text-bambu-gray",children:n("projectDetail.partOf")}),a.jsx(Xs,{to:`/projects/${p.parent_id}`,className:"text-bambu-green hover:underline",children:p.parent_name})]}),(p.tags||p.due_date||p.priority!=="normal")&&a.jsxs("div",{className:"flex flex-wrap items-center gap-4",children:[p.priority&&p.priority!=="normal"&&a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx("span",{className:"text-xs text-bambu-gray uppercase",children:n("projectDetail.priorityLabel")}),a.jsx($Ze,{priority:p.priority,t:n})]}),p.due_date&&a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx(ii,{className:"w-4 h-4 text-bambu-gray"}),a.jsx("span",{className:"text-sm text-white",children:VZe(p.due_date)}),qj(p.due_date,n)&&a.jsxs("span",{className:`text-xs ${qj(p.due_date,n).color}`,children:["(",qj(p.due_date,n).label,")"]})]}),p.tags&&a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx(qh,{className:"w-4 h-4 text-bambu-gray"}),a.jsx("div",{className:"flex flex-wrap gap-1",children:p.tags.split(",").map((Me,$e)=>a.jsx("span",{className:"px-2 py-0.5 bg-bambu-dark-tertiary text-bambu-gray text-xs rounded",children:Me.trim()},$e))})]})]}),a.jsx(vt,{children:a.jsxs(Nt,{className:"p-4",children:[a.jsxs("div",{className:"flex items-center justify-between mb-3",children:[a.jsxs("h2",{className:"text-lg font-semibold text-white flex items-center gap-2",children:[a.jsx(Ps,{className:"w-5 h-5"}),n("projectDetail.notes.title")]}),c?a.jsxs("div",{className:"flex gap-2",children:[a.jsxs(Ce,{variant:"secondary",size:"sm",onClick:B,disabled:P.isPending,children:[a.jsx(Ft,{className:"w-4 h-4 mr-1"}),n("common.cancel")]}),a.jsxs(Ce,{size:"sm",onClick:O,disabled:P.isPending,children:[P.isPending?a.jsx(it,{className:"w-4 h-4 animate-spin mr-1"}):a.jsx(bs,{className:"w-4 h-4 mr-1"}),n("common.save")]})]}):a.jsxs(Ce,{variant:"secondary",size:"sm",onClick:U,disabled:!s("projects:update"),title:s("projects:update")?void 0:n("projectDetail.notes.noEditPermission"),children:[a.jsx(jf,{className:"w-4 h-4 mr-1"}),n("common.edit")]})]}),c?a.jsx(lF,{content:d,onChange:h,placeholder:n("projectDetail.notes.placeholder")}):p.notes?a.jsx("div",{className:"prose prose-invert prose-sm max-w-none",dangerouslySetInnerHTML:{__html:p.notes}}):a.jsx("p",{className:"text-bambu-gray/70 text-sm italic",children:n("projectDetail.notes.empty")})]})}),a.jsx(vt,{children:a.jsxs(Nt,{className:"p-4",children:[a.jsx("div",{className:"flex items-center justify-between mb-3",children:a.jsxs("h2",{className:"text-lg font-semibold text-white flex items-center gap-2",children:[a.jsx(Yl,{className:"w-5 h-5"}),n("projectDetail.files.title")]})}),a.jsxs("p",{className:"text-xs text-bambu-gray mb-3",children:[a.jsx(Xs,{to:"/files",className:"text-bambu-green hover:underline",children:n("projectDetail.files.linkFolders")})," ",n("projectDetail.files.forQuickAccess")]}),k&&k.length>0?a.jsx("div",{className:"space-y-2",children:k.map(Me=>a.jsxs(Xs,{to:`/files?folder=${Me.id}`,className:"flex items-center justify-between p-3 bg-bambu-dark rounded-lg hover:bg-bambu-dark-tertiary transition-colors",children:[a.jsxs("div",{className:"flex items-center gap-3 min-w-0",children:[a.jsx(Yl,{className:"w-5 h-5 text-bambu-green flex-shrink-0"}),a.jsxs("div",{className:"min-w-0",children:[a.jsx("p",{className:"text-sm text-white truncate",children:Me.name}),a.jsx("p",{className:"text-xs text-bambu-gray",children:n("projectDetail.files.fileCount",{count:Me.file_count})})]})]}),a.jsx(pa,{className:"w-4 h-4 text-bambu-gray flex-shrink-0"})]},Me.id))}):a.jsx("p",{className:"text-bambu-gray/70 text-sm italic",children:n("projectDetail.files.empty")})]})}),a.jsx(vt,{children:a.jsxs(Nt,{className:"p-4",children:[a.jsxs("div",{className:"flex items-center justify-between mb-4",children:[a.jsxs("h2",{className:"text-lg font-semibold text-white flex items-center gap-2",children:[a.jsx(xX,{className:"w-5 h-5"}),n("projectDetail.bom.title"),ye&&ye.bom_total_items>0&&a.jsxs("span",{className:"text-sm font-normal text-bambu-gray",children:["(",n("projectDetail.bom.acquired",{completed:ye.bom_completed_items,total:ye.bom_total_items}),")"]})]}),a.jsxs("div",{className:"flex items-center gap-2",children:[S&&S.some(Me=>Me.is_complete)&&a.jsx("button",{onClick:()=>me(!pe),className:`text-xs px-2 py-1 rounded transition-colors ${pe?"bg-bambu-green/20 text-bambu-green":"bg-bambu-dark text-bambu-gray hover:text-white"}`,children:n(pe?"projectDetail.bom.showAll":"projectDetail.bom.hideDone")}),!J&&a.jsxs(Ce,{variant:"secondary",size:"sm",onClick:()=>_e(!0),disabled:!s("projects:update"),title:s("projects:update")?void 0:n("projectDetail.bom.noAddPermission"),children:[a.jsx(ar,{className:"w-4 h-4 mr-1"}),n("projectDetail.bom.addPart")]})]})]}),J&&a.jsxs("form",{onSubmit:H,className:"bg-bambu-dark rounded-lg p-4 mb-4 space-y-3",children:[a.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-3",children:[a.jsx("input",{type:"text",value:R,onChange:Me=>G(Me.target.value),className:"bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded px-3 py-2 text-sm text-white placeholder-bambu-gray focus:outline-none focus:border-bambu-green",placeholder:n("projectDetail.bom.partNamePlaceholder"),autoFocus:!0}),a.jsxs("div",{className:"flex gap-2",children:[a.jsx("input",{type:"number",value:q,onChange:Me=>z(parseInt(Me.target.value)||1),className:"w-20 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded px-3 py-2 text-sm text-white focus:outline-none focus:border-bambu-green",min:"1",placeholder:n("projectDetail.bom.qty")}),a.jsx("input",{type:"number",step:"0.01",value:K,onChange:Me=>Y(Me.target.value),className:"flex-1 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded px-3 py-2 text-sm text-white placeholder-bambu-gray focus:outline-none focus:border-bambu-green",placeholder:n("projectDetail.bom.price",{currency:j})})]})]}),a.jsx("input",{type:"url",value:oe,onChange:Me=>$(Me.target.value),className:"w-full bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded px-3 py-2 text-sm text-white placeholder-bambu-gray focus:outline-none focus:border-bambu-green",placeholder:n("projectDetail.bom.sourcingUrlPlaceholder")}),a.jsx("input",{type:"text",value:X,onChange:Me=>ee(Me.target.value),className:"w-full bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded px-3 py-2 text-sm text-white placeholder-bambu-gray focus:outline-none focus:border-bambu-green",placeholder:n("projectDetail.bom.remarksPlaceholder")}),a.jsxs("div",{className:"flex justify-end gap-2",children:[a.jsx(Ce,{type:"button",variant:"secondary",size:"sm",onClick:()=>_e(!1),children:n("common.cancel")}),a.jsx(Ce,{type:"submit",size:"sm",disabled:!R.trim()||fe.isPending,children:fe.isPending?a.jsx(it,{className:"w-4 h-4 animate-spin"}):n("projectDetail.bom.addPart")})]})]}),N?a.jsx("div",{className:"flex items-center justify-center py-4",children:a.jsx(it,{className:"w-6 h-6 animate-spin text-bambu-green"})}):S&&S.length>0?a.jsxs("div",{className:"space-y-2",children:[S.filter(Me=>!pe||!Me.is_complete).map(Me=>a.jsx("div",{className:`p-3 rounded-lg transition-colors ${Me.is_complete?"bg-status-ok/10":"bg-bambu-dark"}`,children:je?.id===Me.id?a.jsxs("form",{onSubmit:Ue,className:"space-y-3",children:[a.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-3",children:[a.jsx("input",{type:"text",value:ce,onChange:$e=>Se($e.target.value),className:"bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded px-3 py-2 text-sm text-white placeholder-bambu-gray focus:outline-none focus:border-bambu-green",placeholder:n("projectDetail.bom.partName"),autoFocus:!0}),a.jsxs("div",{className:"flex gap-2",children:[a.jsx("input",{type:"number",value:ie,onChange:$e=>Fe(parseInt($e.target.value)||1),className:"w-20 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded px-3 py-2 text-sm text-white focus:outline-none focus:border-bambu-green",min:"1",placeholder:n("projectDetail.bom.qty")}),a.jsx("input",{type:"number",step:"0.01",value:V,onChange:$e=>W($e.target.value),className:"flex-1 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded px-3 py-2 text-sm text-white placeholder-bambu-gray focus:outline-none focus:border-bambu-green",placeholder:n("projectDetail.bom.price",{currency:j})})]})]}),a.jsx("input",{type:"url",value:ue,onChange:$e=>Q($e.target.value),className:"w-full bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded px-3 py-2 text-sm text-white placeholder-bambu-gray focus:outline-none focus:border-bambu-green",placeholder:n("projectDetail.bom.sourcingUrlPlaceholder")}),a.jsx("input",{type:"text",value:se,onChange:$e=>Z($e.target.value),className:"w-full bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded px-3 py-2 text-sm text-white placeholder-bambu-gray focus:outline-none focus:border-bambu-green",placeholder:n("projectDetail.bom.remarksPlaceholder")}),a.jsxs("div",{className:"flex justify-end gap-2",children:[a.jsx(Ce,{type:"button",variant:"secondary",size:"sm",onClick:Oe,children:n("common.cancel")}),a.jsx(Ce,{type:"submit",size:"sm",disabled:!ce.trim()||L.isPending,children:L.isPending?a.jsx(it,{className:"w-4 h-4 animate-spin"}):n("common.save")})]})]}):a.jsxs("div",{className:"flex items-start gap-3",children:[a.jsx("button",{onClick:()=>s("projects:update")&&he(Me),disabled:L.isPending||!s("projects:update"),title:s("projects:update")?void 0:n("projectDetail.bom.noUpdatePermission"),className:`w-5 h-5 mt-0.5 rounded border-2 flex items-center justify-center transition-colors flex-shrink-0 ${Me.is_complete?"bg-status-ok border-status-ok text-white":s("projects:update")?"border-bambu-gray hover:border-bambu-green":"border-bambu-gray/50 cursor-not-allowed"}`,children:Me.is_complete&&a.jsx(gr,{className:"w-3 h-3"})}),a.jsxs("div",{className:"flex-1 min-w-0",children:[a.jsxs("div",{className:"flex items-center justify-between gap-2",children:[a.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[a.jsxs("p",{className:`text-sm font-medium ${Me.is_complete?"text-bambu-gray line-through":"text-white"}`,children:[Me.name,a.jsxs("span",{className:"text-bambu-gray font-normal ml-2",children:["x",Me.quantity_needed]})]}),Me.unit_price!==null&&a.jsxs("span",{className:"text-xs text-bambu-green whitespace-nowrap",children:[j,(Me.unit_price*Me.quantity_needed).toFixed(2)]})]}),a.jsxs("div",{className:"flex items-center gap-1",children:[a.jsx("button",{onClick:()=>s("projects:update")&&be(Me),disabled:!s("projects:update"),className:`p-1 rounded transition-colors flex-shrink-0 ${s("projects:update")?"hover:bg-bambu-dark-tertiary text-bambu-gray hover:text-white":"text-bambu-gray/50 cursor-not-allowed"}`,title:s("projects:update")?n("common.edit"):n("projectDetail.bom.noEditPermission"),children:a.jsx(Vi,{className:"w-4 h-4"})}),a.jsx("button",{onClick:()=>s("projects:update")&&xe(Me.id,Me.name),disabled:!s("projects:update"),className:`p-1 rounded transition-colors flex-shrink-0 ${s("projects:update")?"hover:bg-bambu-dark-tertiary text-bambu-gray hover:text-red-400":"text-bambu-gray/50 cursor-not-allowed"}`,title:s("projects:update")?n("common.delete"):n("projectDetail.bom.noDeletePermission"),children:a.jsx(Jt,{className:"w-4 h-4"})})]})]}),Me.sourcing_url&&a.jsxs("a",{href:Me.sourcing_url,target:"_blank",rel:"noopener noreferrer",className:"flex items-center gap-1 mt-1 text-xs text-blue-400 hover:text-blue-300 transition-colors",onClick:$e=>$e.stopPropagation(),children:[a.jsx(Kr,{className:"w-3 h-3 flex-shrink-0"}),a.jsx("span",{className:"truncate",children:(()=>{try{return new URL(Me.sourcing_url).hostname.replace("www.","")}catch{return Me.sourcing_url}})()})]}),Me.remarks&&a.jsx("p",{className:"mt-1 text-xs text-bambu-gray/80 italic",children:Me.remarks})]})]})},Me.id)),S.some(Me=>Me.unit_price!==null)&&a.jsxs("div",{className:"pt-2 mt-2 border-t border-bambu-dark-tertiary flex justify-between text-sm",children:[a.jsx("span",{className:"text-bambu-gray",children:n("projectDetail.bom.totalCost")}),a.jsxs("span",{className:"text-white font-medium",children:[j,S.reduce((Me,$e)=>Me+($e.unit_price||0)*$e.quantity_needed,0).toFixed(2)]})]})]}):a.jsx("p",{className:"text-bambu-gray/70 text-sm italic",children:n("projectDetail.bom.empty")})]})}),a.jsx(vt,{children:a.jsxs(Nt,{className:"p-4",children:[a.jsx("div",{className:"flex items-center justify-between mb-3",children:a.jsxs("h2",{className:"text-lg font-semibold text-white flex items-center gap-2",children:[a.jsx(N0,{className:"w-5 h-5"}),n("projectDetail.timeline.title")]})}),C?a.jsx("div",{className:"flex items-center justify-center py-4",children:a.jsx(it,{className:"w-6 h-6 animate-spin text-bambu-green"})}):A&&A.length>0?a.jsx("div",{className:"space-y-3",children:A.slice(0,10).map((Me,$e)=>a.jsxs("div",{className:"flex gap-3",children:[a.jsxs("div",{className:`w-8 h-8 rounded-full flex items-center justify-center flex-shrink-0 ${Me.event_type==="print_completed"?"bg-status-ok/20 text-status-ok":Me.event_type==="print_failed"?"bg-status-error/20 text-status-error":Me.event_type==="print_started"?"bg-yellow-500/20 text-yellow-400":"bg-bambu-dark-tertiary text-bambu-gray"}`,children:[Me.event_type==="print_completed"&&a.jsx(gr,{className:"w-4 h-4"}),Me.event_type==="print_failed"&&a.jsx(ha,{className:"w-4 h-4"}),Me.event_type==="print_started"&&a.jsx(Cr,{className:"w-4 h-4"}),Me.event_type==="queued"&&a.jsx(b3,{className:"w-4 h-4"}),Me.event_type==="project_created"&&a.jsx(ar,{className:"w-4 h-4"})]}),a.jsxs("div",{className:"flex-1 min-w-0",children:[a.jsx("p",{className:"text-sm text-white",children:Me.title}),Me.description&&a.jsx("p",{className:"text-xs text-bambu-gray truncate",children:Me.description}),a.jsx("p",{className:"text-xs text-bambu-gray/70",children:we(Me.timestamp)})]})]},$e))}):a.jsx("p",{className:"text-bambu-gray/70 text-sm italic",children:n("projectDetail.timeline.empty")})]})}),!p.is_template&&a.jsx("div",{className:"flex justify-end",children:a.jsxs(Ce,{variant:"secondary",size:"sm",onClick:()=>rt.mutate(),disabled:rt.isPending||!s("projects:create"),title:s("projects:create")?void 0:n("projectDetail.template.noCreatePermission"),children:[rt.isPending?a.jsx(it,{className:"w-4 h-4 animate-spin mr-2"}):a.jsx(Kl,{className:"w-4 h-4 mr-2"}),n("projectDetail.template.saveAsTemplate")]})}),ye&&(ye.queued_prints>0||ye.in_progress_prints>0)&&a.jsx(vt,{children:a.jsxs(Nt,{className:"p-4",children:[a.jsxs("div",{className:"flex items-center justify-between mb-3",children:[a.jsxs("h2",{className:"text-lg font-semibold text-white flex items-center gap-2",children:[a.jsx(b3,{className:"w-5 h-5"}),n("projectDetail.queue.title")]}),a.jsx(Xs,{to:`/queue?project=${f}`,className:"text-sm text-bambu-green hover:underline",children:n("projectDetail.queue.viewAll")})]}),a.jsxs("div",{className:"flex items-center gap-4 text-sm",children:[ye.in_progress_prints>0&&a.jsx("span",{className:"text-yellow-400",children:n("projectDetail.queue.printing",{count:ye.in_progress_prints})}),ye.queued_prints>0&&a.jsx("span",{className:"text-bambu-gray",children:n("projectDetail.queue.queued",{count:ye.queued_prints})})]})]})}),a.jsxs("div",{children:[a.jsx("div",{className:"flex items-center justify-between mb-4",children:a.jsxs("h2",{className:"text-lg font-semibold text-white flex items-center gap-2",children:[a.jsx(fa,{className:"w-5 h-5"}),n("projectDetail.prints.title",{count:b?.length||0})]})}),v?a.jsx("div",{className:"flex items-center justify-center py-8",children:a.jsx(it,{className:"w-6 h-6 animate-spin text-bambu-green"})}):a.jsx(HZe,{archives:b||[],t:n})]}),o&&a.jsx(Yae,{t:n,project:{...p,archive_count:ye?.total_archives||0,total_items:ye?.total_items||0,completed_count:ye?.completed_prints||0,failed_count:ye?.failed_prints||0,queue_count:ye?.queued_prints||0,progress_percent:ye?.progress_percent||null,archives:[]},onClose:()=>l(!1),onSave:Me=>P.mutate(Me),isLoading:P.isPending}),Ne.isOpen&&a.jsx(vn,{title:Ne.title,message:Ne.message,confirmText:n("common.delete"),variant:"danger",onConfirm:Ne.onConfirm,onCancel:()=>ve(Me=>({...Me,isOpen:!1}))})]})}function Bg(t){return t<1024?`${t} B`:t<1024*1024?`${(t/1024).toFixed(1)} KB`:t<1024*1024*1024?`${(t/(1024*1024)).toFixed(1)} MB`:`${(t/(1024*1024*1024)).toFixed(2)} GB`}function qZe({parentId:t,onClose:e,onSave:n,isLoading:r,t:i}){const[s,o]=w.useState(""),l=c=>{c.preventDefault(),n({name:s.trim(),parent_id:t})};return a.jsx("div",{className:"fixed inset-0 bg-black/70 flex items-center justify-center z-50 p-4",children:a.jsxs("div",{className:"bg-bambu-dark-secondary rounded-lg w-full max-w-sm border border-bambu-dark-tertiary",children:[a.jsx("div",{className:"p-4 border-b border-bambu-dark-tertiary",children:a.jsx("h2",{className:"text-lg font-semibold text-white",children:i("fileManager.newFolder")})}),a.jsxs("form",{onSubmit:l,className:"p-4 space-y-4",children:[a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm font-medium text-white mb-1",children:i("fileManager.folderName")}),a.jsx("input",{type:"text",value:s,onChange:c=>o(c.target.value),className:"w-full bg-bambu-dark border border-bambu-dark-tertiary rounded px-3 py-2 text-white placeholder-bambu-gray focus:outline-none focus:border-bambu-green",placeholder:i("fileManager.folderNamePlaceholder"),autoFocus:!0,required:!0})]}),a.jsxs("div",{className:"flex justify-end gap-2 pt-2",children:[a.jsx(Ce,{type:"button",variant:"secondary",onClick:e,children:i("common.cancel")}),a.jsx(Ce,{type:"submit",disabled:!s.trim()||r,children:r?a.jsx(it,{className:"w-4 h-4 animate-spin"}):i("common.create")})]})]})]})})}function WZe({type:t,currentName:e,onClose:n,onSave:r,isLoading:i,t:s}){const[o,l]=w.useState(e),c=u=>{u.preventDefault(),o.trim()&&o.trim()!==e&&r(o.trim())};return a.jsx("div",{className:"fixed inset-0 bg-black/70 flex items-center justify-center z-50 p-4",children:a.jsxs("div",{className:"bg-bambu-dark-secondary rounded-lg w-full max-w-sm border border-bambu-dark-tertiary",children:[a.jsx("div",{className:"p-4 border-b border-bambu-dark-tertiary",children:a.jsx("h2",{className:"text-lg font-semibold text-white",children:s(t==="file"?"fileManager.renameFile":"fileManager.renameFolder")})}),a.jsxs("form",{onSubmit:c,className:"p-4 space-y-4",children:[a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm font-medium text-white mb-1",children:s("common.name")}),a.jsx("input",{type:"text",value:o,onChange:u=>l(u.target.value),className:"w-full bg-bambu-dark border border-bambu-dark-tertiary rounded px-3 py-2 text-white placeholder-bambu-gray focus:outline-none focus:border-bambu-green",autoFocus:!0,required:!0})]}),a.jsxs("div",{className:"flex justify-end gap-2 pt-2",children:[a.jsx(Ce,{type:"button",variant:"secondary",onClick:n,children:s("common.cancel")}),a.jsx(Ce,{type:"submit",disabled:!o.trim()||o.trim()===e||i,children:i?a.jsx(it,{className:"w-4 h-4 animate-spin"}):s("common.rename")})]})]})]})})}function KZe({folders:t,selectedFiles:e,currentFolderId:n,onClose:r,onMove:i,isLoading:s,t:o}){const[l,c]=w.useState(null),u=(h,f=0)=>{const p=[];for(const x of h)p.push({id:x.id,name:x.name,depth:f}),x.children.length>0&&p.push(...u(x.children,f+1));return p},d=[{id:null,name:o("fileManager.rootNoFolder"),depth:0},...u(t)];return a.jsx("div",{className:"fixed inset-0 bg-black/70 flex items-center justify-center z-50 p-4",children:a.jsxs("div",{className:"bg-bambu-dark-secondary rounded-lg w-full max-w-sm border border-bambu-dark-tertiary",children:[a.jsx("div",{className:"p-4 border-b border-bambu-dark-tertiary",children:a.jsx("h2",{className:"text-lg font-semibold text-white",children:o("fileManager.moveFiles",{count:e.length})})}),a.jsxs("div",{className:"p-4 space-y-4",children:[a.jsx("div",{className:"max-h-64 overflow-y-auto space-y-1",children:d.map(h=>a.jsxs("button",{onClick:()=>c(h.id),disabled:h.id===n,className:`w-full text-left px-3 py-2 rounded transition-colors flex items-center gap-2 ${l===h.id?"bg-bambu-green/20 text-bambu-green":h.id===n?"opacity-50 cursor-not-allowed text-bambu-gray":"hover:bg-bambu-dark text-white"}`,style:{paddingLeft:`${12+h.depth*16}px`},children:[a.jsx(Yl,{className:"w-4 h-4"}),h.name,h.id===n&&a.jsxs("span",{className:"text-xs text-bambu-gray ml-auto",children:["(",o("fileManager.current"),")"]})]},h.id??"root"))}),a.jsxs("div",{className:"flex justify-end gap-2 pt-2",children:[a.jsx(Ce,{type:"button",variant:"secondary",onClick:r,children:o("common.cancel")}),a.jsx(Ce,{onClick:()=>i(l),disabled:s,children:s?a.jsx(it,{className:"w-4 h-4 animate-spin"}):o("common.move")})]})]})]})})}function XZe({folder:t,onClose:e,onLink:n,isLoading:r,t:i}){const[s,o]=w.useState("project"),[l,c]=w.useState(t.project_id||t.archive_id||null);w.useState(()=>{t.archive_id&&o("archive")});const{data:u}=Ze({queryKey:["projects"],queryFn:()=>re.getProjects()}),{data:d}=Ze({queryKey:["archives-for-link"],queryFn:()=>re.getArchives(void 0,void 0,100)}),h=()=>{n(s==="project"?{project_id:l,archive_id:0}:{project_id:0,archive_id:l})},f=()=>{n({project_id:0,archive_id:0})},p=t.project_id||t.archive_id;return a.jsx("div",{className:"fixed inset-0 bg-black/70 flex items-center justify-center z-50 p-4",children:a.jsxs("div",{className:"bg-bambu-dark-secondary rounded-lg w-full max-w-md border border-bambu-dark-tertiary",children:[a.jsxs("div",{className:"p-4 border-b border-bambu-dark-tertiary flex items-center justify-between",children:[a.jsxs("h2",{className:"text-lg font-semibold text-white flex items-center gap-2",children:[a.jsx(Rh,{className:"w-5 h-5 text-bambu-green"}),i("fileManager.linkFolder")]}),a.jsx("button",{onClick:e,className:"p-1 hover:bg-bambu-dark rounded",children:a.jsx(Ft,{className:"w-5 h-5 text-bambu-gray"})})]}),a.jsxs("div",{className:"p-4 space-y-4",children:[a.jsx("p",{className:"text-sm text-bambu-gray",children:i("fileManager.linkFolderDescription",{name:t.name})}),a.jsxs("div",{className:"flex gap-2",children:[a.jsxs("button",{onClick:()=>{o("project"),c(null)},className:`flex-1 flex items-center justify-center gap-2 px-3 py-2 rounded-lg border transition-colors ${s==="project"?"border-bambu-green bg-bambu-green/10 text-bambu-green":"border-bambu-dark-tertiary text-bambu-gray hover:text-white"}`,children:[a.jsx(lX,{className:"w-4 h-4"}),i("fileManager.project")]}),a.jsxs("button",{onClick:()=>{o("archive"),c(null)},className:`flex-1 flex items-center justify-center gap-2 px-3 py-2 rounded-lg border transition-colors ${s==="archive"?"border-bambu-green bg-bambu-green/10 text-bambu-green":"border-bambu-dark-tertiary text-bambu-gray hover:text-white"}`,children:[a.jsx(Rs,{className:"w-4 h-4"}),i("fileManager.archive")]})]}),a.jsx("div",{className:"max-h-64 overflow-y-auto space-y-1 bg-bambu-dark rounded-lg p-2",children:s==="project"?u&&u.length>0?u.map(x=>a.jsxs("button",{onClick:()=>c(x.id),className:`w-full text-left px-3 py-2 rounded transition-colors flex items-center gap-2 ${l===x.id?"bg-bambu-green/20 text-bambu-green":"hover:bg-bambu-dark-tertiary text-white"}`,children:[a.jsx("div",{className:"w-3 h-3 rounded-full flex-shrink-0",style:{backgroundColor:x.color||"#00ae42"}}),a.jsx("span",{className:"truncate",children:x.name})]},x.id)):a.jsx("p",{className:"text-sm text-bambu-gray text-center py-4",children:i("fileManager.noProjectsFound")}):d&&d.length>0?d.map(x=>a.jsxs("button",{onClick:()=>c(x.id),className:`w-full text-left px-3 py-2 rounded transition-colors flex items-center gap-2 ${l===x.id?"bg-bambu-green/20 text-bambu-green":"hover:bg-bambu-dark-tertiary text-white"}`,children:[a.jsx(pf,{className:"w-4 h-4 text-bambu-gray flex-shrink-0"}),a.jsx("span",{className:"truncate",children:x.print_name||x.filename})]},x.id)):a.jsx("p",{className:"text-sm text-bambu-gray text-center py-4",children:i("fileManager.noArchivesFound")})})]}),a.jsxs("div",{className:"p-4 border-t border-bambu-dark-tertiary flex justify-between",children:[p&&a.jsxs(Ce,{variant:"danger",onClick:f,disabled:r,children:[a.jsx(dC,{className:"w-4 h-4 mr-2"}),i("fileManager.unlink")]}),a.jsxs("div",{className:`flex gap-2 ${p?"":"ml-auto"}`,children:[a.jsx(Ce,{variant:"secondary",onClick:e,children:i("common.cancel")}),a.jsx(Ce,{onClick:h,disabled:!l||r,children:r?a.jsx(it,{className:"w-4 h-4 animate-spin"}):i("fileManager.link")})]})]})]})})}function YZe({folderId:t,onClose:e,onUploadComplete:n,t:r}){const[i,s]=w.useState([]),[o,l]=w.useState(!1),[c,u]=w.useState(!1),[d,h]=w.useState(!0),[f,p]=w.useState(!1),[x,y]=w.useState(!0),b=w.useRef(null),v=G=>{G.preventDefault(),l(!0)},S=G=>{G.preventDefault(),l(!1)},N=G=>{G.preventDefault(),l(!1);const q=Array.from(G.dataTransfer.files);C(q)},A=G=>{G.target.files&&C(Array.from(G.target.files))},C=G=>{const q=G.map(z=>({file:z,status:"pending",isZip:z.name.toLowerCase().endsWith(".zip"),is3mf:z.name.toLowerCase().endsWith(".3mf")}));s(z=>[...z,...q])},T=G=>{s(q=>q.filter((z,K)=>K!==G))},k=i.some(G=>G.isZip&&G.status==="pending"),j=i.some(G=>G.file.name.toLowerCase().endsWith(".stl")&&G.status==="pending"),E=i.some(G=>G.is3mf&&G.status==="pending"),P=async()=>{if(i.length!==0){u(!0);for(let G=0;Gq.map((z,K)=>K===G?{...z,status:"uploading"}:z));try{if(i[G].isZip){const q=await re.extractZipFile(i[G].file,t,d,f,x);s(z=>z.map((K,Y)=>Y===G?{...K,status:q.errors.length>0&&q.extracted===0?"error":"success",extractedCount:q.extracted,error:q.errors.length>0?`${q.errors.length} files failed`:void 0}:K))}else await re.uploadLibraryFile(i[G].file,t,x),s(q=>q.map((z,K)=>K===G?{...z,status:"success"}:z))}catch(q){s(z=>z.map((K,Y)=>Y===G?{...K,status:"error",error:q instanceof Error?q.message:"Upload failed"}:K))}}u(!1),n(),e()}},U=i.filter(G=>G.status==="pending").length,O=i.filter(G=>G.status==="success").length,B=i.filter(G=>G.status==="error").length,R=i.length>0&&U===0&&!c;return a.jsx("div",{className:"fixed inset-0 bg-black/70 flex items-center justify-center z-50 p-4",children:a.jsxs("div",{className:"bg-bambu-dark-secondary rounded-lg w-full max-w-lg border border-bambu-dark-tertiary",children:[a.jsxs("div",{className:"p-4 border-b border-bambu-dark-tertiary flex items-center justify-between",children:[a.jsx("h2",{className:"text-lg font-semibold text-white",children:r("fileManager.uploadFiles")}),a.jsx("button",{onClick:e,className:"p-1 hover:bg-bambu-dark rounded",children:a.jsx(Ft,{className:"w-5 h-5 text-bambu-gray"})})]}),a.jsxs("div",{className:"p-4 space-y-4",children:[a.jsxs("div",{onDragOver:v,onDragLeave:S,onDrop:N,onClick:()=>b.current?.click(),className:`border-2 border-dashed rounded-lg p-8 text-center cursor-pointer transition-colors ${o?"border-bambu-green bg-bambu-green/10":"border-bambu-dark-tertiary hover:border-bambu-green/50"}`,children:[a.jsx(Fi,{className:`w-10 h-10 mx-auto mb-3 ${o?"text-bambu-green":"text-bambu-gray"}`}),a.jsx("p",{className:"text-white font-medium",children:r(o?"fileManager.dropFilesHere":"fileManager.dragDropFiles")}),a.jsx("p",{className:"text-sm text-bambu-gray mt-1",children:r("fileManager.orClickToBrowse")}),a.jsx("p",{className:"text-xs text-bambu-gray/70 mt-2",children:r("fileManager.allFileTypesSupported")})]}),a.jsx("input",{ref:b,type:"file",multiple:!0,className:"hidden",onChange:A}),k&&a.jsx("div",{className:"p-3 bg-blue-500/10 border border-blue-500/30 rounded-lg",children:a.jsxs("div",{className:"flex items-start gap-3",children:[a.jsx(Rs,{className:"w-5 h-5 text-blue-400 mt-0.5 flex-shrink-0"}),a.jsxs("div",{className:"flex-1",children:[a.jsx("p",{className:"text-sm text-blue-300 font-medium",children:r("fileManager.zipFilesDetected")}),a.jsx("p",{className:"text-xs text-blue-300/70 mt-1",children:r("fileManager.zipExtractOptions")}),a.jsxs("label",{className:"flex items-center gap-2 mt-2 cursor-pointer",children:[a.jsx("input",{type:"checkbox",checked:d,onChange:G=>h(G.target.checked),className:"w-4 h-4 rounded border-bambu-dark-tertiary bg-bambu-dark text-bambu-green focus:ring-bambu-green"}),a.jsx("span",{className:"text-sm text-white",children:r("fileManager.preserveZipStructure")})]}),a.jsxs("label",{className:"flex items-center gap-2 mt-2 cursor-pointer",children:[a.jsx("input",{type:"checkbox",checked:f,onChange:G=>p(G.target.checked),className:"w-4 h-4 rounded border-bambu-dark-tertiary bg-bambu-dark text-bambu-green focus:ring-bambu-green"}),a.jsx("span",{className:"text-sm text-white",children:r("fileManager.createFolderFromZip")})]})]})]})}),E&&a.jsx("div",{className:"p-3 bg-purple-500/10 border border-purple-500/30 rounded-lg",children:a.jsxs("div",{className:"flex items-start gap-3",children:[a.jsx(Cr,{className:"w-5 h-5 text-purple-400 mt-0.5 flex-shrink-0"}),a.jsxs("div",{className:"flex-1",children:[a.jsx("p",{className:"text-sm text-purple-300 font-medium",children:r("fileManager.threemfDetected")}),a.jsx("p",{className:"text-xs text-purple-300/70 mt-1",children:r("fileManager.threemfExtractionInfo")})]})]})}),(j||k)&&a.jsx("div",{className:"p-3 bg-bambu-green/10 border border-bambu-green/30 rounded-lg",children:a.jsxs("div",{className:"flex items-start gap-3",children:[a.jsx(td,{className:"w-5 h-5 text-bambu-green mt-0.5 flex-shrink-0"}),a.jsxs("div",{className:"flex-1",children:[a.jsx("p",{className:"text-sm text-bambu-green font-medium",children:r("fileManager.stlThumbnailGeneration")}),a.jsx("p",{className:"text-xs text-bambu-green/70 mt-1",children:r(k&&!j?"fileManager.zipMayContainStl":"fileManager.thumbnailsCanBeGenerated")}),a.jsxs("label",{className:"flex items-center gap-2 mt-2 cursor-pointer",children:[a.jsx("input",{type:"checkbox",checked:x,onChange:G=>y(G.target.checked),className:"w-4 h-4 rounded border-bambu-dark-tertiary bg-bambu-dark text-bambu-green focus:ring-bambu-green"}),a.jsx("span",{className:"text-sm text-white",children:r("fileManager.generateThumbnailsForStl")})]})]})]})}),i.length>0&&a.jsx("div",{className:"max-h-48 overflow-y-auto space-y-2",children:i.map((G,q)=>a.jsxs("div",{className:"flex items-center gap-3 p-2 bg-bambu-dark rounded-lg",children:[G.isZip?a.jsx(Rs,{className:"w-4 h-4 text-blue-400 flex-shrink-0"}):a.jsx(eC,{className:"w-4 h-4 text-bambu-gray flex-shrink-0"}),a.jsxs("div",{className:"flex-1 min-w-0",children:[a.jsx("p",{className:"text-sm text-white truncate",children:G.file.name}),a.jsxs("p",{className:"text-xs text-bambu-gray",children:[(G.file.size/1024/1024).toFixed(2)," MB",G.isZip&&G.status==="pending"&&a.jsxs("span",{className:"text-blue-400 ml-2",children:["• ",r("fileManager.willBeExtracted")]}),G.extractedCount!==void 0&&a.jsxs("span",{className:"text-green-400 ml-2",children:["• ",r("fileManager.filesExtracted",{count:G.extractedCount})]})]})]}),G.status==="pending"&&a.jsx("button",{onClick:()=>T(q),className:"p-1 hover:bg-bambu-dark-tertiary rounded",children:a.jsx(Ft,{className:"w-4 h-4 text-bambu-gray"})}),G.status==="uploading"&&a.jsx(it,{className:"w-4 h-4 text-bambu-green animate-spin"}),G.status==="success"&&a.jsx(gr,{className:"w-4 h-4 text-green-500"}),G.status==="error"&&a.jsx("span",{title:G.error,children:a.jsx(ha,{className:"w-4 h-4 text-red-500"})})]},q))}),R&&a.jsx("div",{className:"p-3 bg-bambu-dark rounded-lg",children:a.jsxs("p",{className:"text-sm text-white",children:[r("fileManager.uploadComplete",{succeeded:O}),B>0&&a.jsxs("span",{className:"text-red-400",children:[", ",r("fileManager.uploadFailed",{count:B})]})]})})]}),a.jsxs("div",{className:"p-4 border-t border-bambu-dark-tertiary flex justify-end gap-2",children:[a.jsx(Ce,{variant:"secondary",onClick:e,children:r(R?"common.close":"common.cancel")}),!R&&a.jsx(Ce,{onClick:P,disabled:U===0||c,children:c?a.jsxs(a.Fragment,{children:[a.jsx(it,{className:"w-4 h-4 mr-2 animate-spin"}),r("fileManager.uploading")]}):a.jsxs(a.Fragment,{children:[a.jsx(Fi,{className:"w-4 h-4 mr-2"}),r("common.upload")," ",U>0?`(${U})`:""]})})]})]})})}function Qae({folder:t,selectedFolderId:e,onSelect:n,onDelete:r,onLink:i,onRename:s,depth:o=0,wrapNames:l=!1,hasPermission:c,t:u}){const[d,h]=w.useState(!0),[f,p]=w.useState(!1),x=t.children.length>0,y=t.project_id||t.archive_id;return a.jsxs("div",{children:[a.jsxs("div",{className:`group flex items-center gap-1 px-2 py-1.5 rounded cursor-pointer transition-colors ${e===t.id?"bg-bambu-green/20 text-bambu-green":"hover:bg-bambu-dark text-white"}`,style:{paddingLeft:`${8+o*12}px`},onClick:()=>n(t.id),children:[x?a.jsx("button",{onClick:b=>{b.stopPropagation(),h(!d)},className:"p-0.5 hover:bg-bambu-dark-tertiary rounded",children:a.jsx(pa,{className:`w-3.5 h-3.5 transition-transform ${d?"rotate-90":""}`})}):a.jsx("div",{className:"w-4.5"}),a.jsx(Yl,{className:"w-4 h-4 text-bambu-green flex-shrink-0"}),a.jsx("span",{className:`text-sm flex-1 min-w-0 ${l?"break-all":"truncate"}`,title:t.name,children:t.name}),y&&a.jsxs("button",{onClick:b=>{b.stopPropagation(),i(t)},className:"flex-shrink-0 flex items-center gap-1 text-xs px-1.5 py-0.5 rounded bg-blue-500/20 text-blue-400 hover:bg-blue-500/30 transition-colors",title:`${t.project_name?`Project: ${t.project_name}`:`Archive: ${t.archive_name}`} (click to change)`,children:[a.jsx(Rh,{className:"w-3 h-3"}),t.project_name?a.jsx(lX,{className:"w-3 h-3"}):a.jsx(Rs,{className:"w-3 h-3"})]}),t.file_count>0&&a.jsx("span",{className:"flex-shrink-0 text-xs text-bambu-gray",children:t.file_count}),!y&&a.jsx("button",{onClick:b=>{b.stopPropagation(),i(t)},className:"flex-shrink-0 p-1 rounded hover:bg-bambu-dark-tertiary",title:u("fileManager.linkToProjectOrArchive"),children:a.jsx(Rh,{className:"w-3.5 h-3.5 text-bambu-gray hover:text-bambu-green"})}),a.jsx("div",{className:`flex-shrink-0 flex items-center gap-0.5 transition-opacity ${l?"":"opacity-0 group-hover:opacity-100"}`,onClick:b=>b.stopPropagation(),children:a.jsxs("div",{className:"relative",children:[a.jsx("button",{onClick:()=>p(!f),className:"p-1 rounded hover:bg-bambu-dark-tertiary",children:a.jsx(Eh,{className:"w-3.5 h-3.5 text-bambu-gray"})}),f&&a.jsxs(a.Fragment,{children:[a.jsx("div",{className:"fixed inset-0 z-10",onClick:()=>p(!1)}),a.jsxs("div",{className:"absolute right-0 top-full mt-1 z-20 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg shadow-xl py-1 min-w-[120px]",children:[a.jsxs("button",{className:`w-full px-3 py-1.5 text-left text-sm flex items-center gap-2 ${c("library:update_all")?"text-white hover:bg-bambu-dark":"text-bambu-gray cursor-not-allowed"}`,onClick:()=>{c("library:update_all")&&(s(t),p(!1))},disabled:!c("library:update_all"),title:c("library:update_all")?void 0:u("fileManager.noPermissionRenameFolder"),children:[a.jsx(Vi,{className:"w-3.5 h-3.5"}),u("common.rename")]}),a.jsxs("button",{className:`w-full px-3 py-1.5 text-left text-sm flex items-center gap-2 ${c("library:update_all")?"text-white hover:bg-bambu-dark":"text-bambu-gray cursor-not-allowed"}`,onClick:()=>{c("library:update_all")&&(i(t),p(!1))},disabled:!c("library:update_all"),title:c("library:update_all")?void 0:u("fileManager.noPermissionLinkFolder"),children:[a.jsx(Rh,{className:"w-3.5 h-3.5"}),u(y?"fileManager.changeLink":"fileManager.linkTo")]}),a.jsxs("button",{className:`w-full px-3 py-1.5 text-left text-sm flex items-center gap-2 ${c("library:delete_all")?"text-red-400 hover:bg-bambu-dark":"text-bambu-gray cursor-not-allowed"}`,onClick:()=>{c("library:delete_all")&&(r(t.id),p(!1))},disabled:!c("library:delete_all"),title:c("library:delete_all")?void 0:u("fileManager.noPermissionDeleteFolder"),children:[a.jsx(Jt,{className:"w-3.5 h-3.5"}),u("common.delete")]})]})]})]})})]}),x&&d&&a.jsx("div",{children:t.children.map(b=>a.jsx(Qae,{folder:b,selectedFolderId:e,onSelect:n,onDelete:r,onLink:i,onRename:s,depth:o+1,wrapNames:l,hasPermission:c,t:u},b.id))})]})}function pF(t){const e=t.toLowerCase();return e.endsWith(".gcode")||e.includes(".gcode.")}function QZe({file:t,isSelected:e,isMobile:n,onSelect:r,onDelete:i,onDownload:s,onAddToQueue:o,onPrint:l,onPreview3d:c,onRename:u,onGenerateThumbnail:d,thumbnailVersion:h,hasPermission:f,canModify:p,authEnabled:x,t:y}){const[b,v]=w.useState(!1);return a.jsxs("div",{className:`group relative bg-bambu-dark-secondary rounded-lg border transition-all cursor-pointer overflow-hidden ${e?"border-bambu-green ring-1 ring-bambu-green":"border-bambu-dark-tertiary hover:border-bambu-green/50"}`,onClick:()=>r(t.id),children:[a.jsxs("div",{className:"aspect-square bg-bambu-dark flex items-center justify-center overflow-hidden",children:[t.thumbnail_path?a.jsx("img",{src:`${re.getLibraryFileThumbnailUrl(t.id)}${h?`?v=${h}`:""}`,alt:t.filename,className:"w-full h-full object-cover"}):a.jsx(pf,{className:"w-12 h-12 text-bambu-gray/30"}),a.jsx("div",{className:`absolute top-2 right-2 text-xs px-1.5 py-0.5 rounded font-medium ${t.file_type==="3mf"?"bg-bambu-green/90 text-white":t.file_type==="gcode"?"bg-blue-500/90 text-white":t.file_type==="stl"?"bg-purple-500/90 text-white":"bg-bambu-gray/90 text-white"}`,children:t.file_type.toUpperCase()})]}),a.jsxs("div",{className:"p-3",children:[a.jsx("h3",{className:"text-sm font-medium text-white truncate",title:t.print_name||t.filename,children:t.print_name||t.filename}),a.jsxs("div",{className:"flex items-center gap-3 mt-1 text-xs text-bambu-gray",children:[a.jsx("span",{children:Bg(t.file_size)}),t.print_time_seconds&&a.jsxs("span",{className:"flex items-center gap-1",children:[a.jsx(Wn,{className:"w-3 h-3"}),Zs(t.print_time_seconds)]})]}),t.sliced_for_model&&a.jsxs("div",{className:"mt-1 text-xs text-bambu-gray flex items-center gap-1",children:[a.jsx(Cr,{className:"w-3 h-3"}),t.sliced_for_model]}),t.print_count>0&&a.jsx("div",{className:"mt-1 text-xs text-bambu-green",children:y("fileManager.printedCount",{count:t.print_count})}),x&&t.created_by_username&&a.jsxs("div",{className:"mt-1 text-xs text-bambu-gray flex items-center gap-1",children:[a.jsx(rd,{className:"w-3 h-3"}),t.created_by_username]})]}),a.jsxs("div",{className:`absolute bottom-2 right-2 transition-opacity ${n?"opacity-100":"opacity-0 group-hover:opacity-100"}`,onClick:S=>S.stopPropagation(),children:[a.jsx("button",{onClick:()=>v(!b),className:"p-1.5 rounded bg-bambu-dark-secondary/90 hover:bg-bambu-dark-tertiary",children:a.jsx(Eh,{className:"w-4 h-4 text-bambu-gray"})}),b&&a.jsxs(a.Fragment,{children:[a.jsx("div",{className:"fixed inset-0 z-10",onClick:()=>v(!1)}),a.jsxs("div",{className:"absolute right-0 bottom-8 z-20 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg shadow-xl py-1 min-w-[140px]",children:[l&&pF(t.filename)&&a.jsxs("button",{className:`w-full px-3 py-1.5 text-left text-sm flex items-center gap-2 ${f("printers:control")?"text-bambu-green hover:bg-bambu-dark":"text-bambu-gray cursor-not-allowed"}`,onClick:()=>{f("printers:control")&&(l(t),v(!1))},disabled:!f("printers:control"),title:f("printers:control")?void 0:y("fileManager.noPermissionPrint"),children:[a.jsx(Cr,{className:"w-3.5 h-3.5"}),y("common.print")]}),o&&pF(t.filename)&&a.jsxs("button",{className:`w-full px-3 py-1.5 text-left text-sm flex items-center gap-2 ${f("queue:create")?"text-white hover:bg-bambu-dark":"text-bambu-gray cursor-not-allowed"}`,onClick:()=>{f("queue:create")&&(o(t.id),v(!1))},disabled:!f("queue:create"),title:f("queue:create")?void 0:y("fileManager.noPermissionAddToQueue"),children:[a.jsx(Wn,{className:"w-3.5 h-3.5"}),y("fileManager.schedulePrint")]}),c&&(t.file_type==="3mf"||t.file_type==="gcode"||t.file_type==="stl")&&a.jsxs("button",{className:`w-full px-3 py-1.5 text-left text-sm flex items-center gap-2 ${f("library:read")?"text-white hover:bg-bambu-dark":"text-bambu-gray cursor-not-allowed"}`,onClick:()=>{f("library:read")&&(c(t),v(!1))},disabled:!f("library:read"),title:f("library:read")?void 0:"You do not have permission to preview files",children:[a.jsx(ea,{className:"w-3.5 h-3.5"}),"3D Preview"]}),a.jsxs("button",{className:`w-full px-3 py-1.5 text-left text-sm flex items-center gap-2 ${f("library:read")?"text-white hover:bg-bambu-dark":"text-bambu-gray cursor-not-allowed"}`,onClick:()=>{f("library:read")&&(s(t.id),v(!1))},disabled:!f("library:read"),title:f("library:read")?void 0:y("fileManager.noPermissionDownload"),children:[a.jsx(di,{className:"w-3.5 h-3.5"}),y("common.download")]}),u&&a.jsxs("button",{className:`w-full px-3 py-1.5 text-left text-sm flex items-center gap-2 ${p("library","update",t.created_by_id)?"text-white hover:bg-bambu-dark":"text-bambu-gray cursor-not-allowed"}`,onClick:()=>{p("library","update",t.created_by_id)&&(u(t),v(!1))},disabled:!p("library","update",t.created_by_id),title:p("library","update",t.created_by_id)?void 0:y("fileManager.noPermissionRenameFile"),children:[a.jsx(Vi,{className:"w-3.5 h-3.5"}),y("common.rename")]}),d&&t.file_type==="stl"&&a.jsxs("button",{className:`w-full px-3 py-1.5 text-left text-sm flex items-center gap-2 ${p("library","update",t.created_by_id)?"text-white hover:bg-bambu-dark":"text-bambu-gray cursor-not-allowed"}`,onClick:()=>{p("library","update",t.created_by_id)&&(d(t),v(!1))},disabled:!p("library","update",t.created_by_id),title:p("library","update",t.created_by_id)?void 0:y("fileManager.noPermissionGenerateThumbnail"),children:[a.jsx(td,{className:"w-3.5 h-3.5"}),y("fileManager.generateThumbnail")]}),a.jsxs("button",{className:`w-full px-3 py-1.5 text-left text-sm flex items-center gap-2 ${p("library","delete",t.created_by_id)?"text-red-400 hover:bg-bambu-dark":"text-bambu-gray cursor-not-allowed"}`,onClick:()=>{p("library","delete",t.created_by_id)&&(i(t.id),v(!1))},disabled:!p("library","delete",t.created_by_id),title:p("library","delete",t.created_by_id)?void 0:y("fileManager.noPermissionDeleteFile"),children:[a.jsx(Jt,{className:"w-3.5 h-3.5"}),y("common.delete")]})]})]})]}),a.jsx("div",{className:`absolute top-2 left-2 w-5 h-5 rounded border-2 flex items-center justify-center transition-all ${e?"bg-bambu-green border-bambu-green":`border-white/30 bg-black/30 ${n?"opacity-100":"opacity-0 group-hover:opacity-100"}`}`,children:e&&a.jsx("div",{className:"w-2 h-2 bg-white rounded-sm"})})]})}function ZZe(){const{t}=Vt(),e=tn(),{showToast:n}=hn(),{hasPermission:r,hasAnyPermission:i,canModify:s,authEnabled:o}=Ir(),[l]=kF(),c=l.get("folder"),u=c?parseInt(c,10):null,[d,h]=w.useState(u),[f,p]=w.useState([]),[x,y]=w.useState(!1),[b,v]=w.useState(!1),[S,N]=w.useState(!1),[A,C]=w.useState(null),[T,k]=w.useState(null),[j,E]=w.useState(null),[P,U]=w.useState(null),[O,B]=w.useState(null),[R,G]=w.useState(null),[q,z]=w.useState({}),[K,Y]=w.useState(null),[oe,$]=w.useState(()=>localStorage.getItem("library-view-mode")||"grid"),[X,ee]=w.useState(()=>localStorage.getItem("library-wrap-folders")==="true"),[J,_e]=w.useState(()=>{const Ie=localStorage.getItem("library-sidebar-width");return Ie?parseInt(Ie,10):256}),[pe,me]=w.useState(!1),je=w.useRef(null);w.useEffect(()=>{if(!pe)return;document.body.style.userSelect="none",document.body.style.cursor="col-resize";const Ie=wt=>{if(!je.current)return;const Bt=je.current.parentElement?.getBoundingClientRect();if(!Bt)return;const Tn=wt.clientX-Bt.left,fr=Math.min(500,Math.max(200,Tn));_e(fr)},xt=()=>{me(!1),document.body.style.userSelect="",document.body.style.cursor="",localStorage.setItem("library-sidebar-width",String(J))};return document.addEventListener("mousemove",Ie),document.addEventListener("mouseup",xt),()=>{document.removeEventListener("mousemove",Ie),document.removeEventListener("mouseup",xt),document.body.style.userSelect="",document.body.style.cursor=""}},[pe,J]);const[de,ce]=w.useState(""),[Se,ie]=w.useState("all"),[Fe,V]=w.useState(""),[W,ue]=w.useState(()=>localStorage.getItem("library-sort-field")||"name"),[Q,se]=w.useState(()=>localStorage.getItem("library-sort-direction")||"asc"),Z=gne();w.useEffect(()=>{const Ie=l.get("folder");if(Ie){const xt=parseInt(Ie,10);h(xt)}},[l]);const{data:Ne}=Ze({queryKey:["settings"],queryFn:()=>re.getSettings()}),{data:ve,isLoading:fe}=Ze({queryKey:["library-folders"],queryFn:()=>re.getLibraryFolders()}),{data:L,isLoading:D}=Ze({queryKey:["library-files",d],queryFn:()=>re.getLibraryFiles(d,d===null)}),{data:H}=Ze({queryKey:["library-stats"],queryFn:()=>re.getLibraryStats()}),{data:he}=Ze({queryKey:["users"],queryFn:()=>re.getUsers()}),xe=w.useMemo(()=>{if(!L)return[];const Ie=new Set(L.map(xt=>xt.file_type));return Array.from(Ie).sort()},[L]),be=w.useMemo(()=>{if(!L)return[];let Ie=[...L];if(de.trim()){const xt=de.toLowerCase();Ie=Ie.filter(wt=>wt.filename.toLowerCase().includes(xt)||wt.print_name&&wt.print_name.toLowerCase().includes(xt))}if(Se!=="all"&&(Ie=Ie.filter(xt=>xt.file_type===Se)),Fe.trim()){const xt=Fe.toLowerCase();Ie=Ie.filter(wt=>wt.created_by_username&&wt.created_by_username.toLowerCase().includes(xt))}return Ie.sort((xt,wt)=>{let Bt=0;switch(W){case"name":Bt=(xt.print_name||xt.filename).localeCompare(wt.print_name||wt.filename);break;case"date":Bt=new Date(xt.created_at).getTime()-new Date(wt.created_at).getTime();break;case"size":Bt=xt.file_size-wt.file_size;break;case"type":Bt=xt.file_type.localeCompare(wt.file_type);break;case"prints":Bt=xt.print_count-wt.print_count;break}return Q==="asc"?Bt:-Bt}),Ie},[L,de,Se,Fe,W,Q]),Ue=w.useMemo(()=>{if(!H||!Ne)return!1;const Ie=(Ne.library_disk_warning_gb||5)*1024*1024*1024;return H.disk_free_bytesre.createLibraryFolder(Ie),onSuccess:()=>{e.invalidateQueries({queryKey:["library-folders"]}),y(!1),n(t("fileManager.toast.folderCreated"),"success")},onError:Ie=>n(Ie.message,"error")}),Qe=ot({mutationFn:Ie=>re.deleteLibraryFolder(Ie),onSuccess:()=>{e.invalidateQueries({queryKey:["library-folders"]}),e.invalidateQueries({queryKey:["library-files"]}),e.invalidateQueries({queryKey:["library-stats"]}),d===T?.id&&h(null),k(null),n(t("fileManager.toast.folderDeleted"),"success")},onError:Ie=>{k(null),n(Ie.message,"error")}}),rt=ot({mutationFn:Ie=>re.deleteLibraryFile(Ie),onSuccess:()=>{e.invalidateQueries({queryKey:["library-files"]}),e.invalidateQueries({queryKey:["library-folders"]}),e.invalidateQueries({queryKey:["library-stats"]}),p(Ie=>Ie.filter(xt=>xt!==T?.id)),k(null),n(t("fileManager.toast.fileDeleted"),"success")},onError:Ie=>{k(null),n(Ie.message,"error")}}),we=ot({mutationFn:Ie=>re.bulkDeleteLibrary(Ie,[]),onSuccess:(Ie,xt)=>{e.invalidateQueries({queryKey:["library-files"]}),e.invalidateQueries({queryKey:["library-folders"]}),e.invalidateQueries({queryKey:["library-stats"]}),n(t("fileManager.toast.filesDeleted",{count:xt.length}),"success"),p([]),k(null)},onError:Ie=>{k(null),n(Ie.message,"error")}}),ye=ot({mutationFn:({fileIds:Ie,folderId:xt})=>re.moveLibraryFiles(Ie,xt),onSuccess:()=>{e.invalidateQueries({queryKey:["library-files"]}),e.invalidateQueries({queryKey:["library-folders"]}),p([]),v(!1),n(t("fileManager.toast.filesMoved"),"success")},onError:Ie=>n(Ie.message,"error")}),le=ot({mutationFn:({id:Ie,data:xt})=>re.updateLibraryFolder(Ie,xt),onSuccess:(Ie,xt)=>{e.invalidateQueries({queryKey:["library-folders"]}),e.invalidateQueries({queryKey:["project-folders"]}),e.invalidateQueries({queryKey:["archive-folders"]}),C(null);const wt=xt.data.project_id===0&&xt.data.archive_id===0;n(t(wt?"fileManager.toast.folderUnlinked":"fileManager.toast.folderLinked"),"success")},onError:Ie=>n(Ie.message,"error")}),Le=ot({mutationFn:({id:Ie,filename:xt})=>re.updateLibraryFile(Ie,{filename:xt}),onSuccess:()=>{e.invalidateQueries({queryKey:["library-files"]}),G(null),n(t("fileManager.toast.fileRenamed"),"success")},onError:Ie=>{G(null),n(Ie.message,"error")}}),Me=ot({mutationFn:({id:Ie,name:xt})=>re.updateLibraryFolder(Ie,{name:xt}),onSuccess:()=>{e.invalidateQueries({queryKey:["library-folders"]}),e.invalidateQueries({queryKey:["library-files"]}),G(null),n(t("fileManager.toast.folderRenamed"),"success")},onError:Ie=>{G(null),n(Ie.message,"error")}}),$e=ot({mutationFn:()=>re.batchGenerateStlThumbnails({all_missing:!0}),onSuccess:Ie=>{if(e.invalidateQueries({queryKey:["library-files"]}),Ie.succeeded>0){const xt=Date.now(),wt={};Ie.results.forEach(Bt=>{Bt.success&&(wt[Bt.file_id]=xt)}),z(Bt=>({...Bt,...wt}))}Ie.succeeded>0&&Ie.failed===0?n(t("fileManager.toast.thumbnailsGenerated",{count:Ie.succeeded}),"success"):Ie.succeeded>0&&Ie.failed>0?n(t("fileManager.toast.thumbnailsGeneratedPartial",{succeeded:Ie.succeeded,failed:Ie.failed}),"success"):Ie.processed===0?n(t("fileManager.toast.noStlMissingThumbnails"),"info"):n(t("fileManager.toast.failedToGenerateThumbnails",{error:Ie.results[0]?.error||"Unknown error"}),"error")},onError:Ie=>n(Ie.message,"error")}),Ae=ot({mutationFn:Ie=>re.batchGenerateStlThumbnails({file_ids:[Ie]}),onSuccess:Ie=>{if(e.invalidateQueries({queryKey:["library-files"]}),Ie.succeeded>0){const xt=Ie.results[0]?.file_id;xt&&z(wt=>({...wt,[xt]:Date.now()})),n(t("fileManager.toast.thumbnailGenerated"),"success")}else n(t("fileManager.toast.failedToGenerateThumbnail",{error:Ie.results[0]?.error||"Unknown error"}),"error")},onError:Ie=>n(Ie.message,"error")}),Je=w.useCallback(Ie=>{const xt=Ie.toLowerCase();return xt.endsWith(".gcode")||xt.includes(".gcode.")},[]),Pe=w.useMemo(()=>L?L.filter(Ie=>f.includes(Ie.id)&&Je(Ie.filename)):[],[L,f,Je]),Xe=w.useCallback(Ie=>{p(xt=>xt.includes(Ie)?xt.filter(wt=>wt!==Ie):[...xt,Ie])},[]),De=w.useCallback(()=>{be.length>0&&p(be.map(Ie=>Ie.id))},[be]),Re=w.useCallback(()=>{p([])},[]),qe=()=>{e.invalidateQueries({queryKey:["library-files"]}),e.invalidateQueries({queryKey:["library-folders"]}),e.invalidateQueries({queryKey:["library-stats"]})},pt=Ie=>{re.downloadLibraryFile(Ie).catch(xt=>{console.error("Library file download failed:",xt)})},At=()=>{T&&(T.type==="file"?rt.mutate(T.id):T.type==="folder"?Qe.mutate(T.id):T.type==="bulk"&&we.mutate(f))},Rt=Qe.isPending||rt.isPending||we.isPending,Wt=Ie=>{$(Ie),localStorage.setItem("library-view-mode",Ie)},Tt=fe||D;return a.jsxs("div",{className:"p-4 md:p-8 min-h-[calc(100vh-64px)] lg:h-[calc(100vh-64px)] flex flex-col",children:[a.jsxs("div",{className:"flex flex-col sm:flex-row sm:items-center justify-between gap-4 mb-6",children:[a.jsxs("div",{children:[a.jsxs("h1",{className:"text-2xl font-bold text-white flex items-center gap-3",children:[a.jsx("div",{className:"p-2.5 bg-bambu-green/10 rounded-xl",children:a.jsx(Yl,{className:"w-6 h-6 text-bambu-green"})}),t("fileManager.title")]}),a.jsx("p",{className:"text-sm text-bambu-gray mt-2 ml-14",children:t("fileManager.subtitle")})]}),a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsxs("div",{className:"flex items-center bg-bambu-dark rounded-lg p-1",children:[a.jsx("button",{onClick:()=>Wt("grid"),className:`p-1.5 rounded transition-colors ${oe==="grid"?"bg-bambu-dark-secondary text-white":"text-bambu-gray hover:text-white"}`,title:t("fileManager.gridView"),children:a.jsx(xv,{className:"w-4 h-4"})}),a.jsx("button",{onClick:()=>Wt("list"),className:`p-1.5 rounded transition-colors ${oe==="list"?"bg-bambu-dark-secondary text-white":"text-bambu-gray hover:text-white"}`,title:t("fileManager.listView"),children:a.jsx(rC,{className:"w-4 h-4"})})]}),a.jsxs(Ce,{variant:"secondary",onClick:()=>$e.mutate(),disabled:$e.isPending||!i("library:update_own","library:update_all"),title:i("library:update_own","library:update_all")?t("fileManager.generateThumbnailsForMissing"):t("fileManager.noPermissionGenerateThumbnail"),children:[$e.isPending?a.jsx(it,{className:"w-4 h-4 mr-2 animate-spin"}):a.jsx(td,{className:"w-4 h-4 mr-2"}),t("fileManager.generateThumbnails")]}),a.jsxs(Ce,{variant:"secondary",onClick:()=>y(!0),disabled:!r("library:upload"),title:r("library:upload")?void 0:t("fileManager.noPermissionCreateFolder"),children:[a.jsx(tme,{className:"w-4 h-4 mr-2"}),t("fileManager.newFolder")]}),a.jsxs(Ce,{onClick:()=>N(!0),disabled:!r("library:upload"),title:r("library:upload")?void 0:t("fileManager.noPermissionUpload"),children:[a.jsx(Fi,{className:"w-4 h-4 mr-2"}),t("common.upload")]})]})]}),Ue&&H&&Ne&&a.jsxs("div",{className:"flex items-center gap-3 mb-4 p-3 bg-amber-500/10 border border-amber-500/30 rounded-lg",children:[a.jsx(Cn,{className:"w-5 h-5 text-amber-500 flex-shrink-0"}),a.jsxs("div",{className:"flex-1",children:[a.jsx("p",{className:"text-sm text-amber-500 font-medium",children:t("fileManager.lowDiskSpaceWarning")}),a.jsx("p",{className:"text-xs text-amber-500/80",children:t("fileManager.lowDiskSpaceDetails",{free:Bg(H.disk_free_bytes),total:Bg(H.disk_total_bytes),threshold:Ne.library_disk_warning_gb})})]})]}),H&&a.jsxs("div",{className:"flex flex-wrap items-center gap-3 sm:gap-6 mb-6 p-3 bg-bambu-dark-secondary rounded-lg border border-bambu-dark-tertiary",children:[a.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[a.jsx(eC,{className:"w-4 h-4 text-bambu-green"}),a.jsxs("span",{className:"text-bambu-gray",children:[t("fileManager.files"),":"]}),a.jsx("span",{className:"text-white font-medium",children:H.total_files})]}),a.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[a.jsx(Yl,{className:"w-4 h-4 text-blue-400"}),a.jsxs("span",{className:"text-bambu-gray",children:[t("fileManager.folders"),":"]}),a.jsx("span",{className:"text-white font-medium",children:H.total_folders})]}),a.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[a.jsx(qb,{className:"w-4 h-4 text-amber-400"}),a.jsxs("span",{className:"text-bambu-gray",children:[t("fileManager.size"),":"]}),a.jsx("span",{className:"text-white font-medium",children:Bg(H.total_size_bytes)})]}),a.jsxs("div",{className:"flex items-center gap-2 text-sm sm:ml-auto",children:[a.jsxs("span",{className:"text-bambu-gray",children:[t("fileManager.free"),":"]}),a.jsx("span",{className:`font-medium ${Ue?"text-amber-500":"text-white"}`,children:Bg(H.disk_free_bytes)})]})]}),a.jsxs("div",{className:"flex-1 flex flex-col lg:flex-row gap-4 lg:gap-6 min-h-0",children:[a.jsx("div",{className:"lg:hidden",children:a.jsxs("select",{value:d??"",onChange:Ie=>h(Ie.target.value?parseInt(Ie.target.value,10):null),className:"w-full bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg px-3 py-2.5 text-white focus:outline-none focus:border-bambu-green",children:[a.jsxs("option",{value:"",children:["📁 ",t("fileManager.allFiles")]}),ve&&(()=>{const Ie=(xt,wt=0)=>{const Bt=[];for(const Tn of xt)Bt.push({id:Tn.id,name:Tn.name,fileCount:Tn.file_count,depth:wt}),Tn.children.length>0&&Bt.push(...Ie(Tn.children,wt+1));return Bt};return Ie(ve).map(xt=>a.jsxs("option",{value:xt.id,children:["│ ".repeat(xt.depth),"📂 ",xt.name," ",xt.fileCount>0?`(${xt.fileCount})`:""]},xt.id))})()]})}),a.jsxs("div",{ref:je,className:"hidden lg:flex flex-shrink-0 bg-bambu-dark-secondary rounded-lg border border-bambu-dark-tertiary overflow-hidden flex-col relative",style:{width:`${J}px`},children:[a.jsx("div",{className:`absolute right-0 top-0 bottom-0 w-1.5 cursor-col-resize z-10 group/resize flex items-center justify-center transition-colors ${pe?"bg-bambu-green":"hover:bg-bambu-green/50"}`,onMouseDown:Ie=>{Ie.preventDefault(),me(!0)},onDoubleClick:()=>{_e(256),localStorage.setItem("library-sidebar-width","256")},title:t("fileManager.dragToResizeTooltip"),children:a.jsxs("div",{className:`flex flex-col gap-1 opacity-0 group-hover/resize:opacity-100 transition-opacity ${pe?"opacity-100":""}`,children:[a.jsx("div",{className:"w-0.5 h-0.5 rounded-full bg-white/70"}),a.jsx("div",{className:"w-0.5 h-0.5 rounded-full bg-white/70"}),a.jsx("div",{className:"w-0.5 h-0.5 rounded-full bg-white/70"})]})}),a.jsxs("div",{className:"p-3 border-b border-bambu-dark-tertiary flex items-center justify-between",children:[a.jsx("h2",{className:"text-sm font-medium text-white",children:t("fileManager.folders")}),a.jsx("button",{onClick:()=>{const Ie=!X;ee(Ie),localStorage.setItem("library-wrap-folders",String(Ie))},className:`text-xs px-1.5 py-0.5 rounded transition-colors ${X?"bg-bambu-green/20 text-bambu-green":"text-bambu-gray hover:text-white hover:bg-bambu-dark"}`,title:t(X?"fileManager.disableTextWrapping":"fileManager.enableTextWrapping"),children:t("fileManager.wrap")})]}),a.jsxs("div",{className:"flex-1 overflow-y-auto p-2",children:[a.jsxs("div",{className:`flex items-center gap-2 px-2 py-1.5 rounded cursor-pointer transition-colors ${d===null?"bg-bambu-green/20 text-bambu-green":"hover:bg-bambu-dark text-white"}`,onClick:()=>h(null),children:[a.jsx(pf,{className:"w-4 h-4"}),a.jsx("span",{className:"text-sm",children:t("fileManager.allFiles")})]}),ve?.map(Ie=>a.jsx(Qae,{folder:Ie,selectedFolderId:d,onSelect:h,onDelete:xt=>k({type:"folder",id:xt}),onLink:C,onRename:xt=>G({type:"folder",id:xt.id,name:xt.name}),wrapNames:X,hasPermission:r,t},Ie.id))]})]}),a.jsxs("div",{className:"flex-1 flex flex-col min-w-0 min-h-0",children:[L&&L.length>0&&a.jsxs("div",{className:"flex flex-wrap items-center gap-2 sm:gap-3 mb-4 p-2 sm:p-3 bg-bambu-dark-secondary rounded-lg border border-bambu-dark-tertiary sticky top-0 z-10 lg:static",children:[a.jsxs("div",{className:"relative w-full sm:w-auto sm:flex-1 sm:max-w-xs",children:[a.jsx(Or,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray"}),a.jsx("input",{type:"text",placeholder:t("fileManager.searchFiles"),value:de,onChange:Ie=>ce(Ie.target.value),className:"w-full pl-9 pr-3 py-1.5 bg-bambu-dark border border-bambu-dark-tertiary rounded text-sm text-white placeholder-bambu-gray focus:outline-none focus:border-bambu-green"})]}),a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx(tC,{className:"w-4 h-4 text-bambu-gray hidden sm:block"}),a.jsxs("select",{value:Se,onChange:Ie=>ie(Ie.target.value),className:"bg-bambu-dark border border-bambu-dark-tertiary rounded px-2 py-1.5 text-sm text-white focus:outline-none focus:border-bambu-green",children:[a.jsx("option",{value:"all",children:t("fileManager.allTypes")}),xe.map(Ie=>a.jsx("option",{value:Ie,children:Ie.toUpperCase()},Ie))]})]}),o&&a.jsxs("div",{className:"relative",children:[a.jsx("input",{type:"text",placeholder:t("fileManager.filterByUser",{defaultValue:"Filter by user"}),value:Fe,onChange:Ie=>V(Ie.target.value),list:"usernames-list",className:`w-32 sm:w-40 px-2 py-1.5 bg-bambu-dark border border-bambu-dark-tertiary rounded text-sm text-white placeholder-bambu-gray focus:outline-none focus:border-bambu-green ${Fe?"pr-7":""}`,style:Fe?{WebkitAppearance:"none",MozAppearance:"textfield"}:void 0}),Fe&&a.jsx("button",{onClick:()=>V(""),className:"absolute right-2 top-1/2 -translate-y-1/2 text-bambu-gray hover:text-white z-10",children:a.jsx(Ft,{className:"w-3 h-3"})}),a.jsx("datalist",{id:"usernames-list",children:he?.map(Ie=>a.jsx("option",{value:Ie.username},Ie.id))})]}),a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsxs("select",{value:W,onChange:Ie=>{const xt=Ie.target.value;ue(xt),localStorage.setItem("library-sort-field",xt)},className:"bg-bambu-dark border border-bambu-dark-tertiary rounded px-2 py-1.5 text-sm text-white focus:outline-none focus:border-bambu-green",children:[a.jsx("option",{value:"name",children:t("common.name")}),a.jsx("option",{value:"date",children:t("common.date")}),a.jsx("option",{value:"size",children:t("fileManager.size")}),a.jsx("option",{value:"type",children:t("common.type")}),a.jsx("option",{value:"prints",children:t("fileManager.prints")})]}),a.jsx("button",{onClick:()=>se(Ie=>{const xt=Ie==="asc"?"desc":"asc";return localStorage.setItem("library-sort-direction",xt),xt}),className:"p-1.5 rounded bg-bambu-dark border border-bambu-dark-tertiary hover:border-bambu-green transition-colors",title:t(Q==="asc"?"fileManager.ascending":"fileManager.descending"),children:Q==="asc"?a.jsx(wde,{className:"w-4 h-4 text-white"}):a.jsx(mde,{className:"w-4 h-4 text-white"})})]}),(de||Se!=="all"||Fe)&&a.jsx("span",{className:"text-sm text-bambu-gray hidden sm:inline",children:t("fileManager.resultsCount",{showing:be.length,total:L.length})})]}),be.length>0&&a.jsxs("div",{className:"flex flex-wrap items-center gap-2 mb-4 p-2 bg-bambu-dark-secondary rounded-lg border border-bambu-dark-tertiary sticky top-[52px] z-10 lg:static",children:[f.length===be.length&&f.length>0?a.jsxs(Ce,{variant:"secondary",size:"sm",onClick:Re,children:[a.jsx(bl,{className:"w-4 h-4 sm:mr-1"}),a.jsx("span",{className:"hidden sm:inline",children:t("fileManager.deselectAll")})]}):a.jsxs(Ce,{variant:"secondary",size:"sm",onClick:De,children:[a.jsx(oo,{className:"w-4 h-4 sm:mr-1"}),a.jsx("span",{className:"hidden sm:inline",children:t("fileManager.selectAll")})]}),f.length>0&&a.jsxs(a.Fragment,{children:[a.jsx("span",{className:"text-sm text-bambu-gray ml-2",children:t("fileManager.selected",{count:f.length})}),a.jsx("div",{className:"hidden sm:block flex-1"}),a.jsxs("div",{className:"w-full sm:w-auto flex flex-wrap items-center gap-2 mt-2 sm:mt-0",children:[Pe.length===1&&a.jsxs(Ce,{variant:"primary",size:"sm",onClick:()=>U(Pe[0]),disabled:!r("printers:control"),title:r("printers:control")?void 0:t("fileManager.noPermissionPrint"),children:[a.jsx(so,{className:"w-4 h-4 sm:mr-1"}),a.jsx("span",{className:"hidden sm:inline",children:t("common.print")})]}),Pe.length===1&&a.jsxs(Ce,{variant:"secondary",size:"sm",onClick:()=>B(Pe[0]),disabled:!r("queue:create"),title:r("queue:create")?void 0:t("fileManager.noPermissionAddToQueue"),children:[a.jsx(Wn,{className:"w-4 h-4 sm:mr-1"}),a.jsx("span",{className:"hidden sm:inline",children:t("fileManager.schedulePrint")})]}),a.jsxs(Ce,{variant:"secondary",size:"sm",onClick:()=>v(!0),disabled:!i("library:update_own","library:update_all"),title:i("library:update_own","library:update_all")?void 0:t("fileManager.noPermissionMoveFiles"),children:[a.jsx(lfe,{className:"w-4 h-4 sm:mr-1"}),a.jsx("span",{className:"hidden sm:inline",children:t("common.move")})]}),a.jsxs(Ce,{variant:"danger",size:"sm",onClick:()=>{f.length===1?k({type:"file",id:f[0]}):k({type:"bulk",id:0,count:f.length})},disabled:!i("library:delete_own","library:delete_all"),title:i("library:delete_own","library:delete_all")?void 0:t("fileManager.noPermissionDeleteFiles"),children:[a.jsx(Jt,{className:"w-4 h-4 sm:mr-1"}),a.jsx("span",{className:"hidden sm:inline",children:t("common.delete")})]}),a.jsxs(Ce,{variant:"secondary",size:"sm",onClick:Re,children:[a.jsx(Ft,{className:"w-4 h-4 sm:mr-1"}),a.jsx("span",{className:"hidden sm:inline",children:t("common.clear")})]})]})]})]}),Tt?a.jsx("div",{className:"flex-1 flex items-center justify-center",children:a.jsxs("div",{className:"flex flex-col items-center gap-3",children:[a.jsx(it,{className:"w-8 h-8 animate-spin text-bambu-green"}),a.jsx("p",{className:"text-sm text-bambu-gray",children:t("fileManager.loadingFiles")})]})}):L?.length===0?a.jsxs("div",{className:"flex-1 flex flex-col items-center justify-center",children:[a.jsx("div",{className:"p-4 bg-bambu-dark rounded-2xl mb-4",children:a.jsx(pf,{className:"w-12 h-12 text-bambu-gray/50"})}),a.jsx("h3",{className:"text-lg font-medium text-white mb-2",children:t(d!==null?"fileManager.folderIsEmpty":"fileManager.noFilesYet")}),a.jsx("p",{className:"text-bambu-gray text-center max-w-md mb-6",children:t(d!==null?"fileManager.folderEmptyDescription":"fileManager.noFilesDescription")}),a.jsxs(Ce,{onClick:()=>N(!0),disabled:!r("library:upload"),title:r("library:upload")?void 0:t("fileManager.noPermissionUpload"),children:[a.jsx(ar,{className:"w-4 h-4 mr-2"}),t("fileManager.uploadFiles")]})]}):be.length===0?a.jsxs("div",{className:"flex-1 flex flex-col items-center justify-center",children:[a.jsx("div",{className:"p-4 bg-bambu-dark rounded-2xl mb-4",children:a.jsx(Or,{className:"w-12 h-12 text-bambu-gray/50"})}),a.jsx("h3",{className:"text-lg font-medium text-white mb-2",children:t("fileManager.noMatchingFiles")}),a.jsx("p",{className:"text-bambu-gray text-center max-w-md mb-6",children:t("fileManager.noMatchingFilesDescription")}),a.jsx(Ce,{variant:"secondary",onClick:()=>{ce(""),ie("all")},children:t("fileManager.clearFilters")})]}):oe==="grid"?a.jsx("div",{className:"flex-1 lg:overflow-y-auto",children:a.jsx("div",{className:"grid grid-cols-2 sm:grid-cols-3 lg:grid-cols-4 xl:grid-cols-5 2xl:grid-cols-6 gap-4",children:be.map(Ie=>a.jsx(QZe,{file:Ie,isSelected:f.includes(Ie.id),isMobile:Z,t,onSelect:Xe,onDelete:xt=>k({type:"file",id:xt}),onDownload:pt,onAddToQueue:xt=>{const wt=L?.find(Bt=>Bt.id===xt);wt&&B(wt)},onPrint:E,onPreview3d:Y,onRename:xt=>G({type:"file",id:xt.id,name:xt.filename}),onGenerateThumbnail:xt=>Ae.mutate(xt.id),thumbnailVersion:q[Ie.id],hasPermission:r,canModify:s,authEnabled:o},Ie.id))})}):a.jsx("div",{className:"flex-1 lg:overflow-y-auto",children:a.jsxs("div",{className:"bg-bambu-dark-secondary rounded-lg border border-bambu-dark-tertiary overflow-hidden",children:[a.jsxs("div",{className:`hidden sm:grid ${o?"grid-cols-[auto_1fr_120px_100px_100px_100px_80px]":"grid-cols-[auto_1fr_100px_100px_100px_80px]"} gap-4 px-4 py-2 bg-bambu-dark-secondary border-b border-bambu-dark-tertiary text-xs text-bambu-gray font-medium`,children:[a.jsx("div",{className:"w-6"}),a.jsx("div",{children:t("common.name")}),o&&a.jsx("div",{children:t("fileManager.uploadedBy",{defaultValue:"Uploaded By"})}),a.jsx("div",{children:t("common.type")}),a.jsx("div",{children:t("fileManager.size")}),a.jsx("div",{children:t("fileManager.prints")}),a.jsx("div",{})]}),be.map(Ie=>a.jsxs("div",{className:`grid ${o?"grid-cols-[auto_1fr_120px_100px_100px_100px_80px]":"grid-cols-[auto_1fr_100px_100px_100px_80px]"} gap-4 px-4 py-3 items-center border-b border-bambu-dark-tertiary last:border-b-0 cursor-pointer hover:bg-bambu-dark/50 transition-colors ${f.includes(Ie.id)?"bg-bambu-green/10":""}`,onClick:()=>Xe(Ie.id),children:[a.jsx("div",{className:`w-5 h-5 rounded border-2 flex items-center justify-center ${f.includes(Ie.id)?"bg-bambu-green border-bambu-green":"border-bambu-gray/50"}`,children:f.includes(Ie.id)&&a.jsx("div",{className:"w-2 h-2 bg-white rounded-sm"})}),a.jsxs("div",{className:"flex items-center gap-3 min-w-0",children:[a.jsxs("div",{className:"relative group/thumb",children:[a.jsx("div",{className:"w-10 h-10 rounded bg-bambu-dark flex-shrink-0 overflow-hidden",children:Ie.thumbnail_path?a.jsx("img",{src:`${re.getLibraryFileThumbnailUrl(Ie.id)}${q[Ie.id]?`?v=${q[Ie.id]}`:""}`,alt:"",className:"w-full h-full object-cover"}):a.jsx("div",{className:"w-full h-full flex items-center justify-center",children:a.jsx(pf,{className:"w-5 h-5 text-bambu-gray/50"})})}),Ie.thumbnail_path&&a.jsx("div",{className:"absolute left-0 top-full mt-2 z-50 hidden group-hover/thumb:block",children:a.jsx("div",{className:"w-48 h-48 rounded-lg bg-bambu-dark-secondary border border-bambu-dark-tertiary shadow-xl overflow-hidden",children:a.jsx("img",{src:`${re.getLibraryFileThumbnailUrl(Ie.id)}${q[Ie.id]?`?v=${q[Ie.id]}`:""}`,alt:Ie.filename,className:"w-full h-full object-contain"})})})]}),a.jsx("div",{className:"min-w-0",children:a.jsx("div",{className:"text-sm text-white truncate",children:Ie.print_name||Ie.filename})})]}),o&&a.jsx("div",{className:"text-sm text-bambu-gray flex items-center gap-1",children:Ie.created_by_username?a.jsxs(a.Fragment,{children:[a.jsx(rd,{className:"w-3 h-3"}),a.jsx("span",{className:"truncate",children:Ie.created_by_username})]}):"-"}),a.jsx("div",{children:a.jsx("span",{className:`text-xs px-1.5 py-0.5 rounded font-medium ${Ie.file_type==="3mf"?"bg-bambu-green/20 text-bambu-green":Ie.file_type==="gcode"?"bg-blue-500/20 text-blue-400":Ie.file_type==="stl"?"bg-purple-500/20 text-purple-400":"bg-bambu-gray/20 text-bambu-gray"}`,children:Ie.file_type.toUpperCase()})}),a.jsx("div",{className:"text-sm text-bambu-gray",children:Bg(Ie.file_size)}),a.jsx("div",{className:"text-sm text-bambu-gray",children:Ie.print_count>0?`${Ie.print_count}x`:"-"}),a.jsxs("div",{className:"flex items-center gap-1",onClick:xt=>xt.stopPropagation(),children:[pF(Ie.filename)&&a.jsxs(a.Fragment,{children:[a.jsx("button",{onClick:()=>r("printers:control")&&E(Ie),className:`p-1.5 rounded transition-colors ${r("printers:control")?"hover:bg-bambu-dark text-bambu-gray hover:text-bambu-green":"text-bambu-gray/50 cursor-not-allowed"}`,title:r("printers:control")?t("common.print"):t("fileManager.noPermissionPrint"),disabled:!r("printers:control"),children:a.jsx(Cr,{className:"w-4 h-4"})}),a.jsx("button",{onClick:()=>{r("queue:create")&&B(Ie)},className:`p-1.5 rounded transition-colors ${r("queue:create")?"hover:bg-bambu-dark text-bambu-gray hover:text-white":"text-bambu-gray/50 cursor-not-allowed"}`,title:r("queue:create")?t("fileManager.schedulePrint"):t("fileManager.noPermissionAddToQueue"),disabled:!r("queue:create"),children:a.jsx(Wn,{className:"w-4 h-4"})})]}),(Ie.file_type==="3mf"||Ie.file_type==="gcode"||Ie.file_type==="stl")&&a.jsx("button",{onClick:()=>r("library:read")&&Y(Ie),className:`p-1.5 rounded transition-colors ${r("library:read")?"hover:bg-bambu-dark text-bambu-gray hover:text-bambu-green":"text-bambu-gray/50 cursor-not-allowed"}`,title:r("library:read")?"3D Preview":"You do not have permission to preview files",disabled:!r("library:read"),children:a.jsx(ea,{className:"w-4 h-4"})}),a.jsx("button",{onClick:()=>r("library:read")&&pt(Ie.id),className:`p-1.5 rounded transition-colors ${r("library:read")?"hover:bg-bambu-dark text-bambu-gray hover:text-white":"text-bambu-gray/50 cursor-not-allowed"}`,title:r("library:read")?t("common.download"):t("fileManager.noPermissionDownload"),disabled:!r("library:read"),children:a.jsx(di,{className:"w-4 h-4"})}),a.jsx("button",{onClick:()=>s("library","update",Ie.created_by_id)&&G({type:"file",id:Ie.id,name:Ie.filename}),className:`p-1.5 rounded transition-colors ${s("library","update",Ie.created_by_id)?"hover:bg-bambu-dark text-bambu-gray hover:text-white":"text-bambu-gray/50 cursor-not-allowed"}`,title:s("library","update",Ie.created_by_id)?t("common.rename"):t("fileManager.noPermissionRenameFile"),disabled:!s("library","update",Ie.created_by_id),children:a.jsx(Vi,{className:"w-4 h-4"})}),Ie.file_type==="stl"&&a.jsx("button",{onClick:()=>s("library","update",Ie.created_by_id)&&Ae.mutate(Ie.id),className:`p-1.5 rounded transition-colors ${s("library","update",Ie.created_by_id)?"hover:bg-bambu-dark text-bambu-gray hover:text-bambu-green":"text-bambu-gray/50 cursor-not-allowed"}`,title:s("library","update",Ie.created_by_id)?t("fileManager.generateThumbnail"):t("fileManager.noPermissionGenerateThumbnail"),disabled:Ae.isPending||!s("library","update",Ie.created_by_id),children:a.jsx(td,{className:"w-4 h-4"})}),a.jsx("button",{onClick:()=>s("library","delete",Ie.created_by_id)&&k({type:"file",id:Ie.id}),className:`p-1.5 rounded transition-colors ${s("library","delete",Ie.created_by_id)?"hover:bg-bambu-dark text-bambu-gray hover:text-red-400":"text-bambu-gray/50 cursor-not-allowed"}`,title:s("library","delete",Ie.created_by_id)?t("common.delete"):t("fileManager.noPermissionDeleteFile"),disabled:!s("library","delete",Ie.created_by_id),children:a.jsx(Jt,{className:"w-4 h-4"})})]})]},Ie.id))]})})]})]}),x&&a.jsx(qZe,{parentId:d,onClose:()=>y(!1),onSave:Ie=>Oe.mutate(Ie),isLoading:Oe.isPending,t}),b&&ve&&a.jsx(KZe,{folders:ve,selectedFiles:f,currentFolderId:d,onClose:()=>v(!1),onMove:Ie=>ye.mutate({fileIds:f,folderId:Ie}),isLoading:ye.isPending,t}),S&&a.jsx(YZe,{folderId:d,onClose:()=>N(!1),onUploadComplete:qe,t}),A&&a.jsx(XZe,{folder:A,onClose:()=>C(null),onLink:Ie=>le.mutate({id:A.id,data:Ie}),isLoading:le.isPending,t}),T&&a.jsx(vn,{title:T.type==="folder"?t("fileManager.deleteFolder"):T.type==="bulk"?t("fileManager.deleteFilesCount",{count:T.count}):t("fileManager.deleteFile"),message:T.type==="folder"?t("fileManager.deleteFolderConfirm"):T.type==="bulk"?t("fileManager.deleteFilesConfirm",{count:T.count}):t("fileManager.deleteFileConfirm"),confirmText:t("common.delete"),variant:"danger",isLoading:Rt,loadingText:t("fileManager.deleting"),onConfirm:At,onCancel:()=>k(null)}),j&&a.jsx(Qu,{mode:"reprint",libraryFileId:j.id,archiveName:j.print_name||j.filename,onClose:()=>E(null),onSuccess:()=>{E(null),e.invalidateQueries({queryKey:["library-files"]}),e.invalidateQueries({queryKey:["archives"]})}}),P&&a.jsx(Qu,{mode:"reprint",libraryFileId:P.id,archiveName:P.print_name||P.filename,onClose:()=>U(null),onSuccess:()=>{U(null),p([]),e.invalidateQueries({queryKey:["library-files"]}),e.invalidateQueries({queryKey:["archives"]})}}),O&&a.jsx(Qu,{mode:"add-to-queue",libraryFileId:O.id,archiveName:O.print_name||O.filename,onClose:()=>B(null),onSuccess:()=>{B(null),p([]),e.invalidateQueries({queryKey:["library-files"]}),e.invalidateQueries({queryKey:["queue"]}),e.invalidateQueries({queryKey:["archives"]})}}),K&&a.jsx(N4,{libraryFileId:K.id,title:K.print_name||K.filename,fileType:K.file_type,onClose:()=>Y(null)}),R&&a.jsx(WZe,{type:R.type,currentName:R.name,onClose:()=>G(null),onSave:Ie=>{R.type==="file"?Le.mutate({id:R.id,filename:Ie}):Me.mutate({id:R.id,name:Ie})},isLoading:Le.isPending||Me.isPending,t})]})}const Wj=5,JZe=2e3,eJe=3e4,tJe=5e3;function nJe(){const{t}=Vt(),e=tn(),{showToast:n}=hn(),{hasPermission:r}=Ir(),{printerId:i}=Yk(),s=parseInt(i||"0",10),[o,l]=w.useState("stream"),[c,u]=w.useState(!1),[d,h]=w.useState(!1),[f,p]=w.useState(!0),[x,y]=w.useState(Date.now()),[b,v]=w.useState(!1),[S,N]=w.useState(!1),[A,C]=w.useState(0),[T,k]=w.useState(!1),[j,E]=w.useState(0),[P,U]=w.useState(1),[O,B]=w.useState({x:0,y:0}),[R,G]=w.useState(!1),[q,z]=w.useState({x:0,y:0}),[K,Y]=w.useState(null),[oe,$]=w.useState(null),X=w.useRef(null),ee=w.useRef(null),J=w.useRef(null),_e=w.useRef(null),pe=w.useRef(null),{data:me}=Ze({queryKey:["printer",s],queryFn:()=>re.getPrinter(s),enabled:s>0}),{data:je}=Ze({queryKey:["printerStatus",s],queryFn:()=>re.getPrinterStatus(s),refetchInterval:3e4,enabled:s>0}),de=ot({mutationFn:ye=>re.setChamberLight(s,ye),onMutate:async ye=>{await e.cancelQueries({queryKey:["printerStatus",s]});const le=e.getQueryData(["printerStatus",s]);return e.setQueryData(["printerStatus",s],Le=>({...Le,chamber_light:ye})),{previousStatus:le}},onSuccess:(ye,le)=>{n(`Chamber light ${le?"on":"off"}`)},onError:(ye,le,Le)=>{Le?.previousStatus&&e.setQueryData(["printerStatus",s],Le.previousStatus),n(ye.message||t("printers.toast.failedToControlChamberLight"),"error")}}),ce=(je?.state==="RUNNING"||je?.state==="PAUSE"||je?.state==="PAUSED")&&(je?.printable_objects_count??0)>=2;w.useEffect(()=>(me&&(document.title=`${me.name} - Camera`),()=>{document.title="Bambuddy"}),[me]);const Se=w.useRef(!1);w.useEffect(()=>{const ye=`/api/v1/printers/${s}/camera/stop`;Se.current=!1;const le=()=>{if(s>0&&!Se.current){Se.current=!0;const $e={},Ae=id();Ae&&($e.Authorization=`Bearer ${Ae}`),fetch(ye,{method:"POST",keepalive:!0,headers:$e}).catch(()=>{})}},Le=()=>{le()};window.addEventListener("beforeunload",Le);const Me=X.current;return()=>{window.removeEventListener("beforeunload",Le),Me&&(Me.src=""),le()}},[s]),w.useEffect(()=>{if(f&&!b){const le=setTimeout(()=>{p(!1)},o==="stream"?3e3:2e4);return()=>clearTimeout(le)}},[o,f,x,b]),w.useEffect(()=>{const ye=()=>{const le=!!document.fullscreenElement;N(le),U(1),B({x:0,y:0}),o==="stream"&&!b&&(X.current&&(X.current.src=""),setTimeout(()=>{p(!0),y(Date.now())},200))};return document.addEventListener("fullscreenchange",ye),()=>document.removeEventListener("fullscreenchange",ye)},[o,b]),w.useEffect(()=>{let ye;const le=()=>{clearTimeout(ye),ye=setTimeout(()=>{localStorage.setItem("cameraWindowState",JSON.stringify({width:window.outerWidth,height:window.outerHeight,left:window.screenX,top:window.screenY}))},500)};return window.addEventListener("resize",le),()=>{clearTimeout(ye),window.removeEventListener("resize",le)}},[]),w.useEffect(()=>()=>{J.current&&clearTimeout(J.current),_e.current&&clearInterval(_e.current),pe.current&&clearInterval(pe.current)},[]);const ie=w.useCallback(()=>{if(A>=Wj){k(!1),h(!0);return}const ye=Math.min(JZe*Math.pow(2,A),eJe);k(!0),E(Math.ceil(ye/1e3)),_e.current=setInterval(()=>{E(le=>le<=1?(_e.current&&clearInterval(_e.current),0):le-1)},1e3),J.current=setTimeout(()=>{C(le=>le+1),k(!1),p(!0),h(!1),X.current&&(X.current.src=""),y(Date.now())},ye)},[A]);w.useEffect(()=>{if(o!=="stream"||f||T||b){pe.current&&(clearInterval(pe.current),pe.current=null);return}return pe.current=setInterval(async()=>{try{const ye=await re.getCameraStatus(s);(ye.stalled||!ye.active&&!d)&&(console.log(`Stream issue detected: stalled=${ye.stalled}, active=${ye.active}, reconnecting...`),pe.current&&(clearInterval(pe.current),pe.current=null),p(!1),ie())}catch{}},tJe),()=>{pe.current&&(clearInterval(pe.current),pe.current=null)}},[o,f,d,T,b,s,ie]);const Fe=()=>{p(!1),o==="stream"&&A{if(p(!1),h(!1),C(0),k(!1),J.current&&clearTimeout(J.current),_e.current&&clearInterval(_e.current),X.current&&!localStorage.getItem("cameraWindowState")){const ye=X.current,le=ye.naturalWidth,Le=ye.naturalHeight;if(le>0&&Le>0){const Ae=window.outerWidth-window.innerWidth,Je=window.outerHeight-window.innerHeight,Pe=le+16+Ae,Xe=Le+45+16+Je;try{window.resizeTo(Pe,Xe)}catch{}}}},W=()=>{if(s>0){const ye={},le=id();le&&(ye.Authorization=`Bearer ${le}`),fetch(`/api/v1/printers/${s}/camera/stop`,{method:"POST",headers:ye}).catch(()=>{})}},ue=ye=>{o===ye||b||(v(!0),p(!0),h(!1),C(0),k(!1),U(1),B({x:0,y:0}),J.current&&clearTimeout(J.current),_e.current&&clearInterval(_e.current),X.current&&(X.current.src=""),o==="stream"&&W(),setTimeout(()=>{l(ye),y(Date.now()),v(!1)},100))},Q=()=>{b||(v(!0),p(!0),h(!1),C(0),k(!1),J.current&&clearTimeout(J.current),_e.current&&clearInterval(_e.current),X.current&&(X.current.src=""),o==="stream"&&W(),setTimeout(()=>{y(Date.now()),v(!1)},100))},se=()=>{ee.current&&(document.fullscreenElement?document.exitFullscreen():ee.current.requestFullscreen())},Z=()=>{U(ye=>Math.min(ye+.5,4))},Ne=()=>{U(ye=>{const le=Math.max(ye-.5,1);return le===1&&B({x:0,y:0}),le})},ve=ye=>{ye.preventDefault(),ye.deltaY<0?Z():Ne()},fe=ye=>{P>1&&(ye.preventDefault(),G(!0),z({x:ye.clientX-O.x,y:ye.clientY-O.y}))},L=w.useCallback(()=>{if(!ee.current)return{x:300,y:200};const ye=ee.current.getBoundingClientRect(),le=ye.width*(P-1)/2,Le=ye.height*(P-1)/2;return{x:Math.max(50,le),y:Math.max(50,Le)}},[P]),D=ye=>{if(R&&P>1){const le=ye.clientX-q.x,Le=ye.clientY-q.y,Me=L();B({x:Math.max(-Me.x,Math.min(Me.x,le)),y:Math.max(-Me.y,Math.min(Me.y,Le))})}},H=()=>{G(!1)},he=ye=>{if(ye.length<2)return 0;const le=ye[0].clientX-ye[1].clientX,Le=ye[0].clientY-ye[1].clientY;return Math.sqrt(le*le+Le*Le)},xe=ye=>ye.length<2?{x:ye[0].clientX,y:ye[0].clientY}:{x:(ye[0].clientX+ye[1].clientX)/2,y:(ye[0].clientY+ye[1].clientY)/2},be=ye=>{ye.touches.length===2?(ye.preventDefault(),Y(he(ye.touches)),$(xe(ye.touches))):ye.touches.length===1&&P>1&&(ye.preventDefault(),G(!0),z({x:ye.touches[0].clientX-O.x,y:ye.touches[0].clientY-O.y}))},Ue=ye=>{if(ye.touches.length===2&&K!==null){ye.preventDefault();const le=he(ye.touches),Le=le/K;U($e=>{const Ae=Math.max(1,Math.min(4,$e*Le));return Ae===1&&B({x:0,y:0}),Ae}),Y(le);const Me=xe(ye.touches);if(oe){const $e=L();B(Ae=>({x:Math.max(-$e.x,Math.min($e.x,Ae.x+(Me.x-oe.x))),y:Math.max(-$e.y,Math.min($e.y,Ae.y+(Me.y-oe.y)))}))}$(Me)}else if(ye.touches.length===1&&R&&P>1){ye.preventDefault();const le=ye.touches[0].clientX-q.x,Le=ye.touches[0].clientY-q.y,Me=L();B({x:Math.max(-Me.x,Math.min(Me.x,le)),y:Math.max(-Me.y,Math.min(Me.y,Le))})}},Oe=ye=>{ye.touches.length<2&&(Y(null),$(null)),ye.touches.length===0&&G(!1)},Qe=()=>{U(1),B({x:0,y:0})},rt=b?"":o==="stream"?`/api/v1/printers/${s}/camera/stream?fps=15&t=${x}`:`/api/v1/printers/${s}/camera/snapshot?t=${x}`,we=f||b||T;return s?a.jsxs("div",{ref:ee,className:"min-h-screen bg-black flex flex-col",children:[a.jsxs("div",{className:"flex items-center justify-between px-4 py-2 bg-bambu-dark-secondary border-b border-bambu-dark-tertiary",children:[a.jsxs("h1",{className:"text-sm font-medium text-white flex items-center gap-2",children:[a.jsx(mb,{className:"w-4 h-4"}),me?.name||`Printer ${s}`]}),a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsxs("div",{className:"flex bg-bambu-dark rounded p-0.5",children:[a.jsx("button",{onClick:()=>ue("stream"),disabled:we,className:`px-3 py-1 text-xs rounded transition-colors ${o==="stream"?"bg-bambu-green text-white":"text-bambu-gray hover:text-white disabled:opacity-50"}`,children:t("camera.live")}),a.jsx("button",{onClick:()=>ue("snapshot"),disabled:we,className:`px-3 py-1 text-xs rounded transition-colors ${o==="snapshot"?"bg-bambu-green text-white":"text-bambu-gray hover:text-white disabled:opacity-50"}`,children:t("camera.snapshot")})]}),a.jsx("button",{onClick:()=>de.mutate(!je?.chamber_light),disabled:!je?.connected||de.isPending||!r("printers:control"),className:`p-1.5 rounded disabled:opacity-50 ${je?.chamber_light?"bg-yellow-500/20 hover:bg-yellow-500/30":"hover:bg-bambu-dark-tertiary"}`,title:r("printers:control")?t("camera.chamberLight"):t("printers.permission.noControl"),children:a.jsx(xL,{on:je?.chamber_light??!1,className:"w-4 h-4"})}),a.jsx("button",{onClick:()=>u(!0),disabled:!ce||!r("printers:control"),className:`p-1.5 rounded disabled:opacity-50 ${ce&&r("printers:control")?"hover:bg-bambu-dark-tertiary":""}`,title:r("printers:control")?t(ce?"printers.skipObjects.tooltip":"printers.skipObjects.onlyWhilePrinting"):t("printers.permission.noControl"),children:a.jsx(SC,{className:"w-4 h-4 text-bambu-gray"})}),a.jsx("button",{onClick:Q,disabled:we,className:"p-1.5 hover:bg-bambu-dark-tertiary rounded disabled:opacity-50",title:t(o==="stream"?"camera.restartStream":"camera.refreshSnapshot"),children:a.jsx(kr,{className:`w-4 h-4 text-bambu-gray ${we?"animate-spin":""}`})}),a.jsx("button",{onClick:se,className:"p-1.5 hover:bg-bambu-dark-tertiary rounded",title:t(S?"camera.exitFullscreen":"camera.fullscreen"),children:S?a.jsx(gX,{className:"w-4 h-4 text-bambu-gray"}):a.jsx(Yme,{className:"w-4 h-4 text-bambu-gray"})})]})]}),a.jsx("div",{className:"flex-1 flex items-center justify-center p-2 overflow-hidden",onWheel:ve,onMouseMove:D,onMouseUp:H,onMouseLeave:H,onTouchStart:be,onTouchMove:Ue,onTouchEnd:Oe,style:{touchAction:"none"},children:a.jsxs("div",{className:"relative w-full h-full flex items-center justify-center",children:[(f||b)&&!T&&a.jsx("div",{className:"absolute inset-0 flex items-center justify-center bg-black/50 z-10",children:a.jsxs("div",{className:"text-center",children:[a.jsx(kr,{className:"w-8 h-8 text-bambu-gray animate-spin mx-auto mb-2"}),a.jsx("p",{className:"text-sm text-bambu-gray",children:t(o==="stream"?"camera.connectingToCamera":"camera.capturingSnapshot")})]})}),T&&a.jsx("div",{className:"absolute inset-0 flex items-center justify-center bg-black/80 z-10",children:a.jsxs("div",{className:"text-center p-4",children:[a.jsx(Rf,{className:"w-10 h-10 text-orange-400 mx-auto mb-3"}),a.jsx("p",{className:"text-white mb-2",children:t("camera.connectionLost")}),a.jsx("p",{className:"text-sm text-bambu-gray mb-3",children:t("camera.reconnecting",{countdown:j,attempt:A+1,max:Wj})}),a.jsx("button",{onClick:Q,className:"px-4 py-2 bg-bambu-green text-white text-sm rounded hover:bg-bambu-green/80 transition-colors",children:t("camera.reconnectNow")})]})}),d&&!T&&a.jsx("div",{className:"absolute inset-0 flex items-center justify-center bg-black z-10",children:a.jsxs("div",{className:"text-center p-4",children:[a.jsx(Cn,{className:"w-12 h-12 text-orange-400 mx-auto mb-3"}),a.jsx("p",{className:"text-white mb-2",children:t("camera.cameraUnavailable")}),a.jsx("p",{className:"text-xs text-bambu-gray mb-4 max-w-md",children:t("camera.cameraUnavailableDesc")}),a.jsx("button",{onClick:Q,className:"px-4 py-2 bg-bambu-green text-white rounded hover:bg-bambu-green/80 transition-colors",children:t("camera.retry")})]})}),a.jsx("img",{ref:X,src:rt,alt:t("camera.cameraStream"),className:"max-w-full max-h-full object-contain select-none",style:{transform:`scale(${P}) translate(${O.x/P}px, ${O.y/P}px)`,cursor:P>1?R?"grabbing":"grab":"default"},onError:rt?Fe:void 0,onLoad:rt?V:void 0,onMouseDown:fe,draggable:!1},x),a.jsxs("div",{className:"absolute bottom-4 left-4 flex items-center gap-1.5 bg-black/60 rounded-lg px-2 py-1.5",children:[a.jsx("button",{onClick:Ne,disabled:P<=1,className:"p-1.5 hover:bg-white/10 rounded disabled:opacity-30",title:t("camera.zoomOut"),children:a.jsx(HF,{className:"w-4 h-4 text-white"})}),a.jsxs("button",{onClick:Qe,className:"px-2 py-1 text-sm text-white hover:bg-white/10 rounded min-w-[48px]",title:t("camera.resetZoom"),children:[Math.round(P*100),"%"]}),a.jsx("button",{onClick:Z,disabled:P>=4,className:"p-1.5 hover:bg-white/10 rounded disabled:opacity-30",title:t("camera.zoomIn"),children:a.jsx(BF,{className:"w-4 h-4 text-white"})})]})]})}),a.jsx(yL,{printerId:s,isOpen:c,onClose:()=>u(!1)})]}):a.jsx("div",{className:"min-h-screen bg-black flex items-center justify-center",children:a.jsx("p",{className:"text-white",children:t("camera.invalidPrinterId")})})}function rJe(t){const e=t.get("show")?.split(",")||["progress","layers","eta","filename","status"],n=parseInt(t.get("fps")||"15",10),r=Math.min(Math.max(isNaN(n)?15:n,1),30),i=t.get("camera"),s=i!=="false"&&i!=="0";return{size:t.get("size")||"medium",fps:r,showCamera:s,showProgress:e.includes("progress"),showLayers:e.includes("layers"),showEta:e.includes("eta"),showFilename:e.includes("filename"),showStatus:e.includes("status"),showPrinter:e.includes("printer")}}function iJe(t,e){if(t.stg_cur_name)return t.stg_cur_name;switch(t.state){case"RUNNING":return e("streamOverlay.status.printing");case"PAUSE":return e("streamOverlay.status.paused");case"FINISH":return e("streamOverlay.status.finished");case"FAILED":return e("streamOverlay.status.failed");case"IDLE":return e("streamOverlay.status.idle");default:return t.state||e("streamOverlay.status.unknown")}}function aJe(t){switch(t){case"small":return{container:"p-3",text:"text-sm",textLarge:"text-lg",progressHeight:"h-2",icon:"w-3 h-3",gap:"gap-2",logoHeight:"h-12"};case"large":return{container:"p-6",text:"text-xl",textLarge:"text-3xl",progressHeight:"h-4",icon:"w-6 h-6",gap:"gap-4",logoHeight:"h-24"};default:return{container:"p-4",text:"text-base",textLarge:"text-xl",progressHeight:"h-3",icon:"w-4 h-4",gap:"gap-3",logoHeight:"h-16"}}}function sJe(){const{printerId:t}=Yk(),[e]=kF(),{t:n}=Vt(),r=tn(),i=parseInt(t||"0",10),[s,o]=w.useState(Date.now()),l=w.useMemo(()=>rJe(e),[e]),c=aJe(l.size),{data:u}=Ze({queryKey:["printer",i],queryFn:()=>re.getPrinter(i),enabled:i>0}),{data:d}=Ze({queryKey:["printerStatus",i],queryFn:()=>re.getPrinterStatus(i),enabled:i>0,refetchInterval:2e3}),{data:h}=Ze({queryKey:["settings"],queryFn:re.getSettings}),f=h?.time_format||"system";w.useEffect(()=>{if(!i)return;const S=`${window.location.protocol==="https:"?"wss:":"ws:"}//${window.location.host}/api/v1/ws`,N=new WebSocket(S);return N.onmessage=A=>{try{const C=JSON.parse(A.data);C.type==="printer_status"&&C.printer_id===i&&r.setQueryData(["printerStatus",i],C.status)}catch{}},N.onerror=()=>{},()=>{N.close()}},[i,r]),w.useEffect(()=>(document.title=u?`${u.name} - ${n("streamOverlay.title")}`:n("streamOverlay.title"),()=>{document.title="Bambuddy"}),[u,n]);const p=()=>{setTimeout(()=>{o(Date.now())},3e3)};if(!i)return a.jsx("div",{className:"min-h-screen bg-black flex items-center justify-center",children:a.jsx("p",{className:"text-white",children:n("streamOverlay.invalidPrinterId")})});if(!d)return a.jsx("div",{className:"min-h-screen bg-black flex items-center justify-center",children:a.jsx("p",{className:"text-gray-400",children:n("common.loading")})});const x=d.state==="RUNNING"||d.state==="PAUSE",y=d.progress||0,b=`/api/v1/printers/${i}/camera/stream?fps=${l.fps}&t=${s}`;return a.jsxs("div",{className:"min-h-screen bg-black relative overflow-hidden",children:[l.showCamera&&a.jsx("img",{src:b,alt:n("streamOverlay.cameraStream"),className:"absolute inset-0 w-full h-full object-contain",onError:p},s),a.jsx("a",{href:"https://github.com/maziggy/bambuddy",target:"_blank",rel:"noopener noreferrer",className:"absolute top-4 right-4 z-10",children:a.jsx("img",{src:"/img/bambuddy_logo_dark_transparent.png",alt:"Bambuddy",className:`${c.logoHeight} object-contain drop-shadow-lg hover:scale-105 transition-transform`})}),a.jsx("div",{className:"absolute bottom-0 left-0 right-0 z-10 bg-gradient-to-t from-black/80 via-black/60 to-transparent",children:a.jsxs("div",{className:`${c.container}`,children:[l.showPrinter&&u&&a.jsxs("div",{className:`flex items-center ${c.gap} mb-2`,children:[a.jsx(Cr,{className:`${c.icon} text-white/70`}),a.jsx("span",{className:`${c.text} text-white font-medium`,children:u.name})]}),l.showFilename&&d.current_print&&a.jsx("div",{className:`${c.textLarge} text-white font-semibold mb-2 truncate drop-shadow-md`,children:d.current_print.replace(/\.gcode\.3mf$|\.3mf$|\.gcode$/i,"")}),l.showStatus&&a.jsx("div",{className:`${c.text} text-white/70 mb-2`,children:iJe(d,n)}),l.showProgress&&x&&a.jsxs("div",{className:"mb-3",children:[a.jsxs("div",{className:`flex items-center justify-between mb-1 ${c.text}`,children:[a.jsx("span",{className:"text-white/70",children:n("streamOverlay.progress")}),a.jsxs("span",{className:"text-white font-bold",children:[Math.round(y),"%"]})]}),a.jsx("div",{className:`w-full bg-white/20 rounded-full ${c.progressHeight}`,children:a.jsx("div",{className:`bg-bambu-green ${c.progressHeight} rounded-full transition-all duration-500`,style:{width:`${y}%`}})})]}),x&&(l.showLayers||l.showEta)&&a.jsxs("div",{className:`flex items-center ${c.gap} flex-wrap`,children:[l.showLayers&&d.layer_num!=null&&d.total_layers!=null&&d.total_layers>0&&a.jsxs("div",{className:`flex items-center ${c.gap} text-white/70`,children:[a.jsx(ma,{className:c.icon}),a.jsxs("span",{className:c.text,children:[a.jsx("span",{className:"text-white",children:d.layer_num}),a.jsx("span",{className:"mx-1",children:"/"}),a.jsx("span",{children:d.total_layers})]})]}),l.showEta&&d.remaining_time!=null&&d.remaining_time>0&&a.jsxs(a.Fragment,{children:[a.jsxs("div",{className:`flex items-center ${c.gap} text-white/70`,children:[a.jsx(Iu,{className:c.icon}),a.jsx("span",{className:`${c.text} text-white`,children:Zs(d.remaining_time*60)})]}),a.jsxs("div",{className:`flex items-center ${c.gap} text-white/70`,children:[a.jsx(Wn,{className:c.icon}),a.jsxs("span",{className:`${c.text} text-white`,children:[n("streamOverlay.eta")," ",$F(d.remaining_time,f,n)]})]})]})]}),!x&&a.jsx("div",{className:`${c.text} text-white/70 py-2`,children:d.connected?n("streamOverlay.printerIdle"):n("streamOverlay.printerOffline")})]})})]})}function oJe(){const{t}=Vt(),{id:e}=Yk(),{mode:n}=rp(),{data:r,isLoading:i,error:s}=Ze({queryKey:["external-link",e],queryFn:()=>re.getExternalLink(Number(e)),enabled:!!e});return i?a.jsx("div",{className:"flex items-center justify-center h-full",children:a.jsx(it,{className:"w-8 h-8 text-bambu-green animate-spin"})}):s||!r?a.jsxs("div",{className:"flex flex-col items-center justify-center h-full gap-4 text-bambu-gray",children:[a.jsx(Cn,{className:"w-12 h-12"}),a.jsx("p",{children:t("common.linkNotFound")})]}):a.jsx("iframe",{src:r.url,className:"h-full w-full border-0",style:{colorScheme:n},title:r.name,sandbox:"allow-scripts allow-same-origin allow-forms allow-popups allow-popups-to-escape-sandbox"})}const hK={material:"",subtype:"",brand:"",color_name:"",rgba:"808080FF",label_weight:1e3,core_weight:250,core_weight_catalog_id:null,weight_used:0,slicer_filament:"",note:""};function lJe(t){const e={};return t.slicer_filament||(e.slicer_filament="Slicer preset is required"),t.material||(e.material="Material is required"),{isValid:Object.keys(e).length===0,errors:e}}const cJe=["PLA","PETG","ABS","TPU","ASA","PC","PA","PVA","HIPS","PA-CF","PETG-CF","PLA-CF"],uJe=["Bambu","PolyLite","PolyTerra","eSUN","Overture","Fiberon","SUNLU","Inland","Hatchbox","Generic"],y0=["Basic","Matte","Silk","Tough","HF","High Flow","Engineering","Galaxy","Glow","Marble","Metal","Rainbow","Sparkle","Wood","Translucent","Transparent","Clear","Lite","Pro","Plus","Max","Super","Ultra","Flex","Soft","Hard","Strong","Impact","Heat Resistant","UV Resistant","ESD","Conductive","Magnetic","Gradient","Dual Color","Tri Color","Multicolor"],Zae=[{name:"Black",hex:"000000"},{name:"White",hex:"FFFFFF"},{name:"Gray",hex:"808080"},{name:"Red",hex:"FF0000"},{name:"Orange",hex:"FFA500"},{name:"Yellow",hex:"FFFF00"},{name:"Green",hex:"00AE42"},{name:"Blue",hex:"0066FF"},{name:"Purple",hex:"8B00FF"},{name:"Pink",hex:"FF69B4"},{name:"Brown",hex:"8B4513"},{name:"Silver",hex:"C0C0C0"}],dJe=[{name:"Dark Red",hex:"8B0000"},{name:"Crimson",hex:"DC143C"},{name:"Coral",hex:"FF7F50"},{name:"Salmon",hex:"FA8072"},{name:"Dark Orange",hex:"FF8C00"},{name:"Peach",hex:"FFDAB9"},{name:"Gold",hex:"FFD700"},{name:"Khaki",hex:"F0E68C"},{name:"Lemon",hex:"FFF44F"},{name:"Lime",hex:"32CD32"},{name:"Forest Green",hex:"228B22"},{name:"Olive",hex:"808000"},{name:"Mint",hex:"98FF98"},{name:"Teal",hex:"008080"},{name:"Navy",hex:"000080"},{name:"Sky Blue",hex:"87CEEB"},{name:"Royal Blue",hex:"4169E1"},{name:"Cyan",hex:"00FFFF"},{name:"Turquoise",hex:"40E0D0"},{name:"Violet",hex:"EE82EE"},{name:"Magenta",hex:"FF00FF"},{name:"Indigo",hex:"4B0082"},{name:"Lavender",hex:"E6E6FA"},{name:"Plum",hex:"DDA0DD"},{name:"Hot Pink",hex:"FF69B4"},{name:"Rose",hex:"FF007F"},{name:"Blush",hex:"FFB6C1"},{name:"Chocolate",hex:"D2691E"},{name:"Tan",hex:"D2B48C"},{name:"Beige",hex:"F5F5DC"},{name:"Maroon",hex:"800000"},{name:"Dark Gray",hex:"404040"},{name:"Light Gray",hex:"D3D3D3"},{name:"Charcoal",hex:"36454F"},{name:"Ivory",hex:"FFFFF0"},{name:"Bambu Green",hex:"00AE42"},{name:"Jade White",hex:"E8E8E8"},{name:"Titan Gray",hex:"5A5A5A"}],mK=[...Zae,...dJe],Jae="bambuddy-recent-colors",hJe=8,mJe=[{code:"GFL00",name:"Bambu PLA Basic",displayName:"Bambu PLA Basic",isCustom:!1,allCodes:["GFL00"]},{code:"GFL01",name:"Bambu PLA Matte",displayName:"Bambu PLA Matte",isCustom:!1,allCodes:["GFL01"]},{code:"GFL05",name:"Generic PLA",displayName:"Generic PLA",isCustom:!1,allCodes:["GFL05"]},{code:"GFG00",name:"Bambu PETG Basic",displayName:"Bambu PETG Basic",isCustom:!1,allCodes:["GFG00"]},{code:"GFG05",name:"Generic PETG",displayName:"Generic PETG",isCustom:!1,allCodes:["GFG05"]},{code:"GFB00",name:"Bambu ABS Basic",displayName:"Bambu ABS Basic",isCustom:!1,allCodes:["GFB00"]},{code:"GFB05",name:"Generic ABS",displayName:"Generic ABS",isCustom:!1,allCodes:["GFB05"]},{code:"GFA00",name:"Bambu ASA Basic",displayName:"Bambu ASA Basic",isCustom:!1,allCodes:["GFA00"]},{code:"GFU00",name:"Bambu TPU 95A",displayName:"Bambu TPU 95A",isCustom:!1,allCodes:["GFU00"]},{code:"GFU05",name:"Generic TPU",displayName:"Generic TPU",isCustom:!1,allCodes:["GFU05"]},{code:"GFC00",name:"Bambu PC Basic",displayName:"Bambu PC Basic",isCustom:!1,allCodes:["GFC00"]},{code:"GFN00",name:"Bambu PA Basic",displayName:"Bambu PA Basic",isCustom:!1,allCodes:["GFN00"]},{code:"GFN05",name:"Generic PA",displayName:"Generic PA",isCustom:!1,allCodes:["GFN05"]},{code:"GFS00",name:"Bambu PLA-CF",displayName:"Bambu PLA-CF",isCustom:!1,allCodes:["GFS00"]},{code:"GFT00",name:"Bambu PETG-CF",displayName:"Bambu PETG-CF",isCustom:!1,allCodes:["GFT00"]},{code:"GFNC0",name:"Bambu PA-CF",displayName:"Bambu PA-CF",isCustom:!1,allCodes:["GFNC0"]},{code:"GFV00",name:"Bambu PVA",displayName:"Bambu PVA",isCustom:!1,allCodes:["GFV00"]}];function Wk(t){let e=t.replace(/@.*$/,"").trim();e=e.replace(/\(Custom\)/i,"").trim(),e=e.replace(/^[#*]+\s*/,"").trim();const n=["PLA-CF","PETG-CF","ABS-GF","ASA-CF","PA-CF","PAHT-CF","PA6-CF","PA6-GF","PPA-CF","PPA-GF","PET-CF","PPS-CF","PC-CF","PC-ABS","ABS-GF","PETG","PLA","ABS","ASA","PC","PA","TPU","PVA","HIPS","BVOH","PPS","PCTG","PEEK","PEI"];let r="",i=-1;for(const c of n){const u=e.toUpperCase().indexOf(c.toUpperCase());if(u!==-1){r=c,i=u;break}}let s="";i>0&&(s=e.substring(0,i).trim(),s=s.replace(/[-_\s]+$/,""));let o="";i!==-1&&r&&(o=e.substring(i+r.length).trim(),o=o.replace(/^[-_\s]+/,""));let l="";for(const c of y0)if(o.toLowerCase().includes(c.toLowerCase())){l=c;break}if(!l&&s)for(const c of y0){const u=new RegExp(`\\s+${c}$`,"i");if(u.test(s)){l=c,s=s.replace(u,"").trim();break}}return{brand:s,material:r,variant:l}}function fJe(t,e){const n=new Set(uJe);for(const r of t){const{brand:i}=Wk(r.name);i&&i.length>1&&n.add(i)}if(e)for(const r of e)if(r.filament_vendor&&r.filament_vendor.length>1)n.add(r.filament_vendor);else{const{brand:i}=Wk(r.name);i&&i.length>1&&n.add(i)}return Array.from(n).sort((r,i)=>r.localeCompare(i))}function pJe(t){const e=t.filter(r=>r.preset_type==="filament");if(e.length===0)return[];const n=new Map;for(const r of e){const i=r.name.replace(/@.*$/,"").trim(),s=n.get(i);if(s)s.allCodes.push(String(r.id));else{const o=r.filament_type||String(r.id);n.set(i,{code:o,name:i,displayName:i,isCustom:!1,allCodes:[o]})}}return Array.from(n.values()).sort((r,i)=>r.displayName.localeCompare(i.displayName))}function gJe(t,e,n){if(t.length>0){const r=[],i=new Map;for(const s of t)if(s.is_custom){const o=s.name.toUpperCase();(e.size===0||Array.from(e).some(c=>o.includes(c))||!o.includes("@"))&&r.push({code:s.setting_id,name:s.name,displayName:`${s.name} (Custom)`,isCustom:!0,allCodes:[s.setting_id]})}else{const o=s.name.replace(/@.*$/,"").trim(),l=i.get(o);l?l.allCodes.push(s.setting_id):i.set(o,{code:s.setting_id,name:o,displayName:o,isCustom:!1,allCodes:[s.setting_id]})}return[...r,...Array.from(i.values())].sort((s,o)=>s.displayName.localeCompare(o.displayName))}if(n&&n.length>0){const r=pJe(n);if(r.length>0)return r}return mJe}function bJe(t,e){if(!t)return;let n=e.find(r=>r.code===t);if(n||(n=e.find(r=>r.allCodes.includes(t))),!n){const r=t.toLowerCase();n=e.find(i=>i.code.toLowerCase()===r||i.allCodes.some(s=>s.toLowerCase()===r))}return n}function xJe(){try{const t=localStorage.getItem(Jae);if(t)return JSON.parse(t)}catch{}return[]}function yJe(t,e){const n=e.filter(i=>i.hex.toUpperCase()!==t.hex.toUpperCase()),r=[t,...n].slice(0,hJe);try{localStorage.setItem(Jae,JSON.stringify(r))}catch{}return r}function Kj(t,e){if(!e.material)return!1;const r=(t.name||"").replace(/^High Flow[_\s]+/i,"").replace(/^Standard[_\s]+/i,"").replace(/^HF[_\s]+/i,"").replace(/^S[_\s]+/i,"").trim(),i=Wk(r);return!(!(i.material.toUpperCase()===e.material.toUpperCase())||e.brand&&!(i.brand.toLowerCase().includes(e.brand.toLowerCase())||e.brand.toLowerCase().includes(i.brand.toLowerCase()))||e.subtype&&!(i.variant.toLowerCase().includes(e.subtype.toLowerCase())||e.subtype.toLowerCase().includes(i.variant.toLowerCase())||r.toLowerCase().includes(e.subtype.toLowerCase())))}function vJe({formData:t,updateField:e,cloudAuthenticated:n,loadingCloudPresets:r,presetInputValue:i,setPresetInputValue:s,selectedPresetOption:o,filamentOptions:l,availableBrands:c}){const{t:u}=Vt(),[d,h]=w.useState(!1),[f,p]=w.useState(!1),[x,y]=w.useState(!1),[b,v]=w.useState(""),[S,N]=w.useState(""),A=w.useRef(null),C=w.useRef(null),T=w.useRef(null);w.useEffect(()=>{const U=O=>{A.current&&!A.current.contains(O.target)&&h(!1),C.current&&!C.current.contains(O.target)&&p(!1),T.current&&!T.current.contains(O.target)&&y(!1)};return document.addEventListener("mousedown",U),()=>document.removeEventListener("mousedown",U)},[]);const k=w.useMemo(()=>{if(!i)return l;const U=i.toLowerCase();return l.filter(O=>O.displayName.toLowerCase().includes(U)||O.code.toLowerCase().includes(U))},[l,i]),j=w.useMemo(()=>{if(!b)return c;const U=b.toLowerCase();return c.filter(O=>O.toLowerCase().includes(U))},[c,b]),E=w.useMemo(()=>{if(!S)return y0;const U=S.toLowerCase();return y0.filter(O=>O.toLowerCase().includes(U))},[S]),P=U=>{e("slicer_filament",U.code),s(U.displayName),h(!1);const O=Wk(U.name);O.material&&e("material",O.material),O.brand&&e("brand",O.brand),O.variant&&e("subtype",O.variant)};return a.jsxs("div",{className:"space-y-4",children:[a.jsx("div",{className:"flex items-center gap-2 text-xs text-bambu-gray",children:r?a.jsxs(a.Fragment,{children:[a.jsx(it,{className:"w-3 h-3 animate-spin"})," ",u("inventory.loadingPresets")]}):n?a.jsxs(a.Fragment,{children:[a.jsx(Gb,{className:"w-3 h-3 text-bambu-green"})," ",u("inventory.cloudConnected")]}):a.jsxs(a.Fragment,{children:[a.jsx(hhe,{className:"w-3 h-3"})," ",u("inventory.cloudNotConnected")]})}),a.jsxs("div",{children:[a.jsxs("label",{className:"block text-sm font-medium text-bambu-gray mb-1",children:[u("inventory.slicerPreset")," *"]}),a.jsxs("div",{className:"relative",ref:A,children:[a.jsx(Or,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray/50 pointer-events-none"}),a.jsx("input",{type:"text",className:"w-full pl-9 pr-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white text-sm placeholder:text-bambu-gray/50 focus:outline-none focus:border-bambu-green",placeholder:u("inventory.searchPresets"),value:i,onChange:U=>{s(U.target.value),h(!0)},onFocus:()=>{h(!0),s("")}}),d&&a.jsx("div",{className:"absolute z-50 w-full mt-1 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg shadow-lg max-h-64 overflow-y-auto",children:k.length===0?a.jsx("div",{className:"px-3 py-2 text-sm text-bambu-gray",children:u("inventory.noPresetsFound")}):k.map(U=>a.jsxs("button",{type:"button",className:`w-full px-3 py-2 text-left text-sm hover:bg-bambu-dark-tertiary flex justify-between items-center ${o?.code===U.code?"bg-bambu-green/10 text-bambu-green":"text-white"}`,onClick:()=>P(U),children:[a.jsx("span",{className:"truncate",children:U.displayName}),a.jsx("span",{className:"font-mono text-xs text-bambu-gray ml-2 shrink-0",children:U.code})]},U.code))})]}),o&&a.jsxs("div",{className:"mt-1 text-xs text-bambu-gray",children:[u("inventory.selectedPreset"),": ",a.jsx("span",{className:"font-mono text-bambu-green",children:o.code})]})]}),a.jsxs("div",{children:[a.jsxs("label",{className:"block text-sm font-medium text-bambu-gray mb-1",children:[u("inventory.material")," *"]}),a.jsxs("select",{value:t.material,onChange:U=>e("material",U.target.value),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white text-sm focus:outline-none focus:border-bambu-green",children:[a.jsx("option",{value:"",children:u("inventory.selectMaterial")}),cJe.map(U=>a.jsx("option",{value:U,children:U},U))]})]}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm font-medium text-bambu-gray mb-1",children:u("inventory.brand")}),a.jsxs("div",{className:"relative",ref:C,children:[a.jsx("input",{type:"text",className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white text-sm placeholder:text-bambu-gray/50 focus:outline-none focus:border-bambu-green",placeholder:u("inventory.searchBrand"),value:f?b:t.brand,onChange:U=>{v(U.target.value),p(!0)},onFocus:()=>{p(!0),v("")}}),a.jsx(nr,{className:"absolute right-3 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray/50 pointer-events-none"}),f&&a.jsxs("div",{className:"absolute z-50 w-full mt-1 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg shadow-lg max-h-48 overflow-y-auto",children:[j.length===0?a.jsx("div",{className:"px-3 py-2 text-sm text-bambu-gray",children:u("inventory.noResults")}):j.map(U=>a.jsx("button",{type:"button",className:`w-full px-3 py-2 text-left text-sm hover:bg-bambu-dark-tertiary ${t.brand===U?"bg-bambu-green/10 text-bambu-green":"text-white"}`,onClick:()=>{e("brand",U),p(!1),v("")},children:U},U)),b&&!j.includes(b)&&a.jsx("button",{type:"button",className:"w-full px-3 py-2 text-left text-sm hover:bg-bambu-dark-tertiary text-bambu-green border-t border-bambu-dark-tertiary",onClick:()=>{e("brand",b),p(!1),v("")},children:u("inventory.useCustomBrand",{brand:b})})]})]})]}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm font-medium text-bambu-gray mb-1",children:u("inventory.subtype")}),a.jsxs("div",{className:"relative",ref:T,children:[a.jsx("input",{type:"text",value:x?S:t.subtype,onChange:U=>{N(U.target.value),y(!0)},onFocus:()=>{y(!0),N("")},placeholder:"Basic, Matte, Silk...",className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white text-sm placeholder:text-bambu-gray/50 focus:outline-none focus:border-bambu-green"}),a.jsx(nr,{className:"absolute right-3 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray/50 pointer-events-none"}),x&&a.jsxs("div",{className:"absolute z-50 w-full mt-1 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg shadow-lg max-h-48 overflow-y-auto",children:[E.length===0?a.jsx("div",{className:"px-3 py-2 text-sm text-bambu-gray",children:u("inventory.noResults")}):E.map(U=>a.jsx("button",{type:"button",className:`w-full px-3 py-2 text-left text-sm hover:bg-bambu-dark-tertiary ${t.subtype===U?"bg-bambu-green/10 text-bambu-green":"text-white"}`,onClick:()=>{e("subtype",U),y(!1),N("")},children:U},U)),S&&!y0.some(U=>U.toLowerCase()===S.toLowerCase().trim())&&a.jsx("button",{type:"button",className:"w-full px-3 py-2 text-left text-sm hover:bg-bambu-dark-tertiary text-bambu-green border-t border-bambu-dark-tertiary",onClick:()=>{e("subtype",S),y(!1),N("")},children:u("inventory.useCustomBrand",{brand:S})})]})]})]}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm font-medium text-bambu-gray mb-1",children:u("inventory.labelWeight")}),a.jsxs("div",{className:"relative",children:[a.jsx("input",{type:"number",value:t.label_weight,onChange:U=>e("label_weight",parseInt(U.target.value)||0),className:"w-full px-3 py-2 pr-7 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white text-sm focus:outline-none focus:border-bambu-green"}),a.jsx("span",{className:"absolute right-2 top-1/2 -translate-y-1/2 text-xs text-bambu-gray",children:"g"})]})]})]})}function wJe({formData:t,updateField:e,recentColors:n,onColorUsed:r,catalogColors:i}){const{t:s}=Vt(),[o,l]=w.useState(!1),[c,u]=w.useState(""),d=t.rgba.replace("#","").substring(0,6),h=v=>d.toUpperCase()===v.toUpperCase(),f=(v,S)=>{e("rgba",v.toUpperCase()+"FF"),e("color_name",S),r({name:S,hex:v})},p=w.useMemo(()=>{if(i.length===0)return[];const v=t.brand?.trim(),S=t.material?.toLowerCase().trim(),N=t.subtype?.toLowerCase().trim();if(!v&&!S)return[];const A=v?v.toLowerCase().split(/[\s\-_]+/).filter(k=>k.length>=2):[],C=k=>{if(A.length===0)return!0;const j=k.toLowerCase();return A.some(E=>j.includes(E))},T=S&&N?`${S} ${N}`:"";if(T){const k=i.filter(E=>C(E.manufacturer)&&E.material?.toLowerCase()===T);if(k.length>0)return k.map(E=>({name:E.color_name,hex:E.hex_color.replace("#","").substring(0,6)}));const j=T.replace(/\+$/,"");if(j!==T){const E=i.filter(P=>C(P.manufacturer)&&P.material?.toLowerCase()===j);if(E.length>0)return E.map(P=>({name:P.color_name,hex:P.hex_color.replace("#","").substring(0,6)}))}}if(S){const k=i.filter(j=>C(j.manufacturer)&&(!j.material||j.material.toLowerCase().startsWith(S)));if(k.length>0)return k.map(j=>({name:j.color_name,hex:j.hex_color.replace("#","").substring(0,6)}))}return[]},[i,t.brand,t.material,t.subtype]),x=p.length>0,y=w.useMemo(()=>{if(!c)return p;const v=c.toLowerCase();return p.filter(S=>S.name.toLowerCase().includes(v))},[p,c]),b=w.useMemo(()=>c?mK.filter(v=>v.name.toLowerCase().includes(c.toLowerCase())):o?mK:Zae,[c,o]);return a.jsxs("div",{className:"space-y-3",children:[a.jsx("div",{className:"h-10 rounded-lg border border-bambu-dark-tertiary",style:{backgroundColor:`#${d}`}}),n.length>0&&a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsxs("div",{className:"flex items-center gap-1.5 text-xs text-bambu-gray shrink-0",children:[a.jsx(Wn,{className:"w-3 h-3"}),a.jsx("span",{children:s("inventory.recentColors")})]}),a.jsx("div",{className:"flex flex-wrap gap-1.5",children:n.map(v=>a.jsx("button",{type:"button",onClick:()=>f(v.hex,v.name),className:`w-6 h-6 rounded border-2 transition-all hover:scale-110 ${h(v.hex)?"border-bambu-green ring-1 ring-bambu-green/30 scale-110":"border-bambu-dark-tertiary"}`,style:{backgroundColor:`#${v.hex}`},title:v.name},v.hex))})]}),a.jsxs("div",{className:"relative",children:[a.jsx(Or,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray/50 pointer-events-none"}),a.jsx("input",{type:"text",className:"w-full pl-9 pr-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white text-sm placeholder:text-bambu-gray/50 focus:outline-none focus:border-bambu-green",placeholder:s("inventory.searchColors"),value:c,onChange:v=>u(v.target.value)})]}),x?a.jsxs("div",{className:"space-y-1.5",children:[a.jsx("span",{className:"text-xs text-bambu-gray",children:c?s("inventory.searchResults"):`${t.brand}${t.material?` ${t.material}`:""}`}),a.jsxs("div",{className:"flex flex-wrap gap-1.5",children:[y.map(v=>a.jsx("button",{type:"button",onClick:()=>f(v.hex,v.name),className:`w-6 h-6 rounded border-2 transition-all hover:scale-110 hover:z-20 relative group ${h(v.hex)?"border-bambu-green ring-1 ring-bambu-green/30 scale-110":"border-bambu-dark-tertiary"}`,style:{backgroundColor:`#${v.hex}`},title:v.name,children:a.jsx("span",{className:"absolute -bottom-7 left-1/2 -translate-x-1/2 px-2 py-0.5 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded text-xs whitespace-nowrap opacity-0 group-hover:opacity-100 transition-opacity pointer-events-none z-20 shadow-lg text-white",children:v.name})},`${v.hex}-${v.name}`)),y.length===0&&a.jsx("p",{className:"text-sm text-bambu-gray py-1",children:s("inventory.noColorsFound")})]})]}):a.jsxs("div",{className:"space-y-1.5",children:[a.jsxs("div",{className:"flex items-center justify-between text-xs text-bambu-gray",children:[a.jsx("span",{children:s(c?"inventory.searchResults":o?"inventory.allColors":"inventory.commonColors")}),!c&&a.jsx("button",{type:"button",onClick:()=>l(!o),className:"flex items-center gap-1 hover:text-white transition-colors",children:o?a.jsxs(a.Fragment,{children:[s("inventory.showLess")," ",a.jsx(Wl,{className:"w-3 h-3"})]}):a.jsxs(a.Fragment,{children:[s("inventory.showAll")," ",a.jsx(nr,{className:"w-3 h-3"})]})})]}),a.jsxs("div",{className:"flex flex-wrap gap-1.5",children:[b.map(v=>a.jsx("button",{type:"button",onClick:()=>f(v.hex,v.name),className:`w-6 h-6 rounded border-2 transition-all hover:scale-110 hover:z-20 relative group ${h(v.hex)?"border-bambu-green ring-1 ring-bambu-green/30 scale-110":"border-bambu-dark-tertiary"}`,style:{backgroundColor:`#${v.hex}`},title:v.name,children:a.jsx("span",{className:"absolute -bottom-7 left-1/2 -translate-x-1/2 px-2 py-0.5 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded text-xs whitespace-nowrap opacity-0 group-hover:opacity-100 transition-opacity pointer-events-none z-20 shadow-lg text-white",children:v.name})},v.hex)),b.length===0&&a.jsx("p",{className:"text-sm text-bambu-gray py-1",children:s("inventory.noColorsFound")})]})]}),a.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm font-medium text-bambu-gray mb-1",children:s("inventory.colorName")}),a.jsx("input",{type:"text",className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white text-sm placeholder:text-bambu-gray/50 focus:outline-none focus:border-bambu-green",placeholder:s("inventory.colorNamePlaceholder"),value:t.color_name,onChange:v=>e("color_name",v.target.value)})]}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm font-medium text-bambu-gray mb-1",children:s("inventory.hexColor")}),a.jsxs("div",{className:"flex gap-2",children:[a.jsxs("div",{className:"relative flex-1",children:[a.jsx("span",{className:"absolute left-3 top-1/2 -translate-y-1/2 text-bambu-gray",children:"#"}),a.jsx("input",{type:"text",className:"w-full pl-7 pr-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white text-sm font-mono uppercase focus:outline-none focus:border-bambu-green",placeholder:"RRGGBB",value:d.toUpperCase(),onChange:v=>{const S=v.target.value.replace("#","").replace(/[^0-9A-Fa-f]/g,"");S.length<=8&&e("rgba",S.toUpperCase()+(S.length<=6?"FF":""))}})]}),a.jsx("input",{type:"color",className:"w-11 h-[38px] rounded-lg cursor-pointer border border-bambu-dark-tertiary shrink-0 bg-transparent",value:`#${d}`,onChange:v=>{const S=v.target.value.replace("#","").toUpperCase();e("rgba",S+"FF")},title:s("inventory.pickColor")})]})]})]})]})}function _Je({catalog:t,value:e,onChange:n,catalogId:r,onCatalogIdChange:i}){const{t:s}=Vt(),[o,l]=w.useState(!1),[c,u]=w.useState(""),d=w.useRef(null),h=w.useRef(null);w.useEffect(()=>{const y=b=>{d.current&&!d.current.contains(b.target)&&l(!1)};return document.addEventListener("mousedown",y),()=>document.removeEventListener("mousedown",y)},[]),w.useEffect(()=>{if(t.length===0)return;const y=t.filter(b=>b.weight===e);if(r){const b=t.find(v=>v.id===r);if(b&&b.weight===e)return}y.length===1?i(y[0].id):y.length===0&&r!==null&&i(null)},[e,t,r,i]);const f=w.useMemo(()=>{if(!c)return t;const y=c.toLowerCase();return t.filter(b=>b.name.toLowerCase().includes(y)||b.weight.toString().includes(y))},[t,c]),p=w.useMemo(()=>t.filter(y=>y.weight===e),[t,e]),x=w.useMemo(()=>{if(o)return c;if(r){const y=t.find(b=>b.id===r);if(y)return y.name}return p.length>0?p[0].name:""},[o,c,r,t,p]);return a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm font-medium text-bambu-gray mb-1",children:a.jsxs("span",{className:"flex items-center gap-2",children:[a.jsx(jfe,{className:"w-3.5 h-3.5 text-bambu-gray"}),s("inventory.coreWeight")]})}),a.jsxs("div",{className:"flex gap-2 items-center",children:[a.jsxs("div",{className:"flex-1 min-w-0 relative",ref:d,children:[a.jsx("input",{ref:h,type:"text",className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white text-sm placeholder:text-bambu-gray/50 focus:outline-none focus:border-bambu-green",placeholder:s("inventory.searchSpoolWeight"),value:x,onFocus:()=>{l(!0),u("")},onChange:y=>{u(y.target.value),l(!0)}}),o&&a.jsx("div",{className:"absolute z-50 w-full mt-1 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg shadow-lg max-h-64 overflow-y-auto",children:f.length===0?a.jsx("div",{className:"px-3 py-2 text-sm text-bambu-gray",children:s("inventory.noResults")}):f.map(y=>a.jsxs("button",{type:"button",className:`w-full px-3 py-2 text-left text-sm hover:bg-bambu-dark-tertiary flex justify-between items-center ${(r?y.id===r:y.weight===e)?"bg-bambu-green/10 text-bambu-green":"text-white"}`,onClick:()=>{i(y.id),n(y.weight),l(!1),u("")},children:[a.jsx("span",{className:"truncate",children:y.name}),a.jsxs("span",{className:"font-mono text-xs text-bambu-gray ml-2 shrink-0",children:[y.weight,"g"]})]},y.id))})]}),a.jsxs("div",{className:"flex items-center gap-1 shrink-0",children:[a.jsx("input",{type:"number",className:"w-16 px-2 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white text-sm text-center font-mono focus:outline-none focus:border-bambu-green",value:e,min:0,max:2e3,onChange:y=>{const b=parseInt(y.target.value);!isNaN(b)&&b>=0&&n(b)}}),a.jsx("span",{className:"text-bambu-gray text-sm",children:"g"})]})]})]})}function SJe({formData:t,updateField:e,spoolCatalog:n}){const{t:r}=Vt(),{showToast:i}=hn(),[s,o]=w.useState(""),[l,c]=w.useState(!1),u=Math.max(0,t.label_weight-t.weight_used),d=t.core_weight+u;return w.useEffect(()=>{l||o(String(d))},[l,d]),a.jsxs("div",{className:"space-y-4",children:[a.jsx(_Je,{catalog:n,value:t.core_weight,onChange:h=>e("core_weight",h),catalogId:t.core_weight_catalog_id,onCatalogIdChange:h=>e("core_weight_catalog_id",h)}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm font-medium text-bambu-gray mb-1",children:r("inventory.currentWeight")}),a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsxs("div",{className:"relative flex-1",children:[a.jsx("input",{type:"number",value:u,min:0,max:t.label_weight,onChange:h=>{const f=parseInt(h.target.value)||0;e("weight_used",Math.max(0,t.label_weight-f))},className:"w-full px-3 py-2 pr-7 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white text-sm focus:outline-none focus:border-bambu-green"}),a.jsx("span",{className:"absolute right-2 top-1/2 -translate-y-1/2 text-xs text-bambu-gray",children:"g"})]}),a.jsxs("span",{className:"text-xs text-bambu-gray shrink-0",children:["/ ",t.label_weight,"g"]})]})]}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm font-medium text-bambu-gray mb-1",children:r("inventory.measuredWeight")}),a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsxs("div",{className:"relative flex-1",children:[a.jsx("input",{type:"number",value:s,min:0,onFocus:()=>c(!0),onChange:h=>{o(h.target.value)},onBlur:()=>{c(!1);const h=s.trim(),f=Number(h),p=t.core_weight,x=t.core_weight+t.label_weight;if(!h||!Number.isFinite(f)||fx){i(r("inventory.measuredWeightError",{min:p,max:x}),"error"),o(String(d));return}const y=Math.round(f),b=Math.max(0,Math.min(t.label_weight,y-t.core_weight));e("weight_used",Math.max(0,t.label_weight-b)),o(String(y))},className:"w-full px-3 py-2 pr-7 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white text-sm focus:outline-none focus:border-bambu-green"}),a.jsx("span",{className:"absolute right-2 top-1/2 -translate-y-1/2 text-xs text-bambu-gray",children:"g"})]}),a.jsxs("span",{className:"text-xs text-bambu-gray shrink-0",children:["/ ",t.core_weight+t.label_weight,"g"]})]})]}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm font-medium text-bambu-gray mb-1",children:r("inventory.note")}),a.jsx("textarea",{className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white text-sm placeholder:text-bambu-gray/50 focus:outline-none focus:border-bambu-green resize-none min-h-[80px]",placeholder:r("inventory.notePlaceholder"),value:t.note,onChange:h=>e("note",h.target.value)})]})]})}function NJe({formData:t,printersWithCalibrations:e,selectedProfiles:n,setSelectedProfiles:r,expandedPrinters:i,setExpandedPrinters:s}){const{t:o}=Vt(),l=f=>{s(p=>{const x=new Set(p);return x.has(f)?x.delete(f):x.add(f),x})},c=(f,p,x)=>{const y=`${f}:${p}:${x??"null"}`,b=`${f}:${x??"null"}`;r(v=>{const S=new Set(v);if(S.has(y))S.delete(y);else{for(const N of Array.from(S)){const A=N.split(":");`${A[0]}:${A[2]}`===b&&S.delete(N)}S.add(y)}return S})},u=()=>{const f=new Set;for(const{printer:p,calibrations:x}of e){if(!p.connected)continue;const y=x.filter(v=>Kj(v,t)),b=new Map;for(const v of y){const S=`${v.extruder_id??"null"}`;b.has(S)||b.set(S,[]),b.get(S).push(v)}for(const[v,S]of b)if(S.length>0){const A=[...S].sort((C,T)=>T.k_value-C.k_value)[0];f.add(`${p.id}:${A.cali_idx}:${v}`)}}r(f)};if(!t.material)return a.jsx("div",{className:"p-6 bg-bambu-dark rounded-lg text-center",children:a.jsx("p",{className:"text-bambu-gray",children:o("inventory.selectMaterialFirst")})});if(e.length===0)return a.jsx("div",{className:"p-6 bg-bambu-dark rounded-lg text-center",children:a.jsx("p",{className:"text-bambu-gray",children:o("inventory.noPrintersConfigured")})});const d=e.reduce((f,{printer:p,calibrations:x})=>p.connected?f+x.filter(y=>Kj(y,t)).length:f,0),h=(f,p)=>{const x=`${f.id}:${p.cali_idx}:${p.extruder_id??"null"}`,y=n.has(x);return a.jsxs("label",{className:`flex items-center gap-3 p-3 rounded-lg cursor-pointer transition-all border ${y?"bg-bambu-green/10 border-bambu-green/30":"bg-bambu-dark border-transparent hover:bg-bambu-dark/80"}`,children:[a.jsx("input",{type:"checkbox",checked:y,onChange:()=>c(String(f.id),p.cali_idx,p.extruder_id),className:"w-4 h-4 rounded border-bambu-dark-tertiary text-bambu-green focus:ring-bambu-green"}),a.jsx("div",{className:"flex-1 min-w-0",children:a.jsx("span",{className:`text-sm font-medium ${y?"text-bambu-green":"text-white"}`,children:p.name||p.filament_id})}),a.jsx("div",{className:"flex items-center gap-2 shrink-0",children:a.jsxs("span",{className:"text-xs font-mono px-2 py-0.5 rounded bg-bambu-dark text-bambu-gray",children:["K=",p.k_value.toFixed(3)]})})]},`${p.cali_idx}-${p.extruder_id}`)};return a.jsxs("div",{className:"space-y-4",children:[a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsxs("p",{className:"text-xs text-bambu-gray",children:[o("inventory.matchingFilter"),": ",t.brand||o("inventory.anyBrand")," / ",t.material," / ",t.subtype||o("inventory.anyVariant")]}),d>0&&a.jsxs("button",{type:"button",onClick:u,className:"flex items-center gap-1.5 px-2 py-1 text-xs bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-bambu-gray hover:text-white hover:border-bambu-green transition-colors",children:[a.jsx(pb,{className:"w-3.5 h-3.5"}),o("inventory.autoSelect")," (",d,")"]})]}),a.jsx("div",{className:"space-y-3",children:e.map(({printer:f,calibrations:p})=>{const x=i.has(String(f.id)),y=p.filter(A=>Kj(A,t)),b=y.length,v=y.some(A=>A.extruder_id!==void 0&&A.extruder_id!==null&&A.extruder_id>0),S=y.filter(A=>A.extruder_id===1),N=y.filter(A=>A.extruder_id===0||A.extruder_id===void 0||A.extruder_id===null);return a.jsxs("div",{className:"border border-bambu-dark-tertiary rounded-lg overflow-hidden",children:[a.jsxs("button",{type:"button",onClick:()=>l(String(f.id)),className:"w-full px-4 py-3 flex items-center justify-between bg-bambu-dark-secondary hover:bg-bambu-dark-tertiary transition-colors",children:[a.jsxs("div",{className:"flex items-center gap-3",children:[x?a.jsx(nr,{className:"w-4 h-4 text-bambu-gray"}):a.jsx(pa,{className:"w-4 h-4 text-bambu-gray"}),a.jsx("span",{className:"font-medium text-white",children:f.name}),b>0?a.jsxs("span",{className:"text-xs px-2 py-0.5 rounded-full bg-bambu-green/20 text-bambu-green",children:[b," ",o(b!==1?"inventory.matches":"inventory.match")]}):a.jsx("span",{className:"text-xs px-2 py-0.5 rounded-full bg-bambu-dark-tertiary text-bambu-gray",children:o("inventory.noMatches")})]}),a.jsx("span",{className:`text-xs px-2 py-1 rounded-full ${f.connected?"bg-green-500/20 text-green-500":"bg-bambu-gray/20 text-bambu-gray"}`,children:f.connected?o("inventory.connected"):o("inventory.offline")})]}),x&&a.jsx("div",{className:"px-4 py-3 space-y-3 bg-bambu-dark border-t border-bambu-dark-tertiary",children:f.connected?b===0?a.jsx("p",{className:"text-sm text-bambu-gray italic py-2",children:o("inventory.noKProfilesMatch")}):v?a.jsxs(a.Fragment,{children:[S.length>0&&a.jsxs("div",{className:"space-y-2",children:[a.jsx("p",{className:"text-xs font-medium text-bambu-gray uppercase tracking-wide",children:o("inventory.leftNozzle")}),a.jsx("div",{className:"space-y-2",children:S.map(A=>h(f,A))})]}),N.length>0&&a.jsxs("div",{className:"space-y-2",children:[a.jsx("p",{className:"text-xs font-medium text-bambu-gray uppercase tracking-wide",children:o("inventory.rightNozzle")}),a.jsx("div",{className:"space-y-2",children:N.map(A=>h(f,A))})]})]}):a.jsx("div",{className:"space-y-2",children:y.map(A=>h(f,A))}):a.jsx("p",{className:"text-sm text-bambu-gray italic py-2",children:o("inventory.printerOffline")})})]},f.id)})}),n.size>0&&a.jsx("div",{className:"p-3 bg-bambu-green/10 border border-bambu-green/30 rounded-lg",children:a.jsxs("p",{className:"text-sm text-white",children:[a.jsx("span",{className:"font-semibold",children:n.size})," ",o("inventory.profilesSelected")]})})]})}function kJe(t){const e=new Date(t);return e.toLocaleDateString("en-GB",{day:"2-digit",month:"2-digit",year:"2-digit"})+" "+e.toLocaleTimeString("en-GB",{hour:"2-digit",minute:"2-digit"})}const CJe={completed:"text-bambu-green",failed:"text-red-400",aborted:"text-yellow-400"};function MJe({spoolId:t}){const{t:e}=Vt(),n=tn(),{showToast:r}=hn(),{data:i,isLoading:s}=Ze({queryKey:["spool-usage",t],queryFn:()=>re.getSpoolUsageHistory(t)}),o=ot({mutationFn:()=>re.clearSpoolUsageHistory(t),onSuccess:()=>{n.invalidateQueries({queryKey:["spool-usage",t]}),r(e("inventory.historyCleared"),"success")}});return s?a.jsx("div",{className:"flex justify-center py-4",children:a.jsx(it,{className:"w-5 h-5 animate-spin text-bambu-green"})}):!i||i.length===0?a.jsxs("div",{className:"text-center py-4 text-bambu-gray text-sm",children:[a.jsx(Wn,{className:"w-5 h-5 mx-auto mb-2 opacity-50"}),e("inventory.noUsageHistory")]}):a.jsxs("div",{className:"space-y-2",children:[a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsx("h4",{className:"text-sm font-medium text-white",children:e("inventory.usageHistory")}),a.jsxs(Ce,{variant:"ghost",size:"sm",onClick:()=>o.mutate(),disabled:o.isPending,className:"text-xs text-bambu-gray hover:text-red-400",children:[a.jsx(Jt,{className:"w-3 h-3 mr-1"}),e("inventory.clearHistory")]})]}),a.jsx("div",{className:"max-h-48 overflow-y-auto space-y-1",children:i.map(l=>a.jsxs("div",{className:"flex items-center justify-between p-2 rounded bg-bambu-dark/50 text-xs",children:[a.jsxs("div",{className:"flex-1 min-w-0",children:[a.jsx("span",{className:"text-bambu-gray",children:kJe(l.created_at)}),l.print_name&&a.jsx("span",{className:"text-white ml-2 truncate",title:l.print_name,children:l.print_name})]}),a.jsxs("div",{className:"flex items-center gap-2 flex-shrink-0 ml-2",children:[a.jsxs("span",{className:"text-white font-medium",children:[l.weight_used.toFixed(1),"g"]}),a.jsxs("span",{className:"text-bambu-gray",children:["(",l.percent_used,"%)"]}),a.jsx("span",{className:CJe[l.status]||"text-bambu-gray",children:l.status})]})]},l.id))})]})}function AJe({isOpen:t,onClose:e,spool:n,printersWithCalibrations:r=[]}){const{t:i}=Vt(),s=tn(),{showToast:o}=hn(),l=!!n,[c,u]=w.useState(hK),[d,h]=w.useState({}),[f,p]=w.useState("filament"),[x,y]=w.useState(!1),[b,v]=w.useState(!1),[S,N]=w.useState(!1),[A,C]=w.useState([]),[T,k]=w.useState(""),[j,E]=w.useState([]),[P,U]=w.useState([]),[O,B]=w.useState([]),[R,G]=w.useState([]),[q,z]=w.useState([]),[K,Y]=w.useState(new Set),[oe,$]=w.useState(new Set),X=r.length>0?r:q,ee=w.useMemo(()=>K.size,[K]);w.useEffect(()=>{G(xJe())},[]),w.useEffect(()=>{t&&((async()=>{N(!0);try{const W=await re.getCloudStatus();if(v(W.is_authenticated),W.is_authenticated){const ue=await re.getFilamentPresets();C(ue)}}catch(W){console.error("Failed to fetch cloud presets:",W),v(!1)}finally{N(!1)}})(),re.getSpoolCatalog().then(E).catch(console.error),re.getColorCatalog().then(B).catch(console.error),re.getLocalPresets().then(W=>U(W.filament)).catch(console.error),r.length===0&&(async()=>{try{const W=await re.getPrinters(),ue=await Promise.all(W.map(se=>re.getPrinterStatus(se.id).catch(()=>null))),Q=[];for(let se=0;se({cali_idx:D.slot_id,filament_id:D.filament_id,setting_id:D.setting_id||"",name:D.name,k_value:parseFloat(D.k_value)||0,n_coef:parseFloat(D.n_coef)||0,extruder_id:D.extruder_id,nozzle_diameter:D.nozzle_diameter}))}catch{}Q.push({printer:{...Z,connected:ve},calibrations:fe})}z(Q)}catch(W){console.error("Failed to fetch printer calibrations:",W)}})())},[t,r.length]);const J=w.useMemo(()=>gJe(A,new Set,P),[A,P]),_e=w.useMemo(()=>fJe(A,P),[A,P]),pe=w.useMemo(()=>bJe(c.slicer_filament,J),[c.slicer_filament,J]);w.useEffect(()=>{if(t){if(n)if(u({material:n.material||"",subtype:n.subtype||"",brand:n.brand||"",color_name:n.color_name||"",rgba:n.rgba||"808080FF",label_weight:n.label_weight||1e3,core_weight:n.core_weight||250,core_weight_catalog_id:n.core_weight_catalog_id??null,weight_used:n.weight_used||0,slicer_filament:n.slicer_filament||"",note:n.note||""}),k(n.slicer_filament_name||n.slicer_filament||""),n.k_profiles&&n.k_profiles.length>0){const V=new Set;for(const W of n.k_profiles)W.cali_idx!==null&&W.cali_idx!==void 0&&V.add(`${W.printer_id}:${W.cali_idx}:${W.extruder??"null"}`);Y(V)}else Y(new Set);else u(hK),k(""),Y(new Set);h({}),p("filament"),y(!1)}},[t,n]),w.useEffect(()=>{t&&X.length>0&&$(new Set(X.map(V=>String(V.printer.id))))},[t,X]);const me=(V,W)=>{u(ue=>({...ue,[V]:W})),V==="weight_used"&&y(!0),d[V]&&h(ue=>({...ue,[V]:void 0}))},je=V=>{G(W=>yJe(V,W))},de=ot({mutationFn:V=>re.createSpool(V),onSuccess:async V=>{K.size>0&&V?.id&&await Se(V.id),await s.invalidateQueries({queryKey:["inventory-spools"]}),o(i("inventory.spoolCreated"),"success"),e()},onError:V=>{o(V.message,"error")}}),ce=ot({mutationFn:V=>re.updateSpool(n.id,V),onSuccess:async()=>{n?.id&&await Se(n.id),await s.invalidateQueries({queryKey:["inventory-spools"]}),o(i("inventory.spoolUpdated"),"success"),e()},onError:V=>{o(V.message,"error")}}),Se=async V=>{if(K.size===0){try{await re.saveSpoolKProfiles(V,[])}catch{}return}const W=[];for(const ue of K){const[Q,se,Z]=ue.split(":"),Ne=parseInt(Q),ve=parseInt(se),fe=Z==="null"?0:parseInt(Z),L=X.find(D=>D.printer.id===Ne);if(L){const D=L.calibrations.find(H=>H.cali_idx===ve);D&&W.push({printer_id:Ne,extruder:fe,nozzle_diameter:D.nozzle_diameter||"0.4",k_value:D.k_value,name:D.name||null,cali_idx:D.cali_idx,setting_id:D.setting_id||null})}}if(W.length>0)try{await re.saveSpoolKProfiles(V,W)}catch(ue){console.error("Failed to save K-profiles:",ue)}};if(w.useEffect(()=>{if(!t)return;const V=W=>{W.key==="Escape"&&e()};return document.addEventListener("keydown",V),()=>document.removeEventListener("keydown",V)},[t,e]),!t)return null;const ie=()=>{const V=lJe(c);if(!V.isValid){h(V.errors),(V.errors.slicer_filament||V.errors.material)&&p("filament");return}const W=pe?.displayName||T||null,ue={material:c.material,subtype:c.subtype||null,brand:c.brand||null,color_name:c.color_name||null,rgba:c.rgba||null,label_weight:c.label_weight,core_weight:c.core_weight,core_weight_catalog_id:c.core_weight_catalog_id,slicer_filament:c.slicer_filament||null,slicer_filament_name:W,nozzle_temp_min:null,nozzle_temp_max:null,note:c.note||null};(!l||x)&&(ue.weight_used=c.weight_used),l?ce.mutate(ue):de.mutate(ue)},Fe=de.isPending||ce.isPending;return a.jsxs("div",{className:"fixed inset-0 z-50 flex items-center justify-center",children:[a.jsx("div",{className:"absolute inset-0 bg-black/60 backdrop-blur-sm",onClick:e}),a.jsxs("div",{className:"relative w-full max-w-lg mx-4 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-xl shadow-2xl max-h-[90vh] flex flex-col",children:[a.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-bambu-dark-tertiary flex-shrink-0",children:[a.jsx("h2",{className:"text-lg font-semibold text-white",children:i(l?"inventory.editSpool":"inventory.addSpool")}),a.jsx("button",{onClick:e,className:"p-1 text-bambu-gray hover:text-white rounded transition-colors",children:a.jsx(Ft,{className:"w-5 h-5"})})]}),a.jsxs("div",{className:"flex border-b border-bambu-dark-tertiary flex-shrink-0",children:[a.jsxs("button",{onClick:()=>p("filament"),className:`flex-1 px-4 py-2.5 text-sm font-medium flex items-center justify-center gap-2 transition-colors ${f==="filament"?"text-bambu-green border-b-2 border-bambu-green":"text-bambu-gray hover:text-white"}`,children:[a.jsx(aC,{className:"w-4 h-4"}),i("inventory.filamentInfoTab")]}),a.jsxs("button",{onClick:()=>p("pa-profile"),className:`flex-1 px-4 py-2.5 text-sm font-medium flex items-center justify-center gap-2 transition-colors ${f==="pa-profile"?"text-bambu-green border-b-2 border-bambu-green":"text-bambu-gray hover:text-white"}`,children:[a.jsx(Nde,{className:"w-4 h-4"}),i("inventory.paProfileTab"),ee>0&&a.jsx("span",{className:"text-xs px-1.5 py-0.5 rounded-full bg-bambu-green/20 text-bambu-green",children:ee})]})]}),a.jsx("div",{className:"p-4 overflow-y-auto flex-1",style:{scrollbarGutter:"stable"},children:f==="filament"?a.jsxs("div",{className:"space-y-6",children:[a.jsxs("div",{children:[a.jsx("h3",{className:"text-sm font-semibold text-bambu-gray uppercase tracking-wide mb-3",children:i("inventory.filamentInfo")}),a.jsx(vJe,{formData:c,updateField:me,cloudAuthenticated:b,loadingCloudPresets:S,presetInputValue:T,setPresetInputValue:k,selectedPresetOption:pe,filamentOptions:J,availableBrands:_e}),d.slicer_filament&&a.jsx("p",{className:"mt-1 text-xs text-red-400",children:d.slicer_filament}),d.material&&a.jsx("p",{className:"mt-1 text-xs text-red-400",children:d.material})]}),a.jsxs("div",{children:[a.jsx("h3",{className:"text-sm font-semibold text-bambu-gray uppercase tracking-wide mb-3",children:i("inventory.color")}),a.jsx(wJe,{formData:c,updateField:me,recentColors:R,onColorUsed:je,catalogColors:O})]}),a.jsxs("div",{children:[a.jsx("h3",{className:"text-sm font-semibold text-bambu-gray uppercase tracking-wide mb-3",children:i("inventory.additional")}),a.jsx(SJe,{formData:c,updateField:me,spoolCatalog:j})]}),l&&n&&a.jsx("div",{children:a.jsx(MJe,{spoolId:n.id})})]}):a.jsx(NJe,{formData:c,updateField:me,printersWithCalibrations:X,selectedProfiles:K,setSelectedProfiles:Y,expandedPrinters:oe,setExpandedPrinters:$})}),a.jsxs("div",{className:"flex justify-end gap-2 p-4 border-t border-bambu-dark-tertiary flex-shrink-0",children:[a.jsx(Ce,{variant:"secondary",onClick:e,children:i("common.cancel")}),a.jsx(Ce,{onClick:ie,disabled:Fe,children:Fe?a.jsxs(a.Fragment,{children:[a.jsx(it,{className:"w-4 h-4 animate-spin"}),i("common.saving")]}):a.jsxs(a.Fragment,{children:[a.jsx(bs,{className:"w-4 h-4"}),i(l?"common.save":"inventory.addSpool")]})})]})]})]})}function TJe({isOpen:t,onClose:e,columns:n,defaultColumns:r,onSave:i}){const{t:s}=Vt(),[o,l]=w.useState(n),[c,u]=w.useState(null),d=w.useRef(null);if(w.useEffect(()=>{t&&l(n.map(A=>({...A})))},[t,n]),w.useEffect(()=>{if(!t)return;const A=C=>{C.key==="Escape"&&e()};return window.addEventListener("keydown",A),()=>window.removeEventListener("keydown",A)},[t,e]),!t)return null;const h=A=>{l(C=>C.map((T,k)=>k===A?{...T,visible:!T.visible}:T))},f=(A,C)=>{C<0||C>=o.length||l(T=>{const k=[...T],[j]=k.splice(A,1);return k.splice(C,0,j),k})},p=(A,C)=>{d.current=C,u(C),A.dataTransfer.effectAllowed="move"},x=(A,C)=>{A.preventDefault(),A.dataTransfer.dropEffect="move";const T=d.current;T!==null&&T!==C&&(f(T,C),d.current=C,u(C))},y=A=>{A.preventDefault()},b=()=>{d.current=null,u(null)},v=()=>{l(r.map(A=>({...A})))},S=()=>{i(o),e()},N=o.filter(A=>A.visible).length;return a.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4",onClick:e,children:a.jsx(vt,{className:"w-full max-w-md max-h-[80vh] flex flex-col",onClick:A=>A.stopPropagation(),children:a.jsxs(Nt,{className:"p-6 flex flex-col min-h-0",children:[a.jsx("h3",{className:"text-lg font-semibold text-white mb-2",children:s("inventory.configureColumns")}),a.jsxs("p",{className:"text-sm text-bambu-gray mb-4",children:[s("inventory.configureColumnsDesc"),a.jsxs("span",{className:"ml-2 text-bambu-gray/60",children:["(",N," ",s("inventory.of")," ",o.length," ",s("inventory.visible"),")"]})]}),a.jsx("div",{className:"space-y-1 overflow-y-auto flex-1 min-h-0 pr-1",children:o.map((A,C)=>a.jsxs("div",{className:`flex items-center gap-2 p-2 rounded-lg border transition-colors ${c===C?"border-bambu-green bg-bambu-green/10":"border-bambu-dark-tertiary bg-bambu-dark-tertiary/50"} ${A.visible?"":"opacity-50"}`,draggable:!0,onDragStart:T=>p(T,C),onDragOver:T=>x(T,C),onDrop:y,onDragEnd:b,children:[a.jsx("div",{className:"cursor-grab text-bambu-gray/50 hover:text-bambu-gray",children:a.jsx(Dh,{className:"w-4 h-4"})}),a.jsx("span",{className:"flex-1 font-medium text-sm text-white",children:A.label}),a.jsxs("div",{className:"flex items-center gap-0.5",children:[a.jsx("button",{onClick:()=>f(C,C-1),disabled:C===0,className:"p-1 rounded text-bambu-gray hover:bg-bambu-dark-secondary disabled:opacity-30 disabled:cursor-not-allowed",title:s("inventory.moveUp"),children:a.jsx(Wl,{className:"w-4 h-4"})}),a.jsx("button",{onClick:()=>f(C,C+1),disabled:C===o.length-1,className:"p-1 rounded text-bambu-gray hover:bg-bambu-dark-secondary disabled:opacity-30 disabled:cursor-not-allowed",title:s("inventory.moveDown"),children:a.jsx(nr,{className:"w-4 h-4"})})]}),a.jsx("button",{onClick:()=>h(C),className:`p-1.5 rounded transition-colors ${A.visible?"text-bambu-green hover:bg-bambu-green/10":"text-bambu-gray/50 hover:bg-bambu-dark-secondary"}`,title:A.visible?s("inventory.hideColumn"):s("inventory.showColumn"),children:A.visible?a.jsx(Xl,{className:"w-4 h-4"}):a.jsx(gv,{className:"w-4 h-4"})})]},A.id))}),a.jsxs("div",{className:"flex items-center gap-3 mt-4 pt-4 border-t border-bambu-dark-tertiary",children:[a.jsxs(Ce,{variant:"secondary",onClick:v,className:"mr-auto",children:[a.jsx(Ro,{className:"w-4 h-4"}),s("inventory.reset")]}),a.jsx(Ce,{variant:"secondary",onClick:e,children:s("inventory.cancel")}),a.jsx(Ce,{onClick:S,children:s("inventory.applyChanges")})]})]})})})}const ese="bambuddy-inventory-columns",S1=[{id:"id",label:"#",visible:!0},{id:"added_time",label:"Added",visible:!0},{id:"encode_time",label:"Encoded",visible:!1},{id:"last_used_time",label:"Last Used",visible:!1},{id:"rgba",label:"Color",visible:!0},{id:"material",label:"Material",visible:!0},{id:"subtype",label:"Subtype",visible:!0},{id:"color_name",label:"Color Name",visible:!1},{id:"brand",label:"Brand",visible:!0},{id:"slicer_filament",label:"Slicer Filament",visible:!1},{id:"location",label:"Location",visible:!0},{id:"label_weight",label:"Label",visible:!0},{id:"net",label:"Net",visible:!0},{id:"gross",label:"Gross",visible:!1},{id:"added_full",label:"Full",visible:!1},{id:"used",label:"Used",visible:!1},{id:"printed_total",label:"Printed Total",visible:!1},{id:"printed_since_weight",label:"Printed Since Weight",visible:!1},{id:"note",label:"Note",visible:!1},{id:"pa_k",label:"PA(K)",visible:!0},{id:"tag_id",label:"Tag ID",visible:!1},{id:"data_origin",label:"Data Origin",visible:!1},{id:"tag_type",label:"Linked Tag Type",visible:!1},{id:"remaining",label:"Remaining",visible:!0}];function EJe(){try{const t=localStorage.getItem(ese);if(t){const e=JSON.parse(t),n=new Set(S1.map(o=>o.id)),r=new Set(e.map(o=>o.id)),i=e.filter(o=>n.has(o.id)),s=S1.filter(o=>!r.has(o.id));return[...i,...s]}}catch{}return S1.map(t=>({...t}))}function PJe(t){try{localStorage.setItem(ese,JSON.stringify(t))}catch{}}function Lu(t,e=!1){return e&&t>=1e3?`${(t/1e3).toFixed(1)}kg`:`${Math.round(t)}g`}const jJe={PLA:"bg-green-500/20 text-green-400",ABS:"bg-red-500/20 text-red-400",PETG:"bg-blue-500/20 text-blue-400",TPU:"bg-purple-500/20 text-purple-400",ASA:"bg-orange-500/20 text-orange-400",PA:"bg-yellow-500/20 text-yellow-400",PC:"bg-cyan-500/20 text-cyan-400",PET:"bg-sky-500/20 text-sky-400"};function Xj(t){return t?new Date(t).toLocaleDateString("en-GB",{day:"2-digit",month:"2-digit",year:"2-digit"}):"-"}const DJe={id:()=>"#",added_time:()=>"Added",encode_time:()=>"Encoded",last_used_time:()=>"Last Used",rgba:t=>t("inventory.color"),material:t=>t("inventory.material"),subtype:t=>t("inventory.subtype"),color_name:t=>t("inventory.colorName"),brand:t=>t("inventory.brand"),slicer_filament:t=>t("inventory.slicerFilament"),location:()=>"Location",label_weight:t=>t("inventory.labelWeight"),net:t=>t("inventory.net"),gross:()=>"Gross",added_full:()=>"Full",used:t=>t("inventory.weightUsed"),printed_total:()=>"Printed Total",printed_since_weight:()=>"Printed Since Weight",note:t=>t("inventory.note"),pa_k:()=>"PA(K)",tag_id:()=>"Tag ID",data_origin:()=>"Data Origin",tag_type:()=>"Linked Tag Type",remaining:t=>t("inventory.remaining")},RJe={id:({spool:t})=>a.jsx("span",{className:"text-sm font-medium text-white",children:t.id}),added_time:({spool:t})=>a.jsx("span",{className:"text-sm text-bambu-gray",children:Xj(t.created_at)}),encode_time:({spool:t})=>a.jsx("span",{className:"text-sm text-bambu-gray",children:Xj(t.encode_time)}),last_used_time:({spool:t})=>a.jsx("span",{className:"text-sm text-bambu-gray",children:t.last_used?Xj(t.last_used):"Never"}),rgba:({spool:t})=>a.jsx("div",{className:"flex items-center justify-center",children:a.jsx("span",{className:"w-5 h-5 rounded-full border border-white/20 flex-shrink-0",style:{backgroundColor:t.rgba?`#${t.rgba.substring(0,6)}`:"#808080"},title:t.rgba?`#${t.rgba.substring(0,6)}`:void 0})}),material:({spool:t})=>a.jsx("span",{className:"text-sm text-white",children:t.material}),subtype:({spool:t})=>a.jsx("span",{className:"text-sm text-bambu-gray",children:t.subtype||"-"}),color_name:({spool:t})=>a.jsx("span",{className:"text-sm text-bambu-gray",children:bne(t.color_name,t.rgba)||"-"}),brand:({spool:t})=>a.jsx("span",{className:"text-sm text-bambu-gray",children:t.brand||"-"}),slicer_filament:({spool:t})=>a.jsx("span",{className:"text-sm text-bambu-gray",title:t.slicer_filament||void 0,children:t.slicer_filament_name||t.slicer_filament||"-"}),location:({spool:t,assignmentMap:e})=>{const n=e[t.id];if(!n)return a.jsx("span",{className:"text-sm text-bambu-gray",children:"-"});const r=n.printer_name||`Printer ${n.printer_id}`,i=String.fromCharCode(65+n.ams_id),s=n.tray_id+1;return a.jsxs("span",{className:"inline-flex items-center px-1.5 py-0.5 rounded text-xs font-medium bg-purple-500/20 text-purple-400",children:[r," ",i,s]})},label_weight:({spool:t})=>a.jsx("span",{className:"text-sm text-white",children:Lu(t.label_weight)}),net:({remaining:t})=>a.jsx("span",{className:"text-sm text-white",children:Lu(t)}),gross:({spool:t,remaining:e})=>a.jsx("span",{className:"text-sm text-bambu-gray",children:Lu(e+t.core_weight)}),added_full:({spool:t})=>a.jsx("span",{className:"text-sm text-bambu-gray",children:t.added_full==null?"-":t.added_full?"Yes":"No"}),used:({spool:t})=>a.jsx("span",{className:"text-sm text-bambu-gray",children:t.weight_used>0?Lu(t.weight_used):"-"}),printed_total:()=>a.jsx("span",{className:"text-sm text-bambu-gray/50",children:"-"}),printed_since_weight:()=>a.jsx("span",{className:"text-sm text-bambu-gray/50",children:"-"}),note:({spool:t})=>a.jsx("span",{className:"text-sm text-bambu-gray max-w-[150px] truncate block",title:t.note||void 0,children:t.note||"-"}),pa_k:({spool:t})=>(t.k_profiles?.length??0)===0?a.jsx("span",{className:"text-sm text-bambu-gray",children:"-"}):a.jsx("span",{className:"inline-flex items-center px-1.5 py-0.5 rounded text-xs font-medium bg-bambu-green/20 text-bambu-green",children:"K"}),tag_id:({spool:t})=>{const e=t.tag_uid||t.tray_uuid;return e?a.jsx("span",{className:"text-sm text-bambu-gray font-mono",title:e,children:e.length>12?`${e.slice(0,6)}...${e.slice(-4)}`:e}):a.jsx("span",{className:"text-sm text-bambu-gray/50",children:"-"})},data_origin:({spool:t})=>a.jsx("span",{className:"text-sm text-bambu-gray",children:t.data_origin||"-"}),tag_type:({spool:t})=>a.jsx("span",{className:"text-sm text-bambu-gray",children:t.tag_type||"-"}),remaining:({remaining:t,pct:e})=>a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx("div",{className:"flex-1 h-2 bg-bambu-dark-tertiary rounded-full overflow-hidden",children:a.jsx("div",{className:`h-full rounded-full ${e>50?"bg-bambu-green":e>20?"bg-yellow-500":"bg-red-500"}`,style:{width:`${Math.min(e,100)}%`}})}),a.jsxs("span",{className:"text-xs text-bambu-gray min-w-[40px] text-right",children:[Math.round(t),"g"]})]})},Yj={id:t=>t.id,added_time:t=>t.created_at||"",encode_time:t=>t.encode_time||"",last_used_time:t=>t.last_used||"",material:t=>(t.material||"").toLowerCase(),subtype:t=>(t.subtype||"").toLowerCase(),color_name:t=>(t.color_name||"").toLowerCase(),brand:t=>(t.brand||"").toLowerCase(),slicer_filament:t=>(t.slicer_filament_name||t.slicer_filament||"").toLowerCase(),location:(t,e)=>{const n=e[t.id];return n?`${n.printer_name||""} ${String.fromCharCode(65+n.ams_id)}${n.tray_id+1}`:""},label_weight:t=>t.label_weight,net:t=>Math.max(0,t.label_weight-t.weight_used),gross:t=>Math.max(0,t.label_weight-t.weight_used)+t.core_weight,used:t=>t.weight_used,remaining:t=>t.label_weight>0?Math.max(0,t.label_weight-t.weight_used)/t.label_weight:0,note:t=>(t.note||"").toLowerCase(),data_origin:t=>(t.data_origin||"").toLowerCase(),tag_type:t=>(t.tag_type||"").toLowerCase()},gF="bambuddy-inventory-sort";function FJe(){try{const t=localStorage.getItem(gF);if(t)return JSON.parse(t)}catch{}return null}function LJe(t){try{t?localStorage.setItem(gF,JSON.stringify(t)):localStorage.removeItem(gF)}catch{}}function OJe(){const{t}=Vt(),e=tn(),{showToast:n}=hn(),[r,i]=w.useState(null),[s,o]=w.useState(null),[l,c]=w.useState("active"),[u,d]=w.useState("all"),[h,f]=w.useState(""),[p,x]=w.useState(""),[y,b]=w.useState(""),[v,S]=w.useState("table"),[N,A]=w.useState(FJe),[C,T]=w.useState(EJe),[k,j]=w.useState(!1),[E,P]=w.useState(0),[U,O]=w.useState(()=>{try{const Z=localStorage.getItem("bambuddy-inventory-pageSize");if(Z){const Ne=Number(Z);if([15,30,50,100,-1].includes(Ne))return Ne}}catch{}return 15}),{data:B,isLoading:R}=Ze({queryKey:["inventory-spools"],queryFn:()=>re.getSpools(!0),refetchInterval:3e4}),{data:G}=Ze({queryKey:["spool-assignments"],queryFn:()=>re.getAssignments(),refetchInterval:3e4}),q=ot({mutationFn:Z=>re.deleteSpool(Z),onSuccess:()=>{e.invalidateQueries({queryKey:["inventory-spools"]}),n(t("inventory.spoolDeleted"),"success")}}),z=ot({mutationFn:Z=>re.archiveSpool(Z),onSuccess:()=>{e.invalidateQueries({queryKey:["inventory-spools"]}),n(t("inventory.spoolArchived"),"success")}}),K=ot({mutationFn:Z=>re.restoreSpool(Z),onSuccess:()=>{e.invalidateQueries({queryKey:["inventory-spools"]}),n(t("inventory.spoolRestored"),"success")}}),Y=w.useMemo(()=>{if(!B)return null;let Z=0,Ne=0,ve=0,fe=0;const L={};for(const D of B){if(D.archived_at)continue;fe++;const H=Math.max(0,D.label_weight-D.weight_used);Z+=H,Ne+=D.weight_used,(D.label_weight>0?H/D.label_weight*100:0)<20&&ve++;const xe=D.material||"Unknown";L[xe]||(L[xe]={count:0,weight:0}),L[xe].count++,L[xe].weight+=H}return{totalWeight:Z,totalConsumed:Ne,lowStock:ve,byMaterial:L,totalSpools:fe}},[B]),oe=G?.length??0,$=w.useMemo(()=>{const Z={};for(const Ne of G||[])Z[Ne.spool_id]=Ne;return Z},[G]),X=w.useMemo(()=>Y?Object.entries(Y.byMaterial).sort((Z,Ne)=>Ne[1].weight-Z[1].weight).slice(0,4):[],[Y]),ee=w.useMemo(()=>{let Z=B||[];if(l==="active"?Z=Z.filter(Ne=>!Ne.archived_at):Z=Z.filter(Ne=>!!Ne.archived_at),u==="used"?Z=Z.filter(Ne=>Ne.weight_used>0):u==="new"&&(Z=Z.filter(Ne=>Ne.weight_used===0)),h&&(Z=Z.filter(Ne=>Ne.material===h)),p&&(Z=Z.filter(Ne=>Ne.brand===p)),y){const Ne=y.toLowerCase();Z=Z.filter(ve=>ve.brand?.toLowerCase().includes(Ne)||ve.material.toLowerCase().includes(Ne)||ve.color_name?.toLowerCase().includes(Ne)||ve.subtype?.toLowerCase().includes(Ne)||ve.note?.toLowerCase().includes(Ne)||ve.slicer_filament_name?.toLowerCase().includes(Ne))}return Z},[B,l,u,h,p,y]),J=()=>P(0),_e=[...new Set(B?.map(Z=>Z.material)||[])].sort(),pe=[...new Set(B?.map(Z=>Z.brand).filter(Boolean)||[])].sort(),me=l!=="active"||u!=="all"||!!h||!!p||!!y,je=Z=>{T(Z),PJe(Z)},de=w.useMemo(()=>C.filter(Z=>Z.visible).map(Z=>Z.id),[C]),ce=Z=>{Yj[Z]&&(A(Ne=>{let ve;return Ne?.column===Z?ve=Ne.direction==="asc"?{column:Z,direction:"desc"}:null:ve={column:Z,direction:"asc"},LJe(ve),ve}),J())},Se=w.useMemo(()=>{if(!N)return ee;const Z=Yj[N.column];return Z?[...ee].sort((ve,fe)=>{const L=Z(ve,$),D=Z(fe,$);return LD?N.direction==="asc"?1:-1:0}):ee},[ee,N,$]),ie=U===-1,Fe=ie?Se.length||1:U,V=Math.max(1,Math.ceil(Se.length/Fe)),W=ie?0:Math.min(E,V-1),ue=ie?Se:Se.slice(W*Fe,(W+1)*Fe),Q=Z=>{O(Z),P(0);try{localStorage.setItem("bambuddy-inventory-pageSize",String(Z))}catch{}},se=()=>{c("active"),d("all"),f(""),x(""),b(""),J()};return a.jsxs("div",{className:"p-4 md:p-6 space-y-6",children:[a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsxs("div",{children:[a.jsxs("div",{className:"flex items-center gap-3",children:[a.jsx(fa,{className:"w-6 h-6 text-bambu-green"}),a.jsx("h1",{className:"text-2xl font-bold text-white",children:t("inventory.title")})]}),a.jsx("p",{className:"text-sm text-bambu-gray mt-1 ml-9",children:(t("inventory.noSpools").split(".")[0],"")})]}),a.jsxs(Ce,{onClick:()=>i({spool:null}),children:[a.jsx(ar,{className:"w-4 h-4"}),t("inventory.addSpool")]})]}),Y&&!R&&a.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-3 lg:grid-cols-5 gap-3",children:[a.jsxs("div",{className:"bg-bambu-dark-secondary rounded-lg p-4",children:[a.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[a.jsx(fa,{className:"w-4 h-4 text-bambu-green"}),a.jsx("span",{className:"text-xs text-bambu-gray font-medium uppercase tracking-wide",children:t("inventory.totalInventory")})]}),a.jsx("div",{className:"text-xl font-bold text-white",children:Lu(Y.totalWeight,!0)}),a.jsxs("div",{className:"text-xs text-bambu-gray mt-1",children:[Y.totalSpools," ",Y.totalSpools!==1?t("inventory.spools"):t("inventory.spool")]})]}),a.jsxs("div",{className:"bg-bambu-dark-secondary rounded-lg p-4",children:[a.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[a.jsx(zF,{className:"w-4 h-4 text-blue-400"}),a.jsx("span",{className:"text-xs text-bambu-gray font-medium uppercase tracking-wide",children:t("inventory.totalConsumed")})]}),a.jsx("div",{className:"text-xl font-bold text-white",children:Lu(Y.totalConsumed,!0)}),a.jsx("div",{className:"text-xs text-bambu-gray mt-1",children:t("inventory.sinceTracking")})]}),a.jsxs("div",{className:"bg-bambu-dark-secondary rounded-lg p-4",children:[a.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[a.jsx(ma,{className:"w-4 h-4 text-green-400"}),a.jsx("span",{className:"text-xs text-bambu-gray font-medium uppercase tracking-wide",children:t("inventory.byMaterial")})]}),a.jsx("div",{className:"flex flex-wrap gap-1.5 mt-1",children:X.map(([Z,Ne])=>a.jsxs("span",{className:`inline-flex items-center gap-1 px-2 py-0.5 rounded-full text-xs font-medium ${jJe[Z]||"bg-bambu-dark-tertiary text-bambu-gray"}`,children:[Z," ",a.jsx("span",{className:"opacity-70",children:Lu(Ne.weight,!0)})]},Z))})]}),a.jsxs("div",{className:"bg-bambu-dark-secondary rounded-lg p-4",children:[a.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[a.jsx(Cr,{className:"w-4 h-4 text-purple-400"}),a.jsx("span",{className:"text-xs text-bambu-gray font-medium uppercase tracking-wide",children:t("inventory.inPrinter")})]}),a.jsx("div",{className:"text-xl font-bold text-white",children:oe}),a.jsx("div",{className:"text-xs text-bambu-gray mt-1",children:t("inventory.loadedInAms")})]}),a.jsxs("div",{className:"bg-bambu-dark-secondary rounded-lg p-4",children:[a.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[a.jsx(Cn,{className:"w-4 h-4 text-yellow-400"}),a.jsx("span",{className:"text-xs text-bambu-gray font-medium uppercase tracking-wide",children:t("inventory.lowStock")})]}),a.jsx("div",{className:`text-xl font-bold ${Y.lowStock>0?"text-yellow-400":"text-white"}`,children:Y.lowStock}),a.jsx("div",{className:"text-xs text-bambu-gray mt-1",children:t("inventory.lowStockThreshold")})]})]}),a.jsxs("div",{className:"flex flex-col sm:flex-row gap-3 items-start sm:items-center justify-between",children:[a.jsxs("div",{className:"relative flex-1 max-w-md",children:[a.jsx(Or,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray/50"}),a.jsx("input",{type:"text",value:y,onChange:Z=>{b(Z.target.value),J()},placeholder:t("inventory.search"),className:"w-full pl-10 pr-8 py-2 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg text-white text-sm placeholder:text-bambu-gray/50 focus:outline-none focus:border-bambu-green"}),y&&a.jsx("button",{onClick:()=>{b(""),J()},className:"absolute right-3 top-1/2 -translate-y-1/2 text-bambu-gray hover:text-white",children:a.jsx(Ft,{className:"w-4 h-4"})})]}),a.jsxs("div",{className:"flex items-center gap-2",children:[v==="table"&&a.jsxs("button",{onClick:()=>j(!0),className:"flex items-center gap-1.5 px-3 py-1.5 text-sm font-medium text-bambu-gray border border-bambu-dark-tertiary rounded-lg hover:bg-bambu-dark-tertiary transition-colors",title:t("inventory.configureColumns"),children:[a.jsx(_he,{className:"w-4 h-4"}),a.jsx("span",{className:"hidden sm:inline",children:t("inventory.columns")})]}),a.jsxs("div",{className:"flex bg-bambu-dark-primary border border-bambu-dark-tertiary rounded-lg overflow-hidden",children:[a.jsxs("button",{onClick:()=>S("table"),className:`flex items-center gap-1.5 px-3 py-1.5 text-sm font-medium transition-colors ${v==="table"?"bg-bambu-green text-white":"text-bambu-gray hover:bg-bambu-dark-tertiary"}`,children:[a.jsx(ipe,{className:"w-4 h-4"}),a.jsx("span",{className:"hidden sm:inline",children:t("inventory.table")})]}),a.jsxs("button",{onClick:()=>S("cards"),className:`flex items-center gap-1.5 px-3 py-1.5 text-sm font-medium transition-colors ${v==="cards"?"bg-bambu-green text-white":"text-bambu-gray hover:bg-bambu-dark-tertiary"}`,children:[a.jsx(xv,{className:"w-4 h-4"}),a.jsx("span",{className:"hidden sm:inline",children:t("inventory.cards")})]})]})]})]}),a.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[a.jsxs("div",{className:"flex items-center rounded-lg border border-bambu-dark-tertiary overflow-hidden",children:[a.jsxs("button",{onClick:()=>{c("active"),J()},className:`flex items-center gap-1.5 px-3 py-1.5 text-xs font-medium transition-colors ${l==="active"?"bg-bambu-green/20 text-bambu-green":"text-bambu-gray hover:bg-bambu-dark-tertiary"}`,children:[a.jsx(fa,{className:"w-3.5 h-3.5"}),t("inventory.active")]}),a.jsxs("button",{onClick:()=>{c("archived"),J()},className:`flex items-center gap-1.5 px-3 py-1.5 text-xs font-medium transition-colors ${l==="archived"?"bg-bambu-green/20 text-bambu-green":"text-bambu-gray hover:bg-bambu-dark-tertiary"}`,children:[a.jsx(Rs,{className:"w-3.5 h-3.5"}),t("inventory.archived")]})]}),a.jsx("div",{className:"w-px h-5 bg-bambu-dark-tertiary"}),a.jsxs("div",{className:"flex items-center rounded-lg border border-bambu-dark-tertiary overflow-hidden",children:[a.jsx("button",{onClick:()=>{d("all"),J()},className:`px-3 py-1.5 text-xs font-medium transition-colors ${u==="all"?"bg-bambu-green/20 text-bambu-green":"text-bambu-gray hover:bg-bambu-dark-tertiary"}`,children:t("inventory.all")}),a.jsxs("button",{onClick:()=>{d("used"),J()},className:`flex items-center gap-1.5 px-3 py-1.5 text-xs font-medium transition-colors ${u==="used"?"bg-bambu-green/20 text-bambu-green":"text-bambu-gray hover:bg-bambu-dark-tertiary"}`,children:[a.jsx(Wn,{className:"w-3.5 h-3.5"}),t("inventory.used")]}),a.jsx("button",{onClick:()=>{d("new"),J()},className:`px-3 py-1.5 text-xs font-medium transition-colors ${u==="new"?"bg-bambu-green/20 text-bambu-green":"text-bambu-gray hover:bg-bambu-dark-tertiary"}`,children:t("inventory.new")})]}),a.jsx("div",{className:"w-px h-5 bg-bambu-dark-tertiary"}),a.jsxs("select",{value:h,onChange:Z=>{f(Z.target.value),J()},className:`px-3 py-1.5 rounded-lg border text-xs font-medium transition-colors cursor-pointer focus:outline-none ${h?"bg-bambu-green/20 text-bambu-green border-bambu-green/30":"bg-transparent text-bambu-gray border-bambu-dark-tertiary hover:bg-bambu-dark-tertiary"}`,children:[a.jsx("option",{value:"",children:t("inventory.material")}),_e.map(Z=>a.jsx("option",{value:Z,children:Z},Z))]}),a.jsxs("select",{value:p,onChange:Z=>{x(Z.target.value),J()},className:`px-3 py-1.5 rounded-lg border text-xs font-medium transition-colors cursor-pointer focus:outline-none ${p?"bg-bambu-green/20 text-bambu-green border-bambu-green/30":"bg-transparent text-bambu-gray border-bambu-dark-tertiary hover:bg-bambu-dark-tertiary"}`,children:[a.jsx("option",{value:"",children:t("inventory.brand")}),pe.map(Z=>a.jsx("option",{value:Z,children:Z},Z))]}),me&&a.jsxs(a.Fragment,{children:[a.jsx("div",{className:"w-px h-5 bg-bambu-dark-tertiary"}),a.jsxs("button",{onClick:se,className:"flex items-center gap-1 text-xs text-bambu-gray hover:text-bambu-green transition-colors",children:[a.jsx(Ft,{className:"w-3.5 h-3.5"}),t("inventory.clearFilters")]})]}),a.jsxs("span",{className:"ml-auto text-xs text-bambu-gray",children:[Se.length," ",Se.length!==1?t("inventory.spools"):t("inventory.spool")]})]}),R?a.jsx("div",{className:"flex justify-center py-16",children:a.jsx(it,{className:"w-8 h-8 text-bambu-green animate-spin"})}):v==="cards"?ue.length>0?a.jsxs(a.Fragment,{children:[a.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4 gap-4",children:ue.map(Z=>{const Ne=Math.max(0,Z.label_weight-Z.weight_used),ve=Z.label_weight>0?Ne/Z.label_weight*100:0,fe=Z.rgba?`#${Z.rgba.substring(0,6)}`:"#808080";return a.jsxs("div",{className:`bg-bambu-dark-secondary rounded-lg overflow-hidden border border-bambu-dark-tertiary hover:border-bambu-green transition-colors cursor-pointer ${Z.archived_at?"opacity-50":""}`,onClick:()=>i({spool:Z}),children:[a.jsx("div",{className:"h-14 flex items-center justify-center",style:{backgroundColor:fe},children:a.jsx("span",{className:"bg-white/90 text-gray-800 px-3 py-0.5 rounded-full text-sm font-medium",children:bne(Z.color_name,Z.rgba)||"-"})}),a.jsxs("div",{className:"p-4 space-y-3",children:[a.jsxs("div",{className:"flex items-start justify-between gap-2",children:[a.jsxs("div",{children:[a.jsxs("h3",{className:"font-semibold text-white",children:[Z.material,Z.subtype?` ${Z.subtype}`:""]}),a.jsx("p",{className:"text-sm text-bambu-gray",children:Z.brand||"-"})]}),a.jsxs("span",{className:"text-xs font-mono text-bambu-gray bg-bambu-dark-tertiary px-2 py-1 rounded",children:["#",Z.id]})]}),a.jsxs("div",{children:[a.jsxs("div",{className:"flex justify-between text-xs text-bambu-gray mb-1",children:[a.jsx("span",{children:t("inventory.remaining")}),a.jsxs("span",{children:[Math.round(ve),"%"]})]}),a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx("div",{className:"flex-1 h-2 bg-bambu-dark-tertiary rounded-full overflow-hidden",children:a.jsx("div",{className:`h-full rounded-full ${ve>50?"bg-bambu-green":ve>20?"bg-yellow-500":"bg-red-500"}`,style:{width:`${Math.min(ve,100)}%`}})}),a.jsxs("span",{className:"text-xs text-bambu-gray min-w-[40px] text-right",children:[Math.round(Ne),"g"]})]})]}),a.jsxs("div",{className:"grid grid-cols-2 gap-2 text-xs",children:[a.jsxs("div",{children:[a.jsxs("span",{className:"text-bambu-gray/60",children:[t("inventory.labelWeight"),": "]}),a.jsx("span",{className:"text-bambu-gray",children:Lu(Z.label_weight)})]}),a.jsxs("div",{children:[a.jsxs("span",{className:"text-bambu-gray/60",children:[t("inventory.weightUsed"),": "]}),a.jsx("span",{className:"text-bambu-gray",children:Z.weight_used>0?Lu(Z.weight_used):"-"})]})]}),Z.note&&a.jsx("div",{className:"text-xs text-bambu-gray/60 pt-2 border-t border-bambu-dark-tertiary truncate",title:Z.note,children:Z.note})]})]},Z.id)})}),a.jsx(IJe,{pageIndex:W,pageSize:U,totalRows:Se.length,totalPages:V,onPageChange:P,onPageSizeChange:Q,t})]}):a.jsx(fK,{hasFilters:me,onAddSpool:()=>i({spool:null}),t}):ue.length>0?a.jsxs("div",{className:"bg-bambu-dark-secondary rounded-lg overflow-hidden border border-bambu-dark-tertiary",children:[a.jsx("div",{className:"overflow-x-auto",children:a.jsxs("table",{className:"w-full",children:[a.jsx("thead",{children:a.jsxs("tr",{className:"border-b border-bambu-dark-tertiary bg-bambu-dark-tertiary/30",children:[de.map(Z=>{const Ne=!!Yj[Z],ve=N?.column===Z;return a.jsx("th",{className:`text-left py-3 px-4 text-xs font-medium uppercase tracking-wide select-none ${Z==="remaining"?"min-w-[150px]":""} ${Ne?"cursor-pointer hover:text-bambu-green transition-colors":""} ${ve?"text-bambu-green":"text-bambu-gray"}`,onClick:Ne?()=>ce(Z):void 0,children:a.jsxs("span",{className:"inline-flex items-center gap-1",children:[DJe[Z]?.(t)??Z,Ne&&(ve?N.direction==="asc"?a.jsx(Pf,{className:"w-3 h-3"}):a.jsx(hb,{className:"w-3 h-3"}):a.jsx(RF,{className:"w-3 h-3 opacity-30"}))]})},Z)}),a.jsx("th",{className:"text-right py-3 px-4 text-xs font-medium text-bambu-gray uppercase tracking-wide",children:t("common.actions")})]})}),a.jsx("tbody",{children:ue.map(Z=>{const Ne=Math.max(0,Z.label_weight-Z.weight_used),ve=Z.label_weight>0?Ne/Z.label_weight*100:0;return a.jsxs("tr",{className:`border-b border-bambu-dark-tertiary/50 hover:bg-bambu-dark-tertiary/30 transition-colors cursor-pointer ${Z.archived_at?"opacity-50":""}`,onClick:()=>i({spool:Z}),children:[de.map(fe=>a.jsx("td",{className:"py-3 px-4",children:RJe[fe]?.({spool:Z,remaining:Ne,pct:ve,assignmentMap:$})},fe)),a.jsx("td",{className:"py-3 px-4",children:a.jsxs("div",{className:"flex items-center justify-end gap-1",onClick:fe=>fe.stopPropagation(),children:[a.jsx("button",{onClick:()=>i({spool:Z}),className:"p-1.5 text-bambu-gray hover:text-white rounded transition-colors",title:t("inventory.editSpool"),children:a.jsx(af,{className:"w-4 h-4"})}),Z.archived_at?a.jsx("button",{onClick:()=>K.mutate(Z.id),className:"p-1.5 text-bambu-gray hover:text-bambu-green rounded transition-colors",title:t("inventory.restore"),children:a.jsx(Ro,{className:"w-4 h-4"})}):a.jsx("button",{onClick:()=>o({type:"archive",spoolId:Z.id}),className:"p-1.5 text-bambu-gray hover:text-yellow-400 rounded transition-colors",title:t("inventory.archive"),children:a.jsx(Rs,{className:"w-4 h-4"})}),a.jsx("button",{onClick:()=>o({type:"delete",spoolId:Z.id}),className:"p-1.5 text-bambu-gray hover:text-red-400 rounded transition-colors",title:t("common.delete"),children:a.jsx(Jt,{className:"w-4 h-4"})})]})})]},Z.id)})})]})}),a.jsxs("div",{className:"flex items-center justify-between px-4 py-3 bg-bambu-dark-tertiary/50 border-t border-bambu-dark-tertiary text-sm",children:[a.jsx("span",{className:"text-bambu-gray",children:ie?`${Se.length} ${Se.length!==1?t("inventory.spools"):t("inventory.spool")}`:a.jsxs(a.Fragment,{children:[t("inventory.showing")," ",W*Fe+1," ",t("inventory.to")," ",Math.min((W+1)*Fe,Se.length)," ",t("inventory.of")," ",Se.length," ",t("inventory.spools")]})}),a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx("span",{className:"text-bambu-gray",children:t("inventory.show")}),a.jsxs("select",{value:U,onChange:Z=>Q(Number(Z.target.value)),className:"px-2 py-1 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded text-white text-sm focus:outline-none focus:border-bambu-green",children:[[15,30,50,100].map(Z=>a.jsx("option",{value:Z,children:Z},Z)),a.jsx("option",{value:-1,children:t("inventory.all")})]}),!ie&&a.jsxs(a.Fragment,{children:[a.jsx("button",{onClick:()=>P(0),disabled:W===0,className:"p-1.5 rounded text-bambu-gray hover:text-white disabled:opacity-30 disabled:cursor-not-allowed transition-colors",title:"First page",children:a.jsx(cX,{className:"w-4 h-4"})}),a.jsx("button",{onClick:()=>P(Z=>Math.max(0,Z-1)),disabled:W===0,className:"p-1.5 rounded text-bambu-gray hover:text-white disabled:opacity-30 disabled:cursor-not-allowed transition-colors",children:a.jsx(ql,{className:"w-4 h-4"})}),a.jsxs("span",{className:"text-bambu-gray px-2 whitespace-nowrap",children:[t("inventory.page")," ",W+1," ",t("inventory.of")," ",V]}),a.jsx("button",{onClick:()=>P(Z=>Math.min(V-1,Z+1)),disabled:W>=V-1,className:"p-1.5 rounded text-bambu-gray hover:text-white disabled:opacity-30 disabled:cursor-not-allowed transition-colors",children:a.jsx(pa,{className:"w-4 h-4"})}),a.jsx("button",{onClick:()=>P(V-1),disabled:W>=V-1,className:"p-1.5 rounded text-bambu-gray hover:text-white disabled:opacity-30 disabled:cursor-not-allowed transition-colors",title:"Last page",children:a.jsx(uX,{className:"w-4 h-4"})})]})]})]})]}):a.jsx(fK,{hasFilters:me,onAddSpool:()=>i({spool:null}),t}),r!==null&&a.jsx(AJe,{isOpen:!0,onClose:()=>i(null),spool:r.spool}),s&&a.jsx(vn,{title:s.type==="delete"?t("common.delete"):t("inventory.archive"),message:s.type==="delete"?t("inventory.deleteConfirm"):t("inventory.archiveConfirm"),confirmText:s.type==="delete"?t("common.delete"):t("inventory.archive"),variant:s.type==="delete"?"danger":"warning",onConfirm:()=>{s.type==="delete"?q.mutate(s.spoolId):z.mutate(s.spoolId),o(null)},onCancel:()=>o(null)}),a.jsx(TJe,{isOpen:k,onClose:()=>j(!1),columns:C,defaultColumns:S1,onSave:je})]})}function IJe({pageIndex:t,pageSize:e,totalRows:n,totalPages:r,onPageChange:i,onPageSizeChange:s,t:o}){const l=e===-1;if(r<=1&&!l)return null;const c=l?n||1:e;return a.jsxs("div",{className:"flex items-center justify-between pt-2 text-sm",children:[a.jsx("span",{className:"text-bambu-gray",children:l?`${n} ${o(n!==1?"inventory.spools":"inventory.spool")}`:a.jsxs(a.Fragment,{children:[o("inventory.showing")," ",t*c+1," ",o("inventory.to")," ",Math.min((t+1)*c,n)," ",o("inventory.of")," ",n," ",o("inventory.spools")]})}),a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx("span",{className:"text-bambu-gray",children:o("inventory.show")}),a.jsxs("select",{value:e,onChange:u=>s(Number(u.target.value)),className:"px-2 py-1 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded text-white text-sm focus:outline-none focus:border-bambu-green",children:[[15,30,50,100].map(u=>a.jsx("option",{value:u,children:u},u)),a.jsx("option",{value:-1,children:o("inventory.all")})]}),!l&&a.jsxs(a.Fragment,{children:[a.jsx("button",{onClick:()=>i(0),disabled:t===0,className:"p-1.5 rounded text-bambu-gray hover:text-white disabled:opacity-30 disabled:cursor-not-allowed transition-colors",children:a.jsx(cX,{className:"w-4 h-4"})}),a.jsx("button",{onClick:()=>i(Math.max(0,t-1)),disabled:t===0,className:"p-1.5 rounded text-bambu-gray hover:text-white disabled:opacity-30 disabled:cursor-not-allowed transition-colors",children:a.jsx(ql,{className:"w-4 h-4"})}),a.jsxs("span",{className:"text-bambu-gray px-2 whitespace-nowrap",children:[o("inventory.page")," ",t+1," ",o("inventory.of")," ",r]}),a.jsx("button",{onClick:()=>i(Math.min(r-1,t+1)),disabled:t>=r-1,className:"p-1.5 rounded text-bambu-gray hover:text-white disabled:opacity-30 disabled:cursor-not-allowed transition-colors",children:a.jsx(pa,{className:"w-4 h-4"})}),a.jsx("button",{onClick:()=>i(r-1),disabled:t>=r-1,className:"p-1.5 rounded text-bambu-gray hover:text-white disabled:opacity-30 disabled:cursor-not-allowed transition-colors",children:a.jsx(uX,{className:"w-4 h-4"})})]})]})]})}function fK({hasFilters:t,onAddSpool:e,t:n}){return a.jsxs("div",{className:"flex flex-col items-center justify-center py-16 px-4",children:[a.jsxs("div",{className:"relative mb-6",children:[a.jsx("div",{className:"absolute inset-0 -m-4 bg-bambu-green/5 rounded-full blur-2xl"}),a.jsxs("div",{className:"relative flex items-center justify-center w-24 h-24 rounded-2xl bg-gradient-to-br from-bambu-dark-secondary to-bambu-dark-tertiary border border-bambu-dark-tertiary shadow-lg",children:[a.jsx("div",{className:"absolute -top-1 -right-1 w-3 h-3 rounded-full bg-bambu-green/30"}),a.jsx("div",{className:"absolute -bottom-2 -left-2 w-2 h-2 rounded-full bg-bambu-green/20"}),t?a.jsx(Or,{className:"w-10 h-10 text-bambu-gray/40",strokeWidth:1.5}):a.jsxs("div",{className:"relative",children:[a.jsx("div",{className:"w-14 h-14 rounded-full border-4 border-bambu-gray/20 flex items-center justify-center",children:a.jsx("div",{className:"w-6 h-6 rounded-full bg-bambu-gray/10 border-2 border-bambu-gray/20"})}),a.jsx("div",{className:"absolute -bottom-1 -right-1 w-6 h-6 rounded-full bg-bambu-green flex items-center justify-center shadow-md",children:a.jsx("span",{className:"text-white text-lg font-bold leading-none",children:"+"})})]})]})]}),a.jsx("h3",{className:"text-lg font-semibold text-white mb-2 text-center",children:t?n("inventory.noSpoolsMatch"):n("inventory.noSpools").split(".")[0]}),a.jsx("p",{className:"text-sm text-bambu-gray text-center max-w-sm mb-6",children:n(t?"inventory.noSpoolsMatchDesc":"inventory.noSpools")}),!t&&a.jsxs(Ce,{onClick:e,children:[a.jsx(fa,{className:"w-4 h-4"}),n("inventory.addSpool")]})]})}const pK=["DEBUG","INFO","WARNING","ERROR"],Qj={DEBUG:"text-gray-400",INFO:"text-blue-400",WARNING:"text-yellow-400",ERROR:"text-red-400"},zJe={DEBUG:Zk,INFO:Js,WARNING:Cn,ERROR:Hi};function UJe(){const t=tn(),[e,n]=w.useState(!0),[r,i]=w.useState(new Set),[s,o]=w.useState(""),[l,c]=w.useState("ALL"),[u,d]=w.useState(!1),[h,f]=w.useState(!1),p=w.useRef(null),{data:x,isLoading:y,refetch:b}=Ze({queryKey:["application-logs",l,s],queryFn:()=>Zg.getLogs({limit:200,level:l==="ALL"?void 0:l,search:s||void 0}),refetchInterval:h?2e3:!1,enabled:u});w.useEffect(()=>{u||f(!1)},[u]);const v=ot({mutationFn:()=>Zg.clearLogs(),onSuccess:()=>{t.invalidateQueries({queryKey:["application-logs"]})}});w.useEffect(()=>{e&&p.current&&x?.entries&&(p.current.scrollTop=p.current.scrollHeight)},[x?.entries,e]);const S=k=>{i(j=>{const E=new Set(j);return E.has(k)?E.delete(k):E.add(k),E})},N=k=>{const j=k.split(" ");return j.length>=2?j[1]:k},A=w.useMemo(()=>x?.entries??[],[x?.entries]),C=w.useMemo(()=>[...A].reverse(),[A]),T=({level:k})=>{const j=zJe[k]||Js;return a.jsx(j,{className:`w-3.5 h-3.5 ${Qj[k]||"text-gray-400"}`})};return a.jsxs("div",{className:"bg-bambu-dark rounded-lg overflow-hidden",children:[a.jsxs("button",{onClick:()=>d(!u),className:"w-full flex items-center justify-between p-4 hover:bg-bambu-dark-tertiary/50 transition-colors",children:[a.jsxs("div",{className:"flex items-center gap-3",children:[a.jsx("div",{className:`p-2 rounded-lg ${h?"bg-bambu-green/20 text-bambu-green":"bg-bambu-dark-tertiary text-bambu-gray"}`,children:a.jsx(Zk,{className:"w-5 h-5"})}),a.jsxs("div",{className:"text-left",children:[a.jsx("p",{className:"font-medium text-white",children:"Application Logs"}),a.jsx("p",{className:"text-sm text-bambu-gray",children:h?`Live streaming - ${x?.filtered_count??0} entries`:"View and filter application logs"})]})]}),a.jsxs("div",{className:"flex items-center gap-2",children:[h&&a.jsxs("span",{className:"flex items-center gap-1.5 px-2 py-1 bg-bambu-green/20 rounded text-bambu-green text-xs",children:[a.jsx("span",{className:"w-1.5 h-1.5 bg-bambu-green rounded-full animate-pulse"}),"Live"]}),u?a.jsx(Wl,{className:"w-5 h-5 text-bambu-gray"}):a.jsx(nr,{className:"w-5 h-5 text-bambu-gray"})]})]}),u&&a.jsxs("div",{className:"border-t border-bambu-dark-tertiary",children:[a.jsxs("div",{className:"flex flex-col gap-2 p-4 border-b border-bambu-dark-tertiary",children:[a.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[h?a.jsxs("button",{onClick:k=>{k.stopPropagation(),f(!1)},className:"flex items-center gap-1.5 px-3 py-1.5 text-sm bg-red-500/20 text-red-400 hover:bg-red-500/30 rounded transition-colors",children:[a.jsx(bl,{className:"w-4 h-4"}),"Stop"]}):a.jsxs("button",{onClick:k=>{k.stopPropagation(),f(!0),b()},className:"flex items-center gap-1.5 px-3 py-1.5 text-sm bg-bambu-green/20 text-bambu-green hover:bg-bambu-green/30 rounded transition-colors",children:[a.jsx(so,{className:"w-4 h-4"}),"Start"]}),a.jsxs("button",{onClick:()=>v.mutate(),disabled:v.isPending||A.length===0,className:"flex items-center gap-1.5 px-3 py-1.5 text-sm bg-bambu-dark-tertiary text-bambu-gray hover:text-white hover:bg-bambu-dark-secondary rounded transition-colors disabled:opacity-50",children:[a.jsx(Jt,{className:"w-4 h-4"}),"Clear"]}),a.jsx("button",{onClick:()=>b(),disabled:y,className:"flex items-center gap-1.5 px-3 py-1.5 text-sm bg-bambu-dark-tertiary text-bambu-gray hover:text-white hover:bg-bambu-dark-secondary rounded transition-colors disabled:opacity-50",children:a.jsx(kr,{className:`w-4 h-4 ${y?"animate-spin":""}`})}),a.jsx("div",{className:"flex-1"}),a.jsxs("label",{className:"flex items-center gap-2 text-sm text-bambu-gray cursor-pointer",children:[a.jsx("input",{type:"checkbox",checked:e,onChange:k=>n(k.target.checked),className:"rounded border-bambu-dark-tertiary bg-bambu-dark-tertiary"}),"Auto-scroll"]}),a.jsxs("span",{className:"text-sm text-bambu-gray",children:[x?.filtered_count??0,"/",x?.total_in_file??0]})]}),a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsxs("div",{className:"relative flex-1",children:[a.jsx(Or,{className:"absolute left-2.5 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray"}),a.jsx("input",{type:"text",placeholder:"Search message or logger name...",value:s,onChange:k=>o(k.target.value),className:"w-full pl-8 pr-8 py-1.5 text-sm bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded text-white placeholder-bambu-gray focus:border-bambu-green focus:outline-none"}),s&&a.jsx("button",{onClick:()=>o(""),className:"absolute right-2 top-1/2 -translate-y-1/2 text-bambu-gray hover:text-white",children:a.jsx(Ft,{className:"w-4 h-4"})})]}),a.jsxs("div",{className:"flex items-center gap-1 bg-bambu-dark-secondary rounded border border-bambu-dark-tertiary",children:[a.jsx("button",{onClick:()=>c("ALL"),className:`px-2 py-1.5 text-xs rounded-l transition-colors ${l==="ALL"?"bg-bambu-green text-white":"text-bambu-gray hover:text-white"}`,children:"All"}),pK.map((k,j)=>a.jsx("button",{onClick:()=>c(k),className:`px-2 py-1.5 text-xs transition-colors flex items-center gap-1 ${j===pK.length-1?"rounded-r":""} ${l===k?`${Qj[k]} bg-bambu-dark-tertiary`:"text-bambu-gray hover:text-white"}`,children:k},k))]})]})]}),a.jsx("div",{ref:p,className:"overflow-auto font-mono text-xs bg-black min-h-[300px] max-h-[500px]",children:A.length===0?a.jsxs("div",{className:"flex flex-col items-center justify-center h-[300px] text-bambu-gray",children:[a.jsx("p",{className:"mb-2",children:"No log entries found"}),a.jsx("p",{className:"text-sm",children:"Log file may be empty or cleared"})]}):a.jsx("div",{className:"divide-y divide-bambu-dark-tertiary/30",children:C.map((k,j)=>{const E=r.has(j),P=k.message.includes(` +`+n+"}"}return String(t)}function MZe({setting:t,onClose:e,onDeleted:n,onDuplicate:r,onEdit:i,hasPermission:s,t:o}){const{showToast:l}=hn(),c=tn(),[u,d]=w.useState(!1),{data:h,isLoading:f}=Ze({queryKey:["cloudSettingDetail",t.setting_id],queryFn:()=>re.getCloudSettingDetail(t.setting_id)}),p=ot({mutationFn:()=>re.deleteCloudSetting(t.setting_id),onSuccess:()=>{l(o("profiles.presets.toast.deleted")),c.invalidateQueries({queryKey:["cloudSettings"]}),n()},onError:b=>l(b.message,"error")}),x=mv(t.setting_id),y=xI(t.name,h?.setting?.inherits);return a.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4",children:a.jsx(vt,{className:"w-full max-w-3xl max-h-[90vh] flex flex-col overflow-hidden",children:a.jsxs(Nt,{className:"p-0 flex flex-col min-h-0 flex-1",children:[a.jsxs("div",{className:"flex-shrink-0 flex items-center justify-between p-4 border-b border-bambu-dark-tertiary",children:[a.jsxs("div",{className:"flex-1 min-w-0",children:[a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx("h2",{className:"text-xl font-semibold text-white truncate",children:t.name}),x&&a.jsx("span",{className:"px-2 py-0.5 text-xs font-medium bg-bambu-green/20 text-bambu-green rounded-full",children:o("profiles.presets.editable")})]}),a.jsxs("div",{className:"flex items-center gap-2 mt-1 text-sm text-bambu-gray",children:[a.jsx("span",{className:"capitalize",children:o(`profiles.presets.types.${t.type}`)}),y.printer&&a.jsxs(a.Fragment,{children:[a.jsx("span",{children:"•"}),a.jsx("span",{children:y.printer})]})]})]}),a.jsx("button",{onClick:e,className:"p-2 text-bambu-gray hover:text-white hover:bg-bambu-dark-tertiary rounded-lg transition-colors",children:a.jsx(Ft,{className:"w-5 h-5"})})]}),a.jsx("div",{className:"flex-1 min-h-0 overflow-y-auto p-4",children:f?a.jsx("div",{className:"flex items-center justify-center py-16",children:a.jsx(it,{className:"w-8 h-8 text-bambu-green animate-spin"})}):h?a.jsx("pre",{className:"text-xs text-bambu-gray font-mono whitespace-pre-wrap break-all bg-bambu-dark p-4 rounded-lg border border-bambu-dark-tertiary overflow-x-auto max-w-full",children:fF(h)}):a.jsx("div",{className:"text-center py-16 text-bambu-gray",children:o("profiles.presets.failedToLoadDetails")})}),u?a.jsxs("div",{className:"flex-shrink-0 p-4 border-t border-bambu-dark-tertiary bg-red-500/5",children:[a.jsxs("div",{className:"flex items-center gap-2 mb-3 text-red-400",children:[a.jsx(Cn,{className:"w-5 h-5"}),a.jsx("span",{className:"font-medium",children:o("profiles.presets.deleteConfirm")})]}),a.jsx("p",{className:"text-sm text-bambu-gray mb-4",children:o("profiles.presets.deleteWarning",{name:t.name})}),a.jsxs("div",{className:"flex gap-2",children:[a.jsx(Ce,{variant:"secondary",onClick:()=>d(!1),disabled:p.isPending,className:"flex-1",children:o("common.cancel")}),a.jsxs(Ce,{variant:"danger",onClick:()=>p.mutate(),disabled:p.isPending,className:"flex-1",children:[p.isPending?a.jsx(it,{className:"w-4 h-4 animate-spin"}):a.jsx(Jt,{className:"w-4 h-4"}),o("common.delete")]})]})]}):a.jsx("div",{className:"flex-shrink-0 p-4 border-t border-bambu-dark-tertiary",children:a.jsxs("div",{className:"flex gap-2",children:[a.jsx(Ce,{variant:"secondary",onClick:e,className:"flex-1",children:o("common.close")}),a.jsxs(Ce,{variant:"secondary",onClick:r,disabled:!s("cloud:auth"),title:s("cloud:auth")?void 0:o("profiles.presets.noDuplicatePermission"),children:[a.jsx(Kl,{className:"w-4 h-4"}),o("profiles.presets.duplicate")]}),x&&a.jsxs(a.Fragment,{children:[a.jsxs(Ce,{variant:"secondary",onClick:i,disabled:f||!h||!s("cloud:auth"),title:s("cloud:auth")?void 0:o("profiles.presets.noEditPermission"),children:[a.jsx(Vi,{className:"w-4 h-4"}),o("common.edit")]}),a.jsx(Ce,{variant:"danger",onClick:()=>d(!0),disabled:!s("cloud:auth"),title:s("cloud:auth")?void 0:o("profiles.presets.noDeletePermission"),children:a.jsx(Jt,{className:"w-4 h-4"})})]})]})})]})})})}function Wae(){try{const t=localStorage.getItem("bambusy_preset_templates");return t?JSON.parse(t):[]}catch{return[]}}function Kae(t){localStorage.setItem("bambusy_preset_templates",JSON.stringify(t))}function AZe({onClose:t,onApply:e,t:n}){const{showToast:r}=hn(),[i,s]=w.useState(Wae),[o,l]=w.useState("all"),[c,u]=w.useState(null),[d,h]=w.useState(""),[f,p]=w.useState(""),[x,y]=w.useState("{}"),[b,v]=w.useState(null),[S,N]=w.useState(null),A=o==="all"?i:i.filter(B=>B.type===o),C=B=>{s(B),Kae(B)},T=B=>{const R=i.filter(G=>G.id!==B);C(R),N(null),r(n("profiles.templates.toast.deleted"))},k=B=>{u(B.id),h(B.name),p(B.description),y(JSON.stringify(B.settings,null,2)),v(null)},j=()=>{if(!(!c||!d.trim()))try{const B=JSON.parse(x),R=i.map(G=>G.id===c?{...G,name:d.trim(),description:f.trim(),settings:B}:G);C(R),u(null),r(n("profiles.templates.toast.updated"))}catch(B){v(B.message)}},E=()=>{u(null),h(""),p(""),y("{}"),v(null)},P=B=>{const R=i.map(G=>G.id===B?{...G,showInModal:!G.showInModal}:G);C(R)},U={filament:{label:n("profiles.presets.types.filament"),icon:Jk,color:"text-amber-400"},print:{label:n("profiles.presets.types.process"),icon:nd,color:"text-blue-400"},printer:{label:n("profiles.presets.types.printer"),icon:Cr,color:"text-purple-400"}},O=S?i.find(B=>B.id===S):null;return w.useEffect(()=>{const B=R=>{R.key==="Escape"&&(S?N(null):c?E():t())};return window.addEventListener("keydown",B),()=>window.removeEventListener("keydown",B)},[S,c,t]),a.jsxs("div",{className:"fixed inset-0 bg-black/70 flex items-center justify-center z-50 p-4",children:[O&&a.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-60",children:a.jsx(vt,{className:"w-full max-w-md",children:a.jsxs(Nt,{className:"p-6",children:[a.jsxs("div",{className:"flex items-center gap-3 mb-4",children:[a.jsx("div",{className:"p-2 bg-red-500/20 rounded-lg",children:a.jsx(Cn,{className:"w-6 h-6 text-red-400"})}),a.jsxs("div",{children:[a.jsx("h3",{className:"text-lg font-semibold text-white",children:n("profiles.templates.deleteTitle")}),a.jsx("p",{className:"text-sm text-bambu-gray",children:n("profiles.templates.deleteWarning")})]})]}),a.jsx("p",{className:"text-white mb-6",children:n("profiles.templates.deleteConfirm",{name:O.name})}),a.jsxs("div",{className:"flex gap-2",children:[a.jsx(Ce,{variant:"secondary",onClick:()=>N(null),className:"flex-1",children:n("common.cancel")}),a.jsxs(Ce,{onClick:()=>T(S),className:"flex-1 bg-red-500 hover:bg-red-600",children:[a.jsx(Jt,{className:"w-4 h-4"}),n("common.delete")]})]})]})})}),a.jsx(vt,{className:"w-full max-w-2xl max-h-[80vh] flex flex-col",children:a.jsxs(Nt,{className:"p-0 flex flex-col h-full",children:[a.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-bambu-dark-tertiary",children:[a.jsxs("h2",{className:"text-lg font-semibold text-white flex items-center gap-2",children:[a.jsx(pb,{className:"w-5 h-5 text-amber-400"}),n("profiles.templates.title")]}),a.jsx("button",{onClick:t,className:"text-bambu-gray hover:text-white",children:a.jsx(Ft,{className:"w-5 h-5"})})]}),a.jsxs("div",{className:"flex items-center gap-2 p-4 border-b border-bambu-dark-tertiary",children:[a.jsx("span",{className:"text-sm text-bambu-gray",children:n("profiles.templates.typeFilter")}),["all","filament","print","printer"].map(B=>a.jsx("button",{onClick:()=>l(B),className:`px-3 py-1 text-sm rounded-lg transition-colors ${o===B?"bg-bambu-green text-white":"bg-bambu-dark text-bambu-gray hover:text-white"}`,children:B==="all"?n("common.all"):U[B].label},B))]}),a.jsx("div",{className:"flex-1 overflow-y-auto p-4",children:A.length===0?a.jsxs("div",{className:"text-center py-12 text-bambu-gray",children:[a.jsx(pb,{className:"w-12 h-12 mx-auto mb-4 opacity-30"}),a.jsx("p",{children:n("profiles.templates.noTemplates")}),a.jsx("p",{className:"text-sm mt-1",children:n("profiles.templates.createFirst")})]}):a.jsx("div",{className:"space-y-2",children:A.map(B=>{const R=U[B.type],G=R.icon;return c===B.id?a.jsxs("div",{className:"p-4 bg-bambu-dark rounded-lg border border-bambu-green",children:[a.jsxs("div",{className:"grid grid-cols-2 gap-3 mb-3",children:[a.jsx("input",{type:"text",value:d,onChange:q=>h(q.target.value),placeholder:n("profiles.templates.namePlaceholder"),className:"px-3 py-2 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded text-white text-sm focus:border-bambu-green focus:outline-none",autoFocus:!0}),a.jsx("input",{type:"text",value:f,onChange:q=>p(q.target.value),placeholder:n("profiles.templates.descriptionPlaceholder"),className:"px-3 py-2 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded text-white text-sm focus:border-bambu-green focus:outline-none"})]}),a.jsxs("div",{className:"mb-3",children:[a.jsx("label",{className:"text-xs text-bambu-gray mb-1 block",children:n("profiles.templates.settingsJson")}),a.jsx("textarea",{value:x,onChange:q=>{y(q.target.value),v(null)},rows:6,className:`w-full px-3 py-2 bg-bambu-dark-secondary border rounded text-white text-sm font-mono focus:outline-none ${b?"border-red-500":"border-bambu-dark-tertiary focus:border-bambu-green"}`}),b&&a.jsx("p",{className:"text-xs text-red-400 mt-1",children:b})]}),a.jsxs("div",{className:"flex gap-2",children:[a.jsxs(Ce,{size:"sm",onClick:j,disabled:!d.trim(),children:[a.jsx(bs,{className:"w-4 h-4"}),"Save"]}),a.jsx(Ce,{size:"sm",variant:"secondary",onClick:E,children:"Cancel"})]})]},B.id):a.jsxs("div",{className:"flex items-center gap-3 p-3 bg-bambu-dark rounded-lg border border-bambu-dark-tertiary hover:border-bambu-gray-dark transition-colors",children:[a.jsx(G,{className:`w-5 h-5 ${R.color} flex-shrink-0`}),a.jsxs("div",{className:"flex-1 min-w-0",children:[a.jsx("p",{className:"text-sm font-medium text-white",children:B.name}),a.jsx("p",{className:"text-xs text-bambu-gray truncate",children:B.description})]}),a.jsx("span",{className:"text-xs text-bambu-gray-dark px-2 py-1 bg-bambu-dark-secondary rounded",children:n("profiles.templates.fieldsCount",{count:Object.keys(B.settings).length})}),a.jsx("button",{onClick:()=>P(B.id),className:`p-1 transition-colors ${B.showInModal?"text-bambu-green hover:text-bambu-green/70":"text-bambu-gray hover:text-white"}`,title:B.showInModal?n("profiles.templates.shownInModals"):n("profiles.templates.hiddenInModals"),children:B.showInModal?a.jsx(Xl,{className:"w-4 h-4"}):a.jsx(gv,{className:"w-4 h-4"})}),a.jsx("button",{onClick:()=>e(B),className:"px-3 py-1 text-xs bg-bambu-green/20 text-bambu-green rounded hover:bg-bambu-green/30 transition-colors",children:n("profiles.templates.apply")}),a.jsx("button",{onClick:()=>k(B),className:"p-1 text-bambu-gray hover:text-white",title:n("common.edit"),children:a.jsx(Vi,{className:"w-4 h-4"})}),a.jsx("button",{onClick:()=>N(B.id),className:"p-1 text-bambu-gray hover:text-red-400",title:n("common.delete"),children:a.jsx(Jt,{className:"w-4 h-4"})})]},B.id)})})})]})})]})}function Xae({onClose:t,leftPreset:e,rightPreset:n,leftLabel:r,rightLabel:i,t:s}){const[o,l]=w.useState("changes"),[c,u]=w.useState(""),d=w.useMemo(()=>{const x=new Set([...Object.keys(e),...Object.keys(n)]),y=[];for(const b of x){if(b==="inherits"||b==="version")continue;const v=e[b],S=n[b],N=b in e,A=b in n;let C;!N&&A?C="added":N&&!A?C="removed":JSON.stringify(v)!==JSON.stringify(S)?C="changed":C="same",y.push({key:b,left:v,right:S,status:C})}return y.sort((b,v)=>{const S={changed:0,added:1,removed:2,same:3};return S[b.status]!==S[v.status]?S[b.status]-S[v.status]:b.key.localeCompare(v.key)})},[e,n]),h=w.useMemo(()=>{let x=[...d];if(o==="changes"&&(x=x.filter(y=>y.status!=="same")),c){const y=c.toLowerCase();x=x.filter(b=>b.key.toLowerCase().includes(y)||String(b.left).toLowerCase().includes(y)||String(b.right).toLowerCase().includes(y))}return x},[d,o,c]),f=w.useMemo(()=>({added:d.filter(x=>x.status==="added").length,removed:d.filter(x=>x.status==="removed").length,changed:d.filter(x=>x.status==="changed").length,same:d.filter(x=>x.status==="same").length}),[d]),p=x=>{if(x===void 0)return"—";if(x===null)return"null";if(Array.isArray(x))return x.length===0?"[]":x.length===1?String(x[0]):x.join(", ");if(typeof x=="object")return JSON.stringify(x);const y=String(x);if(y.includes("\\n")||y.length>100){const b=y.split("\\n").length;if(b>1)return`[${b} lines of G-code/script]`;if(y.length>100)return y.substring(0,100)+"…"}return y};return w.useEffect(()=>{const x=y=>{y.key==="Escape"&&t()};return window.addEventListener("keydown",x),()=>window.removeEventListener("keydown",x)},[t]),a.jsx("div",{className:"fixed inset-0 bg-black/70 flex items-center justify-center z-50 p-4",children:a.jsx(vt,{className:"w-full max-w-4xl max-h-[85vh] flex flex-col overflow-hidden",children:a.jsxs(Nt,{className:"p-0 flex flex-col min-h-0 flex-1",children:[a.jsxs("div",{className:"flex-shrink-0 flex items-center justify-between p-4 border-b border-bambu-dark-tertiary",children:[a.jsxs("h2",{className:"text-lg font-semibold text-white flex items-center gap-2",children:[a.jsx(Yg,{className:"w-5 h-5 text-blue-400"}),s("profiles.diff.title")]}),a.jsx("button",{onClick:t,className:"text-bambu-gray hover:text-white",children:a.jsx(Ft,{className:"w-5 h-5"})})]}),a.jsxs("div",{className:"flex-shrink-0 grid grid-cols-2 gap-4 p-4 border-b border-bambu-dark-tertiary bg-bambu-dark",children:[a.jsxs("div",{className:"text-center",children:[a.jsx("span",{className:"text-sm text-bambu-gray",children:s("profiles.diff.left")}),a.jsx("p",{className:"text-white font-medium truncate",children:r})]}),a.jsxs("div",{className:"text-center",children:[a.jsx("span",{className:"text-sm text-bambu-gray",children:s("profiles.diff.right")}),a.jsx("p",{className:"text-white font-medium truncate",children:i})]})]}),a.jsxs("div",{className:"flex-shrink-0 flex items-center justify-between p-4 border-b border-bambu-dark-tertiary",children:[a.jsxs("div",{className:"flex items-center gap-4 text-sm",children:[a.jsxs("span",{className:"flex items-center gap-1 text-green-400",children:[a.jsx(ar,{className:"w-3.5 h-3.5"}),f.added," ",s("profiles.diff.added")]}),a.jsxs("span",{className:"flex items-center gap-1 text-red-400",children:[a.jsx(y3,{className:"w-3.5 h-3.5"}),f.removed," ",s("profiles.diff.removed")]}),a.jsxs("span",{className:"flex items-center gap-1 text-amber-400",children:[a.jsx(h3,{className:"w-3.5 h-3.5"}),f.changed," ",s("profiles.diff.changed")]}),a.jsxs("span",{className:"flex items-center gap-1 text-bambu-gray",children:[a.jsx(JT,{className:"w-3.5 h-3.5"}),f.same," ",s("profiles.diff.same")]})]}),a.jsxs("div",{className:"flex items-center gap-3",children:[a.jsxs("div",{className:"relative",children:[a.jsx(Or,{className:"absolute left-2 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray"}),a.jsx("input",{type:"text",value:c,onChange:x=>u(x.target.value),placeholder:s("profiles.diff.searchFields"),className:"pl-8 pr-3 py-1.5 bg-bambu-dark border border-bambu-dark-tertiary rounded text-white text-sm focus:border-bambu-green focus:outline-none w-48"})]}),f.same>0&&a.jsxs("div",{className:"flex rounded overflow-hidden border border-bambu-dark-tertiary",children:[a.jsx("button",{onClick:()=>l("changes"),className:`px-3 py-1.5 text-sm transition-colors ${o==="changes"?"bg-bambu-green text-white":"bg-bambu-dark text-bambu-gray hover:text-white"}`,children:s("profiles.diff.changes")}),a.jsx("button",{onClick:()=>l("all"),className:`px-3 py-1.5 text-sm transition-colors ${o==="all"?"bg-bambu-green text-white":"bg-bambu-dark text-bambu-gray hover:text-white"}`,children:s("common.all")})]})]})]}),a.jsx("div",{className:"flex-1 min-h-0 overflow-y-auto",children:h.length===0?a.jsxs("div",{className:"text-center py-12 text-bambu-gray",children:[a.jsx(JT,{className:"w-12 h-12 mx-auto mb-4 opacity-30"}),a.jsx("p",{children:s(o==="changes"?"profiles.diff.noDifferences":"profiles.diff.noFieldsMatch")})]}):a.jsxs("table",{className:"w-full",children:[a.jsx("thead",{className:"sticky top-0 bg-bambu-dark-secondary",children:a.jsxs("tr",{className:"text-sm text-bambu-gray border-b border-bambu-dark-tertiary",children:[a.jsx("th",{className:"text-left p-3 w-1/3",children:s("profiles.diff.field")}),a.jsx("th",{className:"text-left p-3 w-1/3",children:r}),a.jsx("th",{className:"text-left p-3 w-1/3",children:i})]})}),a.jsx("tbody",{children:h.map(x=>{const y={added:"bg-green-500/10",removed:"bg-red-500/10",changed:"bg-amber-500/10",same:""}[x.status],b={added:a.jsx(ar,{className:"w-3.5 h-3.5 text-green-400"}),removed:a.jsx(y3,{className:"w-3.5 h-3.5 text-red-400"}),changed:a.jsx(h3,{className:"w-3.5 h-3.5 text-amber-400"}),same:a.jsx(JT,{className:"w-3.5 h-3.5 text-bambu-gray-dark"})}[x.status];return a.jsxs("tr",{className:`border-b border-bambu-dark-tertiary ${y}`,children:[a.jsx("td",{className:"p-3",children:a.jsxs("div",{className:"flex items-center gap-2",children:[b,a.jsx("span",{className:"text-sm text-white font-mono",children:x.key})]})}),a.jsx("td",{className:"p-3",children:a.jsx("span",{className:`text-sm font-mono break-all ${x.status==="removed"?"text-red-300":x.status==="changed"?"text-white":"text-bambu-gray"}`,children:p(x.left)})}),a.jsx("td",{className:"p-3",children:a.jsx("span",{className:`text-sm font-mono break-all ${x.status==="added"?"text-green-300":x.status==="changed"?"text-white":"text-bambu-gray"}`,children:p(x.right)})})]},x.key)})})]})})]})})})}function TZe({onClose:t,initialData:e,allPresets:n,t:r}){const{showToast:i}=hn(),s=tn(),o=!!e?.setting_id,[l,c]=w.useState("common"),[u,d]=w.useState(e?.type||"filament"),[h,f]=w.useState(e?.name?o?e.name:`${e.name} (Copy)`:""),[p,x]=w.useState(e?.base_id||""),[y,b]=w.useState(""),[v,S]=w.useState(e?.setting||{inherits:""}),[N,A]=w.useState(JSON.stringify(e?.setting||{inherits:""},null,2)),[C,T]=w.useState(null),[k,j]=w.useState(""),[E,P]=w.useState(!1),[U,O]=w.useState(""),[B,R]=w.useState(!1),[G,q]=w.useState(Wae),[z,K]=w.useState(!1),[Y,oe]=w.useState(""),[$,X]=w.useState(""),[ee,J]=w.useState(!0),[_e,pe]=w.useState(null),[me,je]=w.useState(!1),de=w.useMemo(()=>({filament:n.filament,print:n.process,printer:n.printer})[u]||[],[n,u]),ce=w.useMemo(()=>de.filter(le=>mv(le.setting_id)),[de]),{data:Se}=Ze({queryKey:["cloudFields",u],queryFn:()=>re.getCloudFields(u==="print"?"process":u),staleTime:1e3*60*60}),{data:ie}=Ze({queryKey:["allPresetDetails",u,ce.map(le=>le.setting_id).join(",")],queryFn:async()=>{const le={};for(let Me=0;Me{try{const Pe=await re.getCloudSettingDetail(Je.setting_id);return{id:Je.setting_id,detail:Pe}}catch{return null}}))).forEach(Je=>{Je&&(le[Je.id]=Je.detail)})}return le},enabled:ce.length>0,staleTime:1e3*60*10}),{data:Fe,isLoading:V}=Ze({queryKey:["cloudSettingDetail",p],queryFn:()=>re.getCloudSettingDetail(p),enabled:!!p});w.useEffect(()=>{l!=="json"&&A(JSON.stringify(v,null,2))},[v,l]);const W=w.useMemo(()=>({filament:n.filament,print:n.process,printer:n.printer}[u]||[]).filter(Le=>!mv(Le.setting_id)).sort((Le,Me)=>Le.name.localeCompare(Me.name)),[n,u]);w.useEffect(()=>{if(!p)return;const le=W.find(Le=>Le.setting_id===p);le&&(b(le.name),o||(S({inherits:le.name}),A(JSON.stringify({inherits:le.name},null,2))))},[p,W,o]);const ue=w.useMemo(()=>{const le=Se?.fields||[],Le=new Set(le.map(Je=>Je.key)),Me=new Set,$e=new Set(["inherits","updated_time","compatible_printers","compatible_prints"]);ie&&Object.values(ie).forEach(Je=>{Je?.setting&&Object.keys(Je.setting).forEach(Pe=>{!Le.has(Pe)&&!$e.has(Pe)&&Me.add(Pe)})}),Object.keys(v).forEach(Je=>{!Le.has(Je)&&!$e.has(Je)&&Me.add(Je)});const Ae=Array.from(Me).sort().map(Je=>({key:Je,label:Je.replace(/_/g," ").replace(/\b\w/g,Pe=>Pe.toUpperCase()),type:"text",category:"discovered",description:r("profiles.presets.discoveredFromPresets")}));return[...le,...Ae]},[Se,ie,v,r]),Q=ue.filter(le=>le.label.toLowerCase().includes(k.toLowerCase())||le.key.toLowerCase().includes(k.toLowerCase())),se=()=>{if(U.trim()){const le=U.trim().toLowerCase().replace(/\s+/g,"_");Z(le,""),O(""),R(!1),i(r("profiles.presets.toast.fieldAdded",{key:le}))}},Z=(le,Le)=>{S(Me=>{const $e={...Me};return Le===""||Le===void 0?delete $e[le]:$e[le]=Le,$e})},Ne=le=>{S(Le=>({...Le,...le.settings})),pe(le.name),i(r("profiles.templates.toast.applied"))},ve=()=>{if(!Y.trim())return;const le={...v};if(delete le.inherits,Object.keys(le).length===0){i(r("profiles.presets.noOverridesToSave"),"error");return}const Le={id:Date.now().toString(),name:Y.trim(),description:$.trim()||r("profiles.presets.customTemplate"),type:u,settings:le,showInModal:ee},Me=[...G,Le];q(Me),Kae(Me),K(!1),oe(""),X(""),J(!0),i(r("profiles.templates.toast.created"))},fe=w.useMemo(()=>G.filter(le=>le.type===u&&le.showInModal),[u,G]),L=le=>{A(le);try{const Le=JSON.parse(le);S(Le),T(null)}catch(Le){T(Le.message)}},D=le=>{le.preventDefault(),P(!1);const Le=le.dataTransfer.files[0];if(Le&&Le.name.endsWith(".json")){const Me=new FileReader;Me.onload=$e=>{try{const Ae=$e.target?.result,Je=JSON.parse(Ae),Pe=Je.setting||Je;S(Xe=>({...Xe,...Pe})),A(JSON.stringify({...v,...Pe},null,2)),i(r("profiles.presets.fileImported"))}catch{i(r("profiles.presets.invalidJsonFile"),"error")}},Me.readAsText(Le)}},H=ot({mutationFn:()=>{const le={...v},Le=u==="filament"?"filament_settings_id":u==="print"?"print_settings_id":"printer_settings_id";le[Le]=`"${h}"`;const Me={type:u,name:h,base_id:p,setting:le};return re.createCloudSetting(Me)},onSuccess:async()=>{i(r("profiles.presets.toast.created")),await s.refetchQueries({queryKey:["cloudSettings"]}),t()},onError:le=>i(le.message,"error")}),he=ot({mutationFn:()=>{if(!e?.setting_id)throw new Error(r("profiles.presets.noSettingId"));return re.updateCloudSetting(e.setting_id,{name:h,setting:v})},onSuccess:async()=>{i(r("profiles.presets.toast.updated")),s.removeQueries({queryKey:["cloudSettingDetail"]}),await s.refetchQueries({queryKey:["cloudSettings"]}),t()},onError:le=>i(le.message,"error")}),xe=o?he:H,be=Fe?.setting?.inherits,Ue=be?W.find(le=>le.name===be):void 0,{data:Oe}=Ze({queryKey:["cloudSettingDetail",Ue?.setting_id],queryFn:()=>re.getCloudSettingDetail(Ue.setting_id),enabled:!!Ue?.setting_id}),Qe=w.useMemo(()=>{const le=Oe?.setting||{},Le=Fe?.setting||{},Me=p&&ie?.[p]?.setting?ie[p].setting:{};return{...le,...Le,...Me}},[p,Fe,Oe,ie]),rt=le=>{if(le==null)return"";if(Array.isArray(le)){const Le=[...new Set(le.map(Me=>String(Me)))];return Le.length===1?Le[0]:le.join(", ")}return String(le)},we=le=>{const Le=v[le.key],Me=Qe[le.key],$e=rt(Me),Ae=V?r("common.loading"):$e||"",Je="w-full px-3 py-1.5 bg-bambu-dark border border-bambu-dark-tertiary rounded text-white text-sm focus:border-bambu-green focus:outline-none";if(le.type==="boolean"){const Pe=Le==="1"||Le===void 0&&Me==="1";return a.jsx("button",{type:"button",onClick:()=>Z(le.key,Le==="1"?"0":"1"),className:`w-8 h-5 rounded-full transition-colors ${Pe?"bg-bambu-green":"bg-bambu-dark-tertiary"}`,children:a.jsx("div",{className:`w-4 h-4 rounded-full bg-white shadow transition-transform ${Pe?"translate-x-3.5":"translate-x-0.5"}`})})}return le.type==="select"?a.jsxs("select",{value:Le||"",onChange:Pe=>Z(le.key,Pe.target.value),className:Je,children:[a.jsx("option",{value:"",children:Ae}),le.options?.map(Pe=>a.jsx("option",{value:Pe.value,children:Pe.label},Pe.value))]}):a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx("input",{type:le.type==="number"?"number":"text",value:Le!==void 0?String(Le):"",onChange:Pe=>Z(le.key,Pe.target.value),step:le.step,min:le.min,max:le.max,placeholder:Ae,className:Je}),le.unit&&a.jsx("span",{className:"text-xs text-bambu-gray whitespace-nowrap",children:le.unit})]})},ye=w.useMemo(()=>Fe?.setting?Fe.setting:{},[Fe]);return a.jsxs("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4",onDragOver:le=>{le.preventDefault(),P(!0)},onDragLeave:()=>P(!1),onDrop:D,children:[me&&p&&a.jsx(Xae,{onClose:()=>je(!1),leftPreset:ye,rightPreset:v,leftLabel:r("profiles.presets.baseLabel",{name:y||p}),rightLabel:r("profiles.presets.currentLabel",{name:h||r("profiles.presets.newPreset")}),t:r}),a.jsx(vt,{className:"w-full max-w-6xl max-h-[90vh] flex flex-col overflow-y-auto",children:a.jsxs(Nt,{className:"p-0 flex flex-col h-full",children:[a.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-bambu-dark-tertiary",children:[a.jsxs("div",{children:[a.jsx("h2",{className:"text-xl font-semibold text-white",children:r(o?"profiles.presets.editPreset":e?"profiles.presets.duplicatePreset":"profiles.presets.createNewPreset")}),a.jsx("p",{className:"text-sm text-bambu-gray mt-1",children:r("profiles.presets.customizeSettings")})]}),a.jsxs("div",{className:"flex items-center gap-2",children:[p&&a.jsxs("button",{onClick:()=>je(!0),className:"flex items-center gap-2 px-3 py-2 text-sm text-bambu-gray hover:text-white hover:bg-bambu-dark-tertiary rounded-lg transition-colors",title:r("profiles.presets.compareWithBase"),children:[a.jsx(Yg,{className:"w-4 h-4"}),r("profiles.presets.compare")]}),a.jsx("button",{onClick:t,className:"p-2 text-bambu-gray hover:text-white hover:bg-bambu-dark-tertiary rounded-lg transition-colors",children:a.jsx(Ft,{className:"w-5 h-5"})})]})]}),E&&a.jsx("div",{className:"absolute inset-0 bg-bambu-green/10 border-2 border-dashed border-bambu-green rounded-lg flex items-center justify-center z-10",children:a.jsxs("div",{className:"text-center",children:[a.jsx(Fi,{className:"w-12 h-12 text-bambu-green mx-auto mb-2"}),a.jsx("p",{className:"text-bambu-green font-medium",children:r("profiles.presets.dropJsonToImport")})]})}),a.jsxs("div",{className:"p-4 border-b border-bambu-dark-tertiary space-y-3",children:[a.jsxs("div",{className:"grid grid-cols-3 gap-4 max-[640px]:grid-cols-1",children:[a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:r("common.type")}),a.jsxs("select",{value:u,onChange:le=>{d(le.target.value),x("")},className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",children:[a.jsx("option",{value:"filament",children:r("profiles.presets.types.filament")}),a.jsx("option",{value:"print",children:r("profiles.presets.types.process")}),a.jsx("option",{value:"printer",children:r("profiles.presets.types.printer")})]})]}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:r("profiles.presets.basePreset")}),a.jsxs("select",{value:p,onChange:le=>x(le.target.value),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white text-sm focus:border-bambu-green focus:outline-none",children:[a.jsx("option",{value:"",children:r("profiles.presets.selectBasePreset")}),W.map(le=>a.jsx("option",{value:le.setting_id,children:le.name},le.setting_id))]})]}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:r("profiles.presets.presetName")}),a.jsx("input",{type:"text",value:h,onChange:le=>f(le.target.value),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",placeholder:r("profiles.presets.myCustomPreset")})]})]}),y&&a.jsx("div",{className:"text-xs text-bambu-gray",children:a.jsxs("p",{className:"flex items-center gap-1",children:[a.jsx(Xr,{className:"w-3 h-3 text-bambu-green"}),r("profiles.presets.inheritsFrom")," ",a.jsx("span",{className:"text-white",children:y}),V&&a.jsx(it,{className:"w-3 h-3 animate-spin ml-1"})]})})]}),a.jsxs("div",{className:"flex border-b border-bambu-dark-tertiary max-[640px]:flex-wrap max-[640px]:items-center",children:[a.jsxs("button",{onClick:()=>c("common"),className:`flex items-center gap-2 px-4 py-3 text-sm font-medium transition-colors border-b-2 -mb-px ${l==="common"?"text-bambu-green border-bambu-green":"text-bambu-gray hover:text-white border-transparent"}`,children:[a.jsx($B,{className:"w-4 h-4"}),r("profiles.presets.tabs.common")]}),a.jsxs("button",{onClick:()=>c("fields"),className:`flex items-center gap-2 px-4 py-3 text-sm font-medium transition-colors border-b-2 -mb-px ${l==="fields"?"text-bambu-green border-bambu-green":"text-bambu-gray hover:text-white border-transparent"}`,children:[a.jsx(rC,{className:"w-4 h-4"}),r("profiles.presets.tabs.allFields")]}),a.jsxs("button",{onClick:()=>c("json"),className:`flex items-center gap-2 px-4 py-3 text-sm font-medium transition-colors border-b-2 -mb-px ${l==="json"?"text-bambu-green border-bambu-green":"text-bambu-gray hover:text-white border-transparent"}`,children:[a.jsx(dX,{className:"w-4 h-4"}),"JSON",C&&a.jsx(Hi,{className:"w-3 h-3 text-red-400"})]}),a.jsx("div",{className:"flex-1 max-[640px]:hidden"}),a.jsxs("button",{onClick:()=>{const le={name:h,type:u,base_id:p,setting:v},Le=new Blob([JSON.stringify(le,null,2)],{type:"application/json"}),Me=URL.createObjectURL(Le),$e=document.createElement("a");$e.href=Me,$e.download=`${h||"preset"}.json`,document.body.appendChild($e),$e.click(),document.body.removeChild($e),URL.revokeObjectURL(Me),i(r("profiles.presets.toast.exported"))},className:"flex items-center gap-2 px-4 py-3 text-sm text-bambu-gray hover:text-white transition-colors",title:r("profiles.presets.exportToJson"),children:[a.jsx(di,{className:"w-4 h-4"}),r("common.download")]}),a.jsxs("button",{onClick:()=>document.getElementById("file-import")?.click(),className:"flex items-center gap-2 px-4 py-3 text-sm text-bambu-gray hover:text-white transition-colors",title:r("profiles.presets.importFromJson"),children:[a.jsx(Fi,{className:"w-4 h-4"}),r("common.upload")]}),a.jsx("input",{id:"file-import",type:"file",accept:".json",className:"hidden",onChange:le=>{const Le=le.target.files?.[0];if(Le){const Me=new FileReader;Me.onload=$e=>{try{const Ae=JSON.parse($e.target?.result),Je=Ae.setting||Ae;S(Pe=>({...Pe,...Je})),i(r("profiles.presets.fileImported"))}catch{i(r("profiles.presets.invalidJson"),"error")}},Me.readAsText(Le)}}})]}),a.jsxs("div",{className:"flex-1 p-4",children:[l==="common"&&a.jsxs("div",{className:"space-y-6",children:[a.jsxs("div",{children:[a.jsxs("div",{className:"flex items-center justify-between mb-3",children:[a.jsxs("h3",{className:"text-sm font-medium text-white flex items-center gap-2",children:[a.jsx(pb,{className:"w-4 h-4 text-amber-400"}),r("profiles.templates.title")]}),Object.keys(v).filter(le=>le!=="inherits").length>0&&a.jsxs("button",{onClick:()=>K(!z),className:"text-xs text-bambu-gray hover:text-white flex items-center gap-1 transition-colors",children:[a.jsx(bs,{className:"w-3 h-3"}),r("profiles.presets.saveAsTemplate")]})]}),z&&a.jsxs("div",{className:"mb-3 p-3 bg-bambu-dark rounded-lg border border-bambu-dark-tertiary",children:[a.jsxs("div",{className:"grid grid-cols-2 gap-2 mb-2",children:[a.jsx("input",{type:"text",value:Y,onChange:le=>oe(le.target.value),placeholder:r("profiles.templates.namePlaceholder"),className:"px-3 py-1.5 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded text-white text-sm focus:border-bambu-green focus:outline-none",autoFocus:!0}),a.jsx("input",{type:"text",value:$,onChange:le=>X(le.target.value),placeholder:r("profiles.templates.descriptionPlaceholder"),className:"px-3 py-1.5 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded text-white text-sm focus:border-bambu-green focus:outline-none"})]}),a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsxs("div",{className:"flex gap-2",children:[a.jsxs(Ce,{size:"sm",onClick:ve,disabled:!Y.trim(),children:[a.jsx(bs,{className:"w-3 h-3"}),r("common.save")]}),a.jsx(Ce,{size:"sm",variant:"secondary",onClick:()=>K(!1),children:r("common.cancel")})]}),a.jsxs("button",{onClick:()=>J(!ee),className:`flex items-center gap-1.5 text-xs transition-colors ${ee?"text-bambu-green":"text-bambu-gray hover:text-white"}`,children:[ee?a.jsx(Xl,{className:"w-3.5 h-3.5"}):a.jsx(gv,{className:"w-3.5 h-3.5"}),r(ee?"profiles.templates.shownInModals":"profiles.templates.hiddenInModals")]})]})]}),_e&&a.jsxs("div",{className:"mb-3 px-3 py-2 bg-bambu-green/10 border border-bambu-green/30 rounded-lg flex items-center gap-2",children:[a.jsx(Xr,{className:"w-4 h-4 text-bambu-green"}),a.jsxs("span",{className:"text-sm text-bambu-green",children:[r("profiles.presets.templateApplied")," ",a.jsx("span",{className:"font-medium",children:_e})]}),a.jsx("button",{onClick:()=>pe(null),className:"ml-auto text-bambu-green/70 hover:text-bambu-green",children:a.jsx(Ft,{className:"w-4 h-4"})})]}),a.jsxs("div",{className:"grid grid-cols-3 gap-2",children:[fe.map(le=>a.jsxs("button",{onClick:()=>Ne(le),className:"p-3 text-left bg-bambu-dark border border-bambu-dark-tertiary rounded-lg hover:border-bambu-gray-dark transition-colors",children:[a.jsx("p",{className:"text-sm font-medium text-white",children:le.name}),a.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:le.description})]},le.id)),fe.length===0&&a.jsx("p",{className:"col-span-3 text-center text-bambu-gray text-sm py-4",children:r("profiles.presets.noTemplatesSelected")})]}),a.jsx("p",{className:"text-xs text-bambu-gray-dark mt-2 text-center",children:r("profiles.presets.manageTemplatesHint")})]}),a.jsxs("div",{children:[a.jsx("h3",{className:"text-sm font-medium text-white mb-3",children:r("profiles.presets.commonSettings")}),a.jsx("div",{className:"grid grid-cols-2 gap-x-6 gap-y-3",children:ue.slice(0,10).map(le=>a.jsxs("div",{className:"flex items-center justify-between gap-4 max-[640px]:flex-col max-[640px]:items-start",children:[a.jsx("label",{className:"text-sm text-bambu-gray flex-shrink-0",children:le.label}),a.jsx("div",{className:"w-48 max-[640px]:w-full",children:we(le)})]},le.key))})]}),Object.keys(v).length>1&&a.jsxs("div",{children:[a.jsx("h3",{className:"text-sm font-medium text-white mb-3",children:r("profiles.presets.currentOverrides")}),a.jsx("div",{className:"flex flex-wrap gap-2",children:Object.entries(v).filter(([le])=>le!=="inherits").map(([le,Le])=>a.jsxs("span",{className:"inline-flex items-center gap-1 px-2 py-1 bg-bambu-green/10 text-bambu-green text-xs rounded",children:[le,": ",String(Le).slice(0,20),a.jsx("button",{onClick:()=>Z(le,void 0),className:"hover:text-white",children:a.jsx(Ft,{className:"w-3 h-3"})})]},le))})]})]}),l==="fields"&&a.jsxs("div",{className:"grid grid-cols-2 gap-6",style:{height:"400px"},children:[a.jsxs("div",{className:"flex flex-col h-full overflow-hidden",children:[a.jsxs("div",{className:"flex items-center justify-between mb-3 flex-shrink-0",children:[a.jsx("h3",{className:"text-sm font-medium text-white",children:r("profiles.presets.availableFields")}),a.jsx("span",{className:"text-xs text-bambu-gray",children:ie?r("profiles.templates.fieldsCount",{count:ue.length}):r("common.loading")})]}),a.jsxs("div",{className:"relative mb-3 flex-shrink-0",children:[a.jsx(Or,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray"}),a.jsx("input",{type:"text",value:k,onChange:le=>j(le.target.value),placeholder:r("profiles.presets.searchFieldsPlaceholder"),className:"w-full pl-10 pr-4 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white text-sm placeholder-bambu-gray-dark focus:border-bambu-green focus:outline-none"})]}),a.jsxs("div",{className:"flex-1 overflow-y-auto space-y-1 pr-2 min-h-0",children:[Q.filter(le=>!(le.key in v)).map(le=>{const Le=Qe[le.key],Me=rt(Le);return a.jsxs("div",{onClick:()=>{S($e=>({...$e,[le.key]:Me||""}))},className:"flex items-center justify-between gap-2 p-2 rounded-lg hover:bg-bambu-dark-tertiary transition-colors cursor-pointer group",children:[a.jsxs("div",{className:"min-w-0 flex-1",children:[a.jsx("p",{className:"text-sm text-white truncate",children:le.label}),a.jsx("p",{className:"text-xs text-bambu-gray-dark truncate",children:le.key})]}),a.jsxs("div",{className:"flex items-center gap-2 flex-shrink-0",children:[Me&&a.jsxs("span",{className:"text-xs text-bambu-gray bg-bambu-dark px-2 py-0.5 rounded max-w-32 truncate",title:Me,children:[Me.slice(0,20),Me.length>20?"...":""]}),a.jsx("div",{className:"w-6 h-6 flex items-center justify-center rounded bg-bambu-dark-tertiary group-hover:bg-bambu-green/20 transition-colors",children:a.jsx(ar,{className:"w-4 h-4 text-bambu-gray group-hover:text-bambu-green transition-colors"})})]})]},le.key)}),Q.filter(le=>!(le.key in v)).length===0&&a.jsx("p",{className:"text-center text-bambu-gray py-4 text-sm",children:r(k?"profiles.presets.noMatchingFields":"profiles.presets.allFieldsAdded")})]}),a.jsx("div",{className:"pt-3 mt-3 border-t border-bambu-dark-tertiary flex-shrink-0",children:B?a.jsxs("div",{className:"flex gap-2",children:[a.jsx("input",{type:"text",value:U,onChange:le=>O(le.target.value),onKeyDown:le=>le.key==="Enter"&&se(),placeholder:"custom_field_name",className:"flex-1 px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white font-mono text-sm placeholder-bambu-gray-dark focus:border-bambu-green focus:outline-none",autoFocus:!0}),a.jsx(Ce,{size:"sm",onClick:se,disabled:!U.trim(),children:a.jsx(ar,{className:"w-4 h-4"})}),a.jsx(Ce,{size:"sm",variant:"secondary",onClick:()=>{R(!1),O("")},children:a.jsx(Ft,{className:"w-4 h-4"})})]}):a.jsxs("button",{onClick:()=>R(!0),className:"w-full flex items-center justify-center gap-2 p-2 text-sm text-bambu-gray hover:text-white border border-dashed border-bambu-dark-tertiary hover:border-bambu-gray-dark rounded-lg transition-colors",children:[a.jsx(ar,{className:"w-4 h-4"}),r("profiles.presets.addCustomField")]})})]}),a.jsxs("div",{className:"flex flex-col h-full overflow-hidden",children:[a.jsxs("div",{className:"flex items-center justify-between mb-3 flex-shrink-0",children:[a.jsx("h3",{className:"text-sm font-medium text-white",children:r("profiles.presets.yourOverrides")}),a.jsx("span",{className:"text-xs text-bambu-gray",children:r("profiles.templates.fieldsCount",{count:Object.keys(v).filter(le=>le!=="inherits").length})})]}),a.jsxs("div",{className:"flex-1 overflow-y-auto space-y-2 pr-2 min-h-0",children:[Object.entries(v).filter(([le])=>le!=="inherits").map(([le,Le])=>{const Me=ue.find($e=>$e.key===le);return a.jsxs("div",{className:"p-3 bg-bambu-dark rounded-lg border border-bambu-dark-tertiary",children:[a.jsxs("div",{className:"flex items-center justify-between mb-2",children:[a.jsxs("div",{children:[a.jsx("p",{className:"text-sm font-medium text-white",children:Me?.label||le}),a.jsx("p",{className:"text-xs text-bambu-gray-dark",children:le})]}),a.jsx("button",{onClick:()=>Z(le,void 0),className:"p-1 text-bambu-gray hover:text-red-400 transition-colors",children:a.jsx(Ft,{className:"w-4 h-4"})})]}),Me?we(Me):a.jsx("input",{type:"text",value:String(Le),onChange:$e=>Z(le,$e.target.value),className:"w-full px-3 py-1.5 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded text-white text-sm focus:border-bambu-green focus:outline-none"})]},le)}),Object.keys(v).filter(le=>le!=="inherits").length===0&&a.jsxs("div",{className:"text-center py-8 text-bambu-gray",children:[a.jsx($B,{className:"w-8 h-8 mx-auto mb-2 opacity-50"}),a.jsx("p",{className:"text-sm",children:r("profiles.presets.noOverridesYet")}),a.jsx("p",{className:"text-xs mt-1",children:r("profiles.presets.clickFieldsToAdd")})]})]}),Object.keys(v).filter(le=>le!=="inherits").length>0&&a.jsx("div",{className:"pt-3 mt-3 border-t border-bambu-dark-tertiary flex-shrink-0",children:a.jsxs("button",{onClick:()=>{K(!0),c("common")},className:"w-full flex items-center justify-center gap-2 p-2 text-sm text-bambu-gray hover:text-white border border-dashed border-bambu-dark-tertiary hover:border-bambu-gray-dark rounded-lg transition-colors",children:[a.jsx(bs,{className:"w-4 h-4"}),r("profiles.presets.saveAsTemplate")]})})]})]}),l==="json"&&a.jsxs("div",{className:"space-y-2",children:[C&&a.jsxs("div",{className:"flex items-center gap-2 text-red-400 text-sm",children:[a.jsx(Hi,{className:"w-4 h-4"}),C]}),a.jsx("textarea",{value:N,onChange:le=>L(le.target.value),className:`w-full h-80 px-3 py-2 bg-bambu-dark border rounded-lg text-white text-xs font-mono focus:outline-none resize-none ${C?"border-red-500 focus:border-red-500":"border-bambu-dark-tertiary focus:border-bambu-green"}`,spellCheck:!1}),a.jsx("p",{className:"text-xs text-bambu-gray",children:r("profiles.presets.jsonTip")})]})]}),a.jsxs("div",{className:"p-4 border-t border-bambu-dark-tertiary flex gap-2",children:[a.jsx(Ce,{variant:"secondary",onClick:t,className:"flex-1",children:r("common.cancel")}),a.jsxs(Ce,{onClick:()=>xe.mutate(),disabled:xe.isPending||!h.trim()||!o&&!p||!!C,className:"flex-1",children:[xe.isPending?a.jsx(it,{className:"w-4 h-4 animate-spin"}):o?a.jsx(bs,{className:"w-4 h-4"}):a.jsx(ar,{className:"w-4 h-4"}),r(o?"common.save":e?"common.duplicate":"common.create")]})]})]})})]})}function EZe({settings:t,lastSyncTime:e,onRefresh:n,isRefreshing:r,printers:i,hasPermission:s,t:o}){const[l,c]=w.useState(""),[u,d]=w.useState("all"),[h,f]=w.useState("all"),[p,x]=w.useState("all"),[y,b]=w.useState("all"),[v,S]=w.useState("all"),[N,A]=w.useState("all"),[C,T]=w.useState(null),[k,j]=w.useState(!1),[E,P]=w.useState(!1),[U,O]=w.useState(null),[B,R]=w.useState(null),[G,q]=w.useState(null),[z,K]=w.useState(!1),[Y,oe]=w.useState([null,null]),[$,X]=w.useState(!1),[ee,J]=w.useState(null),_e=tn(),pe=w.useMemo(()=>[...t.filament.map(se=>({...se,type:"filament"})),...t.printer.map(se=>({...se,type:"printer"})),...t.process.map(se=>({...se,type:"process"}))].map(se=>({...se,meta:xI(se.name)})),[t]),me=w.useMemo(()=>{const Q=new Set,se=new Set,Z=new Set;return pe.forEach(Ne=>{Ne.meta.nozzle&&Q.add(Ne.meta.nozzle),Ne.meta.filamentType&&se.add(Ne.meta.filamentType),Ne.meta.layerHeight&&Z.add(Ne.meta.layerHeight)}),{printers:i.map(Ne=>({id:Ne.id.toString(),name:Ne.name})),nozzles:Array.from(Q).sort((Ne,ve)=>parseFloat(Ne)-parseFloat(ve)),filaments:Array.from(se).sort(),layerHeights:Array.from(Z).sort((Ne,ve)=>parseFloat(Ne)-parseFloat(ve))}},[pe,i]),je=w.useMemo(()=>p==="all"?null:i.find(se=>se.id.toString()===p)?.model||null,[p,i]),de=w.useMemo(()=>pe.filter(Q=>u==="all"||Q.type===u).filter(Q=>{if(h==="all")return!0;const se=mv(Q.setting_id);return h==="custom"?se:!se}).filter(Q=>{if(p==="all"||!je)return!0;const se=Q.meta.printer?.toLowerCase()||"",Z=je.toLowerCase();return se.includes(Z)||Z.includes(se)}).filter(Q=>y==="all"||Q.meta.nozzle===y).filter(Q=>v==="all"||Q.meta.filamentType===v).filter(Q=>N==="all"||Q.meta.layerHeight===N).filter(Q=>l===""||Q.name.toLowerCase().includes(l.toLowerCase())).sort((Q,se)=>Q.name.localeCompare(se.name)),[pe,u,h,p,je,y,v,N,l]),ce=Q=>{if(z){const se=Y[0]?.setting_id===Q.setting_id,Z=Y[1]?.setting_id===Q.setting_id;if(se)oe([Y[1],null]);else if(Z)oe([Y[0],null]);else if(!Y[0])oe([Q,null]);else if(Y[1]){if(Y[0].type!==Q.type)return;oe([Y[0],Q])}else{if(Y[0].type!==Q.type)return;oe([Y[0],Q])}}else T(Q)},Se=Q=>{if(Y[0]?.setting_id===Q.setting_id)return 0;if(Y[1]?.setting_id===Q.setting_id)return 1},ie=async Q=>{try{const se=await re.getCloudSettingDetail(Q.setting_id),Z=Q.type==="process"?"print":Q.type;O({type:Z,name:Q.name,base_id:se.base_id||"GFSA00",setting:se.setting||{}}),T(null)}catch(se){console.error("Failed to fetch preset details for duplication:",se)}},Fe=async Q=>{try{_e.removeQueries({queryKey:["cloudSettingDetail",Q.setting_id]});const se=await re.getCloudSettingDetail(Q.setting_id),Z=Q.type==="process"?"print":Q.type;R({type:Z,name:Q.name,base_id:se.base_id||"GFSA00",setting:se.setting||{},setting_id:Q.setting_id}),T(null)}catch(se){console.error("Failed to fetch preset details for editing:",se)}},V=()=>{d("all"),f("all"),x("all"),b("all"),S("all"),A("all"),c("")},W=u!=="all"||h!=="all"||p!=="all"||y!=="all"||v!=="all"||N!=="all"||l!=="",ue=t.filament.length+t.printer.length+t.process.length;return a.jsxs(a.Fragment,{children:[a.jsxs("div",{className:"space-y-4 mb-6",children:[a.jsxs("div",{className:"flex flex-col sm:flex-row gap-3",children:[a.jsxs("div",{className:"relative flex-1",children:[a.jsx(Or,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray"}),a.jsx("input",{type:"text",value:l,onChange:Q=>c(Q.target.value),placeholder:o("profiles.cloudView.searchPlaceholder"),className:"w-full pl-10 pr-4 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white placeholder-bambu-gray-dark focus:border-bambu-green focus:outline-none"})]}),a.jsxs("div",{className:"flex gap-2 max-[550px]:flex-wrap max-[550px]:items-center",children:[a.jsxs(Ce,{variant:z?"primary":"secondary",onClick:()=>{z?(K(!1),oe([null,null])):K(!0)},children:[a.jsx(Yg,{className:"w-4 h-4"}),o(z?"common.cancel":"profiles.presets.compare")]}),a.jsxs(Ce,{variant:"secondary",onClick:()=>P(!0),disabled:!s("cloud:auth"),title:s("cloud:auth")?void 0:o("profiles.cloudView.noTemplatesPermission"),children:[a.jsx(pb,{className:"w-4 h-4"}),o("profiles.cloudView.templates")]}),a.jsxs(Ce,{variant:"secondary",onClick:n,disabled:r||!s("cloud:auth"),title:s("cloud:auth")?void 0:o("profiles.cloudView.noRefreshPermission"),children:[a.jsx(kr,{className:`w-4 h-4 ${r?"animate-spin":""}`}),o("profiles.cloudView.refresh")]}),a.jsxs(Ce,{onClick:()=>j(!0),disabled:!s("cloud:auth"),title:s("cloud:auth")?void 0:o("profiles.cloudView.noCreatePermission"),children:[a.jsx(ar,{className:"w-4 h-4"}),o("profiles.cloudView.newPreset")]})]})]}),a.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[a.jsx(tC,{className:"w-4 h-4 text-bambu-gray"}),a.jsx(Dg,{label:o("profiles.cloudView.filters.type"),value:u,options:[{value:"all",label:o("profiles.cloudView.filters.all"),count:ue},{value:"filament",label:o("profiles.cloudView.filters.filament"),count:t.filament.length},{value:"printer",label:o("profiles.cloudView.filters.printer"),count:t.printer.length},{value:"process",label:o("profiles.cloudView.filters.process"),count:t.process.length}],onChange:Q=>d(Q)}),a.jsx(Dg,{label:o("profiles.cloudView.filters.owner"),value:h,options:[{value:"all",label:o("profiles.cloudView.filters.all")},{value:"custom",label:o("profiles.cloudView.filters.myPresets")},{value:"builtin",label:o("profiles.cloudView.filters.builtIn")}],onChange:Q=>f(Q)}),me.printers.length>0&&a.jsx(Dg,{label:o("profiles.cloudView.filters.printer"),value:p,options:[{value:"all",label:o("profiles.cloudView.filters.all")},...me.printers.map(Q=>({value:Q.id,label:Q.name}))],onChange:x}),me.nozzles.length>0&&a.jsx(Dg,{label:o("profiles.cloudView.filters.nozzle"),value:y,options:[{value:"all",label:o("profiles.cloudView.filters.all")},...me.nozzles.map(Q=>({value:Q,label:Q}))],onChange:b}),me.filaments.length>0&&(u==="all"||u==="filament")&&a.jsx(Dg,{label:o("profiles.cloudView.filters.filament"),value:v,options:[{value:"all",label:o("profiles.cloudView.filters.all")},...me.filaments.map(Q=>({value:Q,label:Q}))],onChange:S}),me.layerHeights.length>0&&(u==="all"||u==="process")&&a.jsx(Dg,{label:o("profiles.cloudView.filters.layer"),value:N,options:[{value:"all",label:o("profiles.cloudView.filters.all")},...me.layerHeights.map(Q=>({value:Q,label:Q}))],onChange:A}),W&&a.jsx("button",{onClick:V,className:"px-3 py-2 text-sm text-bambu-gray hover:text-white transition-colors",children:o("profiles.cloudView.clearFilters")})]})]}),z&&a.jsx("div",{className:"mb-4 p-3 bg-blue-500/10 border border-blue-500/30 rounded-lg",children:a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsxs("div",{className:"flex items-center gap-4",children:[a.jsx(Yg,{className:"w-5 h-5 text-blue-400"}),a.jsx("span",{className:"text-white font-medium",children:o("profiles.cloudView.compareMode")}),a.jsx("span",{className:"text-bambu-gray",children:Y[0]?o("profiles.cloudView.selectAnotherPreset",{type:Y[0].type}):o("profiles.cloudView.clickTwoPresets")})]}),a.jsxs("div",{className:"flex items-center gap-3",children:[a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx("span",{className:`px-2 py-1 text-sm rounded truncate max-w-[200px] ${Y[0]?"bg-blue-500/30 text-blue-700 dark:text-blue-300":"bg-bambu-dark text-bambu-gray"}`,children:Y[0]?Y[0].name:o("profiles.cloudView.selectFirst")}),a.jsx(h3,{className:"w-4 h-4 text-bambu-gray"}),a.jsx("span",{className:`px-2 py-1 text-sm rounded truncate max-w-[200px] ${Y[1]?"bg-blue-500/30 text-blue-700 dark:text-blue-300":"bg-bambu-dark text-bambu-gray"}`,children:Y[1]?Y[1].name:o("profiles.cloudView.selectSecond")})]}),Y[0]&&Y[1]&&a.jsxs(Ce,{size:"sm",onClick:async()=>{try{const[Q,se]=await Promise.all([re.getCloudSettingDetail(Y[0].setting_id),re.getCloudSettingDetail(Y[1].setting_id)]);J([Q.setting||{},se.setting||{}]),X(!0)}catch{}},children:[a.jsx(Yg,{className:"w-4 h-4"}),o("profiles.cloudView.compareNow")]})]})]})}),a.jsxs("div",{className:"flex flex-wrap items-center gap-4 mb-4 text-sm text-bambu-gray",children:[e&&a.jsxs("div",{className:"flex items-center gap-1",children:[a.jsx(Wn,{className:"w-3 h-3"}),o("profiles.cloudView.lastSynced")," ",NZe(e.toISOString(),o)]}),a.jsx("span",{children:o("profiles.cloudView.showingCount",{showing:de.length,total:ue})}),a.jsxs("div",{className:"flex items-center gap-1",children:[a.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-bambu-green"}),a.jsxs("span",{children:["= ",o("profiles.presets.myPreset")]})]})]}),de.length===0?a.jsxs("div",{className:"text-center py-16",children:[a.jsx(ma,{className:"w-12 h-12 text-bambu-gray-dark mx-auto mb-4"}),a.jsx("p",{className:"text-bambu-gray",children:o("profiles.cloudView.noPresetsFound")}),W&&a.jsx("button",{onClick:V,className:"mt-2 text-sm text-bambu-green hover:text-bambu-green-light",children:o("profiles.cloudView.clearFilters")})]}):a.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-6",children:[a.jsxs("div",{children:[a.jsxs("div",{className:"flex items-center gap-2 mb-3 px-1",children:[a.jsx(Jk,{className:"w-4 h-4 text-amber-400"}),a.jsx("h3",{className:"text-sm font-medium text-bambu-gray",children:o("profiles.cloudView.columns.filament")}),a.jsxs("span",{className:"text-xs text-bambu-gray-dark",children:["(",de.filter(Q=>Q.type==="filament").length,")"]})]}),a.jsxs("div",{className:"space-y-1 max-h-[calc(100vh-320px)] overflow-y-auto pr-1",children:[de.filter(Q=>Q.type==="filament").map(Q=>a.jsx(Vj,{setting:Q,onClick:()=>ce(Q),onDuplicate:()=>ie(Q),compareMode:z,isCompareSelected:Se(Q)!==void 0,compareIndex:Se(Q),compareDisabled:z&&!!Y[0]&&Y[0].type!==Q.type,t:o},Q.setting_id)),de.filter(Q=>Q.type==="filament").length===0&&a.jsx("p",{className:"text-xs text-bambu-gray-dark px-3 py-2",children:o("profiles.cloudView.noFilamentPresets")})]})]}),a.jsxs("div",{children:[a.jsxs("div",{className:"flex items-center gap-2 mb-3 px-1",children:[a.jsx(nd,{className:"w-4 h-4 text-blue-400"}),a.jsx("h3",{className:"text-sm font-medium text-bambu-gray",children:o("profiles.cloudView.columns.process")}),a.jsxs("span",{className:"text-xs text-bambu-gray-dark",children:["(",de.filter(Q=>Q.type==="process").length,")"]})]}),a.jsxs("div",{className:"space-y-1 max-h-[calc(100vh-320px)] overflow-y-auto pr-1",children:[de.filter(Q=>Q.type==="process").map(Q=>a.jsx(Vj,{setting:Q,onClick:()=>ce(Q),onDuplicate:()=>ie(Q),compareMode:z,isCompareSelected:Se(Q)!==void 0,compareIndex:Se(Q),compareDisabled:z&&!!Y[0]&&Y[0].type!==Q.type,t:o},Q.setting_id)),de.filter(Q=>Q.type==="process").length===0&&a.jsx("p",{className:"text-xs text-bambu-gray-dark px-3 py-2",children:o("profiles.cloudView.noProcessPresets")})]})]}),a.jsxs("div",{children:[a.jsxs("div",{className:"flex items-center gap-2 mb-3 px-1",children:[a.jsx(Cr,{className:"w-4 h-4 text-purple-400"}),a.jsx("h3",{className:"text-sm font-medium text-bambu-gray",children:o("profiles.cloudView.columns.printer")}),a.jsxs("span",{className:"text-xs text-bambu-gray-dark",children:["(",de.filter(Q=>Q.type==="printer").length,")"]})]}),a.jsxs("div",{className:"space-y-1 max-h-[calc(100vh-320px)] overflow-y-auto pr-1",children:[de.filter(Q=>Q.type==="printer").map(Q=>a.jsx(Vj,{setting:Q,onClick:()=>ce(Q),onDuplicate:()=>ie(Q),compareMode:z,isCompareSelected:Se(Q)!==void 0,compareIndex:Se(Q),compareDisabled:z&&!!Y[0]&&Y[0].type!==Q.type,t:o},Q.setting_id)),de.filter(Q=>Q.type==="printer").length===0&&a.jsx("p",{className:"text-xs text-bambu-gray-dark px-3 py-2",children:o("profiles.cloudView.noPrinterPresets")})]})]})]}),C&&a.jsx(MZe,{setting:C,onClose:()=>T(null),onDeleted:()=>T(null),onDuplicate:()=>ie(C),onEdit:()=>Fe(C),hasPermission:s,t:o}),(k||U||B||G)&&a.jsx(TZe,{onClose:()=>{j(!1),O(null),R(null),q(null)},initialData:B||U||(G?{type:G.type,name:"",base_id:"",setting:G.setting}:void 0),allPresets:t,t:o}),E&&a.jsx(AZe,{onClose:()=>P(!1),onApply:Q=>{q({type:Q.type,setting:Q.settings}),P(!1)},t:o}),$&&ee&&Y[0]&&Y[1]&&a.jsx(Xae,{onClose:()=>{X(!1),J(null)},leftPreset:ee[0],rightPreset:ee[1],leftLabel:Y[0].name,rightLabel:Y[1].name,t:o})]})}function PZe(){const{t}=Vt(),e=tn(),{showToast:n}=hn(),{hasPermission:r}=Ir(),[i,s]=w.useState("cloud"),[o,l]=w.useState(),{data:c,isLoading:u}=Ze({queryKey:["cloudStatus"],queryFn:re.getCloudStatus}),{data:d=[]}=Ze({queryKey:["printers"],queryFn:re.getPrinters}),{data:h,isLoading:f,refetch:p,dataUpdatedAt:x}=Ze({queryKey:["cloudSettings"],queryFn:()=>re.getCloudSettings(),enabled:!!c?.is_authenticated,retry:!1,staleTime:1e3*60*5});w.useEffect(()=>{x&&l(new Date(x))},[x]);const y=ot({mutationFn:re.cloudLogout,onSuccess:()=>{e.invalidateQueries({queryKey:["cloudStatus"]}),e.removeQueries({queryKey:["cloudSettings"]}),n(t("profiles.toast.loggedOut"))}}),b=()=>{e.invalidateQueries({queryKey:["cloudStatus"]})};return u?a.jsx("div",{className:"p-4 md:p-8 flex items-center justify-center min-h-[400px]",children:a.jsx(it,{className:"w-8 h-8 text-bambu-green animate-spin"})}):a.jsxs("div",{className:"p-6 lg:p-8",children:[a.jsxs("div",{className:"mb-6",children:[a.jsx("h1",{className:"text-2xl font-bold text-white",children:t("profiles.title")}),a.jsx("p",{className:"text-bambu-gray",children:t("profiles.subtitle")})]}),a.jsxs("div",{className:"flex border-b border-bambu-dark-tertiary mb-6",children:[a.jsxs("button",{onClick:()=>s("cloud"),className:`flex items-center gap-2 px-4 py-3 text-sm font-medium transition-colors border-b-2 -mb-px ${i==="cloud"?"text-bambu-green border-bambu-green":"text-bambu-gray hover:text-white border-transparent"}`,children:[a.jsx(Gb,{className:"w-4 h-4"}),t("profiles.tabs.cloud")]}),a.jsxs("button",{onClick:()=>s("local"),className:`flex items-center gap-2 px-4 py-3 text-sm font-medium transition-colors border-b-2 -mb-px ${i==="local"?"text-bambu-green border-bambu-green":"text-bambu-gray hover:text-white border-transparent"}`,children:[a.jsx(qb,{className:"w-4 h-4"}),t("profiles.tabs.local")]}),a.jsxs("button",{onClick:()=>s("kprofiles"),className:`flex items-center gap-2 px-4 py-3 text-sm font-medium transition-colors border-b-2 -mb-px ${i==="kprofiles"?"text-bambu-green border-bambu-green":"text-bambu-gray hover:text-white border-transparent"}`,children:[a.jsx(nC,{className:"w-4 h-4"}),t("profiles.tabs.kprofiles")]})]}),i==="cloud"&&a.jsxs(a.Fragment,{children:[c?.is_authenticated&&a.jsxs("div",{className:"flex items-center justify-between p-3 mb-6 bg-bambu-dark rounded-lg border border-bambu-dark-tertiary",children:[a.jsxs("div",{className:"flex items-center gap-3",children:[a.jsx("div",{className:"w-2 h-2 rounded-full bg-bambu-green animate-pulse"}),a.jsxs("span",{className:"text-sm text-bambu-gray",children:[t("profiles.connectedAs")," ",a.jsx("span",{className:"text-white",children:c.email})]})]}),a.jsxs(Ce,{variant:"secondary",size:"sm",onClick:()=>y.mutate(),disabled:y.isPending||!r("cloud:auth"),title:r("cloud:auth")?void 0:t("profiles.noLogoutPermission"),children:[a.jsx(x3,{className:"w-4 h-4"}),t("profiles.logout")]})]}),c?.is_authenticated?f?a.jsx("div",{className:"flex items-center justify-center py-16",children:a.jsx(it,{className:"w-8 h-8 text-bambu-green animate-spin"})}):h?a.jsx(EZe,{settings:h,lastSyncTime:o,onRefresh:()=>p(),isRefreshing:f,printers:d,hasPermission:r,t}):a.jsxs("div",{className:"text-center py-16",children:[a.jsx("p",{className:"text-bambu-gray mb-4",children:t("profiles.failedToLoad")}),a.jsx(Ce,{onClick:()=>p(),children:t("profiles.retry")})]}):a.jsx(kZe,{onSuccess:b,t})]}),i==="local"&&a.jsx(SZe,{}),i==="kprofiles"&&a.jsx(yZe,{}),a.jsx(CZe,{})]})}const Ky={Droplet:Jk,Flame:Qhe,Ruler:Tfe,Sparkles:pb,Square:bl,Cable:Lde,Wrench:Ff,Calendar:ii,Timer:Iu,Cog:vhe,Fan:hX,Zap:Wh,Wind:SX,Thermometer:uC,Layers:ma,Box:ea,Target:vX,RefreshCw:kr,Settings:cC,Filter:tC,CircleDot:rhe};function x0(t){return t&&Ky[t]||Ff}function Rg(t,e,n){if(e==="days"){if(t<1)return n?n("common.today"):"Today";if(t===1)return n?n("maintenance.day"):"1 day";if(t<7){const i=Math.round(t);return n?n("maintenance.days",{count:i}):`${i} days`}if(t<180){const i=Math.round(t/7);return i===1?n?n("maintenance.week"):"1 week":n?n("maintenance.weeks",{count:i}):`${i} weeks`}const r=Math.round(t/30);return r===1?n?n("maintenance.month"):"1 month":n?n("maintenance.months",{count:r}):`${r} months`}else{if(t<1)return`${Math.round(t*60)}m`;if(t<24)return`${t<10?t.toFixed(1):Math.round(t)}h`;const r=t/24;if(r<7)return`${r<2?r.toFixed(1):Math.round(r)}d`;const i=r/7;return i<12?`${i<2?i.toFixed(1):Math.round(i)}w`:`${Math.round(i/4)}mo`}}function Gj(t,e,n){return e==="days"?t===1?n?n("maintenance.day"):"1 day":t===7?n?n("maintenance.week"):"1 week":t===14?n?n("maintenance.weeks",{count:2}):"2 weeks":t===30?n?n("maintenance.month"):"1 month":t===60?n?n("maintenance.months",{count:2}):"2 months":t===90?n?n("maintenance.months",{count:3}):"3 months":t===180?n?n("maintenance.months",{count:6}):"6 months":t===365?n?n("maintenance.year"):"1 year":n?n("maintenance.days",{count:t}):`${t} days`:`${t}h`}function jZe(t,e){const n=(e||"").toUpperCase().replace(/[- ]/g,""),r=n.includes("X1"),i=n.includes("P1"),s=n.includes("A1MINI"),o=n.includes("A1")&&!s,l=n.includes("H2D"),c=n.includes("H2C"),u=n.includes("H2S"),d=l||c||u,h=n.includes("P2S");switch(t){case"Lubricate Carbon Rods":return r?"https://wiki.bambulab.com/en/x1/maintenance/basic-maintenance":i?"https://wiki.bambulab.com/en/p1/maintenance/p1p-maintenance":h?"https://wiki.bambulab.com/en/p2s/maintenance/belt-tension":null;case"Lubricate Linear Rails":return s?"https://wiki.bambulab.com/en/a1-mini/maintenance/lubricate-y-axis":o?"https://wiki.bambulab.com/en/a1/maintenance/lubricate-y-axis":d?"https://wiki.bambulab.com/en/h2/maintenance/x-axis-lubrication":null;case"Clean Nozzle/Hotend":return r||i?"https://wiki.bambulab.com/en/x1/troubleshooting/nozzle-clog":s||o?"https://wiki.bambulab.com/en/a1-mini/troubleshooting/nozzle-clog":d?"https://wiki.bambulab.com/en/h2/maintenance/nozzl-cold-pull-maintenance-and-cleaning":h?"https://wiki.bambulab.com/en/p2s/maintenance/cold-pull-maintenance-hotend":"https://wiki.bambulab.com/en/x1/troubleshooting/nozzle-clog";case"Check Belt Tension":return r?"https://wiki.bambulab.com/en/x1/maintenance/belt-tension":i?"https://wiki.bambulab.com/en/p1/maintenance/p1p-maintenance":s?"https://wiki.bambulab.com/en/a1-mini/maintenance/belt_tension":o?"https://wiki.bambulab.com/en/a1/maintenance/belt_tension":l?"https://wiki.bambulab.com/en/h2/maintenance/belt-tension":c?"https://wiki.bambulab.com/en/h2c/maintenance/belt-tension":u?"https://wiki.bambulab.com/en/h2s/maintenance/belt-tension":h?"https://wiki.bambulab.com/en/p2s/maintenance/belt-tension":"https://wiki.bambulab.com/en/x1/maintenance/belt-tension";case"Clean Carbon Rods":return r||i||h?"https://wiki.bambulab.com/en/general/carbon-rods-clearance":null;case"Clean Linear Rails":return s?"https://wiki.bambulab.com/en/a1-mini/maintenance/lubricate-y-axis":o?"https://wiki.bambulab.com/en/a1/maintenance/lubricate-y-axis":d?"https://wiki.bambulab.com/en/h2/maintenance/x-axis-lubrication":null;case"Clean Build Plate":return"https://wiki.bambulab.com/en/filament-acc/acc/pei-plate-clean-guide";case"Check PTFE Tube":return r||i?"https://wiki.bambulab.com/en/x1/maintenance/replace-ptfe-tube":s||o?"https://wiki.bambulab.com/en/a1-mini/maintenance/ptfe-tube":l?"https://wiki.bambulab.com/en/h2/maintenance/replace-ptfe-tube-on-h2d-printer":u?"https://wiki.bambulab.com/en/h2s/maintenance/replace-ptfe-tube-on-h2s-printer":c?"https://wiki.bambulab.com/en/h2/maintenance/replace-ptfe-tube-on-h2d-printer":"https://wiki.bambulab.com/en/x1/maintenance/replace-ptfe-tube";case"Replace HEPA Filter":case"HEPA Filter":case"Replace Carbon Filter":case"Carbon Filter":return d?"https://wiki.bambulab.com/en/h2/maintenance/replace-smoke-purifier-air-filte":"https://wiki.bambulab.com/en/x1/maintenance/replace-carbon-filter";case"Lubricate Left Nozzle Rail":case"Left Nozzle Rail":return d?"https://wiki.bambulab.com/en/h2/maintenance/x-axis-lubrication":null;default:return null}}function DZe({item:t,onPerform:e,onToggle:n,hasPermission:r,t:i}){const s=x0(t.maintenance_type_icon),o=t.interval_type||"hours",c=(()=>{if(o==="days"){const p=t.days_since_maintenance??0;return Math.max(0,Math.min(100,p/t.interval_hours*100))}return Math.max(0,Math.min(100,(t.interval_hours-t.hours_until_due)/t.interval_hours*100))})(),u=()=>t.enabled?t.is_due?"text-red-400":t.is_warning?"text-amber-400":"text-bambu-green":"text-bambu-gray",d=()=>t.enabled?t.is_due?"bg-red-500":t.is_warning?"bg-amber-500":"bg-bambu-green":"bg-bambu-gray/30",h=()=>t.enabled?t.is_due?"bg-red-500/5 border-red-500/20":t.is_warning?"bg-amber-500/5 border-amber-500/20":"bg-bambu-dark-secondary border-bambu-dark-tertiary":"bg-bambu-dark-secondary/50",f=()=>{if(!t.enabled)return i("common.disabled");if(o==="days"){const p=t.days_until_due??0;return t.is_due?i("maintenance.overdueBy",{duration:Rg(Math.abs(p),"days",i)}):t.is_warning?i("maintenance.dueIn",{duration:Rg(p,"days",i)}):i("maintenance.timeLeft",{duration:Rg(p,"days",i)})}else return t.is_due?i("maintenance.overdueBy",{duration:Rg(Math.abs(t.hours_until_due),"hours",i)}):t.is_warning?i("maintenance.dueIn",{duration:Rg(t.hours_until_due,"hours",i)}):i("maintenance.timeLeft",{duration:Rg(t.hours_until_due,"hours",i)})};return a.jsx("div",{className:`rounded-xl border p-4 transition-all ${h()}`,children:a.jsxs("div",{className:"flex items-start gap-3 max-[550px]:flex-wrap",children:[a.jsxs("div",{className:`relative p-2.5 rounded-lg shrink-0 ${t.is_due?"bg-red-500/20":t.is_warning?"bg-amber-500/20":t.enabled?"bg-bambu-dark":"bg-bambu-dark/50"}`,children:[a.jsx(s,{className:`w-5 h-5 ${u()}`}),t.enabled&&(t.is_due||t.is_warning)&&a.jsx("span",{className:`absolute -top-1 -right-1 w-2.5 h-2.5 rounded-full ${t.is_due?"bg-red-500":"bg-amber-500"} animate-pulse`})]}),a.jsxs("div",{className:"flex-1 min-w-0",children:[a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx("h3",{className:`font-medium truncate ${t.enabled?"text-white":"text-bambu-gray"}`,children:t.maintenance_type_name}),o==="days"&&a.jsx("span",{title:i("maintenance.timeBasedInterval"),children:a.jsx(ii,{className:"w-3.5 h-3.5 text-bambu-gray shrink-0"})}),(()=>{const p=t.maintenance_type_wiki_url||jZe(t.maintenance_type_name,t.printer_model);return p?a.jsx("a",{href:p,target:"_blank",rel:"noopener noreferrer",className:"text-bambu-gray hover:text-bambu-green transition-colors shrink-0",title:i("maintenance.viewDocumentation"),onClick:x=>x.stopPropagation(),children:a.jsx(Kr,{className:"w-3.5 h-3.5"})}):null})()]}),a.jsx("div",{className:"mt-2 mb-1.5",children:a.jsx("div",{className:"w-full h-1.5 bg-bambu-dark rounded-full overflow-hidden",children:a.jsx("div",{className:`h-full rounded-full transition-all duration-500 ${d()}`,style:{width:`${c}%`}})})}),a.jsxs("div",{className:`text-xs flex items-center gap-1 ${u()}`,children:[t.is_due&&a.jsx(Cn,{className:"w-3 h-3"}),t.is_warning&&!t.is_due&&a.jsx(Wn,{className:"w-3 h-3"}),!t.is_due&&!t.is_warning&&t.enabled&&a.jsx(Xr,{className:"w-3 h-3"}),f()]})]}),a.jsxs("div",{className:"flex items-center gap-2 shrink-0 max-[550px]:w-full max-[550px]:justify-end max-[550px]:mt-1",children:[a.jsx("span",{title:r("maintenance:update")?void 0:i("maintenance.noPermissionUpdate"),children:a.jsx(zn,{checked:t.enabled,onChange:p=>n(t.id,p),disabled:!r("maintenance:update")})}),a.jsxs(Ce,{size:"sm",variant:t.is_due?"primary":"secondary",onClick:()=>e(t.id),disabled:!t.enabled||!r("maintenance:update"),title:r("maintenance:update")?void 0:i("maintenance.noPermissionPerform"),className:"!px-3",children:[a.jsx(Ro,{className:"w-3.5 h-3.5"}),i("common.reset")]})]})]})})}function RZe({overview:t,onPerform:e,onToggle:n,onSetHours:r,hasPermission:i,t:s}){const[o,l]=w.useState(!1),[c,u]=w.useState(!1),[d,h]=w.useState(t.total_print_hours.toFixed(1)),f=[...t.maintenance_items].sort((y,b)=>y.is_due&&!b.is_due?-1:!y.is_due&&b.is_due?1:y.is_warning&&!b.is_warning?-1:!y.is_warning&&b.is_warning?1:y.maintenance_type_id-b.maintenance_type_id),p=f.find(y=>y.enabled&&(y.is_due||y.is_warning)),x=()=>{const y=parseFloat(d);!isNaN(y)&&y>=0&&(r(t.printer_id,y),u(!1))};return a.jsxs(vt,{className:"overflow-hidden",children:[a.jsxs("div",{className:"p-5",children:[a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsxs("div",{className:"flex items-center gap-4",children:[a.jsx("h2",{className:"text-xl font-semibold text-white",children:t.printer_name}),a.jsxs("div",{className:"flex items-center gap-2",children:[t.due_count>0&&a.jsxs("span",{className:"px-2.5 py-1 bg-red-500/20 text-red-400 text-xs font-medium rounded-full flex items-center gap-1.5",children:[a.jsx(Cn,{className:"w-3 h-3"}),s("maintenance.overdueCount",{count:t.due_count})]}),t.warning_count>0&&a.jsxs("span",{className:"px-2.5 py-1 bg-amber-500/20 text-amber-400 text-xs font-medium rounded-full flex items-center gap-1.5",children:[a.jsx(Wn,{className:"w-3 h-3"}),s("maintenance.dueSoonCount",{count:t.warning_count})]}),t.due_count===0&&t.warning_count===0&&a.jsxs("span",{className:"px-2.5 py-1 bg-bambu-green/20 text-bambu-green text-xs font-medium rounded-full flex items-center gap-1.5",children:[a.jsx(Xr,{className:"w-3 h-3"}),s("maintenance.allGood")]})]})]}),a.jsxs("button",{onClick:()=>l(!o),className:"flex items-center gap-1.5 px-3 py-1.5 text-sm text-bambu-gray hover:text-white hover:bg-bambu-dark rounded-lg transition-colors",children:[o?a.jsx(Wl,{className:"w-4 h-4"}):a.jsx(nr,{className:"w-4 h-4"}),s(o?"common.collapse":"common.expand")]})]}),a.jsxs("div",{className:"flex items-center gap-6 mt-4",children:[a.jsxs("div",{className:"flex items-center gap-3",children:[a.jsx("div",{className:"p-2 bg-bambu-dark/50 rounded-lg",children:a.jsx(Iu,{className:"w-4 h-4 text-bambu-gray"})}),c?a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx("input",{type:"number",value:d,onChange:y=>h(y.target.value),onKeyDown:y=>{y.key==="Enter"&&x(),y.key==="Escape"&&u(!1)},className:"w-24 px-2 py-1 bg-bambu-dark border border-bambu-dark-tertiary rounded text-white text-sm",min:"0",step:"1",autoFocus:!0}),a.jsx("span",{className:"text-xs text-bambu-gray",children:s("common.hours")}),a.jsx(Ce,{size:"sm",onClick:x,children:s("common.save")}),a.jsx(Ce,{size:"sm",variant:"secondary",onClick:()=>u(!1),children:s("common.cancel")})]}):a.jsxs("button",{onClick:()=>{i("maintenance:update")&&(h(Math.round(t.total_print_hours).toString()),u(!0))},className:`group ${i("maintenance:update")?"":"cursor-not-allowed opacity-60"}`,title:i("maintenance:update")?void 0:s("maintenance.noPermissionEditHours"),children:[a.jsxs("div",{className:`text-sm font-medium text-white ${i("maintenance:update")?"group-hover:text-bambu-green":""} transition-colors flex items-center gap-1`,children:[Math.round(t.total_print_hours)," ",s("common.hours"),a.jsx(jf,{className:`w-3 h-3 text-bambu-gray ${i("maintenance:update")?"group-hover:text-bambu-green":""}`})]}),a.jsx("div",{className:"text-xs text-bambu-gray",children:s("maintenance.totalPrintTime")})]})]}),a.jsx("div",{className:"w-px h-10 bg-bambu-dark-tertiary"}),p&&a.jsxs("div",{className:"flex items-center gap-3",children:[a.jsx("div",{className:`p-2 rounded-lg ${p.is_due?"bg-red-500/20":"bg-amber-500/20"}`,children:(()=>{const y=x0(p.maintenance_type_icon);return a.jsx(y,{className:`w-4 h-4 ${p.is_due?"text-red-400":"text-amber-400"}`})})()}),a.jsxs("div",{children:[a.jsx("div",{className:`text-sm font-medium ${p.is_due?"text-red-400":"text-amber-400"}`,children:p.maintenance_type_name}),a.jsx("div",{className:`text-xs ${p.is_due?"text-red-400/70":"text-amber-400/70"}`,children:p.is_due?s("common.overdue"):s("maintenance.dueSoon")})]})]})]})]}),o&&a.jsx(Nt,{className:"pt-0 border-t border-bambu-dark-tertiary",children:a.jsx("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-3 pt-4",children:f.map(y=>a.jsx(DZe,{item:y,onPerform:e,onToggle:n,hasPermission:i,t:s},y.id))})})]})}function FZe({overview:t,types:e,onUpdateInterval:n,onAddType:r,onUpdateType:i,onDeleteType:s,onRestoreDefaults:o,isRestoringDefaults:l,onAssignType:c,onRemoveItem:u,hasPermission:d,t:h}){const[f,p]=w.useState(null),[x,y]=w.useState(""),[b,v]=w.useState("hours"),[S,N]=w.useState(!1),[A,C]=w.useState(""),[T,k]=w.useState("100"),[j,E]=w.useState("hours"),[P,U]=w.useState("Wrench"),[O,B]=w.useState(""),[R,G]=w.useState(new Set),[q,z]=w.useState(null),[K,Y]=w.useState(null),oe=w.useMemo(()=>t?t.map(L=>({id:L.printer_id,name:L.printer_name})):[],[t]),$=L=>t?t.filter(D=>D.maintenance_items.some(H=>H.maintenance_type_id===L)).map(D=>({printerId:D.printer_id,printerName:D.printer_name,itemId:D.maintenance_items.find(H=>H.maintenance_type_id===L)?.id})):[],X=L=>{if(!t)return[];const D=new Set($(L).map(H=>H.printerId));return oe.filter(H=>!D.has(H.id))},[ee,J]=w.useState(null),[_e,pe]=w.useState(""),[me,je]=w.useState(""),[de,ce]=w.useState("hours"),[Se,ie]=w.useState("Wrench"),[Fe,V]=w.useState(""),W=L=>{J(L),pe(L.name),je(L.default_interval_hours.toString()),ce(L.interval_type||"hours"),ie(L.icon||"Wrench"),V(L.wiki_url||"")},ue=()=>{ee&&_e.trim()&&parseFloat(me)>0&&(i(ee.id,{name:_e.trim(),default_interval_hours:parseFloat(me),interval_type:de,icon:Se,wiki_url:Fe.trim()||null}),J(null))},Q=(L,D,H)=>{const he=parseFloat(x);if(!isNaN(he)&&he>0){const xe=Math.abs(he-D)<.01?null:he;n(L,{custom_interval_hours:xe,custom_interval_type:b!==H?b:null})}p(null)},se=L=>{L.preventDefault(),A.trim()&&parseFloat(T)>0&&R.size>0&&(r({name:A.trim(),default_interval_hours:parseFloat(T),interval_type:j,icon:P,wiki_url:O.trim()||null},Array.from(R)),C(""),k("100"),E("hours"),B(""),G(new Set),N(!1))},Z=L=>{G(D=>{const H=new Set(D);return H.has(L)?H.delete(L):H.add(L),H})},Ne=t?.map(L=>({printerId:L.printer_id,printerName:L.printer_name,items:L.maintenance_items.sort((D,H)=>D.maintenance_type_id-H.maintenance_type_id)})).sort((L,D)=>L.printerName.localeCompare(D.printerName))||[],ve=e.filter(L=>L.is_system),fe=e.filter(L=>!L.is_system);return a.jsxs("div",{className:"space-y-8",children:[a.jsxs("div",{children:[a.jsxs("div",{className:"flex items-center justify-between mb-4",children:[a.jsxs("div",{children:[a.jsx("h2",{className:"text-lg font-semibold text-white",children:h("maintenance.maintenanceTypes")}),a.jsx("p",{className:"text-sm text-bambu-gray mt-1",children:h("maintenance.maintenanceTypesDescription")})]}),a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx(Ce,{variant:"secondary",onClick:o,disabled:!d("maintenance:delete")||l,title:d("maintenance:delete")?void 0:h("maintenance.noPermissionDeleteTypes"),children:h("maintenance.restoreDefaults")}),a.jsxs(Ce,{onClick:()=>N(!S),disabled:!d("maintenance:create"),title:d("maintenance:create")?void 0:h("maintenance.noPermissionEditTypes"),children:[a.jsx(ar,{className:"w-4 h-4"}),h("maintenance.addCustomType")]})]})]}),S&&a.jsx(vt,{className:"mb-6",children:a.jsx(Nt,{className:"py-4",children:a.jsxs("form",{onSubmit:se,children:[a.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-4 gap-4",children:[a.jsxs("div",{className:"lg:col-span-2",children:[a.jsx("label",{className:"block text-xs text-bambu-gray mb-1.5",children:h("common.name")}),a.jsx("input",{type:"text",value:A,onChange:L=>C(L.target.value),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white text-sm focus:border-bambu-green focus:outline-none",placeholder:h("maintenance.exampleName"),autoFocus:!0})]}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-xs text-bambu-gray mb-1.5",children:h("maintenance.intervalType")}),a.jsxs("select",{value:j,onChange:L=>{E(L.target.value),L.target.value==="days"?k("30"):k("100")},className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white text-sm focus:border-bambu-green focus:outline-none",children:[a.jsx("option",{value:"hours",children:h("maintenance.printHours")}),a.jsx("option",{value:"days",children:h("maintenance.calendarDays")})]})]}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-xs text-bambu-gray mb-1.5",children:h("maintenance.intervalValue",{type:j==="days"?h("maintenance.calendarDays").toLowerCase():h("common.hours")})}),a.jsx("input",{type:"number",value:T,onChange:L=>k(L.target.value),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white text-sm focus:border-bambu-green focus:outline-none",min:"1"})]})]}),a.jsx("div",{className:"mt-4 flex items-end justify-between",children:a.jsxs("div",{children:[a.jsx("label",{className:"block text-xs text-bambu-gray mb-1.5",children:h("maintenance.icon")}),a.jsx("div",{className:"flex gap-1",children:Object.keys(Ky).map(L=>{const D=Ky[L];return a.jsx("button",{type:"button",onClick:()=>U(L),className:`p-2 rounded-lg transition-colors ${P===L?"bg-bambu-green text-white":"bg-bambu-dark text-bambu-gray hover:text-white hover:bg-bambu-dark-tertiary"}`,children:a.jsx(D,{className:"w-4 h-4"})},L)})})]})}),a.jsxs("div",{className:"mt-4",children:[a.jsx("label",{className:"block text-xs text-bambu-gray mb-1.5",children:h("maintenance.documentationLink")}),a.jsx("input",{type:"url",value:O,onChange:L=>B(L.target.value),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white text-sm focus:border-bambu-green focus:outline-none",placeholder:"https://wiki.bambulab.com/..."})]}),a.jsxs("div",{className:"mt-4",children:[a.jsx("label",{className:"block text-xs text-bambu-gray mb-1.5",children:h("maintenance.assignToPrinters")}),a.jsx("div",{className:"flex flex-wrap gap-2",children:oe.map(L=>a.jsx("button",{type:"button",onClick:()=>Z(L.id),className:`px-3 py-1.5 rounded-lg text-sm transition-colors ${R.has(L.id)?"bg-bambu-green text-white":"bg-bambu-dark text-bambu-gray hover:text-white hover:bg-bambu-dark-tertiary"}`,children:L.name},L.id))}),R.size===0&&a.jsx("p",{className:"text-xs text-orange-400 mt-1",children:h("maintenance.selectAtLeastOnePrinter")})]}),a.jsxs("div",{className:"mt-4 flex justify-end gap-2",children:[a.jsx(Ce,{type:"button",variant:"secondary",onClick:()=>{N(!1),G(new Set)},children:h("common.cancel")}),a.jsx(Ce,{type:"submit",disabled:!A.trim()||R.size===0,children:h("maintenance.addType")})]})]})})}),a.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-3",children:[ve.map(L=>{const D=x0(L.icon),H=L.interval_type||"hours";return a.jsx("div",{className:"bg-bambu-dark-secondary rounded-xl p-4 border border-bambu-dark-tertiary",children:a.jsxs("div",{className:"flex items-center gap-3",children:[a.jsx("div",{className:"p-2.5 bg-bambu-dark rounded-lg",children:a.jsx(D,{className:"w-5 h-5 text-bambu-gray"})}),a.jsxs("div",{className:"flex-1 min-w-0",children:[a.jsx("div",{className:"text-sm font-medium text-white truncate",children:L.name}),a.jsxs("div",{className:"text-xs text-bambu-gray mt-0.5 flex items-center gap-1",children:[H==="days"?a.jsx(ii,{className:"w-3 h-3"}):a.jsx(Iu,{className:"w-3 h-3"}),Gj(L.default_interval_hours,H,h)]})]}),a.jsx("button",{onClick:()=>{d("maintenance:delete")&&Y(L)},disabled:!d("maintenance:delete"),title:d("maintenance:delete")?void 0:h("maintenance.noPermissionDeleteTypes"),className:`p-2 rounded-lg hover:bg-bambu-dark text-bambu-gray hover:text-red-400 transition-colors ${d("maintenance:delete")?"":"opacity-50 cursor-not-allowed"}`,children:a.jsx(Jt,{className:"w-4 h-4"})})]})},L.id)}),fe.map(L=>{const D=x0(L.icon),H=L.interval_type||"hours";if(ee?.id===L.id)return a.jsx("div",{className:"bg-bambu-dark-secondary rounded-xl p-4 border border-bambu-green",children:a.jsxs("div",{className:"space-y-3",children:[a.jsx("input",{type:"text",value:_e,onChange:Oe=>pe(Oe.target.value),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white text-sm focus:border-bambu-green focus:outline-none",placeholder:h("common.name"),autoFocus:!0}),a.jsxs("div",{className:"flex gap-2",children:[a.jsxs("select",{value:de,onChange:Oe=>ce(Oe.target.value),className:"flex-1 px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white text-sm focus:border-bambu-green focus:outline-none",children:[a.jsx("option",{value:"hours",children:h("maintenance.printHours")}),a.jsx("option",{value:"days",children:h("maintenance.calendarDays")})]}),a.jsx("input",{type:"number",value:me,onChange:Oe=>je(Oe.target.value),className:"w-24 px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white text-sm focus:border-bambu-green focus:outline-none",min:"1"})]}),a.jsx("div",{className:"flex flex-wrap gap-1",children:Object.keys(Ky).map(Oe=>{const Qe=Ky[Oe];return a.jsx("button",{type:"button",onClick:()=>ie(Oe),className:`p-1.5 rounded transition-colors ${Se===Oe?"bg-bambu-green text-white":"bg-bambu-dark text-bambu-gray hover:text-white"}`,children:a.jsx(Qe,{className:"w-3.5 h-3.5"})},Oe)})}),a.jsx("input",{type:"url",value:Fe,onChange:Oe=>V(Oe.target.value),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white text-sm focus:border-bambu-green focus:outline-none",placeholder:h("maintenance.documentationLink")}),a.jsxs("div",{className:"flex gap-2",children:[a.jsx(Ce,{size:"sm",onClick:ue,disabled:!_e.trim(),children:h("common.save")}),a.jsx(Ce,{size:"sm",variant:"secondary",onClick:()=>J(null),children:h("common.cancel")})]})]})},L.id);const xe=$(L.id),be=X(L.id),Ue=q===L.id;return a.jsxs("div",{className:"bg-bambu-dark-secondary rounded-xl p-4 border border-bambu-green/30",children:[a.jsxs("div",{className:"flex items-center gap-3",children:[a.jsx("div",{className:"p-2.5 bg-bambu-green/20 rounded-lg",children:a.jsx(D,{className:"w-5 h-5 text-bambu-green"})}),a.jsxs("div",{className:"flex-1 min-w-0",children:[a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx("span",{className:"text-sm font-medium text-white truncate",children:L.name}),a.jsx("span",{className:"px-1.5 py-0.5 bg-bambu-green/20 text-bambu-green text-[10px] font-medium rounded",children:h("maintenance.custom")})]}),a.jsxs("div",{className:"text-xs text-bambu-gray mt-0.5 flex items-center gap-1",children:[H==="days"?a.jsx(ii,{className:"w-3 h-3"}):a.jsx(Iu,{className:"w-3 h-3"}),Gj(L.default_interval_hours,H,h)]})]}),a.jsxs("button",{onClick:()=>z(Ue?null:L.id),className:`px-2 py-1 rounded-lg border transition-colors flex items-center gap-1 ${xe.length>0?"border-bambu-green/50 bg-bambu-green/10 text-bambu-green hover:bg-bambu-green/20":"border-orange-400/50 bg-orange-400/10 text-orange-400 hover:bg-orange-400/20"}`,title:h("maintenance.printersAssignedClick",{count:xe.length}),children:[a.jsx(Cr,{className:"w-3 h-3"}),a.jsx("span",{className:"text-xs font-medium",children:xe.length}),a.jsx(nr,{className:`w-3 h-3 transition-transform ${Ue?"rotate-180":""}`})]}),a.jsx("button",{onClick:()=>W(L),disabled:!d("maintenance:update"),title:d("maintenance:update")?void 0:h("maintenance.noPermissionEditTypes"),className:`p-2 rounded-lg hover:bg-bambu-dark text-bambu-gray hover:text-white transition-colors ${d("maintenance:update")?"":"opacity-50 cursor-not-allowed"}`,children:a.jsx(jf,{className:"w-4 h-4"})}),a.jsx("button",{onClick:()=>{confirm(h("maintenance.deleteTypeConfirm",{name:L.name}))&&s(L.id)},disabled:!d("maintenance:delete"),title:d("maintenance:delete")?void 0:h("maintenance.noPermissionDeleteTypes"),className:`p-2 rounded-lg hover:bg-bambu-dark text-bambu-gray hover:text-red-400 transition-colors ${d("maintenance:delete")?"":"opacity-50 cursor-not-allowed"}`,children:a.jsx(Jt,{className:"w-4 h-4"})})]}),Ue&&a.jsxs("div",{className:"mt-3 pt-3 border-t border-bambu-dark-tertiary",children:[a.jsx("p",{className:"text-xs text-bambu-gray mb-2",children:h("maintenance.assignedToPrinters")}),xe.length===0?a.jsx("p",{className:"text-xs text-orange-400",children:h("maintenance.noPrintersAssigned")}):a.jsx("div",{className:"flex flex-wrap gap-1 mb-2",children:xe.map(Oe=>a.jsxs("span",{className:"inline-flex items-center gap-1 px-2 py-1 bg-bambu-dark rounded text-xs text-white",children:[Oe.printerName,a.jsx("button",{onClick:()=>Oe.itemId&&u(Oe.itemId),disabled:!d("maintenance:delete"),title:d("maintenance:delete")?h("maintenance.removeFromPrinter"):h("maintenance.noPermissionRemovePrinter"),className:`ml-1 ${d("maintenance:delete")?"hover:text-red-400":"opacity-50 cursor-not-allowed"}`,children:"×"})]},Oe.printerId))}),be.length>0&&a.jsxs("div",{className:"flex flex-wrap gap-1",children:[a.jsx("span",{className:"text-xs text-bambu-gray mr-1",children:h("maintenance.addPrinterShort")}),be.map(Oe=>a.jsxs("button",{onClick:()=>c(Oe.id,L.id),disabled:!d("maintenance:create"),title:d("maintenance:create")?void 0:h("maintenance.noPermissionAssignPrinter"),className:`px-2 py-1 bg-bambu-dark rounded text-xs transition-colors ${d("maintenance:create")?"hover:bg-bambu-green/20 text-bambu-gray hover:text-bambu-green":"opacity-50 cursor-not-allowed text-bambu-gray"}`,children:["+ ",Oe.name]},Oe.id))]})]})]},L.id)})]})]}),Ne.length>0&&a.jsxs("div",{children:[a.jsxs("div",{className:"mb-4",children:[a.jsx("h2",{className:"text-lg font-semibold text-white",children:h("maintenance.intervalOverrides")}),a.jsx("p",{className:"text-sm text-bambu-gray mt-1",children:h("maintenance.intervalOverridesDescription")})]}),a.jsx("div",{className:"space-y-4",children:Ne.map(L=>a.jsx(vt,{children:a.jsxs(Nt,{className:"py-4",children:[a.jsx("h3",{className:"text-sm font-medium text-white mb-3",children:L.printerName}),a.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-2",children:L.items.map(D=>{const H=x0(D.maintenance_type_icon),he=e.find(Qe=>Qe.id===D.maintenance_type_id),xe=he?.default_interval_hours||D.interval_hours,be=he?.interval_type||"hours",Ue=D.interval_type||"hours",Oe=f===D.id;return a.jsxs("div",{className:"flex items-center gap-2 p-2.5 bg-bambu-dark rounded-lg",children:[a.jsx(H,{className:"w-4 h-4 text-bambu-gray shrink-0"}),a.jsx("span",{className:"text-xs text-bambu-gray flex-1 truncate",children:D.maintenance_type_name}),Oe?a.jsxs("div",{className:"flex items-center gap-1",children:[b==="days"?a.jsx(ii,{className:"w-3.5 h-3.5 text-bambu-gray shrink-0"}):a.jsx(Iu,{className:"w-3.5 h-3.5 text-bambu-gray shrink-0"}),a.jsxs("select",{value:b,onChange:Qe=>v(Qe.target.value),className:"px-1.5 py-1 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded text-white text-xs",children:[a.jsx("option",{value:"hours",children:h("maintenance.printHours")}),a.jsx("option",{value:"days",children:h("maintenance.calendarDays")})]}),a.jsx("input",{type:"number",value:x,onChange:Qe=>y(Qe.target.value),onKeyDown:Qe=>{Qe.key==="Enter"&&Q(D.id,xe,be),Qe.key==="Escape"&&p(null)},className:"w-16 px-2 py-1 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded text-white text-xs",min:"1"}),a.jsx(Ce,{size:"sm",onClick:()=>Q(D.id,xe,be),children:"OK"})]}):a.jsxs("button",{onClick:()=>{d("maintenance:update")&&(p(D.id),y(D.interval_hours.toString()),v(Ue))},disabled:!d("maintenance:update"),title:d("maintenance:update")?void 0:h("maintenance.noPermissionEditIntervals"),className:`px-2 py-1 bg-bambu-dark-tertiary border border-bambu-dark-tertiary rounded text-xs font-medium text-white transition-colors flex items-center gap-1 ${d("maintenance:update")?"hover:bg-bambu-dark-secondary hover:border-bambu-green":"opacity-50 cursor-not-allowed"}`,children:[Ue==="days"?a.jsx(ii,{className:"w-3 h-3"}):a.jsx(Iu,{className:"w-3 h-3"}),Gj(D.interval_hours,Ue,h),a.jsx(jf,{className:"w-3 h-3 text-bambu-gray"})]})]},D.id)})})]})},L.printerId))})]}),Ne.length===0&&a.jsx(vt,{children:a.jsxs(Nt,{className:"text-center py-12",children:[a.jsx(Wn,{className:"w-12 h-12 mx-auto mb-4 text-bambu-gray/30"}),a.jsx("p",{className:"text-bambu-gray",children:h("common.noPrinters")}),a.jsx("p",{className:"text-sm text-bambu-gray/70 mt-1",children:h("maintenance.intervalOverridesDescription")})]})}),K&&a.jsx(vn,{title:h("maintenance.deleteSystemTypeTitle"),message:h("maintenance.deleteSystemTypeMessage",{name:K.name}),confirmText:h("common.delete"),cancelText:h("common.cancel"),variant:"danger",cancelVariant:"primary",cardClassName:"bg-red-950/70 border border-red-800/70",onConfirm:()=>{s(K.id),Y(null)},onCancel:()=>Y(null)})]})}function LZe(){const{t}=Vt(),e=tn(),{showToast:n}=hn(),{hasPermission:r}=Ir(),[i,s]=w.useState("status"),{data:o,isLoading:l}=Ze({queryKey:["maintenanceOverview"],queryFn:re.getMaintenanceOverview}),{data:c}=Ze({queryKey:["maintenanceTypes"],queryFn:re.getMaintenanceTypes}),u=ot({mutationFn:({id:T,notes:k})=>re.performMaintenance(T,k),onSuccess:()=>{e.invalidateQueries({queryKey:["maintenanceOverview"]}),e.invalidateQueries({queryKey:["maintenanceSummary"]}),n(t("maintenance.maintenanceComplete"))},onError:T=>{n(T.message,"error")}}),d=ot({mutationFn:({id:T,data:k})=>re.updateMaintenanceItem(T,k),onSuccess:()=>{e.invalidateQueries({queryKey:["maintenanceOverview"]})},onError:T=>{n(T.message,"error")}}),h=ot({mutationFn:({id:T,data:k})=>re.updateMaintenanceType(T,k),onSuccess:()=>{e.invalidateQueries({queryKey:["maintenanceTypes"]}),e.invalidateQueries({queryKey:["maintenanceOverview"]}),n(t("maintenance.typeUpdated"))},onError:T=>{n(T.message,"error")}}),f=ot({mutationFn:re.deleteMaintenanceType,onSuccess:()=>{e.invalidateQueries({queryKey:["maintenanceTypes"]}),e.invalidateQueries({queryKey:["maintenanceOverview"]}),n(t("maintenance.typeDeleted"))},onError:T=>{n(T.message,"error")}}),p=ot({mutationFn:re.restoreDefaultMaintenanceTypes,onSuccess:T=>{e.invalidateQueries({queryKey:["maintenanceTypes"]}),e.invalidateQueries({queryKey:["maintenanceOverview"]}),n(t("maintenance.defaultsRestored",{count:T.restored}))},onError:T=>{n(T.message,"error")}}),x=ot({mutationFn:({printerId:T,hours:k})=>re.setPrinterHours(T,k),onSuccess:()=>{e.invalidateQueries({queryKey:["maintenanceOverview"]}),e.invalidateQueries({queryKey:["maintenanceSummary"]}),n(t("maintenance.printHoursUpdated"))},onError:T=>{n(T.message,"error")}}),y=ot({mutationFn:({printerId:T,typeId:k})=>re.assignMaintenanceType(T,k),onSuccess:()=>{e.invalidateQueries({queryKey:["maintenanceOverview"]}),n(t("maintenance.printerAssigned"))},onError:T=>{n(T.message,"error")}}),b=ot({mutationFn:re.removeMaintenanceItem,onSuccess:()=>{e.invalidateQueries({queryKey:["maintenanceOverview"]}),n(t("maintenance.printerRemoved"))},onError:T=>{n(T.message,"error")}}),v=T=>{u.mutate({id:T})},S=(T,k)=>{d.mutate({id:T,data:{enabled:k}})},N=(T,k)=>{x.mutate({printerId:T,hours:k})};if(l)return a.jsx("div",{className:"p-4 md:p-8 flex justify-center",children:a.jsx(it,{className:"w-8 h-8 text-bambu-green animate-spin"})});const A=o?.reduce((T,k)=>T+k.due_count,0)||0,C=o?.reduce((T,k)=>T+k.warning_count,0)||0;return a.jsxs("div",{className:"p-4 md:p-8",children:[a.jsxs("div",{className:"mb-6",children:[a.jsx("h1",{className:"text-2xl font-bold text-white",children:t("maintenance.title")}),a.jsx("p",{className:"text-bambu-gray text-sm mt-1",children:i==="status"?a.jsxs(a.Fragment,{children:[A>0&&a.jsx("span",{className:"text-red-400",children:t("maintenance.dueCount",{count:A})}),A>0&&C>0&&" · ",C>0&&a.jsx("span",{className:"text-amber-400",children:t("maintenance.warningCount",{count:C})}),A===0&&C===0&&a.jsx("span",{className:"text-bambu-green",children:t("maintenance.allOk")})]}):t("maintenance.configureSettings")})]}),a.jsxs("div",{className:"flex gap-1 mb-6 border-b border-bambu-dark-tertiary",children:[a.jsx("button",{onClick:()=>s("status"),className:`px-4 py-2 text-sm font-medium border-b-2 -mb-px transition-colors ${i==="status"?"text-bambu-green border-bambu-green":"text-bambu-gray border-transparent hover:text-white"}`,children:t("maintenance.statusTab")}),a.jsx("button",{onClick:()=>s("settings"),className:`px-4 py-2 text-sm font-medium border-b-2 -mb-px transition-colors ${i==="settings"?"text-bambu-green border-bambu-green":"text-bambu-gray border-transparent hover:text-white"}`,children:t("maintenance.settingsTab")})]}),i==="status"?a.jsx("div",{className:"space-y-6",children:o&&o.length>0?[...o].sort((T,k)=>{const j=T.due_count*10+T.warning_count,E=k.due_count*10+k.warning_count;return j!==E?E-j:T.printer_name.localeCompare(k.printer_name)}).map(T=>a.jsx(RZe,{overview:T,onPerform:v,onToggle:S,onSetHours:N,hasPermission:r,t},T.printer_id)):a.jsx(vt,{children:a.jsxs(Nt,{className:"text-center py-16",children:[a.jsx(Ff,{className:"w-16 h-16 mx-auto mb-4 text-bambu-gray/30"}),a.jsx("p",{className:"text-lg font-medium text-white mb-2",children:t("common.noPrinters")}),a.jsx("p",{className:"text-bambu-gray",children:t("maintenance.configureSettings")})]})})}):a.jsx(FZe,{overview:o,types:c||[],onUpdateInterval:(T,k)=>d.mutate({id:T,data:k}),onAddType:async(T,k)=>{const j=await re.createMaintenanceType(T);for(const E of k)await re.assignMaintenanceType(E,j.id);e.invalidateQueries({queryKey:["maintenanceTypes"]}),e.invalidateQueries({queryKey:["maintenanceOverview"]}),n(t("maintenance.typeUpdated"))},onUpdateType:(T,k)=>h.mutate({id:T,data:k}),onDeleteType:T=>f.mutate(T),onRestoreDefaults:()=>p.mutate(),isRestoringDefaults:p.isPending,onAssignType:(T,k)=>y.mutate({printerId:T,typeId:k}),onRemoveItem:T=>b.mutate(T),hasPermission:r,t})]})}const uK=["#ef4444","#f97316","#eab308","#22c55e","#06b6d4","#3b82f6","#8b5cf6","#ec4899","#6b7280"];function Yae({project:t,onClose:e,onSave:n,isLoading:r,t:i}){const[s,o]=w.useState(t?.name||""),[l,c]=w.useState(t?.description||""),[u,d]=w.useState(t?.color||uK[0]),[h,f]=w.useState(t?.target_count?.toString()||""),[p,x]=w.useState(t?.target_parts_count?.toString()||""),[y,b]=w.useState(t?.status||"active"),[v,S]=w.useState(t?.tags||""),[N,A]=w.useState(t?.due_date?.split("T")[0]||""),[C,T]=w.useState(t?.priority||"normal"),k=j=>{j.preventDefault(),n({name:s.trim(),description:l.trim()||void 0,color:u,target_count:h?parseInt(h,10):void 0,target_parts_count:p?parseInt(p,10):void 0,tags:v.trim()||void 0,due_date:N||void 0,priority:C,...t&&{status:y}})};return a.jsx("div",{className:"fixed inset-0 bg-black/70 flex items-center justify-center z-50 p-4",children:a.jsxs("div",{className:"bg-bambu-dark-secondary rounded-lg w-full max-w-md border border-bambu-dark-tertiary",children:[a.jsx("div",{className:"p-4 border-b border-bambu-dark-tertiary",children:a.jsx("h2",{className:"text-lg font-semibold text-white",children:i(t?"projects.editProject":"projects.newProject")})}),a.jsxs("form",{onSubmit:k,className:"p-4 space-y-4",children:[a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm font-medium text-white mb-1",children:i("common.name")}),a.jsx("input",{type:"text",value:s,onChange:j=>o(j.target.value),className:"w-full bg-bambu-dark border border-bambu-dark-tertiary rounded px-3 py-2 text-white placeholder-bambu-gray focus:outline-none focus:border-bambu-green",placeholder:i("projects.namePlaceholder"),required:!0})]}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm font-medium text-white mb-1",children:i("common.description")}),a.jsx("textarea",{value:l,onChange:j=>c(j.target.value),className:"w-full bg-bambu-dark border border-bambu-dark-tertiary rounded px-3 py-2 text-white placeholder-bambu-gray focus:outline-none focus:border-bambu-green resize-none",placeholder:i("projects.descriptionPlaceholder"),rows:2})]}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm font-medium text-white mb-1",children:i("projects.color")}),a.jsx("div",{className:"flex gap-2 flex-wrap",children:uK.map(j=>a.jsx("button",{type:"button",onClick:()=>d(j),className:`w-8 h-8 rounded-full transition-transform ${u===j?"ring-2 ring-white ring-offset-2 ring-offset-bambu-dark-secondary scale-110":""}`,style:{backgroundColor:j}},j))})]}),a.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm font-medium text-white mb-1",children:i("projects.targetPlates")}),a.jsx("input",{type:"number",value:h,onChange:j=>f(j.target.value),className:"w-full bg-bambu-dark border border-bambu-dark-tertiary rounded px-3 py-2 text-white placeholder-bambu-gray focus:outline-none focus:border-bambu-green",placeholder:i("projects.targetPlatesPlaceholder"),min:"1"}),a.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:i("projects.targetPlatesHelp")})]}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm font-medium text-white mb-1",children:i("projects.targetParts")}),a.jsx("input",{type:"number",value:p,onChange:j=>x(j.target.value),className:"w-full bg-bambu-dark border border-bambu-dark-tertiary rounded px-3 py-2 text-white placeholder-bambu-gray focus:outline-none focus:border-bambu-green",placeholder:i("projects.targetPartsPlaceholder"),min:"1"}),a.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:i("projects.targetPartsHelp")})]})]}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm font-medium text-white mb-1",children:i("projects.tagsLabel")}),a.jsx("input",{type:"text",value:v,onChange:j=>S(j.target.value),className:"w-full bg-bambu-dark border border-bambu-dark-tertiary rounded px-3 py-2 text-white placeholder-bambu-gray focus:outline-none focus:border-bambu-green",placeholder:i("projects.tagsPlaceholder")})]}),a.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm font-medium text-white mb-1",children:i("projects.dueDate")}),a.jsx("input",{type:"date",value:N,onChange:j=>A(j.target.value),className:"w-full bg-bambu-dark border border-bambu-dark-tertiary rounded px-3 py-2 text-white focus:outline-none focus:border-bambu-green"})]}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm font-medium text-white mb-1",children:i("projects.priority")}),a.jsxs("select",{value:C,onChange:j=>T(j.target.value),className:"w-full bg-bambu-dark border border-bambu-dark-tertiary rounded px-3 py-2 text-white focus:outline-none focus:border-bambu-green",children:[a.jsx("option",{value:"low",children:i("projects.priorityLow")}),a.jsx("option",{value:"normal",children:i("projects.priorityNormal")}),a.jsx("option",{value:"high",children:i("projects.priorityHigh")}),a.jsx("option",{value:"urgent",children:i("projects.priorityUrgent")})]})]})]}),t&&a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm font-medium text-white mb-1",children:i("common.status")}),a.jsxs("select",{value:y,onChange:j=>b(j.target.value),className:"w-full bg-bambu-dark border border-bambu-dark-tertiary rounded px-3 py-2 text-white focus:outline-none focus:border-bambu-green",children:[a.jsx("option",{value:"active",children:i("projects.statusActive")}),a.jsx("option",{value:"completed",children:i("projects.statusCompleted")}),a.jsx("option",{value:"archived",children:i("projects.statusArchived")})]})]}),a.jsxs("div",{className:"flex justify-end gap-2 pt-2",children:[a.jsx(Ce,{type:"button",variant:"secondary",onClick:e,children:i("common.cancel")}),a.jsx(Ce,{type:"submit",disabled:!s.trim()||r,children:r?a.jsx(it,{className:"w-4 h-4 animate-spin"}):i(t?"common.save":"projects.create")})]})]})]})})}function OZe({project:t,onClick:e,onEdit:n,onDelete:r,hasPermission:i,t:s}){const o=t.target_count?Math.round(t.archive_count/t.target_count*100):0,l=t.target_parts_count?Math.round(t.completed_count/t.target_parts_count*100):0,c=t.status==="completed",u=t.status==="archived",[d,h]=w.useState(!1),p=c?{icon:fb,color:"text-bambu-green",bg:"bg-bambu-green/10"}:u?{icon:Rs,color:"text-bambu-gray",bg:"bg-bambu-gray/10"}:t.queue_count>0?{icon:Wn,color:"text-blue-400",bg:"bg-blue-400/10"}:{icon:xs,color:"text-bambu-gray",bg:"bg-bambu-gray/10"};return a.jsxs("div",{className:"group relative bg-gradient-to-br from-bambu-card to-bambu-dark-secondary rounded-xl border border-bambu-dark-tertiary hover:border-bambu-green/50 hover:shadow-lg hover:shadow-bambu-green/5 transition-all duration-300 cursor-pointer overflow-hidden",onClick:e,children:[a.jsx("div",{className:"absolute top-0 left-0 w-1.5 h-full",style:{backgroundColor:t.color||"#6b7280",boxShadow:`0 0 12px ${t.color||"#6b7280"}40`}}),a.jsxs("div",{className:"p-5 pl-6",children:[a.jsxs("div",{className:"flex items-start justify-between mb-4",children:[a.jsxs("div",{className:"flex items-center gap-3 min-w-0 flex-1",children:[a.jsx("div",{className:`p-2 rounded-lg ${p.bg} flex-shrink-0`,children:a.jsx(p.icon,{className:`w-5 h-5 ${p.color}`})}),a.jsxs("div",{className:"min-w-0 flex-1",children:[a.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[a.jsx("h3",{className:"font-semibold text-white truncate",children:t.name}),t.target_parts_count?a.jsxs("span",{className:`text-xs px-2 py-0.5 rounded-full whitespace-nowrap font-medium ${l>=100?"bg-bambu-green/20 text-bambu-green":"bg-bambu-dark text-bambu-gray"}`,children:[t.completed_count,"/",t.target_parts_count," ",s("projects.parts")]}):t.target_count?a.jsxs("span",{className:`text-xs px-2 py-0.5 rounded-full whitespace-nowrap font-medium ${o>=100?"bg-bambu-green/20 text-bambu-green":"bg-bambu-dark text-bambu-gray"}`,children:[t.archive_count,"/",t.target_count," ",s("projects.plates")]}):t.completed_count>0?a.jsxs("span",{className:"text-xs px-2 py-0.5 rounded-full whitespace-nowrap font-medium bg-bambu-dark text-bambu-gray",children:[t.completed_count," ",s("projects.parts")]}):null,c&&a.jsx("span",{className:"text-xs bg-bambu-green/20 text-bambu-green px-2 py-0.5 rounded-full whitespace-nowrap",children:s("projects.done")}),u&&a.jsx("span",{className:"text-xs bg-bambu-gray/20 text-bambu-gray px-2 py-0.5 rounded-full whitespace-nowrap",children:s("projects.statusArchived")})]}),t.description&&a.jsx("p",{className:"text-sm text-bambu-gray/70 mt-1 line-clamp-1",children:t.description}),t.archives&&t.archives.length>0&&(()=>{const x=t.archives.map(S=>S.filament_type).filter(Boolean).flatMap(S=>S.split(",").map(N=>N.trim())).filter(Boolean),y=[...new Set(x)],b=t.archives.map(S=>S.filament_color).filter(Boolean).flatMap(S=>S.split(",").map(N=>N.trim())).filter(S=>S.startsWith("#")||/^[0-9A-Fa-f]{6}$/.test(S)),v=[...new Set(b)];return y.length===0&&v.length===0?null:a.jsxs("div",{className:"flex items-center gap-2 mt-1.5",children:[y.slice(0,3).map(S=>a.jsx("span",{className:"text-[10px] px-1.5 py-0.5 bg-bambu-dark text-bambu-gray rounded",children:S},S)),v.length>0&&a.jsxs("div",{className:"flex items-center gap-0.5",children:[v.slice(0,5).map(S=>a.jsx("div",{className:"w-3 h-3 rounded-full border border-white/20",style:{backgroundColor:S.startsWith("#")?S:`#${S}`},title:S},S)),v.length>5&&a.jsxs("span",{className:"text-[10px] text-bambu-gray ml-0.5",children:["+",v.length-5]})]})]})})()]})]}),a.jsxs("div",{className:"relative",onClick:x=>x.stopPropagation(),children:[a.jsx("button",{className:"p-1.5 rounded-lg hover:bg-bambu-dark text-bambu-gray hover:text-white transition-colors opacity-0 group-hover:opacity-100",onClick:()=>h(!d),children:a.jsx(Eh,{className:"w-4 h-4"})}),d&&a.jsxs(a.Fragment,{children:[a.jsx("div",{className:"fixed inset-0 z-10",onClick:()=>h(!1)}),a.jsxs("div",{className:"absolute right-0 top-8 z-20 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg shadow-xl py-1 min-w-[120px]",children:[a.jsxs("button",{className:`w-full px-3 py-2 text-left text-sm flex items-center gap-2 ${i("projects:update")?"text-white hover:bg-bambu-dark":"text-bambu-gray cursor-not-allowed"}`,onClick:()=>{i("projects:update")&&(n(),h(!1))},disabled:!i("projects:update"),title:i("projects:update")?void 0:s("projects.noEditPermission"),children:[a.jsx(jf,{className:"w-4 h-4"}),s("common.edit")]}),a.jsxs("button",{className:`w-full px-3 py-2 text-left text-sm flex items-center gap-2 ${i("projects:delete")?"text-red-400 hover:bg-bambu-dark":"text-bambu-gray cursor-not-allowed"}`,onClick:()=>{i("projects:delete")&&(r(),h(!1))},disabled:!i("projects:delete"),title:i("projects:delete")?void 0:s("projects.noDeletePermission"),children:[a.jsx(Jt,{className:"w-4 h-4"}),s("common.delete")]})]})]})]})]}),a.jsx("div",{className:"mb-4",children:t.target_count||t.target_parts_count?a.jsxs("div",{className:"space-y-3",children:[t.target_count&&a.jsxs("div",{children:[a.jsxs("div",{className:"flex items-center justify-between text-xs mb-1",children:[a.jsx("span",{className:"text-bambu-gray",children:s("projects.plates")}),a.jsxs("span",{className:o>=100?"text-bambu-green font-medium":"text-white",children:[t.archive_count," / ",t.target_count]})]}),a.jsx("div",{className:"h-2 bg-bambu-dark/80 rounded-full overflow-hidden backdrop-blur-sm",children:a.jsx("div",{className:"h-full transition-all duration-500 ease-out rounded-full relative",style:{width:`${Math.min(o,100)}%`,background:o>=100?"linear-gradient(90deg, #22c55e, #4ade80)":`linear-gradient(90deg, ${t.color||"#6b7280"}, ${t.color||"#6b7280"}cc)`,boxShadow:`0 0 8px ${o>=100?"#22c55e":t.color||"#6b7280"}60`}})})]}),t.target_parts_count&&a.jsxs("div",{children:[a.jsxs("div",{className:"flex items-center justify-between text-xs mb-1",children:[a.jsx("span",{className:"text-bambu-gray",children:s("projects.parts")}),a.jsxs("span",{className:l>=100?"text-bambu-green font-medium":"text-white",children:[t.completed_count," / ",t.target_parts_count]})]}),a.jsx("div",{className:"h-2 bg-bambu-dark/80 rounded-full overflow-hidden backdrop-blur-sm",children:a.jsx("div",{className:"h-full transition-all duration-500 ease-out rounded-full relative",style:{width:`${Math.min(l,100)}%`,background:l>=100?"linear-gradient(90deg, #22c55e, #4ade80)":`linear-gradient(90deg, ${t.color||"#6b7280"}, ${t.color||"#6b7280"}cc)`,boxShadow:`0 0 8px ${l>=100?"#22c55e":t.color||"#6b7280"}60`}})})]}),t.failed_count>0&&a.jsxs("div",{className:"text-xs text-red-400",children:[t.failed_count," ",s("projects.failed")]})]}):t.completed_count>0||t.failed_count>0?a.jsxs("div",{className:"flex items-center gap-4 text-xs",children:[t.completed_count>0&&a.jsxs("div",{className:"flex items-center gap-1.5 text-bambu-gray",children:[a.jsx(Rs,{className:"w-3.5 h-3.5"}),a.jsxs("span",{children:[t.completed_count," ",s("projects.completed")]})]}),t.failed_count>0&&a.jsxs("div",{className:"flex items-center gap-1.5 text-red-400",children:[a.jsx(Cn,{className:"w-3.5 h-3.5"}),a.jsxs("span",{children:[t.failed_count," ",s("projects.failed")]})]}),t.queue_count>0&&a.jsxs("div",{className:"flex items-center gap-1.5 text-blue-400",children:[a.jsx(Wn,{className:"w-3.5 h-3.5"}),a.jsxs("span",{children:[t.queue_count," ",s("projects.inQueue")]})]})]}):a.jsx("div",{className:"text-xs text-bambu-gray/60 italic",children:s("projects.noPrintsYet")})}),t.archives&&t.archives.length>0&&a.jsxs("div",{className:"mb-4",children:[a.jsx("div",{className:"grid grid-cols-4 gap-1.5",children:t.archives.slice(0,4).map(x=>a.jsxs("div",{className:"relative aspect-square rounded-lg bg-bambu-dark overflow-hidden border border-bambu-dark-tertiary",title:x.print_name||"Unknown",children:[x.thumbnail_path?a.jsx("img",{src:re.getArchiveThumbnail(x.id),alt:x.print_name||"",className:"w-full h-full object-cover"}):a.jsx("div",{className:"w-full h-full flex items-center justify-center text-bambu-gray/50",children:a.jsx(fa,{className:"w-6 h-6"})}),x.status==="failed"&&a.jsx("div",{className:"absolute inset-0 bg-red-500/40 flex items-center justify-center",children:a.jsx(Cn,{className:"w-4 h-4 text-white"})})]},x.id))}),t.archive_count>4&&a.jsx("p",{className:"text-xs text-bambu-gray mt-1.5 text-center",children:s("common.more",{count:t.archive_count-4})})]}),a.jsxs("div",{className:"flex items-center justify-between pt-3 border-t border-bambu-dark-tertiary",children:[a.jsxs("div",{className:"flex items-center gap-4 text-xs text-bambu-gray",children:[a.jsxs("div",{className:"flex items-center gap-1.5",title:s("projects.printJobs"),children:[a.jsx(ma,{className:"w-3.5 h-3.5 text-blue-400"}),a.jsxs("span",{children:[t.archive_count," ",s("projects.plates")]})]}),a.jsxs("div",{className:"flex items-center gap-1.5",title:s("projects.partsPrinted"),children:[a.jsx(fa,{className:"w-3.5 h-3.5 text-bambu-green"}),a.jsxs("span",{children:[t.completed_count," ",s("projects.parts")]})]}),t.failed_count>0&&a.jsxs("div",{className:"flex items-center gap-1.5 text-red-400",title:s("projects.failedParts"),children:[a.jsx(Cn,{className:"w-3.5 h-3.5"}),a.jsx("span",{children:t.failed_count})]}),t.queue_count>0&&a.jsxs("div",{className:"flex items-center gap-1.5 text-yellow-400",title:s("projects.inQueue"),children:[a.jsx(b3,{className:"w-3.5 h-3.5"}),a.jsx("span",{children:t.queue_count})]})]}),a.jsx(pa,{className:"w-4 h-4 text-bambu-gray/50 group-hover:text-bambu-gray transition-colors"})]})]})]})}function IZe(){const{t}=Vt(),e=$c(),n=tn(),{showToast:r}=hn(),{hasPermission:i}=Ir(),[s,o]=w.useState(!1),[l,c]=w.useState(),[u,d]=w.useState("active"),[h,f]=w.useState(null),{data:p,isLoading:x}=Ze({queryKey:["projects",u==="all"?void 0:u],queryFn:()=>re.getProjects(u==="all"?void 0:u)}),y=ot({mutationFn:B=>re.createProject(B),onSuccess:()=>{n.invalidateQueries({queryKey:["projects"]}),o(!1),r(t("projects.toast.created"),"success")},onError:B=>{r(B.message,"error")}}),b=ot({mutationFn:({id:B,data:R})=>re.updateProject(B,R),onSuccess:()=>{n.invalidateQueries({queryKey:["projects"]}),o(!1),c(void 0),r(t("projects.toast.updated"),"success")},onError:B=>{r(B.message,"error")}}),v=ot({mutationFn:B=>re.deleteProject(B),onSuccess:()=>{f(null),r(t("projects.toast.deleted"),"success"),setTimeout(()=>window.location.reload(),100)},onError:B=>{f(null),r(B.message,"error")}}),S=ot({mutationFn:B=>re.importProject(B),onSuccess:()=>{n.invalidateQueries({queryKey:["projects"]}),r(t("projects.toast.imported"),"success")},onError:B=>{r(B.message,"error")}}),N=w.useRef(null),A=async()=>{try{const B=await re.getProjects(),R=await Promise.all(B.map(async K=>await re.exportProjectJson(K.id))),G=new Blob([JSON.stringify(R,null,2)],{type:"application/json"}),q=URL.createObjectURL(G),z=document.createElement("a");z.href=q,z.download=`bambuddy_projects_${new Date().toISOString().split("T")[0]}.json`,z.click(),URL.revokeObjectURL(q),r(t("projects.toast.exported"),"success")}catch(B){r(B.message,"error")}},C=()=>{N.current?.click()},T=async B=>{const R=B.target.files?.[0];if(R){try{if(R.name.toLowerCase().endsWith(".zip"))await re.importProjectFile(R),n.invalidateQueries({queryKey:["projects"]}),r(t("projects.toast.imported"),"success");else{const q=await R.text(),z=JSON.parse(q),K=Array.isArray(z)?z:[z];for(const Y of K)await S.mutateAsync(Y);K.length>1&&r(t("projects.toast.multipleImported",{count:K.length}),"success")}}catch(G){r(`${t("projects.toast.importFailed")}: ${G.message}`,"error")}B.target.value=""}},k=B=>{l?b.mutate({id:l.id,data:B}):y.mutate(B)},j=B=>{c(B),o(!0)},E=B=>{e(`/projects/${B.id}`)},P=B=>{f(B)},U=()=>{h!==null&&v.mutate(h)},O=p?.reduce((B,R)=>(B[R.status]=(B[R.status]||0)+1,B.all=(B.all||0)+1,B),{})||{};return a.jsxs("div",{className:"p-4 md:p-8 space-y-8",children:[a.jsx("input",{ref:N,type:"file",accept:".json,.zip",onChange:T,className:"hidden"}),a.jsxs("div",{className:"flex flex-col sm:flex-row sm:items-center justify-between gap-4",children:[a.jsxs("div",{children:[a.jsxs("h1",{className:"text-2xl font-bold text-white flex items-center gap-3",children:[a.jsx("div",{className:"p-2.5 bg-bambu-green/10 rounded-xl",children:a.jsx(xs,{className:"w-6 h-6 text-bambu-green"})}),t("projects.title")]}),a.jsx("p",{className:"text-sm text-bambu-gray mt-2 ml-14",children:t("projects.subtitle")})]}),a.jsxs("div",{className:"flex gap-2",children:[a.jsxs(Ce,{variant:"secondary",onClick:C,disabled:!i("projects:create"),title:i("projects:create")?t("projects.importProject"):t("projects.noImportPermission"),children:[a.jsx(Fi,{className:"w-4 h-4 mr-2"}),t("projects.import")]}),a.jsxs(Ce,{variant:"secondary",onClick:A,disabled:!i("projects:read"),title:i("projects:read")?t("projects.exportAll"):t("projects.noExportPermission"),children:[a.jsx(di,{className:"w-4 h-4 mr-2"}),t("projects.export")]}),a.jsxs(Ce,{onClick:()=>o(!0),className:"sm:w-auto w-full",disabled:!i("projects:create"),title:i("projects:create")?void 0:t("projects.noCreatePermission"),children:[a.jsx(ar,{className:"w-4 h-4 mr-2"}),t("projects.newProject")]})]})]}),a.jsx("div",{className:"flex gap-1 p-1 bg-bambu-dark rounded-xl w-fit",children:[{key:"active",label:t("projects.statusActive"),icon:Wn},{key:"completed",label:t("projects.statusCompleted"),icon:fb},{key:"archived",label:t("projects.statusArchived"),icon:Rs},{key:"all",label:t("common.all"),icon:xs}].map(({key:B,label:R,icon:G})=>a.jsxs("button",{onClick:()=>d(B),className:`flex items-center gap-2 px-4 py-2 text-sm rounded-lg transition-all ${u===B?"bg-bambu-card text-white shadow-sm":"text-bambu-gray hover:text-white"}`,children:[a.jsx(G,{className:"w-4 h-4"}),a.jsx("span",{children:R}),O[B]>0&&a.jsx("span",{className:`text-xs px-1.5 py-0.5 rounded-full ${u===B?"bg-bambu-green/20 text-bambu-green":"bg-bambu-dark-tertiary"}`,children:O[B]})]},B))}),x?a.jsx("div",{className:"flex items-center justify-center py-20",children:a.jsxs("div",{className:"flex flex-col items-center gap-3",children:[a.jsx(it,{className:"w-8 h-8 animate-spin text-bambu-green"}),a.jsx("p",{className:"text-sm text-bambu-gray",children:t("projects.loading")})]})}):p?.length===0?a.jsxs("div",{className:"flex flex-col items-center justify-center py-20 px-4",children:[a.jsx("div",{className:"p-4 bg-bambu-dark rounded-2xl mb-4",children:a.jsx(xs,{className:"w-12 h-12 text-bambu-gray/50"})}),a.jsx("h3",{className:"text-lg font-medium text-white mb-2",children:u==="all"?t("projects.noProjects"):t("projects.noProjectsFiltered",{status:u})}),a.jsx("p",{className:"text-bambu-gray text-center max-w-md mb-6",children:u==="all"?t("projects.createFirst"):t("projects.noProjectsFilteredHelp",{status:u})}),u==="all"&&a.jsxs(Ce,{onClick:()=>o(!0),disabled:!i("projects:create"),title:i("projects:create")?void 0:t("projects.noCreatePermission"),children:[a.jsx(ar,{className:"w-4 h-4 mr-2"}),t("projects.createFirstButton")]})]}):a.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 xl:grid-cols-3 gap-8",children:p?.map(B=>a.jsx(OZe,{project:B,onClick:()=>E(B),onEdit:()=>j(B),onDelete:()=>P(B.id),hasPermission:i,t},B.id))}),h!==null&&a.jsx(vn,{title:t("projects.deleteProject"),message:t("projects.deleteConfirm"),confirmText:t("projects.deleteProject"),variant:"danger",onConfirm:U,onCancel:()=>f(null)}),s&&a.jsx(Yae,{project:l,onClose:()=>{o(!1),c(void 0)},onSave:k,isLoading:y.isPending||b.isPending,t})]})}function zZe(t){if(t<1)return`${Math.round(t*60)}m`;const e=Math.floor(t),n=Math.round((t-e)*60);return n>0?`${e}h ${n}m`:`${e}h`}function UZe(t){return t>=1e3?`${(t/1e3).toFixed(2)}kg`:`${Math.round(t)}g`}function BZe({status:t,t:e}){const n={active:"bg-bambu-green/20 text-bambu-green",completed:"bg-blue-500/20 text-blue-400",archived:"bg-bambu-gray/20 text-bambu-gray"},r=n[t]||n.active,i={active:e("projectDetail.status.active"),completed:e("projectDetail.status.completed"),archived:e("projectDetail.status.archived")};return a.jsx("span",{className:`px-2 py-1 rounded text-sm font-medium ${r}`,children:i[t]||t.charAt(0).toUpperCase()+t.slice(1)})}function dK({icon:t,label:e,value:n,subValue:r,hint:i,color:s="text-bambu-gray"}){return a.jsx(vt,{children:a.jsx(Nt,{className:"p-4",children:a.jsxs("div",{className:"flex items-center gap-3",title:i,children:[a.jsx("div",{className:`p-2 rounded-lg bg-bambu-dark ${s}`,children:a.jsx(t,{className:"w-5 h-5"})}),a.jsxs("div",{children:[a.jsx("p",{className:"text-sm text-bambu-gray",children:e}),a.jsx("p",{className:"text-xl font-semibold text-white",children:n}),r&&a.jsx("p",{className:"text-xs text-bambu-gray/70",children:r})]})]})})})}function HZe({archives:t,t:e}){return t.length===0?a.jsxs("div",{className:"text-center py-8 text-bambu-gray",children:[a.jsx(fa,{className:"w-12 h-12 mx-auto mb-2 opacity-50"}),a.jsx("p",{children:e("projectDetail.noPrints")})]}):a.jsx("div",{className:"grid grid-cols-2 sm:grid-cols-3 md:grid-cols-4 lg:grid-cols-5 xl:grid-cols-6 gap-3",children:t.map(n=>a.jsxs(Xs,{to:`/archives?search=${encodeURIComponent(n.print_name||"")}`,className:"group relative aspect-square rounded-lg bg-bambu-dark border border-bambu-dark-tertiary overflow-hidden hover:border-bambu-green transition-colors",children:[n.thumbnail_path?a.jsx("img",{src:re.getArchiveThumbnail(n.id),alt:n.print_name||"Print",className:"w-full h-full object-cover"}):a.jsx("div",{className:"w-full h-full flex items-center justify-center text-bambu-gray",children:a.jsx(fa,{className:"w-8 h-8"})}),n.status==="failed"&&a.jsx("div",{className:"absolute inset-0 bg-red-500/30 flex items-center justify-center",children:a.jsx(ha,{className:"w-8 h-8 text-white"})}),n.status==="completed"&&a.jsx("div",{className:"absolute top-1 right-1",children:a.jsx(gr,{className:"w-4 h-4 text-bambu-green"})}),a.jsx("div",{className:"absolute inset-x-0 bottom-0 bg-gradient-to-t from-black/80 to-transparent p-2 opacity-0 group-hover:opacity-100 transition-opacity",children:a.jsx("p",{className:"text-xs text-white truncate",children:n.print_name||"Unknown"})})]},n.id))})}function $Ze({priority:t,t:e}){const n={low:{color:"bg-gray-500/20 text-gray-400",label:e("projectDetail.priority.low")},normal:{color:"bg-blue-500/20 text-blue-400",label:e("projectDetail.priority.normal")},high:{color:"bg-orange-500/20 text-orange-400",label:e("projectDetail.priority.high")},urgent:{color:"bg-red-500/20 text-red-400",label:e("projectDetail.priority.urgent")}},{color:r,label:i}=n[t]||n.normal;return a.jsxs("span",{className:`px-2 py-1 rounded text-xs font-medium flex items-center gap-1 ${r}`,children:[t==="urgent"&&a.jsx(Cn,{className:"w-3 h-3"}),i]})}function VZe(t){return t?gb(t,{year:"numeric",month:"short",day:"numeric"}):""}function qj(t,e){if(!t)return null;const n=Zi(t);if(!n)return null;const r=new Date,i=Math.ceil((n.getTime()-r.getTime())/(1e3*60*60*24));return i<0?{color:"text-red-400",label:e("projectDetail.dueDate.overdue")}:i===0?{color:"text-orange-400",label:e("projectDetail.dueDate.today")}:i<=3?{color:"text-yellow-400",label:e("projectDetail.dueDate.daysLeft",{count:i})}:{color:"text-bambu-gray",label:e("projectDetail.dueDate.daysLeft",{count:i})}}function GZe(){const{id:t}=Yk(),e=$c(),{t:n}=Vt(),r=tn(),{showToast:i}=hn(),{hasPermission:s}=Ir(),[o,l]=w.useState(!1),[c,u]=w.useState(!1),[d,h]=w.useState(""),f=parseInt(t||"0",10),{data:p,isLoading:x,error:y}=Ze({queryKey:["project",f],queryFn:()=>re.getProject(f),enabled:f>0}),{data:b,isLoading:v}=Ze({queryKey:["project-archives",f],queryFn:()=>re.getProjectArchives(f),enabled:f>0}),{data:S,isLoading:N}=Ze({queryKey:["project-bom",f],queryFn:()=>re.getProjectBOM(f),enabled:f>0}),{data:A,isLoading:C}=Ze({queryKey:["project-timeline",f],queryFn:()=>re.getProjectTimeline(f,20),enabled:f>0}),{data:T}=Ze({queryKey:["settings"],queryFn:re.getSettings}),{data:k}=Ze({queryKey:["project-folders",f],queryFn:()=>re.getLibraryFoldersByProject(f),enabled:f>0}),j=ju(T?.currency||"USD"),E=T?.time_format||"system",P=ot({mutationFn:Me=>re.updateProject(f,Me),onSuccess:()=>{r.invalidateQueries({queryKey:["project",f]}),r.invalidateQueries({queryKey:["projects"]}),l(!1),u(!1),i(n("projectDetail.toast.projectUpdated"),"success")},onError:Me=>{i(Me.message,"error")}}),U=()=>{h(p?.notes||""),u(!0)},O=()=>{P.mutate({notes:d})},B=()=>{u(!1),h("")},[R,G]=w.useState(""),[q,z]=w.useState(1),[K,Y]=w.useState(""),[oe,$]=w.useState(""),[X,ee]=w.useState(""),[J,_e]=w.useState(!1),[pe,me]=w.useState(!1),[je,de]=w.useState(null),[ce,Se]=w.useState(""),[ie,Fe]=w.useState(1),[V,W]=w.useState(""),[ue,Q]=w.useState(""),[se,Z]=w.useState(""),[Ne,ve]=w.useState({isOpen:!1,title:"",message:"",onConfirm:()=>{}}),fe=ot({mutationFn:Me=>re.createBOMItem(f,Me),onSuccess:()=>{r.invalidateQueries({queryKey:["project-bom",f]}),r.invalidateQueries({queryKey:["project",f]}),G(""),z(1),Y(""),$(""),ee(""),_e(!1),i(n("projectDetail.toast.partAdded"),"success")},onError:Me=>i(Me.message,"error")}),L=ot({mutationFn:({itemId:Me,data:$e})=>re.updateBOMItem(f,Me,$e),onSuccess:()=>{r.invalidateQueries({queryKey:["project-bom",f]}),r.invalidateQueries({queryKey:["project",f]}),de(null)},onError:Me=>i(Me.message,"error")}),D=ot({mutationFn:Me=>re.deleteBOMItem(f,Me),onSuccess:()=>{r.invalidateQueries({queryKey:["project-bom",f]}),r.invalidateQueries({queryKey:["project",f]}),i(n("projectDetail.toast.partRemoved"),"success")},onError:Me=>i(Me.message,"error")}),H=Me=>{Me.preventDefault(),R.trim()&&fe.mutate({name:R.trim(),quantity_needed:q,unit_price:K?parseFloat(K):void 0,sourcing_url:oe.trim()||void 0,remarks:X.trim()||void 0})},he=Me=>{const $e=Me.is_complete?0:Me.quantity_needed;L.mutate({itemId:Me.id,data:{quantity_acquired:$e}})},xe=(Me,$e)=>{ve({isOpen:!0,title:n("projectDetail.bom.deletePart"),message:n("projectDetail.bom.deleteConfirm",{name:$e}),onConfirm:()=>{ve(Ae=>({...Ae,isOpen:!1})),D.mutate(Me)}})},be=Me=>{de(Me),Se(Me.name),Fe(Me.quantity_needed),W(Me.unit_price?.toString()||""),Q(Me.sourcing_url||""),Z(Me.remarks||"")},Ue=Me=>{Me.preventDefault(),!(!je||!ce.trim())&&L.mutate({itemId:je.id,data:{name:ce.trim(),quantity_needed:ie,unit_price:V?parseFloat(V):void 0,sourcing_url:ue.trim()||void 0,remarks:se.trim()||void 0}})},Oe=()=>{de(null)},Qe=async()=>{try{const{blob:Me,filename:$e}=await re.exportProjectZip(Number(f)),Ae=URL.createObjectURL(Me),Je=document.createElement("a");Je.href=Ae,Je.download=$e||`${p?.name||"project"}_${new Date().toISOString().split("T")[0]}.zip`,Je.click(),URL.revokeObjectURL(Ae),i(n("projectDetail.toast.projectExported"),"success")}catch(Me){i(Me.message,"error")}},rt=ot({mutationFn:()=>re.createTemplateFromProject(f),onSuccess:()=>{r.invalidateQueries({queryKey:["projects"]}),i(n("projectDetail.toast.templateCreated"),"success")},onError:Me=>i(Me.message,"error")}),we=Me=>Lf(Me,E,{month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"});if(x)return a.jsx("div",{className:"flex items-center justify-center py-24",children:a.jsx(it,{className:"w-8 h-8 animate-spin text-bambu-green"})});if(y||!p)return a.jsxs("div",{className:"text-center py-24",children:[a.jsx("p",{className:"text-bambu-gray",children:y?`${n("common.error")}: ${y.message}`:n("projectDetail.notFound")}),a.jsx(Ce,{variant:"secondary",className:"mt-4",onClick:()=>e("/projects"),children:n("projectDetail.backToProjects")})]});const ye=p.stats,le=ye?.progress_percent??0,Le=ye?.parts_progress_percent??0;return a.jsxs("div",{className:"p-4 md:p-8 space-y-8",children:[a.jsxs("div",{className:"flex items-center gap-2 text-sm text-bambu-gray",children:[a.jsx(Xs,{to:"/projects",className:"hover:text-white transition-colors",children:n("navigation.projects")}),a.jsx(pa,{className:"w-4 h-4"}),a.jsx("span",{className:"text-white",children:p.name})]}),a.jsxs("div",{className:"flex items-start justify-between",children:[a.jsxs("div",{className:"flex items-center gap-4",children:[a.jsx("button",{onClick:()=>e("/projects"),className:"p-2 rounded-lg bg-bambu-card hover:bg-bambu-dark-tertiary transition-colors",children:a.jsx(gde,{className:"w-5 h-5 text-bambu-gray"})}),a.jsxs("div",{className:"flex items-center gap-3",children:[a.jsx("div",{className:"w-4 h-4 rounded-full flex-shrink-0",style:{backgroundColor:p.color||"#6b7280"}}),a.jsxs("div",{children:[a.jsx("h1",{className:"text-2xl font-bold text-white",children:p.name}),p.description&&a.jsx("p",{className:"text-bambu-gray mt-1",children:p.description})]})]}),a.jsx(BZe,{status:p.status,t:n})]}),a.jsxs("div",{className:"flex gap-2",children:[a.jsxs(Ce,{variant:"secondary",onClick:Qe,disabled:!s("projects:read"),title:s("projects:read")?n("projectDetail.exportProject"):n("projectDetail.noExportPermission"),children:[a.jsx(di,{className:"w-4 h-4 mr-2"}),n("projectDetail.export")]}),a.jsxs(Ce,{onClick:()=>l(!0),disabled:!s("projects:update"),title:s("projects:update")?void 0:n("projectDetail.noEditPermission"),children:[a.jsx(jf,{className:"w-4 h-4 mr-2"}),n("common.edit")]})]})]}),(p.target_count||p.target_parts_count)&&a.jsx(vt,{children:a.jsxs(Nt,{className:"p-4 space-y-4",children:[p.target_count&&a.jsxs("div",{children:[a.jsxs("div",{className:"flex items-center justify-between mb-2",children:[a.jsx("span",{className:"text-sm text-bambu-gray",children:n("projectDetail.progress.platesProgress")}),a.jsxs("span",{className:"text-sm font-medium text-white",children:[ye?.total_archives||0," / ",p.target_count," ",n("projectDetail.progress.printJobs")]})]}),a.jsx("div",{className:"h-3 bg-bambu-dark rounded-full overflow-hidden",children:a.jsx("div",{className:"h-full transition-all duration-500",style:{width:`${Math.min(le,100)}%`,backgroundColor:le>=100?"#22c55e":p.color||"#6b7280"}})}),a.jsxs("div",{className:"flex justify-between mt-1",children:[a.jsx("span",{className:"text-xs text-bambu-gray/70",children:n("projectDetail.progress.percentComplete",{percent:le.toFixed(0)})}),ye?.remaining_prints!=null&&ye.remaining_prints>0&&a.jsx("span",{className:"text-xs text-bambu-gray/70",children:n("projectDetail.progress.remaining",{count:ye.remaining_prints})})]})]}),p.target_parts_count&&a.jsxs("div",{children:[a.jsxs("div",{className:"flex items-center justify-between mb-2",children:[a.jsx("span",{className:"text-sm text-bambu-gray",children:n("projectDetail.progress.partsProgress")}),a.jsxs("span",{className:"text-sm font-medium text-white",children:[ye?.completed_prints||0," / ",p.target_parts_count," ",n("projectDetail.progress.parts")]})]}),a.jsx("div",{className:"h-3 bg-bambu-dark rounded-full overflow-hidden",children:a.jsx("div",{className:"h-full transition-all duration-500",style:{width:`${Math.min(Le,100)}%`,backgroundColor:Le>=100?"#22c55e":p.color||"#6b7280"}})}),a.jsxs("div",{className:"flex justify-between mt-1",children:[a.jsx("span",{className:"text-xs text-bambu-gray/70",children:n("projectDetail.progress.percentComplete",{percent:Le.toFixed(0)})}),ye?.remaining_parts!=null&&ye.remaining_parts>0&&a.jsx("span",{className:"text-xs text-bambu-gray/70",children:n("projectDetail.progress.remaining",{count:ye.remaining_parts})})]})]})]})}),ye&&a.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-4",children:[a.jsx(vt,{children:a.jsx(Nt,{className:"p-4",children:a.jsxs("div",{className:"flex items-center gap-3",children:[a.jsx("div",{className:"p-2 rounded-lg bg-bambu-dark text-bambu-green",children:a.jsx(fa,{className:"w-5 h-5"})}),a.jsxs("div",{children:[a.jsx("p",{className:"text-sm text-bambu-gray",children:n("projectDetail.stats.printJobs")}),a.jsxs("p",{className:"text-xl font-semibold text-white",children:[ye.total_archives," ",a.jsx("span",{className:"text-sm font-normal text-bambu-gray",children:n("projectDetail.stats.total")})]}),ye.failed_prints>0&&a.jsx("p",{className:"text-sm text-status-error",children:n("projectDetail.stats.failed",{count:ye.failed_prints})}),a.jsx("p",{className:"text-sm text-bambu-gray",children:n("projectDetail.stats.partsPrinted",{count:ye.completed_prints})})]})]})})}),a.jsx(dK,{icon:Wn,label:n("projectDetail.stats.printTime"),value:zZe(ye.total_print_time_hours),color:"text-yellow-400"}),a.jsx(dK,{icon:Cr,label:n("projectDetail.stats.filamentUsed"),value:UZe(ye.total_filament_grams),color:"text-purple-400"})]}),ye&&(ye.estimated_cost>0||p.budget)&&a.jsx(vt,{children:a.jsxs(Nt,{className:"p-4",children:[a.jsx("h2",{className:"text-lg font-semibold text-white mb-3",children:n("projectDetail.cost.title")}),a.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-4",children:[a.jsxs("div",{children:[a.jsx("p",{className:"text-xs text-bambu-gray uppercase",children:n("projectDetail.cost.filamentCost")}),a.jsxs("p",{className:"text-lg font-semibold text-white",children:[j,ye.estimated_cost.toFixed(2)]})]}),ye.total_energy_kwh>0&&a.jsxs("div",{children:[a.jsx("p",{className:"text-xs text-bambu-gray uppercase",children:n("projectDetail.cost.energy")}),a.jsxs("p",{className:"text-lg font-semibold text-white",children:[ye.total_energy_kwh.toFixed(2)," kWh",ye.total_energy_cost>0&&a.jsxs("span",{className:"text-sm text-bambu-gray ml-1",children:["(",j,ye.total_energy_cost.toFixed(2),")"]})]})]}),p.budget&&a.jsxs(a.Fragment,{children:[a.jsxs("div",{children:[a.jsx("p",{className:"text-xs text-bambu-gray uppercase",children:n("projectDetail.cost.budget")}),a.jsxs("p",{className:"text-lg font-semibold text-white",children:[j,p.budget.toFixed(2)]})]}),a.jsxs("div",{children:[a.jsx("p",{className:"text-xs text-bambu-gray uppercase",children:n("projectDetail.cost.remaining")}),a.jsxs("p",{className:`text-lg font-semibold ${p.budget-ye.estimated_cost>=0?"text-bambu-green":"text-red-400"}`,children:[j,(p.budget-ye.estimated_cost).toFixed(2)]})]})]})]})]})}),p.children&&p.children.length>0&&a.jsx(vt,{children:a.jsxs(Nt,{className:"p-4",children:[a.jsxs("h2",{className:"text-lg font-semibold text-white flex items-center gap-2 mb-3",children:[a.jsx(rme,{className:"w-5 h-5"}),n("projectDetail.subProjects.title",{count:p.children.length})]}),a.jsx("div",{className:"space-y-2",children:p.children.map(Me=>a.jsxs(Xs,{to:`/projects/${Me.id}`,className:"flex items-center justify-between p-3 bg-bambu-dark rounded-lg hover:bg-bambu-dark-tertiary transition-colors",children:[a.jsxs("div",{className:"flex items-center gap-3",children:[a.jsx("div",{className:"w-3 h-3 rounded-full",style:{backgroundColor:Me.color||"#6b7280"}}),a.jsx("span",{className:"text-white",children:Me.name}),a.jsx("span",{className:`text-xs px-2 py-0.5 rounded ${Me.status==="completed"?"bg-status-ok/20 text-status-ok":Me.status==="archived"?"bg-bambu-gray/20 text-bambu-gray":"bg-blue-500/20 text-blue-400"}`,children:Me.status})]}),Me.progress_percent!==null&&a.jsxs("span",{className:"text-sm text-bambu-gray",children:[Me.progress_percent.toFixed(0),"%"]})]},Me.id))})]})}),p.parent_id&&p.parent_name&&a.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[a.jsx(ma,{className:"w-4 h-4 text-bambu-gray"}),a.jsx("span",{className:"text-bambu-gray",children:n("projectDetail.partOf")}),a.jsx(Xs,{to:`/projects/${p.parent_id}`,className:"text-bambu-green hover:underline",children:p.parent_name})]}),(p.tags||p.due_date||p.priority!=="normal")&&a.jsxs("div",{className:"flex flex-wrap items-center gap-4",children:[p.priority&&p.priority!=="normal"&&a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx("span",{className:"text-xs text-bambu-gray uppercase",children:n("projectDetail.priorityLabel")}),a.jsx($Ze,{priority:p.priority,t:n})]}),p.due_date&&a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx(ii,{className:"w-4 h-4 text-bambu-gray"}),a.jsx("span",{className:"text-sm text-white",children:VZe(p.due_date)}),qj(p.due_date,n)&&a.jsxs("span",{className:`text-xs ${qj(p.due_date,n).color}`,children:["(",qj(p.due_date,n).label,")"]})]}),p.tags&&a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx(qh,{className:"w-4 h-4 text-bambu-gray"}),a.jsx("div",{className:"flex flex-wrap gap-1",children:p.tags.split(",").map((Me,$e)=>a.jsx("span",{className:"px-2 py-0.5 bg-bambu-dark-tertiary text-bambu-gray text-xs rounded",children:Me.trim()},$e))})]})]}),a.jsx(vt,{children:a.jsxs(Nt,{className:"p-4",children:[a.jsxs("div",{className:"flex items-center justify-between mb-3",children:[a.jsxs("h2",{className:"text-lg font-semibold text-white flex items-center gap-2",children:[a.jsx(Ps,{className:"w-5 h-5"}),n("projectDetail.notes.title")]}),c?a.jsxs("div",{className:"flex gap-2",children:[a.jsxs(Ce,{variant:"secondary",size:"sm",onClick:B,disabled:P.isPending,children:[a.jsx(Ft,{className:"w-4 h-4 mr-1"}),n("common.cancel")]}),a.jsxs(Ce,{size:"sm",onClick:O,disabled:P.isPending,children:[P.isPending?a.jsx(it,{className:"w-4 h-4 animate-spin mr-1"}):a.jsx(bs,{className:"w-4 h-4 mr-1"}),n("common.save")]})]}):a.jsxs(Ce,{variant:"secondary",size:"sm",onClick:U,disabled:!s("projects:update"),title:s("projects:update")?void 0:n("projectDetail.notes.noEditPermission"),children:[a.jsx(jf,{className:"w-4 h-4 mr-1"}),n("common.edit")]})]}),c?a.jsx(lF,{content:d,onChange:h,placeholder:n("projectDetail.notes.placeholder")}):p.notes?a.jsx("div",{className:"prose prose-invert prose-sm max-w-none",dangerouslySetInnerHTML:{__html:p.notes}}):a.jsx("p",{className:"text-bambu-gray/70 text-sm italic",children:n("projectDetail.notes.empty")})]})}),a.jsx(vt,{children:a.jsxs(Nt,{className:"p-4",children:[a.jsx("div",{className:"flex items-center justify-between mb-3",children:a.jsxs("h2",{className:"text-lg font-semibold text-white flex items-center gap-2",children:[a.jsx(Yl,{className:"w-5 h-5"}),n("projectDetail.files.title")]})}),a.jsxs("p",{className:"text-xs text-bambu-gray mb-3",children:[a.jsx(Xs,{to:"/files",className:"text-bambu-green hover:underline",children:n("projectDetail.files.linkFolders")})," ",n("projectDetail.files.forQuickAccess")]}),k&&k.length>0?a.jsx("div",{className:"space-y-2",children:k.map(Me=>a.jsxs(Xs,{to:`/files?folder=${Me.id}`,className:"flex items-center justify-between p-3 bg-bambu-dark rounded-lg hover:bg-bambu-dark-tertiary transition-colors",children:[a.jsxs("div",{className:"flex items-center gap-3 min-w-0",children:[a.jsx(Yl,{className:"w-5 h-5 text-bambu-green flex-shrink-0"}),a.jsxs("div",{className:"min-w-0",children:[a.jsx("p",{className:"text-sm text-white truncate",children:Me.name}),a.jsx("p",{className:"text-xs text-bambu-gray",children:n("projectDetail.files.fileCount",{count:Me.file_count})})]})]}),a.jsx(pa,{className:"w-4 h-4 text-bambu-gray flex-shrink-0"})]},Me.id))}):a.jsx("p",{className:"text-bambu-gray/70 text-sm italic",children:n("projectDetail.files.empty")})]})}),a.jsx(vt,{children:a.jsxs(Nt,{className:"p-4",children:[a.jsxs("div",{className:"flex items-center justify-between mb-4",children:[a.jsxs("h2",{className:"text-lg font-semibold text-white flex items-center gap-2",children:[a.jsx(xX,{className:"w-5 h-5"}),n("projectDetail.bom.title"),ye&&ye.bom_total_items>0&&a.jsxs("span",{className:"text-sm font-normal text-bambu-gray",children:["(",n("projectDetail.bom.acquired",{completed:ye.bom_completed_items,total:ye.bom_total_items}),")"]})]}),a.jsxs("div",{className:"flex items-center gap-2",children:[S&&S.some(Me=>Me.is_complete)&&a.jsx("button",{onClick:()=>me(!pe),className:`text-xs px-2 py-1 rounded transition-colors ${pe?"bg-bambu-green/20 text-bambu-green":"bg-bambu-dark text-bambu-gray hover:text-white"}`,children:n(pe?"projectDetail.bom.showAll":"projectDetail.bom.hideDone")}),!J&&a.jsxs(Ce,{variant:"secondary",size:"sm",onClick:()=>_e(!0),disabled:!s("projects:update"),title:s("projects:update")?void 0:n("projectDetail.bom.noAddPermission"),children:[a.jsx(ar,{className:"w-4 h-4 mr-1"}),n("projectDetail.bom.addPart")]})]})]}),J&&a.jsxs("form",{onSubmit:H,className:"bg-bambu-dark rounded-lg p-4 mb-4 space-y-3",children:[a.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-3",children:[a.jsx("input",{type:"text",value:R,onChange:Me=>G(Me.target.value),className:"bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded px-3 py-2 text-sm text-white placeholder-bambu-gray focus:outline-none focus:border-bambu-green",placeholder:n("projectDetail.bom.partNamePlaceholder"),autoFocus:!0}),a.jsxs("div",{className:"flex gap-2",children:[a.jsx("input",{type:"number",value:q,onChange:Me=>z(parseInt(Me.target.value)||1),className:"w-20 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded px-3 py-2 text-sm text-white focus:outline-none focus:border-bambu-green",min:"1",placeholder:n("projectDetail.bom.qty")}),a.jsx("input",{type:"number",step:"0.01",value:K,onChange:Me=>Y(Me.target.value),className:"flex-1 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded px-3 py-2 text-sm text-white placeholder-bambu-gray focus:outline-none focus:border-bambu-green",placeholder:n("projectDetail.bom.price",{currency:j})})]})]}),a.jsx("input",{type:"url",value:oe,onChange:Me=>$(Me.target.value),className:"w-full bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded px-3 py-2 text-sm text-white placeholder-bambu-gray focus:outline-none focus:border-bambu-green",placeholder:n("projectDetail.bom.sourcingUrlPlaceholder")}),a.jsx("input",{type:"text",value:X,onChange:Me=>ee(Me.target.value),className:"w-full bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded px-3 py-2 text-sm text-white placeholder-bambu-gray focus:outline-none focus:border-bambu-green",placeholder:n("projectDetail.bom.remarksPlaceholder")}),a.jsxs("div",{className:"flex justify-end gap-2",children:[a.jsx(Ce,{type:"button",variant:"secondary",size:"sm",onClick:()=>_e(!1),children:n("common.cancel")}),a.jsx(Ce,{type:"submit",size:"sm",disabled:!R.trim()||fe.isPending,children:fe.isPending?a.jsx(it,{className:"w-4 h-4 animate-spin"}):n("projectDetail.bom.addPart")})]})]}),N?a.jsx("div",{className:"flex items-center justify-center py-4",children:a.jsx(it,{className:"w-6 h-6 animate-spin text-bambu-green"})}):S&&S.length>0?a.jsxs("div",{className:"space-y-2",children:[S.filter(Me=>!pe||!Me.is_complete).map(Me=>a.jsx("div",{className:`p-3 rounded-lg transition-colors ${Me.is_complete?"bg-status-ok/10":"bg-bambu-dark"}`,children:je?.id===Me.id?a.jsxs("form",{onSubmit:Ue,className:"space-y-3",children:[a.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-3",children:[a.jsx("input",{type:"text",value:ce,onChange:$e=>Se($e.target.value),className:"bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded px-3 py-2 text-sm text-white placeholder-bambu-gray focus:outline-none focus:border-bambu-green",placeholder:n("projectDetail.bom.partName"),autoFocus:!0}),a.jsxs("div",{className:"flex gap-2",children:[a.jsx("input",{type:"number",value:ie,onChange:$e=>Fe(parseInt($e.target.value)||1),className:"w-20 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded px-3 py-2 text-sm text-white focus:outline-none focus:border-bambu-green",min:"1",placeholder:n("projectDetail.bom.qty")}),a.jsx("input",{type:"number",step:"0.01",value:V,onChange:$e=>W($e.target.value),className:"flex-1 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded px-3 py-2 text-sm text-white placeholder-bambu-gray focus:outline-none focus:border-bambu-green",placeholder:n("projectDetail.bom.price",{currency:j})})]})]}),a.jsx("input",{type:"url",value:ue,onChange:$e=>Q($e.target.value),className:"w-full bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded px-3 py-2 text-sm text-white placeholder-bambu-gray focus:outline-none focus:border-bambu-green",placeholder:n("projectDetail.bom.sourcingUrlPlaceholder")}),a.jsx("input",{type:"text",value:se,onChange:$e=>Z($e.target.value),className:"w-full bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded px-3 py-2 text-sm text-white placeholder-bambu-gray focus:outline-none focus:border-bambu-green",placeholder:n("projectDetail.bom.remarksPlaceholder")}),a.jsxs("div",{className:"flex justify-end gap-2",children:[a.jsx(Ce,{type:"button",variant:"secondary",size:"sm",onClick:Oe,children:n("common.cancel")}),a.jsx(Ce,{type:"submit",size:"sm",disabled:!ce.trim()||L.isPending,children:L.isPending?a.jsx(it,{className:"w-4 h-4 animate-spin"}):n("common.save")})]})]}):a.jsxs("div",{className:"flex items-start gap-3",children:[a.jsx("button",{onClick:()=>s("projects:update")&&he(Me),disabled:L.isPending||!s("projects:update"),title:s("projects:update")?void 0:n("projectDetail.bom.noUpdatePermission"),className:`w-5 h-5 mt-0.5 rounded border-2 flex items-center justify-center transition-colors flex-shrink-0 ${Me.is_complete?"bg-status-ok border-status-ok text-white":s("projects:update")?"border-bambu-gray hover:border-bambu-green":"border-bambu-gray/50 cursor-not-allowed"}`,children:Me.is_complete&&a.jsx(gr,{className:"w-3 h-3"})}),a.jsxs("div",{className:"flex-1 min-w-0",children:[a.jsxs("div",{className:"flex items-center justify-between gap-2",children:[a.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[a.jsxs("p",{className:`text-sm font-medium ${Me.is_complete?"text-bambu-gray line-through":"text-white"}`,children:[Me.name,a.jsxs("span",{className:"text-bambu-gray font-normal ml-2",children:["x",Me.quantity_needed]})]}),Me.unit_price!==null&&a.jsxs("span",{className:"text-xs text-bambu-green whitespace-nowrap",children:[j,(Me.unit_price*Me.quantity_needed).toFixed(2)]})]}),a.jsxs("div",{className:"flex items-center gap-1",children:[a.jsx("button",{onClick:()=>s("projects:update")&&be(Me),disabled:!s("projects:update"),className:`p-1 rounded transition-colors flex-shrink-0 ${s("projects:update")?"hover:bg-bambu-dark-tertiary text-bambu-gray hover:text-white":"text-bambu-gray/50 cursor-not-allowed"}`,title:s("projects:update")?n("common.edit"):n("projectDetail.bom.noEditPermission"),children:a.jsx(Vi,{className:"w-4 h-4"})}),a.jsx("button",{onClick:()=>s("projects:update")&&xe(Me.id,Me.name),disabled:!s("projects:update"),className:`p-1 rounded transition-colors flex-shrink-0 ${s("projects:update")?"hover:bg-bambu-dark-tertiary text-bambu-gray hover:text-red-400":"text-bambu-gray/50 cursor-not-allowed"}`,title:s("projects:update")?n("common.delete"):n("projectDetail.bom.noDeletePermission"),children:a.jsx(Jt,{className:"w-4 h-4"})})]})]}),Me.sourcing_url&&a.jsxs("a",{href:Me.sourcing_url,target:"_blank",rel:"noopener noreferrer",className:"flex items-center gap-1 mt-1 text-xs text-blue-400 hover:text-blue-300 transition-colors",onClick:$e=>$e.stopPropagation(),children:[a.jsx(Kr,{className:"w-3 h-3 flex-shrink-0"}),a.jsx("span",{className:"truncate",children:(()=>{try{return new URL(Me.sourcing_url).hostname.replace("www.","")}catch{return Me.sourcing_url}})()})]}),Me.remarks&&a.jsx("p",{className:"mt-1 text-xs text-bambu-gray/80 italic",children:Me.remarks})]})]})},Me.id)),S.some(Me=>Me.unit_price!==null)&&a.jsxs("div",{className:"pt-2 mt-2 border-t border-bambu-dark-tertiary flex justify-between text-sm",children:[a.jsx("span",{className:"text-bambu-gray",children:n("projectDetail.bom.totalCost")}),a.jsxs("span",{className:"text-white font-medium",children:[j,S.reduce((Me,$e)=>Me+($e.unit_price||0)*$e.quantity_needed,0).toFixed(2)]})]})]}):a.jsx("p",{className:"text-bambu-gray/70 text-sm italic",children:n("projectDetail.bom.empty")})]})}),a.jsx(vt,{children:a.jsxs(Nt,{className:"p-4",children:[a.jsx("div",{className:"flex items-center justify-between mb-3",children:a.jsxs("h2",{className:"text-lg font-semibold text-white flex items-center gap-2",children:[a.jsx(N0,{className:"w-5 h-5"}),n("projectDetail.timeline.title")]})}),C?a.jsx("div",{className:"flex items-center justify-center py-4",children:a.jsx(it,{className:"w-6 h-6 animate-spin text-bambu-green"})}):A&&A.length>0?a.jsx("div",{className:"space-y-3",children:A.slice(0,10).map((Me,$e)=>a.jsxs("div",{className:"flex gap-3",children:[a.jsxs("div",{className:`w-8 h-8 rounded-full flex items-center justify-center flex-shrink-0 ${Me.event_type==="print_completed"?"bg-status-ok/20 text-status-ok":Me.event_type==="print_failed"?"bg-status-error/20 text-status-error":Me.event_type==="print_started"?"bg-yellow-500/20 text-yellow-400":"bg-bambu-dark-tertiary text-bambu-gray"}`,children:[Me.event_type==="print_completed"&&a.jsx(gr,{className:"w-4 h-4"}),Me.event_type==="print_failed"&&a.jsx(ha,{className:"w-4 h-4"}),Me.event_type==="print_started"&&a.jsx(Cr,{className:"w-4 h-4"}),Me.event_type==="queued"&&a.jsx(b3,{className:"w-4 h-4"}),Me.event_type==="project_created"&&a.jsx(ar,{className:"w-4 h-4"})]}),a.jsxs("div",{className:"flex-1 min-w-0",children:[a.jsx("p",{className:"text-sm text-white",children:Me.title}),Me.description&&a.jsx("p",{className:"text-xs text-bambu-gray truncate",children:Me.description}),a.jsx("p",{className:"text-xs text-bambu-gray/70",children:we(Me.timestamp)})]})]},$e))}):a.jsx("p",{className:"text-bambu-gray/70 text-sm italic",children:n("projectDetail.timeline.empty")})]})}),!p.is_template&&a.jsx("div",{className:"flex justify-end",children:a.jsxs(Ce,{variant:"secondary",size:"sm",onClick:()=>rt.mutate(),disabled:rt.isPending||!s("projects:create"),title:s("projects:create")?void 0:n("projectDetail.template.noCreatePermission"),children:[rt.isPending?a.jsx(it,{className:"w-4 h-4 animate-spin mr-2"}):a.jsx(Kl,{className:"w-4 h-4 mr-2"}),n("projectDetail.template.saveAsTemplate")]})}),ye&&(ye.queued_prints>0||ye.in_progress_prints>0)&&a.jsx(vt,{children:a.jsxs(Nt,{className:"p-4",children:[a.jsxs("div",{className:"flex items-center justify-between mb-3",children:[a.jsxs("h2",{className:"text-lg font-semibold text-white flex items-center gap-2",children:[a.jsx(b3,{className:"w-5 h-5"}),n("projectDetail.queue.title")]}),a.jsx(Xs,{to:`/queue?project=${f}`,className:"text-sm text-bambu-green hover:underline",children:n("projectDetail.queue.viewAll")})]}),a.jsxs("div",{className:"flex items-center gap-4 text-sm",children:[ye.in_progress_prints>0&&a.jsx("span",{className:"text-yellow-400",children:n("projectDetail.queue.printing",{count:ye.in_progress_prints})}),ye.queued_prints>0&&a.jsx("span",{className:"text-bambu-gray",children:n("projectDetail.queue.queued",{count:ye.queued_prints})})]})]})}),a.jsxs("div",{children:[a.jsx("div",{className:"flex items-center justify-between mb-4",children:a.jsxs("h2",{className:"text-lg font-semibold text-white flex items-center gap-2",children:[a.jsx(fa,{className:"w-5 h-5"}),n("projectDetail.prints.title",{count:b?.length||0})]})}),v?a.jsx("div",{className:"flex items-center justify-center py-8",children:a.jsx(it,{className:"w-6 h-6 animate-spin text-bambu-green"})}):a.jsx(HZe,{archives:b||[],t:n})]}),o&&a.jsx(Yae,{t:n,project:{...p,archive_count:ye?.total_archives||0,total_items:ye?.total_items||0,completed_count:ye?.completed_prints||0,failed_count:ye?.failed_prints||0,queue_count:ye?.queued_prints||0,progress_percent:ye?.progress_percent||null,archives:[]},onClose:()=>l(!1),onSave:Me=>P.mutate(Me),isLoading:P.isPending}),Ne.isOpen&&a.jsx(vn,{title:Ne.title,message:Ne.message,confirmText:n("common.delete"),variant:"danger",onConfirm:Ne.onConfirm,onCancel:()=>ve(Me=>({...Me,isOpen:!1}))})]})}function Bg(t){return t<1024?`${t} B`:t<1024*1024?`${(t/1024).toFixed(1)} KB`:t<1024*1024*1024?`${(t/(1024*1024)).toFixed(1)} MB`:`${(t/(1024*1024*1024)).toFixed(2)} GB`}function qZe({parentId:t,onClose:e,onSave:n,isLoading:r,t:i}){const[s,o]=w.useState(""),l=c=>{c.preventDefault(),n({name:s.trim(),parent_id:t})};return a.jsx("div",{className:"fixed inset-0 bg-black/70 flex items-center justify-center z-50 p-4",children:a.jsxs("div",{className:"bg-bambu-dark-secondary rounded-lg w-full max-w-sm border border-bambu-dark-tertiary",children:[a.jsx("div",{className:"p-4 border-b border-bambu-dark-tertiary",children:a.jsx("h2",{className:"text-lg font-semibold text-white",children:i("fileManager.newFolder")})}),a.jsxs("form",{onSubmit:l,className:"p-4 space-y-4",children:[a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm font-medium text-white mb-1",children:i("fileManager.folderName")}),a.jsx("input",{type:"text",value:s,onChange:c=>o(c.target.value),className:"w-full bg-bambu-dark border border-bambu-dark-tertiary rounded px-3 py-2 text-white placeholder-bambu-gray focus:outline-none focus:border-bambu-green",placeholder:i("fileManager.folderNamePlaceholder"),autoFocus:!0,required:!0})]}),a.jsxs("div",{className:"flex justify-end gap-2 pt-2",children:[a.jsx(Ce,{type:"button",variant:"secondary",onClick:e,children:i("common.cancel")}),a.jsx(Ce,{type:"submit",disabled:!s.trim()||r,children:r?a.jsx(it,{className:"w-4 h-4 animate-spin"}):i("common.create")})]})]})]})})}function WZe({type:t,currentName:e,onClose:n,onSave:r,isLoading:i,t:s}){const[o,l]=w.useState(e),c=u=>{u.preventDefault(),o.trim()&&o.trim()!==e&&r(o.trim())};return a.jsx("div",{className:"fixed inset-0 bg-black/70 flex items-center justify-center z-50 p-4",children:a.jsxs("div",{className:"bg-bambu-dark-secondary rounded-lg w-full max-w-sm border border-bambu-dark-tertiary",children:[a.jsx("div",{className:"p-4 border-b border-bambu-dark-tertiary",children:a.jsx("h2",{className:"text-lg font-semibold text-white",children:s(t==="file"?"fileManager.renameFile":"fileManager.renameFolder")})}),a.jsxs("form",{onSubmit:c,className:"p-4 space-y-4",children:[a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm font-medium text-white mb-1",children:s("common.name")}),a.jsx("input",{type:"text",value:o,onChange:u=>l(u.target.value),className:"w-full bg-bambu-dark border border-bambu-dark-tertiary rounded px-3 py-2 text-white placeholder-bambu-gray focus:outline-none focus:border-bambu-green",autoFocus:!0,required:!0})]}),a.jsxs("div",{className:"flex justify-end gap-2 pt-2",children:[a.jsx(Ce,{type:"button",variant:"secondary",onClick:n,children:s("common.cancel")}),a.jsx(Ce,{type:"submit",disabled:!o.trim()||o.trim()===e||i,children:i?a.jsx(it,{className:"w-4 h-4 animate-spin"}):s("common.rename")})]})]})]})})}function KZe({folders:t,selectedFiles:e,currentFolderId:n,onClose:r,onMove:i,isLoading:s,t:o}){const[l,c]=w.useState(null),u=(h,f=0)=>{const p=[];for(const x of h)p.push({id:x.id,name:x.name,depth:f}),x.children.length>0&&p.push(...u(x.children,f+1));return p},d=[{id:null,name:o("fileManager.rootNoFolder"),depth:0},...u(t)];return a.jsx("div",{className:"fixed inset-0 bg-black/70 flex items-center justify-center z-50 p-4",children:a.jsxs("div",{className:"bg-bambu-dark-secondary rounded-lg w-full max-w-sm border border-bambu-dark-tertiary",children:[a.jsx("div",{className:"p-4 border-b border-bambu-dark-tertiary",children:a.jsx("h2",{className:"text-lg font-semibold text-white",children:o("fileManager.moveFiles",{count:e.length})})}),a.jsxs("div",{className:"p-4 space-y-4",children:[a.jsx("div",{className:"max-h-64 overflow-y-auto space-y-1",children:d.map(h=>a.jsxs("button",{onClick:()=>c(h.id),disabled:h.id===n,className:`w-full text-left px-3 py-2 rounded transition-colors flex items-center gap-2 ${l===h.id?"bg-bambu-green/20 text-bambu-green":h.id===n?"opacity-50 cursor-not-allowed text-bambu-gray":"hover:bg-bambu-dark text-white"}`,style:{paddingLeft:`${12+h.depth*16}px`},children:[a.jsx(Yl,{className:"w-4 h-4"}),h.name,h.id===n&&a.jsxs("span",{className:"text-xs text-bambu-gray ml-auto",children:["(",o("fileManager.current"),")"]})]},h.id??"root"))}),a.jsxs("div",{className:"flex justify-end gap-2 pt-2",children:[a.jsx(Ce,{type:"button",variant:"secondary",onClick:r,children:o("common.cancel")}),a.jsx(Ce,{onClick:()=>i(l),disabled:s,children:s?a.jsx(it,{className:"w-4 h-4 animate-spin"}):o("common.move")})]})]})]})})}function XZe({folder:t,onClose:e,onLink:n,isLoading:r,t:i}){const[s,o]=w.useState("project"),[l,c]=w.useState(t.project_id||t.archive_id||null);w.useState(()=>{t.archive_id&&o("archive")});const{data:u}=Ze({queryKey:["projects"],queryFn:()=>re.getProjects()}),{data:d}=Ze({queryKey:["archives-for-link"],queryFn:()=>re.getArchives(void 0,void 0,100)}),h=()=>{n(s==="project"?{project_id:l,archive_id:0}:{project_id:0,archive_id:l})},f=()=>{n({project_id:0,archive_id:0})},p=t.project_id||t.archive_id;return a.jsx("div",{className:"fixed inset-0 bg-black/70 flex items-center justify-center z-50 p-4",children:a.jsxs("div",{className:"bg-bambu-dark-secondary rounded-lg w-full max-w-md border border-bambu-dark-tertiary",children:[a.jsxs("div",{className:"p-4 border-b border-bambu-dark-tertiary flex items-center justify-between",children:[a.jsxs("h2",{className:"text-lg font-semibold text-white flex items-center gap-2",children:[a.jsx(Rh,{className:"w-5 h-5 text-bambu-green"}),i("fileManager.linkFolder")]}),a.jsx("button",{onClick:e,className:"p-1 hover:bg-bambu-dark rounded",children:a.jsx(Ft,{className:"w-5 h-5 text-bambu-gray"})})]}),a.jsxs("div",{className:"p-4 space-y-4",children:[a.jsx("p",{className:"text-sm text-bambu-gray",children:i("fileManager.linkFolderDescription",{name:t.name})}),a.jsxs("div",{className:"flex gap-2",children:[a.jsxs("button",{onClick:()=>{o("project"),c(null)},className:`flex-1 flex items-center justify-center gap-2 px-3 py-2 rounded-lg border transition-colors ${s==="project"?"border-bambu-green bg-bambu-green/10 text-bambu-green":"border-bambu-dark-tertiary text-bambu-gray hover:text-white"}`,children:[a.jsx(lX,{className:"w-4 h-4"}),i("fileManager.project")]}),a.jsxs("button",{onClick:()=>{o("archive"),c(null)},className:`flex-1 flex items-center justify-center gap-2 px-3 py-2 rounded-lg border transition-colors ${s==="archive"?"border-bambu-green bg-bambu-green/10 text-bambu-green":"border-bambu-dark-tertiary text-bambu-gray hover:text-white"}`,children:[a.jsx(Rs,{className:"w-4 h-4"}),i("fileManager.archive")]})]}),a.jsx("div",{className:"max-h-64 overflow-y-auto space-y-1 bg-bambu-dark rounded-lg p-2",children:s==="project"?u&&u.length>0?u.map(x=>a.jsxs("button",{onClick:()=>c(x.id),className:`w-full text-left px-3 py-2 rounded transition-colors flex items-center gap-2 ${l===x.id?"bg-bambu-green/20 text-bambu-green":"hover:bg-bambu-dark-tertiary text-white"}`,children:[a.jsx("div",{className:"w-3 h-3 rounded-full flex-shrink-0",style:{backgroundColor:x.color||"#00ae42"}}),a.jsx("span",{className:"truncate",children:x.name})]},x.id)):a.jsx("p",{className:"text-sm text-bambu-gray text-center py-4",children:i("fileManager.noProjectsFound")}):d&&d.length>0?d.map(x=>a.jsxs("button",{onClick:()=>c(x.id),className:`w-full text-left px-3 py-2 rounded transition-colors flex items-center gap-2 ${l===x.id?"bg-bambu-green/20 text-bambu-green":"hover:bg-bambu-dark-tertiary text-white"}`,children:[a.jsx(pf,{className:"w-4 h-4 text-bambu-gray flex-shrink-0"}),a.jsx("span",{className:"truncate",children:x.print_name||x.filename})]},x.id)):a.jsx("p",{className:"text-sm text-bambu-gray text-center py-4",children:i("fileManager.noArchivesFound")})})]}),a.jsxs("div",{className:"p-4 border-t border-bambu-dark-tertiary flex justify-between",children:[p&&a.jsxs(Ce,{variant:"danger",onClick:f,disabled:r,children:[a.jsx(dC,{className:"w-4 h-4 mr-2"}),i("fileManager.unlink")]}),a.jsxs("div",{className:`flex gap-2 ${p?"":"ml-auto"}`,children:[a.jsx(Ce,{variant:"secondary",onClick:e,children:i("common.cancel")}),a.jsx(Ce,{onClick:h,disabled:!l||r,children:r?a.jsx(it,{className:"w-4 h-4 animate-spin"}):i("fileManager.link")})]})]})]})})}function YZe({folderId:t,onClose:e,onUploadComplete:n,t:r}){const[i,s]=w.useState([]),[o,l]=w.useState(!1),[c,u]=w.useState(!1),[d,h]=w.useState(!0),[f,p]=w.useState(!1),[x,y]=w.useState(!0),b=w.useRef(null),v=G=>{G.preventDefault(),l(!0)},S=G=>{G.preventDefault(),l(!1)},N=G=>{G.preventDefault(),l(!1);const q=Array.from(G.dataTransfer.files);C(q)},A=G=>{G.target.files&&C(Array.from(G.target.files))},C=G=>{const q=G.map(z=>({file:z,status:"pending",isZip:z.name.toLowerCase().endsWith(".zip"),is3mf:z.name.toLowerCase().endsWith(".3mf")}));s(z=>[...z,...q])},T=G=>{s(q=>q.filter((z,K)=>K!==G))},k=i.some(G=>G.isZip&&G.status==="pending"),j=i.some(G=>G.file.name.toLowerCase().endsWith(".stl")&&G.status==="pending"),E=i.some(G=>G.is3mf&&G.status==="pending"),P=async()=>{if(i.length!==0){u(!0);for(let G=0;Gq.map((z,K)=>K===G?{...z,status:"uploading"}:z));try{if(i[G].isZip){const q=await re.extractZipFile(i[G].file,t,d,f,x);s(z=>z.map((K,Y)=>Y===G?{...K,status:q.errors.length>0&&q.extracted===0?"error":"success",extractedCount:q.extracted,error:q.errors.length>0?`${q.errors.length} files failed`:void 0}:K))}else await re.uploadLibraryFile(i[G].file,t,x),s(q=>q.map((z,K)=>K===G?{...z,status:"success"}:z))}catch(q){s(z=>z.map((K,Y)=>Y===G?{...K,status:"error",error:q instanceof Error?q.message:"Upload failed"}:K))}}u(!1),n(),e()}},U=i.filter(G=>G.status==="pending").length,O=i.filter(G=>G.status==="success").length,B=i.filter(G=>G.status==="error").length,R=i.length>0&&U===0&&!c;return a.jsx("div",{className:"fixed inset-0 bg-black/70 flex items-center justify-center z-50 p-4",children:a.jsxs("div",{className:"bg-bambu-dark-secondary rounded-lg w-full max-w-lg border border-bambu-dark-tertiary",children:[a.jsxs("div",{className:"p-4 border-b border-bambu-dark-tertiary flex items-center justify-between",children:[a.jsx("h2",{className:"text-lg font-semibold text-white",children:r("fileManager.uploadFiles")}),a.jsx("button",{onClick:e,className:"p-1 hover:bg-bambu-dark rounded",children:a.jsx(Ft,{className:"w-5 h-5 text-bambu-gray"})})]}),a.jsxs("div",{className:"p-4 space-y-4",children:[a.jsxs("div",{onDragOver:v,onDragLeave:S,onDrop:N,onClick:()=>b.current?.click(),className:`border-2 border-dashed rounded-lg p-8 text-center cursor-pointer transition-colors ${o?"border-bambu-green bg-bambu-green/10":"border-bambu-dark-tertiary hover:border-bambu-green/50"}`,children:[a.jsx(Fi,{className:`w-10 h-10 mx-auto mb-3 ${o?"text-bambu-green":"text-bambu-gray"}`}),a.jsx("p",{className:"text-white font-medium",children:r(o?"fileManager.dropFilesHere":"fileManager.dragDropFiles")}),a.jsx("p",{className:"text-sm text-bambu-gray mt-1",children:r("fileManager.orClickToBrowse")}),a.jsx("p",{className:"text-xs text-bambu-gray/70 mt-2",children:r("fileManager.allFileTypesSupported")})]}),a.jsx("input",{ref:b,type:"file",multiple:!0,className:"hidden",onChange:A}),k&&a.jsx("div",{className:"p-3 bg-blue-500/10 border border-blue-500/30 rounded-lg",children:a.jsxs("div",{className:"flex items-start gap-3",children:[a.jsx(Rs,{className:"w-5 h-5 text-blue-400 mt-0.5 flex-shrink-0"}),a.jsxs("div",{className:"flex-1",children:[a.jsx("p",{className:"text-sm text-blue-300 font-medium",children:r("fileManager.zipFilesDetected")}),a.jsx("p",{className:"text-xs text-blue-300/70 mt-1",children:r("fileManager.zipExtractOptions")}),a.jsxs("label",{className:"flex items-center gap-2 mt-2 cursor-pointer",children:[a.jsx("input",{type:"checkbox",checked:d,onChange:G=>h(G.target.checked),className:"w-4 h-4 rounded border-bambu-dark-tertiary bg-bambu-dark text-bambu-green focus:ring-bambu-green"}),a.jsx("span",{className:"text-sm text-white",children:r("fileManager.preserveZipStructure")})]}),a.jsxs("label",{className:"flex items-center gap-2 mt-2 cursor-pointer",children:[a.jsx("input",{type:"checkbox",checked:f,onChange:G=>p(G.target.checked),className:"w-4 h-4 rounded border-bambu-dark-tertiary bg-bambu-dark text-bambu-green focus:ring-bambu-green"}),a.jsx("span",{className:"text-sm text-white",children:r("fileManager.createFolderFromZip")})]})]})]})}),E&&a.jsx("div",{className:"p-3 bg-purple-500/10 border border-purple-500/30 rounded-lg",children:a.jsxs("div",{className:"flex items-start gap-3",children:[a.jsx(Cr,{className:"w-5 h-5 text-purple-400 mt-0.5 flex-shrink-0"}),a.jsxs("div",{className:"flex-1",children:[a.jsx("p",{className:"text-sm text-purple-300 font-medium",children:r("fileManager.threemfDetected")}),a.jsx("p",{className:"text-xs text-purple-300/70 mt-1",children:r("fileManager.threemfExtractionInfo")})]})]})}),(j||k)&&a.jsx("div",{className:"p-3 bg-bambu-green/10 border border-bambu-green/30 rounded-lg",children:a.jsxs("div",{className:"flex items-start gap-3",children:[a.jsx(td,{className:"w-5 h-5 text-bambu-green mt-0.5 flex-shrink-0"}),a.jsxs("div",{className:"flex-1",children:[a.jsx("p",{className:"text-sm text-bambu-green font-medium",children:r("fileManager.stlThumbnailGeneration")}),a.jsx("p",{className:"text-xs text-bambu-green/70 mt-1",children:r(k&&!j?"fileManager.zipMayContainStl":"fileManager.thumbnailsCanBeGenerated")}),a.jsxs("label",{className:"flex items-center gap-2 mt-2 cursor-pointer",children:[a.jsx("input",{type:"checkbox",checked:x,onChange:G=>y(G.target.checked),className:"w-4 h-4 rounded border-bambu-dark-tertiary bg-bambu-dark text-bambu-green focus:ring-bambu-green"}),a.jsx("span",{className:"text-sm text-white",children:r("fileManager.generateThumbnailsForStl")})]})]})]})}),i.length>0&&a.jsx("div",{className:"max-h-48 overflow-y-auto space-y-2",children:i.map((G,q)=>a.jsxs("div",{className:"flex items-center gap-3 p-2 bg-bambu-dark rounded-lg",children:[G.isZip?a.jsx(Rs,{className:"w-4 h-4 text-blue-400 flex-shrink-0"}):a.jsx(eC,{className:"w-4 h-4 text-bambu-gray flex-shrink-0"}),a.jsxs("div",{className:"flex-1 min-w-0",children:[a.jsx("p",{className:"text-sm text-white truncate",children:G.file.name}),a.jsxs("p",{className:"text-xs text-bambu-gray",children:[(G.file.size/1024/1024).toFixed(2)," MB",G.isZip&&G.status==="pending"&&a.jsxs("span",{className:"text-blue-400 ml-2",children:["• ",r("fileManager.willBeExtracted")]}),G.extractedCount!==void 0&&a.jsxs("span",{className:"text-green-400 ml-2",children:["• ",r("fileManager.filesExtracted",{count:G.extractedCount})]})]})]}),G.status==="pending"&&a.jsx("button",{onClick:()=>T(q),className:"p-1 hover:bg-bambu-dark-tertiary rounded",children:a.jsx(Ft,{className:"w-4 h-4 text-bambu-gray"})}),G.status==="uploading"&&a.jsx(it,{className:"w-4 h-4 text-bambu-green animate-spin"}),G.status==="success"&&a.jsx(gr,{className:"w-4 h-4 text-green-500"}),G.status==="error"&&a.jsx("span",{title:G.error,children:a.jsx(ha,{className:"w-4 h-4 text-red-500"})})]},q))}),R&&a.jsx("div",{className:"p-3 bg-bambu-dark rounded-lg",children:a.jsxs("p",{className:"text-sm text-white",children:[r("fileManager.uploadComplete",{succeeded:O}),B>0&&a.jsxs("span",{className:"text-red-400",children:[", ",r("fileManager.uploadFailed",{count:B})]})]})})]}),a.jsxs("div",{className:"p-4 border-t border-bambu-dark-tertiary flex justify-end gap-2",children:[a.jsx(Ce,{variant:"secondary",onClick:e,children:r(R?"common.close":"common.cancel")}),!R&&a.jsx(Ce,{onClick:P,disabled:U===0||c,children:c?a.jsxs(a.Fragment,{children:[a.jsx(it,{className:"w-4 h-4 mr-2 animate-spin"}),r("fileManager.uploading")]}):a.jsxs(a.Fragment,{children:[a.jsx(Fi,{className:"w-4 h-4 mr-2"}),r("common.upload")," ",U>0?`(${U})`:""]})})]})]})})}function Qae({folder:t,selectedFolderId:e,onSelect:n,onDelete:r,onLink:i,onRename:s,depth:o=0,wrapNames:l=!1,hasPermission:c,t:u}){const[d,h]=w.useState(!0),[f,p]=w.useState(!1),x=t.children.length>0,y=t.project_id||t.archive_id;return a.jsxs("div",{children:[a.jsxs("div",{className:`group flex items-center gap-1 px-2 py-1.5 rounded cursor-pointer transition-colors ${e===t.id?"bg-bambu-green/20 text-bambu-green":"hover:bg-bambu-dark text-white"}`,style:{paddingLeft:`${8+o*12}px`},onClick:()=>n(t.id),children:[x?a.jsx("button",{onClick:b=>{b.stopPropagation(),h(!d)},className:"p-0.5 hover:bg-bambu-dark-tertiary rounded",children:a.jsx(pa,{className:`w-3.5 h-3.5 transition-transform ${d?"rotate-90":""}`})}):a.jsx("div",{className:"w-4.5"}),a.jsx(Yl,{className:"w-4 h-4 text-bambu-green flex-shrink-0"}),a.jsx("span",{className:`text-sm flex-1 min-w-0 ${l?"break-all":"truncate"}`,title:t.name,children:t.name}),y&&a.jsxs("button",{onClick:b=>{b.stopPropagation(),i(t)},className:"flex-shrink-0 flex items-center gap-1 text-xs px-1.5 py-0.5 rounded bg-blue-500/20 text-blue-400 hover:bg-blue-500/30 transition-colors",title:`${t.project_name?`Project: ${t.project_name}`:`Archive: ${t.archive_name}`} (click to change)`,children:[a.jsx(Rh,{className:"w-3 h-3"}),t.project_name?a.jsx(lX,{className:"w-3 h-3"}):a.jsx(Rs,{className:"w-3 h-3"})]}),t.file_count>0&&a.jsx("span",{className:"flex-shrink-0 text-xs text-bambu-gray",children:t.file_count}),!y&&a.jsx("button",{onClick:b=>{b.stopPropagation(),i(t)},className:"flex-shrink-0 p-1 rounded hover:bg-bambu-dark-tertiary",title:u("fileManager.linkToProjectOrArchive"),children:a.jsx(Rh,{className:"w-3.5 h-3.5 text-bambu-gray hover:text-bambu-green"})}),a.jsx("div",{className:`flex-shrink-0 flex items-center gap-0.5 transition-opacity ${l?"":"opacity-0 group-hover:opacity-100"}`,onClick:b=>b.stopPropagation(),children:a.jsxs("div",{className:"relative",children:[a.jsx("button",{onClick:()=>p(!f),className:"p-1 rounded hover:bg-bambu-dark-tertiary",children:a.jsx(Eh,{className:"w-3.5 h-3.5 text-bambu-gray"})}),f&&a.jsxs(a.Fragment,{children:[a.jsx("div",{className:"fixed inset-0 z-10",onClick:()=>p(!1)}),a.jsxs("div",{className:"absolute right-0 top-full mt-1 z-20 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg shadow-xl py-1 min-w-[120px]",children:[a.jsxs("button",{className:`w-full px-3 py-1.5 text-left text-sm flex items-center gap-2 ${c("library:update_all")?"text-white hover:bg-bambu-dark":"text-bambu-gray cursor-not-allowed"}`,onClick:()=>{c("library:update_all")&&(s(t),p(!1))},disabled:!c("library:update_all"),title:c("library:update_all")?void 0:u("fileManager.noPermissionRenameFolder"),children:[a.jsx(Vi,{className:"w-3.5 h-3.5"}),u("common.rename")]}),a.jsxs("button",{className:`w-full px-3 py-1.5 text-left text-sm flex items-center gap-2 ${c("library:update_all")?"text-white hover:bg-bambu-dark":"text-bambu-gray cursor-not-allowed"}`,onClick:()=>{c("library:update_all")&&(i(t),p(!1))},disabled:!c("library:update_all"),title:c("library:update_all")?void 0:u("fileManager.noPermissionLinkFolder"),children:[a.jsx(Rh,{className:"w-3.5 h-3.5"}),u(y?"fileManager.changeLink":"fileManager.linkTo")]}),a.jsxs("button",{className:`w-full px-3 py-1.5 text-left text-sm flex items-center gap-2 ${c("library:delete_all")?"text-red-400 hover:bg-bambu-dark":"text-bambu-gray cursor-not-allowed"}`,onClick:()=>{c("library:delete_all")&&(r(t.id),p(!1))},disabled:!c("library:delete_all"),title:c("library:delete_all")?void 0:u("fileManager.noPermissionDeleteFolder"),children:[a.jsx(Jt,{className:"w-3.5 h-3.5"}),u("common.delete")]})]})]})]})})]}),x&&d&&a.jsx("div",{children:t.children.map(b=>a.jsx(Qae,{folder:b,selectedFolderId:e,onSelect:n,onDelete:r,onLink:i,onRename:s,depth:o+1,wrapNames:l,hasPermission:c,t:u},b.id))})]})}function pF(t){const e=t.toLowerCase();return e.endsWith(".gcode")||e.includes(".gcode.")}function QZe({file:t,isSelected:e,isMobile:n,onSelect:r,onDelete:i,onDownload:s,onAddToQueue:o,onPrint:l,onPreview3d:c,onRename:u,onGenerateThumbnail:d,thumbnailVersion:h,hasPermission:f,canModify:p,authEnabled:x,t:y}){const[b,v]=w.useState(!1);return a.jsxs("div",{className:`group relative bg-bambu-dark-secondary rounded-lg border transition-all cursor-pointer overflow-hidden ${e?"border-bambu-green ring-1 ring-bambu-green":"border-bambu-dark-tertiary hover:border-bambu-green/50"}`,onClick:()=>r(t.id),children:[a.jsxs("div",{className:"aspect-square bg-bambu-dark flex items-center justify-center overflow-hidden",children:[t.thumbnail_path?a.jsx("img",{src:`${re.getLibraryFileThumbnailUrl(t.id)}${h?`?v=${h}`:""}`,alt:t.filename,className:"w-full h-full object-cover"}):a.jsx(pf,{className:"w-12 h-12 text-bambu-gray/30"}),a.jsx("div",{className:`absolute top-2 right-2 text-xs px-1.5 py-0.5 rounded font-medium ${t.file_type==="3mf"?"bg-bambu-green/90 text-white":t.file_type==="gcode"?"bg-blue-500/90 text-white":t.file_type==="stl"?"bg-purple-500/90 text-white":"bg-bambu-gray/90 text-white"}`,children:t.file_type.toUpperCase()})]}),a.jsxs("div",{className:"p-3",children:[a.jsx("h3",{className:"text-sm font-medium text-white truncate",title:t.print_name||t.filename,children:t.print_name||t.filename}),a.jsxs("div",{className:"flex items-center gap-3 mt-1 text-xs text-bambu-gray",children:[a.jsx("span",{children:Bg(t.file_size)}),t.print_time_seconds&&a.jsxs("span",{className:"flex items-center gap-1",children:[a.jsx(Wn,{className:"w-3 h-3"}),Zs(t.print_time_seconds)]})]}),t.sliced_for_model&&a.jsxs("div",{className:"mt-1 text-xs text-bambu-gray flex items-center gap-1",children:[a.jsx(Cr,{className:"w-3 h-3"}),t.sliced_for_model]}),t.print_count>0&&a.jsx("div",{className:"mt-1 text-xs text-bambu-green",children:y("fileManager.printedCount",{count:t.print_count})}),x&&t.created_by_username&&a.jsxs("div",{className:"mt-1 text-xs text-bambu-gray flex items-center gap-1",children:[a.jsx(rd,{className:"w-3 h-3"}),t.created_by_username]})]}),a.jsxs("div",{className:`absolute bottom-2 right-2 transition-opacity ${n?"opacity-100":"opacity-0 group-hover:opacity-100"}`,onClick:S=>S.stopPropagation(),children:[a.jsx("button",{onClick:()=>v(!b),className:"p-1.5 rounded bg-bambu-dark-secondary/90 hover:bg-bambu-dark-tertiary",children:a.jsx(Eh,{className:"w-4 h-4 text-bambu-gray"})}),b&&a.jsxs(a.Fragment,{children:[a.jsx("div",{className:"fixed inset-0 z-10",onClick:()=>v(!1)}),a.jsxs("div",{className:"absolute right-0 bottom-8 z-20 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg shadow-xl py-1 min-w-[140px]",children:[l&&pF(t.filename)&&a.jsxs("button",{className:`w-full px-3 py-1.5 text-left text-sm flex items-center gap-2 ${f("printers:control")?"text-bambu-green hover:bg-bambu-dark":"text-bambu-gray cursor-not-allowed"}`,onClick:()=>{f("printers:control")&&(l(t),v(!1))},disabled:!f("printers:control"),title:f("printers:control")?void 0:y("fileManager.noPermissionPrint"),children:[a.jsx(Cr,{className:"w-3.5 h-3.5"}),y("common.print")]}),o&&pF(t.filename)&&a.jsxs("button",{className:`w-full px-3 py-1.5 text-left text-sm flex items-center gap-2 ${f("queue:create")?"text-white hover:bg-bambu-dark":"text-bambu-gray cursor-not-allowed"}`,onClick:()=>{f("queue:create")&&(o(t.id),v(!1))},disabled:!f("queue:create"),title:f("queue:create")?void 0:y("fileManager.noPermissionAddToQueue"),children:[a.jsx(Wn,{className:"w-3.5 h-3.5"}),y("fileManager.schedulePrint")]}),c&&(t.file_type==="3mf"||t.file_type==="gcode"||t.file_type==="stl")&&a.jsxs("button",{className:`w-full px-3 py-1.5 text-left text-sm flex items-center gap-2 ${f("library:read")?"text-white hover:bg-bambu-dark":"text-bambu-gray cursor-not-allowed"}`,onClick:()=>{f("library:read")&&(c(t),v(!1))},disabled:!f("library:read"),title:f("library:read")?void 0:"You do not have permission to preview files",children:[a.jsx(ea,{className:"w-3.5 h-3.5"}),"3D Preview"]}),a.jsxs("button",{className:`w-full px-3 py-1.5 text-left text-sm flex items-center gap-2 ${f("library:read")?"text-white hover:bg-bambu-dark":"text-bambu-gray cursor-not-allowed"}`,onClick:()=>{f("library:read")&&(s(t.id),v(!1))},disabled:!f("library:read"),title:f("library:read")?void 0:y("fileManager.noPermissionDownload"),children:[a.jsx(di,{className:"w-3.5 h-3.5"}),y("common.download")]}),u&&a.jsxs("button",{className:`w-full px-3 py-1.5 text-left text-sm flex items-center gap-2 ${p("library","update",t.created_by_id)?"text-white hover:bg-bambu-dark":"text-bambu-gray cursor-not-allowed"}`,onClick:()=>{p("library","update",t.created_by_id)&&(u(t),v(!1))},disabled:!p("library","update",t.created_by_id),title:p("library","update",t.created_by_id)?void 0:y("fileManager.noPermissionRenameFile"),children:[a.jsx(Vi,{className:"w-3.5 h-3.5"}),y("common.rename")]}),d&&t.file_type==="stl"&&a.jsxs("button",{className:`w-full px-3 py-1.5 text-left text-sm flex items-center gap-2 ${p("library","update",t.created_by_id)?"text-white hover:bg-bambu-dark":"text-bambu-gray cursor-not-allowed"}`,onClick:()=>{p("library","update",t.created_by_id)&&(d(t),v(!1))},disabled:!p("library","update",t.created_by_id),title:p("library","update",t.created_by_id)?void 0:y("fileManager.noPermissionGenerateThumbnail"),children:[a.jsx(td,{className:"w-3.5 h-3.5"}),y("fileManager.generateThumbnail")]}),a.jsxs("button",{className:`w-full px-3 py-1.5 text-left text-sm flex items-center gap-2 ${p("library","delete",t.created_by_id)?"text-red-400 hover:bg-bambu-dark":"text-bambu-gray cursor-not-allowed"}`,onClick:()=>{p("library","delete",t.created_by_id)&&(i(t.id),v(!1))},disabled:!p("library","delete",t.created_by_id),title:p("library","delete",t.created_by_id)?void 0:y("fileManager.noPermissionDeleteFile"),children:[a.jsx(Jt,{className:"w-3.5 h-3.5"}),y("common.delete")]})]})]})]}),a.jsx("div",{className:`absolute top-2 left-2 w-5 h-5 rounded border-2 flex items-center justify-center transition-all ${e?"bg-bambu-green border-bambu-green":`border-white/30 bg-black/30 ${n?"opacity-100":"opacity-0 group-hover:opacity-100"}`}`,children:e&&a.jsx("div",{className:"w-2 h-2 bg-white rounded-sm"})})]})}function ZZe(){const{t}=Vt(),e=tn(),{showToast:n}=hn(),{hasPermission:r,hasAnyPermission:i,canModify:s,authEnabled:o}=Ir(),[l]=kF(),c=l.get("folder"),u=c?parseInt(c,10):null,[d,h]=w.useState(u),[f,p]=w.useState([]),[x,y]=w.useState(!1),[b,v]=w.useState(!1),[S,N]=w.useState(!1),[A,C]=w.useState(null),[T,k]=w.useState(null),[j,E]=w.useState(null),[P,U]=w.useState(null),[O,B]=w.useState(null),[R,G]=w.useState(null),[q,z]=w.useState({}),[K,Y]=w.useState(null),[oe,$]=w.useState(()=>localStorage.getItem("library-view-mode")||"grid"),[X,ee]=w.useState(()=>localStorage.getItem("library-wrap-folders")==="true"),[J,_e]=w.useState(()=>{const Ie=localStorage.getItem("library-sidebar-width");return Ie?parseInt(Ie,10):256}),[pe,me]=w.useState(!1),je=w.useRef(null);w.useEffect(()=>{if(!pe)return;document.body.style.userSelect="none",document.body.style.cursor="col-resize";const Ie=wt=>{if(!je.current)return;const Bt=je.current.parentElement?.getBoundingClientRect();if(!Bt)return;const Tn=wt.clientX-Bt.left,fr=Math.min(500,Math.max(200,Tn));_e(fr)},xt=()=>{me(!1),document.body.style.userSelect="",document.body.style.cursor="",localStorage.setItem("library-sidebar-width",String(J))};return document.addEventListener("mousemove",Ie),document.addEventListener("mouseup",xt),()=>{document.removeEventListener("mousemove",Ie),document.removeEventListener("mouseup",xt),document.body.style.userSelect="",document.body.style.cursor=""}},[pe,J]);const[de,ce]=w.useState(""),[Se,ie]=w.useState("all"),[Fe,V]=w.useState(""),[W,ue]=w.useState(()=>localStorage.getItem("library-sort-field")||"name"),[Q,se]=w.useState(()=>localStorage.getItem("library-sort-direction")||"asc"),Z=gne();w.useEffect(()=>{const Ie=l.get("folder");if(Ie){const xt=parseInt(Ie,10);h(xt)}},[l]);const{data:Ne}=Ze({queryKey:["settings"],queryFn:()=>re.getSettings()}),{data:ve,isLoading:fe}=Ze({queryKey:["library-folders"],queryFn:()=>re.getLibraryFolders()}),{data:L,isLoading:D}=Ze({queryKey:["library-files",d],queryFn:()=>re.getLibraryFiles(d,d===null)}),{data:H}=Ze({queryKey:["library-stats"],queryFn:()=>re.getLibraryStats()}),{data:he}=Ze({queryKey:["users"],queryFn:()=>re.getUsers()}),xe=w.useMemo(()=>{if(!L)return[];const Ie=new Set(L.map(xt=>xt.file_type));return Array.from(Ie).sort()},[L]),be=w.useMemo(()=>{if(!L)return[];let Ie=[...L];if(de.trim()){const xt=de.toLowerCase();Ie=Ie.filter(wt=>wt.filename.toLowerCase().includes(xt)||wt.print_name&&wt.print_name.toLowerCase().includes(xt))}if(Se!=="all"&&(Ie=Ie.filter(xt=>xt.file_type===Se)),Fe.trim()){const xt=Fe.toLowerCase();Ie=Ie.filter(wt=>wt.created_by_username&&wt.created_by_username.toLowerCase().includes(xt))}return Ie.sort((xt,wt)=>{let Bt=0;switch(W){case"name":Bt=(xt.print_name||xt.filename).localeCompare(wt.print_name||wt.filename);break;case"date":Bt=new Date(xt.created_at).getTime()-new Date(wt.created_at).getTime();break;case"size":Bt=xt.file_size-wt.file_size;break;case"type":Bt=xt.file_type.localeCompare(wt.file_type);break;case"prints":Bt=xt.print_count-wt.print_count;break}return Q==="asc"?Bt:-Bt}),Ie},[L,de,Se,Fe,W,Q]),Ue=w.useMemo(()=>{if(!H||!Ne)return!1;const Ie=(Ne.library_disk_warning_gb||5)*1024*1024*1024;return H.disk_free_bytesre.createLibraryFolder(Ie),onSuccess:()=>{e.invalidateQueries({queryKey:["library-folders"]}),y(!1),n(t("fileManager.toast.folderCreated"),"success")},onError:Ie=>n(Ie.message,"error")}),Qe=ot({mutationFn:Ie=>re.deleteLibraryFolder(Ie),onSuccess:()=>{e.invalidateQueries({queryKey:["library-folders"]}),e.invalidateQueries({queryKey:["library-files"]}),e.invalidateQueries({queryKey:["library-stats"]}),d===T?.id&&h(null),k(null),n(t("fileManager.toast.folderDeleted"),"success")},onError:Ie=>{k(null),n(Ie.message,"error")}}),rt=ot({mutationFn:Ie=>re.deleteLibraryFile(Ie),onSuccess:()=>{e.invalidateQueries({queryKey:["library-files"]}),e.invalidateQueries({queryKey:["library-folders"]}),e.invalidateQueries({queryKey:["library-stats"]}),p(Ie=>Ie.filter(xt=>xt!==T?.id)),k(null),n(t("fileManager.toast.fileDeleted"),"success")},onError:Ie=>{k(null),n(Ie.message,"error")}}),we=ot({mutationFn:Ie=>re.bulkDeleteLibrary(Ie,[]),onSuccess:(Ie,xt)=>{e.invalidateQueries({queryKey:["library-files"]}),e.invalidateQueries({queryKey:["library-folders"]}),e.invalidateQueries({queryKey:["library-stats"]}),n(t("fileManager.toast.filesDeleted",{count:xt.length}),"success"),p([]),k(null)},onError:Ie=>{k(null),n(Ie.message,"error")}}),ye=ot({mutationFn:({fileIds:Ie,folderId:xt})=>re.moveLibraryFiles(Ie,xt),onSuccess:()=>{e.invalidateQueries({queryKey:["library-files"]}),e.invalidateQueries({queryKey:["library-folders"]}),p([]),v(!1),n(t("fileManager.toast.filesMoved"),"success")},onError:Ie=>n(Ie.message,"error")}),le=ot({mutationFn:({id:Ie,data:xt})=>re.updateLibraryFolder(Ie,xt),onSuccess:(Ie,xt)=>{e.invalidateQueries({queryKey:["library-folders"]}),e.invalidateQueries({queryKey:["project-folders"]}),e.invalidateQueries({queryKey:["archive-folders"]}),C(null);const wt=xt.data.project_id===0&&xt.data.archive_id===0;n(t(wt?"fileManager.toast.folderUnlinked":"fileManager.toast.folderLinked"),"success")},onError:Ie=>n(Ie.message,"error")}),Le=ot({mutationFn:({id:Ie,filename:xt})=>re.updateLibraryFile(Ie,{filename:xt}),onSuccess:()=>{e.invalidateQueries({queryKey:["library-files"]}),G(null),n(t("fileManager.toast.fileRenamed"),"success")},onError:Ie=>{G(null),n(Ie.message,"error")}}),Me=ot({mutationFn:({id:Ie,name:xt})=>re.updateLibraryFolder(Ie,{name:xt}),onSuccess:()=>{e.invalidateQueries({queryKey:["library-folders"]}),e.invalidateQueries({queryKey:["library-files"]}),G(null),n(t("fileManager.toast.folderRenamed"),"success")},onError:Ie=>{G(null),n(Ie.message,"error")}}),$e=ot({mutationFn:()=>re.batchGenerateStlThumbnails({all_missing:!0}),onSuccess:Ie=>{if(e.invalidateQueries({queryKey:["library-files"]}),Ie.succeeded>0){const xt=Date.now(),wt={};Ie.results.forEach(Bt=>{Bt.success&&(wt[Bt.file_id]=xt)}),z(Bt=>({...Bt,...wt}))}Ie.succeeded>0&&Ie.failed===0?n(t("fileManager.toast.thumbnailsGenerated",{count:Ie.succeeded}),"success"):Ie.succeeded>0&&Ie.failed>0?n(t("fileManager.toast.thumbnailsGeneratedPartial",{succeeded:Ie.succeeded,failed:Ie.failed}),"success"):Ie.processed===0?n(t("fileManager.toast.noStlMissingThumbnails"),"info"):n(t("fileManager.toast.failedToGenerateThumbnails",{error:Ie.results[0]?.error||"Unknown error"}),"error")},onError:Ie=>n(Ie.message,"error")}),Ae=ot({mutationFn:Ie=>re.batchGenerateStlThumbnails({file_ids:[Ie]}),onSuccess:Ie=>{if(e.invalidateQueries({queryKey:["library-files"]}),Ie.succeeded>0){const xt=Ie.results[0]?.file_id;xt&&z(wt=>({...wt,[xt]:Date.now()})),n(t("fileManager.toast.thumbnailGenerated"),"success")}else n(t("fileManager.toast.failedToGenerateThumbnail",{error:Ie.results[0]?.error||"Unknown error"}),"error")},onError:Ie=>n(Ie.message,"error")}),Je=w.useCallback(Ie=>{const xt=Ie.toLowerCase();return xt.endsWith(".gcode")||xt.includes(".gcode.")},[]),Pe=w.useMemo(()=>L?L.filter(Ie=>f.includes(Ie.id)&&Je(Ie.filename)):[],[L,f,Je]),Xe=w.useCallback(Ie=>{p(xt=>xt.includes(Ie)?xt.filter(wt=>wt!==Ie):[...xt,Ie])},[]),De=w.useCallback(()=>{be.length>0&&p(be.map(Ie=>Ie.id))},[be]),Re=w.useCallback(()=>{p([])},[]),qe=()=>{e.invalidateQueries({queryKey:["library-files"]}),e.invalidateQueries({queryKey:["library-folders"]}),e.invalidateQueries({queryKey:["library-stats"]})},pt=Ie=>{re.downloadLibraryFile(Ie).catch(xt=>{console.error("Library file download failed:",xt)})},At=()=>{T&&(T.type==="file"?rt.mutate(T.id):T.type==="folder"?Qe.mutate(T.id):T.type==="bulk"&&we.mutate(f))},Rt=Qe.isPending||rt.isPending||we.isPending,Wt=Ie=>{$(Ie),localStorage.setItem("library-view-mode",Ie)},Tt=fe||D;return a.jsxs("div",{className:"p-4 md:p-8 min-h-[calc(100vh-64px)] lg:h-[calc(100vh-64px)] flex flex-col",children:[a.jsxs("div",{className:"flex flex-col sm:flex-row sm:items-center justify-between gap-4 mb-6",children:[a.jsxs("div",{children:[a.jsxs("h1",{className:"text-2xl font-bold text-white flex items-center gap-3",children:[a.jsx("div",{className:"p-2.5 bg-bambu-green/10 rounded-xl",children:a.jsx(Yl,{className:"w-6 h-6 text-bambu-green"})}),t("fileManager.title")]}),a.jsx("p",{className:"text-sm text-bambu-gray mt-2 ml-14",children:t("fileManager.subtitle")})]}),a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsxs("div",{className:"flex items-center bg-bambu-dark rounded-lg p-1",children:[a.jsx("button",{onClick:()=>Wt("grid"),className:`p-1.5 rounded transition-colors ${oe==="grid"?"bg-bambu-dark-secondary text-white":"text-bambu-gray hover:text-white"}`,title:t("fileManager.gridView"),children:a.jsx(xv,{className:"w-4 h-4"})}),a.jsx("button",{onClick:()=>Wt("list"),className:`p-1.5 rounded transition-colors ${oe==="list"?"bg-bambu-dark-secondary text-white":"text-bambu-gray hover:text-white"}`,title:t("fileManager.listView"),children:a.jsx(rC,{className:"w-4 h-4"})})]}),a.jsxs(Ce,{variant:"secondary",onClick:()=>$e.mutate(),disabled:$e.isPending||!i("library:update_own","library:update_all"),title:i("library:update_own","library:update_all")?t("fileManager.generateThumbnailsForMissing"):t("fileManager.noPermissionGenerateThumbnail"),children:[$e.isPending?a.jsx(it,{className:"w-4 h-4 mr-2 animate-spin"}):a.jsx(td,{className:"w-4 h-4 mr-2"}),t("fileManager.generateThumbnails")]}),a.jsxs(Ce,{variant:"secondary",onClick:()=>y(!0),disabled:!r("library:upload"),title:r("library:upload")?void 0:t("fileManager.noPermissionCreateFolder"),children:[a.jsx(tme,{className:"w-4 h-4 mr-2"}),t("fileManager.newFolder")]}),a.jsxs(Ce,{onClick:()=>N(!0),disabled:!r("library:upload"),title:r("library:upload")?void 0:t("fileManager.noPermissionUpload"),children:[a.jsx(Fi,{className:"w-4 h-4 mr-2"}),t("common.upload")]})]})]}),Ue&&H&&Ne&&a.jsxs("div",{className:"flex items-center gap-3 mb-4 p-3 bg-amber-500/10 border border-amber-500/30 rounded-lg",children:[a.jsx(Cn,{className:"w-5 h-5 text-amber-500 flex-shrink-0"}),a.jsxs("div",{className:"flex-1",children:[a.jsx("p",{className:"text-sm text-amber-500 font-medium",children:t("fileManager.lowDiskSpaceWarning")}),a.jsx("p",{className:"text-xs text-amber-500/80",children:t("fileManager.lowDiskSpaceDetails",{free:Bg(H.disk_free_bytes),total:Bg(H.disk_total_bytes),threshold:Ne.library_disk_warning_gb})})]})]}),H&&a.jsxs("div",{className:"flex flex-wrap items-center gap-3 sm:gap-6 mb-6 p-3 bg-bambu-dark-secondary rounded-lg border border-bambu-dark-tertiary",children:[a.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[a.jsx(eC,{className:"w-4 h-4 text-bambu-green"}),a.jsxs("span",{className:"text-bambu-gray",children:[t("fileManager.files"),":"]}),a.jsx("span",{className:"text-white font-medium",children:H.total_files})]}),a.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[a.jsx(Yl,{className:"w-4 h-4 text-blue-400"}),a.jsxs("span",{className:"text-bambu-gray",children:[t("fileManager.folders"),":"]}),a.jsx("span",{className:"text-white font-medium",children:H.total_folders})]}),a.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[a.jsx(qb,{className:"w-4 h-4 text-amber-400"}),a.jsxs("span",{className:"text-bambu-gray",children:[t("fileManager.size"),":"]}),a.jsx("span",{className:"text-white font-medium",children:Bg(H.total_size_bytes)})]}),a.jsxs("div",{className:"flex items-center gap-2 text-sm sm:ml-auto",children:[a.jsxs("span",{className:"text-bambu-gray",children:[t("fileManager.free"),":"]}),a.jsx("span",{className:`font-medium ${Ue?"text-amber-500":"text-white"}`,children:Bg(H.disk_free_bytes)})]})]}),a.jsxs("div",{className:"flex-1 flex flex-col lg:flex-row gap-4 lg:gap-6 min-h-0",children:[a.jsx("div",{className:"lg:hidden",children:a.jsxs("select",{value:d??"",onChange:Ie=>h(Ie.target.value?parseInt(Ie.target.value,10):null),className:"w-full bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg px-3 py-2.5 text-white focus:outline-none focus:border-bambu-green",children:[a.jsxs("option",{value:"",children:["📁 ",t("fileManager.allFiles")]}),ve&&(()=>{const Ie=(xt,wt=0)=>{const Bt=[];for(const Tn of xt)Bt.push({id:Tn.id,name:Tn.name,fileCount:Tn.file_count,depth:wt}),Tn.children.length>0&&Bt.push(...Ie(Tn.children,wt+1));return Bt};return Ie(ve).map(xt=>a.jsxs("option",{value:xt.id,children:["│ ".repeat(xt.depth),"📂 ",xt.name," ",xt.fileCount>0?`(${xt.fileCount})`:""]},xt.id))})()]})}),a.jsxs("div",{ref:je,className:"hidden lg:flex flex-shrink-0 bg-bambu-dark-secondary rounded-lg border border-bambu-dark-tertiary overflow-hidden flex-col relative",style:{width:`${J}px`},children:[a.jsx("div",{className:`absolute right-0 top-0 bottom-0 w-1.5 cursor-col-resize z-10 group/resize flex items-center justify-center transition-colors ${pe?"bg-bambu-green":"hover:bg-bambu-green/50"}`,onMouseDown:Ie=>{Ie.preventDefault(),me(!0)},onDoubleClick:()=>{_e(256),localStorage.setItem("library-sidebar-width","256")},title:t("fileManager.dragToResizeTooltip"),children:a.jsxs("div",{className:`flex flex-col gap-1 opacity-0 group-hover/resize:opacity-100 transition-opacity ${pe?"opacity-100":""}`,children:[a.jsx("div",{className:"w-0.5 h-0.5 rounded-full bg-white/70"}),a.jsx("div",{className:"w-0.5 h-0.5 rounded-full bg-white/70"}),a.jsx("div",{className:"w-0.5 h-0.5 rounded-full bg-white/70"})]})}),a.jsxs("div",{className:"p-3 border-b border-bambu-dark-tertiary flex items-center justify-between",children:[a.jsx("h2",{className:"text-sm font-medium text-white",children:t("fileManager.folders")}),a.jsx("button",{onClick:()=>{const Ie=!X;ee(Ie),localStorage.setItem("library-wrap-folders",String(Ie))},className:`text-xs px-1.5 py-0.5 rounded transition-colors ${X?"bg-bambu-green/20 text-bambu-green":"text-bambu-gray hover:text-white hover:bg-bambu-dark"}`,title:t(X?"fileManager.disableTextWrapping":"fileManager.enableTextWrapping"),children:t("fileManager.wrap")})]}),a.jsxs("div",{className:"flex-1 overflow-y-auto p-2",children:[a.jsxs("div",{className:`flex items-center gap-2 px-2 py-1.5 rounded cursor-pointer transition-colors ${d===null?"bg-bambu-green/20 text-bambu-green":"hover:bg-bambu-dark text-white"}`,onClick:()=>h(null),children:[a.jsx(pf,{className:"w-4 h-4"}),a.jsx("span",{className:"text-sm",children:t("fileManager.allFiles")})]}),ve?.map(Ie=>a.jsx(Qae,{folder:Ie,selectedFolderId:d,onSelect:h,onDelete:xt=>k({type:"folder",id:xt}),onLink:C,onRename:xt=>G({type:"folder",id:xt.id,name:xt.name}),wrapNames:X,hasPermission:r,t},Ie.id))]})]}),a.jsxs("div",{className:"flex-1 flex flex-col min-w-0 min-h-0",children:[L&&L.length>0&&a.jsxs("div",{className:"flex flex-wrap items-center gap-2 sm:gap-3 mb-4 p-2 sm:p-3 bg-bambu-dark-secondary rounded-lg border border-bambu-dark-tertiary sticky top-0 z-10 lg:static",children:[a.jsxs("div",{className:"relative w-full sm:w-auto sm:flex-1 sm:max-w-xs",children:[a.jsx(Or,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray"}),a.jsx("input",{type:"text",placeholder:t("fileManager.searchFiles"),value:de,onChange:Ie=>ce(Ie.target.value),className:"w-full pl-9 pr-3 py-1.5 bg-bambu-dark border border-bambu-dark-tertiary rounded text-sm text-white placeholder-bambu-gray focus:outline-none focus:border-bambu-green"})]}),a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx(tC,{className:"w-4 h-4 text-bambu-gray hidden sm:block"}),a.jsxs("select",{value:Se,onChange:Ie=>ie(Ie.target.value),className:"bg-bambu-dark border border-bambu-dark-tertiary rounded px-2 py-1.5 text-sm text-white focus:outline-none focus:border-bambu-green",children:[a.jsx("option",{value:"all",children:t("fileManager.allTypes")}),xe.map(Ie=>a.jsx("option",{value:Ie,children:Ie.toUpperCase()},Ie))]})]}),o&&a.jsxs("div",{className:"relative",children:[a.jsx("input",{type:"text",placeholder:t("fileManager.filterByUser",{defaultValue:"Filter by user"}),value:Fe,onChange:Ie=>V(Ie.target.value),list:"usernames-list",className:`w-32 sm:w-40 px-2 py-1.5 bg-bambu-dark border border-bambu-dark-tertiary rounded text-sm text-white placeholder-bambu-gray focus:outline-none focus:border-bambu-green ${Fe?"pr-7":""}`,style:Fe?{WebkitAppearance:"none",MozAppearance:"textfield"}:void 0}),Fe&&a.jsx("button",{onClick:()=>V(""),className:"absolute right-2 top-1/2 -translate-y-1/2 text-bambu-gray hover:text-white z-10",children:a.jsx(Ft,{className:"w-3 h-3"})}),a.jsx("datalist",{id:"usernames-list",children:he?.map(Ie=>a.jsx("option",{value:Ie.username},Ie.id))})]}),a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsxs("select",{value:W,onChange:Ie=>{const xt=Ie.target.value;ue(xt),localStorage.setItem("library-sort-field",xt)},className:"bg-bambu-dark border border-bambu-dark-tertiary rounded px-2 py-1.5 text-sm text-white focus:outline-none focus:border-bambu-green",children:[a.jsx("option",{value:"name",children:t("common.name")}),a.jsx("option",{value:"date",children:t("common.date")}),a.jsx("option",{value:"size",children:t("fileManager.size")}),a.jsx("option",{value:"type",children:t("common.type")}),a.jsx("option",{value:"prints",children:t("fileManager.prints")})]}),a.jsx("button",{onClick:()=>se(Ie=>{const xt=Ie==="asc"?"desc":"asc";return localStorage.setItem("library-sort-direction",xt),xt}),className:"p-1.5 rounded bg-bambu-dark border border-bambu-dark-tertiary hover:border-bambu-green transition-colors",title:t(Q==="asc"?"fileManager.ascending":"fileManager.descending"),children:Q==="asc"?a.jsx(wde,{className:"w-4 h-4 text-white"}):a.jsx(mde,{className:"w-4 h-4 text-white"})})]}),(de||Se!=="all"||Fe)&&a.jsx("span",{className:"text-sm text-bambu-gray hidden sm:inline",children:t("fileManager.resultsCount",{showing:be.length,total:L.length})})]}),be.length>0&&a.jsxs("div",{className:"flex flex-wrap items-center gap-2 mb-4 p-2 bg-bambu-dark-secondary rounded-lg border border-bambu-dark-tertiary sticky top-[52px] z-10 lg:static",children:[f.length===be.length&&f.length>0?a.jsxs(Ce,{variant:"secondary",size:"sm",onClick:Re,children:[a.jsx(bl,{className:"w-4 h-4 sm:mr-1"}),a.jsx("span",{className:"hidden sm:inline",children:t("fileManager.deselectAll")})]}):a.jsxs(Ce,{variant:"secondary",size:"sm",onClick:De,children:[a.jsx(oo,{className:"w-4 h-4 sm:mr-1"}),a.jsx("span",{className:"hidden sm:inline",children:t("fileManager.selectAll")})]}),f.length>0&&a.jsxs(a.Fragment,{children:[a.jsx("span",{className:"text-sm text-bambu-gray ml-2",children:t("fileManager.selected",{count:f.length})}),a.jsx("div",{className:"hidden sm:block flex-1"}),a.jsxs("div",{className:"w-full sm:w-auto flex flex-wrap items-center gap-2 mt-2 sm:mt-0",children:[Pe.length===1&&a.jsxs(Ce,{variant:"primary",size:"sm",onClick:()=>U(Pe[0]),disabled:!r("printers:control"),title:r("printers:control")?void 0:t("fileManager.noPermissionPrint"),children:[a.jsx(so,{className:"w-4 h-4 sm:mr-1"}),a.jsx("span",{className:"hidden sm:inline",children:t("common.print")})]}),Pe.length===1&&a.jsxs(Ce,{variant:"secondary",size:"sm",onClick:()=>B(Pe[0]),disabled:!r("queue:create"),title:r("queue:create")?void 0:t("fileManager.noPermissionAddToQueue"),children:[a.jsx(Wn,{className:"w-4 h-4 sm:mr-1"}),a.jsx("span",{className:"hidden sm:inline",children:t("fileManager.schedulePrint")})]}),a.jsxs(Ce,{variant:"secondary",size:"sm",onClick:()=>v(!0),disabled:!i("library:update_own","library:update_all"),title:i("library:update_own","library:update_all")?void 0:t("fileManager.noPermissionMoveFiles"),children:[a.jsx(lfe,{className:"w-4 h-4 sm:mr-1"}),a.jsx("span",{className:"hidden sm:inline",children:t("common.move")})]}),a.jsxs(Ce,{variant:"danger",size:"sm",onClick:()=>{f.length===1?k({type:"file",id:f[0]}):k({type:"bulk",id:0,count:f.length})},disabled:!i("library:delete_own","library:delete_all"),title:i("library:delete_own","library:delete_all")?void 0:t("fileManager.noPermissionDeleteFiles"),children:[a.jsx(Jt,{className:"w-4 h-4 sm:mr-1"}),a.jsx("span",{className:"hidden sm:inline",children:t("common.delete")})]}),a.jsxs(Ce,{variant:"secondary",size:"sm",onClick:Re,children:[a.jsx(Ft,{className:"w-4 h-4 sm:mr-1"}),a.jsx("span",{className:"hidden sm:inline",children:t("common.clear")})]})]})]})]}),Tt?a.jsx("div",{className:"flex-1 flex items-center justify-center",children:a.jsxs("div",{className:"flex flex-col items-center gap-3",children:[a.jsx(it,{className:"w-8 h-8 animate-spin text-bambu-green"}),a.jsx("p",{className:"text-sm text-bambu-gray",children:t("fileManager.loadingFiles")})]})}):L?.length===0?a.jsxs("div",{className:"flex-1 flex flex-col items-center justify-center",children:[a.jsx("div",{className:"p-4 bg-bambu-dark rounded-2xl mb-4",children:a.jsx(pf,{className:"w-12 h-12 text-bambu-gray/50"})}),a.jsx("h3",{className:"text-lg font-medium text-white mb-2",children:t(d!==null?"fileManager.folderIsEmpty":"fileManager.noFilesYet")}),a.jsx("p",{className:"text-bambu-gray text-center max-w-md mb-6",children:t(d!==null?"fileManager.folderEmptyDescription":"fileManager.noFilesDescription")}),a.jsxs(Ce,{onClick:()=>N(!0),disabled:!r("library:upload"),title:r("library:upload")?void 0:t("fileManager.noPermissionUpload"),children:[a.jsx(ar,{className:"w-4 h-4 mr-2"}),t("fileManager.uploadFiles")]})]}):be.length===0?a.jsxs("div",{className:"flex-1 flex flex-col items-center justify-center",children:[a.jsx("div",{className:"p-4 bg-bambu-dark rounded-2xl mb-4",children:a.jsx(Or,{className:"w-12 h-12 text-bambu-gray/50"})}),a.jsx("h3",{className:"text-lg font-medium text-white mb-2",children:t("fileManager.noMatchingFiles")}),a.jsx("p",{className:"text-bambu-gray text-center max-w-md mb-6",children:t("fileManager.noMatchingFilesDescription")}),a.jsx(Ce,{variant:"secondary",onClick:()=>{ce(""),ie("all")},children:t("fileManager.clearFilters")})]}):oe==="grid"?a.jsx("div",{className:"flex-1 lg:overflow-y-auto",children:a.jsx("div",{className:"grid grid-cols-2 sm:grid-cols-3 lg:grid-cols-4 xl:grid-cols-5 2xl:grid-cols-6 gap-4",children:be.map(Ie=>a.jsx(QZe,{file:Ie,isSelected:f.includes(Ie.id),isMobile:Z,t,onSelect:Xe,onDelete:xt=>k({type:"file",id:xt}),onDownload:pt,onAddToQueue:xt=>{const wt=L?.find(Bt=>Bt.id===xt);wt&&B(wt)},onPrint:E,onPreview3d:Y,onRename:xt=>G({type:"file",id:xt.id,name:xt.filename}),onGenerateThumbnail:xt=>Ae.mutate(xt.id),thumbnailVersion:q[Ie.id],hasPermission:r,canModify:s,authEnabled:o},Ie.id))})}):a.jsx("div",{className:"flex-1 lg:overflow-y-auto",children:a.jsxs("div",{className:"bg-bambu-dark-secondary rounded-lg border border-bambu-dark-tertiary overflow-hidden",children:[a.jsxs("div",{className:`hidden sm:grid ${o?"grid-cols-[auto_1fr_120px_100px_100px_100px_80px]":"grid-cols-[auto_1fr_100px_100px_100px_80px]"} gap-4 px-4 py-2 bg-bambu-dark-secondary border-b border-bambu-dark-tertiary text-xs text-bambu-gray font-medium`,children:[a.jsx("div",{className:"w-6"}),a.jsx("div",{children:t("common.name")}),o&&a.jsx("div",{children:t("fileManager.uploadedBy",{defaultValue:"Uploaded By"})}),a.jsx("div",{children:t("common.type")}),a.jsx("div",{children:t("fileManager.size")}),a.jsx("div",{children:t("fileManager.prints")}),a.jsx("div",{})]}),be.map(Ie=>a.jsxs("div",{className:`grid ${o?"grid-cols-[auto_1fr_120px_100px_100px_100px_80px]":"grid-cols-[auto_1fr_100px_100px_100px_80px]"} gap-4 px-4 py-3 items-center border-b border-bambu-dark-tertiary last:border-b-0 cursor-pointer hover:bg-bambu-dark/50 transition-colors ${f.includes(Ie.id)?"bg-bambu-green/10":""}`,onClick:()=>Xe(Ie.id),children:[a.jsx("div",{className:`w-5 h-5 rounded border-2 flex items-center justify-center ${f.includes(Ie.id)?"bg-bambu-green border-bambu-green":"border-bambu-gray/50"}`,children:f.includes(Ie.id)&&a.jsx("div",{className:"w-2 h-2 bg-white rounded-sm"})}),a.jsxs("div",{className:"flex items-center gap-3 min-w-0",children:[a.jsxs("div",{className:"relative group/thumb",children:[a.jsx("div",{className:"w-10 h-10 rounded bg-bambu-dark flex-shrink-0 overflow-hidden",children:Ie.thumbnail_path?a.jsx("img",{src:`${re.getLibraryFileThumbnailUrl(Ie.id)}${q[Ie.id]?`?v=${q[Ie.id]}`:""}`,alt:"",className:"w-full h-full object-cover"}):a.jsx("div",{className:"w-full h-full flex items-center justify-center",children:a.jsx(pf,{className:"w-5 h-5 text-bambu-gray/50"})})}),Ie.thumbnail_path&&a.jsx("div",{className:"absolute left-0 top-full mt-2 z-50 hidden group-hover/thumb:block",children:a.jsx("div",{className:"w-48 h-48 rounded-lg bg-bambu-dark-secondary border border-bambu-dark-tertiary shadow-xl overflow-hidden",children:a.jsx("img",{src:`${re.getLibraryFileThumbnailUrl(Ie.id)}${q[Ie.id]?`?v=${q[Ie.id]}`:""}`,alt:Ie.filename,className:"w-full h-full object-contain"})})})]}),a.jsx("div",{className:"min-w-0",children:a.jsx("div",{className:"text-sm text-white truncate",children:Ie.print_name||Ie.filename})})]}),o&&a.jsx("div",{className:"text-sm text-bambu-gray flex items-center gap-1",children:Ie.created_by_username?a.jsxs(a.Fragment,{children:[a.jsx(rd,{className:"w-3 h-3"}),a.jsx("span",{className:"truncate",children:Ie.created_by_username})]}):"-"}),a.jsx("div",{children:a.jsx("span",{className:`text-xs px-1.5 py-0.5 rounded font-medium ${Ie.file_type==="3mf"?"bg-bambu-green/20 text-bambu-green":Ie.file_type==="gcode"?"bg-blue-500/20 text-blue-400":Ie.file_type==="stl"?"bg-purple-500/20 text-purple-400":"bg-bambu-gray/20 text-bambu-gray"}`,children:Ie.file_type.toUpperCase()})}),a.jsx("div",{className:"text-sm text-bambu-gray",children:Bg(Ie.file_size)}),a.jsx("div",{className:"text-sm text-bambu-gray",children:Ie.print_count>0?`${Ie.print_count}x`:"-"}),a.jsxs("div",{className:"flex items-center gap-1",onClick:xt=>xt.stopPropagation(),children:[pF(Ie.filename)&&a.jsxs(a.Fragment,{children:[a.jsx("button",{onClick:()=>r("printers:control")&&E(Ie),className:`p-1.5 rounded transition-colors ${r("printers:control")?"hover:bg-bambu-dark text-bambu-gray hover:text-bambu-green":"text-bambu-gray/50 cursor-not-allowed"}`,title:r("printers:control")?t("common.print"):t("fileManager.noPermissionPrint"),disabled:!r("printers:control"),children:a.jsx(Cr,{className:"w-4 h-4"})}),a.jsx("button",{onClick:()=>{r("queue:create")&&B(Ie)},className:`p-1.5 rounded transition-colors ${r("queue:create")?"hover:bg-bambu-dark text-bambu-gray hover:text-white":"text-bambu-gray/50 cursor-not-allowed"}`,title:r("queue:create")?t("fileManager.schedulePrint"):t("fileManager.noPermissionAddToQueue"),disabled:!r("queue:create"),children:a.jsx(Wn,{className:"w-4 h-4"})})]}),(Ie.file_type==="3mf"||Ie.file_type==="gcode"||Ie.file_type==="stl")&&a.jsx("button",{onClick:()=>r("library:read")&&Y(Ie),className:`p-1.5 rounded transition-colors ${r("library:read")?"hover:bg-bambu-dark text-bambu-gray hover:text-bambu-green":"text-bambu-gray/50 cursor-not-allowed"}`,title:r("library:read")?"3D Preview":"You do not have permission to preview files",disabled:!r("library:read"),children:a.jsx(ea,{className:"w-4 h-4"})}),a.jsx("button",{onClick:()=>r("library:read")&&pt(Ie.id),className:`p-1.5 rounded transition-colors ${r("library:read")?"hover:bg-bambu-dark text-bambu-gray hover:text-white":"text-bambu-gray/50 cursor-not-allowed"}`,title:r("library:read")?t("common.download"):t("fileManager.noPermissionDownload"),disabled:!r("library:read"),children:a.jsx(di,{className:"w-4 h-4"})}),a.jsx("button",{onClick:()=>s("library","update",Ie.created_by_id)&&G({type:"file",id:Ie.id,name:Ie.filename}),className:`p-1.5 rounded transition-colors ${s("library","update",Ie.created_by_id)?"hover:bg-bambu-dark text-bambu-gray hover:text-white":"text-bambu-gray/50 cursor-not-allowed"}`,title:s("library","update",Ie.created_by_id)?t("common.rename"):t("fileManager.noPermissionRenameFile"),disabled:!s("library","update",Ie.created_by_id),children:a.jsx(Vi,{className:"w-4 h-4"})}),Ie.file_type==="stl"&&a.jsx("button",{onClick:()=>s("library","update",Ie.created_by_id)&&Ae.mutate(Ie.id),className:`p-1.5 rounded transition-colors ${s("library","update",Ie.created_by_id)?"hover:bg-bambu-dark text-bambu-gray hover:text-bambu-green":"text-bambu-gray/50 cursor-not-allowed"}`,title:s("library","update",Ie.created_by_id)?t("fileManager.generateThumbnail"):t("fileManager.noPermissionGenerateThumbnail"),disabled:Ae.isPending||!s("library","update",Ie.created_by_id),children:a.jsx(td,{className:"w-4 h-4"})}),a.jsx("button",{onClick:()=>s("library","delete",Ie.created_by_id)&&k({type:"file",id:Ie.id}),className:`p-1.5 rounded transition-colors ${s("library","delete",Ie.created_by_id)?"hover:bg-bambu-dark text-bambu-gray hover:text-red-400":"text-bambu-gray/50 cursor-not-allowed"}`,title:s("library","delete",Ie.created_by_id)?t("common.delete"):t("fileManager.noPermissionDeleteFile"),disabled:!s("library","delete",Ie.created_by_id),children:a.jsx(Jt,{className:"w-4 h-4"})})]})]},Ie.id))]})})]})]}),x&&a.jsx(qZe,{parentId:d,onClose:()=>y(!1),onSave:Ie=>Oe.mutate(Ie),isLoading:Oe.isPending,t}),b&&ve&&a.jsx(KZe,{folders:ve,selectedFiles:f,currentFolderId:d,onClose:()=>v(!1),onMove:Ie=>ye.mutate({fileIds:f,folderId:Ie}),isLoading:ye.isPending,t}),S&&a.jsx(YZe,{folderId:d,onClose:()=>N(!1),onUploadComplete:qe,t}),A&&a.jsx(XZe,{folder:A,onClose:()=>C(null),onLink:Ie=>le.mutate({id:A.id,data:Ie}),isLoading:le.isPending,t}),T&&a.jsx(vn,{title:T.type==="folder"?t("fileManager.deleteFolder"):T.type==="bulk"?t("fileManager.deleteFilesCount",{count:T.count}):t("fileManager.deleteFile"),message:T.type==="folder"?t("fileManager.deleteFolderConfirm"):T.type==="bulk"?t("fileManager.deleteFilesConfirm",{count:T.count}):t("fileManager.deleteFileConfirm"),confirmText:t("common.delete"),variant:"danger",isLoading:Rt,loadingText:t("fileManager.deleting"),onConfirm:At,onCancel:()=>k(null)}),j&&a.jsx(Qu,{mode:"reprint",libraryFileId:j.id,archiveName:j.print_name||j.filename,onClose:()=>E(null),onSuccess:()=>{E(null),e.invalidateQueries({queryKey:["library-files"]}),e.invalidateQueries({queryKey:["archives"]})}}),P&&a.jsx(Qu,{mode:"reprint",libraryFileId:P.id,archiveName:P.print_name||P.filename,onClose:()=>U(null),onSuccess:()=>{U(null),p([]),e.invalidateQueries({queryKey:["library-files"]}),e.invalidateQueries({queryKey:["archives"]})}}),O&&a.jsx(Qu,{mode:"add-to-queue",libraryFileId:O.id,archiveName:O.print_name||O.filename,onClose:()=>B(null),onSuccess:()=>{B(null),p([]),e.invalidateQueries({queryKey:["library-files"]}),e.invalidateQueries({queryKey:["queue"]}),e.invalidateQueries({queryKey:["archives"]})}}),K&&a.jsx(N4,{libraryFileId:K.id,title:K.print_name||K.filename,fileType:K.file_type,onClose:()=>Y(null)}),R&&a.jsx(WZe,{type:R.type,currentName:R.name,onClose:()=>G(null),onSave:Ie=>{R.type==="file"?Le.mutate({id:R.id,filename:Ie}):Me.mutate({id:R.id,name:Ie})},isLoading:Le.isPending||Me.isPending,t})]})}const Wj=5,JZe=2e3,eJe=3e4,tJe=5e3;function nJe(){const{t}=Vt(),e=tn(),{showToast:n}=hn(),{hasPermission:r}=Ir(),{printerId:i}=Yk(),s=parseInt(i||"0",10),[o,l]=w.useState("stream"),[c,u]=w.useState(!1),[d,h]=w.useState(!1),[f,p]=w.useState(!0),[x,y]=w.useState(Date.now()),[b,v]=w.useState(!1),[S,N]=w.useState(!1),[A,C]=w.useState(0),[T,k]=w.useState(!1),[j,E]=w.useState(0),[P,U]=w.useState(1),[O,B]=w.useState({x:0,y:0}),[R,G]=w.useState(!1),[q,z]=w.useState({x:0,y:0}),[K,Y]=w.useState(null),[oe,$]=w.useState(null),X=w.useRef(null),ee=w.useRef(null),J=w.useRef(null),_e=w.useRef(null),pe=w.useRef(null),{data:me}=Ze({queryKey:["printer",s],queryFn:()=>re.getPrinter(s),enabled:s>0}),{data:je}=Ze({queryKey:["printerStatus",s],queryFn:()=>re.getPrinterStatus(s),refetchInterval:3e4,enabled:s>0}),de=ot({mutationFn:ye=>re.setChamberLight(s,ye),onMutate:async ye=>{await e.cancelQueries({queryKey:["printerStatus",s]});const le=e.getQueryData(["printerStatus",s]);return e.setQueryData(["printerStatus",s],Le=>({...Le,chamber_light:ye})),{previousStatus:le}},onSuccess:(ye,le)=>{n(`Chamber light ${le?"on":"off"}`)},onError:(ye,le,Le)=>{Le?.previousStatus&&e.setQueryData(["printerStatus",s],Le.previousStatus),n(ye.message||t("printers.toast.failedToControlChamberLight"),"error")}}),ce=(je?.state==="RUNNING"||je?.state==="PAUSE"||je?.state==="PAUSED")&&(je?.printable_objects_count??0)>=2;w.useEffect(()=>(me&&(document.title=`${me.name} - Camera`),()=>{document.title="Bambuddy"}),[me]);const Se=w.useRef(!1);w.useEffect(()=>{const ye=`/api/v1/printers/${s}/camera/stop`;Se.current=!1;const le=()=>{if(s>0&&!Se.current){Se.current=!0;const $e={},Ae=id();Ae&&($e.Authorization=`Bearer ${Ae}`),fetch(ye,{method:"POST",keepalive:!0,headers:$e}).catch(()=>{})}},Le=()=>{le()};window.addEventListener("beforeunload",Le);const Me=X.current;return()=>{window.removeEventListener("beforeunload",Le),Me&&(Me.src=""),le()}},[s]),w.useEffect(()=>{if(f&&!b){const le=setTimeout(()=>{p(!1)},o==="stream"?3e3:2e4);return()=>clearTimeout(le)}},[o,f,x,b]),w.useEffect(()=>{const ye=()=>{const le=!!document.fullscreenElement;N(le),U(1),B({x:0,y:0}),o==="stream"&&!b&&(X.current&&(X.current.src=""),setTimeout(()=>{p(!0),y(Date.now())},200))};return document.addEventListener("fullscreenchange",ye),()=>document.removeEventListener("fullscreenchange",ye)},[o,b]),w.useEffect(()=>{let ye;const le=()=>{clearTimeout(ye),ye=setTimeout(()=>{localStorage.setItem("cameraWindowState",JSON.stringify({width:window.outerWidth,height:window.outerHeight,left:window.screenX,top:window.screenY}))},500)};return window.addEventListener("resize",le),()=>{clearTimeout(ye),window.removeEventListener("resize",le)}},[]),w.useEffect(()=>()=>{J.current&&clearTimeout(J.current),_e.current&&clearInterval(_e.current),pe.current&&clearInterval(pe.current)},[]);const ie=w.useCallback(()=>{if(A>=Wj){k(!1),h(!0);return}const ye=Math.min(JZe*Math.pow(2,A),eJe);k(!0),E(Math.ceil(ye/1e3)),_e.current=setInterval(()=>{E(le=>le<=1?(_e.current&&clearInterval(_e.current),0):le-1)},1e3),J.current=setTimeout(()=>{C(le=>le+1),k(!1),p(!0),h(!1),X.current&&(X.current.src=""),y(Date.now())},ye)},[A]);w.useEffect(()=>{if(o!=="stream"||f||T||b){pe.current&&(clearInterval(pe.current),pe.current=null);return}return pe.current=setInterval(async()=>{try{const ye=await re.getCameraStatus(s);(ye.stalled||!ye.active&&!d)&&(console.log(`Stream issue detected: stalled=${ye.stalled}, active=${ye.active}, reconnecting...`),pe.current&&(clearInterval(pe.current),pe.current=null),p(!1),ie())}catch{}},tJe),()=>{pe.current&&(clearInterval(pe.current),pe.current=null)}},[o,f,d,T,b,s,ie]);const Fe=()=>{p(!1),o==="stream"&&A{if(p(!1),h(!1),C(0),k(!1),J.current&&clearTimeout(J.current),_e.current&&clearInterval(_e.current),X.current&&!localStorage.getItem("cameraWindowState")){const ye=X.current,le=ye.naturalWidth,Le=ye.naturalHeight;if(le>0&&Le>0){const Ae=window.outerWidth-window.innerWidth,Je=window.outerHeight-window.innerHeight,Pe=le+16+Ae,Xe=Le+45+16+Je;try{window.resizeTo(Pe,Xe)}catch{}}}},W=()=>{if(s>0){const ye={},le=id();le&&(ye.Authorization=`Bearer ${le}`),fetch(`/api/v1/printers/${s}/camera/stop`,{method:"POST",headers:ye}).catch(()=>{})}},ue=ye=>{o===ye||b||(v(!0),p(!0),h(!1),C(0),k(!1),U(1),B({x:0,y:0}),J.current&&clearTimeout(J.current),_e.current&&clearInterval(_e.current),X.current&&(X.current.src=""),o==="stream"&&W(),setTimeout(()=>{l(ye),y(Date.now()),v(!1)},100))},Q=()=>{b||(v(!0),p(!0),h(!1),C(0),k(!1),J.current&&clearTimeout(J.current),_e.current&&clearInterval(_e.current),X.current&&(X.current.src=""),o==="stream"&&W(),setTimeout(()=>{y(Date.now()),v(!1)},100))},se=()=>{ee.current&&(document.fullscreenElement?document.exitFullscreen():ee.current.requestFullscreen())},Z=()=>{U(ye=>Math.min(ye+.5,4))},Ne=()=>{U(ye=>{const le=Math.max(ye-.5,1);return le===1&&B({x:0,y:0}),le})},ve=ye=>{ye.preventDefault(),ye.deltaY<0?Z():Ne()},fe=ye=>{P>1&&(ye.preventDefault(),G(!0),z({x:ye.clientX-O.x,y:ye.clientY-O.y}))},L=w.useCallback(()=>{if(!ee.current)return{x:300,y:200};const ye=ee.current.getBoundingClientRect(),le=ye.width*(P-1)/2,Le=ye.height*(P-1)/2;return{x:Math.max(50,le),y:Math.max(50,Le)}},[P]),D=ye=>{if(R&&P>1){const le=ye.clientX-q.x,Le=ye.clientY-q.y,Me=L();B({x:Math.max(-Me.x,Math.min(Me.x,le)),y:Math.max(-Me.y,Math.min(Me.y,Le))})}},H=()=>{G(!1)},he=ye=>{if(ye.length<2)return 0;const le=ye[0].clientX-ye[1].clientX,Le=ye[0].clientY-ye[1].clientY;return Math.sqrt(le*le+Le*Le)},xe=ye=>ye.length<2?{x:ye[0].clientX,y:ye[0].clientY}:{x:(ye[0].clientX+ye[1].clientX)/2,y:(ye[0].clientY+ye[1].clientY)/2},be=ye=>{ye.touches.length===2?(ye.preventDefault(),Y(he(ye.touches)),$(xe(ye.touches))):ye.touches.length===1&&P>1&&(ye.preventDefault(),G(!0),z({x:ye.touches[0].clientX-O.x,y:ye.touches[0].clientY-O.y}))},Ue=ye=>{if(ye.touches.length===2&&K!==null){ye.preventDefault();const le=he(ye.touches),Le=le/K;U($e=>{const Ae=Math.max(1,Math.min(4,$e*Le));return Ae===1&&B({x:0,y:0}),Ae}),Y(le);const Me=xe(ye.touches);if(oe){const $e=L();B(Ae=>({x:Math.max(-$e.x,Math.min($e.x,Ae.x+(Me.x-oe.x))),y:Math.max(-$e.y,Math.min($e.y,Ae.y+(Me.y-oe.y)))}))}$(Me)}else if(ye.touches.length===1&&R&&P>1){ye.preventDefault();const le=ye.touches[0].clientX-q.x,Le=ye.touches[0].clientY-q.y,Me=L();B({x:Math.max(-Me.x,Math.min(Me.x,le)),y:Math.max(-Me.y,Math.min(Me.y,Le))})}},Oe=ye=>{ye.touches.length<2&&(Y(null),$(null)),ye.touches.length===0&&G(!1)},Qe=()=>{U(1),B({x:0,y:0})},rt=b?"":o==="stream"?`/api/v1/printers/${s}/camera/stream?fps=15&t=${x}`:`/api/v1/printers/${s}/camera/snapshot?t=${x}`,we=f||b||T;return s?a.jsxs("div",{ref:ee,className:"min-h-screen bg-black flex flex-col",children:[a.jsxs("div",{className:"flex items-center justify-between px-4 py-2 bg-bambu-dark-secondary border-b border-bambu-dark-tertiary",children:[a.jsxs("h1",{className:"text-sm font-medium text-white flex items-center gap-2",children:[a.jsx(mb,{className:"w-4 h-4"}),me?.name||`Printer ${s}`]}),a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsxs("div",{className:"flex bg-bambu-dark rounded p-0.5",children:[a.jsx("button",{onClick:()=>ue("stream"),disabled:we,className:`px-3 py-1 text-xs rounded transition-colors ${o==="stream"?"bg-bambu-green text-white":"text-bambu-gray hover:text-white disabled:opacity-50"}`,children:t("camera.live")}),a.jsx("button",{onClick:()=>ue("snapshot"),disabled:we,className:`px-3 py-1 text-xs rounded transition-colors ${o==="snapshot"?"bg-bambu-green text-white":"text-bambu-gray hover:text-white disabled:opacity-50"}`,children:t("camera.snapshot")})]}),a.jsx("button",{onClick:()=>de.mutate(!je?.chamber_light),disabled:!je?.connected||de.isPending||!r("printers:control"),className:`p-1.5 rounded disabled:opacity-50 ${je?.chamber_light?"bg-yellow-500/20 hover:bg-yellow-500/30":"hover:bg-bambu-dark-tertiary"}`,title:r("printers:control")?t("camera.chamberLight"):t("printers.permission.noControl"),children:a.jsx(xL,{on:je?.chamber_light??!1,className:"w-4 h-4"})}),a.jsx("button",{onClick:()=>u(!0),disabled:!ce||!r("printers:control"),className:`p-1.5 rounded disabled:opacity-50 ${ce&&r("printers:control")?"hover:bg-bambu-dark-tertiary":""}`,title:r("printers:control")?t(ce?"printers.skipObjects.tooltip":"printers.skipObjects.onlyWhilePrinting"):t("printers.permission.noControl"),children:a.jsx(SC,{className:"w-4 h-4 text-bambu-gray"})}),a.jsx("button",{onClick:Q,disabled:we,className:"p-1.5 hover:bg-bambu-dark-tertiary rounded disabled:opacity-50",title:t(o==="stream"?"camera.restartStream":"camera.refreshSnapshot"),children:a.jsx(kr,{className:`w-4 h-4 text-bambu-gray ${we?"animate-spin":""}`})}),a.jsx("button",{onClick:se,className:"p-1.5 hover:bg-bambu-dark-tertiary rounded",title:t(S?"camera.exitFullscreen":"camera.fullscreen"),children:S?a.jsx(gX,{className:"w-4 h-4 text-bambu-gray"}):a.jsx(Yme,{className:"w-4 h-4 text-bambu-gray"})})]})]}),a.jsx("div",{className:"flex-1 flex items-center justify-center p-2 overflow-hidden",onWheel:ve,onMouseMove:D,onMouseUp:H,onMouseLeave:H,onTouchStart:be,onTouchMove:Ue,onTouchEnd:Oe,style:{touchAction:"none"},children:a.jsxs("div",{className:"relative w-full h-full flex items-center justify-center",children:[(f||b)&&!T&&a.jsx("div",{className:"absolute inset-0 flex items-center justify-center bg-black/50 z-10",children:a.jsxs("div",{className:"text-center",children:[a.jsx(kr,{className:"w-8 h-8 text-bambu-gray animate-spin mx-auto mb-2"}),a.jsx("p",{className:"text-sm text-bambu-gray",children:t(o==="stream"?"camera.connectingToCamera":"camera.capturingSnapshot")})]})}),T&&a.jsx("div",{className:"absolute inset-0 flex items-center justify-center bg-black/80 z-10",children:a.jsxs("div",{className:"text-center p-4",children:[a.jsx(Rf,{className:"w-10 h-10 text-orange-400 mx-auto mb-3"}),a.jsx("p",{className:"text-white mb-2",children:t("camera.connectionLost")}),a.jsx("p",{className:"text-sm text-bambu-gray mb-3",children:t("camera.reconnecting",{countdown:j,attempt:A+1,max:Wj})}),a.jsx("button",{onClick:Q,className:"px-4 py-2 bg-bambu-green text-white text-sm rounded hover:bg-bambu-green/80 transition-colors",children:t("camera.reconnectNow")})]})}),d&&!T&&a.jsx("div",{className:"absolute inset-0 flex items-center justify-center bg-black z-10",children:a.jsxs("div",{className:"text-center p-4",children:[a.jsx(Cn,{className:"w-12 h-12 text-orange-400 mx-auto mb-3"}),a.jsx("p",{className:"text-white mb-2",children:t("camera.cameraUnavailable")}),a.jsx("p",{className:"text-xs text-bambu-gray mb-4 max-w-md",children:t("camera.cameraUnavailableDesc")}),a.jsx("button",{onClick:Q,className:"px-4 py-2 bg-bambu-green text-white rounded hover:bg-bambu-green/80 transition-colors",children:t("camera.retry")})]})}),a.jsx("img",{ref:X,src:rt,alt:t("camera.cameraStream"),className:"max-w-full max-h-full object-contain select-none",style:{transform:`scale(${P}) translate(${O.x/P}px, ${O.y/P}px)`,cursor:P>1?R?"grabbing":"grab":"default"},onError:rt?Fe:void 0,onLoad:rt?V:void 0,onMouseDown:fe,draggable:!1},x),a.jsxs("div",{className:"absolute bottom-4 left-4 flex items-center gap-1.5 bg-black/60 rounded-lg px-2 py-1.5",children:[a.jsx("button",{onClick:Ne,disabled:P<=1,className:"p-1.5 hover:bg-white/10 rounded disabled:opacity-30",title:t("camera.zoomOut"),children:a.jsx(HF,{className:"w-4 h-4 text-white"})}),a.jsxs("button",{onClick:Qe,className:"px-2 py-1 text-sm text-white hover:bg-white/10 rounded min-w-[48px]",title:t("camera.resetZoom"),children:[Math.round(P*100),"%"]}),a.jsx("button",{onClick:Z,disabled:P>=4,className:"p-1.5 hover:bg-white/10 rounded disabled:opacity-30",title:t("camera.zoomIn"),children:a.jsx(BF,{className:"w-4 h-4 text-white"})})]})]})}),a.jsx(yL,{printerId:s,isOpen:c,onClose:()=>u(!1)})]}):a.jsx("div",{className:"min-h-screen bg-black flex items-center justify-center",children:a.jsx("p",{className:"text-white",children:t("camera.invalidPrinterId")})})}function rJe(t){const e=t.get("show")?.split(",")||["progress","layers","eta","filename","status"],n=parseInt(t.get("fps")||"15",10),r=Math.min(Math.max(isNaN(n)?15:n,1),30),i=t.get("camera"),s=i!=="false"&&i!=="0";return{size:t.get("size")||"medium",fps:r,showCamera:s,showProgress:e.includes("progress"),showLayers:e.includes("layers"),showEta:e.includes("eta"),showFilename:e.includes("filename"),showStatus:e.includes("status"),showPrinter:e.includes("printer")}}function iJe(t,e){if(t.stg_cur_name)return t.stg_cur_name;switch(t.state){case"RUNNING":return e("streamOverlay.status.printing");case"PAUSE":return e("streamOverlay.status.paused");case"FINISH":return e("streamOverlay.status.finished");case"FAILED":return e("streamOverlay.status.failed");case"IDLE":return e("streamOverlay.status.idle");default:return t.state||e("streamOverlay.status.unknown")}}function aJe(t){switch(t){case"small":return{container:"p-3",text:"text-sm",textLarge:"text-lg",progressHeight:"h-2",icon:"w-3 h-3",gap:"gap-2",logoHeight:"h-12"};case"large":return{container:"p-6",text:"text-xl",textLarge:"text-3xl",progressHeight:"h-4",icon:"w-6 h-6",gap:"gap-4",logoHeight:"h-24"};default:return{container:"p-4",text:"text-base",textLarge:"text-xl",progressHeight:"h-3",icon:"w-4 h-4",gap:"gap-3",logoHeight:"h-16"}}}function sJe(){const{printerId:t}=Yk(),[e]=kF(),{t:n}=Vt(),r=tn(),i=parseInt(t||"0",10),[s,o]=w.useState(Date.now()),l=w.useMemo(()=>rJe(e),[e]),c=aJe(l.size),{data:u}=Ze({queryKey:["printer",i],queryFn:()=>re.getPrinter(i),enabled:i>0}),{data:d}=Ze({queryKey:["printerStatus",i],queryFn:()=>re.getPrinterStatus(i),enabled:i>0,refetchInterval:2e3}),{data:h}=Ze({queryKey:["settings"],queryFn:re.getSettings}),f=h?.time_format||"system";w.useEffect(()=>{if(!i)return;const S=`${window.location.protocol==="https:"?"wss:":"ws:"}//${window.location.host}/api/v1/ws`,N=new WebSocket(S);return N.onmessage=A=>{try{const C=JSON.parse(A.data);C.type==="printer_status"&&C.printer_id===i&&r.setQueryData(["printerStatus",i],C.status)}catch{}},N.onerror=()=>{},()=>{N.close()}},[i,r]),w.useEffect(()=>(document.title=u?`${u.name} - ${n("streamOverlay.title")}`:n("streamOverlay.title"),()=>{document.title="Bambuddy"}),[u,n]);const p=()=>{setTimeout(()=>{o(Date.now())},3e3)};if(!i)return a.jsx("div",{className:"min-h-screen bg-black flex items-center justify-center",children:a.jsx("p",{className:"text-white",children:n("streamOverlay.invalidPrinterId")})});if(!d)return a.jsx("div",{className:"min-h-screen bg-black flex items-center justify-center",children:a.jsx("p",{className:"text-gray-400",children:n("common.loading")})});const x=d.state==="RUNNING"||d.state==="PAUSE",y=d.progress||0,b=`/api/v1/printers/${i}/camera/stream?fps=${l.fps}&t=${s}`;return a.jsxs("div",{className:"min-h-screen bg-black relative overflow-hidden",children:[l.showCamera&&a.jsx("img",{src:b,alt:n("streamOverlay.cameraStream"),className:"absolute inset-0 w-full h-full object-contain",onError:p},s),a.jsx("a",{href:"https://github.com/maziggy/bambuddy",target:"_blank",rel:"noopener noreferrer",className:"absolute top-4 right-4 z-10",children:a.jsx("img",{src:"/img/bambuddy_logo_dark_transparent.png",alt:"Bambuddy",className:`${c.logoHeight} object-contain drop-shadow-lg hover:scale-105 transition-transform`})}),a.jsx("div",{className:"absolute bottom-0 left-0 right-0 z-10 bg-gradient-to-t from-black/80 via-black/60 to-transparent",children:a.jsxs("div",{className:`${c.container}`,children:[l.showPrinter&&u&&a.jsxs("div",{className:`flex items-center ${c.gap} mb-2`,children:[a.jsx(Cr,{className:`${c.icon} text-white/70`}),a.jsx("span",{className:`${c.text} text-white font-medium`,children:u.name})]}),l.showFilename&&d.current_print&&a.jsx("div",{className:`${c.textLarge} text-white font-semibold mb-2 truncate drop-shadow-md`,children:d.current_print.replace(/\.gcode\.3mf$|\.3mf$|\.gcode$/i,"")}),l.showStatus&&a.jsx("div",{className:`${c.text} text-white/70 mb-2`,children:iJe(d,n)}),l.showProgress&&x&&a.jsxs("div",{className:"mb-3",children:[a.jsxs("div",{className:`flex items-center justify-between mb-1 ${c.text}`,children:[a.jsx("span",{className:"text-white/70",children:n("streamOverlay.progress")}),a.jsxs("span",{className:"text-white font-bold",children:[Math.round(y),"%"]})]}),a.jsx("div",{className:`w-full bg-white/20 rounded-full ${c.progressHeight}`,children:a.jsx("div",{className:`bg-bambu-green ${c.progressHeight} rounded-full transition-all duration-500`,style:{width:`${y}%`}})})]}),x&&(l.showLayers||l.showEta)&&a.jsxs("div",{className:`flex items-center ${c.gap} flex-wrap`,children:[l.showLayers&&d.layer_num!=null&&d.total_layers!=null&&d.total_layers>0&&a.jsxs("div",{className:`flex items-center ${c.gap} text-white/70`,children:[a.jsx(ma,{className:c.icon}),a.jsxs("span",{className:c.text,children:[a.jsx("span",{className:"text-white",children:d.layer_num}),a.jsx("span",{className:"mx-1",children:"/"}),a.jsx("span",{children:d.total_layers})]})]}),l.showEta&&d.remaining_time!=null&&d.remaining_time>0&&a.jsxs(a.Fragment,{children:[a.jsxs("div",{className:`flex items-center ${c.gap} text-white/70`,children:[a.jsx(Iu,{className:c.icon}),a.jsx("span",{className:`${c.text} text-white`,children:Zs(d.remaining_time*60)})]}),a.jsxs("div",{className:`flex items-center ${c.gap} text-white/70`,children:[a.jsx(Wn,{className:c.icon}),a.jsxs("span",{className:`${c.text} text-white`,children:[n("streamOverlay.eta")," ",$F(d.remaining_time,f,n)]})]})]})]}),!x&&a.jsx("div",{className:`${c.text} text-white/70 py-2`,children:d.connected?n("streamOverlay.printerIdle"):n("streamOverlay.printerOffline")})]})})]})}function oJe(){const{t}=Vt(),{id:e}=Yk(),{mode:n}=rp(),{data:r,isLoading:i,error:s}=Ze({queryKey:["external-link",e],queryFn:()=>re.getExternalLink(Number(e)),enabled:!!e});return i?a.jsx("div",{className:"flex items-center justify-center h-full",children:a.jsx(it,{className:"w-8 h-8 text-bambu-green animate-spin"})}):s||!r?a.jsxs("div",{className:"flex flex-col items-center justify-center h-full gap-4 text-bambu-gray",children:[a.jsx(Cn,{className:"w-12 h-12"}),a.jsx("p",{children:t("common.linkNotFound")})]}):a.jsx("iframe",{src:r.url,className:"h-full w-full border-0",style:{colorScheme:n},title:r.name,sandbox:"allow-scripts allow-same-origin allow-forms allow-popups allow-popups-to-escape-sandbox"})}const hK={material:"",subtype:"",brand:"",color_name:"",rgba:"808080FF",label_weight:1e3,core_weight:250,core_weight_catalog_id:null,weight_used:0,slicer_filament:"",note:""};function lJe(t){const e={};return t.slicer_filament||(e.slicer_filament="Slicer preset is required"),t.material||(e.material="Material is required"),t.brand||(e.brand="Brand is required"),t.subtype||(e.subtype="Subtype is required"),{isValid:Object.keys(e).length===0,errors:e}}const cJe=["PLA","PETG","ABS","TPU","ASA","PC","PA","PVA","HIPS","PA-CF","PETG-CF","PLA-CF"],uJe=["Bambu","PolyLite","PolyTerra","eSUN","Overture","Fiberon","SUNLU","Inland","Hatchbox","Generic"],y0=["Basic","Matte","Silk","Tough","HF","High Flow","Engineering","Galaxy","Glow","Marble","Metal","Rainbow","Sparkle","Wood","Translucent","Transparent","Clear","Lite","Pro","Plus","Max","Super","Ultra","Flex","Soft","Hard","Strong","Impact","Heat Resistant","UV Resistant","ESD","Conductive","Magnetic","Gradient","Dual Color","Tri Color","Multicolor"],Zae=[{name:"Black",hex:"000000"},{name:"White",hex:"FFFFFF"},{name:"Gray",hex:"808080"},{name:"Red",hex:"FF0000"},{name:"Orange",hex:"FFA500"},{name:"Yellow",hex:"FFFF00"},{name:"Green",hex:"00AE42"},{name:"Blue",hex:"0066FF"},{name:"Purple",hex:"8B00FF"},{name:"Pink",hex:"FF69B4"},{name:"Brown",hex:"8B4513"},{name:"Silver",hex:"C0C0C0"}],dJe=[{name:"Dark Red",hex:"8B0000"},{name:"Crimson",hex:"DC143C"},{name:"Coral",hex:"FF7F50"},{name:"Salmon",hex:"FA8072"},{name:"Dark Orange",hex:"FF8C00"},{name:"Peach",hex:"FFDAB9"},{name:"Gold",hex:"FFD700"},{name:"Khaki",hex:"F0E68C"},{name:"Lemon",hex:"FFF44F"},{name:"Lime",hex:"32CD32"},{name:"Forest Green",hex:"228B22"},{name:"Olive",hex:"808000"},{name:"Mint",hex:"98FF98"},{name:"Teal",hex:"008080"},{name:"Navy",hex:"000080"},{name:"Sky Blue",hex:"87CEEB"},{name:"Royal Blue",hex:"4169E1"},{name:"Cyan",hex:"00FFFF"},{name:"Turquoise",hex:"40E0D0"},{name:"Violet",hex:"EE82EE"},{name:"Magenta",hex:"FF00FF"},{name:"Indigo",hex:"4B0082"},{name:"Lavender",hex:"E6E6FA"},{name:"Plum",hex:"DDA0DD"},{name:"Hot Pink",hex:"FF69B4"},{name:"Rose",hex:"FF007F"},{name:"Blush",hex:"FFB6C1"},{name:"Chocolate",hex:"D2691E"},{name:"Tan",hex:"D2B48C"},{name:"Beige",hex:"F5F5DC"},{name:"Maroon",hex:"800000"},{name:"Dark Gray",hex:"404040"},{name:"Light Gray",hex:"D3D3D3"},{name:"Charcoal",hex:"36454F"},{name:"Ivory",hex:"FFFFF0"},{name:"Bambu Green",hex:"00AE42"},{name:"Jade White",hex:"E8E8E8"},{name:"Titan Gray",hex:"5A5A5A"}],mK=[...Zae,...dJe],Jae="bambuddy-recent-colors",hJe=8,mJe=[{code:"GFL00",name:"Bambu PLA Basic",displayName:"Bambu PLA Basic",isCustom:!1,allCodes:["GFL00"]},{code:"GFL01",name:"Bambu PLA Matte",displayName:"Bambu PLA Matte",isCustom:!1,allCodes:["GFL01"]},{code:"GFL05",name:"Generic PLA",displayName:"Generic PLA",isCustom:!1,allCodes:["GFL05"]},{code:"GFG00",name:"Bambu PETG Basic",displayName:"Bambu PETG Basic",isCustom:!1,allCodes:["GFG00"]},{code:"GFG05",name:"Generic PETG",displayName:"Generic PETG",isCustom:!1,allCodes:["GFG05"]},{code:"GFB00",name:"Bambu ABS Basic",displayName:"Bambu ABS Basic",isCustom:!1,allCodes:["GFB00"]},{code:"GFB05",name:"Generic ABS",displayName:"Generic ABS",isCustom:!1,allCodes:["GFB05"]},{code:"GFA00",name:"Bambu ASA Basic",displayName:"Bambu ASA Basic",isCustom:!1,allCodes:["GFA00"]},{code:"GFU00",name:"Bambu TPU 95A",displayName:"Bambu TPU 95A",isCustom:!1,allCodes:["GFU00"]},{code:"GFU05",name:"Generic TPU",displayName:"Generic TPU",isCustom:!1,allCodes:["GFU05"]},{code:"GFC00",name:"Bambu PC Basic",displayName:"Bambu PC Basic",isCustom:!1,allCodes:["GFC00"]},{code:"GFN00",name:"Bambu PA Basic",displayName:"Bambu PA Basic",isCustom:!1,allCodes:["GFN00"]},{code:"GFN05",name:"Generic PA",displayName:"Generic PA",isCustom:!1,allCodes:["GFN05"]},{code:"GFS00",name:"Bambu PLA-CF",displayName:"Bambu PLA-CF",isCustom:!1,allCodes:["GFS00"]},{code:"GFT00",name:"Bambu PETG-CF",displayName:"Bambu PETG-CF",isCustom:!1,allCodes:["GFT00"]},{code:"GFNC0",name:"Bambu PA-CF",displayName:"Bambu PA-CF",isCustom:!1,allCodes:["GFNC0"]},{code:"GFV00",name:"Bambu PVA",displayName:"Bambu PVA",isCustom:!1,allCodes:["GFV00"]}];function Wk(t){let e=t.replace(/@.*$/,"").trim();e=e.replace(/\(Custom\)/i,"").trim(),e=e.replace(/^[#*]+\s*/,"").trim();const n=["PLA-CF","PETG-CF","ABS-GF","ASA-CF","PA-CF","PAHT-CF","PA6-CF","PA6-GF","PPA-CF","PPA-GF","PET-CF","PPS-CF","PC-CF","PC-ABS","ABS-GF","PETG","PLA","ABS","ASA","PC","PA","TPU","PVA","HIPS","BVOH","PPS","PCTG","PEEK","PEI"];let r="",i=-1;for(const c of n){const u=e.toUpperCase().indexOf(c.toUpperCase());if(u!==-1){r=c,i=u;break}}let s="";i>0&&(s=e.substring(0,i).trim(),s=s.replace(/[-_\s]+$/,""));let o="";i!==-1&&r&&(o=e.substring(i+r.length).trim(),o=o.replace(/^[-_\s]+/,""));let l="";for(const c of y0)if(o.toLowerCase().includes(c.toLowerCase())){l=c;break}if(!l&&s)for(const c of y0){const u=new RegExp(`\\s+${c}$`,"i");if(u.test(s)){l=c,s=s.replace(u,"").trim();break}}return{brand:s,material:r,variant:l}}function fJe(t,e){const n=new Set(uJe);for(const r of t){const{brand:i}=Wk(r.name);i&&i.length>1&&n.add(i)}if(e)for(const r of e)if(r.filament_vendor&&r.filament_vendor.length>1)n.add(r.filament_vendor);else{const{brand:i}=Wk(r.name);i&&i.length>1&&n.add(i)}return Array.from(n).sort((r,i)=>r.localeCompare(i))}function pJe(t){const e=t.filter(r=>r.preset_type==="filament");if(e.length===0)return[];const n=new Map;for(const r of e){const i=r.name.replace(/@.*$/,"").trim(),s=n.get(i);if(s)s.allCodes.push(String(r.id));else{const o=r.filament_type||String(r.id);n.set(i,{code:o,name:i,displayName:i,isCustom:!1,allCodes:[o]})}}return Array.from(n.values()).sort((r,i)=>r.displayName.localeCompare(i.displayName))}function gJe(t,e,n){if(t.length>0){const r=[],i=new Map;for(const s of t)if(s.is_custom){const o=s.name.toUpperCase();(e.size===0||Array.from(e).some(c=>o.includes(c))||!o.includes("@"))&&r.push({code:s.setting_id,name:s.name,displayName:`${s.name} (Custom)`,isCustom:!0,allCodes:[s.setting_id]})}else{const o=s.name.replace(/@.*$/,"").trim(),l=i.get(o);l?l.allCodes.push(s.setting_id):i.set(o,{code:s.setting_id,name:o,displayName:o,isCustom:!1,allCodes:[s.setting_id]})}return[...r,...Array.from(i.values())].sort((s,o)=>s.displayName.localeCompare(o.displayName))}if(n&&n.length>0){const r=pJe(n);if(r.length>0)return r}return mJe}function bJe(t,e){if(!t)return;let n=e.find(r=>r.code===t);if(n||(n=e.find(r=>r.allCodes.includes(t))),!n){const r=t.toLowerCase();n=e.find(i=>i.code.toLowerCase()===r||i.allCodes.some(s=>s.toLowerCase()===r))}return n}function xJe(){try{const t=localStorage.getItem(Jae);if(t)return JSON.parse(t)}catch{}return[]}function yJe(t,e){const n=e.filter(i=>i.hex.toUpperCase()!==t.hex.toUpperCase()),r=[t,...n].slice(0,hJe);try{localStorage.setItem(Jae,JSON.stringify(r))}catch{}return r}function Kj(t,e){if(!e.material)return!1;const r=(t.name||"").replace(/^High Flow[_\s]+/i,"").replace(/^Standard[_\s]+/i,"").replace(/^HF[_\s]+/i,"").replace(/^S[_\s]+/i,"").trim(),i=Wk(r);return!(!(i.material.toUpperCase()===e.material.toUpperCase())||e.brand&&!(i.brand.toLowerCase().includes(e.brand.toLowerCase())||e.brand.toLowerCase().includes(i.brand.toLowerCase()))||e.subtype&&!(i.variant.toLowerCase().includes(e.subtype.toLowerCase())||e.subtype.toLowerCase().includes(i.variant.toLowerCase())||r.toLowerCase().includes(e.subtype.toLowerCase())))}function vJe({formData:t,updateField:e,cloudAuthenticated:n,loadingCloudPresets:r,presetInputValue:i,setPresetInputValue:s,selectedPresetOption:o,filamentOptions:l,availableBrands:c}){const{t:u}=Vt(),[d,h]=w.useState(!1),[f,p]=w.useState(!1),[x,y]=w.useState(!1),[b,v]=w.useState(""),[S,N]=w.useState(""),A=w.useRef(null),C=w.useRef(null),T=w.useRef(null);w.useEffect(()=>{const U=O=>{A.current&&!A.current.contains(O.target)&&h(!1),C.current&&!C.current.contains(O.target)&&p(!1),T.current&&!T.current.contains(O.target)&&y(!1)};return document.addEventListener("mousedown",U),()=>document.removeEventListener("mousedown",U)},[]);const k=w.useMemo(()=>{if(!i)return l;const U=i.toLowerCase();return l.filter(O=>O.displayName.toLowerCase().includes(U)||O.code.toLowerCase().includes(U))},[l,i]),j=w.useMemo(()=>{if(!b)return c;const U=b.toLowerCase();return c.filter(O=>O.toLowerCase().includes(U))},[c,b]),E=w.useMemo(()=>{if(!S)return y0;const U=S.toLowerCase();return y0.filter(O=>O.toLowerCase().includes(U))},[S]),P=U=>{e("slicer_filament",U.code),s(U.displayName),h(!1);const O=Wk(U.name);O.material&&e("material",O.material),O.brand&&e("brand",O.brand),O.variant&&e("subtype",O.variant)};return a.jsxs("div",{className:"space-y-4",children:[a.jsx("div",{className:"flex items-center gap-2 text-xs text-bambu-gray",children:r?a.jsxs(a.Fragment,{children:[a.jsx(it,{className:"w-3 h-3 animate-spin"})," ",u("inventory.loadingPresets")]}):n?a.jsxs(a.Fragment,{children:[a.jsx(Gb,{className:"w-3 h-3 text-bambu-green"})," ",u("inventory.cloudConnected")]}):a.jsxs(a.Fragment,{children:[a.jsx(hhe,{className:"w-3 h-3"})," ",u("inventory.cloudNotConnected")]})}),a.jsxs("div",{children:[a.jsxs("label",{className:"block text-sm font-medium text-bambu-gray mb-1",children:[u("inventory.slicerPreset")," *"]}),a.jsxs("div",{className:"relative",ref:A,children:[a.jsx(Or,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray/50 pointer-events-none"}),a.jsx("input",{type:"text",className:"w-full pl-9 pr-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white text-sm placeholder:text-bambu-gray/50 focus:outline-none focus:border-bambu-green",placeholder:u("inventory.searchPresets"),value:i,onChange:U=>{s(U.target.value),h(!0)},onFocus:()=>{h(!0),s("")}}),d&&a.jsx("div",{className:"absolute z-50 w-full mt-1 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg shadow-lg max-h-64 overflow-y-auto",children:k.length===0?a.jsx("div",{className:"px-3 py-2 text-sm text-bambu-gray",children:u("inventory.noPresetsFound")}):k.map(U=>a.jsxs("button",{type:"button",className:`w-full px-3 py-2 text-left text-sm hover:bg-bambu-dark-tertiary flex justify-between items-center ${o?.code===U.code?"bg-bambu-green/10 text-bambu-green":"text-white"}`,onClick:()=>P(U),children:[a.jsx("span",{className:"truncate",children:U.displayName}),a.jsx("span",{className:"font-mono text-xs text-bambu-gray ml-2 shrink-0",children:U.code})]},U.code))})]}),o&&a.jsxs("div",{className:"mt-1 text-xs text-bambu-gray",children:[u("inventory.selectedPreset"),": ",a.jsx("span",{className:"font-mono text-bambu-green",children:o.code})]})]}),a.jsxs("div",{children:[a.jsxs("label",{className:"block text-sm font-medium text-bambu-gray mb-1",children:[u("inventory.material")," *"]}),a.jsxs("select",{value:t.material,onChange:U=>e("material",U.target.value),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white text-sm focus:outline-none focus:border-bambu-green",children:[a.jsx("option",{value:"",children:u("inventory.selectMaterial")}),cJe.map(U=>a.jsx("option",{value:U,children:U},U))]})]}),a.jsxs("div",{children:[a.jsxs("label",{className:"block text-sm font-medium text-bambu-gray mb-1",children:[u("inventory.brand")," *"]}),a.jsxs("div",{className:"relative",ref:C,children:[a.jsx("input",{type:"text",className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white text-sm placeholder:text-bambu-gray/50 focus:outline-none focus:border-bambu-green",placeholder:u("inventory.searchBrand"),value:f?b:t.brand,onChange:U=>{v(U.target.value),p(!0)},onFocus:()=>{p(!0),v("")}}),a.jsx(nr,{className:"absolute right-3 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray/50 pointer-events-none"}),f&&a.jsxs("div",{className:"absolute z-50 w-full mt-1 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg shadow-lg max-h-48 overflow-y-auto",children:[j.length===0?a.jsx("div",{className:"px-3 py-2 text-sm text-bambu-gray",children:u("inventory.noResults")}):j.map(U=>a.jsx("button",{type:"button",className:`w-full px-3 py-2 text-left text-sm hover:bg-bambu-dark-tertiary ${t.brand===U?"bg-bambu-green/10 text-bambu-green":"text-white"}`,onClick:()=>{e("brand",U),p(!1),v("")},children:U},U)),b&&!j.includes(b)&&a.jsx("button",{type:"button",className:"w-full px-3 py-2 text-left text-sm hover:bg-bambu-dark-tertiary text-bambu-green border-t border-bambu-dark-tertiary",onClick:()=>{e("brand",b),p(!1),v("")},children:u("inventory.useCustomBrand",{brand:b})})]})]})]}),a.jsxs("div",{children:[a.jsxs("label",{className:"block text-sm font-medium text-bambu-gray mb-1",children:[u("inventory.subtype")," *"]}),a.jsxs("div",{className:"relative",ref:T,children:[a.jsx("input",{type:"text",value:x?S:t.subtype,onChange:U=>{N(U.target.value),y(!0)},onFocus:()=>{y(!0),N("")},placeholder:"Basic, Matte, Silk...",className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white text-sm placeholder:text-bambu-gray/50 focus:outline-none focus:border-bambu-green"}),a.jsx(nr,{className:"absolute right-3 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray/50 pointer-events-none"}),x&&a.jsxs("div",{className:"absolute z-50 w-full mt-1 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg shadow-lg max-h-48 overflow-y-auto",children:[E.length===0?a.jsx("div",{className:"px-3 py-2 text-sm text-bambu-gray",children:u("inventory.noResults")}):E.map(U=>a.jsx("button",{type:"button",className:`w-full px-3 py-2 text-left text-sm hover:bg-bambu-dark-tertiary ${t.subtype===U?"bg-bambu-green/10 text-bambu-green":"text-white"}`,onClick:()=>{e("subtype",U),y(!1),N("")},children:U},U)),S&&!y0.some(U=>U.toLowerCase()===S.toLowerCase().trim())&&a.jsx("button",{type:"button",className:"w-full px-3 py-2 text-left text-sm hover:bg-bambu-dark-tertiary text-bambu-green border-t border-bambu-dark-tertiary",onClick:()=>{e("subtype",S),y(!1),N("")},children:u("inventory.useCustomBrand",{brand:S})})]})]})]}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm font-medium text-bambu-gray mb-1",children:u("inventory.labelWeight")}),a.jsxs("div",{className:"relative",children:[a.jsx("input",{type:"number",value:t.label_weight,onChange:U=>e("label_weight",parseInt(U.target.value)||0),className:"w-full px-3 py-2 pr-7 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white text-sm focus:outline-none focus:border-bambu-green"}),a.jsx("span",{className:"absolute right-2 top-1/2 -translate-y-1/2 text-xs text-bambu-gray",children:"g"})]})]})]})}function wJe({formData:t,updateField:e,recentColors:n,onColorUsed:r,catalogColors:i}){const{t:s}=Vt(),[o,l]=w.useState(!1),[c,u]=w.useState(""),d=t.rgba.replace("#","").substring(0,6),h=v=>d.toUpperCase()===v.toUpperCase(),f=(v,S)=>{e("rgba",v.toUpperCase()+"FF"),e("color_name",S),r({name:S,hex:v})},p=w.useMemo(()=>{if(i.length===0)return[];const v=t.brand?.trim(),S=t.material?.toLowerCase().trim(),N=t.subtype?.toLowerCase().trim();if(!v&&!S)return[];const A=v?v.toLowerCase().split(/[\s\-_]+/).filter(k=>k.length>=2):[],C=k=>{if(A.length===0)return!0;const j=k.toLowerCase();return A.some(E=>j.includes(E))},T=S&&N?`${S} ${N}`:"";if(T){const k=i.filter(E=>C(E.manufacturer)&&E.material?.toLowerCase()===T);if(k.length>0)return k.map(E=>({name:E.color_name,hex:E.hex_color.replace("#","").substring(0,6)}));const j=T.replace(/\+$/,"");if(j!==T){const E=i.filter(P=>C(P.manufacturer)&&P.material?.toLowerCase()===j);if(E.length>0)return E.map(P=>({name:P.color_name,hex:P.hex_color.replace("#","").substring(0,6)}))}}if(S){const k=i.filter(j=>C(j.manufacturer)&&(!j.material||j.material.toLowerCase().startsWith(S)));if(k.length>0)return k.map(j=>({name:j.color_name,hex:j.hex_color.replace("#","").substring(0,6)}))}return[]},[i,t.brand,t.material,t.subtype]),x=p.length>0,y=w.useMemo(()=>{if(!c)return p;const v=c.toLowerCase();return p.filter(S=>S.name.toLowerCase().includes(v))},[p,c]),b=w.useMemo(()=>c?mK.filter(v=>v.name.toLowerCase().includes(c.toLowerCase())):o?mK:Zae,[c,o]);return a.jsxs("div",{className:"space-y-3",children:[a.jsx("div",{className:"h-10 rounded-lg border border-bambu-dark-tertiary",style:{backgroundColor:`#${d}`}}),n.length>0&&a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsxs("div",{className:"flex items-center gap-1.5 text-xs text-bambu-gray shrink-0",children:[a.jsx(Wn,{className:"w-3 h-3"}),a.jsx("span",{children:s("inventory.recentColors")})]}),a.jsx("div",{className:"flex flex-wrap gap-1.5",children:n.map(v=>a.jsx("button",{type:"button",onClick:()=>f(v.hex,v.name),className:`w-6 h-6 rounded border-2 transition-all hover:scale-110 ${h(v.hex)?"border-bambu-green ring-1 ring-bambu-green/30 scale-110":"border-bambu-dark-tertiary"}`,style:{backgroundColor:`#${v.hex}`},title:v.name},v.hex))})]}),a.jsxs("div",{className:"relative",children:[a.jsx(Or,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray/50 pointer-events-none"}),a.jsx("input",{type:"text",className:"w-full pl-9 pr-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white text-sm placeholder:text-bambu-gray/50 focus:outline-none focus:border-bambu-green",placeholder:s("inventory.searchColors"),value:c,onChange:v=>u(v.target.value)})]}),x?a.jsxs("div",{className:"space-y-1.5",children:[a.jsx("span",{className:"text-xs text-bambu-gray",children:c?s("inventory.searchResults"):`${t.brand}${t.material?` ${t.material}`:""}`}),a.jsxs("div",{className:"flex flex-wrap gap-1.5",children:[y.map(v=>a.jsx("button",{type:"button",onClick:()=>f(v.hex,v.name),className:`w-6 h-6 rounded border-2 transition-all hover:scale-110 hover:z-20 relative group ${h(v.hex)?"border-bambu-green ring-1 ring-bambu-green/30 scale-110":"border-bambu-dark-tertiary"}`,style:{backgroundColor:`#${v.hex}`},title:v.name,children:a.jsx("span",{className:"absolute -bottom-7 left-1/2 -translate-x-1/2 px-2 py-0.5 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded text-xs whitespace-nowrap opacity-0 group-hover:opacity-100 transition-opacity pointer-events-none z-20 shadow-lg text-white",children:v.name})},`${v.hex}-${v.name}`)),y.length===0&&a.jsx("p",{className:"text-sm text-bambu-gray py-1",children:s("inventory.noColorsFound")})]})]}):a.jsxs("div",{className:"space-y-1.5",children:[a.jsxs("div",{className:"flex items-center justify-between text-xs text-bambu-gray",children:[a.jsx("span",{children:s(c?"inventory.searchResults":o?"inventory.allColors":"inventory.commonColors")}),!c&&a.jsx("button",{type:"button",onClick:()=>l(!o),className:"flex items-center gap-1 hover:text-white transition-colors",children:o?a.jsxs(a.Fragment,{children:[s("inventory.showLess")," ",a.jsx(Wl,{className:"w-3 h-3"})]}):a.jsxs(a.Fragment,{children:[s("inventory.showAll")," ",a.jsx(nr,{className:"w-3 h-3"})]})})]}),a.jsxs("div",{className:"flex flex-wrap gap-1.5",children:[b.map(v=>a.jsx("button",{type:"button",onClick:()=>f(v.hex,v.name),className:`w-6 h-6 rounded border-2 transition-all hover:scale-110 hover:z-20 relative group ${h(v.hex)?"border-bambu-green ring-1 ring-bambu-green/30 scale-110":"border-bambu-dark-tertiary"}`,style:{backgroundColor:`#${v.hex}`},title:v.name,children:a.jsx("span",{className:"absolute -bottom-7 left-1/2 -translate-x-1/2 px-2 py-0.5 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded text-xs whitespace-nowrap opacity-0 group-hover:opacity-100 transition-opacity pointer-events-none z-20 shadow-lg text-white",children:v.name})},v.hex)),b.length===0&&a.jsx("p",{className:"text-sm text-bambu-gray py-1",children:s("inventory.noColorsFound")})]})]}),a.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm font-medium text-bambu-gray mb-1",children:s("inventory.colorName")}),a.jsx("input",{type:"text",className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white text-sm placeholder:text-bambu-gray/50 focus:outline-none focus:border-bambu-green",placeholder:s("inventory.colorNamePlaceholder"),value:t.color_name,onChange:v=>e("color_name",v.target.value)})]}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm font-medium text-bambu-gray mb-1",children:s("inventory.hexColor")}),a.jsxs("div",{className:"flex gap-2",children:[a.jsxs("div",{className:"relative flex-1",children:[a.jsx("span",{className:"absolute left-3 top-1/2 -translate-y-1/2 text-bambu-gray",children:"#"}),a.jsx("input",{type:"text",className:"w-full pl-7 pr-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white text-sm font-mono uppercase focus:outline-none focus:border-bambu-green",placeholder:"RRGGBB",value:d.toUpperCase(),onChange:v=>{const S=v.target.value.replace("#","").replace(/[^0-9A-Fa-f]/g,"");S.length<=8&&e("rgba",S.toUpperCase()+(S.length<=6?"FF":""))}})]}),a.jsx("input",{type:"color",className:"w-11 h-[38px] rounded-lg cursor-pointer border border-bambu-dark-tertiary shrink-0 bg-transparent",value:`#${d}`,onChange:v=>{const S=v.target.value.replace("#","").toUpperCase();e("rgba",S+"FF")},title:s("inventory.pickColor")})]})]})]})]})}function _Je({catalog:t,value:e,onChange:n,catalogId:r,onCatalogIdChange:i}){const{t:s}=Vt(),[o,l]=w.useState(!1),[c,u]=w.useState(""),d=w.useRef(null),h=w.useRef(null);w.useEffect(()=>{const y=b=>{d.current&&!d.current.contains(b.target)&&l(!1)};return document.addEventListener("mousedown",y),()=>document.removeEventListener("mousedown",y)},[]),w.useEffect(()=>{if(t.length===0)return;const y=t.filter(b=>b.weight===e);if(r){const b=t.find(v=>v.id===r);if(b&&b.weight===e)return}y.length===1?i(y[0].id):y.length===0&&r!==null&&i(null)},[e,t,r,i]);const f=w.useMemo(()=>{if(!c)return t;const y=c.toLowerCase();return t.filter(b=>b.name.toLowerCase().includes(y)||b.weight.toString().includes(y))},[t,c]),p=w.useMemo(()=>t.filter(y=>y.weight===e),[t,e]),x=w.useMemo(()=>{if(o)return c;if(r){const y=t.find(b=>b.id===r);if(y)return y.name}return p.length>0?p[0].name:""},[o,c,r,t,p]);return a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm font-medium text-bambu-gray mb-1",children:a.jsxs("span",{className:"flex items-center gap-2",children:[a.jsx(jfe,{className:"w-3.5 h-3.5 text-bambu-gray"}),s("inventory.coreWeight")]})}),a.jsxs("div",{className:"flex gap-2 items-center",children:[a.jsxs("div",{className:"flex-1 min-w-0 relative",ref:d,children:[a.jsx("input",{ref:h,type:"text",className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white text-sm placeholder:text-bambu-gray/50 focus:outline-none focus:border-bambu-green",placeholder:s("inventory.searchSpoolWeight"),value:x,onFocus:()=>{l(!0),u("")},onChange:y=>{u(y.target.value),l(!0)}}),o&&a.jsx("div",{className:"absolute z-50 w-full mt-1 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg shadow-lg max-h-64 overflow-y-auto",children:f.length===0?a.jsx("div",{className:"px-3 py-2 text-sm text-bambu-gray",children:s("inventory.noResults")}):f.map(y=>a.jsxs("button",{type:"button",className:`w-full px-3 py-2 text-left text-sm hover:bg-bambu-dark-tertiary flex justify-between items-center ${(r?y.id===r:y.weight===e)?"bg-bambu-green/10 text-bambu-green":"text-white"}`,onClick:()=>{i(y.id),n(y.weight),l(!1),u("")},children:[a.jsx("span",{className:"truncate",children:y.name}),a.jsxs("span",{className:"font-mono text-xs text-bambu-gray ml-2 shrink-0",children:[y.weight,"g"]})]},y.id))})]}),a.jsxs("div",{className:"flex items-center gap-1 shrink-0",children:[a.jsx("input",{type:"number",className:"w-16 px-2 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white text-sm text-center font-mono focus:outline-none focus:border-bambu-green",value:e,min:0,max:2e3,onChange:y=>{const b=parseInt(y.target.value);!isNaN(b)&&b>=0&&n(b)}}),a.jsx("span",{className:"text-bambu-gray text-sm",children:"g"})]})]})]})}function SJe({formData:t,updateField:e,spoolCatalog:n}){const{t:r}=Vt(),{showToast:i}=hn(),[s,o]=w.useState(""),[l,c]=w.useState(!1),u=Math.max(0,t.label_weight-t.weight_used),d=t.core_weight+u;return w.useEffect(()=>{l||o(String(d))},[l,d]),a.jsxs("div",{className:"space-y-4",children:[a.jsx(_Je,{catalog:n,value:t.core_weight,onChange:h=>e("core_weight",h),catalogId:t.core_weight_catalog_id,onCatalogIdChange:h=>e("core_weight_catalog_id",h)}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm font-medium text-bambu-gray mb-1",children:r("inventory.currentWeight")}),a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsxs("div",{className:"relative flex-1",children:[a.jsx("input",{type:"number",value:u,min:0,max:t.label_weight,onChange:h=>{const f=parseInt(h.target.value)||0;e("weight_used",Math.max(0,t.label_weight-f))},className:"w-full px-3 py-2 pr-7 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white text-sm focus:outline-none focus:border-bambu-green"}),a.jsx("span",{className:"absolute right-2 top-1/2 -translate-y-1/2 text-xs text-bambu-gray",children:"g"})]}),a.jsxs("span",{className:"text-xs text-bambu-gray shrink-0",children:["/ ",t.label_weight,"g"]})]})]}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm font-medium text-bambu-gray mb-1",children:r("inventory.measuredWeight")}),a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsxs("div",{className:"relative flex-1",children:[a.jsx("input",{type:"number",value:s,min:0,onFocus:()=>c(!0),onChange:h=>{o(h.target.value)},onBlur:()=>{c(!1);const h=s.trim(),f=Number(h),p=t.core_weight,x=t.core_weight+t.label_weight;if(!h||!Number.isFinite(f)||fx){i(r("inventory.measuredWeightError",{min:p,max:x}),"error"),o(String(d));return}const y=Math.round(f),b=Math.max(0,Math.min(t.label_weight,y-t.core_weight));e("weight_used",Math.max(0,t.label_weight-b)),o(String(y))},className:"w-full px-3 py-2 pr-7 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white text-sm focus:outline-none focus:border-bambu-green"}),a.jsx("span",{className:"absolute right-2 top-1/2 -translate-y-1/2 text-xs text-bambu-gray",children:"g"})]}),a.jsxs("span",{className:"text-xs text-bambu-gray shrink-0",children:["/ ",t.core_weight+t.label_weight,"g"]})]})]}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm font-medium text-bambu-gray mb-1",children:r("inventory.note")}),a.jsx("textarea",{className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white text-sm placeholder:text-bambu-gray/50 focus:outline-none focus:border-bambu-green resize-none min-h-[80px]",placeholder:r("inventory.notePlaceholder"),value:t.note,onChange:h=>e("note",h.target.value)})]})]})}function NJe({formData:t,printersWithCalibrations:e,selectedProfiles:n,setSelectedProfiles:r,expandedPrinters:i,setExpandedPrinters:s}){const{t:o}=Vt(),l=f=>{s(p=>{const x=new Set(p);return x.has(f)?x.delete(f):x.add(f),x})},c=(f,p,x)=>{const y=`${f}:${p}:${x??"null"}`,b=`${f}:${x??"null"}`;r(v=>{const S=new Set(v);if(S.has(y))S.delete(y);else{for(const N of Array.from(S)){const A=N.split(":");`${A[0]}:${A[2]}`===b&&S.delete(N)}S.add(y)}return S})},u=()=>{const f=new Set;for(const{printer:p,calibrations:x}of e){if(!p.connected)continue;const y=x.filter(v=>Kj(v,t)),b=new Map;for(const v of y){const S=`${v.extruder_id??"null"}`;b.has(S)||b.set(S,[]),b.get(S).push(v)}for(const[v,S]of b)if(S.length>0){const A=[...S].sort((C,T)=>T.k_value-C.k_value)[0];f.add(`${p.id}:${A.cali_idx}:${v}`)}}r(f)};if(!t.material)return a.jsx("div",{className:"p-6 bg-bambu-dark rounded-lg text-center",children:a.jsx("p",{className:"text-bambu-gray",children:o("inventory.selectMaterialFirst")})});if(e.length===0)return a.jsx("div",{className:"p-6 bg-bambu-dark rounded-lg text-center",children:a.jsx("p",{className:"text-bambu-gray",children:o("inventory.noPrintersConfigured")})});const d=e.reduce((f,{printer:p,calibrations:x})=>p.connected?f+x.filter(y=>Kj(y,t)).length:f,0),h=(f,p)=>{const x=`${f.id}:${p.cali_idx}:${p.extruder_id??"null"}`,y=n.has(x);return a.jsxs("label",{className:`flex items-center gap-3 p-3 rounded-lg cursor-pointer transition-all border ${y?"bg-bambu-green/10 border-bambu-green/30":"bg-bambu-dark border-transparent hover:bg-bambu-dark/80"}`,children:[a.jsx("input",{type:"checkbox",checked:y,onChange:()=>c(String(f.id),p.cali_idx,p.extruder_id),className:"w-4 h-4 rounded border-bambu-dark-tertiary text-bambu-green focus:ring-bambu-green"}),a.jsx("div",{className:"flex-1 min-w-0",children:a.jsx("span",{className:`text-sm font-medium ${y?"text-bambu-green":"text-white"}`,children:p.name||p.filament_id})}),a.jsx("div",{className:"flex items-center gap-2 shrink-0",children:a.jsxs("span",{className:"text-xs font-mono px-2 py-0.5 rounded bg-bambu-dark text-bambu-gray",children:["K=",p.k_value.toFixed(3)]})})]},`${p.cali_idx}-${p.extruder_id}`)};return a.jsxs("div",{className:"space-y-4",children:[a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsxs("p",{className:"text-xs text-bambu-gray",children:[o("inventory.matchingFilter"),": ",t.brand||o("inventory.anyBrand")," / ",t.material," / ",t.subtype||o("inventory.anyVariant")]}),d>0&&a.jsxs("button",{type:"button",onClick:u,className:"flex items-center gap-1.5 px-2 py-1 text-xs bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-bambu-gray hover:text-white hover:border-bambu-green transition-colors",children:[a.jsx(pb,{className:"w-3.5 h-3.5"}),o("inventory.autoSelect")," (",d,")"]})]}),a.jsx("div",{className:"space-y-3",children:e.map(({printer:f,calibrations:p})=>{const x=i.has(String(f.id)),y=p.filter(A=>Kj(A,t)),b=y.length,v=y.some(A=>A.extruder_id!==void 0&&A.extruder_id!==null&&A.extruder_id>0),S=y.filter(A=>A.extruder_id===1),N=y.filter(A=>A.extruder_id===0||A.extruder_id===void 0||A.extruder_id===null);return a.jsxs("div",{className:"border border-bambu-dark-tertiary rounded-lg overflow-hidden",children:[a.jsxs("button",{type:"button",onClick:()=>l(String(f.id)),className:"w-full px-4 py-3 flex items-center justify-between bg-bambu-dark-secondary hover:bg-bambu-dark-tertiary transition-colors",children:[a.jsxs("div",{className:"flex items-center gap-3",children:[x?a.jsx(nr,{className:"w-4 h-4 text-bambu-gray"}):a.jsx(pa,{className:"w-4 h-4 text-bambu-gray"}),a.jsx("span",{className:"font-medium text-white",children:f.name}),b>0?a.jsxs("span",{className:"text-xs px-2 py-0.5 rounded-full bg-bambu-green/20 text-bambu-green",children:[b," ",o(b!==1?"inventory.matches":"inventory.match")]}):a.jsx("span",{className:"text-xs px-2 py-0.5 rounded-full bg-bambu-dark-tertiary text-bambu-gray",children:o("inventory.noMatches")})]}),a.jsx("span",{className:`text-xs px-2 py-1 rounded-full ${f.connected?"bg-green-500/20 text-green-500":"bg-bambu-gray/20 text-bambu-gray"}`,children:f.connected?o("inventory.connected"):o("inventory.offline")})]}),x&&a.jsx("div",{className:"px-4 py-3 space-y-3 bg-bambu-dark border-t border-bambu-dark-tertiary",children:f.connected?b===0?a.jsx("p",{className:"text-sm text-bambu-gray italic py-2",children:o("inventory.noKProfilesMatch")}):v?a.jsxs(a.Fragment,{children:[S.length>0&&a.jsxs("div",{className:"space-y-2",children:[a.jsx("p",{className:"text-xs font-medium text-bambu-gray uppercase tracking-wide",children:o("inventory.leftNozzle")}),a.jsx("div",{className:"space-y-2",children:S.map(A=>h(f,A))})]}),N.length>0&&a.jsxs("div",{className:"space-y-2",children:[a.jsx("p",{className:"text-xs font-medium text-bambu-gray uppercase tracking-wide",children:o("inventory.rightNozzle")}),a.jsx("div",{className:"space-y-2",children:N.map(A=>h(f,A))})]})]}):a.jsx("div",{className:"space-y-2",children:y.map(A=>h(f,A))}):a.jsx("p",{className:"text-sm text-bambu-gray italic py-2",children:o("inventory.printerOffline")})})]},f.id)})}),n.size>0&&a.jsx("div",{className:"p-3 bg-bambu-green/10 border border-bambu-green/30 rounded-lg",children:a.jsxs("p",{className:"text-sm text-white",children:[a.jsx("span",{className:"font-semibold",children:n.size})," ",o("inventory.profilesSelected")]})})]})}function kJe(t){const e=new Date(t);return e.toLocaleDateString("en-GB",{day:"2-digit",month:"2-digit",year:"2-digit"})+" "+e.toLocaleTimeString("en-GB",{hour:"2-digit",minute:"2-digit"})}const CJe={completed:"text-bambu-green",failed:"text-red-400",aborted:"text-yellow-400"};function MJe({spoolId:t}){const{t:e}=Vt(),n=tn(),{showToast:r}=hn(),{data:i,isLoading:s}=Ze({queryKey:["spool-usage",t],queryFn:()=>re.getSpoolUsageHistory(t)}),o=ot({mutationFn:()=>re.clearSpoolUsageHistory(t),onSuccess:()=>{n.invalidateQueries({queryKey:["spool-usage",t]}),r(e("inventory.historyCleared"),"success")}});return s?a.jsx("div",{className:"flex justify-center py-4",children:a.jsx(it,{className:"w-5 h-5 animate-spin text-bambu-green"})}):!i||i.length===0?a.jsxs("div",{className:"text-center py-4 text-bambu-gray text-sm",children:[a.jsx(Wn,{className:"w-5 h-5 mx-auto mb-2 opacity-50"}),e("inventory.noUsageHistory")]}):a.jsxs("div",{className:"space-y-2",children:[a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsx("h4",{className:"text-sm font-medium text-white",children:e("inventory.usageHistory")}),a.jsxs(Ce,{variant:"ghost",size:"sm",onClick:()=>o.mutate(),disabled:o.isPending,className:"text-xs text-bambu-gray hover:text-red-400",children:[a.jsx(Jt,{className:"w-3 h-3 mr-1"}),e("inventory.clearHistory")]})]}),a.jsx("div",{className:"max-h-48 overflow-y-auto space-y-1",children:i.map(l=>a.jsxs("div",{className:"flex items-center justify-between p-2 rounded bg-bambu-dark/50 text-xs",children:[a.jsxs("div",{className:"flex-1 min-w-0",children:[a.jsx("span",{className:"text-bambu-gray",children:kJe(l.created_at)}),l.print_name&&a.jsx("span",{className:"text-white ml-2 truncate",title:l.print_name,children:l.print_name})]}),a.jsxs("div",{className:"flex items-center gap-2 flex-shrink-0 ml-2",children:[a.jsxs("span",{className:"text-white font-medium",children:[l.weight_used.toFixed(1),"g"]}),a.jsxs("span",{className:"text-bambu-gray",children:["(",l.percent_used,"%)"]}),a.jsx("span",{className:CJe[l.status]||"text-bambu-gray",children:l.status})]})]},l.id))})]})}function AJe({isOpen:t,onClose:e,spool:n,printersWithCalibrations:r=[]}){const{t:i}=Vt(),s=tn(),{showToast:o}=hn(),l=!!n,[c,u]=w.useState(hK),[d,h]=w.useState({}),[f,p]=w.useState("filament"),[x,y]=w.useState(!1),[b,v]=w.useState(!1),[S,N]=w.useState(!1),[A,C]=w.useState([]),[T,k]=w.useState(""),[j,E]=w.useState([]),[P,U]=w.useState([]),[O,B]=w.useState([]),[R,G]=w.useState([]),[q,z]=w.useState([]),[K,Y]=w.useState(new Set),[oe,$]=w.useState(new Set),X=r.length>0?r:q,ee=w.useMemo(()=>K.size,[K]);w.useEffect(()=>{G(xJe())},[]),w.useEffect(()=>{t&&((async()=>{N(!0);try{const W=await re.getCloudStatus();if(v(W.is_authenticated),W.is_authenticated){const ue=await re.getFilamentPresets();C(ue)}}catch(W){console.error("Failed to fetch cloud presets:",W),v(!1)}finally{N(!1)}})(),re.getSpoolCatalog().then(E).catch(console.error),re.getColorCatalog().then(B).catch(console.error),re.getLocalPresets().then(W=>U(W.filament)).catch(console.error),r.length===0&&(async()=>{try{const W=await re.getPrinters(),ue=await Promise.all(W.map(se=>re.getPrinterStatus(se.id).catch(()=>null))),Q=[];for(let se=0;se({cali_idx:D.slot_id,filament_id:D.filament_id,setting_id:D.setting_id||"",name:D.name,k_value:parseFloat(D.k_value)||0,n_coef:parseFloat(D.n_coef)||0,extruder_id:D.extruder_id,nozzle_diameter:D.nozzle_diameter}))}catch{}Q.push({printer:{...Z,connected:ve},calibrations:fe})}z(Q)}catch(W){console.error("Failed to fetch printer calibrations:",W)}})())},[t,r.length]);const J=w.useMemo(()=>gJe(A,new Set,P),[A,P]),_e=w.useMemo(()=>fJe(A,P),[A,P]),pe=w.useMemo(()=>bJe(c.slicer_filament,J),[c.slicer_filament,J]);w.useEffect(()=>{if(t){if(n)if(u({material:n.material||"",subtype:n.subtype||"",brand:n.brand||"",color_name:n.color_name||"",rgba:n.rgba||"808080FF",label_weight:n.label_weight||1e3,core_weight:n.core_weight||250,core_weight_catalog_id:n.core_weight_catalog_id??null,weight_used:n.weight_used||0,slicer_filament:n.slicer_filament||"",note:n.note||""}),k(n.slicer_filament_name||n.slicer_filament||""),n.k_profiles&&n.k_profiles.length>0){const V=new Set;for(const W of n.k_profiles)W.cali_idx!==null&&W.cali_idx!==void 0&&V.add(`${W.printer_id}:${W.cali_idx}:${W.extruder??"null"}`);Y(V)}else Y(new Set);else u(hK),k(""),Y(new Set);h({}),p("filament"),y(!1)}},[t,n]),w.useEffect(()=>{t&&X.length>0&&$(new Set(X.map(V=>String(V.printer.id))))},[t,X]);const me=(V,W)=>{u(ue=>({...ue,[V]:W})),V==="weight_used"&&y(!0),d[V]&&h(ue=>({...ue,[V]:void 0}))},je=V=>{G(W=>yJe(V,W))},de=ot({mutationFn:V=>re.createSpool(V),onSuccess:async V=>{K.size>0&&V?.id&&await Se(V.id),await s.invalidateQueries({queryKey:["inventory-spools"]}),o(i("inventory.spoolCreated"),"success"),e()},onError:V=>{o(V.message,"error")}}),ce=ot({mutationFn:V=>re.updateSpool(n.id,V),onSuccess:async()=>{n?.id&&await Se(n.id),await s.invalidateQueries({queryKey:["inventory-spools"]}),o(i("inventory.spoolUpdated"),"success"),e()},onError:V=>{o(V.message,"error")}}),Se=async V=>{if(K.size===0){try{await re.saveSpoolKProfiles(V,[])}catch{}return}const W=[];for(const ue of K){const[Q,se,Z]=ue.split(":"),Ne=parseInt(Q),ve=parseInt(se),fe=Z==="null"?0:parseInt(Z),L=X.find(D=>D.printer.id===Ne);if(L){const D=L.calibrations.find(H=>H.cali_idx===ve);D&&W.push({printer_id:Ne,extruder:fe,nozzle_diameter:D.nozzle_diameter||"0.4",k_value:D.k_value,name:D.name||null,cali_idx:D.cali_idx,setting_id:D.setting_id||null})}}if(W.length>0)try{await re.saveSpoolKProfiles(V,W)}catch(ue){console.error("Failed to save K-profiles:",ue)}};if(w.useEffect(()=>{if(!t)return;const V=W=>{W.key==="Escape"&&e()};return document.addEventListener("keydown",V),()=>document.removeEventListener("keydown",V)},[t,e]),!t)return null;const ie=()=>{const V=lJe(c);if(!V.isValid){h(V.errors),(V.errors.slicer_filament||V.errors.material||V.errors.brand||V.errors.subtype)&&p("filament");return}const W=pe?.displayName||T||null,ue={material:c.material,subtype:c.subtype||null,brand:c.brand||null,color_name:c.color_name||null,rgba:c.rgba||null,label_weight:c.label_weight,core_weight:c.core_weight,core_weight_catalog_id:c.core_weight_catalog_id,slicer_filament:c.slicer_filament||null,slicer_filament_name:W,nozzle_temp_min:null,nozzle_temp_max:null,note:c.note||null};(!l||x)&&(ue.weight_used=c.weight_used),l?ce.mutate(ue):de.mutate(ue)},Fe=de.isPending||ce.isPending;return a.jsxs("div",{className:"fixed inset-0 z-50 flex items-center justify-center",children:[a.jsx("div",{className:"absolute inset-0 bg-black/60 backdrop-blur-sm",onClick:e}),a.jsxs("div",{className:"relative w-full max-w-lg mx-4 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-xl shadow-2xl max-h-[90vh] flex flex-col",children:[a.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-bambu-dark-tertiary flex-shrink-0",children:[a.jsx("h2",{className:"text-lg font-semibold text-white",children:i(l?"inventory.editSpool":"inventory.addSpool")}),a.jsx("button",{onClick:e,className:"p-1 text-bambu-gray hover:text-white rounded transition-colors",children:a.jsx(Ft,{className:"w-5 h-5"})})]}),a.jsxs("div",{className:"flex border-b border-bambu-dark-tertiary flex-shrink-0",children:[a.jsxs("button",{onClick:()=>p("filament"),className:`flex-1 px-4 py-2.5 text-sm font-medium flex items-center justify-center gap-2 transition-colors ${f==="filament"?"text-bambu-green border-b-2 border-bambu-green":"text-bambu-gray hover:text-white"}`,children:[a.jsx(aC,{className:"w-4 h-4"}),i("inventory.filamentInfoTab")]}),a.jsxs("button",{onClick:()=>p("pa-profile"),className:`flex-1 px-4 py-2.5 text-sm font-medium flex items-center justify-center gap-2 transition-colors ${f==="pa-profile"?"text-bambu-green border-b-2 border-bambu-green":"text-bambu-gray hover:text-white"}`,children:[a.jsx(Nde,{className:"w-4 h-4"}),i("inventory.paProfileTab"),ee>0&&a.jsx("span",{className:"text-xs px-1.5 py-0.5 rounded-full bg-bambu-green/20 text-bambu-green",children:ee})]})]}),a.jsx("div",{className:"p-4 overflow-y-auto flex-1",style:{scrollbarGutter:"stable"},children:f==="filament"?a.jsxs("div",{className:"space-y-6",children:[a.jsxs("div",{children:[a.jsx("h3",{className:"text-sm font-semibold text-bambu-gray uppercase tracking-wide mb-3",children:i("inventory.filamentInfo")}),a.jsx(vJe,{formData:c,updateField:me,cloudAuthenticated:b,loadingCloudPresets:S,presetInputValue:T,setPresetInputValue:k,selectedPresetOption:pe,filamentOptions:J,availableBrands:_e}),d.slicer_filament&&a.jsx("p",{className:"mt-1 text-xs text-red-400",children:d.slicer_filament}),d.material&&a.jsx("p",{className:"mt-1 text-xs text-red-400",children:d.material}),d.brand&&a.jsx("p",{className:"mt-1 text-xs text-red-400",children:d.brand}),d.subtype&&a.jsx("p",{className:"mt-1 text-xs text-red-400",children:d.subtype})]}),a.jsxs("div",{children:[a.jsx("h3",{className:"text-sm font-semibold text-bambu-gray uppercase tracking-wide mb-3",children:i("inventory.color")}),a.jsx(wJe,{formData:c,updateField:me,recentColors:R,onColorUsed:je,catalogColors:O})]}),a.jsxs("div",{children:[a.jsx("h3",{className:"text-sm font-semibold text-bambu-gray uppercase tracking-wide mb-3",children:i("inventory.additional")}),a.jsx(SJe,{formData:c,updateField:me,spoolCatalog:j})]}),l&&n&&a.jsx("div",{children:a.jsx(MJe,{spoolId:n.id})})]}):a.jsx(NJe,{formData:c,updateField:me,printersWithCalibrations:X,selectedProfiles:K,setSelectedProfiles:Y,expandedPrinters:oe,setExpandedPrinters:$})}),a.jsxs("div",{className:"flex justify-end gap-2 p-4 border-t border-bambu-dark-tertiary flex-shrink-0",children:[a.jsx(Ce,{variant:"secondary",onClick:e,children:i("common.cancel")}),a.jsx(Ce,{onClick:ie,disabled:Fe,children:Fe?a.jsxs(a.Fragment,{children:[a.jsx(it,{className:"w-4 h-4 animate-spin"}),i("common.saving")]}):a.jsxs(a.Fragment,{children:[a.jsx(bs,{className:"w-4 h-4"}),i(l?"common.save":"inventory.addSpool")]})})]})]})]})}function TJe({isOpen:t,onClose:e,columns:n,defaultColumns:r,onSave:i}){const{t:s}=Vt(),[o,l]=w.useState(n),[c,u]=w.useState(null),d=w.useRef(null);if(w.useEffect(()=>{t&&l(n.map(A=>({...A})))},[t,n]),w.useEffect(()=>{if(!t)return;const A=C=>{C.key==="Escape"&&e()};return window.addEventListener("keydown",A),()=>window.removeEventListener("keydown",A)},[t,e]),!t)return null;const h=A=>{l(C=>C.map((T,k)=>k===A?{...T,visible:!T.visible}:T))},f=(A,C)=>{C<0||C>=o.length||l(T=>{const k=[...T],[j]=k.splice(A,1);return k.splice(C,0,j),k})},p=(A,C)=>{d.current=C,u(C),A.dataTransfer.effectAllowed="move"},x=(A,C)=>{A.preventDefault(),A.dataTransfer.dropEffect="move";const T=d.current;T!==null&&T!==C&&(f(T,C),d.current=C,u(C))},y=A=>{A.preventDefault()},b=()=>{d.current=null,u(null)},v=()=>{l(r.map(A=>({...A})))},S=()=>{i(o),e()},N=o.filter(A=>A.visible).length;return a.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4",onClick:e,children:a.jsx(vt,{className:"w-full max-w-md max-h-[80vh] flex flex-col",onClick:A=>A.stopPropagation(),children:a.jsxs(Nt,{className:"p-6 flex flex-col min-h-0",children:[a.jsx("h3",{className:"text-lg font-semibold text-white mb-2",children:s("inventory.configureColumns")}),a.jsxs("p",{className:"text-sm text-bambu-gray mb-4",children:[s("inventory.configureColumnsDesc"),a.jsxs("span",{className:"ml-2 text-bambu-gray/60",children:["(",N," ",s("inventory.of")," ",o.length," ",s("inventory.visible"),")"]})]}),a.jsx("div",{className:"space-y-1 overflow-y-auto flex-1 min-h-0 pr-1",children:o.map((A,C)=>a.jsxs("div",{className:`flex items-center gap-2 p-2 rounded-lg border transition-colors ${c===C?"border-bambu-green bg-bambu-green/10":"border-bambu-dark-tertiary bg-bambu-dark-tertiary/50"} ${A.visible?"":"opacity-50"}`,draggable:!0,onDragStart:T=>p(T,C),onDragOver:T=>x(T,C),onDrop:y,onDragEnd:b,children:[a.jsx("div",{className:"cursor-grab text-bambu-gray/50 hover:text-bambu-gray",children:a.jsx(Dh,{className:"w-4 h-4"})}),a.jsx("span",{className:"flex-1 font-medium text-sm text-white",children:A.label}),a.jsxs("div",{className:"flex items-center gap-0.5",children:[a.jsx("button",{onClick:()=>f(C,C-1),disabled:C===0,className:"p-1 rounded text-bambu-gray hover:bg-bambu-dark-secondary disabled:opacity-30 disabled:cursor-not-allowed",title:s("inventory.moveUp"),children:a.jsx(Wl,{className:"w-4 h-4"})}),a.jsx("button",{onClick:()=>f(C,C+1),disabled:C===o.length-1,className:"p-1 rounded text-bambu-gray hover:bg-bambu-dark-secondary disabled:opacity-30 disabled:cursor-not-allowed",title:s("inventory.moveDown"),children:a.jsx(nr,{className:"w-4 h-4"})})]}),a.jsx("button",{onClick:()=>h(C),className:`p-1.5 rounded transition-colors ${A.visible?"text-bambu-green hover:bg-bambu-green/10":"text-bambu-gray/50 hover:bg-bambu-dark-secondary"}`,title:A.visible?s("inventory.hideColumn"):s("inventory.showColumn"),children:A.visible?a.jsx(Xl,{className:"w-4 h-4"}):a.jsx(gv,{className:"w-4 h-4"})})]},A.id))}),a.jsxs("div",{className:"flex items-center gap-3 mt-4 pt-4 border-t border-bambu-dark-tertiary",children:[a.jsxs(Ce,{variant:"secondary",onClick:v,className:"mr-auto",children:[a.jsx(Ro,{className:"w-4 h-4"}),s("inventory.reset")]}),a.jsx(Ce,{variant:"secondary",onClick:e,children:s("inventory.cancel")}),a.jsx(Ce,{onClick:S,children:s("inventory.applyChanges")})]})]})})})}const ese="bambuddy-inventory-columns",S1=[{id:"id",label:"#",visible:!0},{id:"added_time",label:"Added",visible:!0},{id:"encode_time",label:"Encoded",visible:!1},{id:"last_used_time",label:"Last Used",visible:!1},{id:"rgba",label:"Color",visible:!0},{id:"material",label:"Material",visible:!0},{id:"subtype",label:"Subtype",visible:!0},{id:"color_name",label:"Color Name",visible:!1},{id:"brand",label:"Brand",visible:!0},{id:"slicer_filament",label:"Slicer Filament",visible:!1},{id:"location",label:"Location",visible:!0},{id:"label_weight",label:"Label",visible:!0},{id:"net",label:"Net",visible:!0},{id:"gross",label:"Gross",visible:!1},{id:"added_full",label:"Full",visible:!1},{id:"used",label:"Used",visible:!1},{id:"printed_total",label:"Printed Total",visible:!1},{id:"printed_since_weight",label:"Printed Since Weight",visible:!1},{id:"note",label:"Note",visible:!1},{id:"pa_k",label:"PA(K)",visible:!0},{id:"tag_id",label:"Tag ID",visible:!1},{id:"data_origin",label:"Data Origin",visible:!1},{id:"tag_type",label:"Linked Tag Type",visible:!1},{id:"remaining",label:"Remaining",visible:!0}];function EJe(){try{const t=localStorage.getItem(ese);if(t){const e=JSON.parse(t),n=new Set(S1.map(o=>o.id)),r=new Set(e.map(o=>o.id)),i=e.filter(o=>n.has(o.id)),s=S1.filter(o=>!r.has(o.id));return[...i,...s]}}catch{}return S1.map(t=>({...t}))}function PJe(t){try{localStorage.setItem(ese,JSON.stringify(t))}catch{}}function Lu(t,e=!1){return e&&t>=1e3?`${(t/1e3).toFixed(1)}kg`:`${Math.round(t)}g`}const jJe={PLA:"bg-green-500/20 text-green-400",ABS:"bg-red-500/20 text-red-400",PETG:"bg-blue-500/20 text-blue-400",TPU:"bg-purple-500/20 text-purple-400",ASA:"bg-orange-500/20 text-orange-400",PA:"bg-yellow-500/20 text-yellow-400",PC:"bg-cyan-500/20 text-cyan-400",PET:"bg-sky-500/20 text-sky-400"};function Xj(t){return t?new Date(t).toLocaleDateString("en-GB",{day:"2-digit",month:"2-digit",year:"2-digit"}):"-"}const DJe={id:()=>"#",added_time:()=>"Added",encode_time:()=>"Encoded",last_used_time:()=>"Last Used",rgba:t=>t("inventory.color"),material:t=>t("inventory.material"),subtype:t=>t("inventory.subtype"),color_name:t=>t("inventory.colorName"),brand:t=>t("inventory.brand"),slicer_filament:t=>t("inventory.slicerFilament"),location:()=>"Location",label_weight:t=>t("inventory.labelWeight"),net:t=>t("inventory.net"),gross:()=>"Gross",added_full:()=>"Full",used:t=>t("inventory.weightUsed"),printed_total:()=>"Printed Total",printed_since_weight:()=>"Printed Since Weight",note:t=>t("inventory.note"),pa_k:()=>"PA(K)",tag_id:()=>"Tag ID",data_origin:()=>"Data Origin",tag_type:()=>"Linked Tag Type",remaining:t=>t("inventory.remaining")},RJe={id:({spool:t})=>a.jsx("span",{className:"text-sm font-medium text-white",children:t.id}),added_time:({spool:t})=>a.jsx("span",{className:"text-sm text-bambu-gray",children:Xj(t.created_at)}),encode_time:({spool:t})=>a.jsx("span",{className:"text-sm text-bambu-gray",children:Xj(t.encode_time)}),last_used_time:({spool:t})=>a.jsx("span",{className:"text-sm text-bambu-gray",children:t.last_used?Xj(t.last_used):"Never"}),rgba:({spool:t})=>a.jsx("div",{className:"flex items-center justify-center",children:a.jsx("span",{className:"w-5 h-5 rounded-full border border-white/20 flex-shrink-0",style:{backgroundColor:t.rgba?`#${t.rgba.substring(0,6)}`:"#808080"},title:t.rgba?`#${t.rgba.substring(0,6)}`:void 0})}),material:({spool:t})=>a.jsx("span",{className:"text-sm text-white",children:t.material}),subtype:({spool:t})=>a.jsx("span",{className:"text-sm text-bambu-gray",children:t.subtype||"-"}),color_name:({spool:t})=>a.jsx("span",{className:"text-sm text-bambu-gray",children:bne(t.color_name,t.rgba)||"-"}),brand:({spool:t})=>a.jsx("span",{className:"text-sm text-bambu-gray",children:t.brand||"-"}),slicer_filament:({spool:t})=>a.jsx("span",{className:"text-sm text-bambu-gray",title:t.slicer_filament||void 0,children:t.slicer_filament_name||t.slicer_filament||"-"}),location:({spool:t,assignmentMap:e})=>{const n=e[t.id];if(!n)return a.jsx("span",{className:"text-sm text-bambu-gray",children:"-"});const r=n.printer_name||`Printer ${n.printer_id}`,i=String.fromCharCode(65+n.ams_id),s=n.tray_id+1;return a.jsxs("span",{className:"inline-flex items-center px-1.5 py-0.5 rounded text-xs font-medium bg-purple-500/20 text-purple-400",children:[r," ",i,s]})},label_weight:({spool:t})=>a.jsx("span",{className:"text-sm text-white",children:Lu(t.label_weight)}),net:({remaining:t})=>a.jsx("span",{className:"text-sm text-white",children:Lu(t)}),gross:({spool:t,remaining:e})=>a.jsx("span",{className:"text-sm text-bambu-gray",children:Lu(e+t.core_weight)}),added_full:({spool:t})=>a.jsx("span",{className:"text-sm text-bambu-gray",children:t.added_full==null?"-":t.added_full?"Yes":"No"}),used:({spool:t})=>a.jsx("span",{className:"text-sm text-bambu-gray",children:t.weight_used>0?Lu(t.weight_used):"-"}),printed_total:()=>a.jsx("span",{className:"text-sm text-bambu-gray/50",children:"-"}),printed_since_weight:()=>a.jsx("span",{className:"text-sm text-bambu-gray/50",children:"-"}),note:({spool:t})=>a.jsx("span",{className:"text-sm text-bambu-gray max-w-[150px] truncate block",title:t.note||void 0,children:t.note||"-"}),pa_k:({spool:t})=>(t.k_profiles?.length??0)===0?a.jsx("span",{className:"text-sm text-bambu-gray",children:"-"}):a.jsx("span",{className:"inline-flex items-center px-1.5 py-0.5 rounded text-xs font-medium bg-bambu-green/20 text-bambu-green",children:"K"}),tag_id:({spool:t})=>{const e=t.tag_uid||t.tray_uuid;return e?a.jsx("span",{className:"text-sm text-bambu-gray font-mono",title:e,children:e.length>12?`${e.slice(0,6)}...${e.slice(-4)}`:e}):a.jsx("span",{className:"text-sm text-bambu-gray/50",children:"-"})},data_origin:({spool:t})=>a.jsx("span",{className:"text-sm text-bambu-gray",children:t.data_origin||"-"}),tag_type:({spool:t})=>a.jsx("span",{className:"text-sm text-bambu-gray",children:t.tag_type||"-"}),remaining:({remaining:t,pct:e})=>a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx("div",{className:"flex-1 h-2 bg-bambu-dark-tertiary rounded-full overflow-hidden",children:a.jsx("div",{className:`h-full rounded-full ${e>50?"bg-bambu-green":e>20?"bg-yellow-500":"bg-red-500"}`,style:{width:`${Math.min(e,100)}%`}})}),a.jsxs("span",{className:"text-xs text-bambu-gray min-w-[40px] text-right",children:[Math.round(t),"g"]})]})},Yj={id:t=>t.id,added_time:t=>t.created_at||"",encode_time:t=>t.encode_time||"",last_used_time:t=>t.last_used||"",material:t=>(t.material||"").toLowerCase(),subtype:t=>(t.subtype||"").toLowerCase(),color_name:t=>(t.color_name||"").toLowerCase(),brand:t=>(t.brand||"").toLowerCase(),slicer_filament:t=>(t.slicer_filament_name||t.slicer_filament||"").toLowerCase(),location:(t,e)=>{const n=e[t.id];return n?`${n.printer_name||""} ${String.fromCharCode(65+n.ams_id)}${n.tray_id+1}`:""},label_weight:t=>t.label_weight,net:t=>Math.max(0,t.label_weight-t.weight_used),gross:t=>Math.max(0,t.label_weight-t.weight_used)+t.core_weight,used:t=>t.weight_used,remaining:t=>t.label_weight>0?Math.max(0,t.label_weight-t.weight_used)/t.label_weight:0,note:t=>(t.note||"").toLowerCase(),data_origin:t=>(t.data_origin||"").toLowerCase(),tag_type:t=>(t.tag_type||"").toLowerCase()},gF="bambuddy-inventory-sort";function FJe(){try{const t=localStorage.getItem(gF);if(t)return JSON.parse(t)}catch{}return null}function LJe(t){try{t?localStorage.setItem(gF,JSON.stringify(t)):localStorage.removeItem(gF)}catch{}}function OJe(){const{t}=Vt(),e=tn(),{showToast:n}=hn(),[r,i]=w.useState(null),[s,o]=w.useState(null),[l,c]=w.useState("active"),[u,d]=w.useState("all"),[h,f]=w.useState(""),[p,x]=w.useState(""),[y,b]=w.useState(""),[v,S]=w.useState("table"),[N,A]=w.useState(FJe),[C,T]=w.useState(EJe),[k,j]=w.useState(!1),[E,P]=w.useState(0),[U,O]=w.useState(()=>{try{const Z=localStorage.getItem("bambuddy-inventory-pageSize");if(Z){const Ne=Number(Z);if([15,30,50,100,-1].includes(Ne))return Ne}}catch{}return 15}),{data:B,isLoading:R}=Ze({queryKey:["inventory-spools"],queryFn:()=>re.getSpools(!0),refetchInterval:3e4}),{data:G}=Ze({queryKey:["spool-assignments"],queryFn:()=>re.getAssignments(),refetchInterval:3e4}),q=ot({mutationFn:Z=>re.deleteSpool(Z),onSuccess:()=>{e.invalidateQueries({queryKey:["inventory-spools"]}),n(t("inventory.spoolDeleted"),"success")}}),z=ot({mutationFn:Z=>re.archiveSpool(Z),onSuccess:()=>{e.invalidateQueries({queryKey:["inventory-spools"]}),n(t("inventory.spoolArchived"),"success")}}),K=ot({mutationFn:Z=>re.restoreSpool(Z),onSuccess:()=>{e.invalidateQueries({queryKey:["inventory-spools"]}),n(t("inventory.spoolRestored"),"success")}}),Y=w.useMemo(()=>{if(!B)return null;let Z=0,Ne=0,ve=0,fe=0;const L={};for(const D of B){if(D.archived_at)continue;fe++;const H=Math.max(0,D.label_weight-D.weight_used);Z+=H,Ne+=D.weight_used,(D.label_weight>0?H/D.label_weight*100:0)<20&&ve++;const xe=D.material||"Unknown";L[xe]||(L[xe]={count:0,weight:0}),L[xe].count++,L[xe].weight+=H}return{totalWeight:Z,totalConsumed:Ne,lowStock:ve,byMaterial:L,totalSpools:fe}},[B]),oe=G?.length??0,$=w.useMemo(()=>{const Z={};for(const Ne of G||[])Z[Ne.spool_id]=Ne;return Z},[G]),X=w.useMemo(()=>Y?Object.entries(Y.byMaterial).sort((Z,Ne)=>Ne[1].weight-Z[1].weight).slice(0,4):[],[Y]),ee=w.useMemo(()=>{let Z=B||[];if(l==="active"?Z=Z.filter(Ne=>!Ne.archived_at):Z=Z.filter(Ne=>!!Ne.archived_at),u==="used"?Z=Z.filter(Ne=>Ne.weight_used>0):u==="new"&&(Z=Z.filter(Ne=>Ne.weight_used===0)),h&&(Z=Z.filter(Ne=>Ne.material===h)),p&&(Z=Z.filter(Ne=>Ne.brand===p)),y){const Ne=y.toLowerCase();Z=Z.filter(ve=>ve.brand?.toLowerCase().includes(Ne)||ve.material.toLowerCase().includes(Ne)||ve.color_name?.toLowerCase().includes(Ne)||ve.subtype?.toLowerCase().includes(Ne)||ve.note?.toLowerCase().includes(Ne)||ve.slicer_filament_name?.toLowerCase().includes(Ne))}return Z},[B,l,u,h,p,y]),J=()=>P(0),_e=[...new Set(B?.map(Z=>Z.material)||[])].sort(),pe=[...new Set(B?.map(Z=>Z.brand).filter(Boolean)||[])].sort(),me=l!=="active"||u!=="all"||!!h||!!p||!!y,je=Z=>{T(Z),PJe(Z)},de=w.useMemo(()=>C.filter(Z=>Z.visible).map(Z=>Z.id),[C]),ce=Z=>{Yj[Z]&&(A(Ne=>{let ve;return Ne?.column===Z?ve=Ne.direction==="asc"?{column:Z,direction:"desc"}:null:ve={column:Z,direction:"asc"},LJe(ve),ve}),J())},Se=w.useMemo(()=>{if(!N)return ee;const Z=Yj[N.column];return Z?[...ee].sort((ve,fe)=>{const L=Z(ve,$),D=Z(fe,$);return LD?N.direction==="asc"?1:-1:0}):ee},[ee,N,$]),ie=U===-1,Fe=ie?Se.length||1:U,V=Math.max(1,Math.ceil(Se.length/Fe)),W=ie?0:Math.min(E,V-1),ue=ie?Se:Se.slice(W*Fe,(W+1)*Fe),Q=Z=>{O(Z),P(0);try{localStorage.setItem("bambuddy-inventory-pageSize",String(Z))}catch{}},se=()=>{c("active"),d("all"),f(""),x(""),b(""),J()};return a.jsxs("div",{className:"p-4 md:p-6 space-y-6",children:[a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsxs("div",{children:[a.jsxs("div",{className:"flex items-center gap-3",children:[a.jsx(fa,{className:"w-6 h-6 text-bambu-green"}),a.jsx("h1",{className:"text-2xl font-bold text-white",children:t("inventory.title")})]}),a.jsx("p",{className:"text-sm text-bambu-gray mt-1 ml-9",children:(t("inventory.noSpools").split(".")[0],"")})]}),a.jsxs(Ce,{onClick:()=>i({spool:null}),children:[a.jsx(ar,{className:"w-4 h-4"}),t("inventory.addSpool")]})]}),Y&&!R&&a.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-3 lg:grid-cols-5 gap-3",children:[a.jsxs("div",{className:"bg-bambu-dark-secondary rounded-lg p-4",children:[a.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[a.jsx(fa,{className:"w-4 h-4 text-bambu-green"}),a.jsx("span",{className:"text-xs text-bambu-gray font-medium uppercase tracking-wide",children:t("inventory.totalInventory")})]}),a.jsx("div",{className:"text-xl font-bold text-white",children:Lu(Y.totalWeight,!0)}),a.jsxs("div",{className:"text-xs text-bambu-gray mt-1",children:[Y.totalSpools," ",Y.totalSpools!==1?t("inventory.spools"):t("inventory.spool")]})]}),a.jsxs("div",{className:"bg-bambu-dark-secondary rounded-lg p-4",children:[a.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[a.jsx(zF,{className:"w-4 h-4 text-blue-400"}),a.jsx("span",{className:"text-xs text-bambu-gray font-medium uppercase tracking-wide",children:t("inventory.totalConsumed")})]}),a.jsx("div",{className:"text-xl font-bold text-white",children:Lu(Y.totalConsumed,!0)}),a.jsx("div",{className:"text-xs text-bambu-gray mt-1",children:t("inventory.sinceTracking")})]}),a.jsxs("div",{className:"bg-bambu-dark-secondary rounded-lg p-4",children:[a.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[a.jsx(ma,{className:"w-4 h-4 text-green-400"}),a.jsx("span",{className:"text-xs text-bambu-gray font-medium uppercase tracking-wide",children:t("inventory.byMaterial")})]}),a.jsx("div",{className:"flex flex-wrap gap-1.5 mt-1",children:X.map(([Z,Ne])=>a.jsxs("span",{className:`inline-flex items-center gap-1 px-2 py-0.5 rounded-full text-xs font-medium ${jJe[Z]||"bg-bambu-dark-tertiary text-bambu-gray"}`,children:[Z," ",a.jsx("span",{className:"opacity-70",children:Lu(Ne.weight,!0)})]},Z))})]}),a.jsxs("div",{className:"bg-bambu-dark-secondary rounded-lg p-4",children:[a.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[a.jsx(Cr,{className:"w-4 h-4 text-purple-400"}),a.jsx("span",{className:"text-xs text-bambu-gray font-medium uppercase tracking-wide",children:t("inventory.inPrinter")})]}),a.jsx("div",{className:"text-xl font-bold text-white",children:oe}),a.jsx("div",{className:"text-xs text-bambu-gray mt-1",children:t("inventory.loadedInAms")})]}),a.jsxs("div",{className:"bg-bambu-dark-secondary rounded-lg p-4",children:[a.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[a.jsx(Cn,{className:"w-4 h-4 text-yellow-400"}),a.jsx("span",{className:"text-xs text-bambu-gray font-medium uppercase tracking-wide",children:t("inventory.lowStock")})]}),a.jsx("div",{className:`text-xl font-bold ${Y.lowStock>0?"text-yellow-400":"text-white"}`,children:Y.lowStock}),a.jsx("div",{className:"text-xs text-bambu-gray mt-1",children:t("inventory.lowStockThreshold")})]})]}),a.jsxs("div",{className:"flex flex-col sm:flex-row gap-3 items-start sm:items-center justify-between",children:[a.jsxs("div",{className:"relative flex-1 max-w-md",children:[a.jsx(Or,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray/50"}),a.jsx("input",{type:"text",value:y,onChange:Z=>{b(Z.target.value),J()},placeholder:t("inventory.search"),className:"w-full pl-10 pr-8 py-2 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg text-white text-sm placeholder:text-bambu-gray/50 focus:outline-none focus:border-bambu-green"}),y&&a.jsx("button",{onClick:()=>{b(""),J()},className:"absolute right-3 top-1/2 -translate-y-1/2 text-bambu-gray hover:text-white",children:a.jsx(Ft,{className:"w-4 h-4"})})]}),a.jsxs("div",{className:"flex items-center gap-2",children:[v==="table"&&a.jsxs("button",{onClick:()=>j(!0),className:"flex items-center gap-1.5 px-3 py-1.5 text-sm font-medium text-bambu-gray border border-bambu-dark-tertiary rounded-lg hover:bg-bambu-dark-tertiary transition-colors",title:t("inventory.configureColumns"),children:[a.jsx(_he,{className:"w-4 h-4"}),a.jsx("span",{className:"hidden sm:inline",children:t("inventory.columns")})]}),a.jsxs("div",{className:"flex bg-bambu-dark-primary border border-bambu-dark-tertiary rounded-lg overflow-hidden",children:[a.jsxs("button",{onClick:()=>S("table"),className:`flex items-center gap-1.5 px-3 py-1.5 text-sm font-medium transition-colors ${v==="table"?"bg-bambu-green text-white":"text-bambu-gray hover:bg-bambu-dark-tertiary"}`,children:[a.jsx(ipe,{className:"w-4 h-4"}),a.jsx("span",{className:"hidden sm:inline",children:t("inventory.table")})]}),a.jsxs("button",{onClick:()=>S("cards"),className:`flex items-center gap-1.5 px-3 py-1.5 text-sm font-medium transition-colors ${v==="cards"?"bg-bambu-green text-white":"text-bambu-gray hover:bg-bambu-dark-tertiary"}`,children:[a.jsx(xv,{className:"w-4 h-4"}),a.jsx("span",{className:"hidden sm:inline",children:t("inventory.cards")})]})]})]})]}),a.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[a.jsxs("div",{className:"flex items-center rounded-lg border border-bambu-dark-tertiary overflow-hidden",children:[a.jsxs("button",{onClick:()=>{c("active"),J()},className:`flex items-center gap-1.5 px-3 py-1.5 text-xs font-medium transition-colors ${l==="active"?"bg-bambu-green/20 text-bambu-green":"text-bambu-gray hover:bg-bambu-dark-tertiary"}`,children:[a.jsx(fa,{className:"w-3.5 h-3.5"}),t("inventory.active")]}),a.jsxs("button",{onClick:()=>{c("archived"),J()},className:`flex items-center gap-1.5 px-3 py-1.5 text-xs font-medium transition-colors ${l==="archived"?"bg-bambu-green/20 text-bambu-green":"text-bambu-gray hover:bg-bambu-dark-tertiary"}`,children:[a.jsx(Rs,{className:"w-3.5 h-3.5"}),t("inventory.archived")]})]}),a.jsx("div",{className:"w-px h-5 bg-bambu-dark-tertiary"}),a.jsxs("div",{className:"flex items-center rounded-lg border border-bambu-dark-tertiary overflow-hidden",children:[a.jsx("button",{onClick:()=>{d("all"),J()},className:`px-3 py-1.5 text-xs font-medium transition-colors ${u==="all"?"bg-bambu-green/20 text-bambu-green":"text-bambu-gray hover:bg-bambu-dark-tertiary"}`,children:t("inventory.all")}),a.jsxs("button",{onClick:()=>{d("used"),J()},className:`flex items-center gap-1.5 px-3 py-1.5 text-xs font-medium transition-colors ${u==="used"?"bg-bambu-green/20 text-bambu-green":"text-bambu-gray hover:bg-bambu-dark-tertiary"}`,children:[a.jsx(Wn,{className:"w-3.5 h-3.5"}),t("inventory.used")]}),a.jsx("button",{onClick:()=>{d("new"),J()},className:`px-3 py-1.5 text-xs font-medium transition-colors ${u==="new"?"bg-bambu-green/20 text-bambu-green":"text-bambu-gray hover:bg-bambu-dark-tertiary"}`,children:t("inventory.new")})]}),a.jsx("div",{className:"w-px h-5 bg-bambu-dark-tertiary"}),a.jsxs("select",{value:h,onChange:Z=>{f(Z.target.value),J()},className:`px-3 py-1.5 rounded-lg border text-xs font-medium transition-colors cursor-pointer focus:outline-none ${h?"bg-bambu-green/20 text-bambu-green border-bambu-green/30":"bg-transparent text-bambu-gray border-bambu-dark-tertiary hover:bg-bambu-dark-tertiary"}`,children:[a.jsx("option",{value:"",children:t("inventory.material")}),_e.map(Z=>a.jsx("option",{value:Z,children:Z},Z))]}),a.jsxs("select",{value:p,onChange:Z=>{x(Z.target.value),J()},className:`px-3 py-1.5 rounded-lg border text-xs font-medium transition-colors cursor-pointer focus:outline-none ${p?"bg-bambu-green/20 text-bambu-green border-bambu-green/30":"bg-transparent text-bambu-gray border-bambu-dark-tertiary hover:bg-bambu-dark-tertiary"}`,children:[a.jsx("option",{value:"",children:t("inventory.brand")}),pe.map(Z=>a.jsx("option",{value:Z,children:Z},Z))]}),me&&a.jsxs(a.Fragment,{children:[a.jsx("div",{className:"w-px h-5 bg-bambu-dark-tertiary"}),a.jsxs("button",{onClick:se,className:"flex items-center gap-1 text-xs text-bambu-gray hover:text-bambu-green transition-colors",children:[a.jsx(Ft,{className:"w-3.5 h-3.5"}),t("inventory.clearFilters")]})]}),a.jsxs("span",{className:"ml-auto text-xs text-bambu-gray",children:[Se.length," ",Se.length!==1?t("inventory.spools"):t("inventory.spool")]})]}),R?a.jsx("div",{className:"flex justify-center py-16",children:a.jsx(it,{className:"w-8 h-8 text-bambu-green animate-spin"})}):v==="cards"?ue.length>0?a.jsxs(a.Fragment,{children:[a.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4 gap-4",children:ue.map(Z=>{const Ne=Math.max(0,Z.label_weight-Z.weight_used),ve=Z.label_weight>0?Ne/Z.label_weight*100:0,fe=Z.rgba?`#${Z.rgba.substring(0,6)}`:"#808080";return a.jsxs("div",{className:`bg-bambu-dark-secondary rounded-lg overflow-hidden border border-bambu-dark-tertiary hover:border-bambu-green transition-colors cursor-pointer ${Z.archived_at?"opacity-50":""}`,onClick:()=>i({spool:Z}),children:[a.jsx("div",{className:"h-14 flex items-center justify-center",style:{backgroundColor:fe},children:a.jsx("span",{className:"bg-white/90 text-gray-800 px-3 py-0.5 rounded-full text-sm font-medium",children:bne(Z.color_name,Z.rgba)||"-"})}),a.jsxs("div",{className:"p-4 space-y-3",children:[a.jsxs("div",{className:"flex items-start justify-between gap-2",children:[a.jsxs("div",{children:[a.jsxs("h3",{className:"font-semibold text-white",children:[Z.material,Z.subtype?` ${Z.subtype}`:""]}),a.jsx("p",{className:"text-sm text-bambu-gray",children:Z.brand||"-"})]}),a.jsxs("span",{className:"text-xs font-mono text-bambu-gray bg-bambu-dark-tertiary px-2 py-1 rounded",children:["#",Z.id]})]}),a.jsxs("div",{children:[a.jsxs("div",{className:"flex justify-between text-xs text-bambu-gray mb-1",children:[a.jsx("span",{children:t("inventory.remaining")}),a.jsxs("span",{children:[Math.round(ve),"%"]})]}),a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx("div",{className:"flex-1 h-2 bg-bambu-dark-tertiary rounded-full overflow-hidden",children:a.jsx("div",{className:`h-full rounded-full ${ve>50?"bg-bambu-green":ve>20?"bg-yellow-500":"bg-red-500"}`,style:{width:`${Math.min(ve,100)}%`}})}),a.jsxs("span",{className:"text-xs text-bambu-gray min-w-[40px] text-right",children:[Math.round(Ne),"g"]})]})]}),a.jsxs("div",{className:"grid grid-cols-2 gap-2 text-xs",children:[a.jsxs("div",{children:[a.jsxs("span",{className:"text-bambu-gray/60",children:[t("inventory.labelWeight"),": "]}),a.jsx("span",{className:"text-bambu-gray",children:Lu(Z.label_weight)})]}),a.jsxs("div",{children:[a.jsxs("span",{className:"text-bambu-gray/60",children:[t("inventory.weightUsed"),": "]}),a.jsx("span",{className:"text-bambu-gray",children:Z.weight_used>0?Lu(Z.weight_used):"-"})]})]}),Z.note&&a.jsx("div",{className:"text-xs text-bambu-gray/60 pt-2 border-t border-bambu-dark-tertiary truncate",title:Z.note,children:Z.note})]})]},Z.id)})}),a.jsx(IJe,{pageIndex:W,pageSize:U,totalRows:Se.length,totalPages:V,onPageChange:P,onPageSizeChange:Q,t})]}):a.jsx(fK,{hasFilters:me,onAddSpool:()=>i({spool:null}),t}):ue.length>0?a.jsxs("div",{className:"bg-bambu-dark-secondary rounded-lg overflow-hidden border border-bambu-dark-tertiary",children:[a.jsx("div",{className:"overflow-x-auto",children:a.jsxs("table",{className:"w-full",children:[a.jsx("thead",{children:a.jsxs("tr",{className:"border-b border-bambu-dark-tertiary bg-bambu-dark-tertiary/30",children:[de.map(Z=>{const Ne=!!Yj[Z],ve=N?.column===Z;return a.jsx("th",{className:`text-left py-3 px-4 text-xs font-medium uppercase tracking-wide select-none ${Z==="remaining"?"min-w-[150px]":""} ${Ne?"cursor-pointer hover:text-bambu-green transition-colors":""} ${ve?"text-bambu-green":"text-bambu-gray"}`,onClick:Ne?()=>ce(Z):void 0,children:a.jsxs("span",{className:"inline-flex items-center gap-1",children:[DJe[Z]?.(t)??Z,Ne&&(ve?N.direction==="asc"?a.jsx(Pf,{className:"w-3 h-3"}):a.jsx(hb,{className:"w-3 h-3"}):a.jsx(RF,{className:"w-3 h-3 opacity-30"}))]})},Z)}),a.jsx("th",{className:"text-right py-3 px-4 text-xs font-medium text-bambu-gray uppercase tracking-wide",children:t("common.actions")})]})}),a.jsx("tbody",{children:ue.map(Z=>{const Ne=Math.max(0,Z.label_weight-Z.weight_used),ve=Z.label_weight>0?Ne/Z.label_weight*100:0;return a.jsxs("tr",{className:`border-b border-bambu-dark-tertiary/50 hover:bg-bambu-dark-tertiary/30 transition-colors cursor-pointer ${Z.archived_at?"opacity-50":""}`,onClick:()=>i({spool:Z}),children:[de.map(fe=>a.jsx("td",{className:"py-3 px-4",children:RJe[fe]?.({spool:Z,remaining:Ne,pct:ve,assignmentMap:$})},fe)),a.jsx("td",{className:"py-3 px-4",children:a.jsxs("div",{className:"flex items-center justify-end gap-1",onClick:fe=>fe.stopPropagation(),children:[a.jsx("button",{onClick:()=>i({spool:Z}),className:"p-1.5 text-bambu-gray hover:text-white rounded transition-colors",title:t("inventory.editSpool"),children:a.jsx(af,{className:"w-4 h-4"})}),Z.archived_at?a.jsx("button",{onClick:()=>K.mutate(Z.id),className:"p-1.5 text-bambu-gray hover:text-bambu-green rounded transition-colors",title:t("inventory.restore"),children:a.jsx(Ro,{className:"w-4 h-4"})}):a.jsx("button",{onClick:()=>o({type:"archive",spoolId:Z.id}),className:"p-1.5 text-bambu-gray hover:text-yellow-400 rounded transition-colors",title:t("inventory.archive"),children:a.jsx(Rs,{className:"w-4 h-4"})}),a.jsx("button",{onClick:()=>o({type:"delete",spoolId:Z.id}),className:"p-1.5 text-bambu-gray hover:text-red-400 rounded transition-colors",title:t("common.delete"),children:a.jsx(Jt,{className:"w-4 h-4"})})]})})]},Z.id)})})]})}),a.jsxs("div",{className:"flex items-center justify-between px-4 py-3 bg-bambu-dark-tertiary/50 border-t border-bambu-dark-tertiary text-sm",children:[a.jsx("span",{className:"text-bambu-gray",children:ie?`${Se.length} ${Se.length!==1?t("inventory.spools"):t("inventory.spool")}`:a.jsxs(a.Fragment,{children:[t("inventory.showing")," ",W*Fe+1," ",t("inventory.to")," ",Math.min((W+1)*Fe,Se.length)," ",t("inventory.of")," ",Se.length," ",t("inventory.spools")]})}),a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx("span",{className:"text-bambu-gray",children:t("inventory.show")}),a.jsxs("select",{value:U,onChange:Z=>Q(Number(Z.target.value)),className:"px-2 py-1 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded text-white text-sm focus:outline-none focus:border-bambu-green",children:[[15,30,50,100].map(Z=>a.jsx("option",{value:Z,children:Z},Z)),a.jsx("option",{value:-1,children:t("inventory.all")})]}),!ie&&a.jsxs(a.Fragment,{children:[a.jsx("button",{onClick:()=>P(0),disabled:W===0,className:"p-1.5 rounded text-bambu-gray hover:text-white disabled:opacity-30 disabled:cursor-not-allowed transition-colors",title:"First page",children:a.jsx(cX,{className:"w-4 h-4"})}),a.jsx("button",{onClick:()=>P(Z=>Math.max(0,Z-1)),disabled:W===0,className:"p-1.5 rounded text-bambu-gray hover:text-white disabled:opacity-30 disabled:cursor-not-allowed transition-colors",children:a.jsx(ql,{className:"w-4 h-4"})}),a.jsxs("span",{className:"text-bambu-gray px-2 whitespace-nowrap",children:[t("inventory.page")," ",W+1," ",t("inventory.of")," ",V]}),a.jsx("button",{onClick:()=>P(Z=>Math.min(V-1,Z+1)),disabled:W>=V-1,className:"p-1.5 rounded text-bambu-gray hover:text-white disabled:opacity-30 disabled:cursor-not-allowed transition-colors",children:a.jsx(pa,{className:"w-4 h-4"})}),a.jsx("button",{onClick:()=>P(V-1),disabled:W>=V-1,className:"p-1.5 rounded text-bambu-gray hover:text-white disabled:opacity-30 disabled:cursor-not-allowed transition-colors",title:"Last page",children:a.jsx(uX,{className:"w-4 h-4"})})]})]})]})]}):a.jsx(fK,{hasFilters:me,onAddSpool:()=>i({spool:null}),t}),r!==null&&a.jsx(AJe,{isOpen:!0,onClose:()=>i(null),spool:r.spool}),s&&a.jsx(vn,{title:s.type==="delete"?t("common.delete"):t("inventory.archive"),message:s.type==="delete"?t("inventory.deleteConfirm"):t("inventory.archiveConfirm"),confirmText:s.type==="delete"?t("common.delete"):t("inventory.archive"),variant:s.type==="delete"?"danger":"warning",onConfirm:()=>{s.type==="delete"?q.mutate(s.spoolId):z.mutate(s.spoolId),o(null)},onCancel:()=>o(null)}),a.jsx(TJe,{isOpen:k,onClose:()=>j(!1),columns:C,defaultColumns:S1,onSave:je})]})}function IJe({pageIndex:t,pageSize:e,totalRows:n,totalPages:r,onPageChange:i,onPageSizeChange:s,t:o}){const l=e===-1;if(r<=1&&!l)return null;const c=l?n||1:e;return a.jsxs("div",{className:"flex items-center justify-between pt-2 text-sm",children:[a.jsx("span",{className:"text-bambu-gray",children:l?`${n} ${o(n!==1?"inventory.spools":"inventory.spool")}`:a.jsxs(a.Fragment,{children:[o("inventory.showing")," ",t*c+1," ",o("inventory.to")," ",Math.min((t+1)*c,n)," ",o("inventory.of")," ",n," ",o("inventory.spools")]})}),a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx("span",{className:"text-bambu-gray",children:o("inventory.show")}),a.jsxs("select",{value:e,onChange:u=>s(Number(u.target.value)),className:"px-2 py-1 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded text-white text-sm focus:outline-none focus:border-bambu-green",children:[[15,30,50,100].map(u=>a.jsx("option",{value:u,children:u},u)),a.jsx("option",{value:-1,children:o("inventory.all")})]}),!l&&a.jsxs(a.Fragment,{children:[a.jsx("button",{onClick:()=>i(0),disabled:t===0,className:"p-1.5 rounded text-bambu-gray hover:text-white disabled:opacity-30 disabled:cursor-not-allowed transition-colors",children:a.jsx(cX,{className:"w-4 h-4"})}),a.jsx("button",{onClick:()=>i(Math.max(0,t-1)),disabled:t===0,className:"p-1.5 rounded text-bambu-gray hover:text-white disabled:opacity-30 disabled:cursor-not-allowed transition-colors",children:a.jsx(ql,{className:"w-4 h-4"})}),a.jsxs("span",{className:"text-bambu-gray px-2 whitespace-nowrap",children:[o("inventory.page")," ",t+1," ",o("inventory.of")," ",r]}),a.jsx("button",{onClick:()=>i(Math.min(r-1,t+1)),disabled:t>=r-1,className:"p-1.5 rounded text-bambu-gray hover:text-white disabled:opacity-30 disabled:cursor-not-allowed transition-colors",children:a.jsx(pa,{className:"w-4 h-4"})}),a.jsx("button",{onClick:()=>i(r-1),disabled:t>=r-1,className:"p-1.5 rounded text-bambu-gray hover:text-white disabled:opacity-30 disabled:cursor-not-allowed transition-colors",children:a.jsx(uX,{className:"w-4 h-4"})})]})]})]})}function fK({hasFilters:t,onAddSpool:e,t:n}){return a.jsxs("div",{className:"flex flex-col items-center justify-center py-16 px-4",children:[a.jsxs("div",{className:"relative mb-6",children:[a.jsx("div",{className:"absolute inset-0 -m-4 bg-bambu-green/5 rounded-full blur-2xl"}),a.jsxs("div",{className:"relative flex items-center justify-center w-24 h-24 rounded-2xl bg-gradient-to-br from-bambu-dark-secondary to-bambu-dark-tertiary border border-bambu-dark-tertiary shadow-lg",children:[a.jsx("div",{className:"absolute -top-1 -right-1 w-3 h-3 rounded-full bg-bambu-green/30"}),a.jsx("div",{className:"absolute -bottom-2 -left-2 w-2 h-2 rounded-full bg-bambu-green/20"}),t?a.jsx(Or,{className:"w-10 h-10 text-bambu-gray/40",strokeWidth:1.5}):a.jsxs("div",{className:"relative",children:[a.jsx("div",{className:"w-14 h-14 rounded-full border-4 border-bambu-gray/20 flex items-center justify-center",children:a.jsx("div",{className:"w-6 h-6 rounded-full bg-bambu-gray/10 border-2 border-bambu-gray/20"})}),a.jsx("div",{className:"absolute -bottom-1 -right-1 w-6 h-6 rounded-full bg-bambu-green flex items-center justify-center shadow-md",children:a.jsx("span",{className:"text-white text-lg font-bold leading-none",children:"+"})})]})]})]}),a.jsx("h3",{className:"text-lg font-semibold text-white mb-2 text-center",children:t?n("inventory.noSpoolsMatch"):n("inventory.noSpools").split(".")[0]}),a.jsx("p",{className:"text-sm text-bambu-gray text-center max-w-sm mb-6",children:n(t?"inventory.noSpoolsMatchDesc":"inventory.noSpools")}),!t&&a.jsxs(Ce,{onClick:e,children:[a.jsx(fa,{className:"w-4 h-4"}),n("inventory.addSpool")]})]})}const pK=["DEBUG","INFO","WARNING","ERROR"],Qj={DEBUG:"text-gray-400",INFO:"text-blue-400",WARNING:"text-yellow-400",ERROR:"text-red-400"},zJe={DEBUG:Zk,INFO:Js,WARNING:Cn,ERROR:Hi};function UJe(){const t=tn(),[e,n]=w.useState(!0),[r,i]=w.useState(new Set),[s,o]=w.useState(""),[l,c]=w.useState("ALL"),[u,d]=w.useState(!1),[h,f]=w.useState(!1),p=w.useRef(null),{data:x,isLoading:y,refetch:b}=Ze({queryKey:["application-logs",l,s],queryFn:()=>Zg.getLogs({limit:200,level:l==="ALL"?void 0:l,search:s||void 0}),refetchInterval:h?2e3:!1,enabled:u});w.useEffect(()=>{u||f(!1)},[u]);const v=ot({mutationFn:()=>Zg.clearLogs(),onSuccess:()=>{t.invalidateQueries({queryKey:["application-logs"]})}});w.useEffect(()=>{e&&p.current&&x?.entries&&(p.current.scrollTop=p.current.scrollHeight)},[x?.entries,e]);const S=k=>{i(j=>{const E=new Set(j);return E.has(k)?E.delete(k):E.add(k),E})},N=k=>{const j=k.split(" ");return j.length>=2?j[1]:k},A=w.useMemo(()=>x?.entries??[],[x?.entries]),C=w.useMemo(()=>[...A].reverse(),[A]),T=({level:k})=>{const j=zJe[k]||Js;return a.jsx(j,{className:`w-3.5 h-3.5 ${Qj[k]||"text-gray-400"}`})};return a.jsxs("div",{className:"bg-bambu-dark rounded-lg overflow-hidden",children:[a.jsxs("button",{onClick:()=>d(!u),className:"w-full flex items-center justify-between p-4 hover:bg-bambu-dark-tertiary/50 transition-colors",children:[a.jsxs("div",{className:"flex items-center gap-3",children:[a.jsx("div",{className:`p-2 rounded-lg ${h?"bg-bambu-green/20 text-bambu-green":"bg-bambu-dark-tertiary text-bambu-gray"}`,children:a.jsx(Zk,{className:"w-5 h-5"})}),a.jsxs("div",{className:"text-left",children:[a.jsx("p",{className:"font-medium text-white",children:"Application Logs"}),a.jsx("p",{className:"text-sm text-bambu-gray",children:h?`Live streaming - ${x?.filtered_count??0} entries`:"View and filter application logs"})]})]}),a.jsxs("div",{className:"flex items-center gap-2",children:[h&&a.jsxs("span",{className:"flex items-center gap-1.5 px-2 py-1 bg-bambu-green/20 rounded text-bambu-green text-xs",children:[a.jsx("span",{className:"w-1.5 h-1.5 bg-bambu-green rounded-full animate-pulse"}),"Live"]}),u?a.jsx(Wl,{className:"w-5 h-5 text-bambu-gray"}):a.jsx(nr,{className:"w-5 h-5 text-bambu-gray"})]})]}),u&&a.jsxs("div",{className:"border-t border-bambu-dark-tertiary",children:[a.jsxs("div",{className:"flex flex-col gap-2 p-4 border-b border-bambu-dark-tertiary",children:[a.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[h?a.jsxs("button",{onClick:k=>{k.stopPropagation(),f(!1)},className:"flex items-center gap-1.5 px-3 py-1.5 text-sm bg-red-500/20 text-red-400 hover:bg-red-500/30 rounded transition-colors",children:[a.jsx(bl,{className:"w-4 h-4"}),"Stop"]}):a.jsxs("button",{onClick:k=>{k.stopPropagation(),f(!0),b()},className:"flex items-center gap-1.5 px-3 py-1.5 text-sm bg-bambu-green/20 text-bambu-green hover:bg-bambu-green/30 rounded transition-colors",children:[a.jsx(so,{className:"w-4 h-4"}),"Start"]}),a.jsxs("button",{onClick:()=>v.mutate(),disabled:v.isPending||A.length===0,className:"flex items-center gap-1.5 px-3 py-1.5 text-sm bg-bambu-dark-tertiary text-bambu-gray hover:text-white hover:bg-bambu-dark-secondary rounded transition-colors disabled:opacity-50",children:[a.jsx(Jt,{className:"w-4 h-4"}),"Clear"]}),a.jsx("button",{onClick:()=>b(),disabled:y,className:"flex items-center gap-1.5 px-3 py-1.5 text-sm bg-bambu-dark-tertiary text-bambu-gray hover:text-white hover:bg-bambu-dark-secondary rounded transition-colors disabled:opacity-50",children:a.jsx(kr,{className:`w-4 h-4 ${y?"animate-spin":""}`})}),a.jsx("div",{className:"flex-1"}),a.jsxs("label",{className:"flex items-center gap-2 text-sm text-bambu-gray cursor-pointer",children:[a.jsx("input",{type:"checkbox",checked:e,onChange:k=>n(k.target.checked),className:"rounded border-bambu-dark-tertiary bg-bambu-dark-tertiary"}),"Auto-scroll"]}),a.jsxs("span",{className:"text-sm text-bambu-gray",children:[x?.filtered_count??0,"/",x?.total_in_file??0]})]}),a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsxs("div",{className:"relative flex-1",children:[a.jsx(Or,{className:"absolute left-2.5 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray"}),a.jsx("input",{type:"text",placeholder:"Search message or logger name...",value:s,onChange:k=>o(k.target.value),className:"w-full pl-8 pr-8 py-1.5 text-sm bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded text-white placeholder-bambu-gray focus:border-bambu-green focus:outline-none"}),s&&a.jsx("button",{onClick:()=>o(""),className:"absolute right-2 top-1/2 -translate-y-1/2 text-bambu-gray hover:text-white",children:a.jsx(Ft,{className:"w-4 h-4"})})]}),a.jsxs("div",{className:"flex items-center gap-1 bg-bambu-dark-secondary rounded border border-bambu-dark-tertiary",children:[a.jsx("button",{onClick:()=>c("ALL"),className:`px-2 py-1.5 text-xs rounded-l transition-colors ${l==="ALL"?"bg-bambu-green text-white":"text-bambu-gray hover:text-white"}`,children:"All"}),pK.map((k,j)=>a.jsx("button",{onClick:()=>c(k),className:`px-2 py-1.5 text-xs transition-colors flex items-center gap-1 ${j===pK.length-1?"rounded-r":""} ${l===k?`${Qj[k]} bg-bambu-dark-tertiary`:"text-bambu-gray hover:text-white"}`,children:k},k))]})]})]}),a.jsx("div",{ref:p,className:"overflow-auto font-mono text-xs bg-black min-h-[300px] max-h-[500px]",children:A.length===0?a.jsxs("div",{className:"flex flex-col items-center justify-center h-[300px] text-bambu-gray",children:[a.jsx("p",{className:"mb-2",children:"No log entries found"}),a.jsx("p",{className:"text-sm",children:"Log file may be empty or cleared"})]}):a.jsx("div",{className:"divide-y divide-bambu-dark-tertiary/30",children:C.map((k,j)=>{const E=r.has(j),P=k.message.includes(` `);return a.jsx("div",{className:`p-2 cursor-pointer hover:bg-bambu-dark-secondary/50 transition-colors ${E?"bg-bambu-dark-secondary/30":""}`,onClick:()=>P&&S(j),children:a.jsxs("div",{className:"flex items-start gap-2",children:[a.jsx("span",{className:"text-bambu-gray/70 shrink-0 w-20",children:N(k.timestamp)}),a.jsx("span",{className:"shrink-0",children:a.jsx(T,{level:k.level})}),a.jsxs("span",{className:"text-purple-400/80 shrink-0 max-w-[200px] truncate",title:k.logger_name,children:["[",k.logger_name,"]"]}),a.jsx("span",{className:`flex-1 ${Qj[k.level]||"text-white/80"} ${!E&&P?"truncate":""}`,children:E?a.jsx("pre",{className:"whitespace-pre-wrap break-all",children:k.message}):k.message.split(` `)[0]}),P&&a.jsx("span",{className:"text-bambu-gray/50 shrink-0",children:E?a.jsx(Wl,{className:"w-3.5 h-3.5"}):a.jsx(nr,{className:"w-3.5 h-3.5"})})]})},j)})})}),a.jsx("div",{className:"flex items-center justify-between p-3 border-t border-bambu-dark-tertiary text-sm text-bambu-gray",children:h?a.jsxs("span",{className:"flex items-center gap-2",children:[a.jsx("span",{className:"w-2 h-2 bg-green-500 rounded-full animate-pulse"}),"Auto-refreshing every 2 seconds"]}):a.jsx("span",{children:"Click Start to enable live log streaming"})})]})]})}function BJe(t){return t<1024?`${t} B`:t<1024*1024?`${(t/1024).toFixed(1)} KB`:t<1024*1024*1024?`${(t/(1024*1024)).toFixed(1)} MB`:`${(t/(1024*1024*1024)).toFixed(2)} GB`}function Mi({icon:t,label:e,value:n,subValue:r,color:i="text-bambu-green"}){return a.jsxs("div",{className:"flex items-start gap-3 p-4 bg-bambu-dark rounded-lg",children:[a.jsx("div",{className:`p-2 rounded-lg bg-bambu-dark-tertiary ${i}`,children:a.jsx(t,{className:"w-5 h-5"})}),a.jsxs("div",{className:"flex-1 min-w-0",children:[a.jsx("p",{className:"text-sm text-bambu-gray",children:e}),a.jsx("p",{className:"text-lg font-semibold text-white truncate",children:n}),r&&a.jsx("p",{className:"text-xs text-bambu-gray mt-0.5",children:r})]})]})}function gK({percent:t,color:e="bg-bambu-green"}){return a.jsx("div",{className:"w-full h-2 bg-bambu-dark rounded-full overflow-hidden",children:a.jsx("div",{className:`h-full ${e} transition-all duration-300`,style:{width:`${Math.min(100,t)}%`}})})}function sh({title:t,icon:e,children:n}){return a.jsxs(vt,{className:"p-6",children:[a.jsxs("div",{className:"flex items-center gap-2 mb-4",children:[a.jsx(e,{className:"w-5 h-5 text-bambu-green"}),a.jsx("h2",{className:"text-lg font-semibold text-white",children:t})]}),n]})}function HJe(){const{t}=Vt(),e=tn(),[n,r]=w.useState(null),[i,s]=w.useState(!1),[o,l]=w.useState(!1),{data:c,isLoading:u,refetch:d,isFetching:h}=Ze({queryKey:["systemInfo"],queryFn:re.getSystemInfo,refetchInterval:3e4}),{data:f}=Ze({queryKey:["debugLogging"],queryFn:Zg.getDebugLoggingState,staleTime:10*1e3,refetchInterval:10*1e3}),{data:p}=Ze({queryKey:["settings"],queryFn:re.getSettings}),{data:x}=Ze({queryKey:["library-stats"],queryFn:re.getLibraryStats}),y=p?.time_format||"system",b=async()=>{l(!0);try{const A=await Zg.setDebugLogging(!f?.enabled);e.setQueryData(["debugLogging"],A)}catch(A){console.error("Failed to toggle debug logging:",A)}finally{l(!1)}},v=async()=>{r(null),s(!0);try{await Zg.downloadSupportBundle()}catch(A){r(A instanceof Error?A.message:"Failed to download support bundle")}finally{s(!1)}};if(u)return a.jsx("div",{className:"flex items-center justify-center h-64",children:a.jsx(it,{className:"w-8 h-8 text-bambu-green animate-spin"})});if(!c)return a.jsx("div",{className:"p-6 text-center text-bambu-gray",children:t("system.failedToLoad","Failed to load system information")});const S=c.storage.disk_percent_used>90?"bg-red-500":c.storage.disk_percent_used>75?"bg-yellow-500":"bg-bambu-green",N=c.memory.percent_used>90?"bg-red-500":c.memory.percent_used>75?"bg-yellow-500":"bg-bambu-green";return a.jsxs("div",{className:"p-6 space-y-6",children:[a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsxs("div",{children:[a.jsx("h1",{className:"text-2xl font-bold text-white",children:t("system.title","System Information")}),a.jsx("p",{className:"text-bambu-gray mt-1",children:t("system.subtitle","Monitor system resources and database statistics")})]}),a.jsxs("button",{onClick:()=>d(),disabled:h,className:"flex items-center gap-2 px-4 py-2 bg-bambu-dark-secondary hover:bg-bambu-dark-tertiary rounded-lg transition-colors disabled:opacity-50",children:[a.jsx(kr,{className:`w-4 h-4 ${h?"animate-spin":""}`}),t("common.refresh","Refresh")]})]}),a.jsx(sh,{title:t("system.application","Application"),icon:Gm,children:a.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-4",children:[a.jsx(Mi,{icon:Gm,label:t("system.version","Version"),value:`v${c.app.version}`}),a.jsx(Mi,{icon:Wn,label:t("system.uptime","System Uptime"),value:c.system.uptime_formatted}),a.jsx(Mi,{icon:Gm,label:t("system.hostname","Hostname"),value:c.system.hostname})]})}),a.jsx(sh,{title:t("support.title","Support & Troubleshooting"),icon:vme,children:a.jsxs("div",{className:"space-y-4",children:[a.jsx("p",{className:"text-sm text-bambu-gray",children:t("support.description","Enable debug logging to capture detailed information, then download a support bundle to share when reporting issues.")}),a.jsxs("div",{className:"flex items-center justify-between p-4 bg-bambu-dark rounded-lg",children:[a.jsxs("div",{className:"flex items-center gap-3",children:[a.jsx("div",{className:`p-2 rounded-lg ${f?.enabled?"bg-amber-500/20 text-amber-500":"bg-bambu-dark-tertiary text-bambu-gray"}`,children:a.jsx(Zk,{className:"w-5 h-5"})}),a.jsxs("div",{children:[a.jsx("p",{className:"font-medium text-white",children:t("support.debugLogging","Debug Logging")}),a.jsxs("p",{className:"text-sm text-bambu-gray",children:[f?.enabled?t("support.debugLoggingEnabled","Capturing detailed logs"):t("support.debugLoggingDisabled","Normal logging level"),f?.enabled&&f.duration_seconds!==null&&a.jsxs("span",{className:"text-amber-400 ml-2",children:["(",Math.floor(f.duration_seconds/60),"m ",f.duration_seconds%60,"s)"]})]})]})]}),a.jsxs("button",{onClick:b,disabled:o,className:`px-4 py-2 rounded-lg font-medium transition-colors flex items-center gap-2 ${f?.enabled?"bg-amber-500/20 text-amber-400 hover:bg-amber-500/30":"bg-bambu-green/20 text-bambu-green hover:bg-bambu-green/30"} disabled:opacity-50`,children:[o&&a.jsx(it,{className:"w-4 h-4 animate-spin"}),f?.enabled?t("support.disableDebug","Disable"):t("support.enableDebug","Enable")]})]}),a.jsxs("div",{className:"flex items-center justify-between p-4 bg-bambu-dark rounded-lg",children:[a.jsxs("div",{className:"flex items-center gap-3",children:[a.jsx("div",{className:"p-2 rounded-lg bg-bambu-dark-tertiary text-bambu-green",children:a.jsx(di,{className:"w-5 h-5"})}),a.jsxs("div",{children:[a.jsx("p",{className:"font-medium text-white",children:t("support.supportBundle","Support Bundle")}),a.jsx("p",{className:"text-sm text-bambu-gray",children:t("support.supportBundleDescription","Download system info and logs as a ZIP file")})]})]}),a.jsxs("button",{onClick:v,disabled:i||!f?.enabled,className:"px-4 py-2 rounded-lg font-medium bg-bambu-green/20 text-bambu-green hover:bg-bambu-green/30 transition-colors flex items-center gap-2 disabled:opacity-50 disabled:cursor-not-allowed",title:f?.enabled?void 0:t("support.enableDebugFirst","Enable debug logging first"),children:[i&&a.jsx(it,{className:"w-4 h-4 animate-spin"}),t("common.download","Download")]})]}),n&&a.jsx("div",{className:"p-3 bg-red-500/20 border border-red-500/30 rounded-lg text-red-400 text-sm",children:n}),!f?.enabled&&a.jsx("div",{className:"p-4 bg-bambu-dark-tertiary/50 rounded-lg",children:a.jsxs("p",{className:"text-sm text-bambu-gray",children:[a.jsx("span",{className:"text-amber-400 font-medium",children:t("support.instructions","To report an issue:")}),a.jsx("br",{}),"1. ",t("support.step1","Enable debug logging"),a.jsx("br",{}),"2. ",t("support.step2","Reproduce the issue"),a.jsx("br",{}),"3. ",t("support.step3","Download the support bundle"),a.jsx("br",{}),"4. ",t("support.step4","Attach the ZIP file to your issue report")]})}),a.jsxs("div",{className:"p-4 bg-bambu-dark rounded-lg space-y-3",children:[a.jsx("p",{className:"text-sm font-medium text-white",children:t("support.privacyTitle","What's in the support bundle?")}),a.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4 text-sm",children:[a.jsxs("div",{children:[a.jsx("p",{className:"text-bambu-green font-medium mb-1",children:t("support.collected","Collected:")}),a.jsxs("ul",{className:"text-bambu-gray space-y-0.5",children:[a.jsxs("li",{children:["• ",t("support.collectItem1","App version and debug mode")]}),a.jsxs("li",{children:["• ",t("support.collectItem2","OS, architecture, Python version")]}),a.jsxs("li",{children:["• ",t("support.collectItem3","Database statistics (counts only)")]}),a.jsxs("li",{children:["• ",t("support.collectItem4","Printer models and nozzle counts")]}),a.jsxs("li",{children:["• ",t("support.collectItem5","Non-sensitive settings (themes, formats)")]}),a.jsxs("li",{children:["• ",t("support.collectItem6","Debug logs (sanitized)")]}),a.jsxs("li",{children:["• ",t("support.collectItem7","Printer connectivity and firmware versions")]}),a.jsxs("li",{children:["• ",t("support.collectItem8","Integration status (Spoolman, MQTT, HA)")]}),a.jsxs("li",{children:["• ",t("support.collectItem9","Network interfaces (subnets only)")]}),a.jsxs("li",{children:["• ",t("support.collectItem10","Python package versions")]}),a.jsxs("li",{children:["• ",t("support.collectItem11","Database health checks")]}),a.jsxs("li",{children:["• ",t("support.collectItem12","Docker environment details")]})]})]}),a.jsxs("div",{children:[a.jsx("p",{className:"text-red-400 font-medium mb-1",children:t("support.notCollected","NOT collected:")}),a.jsxs("ul",{className:"text-bambu-gray space-y-0.5",children:[a.jsxs("li",{children:["• ",t("support.notItem1","Printer names, IPs, serial numbers")]}),a.jsxs("li",{children:["• ",t("support.notItem2","Access codes and passwords")]}),a.jsxs("li",{children:["• ",t("support.notItem3","Email addresses")]}),a.jsxs("li",{children:["• ",t("support.notItem4","API keys and tokens")]}),a.jsxs("li",{children:["• ",t("support.notItem5","Webhook URLs")]}),a.jsxs("li",{children:["• ",t("support.notItem6","Your hostname or username")]})]})]})]}),a.jsx("p",{className:"text-xs text-bambu-gray/70",children:t("support.privacyNote","IP addresses in logs are replaced with [IP] and email addresses with [EMAIL].")})]}),a.jsx(UJe,{})]})}),a.jsxs(sh,{title:t("system.database","Database"),icon:Tc,children:[a.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-4 mb-4",children:[a.jsx(Mi,{icon:Rs,label:t("system.totalArchives","Total Archives"),value:c.database.archives}),a.jsx(Mi,{icon:fb,label:t("system.completed","Completed"),value:c.database.archives_completed,color:"text-green-500"}),a.jsx(Mi,{icon:ha,label:t("system.failed","Failed"),value:c.database.archives_failed,color:"text-red-500"}),a.jsx(Mi,{icon:it,label:t("system.printing","Printing"),value:c.database.archives_printing,color:"text-yellow-500"})]}),a.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-4",children:[a.jsx(Mi,{icon:Cr,label:t("system.printers","Printers"),value:c.database.printers}),a.jsx(Mi,{icon:aC,label:t("system.filaments","Filaments"),value:c.database.filaments}),a.jsx(Mi,{icon:xs,label:t("system.projects","Projects"),value:c.database.projects}),a.jsx(Mi,{icon:hl,label:t("system.smartPlugs","Smart Plugs"),value:c.database.smart_plugs})]}),a.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4 mt-4",children:[a.jsx(Mi,{icon:Wn,label:t("system.totalPrintTime","Total Print Time"),value:c.database.total_print_time_formatted}),a.jsx(Mi,{icon:Rs,label:t("system.totalFilament","Total Filament Used"),value:`${c.database.total_filament_kg} kg`,subValue:`${c.database.total_filament_grams.toLocaleString()} g`})]})]}),a.jsxs(sh,{title:t("system.connectedPrinters","Connected Printers"),icon:Cr,children:[a.jsxs("div",{className:"flex items-center gap-4 mb-4",children:[a.jsx("div",{className:"text-3xl font-bold text-bambu-green",children:c.printers.connected}),a.jsx("div",{className:"text-bambu-gray",children:t("system.ofTotal","of {{total}} printers connected",{total:c.printers.total})})]}),c.printers.connected_list.length>0?a.jsx("div",{className:"space-y-2",children:c.printers.connected_list.map(A=>a.jsxs("div",{className:"flex items-center justify-between p-3 bg-bambu-dark rounded-lg",children:[a.jsxs("div",{className:"flex items-center gap-3",children:[a.jsx("div",{className:"w-2 h-2 rounded-full bg-bambu-green"}),a.jsx("span",{className:"font-medium text-white",children:A.name})]}),a.jsxs("div",{className:"flex items-center gap-4 text-sm text-bambu-gray",children:[a.jsx("span",{children:A.model}),a.jsx("span",{className:`px-2 py-0.5 rounded ${A.state==="RUNNING"?"bg-bambu-green/20 text-bambu-green":A.state==="IDLE"?"bg-blue-500/20 text-blue-400":"bg-bambu-dark-tertiary"}`,children:A.state})]})]},A.id))}):a.jsx("p",{className:"text-bambu-gray",children:t("system.noPrintersConnected","No printers connected")})]}),a.jsx(sh,{title:t("system.storage","Storage"),icon:qb,children:a.jsxs("div",{className:"space-y-4",children:[a.jsxs("div",{children:[a.jsxs("div",{className:"flex justify-between text-sm mb-1",children:[a.jsx("span",{className:"text-bambu-gray",children:t("system.diskUsage","Disk Usage")}),a.jsxs("span",{className:"text-white",children:[c.storage.disk_used_formatted," / ",c.storage.disk_total_formatted]})]}),a.jsx(gK,{percent:c.storage.disk_percent_used,color:S}),a.jsxs("p",{className:"text-xs text-bambu-gray mt-1",children:[c.storage.disk_free_formatted," ",t("system.free","free")," (",(100-c.storage.disk_percent_used).toFixed(1),"%)"]})]}),a.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-4",children:[a.jsx(Mi,{icon:Rs,label:t("system.archiveStorage","Archive Storage"),value:c.storage.archive_size_formatted}),a.jsx(Mi,{icon:Tc,label:t("system.databaseSize","Database Size"),value:c.storage.database_size_formatted}),x&&a.jsx(Mi,{icon:Yl,label:t("system.fileManagerStorage","File Manager"),value:BJe(x.total_size_bytes),subValue:`${x.total_files} files, ${x.total_folders} folders`})]})]})}),a.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-6",children:[a.jsx(sh,{title:t("system.memory","Memory"),icon:Zme,children:a.jsx("div",{className:"space-y-4",children:a.jsxs("div",{children:[a.jsxs("div",{className:"flex justify-between text-sm mb-1",children:[a.jsx("span",{className:"text-bambu-gray",children:t("system.memoryUsage","Memory Usage")}),a.jsxs("span",{className:"text-white",children:[c.memory.used_formatted," / ",c.memory.total_formatted]})]}),a.jsx(gK,{percent:c.memory.percent_used,color:N}),a.jsxs("p",{className:"text-xs text-bambu-gray mt-1",children:[c.memory.available_formatted," ",t("system.available","available")]})]})})}),a.jsx(sh,{title:t("system.cpu","CPU"),icon:h_,children:a.jsx("div",{className:"space-y-4",children:a.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[a.jsx(Mi,{icon:h_,label:t("system.cores","Cores"),value:c.cpu.count,subValue:`${c.cpu.count_logical} logical`}),a.jsx(Mi,{icon:h_,label:t("system.usage","Usage"),value:`${c.cpu.percent}%`})]})})})]}),a.jsx(sh,{title:t("system.systemDetails","System Details"),icon:Gm,children:a.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-4",children:[a.jsx(Mi,{icon:Gm,label:t("system.os","Operating System"),value:c.system.platform,subValue:c.system.platform_release}),a.jsx(Mi,{icon:h_,label:t("system.architecture","Architecture"),value:c.system.architecture}),a.jsx(Mi,{icon:Gm,label:t("system.python","Python"),value:c.system.python_version}),a.jsx(Mi,{icon:Wn,label:t("system.bootTime","Boot Time"),value:Lf(c.system.boot_time,y)})]})})]})}function $Je(){const t=$c(),{t:e}=Vt(),{login:n}=Ir(),{showToast:r}=hn(),{mode:i}=rp(),[s,o]=w.useState(""),[l,c]=w.useState(""),[u,d]=w.useState(!1),[h,f]=w.useState(""),{data:p}=Ze({queryKey:["advancedAuthStatus"],queryFn:()=>re.getAdvancedAuthStatus()}),x=ot({mutationFn:()=>n(s,l),onSuccess:()=>{r(e("login.loginSuccess")),t("/")},onError:S=>{r(S.message||e("login.loginFailed"),"error")}}),y=ot({mutationFn:S=>re.forgotPassword({email:S}),onSuccess:S=>{r(S.message,"success"),d(!1),f("")},onError:S=>{r(S.message,"error")}}),b=S=>{if(S.preventDefault(),!s||!l){r(e("login.enterCredentials"),"error");return}x.mutate()},v=S=>{if(S.preventDefault(),!h){r("Please enter your email address","error");return}y.mutate(h)};return a.jsxs("div",{className:"min-h-screen flex items-center justify-center bg-bambu-dark p-4",children:[a.jsxs("div",{className:"max-w-md w-full space-y-8 p-8 bg-gradient-to-br from-bambu-card to-bambu-dark-secondary rounded-xl border border-bambu-dark-tertiary shadow-lg",children:[a.jsxs("div",{className:"text-center",children:[a.jsx("div",{className:"flex items-center justify-center mb-6",children:a.jsx("img",{src:i==="dark"?"/img/bambuddy_logo_dark_transparent.png":"/img/bambuddy_logo_light.png",alt:"Bambuddy",className:"h-16"})}),a.jsx("h2",{className:"text-3xl font-bold text-white",children:e("login.title")}),a.jsx("p",{className:"mt-2 text-sm text-bambu-gray",children:e("login.subtitle")})]}),a.jsxs("form",{className:"mt-8 space-y-6",onSubmit:b,children:[a.jsxs("div",{className:"space-y-4",children:[a.jsxs("div",{children:[a.jsx("label",{htmlFor:"username",className:"block text-sm font-medium text-white mb-2",children:p?.advanced_auth_enabled?e("login.usernameOrEmail")||"Username or Email":e("login.username")}),a.jsx("input",{id:"username",type:"text",required:!0,value:s,onChange:S=>o(S.target.value),className:"block w-full px-4 py-3 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg text-white placeholder-bambu-gray focus:outline-none focus:ring-2 focus:ring-bambu-green/50 focus:border-bambu-green transition-colors",placeholder:p?.advanced_auth_enabled?e("login.usernameOrEmailPlaceholder")||"Enter your username or email":e("login.usernamePlaceholder"),autoComplete:"username"})]}),a.jsxs("div",{children:[a.jsx("label",{htmlFor:"password",className:"block text-sm font-medium text-white mb-2",children:e("login.password")}),a.jsx("input",{id:"password",type:"password",required:!0,value:l,onChange:S=>c(S.target.value),className:"block w-full px-4 py-3 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg text-white placeholder-bambu-gray focus:outline-none focus:ring-2 focus:ring-bambu-green/50 focus:border-bambu-green transition-colors",placeholder:e("login.passwordPlaceholder"),autoComplete:"current-password"})]})]}),a.jsx("div",{children:a.jsx("button",{type:"submit",disabled:x.isPending,className:"w-full flex justify-center py-3 px-4 bg-bambu-green hover:bg-bambu-green-light text-white font-medium rounded-lg shadow-lg shadow-bambu-green/20 hover:shadow-bambu-green/30 focus:outline-none focus:ring-2 focus:ring-bambu-green/50 focus:ring-offset-2 focus:ring-offset-bambu-dark-secondary transition-all disabled:opacity-50 disabled:cursor-not-allowed disabled:hover:bg-bambu-green",children:x.isPending?e("login.signingIn"):e("login.signIn")})}),p?.advanced_auth_enabled&&a.jsx("div",{className:"text-center",children:a.jsx("button",{type:"button",onClick:()=>d(!0),className:"text-sm text-bambu-gray hover:text-bambu-green transition-colors",children:e("login.forgotPassword")})})]})]}),u&&a.jsx("div",{className:"fixed inset-0 bg-black/70 flex items-center justify-center z-50 p-4",onClick:()=>d(!1),children:a.jsxs(vt,{className:"w-full max-w-md",onClick:S=>S.stopPropagation(),children:[a.jsx(An,{children:a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx(k0,{className:"w-5 h-5 text-bambu-green"}),a.jsx("h2",{className:"text-lg font-semibold text-white",children:e("login.forgotPasswordTitle")})]}),a.jsx(Ce,{variant:"ghost",size:"sm",onClick:()=>{d(!1),f("")},children:a.jsx(Ft,{className:"w-5 h-5"})})]})}),a.jsx(Nt,{children:p?.advanced_auth_enabled?a.jsxs("form",{onSubmit:v,className:"space-y-4",children:[a.jsx("p",{className:"text-bambu-gray text-sm",children:e("login.forgotPasswordEmailMessage")||"Enter your email address and we'll send you a new password."}),a.jsxs("div",{children:[a.jsx("label",{htmlFor:"forgot-email",className:"block text-sm font-medium text-white mb-2",children:e("login.emailAddress")||"Email Address"}),a.jsx("input",{id:"forgot-email",type:"email",required:!0,value:h,onChange:S=>f(S.target.value),className:"block w-full px-4 py-3 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg text-white placeholder-bambu-gray focus:outline-none focus:ring-2 focus:ring-bambu-green/50 focus:border-bambu-green transition-colors",placeholder:e("login.emailPlaceholder")||"your.email@example.com"})]}),a.jsxs("div",{className:"flex gap-2",children:[a.jsx(Ce,{type:"button",variant:"secondary",className:"flex-1",onClick:()=>{d(!1),f("")},children:e("login.cancel")||"Cancel"}),a.jsx(Ce,{type:"submit",className:"flex-1",disabled:y.isPending,children:y.isPending?e("login.sending")||"Sending...":e("login.sendResetEmail")||"Send Reset Email"})]})]}):a.jsxs("div",{className:"space-y-4",children:[a.jsx("p",{className:"text-bambu-gray",children:e("login.forgotPasswordMessage")}),a.jsxs("div",{className:"bg-bambu-dark rounded-lg p-4 space-y-2",children:[a.jsx("p",{className:"text-sm text-white font-medium",children:e("login.howToReset")}),a.jsxs("ol",{className:"text-sm text-bambu-gray space-y-1 list-decimal list-inside",children:[a.jsx("li",{children:e("login.resetStep1")}),a.jsx("li",{children:e("login.resetStep2")}),a.jsx("li",{children:e("login.resetStep3")}),a.jsx("li",{children:e("login.resetStep4")})]})]}),a.jsx(Ce,{variant:"secondary",className:"w-full",onClick:()=>d(!1),children:e("login.gotIt")})]})})]})})]})}function VJe(){const t=$c(),{t:e}=Vt(),{showToast:n}=hn(),{mode:r}=rp(),{refreshAuth:i}=Ir(),[s,o]=w.useState(!1),[l,c]=w.useState(""),[u,d]=w.useState(""),[h,f]=w.useState(""),p=ot({mutationFn:()=>re.setupAuth({auth_enabled:s,admin_username:s?l:void 0,admin_password:s?u:void 0}),onSuccess:async y=>{await i(),y.auth_enabled?y.admin_created?(n(e("setup.toast.authEnabledAdminCreated")),t("/login")):(n(e("setup.toast.authEnabledExistingAdmins")),t("/login")):(n(e("setup.toast.setupCompleted")),t("/"))},onError:y=>{n(y.message,"error")}}),x=y=>{if(y.preventDefault(),s&&(l||u)){if(!l||!u){n(e("setup.toast.enterBothCredentials"),"error");return}if(u!==h){n(e("setup.toast.passwordsDoNotMatch"),"error");return}if(u.length<6){n(e("setup.toast.passwordTooShort"),"error");return}}p.mutate()};return a.jsx("div",{className:"min-h-screen flex items-center justify-center bg-bambu-dark p-4",children:a.jsxs("div",{className:"max-w-md w-full space-y-8 p-8 bg-gradient-to-br from-bambu-card to-bambu-dark-secondary rounded-xl border border-bambu-dark-tertiary shadow-lg",children:[a.jsxs("div",{className:"text-center",children:[a.jsx("div",{className:"flex items-center justify-center mb-6",children:a.jsx("img",{src:r==="dark"?"/img/bambuddy_logo_dark_transparent.png":"/img/bambuddy_logo_light.png",alt:"Bambuddy",className:"h-16"})}),a.jsx("h2",{className:"text-3xl font-bold text-white",children:e("setup.title")}),a.jsx("p",{className:"mt-2 text-sm text-bambu-gray",children:e("setup.subtitle")})]}),a.jsxs("form",{className:"mt-8 space-y-6",onSubmit:x,children:[a.jsxs("div",{className:"space-y-4",children:[a.jsxs("div",{className:"flex items-center p-4 bg-bambu-dark-secondary/50 rounded-lg border border-bambu-dark-tertiary",children:[a.jsx("input",{id:"auth-enabled",type:"checkbox",checked:s,onChange:y=>o(y.target.checked),className:"h-4 w-4 text-bambu-green focus:ring-bambu-green border-bambu-dark-tertiary rounded bg-bambu-dark-secondary"}),a.jsx("label",{htmlFor:"auth-enabled",className:"ml-3 block text-sm font-medium text-white",children:e("setup.enableAuth")})]}),s&&a.jsxs("div",{className:"space-y-4 mt-4",children:[a.jsx("div",{className:"p-3 bg-bambu-dark-secondary/50 border border-bambu-dark-tertiary rounded-lg",children:a.jsxs("div",{className:"flex items-start gap-2",children:[a.jsx(Js,{className:"w-4 h-4 text-bambu-green mt-0.5 flex-shrink-0"}),a.jsxs("div",{className:"text-sm text-bambu-gray",children:[a.jsx("p",{className:"text-white font-medium mb-1",children:e("setup.adminAccount")}),a.jsx("p",{children:e("setup.adminAccountDesc")})]})]})}),a.jsxs("div",{children:[a.jsxs("label",{htmlFor:"admin-username",className:"block text-sm font-medium text-white mb-2",children:[e("setup.adminUsername")," ",a.jsx("span",{className:"text-bambu-gray text-xs",children:e("setup.optionalIfAdminExists")})]}),a.jsx("input",{id:"admin-username",type:"text",value:l,onChange:y=>c(y.target.value),className:"block w-full px-4 py-3 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg text-white placeholder-bambu-gray focus:outline-none focus:ring-2 focus:ring-bambu-green/50 focus:border-bambu-green transition-colors",placeholder:e("setup.adminUsernamePlaceholder"),autoComplete:"username"})]}),a.jsxs("div",{children:[a.jsxs("label",{htmlFor:"admin-password",className:"block text-sm font-medium text-white mb-2",children:[e("setup.adminPassword")," ",a.jsx("span",{className:"text-bambu-gray text-xs",children:e("setup.optionalIfAdminExists")})]}),a.jsx("input",{id:"admin-password",type:"password",value:u,onChange:y=>d(y.target.value),className:"block w-full px-4 py-3 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg text-white placeholder-bambu-gray focus:outline-none focus:ring-2 focus:ring-bambu-green/50 focus:border-bambu-green transition-colors",placeholder:e("setup.adminPasswordPlaceholder"),minLength:6,autoComplete:"new-password"})]}),u&&a.jsxs("div",{children:[a.jsx("label",{htmlFor:"confirm-password",className:"block text-sm font-medium text-white mb-2",children:e("setup.confirmPassword")}),a.jsx("input",{id:"confirm-password",type:"password",value:h,onChange:y=>f(y.target.value),className:"block w-full px-4 py-3 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg text-white placeholder-bambu-gray focus:outline-none focus:ring-2 focus:ring-bambu-green/50 focus:border-bambu-green transition-colors",placeholder:e("setup.confirmPasswordPlaceholder"),minLength:6,autoComplete:"new-password"})]})]})]}),a.jsx("div",{children:a.jsx("button",{type:"submit",disabled:p.isPending,className:"w-full flex justify-center py-3 px-4 bg-bambu-green hover:bg-bambu-green-light text-white font-medium rounded-lg shadow-lg shadow-bambu-green/20 hover:shadow-bambu-green/30 focus:outline-none focus:ring-2 focus:ring-bambu-green/50 focus:ring-offset-2 focus:ring-offset-bambu-dark-secondary transition-all disabled:opacity-50 disabled:cursor-not-allowed disabled:hover:bg-bambu-green",children:p.isPending?e("setup.settingUp"):e("setup.completeSetup")})})]})]})})}function GJe(){const t=w.useRef(null),e=w.useRef(null),n=tn(),[r,i]=w.useState(!1),s=w.useRef(new Set),o=w.useRef(null),l=w.useRef(new Map),c=w.useRef(null),u=w.useRef([]),d=w.useRef(!1),h=w.useRef(()=>{}),f=w.useCallback(()=>{if(d.current||u.current.length===0)return;d.current=!0;const S=()=>{const N=u.current.shift();N?requestAnimationFrame(()=>{h.current(N),u.current.length>0?setTimeout(S,16):d.current=!1}):d.current=!1};S()},[]),p=w.useCallback(()=>{if(t.current?.readyState===WebSocket.OPEN)return;const N=`${window.location.protocol==="https:"?"wss:":"ws:"}//${window.location.host}/api/v1/ws`,A=new WebSocket(N);let C=null;A.onopen=()=>{console.log("[WebSocket] Connected"),i(!0),C=window.setInterval(()=>{A.readyState===WebSocket.OPEN&&A.send(JSON.stringify({type:"ping"}))},3e4)},A.onmessage=T=>{try{const k=JSON.parse(T.data);k.type==="printer_status"&&k.printer_id!==void 0&&k.data?h.current(k):(u.current.push(k),f())}catch{}},A.onclose=T=>{console.log("[WebSocket] Closed",T.code,T.reason),C&&(clearInterval(C),C=null),i(!1),t.current=null,e.current=window.setTimeout(()=>{p()},3e3)},A.onerror=T=>{console.error("[WebSocket] Error",T),A.close()},t.current=A},[f]),x=w.useCallback((S,N)=>{const A=l.current.get(S)||{};l.current.set(S,{...A,...N}),c.current||(c.current=window.setTimeout(()=>{const C=new Map(l.current);l.current.clear(),c.current=null,requestAnimationFrame(()=>{C.forEach((T,k)=>{n.setQueryData(["printerStatus",k],j=>{const E={...j,...T};return E.wifi_signal==null&&j?.wifi_signal!=null&&(E.wifi_signal=j.wifi_signal),E})})})},100))},[n]),y=w.useCallback(S=>{s.current.add(S),o.current&&clearTimeout(o.current),o.current=window.setTimeout(()=>{const N=Array.from(s.current);s.current.clear(),o.current=null;let A=0;N.forEach(C=>{setTimeout(()=>{requestAnimationFrame(()=>{n.invalidateQueries({queryKey:[C]})})},A),A+=500})},3e3)},[n]),b=w.useCallback(S=>{switch(S.type){case"printer_status":S.printer_id!==void 0&&S.data&&x(S.printer_id,S.data);break;case"print_start":S.printer_id!==void 0&&n.invalidateQueries({queryKey:["printerStatus",S.printer_id]});break;case"print_complete":y("archives"),y("archiveStats");break;case"archive_created":y("archives"),y("archiveStats");break;case"archive_updated":y("archives");break;case"pong":break;case"plate_not_empty":window.dispatchEvent(new CustomEvent("plate-not-empty",{detail:{printer_id:S.printer_id,printer_name:S.printer_name,message:S.message}}));break;case"spool_auto_assigned":y("inventory-spools"),y("spool-assignments");break;case"spool_usage_logged":y("inventory-spools");break;case"unknown_tag":window.dispatchEvent(new CustomEvent("unknown-tag",{detail:{printer_id:S.printer_id,ams_id:S.ams_id,tray_id:S.tray_id,tag_uid:S.tag_uid,tray_uuid:S.tray_uuid}}));break}},[n,y,x]);w.useEffect(()=>{h.current=b},[b]),w.useEffect(()=>(p(),()=>{e.current&&clearTimeout(e.current),o.current&&clearTimeout(o.current),c.current&&clearTimeout(c.current),t.current&&t.current.close()}),[p]);const v=w.useCallback(S=>{t.current?.readyState===WebSocket.OPEN&&t.current.send(JSON.stringify(S))},[]);return{isConnected:r,sendMessage:v}}const qJe=new Jue({defaultOptions:{queries:{staleTime:1e3*60,retry:1}}});function WJe({children:t}){return GJe(),a.jsx(a.Fragment,{children:t})}function KJe({children:t}){const{authEnabled:e,loading:n,user:r}=Ir();return n?a.jsx("div",{className:"min-h-screen flex items-center justify-center",children:"Loading..."}):e&&!r?a.jsx(db,{to:"/login",replace:!0}):a.jsx(a.Fragment,{children:t})}function XJe({children:t}){const{authEnabled:e,loading:n,user:r,isAdmin:i}=Ir();return n?a.jsx("div",{className:"min-h-screen flex items-center justify-center",children:"Loading..."}):e?r?i?a.jsx(a.Fragment,{children:t}):a.jsx(db,{to:"/",replace:!0}):a.jsx(db,{to:"/login",replace:!0}):a.jsx(a.Fragment,{children:t})}function YJe({children:t}){const{authEnabled:e,loading:n}=Ir();return n?a.jsx("div",{className:"min-h-screen flex items-center justify-center",children:"Loading..."}):e?a.jsx(db,{to:"/login",replace:!0}):a.jsx(a.Fragment,{children:t})}function QJe(){return a.jsx(Hpe,{children:a.jsx(Qpe,{children:a.jsx(ede,{client:qJe,children:a.jsx(Kpe,{children:a.jsx(yue,{children:a.jsxs(Kce,{children:[a.jsx(Ui,{path:"/setup",element:a.jsx(YJe,{children:a.jsx(VJe,{})})}),a.jsx(Ui,{path:"/login",element:a.jsx($Je,{})}),a.jsx(Ui,{path:"/camera/:printerId",element:a.jsx(nJe,{})}),a.jsx(Ui,{path:"/overlay/:printerId",element:a.jsx(sJe,{})}),a.jsxs(Ui,{element:a.jsx(KJe,{children:a.jsx(WJe,{children:a.jsx(tge,{})})}),children:[a.jsx(Ui,{index:!0,element:a.jsx(r$e,{})}),a.jsx(Ui,{path:"archives",element:a.jsx(HXe,{})}),a.jsx(Ui,{path:"queue",element:a.jsx(MQe,{})}),a.jsx(Ui,{path:"stats",element:a.jsx($Qe,{})}),a.jsx(Ui,{path:"profiles",element:a.jsx(PZe,{})}),a.jsx(Ui,{path:"maintenance",element:a.jsx(LZe,{})}),a.jsx(Ui,{path:"projects",element:a.jsx(IZe,{})}),a.jsx(Ui,{path:"projects/:id",element:a.jsx(GZe,{})}),a.jsx(Ui,{path:"inventory",element:a.jsx(OJe,{})}),a.jsx(Ui,{path:"files",element:a.jsx(ZZe,{})}),a.jsx(Ui,{path:"settings",element:a.jsx(XJe,{children:a.jsx(gZe,{})})}),a.jsx(Ui,{path:"users",element:a.jsx(db,{to:"/settings?tab=users",replace:!0})}),a.jsx(Ui,{path:"groups",element:a.jsx(db,{to:"/settings?tab=users",replace:!0})}),a.jsx(Ui,{path:"system",element:a.jsx(HJe,{})}),a.jsx(Ui,{path:"external/:id",element:a.jsx(oJe,{})})]})]})})})})})})}$oe.createRoot(document.getElementById("root")).render(a.jsx(w.StrictMode,{children:a.jsx(QJe,{})})); diff --git a/static/assets/index-EqFdfChN.css b/static/assets/index-EqFdfChN.css new file mode 100644 index 000000000..485bd9d39 --- /dev/null +++ b/static/assets/index-EqFdfChN.css @@ -0,0 +1 @@ +@import"https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap";@layer properties,theme,base,components,utilities;@layer theme{:root,:host{--font-sans:ui-sans-serif,system-ui,sans-serif,"Apple Color Emoji","Segoe UI Emoji","Segoe UI Symbol","Noto Color Emoji";--font-mono:ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,"Liberation Mono","Courier New",monospace;--color-red-50:oklch(97.1% .013 17.38);--color-red-100:oklch(93.6% .032 17.717);--color-red-200:oklch(88.5% .062 18.334);--color-red-300:oklch(80.8% .114 19.571);--color-red-400:oklch(70.4% .191 22.216);--color-red-500:oklch(63.7% .237 25.331);--color-red-600:oklch(57.7% .245 27.325);--color-red-700:oklch(50.5% .213 27.518);--color-red-800:oklch(44.4% .177 26.899);--color-red-950:oklch(25.8% .092 26.042);--color-orange-200:oklch(90.1% .076 70.697);--color-orange-300:oklch(83.7% .128 66.29);--color-orange-400:oklch(75% .183 55.934);--color-orange-500:oklch(70.5% .213 47.604);--color-orange-600:oklch(64.6% .222 41.116);--color-orange-700:oklch(55.3% .195 38.402);--color-amber-50:oklch(98.7% .022 95.277);--color-amber-200:oklch(92.4% .12 95.746);--color-amber-300:oklch(87.9% .169 91.605);--color-amber-400:oklch(82.8% .189 84.429);--color-amber-500:oklch(76.9% .188 70.08);--color-amber-600:oklch(66.6% .179 58.318);--color-yellow-200:oklch(94.5% .129 101.54);--color-yellow-300:oklch(90.5% .182 98.111);--color-yellow-400:oklch(85.2% .199 91.936);--color-yellow-500:oklch(79.5% .184 86.047);--color-yellow-600:oklch(68.1% .162 75.834);--color-yellow-700:oklch(55.4% .135 66.442);--color-lime-500:oklch(76.8% .233 130.85);--color-green-100:oklch(96.2% .044 156.743);--color-green-200:oklch(92.5% .084 155.995);--color-green-300:oklch(87.1% .15 154.449);--color-green-400:oklch(79.2% .209 151.711);--color-green-500:oklch(72.3% .219 149.579);--color-green-600:oklch(62.7% .194 149.214);--color-green-900:oklch(39.3% .095 152.535);--color-emerald-400:oklch(76.5% .177 163.223);--color-emerald-500:oklch(69.6% .17 162.48);--color-emerald-700:oklch(50.8% .118 165.612);--color-teal-400:oklch(77.7% .152 181.912);--color-teal-500:oklch(70.4% .14 182.503);--color-cyan-300:oklch(86.5% .127 207.078);--color-cyan-400:oklch(78.9% .154 211.53);--color-cyan-500:oklch(71.5% .143 215.221);--color-cyan-600:oklch(60.9% .126 221.723);--color-sky-400:oklch(74.6% .16 232.661);--color-sky-500:oklch(68.5% .169 237.323);--color-blue-50:oklch(97% .014 254.604);--color-blue-100:oklch(93.2% .032 255.585);--color-blue-200:oklch(88.2% .059 254.128);--color-blue-300:oklch(80.9% .105 251.813);--color-blue-400:oklch(70.7% .165 254.624);--color-blue-500:oklch(62.3% .214 259.815);--color-blue-600:oklch(54.6% .245 262.881);--color-blue-700:oklch(48.8% .243 264.376);--color-indigo-400:oklch(67.3% .182 276.935);--color-indigo-500:oklch(58.5% .233 277.117);--color-violet-500:oklch(60.6% .25 292.717);--color-purple-300:oklch(82.7% .119 306.383);--color-purple-400:oklch(71.4% .203 305.504);--color-purple-500:oklch(62.7% .265 303.9);--color-purple-700:oklch(49.6% .265 301.924);--color-fuchsia-500:oklch(66.7% .295 322.15);--color-rose-300:oklch(81% .117 11.638);--color-rose-400:oklch(71.2% .194 13.428);--color-rose-500:oklch(64.5% .246 16.439);--color-rose-600:oklch(58.6% .253 17.585);--color-slate-300:oklch(86.9% .022 252.894);--color-slate-500:oklch(55.4% .046 257.417);--color-gray-50:oklch(98.5% .002 247.839);--color-gray-100:oklch(96.7% .003 264.542);--color-gray-200:oklch(92.8% .006 264.531);--color-gray-300:oklch(87.2% .01 258.338);--color-gray-400:oklch(70.7% .022 261.325);--color-gray-500:oklch(55.1% .027 264.364);--color-gray-600:oklch(44.6% .03 256.802);--color-gray-700:oklch(37.3% .034 259.733);--color-gray-800:oklch(27.8% .033 256.848);--color-gray-900:oklch(21% .034 264.665);--color-black:#000;--color-white:#fff;--spacing:.25rem;--container-xs:20rem;--container-sm:24rem;--container-md:28rem;--container-lg:32rem;--container-xl:36rem;--container-2xl:42rem;--container-3xl:48rem;--container-4xl:56rem;--container-5xl:64rem;--container-6xl:72rem;--text-xs:.75rem;--text-xs--line-height:calc(1/.75);--text-sm:.875rem;--text-sm--line-height:calc(1.25/.875);--text-base:1rem;--text-base--line-height: 1.5 ;--text-lg:1.125rem;--text-lg--line-height:calc(1.75/1.125);--text-xl:1.25rem;--text-xl--line-height:calc(1.75/1.25);--text-2xl:1.5rem;--text-2xl--line-height:calc(2/1.5);--text-3xl:1.875rem;--text-3xl--line-height: 1.2 ;--font-weight-normal:400;--font-weight-medium:500;--font-weight-semibold:600;--font-weight-bold:700;--tracking-wide:.025em;--tracking-wider:.05em;--tracking-widest:.1em;--leading-tight:1.25;--radius-sm:.25rem;--radius-md:.375rem;--radius-lg:.5rem;--radius-xl:.75rem;--radius-2xl:1rem;--drop-shadow-md:0 3px 3px #0000001f;--drop-shadow-lg:0 4px 4px #00000026;--ease-out:cubic-bezier(0,0,.2,1);--ease-in-out:cubic-bezier(.4,0,.2,1);--animate-spin:spin 1s linear infinite;--animate-pulse:pulse 2s cubic-bezier(.4,0,.6,1)infinite;--blur-sm:8px;--blur-2xl:40px;--aspect-video:16/9;--default-transition-duration:.15s;--default-transition-timing-function:cubic-bezier(.4,0,.2,1);--default-font-family:var(--font-sans);--default-mono-font-family:var(--font-mono);--color-bambu-green:var(--accent);--color-bambu-green-light:var(--accent-light);--color-bambu-green-dark:var(--accent-dark);--color-status-ok:var(--status-ok);--color-status-error:var(--status-error);--color-status-warning:var(--status-warning);--color-bambu-dark:var(--bg-primary);--color-bambu-dark-secondary:var(--bg-secondary);--color-bambu-dark-tertiary:var(--bg-tertiary);--color-bambu-gray:var(--text-muted);--color-bambu-gray-light:var(--text-secondary);--color-bambu-gray-dark:var(--text-tertiary)}}@layer base{*,:after,:before,::backdrop{box-sizing:border-box;border:0 solid;margin:0;padding:0}::file-selector-button{box-sizing:border-box;border:0 solid;margin:0;padding:0}html,:host{-webkit-text-size-adjust:100%;tab-size:4;line-height:1.5;font-family:var(--default-font-family,ui-sans-serif,system-ui,sans-serif,"Apple Color Emoji","Segoe UI Emoji","Segoe UI Symbol","Noto Color Emoji");font-feature-settings:var(--default-font-feature-settings,normal);font-variation-settings:var(--default-font-variation-settings,normal);-webkit-tap-highlight-color:transparent}hr{height:0;color:inherit;border-top-width:1px}abbr:where([title]){-webkit-text-decoration:underline dotted;text-decoration:underline dotted}h1,h2,h3,h4,h5,h6{font-size:inherit;font-weight:inherit}a{color:inherit;-webkit-text-decoration:inherit;text-decoration:inherit}b,strong{font-weight:bolder}code,kbd,samp,pre{font-family:var(--default-mono-font-family,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,"Liberation Mono","Courier New",monospace);font-feature-settings:var(--default-mono-font-feature-settings,normal);font-variation-settings:var(--default-mono-font-variation-settings,normal);font-size:1em}small{font-size:80%}sub,sup{vertical-align:baseline;font-size:75%;line-height:0;position:relative}sub{bottom:-.25em}sup{top:-.5em}table{text-indent:0;border-color:inherit;border-collapse:collapse}:-moz-focusring{outline:auto}progress{vertical-align:baseline}summary{display:list-item}ol,ul,menu{list-style:none}img,svg,video,canvas,audio,iframe,embed,object{vertical-align:middle;display:block}img,video{max-width:100%;height:auto}button,input,select,optgroup,textarea{font:inherit;font-feature-settings:inherit;font-variation-settings:inherit;letter-spacing:inherit;color:inherit;opacity:1;background-color:#0000;border-radius:0}::file-selector-button{font:inherit;font-feature-settings:inherit;font-variation-settings:inherit;letter-spacing:inherit;color:inherit;opacity:1;background-color:#0000;border-radius:0}:where(select:is([multiple],[size])) optgroup{font-weight:bolder}:where(select:is([multiple],[size])) optgroup option{padding-inline-start:20px}::file-selector-button{margin-inline-end:4px}::placeholder{opacity:1}@supports (not ((-webkit-appearance:-apple-pay-button))) or (contain-intrinsic-size:1px){::placeholder{color:currentColor}@supports (color:color-mix(in lab,red,red)){::placeholder{color:color-mix(in oklab,currentcolor 50%,transparent)}}}textarea{resize:vertical}::-webkit-search-decoration{-webkit-appearance:none}::-webkit-date-and-time-value{min-height:1lh;text-align:inherit}::-webkit-datetime-edit{display:inline-flex}::-webkit-datetime-edit-fields-wrapper{padding:0}::-webkit-datetime-edit{padding-block:0}::-webkit-datetime-edit-year-field{padding-block:0}::-webkit-datetime-edit-month-field{padding-block:0}::-webkit-datetime-edit-day-field{padding-block:0}::-webkit-datetime-edit-hour-field{padding-block:0}::-webkit-datetime-edit-minute-field{padding-block:0}::-webkit-datetime-edit-second-field{padding-block:0}::-webkit-datetime-edit-millisecond-field{padding-block:0}::-webkit-datetime-edit-meridiem-field{padding-block:0}::-webkit-calendar-picker-indicator{line-height:1}:-moz-ui-invalid{box-shadow:none}button,input:where([type=button],[type=reset],[type=submit]){appearance:button}::file-selector-button{appearance:button}::-webkit-inner-spin-button{height:auto}::-webkit-outer-spin-button{height:auto}[hidden]:where(:not([hidden=until-found])){display:none!important}}@layer utilities{.pointer-events-none{pointer-events:none}.collapse{visibility:collapse}.visible{visibility:visible}.sr-only{clip-path:inset(50%);white-space:nowrap;border-width:0;width:1px;height:1px;margin:-1px;padding:0;position:absolute;overflow:hidden}.absolute{position:absolute}.fixed{position:fixed}.relative{position:relative}.static{position:static}.sticky{position:sticky}.inset-0{inset:calc(var(--spacing)*0)}.inset-x-0{inset-inline:calc(var(--spacing)*0)}.inset-y-0{inset-block:calc(var(--spacing)*0)}.-top-1{top:calc(var(--spacing)*-1)}.-top-1\.5{top:calc(var(--spacing)*-1.5)}.top-0{top:calc(var(--spacing)*0)}.top-0\.5{top:calc(var(--spacing)*.5)}.top-1{top:calc(var(--spacing)*1)}.top-1\.5{top:calc(var(--spacing)*1.5)}.top-1\/2{top:50%}.top-2{top:calc(var(--spacing)*2)}.top-2\.5{top:calc(var(--spacing)*2.5)}.top-3{top:calc(var(--spacing)*3)}.top-4{top:calc(var(--spacing)*4)}.top-8{top:calc(var(--spacing)*8)}.top-\[2px\]{top:2px}.top-\[3px\]{top:3px}.top-\[52px\]{top:52px}.top-full{top:100%}.-right-1{right:calc(var(--spacing)*-1)}.-right-1\.5{right:calc(var(--spacing)*-1.5)}.right-0{right:calc(var(--spacing)*0)}.right-1{right:calc(var(--spacing)*1)}.right-1\.5{right:calc(var(--spacing)*1.5)}.right-2{right:calc(var(--spacing)*2)}.right-3{right:calc(var(--spacing)*3)}.right-4{right:calc(var(--spacing)*4)}.right-6{right:calc(var(--spacing)*6)}.right-12{right:calc(var(--spacing)*12)}.right-\[5\.5rem\]{right:5.5rem}.right-full{right:100%}.-bottom-1{bottom:calc(var(--spacing)*-1)}.-bottom-2{bottom:calc(var(--spacing)*-2)}.-bottom-7{bottom:calc(var(--spacing)*-7)}.bottom-0{bottom:calc(var(--spacing)*0)}.bottom-1{bottom:calc(var(--spacing)*1)}.bottom-2{bottom:calc(var(--spacing)*2)}.bottom-3{bottom:calc(var(--spacing)*3)}.bottom-4{bottom:calc(var(--spacing)*4)}.bottom-6{bottom:calc(var(--spacing)*6)}.bottom-8{bottom:calc(var(--spacing)*8)}.bottom-full{bottom:100%}.-left-2{left:calc(var(--spacing)*-2)}.left-0{left:calc(var(--spacing)*0)}.left-1{left:calc(var(--spacing)*1)}.left-1\/2{left:50%}.left-2{left:calc(var(--spacing)*2)}.left-2\.5{left:calc(var(--spacing)*2.5)}.left-3{left:calc(var(--spacing)*3)}.left-4{left:calc(var(--spacing)*4)}.left-10{left:calc(var(--spacing)*10)}.left-12{left:calc(var(--spacing)*12)}.left-\[2px\]{left:2px}.left-\[3px\]{left:3px}.left-full{left:100%}.z-0{z-index:0}.z-10{z-index:10}.z-20{z-index:20}.z-30{z-index:30}.z-40{z-index:40}.z-50{z-index:50}.z-60,.z-\[60\]{z-index:60}.z-\[100\]{z-index:100}.col-span-1{grid-column:span 1/span 1}.col-span-2{grid-column:span 2/span 2}.col-span-3{grid-column:span 3/span 3}.col-span-4{grid-column:span 4/span 4}.container{width:100%}@media(min-width:40rem){.container{max-width:40rem}}@media(min-width:48rem){.container{max-width:48rem}}@media(min-width:64rem){.container{max-width:64rem}}@media(min-width:80rem){.container{max-width:80rem}}@media(min-width:96rem){.container{max-width:96rem}}.-m-4{margin:calc(var(--spacing)*-4)}.-mx-4{margin-inline:calc(var(--spacing)*-4)}.mx-1{margin-inline:calc(var(--spacing)*1)}.mx-2{margin-inline:calc(var(--spacing)*2)}.mx-4{margin-inline:calc(var(--spacing)*4)}.mx-auto{margin-inline:auto}.my-1{margin-block:calc(var(--spacing)*1)}.my-8{margin-block:calc(var(--spacing)*8)}.-mt-2{margin-top:calc(var(--spacing)*-2)}.mt-0\.5{margin-top:calc(var(--spacing)*.5)}.mt-1{margin-top:calc(var(--spacing)*1)}.mt-1\.5{margin-top:calc(var(--spacing)*1.5)}.mt-2{margin-top:calc(var(--spacing)*2)}.mt-3{margin-top:calc(var(--spacing)*3)}.mt-4{margin-top:calc(var(--spacing)*4)}.mt-6{margin-top:calc(var(--spacing)*6)}.mt-8{margin-top:calc(var(--spacing)*8)}.mt-14{margin-top:calc(var(--spacing)*14)}.mt-auto{margin-top:auto}.mr-1{margin-right:calc(var(--spacing)*1)}.mr-2{margin-right:calc(var(--spacing)*2)}.mr-3{margin-right:calc(var(--spacing)*3)}.mr-4{margin-right:calc(var(--spacing)*4)}.mr-auto{margin-right:auto}.-mb-px{margin-bottom:-1px}.mb-0\.5{margin-bottom:calc(var(--spacing)*.5)}.mb-1{margin-bottom:calc(var(--spacing)*1)}.mb-1\.5{margin-bottom:calc(var(--spacing)*1.5)}.mb-2{margin-bottom:calc(var(--spacing)*2)}.mb-3{margin-bottom:calc(var(--spacing)*3)}.mb-4{margin-bottom:calc(var(--spacing)*4)}.mb-5{margin-bottom:calc(var(--spacing)*5)}.mb-6{margin-bottom:calc(var(--spacing)*6)}.mb-8{margin-bottom:calc(var(--spacing)*8)}.-ml-1{margin-left:calc(var(--spacing)*-1)}.-ml-2{margin-left:calc(var(--spacing)*-2)}.ml-0\.5{margin-left:calc(var(--spacing)*.5)}.ml-1{margin-left:calc(var(--spacing)*1)}.ml-1\.5{margin-left:calc(var(--spacing)*1.5)}.ml-2{margin-left:calc(var(--spacing)*2)}.ml-3{margin-left:calc(var(--spacing)*3)}.ml-4{margin-left:calc(var(--spacing)*4)}.ml-6{margin-left:calc(var(--spacing)*6)}.ml-7{margin-left:calc(var(--spacing)*7)}.ml-9{margin-left:calc(var(--spacing)*9)}.ml-14{margin-left:calc(var(--spacing)*14)}.ml-16{margin-left:calc(var(--spacing)*16)}.ml-64{margin-left:calc(var(--spacing)*64)}.ml-auto{margin-left:auto}.line-clamp-1{-webkit-line-clamp:1;-webkit-box-orient:vertical;display:-webkit-box;overflow:hidden}.block{display:block}.flex{display:flex}.grid{display:grid}.hidden{display:none}.inline{display:inline}.inline-block{display:inline-block}.inline-flex{display:inline-flex}.table{display:table}.aspect-square{aspect-ratio:1}.aspect-video{aspect-ratio:var(--aspect-video)}.h-0{height:calc(var(--spacing)*0)}.h-0\.5{height:calc(var(--spacing)*.5)}.h-1{height:calc(var(--spacing)*1)}.h-1\.5{height:calc(var(--spacing)*1.5)}.h-2{height:calc(var(--spacing)*2)}.h-2\.5{height:calc(var(--spacing)*2.5)}.h-3{height:calc(var(--spacing)*3)}.h-3\.5{height:calc(var(--spacing)*3.5)}.h-4{height:calc(var(--spacing)*4)}.h-5{height:calc(var(--spacing)*5)}.h-6{height:calc(var(--spacing)*6)}.h-7{height:calc(var(--spacing)*7)}.h-8{height:calc(var(--spacing)*8)}.h-10{height:calc(var(--spacing)*10)}.h-12{height:calc(var(--spacing)*12)}.h-14{height:calc(var(--spacing)*14)}.h-16{height:calc(var(--spacing)*16)}.h-20{height:calc(var(--spacing)*20)}.h-24{height:calc(var(--spacing)*24)}.h-48{height:calc(var(--spacing)*48)}.h-64{height:calc(var(--spacing)*64)}.h-80{height:calc(var(--spacing)*80)}.h-\[18px\]{height:18px}.h-\[38px\]{height:38px}.h-\[80vh\]{height:80vh}.h-\[160px\]{height:160px}.h-\[300px\]{height:300px}.h-\[calc\(100\%-40px\)\]{height:calc(100% - 40px)}.h-full{height:100%}.h-px{height:1px}.max-h-40{max-height:calc(var(--spacing)*40)}.max-h-48{max-height:calc(var(--spacing)*48)}.max-h-60{max-height:calc(var(--spacing)*60)}.max-h-64{max-height:calc(var(--spacing)*64)}.max-h-80{max-height:calc(var(--spacing)*80)}.max-h-96{max-height:calc(var(--spacing)*96)}.max-h-\[60vh\]{max-height:60vh}.max-h-\[80vh\]{max-height:80vh}.max-h-\[85vh\]{max-height:85vh}.max-h-\[90vh\]{max-height:90vh}.max-h-\[300px\]{max-height:300px}.max-h-\[400px\]{max-height:400px}.max-h-\[500px\]{max-height:500px}.max-h-\[600px\]{max-height:600px}.max-h-\[calc\(90vh-80px\)\]{max-height:calc(90vh - 80px)}.max-h-\[calc\(100vh-320px\)\]{max-height:calc(100vh - 320px)}.max-h-full{max-height:100%}.min-h-0{min-height:calc(var(--spacing)*0)}.min-h-\[44px\]{min-height:44px}.min-h-\[48px\]{min-height:48px}.min-h-\[80px\]{min-height:80px}.min-h-\[120px\]{min-height:120px}.min-h-\[300px\]{min-height:300px}.min-h-\[400px\]{min-height:400px}.min-h-\[calc\(100vh-64px\)\]{min-height:calc(100vh - 64px)}.min-h-full{min-height:100%}.min-h-screen{min-height:100vh}.w-0{width:calc(var(--spacing)*0)}.w-0\.5{width:calc(var(--spacing)*.5)}.w-1{width:calc(var(--spacing)*1)}.w-1\.5{width:calc(var(--spacing)*1.5)}.w-1\/3{width:33.3333%}.w-2{width:calc(var(--spacing)*2)}.w-2\.5{width:calc(var(--spacing)*2.5)}.w-3{width:calc(var(--spacing)*3)}.w-3\.5{width:calc(var(--spacing)*3.5)}.w-4{width:calc(var(--spacing)*4)}.w-4\.5{width:calc(var(--spacing)*4.5)}.w-5{width:calc(var(--spacing)*5)}.w-6{width:calc(var(--spacing)*6)}.w-7{width:calc(var(--spacing)*7)}.w-8{width:calc(var(--spacing)*8)}.w-9{width:calc(var(--spacing)*9)}.w-10{width:calc(var(--spacing)*10)}.w-11{width:calc(var(--spacing)*11)}.w-12{width:calc(var(--spacing)*12)}.w-14{width:calc(var(--spacing)*14)}.w-16{width:calc(var(--spacing)*16)}.w-20{width:calc(var(--spacing)*20)}.w-24{width:calc(var(--spacing)*24)}.w-32{width:calc(var(--spacing)*32)}.w-36{width:calc(var(--spacing)*36)}.w-40{width:calc(var(--spacing)*40)}.w-44{width:calc(var(--spacing)*44)}.w-48{width:calc(var(--spacing)*48)}.w-52{width:calc(var(--spacing)*52)}.w-56{width:calc(var(--spacing)*56)}.w-64{width:calc(var(--spacing)*64)}.w-72{width:calc(var(--spacing)*72)}.w-96{width:calc(var(--spacing)*96)}.w-\[560px\]{width:560px}.w-auto{width:auto}.w-fit{width:fit-content}.w-full{width:100%}.w-px{width:1px}.max-w-2xl{max-width:var(--container-2xl)}.max-w-3xl{max-width:var(--container-3xl)}.max-w-4xl{max-width:var(--container-4xl)}.max-w-5xl{max-width:var(--container-5xl)}.max-w-6xl{max-width:var(--container-6xl)}.max-w-32{max-width:calc(var(--spacing)*32)}.max-w-\[40\%\]{max-width:40%}.max-w-\[50\%\]{max-width:50%}.max-w-\[80px\]{max-width:80px}.max-w-\[90vw\]{max-width:90vw}.max-w-\[100px\]{max-width:100px}.max-w-\[120px\]{max-width:120px}.max-w-\[150px\]{max-width:150px}.max-w-\[160px\]{max-width:160px}.max-w-\[200px\]{max-width:200px}.max-w-\[280px\]{max-width:280px}.max-w-\[600px\]{max-width:600px}.max-w-full{max-width:100%}.max-w-lg{max-width:var(--container-lg)}.max-w-md{max-width:var(--container-md)}.max-w-none{max-width:none}.max-w-sm{max-width:var(--container-sm)}.max-w-xs{max-width:var(--container-xs)}.min-w-0{min-width:calc(var(--spacing)*0)}.min-w-48{min-width:calc(var(--spacing)*48)}.min-w-\[16px\]{min-width:16px}.min-w-\[18px\]{min-width:18px}.min-w-\[32px\]{min-width:32px}.min-w-\[40px\]{min-width:40px}.min-w-\[48px\]{min-width:48px}.min-w-\[80px\]{min-width:80px}.min-w-\[100px\]{min-width:100px}.min-w-\[120px\]{min-width:120px}.min-w-\[140px\]{min-width:140px}.min-w-\[150px\]{min-width:150px}.min-w-\[160px\]{min-width:160px}.min-w-\[180px\]{min-width:180px}.min-w-\[200px\]{min-width:200px}.min-w-full{min-width:100%}.flex-1{flex:1}.flex-\[2_1_190px\]{flex:2 190px}.flex-shrink{flex-shrink:1}.flex-shrink-0,.shrink-0{flex-shrink:0}.-translate-x-1\/2{--tw-translate-x: -50% ;translate:var(--tw-translate-x)var(--tw-translate-y)}.-translate-x-full{--tw-translate-x:-100%;translate:var(--tw-translate-x)var(--tw-translate-y)}.translate-x-0{--tw-translate-x:calc(var(--spacing)*0);translate:var(--tw-translate-x)var(--tw-translate-y)}.translate-x-0\.5{--tw-translate-x:calc(var(--spacing)*.5);translate:var(--tw-translate-x)var(--tw-translate-y)}.translate-x-1{--tw-translate-x:calc(var(--spacing)*1);translate:var(--tw-translate-x)var(--tw-translate-y)}.translate-x-3\.5{--tw-translate-x:calc(var(--spacing)*3.5);translate:var(--tw-translate-x)var(--tw-translate-y)}.translate-x-4{--tw-translate-x:calc(var(--spacing)*4);translate:var(--tw-translate-x)var(--tw-translate-y)}.translate-x-5{--tw-translate-x:calc(var(--spacing)*5);translate:var(--tw-translate-x)var(--tw-translate-y)}.translate-x-6{--tw-translate-x:calc(var(--spacing)*6);translate:var(--tw-translate-x)var(--tw-translate-y)}.-translate-y-1\/2{--tw-translate-y: -50% ;translate:var(--tw-translate-x)var(--tw-translate-y)}.scale-105{--tw-scale-x:105%;--tw-scale-y:105%;--tw-scale-z:105%;scale:var(--tw-scale-x)var(--tw-scale-y)}.scale-110{--tw-scale-x:110%;--tw-scale-y:110%;--tw-scale-z:110%;scale:var(--tw-scale-x)var(--tw-scale-y)}.scale-\[1\.02\]{scale:1.02}.-rotate-90{rotate:-90deg}.rotate-90{rotate:90deg}.rotate-180{rotate:180deg}.transform{transform:var(--tw-rotate-x,)var(--tw-rotate-y,)var(--tw-rotate-z,)var(--tw-skew-x,)var(--tw-skew-y,)}.animate-pulse{animation:var(--animate-pulse)}.animate-spin{animation:var(--animate-spin)}.cursor-col-resize{cursor:col-resize}.cursor-default{cursor:default}.cursor-ew-resize{cursor:ew-resize}.cursor-grab{cursor:grab}.cursor-not-allowed{cursor:not-allowed}.cursor-pointer{cursor:pointer}.cursor-row-resize{cursor:row-resize}.cursor-se-resize{cursor:se-resize}.touch-manipulation{touch-action:manipulation}.resize{resize:both}.resize-none{resize:none}.resize-y{resize:vertical}.list-inside{list-style-position:inside}.list-decimal{list-style-type:decimal}.list-disc{list-style-type:disc}.appearance-none{appearance:none}.grid-cols-1{grid-template-columns:repeat(1,minmax(0,1fr))}.grid-cols-2{grid-template-columns:repeat(2,minmax(0,1fr))}.grid-cols-3{grid-template-columns:repeat(3,minmax(0,1fr))}.grid-cols-4{grid-template-columns:repeat(4,minmax(0,1fr))}.grid-cols-5{grid-template-columns:repeat(5,minmax(0,1fr))}.grid-cols-7{grid-template-columns:repeat(7,minmax(0,1fr))}.grid-cols-12{grid-template-columns:repeat(12,minmax(0,1fr))}.grid-cols-\[auto_1fr_100px_100px_100px_80px\]{grid-template-columns:auto 1fr 100px 100px 100px 80px}.grid-cols-\[auto_1fr_120px_100px_100px_100px_80px\]{grid-template-columns:auto 1fr 120px 100px 100px 100px 80px}.flex-col{flex-direction:column}.flex-row{flex-direction:row}.flex-wrap{flex-wrap:wrap}.items-center{align-items:center}.items-end{align-items:flex-end}.items-start{align-items:flex-start}.items-stretch{align-items:stretch}.justify-between{justify-content:space-between}.justify-center{justify-content:center}.justify-end{justify-content:flex-end}.gap-0{gap:calc(var(--spacing)*0)}.gap-0\.5{gap:calc(var(--spacing)*.5)}.gap-1{gap:calc(var(--spacing)*1)}.gap-1\.5{gap:calc(var(--spacing)*1.5)}.gap-2{gap:calc(var(--spacing)*2)}.gap-3{gap:calc(var(--spacing)*3)}.gap-4{gap:calc(var(--spacing)*4)}.gap-6{gap:calc(var(--spacing)*6)}.gap-8{gap:calc(var(--spacing)*8)}.gap-\[3px\]{gap:3px}:where(.space-y-0\.5>:not(:last-child)){--tw-space-y-reverse:0;margin-block-start:calc(calc(var(--spacing)*.5)*var(--tw-space-y-reverse));margin-block-end:calc(calc(var(--spacing)*.5)*calc(1 - var(--tw-space-y-reverse)))}:where(.space-y-1>:not(:last-child)){--tw-space-y-reverse:0;margin-block-start:calc(calc(var(--spacing)*1)*var(--tw-space-y-reverse));margin-block-end:calc(calc(var(--spacing)*1)*calc(1 - var(--tw-space-y-reverse)))}:where(.space-y-1\.5>:not(:last-child)){--tw-space-y-reverse:0;margin-block-start:calc(calc(var(--spacing)*1.5)*var(--tw-space-y-reverse));margin-block-end:calc(calc(var(--spacing)*1.5)*calc(1 - var(--tw-space-y-reverse)))}:where(.space-y-2>:not(:last-child)){--tw-space-y-reverse:0;margin-block-start:calc(calc(var(--spacing)*2)*var(--tw-space-y-reverse));margin-block-end:calc(calc(var(--spacing)*2)*calc(1 - var(--tw-space-y-reverse)))}:where(.space-y-2\.5>:not(:last-child)){--tw-space-y-reverse:0;margin-block-start:calc(calc(var(--spacing)*2.5)*var(--tw-space-y-reverse));margin-block-end:calc(calc(var(--spacing)*2.5)*calc(1 - var(--tw-space-y-reverse)))}:where(.space-y-3>:not(:last-child)){--tw-space-y-reverse:0;margin-block-start:calc(calc(var(--spacing)*3)*var(--tw-space-y-reverse));margin-block-end:calc(calc(var(--spacing)*3)*calc(1 - var(--tw-space-y-reverse)))}:where(.space-y-4>:not(:last-child)){--tw-space-y-reverse:0;margin-block-start:calc(calc(var(--spacing)*4)*var(--tw-space-y-reverse));margin-block-end:calc(calc(var(--spacing)*4)*calc(1 - var(--tw-space-y-reverse)))}:where(.space-y-6>:not(:last-child)){--tw-space-y-reverse:0;margin-block-start:calc(calc(var(--spacing)*6)*var(--tw-space-y-reverse));margin-block-end:calc(calc(var(--spacing)*6)*calc(1 - var(--tw-space-y-reverse)))}:where(.space-y-8>:not(:last-child)){--tw-space-y-reverse:0;margin-block-start:calc(calc(var(--spacing)*8)*var(--tw-space-y-reverse));margin-block-end:calc(calc(var(--spacing)*8)*calc(1 - var(--tw-space-y-reverse)))}.gap-x-3{column-gap:calc(var(--spacing)*3)}.gap-x-4{column-gap:calc(var(--spacing)*4)}.gap-x-6{column-gap:calc(var(--spacing)*6)}.gap-y-1{row-gap:calc(var(--spacing)*1)}.gap-y-2{row-gap:calc(var(--spacing)*2)}.gap-y-3{row-gap:calc(var(--spacing)*3)}:where(.divide-y>:not(:last-child)){--tw-divide-y-reverse:0;border-bottom-style:var(--tw-border-style);border-top-style:var(--tw-border-style);border-top-width:calc(1px*var(--tw-divide-y-reverse));border-bottom-width:calc(1px*calc(1 - var(--tw-divide-y-reverse)))}:where(.divide-bambu-dark-tertiary>:not(:last-child)),:where(.divide-bambu-dark-tertiary\/30>:not(:last-child)){border-color:var(--color-bambu-dark-tertiary)}@supports (color:color-mix(in lab,red,red)){:where(.divide-bambu-dark-tertiary\/30>:not(:last-child)){border-color:color-mix(in oklab,var(--color-bambu-dark-tertiary)30%,transparent)}}:where(.divide-bambu-gray\/20>:not(:last-child)){border-color:var(--color-bambu-gray)}@supports (color:color-mix(in lab,red,red)){:where(.divide-bambu-gray\/20>:not(:last-child)){border-color:color-mix(in oklab,var(--color-bambu-gray)20%,transparent)}}.truncate{text-overflow:ellipsis;white-space:nowrap;overflow:hidden}.overflow-auto{overflow:auto}.overflow-hidden{overflow:hidden}.overflow-x-auto{overflow-x:auto}.overflow-y-auto{overflow-y:auto}.rounded{border-radius:.25rem}.rounded-2xl{border-radius:var(--radius-2xl)}.rounded-full{border-radius:3.40282e38px}.rounded-lg{border-radius:var(--radius-lg)}.rounded-md{border-radius:var(--radius-md)}.rounded-none{border-radius:0}.rounded-sm{border-radius:var(--radius-sm)}.rounded-xl{border-radius:var(--radius-xl)}.rounded-t-lg{border-top-left-radius:var(--radius-lg);border-top-right-radius:var(--radius-lg)}.rounded-t-xl{border-top-left-radius:var(--radius-xl);border-top-right-radius:var(--radius-xl)}.\!rounded-l-none{border-top-left-radius:0!important;border-bottom-left-radius:0!important}.rounded-l{border-top-left-radius:.25rem;border-bottom-left-radius:.25rem}.rounded-l-lg{border-top-left-radius:var(--radius-lg);border-bottom-left-radius:var(--radius-lg)}.rounded-tl{border-top-left-radius:.25rem}.\!rounded-r-none{border-top-right-radius:0!important;border-bottom-right-radius:0!important}.rounded-r{border-top-right-radius:.25rem;border-bottom-right-radius:.25rem}.rounded-r-lg{border-top-right-radius:var(--radius-lg);border-bottom-right-radius:var(--radius-lg)}.rounded-b-lg{border-bottom-right-radius:var(--radius-lg);border-bottom-left-radius:var(--radius-lg)}.border{border-style:var(--tw-border-style);border-width:1px}.border-0{border-style:var(--tw-border-style);border-width:0}.border-2{border-style:var(--tw-border-style);border-width:2px}.border-4{border-style:var(--tw-border-style);border-width:4px}.border-t{border-top-style:var(--tw-border-style);border-top-width:1px}.border-t-\[5px\]{border-top-style:var(--tw-border-style);border-top-width:5px}.border-t-\[6px\]{border-top-style:var(--tw-border-style);border-top-width:6px}.\!border-r-0{border-right-style:var(--tw-border-style)!important;border-right-width:0!important}.border-r{border-right-style:var(--tw-border-style);border-right-width:1px}.border-r-\[5px\]{border-right-style:var(--tw-border-style);border-right-width:5px}.border-r-\[6px\]{border-right-style:var(--tw-border-style);border-right-width:6px}.border-b{border-bottom-style:var(--tw-border-style);border-bottom-width:1px}.border-b-2{border-bottom-style:var(--tw-border-style);border-bottom-width:2px}.border-b-\[6px\]{border-bottom-style:var(--tw-border-style);border-bottom-width:6px}.border-l{border-left-style:var(--tw-border-style);border-left-width:1px}.border-l-2{border-left-style:var(--tw-border-style);border-left-width:2px}.border-l-4{border-left-style:var(--tw-border-style);border-left-width:4px}.border-l-\[5px\]{border-left-style:var(--tw-border-style);border-left-width:5px}.border-l-\[6px\]{border-left-style:var(--tw-border-style);border-left-width:6px}.border-dashed{--tw-border-style:dashed;border-style:dashed}.\!border-green-500{border-color:var(--color-green-500)!important}.border-amber-500\/20{border-color:#f99c0033}@supports (color:color-mix(in lab,red,red)){.border-amber-500\/20{border-color:color-mix(in oklab,var(--color-amber-500)20%,transparent)}}.border-amber-500\/30{border-color:#f99c004d}@supports (color:color-mix(in lab,red,red)){.border-amber-500\/30{border-color:color-mix(in oklab,var(--color-amber-500)30%,transparent)}}.border-bambu-dark-tertiary,.border-bambu-dark-tertiary\/20{border-color:var(--color-bambu-dark-tertiary)}@supports (color:color-mix(in lab,red,red)){.border-bambu-dark-tertiary\/20{border-color:color-mix(in oklab,var(--color-bambu-dark-tertiary)20%,transparent)}}.border-bambu-dark-tertiary\/30{border-color:var(--color-bambu-dark-tertiary)}@supports (color:color-mix(in lab,red,red)){.border-bambu-dark-tertiary\/30{border-color:color-mix(in oklab,var(--color-bambu-dark-tertiary)30%,transparent)}}.border-bambu-dark-tertiary\/40{border-color:var(--color-bambu-dark-tertiary)}@supports (color:color-mix(in lab,red,red)){.border-bambu-dark-tertiary\/40{border-color:color-mix(in oklab,var(--color-bambu-dark-tertiary)40%,transparent)}}.border-bambu-dark-tertiary\/50{border-color:var(--color-bambu-dark-tertiary)}@supports (color:color-mix(in lab,red,red)){.border-bambu-dark-tertiary\/50{border-color:color-mix(in oklab,var(--color-bambu-dark-tertiary)50%,transparent)}}.border-bambu-gray,.border-bambu-gray\/20{border-color:var(--color-bambu-gray)}@supports (color:color-mix(in lab,red,red)){.border-bambu-gray\/20{border-color:color-mix(in oklab,var(--color-bambu-gray)20%,transparent)}}.border-bambu-gray\/30{border-color:var(--color-bambu-gray)}@supports (color:color-mix(in lab,red,red)){.border-bambu-gray\/30{border-color:color-mix(in oklab,var(--color-bambu-gray)30%,transparent)}}.border-bambu-gray\/50{border-color:var(--color-bambu-gray)}@supports (color:color-mix(in lab,red,red)){.border-bambu-gray\/50{border-color:color-mix(in oklab,var(--color-bambu-gray)50%,transparent)}}.border-bambu-green,.border-bambu-green\/20{border-color:var(--color-bambu-green)}@supports (color:color-mix(in lab,red,red)){.border-bambu-green\/20{border-color:color-mix(in oklab,var(--color-bambu-green)20%,transparent)}}.border-bambu-green\/30{border-color:var(--color-bambu-green)}@supports (color:color-mix(in lab,red,red)){.border-bambu-green\/30{border-color:color-mix(in oklab,var(--color-bambu-green)30%,transparent)}}.border-bambu-green\/40{border-color:var(--color-bambu-green)}@supports (color:color-mix(in lab,red,red)){.border-bambu-green\/40{border-color:color-mix(in oklab,var(--color-bambu-green)40%,transparent)}}.border-bambu-green\/50{border-color:var(--color-bambu-green)}@supports (color:color-mix(in lab,red,red)){.border-bambu-green\/50{border-color:color-mix(in oklab,var(--color-bambu-green)50%,transparent)}}.border-blue-400\/20{border-color:#54a2ff33}@supports (color:color-mix(in lab,red,red)){.border-blue-400\/20{border-color:color-mix(in oklab,var(--color-blue-400)20%,transparent)}}.border-blue-500{border-color:var(--color-blue-500)}.border-blue-500\/20{border-color:#3080ff33}@supports (color:color-mix(in lab,red,red)){.border-blue-500\/20{border-color:color-mix(in oklab,var(--color-blue-500)20%,transparent)}}.border-blue-500\/30{border-color:#3080ff4d}@supports (color:color-mix(in lab,red,red)){.border-blue-500\/30{border-color:color-mix(in oklab,var(--color-blue-500)30%,transparent)}}.border-blue-500\/50{border-color:#3080ff80}@supports (color:color-mix(in lab,red,red)){.border-blue-500\/50{border-color:color-mix(in oklab,var(--color-blue-500)50%,transparent)}}.border-gray-200{border-color:var(--color-gray-200)}.border-gray-300{border-color:var(--color-gray-300)}.border-gray-400\/20{border-color:#99a1af33}@supports (color:color-mix(in lab,red,red)){.border-gray-400\/20{border-color:color-mix(in oklab,var(--color-gray-400)20%,transparent)}}.border-gray-500\/20{border-color:#6a728233}@supports (color:color-mix(in lab,red,red)){.border-gray-500\/20{border-color:color-mix(in oklab,var(--color-gray-500)20%,transparent)}}.border-gray-700{border-color:var(--color-gray-700)}.border-green-300{border-color:var(--color-green-300)}.border-green-500\/30{border-color:#00c7584d}@supports (color:color-mix(in lab,red,red)){.border-green-500\/30{border-color:color-mix(in oklab,var(--color-green-500)30%,transparent)}}.border-green-500\/50{border-color:#00c75880}@supports (color:color-mix(in lab,red,red)){.border-green-500\/50{border-color:color-mix(in oklab,var(--color-green-500)50%,transparent)}}.border-orange-400\/20{border-color:#ff8b1a33}@supports (color:color-mix(in lab,red,red)){.border-orange-400\/20{border-color:color-mix(in oklab,var(--color-orange-400)20%,transparent)}}.border-orange-400\/50{border-color:#ff8b1a80}@supports (color:color-mix(in lab,red,red)){.border-orange-400\/50{border-color:color-mix(in oklab,var(--color-orange-400)50%,transparent)}}.border-orange-500\/20{border-color:#fe6e0033}@supports (color:color-mix(in lab,red,red)){.border-orange-500\/20{border-color:color-mix(in oklab,var(--color-orange-500)20%,transparent)}}.border-orange-500\/30{border-color:#fe6e004d}@supports (color:color-mix(in lab,red,red)){.border-orange-500\/30{border-color:color-mix(in oklab,var(--color-orange-500)30%,transparent)}}.border-purple-400\/20{border-color:#c07eff33}@supports (color:color-mix(in lab,red,red)){.border-purple-400\/20{border-color:color-mix(in oklab,var(--color-purple-400)20%,transparent)}}.border-purple-500\/20{border-color:#ac4bff33}@supports (color:color-mix(in lab,red,red)){.border-purple-500\/20{border-color:color-mix(in oklab,var(--color-purple-500)20%,transparent)}}.border-purple-500\/30{border-color:#ac4bff4d}@supports (color:color-mix(in lab,red,red)){.border-purple-500\/30{border-color:color-mix(in oklab,var(--color-purple-500)30%,transparent)}}.border-red-300{border-color:var(--color-red-300)}.border-red-500{border-color:var(--color-red-500)}.border-red-500\/20{border-color:#fb2c3633}@supports (color:color-mix(in lab,red,red)){.border-red-500\/20{border-color:color-mix(in oklab,var(--color-red-500)20%,transparent)}}.border-red-500\/30{border-color:#fb2c364d}@supports (color:color-mix(in lab,red,red)){.border-red-500\/30{border-color:color-mix(in oklab,var(--color-red-500)30%,transparent)}}.border-red-500\/50{border-color:#fb2c3680}@supports (color:color-mix(in lab,red,red)){.border-red-500\/50{border-color:color-mix(in oklab,var(--color-red-500)50%,transparent)}}.border-red-800\/70{border-color:#9f0712b3}@supports (color:color-mix(in lab,red,red)){.border-red-800\/70{border-color:color-mix(in oklab,var(--color-red-800)70%,transparent)}}.border-slate-500{border-color:var(--color-slate-500)}.border-status-error\/20{border-color:var(--color-status-error)}@supports (color:color-mix(in lab,red,red)){.border-status-error\/20{border-color:color-mix(in oklab,var(--color-status-error)20%,transparent)}}.border-status-ok,.border-status-ok\/20{border-color:var(--color-status-ok)}@supports (color:color-mix(in lab,red,red)){.border-status-ok\/20{border-color:color-mix(in oklab,var(--color-status-ok)20%,transparent)}}.border-status-warning\/20{border-color:var(--color-status-warning)}@supports (color:color-mix(in lab,red,red)){.border-status-warning\/20{border-color:color-mix(in oklab,var(--color-status-warning)20%,transparent)}}.border-transparent{border-color:#0000}.border-white\/10{border-color:#ffffff1a}@supports (color:color-mix(in lab,red,red)){.border-white\/10{border-color:color-mix(in oklab,var(--color-white)10%,transparent)}}.border-white\/20{border-color:#fff3}@supports (color:color-mix(in lab,red,red)){.border-white\/20{border-color:color-mix(in oklab,var(--color-white)20%,transparent)}}.border-white\/30{border-color:#ffffff4d}@supports (color:color-mix(in lab,red,red)){.border-white\/30{border-color:color-mix(in oklab,var(--color-white)30%,transparent)}}.border-yellow-400\/20{border-color:#fac80033}@supports (color:color-mix(in lab,red,red)){.border-yellow-400\/20{border-color:color-mix(in oklab,var(--color-yellow-400)20%,transparent)}}.border-yellow-400\/30{border-color:#fac8004d}@supports (color:color-mix(in lab,red,red)){.border-yellow-400\/30{border-color:color-mix(in oklab,var(--color-yellow-400)30%,transparent)}}.border-yellow-400\/50{border-color:#fac80080}@supports (color:color-mix(in lab,red,red)){.border-yellow-400\/50{border-color:color-mix(in oklab,var(--color-yellow-400)50%,transparent)}}.border-yellow-500{border-color:var(--color-yellow-500)}.border-yellow-500\/20{border-color:#edb20033}@supports (color:color-mix(in lab,red,red)){.border-yellow-500\/20{border-color:color-mix(in oklab,var(--color-yellow-500)20%,transparent)}}.border-yellow-500\/30{border-color:#edb2004d}@supports (color:color-mix(in lab,red,red)){.border-yellow-500\/30{border-color:color-mix(in oklab,var(--color-yellow-500)30%,transparent)}}.border-yellow-500\/50{border-color:#edb20080}@supports (color:color-mix(in lab,red,red)){.border-yellow-500\/50{border-color:color-mix(in oklab,var(--color-yellow-500)50%,transparent)}}.border-t-bambu-dark-tertiary{border-top-color:var(--color-bambu-dark-tertiary)}.border-t-transparent{border-top-color:#0000}.border-r-transparent{border-right-color:#0000}.border-b-bambu-dark-tertiary{border-bottom-color:var(--color-bambu-dark-tertiary)}.border-l-transparent{border-left-color:#0000}.border-l-yellow-500{border-left-color:var(--color-yellow-500)}.bg-amber-50{background-color:var(--color-amber-50)}.bg-amber-500{background-color:var(--color-amber-500)}.bg-amber-500\/5{background-color:#f99c000d}@supports (color:color-mix(in lab,red,red)){.bg-amber-500\/5{background-color:color-mix(in oklab,var(--color-amber-500)5%,transparent)}}.bg-amber-500\/10{background-color:#f99c001a}@supports (color:color-mix(in lab,red,red)){.bg-amber-500\/10{background-color:color-mix(in oklab,var(--color-amber-500)10%,transparent)}}.bg-amber-500\/20{background-color:#f99c0033}@supports (color:color-mix(in lab,red,red)){.bg-amber-500\/20{background-color:color-mix(in oklab,var(--color-amber-500)20%,transparent)}}.bg-amber-600\/20{background-color:#dd740033}@supports (color:color-mix(in lab,red,red)){.bg-amber-600\/20{background-color:color-mix(in oklab,var(--color-amber-600)20%,transparent)}}.bg-bambu-dark{background-color:var(--color-bambu-dark)}.bg-bambu-dark-secondary,.bg-bambu-dark-secondary\/30{background-color:var(--color-bambu-dark-secondary)}@supports (color:color-mix(in lab,red,red)){.bg-bambu-dark-secondary\/30{background-color:color-mix(in oklab,var(--color-bambu-dark-secondary)30%,transparent)}}.bg-bambu-dark-secondary\/50{background-color:var(--color-bambu-dark-secondary)}@supports (color:color-mix(in lab,red,red)){.bg-bambu-dark-secondary\/50{background-color:color-mix(in oklab,var(--color-bambu-dark-secondary)50%,transparent)}}.bg-bambu-dark-secondary\/60{background-color:var(--color-bambu-dark-secondary)}@supports (color:color-mix(in lab,red,red)){.bg-bambu-dark-secondary\/60{background-color:color-mix(in oklab,var(--color-bambu-dark-secondary)60%,transparent)}}.bg-bambu-dark-secondary\/90{background-color:var(--color-bambu-dark-secondary)}@supports (color:color-mix(in lab,red,red)){.bg-bambu-dark-secondary\/90{background-color:color-mix(in oklab,var(--color-bambu-dark-secondary)90%,transparent)}}.bg-bambu-dark-secondary\/95{background-color:var(--color-bambu-dark-secondary)}@supports (color:color-mix(in lab,red,red)){.bg-bambu-dark-secondary\/95{background-color:color-mix(in oklab,var(--color-bambu-dark-secondary)95%,transparent)}}.bg-bambu-dark-tertiary,.bg-bambu-dark-tertiary\/20{background-color:var(--color-bambu-dark-tertiary)}@supports (color:color-mix(in lab,red,red)){.bg-bambu-dark-tertiary\/20{background-color:color-mix(in oklab,var(--color-bambu-dark-tertiary)20%,transparent)}}.bg-bambu-dark-tertiary\/30{background-color:var(--color-bambu-dark-tertiary)}@supports (color:color-mix(in lab,red,red)){.bg-bambu-dark-tertiary\/30{background-color:color-mix(in oklab,var(--color-bambu-dark-tertiary)30%,transparent)}}.bg-bambu-dark-tertiary\/40{background-color:var(--color-bambu-dark-tertiary)}@supports (color:color-mix(in lab,red,red)){.bg-bambu-dark-tertiary\/40{background-color:color-mix(in oklab,var(--color-bambu-dark-tertiary)40%,transparent)}}.bg-bambu-dark-tertiary\/50{background-color:var(--color-bambu-dark-tertiary)}@supports (color:color-mix(in lab,red,red)){.bg-bambu-dark-tertiary\/50{background-color:color-mix(in oklab,var(--color-bambu-dark-tertiary)50%,transparent)}}.bg-bambu-dark-tertiary\/70{background-color:var(--color-bambu-dark-tertiary)}@supports (color:color-mix(in lab,red,red)){.bg-bambu-dark-tertiary\/70{background-color:color-mix(in oklab,var(--color-bambu-dark-tertiary)70%,transparent)}}.bg-bambu-dark-tertiary\/80{background-color:var(--color-bambu-dark-tertiary)}@supports (color:color-mix(in lab,red,red)){.bg-bambu-dark-tertiary\/80{background-color:color-mix(in oklab,var(--color-bambu-dark-tertiary)80%,transparent)}}.bg-bambu-dark\/20{background-color:var(--color-bambu-dark)}@supports (color:color-mix(in lab,red,red)){.bg-bambu-dark\/20{background-color:color-mix(in oklab,var(--color-bambu-dark)20%,transparent)}}.bg-bambu-dark\/30{background-color:var(--color-bambu-dark)}@supports (color:color-mix(in lab,red,red)){.bg-bambu-dark\/30{background-color:color-mix(in oklab,var(--color-bambu-dark)30%,transparent)}}.bg-bambu-dark\/50{background-color:var(--color-bambu-dark)}@supports (color:color-mix(in lab,red,red)){.bg-bambu-dark\/50{background-color:color-mix(in oklab,var(--color-bambu-dark)50%,transparent)}}.bg-bambu-dark\/80{background-color:var(--color-bambu-dark)}@supports (color:color-mix(in lab,red,red)){.bg-bambu-dark\/80{background-color:color-mix(in oklab,var(--color-bambu-dark)80%,transparent)}}.bg-bambu-dark\/90{background-color:var(--color-bambu-dark)}@supports (color:color-mix(in lab,red,red)){.bg-bambu-dark\/90{background-color:color-mix(in oklab,var(--color-bambu-dark)90%,transparent)}}.bg-bambu-gray\/10{background-color:var(--color-bambu-gray)}@supports (color:color-mix(in lab,red,red)){.bg-bambu-gray\/10{background-color:color-mix(in oklab,var(--color-bambu-gray)10%,transparent)}}.bg-bambu-gray\/20{background-color:var(--color-bambu-gray)}@supports (color:color-mix(in lab,red,red)){.bg-bambu-gray\/20{background-color:color-mix(in oklab,var(--color-bambu-gray)20%,transparent)}}.bg-bambu-gray\/30{background-color:var(--color-bambu-gray)}@supports (color:color-mix(in lab,red,red)){.bg-bambu-gray\/30{background-color:color-mix(in oklab,var(--color-bambu-gray)30%,transparent)}}.bg-bambu-gray\/50{background-color:var(--color-bambu-gray)}@supports (color:color-mix(in lab,red,red)){.bg-bambu-gray\/50{background-color:color-mix(in oklab,var(--color-bambu-gray)50%,transparent)}}.bg-bambu-gray\/90{background-color:var(--color-bambu-gray)}@supports (color:color-mix(in lab,red,red)){.bg-bambu-gray\/90{background-color:color-mix(in oklab,var(--color-bambu-gray)90%,transparent)}}.bg-bambu-green,.bg-bambu-green\/5{background-color:var(--color-bambu-green)}@supports (color:color-mix(in lab,red,red)){.bg-bambu-green\/5{background-color:color-mix(in oklab,var(--color-bambu-green)5%,transparent)}}.bg-bambu-green\/10{background-color:var(--color-bambu-green)}@supports (color:color-mix(in lab,red,red)){.bg-bambu-green\/10{background-color:color-mix(in oklab,var(--color-bambu-green)10%,transparent)}}.bg-bambu-green\/20{background-color:var(--color-bambu-green)}@supports (color:color-mix(in lab,red,red)){.bg-bambu-green\/20{background-color:color-mix(in oklab,var(--color-bambu-green)20%,transparent)}}.bg-bambu-green\/30{background-color:var(--color-bambu-green)}@supports (color:color-mix(in lab,red,red)){.bg-bambu-green\/30{background-color:color-mix(in oklab,var(--color-bambu-green)30%,transparent)}}.bg-bambu-green\/50{background-color:var(--color-bambu-green)}@supports (color:color-mix(in lab,red,red)){.bg-bambu-green\/50{background-color:color-mix(in oklab,var(--color-bambu-green)50%,transparent)}}.bg-bambu-green\/75{background-color:var(--color-bambu-green)}@supports (color:color-mix(in lab,red,red)){.bg-bambu-green\/75{background-color:color-mix(in oklab,var(--color-bambu-green)75%,transparent)}}.bg-bambu-green\/90{background-color:var(--color-bambu-green)}@supports (color:color-mix(in lab,red,red)){.bg-bambu-green\/90{background-color:color-mix(in oklab,var(--color-bambu-green)90%,transparent)}}.bg-black{background-color:var(--color-black)}.bg-black\/30{background-color:#0000004d}@supports (color:color-mix(in lab,red,red)){.bg-black\/30{background-color:color-mix(in oklab,var(--color-black)30%,transparent)}}.bg-black\/40{background-color:#0006}@supports (color:color-mix(in lab,red,red)){.bg-black\/40{background-color:color-mix(in oklab,var(--color-black)40%,transparent)}}.bg-black\/50{background-color:#00000080}@supports (color:color-mix(in lab,red,red)){.bg-black\/50{background-color:color-mix(in oklab,var(--color-black)50%,transparent)}}.bg-black\/60{background-color:#0009}@supports (color:color-mix(in lab,red,red)){.bg-black\/60{background-color:color-mix(in oklab,var(--color-black)60%,transparent)}}.bg-black\/70{background-color:#000000b3}@supports (color:color-mix(in lab,red,red)){.bg-black\/70{background-color:color-mix(in oklab,var(--color-black)70%,transparent)}}.bg-black\/80{background-color:#000c}@supports (color:color-mix(in lab,red,red)){.bg-black\/80{background-color:color-mix(in oklab,var(--color-black)80%,transparent)}}.bg-black\/90{background-color:#000000e6}@supports (color:color-mix(in lab,red,red)){.bg-black\/90{background-color:color-mix(in oklab,var(--color-black)90%,transparent)}}.bg-blue-50{background-color:var(--color-blue-50)}.bg-blue-100{background-color:var(--color-blue-100)}.bg-blue-400{background-color:var(--color-blue-400)}.bg-blue-400\/10{background-color:#54a2ff1a}@supports (color:color-mix(in lab,red,red)){.bg-blue-400\/10{background-color:color-mix(in oklab,var(--color-blue-400)10%,transparent)}}.bg-blue-500{background-color:var(--color-blue-500)}.bg-blue-500\/5{background-color:#3080ff0d}@supports (color:color-mix(in lab,red,red)){.bg-blue-500\/5{background-color:color-mix(in oklab,var(--color-blue-500)5%,transparent)}}.bg-blue-500\/10{background-color:#3080ff1a}@supports (color:color-mix(in lab,red,red)){.bg-blue-500\/10{background-color:color-mix(in oklab,var(--color-blue-500)10%,transparent)}}.bg-blue-500\/20{background-color:#3080ff33}@supports (color:color-mix(in lab,red,red)){.bg-blue-500\/20{background-color:color-mix(in oklab,var(--color-blue-500)20%,transparent)}}.bg-blue-500\/30{background-color:#3080ff4d}@supports (color:color-mix(in lab,red,red)){.bg-blue-500\/30{background-color:color-mix(in oklab,var(--color-blue-500)30%,transparent)}}.bg-blue-500\/90{background-color:#3080ffe6}@supports (color:color-mix(in lab,red,red)){.bg-blue-500\/90{background-color:color-mix(in oklab,var(--color-blue-500)90%,transparent)}}.bg-blue-600{background-color:var(--color-blue-600)}.bg-blue-600\/20{background-color:#155dfc33}@supports (color:color-mix(in lab,red,red)){.bg-blue-600\/20{background-color:color-mix(in oklab,var(--color-blue-600)20%,transparent)}}.bg-cyan-500{background-color:var(--color-cyan-500)}.bg-cyan-500\/10{background-color:#00b7d71a}@supports (color:color-mix(in lab,red,red)){.bg-cyan-500\/10{background-color:color-mix(in oklab,var(--color-cyan-500)10%,transparent)}}.bg-cyan-500\/20{background-color:#00b7d733}@supports (color:color-mix(in lab,red,red)){.bg-cyan-500\/20{background-color:color-mix(in oklab,var(--color-cyan-500)20%,transparent)}}.bg-cyan-600\/20{background-color:#0092b533}@supports (color:color-mix(in lab,red,red)){.bg-cyan-600\/20{background-color:color-mix(in oklab,var(--color-cyan-600)20%,transparent)}}.bg-emerald-500\/20{background-color:#00bb7f33}@supports (color:color-mix(in lab,red,red)){.bg-emerald-500\/20{background-color:color-mix(in oklab,var(--color-emerald-500)20%,transparent)}}.bg-emerald-700{background-color:var(--color-emerald-700)}.bg-fuchsia-500{background-color:var(--color-fuchsia-500)}.bg-gray-50{background-color:var(--color-gray-50)}.bg-gray-100{background-color:var(--color-gray-100)}.bg-gray-400{background-color:var(--color-gray-400)}.bg-gray-400\/10{background-color:#99a1af1a}@supports (color:color-mix(in lab,red,red)){.bg-gray-400\/10{background-color:color-mix(in oklab,var(--color-gray-400)10%,transparent)}}.bg-gray-500{background-color:var(--color-gray-500)}.bg-gray-500\/20{background-color:#6a728233}@supports (color:color-mix(in lab,red,red)){.bg-gray-500\/20{background-color:color-mix(in oklab,var(--color-gray-500)20%,transparent)}}.bg-gray-800{background-color:var(--color-gray-800)}.bg-gray-900{background-color:var(--color-gray-900)}.bg-green-100{background-color:var(--color-green-100)}.bg-green-400{background-color:var(--color-green-400)}.bg-green-500{background-color:var(--color-green-500)}.bg-green-500\/10{background-color:#00c7581a}@supports (color:color-mix(in lab,red,red)){.bg-green-500\/10{background-color:color-mix(in oklab,var(--color-green-500)10%,transparent)}}.bg-green-500\/20{background-color:#00c75833}@supports (color:color-mix(in lab,red,red)){.bg-green-500\/20{background-color:color-mix(in oklab,var(--color-green-500)20%,transparent)}}.bg-green-900\/50{background-color:#0d542b80}@supports (color:color-mix(in lab,red,red)){.bg-green-900\/50{background-color:color-mix(in oklab,var(--color-green-900)50%,transparent)}}.bg-indigo-500\/20{background-color:#625fff33}@supports (color:color-mix(in lab,red,red)){.bg-indigo-500\/20{background-color:color-mix(in oklab,var(--color-indigo-500)20%,transparent)}}.bg-lime-500{background-color:var(--color-lime-500)}.bg-orange-400\/10{background-color:#ff8b1a1a}@supports (color:color-mix(in lab,red,red)){.bg-orange-400\/10{background-color:color-mix(in oklab,var(--color-orange-400)10%,transparent)}}.bg-orange-500{background-color:var(--color-orange-500)}.bg-orange-500\/10{background-color:#fe6e001a}@supports (color:color-mix(in lab,red,red)){.bg-orange-500\/10{background-color:color-mix(in oklab,var(--color-orange-500)10%,transparent)}}.bg-orange-500\/20{background-color:#fe6e0033}@supports (color:color-mix(in lab,red,red)){.bg-orange-500\/20{background-color:color-mix(in oklab,var(--color-orange-500)20%,transparent)}}.bg-orange-600{background-color:var(--color-orange-600)}.bg-orange-600\/20{background-color:#f0510033}@supports (color:color-mix(in lab,red,red)){.bg-orange-600\/20{background-color:color-mix(in oklab,var(--color-orange-600)20%,transparent)}}.bg-purple-400\/10{background-color:#c07eff1a}@supports (color:color-mix(in lab,red,red)){.bg-purple-400\/10{background-color:color-mix(in oklab,var(--color-purple-400)10%,transparent)}}.bg-purple-500{background-color:var(--color-purple-500)}.bg-purple-500\/10{background-color:#ac4bff1a}@supports (color:color-mix(in lab,red,red)){.bg-purple-500\/10{background-color:color-mix(in oklab,var(--color-purple-500)10%,transparent)}}.bg-purple-500\/20{background-color:#ac4bff33}@supports (color:color-mix(in lab,red,red)){.bg-purple-500\/20{background-color:color-mix(in oklab,var(--color-purple-500)20%,transparent)}}.bg-purple-500\/80{background-color:#ac4bffcc}@supports (color:color-mix(in lab,red,red)){.bg-purple-500\/80{background-color:color-mix(in oklab,var(--color-purple-500)80%,transparent)}}.bg-purple-500\/90{background-color:#ac4bffe6}@supports (color:color-mix(in lab,red,red)){.bg-purple-500\/90{background-color:color-mix(in oklab,var(--color-purple-500)90%,transparent)}}.bg-purple-700{background-color:var(--color-purple-700)}.bg-red-50{background-color:var(--color-red-50)}.bg-red-100{background-color:var(--color-red-100)}.bg-red-400{background-color:var(--color-red-400)}.bg-red-500{background-color:var(--color-red-500)}.bg-red-500\/5{background-color:#fb2c360d}@supports (color:color-mix(in lab,red,red)){.bg-red-500\/5{background-color:color-mix(in oklab,var(--color-red-500)5%,transparent)}}.bg-red-500\/10{background-color:#fb2c361a}@supports (color:color-mix(in lab,red,red)){.bg-red-500\/10{background-color:color-mix(in oklab,var(--color-red-500)10%,transparent)}}.bg-red-500\/15{background-color:#fb2c3626}@supports (color:color-mix(in lab,red,red)){.bg-red-500\/15{background-color:color-mix(in oklab,var(--color-red-500)15%,transparent)}}.bg-red-500\/20{background-color:#fb2c3633}@supports (color:color-mix(in lab,red,red)){.bg-red-500\/20{background-color:color-mix(in oklab,var(--color-red-500)20%,transparent)}}.bg-red-500\/30{background-color:#fb2c364d}@supports (color:color-mix(in lab,red,red)){.bg-red-500\/30{background-color:color-mix(in oklab,var(--color-red-500)30%,transparent)}}.bg-red-500\/40{background-color:#fb2c3666}@supports (color:color-mix(in lab,red,red)){.bg-red-500\/40{background-color:color-mix(in oklab,var(--color-red-500)40%,transparent)}}.bg-red-500\/80{background-color:#fb2c36cc}@supports (color:color-mix(in lab,red,red)){.bg-red-500\/80{background-color:color-mix(in oklab,var(--color-red-500)80%,transparent)}}.bg-red-600{background-color:var(--color-red-600)}.bg-red-950\/70{background-color:#460809b3}@supports (color:color-mix(in lab,red,red)){.bg-red-950\/70{background-color:color-mix(in oklab,var(--color-red-950)70%,transparent)}}.bg-rose-500\/20{background-color:#ff235733}@supports (color:color-mix(in lab,red,red)){.bg-rose-500\/20{background-color:color-mix(in oklab,var(--color-rose-500)20%,transparent)}}.bg-rose-600\/20{background-color:#e7004433}@supports (color:color-mix(in lab,red,red)){.bg-rose-600\/20{background-color:color-mix(in oklab,var(--color-rose-600)20%,transparent)}}.bg-sky-500{background-color:var(--color-sky-500)}.bg-sky-500\/20{background-color:#00a5ef33}@supports (color:color-mix(in lab,red,red)){.bg-sky-500\/20{background-color:color-mix(in oklab,var(--color-sky-500)20%,transparent)}}.bg-status-error,.bg-status-error\/10{background-color:var(--color-status-error)}@supports (color:color-mix(in lab,red,red)){.bg-status-error\/10{background-color:color-mix(in oklab,var(--color-status-error)10%,transparent)}}.bg-status-error\/20{background-color:var(--color-status-error)}@supports (color:color-mix(in lab,red,red)){.bg-status-error\/20{background-color:color-mix(in oklab,var(--color-status-error)20%,transparent)}}.bg-status-error\/80{background-color:var(--color-status-error)}@supports (color:color-mix(in lab,red,red)){.bg-status-error\/80{background-color:color-mix(in oklab,var(--color-status-error)80%,transparent)}}.bg-status-ok,.bg-status-ok\/10{background-color:var(--color-status-ok)}@supports (color:color-mix(in lab,red,red)){.bg-status-ok\/10{background-color:color-mix(in oklab,var(--color-status-ok)10%,transparent)}}.bg-status-ok\/20{background-color:var(--color-status-ok)}@supports (color:color-mix(in lab,red,red)){.bg-status-ok\/20{background-color:color-mix(in oklab,var(--color-status-ok)20%,transparent)}}.bg-status-warning\/10{background-color:var(--color-status-warning)}@supports (color:color-mix(in lab,red,red)){.bg-status-warning\/10{background-color:color-mix(in oklab,var(--color-status-warning)10%,transparent)}}.bg-status-warning\/20{background-color:var(--color-status-warning)}@supports (color:color-mix(in lab,red,red)){.bg-status-warning\/20{background-color:color-mix(in oklab,var(--color-status-warning)20%,transparent)}}.bg-teal-500{background-color:var(--color-teal-500)}.bg-teal-500\/20{background-color:#00baa733}@supports (color:color-mix(in lab,red,red)){.bg-teal-500\/20{background-color:color-mix(in oklab,var(--color-teal-500)20%,transparent)}}.bg-transparent{background-color:#0000}.bg-violet-500{background-color:var(--color-violet-500)}.bg-white{background-color:var(--color-white)}.bg-white\/20{background-color:#fff3}@supports (color:color-mix(in lab,red,red)){.bg-white\/20{background-color:color-mix(in oklab,var(--color-white)20%,transparent)}}.bg-white\/50{background-color:#ffffff80}@supports (color:color-mix(in lab,red,red)){.bg-white\/50{background-color:color-mix(in oklab,var(--color-white)50%,transparent)}}.bg-white\/70{background-color:#ffffffb3}@supports (color:color-mix(in lab,red,red)){.bg-white\/70{background-color:color-mix(in oklab,var(--color-white)70%,transparent)}}.bg-white\/90{background-color:#ffffffe6}@supports (color:color-mix(in lab,red,red)){.bg-white\/90{background-color:color-mix(in oklab,var(--color-white)90%,transparent)}}.bg-yellow-400{background-color:var(--color-yellow-400)}.bg-yellow-400\/10{background-color:#fac8001a}@supports (color:color-mix(in lab,red,red)){.bg-yellow-400\/10{background-color:color-mix(in oklab,var(--color-yellow-400)10%,transparent)}}.bg-yellow-400\/20{background-color:#fac80033}@supports (color:color-mix(in lab,red,red)){.bg-yellow-400\/20{background-color:color-mix(in oklab,var(--color-yellow-400)20%,transparent)}}.bg-yellow-500{background-color:var(--color-yellow-500)}.bg-yellow-500\/5{background-color:#edb2000d}@supports (color:color-mix(in lab,red,red)){.bg-yellow-500\/5{background-color:color-mix(in oklab,var(--color-yellow-500)5%,transparent)}}.bg-yellow-500\/10{background-color:#edb2001a}@supports (color:color-mix(in lab,red,red)){.bg-yellow-500\/10{background-color:color-mix(in oklab,var(--color-yellow-500)10%,transparent)}}.bg-yellow-500\/20{background-color:#edb20033}@supports (color:color-mix(in lab,red,red)){.bg-yellow-500\/20{background-color:color-mix(in oklab,var(--color-yellow-500)20%,transparent)}}.bg-gradient-to-b{--tw-gradient-position:to bottom in oklab;background-image:linear-gradient(var(--tw-gradient-stops))}.bg-gradient-to-br{--tw-gradient-position:to bottom right in oklab;background-image:linear-gradient(var(--tw-gradient-stops))}.bg-gradient-to-r{--tw-gradient-position:to right in oklab;background-image:linear-gradient(var(--tw-gradient-stops))}.bg-gradient-to-t{--tw-gradient-position:to top in oklab;background-image:linear-gradient(var(--tw-gradient-stops))}.from-bambu-dark-secondary{--tw-gradient-from:var(--color-bambu-dark-secondary);--tw-gradient-stops:var(--tw-gradient-via-stops,var(--tw-gradient-position),var(--tw-gradient-from)var(--tw-gradient-from-position),var(--tw-gradient-to)var(--tw-gradient-to-position))}.from-bambu-green\/10{--tw-gradient-from:var(--color-bambu-green)}@supports (color:color-mix(in lab,red,red)){.from-bambu-green\/10{--tw-gradient-from:color-mix(in oklab,var(--color-bambu-green)10%,transparent)}}.from-bambu-green\/10{--tw-gradient-stops:var(--tw-gradient-via-stops,var(--tw-gradient-position),var(--tw-gradient-from)var(--tw-gradient-from-position),var(--tw-gradient-to)var(--tw-gradient-to-position))}.from-black\/80{--tw-gradient-from:#000c}@supports (color:color-mix(in lab,red,red)){.from-black\/80{--tw-gradient-from:color-mix(in oklab,var(--color-black)80%,transparent)}}.from-black\/80{--tw-gradient-stops:var(--tw-gradient-via-stops,var(--tw-gradient-position),var(--tw-gradient-from)var(--tw-gradient-from-position),var(--tw-gradient-to)var(--tw-gradient-to-position))}.from-blue-500\/5{--tw-gradient-from:#3080ff0d}@supports (color:color-mix(in lab,red,red)){.from-blue-500\/5{--tw-gradient-from:color-mix(in oklab,var(--color-blue-500)5%,transparent)}}.from-blue-500\/5{--tw-gradient-stops:var(--tw-gradient-via-stops,var(--tw-gradient-position),var(--tw-gradient-from)var(--tw-gradient-from-position),var(--tw-gradient-to)var(--tw-gradient-to-position))}.from-blue-500\/10{--tw-gradient-from:#3080ff1a}@supports (color:color-mix(in lab,red,red)){.from-blue-500\/10{--tw-gradient-from:color-mix(in oklab,var(--color-blue-500)10%,transparent)}}.from-blue-500\/10{--tw-gradient-stops:var(--tw-gradient-via-stops,var(--tw-gradient-position),var(--tw-gradient-from)var(--tw-gradient-from-position),var(--tw-gradient-to)var(--tw-gradient-to-position))}.from-gray-500\/10{--tw-gradient-from:#6a72821a}@supports (color:color-mix(in lab,red,red)){.from-gray-500\/10{--tw-gradient-from:color-mix(in oklab,var(--color-gray-500)10%,transparent)}}.from-gray-500\/10{--tw-gradient-stops:var(--tw-gradient-via-stops,var(--tw-gradient-position),var(--tw-gradient-from)var(--tw-gradient-from-position),var(--tw-gradient-to)var(--tw-gradient-to-position))}.from-purple-500\/10{--tw-gradient-from:#ac4bff1a}@supports (color:color-mix(in lab,red,red)){.from-purple-500\/10{--tw-gradient-from:color-mix(in oklab,var(--color-purple-500)10%,transparent)}}.from-purple-500\/10{--tw-gradient-stops:var(--tw-gradient-via-stops,var(--tw-gradient-position),var(--tw-gradient-from)var(--tw-gradient-from-position),var(--tw-gradient-to)var(--tw-gradient-to-position))}.from-white\/10{--tw-gradient-from:#ffffff1a}@supports (color:color-mix(in lab,red,red)){.from-white\/10{--tw-gradient-from:color-mix(in oklab,var(--color-white)10%,transparent)}}.from-white\/10{--tw-gradient-stops:var(--tw-gradient-via-stops,var(--tw-gradient-position),var(--tw-gradient-from)var(--tw-gradient-from-position),var(--tw-gradient-to)var(--tw-gradient-to-position))}.from-yellow-500\/10{--tw-gradient-from:#edb2001a}@supports (color:color-mix(in lab,red,red)){.from-yellow-500\/10{--tw-gradient-from:color-mix(in oklab,var(--color-yellow-500)10%,transparent)}}.from-yellow-500\/10{--tw-gradient-stops:var(--tw-gradient-via-stops,var(--tw-gradient-position),var(--tw-gradient-from)var(--tw-gradient-from-position),var(--tw-gradient-to)var(--tw-gradient-to-position))}.via-black\/60{--tw-gradient-via:#0009}@supports (color:color-mix(in lab,red,red)){.via-black\/60{--tw-gradient-via:color-mix(in oklab,var(--color-black)60%,transparent)}}.via-black\/60{--tw-gradient-via-stops:var(--tw-gradient-position),var(--tw-gradient-from)var(--tw-gradient-from-position),var(--tw-gradient-via)var(--tw-gradient-via-position),var(--tw-gradient-to)var(--tw-gradient-to-position);--tw-gradient-stops:var(--tw-gradient-via-stops)}.to-bambu-dark-secondary{--tw-gradient-to:var(--color-bambu-dark-secondary);--tw-gradient-stops:var(--tw-gradient-via-stops,var(--tw-gradient-position),var(--tw-gradient-from)var(--tw-gradient-from-position),var(--tw-gradient-to)var(--tw-gradient-to-position))}.to-bambu-dark-tertiary{--tw-gradient-to:var(--color-bambu-dark-tertiary);--tw-gradient-stops:var(--tw-gradient-via-stops,var(--tw-gradient-position),var(--tw-gradient-from)var(--tw-gradient-from-position),var(--tw-gradient-to)var(--tw-gradient-to-position))}.to-transparent{--tw-gradient-to:transparent;--tw-gradient-stops:var(--tw-gradient-via-stops,var(--tw-gradient-position),var(--tw-gradient-from)var(--tw-gradient-from-position),var(--tw-gradient-to)var(--tw-gradient-to-position))}.bg-cover{background-size:cover}.bg-center{background-position:50%}.fill-yellow-400{fill:var(--color-yellow-400)}.object-contain{object-fit:contain}.object-cover{object-fit:cover}.object-left{object-position:left}.p-0{padding:calc(var(--spacing)*0)}.p-0\.5{padding:calc(var(--spacing)*.5)}.p-1{padding:calc(var(--spacing)*1)}.p-1\.5{padding:calc(var(--spacing)*1.5)}.p-2{padding:calc(var(--spacing)*2)}.p-2\.5{padding:calc(var(--spacing)*2.5)}.p-3{padding:calc(var(--spacing)*3)}.p-4{padding:calc(var(--spacing)*4)}.p-5{padding:calc(var(--spacing)*5)}.p-6{padding:calc(var(--spacing)*6)}.p-8{padding:calc(var(--spacing)*8)}.p-12{padding:calc(var(--spacing)*12)}.\!px-1\.5{padding-inline:calc(var(--spacing)*1.5)!important}.\!px-3{padding-inline:calc(var(--spacing)*3)!important}.px-1{padding-inline:calc(var(--spacing)*1)}.px-1\.5{padding-inline:calc(var(--spacing)*1.5)}.px-2{padding-inline:calc(var(--spacing)*2)}.px-2\.5{padding-inline:calc(var(--spacing)*2.5)}.px-3{padding-inline:calc(var(--spacing)*3)}.px-4{padding-inline:calc(var(--spacing)*4)}.px-6{padding-inline:calc(var(--spacing)*6)}.py-0\.5{padding-block:calc(var(--spacing)*.5)}.py-1{padding-block:calc(var(--spacing)*1)}.py-1\.5{padding-block:calc(var(--spacing)*1.5)}.py-2{padding-block:calc(var(--spacing)*2)}.py-2\.5{padding-block:calc(var(--spacing)*2.5)}.py-3{padding-block:calc(var(--spacing)*3)}.py-4{padding-block:calc(var(--spacing)*4)}.py-6{padding-block:calc(var(--spacing)*6)}.py-8{padding-block:calc(var(--spacing)*8)}.py-12{padding-block:calc(var(--spacing)*12)}.py-16{padding-block:calc(var(--spacing)*16)}.py-20{padding-block:calc(var(--spacing)*20)}.py-24{padding-block:calc(var(--spacing)*24)}.pt-0{padding-top:calc(var(--spacing)*0)}.pt-1{padding-top:calc(var(--spacing)*1)}.pt-2{padding-top:calc(var(--spacing)*2)}.pt-3{padding-top:calc(var(--spacing)*3)}.pt-4{padding-top:calc(var(--spacing)*4)}.pr-1{padding-right:calc(var(--spacing)*1)}.pr-2{padding-right:calc(var(--spacing)*2)}.pr-3{padding-right:calc(var(--spacing)*3)}.pr-4{padding-right:calc(var(--spacing)*4)}.pr-6{padding-right:calc(var(--spacing)*6)}.pr-7{padding-right:calc(var(--spacing)*7)}.pr-8{padding-right:calc(var(--spacing)*8)}.pr-10{padding-right:calc(var(--spacing)*10)}.pb-1{padding-bottom:calc(var(--spacing)*1)}.pb-2{padding-bottom:calc(var(--spacing)*2)}.pb-4{padding-bottom:calc(var(--spacing)*4)}.pl-2{padding-left:calc(var(--spacing)*2)}.pl-4{padding-left:calc(var(--spacing)*4)}.pl-6{padding-left:calc(var(--spacing)*6)}.pl-7{padding-left:calc(var(--spacing)*7)}.pl-8{padding-left:calc(var(--spacing)*8)}.pl-9{padding-left:calc(var(--spacing)*9)}.pl-10{padding-left:calc(var(--spacing)*10)}.text-center{text-align:center}.text-left{text-align:left}.text-right{text-align:right}.font-mono{font-family:var(--font-mono)}.font-sans{font-family:var(--font-sans)}.text-2xl{font-size:var(--text-2xl);line-height:var(--tw-leading,var(--text-2xl--line-height))}.text-3xl{font-size:var(--text-3xl);line-height:var(--tw-leading,var(--text-3xl--line-height))}.text-base{font-size:var(--text-base);line-height:var(--tw-leading,var(--text-base--line-height))}.text-lg{font-size:var(--text-lg);line-height:var(--tw-leading,var(--text-lg--line-height))}.text-sm{font-size:var(--text-sm);line-height:var(--tw-leading,var(--text-sm--line-height))}.text-xl{font-size:var(--text-xl);line-height:var(--tw-leading,var(--text-xl--line-height))}.text-xs{font-size:var(--text-xs);line-height:var(--tw-leading,var(--text-xs--line-height))}.text-\[7px\]{font-size:7px}.text-\[8px\]{font-size:8px}.text-\[9px\]{font-size:9px}.text-\[10px\]{font-size:10px}.text-\[11px\]{font-size:11px}.leading-none{--tw-leading:1;line-height:1}.leading-tight{--tw-leading:var(--leading-tight);line-height:var(--leading-tight)}.font-bold{--tw-font-weight:var(--font-weight-bold);font-weight:var(--font-weight-bold)}.font-medium{--tw-font-weight:var(--font-weight-medium);font-weight:var(--font-weight-medium)}.font-normal{--tw-font-weight:var(--font-weight-normal);font-weight:var(--font-weight-normal)}.font-semibold{--tw-font-weight:var(--font-weight-semibold);font-weight:var(--font-weight-semibold)}.tracking-wide{--tw-tracking:var(--tracking-wide);letter-spacing:var(--tracking-wide)}.tracking-wider{--tw-tracking:var(--tracking-wider);letter-spacing:var(--tracking-wider)}.tracking-widest{--tw-tracking:var(--tracking-widest);letter-spacing:var(--tracking-widest)}.break-all{word-break:break-all}.whitespace-nowrap{white-space:nowrap}.whitespace-pre-wrap{white-space:pre-wrap}.\!text-green-400{color:var(--color-green-400)!important}.text-amber-200{color:var(--color-amber-200)}.text-amber-300{color:var(--color-amber-300)}.text-amber-300\/60{color:#ffd23699}@supports (color:color-mix(in lab,red,red)){.text-amber-300\/60{color:color-mix(in oklab,var(--color-amber-300)60%,transparent)}}.text-amber-300\/70{color:#ffd236b3}@supports (color:color-mix(in lab,red,red)){.text-amber-300\/70{color:color-mix(in oklab,var(--color-amber-300)70%,transparent)}}.text-amber-300\/80{color:#ffd236cc}@supports (color:color-mix(in lab,red,red)){.text-amber-300\/80{color:color-mix(in oklab,var(--color-amber-300)80%,transparent)}}.text-amber-400{color:var(--color-amber-400)}.text-amber-400\/70{color:#fcbb00b3}@supports (color:color-mix(in lab,red,red)){.text-amber-400\/70{color:color-mix(in oklab,var(--color-amber-400)70%,transparent)}}.text-amber-500{color:var(--color-amber-500)}.text-amber-500\/80{color:#f99c00cc}@supports (color:color-mix(in lab,red,red)){.text-amber-500\/80{color:color-mix(in oklab,var(--color-amber-500)80%,transparent)}}.text-amber-600{color:var(--color-amber-600)}.text-bambu-dark-tertiary{color:var(--color-bambu-dark-tertiary)}.text-bambu-gray{color:var(--color-bambu-gray)}.text-bambu-gray-dark{color:var(--color-bambu-gray-dark)}.text-bambu-gray-light{color:var(--color-bambu-gray-light)}.text-bambu-gray\/30{color:var(--color-bambu-gray)}@supports (color:color-mix(in lab,red,red)){.text-bambu-gray\/30{color:color-mix(in oklab,var(--color-bambu-gray)30%,transparent)}}.text-bambu-gray\/40{color:var(--color-bambu-gray)}@supports (color:color-mix(in lab,red,red)){.text-bambu-gray\/40{color:color-mix(in oklab,var(--color-bambu-gray)40%,transparent)}}.text-bambu-gray\/50{color:var(--color-bambu-gray)}@supports (color:color-mix(in lab,red,red)){.text-bambu-gray\/50{color:color-mix(in oklab,var(--color-bambu-gray)50%,transparent)}}.text-bambu-gray\/60{color:var(--color-bambu-gray)}@supports (color:color-mix(in lab,red,red)){.text-bambu-gray\/60{color:color-mix(in oklab,var(--color-bambu-gray)60%,transparent)}}.text-bambu-gray\/70{color:var(--color-bambu-gray)}@supports (color:color-mix(in lab,red,red)){.text-bambu-gray\/70{color:color-mix(in oklab,var(--color-bambu-gray)70%,transparent)}}.text-bambu-gray\/80{color:var(--color-bambu-gray)}@supports (color:color-mix(in lab,red,red)){.text-bambu-gray\/80{color:color-mix(in oklab,var(--color-bambu-gray)80%,transparent)}}.text-bambu-green,.text-bambu-green\/70{color:var(--color-bambu-green)}@supports (color:color-mix(in lab,red,red)){.text-bambu-green\/70{color:color-mix(in oklab,var(--color-bambu-green)70%,transparent)}}.text-black{color:var(--color-black)}.text-black\/80{color:#000c}@supports (color:color-mix(in lab,red,red)){.text-black\/80{color:color-mix(in oklab,var(--color-black)80%,transparent)}}.text-blue-300{color:var(--color-blue-300)}.text-blue-300\/70{color:#90c5ffb3}@supports (color:color-mix(in lab,red,red)){.text-blue-300\/70{color:color-mix(in oklab,var(--color-blue-300)70%,transparent)}}.text-blue-300\/80{color:#90c5ffcc}@supports (color:color-mix(in lab,red,red)){.text-blue-300\/80{color:color-mix(in oklab,var(--color-blue-300)80%,transparent)}}.text-blue-400{color:var(--color-blue-400)}.text-blue-500{color:var(--color-blue-500)}.text-blue-500\/70{color:#3080ffb3}@supports (color:color-mix(in lab,red,red)){.text-blue-500\/70{color:color-mix(in oklab,var(--color-blue-500)70%,transparent)}}.text-blue-600{color:var(--color-blue-600)}.text-blue-700{color:var(--color-blue-700)}.text-cyan-300{color:var(--color-cyan-300)}.text-cyan-400{color:var(--color-cyan-400)}.text-emerald-400{color:var(--color-emerald-400)}.text-gray-300{color:var(--color-gray-300)}.text-gray-400{color:var(--color-gray-400)}.text-gray-500{color:var(--color-gray-500)}.text-gray-600{color:var(--color-gray-600)}.text-gray-700{color:var(--color-gray-700)}.text-gray-800{color:var(--color-gray-800)}.text-gray-900{color:var(--color-gray-900)}.text-green-200{color:var(--color-green-200)}.text-green-300{color:var(--color-green-300)}.text-green-400{color:var(--color-green-400)}.text-green-500{color:var(--color-green-500)}.text-green-500\/60{color:#00c75899}@supports (color:color-mix(in lab,red,red)){.text-green-500\/60{color:color-mix(in oklab,var(--color-green-500)60%,transparent)}}.text-green-600{color:var(--color-green-600)}.text-indigo-400{color:var(--color-indigo-400)}.text-orange-200{color:var(--color-orange-200)}.text-orange-300{color:var(--color-orange-300)}.text-orange-400{color:var(--color-orange-400)}.text-orange-500{color:var(--color-orange-500)}.text-orange-600{color:var(--color-orange-600)}.text-orange-700{color:var(--color-orange-700)}.text-purple-300{color:var(--color-purple-300)}.text-purple-300\/70{color:#d9b3ffb3}@supports (color:color-mix(in lab,red,red)){.text-purple-300\/70{color:color-mix(in oklab,var(--color-purple-300)70%,transparent)}}.text-purple-400{color:var(--color-purple-400)}.text-purple-400\/80{color:#c07effcc}@supports (color:color-mix(in lab,red,red)){.text-purple-400\/80{color:color-mix(in oklab,var(--color-purple-400)80%,transparent)}}.text-purple-500{color:var(--color-purple-500)}.text-red-200{color:var(--color-red-200)}.text-red-300{color:var(--color-red-300)}.text-red-300\/80{color:#ffa3a3cc}@supports (color:color-mix(in lab,red,red)){.text-red-300\/80{color:color-mix(in oklab,var(--color-red-300)80%,transparent)}}.text-red-400{color:var(--color-red-400)}.text-red-400\/50{color:#ff656880}@supports (color:color-mix(in lab,red,red)){.text-red-400\/50{color:color-mix(in oklab,var(--color-red-400)50%,transparent)}}.text-red-400\/60{color:#ff656899}@supports (color:color-mix(in lab,red,red)){.text-red-400\/60{color:color-mix(in oklab,var(--color-red-400)60%,transparent)}}.text-red-400\/70{color:#ff6568b3}@supports (color:color-mix(in lab,red,red)){.text-red-400\/70{color:color-mix(in oklab,var(--color-red-400)70%,transparent)}}.text-red-500{color:var(--color-red-500)}.text-red-600{color:var(--color-red-600)}.text-rose-300{color:var(--color-rose-300)}.text-rose-400{color:var(--color-rose-400)}.text-sky-400{color:var(--color-sky-400)}.text-slate-300{color:var(--color-slate-300)}.text-status-error{color:var(--color-status-error)}.text-status-ok{color:var(--color-status-ok)}.text-status-warning{color:var(--color-status-warning)}.text-teal-400{color:var(--color-teal-400)}.text-white{color:var(--color-white)}.text-white\/40{color:#fff6}@supports (color:color-mix(in lab,red,red)){.text-white\/40{color:color-mix(in oklab,var(--color-white)40%,transparent)}}.text-white\/60{color:#fff9}@supports (color:color-mix(in lab,red,red)){.text-white\/60{color:color-mix(in oklab,var(--color-white)60%,transparent)}}.text-white\/70{color:#ffffffb3}@supports (color:color-mix(in lab,red,red)){.text-white\/70{color:color-mix(in oklab,var(--color-white)70%,transparent)}}.text-white\/80{color:#fffc}@supports (color:color-mix(in lab,red,red)){.text-white\/80{color:color-mix(in oklab,var(--color-white)80%,transparent)}}.text-white\/90{color:#ffffffe6}@supports (color:color-mix(in lab,red,red)){.text-white\/90{color:color-mix(in oklab,var(--color-white)90%,transparent)}}.text-yellow-200{color:var(--color-yellow-200)}.text-yellow-200\/70{color:#fff085b3}@supports (color:color-mix(in lab,red,red)){.text-yellow-200\/70{color:color-mix(in oklab,var(--color-yellow-200)70%,transparent)}}.text-yellow-300{color:var(--color-yellow-300)}.text-yellow-400{color:var(--color-yellow-400)}.text-yellow-500{color:var(--color-yellow-500)}.text-yellow-500\/70{color:#edb200b3}@supports (color:color-mix(in lab,red,red)){.text-yellow-500\/70{color:color-mix(in oklab,var(--color-yellow-500)70%,transparent)}}.text-yellow-600{color:var(--color-yellow-600)}.text-yellow-700{color:var(--color-yellow-700)}.capitalize{text-transform:capitalize}.uppercase{text-transform:uppercase}.italic{font-style:italic}.tabular-nums{--tw-numeric-spacing:tabular-nums;font-variant-numeric:var(--tw-ordinal,)var(--tw-slashed-zero,)var(--tw-numeric-figure,)var(--tw-numeric-spacing,)var(--tw-numeric-fraction,)}.line-through{text-decoration-line:line-through}.underline{text-decoration-line:underline}.placeholder-bambu-gray::placeholder{color:var(--color-bambu-gray)}.placeholder-bambu-gray-dark::placeholder{color:var(--color-bambu-gray-dark)}.placeholder-bambu-gray\/50::placeholder{color:var(--color-bambu-gray)}@supports (color:color-mix(in lab,red,red)){.placeholder-bambu-gray\/50::placeholder{color:color-mix(in oklab,var(--color-bambu-gray)50%,transparent)}}.accent-bambu-green{accent-color:var(--color-bambu-green)}.accent-green-500{accent-color:var(--color-green-500)}.opacity-0{opacity:0}.opacity-20{opacity:.2}.opacity-25{opacity:.25}.opacity-30{opacity:.3}.opacity-40{opacity:.4}.opacity-50{opacity:.5}.opacity-60{opacity:.6}.opacity-70{opacity:.7}.opacity-75{opacity:.75}.opacity-80{opacity:.8}.opacity-100{opacity:1}.shadow{--tw-shadow:0 1px 3px 0 var(--tw-shadow-color,#0000001a),0 1px 2px -1px var(--tw-shadow-color,#0000001a);box-shadow:var(--tw-inset-shadow),var(--tw-inset-ring-shadow),var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow)}.shadow-2xl{--tw-shadow:0 25px 50px -12px var(--tw-shadow-color,#00000040);box-shadow:var(--tw-inset-shadow),var(--tw-inset-ring-shadow),var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow)}.shadow-lg{--tw-shadow:0 10px 15px -3px var(--tw-shadow-color,#0000001a),0 4px 6px -4px var(--tw-shadow-color,#0000001a);box-shadow:var(--tw-inset-shadow),var(--tw-inset-ring-shadow),var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow)}.shadow-md{--tw-shadow:0 4px 6px -1px var(--tw-shadow-color,#0000001a),0 2px 4px -2px var(--tw-shadow-color,#0000001a);box-shadow:var(--tw-inset-shadow),var(--tw-inset-ring-shadow),var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow)}.shadow-sm{--tw-shadow:0 1px 3px 0 var(--tw-shadow-color,#0000001a),0 1px 2px -1px var(--tw-shadow-color,#0000001a);box-shadow:var(--tw-inset-shadow),var(--tw-inset-ring-shadow),var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow)}.shadow-xl{--tw-shadow:0 20px 25px -5px var(--tw-shadow-color,#0000001a),0 8px 10px -6px var(--tw-shadow-color,#0000001a);box-shadow:var(--tw-inset-shadow),var(--tw-inset-ring-shadow),var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow)}.ring-1{--tw-ring-shadow:var(--tw-ring-inset,)0 0 0 calc(1px + var(--tw-ring-offset-width))var(--tw-ring-color,currentcolor);box-shadow:var(--tw-inset-shadow),var(--tw-inset-ring-shadow),var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow)}.ring-2{--tw-ring-shadow:var(--tw-ring-inset,)0 0 0 calc(2px + var(--tw-ring-offset-width))var(--tw-ring-color,currentcolor);box-shadow:var(--tw-inset-shadow),var(--tw-inset-ring-shadow),var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow)}.shadow-bambu-green\/20{--tw-shadow-color:var(--color-bambu-green)}@supports (color:color-mix(in lab,red,red)){.shadow-bambu-green\/20{--tw-shadow-color:color-mix(in oklab,color-mix(in oklab,var(--color-bambu-green)20%,transparent)var(--tw-shadow-alpha),transparent)}}.shadow-bambu-green\/25{--tw-shadow-color:var(--color-bambu-green)}@supports (color:color-mix(in lab,red,red)){.shadow-bambu-green\/25{--tw-shadow-color:color-mix(in oklab,color-mix(in oklab,var(--color-bambu-green)25%,transparent)var(--tw-shadow-alpha),transparent)}}.ring-bambu-green,.ring-bambu-green\/30{--tw-ring-color:var(--color-bambu-green)}@supports (color:color-mix(in lab,red,red)){.ring-bambu-green\/30{--tw-ring-color:color-mix(in oklab,var(--color-bambu-green)30%,transparent)}}.ring-blue-400\/50{--tw-ring-color:#54a2ff80}@supports (color:color-mix(in lab,red,red)){.ring-blue-400\/50{--tw-ring-color:color-mix(in oklab,var(--color-blue-400)50%,transparent)}}.ring-green-500{--tw-ring-color:var(--color-green-500)}.ring-white{--tw-ring-color:var(--color-white)}.ring-offset-1{--tw-ring-offset-width:1px;--tw-ring-offset-shadow:var(--tw-ring-inset,)0 0 0 var(--tw-ring-offset-width)var(--tw-ring-offset-color)}.ring-offset-2{--tw-ring-offset-width:2px;--tw-ring-offset-shadow:var(--tw-ring-inset,)0 0 0 var(--tw-ring-offset-width)var(--tw-ring-offset-color)}.ring-offset-bambu-dark{--tw-ring-offset-color:var(--color-bambu-dark)}.ring-offset-bambu-dark-secondary{--tw-ring-offset-color:var(--color-bambu-dark-secondary)}.outline{outline-style:var(--tw-outline-style);outline-width:1px}.blur{--tw-blur:blur(8px);filter:var(--tw-blur,)var(--tw-brightness,)var(--tw-contrast,)var(--tw-grayscale,)var(--tw-hue-rotate,)var(--tw-invert,)var(--tw-saturate,)var(--tw-sepia,)var(--tw-drop-shadow,)}.blur-2xl{--tw-blur:blur(var(--blur-2xl));filter:var(--tw-blur,)var(--tw-brightness,)var(--tw-contrast,)var(--tw-grayscale,)var(--tw-hue-rotate,)var(--tw-invert,)var(--tw-saturate,)var(--tw-sepia,)var(--tw-drop-shadow,)}.drop-shadow-lg{--tw-drop-shadow-size:drop-shadow(0 4px 4px var(--tw-drop-shadow-color,#00000026));--tw-drop-shadow:drop-shadow(var(--drop-shadow-lg));filter:var(--tw-blur,)var(--tw-brightness,)var(--tw-contrast,)var(--tw-grayscale,)var(--tw-hue-rotate,)var(--tw-invert,)var(--tw-saturate,)var(--tw-sepia,)var(--tw-drop-shadow,)}.drop-shadow-md{--tw-drop-shadow-size:drop-shadow(0 3px 3px var(--tw-drop-shadow-color,#0000001f));--tw-drop-shadow:drop-shadow(var(--drop-shadow-md));filter:var(--tw-blur,)var(--tw-brightness,)var(--tw-contrast,)var(--tw-grayscale,)var(--tw-hue-rotate,)var(--tw-invert,)var(--tw-saturate,)var(--tw-sepia,)var(--tw-drop-shadow,)}.filter{filter:var(--tw-blur,)var(--tw-brightness,)var(--tw-contrast,)var(--tw-grayscale,)var(--tw-hue-rotate,)var(--tw-invert,)var(--tw-saturate,)var(--tw-sepia,)var(--tw-drop-shadow,)}.backdrop-blur-sm{--tw-backdrop-blur:blur(var(--blur-sm));-webkit-backdrop-filter:var(--tw-backdrop-blur,)var(--tw-backdrop-brightness,)var(--tw-backdrop-contrast,)var(--tw-backdrop-grayscale,)var(--tw-backdrop-hue-rotate,)var(--tw-backdrop-invert,)var(--tw-backdrop-opacity,)var(--tw-backdrop-saturate,)var(--tw-backdrop-sepia,);backdrop-filter:var(--tw-backdrop-blur,)var(--tw-backdrop-brightness,)var(--tw-backdrop-contrast,)var(--tw-backdrop-grayscale,)var(--tw-backdrop-hue-rotate,)var(--tw-backdrop-invert,)var(--tw-backdrop-opacity,)var(--tw-backdrop-saturate,)var(--tw-backdrop-sepia,)}.transition{transition-property:color,background-color,border-color,outline-color,text-decoration-color,fill,stroke,--tw-gradient-from,--tw-gradient-via,--tw-gradient-to,opacity,box-shadow,transform,translate,scale,rotate,filter,-webkit-backdrop-filter,backdrop-filter,display,content-visibility,overlay,pointer-events;transition-timing-function:var(--tw-ease,var(--default-transition-timing-function));transition-duration:var(--tw-duration,var(--default-transition-duration))}.transition-all{transition-property:all;transition-timing-function:var(--tw-ease,var(--default-transition-timing-function));transition-duration:var(--tw-duration,var(--default-transition-duration))}.transition-colors{transition-property:color,background-color,border-color,outline-color,text-decoration-color,fill,stroke,--tw-gradient-from,--tw-gradient-via,--tw-gradient-to;transition-timing-function:var(--tw-ease,var(--default-transition-timing-function));transition-duration:var(--tw-duration,var(--default-transition-duration))}.transition-opacity{transition-property:opacity;transition-timing-function:var(--tw-ease,var(--default-transition-timing-function));transition-duration:var(--tw-duration,var(--default-transition-duration))}.transition-transform{transition-property:transform,translate,scale,rotate;transition-timing-function:var(--tw-ease,var(--default-transition-timing-function));transition-duration:var(--tw-duration,var(--default-transition-duration))}.duration-150{--tw-duration:.15s;transition-duration:.15s}.duration-200{--tw-duration:.2s;transition-duration:.2s}.duration-300{--tw-duration:.3s;transition-duration:.3s}.duration-500{--tw-duration:.5s;transition-duration:.5s}.ease-in-out{--tw-ease:var(--ease-in-out);transition-timing-function:var(--ease-in-out)}.ease-out{--tw-ease:var(--ease-out);transition-timing-function:var(--ease-out)}.select-none{-webkit-user-select:none;user-select:none}@media(hover:hover){.group-hover\:bg-bambu-green\/20:is(:where(.group):hover *){background-color:var(--color-bambu-green)}@supports (color:color-mix(in lab,red,red)){.group-hover\:bg-bambu-green\/20:is(:where(.group):hover *){background-color:color-mix(in oklab,var(--color-bambu-green)20%,transparent)}}.group-hover\:text-bambu-gray:is(:where(.group):hover *){color:var(--color-bambu-gray)}.group-hover\:text-bambu-green:is(:where(.group):hover *){color:var(--color-bambu-green)}.group-hover\:opacity-50:is(:where(.group):hover *){opacity:.5}.group-hover\:opacity-100:is(:where(.group):hover *),.group-hover\/resize\:opacity-100:is(:where(.group\/resize):hover *){opacity:1}.group-hover\/thumb\:block:is(:where(.group\/thumb):hover *){display:block}}.peer-checked\:bg-bambu-green:is(:where(.peer):checked~*){background-color:var(--color-bambu-green)}.peer-focus\:outline-none:is(:where(.peer):focus~*){--tw-outline-style:none;outline-style:none}.placeholder\:text-bambu-gray::placeholder,.placeholder\:text-bambu-gray\/50::placeholder{color:var(--color-bambu-gray)}@supports (color:color-mix(in lab,red,red)){.placeholder\:text-bambu-gray\/50::placeholder{color:color-mix(in oklab,var(--color-bambu-gray)50%,transparent)}}.before\:absolute:before{content:var(--tw-content);position:absolute}.before\:top-0:before{content:var(--tw-content);top:calc(var(--spacing)*0)}.before\:right-0:before{content:var(--tw-content);right:calc(var(--spacing)*0)}.before\:left-0:before{content:var(--tw-content);left:calc(var(--spacing)*0)}.before\:h-0\.5:before{content:var(--tw-content);height:calc(var(--spacing)*.5)}.before\:bg-bambu-green:before{content:var(--tw-content);background-color:var(--color-bambu-green)}.after\:absolute:after{content:var(--tw-content);position:absolute}.after\:top-\[2px\]:after{content:var(--tw-content);top:2px}.after\:left-\[2px\]:after{content:var(--tw-content);left:2px}.after\:h-4:after{content:var(--tw-content);height:calc(var(--spacing)*4)}.after\:h-5:after{content:var(--tw-content);height:calc(var(--spacing)*5)}.after\:w-4:after{content:var(--tw-content);width:calc(var(--spacing)*4)}.after\:w-5:after{content:var(--tw-content);width:calc(var(--spacing)*5)}.after\:rounded-full:after{content:var(--tw-content);border-radius:3.40282e38px}.after\:border:after{content:var(--tw-content);border-style:var(--tw-border-style);border-width:1px}.after\:border-gray-300:after{content:var(--tw-content);border-color:var(--color-gray-300)}.after\:bg-white:after{content:var(--tw-content);background-color:var(--color-white)}.after\:transition-all:after{content:var(--tw-content);transition-property:all;transition-timing-function:var(--tw-ease,var(--default-transition-timing-function));transition-duration:var(--tw-duration,var(--default-transition-duration))}.after\:content-\[\'\'\]:after{--tw-content:"";content:var(--tw-content)}.peer-checked\:after\:translate-x-full:is(:where(.peer):checked~*):after{content:var(--tw-content);--tw-translate-x:100%;translate:var(--tw-translate-x)var(--tw-translate-y)}.peer-checked\:after\:border-white:is(:where(.peer):checked~*):after{content:var(--tw-content);border-color:var(--color-white)}.last\:border-0:last-child{border-style:var(--tw-border-style);border-width:0}.last\:border-b-0:last-child{border-bottom-style:var(--tw-border-style);border-bottom-width:0}@media(hover:hover){.hover\:z-20:hover{z-index:20}.hover\:scale-105:hover{--tw-scale-x:105%;--tw-scale-y:105%;--tw-scale-z:105%;scale:var(--tw-scale-x)var(--tw-scale-y)}.hover\:scale-110:hover{--tw-scale-x:110%;--tw-scale-y:110%;--tw-scale-z:110%;scale:var(--tw-scale-x)var(--tw-scale-y)}.hover\:border-bambu-dark-tertiary\/80:hover{border-color:var(--color-bambu-dark-tertiary)}@supports (color:color-mix(in lab,red,red)){.hover\:border-bambu-dark-tertiary\/80:hover{border-color:color-mix(in oklab,var(--color-bambu-dark-tertiary)80%,transparent)}}.hover\:border-bambu-gray:hover{border-color:var(--color-bambu-gray)}.hover\:border-bambu-gray-dark:hover{border-color:var(--color-bambu-gray-dark)}.hover\:border-bambu-gray\/50:hover{border-color:var(--color-bambu-gray)}@supports (color:color-mix(in lab,red,red)){.hover\:border-bambu-gray\/50:hover{border-color:color-mix(in oklab,var(--color-bambu-gray)50%,transparent)}}.hover\:border-bambu-green:hover,.hover\:border-bambu-green\/50:hover{border-color:var(--color-bambu-green)}@supports (color:color-mix(in lab,red,red)){.hover\:border-bambu-green\/50:hover{border-color:color-mix(in oklab,var(--color-bambu-green)50%,transparent)}}.hover\:border-white:hover{border-color:var(--color-white)}.hover\:border-white\/40:hover{border-color:#fff6}@supports (color:color-mix(in lab,red,red)){.hover\:border-white\/40:hover{border-color:color-mix(in oklab,var(--color-white)40%,transparent)}}.hover\:\!bg-green-500\/20:hover{background-color:#00c75833!important}@supports (color:color-mix(in lab,red,red)){.hover\:\!bg-green-500\/20:hover{background-color:color-mix(in oklab,var(--color-green-500)20%,transparent)!important}}.hover\:bg-amber-500\/30:hover{background-color:#f99c004d}@supports (color:color-mix(in lab,red,red)){.hover\:bg-amber-500\/30:hover{background-color:color-mix(in oklab,var(--color-amber-500)30%,transparent)}}.hover\:bg-bambu-dark:hover{background-color:var(--color-bambu-dark)}.hover\:bg-bambu-dark-secondary:hover,.hover\:bg-bambu-dark-secondary\/50:hover{background-color:var(--color-bambu-dark-secondary)}@supports (color:color-mix(in lab,red,red)){.hover\:bg-bambu-dark-secondary\/50:hover{background-color:color-mix(in oklab,var(--color-bambu-dark-secondary)50%,transparent)}}.hover\:bg-bambu-dark-tertiary:hover,.hover\:bg-bambu-dark-tertiary\/30:hover{background-color:var(--color-bambu-dark-tertiary)}@supports (color:color-mix(in lab,red,red)){.hover\:bg-bambu-dark-tertiary\/30:hover{background-color:color-mix(in oklab,var(--color-bambu-dark-tertiary)30%,transparent)}}.hover\:bg-bambu-dark-tertiary\/50:hover{background-color:var(--color-bambu-dark-tertiary)}@supports (color:color-mix(in lab,red,red)){.hover\:bg-bambu-dark-tertiary\/50:hover{background-color:color-mix(in oklab,var(--color-bambu-dark-tertiary)50%,transparent)}}.hover\:bg-bambu-dark-tertiary\/70:hover{background-color:var(--color-bambu-dark-tertiary)}@supports (color:color-mix(in lab,red,red)){.hover\:bg-bambu-dark-tertiary\/70:hover{background-color:color-mix(in oklab,var(--color-bambu-dark-tertiary)70%,transparent)}}.hover\:bg-bambu-dark-tertiary\/80:hover{background-color:var(--color-bambu-dark-tertiary)}@supports (color:color-mix(in lab,red,red)){.hover\:bg-bambu-dark-tertiary\/80:hover{background-color:color-mix(in oklab,var(--color-bambu-dark-tertiary)80%,transparent)}}.hover\:bg-bambu-dark\/50:hover{background-color:var(--color-bambu-dark)}@supports (color:color-mix(in lab,red,red)){.hover\:bg-bambu-dark\/50:hover{background-color:color-mix(in oklab,var(--color-bambu-dark)50%,transparent)}}.hover\:bg-bambu-dark\/80:hover{background-color:var(--color-bambu-dark)}@supports (color:color-mix(in lab,red,red)){.hover\:bg-bambu-dark\/80:hover{background-color:color-mix(in oklab,var(--color-bambu-dark)80%,transparent)}}.hover\:bg-bambu-gray-dark:hover{background-color:var(--color-bambu-gray-dark)}.hover\:bg-bambu-green:hover{background-color:var(--color-bambu-green)}.hover\:bg-bambu-green-dark:hover{background-color:var(--color-bambu-green-dark)}.hover\:bg-bambu-green-light:hover{background-color:var(--color-bambu-green-light)}.hover\:bg-bambu-green\/10:hover{background-color:var(--color-bambu-green)}@supports (color:color-mix(in lab,red,red)){.hover\:bg-bambu-green\/10:hover{background-color:color-mix(in oklab,var(--color-bambu-green)10%,transparent)}}.hover\:bg-bambu-green\/20:hover{background-color:var(--color-bambu-green)}@supports (color:color-mix(in lab,red,red)){.hover\:bg-bambu-green\/20:hover{background-color:color-mix(in oklab,var(--color-bambu-green)20%,transparent)}}.hover\:bg-bambu-green\/30:hover{background-color:var(--color-bambu-green)}@supports (color:color-mix(in lab,red,red)){.hover\:bg-bambu-green\/30:hover{background-color:color-mix(in oklab,var(--color-bambu-green)30%,transparent)}}.hover\:bg-bambu-green\/50:hover{background-color:var(--color-bambu-green)}@supports (color:color-mix(in lab,red,red)){.hover\:bg-bambu-green\/50:hover{background-color:color-mix(in oklab,var(--color-bambu-green)50%,transparent)}}.hover\:bg-bambu-green\/80:hover{background-color:var(--color-bambu-green)}@supports (color:color-mix(in lab,red,red)){.hover\:bg-bambu-green\/80:hover{background-color:color-mix(in oklab,var(--color-bambu-green)80%,transparent)}}.hover\:bg-black\/40:hover{background-color:#0006}@supports (color:color-mix(in lab,red,red)){.hover\:bg-black\/40:hover{background-color:color-mix(in oklab,var(--color-black)40%,transparent)}}.hover\:bg-black\/70:hover{background-color:#000000b3}@supports (color:color-mix(in lab,red,red)){.hover\:bg-black\/70:hover{background-color:color-mix(in oklab,var(--color-black)70%,transparent)}}.hover\:bg-black\/80:hover{background-color:#000c}@supports (color:color-mix(in lab,red,red)){.hover\:bg-black\/80:hover{background-color:color-mix(in oklab,var(--color-black)80%,transparent)}}.hover\:bg-blue-500\/30:hover{background-color:#3080ff4d}@supports (color:color-mix(in lab,red,red)){.hover\:bg-blue-500\/30:hover{background-color:color-mix(in oklab,var(--color-blue-500)30%,transparent)}}.hover\:bg-gray-50:hover{background-color:var(--color-gray-50)}.hover\:bg-gray-100:hover{background-color:var(--color-gray-100)}.hover\:bg-gray-700:hover{background-color:var(--color-gray-700)}.hover\:bg-green-500\/20:hover{background-color:#00c75833}@supports (color:color-mix(in lab,red,red)){.hover\:bg-green-500\/20:hover{background-color:color-mix(in oklab,var(--color-green-500)20%,transparent)}}.hover\:bg-orange-400\/20:hover{background-color:#ff8b1a33}@supports (color:color-mix(in lab,red,red)){.hover\:bg-orange-400\/20:hover{background-color:color-mix(in oklab,var(--color-orange-400)20%,transparent)}}.hover\:bg-red-200:hover{background-color:var(--color-red-200)}.hover\:bg-red-400\/10:hover{background-color:#ff65681a}@supports (color:color-mix(in lab,red,red)){.hover\:bg-red-400\/10:hover{background-color:color-mix(in oklab,var(--color-red-400)10%,transparent)}}.hover\:bg-red-500\/10:hover{background-color:#fb2c361a}@supports (color:color-mix(in lab,red,red)){.hover\:bg-red-500\/10:hover{background-color:color-mix(in oklab,var(--color-red-500)10%,transparent)}}.hover\:bg-red-500\/20:hover{background-color:#fb2c3633}@supports (color:color-mix(in lab,red,red)){.hover\:bg-red-500\/20:hover{background-color:color-mix(in oklab,var(--color-red-500)20%,transparent)}}.hover\:bg-red-500\/30:hover{background-color:#fb2c364d}@supports (color:color-mix(in lab,red,red)){.hover\:bg-red-500\/30:hover{background-color:color-mix(in oklab,var(--color-red-500)30%,transparent)}}.hover\:bg-red-600:hover{background-color:var(--color-red-600)}.hover\:bg-red-700:hover{background-color:var(--color-red-700)}.hover\:bg-white\/5:hover{background-color:#ffffff0d}@supports (color:color-mix(in lab,red,red)){.hover\:bg-white\/5:hover{background-color:color-mix(in oklab,var(--color-white)5%,transparent)}}.hover\:bg-white\/10:hover{background-color:#ffffff1a}@supports (color:color-mix(in lab,red,red)){.hover\:bg-white\/10:hover{background-color:color-mix(in oklab,var(--color-white)10%,transparent)}}.hover\:bg-white\/80:hover{background-color:#fffc}@supports (color:color-mix(in lab,red,red)){.hover\:bg-white\/80:hover{background-color:color-mix(in oklab,var(--color-white)80%,transparent)}}.hover\:bg-yellow-500\/30:hover{background-color:#edb2004d}@supports (color:color-mix(in lab,red,red)){.hover\:bg-yellow-500\/30:hover{background-color:color-mix(in oklab,var(--color-yellow-500)30%,transparent)}}.hover\:bg-yellow-600:hover{background-color:var(--color-yellow-600)}.hover\:text-amber-300:hover{color:var(--color-amber-300)}.hover\:text-bambu-gray:hover{color:var(--color-bambu-gray)}.hover\:text-bambu-green:hover{color:var(--color-bambu-green)}.hover\:text-bambu-green-light:hover{color:var(--color-bambu-green-light)}.hover\:text-bambu-green\/70:hover{color:var(--color-bambu-green)}@supports (color:color-mix(in lab,red,red)){.hover\:text-bambu-green\/70:hover{color:color-mix(in oklab,var(--color-bambu-green)70%,transparent)}}.hover\:text-bambu-green\/80:hover{color:var(--color-bambu-green)}@supports (color:color-mix(in lab,red,red)){.hover\:text-bambu-green\/80:hover{color:color-mix(in oklab,var(--color-bambu-green)80%,transparent)}}.hover\:text-blue-300:hover{color:var(--color-blue-300)}.hover\:text-gray-900:hover{color:var(--color-gray-900)}.hover\:text-orange-300:hover{color:var(--color-orange-300)}.hover\:text-red-300:hover{color:var(--color-red-300)}.hover\:text-red-400:hover{color:var(--color-red-400)}.hover\:text-white:hover{color:var(--color-white)}.hover\:text-white\/80:hover{color:#fffc}@supports (color:color-mix(in lab,red,red)){.hover\:text-white\/80:hover{color:color-mix(in oklab,var(--color-white)80%,transparent)}}.hover\:text-yellow-400:hover{color:var(--color-yellow-400)}.hover\:underline:hover{text-decoration-line:underline}.hover\:opacity-70:hover{opacity:.7}.hover\:opacity-80:hover{opacity:.8}.hover\:shadow-lg:hover{--tw-shadow:0 10px 15px -3px var(--tw-shadow-color,#0000001a),0 4px 6px -4px var(--tw-shadow-color,#0000001a);box-shadow:var(--tw-inset-shadow),var(--tw-inset-ring-shadow),var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow)}.hover\:shadow-bambu-green\/5:hover{--tw-shadow-color:var(--color-bambu-green)}@supports (color:color-mix(in lab,red,red)){.hover\:shadow-bambu-green\/5:hover{--tw-shadow-color:color-mix(in oklab,color-mix(in oklab,var(--color-bambu-green)5%,transparent)var(--tw-shadow-alpha),transparent)}}.hover\:shadow-bambu-green\/30:hover{--tw-shadow-color:var(--color-bambu-green)}@supports (color:color-mix(in lab,red,red)){.hover\:shadow-bambu-green\/30:hover{--tw-shadow-color:color-mix(in oklab,color-mix(in oklab,var(--color-bambu-green)30%,transparent)var(--tw-shadow-alpha),transparent)}}}.focus\:border-bambu-green:focus{border-color:var(--color-bambu-green)}.focus\:border-red-500:focus{border-color:var(--color-red-500)}.focus\:ring-1:focus{--tw-ring-shadow:var(--tw-ring-inset,)0 0 0 calc(1px + var(--tw-ring-offset-width))var(--tw-ring-color,currentcolor);box-shadow:var(--tw-inset-shadow),var(--tw-inset-ring-shadow),var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow)}.focus\:ring-2:focus{--tw-ring-shadow:var(--tw-ring-inset,)0 0 0 calc(2px + var(--tw-ring-offset-width))var(--tw-ring-color,currentcolor);box-shadow:var(--tw-inset-shadow),var(--tw-inset-ring-shadow),var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow)}.focus\:ring-bambu-gray:focus{--tw-ring-color:var(--color-bambu-gray)}.focus\:ring-bambu-green:focus,.focus\:ring-bambu-green\/50:focus{--tw-ring-color:var(--color-bambu-green)}@supports (color:color-mix(in lab,red,red)){.focus\:ring-bambu-green\/50:focus{--tw-ring-color:color-mix(in oklab,var(--color-bambu-green)50%,transparent)}}.focus\:ring-red-500:focus{--tw-ring-color:var(--color-red-500)}.focus\:ring-offset-0:focus{--tw-ring-offset-width:0px;--tw-ring-offset-shadow:var(--tw-ring-inset,)0 0 0 var(--tw-ring-offset-width)var(--tw-ring-offset-color)}.focus\:ring-offset-2:focus{--tw-ring-offset-width:2px;--tw-ring-offset-shadow:var(--tw-ring-inset,)0 0 0 var(--tw-ring-offset-width)var(--tw-ring-offset-color)}.focus\:ring-offset-bambu-dark:focus{--tw-ring-offset-color:var(--color-bambu-dark)}.focus\:ring-offset-bambu-dark-secondary:focus{--tw-ring-offset-color:var(--color-bambu-dark-secondary)}.focus\:outline-none:focus{--tw-outline-style:none;outline-style:none}.active\:cursor-grabbing:active{cursor:grabbing}.disabled\:cursor-not-allowed:disabled{cursor:not-allowed}.disabled\:opacity-30:disabled{opacity:.3}.disabled\:opacity-50:disabled{opacity:.5}@media(hover:hover){.disabled\:hover\:bg-bambu-green:disabled:hover{background-color:var(--color-bambu-green)}}@media not all and (min-width:640px){.max-\[640px\]\:hidden{display:none}.max-\[640px\]\:w-full{width:100%}.max-\[640px\]\:grid-cols-1{grid-template-columns:repeat(1,minmax(0,1fr))}.max-\[640px\]\:flex-col{flex-direction:column}.max-\[640px\]\:flex-wrap{flex-wrap:wrap}.max-\[640px\]\:items-center{align-items:center}.max-\[640px\]\:items-start{align-items:flex-start}}@media not all and (min-width:550px){.max-\[550px\]\:order-1{order:1}.max-\[550px\]\:order-2{order:2}.max-\[550px\]\:order-3{order:3}.max-\[550px\]\:order-4{order:4}.max-\[550px\]\:mt-1{margin-top:calc(var(--spacing)*1)}.max-\[550px\]\:w-full{width:100%}.max-\[550px\]\:grid-cols-2{grid-template-columns:repeat(2,minmax(0,1fr))}.max-\[550px\]\:flex-col{flex-direction:column}.max-\[550px\]\:flex-wrap{flex-wrap:wrap}.max-\[550px\]\:items-center{align-items:center}.max-\[550px\]\:items-start{align-items:flex-start}.max-\[550px\]\:justify-end{justify-content:flex-end}.max-\[550px\]\:gap-1\.5{gap:calc(var(--spacing)*1.5)}.max-\[550px\]\:gap-2{gap:calc(var(--spacing)*2)}.max-\[550px\]\:gap-3{gap:calc(var(--spacing)*3)}.max-\[550px\]\:self-start{align-self:flex-start}}@media(min-width:40rem){.sm\:col-span-1{grid-column:span 1/span 1}.sm\:mt-0{margin-top:calc(var(--spacing)*0)}.sm\:mt-2{margin-top:calc(var(--spacing)*2)}.sm\:mt-3{margin-top:calc(var(--spacing)*3)}.sm\:mr-1{margin-right:calc(var(--spacing)*1)}.sm\:mb-4{margin-bottom:calc(var(--spacing)*4)}.sm\:ml-auto{margin-left:auto}.sm\:block{display:block}.sm\:flex{display:flex}.sm\:grid{display:grid}.sm\:hidden{display:none}.sm\:inline{display:inline}.sm\:h-2{height:calc(var(--spacing)*2)}.sm\:h-3{height:calc(var(--spacing)*3)}.sm\:h-3\.5{height:calc(var(--spacing)*3.5)}.sm\:h-4{height:calc(var(--spacing)*4)}.sm\:h-5{height:calc(var(--spacing)*5)}.sm\:h-6{height:calc(var(--spacing)*6)}.sm\:h-10{height:calc(var(--spacing)*10)}.sm\:h-14{height:calc(var(--spacing)*14)}.sm\:w-3{width:calc(var(--spacing)*3)}.sm\:w-3\.5{width:calc(var(--spacing)*3.5)}.sm\:w-4{width:calc(var(--spacing)*4)}.sm\:w-5{width:calc(var(--spacing)*5)}.sm\:w-6{width:calc(var(--spacing)*6)}.sm\:w-10{width:calc(var(--spacing)*10)}.sm\:w-14{width:calc(var(--spacing)*14)}.sm\:w-16{width:calc(var(--spacing)*16)}.sm\:w-40{width:calc(var(--spacing)*40)}.sm\:w-auto{width:auto}.sm\:max-w-none{max-width:none}.sm\:max-w-xs{max-width:var(--container-xs)}.sm\:flex-1{flex:1}.sm\:flex-none{flex:none}.sm\:cursor-default{cursor:default}.sm\:grid-cols-2{grid-template-columns:repeat(2,minmax(0,1fr))}.sm\:grid-cols-3{grid-template-columns:repeat(3,minmax(0,1fr))}.sm\:grid-cols-4{grid-template-columns:repeat(4,minmax(0,1fr))}.sm\:flex-row{flex-direction:row}.sm\:items-center{align-items:center}.sm\:justify-between{justify-content:space-between}.sm\:gap-1{gap:calc(var(--spacing)*1)}.sm\:gap-1\.5{gap:calc(var(--spacing)*1.5)}.sm\:gap-2{gap:calc(var(--spacing)*2)}.sm\:gap-3{gap:calc(var(--spacing)*3)}.sm\:gap-4{gap:calc(var(--spacing)*4)}.sm\:gap-6{gap:calc(var(--spacing)*6)}:where(.sm\:space-y-3>:not(:last-child)){--tw-space-y-reverse:0;margin-block-start:calc(calc(var(--spacing)*3)*var(--tw-space-y-reverse));margin-block-end:calc(calc(var(--spacing)*3)*calc(1 - var(--tw-space-y-reverse)))}:where(.sm\:space-y-8>:not(:last-child)){--tw-space-y-reverse:0;margin-block-start:calc(calc(var(--spacing)*8)*var(--tw-space-y-reverse));margin-block-end:calc(calc(var(--spacing)*8)*calc(1 - var(--tw-space-y-reverse)))}.sm\:border-bambu-dark-tertiary{border-color:var(--color-bambu-dark-tertiary)}.sm\:p-1\.5{padding:calc(var(--spacing)*1.5)}.sm\:p-2{padding:calc(var(--spacing)*2)}.sm\:p-3{padding:calc(var(--spacing)*3)}.sm\:p-4{padding:calc(var(--spacing)*4)}.sm\:px-2{padding-inline:calc(var(--spacing)*2)}.sm\:px-3{padding-inline:calc(var(--spacing)*3)}.sm\:text-2xl{font-size:var(--text-2xl);line-height:var(--tw-leading,var(--text-2xl--line-height))}.sm\:text-base{font-size:var(--text-base);line-height:var(--tw-leading,var(--text-base--line-height))}.sm\:text-lg{font-size:var(--text-lg);line-height:var(--tw-leading,var(--text-lg--line-height))}.sm\:text-sm{font-size:var(--text-sm);line-height:var(--tw-leading,var(--text-sm--line-height))}.sm\:text-xs{font-size:var(--text-xs);line-height:var(--tw-leading,var(--text-xs--line-height))}}@media(min-width:48rem){.md\:top-\[2px\]{top:2px}.md\:left-\[2px\]{left:2px}.md\:mx-0{margin-inline:calc(var(--spacing)*0)}.md\:block{display:block}.md\:inline{display:inline}.md\:h-4{height:calc(var(--spacing)*4)}.md\:h-5{height:calc(var(--spacing)*5)}.md\:min-h-0{min-height:calc(var(--spacing)*0)}.md\:w-4{width:calc(var(--spacing)*4)}.md\:w-9{width:calc(var(--spacing)*9)}.md\:min-w-\[200px\]{min-width:200px}.md\:flex-1{flex:1}.md\:grid-cols-2{grid-template-columns:repeat(2,minmax(0,1fr))}.md\:grid-cols-3{grid-template-columns:repeat(3,minmax(0,1fr))}.md\:grid-cols-4{grid-template-columns:repeat(4,minmax(0,1fr))}.md\:grid-cols-5{grid-template-columns:repeat(5,minmax(0,1fr))}.md\:flex-row{flex-direction:row}.md\:flex-wrap{flex-wrap:wrap}.md\:items-center{align-items:center}.md\:gap-4{gap:calc(var(--spacing)*4)}.md\:p-6{padding:calc(var(--spacing)*6)}.md\:p-8{padding:calc(var(--spacing)*8)}.md\:px-0{padding-inline:calc(var(--spacing)*0)}.md\:py-2{padding-block:calc(var(--spacing)*2)}.md\:pb-0{padding-bottom:calc(var(--spacing)*0)}}@media(min-width:64rem){.lg\:static{position:static}.lg\:col-span-2{grid-column:span 2/span 2}.lg\:flex{display:flex}.lg\:hidden{display:none}.lg\:h-\[calc\(100vh-64px\)\]{height:calc(100vh - 64px)}.lg\:w-1\/3{width:33.3333%}.lg\:w-2\/3{width:66.6667%}.lg\:w-80{width:calc(var(--spacing)*80)}.lg\:w-\[480px\]{width:480px}.lg\:max-w-md{max-width:var(--container-md)}.lg\:max-w-sm{max-width:var(--container-sm)}.lg\:max-w-xl{max-width:var(--container-xl)}.lg\:flex-shrink-0{flex-shrink:0}.lg\:grid-cols-2{grid-template-columns:repeat(2,minmax(0,1fr))}.lg\:grid-cols-3{grid-template-columns:repeat(3,minmax(0,1fr))}.lg\:grid-cols-4{grid-template-columns:repeat(4,minmax(0,1fr))}.lg\:grid-cols-5{grid-template-columns:repeat(5,minmax(0,1fr))}.lg\:flex-row{flex-direction:row}.lg\:gap-4{gap:calc(var(--spacing)*4)}.lg\:gap-6{gap:calc(var(--spacing)*6)}.lg\:gap-8{gap:calc(var(--spacing)*8)}.lg\:overflow-y-auto{overflow-y:auto}.lg\:p-8{padding:calc(var(--spacing)*8)}}@media(min-width:80rem){.xl\:grid-cols-2{grid-template-columns:repeat(2,minmax(0,1fr))}.xl\:grid-cols-3{grid-template-columns:repeat(3,minmax(0,1fr))}.xl\:grid-cols-4{grid-template-columns:repeat(4,minmax(0,1fr))}.xl\:grid-cols-5{grid-template-columns:repeat(5,minmax(0,1fr))}.xl\:grid-cols-6{grid-template-columns:repeat(6,minmax(0,1fr))}}@media(min-width:96rem){.\32xl\:grid-cols-6{grid-template-columns:repeat(6,minmax(0,1fr))}}.dark\:border-bambu-dark-tertiary:where(.dark,.dark *),.dark\:border-bambu-dark-tertiary\/50:where(.dark,.dark *){border-color:var(--color-bambu-dark-tertiary)}@supports (color:color-mix(in lab,red,red)){.dark\:border-bambu-dark-tertiary\/50:where(.dark,.dark *){border-color:color-mix(in oklab,var(--color-bambu-dark-tertiary)50%,transparent)}}.dark\:border-bambu-green\/40:where(.dark,.dark *){border-color:var(--color-bambu-green)}@supports (color:color-mix(in lab,red,red)){.dark\:border-bambu-green\/40:where(.dark,.dark *){border-color:color-mix(in oklab,var(--color-bambu-green)40%,transparent)}}.dark\:border-gray-600:where(.dark,.dark *){border-color:var(--color-gray-600)}.dark\:border-red-500\/30:where(.dark,.dark *){border-color:#fb2c364d}@supports (color:color-mix(in lab,red,red)){.dark\:border-red-500\/30:where(.dark,.dark *){border-color:color-mix(in oklab,var(--color-red-500)30%,transparent)}}.dark\:border-red-500\/40:where(.dark,.dark *){border-color:#fb2c3666}@supports (color:color-mix(in lab,red,red)){.dark\:border-red-500\/40:where(.dark,.dark *){border-color:color-mix(in oklab,var(--color-red-500)40%,transparent)}}.dark\:bg-amber-500\/10:where(.dark,.dark *){background-color:#f99c001a}@supports (color:color-mix(in lab,red,red)){.dark\:bg-amber-500\/10:where(.dark,.dark *){background-color:color-mix(in oklab,var(--color-amber-500)10%,transparent)}}.dark\:bg-bambu-dark:where(.dark,.dark *){background-color:var(--color-bambu-dark)}.dark\:bg-bambu-dark-secondary:where(.dark,.dark *){background-color:var(--color-bambu-dark-secondary)}.dark\:bg-bambu-green\/20:where(.dark,.dark *){background-color:var(--color-bambu-green)}@supports (color:color-mix(in lab,red,red)){.dark\:bg-bambu-green\/20:where(.dark,.dark *){background-color:color-mix(in oklab,var(--color-bambu-green)20%,transparent)}}.dark\:bg-black\/80:where(.dark,.dark *){background-color:#000c}@supports (color:color-mix(in lab,red,red)){.dark\:bg-black\/80:where(.dark,.dark *){background-color:color-mix(in oklab,var(--color-black)80%,transparent)}}.dark\:bg-blue-500\/10:where(.dark,.dark *){background-color:#3080ff1a}@supports (color:color-mix(in lab,red,red)){.dark\:bg-blue-500\/10:where(.dark,.dark *){background-color:color-mix(in oklab,var(--color-blue-500)10%,transparent)}}.dark\:bg-blue-500\/20:where(.dark,.dark *){background-color:#3080ff33}@supports (color:color-mix(in lab,red,red)){.dark\:bg-blue-500\/20:where(.dark,.dark *){background-color:color-mix(in oklab,var(--color-blue-500)20%,transparent)}}.dark\:bg-gray-500\/40:where(.dark,.dark *){background-color:#6a728266}@supports (color:color-mix(in lab,red,red)){.dark\:bg-gray-500\/40:where(.dark,.dark *){background-color:color-mix(in oklab,var(--color-gray-500)40%,transparent)}}.dark\:bg-gray-900:where(.dark,.dark *){background-color:var(--color-gray-900)}.dark\:bg-red-500\/10:where(.dark,.dark *){background-color:#fb2c361a}@supports (color:color-mix(in lab,red,red)){.dark\:bg-red-500\/10:where(.dark,.dark *){background-color:color-mix(in oklab,var(--color-red-500)10%,transparent)}}.dark\:bg-red-500\/20:where(.dark,.dark *){background-color:#fb2c3633}@supports (color:color-mix(in lab,red,red)){.dark\:bg-red-500\/20:where(.dark,.dark *){background-color:color-mix(in oklab,var(--color-red-500)20%,transparent)}}.dark\:text-amber-400:where(.dark,.dark *){color:var(--color-amber-400)}.dark\:text-bambu-gray:where(.dark,.dark *),.dark\:text-bambu-gray\/30:where(.dark,.dark *){color:var(--color-bambu-gray)}@supports (color:color-mix(in lab,red,red)){.dark\:text-bambu-gray\/30:where(.dark,.dark *){color:color-mix(in oklab,var(--color-bambu-gray)30%,transparent)}}.dark\:text-bambu-gray\/50:where(.dark,.dark *){color:var(--color-bambu-gray)}@supports (color:color-mix(in lab,red,red)){.dark\:text-bambu-gray\/50:where(.dark,.dark *){color:color-mix(in oklab,var(--color-bambu-gray)50%,transparent)}}.dark\:text-bambu-green:where(.dark,.dark *),.dark\:text-bambu-green\/60:where(.dark,.dark *){color:var(--color-bambu-green)}@supports (color:color-mix(in lab,red,red)){.dark\:text-bambu-green\/60:where(.dark,.dark *){color:color-mix(in oklab,var(--color-bambu-green)60%,transparent)}}.dark\:text-blue-200:where(.dark,.dark *){color:var(--color-blue-200)}.dark\:text-blue-200\/80:where(.dark,.dark *){color:#bedbffcc}@supports (color:color-mix(in lab,red,red)){.dark\:text-blue-200\/80:where(.dark,.dark *){color:color-mix(in oklab,var(--color-blue-200)80%,transparent)}}.dark\:text-blue-300:where(.dark,.dark *){color:var(--color-blue-300)}.dark\:text-blue-300\/60:where(.dark,.dark *){color:#90c5ff99}@supports (color:color-mix(in lab,red,red)){.dark\:text-blue-300\/60:where(.dark,.dark *){color:color-mix(in oklab,var(--color-blue-300)60%,transparent)}}.dark\:text-blue-400:where(.dark,.dark *){color:var(--color-blue-400)}.dark\:text-orange-200:where(.dark,.dark *){color:var(--color-orange-200)}.dark\:text-orange-400:where(.dark,.dark *){color:var(--color-orange-400)}.dark\:text-red-400:where(.dark,.dark *){color:var(--color-red-400)}.dark\:text-red-400\/70:where(.dark,.dark *){color:#ff6568b3}@supports (color:color-mix(in lab,red,red)){.dark\:text-red-400\/70:where(.dark,.dark *){color:color-mix(in oklab,var(--color-red-400)70%,transparent)}}.dark\:text-white:where(.dark,.dark *){color:var(--color-white)}.dark\:text-yellow-200:where(.dark,.dark *){color:var(--color-yellow-200)}.dark\:text-yellow-200\/70:where(.dark,.dark *){color:#fff085b3}@supports (color:color-mix(in lab,red,red)){.dark\:text-yellow-200\/70:where(.dark,.dark *){color:color-mix(in oklab,var(--color-yellow-200)70%,transparent)}}@media(hover:hover){.dark\:hover\:bg-bambu-dark-tertiary:where(.dark,.dark *):hover{background-color:var(--color-bambu-dark-tertiary)}.dark\:hover\:bg-bambu-dark\/50:where(.dark,.dark *):hover{background-color:var(--color-bambu-dark)}@supports (color:color-mix(in lab,red,red)){.dark\:hover\:bg-bambu-dark\/50:where(.dark,.dark *):hover{background-color:color-mix(in oklab,var(--color-bambu-dark)50%,transparent)}}.dark\:hover\:bg-red-500\/30:where(.dark,.dark *):hover{background-color:#fb2c364d}@supports (color:color-mix(in lab,red,red)){.dark\:hover\:bg-red-500\/30:where(.dark,.dark *):hover{background-color:color-mix(in oklab,var(--color-red-500)30%,transparent)}}.dark\:hover\:text-white:where(.dark,.dark *):hover{color:var(--color-white)}}.\[\&\:\:-webkit-slider-thumb\]\:h-3::-webkit-slider-thumb{height:calc(var(--spacing)*3)}.\[\&\:\:-webkit-slider-thumb\]\:w-3::-webkit-slider-thumb{width:calc(var(--spacing)*3)}.\[\&\:\:-webkit-slider-thumb\]\:cursor-pointer::-webkit-slider-thumb{cursor:pointer}.\[\&\:\:-webkit-slider-thumb\]\:appearance-none::-webkit-slider-thumb{appearance:none}.\[\&\:\:-webkit-slider-thumb\]\:rounded-full::-webkit-slider-thumb{border-radius:3.40282e38px}.\[\&\:\:-webkit-slider-thumb\]\:bg-bambu-green::-webkit-slider-thumb{background-color:var(--color-bambu-green)}}:root{--accent:#00ae42;--accent-light:#00c64d;--accent-dark:#009438;--status-ok:#22c55e;--status-error:#ef4444;--status-warning:#f59e0b;--bg-primary:#f5f5f5;--bg-secondary:#fff;--bg-tertiary:#e5e5e5;--text-primary:#1a1a1a;--text-secondary:#4a4a4a;--text-muted:#6b6b6b;--text-tertiary:gray;--border-color:#d4d4d4;--card-shadow:0 2px 8px #00000014;--glow-color:transparent;font-synthesis:none;text-rendering:optimizeLegibility;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale;font-family:Inter,system-ui,sans-serif;font-weight:400;line-height:1.5}.dark{--bg-primary:#1a1a1a;--bg-secondary:#2d2d2d;--bg-tertiary:#3d3d3d;--text-primary:#fff;--text-secondary:#a0a0a0;--text-muted:gray;--text-tertiary:#4a4a4a;--border-color:#3d3d3d;--card-shadow:0 4px 16px #0006}.bg-warm{--bg-primary:#faf8f5;--bg-secondary:#fffefa;--bg-tertiary:#e8e4dd;--text-primary:#2d2a26;--text-secondary:#5c5750;--text-muted:#7a756c;--text-tertiary:#9a9590;--border-color:#d8d4cc}.bg-cool{--bg-primary:#f0f4f8;--bg-secondary:#fff;--bg-tertiary:#dce4ec;--text-primary:#1a2530;--text-secondary:#4a5568;--text-muted:#6b7a8a;--text-tertiary:#8a9aaa;--border-color:#c8d4e0}.dark.bg-neutral{--bg-primary:#1a1a1a;--bg-secondary:#2d2d2d;--bg-tertiary:#3d3d3d;--text-primary:#fff;--text-secondary:#a0a0a0;--text-muted:gray;--text-tertiary:#4a4a4a;--border-color:#3d3d3d}.dark.bg-warm{--bg-primary:#1c1a18;--bg-secondary:#2e2a26;--bg-tertiary:#3e3a36;--text-primary:#f5f0ea;--text-secondary:#b0a898;--text-muted:#8a8278;--text-tertiary:#5a5248;--border-color:#3e3a36}.dark.bg-cool{--bg-primary:#181c20;--bg-secondary:#262c32;--bg-tertiary:#363e46;--text-primary:#f0f4f8;--text-secondary:#98a8b8;--text-muted:#788898;--text-tertiary:#4a5a6a;--border-color:#363e46}.dark.bg-oled{--bg-primary:#000;--bg-secondary:#141414;--bg-tertiary:#1f1f1f;--text-primary:#fff;--text-secondary:#a0a0a0;--text-muted:#707070;--text-tertiary:#404040;--border-color:#2a2a2a}.dark.bg-slate{--bg-primary:#0f172a;--bg-secondary:#1e293b;--bg-tertiary:#334155;--text-primary:#f1f5f9;--text-secondary:#94a3b8;--text-muted:#64748b;--text-tertiary:#475569;--border-color:#334155}.dark.bg-forest{--bg-primary:#121a16;--bg-secondary:#1c2a22;--bg-tertiary:#2a3d30;--text-primary:#e8f5ec;--text-secondary:#8aa894;--text-muted:#6a8874;--text-tertiary:#4a6854;--border-color:#2a3d30}.printer-control-buttons-container{container-type:inline-size}@container (max-width:220px){.printer-control-buttons{flex-direction:column;align-items:stretch}.printer-control-buttons>button{width:100%}}.style-glow{--card-shadow:0 2px 8px #00000014,0 0 25px var(--accent)}@supports (color:color-mix(in lab,red,red)){.style-glow{--card-shadow:0 2px 8px #00000014,0 0 25px color-mix(in srgb,var(--accent)12%,transparent)}}.dark.style-glow{--card-shadow:0 4px 20px #00000080,0 0 40px var(--accent)}@supports (color:color-mix(in lab,red,red)){.dark.style-glow{--card-shadow:0 4px 20px #00000080,0 0 40px color-mix(in srgb,var(--accent)15%,transparent)}}.style-vibrant{--card-shadow:0 8px 30px #00000026,0 2px 8px #0000001a}.dark.style-vibrant{--card-shadow:0 10px 40px #0009,0 4px 12px #0006}.accent-green{--accent:#00ae42;--accent-light:#00c64d;--accent-dark:#009438}.accent-teal{--accent:#14b8a6;--accent-light:#2dd4bf;--accent-dark:#0d9488}.accent-blue{--accent:#3b82f6;--accent-light:#60a5fa;--accent-dark:#2563eb}.accent-orange{--accent:#f97316;--accent-light:#fb923c;--accent-dark:#ea580c}.accent-purple{--accent:#8b5cf6;--accent-light:#a78bfa;--accent-dark:#7c3aed}.accent-red{--accent:#ef4444;--accent-light:#f87171;--accent-dark:#dc2626}body{background-color:var(--bg-primary);color:var(--text-primary);min-height:100vh;margin:0;transition:background-color .2s,color .2s}#root{min-height:100vh}.text-white{color:var(--text-primary)}.bg-bambu-dark,.bg-bambu-dark-secondary,.bg-bambu-dark-tertiary,.border-bambu-dark-tertiary{transition:background-color .2s,border-color .2s}@keyframes slide-in{0%{opacity:0;transform:translate(100%)}to{opacity:1;transform:translate(0)}}.animate-slide-in{animation:.2s ease-out slide-in}.icon-theme{opacity:.5}.dark .icon-theme{filter:invert();opacity:.4}.icon-green{filter:invert(48%)sepia(89%)saturate(459%)hue-rotate(93deg)brightness(95%)contrast(92%);opacity:1}.icon-heating{filter:invert(50%)sepia()saturate(1000%)hue-rotate(360deg)brightness()contrast();opacity:1}.dark .jogpad-theme{filter:brightness(.35)contrast(1.2)}.ams-empty-slot{background:repeating-linear-gradient(45deg,#444,#444 2px,#222 2px 4px)}.dark .ams-empty-slot{background:repeating-linear-gradient(45deg,#555,#555 2px,#333 2px 4px)}.touch-manipulation{touch-action:manipulation}.safe-area-bottom{padding-bottom:env(safe-area-inset-bottom,0)}.safe-area-top{padding-top:env(safe-area-inset-top,0)}.scrollbar-hide{-ms-overflow-style:none;scrollbar-width:none}.scrollbar-hide::-webkit-scrollbar{display:none}@keyframes slide-in-left{0%{transform:translate(-100%)}to{transform:translate(0)}}.animate-slide-in-left{animation:.3s ease-out slide-in-left}.card-shadow{box-shadow:var(--card-shadow)}.calendar-scroll{scrollbar-width:thin;scrollbar-color:var(--text-muted)transparent}@supports (color:color-mix(in lab,red,red)){.calendar-scroll{scrollbar-color:color-mix(in srgb,var(--text-muted)60%,transparent)transparent}}.calendar-scroll::-webkit-scrollbar{width:8px}.calendar-scroll::-webkit-scrollbar-track{background:0 0}.calendar-scroll::-webkit-scrollbar-thumb{background-color:var(--text-muted)}@supports (color:color-mix(in lab,red,red)){.calendar-scroll::-webkit-scrollbar-thumb{background-color:color-mix(in srgb,var(--text-muted)60%,transparent)}}.calendar-scroll::-webkit-scrollbar-thumb{border:2px solid var(--bg-secondary);border-radius:999px}@supports (color:color-mix(in lab,red,red)){.calendar-scroll::-webkit-scrollbar-thumb{border:2px solid color-mix(in srgb,var(--bg-secondary)70%,transparent)}}.calendar-scroll::-webkit-scrollbar-thumb:hover{background-color:var(--text-muted)}@supports (color:color-mix(in lab,red,red)){.calendar-scroll::-webkit-scrollbar-thumb:hover{background-color:color-mix(in srgb,var(--text-muted)80%,transparent)}}@property --tw-translate-x{syntax:"*";inherits:false;initial-value:0}@property --tw-translate-y{syntax:"*";inherits:false;initial-value:0}@property --tw-translate-z{syntax:"*";inherits:false;initial-value:0}@property --tw-scale-x{syntax:"*";inherits:false;initial-value:1}@property --tw-scale-y{syntax:"*";inherits:false;initial-value:1}@property --tw-scale-z{syntax:"*";inherits:false;initial-value:1}@property --tw-rotate-x{syntax:"*";inherits:false}@property --tw-rotate-y{syntax:"*";inherits:false}@property --tw-rotate-z{syntax:"*";inherits:false}@property --tw-skew-x{syntax:"*";inherits:false}@property --tw-skew-y{syntax:"*";inherits:false}@property --tw-space-y-reverse{syntax:"*";inherits:false;initial-value:0}@property --tw-divide-y-reverse{syntax:"*";inherits:false;initial-value:0}@property --tw-border-style{syntax:"*";inherits:false;initial-value:solid}@property --tw-gradient-position{syntax:"*";inherits:false}@property --tw-gradient-from{syntax:"";inherits:false;initial-value:#0000}@property --tw-gradient-via{syntax:"";inherits:false;initial-value:#0000}@property --tw-gradient-to{syntax:"";inherits:false;initial-value:#0000}@property --tw-gradient-stops{syntax:"*";inherits:false}@property --tw-gradient-via-stops{syntax:"*";inherits:false}@property --tw-gradient-from-position{syntax:"";inherits:false;initial-value:0%}@property --tw-gradient-via-position{syntax:"";inherits:false;initial-value:50%}@property --tw-gradient-to-position{syntax:"";inherits:false;initial-value:100%}@property --tw-leading{syntax:"*";inherits:false}@property --tw-font-weight{syntax:"*";inherits:false}@property --tw-tracking{syntax:"*";inherits:false}@property --tw-ordinal{syntax:"*";inherits:false}@property --tw-slashed-zero{syntax:"*";inherits:false}@property --tw-numeric-figure{syntax:"*";inherits:false}@property --tw-numeric-spacing{syntax:"*";inherits:false}@property --tw-numeric-fraction{syntax:"*";inherits:false}@property --tw-shadow{syntax:"*";inherits:false;initial-value:0 0 #0000}@property --tw-shadow-color{syntax:"*";inherits:false}@property --tw-shadow-alpha{syntax:"";inherits:false;initial-value:100%}@property --tw-inset-shadow{syntax:"*";inherits:false;initial-value:0 0 #0000}@property --tw-inset-shadow-color{syntax:"*";inherits:false}@property --tw-inset-shadow-alpha{syntax:"";inherits:false;initial-value:100%}@property --tw-ring-color{syntax:"*";inherits:false}@property --tw-ring-shadow{syntax:"*";inherits:false;initial-value:0 0 #0000}@property --tw-inset-ring-color{syntax:"*";inherits:false}@property --tw-inset-ring-shadow{syntax:"*";inherits:false;initial-value:0 0 #0000}@property --tw-ring-inset{syntax:"*";inherits:false}@property --tw-ring-offset-width{syntax:"";inherits:false;initial-value:0}@property --tw-ring-offset-color{syntax:"*";inherits:false;initial-value:#fff}@property --tw-ring-offset-shadow{syntax:"*";inherits:false;initial-value:0 0 #0000}@property --tw-outline-style{syntax:"*";inherits:false;initial-value:solid}@property --tw-blur{syntax:"*";inherits:false}@property --tw-brightness{syntax:"*";inherits:false}@property --tw-contrast{syntax:"*";inherits:false}@property --tw-grayscale{syntax:"*";inherits:false}@property --tw-hue-rotate{syntax:"*";inherits:false}@property --tw-invert{syntax:"*";inherits:false}@property --tw-opacity{syntax:"*";inherits:false}@property --tw-saturate{syntax:"*";inherits:false}@property --tw-sepia{syntax:"*";inherits:false}@property --tw-drop-shadow{syntax:"*";inherits:false}@property --tw-drop-shadow-color{syntax:"*";inherits:false}@property --tw-drop-shadow-alpha{syntax:"";inherits:false;initial-value:100%}@property --tw-drop-shadow-size{syntax:"*";inherits:false}@property --tw-backdrop-blur{syntax:"*";inherits:false}@property --tw-backdrop-brightness{syntax:"*";inherits:false}@property --tw-backdrop-contrast{syntax:"*";inherits:false}@property --tw-backdrop-grayscale{syntax:"*";inherits:false}@property --tw-backdrop-hue-rotate{syntax:"*";inherits:false}@property --tw-backdrop-invert{syntax:"*";inherits:false}@property --tw-backdrop-opacity{syntax:"*";inherits:false}@property --tw-backdrop-saturate{syntax:"*";inherits:false}@property --tw-backdrop-sepia{syntax:"*";inherits:false}@property --tw-duration{syntax:"*";inherits:false}@property --tw-ease{syntax:"*";inherits:false}@property --tw-content{syntax:"*";inherits:false;initial-value:""}@keyframes spin{to{transform:rotate(360deg)}}@keyframes pulse{50%{opacity:.5}}@layer properties{@supports (((-webkit-hyphens:none)) and (not (margin-trim:inline))) or ((-moz-orient:inline) and (not (color:rgb(from red r g b)))){*,:before,:after,::backdrop{--tw-translate-x:0;--tw-translate-y:0;--tw-translate-z:0;--tw-scale-x:1;--tw-scale-y:1;--tw-scale-z:1;--tw-rotate-x:initial;--tw-rotate-y:initial;--tw-rotate-z:initial;--tw-skew-x:initial;--tw-skew-y:initial;--tw-space-y-reverse:0;--tw-divide-y-reverse:0;--tw-border-style:solid;--tw-gradient-position:initial;--tw-gradient-from:#0000;--tw-gradient-via:#0000;--tw-gradient-to:#0000;--tw-gradient-stops:initial;--tw-gradient-via-stops:initial;--tw-gradient-from-position:0%;--tw-gradient-via-position:50%;--tw-gradient-to-position:100%;--tw-leading:initial;--tw-font-weight:initial;--tw-tracking:initial;--tw-ordinal:initial;--tw-slashed-zero:initial;--tw-numeric-figure:initial;--tw-numeric-spacing:initial;--tw-numeric-fraction:initial;--tw-shadow:0 0 #0000;--tw-shadow-color:initial;--tw-shadow-alpha:100%;--tw-inset-shadow:0 0 #0000;--tw-inset-shadow-color:initial;--tw-inset-shadow-alpha:100%;--tw-ring-color:initial;--tw-ring-shadow:0 0 #0000;--tw-inset-ring-color:initial;--tw-inset-ring-shadow:0 0 #0000;--tw-ring-inset:initial;--tw-ring-offset-width:0px;--tw-ring-offset-color:#fff;--tw-ring-offset-shadow:0 0 #0000;--tw-outline-style:solid;--tw-blur:initial;--tw-brightness:initial;--tw-contrast:initial;--tw-grayscale:initial;--tw-hue-rotate:initial;--tw-invert:initial;--tw-opacity:initial;--tw-saturate:initial;--tw-sepia:initial;--tw-drop-shadow:initial;--tw-drop-shadow-color:initial;--tw-drop-shadow-alpha:100%;--tw-drop-shadow-size:initial;--tw-backdrop-blur:initial;--tw-backdrop-brightness:initial;--tw-backdrop-contrast:initial;--tw-backdrop-grayscale:initial;--tw-backdrop-hue-rotate:initial;--tw-backdrop-invert:initial;--tw-backdrop-opacity:initial;--tw-backdrop-saturate:initial;--tw-backdrop-sepia:initial;--tw-duration:initial;--tw-ease:initial;--tw-content:""}}} diff --git a/static/assets/index-tulFiIvt.css b/static/assets/index-tulFiIvt.css deleted file mode 100644 index 26f87987b..000000000 --- a/static/assets/index-tulFiIvt.css +++ /dev/null @@ -1 +0,0 @@ -@import"https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap";@layer properties,theme,base,components,utilities;@layer theme{:root,:host{--font-sans:ui-sans-serif,system-ui,sans-serif,"Apple Color Emoji","Segoe UI Emoji","Segoe UI Symbol","Noto Color Emoji";--font-mono:ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,"Liberation Mono","Courier New",monospace;--color-red-50:oklch(97.1% .013 17.38);--color-red-100:oklch(93.6% .032 17.717);--color-red-200:oklch(88.5% .062 18.334);--color-red-300:oklch(80.8% .114 19.571);--color-red-400:oklch(70.4% .191 22.216);--color-red-500:oklch(63.7% .237 25.331);--color-red-600:oklch(57.7% .245 27.325);--color-red-700:oklch(50.5% .213 27.518);--color-red-800:oklch(44.4% .177 26.899);--color-red-950:oklch(25.8% .092 26.042);--color-orange-200:oklch(90.1% .076 70.697);--color-orange-300:oklch(83.7% .128 66.29);--color-orange-400:oklch(75% .183 55.934);--color-orange-500:oklch(70.5% .213 47.604);--color-orange-600:oklch(64.6% .222 41.116);--color-orange-700:oklch(55.3% .195 38.402);--color-amber-50:oklch(98.7% .022 95.277);--color-amber-200:oklch(92.4% .12 95.746);--color-amber-300:oklch(87.9% .169 91.605);--color-amber-400:oklch(82.8% .189 84.429);--color-amber-500:oklch(76.9% .188 70.08);--color-amber-600:oklch(66.6% .179 58.318);--color-yellow-200:oklch(94.5% .129 101.54);--color-yellow-300:oklch(90.5% .182 98.111);--color-yellow-400:oklch(85.2% .199 91.936);--color-yellow-500:oklch(79.5% .184 86.047);--color-yellow-600:oklch(68.1% .162 75.834);--color-yellow-700:oklch(55.4% .135 66.442);--color-lime-500:oklch(76.8% .233 130.85);--color-green-100:oklch(96.2% .044 156.743);--color-green-200:oklch(92.5% .084 155.995);--color-green-300:oklch(87.1% .15 154.449);--color-green-400:oklch(79.2% .209 151.711);--color-green-500:oklch(72.3% .219 149.579);--color-green-600:oklch(62.7% .194 149.214);--color-green-900:oklch(39.3% .095 152.535);--color-emerald-400:oklch(76.5% .177 163.223);--color-emerald-500:oklch(69.6% .17 162.48);--color-emerald-700:oklch(50.8% .118 165.612);--color-teal-400:oklch(77.7% .152 181.912);--color-teal-500:oklch(70.4% .14 182.503);--color-cyan-300:oklch(86.5% .127 207.078);--color-cyan-400:oklch(78.9% .154 211.53);--color-cyan-500:oklch(71.5% .143 215.221);--color-cyan-600:oklch(60.9% .126 221.723);--color-sky-400:oklch(74.6% .16 232.661);--color-sky-500:oklch(68.5% .169 237.323);--color-blue-50:oklch(97% .014 254.604);--color-blue-100:oklch(93.2% .032 255.585);--color-blue-200:oklch(88.2% .059 254.128);--color-blue-300:oklch(80.9% .105 251.813);--color-blue-400:oklch(70.7% .165 254.624);--color-blue-500:oklch(62.3% .214 259.815);--color-blue-600:oklch(54.6% .245 262.881);--color-blue-700:oklch(48.8% .243 264.376);--color-indigo-400:oklch(67.3% .182 276.935);--color-indigo-500:oklch(58.5% .233 277.117);--color-violet-500:oklch(60.6% .25 292.717);--color-purple-300:oklch(82.7% .119 306.383);--color-purple-400:oklch(71.4% .203 305.504);--color-purple-500:oklch(62.7% .265 303.9);--color-purple-700:oklch(49.6% .265 301.924);--color-fuchsia-500:oklch(66.7% .295 322.15);--color-rose-300:oklch(81% .117 11.638);--color-rose-400:oklch(71.2% .194 13.428);--color-rose-500:oklch(64.5% .246 16.439);--color-rose-600:oklch(58.6% .253 17.585);--color-slate-300:oklch(86.9% .022 252.894);--color-slate-500:oklch(55.4% .046 257.417);--color-gray-50:oklch(98.5% .002 247.839);--color-gray-100:oklch(96.7% .003 264.542);--color-gray-200:oklch(92.8% .006 264.531);--color-gray-300:oklch(87.2% .01 258.338);--color-gray-400:oklch(70.7% .022 261.325);--color-gray-500:oklch(55.1% .027 264.364);--color-gray-600:oklch(44.6% .03 256.802);--color-gray-700:oklch(37.3% .034 259.733);--color-gray-800:oklch(27.8% .033 256.848);--color-gray-900:oklch(21% .034 264.665);--color-black:#000;--color-white:#fff;--spacing:.25rem;--container-xs:20rem;--container-sm:24rem;--container-md:28rem;--container-lg:32rem;--container-xl:36rem;--container-2xl:42rem;--container-3xl:48rem;--container-4xl:56rem;--container-5xl:64rem;--container-6xl:72rem;--text-xs:.75rem;--text-xs--line-height:calc(1/.75);--text-sm:.875rem;--text-sm--line-height:calc(1.25/.875);--text-base:1rem;--text-base--line-height: 1.5 ;--text-lg:1.125rem;--text-lg--line-height:calc(1.75/1.125);--text-xl:1.25rem;--text-xl--line-height:calc(1.75/1.25);--text-2xl:1.5rem;--text-2xl--line-height:calc(2/1.5);--text-3xl:1.875rem;--text-3xl--line-height: 1.2 ;--font-weight-normal:400;--font-weight-medium:500;--font-weight-semibold:600;--font-weight-bold:700;--tracking-wide:.025em;--tracking-wider:.05em;--tracking-widest:.1em;--leading-tight:1.25;--radius-sm:.25rem;--radius-md:.375rem;--radius-lg:.5rem;--radius-xl:.75rem;--radius-2xl:1rem;--drop-shadow-md:0 3px 3px #0000001f;--drop-shadow-lg:0 4px 4px #00000026;--ease-out:cubic-bezier(0,0,.2,1);--ease-in-out:cubic-bezier(.4,0,.2,1);--animate-spin:spin 1s linear infinite;--animate-pulse:pulse 2s cubic-bezier(.4,0,.6,1)infinite;--blur-sm:8px;--blur-2xl:40px;--aspect-video:16/9;--default-transition-duration:.15s;--default-transition-timing-function:cubic-bezier(.4,0,.2,1);--default-font-family:var(--font-sans);--default-mono-font-family:var(--font-mono);--color-bambu-green:var(--accent);--color-bambu-green-light:var(--accent-light);--color-bambu-green-dark:var(--accent-dark);--color-status-ok:var(--status-ok);--color-status-error:var(--status-error);--color-status-warning:var(--status-warning);--color-bambu-dark:var(--bg-primary);--color-bambu-dark-secondary:var(--bg-secondary);--color-bambu-dark-tertiary:var(--bg-tertiary);--color-bambu-gray:var(--text-muted);--color-bambu-gray-light:var(--text-secondary);--color-bambu-gray-dark:var(--text-tertiary)}}@layer base{*,:after,:before,::backdrop{box-sizing:border-box;border:0 solid;margin:0;padding:0}::file-selector-button{box-sizing:border-box;border:0 solid;margin:0;padding:0}html,:host{-webkit-text-size-adjust:100%;tab-size:4;line-height:1.5;font-family:var(--default-font-family,ui-sans-serif,system-ui,sans-serif,"Apple Color Emoji","Segoe UI Emoji","Segoe UI Symbol","Noto Color Emoji");font-feature-settings:var(--default-font-feature-settings,normal);font-variation-settings:var(--default-font-variation-settings,normal);-webkit-tap-highlight-color:transparent}hr{height:0;color:inherit;border-top-width:1px}abbr:where([title]){-webkit-text-decoration:underline dotted;text-decoration:underline dotted}h1,h2,h3,h4,h5,h6{font-size:inherit;font-weight:inherit}a{color:inherit;-webkit-text-decoration:inherit;text-decoration:inherit}b,strong{font-weight:bolder}code,kbd,samp,pre{font-family:var(--default-mono-font-family,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,"Liberation Mono","Courier New",monospace);font-feature-settings:var(--default-mono-font-feature-settings,normal);font-variation-settings:var(--default-mono-font-variation-settings,normal);font-size:1em}small{font-size:80%}sub,sup{vertical-align:baseline;font-size:75%;line-height:0;position:relative}sub{bottom:-.25em}sup{top:-.5em}table{text-indent:0;border-color:inherit;border-collapse:collapse}:-moz-focusring{outline:auto}progress{vertical-align:baseline}summary{display:list-item}ol,ul,menu{list-style:none}img,svg,video,canvas,audio,iframe,embed,object{vertical-align:middle;display:block}img,video{max-width:100%;height:auto}button,input,select,optgroup,textarea{font:inherit;font-feature-settings:inherit;font-variation-settings:inherit;letter-spacing:inherit;color:inherit;opacity:1;background-color:#0000;border-radius:0}::file-selector-button{font:inherit;font-feature-settings:inherit;font-variation-settings:inherit;letter-spacing:inherit;color:inherit;opacity:1;background-color:#0000;border-radius:0}:where(select:is([multiple],[size])) optgroup{font-weight:bolder}:where(select:is([multiple],[size])) optgroup option{padding-inline-start:20px}::file-selector-button{margin-inline-end:4px}::placeholder{opacity:1}@supports (not ((-webkit-appearance:-apple-pay-button))) or (contain-intrinsic-size:1px){::placeholder{color:currentColor}@supports (color:color-mix(in lab,red,red)){::placeholder{color:color-mix(in oklab,currentcolor 50%,transparent)}}}textarea{resize:vertical}::-webkit-search-decoration{-webkit-appearance:none}::-webkit-date-and-time-value{min-height:1lh;text-align:inherit}::-webkit-datetime-edit{display:inline-flex}::-webkit-datetime-edit-fields-wrapper{padding:0}::-webkit-datetime-edit{padding-block:0}::-webkit-datetime-edit-year-field{padding-block:0}::-webkit-datetime-edit-month-field{padding-block:0}::-webkit-datetime-edit-day-field{padding-block:0}::-webkit-datetime-edit-hour-field{padding-block:0}::-webkit-datetime-edit-minute-field{padding-block:0}::-webkit-datetime-edit-second-field{padding-block:0}::-webkit-datetime-edit-millisecond-field{padding-block:0}::-webkit-datetime-edit-meridiem-field{padding-block:0}::-webkit-calendar-picker-indicator{line-height:1}:-moz-ui-invalid{box-shadow:none}button,input:where([type=button],[type=reset],[type=submit]){appearance:button}::file-selector-button{appearance:button}::-webkit-inner-spin-button{height:auto}::-webkit-outer-spin-button{height:auto}[hidden]:where(:not([hidden=until-found])){display:none!important}}@layer utilities{.pointer-events-none{pointer-events:none}.collapse{visibility:collapse}.visible{visibility:visible}.sr-only{clip-path:inset(50%);white-space:nowrap;border-width:0;width:1px;height:1px;margin:-1px;padding:0;position:absolute;overflow:hidden}.absolute{position:absolute}.fixed{position:fixed}.relative{position:relative}.static{position:static}.sticky{position:sticky}.inset-0{inset:calc(var(--spacing)*0)}.inset-x-0{inset-inline:calc(var(--spacing)*0)}.inset-y-0{inset-block:calc(var(--spacing)*0)}.-top-1{top:calc(var(--spacing)*-1)}.-top-1\.5{top:calc(var(--spacing)*-1.5)}.top-0{top:calc(var(--spacing)*0)}.top-0\.5{top:calc(var(--spacing)*.5)}.top-1{top:calc(var(--spacing)*1)}.top-1\.5{top:calc(var(--spacing)*1.5)}.top-1\/2{top:50%}.top-2{top:calc(var(--spacing)*2)}.top-2\.5{top:calc(var(--spacing)*2.5)}.top-4{top:calc(var(--spacing)*4)}.top-8{top:calc(var(--spacing)*8)}.top-\[2px\]{top:2px}.top-\[3px\]{top:3px}.top-\[52px\]{top:52px}.top-full{top:100%}.-right-1{right:calc(var(--spacing)*-1)}.-right-1\.5{right:calc(var(--spacing)*-1.5)}.right-0{right:calc(var(--spacing)*0)}.right-1{right:calc(var(--spacing)*1)}.right-1\.5{right:calc(var(--spacing)*1.5)}.right-2{right:calc(var(--spacing)*2)}.right-3{right:calc(var(--spacing)*3)}.right-4{right:calc(var(--spacing)*4)}.right-6{right:calc(var(--spacing)*6)}.right-12{right:calc(var(--spacing)*12)}.right-\[5\.5rem\]{right:5.5rem}.right-full{right:100%}.-bottom-1{bottom:calc(var(--spacing)*-1)}.-bottom-2{bottom:calc(var(--spacing)*-2)}.-bottom-7{bottom:calc(var(--spacing)*-7)}.bottom-0{bottom:calc(var(--spacing)*0)}.bottom-1{bottom:calc(var(--spacing)*1)}.bottom-2{bottom:calc(var(--spacing)*2)}.bottom-4{bottom:calc(var(--spacing)*4)}.bottom-6{bottom:calc(var(--spacing)*6)}.bottom-8{bottom:calc(var(--spacing)*8)}.bottom-full{bottom:100%}.-left-2{left:calc(var(--spacing)*-2)}.left-0{left:calc(var(--spacing)*0)}.left-1{left:calc(var(--spacing)*1)}.left-1\/2{left:50%}.left-2{left:calc(var(--spacing)*2)}.left-2\.5{left:calc(var(--spacing)*2.5)}.left-3{left:calc(var(--spacing)*3)}.left-4{left:calc(var(--spacing)*4)}.left-10{left:calc(var(--spacing)*10)}.left-12{left:calc(var(--spacing)*12)}.left-\[2px\]{left:2px}.left-\[3px\]{left:3px}.left-full{left:100%}.z-0{z-index:0}.z-10{z-index:10}.z-20{z-index:20}.z-30{z-index:30}.z-40{z-index:40}.z-50{z-index:50}.z-60,.z-\[60\]{z-index:60}.z-\[100\]{z-index:100}.col-span-1{grid-column:span 1/span 1}.col-span-2{grid-column:span 2/span 2}.col-span-3{grid-column:span 3/span 3}.col-span-4{grid-column:span 4/span 4}.container{width:100%}@media(min-width:40rem){.container{max-width:40rem}}@media(min-width:48rem){.container{max-width:48rem}}@media(min-width:64rem){.container{max-width:64rem}}@media(min-width:80rem){.container{max-width:80rem}}@media(min-width:96rem){.container{max-width:96rem}}.-m-4{margin:calc(var(--spacing)*-4)}.-mx-4{margin-inline:calc(var(--spacing)*-4)}.mx-1{margin-inline:calc(var(--spacing)*1)}.mx-2{margin-inline:calc(var(--spacing)*2)}.mx-4{margin-inline:calc(var(--spacing)*4)}.mx-auto{margin-inline:auto}.my-1{margin-block:calc(var(--spacing)*1)}.my-8{margin-block:calc(var(--spacing)*8)}.-mt-2{margin-top:calc(var(--spacing)*-2)}.mt-0\.5{margin-top:calc(var(--spacing)*.5)}.mt-1{margin-top:calc(var(--spacing)*1)}.mt-1\.5{margin-top:calc(var(--spacing)*1.5)}.mt-2{margin-top:calc(var(--spacing)*2)}.mt-3{margin-top:calc(var(--spacing)*3)}.mt-4{margin-top:calc(var(--spacing)*4)}.mt-6{margin-top:calc(var(--spacing)*6)}.mt-8{margin-top:calc(var(--spacing)*8)}.mt-14{margin-top:calc(var(--spacing)*14)}.mt-auto{margin-top:auto}.mr-1{margin-right:calc(var(--spacing)*1)}.mr-2{margin-right:calc(var(--spacing)*2)}.mr-3{margin-right:calc(var(--spacing)*3)}.mr-4{margin-right:calc(var(--spacing)*4)}.mr-auto{margin-right:auto}.-mb-px{margin-bottom:-1px}.mb-0\.5{margin-bottom:calc(var(--spacing)*.5)}.mb-1{margin-bottom:calc(var(--spacing)*1)}.mb-1\.5{margin-bottom:calc(var(--spacing)*1.5)}.mb-2{margin-bottom:calc(var(--spacing)*2)}.mb-3{margin-bottom:calc(var(--spacing)*3)}.mb-4{margin-bottom:calc(var(--spacing)*4)}.mb-5{margin-bottom:calc(var(--spacing)*5)}.mb-6{margin-bottom:calc(var(--spacing)*6)}.mb-8{margin-bottom:calc(var(--spacing)*8)}.-ml-1{margin-left:calc(var(--spacing)*-1)}.-ml-2{margin-left:calc(var(--spacing)*-2)}.ml-0\.5{margin-left:calc(var(--spacing)*.5)}.ml-1{margin-left:calc(var(--spacing)*1)}.ml-1\.5{margin-left:calc(var(--spacing)*1.5)}.ml-2{margin-left:calc(var(--spacing)*2)}.ml-3{margin-left:calc(var(--spacing)*3)}.ml-4{margin-left:calc(var(--spacing)*4)}.ml-6{margin-left:calc(var(--spacing)*6)}.ml-7{margin-left:calc(var(--spacing)*7)}.ml-9{margin-left:calc(var(--spacing)*9)}.ml-14{margin-left:calc(var(--spacing)*14)}.ml-16{margin-left:calc(var(--spacing)*16)}.ml-64{margin-left:calc(var(--spacing)*64)}.ml-auto{margin-left:auto}.line-clamp-1{-webkit-line-clamp:1;-webkit-box-orient:vertical;display:-webkit-box;overflow:hidden}.block{display:block}.flex{display:flex}.grid{display:grid}.hidden{display:none}.inline{display:inline}.inline-block{display:inline-block}.inline-flex{display:inline-flex}.table{display:table}.aspect-square{aspect-ratio:1}.aspect-video{aspect-ratio:var(--aspect-video)}.h-0{height:calc(var(--spacing)*0)}.h-0\.5{height:calc(var(--spacing)*.5)}.h-1{height:calc(var(--spacing)*1)}.h-1\.5{height:calc(var(--spacing)*1.5)}.h-2{height:calc(var(--spacing)*2)}.h-2\.5{height:calc(var(--spacing)*2.5)}.h-3{height:calc(var(--spacing)*3)}.h-3\.5{height:calc(var(--spacing)*3.5)}.h-4{height:calc(var(--spacing)*4)}.h-5{height:calc(var(--spacing)*5)}.h-6{height:calc(var(--spacing)*6)}.h-7{height:calc(var(--spacing)*7)}.h-8{height:calc(var(--spacing)*8)}.h-10{height:calc(var(--spacing)*10)}.h-12{height:calc(var(--spacing)*12)}.h-14{height:calc(var(--spacing)*14)}.h-16{height:calc(var(--spacing)*16)}.h-20{height:calc(var(--spacing)*20)}.h-24{height:calc(var(--spacing)*24)}.h-48{height:calc(var(--spacing)*48)}.h-64{height:calc(var(--spacing)*64)}.h-80{height:calc(var(--spacing)*80)}.h-\[18px\]{height:18px}.h-\[38px\]{height:38px}.h-\[80vh\]{height:80vh}.h-\[160px\]{height:160px}.h-\[300px\]{height:300px}.h-\[calc\(100\%-40px\)\]{height:calc(100% - 40px)}.h-full{height:100%}.h-px{height:1px}.max-h-40{max-height:calc(var(--spacing)*40)}.max-h-48{max-height:calc(var(--spacing)*48)}.max-h-60{max-height:calc(var(--spacing)*60)}.max-h-64{max-height:calc(var(--spacing)*64)}.max-h-80{max-height:calc(var(--spacing)*80)}.max-h-96{max-height:calc(var(--spacing)*96)}.max-h-\[60vh\]{max-height:60vh}.max-h-\[80vh\]{max-height:80vh}.max-h-\[85vh\]{max-height:85vh}.max-h-\[90vh\]{max-height:90vh}.max-h-\[300px\]{max-height:300px}.max-h-\[400px\]{max-height:400px}.max-h-\[500px\]{max-height:500px}.max-h-\[600px\]{max-height:600px}.max-h-\[calc\(90vh-80px\)\]{max-height:calc(90vh - 80px)}.max-h-\[calc\(100vh-320px\)\]{max-height:calc(100vh - 320px)}.max-h-full{max-height:100%}.min-h-0{min-height:calc(var(--spacing)*0)}.min-h-\[44px\]{min-height:44px}.min-h-\[48px\]{min-height:48px}.min-h-\[80px\]{min-height:80px}.min-h-\[120px\]{min-height:120px}.min-h-\[300px\]{min-height:300px}.min-h-\[400px\]{min-height:400px}.min-h-\[calc\(100vh-64px\)\]{min-height:calc(100vh - 64px)}.min-h-full{min-height:100%}.min-h-screen{min-height:100vh}.w-0{width:calc(var(--spacing)*0)}.w-0\.5{width:calc(var(--spacing)*.5)}.w-1\.5{width:calc(var(--spacing)*1.5)}.w-1\/3{width:33.3333%}.w-2{width:calc(var(--spacing)*2)}.w-2\.5{width:calc(var(--spacing)*2.5)}.w-3{width:calc(var(--spacing)*3)}.w-3\.5{width:calc(var(--spacing)*3.5)}.w-4{width:calc(var(--spacing)*4)}.w-4\.5{width:calc(var(--spacing)*4.5)}.w-5{width:calc(var(--spacing)*5)}.w-6{width:calc(var(--spacing)*6)}.w-7{width:calc(var(--spacing)*7)}.w-8{width:calc(var(--spacing)*8)}.w-9{width:calc(var(--spacing)*9)}.w-10{width:calc(var(--spacing)*10)}.w-11{width:calc(var(--spacing)*11)}.w-12{width:calc(var(--spacing)*12)}.w-14{width:calc(var(--spacing)*14)}.w-16{width:calc(var(--spacing)*16)}.w-20{width:calc(var(--spacing)*20)}.w-24{width:calc(var(--spacing)*24)}.w-32{width:calc(var(--spacing)*32)}.w-36{width:calc(var(--spacing)*36)}.w-40{width:calc(var(--spacing)*40)}.w-44{width:calc(var(--spacing)*44)}.w-48{width:calc(var(--spacing)*48)}.w-52{width:calc(var(--spacing)*52)}.w-56{width:calc(var(--spacing)*56)}.w-64{width:calc(var(--spacing)*64)}.w-72{width:calc(var(--spacing)*72)}.w-96{width:calc(var(--spacing)*96)}.w-\[560px\]{width:560px}.w-auto{width:auto}.w-fit{width:fit-content}.w-full{width:100%}.w-px{width:1px}.max-w-2xl{max-width:var(--container-2xl)}.max-w-3xl{max-width:var(--container-3xl)}.max-w-4xl{max-width:var(--container-4xl)}.max-w-5xl{max-width:var(--container-5xl)}.max-w-6xl{max-width:var(--container-6xl)}.max-w-32{max-width:calc(var(--spacing)*32)}.max-w-\[40\%\]{max-width:40%}.max-w-\[50\%\]{max-width:50%}.max-w-\[80px\]{max-width:80px}.max-w-\[90vw\]{max-width:90vw}.max-w-\[100px\]{max-width:100px}.max-w-\[120px\]{max-width:120px}.max-w-\[150px\]{max-width:150px}.max-w-\[160px\]{max-width:160px}.max-w-\[200px\]{max-width:200px}.max-w-\[280px\]{max-width:280px}.max-w-\[600px\]{max-width:600px}.max-w-full{max-width:100%}.max-w-lg{max-width:var(--container-lg)}.max-w-md{max-width:var(--container-md)}.max-w-none{max-width:none}.max-w-sm{max-width:var(--container-sm)}.max-w-xs{max-width:var(--container-xs)}.min-w-0{min-width:calc(var(--spacing)*0)}.min-w-48{min-width:calc(var(--spacing)*48)}.min-w-\[16px\]{min-width:16px}.min-w-\[18px\]{min-width:18px}.min-w-\[32px\]{min-width:32px}.min-w-\[40px\]{min-width:40px}.min-w-\[48px\]{min-width:48px}.min-w-\[80px\]{min-width:80px}.min-w-\[100px\]{min-width:100px}.min-w-\[120px\]{min-width:120px}.min-w-\[140px\]{min-width:140px}.min-w-\[150px\]{min-width:150px}.min-w-\[160px\]{min-width:160px}.min-w-\[180px\]{min-width:180px}.min-w-\[200px\]{min-width:200px}.min-w-full{min-width:100%}.flex-1{flex:1}.flex-\[2_1_190px\]{flex:2 190px}.flex-shrink{flex-shrink:1}.flex-shrink-0,.shrink-0{flex-shrink:0}.-translate-x-1\/2{--tw-translate-x: -50% ;translate:var(--tw-translate-x)var(--tw-translate-y)}.-translate-x-full{--tw-translate-x:-100%;translate:var(--tw-translate-x)var(--tw-translate-y)}.translate-x-0{--tw-translate-x:calc(var(--spacing)*0);translate:var(--tw-translate-x)var(--tw-translate-y)}.translate-x-0\.5{--tw-translate-x:calc(var(--spacing)*.5);translate:var(--tw-translate-x)var(--tw-translate-y)}.translate-x-1{--tw-translate-x:calc(var(--spacing)*1);translate:var(--tw-translate-x)var(--tw-translate-y)}.translate-x-3\.5{--tw-translate-x:calc(var(--spacing)*3.5);translate:var(--tw-translate-x)var(--tw-translate-y)}.translate-x-4{--tw-translate-x:calc(var(--spacing)*4);translate:var(--tw-translate-x)var(--tw-translate-y)}.translate-x-5{--tw-translate-x:calc(var(--spacing)*5);translate:var(--tw-translate-x)var(--tw-translate-y)}.translate-x-6{--tw-translate-x:calc(var(--spacing)*6);translate:var(--tw-translate-x)var(--tw-translate-y)}.-translate-y-1\/2{--tw-translate-y: -50% ;translate:var(--tw-translate-x)var(--tw-translate-y)}.scale-105{--tw-scale-x:105%;--tw-scale-y:105%;--tw-scale-z:105%;scale:var(--tw-scale-x)var(--tw-scale-y)}.scale-110{--tw-scale-x:110%;--tw-scale-y:110%;--tw-scale-z:110%;scale:var(--tw-scale-x)var(--tw-scale-y)}.scale-\[1\.02\]{scale:1.02}.-rotate-90{rotate:-90deg}.rotate-90{rotate:90deg}.rotate-180{rotate:180deg}.transform{transform:var(--tw-rotate-x,)var(--tw-rotate-y,)var(--tw-rotate-z,)var(--tw-skew-x,)var(--tw-skew-y,)}.animate-pulse{animation:var(--animate-pulse)}.animate-spin{animation:var(--animate-spin)}.cursor-col-resize{cursor:col-resize}.cursor-default{cursor:default}.cursor-ew-resize{cursor:ew-resize}.cursor-grab{cursor:grab}.cursor-not-allowed{cursor:not-allowed}.cursor-pointer{cursor:pointer}.cursor-row-resize{cursor:row-resize}.cursor-se-resize{cursor:se-resize}.touch-manipulation{touch-action:manipulation}.resize{resize:both}.resize-none{resize:none}.resize-y{resize:vertical}.list-inside{list-style-position:inside}.list-decimal{list-style-type:decimal}.list-disc{list-style-type:disc}.appearance-none{appearance:none}.grid-cols-1{grid-template-columns:repeat(1,minmax(0,1fr))}.grid-cols-2{grid-template-columns:repeat(2,minmax(0,1fr))}.grid-cols-3{grid-template-columns:repeat(3,minmax(0,1fr))}.grid-cols-4{grid-template-columns:repeat(4,minmax(0,1fr))}.grid-cols-5{grid-template-columns:repeat(5,minmax(0,1fr))}.grid-cols-7{grid-template-columns:repeat(7,minmax(0,1fr))}.grid-cols-12{grid-template-columns:repeat(12,minmax(0,1fr))}.grid-cols-\[auto_1fr_100px_100px_100px_80px\]{grid-template-columns:auto 1fr 100px 100px 100px 80px}.grid-cols-\[auto_1fr_120px_100px_100px_100px_80px\]{grid-template-columns:auto 1fr 120px 100px 100px 100px 80px}.flex-col{flex-direction:column}.flex-row{flex-direction:row}.flex-wrap{flex-wrap:wrap}.items-center{align-items:center}.items-end{align-items:flex-end}.items-start{align-items:flex-start}.items-stretch{align-items:stretch}.justify-between{justify-content:space-between}.justify-center{justify-content:center}.justify-end{justify-content:flex-end}.gap-0{gap:calc(var(--spacing)*0)}.gap-0\.5{gap:calc(var(--spacing)*.5)}.gap-1{gap:calc(var(--spacing)*1)}.gap-1\.5{gap:calc(var(--spacing)*1.5)}.gap-2{gap:calc(var(--spacing)*2)}.gap-3{gap:calc(var(--spacing)*3)}.gap-4{gap:calc(var(--spacing)*4)}.gap-6{gap:calc(var(--spacing)*6)}.gap-8{gap:calc(var(--spacing)*8)}.gap-\[3px\]{gap:3px}:where(.space-y-0\.5>:not(:last-child)){--tw-space-y-reverse:0;margin-block-start:calc(calc(var(--spacing)*.5)*var(--tw-space-y-reverse));margin-block-end:calc(calc(var(--spacing)*.5)*calc(1 - var(--tw-space-y-reverse)))}:where(.space-y-1>:not(:last-child)){--tw-space-y-reverse:0;margin-block-start:calc(calc(var(--spacing)*1)*var(--tw-space-y-reverse));margin-block-end:calc(calc(var(--spacing)*1)*calc(1 - var(--tw-space-y-reverse)))}:where(.space-y-1\.5>:not(:last-child)){--tw-space-y-reverse:0;margin-block-start:calc(calc(var(--spacing)*1.5)*var(--tw-space-y-reverse));margin-block-end:calc(calc(var(--spacing)*1.5)*calc(1 - var(--tw-space-y-reverse)))}:where(.space-y-2>:not(:last-child)){--tw-space-y-reverse:0;margin-block-start:calc(calc(var(--spacing)*2)*var(--tw-space-y-reverse));margin-block-end:calc(calc(var(--spacing)*2)*calc(1 - var(--tw-space-y-reverse)))}:where(.space-y-2\.5>:not(:last-child)){--tw-space-y-reverse:0;margin-block-start:calc(calc(var(--spacing)*2.5)*var(--tw-space-y-reverse));margin-block-end:calc(calc(var(--spacing)*2.5)*calc(1 - var(--tw-space-y-reverse)))}:where(.space-y-3>:not(:last-child)){--tw-space-y-reverse:0;margin-block-start:calc(calc(var(--spacing)*3)*var(--tw-space-y-reverse));margin-block-end:calc(calc(var(--spacing)*3)*calc(1 - var(--tw-space-y-reverse)))}:where(.space-y-4>:not(:last-child)){--tw-space-y-reverse:0;margin-block-start:calc(calc(var(--spacing)*4)*var(--tw-space-y-reverse));margin-block-end:calc(calc(var(--spacing)*4)*calc(1 - var(--tw-space-y-reverse)))}:where(.space-y-6>:not(:last-child)){--tw-space-y-reverse:0;margin-block-start:calc(calc(var(--spacing)*6)*var(--tw-space-y-reverse));margin-block-end:calc(calc(var(--spacing)*6)*calc(1 - var(--tw-space-y-reverse)))}:where(.space-y-8>:not(:last-child)){--tw-space-y-reverse:0;margin-block-start:calc(calc(var(--spacing)*8)*var(--tw-space-y-reverse));margin-block-end:calc(calc(var(--spacing)*8)*calc(1 - var(--tw-space-y-reverse)))}.gap-x-4{column-gap:calc(var(--spacing)*4)}.gap-x-6{column-gap:calc(var(--spacing)*6)}.gap-y-1{row-gap:calc(var(--spacing)*1)}.gap-y-2{row-gap:calc(var(--spacing)*2)}.gap-y-3{row-gap:calc(var(--spacing)*3)}:where(.divide-y>:not(:last-child)){--tw-divide-y-reverse:0;border-bottom-style:var(--tw-border-style);border-top-style:var(--tw-border-style);border-top-width:calc(1px*var(--tw-divide-y-reverse));border-bottom-width:calc(1px*calc(1 - var(--tw-divide-y-reverse)))}:where(.divide-bambu-dark-tertiary>:not(:last-child)),:where(.divide-bambu-dark-tertiary\/30>:not(:last-child)){border-color:var(--color-bambu-dark-tertiary)}@supports (color:color-mix(in lab,red,red)){:where(.divide-bambu-dark-tertiary\/30>:not(:last-child)){border-color:color-mix(in oklab,var(--color-bambu-dark-tertiary)30%,transparent)}}:where(.divide-bambu-gray\/20>:not(:last-child)){border-color:var(--color-bambu-gray)}@supports (color:color-mix(in lab,red,red)){:where(.divide-bambu-gray\/20>:not(:last-child)){border-color:color-mix(in oklab,var(--color-bambu-gray)20%,transparent)}}.truncate{text-overflow:ellipsis;white-space:nowrap;overflow:hidden}.overflow-auto{overflow:auto}.overflow-hidden{overflow:hidden}.overflow-x-auto{overflow-x:auto}.overflow-y-auto{overflow-y:auto}.rounded{border-radius:.25rem}.rounded-2xl{border-radius:var(--radius-2xl)}.rounded-full{border-radius:3.40282e38px}.rounded-lg{border-radius:var(--radius-lg)}.rounded-md{border-radius:var(--radius-md)}.rounded-none{border-radius:0}.rounded-sm{border-radius:var(--radius-sm)}.rounded-xl{border-radius:var(--radius-xl)}.rounded-t-lg{border-top-left-radius:var(--radius-lg);border-top-right-radius:var(--radius-lg)}.rounded-t-xl{border-top-left-radius:var(--radius-xl);border-top-right-radius:var(--radius-xl)}.\!rounded-l-none{border-top-left-radius:0!important;border-bottom-left-radius:0!important}.rounded-l{border-top-left-radius:.25rem;border-bottom-left-radius:.25rem}.rounded-l-lg{border-top-left-radius:var(--radius-lg);border-bottom-left-radius:var(--radius-lg)}.rounded-tl{border-top-left-radius:.25rem}.\!rounded-r-none{border-top-right-radius:0!important;border-bottom-right-radius:0!important}.rounded-r{border-top-right-radius:.25rem;border-bottom-right-radius:.25rem}.rounded-r-lg{border-top-right-radius:var(--radius-lg);border-bottom-right-radius:var(--radius-lg)}.rounded-b-lg{border-bottom-right-radius:var(--radius-lg);border-bottom-left-radius:var(--radius-lg)}.border{border-style:var(--tw-border-style);border-width:1px}.border-0{border-style:var(--tw-border-style);border-width:0}.border-2{border-style:var(--tw-border-style);border-width:2px}.border-4{border-style:var(--tw-border-style);border-width:4px}.border-t{border-top-style:var(--tw-border-style);border-top-width:1px}.border-t-\[5px\]{border-top-style:var(--tw-border-style);border-top-width:5px}.border-t-\[6px\]{border-top-style:var(--tw-border-style);border-top-width:6px}.\!border-r-0{border-right-style:var(--tw-border-style)!important;border-right-width:0!important}.border-r{border-right-style:var(--tw-border-style);border-right-width:1px}.border-r-\[5px\]{border-right-style:var(--tw-border-style);border-right-width:5px}.border-r-\[6px\]{border-right-style:var(--tw-border-style);border-right-width:6px}.border-b{border-bottom-style:var(--tw-border-style);border-bottom-width:1px}.border-b-2{border-bottom-style:var(--tw-border-style);border-bottom-width:2px}.border-b-\[6px\]{border-bottom-style:var(--tw-border-style);border-bottom-width:6px}.border-l{border-left-style:var(--tw-border-style);border-left-width:1px}.border-l-2{border-left-style:var(--tw-border-style);border-left-width:2px}.border-l-4{border-left-style:var(--tw-border-style);border-left-width:4px}.border-l-\[5px\]{border-left-style:var(--tw-border-style);border-left-width:5px}.border-l-\[6px\]{border-left-style:var(--tw-border-style);border-left-width:6px}.border-dashed{--tw-border-style:dashed;border-style:dashed}.\!border-green-500{border-color:var(--color-green-500)!important}.border-amber-500\/20{border-color:#f99c0033}@supports (color:color-mix(in lab,red,red)){.border-amber-500\/20{border-color:color-mix(in oklab,var(--color-amber-500)20%,transparent)}}.border-amber-500\/30{border-color:#f99c004d}@supports (color:color-mix(in lab,red,red)){.border-amber-500\/30{border-color:color-mix(in oklab,var(--color-amber-500)30%,transparent)}}.border-bambu-dark-tertiary,.border-bambu-dark-tertiary\/20{border-color:var(--color-bambu-dark-tertiary)}@supports (color:color-mix(in lab,red,red)){.border-bambu-dark-tertiary\/20{border-color:color-mix(in oklab,var(--color-bambu-dark-tertiary)20%,transparent)}}.border-bambu-dark-tertiary\/30{border-color:var(--color-bambu-dark-tertiary)}@supports (color:color-mix(in lab,red,red)){.border-bambu-dark-tertiary\/30{border-color:color-mix(in oklab,var(--color-bambu-dark-tertiary)30%,transparent)}}.border-bambu-dark-tertiary\/40{border-color:var(--color-bambu-dark-tertiary)}@supports (color:color-mix(in lab,red,red)){.border-bambu-dark-tertiary\/40{border-color:color-mix(in oklab,var(--color-bambu-dark-tertiary)40%,transparent)}}.border-bambu-dark-tertiary\/50{border-color:var(--color-bambu-dark-tertiary)}@supports (color:color-mix(in lab,red,red)){.border-bambu-dark-tertiary\/50{border-color:color-mix(in oklab,var(--color-bambu-dark-tertiary)50%,transparent)}}.border-bambu-gray,.border-bambu-gray\/20{border-color:var(--color-bambu-gray)}@supports (color:color-mix(in lab,red,red)){.border-bambu-gray\/20{border-color:color-mix(in oklab,var(--color-bambu-gray)20%,transparent)}}.border-bambu-gray\/30{border-color:var(--color-bambu-gray)}@supports (color:color-mix(in lab,red,red)){.border-bambu-gray\/30{border-color:color-mix(in oklab,var(--color-bambu-gray)30%,transparent)}}.border-bambu-gray\/50{border-color:var(--color-bambu-gray)}@supports (color:color-mix(in lab,red,red)){.border-bambu-gray\/50{border-color:color-mix(in oklab,var(--color-bambu-gray)50%,transparent)}}.border-bambu-green,.border-bambu-green\/20{border-color:var(--color-bambu-green)}@supports (color:color-mix(in lab,red,red)){.border-bambu-green\/20{border-color:color-mix(in oklab,var(--color-bambu-green)20%,transparent)}}.border-bambu-green\/30{border-color:var(--color-bambu-green)}@supports (color:color-mix(in lab,red,red)){.border-bambu-green\/30{border-color:color-mix(in oklab,var(--color-bambu-green)30%,transparent)}}.border-bambu-green\/40{border-color:var(--color-bambu-green)}@supports (color:color-mix(in lab,red,red)){.border-bambu-green\/40{border-color:color-mix(in oklab,var(--color-bambu-green)40%,transparent)}}.border-bambu-green\/50{border-color:var(--color-bambu-green)}@supports (color:color-mix(in lab,red,red)){.border-bambu-green\/50{border-color:color-mix(in oklab,var(--color-bambu-green)50%,transparent)}}.border-blue-400\/20{border-color:#54a2ff33}@supports (color:color-mix(in lab,red,red)){.border-blue-400\/20{border-color:color-mix(in oklab,var(--color-blue-400)20%,transparent)}}.border-blue-500{border-color:var(--color-blue-500)}.border-blue-500\/20{border-color:#3080ff33}@supports (color:color-mix(in lab,red,red)){.border-blue-500\/20{border-color:color-mix(in oklab,var(--color-blue-500)20%,transparent)}}.border-blue-500\/30{border-color:#3080ff4d}@supports (color:color-mix(in lab,red,red)){.border-blue-500\/30{border-color:color-mix(in oklab,var(--color-blue-500)30%,transparent)}}.border-blue-500\/50{border-color:#3080ff80}@supports (color:color-mix(in lab,red,red)){.border-blue-500\/50{border-color:color-mix(in oklab,var(--color-blue-500)50%,transparent)}}.border-gray-200{border-color:var(--color-gray-200)}.border-gray-300{border-color:var(--color-gray-300)}.border-gray-400\/20{border-color:#99a1af33}@supports (color:color-mix(in lab,red,red)){.border-gray-400\/20{border-color:color-mix(in oklab,var(--color-gray-400)20%,transparent)}}.border-gray-500\/20{border-color:#6a728233}@supports (color:color-mix(in lab,red,red)){.border-gray-500\/20{border-color:color-mix(in oklab,var(--color-gray-500)20%,transparent)}}.border-gray-700{border-color:var(--color-gray-700)}.border-green-300{border-color:var(--color-green-300)}.border-green-500\/30{border-color:#00c7584d}@supports (color:color-mix(in lab,red,red)){.border-green-500\/30{border-color:color-mix(in oklab,var(--color-green-500)30%,transparent)}}.border-green-500\/50{border-color:#00c75880}@supports (color:color-mix(in lab,red,red)){.border-green-500\/50{border-color:color-mix(in oklab,var(--color-green-500)50%,transparent)}}.border-orange-400\/20{border-color:#ff8b1a33}@supports (color:color-mix(in lab,red,red)){.border-orange-400\/20{border-color:color-mix(in oklab,var(--color-orange-400)20%,transparent)}}.border-orange-400\/50{border-color:#ff8b1a80}@supports (color:color-mix(in lab,red,red)){.border-orange-400\/50{border-color:color-mix(in oklab,var(--color-orange-400)50%,transparent)}}.border-orange-500\/20{border-color:#fe6e0033}@supports (color:color-mix(in lab,red,red)){.border-orange-500\/20{border-color:color-mix(in oklab,var(--color-orange-500)20%,transparent)}}.border-orange-500\/30{border-color:#fe6e004d}@supports (color:color-mix(in lab,red,red)){.border-orange-500\/30{border-color:color-mix(in oklab,var(--color-orange-500)30%,transparent)}}.border-purple-400\/20{border-color:#c07eff33}@supports (color:color-mix(in lab,red,red)){.border-purple-400\/20{border-color:color-mix(in oklab,var(--color-purple-400)20%,transparent)}}.border-purple-500\/20{border-color:#ac4bff33}@supports (color:color-mix(in lab,red,red)){.border-purple-500\/20{border-color:color-mix(in oklab,var(--color-purple-500)20%,transparent)}}.border-purple-500\/30{border-color:#ac4bff4d}@supports (color:color-mix(in lab,red,red)){.border-purple-500\/30{border-color:color-mix(in oklab,var(--color-purple-500)30%,transparent)}}.border-red-300{border-color:var(--color-red-300)}.border-red-500{border-color:var(--color-red-500)}.border-red-500\/20{border-color:#fb2c3633}@supports (color:color-mix(in lab,red,red)){.border-red-500\/20{border-color:color-mix(in oklab,var(--color-red-500)20%,transparent)}}.border-red-500\/30{border-color:#fb2c364d}@supports (color:color-mix(in lab,red,red)){.border-red-500\/30{border-color:color-mix(in oklab,var(--color-red-500)30%,transparent)}}.border-red-500\/50{border-color:#fb2c3680}@supports (color:color-mix(in lab,red,red)){.border-red-500\/50{border-color:color-mix(in oklab,var(--color-red-500)50%,transparent)}}.border-red-800\/70{border-color:#9f0712b3}@supports (color:color-mix(in lab,red,red)){.border-red-800\/70{border-color:color-mix(in oklab,var(--color-red-800)70%,transparent)}}.border-slate-500{border-color:var(--color-slate-500)}.border-status-error\/20{border-color:var(--color-status-error)}@supports (color:color-mix(in lab,red,red)){.border-status-error\/20{border-color:color-mix(in oklab,var(--color-status-error)20%,transparent)}}.border-status-ok,.border-status-ok\/20{border-color:var(--color-status-ok)}@supports (color:color-mix(in lab,red,red)){.border-status-ok\/20{border-color:color-mix(in oklab,var(--color-status-ok)20%,transparent)}}.border-status-warning\/20{border-color:var(--color-status-warning)}@supports (color:color-mix(in lab,red,red)){.border-status-warning\/20{border-color:color-mix(in oklab,var(--color-status-warning)20%,transparent)}}.border-transparent{border-color:#0000}.border-white\/10{border-color:#ffffff1a}@supports (color:color-mix(in lab,red,red)){.border-white\/10{border-color:color-mix(in oklab,var(--color-white)10%,transparent)}}.border-white\/20{border-color:#fff3}@supports (color:color-mix(in lab,red,red)){.border-white\/20{border-color:color-mix(in oklab,var(--color-white)20%,transparent)}}.border-white\/30{border-color:#ffffff4d}@supports (color:color-mix(in lab,red,red)){.border-white\/30{border-color:color-mix(in oklab,var(--color-white)30%,transparent)}}.border-yellow-400\/20{border-color:#fac80033}@supports (color:color-mix(in lab,red,red)){.border-yellow-400\/20{border-color:color-mix(in oklab,var(--color-yellow-400)20%,transparent)}}.border-yellow-400\/30{border-color:#fac8004d}@supports (color:color-mix(in lab,red,red)){.border-yellow-400\/30{border-color:color-mix(in oklab,var(--color-yellow-400)30%,transparent)}}.border-yellow-400\/50{border-color:#fac80080}@supports (color:color-mix(in lab,red,red)){.border-yellow-400\/50{border-color:color-mix(in oklab,var(--color-yellow-400)50%,transparent)}}.border-yellow-500{border-color:var(--color-yellow-500)}.border-yellow-500\/20{border-color:#edb20033}@supports (color:color-mix(in lab,red,red)){.border-yellow-500\/20{border-color:color-mix(in oklab,var(--color-yellow-500)20%,transparent)}}.border-yellow-500\/30{border-color:#edb2004d}@supports (color:color-mix(in lab,red,red)){.border-yellow-500\/30{border-color:color-mix(in oklab,var(--color-yellow-500)30%,transparent)}}.border-yellow-500\/50{border-color:#edb20080}@supports (color:color-mix(in lab,red,red)){.border-yellow-500\/50{border-color:color-mix(in oklab,var(--color-yellow-500)50%,transparent)}}.border-t-bambu-dark-tertiary{border-top-color:var(--color-bambu-dark-tertiary)}.border-t-transparent{border-top-color:#0000}.border-r-transparent{border-right-color:#0000}.border-b-bambu-dark-tertiary{border-bottom-color:var(--color-bambu-dark-tertiary)}.border-l-transparent{border-left-color:#0000}.border-l-yellow-500{border-left-color:var(--color-yellow-500)}.bg-amber-50{background-color:var(--color-amber-50)}.bg-amber-500{background-color:var(--color-amber-500)}.bg-amber-500\/5{background-color:#f99c000d}@supports (color:color-mix(in lab,red,red)){.bg-amber-500\/5{background-color:color-mix(in oklab,var(--color-amber-500)5%,transparent)}}.bg-amber-500\/10{background-color:#f99c001a}@supports (color:color-mix(in lab,red,red)){.bg-amber-500\/10{background-color:color-mix(in oklab,var(--color-amber-500)10%,transparent)}}.bg-amber-500\/20{background-color:#f99c0033}@supports (color:color-mix(in lab,red,red)){.bg-amber-500\/20{background-color:color-mix(in oklab,var(--color-amber-500)20%,transparent)}}.bg-amber-600\/20{background-color:#dd740033}@supports (color:color-mix(in lab,red,red)){.bg-amber-600\/20{background-color:color-mix(in oklab,var(--color-amber-600)20%,transparent)}}.bg-bambu-dark{background-color:var(--color-bambu-dark)}.bg-bambu-dark-secondary,.bg-bambu-dark-secondary\/30{background-color:var(--color-bambu-dark-secondary)}@supports (color:color-mix(in lab,red,red)){.bg-bambu-dark-secondary\/30{background-color:color-mix(in oklab,var(--color-bambu-dark-secondary)30%,transparent)}}.bg-bambu-dark-secondary\/50{background-color:var(--color-bambu-dark-secondary)}@supports (color:color-mix(in lab,red,red)){.bg-bambu-dark-secondary\/50{background-color:color-mix(in oklab,var(--color-bambu-dark-secondary)50%,transparent)}}.bg-bambu-dark-secondary\/60{background-color:var(--color-bambu-dark-secondary)}@supports (color:color-mix(in lab,red,red)){.bg-bambu-dark-secondary\/60{background-color:color-mix(in oklab,var(--color-bambu-dark-secondary)60%,transparent)}}.bg-bambu-dark-secondary\/90{background-color:var(--color-bambu-dark-secondary)}@supports (color:color-mix(in lab,red,red)){.bg-bambu-dark-secondary\/90{background-color:color-mix(in oklab,var(--color-bambu-dark-secondary)90%,transparent)}}.bg-bambu-dark-secondary\/95{background-color:var(--color-bambu-dark-secondary)}@supports (color:color-mix(in lab,red,red)){.bg-bambu-dark-secondary\/95{background-color:color-mix(in oklab,var(--color-bambu-dark-secondary)95%,transparent)}}.bg-bambu-dark-tertiary,.bg-bambu-dark-tertiary\/20{background-color:var(--color-bambu-dark-tertiary)}@supports (color:color-mix(in lab,red,red)){.bg-bambu-dark-tertiary\/20{background-color:color-mix(in oklab,var(--color-bambu-dark-tertiary)20%,transparent)}}.bg-bambu-dark-tertiary\/30{background-color:var(--color-bambu-dark-tertiary)}@supports (color:color-mix(in lab,red,red)){.bg-bambu-dark-tertiary\/30{background-color:color-mix(in oklab,var(--color-bambu-dark-tertiary)30%,transparent)}}.bg-bambu-dark-tertiary\/40{background-color:var(--color-bambu-dark-tertiary)}@supports (color:color-mix(in lab,red,red)){.bg-bambu-dark-tertiary\/40{background-color:color-mix(in oklab,var(--color-bambu-dark-tertiary)40%,transparent)}}.bg-bambu-dark-tertiary\/50{background-color:var(--color-bambu-dark-tertiary)}@supports (color:color-mix(in lab,red,red)){.bg-bambu-dark-tertiary\/50{background-color:color-mix(in oklab,var(--color-bambu-dark-tertiary)50%,transparent)}}.bg-bambu-dark-tertiary\/70{background-color:var(--color-bambu-dark-tertiary)}@supports (color:color-mix(in lab,red,red)){.bg-bambu-dark-tertiary\/70{background-color:color-mix(in oklab,var(--color-bambu-dark-tertiary)70%,transparent)}}.bg-bambu-dark-tertiary\/80{background-color:var(--color-bambu-dark-tertiary)}@supports (color:color-mix(in lab,red,red)){.bg-bambu-dark-tertiary\/80{background-color:color-mix(in oklab,var(--color-bambu-dark-tertiary)80%,transparent)}}.bg-bambu-dark\/20{background-color:var(--color-bambu-dark)}@supports (color:color-mix(in lab,red,red)){.bg-bambu-dark\/20{background-color:color-mix(in oklab,var(--color-bambu-dark)20%,transparent)}}.bg-bambu-dark\/30{background-color:var(--color-bambu-dark)}@supports (color:color-mix(in lab,red,red)){.bg-bambu-dark\/30{background-color:color-mix(in oklab,var(--color-bambu-dark)30%,transparent)}}.bg-bambu-dark\/50{background-color:var(--color-bambu-dark)}@supports (color:color-mix(in lab,red,red)){.bg-bambu-dark\/50{background-color:color-mix(in oklab,var(--color-bambu-dark)50%,transparent)}}.bg-bambu-dark\/80{background-color:var(--color-bambu-dark)}@supports (color:color-mix(in lab,red,red)){.bg-bambu-dark\/80{background-color:color-mix(in oklab,var(--color-bambu-dark)80%,transparent)}}.bg-bambu-dark\/90{background-color:var(--color-bambu-dark)}@supports (color:color-mix(in lab,red,red)){.bg-bambu-dark\/90{background-color:color-mix(in oklab,var(--color-bambu-dark)90%,transparent)}}.bg-bambu-gray\/10{background-color:var(--color-bambu-gray)}@supports (color:color-mix(in lab,red,red)){.bg-bambu-gray\/10{background-color:color-mix(in oklab,var(--color-bambu-gray)10%,transparent)}}.bg-bambu-gray\/20{background-color:var(--color-bambu-gray)}@supports (color:color-mix(in lab,red,red)){.bg-bambu-gray\/20{background-color:color-mix(in oklab,var(--color-bambu-gray)20%,transparent)}}.bg-bambu-gray\/30{background-color:var(--color-bambu-gray)}@supports (color:color-mix(in lab,red,red)){.bg-bambu-gray\/30{background-color:color-mix(in oklab,var(--color-bambu-gray)30%,transparent)}}.bg-bambu-gray\/50{background-color:var(--color-bambu-gray)}@supports (color:color-mix(in lab,red,red)){.bg-bambu-gray\/50{background-color:color-mix(in oklab,var(--color-bambu-gray)50%,transparent)}}.bg-bambu-gray\/90{background-color:var(--color-bambu-gray)}@supports (color:color-mix(in lab,red,red)){.bg-bambu-gray\/90{background-color:color-mix(in oklab,var(--color-bambu-gray)90%,transparent)}}.bg-bambu-green,.bg-bambu-green\/5{background-color:var(--color-bambu-green)}@supports (color:color-mix(in lab,red,red)){.bg-bambu-green\/5{background-color:color-mix(in oklab,var(--color-bambu-green)5%,transparent)}}.bg-bambu-green\/10{background-color:var(--color-bambu-green)}@supports (color:color-mix(in lab,red,red)){.bg-bambu-green\/10{background-color:color-mix(in oklab,var(--color-bambu-green)10%,transparent)}}.bg-bambu-green\/20{background-color:var(--color-bambu-green)}@supports (color:color-mix(in lab,red,red)){.bg-bambu-green\/20{background-color:color-mix(in oklab,var(--color-bambu-green)20%,transparent)}}.bg-bambu-green\/30{background-color:var(--color-bambu-green)}@supports (color:color-mix(in lab,red,red)){.bg-bambu-green\/30{background-color:color-mix(in oklab,var(--color-bambu-green)30%,transparent)}}.bg-bambu-green\/50{background-color:var(--color-bambu-green)}@supports (color:color-mix(in lab,red,red)){.bg-bambu-green\/50{background-color:color-mix(in oklab,var(--color-bambu-green)50%,transparent)}}.bg-bambu-green\/75{background-color:var(--color-bambu-green)}@supports (color:color-mix(in lab,red,red)){.bg-bambu-green\/75{background-color:color-mix(in oklab,var(--color-bambu-green)75%,transparent)}}.bg-bambu-green\/90{background-color:var(--color-bambu-green)}@supports (color:color-mix(in lab,red,red)){.bg-bambu-green\/90{background-color:color-mix(in oklab,var(--color-bambu-green)90%,transparent)}}.bg-black{background-color:var(--color-black)}.bg-black\/30{background-color:#0000004d}@supports (color:color-mix(in lab,red,red)){.bg-black\/30{background-color:color-mix(in oklab,var(--color-black)30%,transparent)}}.bg-black\/40{background-color:#0006}@supports (color:color-mix(in lab,red,red)){.bg-black\/40{background-color:color-mix(in oklab,var(--color-black)40%,transparent)}}.bg-black\/50{background-color:#00000080}@supports (color:color-mix(in lab,red,red)){.bg-black\/50{background-color:color-mix(in oklab,var(--color-black)50%,transparent)}}.bg-black\/60{background-color:#0009}@supports (color:color-mix(in lab,red,red)){.bg-black\/60{background-color:color-mix(in oklab,var(--color-black)60%,transparent)}}.bg-black\/70{background-color:#000000b3}@supports (color:color-mix(in lab,red,red)){.bg-black\/70{background-color:color-mix(in oklab,var(--color-black)70%,transparent)}}.bg-black\/80{background-color:#000c}@supports (color:color-mix(in lab,red,red)){.bg-black\/80{background-color:color-mix(in oklab,var(--color-black)80%,transparent)}}.bg-black\/90{background-color:#000000e6}@supports (color:color-mix(in lab,red,red)){.bg-black\/90{background-color:color-mix(in oklab,var(--color-black)90%,transparent)}}.bg-blue-50{background-color:var(--color-blue-50)}.bg-blue-100{background-color:var(--color-blue-100)}.bg-blue-400{background-color:var(--color-blue-400)}.bg-blue-400\/10{background-color:#54a2ff1a}@supports (color:color-mix(in lab,red,red)){.bg-blue-400\/10{background-color:color-mix(in oklab,var(--color-blue-400)10%,transparent)}}.bg-blue-500{background-color:var(--color-blue-500)}.bg-blue-500\/5{background-color:#3080ff0d}@supports (color:color-mix(in lab,red,red)){.bg-blue-500\/5{background-color:color-mix(in oklab,var(--color-blue-500)5%,transparent)}}.bg-blue-500\/10{background-color:#3080ff1a}@supports (color:color-mix(in lab,red,red)){.bg-blue-500\/10{background-color:color-mix(in oklab,var(--color-blue-500)10%,transparent)}}.bg-blue-500\/20{background-color:#3080ff33}@supports (color:color-mix(in lab,red,red)){.bg-blue-500\/20{background-color:color-mix(in oklab,var(--color-blue-500)20%,transparent)}}.bg-blue-500\/30{background-color:#3080ff4d}@supports (color:color-mix(in lab,red,red)){.bg-blue-500\/30{background-color:color-mix(in oklab,var(--color-blue-500)30%,transparent)}}.bg-blue-500\/90{background-color:#3080ffe6}@supports (color:color-mix(in lab,red,red)){.bg-blue-500\/90{background-color:color-mix(in oklab,var(--color-blue-500)90%,transparent)}}.bg-blue-600{background-color:var(--color-blue-600)}.bg-blue-600\/20{background-color:#155dfc33}@supports (color:color-mix(in lab,red,red)){.bg-blue-600\/20{background-color:color-mix(in oklab,var(--color-blue-600)20%,transparent)}}.bg-cyan-500{background-color:var(--color-cyan-500)}.bg-cyan-500\/10{background-color:#00b7d71a}@supports (color:color-mix(in lab,red,red)){.bg-cyan-500\/10{background-color:color-mix(in oklab,var(--color-cyan-500)10%,transparent)}}.bg-cyan-500\/20{background-color:#00b7d733}@supports (color:color-mix(in lab,red,red)){.bg-cyan-500\/20{background-color:color-mix(in oklab,var(--color-cyan-500)20%,transparent)}}.bg-cyan-600\/20{background-color:#0092b533}@supports (color:color-mix(in lab,red,red)){.bg-cyan-600\/20{background-color:color-mix(in oklab,var(--color-cyan-600)20%,transparent)}}.bg-emerald-500\/20{background-color:#00bb7f33}@supports (color:color-mix(in lab,red,red)){.bg-emerald-500\/20{background-color:color-mix(in oklab,var(--color-emerald-500)20%,transparent)}}.bg-emerald-700{background-color:var(--color-emerald-700)}.bg-fuchsia-500{background-color:var(--color-fuchsia-500)}.bg-gray-50{background-color:var(--color-gray-50)}.bg-gray-100{background-color:var(--color-gray-100)}.bg-gray-400{background-color:var(--color-gray-400)}.bg-gray-400\/10{background-color:#99a1af1a}@supports (color:color-mix(in lab,red,red)){.bg-gray-400\/10{background-color:color-mix(in oklab,var(--color-gray-400)10%,transparent)}}.bg-gray-500{background-color:var(--color-gray-500)}.bg-gray-500\/20{background-color:#6a728233}@supports (color:color-mix(in lab,red,red)){.bg-gray-500\/20{background-color:color-mix(in oklab,var(--color-gray-500)20%,transparent)}}.bg-gray-800{background-color:var(--color-gray-800)}.bg-gray-900{background-color:var(--color-gray-900)}.bg-green-100{background-color:var(--color-green-100)}.bg-green-400{background-color:var(--color-green-400)}.bg-green-500{background-color:var(--color-green-500)}.bg-green-500\/10{background-color:#00c7581a}@supports (color:color-mix(in lab,red,red)){.bg-green-500\/10{background-color:color-mix(in oklab,var(--color-green-500)10%,transparent)}}.bg-green-500\/20{background-color:#00c75833}@supports (color:color-mix(in lab,red,red)){.bg-green-500\/20{background-color:color-mix(in oklab,var(--color-green-500)20%,transparent)}}.bg-green-900\/50{background-color:#0d542b80}@supports (color:color-mix(in lab,red,red)){.bg-green-900\/50{background-color:color-mix(in oklab,var(--color-green-900)50%,transparent)}}.bg-indigo-500\/20{background-color:#625fff33}@supports (color:color-mix(in lab,red,red)){.bg-indigo-500\/20{background-color:color-mix(in oklab,var(--color-indigo-500)20%,transparent)}}.bg-lime-500{background-color:var(--color-lime-500)}.bg-orange-400\/10{background-color:#ff8b1a1a}@supports (color:color-mix(in lab,red,red)){.bg-orange-400\/10{background-color:color-mix(in oklab,var(--color-orange-400)10%,transparent)}}.bg-orange-500{background-color:var(--color-orange-500)}.bg-orange-500\/10{background-color:#fe6e001a}@supports (color:color-mix(in lab,red,red)){.bg-orange-500\/10{background-color:color-mix(in oklab,var(--color-orange-500)10%,transparent)}}.bg-orange-500\/20{background-color:#fe6e0033}@supports (color:color-mix(in lab,red,red)){.bg-orange-500\/20{background-color:color-mix(in oklab,var(--color-orange-500)20%,transparent)}}.bg-orange-600{background-color:var(--color-orange-600)}.bg-orange-600\/20{background-color:#f0510033}@supports (color:color-mix(in lab,red,red)){.bg-orange-600\/20{background-color:color-mix(in oklab,var(--color-orange-600)20%,transparent)}}.bg-purple-400\/10{background-color:#c07eff1a}@supports (color:color-mix(in lab,red,red)){.bg-purple-400\/10{background-color:color-mix(in oklab,var(--color-purple-400)10%,transparent)}}.bg-purple-500{background-color:var(--color-purple-500)}.bg-purple-500\/10{background-color:#ac4bff1a}@supports (color:color-mix(in lab,red,red)){.bg-purple-500\/10{background-color:color-mix(in oklab,var(--color-purple-500)10%,transparent)}}.bg-purple-500\/20{background-color:#ac4bff33}@supports (color:color-mix(in lab,red,red)){.bg-purple-500\/20{background-color:color-mix(in oklab,var(--color-purple-500)20%,transparent)}}.bg-purple-500\/80{background-color:#ac4bffcc}@supports (color:color-mix(in lab,red,red)){.bg-purple-500\/80{background-color:color-mix(in oklab,var(--color-purple-500)80%,transparent)}}.bg-purple-500\/90{background-color:#ac4bffe6}@supports (color:color-mix(in lab,red,red)){.bg-purple-500\/90{background-color:color-mix(in oklab,var(--color-purple-500)90%,transparent)}}.bg-purple-700{background-color:var(--color-purple-700)}.bg-red-50{background-color:var(--color-red-50)}.bg-red-100{background-color:var(--color-red-100)}.bg-red-400{background-color:var(--color-red-400)}.bg-red-500{background-color:var(--color-red-500)}.bg-red-500\/5{background-color:#fb2c360d}@supports (color:color-mix(in lab,red,red)){.bg-red-500\/5{background-color:color-mix(in oklab,var(--color-red-500)5%,transparent)}}.bg-red-500\/10{background-color:#fb2c361a}@supports (color:color-mix(in lab,red,red)){.bg-red-500\/10{background-color:color-mix(in oklab,var(--color-red-500)10%,transparent)}}.bg-red-500\/15{background-color:#fb2c3626}@supports (color:color-mix(in lab,red,red)){.bg-red-500\/15{background-color:color-mix(in oklab,var(--color-red-500)15%,transparent)}}.bg-red-500\/20{background-color:#fb2c3633}@supports (color:color-mix(in lab,red,red)){.bg-red-500\/20{background-color:color-mix(in oklab,var(--color-red-500)20%,transparent)}}.bg-red-500\/30{background-color:#fb2c364d}@supports (color:color-mix(in lab,red,red)){.bg-red-500\/30{background-color:color-mix(in oklab,var(--color-red-500)30%,transparent)}}.bg-red-500\/40{background-color:#fb2c3666}@supports (color:color-mix(in lab,red,red)){.bg-red-500\/40{background-color:color-mix(in oklab,var(--color-red-500)40%,transparent)}}.bg-red-500\/80{background-color:#fb2c36cc}@supports (color:color-mix(in lab,red,red)){.bg-red-500\/80{background-color:color-mix(in oklab,var(--color-red-500)80%,transparent)}}.bg-red-600{background-color:var(--color-red-600)}.bg-red-950\/70{background-color:#460809b3}@supports (color:color-mix(in lab,red,red)){.bg-red-950\/70{background-color:color-mix(in oklab,var(--color-red-950)70%,transparent)}}.bg-rose-500\/20{background-color:#ff235733}@supports (color:color-mix(in lab,red,red)){.bg-rose-500\/20{background-color:color-mix(in oklab,var(--color-rose-500)20%,transparent)}}.bg-rose-600\/20{background-color:#e7004433}@supports (color:color-mix(in lab,red,red)){.bg-rose-600\/20{background-color:color-mix(in oklab,var(--color-rose-600)20%,transparent)}}.bg-sky-500{background-color:var(--color-sky-500)}.bg-sky-500\/20{background-color:#00a5ef33}@supports (color:color-mix(in lab,red,red)){.bg-sky-500\/20{background-color:color-mix(in oklab,var(--color-sky-500)20%,transparent)}}.bg-status-error,.bg-status-error\/10{background-color:var(--color-status-error)}@supports (color:color-mix(in lab,red,red)){.bg-status-error\/10{background-color:color-mix(in oklab,var(--color-status-error)10%,transparent)}}.bg-status-error\/20{background-color:var(--color-status-error)}@supports (color:color-mix(in lab,red,red)){.bg-status-error\/20{background-color:color-mix(in oklab,var(--color-status-error)20%,transparent)}}.bg-status-error\/80{background-color:var(--color-status-error)}@supports (color:color-mix(in lab,red,red)){.bg-status-error\/80{background-color:color-mix(in oklab,var(--color-status-error)80%,transparent)}}.bg-status-ok,.bg-status-ok\/10{background-color:var(--color-status-ok)}@supports (color:color-mix(in lab,red,red)){.bg-status-ok\/10{background-color:color-mix(in oklab,var(--color-status-ok)10%,transparent)}}.bg-status-ok\/20{background-color:var(--color-status-ok)}@supports (color:color-mix(in lab,red,red)){.bg-status-ok\/20{background-color:color-mix(in oklab,var(--color-status-ok)20%,transparent)}}.bg-status-warning\/10{background-color:var(--color-status-warning)}@supports (color:color-mix(in lab,red,red)){.bg-status-warning\/10{background-color:color-mix(in oklab,var(--color-status-warning)10%,transparent)}}.bg-status-warning\/20{background-color:var(--color-status-warning)}@supports (color:color-mix(in lab,red,red)){.bg-status-warning\/20{background-color:color-mix(in oklab,var(--color-status-warning)20%,transparent)}}.bg-teal-500{background-color:var(--color-teal-500)}.bg-teal-500\/20{background-color:#00baa733}@supports (color:color-mix(in lab,red,red)){.bg-teal-500\/20{background-color:color-mix(in oklab,var(--color-teal-500)20%,transparent)}}.bg-transparent{background-color:#0000}.bg-violet-500{background-color:var(--color-violet-500)}.bg-white{background-color:var(--color-white)}.bg-white\/20{background-color:#fff3}@supports (color:color-mix(in lab,red,red)){.bg-white\/20{background-color:color-mix(in oklab,var(--color-white)20%,transparent)}}.bg-white\/50{background-color:#ffffff80}@supports (color:color-mix(in lab,red,red)){.bg-white\/50{background-color:color-mix(in oklab,var(--color-white)50%,transparent)}}.bg-white\/70{background-color:#ffffffb3}@supports (color:color-mix(in lab,red,red)){.bg-white\/70{background-color:color-mix(in oklab,var(--color-white)70%,transparent)}}.bg-white\/90{background-color:#ffffffe6}@supports (color:color-mix(in lab,red,red)){.bg-white\/90{background-color:color-mix(in oklab,var(--color-white)90%,transparent)}}.bg-yellow-400{background-color:var(--color-yellow-400)}.bg-yellow-400\/10{background-color:#fac8001a}@supports (color:color-mix(in lab,red,red)){.bg-yellow-400\/10{background-color:color-mix(in oklab,var(--color-yellow-400)10%,transparent)}}.bg-yellow-400\/20{background-color:#fac80033}@supports (color:color-mix(in lab,red,red)){.bg-yellow-400\/20{background-color:color-mix(in oklab,var(--color-yellow-400)20%,transparent)}}.bg-yellow-500{background-color:var(--color-yellow-500)}.bg-yellow-500\/5{background-color:#edb2000d}@supports (color:color-mix(in lab,red,red)){.bg-yellow-500\/5{background-color:color-mix(in oklab,var(--color-yellow-500)5%,transparent)}}.bg-yellow-500\/10{background-color:#edb2001a}@supports (color:color-mix(in lab,red,red)){.bg-yellow-500\/10{background-color:color-mix(in oklab,var(--color-yellow-500)10%,transparent)}}.bg-yellow-500\/20{background-color:#edb20033}@supports (color:color-mix(in lab,red,red)){.bg-yellow-500\/20{background-color:color-mix(in oklab,var(--color-yellow-500)20%,transparent)}}.bg-gradient-to-b{--tw-gradient-position:to bottom in oklab;background-image:linear-gradient(var(--tw-gradient-stops))}.bg-gradient-to-br{--tw-gradient-position:to bottom right in oklab;background-image:linear-gradient(var(--tw-gradient-stops))}.bg-gradient-to-r{--tw-gradient-position:to right in oklab;background-image:linear-gradient(var(--tw-gradient-stops))}.bg-gradient-to-t{--tw-gradient-position:to top in oklab;background-image:linear-gradient(var(--tw-gradient-stops))}.from-bambu-dark-secondary{--tw-gradient-from:var(--color-bambu-dark-secondary);--tw-gradient-stops:var(--tw-gradient-via-stops,var(--tw-gradient-position),var(--tw-gradient-from)var(--tw-gradient-from-position),var(--tw-gradient-to)var(--tw-gradient-to-position))}.from-bambu-green\/10{--tw-gradient-from:var(--color-bambu-green)}@supports (color:color-mix(in lab,red,red)){.from-bambu-green\/10{--tw-gradient-from:color-mix(in oklab,var(--color-bambu-green)10%,transparent)}}.from-bambu-green\/10{--tw-gradient-stops:var(--tw-gradient-via-stops,var(--tw-gradient-position),var(--tw-gradient-from)var(--tw-gradient-from-position),var(--tw-gradient-to)var(--tw-gradient-to-position))}.from-black\/80{--tw-gradient-from:#000c}@supports (color:color-mix(in lab,red,red)){.from-black\/80{--tw-gradient-from:color-mix(in oklab,var(--color-black)80%,transparent)}}.from-black\/80{--tw-gradient-stops:var(--tw-gradient-via-stops,var(--tw-gradient-position),var(--tw-gradient-from)var(--tw-gradient-from-position),var(--tw-gradient-to)var(--tw-gradient-to-position))}.from-blue-500\/5{--tw-gradient-from:#3080ff0d}@supports (color:color-mix(in lab,red,red)){.from-blue-500\/5{--tw-gradient-from:color-mix(in oklab,var(--color-blue-500)5%,transparent)}}.from-blue-500\/5{--tw-gradient-stops:var(--tw-gradient-via-stops,var(--tw-gradient-position),var(--tw-gradient-from)var(--tw-gradient-from-position),var(--tw-gradient-to)var(--tw-gradient-to-position))}.from-blue-500\/10{--tw-gradient-from:#3080ff1a}@supports (color:color-mix(in lab,red,red)){.from-blue-500\/10{--tw-gradient-from:color-mix(in oklab,var(--color-blue-500)10%,transparent)}}.from-blue-500\/10{--tw-gradient-stops:var(--tw-gradient-via-stops,var(--tw-gradient-position),var(--tw-gradient-from)var(--tw-gradient-from-position),var(--tw-gradient-to)var(--tw-gradient-to-position))}.from-gray-500\/10{--tw-gradient-from:#6a72821a}@supports (color:color-mix(in lab,red,red)){.from-gray-500\/10{--tw-gradient-from:color-mix(in oklab,var(--color-gray-500)10%,transparent)}}.from-gray-500\/10{--tw-gradient-stops:var(--tw-gradient-via-stops,var(--tw-gradient-position),var(--tw-gradient-from)var(--tw-gradient-from-position),var(--tw-gradient-to)var(--tw-gradient-to-position))}.from-purple-500\/10{--tw-gradient-from:#ac4bff1a}@supports (color:color-mix(in lab,red,red)){.from-purple-500\/10{--tw-gradient-from:color-mix(in oklab,var(--color-purple-500)10%,transparent)}}.from-purple-500\/10{--tw-gradient-stops:var(--tw-gradient-via-stops,var(--tw-gradient-position),var(--tw-gradient-from)var(--tw-gradient-from-position),var(--tw-gradient-to)var(--tw-gradient-to-position))}.from-white\/10{--tw-gradient-from:#ffffff1a}@supports (color:color-mix(in lab,red,red)){.from-white\/10{--tw-gradient-from:color-mix(in oklab,var(--color-white)10%,transparent)}}.from-white\/10{--tw-gradient-stops:var(--tw-gradient-via-stops,var(--tw-gradient-position),var(--tw-gradient-from)var(--tw-gradient-from-position),var(--tw-gradient-to)var(--tw-gradient-to-position))}.from-yellow-500\/10{--tw-gradient-from:#edb2001a}@supports (color:color-mix(in lab,red,red)){.from-yellow-500\/10{--tw-gradient-from:color-mix(in oklab,var(--color-yellow-500)10%,transparent)}}.from-yellow-500\/10{--tw-gradient-stops:var(--tw-gradient-via-stops,var(--tw-gradient-position),var(--tw-gradient-from)var(--tw-gradient-from-position),var(--tw-gradient-to)var(--tw-gradient-to-position))}.via-black\/60{--tw-gradient-via:#0009}@supports (color:color-mix(in lab,red,red)){.via-black\/60{--tw-gradient-via:color-mix(in oklab,var(--color-black)60%,transparent)}}.via-black\/60{--tw-gradient-via-stops:var(--tw-gradient-position),var(--tw-gradient-from)var(--tw-gradient-from-position),var(--tw-gradient-via)var(--tw-gradient-via-position),var(--tw-gradient-to)var(--tw-gradient-to-position);--tw-gradient-stops:var(--tw-gradient-via-stops)}.to-bambu-dark-secondary{--tw-gradient-to:var(--color-bambu-dark-secondary);--tw-gradient-stops:var(--tw-gradient-via-stops,var(--tw-gradient-position),var(--tw-gradient-from)var(--tw-gradient-from-position),var(--tw-gradient-to)var(--tw-gradient-to-position))}.to-bambu-dark-tertiary{--tw-gradient-to:var(--color-bambu-dark-tertiary);--tw-gradient-stops:var(--tw-gradient-via-stops,var(--tw-gradient-position),var(--tw-gradient-from)var(--tw-gradient-from-position),var(--tw-gradient-to)var(--tw-gradient-to-position))}.to-transparent{--tw-gradient-to:transparent;--tw-gradient-stops:var(--tw-gradient-via-stops,var(--tw-gradient-position),var(--tw-gradient-from)var(--tw-gradient-from-position),var(--tw-gradient-to)var(--tw-gradient-to-position))}.bg-cover{background-size:cover}.bg-center{background-position:50%}.fill-yellow-400{fill:var(--color-yellow-400)}.object-contain{object-fit:contain}.object-cover{object-fit:cover}.object-left{object-position:left}.p-0{padding:calc(var(--spacing)*0)}.p-0\.5{padding:calc(var(--spacing)*.5)}.p-1{padding:calc(var(--spacing)*1)}.p-1\.5{padding:calc(var(--spacing)*1.5)}.p-2{padding:calc(var(--spacing)*2)}.p-2\.5{padding:calc(var(--spacing)*2.5)}.p-3{padding:calc(var(--spacing)*3)}.p-4{padding:calc(var(--spacing)*4)}.p-5{padding:calc(var(--spacing)*5)}.p-6{padding:calc(var(--spacing)*6)}.p-8{padding:calc(var(--spacing)*8)}.p-12{padding:calc(var(--spacing)*12)}.\!px-1\.5{padding-inline:calc(var(--spacing)*1.5)!important}.\!px-3{padding-inline:calc(var(--spacing)*3)!important}.px-1{padding-inline:calc(var(--spacing)*1)}.px-1\.5{padding-inline:calc(var(--spacing)*1.5)}.px-2{padding-inline:calc(var(--spacing)*2)}.px-2\.5{padding-inline:calc(var(--spacing)*2.5)}.px-3{padding-inline:calc(var(--spacing)*3)}.px-4{padding-inline:calc(var(--spacing)*4)}.px-6{padding-inline:calc(var(--spacing)*6)}.py-0\.5{padding-block:calc(var(--spacing)*.5)}.py-1{padding-block:calc(var(--spacing)*1)}.py-1\.5{padding-block:calc(var(--spacing)*1.5)}.py-2{padding-block:calc(var(--spacing)*2)}.py-2\.5{padding-block:calc(var(--spacing)*2.5)}.py-3{padding-block:calc(var(--spacing)*3)}.py-4{padding-block:calc(var(--spacing)*4)}.py-6{padding-block:calc(var(--spacing)*6)}.py-8{padding-block:calc(var(--spacing)*8)}.py-12{padding-block:calc(var(--spacing)*12)}.py-16{padding-block:calc(var(--spacing)*16)}.py-20{padding-block:calc(var(--spacing)*20)}.py-24{padding-block:calc(var(--spacing)*24)}.pt-0{padding-top:calc(var(--spacing)*0)}.pt-1{padding-top:calc(var(--spacing)*1)}.pt-2{padding-top:calc(var(--spacing)*2)}.pt-3{padding-top:calc(var(--spacing)*3)}.pt-4{padding-top:calc(var(--spacing)*4)}.pr-1{padding-right:calc(var(--spacing)*1)}.pr-2{padding-right:calc(var(--spacing)*2)}.pr-3{padding-right:calc(var(--spacing)*3)}.pr-4{padding-right:calc(var(--spacing)*4)}.pr-6{padding-right:calc(var(--spacing)*6)}.pr-7{padding-right:calc(var(--spacing)*7)}.pr-8{padding-right:calc(var(--spacing)*8)}.pr-10{padding-right:calc(var(--spacing)*10)}.pb-1{padding-bottom:calc(var(--spacing)*1)}.pb-2{padding-bottom:calc(var(--spacing)*2)}.pb-4{padding-bottom:calc(var(--spacing)*4)}.pl-2{padding-left:calc(var(--spacing)*2)}.pl-4{padding-left:calc(var(--spacing)*4)}.pl-6{padding-left:calc(var(--spacing)*6)}.pl-7{padding-left:calc(var(--spacing)*7)}.pl-8{padding-left:calc(var(--spacing)*8)}.pl-9{padding-left:calc(var(--spacing)*9)}.pl-10{padding-left:calc(var(--spacing)*10)}.text-center{text-align:center}.text-left{text-align:left}.text-right{text-align:right}.font-mono{font-family:var(--font-mono)}.font-sans{font-family:var(--font-sans)}.text-2xl{font-size:var(--text-2xl);line-height:var(--tw-leading,var(--text-2xl--line-height))}.text-3xl{font-size:var(--text-3xl);line-height:var(--tw-leading,var(--text-3xl--line-height))}.text-base{font-size:var(--text-base);line-height:var(--tw-leading,var(--text-base--line-height))}.text-lg{font-size:var(--text-lg);line-height:var(--tw-leading,var(--text-lg--line-height))}.text-sm{font-size:var(--text-sm);line-height:var(--tw-leading,var(--text-sm--line-height))}.text-xl{font-size:var(--text-xl);line-height:var(--tw-leading,var(--text-xl--line-height))}.text-xs{font-size:var(--text-xs);line-height:var(--tw-leading,var(--text-xs--line-height))}.text-\[7px\]{font-size:7px}.text-\[8px\]{font-size:8px}.text-\[9px\]{font-size:9px}.text-\[10px\]{font-size:10px}.text-\[11px\]{font-size:11px}.leading-none{--tw-leading:1;line-height:1}.leading-tight{--tw-leading:var(--leading-tight);line-height:var(--leading-tight)}.font-bold{--tw-font-weight:var(--font-weight-bold);font-weight:var(--font-weight-bold)}.font-medium{--tw-font-weight:var(--font-weight-medium);font-weight:var(--font-weight-medium)}.font-normal{--tw-font-weight:var(--font-weight-normal);font-weight:var(--font-weight-normal)}.font-semibold{--tw-font-weight:var(--font-weight-semibold);font-weight:var(--font-weight-semibold)}.tracking-wide{--tw-tracking:var(--tracking-wide);letter-spacing:var(--tracking-wide)}.tracking-wider{--tw-tracking:var(--tracking-wider);letter-spacing:var(--tracking-wider)}.tracking-widest{--tw-tracking:var(--tracking-widest);letter-spacing:var(--tracking-widest)}.break-all{word-break:break-all}.whitespace-nowrap{white-space:nowrap}.whitespace-pre-wrap{white-space:pre-wrap}.\!text-green-400{color:var(--color-green-400)!important}.text-amber-200{color:var(--color-amber-200)}.text-amber-300{color:var(--color-amber-300)}.text-amber-300\/60{color:#ffd23699}@supports (color:color-mix(in lab,red,red)){.text-amber-300\/60{color:color-mix(in oklab,var(--color-amber-300)60%,transparent)}}.text-amber-300\/70{color:#ffd236b3}@supports (color:color-mix(in lab,red,red)){.text-amber-300\/70{color:color-mix(in oklab,var(--color-amber-300)70%,transparent)}}.text-amber-300\/80{color:#ffd236cc}@supports (color:color-mix(in lab,red,red)){.text-amber-300\/80{color:color-mix(in oklab,var(--color-amber-300)80%,transparent)}}.text-amber-400{color:var(--color-amber-400)}.text-amber-400\/70{color:#fcbb00b3}@supports (color:color-mix(in lab,red,red)){.text-amber-400\/70{color:color-mix(in oklab,var(--color-amber-400)70%,transparent)}}.text-amber-500{color:var(--color-amber-500)}.text-amber-500\/80{color:#f99c00cc}@supports (color:color-mix(in lab,red,red)){.text-amber-500\/80{color:color-mix(in oklab,var(--color-amber-500)80%,transparent)}}.text-amber-600{color:var(--color-amber-600)}.text-bambu-dark-tertiary{color:var(--color-bambu-dark-tertiary)}.text-bambu-gray{color:var(--color-bambu-gray)}.text-bambu-gray-dark{color:var(--color-bambu-gray-dark)}.text-bambu-gray-light{color:var(--color-bambu-gray-light)}.text-bambu-gray\/30{color:var(--color-bambu-gray)}@supports (color:color-mix(in lab,red,red)){.text-bambu-gray\/30{color:color-mix(in oklab,var(--color-bambu-gray)30%,transparent)}}.text-bambu-gray\/40{color:var(--color-bambu-gray)}@supports (color:color-mix(in lab,red,red)){.text-bambu-gray\/40{color:color-mix(in oklab,var(--color-bambu-gray)40%,transparent)}}.text-bambu-gray\/50{color:var(--color-bambu-gray)}@supports (color:color-mix(in lab,red,red)){.text-bambu-gray\/50{color:color-mix(in oklab,var(--color-bambu-gray)50%,transparent)}}.text-bambu-gray\/60{color:var(--color-bambu-gray)}@supports (color:color-mix(in lab,red,red)){.text-bambu-gray\/60{color:color-mix(in oklab,var(--color-bambu-gray)60%,transparent)}}.text-bambu-gray\/70{color:var(--color-bambu-gray)}@supports (color:color-mix(in lab,red,red)){.text-bambu-gray\/70{color:color-mix(in oklab,var(--color-bambu-gray)70%,transparent)}}.text-bambu-gray\/80{color:var(--color-bambu-gray)}@supports (color:color-mix(in lab,red,red)){.text-bambu-gray\/80{color:color-mix(in oklab,var(--color-bambu-gray)80%,transparent)}}.text-bambu-green,.text-bambu-green\/70{color:var(--color-bambu-green)}@supports (color:color-mix(in lab,red,red)){.text-bambu-green\/70{color:color-mix(in oklab,var(--color-bambu-green)70%,transparent)}}.text-black{color:var(--color-black)}.text-black\/80{color:#000c}@supports (color:color-mix(in lab,red,red)){.text-black\/80{color:color-mix(in oklab,var(--color-black)80%,transparent)}}.text-blue-300{color:var(--color-blue-300)}.text-blue-300\/70{color:#90c5ffb3}@supports (color:color-mix(in lab,red,red)){.text-blue-300\/70{color:color-mix(in oklab,var(--color-blue-300)70%,transparent)}}.text-blue-300\/80{color:#90c5ffcc}@supports (color:color-mix(in lab,red,red)){.text-blue-300\/80{color:color-mix(in oklab,var(--color-blue-300)80%,transparent)}}.text-blue-400{color:var(--color-blue-400)}.text-blue-500{color:var(--color-blue-500)}.text-blue-500\/70{color:#3080ffb3}@supports (color:color-mix(in lab,red,red)){.text-blue-500\/70{color:color-mix(in oklab,var(--color-blue-500)70%,transparent)}}.text-blue-600{color:var(--color-blue-600)}.text-blue-700{color:var(--color-blue-700)}.text-cyan-300{color:var(--color-cyan-300)}.text-cyan-400{color:var(--color-cyan-400)}.text-emerald-400{color:var(--color-emerald-400)}.text-gray-300{color:var(--color-gray-300)}.text-gray-400{color:var(--color-gray-400)}.text-gray-500{color:var(--color-gray-500)}.text-gray-600{color:var(--color-gray-600)}.text-gray-700{color:var(--color-gray-700)}.text-gray-800{color:var(--color-gray-800)}.text-gray-900{color:var(--color-gray-900)}.text-green-200{color:var(--color-green-200)}.text-green-300{color:var(--color-green-300)}.text-green-400{color:var(--color-green-400)}.text-green-500{color:var(--color-green-500)}.text-green-500\/60{color:#00c75899}@supports (color:color-mix(in lab,red,red)){.text-green-500\/60{color:color-mix(in oklab,var(--color-green-500)60%,transparent)}}.text-green-600{color:var(--color-green-600)}.text-indigo-400{color:var(--color-indigo-400)}.text-orange-200{color:var(--color-orange-200)}.text-orange-300{color:var(--color-orange-300)}.text-orange-400{color:var(--color-orange-400)}.text-orange-500{color:var(--color-orange-500)}.text-orange-600{color:var(--color-orange-600)}.text-orange-700{color:var(--color-orange-700)}.text-purple-300{color:var(--color-purple-300)}.text-purple-300\/70{color:#d9b3ffb3}@supports (color:color-mix(in lab,red,red)){.text-purple-300\/70{color:color-mix(in oklab,var(--color-purple-300)70%,transparent)}}.text-purple-400{color:var(--color-purple-400)}.text-purple-400\/80{color:#c07effcc}@supports (color:color-mix(in lab,red,red)){.text-purple-400\/80{color:color-mix(in oklab,var(--color-purple-400)80%,transparent)}}.text-purple-500{color:var(--color-purple-500)}.text-red-200{color:var(--color-red-200)}.text-red-300{color:var(--color-red-300)}.text-red-300\/80{color:#ffa3a3cc}@supports (color:color-mix(in lab,red,red)){.text-red-300\/80{color:color-mix(in oklab,var(--color-red-300)80%,transparent)}}.text-red-400{color:var(--color-red-400)}.text-red-400\/50{color:#ff656880}@supports (color:color-mix(in lab,red,red)){.text-red-400\/50{color:color-mix(in oklab,var(--color-red-400)50%,transparent)}}.text-red-400\/60{color:#ff656899}@supports (color:color-mix(in lab,red,red)){.text-red-400\/60{color:color-mix(in oklab,var(--color-red-400)60%,transparent)}}.text-red-400\/70{color:#ff6568b3}@supports (color:color-mix(in lab,red,red)){.text-red-400\/70{color:color-mix(in oklab,var(--color-red-400)70%,transparent)}}.text-red-500{color:var(--color-red-500)}.text-red-600{color:var(--color-red-600)}.text-rose-300{color:var(--color-rose-300)}.text-rose-400{color:var(--color-rose-400)}.text-sky-400{color:var(--color-sky-400)}.text-slate-300{color:var(--color-slate-300)}.text-status-error{color:var(--color-status-error)}.text-status-ok{color:var(--color-status-ok)}.text-status-warning{color:var(--color-status-warning)}.text-teal-400{color:var(--color-teal-400)}.text-white{color:var(--color-white)}.text-white\/40{color:#fff6}@supports (color:color-mix(in lab,red,red)){.text-white\/40{color:color-mix(in oklab,var(--color-white)40%,transparent)}}.text-white\/60{color:#fff9}@supports (color:color-mix(in lab,red,red)){.text-white\/60{color:color-mix(in oklab,var(--color-white)60%,transparent)}}.text-white\/70{color:#ffffffb3}@supports (color:color-mix(in lab,red,red)){.text-white\/70{color:color-mix(in oklab,var(--color-white)70%,transparent)}}.text-white\/80{color:#fffc}@supports (color:color-mix(in lab,red,red)){.text-white\/80{color:color-mix(in oklab,var(--color-white)80%,transparent)}}.text-white\/90{color:#ffffffe6}@supports (color:color-mix(in lab,red,red)){.text-white\/90{color:color-mix(in oklab,var(--color-white)90%,transparent)}}.text-yellow-200{color:var(--color-yellow-200)}.text-yellow-200\/70{color:#fff085b3}@supports (color:color-mix(in lab,red,red)){.text-yellow-200\/70{color:color-mix(in oklab,var(--color-yellow-200)70%,transparent)}}.text-yellow-300{color:var(--color-yellow-300)}.text-yellow-400{color:var(--color-yellow-400)}.text-yellow-500{color:var(--color-yellow-500)}.text-yellow-500\/70{color:#edb200b3}@supports (color:color-mix(in lab,red,red)){.text-yellow-500\/70{color:color-mix(in oklab,var(--color-yellow-500)70%,transparent)}}.text-yellow-600{color:var(--color-yellow-600)}.text-yellow-700{color:var(--color-yellow-700)}.capitalize{text-transform:capitalize}.uppercase{text-transform:uppercase}.italic{font-style:italic}.tabular-nums{--tw-numeric-spacing:tabular-nums;font-variant-numeric:var(--tw-ordinal,)var(--tw-slashed-zero,)var(--tw-numeric-figure,)var(--tw-numeric-spacing,)var(--tw-numeric-fraction,)}.line-through{text-decoration-line:line-through}.underline{text-decoration-line:underline}.placeholder-bambu-gray::placeholder{color:var(--color-bambu-gray)}.placeholder-bambu-gray-dark::placeholder{color:var(--color-bambu-gray-dark)}.placeholder-bambu-gray\/50::placeholder{color:var(--color-bambu-gray)}@supports (color:color-mix(in lab,red,red)){.placeholder-bambu-gray\/50::placeholder{color:color-mix(in oklab,var(--color-bambu-gray)50%,transparent)}}.accent-bambu-green{accent-color:var(--color-bambu-green)}.accent-green-500{accent-color:var(--color-green-500)}.opacity-0{opacity:0}.opacity-20{opacity:.2}.opacity-25{opacity:.25}.opacity-30{opacity:.3}.opacity-40{opacity:.4}.opacity-50{opacity:.5}.opacity-60{opacity:.6}.opacity-70{opacity:.7}.opacity-75{opacity:.75}.opacity-80{opacity:.8}.opacity-100{opacity:1}.shadow{--tw-shadow:0 1px 3px 0 var(--tw-shadow-color,#0000001a),0 1px 2px -1px var(--tw-shadow-color,#0000001a);box-shadow:var(--tw-inset-shadow),var(--tw-inset-ring-shadow),var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow)}.shadow-2xl{--tw-shadow:0 25px 50px -12px var(--tw-shadow-color,#00000040);box-shadow:var(--tw-inset-shadow),var(--tw-inset-ring-shadow),var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow)}.shadow-lg{--tw-shadow:0 10px 15px -3px var(--tw-shadow-color,#0000001a),0 4px 6px -4px var(--tw-shadow-color,#0000001a);box-shadow:var(--tw-inset-shadow),var(--tw-inset-ring-shadow),var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow)}.shadow-md{--tw-shadow:0 4px 6px -1px var(--tw-shadow-color,#0000001a),0 2px 4px -2px var(--tw-shadow-color,#0000001a);box-shadow:var(--tw-inset-shadow),var(--tw-inset-ring-shadow),var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow)}.shadow-sm{--tw-shadow:0 1px 3px 0 var(--tw-shadow-color,#0000001a),0 1px 2px -1px var(--tw-shadow-color,#0000001a);box-shadow:var(--tw-inset-shadow),var(--tw-inset-ring-shadow),var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow)}.shadow-xl{--tw-shadow:0 20px 25px -5px var(--tw-shadow-color,#0000001a),0 8px 10px -6px var(--tw-shadow-color,#0000001a);box-shadow:var(--tw-inset-shadow),var(--tw-inset-ring-shadow),var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow)}.ring-1{--tw-ring-shadow:var(--tw-ring-inset,)0 0 0 calc(1px + var(--tw-ring-offset-width))var(--tw-ring-color,currentcolor);box-shadow:var(--tw-inset-shadow),var(--tw-inset-ring-shadow),var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow)}.ring-2{--tw-ring-shadow:var(--tw-ring-inset,)0 0 0 calc(2px + var(--tw-ring-offset-width))var(--tw-ring-color,currentcolor);box-shadow:var(--tw-inset-shadow),var(--tw-inset-ring-shadow),var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow)}.shadow-bambu-green\/20{--tw-shadow-color:var(--color-bambu-green)}@supports (color:color-mix(in lab,red,red)){.shadow-bambu-green\/20{--tw-shadow-color:color-mix(in oklab,color-mix(in oklab,var(--color-bambu-green)20%,transparent)var(--tw-shadow-alpha),transparent)}}.shadow-bambu-green\/25{--tw-shadow-color:var(--color-bambu-green)}@supports (color:color-mix(in lab,red,red)){.shadow-bambu-green\/25{--tw-shadow-color:color-mix(in oklab,color-mix(in oklab,var(--color-bambu-green)25%,transparent)var(--tw-shadow-alpha),transparent)}}.ring-bambu-green,.ring-bambu-green\/30{--tw-ring-color:var(--color-bambu-green)}@supports (color:color-mix(in lab,red,red)){.ring-bambu-green\/30{--tw-ring-color:color-mix(in oklab,var(--color-bambu-green)30%,transparent)}}.ring-blue-400\/50{--tw-ring-color:#54a2ff80}@supports (color:color-mix(in lab,red,red)){.ring-blue-400\/50{--tw-ring-color:color-mix(in oklab,var(--color-blue-400)50%,transparent)}}.ring-green-500{--tw-ring-color:var(--color-green-500)}.ring-white{--tw-ring-color:var(--color-white)}.ring-offset-1{--tw-ring-offset-width:1px;--tw-ring-offset-shadow:var(--tw-ring-inset,)0 0 0 var(--tw-ring-offset-width)var(--tw-ring-offset-color)}.ring-offset-2{--tw-ring-offset-width:2px;--tw-ring-offset-shadow:var(--tw-ring-inset,)0 0 0 var(--tw-ring-offset-width)var(--tw-ring-offset-color)}.ring-offset-bambu-dark{--tw-ring-offset-color:var(--color-bambu-dark)}.ring-offset-bambu-dark-secondary{--tw-ring-offset-color:var(--color-bambu-dark-secondary)}.outline{outline-style:var(--tw-outline-style);outline-width:1px}.blur{--tw-blur:blur(8px);filter:var(--tw-blur,)var(--tw-brightness,)var(--tw-contrast,)var(--tw-grayscale,)var(--tw-hue-rotate,)var(--tw-invert,)var(--tw-saturate,)var(--tw-sepia,)var(--tw-drop-shadow,)}.blur-2xl{--tw-blur:blur(var(--blur-2xl));filter:var(--tw-blur,)var(--tw-brightness,)var(--tw-contrast,)var(--tw-grayscale,)var(--tw-hue-rotate,)var(--tw-invert,)var(--tw-saturate,)var(--tw-sepia,)var(--tw-drop-shadow,)}.drop-shadow-lg{--tw-drop-shadow-size:drop-shadow(0 4px 4px var(--tw-drop-shadow-color,#00000026));--tw-drop-shadow:drop-shadow(var(--drop-shadow-lg));filter:var(--tw-blur,)var(--tw-brightness,)var(--tw-contrast,)var(--tw-grayscale,)var(--tw-hue-rotate,)var(--tw-invert,)var(--tw-saturate,)var(--tw-sepia,)var(--tw-drop-shadow,)}.drop-shadow-md{--tw-drop-shadow-size:drop-shadow(0 3px 3px var(--tw-drop-shadow-color,#0000001f));--tw-drop-shadow:drop-shadow(var(--drop-shadow-md));filter:var(--tw-blur,)var(--tw-brightness,)var(--tw-contrast,)var(--tw-grayscale,)var(--tw-hue-rotate,)var(--tw-invert,)var(--tw-saturate,)var(--tw-sepia,)var(--tw-drop-shadow,)}.filter{filter:var(--tw-blur,)var(--tw-brightness,)var(--tw-contrast,)var(--tw-grayscale,)var(--tw-hue-rotate,)var(--tw-invert,)var(--tw-saturate,)var(--tw-sepia,)var(--tw-drop-shadow,)}.backdrop-blur-sm{--tw-backdrop-blur:blur(var(--blur-sm));-webkit-backdrop-filter:var(--tw-backdrop-blur,)var(--tw-backdrop-brightness,)var(--tw-backdrop-contrast,)var(--tw-backdrop-grayscale,)var(--tw-backdrop-hue-rotate,)var(--tw-backdrop-invert,)var(--tw-backdrop-opacity,)var(--tw-backdrop-saturate,)var(--tw-backdrop-sepia,);backdrop-filter:var(--tw-backdrop-blur,)var(--tw-backdrop-brightness,)var(--tw-backdrop-contrast,)var(--tw-backdrop-grayscale,)var(--tw-backdrop-hue-rotate,)var(--tw-backdrop-invert,)var(--tw-backdrop-opacity,)var(--tw-backdrop-saturate,)var(--tw-backdrop-sepia,)}.transition{transition-property:color,background-color,border-color,outline-color,text-decoration-color,fill,stroke,--tw-gradient-from,--tw-gradient-via,--tw-gradient-to,opacity,box-shadow,transform,translate,scale,rotate,filter,-webkit-backdrop-filter,backdrop-filter,display,content-visibility,overlay,pointer-events;transition-timing-function:var(--tw-ease,var(--default-transition-timing-function));transition-duration:var(--tw-duration,var(--default-transition-duration))}.transition-all{transition-property:all;transition-timing-function:var(--tw-ease,var(--default-transition-timing-function));transition-duration:var(--tw-duration,var(--default-transition-duration))}.transition-colors{transition-property:color,background-color,border-color,outline-color,text-decoration-color,fill,stroke,--tw-gradient-from,--tw-gradient-via,--tw-gradient-to;transition-timing-function:var(--tw-ease,var(--default-transition-timing-function));transition-duration:var(--tw-duration,var(--default-transition-duration))}.transition-opacity{transition-property:opacity;transition-timing-function:var(--tw-ease,var(--default-transition-timing-function));transition-duration:var(--tw-duration,var(--default-transition-duration))}.transition-transform{transition-property:transform,translate,scale,rotate;transition-timing-function:var(--tw-ease,var(--default-transition-timing-function));transition-duration:var(--tw-duration,var(--default-transition-duration))}.duration-150{--tw-duration:.15s;transition-duration:.15s}.duration-200{--tw-duration:.2s;transition-duration:.2s}.duration-300{--tw-duration:.3s;transition-duration:.3s}.duration-500{--tw-duration:.5s;transition-duration:.5s}.ease-in-out{--tw-ease:var(--ease-in-out);transition-timing-function:var(--ease-in-out)}.ease-out{--tw-ease:var(--ease-out);transition-timing-function:var(--ease-out)}.select-none{-webkit-user-select:none;user-select:none}@media(hover:hover){.group-hover\:bg-bambu-green\/20:is(:where(.group):hover *){background-color:var(--color-bambu-green)}@supports (color:color-mix(in lab,red,red)){.group-hover\:bg-bambu-green\/20:is(:where(.group):hover *){background-color:color-mix(in oklab,var(--color-bambu-green)20%,transparent)}}.group-hover\:text-bambu-gray:is(:where(.group):hover *){color:var(--color-bambu-gray)}.group-hover\:text-bambu-green:is(:where(.group):hover *){color:var(--color-bambu-green)}.group-hover\:opacity-50:is(:where(.group):hover *){opacity:.5}.group-hover\:opacity-100:is(:where(.group):hover *),.group-hover\/resize\:opacity-100:is(:where(.group\/resize):hover *){opacity:1}.group-hover\/thumb\:block:is(:where(.group\/thumb):hover *){display:block}}.peer-checked\:bg-bambu-green:is(:where(.peer):checked~*){background-color:var(--color-bambu-green)}.peer-focus\:outline-none:is(:where(.peer):focus~*){--tw-outline-style:none;outline-style:none}.placeholder\:text-bambu-gray::placeholder,.placeholder\:text-bambu-gray\/50::placeholder{color:var(--color-bambu-gray)}@supports (color:color-mix(in lab,red,red)){.placeholder\:text-bambu-gray\/50::placeholder{color:color-mix(in oklab,var(--color-bambu-gray)50%,transparent)}}.before\:absolute:before{content:var(--tw-content);position:absolute}.before\:top-0:before{content:var(--tw-content);top:calc(var(--spacing)*0)}.before\:right-0:before{content:var(--tw-content);right:calc(var(--spacing)*0)}.before\:left-0:before{content:var(--tw-content);left:calc(var(--spacing)*0)}.before\:h-0\.5:before{content:var(--tw-content);height:calc(var(--spacing)*.5)}.before\:bg-bambu-green:before{content:var(--tw-content);background-color:var(--color-bambu-green)}.after\:absolute:after{content:var(--tw-content);position:absolute}.after\:top-\[2px\]:after{content:var(--tw-content);top:2px}.after\:left-\[2px\]:after{content:var(--tw-content);left:2px}.after\:h-4:after{content:var(--tw-content);height:calc(var(--spacing)*4)}.after\:h-5:after{content:var(--tw-content);height:calc(var(--spacing)*5)}.after\:w-4:after{content:var(--tw-content);width:calc(var(--spacing)*4)}.after\:w-5:after{content:var(--tw-content);width:calc(var(--spacing)*5)}.after\:rounded-full:after{content:var(--tw-content);border-radius:3.40282e38px}.after\:border:after{content:var(--tw-content);border-style:var(--tw-border-style);border-width:1px}.after\:border-gray-300:after{content:var(--tw-content);border-color:var(--color-gray-300)}.after\:bg-white:after{content:var(--tw-content);background-color:var(--color-white)}.after\:transition-all:after{content:var(--tw-content);transition-property:all;transition-timing-function:var(--tw-ease,var(--default-transition-timing-function));transition-duration:var(--tw-duration,var(--default-transition-duration))}.after\:content-\[\'\'\]:after{--tw-content:"";content:var(--tw-content)}.peer-checked\:after\:translate-x-full:is(:where(.peer):checked~*):after{content:var(--tw-content);--tw-translate-x:100%;translate:var(--tw-translate-x)var(--tw-translate-y)}.peer-checked\:after\:border-white:is(:where(.peer):checked~*):after{content:var(--tw-content);border-color:var(--color-white)}.last\:border-0:last-child{border-style:var(--tw-border-style);border-width:0}.last\:border-b-0:last-child{border-bottom-style:var(--tw-border-style);border-bottom-width:0}@media(hover:hover){.hover\:z-20:hover{z-index:20}.hover\:scale-105:hover{--tw-scale-x:105%;--tw-scale-y:105%;--tw-scale-z:105%;scale:var(--tw-scale-x)var(--tw-scale-y)}.hover\:scale-110:hover{--tw-scale-x:110%;--tw-scale-y:110%;--tw-scale-z:110%;scale:var(--tw-scale-x)var(--tw-scale-y)}.hover\:border-bambu-dark-tertiary\/80:hover{border-color:var(--color-bambu-dark-tertiary)}@supports (color:color-mix(in lab,red,red)){.hover\:border-bambu-dark-tertiary\/80:hover{border-color:color-mix(in oklab,var(--color-bambu-dark-tertiary)80%,transparent)}}.hover\:border-bambu-gray:hover{border-color:var(--color-bambu-gray)}.hover\:border-bambu-gray-dark:hover{border-color:var(--color-bambu-gray-dark)}.hover\:border-bambu-gray\/50:hover{border-color:var(--color-bambu-gray)}@supports (color:color-mix(in lab,red,red)){.hover\:border-bambu-gray\/50:hover{border-color:color-mix(in oklab,var(--color-bambu-gray)50%,transparent)}}.hover\:border-bambu-green:hover,.hover\:border-bambu-green\/50:hover{border-color:var(--color-bambu-green)}@supports (color:color-mix(in lab,red,red)){.hover\:border-bambu-green\/50:hover{border-color:color-mix(in oklab,var(--color-bambu-green)50%,transparent)}}.hover\:border-white:hover{border-color:var(--color-white)}.hover\:border-white\/40:hover{border-color:#fff6}@supports (color:color-mix(in lab,red,red)){.hover\:border-white\/40:hover{border-color:color-mix(in oklab,var(--color-white)40%,transparent)}}.hover\:\!bg-green-500\/20:hover{background-color:#00c75833!important}@supports (color:color-mix(in lab,red,red)){.hover\:\!bg-green-500\/20:hover{background-color:color-mix(in oklab,var(--color-green-500)20%,transparent)!important}}.hover\:bg-amber-500\/30:hover{background-color:#f99c004d}@supports (color:color-mix(in lab,red,red)){.hover\:bg-amber-500\/30:hover{background-color:color-mix(in oklab,var(--color-amber-500)30%,transparent)}}.hover\:bg-bambu-dark:hover{background-color:var(--color-bambu-dark)}.hover\:bg-bambu-dark-secondary:hover,.hover\:bg-bambu-dark-secondary\/50:hover{background-color:var(--color-bambu-dark-secondary)}@supports (color:color-mix(in lab,red,red)){.hover\:bg-bambu-dark-secondary\/50:hover{background-color:color-mix(in oklab,var(--color-bambu-dark-secondary)50%,transparent)}}.hover\:bg-bambu-dark-tertiary:hover,.hover\:bg-bambu-dark-tertiary\/30:hover{background-color:var(--color-bambu-dark-tertiary)}@supports (color:color-mix(in lab,red,red)){.hover\:bg-bambu-dark-tertiary\/30:hover{background-color:color-mix(in oklab,var(--color-bambu-dark-tertiary)30%,transparent)}}.hover\:bg-bambu-dark-tertiary\/50:hover{background-color:var(--color-bambu-dark-tertiary)}@supports (color:color-mix(in lab,red,red)){.hover\:bg-bambu-dark-tertiary\/50:hover{background-color:color-mix(in oklab,var(--color-bambu-dark-tertiary)50%,transparent)}}.hover\:bg-bambu-dark-tertiary\/70:hover{background-color:var(--color-bambu-dark-tertiary)}@supports (color:color-mix(in lab,red,red)){.hover\:bg-bambu-dark-tertiary\/70:hover{background-color:color-mix(in oklab,var(--color-bambu-dark-tertiary)70%,transparent)}}.hover\:bg-bambu-dark-tertiary\/80:hover{background-color:var(--color-bambu-dark-tertiary)}@supports (color:color-mix(in lab,red,red)){.hover\:bg-bambu-dark-tertiary\/80:hover{background-color:color-mix(in oklab,var(--color-bambu-dark-tertiary)80%,transparent)}}.hover\:bg-bambu-dark\/50:hover{background-color:var(--color-bambu-dark)}@supports (color:color-mix(in lab,red,red)){.hover\:bg-bambu-dark\/50:hover{background-color:color-mix(in oklab,var(--color-bambu-dark)50%,transparent)}}.hover\:bg-bambu-dark\/80:hover{background-color:var(--color-bambu-dark)}@supports (color:color-mix(in lab,red,red)){.hover\:bg-bambu-dark\/80:hover{background-color:color-mix(in oklab,var(--color-bambu-dark)80%,transparent)}}.hover\:bg-bambu-gray-dark:hover{background-color:var(--color-bambu-gray-dark)}.hover\:bg-bambu-green:hover{background-color:var(--color-bambu-green)}.hover\:bg-bambu-green-dark:hover{background-color:var(--color-bambu-green-dark)}.hover\:bg-bambu-green-light:hover{background-color:var(--color-bambu-green-light)}.hover\:bg-bambu-green\/10:hover{background-color:var(--color-bambu-green)}@supports (color:color-mix(in lab,red,red)){.hover\:bg-bambu-green\/10:hover{background-color:color-mix(in oklab,var(--color-bambu-green)10%,transparent)}}.hover\:bg-bambu-green\/20:hover{background-color:var(--color-bambu-green)}@supports (color:color-mix(in lab,red,red)){.hover\:bg-bambu-green\/20:hover{background-color:color-mix(in oklab,var(--color-bambu-green)20%,transparent)}}.hover\:bg-bambu-green\/30:hover{background-color:var(--color-bambu-green)}@supports (color:color-mix(in lab,red,red)){.hover\:bg-bambu-green\/30:hover{background-color:color-mix(in oklab,var(--color-bambu-green)30%,transparent)}}.hover\:bg-bambu-green\/50:hover{background-color:var(--color-bambu-green)}@supports (color:color-mix(in lab,red,red)){.hover\:bg-bambu-green\/50:hover{background-color:color-mix(in oklab,var(--color-bambu-green)50%,transparent)}}.hover\:bg-bambu-green\/80:hover{background-color:var(--color-bambu-green)}@supports (color:color-mix(in lab,red,red)){.hover\:bg-bambu-green\/80:hover{background-color:color-mix(in oklab,var(--color-bambu-green)80%,transparent)}}.hover\:bg-black\/40:hover{background-color:#0006}@supports (color:color-mix(in lab,red,red)){.hover\:bg-black\/40:hover{background-color:color-mix(in oklab,var(--color-black)40%,transparent)}}.hover\:bg-black\/70:hover{background-color:#000000b3}@supports (color:color-mix(in lab,red,red)){.hover\:bg-black\/70:hover{background-color:color-mix(in oklab,var(--color-black)70%,transparent)}}.hover\:bg-black\/80:hover{background-color:#000c}@supports (color:color-mix(in lab,red,red)){.hover\:bg-black\/80:hover{background-color:color-mix(in oklab,var(--color-black)80%,transparent)}}.hover\:bg-blue-500\/30:hover{background-color:#3080ff4d}@supports (color:color-mix(in lab,red,red)){.hover\:bg-blue-500\/30:hover{background-color:color-mix(in oklab,var(--color-blue-500)30%,transparent)}}.hover\:bg-gray-50:hover{background-color:var(--color-gray-50)}.hover\:bg-gray-100:hover{background-color:var(--color-gray-100)}.hover\:bg-gray-700:hover{background-color:var(--color-gray-700)}.hover\:bg-green-500\/20:hover{background-color:#00c75833}@supports (color:color-mix(in lab,red,red)){.hover\:bg-green-500\/20:hover{background-color:color-mix(in oklab,var(--color-green-500)20%,transparent)}}.hover\:bg-orange-400\/20:hover{background-color:#ff8b1a33}@supports (color:color-mix(in lab,red,red)){.hover\:bg-orange-400\/20:hover{background-color:color-mix(in oklab,var(--color-orange-400)20%,transparent)}}.hover\:bg-red-200:hover{background-color:var(--color-red-200)}.hover\:bg-red-400\/10:hover{background-color:#ff65681a}@supports (color:color-mix(in lab,red,red)){.hover\:bg-red-400\/10:hover{background-color:color-mix(in oklab,var(--color-red-400)10%,transparent)}}.hover\:bg-red-500\/10:hover{background-color:#fb2c361a}@supports (color:color-mix(in lab,red,red)){.hover\:bg-red-500\/10:hover{background-color:color-mix(in oklab,var(--color-red-500)10%,transparent)}}.hover\:bg-red-500\/20:hover{background-color:#fb2c3633}@supports (color:color-mix(in lab,red,red)){.hover\:bg-red-500\/20:hover{background-color:color-mix(in oklab,var(--color-red-500)20%,transparent)}}.hover\:bg-red-500\/30:hover{background-color:#fb2c364d}@supports (color:color-mix(in lab,red,red)){.hover\:bg-red-500\/30:hover{background-color:color-mix(in oklab,var(--color-red-500)30%,transparent)}}.hover\:bg-red-600:hover{background-color:var(--color-red-600)}.hover\:bg-red-700:hover{background-color:var(--color-red-700)}.hover\:bg-white\/5:hover{background-color:#ffffff0d}@supports (color:color-mix(in lab,red,red)){.hover\:bg-white\/5:hover{background-color:color-mix(in oklab,var(--color-white)5%,transparent)}}.hover\:bg-white\/10:hover{background-color:#ffffff1a}@supports (color:color-mix(in lab,red,red)){.hover\:bg-white\/10:hover{background-color:color-mix(in oklab,var(--color-white)10%,transparent)}}.hover\:bg-white\/80:hover{background-color:#fffc}@supports (color:color-mix(in lab,red,red)){.hover\:bg-white\/80:hover{background-color:color-mix(in oklab,var(--color-white)80%,transparent)}}.hover\:bg-yellow-500\/30:hover{background-color:#edb2004d}@supports (color:color-mix(in lab,red,red)){.hover\:bg-yellow-500\/30:hover{background-color:color-mix(in oklab,var(--color-yellow-500)30%,transparent)}}.hover\:bg-yellow-600:hover{background-color:var(--color-yellow-600)}.hover\:text-amber-300:hover{color:var(--color-amber-300)}.hover\:text-bambu-gray:hover{color:var(--color-bambu-gray)}.hover\:text-bambu-green:hover{color:var(--color-bambu-green)}.hover\:text-bambu-green-light:hover{color:var(--color-bambu-green-light)}.hover\:text-bambu-green\/70:hover{color:var(--color-bambu-green)}@supports (color:color-mix(in lab,red,red)){.hover\:text-bambu-green\/70:hover{color:color-mix(in oklab,var(--color-bambu-green)70%,transparent)}}.hover\:text-bambu-green\/80:hover{color:var(--color-bambu-green)}@supports (color:color-mix(in lab,red,red)){.hover\:text-bambu-green\/80:hover{color:color-mix(in oklab,var(--color-bambu-green)80%,transparent)}}.hover\:text-blue-300:hover{color:var(--color-blue-300)}.hover\:text-gray-900:hover{color:var(--color-gray-900)}.hover\:text-orange-300:hover{color:var(--color-orange-300)}.hover\:text-red-300:hover{color:var(--color-red-300)}.hover\:text-red-400:hover{color:var(--color-red-400)}.hover\:text-white:hover{color:var(--color-white)}.hover\:text-white\/80:hover{color:#fffc}@supports (color:color-mix(in lab,red,red)){.hover\:text-white\/80:hover{color:color-mix(in oklab,var(--color-white)80%,transparent)}}.hover\:text-yellow-400:hover{color:var(--color-yellow-400)}.hover\:underline:hover{text-decoration-line:underline}.hover\:opacity-70:hover{opacity:.7}.hover\:opacity-80:hover{opacity:.8}.hover\:shadow-lg:hover{--tw-shadow:0 10px 15px -3px var(--tw-shadow-color,#0000001a),0 4px 6px -4px var(--tw-shadow-color,#0000001a);box-shadow:var(--tw-inset-shadow),var(--tw-inset-ring-shadow),var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow)}.hover\:shadow-bambu-green\/5:hover{--tw-shadow-color:var(--color-bambu-green)}@supports (color:color-mix(in lab,red,red)){.hover\:shadow-bambu-green\/5:hover{--tw-shadow-color:color-mix(in oklab,color-mix(in oklab,var(--color-bambu-green)5%,transparent)var(--tw-shadow-alpha),transparent)}}.hover\:shadow-bambu-green\/30:hover{--tw-shadow-color:var(--color-bambu-green)}@supports (color:color-mix(in lab,red,red)){.hover\:shadow-bambu-green\/30:hover{--tw-shadow-color:color-mix(in oklab,color-mix(in oklab,var(--color-bambu-green)30%,transparent)var(--tw-shadow-alpha),transparent)}}}.focus\:border-bambu-green:focus{border-color:var(--color-bambu-green)}.focus\:border-red-500:focus{border-color:var(--color-red-500)}.focus\:ring-1:focus{--tw-ring-shadow:var(--tw-ring-inset,)0 0 0 calc(1px + var(--tw-ring-offset-width))var(--tw-ring-color,currentcolor);box-shadow:var(--tw-inset-shadow),var(--tw-inset-ring-shadow),var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow)}.focus\:ring-2:focus{--tw-ring-shadow:var(--tw-ring-inset,)0 0 0 calc(2px + var(--tw-ring-offset-width))var(--tw-ring-color,currentcolor);box-shadow:var(--tw-inset-shadow),var(--tw-inset-ring-shadow),var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow)}.focus\:ring-bambu-gray:focus{--tw-ring-color:var(--color-bambu-gray)}.focus\:ring-bambu-green:focus,.focus\:ring-bambu-green\/50:focus{--tw-ring-color:var(--color-bambu-green)}@supports (color:color-mix(in lab,red,red)){.focus\:ring-bambu-green\/50:focus{--tw-ring-color:color-mix(in oklab,var(--color-bambu-green)50%,transparent)}}.focus\:ring-red-500:focus{--tw-ring-color:var(--color-red-500)}.focus\:ring-offset-0:focus{--tw-ring-offset-width:0px;--tw-ring-offset-shadow:var(--tw-ring-inset,)0 0 0 var(--tw-ring-offset-width)var(--tw-ring-offset-color)}.focus\:ring-offset-2:focus{--tw-ring-offset-width:2px;--tw-ring-offset-shadow:var(--tw-ring-inset,)0 0 0 var(--tw-ring-offset-width)var(--tw-ring-offset-color)}.focus\:ring-offset-bambu-dark:focus{--tw-ring-offset-color:var(--color-bambu-dark)}.focus\:ring-offset-bambu-dark-secondary:focus{--tw-ring-offset-color:var(--color-bambu-dark-secondary)}.focus\:outline-none:focus{--tw-outline-style:none;outline-style:none}.active\:cursor-grabbing:active{cursor:grabbing}.disabled\:cursor-not-allowed:disabled{cursor:not-allowed}.disabled\:opacity-30:disabled{opacity:.3}.disabled\:opacity-50:disabled{opacity:.5}@media(hover:hover){.disabled\:hover\:bg-bambu-green:disabled:hover{background-color:var(--color-bambu-green)}}@media not all and (min-width:640px){.max-\[640px\]\:hidden{display:none}.max-\[640px\]\:w-full{width:100%}.max-\[640px\]\:grid-cols-1{grid-template-columns:repeat(1,minmax(0,1fr))}.max-\[640px\]\:flex-col{flex-direction:column}.max-\[640px\]\:flex-wrap{flex-wrap:wrap}.max-\[640px\]\:items-center{align-items:center}.max-\[640px\]\:items-start{align-items:flex-start}}@media not all and (min-width:550px){.max-\[550px\]\:order-1{order:1}.max-\[550px\]\:order-2{order:2}.max-\[550px\]\:order-3{order:3}.max-\[550px\]\:order-4{order:4}.max-\[550px\]\:mt-1{margin-top:calc(var(--spacing)*1)}.max-\[550px\]\:w-full{width:100%}.max-\[550px\]\:grid-cols-2{grid-template-columns:repeat(2,minmax(0,1fr))}.max-\[550px\]\:flex-col{flex-direction:column}.max-\[550px\]\:flex-wrap{flex-wrap:wrap}.max-\[550px\]\:items-center{align-items:center}.max-\[550px\]\:items-start{align-items:flex-start}.max-\[550px\]\:justify-end{justify-content:flex-end}.max-\[550px\]\:gap-1\.5{gap:calc(var(--spacing)*1.5)}.max-\[550px\]\:gap-2{gap:calc(var(--spacing)*2)}.max-\[550px\]\:gap-3{gap:calc(var(--spacing)*3)}.max-\[550px\]\:self-start{align-self:flex-start}}@media(min-width:40rem){.sm\:mt-0{margin-top:calc(var(--spacing)*0)}.sm\:mr-1{margin-right:calc(var(--spacing)*1)}.sm\:ml-auto{margin-left:auto}.sm\:block{display:block}.sm\:grid{display:grid}.sm\:inline{display:inline}.sm\:h-4{height:calc(var(--spacing)*4)}.sm\:w-4{width:calc(var(--spacing)*4)}.sm\:w-16{width:calc(var(--spacing)*16)}.sm\:w-40{width:calc(var(--spacing)*40)}.sm\:w-auto{width:auto}.sm\:max-w-xs{max-width:var(--container-xs)}.sm\:flex-1{flex:1}.sm\:grid-cols-2{grid-template-columns:repeat(2,minmax(0,1fr))}.sm\:grid-cols-3{grid-template-columns:repeat(3,minmax(0,1fr))}.sm\:grid-cols-4{grid-template-columns:repeat(4,minmax(0,1fr))}.sm\:flex-row{flex-direction:row}.sm\:items-center{align-items:center}.sm\:justify-between{justify-content:space-between}.sm\:gap-2{gap:calc(var(--spacing)*2)}.sm\:gap-3{gap:calc(var(--spacing)*3)}.sm\:gap-6{gap:calc(var(--spacing)*6)}.sm\:p-1\.5{padding:calc(var(--spacing)*1.5)}.sm\:p-3{padding:calc(var(--spacing)*3)}}@media(min-width:48rem){.md\:top-\[2px\]{top:2px}.md\:left-\[2px\]{left:2px}.md\:mx-0{margin-inline:calc(var(--spacing)*0)}.md\:block{display:block}.md\:inline{display:inline}.md\:h-4{height:calc(var(--spacing)*4)}.md\:h-5{height:calc(var(--spacing)*5)}.md\:h-8{height:calc(var(--spacing)*8)}.md\:min-h-0{min-height:calc(var(--spacing)*0)}.md\:w-4{width:calc(var(--spacing)*4)}.md\:w-8{width:calc(var(--spacing)*8)}.md\:w-9{width:calc(var(--spacing)*9)}.md\:min-w-\[200px\]{min-width:200px}.md\:flex-1{flex:1}.md\:grid-cols-2{grid-template-columns:repeat(2,minmax(0,1fr))}.md\:grid-cols-3{grid-template-columns:repeat(3,minmax(0,1fr))}.md\:grid-cols-4{grid-template-columns:repeat(4,minmax(0,1fr))}.md\:grid-cols-5{grid-template-columns:repeat(5,minmax(0,1fr))}.md\:flex-row{flex-direction:row}.md\:flex-wrap{flex-wrap:wrap}.md\:items-center{align-items:center}.md\:gap-4{gap:calc(var(--spacing)*4)}.md\:p-6{padding:calc(var(--spacing)*6)}.md\:p-8{padding:calc(var(--spacing)*8)}.md\:px-0{padding-inline:calc(var(--spacing)*0)}.md\:py-2{padding-block:calc(var(--spacing)*2)}.md\:pb-0{padding-bottom:calc(var(--spacing)*0)}}@media(min-width:64rem){.lg\:static{position:static}.lg\:col-span-2{grid-column:span 2/span 2}.lg\:flex{display:flex}.lg\:hidden{display:none}.lg\:h-\[calc\(100vh-64px\)\]{height:calc(100vh - 64px)}.lg\:w-1\/3{width:33.3333%}.lg\:w-2\/3{width:66.6667%}.lg\:w-80{width:calc(var(--spacing)*80)}.lg\:w-\[480px\]{width:480px}.lg\:max-w-md{max-width:var(--container-md)}.lg\:max-w-sm{max-width:var(--container-sm)}.lg\:max-w-xl{max-width:var(--container-xl)}.lg\:flex-shrink-0{flex-shrink:0}.lg\:grid-cols-2{grid-template-columns:repeat(2,minmax(0,1fr))}.lg\:grid-cols-3{grid-template-columns:repeat(3,minmax(0,1fr))}.lg\:grid-cols-4{grid-template-columns:repeat(4,minmax(0,1fr))}.lg\:grid-cols-5{grid-template-columns:repeat(5,minmax(0,1fr))}.lg\:flex-row{flex-direction:row}.lg\:gap-6{gap:calc(var(--spacing)*6)}.lg\:gap-8{gap:calc(var(--spacing)*8)}.lg\:overflow-y-auto{overflow-y:auto}.lg\:p-8{padding:calc(var(--spacing)*8)}}@media(min-width:80rem){.xl\:grid-cols-2{grid-template-columns:repeat(2,minmax(0,1fr))}.xl\:grid-cols-3{grid-template-columns:repeat(3,minmax(0,1fr))}.xl\:grid-cols-4{grid-template-columns:repeat(4,minmax(0,1fr))}.xl\:grid-cols-5{grid-template-columns:repeat(5,minmax(0,1fr))}.xl\:grid-cols-6{grid-template-columns:repeat(6,minmax(0,1fr))}}@media(min-width:96rem){.\32xl\:grid-cols-6{grid-template-columns:repeat(6,minmax(0,1fr))}}.dark\:border-bambu-dark-tertiary:where(.dark,.dark *),.dark\:border-bambu-dark-tertiary\/50:where(.dark,.dark *){border-color:var(--color-bambu-dark-tertiary)}@supports (color:color-mix(in lab,red,red)){.dark\:border-bambu-dark-tertiary\/50:where(.dark,.dark *){border-color:color-mix(in oklab,var(--color-bambu-dark-tertiary)50%,transparent)}}.dark\:border-bambu-green\/40:where(.dark,.dark *){border-color:var(--color-bambu-green)}@supports (color:color-mix(in lab,red,red)){.dark\:border-bambu-green\/40:where(.dark,.dark *){border-color:color-mix(in oklab,var(--color-bambu-green)40%,transparent)}}.dark\:border-gray-600:where(.dark,.dark *){border-color:var(--color-gray-600)}.dark\:border-red-500\/30:where(.dark,.dark *){border-color:#fb2c364d}@supports (color:color-mix(in lab,red,red)){.dark\:border-red-500\/30:where(.dark,.dark *){border-color:color-mix(in oklab,var(--color-red-500)30%,transparent)}}.dark\:border-red-500\/40:where(.dark,.dark *){border-color:#fb2c3666}@supports (color:color-mix(in lab,red,red)){.dark\:border-red-500\/40:where(.dark,.dark *){border-color:color-mix(in oklab,var(--color-red-500)40%,transparent)}}.dark\:bg-amber-500\/10:where(.dark,.dark *){background-color:#f99c001a}@supports (color:color-mix(in lab,red,red)){.dark\:bg-amber-500\/10:where(.dark,.dark *){background-color:color-mix(in oklab,var(--color-amber-500)10%,transparent)}}.dark\:bg-bambu-dark:where(.dark,.dark *){background-color:var(--color-bambu-dark)}.dark\:bg-bambu-dark-secondary:where(.dark,.dark *){background-color:var(--color-bambu-dark-secondary)}.dark\:bg-bambu-green\/20:where(.dark,.dark *){background-color:var(--color-bambu-green)}@supports (color:color-mix(in lab,red,red)){.dark\:bg-bambu-green\/20:where(.dark,.dark *){background-color:color-mix(in oklab,var(--color-bambu-green)20%,transparent)}}.dark\:bg-black\/80:where(.dark,.dark *){background-color:#000c}@supports (color:color-mix(in lab,red,red)){.dark\:bg-black\/80:where(.dark,.dark *){background-color:color-mix(in oklab,var(--color-black)80%,transparent)}}.dark\:bg-blue-500\/10:where(.dark,.dark *){background-color:#3080ff1a}@supports (color:color-mix(in lab,red,red)){.dark\:bg-blue-500\/10:where(.dark,.dark *){background-color:color-mix(in oklab,var(--color-blue-500)10%,transparent)}}.dark\:bg-blue-500\/20:where(.dark,.dark *){background-color:#3080ff33}@supports (color:color-mix(in lab,red,red)){.dark\:bg-blue-500\/20:where(.dark,.dark *){background-color:color-mix(in oklab,var(--color-blue-500)20%,transparent)}}.dark\:bg-gray-500\/40:where(.dark,.dark *){background-color:#6a728266}@supports (color:color-mix(in lab,red,red)){.dark\:bg-gray-500\/40:where(.dark,.dark *){background-color:color-mix(in oklab,var(--color-gray-500)40%,transparent)}}.dark\:bg-gray-900:where(.dark,.dark *){background-color:var(--color-gray-900)}.dark\:bg-red-500\/10:where(.dark,.dark *){background-color:#fb2c361a}@supports (color:color-mix(in lab,red,red)){.dark\:bg-red-500\/10:where(.dark,.dark *){background-color:color-mix(in oklab,var(--color-red-500)10%,transparent)}}.dark\:bg-red-500\/20:where(.dark,.dark *){background-color:#fb2c3633}@supports (color:color-mix(in lab,red,red)){.dark\:bg-red-500\/20:where(.dark,.dark *){background-color:color-mix(in oklab,var(--color-red-500)20%,transparent)}}.dark\:text-amber-400:where(.dark,.dark *){color:var(--color-amber-400)}.dark\:text-bambu-gray:where(.dark,.dark *),.dark\:text-bambu-gray\/30:where(.dark,.dark *){color:var(--color-bambu-gray)}@supports (color:color-mix(in lab,red,red)){.dark\:text-bambu-gray\/30:where(.dark,.dark *){color:color-mix(in oklab,var(--color-bambu-gray)30%,transparent)}}.dark\:text-bambu-gray\/50:where(.dark,.dark *){color:var(--color-bambu-gray)}@supports (color:color-mix(in lab,red,red)){.dark\:text-bambu-gray\/50:where(.dark,.dark *){color:color-mix(in oklab,var(--color-bambu-gray)50%,transparent)}}.dark\:text-bambu-green:where(.dark,.dark *),.dark\:text-bambu-green\/60:where(.dark,.dark *){color:var(--color-bambu-green)}@supports (color:color-mix(in lab,red,red)){.dark\:text-bambu-green\/60:where(.dark,.dark *){color:color-mix(in oklab,var(--color-bambu-green)60%,transparent)}}.dark\:text-blue-200:where(.dark,.dark *){color:var(--color-blue-200)}.dark\:text-blue-200\/80:where(.dark,.dark *){color:#bedbffcc}@supports (color:color-mix(in lab,red,red)){.dark\:text-blue-200\/80:where(.dark,.dark *){color:color-mix(in oklab,var(--color-blue-200)80%,transparent)}}.dark\:text-blue-300:where(.dark,.dark *){color:var(--color-blue-300)}.dark\:text-blue-300\/60:where(.dark,.dark *){color:#90c5ff99}@supports (color:color-mix(in lab,red,red)){.dark\:text-blue-300\/60:where(.dark,.dark *){color:color-mix(in oklab,var(--color-blue-300)60%,transparent)}}.dark\:text-blue-400:where(.dark,.dark *){color:var(--color-blue-400)}.dark\:text-orange-200:where(.dark,.dark *){color:var(--color-orange-200)}.dark\:text-orange-400:where(.dark,.dark *){color:var(--color-orange-400)}.dark\:text-red-400:where(.dark,.dark *){color:var(--color-red-400)}.dark\:text-red-400\/70:where(.dark,.dark *){color:#ff6568b3}@supports (color:color-mix(in lab,red,red)){.dark\:text-red-400\/70:where(.dark,.dark *){color:color-mix(in oklab,var(--color-red-400)70%,transparent)}}.dark\:text-white:where(.dark,.dark *){color:var(--color-white)}.dark\:text-yellow-200:where(.dark,.dark *){color:var(--color-yellow-200)}.dark\:text-yellow-200\/70:where(.dark,.dark *){color:#fff085b3}@supports (color:color-mix(in lab,red,red)){.dark\:text-yellow-200\/70:where(.dark,.dark *){color:color-mix(in oklab,var(--color-yellow-200)70%,transparent)}}@media(hover:hover){.dark\:hover\:bg-bambu-dark-tertiary:where(.dark,.dark *):hover{background-color:var(--color-bambu-dark-tertiary)}.dark\:hover\:bg-bambu-dark\/50:where(.dark,.dark *):hover{background-color:var(--color-bambu-dark)}@supports (color:color-mix(in lab,red,red)){.dark\:hover\:bg-bambu-dark\/50:where(.dark,.dark *):hover{background-color:color-mix(in oklab,var(--color-bambu-dark)50%,transparent)}}.dark\:hover\:bg-red-500\/30:where(.dark,.dark *):hover{background-color:#fb2c364d}@supports (color:color-mix(in lab,red,red)){.dark\:hover\:bg-red-500\/30:where(.dark,.dark *):hover{background-color:color-mix(in oklab,var(--color-red-500)30%,transparent)}}.dark\:hover\:text-white:where(.dark,.dark *):hover{color:var(--color-white)}}.\[\&\:\:-webkit-slider-thumb\]\:h-3::-webkit-slider-thumb{height:calc(var(--spacing)*3)}.\[\&\:\:-webkit-slider-thumb\]\:w-3::-webkit-slider-thumb{width:calc(var(--spacing)*3)}.\[\&\:\:-webkit-slider-thumb\]\:cursor-pointer::-webkit-slider-thumb{cursor:pointer}.\[\&\:\:-webkit-slider-thumb\]\:appearance-none::-webkit-slider-thumb{appearance:none}.\[\&\:\:-webkit-slider-thumb\]\:rounded-full::-webkit-slider-thumb{border-radius:3.40282e38px}.\[\&\:\:-webkit-slider-thumb\]\:bg-bambu-green::-webkit-slider-thumb{background-color:var(--color-bambu-green)}}:root{--accent:#00ae42;--accent-light:#00c64d;--accent-dark:#009438;--status-ok:#22c55e;--status-error:#ef4444;--status-warning:#f59e0b;--bg-primary:#f5f5f5;--bg-secondary:#fff;--bg-tertiary:#e5e5e5;--text-primary:#1a1a1a;--text-secondary:#4a4a4a;--text-muted:#6b6b6b;--text-tertiary:gray;--border-color:#d4d4d4;--card-shadow:0 2px 8px #00000014;--glow-color:transparent;font-synthesis:none;text-rendering:optimizeLegibility;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale;font-family:Inter,system-ui,sans-serif;font-weight:400;line-height:1.5}.dark{--bg-primary:#1a1a1a;--bg-secondary:#2d2d2d;--bg-tertiary:#3d3d3d;--text-primary:#fff;--text-secondary:#a0a0a0;--text-muted:gray;--text-tertiary:#4a4a4a;--border-color:#3d3d3d;--card-shadow:0 4px 16px #0006}.bg-warm{--bg-primary:#faf8f5;--bg-secondary:#fffefa;--bg-tertiary:#e8e4dd;--text-primary:#2d2a26;--text-secondary:#5c5750;--text-muted:#7a756c;--text-tertiary:#9a9590;--border-color:#d8d4cc}.bg-cool{--bg-primary:#f0f4f8;--bg-secondary:#fff;--bg-tertiary:#dce4ec;--text-primary:#1a2530;--text-secondary:#4a5568;--text-muted:#6b7a8a;--text-tertiary:#8a9aaa;--border-color:#c8d4e0}.dark.bg-neutral{--bg-primary:#1a1a1a;--bg-secondary:#2d2d2d;--bg-tertiary:#3d3d3d;--text-primary:#fff;--text-secondary:#a0a0a0;--text-muted:gray;--text-tertiary:#4a4a4a;--border-color:#3d3d3d}.dark.bg-warm{--bg-primary:#1c1a18;--bg-secondary:#2e2a26;--bg-tertiary:#3e3a36;--text-primary:#f5f0ea;--text-secondary:#b0a898;--text-muted:#8a8278;--text-tertiary:#5a5248;--border-color:#3e3a36}.dark.bg-cool{--bg-primary:#181c20;--bg-secondary:#262c32;--bg-tertiary:#363e46;--text-primary:#f0f4f8;--text-secondary:#98a8b8;--text-muted:#788898;--text-tertiary:#4a5a6a;--border-color:#363e46}.dark.bg-oled{--bg-primary:#000;--bg-secondary:#141414;--bg-tertiary:#1f1f1f;--text-primary:#fff;--text-secondary:#a0a0a0;--text-muted:#707070;--text-tertiary:#404040;--border-color:#2a2a2a}.dark.bg-slate{--bg-primary:#0f172a;--bg-secondary:#1e293b;--bg-tertiary:#334155;--text-primary:#f1f5f9;--text-secondary:#94a3b8;--text-muted:#64748b;--text-tertiary:#475569;--border-color:#334155}.dark.bg-forest{--bg-primary:#121a16;--bg-secondary:#1c2a22;--bg-tertiary:#2a3d30;--text-primary:#e8f5ec;--text-secondary:#8aa894;--text-muted:#6a8874;--text-tertiary:#4a6854;--border-color:#2a3d30}.printer-control-buttons-container{container-type:inline-size}@container (max-width:220px){.printer-control-buttons{flex-direction:column;align-items:stretch}.printer-control-buttons>button{width:100%}}.style-glow{--card-shadow:0 2px 8px #00000014,0 0 25px var(--accent)}@supports (color:color-mix(in lab,red,red)){.style-glow{--card-shadow:0 2px 8px #00000014,0 0 25px color-mix(in srgb,var(--accent)12%,transparent)}}.dark.style-glow{--card-shadow:0 4px 20px #00000080,0 0 40px var(--accent)}@supports (color:color-mix(in lab,red,red)){.dark.style-glow{--card-shadow:0 4px 20px #00000080,0 0 40px color-mix(in srgb,var(--accent)15%,transparent)}}.style-vibrant{--card-shadow:0 8px 30px #00000026,0 2px 8px #0000001a}.dark.style-vibrant{--card-shadow:0 10px 40px #0009,0 4px 12px #0006}.accent-green{--accent:#00ae42;--accent-light:#00c64d;--accent-dark:#009438}.accent-teal{--accent:#14b8a6;--accent-light:#2dd4bf;--accent-dark:#0d9488}.accent-blue{--accent:#3b82f6;--accent-light:#60a5fa;--accent-dark:#2563eb}.accent-orange{--accent:#f97316;--accent-light:#fb923c;--accent-dark:#ea580c}.accent-purple{--accent:#8b5cf6;--accent-light:#a78bfa;--accent-dark:#7c3aed}.accent-red{--accent:#ef4444;--accent-light:#f87171;--accent-dark:#dc2626}body{background-color:var(--bg-primary);color:var(--text-primary);min-height:100vh;margin:0;transition:background-color .2s,color .2s}#root{min-height:100vh}.text-white{color:var(--text-primary)}.bg-bambu-dark,.bg-bambu-dark-secondary,.bg-bambu-dark-tertiary,.border-bambu-dark-tertiary{transition:background-color .2s,border-color .2s}@keyframes slide-in{0%{opacity:0;transform:translate(100%)}to{opacity:1;transform:translate(0)}}.animate-slide-in{animation:.2s ease-out slide-in}.icon-theme{opacity:.5}.dark .icon-theme{filter:invert();opacity:.4}.icon-green{filter:invert(48%)sepia(89%)saturate(459%)hue-rotate(93deg)brightness(95%)contrast(92%);opacity:1}.icon-heating{filter:invert(50%)sepia()saturate(1000%)hue-rotate(360deg)brightness()contrast();opacity:1}.dark .jogpad-theme{filter:brightness(.35)contrast(1.2)}.ams-empty-slot{background:repeating-linear-gradient(45deg,#444,#444 2px,#222 2px 4px)}.dark .ams-empty-slot{background:repeating-linear-gradient(45deg,#555,#555 2px,#333 2px 4px)}.touch-manipulation{touch-action:manipulation}.safe-area-bottom{padding-bottom:env(safe-area-inset-bottom,0)}.safe-area-top{padding-top:env(safe-area-inset-top,0)}.scrollbar-hide{-ms-overflow-style:none;scrollbar-width:none}.scrollbar-hide::-webkit-scrollbar{display:none}@keyframes slide-in-left{0%{transform:translate(-100%)}to{transform:translate(0)}}.animate-slide-in-left{animation:.3s ease-out slide-in-left}.card-shadow{box-shadow:var(--card-shadow)}.calendar-scroll{scrollbar-width:thin;scrollbar-color:var(--text-muted)transparent}@supports (color:color-mix(in lab,red,red)){.calendar-scroll{scrollbar-color:color-mix(in srgb,var(--text-muted)60%,transparent)transparent}}.calendar-scroll::-webkit-scrollbar{width:8px}.calendar-scroll::-webkit-scrollbar-track{background:0 0}.calendar-scroll::-webkit-scrollbar-thumb{background-color:var(--text-muted)}@supports (color:color-mix(in lab,red,red)){.calendar-scroll::-webkit-scrollbar-thumb{background-color:color-mix(in srgb,var(--text-muted)60%,transparent)}}.calendar-scroll::-webkit-scrollbar-thumb{border:2px solid var(--bg-secondary);border-radius:999px}@supports (color:color-mix(in lab,red,red)){.calendar-scroll::-webkit-scrollbar-thumb{border:2px solid color-mix(in srgb,var(--bg-secondary)70%,transparent)}}.calendar-scroll::-webkit-scrollbar-thumb:hover{background-color:var(--text-muted)}@supports (color:color-mix(in lab,red,red)){.calendar-scroll::-webkit-scrollbar-thumb:hover{background-color:color-mix(in srgb,var(--text-muted)80%,transparent)}}@property --tw-translate-x{syntax:"*";inherits:false;initial-value:0}@property --tw-translate-y{syntax:"*";inherits:false;initial-value:0}@property --tw-translate-z{syntax:"*";inherits:false;initial-value:0}@property --tw-scale-x{syntax:"*";inherits:false;initial-value:1}@property --tw-scale-y{syntax:"*";inherits:false;initial-value:1}@property --tw-scale-z{syntax:"*";inherits:false;initial-value:1}@property --tw-rotate-x{syntax:"*";inherits:false}@property --tw-rotate-y{syntax:"*";inherits:false}@property --tw-rotate-z{syntax:"*";inherits:false}@property --tw-skew-x{syntax:"*";inherits:false}@property --tw-skew-y{syntax:"*";inherits:false}@property --tw-space-y-reverse{syntax:"*";inherits:false;initial-value:0}@property --tw-divide-y-reverse{syntax:"*";inherits:false;initial-value:0}@property --tw-border-style{syntax:"*";inherits:false;initial-value:solid}@property --tw-gradient-position{syntax:"*";inherits:false}@property --tw-gradient-from{syntax:"";inherits:false;initial-value:#0000}@property --tw-gradient-via{syntax:"";inherits:false;initial-value:#0000}@property --tw-gradient-to{syntax:"";inherits:false;initial-value:#0000}@property --tw-gradient-stops{syntax:"*";inherits:false}@property --tw-gradient-via-stops{syntax:"*";inherits:false}@property --tw-gradient-from-position{syntax:"";inherits:false;initial-value:0%}@property --tw-gradient-via-position{syntax:"";inherits:false;initial-value:50%}@property --tw-gradient-to-position{syntax:"";inherits:false;initial-value:100%}@property --tw-leading{syntax:"*";inherits:false}@property --tw-font-weight{syntax:"*";inherits:false}@property --tw-tracking{syntax:"*";inherits:false}@property --tw-ordinal{syntax:"*";inherits:false}@property --tw-slashed-zero{syntax:"*";inherits:false}@property --tw-numeric-figure{syntax:"*";inherits:false}@property --tw-numeric-spacing{syntax:"*";inherits:false}@property --tw-numeric-fraction{syntax:"*";inherits:false}@property --tw-shadow{syntax:"*";inherits:false;initial-value:0 0 #0000}@property --tw-shadow-color{syntax:"*";inherits:false}@property --tw-shadow-alpha{syntax:"";inherits:false;initial-value:100%}@property --tw-inset-shadow{syntax:"*";inherits:false;initial-value:0 0 #0000}@property --tw-inset-shadow-color{syntax:"*";inherits:false}@property --tw-inset-shadow-alpha{syntax:"";inherits:false;initial-value:100%}@property --tw-ring-color{syntax:"*";inherits:false}@property --tw-ring-shadow{syntax:"*";inherits:false;initial-value:0 0 #0000}@property --tw-inset-ring-color{syntax:"*";inherits:false}@property --tw-inset-ring-shadow{syntax:"*";inherits:false;initial-value:0 0 #0000}@property --tw-ring-inset{syntax:"*";inherits:false}@property --tw-ring-offset-width{syntax:"";inherits:false;initial-value:0}@property --tw-ring-offset-color{syntax:"*";inherits:false;initial-value:#fff}@property --tw-ring-offset-shadow{syntax:"*";inherits:false;initial-value:0 0 #0000}@property --tw-outline-style{syntax:"*";inherits:false;initial-value:solid}@property --tw-blur{syntax:"*";inherits:false}@property --tw-brightness{syntax:"*";inherits:false}@property --tw-contrast{syntax:"*";inherits:false}@property --tw-grayscale{syntax:"*";inherits:false}@property --tw-hue-rotate{syntax:"*";inherits:false}@property --tw-invert{syntax:"*";inherits:false}@property --tw-opacity{syntax:"*";inherits:false}@property --tw-saturate{syntax:"*";inherits:false}@property --tw-sepia{syntax:"*";inherits:false}@property --tw-drop-shadow{syntax:"*";inherits:false}@property --tw-drop-shadow-color{syntax:"*";inherits:false}@property --tw-drop-shadow-alpha{syntax:"";inherits:false;initial-value:100%}@property --tw-drop-shadow-size{syntax:"*";inherits:false}@property --tw-backdrop-blur{syntax:"*";inherits:false}@property --tw-backdrop-brightness{syntax:"*";inherits:false}@property --tw-backdrop-contrast{syntax:"*";inherits:false}@property --tw-backdrop-grayscale{syntax:"*";inherits:false}@property --tw-backdrop-hue-rotate{syntax:"*";inherits:false}@property --tw-backdrop-invert{syntax:"*";inherits:false}@property --tw-backdrop-opacity{syntax:"*";inherits:false}@property --tw-backdrop-saturate{syntax:"*";inherits:false}@property --tw-backdrop-sepia{syntax:"*";inherits:false}@property --tw-duration{syntax:"*";inherits:false}@property --tw-ease{syntax:"*";inherits:false}@property --tw-content{syntax:"*";inherits:false;initial-value:""}@keyframes spin{to{transform:rotate(360deg)}}@keyframes pulse{50%{opacity:.5}}@layer properties{@supports (((-webkit-hyphens:none)) and (not (margin-trim:inline))) or ((-moz-orient:inline) and (not (color:rgb(from red r g b)))){*,:before,:after,::backdrop{--tw-translate-x:0;--tw-translate-y:0;--tw-translate-z:0;--tw-scale-x:1;--tw-scale-y:1;--tw-scale-z:1;--tw-rotate-x:initial;--tw-rotate-y:initial;--tw-rotate-z:initial;--tw-skew-x:initial;--tw-skew-y:initial;--tw-space-y-reverse:0;--tw-divide-y-reverse:0;--tw-border-style:solid;--tw-gradient-position:initial;--tw-gradient-from:#0000;--tw-gradient-via:#0000;--tw-gradient-to:#0000;--tw-gradient-stops:initial;--tw-gradient-via-stops:initial;--tw-gradient-from-position:0%;--tw-gradient-via-position:50%;--tw-gradient-to-position:100%;--tw-leading:initial;--tw-font-weight:initial;--tw-tracking:initial;--tw-ordinal:initial;--tw-slashed-zero:initial;--tw-numeric-figure:initial;--tw-numeric-spacing:initial;--tw-numeric-fraction:initial;--tw-shadow:0 0 #0000;--tw-shadow-color:initial;--tw-shadow-alpha:100%;--tw-inset-shadow:0 0 #0000;--tw-inset-shadow-color:initial;--tw-inset-shadow-alpha:100%;--tw-ring-color:initial;--tw-ring-shadow:0 0 #0000;--tw-inset-ring-color:initial;--tw-inset-ring-shadow:0 0 #0000;--tw-ring-inset:initial;--tw-ring-offset-width:0px;--tw-ring-offset-color:#fff;--tw-ring-offset-shadow:0 0 #0000;--tw-outline-style:solid;--tw-blur:initial;--tw-brightness:initial;--tw-contrast:initial;--tw-grayscale:initial;--tw-hue-rotate:initial;--tw-invert:initial;--tw-opacity:initial;--tw-saturate:initial;--tw-sepia:initial;--tw-drop-shadow:initial;--tw-drop-shadow-color:initial;--tw-drop-shadow-alpha:100%;--tw-drop-shadow-size:initial;--tw-backdrop-blur:initial;--tw-backdrop-brightness:initial;--tw-backdrop-contrast:initial;--tw-backdrop-grayscale:initial;--tw-backdrop-hue-rotate:initial;--tw-backdrop-invert:initial;--tw-backdrop-opacity:initial;--tw-backdrop-saturate:initial;--tw-backdrop-sepia:initial;--tw-duration:initial;--tw-ease:initial;--tw-content:""}}} diff --git a/static/index.html b/static/index.html index 7fc12a5e7..30c7ddc05 100644 --- a/static/index.html +++ b/static/index.html @@ -23,8 +23,8 @@ - - + +
From a903816b8a296c93e22ce2c5919e5ad8568dbfcb Mon Sep 17 00:00:00 2001 From: maziggy Date: Wed, 18 Feb 2026 16:37:35 +0100 Subject: [PATCH 7/8] fix(slicer): token-based auth for Open in Slicer downloads (#433) Slicer protocol handlers (bambustudio://, orcaslicer://) launch the slicer app which fetches files via HTTP but cannot send auth headers. The global auth middleware returned 401, causing "importing failed." Add short-lived, single-use download tokens: the frontend fetches a token via authenticated POST, then builds a /dl/{token}/{filename} URL the slicer can access without auth headers. Tokens are validated server-side (5-min expiry, single-use). Applies to archive files, source 3MFs, and library files. Also fix platform-specific URL formats to match slicer source code: - macOS: bambustudioopen:// with encodeURIComponent - Windows/Linux: bambustudio://open?file= (was wrongly using macOS scheme on Linux) - OrcaSlicer: orcaslicer://open?file= --- CHANGELOG.md | 1 + backend/app/api/routes/archives.py | 116 ++- backend/app/api/routes/library.py | 56 ++ backend/app/core/auth.py | 37 + backend/app/main.py | 4 + frontend/src/api/client.ts | 12 + frontend/src/components/ModelViewerModal.tsx | 28 +- frontend/src/pages/ArchivesPage.tsx | 54 +- frontend/src/utils/slicer.ts | 40 +- .../{index-BLcYYvbZ.js => index-BPE9r2Ne.js} | 828 +++++++++--------- static/index.html | 2 +- 11 files changed, 727 insertions(+), 451 deletions(-) rename static/assets/{index-BLcYYvbZ.js => index-BPE9r2Ne.js} (67%) diff --git a/CHANGELOG.md b/CHANGELOG.md index c5b0a0578..456c3b283 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -20,6 +20,7 @@ All notable changes to Bambuddy will be documented in this file. - **Usage Tracking Wrong Spool on Dual-Nozzle / Multi-AMS Printers** ([#364](https://github.com/maziggy/bambuddy/issues/364)) — On H2C, H2D Pro, and other dual-nozzle printers with multiple AMS units, the usage tracker attributed filament consumption to the wrong spools. The MQTT `mapping` field — a per-print array that maps slicer filament slots to physical AMS trays — was preserved in state but never parsed or used. The tracker fell back to `slot_id - 1` as the global tray ID, which is incorrect when AMS hardware IDs differ from sequential indices (e.g., AMS-HT units with ID 128). Now decodes the MQTT mapping field from its snow encoding (`ams_hw_id * 256 + local_slot`) into bambuddy global tray IDs and uses it as a universal mapping source — working for all printer models and all print sources (slicer, queue, reprint) without relying on `tray_now` disambiguation. - **npm audit: suppress moderate ajv ReDoS finding** — Added `audit-level=high` to `frontend/.npmrc` so `npm audit` exits cleanly. The ajv@6 ReDoS (GHSA-2g4f-4pwh-qvx6) is a transitive dependency of eslint@9 with no patched v6 release; ajv@8 override breaks eslint. The vulnerability requires crafted `$data` schema input — not an attack vector in a linting config. - **Spool Form Allows Empty Brand & Subtype** ([#417](https://github.com/maziggy/bambuddy/issues/417)) — The spool add/edit modal did not require Brand or Subtype fields, allowing spools to be saved without them. When such a spool was assigned to an AMS slot, the `tray_sub_brands` sent to the printer was incomplete (e.g., just "PETG" instead of "PETG Basic"), causing BambuStudio to not recognize the filament profile. Brand and Subtype are now mandatory fields with validation errors shown on submit. +- **Open in Slicer Fails When Authentication Enabled** ([#433](https://github.com/maziggy/bambuddy/issues/433)) — The "Open in Slicer" buttons for BambuStudio and OrcaSlicer failed with "importing failed" when authentication was enabled. Slicer protocol handlers (`bambustudio://`, `orcaslicer://`) launch the slicer app which fetches the file via HTTP — but cannot send authentication headers, so the global auth middleware returned 401. Additionally, the URL format was wrong on Linux (used the macOS-only `bambustudioopen://` scheme instead of `bambustudio://open?file=`). Fixed with short-lived, single-use download tokens: the frontend fetches a token via an authenticated POST endpoint, then builds a `/dl/{token}/{filename}` URL that the slicer can access without auth headers. The token is validated server-side (5-minute expiry, single-use). Platform-specific URL formats now match the actual slicer source code: macOS uses `bambustudioopen://` with URL encoding, Windows/Linux use `bambustudio://open?file=`, and OrcaSlicer uses `orcaslicer://open?file=`. ### Changed - **Filament Catalog API Renamed** ([#427](https://github.com/maziggy/bambuddy/issues/427)) — Renamed `/api/v1/filaments/` to `/api/v1/filament-catalog/` to avoid confusion with the inventory spools page (labeled "Filament" in the UI). The old endpoint managed material type definitions (cost, temperature, density), not physical spools — the shared name caused users to expect the API to return their spool inventory. diff --git a/backend/app/api/routes/archives.py b/backend/app/api/routes/archives.py index e1094b93c..4cf82d67d 100644 --- a/backend/app/api/routes/archives.py +++ b/backend/app/api/routes/archives.py @@ -1074,7 +1074,63 @@ async def download_archive_with_filename( db: AsyncSession = Depends(get_db), _: User | None = RequirePermissionIfAuthEnabled(Permission.ARCHIVES_READ), ): - """Download the 3MF file with filename in URL (for Bambu Studio protocol).""" + """Download the 3MF file with filename in URL.""" + service = ArchiveService(db) + archive = await service.get_archive(archive_id) + if not archive: + raise HTTPException(404, "Archive not found") + + file_path = settings.base_dir / archive.file_path + if not file_path.exists(): + raise HTTPException(404, "File not found") + + return FileResponse( + path=file_path, + filename=archive.filename, + media_type="application/vnd.ms-package.3dmanufacturing-3dmodel+xml", + ) + + +@router.post("/{archive_id}/slicer-token") +async def create_archive_slicer_token( + archive_id: int, + db: AsyncSession = Depends(get_db), + _: User | None = RequirePermissionIfAuthEnabled(Permission.ARCHIVES_READ), +): + """Create a short-lived download token for opening files in slicer applications. + + Slicer protocol handlers (bambustudioopen://, orcaslicer://) cannot send + auth headers, so they use this token in the URL path instead. + """ + from backend.app.core.auth import create_slicer_download_token + + service = ArchiveService(db) + archive = await service.get_archive(archive_id) + if not archive: + raise HTTPException(404, "Archive not found") + + token = create_slicer_download_token("archive", archive_id) + return {"token": token} + + +@router.get("/{archive_id}/dl/{token}/{filename}") +async def download_archive_for_slicer( + archive_id: int, + token: str, + filename: str, + db: AsyncSession = Depends(get_db), +): + """Download 3MF file using a slicer download token. + + Token-authenticated (no auth headers needed). The token is short-lived + and single-use, created by POST /{archive_id}/slicer-token. + Filename is at the end of the URL so slicers can detect the file format. + """ + from backend.app.core.auth import verify_slicer_download_token + + if not verify_slicer_download_token(token, "archive", archive_id): + raise HTTPException(403, "Invalid or expired download token") + service = ArchiveService(db) archive = await service.get_archive(archive_id) if not archive: @@ -3093,7 +3149,63 @@ async def download_source_3mf_for_slicer( db: AsyncSession = Depends(get_db), _: User | None = RequirePermissionIfAuthEnabled(Permission.ARCHIVES_READ), ): - """Download source 3MF with filename in URL (for Bambu Studio compatibility).""" + """Download source 3MF with filename in URL.""" + result = await db.execute(select(PrintArchive).where(PrintArchive.id == archive_id)) + archive = result.scalar_one_or_none() + if not archive: + raise HTTPException(404, "Archive not found") + + if not archive.source_3mf_path: + raise HTTPException(404, "No source 3MF attached to this archive") + + source_path = settings.base_dir / archive.source_3mf_path + if not source_path.exists(): + raise HTTPException(404, "Source 3MF file not found on disk") + + return FileResponse( + path=source_path, + filename=filename if filename.endswith(".3mf") else f"{filename}.3mf", + media_type="application/vnd.ms-package.3dmanufacturing-3dmodel+xml", + ) + + +@router.post("/{archive_id}/source-slicer-token") +async def create_source_slicer_token( + archive_id: int, + db: AsyncSession = Depends(get_db), + _: User | None = RequirePermissionIfAuthEnabled(Permission.ARCHIVES_READ), +): + """Create a short-lived download token for opening source 3MF in slicer.""" + from backend.app.core.auth import create_slicer_download_token + + result = await db.execute(select(PrintArchive).where(PrintArchive.id == archive_id)) + archive = result.scalar_one_or_none() + if not archive: + raise HTTPException(404, "Archive not found") + if not archive.source_3mf_path: + raise HTTPException(404, "No source 3MF attached to this archive") + + token = create_slicer_download_token("source", archive_id) + return {"token": token} + + +@router.get("/{archive_id}/source-dl/{token}/{filename}") +async def download_source_3mf_for_slicer_with_token( + archive_id: int, + token: str, + filename: str, + db: AsyncSession = Depends(get_db), +): + """Download source 3MF using a slicer download token. + + Token-authenticated (no auth headers needed). The token is short-lived + and single-use, created by POST /{archive_id}/source-slicer-token. + """ + from backend.app.core.auth import verify_slicer_download_token + + if not verify_slicer_download_token(token, "source", archive_id): + raise HTTPException(403, "Invalid or expired download token") + result = await db.execute(select(PrintArchive).where(PrintArchive.id == archive_id)) archive = result.scalar_one_or_none() if not archive: diff --git a/backend/app/api/routes/library.py b/backend/app/api/routes/library.py index 11222d22a..dac910fcc 100644 --- a/backend/app/api/routes/library.py +++ b/backend/app/api/routes/library.py @@ -2138,6 +2138,62 @@ async def download_file( ) +@router.post("/files/{file_id}/slicer-token") +async def create_library_slicer_token( + file_id: int, + db: AsyncSession = Depends(get_db), + _: User | None = Depends(require_permission_if_auth_enabled(Permission.LIBRARY_READ)), +): + """Create a short-lived download token for opening files in slicer applications. + + Slicer protocol handlers (bambustudioopen://, orcaslicer://) cannot send + auth headers, so they use this token in the URL path instead. + """ + from backend.app.core.auth import create_slicer_download_token + + result = await db.execute(select(LibraryFile).where(LibraryFile.id == file_id)) + file = result.scalar_one_or_none() + if not file: + raise HTTPException(status_code=404, detail="File not found") + + token = create_slicer_download_token("library", file_id) + return {"token": token} + + +@router.get("/files/{file_id}/dl/{token}/{filename}") +async def download_library_file_for_slicer( + file_id: int, + token: str, + filename: str, + db: AsyncSession = Depends(get_db), +): + """Download a library file using a slicer download token. + + Token-authenticated (no auth headers needed). The token is short-lived + and single-use, created by POST /files/{file_id}/slicer-token. + Filename is at the end of the URL so slicers can detect the file format. + """ + from backend.app.core.auth import verify_slicer_download_token + + if not verify_slicer_download_token(token, "library", file_id): + raise HTTPException(status_code=403, detail="Invalid or expired download token") + + result = await db.execute(select(LibraryFile).where(LibraryFile.id == file_id)) + file = result.scalar_one_or_none() + if not file: + raise HTTPException(status_code=404, detail="File not found") + + abs_path = to_absolute_path(file.file_path) + if not abs_path or not abs_path.exists(): + raise HTTPException(status_code=404, detail="File not found on disk") + + return FastAPIFileResponse( + str(abs_path), + filename=file.filename, + media_type="application/octet-stream", + ) + + @router.get("/files/{file_id}/thumbnail") async def get_thumbnail(file_id: int, db: AsyncSession = Depends(get_db)): """Get a file's thumbnail.""" diff --git a/backend/app/core/auth.py b/backend/app/core/auth.py index 0f1d546a0..a24323b14 100644 --- a/backend/app/core/auth.py +++ b/backend/app/core/auth.py @@ -98,6 +98,43 @@ ACCESS_TOKEN_EXPIRE_MINUTES = 60 * 24 * 7 # 7 days # HTTP Bearer token security = HTTPBearer(auto_error=False) +# --- Slicer download tokens --- +# Short-lived tokens for slicer protocol handlers that can't send auth headers. +# Maps token → (resource_key, expiry). resource_key = "archive:{id}" or "library:{id}". +_slicer_tokens: dict[str, tuple[str, datetime]] = {} +SLICER_TOKEN_EXPIRE_MINUTES = 5 + + +def create_slicer_download_token(resource_type: str, resource_id: int) -> str: + """Create a short-lived download token for slicer protocol handlers.""" + # Cleanup expired tokens + now = datetime.utcnow() + expired = [k for k, (_, exp) in _slicer_tokens.items() if exp < now] + for k in expired: + del _slicer_tokens[k] + + token = secrets.token_urlsafe(24) + resource_key = f"{resource_type}:{resource_id}" + _slicer_tokens[token] = (resource_key, now + timedelta(minutes=SLICER_TOKEN_EXPIRE_MINUTES)) + return token + + +def verify_slicer_download_token(token: str, resource_type: str, resource_id: int) -> bool: + """Verify a slicer download token is valid for the given resource.""" + entry = _slicer_tokens.get(token) + if not entry: + return False + resource_key, expiry = entry + if datetime.utcnow() > expiry: + del _slicer_tokens[token] + return False + expected_key = f"{resource_type}:{resource_id}" + if resource_key != expected_key: + return False + # Token is single-use + del _slicer_tokens[token] + return True + def verify_password(plain_password: str, hashed_password: str) -> bool: """Verify a password against a hash. diff --git a/backend/app/main.py b/backend/app/main.py index 9e395ec87..01513f860 100644 --- a/backend/app/main.py +++ b/backend/app/main.py @@ -3356,6 +3356,10 @@ PUBLIC_API_PATTERNS = [ # Camera (streams loaded via tag) "/camera/stream", # /printers/{id}/camera/stream "/camera/snapshot", # /printers/{id}/camera/snapshot + # Slicer token-authenticated downloads — protocol handlers (bambustudioopen://, + # orcaslicer://) cannot send auth headers. These endpoints validate a short-lived + # download token in the URL path instead. + "/dl/", # /archives/{id}/dl/{token}/{filename}, /library/files/{id}/dl/{token}/{filename} ] diff --git a/frontend/src/api/client.ts b/frontend/src/api/client.ts index 9c95a260a..18f4526a1 100644 --- a/frontend/src/api/client.ts +++ b/frontend/src/api/client.ts @@ -2786,6 +2786,10 @@ export const api = { }, getSource3mfForSlicer: (archiveId: number, filename: string) => `${API_BASE}/archives/${archiveId}/source/${encodeURIComponent(filename.endsWith('.3mf') ? filename : filename + '.3mf')}`, + createSourceSlicerToken: (archiveId: number) => + request<{ token: string }>(`/archives/${archiveId}/source-slicer-token`, { method: 'POST' }), + getSourceSlicerDownloadUrl: (archiveId: number, token: string, filename: string) => + `${API_BASE}/archives/${archiveId}/source-dl/${token}/${encodeURIComponent(filename.endsWith('.3mf') ? filename : filename + '.3mf')}`, uploadSource3mf: async (archiveId: number, file: File): Promise<{ status: string; filename: string }> => { const formData = new FormData(); formData.append('file', file); @@ -2908,6 +2912,10 @@ export const api = { `${API_BASE}/archives/${archiveId}/project-image/${encodeURIComponent(imagePath)}`, getArchiveForSlicer: (id: number, filename: string) => `${API_BASE}/archives/${id}/file/${encodeURIComponent(filename.endsWith('.3mf') ? filename : filename + '.3mf')}`, + createArchiveSlicerToken: (archiveId: number) => + request<{ token: string }>(`/archives/${archiveId}/slicer-token`, { method: 'POST' }), + getArchiveSlicerDownloadUrl: (archiveId: number, token: string, filename: string) => + `${API_BASE}/archives/${archiveId}/dl/${token}/${encodeURIComponent(filename.endsWith('.3mf') ? filename : filename + '.3mf')}`, getArchivePlates: (archiveId: number) => request(`/archives/${archiveId}/plates`), getArchiveFilamentRequirements: (archiveId: number, plateId?: number) => @@ -3938,6 +3946,10 @@ export const api = { deleteLibraryFile: (id: number) => request<{ status: string; message: string }>(`/library/files/${id}`, { method: 'DELETE' }), getLibraryFileDownloadUrl: (id: number) => `${API_BASE}/library/files/${id}/download`, + createLibrarySlicerToken: (fileId: number) => + request<{ token: string }>(`/library/files/${fileId}/slicer-token`, { method: 'POST' }), + getLibrarySlicerDownloadUrl: (fileId: number, token: string, filename: string) => + `${API_BASE}/library/files/${fileId}/dl/${token}/${encodeURIComponent(filename)}`, downloadLibraryFile: async (id: number, filename?: string): Promise => { const headers: Record = {}; if (authToken) { diff --git a/frontend/src/components/ModelViewerModal.tsx b/frontend/src/components/ModelViewerModal.tsx index 29968331f..95af1a41b 100644 --- a/frontend/src/components/ModelViewerModal.tsx +++ b/frontend/src/components/ModelViewerModal.tsx @@ -263,17 +263,29 @@ export function ModelViewerModal({ archiveId, libraryFileId, title, fileType, on const canOpenInSlicer = isLibrary ? (fileType || '').toLowerCase() === '3mf' : true; - const handleOpenInSlicer = () => { + const handleOpenInSlicer = async () => { if (!canOpenInSlicer) return; - // URL must include .3mf filename for Bambu Studio to recognize the format const filename = title || 'model'; - if (isLibrary) { - const downloadUrl = `${window.location.origin}${api.getLibraryFileDownloadUrl(libraryFileId!)}`; - openInSlicer(downloadUrl, preferredSlicer); - return; + try { + if (isLibrary) { + const { token } = await api.createLibrarySlicerToken(libraryFileId!); + const path = api.getLibrarySlicerDownloadUrl(libraryFileId!, token, filename); + openInSlicer(`${window.location.origin}${path}`, preferredSlicer); + } else { + const { token } = await api.createArchiveSlicerToken(archiveId!); + const path = api.getArchiveSlicerDownloadUrl(archiveId!, token, filename); + openInSlicer(`${window.location.origin}${path}`, preferredSlicer); + } + } catch { + // Fallback to direct URL (works when auth is disabled) + if (isLibrary) { + const downloadUrl = `${window.location.origin}${api.getLibraryFileDownloadUrl(libraryFileId!)}`; + openInSlicer(downloadUrl, preferredSlicer); + } else { + const downloadUrl = `${window.location.origin}${api.getArchiveForSlicer(archiveId!, filename)}`; + openInSlicer(downloadUrl, preferredSlicer); + } } - const downloadUrl = `${window.location.origin}${api.getArchiveForSlicer(archiveId!, filename)}`; - openInSlicer(downloadUrl, preferredSlicer); }; return ( diff --git a/frontend/src/pages/ArchivesPage.tsx b/frontend/src/pages/ArchivesPage.tsx index 661720c67..6f2b59d9c 100644 --- a/frontend/src/pages/ArchivesPage.tsx +++ b/frontend/src/pages/ArchivesPage.tsx @@ -105,6 +105,36 @@ function getArchiveFileType(filename: string | null | undefined): string | undef // formatDate imported from '../utils/date' - handles UTC conversion +/** + * Open an archive file in the slicer. + * Fetches a short-lived download token, then builds a token-authenticated URL + * that bypasses auth middleware (slicer protocol handlers can't send auth headers). + */ +async function openInSlicerWithToken( + archiveId: number, + filename: string, + resourceType: 'file' | 'source', + slicer: SlicerType, +): Promise { + try { + if (resourceType === 'source') { + const { token } = await api.createSourceSlicerToken(archiveId); + const path = api.getSourceSlicerDownloadUrl(archiveId, token, filename); + openInSlicer(`${window.location.origin}${path}`, slicer); + } else { + const { token } = await api.createArchiveSlicerToken(archiveId); + const path = api.getArchiveSlicerDownloadUrl(archiveId, token, filename); + openInSlicer(`${window.location.origin}${path}`, slicer); + } + } catch { + // Fallback to direct URL (works when auth is disabled) + const path = resourceType === 'source' + ? api.getSource3mfForSlicer(archiveId, filename) + : api.getArchiveForSlicer(archiveId, filename); + openInSlicer(`${window.location.origin}${path}`, slicer); + } +} + function ArchiveCard({ archive, printerName, @@ -337,8 +367,7 @@ function ArchiveCard({ icon: , onClick: () => { const filename = archive.print_name || archive.filename || 'model'; - const downloadUrl = `${window.location.origin}${api.getArchiveForSlicer(archive.id, filename)}`; - openInSlicer(downloadUrl, preferredSlicer); + openInSlicerWithToken(archive.id, filename, 'file', preferredSlicer); }, disabled: !archive.file_path, title: !archive.file_path ? t('archives.card.noFileForReprint') : undefined, @@ -349,8 +378,7 @@ function ArchiveCard({ icon: , onClick: () => { const filename = archive.print_name || archive.filename || 'model'; - const downloadUrl = `${window.location.origin}${api.getArchiveForSlicer(archive.id, filename)}`; - openInSlicer(downloadUrl, preferredSlicer); + openInSlicerWithToken(archive.id, filename, 'file', preferredSlicer); }, }, ]), @@ -738,8 +766,7 @@ function ArchiveCard({ e.stopPropagation(); // Open source 3MF in Bambu Studio - use filename in URL for slicer compatibility const sourceName = (archive.print_name || archive.filename || 'source').replace(/\.gcode\.3mf$/i, '') + '_source'; - const downloadUrl = `${window.location.origin}${api.getSource3mfForSlicer(archive.id, sourceName)}`; - openInSlicer(downloadUrl, preferredSlicer); + openInSlicerWithToken(archive.id, sourceName, 'source', preferredSlicer); }} title={t('archives.card.openSource3mf')} > @@ -1008,8 +1035,7 @@ function ArchiveCard({ className="min-w-0 p-1 sm:p-1.5" onClick={() => { const filename = archive.print_name || archive.filename || 'model'; - const downloadUrl = `${window.location.origin}${api.getArchiveForSlicer(archive.id, filename)}`; - openInSlicer(downloadUrl, preferredSlicer); + openInSlicerWithToken(archive.id, filename, 'file', preferredSlicer); }} title={t('archives.card.openInBambuStudio')} > @@ -1024,8 +1050,7 @@ function ArchiveCard({ className="flex-1 min-w-0" onClick={() => { const filename = archive.print_name || archive.filename || 'model'; - const downloadUrl = `${window.location.origin}${api.getArchiveForSlicer(archive.id, filename)}`; - openInSlicer(downloadUrl, preferredSlicer); + openInSlicerWithToken(archive.id, filename, 'file', preferredSlicer); }} title={t('archives.card.openInBambuStudioToSlice')} > @@ -1546,8 +1571,7 @@ function ArchiveListRow({ icon: , onClick: () => { const filename = archive.print_name || archive.filename || 'model'; - const downloadUrl = `${window.location.origin}${api.getArchiveForSlicer(archive.id, filename)}`; - openInSlicer(downloadUrl, preferredSlicer); + openInSlicerWithToken(archive.id, filename, 'file', preferredSlicer); }, disabled: !archive.file_path, title: !archive.file_path ? t('archives.card.noFileForReprint') : undefined, @@ -1558,8 +1582,7 @@ function ArchiveListRow({ icon: , onClick: () => { const filename = archive.print_name || archive.filename || 'model'; - const downloadUrl = `${window.location.origin}${api.getArchiveForSlicer(archive.id, filename)}`; - openInSlicer(downloadUrl, preferredSlicer); + openInSlicerWithToken(archive.id, filename, 'file', preferredSlicer); }, }, ]), @@ -1900,8 +1923,7 @@ function ArchiveListRow({ size="sm" onClick={() => { const filename = archive.print_name || archive.filename || 'model'; - const downloadUrl = `${window.location.origin}${api.getArchiveForSlicer(archive.id, filename)}`; - openInSlicer(downloadUrl, preferredSlicer); + openInSlicerWithToken(archive.id, filename, 'file', preferredSlicer); }} title={t('archives.card.openInBambuStudio')} > diff --git a/frontend/src/utils/slicer.ts b/frontend/src/utils/slicer.ts index b6f376fcc..c2f21ebb5 100644 --- a/frontend/src/utils/slicer.ts +++ b/frontend/src/utils/slicer.ts @@ -1,12 +1,23 @@ /** * Utility for opening files in slicer applications * - * Bambu Studio URL protocol is OS-specific: - * - Windows: bambustudio:// - * - macOS/Linux: bambustudioopen:// + * Protocol handler URL formats (from BambuStudio/OrcaSlicer source code): * - * OrcaSlicer uses the same protocol on all platforms: - * - orcaslicer://open?file= + * Bambu Studio has TWO separate URL handlers: + * 1. post_init() [Windows/Linux CLI args]: bambustudio://open?file= + * - Checks: starts_with("bambustudio://open") + * - Calls url_decode(), then split_str(url, "file=") + * 2. MacOpenURL() [macOS Apple Events]: bambustudioopen:// + * - Checks: starts_with("bambustudioopen://") + * - Strips prefix, then url_decode() + * + * OrcaSlicer Downloader accepts both formats via regex: + * - (orcaslicer|bambustudio|...)://open?file= + * - bambustudioopen:// + * + * Key insight: Using ?file= query format, the browser's URL parser preserves + * http:// in the query string without any encoding. Only the macOS-specific + * bambustudioopen:// format needs encodeURIComponent (BS calls url_decode). */ export type SlicerType = 'bambu_studio' | 'orcaslicer'; @@ -34,8 +45,6 @@ export function detectPlatform(): Platform { /** * Open a URL in the specified slicer application. - * Uses a temporary link element to trigger the protocol handler, - * which avoids browser "unknown protocol" blocks on window.location.href. * @param downloadUrl - The URL to the file to open * @param slicer - Which slicer to use (defaults to bambu_studio) */ @@ -43,15 +52,26 @@ export function openInSlicer(downloadUrl: string, slicer: SlicerType = 'bambu_st let url: string; if (slicer === 'orcaslicer') { + // OrcaSlicer: ?file= query format — http:// preserved in query string url = `orcaslicer://open?file=${downloadUrl}`; } else { const platform = detectPlatform(); - const protocol = platform === 'windows' ? 'bambustudio' : 'bambustudioopen'; - url = `${protocol}://${encodeURIComponent(downloadUrl)}`; + if (platform === 'macos') { + // macOS only: bambustudioopen scheme via MacOpenURL() callback. + // Must encode because bare http:// in authority gets mangled by browser. + // BS calls url_decode() after stripping "bambustudioopen://" prefix. + url = `bambustudioopen://${encodeURIComponent(downloadUrl)}`; + } else { + // Windows/Linux: bambustudio://open?file= via post_init() CLI args. + // The ?file= query format preserves http:// without encoding. + // IMPORTANT: On Linux, BS only handles "bambustudio://open" prefix — + // it does NOT process "bambustudioopen://" (that's macOS-only). + url = `bambustudio://open?file=${downloadUrl}`; + } } // Use a temporary element to trigger the protocol handler. - // This works more reliably than window.location.href for custom protocols. + // This avoids navigating away from the page (unlike window.location.href). const link = document.createElement('a'); link.href = url; link.style.display = 'none'; diff --git a/static/assets/index-BLcYYvbZ.js b/static/assets/index-BPE9r2Ne.js similarity index 67% rename from static/assets/index-BLcYYvbZ.js rename to static/assets/index-BPE9r2Ne.js index b6f3945b1..669cc55f9 100644 --- a/static/assets/index-BLcYYvbZ.js +++ b/static/assets/index-BPE9r2Ne.js @@ -1,18 +1,18 @@ -function Doe(t,e){for(var n=0;nr[i]})}}}return Object.freeze(Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}))}(function(){const e=document.createElement("link").relList;if(e&&e.supports&&e.supports("modulepreload"))return;for(const i of document.querySelectorAll('link[rel="modulepreload"]'))r(i);new MutationObserver(i=>{for(const s of i)if(s.type==="childList")for(const o of s.addedNodes)o.tagName==="LINK"&&o.rel==="modulepreload"&&r(o)}).observe(document,{childList:!0,subtree:!0});function n(i){const s={};return i.integrity&&(s.integrity=i.integrity),i.referrerPolicy&&(s.referrerPolicy=i.referrerPolicy),i.crossOrigin==="use-credentials"?s.credentials="include":i.crossOrigin==="anonymous"?s.credentials="omit":s.credentials="same-origin",s}function r(i){if(i.ep)return;i.ep=!0;const s=n(i);fetch(i.href,s)}})();var l_=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function ec(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var zT={exports:{}},ry={};var GU;function Roe(){if(GU)return ry;GU=1;var t=Symbol.for("react.transitional.element"),e=Symbol.for("react.fragment");function n(r,i,s){var o=null;if(s!==void 0&&(o=""+s),i.key!==void 0&&(o=""+i.key),"key"in i){s={};for(var l in i)l!=="key"&&(s[l]=i[l])}else s=i;return i=s.ref,{$$typeof:t,type:r,key:o,ref:i!==void 0?i:null,props:s}}return ry.Fragment=e,ry.jsx=n,ry.jsxs=n,ry}var qU;function Foe(){return qU||(qU=1,zT.exports=Roe()),zT.exports}var a=Foe(),UT={exports:{}},kn={};var WU;function Loe(){if(WU)return kn;WU=1;var t=Symbol.for("react.transitional.element"),e=Symbol.for("react.portal"),n=Symbol.for("react.fragment"),r=Symbol.for("react.strict_mode"),i=Symbol.for("react.profiler"),s=Symbol.for("react.consumer"),o=Symbol.for("react.context"),l=Symbol.for("react.forward_ref"),c=Symbol.for("react.suspense"),u=Symbol.for("react.memo"),d=Symbol.for("react.lazy"),h=Symbol.for("react.activity"),f=Symbol.iterator;function p($){return $===null||typeof $!="object"?null:($=f&&$[f]||$["@@iterator"],typeof $=="function"?$:null)}var x={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},y=Object.assign,b={};function v($,X,ee){this.props=$,this.context=X,this.refs=b,this.updater=ee||x}v.prototype.isReactComponent={},v.prototype.setState=function($,X){if(typeof $!="object"&&typeof $!="function"&&$!=null)throw Error("takes an object of state variables to update or a function which returns an object of state variables.");this.updater.enqueueSetState(this,$,X,"setState")},v.prototype.forceUpdate=function($){this.updater.enqueueForceUpdate(this,$,"forceUpdate")};function S(){}S.prototype=v.prototype;function N($,X,ee){this.props=$,this.context=X,this.refs=b,this.updater=ee||x}var A=N.prototype=new S;A.constructor=N,y(A,v.prototype),A.isPureReactComponent=!0;var C=Array.isArray;function T(){}var k={H:null,A:null,T:null,S:null},j=Object.prototype.hasOwnProperty;function E($,X,ee){var J=ee.ref;return{$$typeof:t,type:$,key:X,ref:J!==void 0?J:null,props:ee}}function P($,X){return E($.type,X,$.props)}function U($){return typeof $=="object"&&$!==null&&$.$$typeof===t}function O($){var X={"=":"=0",":":"=2"};return"$"+$.replace(/[=:]/g,function(ee){return X[ee]})}var B=/\/+/g;function R($,X){return typeof $=="object"&&$!==null&&$.key!=null?O(""+$.key):X.toString(36)}function G($){switch($.status){case"fulfilled":return $.value;case"rejected":throw $.reason;default:switch(typeof $.status=="string"?$.then(T,T):($.status="pending",$.then(function(X){$.status==="pending"&&($.status="fulfilled",$.value=X)},function(X){$.status==="pending"&&($.status="rejected",$.reason=X)})),$.status){case"fulfilled":return $.value;case"rejected":throw $.reason}}throw $}function q($,X,ee,J,_e){var pe=typeof $;(pe==="undefined"||pe==="boolean")&&($=null);var me=!1;if($===null)me=!0;else switch(pe){case"bigint":case"string":case"number":me=!0;break;case"object":switch($.$$typeof){case t:case e:me=!0;break;case d:return me=$._init,q(me($._payload),X,ee,J,_e)}}if(me)return _e=_e($),me=J===""?"."+R($,0):J,C(_e)?(ee="",me!=null&&(ee=me.replace(B,"$&/")+"/"),q(_e,X,ee,"",function(ce){return ce})):_e!=null&&(U(_e)&&(_e=P(_e,ee+(_e.key==null||$&&$.key===_e.key?"":(""+_e.key).replace(B,"$&/")+"/")+me)),X.push(_e)),1;me=0;var je=J===""?".":J+":";if(C($))for(var de=0;de<$.length;de++)J=$[de],pe=je+R(J,de),me+=q(J,X,ee,pe,_e);else if(de=p($),typeof de=="function")for($=de.call($),de=0;!(J=$.next()).done;)J=J.value,pe=je+R(J,de++),me+=q(J,X,ee,pe,_e);else if(pe==="object"){if(typeof $.then=="function")return q(G($),X,ee,J,_e);throw X=String($),Error("Objects are not valid as a React child (found: "+(X==="[object Object]"?"object with keys {"+Object.keys($).join(", ")+"}":X)+"). If you meant to render a collection of children, use an array instead.")}return me}function z($,X,ee){if($==null)return $;var J=[],_e=0;return q($,J,"","",function(pe){return X.call(ee,pe,_e++)}),J}function K($){if($._status===-1){var X=$._result;X=X(),X.then(function(ee){($._status===0||$._status===-1)&&($._status=1,$._result=ee)},function(ee){($._status===0||$._status===-1)&&($._status=2,$._result=ee)}),$._status===-1&&($._status=0,$._result=X)}if($._status===1)return $._result.default;throw $._result}var Y=typeof reportError=="function"?reportError:function($){if(typeof window=="object"&&typeof window.ErrorEvent=="function"){var X=new window.ErrorEvent("error",{bubbles:!0,cancelable:!0,message:typeof $=="object"&&$!==null&&typeof $.message=="string"?String($.message):String($),error:$});if(!window.dispatchEvent(X))return}else if(typeof process=="object"&&typeof process.emit=="function"){process.emit("uncaughtException",$);return}console.error($)},oe={map:z,forEach:function($,X,ee){z($,function(){X.apply(this,arguments)},ee)},count:function($){var X=0;return z($,function(){X++}),X},toArray:function($){return z($,function(X){return X})||[]},only:function($){if(!U($))throw Error("React.Children.only expected to receive a single React element child.");return $}};return kn.Activity=h,kn.Children=oe,kn.Component=v,kn.Fragment=n,kn.Profiler=i,kn.PureComponent=N,kn.StrictMode=r,kn.Suspense=c,kn.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=k,kn.__COMPILER_RUNTIME={__proto__:null,c:function($){return k.H.useMemoCache($)}},kn.cache=function($){return function(){return $.apply(null,arguments)}},kn.cacheSignal=function(){return null},kn.cloneElement=function($,X,ee){if($==null)throw Error("The argument must be a React element, but you passed "+$+".");var J=y({},$.props),_e=$.key;if(X!=null)for(pe in X.key!==void 0&&(_e=""+X.key),X)!j.call(X,pe)||pe==="key"||pe==="__self"||pe==="__source"||pe==="ref"&&X.ref===void 0||(J[pe]=X[pe]);var pe=arguments.length-2;if(pe===1)J.children=ee;else if(1>>1,oe=q[Y];if(0>>1;Y<$;){var X=2*(Y+1)-1,ee=q[X],J=X+1,_e=q[J];if(0>i(ee,K))Ji(_e,ee)?(q[Y]=_e,q[J]=K,Y=J):(q[Y]=ee,q[X]=K,Y=X);else if(Ji(_e,K))q[Y]=_e,q[J]=K,Y=J;else break e}}return z}function i(q,z){var K=q.sortIndex-z.sortIndex;return K!==0?K:q.id-z.id}if(t.unstable_now=void 0,typeof performance=="object"&&typeof performance.now=="function"){var s=performance;t.unstable_now=function(){return s.now()}}else{var o=Date,l=o.now();t.unstable_now=function(){return o.now()-l}}var c=[],u=[],d=1,h=null,f=3,p=!1,x=!1,y=!1,b=!1,v=typeof setTimeout=="function"?setTimeout:null,S=typeof clearTimeout=="function"?clearTimeout:null,N=typeof setImmediate<"u"?setImmediate:null;function A(q){for(var z=n(u);z!==null;){if(z.callback===null)r(u);else if(z.startTime<=q)r(u),z.sortIndex=z.expirationTime,e(c,z);else break;z=n(u)}}function C(q){if(y=!1,A(q),!x)if(n(c)!==null)x=!0,T||(T=!0,O());else{var z=n(u);z!==null&&G(C,z.startTime-q)}}var T=!1,k=-1,j=5,E=-1;function P(){return b?!0:!(t.unstable_now()-Eq&&P());){var Y=h.callback;if(typeof Y=="function"){h.callback=null,f=h.priorityLevel;var oe=Y(h.expirationTime<=q);if(q=t.unstable_now(),typeof oe=="function"){h.callback=oe,A(q),z=!0;break t}h===n(c)&&r(c),A(q)}else r(c);h=n(c)}if(h!==null)z=!0;else{var $=n(u);$!==null&&G(C,$.startTime-q),z=!1}}break e}finally{h=null,f=K,p=!1}z=void 0}}finally{z?O():T=!1}}}var O;if(typeof N=="function")O=function(){N(U)};else if(typeof MessageChannel<"u"){var B=new MessageChannel,R=B.port2;B.port1.onmessage=U,O=function(){R.postMessage(null)}}else O=function(){v(U,0)};function G(q,z){k=v(function(){q(t.unstable_now())},z)}t.unstable_IdlePriority=5,t.unstable_ImmediatePriority=1,t.unstable_LowPriority=4,t.unstable_NormalPriority=3,t.unstable_Profiling=null,t.unstable_UserBlockingPriority=2,t.unstable_cancelCallback=function(q){q.callback=null},t.unstable_forceFrameRate=function(q){0>q||125Y?(q.sortIndex=K,e(u,q),n(c)===null&&q===n(u)&&(y?(S(k),k=-1):y=!0,G(C,K-Y))):(q.sortIndex=oe,e(c,q),x||p||(x=!0,T||(T=!0,O()))),q},t.unstable_shouldYield=P,t.unstable_wrapCallback=function(q){var z=f;return function(){var K=f;f=z;try{return q.apply(this,arguments)}finally{f=K}}}})($T)),$T}var YU;function zoe(){return YU||(YU=1,HT.exports=Ioe()),HT.exports}var VT={exports:{}},ss={};var QU;function Uoe(){if(QU)return ss;QU=1;var t=Bb();function e(c){var u="https://react.dev/errors/"+c;if(1"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(t)}catch(e){console.error(e)}}return t(),VT.exports=Uoe(),VT.exports}var JU;function Boe(){if(JU)return iy;JU=1;var t=zoe(),e=Bb(),n=bK();function r(m){var g="https://react.dev/errors/"+m;if(1oe||(m.current=Y[oe],Y[oe]=null,oe--)}function ee(m,g){oe++,Y[oe]=m.current,m.current=g}var J=$(null),_e=$(null),pe=$(null),me=$(null);function je(m,g){switch(ee(pe,g),ee(_e,m),ee(J,null),g.nodeType){case 9:case 11:m=(m=g.documentElement)&&(m=m.namespaceURI)?fU(m):0;break;default:if(m=g.tagName,g=g.namespaceURI)g=fU(g),m=pU(g,m);else switch(m){case"svg":m=1;break;case"math":m=2;break;default:m=0}}X(J),ee(J,m)}function de(){X(J),X(_e),X(pe)}function ce(m){m.memoizedState!==null&&ee(me,m);var g=J.current,_=pU(g,m.type);g!==_&&(ee(_e,m),ee(J,_))}function Se(m){_e.current===m&&(X(J),X(_e)),me.current===m&&(X(me),Jx._currentValue=K)}var ie,Fe;function V(m){if(ie===void 0)try{throw Error()}catch(_){var g=_.stack.trim().match(/\n( *(at )?)/);ie=g&&g[1]||"",Fe=-1<_.stack.indexOf(` +function Roe(t,e){for(var n=0;nr[i]})}}}return Object.freeze(Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}))}(function(){const e=document.createElement("link").relList;if(e&&e.supports&&e.supports("modulepreload"))return;for(const i of document.querySelectorAll('link[rel="modulepreload"]'))r(i);new MutationObserver(i=>{for(const s of i)if(s.type==="childList")for(const o of s.addedNodes)o.tagName==="LINK"&&o.rel==="modulepreload"&&r(o)}).observe(document,{childList:!0,subtree:!0});function n(i){const s={};return i.integrity&&(s.integrity=i.integrity),i.referrerPolicy&&(s.referrerPolicy=i.referrerPolicy),i.crossOrigin==="use-credentials"?s.credentials="include":i.crossOrigin==="anonymous"?s.credentials="omit":s.credentials="same-origin",s}function r(i){if(i.ep)return;i.ep=!0;const s=n(i);fetch(i.href,s)}})();var c_=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function ec(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var UT={exports:{}},iy={};var qU;function Foe(){if(qU)return iy;qU=1;var t=Symbol.for("react.transitional.element"),e=Symbol.for("react.fragment");function n(r,i,s){var o=null;if(s!==void 0&&(o=""+s),i.key!==void 0&&(o=""+i.key),"key"in i){s={};for(var l in i)l!=="key"&&(s[l]=i[l])}else s=i;return i=s.ref,{$$typeof:t,type:r,key:o,ref:i!==void 0?i:null,props:s}}return iy.Fragment=e,iy.jsx=n,iy.jsxs=n,iy}var WU;function Loe(){return WU||(WU=1,UT.exports=Foe()),UT.exports}var a=Loe(),BT={exports:{}},kn={};var KU;function Ooe(){if(KU)return kn;KU=1;var t=Symbol.for("react.transitional.element"),e=Symbol.for("react.portal"),n=Symbol.for("react.fragment"),r=Symbol.for("react.strict_mode"),i=Symbol.for("react.profiler"),s=Symbol.for("react.consumer"),o=Symbol.for("react.context"),l=Symbol.for("react.forward_ref"),c=Symbol.for("react.suspense"),u=Symbol.for("react.memo"),d=Symbol.for("react.lazy"),h=Symbol.for("react.activity"),f=Symbol.iterator;function p($){return $===null||typeof $!="object"?null:($=f&&$[f]||$["@@iterator"],typeof $=="function"?$:null)}var x={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},y=Object.assign,b={};function v($,X,ee){this.props=$,this.context=X,this.refs=b,this.updater=ee||x}v.prototype.isReactComponent={},v.prototype.setState=function($,X){if(typeof $!="object"&&typeof $!="function"&&$!=null)throw Error("takes an object of state variables to update or a function which returns an object of state variables.");this.updater.enqueueSetState(this,$,X,"setState")},v.prototype.forceUpdate=function($){this.updater.enqueueForceUpdate(this,$,"forceUpdate")};function S(){}S.prototype=v.prototype;function N($,X,ee){this.props=$,this.context=X,this.refs=b,this.updater=ee||x}var A=N.prototype=new S;A.constructor=N,y(A,v.prototype),A.isPureReactComponent=!0;var C=Array.isArray;function T(){}var k={H:null,A:null,T:null,S:null},j=Object.prototype.hasOwnProperty;function E($,X,ee){var J=ee.ref;return{$$typeof:t,type:$,key:X,ref:J!==void 0?J:null,props:ee}}function P($,X){return E($.type,X,$.props)}function U($){return typeof $=="object"&&$!==null&&$.$$typeof===t}function O($){var X={"=":"=0",":":"=2"};return"$"+$.replace(/[=:]/g,function(ee){return X[ee]})}var B=/\/+/g;function R($,X){return typeof $=="object"&&$!==null&&$.key!=null?O(""+$.key):X.toString(36)}function G($){switch($.status){case"fulfilled":return $.value;case"rejected":throw $.reason;default:switch(typeof $.status=="string"?$.then(T,T):($.status="pending",$.then(function(X){$.status==="pending"&&($.status="fulfilled",$.value=X)},function(X){$.status==="pending"&&($.status="rejected",$.reason=X)})),$.status){case"fulfilled":return $.value;case"rejected":throw $.reason}}throw $}function q($,X,ee,J,_e){var pe=typeof $;(pe==="undefined"||pe==="boolean")&&($=null);var he=!1;if($===null)he=!0;else switch(pe){case"bigint":case"string":case"number":he=!0;break;case"object":switch($.$$typeof){case t:case e:he=!0;break;case d:return he=$._init,q(he($._payload),X,ee,J,_e)}}if(he)return _e=_e($),he=J===""?"."+R($,0):J,C(_e)?(ee="",he!=null&&(ee=he.replace(B,"$&/")+"/"),q(_e,X,ee,"",function(ce){return ce})):_e!=null&&(U(_e)&&(_e=P(_e,ee+(_e.key==null||$&&$.key===_e.key?"":(""+_e.key).replace(B,"$&/")+"/")+he)),X.push(_e)),1;he=0;var je=J===""?".":J+":";if(C($))for(var de=0;de<$.length;de++)J=$[de],pe=je+R(J,de),he+=q(J,X,ee,pe,_e);else if(de=p($),typeof de=="function")for($=de.call($),de=0;!(J=$.next()).done;)J=J.value,pe=je+R(J,de++),he+=q(J,X,ee,pe,_e);else if(pe==="object"){if(typeof $.then=="function")return q(G($),X,ee,J,_e);throw X=String($),Error("Objects are not valid as a React child (found: "+(X==="[object Object]"?"object with keys {"+Object.keys($).join(", ")+"}":X)+"). If you meant to render a collection of children, use an array instead.")}return he}function z($,X,ee){if($==null)return $;var J=[],_e=0;return q($,J,"","",function(pe){return X.call(ee,pe,_e++)}),J}function K($){if($._status===-1){var X=$._result;X=X(),X.then(function(ee){($._status===0||$._status===-1)&&($._status=1,$._result=ee)},function(ee){($._status===0||$._status===-1)&&($._status=2,$._result=ee)}),$._status===-1&&($._status=0,$._result=X)}if($._status===1)return $._result.default;throw $._result}var Y=typeof reportError=="function"?reportError:function($){if(typeof window=="object"&&typeof window.ErrorEvent=="function"){var X=new window.ErrorEvent("error",{bubbles:!0,cancelable:!0,message:typeof $=="object"&&$!==null&&typeof $.message=="string"?String($.message):String($),error:$});if(!window.dispatchEvent(X))return}else if(typeof process=="object"&&typeof process.emit=="function"){process.emit("uncaughtException",$);return}console.error($)},oe={map:z,forEach:function($,X,ee){z($,function(){X.apply(this,arguments)},ee)},count:function($){var X=0;return z($,function(){X++}),X},toArray:function($){return z($,function(X){return X})||[]},only:function($){if(!U($))throw Error("React.Children.only expected to receive a single React element child.");return $}};return kn.Activity=h,kn.Children=oe,kn.Component=v,kn.Fragment=n,kn.Profiler=i,kn.PureComponent=N,kn.StrictMode=r,kn.Suspense=c,kn.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=k,kn.__COMPILER_RUNTIME={__proto__:null,c:function($){return k.H.useMemoCache($)}},kn.cache=function($){return function(){return $.apply(null,arguments)}},kn.cacheSignal=function(){return null},kn.cloneElement=function($,X,ee){if($==null)throw Error("The argument must be a React element, but you passed "+$+".");var J=y({},$.props),_e=$.key;if(X!=null)for(pe in X.key!==void 0&&(_e=""+X.key),X)!j.call(X,pe)||pe==="key"||pe==="__self"||pe==="__source"||pe==="ref"&&X.ref===void 0||(J[pe]=X[pe]);var pe=arguments.length-2;if(pe===1)J.children=ee;else if(1>>1,oe=q[Y];if(0>>1;Y<$;){var X=2*(Y+1)-1,ee=q[X],J=X+1,_e=q[J];if(0>i(ee,K))Ji(_e,ee)?(q[Y]=_e,q[J]=K,Y=J):(q[Y]=ee,q[X]=K,Y=X);else if(Ji(_e,K))q[Y]=_e,q[J]=K,Y=J;else break e}}return z}function i(q,z){var K=q.sortIndex-z.sortIndex;return K!==0?K:q.id-z.id}if(t.unstable_now=void 0,typeof performance=="object"&&typeof performance.now=="function"){var s=performance;t.unstable_now=function(){return s.now()}}else{var o=Date,l=o.now();t.unstable_now=function(){return o.now()-l}}var c=[],u=[],d=1,h=null,f=3,p=!1,x=!1,y=!1,b=!1,v=typeof setTimeout=="function"?setTimeout:null,S=typeof clearTimeout=="function"?clearTimeout:null,N=typeof setImmediate<"u"?setImmediate:null;function A(q){for(var z=n(u);z!==null;){if(z.callback===null)r(u);else if(z.startTime<=q)r(u),z.sortIndex=z.expirationTime,e(c,z);else break;z=n(u)}}function C(q){if(y=!1,A(q),!x)if(n(c)!==null)x=!0,T||(T=!0,O());else{var z=n(u);z!==null&&G(C,z.startTime-q)}}var T=!1,k=-1,j=5,E=-1;function P(){return b?!0:!(t.unstable_now()-Eq&&P());){var Y=h.callback;if(typeof Y=="function"){h.callback=null,f=h.priorityLevel;var oe=Y(h.expirationTime<=q);if(q=t.unstable_now(),typeof oe=="function"){h.callback=oe,A(q),z=!0;break t}h===n(c)&&r(c),A(q)}else r(c);h=n(c)}if(h!==null)z=!0;else{var $=n(u);$!==null&&G(C,$.startTime-q),z=!1}}break e}finally{h=null,f=K,p=!1}z=void 0}}finally{z?O():T=!1}}}var O;if(typeof N=="function")O=function(){N(U)};else if(typeof MessageChannel<"u"){var B=new MessageChannel,R=B.port2;B.port1.onmessage=U,O=function(){R.postMessage(null)}}else O=function(){v(U,0)};function G(q,z){k=v(function(){q(t.unstable_now())},z)}t.unstable_IdlePriority=5,t.unstable_ImmediatePriority=1,t.unstable_LowPriority=4,t.unstable_NormalPriority=3,t.unstable_Profiling=null,t.unstable_UserBlockingPriority=2,t.unstable_cancelCallback=function(q){q.callback=null},t.unstable_forceFrameRate=function(q){0>q||125Y?(q.sortIndex=K,e(u,q),n(c)===null&&q===n(u)&&(y?(S(k),k=-1):y=!0,G(C,K-Y))):(q.sortIndex=oe,e(c,q),x||p||(x=!0,T||(T=!0,O()))),q},t.unstable_shouldYield=P,t.unstable_wrapCallback=function(q){var z=f;return function(){var K=f;f=z;try{return q.apply(this,arguments)}finally{f=K}}}})(VT)),VT}var QU;function Uoe(){return QU||(QU=1,$T.exports=zoe()),$T.exports}var GT={exports:{}},ss={};var ZU;function Boe(){if(ZU)return ss;ZU=1;var t=Hb();function e(c){var u="https://react.dev/errors/"+c;if(1"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(t)}catch(e){console.error(e)}}return t(),GT.exports=Boe(),GT.exports}var eB;function Hoe(){if(eB)return ay;eB=1;var t=Uoe(),e=Hb(),n=xK();function r(m){var g="https://react.dev/errors/"+m;if(1oe||(m.current=Y[oe],Y[oe]=null,oe--)}function ee(m,g){oe++,Y[oe]=m.current,m.current=g}var J=$(null),_e=$(null),pe=$(null),he=$(null);function je(m,g){switch(ee(pe,g),ee(_e,m),ee(J,null),g.nodeType){case 9:case 11:m=(m=g.documentElement)&&(m=m.namespaceURI)?pU(m):0;break;default:if(m=g.tagName,g=g.namespaceURI)g=pU(g),m=gU(g,m);else switch(m){case"svg":m=1;break;case"math":m=2;break;default:m=0}}X(J),ee(J,m)}function de(){X(J),X(_e),X(pe)}function ce(m){m.memoizedState!==null&&ee(he,m);var g=J.current,_=gU(g,m.type);g!==_&&(ee(_e,m),ee(J,_))}function Se(m){_e.current===m&&(X(J),X(_e)),he.current===m&&(X(he),ey._currentValue=K)}var ie,Fe;function V(m){if(ie===void 0)try{throw Error()}catch(_){var g=_.stack.trim().match(/\n( *(at )?)/);ie=g&&g[1]||"",Fe=-1<_.stack.indexOf(` at`)?" ()":-1<_.stack.indexOf("@")?"@unknown:0:0":""}return` `+ie+m+Fe}var W=!1;function ue(m,g){if(!m||W)return"";W=!0;var _=Error.prepareStackTrace;Error.prepareStackTrace=void 0;try{var M={DetermineComponentFrameRoot:function(){try{if(g){var Ct=function(){throw Error()};if(Object.defineProperty(Ct.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(Ct,[])}catch(gt){var mt=gt}Reflect.construct(m,[],Ct)}else{try{Ct.call()}catch(gt){mt=gt}m.call(Ct.prototype)}}else{try{throw Error()}catch(gt){mt=gt}(Ct=m())&&typeof Ct.catch=="function"&&Ct.catch(function(){})}}catch(gt){if(gt&&mt&&typeof gt.stack=="string")return[gt.stack,mt.stack]}return[null,null]}};M.DetermineComponentFrameRoot.displayName="DetermineComponentFrameRoot";var F=Object.getOwnPropertyDescriptor(M.DetermineComponentFrameRoot,"name");F&&F.configurable&&Object.defineProperty(M.DetermineComponentFrameRoot,"name",{value:"DetermineComponentFrameRoot"});var I=M.DetermineComponentFrameRoot(),te=I[0],ke=I[1];if(te&&ke){var Be=te.split(` `),ht=ke.split(` `);for(F=M=0;MF||Be[M]!==ht[F]){var yt=` `+Be[M].replace(" at new "," at ");return m.displayName&&yt.includes("")&&(yt=yt.replace("",m.displayName)),yt}while(1<=M&&0<=F);break}}}finally{W=!1,Error.prepareStackTrace=_}return(_=m?m.displayName||m.name:"")?V(_):""}function Q(m,g){switch(m.tag){case 26:case 27:case 5:return V(m.type);case 16:return V("Lazy");case 13:return m.child!==g&&g!==null?V("Suspense Fallback"):V("Suspense");case 19:return V("SuspenseList");case 0:case 15:return ue(m.type,!1);case 11:return ue(m.type.render,!1);case 1:return ue(m.type,!0);case 31:return V("Activity");default:return""}}function se(m){try{var g="",_=null;do g+=Q(m,_),_=m,m=m.return;while(m);return g}catch(M){return` Error generating stack: `+M.message+` -`+M.stack}}var Z=Object.prototype.hasOwnProperty,Ne=t.unstable_scheduleCallback,ve=t.unstable_cancelCallback,fe=t.unstable_shouldYield,L=t.unstable_requestPaint,D=t.unstable_now,H=t.unstable_getCurrentPriorityLevel,he=t.unstable_ImmediatePriority,xe=t.unstable_UserBlockingPriority,be=t.unstable_NormalPriority,Ue=t.unstable_LowPriority,Oe=t.unstable_IdlePriority,Qe=t.log,rt=t.unstable_setDisableYieldValue,we=null,ye=null;function le(m){if(typeof Qe=="function"&&rt(m),ye&&typeof ye.setStrictMode=="function")try{ye.setStrictMode(we,m)}catch{}}var Le=Math.clz32?Math.clz32:Ae,Me=Math.log,$e=Math.LN2;function Ae(m){return m>>>=0,m===0?32:31-(Me(m)/$e|0)|0}var Je=256,Pe=262144,Xe=4194304;function De(m){var g=m&42;if(g!==0)return g;switch(m&-m){case 1:return 1;case 2:return 2;case 4:return 4;case 8:return 8;case 16:return 16;case 32:return 32;case 64:return 64;case 128:return 128;case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:return m&261888;case 262144:case 524288:case 1048576:case 2097152:return m&3932160;case 4194304:case 8388608:case 16777216:case 33554432:return m&62914560;case 67108864:return 67108864;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 0;default:return m}}function Re(m,g,_){var M=m.pendingLanes;if(M===0)return 0;var F=0,I=m.suspendedLanes,te=m.pingedLanes;m=m.warmLanes;var ke=M&134217727;return ke!==0?(M=ke&~I,M!==0?F=De(M):(te&=ke,te!==0?F=De(te):_||(_=ke&~m,_!==0&&(F=De(_))))):(ke=M&~I,ke!==0?F=De(ke):te!==0?F=De(te):_||(_=M&~m,_!==0&&(F=De(_)))),F===0?0:g!==0&&g!==F&&(g&I)===0&&(I=F&-F,_=g&-g,I>=_||I===32&&(_&4194048)!==0)?g:F}function qe(m,g){return(m.pendingLanes&~(m.suspendedLanes&~m.pingedLanes)&g)===0}function pt(m,g){switch(m){case 1:case 2:case 4:case 8:case 64:return g+250;case 16:case 32:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:return g+5e3;case 4194304:case 8388608:case 16777216:case 33554432:return-1;case 67108864:case 134217728:case 268435456:case 536870912:case 1073741824:return-1;default:return-1}}function At(){var m=Xe;return Xe<<=1,(Xe&62914560)===0&&(Xe=4194304),m}function Rt(m){for(var g=[],_=0;31>_;_++)g.push(m);return g}function Wt(m,g){m.pendingLanes|=g,g!==268435456&&(m.suspendedLanes=0,m.pingedLanes=0,m.warmLanes=0)}function Tt(m,g,_,M,F,I){var te=m.pendingLanes;m.pendingLanes=_,m.suspendedLanes=0,m.pingedLanes=0,m.warmLanes=0,m.expiredLanes&=_,m.entangledLanes&=_,m.errorRecoveryDisabledLanes&=_,m.shellSuspendCounter=0;var ke=m.entanglements,Be=m.expirationTimes,ht=m.hiddenUpdates;for(_=te&~_;0<_;){var yt=31-Le(_),Ct=1<"u")return null;try{return m.activeElement||m.body}catch{return m.body}}var Qr=/[\n"\\]/g;function gn(m){return m.replace(Qr,function(g){return"\\"+g.charCodeAt(0).toString(16)+" "})}function Zr(m,g,_,M,F,I,te,ke){m.name="",te!=null&&typeof te!="function"&&typeof te!="symbol"&&typeof te!="boolean"?m.type=te:m.removeAttribute("type"),g!=null?te==="number"?(g===0&&m.value===""||m.value!=g)&&(m.value=""+Mn(g)):m.value!==""+Mn(g)&&(m.value=""+Mn(g)):te!=="submit"&&te!=="reset"||m.removeAttribute("value"),g!=null?vi(m,te,Mn(g)):_!=null?vi(m,te,Mn(_)):M!=null&&m.removeAttribute("value"),F==null&&I!=null&&(m.defaultChecked=!!I),F!=null&&(m.checked=F&&typeof F!="function"&&typeof F!="symbol"),ke!=null&&typeof ke!="function"&&typeof ke!="symbol"&&typeof ke!="boolean"?m.name=""+Mn(ke):m.removeAttribute("name")}function Kn(m,g,_,M,F,I,te,ke){if(I!=null&&typeof I!="function"&&typeof I!="symbol"&&typeof I!="boolean"&&(m.type=I),g!=null||_!=null){if(!(I!=="submit"&&I!=="reset"||g!=null)){sn(m);return}_=_!=null?""+Mn(_):"",g=g!=null?""+Mn(g):_,ke||g===m.value||(m.value=g),m.defaultValue=g}M=M??F,M=typeof M!="function"&&typeof M!="symbol"&&!!M,m.checked=ke?m.checked:!!M,m.defaultChecked=!!M,te!=null&&typeof te!="function"&&typeof te!="symbol"&&typeof te!="boolean"&&(m.name=te),sn(m)}function vi(m,g,_){g==="number"&&Mr(m.ownerDocument)===m||m.defaultValue===""+_||(m.defaultValue=""+_)}function mi(m,g,_,M){if(m=m.options,g){g={};for(var F=0;F<_.length;F++)g["$"+_[F]]=!0;for(_=0;_"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),vr=!1;if(Ur)try{var Cl={};Object.defineProperty(Cl,"passive",{get:function(){vr=!0}}),window.addEventListener("test",Cl,Cl),window.removeEventListener("test",Cl,Cl)}catch{vr=!1}var Ma=null,oa=null,ic=null;function Br(){if(ic)return ic;var m,g=oa,_=g.length,M,F="value"in Ma?Ma.value:Ma.textContent,I=F.length;for(m=0;m<_&&g[m]===F[m];m++);var te=_-m;for(M=1;M<=te&&g[_-M]===F[I-M];M++);return ic=F.slice(m,1=vx),wI=" ",_I=!1;function SI(m,g){switch(m){case"keyup":return tse.indexOf(g.keyCode)!==-1;case"keydown":return g.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function NI(m){return m=m.detail,typeof m=="object"&&"data"in m?m.data:null}var fp=!1;function rse(m,g){switch(m){case"compositionend":return NI(g);case"keypress":return g.which!==32?null:(_I=!0,wI);case"textInput":return m=g.data,m===wI&&_I?null:m;default:return null}}function ise(m,g){if(fp)return m==="compositionend"||!GM&&SI(m,g)?(m=Br(),ic=oa=Ma=null,fp=!1,m):null;switch(m){case"paste":return null;case"keypress":if(!(g.ctrlKey||g.altKey||g.metaKey)||g.ctrlKey&&g.altKey){if(g.char&&1=g)return{node:_,offset:g-m};m=M}e:{for(;_;){if(_.nextSibling){_=_.nextSibling;break e}_=_.parentNode}_=void 0}_=jI(_)}}function RI(m,g){return m&&g?m===g?!0:m&&m.nodeType===3?!1:g&&g.nodeType===3?RI(m,g.parentNode):"contains"in m?m.contains(g):m.compareDocumentPosition?!!(m.compareDocumentPosition(g)&16):!1:!1}function FI(m){m=m!=null&&m.ownerDocument!=null&&m.ownerDocument.defaultView!=null?m.ownerDocument.defaultView:window;for(var g=Mr(m.document);g instanceof m.HTMLIFrameElement;){try{var _=typeof g.contentWindow.location.href=="string"}catch{_=!1}if(_)m=g.contentWindow;else break;g=Mr(m.document)}return g}function KM(m){var g=m&&m.nodeName&&m.nodeName.toLowerCase();return g&&(g==="input"&&(m.type==="text"||m.type==="search"||m.type==="tel"||m.type==="url"||m.type==="password")||g==="textarea"||m.contentEditable==="true")}var hse=Ur&&"documentMode"in document&&11>=document.documentMode,pp=null,XM=null,Nx=null,YM=!1;function LI(m,g,_){var M=_.window===_?_.document:_.nodeType===9?_:_.ownerDocument;YM||pp==null||pp!==Mr(M)||(M=pp,"selectionStart"in M&&KM(M)?M={start:M.selectionStart,end:M.selectionEnd}:(M=(M.ownerDocument&&M.ownerDocument.defaultView||window).getSelection(),M={anchorNode:M.anchorNode,anchorOffset:M.anchorOffset,focusNode:M.focusNode,focusOffset:M.focusOffset}),Nx&&Sx(Nx,M)||(Nx=M,M=Ww(XM,"onSelect"),0>=te,F-=te,ac=1<<32-Le(g)+F|_<Rn?(tr=en,en=null):tr=en.sibling;var dr=mt(nt,en,ut[Rn],St);if(dr===null){en===null&&(en=tr);break}m&&en&&dr.alternate===null&&g(nt,en),We=I(dr,We,Rn),ur===null?an=dr:ur.sibling=dr,ur=dr,en=tr}if(Rn===ut.length)return _(nt,en),rr&&Zc(nt,Rn),an;if(en===null){for(;RnRn?(tr=en,en=null):tr=en.sibling;var Vd=mt(nt,en,dr.value,St);if(Vd===null){en===null&&(en=tr);break}m&&en&&Vd.alternate===null&&g(nt,en),We=I(Vd,We,Rn),ur===null?an=Vd:ur.sibling=Vd,ur=Vd,en=tr}if(dr.done)return _(nt,en),rr&&Zc(nt,Rn),an;if(en===null){for(;!dr.done;Rn++,dr=ut.next())dr=Ct(nt,dr.value,St),dr!==null&&(We=I(dr,We,Rn),ur===null?an=dr:ur.sibling=dr,ur=dr);return rr&&Zc(nt,Rn),an}for(en=M(en);!dr.done;Rn++,dr=ut.next())dr=gt(en,nt,Rn,dr.value,St),dr!==null&&(m&&dr.alternate!==null&&en.delete(dr.key===null?Rn:dr.key),We=I(dr,We,Rn),ur===null?an=dr:ur.sibling=dr,ur=dr);return m&&en.forEach(function(joe){return g(nt,joe)}),rr&&Zc(nt,Rn),an}function Er(nt,We,ut,St){if(typeof ut=="object"&&ut!==null&&ut.type===y&&ut.key===null&&(ut=ut.props.children),typeof ut=="object"&&ut!==null){switch(ut.$$typeof){case p:e:{for(var an=ut.key;We!==null;){if(We.key===an){if(an=ut.type,an===y){if(We.tag===7){_(nt,We.sibling),St=F(We,ut.props.children),St.return=nt,nt=St;break e}}else if(We.elementType===an||typeof an=="object"&&an!==null&&an.$$typeof===j&&Nm(an)===We.type){_(nt,We.sibling),St=F(We,ut.props),Ex(St,ut),St.return=nt,nt=St;break e}_(nt,We);break}else g(nt,We);We=We.sibling}ut.type===y?(St=ym(ut.props.children,nt.mode,St,ut.key),St.return=nt,nt=St):(St=uw(ut.type,ut.key,ut.props,null,nt.mode,St),Ex(St,ut),St.return=nt,nt=St)}return te(nt);case x:e:{for(an=ut.key;We!==null;){if(We.key===an)if(We.tag===4&&We.stateNode.containerInfo===ut.containerInfo&&We.stateNode.implementation===ut.implementation){_(nt,We.sibling),St=F(We,ut.children||[]),St.return=nt,nt=St;break e}else{_(nt,We);break}else g(nt,We);We=We.sibling}St=rA(ut,nt.mode,St),St.return=nt,nt=St}return te(nt);case j:return ut=Nm(ut),Er(nt,We,ut,St)}if(G(ut))return Qt(nt,We,ut,St);if(O(ut)){if(an=O(ut),typeof an!="function")throw Error(r(150));return ut=an.call(ut),mn(nt,We,ut,St)}if(typeof ut.then=="function")return Er(nt,We,bw(ut),St);if(ut.$$typeof===N)return Er(nt,We,mw(nt,ut),St);xw(nt,ut)}return typeof ut=="string"&&ut!==""||typeof ut=="number"||typeof ut=="bigint"?(ut=""+ut,We!==null&&We.tag===6?(_(nt,We.sibling),St=F(We,ut),St.return=nt,nt=St):(_(nt,We),St=nA(ut,nt.mode,St),St.return=nt,nt=St),te(nt)):_(nt,We)}return function(nt,We,ut,St){try{Tx=0;var an=Er(nt,We,ut,St);return Cp=null,an}catch(en){if(en===kp||en===pw)throw en;var ur=fo(29,en,null,nt.mode);return ur.lanes=St,ur.return=nt,ur}}}var Cm=a5(!0),s5=a5(!1),Md=!1;function pA(m){m.updateQueue={baseState:m.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,lanes:0,hiddenCallbacks:null},callbacks:null}}function gA(m,g){m=m.updateQueue,g.updateQueue===m&&(g.updateQueue={baseState:m.baseState,firstBaseUpdate:m.firstBaseUpdate,lastBaseUpdate:m.lastBaseUpdate,shared:m.shared,callbacks:null})}function Ad(m){return{lane:m,tag:0,payload:null,callback:null,next:null}}function Td(m,g,_){var M=m.updateQueue;if(M===null)return null;if(M=M.shared,(pr&2)!==0){var F=M.pending;return F===null?g.next=g:(g.next=F.next,F.next=g),M.pending=g,g=cw(m),$I(m,null,_),g}return lw(m,M,g,_),cw(m)}function Px(m,g,_){if(g=g.updateQueue,g!==null&&(g=g.shared,(_&4194048)!==0)){var M=g.lanes;M&=m.pendingLanes,_|=M,g.lanes=_,xt(m,_)}}function bA(m,g){var _=m.updateQueue,M=m.alternate;if(M!==null&&(M=M.updateQueue,_===M)){var F=null,I=null;if(_=_.firstBaseUpdate,_!==null){do{var te={lane:_.lane,tag:_.tag,payload:_.payload,callback:null,next:null};I===null?F=I=te:I=I.next=te,_=_.next}while(_!==null);I===null?F=I=g:I=I.next=g}else F=I=g;_={baseState:M.baseState,firstBaseUpdate:F,lastBaseUpdate:I,shared:M.shared,callbacks:M.callbacks},m.updateQueue=_;return}m=_.lastBaseUpdate,m===null?_.firstBaseUpdate=g:m.next=g,_.lastBaseUpdate=g}var xA=!1;function jx(){if(xA){var m=Np;if(m!==null)throw m}}function Dx(m,g,_,M){xA=!1;var F=m.updateQueue;Md=!1;var I=F.firstBaseUpdate,te=F.lastBaseUpdate,ke=F.shared.pending;if(ke!==null){F.shared.pending=null;var Be=ke,ht=Be.next;Be.next=null,te===null?I=ht:te.next=ht,te=Be;var yt=m.alternate;yt!==null&&(yt=yt.updateQueue,ke=yt.lastBaseUpdate,ke!==te&&(ke===null?yt.firstBaseUpdate=ht:ke.next=ht,yt.lastBaseUpdate=Be))}if(I!==null){var Ct=F.baseState;te=0,yt=ht=Be=null,ke=I;do{var mt=ke.lane&-536870913,gt=mt!==ke.lane;if(gt?(er&mt)===mt:(M&mt)===mt){mt!==0&&mt===Sp&&(xA=!0),yt!==null&&(yt=yt.next={lane:0,tag:ke.tag,payload:ke.payload,callback:null,next:null});e:{var Qt=m,mn=ke;mt=g;var Er=_;switch(mn.tag){case 1:if(Qt=mn.payload,typeof Qt=="function"){Ct=Qt.call(Er,Ct,mt);break e}Ct=Qt;break e;case 3:Qt.flags=Qt.flags&-65537|128;case 0:if(Qt=mn.payload,mt=typeof Qt=="function"?Qt.call(Er,Ct,mt):Qt,mt==null)break e;Ct=h({},Ct,mt);break e;case 2:Md=!0}}mt=ke.callback,mt!==null&&(m.flags|=64,gt&&(m.flags|=8192),gt=F.callbacks,gt===null?F.callbacks=[mt]:gt.push(mt))}else gt={lane:mt,tag:ke.tag,payload:ke.payload,callback:ke.callback,next:null},yt===null?(ht=yt=gt,Be=Ct):yt=yt.next=gt,te|=mt;if(ke=ke.next,ke===null){if(ke=F.shared.pending,ke===null)break;gt=ke,ke=gt.next,gt.next=null,F.lastBaseUpdate=gt,F.shared.pending=null}}while(!0);yt===null&&(Be=Ct),F.baseState=Be,F.firstBaseUpdate=ht,F.lastBaseUpdate=yt,I===null&&(F.shared.lanes=0),Rd|=te,m.lanes=te,m.memoizedState=Ct}}function o5(m,g){if(typeof m!="function")throw Error(r(191,m));m.call(g)}function l5(m,g){var _=m.callbacks;if(_!==null)for(m.callbacks=null,m=0;m<_.length;m++)o5(_[m],g)}var Mp=$(null),yw=$(0);function c5(m,g){m=cu,ee(yw,m),ee(Mp,g),cu=m|g.baseLanes}function yA(){ee(yw,cu),ee(Mp,Mp.current)}function vA(){cu=yw.current,X(Mp),X(yw)}var po=$(null),Vo=null;function Ed(m){var g=m.alternate;ee(Ii,Ii.current&1),ee(po,m),Vo===null&&(g===null||Mp.current!==null||g.memoizedState!==null)&&(Vo=m)}function wA(m){ee(Ii,Ii.current),ee(po,m),Vo===null&&(Vo=m)}function u5(m){m.tag===22?(ee(Ii,Ii.current),ee(po,m),Vo===null&&(Vo=m)):Pd()}function Pd(){ee(Ii,Ii.current),ee(po,po.current)}function go(m){X(po),Vo===m&&(Vo=null),X(Ii)}var Ii=$(0);function vw(m){for(var g=m;g!==null;){if(g.tag===13){var _=g.memoizedState;if(_!==null&&(_=_.dehydrated,_===null||MT(_)||AT(_)))return g}else if(g.tag===19&&(g.memoizedProps.revealOrder==="forwards"||g.memoizedProps.revealOrder==="backwards"||g.memoizedProps.revealOrder==="unstable_legacy-backwards"||g.memoizedProps.revealOrder==="together")){if((g.flags&128)!==0)return g}else if(g.child!==null){g.child.return=g,g=g.child;continue}if(g===m)break;for(;g.sibling===null;){if(g.return===null||g.return===m)return null;g=g.return}g.sibling.return=g.return,g=g.sibling}return null}var tu=0,En=null,Ar=null,Wi=null,ww=!1,Ap=!1,Mm=!1,_w=0,Rx=0,Tp=null,_se=0;function Ni(){throw Error(r(321))}function _A(m,g){if(g===null)return!1;for(var _=0;_I?I:8;var te=q.T,ke={};q.T=ke,OA(m,!1,g,_);try{var Be=F(),ht=q.S;if(ht!==null&&ht(ke,Be),Be!==null&&typeof Be=="object"&&typeof Be.then=="function"){var yt=wse(Be,M);Lx(m,g,yt,yo(m))}else Lx(m,g,M,yo(m))}catch(Ct){Lx(m,g,{then:function(){},status:"rejected",reason:Ct},yo())}finally{z.p=I,te!==null&&ke.types!==null&&(te.types=ke.types),q.T=te}}function Mse(){}function FA(m,g,_,M){if(m.tag!==5)throw Error(r(476));var F=U5(m).queue;z5(m,F,g,K,_===null?Mse:function(){return B5(m),_(M)})}function U5(m){var g=m.memoizedState;if(g!==null)return g;g={memoizedState:K,baseState:K,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:nu,lastRenderedState:K},next:null};var _={};return g.next={memoizedState:_,baseState:_,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:nu,lastRenderedState:_},next:null},m.memoizedState=g,m=m.alternate,m!==null&&(m.memoizedState=g),g}function B5(m){var g=U5(m);g.next===null&&(g=m.alternate.memoizedState),Lx(m,g.next.queue,{},yo())}function LA(){return $a(Jx)}function H5(){return zi().memoizedState}function $5(){return zi().memoizedState}function Ase(m){for(var g=m.return;g!==null;){switch(g.tag){case 24:case 3:var _=yo();m=Ad(_);var M=Td(g,m,_);M!==null&&(qs(M,g,_),Px(M,g,_)),g={cache:dA()},m.payload=g;return}g=g.return}}function Tse(m,g,_){var M=yo();_={lane:M,revertLane:0,gesture:null,action:_,hasEagerState:!1,eagerState:null,next:null},Aw(m)?G5(g,_):(_=eA(m,g,_,M),_!==null&&(qs(_,m,M),q5(_,g,M)))}function V5(m,g,_){var M=yo();Lx(m,g,_,M)}function Lx(m,g,_,M){var F={lane:M,revertLane:0,gesture:null,action:_,hasEagerState:!1,eagerState:null,next:null};if(Aw(m))G5(g,F);else{var I=m.alternate;if(m.lanes===0&&(I===null||I.lanes===0)&&(I=g.lastRenderedReducer,I!==null))try{var te=g.lastRenderedState,ke=I(te,_);if(F.hasEagerState=!0,F.eagerState=ke,mo(ke,te))return lw(m,g,F,0),Hr===null&&ow(),!1}catch{}if(_=eA(m,g,F,M),_!==null)return qs(_,m,M),q5(_,g,M),!0}return!1}function OA(m,g,_,M){if(M={lane:2,revertLane:pT(),gesture:null,action:M,hasEagerState:!1,eagerState:null,next:null},Aw(m)){if(g)throw Error(r(479))}else g=eA(m,_,M,2),g!==null&&qs(g,m,2)}function Aw(m){var g=m.alternate;return m===En||g!==null&&g===En}function G5(m,g){Ap=ww=!0;var _=m.pending;_===null?g.next=g:(g.next=_.next,_.next=g),m.pending=g}function q5(m,g,_){if((_&4194048)!==0){var M=g.lanes;M&=m.pendingLanes,_|=M,g.lanes=_,xt(m,_)}}var Ox={readContext:$a,use:Nw,useCallback:Ni,useContext:Ni,useEffect:Ni,useImperativeHandle:Ni,useLayoutEffect:Ni,useInsertionEffect:Ni,useMemo:Ni,useReducer:Ni,useRef:Ni,useState:Ni,useDebugValue:Ni,useDeferredValue:Ni,useTransition:Ni,useSyncExternalStore:Ni,useId:Ni,useHostTransitionStatus:Ni,useFormState:Ni,useActionState:Ni,useOptimistic:Ni,useMemoCache:Ni,useCacheRefresh:Ni};Ox.useEffectEvent=Ni;var W5={readContext:$a,use:Nw,useCallback:function(m,g){return Cs().memoizedState=[m,g===void 0?null:g],m},useContext:$a,useEffect:E5,useImperativeHandle:function(m,g,_){_=_!=null?_.concat([m]):null,Cw(4194308,4,R5.bind(null,g,m),_)},useLayoutEffect:function(m,g){return Cw(4194308,4,m,g)},useInsertionEffect:function(m,g){Cw(4,2,m,g)},useMemo:function(m,g){var _=Cs();g=g===void 0?null:g;var M=m();if(Mm){le(!0);try{m()}finally{le(!1)}}return _.memoizedState=[M,g],M},useReducer:function(m,g,_){var M=Cs();if(_!==void 0){var F=_(g);if(Mm){le(!0);try{_(g)}finally{le(!1)}}}else F=g;return M.memoizedState=M.baseState=F,m={pending:null,lanes:0,dispatch:null,lastRenderedReducer:m,lastRenderedState:F},M.queue=m,m=m.dispatch=Tse.bind(null,En,m),[M.memoizedState,m]},useRef:function(m){var g=Cs();return m={current:m},g.memoizedState=m},useState:function(m){m=EA(m);var g=m.queue,_=V5.bind(null,En,g);return g.dispatch=_,[m.memoizedState,_]},useDebugValue:DA,useDeferredValue:function(m,g){var _=Cs();return RA(_,m,g)},useTransition:function(){var m=EA(!1);return m=z5.bind(null,En,m.queue,!0,!1),Cs().memoizedState=m,[!1,m]},useSyncExternalStore:function(m,g,_){var M=En,F=Cs();if(rr){if(_===void 0)throw Error(r(407));_=_()}else{if(_=g(),Hr===null)throw Error(r(349));(er&127)!==0||f5(M,g,_)}F.memoizedState=_;var I={value:_,getSnapshot:g};return F.queue=I,E5(g5.bind(null,M,I,m),[m]),M.flags|=2048,Ep(9,{destroy:void 0},p5.bind(null,M,I,_,g),null),_},useId:function(){var m=Cs(),g=Hr.identifierPrefix;if(rr){var _=sc,M=ac;_=(M&~(1<<32-Le(M)-1)).toString(32)+_,g="_"+g+"R_"+_,_=_w++,0<_&&(g+="H"+_.toString(32)),g+="_"}else _=_se++,g="_"+g+"r_"+_.toString(32)+"_";return m.memoizedState=g},useHostTransitionStatus:LA,useFormState:k5,useActionState:k5,useOptimistic:function(m){var g=Cs();g.memoizedState=g.baseState=m;var _={pending:null,lanes:0,dispatch:null,lastRenderedReducer:null,lastRenderedState:null};return g.queue=_,g=OA.bind(null,En,!0,_),_.dispatch=g,[m,g]},useMemoCache:MA,useCacheRefresh:function(){return Cs().memoizedState=Ase.bind(null,En)},useEffectEvent:function(m){var g=Cs(),_={impl:m};return g.memoizedState=_,function(){if((pr&2)!==0)throw Error(r(440));return _.impl.apply(void 0,arguments)}}},IA={readContext:$a,use:Nw,useCallback:L5,useContext:$a,useEffect:jA,useImperativeHandle:F5,useInsertionEffect:j5,useLayoutEffect:D5,useMemo:O5,useReducer:kw,useRef:T5,useState:function(){return kw(nu)},useDebugValue:DA,useDeferredValue:function(m,g){var _=zi();return I5(_,Ar.memoizedState,m,g)},useTransition:function(){var m=kw(nu)[0],g=zi().memoizedState;return[typeof m=="boolean"?m:Fx(m),g]},useSyncExternalStore:m5,useId:H5,useHostTransitionStatus:LA,useFormState:C5,useActionState:C5,useOptimistic:function(m,g){var _=zi();return y5(_,Ar,m,g)},useMemoCache:MA,useCacheRefresh:$5};IA.useEffectEvent=P5;var K5={readContext:$a,use:Nw,useCallback:L5,useContext:$a,useEffect:jA,useImperativeHandle:F5,useInsertionEffect:j5,useLayoutEffect:D5,useMemo:O5,useReducer:TA,useRef:T5,useState:function(){return TA(nu)},useDebugValue:DA,useDeferredValue:function(m,g){var _=zi();return Ar===null?RA(_,m,g):I5(_,Ar.memoizedState,m,g)},useTransition:function(){var m=TA(nu)[0],g=zi().memoizedState;return[typeof m=="boolean"?m:Fx(m),g]},useSyncExternalStore:m5,useId:H5,useHostTransitionStatus:LA,useFormState:A5,useActionState:A5,useOptimistic:function(m,g){var _=zi();return Ar!==null?y5(_,Ar,m,g):(_.baseState=m,[m,_.queue.dispatch])},useMemoCache:MA,useCacheRefresh:$5};K5.useEffectEvent=P5;function zA(m,g,_,M){g=m.memoizedState,_=_(M,g),_=_==null?g:h({},g,_),m.memoizedState=_,m.lanes===0&&(m.updateQueue.baseState=_)}var UA={enqueueSetState:function(m,g,_){m=m._reactInternals;var M=yo(),F=Ad(M);F.payload=g,_!=null&&(F.callback=_),g=Td(m,F,M),g!==null&&(qs(g,m,M),Px(g,m,M))},enqueueReplaceState:function(m,g,_){m=m._reactInternals;var M=yo(),F=Ad(M);F.tag=1,F.payload=g,_!=null&&(F.callback=_),g=Td(m,F,M),g!==null&&(qs(g,m,M),Px(g,m,M))},enqueueForceUpdate:function(m,g){m=m._reactInternals;var _=yo(),M=Ad(_);M.tag=2,g!=null&&(M.callback=g),g=Td(m,M,_),g!==null&&(qs(g,m,_),Px(g,m,_))}};function X5(m,g,_,M,F,I,te){return m=m.stateNode,typeof m.shouldComponentUpdate=="function"?m.shouldComponentUpdate(M,I,te):g.prototype&&g.prototype.isPureReactComponent?!Sx(_,M)||!Sx(F,I):!0}function Y5(m,g,_,M){m=g.state,typeof g.componentWillReceiveProps=="function"&&g.componentWillReceiveProps(_,M),typeof g.UNSAFE_componentWillReceiveProps=="function"&&g.UNSAFE_componentWillReceiveProps(_,M),g.state!==m&&UA.enqueueReplaceState(g,g.state,null)}function Am(m,g){var _=g;if("ref"in g){_={};for(var M in g)M!=="ref"&&(_[M]=g[M])}if(m=m.defaultProps){_===g&&(_=h({},_));for(var F in m)_[F]===void 0&&(_[F]=m[F])}return _}function Q5(m){sw(m)}function Z5(m){console.error(m)}function J5(m){sw(m)}function Tw(m,g){try{var _=m.onUncaughtError;_(g.value,{componentStack:g.stack})}catch(M){setTimeout(function(){throw M})}}function ez(m,g,_){try{var M=m.onCaughtError;M(_.value,{componentStack:_.stack,errorBoundary:g.tag===1?g.stateNode:null})}catch(F){setTimeout(function(){throw F})}}function BA(m,g,_){return _=Ad(_),_.tag=3,_.payload={element:null},_.callback=function(){Tw(m,g)},_}function tz(m){return m=Ad(m),m.tag=3,m}function nz(m,g,_,M){var F=_.type.getDerivedStateFromError;if(typeof F=="function"){var I=M.value;m.payload=function(){return F(I)},m.callback=function(){ez(g,_,M)}}var te=_.stateNode;te!==null&&typeof te.componentDidCatch=="function"&&(m.callback=function(){ez(g,_,M),typeof F!="function"&&(Fd===null?Fd=new Set([this]):Fd.add(this));var ke=M.stack;this.componentDidCatch(M.value,{componentStack:ke!==null?ke:""})})}function Ese(m,g,_,M,F){if(_.flags|=32768,M!==null&&typeof M=="object"&&typeof M.then=="function"){if(g=_.alternate,g!==null&&_p(g,_,F,!0),_=po.current,_!==null){switch(_.tag){case 31:case 13:return Vo===null?Bw():_.alternate===null&&ki===0&&(ki=3),_.flags&=-257,_.flags|=65536,_.lanes=F,M===gw?_.flags|=16384:(g=_.updateQueue,g===null?_.updateQueue=new Set([M]):g.add(M),hT(m,M,F)),!1;case 22:return _.flags|=65536,M===gw?_.flags|=16384:(g=_.updateQueue,g===null?(g={transitions:null,markerInstances:null,retryQueue:new Set([M])},_.updateQueue=g):(_=g.retryQueue,_===null?g.retryQueue=new Set([M]):_.add(M)),hT(m,M,F)),!1}throw Error(r(435,_.tag))}return hT(m,M,F),Bw(),!1}if(rr)return g=po.current,g!==null?((g.flags&65536)===0&&(g.flags|=256),g.flags|=65536,g.lanes=F,M!==sA&&(m=Error(r(422),{cause:M}),Cx(Uo(m,_)))):(M!==sA&&(g=Error(r(423),{cause:M}),Cx(Uo(g,_))),m=m.current.alternate,m.flags|=65536,F&=-F,m.lanes|=F,M=Uo(M,_),F=BA(m.stateNode,M,F),bA(m,F),ki!==4&&(ki=2)),!1;var I=Error(r(520),{cause:M});if(I=Uo(I,_),Gx===null?Gx=[I]:Gx.push(I),ki!==4&&(ki=2),g===null)return!0;M=Uo(M,_),_=g;do{switch(_.tag){case 3:return _.flags|=65536,m=F&-F,_.lanes|=m,m=BA(_.stateNode,M,m),bA(_,m),!1;case 1:if(g=_.type,I=_.stateNode,(_.flags&128)===0&&(typeof g.getDerivedStateFromError=="function"||I!==null&&typeof I.componentDidCatch=="function"&&(Fd===null||!Fd.has(I))))return _.flags|=65536,F&=-F,_.lanes|=F,F=tz(F),nz(F,m,_,M),bA(_,F),!1}_=_.return}while(_!==null);return!1}var HA=Error(r(461)),Ki=!1;function Va(m,g,_,M){g.child=m===null?s5(g,null,_,M):Cm(g,m.child,_,M)}function rz(m,g,_,M,F){_=_.render;var I=g.ref;if("ref"in M){var te={};for(var ke in M)ke!=="ref"&&(te[ke]=M[ke])}else te=M;return _m(g),M=SA(m,g,_,te,I,F),ke=NA(),m!==null&&!Ki?(kA(m,g,F),ru(m,g,F)):(rr&&ke&&iA(g),g.flags|=1,Va(m,g,M,F),g.child)}function iz(m,g,_,M,F){if(m===null){var I=_.type;return typeof I=="function"&&!tA(I)&&I.defaultProps===void 0&&_.compare===null?(g.tag=15,g.type=I,az(m,g,I,M,F)):(m=uw(_.type,null,M,g,g.mode,F),m.ref=g.ref,m.return=g,g.child=m)}if(I=m.child,!YA(m,F)){var te=I.memoizedProps;if(_=_.compare,_=_!==null?_:Sx,_(te,M)&&m.ref===g.ref)return ru(m,g,F)}return g.flags|=1,m=Qc(I,M),m.ref=g.ref,m.return=g,g.child=m}function az(m,g,_,M,F){if(m!==null){var I=m.memoizedProps;if(Sx(I,M)&&m.ref===g.ref)if(Ki=!1,g.pendingProps=M=I,YA(m,F))(m.flags&131072)!==0&&(Ki=!0);else return g.lanes=m.lanes,ru(m,g,F)}return $A(m,g,_,M,F)}function sz(m,g,_,M){var F=M.children,I=m!==null?m.memoizedState:null;if(m===null&&g.stateNode===null&&(g.stateNode={_visibility:1,_pendingMarkers:null,_retryCache:null,_transitions:null}),M.mode==="hidden"){if((g.flags&128)!==0){if(I=I!==null?I.baseLanes|_:_,m!==null){for(M=g.child=m.child,F=0;M!==null;)F=F|M.lanes|M.childLanes,M=M.sibling;M=F&~I}else M=0,g.child=null;return oz(m,g,I,_,M)}if((_&536870912)!==0)g.memoizedState={baseLanes:0,cachePool:null},m!==null&&fw(g,I!==null?I.cachePool:null),I!==null?c5(g,I):yA(),u5(g);else return M=g.lanes=536870912,oz(m,g,I!==null?I.baseLanes|_:_,_,M)}else I!==null?(fw(g,I.cachePool),c5(g,I),Pd(),g.memoizedState=null):(m!==null&&fw(g,null),yA(),Pd());return Va(m,g,F,_),g.child}function Ix(m,g){return m!==null&&m.tag===22||g.stateNode!==null||(g.stateNode={_visibility:1,_pendingMarkers:null,_retryCache:null,_transitions:null}),g.sibling}function oz(m,g,_,M,F){var I=mA();return I=I===null?null:{parent:qi._currentValue,pool:I},g.memoizedState={baseLanes:_,cachePool:I},m!==null&&fw(g,null),yA(),u5(g),m!==null&&_p(m,g,M,!0),g.childLanes=F,null}function Ew(m,g){return g=jw({mode:g.mode,children:g.children},m.mode),g.ref=m.ref,m.child=g,g.return=m,g}function lz(m,g,_){return Cm(g,m.child,null,_),m=Ew(g,g.pendingProps),m.flags|=2,go(g),g.memoizedState=null,m}function Pse(m,g,_){var M=g.pendingProps,F=(g.flags&128)!==0;if(g.flags&=-129,m===null){if(rr){if(M.mode==="hidden")return m=Ew(g,M),g.lanes=536870912,Ix(null,m);if(wA(g),(m=Jr)?(m=vU(m,$o),m=m!==null&&m.data==="&"?m:null,m!==null&&(g.memoizedState={dehydrated:m,treeContext:Sd!==null?{id:ac,overflow:sc}:null,retryLane:536870912,hydrationErrors:null},_=GI(m),_.return=g,g.child=_,Ha=g,Jr=null)):m=null,m===null)throw kd(g);return g.lanes=536870912,null}return Ew(g,M)}var I=m.memoizedState;if(I!==null){var te=I.dehydrated;if(wA(g),F)if(g.flags&256)g.flags&=-257,g=lz(m,g,_);else if(g.memoizedState!==null)g.child=m.child,g.flags|=128,g=null;else throw Error(r(558));else if(Ki||_p(m,g,_,!1),F=(_&m.childLanes)!==0,Ki||F){if(M=Hr,M!==null&&(te=wt(M,_),te!==0&&te!==I.retryLane))throw I.retryLane=te,xm(m,te),qs(M,m,te),HA;Bw(),g=lz(m,g,_)}else m=I.treeContext,Jr=Go(te.nextSibling),Ha=g,rr=!0,Nd=null,$o=!1,m!==null&&KI(g,m),g=Ew(g,M),g.flags|=4096;return g}return m=Qc(m.child,{mode:M.mode,children:M.children}),m.ref=g.ref,g.child=m,m.return=g,m}function Pw(m,g){var _=g.ref;if(_===null)m!==null&&m.ref!==null&&(g.flags|=4194816);else{if(typeof _!="function"&&typeof _!="object")throw Error(r(284));(m===null||m.ref!==_)&&(g.flags|=4194816)}}function $A(m,g,_,M,F){return _m(g),_=SA(m,g,_,M,void 0,F),M=NA(),m!==null&&!Ki?(kA(m,g,F),ru(m,g,F)):(rr&&M&&iA(g),g.flags|=1,Va(m,g,_,F),g.child)}function cz(m,g,_,M,F,I){return _m(g),g.updateQueue=null,_=h5(g,M,_,F),d5(m),M=NA(),m!==null&&!Ki?(kA(m,g,I),ru(m,g,I)):(rr&&M&&iA(g),g.flags|=1,Va(m,g,_,I),g.child)}function uz(m,g,_,M,F){if(_m(g),g.stateNode===null){var I=xp,te=_.contextType;typeof te=="object"&&te!==null&&(I=$a(te)),I=new _(M,I),g.memoizedState=I.state!==null&&I.state!==void 0?I.state:null,I.updater=UA,g.stateNode=I,I._reactInternals=g,I=g.stateNode,I.props=M,I.state=g.memoizedState,I.refs={},pA(g),te=_.contextType,I.context=typeof te=="object"&&te!==null?$a(te):xp,I.state=g.memoizedState,te=_.getDerivedStateFromProps,typeof te=="function"&&(zA(g,_,te,M),I.state=g.memoizedState),typeof _.getDerivedStateFromProps=="function"||typeof I.getSnapshotBeforeUpdate=="function"||typeof I.UNSAFE_componentWillMount!="function"&&typeof I.componentWillMount!="function"||(te=I.state,typeof I.componentWillMount=="function"&&I.componentWillMount(),typeof I.UNSAFE_componentWillMount=="function"&&I.UNSAFE_componentWillMount(),te!==I.state&&UA.enqueueReplaceState(I,I.state,null),Dx(g,M,I,F),jx(),I.state=g.memoizedState),typeof I.componentDidMount=="function"&&(g.flags|=4194308),M=!0}else if(m===null){I=g.stateNode;var ke=g.memoizedProps,Be=Am(_,ke);I.props=Be;var ht=I.context,yt=_.contextType;te=xp,typeof yt=="object"&&yt!==null&&(te=$a(yt));var Ct=_.getDerivedStateFromProps;yt=typeof Ct=="function"||typeof I.getSnapshotBeforeUpdate=="function",ke=g.pendingProps!==ke,yt||typeof I.UNSAFE_componentWillReceiveProps!="function"&&typeof I.componentWillReceiveProps!="function"||(ke||ht!==te)&&Y5(g,I,M,te),Md=!1;var mt=g.memoizedState;I.state=mt,Dx(g,M,I,F),jx(),ht=g.memoizedState,ke||mt!==ht||Md?(typeof Ct=="function"&&(zA(g,_,Ct,M),ht=g.memoizedState),(Be=Md||X5(g,_,Be,M,mt,ht,te))?(yt||typeof I.UNSAFE_componentWillMount!="function"&&typeof I.componentWillMount!="function"||(typeof I.componentWillMount=="function"&&I.componentWillMount(),typeof I.UNSAFE_componentWillMount=="function"&&I.UNSAFE_componentWillMount()),typeof I.componentDidMount=="function"&&(g.flags|=4194308)):(typeof I.componentDidMount=="function"&&(g.flags|=4194308),g.memoizedProps=M,g.memoizedState=ht),I.props=M,I.state=ht,I.context=te,M=Be):(typeof I.componentDidMount=="function"&&(g.flags|=4194308),M=!1)}else{I=g.stateNode,gA(m,g),te=g.memoizedProps,yt=Am(_,te),I.props=yt,Ct=g.pendingProps,mt=I.context,ht=_.contextType,Be=xp,typeof ht=="object"&&ht!==null&&(Be=$a(ht)),ke=_.getDerivedStateFromProps,(ht=typeof ke=="function"||typeof I.getSnapshotBeforeUpdate=="function")||typeof I.UNSAFE_componentWillReceiveProps!="function"&&typeof I.componentWillReceiveProps!="function"||(te!==Ct||mt!==Be)&&Y5(g,I,M,Be),Md=!1,mt=g.memoizedState,I.state=mt,Dx(g,M,I,F),jx();var gt=g.memoizedState;te!==Ct||mt!==gt||Md||m!==null&&m.dependencies!==null&&hw(m.dependencies)?(typeof ke=="function"&&(zA(g,_,ke,M),gt=g.memoizedState),(yt=Md||X5(g,_,yt,M,mt,gt,Be)||m!==null&&m.dependencies!==null&&hw(m.dependencies))?(ht||typeof I.UNSAFE_componentWillUpdate!="function"&&typeof I.componentWillUpdate!="function"||(typeof I.componentWillUpdate=="function"&&I.componentWillUpdate(M,gt,Be),typeof I.UNSAFE_componentWillUpdate=="function"&&I.UNSAFE_componentWillUpdate(M,gt,Be)),typeof I.componentDidUpdate=="function"&&(g.flags|=4),typeof I.getSnapshotBeforeUpdate=="function"&&(g.flags|=1024)):(typeof I.componentDidUpdate!="function"||te===m.memoizedProps&&mt===m.memoizedState||(g.flags|=4),typeof I.getSnapshotBeforeUpdate!="function"||te===m.memoizedProps&&mt===m.memoizedState||(g.flags|=1024),g.memoizedProps=M,g.memoizedState=gt),I.props=M,I.state=gt,I.context=Be,M=yt):(typeof I.componentDidUpdate!="function"||te===m.memoizedProps&&mt===m.memoizedState||(g.flags|=4),typeof I.getSnapshotBeforeUpdate!="function"||te===m.memoizedProps&&mt===m.memoizedState||(g.flags|=1024),M=!1)}return I=M,Pw(m,g),M=(g.flags&128)!==0,I||M?(I=g.stateNode,_=M&&typeof _.getDerivedStateFromError!="function"?null:I.render(),g.flags|=1,m!==null&&M?(g.child=Cm(g,m.child,null,F),g.child=Cm(g,null,_,F)):Va(m,g,_,F),g.memoizedState=I.state,m=g.child):m=ru(m,g,F),m}function dz(m,g,_,M){return vm(),g.flags|=256,Va(m,g,_,M),g.child}var VA={dehydrated:null,treeContext:null,retryLane:0,hydrationErrors:null};function GA(m){return{baseLanes:m,cachePool:e5()}}function qA(m,g,_){return m=m!==null?m.childLanes&~_:0,g&&(m|=xo),m}function hz(m,g,_){var M=g.pendingProps,F=!1,I=(g.flags&128)!==0,te;if((te=I)||(te=m!==null&&m.memoizedState===null?!1:(Ii.current&2)!==0),te&&(F=!0,g.flags&=-129),te=(g.flags&32)!==0,g.flags&=-33,m===null){if(rr){if(F?Ed(g):Pd(),(m=Jr)?(m=vU(m,$o),m=m!==null&&m.data!=="&"?m:null,m!==null&&(g.memoizedState={dehydrated:m,treeContext:Sd!==null?{id:ac,overflow:sc}:null,retryLane:536870912,hydrationErrors:null},_=GI(m),_.return=g,g.child=_,Ha=g,Jr=null)):m=null,m===null)throw kd(g);return AT(m)?g.lanes=32:g.lanes=536870912,null}var ke=M.children;return M=M.fallback,F?(Pd(),F=g.mode,ke=jw({mode:"hidden",children:ke},F),M=ym(M,F,_,null),ke.return=g,M.return=g,ke.sibling=M,g.child=ke,M=g.child,M.memoizedState=GA(_),M.childLanes=qA(m,te,_),g.memoizedState=VA,Ix(null,M)):(Ed(g),WA(g,ke))}var Be=m.memoizedState;if(Be!==null&&(ke=Be.dehydrated,ke!==null)){if(I)g.flags&256?(Ed(g),g.flags&=-257,g=KA(m,g,_)):g.memoizedState!==null?(Pd(),g.child=m.child,g.flags|=128,g=null):(Pd(),ke=M.fallback,F=g.mode,M=jw({mode:"visible",children:M.children},F),ke=ym(ke,F,_,null),ke.flags|=2,M.return=g,ke.return=g,M.sibling=ke,g.child=M,Cm(g,m.child,null,_),M=g.child,M.memoizedState=GA(_),M.childLanes=qA(m,te,_),g.memoizedState=VA,g=Ix(null,M));else if(Ed(g),AT(ke)){if(te=ke.nextSibling&&ke.nextSibling.dataset,te)var ht=te.dgst;te=ht,M=Error(r(419)),M.stack="",M.digest=te,Cx({value:M,source:null,stack:null}),g=KA(m,g,_)}else if(Ki||_p(m,g,_,!1),te=(_&m.childLanes)!==0,Ki||te){if(te=Hr,te!==null&&(M=wt(te,_),M!==0&&M!==Be.retryLane))throw Be.retryLane=M,xm(m,M),qs(te,m,M),HA;MT(ke)||Bw(),g=KA(m,g,_)}else MT(ke)?(g.flags|=192,g.child=m.child,g=null):(m=Be.treeContext,Jr=Go(ke.nextSibling),Ha=g,rr=!0,Nd=null,$o=!1,m!==null&&KI(g,m),g=WA(g,M.children),g.flags|=4096);return g}return F?(Pd(),ke=M.fallback,F=g.mode,Be=m.child,ht=Be.sibling,M=Qc(Be,{mode:"hidden",children:M.children}),M.subtreeFlags=Be.subtreeFlags&65011712,ht!==null?ke=Qc(ht,ke):(ke=ym(ke,F,_,null),ke.flags|=2),ke.return=g,M.return=g,M.sibling=ke,g.child=M,Ix(null,M),M=g.child,ke=m.child.memoizedState,ke===null?ke=GA(_):(F=ke.cachePool,F!==null?(Be=qi._currentValue,F=F.parent!==Be?{parent:Be,pool:Be}:F):F=e5(),ke={baseLanes:ke.baseLanes|_,cachePool:F}),M.memoizedState=ke,M.childLanes=qA(m,te,_),g.memoizedState=VA,Ix(m.child,M)):(Ed(g),_=m.child,m=_.sibling,_=Qc(_,{mode:"visible",children:M.children}),_.return=g,_.sibling=null,m!==null&&(te=g.deletions,te===null?(g.deletions=[m],g.flags|=16):te.push(m)),g.child=_,g.memoizedState=null,_)}function WA(m,g){return g=jw({mode:"visible",children:g},m.mode),g.return=m,m.child=g}function jw(m,g){return m=fo(22,m,null,g),m.lanes=0,m}function KA(m,g,_){return Cm(g,m.child,null,_),m=WA(g,g.pendingProps.children),m.flags|=2,g.memoizedState=null,m}function mz(m,g,_){m.lanes|=g;var M=m.alternate;M!==null&&(M.lanes|=g),cA(m.return,g,_)}function XA(m,g,_,M,F,I){var te=m.memoizedState;te===null?m.memoizedState={isBackwards:g,rendering:null,renderingStartTime:0,last:M,tail:_,tailMode:F,treeForkCount:I}:(te.isBackwards=g,te.rendering=null,te.renderingStartTime=0,te.last=M,te.tail=_,te.tailMode=F,te.treeForkCount=I)}function fz(m,g,_){var M=g.pendingProps,F=M.revealOrder,I=M.tail;M=M.children;var te=Ii.current,ke=(te&2)!==0;if(ke?(te=te&1|2,g.flags|=128):te&=1,ee(Ii,te),Va(m,g,M,_),M=rr?kx:0,!ke&&m!==null&&(m.flags&128)!==0)e:for(m=g.child;m!==null;){if(m.tag===13)m.memoizedState!==null&&mz(m,_,g);else if(m.tag===19)mz(m,_,g);else if(m.child!==null){m.child.return=m,m=m.child;continue}if(m===g)break e;for(;m.sibling===null;){if(m.return===null||m.return===g)break e;m=m.return}m.sibling.return=m.return,m=m.sibling}switch(F){case"forwards":for(_=g.child,F=null;_!==null;)m=_.alternate,m!==null&&vw(m)===null&&(F=_),_=_.sibling;_=F,_===null?(F=g.child,g.child=null):(F=_.sibling,_.sibling=null),XA(g,!1,F,_,I,M);break;case"backwards":case"unstable_legacy-backwards":for(_=null,F=g.child,g.child=null;F!==null;){if(m=F.alternate,m!==null&&vw(m)===null){g.child=F;break}m=F.sibling,F.sibling=_,_=F,F=m}XA(g,!0,_,null,I,M);break;case"together":XA(g,!1,null,null,void 0,M);break;default:g.memoizedState=null}return g.child}function ru(m,g,_){if(m!==null&&(g.dependencies=m.dependencies),Rd|=g.lanes,(_&g.childLanes)===0)if(m!==null){if(_p(m,g,_,!1),(_&g.childLanes)===0)return null}else return null;if(m!==null&&g.child!==m.child)throw Error(r(153));if(g.child!==null){for(m=g.child,_=Qc(m,m.pendingProps),g.child=_,_.return=g;m.sibling!==null;)m=m.sibling,_=_.sibling=Qc(m,m.pendingProps),_.return=g;_.sibling=null}return g.child}function YA(m,g){return(m.lanes&g)!==0?!0:(m=m.dependencies,!!(m!==null&&hw(m)))}function jse(m,g,_){switch(g.tag){case 3:je(g,g.stateNode.containerInfo),Cd(g,qi,m.memoizedState.cache),vm();break;case 27:case 5:ce(g);break;case 4:je(g,g.stateNode.containerInfo);break;case 10:Cd(g,g.type,g.memoizedProps.value);break;case 31:if(g.memoizedState!==null)return g.flags|=128,wA(g),null;break;case 13:var M=g.memoizedState;if(M!==null)return M.dehydrated!==null?(Ed(g),g.flags|=128,null):(_&g.child.childLanes)!==0?hz(m,g,_):(Ed(g),m=ru(m,g,_),m!==null?m.sibling:null);Ed(g);break;case 19:var F=(m.flags&128)!==0;if(M=(_&g.childLanes)!==0,M||(_p(m,g,_,!1),M=(_&g.childLanes)!==0),F){if(M)return fz(m,g,_);g.flags|=128}if(F=g.memoizedState,F!==null&&(F.rendering=null,F.tail=null,F.lastEffect=null),ee(Ii,Ii.current),M)break;return null;case 22:return g.lanes=0,sz(m,g,_,g.pendingProps);case 24:Cd(g,qi,m.memoizedState.cache)}return ru(m,g,_)}function pz(m,g,_){if(m!==null)if(m.memoizedProps!==g.pendingProps)Ki=!0;else{if(!YA(m,_)&&(g.flags&128)===0)return Ki=!1,jse(m,g,_);Ki=(m.flags&131072)!==0}else Ki=!1,rr&&(g.flags&1048576)!==0&&WI(g,kx,g.index);switch(g.lanes=0,g.tag){case 16:e:{var M=g.pendingProps;if(m=Nm(g.elementType),g.type=m,typeof m=="function")tA(m)?(M=Am(m,M),g.tag=1,g=uz(null,g,m,M,_)):(g.tag=0,g=$A(null,g,m,M,_));else{if(m!=null){var F=m.$$typeof;if(F===A){g.tag=11,g=rz(null,g,m,M,_);break e}else if(F===k){g.tag=14,g=iz(null,g,m,M,_);break e}}throw g=R(m)||m,Error(r(306,g,""))}}return g;case 0:return $A(m,g,g.type,g.pendingProps,_);case 1:return M=g.type,F=Am(M,g.pendingProps),uz(m,g,M,F,_);case 3:e:{if(je(g,g.stateNode.containerInfo),m===null)throw Error(r(387));M=g.pendingProps;var I=g.memoizedState;F=I.element,gA(m,g),Dx(g,M,null,_);var te=g.memoizedState;if(M=te.cache,Cd(g,qi,M),M!==I.cache&&uA(g,[qi],_,!0),jx(),M=te.element,I.isDehydrated)if(I={element:M,isDehydrated:!1,cache:te.cache},g.updateQueue.baseState=I,g.memoizedState=I,g.flags&256){g=dz(m,g,M,_);break e}else if(M!==F){F=Uo(Error(r(424)),g),Cx(F),g=dz(m,g,M,_);break e}else for(m=g.stateNode.containerInfo,m.nodeType===9?m=m.body:m=m.nodeName==="HTML"?m.ownerDocument.body:m,Jr=Go(m.firstChild),Ha=g,rr=!0,Nd=null,$o=!0,_=s5(g,null,M,_),g.child=_;_;)_.flags=_.flags&-3|4096,_=_.sibling;else{if(vm(),M===F){g=ru(m,g,_);break e}Va(m,g,M,_)}g=g.child}return g;case 26:return Pw(m,g),m===null?(_=CU(g.type,null,g.pendingProps,null))?g.memoizedState=_:rr||(_=g.type,m=g.pendingProps,M=Kw(pe.current).createElement(_),M[Pn]=g,M[cr]=m,Ga(M,_,m),Ve(M),g.stateNode=M):g.memoizedState=CU(g.type,m.memoizedProps,g.pendingProps,m.memoizedState),null;case 27:return ce(g),m===null&&rr&&(M=g.stateNode=SU(g.type,g.pendingProps,pe.current),Ha=g,$o=!0,F=Jr,zd(g.type)?(TT=F,Jr=Go(M.firstChild)):Jr=F),Va(m,g,g.pendingProps.children,_),Pw(m,g),m===null&&(g.flags|=4194304),g.child;case 5:return m===null&&rr&&((F=M=Jr)&&(M=loe(M,g.type,g.pendingProps,$o),M!==null?(g.stateNode=M,Ha=g,Jr=Go(M.firstChild),$o=!1,F=!0):F=!1),F||kd(g)),ce(g),F=g.type,I=g.pendingProps,te=m!==null?m.memoizedProps:null,M=I.children,NT(F,I)?M=null:te!==null&&NT(F,te)&&(g.flags|=32),g.memoizedState!==null&&(F=SA(m,g,Sse,null,null,_),Jx._currentValue=F),Pw(m,g),Va(m,g,M,_),g.child;case 6:return m===null&&rr&&((m=_=Jr)&&(_=coe(_,g.pendingProps,$o),_!==null?(g.stateNode=_,Ha=g,Jr=null,m=!0):m=!1),m||kd(g)),null;case 13:return hz(m,g,_);case 4:return je(g,g.stateNode.containerInfo),M=g.pendingProps,m===null?g.child=Cm(g,null,M,_):Va(m,g,M,_),g.child;case 11:return rz(m,g,g.type,g.pendingProps,_);case 7:return Va(m,g,g.pendingProps,_),g.child;case 8:return Va(m,g,g.pendingProps.children,_),g.child;case 12:return Va(m,g,g.pendingProps.children,_),g.child;case 10:return M=g.pendingProps,Cd(g,g.type,M.value),Va(m,g,M.children,_),g.child;case 9:return F=g.type._context,M=g.pendingProps.children,_m(g),F=$a(F),M=M(F),g.flags|=1,Va(m,g,M,_),g.child;case 14:return iz(m,g,g.type,g.pendingProps,_);case 15:return az(m,g,g.type,g.pendingProps,_);case 19:return fz(m,g,_);case 31:return Pse(m,g,_);case 22:return sz(m,g,_,g.pendingProps);case 24:return _m(g),M=$a(qi),m===null?(F=mA(),F===null&&(F=Hr,I=dA(),F.pooledCache=I,I.refCount++,I!==null&&(F.pooledCacheLanes|=_),F=I),g.memoizedState={parent:M,cache:F},pA(g),Cd(g,qi,F)):((m.lanes&_)!==0&&(gA(m,g),Dx(g,null,null,_),jx()),F=m.memoizedState,I=g.memoizedState,F.parent!==M?(F={parent:M,cache:M},g.memoizedState=F,g.lanes===0&&(g.memoizedState=g.updateQueue.baseState=F),Cd(g,qi,M)):(M=I.cache,Cd(g,qi,M),M!==F.cache&&uA(g,[qi],_,!0))),Va(m,g,g.pendingProps.children,_),g.child;case 29:throw g.pendingProps}throw Error(r(156,g.tag))}function iu(m){m.flags|=4}function QA(m,g,_,M,F){if((g=(m.mode&32)!==0)&&(g=!1),g){if(m.flags|=16777216,(F&335544128)===F)if(m.stateNode.complete)m.flags|=8192;else if(Hz())m.flags|=8192;else throw km=gw,fA}else m.flags&=-16777217}function gz(m,g){if(g.type!=="stylesheet"||(g.state.loading&4)!==0)m.flags&=-16777217;else if(m.flags|=16777216,!PU(g))if(Hz())m.flags|=8192;else throw km=gw,fA}function Dw(m,g){g!==null&&(m.flags|=4),m.flags&16384&&(g=m.tag!==22?At():536870912,m.lanes|=g,Rp|=g)}function zx(m,g){if(!rr)switch(m.tailMode){case"hidden":g=m.tail;for(var _=null;g!==null;)g.alternate!==null&&(_=g),g=g.sibling;_===null?m.tail=null:_.sibling=null;break;case"collapsed":_=m.tail;for(var M=null;_!==null;)_.alternate!==null&&(M=_),_=_.sibling;M===null?g||m.tail===null?m.tail=null:m.tail.sibling=null:M.sibling=null}}function ei(m){var g=m.alternate!==null&&m.alternate.child===m.child,_=0,M=0;if(g)for(var F=m.child;F!==null;)_|=F.lanes|F.childLanes,M|=F.subtreeFlags&65011712,M|=F.flags&65011712,F.return=m,F=F.sibling;else for(F=m.child;F!==null;)_|=F.lanes|F.childLanes,M|=F.subtreeFlags,M|=F.flags,F.return=m,F=F.sibling;return m.subtreeFlags|=M,m.childLanes=_,g}function Dse(m,g,_){var M=g.pendingProps;switch(aA(g),g.tag){case 16:case 15:case 0:case 11:case 7:case 8:case 12:case 9:case 14:return ei(g),null;case 1:return ei(g),null;case 3:return _=g.stateNode,M=null,m!==null&&(M=m.memoizedState.cache),g.memoizedState.cache!==M&&(g.flags|=2048),eu(qi),de(),_.pendingContext&&(_.context=_.pendingContext,_.pendingContext=null),(m===null||m.child===null)&&(wp(g)?iu(g):m===null||m.memoizedState.isDehydrated&&(g.flags&256)===0||(g.flags|=1024,oA())),ei(g),null;case 26:var F=g.type,I=g.memoizedState;return m===null?(iu(g),I!==null?(ei(g),gz(g,I)):(ei(g),QA(g,F,null,M,_))):I?I!==m.memoizedState?(iu(g),ei(g),gz(g,I)):(ei(g),g.flags&=-16777217):(m=m.memoizedProps,m!==M&&iu(g),ei(g),QA(g,F,m,M,_)),null;case 27:if(Se(g),_=pe.current,F=g.type,m!==null&&g.stateNode!=null)m.memoizedProps!==M&&iu(g);else{if(!M){if(g.stateNode===null)throw Error(r(166));return ei(g),null}m=J.current,wp(g)?XI(g):(m=SU(F,M,_),g.stateNode=m,iu(g))}return ei(g),null;case 5:if(Se(g),F=g.type,m!==null&&g.stateNode!=null)m.memoizedProps!==M&&iu(g);else{if(!M){if(g.stateNode===null)throw Error(r(166));return ei(g),null}if(I=J.current,wp(g))XI(g);else{var te=Kw(pe.current);switch(I){case 1:I=te.createElementNS("http://www.w3.org/2000/svg",F);break;case 2:I=te.createElementNS("http://www.w3.org/1998/Math/MathML",F);break;default:switch(F){case"svg":I=te.createElementNS("http://www.w3.org/2000/svg",F);break;case"math":I=te.createElementNS("http://www.w3.org/1998/Math/MathML",F);break;case"script":I=te.createElement("div"),I.innerHTML=" + From 1bb67588077fb0587c592542a33a4072f4512758 Mon Sep 17 00:00:00 2001 From: maziggy Date: Wed, 18 Feb 2026 16:53:16 +0100 Subject: [PATCH 8/8] Updated CHANGELOG --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 456c3b283..efe5f50bc 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -20,7 +20,7 @@ All notable changes to Bambuddy will be documented in this file. - **Usage Tracking Wrong Spool on Dual-Nozzle / Multi-AMS Printers** ([#364](https://github.com/maziggy/bambuddy/issues/364)) — On H2C, H2D Pro, and other dual-nozzle printers with multiple AMS units, the usage tracker attributed filament consumption to the wrong spools. The MQTT `mapping` field — a per-print array that maps slicer filament slots to physical AMS trays — was preserved in state but never parsed or used. The tracker fell back to `slot_id - 1` as the global tray ID, which is incorrect when AMS hardware IDs differ from sequential indices (e.g., AMS-HT units with ID 128). Now decodes the MQTT mapping field from its snow encoding (`ams_hw_id * 256 + local_slot`) into bambuddy global tray IDs and uses it as a universal mapping source — working for all printer models and all print sources (slicer, queue, reprint) without relying on `tray_now` disambiguation. - **npm audit: suppress moderate ajv ReDoS finding** — Added `audit-level=high` to `frontend/.npmrc` so `npm audit` exits cleanly. The ajv@6 ReDoS (GHSA-2g4f-4pwh-qvx6) is a transitive dependency of eslint@9 with no patched v6 release; ajv@8 override breaks eslint. The vulnerability requires crafted `$data` schema input — not an attack vector in a linting config. - **Spool Form Allows Empty Brand & Subtype** ([#417](https://github.com/maziggy/bambuddy/issues/417)) — The spool add/edit modal did not require Brand or Subtype fields, allowing spools to be saved without them. When such a spool was assigned to an AMS slot, the `tray_sub_brands` sent to the printer was incomplete (e.g., just "PETG" instead of "PETG Basic"), causing BambuStudio to not recognize the filament profile. Brand and Subtype are now mandatory fields with validation errors shown on submit. -- **Open in Slicer Fails When Authentication Enabled** ([#433](https://github.com/maziggy/bambuddy/issues/433)) — The "Open in Slicer" buttons for BambuStudio and OrcaSlicer failed with "importing failed" when authentication was enabled. Slicer protocol handlers (`bambustudio://`, `orcaslicer://`) launch the slicer app which fetches the file via HTTP — but cannot send authentication headers, so the global auth middleware returned 401. Additionally, the URL format was wrong on Linux (used the macOS-only `bambustudioopen://` scheme instead of `bambustudio://open?file=`). Fixed with short-lived, single-use download tokens: the frontend fetches a token via an authenticated POST endpoint, then builds a `/dl/{token}/{filename}` URL that the slicer can access without auth headers. The token is validated server-side (5-minute expiry, single-use). Platform-specific URL formats now match the actual slicer source code: macOS uses `bambustudioopen://` with URL encoding, Windows/Linux use `bambustudio://open?file=`, and OrcaSlicer uses `orcaslicer://open?file=`. +- **Open in Slicer Fails When Authentication Enabled** ([#421](https://github.com/maziggy/bambuddy/issues/421)) — The "Open in Slicer" buttons for BambuStudio and OrcaSlicer failed with "importing failed" when authentication was enabled. Slicer protocol handlers (`bambustudio://`, `orcaslicer://`) launch the slicer app which fetches the file via HTTP — but cannot send authentication headers, so the global auth middleware returned 401. Additionally, the URL format was wrong on Linux (used the macOS-only `bambustudioopen://` scheme instead of `bambustudio://open?file=`). Fixed with short-lived, single-use download tokens: the frontend fetches a token via an authenticated POST endpoint, then builds a `/dl/{token}/{filename}` URL that the slicer can access without auth headers. The token is validated server-side (5-minute expiry, single-use). Platform-specific URL formats now match the actual slicer source code: macOS uses `bambustudioopen://` with URL encoding, Windows/Linux use `bambustudio://open?file=`, and OrcaSlicer uses `orcaslicer://open?file=`. ### Changed - **Filament Catalog API Renamed** ([#427](https://github.com/maziggy/bambuddy/issues/427)) — Renamed `/api/v1/filaments/` to `/api/v1/filament-catalog/` to avoid confusion with the inventory spools page (labeled "Filament" in the UI). The old endpoint managed material type definitions (cost, temperature, density), not physical spools — the shared name caused users to expect the API to return their spool inventory.