define("layout/scratchbook",["exports","mvc/ui/ui-frames","mvc/dataset/data","viz/visualization","viz/trackster","utils/localization"],function(t,e,a,i,n,o){"use strict";function l(t){return t&&t.__esModule?t:{default:t}}Object.defineProperty(t,"__esModule",{value:!0});var s=l(e),r=l(a),c=l(i),d=l(n),u=l(o);t.default=Backbone.View.extend({initialize:function(t){var e=this;t=t||{},this.frames=new s.default.View({visible:!1}),this.setElement(this.frames.$el),this.buttonActive=t.collection.add({id:"enable-scratchbook",icon:"fa-th",tooltip:(0,u.default)("Enable/Disable Scratchbook"),onclick:function(){e.active=!e.active,e.buttonActive.set({toggle:e.active,show_note:e.active,note_cls:e.active&&"fa fa-check"}),!e.active&&e.frames.hide()},onbeforeunload:function(){if(e.frames.length()>0)return"You opened "+e.frames.length()+" frame(s) which will be lost."}}),this.buttonLoad=t.collection.add({id:"show-scratchbook",icon:"fa-eye",tooltip:(0,u.default)("Show/Hide Scratchbook"),show_note:!0,visible:!1,onclick:function(t){e.frames.visible?e.frames.hide():e.frames.show()}}),this.frames.on("add remove",function(){this.visible&&0==this.length()&&this.hide(),e.buttonLoad.set({note:this.length(),visible:this.length()>0})}).on("show hide ",function(){e.buttonLoad.set({toggle:this.visible,icon:this.visible&&"fa-eye"||"fa-eye-slash"})}),this.history_cache={}},addDataset:function(t){var e=this,a=null;if(Galaxy&&Galaxy.currHistoryPanel){var i=Galaxy.currHistoryPanel.collection.historyId;this.history_cache[i]={name:Galaxy.currHistoryPanel.model.get("name"),dataset_ids:[]},Galaxy.currHistoryPanel.collection.each(function(t){!t.get("deleted")&&t.get("visible")&&e.history_cache[i].dataset_ids.push(t.get("id"))})}var n=function(t,a){if(t){var i=e.history_cache[t.get("history_id")];if(i&&i.dataset_ids){var n=i.dataset_ids,o=n.indexOf(t.get("id"));if(-1!==o&&o+a>=0&&o+a