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

    {{!-- Sheet Header --}}
    <header class="sheet-header">
      <div class="header-fields">
        <div class="flexrow">
          <img class="profile-img" src="{{img}}" data-edit="img" title="{{name}}" />
          <h1 class="charname"><input name="name" type="text" value="{{name}}" placeholder="Name"/></h1>
        </div>
      </div>
    </header>

    {{!-- Sheet Tab Navigation --}}
    <nav class="sheet-tabs tabs" data-group="primary">
        <a class="item" data-tab="principal">Attributs</a>
        <a class="item" data-tab="equipement">Equipement</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="principal">
          <span><a class="lock-unlock-sheet"><img class="small-button-container" 
            src="systems/fvtt-yggdrasill/images/icons/{{#if editScore}}unlocked.svg{{else}}locked.svg{{/if}}" alt="Editable/Vérouillé"
            >{{#if editScore}}Editable{{else}}Vérouillé{{/if}}</a>
          </span>
          
          <div class="grid grid-2col">
            <div class="">
              <span class="generic-label"><h3>Attributs</h3></span>
              <ul>
                {{#each data.attributs as |attr key|}}
                  <li class="item flexrow list-item" data-attr-key="{{key}}">
                    <span class="stat-label flexrow tooltip tooltip-nobottom" name="{{key}}">
                      {{#if attr.rollable}}
                      <a class="attribut-roll">{{attr.label}}</a>
                      {{else}}
                      {{attr.label}}
                      {{/if}}
                    </span>

                    {{#each attr.values as |value index|}}
                      {{#if value.label}}
                      <span class="stat-label flexrow tooltip tooltip-nobottom" name="{{index}}">
                        <a class="attribut-roll" data-attr-sub-key="{{index}}">{{value.label}}</a></span>
                      {{/if}}
                      <select class="carac-base flexrow" type="text" name="system.attributs.{{key}}.values.{{index}}.value" value="{{value.value}}" data-dtype="Number" {{#unless @root.editScore}}disabled{{/unless}}>
                        {{#select value.value}}
                          {{#each @root.optionsAttr as |option index|}}
                          <option value="{{index}}">{{index}}</option>
                          {{/each}}
                        {{/select}}
                        </select> 
                    {{/each}}

                    </li>
                </ul>  
                {{/each}}
              </ul>  
            </div>

            <div class="">
                <span class="generic-label"><h3>Etat</h3></span>
                <ul>
                  <li class="item flexrow list-item" data-attr-key="etat">
                    <span class="stat-label flexrow tooltip tooltip-nobottom" name="etat">Etat : </span>
                    <select class="carac-base flexrow" type="text" name="system.etat.etat" value="{{data.etat.etat}}" data-dtype="String" {{#unless @root.editScore}}disabled{{/unless}}>
                      {{#select data.etat.etat}}
                      <option value="fringant">Fringant</option>
                      <option value="blesse">Blessé</option>
                      <option value="mort">Mort</option>
                      {{/select}}
                      </select> 
                  </li>                  
                </ul>  

                <span class="generic-label"><h3>Sorts/Rune actifs</h3></span>
                <ul>
                  {{#each effetsmagiques as |effetmagique key|}}
                  <li class="item flexrow list-item" data-item-id="{{effetmagique.id}}">
                    <img class="sheet-competence-img" src="{{effetmagique.img}}"/>
                    <span class="competence-label">{{effetmagique.name}}</span>
                    <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}}
                </ul>  
            </div>
            </div>
        </div>
        

      {{!-- Equipement Tab --}}
        <div class="tab equipement" data-group="primary" data-tab="equipement">
          <div><h4>Argent</h4></div>
          <ul class="item-list alternate-list">
            {{#each monnaies as |monnaie key|}}
            <li class="item flexrow list-item" data-item-id="{{monnaie.id}}">
              <img class="sheet-competence-img" src="{{monnaie.img}}"/>
              <span class="generic-label">{{monnaie.name}}</span>
              <span class="generic-label">{{monnaie.system.quantite}}
                  (<a class="equipement-moins plus-moins-button"> -</a>/<a class="equipement-plus plus-moins-button">+</a>)
              </span>  
              </span>              
              <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}}
          </ul>
          <div><h4>Equipement (Encombrement total : {{encTotal}})</h4></div>
          <ul class="item-list alternate-list">
            <li class="item flexrow list-item">
              <span class="equipement-label">Nom</span>
              <span class="equipement-label">Quantité</span>
              <span class="equipement-label">Enc.</span>
              <span class="equipement-label">+/-</span>
              <div class="item-controls">
                <span class="equipement-label">&nbsp;</span>
                <span class="equipement-label">&nbsp;</span>
                <span class="equipement-label">&nbsp;</span>
              </div>
            </li>
            {{#each equipements as |equipement key|}}
            <li class="item flexrow list-item" data-item-id="{{equipement.id}}">
              <img class="sheet-competence-img" src="{{equipement.img}}"/>
              <span class="equipement-label">{{equipement.name}}</span>
              <span class="equipement-label">{{equipement.system.quantite}}</span>
              <span class="equipement-label">{{equipement.system.enc}}</span>
              <span class="equipement-label">
                (<a class="equipement-moins plus-moins-button">-</a>/<a class="equipement-plus plus-moins-button">+</a>)
              </span>
              <div class="item-controls">
                <a class="item-control item-equip" title="Worn">{{#if equipement.system.equipe}}<i class="fas fa-circle"></i>{{else}}<i class="fas fa-genderless"></i>{{/if}}</a>
                <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}}
          </ul>
        </div>


      {{!-- Biography Tab --}}
      <div class="tab description" data-group="primary" data-tab="description">        
        <article class="flexcol">
          <h3>Biographie : </h3>
          <div class="form-group editor">
            {{editor content=data.description target="data.description" button=true owner=owner editable=editable}}
          </div>
          <hr>
          <h3>Notes : </h3>
          <div class="form-group editor">
            {{editor content=data.notes target="data.notes" button=true owner=owner editable=editable}}
          </div>
        </article>
      </div>

    </section>
</form>

