text: /**
  @license
  Copyright (c) 2015 The Polymer Project Authors. All rights reserved.
  This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt
  The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt
  The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt
  Code distributed by Google as part of the polymer project is also
  subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt
  */
  import"../polymer/polymer-legacy.js";import"../iron-flex-layout/iron-flex-layout.js";import"../iron-icon/iron-icon.js";import"../paper-icon-button/paper-icon-button.js";import"../paper-styles/color.js";import"./paper-tabs-icons.js";import"./paper-tab.js";import{IronMenuBehaviorImpl as t}from"../iron-menu-behavior/iron-menu-behavior.js";import{IronMenubarBehavior as e}from"../iron-menu-behavior/iron-menubar-behavior.js";import{IronResizableBehavior as i}from"../iron-resizable-behavior/iron-resizable-behavior.js";import{Polymer as n}from"../polymer/lib/legacy/polymer-fn.js";import{dom as o}from"../polymer/lib/legacy/polymer.dom.js";import{html as a}from"../polymer/lib/utils/html-tag.js";n({_template:a`
      <style>
        :host {
          @apply --layout;
          @apply --layout-center;
  
          height: 48px;
          font-size: 14px;
          font-weight: 500;
          overflow: hidden;
          -moz-user-select: none;
          -ms-user-select: none;
          -webkit-user-select: none;
          user-select: none;
  
          /* NOTE: Both values are needed, since some phones require the value to be \`transparent\`. */
          -webkit-tap-highlight-color: rgba(0, 0, 0, 0);
          -webkit-tap-highlight-color: transparent;
  
          @apply --paper-tabs;
        }
  
        :host(:dir(rtl)) {
          @apply --layout-horizontal-reverse;
        }
  
        #tabsContainer {
          position: relative;
          height: 100%;
          white-space: nowrap;
          overflow: hidden;
          @apply --layout-flex-auto;
          @apply --paper-tabs-container;
        }
  
        #tabsContent {
          height: 100%;
          -moz-flex-basis: auto;
          -ms-flex-basis: auto;
          flex-basis: auto;
          @apply --paper-tabs-content;
        }
  
        #tabsContent.scrollable {
          position: absolute;
          white-space: nowrap;
        }
  
        #tabsContent:not(.scrollable),
        #tabsContent.scrollable.fit-container {
          @apply --layout-horizontal;
        }
  
        #tabsContent.scrollable.fit-container {
          min-width: 100%;
        }
  
        #tabsContent.scrollable.fit-container > ::slotted(*) {
          /* IE - prevent tabs from compressing when they should scroll. */
          -ms-flex: 1 0 auto;
          -webkit-flex: 1 0 auto;
          flex: 1 0 auto;
        }
  
        .hidden {
          display: none;
        }
  
        .not-visible {
          opacity: 0;
          cursor: default;
        }
  
        paper-icon-button {
          width: 48px;
          height: 48px;
          padding: 12px;
          margin: 0 4px;
        }
  
        #selectionBar {
          position: absolute;
          height: 0;
          bottom: 0;
          left: 0;
          right: 0;
          border-bottom: 2px solid var(--paper-tabs-selection-bar-color, var(--paper-yellow-a100));
            -webkit-transform: scale(0);
          transform: scale(0);
            -webkit-transform-origin: left center;
          transform-origin: left center;
            transition: -webkit-transform;
          transition: transform;
  
          @apply --paper-tabs-selection-bar;
        }
  
        #selectionBar.align-bottom {
          top: 0;
          bottom: auto;
        }
  
        #selectionBar.expand {
          transition-duration: 0.15s;
          transition-timing-function: cubic-bezier(0.4, 0.0, 1, 1);
        }
  
        #selectionBar.contract {
          transition-duration: 0.18s;
          transition-timing-function: cubic-bezier(0.0, 0.0, 0.2, 1);
        }
  
        #tabsContent > ::slotted(:not(#selectionBar)) {
          height: 100%;
        }
      </style>
  
      <paper-icon-button icon="paper-tabs:chevron-left" class$="[[_computeScrollButtonClass(_leftHidden, scrollable, hideScrollButtons)]]" on-up="_onScrollButtonUp" on-down="_onLeftScrollButtonDown" tabindex="-1"></paper-icon-button>
  
      <div id="tabsContainer" on-track="_scroll" on-down="_down">
        <div id="tabsContent" class$="[[_computeTabsContentClass(scrollable, fitContainer)]]">
          <div id="selectionBar" class$="[[_computeSelectionBarClass(noBar, alignBottom)]]" on-transitionend="_onBarTransitionEnd"></div>
          <slot></slot>
        </div>
      </div>
  
      <paper-icon-button icon="paper-tabs:chevron-right" class$="[[_computeScrollButtonClass(_rightHidden, scrollable, hideScrollButtons)]]" on-up="_onScrollButtonUp" on-down="_onRightScrollButtonDown" tabindex="-1"></paper-icon-button>
  `,is:"paper-tabs",behaviors:[i,e],properties:{noink:{type:Boolean,value:!1,observer:"_noinkChanged"},noBar:{type:Boolean,value:!1},noSlide:{type:Boolean,value:!1},scrollable:{type:Boolean,value:!1},fitContainer:{type:Boolean,value:!1},disableDrag:{type:Boolean,value:!1},hideScrollButtons:{type:Boolean,value:!1},alignBottom:{type:Boolean,value:!1},selectable:{type:String,value:"paper-tab"},autoselect:{type:Boolean,value:!1},autoselectDelay:{type:Number,value:0},_step:{type:Number,value:10},_holdDelay:{type:Number,value:1},_leftHidden:{type:Boolean,value:!1},_rightHidden:{type:Boolean,value:!1},_previousTab:{type:Object}},hostAttributes:{role:"tablist"},listeners:{"iron-resize":"_onTabSizingChanged","iron-items-changed":"_onTabSizingChanged","iron-select":"_onIronSelect","iron-deselect":"_onIronDeselect"},keyBindings:{"left:keyup right:keyup":"_onArrowKeyup"},created:function(){this._holdJob=null,this._pendingActivationItem=void 0,this._pendingActivationTimeout=void 0,this._bindDelayedActivationHandler=this._delayedActivationHandler.bind(this),this.addEventListener("blur",this._onBlurCapture.bind(this),!0)},ready:function(){this.setScrollDirection("y",this.$.tabsContainer)},detached:function(){this._cancelPendingActivation()},_noinkChanged:function(t){o(this).querySelectorAll("paper-tab").forEach(t?this._setNoinkAttribute:this._removeNoinkAttribute)},_setNoinkAttribute:function(t){t.setAttribute("noink","")},_removeNoinkAttribute:function(t){t.removeAttribute("noink")},_computeScrollButtonClass:function(t,e,i){return!e||i?"hidden":t?"not-visible":""},_computeTabsContentClass:function(t,e){return t?"scrollable"+(e?" fit-container":""):" fit-container"},_computeSelectionBarClass:function(t,e){return t?"hidden":e?"align-bottom":""},_onTabSizingChanged:function(){this.debounce("_onTabSizingChanged",(function(){this._scroll(),this._tabChanged(this.selectedItem)}),10)},_onIronSelect:function(t){this._tabChanged(t.detail.item,this._previousTab),this._previousTab=t.detail.item,this.cancelDebouncer("tab-changed")},_onIronDeselect:function(t){this.debounce("tab-changed",(function(){this._tabChanged(null,this._previousTab),this._previousTab=null}),1)},_activateHandler:function(){this._cancelPendingActivation(),t._activateHandler.apply(this,arguments)},_scheduleActivation:function(t,e){this._pendingActivationItem=t,this._pendingActivationTimeout=this.async(this._bindDelayedActivationHandler,e)},_delayedActivationHandler:function(){var t=this._pendingActivationItem;this._pendingActivationItem=void 0,this._pendingActivationTimeout=void 0,t.fire(this.activateEvent,null,{bubbles:!0,cancelable:!0})},_cancelPendingActivation:function(){void 0!==this._pendingActivationTimeout&&(this.cancelAsync(this._pendingActivationTimeout),this._pendingActivationItem=void 0,this._pendingActivationTimeout=void 0)},_onArrowKeyup:function(t){this.autoselect&&this._scheduleActivation(this.focusedItem,this.autoselectDelay)},_onBlurCapture:function(t){t.target===this._pendingActivationItem&&this._cancelPendingActivation()},get _tabContainerScrollSize(){return Math.max(0,this.$.tabsContainer.scrollWidth-this.$.tabsContainer.offsetWidth)},_scroll:function(t,e){if(this.scrollable){var i=e&&-e.ddx||0;this._affectScroll(i)}},_down:function(t){this.async((function(){this._defaultFocusAsync&&(this.cancelAsync(this._defaultFocusAsync),this._defaultFocusAsync=null)}),1)},_affectScroll:function(t){this.$.tabsContainer.scrollLeft+=t;var e=this.$.tabsContainer.scrollLeft;this._leftHidden=0===e,this._rightHidden=e===this._tabContainerScrollSize},_onLeftScrollButtonDown:function(){this._scrollToLeft(),this._holdJob=setInterval(this._scrollToLeft.bind(this),this._holdDelay)},_onRightScrollButtonDown:function(){this._scrollToRight(),this._holdJob=setInterval(this._scrollToRight.bind(this),this._holdDelay)},_onScrollButtonUp:function(){clearInterval(this._holdJob),this._holdJob=null},_scrollToLeft:function(){this._affectScroll(-this._step)},_scrollToRight:function(){this._affectScroll(this._step)},_tabChanged:function(t,e){if(!t)return this.$.selectionBar.classList.remove("expand"),this.$.selectionBar.classList.remove("contract"),void this._positionBar(0,0);var i=this.$.tabsContent.getBoundingClientRect(),n=i.width,o=t.getBoundingClientRect(),a=o.left-i.left;if(this._pos={width:this._calcPercent(o.width,n),left:this._calcPercent(a,n)},this.noSlide||null==e)return this.$.selectionBar.classList.remove("expand"),this.$.selectionBar.classList.remove("contract"),void this._positionBar(this._pos.width,this._pos.left);var s=e.getBoundingClientRect(),l=this.items.indexOf(e),r=this.items.indexOf(t);this.$.selectionBar.classList.add("expand");var c=l<r;this._isRTL&&(c=!c),c?this._positionBar(this._calcPercent(o.left+o.width-s.left,n)-5,this._left):this._positionBar(this._calcPercent(s.left+s.width-o.left,n)-5,this._calcPercent(a,n)+5),this.scrollable&&this._scrollToSelectedIfNeeded(o.width,a)},_scrollToSelectedIfNeeded:function(t,e){var i=e-this.$.tabsContainer.scrollLeft;(i<0||(i+=t-this.$.tabsContainer.offsetWidth)>0)&&(this.$.tabsContainer.scrollLeft+=i)},_calcPercent:function(t,e){return 100*t/e},_positionBar:function(t,e){t=t||0,e=e||0,this._width=t,this._left=e,this.transform("translateX("+e+"%) scaleX("+t/100+")",this.$.selectionBar)},_onBarTransitionEnd:function(t){var e=this.$.selectionBar.classList;e.contains("expand")?(e.remove("expand"),e.add("contract"),this._positionBar(this._pos.width,this._pos.left)):e.contains("contract")&&e.remove("contract")}});