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

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

    {{!-- Sheet Tab Navigation --}}
    <nav class="sheet-tabs tabs" data-group="primary">
        <a class="item" data-tab="principal">Principal</a>
        <a class="item" data-tab="capacite">Capacités</a>
        <a class="item" data-tab="combat">Combat</a>
        <a class="item" data-tab="sorts">Sorts</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/foundryvtt-vadentis/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>Données</h3></span>
              <ul>
                {{#each donnees as |donnee key|}}
                <li class="item flexrow list-item" data-item-id="{{donnee._id}}">
                  <img class="sheet-competence-img" src="{{donnee.img}}"/>
                  <span class="stat-label flexrow tooltip tooltip-nobottom" name="donnee.name">{{donnee.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>  

              <hr><span class="generic-label"><h3>Eglise</h3></span>
              <ul>
                {{#each eglises as |eglise key|}}
                <li class="item flexrow list-item" data-item-id="{{eglise._id}}">
                  <img class="sheet-competence-img" src="{{eglise.img}}"/>
                  <span class="stat-label flexrow tooltip tooltip-nobottom" name="eglise.name">{{eglise.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>  
                    
              <hr><span class="generic-label"><h3>Scores</h3></span>
              <ul class="stat-list alternate-list">
                  <li class="stat flexrow" >
                    <span class="sheet-competence-img" name=""></span>
                    <span class="generic-label flexrow tooltip tooltip-nobottom" name="statlabel1">Désignation</span>
                    <span class="flexrow tooltip tooltip-nobottom" name="statlabel2">Valeur</span>
                    <span class="flexrow tooltip tooltip-nobottom" name="statlabel3">Max</span>
                  </li>
                  <li class="stat flexrow list-item" data-attribute="pointsvie">
                    <img class="sheet-competence-img" src="systems/foundryvtt-vadentis/images/icons/feuille_perso_PV.webp"/>
                    <span class="stat-label flexrow tooltip tooltip-nobottom">Points de Vie</span>
                    <select class="stat-value flexrow" type="text" name="data.stats.pointsvie.value" value="{{data.stats.pointsvie.value}}" data-dtype="Number" {{#unless @root.editScore}}disabled{{/unless}}>
                      {{#select data.stats.pointsvie.value}}
                      {{{@root.optionsPV}}}
                      {{/select}}
                    </select> 
                    <select class="stat-value flexrow" type="text" name="data.stats.pointsvie.max" value="{{data.stats.pointsvie.max}}" data-dtype="Number" {{#unless @root.editScore}}disabled{{/unless}}>
                      {{#select data.stats.pointsvie.max}}
                      {{{@root.optionsPV}}}
                      {{/select}}
                    </select> 
                  </li>
                  <li class="stat flexrow list-item" data-attribute="pointsenergie">
                    <img class="sheet-competence-img" src="systems/foundryvtt-vadentis/images/icons/feuille_perso_PE.webp"/>
                    <span class="stat-label flexrow tooltip tooltip-nobottom">Points d'Energie</span>
                    <select class="stat-value flexrow" type="text" name="data.stats.pointsenergie.value" value="{{stats.pointsenergie.value}}" data-dtype="Number" {{#unless @root.editScore}}disabled{{/unless}}>
                      {{#select data.stats.pointsenergie.value}}
                      {{{@root.optionsPE}}}
                      {{/select}}
                    </select> 
                    <select class="stat-value flexrow" type="text" name="data.stats.pointsenergie.max" value="{{data.stats.pointsenergie.max}}" data-dtype="Number" {{#unless @root.editScore}}disabled{{/unless}}>
                      {{#select data.stats.pointsenergie.max}}
                      {{{@root.optionsPE}}}
                      {{/select}}
                    </select> 
                  </li>
                  <li class="stat flexrow list-item" data-attribute="pointsadrenaline">
                    <img class="sheet-competence-img" src="systems/foundryvtt-vadentis/images/icons/feuille_perso_PA.webp"/>
                    <span class="stat-label flexrow tooltip tooltip-nobottom">Points d'Adrénaline</span>
                    <select class="stat-value flexrow" type="text" name="data.stats.pointsadrenaline.value" value="{{data.stats.pointsadrenaline.value}}" data-dtype="Number" {{#unless @root.editScore}}disabled{{/unless}}>
                      {{#select data.stats.pointsadrenaline.value}}
                      {{{@root.optionsPA}}}
                      {{/select}}
                    </select> 
                    <select class="stat-value flexrow" type="text" name="data.stats.pointsadrenaline.max" value="{{data.stats.pointsadrenaline.max}}" data-dtype="Number" {{#unless @root.editScore}}disabled{{/unless}}>
                      {{#select data.stats.pointsadrenaline.max}}
                      {{{@root.optionsPA}}}
                      {{/select}}
                    </select> 
                  </li>
              </ul>          
              <hr><span class="generic-label"><h3>Expérience</h3></span>
              <ul class="stat-list alternate-list">
                <li class="stat flexrow list-item" data-attribute="experience">
                  <img class="sheet-competence-img" src="systems/foundryvtt-vadentis/images/icons/feuille_perso_experience.webp"/>
                  <span class="stat-label flexrow tooltip tooltip-nobottom">Expérience</span>
                  <input type="text" name="data.experience.experience.total" value="{{data.experience.experience.total}}" data-dtype="Number"/>                  
                </li>
              </ul>
            </div>
            <div class="">
              <hr><span class="generic-label"><h3>Combat</h3></span>
              <ul class="stat-list alternate-list">
                <li class="stat flexrow" >
                  <span class="generic-label flexrow tooltip tooltip-nobottom" name="statlabel">Désignation</span>
                  <span class="flexrow tooltip tooltip-nobottom" name="statlabel">Valeur</span>
                  <span class="flexrow tooltip tooltip-nobottom" name="statlabel">Malus</span>
                  <span class="flexrow tooltip tooltip-nobottom" name="statlabel">Bonus</span>
                  <span class="flexrow tooltip tooltip-nobottom" name="statlabel">Score</span>
                </li>
                {{#each data.combat as |mycombat key|}}
                <li class="stat flexrow list-item" data-attribute="{{key}}">
                  <img class="sheet-competence-img" src="systems/foundryvtt-vadentis/images/icons/feuille_perso_{{key}}.webp"/>
                  <span class="stat-label combat-label flexrow tooltip tooltip-nobottom" name="data.combat.{{key}}.label"><a name="{{key}}">{{mycombat.label}}</a></span>
                  <select class="stat-value flexrow" type="text" name="data.combat.{{key}}.base" value="{{mycombat.base}}" data-dtype="Number" {{#unless @root.editScore}}disabled{{/unless}}>
                    {{selectOptions @root.optionsBase selected=mycombat.base  localize=false}}
                  </select> 
                  <select class="stat-value flexrow" type="text" name="data.combat.{{key}}.malus" value="{{mycombat.malus}}" data-dtype="Number" {{#unless @root.editScore}}disabled{{/unless}}>
                    {{selectOptions @root.optionsMalus selected=mycombat.malus  localize=false}}
                  </select> 
                  <select class="stat-value flexrow" type="text" name="data.combat.{{key}}.bonus" value="{{mycombat.bonus}}" data-dtype="Number" {{#unless @root.editScore}}disabled{{/unless}}>
                    {{selectOptions @root.optionsBonus selected=mycombat.bonus  localize=false}}
                  </select> 
                  <span class="score-label combat-label "><a name="{{key}}">&nbsp;1d20 + {{mycombat.total}}</a></span>
                </li>
                {{/each}}                
              </ul>          
              <hr><span class="generic-label"><h3>Magie</h3></span>
              <ul class="stat-list alternate-list">
                <li class="stat flexrow" >
                  <span class="generic-label flexrow tooltip tooltip-nobottom" name="statlabel">Désignation</span>
                  <span class="flexrow tooltip tooltip-nobottom" name="statlabel">Valeur</span>
                  <span class="flexrow tooltip tooltip-nobottom" name="statlabel">Malus</span>
                  <span class="flexrow tooltip tooltip-nobottom" name="statlabel">Bonus</span>
                  <span class="flexrow tooltip tooltip-nobottom" name="statlabel">Score</span>
                </li>
                {{#each data.magie as |mymagie key|}}
                <li class="stat flexrow list-item" data-attribute="{{key}}">
                  <img class="sheet-competence-img" src="systems/foundryvtt-vadentis/images/icons/feuille_perso_{{key}}.webp"/>
                  <span class="stat-label magie-label flexrow tooltip tooltip-nobottom" name="data.magie.{{key}}.label"><a name="{{key}}">{{mymagie.label}}</a></span>
                  <select class="stat-value flexrow" type="text" name="data.magie.{{key}}.base" value="{{mymagie.base}}" data-dtype="Number" {{#unless @root.editScore}}disabled{{/unless}}>
                    {{selectOptions @root.optionsBase selected=mymagie.base  localize=false}}
                  </select> 
                  <select class="stat-value flexrow" type="text" name="data.magie.{{key}}.malus" value="{{mymagie.malus}}" data-dtype="Number" {{#unless @root.editScore}}disabled{{/unless}}>
                    {{selectOptions @root.optionsMalus selected=mymagie.malus  localize=false}}
                  </select> 
                  <select class="stat-value flexrow" type="text" name="data.magie.{{key}}.bonus" value="{{mymagie.bonus}}" data-dtype="Number" {{#unless @root.editScore}}disabled{{/unless}}>
                    {{selectOptions @root.optionsBonus selected=mymagie.bonus  localize=false}}
                  </select> 
                  <span class="score-label magie-label"><a name="{{key}}">&nbsp;1d20 + {{mymagie.total}}</a></span>
                </li>
                {{/each}}                
              </ul>          
            </div>
          </div>
          
        </div>
        
        {{!-- Skills Tab --}}
        <div class="tab capacite" data-group="primary" data-tab="capacite">
          <div class="flexrow">
            <span><a class="lock-unlock-sheet"><img class="small-button-container" 
              src="systems/foundryvtt-vadentis/images/icons/{{#if editScore}}unlocked.svg{{else}}locked.svg{{/if}}" alt="Editable/Vérouillé"
              >{{#if editScore}}Editable{{else}}Vérouillé{{/if}}</a>
            </span>
          </div>
          <div class="grid grid-2col">
            <div>
              <span class="generic-label">Compétences</span>
              <ul class="item-list alterne-list">
                {{#each competences as |competence key|}}
                  <li class="item flexrow list-item" data-item-id="{{competence._id}}">
                    <img class="sheet-competence-img" src="{{competence.img}}"/>
                    <span class="competence-label"><a>{{competence.name}}</a></span>
                    <select class="competence-base flexrow" type="text" skillname="{{competence.name}}" value="{{competence.data.base}}" data-dtype="Number" {{#unless @root.editScore}}disabled{{/unless}}>
                      {{selectOptions @root.optionsBase selected=competence.data.base localize=false}}
                    </select> 
                    <select class="competence-malus flexrow" type="text" skillname="{{competence.name}}" value="{{competence.data.malus}}" data-dtype="Number" {{#unless @root.editScore}}disabled{{/unless}}>
                      {{selectOptions @root.optionsMalus selected=competence.data.malus localize=false}}
                    </select> 
                    <select class="competence-bonus flexrow" type="text" skillname="{{competence.name}}" value="{{competence.data.bonus}}" data-dtype="Number" {{#unless @root.editScore}}disabled{{/unless}}>
                      {{selectOptions @root.optionsBonus selected=competence.data.bonus localize=false}}
                    </select> 
                    <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>
              <span class="generic-label">Attributs</span>
              <ul class="item-list alterne-list">
                {{#each attributs as |attribut key|}}
                  <li class="item flexrow list-item" data-item-id="{{attribut._id}}">
                    <img class="sheet-competence-img" src="{{attribut.img}}"/>
                    <span class="competence-label">{{attribut.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>
              <span class="generic-label">Techniques</span>
              <ul class="item-list alterne-list">
                {{#each techniques as |technique key|}}
                  <li class="item flexrow list-item" data-item-id="{{technique._id}}">
                    <img class="sheet-competence-img" src="{{technique.img}}"/>
                    <span class="technique-label"><a>{{technique.name}}</a></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>

      {{!-- Combat Tab --}}
      <div class="tab combat" data-group="primary" data-tab="combat">
        <div class="flexcol">
          <hr><span class="generic-label"><h3>Combat</h3></span>
          <ul class="stat-list alternate-list">
            <li class="stat flexrow" >
              <span class="generic-label flexrow tooltip tooltip-nobottom" name="statlabel">Désignation</span>
              <span class="flexrow tooltip tooltip-nobottom" name="statlabel">Valeur</span>
              <span class="flexrow tooltip tooltip-nobottom" name="statlabel">Malus</span>
              <span class="flexrow tooltip tooltip-nobottom" name="statlabel">Bonus</span>
              <span class="flexrow tooltip tooltip-nobottom" name="statlabel">Total</span>
            </li>
            {{#each data.combat as |mycombat key|}}
            <li class="stat flexrow list-item" data-attribute="{{key}}">
              <span class="stat-label combat-label flexrow tooltip tooltip-nobottom" name="data.combat.{{key}}.label"><a name="{{key}}">{{mycombat.label}}</a></span>
              <span class="stat-label combat-label">&nbsp;{{mycombat.base}}</span>
              <span class="stat-label combat-label">&nbsp;{{mycombat.malus}}</span>
              <span class="stat-label combat-label">&nbsp;{{mycombat.bonus}}</span>
              <span class="score-label combat-label "><a name="{{key}}">&nbsp;1d20 + {{mycombat.total}}</a></span>
            </li>
            {{/each}}                
          </ul>          
          <div><h4>Armes équipées</h4></div>
          <ul class="item-list alternate-list">
            {{#each armes as |arme key|}}
            {{#if arme.data.equipee}}
            <li class="item flexrow list-item" data-item-id="{{arme._id}}">
              <img class="sheet-competence-img" src="{{arme.img}}"/>
              <span class="arme-label"><a>{{arme.name}}</a></span>
              <span class="generic-label"><a class="weapon-damage">{{arme.data.damage}}</a> / <a class="weapon-damage-critical">{{arme.data.criticaldamage}}</a></span>
            </li>                  
            {{/if}}
            {{/each}}
          </ul>
        </div>
      </div>

      {{!-- Sort Tab --}}
      <div class="tab sorts" data-group="primary" data-tab="sorts">
        <div class="flexcol">
          
          <span class="generic-label">Sorts</span>
            <ul class="item-list alterne-list">
              {{#each sorts as |sort key|}}
                <li class="item flexrow list-item" data-item-id="{{sort._id}}">
                  <img class="sheet-competence-img" src="{{sort.img}}"/>
                  <span class="sort-label"><a>{{sort.name}}</a></span>
                  <span class="sort-difficulty"><a>{{sort.data.difficulty}}</a></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>

            <span class="generic-label">Dévotions</span>
            <ul class="item-list alterne-list">
              {{#each devotions as |devotion key|}}
                <li class="item flexrow list-item" data-item-id="{{devotion._id}}">
                  <img class="sheet-competence-img" src="{{devotion.img}}"/>
                  <span class="devotion-label"><a>{{devotion.name}}</a></span>
                  <span class="sort-difficulty"><a>{{devotion.data.difficulty}}</a></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>

        {{!-- Equipement Tab --}}
        <div class="tab equipement" data-group="primary" data-tab="equipement">
          <div><h4>Armes</h4></div>
          <ul class="item-list alternate-list">
            {{#each armes as |arme key|}}
            <li class="item flexrow list-item" data-item-id="{{arme._id}}">
              <img class="sheet-competence-img" src="{{arme.img}}"/>
              <span class="arme-label">{{arme.name}}</span>
              <div class="item-controls">
                <a class="item-control item-equip" title="Equipé">{{#if arme.data.equipee}}<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><h4>Armures</h4></div>
          <ul class="item-list alternate-list">
            {{#each armures as |armure key|}}
            <li class="item flexrow list-item" data-item-id="{{armure._id}}">
              <img class="sheet-competence-img" src="{{armure.img}}"/>
              <span class="armure-label">{{armure.name}}</span>
              <div class="item-controls">
                <a class="item-control item-equip" title="Equipé">{{#if armure.data.equipee}}<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><h4>Equipement</h4></div>
          <ul class="item-list alternate-list">
            {{#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>
              <div class="item-controls">
                <a class="item-control item-equip" title="Worn">{{#if equipement.data.equipee}}<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="flexrow">          
          <ul class="item-list alternate-list">
          </ul>
        </article>

        <hr>
        <article class="flexcol">
          <hr>
          <h3>Biography : </h3>
          <div class="form-group editor">
            {{editor content=data.history target="data.history" 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>
          <hr>
          {{>"systems/foundryvtt-vadentis/templates/editor-notes-gm.html"}}
        </article>
      </div>

    </section>
</form>

