   flushLog()
   return
 
+toggleSidebar = ->
+  sidebarOpen = false
+  if sidebarOpen
+    dump "closed sidebar from menu"
+    google.script.host.close()
+  else
+    dump "opened sidebar from menu"
+    SpreadsheetApp.getUi().showSidebar createSidebarHtml()
+  flushLog()
+  return
+
+createSitebarTemplate = ->
+  t = HtmlService.createTemplateFromFile 'sidebar.html'
+  dump "getCode #{t.getCode()}" if verbose
+  return t
+
+createSidebarHtml = ->
+  return createSitebarTemplate().evaluate()
+
+emitConfig = ->
+  html = []
+  namespace = properties.getProperty 'namespace'
+  for item in configDefinitions
+    n = item.name
+    d = item.desc
+    v = config[n]
+    dump "#{n} #{d} #{v} #{typeof v}" if trace
+    html.push switch typeof v
+      when 'boolean'
+        """
+        <div class="block">
+        <label for=\"#{n}\">
+          #{n}
+        </lable>
+        <input type="checkbox" name="config_#{n}" id="#{n}"
+        #{"checked" if config[n]} >
+        #{d}
+        </div>
+        """
+      when 'number' then ""
+      when 'string' then ""
+  dump "html #{html}" if verbose
+  return html.join '\n'
+
+
 initialize = (e) ->
   dump "initialize."
   readConfig()

  "Config"
]
logSheetName = "Log"
if SpreadsheetApp?
  spreadsheet = SpreadsheetApp.getActive()
  logSheet = spreadsheet.getSheetByName logSheetName
  properties = PropertiesService.getDocumentProperties()
  config = {}
  verbose = properties.getProperty "config.verbose"
  trace = properties.getProperty "config.trace"
  # todo: add to config
  # todo: create config sidebar, eliminate config sheet
  autoAddNewLines = true

    ScriptApp.getProjectTriggers().map (item) ->
      item.getHandlerFunction()
  dump "config %s", config
  dump "configDefinitions %s", configDefinitions
  dump properties.getProperty 'namespace'
  sheet = SpreadsheetApp.getActiveSheet()
  if sheet
