<form class="{{cssClass}}" autocomplete="off">

  {{!-- Sheet Header --}}
  <header class="sheet-header">
    <div class="header-fields">
      <div class="flexrow">

        <div class="profile-img-container">
          <img class="profile-img" src="{{img}}" data-edit="img" title="{{name}}" />
        </div>

        <div class="flexcol">
          <h1 class="charname margin-right"><input name="name" type="text" value="{{name}}" placeholder="Name" /></h1>

          <div class="flexrow">
          </div>

        </div>
      </div>
    </div>
    </div>

  </header>

  {{!-- Sheet Tab Navigation --}}
  <nav class="sheet-tabs tabs" data-group="primary">
    <a class="item" data-tab="principal">Carac&Santé</a>
    <a class="item" data-tab="competences">Compétences</a>
    <a class="item" data-tab="combat">Combat</a>
    <a class="item" data-tab="equipements">Equipement</a>
    <a class="item" data-tab="biodata">Bio&Notes</a>
  </nav>

  {{!-- Sheet Body --}}
  <section class="sheet-body">

    {{!-- Skills Tab --}}
    <div class="tab principal" data-group="primary" data-tab="principal">

      <div class="grid grid-2col">

        <div>
        <ul class="item-list alternate-list">
          {{#each caracList as |char key|}}
          <li class="item flexrow list-item carac-box">
            <img class="sheet-competence-img" src="/systems/fvtt-te-deum/images/icons/{{key}}.webp" />
            <label class="item-left-pad item-field item-field-label-medium">{{char.name}}</label>
            <select type="text" class="input-numeric-short" name="system.caracteristiques.{{key}}.value"
              data-dtype="Number" />
            {{selectOptions @root.config.descriptionValeur selected=char.value labelAttr="valeur"}}
            </select>
            <label class="item-field item-field-label-medium">{{char.qualite}}</label>
            <label class="item-field item-field-label-medium">{{char.dice}} ({{char.negativeDice}})</label>
          </li>
          {{/each}}
        </ul>
        
        <div>
          <h4>Malus de santé : {{santeModifier}} niveaux</h4>
        </div>

        <ul class="item-list alternate-list">
            <li class="item flexrow list-item items-title-bg">
              <span class="item-field-title-long">
                <h3><label class="item-field-label-long">Blessures</label></h3>
              </span>
            </li>
            {{#each blessures as |blessure key|}}
            <li class="item flexrow list-item list-item-shadow item-id" data-item-id="{{blessure._id}}">
              <a class="item-edit item-name-img" title="Editer Item"><img class="sheet-competence-img"
                  src="{{blessure.img}}" /></a>
              <span class="item-field-label-medium">
                {{blessure.name}}
              </span>
              <span class="item-field-label-short">
                {{getConfigLabel "blessures" blessure.system.typeBlessure}}
              </span>
              <span class="item-field-label-short">
                {{getConfigLabel "LOCALISATION" blessure.system.localisation}}
              </span>
              <span class="item-field-label-short">
                {{blessure.malus}}
              </span>
              <div class="item-filler">&nbsp;</div>
              <div class="item-controls item-controls-fixed">
                <a class="item-control item-edit" title="Editer"><i class="fas fa-edit"></i></a>
                <a class="item-control item-delete" title="Supprimer l'arme"><i class="fas fa-trash"></i></a>
              </div>
            </li>
            {{/each}}
          </ul>

          {{#if (or (count maladies) (count poisons))}}
          <ul class="item-list alternate-list"> 
            <li class="item flexrow list-item items-title-bg">
              <span class="item-field-title-long">
                <h3><label class="item-field-label-long">Maladies & Poisons</label></h3>
              </span>
            </li>
            {{#each maladies as |maladie key|}}
            <li class="item flexrow list-item list-item-shadow item-id" data-item-id="{{maladie._id}}">
              <a class="item-edit item-name-img" title="Editer Item"><img class="sheet-competence-img"
                  src="{{maladie.img}}" /></a>
              <span class="item-field-label-medium">
                {{maladie.name}}
              </span>
              <span class="item-field-label-short">
                {{maladie.malus}}
              </span>
              <div class="item-filler">&nbsp;</div>
              <div class="item-controls item-controls-fixed">
                <a class="item-control item-edit" title="Editer"><i class="fas fa-edit"></i></a>
                <a class="item-control item-delete" title="Supprimer l'arme"><i class="fas fa-trash"></i></a>
              </div>
            </li>
            {{/each}}
            {{#each poisons as |poison key|}}
            <li class="item flexrow list-item list-item-shadow item-id" data-item-id="{{poison._id}}">
              <a class="item-edit item-name-img" title="Editer Item"><img class="sheet-competence-img"
                  src="{{poison.img}}" /></a>
              <span class="item-field-label-medium">
                {{poison.name}}
              </span>
              <span class="item-field-label-short">
                {{poison.malus}}
              </span>
              <div class="item-filler">&nbsp;</div>
              <div class="item-controls item-controls-fixed">
                <a class="item-control item-edit" title="Editer"><i class="fas fa-edit"></i></a>
                <a class="item-control item-delete" title="Supprimer l'arme"><i class="fas fa-trash"></i></a>
              </div>
            </li>
            {{/each}}

          </ul>
          {{/if}}

        </div>

        <div>
          <ul class="item-list alternate-list">
            <li class="item flexrow list-item carac-box">
              <label class="item-left-pad  item-field item-field-label-medium">Providence</label>
              <select type="text" class="input-numeric-short" name="system.providence.value" data-dtype="Number" />
              {{selectOptions @root.config.providence selected=providence.value nameAttr="value" valueAttr="value"
              labelAttr="value"}}
              </select>
              <label class="item-field item-field-label-long">{{providence.qualite}}</label>
              <label class="item-field item-field-label-short">{{providence.dice}}</label>
            </li>
            <li class="item flexrow list-item carac-box">
              <label class="item-left-pad item-field item-field-label-medium">Bienveillance</label>
              <input class="input-numeric-short" type="text" name="system.bienveillance.value" data-dtype="Number" />
              <label class="item-field item-field-label-long"></label>
              <label class="item-field item-field -label-short"></label>
            </li>
          </ul>

          <ul class="item-list alternate-list">
            <li class="item flexrow list-item items-title-bg">
              <span class="item-field-title-long">
                <h3><label class="item-field-label-long">Graces</label></h3>
              </span>
            </li>
            {{#each graces as |grace key|}}
            <li class="item flexrow list-item list-item-shadow item-id" data-item-id="{{arme._id}}">
              <a class="item-edit item-name-img" title="Edit Item"><img class="sheet-competence-img"
                  src="{{grace.img}}" /></a>
              <span class="item-field-label-long">
                {{grace.name}}
              </span>
              <div class="item-filler">&nbsp;</div>
              <div class="item-controls item-controls-fixed">
                <a class="item-control item-edit" title="Editer"><i class="fas fa-edit"></i></a>
                <a class="item-control item-delete" title="Supprimer l'arme"><i class="fas fa-trash"></i></a>
              </div>
            </li>
            {{/each}}
          </ul>
        </div>
      </div>

    </div>

    {{!-- Skills Tab --}}
    <div class="tab competences" data-group="primary" data-tab="competences">

      {{#each arbreCompetences as |carac key|}}
      <ul>
        <li class="flexrow">
          <img class="sheet-competence-img" src="/systems/fvtt-te-deum/images/icons/{{key}}.webp" />
          <h3 class="item-field-label-long14" data-tooltip="Caracteristique">{{carac.name}} : {{carac.qualite}}</h3>
          <label class="item-field item-field-label-short">{{carac.value}}</label>
          <label class="item-field item-field-label-medium">{{carac.dice}} (xp : {{carac.experience}})</label>
        </li>
        <ul class="ul-level1 flexrow item-list">
          {{#each carac.competences as |comp skillkey|}}
          <li class="flexrow carac-box comp-box item-id" data-item-id="{{comp.id}}">
            <label class="item-left-pad item-field item-field-label-long">
              <a class="roll-competence" data-comp-id="{{comp.id}}">{{comp.name}} {{comp.system.formula}} </a>
            </label>
            <span>&nbsp;</span>
            <a class="item-control item-edit" title="Editer"><i class="fas fa-edit"></i></a>
            <a class="item-control item-delete" title="Supprimer"><i class="fas fa-trash"></i></a>
          </li>
          {{/each}}
        </ul>
      </ul>
      {{/each}}

    </div>


    <div class="tab combat" data-group="primary" data-tab="combat">

      <div class="flexrow">
      </div>

      <ul class="item-list alternate-list">
        <li class="item flexrow list-item items-title-bg">
          <span class="item-field-title-long">
            <h3><label class="item-field-label-long">Armes</label></h3>
          </span>
          <span class="item-field-label-medium">
            <label class="item-field-label-medium">Type</label>
          </span>
          <span class="item-field-label-medium">
            <label class="item-field-label-medium">Compétence</label>
          </span>
          <span class="item-field-label-medium">
            <label class="item-field-label-medium">Degats</label>
          </span>
        </li>
        {{#each armes as |arme key|}}
        <li class="item flexrow list-item list-item-shadow item-id" data-item-id="{{arme._id}}">
          <a class="item-edit item-name-img" title="Edit Item"><img class="sheet-competence-img"
              src="{{arme.img}}" /></a>
          <span class="item-field-label-long">
            <a class="roll-arme" data-arme-id="{{arme._id}}">
              {{arme.name}}
            </a>
          </span>
          <span class="item-field-label-medium">{{upperFirst arme.system.typeArme}}</span>
          <span class="item-field-label-medium">{{upperFirst arme.system.competence}}</span>
          <span class="item-field-label-medium">{{arme.system.degats}}</span>

          <div class="item-filler">&nbsp;</div>
          <div class="item-controls item-controls-fixed">
            <a class="item-control item-edit" title="Editer"><i class="fas fa-edit"></i></a>
            <a class="item-control item-delete" title="Supprimer l'arme"><i class="fas fa-trash"></i></a>
          </div>
        </li>
        {{/each}}
      </ul>

      <ul class="item-list alternate-list">
        <li class="item flexrow list-item items-title-bg">
          <span class="item-name-label-header-long2">
            <h3><label class="item-name-label-header-long2">Armures</label></h3>
          </span>
        </li>
        {{#each armures as |armure key|}}
        <li class="item flexrow list-item list-item-shadow item-id" data-item-id="{{armure._id}}">
          <a class="item-edit item-name-img" title="Edit Item"><img class="sheet-competence-img"
              src="{{armure.img}}" /></a>
          <span class="item-name-label-long2">
            {{armure.name}}
          </span>

          <div class="item-filler">&nbsp;</div>
          <div class="item-controls item-controls-fixed">
            <a class="item-control item-edit" title="Editer l'armure"><i class="fas fa-edit"></i></a>
            <a class="item-control item-delete" title="Supprimer l'armure"><i class="fas fa-trash"></i></a>
          </div>
        </li>
        {{/each}}
      </ul>

      <div class="center-content">
        <div class="corps-combat-block flexrow">
          <img src="/systems/fvtt-te-deum/images/ui/femme_gauche.webp" class="silhouette-combat-picture" />
          <div class="silhouette-combat-space"></div>
          <img src="/systems/fvtt-te-deum/images/ui/homme_droit.webp" class="silhouette-combat-picture" />

          {{#each combat as |loc key|}}
          <div class="silhouette-combat-block" style="top:{{loc.coord.top}}px;left:{{loc.coord.left}}px;">
            <h4 class="center">{{loc.score.min}}-{{loc.score.max}}. {{loc.label}}</h4>
            <div class="flexcol">
              {{#each loc.armures as |armure idx| }}
                <span>{{armure.name}} ({{armure.system.protection}})</span>
              {{/each}}
              <span>Touché : {{touche}}</span>
              <span>Blessures : {{blessuresTete}}</span>
            </div>
          </div>
          {{/each}}

        </div>
      </div>

    </div>


    {{!-- Equipement Tab --}}
    <div class="tab equipements" data-group="primary" data-tab="equipements">

      <span class="item-name-label-header items-title-bg">
        <h3><label class="items-title-text">Zone libre</label></h3>
      </span>
      <div class="form-group small-editor">
        {{editor equipementlibre target="system.equipmentfree" button=true owner=owner editable=editable}}
      </div>

      <ul class="item-list alternate-list">
        <li class="item flexrow list-item items-title-bg">
          <span class="item-field-label-long">
            <h3><label class="item-field-label-long">Equipements</label></h3>
          </span>
          <span class="item-field-label-medium">
            <label class="item-field-label-medium">Prix</label>
          </span>
          <div class="item-filler">&nbsp;</div>
          <div class="item-controls item-controls-fixed">
            <a class="item-control item-add" data-type="equipment" title="Créer un équipement"><i
                class="fas fa-plus"></i></a>
          </div>

        </li>
        {{#each equipements as |equip key|}}
        <li class="item list-item flexrow list-item-shadow item-id" data-item-id="{{equip._id}}">
          <a class="item-edit item-name-img" title="Edit Item"><img class="sheet-competence-img"
              src="{{equip.img}}" /></a>
          <span class="item-name-label">{{equip.name}}</span>
          <span class="item-field-label-medium">{{equip.system.prix}} {{equip.system.monnaie}}</span>

          <div class="item-filler">&nbsp;</div>
          <div class="item-controls item-controls-fixed">
            <a class="item-control item-edit" title="Editer un équipement"><i class="fas fa-edit"></i></a>
            <a class="item-control item-delete" title="Supprimer un équipement"><i class="fas fa-trash"></i></a>
          </div>
        </li>
        {{/each}}
      </ul>

      <hr>

    </div>

    {{!-- Biography Tab --}}
    <div class="tab biodata" data-group="primary" data-tab="biodata">

      <div class="grid grid-2col">
        <div>
          <ul class="item-list alternate-list">
            <li class="item flexrow">
              <label class="item-name-label-medium">Lieu de naissance</label>
              <input type="text" class="" name="system.lieunaissance" value="{{system.biodata.lieunaissance}}"
                data-dtype="String" />
            </li>
            <li class="item flexrow">
              <label class="item-name-label-medium">Age</label>
              <input type="text" class="" name="system.biodata.age" value="{{system.biodata.age}}"
                data-dtype="String" />
            </li>
          </ul>
        </div>
        <div>
          <ul>
            <li class="item flexrow">
              <label class="item-name-label-medium">Statut social</label>
              <input type="text" class="" name="system.statutocial" value="{{system.biodata.residence}}"
                data-dtype="String" />
            </li>
            <li class="item flexrow">
              <label class="item-name-label-medium">Charges et Titres</label>
              <input type="text" class="" name="system.chargestitre" value="{{system.biodata.nationalite}}"
                data-dtype="String" />
            </li>
            <li class="item flexrow">
              <label class="item-name-label-medium">Religion</label>
              <input type="text" class="" name="system.biodata.enfance" value="{{system.biodata.enfance}}"
                data-dtype="String" />
            </li>
          </ul>
        </div>
      </div>

      <hr>
      <span class="item-name-label-header items-title-bg">
        <h3><label class="items-title-text">Background</label></h3>
      </span>
      <div class="form-group editor">
        {{editor description target="system.biodata.description" button=true owner=owner
        editable=editable}}
      </div>
      <hr>
      <span class="item-name-label-header items-title-bg">
        <h3><label class="items-title-text">Notes</label></h3>
      </span>
      <div class="form-group editor">
        {{editor notes target="system.biodata.notes" button=true owner=owner editable=editable}}
      </div>
      <hr>

    </div>


  </section>
</form>