"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var shared_1 = require("./shared");
function createLocalStorage(options) {
    if (options === void 0) { options = {}; }
    var mode = options.mode || "auto";
    var actualMode = mode === "auto" ? shared_1.autoSelectMode() : mode;
    if (actualMode === "browser") {
        return window.localStorage;
    }
    else if (actualMode === "node") {
        var appRoot = require('app-root-path');
        var path = require("path");
        var LocalStorage = require('node-localstorage').LocalStorage;
        var defaultCacheDir = path.join(appRoot.toString(), ".cache");
        if (!options.storeFilePath) {
            var mkdirp = require('mkdirp');
            mkdirp.sync(defaultCacheDir);
        }
        var saveFilePath = options.storeFilePath ? options.storeFilePath : path.join(defaultCacheDir, "localstorage-ponyfill");
        return new LocalStorage(saveFilePath);
    }
    else if (actualMode === "memory") {
        return require("localstorage-memory");
    }
    throw new Error("Unknown mode:" + actualMode);
}
exports.createLocalStorage = createLocalStorage;
//# sourceMappingURL=index.js.map