script(id='partials/options.settings.html', type="text/ng-template")
  ul.nav.nav-tabs
    li(ng-class="{ active: $state.includes('options.settings.settings') }")
      a(ui-sref='options.settings.settings')
        =env.t('settings')
    li(ng-class="{ active: $state.includes('options.settings.api') }")
      a(ui-sref='options.settings.api')
        =env.t('API')
    li(ng-class="{ active: $state.includes('options.settings.export') }")
      a(ui-sref='options.settings.export')
        =env.t('dataExport')
    li(ng-class="{ active: $state.includes('options.settings.subscription') }")
      a(ui-sref='options.settings.subscription')=env.t('subscription')

  .tab-content
    .tab-pane.active
      div(ui-view)

script(type='text/ng-template', id='partials/options.settings.settings.html')
  .containter-fluid
    .row
      .personal-options.col-md-6
        h2=env.t('settings')
        h4=env.t('customDayStart')
        .form-group
          input.form-control(type='number', min='0', max='24', ng-model='user.preferences.dayStart', ng-change='saveDayStart()')
          span.input-suffix= ':00 (' + env.t('24HrClock') + ')'
        div
          small
            div=env.t('clockInfo')
            .alert.alert-danger.alert-sm
              =env.t('subWarning1')
              |&nbsp;
              a(href='https://github.com/HabitRPG/habitrpg/issues/1057' target='_blank')=env.t('subWarning2')
              |&nbsp;
              =env.t('subWarning3')
        hr
        h4=env.t('language')
        select(ng-model='language.code', ng-options='lang.code as lang.name for lang in avalaibleLanguages', ng-change='changeLanguage()')
        hr
        h4=env.t('misc')
        .checkbox
          label
            input(type='checkbox', ng-click='set({"preferences.hideHeader":user.preferences.hideHeader?false:true})', ng-checked='user.preferences.hideHeader!==true')
            span.hint(popover-trigger='mouseenter', popover-placement='right', popover=env.t('showHeaderPop'))=env.t('showHeader')
        .checkbox
          label
            input(type='checkbox', ng-click='toggleStickyHeader()', ng-checked='user.preferences.stickyHeader!==false')
            span.hint(popover-trigger='mouseenter', popover-placement='right', popover=env.t('stickyHeaderPop'))=env.t('stickyHeader')
        .checkbox
          label
            input(type='checkbox', ng-model='user.preferences.newTaskEdit', ng-change='set({"preferences.newTaskEdit": user.preferences.newTaskEdit?true: false})')
            span.hint(popover-trigger='mouseenter', popover-placement='right', popover=env.t('newTaskEditPop'))=env.t('newTaskEdit')
        .checkbox
          label
            input(type='checkbox', ng-model='user.preferences.tagsCollapsed', ng-change='set({"preferences.tagsCollapsed": user.preferences.tagsCollapsed?true: false})')
            span.hint(popover-trigger='mouseenter', popover-placement='right', popover=env.t('startCollapsedPop'))=env.t('startCollapsed')
        .checkbox
          label
            input(type='checkbox', ng-model='user.preferences.advancedCollapsed', ng-change='set({"preferences.advancedCollapsed": user.preferences.advancedCollapsed?true: false})')
            span.hint(popover-trigger='mouseenter', popover-placement='right', popover=env.t('startAdvCollapsedPop'))=env.t('startAdvCollapsed')
        button.btn.btn-default(ng-click='showTour()', popover-placement='right', popover-trigger='mouseenter', popover=env.t('restartTour'))= env.t('showTour')
        button.btn.btn-default(ng-click='showBailey()', popover-trigger='mouseenter', popover-placement='right', popover=env.t('showBaileyPop'))= env.t('showBailey')
        button.btn.btn-default(ng-click='openRestoreModal()', popover-trigger='mouseenter', popover-placement='right', popover=env.t('fixValPop'))= env.t('fixVal')
        button.btn.btn-default(ng-if='user.preferences.disableClasses==true', ng-click='user.ops.changeClass({})', popover-trigger='mouseenter', popover-placement='right', popover=env.t('enableClassPop'))= env.t('enableClass')
        button.btn.btn-default(ng-if='!user.preferences.disableClasses && user.flags.classSelected', ng-click='showClassesTour()', popover-trigger='mouseenter', popover-placement='right', popover=env.t('classTourPop'))= env.t('showClass')

        //- Why is ng-if='user.auth.local' validating for users *without* user.auth.local (facebook users)? adding .username here for extra
        div(ng-if='user.auth.local.username')
          hr
          h4=env.t('changePass')
          form(ng-submit='changePassword(changePass)', ng-show='user.auth.local')
            .form-group
              input.form-control(type='password', placeholder=env.t('oldPass'), ng-model='changePass.oldPassword', required)
            .form-group
              input.form-control(type='password', placeholder=env.t('newPass'), ng-model='changePass.newPassword', required)
            .form-group
              input.form-control(type='password', placeholder=env.t('confirmPass'), ng-model='changePass.confirmNewPassword', required)
            input.btn.btn-default(type='submit', value=env.t('submit'))

        hr
        h4=env.t('dangerZone')
        a.btn.btn-danger(ng-click='openModal("reset", {controller:"SettingsCtrl"})', popover-trigger='mouseenter', popover-placement='right', popover=env.t('resetAccPop'))= env.t('resetAccount')
        a.btn.btn-danger(ng-click='openModal("delete", {controller:"SettingsCtrl"})', popover-trigger='mouseenter', popover=env.t('deleteAccPop'))= env.t('deleteAccount')

script(type='text/ng-template', id='partials/options.settings.api.html')
  .containter-fluid
    .row
      .col-md-6
        h2=env.t('API')
        small=env.t('APIText')
        h6=env.t('userId')
        pre.prettyprint {{user.id}}
        h6=env.t('APIToken')
        pre.prettyprint {{user.apiToken}}
        h6=env.t('qrCode')
        img(src='https://chart.googleapis.com/chart?cht=qr&chs=200x200&chl=%7B%22address%22%3A%22https%3A%2F%2Fhabitrpg.com%22%2C%22user%22%3A%22{{user.id}}%22%2C%22key%22%3A%22{{user.apiToken}}%22%7D&choe=UTF-8&chld=L', alt='qrcode')

script(id='partials/options.settings.export.html', type="text/ng-template")
  .containter-fluid
    .row
      .col-md-6
        h2=env.t('dataExport')
        small=env.t('saveData')
        h4=env.t('habitHistory')
        =env.t('exportHistory')
        a(href="/export/history.csv")= ' ' + env.t('csv')
        h4=env.t('userData')
        =env.t('exportUserData')
        a(href="/export/userdata.xml")= ' ' + env.t('xml') + ' '
        a(href="/export/userdata.json")= env.t('json')

script(id='partials/options.settings.subscription.perks.html',type='text/ng-template')
  table.table.table-striped
    tr
      td
        span.hint(popover=env.t('disableAdsText'),popover-trigger='mouseenter',popover-placement='right')=env.t('disableAds')
    tr
      td
        span.hint(popover=env.t('buyGemsGoldText', {gemCost: "{{Shared.planGemLimits.convRate}}", gemLimit: "{{Shared.planGemLimits.convCap}}"}),popover-trigger='mouseenter',popover-placement='right')=env.t('buyGemsGold')
    tr
      td
        span.hint(popover=env.t('retainHistoryText'),popover-trigger='mouseenter',popover-placement='right')=env.t('retainHistory')
    tr
      td
        span.hint(popover=env.t('doubleDropsText'),popover-trigger='mouseenter',popover-placement='right')=env.t('doubleDrops')
    tr
      td
        span.hint(popover=env.t('mysteryItemText'),popover-trigger='mouseenter',popover-placement='right')=env.t('mysteryItem')
    tr
      td
        span.hint(popover=env.t('supportDevsText'),popover-trigger='mouseenter',popover-placement='right')=env.t('supportDevs')
    tr
      td.alert.alert-info $5&nbsp;
        =env.t('monthUSD')

script(id='partials/feature-matrix-check.html',type='text/ng-template')
  span.task-checker.action-yesno
    input.focusable(type='checkbox', checked)
    label

script(id='partials/options.settings.subscription.html',type='text/ng-template')

  .well
    h2=env.t('individualSub')
    div(ng-if='!user.purchased.plan.customerId')
      div(ng-include="'partials/options.settings.subscription.perks.html'")
      .btn.btn-primary(ng-click='showStripe(true)')=env.t('subscribe')
      //-small.muted PayPal coming soon.

    div(ng-if='user.purchased.plan.customerId')
      .well
        p.lead
          =env.t('subscribed')
          | &nbsp;
          span.glyphicon.glyphicon-ok
        div(ng-include="'partials/options.settings.subscription.perks.html'")
      .btn.btn-sm.btn-danger(ng-click='cancelSubscription()')=env.t('cancelSub')
