DZURLJKGFFIAG4KUZTLCURERBXHFWNSNUFYYB7PXCXFUJWPIHWZQC 5ZUW64LB2SW6TANPRVHFGZ2HW2WUWO3HNG7NCRNCE3LIGXCORQGQC SML4CPUO62JIWYGYWZGSWFVAMRRBNE2ECK7ATUSFPKC6XICKVIMAC 6W73J6WJQHALRF4ZLBJ4JH6H7UYT74KFPKFH537T2BRW2G6MCLRQC 4667MSQANSFBWQVT7EDH7ZGWYVGNPCVLQRIXOECHY2BMS7V4SYUQC IUHUM6OZ5KYEAYQCIYNG5Q4QLQRAQNMBWKYGV2ZDJFNY5W4DOUNQC TPANU3OQD53OXF5IGXJELSD5FFMY7KHDSVZTPSUG3VZBUAPNPK6QC YBJGFUTFTV4SBPUVC6LBETGMPMLS47LSQPL3OJAAPH7BROBQD7DQC ETAXJ5YIOUH75V6ZKHUGQWTRWIRZVJAUG5LYXYZEJDS7SXPNEZSAC NYBASAG4KWZNPSFBXWQJWQRBCGT7C5B24IYO2IBCXCE2WGJQJOEQC CWCD3MTTPIKDNDPLRTLU4S6JQ35YYRDW34NW25DQ5KHJYMQP3SNAC I27QGYUJ66RJXCXQPY2MMSODRGL3SB7KO4UOGQSK2WRFG7LG23GAC 746WXWS34DYNQ4CEFWBXDFWPPDY7CNR7TJGLTCK6UEAG7ZXBYCIQC RELTAIDEZ4Y2SC2WQROQ4IEJO5BVPULTVLLJ4BA23WE5FVT5QOQAC LSAQ6ZM2NELU3FIWKEFBOXKVLSZS2ZOK2PHPHJRWPVZ5CVILSUYQC import { X, Play, Pause, Upload, AlertCircle } from 'lucide-react';import WaveSurfer from 'wavesurfer.js';import Spectrogram from 'wavesurfer.js/dist/plugins/spectrogram.esm.js';import Timeline from 'wavesurfer.js/dist/plugins/timeline.esm.js';import Regions from 'wavesurfer.js/dist/plugins/regions.esm.js';import Button from './ui/button';import type { File as FileType } from '../types/file';
import { AlertCircle, Pause, Play, Upload, X } from "lucide-react";import React, { useCallback, useEffect, useRef, useState } from "react";import WaveSurfer from "wavesurfer.js";import Regions from "wavesurfer.js/dist/plugins/regions.esm.js";import Spectrogram from "wavesurfer.js/dist/plugins/spectrogram.esm.js";import Timeline from "wavesurfer.js/dist/plugins/timeline.esm.js";import type { File as FileType } from "../types/file";import Button from "./ui/button";
wavesurfer.on('error', (error) => {console.error('WaveSurfer error:', error);setState(prev => ({...prev,audioError: 'Failed to load audio file',audioLoading: false
wavesurfer.on("error", (error) => {console.error("WaveSurfer error:", error);setState(prev => ({...prev,audioError: "Failed to load audio file",audioLoading: false,
console.error('Error loading online file:', error);setState(prev => ({...prev,audioError: 'Failed to load audio file from server',audioLoading: false
console.error("Error loading online file:", error);setState(prev => ({...prev,audioError: "Failed to load audio file from server",audioLoading: false,
console.error('Error loading local file:', error);setState(prev => ({...prev,audioError: 'Failed to load local audio file',audioLoading: false
console.error("Error loading local file:", error);setState(prev => ({...prev,audioError: "Failed to load local audio file",audioLoading: false,
console.error('Error fetching selections:', error);setState(prev => ({...prev,selectionsError: 'Failed to load selections',selectionsLoading: false
console.error("Error fetching selections:", error);setState(prev => ({...prev,selectionsError: "Failed to load selections",selectionsLoading: false,
const shortName = species.name.length > 15 ? species.name.substring(0, 15) + '...' : species.name;const callTypeText = species.callTypes.length > 0
const shortName = species.name.length > 15 ? species.name.substring(0, 15) + "..." : species.name;const callTypeText = species.callTypes.length > 0
const region = (state.regionsPlugin as { addRegion: (config: unknown) => { element?: HTMLElement } }).addRegion({start: regionData.startTime,end: regionData.endTime,color: regionData.color + '25', // Slightly more opacityresize: false,drag: false,});
const region = (state.regionsPlugin as { addRegion: (config: unknown) => { element?: HTMLElement } }).addRegion({start: regionData.startTime,end: regionData.endTime,color: regionData.color + "25", // Slightly more opacityresize: false,drag: false,},);
{state.fileContext ? (<>{state.fileContext.dataset && `Dataset: ${state.fileContext.dataset.name}`}{state.fileContext.dataset && state.fileContext.location && ' • '}{state.fileContext.location && `Location: ${state.fileContext.location.name}`}{(state.fileContext.dataset || state.fileContext.location) && state.fileContext.cluster && ' • '}{state.fileContext.cluster && `Cluster: ${state.fileContext.cluster.name}`}</>) : state.fileContextLoading ? ('Loading context...') : ('Audio File')}
{state.fileContext? (<>{state.fileContext.dataset && `Dataset: ${state.fileContext.dataset.name}`}{state.fileContext.dataset && state.fileContext.location && " • "}{state.fileContext.location && `Location: ${state.fileContext.location.name}`}{(state.fileContext.dataset || state.fileContext.location) && state.fileContext.cluster && " • "}{state.fileContext.cluster && `Cluster: ${state.fileContext.cluster.name}`}</>): state.fileContextLoading? ("Loading context..."): ("Audio File")}
value={state.selectedFilterId || 'all'}onChange={(e) => setState(prev => ({...prev,selectedFilterId: e.target.value === 'all' ? null : e.target.value}))}
value={state.selectedFilterId || "all"}onChange={(e) =>setState(prev => ({...prev,selectedFilterId: e.target.value === "all" ? null : e.target.value,}))}