text: "use strict";
  
  function Ide3(window, document, translate, gUserId, pagePanic) {
  
  var self = this
  
  var globs = null
  
  var ResizeTimeout = 300
  var PollInterval = 1
  var MaxSaveItems = 10
  
  var LineHeight = 34
  var TitleHeight = 30
  
  var TopPanelHeight = 52
  var DockHeaderColor = "#E2EDF5"
  var DarkBackground = "#455A64"
  var BorderRadius = "4px"
  var ImagePath = "/static/images/"
  
  var SearchHeight = 30
  
  var logonCtrl = new Logon(window, document, translate)
  
  var SpecialBack = "linear-gradient(coral, #CD5B45)"
  var NormalBack = "linear-gradient(#758A94, #455A64)"
  var WhiteBack = "linear-gradient(white, #dddddd)"
  var SpecialBottom = "solid 1px 1A0D00"
  
  // Autogenerated with DRAKON Editor 1.33
  
  
  function Clipboard() {
      this.getClipboardType = getClipboardType
      this.copyToClipboard = copyToClipboard
      this.getClipboard = getClipboard
      this.clear = clearClipboard
  }
  
  function Storage() {
      var saveChanges = function(changes) {
      	self.logic.saveChanges(changes)
      }
      this.saveChanges = wrapException(
      	saveChanges,
      	"saveChanges"
      )
  }
  
  function addAdmin() {
      onAddUserClicked("admin")
  }
  
  function addCentral(node, centralMachine) {
      createCentralCore(
      	node,
      	centralMachine
      )
  }
  
  function addClickable(popup, text, action, style) {
      var row = make(popup, "div")
      
      row.style.padding = "10px"
      row.style.background = DarkBackground
      row.style.color = "white"
      row.style.textAlign = "center"
      row.style.borderRadius = "4px"
      row.style.margin = "5px"
      if (style) {
          Utils.mergeSets(row.style, style)
      }
      row.className = "list_item"
      HtmlUtils.setDivText(
      	row,
      	text
      )
      row.onclick = wrapException(
      	action,
      	"searchGroup"
      )
  }
  
  function addDrakonHubClosed(parent) {
      if (Config.dead) {
          var banner = make(parent, "div")
          banner.style.padding = "10px"
          banner.style.fontSize = "30px"
          banner.style.cursor = "pointer"
          banner.style.background = "black"
          banner.style.color = "red"
          banner.style.border = "solid 2px red"
          var text = translate("MES_DRAKONHUB_CLOSED")
          HtmlUtils.setDivText(banner, text)
          banner.onclick = function() {
          	goToUrl("/static/dead.html")
          }
      }
  }
  
  function addEmpty(text) {
      var popup = globs.search.popup
      var row = make(popup, "div")
      
      row.style.padding = "5px"
      row.style.background = DarkBackground
      row.style.color = "white"
      HtmlUtils.setDivText(
      	row,
      	text
      )
      globs.search.empty = row
  }
  
  function addExpandedGroup(items) {
      var _sw33580000_ = 0;
      var list = getOrCreateExpanded()
      var _ind3347 = 0;
      var _col3347 = items;
      var _len3347 = _col3347.length;
      while (true) {
          if (_ind3347 < _len3347) {
              
          } else {
              break;
          }
          var item = _col3347[_ind3347];
          _sw33580000_ = item.type;
          if (_sw33580000_ === "folder") {
              addSearchFolder(
              	list,
              	item
              )
          } else {
              if (_sw33580000_ === "item") {
                  addSearchItem(
                  	list,
                  	item
                  )
              }
          }
          _ind3347++;
      }
  }
  
  function addFoundGroup(group, completed, items) {
      var _sw32810000_ = 0;
      var MaxItems = 8
      if (items.length == 0) {
          
      } else {
          var gl = getOrCreateGroupList(group)
          var _ind3260 = 0;
          var _col3260 = items;
          var _len3260 = _col3260.length;
          while (true) {
              if (_ind3260 < _len3260) {
                  
              } else {
                  break;
              }
              var item = _col3260[_ind3260];
              if (gl.count < MaxItems) {
                  
              } else {
                  break;
              }
              gl.count++
              _sw32810000_ = item.type;
              if (_sw32810000_ === "folder") {
                  addSearchFolder(
                  	gl.div,
                  	item
                  )
              } else {
                  if (_sw32810000_ === "item") {
                      addSearchItem(
                      	gl.div,
                      	item
                      )
                  }
              }
              _ind3260++;
          }
      }
  }
  
  function addIconText(list, image, text) {
      var row = {
      	id: text,
      	cells: [
      		{src:image, width:36, height:36},
      		{text: text}
      	]
      }
      list.push(row)
  }
  
  function addMainMenuItems(parent, items, color) {
      var first = true
      var makeCallback = function(action) {
      	var onClick = function() {
      		hidePopup()
      		action()
      	}
      	return wrapException(onClick, "main menu")
      }
      var _ind2396 = 0;
      var _col2396 = items;
      var _len2396 = _col2396.length;
      while (true) {
          if (_ind2396 < _len2396) {
              
          } else {
              break;
          }
          var item = _col2396[_ind2396];
          var row = make(parent, "div")
          row.style.padding = "3px"
          row.style.paddingBottom = "10px"
          row.style.minWidth = "100px"
          row.className = "list_item"
          if (first) {
              first = false
          } else {
              row.style.borderTop = "solid 1px silver"
          }
          var tpart
          if (item.link) {
              tpart = make(row, "a")
              tpart.className = "white_link"
              tpart.href = item.link
          } else {
              tpart = make(row, "div")
              row.onclick = makeCallback(item.action)
          }
          tpart.style.display = "inline-block"
          tpart.style.marginTop = "8px"
          HtmlUtils.setDivText(tpart, translate(item.text))
          _ind2396++;
      }
  }
  
  function addMenuSection(parent, menu) {
      var colHead = make(parent, "div")
      colHead.style.textAlign = "center"
      colHead.style.fontWeight = "bold"
      colHead.style.fontSize = "110%"
      colHead.style.padding = "5px"
      colHead.style.color = DarkBackground
      colHead.style.borderBottom = "solid 3px " + menu.color
      HtmlUtils.setDivText(colHead, translate(menu.title))
      var colBody = make(parent, "div")
      addMainMenuItems(colBody, menu.items, menu.color)
  }
  
  function addPopupItem(div, item) {
      if (item.type == "separator") {
          var hr = make(div, "hr")
          hr.style.margin = "0px"
      } else {
          var callback = function(evt) {
          	hidePopup()
          	item.code(evt)
          }
          var row = make(div, "div")
          row.className = "list_item"
          row.style.height = LineHeight + "px"
          var textPart = makeIB(row)
          textPart.style.padding = "8px"
          HtmlUtils.setDivText(
          	textPart,
          	translate(item.text)
          )
          var itemId = item.id || ""
          row.onclick = callback
      }
  }
  
  function addProjectRow(table, project) {
      var id = project + " 1"
      var action = function() {
      	self.logic.goToFolder(id)
      }
      var td = createIconListRow(
      	table,
      	"workspace-s2.png",
      	action
      )
      td.style.padding = "5px"
      td.style.overflowWrap = "break-word"
      HtmlUtils.setDivText(td, project)
  }
  
  function addReader() {
      onAddUserClicked("read")
  }
  
  function addRecentRow(table, item) {
      var action = function() {
      	self.logic.goToFolder(item.id)
      }
      var td = createIconListRow(
      	table,
      	item.icon,
      	action
      )
      td.style.padding = "5px"
      HtmlUtils.setDivText(td, item.text)
  }
  
  function addSearchFolder(popup, item) {
      var size = 30
      var path = makeImagePath(item.image)
      var table = make(popup, "table")
      var tr = make(table, "tr")
      var left = make(tr, "td")
      var right = make(tr, "td")
      table.className = "list_item"
      table.style.borderBottom = 
       "solid 1px silver"
      left.style.verticalAlign = "middle"
      left.style.width = size + "px"
      right.style.verticalAlign = "middle"
      right.style.width = "100%"
      var img = make(left, "img")
      img.width = size
      img.height = size
      img.src = path
      right.style.padding = "2px"
      table.onclick = makeSearchCallback(item)
      if (item.path) {
          var pathDiv = make(right, "div")
          HtmlUtils.setDivText(pathDiv, item.path)
          pathDiv.style.color = DarkBackground
      }
      var nameDiv = make(right, "div")
      HtmlUtils.setDivText(nameDiv, item.name)
      nameDiv.style.fontWeight = "normal"
  }
  
  function addSearchItem(popup, item) {
      var row = make(popup, "div")
      row.className = "list_item"
      row.style.borderBottom = 
       "solid 1px silver"
      row.style.padding = "2px"
      row.onclick = makeSearchCallback(item)
      if (item.path) {
          var pathDiv = make(row, "div")
          HtmlUtils.setDivText(pathDiv, item.path)
          pathDiv.style.color = DarkBackground
      }
      var nameDiv = make(row, "div")
      HtmlUtils.setDivText(nameDiv, item.name)
      nameDiv.style.fontWeight = "normal"
      var contentDiv = make(row, "div")
      var found = item.found
      var before = found.line.substring(
      	0,
      	found.start
      )
      var selected = found.line.substring(
      	found.start,
      	found.start + found.length
      )
      var after = found.line.substring(
      	found.start + found.length
      )
      var beforeNode = makeSpan(contentDiv, before)
      beforeNode.style.color = DarkBackground
      var selectedNode = makeSpan(contentDiv, selected)
      selectedNode.style.fondWeight = "bold"
      selectedNode.style.background = "coral"
      var afterNode = makeSpan(contentDiv, after)
      afterNode.style.color = DarkBackground
  }
  
  function addStyle(content) {
      var tn = document.createTextNode(content)
      var style = make(document.head, "style")
      style.appendChild(tn)
  }
  
  function addToSearchList(found) {
      var defs = globs.search.defs
      var changed = false
      if (defs) {
          if (found.completed) {
              defs.completed = true
          }
          var _ind3193 = 0;
          var _col3193 = defs;
          var _len3193 = _col3193.length;
          while (true) {
              if (_ind3193 < _len3193) {
                  
              } else {
                  break;
              }
              var group = _col3193[_ind3193];
              var items = found[group.id]
              if (items) {
                  Utils.addRange(items, group.items)
              }
              _ind3193++;
          }
          if (globs.search.expanded) {
              var items = found[globs.search.expanded]
              if (items) {
                  addExpandedGroup(
                  	items
                  )
              }
          } else {
              var _ind3505 = 0;
              var _col3505 = defs;
              var _len3505 = _col3505.length;
              while (true) {
                  if (_ind3505 < _len3505) {
                      
                  } else {
                      break;
                  }
                  var group = _col3505[_ind3505];
                  var items = found[group.id]
                  if ((items) && (items.length > 0)) {
                      addFoundGroup(
                      	group,
                      	defs.completed,
                      	items
                      )
                      changed = true
                  }
                  _ind3505++;
              }
              var total = getTotalFound()
              if (defs.completed) {
                  removeEmpty()
                  if (total == 0) {
                      addEmpty(
                      	translate("MES_NOTHING_FOUND")
                      )
                  }
              } else {
                  if (changed) {
                      removeEmpty()
                  }
              }
          }
      }
  }
  
  function addWriter() {
      onAddUserClicked("write")
  }
  
  function applyDashStyle(div) {
      var style = div.style
      style.padding = "5px"
  }
  
  function bindAddItem(shortcut, type) {
      var action = function() {
      	getEditor().showSockets(type)
      }
      bindEditor(shortcut, action)
  }
  
  function bindEditor(shortcuts, method) {
      var callback = function(evt) {
      	runIfEditorVisible(evt, method)
      }
      bindKey(shortcuts, callback, "keydown")
  }
  
  function bindKey(shortcuts, action, aux) {
      var wrapped = wrapException(action, shortcuts[0])
      Mousetrap.bind(shortcuts, wrapped, aux)
  }
  
  function buildDashboardWidget(div, node, widget) {
      div.style.overflow = "auto"
      div.style.background = "white"
      widget.setDashboardRecent = setDashboardRecent
      widget.setDashboardProjects = setDashboardProjects
      var myPane, recentPane, projectsPane, docs
      var bStyle =
       "solid 1px " + DarkBackground
      if (globs.wide) {
          var table = make(div, "table")
          var row = make(table, "tr")
          table.style.width = "1100px"
          table.style.maxWidth = "1100px"
          var myTd = make(row, "td")
          myTd.style.width = "300px"
          myTd.style.verticalAlign = "top"
          recentPane = make(row, "td")
          recentPane.style.width = "400px"
          recentPane.style.maxWidth = "400px"
          recentPane.style.verticalAlign = "top"
          projectsPane = make(row, "td")
          projectsPane.style.width = "400px"
          projectsPane.style.maxWidth = "400px"
          projectsPane.style.verticalAlign = "top"
          myPane = make(myTd, "div")
          docs = make(myTd, "div")
      } else {
          myPane = make(div, "div")
          docs = make(div, "div")
          recentPane = make(div, "div")
          projectsPane = make(div, "div")
          myPane.style.borderTop = bStyle
          recentPane.style.borderTop = bStyle
          projectsPane.style.borderTop = bStyle
      }
      myPane.style.padding = "20px"
      myPane.style.paddingTop = "10px"
      docs.style.padding = "20px"
      createButton(
      	myPane,
      	"MES_MY_PROJECT",
      	goToMyProject,
      	"coral"
      )
      createButton(
      	myPane,
      	"MES_SPACES",
      	goToSpaces,
      	DarkBackground
      )
      if (onPremises) {
          
      } else {
          createButton(
          	myPane,
          	"MES_BUY_SUBSCRIPTION",
          	goToPrices,
          	DarkBackground
          )
      }
      createLink(
      	myPane,
      	"MES_ACCOUNT",
      	"/account"
      )
      createLink(
      	myPane,
      	"MES_HOMEPAGE",
      	"/"
      )
      var host = "https://drakonhub.com"
      docs.style.borderTop = bStyle
      createLink(
      	docs,
      	"MES_DOCUMENTATION",
      	host + "/read/docs"
      )
      createLink(
      	docs,
      	"title-drakon",
      	host + "/drakon"
      )
      createLink(
      	docs,
      	"title-guidelines",
      	host + "/read/guidelines-for-drawing-drakon"
      )
      createLink(
      	docs,
      	"title-drakon-reference",
      	host + "/drakon-reference"
      )
      createLink(
      	docs,
      	"title-video-how-to-flowchart",
      	host + "/video-how-to-flowchart"
      )
      createLink(
      	docs,
      	"title-video-how-to-mind-map",
      	host + "/video-how-to-mind-map"
      )
      applyDashStyle(recentPane)
      createHeader(
      	recentPane,
      	"MES_RECENT"
      )
      widget.recent = make(
      	recentPane,
      	"div"
      )
      applyDashStyle(projectsPane)
      createHeader(
      	projectsPane,
      	"MES_SPACES"
      )
      widget.projects = make(
      	projectsPane,
      	"div"
      )
  }
  
  function buildImageWidget(parent, node, widget) {
      var img = make(parent, "img")
      widget.customWidth = node.width
      img.width = node.width
      img.height = node.height
      img.id = node.id + "_img"
      img.style.border = "solid 2px " + DarkBackground
  }
  
  function buildLogonGui() {
      var titleStyle = {
      	fontSize: "150%",
      	fontWeight: "bold",
      	textAlign: "center",
      	color: "#990000"
      }
      var title = {
      	type: "wlabel",
      	text: "MES_LOGIN",
      	style: titleStyle
      }
      var username = {
      	type: "edit",
      	editType: "text",
      	water: translate("MES_USERNAME"),
      	id: "username"
      }
      var password = {
      	type: "edit",
      	editType: "password",
      	water: translate("MES_PASSWORD"),
      	id: "password"
      }
      var forgot = {
      	type: "custom",
      	builder: makeRecoverLink
      }
      var status = {
      	type: "wlabel",
      	id: "status",
      	text: " "
      }
      var ok = {
      	signalId: "startLogon",
      	type: "wbutton",
      	text: "MES_LOGIN",
      	style:{background: "Coral", color: "white"}
      }
      var cancel = {
      	signalId: "cancelMachine",
      	type: "wbutton",
      	text: "MES_CANCEL",
      	style: {
      		color: "white",
      		background: DarkBackground,
      		padding: "12px",
      		textAlign: "center"
      	}
      }
      return {
      	type: "page",
      	padding: 10,
      	style: {background: "white"},
      	kids: [title, username, password, 
      		forgot, status, ok, cancel]
      }
  }
  
  function buildNormalCheckbox(parent, node) {
      var label = make(parent, "label")
      var text = translate(node.text)
      var value = node.value ? true : false
      var checkbox = make(label, "input")
      checkbox.type = "checkbox"
      checkbox.name = "checkbox"
      checkbox.id = node.id + "_check"
      checkbox.style.marginRight = "10px"
      checkbox.checked = value
      var tnode = document.createTextNode(text)
      label.appendChild(tnode)
      if (node.onchange) {
          checkbox.onchange = wrapException(
          	node.onchange, 
          	"normalCheckbox"
          )
      }
  }
  
  function buildSignupGui() {
      var titleStyle = {
      	fontSize: "150%",
      	fontWeight: "bold",
      	textAlign: "center",
      	color: "#990000"
      }
      var title = {
      	type: "wlabel",
      	text: "MES_SIGNUP",
      	style: titleStyle
      }
      var chars = {
      	type: "wlabel",
      	text: "MES_CHARACTERS"
      }
      var chars2 = {
      	type: "wlabel",
      	text: "MES_CHARACTERS2"
      }
      var shifted = {
      	transform: "translateY(5px)"
      }
      var userLab = {
      	type: "wlabel",
      	text: "MES_CREATE_USERNAME",
      	style: shifted
      }
      var emailLab = {
      	type: "wlabel",
      	text: "MES_EMAIL",
      	style: shifted
      }
      var chars3 = {
      	type: "wlabel",
      	text: "MES_CHARACTERS3",
      	style: {color:"grey", fontSize:"90%",
      	marginTop:"-6px"}
      }
      var username = {
      	type: "edit",
      	editType: "text",
      	id: "signup_user"
      }
      var email = {
      	type: "edit",
      	editType: "text",
      	id: "signup_email"
      }
      var password = {
      	type: "edit",
      	editType: "password",
      	water: translate("MES_PASSWORD"),
      	id: "signup_password"
      }
      var password2 = {
      	type: "edit",
      	editType: "password",
      	water: translate("MES_REPEAT_PASSWORD"),
      	id: "signup_password2"
      }
      var status = {
      	type: "wlabel",
      	id: "signup_status",
      	text: " "
      }
      var accept = {
      	type: "custom",
      	builder: makeAccept
      }
      var ok = {
      	signalId: "startSignup",
      	id: "signupOk",
      	type: "wbutton",
      	text: "MES_CREATE_FREE",
      	className: "disabled_button"
      }
      var cancel = {
      	signalId: "cancelMachine",
      	type: "wbutton",
      	text: "MES_CANCEL",
      	style: {
      		color: "white",
      		background: DarkBackground,
      		padding: "12px",
      		textAlign: "center"
      	}
      }
      var kids
      if (Config.EMAIL_SIGNUP) {
          kids = [title,
          	userLab, username, 
          	chars3, emailLab, email, status]
      } else {
          kids = [title,
          	userLab, username, chars3,
          	emailLab, email,
          	password, password2, status]
      }
      if (onPremises) {
          
      } else {
          kids.push(accept)
      }
      kids.push(ok)
      kids.push(cancel)
      return {
      	type: "page",
      	padding: 10,
      	style: {background: "white"},
      	kids: kids
      }
  }
  
  function buildUrlForFolder(spaceId, folderId) {
      var host = location.hostname
      return "https://" + host + "/ide/doc/" + 
        spaceId + "/" + folderId
  }
  
  function canDefQueryFrom(item) {
      var _sw36150000_ = 0;
      if (item.content) {
          _sw36150000_ = item.type;
          if ((((_sw36150000_ === "beginend") || (_sw36150000_ === "end")) || (_sw36150000_ === "branch")) || (_sw36150000_ === "address")) {
              return false
          } else {
              return true
          }
      } else {
          return false
      }
  }
  
  function cancelMachine() {
      var count = globs.centralMachines.length
      if (count == 0) {
          hideCentral()
      } else {
          var machine = globs.centralMachines[count - 1]
          machine.cancel()
      }
  }
  
  function cancelSearch() {
      var search = findSearch()
      if (search) {
          search.clear()
      }
      globs.search.defs = null
      globs.search.widgetId = null
      globs.search.popup = null
      globs.search.groups = {}
      HtmlUtils.hideSoftPopup()
      HtmlUtils.unfocus()
  }
  
  function changeId(node, id) {
      var copy = Utils.copyObject(node)
      copy.id = id
      return copy
  }
  
  function chooseFile() {
      get("file-input").click()
  }
  
  function clearClipboard() {
      setLsItem("clipboard type", "");
      setLsItem("clipboard", "");
  }
  
  function clearMachines() {
      var _ind2776 = 0;
      var _col2776 = globs.centralMachines;
      var _len2776 = _col2776.length;
      while (true) {
          if (_ind2776 < _len2776) {
              
          } else {
              break;
          }
          var machine = _col2776[_ind2776];
          machine.state = null
          _ind2776++;
      }
      globs.centralMachines = []
  }
  
  function clearTimeout(timerId) {
      window.clearTimeout(timerId)
  }
  
  function confirmExit() {
      return translate("MES_SURE_EXIT")
  }
  
  function copyToClipboard(type, subgraph) {
      var text = JSON.stringify(subgraph);
      setLsItem("clipboard type", type);
      setLsItem("clipboard", text);
      scheduleClipboardClear()
  }
  
  function createButton(parent, textId, action, color) {
      var div = make(parent, "div")
      var text = translate(textId)
      HtmlUtils.setDivText(div, text)
      div.onclick = wrapException(
      	action,
      	"buttonClick"
      )
      div.className = "common_button"
      div.style.color = "white"
      div.style.background = color
      div.style.marginTop = "10px"
      div.style.marginBottom = "20px"
      div.style.padding = "10px"
      div.style.borderRadius = "8px"
      div.style.textAlign = "center"
  }
  
  function createCentral(node, centralMachine) {
      clearMachines()
      createCentralCore(
      	node,
      	centralMachine
      )
  }
  
  function createCentralBack() {
      var central = get("central")
      var back = make(central, "div")
      var style = back.style
      style.display = "inline-block"
      style.position = "absolute"
      style.zIndex = 25
      style.left = "0px"
      style.top = "0px"
      style.right = "0px"
      style.bottom = "0px"
      style.background = "black"
      style.opacity = 0.3
      back.onclick = wrapException(
      	killCentral,
      	"killCentral"
      )
      back.oncontextmenu = function() { return false }
  }
  
  function createCentralCore(node, centralMachine) {
      if (globs.central) {
          
      } else {
          pushTempIfMobile()
      }
      if (centralMachine) {
          globs.centralMachines.push(centralMachine)
      }
      hideCentralCore()
      createCentralBack()
      var central = get("central")
      showDiv(central, "block")
      var id = globs.widgets.createWidget(
      	central,
      	node
      )
      var widget = getWidget(id)
      var div = get(id)
      div.style.background = "white"
      div.style.zIndex = 26
      div.style.overflow = "hidden"
      globs.central = id
      resizeCentral()
  }
  
  function createCloseBanner() {
      if (Config.dead) {
          var banner = make(document.body, "div")
          banner.style.display = "inline-block"
          banner.style.position = "fixed"
          banner.style.left = "10px"
          banner.style.bottom = "10px"
          banner.style.padding = "10px"
          banner.style.fontSize = "30px"
          banner.style.zIndex = 1000
          banner.style.cursor = "pointer"
          banner.style.background = "black"
          banner.style.color = "red"
          banner.style.border = "solid 2px red"
          var text = translate("MES_DRAKONHUB_CLOSED")
          HtmlUtils.setDivText(banner, text)
          banner.onclick = function() {
          	goToUrl("/static/dead.html")
          }
      }
  }
  
  function createEditor() {
      var editor = new EditorCtrl(window, document, "middle_diagram", gUserId)
      var inputBox = {
      	show: function(title, text, onSave, validate, x, y) {
      		showInputBox(
      			false,
      			title,
      			text,
      			onSave,
      			validate,
      			false, x, y
      		)
      	}
      }
      var cfg = {
      	imageBase: ImagePath,
      	translate: translate,
      	tooltip: globs.widgets.getToolTip(),
      	inputBox: inputBox,
      	context: showContextMenu,
      	storage: new Storage(),
      	status: wrapException(saveStatus, "saveStatus"),
      	warning: showNotification,
      	panic: panic,
      	saveUserSettings: wrapException(
      		saveUserSettings,
      		"saveUserSettings"
      	),
      	clipboard: new Clipboard(),
      	loadFont: loadFont,
      	findReferences: findReferences,
      	openSub: self.logic.openSub
      }
      editor.init(cfg)
      globs.editor = editor
      getWidget("middle_diagram").setRect = resizeEditor
  }
  
  function createFeedbackButton() {
      if ((globs.wide) && (!(globs.tryMe))) {
          var rootDiv = get("wide")
          var button = document.createElement("div")
          HtmlUtils.insertAfter(button, rootDiv)
          button.id = "feedback"
          HtmlUtils.setDivText(
          	button,
          	translate("MES_SEND_FEEDBACK")
          )
          setButtonStyle(
          	button,
          	"black",
          	"coral",
          	"3px"
          )
          button.style.position = "absolute"
          button.style.right = "50px"
          button.style.bottom = "2px"
          button.style.zIndex = 20
          button.onclick = sendFeedback
      }
  }
  
  function createHeader(parent, textId) {
      var div = make(parent, "div")
      var text = translate(textId)
      HtmlUtils.setDivText(div, text)
      div.style.color = DarkBackground
      div.style.marginBottom = "20px"
      div.style.marginTop = "5px"
  }
  
  function createIconListRow(table, icon, action) {
      var tr = make(table, "tr")
      tr.className = "list_item"
      var iconTd = make(tr, "td")
      var td = make(tr, "td")
      var size = 30
      var path = makeImagePath(icon)
      var img = make(iconTd, "img")
      img.width = size
      img.height = size
      img.src = path
      if (action) {
          tr.onclick = wrapException(
          	action,
          	"listClick"
          )
      }
      return td
  }
  
  function createLink(parent, textId, url) {
      var div = make(parent, "div")
      var link = make(div, "a")
      var text = translate(textId)
      HtmlUtils.setDivText(link, text)
      link.href = url
      div.style.marginBottom = "20px"
  }
  
  function createPopup() {
      return HtmlUtils.createPopup(null)
  }
  
  function createPopupList(items) {
      var div = createPopup()
      div.className = "popup"
      div.style.background = "white"
      var _ind1691 = 0;
      var _col1691 = items;
      var _len1691 = _col1691.length;
      while (true) {
          if (_ind1691 < _len1691) {
              
          } else {
              break;
          }
          var item = _col1691[_ind1691];
          addPopupItem(div, item)
          _ind1691++;
      }
      return div
  }
  
  function createSearchList(defs, found) {
      globs.search = {}
      var search = findSearch()
      globs.search.defs = Utils.copyObjectDeep(
      	defs
      )
      globs.search.widgetId = search.id
      globs.search.expanded = null
      createSearchPopup()
      addToSearchList(found)
  }
  
  function createSearchPopup() {
      var width = 400
      var popup = HtmlUtils.getSoftPopup()
      if (popup) {
          HtmlUtils.hideSoftPopup()
      }
      var searchWidget = getWidget(
      	globs.search.widgetId
      )
      var tellLogic = function() {
      	self.logic.resetSearch()
      }
      popup = HtmlUtils.createSoftPopup(
      	searchWidget.rect,
      	tellLogic
      )
      popup.style.background = "white"
      popup.style.maxWidth = width + "px"
      popup.style.width = width + "px"
      popup.className = "popup"
      var top = searchWidget.rect.top +
      	searchWidget.rect.height
      var start = top + 50
      popup.style.top = top + "px"
      popup.style.right= "0px"
      var closeStyle = {
      	background:"coral"
      }
      addClickable(
      	popup,
      	translate("MES_CLOSE"),
      	cancelSearch,
      	closeStyle
      )
      var popupList = make(popup, "div")
      popupList.style.maxHeight = 
      	"calc(100vh - " + start + "px)"
      popupList.style.overflowY = "auto"
      popup.style.display = "inline-block"
      popup.style.position = "fixed"
      globs.search.popup = popupList
      addEmpty(
      	translate("MES_SEARCHING")
      )
  }
  
  function createState() {
      var state = {
      	tt: new ToolTip(window, document),
      	pop: new Popup(window, document),
      	logon: new Logon(window, document, translate),
      	widgets: new DraWidgets(window, document, translate, 1, ImagePath),
      	loadedFonts: {},
      	clip: {},
      	myHandlers: {},
      	centralMachines: [],
      	search: {},
      	initCompleted: false,
      	demo: {}
      }
      state.myHandlers.createDrakon = function() {
      	sendToCentralMachine("drakon")
      }
      state.myHandlers.createFree = function() {
      	sendToCentralMachine("free")
      }
      state.myHandlers.createMind = function() {
      	sendToCentralMachine("mind")
      }
      state.myHandlers.sendToCentralMachine = function() {
      	sendToCentralMachine()
      }
      state.myHandlers.accessForShare = function() {
      	getMachine().access()
      }
      state.myHandlers.login = function(data) {
      	getMachine().login(data)
      }
      state.myHandlers.signup = function(data) {
      	getMachine().signup(data)
      }
      state.myHandlers.removeLimit = removeLimit
      state.myHandlers.sendFeedback = sendFeedback
      state.myHandlers.showHelp = showHelp
      state.myHandlers.hideHelp = hideHelp
      state.myHandlers.hideCentral = hideCentral
      state.myHandlers.cancelMachine = cancelMachine
      state.myHandlers.startLogon = startLogon
      state.myHandlers.startSignup = startSignup
      state.myHandlers.saveMobileInput = saveMobileInput
      state.myHandlers.saveProject = saveAccess
      state.myHandlers.chooseFile = chooseFile
      state.myHandlers.loadFile = loadFile
      state.myHandlers.addWriter = addWriter
      state.myHandlers.addAdmin = addAdmin
      state.myHandlers.addReader = addReader
      state.myHandlers.searchUsers = searchUsers
      state.myHandlers.removeAdmin = removeAdmin
      state.myHandlers.removeReader = removeReader
      state.myHandlers.removeWriter = removeWriter
      state.myHandlers.foundUser = foundUser
      state.myHandlers.saveAccess = saveAccess
      state.myHandlers.hideDemo = hideDemo
      state.widgets.wrapException = wrapException
      return state
  }
  
  function createUserList(id, userSet) {
      var node = {
      	id: id,
      	type: "list_grid",
      	noScroll: true,
      	columns: [
      		{type:"image", width:"36px", clickable:true},
      		{type:"text", width:"100%"}
      	],
      	rows: []
      }
      var users = Object.keys(userSet)
      users.sort()
      var _ind1873 = 0;
      var _col1873 = users;
      var _len1873 = _col1873.length;
      while (true) {
          if (_ind1873 < _len1873) {
              
          } else {
              break;
          }
          var user = _col1873[_ind1873];
          addIconText(
          	node.rows,
          	"delete.png",
          	user
          )
          _ind1873++;
      }
      return node
  }
  
  function destroyDemoWindow() {
      var id = globs.demo.widgetId
      if (id) {
          self.widgets.deleteWidget(id)
          globs.demo.widgetId = null
      }
      var root = get("demo")
      root.innerHTML = ""
      root.style.display = "none"
  }
  
  function disableSignupOk() {
      var button = get("signupOk")
      button.className = "disabled_button"
  }
  
  function display(id, value) {
      var element = get(id)
      element.style.display = value
  }
  
  function doSendFeedback(text) {
      CallTrace.add("doSendFeedback", [text])
      var success = function() {
      	hideWorking()
      	hideInputBox()
      	showNotification("MES_MESSAGE_SENT")
      }
      var error = function() {
      	hideWorking()
      	setInputBoxError(translate("MES_MESSAGE_NOT_SENT"))
      }
      var data = {
      	type: "feedback",
      	message: text
      }
      showWorking()
      sendFeedbackCore(
      	data,
      	success,
      	error
      )
  }
  
  function downloadFile(url, filename) {
      console.log("downloadFile", url, filename)
      var link = document.createElement("a")
      link.href = url
      link.download = filename
      link.click()
  }
  
  function enableSignupOk() {
      var button = get("signupOk")
      button.className = "default_button"
  }
  
  function endPan() {
      getEditor().endPan()
      globs.panning = false
  }
  
  function enforceNotEmpty(name) {
      name = name || ""
      name = name.trim()
      if (name) {
          return null
      } else {
          return translate("ERR_EMPTY_TEXT")
      }
  }
  
  function exportMethod(self, method, name) {
      self[name] = wrapException(method, name)
  }
  
  function findReferences(name) {
      self.logic.findReferences(name)
  }
  
  function findSearch() {
      var top = getWidget("top")
      var topPanel = top.active
      if (topPanel) {
          var isSearch = function(widget) {
          	return widget.type == "search"
          }
          return findWidgetInTree(
          	topPanel,
          	isSearch
          )
      } else {
          return null
      }
  }
  
  function findSearchGroup(groupId) {
      var defs = globs.search.defs
      var _ind3384 = 0;
      var _col3384 = defs;
      var _len3384 = _col3384.length;
      while (true) {
          if (_ind3384 < _len3384) {
              
          } else {
              throw Error("Group '" + groupId + "' not found")
          }
          var group = _col3384[_ind3384];
          if (group.id == groupId) {
              return group
          }
          _ind3384++;
      }
  }
  
  function findWidgetInTree(root, criterion) {
      if (criterion(root)) {
          return root
      } else {
          if (root.kids) {
              var _ind3432 = 0;
              var _col3432 = root.kids;
              var _len3432 = _col3432.length;
              while (true) {
                  if (_ind3432 < _len3432) {
                      
                  } else {
                      return null
                  }
                  var kid = _col3432[_ind3432];
                  if (findWidgetInTree(kid, criterion)) {
                      return kid
                  }
                  _ind3432++;
              }
          } else {
              return null
          }
      }
  }
  
  function focusSearch(evt) {
      if (((((HtmlUtils.hasPopup()) || (HtmlUtils.hasSoftPopup())) || (isCentralVisible())) || (!(globs.wide))) || (globs.helpOn)) {
          
      } else {
          var search = findSearch()
          if (search) {
              search.focus()
          }
      }
      HtmlUtils.preventDefaultHandling(evt)
  }
  
  function foundUser(evt, type, widget, rowId, cellId) {
      getMachine().choose(rowId)
  }
  
  function get(id) {
      var element = document.getElementById(id)
      if (element) {
          return element
      } else {
          throw Error("Element '" + id + "' not found")
      }
  }
  
  function getClipboard() {
      var text = getLsItem("clipboard");
      var obj = JSON.parse(text);
      return obj;
  }
  
  function getClipboardType() {
      return getLsItem("clipboard type");
  }
  
  function getDateString() {
      var date = new Date()
      var yyyy = String(date.getFullYear())
      var mm = String(date.getMonth() + 1)
      var dd = String(date.getDate())
      var hh = String(date.getHours())
      var m = String(date.getMinutes())
      var s = String(date.getSeconds())
      return pad1(yyyy) + pad1(mm) + pad1(dd)
       + pad1(hh) + pad1(m) + pad1(s)
  }
  
  function getDrakosha() {
      return "/static/drakosha132.png"
  }
  
  function getEditor() {
      return globs.editor
  }
  
  function getExample() {
      var search = Utils.parseSearch(window.location.search)
      var example = search.example || "example01"
      return "/static/" + example + ".json"
  }
  
  function getHeight() {
      return window.innerHeight
  }
  
  function getItemLines(content) {
      var txt = content.txt || ""
      var txt2 = content.txt2 || ""
      var lines1 = txt.split("\n")
      var lines2 = txt2.split("\n")
      var allLines = lines1.concat(lines2)
      var isNotEmpty = function(text) {
      	return text.trim() != ""
      }
      return allLines.filter(isNotEmpty)
  }
  
  function getItemUrls(content) {
      var txt = content.txt || ""
      var txt2 = content.txt2 || ""
      var urls = Utils.extractUrls(txt)
      var urls2 = Utils.extractUrls(txt2)
      var all = urls.concat(urls2)
      return all
  }
  
  function getLeftSplitterWidth() {
      return 200
  }
  
  function getLsItem(key) {
      var result
      try {
      	result = window.localStorage.getItem(key)
      } catch (e) {
      	result = globs.clip[key]
      }
      DTools.print(result)
      return result
  }
  
  function getMachine() {
      var count = globs.centralMachines.length
      var machine = globs.centralMachines[count - 1]
      return machine
  }
  
  function getMyUrl() {
      return window.location.href
  }
  
  function getOrCreateExpanded(group) {
      if (globs.search.expandedList) {
          return globs.search.expandedList
      } else {
          var popup = globs.search.popup
          var caption = translate("MES_SHOW_ALL_RESULTS")
          var toAllResults = function() {
          	toSearchResults(null)
          }
          addClickable(
          	popup,
          	caption,
          	toAllResults
          )
          var listDiv = make(popup, "div")
          globs.search.expandedList = listDiv
          return listDiv
      }
  }
  
  function getOrCreateGroupList(group) {
      var groups = globs.search.groupLists
      if (groups) {
          
      } else {
          groups = {}
          globs.search.groupLists = groups
      }
      if (group.id in groups) {
          
      } else {
          var popup = globs.search.popup
          var caption = translate("MES_SHOW_MORE") +
           ": " + group.name
          var toGroup = function() {
          	toSearchResults(group.id)
          }
          var groupDiv = make(popup, "div")
          var listDiv = make(groupDiv, "div")
          addClickable(
          	groupDiv,
          	caption,
          	toGroup
          )
          groups[group.id] = {div:listDiv, count:0}
      }
      return groups[group.id]
  }
  
  function getPath() {
      return window.location.pathname.toLowerCase()
  }
  
  function getRightSplitterWidth() {
      return 200
  }
  
  function getTextMenu() {
      return "/static/logo-text-s-hub.png"
  }
  
  function getTotalFound() {
      var defs = globs.search.defs
      var count = 0
      var _ind4326 = 0;
      var _col4326 = defs;
      var _len4326 = _col4326.length;
      while (true) {
          if (_ind4326 < _len4326) {
              
          } else {
              break;
          }
          var group = _col4326[_ind4326];
          count += group.items.length
          _ind4326++;
      }
      return count
  }
  
  function getUrl() {
      return window.location.href.toLowerCase()
  }
  
  function getWidget(id) {
      return globs.widgets.getWidget(id)
  }
  
  function getWidth() {
      return window.innerWidth
  }
  
  function goToMyProject() {
      var id = gUserId + " 1"
      self.logic.goToFolder(id)
  }
  
  function goToPrices() {
      goToUrl("/drakonhub-source?ref=dashboard")
  }
  
  function goToSpaces() {
      self.logic.goToProjectsNoArg()
  }
  
  function goToUrl(url) {
      window.location.href = url
  }
  
  function handleBasicStatusChange(machine, request) {
      if (request.readyState === 4) {
          var result = {
              responseText: request.responseText,
              status: request.status
          }
          machine.onData(result)
      }
  }
  
  function hideCentral() {
      if (globs.centralMachines.length == 0) {
          
      } else {
          globs.centralMachines.pop()
      }
      hideCentralCore()
  }
  
  function hideCentralCore() {
      var id = globs.central
      if (id) {
          globs.central = null
          self.widgets.deleteWidget(id)
          var central = get("central")
          central.innerHTML = ""
          hideDiv(central)
          globs.mobileInput = false
          globs.mobileSubmit = false
          globs.search = {}
      }
  }
  
  function hideDemo() {
      var check = document.getElementById("demoShowOnStart_check")
      if (check) {
          if (check.checked) {
              HtmlUtils.deleteCookie(
              	"demo-discarded"
              )
          } else {
              HtmlUtils.setCookie(
              	"demo-discarded",
              	"discarded",
              	20
              )
          }
          destroyDemoWindow()
      }
  }
  
  function hideDiv(div) {
      div.style.display = "none"
  }
  
  function hideHelp() {
      show("help_wide", "none")
      show("help_narrow", "none")
      globs.helpOn = false
  }
  
  function hideInputBox() {
      if (globs.wide) {
          InputBox.hide()
      } else {
          hideCentral()
      }
  }
  
  function hidePopup() {
      HtmlUtils.hidePopup()
  }
  
  function hideWorking() {
      display("working", "none")
  }
  
  function init() {
      globs.widgets.onEvent = onEvent
      self.logic.init()
      registerShortcuts()
      Nav.stateCallback = self.logic.onStateChange
      if (globs.isTryMe) {
          //window.onbeforeunload = confirmExit
          window.onbeforeunload = null
      }
      createCloseBanner()
  }
  
  function initControls(wide, isTryMe) {
      globs.wide = wide
      globs.isTryMe = isTryMe
      var tops
      var topHeight = TopPanelHeight
      if (globs.wide) {
          tops = makeTopWidgetsDesc()
      } else {
          tops = makeTopWidgetsDescMob()
      }
      var folders = makeFolderListDesc()
      folders.id = "middle_folder"
      var diagram = makeDiagramDesc()
      diagram.id = "middle_diagram"
      var trash = makeRubbishListDesc()
      trash.id = "middle_trash"
      var dashboard = makeDashboardDesc()
      dashboard.id = "middle_dashboard"
      var spacesGrid = {
      	id: "middle_spaces",
      	type: "list_grid",
      	columns: [
      		{type:"image", width:"36px", clickable:false},
      		{type:"text", width:"100%"},
      		{type:"image", width:"36px", clickable:true}
      	]
      }
      var mrecentGrid = {
      	id: "middle_recent",
      	type: "list_grid",
      	columns: [
      		{type:"image", width:"36px", clickable:false},
      		{type:"text", width:"100%"}
      	]
      }
      var middles = [folders, diagram, spacesGrid,
         trash, mrecentGrid, dashboard]
      var rootNode = {
      	type: "vdock",
      	id: "root",
      	top: {
      		id: "top",
      		type: "many",
      		height: topHeight,
      		kids: tops
      	},
      	center: {
      		"id": "splitter",
      		type: "splitter",
      		left: getLeftSplitterWidth(),
      		right: getRightSplitterWidth(),
      		leftChild: {
      			type: "pane",
      			id: "left_pane",
      			text: "MES_SPACES",
      			kid: {
      				type: "tree",
      				id: "tree"
      			}
      		},
      		middleChild:{
      			id: "middle",
      			type: "many",
      			kids: middles
      		},
      		rightChild: {
      			type: "pane",
      			id: "right_pane",
      			text: "MES_RECENT",
      			kid: {
      				type: "list",
      				id: "recent"
      			}
      		}
      	}
      }
      var rootDiv = get("wide")
      globs.root = globs.widgets.createWidget(
      	rootDiv,
      	rootNode
      )
      createFeedbackButton()
      createEditor()
      getWidget("top").setActive("top_diagram")
      getWidget("middle").setActive("middle_folder")
      //registerShortcuts()
  }
  
  function isCentralVisible() {
      return !!globs.central
  }
  
  function isDemoDiscarded() {
      var discarded = HtmlUtils.getCookie(
      	"demo-discarded"
      )
      return !!discarded
  }
  
  function isDrakon() {
      var current = self.logic.getCurrent()
      return (current.type == "drakon")
  }
  
  function isEditorOn() {
      var current = self.logic.getCurrent()
      if (((current.screen == "middle_diagram") && (!(HtmlUtils.hasPopup()))) && (!(isCentralVisible()))) {
          var editor = getEditor()
          if (editor.isDragOn()) {
              return false
          } else {
              return true
          }
      } else {
          return false
      }
  }
  
  function isMind() {
      var current = self.logic.getCurrent()
      return (current.type == "mind")
  }
  
  function isReadonly() {
      var current = self.logic.getCurrent()
      if ((current.screen == "middle_diagram") && (!(current.isReadonly))) {
          return false
      } else {
          return true
      }
  }
  
  function killCentral() {
      clearMachines()
      hideCentralCore()
  }
  
  function loadFile() {
      var input = get("file-input")
      var path = input.files[0]
      if (path) {
          sendToCentralMachine(path)
      } else {
          HtmlUtils.setText(
          	"file-error",
          	translate("MES_NO_FILE_CHOSEN")
          )
      }
  }
  
  function loadFont(italic, bold, family, file, onLoaded) {
      try {
      var spec = {
      	italic: italic,
      	bold: bold,
      	family: family,
      	file: file
      }
      var target = {
      	onData: function() {
      		hideWorking()
      		onLoaded()
      	},
      	onError: function(e) {
      		panicOnFont(e, spec)
      	}
      }
      showWorking()
      loadFontCore(
      	spec,
      	target
      )
      
      } catch (e) {
      	CallTrace.error(e)
      	panic(e)
      }
  }
  
  function loadFontCore(font, target) {
      var file = font.file
      if (file in globs.loadedFonts) {
          console.log(
          	"Font already loaded ",
          	file
          )
          scheduleNextState(
          	target,
          	null
          )
      } else {
          var onSuccess = function() {
          	try {
          		onFontLoaded(file, target, font)
          	} catch (e) {
          		panicOnFont(e, font)
          	}
          }
          var onError = function() {
          	onFontNotLoaded(file, target)
          }
          var ruleText = makeFontFaceRule(
          	font.italic,
          	font.bold,
          	font.family,
          	file
          )
          addStyle(ruleText)
          var fontSpec = makeFontSpec2(
          	font.italic,
          	font.bold
          )
          var font2 = new FontFaceObserver(
          	font.family,
          	fontSpec
          )
          var timeout = Config.FONT_TIMEOUT * 1000
          font2.load(null, timeout).then(
          	onSuccess,
          	onError
          )
      }
  }
  
  function logout() {
      globs.logon.logout()
  }
  
  function make(parent, tag) {
      var element = document.createElement(tag)
      parent.appendChild(element)
      //element.ontouchstart = prevent
      //element.ontouchmove = prevent
      //element.ontouchend = prevent
      return element
  }
  
  function makeAccept(div) {
      var table = make(div, "table")
      var tr = make(table, "tr")
      var td1 = make(tr, "td")
      var td2 = make(tr, "td")
      table.style.marginTop = "10px"
      table.style.marginBottom = "10px"
      td2.style.paddingLeft = "10px"
      var check = make(td1, "input")
      check.type = "checkbox"
      //check.onchange = updateSignupButton
      var span = make(td2, "div")
      span.innerHTML = translate("MES_I_AGREE")
      span.style.marginLeft = "10px"
      span.style.display = "inline-block"
      check.id = "signup_agree"
  }
  
  function makeAccessSubheader(header, actionId) {
      var headerStyle = {
      	color: DarkBackground,
      	fontWeight: "bold"
      }
      var header = {
      	type: "label",
      	text: header,
      	style: headerStyle
      }
      var add = {
      	type: "text_button",
      	text: "MES_ADD",
      	signalId: actionId,
      	style: {
      		background: DarkBackground,
      		color: "white",
      		padding: "8px",
      		textAlign: "center",
      		borderRadius: "5px"
      	}
      }
      var stack = {
      	type: "hdock",
      	height: 31,
      	lefts: [header],
      	rights: [add]
      }
      return stack
  }
  
  function makeBigPictureButton(div, node, widget) {
      div.className = "big_picture_button"
      div.style.padding = "5px"
      div.style.borderWidth = "2px"
      var table = make(div, "table")
      var tr = make(table, tr)
      var left = make(tr, "td")
      var right = make(tr, "td")
      right.style.height = "100px"
      var img = make(left, "img")
      img.draggable = false
      img.src = ImagePath + node.image
      img.style.width = "80px"
      var label = make(right, "div")
      label.style.fontSize = "110%"
      label.style.fontWeight = "bold"
      label.style.margin = "5px"
      HtmlUtils.setDivText(label, translate(node.text))
      var desc = make(right, "p")
      desc.style.textAlign = "center"
      desc.style.color = DarkBackground
      desc.style.fontSize = "90%"
      desc.style.margin = "5px"
      HtmlUtils.setDivText(desc, translate(node.desc))
      registerEvent(
      	div,
      	widget,
      	"click"
      )
  }
  
  function makeDashboardDesc() {
      return {
      	type: "custom",
      	builder: buildDashboardWidget
      }
  }
  
  function makeDemoButtons(items) {
      var result = []
      globs.demo.buttons = {}
      var i = 1
      var _ind4137 = 0;
      var _col4137 = items;
      var _len4137 = _col4137.length;
      while (true) {
          if (_ind4137 < _len4137) {
              
          } else {
              break;
          }
          var item = _col4137[_ind4137];
          var id = "demoButton_" + i
          var image = item[1]
          var text = item[0]
          result.push({
          	id: id,
          	type: "wbutton",
          	text: text,
          	style: {
          		background: DarkBackground,
          		color: "white",
          		fontSize:"80%"
          	}
          })
          globs.demo.buttons[id] = {
          	image: image
          }
          globs.myHandlers[id] = onDemoButton
          i++
          _ind4137++;
      }
      return result
  }
  
  function makeDemoListDrakon() {
      var result = [
      	["MES_INSERT_ICONS", "demo_drakon_insert.gif"],
      	["MES_RELOCATE", "demo_drakon_join.gif"],
      	["MES_APPLY_THEME", "demo_drakon_theme.gif"],
      	["MES_FORMAT_ICON", "demo_drakon_format.gif"]
      ]
      return result
  }
  
  function makeDemoListMind() {
      var result = [
      	["MES_BUILD_LADDER", "demo_graf_vertical.gif"],
      	["MES_BUILD_MIXED", "demo_graf_horizontal.gif"],
      	["MES_APPLY_THEME", "demo_drakon_theme.gif"],
      	["MES_FORMAT_ICON", "demo_drakon_format.gif"]
      ]
      return result
  }
  
  function makeDiagramDesc() {
      return {
      	type: "dummy"
      }
  }
  
  function makeErrorMessage(data) {
      var message = Utils.makeErrorMessage(data)
      return translate(message)
  }
  
  function makeFolderListDesc() {
      var margin = 6
      var searchHeight = SearchHeight
      var height = margin * 2
       + searchHeight
      var search = {
      	id: "folderSearch",
      	vPadding: margin,
      	hPadding: margin,
      	type: "search",
      	height: searchHeight,
      	width: 150
      }
      var check = {
      	id: "check_all",
      	hPadding:4,
      	vPadding:5,
      	type: "check",
      	width: 30,
      	height: 30
      }
      
      var actions = {
      	id: "actions",
      	vPadding: 6,
      	hPadding: 8,
      	type: "text_button",
      	text:"MES_ACTIONS",
      	style: {
      		color: "white",
      		background: DarkBackground,
      		padding: "6px",
      		borderRadius: BorderRadius
      	}
      }
      var rights = []
      rights.push(search)
      var topStack = {
      	type: "hdock",
      	height: height,
      	lefts: [check, actions],
      	rights: rights,
      	style: {background: DockHeaderColor}
      }
      var grid = {
      	id: "folder_grid",
      	type: "list_grid",
      	columns: [
      		{type:"image", width:"36px", clickable:true},
      		{type:"text", width:"100%"}
      	]
      }
      var page = {
      	type: "vdock",
      	top: topStack,
      	center: grid
      }
      return page
  }
  
  function makeFontFaceRule(italic, bold, family, file) {
      var text = "@font-face {\n"
      text += "    font-family: '" + family + "';\n"
      text += "    src: url('/static/fonts/" + file + "');\n"
      if (italic) {
          text += "    font-style: italic;\n"
      }
      if (bold) {
          text += "    font-weight: bold;\n"
      }
      text += "}"
      return text
  }
  
  function makeFontSpec2(italic, bold) {
      var result = {
      }
      var style = ""
      if (italic) {
          result.style = "italic"
      }
      if (bold) {
          result.weight = "bold"
      }
      return result
  }
  
  function makeGoOutside(url) {
      return function() {
      	window.open(url)
      }
  }
  
  function makeGotoText(name) {
      var text = "> " + Utils.truncateText(name, 40)
      return text
  }
  
  function makeIB(parent) {
      var div = make(parent, "div")
      div.style.display = "inline-block"
      return div
  }
  
  function makeImagePath(image) {
      return ImagePath + image
  }
  
  function makeNavFolder(spaceId, folderId) {
      var id = spaceId + " " + folderId
      var go = function() {
      	self.logic.goToFolder(id)
      }
      return go
  }
  
  function makePngName() {
      var s1 = getEditor().getName()
      var sanitized = s1.replace(/,| |:|\\|\/|\r|\n|\t/g, "-");
      if (sanitized) {
          
      } else {
          sanitized = "diagram"
      }
      return sanitized + ".png";
  }
  
  function makeRecoverLink(div) {
      var a = make(div, "a")
      a.href = "/reset"
      HtmlUtils.setDivText(
      	a,
      	translate("MES_FORGOT_PASSWORD")
      )
  }
  
  function makeRubbishListDesc() {
      var margin = 4
      var searchHeight = 30
      var height = margin * 2 + searchHeight
      
      var upButton = {
      	vPadding: margin,
      	hPadding: margin,
      	signalId: "goToProjects",
      	type: "text_button",
      	text:"MES_TO_SPACES",
      	style: {
      		color: "white",
      		background: DarkBackground,
      		borderRadius: BorderRadius,
      		padding: "6px"
      	}
      }
      
      var clearButton = {
      	vPadding: margin,
      	hPadding: margin,
      	signalId: "clearTrash",
      	type: "text_button",
      	text:"MES_CLEAR_TRASH",
      	style: {
      		color: "white",
      		background: "#c00000",
      		borderRadius: BorderRadius,
      		padding: "6px"
      	}
      }
      var topStack = {
      	type: "hdock",
      	height: height,
      	lefts: [upButton],
      	rights: [clearButton],
      	style: {background: DockHeaderColor}
      }
      var grid = {
      	id: "trash_grid",
      	type: "list_grid",
      	columns: [
      		{type:"image", width:"36px", clickable:false},
      		{type:"text", width:"100%"},
      		{type:"button"}
      	]
      }
      var page = {
      	type: "vdock",
      	top: topStack,
      	center: grid
      }
      return page
  }
  
  function makeSearchCallback(item) {
      var type = item.type
      var target = item.target
      var action = function() {
      	hidePopup()
      	hideCentral()
      	hideHelp()
      	hideDemo()
      	self.logic.onSearchItem(
      		type,
      		target
      	)
      }
      return wrapException(
      	action,
      	"searchItem:" + type + ":" + target
      )
  }
  
  function makeSeparator(list) {
      var item = {
      	type: "separator"
      }
      list.push(item)
  }
  
  function makeSpan(div, text) {
      var span = make(div, "span")
      HtmlUtils.setDivText(span, text)
      return span
  }
  
  function makeTextArea(parent) {
      var editor = make(parent, "textarea")
      editor.style.fontSize = "12pt"
      editor.style.fontFamily = Config.FONT_FAMILY
      editor.style.boxSizing = "border-box"
      editor.style.resize = "none"
      editor.style.outline = "none"
      editor.style.width = "100%"
      editor.style.padding = "10px"
      editor.style.border = "none"
      editor.style.height = "60px"
      editor.style.margin = "0px"
      editor.style.border = "solid 1px #707070"
      editor.style.verticalAlign = "top"
      editor.className = "mousetrap"
      return editor
  }
  
  function makeTextListItem(list, textId, action, id, image) {
      var item = {
      	text: translate(textId),
      	code: action,
      	id: id,
      	image: image
      }
      list.push(item)
  }
  
  function makeTopWidgetsDesc() {
      var buttonMargin = 6
      var buttonMargin2 = 10
      var createFont = "80%"
      var createPadding = "30px"
      var radius = "5px"
      var createStyle = {
      	fontSize: createFont,
      	padding: "12px",
      	width: "100px",
      	textAlign: "center",
      	paddingLeft: "0px",
      	paddingRight: "0px",
      	borderRadius: BorderRadius,
      	color: DarkBackground,
      	background: "white"
      }
      var mainMenu = {
      	signalId: "showMainMenu",
      	type: "image_button",
      	image:"drakosha-menu-104.png",
      	width:80,
      	height:52,
      	tooltip: "MES_MENU"
      }
      var create = {
      	signalId : "create_diagram",
      	hPadding:8, vPadding:8,
      	type: "text_button",
      	text:"new_diagram",
      	tooltip: "MES_CREATE_DIAGRAM",
      	style: {
      		color: "white",
      		background: "coral",
      		fontSize: createFont,
      		padding: "12px",
      		paddingLeft: "0px",
      		paddingRight: "0px",
      		textAlign: "center",
      		borderRadius: BorderRadius
      	},
      	customWidth: 100
      }
      var share = {
      	hPadding:1, vPadding:buttonMargin,
      	signalId: "share",
      	type: "image_button",
      	image:"share.png",
      	width:40,
      	height:40,
      	tooltip: "MES_SHARE",
      	style: {
      		background: "white",
      		borderRadius: radius
      	}
      }
      var undoButton = {
      	signalId: "undo",
      	hPadding:buttonMargin, vPadding:buttonMargin,
      	type: "image_button",
      	image:"undo.png",
      	width:40,
      	height:40,
      	style:{borderRadius:radius},
      	tooltip: "MES_UNDO"
      }
      
      var redoButton = {
      	signalId: "redo",
      	hPadding:1, vPadding:buttonMargin,
      	type: "image_button",
      	image:"redo.png",
      	width:40,
      	height:40,
      	style:{borderRadius:radius},
      	tooltip: "MES_REDO"
      }
      var exp = {
      	hPadding:buttonMargin, vPadding:buttonMargin,
      	signalId: "exportButton",
      	type: "image_button",
      	image:"export.png",
      	width:40,
      	height:40,
      	style:{borderRadius:radius},
      	tooltip: "MES_SAVE_AS_IMAGE"
      }
      var folder = {
      	signalId: "up",
      	hPadding:buttonMargin, vPadding:buttonMargin,
      	type: "image_button",
      	image:"arrow-up.png",
      	width:40,
      	height:40,
      	style:{borderRadius:radius},
      	tooltip: "MES_UP"
      }
      var search = {
      	signalId: "globalSearch",
      	hPadding:buttonMargin,
      	vPadding:buttonMargin,
      	type: "search",
      	height: SearchHeight,
      	width: 150
      }
      var sSpacer = {
      	type: "dummy",
      	width: 25
      }
      var createFolderButton = {
      	hPadding:8, vPadding:8,
      	signalId: "create_folder",
      	type: "text_button",
      	text:"new_folder",
      	style: createStyle,
      	tooltip: translate("MES_CREATE_FOLDER"),
      	customWidth: 100
      }
      var createProject = {
      	hPadding:8, vPadding:8,
      	type: "text_button",
      	signalId: "createProject",
      	text:"new_project",	
      	style: {
      		color: "white",
      		background: "coral",
      		fontSize: createFont,
      		padding: "12px",
      		textAlign: "center",
      		borderRadius:radius
      	},
      	tooltip: "MES_CREATE_SPACE"
      }
      var projects = {
      	hPadding:10, vPadding:10,
      	type: "text_button",
      	text:"MES_SPACES",
      	style: {background: DarkBackground},
      	background: "white"
      }
      var help = 
      {
      	hPadding:buttonMargin, vPadding:buttonMargin,
      	type: "image_button",
      	signalId: "showHelp",
      	image:"help.png",
      	width:40,
      	height:40,
      	style:{borderRadius:radius},
      	tooltip: translate("MES_HELP")
      }
      var user = {
      	hPadding:buttonMargin, vPadding:buttonMargin,
      	signalId: "accountButton",
      	type: "image_button",
      	image:"user.png",
      	width:40,
      	height:40,
      	style:{borderRadius:radius},
      	tooltip: translate("MES_ACCOUNT")
      }
      var rights = [user, help, search]
      var spacesTop = {
      	id: "top_spaces",
      	type: "hdock",
      	height: TopPanelHeight,
      	lefts: [mainMenu, createProject],
      	rights: [user, search],
      	style:{background:DarkBackground},
      	center: {
      		type: "path",
      		id: "spacesTopPath"
      	}
      }
      var diagramTop = {
      	id: "top_diagram",
      	type: "hdock",
      	height: TopPanelHeight,
      	lefts: [mainMenu, create, undoButton, 
      redoButton, exp, share, folder],
      	rights: rights,
      	style:{background:DarkBackground},
      	center: {
      		type: "path",
      		id: "foldersTopPath"
      	}
      }
      var fSpacer = {
      	type: "dummy",
      	width: 87
      }
      var folderTop = {
      	id: "top_folder",
      	type: "hdock",
      	height: TopPanelHeight,
      	lefts: [mainMenu, create, createFolderButton, sSpacer,
      share, folder],
      	rights: [user, search],
      	style:{background:DarkBackground},
      	center: {
      		type: "path"
      	}
      }
      var empty = {
      	id: "top_empty",
      	type: "hdock",
      	height: TopPanelHeight,
      	lefts: [mainMenu],
      	rights: [user, search],
      	style:{background:DarkBackground},
      	center: {
      		type: "path"
      	}
      }
      var exp2 = Utils.copyObject(exp)
      exp2.id = "export_button_ro"
      var oneButtSpace = {
      	type: "dummy",
      	width: 46
      }
      var diagramTopRo = {
      	id: "top_diagram_ro",
      	type: "hdock",
      	height: TopPanelHeight,
      	lefts: [mainMenu, exp2, share, folder],
      	rights: rights,
      	style:{background:DarkBackground},
      	center: {
      		type: "path"
      	}
      }
      var folderTopRo = {
      	id: "top_folder_ro",
      	type: "hdock",
      	height: TopPanelHeight,
      	lefts: [mainMenu, oneButtSpace, share, folder],
      	rights: [user, search],
      	style:{background:DarkBackground},
      	center: {
      		type: "path"
      	}
      }
      var exp3 = Utils.copyObject(exp)
      exp3.id = "export_button_nu"
      var nuSpace = {
      	type: "dummy",
      	width: 154
      }
      var saveStyle = {
      	fontSize: createFont,
      	padding: "12px",
      	width: "100px",
      	textAlign: "center",
      	paddingLeft: "0px",
      	paddingRight: "0px",
      	borderRadius: BorderRadius,
      	color: "white",
      	background: "coral"
      }
      var saveButton = {
      	hPadding:8, vPadding:8,
      	signalId: "saveDiagram",
      	type: "text_button",
      	text:"MES_SAVE",
      	style: saveStyle,
      	tooltip: translate("MES_SAVE_OWN"),
      	customWidth: 100
      }
      var diagramTopNu = {
      	id: "top_diagram_nu",
      	type: "hdock",
      	height: TopPanelHeight,
      	lefts: [mainMenu, saveButton, exp3, share, folder],
      	rights: [help, search],
      	style:{background:DarkBackground},
      	center: {
      		type: "path"
      	}
      }
      var folderTopNu = {
      	id: "top_folder_nu",
      	type: "hdock",
      	height: TopPanelHeight,
      	lefts: [mainMenu, nuSpace, share, folder],
      	rights: [search],
      	style:{background:DarkBackground},
      	center: {
      		type: "path"
      	}
      }
      var spacesTopNu = {
      	id: "top_spaces_nu",
      	type: "hdock",
      	height: TopPanelHeight,
      	lefts: [mainMenu],
      	rights: [search],
      	style:{background:DarkBackground},
      	center: {
      		type: "path"
      	}
      }
      var exp4 = Utils.copyObject(exp)
      exp4.id = "export_button_try"
      var diagramTopTry = {
      	id: "top_diagram_try",
      	type: "hdock",
      	height: TopPanelHeight,
      	lefts: [mainMenu, saveButton, undoButton, 
      		redoButton, exp4],
      	rights: [help],
      	style:{background:DarkBackground},
      	center: {
      		type: "path"
      	}
      }
      var dummy = {
      	id: "dummy",
      	type: "dummy",
      	height: TopPanelHeight,
      	style:{background: "#ffd0d0"}
      }
      return [dummy, spacesTop, folderTop, diagramTop, 
        empty, folderTopRo, diagramTopRo, 
        folderTopNu, diagramTopNu, spacesTopNu,
        diagramTopTry]
  }
  
  function makeTopWidgetsDescMob() {
      var buttonMargin = 6
      var buttonMargin2 = 10
      var createFont = "80%"
      var createPadding = "30px"
      var radius = "5px"
      var createStyle = {
      	fontSize: createFont,
      	padding: "12px",
      	textAlign: "center",
      	paddingLeft: "5px",
      	paddingRight: "5px",
      	color: DarkBackground,
      	background: "white",
      	borderRadius:radius
      }
      var mainMenu = {
      	signalId: "showMainMenu",
      	type: "image_button",
      	image:"menu.png",
      	width:52,
      	height:52,
      	tooltip: "MES_MENU"
      }
      var create = {
      	signalId : "create_diagram",
      	hPadding:0, vPadding:8,
      	type: "text_button",
      	text:"+",
      	tooltip: "MES_CREATE_DIAGRAM",
      	style: {
      		color: "white",
      		background: "coral",
      		fontSize: createFont,
      		padding: "12px",
      		paddingLeft: "0px",
      		paddingRight: "0px",
      		textAlign: "center",
      		borderRadius:radius
      	},
      	customWidth: 40
      }
      var share = {
      	hPadding:8, vPadding:buttonMargin,
      	signalId: "share",
      	type: "image_button",
      	image:"share.png",
      	width:40,
      	height:40,
      	style:{borderRadius:radius},
      	tooltip: "MES_SHARE"
      }
      var undoButton = {
      	signalId: "undo",
      	hPadding:buttonMargin, vPadding:buttonMargin,
      	type: "image_button",
      	image:"undo.png",
      	width:40,
      	height:40,
      	style:{borderRadius:radius},
      	tooltip: "MES_UNDO"
      }
      
      var redoButton = {
      	signalId: "redo",
      	hPadding:1, vPadding:buttonMargin,
      	type: "image_button",
      	image:"redo.png",
      	width:40,
      	height:40,
      	style:{borderRadius:radius},
      	tooltip: "MES_REDO"
      }
      var exp = {
      	hPadding:buttonMargin, vPadding:buttonMargin,
      	signalId: "exportButton",
      	type: "image_button",
      	image:"export.png",
      	width:40,
      	height:40,
      	style:{borderRadius:radius},
      	tooltip: "MES_SAVE_AS_IMAGE"
      }
      var up = {
      	signalId: "up",
      	hPadding:buttonMargin, vPadding:buttonMargin,
      	type: "image_button",
      	image:"arrow-up.png",
      	width:40,
      	height:40,
      	style:{borderRadius:radius},
      	tooltip: "MES_UP"
      }
      var createFolderButton = {
      	hPadding:8, vPadding:buttonMargin,
      	type: "image_button",
      	signalId: "create_folder",
      	image:"folder-s3.png",
      	width:40,
      	height:40,
      	style:{borderRadius:radius},
      	tooltip: translate("MES_CREATE_FOLDER")
      }
      var createProject = {
      	hPadding:8, vPadding:8,
      	type: "text_button",
      	text:"new_project",	
      	signalId: "createProject",
      	style: {
      		color: "white",
      		background: "coral",
      		fontSize: createFont,
      		padding: "12px",
      		textAlign: "center",
      		borderRadius:radius
      	},
      	tooltip: "MES_CREATE_SPACE"
      }
      var projects = {
      	hPadding:10, vPadding:10,
      	type: "text_button",
      	text:"MES_SPACES",
      	style: {background: DarkBackground},
      	background: "white"
      }
      var spacesLabel = {
      	hPadding:8,
      	vPadding: 10,
      	type: "label",
      	text: "MES_SPACES",
      	style: {
      		color: "white"
      	}
      }
      var help = 
      {
      	hPadding:buttonMargin, vPadding:buttonMargin,
      	type: "image_button",
      	signalId: "showHelp",
      	image:"help.png",
      	width:40,
      	height:40,
      	style:{borderRadius:radius},
      	tooltip: translate("MES_HELP")
      }
      var rights = [up, help]
      var diaLabel = {
      	id: "diaLabel",
      	type: "wlabel",
      	text: "Ololo!",
      	style: {
      		background: DockHeaderColor,
      		borderBottom: "solid 1px grey",
      		fontSize: "11pt"
      	}
      }
      var folderLabel = {
      	id: "folderLabel",
      	type: "wlabel",
      	text: "Ololo!",
      	style: {
      		background: DockHeaderColor,
      		borderBottom: "solid 1px grey",
      		fontSize: "11pt"
      	}
      }
      var spacesTop = {
      	id: "top_spaces",
      	type: "hdock",
      	height: TopPanelHeight,
      	lefts: [mainMenu, createProject, spacesLabel],
      	rights: [],
      	style:{background: DarkBackground}
      }
      var diagramTop = {
      	type: "hdock",
      	height: TopPanelHeight,
      	lefts: [mainMenu, create, undoButton, 
      redoButton, exp],
      	rights: rights,
      	style:{background: DarkBackground}
      }
      var diagramHead = {
      	id: "top_diagram",
      	type: "vpanel",
      	kids: [diagramTop, diaLabel]
      }
      var folderTop = {
      	type: "hdock",
      	height: TopPanelHeight,
      	lefts: [mainMenu, create, createFolderButton, share],
      	rights: [up],
      	style:{background: DarkBackground}
      }
      var folderHead = {
      	id: "top_folder",
      	type: "vpanel",
      	kids: [folderTop, folderLabel]
      }
      var empty = {
      	id: "top_empty",
      	type: "hdock",
      	height: TopPanelHeight,
      	lefts: [mainMenu],
      	rights: [],
      	style:{background:DarkBackground},
      	center: {
      		type: "path"
      	}
      }
      var exp2 = Utils.copyObject(exp)
      exp2.id = "export_button_ro"
      var diaLabelRo = Utils.copyObject(diaLabel)
      diaLabelRo.id = "diaLabelRo"
      var folderLabelRo = Utils.copyObject(folderLabel)
      folderLabelRo.id = "folderLabelRo"
      var diagramTopRo = {
      	type: "hdock",
      	height: TopPanelHeight,
      	lefts: [mainMenu, exp2],
      	rights: rights,
      	style:{background: DarkBackground}
      }
      var diagramHeadRo = {
      	id: "top_diagram_ro",
      	type: "vpanel",
      	kids: [diagramTopRo, diaLabelRo]
      }
      var folderTopRo = {
      	type: "hdock",
      	height: TopPanelHeight,
      	lefts: [mainMenu, share],
      	rights: [up],
      	style:{background: DarkBackground}
      }
      var folderHeadRo = {
      	id: "top_folder_ro",
      	type: "vpanel",
      	kids: [folderTopRo, folderLabelRo]
      }
      var exp3 = Utils.copyObject(exp)
      exp3.id = "export_button_nu"
      var diaLabelNu = Utils.copyObject(diaLabel)
      diaLabelNu.id = "diaLabelNu"
      var folderLabelNu = Utils.copyObject(folderLabel)
      folderLabelNu.id = "folderLabelNu"
      var spacesLabelNu = Utils.copyObject(spacesLabel)
      spacesLabelNu.id = "spacesLabelNu"
      var saveStyle = Utils.copyObject(createStyle)
      saveStyle.color = "white"
      saveStyle.background = "coral"
      var saveButton = {
      	hPadding:8, vPadding:8,
      	type: "text_button",
      	text:"MES_SAVE",
      	signalId: "saveDiagram",	
      	style: saveStyle,
      	tooltip: translate("MES_SAVE_OWN")
      }
      var diagramTopNu = {
      	type: "hdock",
      	height: TopPanelHeight,
      	lefts: [mainMenu, saveButton, exp3, share],
      	rights: rights,
      	style:{background: DarkBackground}
      }
      var diagramHeadNu = {
      	id: "top_diagram_nu",
      	type: "vpanel",
      	kids: [diagramTopNu, diaLabelNu]
      }
      var folderTopNu = {
      	type: "hdock",
      	height: TopPanelHeight,
      	lefts: [mainMenu, share],
      	rights: [up],
      	style:{background: DarkBackground}
      }
      var folderHeadNu = {
      	id: "top_folder_nu",
      	type: "vpanel",
      	kids: [folderTopNu, folderLabelNu]
      }
      var spacesTopNu = {
      	id: "top_spaces_nu",
      	type: "hdock",
      	height: TopPanelHeight,
      	lefts: [mainMenu, spacesLabelNu],
      	rights: [],
      	style:{background: DarkBackground}
      }
      var exp4 = Utils.copyObject(exp)
      exp4.id = "export_button_try"
      var diagramTopTry = {
      	id: "top_diagram_try",
      	type: "hdock",
      	height: TopPanelHeight,
      	lefts: [mainMenu, saveButton, undoButton, 
      		redoButton, exp4],
      	rights: [help],
      	style:{background:DarkBackground},
      	center: {
      		type: "path"
      	}
      }
      var dummy = {
      	id: "dummy",
      	type: "dummy",height: TopPanelHeight,
      	style:{background: "#ffd0d0"}
      }
      return [dummy, spacesTop, folderHead, diagramHead, empty,
      folderHeadRo, diagramHeadRo,
      folderHeadNu, diagramHeadNu, spacesTopNu,
      diagramTopTry]
  }
  
  function noContext(div) {
      HtmlUtils.noContext(div)
  }
  
  function onAddUserClicked(role) {
      var machine = getMachine()
      machine.addUser(role)
  }
  
  function onClearClipboard(timer) {
      if (timer == globs.clipboardTimer) {
          clearClipboard()
      }
  }
  
  function onCtrlA() {
      getEditor().selectAll()
  }
  
  function onCtrlEnter() {
      if (InputBox.isVisible()) {
          InputBox.submit()
      } else {
          if (globs.mobileInput) {
              saveMobileInput()
          }
      }
  }
  
  function onCtrlY() {
      self.logic.redo()
  }
  
  function onCtrlZ() {
      self.logic.undo()
  }
  
  function onData(target, data, requestId) {
      if (target.requestId == requestId) {
          target.onData(data)
      }
  }
  
  function onDefResult(cx, cy, queryId, current, data) {
      var extended = globs.extended
      if ((extended) && (queryId == extended.queryId)) {
          var menuItems = []
          if (data.items) {
              var _ind3662 = 0;
              var _col3662 = data.items;
              var _len3662 = _col3662.length;
              while (true) {
                  if (_ind3662 < _len3662) {
                      
                  } else {
                      break;
                  }
                  var item = _col3662[_ind3662];
                  if ((item.space_id == current.spaceId) && (!(item.folder_id == current.folderId))) {
                      var text = makeGotoText(item.name)
                      var action = makeNavFolder(item.space_id, item.folder_id)
                      menuItems.push({
                      	type: "item",
                      	text: text,
                      	code: action
                      })
                  }
                  _ind3662++;
              }
          }
          var _ind3690 = 0;
          var _col3690 = extended.urls;
          var _len3690 = _col3690.length;
          while (true) {
              if (_ind3690 < _len3690) {
                  
              } else {
                  break;
              }
              var url = _col3690[_ind3690];
              var text = makeGotoText(url)
              var action = makeGoOutside(url)
              menuItems.push({
              	type: "item",
              	text: text,
              	code: action
              })
              _ind3690++;
          }
          if (menuItems.length == 0) {
              
          } else {
              var items = menuItems.slice(0, 7)
              ContextMenu.addItem({
              	type: "separator"
              })
              var _ind3683 = 0;
              var _col3683 = items;
              var _len3683 = _col3683.length;
              while (true) {
                  if (_ind3683 < _len3683) {
                      
                  } else {
                      break;
                  }
                  var item = _col3683[_ind3683];
                  ContextMenu.addItem(item)
                  _ind3683++;
              }
              ContextMenu.repos(
              	cx,
              	cy
              )
          }
      }
  }
  
  function onDeleteKey(evt) {
      if ((isEditorOn()) && (!(isReadonly()))) {
          getEditor().deleteSelection()
          HtmlUtils.preventDefaultHandling(evt)
      }
  }
  
  function onDemoButton(evt, type, widget, id, cellId) {
      selectDemoButton(widget.id)
  }
  
  function onEnter(evt) {
      startEdit(evt)
      if (globs.enterSave) {
          onCtrlEnter(evt)
      }
  }
  
  function onError(errorMsg, url, lineNumber, column, errorObj) {
      reportError(
      	errorMsg,
      	url,
      	lineNumber,
      	column,
      	errorObj
      )
      pagePanic(errorMsg)
  }
  
  function onEscape(evt) {
      if (isCentralVisible()) {
          cancelMachine()
      }
      if (HtmlUtils.hasPopup()) {
          hidePopup()
      }
      HtmlUtils.hideSoftPopup()
      hideHelp()
  }
  
  function onEvent(evt, type, widget, rowId, cellId) {
      var myHandler = globs.myHandlers[widget.signalId]
      if (myHandler) {
          myHandler(
          	evt,
          	type,
          	widget,
          	rowId,
          	cellId
          )
      } else {
          self.logic.onEvent(
          	evt,
          	type,
          	widget,
          	rowId,
          	cellId
          )
      }
  }
  
  function onFileChange() {
      HtmlUtils.setText(
      	"file-error",
      	""
      )
  }
  
  function onFontLoaded(file, target, font) {
      CallTrace.add("font ready", [file])
      var face = Utils.buildFontFace(
      	font.italic,
      	font.bold,
      	font.family
      )
      console.log(
      	"Font ready",
      	file,
      	face
      )
      HtmlUtils.fontFaceLoaded(face)
      globs.loadedFonts[file] = true
      scheduleNextStateAfter(target, null, 200)
  }
  
  function onFontNotLoaded(file, target) {
      console.log(
      	"Font NOT loaded",
      	file
      )
      CallTrace.add("font NOT loaded", [file])
      scheduleNextStateAfter(target, null, 200)
  }
  
  function onInitCompleted() {
      display("loading", "none")
      display("wide", "block")
      globs.initCompleted = true
      onResize()
  }
  
  function onIsPublicChange() {
      var div = get("access_is_public_check")
      getMachine().togglePublic()
  }
  
  function onPassDown(evt) {
      var _sw28780000_ = 0;
      _sw28780000_ = evt.keyCode;
      if (_sw28780000_ === 13) {
          startLogon()
      } else {
          if (_sw28780000_ === 27) {
              cancelMachine()
          }
      }
  }
  
  function onResize() {
      var border = 0
      var top = border
      var left = border
      var width = HtmlUtils.width() - border * 2
      var height = HtmlUtils.height() - border * 2
      globs.widgets.resizeWidget(
      	globs.root,
      	left,
      	top,
      	width,
      	height
      )
      resizeCentral()
      //resizeCentral()
  }
  
  function onSignupError(data) {
      var message = makeErrorMessage(data)
      HtmlUtils.setText("signup_status", message)
      resizeCentral()
      hideWorking()
  }
  
  function onSignupSuccess(data) {
      getMachine().signup(data)
  }
  
  function onStateChange(state) {
      if (globs.initCompleted) {
          killCentral()
          hidePopup()
          hidePopup()
          hideHelp()
          Nav.onStateChange(state)
      }
  }
  
  function onUserDown(evt) {
      var _sw28630000_ = 0;
      _sw28630000_ = evt.keyCode;
      if (_sw28630000_ === 13) {
          get("password_edit").focus()
      } else {
          if (_sw28630000_ === 27) {
              cancelMachine()
          }
      }
  }
  
  function orderResize() {
      var existing = globs.resizeTimer
      if (existing) {
          clearTimeout(existing)
      }
      var callback = function() {
      	globs.resizeTimer = null
      	onResize()
      }
      var timer = setTimeout(
      	callback,
      	ResizeTimeout,
      	"orderResize"
      )
      globs.resizeTimer = timer
  }
  
  function pad1(text) {
      if (text.length == 1) {
          text = "0" + text
      }
      return text
  }
  
  function panic(data) {
      var rawMessage = Utils.makeErrorMessage(data)
      var message = translate(rawMessage)
      var url, lineNumber
      var column, errorObj
      url = null
      lineNumber = null
      column = null
      errorObj = null
      if (data.name == "Error") {
          errorObj = data
      }
      if (shouldReport(rawMessage)) {
          reportError(
          	message,
          	url,
          	lineNumber,
          	column,
          	errorObj
          )
          pagePanic(message)
      } else {
          if (rawMessage == "ERR_NOT_LOGGED_ON") {
              var url = "/logon?target=" +
               getMyUrl()
              goToUrl(url)
          } else {
              pagePanic(message)
          }
      }
  }
  
  function panicOnFont(data, font) {
      var error = makeErrorMessage(data)
      if (font) {
          error += (" family:" + font.family)
          error += (" italic:" + font.italic)
          error += (" bold:" + font.bold)
      }
      panic(error)
  }
  
  function placeFeedback(right) {
      var button = get("feedback")
      button.style.right = right + "px"
  }
  
  function positionSearchResults() {
      var popup = globs.search.popup
      var widget = get(globs.search.widgetId)
      HtmlUtils.showUnder(
      	widget,
      	popup
      )
  }
  
  function preventQuestion() {
      window.onbeforeunload = null
  }
  
  function promiseError(ex) {
      onError(
      	ex.message,
      	ex.fileName,
      	ex.lineNumber,
      	null,
      	ex
      )
  }
  
  function pushState(onState, title, url) {
      Nav.pushState(
      	onState,
      	title,
      	window.location.origin + url
      )
  }
  
  function pushTempIfMobile() {
      if ((globs.wide) || (globs.isTryMe)) {
          
      } else {
          pushTempState()
      }
  }
  
  function pushTempState() {
      var state = {
      	type: "tmp"
      }
      //Nav.pushState(null, "", "")
  }
  
  function registerEvent(div, widget, eventName) {
      var fullname = "on" + eventName
      var action = function(evt) {
      	onEvent(evt, eventName, widget)
      }
      div[fullname] = wrapException(action, "registerEvent")
  }
  
  function registerShortcuts() {
      bindKey(["escape"], onEscape)
      bindKey(["enter"], onEnter)
      bindKey(["mod+enter"], onCtrlEnter)
      bindKey(["backspace", "del"], onDeleteKey)
      bindKey(["space"], startPan, "keydown")
      bindKey(["space"], endPan, "keyup")
      bindKey(["mod+f"], focusSearch)
      bindEditor(["mod+z"], onCtrlZ)
      bindEditor(["mod+y"], onCtrlY)
      bindEditor(["mod+a"], onCtrlA)
      var editor = getEditor()
      bindEditor("f2", startEdit)
      bindEditor("mod+c", editor.copy)
      bindEditor("mod+x", editor.cut)
      bindEditor("mod+v", editor.paste)
      bindEditor("up", function() {editor.arrowUp(false, false, false)})
      bindEditor("mod+up", function() {editor.arrowUp(true, false, false)})
      bindEditor("shift+up", function() {editor.arrowUp(false, true, false)})
      bindEditor("alt+up", function() {editor.arrowUp(false, false, true)})
      bindEditor("down", function() {editor.arrowDown(false, false, false)})
      bindEditor("mod+down", function() {editor.arrowDown(true, false, false)})
      bindEditor("shift+down", function() {editor.arrowDown(false, true, false)})
      bindEditor("alt+down", function() {editor.arrowDown(false, false, true)})
      bindEditor("left", function() {editor.arrowLeft(false, false, false)})
      bindEditor("mod+left", function() {editor.arrowLeft(true, false, false)})
      bindEditor("shift+left", function() {editor.arrowLeft(false, true, false)})
      bindEditor("alt+left", function() {editor.arrowLeft(false, false, true)})
      bindEditor("right", function() {editor.arrowRight(false, false, false)})
      bindEditor("mod+right", function() {editor.arrowRight(true, false, false)})
      bindEditor("shift+right", function() {editor.arrowRight(false, true, false)})
      bindEditor("alt+right", function() {editor.arrowRight(false, false, true)})
      bindAddItem("a", "action")
      bindAddItem("q", "question")
      bindAddItem("l", "foreach")
      bindAddItem("n", "insertion")
      bindAddItem("f", "shelf")
      bindAddItem("m", "comment")
      bindAddItem("s", "select")
      bindAddItem("c", "case")
      bindAddItem("b", "branch")
      bindAddItem("r", "raction")
  }
  
  function removeAdmin(evt, type, widget, user, cellId) {
      if (cellId == 0) {
          getWidget("removeAdmin").remove(user)
          resizeCentral()
          var msg = {
          	role: "admin",
          	user: user
          }
          getMachine().removeUser(msg)
      }
  }
  
  function removeEmpty() {
      var popup = globs.search.popup
      if (globs.search.empty) {
          popup.removeChild(globs.search.empty)
          globs.search.empty = null
      }
  }
  
  function removeLimit() {
      var url = "/buy"
      if (trialAllowed()) {
          if (globs.plan == "team") {
              url = "/trial"
          } else {
              url = "/prices"
          }
      }
      var query = []
      if (globs.plan) {
          query.push("product=" + globs.plan)
      }
      if (globs.ref) {
          query.push("ref=" + globs.ref)
      }
      if (query.length == 0) {
          
      } else {
          var qstring = query.join("&")
          url += ("?" + qstring)
      }
      goToUrl(url)
  }
  
  function removeReader(evt, type, widget, user, cellId) {
      if (cellId == 0) {
          getWidget("removeReader").remove(user)
          resizeCentral()
          var msg = {
          	role: "read",
          	user: user
          }
          getMachine().removeUser(msg)
      }
  }
  
  function removeWriter(evt, type, widget, user, cellId) {
      if (cellId == 0) {
          getWidget("removeWriter").remove(user)
          resizeCentral()
          var msg = {
          	role: "write",
          	user: user
          }
          getMachine().removeUser(msg)
      }
  }
  
  function reportError(errorMsg, url, lineNumber, column, errorObj) {
      var stack = null
      if (errorObj) {
          stack = errorObj.stack
      }
      console.log(errorMsg, url, lineNumber, column, errorObj)
      DTools.print(errorMsg, errorObj, url, lineNumber)
      var trace = CallTrace.reset()
      console.log(trace)
      var crashData = {
      	type: "crash",
      	errorMsg: errorMsg,
      	errorUrl: url,
      	errorObj: errorObj,
      	trace: trace,
      	stack: stack,
      	clientDiagram: self.logic.getDiagram()
      }
      sendFeedbackCore(
      	crashData,
      	function(){},
      	function(){}
      )
  }
  
  function resizeCentral() {
      var id = globs.central
      if (id) {
          var topMargin = 10
          var width = 320
          var height = window.innerHeight - topMargin
          var winWidth = window.innerWidth
          var x = Math.floor((winWidth - width) / 2)
          var y = topMargin
          var requested = getWidget(id).measureHeight(width)
          height = Math.min(height, requested)
          globs.widgets.resizeWidget(
          	id,
          	x,
          	y,
          	width,
          	height
          )
      }
  }
  
  function resizeEditor() {
      var rect = this.rect
      globs.editor.resize(
      	rect.left,
      	rect.top,
      	rect.width,
      	rect.height
      )
  }
  
  function runIfEditorVisible(evt, method) {
      if (isEditorOn()) {
          method(evt)
          HtmlUtils.preventDefaultHandling(evt)
      }
  }
  
  function saveAccess() {
      sendToCentralMachine(null)
  }
  
  function saveAsPng(zoom) {
      var exportCanvas = make(
      	document.body,
      	"canvas"
      )
      var image = getEditor().exportPng(exportCanvas, zoom)
      if (globs.wide) {
          var filename = getDateString() + ".png"
          var success = function(data) {
          	hideWorking()
          	var url = "/api/download/" + data.download_id
          	window.location.href = url
          }
          showWorking()
          HtmlUtils.sendRawPost(
          	"/api/download/" + filename,
          	image,
          	success,
          	panic
          )
      } else {
          var name = makePngName()
          var w = window.open('about:blank', "");
          if (!w) return
          
          w.document.write("<img src='" + image + "' alt='" + name + "'/>");
      }
      document.body.removeChild(exportCanvas)
  }
  
  function saveAsSvg() {
      var filename = getDateString() + ".svg"
      var image = getEditor().exportSvg()
      var fonts = getEditor().getFontsFromEditor()
      var data = {
      	filename: filename,
      	image: image,
      	fonts: fonts
      }
      var success = function(data) {
      	hideWorking()
      	var url = "/api/download/" + data.download_id
      	window.location.href = url
      }
      showWorking()
      HtmlUtils.sendPost(
      	"/api/download_svg",
      	data,
      	success,
      	panic
      )
  }
  
  function saveMobileInput() {
      var isAsync = globs.mobileIsAsync
      var onSave = globs.mobileOnSave
      var validate = globs.mobileValidate
      var text = get("mob_input_edit").value
      if (validate) {
          var error = validate(text)
          if (error) {
              setMobileInputError(translate(error))
          } else {
              if (isAsync) {
                  
              } else {
                  hideCentral()
              }
              onSave(text)
          }
      } else {
          if (isAsync) {
              
          } else {
              hideCentral()
          }
          onSave(text)
      }
  }
  
  function saveStatus(status) {
      
  }
  
  function saveUserSettings(settings) {
      self.logic.saveUserSettings(settings)
  }
  
  function schedule(target, ms) {
      var callback = function() {
      	target.timeout()
      }
      return setTimeout(
      	callback,
      	ms,
      	"schedule"
      )
  }
  
  function scheduleClipboardClear() {
      var CLIPBOARD_TTL = 5 * 60 * 1000
      var timer = Math.floor(Math.random() * 100000).toString()
      globs.clipboardTimer = timer
      window.setTimeout(
      	function() { onClearClipboard(timer) },
      	CLIPBOARD_TTL
      )
  }
  
  function scheduleNextState(machine, data) {
      scheduleNextStateAfter(
      	machine,
      	data,
      	1
      )
  }
  
  function scheduleNextStateAfter(machine, data, delay) {
      var delayed = function() {
      	machine.onData(data)
      }
      window.setTimeout(delayed, delay)
  }
  
  function searchUsers() {
      var search = getWidget("searchUsers")
      var value = search.getValue()
      value = value.trim()
      getMachine().onInput(value)
  }
  
  function selectDemoButton(id) {
      var _ind4167 = 0;
      var _col4167 = globs.demo.buttons;
      var _keys4167 = Object.keys(_col4167); 
      var _len4167 = _keys4167.length;
      while (true) {
          if (_ind4167 < _len4167) {
              
          } else {
              break;
          }
          var buttonId = _keys4167[_ind4167]; var rec = _col4167[buttonId];
          var div = get(buttonId)
          div.style.background = DarkBackground
          _ind4167++;
      }
      var div = get(id)
      div.style.background = "black"
      var rec = globs.demo.buttons[id]
      var image = makeImagePath(rec.image)
      get("demoViewport_img").src = image
  }
  
  function sendDelete(url, target) {
      CallTrace.add("sendDelete", [url])
      var success = wrapException(function(data) {
      	target.onData(data)
      }, "sendDelete:success")
      var error = wrapException(function(data) {
      	sendError(target, data)
      }, "sendDelete:error")
      HtmlUtils.sendRequest(
      	"DELETE",
      	url,
      	{},
      	success,
      	error
      )
  }
  
  function sendError(machine, error) {
      if (machine.onError) {
          machine.onError(error)
      }
  }
  
  function sendFeedback() {
      var title = translate("MES_SEND_FEEDBACK_TO_DEV")
      var onSave = function(name) {
      	doSendFeedback(
      		name
      	)
      }
      showInputBox(
      	true,
      	translate(title),
      	"",
      	onSave,
      	enforceNotEmpty,
      	false
      )
  }
  
  function sendFeedbackCore(data, success, error) {
      data.url = window.location.href
      var current = self.logic.getCurrent()
      data.screen = current.screen
      data.spaceId = current.spaceId
      data.folderId = current.folderId
      data.doc_type = current.type
      var url = "/api/feedback/"
      HtmlUtils.sendPost(
      	url,
      	data,
      	success,
      	error
      )
  }
  
  function sendGet(url, target) {
      CallTrace.add("sendGet", [url])
      var requestId = Utils.randomString(10)
      target.requestId = requestId
      var success = wrapException(function(data) {
      	onData(target, data, requestId)
      }, "sendGet:success")
      var error = wrapException(function(data) {
      	sendError(target, data)
      }, "sendGet:error")
      HtmlUtils.sendGet(
      	url,
      	success,
      	error
      )
  }
  
  function sendPost(url, payload, target) {
      CallTrace.add("sendPost", [url])
      var requestId = Utils.randomString(10)
      target.requestId = requestId
      var success = wrapException(function(data) {
      	onData(target, data, requestId)
      }, "sendPost:success")
      var error = wrapException(function(data) {
      	sendError(target, data)
      }, "sendPost:error")
      HtmlUtils.sendPost(
      	url,
      	payload,
      	success,
      	error
      )
  }
  
  function sendPut(url, payload, target) {
      CallTrace.add("sendPut", [url])
      var requestId = Utils.randomString(10)
      target.requestId = requestId
      var success = wrapException(function(data) {
      	onData(target, data, requestId)
      }, "sendPut:success")
      var error = wrapException(function(data) {
      	sendError(target, data)
      }, "sendPut:error")
      HtmlUtils.sendRequest(
      	"PUT",
      	url,
      	payload,
      	success,
      	error
      )
  }
  
  function sendToCentralMachine(message) {
      var count = globs.centralMachines.length
      if (count == 0) {
          
      } else {
          var machine = globs.centralMachines[count - 1]
          machine.onData(message)
      }
  }
  
  function setAccessError(message) {
      var label = get("access_error")
      HtmlUtils.setDivText(
      	label,
      	message
      )
      resizeCentral()
  }
  
  function setButtonStyle(div, color, background, padding) {
      var style = div.style
      div.className = "common_button"
      noContext(div)
      style.cursor = "pointer"
      style.display = "inline-block"
      style.color = color
      style.background = background
      style.padding = padding
      style.borderRadius = BorderRadius
  }
  
  function setDashboardProjects(projects) {
      var widget = this
      widget.projects.innerHTML = ""
      var table = make(widget.projects, "table")
      var _ind3879 = 0;
      var _col3879 = projects;
      var _len3879 = _col3879.length;
      while (true) {
          if (_ind3879 < _len3879) {
              
          } else {
              break;
          }
          var project = _col3879[_ind3879];
          addProjectRow(table, project)
          _ind3879++;
      }
  }
  
  function setDashboardRecent(recent) {
      var widget = this
      widget.recent.innerHTML = ""
      var table = make(widget.recent, "table")
      var _ind3911 = 0;
      var _col3911 = recent;
      var _len3911 = _col3911.length;
      while (true) {
          if (_ind3911 < _len3911) {
              
          } else {
              break;
          }
          var item = _col3911[_ind3911];
          addRecentRow(table, item)
          _ind3911++;
      }
  }
  
  function setFoundUsers(users) {
      var rows = []
      var _ind2742 = 0;
      var _col2742 = users;
      var _len2742 = _col2742.length;
      while (true) {
          if (_ind2742 < _len2742) {
              
          } else {
              break;
          }
          var user = _col2742[_ind2742];
          addIconText(
          	rows,
          	"user-s.png",
          	user
          )
          _ind2742++;
      }
      getWidget("foundUser").setItems(rows)
      resizeCentral()
  }
  
  function setInputBoxError(message) {
      if (globs.wide) {
          InputBox.setError(message)
      } else {
          setMobileInputError(message)
      }
  }
  
  function setLsItem(key, value) {
      try {
      	window.localStorage.setItem(key, value)
      } catch (e) {
      	globs.clip[key] = value
      }
  }
  
  function setMobileHeader(text) {
      if (globs.wide) {
          
      } else {
          var widgets = [
          	"folderLabel",
          	"diaLabel",
          	"folderLabelRo",
          	"diaLabelRo",
          	"folderLabelNu",
          	"diaLabelNu"
          ]
          var _ind3096 = 0;
          var _col3096 = widgets;
          var _len3096 = _col3096.length;
          while (true) {
              if (_ind3096 < _len3096) {
                  
              } else {
                  break;
              }
              var id = _col3096[_ind3096];
              HtmlUtils.setText(id, text)
              _ind3096++;
          }
      }
  }
  
  function setMobileInputError(message) {
      HtmlUtils.setText(
      	"mobile_input_error",
      	message
      )
      resizeCentral()
  }
  
  function setTimeout(delayed, delay, src) {
      var wrapped = wrapException(delayed, src)
      return window.setTimeout(wrapped, delay)
  }
  
  function setTitle(title) {
      document.title = title
  }
  
  function shouldReport(message) {
      if ((((((((message == "ERR_ACCESS_DENIED") || (message == "ERR_BAD_PATH")) || (message == "ERR_NOT_FOUND")) || (message == "ERR_COMMUNICATION")) || (message == "ERR_DIAGRAM_LIMIT")) || (message == "ERR_USER_LIMIT")) || (message == "ERR_SPACE_LIMIT")) || (message == "ERR_NOT_LOGGED_ON")) {
          return false
      } else {
          return true
      }
  }
  
  function show(id, display) {
      var div = get(id)
      showDiv(div, display)
  }
  
  function showAccessScreen(access, machine) {
      var cancel = {
      	signalId: "cancelMachine",
      	type: "text_button",
      	text: "MES_CANCEL",
      	style: {
      		color: "white",
      		background: DarkBackground,
      		padding: "12px",
      		textAlign: "center",
      		borderRadius: "5px"
      	}
      }
      var save = {
      	signalId: "saveAccess",
      	type: "text_button",
      	text: "MES_SAVE",
      	style: {
      		color: "white",
      		background: "coral",
      		padding: "12px",
      		textAlign: "center",
      		borderRadius: "5px"
      	}
      }
      var buttons = {
      	type: "hdock",
      	height: 40,
      	lefts: [cancel],
      	rights: [save]
      }
      var label = {
      	type: "custom",
      	builder: function(div) {
      		var top = make(div, "div")
      		HtmlUtils.setDivText(top, translate("MES_ACCESS_TO"))
      		top.style.textAlign = "center"
      		var name = make(div, "div")
      		HtmlUtils.setDivText(name, access.spaceId)
      		name.style.textAlign = "center"
      		name.style.fontWeight = "bold"
      	}
      }
      var error = {
      	type: "custom",
      	id: "access_error",
      	builder: function(div) {
      		div.style.color = "#900000"
      	}
      }
      var check = {
      	type: "custom",
      	id: "access_is_public",
      	builder: buildNormalCheckbox,
      	text: "All can read",
      	value: access.isPublic,
      	onchange: onIsPublicChange
      }
      var readHead = makeAccessSubheader("Read", "addReader")
      var writeHead = makeAccessSubheader("Write", "addWriter")
      var adminHead = makeAccessSubheader("Admin", "addAdmin")
      var read = createUserList("removeReader", access.roles.read)
      var write = createUserList("removeWriter", access.roles.write)
      var admin = createUserList("removeAdmin", access.roles.admin)
      var topPage = {
      	type: "page",
      	padding: 10,
      	kids: [buttons, label, error, check]
      }
      var bottomPage = {
      	type: "page",
      	padding: 10,
      	kids: [readHead, read, 
      	writeHead, write, 
      	adminHead, admin]
      }
      var root = {
      	type: "vdock",
      	top: topPage,
      	center: bottomPage
      }
      addCentral(root, machine)
  }
  
  function showAddUserScreen(machine) {
      var label = {
      	type: "label",
      	text: "MES_ADD_USER",
      	style: {
      		textAlign: "center"
      	}
      }
      var cancel = {
      	signalId: "cancelMachine",
      	type: "text_button",
      	text: "MES_CANCEL",
      	style: {
      		color: "white",
      		background: DarkBackground,
      		padding: "12px",
      		textAlign: "center",
      		borderRadius: "5px"
      	}
      }
      var buttons = {
      	type: "hdock",
      	height: 40,
      	lefts: [cancel],
      	rights: []
      }
      var search = {
      	id: "searchUsers",
      	type: "search",
      	height: 30,
      	width: 300
      }
      var list = {
      	id: "foundUser",
      	type: "list_grid",
      	noScroll: true,
      	columns: [
      		{type:"image", width:"36px", clickable:false},
      		{type:"text", width:"100%"}
      	]
      }
      var topPage = {
      	type: "page",
      	padding: 10,
      	kids: [buttons, label, search]
      }
      var bottomPage = {
      	type: "page",
      	padding: 10,
      	kids: [list]
      }
      var root = {
      	type: "vdock",
      	top: topPage,
      	center: bottomPage
      }
      addCentral(root, machine)
      getWidget("searchUsers").focus()
  }
  
  function showChooseTypeDialog(centralMachine) {
      var lab = {
      	type: "wlabel",
      	text: "Choose diagram type",
      	textAlign: "center",
      	style: {
      		fontWeight: "bold",
      		fontSize: "120%"
      	}
      }
      var drakon = {
      	signalId: "createDrakon",
      	type: "custom",
      	builder: makeBigPictureButton,
      	text: "DRAKON diagram",
      	desc: "DRAKON diagram desc",
      	image: "logo-drakon.png",
      	width: 90,
      	height: 100
      }
      var mind = {
      	signalId: "createMind",
      	type: "custom",
      	builder: makeBigPictureButton,
      	text: "GRAF mindmap",
      	desc: "GRAF mindmap desc",
      	image: "logo-graf.png",
      	width: 117,
      	height: 77
      }
      var free = {
      	signalId: "createFree",
      	type: "custom",
      	builder: makeBigPictureButton,
      	text: "Free-form diagram",
      	desc: "Free-form diagram desc",
      	image: "logo-free.png",
      	width: 117,
      	height: 70
      }
      var cancel = {
      	signalId: "cancelMachine",
      	type: "wbutton",
      	text: "MES_CANCEL",
      	style: {
      		color: "white",
      		background: DarkBackground,
      		padding: "12px",
      		textAlign: "center"
      	}
      }
      var d3 = {
      	type: "page",
      	style: {
      		background: "white"
      	},
      	padding: 5,
      	kids: [lab, drakon, mind, free, cancel]
      //	kids: [lab, drakon, free, cancel]
      }
      createCentral(d3, centralMachine)
  }
  
  function showContextMenu(x, y, menu, onBackground, item) {
      var _ind1745 = 0;
      var _col1745 = menu.rows;
      var _len1745 = _col1745.length;
      while (true) {
          if (_ind1745 < _len1745) {
              
          } else {
              break;
          }
          var it = _col1745[_ind1745];
          var itemId = it.id || "<none>"
          var wrapped = wrapException(
          	it.code,
          	"context-menu:" + itemId
          )
          it.code = wrapped
          _ind1745++;
      }
      ContextMenu.show(
      	x,
      	y,
      	menu,
      	onBackground
      )
      var extended = {}
      globs.extended = extended
      if (((item) && (!(globs.tryMe))) && (canDefQueryFrom(item))) {
          var lines = getItemLines(item.content)
          if (lines.length == 0) {
              
          } else {
              var queryId = Utils.randomString(10)
              extended.urls = getItemUrls(item.content)
              extended.queryId = queryId
              extended.item = item
              var url = "/api/def_query"
              var current = self.logic.getCurrent()
              var spaceId = current.spaceId
              var onSuccess = function(data) {
              	onDefResult(
              		x,
              		y,
              		queryId,
              		current,
              		data
              	)
              }
              var body = {
              	space_id: spaceId,
              	lines: lines
              }
              var target = {
              	onData: onSuccess,
              	onError: function(){}
              }
              sendPost(
              	url,
              	body,
              	target
              )
          }
      }
  }
  
  function showDemo(type) {
      var videoMargin = 5
      var panelWidth = 200
      var videoWidth = 600
      var videoHeight = 500
      var lowerHeight = 50
      var upperHeight = videoMargin * 2 + videoHeight
      var width = videoMargin * 2 + 
      	panelWidth + videoWidth
      var height = lowerHeight + upperHeight
      destroyDemoWindow()
      var root = get("demo")
      root.style.display = "inline-block"
      root.style.position = "fixed"
      var back = make(root, "div")
      back.style.background = "black"
      back.style.opacity = 0.3
      //back.style.zIndex = 25
      back.onclick = wrapException(
      	hideDemo,
      	"hideDemo"
      )
      showFullscreen(back)
      var dialog = make(root, "div")
      showInCenter(dialog, width, height)
      //dialog.style.zIndex = 26
      var show = !isDemoDiscarded()
      var check = {
      	id: "demoShowOnStart",
      	type: "custom",
      	text: "MES_SHOW_ON_START",
      	value: show,
      	builder: buildNormalCheckbox,
      	hPadding:10, vPadding:15
      }
      var close = {
      	type: "text_button",
      	text: "MES_CLOSE",
      	signalId: "hideDemo",
      	style: {
      		background: "Coral",
      		color: "white",
      		padding: "6px",
      		textAlign: "center",
      		borderRadius: "5px"
      	},
      	hPadding:10, vPadding:10
      }
      var bottomHalf = {
      	type: "hdock",
      	lefts: [],
      	rights: [close, check],
      	height: lowerHeight,
      	padding:10
      }
      var items
      if (type == "drakon") {
          items = makeDemoListDrakon()
      } else {
          items = makeDemoListMind()
      }
      var buttons = makeDemoButtons(items)
      var buttonsPanel = {
      	type: "page",
      	kids: buttons,
      	padding: 5,
      	width: panelWidth,
      	style: {background:"#d0d0ff"},
      	hPadding:videoMargin
      }
      var viewport = {
      	type: "custom",
      	id: "demoViewport",
      	builder: buildImageWidget,
      	width: videoWidth,
      	height: videoHeight,
      	hPadding:videoMargin, vPadding:videoMargin
      }
      var topHalf = {
      	type: "hdock",
      	height: upperHeight,
      	lefts: [viewport, buttonsPanel],
      	rights: []
      }
      var node = {
      	type: "vpanel",
      	kids: [topHalf, bottomHalf]
      }
      var id = globs.widgets.createWidget(
      	dialog,
      	node
      )
      globs.demo.widgetId = id
      globs.widgets.resizeWidget(
      	id,
      	0,
      	0,
      	width,
      	height
      )
      selectDemoButton("demoButton_1")
  }
  
  function showDiv(div, display) {
      div.style.display = display
  }
  
  function showFullscreen(div) {
      div.style.display = "inline-block"
      div.style.position = "fixed"
      div.style.left = "0px"
      div.style.right = "0px"
      div.style.top = "0px"
      div.style.bottom = "0px"
  }
  
  function showHelp() {
      if (isDrakon()) {
          showMany("drakon_only", "block")
      } else {
          showMany("drakon_only", "none")
      }
      if (isMind()) {
          showMany("mind_only", "block")
      } else {
          showMany("mind_only", "none")
      }
      if (globs.wide) {
          show("help_wide", "block")
      } else {
          pushTempIfMobile()
          show("help_narrow", "block")
      }
      globs.helpOn = true
  }
  
  function showInCenter(dialog, width, height) {
      var hw = Math.floor(width / 2).toString()
      var hh = Math.floor(height / 2).toString()
      dialog.style.display = "inline-block"
      dialog.style.position = "fixed"
      dialog.style.background = "white"
      dialog.style.left = "calc(50% - " + hw + "px)"
      dialog.style.top = "calc(50vh - " + hh + "px)"
      dialog.style.width = width + "px"
      dialog.style.height = height + "px"
  }
  
  function showInputBox(isAsync, header, old, onSave, validate, enterSave, x, y) {
      globs.enterSave = enterSave
      if (globs.wide) {
          InputBox.show(
          	isAsync,
          	header,
          	old,
          	onSave,
          	validate,
          	x,
          	y
          )
      } else {
          showMobileInput(
          	isAsync,
          	header,
          	old,
          	onSave,
          	validate
          )
      }
  }
  
  function showLoadFromFile(spaceId, machine) {
      var label = {
      	type: "custom",
      	builder: function(div) {
      		var top = make(div, "div")
      		HtmlUtils.setDivText(top, translate("MES_LOAD_FROM_FILE_EX"))
      		top.style.textAlign = "center"
      		var name = make(div, "div")
      		HtmlUtils.setDivText(name, translate("MES_SPACE") + ": " + spaceId)
      		name.style.textAlign = "center"
      		name.style.fontWeight = "bold"
      		var input = make(div, "input")
      		input.id = "file-input"
      		input.type = "file"
      		input.name = "Project file"
      		input.addEventListener("change", onFileChange)
      		input.style.marginTop = "15px"
      		input.style.marginBottom = "15px"
      		var error = make(div, "div")
      		error.id = "file-error"
      		error.style.color = "darkred"
      		error.style.height = "15px"
      	}
      }
      var choose = {
      	signalId: "chooseFile",
      	type: "wbutton",
      	text: "MES_CHOOSE_FILE",
      	style: {
      		color: "white",
      		background: NormalBack,
      		padding: "12px",
      		textAlign: "center"
      	}
      }
      var confirm = {
      	signalId: "loadFile",
      	type: "wbutton",
      	text: "MES_LOAD_AND_REPLACE",
      	style: {
      		color: "white",
      		background: NormalBack,
      		padding: "12px",
      		textAlign: "center"
      	}
      }
      var cancel = {
      	signalId: "hideCentral",
      	type: "wbutton",
      	text: "MES_CANCEL",
      	style: {
      		color: "white",
      		background: DarkBackground,
      		padding: "12px",
      		textAlign: "center"
      	}
      }
      var root = {
      	type: "page",
      	style: {
      		background: "white"
      	},
      	padding: 10,
      	kids: [label, confirm, cancel]
      }
      addCentral(root, machine)
  }
  
  function showLogon(machine) {
      var ui = buildLogonGui()
      addCentral(ui, machine)
      get("username_edit").onkeydown = onUserDown
      get("password_edit").onkeydown = onPassDown
  }
  
  function showLogonSignup(machine) {
      var titleLabel = {
      	type: "wlabel",
      	text: "MES_SAVE_OWN",
      	textAlign: "center",
      	style: {
      		fontSize: "110%",
      		fontWeight: "bold"
      	}
      }
      var login = {
      	signalId: "login",
      	type: "wbutton",
      	text: "MES_LOGIN",
      	style: {
      		color: "white",
      		background: DarkBackground,
      		padding: "12px",
      		textAlign: "center"
      	}
      }
      var signup = {
      	signalId: "signup",
      	type: "wbutton",
      	text: "MES_SIGNUP",
      	style: {
      		color: "white",
      		background: DarkBackground,
      		padding: "12px",
      		textAlign: "center"
      	}
      }
      var cancel = {
      	type: "custom",
      	builder: function(div) {
      		div.style.textAlign = "center"
      		div.style.padding = "10px"
      		var a = make(div, "a")
      		HtmlUtils.setDivText(a, translate("MES_CANCEL"))
      		a.onclick = cancelMachine
      		a.href="javascript:;"
      	}
      }
      var root = {
      	type: "page",
      	style: {
      		background: "white"
      	},
      	padding: 10,
      	kids: [titleLabel, signup, login, cancel]
      }
      addCentral(root, machine)
  }
  
  function showMainMenu(menus) {
      var main = createPopup()
      main.style.opacity = 0
      main.style.transform = "translate(0px, -50px)"
      main.style.background = "white"
      main.style.color = "black"
      main.className = "popup appearing"
      addDrakonHubClosed(main)
      var header = make(main, "div")
      header.style.paddingLeft = "5px"
      header.style.paddingRight = "5px"
      header.style.paddingTop = "5px"
      var logo = make(header, "img")
      logo.draggable = false
      logo.width = 66
      logo.height = 66
      logo.src = getDrakosha()
      logo.style.verticalAlign = "middle"
      logo.style.cursor = "pointer"
      logo.onclick = hidePopup
      if (globs.wide) {
          var tlogo = make(header, "img")
          tlogo.draggable = false
          tlogo.width = 100
          tlogo.height = 40
          tlogo.src = getTextMenu()
          tlogo.style.verticalAlign = "middle"
      }
      var close = make(header, "img")
      close.draggable = false
      close.width = 30
      close.height = 30
      close.src = makeImagePath("cross.png")
      close.className = "common_button"
      close.style["float"] = "right"
      close.onclick = hidePopup
      close.style.cursor = "pointer"
      close.style.background = DarkBackground
      close.style.verticalAlign = "middle"
      if (globs.wide) {
          var menusDiv = make(main, "table")
          menusDiv.style.marginRight = "2px"
          var row = make(menusDiv, "tr")
          var _ind2347 = 0;
          var _col2347 = menus;
          var _len2347 = _col2347.length;
          while (true) {
              if (_ind2347 < _len2347) {
                  
              } else {
                  break;
              }
              var menu = _col2347[_ind2347];
              var td = make(row, "td")
              td.style.verticalAlign = "top"
              td.style.paddingLeft = "5px"
              td.style.paddingBottom = "4px"
              td.style.maxWidth="300px"
              addMenuSection(
              	td,
              	menu
              )
              _ind2347++;
          }
      } else {
          main.style.overflowY = "auto"
          var _ind2359 = 0;
          var _col2359 = menus;
          var _len2359 = _col2359.length;
          while (true) {
              if (_ind2359 < _len2359) {
                  
              } else {
                  break;
              }
              var menu = _col2359[_ind2359];
              var section = make(main, "div")
              section.style.paddingLeft = "5px"
              section.style.paddingRight = "5px"
              section.style.paddingBottom = "4px"
              addMenuSection(
              	section,
              	menu
              )
              _ind2359++;
          }
      }
      pushTempIfMobile()
      HtmlUtils.setPosCorrected(
      	0,
      	0,
      	main
      )
      main.style.opacity = 1
      main.style.transform = "translate(0px, 0px)"
  }
  
  function showMany(className, display) {
      display = display || "block"
      var elements = document.getElementsByClassName(className)
      var _ind2307 = 0;
      var _col2307 = elements;
      var _len2307 = _col2307.length;
      while (true) {
          if (_ind2307 < _len2307) {
              
          } else {
              break;
          }
          var element = _col2307[_ind2307];
          element.style.display = display
          _ind2307++;
      }
  }
  
  function showMobileInput(isAsync, header, old, onSave, validate) {
      var cancel = {
      	signalId: "cancelMachine",
      	type: "text_button",
      	text: "MES_CANCEL",
      	style: {
      		color: "white",
      		background: DarkBackground,
      		padding: "12px",
      		textAlign: "center",
      		borderRadius: "5px"
      	}
      }
      var save = {
      	signalId: "saveMobileInput",
      	type: "text_button",
      	text: "MES_SAVE",
      	style: {
      		color: "white",
      		background: "coral",
      		padding: "12px",
      		textAlign: "center",
      		borderRadius: "5px"
      	}
      }
      var header = {
      	type: "label",
      	text: header,
      	raw: true,
      	style: {fontSize: "80%"}
      }
      var buttons = {
      	type: "hdock",
      	height: 40,
      	lefts: [cancel],
      	rights: [save],
      	center: header
      }
      var error = {
      	type: "custom",
      	id: "mobile_input_error",
      	builder: function(div) {
      		div.style.color = "#900000"
      	}
      }
      var edit = {
      	type: "custom",	
      	builder: function(div) {
      		var input = makeTextArea(div)
      		input.style.height = "180px"
      		input.value = old
      		input.focus()
      		input.select()
      		input.id = "mob_input_edit"
      	}
      }
      var kids = [buttons, error, edit]
      var root = {
      	type: "page",
      	style: {
      		background: "white"
      	},
      	padding: 10,
      	kids: kids
      }
      createCentral(root, null)
      globs.mobileInput = true
      globs.mobileIsAsync = isAsync
      globs.mobileOnSave = onSave
      globs.mobileValidate = validate
  }
  
  function showNotification(text) {
      globs.pop.show(
      	translate(text)
      )
  }
  
  function showPopupList(parentId, items) {
      var parentDiv = get(parentId)
      new ToolTip(window, document).hideTooptip()
      var div = createPopupList(items)
      HtmlUtils.showUnder(parentDiv, div)
  }
  
  function showPopupListAt(x, y, items) {
      new ToolTip(window, document).hideTooptip()
      var div = createPopupList(items)
      HtmlUtils.setPosCorrected(x, y, div)
  }
  
  function showSaveProjectScreen(spaceId, machine) {
      var cancel = {
      	signalId: "cancelMachine",
      	type: "text_button",
      	text: "MES_CANCEL",
      	style: {
      		color: "white",
      		background: NormalBack,
      		padding: "12px",
      		textAlign: "center",
      		borderRadius: "5px"
      	}
      }
      var save = {
      	signalId: "saveProject",
      	type: "text_button",
      	text: "MES_SAVE",
      	style: {
      		color: "white",
      		background: SpecialBack,
      		padding: "12px",
      		textAlign: "center",
      		borderRadius: "5px"
      	}
      }
      var buttons = {
      	type: "hdock",
      	height: 40,
      	lefts: [cancel],
      	rights: [save]
      }
      var label = {
      	type: "custom",
      	builder: function(div) {
      		var top = make(div, "div")
      		HtmlUtils.setDivText(top, translate("MES_SAVE_TO_FILE"))
      		top.style.textAlign = "center"
      		var name = make(div, "div")
      		HtmlUtils.setDivText(name, translate("MES_SPACE") + ": " + spaceId)
      		name.style.textAlign = "center"
      		name.style.fontWeight = "bold"
      	}
      }
      var topPage = {
      	type: "page",
      	padding: 10,
      	kids: [label, buttons]
      }
      addCentral(topPage, machine)
  }
  
  function showShareScreen(spaceId, folderId, type, isPublic, isAdmin, machine) {
      var url = buildUrlForFolder(
      	spaceId,
      	folderId
      )
      var title
      if (type == "folder") {
          title = "MES_FOLDER_LINK"
      } else {
          title = "MES_DIAGRAM_LINK"
      }
      var titleLabel = {
      	type: "wlabel",
      	text: title,
      	textAlign: "center",
      	style: {
      		fontSize: "110%",
      		fontWeight: "bold"
      	}
      }
      var edit = {
      	type: "custom",
      	builder: function(div) {
      		var input = makeTextArea(div)
      		input.value = url
      		input.focus()
      		input.select()
      	}
      }
      var lab = {
      	type: "wlabel",
      	text: "MES_UNREGISTERED_CANT",
      	style: {
      		fontSize: "100%",
      		textAlign: "left"
      	}
      }
      var access = {
      	signalId: "accessForShare",
      	type: "wbutton",
      	text: "MES_ACCESS",
      	style: {
      		color: "white",
      		background: DarkBackground,
      		padding: "12px",
      		textAlign: "center"
      	}
      }
      var cancel = {
      	signalId: "cancelMachine",
      	type: "wbutton",
      	text: "MES_CANCEL",
      	style: {
      		color: "white",
      		background: DarkBackground,
      		padding: "12px",
      		textAlign: "center"
      	}
      }
      var kids = [titleLabel, edit]
      if (isPublic) {
          
      } else {
          kids.push(lab)
      }
      if (isAdmin) {
          kids.push(access)
      }
      kids.push(cancel)
      var root = {
      	type: "page",
      	style: {
      		background: "white"
      	},
      	padding: 10,
      	kids: kids
      }
      addCentral(root, machine)
  }
  
  function showSignup(machine) {
      var ui = buildSignupGui()
      addCentral(ui, machine)
      enableSignupOk()
  }
  
  function showWorking() {
      display("working", "block")
  }
  
  function startEdit(evt) {
      if (isEditorOn()) {
          HtmlUtils.preventDefaultHandling(evt)
          getEditor().startEdit()
      }
  }
  
  function startLogon() {
      logonCtrl.logon(
      	"username_edit",
      	"password_edit",
      	"status",
      	globs.myHandlers.login
      )
  }
  
  function startPan() {
      if ((globs.panning) || (!(isEditorOn()))) {
          
      } else {
          getEditor().startPan()
          globs.panning = true
      }
  }
  
  function startSignup() {
      if ((onPremises) || (get("signup_agree").checked)) {
          globs.signup = new Signup(
          	window, document, translate,
          	"signup_user", "signup_email",
          	"signup_password", "signup_password2",
          	"signup_status",
          	showWorking,
          	onSignupSuccess,
          	onSignupError,
          	false
          )
          globs.signup.update = resizeCentral
          globs.signup.signup("example")
      } else {
          onSignupError({error:"MES_AGREE"})
      }
  }
  
  function suggest(message, plan, ref) {
      var lab = {
      	type: "wlabel",
      	text: message,
      	style: {
      		fontSize: "100%",
      		textAlign: "left"
      	}
      }
      var buy = {
      	signalId: "removeLimit",
      	type: "wbutton",
      	text: "MES_GET_BETTER_PRODUCT",
      	style: {
      		color: "white",
      		background: "Coral",
      		fontSize:"120%",
      		padding: "12px",
      		textAlign: "center",
      		fontWeight: "bold"
      	}
      }
      var cancel = {
      	signalId: "hideCentral",
      	type: "wbutton",
      	text: "MES_CANCEL",
      	style: {
      		color: "white",
      		background: DarkBackground,
      		padding: "12px",
      		textAlign: "center"
      	}
      }
      var root = {
      	type: "page",
      	style: {
      		background: "white"
      	},
      	padding: 10,
      	kids: [lab, buy, cancel]
      }
      globs.plan = plan
      globs.ref = ref
      createCentral(root, null)
  }
  
  function toSearchResults(groupId) {
      globs.search.expanded = groupId
      globs.search.popup.innerHTML = ""
      if (groupId) {
          globs.search.expandedList = null
          var group = findSearchGroup(groupId)
          addExpandedGroup(
          	group.items
          )
      } else {
          globs.search.groupLists = {}
          var defs = globs.search.defs
          var _ind4348 = 0;
          var _col4348 = defs;
          var _len4348 = _col4348.length;
          while (true) {
              if (_ind4348 < _len4348) {
                  
              } else {
                  break;
              }
              var group = _col4348[_ind4348];
              if (group.items.length > 0) {
                  addFoundGroup(
                  	group,
                  	defs.completed,
                  	group.items
                  )
              }
              _ind4348++;
          }
      }
  }
  
  function trialAllowed() {
      if (((ServerVars.userId) && (!(ServerVars.hadTrial))) && (ServerVars.currentPlan == "basic")) {
          return true
      } else {
          return false
      }
  }
  
  function updateSignupButton() {
      if (get("signup_agree").checked) {
          enableSignupOk()
      } else {
          disableSignupOk()
      }
  }
  
  function upload(url, name, file, machine) {
      var req = new XMLHttpRequest()
      var formData = new FormData()
      req.onreadystatechange = function () {
          handleBasicStatusChange(machine, req)
      }
      formData.append(name, file);
      req.open("POST", url);
      req.send(formData)
  }
  
  function validateFolderName(name) {
      name = name || ""
      name = name.trim()
      if (name) {
          return null
      } else {
          return translate("ERR_EMPTY_NAME")
      }
  }
  
  function validateSpaceName(name) {
      name = name || ""
      name = name.trim()
      if (name) {
          var error = Utils.checkSpaceName(name)
          if (error) {
              return translate(error)
          } else {
              return null
          }
      } else {
          return translate("ERR_EMPTY_NAME")
      }
  }
  
  function wrapException(action, actionName) {
      var wrapped = function(arg1, arg2, arg3) {
      	try {
      		CallTrace.add(actionName, [])
      		action(arg1, arg2, arg3)
      	} catch (e) {
      		CallTrace.error(e)
      		panic(e)
      	}
      }
      return wrapped
  }
  
  
  globs = createState()
  self.widgets = globs.widgets
  
  logonCtrl.onError = resizeCentral
  
  
  exportMethod(this, init, "init")
  exportMethod(this, onResize, "onResize")
  exportMethod(this, orderResize, "orderResize")
  exportMethod(this, onStateChange, "onStateChange")
  exportMethod(this, onError, "onError")
  exportMethod(this, hideHelp, "hideHelp")
  
  
  
  this.getUrl = getUrl
  this.getWidth = getWidth
  this.getHeight = getHeight
  this.getPath = getPath
  this.onInitCompleted = onInitCompleted
  this.initControls = initControls
  
  this.panic = panic
  this.goToUrl = goToUrl
  this.setTimeout = setTimeout
  
  this.sendGet = sendGet
  this.sendPost = sendPost
  this.sendDelete = sendDelete
  this.sendPut = sendPut
  
  this.showWorking = showWorking
  this.hideWorking = hideWorking
  this.setTitle = setTitle
  
  this.showInputBox = showInputBox
  this.hideInputBox = hideInputBox
  this.setInputBoxError = setInputBoxError
  this.getEditor = getEditor
  this.loadFontCore = loadFontCore
  this.showNotification = showNotification
  this.placeFeedback = placeFeedback
  
  this.pushState = pushState
  
  this.createCentral = createCentral
  this.addCentral = addCentral
  this.hideCentral = hideCentral
  this.resizeCentral = resizeCentral
  
  this.showChooseTypeDialog = showChooseTypeDialog
  
  this.showPopupList = showPopupList
  this.showPopupListAt = showPopupListAt
  this.Clipboard = Clipboard
  this.showContextMenu = showContextMenu
  this.showAccessScreen = showAccessScreen
  
  this.suggest = suggest
  this.showShareScreen = showShareScreen
  
  this.saveAsPng = saveAsPng
  this.saveAsSvg = saveAsSvg
  this.logout = logout
  
  this.hideHelp = hideHelp
  this.showHelp = showHelp
  this.showMainMenu = showMainMenu
  this.schedule = schedule
  this.killCentral = killCentral
  this.showAddUserScreen = showAddUserScreen
  this.setAccessError = setAccessError
  this.setFoundUsers = setFoundUsers
  this.clearTimeout = clearTimeout
  this.showLogonSignup = showLogonSignup
  this.showLogon = showLogon
  this.startLogon = startLogon
  this.showSignup = showSignup
  this.scheduleNextStateAfter = scheduleNextStateAfter
  this.getExample = getExample
  this.preventQuestion = preventQuestion
  HtmlUtils.setErrorReporter(panic)
  this.setMobileHeader = setMobileHeader
  this.cancelSearch = cancelSearch
  this.createSearchList = createSearchList
  this.addToSearchList = addToSearchList
  this.trialAllowed = trialAllowed
  this.showDemo = showDemo
  this.isDemoDiscarded = isDemoDiscarded
  this.showSaveProjectScreen = showSaveProjectScreen
  this.showLoadFromFile = showLoadFromFile
  this.upload = upload
  this.downloadFile = downloadFile
  }
  