# Path: il2fb/ds/airbridge/typing.py



from contextlib import contextmanager
from ddict import DotAccessDict
from .typing import StringOrPath
import yaml
StateLoader.add_constructor(
    yaml.resolver.BaseResolver.DEFAULT_MAPPING_TAG,
    _construct_mapping,
)


class StateDumper(yaml.Dumper):
    pass


def _dict_representer(dumper, data):
    return dumper.represent_mapping(
        yaml.resolver.BaseResolver.DEFAULT_MAPPING_TAG,
        data.items(),
    )


StateDumper.add_representer(DotAccessDict, _dict_representer)


def load_state(path: StringOrPath) -> DotAccessDict:
    try:
        with open(path, 'r') as f:
            data = f.read()
    except FileNotFoundError:
        data = None

    return yaml.load(data, Loader=StateLoader) if data else DotAccessDict()



# Path: il2fb/ds/airbridge/typing.py



# Path: il2fb/ds/airbridge/state.py
from contextlib import contextmanager
from ddict import DotAccessDict
from .typing import StringOrPath
import yaml

StateLoader.add_constructor(
    yaml.resolver.BaseResolver.DEFAULT_MAPPING_TAG,
    _construct_mapping,
)


class StateDumper(yaml.Dumper):
    pass


def _dict_representer(dumper, data):
    return dumper.represent_mapping(
        yaml.resolver.BaseResolver.DEFAULT_MAPPING_TAG,
        data.items(),
    )


StateDumper.add_representer(DotAccessDict, _dict_representer)


def load_state(path: StringOrPath) -> DotAccessDict:
    try:
        with open(path, 'r') as f:
            data = f.read()
    except FileNotFoundError:
        data = None

    return yaml.load(data, Loader=StateLoader) if data else DotAccessDict()



def save_state(state: DotAccessDict, path: StringOrPath) -> None: