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

  {{!-- Sheet Header --}}
  <header class="sheet-header">
    <div class="header-fields">
      <div class="flexrow">

        <div class="profile-img-container">
          <img class="profile-img" src="{{img}}" data-edit="img" title="{{name}}" />
        </div>

        <div class="flexcol">
          <h1 class="charname margin-right"><input name="name" type="text" value="{{name}}" placeholder="Name" /></h1>

          <div class="flexrow">
            <ul>
              <li class="flexrow item" data-item-id="{{spleen.id}}">
                <label class="item-field-label-short">Spleen :</label>
                <label class="item-name-label-long" title="{{spleen.name}}">{{spleen.name}}</label>
                {{#if spleen}}
                <div class="item-controls item-controls-fixed-full">
                  <a class="item-control item-add" data-type="trait" title="Create Trait"><i
                      class="fas fa-plus"></i></a>
                  <a class="item-control item-edit" data-type="trait" title="Edit Item"><i class="fas fa-edit"></i></a>
                  <a class="item-control item-add" data-type="trait" title="Delete Item"><i
                      class="fas fa-trash"></i></a>
                </div>
                {{/if}}
              </li>
              <li class="item flexrow" data-item-id="{{ideal.id}}">
                <label class="item-field-label-short">Ideal :</label>
                <label class="item-name-label-long" title="{{ideal.name}}">{{ideal.name}}</label>
                {{#if ideal}}
                <div class="item-controls item-controls-fixed-full">
                  <a class="item-control item-add" data-type="trait" title="Create Trait"><i
                      class="fas fa-plus"></i></a>
                  <a class="item-control item-edit" data-type="trait" title="Edit Item"><i class="fas fa-edit"></i></a>
                  <a class="item-control item-add" data-type="trait" title="Delete Item"><i
                      class="fas fa-trash"></i></a>
                </div>
                {{/if}}
              </li>
              <li class="item flexrow flexrow-no-expand flexrow-start ">
                <label class="item-name-label-short">Traits :</label>
                {{#each traits as |trait key|}}
                  <label class="item-name-label-free" title="{{trait.name}}"><a data-item-id="{{trait._id}}" class="item-edit">{{trait.name}}</a>,&nbsp;</label>
                {{/each}}
              </li>

            </ul>
          </div>

        </div>
      </div>
    </div>
    </div>

  </header>

  {{!-- Sheet Tab Navigation --}}
  <nav class="sheet-tabs tabs" data-group="primary">
    <a class="item" data-tab="competences">{{localize "ECRY.ui.skills"}}</a>
    <a class="item" data-tab="traits">{{localize "ECRY.ui.traits"}}</a>
    <a class="item" data-tab="combat">{{localize "ECRY.ui.healthcombat"}}</a>
    {{#if hasCephaly}}
    <a class="item" data-tab="cephaly">{{localize "ECRY.ui.cephaly"}}</a>
    {{/if}}
    <a class="item" data-tab="equipements">{{localize "ECRY.ui.equipment"}}</a>
    <a class="item" data-tab="biodata">{{localize "ECRY.ui.bionotes"}}</a>
  </nav>

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

    {{!-- Skills Tab --}}
    <div class="tab competences" data-group="primary" data-tab="competences">


      <div class="grid grid-3col">

        {{#each skills as |category categkey|}}
        <div>
          <ul class="stat-list alternate-list item-list">
            <li class="item flexrow list-item items-title-bg">
              <span class="item-name-label-header impact-title">
                <h3>
                  
                {{#if (eq @root.type "npc")}}
                  <a class="roll-skill-confront" data-category-key="{{categkey}}" data-skill-key="rawnpc">
                    <i class="fa-regular fa-swords"></i>
                  </a>
                  <a class="roll-skill" data-category-key="{{categkey}}" data-skill-key="rawnpc">
                  <i class="fa-solid fa-dice-d6"></i>
                {{/if}}
                  <label class="items-title-text">{{localize category.name}} ({{valueAtIndex @root.impactsMalus
                    categkey}})</label>
                {{#if (eq @root.type "npc")}}
                  </a>
                  <select class="item-field-label-short-header" type="text"
                      name="system.skills.{{categkey}}.pnjvalue" value="{{category.pnjvalue}}"
                        data-dtype="Number">
                        {{selectOptions @root.config.skillLevel selected=category.pnjvalue}}
                  </select>
                {{/if}}
                </h3>
              </span>
            </li>
            
            {{#each category.skilllist as |skill skillkey|}}
            <li class="item flexrow list-item">
              <span class="item-name-label-long">
                <a class="roll-skill-confront" data-category-key="{{categkey}}" data-skill-key="{{skillkey}}">
                  <i class="fa-regular fa-swords"></i>
                </a>
                <a class="roll-skill" data-category-key="{{categkey}}" data-skill-key="{{skillkey}}">
                  <i class="fa-solid fa-dice-d6"></i>
                  {{localize skill.name}}
                </a></span>
              <select class="item-field-skill-level"
                name="system.skills.{{categkey}}.skilllist.{{skillkey}}.value"
                title="{{localize "ECRY.ui.transcendenceCurrent"}}">
                {{selectOptions @root.config.skillLevel selected=skill.value}}
              </select>
              <span class="skill-separator">/</span>
              <select class="item-field-skill-level"
                name="system.skills.{{categkey}}.skilllist.{{skillkey}}.max"
                title="{{localize "ECRY.ui.transcendenceMax"}}"
                {{#unless editScore}}disabled{{/unless}}>
                {{selectOptions @root.config.skillLevel selected=skill.max}}
              </select>
            </li>
            <li class="item flexrow list-item">
              <ul class="ul-level1">
                {{#each skill.spec as |spec idx|}}
                <li class="item flexrow list-item" data-item-id="{{spec._id}}" data-item-type="specialization">
                  <a class="roll-spec" data-category-key="{{categkey}}" data-skill-key="{{skillkey}}"
                    data-spec-id="{{spec._id}}">
                    <i class="fa-solid fa-dice-d6"></i>
                    {{spec.name}}
                  </a>
                  <div class="item-controls item-controls-fixed">
                    <a class="item-control item-edit" data-type="specialization" title="Edit Item"><i
                        class="fas fa-edit"></i></a>
                    <a class="item-control item-delete" data-type="specialization" title="Delete Item"><i
                        class="fas fa-trash"></i></a>
                  </div>
                </li>
                {{/each}}
              </ul>
            </li>
            {{/each}}
          </ul>
        </div>
        {{/each}}
      </div>

      <div class="skill-toolbar">
        <a class="lock-unlock-sheet" title="{{localize "ECRY.ui.toggleEditMax"}}">
          <i class="fas {{#if editScore}}fa-lock-open{{else}}fa-lock{{/if}}"></i>
          {{localize "ECRY.ui.toggleEditMax"}}
        </a>
      </div>

    </div>

    {{#if hasCephaly}}
    {{!-- Cephaly Tab --}}
    <div class="tab cephaly" data-group="primary" data-tab="cephaly">

      <div class="grid grid-2col">

        <div>

          <h3>{{localize "ECRY.ui.cephaly"}}</h3>
          <ul class="stat-list alternate-list item-list">
            {{#each cephalySkills as |skill skillkey|}}
            <li class="item flexrow list-item">
              <span class="item-name-label-long">
                <a class="roll-cephaly" data-category-key="cephaly" data-skill-key="{{skillkey}}">
                  <i class="fa-solid fa-dice-d6"></i>
                  {{localize skill.name}}
                </a></span>
              <select class="item-field-skill-level"
                name="system.cephaly.skilllist.{{skillkey}}.value"
                title="{{localize "ECRY.ui.transcendenceCurrent"}}">
                {{selectOptions @root.config.skillLevel selected=skill.value}}
              </select>
              <span class="skill-separator">/</span>
              <select class="item-field-skill-level"
                name="system.cephaly.skilllist.{{skillkey}}.max"
                title="{{localize "ECRY.ui.transcendenceMax"}}"
                {{#unless editScore}}disabled{{/unless}}>
                {{selectOptions @root.config.skillLevel selected=skill.max}}
              </select>
            </li>
            {{/each}}
          </ul>

        </div>

        <div>
          {{#if annency}}
          <h3>{{localize "ECRY.ui.annency"}} : <a class="open-annency"
              data-annency-id="{{annency.id}}">{{annency.name}}<i class="fas fa-edit"></i></a></h3>
          <ul class="stat-list alternate-list item-list">
            <li class="item flexrow list-item">
              <span class="item-name-label-long">
                {{annency.system.base.description}}
              </span>
            </li>
          </ul>
          {{/if}}

        </div>

      </div>

      <div class="skill-toolbar">
        <a class="lock-unlock-sheet" title="{{localize "ECRY.ui.toggleEditMax"}}">
          <i class="fas {{#if editScore}}fa-lock-open{{else}}fa-lock{{/if}}"></i>
          {{localize "ECRY.ui.toggleEditMax"}}
        </a>
      </div>

    </div>
    {{/if}}

    <div class="tab traits" data-group="primary" data-tab="traits">

      <ul class="item-list alternate-list">
        <li class="item flexrow list-item items-title-bg">
          <span class="item-name-label-header-long2">
            <h3><label class="item-name-label-header-long2">Traits</label></h3>
          </span>
          <span class="item-field-label-short">
            <label class="item-field-label-short">Niveau</label>
          </span>
          <div class="item-controls item-controls-fixed">
            <a class="item-control item-add" data-type="trait" title="Create Trait"><i class="fas fa-plus"></i></a>
          </div>
        </li>
        {{#each traits as |trait key|}}
        <li class="item flexrow list-item list-item-shadow" data-item-id="{{trait._id}}">
          <a class="item-edit item-name-img" title="Edit Item"><img class="sheet-competence-img"
              src="{{trait.img}}" /></a>
          <span class="item-name-label-long2">{{trait.name}}</span>
          <span class="item-field-label-short"><label>{{trait.system.level}}</label></span>

          <div class="item-filler">&nbsp;</div>
          <div class="item-controls item-controls-fixed">
            <a class="item-control item-delete" title="Delete trait"><i class="fas fa-trash"></i></a>
          </div>
        </li>
        {{/each}}
      </ul>

    </div>

    <div class="tab combat" data-group="primary" data-tab="combat">

      <div class="flexrow">
        {{> systems/fvtt-ecryme/templates/actors/partial-impacts.hbs impacts=system.impacts.physical
        impacttype="physical" impactMalus=impactsMalus.physical}}
        {{> systems/fvtt-ecryme/templates/actors/partial-impacts.hbs impacts=system.impacts.mental
        impacttype="mental" impactMalus=impactsMalus.mental}}
        {{> systems/fvtt-ecryme/templates/actors/partial-impacts.hbs impacts=system.impacts.social
        impacttype="social" impactMalus=impactsMalus.social}}
      </div>

      <ul class="item-list alternate-list">
        <li class="item flexrow list-item items-title-bg">
          <span class="item-name-label-header-long2">
            <h3><label class="item-name-label-header-long2">{{localize "ECRY.ui.weapons"}}</label></h3>
          </span>
          <span class="item-field-label-medium">
            <label class="item-field-label-medium">{{localize "ECRY.ui.type"}}</label>
          </span>
          <span class="item-field-label-medium">
            <label class="item-field-label-medium">{{localize "ECRY.ui.effect"}}</label>
          </span>
        </li>
        {{#each weapons as |weapon key|}}
        <li class="item flexrow list-item list-item-shadow" data-item-id="{{weapon._id}}">
          <a class="item-edit item-name-img" title="Edit Item"><img class="sheet-competence-img"
              src="{{weapon.img}}" /></a>
          <span class="item-name-label-long2">
            <a class="roll-weapon-confront" data-category-key="{{categkey}}" data-skill-key="{{skillkey}}">
              <i class="fa-regular fa-swords"></i>
              {{weapon.name}}
            </a>
          </span>
          <span class="item-field-label-medium">{{localize (concat "ECRY.ui." weapon.system.weapontype)}}</span>
          <span class="item-field-label-medium">{{weapon.system.effect}}</span>

          <div class="item-filler">&nbsp;</div>
          <div class="item-controls item-controls-fixed">
            <a class="item-control item-delete" title="Delete weapon"><i class="fas fa-trash"></i></a>
          </div>
        </li>
        {{/each}}
      </ul>

      <ul class="item-list alternate-list">
        <li class="item flexrow list-item items-title-bg">
          <span class="item-name-label-header-long2">
            <h3><label class="item-name-label-header-long2">{{localize "ECRY.ui.maneuvers"}}</label></h3>
          </span>
        </li>
        {{#each maneuvers as |maneuver key|}}
        <li class="item flexrow list-item list-item-shadow" data-item-id="{{maneuver._id}}">
          <a class="item-edit item-name-img" title="Edit Item"><img class="sheet-competence-img"
              src="{{maneuver.img}}" /></a>
          <span class="item-name-label-long2">
            {{maneuver.name}}
          </span>

          <div class="item-filler">&nbsp;</div>
          <div class="item-controls item-controls-fixed">
            <a class="item-control item-delete" title="Delete maneuver"><i class="fas fa-trash"></i></a>
          </div>
        </li>
        {{/each}}
      </ul>

    </div>


    {{!-- Equipement Tab --}}
    <div class="tab equipements" data-group="primary" data-tab="equipements">

      <span class="item-name-label-header items-title-bg">
        <h3><label class="items-title-text">{{localize "ECRY.ui.equipmentfree"}}</label></h3>
      </span>
      <div class="form-group small-editor">
        {{editor equipementlibre target="system.equipmentfree" button=true owner=owner editable=editable}}
      </div>

      <ul class="item-list alternate-list">
        <li class="item flexrow list-item items-title-bg">
          <span class="item-name-label-header">
            <h3><label class="items-title-text">{{localize "ECRY.ui.equipment"}}s</label></h3>
          </span>
          <span class="item-field-label-medium">
            <label class="item-field-label-medium">{{localize "ECRY.ui.weight"}}</label>
          </span>
          <div class="item-filler">&nbsp;</div>
          <div class="item-controls item-controls-fixed">
            <a class="item-control item-add" data-type="equipment" title="Create Item"><i class="fas fa-plus"></i></a>
          </div>

        </li>
        {{#each equipments as |equip key|}}
        <li class="item list-item flexrow list-item-shadow" data-item-id="{{equip._id}}">
          <a class="item-edit item-name-img" title="Edit Item"><img class="sheet-competence-img"
              src="{{equip.img}}" /></a>
          <span class="item-name-label">{{equip.name}}</span>
          <span class="item-field-label-medium">{{equip.system.weight}}</span>

          <div class="item-filler">&nbsp;</div>
          <div class="item-controls item-controls-fixed">
            <a class="item-control item-delete" title="Delete Item"><i class="fas fa-trash"></i></a>
          </div>
        </li>
        {{/each}}
      </ul>

      <hr>

    </div>

    {{!-- Biography Tab --}}
    <div class="tab biodata" data-group="primary" data-tab="biodata">

      <div class="grid grid-2col">
        <div>
          <ul class="item-list alternate-list">
            <li class="item flexrow">
              <label class="item-name-label-medium">{{localize "ECRY.ui.bornplace"}}</label>
              <input type="text" class="" name="system.biodata.lieunaissance" value="{{system.biodata.lieunaissance}}"
                data-dtype="String" />
            </li>
            <li class="item flexrow">
              <label class="item-name-label-medium">Age</label>
              <input type="text" class="" name="system.biodata.age" value="{{system.biodata.age}}"
                data-dtype="String" />
            </li>
            <li class="item flexrow">
              <label class="item-name-label-medium">Profession</label>
              <input type="text" class="" name="system.biodata.profession" value="{{system.biodata.profession}}"
                data-dtype="String" />
            </li>
          </ul>
        </div>
        <div>
          <ul>
            <li class="item flexrow">
              <label class="item-name-label-medium">{{localize "ECRY.ui.residence"}}</label>
              <input type="text" class="" name="system.biodata.residence" value="{{system.biodata.residence}}"
                data-dtype="String" />
            </li>
            <li class="item flexrow">
              <label class="item-name-label-medium">{{localize "ECRY.ui.origin"}}</label>
              <input type="text" class="" name="system.biodata.nationalite" value="{{system.biodata.nationalite}}"
                data-dtype="String" />
            </li>
            <li class="item flexrow">
              <label class="item-name-label-medium">{{localize "ECRY.ui.childhood"}}</label>
              <input type="text" class="" name="system.biodata.enfance" value="{{system.biodata.enfance}}"
                data-dtype="String" />
            </li>
          </ul>
        </div>
      </div>

      <hr>
      <span class="item-name-label-header items-title-bg">
        <h3><label class="items-title-text">Background</label></h3>
      </span>
      <div class="form-group editor">
        {{editor description target="system.biodata.description" button=true owner=owner
        editable=editable}}
      </div>
      <hr>
      <span class="item-name-label-header items-title-bg">
        <h3><label class="items-title-text">Notes</label></h3>
      </span>
      <div class="form-group editor">
        {{editor notes target="system.biodata.notes" button=true owner=owner editable=editable}}
      </div>
      <hr>
      <div class="form-group">
        <button type="button" class="reset-transcendence" title="{{localize "ECRY.ui.resetTranscendence"}}">
          <i class="fas fa-undo-alt"></i> {{localize "ECRY.ui.resetTranscendence"}}
        </button>
      </div>

    </div>


  </section>
</form>