# Path: mugen/video/sources/Source.py
# class SourceList(WeightableList):
#     """
#     A list of sources
#     """
# 
#     def __init__(
#         self,
#         sources: Optional[List[Union[Source, "SourceList"]]] = None,
#         *,
#         weights: List[float] = None,
#         **kwargs,
#     ):
#         """
#         Parameters
#         ----------
#         sources
#             A list of Sources
# 
#         weights
#             weights to apply to top-most level sources
#         """
#         super().__init__(sources, **kwargs)
# 
#         if weights:
#             for source, weight in zip(sources, weights):
#                 source.weight = weight
# 
#     def __repr__(self):
#         source_reprs = []
#         for source in self:
#             if isinstance(source, SourceList):
#                 source_repr = source.list_repr()
#             else:
#                 source_repr = repr(source)
# 
#             source_reprs.append(source_repr)
# 
#         return f"<{super().pretty_repr(source_reprs)}>"
# 
#     def list_repr(self):
#         """
#         Repr for use in lists
#         """
#         return f"<{self.__class__.__name__} ({len(self)}): weight: {self.weight}>"
# 
#     def weight_stats(self) -> str:
#         """
#         Returns
#         -------
#         A string describing the weights for the sources
#         """
#         flattened_sources = self.flatten()
# 
#         string = ""
#         for index, (source, weight) in enumerate(
#             zip(flattened_sources, flattened_sources.weight_percentages)
#         ):
#             string += f"{source.name}: {weight:.2f}%"
#             if index != len(flattened_sources) - 1:
#                 string += ", \n"
# 
#         return string
# 
# Path: mugen/video/sources/SourceSampler.py
# class SourceSampler:
#     """
#     A set of content sources for sampling video segments
#     """
# 
#     sources: SourceList
# 
#     def __init__(self, sources: Union[SourceList, list]):
#         """
#         video_segments
# 
#         Parameters
#         ----------
#         sources
#             An arbitrarily nested list of sources. Sources will be flattened internally.
#             e.g. [S1, S2, [S3, S4]] -> [S1, S2, S3, S4]
#         """
#         if not isinstance(sources, SourceList):
#             sources = SourceList(sources)
# 
#         self.sources = sources.flatten()
# 
#     def sample(self, duration: float) -> Segment:
#         """
#         Randomly samples a segment with the specified duration
# 
#         Parameters
#         ----------
#         duration
#             duration of the sample
# 
#         Returns
#         -------
#         A randomly sampled segment with the specified duration
#         """
#         selected_source = choice(self.sources, p=self.sources.normalized_weights)
#         sample = selected_source.sample(duration)
# 
#         return sample
# 
# Path: tests/unit/video/sources/test_ColorSource.py
# def get_black_source() -> ColorSource:
#     return ColorSource("black")
# 
# def get_orange_source() -> ColorSource:
#     return ColorSource("#FFA500")
# 
# def get_purple_source() -> ColorSource:
#     return ColorSource("#800080")
# 
# def get_white_source() -> ColorSource:
#     return ColorSource("white")


import pytest
from mugen.video.sources.Source import SourceList
from mugen.video.sources.SourceSampler import SourceSampler
from tests.unit.video.sources.test_ColorSource import (
    get_black_source,
    get_orange_source,
    get_purple_source,
    get_white_source,
)



def source_sampler(weights) -> SourceSampler:
    return SourceSampler(
        SourceList(
            [
                get_black_source(),
                get_white_source(),
                get_orange_source(),
                get_purple_source(),

# Path: mugen/video/sources/Source.py
# class SourceList(WeightableList):
#     """
#     A list of sources
#     """
# 
#     def __init__(
#         self,
#         sources: Optional[List[Union[Source, "SourceList"]]] = None,
#         *,
#         weights: List[float] = None,
#         **kwargs,
#     ):
#         """
#         Parameters
#         ----------
#         sources
#             A list of Sources
# 
#         weights
#             weights to apply to top-most level sources
#         """
#         super().__init__(sources, **kwargs)
# 
#         if weights:
#             for source, weight in zip(sources, weights):
#                 source.weight = weight
# 
#     def __repr__(self):
#         source_reprs = []
#         for source in self:
#             if isinstance(source, SourceList):
#                 source_repr = source.list_repr()
#             else:
#                 source_repr = repr(source)
# 
#             source_reprs.append(source_repr)
# 
#         return f"<{super().pretty_repr(source_reprs)}>"
# 
#     def list_repr(self):
#         """
#         Repr for use in lists
#         """
#         return f"<{self.__class__.__name__} ({len(self)}): weight: {self.weight}>"
# 
#     def weight_stats(self) -> str:
#         """
#         Returns
#         -------
#         A string describing the weights for the sources
#         """
#         flattened_sources = self.flatten()
# 
#         string = ""
#         for index, (source, weight) in enumerate(
#             zip(flattened_sources, flattened_sources.weight_percentages)
#         ):
#             string += f"{source.name}: {weight:.2f}%"
#             if index != len(flattened_sources) - 1:
#                 string += ", \n"
# 
#         return string
# 
# Path: mugen/video/sources/SourceSampler.py
# class SourceSampler:
#     """
#     A set of content sources for sampling video segments
#     """
# 
#     sources: SourceList
# 
#     def __init__(self, sources: Union[SourceList, list]):
#         """
#         video_segments
# 
#         Parameters
#         ----------
#         sources
#             An arbitrarily nested list of sources. Sources will be flattened internally.
#             e.g. [S1, S2, [S3, S4]] -> [S1, S2, S3, S4]
#         """
#         if not isinstance(sources, SourceList):
#             sources = SourceList(sources)
# 
#         self.sources = sources.flatten()
# 
#     def sample(self, duration: float) -> Segment:
#         """
#         Randomly samples a segment with the specified duration
# 
#         Parameters
#         ----------
#         duration
#             duration of the sample
# 
#         Returns
#         -------
#         A randomly sampled segment with the specified duration
#         """
#         selected_source = choice(self.sources, p=self.sources.normalized_weights)
#         sample = selected_source.sample(duration)
# 
#         return sample
# 
# Path: tests/unit/video/sources/test_ColorSource.py
# def get_black_source() -> ColorSource:
#     return ColorSource("black")
# 
# def get_orange_source() -> ColorSource:
#     return ColorSource("#FFA500")
# 
# def get_purple_source() -> ColorSource:
#     return ColorSource("#800080")
# 
# def get_white_source() -> ColorSource:
#     return ColorSource("white")


# Path: tests/unit/video/sources/test_SourceSampler.py
import pytest
from mugen.video.sources.Source import SourceList
from mugen.video.sources.SourceSampler import SourceSampler
from tests.unit.video.sources.test_ColorSource import (
    get_black_source,
    get_orange_source,
    get_purple_source,
    get_white_source,
)




def source_sampler(weights) -> SourceSampler:
    return SourceSampler(
        SourceList(
            [
                get_black_source(),
                get_white_source(),
                get_orange_source(),
                get_purple_source(),

            ],