{#
  AAE Form Calculation — a visible display box plus a hidden real <input>
  carrying the computed value, so the total submits/stores/emails like any
  other field. lib/calculation.js writes both; inc/Forms/Formula.php recomputes
  server-side and the Validator rejects a tampered value.

  readonly (not disabled) — a disabled control wouldn't submit at all.
  name falls back to _cssid, then element id, same as the text-family Input.
#}
{% set classes = ['aae-a-form-calculation', 'e-atomic-element', base_styles.base | default('')] | merge(settings.classes | default([])) | join(' ') | trim %}
{% set input_name = settings.name is defined and settings.name is not empty ? settings.name : (settings._cssid is defined and settings._cssid is not empty ? settings._cssid : id) %}
{% set decimals = settings.decimals is defined and settings.decimals is not empty ? settings.decimals : 2 %}
{% set empty_text = settings.empty_text is defined and settings.empty_text is not empty ? settings.empty_text : '—' %}

<div
    class="{{ classes }} {{ editor_classes | default('') }}"
    data-id="{{ id }}"
    data-element_type="{{ type }}"
    data-e-type="{{ type }}"
    data-interaction-id="{{ interaction_id | default(id) }}"
    data-aae-calc="{{ settings.formula | default('') | e('html_attr') }}"
    data-aae-calc-decimals="{{ decimals }}"
    data-aae-calc-empty="{{ empty_text | e('html_attr') }}"
    {% if settings.prefix is defined and settings.prefix is not empty %}data-aae-calc-prefix="{{ settings.prefix | e('html_attr') }}"{% endif %}
    {% if settings.suffix is defined and settings.suffix is not empty %}data-aae-calc-suffix="{{ settings.suffix | e('html_attr') }}"{% endif %}
    {{ editor_attributes | default('') | raw }}>
    <span class="aae-a-form-calc-display" aria-live="polite">{{ empty_text }}</span>
    <input
        class="aae-a-form-calc-native"
        type="text"
        inputmode="decimal"
        readonly
        tabindex="-1"
        aria-hidden="true"
        name="{{ input_name | e('html_attr') }}"
        value=""
        data-id="{{ id }}"
        {% if settings._cssid is defined and settings._cssid is not empty %}id="{{ settings._cssid | e('html_attr') }}"{% endif %}
        {% if settings.attributes is defined and settings.attributes is not empty %}{{ settings.attributes | raw }}{% endif %}
    />
</div>
