{% load dlux_tags %}

{{ DLUX_STRINGS.ocr_title|default:'Extracted text (OCR)' }}

{% if ocr_result %} {% if ocr_active %}{% endif %} {% if ocr_result.status == 'done' %}{{ DLUX_STRINGS.ocr_status_done|default:'Done' }}{% elif ocr_result.status == 'failed' %}{{ DLUX_STRINGS.ocr_status_failed|default:'Failed' }}{% elif ocr_result.status == 'running' %}{{ DLUX_STRINGS.ocr_status_running|default:'Running' }}{% elif ocr_result.status == 'skipped' %}{{ DLUX_STRINGS.ocr_status_skipped|default:'Skipped' }}{% else %}{{ DLUX_STRINGS.ocr_status_pending|default:'Queued' }}{% endif %} {% endif %} {% if ocr_can_run %} {% csrf_token %} {% endif %}
{% if not ocr_enabled %}

{{ DLUX_STRINGS.ocr_disabled|default:'OCR is not enabled.' }}

{% endif %} {% if not ocr_result %}

{{ DLUX_STRINGS.ocr_none|default:'No text has been read from this file yet.' }}

{% else %} {% if ocr_result.status == 'pending' and ocr_result.error %}

{{ DLUX_STRINGS.ocr_unavailable|default:'The OCR service is unavailable right now; it will retry automatically.' }}

{% endif %} {% if ocr_result.status == 'failed' or ocr_result.status == 'skipped' %}

{{ ocr_result.error }}

{% endif %} {% if ocr_result.status == 'done' %}
{{ DLUX_STRINGS.ocr_engine|default:'Engine' }}
{{ ocr_result.engine }} {{ ocr_result.engine_version }}{% if ocr_result.model_version %} ยท {{ ocr_result.model_version }}{% endif %}
{{ DLUX_STRINGS.ocr_pages|default:'Pages' }}
{{ ocr_result.page_count }}
{{ DLUX_STRINGS.ocr_duration|default:'Duration' }}
{{ ocr_result.duration_ms|default:0 }} ms
{% if ocr_result.mean_confidence is not None %}
{{ DLUX_STRINGS.ocr_confidence|default:'Mean confidence' }}
{% widthratio ocr_result.mean_confidence 1 100 %}%
{% endif %}
{{ DLUX_STRINGS.ocr_finished|default:'Finished' }}
{{ ocr_result.finished_at|date:'Y-m-d H:i' }}
{% if ocr_result.error %}

{{ ocr_result.error }}

{% endif %} {% if ocr_result.text %}
{{ ocr_result.text }}
{{ ocr_result.markdown }}

{{ DLUX_STRINGS.ocr_machine_note|default:'Machine-read text may contain errors; check the original file.' }}

{% else %}

{{ DLUX_STRINGS.ocr_empty_text|default:'No text was found in the file.' }}

{% endif %} {% endif %} {% endif %}