def decls(hub, name, state, sls_ref):
    """
    Resolve and state formatting and data insertion
    """
    for id_ in state:
        if not isinstance(state[id_], dict):
            if id_ == '__extend__':
                continue
            if id_ == '__exclude__':
                continue
            if isinstance(state[id_], str):
                if '.' in state[id_]:
                    comps = state[id_].split('.')
                    state[id_] = {'__sls__': sls_ref, comps[0]: [comps[1]]}
                    continue
            hub.idem.RUNS[name]['errors'].append(
                f'ID {id_} in SLS {sls_ref} is not a dictionary')
            continue
        skeys = set()
        for key in list(state[id_]):
            if key.startswith('_'):
                continue
            if not isinstance(state[id_][key], list):
                continue
            if '.' in key:
                comps = key.split('.')
                ref = '.'.join(comps[:-1])
                if ref in skeys:
                    hub.idem.RUNS[name]['errors'].append(
                        f'ID "{id_}" in SLS "{sls_ref}" contains multiple state declarations of the same type'
                        )
                    continue
                state[id_][ref] = state[id_].pop(key)
                state[id_][ref].append(comps[-1])
                skeys.add(ref)
                continue
            skeys.add(key)
        if '__sls__' not in state[id_]:
            state[id_]['__sls__'] = sls_ref
