text: module.exports=function(e){var o={};function t(r){if(o[r])return o[r].exports;var s=o[r]={i:r,l:!1,exports:{}};return e[r].call(s.exports,s,s.exports,t),s.l=!0,s.exports}return t.m=e,t.c=o,t.d=function(e,o,r){t.o(e,o)||Object.defineProperty(e,o,{enumerable:!0,get:r})},t.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},t.t=function(e,o){if(1&o&&(e=t(e)),8&o)return e;if(4&o&&"object"==typeof e&&e&&e.__esModule)return e;var r=Object.create(null);if(t.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:e}),2&o&&"string"!=typeof e)for(var s in e)t.d(r,s,function(o){return e[o]}.bind(null,s));return r},t.n=function(e){var o=e&&e.__esModule?function(){return e.default}:function(){return e};return t.d(o,"a",o),o},t.o=function(e,o){return Object.prototype.hasOwnProperty.call(e,o)},t.p="",t(t.s=1)}([function(e,o){e.exports=require("vscode")},function(e,o,t){"use strict";t.r(o),t.d(o,"activate",(function(){return k})),t.d(o,"deactivate",(function(){return h}));var r=t(0);class s{constructor(e,o,t,r){this.bookmarkName=e.trim(),this.index=t,this.flowName=o,this.flowIndex=r}getBookmarkName(){return this.bookmarkName}getFlow(){return this.flowName}getIndex(){return this.index}}class a{constructor(e,o=[]){this.name=e,this.bookmarksIndexes=o}getbookmarksIndexes(){return this.bookmarksIndexes}getName(){return this.name}addNewBookmarkIndex(e){this.bookmarksIndexes.push(e)}}const n=["blue","red","pink","purple","yellow"];class i{constructor(e,o,t){this.context=e,this.workspaceController=o,this.editorController=t}addBookmark(e=r.window.activeTextEditor,o){const{filePath:t,lineNumber:s}=this.getFilePathAndLine(e);this.addOrEditBookmark(t,s,o)}editBookmark(e,o,t){this.addOrEditBookmark(e,Number(o),t)}addOrEditBookmark(e,o,t="Uncategorised"){const[r,n,i]=t.split(",").map(e=>e.trim())||[],l=this.workspaceController.getBookmarks(),m=n||"Uncategorised";let c=this.workspaceController.getFlows();if(c=Array.isArray(c)?c:[],(l[e]||{})[o]){const t=l[e][o].flowIndex,r=c[t].bookmarksIndexes;1===r.length?c[t]=null:r.pop()}const d=this.getIndexOfExistingOrNewFLow(c,m),k=c[d],h=d<c.length&&k?new a(k.name,k.bookmarksIndexes):new a(m),w=i?Number(i):h.getbookmarksIndexes().length;h.addNewBookmarkIndex(w),d<c.length?c[d]=h:c.push(h);const u=new s(r,h.getName(),w,d);l[e]=l[e]||{},l[e][o]=u,this.workspaceController.updateBookmarks(l),this.workspaceController.updateFlows(c),this.decorateActiveEditor()}clearBookmark(e=r.window.activeTextEditor){const{filePath:o,lineNumber:t}=this.getFilePathAndLine(e);this.clearOrDeleteBookmark(o,t)}deleteBookmark(e,o){this.clearOrDeleteBookmark(e,Number(o))}clearOrDeleteBookmark(e,o){const t=this.workspaceController.getBookmarks();let s="",n=-1;if(!t[e]||!t[e][o])return void r.window.showInformationMessage("This line does not have any bookmark");{const r={};Object.keys(t[e]).forEach(a=>{a!==o.toString()?(r[a]=r[a]||{},r[a]=t[e][a]):(s=t[e][a].flowName,n=Number(t[e][a].flowIndex))}),t[e]=r}const i=this.workspaceController.getFlows(),l=new a(i[n].name,i[n].bookmarksIndexes);l.bookmarksIndexes.pop(),i[n]=l.bookmarksIndexes.length>0?l:null,this.workspaceController.updateFlows(i),this.workspaceController.updateBookmarks(t),this.decorateActiveEditor()}clearAllBookmarks(){this.workspaceController.clearAllFlows(),this.workspaceController.clearAllBookmarks(),this.decorateActiveEditor()}decorateActiveEditor(e=r.window.activeTextEditor){const o=this.workspaceController.getActiveEditorBookmarks(e);this.editorController.displayBookmarkForActiveEditor(e,o)}getFilePathAndLine(e=r.window.activeTextEditor){var o;const t=e.document.uri.fsPath,s=(null===(o=r.workspace.rootPath)||void 0===o?void 0:o.length)||0;return{filePath:t.substring(s),lineNumber:e.selection.active.line}}getIndexOfExistingOrNewFLow(e,o){let t=-1;for(let r=0;r<e.length;r++){const s=e[r];if(s&&s.name.toLowerCase()===o.toLowerCase()){t=r;break}!s&&t<0&&(t=r)}return t>=0?t:e.length}}class l{constructor(e){this.context=e,this.savedBookmarks={}}getBookmarks(){return this.context.workspaceState.get("bookmarks")||{}}updateBookmarks(e){this.context.workspaceState.update("bookmarks",e)}clearAllBookmarks(){this.context.workspaceState.update("bookmarks",{})}getFlows(){return this.context.workspaceState.get("flows")||[]}updateFlows(e){this.context.workspaceState.update("flows",e)}clearAllFlows(){this.context.workspaceState.update("flows",[])}getActiveEditorBookmarks(e=r.window.activeTextEditor){var o;const t=e.document.uri.fsPath,s=(null===(o=r.workspace.rootPath)||void 0===o?void 0:o.length)||0,a=t.substring(s)||"";return this.getBookmarks()[a]}getListOfFlowNames(){this.savedBookmarks={};const e={},o=this.getBookmarks();return Object.keys(o).forEach(t=>{Object.keys(o[t]).forEach(r=>{const s=o[t][r];e[s.flowName]||(e[s.flowName]=s.flowIndex),this.savedBookmarks[s.flowName]=this.savedBookmarks[s.flowName]||{},this.savedBookmarks[s.flowName][t]=this.savedBookmarks[s.flowName][t]||{},this.savedBookmarks[s.flowName][t][r]=this.savedBookmarks[s.flowName][t][r]||{},this.savedBookmarks[s.flowName][t][r].bookmarkName=s.bookmarkName,this.savedBookmarks[s.flowName][t][r].index=s.index,this.savedBookmarks[s.flowName][t][r].flowIndex=s.flowIndex})}),e}getBookmarksForFlow(e){return this.savedBookmarks[e]}}class m{constructor(e,o,t,s){this.workSpaceRoot=e,this.workspaceController=o,this.context=t,this.colors=s,this._onDidChangeTreeData=new r.EventEmitter,this.onDidChangeTreeData=this._onDidChangeTreeData.event}refresh(e){this._onDidChangeTreeData.fire(e)}getTreeItem(e){return e}getChildren(e){return this.workSpaceRoot||r.window.showInformationMessage("No workspace root was provided..."),e?e.getFileName()?Promise.resolve([]):Promise.resolve(this.getBookmarksForFlow(e.label)):Promise.resolve(this.getListOfFlow())}getListOfFlow(){let e=[];const o=this.workspaceController.getListOfFlowNames();return e=Object.keys(o).map(e=>{const t=this.colors[o[e]%this.colors.length];return new c(e,r.TreeItemCollapsibleState.Collapsed,this.context.asAbsolutePath(`images/bookmark-${t}.svg`))}),e.sort((e,o)=>{const t=e.getLabel(),r=o.getLabel();return t<r?-1:t>r?1:0})}getBookmarksForFlow(e){const o=this.workspaceController.getBookmarksForFlow(e),t=[];return Object.keys(o).forEach(s=>{Object.keys(o[s]).forEach(a=>{const n=Number(o[s][a].flowIndex)%this.colors.length,i=this.colors[n],l=s.substr(s.lastIndexOf("/")+1);t.push(new c(o[s][a].index+". "+o[s][a].bookmarkName,r.TreeItemCollapsibleState.None,this.context.asAbsolutePath(`images/bookmark-${i}.svg`),l,a,o[s][a].index,e,{command:"flowBookmark.jumpTo",title:"",arguments:[s,a,e]},"dependency"))})}),t.sort((e,o)=>e.getIndex()-o.getIndex())}}class c extends r.TreeItem{constructor(e,o,t,r,s,a,n,i,l){super(e,o),this.label=e,this.collapsibleState=o,this.iconPath=t,this.fileName=r,this.lineNumber=s,this.index=a,this.flowName=n,this.command=i,this.contextValue=l}get tooltip(){return`${this.index}.${this.label}- ${this.fileName}`}get description(){return this.fileName&&this.lineNumber?`${this.fileName} - ${Number(this.lineNumber)+1}`:""}getFileName(){return this.fileName}getIndex(){return this.index||0}getLabel(){return this.label}}class d{constructor(e,o){this.colors=[],this.context=e,this.colors=o,this.bookmarkDecoratorList=this.colors.map(o=>r.window.createTextEditorDecorationType({gutterIconPath:e.asAbsolutePath(`images/bookmark-${o}.svg`)}))}openTextDocument(e,o){e=r.workspace.rootPath+e;const t=r.Uri.file(e);r.workspace.openTextDocument(t).then(e=>{r.window.showTextDocument(e).then(e=>{const t=parseInt(o,10),s=parseInt(o,10)+100;let a=r.TextEditorRevealType.InCenter;e.selection.active.line===t&&(a=r.TextEditorRevealType.InCenterIfOutsideViewport);const n=new r.Selection(t,s,t,s);e.selection=n,e.revealRange(n,a)})})}displayBookmarkForActiveEditor(e,o){const t=this.colors.map(e=>[]);o&&Object.keys(o).forEach(e=>{const s={range:new r.Range(new r.Position(Number(e),0),new r.Position(Number(e),10)),rangeBehaviour:r.DecorationRangeBehavior.OpenClosed,hoverMessage:o[e].bookmarkName+", "+o[e].flowName+", "+o[e].index||""};t[Number(o[e].flowIndex)%this.colors.length].push(s)}),t.forEach((o,t)=>e.setDecorations(this.bookmarkDecoratorList[t],o))}}function k(e){let o,t,s,a=n,c=void 0;!function(){const k=r.workspace.getConfiguration("flowbookmark");a=k.get("listOfColors").length>0&&k.get("listOfColors").length<11?k.get("listOfColors"):n,o=new d(e,a),t=new l(e),c=new i(e,t,o),s=new m(r.workspace.rootPath,t,e,a),r.window.registerTreeDataProvider("flowBookmarksView",s)}(),c&&c.decorateActiveEditor(),r.commands.registerCommand("flowBookmarksView.refreshEntry",e=>{s.refresh(e)}),r.window.onDidChangeActiveTextEditor(e=>{var o;e&&e.document===(null===(o=r.window.activeTextEditor)||void 0===o?void 0:o.document)&&c.decorateActiveEditor(e)});let k=r.commands.registerCommand("flowbookmark.addNew",()=>{const e=r.window.activeTextEditor;if(!e)return r.window.showInformationMessage("Please select a file first...");r.window.showInputBox({prompt:"Add Bookmark name, Flow name, index",placeHolder:"Bookmark name, Flow name, index"}).then(o=>{o?(c.addBookmark(e,o),r.commands.executeCommand("flowBookmarksView.refreshEntry")):r.window.showInformationMessage("Please enter Bookmark Name,Flow Name and/or index")})});const h=r.commands.registerCommand("flowBookmarksView.editEntry",e=>{const[o,t]=e.label.split(". "),s=e.command.arguments[0],a=e.command.arguments[1],n={prompt:"Edit Bookmark name, Flow name, index",placeHolder:"Bookmark name, Flow name, index",value:t+", "+e.command.arguments[2]+", "+o};r.window.showInputBox(n).then(e=>{e?(c.editBookmark(s,a,e),r.commands.executeCommand("flowBookmarksView.refreshEntry")):r.window.showInformationMessage("Please enter Bookmark Name,Flow Name and/or index")})});let w=r.commands.registerCommand("flowbookmark.clear",()=>{const e=r.window.activeTextEditor;if(!e)return r.window.showWarningMessage("Select a file first");c.clearBookmark(e),r.commands.executeCommand("flowBookmarksView.refreshEntry")});const u=r.commands.registerCommand("flowBookmarksView.deleteBookmark",e=>{const[o,t]=e.label.split(". "),s=e.command.arguments[0],a=e.command.arguments[1];e.command.arguments[2];c.deleteBookmark(s,a),r.commands.executeCommand("flowBookmarksView.refreshEntry")});let f=r.commands.registerCommand("flowbookmark.clearAll",()=>{c.clearAllBookmarks(),r.commands.executeCommand("flowBookmarksView.refreshEntry")});r.commands.registerCommand("flowBookmark.jumpTo",(e,t)=>{o.openTextDocument(e,t)}),e.subscriptions.push(k),e.subscriptions.push(h),e.subscriptions.push(w),e.subscriptions.push(u),e.subscriptions.push(f)}function h(){}}]);
  //# sourceMappingURL=extension.js.map