text: define(["jasperreports-loader","./jasperreports-status-checker","./jasperreports-component-registrar","./jasperreports-event-manager","./jasperreports-report-processor","jquery"],function(e,t,n,r,a,s){var o=function(o){this.config={reporturi:null,async:!0,page:0,updateInterval:1e3,container:null},s.extend(this.config,o),this.currentpage=this.config.page,this.html=null,this.status=null,this.components=null,this.eventManager=new r,this.events={ACTION_PERFORMED:"action",BEFORE_ACTION_PERFORMED:"beforeAction",UNDO_PERFORMED:"undo",UNDO_ALL_PERFORMED:"undoall",SEARCH_PERFORMED:"search",SAVE_ZOOM_PERFORMED:"saveZoom",REDO_PERFORMED:"redo",PAGE_MODIFIED:"pageModified",REPORT_HTML_READY:"reportHtmlReady",COMPONENTS_REGISTERED:"componentsRegistered",REPORT_FINISHED:"reportFinished"},this.loader=new e({reporturi:this.config.reporturi,async:this.config.async,eventManager:this.eventManager}),this.statusChecker=new t(this.loader,this.config.updateInterval),this.componentRegistrar=new n(this.loader),this.reportProcessor=new a,o.stopOnFinishOnly&&(this.loader.config.stopOnFinishOnly=!0)};return o.prototype={init:function(e){return this.refreshPage(this.currentpage,null,e)},refreshPage:function(e,t,n){var r=this;return r.currentpage=e,r.loader.getHtmlForPage(e,t,n).then(function(t,n,a){return r.status=s.parseJSON(a.getResponseHeader("jasperreports-report-status")),r.html=t,r.config.postProcess&&r.config.postProcess.call(r),r.reportProcessor.processReport(r),r.eventManager.triggerEvent(r.events.REPORT_HTML_READY),r.status.isComponentMetadataEmbedded?s.parseJSON(s(t).find("#reportComponents").text()):r.loader.getComponentsForPage(e)}).then(function(e){return r.components={},r.componentRegistrar.registerComponents(e,r)}).then(function(){return!r.status.pageTimestamp&&r.status.totalPages||"canceled"==r.status.reportStatus||r.statusChecker.checkPageModified(e,r.status.pageTimestamp).then(function(e){r.status.originalStatus=e,"finished"==e.status?(r.status.totalPages=e.lastPageIndex+1,r.status.partialPageCount=e.lastPartialPageIndex+1,r.status.reportStatus=e.status,r.eventManager.triggerEvent(r.events.REPORT_FINISHED)):e.pageModified&&r.eventManager.triggerEvent(r.events.PAGE_MODIFIED)}),r.eventManager.triggerEvent(r.events.COMPONENTS_REGISTERED),r})},gotoPage:function(e){return this.statusChecker.cancelCheckPageModified(),this.refreshPage(e,!0)},search:function(e){var t=this;return this.loader.runAction({action:{actionName:"search",searchData:{searchString:e.searchString,caseSensitive:e.caseSensitive||!1,wholeWordsOnly:e.wholeWordsOnly||!1}}}).then(function(e){return t._notify({name:t.events.SEARCH_PERFORMED,type:"search",data:e}),t})},saveZoom:function(e){var t=this;return this.loader.runAction({action:{actionName:"saveZoom",zoomValue:e},showAjaxDialog:!1}).then(function(e){return t._notify({name:t.events.SAVE_ZOOM_PERFORMED,type:"saveZoom",data:e}),t})},undo:function(){var e=this;return e._notify({name:e.events.BEFORE_ACTION_PERFORMED}),this.loader.runAction({action:{actionName:"undo"}}).then(function(t){return e._notify({name:e.events.UNDO_PERFORMED,type:"undo",data:t}),e})},redo:function(){var e=this;return e._notify({name:e.events.BEFORE_ACTION_PERFORMED}),this.loader.runAction({action:{actionName:"redo"}}).then(function(t){return e._notify({name:e.events.REDO_PERFORMED,type:"redo",data:t}),e})},undoAll:function(){var e=this;return e._notify({name:e.events.BEFORE_ACTION_PERFORMED}),this.loader.runAction({action:{actionName:"undoAll"}}).then(function(t){return e._notify({name:e.events.UNDO_ALL_PERFORMED,type:"undoall",data:t}),e})},cancelStatusUpdates:function(){this.statusChecker.cancelCheckPageModified()},cancelExecution:function(e){return this.statusChecker.cancelCheckPageModified(),this.loader.cancelExecution(e)},on:function(e,t){return this.eventManager.subscribeToEvent({name:e,callback:t,thisContext:this,keep:!0}),this},_notify:function(e){this.config.debug&&console.log("report notified of event: "+e.name+"; type: "+e.type),this.eventManager.triggerEvent(e.name,e)}},o});