{{log "handlebar actor-sheet" this}} 
<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="stats">{{localize 'SHEET.TabStats'}}</a>
        <a class="item" data-tab="skills">{{localize 'SHEET.TabSkills'}}</a>
        <a class="item" data-tab="consequences">{{localize 'SHEET.TabConsequences'}}</a>
        <a class="item" data-tab="gears">{{localize 'SHEET.TabGears'}}</a>
        <a class="item" data-tab="description">{{localize 'SHEET.TabDescription'}}</a>
    </nav>

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

        {{!-- Carac Tab --}}
        <div class="tab items" data-group="primary" data-tab="stats">
          <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-shadows-over-sol/img/icons/{{#if editStatSkill}}unlocked.svg{{else}}locked.svg{{/if}}" alt="lock/unlock"
                >{{#if editStatSkill}}Lock{{else}}Unlock{{/if}}</a></span>
              <ul class="stat-list alternate-list">
                <li class="stat flexrow" >
                  <span class="stat-label flexrow tooltip tooltip-nobottom" name="statlabel">Stat name</span>
                  <span class="stat-label flexrow tooltip tooltip-nobottom" name="statlabel">Value</span>
                  <span class="stat-label flexrow tooltip tooltip-nobottom" name="statlabel">XP</span>
                </li>

                  {{#each data.stats as |stat key|}}
                    {{#if stat.isLevelUp}}
                    <li class="stat flexrow xp-level-up" data-attribute="{{key}}">
                      <span class="stat-label flexrow tooltip tooltip-nobottom" name="system.stats.{{key}}.label">
                        <span class="tooltiptext ttt-xp">
                          {{localize 'STAT.levelUp'}}
                      </span>
                      {{else}}
                      <li class="stat flexrow list-item" data-attribute="{{key}}">
                      {{/if}}
                      <span class="stat-label flexrow tooltip tooltip-nobottom" name="system.stat.{{key}}.label"><a name={{key}}>{{localize stat.label}}</a></span>
                      <select class="stat-value flexrow" type="text" name="system.stats.{{key}}.value" value="{{stat.value}}" data-dtype="Number" {{#unless @root.editStatSkill}}disabled{{/unless}}>
                        {{#select stat.value}}
                        {{>"systems/foundryvtt-shadows-over-sol/templates/stat-option-list.html"}}
                        {{/select}}
                      </select>     
                      <input class="stat-xp flexrow" type="text" name="system.stats.{{key}}.xp" value="{{stat.xp}}" data-dtype="Number" {{#unless @root.editStatSkill}}disabled{{/unless}} />
                      <span class="flexrow"><img class="cardsuit-img" src="systems/foundryvtt-shadows-over-sol/img/cards/{{stat.cardsuit}}.webp" /></span>
                      </li>
                {{/each}}
              </ul>          
            </div>
            <div class="flex-group-left flexcol">
              <ul class="stat-list alternate-list">
                <li class="stat flexrow" >
                  <span class="generic-label flexrow tooltip tooltip-nobottom" name="statlabel">Score name</span>
                  <span class="generic-label flexrow tooltip tooltip-nobottom" name="statlabel">Value</span>
                  <span class="generic-label flexrow tooltip tooltip-nobottom" name="statlabel">Bonus/Malus</span>
                </li>
                {{#each data.scores as |score key|}}
                  <li class="stat flexrow list-item" data-attribute="{{key}}">
                    <span class="generic-label flexrow tooltip tooltip-nobottom" name="system.scores.{{key}}.label">{{localize score.label}}</span>                    
                    <input class="stat-value flexrow" type="text" name="system.scores.{{key}}.value" value="{{score.value}}" data-dtype="Number" {{#unless @root.editStatSkill}}disabled{{/unless}} />
                    {{#if (eq key 'defense')}}
                    <input class="stat-value flexrow" type="text" name="system.scores.{{key}}.critical" value="{{score.critical}}" data-dtype="Number" {{#unless @root.editStatSkill}}disabled{{/unless}} />
                    {{/if}}
                    <input class="stat-value flexrow" type="text" name="system.scores.{{key}}.bonusmalus" value="{{score.bonusmalus}}" data-dtype="Number" {{#unless @root.editStatSkill}}disabled{{/unless}} />
                  </li>
                {{/each}}
              </ul>          
            </div>
          </div>
          
          <div class="flexcol">
            <h3 class="edge-name">Current deck size : {{deckSize}} cards</h3>
            <div class="flexrow">
              <span class="edge-name"><a class="card-button reset-deck-full">Reset full deck and edges</a></span>
              <span class="edge-name"><a class="card-button draw-new-edge">Draw a new Edge card</a></span>
              <span class="edge-name"><a class="card-button reset-deck">Reset deck only (ie after a Joker)</a></span>
            </div>
            <span class="edge-name">
              <h3 class="edge-name">Edge cards : </h3>
              <div class="flexrow">
                {{#each edgecard as |card key|}}
                <div class="flexcol">
                  <img class="card-img" src="{{card.path}}" data-edit="img" title="{{card.cardName}}" />
                  <span class="edge-name"><a class="card-button discard-card" data-discard="{{card.cardName}}">Discard</a></span>
                </div>
                {{/each}}
              </div>
            </span>
          </div>

        </div>
        
        {{!-- Skills Tab --}}
        <div class="tab skills" data-group="primary" data-tab="skills">
          <div class="flexrow">
            <span><a class="lock-unlock-sheet"><img class="small-button-container" 
              src="systems/foundryvtt-shadows-over-sol/img/icons/{{#if editStatSkill}}unlocked.svg{{else}}locked.svg{{/if}}" alt="lock/unlock"
              >{{#if editStatSkill}}Lock{{else}}Unlock{{/if}}</a></span>
          </div>
          
          <span class="generic-label">Skills</span>
          <div class="grid grid-2col">

          <div class="flex-group-left flexcol skill-column">
            <ul class="item-list alterne-list">
              {{#each skill1 as |skill key|}}
                {{#if skill.system.isLevelUp}}
                <li class="item flexrow xp-level-up" data-item-id="{{skill.id}}">
                {{else}}
                <li class="item flexrow list-item" data-item-id="{{skill.id}}">
                {{/if}}
                  <img class="sheet-skill-img" src="{{skill.img}}"/>
                  {{#if skill.system.isLevelUp}}
                  <span class="skill-label tooltip tooltip-nobottom">
                    <span class="tooltiptext ttt-xp">
                    </span>
                  <a name={{key}}>{{skill.name}}</a></span>
                  {{else}}                          
                  <span class="skill-label"><a>{{skill.name}}</a></span>
                  {{/if}}
                  <input class="skill-value" type="text" skillname="{{skill.name}}" value="{{numberFormat skill.system.value decimals=0}}" data-dtype="number" {{#unless @root.editStatSkill}}disabled{{/unless}}/>
                  <input class="skill-xp" type="text" skillname="{{skill.name}}" value="{{skill.system.xp}}" data-dtype="number" {{#unless @root.editStatSkill}}disabled{{/unless}}/>
                  <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 class="flex-group-left flexcol skill-column">
            <ul class="item-list alterne-list">
              {{#each skill2 as |skill key|}}
                {{#if skill.system.isLevelUp}}
                <li class="item flexrow xp-level-up" data-item-id="{{skill.id}}">
                {{else}}
                <li class="item flexrow list-item" data-item-id="{{skill.id}}">
                {{/if}}
                  <img class="sheet-skill-img" src="{{skill.img}}"/>
                  {{#if skill.system.isLevelUp}}
                  <span class="skill-label tooltip tooltip-nobottom">
                    <span class="tooltiptext ttt-xp">
                    </span>
                  <a name={{key}}>{{skill.name}}</a></span>
                  {{else}}                          
                  <span class="skill-label"><a>{{skill.name}}</a></span>
                  {{/if}}
                  <input class="skill-value" type="text" skillname="{{skill.name}}" value="{{numberFormat skill.system.value decimals=0}}" data-dtype="number" {{#unless @root.editStatSkill}}disabled{{/unless}}/>
                  <input class="skill-xp" type="text" skillname="{{skill.name}}" value="{{skill.system.xp}}" data-dtype="number" {{#unless @root.editStatSkill}}disabled{{/unless}}/>
                  <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>

        {{!-- Consequences Tab --}}
        <div class="tab consequences" data-group="primary" data-tab="consequences">
          <span><a class="lock-unlock-sheet"><img class="small-button-container" 
            src="systems/foundryvtt-shadows-over-sol/img/icons/{{#if editStatSkill}}unlocked.svg{{else}}locked.svg{{/if}}" alt="lock/unlock"
            >{{#if editStatSkill}}Lock{{else}}Unlock{{/if}}</a></span>
            <h4>Wounds & Conséquences</h4>
          <div class="grid grid-2col">
            <div class="flex-group-left flexcol skill-column">
              <ul class="item-list alterne-list">
                <li class="item flexrow list-item" data-wound-name="light"><h4>Wounds : </h4></li>
                <li class="item flexrow list-item" data-wound-name="light"><span class="skill-label">Light :</span>
                  <input class="wound-value" type="text" woundname="light" value="{{numberFormat data.wounds.light decimals=0}}" data-dtype="number" {{#unless @root.editStatSkill}}disabled{{/unless}}/>
                </li>
                <li class="item flexrow list-item" data-wound-name="moderate"><span class="skill-label">Moderate :</span> 
                  <input class="wound-value" type="text" woundname="moderate" value="{{numberFormat data.wounds.moderate decimals=0}}" data-dtype="number" {{#unless @root.editStatSkill}}disabled{{/unless}}/>
                </li>
                <li class="item flexrow list-item" data-wound-name="severe"><span class="skill-label">Severe :</span>
                <input class="wound-value" type="text" woundname="severe" value="{{numberFormat data.wounds.severe decimals=0}}" data-dtype="number" {{#unless @root.editStatSkill}}disabled{{/unless}}/>
                </li>
                <li class="item flexrow list-item" data-wound-name="critical"><span class="skill-label">Critical :</span> 
                  <input class="wound-value" type="text" woundname="critical" value="{{numberFormat data.wounds.critical decimals=0}}" data-dtype="number" {{#unless @root.editStatSkill}}disabled{{/unless}}/>
                </li>
                <li class="item flexrow list-item" data-wound-name="critical"><span class="skill-label">Total :</span> 
                  <span class="skill-label">{{data.currentWounds}} / {{data.totalWounds}}</span>
                </li>
              </ul>
            </div>
            <div class="flex-group-left flexcol skill-column">
              <ul class="item-list alterne-list">
                {{#each consequences as |conseq key|}}
                <li class="item flexrow list-item" data-item-id="{{conseq.id}}">
                  <img class="sheet-skill-img" src="{{conseq.img}}"/>
                  <span class="conseq-label">{{conseq.name}}</span>
                  <select class="consequence-severity" type="text" name="conseq.system.severity" value="{{conseq.system.severity}}" data-dtype="String">
                    {{#select conseq.system.severity}}
                    <option value="none">None</option>
                    <option value="light">Light</option>
                    <option value="moderate">Moderate</option>
                    <option value="severe">Severe</option>
                    <option value="critical">Critical</option>
                    {{/select}}
                  </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>
        </div>

        {{!-- Gears Tab --}}
        <div class="tab gears" data-group="primary" data-tab="gears">
          <div>
            <h4>Total Encumbrance : {{totalEncumbrance}} / {{data.data.stats.strength.value}}</h4>
          </div>
          <div><h4>Weapons</h4></div>
          <ul class="item-list alternate-list">
            {{#each weapons as |weapon key|}}
            <li class="item flexrow list-item" data-item-id="{{weapon.id}}">
              <img class="sheet-skill-img" src="{{weapon.img}}"/>
              <span class="weapon-label"><a>{{weapon.name}}</a></span>
              <div class="item-controls">
                <a class="item-control item-equip" title="Equipped">{{#if weapon.system.equiped}}<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>Armors</h4></div>
          <ul class="item-list alternate-list">
            {{#each armors as |armor key|}}
            <li class="item flexrow list-item" data-item-id="{{armor.id}}">
              <img class="sheet-skill-img" src="{{armor.img}}"/>
              <span class="armor-label">{{armor.name}}</span>
              <div class="item-controls">
                <a class="item-control item-worn" title="Worn">{{#if armor.system.worn}}<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>Equipment/Gears</h4></div>
          <ul class="item-list alternate-list">
            {{#each gearsRoot as |gear key|}}
            <li class="item flexrow list-item" data-item-id="{{gear.id}}">
              <img class="sheet-skill-img" src="{{gear.img}}"/>
              <span class="conseq-label">{{gear.name}}</span>
              <div class="item-controls">
                <a class="item-control item-equip" title="Worn">{{#if gear.system.worn}}<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>                  
            <ul class="item-list alternate-list list-item-margin1">
                {{#each data.contains as |subgear key|}}
                <li class="item flexrow list-item" data-item-id="{{subgear.id}}">
                  <img class="sheet-skill-img" src="{{subgear.img}}"/>
                  <span class="conseq-label">{{subgear.name}}</span>
                  <div class="item-controls">
                    <a class="item-control item-equip" title="Worn">{{#if subgear.worn}}<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>
                    {{/each}}
              </ul>
          {{/each}}
          </ul>
        </div>


      {{!-- Biography Tab --}}
      <div class="tab biography" data-group="primary" data-tab="description">        
        <article class="flexrow">          
          <ul class="item-list alternate-list">
            <li class="item flexrow list-item">
              <label class="description-label generic-label">Geneline : </label>
              <label class="description-label generic-label item-link"><a data-item-id="{{system.geneline.id}}">{{data.geneline.name}}</a></label>
            </li>
            <li class="item flexrow list-item">
              <label class="description-label generic-label">Main Subculture :</label>
              <select class="stat-value flexrow" type="text" name="system.subculture" value="{{system.subculture}}" data-dtype="String">
                {{#select subculture}}
                {{#each subcultureList as |subculture key|}}
                <option value="{{subculture.name}}">{{subculture.name}}</option>
                {{/each}}
                {{/select}}
              </select>     
            </li>
            <li class="item flexrow list-item">
              <label class="description-label stat-label">Genre : </label>
              <input class="description-value flexrow" type="text" name="system.sex" value="{{data.sex}}" data-dtype="String"/>
            </li>
            <li class="item flexrow list-item">
              <label class="description-label stat-label">Weight : </label>
              <input class="description-value flexrow" type="text" name="system.weight" value="{{data.weight}}" data-dtype="String"/>              
            </li>
            <li class="item flexrow list-item">
              <label class="description-label stat-label">Size : </label>
              <input class="description-value flexrow" type="text" name="system.taille" value="{{data.taille}}" data-dtype="String"/>
            </li>
          </ul>
          <ul class="item-list alterne-list">
            <li class="item flexrow list-item">
              <label class="description-label stat-label">Hair : </label>
              <input class="description-value flexrow" type="text" name="system.hair" value="{{data.hair}}" data-dtype="String"/>
            </li>
            <li class="item flexrow list-item">
              <label class="description-label stat-label">Eyes : </label>
              <input class="description-value flexrow" type="text" name="system.eyes" value="{{data.eyes}}" data-dtype="String"/>
            </li>
            <li class="item flexrow list-item">
              <label class="description-label stat-label">Age : </label>
              <input class="description-value flexrow" type="text" name="system.age" value="{{data.age}}" data-dtype="String"/>
            </li>
          </ul>
        </article>
        <hr>
        <article class="flexcol">
          <div class="grid grid-3col">

            <div class="flex-group-left flexcol genelang-column">  
              <span class="description-label">Familiar Subcultures</span>
              <ul class="item-list alternate-list">
                {{#each subcultureList as |subculture key|}}
                <li class="item flexrow list-item" data-item-id="{{subculture.id}}">
                  <img class="sheet-skill-img" src="{{subculture.img}}"/>
                  <span class="conseq-label genelang-label">{{subculture.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 class="flex-group-left flexcol genelang-column">  
              <span class="description-label">Known Languages</span>
              <ul class="item-list alternate-list">
                {{#each languageList as |language key|}}
                <li class="item flexrow list-item" data-item-id="{{language.id}}">
                  <img class="sheet-skill-img" src="{{language.img}}"/>
                  <span class="conseq-label">{{language.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 class="flex-group-left flexcol genelang-column">  
              <span class="description-label">Weaknesses</span>
              <ul class="item-list alternate-list">
                {{#each weaknessList as |weakness key|}}
                <li class="item flexrow list-item" data-item-id="{{weakness.id}}">
                  <img class="sheet-skill-img" src="{{weakness.img}}"/>
                  <span class="conseq-label">{{weakness.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>          
        </article>

        <hr>

        <article class="flexcol">
          <hr>
          <h3>Biography : </h3>
          <div class="form-group editor">
            {{editor data.history target="system.history" button=true owner=owner editable=editable}}
          </div>
          <hr>
          <h3>Notes : </h3>
          <div class="form-group editor">
            {{editor data.notes target="system.notes" button=true owner=owner editable=editable}}
          </div>
          <hr>
          {{>"systems/foundryvtt-shadows-over-sol/templates/editor-notes-gm.html"}}
        </article>
      </div>

    </section>
</form>

