text: define(["exports","../../../@polymer/polymer/polymer-element.js","./a11y-media-behaviors.js","./a11y-media-transcript-cue.js"],function(_exports,_polymerElement,_a11yMediaBehaviors,_a11yMediaTranscriptCue){Object.defineProperty(_exports,"__esModule",{value:!0}),_exports.A11yMediaTranscript=void 0;class A11yMediaTranscript extends _a11yMediaBehaviors.A11yMediaBehaviors{static get properties(){return{activeCues:{type:Array,value:null,reflectToAttribute:!0,notify:!0},disableInteractive:{name:"disableInteractive",type:Boolean,value:!1},hideTimestamps:{name:"hideTimestamps",type:Boolean,value:!1},lang:{type:String,value:"en",reflectToAttribute:!0},mediaId:{type:String,value:null},tabIndex:{type:Number,computed:"_getTabIndex(disableInteractive)"},role:{type:Number,computed:"_getRole(disableInteractive)"},selectedTranscript:{type:String,value:"0"},status:{type:String,computed:"_stampLoadingStatus(disableSeek)"},tracks:{type:Array,value:null}}}static get tag(){return"a11y-media-transcript"}static get template(){return _polymerElement.html`
        <style>
          :host {
            color: var(--a11y-media-transcript-cue-color);
            background-color: var(--a11y-media-transcript-cue-bg-color);
            border-left: 1px solid var(--a11y-media-transcript-bg-color);
          }
          :host([hidden]) {
            display: none !important;
          }
          :host .transcript-from-track {
            display: none;
            width: calc(100% - 30px);
            padding: 0 15px 15px;
            color: var(--a11y-media-transcript-cue-color);
            background-color: var(--a11y-media-transcript-cue-bg-color);
          }
          :host .transcript-from-track[active] {
            display: table;
          }
          :host .transcript-from-track[active][hideTimestamps] {
            display: block;
          }
          :host .sr-only:not(:focus) {
            position: absolute;
            left: -99999;
            top: 0;
            height: 0;
            width: 0;
            overflow: hidden;
          }
          @media print {
            :host {
              padding: 0 15px 5px;
              color: #000;
              background-color: #ffffff;
              border-top: 1px solid #aaa;
            }
          }
        </style>
        <a id="transcript-desc" class="sr-only" href="#bottom">
          [[_getLocal('transcript','skip')]]
        </a>
        <div
          aria-live="polite"
          id="loading"
          active$="[[_isLoading(selectedTranscript, tracks)]]"
          class="transcript-from-track"
        >
          [[status]]
        </div>
        <template id="tracks" is="dom-repeat" items="{{tracks}}" as="track">
          <div
            aria-live="polite"
            id="track"
            class="transcript-from-track"
            lang="{{track.language}}"
            active$="[[_isActive(selectedTranscript,index)]]"
          >
            <template is="dom-repeat" items="{{track.cues}}" as="cue">
              <a11y-media-transcript-cue
                accent-color$="[[accentColor]]"
                active-cues$="[[activeCues]]"
                controls$="[[mediaId]]"
                cue$="{{cue}}"
                disabled$="[[disableCue]]"
                disable-search$="[[disableSearch]]"
                hide-timestamps$="[[hideTimestamps]]"
                on-cue-seek="_handleCueSeek"
                order$="{{cue.order}}"
                role="button"
                search="[[search]]"
                tabindex="0"
              >
              </a11y-media-transcript-cue>
            </template>
          </div>
        </template>
        <template is="dom-repeat" items="{{tracks}}" as="track">
          <div
            id="download"
            class="downloadable-track"
            hidden
            active$="[[_isActive(selectedTranscript,index)]]"
          >
            <template is="dom-repeat" items="{{track.cues}}" as="cue">
              [[cue.start]] - [[cue.end]]: [[cue.text]]
            </template>
          </div>
        </template>
        <div id="bottom" class="sr-only"></div>
      `}connectedCallback(){super.connectedCallback(),this.dispatchEvent(new CustomEvent("transcript-ready",{detail:this}))}ready(){super.ready()}download(mediaTitle){let a=document.createElement("a"),title=null!==mediaTitle&&""!==mediaTitle?mediaTitle:this._getLocal("transcript","label"),filename=null!==mediaTitle&&""!==mediaTitle?mediaTitle.replace(/[^\w\d]/g,""):"Transcript",track=this.shadowRoot.querySelector("#download[active]"),data=null!==track?track.innerText:"";a.setAttribute("href","data:text/plain;charset=UTF-8,"+encodeURIComponent(title+"\n"+data)),a.setAttribute("download",filename+".txt"),a.style.display="none",document.body.appendChild(a),a.click(),document.body.removeChild(a)}print(mediaTitle){let track=this.shadowRoot.querySelector("#track[active]").cloneNode(!0),css=_polymerElement.html`
          <style>
            a11y-media-transcript-cue {
              display: table-row;
              background-color: #fff;
              color: #000;
            }
            a11y-media-transcript-cue[hide-timestamps],
            a11y-media-transcript-cue[hide-timestamps] #text {
              display: inline;
            }
            a11y-media-transcript-cue #text {
              display: table-cell;
              line-height: 200%;
            }
            a11y-media-transcript-cue #time {
              display: table-cell;
              font-size: 80%;
              padding: 0 16px;
              white-space: nowrap;
              font-family: monospace;
            }
            a11y-media-transcript-cue[hide-timestamps] #time {
              display: none;
            }
            a11y-media-transcript-cue [matched] {
              background-color: #fff;
              color: #eee;
              padding: 3px 4px;
              border-radius: 3px;
            }
          </style>
        `,h1=_polymerElement.html`
          <h1>Transcript</h1>
        `;if(void 0!==mediaTitle&&(h1.innerHTML=mediaTitle),null!==track&void 0!==track){let print=window.open("","","left=0,top=0,width=552,height=477,toolbar=0,scrollbars=0,status =0");print.document.body.appendChild(css),print.document.body.appendChild(h1),print.document.body.appendChild(track),print.document.close(),print.focus(),print.print(),print.close()}}setActiveCues(cues){let root=this,offset=null!==root.shadowRoot.querySelector("#track")&&void 0!==root.shadowRoot.querySelector("#track")?root.shadowRoot.querySelector("#track").offsetTop:0,cue=root.shadowRoot.querySelector("#track a11y-media-transcript-cue[active]");if(root.set("activeCues",cues.slice(0)),!root.disableScroll&&null!=cue&&void 0!==root.activeCues&&cue.getAttribute("order")!==root.activeCues[0]){let scrollingTo=function(element,to,duration){if(!(duration<=0)){var perTick=(to-element.scrollTop)/duration*10;setTimeout(function(){element.scrollTop=element.scrollTop+perTick,element.scrollTop!==to&&scrollingTo(element,to,duration-10)},10)}};scrollingTo(root,cue.offsetTop-offset,250)}}setMedia(player){this.media=player,this.dispatchEvent(new CustomEvent("transcript-ready",{detail:this}))}setTracks(tracks){this.set("tracks",tracks.slice(0)),this.notifyPath("tracks"),void 0!==this.tracks&&this.tracks.length>0&&this.$.tracks.render()}toggleHidden(mode){let inner=document.getElementById("inner");null!=inner&&inner.querySelector("a11y-media-transcript-cue[active]"),null!=inner&&inner.querySelector("a11y-media-transcript-cue");mode=void 0!==mode?mode:this.hidden,this.hidden=mode}_getTabIndex(disableInteractive){return disableInteractive?-1:0}_getRole(disableInteractive){return disableInteractive?null:"button"}_handleCueSeek(e){this.disableInteractive||this.dispatchEvent(new CustomEvent("transcript-seek",{detail:e.detail}))}_isActive(selectedTranscript,index){return null!=selectedTranscript&&parseInt(selectedTranscript)===parseInt(index)}_isLoading(selectedTranscript,tracks){return null==selectedTranscript||null==tracks||0===tracks.length}_stampLoadingStatus(disableSeek){return this.$.loading.innerHTML=!1===disableSeek?this._getLocal("transcript","label"):this._getLocal("youTubeTranscript","label"),this.$.loading.innerHTML}}_exports.A11yMediaTranscript=A11yMediaTranscript,window.customElements.define(A11yMediaTranscript.tag,A11yMediaTranscript)});