"use strict";var gtm4wp_soundclound_percentage_tracking=10,gtm4wp_soundclound_percentage_tracking_marks={};window.addEventListener("DOMContentLoaded",function(){var e=document.querySelectorAll('iframe[src*="soundcloud.com"]');e&&0!=e.length&&e.forEach(function(t){var e=SC.Widget(t),a={},n=(e.bind(SC.Widget.Events.READY,function(){e.getCurrentSound(function(e){t.setAttribute("data-player_id",e.id),t.setAttribute("data-player_author",e.user.username),t.setAttribute("data-player_title",e.title),t.setAttribute("data-player_url",e.permalink_url),t.setAttribute("data-player_duration",e.duration),a=e,window[gtm4wp_datalayer_name].push({event:"gtm4wp.mediaPlayerReady",mediaType:"soundcloud",mediaData:{id:e.id,author:e.user.username,title:e.title,url:e.permalink_url,duration:e.duration},mediaCurrentTime:0})}),e.bind(SC.Widget.Events.PLAY_PROGRESS,function(e){i(e)}),e.bind(SC.Widget.Events.PLAY,function(e){n(e,"play")}),e.bind(SC.Widget.Events.PAUSE,function(e){n(e,"pause")}),e.bind(SC.Widget.Events.FINISH,function(e){n(e,"ended")}),e.bind(SC.Widget.Events.SEEK,function(e){n(e,"seeked")}),e.bind(SC.Widget.Events.CLICK_DOWNLOAD,function(){d("click-download")}),e.bind(SC.Widget.Events.CLICK_BUY,function(){d("click-buy")}),e.bind(SC.Widget.Events.OPEN_SHARE_PANEL,function(){d("open-share-panel")}),e.bind(SC.Widget.Events.ERROR,function(){d("error")})}),function(e,t){window[gtm4wp_datalayer_name].push({event:"gtm4wp.mediaPlayerStateChange",mediaType:"soundcloud",mediaData:{id:a.id,author:a.user.username,title:a.title,url:a.permalink_url,duration:a.duration},mediaCurrentTime:e.currentPosition,mediaPlayerState:t})}),i=function(e){var t=Math.floor(e.currentPosition/a.duration*100);void 0===gtm4wp_soundclound_percentage_tracking_marks[a.id]&&(gtm4wp_soundclound_percentage_tracking_marks[a.id]=[]);for(var n=0;n<100;n+=gtm4wp_soundclound_percentage_tracking)n<t&&-1==gtm4wp_soundclound_percentage_tracking_marks[a.id].indexOf(n)&&(gtm4wp_soundclound_percentage_tracking_marks[a.id].push(n),window[gtm4wp_datalayer_name].push({event:"gtm4wp.mediaPlaybackPercentage",mediaType:"soundcloud",mediaData:{id:a.id,author:a.user.username,title:a.title,url:a.permalink_url,duration:a.duration},mediaCurrentTime:e.currentPosition,mediaPercentage:n}))},d=function(t){e.getPosition(function(e){window[gtm4wp_datalayer_name].push({event:"gtm4wp.mediaPlayerEvent",mediaType:"soundcloud",mediaData:{id:a.id,author:a.user.username,title:a.title,url:a.permalink_url,duration:soundData.duration},mediaCurrentTime:e,mediaPlayerEvent:t})})}})});