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

  {{!-- Sheet Header --}}
  <header class="sheet-header">
    <img class="profile-img" src="{{img}}" data-edit="img" title="{{name}}" />
    <div class="header-fields">
      <div class="flexrow">
        <h1 class="charname"><input name="name" type="text" value="{{name}}" placeholder="Name" /></h1>
      </div>
      <div class="flexrow flex-group-center flex-actions-bar">
        <div>
          <span class="encaisser-direct"><a title="Encaisser des dommages"><img class="button-img" src="icons/svg/bones.svg" alt="Encaisser des dommages"/></a></span>
          <span class="gm-only remise-a-neuf"><a title="Remise à neuf"><img class="button-img" src="icons/svg/regen.svg" alt="Remise à neuf"/></a></span>
        </div>
      </div>
      <div class="flexrow">
        <div class="flexrow">
          <span>{{calc.resumeBlessures}}</span>
        </div>
        <div class="flexrow">
          {{#if calc.surprise}}{{calc.surprise}}! {{/if}}
          {{#if effects}}
          {{#each effects as |effect key|}}
          <span id="effect-{{effect.flags.core.status.statusId}} ">
            <img class="button-effect-img" src="{{effect.icon}}" alt="{{effect.label}}" width="24" height="24" />
          </span>
          {{/each}}
          {{#if options.isGM}}
          <span id="enlever-tous-effets"><a>(enlever tout)</a></span>
          {{/if}}
          {{else}}
          Aucun effet actif
          {{/if}}
        </div>
    </div>
    </div>
  </header>

  {{!-- Sheet Tab Navigation --}}
  <nav class="sheet-tabs tabs" data-group="primary">
    <a class="item" data-tab="carac">Caractéristiques</a>
    <a class="item" data-tab="competences">Compétences</a>
    <a class="item" data-tab="blessures">Blessures</a>
    <a class="item" data-tab="items">Équipement</a>
    <a class="item" data-tab="description">Description</a>
  </nav>

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

    {{!-- Carac Tab --}}
    <div class="tab items" data-group="primary" data-tab="carac">
      <div class="grid grid-2col">
        <div class="flex-group-left flexcol">
          <ol class="carac-list alterne-list">
            {{#each data.carac as |carac key|}}
            <li class="flexrow list-item" data-attribute="{{key}}">
              {{#if (eq key 'taille')}}
              <span class="carac-label flexrow" name="data.carac.{{key}}.label">{{carac.label}}</span>
              {{else}}
              <span class="carac-label flexrow" name="data.carac.{{key}}.label"><a
                  name={{key}}>{{carac.label}}</a></span>
              {{/if}}
              <input class="competence-value flexrow" type="text" name="data.carac.{{key}}.value"
                value="{{carac.value}}" data-dtype="{{carac.type}}" />
            </li>
            {{/each}}
            <li class="flexrow">
              <span class="carac-label" name="carac-total">Total Caractéristiques</span>
              {{log 'data-actor-creature' this}}
              <span class="competence-value" name="carac-total-value">{{calc.caracTotal}}</span>
            </li>
          </ol>
        </div>
        <div class="flex-group-left flexcol">
          <ol class="carac-list alterne-list">
            {{#each data.attributs as |attr key|}}
            <li class="flexrow list-item" data-attribute="{{key}}">
              <span class="carac-label" name="data.attributs.{{key}}.label">{{attr.label}}</span>
              <input type="text" name="data.attributs.{{key}}.value" value="{{attr.value}}" data-dtype="{{attr.type}}" />
            </li>
            {{/each}}
            <li class="flexrow list-item" data-attribute="vie">
              <span class="competence-label" name="data.sante.vie.label">Vie</span>
              <span class="flexrow" >
                <input type="text" name="data.sante.vie.value" value="{{data.sante.vie.value}}" data-dtype="Number" /> / 
                <input type="text" name="data.sante.vie.max" value="{{data.sante.vie.max}}" data-dtype="Number" />
              </span>
            </li>
            <li class="flexrow list-item" data-attribute="endurance">
              <span class="competence-label" name="data.sante.endurance.label">Endurance</span>
              <span class="flexrow" >
                <input type="text" name="data.sante.endurance.value" value="{{data.sante.endurance.value}}" data-dtype="Number" /> / 
                <input type="text" name="data.sante.endurance.max" value="{{data.sante.endurance.max}}" data-dtype="Number" />
              </span>
            </li>
            <li class="flexrow list-item" data-attribute="sonne">
              <span class="competence-label" name="data.sante.sonne.label">Sonné</span>
              <input type="checkbox" name="data.sante.sonne.value" value="{{data.sante.sonne.value}}" {{#if data.sante.sonne.value}}checked{{/if}} />
            </li>
            <li class="flexrow list-item" data-attribute="etat">
              <span class="competence-label" name="data.compteurs.etat.label">Etat Général</span>
              <input type="text" value="{{data.compteurs.etat.value}}" disabled />
            </li>
          </ol>
        </div>
      </div>
    </div>

    {{!-- Compétences Tab --}}
    <div class="tab competences" data-group="primary" data-tab="competences">
      <div class="flexcol">
        <div class="flex-group-left flexcol competence-column">
          <ol class="item-list alterne-list">
            {{#each competences as |comp key|}}
            <li class="item flexrow list-item" data-item-id="{{comp._id}}">
              <a class="competence-label" name="{{comp.name}}">
                <img class="sheet-competence-img" src="{{comp.img}}"/>
                <span class="competence-label">{{comp.name}}</span>
              </a>
                <input class="competence-value creature-carac" type="text" compname="{{comp.name}}"
                value="{{comp.data.carac_value}}" data-dtype="number" />
              <input class="competence-value creature-niveau" type="text" compname="{{comp.name}}"
                value="{{numberFormat comp.data.niveau decimals=0 sign=true}}" data-dtype="number" />
              <input class="competence-value creature-dommages" type="text" compname="{{comp.name}}"
                value="{{numberFormat comp.data.dommages decimals=0 sign=true}}" data-dtype="number" />
              <div class="item-controls">
                <a class="item-control item-edit" title="Edit Item"><i class="fas fa-edit"></i></a>
                <a class="item-control item-delete" title="Delete Item"><i class="fas fa-trash"></i></a>
              </div>
            </li>
            {{/each}}
          </ol>
        </div>
      </div>
    </div>

    {{!-- blessures Tab --}}
    <div class="tab blessures" data-group="primary" data-tab="blessures" style="height:200px">
      {{!-- Liste de blessures --}}
      {{> "systems/foundryvtt-reve-de-dragon/templates/actor-liste-blessures-partial.html" this}}
    </div>

    {{!-- Equipment Tab --}}
    <div class="tab items" data-group="primary" data-tab="items">

      {{> "systems/foundryvtt-reve-de-dragon/templates/actor-sheet-inventaire-monnaie.html" monnaie=monnaie}}

      <span class="item-name"><h4>Equipement porté</h4></span>
      <span class="item-name">Encombrement total/max : {{numberFormat calc.encTotal decimals=2}} / {{data.attributs.encombrement.value}} <b>{{calc.surEncombrementMessage}}</b></span> - 
      <span class="item-name"><a class="creer-un-objet">Créer un objet</a></span>
      {{#if options.isGM}}
      <span class="item-name"> - <a id="nettoyer-conteneurs">Vider tout les conteneurs</a></span>
      {{/if}}

      <ul class="item-list alterne-list">
        <li class="competence-header flexrow">
          <img class="sheet-competence-img" src="{{img}}" title="Equipement"/>
          <span class="competence-title flex-grow">Nom</span>
          <span class="competence-title">Q.</span>
          <span class="competence-title">Enc.</span>
          <span class="competence-title flex-grow">Equiper/Editer/Suppr.</span>
        </li>
        {{#each objets as |item id|}}
          {{#unless item.estContenu}}
          {{#if (ne item.type 'conteneur')}}
            {{> "systems/foundryvtt-reve-de-dragon/templates/actor-sheet-inventaire-conteneur.html" item=item }}
          {{/if}}
          {{/unless}}
        {{/each}}
        {{#each conteneurs as |conteneur id|}}
          {{buildConteneur this}}
        {{/each}}
      </ul>
    </div>

    {{!-- Biography Tab --}}
    <div class="tab description" data-group="primary" data-tab="description">
      <div class="form-group editor">
        {{editor content=data.description target="data.description" button=true owner=owner editable=editable}}
      </div>
      {{>"systems/foundryvtt-reve-de-dragon/templates/actor-sheet-editor-notes-mj.html"}}
    </div>

  </section>
</form>