!function(e,t){if("object"==typeof exports&&"object"==typeof module)module.exports=t(require("polyglot"));else if("function"==typeof define&&define.amd)define(["polyglot"],t);else{var n="object"==typeof exports?t(require("polyglot")):t(e.polyglot);for(var r in n)("object"==typeof exports?exports:e)[r]=n[r]}}(window,function(e){return function(e){var t={};function n(r){if(t[r])return t[r].exports;var o=t[r]={i:r,l:!1,exports:{}};return e[r].call(o.exports,o,o.exports,n),o.l=!0,o.exports}return n.m=e,n.c=t,n.d=function(e,t,r){n.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:r})},n.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},n.t=function(e,t){if(1&t&&(e=n(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var r=Object.create(null);if(n.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var o in e)n.d(r,o,function(t){return e[t]}.bind(null,o));return r},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,"a",t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p="/install/webcontent/bi/js/smarts-js",n(n.s=12)}([,,,function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r=function(){function e(e,t){for(var n=0;n1){var a={or:[]};n.values.forEach(function(e){var t=Object.assign({},o);t.values=[e],a.or.push(t)}),o=a}return{id:t,columnId:t,values:[],excludedValues:[],operator:"in",conditions:r?{not:o}:o}},_addTopBottomSpec:function(e,t){var n=t.topBottomType,r=t.method;if(!(n=n.toLowerCase()))return e;var o={operation:"keep",topBottom:{type:n+("count"===(r=r.toLowerCase())?"count":"percent"),value:t.domainSize}};if(t.byColumn){var i={itemId:t.byColumn},u=t.byAggregate;u&&(i.aggregate=a[u]),o.context=[i]}return e.selection=[o],e},_addProperties:function(e){return e.showTitle=!("summary"===e.visId),e.borderColor="color2",e.type=e.type?e.type:"live",e.localFilters=[],e.properties=[{id:"widget.legend.position",value:"bottom"}],"com.ibm.vis.rave2marimekko"===e.visId&&e.properties.push({id:"stacked.percent",value:!1}),e}}},,,,,,function(e,t,n){"use strict";var r,o=function(){function e(e,t){for(var n=0;n0){var u={ContentType:"CHART",instances:a};Object.assign(i,{includedArtifacts:[u]})}return i}(t);return e.getSvc(".SmartsService").then(function(e){return e.getContentRecommendation(n)}).then(function(e){return e.containers})}return function(){function t(){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,t)}return o(t,[{key:"initialize",value:function(e){var t=this;return Promise.resolve().then(function(){t._glassContext=e})}},{key:"generate",value:function(t){var n=this;e(this._glassContext,t).then(function(e){return t.content=e,n.createNewDashboard(t)})}},{key:"createNewDashboard",value:function(e){var t=this,n=e.sourceId,r=e.sourceType,o=e.content;return Promise.resolve().then(function(){return t._glassContext.openAppView("dashboard",{content:i.default.getNewDashboardSpec()})}).then(function(){return t._glassContext.getCurrentContentView().dashboardApi}).then(function(e){return t.addToTabbedDashboard({sourceId:n,sourceType:r,content:o,dashboardApi:e})})}},{key:"addToTabbedDashboard",value:function(e){var t=this,n=e.sourceId,r=e.sourceType,o=e.content,i=e.dashboardApi;if("dashboard"!==i.getType())return Promise.reject(Error(u.default.get("errorNotADashbaord")));if(i.getMode()===i.MODES.VIEW)return Promise.reject(Error(u.default.get("errorDashboardCannotBeModified")));if(this._canvas=i.getCanvas(),!(this._canvas.getContent().getType().indexOf("tab")>-1))return Promise.reject(Error(u.default.get("errorDashboardNotTabbed")));var s=this._canvas.findContent({type:"container"}),c=i.getFeature("Transaction"),d=c.startTransaction(),l=i.getFeature("DataSources").addDataSource({assetId:n,type:r}),f=this._canvas.findContent({type:"tab"})[0].getId();return a.default.processSmartsContent(this._glassContext,{sourceId:n,sourceType:r,content:o,modelRefId:l}).then(function(e){return e.reverse().reduce(function(e,n){var r=n.chartInfoList,o=n.tabLabel;return e.then(function(){return t._addPage(f,r,o,d,0)})},Promise.resolve())}).catch(Promise.reject).finally(function(){s.forEach(function(e){return t._canvas.removeContent(e.getId())}),c.endTransaction(d)})}},{key:"_addPage",value:function(e,t,n,r,o){var a=this;return this._createPage(e,n,r,o).then(function(e){return a._addWidgetsToPage(e,t,r)})}},{key:"_createPage",value:function(e,t,n,r){return this._canvas.addContent({containerId:e,type:"page",properties:{title:t},position:r},n).then(function(e){var t=e.getFeature("state");return t.whenStatusChanges(t.STATUS.RENDERED).then(function(){return e.getId()})})}},{key:"_addWidgetsToPage",value:function(e,t,n){var r=this;return Promise.all(t.map(function(t){var o=t.spec,a=t.style;return r._canvas.addContent({containerId:e,spec:o,properties:a},n)})).then(function(){return e})}}]),t}()}.apply(t,[]))||(e.exports=r)},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r=function(e){return e&&e.__esModule?e:{default:e}}(n(6));t.default={convertToTabContents:function(e,t){this.glassContext=e;var n="dashboard_"+Date.now(),o=t.sourceId,a=t.sourceType,i={modelRefId:t.modelRefId,sourceId:o,sourceType:a};return this.processSmartsContent(e,t).then(function(e){return r.default.buildTabContents(n,e,i)})},processSmartsContent:function(e,t){var n=this,r=t.sourceId,o=t.sourceType,a=t.content,i=t.modelRefId;return this.glassContext=e,Promise.all(a.map(function(e){return n._processContainer(e,r,o,i)}))},_processContainer:function(e,t,n,r){var o=this,a=e.groups,i=e.predictive,u=e.label;return Promise.all(a.map(function(e,a){var u=e.contents;return o._processGroup(t,n,r,u,0==a,i)})).then(function(e){return{chartInfoList:e.reduce(function(e,t){return e.concat(t)},[]),tabLabel:u}})},_processGroup:function(e,t,n,o,a,i){var u=this;return Promise.all(o.map(function(o){var a=o.chart;return u._convertToLiveWidgetSpec(e,t,a,n).then(function(e){return e.length?(r.default.fixupLiveWidgetSpec(e[0],n,a),e[0]):Promise.reject(Error("Unable to create dashboard due to unsupported chart type: "+a.chartType))}).then(function(e){return{spec:e,chart:a}})})).then(function(e){return e=e.filter(function(e){return!!e.spec}),u._addLayoutInfo(e,i,a),e})},_addLayoutInfo:function(e,t,n){if(n)return this._addStyleForPrimaryGroup(e,t);var r=75/e.length-1;return e.forEach(function(e,t){var n=t*r+1*(t+1);e.style={left:"56%",width:"43%",height:r+"%",top:n+"%"}}),e},_addStyleForPrimaryGroup:function(e,t){var n={vizOnly:{viz:{top:"1%",height:"74%",left:"1%",width:"54%"}},withText:{viz:{top:"1%",height:"57%",left:"1%",width:"54%"},text:{top:"60%",height:"15%",left:"1%",width:"54%"}},withPredict:{viz:{top:"1%",height:"56%",left:"1%",width:"54%"},predict:{top:"58%",height:"17%",left:"1%",width:"54%"}},withBoth:{predict:{top:"1%",height:"18%",left:"1%",width:"54%"},viz:{top:"20%",height:"35%",left:"1%",width:"54%"},text:{top:"65%",height:"10%",left:"1%",width:"54%"}}},r={};return r=1===e.length?n.vizOnly:2===e.length?t?n.withPredict:n.withText:n.withBoth,e.forEach(function(e){switch(e.chart.chartType){case"Spiral":case"DecisionTree":case"DriverAnalysis":case"Sunburst":e.style=r.predict;break;default:e.style=r.viz}}),e},_convertToLiveWidgetSpec:function(e,t,n){if(n)return this.glassContext.getSvc(".LiveWidgetService").then(function(r){return r.transformRecommendationsToLiveWidgetSpecs([n],{assetId:e,type:t})})}}}])}); //# sourceMappingURL=smartsDashboardGenerator.min.js.map