<!-- $Id: configServerForm.vue,v 1 2026/04/30 15:36:40 qvarin Exp $ -->

<template>
  <div class="row">
    <div class="row">
      <div class="colonne4">
        <label for="ocr_server_url">
          {{ messages.get("ocr", "admin_ocr_config_server_url") }}
          <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_server_url" id="ocr_server_url" required="" v-model.trim="url" />
      </div>
    </div>
    <div class="row">
      <div class="colonne4">
        <label for="ocr_server_salt">
          {{ messages.get("ocr", "admin_ocr_config_server_salt") }}
          <span :aria-label="messages.get('common', 'required_message')">
            {{ messages.get("common", "required_symbol") }}
          </span>
        </label>
      </div>
      <div class="colonne8">
        <input type="password" class="saisie-80em" name="ocr_server_salt" id="ocr_server_salt" required="" v-model.trim="salt" autocomplete="off" />
        <span class="fa fa-eye" onclick="toggle_password(this, 'ocr_server_salt');"></span>
      </div>
    </div>
    <div class="row">
      <div class="colonne4">
        <label for="ocr_server_token">
          {{ messages.get("ocr", "admin_ocr_config_server_token") }}
          <span :aria-label="messages.get('common', 'required_message')">
            {{ messages.get("common", "required_symbol") }}
          </span>
        </label>
      </div>
      <div class="colonne8">
        <input type="password" class="saisie-80em" name="ocr_server_token" id="ocr_server_token" required="" v-model.trim="token" autocomplete="off" />
        <span class="fa fa-eye" onclick="toggle_password(this, 'ocr_server_token');"></span>
      </div>
    </div>
  </div>
</template>

<script>
export default {
  props: {
    config: {
      type: Object,
      default: () => ({}),
    },
  },
  computed: {
    url: {
      get: function () {
        return this.config.url ?? "";
      },
      set: function (value) {
        this.emitConfig({ url: value });
      },
    },
    salt: {
      get: function () {
        return this.config.salt ?? "";
      },
      set: function (value) {
        this.emitConfig({ salt: value });
      },
    },
    token: {
      get: function () {
        return this.config.token ?? "";
      },
      set: function (value) {
        this.emitConfig({ token: value });
      },
    },
  },
  methods: {
    emitConfig(patch) {
      this.$emit("update:config", {
        url: this.url,
        salt: this.salt,
        token: this.token,
        ...patch,
      });
    },
  },
};
</script>
