/**
@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{IronResizableBehavior as i}from"../iron-resizable-behavior/iron-resizable-behavior.js";import{IronSelectableBehavior as t}from"../iron-selector/iron-selectable.js";import{Polymer as e}from"../polymer/lib/legacy/polymer-fn.js";import{dom as n}from"../polymer/lib/legacy/polymer.dom.js";import{html as o}from"../polymer/lib/utils/html-tag.js";import{NeonAnimationRunnerBehavior as s}from"./neon-animation-runner-behavior.js";e({_template:o`
    <style>
      :host {
        display: block;
        position: relative;
      }

      :host > ::slotted(*) {
        position: absolute;
        top: 0;
        left: 0;
        bottom: 0;
        right: 0;
      }

      :host > ::slotted(:not(.iron-selected):not(.neon-animating))
       {
        display: none !important;
      }

      :host > ::slotted(.neon-animating) {
        pointer-events: none;
      }
    </style>

    <slot id="content"></slot>
  `,is:"neon-animated-pages",behaviors:[i,t,s],properties:{activateEvent:{type:String,value:""},animateInitialSelection:{type:Boolean,value:!1}},listeners:{"iron-select":"_onIronSelect","neon-animation-finish":"_onNeonAnimationFinish"},_onIronSelect:function(i){var t=i.detail.item;if(!(this.items.indexOf(t)<0)){var e=this._valueToItem(this._prevSelected)||!1;this._prevSelected=this.selected,e||this.animateInitialSelection?(this.animationConfig=[],this.entryAnimation?this.animationConfig.push({name:this.entryAnimation,node:t}):t.getAnimationConfig&&this.animationConfig.push({animatable:t,type:"entry"}),e&&(e.classList.contains("neon-animating")&&(this._squelchNextFinishEvent=!0,this.cancelAnimation(),this._completeSelectedChanged(),this._squelchNextFinishEvent=!1),this.exitAnimation?this.animationConfig.push({name:this.exitAnimation,node:e}):e.getAnimationConfig&&this.animationConfig.push({animatable:e,type:"exit"}),e.classList.add("neon-animating")),t.classList.add("neon-animating"),this.animationConfig.length>=1?this.isAttached?this.playAnimation(void 0,{fromPage:e,toPage:t}):this.async((function(){this.playAnimation(void 0,{fromPage:null,toPage:t})})):this._completeSelectedChanged(e,t)):this._completeSelectedChanged()}},_completeSelectedChanged:function(i,t){if(t&&t.classList.remove("neon-animating"),i&&i.classList.remove("neon-animating"),!t||!i)for(var e,o=n(this.$.content).getDistributedNodes(),s=0;e=o[s];s++)e.classList&&e.classList.remove("neon-animating");this.async(this._notifyPageResize)},_onNeonAnimationFinish:function(i){this._squelchNextFinishEvent?this._squelchNextFinishEvent=!1:this._completeSelectedChanged(i.detail.fromPage,i.detail.toPage)},_notifyPageResize:function(){var i=this.selectedItem||this._valueToItem(this.selected);this.resizerShouldNotify=function(t){return t==i},this.notifyResize()}});