{% set etc_aliases__tpl_dependent_recipients = {} %}
{% if (etc_aliases__register_dependent_recipients|d() and etc_aliases__register_dependent_recipients.content|d()) %}
{%   set _ = etc_aliases__tpl_dependent_recipients.update(etc_aliases__register_dependent_recipients.content | b64decode | trim | from_json) %}
{% endif %}
{% if etc_aliases__dependent_recipients %}
{%   set etc_aliases__tpl_flattened_recipients = lookup('flattened', etc_aliases__dependent_recipients) %}
{%   for element in ([ etc_aliases__tpl_flattened_recipients ] if etc_aliases__tpl_flattened_recipients is mapping else etc_aliases__tpl_flattened_recipients) %}
{%     if element.role|d() and element.config|d() %}
{%       if element.state|d('present') not in [ 'ignore', 'absent' ] %}
{%         set flattened_config = lookup('flattened', element.config) %}
{%         set _ = etc_aliases__tpl_dependent_recipients.update({
  element.role: ([ flattened_config ] if flattened_config is mapping else flattened_config)
}) %}
{%       elif element.state|d('present') == 'absent' %}
{%         set _ = etc_aliases__tpl_dependent_recipients.pop(element.role, None) %}
{%       endif %}
{%     else %}
{%       for role, config in element.items() %}
{%         set flattened_config = lookup('flattened', config) %}
{%         set _ = etc_aliases__tpl_dependent_recipients.update({
  role: ([ flattened_config ] if flattened_config is mapping else flattened_config)
}) %}
{%       endfor %}
{%     endif %}
{%   endfor %}
{% endif %}
{{ etc_aliases__tpl_dependent_recipients | to_nice_json }}
