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Root":"","sourcesContent":["/**\n * Minified by jsDelivr using Terser v5.39.0.\n * Original file: /npm/camp@18.1.1/lib/camp.js\n *\n * Do NOT use SRI with dynamically generated files! More information: https://www.jsdelivr.com/using-sri-with-dynamic-files\n */\n","// Server-side Ajax handler that wraps around node.js.\n// Copyright © Thaddee Tyl, Jan Keromnes. All rights reserved.\n// Code covered by the LGPL license.\n\n\"use strict\";\n\nvar templateReader = require('fleau');\nvar formidable = require('formidable');\nvar WebSocket = require('ws');\nvar Cookies = require('cookies');\n\nvar EventEmitter = require ('events').EventEmitter;\nvar inherits = require('util').inherits;\nvar http = require('http');\nvar https = require('https');\nvar spdy = require('spdy');\nvar log = require('multilog');\nvar p = require('path');\nvar fs = require('fs');\nvar url = require('url');\nvar zlib = require('zlib');\nvar stream = require('stream');\nvar querystring = require('querystring');\n\n// Logs.\nlog.pipe('warn', 'all');\nlog.pipe('error', 'all');\nlog.pipe('error', 'stderr');\nlog.pipe('warn', 'stderr');\n\n\n\n\nvar mime = require('./mime.json');\nvar binaries = [\n      'pdf', 'ps', 'odt', 'ods', 'odp', 'xls', 'doc', 'ppt', 'dvi', 'ttf',\n      'swf', 'rar', 'zip', 'tar', 'gz', 'ogg', 'mp3', 'mpeg', 'wav', 'wma',\n      'gif', 'jpg', 'jpeg', 'png', 'svg', 'tiff', 'ico', 'mp4', 'ogv', 'mov',\n      'webm', 'wmv'\n];\nvar serverStartTime = new Date();\nvar serverStartTimeGMTString = serverStartTime.toGMTString();\n\n\n// Augment IncomingMessage and ServerResponse.\nfunction augmentReqRes(req, res, server) {\n  req.server = server;\n  req.uri = url.parse(req.url, true);\n  // The form is used for multipart data.\n  req.form = undefined;\n  try {\n    req.path = decodeURIComponent(req.uri.pathname);\n  } catch(e) {  // Using `escape` should not kill the server.\n    req.path = unescape(req.uri.pathname);\n  }\n  req.query = req.uri.query;\n  req.data = req.query;\n  // Check (and add fields) for basic authentication.\n  req.username = undefined;\n  req.password = undefined;\n  if (req.headers.authorization) {\n    var authorization = req.headers.authorization;\n    var authComponent = authorization.split(/\\s+/);\n    if (authComponent[0] === 'Basic') {\n      // Username / password.\n      if (typeof authComponent[1] === 'string' || authComponent[1] instanceof String) {\n        var up = Buffer.from(authComponent[1], 'base64').toString().split(':');\n        req.username = up[0];\n        req.password = up[1];\n      }\n    }\n  }\n  // Cookies\n  req.cookies = new Cookies(req, res);\n  // Templates\n  res.template = function(scope, templates) {\n    // If there is no template.\n    if (templates === undefined) {\n      // We assume that the template is for a file on disk under documentRoot.\n      var realpath = protectedPath(req.server.documentRoot, req.path);\n      templates = [server.template(realpath)];\n    }\n    // If there is only one template.\n    if (!(templates instanceof Array)) { templates = [templates]; }\n\n    if (templates.length > 0) {\n      res.mime(p.extname(templates[0].paths[0]).slice(1));\n    }\n    var templateStreams = templates.map(function(template) {\n      if (typeof template === 'string') {\n        return streamFromString(template);\n      } else if (typeof template === 'function') {\n        return template(scope);\n      } else {\n        log('Template ' + template + ' does not have a valid type', 'warn');\n        return streamFromString('');\n      }\n    });\n    var template = concatStreams(templateStreams);\n    template.on('error', function(err) {\n      log(err.stack, 'error');\n      res.end('Not Found\\n');\n    });\n    template.pipe(res.compressed());\n  };\n  // Sending a file\n  res.file = function(path) {\n    respondWithFile(req, res, path, function ifNoFile() {\n      log('The file \"' + path + '\", which was meant to be sent back, ' +\n          'was not found', 'error');\n      res.statusCode = 404;\n      res.end('Not Found\\n');\n    });\n  };\n  // Sending JSON data\n  res.json = function (data, replacer, space) {\n    res.setHeader('Content-Type', mime.json);\n    var json = JSON.stringify(data, replacer, space) + (space ? '\\n' : '');\n    res.compressed().end(json);\n  };\n  res.compressed = function() {\n    return getCompressedStream(req, res) || res;\n  };\n  res.redirect = function(path) {\n    res.setHeader('Location', path);\n    res.statusCode = 303;\n    res.end();\n  };\n}\n\n// Set a content type based on a file extension.\nhttp.ServerResponse.prototype.mime =\nfunction mimeFromExt(ext) {\n  this.setHeader('Content-Type', mime[ext] || 'text/plain');\n}\n\n// Ask is a model of the client's request / response environment.\n// It will be slowly deprecated.\nfunction Ask(server, req, res) {\n  this.server = server;\n  this.req = req;\n  this.res = res;\n  this.uri = req.uri;\n  this.form = req.form;\n  this.path = req.path;\n  this.query = req.query;\n  this.username = req.username;\n  this.password = req.password;\n  this.cookies = req.cookies;\n}\n\n// Set the mime type of the response.\nAsk.prototype.mime = function (type) {\n  this.res.setHeader('Content-Type', type);\n};\n\nfunction addToQuery(ask, obj) {\n  for (var item in obj) {\n    ask.query[item] = obj[item];\n  }\n}\n\nfunction jsonFromQuery(query, obj) {\n  obj = obj || Object.create(null);\n  // First attempt to decode the query as JSON\n  // (ie, 'foo=\"bar\"&baz={\"something\":\"else\"}').\n  try {\n    var items = query.split('&');\n    for (var i = 0; i < items.length; i++) {\n      // Each element of key=value is then again split along `=`.\n      var elems = items[i].split('=');\n      obj[decodeURIComponent(elems[0])] =\n        JSON.parse(decodeURIComponent(elems[1]));\n    }\n  } catch(e) {\n    // Couldn't parse as JSON.\n    try {\n      var newobj = querystring.parse(query);\n    } catch(e) {\n      log('Error while parsing query ', JSON.stringify(query) + '\\n'\n        + '(' + e.toString() + ')\\n'\n        , 'error');\n    }\n    var keys = Object.keys(newobj);\n    for (var i = 0; i < keys.length; i++) {\n      obj[keys[i]] = newobj[keys[i]];\n    }\n  }\n}\n\n// We'll need to parse the query as a literal.\n// Ask objects already have ask.query set after the URL query part.\n// This function updates ask.query with:\n// - application/x-www-form-urlencoded\n// - multipart/form-data\nfunction getQueries(req, end) {\n  var urlencoded = /^application\\/x-www-form-urlencoded/;\n  var multipart = /^multipart\\/form-data/;\n  var contentType = req.headers['content-type'] || '';\n\n  if (multipart.test(contentType)) {\n    // Multipart data.\n    req.form = req.form || new formidable.IncomingForm();\n    req.form.multiples = true;\n    req.form.parse(req, function(err, fields, files) {\n      req.fields = fields;\n      req.files = files;\n      // Ensure that files are arrays.\n      for (var key in req.files) {\n        if (!(req.files[key] instanceof Array)) {\n          req.files[key] = [req.files[key]];\n        }\n      }\n      if (err == null) {\n        addToQuery(req, req.fields);\n        addToQuery(req, req.files);\n      }\n      end(err);\n    });\n\n  } else if (urlencoded.test(contentType)) {\n    // URL encoded data.\n    var chunks;\n    var gotrequest = function (chunk) {\n      if (chunk !== undefined) {\n        if (chunks === undefined) {\n          chunks = chunk;\n        } else {\n          chunks = Buffer.concat([chunks, chunk]);\n        }\n      }\n    };\n    req.on('data', gotrequest);\n    req.on('end', function(err) {\n      if (req.server.saveRequestChunks) {\n        req.savedChunks = chunks;\n      }\n      var strquery = chunks? chunks.toString(): '';\n      jsonFromQuery(strquery, req.query);\n      end(err);\n    });\n  } else {\n    // URL query parameters.\n    var search = req.uri.search || '';\n    jsonFromQuery(search.slice(1), req.query);\n    end();\n  }\n}\n\n// Return a writable response stream, using compression when possible.\nfunction getCompressedStream(req, res) {\n  var encoding = req.headers['accept-encoding'] || '';\n  var stream;\n  var contentEncodingHeader = res.getHeader('Content-Encoding');\n  if ((contentEncodingHeader === 'gzip') || /\\bgzip\\b/.test(encoding)) {\n    if (!contentEncodingHeader) {\n      res.setHeader('Content-Encoding', 'gzip');\n    }\n    stream = zlib.createGzip();\n    stream.pipe(res);\n  } else if ((contentEncodingHeader === 'deflate') ||\n      /\\bdeflate\\b/.test(encoding)) {\n    if (!contentEncodingHeader) {\n      res.setHeader('Content-Encoding', 'deflate');\n    }\n    stream = zlib.createDeflate();\n    stream.pipe(res);\n  }\n  return stream;\n}\n\n// Concatenate an array of streams into a single stream.\nfunction concatStreams(array) {\n  var concat = new stream.PassThrough();\n\n  function pipe(i) {\n    if (i < array.length - 1) {\n      array[i].pipe(concat, {end: false});\n      array[i].on('end', function () { pipe(i + 1) });\n    } else {\n      array[i].pipe(concat);\n    }\n  }\n  if (array.length > 0) {\n    pipe(0);\n  }\n\n  return concat;\n}\n\n// paths: paths to templating file (String), or to an Array of templating files.\n// options:\n// - reader: template reader function.\n// - asString: use the string as a template, not as a file path.\n// - callback: function taking a function(scope) → readableStream.\n//   If you don't want the template creation to be synchronous, use this.\n//   We return nothing from the function if `callback` is set.\n// Returns a function(scope) → readableStream, unless `callback` is set.\nfunction template(paths, options) {\n  options = options || {};\n  var callback = options.callback;\n  var reader = options.reader || this.templateReader;\n\n  // Deal with a list of paths in the general case.\n  if (!(paths instanceof Array)) { paths = [paths]; }\n\n  var input = '';\n  if (!callback) {\n    for (var i = 0, pathLen = paths.length; i < pathLen; i++) {\n      if (options.asString) {\n        input += paths[i];\n      } else {\n        input += '' + fs.readFileSync(paths[i]);\n      }\n    }\n    var result = reader.create(input);\n    result.paths = paths;\n    return result;\n\n  } else {\n    // We have a callback.\n    var pathLen = paths.length;\n    var pathCounter = 0;\n    paths.forEach(function(path, i) {\n      if (options.asString) {\n        var getInput = function(cb) { cb(path); };\n      } else {\n        var getInput = function(cb) {\n          fs.readFile(path, function(err, string) {\n            if (err != null) {\n              log('Error reading template file:\\n' + err, 'error');\n              return cb('');\n            }\n            return cb('' + string);\n          });\n        };\n      }\n      getInput(function(fileInput) {\n        pathCounter++;\n        input += fileInput;\n\n        if (pathCounter >= pathLen) {\n          var result = reader.create(input);\n          result.paths = paths;\n          callback(result);\n        }\n      });\n    });\n  }\n}\n\n\n\n\n// Camp class is classy.\n//\n// Camp has a router function that returns the stack of functions to call, one\n// after the other, in order to process the request.\n\nfunction augmentServer(server, opts) {\n  server.templateReader = opts.templateReader || templateReader;\n  server.documentRoot = opts.documentRoot || p.join(process.cwd(), 'web');\n  server.saveRequestChunks = !!opts.saveRequestChunks;\n  server.template = template;\n  server.stack = [];\n  server.staticMaxAge = opts.staticMaxAge\n  server.stackInsertion = 0;\n  defaultRoute.forEach(function(mkfn) { server.handle(mkfn(server)); });\n  server.stackInsertion = 0;\n  server.on('request', function(req, res) { listener(server, req, res) });\n}\n\nfunction Camp(opts) {\n  http.Server.call(this);\n  augmentServer(this, opts);\n}\ninherits(Camp, http.Server);\n\nfunction SecureCamp(opts) {\n  https.Server.call(this, opts);\n  augmentServer(this, opts);\n}\ninherits(SecureCamp, https.Server);\n\nfunction SpdyCamp(opts) {\n  spdy.Server.call(this, opts);\n  augmentServer(this, opts);\n}\ninherits(SpdyCamp, spdy.Server);\n\nCamp.prototype.handle = SecureCamp.prototype.handle = SpdyCamp.prototype.handle =\nfunction handle(fn) {\n  this.stack.splice(this.stackInsertion, 0, fn);\n  this.stackInsertion++;\n};\n\nCamp.prototype.removeHandler = SecureCamp.prototype.removeHandler = SpdyCamp.prototype.removeHandler =\nfunction removeHandler(fn) {\n  var index = this.stack.indexOf(fn);\n  if (index < 0) { return; }\n  if (index < this.stackInsertion) {\n    this.stackInsertion--;\n  }\n  this.stack.splice(index, 1);\n};\n\n// Default request listener.\n\nfunction listener(server, req, res) {\n  augmentReqRes(req, res, server);\n  var ask = new Ask(server, req, res);\n  req.ask = ask;  // Legacy.\n  bubble(ask, 0);\n}\n\n// The bubble goes through each layer of the stack until it reaches the surface.\n// The surface is a Server Error, btw.\nfunction bubble(ask, layer) {\n  ask.server.stack[layer](ask.req, ask.res, function next() {\n    if (ask.server.stack.length > layer + 1) bubble(ask, layer + 1);\n    else {\n      ask.res.statusCode = 500;\n      ask.res.end('Internal Server Error\\n');\n    }\n  });\n}\n\n\n// On-demand loading of socket.io.\nCamp.prototype.socketIo = SecureCamp.prototype.socketIo = SpdyCamp.prototype.socketIo\n                        = null;\nvar socketIoProperty = {\n  get: function() {\n    if (this.socketIo === null) {\n      this.socketIo = require('socket.io')(this, {path: '/$socket.io'});\n      // Add socketUnit only once.\n      this.stack.unshift(socketUnit(this));\n    }\n    return this.socketIo;\n  },\n};\nObject.defineProperty(Camp.prototype,       'io', socketIoProperty);\nObject.defineProperty(SecureCamp.prototype, 'io', socketIoProperty);\nObject.defineProperty(SpdyCamp.prototype,   'io', socketIoProperty);\n\n\n\n// Generic unit. Deprecated.\nfunction genericUnit (server) {\n  var processors = [];\n  server.handler = function (f) { processors.push(f); };\n  return function genericLayer (req, res, next) {\n    for (var i = 0; i < processors.length; i++) {\n      var keep = processors[i](req.ask);\n      if (keep) { return; }  // Don't call next, nor the rest.\n    }\n    next();  // We never catch that request.\n  };\n}\n\n// Socket.io unit.\nfunction socketUnit (server) {\n  var io = server.io;\n  // Client-side: <script src=\"/$socket.io/socket.io.js\"></script>\n\n  return function socketLayer (req, res, next) {\n    // Socket.io doesn't care about anything but /$socket.io now.\n    if (req.path.slice(1, 11) !== '$socket.io') next();\n  };\n}\n\n// WebSocket unit.\nfunction wsUnit (server) {\n  var chanPool = server.wsChannels = {};\n  // Main WebSocket API:\n  // ws(channel :: String, conListener :: function(socket))\n  server.ws = function ws (channel, conListener) {\n    if (channel[0] !== '/') {\n      channel = '/$websocket:' + channel;  // Deprecated API.\n    }\n    if (chanPool[channel] !== undefined) {\n      chanPool[channel].close();\n    }\n    chanPool[channel] = new WebSocket.Server({\n      server: server,\n      path: channel,\n    });\n    chanPool[channel].on('connection', conListener);\n    return chanPool[channel];\n  };\n  // WebSocket broadcast API.\n  // webBroadcast(channel :: String, recvListener :: function(data, end))\n  server.wsBroadcast = function wsBroadcast (channel, recvListener) {\n    if (channel[0] === '/') {\n      return server.ws(channel, function (socket) {\n        socket.on('message', function wsBroadcastRecv (data, flags) {\n          recvListener({data: data, flags: flags}, {\n            send: function wsBroadcastSend (dataBack) {\n              chanPool[channel].clients.forEach(function (s) {\n                s.send(dataBack);\n              });\n            },\n          });\n        });\n      });\n    } else { // Deprecated API\n      return server.ws(channel, function (socket) {\n        socket.on('message', function wsBroadcastRecv (data, flags) {\n          recvListener(data, function wsBroadcastSend (dataBack) {\n            chanPool[channel].clients.forEach(function (s) { s.send(dataBack); });\n          });\n        });\n      });\n    }\n  };\n\n  return function wsLayer (req, res, next) {\n    // This doesn't actually get run, since ws overrides it at the root.\n    if (chanPool[req.path] === undefined) return next();\n  };\n}\n\n// Ajax unit.\nfunction ajaxUnit (server) {\n  var ajax = server.ajax = new EventEmitter();\n  // Register events to be fired before loading the ajax data.\n  var ajaxReq = server.ajaxReq = new EventEmitter();\n\n  return function ajaxLayer (req, res, next) {\n    if (req.path[1] !== '$') { return next(); }\n    var action = req.path.slice(2);\n\n    if (ajax.listeners(action).length <= 0) { return next(); }\n\n    res.setHeader('Content-Type', mime.json);\n\n    ajaxReq.emit(action, req.ask);\n    // Get all data requests.\n    getQueries(req, function(err) {\n      if (err == null) {\n        ajax.emit(action, req.query, function ajaxEnd(data) {\n          res.compressed().end(JSON.stringify(data || {}));\n        }, req.ask);\n      } else {\n        log('While parsing', req.url + ':\\n'\n          + err\n          , 'error');\n        return next();\n      }\n    });\n  };\n}\n\n\n// EventSource unit.\n//\n// Note: great inspiration was taken from Remy Sharp's code.\nfunction eventSourceUnit (server) {\n  var sources = {};\n\n  function Source () {\n    this.conn = [];\n    this.history = [];\n    this.lastMsgId = 0;\n  }\n\n  Source.prototype.removeConn = function(res) {\n    var i = this.conn.indexOf(res);\n    if (i !== -1) {\n      this.conn.splice(i, 1);\n    }\n  };\n\n  Source.prototype.sendSSE = function (res, id, event, message) {\n    var data = '';\n    if (event !== null) {\n      data += 'event:' + event + '\\n';\n    }\n\n    // Blank id resets the id counter.\n    if (id !== null) {\n      data += 'id:' + id + '\\n';\n    } else {\n      data += 'id\\n';\n    }\n\n    if (message) {\n      data += 'data:' + message.split('\\n').join('\\ndata:') + '\\n';\n    }\n    data += '\\n';\n\n    res.write(data);\n\n    if (res.hasOwnProperty('xhr')) {\n      clearTimeout(res.xhr);\n      var self = this;\n      res.xhr = setTimeout(function () {\n        res.end();\n        self.removeConn(res);\n      }, 250);\n    }\n  };\n\n  Source.prototype.emit = function (event, msg) {\n    this.lastMsgId++;\n    this.history.push({\n      id: this.lastMsgId,\n      event: event,\n      msg: msg\n    });\n\n    for (var i = 0; i < this.conn.length; i++) {\n      this.sendSSE(this.conn[i], this.lastMsgId, event, msg);\n    }\n  }\n\n  Source.prototype.send = function (msg) {\n    this.emit(null, JSON.stringify(msg));\n  }\n\n  function eventSource (channel) {\n    if (channel[0] !== '/') { channel = '/$' + channel; }\n    return sources[channel] = new Source();\n  }\n\n  server.eventSource = eventSource;\n\n\n  return function eventSourceLayer (req, res, next) {\n    if (sources[req.path] === undefined) return next();\n    var source = sources[req.path];\n    if (!source || req.headers.accept !== 'text/event-stream')\n      return next();    // Don't bother if the client cannot handle it.\n\n    // Remy Sharp's Polyfill support.\n    if (req.headers['x-requested-with'] == 'XMLHttpRequest') {\n      res.xhr = null;\n    }\n\n    res.setHeader('Content-Type', 'text/event-stream');\n    res.setHeader('Cache-Control', 'no-cache');\n\n    if (req.headers['last-event-id']) {\n      var id = parseInt(req.headers['last-event-id']);\n      for (var i = 0; i < source.history.length; i++)\n        if (source.history[i].id > id)\n          source.sendSSE(res, source.history[i].id,\n              source.history[i].event, source.history[i].msg);\n    } else res.write('id\\n\\n');      // Reset id.\n\n    source.conn.push(res);\n\n    // Every 15s, send a comment (avoids proxy dropping HTTP connection).\n    var to = setInterval(function () {res.write(':\\n');}, 15000);\n\n    // This can only end in blood.\n    req.on('close', function () {\n      source.removeConn(res);\n      clearInterval(to);\n    });\n  };\n}\n\nfunction protectedPath(documentRoot, path) {\n  return p.join(documentRoot, p.join('/', path));\n}\n\nfunction setHeadersForCacheLength(res, cacheLengthSeconds) {\n  const now = new Date();\n  const cacheControl = `max-age=${cacheLengthSeconds}, s-maxage=${cacheLengthSeconds}`;\n  const expires = new Date(now.getTime() + cacheLengthSeconds * 1000).toGMTString();\n\n  res.setHeader('Cache-Control', cacheControl);\n  res.setHeader('Expires', expires);\n}\n\n// End the response `res` with file at path `path`.\n// If the file does not exist, we call `ifNoFile()`.\nfunction respondWithFile(req, res, path, ifNoFile) {\n  ifNoFile = ifNoFile || function() {};\n  // We use `documentRoot` as the root wherein we seek files.\n  var realpath = protectedPath(req.server.documentRoot, path);\n  fs.stat(realpath, function(err, stats) {\n    if (err) return ifNoFile();\n\n    if (stats.isDirectory()) {\n      realpath = p.join(realpath, 'index.html');\n    }\n    res.mime(p.extname(realpath).slice(1));\n\n    if (req.server.staticMaxAge) {\n      setHeadersForCacheLength(res, req.server.staticMaxAge);\n    }\n\n    // Cache management (compare timestamps at second-level precision).\n    var since = req.headers['if-modified-since'];\n    if (since && (Math.floor(serverStartTime / 1000) <= Math.floor(new Date(since) / 1000))) {\n      res.statusCode = 304; // not modified.\n      res.end();\n      return;\n    }\n    res.setHeader('Last-Modified', serverStartTimeGMTString);\n\n    // Connect the output of the file to the network!\n    var raw = fs.createReadStream(realpath);\n    raw.on('error', function(err) {\n      log(err.stack, 'error');\n      res.statusCode = 404;\n      res.end('Not Found\\n');\n    });\n    raw.pipe(res.compressed());\n  });\n}\n\n// Static unit.\nfunction staticUnit (server) {\n  return function staticLayer (req, res, next) {\n    respondWithFile(req, res, req.path, next);\n  };\n}\n\nfunction escapeRegex(string) {\n  return string.replace(/[-\\/\\\\^$+?.()|[\\]{}]/g, '\\\\$&');\n}\n\n// Convert a String to a RegExp, escaping everything.\n// Make * stand for anything and :foo be a named non-slash placeholder.\n// ** is a star, :: is a colon.\nfunction regexFromString(string) {\n  var r = /::|\\*\\*|:[a-zA-Z_]+|\\*/g;\n  var match;\n  var regexString = '^';\n  var previousIndex = 0;\n  var regexKeys = [];\n  var starKey = 0;\n  while ((match = r.exec(string)) !== null) {\n    var matched = match[0];\n    var index = match.index;\n    regexString += escapeRegex(string.slice(previousIndex, index));\n    previousIndex = index;\n    if (matched === '**') {\n      regexString += '\\\\*\\\\*';\n      previousIndex += 2;\n    } else if (matched === '::') {\n      regexString += '::';\n      previousIndex += 2;\n    } else if (matched === '*') {\n      regexString += '(.*)';\n      regexKeys.push(starKey);\n      previousIndex += 1;\n      starKey++;\n    } else {  // :foo\n      regexString += '([^/]+)';\n      regexKeys.push(matched.slice(1));\n      previousIndex += matched.length;\n    }\n  }\n  regexString += escapeRegex(string.slice(previousIndex)) + '$';\n  var regex = new RegExp(regexString);\n  regex.keys = regexKeys;\n  return regex;\n}\n\nfunction Path(matcher) {\n  this.matcher = matcher;\n  if (matcher instanceof RegExp) {\n    this.match = function(path) {\n      return path.match(matcher);\n    };\n  } else if (typeof matcher === 'string') {\n    if (matcher[0] !== '/' && matcher[0] !== '*') {\n      matcher = '/' + matcher;\n    }\n    if (/[:*]/.test(matcher)) {\n      matcher = regexFromString(matcher);\n    }\n\n    // Takes a String path. If the matcher doesn't match it, return null;\n    // otherwise, return an object mapping keys (from the matcher) to the String\n    // corresponding to it in the path. Matchers like :foo have key 'foo',\n    // matchers like * have an integer key starting from 0.\n    this.match = function(path) {\n      var matched;\n      if ((typeof matcher === 'string') && (path === matcher)) {\n        return {};\n      } else if ((matcher instanceof RegExp)\n        && (matched = matcher.exec(path))) {\n        var data = {};\n        for (var i = 0; i < matcher.keys.length; i++) {\n          var key = matcher.keys[i];\n          var value = matched[i + 1];\n          data[key] = value;\n        }\n        return data;\n      } else { return null; }\n    };\n  }\n}\n\n// Path-like unit.\n//\n// The optional `httpMethods` array allows specifying which HTTP methods should\n// have their own specific helpers like `server.get()`, `server.post()`, etc.\n// Warning: Calling `pathLikeUnit` several times with the same HTTP methods will\n// overwrite any corresponding `server[method]` helpers!\nfunction pathLikeUnit(serverMethod, statusCode, httpMethods) {\n  httpMethods = httpMethods || [];\n  return function pathLikeUnit(server) {\n    var callbacks = [];\n\n    var addCallback = function (path, callback) {\n      callbacks.push({\n        path: new Path(path),\n        methods: null,\n        callback: callback\n      });\n    };\n    server[serverMethod] = addCallback;\n\n    // HTTP method-specific helpers like server.get(), server.post(), etc.\n    httpMethods.forEach(function (method) {\n      server[method.toLowerCase()] = function (path, callback) {\n        callbacks.push({\n          path: new Path(path),\n          methods: [method],\n          callback: callback\n        });\n      };\n    });\n\n    return function pathLayer (req, res, next) {\n      var pathLen = callbacks.length;\n      var matched = null;\n      var cbindex = -1;\n      for (var i = 0; i < pathLen; i++) {\n        matched = callbacks[i].path.match(req.path);\n        if (matched == null) {\n          continue;\n        }\n        var methods = callbacks[i].methods;\n        if (methods != null && methods.indexOf(req.method) === -1) {\n          continue;\n        }\n        cbindex = i; break;\n      }\n      if (cbindex >= 0) {\n        getQueries(req, function(err) {\n          if (err != null) {\n            log('While getting queries for ' + req.url + ' in pathUnit:\\n'\n              + err.stack, 'error');\n          }\n          for (var key in matched) {\n            req.data[key] = matched[key];\n          }\n          res.statusCode = statusCode;\n          var cb = callbacks[cbindex] && callbacks[cbindex].callback;\n          if (cb != null) {\n            cb(req, res);\n          } else {\n            res.template(req.data);\n          }\n        });\n      } else { next(); }\n    };\n  };\n}\nvar pathUnit = pathLikeUnit('path', 200, http.METHODS);\nvar notFoundUnit = pathLikeUnit('notFound', 404);\n\n// Template unit.\nfunction routeUnit (server) {\n  var regexes = [];\n  var callbacks = [];\n\n  function route (paths, literalCall) {\n    regexes.push(RegExp(paths));\n    callbacks.push(literalCall);\n  }\n\n  server.route = route;\n\n  return function routeLayer (req, res, next) {\n    var matched = null;\n    var cbindex = -1;\n    for (var i = 0; i < regexes.length; i++) {\n      matched = req.path.match (regexes[i]);\n      if (matched !== null) { cbindex = i; break; }\n    }\n    if (cbindex >= 0) {\n      catchpath(req, res, matched, callbacks[cbindex], server.templateReader);\n    } else {\n      next();\n    }\n  };\n}\n\n// Not Fount unit — in fact, mostly a copy&paste of the route unit.\nfunction notfoundUnit (server) {\n  var regexes = [];\n  var callbacks = [];\n\n  function notfound (paths, literalCall) {\n    regexes.push(RegExp(paths));\n    callbacks.push(literalCall);\n  }\n\n  server.notfound = notfound;\n\n  return function notfoundLayer (req, res) {\n    res.statusCode = 404;\n    var matched = null;\n    var cbindex = -1;\n    for (var i = 0; i < regexes.length; i++) {\n      matched = req.path.match (regexes[i]);\n      if (matched !== null) { cbindex = i; break; }\n    }\n    if (cbindex >= 0) {\n      catchpath(req, res, matched, callbacks[cbindex], server.templateReader);\n    } else {\n      res.end('Not Found\\n');\n    }\n  };\n}\n\n// Route *and* not found units — see what I did there?\n\nfunction catchpath (req, res, pathmatch, callback, templateReader) {\n  getQueries(req, function gotQueries(err) {\n    if (err != null) {\n      log('While getting queries for ' + req.uri + ':\\n'\n        + err\n        , 'error');\n    } else {\n      // params: template parameters (JSON-serializable).\n      callback(req.query, pathmatch, function end (params, options) {\n        options = options || {};\n        var templates = options.template || pathmatch[0];\n        var reader = options.reader || templateReader;\n        if (Object(options.string) instanceof String) {\n          templates = [streamFromString(options.string)];\n        } else if (Object(params) instanceof String) {\n          templates = [streamFromString(params)];\n        } else if (!Array.isArray(templates)) {\n          templates = [templates];\n        }\n        if (!res.getHeader('Content-Type')  // Allow overriding.\n            && (Object(templates[0]) instanceof String)) {\n          res.mime(p.extname(templates[0]).slice(1));\n        }\n        for (var i = 0; i < templates.length; i++) {\n          if (Object(templates[i]) instanceof String) {\n            // `templates[i]` is a string path for a file.\n            var templatePath = p.join(req.server.documentRoot, templates[i]);\n            templates[i] = fs.createReadStream(templatePath);\n          }\n        }\n\n        var template = concatStreams(templates);\n\n        template.on('error', function(err) {\n          log(err.stack, 'error');\n          res.end('Not Found\\n');\n        });\n\n        if (params === null || reader === null) {\n          // No data was given. Same behaviour as static.\n          template.pipe(res);\n        } else {\n          reader(template, res, params, function errorcb(err) {\n            if (err) {\n              log(err.stack, 'error');\n              res.end('Not Found\\n');\n            }\n          });\n        }\n      }, req.ask);\n    }\n  });\n}\n\n// The default routing function:\n//\n// - if the request is of the form /$socket.io, it runs the socket.io unit.\n//   (By default, that is not in. Using `server.io` loads the library.)\n// - if the request is of the form /$websocket:, it runs the websocket unit.\n// - if the request is of the form /$..., it runs the ajax / eventSource unit.\n// - if the request is a registered template, it runs the template unit.\n// - if the request isn't a registered route, it runs the static unit.\n// - else, it runs the notfound unit.\n\nvar defaultRoute = [genericUnit, wsUnit, ajaxUnit, eventSourceUnit,\n                    pathUnit, routeUnit, staticUnit,\n                    notFoundUnit, notfoundUnit];\n\nfunction streamFromString(string) {\n  var sstream = new stream.Readable();\n  sstream._read = function() { sstream.push(string); sstream.push(null); };\n  return sstream;\n}\n\n\n\n\n\n\n// Internal start function.\n//\n\nfunction createServer () { return new Camp(); }\n\nfunction createSecureServer (opts) { return new SecureCamp(opts); }\n\nfunction createSpdyServer (opts) { return new SpdyCamp(opts); }\n\nvar KEY_HEADER = /^-+BEGIN \\w+ PRIVATE KEY-+/;\nvar CERT_HEADER = /^-+BEGIN CERTIFICATE-+/;\nfunction createServerWithSettings (settings) {\n  var server;\n  settings.hostname = settings.hostname || '::';\n\n  // Are we running https?\n  if (settings.secure) { // Yep\n    var key, cert;\n    if (KEY_HEADER.test(settings.key)) {\n      key = settings.key;\n    } else {\n      key = fs.readFileSync(settings.key);\n    }\n    if (CERT_HEADER.test(settings.cert)) {\n      cert = settings.cert;\n    } else {\n      cert = fs.readFileSync(settings.cert);\n    }\n    settings.key  = key;\n    settings.cert = cert;\n    settings.ca   = settings.ca.map(function(file) {\n      try {\n        var ca;\n        if (CERT_HEADER.test(file)) {\n          ca = file;\n        } else {\n          ca = fs.readFileSync(file);\n        }\n        return ca;\n      } catch (e) { log('CA file not found: ' + file, 'error'); }\n    });\n    if (settings.spdy === false) {\n      server = new SecureCamp(settings);\n    } else {\n      server = new SpdyCamp(settings);\n    }\n  } else { // Nope\n    server = new Camp(settings);\n  }\n  if (settings.setuid) {\n    server.on('listening', function switchuid() {\n      process.setuid(settings.setuid);\n    });\n  }\n\n  server.listenAsConfigured = function() {\n    return this.listen(settings.port, settings.hostname);\n  }\n\n  return server;\n}\n\n\n// Each camp instance creates an HTTP / HTTPS server automatically.\n//\nfunction create (settings) {\n\n  settings = settings || {};\n\n  // Populate security values with the corresponding files.\n  if (settings.secure) {\n    settings.passphrase = settings.passphrase || '1234';\n    settings.key = settings.key || 'https.key';\n    settings.cert = settings.cert || 'https.crt';\n    settings.ca = settings.ca || [];\n  }\n\n  settings.port = settings.port || (settings.secure ? 443 : 80);\n\n  return createServerWithSettings(settings);\n};\n\nfunction start (settings) {\n  return create(settings).listenAsConfigured();\n}\n\n\nexports.create = create;\nexports.start = start;\nexports.createServer = createServer;\nexports.createSecureServer = createSecureServer;\nexports.Camp = Camp;\nexports.SecureCamp = SecureCamp;\nexports.SpdyCamp = SpdyCamp;\n\nexports.genericUnit = genericUnit;\nexports.socketUnit = socketUnit;\nexports.wsUnit = wsUnit;\nexports.ajaxUnit = ajaxUnit;\nexports.eventSourceUnit = eventSourceUnit;\nexports.pathUnit = pathUnit;\nexports.routeUnit = routeUnit;\nexports.staticUnit = staticUnit;\nexports.notfoundUnit = notfoundUnit;\n\nexports.template = template;\nexports.templateReader = templateReader;\nexports.augmentReqRes = augmentReqRes;\nexports.mime = mime;\nexports.binaries = binaries;\nexports.log = log;\n"]}