 `import Save from '../models/save'`
+
+utf8_to_b64 = (str) ->
+    btoa encodeURIComponent escape str
+
+b64_to_utf8 = (str) ->
+    unescape decodeURIComponent atob str
 
 guid = (->
     s4 = ->

    defaultSerializer: '-rest'

    find: (store, type, id) -> new Promise (resolve, reject) ->
        key = getKey type, id
        json = localStorage.getItem key

        try
            result = { }
            hash = JSON.parse json
            hash.id = id
            result[type.typeKey] = hash
            resolve result

        record.set 'id', guid()
        serializer = store.serializerFor type.typeKey

        key = getKey record
        data = serializer.serialize record

        localStorage.setItem key, utf8_to_b64 JSON.stringify data
        resolve()

    updateRecord: (store, type, record) -> new Promise (resolve) ->
        serializer = store.serializerFor type.typeKey

        key = getKey record
        data = serializer.serialize record

        localStorage.setItem key, utf8_to_b64 JSON.stringify data
        resolve()

    deleteRecord: (store, type, record) ->
