<template>
  <div class="row">
    <div class="row">
      <div class="colonne4">
        <label for="ocr_path" aria-describedby="path-description">
          {{ messages.get("ocr", "admin_ocr_config_path") }}
          <span :aria-label="messages.get('common', 'required_message')">
            {{ messages.get("common", "required_symbol") }}
          </span>
        </label>
      </div>
      <div class="colonne8">
        <input type="text" class="saisie-80em" name="ocr_path" id="ocr_path" required="" placeholder="/usr/bin/ocrmypdf" v-model.trim="values.path" />
      </div>
    </div>
  </div>
</template>

<script>
export default {
  props: {
    config: {
      type: Object,
      default: () => ({}),
    },
  },
  data: function() {
    return {
      values: {
        path: "",
      },
    };
  },
  mounted() {
    if (this.config.path) {
      this.values.path = this.config.path;
    } else {
      this.values.path = "/usr/bin/ocrmypdf";
      this.$emit("update:config", this.values);
    }
  },
  watch: {
    values: function (_, newConfig) {
      this.$emit("update:config", newConfig);
    }
  },
};
</script>
