Socket
Socket
Sign inDemoInstall

@sanity/client

Package Overview
Dependencies
Maintainers
6
Versions
986
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@sanity/client - npm Package Compare versions

Comparing version 0.2.9 to 0.2.10

31

lib/data/dataMethods.js

@@ -14,3 +14,3 @@ 'use strict';

// Always return IDs
{ returnIds: true },
{ returnIDs: true },

@@ -51,8 +51,9 @@ // Allow user to disable returning documents

validators.validateDocumentId('delete', documentId);
return this.dataRequest('mutate', { delete: { id: documentId } });
return this.dataRequest('mutate', { mutations: [{ delete: { id: documentId } }] });
},
mutate: function mutate(mutations, options) {
var body = mutations instanceof Patch ? mutations.serialize() : mutations;
var mut = mutations instanceof Patch ? mutations.serialize() : mutations;
var muts = Array.isArray(mut) ? mut : [mut];
return this.dataRequest('mutate', body, options);
return this.dataRequest('mutate', { mutations: muts }, options);
},

@@ -74,2 +75,3 @@ transaction: function transaction(operations) {

var stringQuery = useGet ? strQuery : '';
var returnFirst = options.returnFirst;

@@ -89,3 +91,15 @@ return validators.promise.hasDataset(this.clientConfig).then(function (dataset) {

return options.returnDocuments === false ? { transactionId: res.transactionId, documentId: getMutatedId(res) } : res.documents && res.documents[0];
var results = res.results || [];
if (options.returnDocuments) {
return returnFirst ? results[0] && results[0].document : results.map(function (mut) {
return mut.document;
});
}
// Only return IDs
var key = returnFirst ? 'documentId' : 'documentIds';
var ids = returnFirst ? results[0] && results[0].id : results.map(function (mut) {
return mut.id;
});
return _defineProperty({ transactionId: res.transactionID }, key, ids);
});

@@ -98,9 +112,6 @@ },

var mutation = _defineProperty({}, op, assign({}, doc, { _id: doc._id || dataset + '/' }));
return this.dataRequest('mutate', mutation, options);
var opts = assign({ returnFirst: true, returnDocuments: true }, options);
return this.dataRequest('mutate', { mutations: [mutation] }, opts);
}
};
function getMutatedId(res) {
return res.createdIds && res.createdIds[0] || res.updatedIds && res.updatedIds[0];
}
//# sourceMappingURL=dataMethods.js.map

@@ -1,2 +0,2 @@

'use strict';
"use strict";

@@ -10,10 +10,6 @@ var enc = encodeURIComponent;

if (params.query) {
throw new Error('Parameter "query" is reserved, cannot be used as a parameter');
}
return Object.keys(params).reduce(function (qs, param) {
return qs + '&' + enc(param) + '=' + enc(JSON.stringify(params[param]));
}, '?query=' + enc(query));
return qs + "&" + enc("$" + param) + "=" + enc(JSON.stringify(params[param]));
}, "?query=" + enc(query));
};
//# sourceMappingURL=encodeQueryString.js.map

@@ -81,3 +81,5 @@ 'use strict';

return this.client.mutate({ patch: this.serialize() }, options);
var returnFirst = typeof this.selection === 'string';
var opts = assign({ returnFirst: returnFirst, returnDocuments: true }, options);
return this.client.mutate({ patch: this.serialize() }, opts);
},

@@ -90,15 +92,5 @@ reset: function reset() {

return this.clone(_defineProperty({}, op, assign({}, this.operations[op] || {}, props)));
},
then: throwPromiseError('then'),
catch: throwPromiseError('catch')
}
});
function throwPromiseError(op) {
return function () {
throw new Error(op + '() called on an uncommited patch, did you forget to call commit()?');
};
}
function getSelection(sel) {

@@ -105,0 +97,0 @@ if (typeof sel === 'string' || Array.isArray(sel)) {

@@ -88,16 +88,6 @@ 'use strict';

return this.clone(mut);
},
then: throwPromiseError('then'),
catch: throwPromiseError('catch')
}
});
function throwPromiseError(op) {
return function () {
throw new Error(op + '() called on an uncommited transaction, did you forget to call commit()?');
};
}
module.exports = Transaction;
//# sourceMappingURL=transaction.js.map

@@ -22,4 +22,4 @@ 'use strict';

log('HTTP %s %s', options.method || 'GET', options.uri);
if (options.method === 'POST' && options.json) {
log('Request body: %s', JSON.stringify(options.json, null, 2));
if (options.method === 'POST' && options.body) {
log('Request body: %s', JSON.stringify(options.body, null, 2));
}

@@ -26,0 +26,0 @@ }

@@ -32,3 +32,3 @@ 'use strict';

