-
Notifications
You must be signed in to change notification settings - Fork 25
/
Copy pathfamilysearch-javascript-sdk.min.js
4 lines (4 loc) · 117 KB
/
familysearch-javascript-sdk.min.js
1
2
3
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;b="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this,b.FamilySearch=a()}}(function(){var a;return function a(b,c,d){function e(g,h){if(!c[g]){if(!b[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:{}};b[g][0].call(k.exports,function(a){var c=b[g][1][a];return e(c?c:a)},k,k.exports,a,b,c,d)}return c[g].exports}for(var f="function"==typeof require&&require,g=0;g<d.length;g++)e(d[g]);return e}({1:[function(a,b,c){},{}],2:[function(a,b,c){function d(){throw new Error("setTimeout has not been defined")}function e(){throw new Error("clearTimeout has not been defined")}function f(a){if(l===setTimeout)return setTimeout(a,0);if((l===d||!l)&&setTimeout)return l=setTimeout,setTimeout(a,0);try{return l(a,0)}catch(b){try{return l.call(null,a,0)}catch(b){return l.call(this,a,0)}}}function g(a){if(m===clearTimeout)return clearTimeout(a);if((m===e||!m)&&clearTimeout)return m=clearTimeout,clearTimeout(a);try{return m(a)}catch(b){try{return m.call(null,a)}catch(b){return m.call(this,a)}}}function h(){q&&o&&(q=!1,o.length?p=o.concat(p):r=-1,p.length&&i())}function i(){if(!q){var a=f(h);q=!0;for(var b=p.length;b;){for(o=p,p=[];++r<b;)o&&o[r].run();r=-1,b=p.length}o=null,q=!1,g(a)}}function j(a,b){this.fun=a,this.array=b}function k(){}var l,m,n=b.exports={};!function(){try{l="function"==typeof setTimeout?setTimeout:d}catch(a){l=d}try{m="function"==typeof clearTimeout?clearTimeout:e}catch(a){m=e}}();var o,p=[],q=!1,r=-1;n.nextTick=function(a){var b=new Array(arguments.length-1);if(arguments.length>1)for(var c=1;c<arguments.length;c++)b[c-1]=arguments[c];p.push(new j(a,b)),1!==p.length||q||f(i)},j.prototype.run=function(){this.fun.apply(null,this.array)},n.title="browser",n.browser=!0,n.env={},n.argv=[],n.version="",n.versions={},n.on=k,n.addListener=k,n.once=k,n.off=k,n.removeListener=k,n.removeAllListeners=k,n.emit=k,n.binding=function(a){throw new Error("process.binding is not supported")},n.cwd=function(){return"/"},n.chdir=function(a){throw new Error("process.chdir is not supported")},n.umask=function(){return 0}},{}],3:[function(b,c,d){(function(d,e){(function(){"use strict";function f(a){return"function"==typeof a||"object"==typeof a&&null!==a}function g(a){return"function"==typeof a}function h(a){return"object"==typeof a&&null!==a}function i(a){U=a}function j(a){Y=a}function k(){return function(){d.nextTick(p)}}function l(){return function(){T(p)}}function m(){var a=0,b=new _(p),c=document.createTextNode("");return b.observe(c,{characterData:!0}),function(){c.data=a=++a%2}}function n(){var a=new MessageChannel;return a.port1.onmessage=p,function(){a.port2.postMessage(0)}}function o(){return function(){setTimeout(p,1)}}function p(){for(var a=0;a<X;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;g<b.length;g+=3)d=b[g],e=b[g+c],d?H(c,d,e,f):e(f);a._subscribers.length=0}}function F(){this.error=null}function G(a,b){try{return a(b)}catch(c){return ha.error=c,ha}}function H(a,b,c,d){var e,f,h,i,j=g(c);if(j){if(e=G(c,d),e===ha?(i=!0,f=e.error,e=null):h=!0,b===e)return void C(b,t())}else e=d,h=!0;b._state!==da||(j&&h?z(b,e):i?C(b,f):a===ea?B(b,e):a===fa&&C(b,e))}function I(a,b){try{b(function(b){z(a,b)},function(b){C(a,b)})}catch(c){C(a,c)}}function J(a,b){var c=this;c._instanceConstructor=a,c.promise=new a(r),c._validateInput(b)?(c._input=b,c.length=b.length,c._remaining=b.length,c._init(),0===c.length?B(c.promise,c._result):(c.length=c.length||0,c._enumerate(),0===c._remaining&&B(c.promise,c._result))):C(c.promise,c._validationError())}function K(a){return new ia(this,a).promise}function L(a){function b(a){z(e,a)}function c(a){C(e,a)}var d=this,e=new d(r);if(!W(a))return C(e,new TypeError("You must pass an array to race.")),e;for(var f=a.length,g=0;e._state===da&&g<f;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&&e<b;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:2}],4:[function(a,b,c){a("whatwg-fetch"),b.exports=self.fetch.bind(self)},{"whatwg-fetch":5}],5:[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(c<100||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}}()},{}],6:[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/ordinances"),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("./modules/node-only"),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":7,"./classes/attribution":8,"./classes/base":9,"./classes/change":10,"./classes/childAndParents":11,"./classes/collection":12,"./classes/comment":13,"./classes/couple":14,"./classes/date":15,"./classes/discussion":16,"./classes/discussionRef":17,"./classes/fact":18,"./classes/gender":19,"./classes/memory":20,"./classes/memoryArtifactRef":21,"./classes/memoryPersona":22,"./classes/memoryPersonaRef":23,"./classes/name":24,"./classes/note":25,"./classes/person":26,"./classes/placeDescription":27,"./classes/placeReference":28,"./classes/placesSearchResult":29,"./classes/searchResult":30,"./classes/sourceDescription":31,"./classes/sourceRef":32,"./classes/textValue":33,"./classes/user":34,"./classes/vocabularyElement":35,"./classes/vocabularyList":36,"./globals":37,"./helpers":38,"./modules/authentication":39,"./modules/authorities":40,"./modules/changeHistory":41,"./modules/discussions":42,"./modules/memories":43,"./modules/node-only":1,"./modules/notes":44,"./modules/ordinances":45,"./modules/parentsAndChildren":46,"./modules/pedigree":47,"./modules/persons":48,"./modules/places":49,"./modules/searchAndMatch":50,"./modules/sourceBox":51,"./modules/sources":52,"./modules/spouses":53,"./modules/users":54,"./modules/utilities":55,"./plumbing":56,"./utils":58}],7:[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":6,"./../utils":58}],8:[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":6,"./../utils":58}],9:[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;c<a.length;c++)b[c]=d(a[c]);return b}return void 0!==a?JSON.parse(JSON.stringify(a)):void 0}var e=a("./../FamilySearch"),f=a("./../utils");e.BaseClass=function(a,b){b?this.data=b:this.data={},this.client=a,this.helpers=a.helpers,this.plumbing=a.plumbing,!this.data.attribution||this.data.attribution instanceof e.Attribution||this.setAttribution(this.data.attribution)},e.BaseClass.prototype.getId=function(){return this.data.id},e.BaseClass.prototype.setId=function(a){return this.data.id=a,this},e.BaseClass.prototype.getLinks=function(){return this.data.links?this.data.links:{}},e.BaseClass.prototype.getLink=function(a){if(this.data.links&&this.data.links[a])return this.data.links[a]},e.BaseClass.prototype.getLinkPromise=function(a){var b=this.getLinks();return b[a]?Promise.resolve(b[a]):Promise.reject(new Error("Missing link: "+a))},e.BaseClass.prototype.addLink=function(a,b){return this.data.links||(this.data.links={}),this.data.links[a]=b,this},e.BaseClass.prototype.addLinks=function(a){var b=this;return f.forEach(a,function(a,c){b.addLink(c,a)}),this},e.BaseClass.prototype.setAttribution=function(a){return a&&(a instanceof e.Attribution||(a=this.client.createAttribution(a)),this.data.attribution=a),this},e.BaseClass.prototype.getAttribution=function(){return this.data.attribution},e.BaseClass.prototype.updateFromResponse=function(a,b){return a.getHeader("x-entity-id")&&this.setId(a.getHeader("x-entity-id")),a.getHeader("link")&&this.addLinks(this.helpers.parseLinkHeaders(a.getHeader("link",!0))),b&&a.getHeader("location")&&this.addLink(b,{href:a.getHeader("location")}),this},e.BaseClass.prototype.toJSON=function(){var a={};return f.forEach(this.data,function(b,c){a[c]=d(b)}),a},e.BaseClass.prototype.toString=function(){return JSON.stringify(this)},e.BaseClass.prototype.inspect=function(){return this.toString()}},{"./../FamilySearch":6,"./../utils":58}],10:[function(a,b,c){var d=a("./../FamilySearch"),e=a("./../utils"),f=e.maybe,g=d.Change=function(a,b){d.BaseClass.call(this,a,b)};d.prototype.createChange=function(a){return new g(this,a)},g.prototype=e.extend(Object.create(d.BaseClass.prototype),{constructor:g,getTitle:function(){return this.data.title},getUpdatedTimestamp:function(){return this.data.updated},getAgentName:function(){return f(f(this.data.contributors)[0]).name},getChangeReason:function(){return f(f(this.data.changeInfo)[0]).reason},getAgentUrl:function(){return this.helpers.removeAccessToken(f(this.getLink("agent")).href)},getAgent:function(){return this.client.getAgent(this.getAgentUrl())},restore:function(){var a=this;return a.getLinkPromise("restore").then(function(b){return a.client.restoreChange(b.href)})}})},{"./../FamilySearch":6,"./../utils":58}],11:[function(a,b,c){var d=a("../FamilySearch"),e=a("../relationshipHelpers"),f=a("../utils"),g=f.maybe,h=d.ChildAndParents=function(a,b){d.BaseClass.call(this,a,b),b&&(b.father&&this.setFather(b.father),b.mother&&this.setMother(b.mother),b.child&&this.setChild(b.child),b.fatherFacts&&f.forEach(this.data.fatherFacts,function(b,c){b instanceof d.Fact||(this.data.fatherFacts[c]=a.createFact(b))},this),b.motherFacts&&f.forEach(this.data.motherFacts,function(b,c){b instanceof d.Fact||(this.data.motherFacts[c]=a.createFact(b))},this))};d.prototype.createChildAndParents=function(a){return new h(this,a)},h.prototype=f.extend(Object.create(d.BaseClass.prototype),{constructor:h,getId:function(){return this.data.id},getChildAndParentsUrl:function(){return this.helpers.removeAccessToken(g(this.getLink("relationship")).href)},getFatherFacts:function(){return this.data.fatherFacts||[]},getMotherFacts:function(){return this.data.motherFacts||[]},getFatherId:function(){return g(this.data.father).resourceId},getFatherUrl:function(){return this.helpers.removeAccessToken(g(this.data.father).resource)},getFather:function(){return this.client.getPerson(this.getFatherUrl())},getMotherId:function(){return g(this.data.mother).resourceId},getMotherUrl:function(){return this.helpers.removeAccessToken(g(this.data.mother).resource)},getMother:function(){return this.client.getPerson(this.getMotherUrl())},getChildId:function(){return g(this.data.child).resourceId},getChildUrl:function(){return this.helpers.removeAccessToken(g(this.data.child).resource)},getChild:function(){return this.client.getPerson(this.getChildUrl())},getNotes:function(){var a=this;return a.getLinkPromise("notes").then(function(b){return a.client.getNotes(b.href)})},getSourceRefs:function(){var a=this;return a.getLinkPromise("source-references").then(function(b){return a.client.getSourceRefs(b.href)})},getSources:function(){var a=this;return a.getLinkPromise("source-descriptions").then(function(b){return a.client.getSourcesQuery(b.href)})},getChanges:function(a){var b=this;return b.getLinkPromise("change-history").then(function(c){return b.client.getChanges(c.href,a)})},setFather:function(a){return e.setMember.call(this,"father",a),this.fatherChanged=!0,this},setMother:function(a){return e.setMember.call(this,"mother",a),this.motherChanged=!0,this},setChild:function(a){return e.setMember.call(this,"child",a),this},deleteFather:function(a){return e.deleteMember.call(this,"father",a),this},deleteMother:function(a){return e.deleteMember.call(this,"mother",a),this},setFatherFacts:function(a,b){return e.setFacts.call(this,"fatherFacts",a,b),this},addFatherFact:function(a){return e.addFact.call(this,"fatherFacts",a),this},deleteFatherFact:function(a,b){return e.deleteFact.call(this,"fatherFacts",a,b),this},setMotherFacts:function(a,b){return e.setFacts.call(this,"motherFacts",a,b),this},addMotherFact:function(a){return e.addFact.call(this,"motherFacts",a),this},deleteMotherFact:function(a,b){return e.deleteFact.call(this,"motherFacts",a,b),this},addSource:function(a,b,c){return this.client._createAndAttachSource(this.getChildAndParentsUrl(),a,b,c)},addNote:function(a,b){var c=this.client;return this.getLinkPromise("notes").then(function(d){return c._addNote(d.href,a,b)})},save:function(a){var b=this.client.createChildAndParents(),c=!1,d=this.getId(),g=this;d&&!this.fatherChanged||(b.setFather(this.data.father),c=!0),d&&!this.motherChanged||(b.setMother(this.data.mother),c=!0),d||(b.setChild(this.data.child),c=!0),a&&b.setAttribution(a),f.forEach(["fatherFacts","motherFacts"],function(a){f.forEach(g.data[a],function(f){d&&f.getId()&&!f.changed||(e.addFact.call(b,a,f),c=!0)})});var h=[];if(c){var i=g.getChildAndParentsUrl()?Promise.resolve(g.getChildAndParentsUrl()):g.plumbing.getCollectionUrl("FSFT","relationships");h.push(i.then(function(a){return f.forEach(["father","mother","child"],function(a){b.data[a]&&!b.data[a].resource&&b.data[a].resourceId&&(b.data[a].resource=b.data[a].resourceId)}),g.plumbing.post(a,{childAndParentsRelationships:[b]},{"Content-Type":"application/x-fs-v1+json"})}).then(function(a){return g.updateFromResponse(a,"relationship"),a}))}return f.forEach(["father","mother"],function(b){if(g.getId()&&g.deletedMembers&&g.deletedMembers.hasOwnProperty(b)&&!g.data[b]){var c=g.deletedMembers[b]||a;h.push(g.getLinkPromise(b+"-role").then(function(a){var b={"Content-Type":"application/x-fs-v1+json"};return c&&(b["X-Reason"]=c),g.plumbing.del(a.href,b)}))}}),d&&g.deletedFacts&&f.forEach(g.deletedFacts,function(b,c){b=b||a;var d={"Content-Type":"application/x-fs-v1+json"};b&&(d["X-Reason"]=b),h.push(g.plumbing.del(c,d))}),Promise.all(h)},delete:function(a){return this.client.deleteChildAndParents(this.getChildAndParentsUrl(),a)},restore:function(){var a=this;return a.getLinkPromise("restore").then(function(b){return a.client.restoreChildAndParents(b.href)})}})},{"../FamilySearch":6,"../relationshipHelpers":57,"../utils":58}],12:[function(a,b,c){var d=a("./../FamilySearch"),e=a("./../utils"),f=e.maybe,g=d.Collection=function(a,b){d.BaseClass.call(this,a,b)};d.prototype.createCollection=function(a){return new g(this,a)},g.prototype=e.extend(Object.create(d.BaseClass.prototype),{constructor:g,getTitle:function(){return this.data.title},getSize:function(){return this.data.size},getCollectionUrl:function(){return this.helpers.removeAccessToken(f(this.getLink("self")).href)},getSourceDescriptions:function(a){return this.client.getCollectionSourceDescriptions(this.helpers.removeAccessToken(f(this.getLink("source-descriptions")).href),a)},save:function(){var a=this,b=a.getCollectionUrl()?Promise.resolve(a.getCollectionUrl()):a.plumbing.getCollectionUrl("FSUDS","subcollections");return b.then(function(b){return a.plumbing.post(b,{collections:[a]})}).then(function(b){return a.updateFromResponse(b,"self"),b})},delete:function(){return this.client.deleteCollection(this.getCollectionUrl())}})},{"./../FamilySearch":6,"./../utils":58}],13:[function(a,b,c){var d=a("./../FamilySearch"),e=a("./../utils"),f=e.maybe,g=d.Comment=function(a,b){d.BaseClass.call(this,a,b)};d.prototype.createComment=function(a){return new g(this,a)},g.prototype=e.extend(Object.create(d.BaseClass.prototype),{constructor:g,getText:function(){return this.data.text},getCreatedTimestamp:function(){return this.data.created},getCommentUrl:function(){return this.helpers.removeAccessToken(f(this.getLink("comment")).href)},getAgentId:function(){return f(this.data.contributor).resourceId},getAgentUrl:function(){return this.helpers.removeAccessToken(f(this.data.contributor).resource)},getAgent:function(){return this.client.getAgent(this.getAgentUrl()||this.getAgentId())},save:function(a){var b=this,c={discussions:[{comments:[b]}]};return b.plumbing.post(a,c,{"Content-Type":"application/x-fs-v1+json"}).then(function(a){return b.updateFromResponse(a,"comment"),a})},delete:function(a,b){return this.client.deleteComment(this.getCommentUrl(),b)}})},{"./../FamilySearch":6,"./../utils":58}],14:[function(a,b,c){var d=a("../FamilySearch"),e=a("../relationshipHelpers"),f=a("../utils"),g=f.maybe,h=d.Couple=function(a,b){d.BaseClass.call(this,a,b),b&&(b.husband&&(this.setHusband(b.husband),delete b.husband),b.wife&&(this.setWife(b.wife),delete b.wife),b.facts&&f.forEach(this.data.facts,function(b,c){b instanceof d.Fact||(this.data.facts[c]=a.createFact(b))},this))};d.prototype.createCouple=function(a){return new h(this,a)},h.prototype=f.extend(Object.create(d.BaseClass.prototype),{constructor:h,getCoupleUrl:function(){return this.helpers.removeAccessToken(g(this.getLink("relationship")).href)},getFacts:function(){return this.data.facts||[]},getMarriageFact:function(){return f.find(this.data.facts,function(a){return"http://gedcomx.org/Marriage"===a.getType()})},getHusbandId:function(){return g(this.data.person1).resourceId},getHusbandUrl:function(){return this.helpers.removeAccessToken(g(this.data.person1).resource)},getHusband:function(){return this.client.getPerson(this.getHusbandUrl())},getWifeId:function(){return g(this.data.person2).resourceId},getWifeUrl:function(){return this.helpers.removeAccessToken(g(this.data.person2).resource)},getWife:function(){return this.client.getPerson(this.getWifeUrl())},getSpouseId:function(a){return g(this.data.person1).resourceId===a?g(this.data.person2).resourceId:g(this.data.person1).resourceId},getSpouseUrl:function(a){return g(this.data.person1).resourceId===a?this.helpers.removeAccessToken(g(this.data.person2).resource):this.helpers.removeAccessToken(g(this.data.person1).resource)},getSpouse:function(a){return this.client.getPerson(this.getSpouseUrl(a))},getNotes:function(){var a=this;return a.getLinkPromise("notes").then(function(b){return a.client.getNotes(b.href)})},getSourceRefs:function(){var a=this;return a.getLinkPromise("source-references").then(function(b){return a.client.getSourceRefs(b.href)})},getSources:function(){var a=this;return a.getLinkPromise("source-descriptions").then(function(b){return a.client.getSourcesQuery(b.href)})},getChanges:function(a){var b=this;return b.getLinkPromise("change-history").then(function(c){return b.client.getChanges(c.href,a)})},setHusband:function(a){return e.setMember.call(this,"person1",a),this.husbandChanged=!0,this},setWife:function(a){return e.setMember.call(this,"person2",a),this.wifeChanged=!0,this},setFacts:function(a,b){return e.setFacts.call(this,"facts",a,b),this},addFact:function(a){return e.addFact.call(this,"facts",a),this},deleteFact:function(a,b){return e.deleteFact.call(this,"facts",a,b),this},addSource:function(a,b,c){return this.client._createAndAttachSource(this.getCoupleUrl(),a,b,c)},addNote:function(a,b){var c=this.client;return this.getLinkPromise("notes").then(function(d){return c._addNote(d.href,a,b)})},save:function(a){var b=this.client.createCouple(),c=!1,d=this.getId(),g=this;(!d||this.husbandChanged||this.wifeChanged)&&(b.data.person1=this.data.person1,b.data.person2=this.data.person2,c=!0),a&&b.setAttribution(g.client.createAttribution(a)),f.forEach(this.data.facts,function(a){d&&a.getId()&&!a.changed||(e.addFact.call(b,"facts",a),c=!0)});var h=[];if(c){d||(b.data.type="http://gedcomx.org/Couple");var i=g.getCoupleUrl()?Promise.resolve(g.getCoupleUrl()):g.plumbing.getCollectionUrl("FSFT","relationships");h.push(i.then(function(a){return f.forEach(["person1","person2"],function(a){b.data[a]&&!b.data[a].resource&&b.data[a].resourceId&&(b.data[a].resource=b.data[a].resourceId)}),g.plumbing.post(a,{relationships:[b]})}).then(function(a){return g.updateFromResponse(a),a}))}return d&&this.deletedFacts&&f.forEach(this.deletedFacts,function(b,c){b=b||a,h.push(g.plumbing.del(c,b?{"X-Reason":b}:{}))}),Promise.all(h)},
delete:function(a){return this.client.deleteCouple(this.getCoupleUrl(),a)},restore:function(){var a=this;return a.getLinkPromise("restore").then(function(b){return a.client.restoreCouple(b.href)})}})},{"../FamilySearch":6,"../relationshipHelpers":57,"../utils":58}],15:[function(a,b,c){var d=a("./../FamilySearch"),e=a("../utils"),f=d.Date=function(a,b){d.BaseClass.call(this,a,b),b&&e.isString(b.normalized)&&this.setNormalized(b.normalized)};d.prototype.createDate=function(a){return new f(this,a)},f.prototype=e.extend(Object.create(d.BaseClass.prototype),{constructor:f,getOriginal:function(){return this.data.original},getFormal:function(){return this.data.formal},getNormalized:function(){return e.maybe(e.maybe(this.data.normalized)[0]).value},setOriginal:function(a){return this.data.original=a,this},setFormal:function(a){return this.data.formal=a,this},setNormalized:function(a){return this.data.normalized=[{value:a}],this}})},{"../utils":58,"./../FamilySearch":6}],16:[function(a,b,c){var d=a("./../FamilySearch"),e=a("./../utils"),f=e.maybe,g=d.Discussion=function(a,b){d.BaseClass.call(this,a,b)};d.prototype.createDiscussion=function(a){return new g(this,a)},g.prototype=e.extend(Object.create(d.BaseClass.prototype),{constructor:g,getTitle:function(){return this.data.title},getDetails:function(){return this.data.details},getCreatedTimestamp:function(){return this.data.created},getModifiedTimestamp:function(){return this.data.modified},getNumberOfComments:function(){return this.data.numberOfComments},getDiscussionUrl:function(){return this.helpers.removeAccessToken(f(this.getLink("discussion")).href)},getCommentsUrl:function(){return this.helpers.removeAccessToken(f(this.getLink("comments")).href)},getComments:function(){return this.client.getDiscussionComments(this.getCommentsUrl())},getAgentId:function(){return f(this.data.contributor).resourceId},getAgentUrl:function(){return this.helpers.removeAccessToken(f(this.data.contributor).resource)},getAgent:function(){return this.client.getAgent(this.getAgentUrl())},save:function(){var a=this,b=a.getDiscussionUrl()?Promise.resolve(a.getDiscussionUrl()):a.plumbing.getCollectionUrl("FSDF","discussions");return b.then(function(b){return a.plumbing.post(b,{discussions:[a]},{"Content-Type":"application/x-fs-v1+json"})}).then(function(b){return a.updateFromResponse(b,"discussion"),b})},delete:function(a){return this.client.deleteDiscussion(this.getDiscussionUrl(),a)}})},{"./../FamilySearch":6,"./../utils":58}],17:[function(a,b,c){var d=a("./../FamilySearch"),e=a("./../utils"),f=e.maybe,g=d.DiscussionRef=function(a,b){d.BaseClass.call(this,a,b),b&&b.discussion&&(this.setDiscussion(b.discussion),delete b.discussion)};d.prototype.createDiscussionRef=function(a){return new g(this,a)},g.prototype=e.extend(Object.create(d.BaseClass.prototype),{constructor:g,getResourceId:function(){return this.data.resourceId},getResource:function(){return this.data.resource},getDiscussionRefUrl:function(){return this.helpers.removeAccessToken(f(this.getLink("discussion-reference")).href)},getDiscussionUrl:function(){return this.helpers.removeAccessToken(this.data.resource)},getDiscussion:function(){return this.client.getDiscussion(this.getDiscussionUrl()||this.resourceId)},setDiscussion:function(a){return a instanceof d.Discussion?(this.data.resource=a.getDiscussionUrl(),this.data.resourceId=a.getId()):this.helpers.isAbsoluteUrl(a)?this.data.resource=this.helpers.removeAccessToken(a):this.data.resourceId=a,this},save:function(a){var b=this;b.getDiscussionRefUrl()&&(a=b.getDiscussionRefUrl()),!b.data.resource&&b.data.resourceId&&(b.data.resource=b.data.resourceId);var c={persons:[{"discussion-references":[{resource:b.data.resource}]}]},d={"Content-Type":"application/x-fs-v1+json"};return b.plumbing.post(a,c,d).then(function(a){return b.updateFromResponse(a,"discussion-reference"),a})},delete:function(a){return this.client.deleteDiscussionRef(this.getDiscussionRefUrl(),a)}})},{"./../FamilySearch":6,"./../utils":58}],18:[function(a,b,c){var d=a("./../FamilySearch"),e=a("./../utils"),f=e.maybe,g=d.Fact=function(a,b){d.BaseClass.call(this,a,b),b&&(b.date&&this.setDate(b.date),b.place&&this.setPlace(b.place),!b.attribution||b.attribution instanceof d.Attribution||this.setAttribution(a.createAttribution(b.attribution))),this.changed=!1};d.prototype.createFact=function(a){return new g(this,a)},g.prototype=e.extend(Object.create(d.BaseClass.prototype),{constructor:g,getType:function(){return this.data.type},getValue:function(){return this.data.value},getDate:function(){return this.data.date},getOriginalDate:function(){if(this.data.date)return this.data.date.getOriginal()},getNormalizedDate:function(){if(this.data.date)return this.data.date.getNormalized()},getFormalDate:function(){if(this.data.date)return this.data.date.getFormal()},getPlace:function(){return this.data.place},getOriginalPlace:function(){if(this.data.place)return this.data.place.getOriginal()},getNormalizedPlace:function(){if(this.data.place)return this.data.place.getNormalized()},getNormalizedPlaceId:function(){var a=f(this.data.place).description;return a&&"#"===a.charAt(0)?a.substr(1):""},isCustomNonEvent:function(){if(this.data.qualifiers){var a=e.find(this.data.qualifiers,{name:"http://familysearch.org/v1/Event"});return!!a&&"false"===a.value}return!1},setType:function(a){return this.changed=!0,this.data.type=a,this},setCustomNonEvent:function(a){var b;return a?(this.data.qualifiers||(this.data.qualifiers=[]),b=e.findIndex(this.data.qualifiers,{name:"http://familysearch.org/v1/Event"}),b<0&&(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":6,"./../utils":58}],19:[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":58,"./../FamilySearch":6}],20:[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":6,"./../utils":58}],21:[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":6,"./../utils":58}],22:[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":6,"./../utils":58}],23:[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":6,"./../utils":58}],24:[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":6,"./../utils":58}],25:[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":6,"./../utils":58}],26:[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.getNotes(g(this.getLink("notes")).href)},getSourceRefs:function(){return this.client.getSourceRefs(this.getLink("source-references").href)},getSources:function(){return this.client.getSourcesQuery(this.getLink("source-descriptions").href)},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)})},getSpouseRelationships:function(a){var b=this;return b.getLinkPromise("spouse-relationships").then(function(c){return b.plumbing.get(c.href,a)}).then(function(a){return b.client._personsAndRelationshipsMapper(a)})},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)})},getParentRelationships:function(a){var b=this;return b.getLinkPromise("parent-relationships").then(function(c){return b.plumbing.get(c.href,a)}).then(function(a){return b.client._personsAndRelationshipsMapper(a)})},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)})},getChildRelationships:function(a){var b=this;return b.getLinkPromise("child-relationships").then(function(c){return b.plumbing.get(c.href,a)}).then(function(a){return b.client._personsAndRelationshipsMapper(a)})},getMatches:function(){var a=this;return a.getLinkPromise("matches").then(function(b){return a.client.getPersonMatches(b.href)})},getRecordMatches:function(){var a=this;return a.getLinkPromise("matches").then(function(b){return a.client.getPersonMatches(b.href,{collection:"records"})})},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},addSource:function(a,b,c){return this.client._createAndAttachSource(this.getPersonUrl(),a,b,c)},addDiscussion:function(a,b){var c=this,d=this.client;a instanceof e.Discussion||(a=d.createDiscussion(a));var f=new Promise(function(b,c){a.getId()?b(a):a.save().then(function(){b(a)},function(a){c(a)})});return f.then(function(a){var e=d.createDiscussionRef({discussion:a});return e.save(c.getPersonUrl(),b)})},addNote:function(a,b){var c=this.client;return this.getLinkPromise("notes").then(function(d){return c._addNote(d.href,a,b)})},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":6,"../utils":58}],27:[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(){if(this.data.jurisdiction instanceof d.PlaceDescription)return this.data.jurisdiction},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":6,"./../utils":58}],28:[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":6,"./../utils":58}],29:[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":6,"./../utils":58}],30:[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},getConfidence:function(){return this.data.confidence},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":6,"./../utils":58}],31:[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":6,"./../utils":58}],32:[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(){if("#"!==this.getDescription().charAt(0))return this.helpers.removeAccessToken(this.getDescription())},getSourceDescriptionId:function(){return"#"===this.getDescription().charAt(0)?this.getDescription().substr(1):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})},getAttachedEntityId:function(){return this.attachedEntityId},getAttachedEntityUrl:function(){return this.attachedEntityUrl},setAttachedEntityId:function(a){return this.attachedEntityId=a,this},setAttachedEntityUrl:function(a){return this.attachedEntityUrl=this.helpers.removeAccessToken(a),this},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.data.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":6,"./../utils":58}],33:[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":58,"./../FamilySearch":6}],34:[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":6,"../utils":58}],35:[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":6,"./../utils":58}],36:[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":6,"./../utils":58}],37:[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://integration.familysearch.org",integration:"https://integration.familysearch.org",staging:"https://stage.familysearch.org",beta:"https://beta.familysearch.org",production:"https://familysearch.org"},oauthServer:{integration:"https://integration.familysearch.org/cis-web/oauth2/v3",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"}},{}],38:[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<this.settings.maxAccessTokenInactivityTime&&f<this.settings.maxAccessTokenCreationTime&&(this.settings.accessToken=d[2],this.settings.autoExpire&&(b.setAccessTokenInactiveTimer(this.settings.maxAccessTokenInactivityTime-e),b.setAccessTokenCreationTimer(this.settings.maxAccessTokenCreationTime-f)))}}}},f.prototype.setAccessToken=function(a){if(this.settings.accessToken=a,"undefined"!=typeof window&&(this.settings.autoExpire&&(this.setAccessTokenInactiveTimer(this.settings.maxAccessTokenInactivityTime),this.setAccessTokenCreationTimer(this.settings.maxAccessTokenCreationTime)),this.settings.saveAccessToken)){var b=(new Date).getTime(),c=b+"|"+b+"|"+a;this.createCookie(this.getAccessTokenCookieName(),c,0)}},f.prototype.refreshAccessToken=function(){var a=(new Date).getTime();if(this.settings.autoExpire&&this.setAccessTokenInactiveTimer(this.settings.maxAccessTokenInactivityTime),this.settings.saveAccessToken){var b=this.readCookie(this.getAccessTokenCookieName());if(b){var c=b.split("|",3);3===c.length&&(b=a+"|"+c[1]+"|"+c[2],this.createCookie(this.getAccessTokenCookieName(),b,0))}}},f.prototype.eraseAccessToken=function(a){this.settings.accessToken=null,"undefined"!=typeof window&&(this.settings.autoExpire&&this.clearAccessTokenTimers(),this.settings.saveAccessToken&&this.eraseCookie(this.getAccessTokenCookieName()),this.settings.expireCallback&&!a&&this.settings.expireCallback(this.client))},f.prototype.isAbsoluteUrl=function(a){return/^https?:\/\//.test(a)},f.prototype.isAuthoritiesServerUrl=function(a){return a.indexOf("/authorities/v1/")!==-1},f.prototype.encodeQueryString=function(a){var b=[];return e(a,function(a,c){c=encodeURIComponent(c);var e;e=d.isArray(a)?d.map(a,function(a){return c+"="+encodeURIComponent(a)}).join("&"):null!=a?c+"="+encodeURIComponent(a):c,b.push(e)}),b.join("&")},f.prototype.appendQueryParameters=function(a,b){var c=this.encodeQueryString(b);return 0===c.length?a:a+(a.indexOf("?")>=0?"&":"?")+c},f.prototype.decodeQueryString=function(a){var b={};if(a){var c=a.indexOf("?");if(c!==-1){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("?");b!==-1&&(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;e<f;e++)if(e%2===1){var g=b[c[e]];c[e]=d?encodeURIComponent(g):encodeURI(g)}else c[e].indexOf("?")!==-1&&(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<c.length;d++){for(var e=c[d];" "===e.charAt(0);)e=e.substring(1,e.length);if(0===e.indexOf(b))return e.substring(b.length,e.length)}return null},f.prototype.eraseCookie=function(a){this.createCookie(a,"",-1)},b.exports=f},{"./utils":58}],39:[function(a,b,c){var d=a("./../FamilySearch"),e=a("./../utils");d.prototype.getAuthCode=function(){var a=this,b=a.settings;if("undefined"==typeof window)return Promise.reject(new Error("This method can only be used in browsers."));if(b.expireCallback&&!b.autoSignin)return b.expireCallback(this),Promise.reject(new Error("Not sure why we are rejecting here"));var c=a.settings.oauthServer[a.settings.environment]+"/authorization",d=a.openPopup(c,{response_type:"code",client_id:b.clientId,redirect_uri:b.redirectUri});return a._pollForAuthCode(d)},d.prototype.handleAccessTokenResponse=function(a){var b=this,c=a.getData(),d=c.access_token;return d?(b.helpers.setAccessToken(d),Promise.resolve(d)):Promise.reject(new Error(c.error))},d.prototype.getAccessToken=function(a){var b=this,c=b.settings,d=b.plumbing;if(c.accessToken)return Promise.resolve(c.accessToken);var e;return e=a?Promise.resolve(a):b.getAuthCode(),e.then(function(a){var e=b.settings.oauthServer[b.settings.environment]+"/token";return d.post(e,{grant_type:"authorization_code",code:a,client_id:c.clientId,redirect_uri:c.redirectUri},{"Content-Type":"application/x-www-form-urlencoded"}).then(function(a){return b.handleAccessTokenResponse(a)})})},d.prototype.getAccessTokenForMobile=function(a,b){var c=this;if(c.settings.accessToken)return Promise.resolve(c.settings.accessToken);var d=c.settings.oauthServer[c.settings.environment]+"/token";return c.plumbing.post(d,{grant_type:"password",client_id:c.settings.clientId,username:a,password:b},{"Content-Type":"application/x-www-form-urlencoded"}).then(function(a){return c.handleAccessTokenResponse(a)})},d.prototype.getUnauthenticatedAccessToken=function(a){var b=this;if(!a)return Promise.reject("IP Address is required.");if(b.settings.accessToken)return Promise.resolve(b.settings.accessToken);var c=b.settings.oauthServer[b.settings.environment]+"/token";return b.plumbing.post(c,{grant_type:"unauthenticated_session",client_id:b.settings.clientId,ip_address:a},{"Content-Type":"application/x-www-form-urlencoded"}).then(function(a){return b.handleAccessTokenResponse(a)})},d.prototype.getAccessTokenWithClientCredentials=function(){throw new Error("Authentication via client credentials is not supported in the browser.")},d.prototype.getOAuth2AuthorizeURL=function(a){var b=this,c=b.settings,d={response_type:"code",client_id:c.clientId,redirect_uri:c.redirectUri};a&&(d.state=a);var e=c.oauthServer[c.environment]+"/authorization";return b.helpers.appendQueryParameters(e,d)},d.prototype.hasAccessToken=function(){return!!this.settings.accessToken},d.prototype.invalidateAccessToken=function(){var a=this,b=a.settings.accessToken;return a.helpers.eraseAccessToken(!0),a.plumbing.getCollectionUrl("FSFT","logout").then(function(c){return a.plumbing.post(a.helpers.appendQueryParameters(c,{access_token:b}))})},d.prototype.openPopup=function(a,b){var c=e.isUndefined(window.screenX)?window.screenLeft:window.screenX,d=e.isUndefined(window.screenY)?window.screenTop:window.screenY,f=e.isUndefined(window.outerWidth)?document.documentElement.clientWidth:window.outerWidth,g=e.isUndefined(window.outerHeight)?document.documentElement.clientHeight-22:window.outerHeight,h=b.width||780,i=b.height||500,j=parseInt(c+(f-h)/2,10),k=parseInt(d+(g-i)/2.5,10),l="width="+h+",height="+i+",left="+j+",top="+k;return window.open(this.helpers.appendQueryParameters(a,b),"",l)},d.prototype.getCode=function(a){var b=this.helpers.decodeQueryString(a);return b.code?Promise.resolve(b.code):Promise.reject(b.error)},d.prototype._pollForAuthCode=function(a){var b=this;return a?new Promise(function(c,d){var e=setInterval(function(){try{a.location.hostname===window.location.hostname&&(b.getCode(a.location.href).then(function(a){c(a)},function(a){d(a)}),clearInterval(e),a.close())}catch(f){}},b.settings.authCodePollDelay);window.FamilySearchOauthReceiver=function(a){b.getCode(a).then(function(a){c(a)},function(a){d(a)}),clearInterval(e)}}):Promise.reject("Popup blocked")}},{"./../FamilySearch":6,"./../utils":58}],40:[function(a,b,c){var d=a("./../FamilySearch"),e=a("./../utils");d.prototype.getDate=function(a){var b=this;return b.plumbing.getCollectionUrl("FSDA","normalized-date").then(function(c){return b.plumbing.get(c,{date:a},{Accept:"text/plain"})}).then(function(a){var c;return a.getData()&&(c=b.createDate({normalized:a.getData(),formal:a.getHeader("Location").split(":")[1]})),a.getDate=function(){return e.maybe(c)},a})}},{"./../FamilySearch":6,"./../utils":58}],41:[function(a,b,c){var d=a("./../FamilySearch"),e=a("./../utils");d.prototype._changeHistoryResponseMapper=function(a){for(var b=this,c=e.maybe(a.getData()),d=0;d<c.entries.length;d++)c.entries[d]=b.createChange(c.entries[d]);return e.extend({getChanges:function(){return c.entries||[]}})},d.prototype.getChanges=function(a,b){var c=this;return c.plumbing.get(a,b,{Accept:"application/x-gedcomx-atom+json"}).then(function(a){return c._changeHistoryResponseMapper(a)})},d.prototype.restoreChange=function(a){return this.plumbing.post(a,null,{"Content-Type":void 0})}},{"./../FamilySearch":6,"./../utils":58}],42:[function(a,b,c){var d=a("./../FamilySearch"),e=a("./../utils"),f=e.maybe;d.prototype.getDiscussion=function(a){var b=this;return b.plumbing.get(a,null,{Accept:"application/x-fs-v1+json"}).then(function(a){return e.forEach(a.getData().discussions,function(a,c,d){d[c]=b.createDiscussion(a)}),e.extend(a,{getDiscussion:function(){return f(f(this.getData()).discussions)[0]}})})},d.prototype.getMultiDiscussion=function(a){var b=this,c=[],f={};return e.forEach(a,function(a){a instanceof d.DiscussionRef&&(a=a.$getDiscussionUrl()),c.push(b.getDiscussion(a).then(function(b){f[a]=b}))}),Promise.all(c).then(function(){return f})},d.prototype.getPersonDiscussionRefs=function(a){var b=this;return b.plumbing.get(a,null,{Accept:"application/x-fs-v1+json"}).then(function(a){var c=a.getData();if(c.persons&&c.persons[0]&&e.isArray(c.persons[0]["discussion-references"]))for(var d=c.persons[0]["discussion-references"],g=0;g<d.length;g++)d[g]=b.createDiscussionRef(d[g]);return e.extend(a,{getDiscussionRefs:function(){return f(f(f(this.getData()).persons)[0])["discussion-references"]||[]}})})},d.prototype._commentsResponseMapper=function(a){var b=this,c=a.getData();if(c.discussions&&c.discussions[0]&&e.isArray(c.discussions[0].comments))for(var d=c.discussions[0].comments,g=0;g<d.length;g++)d[g]=b.createComment(d[g]);return e.extend(a,{getComments:function(){return f(f(f(this.getData()).discussions)[0]).comments||[]}})},d.prototype.getDiscussionComments=function(a){var b=this;return b.plumbing.get(a,null,{Accept:"application/x-fs-v1+json"}).then(function(a){return b._commentsResponseMapper(a)})},d.prototype.deleteDiscussion=function(a){return this.plumbing.del(a,{"Content-Type":"application/x-fs-v1+json"})},d.prototype.deleteDiscussionRef=function(a,b){var c={"Content-Type":"application/x-fs-v1+json"};return b&&(c["X-Reason"]=b),this.plumbing.del(a,c)},d.prototype.deleteComment=function(a){return this.plumbing.del(a)}},{"./../FamilySearch":6,"./../utils":58}],43:[function(a,b,c){var d=a("./../FamilySearch"),e=a("./../utils"),f=e.maybe;d.prototype._memoriesResponseMapper=function(a){var b=this,c=f(a.getData());e.forEach(c.sourceDescriptions,function(a,d){c.sourceDescriptions[d]=b.createMemory(a)})},d.prototype.getPersonMemoriesQuery=function(a,b){var c=this;return c.plumbing.get(a,b).then(function(a){return c._memoriesResponseMapper(a),e.extend(a,{getMemories:function(){return f(this.getData()).sourceDescriptions||[]}})})},d.prototype.getUserMemoriesQuery=function(a){var b=this;return b.plumbing.getCollectionUrl("FSMEM","artifacts").then(function(a){return b.plumbing.get(a,null,{"X-Expect-Override":"200-ok"})}).then(function(a){return a.getHeader("Location")}).then(function(c){return b.plumbing.get(c,a)}).then(function(a){return b._memoriesResponseMapper(a),e.extend(a,{getMemories:function(){return f(this.getData()).sourceDescriptions||[]}})})},d.prototype.getMemory=function(a){var b=this;return b.plumbing.get(a).then(function(a){return b._memoriesResponseMapper(a),e.extend(a,{getMemory:function(){return f(f(this.getData()).sourceDescriptions)[0]}})})},d.prototype.getMemoryComments=function(a){var b=this;return b.plumbing.get(a,null,{Accept:"application/x-fs-v1+json"}).then(function(a){return b._commentsResponseMapper(a),a})},d.prototype._memoryPersonasMapper=function(a){var b=this,c=f(a.getData());e.forEach(c.persons,function(a,d){e.forEach(a.media,function(c,d){a.media[d]=b.createMemoryArtifactRef(c)}),e.forEach(a.names,function(c,d){a.names[d]=b.createName(c)}),c.persons[d]=b.createMemoryPersona(a)})},d.prototype.getMemoryPersonas=function(a){var b=this;return b.plumbing.get(a).then(function(a){var c=f(a.getData());return b._memoryPersonasMapper(a),e.extend(a,{getMemoryPersonas:function(){return c.persons||[]}})})},d.prototype.getMemoryPersona=function(a){var b=this;return b.plumbing.get(a).then(function(a){var c=f(a.getData());return b._memoryPersonasMapper(a),e.extend(a,{getMemoryPersona:function(){return f(c.persons)[0]}})})},d.prototype.getMemoryPersonaRefs=function(a){var b=this;return b.plumbing.get(a).then(function(a){var c=f(a.getData());return e.forEach(c.persons,function(a){e.forEach(a.evidence,function(c,d){a.evidence[d]=b.createMemoryPersonaRef(c)})}),e.extend(a,{getMemoryPersonaRefs:function(){return f(f(c.persons)[0]).evidence||[]}})})},d.prototype.getPersonPortraitUrl=function(a,b){var c=this;return c.plumbing.get(a,b,{"X-Expect-Override":"200-ok"}).then(function(a){return a.getPortraitUrl=function(){return 204===a.getStatusCode()?"":c.helpers.appendAccessToken(a.getHeader("Location"))},a})},d.prototype.deleteMemory=function(a){return this.plumbing.del(a)},d.prototype.deleteMemoryPersona=function(a){return this.plumbing.del(a)},d.prototype.deleteMemoryPersonaRef=function(a){return this.plumbing.del(a)}},{"./../FamilySearch":6,"./../utils":58}],44:[function(a,b,c){function d(a){var b=a.getData();if(b){if(b.persons)return b.persons;if(b.childAndParentsRelationships)return b.childAndParentsRelationships;if(b.relationships)return b.relationships}return{}}var e=a("./../FamilySearch"),f=a("./../utils"),g=f.maybe;e.prototype.getNote=function(a,b){var c=this;return c.plumbing.get(a,b,{Accept:"application/x-fs-v1+json"}).then(function(a){var b=g(d(a)[0]).notes;return f.forEach(b,function(a,d){b[d]=c.createNote(a)}),f.extend(a,{getNote:function(){return g(g(d(this)[0]).notes)[0]}})})},e.prototype.getMultiNote=function(a){var b=this,c=[],d={};return f.forEach(a,function(a){c.push(b.getNote.call(b,a).then(function(b){return d[a]=b,b}))}),Promise.all(c).then(function(){return d})},e.prototype.getNotes=function(a){var b=this;return b.plumbing.get(a,null,{Accept:"application/x-fs-v1+json"}).then(function(a){var c=g(d(a)[0]).notes;return f.forEach(c,function(a,d){c[d]=b.createNote(a)}),f.extend(a,{getNotes:function(){return g(d(this)[0]).notes||[]}})})},e.prototype.deleteNote=function(a,b){var c=this,d={"Content-Type":"application/x-fs-v1+json"};return b&&(d["X-Reason"]=b),c.plumbing.del(a,d)},e.prototype._addNote=function(a,b,c){return b instanceof e.Note||(b=this.createNote(b)),b.save(a,c)}},{"./../FamilySearch":6,"./../utils":58}],45:[function(a,b,c){var d=a("./../FamilySearch");d.prototype.hasOrdinancesAccess=function(){return this.plumbing.get("/platform/ordinances/ordinances")},d.prototype.getOrdinancesPolicy=function(a,b){var c={Accept:"text/plain"};return"html"===a&&(c.Accept="text/html"),b&&(c["Accept-Language"]=b),this.plumbing.get("/platform/ordinances/policy",null,c)}},{"./../FamilySearch":6}],46:[function(a,b,c){var d=a("../FamilySearch"),e=a("../utils"),f=e.maybe,g={getRelationship:function(){return f(this.getData().childAndParentsRelationships)[0]},getPerson:function(a){return e.find(this.getData().persons,{id:a})}};d.prototype.getChildAndParents=function(a,b){var c=this;return c.plumbing.get(a,b,{Accept:"application/x-fs-v1+json"}).then(function(a){return e.forEach(a.getData().persons,function(a,b,d){d[b]=c.createPerson(a)}),e.forEach(a.getData().childAndParentsRelationships,function(a,b,d){d[b]=c.createChildAndParents(a)}),e.extend(a,g)})},d.prototype.deleteChildAndParents=function(a,b){var c=this,d={"Content-Type":"application/x-fs-v1+json"};return b&&(d["X-Reason"]=b),c.plumbing.del(a,d)},d.prototype.restoreChildAndParents=function(a){return this.plumbing.post(a,null,{"Content-Type":"application/x-fs-v1+json"})}},{"../FamilySearch":6,"../utils":58}],47:[function(a,b,c){function d(a){return{getPersons:function(){return h(this.getData()).persons},exists:function(b){return!!h(h(g.find(h(this.getData()).persons,e(a,b))).data).id},getPerson:function(b){return g.find(h(this.getData()).persons,e(a,b))}}}function e(a,b){return function(c){return c.getDisplay()[a]==b}}var f=a("./../FamilySearch"),g=a("./../utils"),h=g.maybe;f.prototype.getAncestry=function(a,b){var c=this;return c.plumbing.getCollectionUrl("FSFT","ancestry-query").then(function(d){return c.plumbing.get(d,g.extend({person:a},b))}).then(function(a){var f=h(a.getData());return g.forEach(f.persons,function(a,b,d){d[b]=c.createPerson(a)}),g.forEach(f.persons,function(a){a.getAscendancyNumber=function(){return this.data.display.ascendancyNumber}}),b&&b.descendants&&(g.forEach(f.persons,function(a){a.getDescendancyNumber=function(){return this.data.display.descendancyNumber}}),g.extend(a,{getDescendant:function(a){return g.find(f.persons,e("descendancyNumber",a))},existsDescendant:function(a){return!!h(g.find(f.persons,e("descendancyNumber",a))).id}})),g.extend(a,d("ascendancyNumber"))})},f.prototype.getDescendancy=function(a,b){var c=this;return Promise.resolve(c.helpers.getAPIServerUrl("/platform/tree/descendancy")).then(function(d){return c.plumbing.get(d,g.extend({person:a},b))}).then(function(a){var b=h(a.getData());return g.forEach(b.persons,function(a,b,d){d[b]=c.createPerson(a),d[b].getDescendancyNumber=function(){return this.data.display.descendancyNumber}}),g.extend(a,d("descendancyNumber"))})}},{"./../FamilySearch":6,"./../utils":58}],48:[function(a,b,c){var d=a("../FamilySearch"),e=a("../utils"),f=e.maybe;d.prototype.getPerson=function(a){var b=this,c=b.helpers.isAbsoluteUrl(a)?Promise.resolve(a):b.plumbing.getCollectionUrl("FSFT","person",{pid:a});return c.then(function(a){return b.plumbing.get(a)}).then(function(a){var c=a.getData().persons[0]=b.createPerson(a.getData().persons[0]);return c.isReadOnly=function(){var b=a.getHeader("Allow");return!!b&&b.indexOf("POST")<0},e.extend(a,{getPerson:function(){return c}})})},d.prototype.getMultiPerson=function(a){var b=[],c={},d=this;return e.forEach(a,function(a){b.push(d.getPerson(a).then(function(b){c[a]=b}))}),Promise.all(b).then(function(){return c})},d.prototype._personsAndRelationshipsMapper=function(a){var b=this;return e.forEach(a.getData().persons,function(a,c,d){d[c]=b.createPerson(a)}),e.forEach(a.getData().relationships,function(a,c,d){d[c]=b.createCouple(a)}),e.forEach(a.getData().childAndParentsRelationships,function(a,c,d){d[c]=b.createChildAndParents(a)}),e.extend(a,{getCoupleRelationships:function(){return e.filter(f(this.getData()).relationships,function(a){return"http://gedcomx.org/Couple"===a.data.type})||[]},getChildAndParentsRelationships:function(){return f(this.getData()).childAndParentsRelationships||[]},getPerson:function(a){return e.find(this.getData().persons,function(b){return b.getId()===a})}})},d.prototype.getPersonWithRelationships=function(a,b){var c=this;return c.plumbing.getCollectionUrl("FSFT","person-with-relationships").then(function(d){return c.plumbing.get(d,e.extend({person:a},b))}).then(function(b){return b=c._personsAndRelationshipsMapper(b),b.getData().persons[0].isReadOnly=function(){var a=b.getHeader("Allow");return!!a&&a.indexOf("POST")<0},e.extend(b,{getRequestedId:function(){return a},getPrimaryId:function(){var a=this.getData().description.substring(1),b=e.find(this.getData().sourceDescriptions,function(b){return b.id===a});if(b)return b.about.substring(1)},getPerson:function(a){return e.find(this.getData().persons,function(b){return b.getId()===a})},getPrimaryPerson:function(){return this.getPerson(this.getPrimaryId())},getParentRelationships:function(){var a=this.getPrimaryId();return e.filter(this.getData().childAndParentsRelationships,function(b){return b.getChildId()===a})},getSpouseRelationships:function(){return e.filter(this.getData().relationships,function(a){return"http://gedcomx.org/Couple"===a.data.type})},getSpouseRelationship:function(a){var b=this.getPrimaryId();return e.find(this.getData().relationships,function(c){return"http://gedcomx.org/Couple"===c.data.type&&(b===c.getHusbandId()?c.getWifeId():c.getHusbandId())===a})},getChildRelationships:function(){var a=this.getPrimaryId();return e.filter(this.getData().childAndParentsRelationships,function(b){return b.getFatherId()===a||b.getMotherId()===a})},getChildRelationshipsOf:function(a){var b=this.getPrimaryId();return e.filter(this.getData().childAndParentsRelationships,function(c){return!(c.getFatherId()!==b&&c.getMotherId()!==b||c.getFatherId()!=a&&c.getMotherId()!=a)})},getFatherIds:function(){return e.uniq(e.map(e.filter(this.getParentRelationships(),function(a){return!!a.getFatherId()}),function(a){return a.getFatherId()},this))},getFathers:function(){return e.map(this.getFatherIds(),this.getPerson,this)},getMotherIds:function(){return e.uniq(e.map(e.filter(this.getParentRelationships(),function(a){return!!a.getMotherId()}),function(a){return a.getMotherId()},this))},getMothers:function(){return e.map(this.getMotherIds(),this.getPerson,this)},getSpouseIds:function(){return e.uniq(e.map(e.filter(this.getSpouseRelationships(),function(a){return a.getHusbandId()&&a.getWifeId()}),function(a){return this.getPrimaryId()===a.getHusbandId()?a.getWifeId():a.getHusbandId()},this))},getSpouses:function(){return e.map(this.getSpouseIds(),this.getPerson,this)},getChildIds:function(){return e.uniq(e.map(this.getChildRelationships(),function(a){return a.getChildId()},this))},getChildren:function(){return e.map(this.getChildIds(),this.getPerson,this)},getChildIdsOf:function(a){return e.uniq(e.map(this.getChildRelationshipsOf(a),function(a){return a.getChildId()},this))},getChildrenOf:function(a){return e.map(this.getChildIdsOf(a),this.getPerson,this)},wasRedirected:function(){return this.getPrimaryId()!==this.getRequestedId()}})})},d.prototype.deletePerson=function(a,b){var c=this,d=c.helpers.isAbsoluteUrl(a)?Promise.resolve(a):c.plumbing.getCollectionUrl("FSFT","person",{
pid:a});return d.then(function(a){return c.plumbing.del(a,b?{"X-Reason":b}:{})})},d.prototype.getPreferredSpouse=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.get(a+".json",null,{"X-Expect-Override":"200-ok"})}).then(function(a){return a.getPreferredSpouse=function(){if(200===a.getStatusCode()){var b=a.getHeader("Location");return b.indexOf("child-and-parents-relationships")>=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":6,"../utils":58}],49:[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":6,"./../utils":58}],50:[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,b){var c=this;return c.plumbing.get(a,b,{Accept:"application/x-gedcomx-atom+json"}).then(function(a){return c._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":6,"./../utils":58}],51:[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.getId():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.getId():a});return b.plumbing.del(b.helpers.appendQueryParameters(c,{id:f}))})},d.prototype.deleteCollection=function(a){return this.plumbing.del(a)}},{"./../FamilySearch":6,"./../utils":58}],52:[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<c.length;d++)c[d]=b.createSourceDescription(c[d]);return e.extend(a,{getSourceDescription:function(){return c[0]}})})},d.prototype.getMultiSourceDescription=function(a){var b=this,c=[],d={};return e.forEach(a,function(a){c.push(b.getSourceDescription(a).then(function(b){d[a]=b}))}),Promise.all(c).then(function(){return d})},d.prototype._getSourceRefsQueryResponseMapper=function(a,b){var c=this,d=f(a.getData());return b&&(e.forEach(d.sourceDescriptions,function(a,b,d){d[b]=c.createSourceDescription(a)}),e.extend(a,{getSourceDescriptions:function(){return d.sourceDescriptions||[]},getSourceDescription:function(a){return e.find(d.sourceDescriptions,function(b){return b.getId()===a})},getPersonIds:function(){return e.map(d.persons,function(a){return a.id})},getCoupleIds:function(){return e.map(d.relationships,function(a){return a.id})},getChildAndParentsIds:function(){return e.map(d.childAndParentsRelationships,function(a){return a.id})}})),e.forEach(["persons","relationships","childAndParentsRelationships"],function(a){var b="persons"===a?"person":"relationship";d[a]=e.map(d[a],function(a){var d=a.id,g=f(f(a.links)[b]).href;return a.sources=e.map(a.sources,function(a){var b=c.createSourceRef(a);return b.setAttachedEntityId(d),b.setAttachedEntityUrl(g),b}),a})}),e.extend(a,{getPersonSourceRefs:function(){return e.flatMap(f(d.persons),function(a){return a.sources})},getCoupleSourceRefs:function(){return e.flatMap(f(d.relationships),function(a){return a.sources})},getChildAndParentsSourceRefs:function(){return e.flatMap(f(d.childAndParentsRelationships),function(a){return a.sources})}})},d.prototype.getSourceRefsQuery=function(a){var b=this;return b.plumbing.get(a,null,{Accept:"application/x-fs-v1+json"}).then(function(a){return b._getSourceRefsQueryResponseMapper(a,!1),a})},d.prototype.getSourceAttachments=function(a){var b=this,c={source:a},d={"X-FS-Feature-Tag":"local-source-description-references"};return this.get("/platform/tree/source-references",c,d).then(function(a){return b._getSourceRefsQueryResponseMapper(a,!0),a})},d.prototype._getSourcesResponseMapper=function(a,b,c){var d=this,g=f(a.getData());c&&(e.forEach(g.sourceDescriptions,function(a,b,c){c[b]=d.createSourceDescription(a)}),e.extend(a,{getSourceDescriptions:function(){return g.sourceDescriptions||[]},getSourceDescription:function(a){return e.find(g.sourceDescriptions,function(b){return b.getId()===a})}}));var h=f(f(g[b])[0]),i=h.sources;if(i){var j="persons"===b?"person":"relationship",k=h.id,l=f(f(f(h).links)[j]).href;e.forEach(f(f(g[b])[0]).sources,function(b,c,e){var f=d.createSourceRef(b);"#"===b.description.charAt(0)&&f.setSourceDescription(a.getSourceDescription(b.description.substr(1))),f.setAttachedEntityId(k),f.setAttachedEntityUrl(l),e[c]=f})}return e.extend(a,{getSourceRefs:function(){return f(f(g[b])[0]).sources||[]}})},d.prototype.getSourceRefs=function(a){var b=this;return b.plumbing.get(a,null,{Accept:"application/x-fs-v1+json"}).then(function(c){return b._getSourcesResponseMapper(c,b.helpers.getEntityType(a),!1),c})},d.prototype.getSourcesQuery=function(a){var b=this;return b.plumbing.get(a,null,{Accept:"application/x-fs-v1+json"}).then(function(c){return b._getSourcesResponseMapper(c,b.helpers.getEntityType(a),!0),c})},d.prototype.deleteSourceDescription=function(a,b){return this.plumbing.del(a,b?{"X-Reason":b}:{})},d.prototype.deleteSourceRef=function(a,b){return this.plumbing.del(a,b?{"X-Reason":b}:{})},d.prototype._createAndAttachSource=function(a,b,c,e){var f=this;b instanceof d.SourceDescription||(b=f.createSourceDescription(b));var g=new Promise(function(a,c){b.getId()?a(b):b.save().then(function(){a(b)},function(a){c(a)})});return g.then(function(b){var d=f.createSourceRef({sourceDescription:b});return e&&d.setTags(e),d.save(a,c)})}},{"./../FamilySearch":6,"./../utils":58}],53:[function(a,b,c){var d=a("../FamilySearch"),e=a("../utils"),f=e.maybe,g={getRelationship:function(){return f(this.getData().relationships)[0]},getPerson:function(a){return e.find(this.getData().persons,function(b){return b.getId()===a})}};d.prototype.getCouple=function(a,b){var c=this;return c.plumbing.get(a,b).then(function(a){return e.forEach(f(a.getData()).persons,function(a,b,d){d[b]=c.createPerson(a)}),e.forEach(f(a.getData()).relationships,function(a,b,d){d[b]=c.createCouple(a)}),e.extend(a,g)})},d.prototype.deleteCouple=function(a,b){return this.plumbing.del(a,b?{"X-Reason":b}:{})},d.prototype.restoreCouple=function(a){return this.plumbing.post(a,null,{"Content-Type":"application/x-fs-v1+json"})}},{"../FamilySearch":6,"../utils":58}],54:[function(a,b,c){var d=a("./../FamilySearch"),e=a("./../utils"),f=e.maybe;d.prototype.getCurrentUser=function(){var a=this;return a.plumbing.getCollectionUrl("FSFT","current-user").then(function(b){return a.plumbing.get(b)}).then(function(b){return e.forEach(b.getData().users,function(b,c,d){d[c]=a.createUser(b)}),b.getUser=function(){return f(b.getData().users)[0]},b})},d.prototype.getAgent=function(a){var b=this;return b.plumbing.get(a).then(function(a){return e.forEach(a.getData().agents,function(a,c,d){d[c]=b.createAgent(a)}),e.extend(a,{getAgent:function(){return f(a.getData().agents)[0]}})})},d.prototype.getMultiAgent=function(a,b){var c=this,d=[],f={};return e.forEach(a,function(a){d.push(c.getAgent(a,b).then(function(b){f[a]=b}))}),Promise.all(d).then(function(){return f})},d.prototype.getCurrentUserPerson=function(){var a=this;return a.plumbing.getCollectionUrl("FSFT","current-user-person").then(function(b){return a.plumbing.get(b,null,{"X-Expect-Override":"200-ok"})}).then(function(a){return a.getHeader("Location")}).then(function(b){return a.getPerson(b)})}},{"./../FamilySearch":6,"./../utils":58}],55:[function(a,b,c){var d=a("./../FamilySearch");d.prototype.getRedirectUrl=function(a){return this.helpers.appendAccessToken(this.helpers.appendQueryParameters(this.helpers.getAPIServerUrl("/platform/redirect"),a))},d.prototype.getPendingModifications=function(){return this.plumbing.get("/platform/pending-modifications").then(function(a){return a.getPendingModifications=function(){return a.getData().features},a})}},{"./../FamilySearch":6}],56:[function(a,b,c){function d(a){var b,c,e,f,g,h,i,j="";for(b in a)if(a.hasOwnProperty(b))if(c=a[b],c instanceof Array)for(i=0;i<c.length;++i)g=c[i],e=b+"["+i+"]",h={},h[e]=g,j+=d(h)+"&";else if(c instanceof Object)for(f in c)c.hasOwnProperty(f)&&(g=c[f],e=b+"["+f+"]",h={},h[e]=g,j+=d(h)+"&");else void 0!==c&&null!==c&&(j+=encodeURIComponent(b)+"="+encodeURIComponent(c)+"&");return j.length?j.substr(0,j.length-1):j}a("es6-promise").polyfill(),a("isomorphic-fetch");var e=a("./utils"),f=function(a){this.client=a,this.helpers=a.helpers,this.settings=a.settings,this.totalProcessingTime=0};f.prototype.getTotalProcessingTime=function(){return this.totalProcessingTime},f.prototype.setTotalProcessingTime=function(a){this.totalProcessingTime=a},f.prototype.getCollectionUrl=function(a,b,c){var d=this;return d.getCollectionPromise(a).then(function(a){return d.helpers.getUrlFromCollection(a.getData().collections[0],b,c)})},f.prototype.getCollectionPromise=function(a){var b=this;return b.settings.collectionsPromises[a]?b.settings.collectionsPromises[a]:b.settings.collectionsPromises.collections.then(function(c){for(var d=c.getData().collections,e=0;e<d.length;e++)if(d[e].id===a)return b.settings.collectionsPromises[a]=b.get(d[e].links.self.href),b.settings.collectionsPromises[a];return Promise.reject(new Error("Collection "+a+" does not exist"))})},f.prototype.get=function(a,b,c){return this.http("GET",this.helpers.appendQueryParameters(a,b),e.extend({Accept:"application/x-gedcomx-v1+json"},c))},f.prototype.post=function(a,b,c){return this.http("POST",a,e.extend({"Content-Type":"application/x-gedcomx-v1+json"},c),b)},f.prototype.put=function(a,b,c){return this.http("PUT",a,e.extend({"Content-Type":"application/x-gedcomx-v1+json"},c),b)},f.prototype.del=function(a,b){return this.http("DELETE",a,e.extend({"Content-Type":"application/x-gedcomx-v1+json"},b))},f.prototype.transformData=function(a,b){if(a&&e.isObject(a)&&"[object FormData]"!==String(a)){if("application/x-www-form-urlencoded"===b)return d(a);if(b&&b.indexOf("json")!==-1)return JSON.stringify(a)}return a},f.prototype.http=function(a,b,c,d,e){var f=this,g=this.helpers.getAPIServerUrl(b);c=c||{};var h;return h=this.settings.accessToken||!this.settings.autoSignin||this.helpers.isOAuthServerUrl(g)||b.indexOf("/platform/collections")!==-1?Promise.resolve(this.settings.accessToken):this.client.getAccessToken(),h.then(function(){var b=f.helpers.isAuthoritiesServerUrl(g)?"sessionId":"access_token";if(f.settings.accessToken&&g.indexOf(b+"=")===-1){var h={};h[b]=f.settings.accessToken,g=f.helpers.appendQueryParameters(g,h)}null==e&&(e=f.settings.maxHttpRequestRetries),f.settings.pendingModifications&&(c["X-FS-Feature-Tag"]=f.settings.pendingModifications);var i=f.transformData(d,c["Content-Type"]);return f._http(a,g,c,i,e).then(function(a){return a.json().then(function(b){return a.data=b,a},function(){return 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:i}}}})})},f.prototype._http=function(a,b,c,d,e){var f=this;return fetch(b,{method:a,headers:c,body:d}).then(function(a){return 401===a.status&&f.helpers.eraseAccessToken(),a}).then(function(g){if("GET"===a&&e>0&&(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":58,"es6-promise":3,"isomorphic-fetch":4}],57:[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":6,"./utils":58}],58:[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;d<e;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 a.indexOf(b)!==-1;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;c<d;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;h<i;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;h<i;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}},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(" ")}},{}]},{},[6])(6)});