<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 class="flexrow">
          <ul class="flex-group-center flex-compteurs">
            <li>
              <label class="ctn-vie">
                <a id="jet-vie">Vie</a>
                <a id="vie-moins">-</a>
                <input class="resource-content" type="text" name="data.sante.vie.value" value="{{data.sante.vie.value}}" data-dtype="Number"/>
                <span>/ {{data.sante.vie.max}}</span>
                <a id="vie-plus">+</a>
              </label>
            </li>
            <li>
              <label class="ctn-endu">
                <a id="jet-endurance">Endurance</a>                
                <a id="endurance-moins">-</a>
                <input class="resource-content" type="text" name="data.sante.endurance.value" value="{{data.sante.endurance.value}}" data-dtype="Number"/>
                <span>/ {{data.sante.endurance.max}}</span>
                <a id="endurance-plus">+</a>
              </label>
            </li>
            <li>
              <label class="ctn-fatigue tooltip">
                <span class="tooltiptext ttt-fatigue">{{{calc.fatigue.html}}}</span>
                Fatigue
                <a id="fatigue-moins">-</a>
                <input class="resource-content" id="fatigue-value" type="text" name="data.sante.fatigue.value" value="{{data.sante.fatigue.value}}" data-dtype="Number" />
                <span>/ {{data.sante.fatigue.max}}</span>
                <a id="fatigue-plus">+</a>
              </label>
            </li>
            <li>
              <label class="ctn-sonne">
                Sonné :
                <input class="resource-content data-sante-sonne" type="checkbox" {{#if data.sante.sonne.value}}checked{{/if}} />
              </label>
            </li>
            <li>
              <label class="ctn-reve">
                <span class="ptreve-actuel"><a>Rêve</a></span>
                <a id="ptreve-actuel-moins">-</a>
                <input class="resource-content" id="pointsreve-value" type="text" name="data.reve.reve.value" value="{{data.reve.reve.value}}" data-dtype="Number" />
                <span>/ {{data.reve.seuil.value}}</span>
                <a id="ptreve-actuel-plus">+</a>
              </label>
            </li>
          </ul>
          <div class="flex-group-center  flex-actions-bar">
            <div>
              <span id="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>
              <span id="dormir-une-heure"><a title="Dormir une heure"><img class="button-img" src="icons/svg/sleep.svg" alt="Dormir une heure"/></a></span>
              <span id="dormir-chateau-dormant"><a title="Chateau Dormant"><img class="button-img" src="systems/foundryvtt-reve-de-dragon/icons/heures/hd12.svg" alt="Chateau Dormant"/></a></span>
              <span id="monte-tmr"><a title="Montée dans les Terres M&eacute;dianes !"><img class="button-img" src="systems/foundryvtt-reve-de-dragon/styles/img/ui/icon-tmr-normal.svg" alt="Montée dans les Terres M&eacute;dianes !"/></a></span>
              <span id="monte-tmr-rapide"><a title="Montée accélérée dans les Terres M&eacute;dianes !"><img class="button-img" src="systems/foundryvtt-reve-de-dragon/styles/img/ui/icon-tmr-rapide.svg" alt="Montée accélérée dans les Terres M&eacute;dianes !"/></a></span>
              <span id="visu-tmr"><a title="Regarder les Terres M&eacute;dianes"><img class="button-img" src="systems/foundryvtt-reve-de-dragon/styles/img/ui/icon-tmr-view.svg" alt="Regarder les Terres M&eacute;dianes"/></a></span>
            </div>
            <div class="flexrow">
              <span class="tooltip">Malus de fatigue : {{calc.fatigue.malus}}
                <span class="tooltiptext ttt-fatigue">{{{calc.fatigue.html}}}</span>
              </span>
              <span>{{calc.resumeBlessures}}</span>
            </div>
            <div class="flexrow">
              <span>{{data.compteurs.etat.label}}: {{data.compteurs.etat.value}}</span>
              <span>{{data.compteurs.surenc.label}}: {{data.compteurs.surenc.value}}</span>
            </div>
            <div>
              {{#if calc.surprise}}{{calc.surprise}}! {{/if}}
              {{#if actor.effects}}
              {{#each actor.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>
      </div>
    </header>

    {{!-- Sheet Tab Navigation --}}
    <nav class="sheet-tabs tabs" data-group="primary">
        <a class="item" data-tab="carac">Carac.</a>
        <a class="item" data-tab="competences">Compétences</a>
        <a class="item" data-tab="combat">Combat</a>
        <a class="item" data-tab="connaissances">Savoirs&Taches</a>
        <a class="item" data-tab="hautreve">Haut-Rêve</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">
              <span><a class="lock-unlock-sheet"><img class="small-button-container" 
                src="systems/foundryvtt-reve-de-dragon/icons/{{#if options.editCaracComp}}unlocked.svg{{else}}locked.svg{{/if}}" alt="blocker/débloquer"
                >{{#if options.editCaracComp}}Verrouiller{{else}}Déverrouiller{{/if}}</a></span>
              <ul class="carac-list alterne-list">
                {{#each data.carac as |carac key|}}
                    {{#if carac.isLevelUp}}
                    <li class="competence flexrow xp-level-up" data-attribute="{{key}}">
                    {{else}}
                    <li class="competence flexrow list-item" data-attribute="{{key}}">
                    {{/if}}
                      {{#if carac.isTaille}}
                        <span class="carac-label flexrow" name="data.carac.{{key}}.label">{{carac.label}}</span>
                        <input class="carac-value flexrow" type="text" name="data.carac.{{key}}.value" value="{{carac.value}}" data-dtype="{{carac.type}}" {{#unless @root.options.editCaracComp}}disabled{{/unless}} />
                        <label class="carac-xp flexrow"/>
                      {{else}}
                          {{#if carac.derivee}}
                          <span class="carac-label flexrow" name="data.carac.{{key}}.label"> <a name={{key}}>{{carac.label}}</a></span>
                          <label class="competence-value flexrow">{{carac.value}}</label>
                          <label class="carac-xp flexrow"/>
                          {{else}}
                            {{#if carac.isLevelUp}}
                            <span class="carac-label flexrow tooltip tooltip-nobottom" name="data.carac.{{key}}.label">
                              <span class="tooltiptext ttt-xp">
                              Vous pouvez dépenser {{carac.xpNext}} points d'Experience pour augmenter de 1 votre caractéristique {{carac.label}}
                            </span>
                            <a name={{key}}>{{carac.label}}</a></span>
                            {{else}}                          
                            <span class="carac-label flexrow tooltip tooltip-nobottom" name="data.carac.{{key}}.label"><a name={{key}}>{{carac.label}}</a></span>
                            {{/if}}
                          <input class="carac-value flexrow" type="text" name="data.carac.{{key}}.value" value="{{carac.value}}" data-dtype="{{carac.type}}" {{#unless @root.options.editCaracComp}}disabled{{/unless}} />
                          <input class="carac-xp flexrow" type="text" name="data.carac.{{key}}.xp" value="{{carac.xp}}" data-dtype="number" {{#unless @root.options.editCaracComp}}disabled{{/unless}} />
                          {{/if}}
                      {{/if}}
                    </li>
                {{/each}}
                <li class="competence flexrow">
                  <span class="carac-label flexrow" name="carac-total">Total Caractéristiques </span>
                  <span class="competence-value flexrow" name="carac-total-value">{{calc.caracTotal}} </span>
                </li>
              </ul>          
            </div>
            <div class="flex-group-left flexcol" >
              <ul class="carac-list">
                <li class="competence flexrow  list-item">
                  <span class="competence-label flexrow" name="beaute">Beauté : 
                    <input class="description-value" type="text" name="data.beaute" value="{{data.beaute}}" data-dtype="String" {{#unless @root.options.editCaracComp}}disabled{{/unless}}/>
                  </span>
                </li>
                {{#each data.attributs as |attr key|}}
                <li class="competence flexrow  list-item" data-attribute="{{key}}">
                  <span class="competence-label flexrow" name="data.attributs.{{key}}.label">{{attr.label}} :
                  {{#if (eq key 'protection')}}
                    <input id="attribut-protection-edit" type="text" name="{{key}}" value="{{attr.value}}" data-dtype="number"/><span/>
                  {{else}}
                    {{attr.value}}
                  {{/if}}
                  </span>
                </li>
                {{/each}}
              </ul>
              <ul class="carac-list alterne-list">
                <li class="competence flexrow list-item">
                  <span class="generic-label chance-actuelle"><a>Chance actuelle</a></span>
                  <input class="compteur-edit" type="text" name="chance" value="{{data.compteurs.chance.value}}" data-dtype="number"/>
                  <span><a class="item-control chance-appel">Utiliser</a></span>
                </li>
                {{#each data.compteurs as |compteur key|}}
                  {{#if (eq compteur.label 'Chance')}}
                  {{else if (eq compteur.label 'Experience')}}
                  {{else if compteur.isInput}}
                    <li class="competence flexrow list-item">
                      <span class="generic-label">{{compteur.label}}</span>
                      {{#if (eq compteur.label 'Ethylisme')}}
                      <select name="data.compteurs.ethylisme.value" id="ethylisme" data-dtype="Number">
                        {{#select compteur.value}}
                        {{>"systems/foundryvtt-reve-de-dragon/templates/niveau-ethylisme.html"}}
                        {{/select}}
                      </select>          
                      {{else}}
                      <input class="compteur-edit" id="{{key}}-edit" type="text" name="{{key}}" value="{{compteur.value}}" data-dtype="number"/>
                      {{/if}}
                      <span>
                        {{#if compteur.isStress}}
                        <a class="item-control stress-test" title="Transformer">Transformer</a>
                        {{else if (eq compteur.label 'Ethylisme')}}
                        <a class="item-control ethylisme-test" id="ethylisme-test" title="Jet d'Ethylisme">Jet d'Ethylisme</a>
                        {{else if (eq compteur.label 'Moral')}}
                        <a class="moral-malheureux" title="Jet de moral situation malheureuse"><img class="small-button-container" src="systems/foundryvtt-reve-de-dragon/icons/moral-malheureux.svg" alt="Jet de moral situation malheureuse"/></a>
                        <a class="moral-neutre" title="Jet de moral situation neutre"><img class="small-button-container" src="systems/foundryvtt-reve-de-dragon/icons/moral-neutre.svg" alt="Jet de moral situation neutre"/></a>
                        <a class="moral-heureux" title="Jet de moral situation heureuse"><img class="small-button-container" src="systems/foundryvtt-reve-de-dragon/icons/moral-heureux.svg" alt="Jet de moral situation heureuse"/></a>
                        {{else}}
                        <label></label>
                      {{/if}}
                      </span>
                    </li>
                  {{/if}}
                {{/each}}
              </ul>
              <ul class="carac-list"></ul>
            </div>
          </div>
        </div>
        
        {{!-- Compétences Tab --}}
        <div class="tab competences" data-group="primary" data-tab="competences">
          <div class="flexrow">
            <span><a class="lock-unlock-sheet"><img class="small-button-container" 
              src="systems/foundryvtt-reve-de-dragon/icons/{{#if options.editCaracComp}}unlocked.svg{{else}}locked.svg{{/if}}" alt="blocker/débloquer"
              >{{#if options.editCaracComp}}Verrouiller{{else}}Déverrouiller{{/if}}</a></span>
            <span><a id="show-hide-competences"><img class="small-button-container" 
              src="systems/foundryvtt-reve-de-dragon/icons/{{#if options.showCompNiveauBase}}no-filter.svg{{else}}filter.svg{{/if}}" alt="filter/montrer tout"
              >{{#if options.showCompNiveauBase}}Montrer tout{{else}}Filtrer{{/if}}</a></span> 
            <span><a id="show-hide-archetype"><img class="small-button-container" 
              src="systems/foundryvtt-reve-de-dragon/icons/{{#if options.montrerArchetype}}no-filter.svg{{else}}filter.svg{{/if}}" alt="filter/montrer l'archétype"
              >{{#if options.montrerArchetype}}Masquer l'archétype{{else}}Voir l'archétype{{/if}}</a></span> 
          </div>
          <div class="grid grid-2col">
            <div class="flex-group-left flexcol competence-column">
              
              <header class="competence-header flexrow">
                <span class="competence-title">Compétences générales</span>
              </header>
              <ul class="item-list alterne-list">
                {{#each data.competenceByCategory.generale as |comp key|}}
                {{> "systems/foundryvtt-reve-de-dragon/templates/actor-sheet-competence-partial.html" comp}}
                {{/each}}
              </ul>

              <header class="competence-header flexrow">
                  <span class="competence-title">Compétences Particulières</span>
              </header>
              <ul class="item-list alterne-list">
                {{#each data.competenceByCategory.particuliere as |comp key|}}
                {{> "systems/foundryvtt-reve-de-dragon/templates/actor-sheet-competence-partial.html" comp}}
                {{/each}}
              </ul>

              <header class="competence-header flexrow">
                <span class="competence-title">Compétences Spécialisées</span>
              </header>
              <ul class="item-list alterne-list">
                {{#each data.competenceByCategory.specialisee as |comp key|}}
                {{> "systems/foundryvtt-reve-de-dragon/templates/actor-sheet-competence-partial.html" comp}}
                {{/each}}
              </ul>
            </div>
            
            <div class="flex-group-left flexcol competence-column">
              <header class="competence-header flexrow">
                <span class="competence-title">Compétences de Mêlée</span>
              </header>
              <ul class="item-list alterne-list">
                {{#each data.competenceByCategory.melee as |comp key|}}
                {{> "systems/foundryvtt-reve-de-dragon/templates/actor-sheet-competence-partial.html" comp}}
                {{/each}}
              </ul>
              
              <header class="competence-header flexrow">
                <span class="competence-title">Compétences de Tir</span>
              </header>
              <ul class="item-list alterne-list">
                {{#each data.competenceByCategory.tir as |comp key|}}
                {{> "systems/foundryvtt-reve-de-dragon/templates/actor-sheet-competence-partial.html" comp}}
                {{/each}}
              </ul>
              
              <header class="competence-header flexrow">
                <span class="competence-title">Compétences de Lancer</span>
              </header>
              <ul class="item-list alterne-list">
                {{#each data.competenceByCategory.lancer as |comp key|}}
                {{> "systems/foundryvtt-reve-de-dragon/templates/actor-sheet-competence-partial.html" comp}}
                {{/each}}
              </ul>

              <header class="competence-header flexrow">
                  <span class="competence-title">Connaissances</span>
              </header>
              <ul class="item-list alterne-list">
                {{#each data.competenceByCategory.connaissance as |comp key|}}
                {{> "systems/foundryvtt-reve-de-dragon/templates/actor-sheet-competence-partial.html" comp}}
                {{/each}}
              </ul>

              <header class="competence-header flexrow">
                  <span class="competence-title">Draconic</span>
              </header>
              <ul class="item-list alterne-list">
              {{#each data.competenceByCategory.draconic as |comp key|}}
              {{> "systems/foundryvtt-reve-de-dragon/templates/actor-sheet-competence-partial.html" comp}}
              {{/each}}
              </ul>
              <div>
                <ul class="item-list">
                  <li class="item flexrow">
                    <span class="generic-label">Stress transformé</span>
                    <input class="compteur-edit" type="text" name="experience" value="{{data.compteurs.experience.value}}" data-dtype="number" size="3"/>
                  </li>

                  <li class="item flexrow">
                    <span class="generic-label">Total XP compétences</span>
                    <span class="competence-value">{{calc.competenceXPTotal}}</span>
                  </li>
                  {{#if options.montrerArchetype}}
                  {{#each calc.comptageArchetype as |archetype key|}}
                  <li class="item flexrow">
                    <label class="generic-label">Archetype {{archetype.niveau}} : {{archetype.nombre}} / {{archetype.nombreMax}}</label>
                  </li>
                  {{/each}}
                  {{/if}}
                </ul>
              </div>    
            </div>
          </div>
        </div>

        {{!-- Combat Tab --}}
        <div class="tab combat" data-group="primary" data-tab="combat">
          <h3 class="blessures-title">Armes et Défenses:</h3>
            <ul class="item-list alterne-list">
              <li class="competence-header flexrow">
                <span class="competence-title competence-label">Armes</span>
                <span class="competence-title competence-label">Initiative</span>
                <span class="competence-title competence-label">Comp.</span>
                <span class="competence-title competence-value">Niveau</span>
                <span class="competence-title competence-value">+dom</span>
              </li>
            {{#each data.combat as |arme key|}}
              <li class="item flexrow list-item" data-item-id="{{arme._id}}">
                  <span class="arme-label"><a data-competence-name="{{arme.data.competence}}">{{arme.name}}</a></span>
                  <span class="arme-initiative"><a data-arme-name="{{arme.name}}" data-competence-name="{{arme.data.competence}}">{{arme.data.initiative}}</a></span>
                  <span class="competence-label">{{arme.data.competence}}</span>
                  <span class="competence-value">{{numberFormat arme.data.niveau decimals=0 sign=true}}</span>
                  <span class="competence-value">{{numberFormat arme.data.dommages decimals=0 sign=true}}</span>
              </li>
            {{/each}}
            <li class="item flexrow list-item">
              <span class="competence-label"><a data-competence-name="{{esquive.name}}">{{esquive.name}}</a></span>
              <span class="arme-initiative"></span>
              <span class="competence-label"></span>
              <span class="competence-value">{{numberFormat esquive.niveau decimals=0 sign=true}}</span>
              <span class="competence-value"></span>
          </li>
        </ul>
        <hr>

        {{!-- Liste de blessures --}}
        <h3 class="blessures-title">Blessures:</h3>
        <div class="flex-group-left flexcol competence-column">
          <h4 class="blessures-title">Légères:</h4>
          <ul class="blessure-data flexrow alterne-list blessures-list">
            {{#each data.blessures.legeres.liste as |bless key|}}
            <li class="item flexrow blessure-data list-item" data-blessure-type="legere" data-attribute={{key}} data-blessure-index="{{key}}">
              <ul>
                <li class="item-control blessure-control" title="Blessure Légère" data-blessure-active="{{bless.active}}">
                  {{#if bless.active}}
                    <i class="fas fa-circle"></i>
                  {{else}}
                    <i class="fas fa-genderless"></i>
                  {{/if}}
                </li>
                <li>
                  Premiers soins
                  <input class="blessures-soins" type="text" name='premiers_soins' data-dtype="number" value="{{bless.premiers_soins}}"/>
                </li>
                <li>
                  Soins complets
                  <input class="blessures-soins" type="text" name='soins_complets' data-dtype="number" value="{{bless.soins_complets}}"/>
                </li>
                <li>
                  Jours
                  <input class="blessures-soins" type="text" name='jours' data-dtype="number" value="{{bless.jours}}"/>
                </li>
                <li>
                  Loc.
                  <input class="blessures-soins" type="text" name='localisation' data-dtype="String" value="{{bless.loc}}"/>
                </li>
              </ul>
            </li>
            {{/each}}
          </ul>
          <h4 class="blessures-title">Graves :</h4>
          <ul class="flexrow alterne-list blessures-list">
            {{#each data.blessures.graves.liste as |bless key|}}
            <li class="item flexrow list-item" data-blessure-type="grave" data-attribute={{key}} data-blessure-index="{{key}}" >
              <ul>
                <li class="item-control blessure-control" title="Blessure Grave" data-blessure-active="{{bless.active}}">
                  {{#if bless.active}}
                    <i class="fas fa-circle"></i>
                  {{else}}
                    <i class="fas fa-genderless"></i>
                  {{/if}}
                </li>
                <li>
                  Premiers soins
                  <input class="blessures-soins" type="text" name='premiers_soins' data-dtype="number" value="{{bless.premiers_soins}}"/>
                </li>
                <li>
                  Soins complets
                  <input class="blessures-soins" type="text" name='soins_complets' data-dtype="number" value="{{bless.soins_complets}}"/>
                </li>
                <li>
                  Jours
                  <input class="blessures-soins" type="text" name='jours' data-dtype="number" value="{{bless.jours}}"/>
                </li>
                <li>
                  Loc.
                  <input class="blessures-soins" type="text" name='localisation' data-dtype="String" value="{{bless.loc}}"/>
                </li>
              </ul>
            </li>
            {{/each}}
          </ul>
          <h4 class="blessures-title">Critique :</h4>
          <ul class="flexrow alterne-list blessures-list">
            {{#each data.blessures.critiques.liste as |bless key|}}
            <li class="item list-item flexrow" data-blessure-type="critique" data-attribute={{key}} data-blessure-index="{{key}}" >
              <ul>
                <li class="flex-group-center item-control blessure-control" title="Blessure Critique" data-blessure-active="{{bless.active}}">
                  {{#if bless.active}}
                    <i class="fas fa-circle"></i>
                  {{else}}
                    <i class="fas fa-genderless"></i>
                  {{/if}}
                </li>
                <li>
                  Premiers soins
                  <input class="blessures-soins" type="text" name='premiers_soins' data-dtype="number" value="{{bless.premiers_soins}}"/>
                </li>
                <li>
                  Soins complets
                  <input class="blessures-soins" type="text" name='soins_complets' data-dtype="number" value="{{bless.soins_complets}}"/>
                </li>
                <li>
                  Jours
                  <input class="blessures-soins" type="text" name='jours' data-dtype="number" value="{{bless.jours}}"/>
                </li>
                <li>
                  Loc.
                  <input class="blessures-soins" type="text" name='localisation' data-dtype="String" value="{{bless.loc}}"/>
                </li>
              </ul>
            </li>
            {{/each}}
          </ul>
        </div>
        </div>

      {{!-- Connaissances Tab --}}
      <div class="tab connaissances" data-group="primary" data-tab="connaissances">
        <h3>Oeuvres diverses :</h3>
        <ul class="item-list alterne-list">
          {{#each data.chants as |chant id|}}
          <li class="item flexrow list-item" data-item-id="{{chant._id}}"><span>Chant</span><span class="competence-title chant-label"><a>{{chant.name}} (niveau {{chant.data.niveau}})</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}}
          {{#each data.musiques as |musique id|}}
          <li class="item flexrow list-item" data-item-id="{{musique._id}}"><span>Musique</span><span class="competence-title musique-label"><a>{{musique.name}} (niveau {{musique.data.niveau}})</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}}
          {{#each data.danses as |danse id|}}
          <li class="item flexrow list-item" data-item-id="{{danse._id}}"><span>Danse</span><span class="competence-title danse-label"><a>{{danse.name}} (niveau {{danse.data.niveau}})</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}}
          {{#each data.oeuvres as |oeuvre id|}}
          <li class="item flexrow list-item" data-item-id="{{oeuvre._id}}"><span>{{upperFirst oeuvre.data.competence}}</span><span class="competence-title oeuvre-label"><a>{{oeuvre.name}} (niveau {{oeuvre.data.niveau}})</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}}
          {{#each data.recettescuisine as |recette id|}}
          <li class="item flexrow list-item" data-item-id="{{recette._id}}"><span>Recette de cuisine</span><span class="competence-title recettecuisine-label"><a>{{recette.name}} (niveau {{recette.data.niveau}})</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>
        <h3>Jeux :</h3>
        <ul class="item-list alterne-list">
          {{#each data.jeux as |jeu id|}}
          <li class="item flexrow list-item" data-item-id="{{jeu._id}}"><span class="competence-title jeu-label"><a>{{jeu.name}} (base {{jeu.data.base}})</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>
        <h3>Recettes Alchimiques</h3>
          <ul class="item-list alterne-list">
          {{#each data.recettesAlchimiques as |recette id|}}
          <li class="item flexrow list-item" data-item-id="{{recette._id}}"><span class="competence-title recette-label item-edit"><a>{{recette.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>
        <h3>Tâches</h3><a id='creer-tache'>Créer une nouvelle Tâche</a>
          <ul class="item-list alterne-list">
          {{#each data.taches as |tache id|}}
          <li class="item flexrow list-item" data-item-id="{{tache._id}}"><span class="competence-title tache-label"><a>{{tache.name}} ({{tache.data.points_de_tache_courant}}/{{tache.data.points_de_tache}})</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>
          <hr>
      </div>

      {{!-- hautreve Tab --}}
      <div class="tab hautreve " data-group="primary" data-tab="hautreve" style="height:200px">
        <div>
          <h3>Haut rêve:</h3>
          <ul class="item-list">
            <li class="item flexrow">
              <span class="competence-label">Position en TMR :</span> 
              <span>
              {{#if options.isGM}}
                <input class="competence-value" type="text" name="data.reve.tmrpos.coord" value="{{data.reve.tmrpos.coord}}" data-dtype="String"/>
              {{else}}
                {{data.reve.tmrpos.coord}}
              {{/if}}
              </span>
            </li>
            <li class="item flexrow">
              <span class="competence-label">Seuil de Rêve :</span>
              <span>
              {{#if options.isGM}}
                <input class="seuil-reve-value" type="text" name="data.reve.seuil.value" value="{{data.reve.seuil.value}}" data-dtype="Number"/>
              {{else}}
                {{data.reve.seuil.value}}
              {{/if}}
              </span>
            </li>
            <li class="item flexrow" >
              <span class="competence-label">Refoulement : </span>
              <span>
              {{#if options.isGM}}
                <input class="competence-value" type="text" name="data.reve.refoulement.value" value="{{data.reve.refoulement.value}}" data-dtype="Number"/>
              {{else}}
                {{data.reve.refoulement.value}}
              {{/if}}
              </span>
            </li>
            <li class="item flexrow" >
              <span class="astrologie-label"><a id="jet-astrologie">Astrologie : Nombres Astraux</a></span>
            </li>
          </ul>
        </div>
        <hr>
        <div>
          <h3>Sorts:</h3>
          <ul class="item-list">
            {{#each data.sorts as |mysort key|}}
            <li class="item flexrow" data-item-id="{{mysort._id}}" data-attribute="{{key}}">
              <span class="sort-label"> <a data-id="{{mysort._id}}">{{mysort.name}}</a></span> 
              <span>{{mysort.data.draconic}} / {{mysort.data.difficulte}}</span>
              <div class="item-controls">
                <a class="item-control item-delete" title="Supprimer"><i class="fas fa-trash"></i></a>
              </div>
            </li>
            {{/each}}
          </ul>
        </div>
        <hr>
        <div>
          <h3>Sorts en Réserve:</h3>
          <ul class="item-list">
            {{#each hautreve.sortsReserve as |reserve key|}}
            <li class="item flexrow" data-item-id="{{mysort._id}}" data-attribute="{{key}}">
              <span class="sort-label"> {{reserve.sort.name}} - {{reserve.coord}}</span> 
            </li>
            {{/each}}
          </ul>
        </div>
        <hr>
        <div>
          <h3>Méditations:</h3>
          <ul class="item-list">
            {{#each data.meditations as |meditation key|}}
            <li class="item flexrow" data-item-id="{{meditation._id}}" data-attribute="{{key}}">
              <span class="meditation-label"><a data-id="{{meditation._id}}">{{meditation.name}} - {{meditation.data.competence}}</a></span> 
              <div class="item-controls">
                <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>
              </div>
            </li>
            {{/each}}
          </ul>
        </div>
        <hr>
        <div>
          <h3>Cases Spéciales:</h3>
          <ul class="item-list">
            {{#each hautreve.casesTmr as |casetmr key|}}
            <li class="item flexrow" data-item-id="{{casetmr._id}}" data-attribute="{{key}}">
              <span class="case-label"><a data-id="{{casetmr._id}}">{{casetmr.name}}</a></span> 
              <div class="item-controls">
                <a class="item-control item-delete" title="Supprimer"><i class="fas fa-trash"></i></a>
              </div>
            </li>
            {{/each}}
          </ul>
        </div>
        <hr>
        <div>
          <h3>Rencontres présentes:</h3>
          <ul class="item-list">
            {{#each hautreve.rencontres as |rencontre key|}}
            <li class="item flexrow" data-item-id="{{key}}" data-attribute="{{key}}">
              <span class="case-label"><a data-id="{{key}}">{{rencontre.rencontre.name}} - {{rencontre.coord}} {{#if rencontre.rencontre.date}}({{rencontre.rencontre.date}} - {{rencontre.rencontre.heure}}){{/if}}</a></span> 
              <div class="item-controls">
                <a class="item-control rencontre-delete" title="Supprimer"><i class="fas fa-trash"></i></a>
              </div>
            </li>
            {{/each}}
          </ul>
        </div>
        
        {{!-- Queues, Souffles, Tetes, Ombre --}}
        <hr>
        <h3>Queues:</h3>
        <ul class="flex-group-left">
          {{#each data.queues as |queue key|}}
          <li class="item flexrow" data-attribute={{key}} data-item-id="{{queue._id}}">
            <span class="queuesouffle-label"> <a data-item-id="{{queue._id}}">{{queue.name}}</a></span>
            <div class="item-controls">
              <a class="item-control item-delete" title="Delete Item"><i class="fas fa-trash"></i></a>
            </div>
          </li>
          {{/each}}
        </ul>
        <h3>Souffles:</h3>
        <ul class="item-list">
          {{#each data.souffles as |souffle key|}}
          <li class="item flexrow" data-attribute={{key}} data-item-id="{{souffle._id}}">
            <span class="queuesouffle-label"> <a data-item-id="{{souffle._id}}">{{souffle.name}}</a></span>
            <div class="item-controls">
              <a class="item-control item-delete" title="Delete Item"><i class="fas fa-trash"></i></a>
            </div>
          </li>
          {{/each}}                 
        </ul>
        <h3>Tetes:</h3>
        <ul class="item-list">
          {{#each data.tetes as |tete key|}}
          <li class="item flexrow" data-attribute={{key}} data-item-id="{{tete._id}}">
            <span class="queuesouffle-label"> <a data-item-id="{{tete._id}}">{{tete.name}}</a></span>
            <div class="item-controls">
              <a class="item-control item-delete" title="Delete Item"><i class="fas fa-trash"></i></a>
            </div>
          </li>
          {{/each}}
        </ul>
        <h3>Ombres de Thanatos:</h3>
        <ul class="item-list">
          {{#each data.ombres as |ombre key|}}
          <li class="item flexrow" data-attribute={{key}} data-item-id="{{ombre._id}}">
            <span class="queuesouffle-label"> <a data-item-id="{{ombre._id}}">{{ombre.name}}</a></span>
            <div class="item-controls">
              <a class="item-control item-delete" title="Delete Item"><i class="fas fa-trash"></i></a>
            </div>
          </li>
          {{/each}}
        </ul>

      </div>

      {{!-- Equipment Tab --}}
      <div class="tab items" data-group="primary" data-tab="items">
        <span class="item-name"><h4>Argent et Monnaies</h4></span>
        <ul class="item-list alterne-list">
          {{#each data.monnaie as |piece id|}}
          <li class="item flexrow list-item" data-item-id="{{piece._id}}">
            <img class="sheet-competence-img" src="{{piece.img}}" title="{{piece.name}}"/>
            <span class="competence-title competence-label">{{piece.name}}</span>
            <span class="competence-title competence-label">{{piece.data.quantite}}</span>
            <span class="competence-title"><a class="monnaie-plus">+</a><a class="monnaie-moins">-</a></span>
            <div class="item-controls">
              <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>
          </div>
          </li>
          {{/each}}
        </ul>

        <span class="item-name"><h4>Equipement porté</h4></span>
        <div>
          <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">Estimation de l'équipement : {{numberFormat calc.prixTotalEquipement decimals=2}} Sols</span>
          </div>
        <div>
          <span class="item-name"><a id="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}}
          </div>
      <ul class="item-list alterne-list">
        <li class="competence-header flexrow">
          <img class="sheet-competence-img" src="systems/foundryvtt-reve-de-dragon/icons/objets/sac_a_dos.webp" title="Equipement"/>
          <span class="competence-title competence-label">Nom</span>
          <span class="competence-title competence-label">Q.</span>
          <span class="competence-title competence-label">Enc.</span>
          <span class="competence-title competence-label">Equiper/Editer/Suppr.</span>
        </li>
        {{#each data.objets as |item id|}}
          {{#unless item.estContenu}}
          {{#if (ne item.type 'conteneur')}}
          <li class="item flexrow list-item" data-item-id="{{item._id}}">
              <img class="sheet-competence-img" src="{{item.img}}" title="{{item.name}}"/>
              <span class="item-name">{{item.name}}</span>
              <span class="item-quantite">{{item.data.quantite}}</span>
              <span class="item-quantite">{{numberFormat item.data.encTotal decimals=2}}</span>
              <span class="item-controls">
                  <a class="item-control item-equip" title="Equiper">{{#if item.data.equipe}}<i class="fas fa-circle"></i>{{else}}<i class="fas fa-genderless"></i>{{/if}}</a>
                  <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>
              </span>
          </li>
          {{/if}}
          {{/unless}}
          {{/each}}
          {{#each data.conteneurs as |conteneur id|}}
          {{buildConteneur this}}
          {{/each}}
        </ul>

        <span class="item-name"><h4>Montures</h4></span>
        <ul class="item-list alterne-list">
          {{#each subacteurs.montures as |monture id|}}
          <li class="item flexrow list-item" data-actor-id="{{monture.id}}">
            <img class="sheet-competence-img" src="{{monture.img}}" title="{{monture.name}}"/>
            <span class="competence-title subacteur-label"><a>{{monture.name}}</a></span>
            <div class="item-controls">
              <a class="item-control subacteur-delete" title="Supprimer"><i class="fas fa-trash"></i></a>
          </div>
          </li>
          {{/each}}
        </ul>
        
        <span class="item-name"><h4>Véhicules</h4></span>
        <ul class="item-list alterne-list">
          {{#each subacteurs.vehicules as |vehicule id|}}
          <li class="item flexrow list-item" data-actor-id="{{vehicule.id}}">
            <img class="sheet-competence-img" src="{{vehicule.img}}" title="{{vehicule.name}}"/>
            <span class="competence-title subacteur-label"><a>{{vehicule.name}}</a></span>
            <span class="competence-title">{{vehicule.categorie}}</span>
            <span class="competence-title">{{vehicule.structure}}</span>
            <div class="item-controls">
              <a class="item-control subacteur-delete" title="Supprimer"><i class="fas fa-trash"></i></a>
          </div>
          </li>
          {{/each}}
        </ul>

        <span class="item-name"><h4>Suivants</h4></span>
        <ul class="item-list alterne-list">
          {{#each subacteurs.suivants as |suivant id|}}
          <li class="item flexrow list-item" data-actor-id="{{suivant.id}}">
            <img class="sheet-competence-img" src="{{suivant.img}}" title="{{suivant.name}}"/>
            <span class="competence-title subacteur-label"><a>{{suivant.name}}</a></span>
            <div class="item-controls">
              <a class="item-control subacteur-delete" title="Supprimer"><i class="fas fa-trash"></i></a>
          </div>
          </li>
          {{/each}}
        </ul>

      </div>

      {{!-- Biography Tab --}}
      <div class="tab biography" data-group="primary" data-tab="description">        
        <article class="flexrow">
          <ul class="item-list alterne-list">
            <li class="item flexrow list-item">
              <label class="description-label competence-label">Sexe : 
                <input class="description-value flexrow" type="text" name="data.sexe" value="{{data.sexe}}" data-dtype="String"/>
              </label>
            </li>
            <li class="item flexrow list-item">
              <label class="description-label competence-label">Poids : 
                <input class="description-value flexrow" type="text" name="data.poids" value="{{data.poids}}" data-dtype="String"/>
              </label>
            </li>
            <li class="item flexrow list-item">
              <label class="description-label competence-label">Taille : 
                <input class="description-value flexrow" type="text" name="data.taille" value="{{data.taille}}" data-dtype="String"/>
              </label>
            </li>
            <li class="item flexrow list-item">
              <label class="description-label competence-label">Cheveux : 
                <input class="description-value flexrow" type="text" name="data.cheveux" value="{{data.cheveux}}" data-dtype="String"/>
              </label>
            </li>
            <li class="item flexrow list-item">
              <label class="description-label competence-label">Yeux : 
                <input class="description-value flexrow" type="text" name="data.yeux" value="{{data.yeux}}" data-dtype="String"/>
              </label>
            </li>
          </ul>
          <ul class="item-list alterne-list">
            <li class="item flexrow list-item">
              <label class="description-label competence-label">Age : 
                <input class="description-value flexrow" type="text" name="data.age" value="{{data.age}}" data-dtype="String"/>
              </label>
            </li>
            <li class="item flexrow list-item">
              <label class="description-label competence-label">Heure de naissance : 
                <select class="description-value flexrow" type="text" name="data.heure" value="{{data.heure}}" data-dtype="String">
                  {{#select data.heure}}
                  {{>"systems/foundryvtt-reve-de-dragon/templates/heures-select-option.html"}}
                  {{/select}}
                </select>
              </label>
            </li>
            <li class="item flexrow list-item">
              <label class="description-label competence-label">Beauté : 
                <label class="description-label competence-label">{{data.beaute}}
                </label>
              </label>
            </li>
            <li class="item flexrow list-item">
              <label class="description-label competence-label">Main directrice : 
                <input class="description-value flexrow" type="text" name="data.main" value="{{data.main}}" data-dtype="String"/>
              </label>
            </li>
          </ul>
        </article>

        <article class="flexcol">
          <h3>Biographie : </h3>
          <div class="form-group editor">
            {{editor content=data.biographie target="data.biographie" button=true owner=owner editable=editable}}
          </div>
          <h3>Notes : </h3>
          <div class="form-group editor">
            {{editor content=data.notes target="data.notes" button=true owner=owner editable=editable}}
          </div>
          {{>"systems/foundryvtt-reve-de-dragon/templates/editor-notes-mj.html"}}
        </article>
      </div>

    </section>
</form>

