var GLOBAL_CONFIG={apiBaseUrl:"https://analytics.storysoft.io/api/",plannerUrl:"https://builder-api.storysoft.io/api/",STARTING_PAGE:1,MAX_WIDTH_PX:720,MAX_HEIGHT_PX:1280,MIN_SCREEN_HEIGHT:576,ASPECT_RATIO:1280/720,SCREEN_RESIZE_DELAY:50},INTERACTION_TYPE={PAGE_VIEW:0,PAGE_EXIT:1,LINK_OPEN:2,CLICK:3,QUESTION:4,TEXT:5,CUSTOM:6},LOADING_ERRORS={UNREGISTERED_STORY:"Invalid Story Code"},queryParams=URI(document.URL).query(!0);function debounce(i,s,o){var a,r,e=function(){var e=this,n=arguments;if(a&&clearTimeout(a),o){var t=!a;a=setTimeout(function(){a=null},s),t&&(r=i.apply(e,n))}else a=setTimeout(function(){i.apply(e,n)},s);return r};return e.cancel=function(){clearTimeout(a),a=null},e}var init=function(e){window.preview=new Vue({el:"#app",data:{GLOBAL_CONFIG:GLOBAL_CONFIG,GLOBAL_HEADER:e.GLOBAL_HEADER,GLOBAL_FOOTER:e.GLOBAL_FOOTER,STORY_CONFIG:e.STORY_CONFIG,VISIT_CODE:e.VISIT_CODE,interactions:[],isFullscreen:isStoryFullscreen(),showSwipeMsg:!1,swipeWasUsed:!1,preventNext:!1,preventBack:!1,shouldHighlightNav:e.STORY_CONFIG.HIGHLIGHT_NAV,session:{},params:queryParams,config:e.STORY_CONFIG,pages:e.STORY_PAGES,pageNum:0},created:function(){window.addEventListener("unload",this.saveFinalExit,!1),window.addEventListener("resize",debounce(this.onScreenResize,GLOBAL_CONFIG.SCREEN_RESIZE_DELAY)),window.addEventListener("orientationchange",debounce(this.onScreenResize,GLOBAL_CONFIG.SCREEN_RESIZE_DELAY))},mounted:function(){var n=this;this.goHome(),this.STORY_CONFIG.SHOW_MESSAGE_AFTER&&setTimeout(function(){n.swipeWasUsed||(n.showSwipeMsg=!0)},1e3*this.STORY_CONFIG.SHOW_MESSAGE_AFTER),this.STORY_CONFIG.HIDE_MESSAGE_AFTER&&setTimeout(function(){n.showSwipeMsg=!1},1e3*this.STORY_CONFIG.HIDE_MESSAGE_AFTER);var e=new Hammer(document.getElementById("story-container"),{inputClass:Hammer.TouchInput});e.on("swipeleft",this.nextPage),e.on("swiperight",this.prevPage),$("#app").on("click","a",function(){var e=$(this).attr("href");n.saveLink(e)})},methods:{goHome:function(){this.setPage(this.GLOBAL_CONFIG.STARTING_PAGE)},nextPage:function(){this.swipeWasUsed=!0,this.showSwipeMsg=!1,this.preventNext||this.setPage(this.pageNum+1)},prevPage:function(){this.swipeWasUsed=!0,this.showSwipeMsg=!1,this.preventBack||this.setPage(this.pageNum-1)},setPage:function(e){0>16&255,t>>8&255,255&t].join(",")+","+n+")"):e},personalize:function(e){if(!e)return e;var n=/{{([a-zA-Z])\w+(\|[^}]*)?}}/g,t=(" "+e).slice(1),i=null;do{if(i=n.exec(e)){var s=i[0],o=s.substr(2,s.length-4).split("|"),a=1]+)>)/gi,"")},submitSurvey:function(){this.saveQuestion(this.unsafeStripTags(this.personalize(this.activePage.question)),this.unsafeStripTags(this.personalize(this.activePage["answer"+this.activePage.answer]))),this.nextPage()},saveView:function(e){return this.saveInteraction(INTERACTION_TYPE.PAGE_VIEW,e)},saveLink:function(e,n,t){return this.saveInteraction(INTERACTION_TYPE.LINK_OPEN,this.pageNum,e,n,t)},saveClick:function(e,n,t){return this.saveInteraction(INTERACTION_TYPE.CLICK,this.pageNum,e,n,t)},saveQuestion:function(e,n,t){return this.saveInteraction(INTERACTION_TYPE.QUESTION,this.pageNum,e,n,t)},saveText:function(e,n,t){return this.saveInteraction(INTERACTION_TYPE.TEXT,this.pageNum,e,n,t)},saveInteraction:function(e,n,t,i,s){if(this.VISIT_CODE){var o={V:this.VISIT_CODE,G:s,N:t,D:i,T:e,P:n-1,C:(new Date).toISOString(),I:this.interactions.length};$.ajax({url:this.GLOBAL_CONFIG.apiBaseUrl+"Interactions",dataType:"json",type:"post",contentType:"application/json",data:JSON.stringify(o)})}},saveFinalExit:function(){navigator.sendBeacon(this.GLOBAL_CONFIG.apiBaseUrl+"Interactions",JSON.stringify({V:this.VISIT_CODE,T:INTERACTION_TYPE.PAGE_EXIT,P:this.pageNum-1,C:(new Date).toISOString(),I:this.interactions.length}))}},watch:{pageNum:function(e,n){document.body.scrollTop=document.documentElement.scrollTop=0,this.pages[n-1]&&this.pages[n-1].onExit&&this.pages[n-1].onExit(),this.pages[e-1]&&this.pages[e-1].onEnter&&this.pages[e-1].onEnter()}},computed:{activePage:function(){return this.pages[this.pageNum-1]||{}},hasNextPage:function(){return this.pageNum=GLOBAL_CONFIG.MAX_WIDTH_PX||window.innerHeight>=GLOBAL_CONFIG.MAX_HEIGHT_PX)}function showLoadingError(e){$("#story-loading-error-message").text(e),$("#story-loading-error").show()}$(function(){function e(){var e=$("#story-container");window.innerWidth>window.innerHeight&&window.innerHeight