<form class="skill-roll-dialog">
  <header class="roll-dialog-header">
    {{#if img}}
    <img class="actor-icon" src="{{img}}" data-edit="img" title="{{name}}" />
    {{/if}}
    <h1 class="dialog-roll-title roll-dialog-header">{{title}}</h1>
  </header>

  <div class="flexcol">

    <div class="flexrow">
      {{#if (eq attrKey "tochoose")}}
        <span class="roll-dialog-label">Attribut</span>
        <select class="status-small-label color-class-common" id ="attrKey" type="text" name="attrKey" value="attrKey" data-dtype="string" >
          {{#select attrKey}}
          {{#each attributs as |attrLabel attrKey|}}
            <option value="{{attrKey}}">{{attrLabel}}</option>
          {{/each}}
          {{/select}}
        </select>      
      {{else}}
        <span class="roll-dialog-label">{{attr.label}}</span>
        <span class="small-label roll-dialog-label">{{attr.value}}</span>
      {{/if}}
    </div>

    {{#if nbAdversites}}
    <div class="flexrow">
      <span class="roll-dialog-label">Malus d'adversités </span>
      <span class="small-label roll-dialog-label">- {{nbAdversites}}</span>
    </div>
    {{/if}}

    {{#if competence}}
      <div class="flexrow">
        <span class="roll-dialog-label">{{competence.name}}</span>
        <span class="small-label roll-dialog-label">{{competence.system.niveau}}</span>
      </div>
      {{#if maitrises}}
      <div class="flexrow">
        <span class="roll-dialog-label">Utiliser une maîtrise</span>
        <select class="status-small-label color-class-common" id ="select-maitrise" type="text" name="select-maitrise" value="maitriseId" data-dtype="string" >
          {{#select maitriseId}}
            <option value="none">Aucune</option>
            {{#each maitrises as |maitrise mKey|}}
              <option value="{{maitrise.id}}">{{maitrise.name}}</option>
            {{/each}}
          {{/select}}
        </select>      
      </div>
      {{/if}}
    {{else}}
      <div class="flexrow">
        <span class="roll-dialog-label">Second Attribut</span>
        <select class="status-small-label color-class-common" id ="attrKey2" type="text" name="attrKey2" value="attrKey2" data-dtype="string" >
          {{#select attrKey2}}
          <option value="none">Aucun</option>
          {{#each attributs as |attrLabel attrKey|}}
            <option value="{{attrKey}}">{{attrLabel}}</option>
          {{/each}}
          {{/select}}
        </select>      
      </div>
    {{/if}}

    {{#if (count talents)}}
    <div class="flexrow">
      <span class="roll-dialog-label">Talents </span>
      <select class="flex1" name="competence-talents" id="competence-talents" data-type="String" multiple>
        {{#each talents as |talent key|}}
          <option value="{{talent._id}}">{{talent.name}}</option>
        {{/each}}
      </select>
    </div>
    {{/if}}

    {{#if arme}}
      {{#if arme.system.isMelee}}
        {{#if bonusArmeNaturelle}}
          <div class="flexrow">
            <span class="roll-dialog-label">Arme naturelle/fortune en défense</span>
            <span class="small-label roll-dialog-label">{{bonusArmeNaturelle}}</span>
          </div>
        {{/if}}
        <div class="flexrow">
          <span class="roll-dialog-label">En surplomb ou défenseur au sol (+3)?</span>
          <input type="checkbox" id="defenseur-au-sol" {{checked defenseurAuSol}} />
        </div>
        <div class="flexrow">
          <span class="roll-dialog-label">Défenseur aveuglé (+10)?</span>
          <input type="checkbox" id="defenseur-aveugle" {{checked defenseurAveugle}} />
        </div>
        <div class="flexrow">
          <span class="roll-dialog-label">Défenseur de dos (+5)?</span>
          <input type="checkbox" id="defenseur-de-dos" {{checked defenseurDeDos}} />
        </div>
        <div class="flexrow">
          <span class="roll-dialog-label">Défenseur dans espace restreint (+3)?</span>
          <input type="checkbox" id="defenseur-restreint" {{checked defenseurRestreint}} />
        </div>
        <div class="flexrow">
          <span class="roll-dialog-label">Défenseur immobilisé (+5)?</span>
          <input type="checkbox" id="defenseur-immobilise" {{checked defenseurImmobilise}} />
        </div>
        <div class="flexrow">
          <span class="roll-dialog-label">Charge ?</span>
          <input type="checkbox" id="attaque-charge" {{checked attaqueCharge}} />
        </div>
        <div class="flexrow">
          <span class="roll-dialog-label">Désarmer (SD+10)?</span>
          <input type="checkbox" id="attaque-desarme" {{checked attaqueDesarme}} />
        </div>
      {{else}}
      <div class="flexrow">
        <span class="roll-dialog-label">Tireur en déplacement ?</span>
        <select class="item-field-label-long" type="text" id="tireur-deplacement" data-dtype="string">
          {{#select tireurDeplacement}}
            <option value="immobile">Immobile (SD+0)</option>
            <option value="lent">Lent (SD+3)</option>
            <option value="rapide">Rapide (SD+5)</option>
          {{/select}}
        </select>
      </div>
      <div class="flexrow">
        <span class="roll-dialog-label">Couvert de la cible ?</span>
        <select class="item-field-label-long" type="text" id="cible-couvert" data-dtype="string">
          {{#select cibleCouvert}}
            <option value="aucun">Aucun</option>
            <option value="leger">Léger (SD+5)</option>
            <option value="complet">Quasi complet (SD+10)</option>
          {{/select}}
        </select>
      </div>
      <div class="flexrow">
        <span class="roll-dialog-label">Cible se déplace vite (SD+3)?</span>
        <input type="checkbox" id="tireur-cible-deplace" {{checked cibleDeplace}} />
      </div>
      <div class="flexrow">
        <span class="roll-dialog-label">Cible corps à corps (SD+3)?</span>
        <input type="checkbox" id="tireur-cible-cac" {{checked cibleCaC}} />
      </div>      
      <div class="flexrow">
        <span class="roll-dialog-label">Taille de la cible ?</span>
        <select class="item-field-label-long" type="text" id="taille-cible" data-dtype="string">
          {{#select tailleCible}}
            <option value="normal">Normal (SD+0)</option>
            <option value="main">Main (SD+10)</option>
            <option value="enfant">Enfant (SD+3)</option>
            <option value="maison">Maison (SD-10)</option>
          {{/select}}
        </select>
      </div>
      {{/if}}
    {{/if}}

    <div class="flexrow">
      <span class="roll-dialog-label">Bonus/Malus </span>
      <select class="roll-dialog-label" id="bonus-malus-context" type="text" value="{{bonusMalusContext}}"
        data-dtype="Number">
        {{#select bonusMalusContext}}
        <option value="-4">-4</option>
        <option value="-3">-3</option>
        <option value="-2">-2</option>
        <option value="-1">-1</option>
        <option value="0">0</option>
        <option value="1">+1</option>
        <option value="2">+2</option>
        <option value="3">+3</option>
        <option value="4">+4</option>
        {{/select}}
      </select>
    </div>

    {{#if (or armeDefense arme.system.isDistance)}}
    
      {{#if arme.system.isDistance}}
      <div class="flexrow">
        <span class="roll-dialog-label">SD de distance</span>
        <select class="item-field-label-long" type="text" id="distance-tir" data-dtype="string">
          {{#select distanceTir}}
            <option value="porteecourte">Courte ({{protectionDefenseur}}+5)</option>
            <option value="porteemoyenne">Moyenne ({{protectionDefenseur}}+9)</option>
            <option value="porteelongue">Longue ({{protectionDefenseur}}+14)</option>
          {{/select}}
        </select>
      </div>
      {{else}}
        <div class="flexrow">
          <span class="roll-dialog-label">Défense adversaire : </span>
          <span class="roll-dialog-label"><strong>{{difficulte}}</strong> </span>
        </div>
      {{/if}}
    
    {{else}}
      
      {{#if isInit}}

      {{else}}
        <div class="flexrow">
          <span class="roll-dialog-label">Difficulté : </span>
          <select class="roll-dialog-label" id="difficulte" type="text" name="difficulte" value="{{difficulte}}"
            data-dtype="Number">
            {{#select difficulte}}
            <option value="0">Aucune/Inconnue</option>
            <option value="5">Facile (5)</option>
            <option value="10">Moyenne (10)</option>
            <option value="15">Ardue (15)</option>
            <option value="20">Hasardeuse (20)</option>
            <option value="25">Insensée (25)</option>
            <option value="30">Pure Folie (30)</option>
            {{/select}}
          </select>
        </div>
      {{/if}}
    {{/if}}
    
  </div>

</form>