diff --git a/familysearch-javascript-sdk.js b/familysearch-javascript-sdk.js index 7ebadf1..a4c719b 100644 --- a/familysearch-javascript-sdk.js +++ b/familysearch-javascript-sdk.js @@ -7739,8 +7739,8 @@ module.exports = { // constants for now, but could become options in the future accessTokenCookie: 'FS_ACCESS_TOKEN', authCodePollDelay: 50, - defaultThrottleRetryAfter: 500, - maxHttpRequestRetries: 2, + defaultThrottleRetryAfter: 1000, + maxHttpRequestRetries: 4, maxAccessTokenInactivityTime: 3540000, // 59 minutes to be safe maxAccessTokenCreationTime: 86340000, // 23 hours 59 minutes to be safe apiServer: { @@ -7826,8 +7826,8 @@ Helpers.prototype.appendAccessToken = function(url) { * log to console only if debugging is turned on */ Helpers.prototype.log = function() { - if (this.settings.debug) { - console.log.apply(null, arguments); + if (this.settings.debug && console.log) { + console.log.apply(console, arguments); } }; @@ -11517,7 +11517,7 @@ Plumbing.prototype.http = function(method, url, headers, data, retries) { return accessTokenPromise.then(function() { - // append the access token as a query parameter to avoid cors pre-flight + // Append the access token as a query parameter to avoid cors pre-flight // this is detrimental to browser caching across sessions, which seems less bad than cors pre-flight requests var accessTokenName = self.helpers.isAuthoritiesServerUrl(absoluteUrl) ? 'sessionId' : 'access_token'; if (self.settings.accessToken && absoluteUrl.indexOf(accessTokenName+'=') === -1) { @@ -11526,7 +11526,7 @@ Plumbing.prototype.http = function(method, url, headers, data, retries) { absoluteUrl = self.helpers.appendQueryParameters(absoluteUrl, accessTokenParam); } - // default retries + // Default retries if (retries == null) { // also catches undefined retries = self.settings.maxHttpRequestRetries; } @@ -11536,47 +11536,11 @@ Plumbing.prototype.http = function(method, url, headers, data, retries) { headers['X-FS-Feature-Tag'] = self.settings.pendingModifications; } + // Prepare body var body = self.transformData(data, headers['Content-Type']); - // Make the HTTP request - return fetch(absoluteUrl, { - method: method, - headers: headers, - body: body - }) - - // Erase access token when a 401 Unauthenticated response is received - .then(function(response){ - if(response.status === 401){ - self.helpers.eraseAccessToken(); - } - return response; - }) - - // Handle throttling - .then(function(response){ - if ((method === 'GET' && response.status >= 500 && retries > 0) || response.status === 429) { - //var retryAfterHeader = response.headers.get('Retry-After'); - //var retryAfter = retryAfterHeader ? parseInt(retryAfterHeader,10) : self.settings.defaultThrottleRetryAfter; - return self.http(method, url, headers, data, retries-1); - } else { - return response; - } - }) - - // Catch all other errors - .then(function(response){ - if (response.status >= 200 && response.status < 400) { - return response; - } else { - if(self.settings.debug){ - self.helpers.log('http failure', response.status, retries); - } - var error = new Error(response.statusText); - error.response = response; - throw error; - } - }) + // HTTP request and error handling + return self._http(method, absoluteUrl, headers, body, retries) // Process the response body and make available at the `body` property // of the response. If JSON parsing fails then we have bad data or no data. @@ -11590,16 +11554,6 @@ Plumbing.prototype.http = function(method, url, headers, data, retries) { }); }) - // Processing time - .then(function(response){ - self.helpers.refreshAccessToken(); - var processingTime = response.headers.get('X-PROCESSING-TIME'); - if (processingTime) { - self.totalProcessingTime += parseInt(processingTime,10); - } - return response; - }) - // Return a custom response object .then(function(response){ return { @@ -11628,6 +11582,65 @@ Plumbing.prototype.http = function(method, url, headers, data, retries) { }); }; +/** + * Helper and internal HTTP function. Enables recursive calling required for + * handling throttling. + */ +Plumbing.prototype._http = function(method, url, headers, body, retries){ + var self = this; + + // Make the HTTP request + return fetch(url, { + method: method, + headers: headers, + body: body + }) + + // Erase access token when a 401 Unauthenticated response is received + .then(function(response){ + if(response.status === 401){ + self.helpers.eraseAccessToken(); + } + return response; + }) + + // Handle throttling and other random server failures. If the Retry-After + // header exists then honor it's value (it always exists for throttled + // responses). The Retry-After value is in seconds while the setTimeout + // parameter is in ms so we multiply the header value by 1000. + .then(function(response){ + if (method === 'GET' && retries > 0 && (response.status >= 500 || response.status === 429)) { + var retryAfterHeader = response.headers.get('Retry-After'); + var retryAfter = retryAfterHeader ? parseInt(retryAfterHeader, 10) * 1000 : self.settings.defaultThrottleRetryAfter; + return new Promise(function(resolve, reject){ + setTimeout(function(){ + self._http(method, url, headers, body, retries-1).then(function(response){ + resolve(response); + }, function(error){ + reject(error); + }); + }, retryAfter); + }); + } else { + return response; + } + }) + + // Catch all other errors + .then(function(response){ + if (response.status >= 200 && response.status < 400) { + return response; + } else { + if(self.settings.debug){ + self.helpers.log('http failure', response.status, retries); + } + var error = new Error(response.statusText); + error.response = response; + throw error; + } + }); +}; + module.exports = Plumbing; },{"./utils":56,"es6-promise":2,"isomorphic-fetch":3}],55:[function(require,module,exports){ var FS = require('./FamilySearch'), diff --git a/familysearch-javascript-sdk.min.js b/familysearch-javascript-sdk.min.js index a6235cb..02f8a64 100644 --- a/familysearch-javascript-sdk.min.js +++ b/familysearch-javascript-sdk.min.js @@ -1,4 +1,4 @@ !function(a){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=a();else if("function"==typeof define&&define.amd)define([],a);else{var b;"undefined"!=typeof window?b=window:"undefined"!=typeof global?b=global:"undefined"!=typeof self&&(b=self),b.FamilySearch=a()}}(function(){var a;return function b(a,c,d){function e(g,h){if(!c[g]){if(!a[g]){var i="function"==typeof require&&require;if(!h&&i)return i(g,!0);if(f)return f(g,!0);var j=new Error("Cannot find module '"+g+"'");throw j.code="MODULE_NOT_FOUND",j}var k=c[g]={exports:{}};a[g][0].call(k.exports,function(b){var c=a[g][1][b];return e(c?c:b)},k,k.exports,b,a,c,d)}return c[g].exports}for(var f="function"==typeof require&&require,g=0;ga;a+=2){var b=ca[a],c=ca[a+1];b(c),ca[a]=void 0,ca[a+1]=void 0}X=0}function q(){try{var a=b,c=a("vertx");return T=c.runOnLoop||c.runOnContext,l()}catch(d){return o()}}function r(){}function s(){return new TypeError("You cannot resolve a promise with itself")}function t(){return new TypeError("A promises callback cannot return that same promise.")}function u(a){try{return a.then}catch(b){return ga.error=b,ga}}function v(a,b,c,d){try{a.call(b,c,d)}catch(e){return e}}function w(a,b,c){Y(function(a){var d=!1,e=v(c,b,function(c){d||(d=!0,b!==c?z(a,c):B(a,c))},function(b){d||(d=!0,C(a,b))},"Settle: "+(a._label||" unknown promise"));!d&&e&&(d=!0,C(a,e))},a)}function x(a,b){b._state===ea?B(a,b._result):b._state===fa?C(a,b._result):D(b,void 0,function(b){z(a,b)},function(b){C(a,b)})}function y(a,b){if(b.constructor===a.constructor)x(a,b);else{var c=u(b);c===ga?C(a,ga.error):void 0===c?B(a,b):g(c)?w(a,b,c):B(a,b)}}function z(a,b){a===b?C(a,s()):f(b)?y(a,b):B(a,b)}function A(a){a._onerror&&a._onerror(a._result),E(a)}function B(a,b){a._state===da&&(a._result=b,a._state=ea,0!==a._subscribers.length&&Y(E,a))}function C(a,b){a._state===da&&(a._state=fa,a._result=b,Y(A,a))}function D(a,b,c,d){var e=a._subscribers,f=e.length;a._onerror=null,e[f]=b,e[f+ea]=c,e[f+fa]=d,0===f&&a._state&&Y(E,a)}function E(a){var b=a._subscribers,c=a._state;if(0!==b.length){for(var d,e,f=a._result,g=0;gg;g++)D(d.resolve(a[g]),void 0,b,c);return e}function M(a){var b=this;if(a&&"object"==typeof a&&a.constructor===b)return a;var c=new b(r);return z(c,a),c}function N(a){var b=this,c=new b(r);return C(c,a),c}function O(){throw new TypeError("You must pass a resolver function as the first argument to the promise constructor")}function P(){throw new TypeError("Failed to construct 'Promise': Please use the 'new' operator, this object constructor cannot be called as a function.")}function Q(a){this._id=na++,this._state=void 0,this._result=void 0,this._subscribers=[],r!==a&&(g(a)||O(),this instanceof Q||P(),I(this,a))}function R(){var a;if("undefined"!=typeof e)a=e;else if("undefined"!=typeof self)a=self;else try{a=Function("return this")()}catch(b){throw new Error("polyfill failed because global object is unavailable in this environment")}var c=a.Promise;(!c||"[object Promise]"!==Object.prototype.toString.call(c.resolve())||c.cast)&&(a.Promise=oa)}var S;S=Array.isArray?Array.isArray:function(a){return"[object Array]"===Object.prototype.toString.call(a)};var T,U,V,W=S,X=0,Y=({}.toString,function(a,b){ca[X]=a,ca[X+1]=b,X+=2,2===X&&(U?U(p):V())}),Z="undefined"!=typeof window?window:void 0,$=Z||{},_=$.MutationObserver||$.WebKitMutationObserver,aa="undefined"!=typeof d&&"[object process]"==={}.toString.call(d),ba="undefined"!=typeof Uint8ClampedArray&&"undefined"!=typeof importScripts&&"undefined"!=typeof MessageChannel,ca=new Array(1e3);V=aa?k():_?m():ba?n():void 0===Z&&"function"==typeof b?q():o();var da=void 0,ea=1,fa=2,ga=new F,ha=new F;J.prototype._validateInput=function(a){return W(a)},J.prototype._validationError=function(){return new Error("Array Methods must be provided an Array")},J.prototype._init=function(){this._result=new Array(this.length)};var ia=J;J.prototype._enumerate=function(){for(var a=this,b=a.length,c=a.promise,d=a._input,e=0;c._state===da&&b>e;e++)a._eachEntry(d[e],e)},J.prototype._eachEntry=function(a,b){var c=this,d=c._instanceConstructor;h(a)?a.constructor===d&&a._state!==da?(a._onerror=null,c._settledAt(a._state,b,a._result)):c._willSettleAt(d.resolve(a),b):(c._remaining--,c._result[b]=a)},J.prototype._settledAt=function(a,b,c){var d=this,e=d.promise;e._state===da&&(d._remaining--,a===fa?C(e,c):d._result[b]=c),0===d._remaining&&B(e,d._result)},J.prototype._willSettleAt=function(a,b){var c=this;D(a,void 0,function(a){c._settledAt(ea,b,a)},function(a){c._settledAt(fa,b,a)})};var ja=K,ka=L,la=M,ma=N,na=0,oa=Q;Q.all=ja,Q.race=ka,Q.resolve=la,Q.reject=ma,Q._setScheduler=i,Q._setAsap=j,Q._asap=Y,Q.prototype={constructor:Q,then:function(a,b){var c=this,d=c._state;if(d===ea&&!a||d===fa&&!b)return this;var e=new this.constructor(r),f=c._result;if(d){var g=arguments[d-1];Y(function(){H(d,e,g,f)})}else D(c,e,a,b);return e},"catch":function(a){return this.then(null,a)}};var pa=R,qa={Promise:oa,polyfill:pa};"function"==typeof a&&a.amd?a(function(){return qa}):"undefined"!=typeof c&&c.exports?c.exports=qa:"undefined"!=typeof this&&(this.ES6Promise=qa),pa()}).call(this)}).call(this,b("_process"),"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{_process:1}],3:[function(a,b,c){a("whatwg-fetch"),b.exports=self.fetch.bind(self)},{"whatwg-fetch":4}],4:[function(a,b,c){!function(){"use strict";function a(a){if("string"!=typeof a&&(a=a.toString()),/[^a-z0-9\-#$%&'*+.\^_`|~]/i.test(a))throw new TypeError("Invalid character in header field name");return a.toLowerCase()}function b(a){return"string"!=typeof a&&(a=a.toString()),a}function c(a){this.map={};var b=this;a instanceof c?a.forEach(function(a,c){c.forEach(function(c){b.append(a,c)})}):a&&Object.getOwnPropertyNames(a).forEach(function(c){b.append(c,a[c])})}function d(a){return a.bodyUsed?Promise.reject(new TypeError("Already read")):void(a.bodyUsed=!0)}function e(a){return new Promise(function(b,c){a.onload=function(){b(a.result)},a.onerror=function(){c(a.error)}})}function f(a){var b=new FileReader;return b.readAsArrayBuffer(a),e(b)}function g(a){var b=new FileReader;return b.readAsText(a),e(b)}function h(){return this.bodyUsed=!1,this._initBody=function(a){if(this._bodyInit=a,"string"==typeof a)this._bodyText=a;else if(n.blob&&Blob.prototype.isPrototypeOf(a))this._bodyBlob=a;else if(n.formData&&FormData.prototype.isPrototypeOf(a))this._bodyFormData=a;else{if(a)throw new Error("unsupported BodyInit type");this._bodyText=""}},n.blob?(this.blob=function(){var a=d(this);if(a)return a;if(this._bodyBlob)return Promise.resolve(this._bodyBlob);if(this._bodyFormData)throw new Error("could not read FormData body as blob");return Promise.resolve(new Blob([this._bodyText]))},this.arrayBuffer=function(){return this.blob().then(f)},this.text=function(){var a=d(this);if(a)return a;if(this._bodyBlob)return g(this._bodyBlob);if(this._bodyFormData)throw new Error("could not read FormData body as text");return Promise.resolve(this._bodyText)}):this.text=function(){var a=d(this);return a?a:Promise.resolve(this._bodyText)},n.formData&&(this.formData=function(){return this.text().then(k)}),this.json=function(){return this.text().then(JSON.parse)},this}function i(a){var b=a.toUpperCase();return o.indexOf(b)>-1?b:a}function j(a,b){if(b=b||{},this.url=a,this.credentials=b.credentials||"omit",this.headers=new c(b.headers),this.method=i(b.method||"GET"),this.mode=b.mode||null,this.referrer=null,("GET"===this.method||"HEAD"===this.method)&&b.body)throw new TypeError("Body not allowed for GET or HEAD requests");this._initBody(b.body)}function k(a){var b=new FormData;return a.trim().split("&").forEach(function(a){if(a){var c=a.split("="),d=c.shift().replace(/\+/g," "),e=c.join("=").replace(/\+/g," ");b.append(decodeURIComponent(d),decodeURIComponent(e))}}),b}function l(a){var b=new c,d=a.getAllResponseHeaders().trim().split("\n");return d.forEach(function(a){var c=a.trim().split(":"),d=c.shift().trim(),e=c.join(":").trim();b.append(d,e)}),b}function m(a,b){b||(b={}),this._initBody(a),this.type="default",this.url=null,this.status=b.status,this.ok=this.status>=200&&this.status<300,this.statusText=b.statusText,this.headers=b.headers instanceof c?b.headers:new c(b.headers),this.url=b.url||""}if(!self.fetch){c.prototype.append=function(c,d){c=a(c),d=b(d);var e=this.map[c];e||(e=[],this.map[c]=e),e.push(d)},c.prototype["delete"]=function(b){delete this.map[a(b)]},c.prototype.get=function(b){var c=this.map[a(b)];return c?c[0]:null},c.prototype.getAll=function(b){return this.map[a(b)]||[]},c.prototype.has=function(b){return this.map.hasOwnProperty(a(b))},c.prototype.set=function(c,d){this.map[a(c)]=[b(d)]},c.prototype.forEach=function(a){var b=this;Object.getOwnPropertyNames(this.map).forEach(function(c){a(c,b.map[c])})};var n={blob:"FileReader"in self&&"Blob"in self&&function(){try{return new Blob,!0}catch(a){return!1}}(),formData:"FormData"in self},o=["DELETE","GET","HEAD","OPTIONS","POST","PUT"];h.call(j.prototype),h.call(m.prototype),self.Headers=c,self.Request=j,self.Response=m,self.fetch=function(a,b){var c;return c=j.prototype.isPrototypeOf(a)&&!b?a:new j(a,b),new Promise(function(a,b){function d(){return"responseURL"in e?e.responseURL:/^X-Request-URL:/m.test(e.getAllResponseHeaders())?e.getResponseHeader("X-Request-URL"):void 0}var e=new XMLHttpRequest;e.onload=function(){var c=1223===e.status?204:e.status;if(100>c||c>599)return void b(new TypeError("Network request failed"));var f={status:c,statusText:e.statusText,headers:l(e),url:d()},g="response"in e?e.response:e.responseText;a(new m(g,f))},e.onerror=function(){b(new TypeError("Network request failed"))},e.open(c.method,c.url,!0),"include"===c.credentials&&(e.withCredentials=!0),"responseType"in e&&n.blob&&(e.responseType="blob"),c.headers.forEach(function(a,b){b.forEach(function(b){e.setRequestHeader(a,b)})}),e.send("undefined"==typeof c._bodyInit?null:c._bodyInit)})},self.fetch.polyfill=!0}}()},{}],5:[function(a,b,c){function d(a,b){j.prototype[b]=function(){return this[a][b].apply(this[a],arguments)}}var e=a("./globals"),f=a("./utils"),g=a("./helpers"),h=a("./plumbing"),i=0,j=b.exports=function(a){var b=this;if(b.settings=f.extend(b.settings,e),b.settings.instanceId=++i,b.helpers=new g(b),b.plumbing=new h(b),a=a||{},!a.client_id&&!a.app_key)throw"client_id must be set";if(b.settings.clientId=a.client_id||a.app_key,!a.environment)throw"environment must be set";b.settings.environment=a.environment,b.settings.redirectUri=a.redirect_uri||a.auth_callback,b.settings.autoSignin=a.auto_signin,b.settings.autoExpire=a.auto_expire,a.save_access_token&&(b.settings.saveAccessToken=!0,b.helpers.readAccessToken()),a.access_token&&(b.settings.accessToken=a.access_token),a.pending_modifications&&f.isArray(a.pending_modifications)&&(b.settings.pendingModifications=a.pending_modifications.join(",")),b.settings.debug=a.debug,b.settings.collectionsPromises={collections:b.plumbing.get(b.settings.collectionsUrl)},b.settings.expireCallback=a.expire_callback};a("./modules/authorities"),a("./modules/authentication"),a("./modules/changeHistory"),a("./modules/discussions"),a("./modules/memories"),a("./modules/notes"),a("./modules/parentsAndChildren"),a("./modules/pedigree"),a("./modules/persons"),a("./modules/places"),a("./modules/searchAndMatch"),a("./modules/sourceBox"),a("./modules/sources"),a("./modules/spouses"),a("./modules/users"),a("./modules/utilities"),a("./classes/base"),a("./classes/agent"),a("./classes/attribution"),a("./classes/change"),a("./classes/childAndParents"),a("./classes/collection"),a("./classes/comment"),a("./classes/couple"),a("./classes/date"),a("./classes/discussion"),a("./classes/discussionRef"),a("./classes/fact"),a("./classes/gender"),a("./classes/memoryArtifactRef"),a("./classes/memoryPersona"),a("./classes/memoryPersonaRef"),a("./classes/memory"),a("./classes/name"),a("./classes/note"),a("./classes/person"),a("./classes/placeDescription"),a("./classes/placeReference"),a("./classes/placesSearchResult"),a("./classes/searchResult"),a("./classes/sourceDescription"),a("./classes/sourceRef"),a("./classes/textValue"),a("./classes/user"),a("./classes/vocabularyElement"),a("./classes/vocabularyList"),d("plumbing","del"),d("plumbing","get"),d("plumbing","getTotalProcessingTime"),d("plumbing","getUrl"),d("plumbing","http"),d("plumbing","post"),d("plumbing","put"),d("plumbing","setTotalProcessingTime")},{"./classes/agent":6,"./classes/attribution":7,"./classes/base":8,"./classes/change":9,"./classes/childAndParents":10,"./classes/collection":11,"./classes/comment":12,"./classes/couple":13,"./classes/date":14,"./classes/discussion":15,"./classes/discussionRef":16,"./classes/fact":17,"./classes/gender":18,"./classes/memory":19,"./classes/memoryArtifactRef":20,"./classes/memoryPersona":21,"./classes/memoryPersonaRef":22,"./classes/name":23,"./classes/note":24,"./classes/person":25,"./classes/placeDescription":26,"./classes/placeReference":27,"./classes/placesSearchResult":28,"./classes/searchResult":29,"./classes/sourceDescription":30,"./classes/sourceRef":31,"./classes/textValue":32,"./classes/user":33,"./classes/vocabularyElement":34,"./classes/vocabularyList":35,"./globals":36,"./helpers":37,"./modules/authentication":38,"./modules/authorities":39,"./modules/changeHistory":40,"./modules/discussions":41,"./modules/memories":42,"./modules/notes":43,"./modules/parentsAndChildren":44,"./modules/pedigree":45,"./modules/persons":46,"./modules/places":47,"./modules/searchAndMatch":48,"./modules/sourceBox":49,"./modules/sources":50,"./modules/spouses":51,"./modules/users":52,"./modules/utilities":53,"./plumbing":54,"./utils":56}],6:[function(a,b,c){var d=a("./../FamilySearch"),e=a("./../utils"),f=e.maybe,g=d.Agent=function(a,b){d.BaseClass.call(this,a,b)};d.prototype.createAgent=function(a){return new g(this,a)},g.prototype=e.extend(Object.create(d.BaseClass.prototype),{constructor:g,getName:function(){return f(f(this.data.names)[0]).value},getAccountName:function(){return f(f(this.data.accounts)[0]).accountName},getEmail:function(){var a=f(f(this.data.emails)[0]).resource;return a?a.replace(/^mailto:/,""):a},getPhoneNumber:function(){return f(f(this.data.phones)[0]).resource},getAddress:function(){return f(f(this.data.addresses)[0]).value}})},{"./../FamilySearch":5,"./../utils":56}],7:[function(a,b,c){var d=a("./../FamilySearch"),e=a("./../utils"),f=e.maybe,g=d.Attribution=function(a,b){e.isString(b)&&(b={changeMessage:b}),d.BaseClass.call(this,a,b)};d.prototype.createAttribution=function(a){return new g(this,a)},g.prototype=e.extend(Object.create(d.BaseClass.prototype),{constructor:g,getModifiedTimestamp:function(){return this.data.modified},getChangeMessage:function(){return this.data.changeMessage},getAgentId:function(){return f(this.data.contributor).resourceId},getAgentUrl:function(){return this.client.helpers.removeAccessToken(f(this.data.contributor).resource)},getAgent:function(){return this.client.getAgent(this.getAgentUrl())}})},{"./../FamilySearch":5,"./../utils":56}],8:[function(a,b,c){function d(a){if(f.isFunction(a)&&a instanceof e.BaseClass)return a.toJSON();if(f.isArray(a)){for(var b=[],c=0;cb&&(b=this.data.qualifiers.push({name:"http://familysearch.org/v1/Event"})-1),this.data.qualifiers[b].value="false"):this.data.qualifiers&&(b=e.findIndex(this.data.qualifiers,{name:"http://familysearch.org/v1/Event"}),b>=0&&this.data.qualifiers.splice(b,1),0===this.data.qualifiers.length&&delete this.data.qualifiers),this.changed=!0,this},setDate:function(a){return this.changed=!0,a instanceof d.Date?this.data.date=a:this.data.date=this.client.createDate(a),this},setOriginalDate:function(a){return this.changed=!0,this.data.date||(this.data.date=this.client.createDate()),this.data.date.setOriginal(a),this},setFormalDate:function(a){return this.changed=!0,this.data.date||(this.data.date=this.client.createDate()),this.data.date.setFormal(a),this},setNormalizedDate:function(a){return this.changed=!0,this.data.date||(this.data.date=this.client.createDate()),this.data.date.setNormalized(a),this},setPlace:function(a){return this.changed=!0,a instanceof d.PlaceReference?this.data.place=a:a instanceof d.PlaceDescription?this.data.place=this.client.createPlaceReference({original:a.getFullName(),normalized:a.getFullName()}):this.data.place=this.client.createPlaceReference(a),this},setOriginalPlace:function(a){return this.changed=!0,this.data.place||(this.data.place=this.client.createPlaceReference()),this.data.place.setOriginal(a),this},setNormalizedPlace:function(a){return this.changed=!0,this.data.place||(this.data.place=this.client.createPlaceReference()),this.data.place.setNormalized(a),this}})},{"./../FamilySearch":5,"./../utils":56}],18:[function(a,b,c){var d=a("./../FamilySearch"),e=a("../utils"),f=d.Gender=function(a,b){d.BaseClass.call(this,a,b),this.changed=!1};d.prototype.createGender=function(a){return new f(this,a)},f.prototype=e.extend(Object.create(d.BaseClass.prototype),{constructor:f,getType:function(){return this.data.type},setType:function(a){return this.changed=!0,this.data.type=a,this}})},{"../utils":56,"./../FamilySearch":5}],19:[function(a,b,c){var d=a("./../FamilySearch"),e=a("./../utils"),f=e.maybe,g=d.Memory=function(a,b){d.BaseClass.call(this,a,b)};d.prototype.createMemory=function(a){return new g(this,a)},g.prototype=e.extend(Object.create(d.BaseClass.prototype),{constructor:g,getMediaType:function(){return this.data.mediaType},getResourceType:function(){return this.data.resourceType},getAbout:function(){return this.data.about},getArtifactMetadata:function(){return f(this.data.artifactMetadata)},getTitle:function(){return f(f(this.data.titles)[0]).value},getDescription:function(){return f(f(this.data.description)[0]).value},getIconUrl:function(){return this.helpers.appendAccessToken(f(this.getLink("image-icon")).href)},getThumbnailUrl:function(){return this.helpers.appendAccessToken(f(this.getLink("image-thumbnail")).href)},getImageUrl:function(){return this.helpers.appendAccessToken(f(this.getLink("image")).href)},getMemoryArtifactUrl:function(){return this.helpers.appendAccessToken(this.helpers.removeAccessToken(this.data.about))},getMemoryUrl:function(){return this.helpers.removeAccessToken(f(this.getLink("description")).href)},getArtifactFilename:function(){return f(f(this.data.artifactMetadata)[0]).filename},getArtifactType:function(){return f(f(this.data.artifactMetadata)[0]).artifactType},getArtifactHeight:function(){return f(f(this.data.artifactMetadata)[0]).height},getArtifactWidth:function(){return f(f(this.data.artifactMetadata)[0]).width},getCommentsUrl:function(){return this.helpers.removeAccessToken(f(this.getLink("comments")).href)},getComments:function(){return this.client.getMemoryComments(this.getCommentsUrl())},setTitle:function(a){return this.data.titles=[{value:a}],this},setDescription:function(a){return this.data.description=[{value:a}],this},setArtifactFilename:function(a){return e.isArray(this.data.artifactMetadata)&&this.artifactMetadata.length||(this.data.artifactMetadata=[{}]),this.data.artifactMetadata[0].filename=a,this},save:function(){var a=this,b=a.getMemoryUrl()?Promise.resolve(a.getMemoryUrl()):a.plumbing.getCollectionUrl("FSMEM","artifacts");return b.then(function(b){if(a.getId())return a.plumbing.post(b,{sourceDescriptions:[a]});var c={};return a.getTitle()&&(c.title=a.getTitle()),a.getDescription()&&(c.description=a.getDescription()),a.getArtifactFilename()&&(c.filename=a.getArtifactFilename()),a.plumbing.post(a.helpers.appendQueryParameters(b,c),a.data.data,{"Content-Type":e.isString(a.data.data)?"text/plain":"multipart/form-data"}).then(function(b){return a.updateFromResponse(b,"description"),b})})},"delete":function(){return this.client.deleteMemory(this.getMemoryUrl())}})},{"./../FamilySearch":5,"./../utils":56}],20:[function(a,b,c){var d=a("./../FamilySearch"),e=a("./../utils"),f=e.maybe,g=d.MemoryArtifactRef=function(a,b){d.BaseClass.call(this,a,b),b&&b.qualifierName&&b.qualifierValue&&(this.setQualifierName(b.qualifierName),this.setQualifierValue(b.qualifierValue),delete b.qualifierName,delete b.qualifierValue)};d.prototype.createMemoryArtifactRef=function(a){return new g(this,a)},g.prototype=e.extend(Object.create(d.BaseClass.prototype),{constructor:g,getDescription:function(){return this.data.description},getQualifierName:function(){return f(f(this.data.qualifiers)[0]).name},getQualifierValue:function(){return f(f(this.data.qualifiers)[0]).value},setQualifierName:function(a){return e.isArray(this.data.qualifiers)&&this.data.qualifiers.length||(this.data.qualifiers=[{}]),this.data.qualifiers[0].name=a,this},setQualifierValue:function(a){return e.isArray(this.data.qualifiers)&&this.data.qualifiers.length||(this.data.qualifiers=[{}]),this.data.qualifiers[0].value=a,this}})},{"./../FamilySearch":5,"./../utils":56}],21:[function(a,b,c){var d=a("./../FamilySearch"),e=a("./../utils"),f=e.maybe,g=d.MemoryPersona=function(a,b){d.BaseClass.call(this,a,b),b&&(b.name&&this.setName(b.name),b.memoryArtifactRef&&this.setMemoryArtifactRef(b.memoryArtifactRef))};d.prototype.createMemoryPersona=function(a){return new g(this,a)},g.prototype=e.extend(Object.create(d.BaseClass.prototype),{constructor:g,isExtracted:function(){return this.data.extracted},getMemoryPersonaUrl:function(){return this.helpers.removeAccessToken(f(this.getLink("persona")).href)},getMemoryArtifactRef:function(){return f(this.data.media)[0]},getName:function(){return f(this.data.names)[0]},getDisplayName:function(){return f(this.data.display).name},getMemoryUrl:function(){return this.helpers.removeAccessToken(f(this.getMemoryArtifactRef()).description)},getMemory:function(){return this.client.getMemory(this.getMemoryUrl())},setName:function(a){return a instanceof d.Name||(a=this.client.createName(a)),this.data.names=[a],this},setMemoryArtifactRef:function(a){return this.data.media=[a],this},save:function(a){var b=this;return Promise.resolve(a?a:b.getMemoryPersonaUrl()).then(function(a){return b.plumbing.post(a,{persons:[b]})}).then(function(a){return b.updateFromResponse(a,"persona"),a})},"delete":function(){return this.client.deleteMemoryPersona(this.getMemoryPersonaUrl())}})},{"./../FamilySearch":5,"./../utils":56}],22:[function(a,b,c){var d=a("./../FamilySearch"),e=a("./../utils"),f=e.maybe,g=d.MemoryPersonaRef=function(a,b){d.BaseClass.call(this,a,b),b&&b.memoryPersona&&(this.setMemoryPersona(b.memoryPersona),delete b.memoryPersona)};d.prototype.createMemoryPersonaRef=function(a){return new g(this,a)},g.prototype=e.extend(Object.create(d.BaseClass.prototype),{constructor:g,getResource:function(){return this.data.resource},getResourceId:function(){return this.data.resourceId},getMemoryPersonaRefUrl:function(){return this.helpers.removeAccessToken(f(this.getLink("evidence-reference")).href)},getMemoryPersonaUrl:function(){return this.helpers.removeAccessToken(this.data.resource)},getMemoryPersona:function(){return this.client.getMemoryPersona(this.getMemoryPersonaUrl())},getMemoryUrl:function(){return this.helpers.removeAccessToken(f(this.getLink("memory")).href)},getMemory:function(){return this.client.getMemory(this.getMemoryUrl())},setMemoryPersona:function(a){return a instanceof d.MemoryPersona&&(a=a.getMemoryPersonaUrl()),this.data.resource=this.helpers.removeAccessToken(a),this},save:function(a){var b=this;return b.plumbing.post(a,{persons:[{evidence:[b]}]}).then(function(a){return b.updateFromResponse(a,"evidence-reference"),a})},"delete":function(){return this.client.deleteMemoryPersonaRef(this.getMemoryPersonaRefUrl())}})},{"./../FamilySearch":5,"./../utils":56}],23:[function(a,b,c){function d(a,b){var c=b||0;for(f.isArray(a.data.nameForms)||(a.data.nameForms=[]);c>=a.data.nameForms.length;)a.data.nameForms.push({});return a.data.nameForms[c]}var e=a("./../FamilySearch"),f=a("./../utils"),g=f.maybe,h=e.Name=function(a,b){e.BaseClass.call(this,a,b),b&&(f.isString(b)?(this.data={},this.setFullText(b)):(b.type&&this.setType(b.type),b.givenName&&(this.setGivenName(b.givenName),delete b.givenName),b.surname&&(this.setSurname(b.surname),delete b.surname),b.prefix&&(this.setPrefix(b.prefix),delete b.prefix),b.suffix&&(this.setSuffix(b.suffix),delete b.suffix),b.fullText&&(this.setFullText(b.fullText),delete b.fullText),this.setPreferred(!!b.preferred),b.changeMessage&&(this.setChangeMessage(b.changeMessage),delete b.changeMessage),!b.attribution||b.attribution instanceof e.Attribution||(this.attribution=a.createAttribution(b.attribution))))};e.prototype.createName=function(a){return new h(this,a)},h.prototype=f.extend(Object.create(e.BaseClass.prototype),{constructor:h,getType:function(){return this.data.type},isPreferred:function(){return this.data.preferred},getNameFormsCount:function(){return this.data.nameForms?this.data.nameForms.length:0},getNameForm:function(a){return g(this.data.nameForms)[a||0]},getFullText:function(a){return g(this.getNameForm(a)).fullText},getLang:function(a){return g(this.getNameForm(a)).lang},getNamePart:function(a,b){return g(f.find(g(this.getNameForm(b)).parts,{type:a})).value},getGivenName:function(a){return this.getNamePart("http://gedcomx.org/Given",a)},getSurname:function(a){return this.getNamePart("http://gedcomx.org/Surname",a)},getPrefix:function(a){return this.getNamePart("http://gedcomx.org/Prefix",a)},getSuffix:function(a){return this.getNamePart("http://gedcomx.org/Suffix",a)},setType:function(a){return this.changed=!0,a?this.data.type=a:delete this.data.type,this},setPreferred:function(a){return this.changed=!0,this.data.preferred=a,this},setFullText:function(a,b){this.changed=!0;var c=d(this,b);return a?c.fullText=a:delete c.fullText,this},setNamePart:function(a,b,c){this.changed=!0;var e=d(this,c);f.isArray(e.parts)||(e.parts=[]);var g=f.find(e.parts,{type:b});return a?(g||(g={type:b},e.parts.push(g)),g.value=a):g&&e.parts.splice(e.parts.indexOf(g),1),this},setGivenName:function(a,b){return this.setNamePart(a,"http://gedcomx.org/Given",b)},setSurname:function(a,b){return this.setNamePart(a,"http://gedcomx.org/Surname",b)},setPrefix:function(a,b){return this.setNamePart(a,"http://gedcomx.org/Prefix",b)},setSuffix:function(a,b){return this.setNamePart(a,"http://gedcomx.org/Suffix",b)},setChangeMessage:function(a){return this.setAttribution(this.client.createAttribution(a)),this}})},{"./../FamilySearch":5,"./../utils":56}],24:[function(a,b,c){var d=a("./../FamilySearch"),e=a("./../utils"),f=e.maybe,g=d.Note=function(a,b){d.BaseClass.call(this,a,b),!this.attribution||this.attribution instanceof d.Attribution||(this.attribution=a.createAttribution(this.attribution))};d.prototype.createNote=function(a){return new g(this,a)},g.prototype=e.extend(Object.create(d.BaseClass.prototype),{constructor:g,getSubject:function(){return this.data.subject},getText:function(){return this.data.text},getNoteUrl:function(){return this.helpers.removeAccessToken(f(this.getLink("note")).href)},save:function(a,b){var c=this;a||(a=c.getNoteUrl());var d={},e=c.helpers.getEntityType(a);"childAndParentsRelationships"===e&&(d["Content-Type"]="application/x-fs-v1+json");var f={};return f[e]=[{notes:[c]}],b&&(f[e][0].attribution=c.client.createAttribution(b)),c.plumbing.post(a,f,d).then(function(a){return c.updateFromResponse(a,"note"),a})},"delete":function(a){return this.client.deleteNote(this.getNoteUrl(),a)}})},{"./../FamilySearch":5,"./../utils":56}],25:[function(a,b,c){function d(a){return a?" "+a:""}var e=a("../FamilySearch"),f=a("../utils"),g=f.maybe,h=e.Person=function(a,b){e.BaseClass.call(this,a,b),b&&(b.gender&&this.setGender(b.gender),b.names&&f.forEach(this.data.names,function(b,c){b instanceof e.Name||(this.data.names[c]=a.createName(b))},this),b.facts&&f.forEach(this.data.facts,function(b,c){b instanceof e.Fact||(this.data.facts[c]=a.createFact(b))},this))};e.prototype.createPerson=function(a){return new h(this,a)},h.prototype=f.extend(Object.create(e.BaseClass.prototype),{constructor:h,isLiving:function(){return this.data.living},getDisplay:function(){return g(this.data.display)},getIdentifiers:function(){return g(this.data.identifiers)},getGender:function(){return this.data.gender},getFacts:function(a){return(a?f.filter(this.data.facts,{type:a}):this.data.facts)||[]},getFact:function(a){return f.find(this.data.facts,function(b){return b.getType()===a})},getBirth:function(){return this.getFact("http://gedcomx.org/Birth")},getBirthDate:function(){var a=this.getBirth();return a?a.getOriginalDate():""},getBirthPlace:function(){var a=this.getBirth();return a?a.getOriginalPlace():""},getChristening:function(){return this.getFact("http://gedcomx.org/Christening")},getChristeningDate:function(){var a=this.getChristening();return a?a.getOriginalDate():""},getChristeningPlace:function(){var a=this.getChristening();return a?a.getOriginalPlace():""},getDeath:function(){return this.getFact("http://gedcomx.org/Death")},getDeathDate:function(){var a=this.getDeath();return a?a.getOriginalDate():""},getDeathPlace:function(){var a=this.getDeath();return a?a.getOriginalPlace():""},getBurial:function(){return this.getFact("http://gedcomx.org/Burial")},getBurialDate:function(){var a=this.getBurial();return a?a.getOriginalDate():""},getBurialPlace:function(){var a=this.getBurial();return a?a.getOriginalPlace():""},getDisplayBirthDate:function(){return this.getDisplay().birthDate},getDisplayBirthPlace:function(){return this.getDisplay().birthPlace},getDisplayDeathDate:function(){return this.getDisplay().deathDate},getDisplayDeathPlace:function(){return this.getDisplay().deathPlace},getDisplayGender:function(){return this.getDisplay().gender},getDisplayLifeSpan:function(){return this.getDisplay().lifespan},getDisplayName:function(){return this.getDisplay().name},getNames:function(a){return(a?f.filter(this.data.names,function(b){return b.getType()===a}):this.data.names)||[]},getPreferredName:function(){return f.findOrFirst(this.data.names,function(a){return a.isPreferred()})},getGivenName:function(){var a=this.getPreferredName();return a&&(a=a.getGivenName()),a},getSurname:function(){var a=this.getPreferredName();return a&&(a=a.getSurname()),a},getPersistentIdentifier:function(){return g(this.getIdentifiers()["http://gedcomx.org/Persistent"])[0]},getPersonUrl:function(){return this.helpers.removeAccessToken(g(this.getLink("person")).href)},getChanges:function(a){var b=this;return b.getLinkPromise("change-history").then(function(c){return b.client.getChanges(c.href,a)})},getDiscussionRefs:function(){return this.client.getPersonDiscussionRefs(this.helpers.removeAccessToken(g(this.getLink("discussion-references")).href))},getMemoryPersonaRefs:function(){return this.client.getMemoryPersonaRefs(this.helpers.removeAccessToken(g(this.getLink("evidence-references")).href))},getNotes:function(){return this.client.getPersonNotes(this.helpers.removeAccessToken(g(this.getLink("notes")).href))},getSourceRefs:function(){return this.client.getPersonSourceRefs(this.getId())},getSources:function(){return this.client.getPersonSourcesQuery(this.getId())},getSpouses:function(){var a=this;return a.getLinkPromise("spouses").then(function(b){return a.plumbing.get(b.href)}).then(function(b){return a.client._personsAndRelationshipsMapper(b)})},getParents:function(){var a=this;return a.getLinkPromise("parents").then(function(b){return a.plumbing.get(b.href)}).then(function(b){return a.client._personsAndRelationshipsMapper(b)})},getChildren:function(){var a=this;return a.getLinkPromise("children").then(function(b){return a.plumbing.get(b.href)}).then(function(b){return a.client._personsAndRelationshipsMapper(b)})},getMatches:function(){return this.client.getPersonMatches(this.getId())},getAncestry:function(a){return this.client.getAncestry(this.getId(),a)},getDescendancy:function(a){return this.client.getDescendancy(this.getId(),a)},getPersonPortraitUrl:function(a){return this.client.getPersonPortraitUrl(this.getLink("portrait").href,a)},setNames:function(a,b){return f.isArray(this.data.names)&&f.forEach(this.data.names,function(a){this.deleteName(a,b)},this),this.data.names=[],f.forEach(a,function(a){this.addName(a)},this),this},addName:function(a){return f.isArray(this.data.names)||(this.data.names=[]),a instanceof e.Name||(a=this.client.createName(a)),this.data.names.push(a),this},deleteName:function(a,b){a instanceof e.Name||(a=f.find(this.data.names,function(b){return b.getId()===a}));var c=f.indexOf(this.data.names,a);return c>=0&&(this.deletedConclusions||(this.deletedConclusions={}),this.deletedConclusions[a.getId()]=b,this.data.names.splice(c,1)),this},setFacts:function(a,b){return f.isArray(this.data.facts)&&f.forEach(this.data.facts,function(a){this.deleteFact(a,b)},this),this.data.facts=[],f.forEach(a,function(a){this.addFact(a)},this),this},addFact:function(a){return f.isArray(this.data.facts)||(this.data.facts=[]),a instanceof e.Fact||(a=this.client.createFact(a)),this.data.facts.push(a),this},deleteFact:function(a,b){a instanceof e.Fact||(a=f.find(this.data.facts,function(b){return b.getId()===a}));var c=f.indexOf(this.data.facts,a);return c>=0&&(this.deletedConclusions||(this.deletedConclusions={}),this.deletedConclusions[a.getId()]=b,this.data.facts.splice(c,1)),this},setGender:function(a,b){return f.isString(a)?this.data.gender=this.client.createGender().setType(a):this.data.gender=this.client.createGender(a),b&&this.data.gender.setAttribution(b),this},save:function(a){var b=this.client.createPerson(),c=!1;this.getId()?b.setId(this.getId()):(this.data.gender||this.setGender("http://gedcomx.org/Unknown"),0===this.getNames().length&&this.addName({fullText:"Unknown",givenName:"Unknown"}),f.find(this.getNames(),function(a){return a.isPreferred()})||this.getNames()[0].setPreferred(!0),1!==this.getNames().length||this.getNames()[0].type||this.getNames()[0].setType("http://gedcomx.org/BirthName"),f.isUndefined(this.data.living)&&(this.data.living=!1)),a&&b.setAttribution(a),this.getId()||(b.data.living=this.data.living),!this.data.gender||this.data.gender.id&&!this.data.gender.changed||(b.data.gender=this.data.gender,delete b.data.gender.changed,c=!0),f.forEach(this.getNames(),function(a){(!a.getId()||a.changed)&&(a.getFullText()||a.setFullText((d(a.getPrefix())+d(a.getGivenName())+d(a.getSurname())+d(a.getSuffix())).trim()),b.addName(a),c=!0)}),f.forEach(this.getFacts(),function(a){(!a.getId()||a.changed)&&(b.addFact(a),c=!0)});var e=[],g=this;if(c){var h=b.getId()?g.plumbing.getCollectionUrl("FSFT","person",{pid:b.getId()}):g.plumbing.getCollectionUrl("FSFT","persons");e.push(h.then(function(a){return g.plumbing.post(a,{persons:[b]})}).then(function(a){return g.updateFromResponse(a,"person"),a}))}return this.getId()&&this.deletedConclusions&&f.forEach(this.deletedConclusions,function(c,d){c=c||a,e.push(g.plumbing.getCollectionUrl("FSFT","person",{pid:b.getId()}).then(function(a){return g.plumbing.del(a+"/conclusions/"+d,c?{"X-Reason":c}:{})}))}),Promise.all(e)},"delete":function(a){return this.client.deletePerson(this.getPersonUrl(),a)},restore:function(){var a=this;return a.getLinkPromise("restore").then(function(b){return a.plumbing.post(b.href,null,{"Content-Type":"application/x-fs-v1+json"})})}})},{"../FamilySearch":5,"../utils":56}],26:[function(a,b,c){var d=a("./../FamilySearch"),e=a("./../utils"),f=d.PlaceDescription=function(a,b){d.BaseClass.call(this,a,b),b&&b.names&&e.forEach(this.data.names,function(b,c){b instanceof d.TextValue||(this.data.names[c]=a.createTextValue(b))},this)};d.prototype.createPlaceDescription=function(a){return new f(this,a)},f.prototype=e.extend(Object.create(d.BaseClass.prototype),{constructor:f,getNames:function(){return e.maybe(this.data.names)},getLang:function(){return this.data.lang},getIdentifiers:function(){return e.maybe(this.data.identifiers)},getTypeUri:function(){return this.data.type},getLatitude:function(){return this.data.latitude},getLongitude:function(){return this.data.longitude},getTemporalDescription:function(){return e.maybe(this.data.temporalDescription)},getDisplay:function(){return e.maybe(this.data.display)},getName:function(){return this.getDisplay().name},getFullName:function(){return this.getDisplay().fullName},getType:function(){return this.getDisplay().type},getPlaceDescriptionUrl:function(){return this.helpers.removeAccessToken(e.maybe(this.getLink("description")).href)},getJurisdictionSummary:function(){return this.data.jurisdiction instanceof d.PlaceDescription?this.data.jurisdiction:void 0},getJurisdictionDetails:function(){return this.data.jurisdiction instanceof d.PlaceDescription?this.client.getPlaceDescription(this.data.jurisdiction.getPlaceDescriptionUrl()):Promise.reject(new Error("No jurisdiction available"))},setJurisdiction:function(a){return a instanceof d.PlaceDescription||(a=this.client.createPlaceDescription(a)),this.data.jurisdiction=a,this}})},{"./../FamilySearch":5,"./../utils":56}],27:[function(a,b,c){var d=a("./../FamilySearch"),e=a("./../utils"),f=d.PlaceReference=function(a,b){d.BaseClass.call(this,a,b),b&&e.isString(b.normalized)&&this.setNormalized(b.normalized)};d.prototype.createPlaceReference=function(a){return new f(this,a)},f.prototype=e.extend(Object.create(d.BaseClass.prototype),{constructor:f,getOriginal:function(){return this.data.original},getNormalized:function(){return e.maybe(e.maybe(this.data.normalized)[0]).value},setOriginal:function(a){return this.data.original=a,this},setNormalized:function(a){return this.data.normalized=[{value:a}],this}})},{"./../FamilySearch":5,"./../utils":56}],28:[function(a,b,c){var d=a("./../FamilySearch"),e=a("./../utils"),f=d.PlacesSearchResult=function(a,b){if(d.BaseClass.call(this,a,b),b&&b.content&&b.content.gedcomx&&b.content.gedcomx.places){var c=b.content.gedcomx.places,f={};e.forEach(c,function(b,c,e){b instanceof d.PlaceDescription||(e[c]=f[b.id]=a.createPlaceDescription(b))}),e.forEach(c,function(a){if(a.data.jurisdiction&&a.data.jurisdiction.resource){var b=a.data.jurisdiction.resource.substring(1);f[b]&&a.setJurisdiction(f[b])}})}};d.prototype.createPlacesSearchResult=function(a){return new f(this,a)},f.prototype=e.extend(Object.create(d.BaseClass.prototype),{constructor:f,getScore:function(){return this.data.score},getPlace:function(){var a=e.maybe;return a(a(a(this.data.content).gedcomx).places)[0]}})},{"./../FamilySearch":5,"./../utils":56}],29:[function(a,b,c){var d=a("./../FamilySearch"),e=a("./../utils"),f=e.maybe,g=d.SearchResult=function(a,b){d.BaseClass.call(this,a,b),e.forEach(f(f(f(b).content).gedcomx).persons,function(b,c,e){b instanceof d.Person||(e[c]=a.createPerson(b))})};d.prototype.createSearchResult=function(a){return new g(this,a)},g.prototype=e.extend(Object.create(d.BaseClass.prototype),{constructor:g,getTitle:function(){return this.data.title},getScore:function(){return this.data.score},getPerson:function(a){return e.find(f(f(this.data.content).gedcomx).persons,function(b){return b.getId()===a})},getPrimaryPerson:function(){return this.getPerson(this.getId())},getFullPrimaryPerson:function(){return this.client.getPerson(this.getId())},getFatherIds:function(){var a=this.getId(),b=this;return e.uniq(e.map(e.filter(f(f(this.data.content).gedcomx).relationships,function(c){return"http://gedcomx.org/ParentChild"===c.type&&c.person2.resourceId===a&&c.person1&&"http://gedcomx.org/Male"===b.getPerson(c.person1.resourceId).getGender().getType()}),function(a){return a.person1.resourceId}))},getFathers:function(){return e.map(this.getFatherIds(),this.getPerson,this)},getMotherIds:function(){var a=this.getId(),b=this;return e.uniq(e.map(e.filter(f(f(this.data.content).gedcomx).relationships,function(c){return"http://gedcomx.org/ParentChild"===c.type&&c.person2.resourceId===a&&c.person1&&"http://gedcomx.org/Male"!==b.getPerson(c.person1.resourceId).getGender().getType()}),function(a){return a.person1.resourceId}))},getMothers:function(){return e.map(this.getMotherIds(),this.getPerson,this)},getSpouseIds:function(){var a=this.getId();return e.uniq(e.map(e.filter(f(f(this.data.content).gedcomx).relationships,function(b){return"http://gedcomx.org/Couple"===b.type&&(b.person1.resourceId===a||b.person2.resourceId===a)}),function(b){return b.person1.resourceId===a?b.person2.resourceId:b.person1.resourceId}))},getSpouses:function(){return e.map(this.getSpouseIds(),this.getPerson,this)},getChildIds:function(){var a=this.getId();return e.uniq(e.map(e.filter(f(f(this.data.content).gedcomx).relationships,function(b){return"http://gedcomx.org/ParentChild"===b.type&&b.person1.resourceId===a&&b.person2}),function(a){return a.person2.resourceId}))},getChildren:function(){return e.map(this.getChildIds(),this.getPerson,this)}})},{"./../FamilySearch":5,"./../utils":56}],30:[function(a,b,c){var d=a("./../FamilySearch"),e=a("./../utils"),f=e.maybe,g=d.SourceDescription=function(a,b){d.BaseClass.call(this,a,b),b&&(b.citation&&(this.setCitation(b.citation),delete b.citation),b.title&&(this.setTitle(b.title),delete b.title),b.text&&(this.setText(b.text),delete b.text))};d.prototype.createSourceDescription=function(a){return new g(this,a)},g.prototype=e.extend(Object.create(d.BaseClass.prototype),{constructor:g,getAbout:function(){return this.data.about},getCitation:function(){return f(f(this.data.citations)[0]).value},getTitle:function(){return f(f(this.data.titles)[0]).value},getText:function(){return f(f(this.data.notes)[0]).text},getSourceDescriptionUrl:function(){return this.helpers.removeAccessToken(f(this.getLink("description")).href)},getSourceRefsQuery:function(){return this.client.getSourceRefsQuery(f(this.getLink("source-references-query")).href)},setCitation:function(a){return this.data.citations=[{value:a}],this},setTitle:function(a){return this.data.titles=[{value:a}],this},setText:function(a){return this.data.notes=[{text:a}],this},save:function(a){var b=this;a&&b.setAttribution(b.client.createAttribution(a));var c=b.getSourceDescriptionUrl()?Promise.resolve(b.getSourceDescriptionUrl()):b.plumbing.getCollectionUrl("FSUDS","source-descriptions");return c.then(function(a){return b.plumbing.post(a,{sourceDescriptions:[b]})}).then(function(a){return b.updateFromResponse(a,"description"),a})},"delete":function(a){return this.client.deleteSourceDescription(this.getSourceDescriptionUrl(),a)}})},{"./../FamilySearch":5,"./../utils":56}],31:[function(a,b,c){var d=a("./../FamilySearch"),e=a("./../utils"),f=e.maybe,g=d.SourceRef=function(a,b){d.BaseClass.call(this,a,b),b&&b.sourceDescription&&(this.setSourceDescription(b.sourceDescription),delete b.sourceDescription)};d.prototype.createSourceRef=function(a){return new g(this,a)},g.prototype=e.extend(Object.create(d.BaseClass.prototype),{constructor:g,getDescription:function(){return this.data.description},getSourceRefUrl:function(){return this.helpers.removeAccessToken(f(this.getLink("source-reference")).href)},getSourceDescriptionUrl:function(){return this.helpers.removeAccessToken(this.getDescription())},getSourceDescriptionId:function(){return this.getSourceDescriptionUrl().split("/").pop()},getSourceDescription:function(){return this.client.getSourceDescription(this.getSourceDescriptionUrl())},getTags:function(){return e.map(this.data.tags,function(a){ -return a.resource})},setSourceDescription:function(a){return a instanceof d.SourceDescription?this.data.description=a.getSourceDescriptionUrl():this.data.description=this.helpers.removeAccessToken(a),this},setTags:function(a){return this.data.tags=e.map(a,function(a){return{resource:a}}),this},addTag:function(a){return e.isArray(this.data.tags)||(this.tags=[]),this.data.tags.push({resource:a}),this},removeTag:function(a){return a=e.find(this.data.tags,{resource:a}),a&&this.data.tags.splice(e.indexOf(this.data.tags,a),1),this},save:function(a,b){var c=this;b&&c.setAttribution(c.client.createAttribution(b));var d=c.helpers.getEntityType(a),e={};"childAndParentsRelationships"===d&&(e["Content-Type"]="application/x-fs-v1+json");var f={};return f[d]=[{sources:[c]}],c.plumbing.post(a,f,e).then(function(a){return c.updateFromResponse(a,"source-reference"),a})},"delete":function(a){return this.client.deleteSourceRef(this.getSourceRefUrl(),a)}})},{"./../FamilySearch":5,"./../utils":56}],32:[function(a,b,c){var d=a("./../FamilySearch"),e=a("../utils"),f=d.TextValue=function(a,b){d.BaseClass.call(this,a,b)};d.prototype.createTextValue=function(a){return new f(this,a)},f.prototype=e.extend(Object.create(d.BaseClass.prototype),{constructor:f,getLang:function(){return this.data.lang},getValue:function(){return this.data.value}})},{"../utils":56,"./../FamilySearch":5}],33:[function(a,b,c){var d=a("../FamilySearch"),e=a("../utils"),f=d.User=function(a,b){d.BaseClass.call(this,a,b)};d.prototype.createUser=function(a){return new f(this,a)},f.prototype=e.extend(Object.create(d.BaseClass.prototype),{constructor:f,getId:function(){return this.data.id},getPersonId:function(){return this.data.personId},getTreeUserId:function(){return this.data.treeUserId},getContactName:function(){return this.data.contactName},getDisplayName:function(){return this.data.displayName},getGivenName:function(){return this.data.givenName},getFamilyName:function(){return this.data.familyName},getGender:function(){return this.data.gender},getEmail:function(){return this.data.email},getPreferredLanguage:function(){return this.data.preferredLanguage}})},{"../FamilySearch":5,"../utils":56}],34:[function(a,b,c){var d=a("./../FamilySearch"),e=a("./../utils"),f=d.VocabularyElement=function(a,b){d.BaseClass.call(this,a,b)};d.prototype.createVocabularyElement=function(a){return new f(this,a)},f.prototype=e.extend(Object.create(d.BaseClass.prototype),{constructor:f,getLabel:function(){return e.maybe(e.maybe(this.data.labels)[0])["@value"]},getDescription:function(){return e.maybe(e.maybe(this.data.descriptions)[0])["@value"]}})},{"./../FamilySearch":5,"./../utils":56}],35:[function(a,b,c){var d=a("./../FamilySearch"),e=a("./../utils"),f=d.VocabularyList=function(a,b){d.BaseClass.call(this,a,b),b&&b.elements&&e.forEach(this.data.elements,function(b,c,e){b instanceof d.VocabularyElement||(e[c]=a.createVocabularyElement(b))})};d.prototype.createVocabularyList=function(a){return new f(this,a)},f.prototype=e.extend(Object.create(d.BaseClass.prototype),{constructor:f,getTitle:function(){return this.data.title},getDescription:function(){return this.data.description},getElements:function(){return e.maybe(this.data.elements)}})},{"./../FamilySearch":5,"./../utils":56}],36:[function(a,b,c){b.exports={clientId:null,environment:null,redirectUri:null,autoSignin:!1,autoExpire:!1,accessToken:null,saveAccessToken:!1,logging:!1,accessTokenCookie:"FS_ACCESS_TOKEN",authCodePollDelay:50,defaultThrottleRetryAfter:500,maxHttpRequestRetries:2,maxAccessTokenInactivityTime:354e4,maxAccessTokenCreationTime:8634e4,apiServer:{sandbox:"https://sandbox.familysearch.org",staging:"https://stage.familysearch.org",beta:"https://beta.familysearch.org",production:"https://familysearch.org"},oauthServer:{sandbox:"https://integration.familysearch.org/cis-web/oauth2/v3",staging:"https://identbeta.familysearch.org/cis-web/oauth2/v3",beta:"https://identbeta.familysearch.org/cis-web/oauth2/v3",production:"https://ident.familysearch.org/cis-web/oauth2/v3"},collectionsUrl:"/platform/collections"}},{}],37:[function(a,b,c){var d=a("./utils"),e=d.forEach,f=function(a){this.settings=a.settings,this.client=a,this.accessTokenInactiveTimer=null,this.accessTokenCreationTimer=null};f.prototype.getAbsoluteUrl=function(a,b){return this.isAbsoluteUrl(b)?b:a+("/"!==b.charAt(0)?"/":"")+b},f.prototype.isOAuthServerUrl=function(a){return 0===a.indexOf(this.settings.oauthServer[this.settings.environment])},f.prototype.getAPIServerUrl=function(a){return this.getAbsoluteUrl(this.settings.apiServer[this.settings.environment],a)},f.prototype.appendAccessToken=function(a){if(a){var b=this.decodeQueryString(a);a=this.removeQueryString(a),b.access_token=this.settings.accessToken,a=this.appendQueryParameters(a,b)}return a},f.prototype.log=function(){this.settings.debug&&console.log.apply(null,arguments)},f.prototype.setTimer=function(a,b,c){c&&clearTimeout(c),setTimeout(function(){a()},b)},f.prototype.setAccessTokenInactiveTimer=function(a){this.accessTokenInactiveTimer=this.setTimer(this.settings.eraseAccessToken,a,this.accessTokenInactiveTimer)},f.prototype.setAccessTokenCreationTimer=function(a){this.accessTokenCreationTimer=this.setTimer(this.settings.eraseAccessToken,a,this.accessTokenCreationTimer)},f.prototype.clearAccessTokenTimers=function(){clearTimeout(this.accessTokenInactiveTimer),this.accessTokenInactiveTimer=null,clearTimeout(this.accessTokenCreationTimer),this.accessTokenCreationTimer=null},f.prototype.getAccessTokenCookieName=function(){return this.settings.accessTokenCookie+"_"+this.settings.instanceId},f.prototype.readAccessToken=function(){if("undefined"!=typeof window){var a=(new Date).getTime(),b=this,c=this.readCookie(this.getAccessTokenCookieName());if(c){var d=c.split("|",3);if(3===d.length){var e=a-parseInt(d[0],10),f=a-parseInt(d[1],10);e=0?"&":"?")+c},f.prototype.decodeQueryString=function(a){var b={};if(a){var c=a.indexOf("?");if(-1!==c){var f=a.substring(c+1).split("&");e(f,function(a){var c=a.split("=",2);if(c&&c[0]){var e=decodeURIComponent(c[0]),f=null!=c[1]?decodeURIComponent(c[1]):c[1];null==b[e]||d.isArray(b[e])||(b[e]=[b[e]]),null!=b[e]?b[e].push(f):b[e]=f}})}}return b},f.prototype.removeQueryString=function(a){if(a){var b=a.indexOf("?");-1!==b&&(a=a.substring(0,b))}return a},f.prototype.removeAccessToken=function(a){if(a){var b=this.decodeQueryString(a);a=this.removeQueryString(a),delete b.access_token,a=this.appendQueryParameters(a,b)}return a},f.prototype.populateUriTemplate=function(a,b){for(var c=a.split(/[{}]/),d=!1,e=0,f=c.length;f>e;e++)if(e%2===1){var g=b[c[e]];c[e]=d?encodeURIComponent(g):encodeURI(g)}else-1!==c[e].indexOf("?")&&(d=!0);return c.join("")},f.prototype.parseLinkHeaders=function(a){var b={};return d.isArray(a)&&d.forEach(a,function(a){var c=a.split(", ");d.forEach(c,function(a){var c=a.split("; "),d=c[0].slice(1,-1),e=c[1].slice(5,-1);b[e]={href:d}})}),b},f.prototype.getUrlFromCollection=function(a,b,c){var d="",e=a.links[b];if(e.href)d=this.removeAccessToken(e.href);else if(e.template){var f=e.template.replace(/{\?[^}]*}/,"");d=this.populateUriTemplate(f,c||{})}return d},f.prototype.getEntityType=function(a){if(d.isString(a)){var b=a.match(/platform\/tree\/([^\/]+)/);if(b&&b[1]){if("persons"===b[1])return"persons";if("couple-relationships"===b[1])return"relationships";if("child-and-parents-relationships"===b[1])return"childAndParentsRelationships"}}},f.prototype.createCookie=function(a,b,c){var d="",e="https"===document.location.protocol&&"localhost"!==document.location.hostname;if(c){var f=new Date;f.setTime(f.getTime()+86400*c),d="; expires="+f.toUTCString()}document.cookie=a+"="+b+d+"; path=/"+(e?"; secure":"")},f.prototype.readCookie=function(a){for(var b=a+"=",c=document.cookie.split(";"),d=0;d=0?null:b}},a})},d.prototype.setPreferredSpouse=function(a,b){var c=b,d=this;return d.getCurrentUser().then(function(b){var c=b.getUser().getTreeUserId();return d.plumbing.getCollectionUrl("FSFT","preferred-spouse-relationship",{uid:c,pid:a})}).then(function(a){return d.plumbing.put(a,null,{Location:c})})},d.prototype.deletePreferredSpouse=function(a){var b=this;return b.getCurrentUser().then(function(c){var d=c.getUser().getTreeUserId();return b.plumbing.getCollectionUrl("FSFT","preferred-spouse-relationship",{uid:d,pid:a})}).then(function(a){return b.plumbing.del(a)})},d.prototype.getPreferredParents=function(a){var b=this;return b.getCurrentUser().then(function(c){var d=c.getUser().getTreeUserId();return b.plumbing.getCollectionUrl("FSFT","preferred-parent-relationship",{uid:d,pid:a})}).then(function(a){return b.plumbing.get(a+".json",null,{Accept:"application/x-fs-v1+json","X-Expect-Override":"200-ok"})}).then(function(a){return a.getPreferredParents=function(){return 200===a.getStatusCode()?a.getHeader("Location"):void 0},a})},d.prototype.setPreferredParents=function(a,b){var c=b,d=this;return d.getCurrentUser().then(function(b){var c=b.getUser().getTreeUserId();return d.plumbing.getCollectionUrl("FSFT","preferred-parent-relationship",{uid:c,pid:a})}).then(function(a){return d.plumbing.put(a,null,{Location:c})})},d.prototype.deletePreferredParents=function(a){var b=this;return b.getCurrentUser().then(function(c){var d=c.getUser().getTreeUserId();return b.plumbing.getCollectionUrl("FSFT","preferred-parent-relationship",{uid:d,pid:a})}).then(function(a){return b.plumbing.del(a)})}},{"../FamilySearch":5,"../utils":56}],47:[function(a,b,c){var d=a("./../FamilySearch"),e=a("./../utils");d.prototype.getPlace=function(a){var b=this;return b.plumbing.get(a).then(function(a){var c=e.maybe(a.getData());return e.forEach(c.places,function(a,c,d){d[c]=b.createPlaceDescription(a)}),e.extend(a,{getPlace:function(){return e.maybe(c.places)[0]}})})},d.prototype.getPlaceDescription=function(a){var b=this;return b.plumbing.get(a).then(function(a){var c=e.maybe(a.getData()),d={};return e.forEach(c.places,function(a,c,e){e[c]=d[a.id]=b.createPlaceDescription(a)}),e.forEach(c.places,function(a){if(a.data.jurisdiction&&a.data.jurisdiction.resource){var b=a.data.jurisdiction.resource.substring(1);d[b]&&a.setJurisdiction(d[b])}}),e.extend(a,{getPlaceDescription:function(){return e.maybe(c.places)[0]}})})},d.prototype.getPlacesSearch=function(a){var b=this;return b.plumbing.getCollectionUrl("FSPA","place-search").then(function(c){return b.plumbing.get(c,e.removeEmptyProperties({q:e.searchParamsFilter(e.removeEmptyProperties(e.extend({},a))),start:a.start,count:a.count}),{Accept:"application/x-gedcomx-atom+json"})}).then(function(a){var c=e.maybe(a.getData());return e.forEach(c.entries,function(a,c,d){d[c]=b.createPlacesSearchResult(a)}),e.extend(a,{getSearchResults:function(){return e.maybe(c.entries)}})})},d.prototype.getPlaceDescriptionChildren=function(a){var b=this;return b.plumbing.get(a).then(function(a){var c=e.maybe(a.getData());return e.forEach(c.places,function(a,c,d){d[c]=b.createPlaceDescription(a)}),e.extend(a,{getChildren:function(){return e.maybe(c.places)}})})},d.prototype.getPlaceType=function(a){var b=this;return b.plumbing.getCollectionUrl("FSPA","place-type",{ptid:a}).then(function(a){return b.plumbing.get(a,{},{Accept:"application/ld+json"})}).then(function(a){return e.extend(a,{getPlaceType:function(){return b.createVocabularyElement(this.getData())}})})},d.prototype.getPlaceTypes=function(){var a=this;return a.plumbing.getCollectionUrl("FSPA","place-types").then(function(b){return a.plumbing.get(b,{},{Accept:"application/ld+json"})}).then(function(b){return e.extend(b,{getList:function(){return a.createVocabularyList(this.getData())},getPlaceTypes:function(){return this.getList().getElements()}})})},d.prototype.getPlaceTypeGroup=function(a){var b=this;return b.plumbing.getCollectionUrl("FSPA","place-type-group",{ptgid:a}).then(function(a){return b.plumbing.get(a,{},{Accept:"application/ld+json"})}).then(function(a){return e.extend(a,{getList:function(){return b.createVocabularyList(this.getData()); -},getPlaceTypes:function(){return this.getList().getElements()}})})},d.prototype.getPlaceTypeGroups=function(){var a=this;return a.plumbing.getCollectionUrl("FSPA","place-type-groups").then(function(b){return a.plumbing.get(b,{},{Accept:"application/ld+json"})}).then(function(b){return e.extend(b,{getList:function(){return a.createVocabularyList(this.getData())},getPlaceTypeGroups:function(){return this.getList().getElements()}})})}},{"./../FamilySearch":5,"./../utils":56}],48:[function(a,b,c){var d=a("./../FamilySearch"),e=a("./../utils"),f={getSearchResults:function(){return e.maybe(this.getData()).entries||[]},getResultsCount:function(){return e.maybe(this.getData()).results||0},getIndex:function(){return e.maybe(this.getData()).index||0}};d.prototype._getSearchMatchResponseMapper=function(a){var b=this;return e.forEach(e.maybe(a.getData()).entries,function(a,c,d){d[c]=b.createSearchResult(a)}),e.extend(a,f)},d.prototype.getPersonSearch=function(a){var b=this;return b.plumbing.getCollectionUrl("FSFT","person-search").then(function(c){return b.plumbing.get(c,e.removeEmptyProperties({q:e.searchParamsFilter(e.removeEmptyProperties(e.extend({},a))),start:a.start,count:a.count,context:a.context}),{Accept:"application/x-gedcomx-atom+json"})}).then(function(a){return a.getContext=function(){return a.getHeader("X-FS-Page-Context")},b._getSearchMatchResponseMapper(a)})},d.prototype.getPersonMatches=function(a){var b=this;return b.plumbing.get(a,null,{Accept:"application/x-gedcomx-atom+json"}).then(function(a){return b._getSearchMatchResponseMapper(a)})},d.prototype.getPersonMatchesQuery=function(a){var b=this;return b.plumbing.getCollectionUrl("FSFT","person-matches-query").then(function(c){return b.plumbing.get(c,e.removeEmptyProperties({q:e.searchParamsFilter(e.removeEmptyProperties(e.extend({},a))),start:a.start,count:a.count}),{Accept:"application/x-gedcomx-atom+json"})}).then(function(a){return b._getSearchMatchResponseMapper(a)})}},{"./../FamilySearch":5,"./../utils":56}],49:[function(a,b,c){var d=a("./../FamilySearch"),e=a("./../utils"),f=e.maybe;d.prototype._getUserSourceDescriptionsUrl=function(){var a=this,b={Accept:"application/x-fs-v1+json","X-Expect-Override":"200-ok"};return a.plumbing.getCollectionUrl("FSFT","source-descriptions").then(function(c){return a.plumbing.get(c,null,b)}).then(function(a){return a.getHeader("Location")})},d.prototype.getCollectionsForUser=function(){var a=this;return a.plumbing.getCollectionUrl("FSUDS","subcollections").then(function(b){var c={Accept:"application/x-fs-v1+json","X-Expect-Override":"200-ok"};return a.plumbing.get(b,null,c)}).then(function(a){return a.getHeader("Location")}).then(function(b){return a.plumbing.get(b,{},{Accept:"application/x-fs-v1+json"})}).then(function(b){var c=f(b.getData());return e.forEach(c.collections,function(b,c,d){d[c]=a.createCollection(b)}),e.extend(b,{getCollections:function(){return c.collections||[]}})})},d.prototype.getCollection=function(a){var b=this;return b.plumbing.get(a,null,{Accept:"application/x-fs-v1+json"}).then(function(a){var c=f(a.getData());return e.forEach(c.collections,function(a,c,d){d[c]=b.createCollection(a)}),e.extend(a,{getCollection:function(){return f(c.collections)[0]}})})},d.prototype.getCollectionSourceDescriptions=function(a,b){var c=this;return c.plumbing.get(a,b,{Accept:"application/x-fs-v1+json"}).then(function(a){var b=f(a.getData());return e.forEach(b.sourceDescriptions,function(a,b,d){d[b]=c.createSourceDescription(a)}),e.extend(a,{getSourceDescriptions:function(){return b.sourceDescriptions||[]}})})},d.prototype.getCollectionSourceDescriptionsForUser=function(a){var b=this;return b._getUserSourceDescriptionsUrl().then(function(c){return b.plumbing.get(c,a,{Accept:"application/x-fs-v1+json"})}).then(function(a){var c=f(a.getData());return e.forEach(c.sourceDescriptions,function(a,c,d){d[c]=b.createSourceDescription(a)}),e.extend(a,{getSourceDescriptions:function(){return c.sourceDescriptions||[]}})})},d.prototype.moveSourceDescriptionsToCollection=function(a,b){var c=this,f=e.map(b,function(a){return{id:a instanceof d.SourceDescription?a.id:a}});return c.plumbing.post(a,{sourceDescriptions:f})},d.prototype.removeSourceDescriptionsFromCollections=function(a){var b=this;return b._getUserSourceDescriptionsUrl().then(function(c){var f=e.map(a,function(a){return a instanceof d.SourceDescription?a.id:a});return b.plumbing.del(b.helpers.appendQueryParameters(c,{id:f}))})},d.prototype.deleteCollection=function(a){return this.plumbing.del(a)}},{"./../FamilySearch":5,"./../utils":56}],50:[function(a,b,c){var d=a("./../FamilySearch"),e=a("./../utils"),f=e.maybe;d.prototype.getSourceDescription=function(a){var b=this;return b.plumbing.get(a).then(function(a){for(var c=f(f(a.getData()).sourceDescriptions),d=0;d=500&&e>0||429===g.status?f.http(a,b,c,d,e-1):g}).then(function(a){if(a.status>=200&&a.status<400)return a;f.settings.debug&&f.helpers.log("http failure",a.status,e);var b=new Error(a.statusText);throw b.response=a,b}).then(function(a){return a.json().then(function(b){return a.data=b,a},function(){return a})}).then(function(a){f.helpers.refreshAccessToken();var b=a.headers.get("X-PROCESSING-TIME");return b&&(f.totalProcessingTime+=parseInt(b,10)),a}).then(function(b){return{getBody:function(){return b.body},getData:function(){return b.data},getStatusCode:function(){return b.status},getHeader:function(a,c){return c===!0?b.headers.getAll(a):b.headers.get(a)},getRequest:function(){return{url:g,method:a,headers:c,body:j}}}})})},b.exports=f},{"./utils":56,"es6-promise":2,"isomorphic-fetch":3}],55:[function(a,b,c){var d=a("./FamilySearch"),e=a("./utils"),f=e.maybe,c={};c.setMember=function(a,b){this.data[a]||(this.data[a]={}),b instanceof d.Person?(this.data[a].resource=b.getPersonUrl(),delete this.data[a].resourceId):this.helpers.isAbsoluteUrl(b)?(this.data[a].resource=b,delete this.data[a].resourceId):e.isString(b)?(this.data[a].resourceId=b,delete this.data[a].resource):this.data[a]=b},c.deleteMember=function(a,b){this.deletedMembers||(this.deletedMembers={}),this.deletedMembers[a]=b,delete this.data[a]},c.setFacts=function(a,b,d){e.isArray(this.data[a])&&e.forEach(this.data[a],function(b){c.deleteFact.call(this,a,b,d)},this),this.data[a]=[],e.forEach(b,function(b){c.addFact.call(this,a,b)},this)},c.addFact=function(a,b){e.isArray(this.data[a])||(this.data[a]=[]),b instanceof d.Fact||(b=this.client.createFact(b)),this.data[a].push(b)},c.deleteFact=function(a,b,c){b instanceof d.Fact||(b=e.find(this.data[a],{id:b}));var g=e.indexOf(this.data[a],b);if(g>=0){var h=this.helpers.removeAccessToken(f(b.getLink("conclusion")).href);h&&(this.deletedFacts||(this.deletedFacts={}),this.deletedFacts[h]=c),this.data[a].splice(g,1)}},b.exports=c},{"./FamilySearch":5,"./utils":56}],56:[function(a,b,c){function d(a,b){for(var c in a)if(a.hasOwnProperty(c)&&b[c]!==a[c])return!1;return!0}function e(a){return c.isString(a)?(a=a.replace(/[:"]/g,"").trim(),a.indexOf(" ")>=0?'"'+a+'"':a):a}var c=b.exports;Object.create||(Object.create=function(){function a(){}return function(b){if(1!==arguments.length)throw new Error("Object.create implementation only accepts one parameter.");return a.prototype=b,new a}}()),"function"!=typeof Object.getPrototypeOf&&(Object.getPrototypeOf="object"==typeof"".__proto__?function(a){return a.__proto__}:function(a){return a.constructor.prototype}),c.isArray=function(a){return Array.isArray?Array.isArray(a):"[object Array]"==Object.prototype.toString.call(a)},c.isString=function(a){return"[object String]"==Object.prototype.toString.call(a)},c.isFunction=function(a){return"function"!=typeof/./?"function"==typeof a:"[object Function]"==Object.prototype.toString.call(a)},c.isObject=function(a){return a===Object(a)},c.isUndefined=function(a){return void 0===a};var f=c.forEach=function(a,b,c){if(null!=a)if(Array.prototype.forEach&&a.forEach===Array.prototype.forEach)a.forEach(b,c);else if(a.length===+a.length){for(var d=0,e=a.length;e>d;d++)if(b.call(c,a[d],d,a)==={})return}else for(var f in a)if(a.hasOwnProperty(f)&&b.call(c,a[f],f,a)==={})return};c.removeEmptyProperties=function(a){return f(a,function(b,c){(null==b||""===b)&&delete a[c]}),a},c.keys=Object.keys||function(a){if(a!==Object(a))throw new TypeError("Invalid object");var b=[];for(var c in a)a.hasOwnProperty(c)&&b.push(c);return b},c.filter=function(a,b,e){var g=[],h=c.isFunction(b);return f(a,function(a){(h?b.call(e,a):d(b,a))&&g.push(a)}),g},c.map=function(a,b,c){var d=[];return f(a,function(a,e,f){d.push(b.call(c,a,e,f))}),d},c.contains=function(a,b){if(null==a)return!1;if(a.indexOf&&a.indexOf===Array.prototype.indexOf)return-1!==a.indexOf(b);var c=!1;return f(a,function(a){a===b&&(c=!0)}),c},c.indexOf=function(a,b){if(Array.prototype.indexOf===a.indexOf)return a.indexOf(b);for(var c=0,d=a.length;d>c;c++)if(a[c]===b)return c;return-1},c.uniq=function(a){var b=[];return f(a,function(a){c.contains(b,a)||b.push(a)}),b},c.find=function(a,b,e){var f,g=c.isFunction(b);if(a)for(var h=0,i=a.length;i>h;h++){var j=a[h];if(g?b.call(e,j):d(b,j)){f=j;break}}return f},c.findIndex=function(a,b,e){var f=-1,g=c.isFunction(b);if(a)for(var h=0,i=a.length;i>h;h++){var j=a[h];if(g?b.call(e,j):d(b,j)){f=h;break}}return f},c.flatten=function(a){var b=[];return f(a,function(a){c.isArray(a)&&Array.prototype.push.apply(b,a)}),b},c.flatMap=function(a,b,d){return c.flatten(c.map(a,b,d))},c.findOrFirst=function(a,b){if(!c.isUndefined(a)){var d=c.find(a,b);return c.isUndefined(d)?a[0]:d}return void 0},c.extend=function(a){return a=a||{},f(Array.prototype.slice.call(arguments,1),function(b){b&&f(b,function(b,c){a[c]=b})}),a},c.maybe=function(a){return null!=a?a:{}};var g={start:!0,count:!0,context:!0};c.searchParamsFilter=function(a){return c.map(c.filter(c.keys(a),function(a){return!g[a]}),function(b){return b+":"+e(a[b])}).join(" ")}},{}]},{},[5])(5)}); \ No newline at end of file +return a.resource})},setSourceDescription:function(a){return a instanceof d.SourceDescription?this.data.description=a.getSourceDescriptionUrl():this.data.description=this.helpers.removeAccessToken(a),this},setTags:function(a){return this.data.tags=e.map(a,function(a){return{resource:a}}),this},addTag:function(a){return e.isArray(this.data.tags)||(this.tags=[]),this.data.tags.push({resource:a}),this},removeTag:function(a){return a=e.find(this.data.tags,{resource:a}),a&&this.data.tags.splice(e.indexOf(this.data.tags,a),1),this},save:function(a,b){var c=this;b&&c.setAttribution(c.client.createAttribution(b));var d=c.helpers.getEntityType(a),e={};"childAndParentsRelationships"===d&&(e["Content-Type"]="application/x-fs-v1+json");var f={};return f[d]=[{sources:[c]}],c.plumbing.post(a,f,e).then(function(a){return c.updateFromResponse(a,"source-reference"),a})},"delete":function(a){return this.client.deleteSourceRef(this.getSourceRefUrl(),a)}})},{"./../FamilySearch":5,"./../utils":56}],32:[function(a,b,c){var d=a("./../FamilySearch"),e=a("../utils"),f=d.TextValue=function(a,b){d.BaseClass.call(this,a,b)};d.prototype.createTextValue=function(a){return new f(this,a)},f.prototype=e.extend(Object.create(d.BaseClass.prototype),{constructor:f,getLang:function(){return this.data.lang},getValue:function(){return this.data.value}})},{"../utils":56,"./../FamilySearch":5}],33:[function(a,b,c){var d=a("../FamilySearch"),e=a("../utils"),f=d.User=function(a,b){d.BaseClass.call(this,a,b)};d.prototype.createUser=function(a){return new f(this,a)},f.prototype=e.extend(Object.create(d.BaseClass.prototype),{constructor:f,getId:function(){return this.data.id},getPersonId:function(){return this.data.personId},getTreeUserId:function(){return this.data.treeUserId},getContactName:function(){return this.data.contactName},getDisplayName:function(){return this.data.displayName},getGivenName:function(){return this.data.givenName},getFamilyName:function(){return this.data.familyName},getGender:function(){return this.data.gender},getEmail:function(){return this.data.email},getPreferredLanguage:function(){return this.data.preferredLanguage}})},{"../FamilySearch":5,"../utils":56}],34:[function(a,b,c){var d=a("./../FamilySearch"),e=a("./../utils"),f=d.VocabularyElement=function(a,b){d.BaseClass.call(this,a,b)};d.prototype.createVocabularyElement=function(a){return new f(this,a)},f.prototype=e.extend(Object.create(d.BaseClass.prototype),{constructor:f,getLabel:function(){return e.maybe(e.maybe(this.data.labels)[0])["@value"]},getDescription:function(){return e.maybe(e.maybe(this.data.descriptions)[0])["@value"]}})},{"./../FamilySearch":5,"./../utils":56}],35:[function(a,b,c){var d=a("./../FamilySearch"),e=a("./../utils"),f=d.VocabularyList=function(a,b){d.BaseClass.call(this,a,b),b&&b.elements&&e.forEach(this.data.elements,function(b,c,e){b instanceof d.VocabularyElement||(e[c]=a.createVocabularyElement(b))})};d.prototype.createVocabularyList=function(a){return new f(this,a)},f.prototype=e.extend(Object.create(d.BaseClass.prototype),{constructor:f,getTitle:function(){return this.data.title},getDescription:function(){return this.data.description},getElements:function(){return e.maybe(this.data.elements)}})},{"./../FamilySearch":5,"./../utils":56}],36:[function(a,b,c){b.exports={clientId:null,environment:null,redirectUri:null,autoSignin:!1,autoExpire:!1,accessToken:null,saveAccessToken:!1,logging:!1,accessTokenCookie:"FS_ACCESS_TOKEN",authCodePollDelay:50,defaultThrottleRetryAfter:1e3,maxHttpRequestRetries:4,maxAccessTokenInactivityTime:354e4,maxAccessTokenCreationTime:8634e4,apiServer:{sandbox:"https://sandbox.familysearch.org",staging:"https://stage.familysearch.org",beta:"https://beta.familysearch.org",production:"https://familysearch.org"},oauthServer:{sandbox:"https://integration.familysearch.org/cis-web/oauth2/v3",staging:"https://identbeta.familysearch.org/cis-web/oauth2/v3",beta:"https://identbeta.familysearch.org/cis-web/oauth2/v3",production:"https://ident.familysearch.org/cis-web/oauth2/v3"},collectionsUrl:"/platform/collections"}},{}],37:[function(a,b,c){var d=a("./utils"),e=d.forEach,f=function(a){this.settings=a.settings,this.client=a,this.accessTokenInactiveTimer=null,this.accessTokenCreationTimer=null};f.prototype.getAbsoluteUrl=function(a,b){return this.isAbsoluteUrl(b)?b:a+("/"!==b.charAt(0)?"/":"")+b},f.prototype.isOAuthServerUrl=function(a){return 0===a.indexOf(this.settings.oauthServer[this.settings.environment])},f.prototype.getAPIServerUrl=function(a){return this.getAbsoluteUrl(this.settings.apiServer[this.settings.environment],a)},f.prototype.appendAccessToken=function(a){if(a){var b=this.decodeQueryString(a);a=this.removeQueryString(a),b.access_token=this.settings.accessToken,a=this.appendQueryParameters(a,b)}return a},f.prototype.log=function(){this.settings.debug&&console.log&&console.log.apply(console,arguments)},f.prototype.setTimer=function(a,b,c){c&&clearTimeout(c),setTimeout(function(){a()},b)},f.prototype.setAccessTokenInactiveTimer=function(a){this.accessTokenInactiveTimer=this.setTimer(this.settings.eraseAccessToken,a,this.accessTokenInactiveTimer)},f.prototype.setAccessTokenCreationTimer=function(a){this.accessTokenCreationTimer=this.setTimer(this.settings.eraseAccessToken,a,this.accessTokenCreationTimer)},f.prototype.clearAccessTokenTimers=function(){clearTimeout(this.accessTokenInactiveTimer),this.accessTokenInactiveTimer=null,clearTimeout(this.accessTokenCreationTimer),this.accessTokenCreationTimer=null},f.prototype.getAccessTokenCookieName=function(){return this.settings.accessTokenCookie+"_"+this.settings.instanceId},f.prototype.readAccessToken=function(){if("undefined"!=typeof window){var a=(new Date).getTime(),b=this,c=this.readCookie(this.getAccessTokenCookieName());if(c){var d=c.split("|",3);if(3===d.length){var e=a-parseInt(d[0],10),f=a-parseInt(d[1],10);e=0?"&":"?")+c},f.prototype.decodeQueryString=function(a){var b={};if(a){var c=a.indexOf("?");if(-1!==c){var f=a.substring(c+1).split("&");e(f,function(a){var c=a.split("=",2);if(c&&c[0]){var e=decodeURIComponent(c[0]),f=null!=c[1]?decodeURIComponent(c[1]):c[1];null==b[e]||d.isArray(b[e])||(b[e]=[b[e]]),null!=b[e]?b[e].push(f):b[e]=f}})}}return b},f.prototype.removeQueryString=function(a){if(a){var b=a.indexOf("?");-1!==b&&(a=a.substring(0,b))}return a},f.prototype.removeAccessToken=function(a){if(a){var b=this.decodeQueryString(a);a=this.removeQueryString(a),delete b.access_token,a=this.appendQueryParameters(a,b)}return a},f.prototype.populateUriTemplate=function(a,b){for(var c=a.split(/[{}]/),d=!1,e=0,f=c.length;f>e;e++)if(e%2===1){var g=b[c[e]];c[e]=d?encodeURIComponent(g):encodeURI(g)}else-1!==c[e].indexOf("?")&&(d=!0);return c.join("")},f.prototype.parseLinkHeaders=function(a){var b={};return d.isArray(a)&&d.forEach(a,function(a){var c=a.split(", ");d.forEach(c,function(a){var c=a.split("; "),d=c[0].slice(1,-1),e=c[1].slice(5,-1);b[e]={href:d}})}),b},f.prototype.getUrlFromCollection=function(a,b,c){var d="",e=a.links[b];if(e.href)d=this.removeAccessToken(e.href);else if(e.template){var f=e.template.replace(/{\?[^}]*}/,"");d=this.populateUriTemplate(f,c||{})}return d},f.prototype.getEntityType=function(a){if(d.isString(a)){var b=a.match(/platform\/tree\/([^\/]+)/);if(b&&b[1]){if("persons"===b[1])return"persons";if("couple-relationships"===b[1])return"relationships";if("child-and-parents-relationships"===b[1])return"childAndParentsRelationships"}}},f.prototype.createCookie=function(a,b,c){var d="",e="https"===document.location.protocol&&"localhost"!==document.location.hostname;if(c){var f=new Date;f.setTime(f.getTime()+86400*c),d="; expires="+f.toUTCString()}document.cookie=a+"="+b+d+"; path=/"+(e?"; secure":"")},f.prototype.readCookie=function(a){for(var b=a+"=",c=document.cookie.split(";"),d=0;d=0?null:b}},a})},d.prototype.setPreferredSpouse=function(a,b){var c=b,d=this;return d.getCurrentUser().then(function(b){var c=b.getUser().getTreeUserId();return d.plumbing.getCollectionUrl("FSFT","preferred-spouse-relationship",{uid:c,pid:a})}).then(function(a){return d.plumbing.put(a,null,{Location:c})})},d.prototype.deletePreferredSpouse=function(a){var b=this;return b.getCurrentUser().then(function(c){var d=c.getUser().getTreeUserId();return b.plumbing.getCollectionUrl("FSFT","preferred-spouse-relationship",{uid:d,pid:a})}).then(function(a){return b.plumbing.del(a)})},d.prototype.getPreferredParents=function(a){var b=this;return b.getCurrentUser().then(function(c){var d=c.getUser().getTreeUserId();return b.plumbing.getCollectionUrl("FSFT","preferred-parent-relationship",{uid:d,pid:a})}).then(function(a){return b.plumbing.get(a+".json",null,{Accept:"application/x-fs-v1+json","X-Expect-Override":"200-ok"})}).then(function(a){return a.getPreferredParents=function(){return 200===a.getStatusCode()?a.getHeader("Location"):void 0},a})},d.prototype.setPreferredParents=function(a,b){var c=b,d=this;return d.getCurrentUser().then(function(b){var c=b.getUser().getTreeUserId();return d.plumbing.getCollectionUrl("FSFT","preferred-parent-relationship",{uid:c,pid:a})}).then(function(a){return d.plumbing.put(a,null,{Location:c})})},d.prototype.deletePreferredParents=function(a){var b=this;return b.getCurrentUser().then(function(c){var d=c.getUser().getTreeUserId();return b.plumbing.getCollectionUrl("FSFT","preferred-parent-relationship",{uid:d,pid:a})}).then(function(a){return b.plumbing.del(a)})}},{"../FamilySearch":5,"../utils":56}],47:[function(a,b,c){var d=a("./../FamilySearch"),e=a("./../utils");d.prototype.getPlace=function(a){var b=this;return b.plumbing.get(a).then(function(a){var c=e.maybe(a.getData());return e.forEach(c.places,function(a,c,d){d[c]=b.createPlaceDescription(a)}),e.extend(a,{getPlace:function(){return e.maybe(c.places)[0]}})})},d.prototype.getPlaceDescription=function(a){var b=this;return b.plumbing.get(a).then(function(a){var c=e.maybe(a.getData()),d={};return e.forEach(c.places,function(a,c,e){e[c]=d[a.id]=b.createPlaceDescription(a)}),e.forEach(c.places,function(a){if(a.data.jurisdiction&&a.data.jurisdiction.resource){var b=a.data.jurisdiction.resource.substring(1);d[b]&&a.setJurisdiction(d[b])}}),e.extend(a,{getPlaceDescription:function(){return e.maybe(c.places)[0]}})})},d.prototype.getPlacesSearch=function(a){var b=this;return b.plumbing.getCollectionUrl("FSPA","place-search").then(function(c){return b.plumbing.get(c,e.removeEmptyProperties({q:e.searchParamsFilter(e.removeEmptyProperties(e.extend({},a))),start:a.start,count:a.count}),{Accept:"application/x-gedcomx-atom+json"})}).then(function(a){var c=e.maybe(a.getData());return e.forEach(c.entries,function(a,c,d){d[c]=b.createPlacesSearchResult(a)}),e.extend(a,{getSearchResults:function(){return e.maybe(c.entries)}})})},d.prototype.getPlaceDescriptionChildren=function(a){var b=this;return b.plumbing.get(a).then(function(a){var c=e.maybe(a.getData());return e.forEach(c.places,function(a,c,d){d[c]=b.createPlaceDescription(a)}),e.extend(a,{getChildren:function(){return e.maybe(c.places)}})})},d.prototype.getPlaceType=function(a){var b=this;return b.plumbing.getCollectionUrl("FSPA","place-type",{ptid:a}).then(function(a){return b.plumbing.get(a,{},{Accept:"application/ld+json"})}).then(function(a){return e.extend(a,{getPlaceType:function(){return b.createVocabularyElement(this.getData())}})})},d.prototype.getPlaceTypes=function(){var a=this;return a.plumbing.getCollectionUrl("FSPA","place-types").then(function(b){return a.plumbing.get(b,{},{Accept:"application/ld+json"})}).then(function(b){return e.extend(b,{getList:function(){return a.createVocabularyList(this.getData())},getPlaceTypes:function(){return this.getList().getElements()}})})},d.prototype.getPlaceTypeGroup=function(a){var b=this;return b.plumbing.getCollectionUrl("FSPA","place-type-group",{ptgid:a}).then(function(a){return b.plumbing.get(a,{},{Accept:"application/ld+json"})}).then(function(a){return e.extend(a,{getList:function(){ +return b.createVocabularyList(this.getData())},getPlaceTypes:function(){return this.getList().getElements()}})})},d.prototype.getPlaceTypeGroups=function(){var a=this;return a.plumbing.getCollectionUrl("FSPA","place-type-groups").then(function(b){return a.plumbing.get(b,{},{Accept:"application/ld+json"})}).then(function(b){return e.extend(b,{getList:function(){return a.createVocabularyList(this.getData())},getPlaceTypeGroups:function(){return this.getList().getElements()}})})}},{"./../FamilySearch":5,"./../utils":56}],48:[function(a,b,c){var d=a("./../FamilySearch"),e=a("./../utils"),f={getSearchResults:function(){return e.maybe(this.getData()).entries||[]},getResultsCount:function(){return e.maybe(this.getData()).results||0},getIndex:function(){return e.maybe(this.getData()).index||0}};d.prototype._getSearchMatchResponseMapper=function(a){var b=this;return e.forEach(e.maybe(a.getData()).entries,function(a,c,d){d[c]=b.createSearchResult(a)}),e.extend(a,f)},d.prototype.getPersonSearch=function(a){var b=this;return b.plumbing.getCollectionUrl("FSFT","person-search").then(function(c){return b.plumbing.get(c,e.removeEmptyProperties({q:e.searchParamsFilter(e.removeEmptyProperties(e.extend({},a))),start:a.start,count:a.count,context:a.context}),{Accept:"application/x-gedcomx-atom+json"})}).then(function(a){return a.getContext=function(){return a.getHeader("X-FS-Page-Context")},b._getSearchMatchResponseMapper(a)})},d.prototype.getPersonMatches=function(a){var b=this;return b.plumbing.get(a,null,{Accept:"application/x-gedcomx-atom+json"}).then(function(a){return b._getSearchMatchResponseMapper(a)})},d.prototype.getPersonMatchesQuery=function(a){var b=this;return b.plumbing.getCollectionUrl("FSFT","person-matches-query").then(function(c){return b.plumbing.get(c,e.removeEmptyProperties({q:e.searchParamsFilter(e.removeEmptyProperties(e.extend({},a))),start:a.start,count:a.count}),{Accept:"application/x-gedcomx-atom+json"})}).then(function(a){return b._getSearchMatchResponseMapper(a)})}},{"./../FamilySearch":5,"./../utils":56}],49:[function(a,b,c){var d=a("./../FamilySearch"),e=a("./../utils"),f=e.maybe;d.prototype._getUserSourceDescriptionsUrl=function(){var a=this,b={Accept:"application/x-fs-v1+json","X-Expect-Override":"200-ok"};return a.plumbing.getCollectionUrl("FSFT","source-descriptions").then(function(c){return a.plumbing.get(c,null,b)}).then(function(a){return a.getHeader("Location")})},d.prototype.getCollectionsForUser=function(){var a=this;return a.plumbing.getCollectionUrl("FSUDS","subcollections").then(function(b){var c={Accept:"application/x-fs-v1+json","X-Expect-Override":"200-ok"};return a.plumbing.get(b,null,c)}).then(function(a){return a.getHeader("Location")}).then(function(b){return a.plumbing.get(b,{},{Accept:"application/x-fs-v1+json"})}).then(function(b){var c=f(b.getData());return e.forEach(c.collections,function(b,c,d){d[c]=a.createCollection(b)}),e.extend(b,{getCollections:function(){return c.collections||[]}})})},d.prototype.getCollection=function(a){var b=this;return b.plumbing.get(a,null,{Accept:"application/x-fs-v1+json"}).then(function(a){var c=f(a.getData());return e.forEach(c.collections,function(a,c,d){d[c]=b.createCollection(a)}),e.extend(a,{getCollection:function(){return f(c.collections)[0]}})})},d.prototype.getCollectionSourceDescriptions=function(a,b){var c=this;return c.plumbing.get(a,b,{Accept:"application/x-fs-v1+json"}).then(function(a){var b=f(a.getData());return e.forEach(b.sourceDescriptions,function(a,b,d){d[b]=c.createSourceDescription(a)}),e.extend(a,{getSourceDescriptions:function(){return b.sourceDescriptions||[]}})})},d.prototype.getCollectionSourceDescriptionsForUser=function(a){var b=this;return b._getUserSourceDescriptionsUrl().then(function(c){return b.plumbing.get(c,a,{Accept:"application/x-fs-v1+json"})}).then(function(a){var c=f(a.getData());return e.forEach(c.sourceDescriptions,function(a,c,d){d[c]=b.createSourceDescription(a)}),e.extend(a,{getSourceDescriptions:function(){return c.sourceDescriptions||[]}})})},d.prototype.moveSourceDescriptionsToCollection=function(a,b){var c=this,f=e.map(b,function(a){return{id:a instanceof d.SourceDescription?a.id:a}});return c.plumbing.post(a,{sourceDescriptions:f})},d.prototype.removeSourceDescriptionsFromCollections=function(a){var b=this;return b._getUserSourceDescriptionsUrl().then(function(c){var f=e.map(a,function(a){return a instanceof d.SourceDescription?a.id:a});return b.plumbing.del(b.helpers.appendQueryParameters(c,{id:f}))})},d.prototype.deleteCollection=function(a){return this.plumbing.del(a)}},{"./../FamilySearch":5,"./../utils":56}],50:[function(a,b,c){var d=a("./../FamilySearch"),e=a("./../utils"),f=e.maybe;d.prototype.getSourceDescription=function(a){var b=this;return b.plumbing.get(a).then(function(a){for(var c=f(f(a.getData()).sourceDescriptions),d=0;d0&&(g.status>=500||429===g.status)){var h=g.headers.get("Retry-After"),i=h?1e3*parseInt(h,10):f.settings.defaultThrottleRetryAfter;return new Promise(function(g,h){setTimeout(function(){f._http(a,b,c,d,e-1).then(function(a){g(a)},function(a){h(a)})},i)})}return g}).then(function(a){if(a.status>=200&&a.status<400)return a;f.settings.debug&&f.helpers.log("http failure",a.status,e);var b=new Error(a.statusText);throw b.response=a,b})},b.exports=f},{"./utils":56,"es6-promise":2,"isomorphic-fetch":3}],55:[function(a,b,c){var d=a("./FamilySearch"),e=a("./utils"),f=e.maybe,c={};c.setMember=function(a,b){this.data[a]||(this.data[a]={}),b instanceof d.Person?(this.data[a].resource=b.getPersonUrl(),delete this.data[a].resourceId):this.helpers.isAbsoluteUrl(b)?(this.data[a].resource=b,delete this.data[a].resourceId):e.isString(b)?(this.data[a].resourceId=b,delete this.data[a].resource):this.data[a]=b},c.deleteMember=function(a,b){this.deletedMembers||(this.deletedMembers={}),this.deletedMembers[a]=b,delete this.data[a]},c.setFacts=function(a,b,d){e.isArray(this.data[a])&&e.forEach(this.data[a],function(b){c.deleteFact.call(this,a,b,d)},this),this.data[a]=[],e.forEach(b,function(b){c.addFact.call(this,a,b)},this)},c.addFact=function(a,b){e.isArray(this.data[a])||(this.data[a]=[]),b instanceof d.Fact||(b=this.client.createFact(b)),this.data[a].push(b)},c.deleteFact=function(a,b,c){b instanceof d.Fact||(b=e.find(this.data[a],{id:b}));var g=e.indexOf(this.data[a],b);if(g>=0){var h=this.helpers.removeAccessToken(f(b.getLink("conclusion")).href);h&&(this.deletedFacts||(this.deletedFacts={}),this.deletedFacts[h]=c),this.data[a].splice(g,1)}},b.exports=c},{"./FamilySearch":5,"./utils":56}],56:[function(a,b,c){function d(a,b){for(var c in a)if(a.hasOwnProperty(c)&&b[c]!==a[c])return!1;return!0}function e(a){return c.isString(a)?(a=a.replace(/[:"]/g,"").trim(),a.indexOf(" ")>=0?'"'+a+'"':a):a}var c=b.exports;Object.create||(Object.create=function(){function a(){}return function(b){if(1!==arguments.length)throw new Error("Object.create implementation only accepts one parameter.");return a.prototype=b,new a}}()),"function"!=typeof Object.getPrototypeOf&&(Object.getPrototypeOf="object"==typeof"".__proto__?function(a){return a.__proto__}:function(a){return a.constructor.prototype}),c.isArray=function(a){return Array.isArray?Array.isArray(a):"[object Array]"==Object.prototype.toString.call(a)},c.isString=function(a){return"[object String]"==Object.prototype.toString.call(a)},c.isFunction=function(a){return"function"!=typeof/./?"function"==typeof a:"[object Function]"==Object.prototype.toString.call(a)},c.isObject=function(a){return a===Object(a)},c.isUndefined=function(a){return void 0===a};var f=c.forEach=function(a,b,c){if(null!=a)if(Array.prototype.forEach&&a.forEach===Array.prototype.forEach)a.forEach(b,c);else if(a.length===+a.length){for(var d=0,e=a.length;e>d;d++)if(b.call(c,a[d],d,a)==={})return}else for(var f in a)if(a.hasOwnProperty(f)&&b.call(c,a[f],f,a)==={})return};c.removeEmptyProperties=function(a){return f(a,function(b,c){(null==b||""===b)&&delete a[c]}),a},c.keys=Object.keys||function(a){if(a!==Object(a))throw new TypeError("Invalid object");var b=[];for(var c in a)a.hasOwnProperty(c)&&b.push(c);return b},c.filter=function(a,b,e){var g=[],h=c.isFunction(b);return f(a,function(a){(h?b.call(e,a):d(b,a))&&g.push(a)}),g},c.map=function(a,b,c){var d=[];return f(a,function(a,e,f){d.push(b.call(c,a,e,f))}),d},c.contains=function(a,b){if(null==a)return!1;if(a.indexOf&&a.indexOf===Array.prototype.indexOf)return-1!==a.indexOf(b);var c=!1;return f(a,function(a){a===b&&(c=!0)}),c},c.indexOf=function(a,b){if(Array.prototype.indexOf===a.indexOf)return a.indexOf(b);for(var c=0,d=a.length;d>c;c++)if(a[c]===b)return c;return-1},c.uniq=function(a){var b=[];return f(a,function(a){c.contains(b,a)||b.push(a)}),b},c.find=function(a,b,e){var f,g=c.isFunction(b);if(a)for(var h=0,i=a.length;i>h;h++){var j=a[h];if(g?b.call(e,j):d(b,j)){f=j;break}}return f},c.findIndex=function(a,b,e){var f=-1,g=c.isFunction(b);if(a)for(var h=0,i=a.length;i>h;h++){var j=a[h];if(g?b.call(e,j):d(b,j)){f=h;break}}return f},c.flatten=function(a){var b=[];return f(a,function(a){c.isArray(a)&&Array.prototype.push.apply(b,a)}),b},c.flatMap=function(a,b,d){return c.flatten(c.map(a,b,d))},c.findOrFirst=function(a,b){if(!c.isUndefined(a)){var d=c.find(a,b);return c.isUndefined(d)?a[0]:d}return void 0},c.extend=function(a){return a=a||{},f(Array.prototype.slice.call(arguments,1),function(b){b&&f(b,function(b,c){a[c]=b})}),a},c.maybe=function(a){return null!=a?a:{}};var g={start:!0,count:!0,context:!0};c.searchParamsFilter=function(a){return c.map(c.filter(c.keys(a),function(a){return!g[a]}),function(b){return b+":"+e(a[b])}).join(" ")}},{}]},{},[5])(5)}); \ No newline at end of file