exports.validateDocumentId = function (op, id) {
if (typeof id !== 'string' || !/^[-\w]{1,128}\/[-_a-z0-9]+$/i.test(id)) {
if (typeof id !== 'string' || !/^[-_a-z0-9]{1,128}\/[-_a-z0-9\/]+$/i.test(id)) {
throw new Error(op + '() takes a document ID in format dataset/docId');

@@ -35,0 +35,0 @@ }

{
"name": "@sanity/client",
"version": "0.2.9",
"version": "0.2.10",
"description": "Client for retrieving data from Sanity",

@@ -5,0 +5,0 @@ "main": "lib/sanityClient.js",

@@ -10,2 +10,3 @@ // (Node 4 compat)

const sanityClient = require('../src/sanityClient')
const validators = require('../src/validators')
const noop = () => {} // eslint-disable-line no-empty-function

@@ -19,2 +20,3 @@

const fixture = name => path.join(__dirname, 'fixtures', name)
const skipTestOnCI = process.env.CI ? test.skip : test

@@ -85,2 +87,9 @@ /*****************

test('validation', t => {
t.doesNotThrow(() => validators.validateDocumentId('op', 'foo/bar'), /document ID in format/, 'does not throw on valid ID')
t.doesNotThrow(() => validators.validateDocumentId('op', 'foo/bar/baz'), /document ID in format/, 'does not throw on valid ID')
t.throws(() => validators.validateDocumentId('op', 'blahblah'), /document ID in format/, 'throws on invalid ID')
t.end()
})
/*****************

@@ -150,5 +159,5 @@ * PROJECTS *

test('can query for documents', t => {
const query = 'beerfiesta.beer[.title == %beerName]'
const query = 'beerfiesta.beer[.title == $beerName]'
const params = {beerName: 'Headroom Double IPA'}
const qs = 'beerfiesta.beer%5B.title%20%3D%3D%20%25beerName%5D&beerName=%22Headroom%20Double%20IPA%22'
const qs = 'beerfiesta.beer%5B.title%20%3D%3D%20%24beerName%5D&%24beerName=%22Headroom%20Double%20IPA%22'

@@ -178,3 +187,6 @@ nock(projectHost()).get(`/v1/data/query/foo?query=${qs}`).reply(200, {

getClient().fetch('area51')
.then(res => t.fail('Resolve handler should not be called on failure'))
.then(res => {
t.fail('Resolve handler should not be called on failure')
t.end()
})
.catch(err => {

@@ -208,3 +220,6 @@ t.ok(err instanceof Error, 'should be error')

getClient().getDocument('foo/127')
.then(res => t.fail('Resolve handler should not be called on failure'))
.then(res => {
t.fail('Resolve handler should not be called on failure')
t.end()
})
.catch(err => {

@@ -222,3 +237,6 @@ t.ok(err instanceof Error, 'should be error')

getClient().getDocument('foo/123')
.then(res => t.fail('Resolve handler should not be called on failure'))
.then(res => {
t.fail('Resolve handler should not be called on failure')
t.end()
})
.catch(err => {

@@ -235,3 +253,6 @@ t.ok(err instanceof Error, 'should be error')

getClient().getDocument('foo/123')
.then(res => t.fail('Resolve handler should not be called on failure'))
.then(res => {
t.fail('Resolve handler should not be called on failure')
t.end()
})
.catch(err => {

@@ -247,3 +268,6 @@ t.ok(err instanceof Error, 'should be error')

sanityClient({projectId: 'foo'}).fetch('blah')
.then(res => t.fail('Resolve handler should not be called on failure'))
.then(res => {
t.fail('Resolve handler should not be called on failure')
t.end()
})
.catch(err => {

@@ -259,6 +283,9 @@ t.ok(err instanceof Error, 'should be error')

nock(projectHost()).post('/v1/data/mutate/foo?returnIds=true&returnDocuments=true', {create: doc}).reply(200, {
transactionId: 'abc123',
createdIds: ['foo/123'],
documents: [{_id: 'foo/123', _createdAt: '2016-10-24T08:09:32.997Z', name: 'Raptor'}]
nock(projectHost()).post('/v1/data/mutate/foo?returnIDs=true&returnDocuments=true', {mutations: [{create: doc}]})
.reply(200, {
transactionID: 'abc123',
results: [{
document: {_id: 'foo/123', _createdAt: '2016-10-24T08:09:32.997Z', name: 'Raptor'},
operation: 'create'
}]
})

@@ -277,8 +304,10 @@

const doc = {name: 'Raptor'}
const expectedBody = {create: Object.assign({}, doc, {_id: 'foo/'})}
nock(projectHost()).post('/v1/data/mutate/foo?returnIds=true&returnDocuments=true', expectedBody)
const expectedBody = {mutations: [{create: Object.assign({}, doc, {_id: 'foo/'})}]}
nock(projectHost()).post('/v1/data/mutate/foo?returnIDs=true&returnDocuments=true', expectedBody)
.reply(200, {
transactionId: '123abc',
createdIds: ['foo/456'],
documents: [{_id: 'foo/456', name: 'Raptor'}]
transactionID: '123abc',
results: [{
id: 'foo/456',
document: {_id: 'foo/456', name: 'Raptor'}
}]
})

@@ -296,4 +325,4 @@

const doc = {_id: 'foo/123', name: 'Raptor'}
nock(projectHost()).post('/v1/data/mutate/foo?returnIds=true', {create: doc})
.reply(200, {transactionId: 'abc123', createdIds: ['foo/123']})
nock(projectHost()).post('/v1/data/mutate/foo?returnIDs=true', {mutations: [{create: doc}]})
.reply(200, {transactionID: 'abc123', results: [{id: 'foo/123', operation: 'create'}]})

@@ -311,6 +340,6 @@ getClient().create(doc, {returnDocuments: false})

const doc = {_id: 'foo/123', name: 'Raptor'}
const expectedBody = {mutations: [{createIfNotExists: doc}]}
nock(projectHost()).post('/v1/data/mutate/foo?returnIDs=true&returnDocuments=true', expectedBody)
.reply(200, {transactionID: '123abc', results: [{id: 'foo/123', document: doc, operation: 'create'}]})
nock(projectHost()).post('/v1/data/mutate/foo?returnIds=true&returnDocuments=true', {createIfNotExists: doc})
.reply(200, {transactionId: '123abc', createdIds: ['foo/123']})
getClient().createIfNotExists(doc).then(() => t.end()).catch(t.ifError)

@@ -321,4 +350,5 @@ })

const doc = {_id: 'foo/123', name: 'Raptor'}
nock(projectHost()).post('/v1/data/mutate/foo?returnIds=true', {createIfNotExists: doc})
.reply(200, {transactionId: 'abc123', createdIds: ['foo/123']})
const expectedBody = {mutations: [{createIfNotExists: doc}]}
nock(projectHost()).post('/v1/data/mutate/foo?returnIDs=true', expectedBody)
.reply(200, {transactionID: 'abc123', results: [{id: 'foo/123', operation: 'create'}]})

@@ -336,6 +366,6 @@ getClient().createIfNotExists(doc, {returnDocuments: false})

const doc = {_id: 'foo/123', name: 'Raptor'}
const expectedBody = {mutations: [{createOrReplace: doc}]}
nock(projectHost()).post('/v1/data/mutate/foo?returnIDs=true&returnDocuments=true', expectedBody)
.reply(200, {transactionID: '123abc', results: [{id: 'foo/123', operation: 'create'}]})
nock(projectHost()).post('/v1/data/mutate/foo?returnIds=true&returnDocuments=true', {createOrReplace: doc})
.reply(200, {transactionId: '123abc', createdIds: ['foo/123']})
getClient().createOrReplace(doc).then(() => t.end()).catch(t.ifError)

@@ -346,4 +376,5 @@ })

const doc = {_id: 'foo/123', name: 'Raptor'}
nock(projectHost()).post('/v1/data/mutate/foo?returnIds=true', {createOrReplace: doc})
.reply(200, {transactionId: 'abc123', createdIds: ['foo/123']})
const expectedBody = {mutations: [{createOrReplace: doc}]}
nock(projectHost()).post('/v1/data/mutate/foo?returnIDs=true', expectedBody)
.reply(200, {transactionID: 'abc123', results: [{id: 'foo/123', operation: 'create'}]})

@@ -359,20 +390,7 @@ getClient().createOrReplace(doc, {returnDocuments: false})

test('createOrReplace() returns document ID if document was replaced', t => {
const doc = {_id: 'foo/123', name: 'Raptor'}
nock(projectHost()).post('/v1/data/mutate/foo?returnIds=true&returnDocuments=true', {createOrReplace: doc})
.reply(200, {transactionId: '123abc', updatedIds: ['foo/123'], documents: [{
_id: 'foo/123',
name: 'Raptor'
}]})
getClient().createOrReplace(doc).then(res => {
t.equal(res._id, 'foo/123', 'document id returned')
t.end()
}).catch(t.ifError)
})
test('delete() sends correct mutation', t => {
const expectedBody = {mutations: [{delete: {id: 'foo/123'}}]}
nock(projectHost())
.post('/v1/data/mutate/foo?returnIds=true&returnDocuments=true', {delete: {id: 'foo/123'}})
.reply(200, {transactionId: 'abc123'})
.post('/v1/data/mutate/foo?returnIDs=true&returnDocuments=true', expectedBody)
.reply(200, {transactionID: 'abc123', results: [{id: 'foo/123', operation: 'delete'}]})

@@ -383,17 +401,23 @@ getClient().delete('foo/123').then(() => t.end()).catch(t.ifError)

test('mutate() accepts multiple mutations', t => {
const mutations = [{
create: {
_id: 'movie:raiders-of-the-lost-ark',
title: 'Raiders of the Lost Ark',
year: 1981
}
const docs = [{
_id: 'movie/raiders-of-the-lost-ark',
title: 'Raiders of the Lost Ark',
year: 1981
}, {
delete: {
id: 'movie:the-phantom-menace'
}
_id: 'movie/the-phantom-menace',
title: 'Star Wars: Episode I - The Phantom Menace',
year: 1999
}]
const mutations = [
{create: docs[0]},
{delete: {id: 'movie/the-phantom-menace'}}
]
nock(projectHost())
.post('/v1/data/mutate/foo?returnIds=true&returnDocuments=true', mutations)
.reply(200, {transactionId: 'foo'})
.post('/v1/data/mutate/foo?returnIDs=true&returnDocuments=true', {mutations})
.reply(200, {transactionID: 'foo', results: [
{id: 'movie/raiders-of-the-lost-ark', operation: 'create', document: docs[0]},
{id: 'movie/the-phantom-menace', operation: 'delete', document: docs[1]}
]})

@@ -408,3 +432,3 @@ getClient().mutate(mutations).then(() => t.end()).catch(t.ifError)

for (let i = 1866; i <= 2016; i++) {
clause.push(`.title == %beerName${i}`)
clause.push(`.title == $beerName${i}`)
params[`beerName${i}`] = `some beer ${i}`

@@ -511,4 +535,4 @@ }

nock(projectHost())
.post('/v1/data/mutate/foo?returnIds=true', expectedPatch)
.reply(200, {transactionId: 'blatti'})
.post('/v1/data/mutate/foo?returnIDs=true', {mutations: [expectedPatch]})
.reply(200, {transactionID: 'blatti'})

@@ -528,9 +552,14 @@ getClient().patch('foo/123')

const expectedPatch = {patch: {id: 'foo/123', inc: {count: 1}, set: {visited: true}}}
const expectedBody = {mutations: [expectedPatch]}
nock(projectHost())
.post('/v1/data/mutate/foo?returnIds=true&returnDocuments=true', expectedPatch)
.reply(200, {transactionId: 'blatti', documents: [{
_id: 'foo/123',
_createdAt: '2016-10-24T08:09:32.997Z',
count: 2,
visited: true
.post('/v1/data/mutate/foo?returnIDs=true&returnDocuments=true', expectedBody)
.reply(200, {transactionID: 'blatti', results: [{
id: 'foo/123',
operation: 'update',
document: {
_id: 'foo/123',
_createdAt: '2016-10-24T08:09:32.997Z',
count: 2,
visited: true
}
}]})

@@ -551,4 +580,5 @@

const expectedPatch = {patch: {id: 'foo/123', inc: {count: 1}, set: {visited: true}}}
const expectedBody = {mutations: [expectedPatch]}
nock(projectHost())
.post('/v1/data/mutate/foo?returnIds=true&returnDocuments=true', expectedPatch)
.post('/v1/data/mutate/foo?returnIDs=true&returnDocuments=true', expectedBody)
.reply(400)

@@ -598,9 +628,2 @@

test('throws when trying to use patch as a promise without calling commit()', t => {
const patch = getClient().patch('foo/123').inc({count: 1})
t.throws(() => patch.then(noop), /uncommited patch/, 'throws on then()')
t.throws(() => patch.catch(noop), /uncommited patch/, 'throws on catch()')
t.end()
})
test('patch has toJSON() which serializes patch', t => {

@@ -744,6 +767,6 @@ const patch = getClient().patch('foo/123').inc({count: 1})

test('executes transaction when commit() is called', t => {
const expectedTransaction = [{create: {_id: 'foo/', bar: true}}, {delete: {id: 'foo/bar'}}]
const mutations = [{create: {_id: 'foo/', bar: true}}, {delete: {id: 'foo/bar'}}]
nock(projectHost())
.post('/v1/data/mutate/foo?returnIds=true', expectedTransaction)
.reply(200, {transactionId: 'blatti'})
.post('/v1/data/mutate/foo?returnIDs=true', {mutations})
.reply(200, {transactionID: 'blatti'})

@@ -761,9 +784,2 @@ getClient().transaction()

test('throws when trying to use transaction as a promise without calling commit()', t => {
const trans = getClient().transaction().delete('foo/bar')
t.throws(() => trans.then(noop), /uncommited transaction/, 'throws on then()')
t.throws(() => trans.catch(noop), /uncommited transaction/, 'throws on catch()')
t.end()
})
test('throws when passing incorrect input to transaction operations', t => {

@@ -878,8 +894,12 @@ const trans = getClient().transaction()

const doc = {_id: 'foo/bar', visits: 5}
const expectedBody = {mutations: [{create: doc}]}
nock(projectHost())
.post('/v1/data/mutate/foo?returnIds=true&returnDocuments=true', {create: doc})
.post('/v1/data/mutate/foo?returnIDs=true&returnDocuments=true', expectedBody)
.replyWithError(new Error('Something went wrong'))
getClient().create(doc)
.then(() => t.fail('Should not call success handler on error'))
.then(() => {
t.fail('Should not call success handler on error')
t.end()
})
.catch(err => {

@@ -892,27 +912,16 @@ t.ok(err instanceof Error, 'should error')

test('handles response timeouts gracefully', t => {
skipTestOnCI('handles connection timeouts gracefully', t => {
const doc = {_id: 'foo/bar', visits: 5}
const expectedBody = {mutations: [{create: doc}]}
nock(projectHost())
.post('/v1/data/mutate/foo?returnIds=true&returnDocuments=true', {create: doc})
.delay(500)
.post('/v1/data/mutate/foo?returnIDs=true&returnDocuments=true', expectedBody)
.socketDelay(75)
.delay({head: 500, body: 750})
.reply(200, {transactionId: 'abc123', documents: []})
getClient({timeout: 150}).create(doc)
.then(() => t.fail('Should not call success handler on timeouts'))
.catch(err => {
t.ok(err instanceof Error, 'should error')
t.equal(err.code, 'ETIMEDOUT', `should have timeout error code, got err\n${err.toString()}`)
.then(() => {
t.fail('Should not call success handler on timeouts')
t.end()
})
})
test('handles connection timeouts gracefully', t => {
const doc = {_id: 'foo/bar', visits: 5}
nock(projectHost())
.post('/v1/data/mutate/foo?returnIds=true&returnDocuments=true', {create: doc})
.delayConnection(500)
.reply(200, {transactionId: 'abc123', documents: []})
getClient({timeout: 150}).create(doc)
.then(() => t.fail('Should not call success handler on timeouts'))
.catch(err => {

@@ -927,4 +936,5 @@ t.ok(err instanceof Error, 'should error')

const doc = {_id: 'foo/bar', visits: 5}
const expectedBody = {mutations: [{create: doc}]}
nock(projectHost())
.post('/v1/data/mutate/foo?returnIds=true&returnDocuments=true', {create: doc})
.post('/v1/data/mutate/foo?returnIDs=true&returnDocuments=true', expectedBody)
.socketDelay(300)

@@ -934,3 +944,6 @@ .reply(200)

getClient({timeout: 150}).create(doc)
.then(() => t.fail('Should not call success handler on timeouts'))
.then(() => {
t.fail('Should not call success handler on timeouts')
t.end()
})
.catch(err => {

@@ -937,0 +950,0 @@ t.ok(err instanceof Error, 'should error')

const test = require('tape')
const encode = require('../src/data/encodeQueryString')
test('throws if parameters contain "query"', t => {
t.throws(() => encode({
query: 'gamedb.game[.some == %query]',
params: {query: 'foo'}
}), /query.*?reserved/)
t.end()
})
test('can encode basic query without parameters', t => {
const query = 'gamedb.game[.maxPlayers == 64]'
t.equal(encode({query}), '?query=gamedb.game%5B.maxPlayers%20%3D%3D%2064%5D')
const query = 'gamedb.game[maxPlayers == 64]'
t.equal(encode({query}), '?query=gamedb.game%5BmaxPlayers%20%3D%3D%2064%5D')
t.end()

@@ -19,7 +11,7 @@ })

test('can encode queries with basic numeric parameters', t => {
const query = 'gamedb.game[.maxPlayers == %maxPlayers && .score == %score]'
const query = 'gamedb.game[maxPlayers == $maxPlayers && score == $score]'
t.equal(
encode({query, params: {maxPlayers: 64, score: 3.45678}}),
'?query=gamedb.game%5B.maxPlayers%20%3D%3D%20%25maxPlayers%20%26%26%20.score%20%3D%3D%20%25score%5D'
+ '&maxPlayers=64&score=3.45678'
'?query=gamedb.game%5BmaxPlayers%20%3D%3D%20%24maxPlayers%20%26%26%20score%20%3D%3D%20%24score%5D'
+ '&%24maxPlayers=64&%24score=3.45678'
)

@@ -30,6 +22,6 @@ t.end()

test('can encode queries with basic string parameters', t => {
const query = 'gamedb.game[.name == %name]'
const query = 'gamedb.game[name == $name]'
t.equal(
encode({query, params: {name: 'foobar'}}),
'?query=gamedb.game%5B.name%20%3D%3D%20%25name%5D&name=%22foobar%22'
'?query=gamedb.game%5Bname%20%3D%3D%20%24name%5D&%24name=%22foobar%22'
)

@@ -40,8 +32,8 @@ t.end()

test('can encode queries with booleans', t => {
const query = 'gamedb.game[.isReleased == %released]'
const query = 'gamedb.game[isReleased == $released]'
t.equal(
encode({query, params: {released: true}}),
'?query=gamedb.game%5B.isReleased%20%3D%3D%20%25released%5D&released=true'
'?query=gamedb.game%5BisReleased%20%3D%3D%20%24released%5D&%24released=true'
)
t.end()
})

@@ -10,12 +10,12 @@ (function(f){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=f()}else if(typeof define==="function"&&define.amd){define([],f)}else{var g;if(typeof window!=="undefined"){g=window}else if(typeof global!=="undefined"){g=global}else if(typeof self!=="undefined"){g=self}else{g=this}g.SanityClient = f()}})(function(){var define,module,exports;return (function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(require,module,exports){

},{"./validators":15,"xtend/mutable":26}],4:[function(require,module,exports){
"use strict";function _defineProperty(t,e,n){return e in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function getMutatedId(t){return t.createdIds&&t.createdIds[0]||t.updatedIds&&t.updatedIds[0]}var assign=require("xtend/mutable"),validators=require("../validators"),encodeQueryString=require("./encodeQueryString"),Transaction=require("./transaction"),Patch=require("./patch"),getMutationQuery=function(t){return assign({returnIds:!0},t.returnDocuments===!1?{}:{returnDocuments:!0})},getQuerySizeLimit=1948;module.exports={fetch:function(t,e){return this.dataRequest("query",{query:t,params:e}).then(function(t){return t.result||[]})},getDocument:function(t){return this.request({uri:"/data/doc/"+t,json:!0}).then(function(t){return t.documents&&t.documents[0]})},create:function(t,e){return this._create(t,"create",e)},createIfNotExists:function(t,e){return this._create(t,"createIfNotExists",e)},createOrReplace:function(t,e){return this._create(t,"createOrReplace",e)},patch:function(t,e){return new Patch(t,e,this)},delete:function(t){return validators.validateDocumentId("delete",t),this.dataRequest("mutate",{delete:{id:t}})},mutate:function(t,e){var n=t instanceof Patch?t.serialize():t;return this.dataRequest("mutate",n,e)},transaction:function(t){return new Transaction(t,this)},dataRequest:function(t,e){var n=this,r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},u="mutate"===t,a=!u&&encodeQueryString(e),i=!u&&a.length<getQuerySizeLimit,s=i?a:"";return validators.promise.hasDataset(this.clientConfig).then(function(a){return n.request({method:i?"GET":"POST",uri:"/data/"+t+"/"+a+s,json:!0,body:i?void 0:e,query:u&&getMutationQuery(r)})}).then(function(t){return u?r.returnDocuments===!1?{transactionId:t.transactionId,documentId:getMutatedId(t)}:t.documents&&t.documents[0]:t})},_create:function(t,e){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},r=validators.hasDataset(this.clientConfig),u=_defineProperty({},e,assign({},t,{_id:t._id||r+"/"}));return this.dataRequest("mutate",u,n)}};
"use strict";function _defineProperty(t,e,r){return e in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}var assign=require("xtend/mutable"),validators=require("../validators"),encodeQueryString=require("./encodeQueryString"),Transaction=require("./transaction"),Patch=require("./patch"),getMutationQuery=function(t){return assign({returnIDs:!0},t.returnDocuments===!1?{}:{returnDocuments:!0})},getQuerySizeLimit=1948;module.exports={fetch:function(t,e){return this.dataRequest("query",{query:t,params:e}).then(function(t){return t.result||[]})},getDocument:function(t){return this.request({uri:"/data/doc/"+t,json:!0}).then(function(t){return t.documents&&t.documents[0]})},create:function(t,e){return this._create(t,"create",e)},createIfNotExists:function(t,e){return this._create(t,"createIfNotExists",e)},createOrReplace:function(t,e){return this._create(t,"createOrReplace",e)},patch:function(t,e){return new Patch(t,e,this)},delete:function(t){return validators.validateDocumentId("delete",t),this.dataRequest("mutate",{mutations:[{delete:{id:t}}]})},mutate:function(t,e){var r=t instanceof Patch?t.serialize():t,n=Array.isArray(r)?r:[r];return this.dataRequest("mutate",{mutations:n},e)},transaction:function(t){return new Transaction(t,this)},dataRequest:function(t,e){var r=this,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},u="mutate"===t,i=!u&&encodeQueryString(e),a=!u&&i.length<getQuerySizeLimit,s=a?i:"",o=n.returnFirst;return validators.promise.hasDataset(this.clientConfig).then(function(i){return r.request({method:a?"GET":"POST",uri:"/data/"+t+"/"+i+s,json:!0,body:a?void 0:e,query:u&&getMutationQuery(n)})}).then(function(t){if(!u)return t;var e=t.results||[];if(n.returnDocuments)return o?e[0]&&e[0].document:e.map(function(t){return t.document});var r=o?"documentId":"documentIds",i=o?e[0]&&e[0].id:e.map(function(t){return t.id});return _defineProperty({transactionId:t.transactionID},r,i)})},_create:function(t,e){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},n=validators.hasDataset(this.clientConfig),u=_defineProperty({},e,assign({},t,{_id:t._id||n+"/"})),i=assign({returnFirst:!0,returnDocuments:!0},r);return this.dataRequest("mutate",{mutations:[u]},i)}};
},{"../validators":15,"./encodeQueryString":5,"./patch":6,"./transaction":7,"xtend/mutable":26}],5:[function(require,module,exports){
"use strict";var enc=encodeURIComponent;module.exports=function(e){var r=e.query,n=e.params,t=void 0===n?{}:n;if(t.query)throw new Error('Parameter "query" is reserved, cannot be used as a parameter');return Object.keys(t).reduce(function(e,r){return e+"&"+enc(r)+"="+enc(JSON.stringify(t[r]))},"?query="+enc(r))};
"use strict";var enc=encodeURIComponent;module.exports=function(e){var n=e.query,r=e.params,c=void 0===r?{}:r;return Object.keys(c).reduce(function(e,n){return e+"&"+enc("$"+n)+"="+enc(JSON.stringify(c[n]))},"?query="+enc(n))};
},{}],6:[function(require,module,exports){
"use strict";function _defineProperty(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function Patch(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null;this.selection=e,this.operations=assign({},t),this.client=n}function throwPromiseError(e){return function(){throw new Error(e+"() called on an uncommited patch, did you forget to call commit()?")}}function getSelection(e){if("string"==typeof e||Array.isArray(e))return{id:e};if(e&&e.query)return{query:e.query};var t=["* Dataset-prefixed document ID (<dataset/docId>)","* Array of dataset-prefixed document IDs","* Object containing `query`"].join("\n");throw new Error("Unknown selection for patch - must be one of:\n\n"+t)}var deepAssign=require("deep-assign"),assign=require("xtend/mutable"),validateObject=require("../validators").validateObject;assign(Patch.prototype,{clone:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return new Patch(this.selection,assign({},this.operations,e),this.client)},merge:function(e){return validateObject("merge",e),this.clone({merge:deepAssign(this.operations.merge||{},e)})},set:function(e){return this._assign("set",e)},setIfMissing:function(e){return this._assign("setIfMissing",e)},replace:function(e){return validateObject("replace",e),this.clone({replace:e})},inc:function(e){return this._assign("inc",e)},dec:function(e){return this._assign("dec",e)},unset:function(e){throw new Error("Not implemented yet")},append:function(e){throw new Error("Not implemented yet")},prepend:function(e){throw new Error("Not implemented yet")},splice:function(e){throw new Error("Not implemented yet")},serialize:function(){return assign(getSelection(this.selection),this.operations)},toJSON:function(){return this.serialize()},commit:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};if(!this.client)throw new Error("No `client` passed to patch, either provide one or pass the patch to a clients `mutate()` method");return this.client.mutate({patch:this.serialize()},e)},reset:function(){return new Patch(this.selection,{},this.client)},_assign:function(e,t){return validateObject(e,t),this.clone(_defineProperty({},e,assign({},this.operations[e]||{},t)))},then:throwPromiseError("then"),catch:throwPromiseError("catch")}),module.exports=Patch;
"use strict";function _defineProperty(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function Patch(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null;this.selection=e,this.operations=assign({},t),this.client=n}function getSelection(e){if("string"==typeof e||Array.isArray(e))return{id:e};if(e&&e.query)return{query:e.query};var t=["* Dataset-prefixed document ID (<dataset/docId>)","* Array of dataset-prefixed document IDs","* Object containing `query`"].join("\n");throw new Error("Unknown selection for patch - must be one of:\n\n"+t)}var deepAssign=require("deep-assign"),assign=require("xtend/mutable"),validateObject=require("../validators").validateObject;assign(Patch.prototype,{clone:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return new Patch(this.selection,assign({},this.operations,e),this.client)},merge:function(e){return validateObject("merge",e),this.clone({merge:deepAssign(this.operations.merge||{},e)})},set:function(e){return this._assign("set",e)},setIfMissing:function(e){return this._assign("setIfMissing",e)},replace:function(e){return validateObject("replace",e),this.clone({replace:e})},inc:function(e){return this._assign("inc",e)},dec:function(e){return this._assign("dec",e)},unset:function(e){throw new Error("Not implemented yet")},append:function(e){throw new Error("Not implemented yet")},prepend:function(e){throw new Error("Not implemented yet")},splice:function(e){throw new Error("Not implemented yet")},serialize:function(){return assign(getSelection(this.selection),this.operations)},toJSON:function(){return this.serialize()},commit:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};if(!this.client)throw new Error("No `client` passed to patch, either provide one or pass the patch to a clients `mutate()` method");var t="string"==typeof this.selection,n=assign({returnFirst:t,returnDocuments:!0},e);return this.client.mutate({patch:this.serialize()},n)},reset:function(){return new Patch(this.selection,{},this.client)},_assign:function(e,t){return validateObject(e,t),this.clone(_defineProperty({},e,assign({},this.operations[e]||{},t)))}}),module.exports=Patch;
},{"../validators":15,"deep-assign":18,"xtend/mutable":26}],7:[function(require,module,exports){
"use strict";function _defineProperty(t,e,r){return e in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function Transaction(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[],e=arguments[1];this.operations=t,this.client=e}function throwPromiseError(t){return function(){throw new Error(t+"() called on an uncommited transaction, did you forget to call commit()?")}}var assign=require("xtend/mutable"),validators=require("../validators"),Patch=require("./patch"),defaultMutateOptions={returnDocuments:!1};assign(Transaction.prototype,{clone:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[];return new Transaction(this.operations.concat(t),this.client)},create:function(t){return this._create(t,"create")},createIfNotExists:function(t){return this._create(t,"createIfNotExists")},createOrReplace:function(t){return this._create(t,"createOrReplace")},delete:function(t){return validators.validateDocumentId("delete",t),this._add({delete:{id:t}})},patch:function t(e,r){var i="function"==typeof r,n=e instanceof Patch;if(n)return this._add({patch:e.serialize()});if(i){var t=r(new Patch(e,{},this.client));if(!(t instanceof Patch))throw new Error("function passed to `patch()` must return the patch");return this._add({patch:t.serialize()})}return this._add({patch:assign({id:e},r)})},serialize:function(){return this.operations.slice()},toJSON:function(){return this.serialize()},commit:function(t){if(!this.client)throw new Error("No `client` passed to transaction, either provide one or pass the transaction to a clients `mutate()` method");return this.client.mutate(this.serialize(),t||defaultMutateOptions)},reset:function(){return this.operations=[],this},_create:function(t,e){if(!t._id&&!this.client)throw new Error('Document needs an _id property when transaction is create outside a client scope. Pass `{_id: "<datasetName>:"}` to have Sanity generate an ID for you.');validators.validateObject(e,t);var r=validators.hasDataset(this.client.clientConfig),i=_defineProperty({},e,assign({},t,{_id:t._id||r+"/"}));return this._add(i)},_add:function(t){return this.clone(t)},then:throwPromiseError("then"),catch:throwPromiseError("catch")}),module.exports=Transaction;
"use strict";function _defineProperty(t,e,i){return e in t?Object.defineProperty(t,e,{value:i,enumerable:!0,configurable:!0,writable:!0}):t[e]=i,t}function Transaction(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[],e=arguments[1];this.operations=t,this.client=e}var assign=require("xtend/mutable"),validators=require("../validators"),Patch=require("./patch"),defaultMutateOptions={returnDocuments:!1};assign(Transaction.prototype,{clone:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[];return new Transaction(this.operations.concat(t),this.client)},create:function(t){return this._create(t,"create")},createIfNotExists:function(t){return this._create(t,"createIfNotExists")},createOrReplace:function(t){return this._create(t,"createOrReplace")},delete:function(t){return validators.validateDocumentId("delete",t),this._add({delete:{id:t}})},patch:function t(e,i){var n="function"==typeof i,r=e instanceof Patch;if(r)return this._add({patch:e.serialize()});if(n){var t=i(new Patch(e,{},this.client));if(!(t instanceof Patch))throw new Error("function passed to `patch()` must return the patch");return this._add({patch:t.serialize()})}return this._add({patch:assign({id:e},i)})},serialize:function(){return this.operations.slice()},toJSON:function(){return this.serialize()},commit:function(t){if(!this.client)throw new Error("No `client` passed to transaction, either provide one or pass the transaction to a clients `mutate()` method");return this.client.mutate(this.serialize(),t||defaultMutateOptions)},reset:function(){return this.operations=[],this},_create:function(t,e){if(!t._id&&!this.client)throw new Error('Document needs an _id property when transaction is create outside a client scope. Pass `{_id: "<datasetName>:"}` to have Sanity generate an ID for you.');validators.validateObject(e,t);var i=validators.hasDataset(this.client.clientConfig),n=_defineProperty({},e,assign({},t,{_id:t._id||i+"/"}));return this._add(n)},_add:function(t){return this.clone(t)}}),module.exports=Transaction;

@@ -29,3 +29,3 @@ },{"../validators":15,"./patch":6,"xtend/mutable":26}],8:[function(require,module,exports){

},{}],10:[function(require,module,exports){
"use strict";function httpError(r){return"Server responded with HTTP "+r.statusCode+" "+(r.statusMessage||"")+", no description"}function stringifyBody(r,e){var o=(e.headers["content-type"]||"").toLowerCase(),t=o.indexOf("application/json")!==-1;return t?JSON.stringify(r,null,2):r}var request=require("@sanity/request"),queryString=require("./queryString"),Observable=require("zen-observable"),debug="".indexOf("sanity")!==-1,log=function(){};module.exports=function(r){r.query&&(r.uri+="?"+queryString.stringify(r.query)),debug&&(log("HTTP %s %s",r.method||"GET",r.uri),"POST"===r.method&&r.json&&log("Request body: %s",JSON.stringify(r.json,null,2)));var e=new Observable(function(e){function o(r){return function(o){var t=o.lengthComputable?o.loaded/o.total:-1;e.next({type:"progress",stage:r,percent:t})}}var t=request(r,function(r,o,t){if(r)return void e.error(r);log("Response code: %s",o.statusCode),debug&&t&&log("Response body: %s",stringifyBody(t,o));var n=o.statusCode>=400;if(n&&t){var s=(t.errors?t.errors.map(function(r){return r.message}):[]).concat([t.error,t.message]).filter(Boolean).join("\n"),u=new Error(s||httpError(o));return u.responseBody=stringifyBody(t,o),u.statusCode=o.statusCode,void e.error(u)}if(n){var i=new Error(httpError(o));return i.statusCode=o.statusCode,void e.error(i)}e.next({type:"response",body:t}),e.complete()});return"upload"in t&&"onprogress"in t.upload&&(t.upload.onprogress=o("upload")),"onprogress"in t&&(t.onprogress=o("download")),t.onabort=function(){e.next({type:"abort"}),e.complete()},function(){return t.abort()}});return e.toPromise=function(){var r=void 0;return e.forEach(function(e){r=e}).then(function(){return r.body})},e};
"use strict";function httpError(r){return"Server responded with HTTP "+r.statusCode+" "+(r.statusMessage||"")+", no description"}function stringifyBody(r,e){var o=(e.headers["content-type"]||"").toLowerCase(),t=o.indexOf("application/json")!==-1;return t?JSON.stringify(r,null,2):r}var request=require("@sanity/request"),queryString=require("./queryString"),Observable=require("zen-observable"),debug="".indexOf("sanity")!==-1,log=function(){};module.exports=function(r){r.query&&(r.uri+="?"+queryString.stringify(r.query)),debug&&(log("HTTP %s %s",r.method||"GET",r.uri),"POST"===r.method&&r.body&&log("Request body: %s",JSON.stringify(r.body,null,2)));var e=new Observable(function(e){function o(r){return function(o){var t=o.lengthComputable?o.loaded/o.total:-1;e.next({type:"progress",stage:r,percent:t})}}var t=request(r,function(r,o,t){if(r)return void e.error(r);log("Response code: %s",o.statusCode),debug&&t&&log("Response body: %s",stringifyBody(t,o));var n=o.statusCode>=400;if(n&&t){var s=(t.errors?t.errors.map(function(r){return r.message}):[]).concat([t.error,t.message]).filter(Boolean).join("\n"),u=new Error(s||httpError(o));return u.responseBody=stringifyBody(t,o),u.statusCode=o.statusCode,void e.error(u)}if(n){var i=new Error(httpError(o));return i.statusCode=o.statusCode,void e.error(i)}e.next({type:"response",body:t}),e.complete()});return"upload"in t&&"onprogress"in t.upload&&(t.upload.onprogress=o("upload")),"onprogress"in t&&(t.onprogress=o("download")),t.onabort=function(){e.next({type:"abort"}),e.complete()},function(){return t.abort()}});return e.toPromise=function(){var r=void 0;return e.forEach(function(e){r=e}).then(function(){return r.body})},e};

@@ -44,3 +44,3 @@ },{"./queryString":9,"@sanity/request":17,"zen-observable":27}],11:[function(require,module,exports){

},{"xtend/mutable":26}],15:[function(require,module,exports){
"use strict";var _typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},VALID_ASSET_TYPES=["image","file"];exports.dataset=function(t){if(!/^[-\w]{1,128}$/.test(t))throw new Error("Datasets can only contain lowercase characters, numbers, underscores and dashes")},exports.projectId=function(t){if(!/^[-a-z0-9]+$/i.test(t))throw new Error("`projectId` can only contain only a-z, 0-9 and dashes")},exports.validateAssetType=function(t){if(VALID_ASSET_TYPES.indexOf(t)===-1)throw new Error("Invalid asset type: "+t+". Must be one of "+VALID_ASSET_TYPES.join(", "))},exports.validateObject=function(t,e){if(null===e||"object"!==("undefined"==typeof e?"undefined":_typeof(e))||Array.isArray(e))throw new Error(t+"() takes an object of properties")},exports.validateDocumentId=function(t,e){if("string"!=typeof e||!/^[-\w]{1,128}\/[-_a-z0-9]+$/i.test(e))throw new Error(t+"() takes a document ID in format dataset/docId")},exports.hasDataset=function(t){if(!t.dataset)throw new Error("`dataset` must be provided to perform queries");return t.dataset},exports.promise={hasDataset:function(t){return new Promise(function(e){return e(exports.hasDataset(t))})}};
"use strict";var _typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},VALID_ASSET_TYPES=["image","file"];exports.dataset=function(t){if(!/^[-\w]{1,128}$/.test(t))throw new Error("Datasets can only contain lowercase characters, numbers, underscores and dashes")},exports.projectId=function(t){if(!/^[-a-z0-9]+$/i.test(t))throw new Error("`projectId` can only contain only a-z, 0-9 and dashes")},exports.validateAssetType=function(t){if(VALID_ASSET_TYPES.indexOf(t)===-1)throw new Error("Invalid asset type: "+t+". Must be one of "+VALID_ASSET_TYPES.join(", "))},exports.validateObject=function(t,e){if(null===e||"object"!==("undefined"==typeof e?"undefined":_typeof(e))||Array.isArray(e))throw new Error(t+"() takes an object of properties")},exports.validateDocumentId=function(t,e){if("string"!=typeof e||!/^[-_a-z0-9]{1,128}\/[-_a-z0-9\/]+$/i.test(e))throw new Error(t+"() takes a document ID in format dataset/docId")},exports.hasDataset=function(t){if(!t.dataset)throw new Error("`dataset` must be provided to perform queries");return t.dataset},exports.promise={hasDataset:function(t){return new Promise(function(e){return e(exports.hasDataset(t))})}};
},{}],16:[function(require,module,exports){

@@ -58,2 +58,3 @@ "use strict";function forEachArray(e,t){for(var r=0;r<e.length;r++)t(e[r])}function isEmpty(e){for(var t in e)if(e.hasOwnProperty(t))return!1;return!0}function initParams(e,t,r){var n=e;return isFunction(t)?(r=t,"string"==typeof e&&(n={uri:e})):n=xtend(t,{uri:e}),n.callback=r,n}function createXHR(e,t,r){return t=initParams(e,t,r),_createXHR(t)}function _createXHR(e){function t(){4===u.readyState&&o()}function r(){var e=void 0;if(e=u.response?u.response:u.responseText||getXml(u),h)try{e=JSON.parse(e)}catch(e){}return e}function n(e){return clearTimeout(p),e instanceof Error||(e=new Error(""+(e||"Unknown XMLHttpRequest Error"))),e.statusCode=0,a(e,i)}function o(){if(!d){var t;clearTimeout(p),t=e.useXDR&&void 0===u.status?200:1223===u.status?204:u.status;var n=i,o=null;return 0!==t?(n={body:r(),statusCode:t,method:f,headers:{},url:l,rawRequest:u},u.getAllResponseHeaders&&(n.headers=parseHeaders(u.getAllResponseHeaders()))):o=new Error("Internal XMLHttpRequest Error"),a(o,n,n.body)}}if("undefined"==typeof e.callback)throw new Error("callback argument missing");var s=!1,a=function(t,r,n){s||(s=!0,e.callback(t,r,n))},i={body:void 0,headers:{},statusCode:0,method:f,url:l,rawRequest:u},u=e.xhr||null;u||(u=e.cors||e.useXDR?new createXHR.XDomainRequest:new createXHR.XMLHttpRequest);var c,d,p,l=u.url=e.uri||e.url,f=u.method=e.method||"GET",m=e.body||e.data||null,R=u.headers=e.headers||{},X=!!e.sync,h=!1;if(e.json===!0&&(h=!0,R.accept||R.Accept||(R.Accept="application/json"),"GET"!==f&&"HEAD"!==f&&(R["content-type"]||R["Content-Type"]||(R["Content-Type"]="application/json"),m=JSON.stringify(e.body))),u.onreadystatechange=t,u.onload=o,u.onerror=n,u.onprogress=function(){},u.ontimeout=n,u.open(f,l,!X,e.username,e.password),X||(u.withCredentials=!!e.withCredentials),!X&&e.timeout>0&&(p=setTimeout(function(){d=!0,u.abort("timeout");var e=new Error("XMLHttpRequest timeout");e.code="ETIMEDOUT",n(e)},e.timeout)),u.setRequestHeader)for(c in R)R.hasOwnProperty(c)&&u.setRequestHeader(c,R[c]);else if(e.headers&&!isEmpty(e.headers))throw new Error("Headers cannot be set on an XDomainRequest object");return"responseType"in e&&(u.responseType=e.responseType),"beforeSend"in e&&"function"==typeof e.beforeSend&&e.beforeSend(u),u.send(m),u}function getXml(e){if("document"===e.responseType)return e.responseXML;var t=204===e.status&&e.responseXML&&"parsererror"===e.responseXML.documentElement.nodeName;return""!==e.responseType||t?null:e.responseXML}function noop(){}var window=require("global/window"),isFunction=require("is-function"),parseHeaders=require("parse-headers"),xtend=require("xtend");module.exports=createXHR,createXHR.XMLHttpRequest=window.XMLHttpRequest||noop,createXHR.XDomainRequest="withCredentials"in new createXHR.XMLHttpRequest?createXHR.XMLHttpRequest:window.XDomainRequest,forEachArray(["get","put","post","patch","head","delete"],function(e){createXHR["delete"===e?"del":e]=function(t,r,n){return r=initParams(t,r,n),r.method=e.toUpperCase(),_createXHR(r)}});

"undefined"!=typeof window?module.exports=window:"undefined"!=typeof global?module.exports=global:"undefined"!=typeof self?module.exports=self:module.exports={};
}).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})

@@ -71,3 +72,2 @@ },{}],21:[function(require,module,exports){

function extend(){for(var r={},e=0;e<arguments.length;e++){var t=arguments[e];for(var n in t)hasOwnProperty.call(t,n)&&(r[n]=t[n])}return r}module.exports=extend;var hasOwnProperty=Object.prototype.hasOwnProperty;
},{}],26:[function(require,module,exports){

@@ -74,0 +74,0 @@ function extend(r){for(var e=1;e<arguments.length;e++){var t=arguments[e];for(var n in t)hasOwnProperty.call(t,n)&&(r[n]=t[n])}return r}module.exports=extend;var hasOwnProperty=Object.prototype.hasOwnProperty;

@@ -1,1 +0,1 @@

!function(t){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=t();else if("function"==typeof define&&define.amd)define([],t);else{var e;e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this,e.SanityClient=t()}}(function(){return function t(e,n,r){function o(s,u){if(!n[s]){if(!e[s]){var a="function"==typeof require&&require;if(!u&&a)return a(s,!0);if(i)return i(s,!0);var c=new Error("Cannot find module '"+s+"'");throw c.code="MODULE_NOT_FOUND",c}var f=n[s]={exports:{}};e[s][0].call(f.exports,function(t){var n=e[s][1][t];return o(n?n:t)},f,f.exports,t,e,n,r)}return n[s].exports}for(var i="function"==typeof require&&require,s=0;s<r.length;s++)o(r[s]);return o}({1:[function(t,e,n){"use strict";function r(t){this.client=t}var o=t("xtend/mutable"),i=t("../validators"),s={image:"images",file:"files"};o(r.prototype,{upload:function(t,e){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};i.validateAssetType(t);var r=i.hasDataset(this.client.clientConfig),u="contentType"in n?{"Content-Type":n.contentType}:{},a=s[t];return this.client.requestObservable({method:"POST",headers:o({Accept:"application/json"},u),uri:"/assets/"+a+"/"+r,body:e,json:!1,timeout:0}).map(function(t){return"response"!==t.type?t:o({},t,{body:JSON.parse(t.body)})})}}),e.exports=r},{"../validators":15,"xtend/mutable":26}],2:[function(t,e,n){"use strict";function r(t){this.client=t}var o=t("xtend/mutable");o(r.prototype,{getLoginProviders:function(){return this.client.request({uri:"/auth/providers"})},logout:function(){return this.client.request({uri:"/auth/logout"})}}),e.exports=r},{"xtend/mutable":26}],3:[function(t,e,n){"use strict";var r=t("xtend/mutable"),o=t("./validators"),i=n.defaultConfig={apiHost:"https://api.sanity.io",useProjectHostname:!0};n.initConfig=function(t,e){var n=r({},i,e,t),s=n.useProjectHostname;if("undefined"==typeof Promise)throw new Error("No native `Promise`-implementation found, polyfill needed");if(s&&!n.projectId)throw new Error("Configuration must contain `projectId`");s&&o.projectId(n.projectId),n.dataset&&o.dataset(n.dataset);var u=n.apiHost.split("://",2),a=u[0],c=u[1];return n.useProjectHostname?n.url=a+"://"+n.projectId+"."+c+"/v1":n.url=n.apiHost+"/v1",n}},{"./validators":15,"xtend/mutable":26}],4:[function(t,e,n){"use strict";function r(t,e,n){return e in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function o(t){return t.createdIds&&t.createdIds[0]||t.updatedIds&&t.updatedIds[0]}var i=t("xtend/mutable"),s=t("../validators"),u=t("./encodeQueryString"),a=t("./transaction"),c=t("./patch"),f=function(t){return i({returnIds:!0},t.returnDocuments===!1?{}:{returnDocuments:!0})},l=1948;e.exports={fetch:function(t,e){return this.dataRequest("query",{query:t,params:e}).then(function(t){return t.result||[]})},getDocument:function(t){return this.request({uri:"/data/doc/"+t,json:!0}).then(function(t){return t.documents&&t.documents[0]})},create:function(t,e){return this._create(t,"create",e)},createIfNotExists:function(t,e){return this._create(t,"createIfNotExists",e)},createOrReplace:function(t,e){return this._create(t,"createOrReplace",e)},patch:function(t,e){return new c(t,e,this)},delete:function(t){return s.validateDocumentId("delete",t),this.dataRequest("mutate",{delete:{id:t}})},mutate:function(t,e){var n=t instanceof c?t.serialize():t;return this.dataRequest("mutate",n,e)},transaction:function(t){return new a(t,this)},dataRequest:function(t,e){var n=this,r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},i="mutate"===t,a=!i&&u(e),c=!i&&a.length<l,d=c?a:"";return s.promise.hasDataset(this.clientConfig).then(function(o){return n.request({method:c?"GET":"POST",uri:"/data/"+t+"/"+o+d,json:!0,body:c?void 0:e,query:i&&f(r)})}).then(function(t){return i?r.returnDocuments===!1?{transactionId:t.transactionId,documentId:o(t)}:t.documents&&t.documents[0]:t})},_create:function(t,e){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},o=s.hasDataset(this.clientConfig),u=r({},e,i({},t,{_id:t._id||o+"/"}));return this.dataRequest("mutate",u,n)}}},{"../validators":15,"./encodeQueryString":5,"./patch":6,"./transaction":7,"xtend/mutable":26}],5:[function(t,e,n){"use strict";var r=encodeURIComponent;e.exports=function(t){var e=t.query,n=t.params,o=void 0===n?{}:n;if(o.query)throw new Error('Parameter "query" is reserved, cannot be used as a parameter');return Object.keys(o).reduce(function(t,e){return t+"&"+r(e)+"="+r(JSON.stringify(o[e]))},"?query="+r(e))}},{}],6:[function(t,e,n){"use strict";function r(t,e,n){return e in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function o(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null;this.selection=t,this.operations=a({},e),this.client=n}function i(t){return function(){throw new Error(t+"() called on an uncommited patch, did you forget to call commit()?")}}function s(t){if("string"==typeof t||Array.isArray(t))return{id:t};if(t&&t.query)return{query:t.query};var e=["* Dataset-prefixed document ID (<dataset/docId>)","* Array of dataset-prefixed document IDs","* Object containing `query`"].join("\n");throw new Error("Unknown selection for patch - must be one of:\n\n"+e)}var u=t("deep-assign"),a=t("xtend/mutable"),c=t("../validators").validateObject;a(o.prototype,{clone:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return new o(this.selection,a({},this.operations,t),this.client)},merge:function(t){return c("merge",t),this.clone({merge:u(this.operations.merge||{},t)})},set:function(t){return this._assign("set",t)},setIfMissing:function(t){return this._assign("setIfMissing",t)},replace:function(t){return c("replace",t),this.clone({replace:t})},inc:function(t){return this._assign("inc",t)},dec:function(t){return this._assign("dec",t)},unset:function(t){throw new Error("Not implemented yet")},append:function(t){throw new Error("Not implemented yet")},prepend:function(t){throw new Error("Not implemented yet")},splice:function(t){throw new Error("Not implemented yet")},serialize:function(){return a(s(this.selection),this.operations)},toJSON:function(){return this.serialize()},commit:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};if(!this.client)throw new Error("No `client` passed to patch, either provide one or pass the patch to a clients `mutate()` method");return this.client.mutate({patch:this.serialize()},t)},reset:function(){return new o(this.selection,{},this.client)},_assign:function(t,e){return c(t,e),this.clone(r({},t,a({},this.operations[t]||{},e)))},then:i("then"),catch:i("catch")}),e.exports=o},{"../validators":15,"deep-assign":18,"xtend/mutable":26}],7:[function(t,e,n){"use strict";function r(t,e,n){return e in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function o(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[],e=arguments[1];this.operations=t,this.client=e}function i(t){return function(){throw new Error(t+"() called on an uncommited transaction, did you forget to call commit()?")}}var s=t("xtend/mutable"),u=t("../validators"),a=t("./patch"),c={returnDocuments:!1};s(o.prototype,{clone:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[];return new o(this.operations.concat(t),this.client)},create:function(t){return this._create(t,"create")},createIfNotExists:function(t){return this._create(t,"createIfNotExists")},createOrReplace:function(t){return this._create(t,"createOrReplace")},delete:function(t){return u.validateDocumentId("delete",t),this._add({delete:{id:t}})},patch:function t(e,n){var r="function"==typeof n,o=e instanceof a;if(o)return this._add({patch:e.serialize()});if(r){var t=n(new a(e,{},this.client));if(!(t instanceof a))throw new Error("function passed to `patch()` must return the patch");return this._add({patch:t.serialize()})}return this._add({patch:s({id:e},n)})},serialize:function(){return this.operations.slice()},toJSON:function(){return this.serialize()},commit:function(t){if(!this.client)throw new Error("No `client` passed to transaction, either provide one or pass the transaction to a clients `mutate()` method");return this.client.mutate(this.serialize(),t||c)},reset:function(){return this.operations=[],this},_create:function(t,e){if(!t._id&&!this.client)throw new Error('Document needs an _id property when transaction is create outside a client scope. Pass `{_id: "<datasetName>:"}` to have Sanity generate an ID for you.');u.validateObject(e,t);var n=u.hasDataset(this.client.clientConfig),o=r({},e,s({},t,{_id:t._id||n+"/"}));return this._add(o)},_add:function(t){return this.clone(t)},then:i("then"),catch:i("catch")}),e.exports=o},{"../validators":15,"./patch":6,"xtend/mutable":26}],8:[function(t,e,n){"use strict";function r(t){this.request=t.request.bind(t)}var o=t("xtend/mutable"),i=t("../validators");o(r.prototype,{create:function(t){return this._modify("PUT",t)},delete:function(t){return this._modify("DELETE",t)},list:function(){return this.request({uri:"/datasets"})},_modify:function(t,e){return i.dataset(e),this.request({method:t,uri:"/datasets/"+e})}}),e.exports=r},{"../validators":15,"xtend/mutable":26}],9:[function(t,e,n){"use strict";function r(t){var e=function(e,n){return e.concat(o(n)+"="+o(t[n]))};return Object.keys(t).reduce(e,[]).join("&")}var o=function(t){return encodeURIComponent(t)};n.stringify=r},{}],10:[function(t,e,n){"use strict";function r(t){return"Server responded with HTTP "+t.statusCode+" "+(t.statusMessage||"")+", no description"}function o(t,e){var n=(e.headers["content-type"]||"").toLowerCase(),r=n.indexOf("application/json")!==-1;return r?JSON.stringify(t,null,2):t}var i=t("@sanity/request"),s=t("./queryString"),u=t("zen-observable"),a="".indexOf("sanity")!==-1,c=function(){};e.exports=function(t){t.query&&(t.uri+="?"+s.stringify(t.query)),a&&(c("HTTP %s %s",t.method||"GET",t.uri),"POST"===t.method&&t.json&&c("Request body: %s",JSON.stringify(t.json,null,2)));var e=new u(function(e){function n(t){return function(n){var r=n.lengthComputable?n.loaded/n.total:-1;e.next({type:"progress",stage:t,percent:r})}}var s=i(t,function(t,n,i){if(t)return void e.error(t);c("Response code: %s",n.statusCode),a&&i&&c("Response body: %s",o(i,n));var s=n.statusCode>=400;if(s&&i){var u=(i.errors?i.errors.map(function(t){return t.message}):[]).concat([i.error,i.message]).filter(Boolean).join("\n"),f=new Error(u||r(n));return f.responseBody=o(i,n),f.statusCode=n.statusCode,void e.error(f)}if(s){var l=new Error(r(n));return l.statusCode=n.statusCode,void e.error(l)}e.next({type:"response",body:i}),e.complete()});return"upload"in s&&"onprogress"in s.upload&&(s.upload.onprogress=n("upload")),"onprogress"in s&&(s.onprogress=n("download")),s.onabort=function(){e.next({type:"abort"}),e.complete()},function(){return s.abort()}});return e.toPromise=function(){var t=void 0;return e.forEach(function(e){t=e}).then(function(){return t.body})},e}},{"./queryString":9,"@sanity/request":17,"zen-observable":27}],11:[function(t,e,n){"use strict";var r="Sanity-Token",o="Sanity-Project-ID";e.exports=function(t){var e={};return t.token&&(e[r]=t.token),!t.useProjectHostname&&t.projectId&&(e[o]=t.projectId),{headers:e,timeout:"timeout"in t?t.timeout:15e3,withCredentials:!0,json:!0}}},{}],12:[function(t,e,n){"use strict";function r(t){this.client=t}var o=t("xtend/mutable");o(r.prototype,{list:function(){return this.client.request({uri:"/projects"})},getById:function(t){return this.client.request({uri:"/projects/"+t})}}),e.exports=r},{"xtend/mutable":26}],13:[function(t,e,n){"use strict";function r(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:m;this.config(t),this.assets=new d(this),this.datasets=new f(this),this.projects=new l(this),this.users=new p(this),this.auth=new h(this)}function o(){for(var t=arguments.length,e=Array(t),n=0;n<t;n++)e[n]=arguments[n];var r=e.reduce(function(t,e){return t||e.headers?s(t||{},e.headers||{}):null},null);return s.apply(void 0,e.concat([r?{headers:r}:{}]))}function i(t){return new r(t)}var s=t("xtend/mutable"),u=t("./data/patch"),a=t("./data/transaction"),c=t("./data/dataMethods"),f=t("./datasets/datasetsClient"),l=t("./projects/projectsClient"),d=t("./assets/assetsClient"),p=t("./users/usersClient"),h=t("./auth/authClient"),y=t("./http/request"),v=t("./http/requestOptions"),b=t("./config"),m=b.defaultConfig,w=b.initConfig;s(r.prototype,c),s(r.prototype,{config:function(t){return"undefined"==typeof t?this.clientConfig:(this.clientConfig=w(t,this.clientConfig||{}),this)},getUrl:function(t){return this.clientConfig.url+"/"+t.replace(/^\//,"")},request:function(t){return this.requestObservable(t).toPromise()},clone:function(t){var e=s(this.config(),t||{});return new r(e)},requestObservable:function(t){return y(o(v(this.clientConfig),t,{uri:this.getUrl(t.uri)}))}}),i.Patch=u,i.Transaction=a,e.exports=i},{"./assets/assetsClient":1,"./auth/authClient":2,"./config":3,"./data/dataMethods":4,"./data/patch":6,"./data/transaction":7,"./datasets/datasetsClient":8,"./http/request":10,"./http/requestOptions":11,"./projects/projectsClient":12,"./users/usersClient":14,"xtend/mutable":26}],14:[function(t,e,n){"use strict";function r(t){this.client=t}var o=t("xtend/mutable");o(r.prototype,{getById:function(t){return this.client.request({uri:"/users/"+t})}}),e.exports=r},{"xtend/mutable":26}],15:[function(t,e,n){"use strict";var r="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},o=["image","file"];n.dataset=function(t){if(!/^[-\w]{1,128}$/.test(t))throw new Error("Datasets can only contain lowercase characters, numbers, underscores and dashes")},n.projectId=function(t){if(!/^[-a-z0-9]+$/i.test(t))throw new Error("`projectId` can only contain only a-z, 0-9 and dashes")},n.validateAssetType=function(t){if(o.indexOf(t)===-1)throw new Error("Invalid asset type: "+t+". Must be one of "+o.join(", "))},n.validateObject=function(t,e){if(null===e||"object"!==("undefined"==typeof e?"undefined":r(e))||Array.isArray(e))throw new Error(t+"() takes an object of properties")},n.validateDocumentId=function(t,e){if("string"!=typeof e||!/^[-\w]{1,128}\/[-_a-z0-9]+$/i.test(e))throw new Error(t+"() takes a document ID in format dataset/docId")},n.hasDataset=function(t){if(!t.dataset)throw new Error("`dataset` must be provided to perform queries");return t.dataset},n.promise={hasDataset:function(t){return new Promise(function(e){return e(n.hasDataset(t))})}}},{}],16:[function(t,e,n){"use strict";function r(t,e){for(var n=0;n<t.length;n++)e(t[n])}function o(t){for(var e in t)if(t.hasOwnProperty(e))return!1;return!0}function i(t,e,n){var r=t;return l(e)?(n=e,"string"==typeof t&&(r={uri:t})):r=p(e,{uri:t}),r.callback=n,r}function s(t,e,n){return e=i(t,e,n),u(e)}function u(t){function e(){4===l.readyState&&i()}function n(){var t=void 0;if(t=l.response?l.response:l.responseText||a(l),j)try{t=JSON.parse(t)}catch(t){}return t}function r(t){return clearTimeout(y),t instanceof Error||(t=new Error(""+(t||"Unknown XMLHttpRequest Error"))),t.statusCode=0,c(t,f)}function i(){if(!h){var e;clearTimeout(y),e=t.useXDR&&void 0===l.status?200:1223===l.status?204:l.status;var r=f,o=null;return 0!==e?(r={body:n(),statusCode:e,method:b,headers:{},url:v,rawRequest:l},l.getAllResponseHeaders&&(r.headers=d(l.getAllResponseHeaders()))):o=new Error("Internal XMLHttpRequest Error"),c(o,r,r.body)}}if("undefined"==typeof t.callback)throw new Error("callback argument missing");var u=!1,c=function(e,n,r){u||(u=!0,t.callback(e,n,r))},f={body:void 0,headers:{},statusCode:0,method:b,url:v,rawRequest:l},l=t.xhr||null;l||(l=t.cors||t.useXDR?new s.XDomainRequest:new s.XMLHttpRequest);var p,h,y,v=l.url=t.uri||t.url,b=l.method=t.method||"GET",m=t.body||t.data||null,w=l.headers=t.headers||{},g=!!t.sync,j=!1;if(t.json===!0&&(j=!0,w.accept||w.Accept||(w.Accept="application/json"),"GET"!==b&&"HEAD"!==b&&(w["content-type"]||w["Content-Type"]||(w["Content-Type"]="application/json"),m=JSON.stringify(t.body))),l.onreadystatechange=e,l.onload=i,l.onerror=r,l.onprogress=function(){},l.ontimeout=r,l.open(b,v,!g,t.username,t.password),g||(l.withCredentials=!!t.withCredentials),!g&&t.timeout>0&&(y=setTimeout(function(){h=!0,l.abort("timeout");var t=new Error("XMLHttpRequest timeout");t.code="ETIMEDOUT",r(t)},t.timeout)),l.setRequestHeader)for(p in w)w.hasOwnProperty(p)&&l.setRequestHeader(p,w[p]);else if(t.headers&&!o(t.headers))throw new Error("Headers cannot be set on an XDomainRequest object");return"responseType"in t&&(l.responseType=t.responseType),"beforeSend"in t&&"function"==typeof t.beforeSend&&t.beforeSend(l),l.send(m),l}function a(t){if("document"===t.responseType)return t.responseXML;var e=204===t.status&&t.responseXML&&"parsererror"===t.responseXML.documentElement.nodeName;return""!==t.responseType||e?null:t.responseXML}function c(){}var f=t("global/window"),l=t("is-function"),d=t("parse-headers"),p=t("xtend");e.exports=s,s.XMLHttpRequest=f.XMLHttpRequest||c,s.XDomainRequest="withCredentials"in new s.XMLHttpRequest?s.XMLHttpRequest:f.XDomainRequest,r(["get","put","post","patch","head","delete"],function(t){s["delete"===t?"del":t]=function(e,n,r){return n=i(e,n,r),n.method=t.toUpperCase(),u(n)}})},{"global/window":20,"is-function":21,"parse-headers":23,xtend:25}],17:[function(t,e,n){e.exports=t("@bjoerge/xhr")},{"@bjoerge/xhr":16}],18:[function(t,e,n){"use strict";function r(t){if(null===t||void 0===t)throw new TypeError("Sources cannot be null or undefined");return Object(t)}function o(t,e,n){var r=e[n];if(void 0!==r&&null!==r){if(u.call(t,n)&&(void 0===t[n]||null===t[n]))throw new TypeError("Cannot convert undefined or null to object ("+n+")");u.call(t,n)&&s(r)?t[n]=i(Object(t[n]),e[n]):t[n]=r}}function i(t,e){if(t===e)return t;e=Object(e);for(var n in e)u.call(e,n)&&o(t,e,n);if(Object.getOwnPropertySymbols)for(var r=Object.getOwnPropertySymbols(e),i=0;i<r.length;i++)a.call(e,r[i])&&o(t,e,r[i]);return t}var s=t("is-obj"),u=Object.prototype.hasOwnProperty,a=Object.prototype.propertyIsEnumerable;e.exports=function(t){t=r(t);for(var e=1;e<arguments.length;e++)i(t,arguments[e]);return t}},{"is-obj":22}],19:[function(t,e,n){function r(t,e,n){if(!u(e))throw new TypeError("iterator must be a function");arguments.length<3&&(n=this),"[object Array]"===a.call(t)?o(t,e,n):"string"==typeof t?i(t,e,n):s(t,e,n)}function o(t,e,n){for(var r=0,o=t.length;r<o;r++)c.call(t,r)&&e.call(n,t[r],r,t)}function i(t,e,n){for(var r=0,o=t.length;r<o;r++)e.call(n,t.charAt(r),r,t)}function s(t,e,n){for(var r in t)c.call(t,r)&&e.call(n,t[r],r,t)}var u=t("is-function");e.exports=r;var a=Object.prototype.toString,c=Object.prototype.hasOwnProperty},{"is-function":21}],20:[function(t,e,n){(function(t){"undefined"!=typeof window?e.exports=window:"undefined"!=typeof t?e.exports=t:"undefined"!=typeof self?e.exports=self:e.exports={}}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{}],21:[function(t,e,n){function r(t){var e=o.call(t);return"[object Function]"===e||"function"==typeof t&&"[object RegExp]"!==e||"undefined"!=typeof window&&(t===window.setTimeout||t===window.alert||t===window.confirm||t===window.prompt)}e.exports=r;var o=Object.prototype.toString},{}],22:[function(t,e,n){"use strict";e.exports=function(t){var e=typeof t;return null!==t&&("object"===e||"function"===e)}},{}],23:[function(t,e,n){var r=t("trim"),o=t("for-each"),i=function(t){return"[object Array]"===Object.prototype.toString.call(t)};e.exports=function(t){if(!t)return{};var e={};return o(r(t).split("\n"),function(t){var n=t.indexOf(":"),o=r(t.slice(0,n)).toLowerCase(),s=r(t.slice(n+1));"undefined"==typeof e[o]?e[o]=s:i(e[o])?e[o].push(s):e[o]=[e[o],s]}),e}},{"for-each":19,trim:24}],24:[function(t,e,n){function r(t){return t.replace(/^\s*|\s*$/g,"")}n=e.exports=r,n.left=function(t){return t.replace(/^\s*/,"")},n.right=function(t){return t.replace(/\s*$/,"")}},{}],25:[function(t,e,n){function r(){for(var t={},e=0;e<arguments.length;e++){var n=arguments[e];for(var r in n)o.call(n,r)&&(t[r]=n[r])}return t}e.exports=r;var o=Object.prototype.hasOwnProperty},{}],26:[function(t,e,n){function r(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var r in n)o.call(n,r)&&(t[r]=n[r])}return t}e.exports=r;var o=Object.prototype.hasOwnProperty},{}],27:[function(t,e,n){e.exports=t("./zen-observable.js").Observable},{"./zen-observable.js":28}],28:[function(t,e,n){"use strict";!function(t,r){"undefined"!=typeof n?t(n,e):"undefined"!=typeof self&&t("*"===r?self:r?self[r]={}:{})}(function(t,e){function n(t){return"function"==typeof Symbol&&Boolean(Symbol[t])}function r(t){return n(t)?Symbol[t]:"@@"+t}function o(t,e){var n=t[e];if(null!=n){if("function"!=typeof n)throw new TypeError(n+" is not a function");return n}}function i(t){var e=r("species");return e?t[e]:t}function s(t,e){Object.keys(e).forEach(function(n){var r=Object.getOwnPropertyDescriptor(e,n);r.enumerable=!1,Object.defineProperty(t,n,r)})}function u(t){var e=t._cleanup;e&&(t._cleanup=void 0,e())}function a(t){return void 0===t._observer}function c(t){a(t)||(t._observer=void 0,u(t))}function f(t){return function(e){t.unsubscribe()}}function l(t,e){if(Object(t)!==t)throw new TypeError("Observer must be an object");this._cleanup=void 0,this._observer=t;var n=o(t,"start");if(n&&n.call(t,this),!a(this)){t=new d(this);try{var r=e.call(void 0,t);if(null!=r){if("function"==typeof r.unsubscribe)r=f(r);else if("function"!=typeof r)throw new TypeError(r+" is not a function");this._cleanup=r}}catch(e){return void t.error(e)}a(this)&&u(this)}}function d(t){this._subscription=t}function p(t){if("function"!=typeof t)throw new TypeError("Observable initializer must be a function");this._subscriber=t}s(l.prototype={},{get closed(){return a(this)},unsubscribe:function(){c(this)}}),s(d.prototype={},{get closed(){return a(this._subscription)},next:function(t){var e=this._subscription;if(!a(e)){var n=e._observer;try{var r=o(n,"next");if(!r)return;return r.call(n,t)}catch(t){try{c(e)}finally{throw t}}}},error:function(t){var e=this._subscription;if(a(e))throw t;var n=e._observer;e._observer=void 0;try{var r=o(n,"error");if(!r)throw t;t=r.call(n,t)}catch(t){try{u(e)}finally{throw t}}return u(e),t},complete:function(t){var e=this._subscription;if(!a(e)){var n=e._observer;e._observer=void 0;try{var r=o(n,"complete");t=r?r.call(n,t):void 0}catch(t){try{u(e)}finally{throw t}}return u(e),t}}}),s(p.prototype,{subscribe:function(t){for(var e=[],n=1;n<arguments.length;++n)e.push(arguments[n]);return"function"==typeof t&&(t={next:t,error:e[0],complete:e[1]}),new l(t,this._subscriber)},forEach:function(t){var e=this;return new Promise(function(n,r){return"function"!=typeof t?Promise.reject(new TypeError(t+" is not a function")):void e.subscribe({_subscription:null,start:function(t){if(Object(t)!==t)throw new TypeError(t+" is not an object");this._subscription=t},next:function(e){var n=this._subscription;if(!n.closed)try{return t(e)}catch(t){r(t),n.unsubscribe()}},error:r,complete:n})})},map:function(t){var e=this;if("function"!=typeof t)throw new TypeError(t+" is not a function");var n=i(this.constructor);return new n(function(n){return e.subscribe({next:function(e){if(!n.closed){try{e=t(e)}catch(t){return n.error(t)}return n.next(e)}},error:function(t){return n.error(t)},complete:function(t){return n.complete(t)}})})},filter:function(t){var e=this;if("function"!=typeof t)throw new TypeError(t+" is not a function");var n=i(this.constructor);return new n(function(n){return e.subscribe({next:function(e){if(!n.closed){try{if(!t(e))return}catch(t){return n.error(t)}return n.next(e)}},error:function(t){return n.error(t)},complete:function(){return n.complete()}})})},reduce:function(t){var e=this;if("function"!=typeof t)throw new TypeError(t+" is not a function");var n=i(this.constructor),r=arguments.length>1,o=!1,s=arguments[1],u=s;return new n(function(n){return e.subscribe({next:function(e){if(!n.closed){var i=!o;if(o=!0,!i||r)try{u=t(u,e)}catch(t){return n.error(t)}else u=e}},error:function(t){return n.error(t)},complete:function(){return o||r?(n.next(u),void n.complete()):void n.error(new TypeError("Cannot reduce an empty sequence"))}})})},flatMap:function(t){var e=this;if("function"!=typeof t)throw new TypeError(t+" is not a function");var n=i(this.constructor);return new n(function(n){function r(){o&&0===i.length&&n.complete()}var o=!1,i=[],s=e.subscribe({next:function(e){if(t)try{e=t(e)}catch(t){return void n.error(t)}p.from(e).subscribe({_subscription:null,start:function(t){i.push(this._subscription=t)},next:function(t){n.next(t)},error:function(t){n.error(t)},complete:function(){var t=i.indexOf(this._subscription);t>=0&&i.splice(t,1),r()}})},error:function(t){return n.error(t)},complete:function(){o=!0,r()}});return function(t){i.forEach(function(t){return t.unsubscribe()}),s.unsubscribe()}})}}),Object.defineProperty(p.prototype,r("observable"),{value:function(){return this},writable:!0,configurable:!0}),s(p,{from:function(t){var e="function"==typeof this?this:p;if(null==t)throw new TypeError(t+" is not an object");var i=o(t,r("observable"));if(i){var s=i.call(t);if(Object(s)!==s)throw new TypeError(s+" is not an object");return s.constructor===e?s:new e(function(t){return s.subscribe(t)})}if(n("iterator")&&(i=o(t,r("iterator"))))return new e(function(e){for(var n,r=i.call(t)[Symbol.iterator]();n=r.next(),!n.done;){var o=n.value;if(e.next(o),e.closed)return}e.complete()});if(Array.isArray(t))return new e(function(e){for(var n=0;n<t.length;++n)if(e.next(t[n]),e.closed)return;e.complete()});throw new TypeError(t+" is not observable")},of:function(){for(var t=[],e=0;e<arguments.length;++e)t.push(arguments[e]);var n="function"==typeof this?this:p;return new n(function(e){for(var n=0;n<t.length;++n)if(e.next(t[n]),e.closed)return;e.complete()})}}),Object.defineProperty(p,r("species"),{get:function(){return this},configurable:!0}),t.Observable=p},"*")},{}]},{},[13])(13)});
!function(t){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=t();else if("function"==typeof define&&define.amd)define([],t);else{var e;e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this,e.SanityClient=t()}}(function(){return function t(e,n,r){function o(s,u){if(!n[s]){if(!e[s]){var a="function"==typeof require&&require;if(!u&&a)return a(s,!0);if(i)return i(s,!0);var c=new Error("Cannot find module '"+s+"'");throw c.code="MODULE_NOT_FOUND",c}var f=n[s]={exports:{}};e[s][0].call(f.exports,function(t){var n=e[s][1][t];return o(n?n:t)},f,f.exports,t,e,n,r)}return n[s].exports}for(var i="function"==typeof require&&require,s=0;s<r.length;s++)o(r[s]);return o}({1:[function(t,e,n){"use strict";function r(t){this.client=t}var o=t("xtend/mutable"),i=t("../validators"),s={image:"images",file:"files"};o(r.prototype,{upload:function(t,e){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};i.validateAssetType(t);var r=i.hasDataset(this.client.clientConfig),u="contentType"in n?{"Content-Type":n.contentType}:{},a=s[t];return this.client.requestObservable({method:"POST",headers:o({Accept:"application/json"},u),uri:"/assets/"+a+"/"+r,body:e,json:!1,timeout:0}).map(function(t){return"response"!==t.type?t:o({},t,{body:JSON.parse(t.body)})})}}),e.exports=r},{"../validators":15,"xtend/mutable":26}],2:[function(t,e,n){"use strict";function r(t){this.client=t}var o=t("xtend/mutable");o(r.prototype,{getLoginProviders:function(){return this.client.request({uri:"/auth/providers"})},logout:function(){return this.client.request({uri:"/auth/logout"})}}),e.exports=r},{"xtend/mutable":26}],3:[function(t,e,n){"use strict";var r=t("xtend/mutable"),o=t("./validators"),i=n.defaultConfig={apiHost:"https://api.sanity.io",useProjectHostname:!0};n.initConfig=function(t,e){var n=r({},i,e,t),s=n.useProjectHostname;if("undefined"==typeof Promise)throw new Error("No native `Promise`-implementation found, polyfill needed");if(s&&!n.projectId)throw new Error("Configuration must contain `projectId`");s&&o.projectId(n.projectId),n.dataset&&o.dataset(n.dataset);var u=n.apiHost.split("://",2),a=u[0],c=u[1];return n.useProjectHostname?n.url=a+"://"+n.projectId+"."+c+"/v1":n.url=n.apiHost+"/v1",n}},{"./validators":15,"xtend/mutable":26}],4:[function(t,e,n){"use strict";function r(t,e,n){return e in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}var o=t("xtend/mutable"),i=t("../validators"),s=t("./encodeQueryString"),u=t("./transaction"),a=t("./patch"),c=function(t){return o({returnIDs:!0},t.returnDocuments===!1?{}:{returnDocuments:!0})},f=1948;e.exports={fetch:function(t,e){return this.dataRequest("query",{query:t,params:e}).then(function(t){return t.result||[]})},getDocument:function(t){return this.request({uri:"/data/doc/"+t,json:!0}).then(function(t){return t.documents&&t.documents[0]})},create:function(t,e){return this._create(t,"create",e)},createIfNotExists:function(t,e){return this._create(t,"createIfNotExists",e)},createOrReplace:function(t,e){return this._create(t,"createOrReplace",e)},patch:function(t,e){return new a(t,e,this)},delete:function(t){return i.validateDocumentId("delete",t),this.dataRequest("mutate",{mutations:[{delete:{id:t}}]})},mutate:function(t,e){var n=t instanceof a?t.serialize():t,r=Array.isArray(n)?n:[n];return this.dataRequest("mutate",{mutations:r},e)},transaction:function(t){return new u(t,this)},dataRequest:function(t,e){var n=this,o=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},u="mutate"===t,a=!u&&s(e),l=!u&&a.length<f,p=l?a:"",d=o.returnFirst;return i.promise.hasDataset(this.clientConfig).then(function(r){return n.request({method:l?"GET":"POST",uri:"/data/"+t+"/"+r+p,json:!0,body:l?void 0:e,query:u&&c(o)})}).then(function(t){if(!u)return t;var e=t.results||[];if(o.returnDocuments)return d?e[0]&&e[0].document:e.map(function(t){return t.document});var n=d?"documentId":"documentIds",i=d?e[0]&&e[0].id:e.map(function(t){return t.id});return r({transactionId:t.transactionID},n,i)})},_create:function(t,e){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},s=i.hasDataset(this.clientConfig),u=r({},e,o({},t,{_id:t._id||s+"/"})),a=o({returnFirst:!0,returnDocuments:!0},n);return this.dataRequest("mutate",{mutations:[u]},a)}}},{"../validators":15,"./encodeQueryString":5,"./patch":6,"./transaction":7,"xtend/mutable":26}],5:[function(t,e,n){"use strict";var r=encodeURIComponent;e.exports=function(t){var e=t.query,n=t.params,o=void 0===n?{}:n;return Object.keys(o).reduce(function(t,e){return t+"&"+r("$"+e)+"="+r(JSON.stringify(o[e]))},"?query="+r(e))}},{}],6:[function(t,e,n){"use strict";function r(t,e,n){return e in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function o(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null;this.selection=t,this.operations=u({},e),this.client=n}function i(t){if("string"==typeof t||Array.isArray(t))return{id:t};if(t&&t.query)return{query:t.query};var e=["* Dataset-prefixed document ID (<dataset/docId>)","* Array of dataset-prefixed document IDs","* Object containing `query`"].join("\n");throw new Error("Unknown selection for patch - must be one of:\n\n"+e)}var s=t("deep-assign"),u=t("xtend/mutable"),a=t("../validators").validateObject;u(o.prototype,{clone:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return new o(this.selection,u({},this.operations,t),this.client)},merge:function(t){return a("merge",t),this.clone({merge:s(this.operations.merge||{},t)})},set:function(t){return this._assign("set",t)},setIfMissing:function(t){return this._assign("setIfMissing",t)},replace:function(t){return a("replace",t),this.clone({replace:t})},inc:function(t){return this._assign("inc",t)},dec:function(t){return this._assign("dec",t)},unset:function(t){throw new Error("Not implemented yet")},append:function(t){throw new Error("Not implemented yet")},prepend:function(t){throw new Error("Not implemented yet")},splice:function(t){throw new Error("Not implemented yet")},serialize:function(){return u(i(this.selection),this.operations)},toJSON:function(){return this.serialize()},commit:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};if(!this.client)throw new Error("No `client` passed to patch, either provide one or pass the patch to a clients `mutate()` method");var e="string"==typeof this.selection,n=u({returnFirst:e,returnDocuments:!0},t);return this.client.mutate({patch:this.serialize()},n)},reset:function(){return new o(this.selection,{},this.client)},_assign:function(t,e){return a(t,e),this.clone(r({},t,u({},this.operations[t]||{},e)))}}),e.exports=o},{"../validators":15,"deep-assign":18,"xtend/mutable":26}],7:[function(t,e,n){"use strict";function r(t,e,n){return e in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function o(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[],e=arguments[1];this.operations=t,this.client=e}var i=t("xtend/mutable"),s=t("../validators"),u=t("./patch"),a={returnDocuments:!1};i(o.prototype,{clone:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[];return new o(this.operations.concat(t),this.client)},create:function(t){return this._create(t,"create")},createIfNotExists:function(t){return this._create(t,"createIfNotExists")},createOrReplace:function(t){return this._create(t,"createOrReplace")},delete:function(t){return s.validateDocumentId("delete",t),this._add({delete:{id:t}})},patch:function t(e,n){var r="function"==typeof n,o=e instanceof u;if(o)return this._add({patch:e.serialize()});if(r){var t=n(new u(e,{},this.client));if(!(t instanceof u))throw new Error("function passed to `patch()` must return the patch");return this._add({patch:t.serialize()})}return this._add({patch:i({id:e},n)})},serialize:function(){return this.operations.slice()},toJSON:function(){return this.serialize()},commit:function(t){if(!this.client)throw new Error("No `client` passed to transaction, either provide one or pass the transaction to a clients `mutate()` method");return this.client.mutate(this.serialize(),t||a)},reset:function(){return this.operations=[],this},_create:function(t,e){if(!t._id&&!this.client)throw new Error('Document needs an _id property when transaction is create outside a client scope. Pass `{_id: "<datasetName>:"}` to have Sanity generate an ID for you.');s.validateObject(e,t);var n=s.hasDataset(this.client.clientConfig),o=r({},e,i({},t,{_id:t._id||n+"/"}));return this._add(o)},_add:function(t){return this.clone(t)}}),e.exports=o},{"../validators":15,"./patch":6,"xtend/mutable":26}],8:[function(t,e,n){"use strict";function r(t){this.request=t.request.bind(t)}var o=t("xtend/mutable"),i=t("../validators");o(r.prototype,{create:function(t){return this._modify("PUT",t)},delete:function(t){return this._modify("DELETE",t)},list:function(){return this.request({uri:"/datasets"})},_modify:function(t,e){return i.dataset(e),this.request({method:t,uri:"/datasets/"+e})}}),e.exports=r},{"../validators":15,"xtend/mutable":26}],9:[function(t,e,n){"use strict";function r(t){var e=function(e,n){return e.concat(o(n)+"="+o(t[n]))};return Object.keys(t).reduce(e,[]).join("&")}var o=function(t){return encodeURIComponent(t)};n.stringify=r},{}],10:[function(t,e,n){"use strict";function r(t){return"Server responded with HTTP "+t.statusCode+" "+(t.statusMessage||"")+", no description"}function o(t,e){var n=(e.headers["content-type"]||"").toLowerCase(),r=n.indexOf("application/json")!==-1;return r?JSON.stringify(t,null,2):t}var i=t("@sanity/request"),s=t("./queryString"),u=t("zen-observable"),a="".indexOf("sanity")!==-1,c=function(){};e.exports=function(t){t.query&&(t.uri+="?"+s.stringify(t.query)),a&&(c("HTTP %s %s",t.method||"GET",t.uri),"POST"===t.method&&t.body&&c("Request body: %s",JSON.stringify(t.body,null,2)));var e=new u(function(e){function n(t){return function(n){var r=n.lengthComputable?n.loaded/n.total:-1;e.next({type:"progress",stage:t,percent:r})}}var s=i(t,function(t,n,i){if(t)return void e.error(t);c("Response code: %s",n.statusCode),a&&i&&c("Response body: %s",o(i,n));var s=n.statusCode>=400;if(s&&i){var u=(i.errors?i.errors.map(function(t){return t.message}):[]).concat([i.error,i.message]).filter(Boolean).join("\n"),f=new Error(u||r(n));return f.responseBody=o(i,n),f.statusCode=n.statusCode,void e.error(f)}if(s){var l=new Error(r(n));return l.statusCode=n.statusCode,void e.error(l)}e.next({type:"response",body:i}),e.complete()});return"upload"in s&&"onprogress"in s.upload&&(s.upload.onprogress=n("upload")),"onprogress"in s&&(s.onprogress=n("download")),s.onabort=function(){e.next({type:"abort"}),e.complete()},function(){return s.abort()}});return e.toPromise=function(){var t=void 0;return e.forEach(function(e){t=e}).then(function(){return t.body})},e}},{"./queryString":9,"@sanity/request":17,"zen-observable":27}],11:[function(t,e,n){"use strict";var r="Sanity-Token",o="Sanity-Project-ID";e.exports=function(t){var e={};return t.token&&(e[r]=t.token),!t.useProjectHostname&&t.projectId&&(e[o]=t.projectId),{headers:e,timeout:"timeout"in t?t.timeout:15e3,withCredentials:!0,json:!0}}},{}],12:[function(t,e,n){"use strict";function r(t){this.client=t}var o=t("xtend/mutable");o(r.prototype,{list:function(){return this.client.request({uri:"/projects"})},getById:function(t){return this.client.request({uri:"/projects/"+t})}}),e.exports=r},{"xtend/mutable":26}],13:[function(t,e,n){"use strict";function r(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:m;this.config(t),this.assets=new p(this),this.datasets=new f(this),this.projects=new l(this),this.users=new d(this),this.auth=new h(this)}function o(){for(var t=arguments.length,e=Array(t),n=0;n<t;n++)e[n]=arguments[n];var r=e.reduce(function(t,e){return t||e.headers?s(t||{},e.headers||{}):null},null);return s.apply(void 0,e.concat([r?{headers:r}:{}]))}function i(t){return new r(t)}var s=t("xtend/mutable"),u=t("./data/patch"),a=t("./data/transaction"),c=t("./data/dataMethods"),f=t("./datasets/datasetsClient"),l=t("./projects/projectsClient"),p=t("./assets/assetsClient"),d=t("./users/usersClient"),h=t("./auth/authClient"),y=t("./http/request"),v=t("./http/requestOptions"),b=t("./config"),m=b.defaultConfig,w=b.initConfig;s(r.prototype,c),s(r.prototype,{config:function(t){return"undefined"==typeof t?this.clientConfig:(this.clientConfig=w(t,this.clientConfig||{}),this)},getUrl:function(t){return this.clientConfig.url+"/"+t.replace(/^\//,"")},request:function(t){return this.requestObservable(t).toPromise()},clone:function(t){var e=s(this.config(),t||{});return new r(e)},requestObservable:function(t){return y(o(v(this.clientConfig),t,{uri:this.getUrl(t.uri)}))}}),i.Patch=u,i.Transaction=a,e.exports=i},{"./assets/assetsClient":1,"./auth/authClient":2,"./config":3,"./data/dataMethods":4,"./data/patch":6,"./data/transaction":7,"./datasets/datasetsClient":8,"./http/request":10,"./http/requestOptions":11,"./projects/projectsClient":12,"./users/usersClient":14,"xtend/mutable":26}],14:[function(t,e,n){"use strict";function r(t){this.client=t}var o=t("xtend/mutable");o(r.prototype,{getById:function(t){return this.client.request({uri:"/users/"+t})}}),e.exports=r},{"xtend/mutable":26}],15:[function(t,e,n){"use strict";var r="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},o=["image","file"];n.dataset=function(t){if(!/^[-\w]{1,128}$/.test(t))throw new Error("Datasets can only contain lowercase characters, numbers, underscores and dashes")},n.projectId=function(t){if(!/^[-a-z0-9]+$/i.test(t))throw new Error("`projectId` can only contain only a-z, 0-9 and dashes")},n.validateAssetType=function(t){if(o.indexOf(t)===-1)throw new Error("Invalid asset type: "+t+". Must be one of "+o.join(", "))},n.validateObject=function(t,e){if(null===e||"object"!==("undefined"==typeof e?"undefined":r(e))||Array.isArray(e))throw new Error(t+"() takes an object of properties")},n.validateDocumentId=function(t,e){if("string"!=typeof e||!/^[-_a-z0-9]{1,128}\/[-_a-z0-9\/]+$/i.test(e))throw new Error(t+"() takes a document ID in format dataset/docId")},n.hasDataset=function(t){if(!t.dataset)throw new Error("`dataset` must be provided to perform queries");return t.dataset},n.promise={hasDataset:function(t){return new Promise(function(e){return e(n.hasDataset(t))})}}},{}],16:[function(t,e,n){"use strict";function r(t,e){for(var n=0;n<t.length;n++)e(t[n])}function o(t){for(var e in t)if(t.hasOwnProperty(e))return!1;return!0}function i(t,e,n){var r=t;return l(e)?(n=e,"string"==typeof t&&(r={uri:t})):r=d(e,{uri:t}),r.callback=n,r}function s(t,e,n){return e=i(t,e,n),u(e)}function u(t){function e(){4===l.readyState&&i()}function n(){var t=void 0;if(t=l.response?l.response:l.responseText||a(l),x)try{t=JSON.parse(t)}catch(t){}return t}function r(t){return clearTimeout(y),t instanceof Error||(t=new Error(""+(t||"Unknown XMLHttpRequest Error"))),t.statusCode=0,c(t,f)}function i(){if(!h){var e;clearTimeout(y),e=t.useXDR&&void 0===l.status?200:1223===l.status?204:l.status;var r=f,o=null;return 0!==e?(r={body:n(),statusCode:e,method:b,headers:{},url:v,rawRequest:l},l.getAllResponseHeaders&&(r.headers=p(l.getAllResponseHeaders()))):o=new Error("Internal XMLHttpRequest Error"),c(o,r,r.body)}}if("undefined"==typeof t.callback)throw new Error("callback argument missing");var u=!1,c=function(e,n,r){u||(u=!0,t.callback(e,n,r))},f={body:void 0,headers:{},statusCode:0,method:b,url:v,rawRequest:l},l=t.xhr||null;l||(l=t.cors||t.useXDR?new s.XDomainRequest:new s.XMLHttpRequest);var d,h,y,v=l.url=t.uri||t.url,b=l.method=t.method||"GET",m=t.body||t.data||null,w=l.headers=t.headers||{},g=!!t.sync,x=!1;if(t.json===!0&&(x=!0,w.accept||w.Accept||(w.Accept="application/json"),"GET"!==b&&"HEAD"!==b&&(w["content-type"]||w["Content-Type"]||(w["Content-Type"]="application/json"),m=JSON.stringify(t.body))),l.onreadystatechange=e,l.onload=i,l.onerror=r,l.onprogress=function(){},l.ontimeout=r,l.open(b,v,!g,t.username,t.password),g||(l.withCredentials=!!t.withCredentials),!g&&t.timeout>0&&(y=setTimeout(function(){h=!0,l.abort("timeout");var t=new Error("XMLHttpRequest timeout");t.code="ETIMEDOUT",r(t)},t.timeout)),l.setRequestHeader)for(d in w)w.hasOwnProperty(d)&&l.setRequestHeader(d,w[d]);else if(t.headers&&!o(t.headers))throw new Error("Headers cannot be set on an XDomainRequest object");return"responseType"in t&&(l.responseType=t.responseType),"beforeSend"in t&&"function"==typeof t.beforeSend&&t.beforeSend(l),l.send(m),l}function a(t){if("document"===t.responseType)return t.responseXML;var e=204===t.status&&t.responseXML&&"parsererror"===t.responseXML.documentElement.nodeName;return""!==t.responseType||e?null:t.responseXML}function c(){}var f=t("global/window"),l=t("is-function"),p=t("parse-headers"),d=t("xtend");e.exports=s,s.XMLHttpRequest=f.XMLHttpRequest||c,s.XDomainRequest="withCredentials"in new s.XMLHttpRequest?s.XMLHttpRequest:f.XDomainRequest,r(["get","put","post","patch","head","delete"],function(t){s["delete"===t?"del":t]=function(e,n,r){return n=i(e,n,r),n.method=t.toUpperCase(),u(n)}})},{"global/window":20,"is-function":21,"parse-headers":23,xtend:25}],17:[function(t,e,n){e.exports=t("@bjoerge/xhr")},{"@bjoerge/xhr":16}],18:[function(t,e,n){"use strict";function r(t){if(null===t||void 0===t)throw new TypeError("Sources cannot be null or undefined");return Object(t)}function o(t,e,n){var r=e[n];if(void 0!==r&&null!==r){if(u.call(t,n)&&(void 0===t[n]||null===t[n]))throw new TypeError("Cannot convert undefined or null to object ("+n+")");u.call(t,n)&&s(r)?t[n]=i(Object(t[n]),e[n]):t[n]=r}}function i(t,e){if(t===e)return t;e=Object(e);for(var n in e)u.call(e,n)&&o(t,e,n);if(Object.getOwnPropertySymbols)for(var r=Object.getOwnPropertySymbols(e),i=0;i<r.length;i++)a.call(e,r[i])&&o(t,e,r[i]);return t}var s=t("is-obj"),u=Object.prototype.hasOwnProperty,a=Object.prototype.propertyIsEnumerable;e.exports=function(t){t=r(t);for(var e=1;e<arguments.length;e++)i(t,arguments[e]);return t}},{"is-obj":22}],19:[function(t,e,n){function r(t,e,n){if(!u(e))throw new TypeError("iterator must be a function");arguments.length<3&&(n=this),"[object Array]"===a.call(t)?o(t,e,n):"string"==typeof t?i(t,e,n):s(t,e,n)}function o(t,e,n){for(var r=0,o=t.length;r<o;r++)c.call(t,r)&&e.call(n,t[r],r,t)}function i(t,e,n){for(var r=0,o=t.length;r<o;r++)e.call(n,t.charAt(r),r,t)}function s(t,e,n){for(var r in t)c.call(t,r)&&e.call(n,t[r],r,t)}var u=t("is-function");e.exports=r;var a=Object.prototype.toString,c=Object.prototype.hasOwnProperty},{"is-function":21}],20:[function(t,e,n){(function(t){"undefined"!=typeof window?e.exports=window:"undefined"!=typeof t?e.exports=t:"undefined"!=typeof self?e.exports=self:e.exports={}}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{}],21:[function(t,e,n){function r(t){var e=o.call(t);return"[object Function]"===e||"function"==typeof t&&"[object RegExp]"!==e||"undefined"!=typeof window&&(t===window.setTimeout||t===window.alert||t===window.confirm||t===window.prompt)}e.exports=r;var o=Object.prototype.toString},{}],22:[function(t,e,n){"use strict";e.exports=function(t){var e=typeof t;return null!==t&&("object"===e||"function"===e)}},{}],23:[function(t,e,n){var r=t("trim"),o=t("for-each"),i=function(t){return"[object Array]"===Object.prototype.toString.call(t)};e.exports=function(t){if(!t)return{};var e={};return o(r(t).split("\n"),function(t){var n=t.indexOf(":"),o=r(t.slice(0,n)).toLowerCase(),s=r(t.slice(n+1));"undefined"==typeof e[o]?e[o]=s:i(e[o])?e[o].push(s):e[o]=[e[o],s]}),e}},{"for-each":19,trim:24}],24:[function(t,e,n){function r(t){return t.replace(/^\s*|\s*$/g,"")}n=e.exports=r,n.left=function(t){return t.replace(/^\s*/,"")},n.right=function(t){return t.replace(/\s*$/,"")}},{}],25:[function(t,e,n){function r(){for(var t={},e=0;e<arguments.length;e++){var n=arguments[e];for(var r in n)o.call(n,r)&&(t[r]=n[r])}return t}e.exports=r;var o=Object.prototype.hasOwnProperty},{}],26:[function(t,e,n){function r(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var r in n)o.call(n,r)&&(t[r]=n[r])}return t}e.exports=r;var o=Object.prototype.hasOwnProperty},{}],27:[function(t,e,n){e.exports=t("./zen-observable.js").Observable},{"./zen-observable.js":28}],28:[function(t,e,n){"use strict";!function(t,r){"undefined"!=typeof n?t(n,e):"undefined"!=typeof self&&t("*"===r?self:r?self[r]={}:{})}(function(t,e){function n(t){return"function"==typeof Symbol&&Boolean(Symbol[t])}function r(t){return n(t)?Symbol[t]:"@@"+t}function o(t,e){var n=t[e];if(null!=n){if("function"!=typeof n)throw new TypeError(n+" is not a function");return n}}function i(t){var e=r("species");return e?t[e]:t}function s(t,e){Object.keys(e).forEach(function(n){var r=Object.getOwnPropertyDescriptor(e,n);r.enumerable=!1,Object.defineProperty(t,n,r)})}function u(t){var e=t._cleanup;e&&(t._cleanup=void 0,e())}function a(t){return void 0===t._observer}function c(t){a(t)||(t._observer=void 0,u(t))}function f(t){return function(e){t.unsubscribe()}}function l(t,e){if(Object(t)!==t)throw new TypeError("Observer must be an object");this._cleanup=void 0,this._observer=t;var n=o(t,"start");if(n&&n.call(t,this),!a(this)){t=new p(this);try{var r=e.call(void 0,t);if(null!=r){if("function"==typeof r.unsubscribe)r=f(r);else if("function"!=typeof r)throw new TypeError(r+" is not a function");this._cleanup=r}}catch(e){return void t.error(e)}a(this)&&u(this)}}function p(t){this._subscription=t}function d(t){if("function"!=typeof t)throw new TypeError("Observable initializer must be a function");this._subscriber=t}s(l.prototype={},{get closed(){return a(this)},unsubscribe:function(){c(this)}}),s(p.prototype={},{get closed(){return a(this._subscription)},next:function(t){var e=this._subscription;if(!a(e)){var n=e._observer;try{var r=o(n,"next");if(!r)return;return r.call(n,t)}catch(t){try{c(e)}finally{throw t}}}},error:function(t){var e=this._subscription;if(a(e))throw t;var n=e._observer;e._observer=void 0;try{var r=o(n,"error");if(!r)throw t;t=r.call(n,t)}catch(t){try{u(e)}finally{throw t}}return u(e),t},complete:function(t){var e=this._subscription;if(!a(e)){var n=e._observer;e._observer=void 0;try{var r=o(n,"complete");t=r?r.call(n,t):void 0}catch(t){try{u(e)}finally{throw t}}return u(e),t}}}),s(d.prototype,{subscribe:function(t){for(var e=[],n=1;n<arguments.length;++n)e.push(arguments[n]);return"function"==typeof t&&(t={next:t,error:e[0],complete:e[1]}),new l(t,this._subscriber)},forEach:function(t){var e=this;return new Promise(function(n,r){return"function"!=typeof t?Promise.reject(new TypeError(t+" is not a function")):void e.subscribe({_subscription:null,start:function(t){if(Object(t)!==t)throw new TypeError(t+" is not an object");this._subscription=t},next:function(e){var n=this._subscription;if(!n.closed)try{return t(e)}catch(t){r(t),n.unsubscribe()}},error:r,complete:n})})},map:function(t){var e=this;if("function"!=typeof t)throw new TypeError(t+" is not a function");var n=i(this.constructor);return new n(function(n){return e.subscribe({next:function(e){if(!n.closed){try{e=t(e)}catch(t){return n.error(t)}return n.next(e)}},error:function(t){return n.error(t)},complete:function(t){return n.complete(t)}})})},filter:function(t){var e=this;if("function"!=typeof t)throw new TypeError(t+" is not a function");var n=i(this.constructor);return new n(function(n){return e.subscribe({next:function(e){if(!n.closed){try{if(!t(e))return}catch(t){return n.error(t)}return n.next(e)}},error:function(t){return n.error(t)},complete:function(){return n.complete()}})})},reduce:function(t){var e=this;if("function"!=typeof t)throw new TypeError(t+" is not a function");var n=i(this.constructor),r=arguments.length>1,o=!1,s=arguments[1],u=s;return new n(function(n){return e.subscribe({next:function(e){if(!n.closed){var i=!o;if(o=!0,!i||r)try{u=t(u,e)}catch(t){return n.error(t)}else u=e}},error:function(t){return n.error(t)},complete:function(){return o||r?(n.next(u),void n.complete()):void n.error(new TypeError("Cannot reduce an empty sequence"))}})})},flatMap:function(t){var e=this;if("function"!=typeof t)throw new TypeError(t+" is not a function");var n=i(this.constructor);return new n(function(n){function r(){o&&0===i.length&&n.complete()}var o=!1,i=[],s=e.subscribe({next:function(e){if(t)try{e=t(e)}catch(t){return void n.error(t)}d.from(e).subscribe({_subscription:null,start:function(t){i.push(this._subscription=t)},next:function(t){n.next(t)},error:function(t){n.error(t)},complete:function(){var t=i.indexOf(this._subscription);t>=0&&i.splice(t,1),r()}})},error:function(t){return n.error(t)},complete:function(){o=!0,r()}});return function(t){i.forEach(function(t){return t.unsubscribe()}),s.unsubscribe()}})}}),Object.defineProperty(d.prototype,r("observable"),{value:function(){return this},writable:!0,configurable:!0}),s(d,{from:function(t){var e="function"==typeof this?this:d;if(null==t)throw new TypeError(t+" is not an object");var i=o(t,r("observable"));if(i){var s=i.call(t);if(Object(s)!==s)throw new TypeError(s+" is not an object");return s.constructor===e?s:new e(function(t){return s.subscribe(t)})}if(n("iterator")&&(i=o(t,r("iterator"))))return new e(function(e){for(var n,r=i.call(t)[Symbol.iterator]();n=r.next(),!n.done;){var o=n.value;if(e.next(o),e.closed)return}e.complete()});if(Array.isArray(t))return new e(function(e){for(var n=0;n<t.length;++n)if(e.next(t[n]),e.closed)return;e.complete()});throw new TypeError(t+" is not observable")},of:function(){for(var t=[],e=0;e<arguments.length;++e)t.push(arguments[e]);var n="function"==typeof this?this:d;return new n(function(e){for(var n=0;n<t.length;++n)if(e.next(t[n]),e.closed)return;e.complete()})}}),Object.defineProperty(d,r("species"),{get:function(){return this},configurable:!0}),t.Observable=d},"*")},{}]},{},[13])(13)});

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc