'undefined'==typeof window||window.solid||(window.solid={}),function e(t,n){'object'==typeof exports&&'object'==typeof module?module.exports=n(require('window'),require('solid-auth-client')):'function'==typeof define&&define.amd?define(['window'],n):'object'==typeof exports?exports.$rdf=n(require('window'),require('solid-auth-client')):t.$rdf=n(t.window,t.solid.auth)}(window,function(e,t){var n=Math.pow,a=Math.floor,r=String.fromCharCode,o=Math.abs;return function(e){function t(a){if(n[a])return n[a].exports;var r=n[a]={i:a,l:!1,exports:{}};return e[a].call(r.exports,r,r.exports,t),r.l=!0,r.exports}var n={};return t.m=e,t.c=n,t.d=function(e,n,a){t.o(e,n)||Object.defineProperty(e,n,{enumerable:!0,get:a})},t.r=function(e){'undefined'!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:'Module'}),Object.defineProperty(e,'__esModule',{value:!0})},t.t=function(e,n){if(1&n&&(e=t(e)),8&n)return e;if(4&n&&'object'==typeof e&&e&&e.__esModule)return e;var a=Object.create(null);if(t.r(a),Object.defineProperty(a,'default',{enumerable:!0,value:e}),2&n&&'string'!=typeof e)for(var r in e)t.d(a,r,function(t){return e[t]}.bind(null,r));return a},t.n=function(e){var n=e&&e.__esModule?function t(){return e['default']}:function t(){return e};return t.d(n,'a',n),n},t.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},t.p='',t(t.s=59)}([function(e,t,n){'use strict';function a(e){return a='function'==typeof Symbol&&'symbol'==typeof Symbol.iterator?function e(t){return typeof t}:function e(t){return t&&'function'==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?'symbol':typeof t},a(e)}function r(e,t){if(!(e instanceof t))throw new TypeError('Cannot call a class as a function')}function o(e,t){for(var n=0,a;na?null:new t(n.slice(0,a+1))}},{key:'site',value:function e(){var n=this.uri.split('#')[0],a=n.indexOf('//');if(0>a)throw new Error('This URI does not have a web site part (origin)');var r=n.indexOf('/',a+2);if(0>r)throw new Error('This URI does not have a web site part. (origin)');return new t(n.slice(0,r+1))}},{key:'doc',value:function e(){return 0>this.uri.indexOf('#')?this:new t(this.uri.split('#')[0])}},{key:'toString',value:function e(){return'<'+this.uri+'>'}},{key:'uri',get:function e(){return this.value},set:function e(t){this.value=t}}],[{key:'fromValue',value:function e(n){if('undefined'==typeof n||null===n)return n;var a=n&&n.termType;return a?n:new t(n)}}]),t}(h);f.termType='NamedNode',f.prototype.classOrder=c.NamedNode,f.prototype.isVar=0,e.exports=f},function(e,t,n){'use strict';function a(e,t){if(!(e instanceof t))throw new TypeError('Cannot call a class as a function')}function r(e,t){for(var n=0,a;nt.classOrder?1:this.valuet.value?1:0}},{key:'equals',value:function e(t){return!!t&&this.termType===t.termType&&this.value===t.value}},{key:'hashString',value:function e(){return this.toCanonical()}},{key:'sameTerm',value:function e(t){return this.equals(t)}},{key:'toCanonical',value:function e(){return this.toNT()}},{key:'toNT',value:function e(){return this.toString()}},{key:'toString',value:function e(){throw new Error('Node.toString() is abstract - see the subclasses instead')}}]),e}();e.exports=i,i.fromValue=function e(t){var a=n(17),r=n(11),o=n(0);if('undefined'==typeof t||null===t)return t;var i=t&&t.termType;return i?t:Array.isArray(t)?new a(t):r.fromValue(t)},i.toJS=function e(t){return t.elements?t.elements.map(i.toJS):t.datatype?t.datatype.equals(ns.xsd('boolean'))?'1'===t.value:t.datatype.equals(ns.xsd('dateTime'))||t.datatype.equals(ns.xsd('date'))?new Date(t.value):t.datatype.equals(ns.xsd('integer'))||t.datatype.equals(ns.xsd('float'))||t.datatype.equals(ns.xsd('decimal'))?+t.value:t.value:t}},function(e,t,n){function a(e){var t;return t=e.indexOf('#'),0>t?e:e.slice(0,t)}function r(e){return new p(a(e.uri))}function o(e){var t=/[^\/]*\/\/([^\/]*)\//.exec(e);return t?t[1]:''}function i(e,t){var n=t.indexOf('#'),a,r,o,i,s,d;if(0a)return l('Invalid base: '+t+' in join with given: '+e),e;if(r=t.slice(0,+a+1||9e9),0===e.indexOf('//'))return r+e;if(t.indexOf('//',a)===a+1){if(o=t.indexOf('/',a+3),0>o)return 0o)return 0s)return r+e;for(0<=s&&st?null:e.slice(0,t)}function d(e,t){var a=/^[-_a-zA-Z0-9.]+:(\/\/[^\/]*)?\/[^\/]*$/,r,d,i,u,l,c,h,n,o,p,f,g,m;if(!e)return t;if(e===t)return'';for(d=n=0,l=t.length;ni&&(i=-2),u=t.indexOf('/',i+2),'/'!==t[u+1]&&'/'!==e[u+1]&&t.slice(0,u)===e.slice(0,u)))return t.slice(u);if('#'===t[d]&&e.length===d)return t.slice(d);for(;0d)return t;if(0=g;1<=g?++p:--p)m+='../';return m+t.slice(d)}var l=l||console.log;e.exports.docpart=a,e.exports.document=r,e.exports.hostpart=o,e.exports.join=i,e.exports.protocol=s,e.exports.refTo=d;var p=n(0)},function(e,t){var n;n=function(){return this}();try{n=n||Function('return this')()||(1,eval)('this')}catch(t){'object'==typeof window&&(n=window)}e.exports=n},function(e,t,n){(function(e){function t(e,t,n){var a=null;if('undefined'!=typeof e.fetcher)a=e.fetcher;else return;if('NamedNode'===t.termType){var r=y(t.uri),o;if(0>t.uri.indexOf('#')){if(f(t.uri,'http://dbpedia.org/resource/Category:'))return;f(t.uri,'http://purl.org/dc/elements/1.1/')||f(t.uri,'http://purl.org/dc/terms/')?o='http://dublincore.org/2005/06/13/dcq':f(t.uri,'http://xmlns.com/wot/0.1/')?o='http://xmlns.com/wot/0.1/index.rdf':f(t.uri,'http://web.resource.org/cc/')&&(o='http://web.resource.org/cc/schema.rdf')}return(o&&(r=o),!(a&&'unrequested'!==a.getState(r)))?(o&&b.warn('Assuming server still broken, faking redirect of <'+t.uri+'> to <'+r+'>'),a.fetch(r,{referringTerm:n})):void 0}}function a(e,t,n){n||(n=0);var a=e.length;for(0>n&&(n=a+n);n/g,'>').replace(/'/g,'"')+'\'')}}if(0\n':''}}}else if(8===e.nodeType)r+='';else if(3===e.nodeType||4===e.nodeType){var c=e.nodeValue.replace(/\n+$/,'');r+=o[o.length-1]?c:c.replace(/&/g,'&').replace(//g,'>')}else console.log('Warning; Cannot handle serialising nodes of type: '+e.nodeType),console.log(e);return r}function d(){var e=new Date,t=e.getYear()+1900,n=e.getMonth()+1,a=e.getDate(),r=e.getUTCHours(),o=e.getUTCMinutes(),i=e.getSeconds();return 10>n&&(n='0'+n),10>a&&(a='0'+a),10>r&&(r='0'+r),10>o&&(o='0'+o),10>i&&(i='0'+i),t+'-'+n+'-'+a+'T'+r+':'+o+':'+i+'Z'}function l(e,t,n,a){var r=function e(t){return'BlankNode'===t.termType?null:t},o=function e(t){var a=n.statementsMatching(t).map(function(e){return''+r(e.subject)+' '+r(e.predicate)+' '+r(e.object)}).concat(n.statementsMatching(void 0,void 0,t).map(function(e){return''+r(e.subject)+' '+r(e.predicate)+' '+r(e.object)}));return a.sort(),a.join('\n')};return'BlankNode'===e.termType&&'BlankNode'===t.termType?0===e.compareTerm(t)?0:o(e)>o(t)?1:o(e)t.classOrder?1:this.idt.id?1:0}},{key:'copy',value:function e(n){var a=new t;return n.copyTo(this,a),a}},{key:'toCanonical',value:function e(){return'_:'+this.value}},{key:'toString',value:function e(){return t.NTAnonymousNodePrefix+this.id}}]),t}(h);f.nextId=0,f.termType='BlankNode',f.NTAnonymousNodePrefix='_:',f.prototype.classOrder=c.BlankNode,f.prototype.isBlank=1,f.prototype.isVar=1,e.exports=f},function(e,t){e.exports='function'==typeof Object.create?function e(t,n){t.super_=n,t.prototype=Object.create(n.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}})}:function e(t,n){t.super_=n;var a=function(){};a.prototype=n.prototype,t.prototype=new a,t.prototype.constructor=t}},function(e,t,n){'use strict';function a(e){return this instanceof a?void(l.call(this,e),p.call(this,e),e&&!1===e.readable&&(this.readable=!1),e&&!1===e.writable&&(this.writable=!1),this.allowHalfOpen=!0,e&&!1===e.allowHalfOpen&&(this.allowHalfOpen=!1),this.once('end',r)):new a(e)}function r(){this.allowHalfOpen||this._writableState.ended||i.nextTick(o,this)}function o(e){e.end()}var i=n(18),s=Object.keys||function(e){var t=[];for(var n in e)t.push(n);return t};e.exports=a;var d=n(14);d.inherits=n(7);var l=n(46),p=n(30);d.inherits(a,l);for(var u=s(p.prototype),c=0,h;ca.indexOf('e')&&o(n)<=Number.MAX_SAFE_INTEGER?Number.isInteger(n)?m.integer:m.decimal:m.double,new t(a,null,r)}},{key:'fromValue',value:function e(n){if('undefined'==typeof n||null===n)return n;if('object'===a(n)&&n.termType)return n;switch(a(n)){case'object':if(n instanceof Date)return t.fromDate(n);case'boolean':return t.fromBoolean(n);case'number':return t.fromNumber(n);case'string':return new t(n);}throw new Error('Can\'t make literal from '+n+' of type '+a(n))}}]),t}(g);y.termType='Literal',y.prototype.classOrder=h.Literal,y.prototype.datatype=m.string,y.prototype.lang='',y.prototype.isVar=0,e.exports=y},function(e,t){},function(e,t,n){(function(e){function a(e,t){this._id=e,this._clearFn=t}var r='undefined'!=typeof e&&e||'undefined'!=typeof self&&self||window,o=Function.prototype.apply;t.setTimeout=function(){return new a(o.call(setTimeout,r,arguments),clearTimeout)},t.setInterval=function(){return new a(o.call(setInterval,r,arguments),clearInterval)},t.clearTimeout=t.clearInterval=function(e){e&&e.close()},a.prototype.unref=a.prototype.ref=function(){},a.prototype.close=function(){this._clearFn.call(r,this._id)},t.enroll=function(e,t){clearTimeout(e._idleTimeoutId),e._idleTimeout=t},t.unenroll=function(e){clearTimeout(e._idleTimeoutId),e._idleTimeout=-1},t._unrefActive=t.active=function(e){clearTimeout(e._idleTimeoutId);var t=e._idleTimeout;0<=t&&(e._idleTimeoutId=setTimeout(function t(){e._onTimeout&&e._onTimeout()},t))},n(62),t.setImmediate='undefined'!=typeof self&&self.setImmediate||'undefined'!=typeof e&&e.setImmediate||this&&this.setImmediate,t.clearImmediate='undefined'!=typeof self&&self.clearImmediate||'undefined'!=typeof e&&e.clearImmediate||this&&this.clearImmediate}).call(this,n(3))},function(e,t,n){(function(e){function n(e){return Array.isArray?Array.isArray(e):'[object Array]'===m(e)}function a(e){return'boolean'==typeof e}function r(e){return null===e}function o(e){return null==e}function i(e){return'number'==typeof e}function s(e){return'string'==typeof e}function d(e){return'symbol'==typeof e}function l(e){return void 0===e}function p(e){return'[object RegExp]'===m(e)}function u(e){return'object'==typeof e&&null!==e}function c(e){return'[object Date]'===m(e)}function h(t){return'[object Error]'===m(t)||t instanceof Error}function f(e){return'function'==typeof e}function g(e){return null===e||'boolean'==typeof e||'number'==typeof e||'string'==typeof e||'symbol'==typeof e||'undefined'==typeof e}function m(e){return Object.prototype.toString.call(e)}t.isArray=n,t.isBoolean=a,t.isNull=r,t.isNullOrUndefined=o,t.isNumber=i,t.isString=s,t.isSymbol=d,t.isUndefined=l,t.isRegExp=p,t.isObject=u,t.isDate=c,t.isError=h,t.isFunction=f,t.isPrimitive=g,t.isBuffer=e.isBuffer}).call(this,n(49).Buffer)},function(e,t,n){function a(e){return a='function'==typeof Symbol&&'symbol'==typeof Symbol.iterator?function e(t){return typeof t}:function e(t){return t&&'function'==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?'symbol':typeof t},a(e)}function r(e,t){if(!(e instanceof t))throw new TypeError('Cannot call a class as a function')}function o(e,t){for(var n=0,a;n']=[f],0<=g(t,'sameAs')&&(this.propertyActions['']=[function(e,t,n,a,r){return e.equate(t,a),!0}]),0<=g(t,'InverseFunctionalProperty')&&(this.classActions['<'+v+'InverseFunctionalProperty>']=[function(e,t,n,a,r){return e.newPropertyAction(t,h)}]),0<=g(t,'FunctionalProperty')&&(this.classActions['<'+v+'FunctionalProperty>']=[function(e,t,n,a,r){return e.newPropertyAction(t,c)}])}},{key:'add',value:function e(n,a,r,o){var s;if(1===arguments.length){if(n instanceof Array)for(s=0;ss;s++){var c=this.index[s],f=u[s];c[f]||(c[f]=[]),c[f].push(d)}return this.statements.push(d),d}},{key:'addAll',value:function e(t){var n=this;t.forEach(function(e){n.add(e.subject,e.predicate,e.object,e.graph)})}},{key:'any',value:function e(t,n,a,r){var o=this.anyStatementMatching(t,n,a,r);if(null!=o)return null==t?o.subject:null==n?o.predicate:null==a?o.object:void 0}},{key:'anyValue',value:function e(t,n,a,r){var o=this.any(t,n,a,r);return o?o.value:void 0}},{key:'anyStatementMatching',value:function e(t,n,a,r){var o=this.statementsMatching(t,n,a,r,!0);return o&&0!==o.length?o[0]:void 0}},{key:'canon',value:function e(t){if(!t)return t;var n=this.redirections[t.hashString()];return n?n:t}},{key:'check',value:function e(){this.checkStatementList(this.statements);for(var t=0,n;4>t;t++)for(var a in n=this.index[t],n)n.hasOwnProperty(a)&&this.checkStatementList(n[a],t)}},{key:'checkStatementList',value:function e(t,n){for(var a=['subject','predicate','object','why'],r=' found in '+a[n]+' index.',o=0,i;ol;l++){var p=this.canon(s[l]),u=p.hashString();this.index[l][u]&&d(this.index[l][u],i)}if(!d(this.statements,i))throw new Error('Statement list does not statement '+i+'@'+i.why+r)}}},{key:'close',value:function e(){return this}},{key:'copyTo',value:function e(t,n,a){a||(a=[]);var r=this.statementsMatching(t);-1!==g(a,'two-direction')&&r.concat(this.statementsMatching(void 0,void 0,t));for(var o=0,i;oa?this.replaceWith(n,t):this.replaceWith(t,n))}},{key:'formula',value:function e(n){return new t(n)}},{key:'match',value:function e(t,n,a,r){return this.statementsMatching(x.fromValue(t),x.fromValue(n),x.fromValue(a),x.fromValue(r))}},{key:'mentionsURI',value:function e(t){var n='<'+t+'>';return!!this.subjectIndex[n]||!!this.objectIndex[n]||!!this.predicateIndex[n]}},{key:'newExistential',value:function e(t){if(!t)return this.bnode();var n=this.sym(t);return this.declareExistential(n)}},{key:'newPropertyAction',value:function e(t,n){var a=t.hashString();this.propertyActions[a]||(this.propertyActions[a]=[]),this.propertyActions[a].push(n);for(var r=this.statementsMatching(void 0,t,void 0),o=!1,s=0;sa;a++){var r=this.canon(n[a]),o=r.hashString();this.index[a][o]&&y(this.index[a][o],t)}return y(this.statements,t),this}},{key:'removeStatements',value:function e(t){for(var n=0;ns;s++)o(this.index[s]);if(this.redirections[a]=n,t.uri){if(this.aliases[r]||(this.aliases[r]=[]),this.aliases[r].push(t),this.aliases[a])for(s=0;sh;h++)d[h]=this.canon(x.fromValue(s[h])),d[h]?(c.push(h),l[h]=d[h].hashString()):u.push(h);if(0===c.length)return this.statements;if(1===c.length)return h=c[0],p=this.index[h][l[h]],p&&o&&1 '+t[a]);return n},i=function e(t){var a='Bindings: ',r=t.length,n;for(n=0;ne)return this.originalCallback(t);for(n=0;nd;d++){var p=o[d];if(p.uri&&p.uri===l);else if(p.isVar&&void 0===r[p])a.nvars++;else{if(p=c(o[d],r),n.redirections[p.hashString()]&&(p=n.redirections[p.hashString()]),s=i[d][p.hashString()],!s)return a.index=[],!1;(null===a.index||a.index.length>s.length)&&(a.index=s)}}return null===a.index&&(a.index=n.statements),!0},x=0,_=function e(a,r,l,p,u,c,h){s.debug('Match begins, Branch count now: '+h.count+' for '+h.pattern_debug);var f=a.fetcher?a.fetcher:null,g=r.statements;if(0===g.length){if(s.debug('FOUND MATCH WITH BINDINGS:'+o(l)),0===r.optional.length)h.reportMatch(l);else{s.debug('OPTIONAL: '+r.optional);var _=new m(t,l),w=[],k;for(k=0;k in query: '+o),e(a,r,l,p,u,c,h)})};for(T=0;T: Bad syntax: '+r+'\nat: "'+w(n,a,a+30)+'"'}function u(e){var t='',n=new T(e);try{for(;!0;){var a=n.next();if('\r'!=a)var t=t+a}}catch(t){if(t!=k)throw t}return t}function c(e){}var h=String.prototype,f={encode:function e(t){t=t.replace(/\r\n/g,'\n');for(var a='',o=0,n;on?a+=r(n):127n?(a+=r(192|n>>6),a+=r(128|63&n)):(a+=r(224|n>>12),a+=r(128|63&n>>6),a+=r(128|63&n));return a},decode:function e(t){for(var n='',a=0,o;ao?(n+=r(o),a++):191o?(n+=r((31&o)<<6|63&t.charCodeAt(a+1)),a+=2):(n+=r((15&o)<<12|(63&t.charCodeAt(a+1))<<6|63&t.charCodeAt(a+2)),a+=3);return n}},g='http://www.w3.org/2000/10/swap/log#forSome',m='http://www.w3.org/2000/10/swap/log#forAll',y='http://www.w3.org/2000/10/swap/log#',b=function e(t){return t},_=function e(t){return t},x=function e(t){if(0?@[\\]^`{|}~',W=X+':',J='http://www.w3.org/1999/02/22-rdf-syntax-ns#',Y='#',Q=/^[ \t]*(#[^\n]*)?\r?\n/g,G=/^[ \t]*(#[^\n]*)?$/g,K=/^[ \t]*/g,Z=/^[-+]?[0-9]+/g,ee=/^([-+]?[0-9]+)(\.[0-9]+)?(e[-+]?[0-9]+)?/g,te=/^[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9](T[0-9][0-9]:[0-9][0-9](:[0-9][0-9](\.[0-9]*)?)?)?Z?/,ne=/^[0-9]+/g,ae=/[\\\r\n\"]/g,re=/^[a-zA-Z0-9]+(-[a-zA-Z0-9]+)*/g;return i.prototype.here=function(e){return this._genPrefix+'_L'+this.lines+'C'+(e-this.startOfLine+1)},i.prototype.formula=function(){return this._formula},i.prototype.loadStream=function(e){return this.loadBuf(e.read())},i.prototype.loadBuf=function(e){return this.startDoc(),this.feed(e),this.endDoc()},i.prototype.feed=function(e){for(var t=e.decode('utf-8'),n=0,a;0<=n;){if(a=this.skipSpace(t,n),0>a)return;var n=this.directiveOrStatement(t,a);if(0>n)throw p(this._thisDoc,this.lines,t,a,'expected directive or statement')}},i.prototype.directiveOrStatement=function(e,t){var n=this.skipSpace(e,t);if(0>n)return n;var a=this.directive(e,n);if(0<=a)return this.checkDot(e,a);var a=this.statement(e,n);return 0<=a?this.checkDot(e,a):a},i.prototype.tok=function(e,t,n){var a='\t\n\x0B\f\r ';if('@'==w(t,n,n+1))var n=n+1;else if(0>s(this.keywords,e))return-1;var r=n+v(e);return w(t,n,r)==e&&0<=X.indexOf(t.charAt(r))?r:-1},i.prototype.directive=function(n,a){var r=this.skipSpace(n,a);if(0>r)return r;var o=new _([]),r=this.tok('bind',n,a);if(0a)throw p(this._thisDoc,this.lines,n,a,'\'@keywords\' needs comma separated list of words');return this.setKeywords(w(o,null,null)),80a)throw p(this._thisDoc,this.lines,n,a,'Bad variable list after @forAll');var i=new T(o);try{for(;!0;){var d=i.next();(0>s(this._variables,d)||0<=s(this._parentVariables,d))&&(this._variables[d]=this._context.newUniversal(d))}}catch(t){if(t!=k)throw t}return a}var r=this.tok('forSome',n,a);if(0a)throw p(this._thisDoc,this.lines,n,a,'Bad variable list after @forSome');var i=new T(o);try{for(;!0;){var d=i.next();this._context.declareExistential(d)}}catch(t){if(t!=k)throw t}return a}var r=this.tok('prefix',n,a);if(0<=r){var l=new _([]),a=this.qname(n,r,l);if(0>a)throw p(this._thisDoc,this.lines,n,r,'expected qname after @prefix');var r=this.uri_ref2(n,a,l);if(0>r)throw p(this._thisDoc,this.lines,n,a,'expected after @prefix _qname_');var t=l[1].uri;if(this._baseURI)var t=C(this._baseURI,t);else S(0<=t.indexOf(':'),'With no base URI, cannot handle relative URI for NS');return S(0<=t.indexOf(':')),this._bindings[l[0][0]]=t,this.bind(l[0][0],e(t)),r}var r=this.tok('base',n,a);if(0<=r){var l=new _([]),a=this.uri_ref2(n,r,l);if(0>a)throw p(this._thisDoc,this.lines,n,r,'expected after @base ');var t=l[0].uri;if(this._baseURI)var t=C(this._baseURI,t);else throw p(this._thisDoc,this.lines,n,r,'With no previous base URI, cannot use relative URI in @base <'+t+'>');return S(0<=t.indexOf(':')),this._baseURI=t,a}return-1},i.prototype.bind=function(e,t){''==e||this._store.setPrefixForURI(e,t)},i.prototype.setKeywords=function(e){null==e?this.keywordsSet=0:(this.keywords=e,this.keywordsSet=1)},i.prototype.startDoc=function(){},i.prototype.endDoc=function(){return this._formula},i.prototype.makeStatement=function(e){e[0].add(e[2],e[1],e[3],this.source),this.statementCount+=1},i.prototype.statement=function(e,t){var n=new _([]),t=this.object(e,t,n);if(0>t)return t;var a=this.property_list(e,t,n[0]);if(0>a)throw p(this._thisDoc,this.lines,e,t,'expected propertylist');return a},i.prototype.subject=function(e,t,n){return this.item(e,t,n)},i.prototype.verb=function(e,t,n){var a=this.skipSpace(e,t);if(0>a)return a;var o=new _([]),a=this.tok('has',e,t);if(0<=a){var t=this.prop(e,a,o);if(0>t)throw p(this._thisDoc,this.lines,e,a,'expected property after \'has\'');return n.push(new b(['->',o[0]])),t}var a=this.tok('is',e,t);if(0<=a){var t=this.prop(e,a,o);if(0>t)throw p(this._thisDoc,this.lines,e,a,'expected after \'is\'');var a=this.skipSpace(e,t);if(0>a){throw p(this._thisDoc,this.lines,e,t,'End of file found, expected property after \'is\'');return a}var t=a,a=this.tok('of',e,t);if(0>a)throw p(this._thisDoc,this.lines,e,t,'expected \'of\' after \'is\' ');return n.push(new b(['<-',o[0]])),a}var a=this.tok('a',e,t);if(0<=a)return n.push(new b(['->',this._store.sym(D)])),a;if('<='==w(e,t,t+2))return n.push(new b(['<-',this._store.sym(y+'implies')])),t+2;if('='==w(e,t,t+1))return'>'==w(e,t+1,t+2)?(n.push(new b(['->',this._store.sym(y+'implies')])),t+2):(n.push(new b(['->',this._store.sym(U)])),t+1);if(':='==w(e,t,t+2))return n.push(new b(['->',y+'becomes'])),t+2;var a=this.prop(e,t,o);if(0<=a)return n.push(new b(['->',o[0]])),a;if('>-'==w(e,t,t+2)||'<-'==w(e,t,t+2))throw p(this._thisDoc,this.lines,e,a,'>- ... -> syntax is obsolete.');return-1},i.prototype.prop=function(e,t,n){return this.item(e,t,n)},i.prototype.item=function(e,t,n){return this.path(e,t,n)},i.prototype.blankNode=function(e){return this._context.bnode(e,this._reason2)},i.prototype.path=function(e,t,n){var a=this.nodeOrLiteral(e,t,n);if(0>a)return a;for(;0<='!^.'.indexOf(w(e,a,a+1));){var r=w(e,a,a+1);if('.'==r){var o=w(e,a+1,a+2);if(!o||0<=W.indexOf(o)&&0>':?<[{('.indexOf(o))break}var i=n.pop(),s=this.blankNode(this.here(a)),a=this.node(e,a+1,n);if(0>a)throw p(this._thisDoc,this.lines,e,a,'EOF found in middle of path syntax');var d=n.pop();'^'==r?this.makeStatement(new b([this._context,d,s,i])):this.makeStatement(new b([this._context,d,i,s])),n.push(s)}return a},i.prototype.anonymousNode=function(e){var t=this._anonymousNodes[e];if(t)return t;var t=this._store.bnode(e);return this._anonymousNodes[e]=t,t},i.prototype.node=function(e,t,n,a){'undefined'==typeof a&&(a=null);var r=a,o=this.skipSpace(e,t);if(0>o)return o;var t=o,i=w(e,t,t+1);if('['==i){var s=this.here(t),o=this.skipSpace(e,t+1);if(0>o)throw p(this._thisDoc,this.lines,e,t,'EOF after \'[\'');if('='==w(e,o,o+1)){var t=o+1,d=new _([]),o=this.objectList(e,t,d);if(0<=o){var r=d[0];if(1o)throw p(this._thisDoc,this.lines,e,t,'EOF when objectList expected after [ = ');if(';'==w(e,o,o+1))var o=o+1}else throw p(this._thisDoc,this.lines,e,t,'objectList expected after [= ')}if(null==r)var r=this.blankNode(s);var t=this.property_list(e,o,r);if(0>t)throw p(this._thisDoc,this.lines,e,o,'property_list expected');var o=this.skipSpace(e,t);if(0>o)throw p(this._thisDoc,this.lines,e,t,'EOF when \']\' expected after [ ');if(']'!=w(e,o,o+1))throw p(this._thisDoc,this.lines,e,o,'\']\' expected');return n.push(r),o+1}if('{'==i){var c=w(e,t+1,t+2);if('$'==c){t+=1;for(var o=t+1,h=new _([]),f=!0,t;1;){if(t=this.skipSpace(e,o),0>t)throw p(this._thisDoc,this.lines,e,t,'needed \'$}\', found end.');if('$}'==w(e,t,t+2)){var o=t+2;break}if(!!f)var f=!1;else if(','==w(e,t,t+1))t+=1;else throw p(this._thisDoc,this.lines,e,t,'expected: \',\'');var g=new _([]),o=this.item(e,t,g);if(0>o)throw p(this._thisDoc,this.lines,e,t,'expected item in set or \'$}\'');h.push(g[0])}return n.push(this._store.newSet(h,this._context)),o}var o=t+1,m=this._parentContext;this._parentContext=this._context;var y=this._anonymousNodes,N=this._parentVariables;this._parentVariables=this._variables,this._anonymousNodes=new x([]),this._variables=this._variables.slice();var I=this._reason2;if(this._reason2=L,null==r)var r=this._store.formula();for(this._context=r;1;){var t=this.skipSpace(e,o);if(0>t)throw p(this._thisDoc,this.lines,e,t,'needed \'}\', found end.');if('}'==w(e,t,t+1)){var o=t+1;break}var o=this.directiveOrStatement(e,t);if(0>o)throw p(this._thisDoc,this.lines,e,t,'expected statement or \'}\'')}return this._anonymousNodes=y,this._variables=this._parentVariables,this._parentVariables=N,this._context=this._parentContext,this._reason2=I,this._parentContext=m,n.push(r.close()),o}if('('==i){var S=this._store.list,c=w(e,t+1,t+2);if('$'==c){var S=this._store.newSet;t+=1}for(var o=t+1,h=new _([]),t;1;){if(t=this.skipSpace(e,o),0>t)throw p(this._thisDoc,this.lines,e,t,'needed \')\', found end.');if(')'==w(e,t,t+1)){var o=t+1;break}var g=new _([]),o=this.item(e,t,g);if(0>o)throw p(this._thisDoc,this.lines,e,t,'expected item in list or \')\'');h.push(g[0])}return n.push(S(h,this._context)),o}var o=this.tok('this',e,t);if(0<=o){throw p(this._thisDoc,this.lines,e,t,'Keyword \'this\' was ancient N3. Now use @forSome and @forAll keywords.');return n.push(this._context),o}var o=this.tok('true',e,t);if(0<=o)return n.push(!0),o;var o=this.tok('false',e,t);if(0<=o)return n.push(!1),o;if(null==r){var o=this.uri_ref2(e,t,n);if(0<=o)return o}return-1},i.prototype.property_list=function(e,t,n){for(;1;){var a=this.skipSpace(e,t);if(0>a){throw p(this._thisDoc,this.lines,e,t,'EOF found when expected verb in property list');return a}if(':-'==w(e,a,a+2)){var t=a+2,r=new _([]),a=this.node(e,t,r,n);if(0>a)throw p(this._thisDoc,this.lines,e,t,'bad {} or () or [] node after :- ');var t=a;continue}var t=a,o=new _([]),a=this.verb(e,t,o);if(0>=a)return t;var i=new _([]),t=this.objectList(e,a,i);if(0>t)throw p(this._thisDoc,this.lines,e,a,'objectList expected');var s=new T(i);try{for(;!0;){var d=s.next(),l=o[0],u=l[0],c=l[1];'->'==u?this.makeStatement(new b([this._context,c,n,d])):this.makeStatement(new b([this._context,c,d,n]))}}catch(t){if(t!=k)throw t}var a=this.skipSpace(e,t);if(0>a){throw p(this._thisDoc,this.lines,e,a,'EOF found in list of objects');return a}if(';'!=w(e,t,t+1))return t;var t=t+1}},i.prototype.commaSeparatedList=function(e,t,n,a){var r=this.skipSpace(e,t);if(0>r){throw p(this._thisDoc,this.lines,e,r,'EOF found expecting comma sep list');return r}if('.'==e.charAt(r))return t;if(a)var r=this.uri_ref2(e,r,n);else var r=this.bareWord(e,r,n);if(0>r)return-1;for(;1;){var t=this.skipSpace(e,r);if(0>t)return t;var o=w(e,t,t+1);if(','!=o)return'.'==o?t:-1;if(a)var r=this.uri_ref2(e,t+1,n);else var r=this.bareWord(e,t+1,n);if(0>r){throw p(this._thisDoc,this.lines,e,r,'bad list content');return r}}},i.prototype.objectList=function(e,t,n){var t=this.object(e,t,n);if(0>t)return-1;for(;1;){var a=this.skipSpace(e,t);if(0>a){throw p(this._thisDoc,this.lines,e,a,'EOF found after object');return a}if(','!=w(e,a,a+1))return a;var t=this.object(e,a+1,n);if(0>t)return t}},i.prototype.checkDot=function(e,t){var n=this.skipSpace(e,t);if(0>n)return n;if('.'==w(e,n,n+1))return n+1;if('}'==w(e,n,n+1))return n;if(']'==w(e,n,n+1))return n;throw p(this._thisDoc,this.lines,e,n,'expected \'.\' or \'}\' or \']\' at end of statement');return t},i.prototype.uri_ref2=function(e,t,n){var a=new _([]),r=this.qname(e,t,a);if(0<=r){var o=a[0],i=o[0],d=o[1];if(null==i){S(0,'not used?');var l=this._baseURI+A}else{var l=this._bindings[i];if(!l){if('_'==i)return n.push(this.anonymousNode(d)),r;throw p(this._thisDoc,this.lines,e,t,'Prefix '+i+' not bound.')}}var u=this._store.sym(l+d);return 0<=s(this._variables,u)?n.push(this._variables[u]):n.push(u),r}var t=this.skipSpace(e,t);if(0>t)return-1;if('?'==e.charAt(t)){var c=new _([]),r=this.variable(e,t,c);return 0'==e.charAt(t)){var f=w(e,h,t);if(this._baseURI)var f=C(this._baseURI,f);else S(0<=f.indexOf(':'),'With no base URI, cannot deal with relative URIs');if('#'==w(e,t-1,t)&&'#'!=w(f,-1,null))var f=f+'#';var u=this._store.sym(f);return 0<=s(this._variables,u)?n.push(this._variables[u]):n.push(u),t+1}var t=t+1}throw p(this._thisDoc,this.lines,e,r,'unterminated URI reference')}else{if(this.keywordsSet){var c=new _([]),r=this.bareWord(e,t,c);if(0>r)return-1;if(0<=s(this.keywords,c[0]))throw p(this._thisDoc,this.lines,e,t,'Keyword "'+c[0]+'" not allowed here.');return n.push(this._store.sym(this._bindings['']+c[0])),r}return-1}},i.prototype.skipSpace=function(e,t){for(var n=' \n\r\t\f\x0B\xA0\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200A\u200B\u2028\u2029\u3000',a=t?t:0,r;an.indexOf(r)))'\n'===e.charAt(a)&&++this.lines;else if('#'===e.charAt(a)){for(;;a++){if(a===e.length)return-1;if('\n'===e.charAt(a)){++this.lines;break}};}else return a;return-1},i.prototype.variable=function(e,t,n){var a=this.skipSpace(e,t);if(0>a)return-1;if('?'!=w(e,a,a+1))return-1;var a=a+1,t=a;if(0<='0123456789-'.indexOf(e.charAt(a))){throw p(this._thisDoc,this.lines,e,a,'Varible name can\'t start with \''+e.charAt(a)+'s\'');return-1}for(;tW.indexOf(e.charAt(t));)var t=t+1;if(null==this._parentContext)throw p(this._thisDoc,this.lines,e,a,'Can\'t use ?xxx syntax for variable in outermost level: '+w(e,a-1,t));return n.push(this._store.variable(w(e,a,t))),t},i.prototype.bareWord=function(e,t,n){var a=this.skipSpace(e,t);if(0>a)return-1;var r=e.charAt(a);if(0<='0123456789-'.indexOf(r))return-1;if(0<=W.indexOf(r))return-1;for(var t=a,t;tW.indexOf(e.charAt(t));)++t;return n.push(w(e,a,t)),t},i.prototype.qname=function(e,t,n){var t=this.skipSpace(e,t);if(0>t)return-1;var a=e.charAt(t);if(0<='0123456789-+'.indexOf(a))return-1;if(0>W.indexOf(a))for(var r=a,t=t+1,a;tW.indexOf(a));)var r=r+a,t=t+1;else var r='';if(tW.indexOf(a));)var r=r+a,t=t+1;return n.push(new b([o,r])),t}return r&&this.keywordsSet&&0>s(this.keywords,r)?(n.push(new b(['',r])),t):-1},i.prototype.object=function(e,t,n){var a=this.subject(e,t,n);if(0<=a)return a;var a=this.skipSpace(e,t);if(0>a)return-1;var t=a,r=null,o=e.charAt(t);if('"'==o||'\''==o){r=e.slice(t,t+3==o+o)?o+o+o:o;var t=t+v(r),i=this.strconst(e,t,r),a=i[0],d=i[1];return n.push(this._store.literal(d)),E('New string const ',d,a),a}return-1},i.prototype.nodeOrLiteral=function(e,t,n){var a=this.node(e,t,n);if(0<=a)return a;var a=this.skipSpace(e,t);if(0>a)return-1;var t=a,r=e.charAt(t);if(0<='-+0987654321'.indexOf(r)){te.lastIndex=0;var o=te.exec(e.slice(t));if(null!=o){var i=o[0];a=t+i.length,0<=i.indexOf('T')?n.push(this._store.literal(i,void 0,this._store.sym(H))):n.push(this._store.literal(i,void 0,this._store.sym(q)))}else{ee.lastIndex=0;var o=ee.exec(e.slice(t));if(null==o)throw p(this._thisDoc,this.lines,e,t,'Bad number or date syntax');a=t+ee.lastIndex;var i=w(e,t,a);0<=i.indexOf('e')?n.push(this._store.literal(parseFloat(i),void 0,this._store.sym(F))):0<=w(e,t,a).indexOf('.')?n.push(this._store.literal(parseFloat(i),void 0,this._store.sym(B))):n.push(this._store.literal(parseInt(i),void 0,this._store.sym(M)))};return a}if('"'==e.charAt(t)){if('"""'==w(e,t,t+3))var d='"""';else var d='"';var t=t+v(d),l=null,u=this.strconst(e,t,d),a=u[0],c=u[1],s=null;if('@'==w(e,a,a+1)){re.lastIndex=0;var o=re.exec(e.slice(a+1));if(null==o)throw p(this._thisDoc,startline,e,t,'Bad language code syntax on string literal, after @');var t=re.lastIndex+a+1,s=w(e,a+1,t),a=t}if('^^'==w(e,a,a+2))var h=new _([]),a=this.uri_ref2(e,a+2,h),l=h[0];return n.push(this._store.literal(c,s,l)),a}return-1},i.prototype.strconst=function(e,t,n){for(var a=t,r='',o=this.lines,t;ao;){var s=w(e,a,a+1),d=s.toLowerCase(),a=a+1;if(''==d)throw p(this._thisDoc,n,e,t,'unterminated string literal(3)');var l=I('0123456789abcdef',d);if(0>l)throw p(this._thisDoc,n,e,t,'bad string literal hex escape');var i=16*i+l,o=o+1}var u=r(i);return new b([a,u])},i.prototype.UEscape=function(e,t,n){for(var a=t,r=0,o='\\U';8>r;){var i=w(e,a,a+1),s=i.toLowerCase(),a=a+1;if(''==s)throw p(this._thisDoc,n,e,t,'unterminated string literal(3)');var d=I('0123456789abcdef',s);if(0>d)throw p(this._thisDoc,n,e,t,'bad string literal hex escape');var o=o+s,r=r+1}var l=R('0x'+w(o,2,10)-0);return new b([a,l])},l.prototype.toString=function(){var e=this._str,t=this._i,n=0;if(60: Bad syntax (%s) at ^ in:\n"%s%s^%s%s"'%new b([this.lines+1,this._uri,this._why,a,w(e,n,t),w(e,t,t+60),r])},n}();e.exports=i},function(e,t,n){(function(t){function n(e){if(!(this instanceof n))return new n(e);if(e&&e.lineMode){this._tripleQuotedString=this._number=this._boolean=/$0^/;var t=this;this._tokenize=this.tokenize,this.tokenize=function(e,n){this._tokenize(e,function(e,a){!e&&/^(?:IRI|prefixed|literal|langcode|type|\.|eof)$/.test(a.type)?n&&n(e,a):n&&n(e||t._syntaxError(a.type,n=null))})}}}var a=r,o='function'==typeof t?t:function e(t){setTimeout(t,0)},i=/\\u([a-fA-F0-9]{4})|\\U([a-fA-F0-9]{8})|\\[uU]|\\(.)/g,s={"\\":'\\',"'":'\'','"':'"',n:'\n',r:'\r',t:'\t',f:'\f',b:'\b',_:'_',"~":'~',".":'.',"-":'-',"!":'!',$:'$',"&":'&',"(":'(',")":')',"*":'*',"+":'+',",":',',";":';',"=":'=',"/":'/',"?":'?',"#":'#',"@":'@',"%":'%'},d=/[\x00-\x20<>\\"\{\}\|\^\`]/;n.prototype={_iri:/^<((?:[^>\\]|\\[uU])+)>/,_unescapedIri:/^<([^\x00-\x20<>\\"\{\}\|\^\`]*)>/,_unescapedString:/^"[^"\\]+"(?=[^"\\])/,_singleQuotedString:/^"[^"\\]*(?:\\.[^"\\]*)*"(?=[^"\\])|^'[^'\\]*(?:\\.[^'\\]*)*'(?=[^'\\])/,_tripleQuotedString:/^""("[^"\\]*(?:(?:\\.|"(?!""))[^"\\]*)*")""|^''('[^'\\]*(?:(?:\\.|'(?!''))[^'\\]*)*')''/,_langcode:/^@([a-z]+(?:-[a-z0-9]+)*)(?=[^a-z0-9\-])/i,_prefix:/^((?:[A-Za-z\xc0-\xd6\xd8-\xf6\xf8-\u02ff\u0370-\u037d\u037f-\u1fff\u200c\u200d\u2070-\u218f\u2c00-\u2fef\u3001-\ud7ff\uf900-\ufdcf\ufdf0-\ufffd]|[\ud800-\udb7f][\udc00-\udfff])(?:\.?[\-0-9A-Z_a-z\xb7\xc0-\xd6\xd8-\xf6\xf8-\u037d\u037f-\u1fff\u200c\u200d\u203f\u2040\u2070-\u218f\u2c00-\u2fef\u3001-\ud7ff\uf900-\ufdcf\ufdf0-\ufffd]|[\ud800-\udb7f][\udc00-\udfff])*)?:(?=[#\s<])/,_prefixed:/^((?:[A-Za-z\xc0-\xd6\xd8-\xf6\xf8-\u02ff\u0370-\u037d\u037f-\u1fff\u200c\u200d\u2070-\u218f\u2c00-\u2fef\u3001-\ud7ff\uf900-\ufdcf\ufdf0-\ufffd]|[\ud800-\udb7f][\udc00-\udfff])(?:\.?[\-0-9A-Z_a-z\xb7\xc0-\xd6\xd8-\xf6\xf8-\u037d\u037f-\u1fff\u200c\u200d\u203f\u2040\u2070-\u218f\u2c00-\u2fef\u3001-\ud7ff\uf900-\ufdcf\ufdf0-\ufffd]|[\ud800-\udb7f][\udc00-\udfff])*)?:((?:(?:[0-:A-Z_a-z\xc0-\xd6\xd8-\xf6\xf8-\u02ff\u0370-\u037d\u037f-\u1fff\u200c\u200d\u2070-\u218f\u2c00-\u2fef\u3001-\ud7ff\uf900-\ufdcf\ufdf0-\ufffd]|[\ud800-\udb7f][\udc00-\udfff]|%[0-9a-fA-F]{2}|\\[!#-\/;=?\-@_~])(?:(?:[\.\-0-:A-Z_a-z\xb7\xc0-\xd6\xd8-\xf6\xf8-\u037d\u037f-\u1fff\u200c\u200d\u203f\u2040\u2070-\u218f\u2c00-\u2fef\u3001-\ud7ff\uf900-\ufdcf\ufdf0-\ufffd]|[\ud800-\udb7f][\udc00-\udfff]|%[0-9a-fA-F]{2}|\\[!#-\/;=?\-@_~])*(?:[\-0-:A-Z_a-z\xb7\xc0-\xd6\xd8-\xf6\xf8-\u037d\u037f-\u1fff\u200c\u200d\u203f\u2040\u2070-\u218f\u2c00-\u2fef\u3001-\ud7ff\uf900-\ufdcf\ufdf0-\ufffd]|[\ud800-\udb7f][\udc00-\udfff]|%[0-9a-fA-F]{2}|\\[!#-\/;=?\-@_~]))?)?)(?=\.?[,;\s#()\[\]\{\}"'<])/,_blank:/^_:((?:[0-9A-Z_a-z\xc0-\xd6\xd8-\xf6\xf8-\u02ff\u0370-\u037d\u037f-\u1fff\u200c\u200d\u2070-\u218f\u2c00-\u2fef\u3001-\ud7ff\uf900-\ufdcf\ufdf0-\ufffd]|[\ud800-\udb7f][\udc00-\udfff])(?:\.?[\-0-9A-Z_a-z\xb7\xc0-\xd6\xd8-\xf6\xf8-\u037d\u037f-\u1fff\u200c\u200d\u203f\u2040\u2070-\u218f\u2c00-\u2fef\u3001-\ud7ff\uf900-\ufdcf\ufdf0-\ufffd]|[\ud800-\udb7f][\udc00-\udfff])*)(?=\.?[,;:\s#()\[\]\{\}"'<])/,_number:/^[\-+]?(?:\d+\.?\d*([eE](?:[\-\+])?\d+)|\d*\.?\d+)(?=[.,;:\s#()\[\]\{\}"'<])/,_boolean:/^(?:true|false)(?=[.,;:\s#()\[\]\{\}"'<])/,_keyword:/^@[a-z]+(?=[\s#<:])/,_sparqlKeyword:/^(?:PREFIX|BASE|GRAPH)(?=[\s#<:])/i,_shortPredicates:/^a(?=\s+|<)/,_newline:/^[ \t]*(?:#[^\n\r]*)?(?:\r\n|\n|\r)[ \t]*/,_whitespace:/^[ \t]+/,_endOfFile:/^(?:#[^\n\r]*)?$/,_tokenizeToEnd:function(e,t){function n(t){e(t._syntaxError(/^\S*/.exec(a)[0]))}for(var a=this._input;!0;){for(var r;r=this._newline.exec(a);)a=a.substr(r[0].length,a.length),this._line++;if((r=this._whitespace.exec(a))&&(a=a.substr(r[0].length,a.length)),this._endOfFile.test(a))return t&&e(a=null,{line:this._line,type:'eof',value:'',prefix:''}),this._input=a;var o=this._line,i='',s='',l='',p=a[0],u=null,c=0,h=!1,f;switch(p){case'^':if(1===a.length)break;else if('^'!==a[1])return n(this);if(this._prevTokenType='^',a=a.substr(2),'<'!==a[0]){h=!0;break}case'<':if(u=this._unescapedIri.exec(a))i='IRI',s=u[1];else if(u=this._iri.exec(a)){if(f=this._unescape(u[1]),null===f||d.test(f))return n(this);i='IRI',s=f}break;case'_':((u=this._blank.exec(a))||t&&(u=this._blank.exec(a+' ')))&&(i='prefixed',l='_',s=u[1]);break;case'"':case'\'':if(u=this._unescapedString.exec(a))i='literal',s=u[0];else if(u=this._singleQuotedString.exec(a)){if(f=this._unescape(u[0]),null===f)return n(this);i='literal',s=f.replace(/^'|'$/g,'"')}else if(u=this._tripleQuotedString.exec(a)){if(f=u[1]||u[2],this._line+=f.split(/\r\n|\r|\n/).length-1,f=this._unescape(f),null===f)return n(this);i='literal',s=f.replace(/^'|'$/g,'"')}break;case'@':'literal'===this._prevTokenType&&(u=this._langcode.exec(a))?(i='langcode',s=u[1]):(u=this._keyword.exec(a))&&(i=u[0]);break;case'.':if(1===a.length?t:'0'>a[1]||'9'=o?a(o):a(55296+(o-=65536)/1024,56320+(1023&o))}var i=s[r];if(!i)throw new Error;return i})}catch(e){return null}},_syntaxError:function(e){return this._input=null,new Error('Syntax error: unexpected "'+e+'" on line '+this._line+'.')},tokenize:function(e,t){function n(e){null!==r._input&&(r._input+=e,r._tokenizeToEnd(t,!1))}function a(){null!==r._input&&r._tokenizeToEnd(t,!0)}var r=this;this._line=1,'string'==typeof e?(this._input=e,o(function(){r._tokenizeToEnd(t,!0)})):(this._input='',e&&'function'!=typeof e?('function'==typeof e.setEncoding&&e.setEncoding('utf8'),e.on('data',n),e.on('end',a)):(this.addChunk=n,this.end=a,!t&&(t=e)))}},e.exports=n}).call(this,n(13).setImmediate)},function(e,t,n){function a(e){if(!(this instanceof a))return new a(e);this._tripleStack=[],this._graph=null,e=e||{},this._setBase(e.documentIRI);var t='string'==typeof e.format&&e.format.match(/\w*$/)[0].toLowerCase(),n='turtle'===t,i='trig'===t,s=/triple/.test(t),d=/quad/.test(t),l=s||d;(this._supportsNamedGraphs=!n)||(this._readPredicateOrNamedGraph=this._readPredicate),this._supportsQuads=!(n||i||s),l&&(this._base='',this._resolveIRI=function(e){return this._error('Disallowed relative IRI',e),this._callback=r,this._subject=null}),this._blankNodePrefix='string'==typeof e.blankNodePrefix?'_:'+e.blankNodePrefix.replace(/^_:/,''):'',this._lexer=e.lexer||new o({lineMode:l})}function r(){}var o=n(25),i='http://www.w3.org/1999/02/22-rdf-syntax-ns#',s=i+'nil',d=i+'first',l=i+'rest',p=/^[a-z][a-z0-9+.-]*:/i,u=/^(?:([a-z][a-z0-9+.-]*:))?(?:\/\/[^\/]*)?/i,c=/(?:^|\/)\.\.?(?:$|[\/#?])/,h=0,f=0;a._resetBlankNodeIds=function(){h=f=0},a.prototype={_setBase:function(e){if(!e)e=null;else if(0<=e.indexOf('#'))throw new Error('Invalid base IRI '+e);(this._base=e)&&(this._basePath=e.replace(/[^\/?]*(?:\?.*)?$/,''),e=e.match(u),this._baseRoot=e[0],this._baseScheme=e[1])},_readInTopContext:function(e){switch(e.type){case'eof':return null===this._graph?(delete this._prefixes._,this._callback(null,null,this._prefixes)):this._error('Unclosed graph',e);case'@prefix':return this._sparqlStyle=!1,this._readPrefix;case'PREFIX':return this._sparqlStyle=!0,this._readPrefix;case'@base':return this._sparqlStyle=!1,this._readBaseIRI;case'BASE':return this._sparqlStyle=!0,this._readBaseIRI;case'{':if(this._supportsNamedGraphs)return this._graph='',this._subject=null,this._readSubject;case'GRAPH':if(this._supportsNamedGraphs)return this._readNamedGraphLabel;default:return this._readSubject(e);}},_readSubject:function(e){switch(this._predicate=null,e.type){case'IRI':this._subject=null===this._base||p.test(e.value)?e.value:this._resolveIRI(e);break;case'prefixed':var t=this._prefixes[e.prefix];if(void 0===t)return this._error('Undefined prefix "'+e.prefix+':"',e);this._subject=t+e.value;break;case'[':return this._subject='_:b'+f++,this._tripleStack.push({subject:this._subject,predicate:null,object:null,type:'blank'}),this._readBlankNodeHead;case'(':return this._tripleStack.push({subject:s,predicate:null,object:null,type:'list'}),this._subject=null,this._readListItem;case'}':return this._readPunctuation(e);default:return this._error('Expected subject but got '+e.type,e);}return this._readPredicateOrNamedGraph},_readPredicate:function(e){var t=e.type;switch(t){case'IRI':case'abbreviation':this._predicate=null===this._base||p.test(e.value)?e.value:this._resolveIRI(e);break;case'prefixed':if('_'===e.prefix)return this._error('Disallowed blank node as predicate',e);var n=this._prefixes[e.prefix];if(void 0===n)return this._error('Undefined prefix "'+e.prefix+':"',e);this._predicate=n+e.value;break;case'.':case']':case'}':return null===this._predicate?this._error('Unexpected '+t,e):(this._subject=null,']'===t?this._readBlankNodeTail(e):this._readPunctuation(e));case';':return this._readPredicate;default:return this._error('Expected predicate to follow "'+this._subject+'"',e);}return this._readObject},_readObject:function(e){switch(e.type){case'IRI':this._object=null===this._base||p.test(e.value)?e.value:this._resolveIRI(e);break;case'prefixed':var t=this._prefixes[e.prefix];if(void 0===t)return this._error('Undefined prefix "'+e.prefix+':"',e);this._object=t+e.value;break;case'literal':return this._object=e.value,this._readDataTypeOrLang;case'[':var n='_:b'+f++;return this._tripleStack.push({subject:this._subject,predicate:this._predicate,object:n,type:'blank'}),this._subject=n,this._readBlankNodeHead;case'(':return this._tripleStack.push({subject:this._subject,predicate:this._predicate,object:s,type:'list'}),this._subject=null,this._readListItem;default:return this._error('Expected object to follow "'+this._predicate+'"',e);}return this._getTripleEndReader()},_readPredicateOrNamedGraph:function(e){return'{'===e.type?this._readGraph(e):this._readPredicate(e)},_readGraph:function(e){return'{'===e.type?(this._graph=this._subject,this._subject=null,this._readSubject):this._error('Expected graph but got '+e.type,e)},_readBlankNodeHead:function(e){return']'===e.type?(this._subject=null,this._readBlankNodeTail(e)):(this._predicate=null,this._readPredicate(e))},_readBlankNodeTail:function(e){if(']'!==e.type)return this._readBlankNodePunctuation(e);null!==this._subject&&this._callback(null,{subject:this._subject,predicate:this._predicate,object:this._object,graph:this._graph||''});var t=this._tripleStack.pop();return this._subject=t.subject,null===t.object?null===this._predicate?this._readPredicateOrNamedGraph:this._readPredicate:(this._predicate=t.predicate,this._object=t.object,this._getTripleEndReader())},_readDataTypeOrLang:function(e){switch(e.type){case'type':var t;if(''===e.prefix)t=null===this._base||p.test(e.value)?e.value:this._resolveIRI(e);else{var n=this._prefixes[e.prefix];if(void 0===n)return this._error('Undefined prefix "'+e.prefix+':"',e);t=n+e.value}return this._object+='^^'+t,this._getTripleEndReader();case'langcode':return this._object+='@'+e.value.toLowerCase(),this._getTripleEndReader();default:return this._getTripleEndReader().call(this,e);}},_readListItem:function(e){var t=null,n=null,a=this._subject,r=this._tripleStack,o=r[r.length-1],i=this._readListItem;switch(e.type){case'IRI':t=null===this._base||p.test(e.value)?e.value:this._resolveIRI(e);break;case'prefixed':var u=this._prefixes[e.prefix];if(void 0===u)return this._error('Undefined prefix "'+e.prefix+':"',e);t=u+e.value;break;case'literal':t=e.value,i=this._readDataTypeOrLang;break;case'[':n='_:b'+f++,t='_:b'+f++,r.push({subject:n,predicate:d,object:t,type:'blank'}),this._subject=t,i=this._readBlankNodeHead;break;case'(':n='_:b'+f++,r.push({subject:n,predicate:d,object:s,type:'list'}),this._subject=null,i=this._readListItem;break;case')':if(r.pop(),0!==r.length&&'list'===r[r.length-1].type&&this._callback(null,{subject:o.subject,predicate:o.predicate,object:o.object,graph:this._graph||''}),this._subject=o.subject,null===o.predicate){if(i=this._readPredicate,o.subject===s)return i;}else if(this._predicate=o.predicate,this._object=o.object,i=this._getTripleEndReader(),o.object===s)return i;n=s;break;default:return this._error('Expected list item instead of "'+e.type+'"',e);}return null===n&&(this._subject=n='_:b'+f++),null===a?o.object===s?o.object=n:o.subject=n:this._callback(null,{subject:a,predicate:l,object:n,graph:this._graph||''}),null!==t&&this._callback(null,{subject:n,predicate:d,object:t,graph:this._graph||''}),i},_readPunctuation:function(e){var t=this._subject,n=this._graph,a;switch(e.type){case'}':if(null===this._graph)return this._error('Unexpected graph closing',e);this._graph=null;case'.':this._subject=null,a=this._readInTopContext;break;case';':a=this._readPredicate;break;case',':a=this._readObject;break;case'IRI':if(this._supportsQuads&&null===this._graph){n=null===this._base||p.test(e.value)?e.value:this._resolveIRI(e),t=this._subject,a=this._readQuadPunctuation;break}case'prefixed':if(this._supportsQuads&&null===this._graph){var r=this._prefixes[e.prefix];if(void 0===r)return this._error('Undefined prefix "'+e.prefix+':"',e);n=r+e.value,a=this._readQuadPunctuation;break}default:return this._error('Expected punctuation to follow "'+this._object+'"',e);}return null!==t&&this._callback(null,{subject:t,predicate:this._predicate,object:this._object,graph:n||''}),a},_readBlankNodePunctuation:function(e){var t;switch(e.type){case';':t=this._readPredicate;break;case',':t=this._readObject;break;default:return this._error('Expected punctuation to follow "'+this._object+'"',e);}return this._callback(null,{subject:this._subject,predicate:this._predicate,object:this._object,graph:this._graph||''}),t},_readQuadPunctuation:function(e){return'.'===e.type?this._readInTopContext:this._error('Expected dot to follow quad',e)},_readPrefix:function(e){return'prefix'===e.type?(this._prefix=e.value,this._readPrefixIRI):this._error('Expected prefix to follow @prefix',e)},_readPrefixIRI:function(e){if('IRI'!==e.type)return this._error('Expected IRI to follow prefix "'+this._prefix+':"',e);var t;return t=null===this._base||p.test(e.value)?e.value:this._resolveIRI(e),this._prefixes[this._prefix]=t,this._prefixCallback(this._prefix,t),this._readDeclarationPunctuation},_readBaseIRI:function(e){if('IRI'!==e.type)return this._error('Expected IRI to follow base declaration',e);try{this._setBase(null===this._base||p.test(e.value)?e.value:this._resolveIRI(e))}catch(t){this._error(t.message,e)}return this._readDeclarationPunctuation},_readNamedGraphLabel:function(e){switch(e.type){case'IRI':case'prefixed':return this._readSubject(e),this._readGraph;case'[':return this._readNamedGraphBlankLabel;default:return this._error('Invalid graph label',e);}},_readNamedGraphBlankLabel:function(e){return']'===e.type?(this._subject='_:b'+f++,this._readGraph):this._error('Invalid graph label',e)},_readDeclarationPunctuation:function(e){return this._sparqlStyle?this._readInTopContext(e):'.'===e.type?this._readInTopContext:this._error('Expected declaration to end with a dot',e)},_getTripleEndReader:function(){var e=this._tripleStack;if(0===e.length)return this._readPunctuation;switch(e[e.length-1].type){case'blank':return this._readBlankNodeTail;case'list':return this._readListItem;}},_error:function(e,t){this._callback(new Error(e+' at line '+t.line+'.'))},_resolveIRI:function(e){var t=e.value;switch(t[0]){case void 0:return this._base;case'#':return this._base+t;case'?':return this._base.replace(/(?:\?.*)?$/,t);case'/':return('/'===t[1]?this._baseScheme:this._baseRoot)+this._removeDotSegments(t);default:return this._removeDotSegments(this._basePath+t);}},_removeDotSegments:function(e){if(!c.test(e))return e;for(var t='',n=e.length,a=-1,r=-1,o=0,i='/';ar&&'/'===e[++a]&&'/'===e[++a])for(;(r=a+1)=r&&(t=t.substr(0,o)),'/'!==i)return t+'/'+e.substr(a+1);o=a+1}}}i=e[++a]}return t+e.substring(o)},parse:function(e,t,n){this._readCallback=this._readInTopContext,this._prefixes=Object.create(null),this._prefixes._=this._blankNodePrefix||'_:b'+h++ +'_','function'==typeof e&&(n=t,t=e,e=null),this._callback=t||r,this._prefixCallback=n||r;var a=this;this._lexer.tokenize(e,function(e,t){null===e?a._readCallback!==void 0&&(a._readCallback=a._readCallback(t)):(a._callback(e),a._callback=r)}),e||(this.addChunk=this._lexer.addChunk,this.end=this._lexer.end)}},e.exports=a},function(e,t){function n(e,t){for(var n in p)t?e.prototype[n]=a(p[n]):e[n]=p[n];return e}function a(e){return function(t){return e(this,t)}}var r='http://www.w3.org/2001/XMLSchema#',o=r+'string',i=r+'integer',s=r+'decimal',d=r+'boolean',l='http://www.w3.org/1999/02/22-rdf-syntax-ns#langString',p={isIRI:function(e){if(!e)return e;var t=e[0];return'"'!==t&&'_'!==t},isLiteral:function(e){return e&&'"'===e[0]},isBlank:function(e){return e&&'_:'===e.substr(0,2)},getLiteralValue:function(e){var t=/^"([^]*)"/.exec(e);if(!t)throw new Error(e+' is not a literal');return t[1]},getLiteralType:function(e){var t=/^"[^]*"(?:\^\^([^"]+)|(@)[^@"]+)?$/.exec(e);if(!t)throw new Error(e+' is not a literal');return t[1]||(t[2]?l:o)},getLiteralLanguage:function(e){var t=/^"[^]*"(?:@([^@"]+)|\^\^[^"]+)?$/.exec(e);if(!t)throw new Error(e+' is not a literal');return t[1]?t[1].toLowerCase():''},isPrefixedName:function(e){return e&&/^[^:\/"']*:[^:\/"']+$/.test(e)},expandPrefixedName:function(e,t){var n=/(?:^|"\^\^)([^:\/#"'\^_]*):[^\/]*$/.exec(e),a,r,o;return n&&(a=n[1],r=t[a],o=n.index),void 0===r?e:0===o?r+e.substr(a.length+1):e.substr(0,o+3)+r+e.substr(o+a.length+4)},createIRI:function(e){return e&&'"'===e[0]?p.getLiteralValue(e):e},createLiteral:function(e,t){if(!t)switch(typeof e){case'boolean':t=d;break;case'number':if(isFinite(e)){t=0==e%1?i:s;break}default:return'"'+e+'"';}return'"'+e+(/^[a-z]+(-[a-z0-9]+)*$/i.test(t)?'"@'+t.toLowerCase():'"^^'+t)}};e.exports=n(n)},function(e,t){function n(){this._events=this._events||{},this._maxListeners=this._maxListeners||void 0}function a(e){return'function'==typeof e}function r(e){return'number'==typeof e}function o(e){return'object'==typeof e&&null!==e}function s(e){return void 0===e}e.exports=n,n.EventEmitter=n,n.prototype._events=void 0,n.prototype._maxListeners=void 0,n.defaultMaxListeners=10,n.prototype.setMaxListeners=function(e){if(!r(e)||0>e||isNaN(e))throw TypeError('n must be a positive number');return this._maxListeners=e,this},n.prototype.emit=function(e){var t,n,r,d,l,i;if(this._events||(this._events={}),'error'===e&&(!this._events.error||o(this._events.error)&&!this._events.error.length))if(t=arguments[1],t instanceof Error)throw t;else{var p=new Error('Uncaught, unspecified "error" event. ('+t+')');throw p.context=t,p}if(n=this._events[e],s(n))return!1;if(a(n))switch(arguments.length){case 1:n.call(this);break;case 2:n.call(this,arguments[1]);break;case 3:n.call(this,arguments[1],arguments[2]);break;default:d=Array.prototype.slice.call(arguments,1),n.apply(this,d);}else if(o(n))for(d=Array.prototype.slice.call(arguments,1),i=n.slice(),r=i.length,l=0;lr&&(this._events[e].warned=!0,console.error('(node) warning: possible EventEmitter memory leak detected. %d listeners added. Use emitter.setMaxListeners() to increase limit.',this._events[e].length),'function'==typeof console.trace&&console.trace())),this},n.prototype.on=n.prototype.addListener,n.prototype.once=function(e,t){function n(){this.removeListener(e,n),r||(r=!0,t.apply(this,arguments))}if(!a(t))throw TypeError('listener must be a function');var r=!1;return n.listener=t,this.on(e,n),this},n.prototype.removeListener=function(e,t){var n,r,s,d;if(!a(t))throw TypeError('listener must be a function');if(!this._events||!this._events[e])return this;if(n=this._events[e],s=n.length,r=-1,n===t||a(n.listener)&&n.listener===t)delete this._events[e],this._events.removeListener&&this.emit('removeListener',e,t);else if(o(n)){for(d=s;0r)return this;1===n.length?(n.length=0,delete this._events[e]):n.splice(r,1),this._events.removeListener&&this.emit('removeListener',e,t)}return this},n.prototype.removeAllListeners=function(e){var t,n;if(!this._events)return this;if(!this._events.removeListener)return 0===arguments.length?this._events={}:this._events[e]&&delete this._events[e],this;if(0===arguments.length){for(t in this._events)'removeListener'!==t&&this.removeAllListeners(t);return this.removeAllListeners('removeListener'),this._events={},this}if(n=this._events[e],a(n))this.removeListener(e,n);else if(n)for(;n.length;)this.removeListener(e,n[n.length-1]);return delete this._events[e],this},n.prototype.listeners=function(e){var t;return t=this._events&&this._events[e]?a(this._events[e])?[this._events[e]]:this._events[e].slice():[],t},n.prototype.listenerCount=function(e){if(this._events){var t=this._events[e];if(a(t))return 1;if(t)return t.length}return 0},n.listenerCount=function(e,t){return e.listenerCount(t)}},function(e,t,n){t=e.exports=n(46),t.Stream=t,t.Readable=t,t.Writable=n(30),t.Duplex=n(8),t.Transform=n(52),t.PassThrough=n(72)},function(e,t,n){'use strict';(function(t,r,o){function i(e,t,n){this.chunk=e,this.encoding=t,this.callback=n,this.next=null}function s(e){var t=this;this.next=null,this.entry=null,this.finish=function(){R(t,e)}}function d(e){return A.from(e)}function l(e){return A.isBuffer(e)||e instanceof P}function p(){}function u(e,t){O=O||n(8),e=e||{};var r=t instanceof O;this.objectMode=!!e.objectMode,r&&(this.objectMode=this.objectMode||!!e.writableObjectMode);var o=e.highWaterMark,i=e.writableHighWaterMark,d=this.objectMode?16:16384;this.highWaterMark=o||0===o?o:r&&(i||0===i)?i:d,this.highWaterMark=a(this.highWaterMark),this.finalCalled=!1,this.needDrain=!1,this.ending=!1,this.ended=!1,this.finished=!1,this.destroyed=!1;var l=!1===e.decodeStrings;this.decodeStrings=!l,this.defaultEncoding=e.defaultEncoding||'utf8',this.length=0,this.writing=!1,this.corked=0,this.sync=!0,this.bufferProcessing=!1,this.onwrite=function(e){_(t,e)},this.writecb=null,this.writelen=0,this.bufferedRequest=null,this.lastBufferedRequest=null,this.pendingcb=0,this.prefinished=!1,this.errorEmitted=!1,this.bufferedRequestCount=0,this.corkedRequestsFree=new s(this)}function c(e){return O=O||n(8),F.call(c,this)||this instanceof O?void(this._writableState=new u(e,this),this.writable=!0,e&&('function'==typeof e.write&&(this._write=e.write),'function'==typeof e.writev&&(this._writev=e.writev),'function'==typeof e.destroy&&(this._destroy=e.destroy),'function'==typeof e.final&&(this._final=e.final)),U.call(this)):new c(e)}function h(e,t){var n=new Error('write after end');e.emit('error',n),C.nextTick(t,n)}function f(e,t,n,a){var r=!0,o=!1;return null===n?o=new TypeError('May not write null values to stream'):'string'!=typeof n&&void 0!==n&&!t.objectMode&&(o=new TypeError('Invalid non-string/buffer chunk')),o&&(e.emit('error',o),C.nextTick(a,o),r=!1),r}function g(e,t,n){return e.objectMode||!1===e.decodeStrings||'string'!=typeof t||(t=A.from(t,n)),t}function m(e,t,n,a,r,o){if(!n){var i=g(t,a,r);a!==i&&(n=!0,r='buffer',a=i)}var s=t.objectMode?1:a.length;t.length+=s;var d=t.length'},_encodeLiteral:function(e,t,n){return s.test(e)&&(e=e.replace(d,a)),n?'"'+e+'"@'+n:t?'"'+e+'"^^'+this._encodeIriOrBlankNode(t):'"'+e+'"'},_encodeSubject:function(e){if('"'===e[0])throw new Error('A literal as subject is not allowed: '+e);return'['===e[0]&&(this._subject=']'),this._encodeIriOrBlankNode(e)},_encodePredicate:function(e){if('"'===e[0])throw new Error('A literal as predicate is not allowed: '+e);return e===i?'a':this._encodeIriOrBlankNode(e)},_encodeObject:function(e){if('"'!==e[0])return this._encodeIriOrBlankNode(e);var t=r.exec(e);if(!t)throw new Error('Invalid literal: '+e);return this._encodeLiteral(t[1],t[2],t[3])},_blockedWrite:function(){throw new Error('Cannot write because the writer has been closed.')},addTriple:function(e,t,n,a,r){n===void 0?this._writeTriple(e.subject,e.predicate,e.object,e.graph||'',t):'string'==typeof a?this._writeTriple(e,t,n,a,r):this._writeTriple(e,t,n,'',a)},addTriples:function(e){for(var t=0;t.\n'))}if(a){var i='',s='';for(var d in n)i+=i?'|'+d:d,s+=(s?'|':'')+n[d];i=i.replace(/[\]\/\(\)\*\+\?\.\\\$]/g,'\\$&'),this._prefixRegex=new RegExp('^(?:'+s+')[^/]*$|^('+i+')([a-zA-Z][\\-_a-zA-Z0-9]*)$')}this._write(a?'\n':'',t)},blank:function(e,t){var n=e,a,r;switch(void 0===e?n=[]:'string'==typeof e?n=[{predicate:e,object:t}]:!('length'in e)&&(n=[e]),r=n.length){case 0:return'[]';case 1:if(a=n[0],'['!==a.object[0])return'[ '+this._encodePredicate(a.predicate)+' '+this._encodeObject(a.object)+' ]';default:for(var o='[',s=0;s]+\?>/)){t.addStatus(a.req,'Has an XML declaration. We\'ll assume it\'s XHTML as the content-type was text/html.\n');var i=new C(this.response);return i.parse(t,n,a,r)}if(n.match(/.*/)){t.addStatus(a.req,'Has XHTML DOCTYPE. Switching to XHTMLHandler.\n');var s=new C(this.response);return s.parse(t,n,a,r)}if(n.match(/[^(/)){t.addStatus(a.req,'Has default namespace for XHTML, so switching to XHTMLHandler.\n');var d=new C(this.response);return d.parse(t,n,a,r)}var l=/([\s\S]+?)<\/title>/im.exec(n);return l&&o.add(a.resource,S.dc('title'),o.literal(l[1]),a.resource),o.add(a.resource,S.rdf('type'),S.link('WebPage'),t.appNode),t.addStatus(a.req,'non-XML HTML document, not parsed for data.'),t.doneFetch(a,this.response)}}],[{key:'toString',value:function e(){return'HTMLHandler'}},{key:'register',value:function e(t){t.mediatypes['text/html']={q:.9}}}]),t}(j);O.pattern=/text\/html/;var E=function(e){function t(){return p(this,t),i(this,d(t).apply(this,arguments))}return l(t,e),o(t,[{key:'parse',value:function e(t,n,a,r){if(n.match(/\s*<\?xml\s+version\s*=[^<>]+\?>/)){t.addStatus(a.req,'Warning: '+a.resource+' has an XML declaration. We\'ll assume it\'s XML but its content-type wasn\'t XML.\n');var o=new L(this.response);return o.parse(t,n,a,r)}if(n.slice(0,500).match(/xmlns:/)){t.addStatus(a.req,'May have an XML namespace. We\'ll assume it\'s XML but its content-type wasn\'t XML.\n');var i=new L(this.response);return i.parse(t,n,a,r)}return t.addStatus(a.req,'Plain text document, no known RDF semantics.'),t.doneFetch(a,this.response)}}],[{key:'toString',value:function e(){return'TextHandler'}},{key:'register',value:function e(t){t.mediatypes['text/plain']={q:.5}}}]),t}(j);E.pattern=/text\/plain/;var D=function(e){function t(){return p(this,t),i(this,d(t).apply(this,arguments))}return l(t,e),o(t,[{key:'parse',value:function e(t,n,a,r){var o=t.store,i=f(o,o,a.original.uri,a.original.uri,null,null,'',null);try{i.loadBuf(n)}catch(e){var s='Error trying to parse '+a.resource+' as Notation3:\n'+e+':\n'+e.stack;return t.failFetch(a,s,'parse_error',r)}return t.addStatus(a.req,'N3 parsed: '+i.statementCount+' triples in '+i.lines+' lines.'),t.store.add(a.original,S.rdf('type'),S.link('RDFDocument'),t.appNode),t.doneFetch(a,this.response)}}],[{key:'toString',value:function e(){return'N3Handler'}},{key:'register',value:function e(t){t.mediatypes['text/n3']={q:'1.0'},t.mediatypes['text/turtle']={q:1}}}]),t}(j);D.pattern=/(application|text)\/(x-)?(rdf\+)?(n3|turtle)/;var U={RDFXMLHandler:R,XHTMLHandler:C,XMLHandler:L,HTMLHandler:O,TextHandler:E,N3Handler:D},A=function(){function e(t){var n=this,a=1<arguments.length&&void 0!==arguments[1]?arguments[1]:{};if(p(this,e),this.store=t||new c,this.timeout=a.timeout||3e4,this._fetch=a.fetch||T,!this._fetch)throw new Error('No _fetch function availble for Fetcher');this.appNode=this.store.bnode(),this.store.fetcher=this,this.requested={},this.timeouts={},this.redirectedTo={},this.fetchQueue={},this.fetchCallbacks={},this.nonexistent={},this.lookedUp={},this.handlers=[],this.mediatypes={"image/*":{q:.9},"*/*":{q:.1}},v.callbackify(this,['request','fail','refresh','retract','done']),Object.keys(U).map(function(e){return n.addHandler(U[e])})}return o(e,[{key:'load',value:function e(t){var n=this,a=1<arguments.length&&void 0!==arguments[1]?arguments[1]:{};if(t instanceof Array)return Promise.all(t.map(function(e){return n.load(e,Object.assign({},a))}));var r=t.uri||t;return r=r.split('#')[0],a=this.initFetchOptions(r,a),this.pendingFetchPromise(r,a.baseURI,a)}},{key:'pendingFetchPromise',value:function e(t,n,a){var r=this,o;return!a.force&&this.fetchQueue[n]?o=this.fetchQueue[n]:(o=Promise.race([this.setRequestTimeout(t,a),this.fetchUri(t,a)]),this.fetchQueue[n]=o,this.cleanupFetchRequest(n,a,this.timeout)),o.then(function(e){return t in r.timeouts&&(r.timeouts[t].forEach(clearTimeout),delete r.timeouts[t]),e})}},{key:'cleanupFetchRequest',value:function e(t,n,a){var r=this;this.timeouts[t]=(this.timeouts[t]||[]).concat(setTimeout(function(){r.isPending(t)||delete r.fetchQueue[t]},a))}},{key:'initFetchOptions',value:function t(n,a){var r=this.store,o=!a.method||'GET'===a.method.toUpperCase();o||(a.force=!0),a.resource=r.sym(n),a.baseURI=a.baseURI||n,a.original=r.sym(a.baseURI),a.req=r.bnode(),a.headers=a.headers||{},a.contentType&&(a.headers['content-type']=a.contentType),a.force&&(a.cache='no-cache');var i=this.acceptString();a.headers.accept=i;var s=e.offlineOverride(n);a.requestedURI=s,e.withCredentials(s,a)&&(a.credentials='include');var d=e.proxyIfNecessary(s);return s!==d&&(a.proxyUsed=!0),a.actualProxyURI=d,a}},{key:'fetchUri',value:function t(n,a){var r=this;if(!n)return Promise.reject(new Error('Cannot fetch an empty uri'));if(e.unsupportedProtocol(n))return this.failFetch(a,'fetcher: Unsupported protocol','unsupported_protocol');var o=this.getState(n);if(!a.force){if('fetched'===o)return Promise.resolve(this.doneFetch(a,{status:200,ok:!0,statusText:'Already loaded into quadstore.'}));if('failed'===o&&404===this.requested[n]){var i='Previously failed: '+this.requested[n],s={url:n,status:this.requested[n],statusText:i,responseText:i,headers:{},ok:!1,body:null,bodyUsed:!1,size:0,timeout:0};return this.failFetch(a,i,this.requested[n],s)}}else delete this.nonexistent[n];this.fireCallbacks('request',[n]),this.requested[n]=!0,a.noMeta||this.saveRequestMetadata(n,a);var d=a.actualProxyURI;return this._fetch(d,a).then(function(e){return r.handleResponse(e,n,a)},function(e){var t={url:d,status:999,statusText:(e.name||'network failure')+': '+(e.errno||e.code||e.type),responseText:e.message,headers:{},ok:!1,body:null,bodyUsed:!1,size:0,timeout:0};return console.log('Fetcher: <'+d+'> Non-HTTP fetch error: '+e),r.failFetch(a,'fetch failed: '+e,999,t)})}},{key:'nowOrWhenFetched',value:function e(t,n,a){var r=3<arguments.length&&void 0!==arguments[3]?arguments[3]:{};t=t.uri||t,'function'==typeof n?a=n:'undefined'==typeof n||(n instanceof g?r.referringTerm=n:r=n),this.load(t,r).then(function(e){if(a)if(!e){var n='@@ nowOrWhenFetched: no response object!';console.log(n),a(!1,n)}else if(e.ok)a(!0,'OK',e);else{console.log('@@@ fetcher.js Should not take this path !!!!!!!!!!!!');var r='HTTP error: Status '+e.status+' ('+e.statusText+')';e.responseText&&(r+=' '+e.responseText),console.log(r+' fetching '+t),a(!1,r,e)}},function(e){var n=e.message||e.statusText;n='Failed to load <'+t+'> '+n,console.log(n),e.response&&e.response.status&&(n+=' status: '+e.response.status),a(!1,n,e.response)})}},{key:'addStatus',value:function e(t,n){var a=new Date;n='['+a.getHours()+':'+a.getMinutes()+':'+a.getSeconds()+'.'+a.getMilliseconds()+'] '+n;var r=this.store,o=r.the(t,S.link('status'));o&&o.append?o.append(r.literal(n)):h.warn('web.js: No list to add to: '+o+','+n)}},{key:'failFetch',value:function e(t,n,a,r){this.addStatus(t.req,n),t.noMeta||this.store.add(t.original,S.link('error'),n);var o=(t.method||'GET').toUpperCase(),i='GET'===o||'HEAD'===o;i&&(t.resource.sameTerm(t.original)?console.log('@@ Recording '+o+' failure for '+t.original+': '+a):console.log('@@ Recording failure '+o+' original '+t.original+'( as '+t.resource+') : '+a),this.requested[_.docpart(t.original.uri)]=a,this.fireCallbacks('fail',[t.original.uri,n]));var s=new Error('Fetcher: '+n);return s.status=a,s.statusText=n,s.response=r,Promise.reject(s)}},{key:'linkData',value:function e(t,n,a,r,o){if(a){var i=this.store,s=i.sym(_.join(a,t.uri)),d;if('alternate'===n||'seeAlso'===n||'meta'===n||'describedby'===n){if(s.uri===t.uri)return;d=S.rdfs('seeAlso')}else d='type'===n?i.sym('http://www.w3.org/1999/02/22-rdf-syntax-ns#type'):i.sym(_.join(encodeURIComponent(n),'http://www.iana.org/assignments/link-relations/'));o?i.add(s,d,t,r):i.add(t,d,s,r)}}},{key:'parseLinkHeader',value:function e(t,n,a){if(t)for(var r=/<[^>]*>\s*(\s*;\s*[^()<>@,;:"/[\]?={} \t]+=(([^\(\)<>@,;:"\/\[\]\?={} \t]+)|("[^"]*")))*(,|$)/g,o=/[^\(\)<>@,;:"\/\[\]\?={} \t]+=(([^\(\)<>@,;:"\/\[\]\?={} \t]+)|("[^"]*"))/g,d=t.match(r),l=0;l<d.length;l++)for(var i=d[l].split('>'),u=i[0].substring(1),c=i[1],h=c.match(o),s=0;s<h.length;s++){var f=h[s],p=f.split('='),g=p[1].replace(/["']/g,'');this.linkData(n,g,u,a)}}},{key:'doneFetch',value:function e(t,n){return this.addStatus(t.req,'Done.'),this.requested[t.original.uri]='done',this.fireCallbacks('done',[t.original.uri]),n.req=t.req,n}},{key:'nowKnownAs',value:function e(t,n){this.lookedUp[t.uri]?!this.lookedUp[n.uri]&&this.lookUpThing(n,t):this.lookedUp[n.uri]&&!this.lookedUp[t.uri]&&this.lookUpThing(t,n)}},{key:'putBack',value:function e(t){var n=1<arguments.length&&void 0!==arguments[1]?arguments[1]:{};t=t.uri||t;var a=new g(t).doc();return n.contentType=n.contentType||'text/turtle',n.data=w(a,this.store,a.uri,n.contentType),this.webOperation('PUT',t,n)}},{key:'webCopy',value:function e(t,n,a){var r=this;return this.webOperation('GET',t).then(function(e){return r.webOperation('PUT',n,{data:e.responseText,contentType:a})})}},{key:'delete',value:function e(t,n){var a=this;return this.webOperation('DELETE',t,n).then(function(e){return a.requested[t]=404,a.nonexistent[t]=!0,a.unload(a.store.sym(t)),e})}},{key:'createContainer',value:function e(t,n,a){var r={"content-type":'text/turtle',link:S.ldp('BasicContainer')+'; rel="type"'};n&&(r.slug=n);var o={headers:r};return a&&(o.body=a),this.webOperation('POST',t,o)}},{key:'webOperation',value:function t(n,a){var r=2<arguments.length&&void 0!==arguments[2]?arguments[2]:{};a=a.uri||a,r.method=n,r.body=r.data||r.body,r.force=!0;var o=this;if(r.body&&!r.contentType)throw new Error('Web operation sending data must have a defined contentType.');return r.contentType&&(r.headers=r.headers||{},r.headers['content-type']=r.contentType),e.withCredentials(a,r)&&(r.credentials='include'),new Promise(function(e,t){o._fetch(a,r).then(function(r){if(r.ok)r.body?r.text().then(function(t){r.responseText=t,e(r)}):e(r);else{var o='Web error: '+r.status;r.statusText&&(o+=' ('+r.statusText+')'),o+=' on '+n+' of <'+a+'>',r.responseText&&(o+=': '+r.responseText);var i=new Error(o);i.response=r,t(i)}},function(e){var r='Fetch error for '+n+' of <'+a+'>:'+e;t(new Error(r))})})}},{key:'lookUpThing',value:function e(t,n){var a=this,r=this.store.uris(t);return r=r.map(function(e){return _.docpart(e)}),r.forEach(function(e){a.lookedUp[e]=!0}),this.load(r,{referringTerm:n})}},{key:'getHeader',value:function e(t,n){for(var a=this.store,o=a.each(void 0,S.link('requestedURI'),t.uri),i=0,r;i<o.length;i++)if(r=o[i],void 0!==r){var s=a.any(r,S.link('response'));if(void 0!==s){console.log('@@@ looking for '+S.httph(n.toLowerCase()));var d=a.each(s,S.httph(n.toLowerCase()));return d.length?d.map(function(e){return e.value}):[]}}}},{key:'saveRequestMetadata',value:function e(t,n){var a=n.req,r=this.store,o=n.referringTerm;this.addStatus(n.req,'Accept: '+n.headers.accept),o&&o.uri&&r.add(t,S.link('requestedBy'),o.uri,this.appNode),n.original&&n.original.uri!==t&&r.add(a,S.link('orginalURI'),r.literal(n.original.uri),this.appNode);var i=new Date,s='['+i.getHours()+':'+i.getMinutes()+':'+i.getSeconds()+'] ';r.add(a,S.rdfs('label'),r.literal(s+' Request for '+t),this.appNode),r.add(a,S.link('requestedURI'),r.literal(t),this.appNode),r.add(a,S.link('status'),r.collection(),this.appNode)}},{key:'saveResponseMetadata',value:function e(t,n){var a=this.store,r=a.bnode();return(a.add(n.req,S.link('response'),r,r),a.add(r,S.http('status'),a.literal(t.status),r),a.add(r,S.http('statusText'),a.literal(t.statusText),r),!n.resource.uri.startsWith('http'))?r:(t.headers.forEach(function(e,t){a.add(r,S.httph(t),e,r),'content-type'===t&&a.add(n.resource,S.rdf('type'),v.mediaTypeClass(e),r)}),r)}},{key:'objectRefresh',value:function e(t){var n=this.store.uris(t);if('undefined'!=typeof n)for(var a=0;a<n.length;a++)this.refresh(this.store.sym(_.docpart(n[a])))}},{key:'refresh',value:function e(t,n){this.fireCallbacks('refresh',arguments),this.nowOrWhenFetched(t,{force:!0,clearPreviousData:!0},n)}},{key:'refreshIfExpired',value:function e(t,n){var a=this.getHeader(t,'Expires');!a||new Date(a).getTime()<=new Date().getTime()?this.refresh(t,n):n(!0,'Not expired',{})}},{key:'retract',value:function e(t){this.store.removeMany(void 0,void 0,void 0,t),t.uri&&delete this.requested[_.docpart(t.uri)],this.fireCallbacks('retract',arguments)}},{key:'getState',value:function e(t){return'undefined'==typeof this.requested[t]?'unrequested':!0===this.requested[t]?'requested':'done'===this.requested[t]?'fetched':'redirected'===this.requested[t]?this.getState(this.redirectedTo[t]):'failed'}},{key:'isPending',value:function e(t){return!0===this.requested[t]}},{key:'unload',value:function e(t){this.store.removeDocument(t),delete this.requested[t.uri]}},{key:'addHandler',value:function e(t){this.handlers.push(t),t.register(this)}},{key:'retryNoCredentials',value:function e(t,n){console.log('web: Retrying with no credentials for '+n.resource),n.retriedWithNoCredentials=!0,delete this.requested[t];var a=Object.assign({},n,{withCredentials:!1});return this.addStatus(n.req,'Abort: Will retry with credentials SUPPRESSED to see if that helps'),this.load(t,a)}},{key:'isCrossSite',value:function e(t){if('undefined'==typeof document||!document.location)return!1;var n=_.hostpart,a=''+document.location;return n(a)&&n(t)&&n(a)!==n(t)}},{key:'handleError',value:function t(n,a,r){if(this.isCrossSite(a)){if(r.withCredentials&&!r.retriedWithNoCredentials)return this.retryNoCredentials(a,r);var o=e.crossSiteProxy(a);if(o&&!r.proxyUsed)return console.log('web: Direct failed so trying proxy '+o),this.redirectToProxy(o,r)}var i;return n.message?i='Fetch error: '+n.message:(i=n.statusText,n.responseText&&(i+=' '.concat(n.responseText))),this.failFetch(r,i,n.status||998,n)}},{key:'addType',value:function e(t,n,a,r){var o=n;if(r){var i=a.any(o,S.link('requestedURI'));i&&i!==r&&a.add(a.sym(r),S.rdf('type'),t,this.appNode)}for(;;){var s=a.any(o,S.link('requestedURI'));if(s&&s.value&&a.add(a.sym(s.value),S.rdf('type'),t,this.appNode),o=a.any(void 0,a.sym('http://www.w3.org/2007/ont/link#redirectedRequest'),o),!o)break;var d=a.any(o,a.sym('http://www.w3.org/2007/ont/link#response'));if(!d)break;var l=a.any(d,a.sym('http://www.w3.org/2007/ont/http#status'));if(!l)break;if('301'!==l&&'302'!==l)break}}},{key:'handleResponse',value:function e(t,n,a){var r=this,o=this.store,i=t.headers,s=a.req,d=this.saveResponseMetadata(t,a),l=this.normalizedContentType(a,i)||'',p=i.get('content-location');if(0===t.status)return console.log('Masked error - status 0 for '+n),this.handleError(t,n,a);if(400<=t.status)return 404===t.status&&(this.nonexistent[a.original.uri]=!0,this.nonexistent[n]=!0),this.saveErrorResponse(t,d).then(function(){var e=a.resource+' '+t.statusText;return r.failFetch(a,e,t.status,t)});var u=null,c=null;if(p&&(c=_.join(p,n),c!==n&&(u=c)),200===t.status){this.addType(S.link('Document'),s,o,n),u&&this.addType(S.link('Document'),s,o,u),a.clearPreviousData&&o.removeDocument(a.resource);var h=l.includes('image/')||l.includes('application/pdf');l&&h&&(this.addType(o.sym('http://purl.org/dc/terms/Image'),s,o,n),u&&this.addType(o.sym('http://purl.org/dc/terms/Image'),s,o,u))}if(p){if(!a.force&&u&&'done'===this.requested[c])return this.doneFetch(a,t);this.requested[c]=!0}this.parseLinkHeader(i.get('link'),a.original,s);var f=this.handlerForContentType(l,t);return f?t.text().then(function(e){return t.responseText=e,f.parse(r,e,a,t)}):(this.addStatus(s,'Fetch over. No data handled.'),this.doneFetch(a,t))}},{key:'saveErrorResponse',value:function e(t,n){var a=this.store;return t.text().then(function(e){10<e.length&&a.add(n,S.http('content'),a.literal(e),n)})}},{key:'handlerForContentType',value:function e(t,n){if(!t)return null;var a=this.handlers.find(function(e){return t.match(e.pattern)});return a?new a(n):null}},{key:'guessContentType',value:function e(t){return I[t.split('.').pop()]}},{key:'normalizedContentType',value:function e(t,n){if(t.forceContentType)return t.forceContentType;var a=n.get('content-type');if(!a||a.includes('application/octet-stream')){var r=this.guessContentType(t.resource.uri);if(r)return r}var o=_.protocol(t.resource.uri);return!a&&['file','chrome'].includes(o)?'text/xml':a}},{key:'redirectToProxy',value:function e(t,n){var a=this;this.addStatus(n.req,'BLOCKED -> Cross-site Proxy to <'+t+'>'),n.proxyUsed=!0;var r=this.store,o=n.req;n.noMeta||(r.add(o,S.link('redirectedTo'),r.sym(t),o),this.addStatus(o,'redirected to new request')),this.requested[n.resource.uri]='redirected',this.redirectedTo[n.resource.uri]=t;var i=Object.assign({},n);return i.baseURI=n.resource.uri,this.fetchUri(t,i).then(function(e){return i.noMeta||r.add(o,S.link('redirectedRequest'),i.req,a.appNode),e})}},{key:'setRequestTimeout',value:function e(t,n){var a=this;return new Promise(function(e){a.timeouts[t]=(a.timeouts[t]||[]).concat(setTimeout(function(){!a.isPending(t)||n.retriedWithNoCredentials||n.proxyUsed||e(a.failFetch(n,'Request to '.concat(t,' timed out'),'timeout'))},a.timeout))})}},{key:'addFetchCallback',value:function e(t,n){this.fetchCallbacks[t]?this.fetchCallbacks[t].push(n):this.fetchCallbacks[t]=[n]}},{key:'acceptString',value:function e(){var t='';for(var n in this.mediatypes)for(var a in''!=t&&(t+=', '),t+=n,this.mediatypes[n])t+=';'+a+'='+this.mediatypes[n][a];return t}}],[{key:'crossSiteProxy',value:function t(n){return e.crossSiteProxyTemplate?e.crossSiteProxyTemplate.replace('{uri}',encodeURIComponent(n)):void 0}},{key:'offlineOverride',value:function e(t){var n=t,a;return'undefined'!=typeof window&&window.panes&&(a=window.panes.UI)&&a.preferences&&a.preferences.get('offlineModeUsingLocalhost')&&'http://'===n.slice(0,7)&&'localhost/'!==n.slice(7,17)&&(n='http://localhost/'+n.slice(7),h.warn('Localhost kludge for offline use: actually getting <'+n+'>')),n}},{key:'proxyIfNecessary',value:function t(n){var a;if('undefined'!=typeof window&&window.panes&&(a=window.panes.UI)&&a.isExtension)return n;if('undefined'!=typeof $SolidTestEnvironment&&$SolidTestEnvironment.localSiteMap){var r=n.split('/').slice(2),o=function e(t,n){var a=n[t.shift()];return a?'string'==typeof a?a+t.join('/'):t?e(t,a):null:null},i=o(r,$SolidTestEnvironment.localSiteMap);if(i)return i}return e.crossSiteProxyTemplate&&'undefined'!=typeof document&&document.location&&'https:'===(''+document.location).slice(0,6)&&'http:'===n.slice(0,5)?e.crossSiteProxyTemplate.replace('{uri}',encodeURIComponent(n)):n}},{key:'unsupportedProtocol',value:function e(t){var n=_.protocol(t);return'tel'===n||'mailto'===n||'urn'===n}},{key:'withCredentials',value:function e(t){var n=1<arguments.length&&void 0!==arguments[1]?arguments[1]:{},e=t.startsWith('https:');return void 0!==n.withCredentials&&(e=n.withCredentials),e}}]),e}();e.exports=A,e.exports.HANDLERS=U,e.exports.CONTENT_TYPE_BY_EXT=I},function(e,t,n){function a(e,t,n,a,i,s){function d(e,t){return i?void i(e,t):t}n=n||e.uri,s=s||{},a=a||'text/turtle';var l=null;try{var p=o(t);s.flags&&p.setFlags(s.flags);var u=t.statementsMatching(void 0,void 0,void 0,e),c;switch(p.suggestNamespaces(t.namespaces),p.setBase(n),a){case'application/rdf+xml':return l=p.statementsToXML(u),d(null,l);case'text/n3':case'application/n3':return l=p.statementsToN3(u),d(null,l);case'text/turtle':case'application/x-turtle':return p.setFlags('si'),l=p.statementsToN3(u),d(null,l);case'application/n-triples':return p.setFlags('deinprstux'),l=p.statementsToNTriples(u),d(null,l);case'application/ld+json':p.setFlags('deinprstux'),c=p.statementsToNTriples(u),r.convertToJson(c,i);break;case'application/n-quads':case'application/nquads':return p.setFlags('deinprstux q'),l=p.statementsToNTriples(u),d(null,l);break;default:throw new Error('Serialize: Content-type '+a+' not supported for data write.');}}catch(e){if(i)return i(e);throw e}}e.exports=a;var r=n(38),o=n(34)},function(e,t,n){var a=n(0),r=n(6),o=n(2),i=n(4),s=n(37),d=function(){function e(e){return encodeURI(e)}function t(e){for(var t='',n=0,a;n<e.length;n++)a=e.charCodeAt(n),t+=65535<a?'\\U'+('00000000'+a.toString(16)).slice(-8):126<a?'\\u'+('0000'+a.toString(16)).slice(-4):e[n];return t}var n=function e(t){this.flags='',this.base=null,this.prefixes=[],this.namespaces=[],this.suggestPrefix('rdf','http://www.w3.org/1999/02/22-rdf-syntax-ns#'),this.suggestPrefix('xml','reserved:reservedForFutureUse'),this.namespacesUsed=[],this.keywords=['a'],this.prefixchars='abcdefghijklmnopqustuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ',this.incoming=null,this.formulas=[],this.store=t};n.prototype.setBase=function(e){return this.base=e,this},n.prototype.setFlags=function(e){return this.flags=e||'',this},n.prototype.toStr=function(e){var t=e.toNT();return'Graph'===e.termType&&(this.formulas[t]=e),t},n.prototype.fromStr=function(e){if('{'===e[0]){var t=this.formulas[e];return t||console.log('No formula object for '+e),t}return this.store.fromNT(e)},n.prototype.suggestPrefix=function(e,t){'default'===e.slice(0,7)||'ns'===e.slice(0,2)||!e||!t||e in this.namespaces||t in this.prefixes||(this.prefixes[t]=e,this.namespaces[e]=t)},n.prototype.suggestNamespaces=function(e){for(var t in e)return this.suggestPrefix(t,e[t]),this},n.prototype.checkIntegrity=function(){var e,t;for(e in this.namespaces)if(this.prefixes[this.namespaces[e]]!==e)throw new Error('Serializer integity error 1: '+e+', '+this.namespaces[e]+', '+this.prefixes[this.namespaces[e]]+'!');for(t in this.prefixes)if(this.namespaces[this.prefixes[t]]!==t)throw new Error('Serializer integity error 2: '+t+', '+this.prefixs[t]+', '+this.namespaces[this.prefixes[t]]+'!')},n.prototype.makeUpPrefix=function(e){function t(t){return!!n.prototype.validPrefix.test(t)&&'ns'!==t&&!(t in this.namespaces)&&(this.prefixes[e]=t,this.namespaces[t]=e,t)}var a=e,r=t.bind(this);0<='#/'.indexOf(a[a.length-1])&&(a=a.slice(0,-1));var o=a.lastIndexOf('/');0<=o&&(a=a.slice(o+1));for(var s=0;s<a.length&&this.prefixchars.indexOf(a[s]);)s++;if(a=a.slice(0,s),6>a.length&&r(a))return a;if(r(a.slice(0,3)))return a.slice(0,3);if(r(a.slice(0,2)))return a.slice(0,2);if(r(a.slice(0,4)))return a.slice(0,4);if(r(a.slice(0,1)))return a.slice(0,1);if(r(a.slice(0,5)))return a.slice(0,5);n.prototype.validPrefix.test(a)||(a='n');for(var i=0;;i++)if(r(a.slice(0,3)+i))return a.slice(0,3)+i},n.prototype.rootSubjects=function(e){for(var t={},n={},a={},r=0;r<e.length;r++){var o=e[r],i=function e(n){t.hasOwnProperty(n)||(t[n]=[]),t[n].push(o.subject)},s=[o.subject,o.predicate,o.object];s.map(function(e){'BlankNode'===e.termType?a[e.toNT()]=!0:'Collection'===e.termType&&e.elements.forEach(function(e){i(e)})}),i(e[r].object);var d=n[this.toStr(o.subject)];d||(d=[]),d.push(o),n[this.toStr(o.subject)]=d}var l=[];for(var p in n)if(n.hasOwnProperty(p)){var u=this.fromStr(p);if('BlankNode'!==u.termType||!t[u]||1!==t[u].length){l.push(u);continue}}this.incoming=t;for(var c={},h=0;h<l.length;h++)c[l[h].toNT()]=!0;return{roots:l,subjects:n,rootsHash:c,incoming:t}},n.prototype.toN3=function(e){return this.statementsToN3(e.statements)},n.prototype._notQNameChars='\t\r\n !"#$%&\'()*.,+/;<=>?@[\\]^`{|}~',n.prototype._notNameChars=n.prototype._notQNameChars+':',n.prototype.explicitURI=function(n){return n=0>this.flags.indexOf('r')&&this.base?o.refTo(this.base,n):0<=this.flags.indexOf('u')?t(n):e(n),'<'+n+'>'},n.prototype.statementsToNTriples=function(e){var t=e.slice();t.sort();for(var n='',a='http://www.w3.org/1999/02/22-rdf-syntax-ns#',o=this,d=this.store,l=function e(t){if('Collection'!==t.termType)return o.atomicTermToN3(t);for(var s=t.elements,l=d.sym(a+'nill'),p=s.length-1,i;0<=p;p--)i=new r,n+=e(i)+' '+e(d.sym(a+'first'))+' '+e(s[p])+'.\n',n+=e(i)+' '+e(d.sym(a+'rest'))+' '+e(l)+'.\n',l=i;return o.atomicTermToN3(l)},p=0;p<t.length;p++){var i=t[p],u='';u+=l(i.subject)+' ',u+=l(i.predicate)+' ',u+=l(i.object)+' ',0<=this.flags.indexOf('q')&&(u+=l(i.why)+' '),u+='.\n',n+=u}return n},n.prototype.statementsToN3=function(e){function t(e){for(var t=this.rootSubjects(e),n=t.roots,r=[],o=0,i;o<n.length;o++)i=n[o],r.push(a(i,t));return r}function a(e,t){return'BlankNode'!==e.termType||t.incoming[e]?[v(e,t)].concat([x(e,t)]).concat(['.']):_(e,t,!0).concat(['.'])}function r(e,t){var n=[],a=null,r=t.subjects[this.toStr(e)]||[];if('undefined'==typeof r)throw new Error('Cant find statements for '+e);for(var o=[],s=0,i;s<r.length;s++)i=r[s],i.predicate.uri===a?o.push(','):(a&&(n=n.concat([o]).concat([';']),o=[]),n.push(f[i.predicate.uri]?f[i.predicate.uri]:v(i.predicate,t))),a=i.predicate.uri,o.push(_(i.object,t));return n=n.concat([o]),n}function o(e,t,n){return'BlankNode'===e.termType&&(n||void 0===t.rootsHash[e.toNT()])?t.subjects[this.toStr(e)]?['[',x(e,t),']']:'[]':v(e,t)}function s(e,t){var n,a;switch(e.termType){case'Graph':return a=['{'],a=a.concat(b(e.statements)),a.concat(['}']);case'Collection':for(a=['('],n=0;n<e.elements.length;n++)a.push([_(e.elements[n],t)]);return a.push(')'),a;default:return this.atomicTermToN3(e);}}function d(){var e='';for(var t in this.defaultNamespace&&(e+='@prefix : '+this.explicitURI(this.defaultNamespace)+'.\n'),this.prefixes)this.prefixes.hasOwnProperty(t)&&this.namespacesUsed[t]&&(e+='@prefix '+this.prefixes[t]+': '+this.explicitURI(t)+'.\n');return e+'\n'}var l=4,p=80,u=this.store,c={"http://www.w3.org/1999/02/22-rdf-syntax-ns#type":'aaa:00'},h=function e(t,n){return i.heavyCompareSPO(t,n,u,c)};e.sort(h),this.base&&!this.defaultNamespace&&(this.defaultNamespace=this.base+'#');var f={};0>this.flags.indexOf('s')&&(f['http://www.w3.org/2002/07/owl#sameAs']='='),0>this.flags.indexOf('t')&&(f['http://www.w3.org/1999/02/22-rdf-syntax-ns#type']='a'),0>this.flags.indexOf('i')&&(f['http://www.w3.org/2000/10/swap/log#implies']='=>');var g=function e(t){for(var n='',a=0;a<t;a++)n+=' ';return n},m=function e(t){for(var n='',a=0;a<t.length;a++){var r=t[a],o='string'==typeof r?r:e(r);if(0!==a){var i=n.slice(-1)||' ';','!==o&&';'!==o&&('.'!==o||'0123456789.'.includes(i))&&(n+=' ')}n+=o}return n},y=function e(t,n){var a='',r=1e5;n===void 0&&(n=-1);for(var o=0,i;o<t.length;o++){if(i=t[o],'string'!=typeof i){var s=e(i,n+1);if(s.length<10*(p-l*n)&&0>s.indexOf('"""')){var d=m(i);d.length<p-l*n&&(i=d,s='')}s&&(r=1e4),a+=s}if('string'==typeof i){if(1===i.length&&'\n'===a.slice(-1)&&0<=',.;'.indexOf(i)){a=a.slice(0,-1)+i+'\n',r+=1;continue}if(r<l*n+4||r+i.length+1<p&&0>';.'.indexOf(a[a.length-2]))a=a.slice(0,-1)+' '+i+'\n',r+=i.length+1;else{var u=g(l*n)+i;a+=u+'\n',r=u.length,0>n&&(a+='\n',r=1e5)}}}return a},b=t.bind(this),x=r.bind(this),_=o.bind(this);n.prototype.termToN3=v;var v=s.bind(this),w=d.bind(this),k=b(e);return w()+y(k)},n.prototype.atomicTermToN3=function e(t,n){switch(t.termType){case'BlankNode':case'Variable':return t.toNT();case'Literal':var a=t.value;if('string'!=typeof a)throw new TypeError('Value of RDF literal node must be a string');if(t.datatype&&0>this.flags.indexOf('x'))switch(t.datatype.uri){case'http://www.w3.org/2001/XMLSchema#integer':return a;case'http://www.w3.org/2001/XMLSchema#decimal':return 0>a.indexOf('.')&&(a+='.0'),a;case'http://www.w3.org/2001/XMLSchema#double':return 0>a.indexOf('.')&&(a+='.0'),0>a.indexOf('e')&&(a+='e0'),a;case'http://www.w3.org/2001/XMLSchema#boolean':return'1'===t.value?'true':'false';}var r=this.stringToN3(t.value);return t.language?r+='@'+t.language:!t.datatype.equals(s.string)&&(r+='^^'+this.atomicTermToN3(t.datatype,n)),r;case'NamedNode':return this.symbolToN3(t);default:throw new Error('Internal: atomicTermToN3 cannot handle '+t+' of termType: '+t.termType);}},n.prototype.validPrefix=new RegExp(/^[a-zA-Z][a-zA-Z0-9]*$/),n.prototype.forbidden1=new RegExp(/[\\"\b\f\r\v\t\n\u0080-\uffff]/gm),n.prototype.forbidden3=new RegExp(/[\\"\b\f\r\v\u0080-\uffff]/gm),n.prototype.stringToN3=function e(t,a){a||(a='e');var r='',o,i,s,d,l;for(20<t.length&&'"'!==t.slice(-1)&&0>a.indexOf('n')&&(0<t.indexOf('\n')||0<t.indexOf('"'))?(d='"""',l=n.prototype.forbidden3):(d='"',l=n.prototype.forbidden1),o=0;o<t.length;){l.lastIndex=0;var p=l.exec(t.slice(o));if(null==p)break;i=o+l.lastIndex-1,r+=t.slice(o,i);var u=t[i];'"'===u&&'"""'===d&&'"""'!==t.slice(i,i+3)?r+=u:(s='\b\f\r\t\x0B\n\\"'.indexOf(u),r+=0<=s?'\\'+'bfrtvn\\"'[s]:0<=a.indexOf('e')?'\\u'+('000'+u.charCodeAt(0).toString(16).toLowerCase()).slice(-4):u),o=i+1}return d+r+t.slice(o)+d},n.prototype.symbolToN3=function e(t){var a=t.uri,r=a.indexOf('#');if(0>r&&0>this.flags.indexOf('/')&&(r=a.lastIndexOf('/')),0<=r&&0>this.flags.indexOf('p')&&(0===a.indexOf('http')||0===a.indexOf('ws')||0===a.indexOf('file'))){for(var o=!0,i=r+1;i<a.length;i++)if(0<=n.prototype._notNameChars.indexOf(a[i])){o=!1;break}if(o){var s=a.slice(r+1),d=a.slice(0,r+1);if(this.defaultNamespace&&this.defaultNamespace===d&&0>this.flags.indexOf('d'))return 0<=this.flags.indexOf('k')&&0>this.keyords.indexOf(s)?s:':'+s;var l=this.prefixes[d];if(l||(l=this.makeUpPrefix(d)),l)return this.namespacesUsed[d]=!0,l+':'+s}}return this.explicitURI(a)},n.prototype.writeStore=function(e){var t=this.store,n=t.fetcher,a=n&&n.appNode,r=this.store.index[3];for(var o in r){var i=t.fromNT(o);a&&i.sameTerm(a)||e('\n'+this.atomicTermToN3(i)+' '+this.atomicTermToN3(t.sym('http://www.w3.org/2000/10/swap/log#semantics'))+' { '+this.statementsToN3(t.statementsMatching(void 0,void 0,void 0,i))+' }.\n')}t.statementsMatching(void 0,t.sym('http://www.w3.org/2007/ont/link#requestedURI')).map(function(n){e('\n<'+n.object.value+'> log:metadata {\n');var a=t.statementsMatching(void 0,void 0,void 0,n.subject);e(this.statementsToN3(this.statementsToN3(a))),e('}.\n')});var s=[];a&&s.push(a);var d=[];s.map(function(e){d=d.concat(t.statementsMatching(void 0,void 0,void 0,e))}),e(this.statementsToN3(d))},n.prototype.statementsToXML=function(e){function t(e){this.suggestPrefix('rdf','http://www.w3.org/1999/02/22-rdf-syntax-ns#');for(var t=this.rootSubjects(e),n=t.roots,a=[],r=0,o;r<n.length;r++)o=n[r],a.push(v(o,t));return a}function r(e){return'undefined'==typeof e?'@@@undefined@@@@':e.replace(/[&<"]/g,function(e){switch(e[0]){case'&':return'&';case'<':return'<';case'"':return'"';}})}function o(e){return r(this.base?i.uri.refTo(this.base,e.uri):e.uri)}function d(e,n){var o=[],d=n.subjects[this.toStr(e)],p,u,t,c;if('undefined'==typeof d)return w(e,n);d.sort(function(e,t){var n=e.predicate.uri,a=t.predicate.uri;if(n.substring(0,g.length)===g||a.substring(0,g.length)===g)return n.localeCompare(a);var r=n.substring(g.length),o=a.substring(g.length),i=parseInt(r,10),s=parseInt(o,10);return isNaN(i)||isNaN(s)||i!==r||s!==o?n.localeCompare(a):i-s});for(var h=0;h<d.length;h++){if(t=d[h],'http://www.w3.org/1999/02/22-rdf-syntax-ns#type'===t.predicate.uri&&!p&&'symbol'===t.object.termType){p=t.object;continue}if(c=t.predicate,c.uri.substr(0,g.length)===g){var i=c.uri.substr(g.length),f=parseInt(i,10);i===f.toString()&&(c=new a('http://www.w3.org/1999/02/22-rdf-syntax-ns#li'))}switch(u=k(c),t.object.termType){case'BlankNode':o=1===n.incoming[t.object].length?o.concat(['<'+u+' rdf:parseType="Resource">',v(t.object,n),'</'+u+'>']):o.concat(['<'+u+' rdf:nodeID="'+t.object.toNT().slice(2)+'"/>']);break;case'NamedNode':o=o.concat(['<'+u+' rdf:resource="'+_(t.object)+'"/>']);break;case'Literal':o=o.concat(['<'+u+(t.object.datatype.equals(s.string)?'':' rdf:datatype="'+r(t.object.datatype.uri)+'"')+(t.object.language?' xml:lang="'+t.object.language+'"':'')+'>'+r(t.object.value)+'</'+u+'>']);break;case'Collection':o=o.concat(['<'+u+' rdf:parseType="Collection">',l(t.object,n),'</'+u+'>']);break;default:throw new Error('Can\'t serialize object of type '+t.object.termType+' into XML');}}var m=p?k(p):'rdf:Description',y='';return'BlankNode'===e.termType?(!n.incoming[e]||1!==n.incoming[e].length)&&(y=' rdf:nodeID="'+e.toNT().slice(2)+'"'):y=' rdf:about="'+_(e)+'"',['<'+m+y+'>'].concat([o]).concat(['</'+m+'>'])}function l(e,t){for(var n=[],a=0;a<e.elements.length;a++)n.push(v(e.elements[a],t));return n}function p(e,t){var n=[],a=t.subjects[this.toStr(e)];if(!a)return n;a.sort();for(var o=0,i;o<a.length;o++)switch(i=a[o],i.object.termType){case'BlankNode':n=t.rootsHash[i.object.toNT()]?n.concat(['<'+k(i.predicate)+' rdf:nodeID="'+i.object.toNT().slice(2)+'">','</'+k(i.predicate)+'>']):n.concat(['<'+k(i.predicate)+' rdf:parseType="Resource">',w(i.object,t),'</'+k(i.predicate)+'>']);break;case'NamedNode':n=n.concat(['<'+k(i.predicate)+' rdf:resource="'+_(i.object)+'"/>']);break;case'Literal':n=n.concat(['<'+k(i.predicate)+(i.object.datatype.equals(s.string)?'':' rdf:datatype="'+r(i.object.datatype.value)+'"')+(i.object.language?' xml:lang="'+i.object.language+'"':'')+'>'+r(i.object.value)+'</'+k(i.predicate)+'>']);break;case'Collection':n=n.concat(['<'+k(i.predicate)+' rdf:parseType="Collection">',l(i.object,t),'</'+k(i.predicate)+'>']);break;default:throw new Error('Can\'t serialize object of type '+i.object.termType+' into XML');}return n}function u(e){var t=e.uri,a=t.indexOf('#');if(0>a&&0>this.flags.indexOf('/')&&(a=t.lastIndexOf('/')),0>a)throw new Error('Cannot make qname out of <'+t+'>');for(var r=a+1;r<t.length;r++)if(0<=n.prototype._notNameChars.indexOf(t[r]))throw new Error('Invalid character "'+t[r]+'" cannot be in XML qname for URI: '+t);var o=t.slice(a+1),i=t.slice(0,a+1);if(this.defaultNamespace&&this.defaultNamespace===i&&0>this.flags.indexOf('d'))return o;var s=this.prefixes[i];return s||(s=this.makeUpPrefix(i)),f[i]=!0,s+':'+o}var c=4,h=80,f=[];f['http://www.w3.org/1999/02/22-rdf-syntax-ns#']=!0;var g='http://www.w3.org/1999/02/22-rdf-syntax-ns#_',m=function e(t){for(var n='',a=0;a<t;a++)n+=' ';return n},y=function e(t){for(var n='',a=0;a<t.length;a++){var r=t[a],o='string'==typeof r?r:e(r);n+=o}return n},b=function e(t,n){var a='',r=1e5,o;n||(n=0);for(var s=0,i;s<t.length;s++){if(i=t[s],'string'!=typeof i){var d=e(i,n+1);d.length<10*(h-c*n)&&0>d.indexOf('"""')&&(o=y(i),o.length<h-c*n&&(i=' '+o,d='')),d&&(r=1e4),a+=d}'string'==typeof i&&(r<c*n+4?(a=a.slice(0,-1)+' '+i+'\n',r+=i.length+1):(o=m(c*n)+i,a+=o+'\n',r=o.length))}return a},x=t.bind(this),_=o.bind(this),v=d.bind(this),w=p.bind(this),k=u.bind(this),T=x(e),N='<rdf:RDF';for(var I in this.defaultNamespace&&(N+=' xmlns="'+r(this.defaultNamespace)+'"'),f)if(f.hasOwnProperty(I)){var S=this.base&&this.flags.includes('z')?i.uri.refTo(this.base,I):I;N+='\n xmlns:'+this.prefixes[I]+'="'+r(S)+'"'}N+='>';var j=[N,T,'</rdf:RDF>'];return b(j,-1)};var d=function e(t){return new n(t)};return d}();e.exports=d},function(e,t,n){function a(e,t){if(!(e instanceof t))throw new TypeError('Cannot call a class as a function')}function r(e,t){for(var n=0,a;n<t.length;n++)a=t[n],a.enumerable=a.enumerable||!1,a.configurable=!0,'value'in a&&(a.writable=!0),Object.defineProperty(e,a.key,a)}function o(e,t,n){return t&&r(e.prototype,t),n&&r(e,n),e}var i=n(6),s=n(11),d=n(20),l=n(0),p=n(2),u=n(4);if('undefined'==typeof c)var c={ELEMENT_NODE:1,ATTRIBUTE_NODE:2,TEXT_NODE:3,CDATA_SECTION_NODE:4,ENTITY_REFERENCE_NODE:5,ENTITY_NODE:6,PROCESSING_INSTRUCTION_NODE:7,COMMENT_NODE:8,DOCUMENT_NODE:9,DOCUMENT_TYPE_NODE:10,DOCUMENT_FRAGMENT_NODE:11,NOTATION_NODE:12};var h=function(){function e(t,n){a(this,e),this.options=n||{},this.kb=t,this.target=n.target||{graph:{subjects:{},prefixes:{},terms:{}}},this.blankNodes=[],this.htmlOptions={selfClosing:'br img input area base basefont col colgroup source wbr isindex link meta param hr'},this.theOne='_:'+new Date().getTime(),this.language=null,this.vocabulary=null,this.blankCounter=0,this.langAttributes=[{namespaceURI:'http://www.w3.org/XML/1998/namespace',localName:'lang'}],this.inXHTMLMode=!1,this.absURIRE=/[\w\_\-]+:\S+/,this.finishedHandlers=[],this.init()}return o(e,[{key:'addTriple',value:function e(t,n,a,r){var o,i,s,l;o='undefined'==typeof n?d.namedNode(this.options.base):this.toRDFNodeObject(n),s=this.toRDFNodeObject(a),i=this.toRDFNodeObject(r),l=d.namedNode(this.options.base),this.kb.add(o,s,i,l)}},{key:'ancestorPath',value:function e(t){for(var n='';t&&t.nodeType!==c.DOCUMENT_NODE;)n='/'+t.localName+n,t=t.parentNode;return n}},{key:'copyMappings',value:function e(t){var n={};for(var a in t)n[a]=t[a];return n}},{key:'copyProperties',value:function e(){}},{key:'deriveDateTimeType',value:function t(n){for(var a=0,r;a<e.dateTimeTypes.length;a++)if(r=e.dateTimeTypes[a].pattern.exec(n),r&&r[0].length===n.length)return e.dateTimeTypes[a].type;return null}},{key:'init',value:function e(){}},{key:'newBlankNode',value:function e(){return this.blankCounter++,'_:'+this.blankCounter}},{key:'newSubjectOrigin',value:function e(t,n){}},{key:'parseCURIE',value:function t(n,a,r){var o=n.indexOf(':'),i;if(0<=o){var s=n.substring(0,o);if(''===s)return i=a[''],i?i+n.substring(o+1):null;if('_'===s)return'_:'+n.substring(o+1);if(e.NCNAME.test(s)&&(i=a[s],i))return i+n.substring(o+1)}return null}},{key:'parseCURIEOrURI',value:function e(t,n,a){var r=this.parseCURIE(t,n,a);return r?r:this.resolveAndNormalize(a,t)}},{key:'parsePredicate',value:function e(t,n,a,r,o,i){if(''===t)return null;var s=this.parseTermOrCURIEOrAbsURI(t,n,i?null:a,r,o);return s&&0===s.indexOf('_:')?null:s}},{key:'parsePrefixMappings',value:function e(t,n){for(var a=this.tokenize(t),r=null,o=0;o<a.length;o++)':'===a[o][a[o].length-1]?r=a[o].substring(0,a[o].length-1):r&&(n[r]=this.options.base?p.join(a[o],this.options.base):a[o],r=null)}},{key:'parseSafeCURIEOrCURIEOrURI',value:function e(t,n,a){return t=this.trim(t),'['===t.charAt(0)&&']'===t.charAt(t.length-1)?(t=t.substring(1,t.length-1),t=t.trim(t),0===t.length?null:'_:'===t?this.theOne:this.parseCURIE(t,n,a)):this.parseCURIEOrURI(t,n,a)}},{key:'parseTermOrCURIEOrAbsURI',value:function e(t,n,a,r,o){t=this.trim(t);var i=this.parseCURIE(t,r,o);if(i)return i;if(a){if(n&&!this.absURIRE.exec(t))return n+t;var s=a[t];if(s)return s;var d=t.toLowerCase();if(s=a[d],s)return s}return this.absURIRE.exec(t)?this.resolveAndNormalize(o,t):null}},{key:'parseTermOrCURIEOrURI',value:function e(t,n,a,r,o){t=this.trim(t);var i=this.parseCURIE(t,r,o);if(i)return i;var s=a[t];if(s)return s;var d=t.toLowerCase();return(s=a[d],s)?s:n&&!this.absURIRE.exec(t)?n+t:this.resolveAndNormalize(o,t)}},{key:'parseURI',value:function e(t){return t}},{key:'process',value:function t(n,a){var r;n.nodeType===c.DOCUMENT_NODE?(r=n.baseURI,n=n.documentElement,n.baseURI=r,this.setContext(n)):n.parentNode.nodeType===c.DOCUMENT_NODE&&this.setContext(n);var o=[],s=function e(t){if(!t&&a&&a.baseURI)return a.baseURI;var n=t.indexOf('#');return 0<=n&&(t=t.substring(0,n)),a&&a.baseURIMap&&(t=a.baseURIMap(t)),t};for(o.push({current:n,context:this.push(null,s(n.baseURI))});0<o.length;){var d=o.shift();if(d.parent){if(d.context.parent&&d.context.parent.listMapping===d.listMapping)continue;for(var l in d.listMapping){var u=d.listMapping[l];if(0===u.length){this.addTriple(d.parent,d.subject,l,{type:e.objectURI,value:'http://www.w3.org/1999/02/22-rdf-syntax-ns#nil'});continue}for(var h=[],f=0;f<u.length;f++)h.push(this.newBlankNode());for(var g=0;g<h.length;g++)this.addTriple(d.parent,h[g],'http://www.w3.org/1999/02/22-rdf-syntax-ns#first',u[g]),this.addTriple(d.parent,h[g],'http://www.w3.org/1999/02/22-rdf-syntax-ns#rest',{type:e.objectURI,value:g+1<h.length?h[g+1]:'http://www.w3.org/1999/02/22-rdf-syntax-ns#nil'});this.addTriple(d.parent,d.subject,l,{type:e.objectURI,value:h[0]})}continue}var m=d.current,y=d.context,b=!1,x=null,_=null,v=null,w=y.prefixes,k=!1,T=[],N=y.listMapping,I=!y.parent,S=y.language,j=y.vocabulary;r=this.parseURI(s(m.baseURI)),m.item=null;var R=m.getAttributeNode('vocab');if(R){var C=this.trim(R.value);if(0<C.length){j=C;var L=r.spec;this.addTriple(m,L,'http://www.w3.org/ns/rdfa#usesVocabulary',{type:e.objectURI,value:j})}else j=this.vocabulary}for(var O=0,i;O<m.attributes.length;O++)if(i=m.attributes[O],'x'===i.nodeName.charAt(0)&&0===i.nodeName.indexOf('xmlns:')){k||(w=this.copyMappings(w),k=!0);var E=i.nodeName.substring(6),D=e.trim(i.value);w[E]=this.options.base?p.join(D,this.options.base):D}var U=m.getAttributeNode('prefix');U&&(!k&&(w=this.copyMappings(w),k=!0),this.parsePrefixMappings(U.value,w));for(var A=null,P=0;!A&&P<this.langAttributes.length;P++)A=m.getAttributeNodeNS(this.langAttributes[P].namespaceURI,this.langAttributes[P].localName);if(A){var M=e.trim(A.value);S=0<M.length?M:null}var F=m.getAttributeNode('rel'),B=m.getAttributeNode('rev'),q=m.getAttributeNode('typeof'),H=m.getAttributeNode('property'),z=m.getAttributeNode('datatype'),V=this.inHTMLMode?m.getAttributeNode('datetime'):null,X=m.getAttributeNode('content'),W=m.getAttributeNode('about'),J=m.getAttributeNode('src'),Y=m.getAttributeNode('resource'),Q=m.getAttributeNode('href'),G=m.getAttributeNode('inlist'),K=[],Z,ee;if(F){ee=this.tokenize(F.value);for(var te=0;te<ee.length;te++)Z=this.parsePredicate(ee[te],j,y.terms,w,r,this.inHTMLMode&&null!==H),Z&&K.push(Z)}var ne=[];if(B){ee=this.tokenize(B.value);for(var ae=0;ae<ee.length;ae++)Z=this.parsePredicate(ee[ae],j,y.terms,w,r,this.inHTMLMode&&H),Z&&ne.push(Z)}if(this.inHTMLMode&&(F||B)&&H&&(0===K.length&&(F=null),0===ne.length&&(B=null)),F||B?(W&&(x=this.parseSafeCURIEOrCURIEOrURI(W.value,w,r)),q&&(v=x),!x&&(m.parentNode.nodeType===c.DOCUMENT_NODE?x=s(m.baseURI):y.parentObject&&(x=s(m.parentNode.baseURI)===y.parentObject?s(m.baseURI):y.parentObject)),Y&&(_=this.parseSafeCURIEOrCURIEOrURI(Y.value,w,r)),!_&&(Q?_=this.resolveAndNormalize(r,encodeURI(Q.value)):J?_=this.resolveAndNormalize(r,encodeURI(J.value)):q&&!W&&!(this.inXHTMLMode&&('head'===m.localName||'body'===m.localName))&&(_=this.newBlankNode())),q&&!W&&this.inXHTMLMode&&('head'===m.localName||'body'===m.localName)?v=x:q&&!W&&(v=_)):!H||X||z?(W&&(x=this.parseSafeCURIEOrCURIEOrURI(W.value,w,r)),!x&&Y&&(x=this.parseSafeCURIEOrCURIEOrURI(Y.value,w,r)),!x&&Q&&(x=this.resolveAndNormalize(r,encodeURI(Q.value))),!x&&J&&(x=this.resolveAndNormalize(r,encodeURI(J.value))),!x&&(m.parentNode.nodeType===c.DOCUMENT_NODE?x=s(m.baseURI):(this.inXHTMLMode||this.inHTMLMode)&&('head'===m.localName||'body'===m.localName)?x=s(m.parentNode.baseURI)===y.parentObject?s(m.baseURI):y.parentObject:q?x=this.newBlankNode():y.parentObject&&(x=s(m.parentNode.baseURI)===y.parentObject?s(m.baseURI):y.parentObject,!H&&(b=!0))),q&&(v=x)):(W&&(x=this.parseSafeCURIEOrCURIEOrURI(W.value,w,r),q&&(v=x)),x||m.parentNode.nodeType!==c.DOCUMENT_NODE?!x&&y.parentObject&&(x=s(m.parentNode.baseURI)===y.parentObject?s(m.baseURI):y.parentObject):(x=s(m.baseURI),q&&(v=x)),q&&!v&&(Y&&(v=this.parseSafeCURIEOrCURIEOrURI(Y.value,w,r)),!v&&Q&&(v=this.resolveAndNormalize(r,encodeURI(Q.value))),!v&&J&&(v=this.resolveAndNormalize(r,encodeURI(J.value))),!v&&(this.inXHTMLMode||this.inHTMLMode)&&('head'===m.localName||'body'===m.localName)&&(v=x),!v&&(v=this.newBlankNode()),_=v)),x&&(W||Y||v)){var re=x;q&&!W&&!Y&&_&&(re=_),this.newSubjectOrigin(m,re)}if(v){ee=this.tokenize(q.value);for(var oe=0,ie;oe<ee.length;oe++)ie=this.parseTermOrCURIEOrAbsURI(ee[oe],j,y.terms,w,r),ie&&this.addTriple(m,v,e.typeURI,{type:e.objectURI,value:ie})}if(x&&x!==y.parentObject&&(N={},I=!0),_){if(F&&G)for(var se=0,de;se<K.length;se++)de=N[K[se]],de||(de=[],N[K[se]]=de),de.push({type:e.objectURI,value:_});else if(F)for(var le=0;le<K.length;le++)this.addTriple(m,x,K[le],{type:e.objectURI,value:_});if(B)for(var pe=0;pe<ne.length;pe++)this.addTriple(m,_,ne[pe],{type:e.objectURI,value:x})}else{if(x&&!_&&(F||B)&&(_=this.newBlankNode()),F&&G)for(var ue=0,ce;ue<K.length;ue++)ce=N[K[ue]],ce||(ce=[],N[Z]=ce),T.push({predicate:K[ue],list:ce});else if(F)for(var he=0;he<K.length;he++)T.push({predicate:K[he],forward:!0});if(B)for(var fe=0;fe<ne.length;fe++)T.push({predicate:ne[fe],forward:!1})}if(H){var ge=null,me=null;z?(ge=''===z.value?e.PlainLiteralURI:this.parseTermOrCURIEOrAbsURI(z.value,j,y.terms,w,r),me=V&&!X?V.value:ge===e.XMLLiteralURI||ge===e.HTMLLiteralURI?null:X?X.value:m.textContent):X?(ge=e.PlainLiteralURI,me=X.value):V?(me=V.value,ge=e.deriveDateTimeType(me),!ge&&(ge=e.PlainLiteralURI)):!F&&!B&&(Y&&(me=this.parseSafeCURIEOrCURIEOrURI(Y.value,w,r)),!me&&Q?me=this.resolveAndNormalize(r,encodeURI(Q.value)):!me&&J&&(me=this.resolveAndNormalize(r,encodeURI(J.value))),me&&(ge=e.objectURI)),ge||(q&&!W?(ge=e.objectURI,me=v):(me=m.textContent,this.inHTMLMode&&'time'===m.localName&&(ge=e.deriveDateTimeType(me)),!ge&&(ge=e.PlainLiteralURI))),ee=this.tokenize(H.value);for(var ye=0,be;ye<ee.length;ye++)if(be=this.parsePredicate(ee[ye],j,y.terms,w,r),be)if(G){var xe=N[be];xe||(xe=[],N[be]=xe),xe.push(ge===e.XMLLiteralURI||ge===e.HTMLLiteralURI?{type:ge,value:m.childNodes}:{type:ge?ge:e.PlainLiteralURI,value:me,language:S})}else ge===e.XMLLiteralURI||ge===e.HTMLLiteralURI?this.addTriple(m,x,be,{type:ge,value:m.childNodes}):this.addTriple(m,x,be,{type:ge?ge:e.PlainLiteralURI,value:me,language:S})}if(x&&!b)for(var _e=0;_e<y.incomplete.length;_e++)y.incomplete[_e].list?y.incomplete[_e].list.push({type:e.objectURI,value:x}):y.incomplete[_e].forward?this.addTriple(m,y.subject,y.incomplete[_e].predicate,{type:e.objectURI,value:x}):this.addTriple(m,x,y.incomplete[_e].predicate,{type:e.objectURI,value:y.subject});var ve=null,we=x;b?(ve=this.push(y,y.subject),ve.parentObject=s(m.parentNode.baseURI)===y.parentObject?s(m.baseURI):y.parentObject,ve.incomplete=y.incomplete,ve.language=S,ve.prefixes=w,ve.vocabulary=j):(ve=this.push(y,x),ve.parentObject=_?_:x?x:y.subject,ve.prefixes=w,ve.incomplete=T,_&&(we=_,N={},I=!0),ve.listMapping=N,ve.language=S,ve.vocabulary=j),I&&o.unshift({parent:m,context:y,subject:we,listMapping:N});for(var ke=m.lastChild;ke;ke=ke.previousSibling)ke.nodeType===c.ELEMENT_NODE&&(ke.baseURI=m.baseURI,o.unshift({current:ke,context:ve}))}this.inHTMLMode&&this.copyProperties();for(var Te=0;Te<this.finishedHandlers.length;Te++)this.finishedHandlers[Te](n)}},{key:'push',value:function e(t,n){return{parent:t,subject:n?n:t?t.subject:null,parentObject:null,incomplete:[],listMapping:t?t.listMapping:{},language:t?t.language:this.language,prefixes:t?t.prefixes:this.target.graph.prefixes,terms:t?t.terms:this.target.graph.terms,vocabulary:t?t.vocabulary:this.vocabulary}}},{key:'resolveAndNormalize',value:function e(t,n){return p.join(n,t)}},{key:'setContext',value:function e(t){'html'===t.localName&&'XHTML+RDFa 1.1'===t.getAttribute('version')?this.setXHTMLContext():'html'===t.localName||'http://www.w3.org/1999/xhtml'===t.namespaceURI?'undefined'!=typeof document&&document.doctype?'-//W3C//DTD XHTML+RDFa 1.0//EN'===document.doctype.publicId&&'http://www.w3.org/MarkUp/DTD/xhtml-rdfa-1.dtd'===document.doctype.systemId?(console.log('WARNING: RDF 1.0 is not supported. Defaulting to HTML5 mode.'),this.setHTMLContext()):'-//W3C//DTD XHTML+RDFa 1.1//EN'===document.doctype.publicId&&'http://www.w3.org/MarkUp/DTD/xhtml-rdfa-2.dtd'===document.doctype.systemId?this.setXHTMLContext():this.setHTMLContext():this.setHTMLContext():this.setXMLContext()}},{key:'setHTMLContext',value:function e(){this.setInitialContext(),this.langAttributes=[{namespaceURI:'http://www.w3.org/XML/1998/namespace',localName:'lang'},{namespaceURI:null,localName:'lang'}],this.inXHTMLMode=!1,this.inHTMLMode=!0}},{key:'setInitialContext',value:function e(){this.vocabulary=null,this.langAttributes=[{namespaceURI:'http://www.w3.org/XML/1998/namespace',localName:'lang'}]}},{key:'setXHTMLContext',value:function e(){this.setInitialContext(),this.inXHTMLMode=!0,this.inHTMLMode=!1,this.langAttributes=[{namespaceURI:'http://www.w3.org/XML/1998/namespace',localName:'lang'},{namespaceURI:null,localName:'lang'}],this.target.graph.terms.alternate='http://www.w3.org/1999/xhtml/vocab#alternate',this.target.graph.terms.appendix='http://www.w3.org/1999/xhtml/vocab#appendix',this.target.graph.terms.bookmark='http://www.w3.org/1999/xhtml/vocab#bookmark',this.target.graph.terms.cite='http://www.w3.org/1999/xhtml/vocab#cite',this.target.graph.terms.chapter='http://www.w3.org/1999/xhtml/vocab#chapter',this.target.graph.terms.contents='http://www.w3.org/1999/xhtml/vocab#contents',this.target.graph.terms.copyright='http://www.w3.org/1999/xhtml/vocab#copyright',this.target.graph.terms.first='http://www.w3.org/1999/xhtml/vocab#first',this.target.graph.terms.glossary='http://www.w3.org/1999/xhtml/vocab#glossary',this.target.graph.terms.help='http://www.w3.org/1999/xhtml/vocab#help',this.target.graph.terms.icon='http://www.w3.org/1999/xhtml/vocab#icon',this.target.graph.terms.index='http://www.w3.org/1999/xhtml/vocab#index',this.target.graph.terms.last='http://www.w3.org/1999/xhtml/vocab#last',this.target.graph.terms.license='http://www.w3.org/1999/xhtml/vocab#license',this.target.graph.terms.meta='http://www.w3.org/1999/xhtml/vocab#meta',this.target.graph.terms.next='http://www.w3.org/1999/xhtml/vocab#next',this.target.graph.terms.prev='http://www.w3.org/1999/xhtml/vocab#prev',this.target.graph.terms.previous='http://www.w3.org/1999/xhtml/vocab#previous',this.target.graph.terms.section='http://www.w3.org/1999/xhtml/vocab#section',this.target.graph.terms.stylesheet='http://www.w3.org/1999/xhtml/vocab#stylesheet',this.target.graph.terms.subsection='http://www.w3.org/1999/xhtml/vocab#subsection',this.target.graph.terms.start='http://www.w3.org/1999/xhtml/vocab#start',this.target.graph.terms.top='http://www.w3.org/1999/xhtml/vocab#top',this.target.graph.terms.up='http://www.w3.org/1999/xhtml/vocab#up',this.target.graph.terms.p3pv1='http://www.w3.org/1999/xhtml/vocab#p3pv1',this.target.graph.terms.related='http://www.w3.org/1999/xhtml/vocab#related',this.target.graph.terms.role='http://www.w3.org/1999/xhtml/vocab#role',this.target.graph.terms.transformation='http://www.w3.org/1999/xhtml/vocab#transformation'}},{key:'setXMLContext',value:function e(){this.setInitialContext(),this.inXHTMLMode=!1,this.inHTMLMode=!1}},{key:'tokenize',value:function e(t){return this.trim(t).split(/\s+/)}},{key:'toRDFNodeObject',value:function t(n){if('undefined'!=typeof n){if('string'==typeof n)return'_:'===n.substring(0,2)?('undefined'==typeof this.blankNodes[n.substring(2)]&&(this.blankNodes[n.substring(2)]=new i(n.substring(2))),this.blankNodes[n.substring(2)]):d.namedNode(n);switch(n.type){case e.objectURI:return'_:'===n.value.substring(0,2)?('undefined'==typeof this.blankNodes[n.value.substring(2)]&&(this.blankNodes[n.value.substring(2)]=new i(n.value.substring(2))),this.blankNodes[n.value.substring(2)]):d.namedNode(n.value);case e.PlainLiteralURI:return new s(n.value,n.language||'');case e.XMLLiteralURI:case e.HTMLLiteralURI:var a='';return Object.keys(n.value).forEach(function(e){a+=u.domToString(n.value[e],this.htmlOptions)}),new s(a,'',new l(n.type));default:return new s(n.value,'',new l(n.type));}}}},{key:'trim',value:function e(t){return t.replace(/^\s\s*/,'').replace(/\s\s*$/,'')}}],[{key:'parseRDFaDOM',value:function t(n,a,r){var o=new e(a,{base:r});n.baseURI=r,o.process(n)}}]),e}();h.XMLLiteralURI='http://www.w3.org/1999/02/22-rdf-syntax-ns#XMLLiteral',h.HTMLLiteralURI='http://www.w3.org/1999/02/22-rdf-syntax-ns#HTML',h.PlainLiteralURI='http://www.w3.org/1999/02/22-rdf-syntax-ns#PlainLiteral',h.objectURI='http://www.w3.org/1999/02/22-rdf-syntax-ns#object',h.typeURI='http://www.w3.org/1999/02/22-rdf-syntax-ns#type',h.nameChar='[-A-Z_a-z\xC0-\xD6\xD8-\xF6\xF8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD\u10000-\uEFFFF.0-9\xB7\u0300-\u036F\u203F-\u2040]',h.nameStartChar='[A-Za-z\xC0-\xD6\xD8-\xF6\xF8-\xFF\u0100-\u0131\u0134-\u013E\u0141-\u0148\u014A-\u017E\u0180-\u01C3\u01CD-\u01F0\u01F4-\u01F5\u01FA-\u0217\u0250-\u02A8\u02BB-\u02C1\u0386\u0388-\u038A\u038C\u038E-\u03A1\u03A3-\u03CE\u03D0-\u03D6\u03DA\u03DC\u03DE\u03E0\u03E2-\u03F3\u0401-\u040C\u040E-\u044F\u0451-\u045C\u045E-\u0481\u0490-\u04C4\u04C7-\u04C8\u04CB-\u04CC\u04D0-\u04EB\u04EE-\u04F5\u04F8-\u04F9\u0531-\u0556\u0559\u0561-\u0586\u05D0-\u05EA\u05F0-\u05F2\u0621-\u063A\u0641-\u064A\u0671-\u06B7\u06BA-\u06BE\u06C0-\u06CE\u06D0-\u06D3\u06D5\u06E5-\u06E6\u0905-\u0939\u093D\u0958-\u0961\u0985-\u098C\u098F-\u0990\u0993-\u09A8\u09AA-\u09B0\u09B2\u09B6-\u09B9\u09DC-\u09DD\u09DF-\u09E1\u09F0-\u09F1\u0A05-\u0A0A\u0A0F-\u0A10\u0A13-\u0A28\u0A2A-\u0A30\u0A32-\u0A33\u0A35-\u0A36\u0A38-\u0A39\u0A59-\u0A5C\u0A5E\u0A72-\u0A74\u0A85-\u0A8B\u0A8D\u0A8F-\u0A91\u0A93-\u0AA8\u0AAA-\u0AB0\u0AB2-\u0AB3\u0AB5-\u0AB9\u0ABD\u0AE0\u0B05-\u0B0C\u0B0F-\u0B10\u0B13-\u0B28\u0B2A-\u0B30\u0B32-\u0B33\u0B36-\u0B39\u0B3D\u0B5C-\u0B5D\u0B5F-\u0B61\u0B85-\u0B8A\u0B8E-\u0B90\u0B92-\u0B95\u0B99-\u0B9A\u0B9C\u0B9E-\u0B9F\u0BA3-\u0BA4\u0BA8-\u0BAA\u0BAE-\u0BB5\u0BB7-\u0BB9\u0C05-\u0C0C\u0C0E-\u0C10\u0C12-\u0C28\u0C2A-\u0C33\u0C35-\u0C39\u0C60-\u0C61\u0C85-\u0C8C\u0C8E-\u0C90\u0C92-\u0CA8\u0CAA-\u0CB3\u0CB5-\u0CB9\u0CDE\u0CE0-\u0CE1\u0D05-\u0D0C\u0D0E-\u0D10\u0D12-\u0D28\u0D2A-\u0D39\u0D60-\u0D61\u0E01-\u0E2E\u0E30\u0E32-\u0E33\u0E40-\u0E45\u0E81-\u0E82\u0E84\u0E87-\u0E88\u0E8A\u0E8D\u0E94-\u0E97\u0E99-\u0E9F\u0EA1-\u0EA3\u0EA5\u0EA7\u0EAA-\u0EAB\u0EAD-\u0EAE\u0EB0\u0EB2-\u0EB3\u0EBD\u0EC0-\u0EC4\u0F40-\u0F47\u0F49-\u0F69\u10A0-\u10C5\u10D0-\u10F6\u1100\u1102-\u1103\u1105-\u1107\u1109\u110B-\u110C\u110E-\u1112\u113C\u113E\u1140\u114C\u114E\u1150\u1154-\u1155\u1159\u115F-\u1161\u1163\u1165\u1167\u1169\u116D-\u116E\u1172-\u1173\u1175\u119E\u11A8\u11AB\u11AE-\u11AF\u11B7-\u11B8\u11BA\u11BC-\u11C2\u11EB\u11F0\u11F9\u1E00-\u1E9B\u1EA0-\u1EF9\u1F00-\u1F15\u1F18-\u1F1D\u1F20-\u1F45\u1F48-\u1F4D\u1F50-\u1F57\u1F59\u1F5B\u1F5D\u1F5F-\u1F7D\u1F80-\u1FB4\u1FB6-\u1FBC\u1FBE\u1FC2-\u1FC4\u1FC6-\u1FCC\u1FD0-\u1FD3\u1FD6-\u1FDB\u1FE0-\u1FEC\u1FF2-\u1FF4\u1FF6-\u1FFC\u2126\u212A-\u212B\u212E\u2180-\u2182\u3041-\u3094\u30A1-\u30FA\u3105-\u312C\uAC00-\uD7A3\u4E00-\u9FA5\u3007\u3021-\u3029_]',h.NCNAME=new RegExp('^'+h.nameStartChar+h.nameChar+'*$'),h.dateTimeTypes=[{pattern:/-?P(?:[0-9]+Y)?(?:[0-9]+M)?(?:[0-9]+D)?(?:T(?:[0-9]+H)?(?:[0-9]+M)?(?:[0-9]+(?:\.[0-9]+)?S)?)?/,type:'http://www.w3.org/2001/XMLSchema#duration'},{pattern:/-?(?:[1-9][0-9][0-9][0-9]|0[1-9][0-9][0-9]|00[1-9][0-9]|000[1-9])-[0-9][0-9]-[0-9][0-9]T(?:[0-1][0-9]|2[0-4]):[0-5][0-9]:[0-5][0-9](?:\.[0-9]+)?(?:Z|[+\-][0-9][0-9]:[0-9][0-9])?/,type:'http://www.w3.org/2001/XMLSchema#dateTime'},{pattern:/-?(?:[1-9][0-9][0-9][0-9]|0[1-9][0-9][0-9]|00[1-9][0-9]|000[1-9])-[0-9][0-9]-[0-9][0-9](?:Z|[+\-][0-9][0-9]:[0-9][0-9])?/,type:'http://www.w3.org/2001/XMLSchema#date'},{pattern:/(?:[0-1][0-9]|2[0-4]):[0-5][0-9]:[0-5][0-9](?:\.[0-9]+)?(?:Z|[+\-][0-9][0-9]:[0-9][0-9])?/,type:'http://www.w3.org/2001/XMLSchema#time'},{pattern:/-?(?:[1-9][0-9][0-9][0-9]|0[1-9][0-9][0-9]|00[1-9][0-9]|000[1-9])-[0-9][0-9]/,type:'http://www.w3.org/2001/XMLSchema#gYearMonth'},{pattern:/-?[1-9][0-9][0-9][0-9]|0[1-9][0-9][0-9]|00[1-9][0-9]|000[1-9]/,type:'http://www.w3.org/2001/XMLSchema#gYear'}],e.exports=h},function(e,t,n){var a=n(2),r=function e(t){var e={};e.ns={RDF:'http://www.w3.org/1999/02/22-rdf-syntax-ns#',RDFS:'http://www.w3.org/2000/01/rdf-schema#'},e.nodeType={ELEMENT:1,ATTRIBUTE:2,TEXT:3,CDATA_SECTION:4,ENTITY_REFERENCE:5,ENTITY:6,PROCESSING_INSTRUCTION:7,COMMENT:8,DOCUMENT:9,DOCUMENT_TYPE:10,DOCUMENT_FRAGMENT:11,NOTATION:12},this.frameFactory=function(t,n,r){return{NODE:1,ARC:2,parent:n,parser:t,store:t.store,element:r,lastChild:0,base:null,lang:null,node:null,nodeType:null,listIndex:1,rdfid:null,datatype:null,collection:!1,terminateFrame:function e(){this.collection&&this.node.close()},addSymbol:function e(t,n){n=a.join(n,this.base),this.node=this.store.sym(n),this.nodeType=t},loadTriple:function t(){if(this.parent.parent.collection?this.parent.parent.node.append(this.node):this.store.add(this.parent.parent.node,this.parent.node,this.node,this.parser.why),null!=this.parent.rdfid){var n=this.store.sym(a.join('#'+this.parent.rdfid,this.base));this.store.add(n,this.store.sym(e.ns.RDF+'type'),this.store.sym(e.ns.RDF+'Statement'),this.parser.why),this.store.add(n,this.store.sym(e.ns.RDF+'subject'),this.parent.parent.node,this.parser.why),this.store.add(n,this.store.sym(e.ns.RDF+'predicate'),this.parent.node,this.parser.why),this.store.add(n,this.store.sym(e.ns.RDF+'object'),this.node,this.parser.why)}},isTripleToLoad:function e(){return null!=this.parent&&null!=this.parent.parent&&this.nodeType===this.NODE&&this.parent.nodeType===this.ARC&&this.parent.parent.nodeType===this.NODE},addNode:function e(t){this.addSymbol(this.NODE,t),this.isTripleToLoad()&&this.loadTriple()},addCollection:function e(){this.nodeType=this.NODE,this.node=this.store.collection(),this.collection=!0,this.isTripleToLoad()&&this.loadTriple()},addCollectionArc:function e(){this.nodeType=this.ARC},addBNode:function e(t){this.node=null==t?this.store.bnode():null==this.parser.bnodes[t]?this.parser.bnodes[t]=this.store.bnode():this.parser.bnodes[t],this.nodeType=this.NODE,this.isTripleToLoad()&&this.loadTriple()},addArc:function t(n){n===e.ns.RDF+'li'&&(n=e.ns.RDF+'_'+this.parent.listIndex,this.parent.listIndex++),this.addSymbol(this.ARC,n)},addLiteral:function e(t){this.node=this.parent.datatype?this.store.literal(t,'',this.store.sym(this.parent.datatype)):this.store.literal(t,this.lang),this.nodeType=this.NODE,this.isTripleToLoad()&&this.loadTriple()}}},this.getAttributeNodeNS=function(e,t,n){var a=null;if(e.getAttributeNodeNS)a=e.getAttributeNodeNS(t,n);else for(var r=e.attributes,o=0,i,s;o<r.length;++o)if(i=r[o],i.namespaceURI===t&&(s=i.prefix?i.prefix+':'+n:n,s===i.nodeName)){a=i;break}return a},this.store=t,this.bnodes={},this.why=null,this.reify=!1,this.parse=function(t,n,a){var r=t.childNodes;this.cleanParser();var o;if(t.nodeType===e.nodeType.DOCUMENT){for(var i=0;i<r.length;i++)if(r[i].nodeType===e.nodeType.ELEMENT){o=r[i];break}}else if(t.nodeType===e.nodeType.ELEMENT)o=t;else throw new Error('RDFParser: can\'t find root in '+n+'. Halting. ');this.why=a;var s=this.frameFactory(this);return this.base=n,s.base=n,s.lang=null,this.parseDOM(this.buildFrame(s,o)),!0},this.parseDOM=function(t){for(var n=function(e){var t='';if(null==e.namespaceURI)throw new Error('RDF/XML syntax error: No namespace for '+e.localName+' in '+this.base);return e.namespaceURI&&(t+=e.namespaceURI),e.localName?t+=e.localName:e.nodeName&&(0<=e.nodeName.indexOf(':')?t+=e.nodeName.split(':')[1]:t+=e.nodeName),t}.bind(this),r=!0,o;t.parent;){var i=t.element,s=i.attributes;if(i.nodeType===e.nodeType.TEXT||i.nodeType===e.nodeType.CDATA_SECTION)t.parent.nodeType===t.NODE&&(t.addArc(e.ns.RDF+'value'),t=this.buildFrame(t)),t.addLiteral(i.nodeValue);else if(n(i)!==e.ns.RDF+'RDF')if(t.parent&&t.parent.collection&&(t.addCollectionArc(),t=this.buildFrame(t,t.element),t.parent.element=null),!t.parent||!t.parent.nodeType||t.parent.nodeType===t.ARC){var d=this.getAttributeNodeNS(i,e.ns.RDF,'about');if(o=this.getAttributeNodeNS(i,e.ns.RDF,'ID'),d&&o)throw new Error('RDFParser: '+i.nodeName+' has both rdf:id and rdf:about. Halting. Only one of these properties may be specified on a node.');if(!d&&o)t.addNode('#'+o.nodeValue),i.removeAttributeNode(o);else if(null==d&&null==o){var l=this.getAttributeNodeNS(i,e.ns.RDF,'nodeID');l?(t.addBNode(l.nodeValue),i.removeAttributeNode(l)):t.addBNode()}else t.addNode(d.nodeValue),i.removeAttributeNode(d);var p=this.getAttributeNodeNS(i,e.ns.RDF,'type');e.ns.RDF+'Description'!==n(i)&&(p={nodeValue:n(i)}),null!=p&&(this.store.add(t.node,this.store.sym(e.ns.RDF+'type'),this.store.sym(a.join(p.nodeValue,t.base)),this.why),p.nodeName&&i.removeAttributeNode(p));for(var u=s.length-1;0<=u;u--)this.store.add(t.node,this.store.sym(n(s[u])),this.store.literal(s[u].nodeValue,t.lang),this.why)}else{t.addArc(n(i)),this.reify&&(o=this.getAttributeNodeNS(i,e.ns.RDF,'ID'),o&&(t.rdfid=o.nodeValue,i.removeAttributeNode(o)));var c=this.getAttributeNodeNS(i,e.ns.RDF,'parseType'),h=this.getAttributeNodeNS(i,e.ns.RDF,'datatype');if(h&&(t.datatype=h.nodeValue,i.removeAttributeNode(h)),c){var g=c.nodeValue;'Literal'===g?(t.datatype=e.ns.RDF+'XMLLiteral',t=this.buildFrame(t),t.addLiteral(i.childNodes),r=!1):'Resource'===g?(t=this.buildFrame(t,t.element),t.parent.element=null,t.addBNode()):'Collection'===g&&(t=this.buildFrame(t,t.element),t.parent.element=null,t.addCollection()),i.removeAttributeNode(c)}if(0!==s.length){var m=this.getAttributeNodeNS(i,e.ns.RDF,'resource'),y=this.getAttributeNodeNS(i,e.ns.RDF,'nodeID');t=this.buildFrame(t),m?(t.addNode(m.nodeValue),i.removeAttributeNode(m)):y?(t.addBNode(y.nodeValue),i.removeAttributeNode(y)):t.addBNode();for(var b=s.length-1,x;0<=b;b--)x=this.buildFrame(t),x.addArc(n(s[b])),n(s[b])===e.ns.RDF+'type'?this.buildFrame(x).addNode(s[b].nodeValue):this.buildFrame(x).addLiteral(s[b].nodeValue)}else 0===i.childNodes.length&&this.buildFrame(t).addLiteral('')}for(i=t.element;t.parent;){for(var f=t;null==i;)t=t.parent,i=t.element;var _=i.childNodes&&i.childNodes[t.lastChild];if(!_||!r){if(t.terminateFrame(),!(t=t.parent))break;i=t.element,r=!0}else if(_.nodeType!==e.nodeType.ELEMENT&&_.nodeType!==e.nodeType.TEXT&&_.nodeType!==e.nodeType.CDATA_SECTION||(_.nodeType===e.nodeType.TEXT||_.nodeType===e.nodeType.CDATA_SECTION)&&1!==i.childNodes.length)t.lastChild++;else{t.lastChild++,t=this.buildFrame(f,i.childNodes[t.lastChild-1]);break}}}},this.cleanParser=function(){this.bnodes={},this.why=null},this.buildFrame=function(t,n){var r=this.frameFactory(this,t,n);if(t&&(r.base=t.base,r.lang=t.lang),!n||n.nodeType===e.nodeType.TEXT||n.nodeType===e.nodeType.CDATA_SECTION)return r;var o=n.attributes,i=n.getAttributeNode('xml:base');null!=i&&(r.base=i.nodeValue,n.removeAttribute('xml:base'));var s=n.getAttributeNode('xml:lang');null!=s&&(r.lang=s.nodeValue,n.removeAttribute('xml:lang'));for(var d=o.length-1;0<=d;d--)if('xml'===o[d].nodeName.substr(0,3)){if('xmlns:'===o[d].name.slice(0,6)){var l=o[d].nodeValue;this.base&&(l=a.join(l,this.base)),this.store.setPrefixForURI(o[d].name.slice(6),l)}n.removeAttributeNode(o[d])}return r}};e.exports=r},function(e,t,n){function a(e,t){if(!(e instanceof t))throw new TypeError('Cannot call a class as a function')}var r=n(0),o=function e(){a(this,e)};o.boolean=new r('http://www.w3.org/2001/XMLSchema#boolean'),o.dateTime=new r('http://www.w3.org/2001/XMLSchema#dateTime'),o.decimal=new r('http://www.w3.org/2001/XMLSchema#decimal'),o.double=new r('http://www.w3.org/2001/XMLSchema#double'),o.integer=new r('http://www.w3.org/2001/XMLSchema#integer'),o.langString=new r('http://www.w3.org/1999/02/22-rdf-syntax-ns#langString'),o.string=new r('http://www.w3.org/2001/XMLSchema#string'),e.exports=o},function(e,t,n){function a(e,t){var n=s.Parser(),a=s.Writer({format:'N-Quads'}),r;o.waterfall([function(t){n.parse(e,t)},function(e,t,n){null!==e&&a.addTriple(e),'function'==typeof n&&a.end(n)},function(e,t){try{i.fromRDF(e,{format:'application/nquads'},t)}catch(e){t(e)}},function(e,n){r=JSON.stringify(e),t(null,r)}],function(e,n){t(e,r)})}function r(e,t){var n=s.Parser(),a=s.Writer({format:'N-Quads'}),r;o.waterfall([function(t){n.parse(e,t)},function(e,t,n){null!==e&&a.addTriple(e),'function'==typeof n&&a.end(n)},function(e,n){r=e,t(null,r)}],function(e,n){t(e,r)})}e.exports.convertToJson=a,e.exports.convertToNQuads=r;var o=n(61),i=n(39),s=n(42)},function(e,t,n){(function(a,o,i,s){var d,l;/** * A JavaScript implementation of the JSON-LD API. * * @author Dave Longley * * @license BSD 3-Clause License * Copyright (c) 2011-2015 Digital Bazaar, Inc. * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * Neither the name of the Digital Bazaar, Inc. nor the names of its * contributors may be used to endorse or promote products derived from * this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */(function(){var p='undefined'!=typeof a&&a.versions&&a.versions.node,u=!p&&('undefined'!=typeof window||'undefined'!=typeof self);u&&'undefined'==typeof o&&('undefined'==typeof window?'undefined'==typeof self?'undefined'!=typeof $&&(o=$):o=self:o=window);var c=function(t){function e(){}function d(e){for(var t=[],n=Object.keys(e).sort(),a=0;a<n.length;++a){var r=n[a],o=e[r];H(o)||(o=[o]);for(var i=0,s;i<o.length;++i)if(s=o[i],null!==s){if(!V(s))throw new De('Invalid JSON-LD syntax; language map values must be strings.','jsonld.SyntaxError',{code:'invalid language map value',languageMap:e});t.push({"@value":s,"@language":r.toLowerCase()})}}return t}function l(e,t){if(H(t))for(var n=0;n<t.length;++n)t[n]=l(e,t[n]);else if(ee(t))t['@list']=l(e,t['@list']);else if(B(t)){te(t)&&(t['@id']=e.getId(t['@id']));for(var a=Object.keys(t).sort(),r=0,o;r<a.length;++r)o=a[r],'@id'!==o&&(t[o]=l(e,t[o]))}return t}function c(e,n,a){if(null===a||void 0===a)return null;var r=U(e,n,{vocab:!0});if('@id'===r)return U(e,a,{base:!0});if('@type'===r)return U(e,a,{vocab:!0,base:!0});var o=t.getContextValue(e,n,'@type');if('@id'===o||'@graph'===r&&V(a))return{"@id":U(e,a,{base:!0})};if('@vocab'===o)return{"@id":U(e,a,{vocab:!0,base:!0})};if(F(r))return a;var i={};if(null!==o)i['@type']=o;else if(V(a)){var s=t.getContextValue(e,n,'@language');null!==s&&(i['@language']=s)}return-1===['boolean','number','string'].indexOf(typeof a)&&(a=a.toString()),i['@value']=a,i}function h(e,t,n){for(var a=[],r=Object.keys(e).sort(),o=0;o<r.length;++o)for(var i=r[o],s=e[i],d=Object.keys(s).sort(),l=0;l<d.length;++l){var p=d[l],u=s[p];if('@type'===p)p=Se;else if(F(p))continue;for(var c=0;c<u.length;++c){var h=u[c],m={};if(m.type=0===i.indexOf('_:')?'blank node':'IRI',m.value=i,!!ne(i)){var y={type:0===p.indexOf('_:')?'blank node':'IRI',value:p};if(ne(p)&&('blank node'!==y.type||n.produceGeneralizedRdf))if(ee(h))f(h['@list'],t,m,y,a);else{var b=g(h);b&&a.push({subject:m,predicate:y,object:b})}}}}return a}function f(e,t,n,a,r){for(var o={type:'IRI',value:Te},s={type:'IRI',value:Ne},d={type:'IRI',value:Ie},l=0;l<e.length;++l){var i=e[l],p={type:'blank node',value:t.getId()};r.push({subject:n,predicate:a,object:p}),n=p,a=o;var u=g(i);u&&r.push({subject:n,predicate:a,object:u}),a=s}r.push({subject:n,predicate:a,object:d})}function g(e){var t={};if(Z(e)){t.type='literal';var n=e['@value'],a=e['@type']||null;Y(n)?(t.value=n.toString(),t.datatype=a||be):W(n)||a===xe?(!W(n)&&(n=parseFloat(n)),t.value=n.toExponential(15).replace(/(\d)0*e\+?/,'$1E'),t.datatype=a||xe):X(n)?(t.value=n.toFixed(0),t.datatype=a||_e):'@language'in e?(t.value=n,t.datatype=a||Le,t.language=e['@language']):(t.value=n,t.datatype=a||ve)}else{var r=B(e)?e['@id']:e;t.type=0===r.indexOf('_:')?'blank node':'IRI',t.value=r}return'IRI'!==t.type||ne(t.value)?t:null}function m(e,t){if('IRI'===e.type||'blank node'===e.type)return{"@id":e.value};var n={"@value":e.value};if(e.language)n['@language']=e.language;else{var a=e.datatype;if(a||(a=ve),t){if(a===be)'true'===n['@value']?n['@value']=!0:'false'===n['@value']&&(n['@value']=!1);else if(J(n['@value']))if(a===_e){var r=parseInt(n['@value'],10);r.toFixed(0)===n['@value']&&(n['@value']=r)}else a===xe&&(n['@value']=parseFloat(n['@value']));-1===[be,_e,xe,ve].indexOf(a)&&(n['@type']=a)}else a!==ve&&(n['@type']=a)}return n}function y(e,t){for(var n=['subject','predicate','object'],a=0,r;a<n.length;++a)if(r=n[a],e[r].type!==t[r].type||e[r].value!==t[r].value)return!1;return e.object.language===t.object.language&&e.object.datatype===t.object.datatype}function b(e,n,a,r,s,d){if(H(e)){for(var l=0;l<e.length;++l)b(e[l],n,a,r,void 0,d);return}if(!B(e))return void(d&&d.push(e));if(Z(e)){if('@type'in e){var i=e['@type'];0===i.indexOf('_:')&&(e['@type']=i=r.getId(i))}return void(d&&d.push(e))}if('@type'in e)for(var p=e['@type'],l=0,i;l<p.length;++l)i=p[l],0===i.indexOf('_:')&&r.getId(i);Q(s)&&(s=te(e)?r.getId(e['@id']):e['@id']),d&&d.push({"@id":s});var u=n[a],c=u[s]=u[s]||{};c['@id']=s;for(var h=Object.keys(e).sort(),f=0,m;f<h.length;++f)if(m=h[f],'@id'!==m){if('@reverse'===m){var y={"@id":s},x=e['@reverse'];for(var _ in x)for(var v=x[_],w=0;w<v.length;++w){var k=v[w],T=k['@id'];te(k)&&(T=r.getId(T)),b(k,n,a,r,T),t.addValue(u[T],_,y,{propertyIsArray:!0,allowDuplicate:!1})}continue}if('@graph'===m){s in n||(n[s]={});var N='@merged'===a?a:s;b(e[m],n,N,r);continue}if('@type'!==m&&F(m)){if('@index'===m&&m in c&&(e[m]!==c[m]||e[m]['@id']!==c[m]['@id']))throw new De('Invalid JSON-LD syntax; conflicting @index property detected.','jsonld.SyntaxError',{code:'conflicting indexes',subject:c});c[m]=e[m];continue}var g=e[m];if(0===m.indexOf('_:')&&(m=r.getId(m)),0===g.length){t.addValue(c,m,[],{propertyIsArray:!0});continue}for(var I=0,S;I<g.length;++I)if(S=g[I],'@type'===m&&(S=0===S.indexOf('_:')?r.getId(S):S),G(S)||K(S)){var o=te(S)?r.getId(S['@id']):S['@id'];t.addValue(c,m,{"@id":o},{propertyIsArray:!0,allowDuplicate:!1}),b(S,n,a,r,o)}else if(ee(S)){var j=[];b(S['@list'],n,a,r,s,j),S={"@list":j},t.addValue(c,m,S,{propertyIsArray:!0,allowDuplicate:!1})}else b(S,n,a,r,s),t.addValue(c,m,S,{propertyIsArray:!0,allowDuplicate:!1})}}function x(e){for(var t=e['@default'],n=Object.keys(e).sort(),a=0,r;a<n.length;++a)if(r=n[a],'@default'!==r){var o=e[r],i=t[r];i?!('@graph'in i)&&(i['@graph']=[]):t[r]=i={"@id":r,"@graph":[]};for(var s=i['@graph'],d=Object.keys(o).sort(),l=0,p;l<d.length;++l)p=o[d[l]],K(p)||s.push(p)}return t}function _(e,t,a,r,s){T(a),a=a[0];for(var d=e.options,l={embed:k(a,d,'embed'),explicit:k(a,d,'explicit'),requireAll:k(a,d,'requireAll')},p=N(e,t,a,l),u=Object.keys(p).sort(),c=0;c<u.length;++c){var h=u[c],f=p[h];if('@link'===l.embed&&h in e.link){j(r,s,e.link[h]);continue}null===s&&(e.uniqueEmbeds={});var g={};if(g['@id']=h,e.link[h]=g,'@never'===l.embed||w(f,e.subjectStack)){j(r,s,g);continue}'@last'===l.embed&&(h in e.uniqueEmbeds&&S(e,h),e.uniqueEmbeds[h]={parent:r,property:s}),e.subjectStack.push(f);for(var m=Object.keys(f).sort(),y=0,i;y<m.length;y++){if(i=m[y],F(i)){g[i]=ae(f[i]);continue}if(!l.explicit||i in a)for(var b=f[i],x=0,I;x<b.length;++x){if(I=b[x],ee(I)){var o={"@list":[]};j(g,i,o);var R=I['@list'];for(var C in R)if(I=R[C],K(I)){var n=i in a?a[i][0]['@list']:v(l);_(e,[I['@id']],n,o,'@list')}else j(o,'@list',ae(I));continue}if(K(I)){var n=i in a?a[i]:v(l);_(e,[I['@id']],n,g,i)}else j(g,i,ae(I))}}for(var m=Object.keys(a).sort(),y=0,i;y<m.length;++y)if(i=m[y],!F(i)){var L=a[i][0],O=k(L,d,'omitDefault');if(!O&&!(i in g)){var E='@null';'@default'in L&&(E=ae(L['@default'])),H(E)||(E=[E]),g[i]=[{"@preserve":E}]}}j(r,s,g),e.subjectStack.pop()}}function v(e){var t={};for(var n in e)void 0!==e[n]&&(t['@'+n]=[e[n]]);return[t]}function w(e,t){for(var n=t.length-1;0<=n;--n)if(t[n]['@id']===e['@id'])return!0;return!1}function k(e,t,n){var a='@'+n,r=a in e?e[a][0]:t[n];return'embed'===n&&(!0===r?r='@last':!1===r?r='@never':'@always'!==r&&'@never'!==r&&'@link'!==r&&(r='@last')),r}function T(e){if(!H(e)||1!==e.length||!B(e[0]))throw new De('Invalid JSON-LD syntax; a JSON-LD frame must be a single object.','jsonld.SyntaxError',{frame:e})}function N(e,t,n,a){for(var r={},o=0;o<t.length;++o){var i=t[o],s=e.subjects[i];I(s,n,a)&&(r[i]=s)}return r}function I(e,n,a){if('@type'in n&&!(1===n['@type'].length&&B(n['@type'][0]))){for(var r=n['@type'],o=0;o<r.length;++o)if(t.hasValue(e,'@type',r[o]))return!0;return!1}var i=!0,s=!1;for(var d in n){if(F(d)){if('@id'!=d&&'@type'!=d)continue;if(i=!1,'@id'==d&&V(n[d])){if(e[d]!==n[d])return!1;s=!0;continue}}if(i=!1,d in e){if(H(n[d])&&0===n[d].length&&void 0!==e[d])return!1;s=!0;continue}var l=H(n[d])&&B(n[d][0])&&'@default'in n[d][0];if(a.requireAll&&!l)return!1}return i||s}function S(e,n){var a=e.uniqueEmbeds,r=a[n],o=r.parent,s=r.property,d={"@id":n};if(H(o)){for(var l=0;l<o.length;++l)if(t.compareValues(o[l],d)){o[l]=d;break}}else{var i=H(o[s]);t.removeValue(o,s,d,{propertyIsArray:i}),t.addValue(o,s,d,{propertyIsArray:i})}var p=function(e){for(var t=Object.keys(a),n=0,r;n<t.length;++n)r=t[n],r in a&&B(a[r].parent)&&a[r].parent['@id']===e&&(delete a[r],p(r))};p(n)}function j(e,n,a){B(e)?t.addValue(e,n,a,{propertyIsArray:!0}):e.push(a)}/** * Removes the @preserve keywords as the last step of the framing algorithm. * * @param ctx the active context used to compact the input. * @param input the framed, compacted output. * @param options the compaction options used. * * @return the resulting output. */function R(e,n,a){if(H(n)){for(var r=[],o=0,i;o<n.length;++o)i=R(e,n[o],a),null!==i&&r.push(i);n=r}else if(B(n)){// remove @preserve if('@preserve'in n)return'@null'===n['@preserve']?null:n['@preserve'];if(Z(n))return n;if(ee(n))return n['@list']=R(e,n['@list'],a),n;var s=O(e,'@id');if(s in n){var d=n[s];if(d in a.link){var l=a.link[d].indexOf(n);if(-1===l)a.link[d].push(n);else return a.link[d][l]}else a.link[d]=[n]}for(var p in n){var i=R(e,n[p],a),u=t.getContextValue(e,p,'@container');a.compactArrays&&H(i)&&1===i.length&&null===u&&(i=i[0]),n[p]=i}}return n}function C(e,t){return e.length<t.length?-1:t.length<e.length?1:e===t?0:e<t?-1:1}function L(e,t,n,a,r,o){null===o&&(o='@null');var i=[];if(('@id'===o||'@reverse'===o)&&K(n)){'@reverse'==o&&i.push('@reverse');var s=O(e,n['@id'],null,{vocab:!0});s in e.mappings&&e.mappings[s]&&e.mappings[s]['@id']===n['@id']?i.push.apply(i,['@vocab','@id']):i.push.apply(i,['@id','@vocab'])}else i.push(o);i.push('@none');for(var d=e.inverse[t],l=0,p;l<a.length;++l)if(p=a[l],!!(p in d))for(var u=d[p][r],c=0,h;c<i.length;++c)if(h=i[c],!!(h in u))return u[h];return null}function O(e,t,n,a,r){if(null===t)return t;Q(n)&&(n=null),Q(r)&&(r=!1),a=a||{};var o=e.getInverse();if(F(t))return t in o?o[t]['@none']['@type']['@none']:t;if(a.vocab&&t in o){var s=e['@language']||'@none',d=[];B(n)&&'@index'in n&&d.push('@index');var l='@language',p='@null';if(r)l='@type',p='@reverse',d.push('@set');else if(ee(n)){'@index'in n||d.push('@list');for(var u=n['@list'],c=0===u.length?s:null,h=null,f=0;f<u.length;++f){var i=u[f],g='@none',m='@none';if(Z(i)?'@language'in i?g=i['@language']:'@type'in i?m=i['@type']:g='@null':m='@id',null===c?c=g:g!==c&&Z(i)&&(c='@none'),null===h?h=m:m!==h&&(h='@none'),'@none'===c&&'@none'===h)break}c=c||'@none',h=h||'@none','@none'===h?p=c:(l='@type',p=h)}else Z(n)?'@language'in n&&!('@index'in n)?(d.push('@language'),p=n['@language']):'@type'in n&&(l='@type',p=n['@type']):(l='@type',p='@id'),d.push('@set');d.push('@none');var y=L(e,t,n,d,l,p);if(null!==y)return y}if(a.vocab&&'@vocab'in e){var b=e['@vocab'];if(0===t.indexOf(b)&&t!==b){var x=t.substr(b.length);if(!(x in e.mappings))return x}}for(var _=null,v=0,w=[],k=e.fastCurieMap,T=t.length-1;v<T&&t[v]in k;++v)k=k[t[v]],''in k&&w.push(k[''][0]);for(var f=w.length-1;0<=f;--f)for(var N=w[f],I=N.terms,S=0;S<I.length;++S){var j=I[S]+':'+t.substr(N.iri.length),R=!(j in e.mappings)||null===n&&e.mappings[j]['@id']===t;R&&(null===_||0>C(j,_))&&(_=j)}return null===_?a.vocab?t:P(e['@base'],t):_}function E(e,n,a){if(Z(a)){var r=t.getContextValue(e,n,'@type'),o=t.getContextValue(e,n,'@language'),i=t.getContextValue(e,n,'@container'),s='@index'in a&&'@index'!==i;if(!s&&(a['@type']===r||a['@language']===o))return a['@value'];var d=Object.keys(a).length,l=1===d||2===d&&'@index'in a&&!s,p='@language'in e,u=V(a['@value']),c=e.mappings[n]&&null===e.mappings[n]['@language'];if(l&&(!p||!u||c))return a['@value'];var h={};return s&&(h[O(e,'@index')]=a['@index']),'@type'in a?h[O(e,'@type')]=O(e,a['@type'],null,{vocab:!0}):'@language'in a&&(h[O(e,'@language')]=a['@language']),h[O(e,'@value')]=a['@value'],h}var f=U(e,n,{vocab:!0}),r=t.getContextValue(e,n,'@type'),g=O(e,a['@id'],null,{vocab:'@vocab'===r});if('@id'===r||'@vocab'===r||'@graph'===f)return g;var h={};return h[O(e,'@id')]=g,h}function D(e,t,n,a){if(n in a){if(a[n])return;throw new De('Cyclical context definition detected.','jsonld.CyclicalContext',{code:'cyclic IRI mapping',context:t,term:n})}if(a[n]=!1,F(n))throw new De('Invalid JSON-LD syntax; keywords cannot be overridden.','jsonld.SyntaxError',{code:'keyword redefinition',context:t,term:n});if(''===n)throw new De('Invalid JSON-LD syntax; a term cannot be an empty string.','jsonld.SyntaxError',{code:'invalid term definition',context:t});e.mappings[n]&&delete e.mappings[n];var r=t[n];if(null===r||B(r)&&null===r['@id'])return e.mappings[n]=null,void(a[n]=!0);if(V(r)&&(r={"@id":r}),!B(r))throw new De('Invalid JSON-LD syntax; @context property values must be strings or objects.','jsonld.SyntaxError',{code:'invalid term definition',context:t});var o=e.mappings[n]={};if(o.reverse=!1,'@reverse'in r){if('@id'in r)throw new De('Invalid JSON-LD syntax; a @reverse term definition must not contain @id.','jsonld.SyntaxError',{code:'invalid reverse property',context:t});var i=r['@reverse'];if(!V(i))throw new De('Invalid JSON-LD syntax; a @context @reverse value must be a string.','jsonld.SyntaxError',{code:'invalid IRI mapping',context:t});var s=U(e,i,{vocab:!0,base:!1},t,a);if(!ne(s))throw new De('Invalid JSON-LD syntax; a @context @reverse value must be an absolute IRI or a blank node identifier.','jsonld.SyntaxError',{code:'invalid IRI mapping',context:t});o['@id']=s,o.reverse=!0}else if('@id'in r){var s=r['@id'];if(!V(s))throw new De('Invalid JSON-LD syntax; a @context @id value must be an array of strings or a string.','jsonld.SyntaxError',{code:'invalid IRI mapping',context:t});if(s!==n){if(s=U(e,s,{vocab:!0,base:!1},t,a),!ne(s)&&!F(s))throw new De('Invalid JSON-LD syntax; a @context @id value must be an absolute IRI, a blank node identifier, or a keyword.','jsonld.SyntaxError',{code:'invalid IRI mapping',context:t});o['@id']=s}}var d=n.indexOf(':');if(o._termHasColon=-1!==d,!('@id'in o))if(o._termHasColon){var l=n.substr(0,d);if(l in t&&D(e,t,l,a),e.mappings[l]){var p=n.substr(d+1);o['@id']=e.mappings[l]['@id']+p}else o['@id']=n}else{if(!('@vocab'in e))throw new De('Invalid JSON-LD syntax; @context terms must define an @id.','jsonld.SyntaxError',{code:'invalid IRI mapping',context:t,term:n});o['@id']=e['@vocab']+n}if(a[n]=!0,'@type'in r){var u=r['@type'];if(!V(u))throw new De('Invalid JSON-LD syntax; an @context @type values must be a string.','jsonld.SyntaxError',{code:'invalid type mapping',context:t});if('@id'!==u&&'@vocab'!==u){if(u=U(e,u,{vocab:!0,base:!1},t,a),!ne(u))throw new De('Invalid JSON-LD syntax; an @context @type value must be an absolute IRI.','jsonld.SyntaxError',{code:'invalid type mapping',context:t});if(0===u.indexOf('_:'))throw new De('Invalid JSON-LD syntax; an @context @type values must be an IRI, not a blank node identifier.','jsonld.SyntaxError',{code:'invalid type mapping',context:t})}o['@type']=u}if('@container'in r){var c=r['@container'];if('@list'!==c&&'@set'!==c&&'@index'!==c&&'@language'!==c)throw new De('Invalid JSON-LD syntax; @context @container value must be one of the following: @list, @set, @index, or @language.','jsonld.SyntaxError',{code:'invalid container mapping',context:t});if(o.reverse&&'@index'!==c&&'@set'!==c&&null!==c)throw new De('Invalid JSON-LD syntax; @context @container value for a @reverse type definition must be @index or @set.','jsonld.SyntaxError',{code:'invalid reverse property',context:t});o['@container']=c}if('@language'in r&&!('@type'in r)){var h=r['@language'];if(null!==h&&!V(h))throw new De('Invalid JSON-LD syntax; @context @language value must be a string or null.','jsonld.SyntaxError',{code:'invalid language mapping',context:t});null!==h&&(h=h.toLowerCase()),o['@language']=h}// disallow aliasing @context and @preserve var s=o['@id'];if('@context'===s||'@preserve'===s)throw new De('Invalid JSON-LD syntax; @context and @preserve cannot be aliased.','jsonld.SyntaxError',{code:'invalid keyword alias',context:t})}function U(e,n,a,r,o){if(null===n||F(n))return n;if(n+='',r&&n in r&&!0!==o[n]&&D(e,r,n,o),a=a||{},a.vocab){var i=e.mappings[n];if(null===i)return null;if(i)return i['@id']}var s=n.indexOf(':');if(-1!==s){var d=n.substr(0,s),l=n.substr(s+1);if('_'===d||0===l.indexOf('//'))return n;r&&d in r&&D(e,r,d,o);var i=e.mappings[d];return i?i['@id']+l:n}if(a.vocab&&'@vocab'in e)return e['@vocab']+n;var p=n;return a.base&&(p=t.prependBase(e['@base'],p)),p}function A(e,n){if(null===e)return n;if(-1!==n.indexOf(':'))return n;V(e)&&(e=t.url.parse(e||''));var a=t.url.parse(n),r={protocol:e.protocol||''};if(null!==a.authority)r.authority=a.authority,r.path=a.path,r.query=a.query;else if(r.authority=e.authority,''===a.path)r.path=e.path,r.query=null===a.query?e.query:a.query;else{if(0===a.path.indexOf('/'))r.path=a.path;else{var o=e.path;''!==a.path&&(o=o.substr(0,o.lastIndexOf('/')+1),0<o.length&&'/'!==o.substr(-1)&&(o+='/'),o+=a.path),r.path=o}r.query=a.query}r.path=ue(r.path,!!r.authority);var i=r.protocol;return null!==r.authority&&(i+='//'+r.authority),i+=r.path,null!==r.query&&(i+='?'+r.query),null!==a.fragment&&(i+='#'+a.fragment),''===i&&(i='./'),i}function P(e,n){if(null===e)return n;V(e)&&(e=t.url.parse(e||''));var a='';if(''===e.href?n.indexOf('//')&&(a+='//'):a+=(e.protocol||'')+'//'+(e.authority||''),0!==n.indexOf(a))return n;for(var r=t.url.parse(n.substr(a.length)),o=e.normalizedPath.split('/'),s=r.normalizedPath.split('/'),d=r.fragment||r.query?0:1;0<o.length&&s.length>d&&o[0]===s[0];)o.shift(),s.shift();var l='';if(0<o.length){o.pop();for(var p=0;p<o.length;++p)l+='../'}return l+=s.join('/'),null!==r.query&&(l+='?'+r.query),null!==r.fragment&&(l+='#'+r.fragment),''===l&&(l='./'),l}function M(e){function n(){var e=this;if(e.inverse)return e.inverse;for(var t=e.inverse={},n=e.fastCurieMap={},o={},s=e['@language']||'@none',d=e.mappings,l=Object.keys(d).sort(C),p=0;p<l.length;++p){var i=l[p],u=d[i];if(null!==u){var c=u['@container']||'@none',h=u['@id'];H(h)||(h=[h]);for(var f=0;f<h.length;++f){var g=h[f],m=t[g],y=F(g);if(!!m)y||u._termHasColon||o[g].push(i);else if(t[g]=m={},!y&&!u._termHasColon){o[g]=[i];var b={iri:g,terms:o[g]};g[0]in n?n[g[0]].push(b):n[g[0]]=[b]}if(m[c]||(m[c]={"@language":{},"@type":{}}),m=m[c],u.reverse)r(u,i,m['@type'],'@reverse');else if('@type'in u)r(u,i,m['@type'],u['@type']);else if('@language'in u){var x=u['@language']||'@null';r(u,i,m['@language'],x)}else r(u,i,m['@language'],s),r(u,i,m['@type'],'@none'),r(u,i,m['@language'],'@none')}}}for(var _ in n)a(n,_,1);return t}function a(e,t,n){for(var r=e[t],o=e[t]={},s=0,i,d;s<r.length;++s)i=r[s].iri,d=n>=i.length?'':i[n],d in o?o[d].push(r[s]):o[d]=[r[s]];for(var t in o)''!==t&&a(o,t,n+1)}function r(e,t,n,a){a in n||(n[a]=t)}function o(){var e={};return e['@base']=this['@base'],e.mappings=ae(this.mappings),e.clone=this.clone,e.inverse=null,e.getInverse=this.getInverse,'@language'in this&&(e['@language']=this['@language']),'@vocab'in this&&(e['@vocab']=this['@vocab']),e}var i=t.url.parse(e.base||'');return{"@base":i,mappings:{},inverse:null,getInverse:n,clone:o}}function F(e){return!!V(e)&&('@base'===e||'@context'===e||'@container'===e||'@default'===e||'@embed'===e||'@explicit'===e||'@graph'===e||'@id'===e||'@index'===e||'@language'===e||'@list'===e||'@omitDefault'===e||'@preserve'===e||'@requireAll'===e||'@reverse'===e||'@set'===e||'@type'===e||'@value'===e||'@vocab'===e)}function B(e){return'[object Object]'===Object.prototype.toString.call(e)}function q(e){return B(e)&&0===Object.keys(e).length}function H(e){return Array.isArray(e)}function z(e){if(!(V(e)||q(e))){var t=!1;if(H(e)){t=!0;for(var n=0;n<e.length;++n)if(!V(e[n])){t=!1;break}}if(!t)throw new De('Invalid JSON-LD syntax; "@type" value must a string, an array of strings, or an empty object.','jsonld.SyntaxError',{code:'invalid type value',value:e})}}function V(e){return'string'==typeof e||'[object String]'===Object.prototype.toString.call(e)}function X(e){return'number'==typeof e||'[object Number]'===Object.prototype.toString.call(e)}function W(e){return X(e)&&-1!==(e+'').indexOf('.')}function J(e){return!isNaN(parseFloat(e))&&isFinite(e)}function Y(e){return'boolean'==typeof e||'[object Boolean]'===Object.prototype.toString.call(e)}function Q(e){return'undefined'==typeof e}function G(e){var t=!1;if(B(e)&&!('@value'in e||'@set'in e||'@list'in e)){var n=Object.keys(e).length;t=1<n||!('@id'in e)}return t}function K(e){return B(e)&&1===Object.keys(e).length&&'@id'in e}function Z(e){return B(e)&&'@value'in e}function ee(e){return B(e)&&'@list'in e}function te(e){var t=!1;return B(e)&&('@id'in e?t=0===e['@id'].indexOf('_:'):t=0===Object.keys(e).length||!('@value'in e||'@set'in e||'@list'in e)),t}function ne(e){return V(e)&&-1!==e.indexOf(':')}function ae(e){if(e&&'object'==typeof e){var t;if(H(e)){t=[];for(var n=0;n<e.length;++n)t[n]=ae(e[n])}else if(B(e))for(var a in t={},e)t[a]=ae(e[a]);else t=e.toString();return t}return e}function re(e,n,a,r){var o=Object.keys(n).length;if(H(e)){for(var s=0;s<e.length;++s)re(e[s],n,a,r);return o<Object.keys(n).length}if(B(e)){for(var i in e){if('@context'!=i){re(e[i],n,a,r);continue}var d=e[i];if(H(d))for(var l=d.length,s=0,p;s<l;++s)p=d[s],V(p)&&(p=t.prependBase(r,p),a?(p=n[p],H(p)?(Array.prototype.splice.apply(d,[s,1].concat(p)),s+=p.length-1,l=d.length):d[s]=p):!(p in n)&&(n[p]=!1));else V(d)&&(d=t.prependBase(r,d),a?e[i]=n[d]:!(d in n)&&(n[d]=!1))}return o<Object.keys(n).length}return!1}function oe(e,t,n){var a=null,r=t.documentLoader,o=function(e,t,n,r,s){if(Object.keys(t).length>Ee)return a=new De('Maximum number of @context URLs exceeded.','jsonld.ContextUrlError',{code:'loading remote context failed',max:Ee}),s(a);var d={},l=function(){re(e,d,!0,r),s(null,e)};if(!re(e,d,!1,r))return l();var p=[];for(var u in d)!1===d[u]&&p.push(u);for(var c=p.length,h=0;h<p.length;++h)(function(e){if(e in t)return a=new De('Cyclical @context URLs detected.','jsonld.ContextUrlError',{code:'recursive context inclusion',url:e}),s(a);var r=ae(t);r[e]=!0;var i=function(t,i){if(!a){var p=i?i.document:null;if(!t&&V(p))try{p=JSON.parse(p)}catch(e){t=e}return t?t=new De('Dereferencing a URL did not result in a valid JSON-LD object. Possible causes are an inaccessible URL perhaps due to a same-origin policy (ensure the server uses CORS if you are using client-side JavaScript), too many redirects, a non-JSON response, or more than one HTTP Link Header was provided for a remote context.','jsonld.InvalidUrl',{code:'loading remote context failed',url:e,cause:t}):!B(p)&&(t=new De('Dereferencing a URL did not result in a JSON object. The response was valid JSON, but it was not a JSON object.','jsonld.InvalidUrl',{code:'invalid remote context',url:e,cause:t})),t?(a=t,s(a)):void(p='@context'in p?{"@context":p['@context']}:{"@context":{}},i.contextUrl&&(!H(p['@context'])&&(p['@context']=[p['@context']]),p['@context'].push(i.contextUrl)),o(p,r,n,e,function(t,n){return t?s(t):void(d[e]=n['@context'],c-=1,0===c&&l())}))}},p=n(e,i);p&&'then'in p&&p.then(i.bind(null,null),i)})(p[h])};o(e,{},r,t.base,n)}function ie(e){for(var t='(?:<([^:]+:[^>]*)>)',n='(_:(?:[A-Za-z0-9]+))',a='"([^"\\\\]*(?:\\\\.[^"\\\\]*)*)"',r='(?:\\^\\^'+t+')',o='(?:@([a-z]+(?:-[a-z0-9]+)*))',i='(?:'+a+'(?:'+r+'|'+o+')?)',s='(?:#.*)?',d='[ \\t]+',l='[ \\t]*',p=/(?:\r\n)|(?:\n)|(?:\r)/g,u=/^[ \t]*(?:#.*)?$/,c='(?:'+t+'|'+n+')'+d,h=t+d,f='(?:'+t+'|'+n+'|'+i+')'+l,g='(?:\\.|(?:(?:'+t+'|'+n+')'+l+'\\.))',m=/^[ \t]*(?:(?:<([^:]+:[^>]*)>)|(_:(?:[A-Za-z0-9]+)))[ \t]+(?:<([^:]+:[^>]*)>)[ \t]+(?:(?:<([^:]+:[^>]*)>)|(_:(?:[A-Za-z0-9]+))|(?:"([^"\\]*(?:\\.[^"\\]*)*)"(?:(?:\^\^(?:<([^:]+:[^>]*)>))|(?:@([a-z]+(?:-[a-z0-9]+)*)))?))[ \t]*(?:\.|(?:(?:(?:<([^:]+:[^>]*)>)|(_:(?:[A-Za-z0-9]+)))[ \t]*\.))[ \t]*(?:#.*)?$/,b={},x=e.split(p),_=0,v=0,w;v<x.length;++v)if(w=x[v],_++,!u.test(w)){var k=w.match(m);if(null===k)throw new De('Error while parsing N-Quads; invalid quad.','jsonld.ParseError',{line:_});var T={};if(T.subject=Q(k[1])?{type:'blank node',value:k[2]}:{type:'IRI',value:k[1]},T.predicate={type:'IRI',value:k[3]},!Q(k[4]))T.object={type:'IRI',value:k[4]};else if(!Q(k[5]))T.object={type:'blank node',value:k[5]};else{T.object={type:'literal'},Q(k[7])?Q(k[8])?T.object.datatype=ve:(T.object.datatype=Le,T.object.language=k[8]):T.object.datatype=k[7];var N=k[6].replace(/\\"/g,'"').replace(/\\t/g,'\t').replace(/\\n/g,'\n').replace(/\\r/g,'\r').replace(/\\\\/g,'\\');T.object.value=N}var I='@default';if(Q(k[9])?!Q(k[10])&&(I=k[10]):I=k[9],!(I in b))b[I]=[T];else{for(var S=!0,j=b[I],R=0;S&&R<j.length;++R)y(j[R],T)&&(S=!1);S&&j.push(T)}}return b}function se(e){var t=[];for(var n in e)for(var a=e[n],r=0,o;r<a.length;++r)o=a[r],'@default'==n&&(n=null),t.push(de(o,n));return t.sort().join('')}function de(e,t){var n=e.subject,a=e.predicate,r=e.object,o=t||null;'name'in e&&e.name&&(o=e.name.value);var i='';if(i+='IRI'===n.type?'<'+n.value+'>':n.value,i+=' ',i+='IRI'===a.type?'<'+a.value+'>':a.value,i+=' ','IRI'===r.type)i+='<'+r.value+'>';else if('blank node'===r.type)i+=r.value;else{var s=r.value.replace(/\\/g,'\\\\').replace(/\t/g,'\\t').replace(/\n/g,'\\n').replace(/\r/g,'\\r').replace(/\"/g,'\\"');i+='"'+s+'"',r.datatype===Le?r.language&&(i+='@'+r.language):r.datatype!==ve&&(i+='^^<'+r.datatype+'>')}return null!==o&&void 0!==o&&(0===o.indexOf('_:')?i+=' '+o:i+=' <'+o+'>'),i+=' .\n',i}function le(e){for(var t={"@default":[]},n=e.getSubjects(),a=0,r;a<n.length;++a)if(r=n[a],null!==r){var o=e.getSubjectTriples(r);if(null!==o){var i=o.predicates;for(var s in i)for(var d=i[s].objects,l=0;l<d.length;++l){var p=d[l],u={};u.subject=0===r.indexOf('_:')?{type:'blank node',value:r}:{type:'IRI',value:r},u.predicate=0===s.indexOf('_:')?{type:'blank node',value:s}:{type:'IRI',value:s};var c=p.value;if(p.type===Re){me||Be();var h=new me;c='';for(var f=0;f<p.value.length;f++)p.value[f].nodeType===ye.ELEMENT_NODE?c+=h.serializeToString(p.value[f]):p.value[f].nodeType===ye.TEXT_NODE&&(c+=p.value[f].nodeValue)}u.object={},p.type===Ce?0===p.value.indexOf('_:')?u.object.type='blank node':u.object.type='IRI':(u.object.type='literal',p.type===je?p.language?(u.object.datatype=Le,u.object.language=p.language):u.object.datatype=ve:u.object.datatype=p.type),u.object.value=c,t['@default'].push(u)}}}return t}function pe(e){this.prefix=e,this.counter=0,this.existing={}}function ue(e,t){var n='';0===e.indexOf('/')&&(n='/');for(var a=e.split('/'),r=[];0<a.length;){if('.'===a[0]||''===a[0]&&1<a.length){a.shift();continue}if('..'===a[0]){a.shift(),t||0<r.length&&'..'!==r[r.length-1]?r.pop():r.push('..');continue}r.push(a.shift())}return n+r.join('/')}t.compact=function(e,n,a,r){function o(e,t,a,o){if(e)return r(e);o.compactArrays&&!o.graph&&H(t)?1===t.length?t=t[0]:0===t.length&&(t={}):o.graph&&B(t)&&(t=[t]),B(n)&&'@context'in n&&(n=n['@context']),n=ae(n),H(n)||(n=[n]);var s=n;n=[];for(var d=0;d<s.length;++d)(!B(s[d])||0<Object.keys(s[d]).length)&&n.push(s[d]);var i=0<n.length;if(1===n.length&&(n=n[0]),H(t)){var l=O(a,'@graph'),p=t;t={},i&&(t['@context']=n),t[l]=p}else if(B(t)&&i){var p=t;for(var u in t={"@context":n},p)t[u]=p[u]}r(null,t,a)}if(2>arguments.length)return t.nextTick(function(){r(new TypeError('Could not compact, too few arguments.'))});if('function'==typeof a&&(r=a,a={}),a=a||{},null===n)return t.nextTick(function(){r(new De('The compaction context must not be null.','jsonld.CompactError',{code:'invalid local context'}))});if(null===e)return t.nextTick(function(){r(null,null)});'base'in a||(a.base='string'==typeof e?e:''),'compactArrays'in a||(a.compactArrays=!0),'graph'in a||(a.graph=!1),'skipExpansion'in a||(a.skipExpansion=!1),'documentLoader'in a||(a.documentLoader=t.loadDocument),'link'in a||(a.link=!1),a.link&&(a.skipExpansion=!0);var i=function(e,n,a){return n.skipExpansion?t.nextTick(function(){a(null,e)}):void t.expand(e,n,a)};i(e,a,function(e,i){if(e)return r(new De('Could not expand input before compaction.','jsonld.CompactError',{cause:e}));var s=M(a);t.processContext(s,n,a,function(e,t){if(e)return r(new De('Could not process context before compaction.','jsonld.CompactError',{cause:e}));var n;try{n=new Ue().compact(t,null,i,a)}catch(e){return r(e)}o(null,n,t,a)})})},t.expand=function(e,n,a){function r(e){'base'in n||(n.base=e.documentUrl||'');var t={document:ae(e.document),remoteContext:{"@context":e.contextUrl}};if('expandContext'in n){var r=ae(n.expandContext);t.expandContext='object'==typeof r&&'@context'in r?r:{"@context":r}}oe(t,n,function(e,t){if(e)return a(e);var r;try{var o=new Ue,i=M(n),s=t.document,d=t.remoteContext['@context'];t.expandContext&&(i=o.processContext(i,t.expandContext['@context'],n)),d&&(i=o.processContext(i,d,n)),r=o.expand(i,null,s,n,!1),B(r)&&'@graph'in r&&1===Object.keys(r).length?r=r['@graph']:null===r&&(r=[]),H(r)||(r=[r])}catch(e){return a(e)}a(null,r)})}return 1>arguments.length?t.nextTick(function(){a(new TypeError('Could not expand, too few arguments.'))}):void('function'==typeof n&&(a=n,n={}),n=n||{},!('documentLoader'in n)&&(n.documentLoader=t.loadDocument),!('keepFreeFloatingNodes'in n)&&(n.keepFreeFloatingNodes=!1),t.nextTick(function(){if('string'==typeof e){var t=function(e,t){if(e)return a(e);try{if(!t.document)throw new De('No remote document found at the given URL.','jsonld.NullRemoteDocument');'string'==typeof t.document&&(t.document=JSON.parse(t.document))}catch(e){return a(new De('Could not retrieve a JSON-LD document from the URL. URL dereferencing not implemented.','jsonld.LoadDocumentError',{code:'loading document failed',cause:e,remoteDoc:t}))}r(t)},o=n.documentLoader(e,t);return void(o&&'then'in o&&o.then(t.bind(null,null),t))}r({contextUrl:null,documentUrl:null,document:e})}))},t.flatten=function(e,n,a,r){return 1>arguments.length?t.nextTick(function(){r(new TypeError('Could not flatten, too few arguments.'))}):void('function'==typeof a?(r=a,a={}):'function'==typeof n&&(r=n,n=null,a={}),a=a||{},!('base'in a)&&(a.base='string'==typeof e?e:''),!('documentLoader'in a)&&(a.documentLoader=t.loadDocument),t.expand(e,a,function(e,o){if(e)return r(new De('Could not expand input before flattening.','jsonld.FlattenError',{cause:e}));var i;try{i=new Ue().flatten(o)}catch(e){return r(e)}return null===n?r(null,i):void(a.graph=!0,a.skipExpansion=!0,t.compact(i,n,a,function(e,t){return e?r(new De('Could not compact flattened output.','jsonld.FlattenError',{cause:e})):void r(null,t)}))}))},t.frame=function(e,n,a,r){function o(n){var o=n.document,i;o?(i=o['@context'],n.contextUrl?(i?H(i)?i.push(n.contextUrl):i=[i,n.contextUrl]:i=n.contextUrl,o['@context']=i):i=i||{}):i={},t.expand(e,a,function(e,n){if(e)return r(new De('Could not expand input before framing.','jsonld.FrameError',{cause:e}));var s=ae(a);s.isFrame=!0,s.keepFreeFloatingNodes=!0,t.expand(o,s,function(e,a){if(e)return r(new De('Could not expand frame before framing.','jsonld.FrameError',{cause:e}));var o;try{o=new Ue().frame(n,a,s)}catch(e){return r(e)}s.graph=!0,s.skipExpansion=!0,s.link={},t.compact(o,i,s,function(e,t,n){if(e)return r(new De('Could not compact framed output.','jsonld.FrameError',{cause:e}));var a=O(n,'@graph');// remove @preserve from results s.link={},t[a]=R(n,t[a],s),r(null,t)})})})}return 2>arguments.length?t.nextTick(function(){r(new TypeError('Could not frame, too few arguments.'))}):void('function'==typeof a&&(r=a,a={}),a=a||{},!('base'in a)&&(a.base='string'==typeof e?e:''),!('documentLoader'in a)&&(a.documentLoader=t.loadDocument),!('embed'in a)&&(a.embed='@last'),a.explicit=a.explicit||!1,!('requireAll'in a)&&(a.requireAll=!0),a.omitDefault=a.omitDefault||!1,t.nextTick(function(){if('string'==typeof n){var e=function(e,t){if(e)return r(e);try{if(!t.document)throw new De('No remote document found at the given URL.','jsonld.NullRemoteDocument');'string'==typeof t.document&&(t.document=JSON.parse(t.document))}catch(e){return r(new De('Could not retrieve a JSON-LD document from the URL. URL dereferencing not implemented.','jsonld.LoadDocumentError',{code:'loading document failed',cause:e,remoteDoc:t}))}o(t)},t=a.documentLoader(n,e);return void(t&&'then'in t&&t.then(e.bind(null,null),e))}o({contextUrl:null,documentUrl:null,document:n})}))},t.link=function(e,n,a,r){var o={};n&&(o['@context']=n),o['@embed']='@link',t.frame(e,o,a,r)},t.objectify=function(e,n,a,r){'function'==typeof a&&(r=a,a={}),a=a||{},'base'in a||(a.base='string'==typeof e?e:''),'documentLoader'in a||(a.documentLoader=t.loadDocument),t.expand(e,a,function(e,o){if(e)return r(new De('Could not expand input before linking.','jsonld.LinkError',{cause:e}));var i;try{i=new Ue().flatten(o)}catch(e){return r(e)}a.graph=!0,a.skipExpansion=!0,t.compact(i,n,a,function(e,n,a){if(e)return r(new De('Could not compact flattened output before linking.','jsonld.LinkError',{cause:e}));var o=O(a,'@graph'),d=n[o][0],l=function(e){if(B(e)||H(e)){if(B(e)){if(l.visited[e['@id']])return;l.visited[e['@id']]=!0}for(var n in e){var r=e[n],o='@id'===t.getContextValue(a,n,'@type');if(H(r)||B(r)||o)if(V(r)&&o)e[n]=r=d[r],l(r);else if(H(r))for(var s=0;s<r.length;++s)V(r[s])&&o?r[s]=d[r[s]]:B(r[s])&&'@id'in r[s]&&(r[s]=d[r[s]['@id']]),l(r[s]);else if(B(r)){var i=r['@id'];e[n]=r=d[i],l(r)}}}};for(var i in l.visited={},l(d),n.of_type={},d)if('@type'in d[i]){var s=d[i]['@type'];H(s)||(s=[s]);for(var p=0;p<s.length;++p)s[p]in n.of_type||(n.of_type[s[p]]=[]),n.of_type[s[p]].push(d[i])}r(null,n)})})},t.normalize=function(e,n,a){if(1>arguments.length)return t.nextTick(function(){a(new TypeError('Could not normalize, too few arguments.'))});if('function'==typeof n&&(a=n,n={}),n=n||{},'algorithm'in n||(n.algorithm='URGNA2012'),'base'in n||(n.base='string'==typeof e?e:''),'documentLoader'in n||(n.documentLoader=t.loadDocument),'inputFormat'in n){if('application/nquads'!==n.inputFormat)return a(new De('Unknown normalization input format.','jsonld.NormalizeError'));var r=ie(e);new Ue().normalize(r,n,a)}else{var o=ae(n);delete o.format,o.produceGeneralizedRdf=!1,t.toRDF(e,o,function(e,t){return e?a(new De('Could not convert input to RDF dataset before normalization.','jsonld.NormalizeError',{cause:e})):void new Ue().normalize(t,n,a)})}},t.fromRDF=function(e,n,a){return 1>arguments.length?t.nextTick(function(){a(new TypeError('Could not convert from RDF, too few arguments.'))}):void('function'==typeof n&&(a=n,n={}),n=n||{},!('useRdfType'in n)&&(n.useRdfType=!1),!('useNativeTypes'in n)&&(n.useNativeTypes=!1),!('format'in n)&&V(e)&&!('format'in n)&&(n.format='application/nquads'),t.nextTick(function(){function t(e,t,n){new Ue().fromRDF(e,t,n)}var r;if(!n.format)r=function(){return e};else if(r=n.rdfParser||ge[n.format],!r)return a(new De('Unknown input format.','jsonld.UnknownFormat',{format:n.format}));var o=!1;try{e=r(e,function(e,r){return o=!0,e?a(e):void t(r,n,a)})}catch(t){if(!o)return a(t);throw t}if(e){if('then'in e)return e.then(function(e){t(e,n,a)},a);t(e,n,a)}}))},t.toRDF=function(e,n,a){return 1>arguments.length?t.nextTick(function(){a(new TypeError('Could not convert to RDF, too few arguments.'))}):void('function'==typeof n&&(a=n,n={}),n=n||{},!('base'in n)&&(n.base='string'==typeof e?e:''),!('documentLoader'in n)&&(n.documentLoader=t.loadDocument),t.expand(e,n,function(e,t){if(e)return a(new De('Could not expand input before serialization to RDF.','jsonld.RdfError',{cause:e}));var r;try{if(r=Ue.prototype.toRDF(t,n),n.format){if('application/nquads'===n.format)return a(null,se(r));throw new De('Unknown output format.','jsonld.UnknownFormat',{format:n.format})}}catch(e){return a(e)}a(null,r)}))},t.createNodeMap=function(e,n,a){return 1>arguments.length?t.nextTick(function(){a(new TypeError('Could not create node map, too few arguments.'))}):void('function'==typeof n&&(a=n,n={}),n=n||{},!('base'in n)&&(n.base='string'==typeof e?e:''),!('documentLoader'in n)&&(n.documentLoader=t.loadDocument),t.expand(e,n,function(e,t){if(e)return a(new De('Could not expand input before creating node map.','jsonld.CreateNodeMapError',{cause:e}));var r;try{r=new Ue().createNodeMap(t,n)}catch(e){return a(e)}a(null,r)}))},t.merge=function(e,n,a,r){function o(e,t){return l?void 0:e?(l=e,r(new De('Could not expand input before flattening.','jsonld.FlattenError',{cause:e}))):void(d.push(t),0==--p&&s(d))}function s(e){var o=!0;'mergeNodes'in a&&(o=a.mergeNodes);var s=a.namer||a.issuer||new pe('_:b'),d={"@default":{}},l;try{for(var p=0,i;p<e.length;++p){i=e[p],i=t.relabelBlankNodes(i,{issuer:new pe('_:b'+p+'-')});var u=o||0===p?d:{"@default":{}};if(b(i,u,'@default',s),u!==d)for(var c in u){var h=u[c];if(!(c in d)){d[c]=h;continue}var f=d[c];for(var g in h)g in f||(f[g]=h[g])}}l=x(d)}catch(e){return r(e)}for(var m=[],y=Object.keys(l).sort(),_=0,v;_<y.length;++_)v=l[y[_]],K(v)||m.push(v);return null===n?r(null,m):void(a.graph=!0,a.skipExpansion=!0,t.compact(m,n,a,function(e,t){return e?r(new De('Could not compact merged output.','jsonld.MergeError',{cause:e})):void r(null,t)}))}if(1>arguments.length)return t.nextTick(function(){r(new TypeError('Could not merge, too few arguments.'))});if(!H(e))return t.nextTick(function(){r(new TypeError('Could not merge, "docs" must be an array.'))});'function'==typeof a?(r=a,a={}):'function'==typeof n&&(r=n,n=null,a={}),a=a||{};for(var d=[],l=null,p=e.length,u=0,i;u<e.length;++u){for(var c in i={},a)i[c]=a[c];t.expand(e[u],i,o)}},t.relabelBlankNodes=function(e,t){t=t||{};var n=t.namer||t.issuer||new pe('_:b');return l(n,e)},t.prependBase=function(e,t){return A(e,t)},t.documentLoader=function(e,n){var a=new De('Could not retrieve a JSON-LD document from the URL. URL dereferencing not implemented.','jsonld.LoadDocumentError',{code:'loading document failed'});return p?n(a,{contextUrl:null,documentUrl:e,document:null}):t.promisify(function(e){e(a)})},t.loadDocument=function(e,n){var a=t.documentLoader(e,n);a&&'then'in a&&a.then(n.bind(null,null),n)},t.promises=function(e){e=e||{};var a=Array.prototype.slice,r=t.promisify,i=e.api||{},s=e.version||'jsonld.js';'string'==typeof e.api&&(!e.version&&(s=e.api),i={}),i.expand=function(e){if(1>arguments.length)throw new TypeError('Could not expand, too few arguments.');return r.apply(null,[t.expand].concat(a.call(arguments)))},i.compact=function(e,n){if(2>arguments.length)throw new TypeError('Could not compact, too few arguments.');var o=function(e,n,a,r){'function'==typeof a&&(r=a,a={}),a=a||{},t.compact(e,n,a,function(e,t){r(e,t)})};return r.apply(null,[o].concat(a.call(arguments)))},i.flatten=function(e){if(1>arguments.length)throw new TypeError('Could not flatten, too few arguments.');return r.apply(null,[t.flatten].concat(a.call(arguments)))},i.frame=function(e,n){if(2>arguments.length)throw new TypeError('Could not frame, too few arguments.');return r.apply(null,[t.frame].concat(a.call(arguments)))},i.fromRDF=function(e){if(1>arguments.length)throw new TypeError('Could not convert from RDF, too few arguments.');return r.apply(null,[t.fromRDF].concat(a.call(arguments)))},i.toRDF=function(e){if(1>arguments.length)throw new TypeError('Could not convert to RDF, too few arguments.');return r.apply(null,[t.toRDF].concat(a.call(arguments)))},i.normalize=function(e){if(1>arguments.length)throw new TypeError('Could not normalize, too few arguments.');return r.apply(null,[t.normalize].concat(a.call(arguments)))},'jsonld.js'===s&&(i.link=function(e,n){if(2>arguments.length)throw new TypeError('Could not link, too few arguments.');return r.apply(null,[t.link].concat(a.call(arguments)))},i.objectify=function(e){return r.apply(null,[t.objectify].concat(a.call(arguments)))},i.createNodeMap=function(e){return r.apply(null,[t.createNodeMap].concat(a.call(arguments)))},i.merge=function(e){return r.apply(null,[t.merge].concat(a.call(arguments)))});try{t.Promise=o.Promise||n(40).Promise}catch(t){var d=function(){throw new Error('Unable to find a Promise implementation.')};for(var l in i)i[l]=d}return i},t.promisify=function(e){if(!t.Promise)try{t.Promise=o.Promise||n(40).Promise}catch(t){throw new Error('Unable to find a Promise implementation.')}var a=Array.prototype.slice.call(arguments,1);return new t.Promise(function(t,n){e.apply(null,a.concat(function(e,a){e?n(e):t(a)}))})},t.promises({api:t.promises}),e.prototype=t.promises({version:'json-ld-1.0'}),e.prototype.toString=function(){return this instanceof e?'[object JsonLdProcessor]':'[object JsonLdProcessorPrototype]'},t.JsonLdProcessor=e;var ce=!!Object.defineProperty;if(ce)try{Object.defineProperty({},'x',{})}catch(t){ce=!1}ce&&(Object.defineProperty(e,'prototype',{writable:!1,enumerable:!1}),Object.defineProperty(e.prototype,'constructor',{writable:!0,enumerable:!1,configurable:!0,value:e})),u&&'undefined'==typeof o.JsonLdProcessor&&(ce?Object.defineProperty(o,'JsonLdProcessor',{writable:!0,enumerable:!1,configurable:!0,value:e}):o.JsonLdProcessor=e);var he='function'==typeof i&&i,fe=he?function(e){he(e)}:function(e){setTimeout(e,0)};t.nextTick='object'==typeof a&&'function'==typeof a.nextTick?a.nextTick:fe,t.setImmediate=he?fe:t.nextTick,t.parseLinkHeader=function(e){for(var t={},n=e.match(/(?:<[^>]*?>|"[^"]*?"|[^,])+/g),a=/\s*<([^>]*?)>\s*(?:;\s*(.*))?/,r=0,o;r<n.length;++r)if(o=n[r].match(a),!!o){for(var i={target:o[1]},s=o[2],d=/(.*?)=(?:(?:"([^"]*?)")|([^"]*?))\s*(?:(?:;\s*)|$)/g;o=d.exec(s);)i[o[1]]=void 0===o[2]?o[3]:o[2];var l=i.rel||'';H(t[l])?t[l].push(i):l in t?t[l]=[t[l],i]:t[l]=i}return t},t.RequestQueue=function(){this._requests={}},t.RequestQueue.prototype.wrapLoader=function(e){return this._loader=e,this._usePromise=1===e.length,this.add.bind(this)},t.RequestQueue.prototype.add=function(e,n){var a=this;if(!n&&!a._usePromise)throw new Error('callback must be specified.');return a._usePromise?new t.Promise(function(t,n){var r=a._requests[e];r||(r=a._requests[e]=a._loader(e).then(function(t){return delete a._requests[e],t}).catch(function(t){throw delete a._requests[e],t})),r.then(function(e){t(e)}).catch(function(e){n(e)})}):void(e in a._requests?a._requests[e].push(n):(a._requests[e]=[n],a._loader(e,function(t,n){var r=a._requests[e];delete a._requests[e];for(var o=0;o<r.length;++o)r[o](t,n)})))},t.DocumentCache=function(e){this.order=[],this.cache={},this.size=e||50,this.expires=30000},t.DocumentCache.prototype.get=function(e){if(e in this.cache){var t=this.cache[e];if(t.expires>=+new Date)return t.ctx;delete this.cache[e],this.order.splice(this.order.indexOf(e),1)}return null},t.DocumentCache.prototype.set=function(e,t){this.order.length===this.size&&delete this.cache[this.order.shift()],this.order.push(e),this.cache[e]={ctx:t,expires:+new Date+this.expires}},t.ActiveContextCache=function(e){this.order=[],this.cache={},this.size=e||100},t.ActiveContextCache.prototype.get=function(e,t){var n=JSON.stringify(e),a=JSON.stringify(t),r=this.cache[n];return r&&a in r?r[a]:null},t.ActiveContextCache.prototype.set=function(e,t,n){if(this.order.length===this.size){var a=this.order.shift();delete this.cache[a.activeCtx][a.localCtx]}var r=JSON.stringify(e),o=JSON.stringify(t);this.order.push({activeCtx:r,localCtx:o}),r in this.cache||(this.cache[r]={}),this.cache[r][o]=ae(n)},t.cache={activeCtx:new t.ActiveContextCache},t.documentLoaders={},t.documentLoaders.jquery=function(e,n){function a(a,r){return 0!==a.indexOf('http:')&&0!==a.indexOf('https:')?r(new De('URL could not be dereferenced; only "http" and "https" URLs are supported.','jsonld.InvalidUrl',{code:'loading document failed',url:a}),{contextUrl:null,documentUrl:a,document:null}):n.secure&&0!==a.indexOf('https')?r(new De('URL could not be dereferenced; secure mode is enabled and the URL\'s scheme is not "https".','jsonld.InvalidUrl',{code:'loading document failed',url:a}),{contextUrl:null,documentUrl:a,document:null}):void e.ajax({url:a,accepts:{json:'application/ld+json, application/json'},headers:{Accept:'application/ld+json, application/json'},dataType:'json',crossDomain:!0,success:function(e,n,o){var i={contextUrl:null,documentUrl:a,document:e},s=o.getResponseHeader('Content-Type'),d=o.getResponseHeader('Link');if(d&&'application/ld+json'!==s){if(d=t.parseLinkHeader(d)[Oe],H(d))return r(new De('URL could not be dereferenced, it has more than one associated HTTP Link Header.','jsonld.InvalidUrl',{code:'multiple context link headers',url:a}),i);d&&(i.contextUrl=d.target)}r(null,i)},error:function(e,t,n){r(new De('URL could not be dereferenced, an error occurred.','jsonld.LoadDocumentError',{code:'loading document failed',url:a,cause:n}),{contextUrl:null,documentUrl:a,document:null})}})}n=n||{};var r=new t.RequestQueue,o='usePromise'in n?n.usePromise:'undefined'!=typeof Promise;return o?r.wrapLoader(function(e){return t.promisify(a,e)}):r.wrapLoader(a)},t.documentLoaders.node=function(e){function a(n,l,p){function u(e,r,i){if(c={contextUrl:null,documentUrl:n,document:i||null},e)return p(new De('URL could not be dereferenced, an error occurred.','jsonld.LoadDocumentError',{code:'loading document failed',url:n,cause:e}),c);var s=d.STATUS_CODES[r.statusCode];if(400<=r.statusCode)return p(new De('URL could not be dereferenced: '+s,'jsonld.InvalidUrl',{code:'loading document failed',url:n,httpStatusCode:r.statusCode}),c);if(r.headers.link&&'application/ld+json'!==r.headers['content-type']){var u=t.parseLinkHeader(r.headers.link)[Oe];if(H(u))return p(new De('URL could not be dereferenced, it has more than one associated HTTP Link Header.','jsonld.InvalidUrl',{code:'multiple context link headers',url:n}),c);u&&(c.contextUrl=u.target)}return 300<=r.statusCode&&400>r.statusCode&&r.headers.location?l.length===o?p(new De('URL could not be dereferenced; there were too many redirects.','jsonld.TooManyRedirects',{code:'loading document failed',url:n,httpStatusCode:r.statusCode,redirects:l}),c):-1===l.indexOf(n)?(l.push(n),a(r.headers.location,l,p)):p(new De('URL could not be dereferenced; infinite redirection was detected.','jsonld.InfiniteRedirectDetected',{code:'recursive context inclusion',url:n,httpStatusCode:r.statusCode,redirects:l}),c):void(l.push(n),p(e,c))}if(0!==n.indexOf('http:')&&0!==n.indexOf('https:'))return p(new De('URL could not be dereferenced; only "http" and "https" URLs are supported.','jsonld.InvalidUrl',{code:'loading document failed',url:n}),{contextUrl:null,documentUrl:n,document:null});if(e.secure&&0!==n.indexOf('https'))return p(new De('URL could not be dereferenced; secure mode is enabled and the URL\'s scheme is not "https".','jsonld.InvalidUrl',{code:'loading document failed',url:n}),{contextUrl:null,documentUrl:n,document:null});var c=null;if(null!==c)return p(null,c);var h={Accept:s};for(var f in e.headers)h[f]=e.headers[f];i({url:n,headers:h,strictSSL:r,followRedirect:!1},u)}e=e||{};var r=!('strictSSL'in e)||e.strictSSL,o='maxRedirects'in e?e.maxRedirects:-1,i='request'in e?e.request:n(12),s='application/ld+json, application/json',d=n(12),l=new t.RequestQueue;if(e.usePromise)return l.wrapLoader(function(e){return t.promisify(a,e,[])});var p=e.headers||{};if('Accept'in p||'accept'in p)throw new RangeError('Accept header may not be specified as an option; only "'+s+'" is supported.');return l.wrapLoader(function(e,t){a(e,[],t)})},t.documentLoaders.xhr=function(e){function n(n,r){if(0!==n.indexOf('http:')&&0!==n.indexOf('https:'))return r(new De('URL could not be dereferenced; only "http" and "https" URLs are supported.','jsonld.InvalidUrl',{code:'loading document failed',url:n}),{contextUrl:null,documentUrl:n,document:null});if(e.secure&&0!==n.indexOf('https'))return r(new De('URL could not be dereferenced; secure mode is enabled and the URL\'s scheme is not "https".','jsonld.InvalidUrl',{code:'loading document failed',url:n}),{contextUrl:null,documentUrl:n,document:null});var o=e.xhr||XMLHttpRequest,i=new o;i.onload=function(){if(400<=i.status)return r(new De('URL could not be dereferenced: '+i.statusText,'jsonld.LoadDocumentError',{code:'loading document failed',url:n,httpStatusCode:i.status}),{contextUrl:null,documentUrl:n,document:null});var e={contextUrl:null,documentUrl:n,document:i.response},o=i.getResponseHeader('Content-Type'),s;if(a.test(i.getAllResponseHeaders())&&(s=i.getResponseHeader('Link')),s&&'application/ld+json'!==o){if(s=t.parseLinkHeader(s)[Oe],H(s))return r(new De('URL could not be dereferenced, it has more than one associated HTTP Link Header.','jsonld.InvalidUrl',{code:'multiple context link headers',url:n}),e);s&&(e.contextUrl=s.target)}r(null,e)},i.onerror=function(){r(new De('URL could not be dereferenced, an error occurred.','jsonld.LoadDocumentError',{code:'loading document failed',url:n}),{contextUrl:null,documentUrl:n,document:null})},i.open('GET',n,!0),i.setRequestHeader('Accept','application/ld+json, application/json'),i.send()}e=e||{};var a=/(^|(\r\n))link:/i,r=new t.RequestQueue,o='usePromise'in e?e.usePromise:'undefined'!=typeof Promise;return o?r.wrapLoader(function(e){return t.promisify(n,e)}):r.wrapLoader(n)},t.useDocumentLoader=function(e){if(!(e in t.documentLoaders))throw new De('Unknown document loader type: "'+e+'"','jsonld.UnknownDocumentLoader',{type:e});t.documentLoader=t.documentLoaders[e].apply(t,Array.prototype.slice.call(arguments,1))},t.processContext=function(e,n){var a={},r=2;3<arguments.length&&(a=arguments[2]||{},r+=1);var o=arguments[r];return'base'in a||(a.base=''),'documentLoader'in a||(a.documentLoader=t.loadDocument),null===n?o(null,M(a)):void(n=ae(n),!(B(n)&&'@context'in n)&&(n={"@context":n}),oe(n,a,function(t,n){if(t)return o(t);try{n=new Ue().processContext(e,n,a)}catch(e){return o(e)}o(null,n)}))},t.hasProperty=function(e,t){var n=!1;if(t in e){var a=e[t];n=!H(a)||0<a.length}return n},t.hasValue=function(e,n,a){var r=!1;if(t.hasProperty(e,n)){var o=e[n],s=ee(o);if(H(o)||s){s&&(o=o['@list']);for(var d=0;d<o.length;++d)if(t.compareValues(a,o[d])){r=!0;break}}else H(a)||(r=t.compareValues(a,o))}return r},t.addValue=function(e,n,a,r){if(r=r||{},'propertyIsArray'in r||(r.propertyIsArray=!1),'allowDuplicate'in r||(r.allowDuplicate=!0),H(a)){0===a.length&&r.propertyIsArray&&!(n in e)&&(e[n]=[]);for(var o=0;o<a.length;++o)t.addValue(e,n,a[o],r)}else if(n in e){var i=!r.allowDuplicate&&t.hasValue(e,n,a);H(e[n])||i&&!r.propertyIsArray||(e[n]=[e[n]]),i||e[n].push(a)}else e[n]=r.propertyIsArray?[a]:a},t.getValues=function(e,t){var n=e[t]||[];return H(n)||(n=[n]),n},t.removeProperty=function(e,t){delete e[t]},t.removeValue=function(e,n,a,r){r=r||{},'propertyIsArray'in r||(r.propertyIsArray=!1);var o=t.getValues(e,n).filter(function(n){return!t.compareValues(n,a)});0===o.length?t.removeProperty(e,n):1!==o.length||r.propertyIsArray?e[n]=o:e[n]=o[0]},t.compareValues=function(e,t){return e===t||!!(Z(e)&&Z(t)&&e['@value']===t['@value']&&e['@type']===t['@type']&&e['@language']===t['@language']&&e['@index']===t['@index'])||!!(B(e)&&'@id'in e&&B(t)&&'@id'in t)&&e['@id']===t['@id']},t.getContextValue=function(e,t,n){var a=null;if(null===t)return a;if('@language'===n&&n in e&&(a=e[n]),e.mappings[t]){var r=e.mappings[t];Q(n)?a=r:n in r&&(a=r[n])}return a};var ge={};if(t.registerRDFParser=function(e,t){ge[e]=t},t.unregisterRDFParser=function(e){delete ge[e]},p){if('undefined'==typeof me)var me=null;if('undefined'==typeof ye)var ye={ELEMENT_NODE:1,ATTRIBUTE_NODE:2,TEXT_NODE:3,CDATA_SECTION_NODE:4,ENTITY_REFERENCE_NODE:5,ENTITY_NODE:6,PROCESSING_INSTRUCTION_NODE:7,COMMENT_NODE:8,DOCUMENT_NODE:9,DOCUMENT_TYPE_NODE:10,DOCUMENT_FRAGMENT_NODE:11,NOTATION_NODE:12}}var be='http://www.w3.org/2001/XMLSchema#boolean',xe='http://www.w3.org/2001/XMLSchema#double',_e='http://www.w3.org/2001/XMLSchema#integer',ve='http://www.w3.org/2001/XMLSchema#string',we='http://www.w3.org/1999/02/22-rdf-syntax-ns#',ke=we+'List',Te=we+'first',Ne=we+'rest',Ie=we+'nil',Se=we+'type',je=we+'PlainLiteral',Re=we+'XMLLiteral',Ce=we+'object',Le=we+'langString',Oe='http://www.w3.org/ns/json-ld#context',Ee=10,De=function(e,t,n){p?(Error.call(this),Error.captureStackTrace(this,this.constructor)):'undefined'!=typeof Error&&(this.stack=new Error().stack),this.name=t||'jsonld.Error',this.message=e||'An unspecified JSON-LD error occurred.',this.details=n||{}};p?n(12).inherits(De,Error):'undefined'!=typeof Error&&(De.prototype=new Error);var Ue=function(){};Ue.prototype.compact=function(e,n,a,r){if(H(a)){for(var o=[],s=0,i;s<a.length;++s)i=this.compact(e,n,a[s],r),null!==i&&o.push(i);if(r.compactArrays&&1===o.length){var d=t.getContextValue(e,n,'@container');null===d&&(o=o[0])}return o}if(B(a)){if(r.link&&'@id'in a&&a['@id']in r.link)for(var l=r.link[a['@id']],s=0;s<l.length;++s)if(l[s].expanded===a)return l[s].compacted;if(Z(a)||K(a)){var o=E(e,n,a);return r.link&&K(a)&&(!(a['@id']in r.link)&&(r.link[a['@id']]=[]),r.link[a['@id']].push({expanded:a,compacted:o})),o}var p='@reverse'===n,o={};r.link&&'@id'in a&&(!(a['@id']in r.link)&&(r.link[a['@id']]=[]),r.link[a['@id']].push({expanded:a,compacted:o}));for(var u=Object.keys(a).sort(),c=0;c<u.length;++c){var h=u[c],f=a[h];if('@id'===h||'@type'===h){var g;if(V(f))g=O(e,f,null,{vocab:'@type'===h});else{g=[];for(var m=0;m<f.length;++m)g.push(O(e,f[m],null,{vocab:!0}))}var y=O(e,h),b=H(g)&&0===f.length;t.addValue(o,y,g,{propertyIsArray:b});continue}if('@reverse'===h){var g=this.compact(e,'@reverse',f,r);for(var x in g)if(e.mappings[x]&&e.mappings[x].reverse){var _=g[x],d=t.getContextValue(e,x,'@container'),v='@set'===d||!r.compactArrays;t.addValue(o,x,_,{propertyIsArray:v}),delete g[x]}if(0<Object.keys(g).length){var y=O(e,h);t.addValue(o,y,g)}continue}if('@index'===h){var d=t.getContextValue(e,n,'@container');if('@index'===d)continue;var y=O(e,h);t.addValue(o,y,f);continue}if('@graph'!==h&&'@list'!==h&&F(h)){var y=O(e,h);t.addValue(o,y,f);continue}if(0===f.length){var w=O(e,h,f,{vocab:!0},p);t.addValue(o,w,f,{propertyIsArray:!0})}for(var m=0;m<f.length;++m){var k=f[m],w=O(e,h,k,{vocab:!0},p),d=t.getContextValue(e,w,'@container'),T=ee(k),N=null;T&&(N=k['@list']);var I=this.compact(e,w,T?N:k,r);if(T)if(H(I)||(I=[I]),'@list'!==d){var S={};S[O(e,'@list')]=I,I=S,'@index'in k&&(I[O(e,'@index')]=k['@index'])}else if(w in o)throw new De('JSON-LD compact error; property has a "@list" @container rule but there is more than a single @list that matches the compacted term in the document. Compaction might mix unwanted items into the list.','jsonld.SyntaxError',{code:'compaction to list of lists'});if('@language'===d||'@index'===d){var j;w in o?j=o[w]:o[w]=j={},'@language'===d&&Z(I)&&(I=I['@value']),t.addValue(j,k[d],I)}else{var b=!r.compactArrays||'@set'===d||'@list'===d||H(I)&&0===I.length||'@list'===h||'@graph'===h;t.addValue(o,w,I,{propertyIsArray:b})}}}return o}return a},Ue.prototype.expand=function(n,a,r,o,s){var l=this;if(null===r||void 0===r)return null;if(!H(r)&&!B(r))return s||null!==a&&'@graph'!==U(n,a,{vocab:!0})?c(n,a,r):null;if(H(r)){var p=[],u=t.getContextValue(n,a,'@container');s=s||'@list'===u;for(var h=0,i;h<r.length;++h){if(i=l.expand(n,a,r[h],o),s&&(H(i)||ee(i)))throw new De('Invalid JSON-LD syntax; lists of lists are not permitted.','jsonld.SyntaxError',{code:'list of lists'});null!==i&&(H(i)?p=p.concat(i):p.push(i))}return p}'@context'in r&&(n=l.processContext(n,r['@context'],o));for(var e=U(n,a,{vocab:!0}),p={},f=Object.keys(r).sort(),g=0;g<f.length;++g){var m=f[g],y=r[m],b;if('@context'!==m){var x=U(n,m,{vocab:!0});if(null!==x&&(ne(x)||F(x))){if(F(x)){if('@reverse'===e)throw new De('Invalid JSON-LD syntax; a keyword cannot be used as a @reverse property.','jsonld.SyntaxError',{code:'invalid reverse property map',value:y});if(x in p)throw new De('Invalid JSON-LD syntax; colliding keywords detected.','jsonld.SyntaxError',{code:'colliding keywords',keyword:x})}if('@id'===x&&!V(y)){if(!o.isFrame)throw new De('Invalid JSON-LD syntax; "@id" value must a string.','jsonld.SyntaxError',{code:'invalid @id value',value:y});if(!B(y))throw new De('Invalid JSON-LD syntax; "@id" value must be a string or an object.','jsonld.SyntaxError',{code:'invalid @id value',value:y})}if('@type'===x&&z(y),'@graph'===x&&!(B(y)||H(y)))throw new De('Invalid JSON-LD syntax; "@graph" value must not be an object or an array.','jsonld.SyntaxError',{code:'invalid @graph value',value:y});if('@value'===x&&(B(y)||H(y)))throw new De('Invalid JSON-LD syntax; "@value" value must not be an object or an array.','jsonld.SyntaxError',{code:'invalid value object value',value:y});if('@language'===x){if(null===y)continue;if(!V(y))throw new De('Invalid JSON-LD syntax; "@language" value must be a string.','jsonld.SyntaxError',{code:'invalid language-tagged string',value:y});y=y.toLowerCase()}if('@index'===x&&!V(y))throw new De('Invalid JSON-LD syntax; "@index" value must be a string.','jsonld.SyntaxError',{code:'invalid @index value',value:y});if('@reverse'===x){if(!B(y))throw new De('Invalid JSON-LD syntax; "@reverse" value must be an object.','jsonld.SyntaxError',{code:'invalid @reverse value',value:y});if(b=l.expand(n,'@reverse',y,o),'@reverse'in b)for(var _ in b['@reverse'])t.addValue(p,_,b['@reverse'][_],{propertyIsArray:!0});var v=p['@reverse']||null;for(var _ in b)if('@reverse'!=_){null===v&&(v=p['@reverse']={}),t.addValue(v,_,[],{propertyIsArray:!0});for(var w=b[_],k=0,T;k<w.length;++k){if(T=w[k],Z(T)||ee(T))throw new De('Invalid JSON-LD syntax; "@reverse" value must not be a @value or an @list.','jsonld.SyntaxError',{code:'invalid reverse property value',value:b});t.addValue(v,_,T,{propertyIsArray:!0})}}continue}var u=t.getContextValue(n,m,'@container');if('@language'===u&&B(y))b=d(y);else if('@index'===u&&B(y))b=function e(t){for(var a=[],r=Object.keys(y).sort(),i=0;i<r.length;++i){var s=r[i],d=y[s];H(d)||(d=[d]),d=l.expand(n,t,d,o,!1);for(var p=0,u;p<d.length;++p)u=d[p],'@index'in u||(u['@index']=s),a.push(u)}return a}(m);else{var N='@list'===x;if(N||'@set'===x){var I=a;if(N&&'@graph'===e&&(I=null),b=l.expand(n,I,y,o,N),N&&ee(b))throw new De('Invalid JSON-LD syntax; lists of lists are not permitted.','jsonld.SyntaxError',{code:'list of lists'})}else b=l.expand(n,m,y,o,!1)}if(null!==b||'@value'===x){if('@list'===x||ee(b)||'@list'!==u||(b=H(b)?b:[b],b={"@list":b}),n.mappings[m]&&n.mappings[m].reverse){var v=p['@reverse']=p['@reverse']||{};H(b)||(b=[b]);for(var k=0,T;k<b.length;++k){if(T=b[k],Z(T)||ee(T))throw new De('Invalid JSON-LD syntax; "@reverse" value must not be a @value or an @list.','jsonld.SyntaxError',{code:'invalid reverse property value',value:b});t.addValue(v,x,T,{propertyIsArray:!0})}continue}var S=-1===['@index','@id','@type','@value','@language'].indexOf(x);t.addValue(p,x,b,{propertyIsArray:S})}}}}f=Object.keys(p);var j=f.length;if('@value'in p){if('@type'in p&&'@language'in p)throw new De('Invalid JSON-LD syntax; an element containing "@value" may not contain both "@type" and "@language".','jsonld.SyntaxError',{code:'invalid value object',element:p});var R=j-1;if('@type'in p&&(R-=1),'@index'in p&&(R-=1),'@language'in p&&(R-=1),0!=R)throw new De('Invalid JSON-LD syntax; an element containing "@value" may only have an "@index" property and at most one other property which can be "@type" or "@language".','jsonld.SyntaxError',{code:'invalid value object',element:p});if(null===p['@value'])p=null;else if('@language'in p&&!V(p['@value']))throw new De('Invalid JSON-LD syntax; only strings may be language-tagged.','jsonld.SyntaxError',{code:'invalid language-tagged value',element:p});else if('@type'in p&&(!ne(p['@type'])||0===p['@type'].indexOf('_:')))throw new De('Invalid JSON-LD syntax; an element containing "@value" and "@type" must have an absolute IRI for the value of "@type".','jsonld.SyntaxError',{code:'invalid typed value',element:p})}else if('@type'in p&&!H(p['@type']))p['@type']=[p['@type']];else if('@set'in p||'@list'in p){if(1<j&&!(2===j&&'@index'in p))throw new De('Invalid JSON-LD syntax; if an element has the property "@set" or "@list", then it can have at most one other property that is "@index".','jsonld.SyntaxError',{code:'invalid set or list object',element:p});'@set'in p&&(p=p['@set'],f=Object.keys(p),j=f.length)}else 1===j&&'@language'in p&&(p=null);return B(p)&&!o.keepFreeFloatingNodes&&!s&&(null===a||'@graph'===e)&&(0===j||'@value'in p||'@list'in p||1===j&&'@id'in p)&&(p=null),p},Ue.prototype.createNodeMap=function(e,t){t=t||{};var n=t.namer||t.issuer||new pe('_:b'),a={"@default":{}};return b(e,a,'@default',n),x(a)},Ue.prototype.flatten=function(e){for(var t=this.createNodeMap(e),n=[],a=Object.keys(t).sort(),r=0,o;r<a.length;++r)o=t[a[r]],K(o)||n.push(o);return n},Ue.prototype.frame=function(e,t,n){var a={options:n,graphs:{"@default":{},"@merged":{}},subjectStack:[],link:{}},r=new pe('_:b');b(e,a.graphs,'@merged',r),a.subjects=a.graphs['@merged'];var o=[];return _(a,Object.keys(a.subjects).sort(),t,o,null),o},Ue.prototype.normalize=function(e,t,n){return'URDNA2015'===t.algorithm?new Ae(t).main(e,n):'URGNA2012'===t.algorithm?new Pe(t).main(e,n):void n(new Error('Invalid RDF Dataset Normalization algorithm: '+t.algorithm))},Ue.prototype.fromRDF=function(e,n,a){var r={},d={"@default":r},l={};for(var u in e){var c=e[u];u in d||(d[u]={}),'@default'==u||u in r||(r[u]={"@id":u});for(var h=d[u],f=0;f<c.length;++f){var g=c[f],y=g.subject.value,b=g.predicate.value,x=g.object;y in h||(h[y]={"@id":y});var o=h[y],_='IRI'===x.type||'blank node'===x.type;if(_&&!(x.value in h)&&(h[x.value]={"@id":x.value}),b===Se&&!n.useRdfType&&_){t.addValue(o,'@type',x.value,{propertyIsArray:!0});continue}var v=m(x,n.useNativeTypes);if(t.addValue(o,b,v,{propertyIsArray:!0}),_)if(x.value===Ie){var w=h[x.value];'usages'in w||(w.usages=[]),w.usages.push({node:o,property:b,value:v})}else l[x.value]=!(x.value in l)&&{node:o,property:b,value:v}}}for(var u in d){var k=d[u];if(Ie in k){for(var T=k[Ie],N=0;N<T.usages.length;++N){for(var i=T.usages[N],o=i.node,I=i.property,S=i.value,R=[],C=[],L=Object.keys(o).length;I===Ne&&B(l[o['@id']])&&H(o[Te])&&1===o[Te].length&&H(o[Ne])&&1===o[Ne].length&&(3===L||4===L&&H(o['@type'])&&1===o['@type'].length&&o['@type'][0]===ke)&&(R.push(o[Te][0]),C.push(o['@id']),i=l[o['@id']],o=i.node,I=i.property,S=i.value,L=Object.keys(o).length,0===o['@id'].indexOf('_:')););if(I===Te){if(o['@id']===Ie)continue;S=k[S['@id']][Ne][0],R.pop(),C.pop()}delete S['@id'],S['@list']=R.reverse();for(var O=0;O<C.length;++O)delete k[C[O]]}delete T.usages}}for(var j=[],E=Object.keys(r).sort(),N=0;N<E.length;++N){var D=E[N],o=r[D];if(D in d)for(var c=o['@graph']=[],k=d[D],U=Object.keys(k).sort(),A=0,P;A<U.length;++A)P=k[U[A]],K(P)||c.push(P);K(o)||j.push(o)}a(null,j)},Ue.prototype.toRDF=function(e,t){var n=new pe('_:b'),a={"@default":{}};b(e,a,'@default',n);for(var r={},o=Object.keys(a).sort(),s=0,i;s<o.length;++s)i=o[s],('@default'===i||ne(i))&&(r[i]=h(a[i],n,t));return r},Ue.prototype.processContext=function(e,n,a){B(n)&&'@context'in n&&H(n['@context'])&&(n=n['@context']);var r=H(n)?n:[n];if(0===r.length)return e.clone();for(var o=e,s=0,i;s<r.length;++s){if(i=r[s],null===i){o=e=M(a);continue}if(B(i)&&'@context'in i&&(i=i['@context']),!B(i))throw new De('Invalid JSON-LD syntax; @context must be an object.','jsonld.SyntaxError',{code:'invalid local context',context:i});if(t.cache.activeCtx){var d=t.cache.activeCtx.get(e,i);if(d){o=e=d;continue}}e=o,o=o.clone();var l={};if('@base'in i){var p=i['@base'];if(null===p)p=null;else if(!V(p))throw new De('Invalid JSON-LD syntax; the value of "@base" in a @context must be a string or null.','jsonld.SyntaxError',{code:'invalid base IRI',context:i});else if(''!==p&&!ne(p))throw new De('Invalid JSON-LD syntax; the value of "@base" in a @context must be an absolute IRI or the empty string.','jsonld.SyntaxError',{code:'invalid base IRI',context:i});null!==p&&(p=t.url.parse(p||'')),o['@base']=p,l['@base']=!0}if('@vocab'in i){var u=i['@vocab'];if(null===u)delete o['@vocab'];else if(!V(u))throw new De('Invalid JSON-LD syntax; the value of "@vocab" in a @context must be a string or null.','jsonld.SyntaxError',{code:'invalid vocab mapping',context:i});else if(!ne(u))throw new De('Invalid JSON-LD syntax; the value of "@vocab" in a @context must be an absolute IRI.','jsonld.SyntaxError',{code:'invalid vocab mapping',context:i});else o['@vocab']=u;l['@vocab']=!0}if('@language'in i){var u=i['@language'];if(null===u)delete o['@language'];else if(!V(u))throw new De('Invalid JSON-LD syntax; the value of "@language" in a @context must be a string or null.','jsonld.SyntaxError',{code:'invalid default language',context:i});else o['@language']=u.toLowerCase();l['@language']=!0}for(var c in i)D(o,i,c,l);t.cache.activeCtx&&t.cache.activeCtx.set(e,i,o)}return o};var Ae=function(){var e={subject:'s',object:'o',name:'g'},n=function(e){e=e||{},this.name='URDNA2015',this.options=e,this.blankNodeInfo={},this.hashToBlankNodes={},this.canonicalIssuer=new pe('_:c14n'),this.quads=[],this.schedule={},this.schedule.MAX_DEPTH='maxCallStackDepth'in e?e.maxCallStackDepth:500,this.schedule.MAX_TOTAL_DEPTH='maxTotalCallStackDepth'in e?e.maxCallStackDepth:4294967295,this.schedule.depth=0,this.schedule.totalDepth=0,this.schedule.timeSlice='timeSlice'in e?e.timeSlice:10};return n.prototype.doWork=function(e,n){var a=this.schedule;return a.totalDepth>=a.MAX_TOTAL_DEPTH?n(new Error('Maximum total call stack depth exceeded; normalization aborting.')):void function r(){if(a.depth===a.MAX_DEPTH)return a.depth=0,a.running=!1,t.nextTick(r);var o=new Date().getTime();return a.running||(a.start=new Date().getTime(),a.deadline=a.start+a.timeSlice),o<a.deadline?(a.running=!0,a.depth++,a.totalDepth++,e(function(e,t){a.depth--,a.totalDepth--,n(e,t)})):void(a.depth=0,a.running=!1,t.setImmediate(r))}()},n.prototype.forEach=function(e,t,n){var a=this,r=0,o,i;if(H(e))i=e.length,o=function(){return r!==i&&(o.value=e[r++],o.key=r,!0)};else{var s=Object.keys(e);i=s.length,o=function(){return r!==i&&(o.key=s[r++],o.value=e[o.key],!0)}}(function e(r,i){return r?n(r):o()?a.doWork(function(){t(o.value,o.key,e)}):void n()})()},n.prototype.waterfall=function(e,t){var n=this;n.forEach(e,function(e,t,a){n.doWork(e,a)},t)},n.prototype.whilst=function(e,t,n){var a=this;(function r(o){return o?n(o):e()?void a.doWork(t,r):n()})()},n.prototype.main=function(e,t){var n=this;n.schedule.start=new Date().getTime();var a;if(n.options.format&&'application/nquads'!==n.options.format)return t(new De('Unknown output format.','jsonld.UnknownFormat',{format:n.options.format}));var r={};n.waterfall([function(t){n.forEach(e,function(e,t,a){'@default'===t&&(t=null),n.forEach(e,function(e,a,o){null!==t&&(0===t.indexOf('_:')?e.name={type:'blank node',value:t}:e.name={type:'IRI',value:t}),n.quads.push(e),n.forEachComponent(e,function(t){if('blank node'===t.type){var a=t.value;a in n.blankNodeInfo?n.blankNodeInfo[a].quads.push(e):(r[a]=!0,n.blankNodeInfo[a]={quads:[e]})}}),o()},a)},t)},function(e){var t=!0;n.whilst(function(){return t},function(e){t=!1,n.hashToBlankNodes={},n.waterfall([function(e){n.forEach(r,function(e,t,a){n.hashFirstDegreeQuads(t,function(e,r){return e?a(e):void(r in n.hashToBlankNodes?n.hashToBlankNodes[r].push(t):n.hashToBlankNodes[r]=[t],a())})},e)},function(e){var a=Object.keys(n.hashToBlankNodes).sort();n.forEach(a,function(e,a,o){var i=n.hashToBlankNodes[e];if(1<i.length)return o();var s=i[0];n.canonicalIssuer.getId(s),delete r[s],delete n.hashToBlankNodes[e],t=!0,o()},e)}],e)},e)},function(e){var t=Object.keys(n.hashToBlankNodes).sort();n.forEach(t,function(e,t,a){var r=[],o=n.hashToBlankNodes[e];n.waterfall([function(e){n.forEach(o,function(e,t,a){if(n.canonicalIssuer.hasId(e))return a();var o=new pe('_:b');o.getId(e),n.hashNDegreeQuads(e,o,function(e,t){return e?a(e):void(r.push(t),a())})},e)},function(e){r.sort(function(e,t){return e.hash<t.hash?-1:e.hash>t.hash?1:0}),n.forEach(r,function(e,t,a){for(var r in e.issuer.existing)n.canonicalIssuer.getId(r);a()},e)}],a)},e)},function(e){var t=[];n.waterfall([function(e){n.forEach(n.quads,function(e,a,r){n.forEachComponent(e,function(e){'blank node'===e.type&&0!==e.value.indexOf(n.canonicalIssuer.prefix)&&(e.value=n.canonicalIssuer.getId(e.value))}),t.push(de(e)),r()},e)},function(e){return t.sort(),'application/nquads'===n.options.format?(a=t.join(''),e()):void(a=ie(t.join('')),e())}],e)}],function(e){t(e,a)})},n.prototype.hashFirstDegreeQuads=function(e,t){var n=this,a=n.blankNodeInfo[e];if('hash'in a)return t(null,a.hash);var r=[],o=a.quads;n.forEach(o,function(t,a,o){var i={predicate:t.predicate};n.forEachComponent(t,function(t,a){i[a]=n.modifyFirstDegreeComponent(e,t,a)}),r.push(de(i)),o()},function(e){return e?t(e):void(r.sort(),a.hash=Fe.hashNQuads(n.name,r),t(null,a.hash))})},n.prototype.modifyFirstDegreeComponent=function(e,t){return'blank node'===t.type?(t=ae(t),t.value=t.value===e?'_:a':'_:z',t):t},n.prototype.hashRelatedBlankNode=function(e,t,n,a,r){var o=this,i;o.waterfall([function(t){return o.canonicalIssuer.hasId(e)?(i=o.canonicalIssuer.getId(e),t()):n.hasId(e)?(i=n.getId(e),t()):void o.hashFirstDegreeQuads(e,function(e,n){return e?t(e):void(i=n,t())})}],function(e){if(e)return r(e);var n=new Fe(o.name);return n.update(a),'g'!==a&&n.update(o.getRelatedPredicate(t)),n.update(i),r(null,n.digest())})},n.prototype.getRelatedPredicate=function(e){return'<'+e.predicate.value+'>'},n.prototype.hashNDegreeQuads=function(e,t,n){var a=this,r=new Fe(a.name),o;a.waterfall([function(n){a.createHashToRelated(e,t,function(e,t){return e?n(e):void(o=t,n())})},function(e){var n=Object.keys(o).sort();a.forEach(n,function(e,n,i){r.update(e);var s='',d=new Me(o[e]),l;a.whilst(function(){return d.hasNext()},function(e){var n=d.next(),r=t.clone(),o='',i=[];a.waterfall([function(t){a.forEach(n,function(t,n,d){return a.canonicalIssuer.hasId(t)?o+=a.canonicalIssuer.getId(t):(!r.hasId(t)&&i.push(t),o+=r.getId(t)),0!==s.length&&o.length>=s.length&&o>s?e():void d()},t)},function(t){a.forEach(i,function(t,n,i){a.hashNDegreeQuads(t,r,function(n,a){return n?i(n):(o+=r.getId(t),o+='<'+a.hash+'>',r=a.issuer,0!==s.length&&o.length>=s.length&&o>s?e():void i())})},t)},function(e){(0===s.length||o<s)&&(s=o,l=r),e()}],e)},function(e){return e?i(e):void(r.update(s),t=l,i())})},e)}],function(e){n(e,{hash:r.digest(),issuer:t})})},n.prototype.createHashToRelated=function(t,n,a){var r=this,o={},i=r.blankNodeInfo[t].quads;r.forEach(i,function(a,i,s){r.forEach(a,function(i,s,d){if('predicate'===s||'blank node'!==i.type||i.value===t)return d();var l=i.value,p=e[s];r.hashRelatedBlankNode(l,a,n,p,function(e,t){return e?d(e):void(t in o?o[t].push(l):o[t]=[l],d())})},s)},function(e){a(e,o)})},n.prototype.forEachComponent=function(e,t){for(var n in e)'predicate'!=n&&t(e[n],n,e)},n}(),Pe=function(){var e=function(e){Ae.call(this,e),this.name='URGNA2012'};return e.prototype=new Ae,e.prototype.modifyFirstDegreeComponent=function(e,t,n){return'blank node'===t.type?(t=ae(t),t.value='name'===n?'_:g':t.value===e?'_:a':'_:z',t):t},e.prototype.getRelatedPredicate=function(e){return e.predicate.value},e.prototype.createHashToRelated=function(e,t,n){var a=this,r={},o=a.blankNodeInfo[e].quads;a.forEach(o,function(n,o,i){var s,d;if('blank node'===n.subject.type&&n.subject.value!==e)d=n.subject.value,s='p';else if('blank node'===n.object.type&&n.object.value!==e)d=n.object.value,s='r';else return i();a.hashRelatedBlankNode(d,n,t,s,function(e,t){t in r?r[t].push(d):r[t]=[d],i()})},function(e){n(e,r)})},e}();Object.keys||(Object.keys=function(e){if(e!==Object(e))throw new TypeError('Object.keys called on non-object');var t=[];for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&t.push(n);return t}),t.registerRDFParser('application/nquads',ie),t.registerRDFParser('rdfa-api',le),t.IdentifierIssuer=pe,t.UniqueNamer=pe,pe.prototype.clone=function(){var e=new pe(this.prefix);return e.counter=this.counter,e.existing=ae(this.existing),e},pe.prototype.getId=function(e){if(e&&e in this.existing)return this.existing[e];var t=this.prefix+this.counter;return this.counter+=1,e&&(this.existing[e]=t),t},pe.prototype.getName=pe.prototype.getName,pe.prototype.hasId=function(e){return e in this.existing},pe.prototype.isNamed=pe.prototype.hasId;var Me=function(e){this.list=e.sort(),this.done=!1,this.left={};for(var t=0;t<e.length;++t)this.left[e[t]]=!0};Me.prototype.hasNext=function(){return!this.done},Me.prototype.next=function(){for(var e=this.list.slice(),t=null,n=0,a=this.list.length,r=0;r<a;++r){var o=this.list[r],i=this.left[o];(null===t||o>t)&&(i&&0<r&&o>this.list[r-1]||!i&&r<a-1&&o>this.list[r+1])&&(t=o,n=r)}if(null===t)this.done=!0;else{var s=this.left[t]?n-1:n+1;this.list[n]=this.list[s],this.list[s]=t;for(var r=0;r<a;++r)this.list[r]>t&&(this.left[this.list[r]]=!this.left[this.list[r]])}return e};var Fe=function(e){if(!(this instanceof Fe))return new Fe(e);if(-1===['URDNA2015','URGNA2012'].indexOf(e))throw new Error('Invalid RDF Dataset Normalization algorithm: '+e);Fe._init.call(this,e)};if(Fe.hashNQuads=function(e,t){for(var n=new Fe(e),a=0;a<t.length;++a)n.update(t[a]);return n.digest()},function(e){if(e){var t=n(12);return Fe._init=function(e){e='URDNA2015'===e?'sha256':'sha1',this.md=t.createHash(e)},Fe.prototype.update=function(e){return this.md.update(e,'utf8')},void(Fe.prototype.digest=function(){return this.md.digest('hex')})}Fe._init=function(e){e='URDNA2015'===e?new l.Algorithm:new o.Algorithm,this.md=new a(e)},Fe.prototype.update=function(e){return this.md.update(e)},Fe.prototype.digest=function(){return this.md.digest().toHex()};var a=function(e){if(!(this instanceof a))return new a(e);if(this._algorithm=e,!a._padding||a._padding.length<this._algorithm.blockSize){a._padding='\x80';for(var t='\0',r=64;0<r;)1&r&&(a._padding+=t),r>>>=1,0<r&&(t+=t)}this.start()};a.prototype.start=function(){this.messageLength=0,this.fullMessageLength=[];for(var e=this._algorithm.messageLengthSize/4,t=0;t<e;++t)this.fullMessageLength.push(0);return this._input=new a.ByteBuffer,this.state=this._algorithm.start(),this},a.prototype.update=function(e){e=new a.ByteBuffer(unescape(encodeURIComponent(e))),this.messageLength+=e.length();var t=e.length();t=[t/4294967296>>>0,t>>>0];for(var n=this.fullMessageLength.length-1;0<=n;--n)this.fullMessageLength[n]+=t[1],t[1]=t[0]+(this.fullMessageLength[n]/4294967296>>>0),this.fullMessageLength[n]>>>=0,t[0]=t[1]/4294967296>>>0;for(this._input.putBytes(e.bytes());this._input.length()>=this._algorithm.blockSize;)this.state=this._algorithm.digest(this.state,this._input);return(2048<this._input.read||0===this._input.length())&&this._input.compact(),this},a.prototype.digest=function(){var e=new a.ByteBuffer;e.putBytes(this._input.bytes());var t=this.fullMessageLength[this.fullMessageLength.length-1]+this._algorithm.messageLengthSize,n=t&this._algorithm.blockSize-1;e.putBytes(a._padding.substr(0,this._algorithm.blockSize-n));for(var r=new a.ByteBuffer,o=0;o<this.fullMessageLength.length;++o)r.putInt32(this.fullMessageLength[o]<<3|this.fullMessageLength[o+1]>>>28);this._algorithm.writeMessageLength(e,r);var i=this._algorithm.digest(this.state.copy(),e),s=new a.ByteBuffer;return i.write(s),s},a.ByteBuffer=function(e){this.data='string'==typeof e?e:'',this.read=0},a.ByteBuffer.prototype.putInt32=function(e){this.data+=r(255&e>>24)+r(255&e>>16)+r(255&e>>8)+r(255&e)},a.ByteBuffer.prototype.getInt32=function(){var e=this.data.charCodeAt(this.read)<<24^this.data.charCodeAt(this.read+1)<<16^this.data.charCodeAt(this.read+2)<<8^this.data.charCodeAt(this.read+3);return this.read+=4,e},a.ByteBuffer.prototype.putBytes=function(e){this.data+=e},a.ByteBuffer.prototype.bytes=function(){return this.data.slice(this.read)},a.ByteBuffer.prototype.length=function(){return this.data.length-this.read},a.ByteBuffer.prototype.compact=function(){this.data=this.data.slice(this.read),this.read=0},a.ByteBuffer.prototype.toHex=function(){for(var e='',t=this.read,n;t<this.data.length;++t)n=this.data.charCodeAt(t),16>n&&(e+='0'),e+=n.toString(16);return e};var o={_w:null};o.Algorithm=function(){this.name='sha1',this.blockSize=64,this.digestLength=20,this.messageLengthSize=8},o.Algorithm.prototype.start=function(){return o._w||(o._w=Array(80)),o._createState()},o.Algorithm.prototype.writeMessageLength=function(e,t){e.putBytes(t.bytes())},o.Algorithm.prototype.digest=function(n,r){for(var s=r.length(),l=o._w,p,t,a,u,c,d,e,h;64<=s;){for(t=n.h0,a=n.h1,u=n.h2,c=n.h3,d=n.h4,h=0;16>h;++h)p=r.getInt32(),l[h]=p,e=c^a&(u^c),p=(t<<5|t>>>27)+e+d+1518500249+p,d=c,c=u,u=a<<30|a>>>2,a=t,t=p;for(;20>h;++h)p=l[h-3]^l[h-8]^l[h-14]^l[h-16],p=p<<1|p>>>31,l[h]=p,e=c^a&(u^c),p=(t<<5|t>>>27)+e+d+1518500249+p,d=c,c=u,u=a<<30|a>>>2,a=t,t=p;for(;32>h;++h)p=l[h-3]^l[h-8]^l[h-14]^l[h-16],p=p<<1|p>>>31,l[h]=p,e=a^u^c,p=(t<<5|t>>>27)+e+d+1859775393+p,d=c,c=u,u=a<<30|a>>>2,a=t,t=p;for(;40>h;++h)p=l[h-6]^l[h-16]^l[h-28]^l[h-32],p=p<<2|p>>>30,l[h]=p,e=a^u^c,p=(t<<5|t>>>27)+e+d+1859775393+p,d=c,c=u,u=a<<30|a>>>2,a=t,t=p;for(;60>h;++h)p=l[h-6]^l[h-16]^l[h-28]^l[h-32],p=p<<2|p>>>30,l[h]=p,e=a&u|c&(a^u),p=(t<<5|t>>>27)+e+d+2400959708+p,d=c,c=u,u=a<<30|a>>>2,a=t,t=p;for(;80>h;++h)p=l[h-6]^l[h-16]^l[h-28]^l[h-32],p=p<<2|p>>>30,l[h]=p,e=a^u^c,p=(t<<5|t>>>27)+e+d+3395469782+p,d=c,c=u,u=a<<30|a>>>2,a=t,t=p;n.h0=0|n.h0+t,n.h1=0|n.h1+a,n.h2=0|n.h2+u,n.h3=0|n.h3+c,n.h4=0|n.h4+d,s-=64}return n},o._createState=function(){var e={h0:1732584193,h1:4023233417,h2:2562383102,h3:271733878,h4:3285377520};return e.copy=function(){var t=o._createState();return t.h0=e.h0,t.h1=e.h1,t.h2=e.h2,t.h3=e.h3,t.h4=e.h4,t},e.write=function(t){t.putInt32(e.h0),t.putInt32(e.h1),t.putInt32(e.h2),t.putInt32(e.h3),t.putInt32(e.h4)},e};var l={_k:null,_w:null};l.Algorithm=function(){this.name='sha256',this.blockSize=64,this.digestLength=32,this.messageLengthSize=8},l.Algorithm.prototype.start=function(){return l._k||l._init(),l._createState()},l.Algorithm.prototype.writeMessageLength=function(e,t){e.putBytes(t.bytes())},l.Algorithm.prototype.digest=function(t,n){for(var r=n.length(),o=l._k,s=l._w,p,u,m,y,x,_,v,i,a,b,c,d,e,f,g;64<=r;){for(v=0;16>v;++v)s[v]=n.getInt32();for(;64>v;++v)p=s[v-2],p=(p>>>17|p<<15)^(p>>>19|p<<13)^p>>>10,u=s[v-15],u=(u>>>7|u<<25)^(u>>>18|u<<14)^u>>>3,s[v]=0|p+s[v-7]+u+s[v-16];for(i=t.h0,a=t.h1,b=t.h2,c=t.h3,d=t.h4,e=t.h5,f=t.h6,g=t.h7,v=0;64>v;++v)y=(d>>>6|d<<26)^(d>>>11|d<<21)^(d>>>25|d<<7),x=f^d&(e^f),m=(i>>>2|i<<30)^(i>>>13|i<<19)^(i>>>22|i<<10),_=i&a|b&(i^a),p=g+y+x+o[v]+s[v],u=m+_,g=f,f=e,e=d,d=0|c+p,c=b,b=a,a=i,i=0|p+u;t.h0=0|t.h0+i,t.h1=0|t.h1+a,t.h2=0|t.h2+b,t.h3=0|t.h3+c,t.h4=0|t.h4+d,t.h5=0|t.h5+e,t.h6=0|t.h6+f,t.h7=0|t.h7+g,r-=64}return t},l._createState=function(){var e={h0:1779033703,h1:3144134277,h2:1013904242,h3:2773480762,h4:1359893119,h5:2600822924,h6:528734635,h7:1541459225};return e.copy=function(){var t=l._createState();return t.h0=e.h0,t.h1=e.h1,t.h2=e.h2,t.h3=e.h3,t.h4=e.h4,t.h5=e.h5,t.h6=e.h6,t.h7=e.h7,t},e.write=function(t){t.putInt32(e.h0),t.putInt32(e.h1),t.putInt32(e.h2),t.putInt32(e.h3),t.putInt32(e.h4),t.putInt32(e.h5),t.putInt32(e.h6),t.putInt32(e.h7)},e},l._init=function(){l._k=[1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298],l._w=Array(64)}}(p),!me)var Be=function(){me=n(41).XMLSerializer};if(t.url={},t.url.parsers={simple:{keys:['href','scheme','authority','path','query','fragment'],regex:/^(?:([^:\/?#]+):)?(?:\/\/([^\/?#]*))?([^?#]*)(?:\?([^#]*))?(?:#(.*))?/},full:{keys:['href','protocol','scheme','authority','auth','user','password','hostname','port','path','directory','file','query','fragment'],regex:/^(([^:\/?#]+):)?(?:\/\/((?:(([^:@]*)(?::([^:@]*))?)?@)?([^:\/?#]*)(?::(\d*))?))?(?:(((?:[^?#\/]*\/)*)([^?#]*))(?:\?([^#]*))?(?:#(.*))?)/}},t.url.parse=function(e,n){for(var a={},r=t.url.parsers[n||'full'],o=r.regex.exec(e),s=r.keys.length;s--;)a[r.keys[s]]=void 0===o[s]?null:o[s];return a.normalizedPath=ue(a.path,!!a.authority),a},p?t.useDocumentLoader('node'):'undefined'!=typeof XMLHttpRequest&&t.useDocumentLoader('xhr'),p){t.use=function(e){switch(e){case'request':t.request=n(12);break;default:throw new De('Unknown extension.','jsonld.UnknownExtension',{extension:e});}};var qe={exports:{},filename:s};n(12)(qe,'version'),t.version=qe.exports.version}return t},h=function(){return c(function(){return h()})};return!p&&n(64)?(d=[],l=function(){return c(h),h}.apply(t,d),!(void 0!==l&&(e.exports=l))):(c(h),'undefined'!=typeof e&&e.exports&&(e.exports=h),u&&('undefined'==typeof jsonld?jsonld=jsonldjs=h:jsonldjs=h)),h})()}).call(this,n(5),n(3),n(13).setImmediate,'/')},function(e,t,n){(function(a,r,o){var i,s;/*! * @overview es6-promise - a tiny implementation of Promises/A+. * @copyright Copyright (c) 2014 Yehuda Katz, Tom Dale, Stefan Penner and contributors (Conversion to ES6 API by Jake Archibald) * @license Licensed under MIT license * See https://raw.githubusercontent.com/jakearchibald/es6-promise/master/LICENSE * @version 2.3.0 */(function(){'use strict';function d(e){return'function'==typeof e||'object'==typeof e&&null!==e}function l(e){return'function'==typeof e}function p(e){return'object'==typeof e&&null!==e}function u(e){ie=e}function c(e){K=e}function h(){var e=a.nextTick,t=a.versions.node.match(/^(?:(\d+)\.)?(?:(\d+)\.)?(\*|\d+)$/);return Array.isArray(t)&&'0'===t[1]&&'10'===t[2]&&(e=r),function(){e(b)}}function f(){return function(){oe(b)}}function g(){var e=0,t=new te(b),n=document.createTextNode('');return t.observe(n,{characterData:!0}),function(){n.data=e=++e%2}}function m(){var e=new MessageChannel;return e.port1.onmessage=b,function(){e.port2.postMessage(0)}}function y(){return function(){setTimeout(b,1)}}function b(){for(var e=0;e<Q;e+=2){var t=re[e],n=re[e+1];t(n),re[e]=void 0,re[e+1]=void 0}Q=0}function x(){try{var e=i,t=n(63);return oe=t.runOnLoop||t.runOnContext,f()}catch(t){return y()}}function _(){}function v(){return new TypeError('You cannot resolve a promise with itself')}function w(){return new TypeError('A promises callback cannot return that same promise.')}function k(e){try{return e.then}catch(e){return ue.error=e,ue}}function T(e,t,n,a){try{e.call(t,n,a)}catch(t){return t}}function N(e,t,n){K(function(e){var a=!1,r=T(n,t,function(n){a||(a=!0,t===n?C(e,n):j(e,n))},function(t){a||(a=!0,L(e,t))},'Settle: '+(e._label||' unknown promise'));!a&&r&&(a=!0,L(e,r))},e)}function I(e,t){t._state===le?C(e,t._result):t._state===pe?L(e,t._result):O(t,void 0,function(t){j(e,t)},function(t){L(e,t)})}function S(e,t){if(t.constructor===e.constructor)I(e,t);else{var n=k(t);n===ue?L(e,ue.error):n===void 0?C(e,t):l(n)?N(e,t,n):C(e,t)}}function j(e,t){e===t?L(e,v()):d(t)?S(e,t):C(e,t)}function R(e){e._onerror&&e._onerror(e._result),E(e)}function C(e,t){e._state!==de||(e._result=t,e._state=le,0!==e._subscribers.length&&K(E,e))}function L(e,t){e._state!==de||(e._state=pe,e._result=t,K(R,e))}function O(e,t,n,a){var r=e._subscribers,o=r.length;e._onerror=null,r[o]=t,r[o+le]=n,r[o+pe]=a,0===o&&e._state&&K(E,e)}function E(e){var t=e._subscribers,n=e._state;if(0!==t.length){for(var a=e._result,r=0,o,i;r<t.length;r+=3)o=t[r],i=t[r+n],o?A(n,o,i,a):i(a);e._subscribers.length=0}}function D(){this.error=null}function U(e,t){try{return e(t)}catch(t){return ce.error=t,ce}}function A(e,t,n,a){var r=l(n),o,i,s,d;if(!r)o=a,s=!0;else if(o=U(n,a),o===ce?(d=!0,i=o.error,o=null):s=!0,t===o)return void L(t,w());t._state!==de||(r&&s?j(t,o):d?L(t,i):e===le?C(t,o):e===pe&&L(t,o))}function P(t,e){try{e(function e(n){j(t,n)},function e(n){L(t,n)})}catch(n){L(t,n)}}function M(e,t){var n=this;n._instanceConstructor=e,n.promise=new e(_),n._validateInput(t)?(n._input=t,n.length=t.length,n._remaining=t.length,n._init(),0===n.length?C(n.promise,n._result):(n.length=n.length||0,n._enumerate(),0===n._remaining&&C(n.promise,n._result))):L(n.promise,n._validationError())}function F(e){return new he(this,e).promise}function B(e){function t(e){j(r,e)}function n(e){L(r,e)}var a=this,r=new a(_);if(!Y(e))return L(r,new TypeError('You must pass an array to race.')),r;for(var o=e.length,s=0;r._state===de&&s<o;s++)O(a.resolve(e[s]),void 0,t,n);return r}function q(e){var t=this;if(e&&'object'==typeof e&&e.constructor===t)return e;var n=new t(_);return j(n,e),n}function H(e){var t=this,n=new t(_);return L(n,e),n}function z(){throw new TypeError('You must pass a resolver function as the first argument to the promise constructor')}function V(){throw new TypeError('Failed to construct \'Promise\': Please use the \'new\' operator, this object constructor cannot be called as a function.')}function X(e){this._id=be++,this._state=void 0,this._result=void 0,this._subscribers=[],_!==e&&(!l(e)&&z(),!(this instanceof X)&&V(),P(this,e))}function W(){var e;if('undefined'!=typeof o)e=o;else if('undefined'!=typeof self)e=self;else try{e=Function('return this')()}catch(t){throw new Error('polyfill failed because global object is unavailable in this environment')}var t=e.Promise;t&&'[object Promise]'===Object.prototype.toString.call(t.resolve())&&!t.cast||(e.Promise=xe)}var J;J=Array.isArray?Array.isArray:function(e){return'[object Array]'===Object.prototype.toString.call(e)};var Y=J,Q=0,G={}.toString,K=function e(t,n){re[Q]=t,re[Q+1]=n,Q+=2,2==Q&&(ie?ie(b):se())},Z='undefined'==typeof window?void 0:window,ee=Z||{},te=ee.MutationObserver||ee.WebKitMutationObserver,ne='undefined'!=typeof a&&'[object process]'==={}.toString.call(a),ae='undefined'!=typeof Uint8ClampedArray&&'undefined'!=typeof importScripts&&'undefined'!=typeof MessageChannel,re=Array(1e3),oe,ie,se;se=ne?h():te?g():ae?m():void 0!==Z||0?y():x();var de=void 0,le=1,pe=2,ue=new D,ce=new D;M.prototype._validateInput=function(e){return Y(e)},M.prototype._validationError=function(){return new Error('Array Methods must be provided an Array')},M.prototype._init=function(){this._result=Array(this.length)};var he=M;M.prototype._enumerate=function(){for(var e=this,t=e.length,n=e.promise,a=e._input,r=0;n._state===de&&r<t;r++)e._eachEntry(a[r],r)},M.prototype._eachEntry=function(e,t){var n=this,a=n._instanceConstructor;p(e)?e.constructor===a&&e._state!==de?(e._onerror=null,n._settledAt(e._state,t,e._result)):n._willSettleAt(a.resolve(e),t):(n._remaining--,n._result[t]=e)},M.prototype._settledAt=function(e,t,n){var a=this,r=a.promise;r._state===de&&(a._remaining--,e===pe?L(r,n):a._result[t]=n),0===a._remaining&&C(r,a._result)},M.prototype._willSettleAt=function(e,t){var n=this;O(e,void 0,function(e){n._settledAt(le,t,e)},function(e){n._settledAt(pe,t,e)})};var fe=F,ge=B,me=q,ye=H,be=0,xe=X;X.all=fe,X.race=ge,X.resolve=me,X.reject=ye,X._setScheduler=u,X._setAsap=c,X._asap=K,X.prototype={constructor:X,then:function(e,t){var n=this,a=n._state;if(a===le&&!e||a===pe&&!t)return this;var r=new this.constructor(_),o=n._result;if(a){var i=arguments[a-1];K(function(){A(a,r,i,o)})}else O(n,r,e,t);return r},catch:function(e){return this.then(null,e)}};var _e=W,ve={Promise:xe,polyfill:_e};s=function(){return ve}.call(t,n,t,e),!(s!==void 0&&(e.exports=s)),_e()}).call(this)}).call(this,n(5),n(13).setImmediate,n(3))},function(t,n){t.exports=e},function(e,t,n){var a=r,r,r;r=function(){};var t=e.exports={Lexer:r('./lib/N3Lexer'),Parser:r('./lib/N3Parser'),Writer:r('./lib/N3Writer'),Store:r('./lib/N3Store'),StreamParser:r('./lib/N3StreamParser'),StreamWriter:r('./lib/N3StreamWriter'),Util:r('./lib/N3Util')};Object.keys(t).forEach(function(e){Object.defineProperty(t,e,{configurable:!0,enumerable:!0,get:function(){return delete t[e],t[e]=n(65)('./N3'+e)}})})},function(e,t,n){function a(e,t){return this instanceof a?void(this._size=0,this._graphs=Object.create(null),this._entities=Object.create(null),this._entities['><']=0,this._entityCount=0,this._blankNodeIndex=0,!t&&e&&!e[0]&&(t=e,e=null),this._prefixes=Object.create(null),t&&t.prefixes&&this.addPrefixes(t.prefixes),e&&this.addTriples(e)):new a(e,t)}var r=n(27).expandPrefixedName;a.prototype={get size(){var e=this._size;if(null!==e)return e;var t=this._graphs,n,a;for(var r in t)for(var o in n=t[r].subjects)for(var i in a=n[o])e+=Object.keys(a[i]).length;return this._size=e},_addToIndex:function(e,t,n,a){var r=e[t]||(e[t]={}),o=r[n]||(r[n]={});o[a]=null},_removeFromIndex:function(e,t,n,a){var r=e[t],o=r[n],i;for(i in delete o[a],o)return;for(i in delete r[n],r)return;delete e[t]},_findInIndex:function(e,t,n,a,r,o,i,s){var d=[],p=Object.keys(this._entities),u,c,h;for(var f in t&&((u=e,e={})[t]=u[t]),e){var g=p[f];if(c=e[f])for(var m in n&&((u=c,c={})[n]=u[n]),c){var y=p[m];if(h=c[m])for(var b=a?(a in h)?[a]:[]:Object.keys(h),x=b.length-1,l;0<=x;x--)l={subject:'',predicate:'',object:'',graph:s},l[r]=g,l[o]=y,l[i]=p[b[x]],d.push(l)}}return d},_countInIndex:function(e,t,n,a){var r=0,o,i,s;for(var d in t&&((o=e,e={})[t]=o[t]),e)if(i=e[d])for(var l in n&&((o=i,i={})[n]=o[n]),i)(s=i[l])&&(a?a in s&&r++:r+=Object.keys(s).length);return r},addTriple:function(e,t,n,a){t||(a=e.graph,n=e.object,t=e.predicate,e=e.subject),a=a||'';var r=this._graphs[a];r||(r=this._graphs[a]={subjects:{},predicates:{},objects:{}},Object.freeze(r));var o=this._entities;e=o[e]||(o[e]=++this._entityCount),t=o[t]||(o[t]=++this._entityCount),n=o[n]||(o[n]=++this._entityCount),this._addToIndex(r.subjects,e,t,n),this._addToIndex(r.predicates,t,n,e),this._addToIndex(r.objects,n,e,t),this._size=null},addTriples:function(e){for(var t=e.length-1;0<=t;t--)this.addTriple(e[t])},addPrefix:function(e,t){this._prefixes[e]=t},addPrefixes:function(e){for(var t in e)this.addPrefix(t,e[t])},removeTriple:function(e,t,n,a){t||(a=e.graph,n=e.object,t=e.predicate,e=e.subject),a=a||'';var r=this._entities,o=this._graphs,i;if((e=r[e])&&(t=r[t])&&(n=r[n])&&(i=o[a])){var s,d;if((s=i.subjects[e])&&(d=s[t])&&n in d){for(e in this._removeFromIndex(i.subjects,e,t,n),this._removeFromIndex(i.predicates,t,n,e),this._removeFromIndex(i.objects,n,e,t),null!==this._size&&this._size--,i.subjects)return;delete o[a]}}},removeTriples:function(e){for(var t=e.length-1;0<=t;t--)this.removeTriple(e[t])},find:function(e,t,n,a){var o=this._prefixes;return this.findByIRI(r(e,o),r(t,o),r(n,o),r(a,o))},findByIRI:function(e,t,n,a){a=a||'';var r=this._graphs[a],o=this._entities;return r?e&&!(e=o[e])?[]:t&&!(t=o[t])?[]:n&&!(n=o[n])?[]:e?n?this._findInIndex(r.objects,n,e,t,'object','subject','predicate',a):this._findInIndex(r.subjects,e,t,null,'subject','predicate','object',a):t?this._findInIndex(r.predicates,t,n,null,'predicate','object','subject',a):n?this._findInIndex(r.objects,n,null,null,'object','subject','predicate',a):this._findInIndex(r.subjects,null,null,null,'subject','predicate','object',a):[]},count:function(e,t,n,a){var o=this._prefixes;return this.countByIRI(r(e,o),r(t,o),r(n,o),r(a,o))},countByIRI:function(e,t,n,a){a=a||'';var r=this._graphs[a],o=this._entities;return r?e&&!(e=o[e])?0:t&&!(t=o[t])?0:n&&!(n=o[n])?0:e?n?this._countInIndex(r.objects,n,e,t):this._countInIndex(r.subjects,e,t,n):t?this._countInIndex(r.predicates,t,n,e):this._countInIndex(r.objects,n,e,t):0},createBlankNode:function(e){var t,n;if(e)for(t=e='_:'+e,n=1;this._entities[t];)t=e+n++;else do t='_:b'+this._blankNodeIndex++;while(this._entities[t]);return this._entities[t]=++this._entityCount,t}},e.exports=a},function(e,t,n){function a(e){if(!(this instanceof a))return new a(e);r.call(this,{decodeStrings:!0}),this._readableState.objectMode=!0;var t=this,n=new i(e);n.parse(function(e,n){n&&t.push(n)||e&&t.emit('error',e)},this.emit.bind(this,'prefix')),this._transform=function(e,t,a){n.addChunk(e),a()},this._flush=function(e){n.end(),e()}}var r=n(45).Transform,o=n(53),i=n(26);o.inherits(a,r),e.exports=a},function(e,t,n){function a(){r.call(this)}e.exports=a;var r=n(28).EventEmitter,o=n(7);o(a,r),a.Readable=n(29),a.Writable=n(73),a.Duplex=n(74),a.Transform=n(75),a.PassThrough=n(76),a.Stream=a,a.prototype.pipe=function(e,t){function n(t){e.writable&&!1===e.write(t)&&l.pause&&l.pause()}function a(){l.readable&&l.resume&&l.resume()}function o(){p||(p=!0,e.end())}function i(){p||(p=!0,'function'==typeof e.destroy&&e.destroy())}function s(e){if(d(),0===r.listenerCount(this,'error'))throw e}function d(){l.removeListener('data',n),e.removeListener('drain',a),l.removeListener('end',o),l.removeListener('close',i),l.removeListener('error',s),e.removeListener('error',s),l.removeListener('end',d),l.removeListener('close',d),e.removeListener('close',d)}var l=this;l.on('data',n),e.on('drain',a),e._isStdio||t&&!1===t.end||(l.on('end',o),l.on('close',i));var p=!1;return l.on('error',s),e.on('error',s),l.on('end',d),l.on('close',d),e.on('close',d),e.emit('pipe',l),e}},function(e,t,n){'use strict';(function(t,r){function o(e){return F.from(e)}function i(e){return F.isBuffer(e)||e instanceof B}function s(e,t,n){return'function'==typeof e.prependListener?e.prependListener(t,n):void(e._events&&e._events[t]?D(e._events[t])?e._events[t].unshift(n):e._events[t]=[n,e._events[t]]:e.on(t,n))}function d(e,t){U=U||n(8),e=e||{};var r=t instanceof U;this.objectMode=!!e.objectMode,r&&(this.objectMode=this.objectMode||!!e.readableObjectMode);var o=e.highWaterMark,i=e.readableHighWaterMark,s=this.objectMode?16:16384;this.highWaterMark=o||0===o?o:r&&(i||0===i)?i:s,this.highWaterMark=a(this.highWaterMark),this.buffer=new V,this.length=0,this.pipes=null,this.pipesCount=0,this.flowing=null,this.ended=!1,this.endEmitted=!1,this.reading=!1,this.sync=!0,this.needReadable=!1,this.emittedReadable=!1,this.readableListening=!1,this.resumeScheduled=!1,this.destroyed=!1,this.defaultEncoding=e.defaultEncoding||'utf8',this.awaitDrain=0,this.readingMore=!1,this.decoder=null,this.encoding=null,e.encoding&&(!W&&(W=n(51).StringDecoder),this.decoder=new W(e.encoding),this.encoding=e.encoding)}function l(e){return U=U||n(8),this instanceof l?void(this._readableState=new d(e,this),this.readable=!0,e&&('function'==typeof e.read&&(this._read=e.read),'function'==typeof e.destroy&&(this._destroy=e.destroy)),M.call(this)):new l(e)}function p(e,t,n,a,r){var i=e._readableState;if(null===t)i.reading=!1,m(e,i);else{var s;r||(s=c(i,t)),s?e.emit('error',s):i.objectMode||t&&0<t.length?('string'!=typeof t&&!i.objectMode&&Object.getPrototypeOf(t)!==F.prototype&&(t=o(t)),a?i.endEmitted?e.emit('error',new Error('stream.unshift() after end event')):u(e,i,t,!0):i.ended?e.emit('error',new Error('stream.push() after EOF')):(i.reading=!1,i.decoder&&!n?(t=i.decoder.write(t),i.objectMode||0!==t.length?u(e,i,t,!1):x(e,i)):u(e,i,t,!1))):!a&&(i.reading=!1)}return h(i)}function u(e,t,n,a){t.flowing&&0===t.length&&!t.sync?(e.emit('data',n),e.read(0)):(t.length+=t.objectMode?1:n.length,a?t.buffer.unshift(n):t.buffer.push(n),t.needReadable&&y(e)),x(e,t)}function c(e,t){var n;return i(t)||'string'==typeof t||void 0===t||e.objectMode||(n=new TypeError('Invalid non-string/buffer chunk')),n}function h(e){return!e.ended&&(e.needReadable||e.length<e.highWaterMark||0===e.length)}function f(e){return e>=Y?e=Y:(e--,e|=e>>>1,e|=e>>>2,e|=e>>>4,e|=e>>>8,e|=e>>>16,e++),e}function g(e,t){return 0>=e||0===t.length&&t.ended?0:t.objectMode?1:e===e?(e>t.highWaterMark&&(t.highWaterMark=f(e)),e<=t.length?e:t.ended?t.length:(t.needReadable=!0,0)):t.flowing&&t.length?t.buffer.head.data.length:t.length}function m(e,t){if(!t.ended){if(t.decoder){var n=t.decoder.end();n&&n.length&&(t.buffer.push(n),t.length+=t.objectMode?1:n.length)}t.ended=!0,y(e)}}function y(e){var t=e._readableState;t.needReadable=!1,t.emittedReadable||(z('emitReadable',t.flowing),t.emittedReadable=!0,t.sync?E.nextTick(b,e):b(e))}function b(e){z('emit readable'),e.emit('readable'),N(e)}function x(e,t){t.readingMore||(t.readingMore=!0,E.nextTick(_,e,t))}function _(e,t){for(var n=t.length;!t.reading&&!t.flowing&&!t.ended&&t.length<t.highWaterMark&&(z('maybeReadMore read 0'),e.read(0),n!==t.length);)n=t.length;t.readingMore=!1}function v(e){return function(){var t=e._readableState;z('pipeOnDrain',t.awaitDrain),t.awaitDrain&&t.awaitDrain--,0===t.awaitDrain&&P(e,'data')&&(t.flowing=!0,N(e))}}function w(e){z('readable nexttick read 0'),e.read(0)}function k(e,t){t.resumeScheduled||(t.resumeScheduled=!0,E.nextTick(T,e,t))}function T(e,t){t.reading||(z('resume read 0'),e.read(0)),t.resumeScheduled=!1,t.awaitDrain=0,e.emit('resume'),N(e),t.flowing&&!t.reading&&e.read(0)}function N(e){var t=e._readableState;for(z('flow',t.flowing);t.flowing&&null!==e.read(););}function I(e,t){if(0===t.length)return null;var a;return t.objectMode?a=t.buffer.shift():!e||e>=t.length?(a=t.decoder?t.buffer.join(''):1===t.buffer.length?t.buffer.head.data:t.buffer.concat(t.length),t.buffer.clear()):a=S(e,t.buffer,t.decoder),a}function S(e,t,n){var a;return e<t.head.data.length?(a=t.head.data.slice(0,e),t.head.data=t.head.data.slice(e)):e===t.head.data.length?a=t.shift():a=n?j(e,t):R(e,t),a}function j(e,t){var n=t.head,a=1,r=n.data;for(e-=r.length;n=n.next;){var o=n.data,i=e>o.length?o.length:e;if(r+=i===o.length?o:o.slice(0,e),e-=i,0===e){i===o.length?(++a,t.head=n.next?n.next:t.tail=null):(t.head=n,n.data=o.slice(i));break}++a}return t.length-=a,r}function R(e,t){var n=F.allocUnsafe(e),a=t.head,r=1;for(a.data.copy(n),e-=a.data.length;a=a.next;){var o=a.data,i=e>o.length?o.length:e;if(o.copy(n,n.length-e,0,i),e-=i,0===e){i===o.length?(++r,t.head=a.next?a.next:t.tail=null):(t.head=a,a.data=o.slice(i));break}++r}return t.length-=r,n}function C(e){var t=e._readableState;if(0<t.length)throw new Error('"endReadable()" called on non-empty stream');t.endEmitted||(t.ended=!0,E.nextTick(L,t,e))}function L(e,t){e.endEmitted||0!==e.length||(e.endEmitted=!0,t.readable=!1,t.emit('end'))}function O(e,t){for(var n=0,a=e.length;n<a;n++)if(e[n]===t)return n;return-1}var E=n(18);e.exports=l;var D=n(47),U;l.ReadableState=d;var A=n(28).EventEmitter,P=function(e,t){return e.listeners(t).length},M=n(48),F=n(19).Buffer,B=t.Uint8Array||function(){},q=n(14);q.inherits=n(7);var H=n(68),z=void 0;z=H&&H.debuglog?H.debuglog('stream'):function(){};var V=n(69),X=n(50),W;q.inherits(l,M);var J=['error','close','destroy','pause','resume'];Object.defineProperty(l.prototype,'destroyed',{get:function(){return void 0!==this._readableState&&this._readableState.destroyed},set:function(e){this._readableState&&(this._readableState.destroyed=e)}}),l.prototype.destroy=X.destroy,l.prototype._undestroy=X.undestroy,l.prototype._destroy=function(e,t){this.push(null),t(e)},l.prototype.push=function(e,t){var n=this._readableState,a;return n.objectMode?a=!0:'string'==typeof e&&(t=t||n.defaultEncoding,t!==n.encoding&&(e=F.from(e,t),t=''),a=!0),p(this,e,t,!1,a)},l.prototype.unshift=function(e){return p(this,e,null,!0,!1)},l.prototype.isPaused=function(){return!1===this._readableState.flowing},l.prototype.setEncoding=function(e){return W||(W=n(51).StringDecoder),this._readableState.decoder=new W(e),this._readableState.encoding=e,this};var Y=8388608;l.prototype.read=function(e){z('read',e),e=parseInt(e,10);var t=this._readableState,n=e;if(0!==e&&(t.emittedReadable=!1),0===e&&t.needReadable&&(t.length>=t.highWaterMark||t.ended))return z('read: emitReadable',t.length,t.ended),0===t.length&&t.ended?C(this):y(this),null;if(e=g(e,t),0===e&&t.ended)return 0===t.length&&C(this),null;var a=t.needReadable;z('need readable',a),(0===t.length||t.length-e<t.highWaterMark)&&(a=!0,z('length less than watermark',a)),t.ended||t.reading?(a=!1,z('reading or ended',a)):a&&(z('do read'),t.reading=!0,t.sync=!0,0===t.length&&(t.needReadable=!0),this._read(t.highWaterMark),t.sync=!1,!t.reading&&(e=g(n,t)));var r;return r=0<e?I(e,t):null,null===r?(t.needReadable=!0,e=0):t.length-=e,0===t.length&&(!t.ended&&(t.needReadable=!0),n!==e&&t.ended&&C(this)),null!==r&&this.emit('data',r),r},l.prototype._read=function(e){this.emit('error',new Error('_read() is not implemented'))},l.prototype.pipe=function(e,t){function n(e,t){z('onunpipe'),e===c&&t&&!1===t.hasUnpiped&&(t.hasUnpiped=!0,o())}function a(){z('onend'),e.end()}function o(){z('cleanup'),e.removeListener('close',l),e.removeListener('finish',p),e.removeListener('drain',m),e.removeListener('error',d),e.removeListener('unpipe',n),c.removeListener('end',a),c.removeListener('end',u),c.removeListener('data',i),y=!0,h.awaitDrain&&(!e._writableState||e._writableState.needDrain)&&m()}function i(t){z('ondata'),b=!1;var n=e.write(t);!1!==n||b||((1===h.pipesCount&&h.pipes===e||1<h.pipesCount&&-1!==O(h.pipes,e))&&!y&&(z('false write response, pause',c._readableState.awaitDrain),c._readableState.awaitDrain++,b=!0),c.pause())}function d(t){z('onerror',t),u(),e.removeListener('error',d),0===P(e,'error')&&e.emit('error',t)}function l(){e.removeListener('finish',p),u()}function p(){z('onfinish'),e.removeListener('close',l),u()}function u(){z('unpipe'),c.unpipe(e)}var c=this,h=this._readableState;switch(h.pipesCount){case 0:h.pipes=e;break;case 1:h.pipes=[h.pipes,e];break;default:h.pipes.push(e);}h.pipesCount+=1,z('pipe count=%d opts=%j',h.pipesCount,t);var f=(!t||!1!==t.end)&&e!==r.stdout&&e!==r.stderr,g=f?a:u;h.endEmitted?E.nextTick(g):c.once('end',g),e.on('unpipe',n);var m=v(c);e.on('drain',m);var y=!1,b=!1;return c.on('data',i),s(e,'error',d),e.once('close',l),e.once('finish',p),e.emit('pipe',c),h.flowing||(z('pipe resume'),c.resume()),e},l.prototype.unpipe=function(e){var t=this._readableState,n={hasUnpiped:!1};if(0===t.pipesCount)return this;if(1===t.pipesCount)return e&&e!==t.pipes?this:(e||(e=t.pipes),t.pipes=null,t.pipesCount=0,t.flowing=!1,e&&e.emit('unpipe',this,n),this);if(!e){var a=t.pipes,r=t.pipesCount;t.pipes=null,t.pipesCount=0,t.flowing=!1;for(var o=0;o<r;o++)a[o].emit('unpipe',this,n);return this}var i=O(t.pipes,e);return-1===i?this:(t.pipes.splice(i,1),t.pipesCount-=1,1===t.pipesCount&&(t.pipes=t.pipes[0]),e.emit('unpipe',this,n),this)},l.prototype.on=function(e,t){var n=M.prototype.on.call(this,e,t);if('data'===e)!1!==this._readableState.flowing&&this.resume();else if('readable'===e){var a=this._readableState;a.endEmitted||a.readableListening||(a.readableListening=a.needReadable=!0,a.emittedReadable=!1,a.reading?a.length&&y(this):E.nextTick(w,this))}return n},l.prototype.addListener=l.prototype.on,l.prototype.resume=function(){var e=this._readableState;return e.flowing||(z('resume'),e.flowing=!0,k(this,e)),this},l.prototype.pause=function(){return z('call pause flowing=%j',this._readableState.flowing),!1!==this._readableState.flowing&&(z('pause'),this._readableState.flowing=!1,this.emit('pause')),this},l.prototype.wrap=function(e){var t=this,a=this._readableState,r=!1;for(var o in e.on('end',function(){if(z('wrapped end'),a.decoder&&!a.ended){var e=a.decoder.end();e&&e.length&&t.push(e)}t.push(null)}),e.on('data',function(n){if((z('wrapped data'),a.decoder&&(n=a.decoder.write(n)),!(a.objectMode&&(null===n||void 0===n)))&&(a.objectMode||n&&n.length)){var o=t.push(n);o||(r=!0,e.pause())}}),e)void 0===this[o]&&'function'==typeof e[o]&&(this[o]=function(t){return function(){return e[t].apply(e,arguments)}}(o));for(var i=0;i<J.length;i++)e.on(J[i],this.emit.bind(this,J[i]));return this._read=function(t){z('wrapped _read',t),r&&(r=!1,e.resume())},this},Object.defineProperty(l.prototype,'readableHighWaterMark',{enumerable:!1,get:function(){return this._readableState.highWaterMark}}),l._fromList=I}).call(this,n(3),n(5))},function(e,t){var n={}.toString;e.exports=Array.isArray||function(e){return'[object Array]'==n.call(e)}},function(e,t,n){e.exports=n(28).EventEmitter},function(e,t,o){'use strict';(function(e){function i(){try{var e=new Uint8Array(1);return e.__proto__={__proto__:Uint8Array.prototype,foo:function(){return 42}},42===e.foo()&&'function'==typeof e.subarray&&0===e.subarray(1,1).byteLength}catch(t){return!1}}function s(){return l.TYPED_ARRAY_SUPPORT?2147483647:1073741823}function d(e,t){if(s()<t)throw new RangeError('Invalid typed array length');return l.TYPED_ARRAY_SUPPORT?(e=new Uint8Array(t),e.__proto__=l.prototype):(null===e&&(e=new l(t)),e.length=t),e}function l(e,t,n){if(!l.TYPED_ARRAY_SUPPORT&&!(this instanceof l))return new l(e,t,n);if('number'==typeof e){if('string'==typeof t)throw new Error('If encoding is specified then the first argument must be a string');return h(this,e)}return p(this,e,t,n)}function p(e,t,n,a){if('number'==typeof t)throw new TypeError('"value" argument must not be a number');return'undefined'!=typeof ArrayBuffer&&t instanceof ArrayBuffer?m(e,t,n,a):'string'==typeof t?f(e,t,n):y(e,t)}function u(e){if('number'!=typeof e)throw new TypeError('"size" argument must be a number');else if(0>e)throw new RangeError('"size" argument must not be negative')}function c(e,t,n,a){return u(t),0>=t?d(e,t):void 0===n?d(e,t):'string'==typeof a?d(e,t).fill(n,a):d(e,t).fill(n)}function h(e,t){if(u(t),e=d(e,0>t?0:0|b(t)),!l.TYPED_ARRAY_SUPPORT)for(var n=0;n<t;++n)e[n]=0;return e}function f(e,t,n){if(('string'!=typeof n||''===n)&&(n='utf8'),!l.isEncoding(n))throw new TypeError('"encoding" must be a valid string encoding');var a=0|_(t,n);e=d(e,a);var r=e.write(t,n);return r!==a&&(e=e.slice(0,r)),e}function g(e,t){var n=0>t.length?0:0|b(t.length);e=d(e,n);for(var a=0;a<n;a+=1)e[a]=255&t[a];return e}function m(e,t,n,a){if(t.byteLength,0>n||t.byteLength<n)throw new RangeError('\'offset\' is out of bounds');if(t.byteLength<n+(a||0))throw new RangeError('\'length\' is out of bounds');return t=void 0===n&&void 0===a?new Uint8Array(t):void 0===a?new Uint8Array(t,n):new Uint8Array(t,n,a),l.TYPED_ARRAY_SUPPORT?(e=t,e.__proto__=l.prototype):e=g(e,t),e}function y(e,t){if(l.isBuffer(t)){var n=0|b(t.length);return(e=d(e,n),0===e.length)?e:(t.copy(e,0,0,n),e)}if(t){if('undefined'!=typeof ArrayBuffer&&t.buffer instanceof ArrayBuffer||'length'in t)return'number'!=typeof t.length||ee(t.length)?d(e,0):g(e,t);if('Buffer'===t.type&&re(t.data))return g(e,t.data)}throw new TypeError('First argument must be a string, Buffer, ArrayBuffer, Array, or array-like object.')}function b(e){if(e>=s())throw new RangeError('Attempt to allocate Buffer larger than maximum size: 0x'+s().toString(16)+' bytes');return 0|e}function x(e){return+e!=e&&(e=0),l.alloc(+e)}function _(e,t){if(l.isBuffer(e))return e.length;if('undefined'!=typeof ArrayBuffer&&'function'==typeof ArrayBuffer.isView&&(ArrayBuffer.isView(e)||e instanceof ArrayBuffer))return e.byteLength;'string'!=typeof e&&(e=''+e);var n=e.length;if(0===n)return 0;for(var a=!1;;)switch(t){case'ascii':case'latin1':case'binary':return n;case'utf8':case'utf-8':case void 0:return Y(e).length;case'ucs2':case'ucs-2':case'utf16le':case'utf-16le':return 2*n;case'hex':return n>>>1;case'base64':return K(e).length;default:if(a)return Y(e).length;t=(''+t).toLowerCase(),a=!0;}}function v(e,t,n){var a=!1;if((void 0===t||0>t)&&(t=0),t>this.length)return'';if((void 0===n||n>this.length)&&(n=this.length),0>=n)return'';if(n>>>=0,t>>>=0,n<=t)return'';for(e||(e='utf8');!0;)switch(e){case'hex':return A(this,t,n);case'utf8':case'utf-8':return O(this,t,n);case'ascii':return D(this,t,n);case'latin1':case'binary':return U(this,t,n);case'base64':return L(this,t,n);case'ucs2':case'ucs-2':case'utf16le':case'utf-16le':return P(this,t,n);default:if(a)throw new TypeError('Unknown encoding: '+e);e=(e+'').toLowerCase(),a=!0;}}function w(e,t,n){var a=e[t];e[t]=e[n],e[n]=a}function k(e,t,n,a,r){if(0===e.length)return-1;if('string'==typeof n?(a=n,n=0):2147483647<n?n=2147483647:-2147483648>n&&(n=-2147483648),n=+n,isNaN(n)&&(n=r?0:e.length-1),0>n&&(n=e.length+n),n>=e.length){if(r)return-1;n=e.length-1}else if(0>n)if(r)n=0;else return-1;if('string'==typeof t&&(t=l.from(t,a)),l.isBuffer(t))return 0===t.length?-1:T(e,t,n,a,r);if('number'==typeof t)return t&=255,l.TYPED_ARRAY_SUPPORT&&'function'==typeof Uint8Array.prototype.indexOf?r?Uint8Array.prototype.indexOf.call(e,t,n):Uint8Array.prototype.lastIndexOf.call(e,t,n):T(e,[t],n,a,r);throw new TypeError('val must be string, number or Buffer')}function T(e,t,n,a,r){function o(e,t){return 1===s?e[t]:e.readUInt16BE(t*s)}var s=1,d=e.length,l=t.length;if(void 0!==a&&(a=(a+'').toLowerCase(),'ucs2'===a||'ucs-2'===a||'utf16le'===a||'utf-16le'===a)){if(2>e.length||2>t.length)return-1;s=2,d/=2,l/=2,n/=2}var p;if(r){var i=-1;for(p=n;p<d;p++)if(o(e,p)!==o(t,-1==i?0:p-i))-1!=i&&(p-=p-i),i=-1;else if(-1==i&&(i=p),p-i+1===l)return i*s}else for(n+l>d&&(n=d-l),p=n;0<=p;p--){for(var u=!0,c=0;c<l;c++)if(o(e,p+c)!==o(t,c)){u=!1;break}if(u)return p}return-1}function N(e,t,n,a){n=+n||0;var r=e.length-n;a?(a=+a,a>r&&(a=r)):a=r;var o=t.length;if(0!=o%2)throw new TypeError('Invalid hex string');a>o/2&&(a=o/2);for(var s=0,i;s<a;++s){if(i=parseInt(t.substr(2*s,2),16),isNaN(i))return s;e[n+s]=i}return s}function I(e,t,n,a){return Z(Y(t,e.length-n),e,n,a)}function S(e,t,n,a){return Z(Q(t),e,n,a)}function j(e,t,n,a){return S(e,t,n,a)}function R(e,t,n,a){return Z(K(t),e,n,a)}function C(e,t,n,a){return Z(G(t,e.length-n),e,n,a)}function L(e,t,n){return 0===t&&n===e.length?ne.fromByteArray(e):ne.fromByteArray(e.slice(t,n))}function O(e,t,n){n=te(e.length,n);for(var a=[],r=t;r<n;){var o=e[r],i=null,s=239<o?4:223<o?3:191<o?2:1;if(r+s<=n){var d,l,p,u;1==s?128>o&&(i=o):2==s?(d=e[r+1],128==(192&d)&&(u=(31&o)<<6|63&d,127<u&&(i=u))):3==s?(d=e[r+1],l=e[r+2],128==(192&d)&&128==(192&l)&&(u=(15&o)<<12|(63&d)<<6|63&l,2047<u&&(55296>u||57343<u)&&(i=u))):4==s?(d=e[r+1],l=e[r+2],p=e[r+3],128==(192&d)&&128==(192&l)&&128==(192&p)&&(u=(15&o)<<18|(63&d)<<12|(63&l)<<6|63&p,65535<u&&1114112>u&&(i=u))):void 0}null===i?(i=65533,s=1):65535<i&&(i-=65536,a.push(55296|1023&i>>>10),i=56320|1023&i),a.push(i),r+=s}return E(a)}function E(e){var t=e.length;if(t<=oe)return r.apply(String,e);for(var n='',a=0;a<t;)n+=r.apply(String,e.slice(a,a+=oe));return n}function D(e,t,n){var a='';n=te(e.length,n);for(var o=t;o<n;++o)a+=r(127&e[o]);return a}function U(e,t,n){var a='';n=te(e.length,n);for(var o=t;o<n;++o)a+=r(e[o]);return a}function A(e,t,n){var a=e.length;(!t||0>t)&&(t=0),(!n||0>n||n>a)&&(n=a);for(var r='',o=t;o<n;++o)r+=J(e[o]);return r}function P(e,t,n){for(var a=e.slice(t,n),o='',s=0;s<a.length;s+=2)o+=r(a[s]+256*a[s+1]);return o}function M(e,t,n){if(0!=e%1||0>e)throw new RangeError('offset is not uint');if(e+t>n)throw new RangeError('Trying to access beyond buffer length')}function F(e,t,n,a,r,o){if(!l.isBuffer(e))throw new TypeError('"buffer" argument must be a Buffer instance');if(t>r||t<o)throw new RangeError('"value" argument is out of bounds');if(n+a>e.length)throw new RangeError('Index out of range')}function B(e,t,n,a){0>t&&(t=65535+t+1);for(var r=0,o=te(e.length-n,2);r<o;++r)e[n+r]=(t&255<<8*(a?r:1-r))>>>8*(a?r:1-r)}function q(e,t,n,a){0>t&&(t=4294967295+t+1);for(var r=0,o=te(e.length-n,4);r<o;++r)e[n+r]=255&t>>>8*(a?r:3-r)}function H(e,t,n,a,r,o){if(n+a>e.length)throw new RangeError('Index out of range');if(0>n)throw new RangeError('Index out of range')}function z(e,t,n,a,r){return r||H(e,t,n,4,34028234663852886e22,-34028234663852886e22),ae.write(e,t,n,a,23,4),n+4}function V(e,t,n,a,r){return r||H(e,t,n,8,17976931348623157e292,-17976931348623157e292),ae.write(e,t,n,a,52,8),n+8}function X(e){if(e=W(e).replace(ie,''),2>e.length)return'';for(;0!=e.length%4;)e+='=';return e}function W(e){return e.trim?e.trim():e.replace(/^\s+|\s+$/g,'')}function J(e){return 16>e?'0'+e.toString(16):e.toString(16)}function Y(e,t){t=t||Infinity;for(var n=e.length,a=null,r=[],o=0,i;o<n;++o){if(i=e.charCodeAt(o),55295<i&&57344>i){if(!a){if(56319<i){-1<(t-=3)&&r.push(239,191,189);continue}else if(o+1===n){-1<(t-=3)&&r.push(239,191,189);continue}a=i;continue}if(56320>i){-1<(t-=3)&&r.push(239,191,189),a=i;continue}i=(a-55296<<10|i-56320)+65536}else a&&-1<(t-=3)&&r.push(239,191,189);if(a=null,128>i){if(0>(t-=1))break;r.push(i)}else if(2048>i){if(0>(t-=2))break;r.push(192|i>>6,128|63&i)}else if(65536>i){if(0>(t-=3))break;r.push(224|i>>12,128|63&i>>6,128|63&i)}else if(1114112>i){if(0>(t-=4))break;r.push(240|i>>18,128|63&i>>12,128|63&i>>6,128|63&i)}else throw new Error('Invalid code point')}return r}function Q(e){for(var t=[],n=0;n<e.length;++n)t.push(255&e.charCodeAt(n));return t}function G(e,t){for(var n=[],a=0,r,o,i;a<e.length&&!(0>(t-=2));++a)r=e.charCodeAt(a),o=r>>8,i=r%256,n.push(i),n.push(o);return n}function K(e){return ne.toByteArray(X(e))}function Z(e,t,n,a){for(var r=0;r<a&&!(r+n>=t.length||r>=e.length);++r)t[r+n]=e[r];return r}function ee(e){return e!==e}var te=Math.min,ne=o(66),ae=o(67),re=o(47);/*! * The buffer module from node.js, for the browser. * * @author Feross Aboukhadijeh <feross@feross.org> <http://feross.org> * @license MIT */t.Buffer=l,t.SlowBuffer=x,t.INSPECT_MAX_BYTES=50,l.TYPED_ARRAY_SUPPORT=e.TYPED_ARRAY_SUPPORT===void 0?i():e.TYPED_ARRAY_SUPPORT,t.kMaxLength=s(),l.poolSize=8192,l._augment=function(e){return e.__proto__=l.prototype,e},l.from=function(e,t,n){return p(null,e,t,n)},l.TYPED_ARRAY_SUPPORT&&(l.prototype.__proto__=Uint8Array.prototype,l.__proto__=Uint8Array,'undefined'!=typeof Symbol&&Symbol.species&&l[Symbol.species]===l&&Object.defineProperty(l,Symbol.species,{value:null,configurable:!0})),l.alloc=function(e,t,n){return c(null,e,t,n)},l.allocUnsafe=function(e){return h(null,e)},l.allocUnsafeSlow=function(e){return h(null,e)},l.isBuffer=function e(t){return!!(null!=t&&t._isBuffer)},l.compare=function e(t,n){if(!l.isBuffer(t)||!l.isBuffer(n))throw new TypeError('Arguments must be Buffers');if(t===n)return 0;for(var a=t.length,r=n.length,o=0,i=te(a,r);o<i;++o)if(t[o]!==n[o]){a=t[o],r=n[o];break}return a<r?-1:r<a?1:0},l.isEncoding=function e(t){switch((t+'').toLowerCase()){case'hex':case'utf8':case'utf-8':case'ascii':case'latin1':case'binary':case'base64':case'ucs2':case'ucs-2':case'utf16le':case'utf-16le':return!0;default:return!1;}},l.concat=function e(t,n){if(!re(t))throw new TypeError('"list" argument must be an Array of Buffers');if(0===t.length)return l.alloc(0);var a;if(n===void 0)for(n=0,a=0;a<t.length;++a)n+=t[a].length;var r=l.allocUnsafe(n),o=0;for(a=0;a<t.length;++a){var i=t[a];if(!l.isBuffer(i))throw new TypeError('"list" argument must be an Array of Buffers');i.copy(r,o),o+=i.length}return r},l.byteLength=_,l.prototype._isBuffer=!0,l.prototype.swap16=function e(){var t=this.length;if(0!=t%2)throw new RangeError('Buffer size must be a multiple of 16-bits');for(var n=0;n<t;n+=2)w(this,n,n+1);return this},l.prototype.swap32=function e(){var t=this.length;if(0!=t%4)throw new RangeError('Buffer size must be a multiple of 32-bits');for(var n=0;n<t;n+=4)w(this,n,n+3),w(this,n+1,n+2);return this},l.prototype.swap64=function e(){var t=this.length;if(0!=t%8)throw new RangeError('Buffer size must be a multiple of 64-bits');for(var n=0;n<t;n+=8)w(this,n,n+7),w(this,n+1,n+6),w(this,n+2,n+5),w(this,n+3,n+4);return this},l.prototype.toString=function e(){var t=0|this.length;return 0==t?'':0===arguments.length?O(this,0,t):v.apply(this,arguments)},l.prototype.equals=function e(t){if(!l.isBuffer(t))throw new TypeError('Argument must be a Buffer');return this===t||0===l.compare(this,t)},l.prototype.inspect=function e(){var n='',a=t.INSPECT_MAX_BYTES;return 0<this.length&&(n=this.toString('hex',0,a).match(/.{2}/g).join(' '),this.length>a&&(n+=' ... ')),'<Buffer '+n+'>'},l.prototype.compare=function e(t,n,a,r,o){if(!l.isBuffer(t))throw new TypeError('Argument must be a Buffer');if(void 0===n&&(n=0),void 0===a&&(a=t?t.length:0),void 0===r&&(r=0),void 0===o&&(o=this.length),0>n||a>t.length||0>r||o>this.length)throw new RangeError('out of range index');if(r>=o&&n>=a)return 0;if(r>=o)return-1;if(n>=a)return 1;if(n>>>=0,a>>>=0,r>>>=0,o>>>=0,this===t)return 0;for(var s=o-r,d=a-n,p=te(s,d),u=this.slice(r,o),c=t.slice(n,a),h=0;h<p;++h)if(u[h]!==c[h]){s=u[h],d=c[h];break}return s<d?-1:d<s?1:0},l.prototype.includes=function e(t,n,a){return-1!==this.indexOf(t,n,a)},l.prototype.indexOf=function e(t,n,a){return k(this,t,n,a,!0)},l.prototype.lastIndexOf=function e(t,n,a){return k(this,t,n,a,!1)},l.prototype.write=function e(t,n,a,r){if(void 0===n)r='utf8',a=this.length,n=0;else if(void 0===a&&'string'==typeof n)r=n,a=this.length,n=0;else if(isFinite(n))n|=0,isFinite(a)?(a|=0,void 0===r&&(r='utf8')):(r=a,a=void 0);else throw new Error('Buffer.write(string, encoding, offset[, length]) is no longer supported');var o=this.length-n;if((void 0===a||a>o)&&(a=o),0<t.length&&(0>a||0>n)||n>this.length)throw new RangeError('Attempt to write outside buffer bounds');r||(r='utf8');for(var i=!1;;)switch(r){case'hex':return N(this,t,n,a);case'utf8':case'utf-8':return I(this,t,n,a);case'ascii':return S(this,t,n,a);case'latin1':case'binary':return j(this,t,n,a);case'base64':return R(this,t,n,a);case'ucs2':case'ucs-2':case'utf16le':case'utf-16le':return C(this,t,n,a);default:if(i)throw new TypeError('Unknown encoding: '+r);r=(''+r).toLowerCase(),i=!0;}},l.prototype.toJSON=function e(){return{type:'Buffer',data:Array.prototype.slice.call(this._arr||this,0)}};var oe=4096;l.prototype.slice=function e(t,n){var a=this.length;t=~~t,n=n===void 0?a:~~n,0>t?(t+=a,0>t&&(t=0)):t>a&&(t=a),0>n?(n+=a,0>n&&(n=0)):n>a&&(n=a),n<t&&(n=t);var r;if(l.TYPED_ARRAY_SUPPORT)r=this.subarray(t,n),r.__proto__=l.prototype;else{var o=n-t;r=new l(o,void 0);for(var s=0;s<o;++s)r[s]=this[s+t]}return r},l.prototype.readUIntLE=function e(t,n,a){t|=0,n|=0,a||M(t,n,this.length);for(var r=this[t],o=1,s=0;++s<n&&(o*=256);)r+=this[t+s]*o;return r},l.prototype.readUIntBE=function e(t,n,a){t|=0,n|=0,a||M(t,n,this.length);for(var r=this[t+--n],o=1;0<n&&(o*=256);)r+=this[t+--n]*o;return r},l.prototype.readUInt8=function e(t,n){return n||M(t,1,this.length),this[t]},l.prototype.readUInt16LE=function e(t,n){return n||M(t,2,this.length),this[t]|this[t+1]<<8},l.prototype.readUInt16BE=function e(t,n){return n||M(t,2,this.length),this[t]<<8|this[t+1]},l.prototype.readUInt32LE=function e(t,n){return n||M(t,4,this.length),(this[t]|this[t+1]<<8|this[t+2]<<16)+16777216*this[t+3]},l.prototype.readUInt32BE=function e(t,n){return n||M(t,4,this.length),16777216*this[t]+(this[t+1]<<16|this[t+2]<<8|this[t+3])},l.prototype.readIntLE=function e(t,a,r){t|=0,a|=0,r||M(t,a,this.length);for(var o=this[t],s=1,d=0;++d<a&&(s*=256);)o+=this[t+d]*s;return s*=128,o>=s&&(o-=n(2,8*a)),o},l.prototype.readIntBE=function e(t,a,r){t|=0,a|=0,r||M(t,a,this.length);for(var o=a,i=1,s=this[t+--o];0<o&&(i*=256);)s+=this[t+--o]*i;return i*=128,s>=i&&(s-=n(2,8*a)),s},l.prototype.readInt8=function e(t,n){return n||M(t,1,this.length),128&this[t]?-1*(255-this[t]+1):this[t]},l.prototype.readInt16LE=function e(t,n){n||M(t,2,this.length);var a=this[t]|this[t+1]<<8;return 32768&a?4294901760|a:a},l.prototype.readInt16BE=function e(t,n){n||M(t,2,this.length);var a=this[t+1]|this[t]<<8;return 32768&a?4294901760|a:a},l.prototype.readInt32LE=function e(t,n){return n||M(t,4,this.length),this[t]|this[t+1]<<8|this[t+2]<<16|this[t+3]<<24},l.prototype.readInt32BE=function e(t,n){return n||M(t,4,this.length),this[t]<<24|this[t+1]<<16|this[t+2]<<8|this[t+3]},l.prototype.readFloatLE=function e(t,n){return n||M(t,4,this.length),ae.read(this,t,!0,23,4)},l.prototype.readFloatBE=function e(t,n){return n||M(t,4,this.length),ae.read(this,t,!1,23,4)},l.prototype.readDoubleLE=function e(t,n){return n||M(t,8,this.length),ae.read(this,t,!0,52,8)},l.prototype.readDoubleBE=function e(t,n){return n||M(t,8,this.length),ae.read(this,t,!1,52,8)},l.prototype.writeUIntLE=function e(t,a,r,o){if(t=+t,a|=0,r|=0,!o){var s=n(2,8*r)-1;F(this,t,a,r,s,0)}var d=1,l=0;for(this[a]=255&t;++l<r&&(d*=256);)this[a+l]=255&t/d;return a+r},l.prototype.writeUIntBE=function e(t,a,r,o){if(t=+t,a|=0,r|=0,!o){var s=n(2,8*r)-1;F(this,t,a,r,s,0)}var d=r-1,i=1;for(this[a+d]=255&t;0<=--d&&(i*=256);)this[a+d]=255&t/i;return a+r},l.prototype.writeUInt8=function e(t,n,r){return t=+t,n|=0,r||F(this,t,n,1,255,0),l.TYPED_ARRAY_SUPPORT||(t=a(t)),this[n]=255&t,n+1},l.prototype.writeUInt16LE=function e(t,n,a){return t=+t,n|=0,a||F(this,t,n,2,65535,0),l.TYPED_ARRAY_SUPPORT?(this[n]=255&t,this[n+1]=t>>>8):B(this,t,n,!0),n+2},l.prototype.writeUInt16BE=function e(t,n,a){return t=+t,n|=0,a||F(this,t,n,2,65535,0),l.TYPED_ARRAY_SUPPORT?(this[n]=t>>>8,this[n+1]=255&t):B(this,t,n,!1),n+2},l.prototype.writeUInt32LE=function e(t,n,a){return t=+t,n|=0,a||F(this,t,n,4,4294967295,0),l.TYPED_ARRAY_SUPPORT?(this[n+3]=t>>>24,this[n+2]=t>>>16,this[n+1]=t>>>8,this[n]=255&t):q(this,t,n,!0),n+4},l.prototype.writeUInt32BE=function e(t,n,a){return t=+t,n|=0,a||F(this,t,n,4,4294967295,0),l.TYPED_ARRAY_SUPPORT?(this[n]=t>>>24,this[n+1]=t>>>16,this[n+2]=t>>>8,this[n+3]=255&t):q(this,t,n,!1),n+4},l.prototype.writeIntLE=function e(t,a,r,o){if(t=+t,a|=0,!o){var s=n(2,8*r-1);F(this,t,a,r,s-1,-s)}var d=0,i=1,l=0;for(this[a]=255&t;++d<r&&(i*=256);)0>t&&0==l&&0!==this[a+d-1]&&(l=1),this[a+d]=255&(t/i>>0)-l;return a+r},l.prototype.writeIntBE=function e(t,a,r,o){if(t=+t,a|=0,!o){var s=n(2,8*r-1);F(this,t,a,r,s-1,-s)}var d=r-1,i=1,l=0;for(this[a+d]=255&t;0<=--d&&(i*=256);)0>t&&0==l&&0!==this[a+d+1]&&(l=1),this[a+d]=255&(t/i>>0)-l;return a+r},l.prototype.writeInt8=function e(t,n,r){return t=+t,n|=0,r||F(this,t,n,1,127,-128),l.TYPED_ARRAY_SUPPORT||(t=a(t)),0>t&&(t=255+t+1),this[n]=255&t,n+1},l.prototype.writeInt16LE=function e(t,n,a){return t=+t,n|=0,a||F(this,t,n,2,32767,-32768),l.TYPED_ARRAY_SUPPORT?(this[n]=255&t,this[n+1]=t>>>8):B(this,t,n,!0),n+2},l.prototype.writeInt16BE=function e(t,n,a){return t=+t,n|=0,a||F(this,t,n,2,32767,-32768),l.TYPED_ARRAY_SUPPORT?(this[n]=t>>>8,this[n+1]=255&t):B(this,t,n,!1),n+2},l.prototype.writeInt32LE=function e(t,n,a){return t=+t,n|=0,a||F(this,t,n,4,2147483647,-2147483648),l.TYPED_ARRAY_SUPPORT?(this[n]=255&t,this[n+1]=t>>>8,this[n+2]=t>>>16,this[n+3]=t>>>24):q(this,t,n,!0),n+4},l.prototype.writeInt32BE=function e(t,n,a){return t=+t,n|=0,a||F(this,t,n,4,2147483647,-2147483648),0>t&&(t=4294967295+t+1),l.TYPED_ARRAY_SUPPORT?(this[n]=t>>>24,this[n+1]=t>>>16,this[n+2]=t>>>8,this[n+3]=255&t):q(this,t,n,!1),n+4},l.prototype.writeFloatLE=function e(t,n,a){return z(this,t,n,!0,a)},l.prototype.writeFloatBE=function e(t,n,a){return z(this,t,n,!1,a)},l.prototype.writeDoubleLE=function e(t,n,a){return V(this,t,n,!0,a)},l.prototype.writeDoubleBE=function e(t,n,a){return V(this,t,n,!1,a)},l.prototype.copy=function e(t,n,a,r){if(a||(a=0),r||0===r||(r=this.length),n>=t.length&&(n=t.length),n||(n=0),0<r&&r<a&&(r=a),r===a)return 0;if(0===t.length||0===this.length)return 0;if(0>n)throw new RangeError('targetStart out of bounds');if(0>a||a>=this.length)throw new RangeError('sourceStart out of bounds');if(0>r)throw new RangeError('sourceEnd out of bounds');r>this.length&&(r=this.length),t.length-n<r-a&&(r=t.length-n+a);var o=r-a,s;if(this===t&&a<n&&n<r)for(s=o-1;0<=s;--s)t[s+n]=this[s+a];else if(1e3>o||!l.TYPED_ARRAY_SUPPORT)for(s=0;s<o;++s)t[s+n]=this[s+a];else Uint8Array.prototype.set.call(t,this.subarray(a,a+o),n);return o},l.prototype.fill=function e(t,n,a,r){if('string'==typeof t){if('string'==typeof n?(r=n,n=0,a=this.length):'string'==typeof a&&(r=a,a=this.length),1===t.length){var o=t.charCodeAt(0);256>o&&(t=o)}if(void 0!==r&&'string'!=typeof r)throw new TypeError('encoding must be a string');if('string'==typeof r&&!l.isEncoding(r))throw new TypeError('Unknown encoding: '+r)}else'number'==typeof t&&(t&=255);if(0>n||this.length<n||this.length<a)throw new RangeError('Out of range index');if(a<=n)return this;n>>>=0,a=a===void 0?this.length:a>>>0,t||(t=0);var s;if('number'==typeof t)for(s=n;s<a;++s)this[s]=t;else{var i=l.isBuffer(t)?t:Y(new l(t,r).toString()),d=i.length;for(s=0;s<a-n;++s)this[s+n]=i[s%d]}return this};var ie=/[^+\/0-9A-Za-z-_]/g}).call(this,o(3))},function(e,t,n){'use strict';function a(e,t){var n=this,a=this._readableState&&this._readableState.destroyed,r=this._writableState&&this._writableState.destroyed;return a||r?(t?t(e):e&&(!this._writableState||!this._writableState.errorEmitted)&&i.nextTick(o,this,e),this):(this._readableState&&(this._readableState.destroyed=!0),this._writableState&&(this._writableState.destroyed=!0),this._destroy(e||null,function(e){!t&&e?(i.nextTick(o,n,e),n._writableState&&(n._writableState.errorEmitted=!0)):t&&t(e)}),this)}function r(){this._readableState&&(this._readableState.destroyed=!1,this._readableState.reading=!1,this._readableState.ended=!1,this._readableState.endEmitted=!1),this._writableState&&(this._writableState.destroyed=!1,this._writableState.ended=!1,this._writableState.ending=!1,this._writableState.finished=!1,this._writableState.errorEmitted=!1)}function o(e,t){e.emit('error',t)}var i=n(18);e.exports={destroy:a,undestroy:r}},function(e,t,n){'use strict';function a(e){if(!e)return'utf8';for(var t;!0;)switch(e){case'utf8':case'utf-8':return'utf8';case'ucs2':case'ucs-2':case'utf16le':case'utf-16le':return'utf16le';case'latin1':case'binary':return'latin1';case'base64':case'ascii':case'hex':return e;default:if(t)return;e=(''+e).toLowerCase(),t=!0;}}function r(e){var t=a(e);if('string'!=typeof t&&(b.isEncoding===x||!x(e)))throw new Error('Unknown encoding: '+e);return t||e}function o(e){this.encoding=r(e);var t;switch(this.encoding){case'utf16le':this.text=c,this.end=h,t=4;break;case'utf8':this.fillLast=l,t=4;break;case'base64':this.text=f,this.end=g,t=3;break;default:return this.write=m,void(this.end=y);}this.lastNeed=0,this.lastTotal=0,this.lastChar=b.allocUnsafe(t)}function s(e){if(127>=e)return 0;return 6==e>>5?2:14==e>>4?3:30==e>>3?4:2==e>>6?-1:-2}function d(e,t,n){var a=t.length-1;if(a<n)return 0;var r=s(t[a]);return 0<=r?(0<r&&(e.lastNeed=r-1),r):--a<n||-2===r?0:(r=s(t[a]),0<=r)?(0<r&&(e.lastNeed=r-2),r):--a<n||-2===r?0:(r=s(t[a]),0<=r?(0<r&&(2===r?r=0:e.lastNeed=r-3),r):0)}function i(e,t,n){if(128!=(192&t[0]))return e.lastNeed=0,'\uFFFD';if(1<e.lastNeed&&1<t.length){if(128!=(192&t[1]))return e.lastNeed=1,'\uFFFD';if(2<e.lastNeed&&2<t.length&&128!=(192&t[2]))return e.lastNeed=2,'\uFFFD'}}function l(e){var t=this.lastTotal-this.lastNeed,n=i(this,e,t);return void 0===n?this.lastNeed<=e.length?(e.copy(this.lastChar,t,0,this.lastNeed),this.lastChar.toString(this.encoding,0,this.lastTotal)):void(e.copy(this.lastChar,t,0,e.length),this.lastNeed-=e.length):n}function p(e,t){var n=d(this,e,t);if(!this.lastNeed)return e.toString('utf8',t);this.lastTotal=n;var a=e.length-(n-this.lastNeed);return e.copy(this.lastChar,0,a),e.toString('utf8',t,a)}function u(e){var t=e&&e.length?this.write(e):'';return this.lastNeed?t+'\uFFFD':t}function c(e,t){if(0==(e.length-t)%2){var n=e.toString('utf16le',t);if(n){var a=n.charCodeAt(n.length-1);if(55296<=a&&56319>=a)return this.lastNeed=2,this.lastTotal=4,this.lastChar[0]=e[e.length-2],this.lastChar[1]=e[e.length-1],n.slice(0,-1)}return n}return this.lastNeed=1,this.lastTotal=2,this.lastChar[0]=e[e.length-1],e.toString('utf16le',t,e.length-1)}function h(e){var t=e&&e.length?this.write(e):'';if(this.lastNeed){var n=this.lastTotal-this.lastNeed;return t+this.lastChar.toString('utf16le',0,n)}return t}function f(e,t){var a=(e.length-t)%3;return 0==a?e.toString('base64',t):(this.lastNeed=3-a,this.lastTotal=3,1==a?this.lastChar[0]=e[e.length-1]:(this.lastChar[0]=e[e.length-2],this.lastChar[1]=e[e.length-1]),e.toString('base64',t,e.length-a))}function g(e){var t=e&&e.length?this.write(e):'';return this.lastNeed?t+this.lastChar.toString('base64',0,3-this.lastNeed):t}function m(e){return e.toString(this.encoding)}function y(e){return e&&e.length?this.write(e):''}var b=n(19).Buffer,x=b.isEncoding||function(e){switch(e=''+e,e&&e.toLowerCase()){case'hex':case'utf8':case'utf-8':case'ascii':case'binary':case'base64':case'ucs2':case'ucs-2':case'utf16le':case'utf-16le':case'raw':return!0;default:return!1;}};;t.StringDecoder=o,o.prototype.write=function(e){if(0===e.length)return'';var t,n;if(this.lastNeed){if(t=this.fillLast(e),void 0===t)return'';n=this.lastNeed,this.lastNeed=0}else n=0;return n<e.length?t?t+this.text(e,n):this.text(e,n):t||''},o.prototype.end=u,o.prototype.text=p,o.prototype.fillLast=function(e){return this.lastNeed<=e.length?(e.copy(this.lastChar,this.lastTotal-this.lastNeed,0,this.lastNeed),this.lastChar.toString(this.encoding,0,this.lastTotal)):void(e.copy(this.lastChar,this.lastTotal-this.lastNeed,0,e.length),this.lastNeed-=e.length)}},function(e,t,n){'use strict';function a(e,t){var n=this._transformState;n.transforming=!1;var a=n.writecb;if(!a)return this.emit('error',new Error('write callback called multiple times'));n.writechunk=null,n.writecb=null,null!=t&&this.push(t),a(e);var r=this._readableState;r.reading=!1,(r.needReadable||r.length<r.highWaterMark)&&this._read(r.highWaterMark)}function r(e){return this instanceof r?void(s.call(this,e),this._transformState={afterTransform:a.bind(this),needTransform:!1,transforming:!1,writecb:null,writechunk:null,writeencoding:null},this._readableState.needReadable=!0,this._readableState.sync=!1,e&&('function'==typeof e.transform&&(this._transform=e.transform),'function'==typeof e.flush&&(this._flush=e.flush)),this.on('prefinish',o)):new r(e)}function o(){var e=this;'function'==typeof this._flush?this._flush(function(t,n){i(e,t,n)}):i(this,null,null)}function i(e,t,n){if(t)return e.emit('error',t);if(null!=n&&e.push(n),e._writableState.length)throw new Error('Calling transform done when ws.length != 0');if(e._transformState.transforming)throw new Error('Calling transform done when still transforming');return e.push(null)}e.exports=r;var s=n(8),d=n(14);d.inherits=n(7),d.inherits(r,s),r.prototype.push=function(e,t){return this._transformState.needTransform=!1,s.prototype.push.call(this,e,t)},r.prototype._transform=function(e,t,n){throw new Error('_transform() is not implemented')},r.prototype._write=function(e,t,n){var a=this._transformState;if(a.writecb=n,a.writechunk=e,a.writeencoding=t,!a.transforming){var r=this._readableState;(a.needTransform||r.needReadable||r.length<r.highWaterMark)&&this._read(r.highWaterMark)}},r.prototype._read=function(e){var t=this._transformState;null!==t.writechunk&&t.writecb&&!t.transforming?(t.transforming=!0,this._transform(t.writechunk,t.writeencoding,t.afterTransform)):t.needTransform=!0},r.prototype._destroy=function(e,t){var n=this;s.prototype._destroy.call(this,e,function(e){t(e),n.emit('close')})}},function(e,t,n){(function(e,a){function r(e,n){var a={seen:[],stylize:i};return 3<=arguments.length&&(a.depth=arguments[2]),4<=arguments.length&&(a.colors=arguments[3]),g(n)?a.showHidden=n:n&&t._extend(a,n),v(a.showHidden)&&(a.showHidden=!1),v(a.depth)&&(a.depth=2),v(a.colors)&&(a.colors=!1),v(a.customInspect)&&(a.customInspect=!0),a.colors&&(a.stylize=o),d(a,e,a.depth)}function o(e,t){var n=r.styles[t];return n?'\x1B['+r.colors[n][0]+'m'+e+'\x1B['+r.colors[n][1]+'m':e}function i(e,t){return e}function s(e){var t={};return e.forEach(function(e,n){t[e]=!0}),t}function d(e,a,r){if(e.customInspect&&a&&I(a.inspect)&&a.inspect!==t.inspect&&!(a.constructor&&a.constructor.prototype===a)){var o=a.inspect(r,e);return _(o)||(o=d(e,o,r)),o}var i=l(e,a);if(i)return i;var g=Object.keys(a),m=s(g);if(e.showHidden&&(g=Object.getOwnPropertyNames(a)),N(a)&&(0<=g.indexOf('message')||0<=g.indexOf('description')))return p(a);if(0===g.length){if(I(a)){var y=a.name?': '+a.name:'';return e.stylize('[Function'+y+']','special')}if(w(a))return e.stylize(RegExp.prototype.toString.call(a),'regexp');if(T(a))return e.stylize(Date.prototype.toString.call(a),'date');if(N(a))return p(a)}var b='',x=!1,v=['{','}'];if(f(a)&&(x=!0,v=['[',']']),I(a)){var k=a.name?': '+a.name:'';b=' [Function'+k+']'}if(w(a)&&(b=' '+RegExp.prototype.toString.call(a)),T(a)&&(b=' '+Date.prototype.toUTCString.call(a)),N(a)&&(b=' '+p(a)),0===g.length&&(!x||0==a.length))return v[0]+b+v[1];if(0>r)return w(a)?e.stylize(RegExp.prototype.toString.call(a),'regexp'):e.stylize('[Object]','special');e.seen.push(a);var n;return n=x?u(e,a,r,m,g):g.map(function(t){return c(e,a,r,m,t,x)}),e.seen.pop(),h(n,b,v)}function l(e,t){if(v(t))return e.stylize('undefined','undefined');if(_(t)){var n='\''+JSON.stringify(t).replace(/^"|"$/g,'').replace(/'/g,'\\\'').replace(/\\"/g,'"')+'\'';return e.stylize(n,'string')}return b(t)?e.stylize(''+t,'number'):g(t)?e.stylize(''+t,'boolean'):m(t)?e.stylize('null','null'):void 0}function p(e){return'['+Error.prototype.toString.call(e)+']'}function u(e,t,n,a,r){for(var o=[],s=0,i=t.length;s<i;++s)L(t,s+'')?o.push(c(e,t,n,a,s+'',!0)):o.push('');return r.forEach(function(r){r.match(/^\d+$/)||o.push(c(e,t,n,a,r,!0))}),o}function c(e,t,n,a,r,o){var i,s,l;if(l=Object.getOwnPropertyDescriptor(t,r)||{value:t[r]},l.get?l.set?s=e.stylize('[Getter/Setter]','special'):s=e.stylize('[Getter]','special'):l.set&&(s=e.stylize('[Setter]','special')),L(a,r)||(i='['+r+']'),s||(0>e.seen.indexOf(l.value)?(s=m(n)?d(e,l.value,null):d(e,l.value,n-1),-1<s.indexOf('\n')&&(o?s=s.split('\n').map(function(e){return' '+e}).join('\n').substr(2):s='\n'+s.split('\n').map(function(e){return' '+e}).join('\n'))):s=e.stylize('[Circular]','special')),v(i)){if(o&&r.match(/^\d+$/))return s;i=JSON.stringify(''+r),i.match(/^"([a-zA-Z_][a-zA-Z_0-9]*)"$/)?(i=i.substr(1,i.length-2),i=e.stylize(i,'name')):(i=i.replace(/'/g,'\\\'').replace(/\\"/g,'"').replace(/(^"|"$)/g,'\''),i=e.stylize(i,'string'))}return i+': '+s}function h(e,t,n){var a=0,r=e.reduce(function(e,t){return a++,0<=t.indexOf('\n')&&a++,e+t.replace(/\u001b\[\d\d?m/g,'').length+1},0);return 60<r?n[0]+(''===t?'':t+'\n ')+' '+e.join(',\n ')+' '+n[1]:n[0]+t+' '+e.join(', ')+' '+n[1]}function f(e){return Array.isArray(e)}function g(e){return'boolean'==typeof e}function m(e){return null===e}function y(e){return null==e}function b(e){return'number'==typeof e}function _(e){return'string'==typeof e}function x(e){return'symbol'==typeof e}function v(e){return void 0===e}function w(e){return k(e)&&'[object RegExp]'===j(e)}function k(e){return'object'==typeof e&&null!==e}function T(e){return k(e)&&'[object Date]'===j(e)}function N(t){return k(t)&&('[object Error]'===j(t)||t instanceof Error)}function I(e){return'function'==typeof e}function S(e){return null===e||'boolean'==typeof e||'number'==typeof e||'string'==typeof e||'symbol'==typeof e||'undefined'==typeof e}function j(e){return Object.prototype.toString.call(e)}function R(e){return 10>e?'0'+e.toString(10):e.toString(10)}function C(){var e=new Date,t=[R(e.getHours()),R(e.getMinutes()),R(e.getSeconds())].join(':');return[e.getDate(),U[e.getMonth()],t].join(' ')}function L(e,t){return Object.prototype.hasOwnProperty.call(e,t)}var O=/%[sdj%]/g;t.format=function(e){if(!_(e)){for(var t=[],n=0;n<arguments.length;n++)t.push(r(arguments[n]));return t.join(' ')}for(var n=1,a=arguments,o=a.length,i=(e+'').replace(O,function(e){if('%%'===e)return'%';if(n>=o)return e;switch(e){case'%s':return a[n++]+'';case'%d':return+a[n++];case'%j':try{return JSON.stringify(a[n++])}catch(e){return'[Circular]'}default:return e;}}),s=a[n];n<o;s=a[++n])i+=m(s)||!k(s)?' '+s:' '+r(s);return i},t.deprecate=function(n,r){function o(){if(!i){if(a.throwDeprecation)throw new Error(r);else a.traceDeprecation?console.trace(r):console.error(r);i=!0}return n.apply(this,arguments)}if(v(e.process))return function(){return t.deprecate(n,r).apply(this,arguments)};if(!0===a.noDeprecation)return n;var i=!1;return o};var E={},D;t.debuglog=function(e){if(v(D)&&(D=a.env.NODE_DEBUG||''),e=e.toUpperCase(),!E[e])if(new RegExp('\\b'+e+'\\b','i').test(D)){var n=a.pid;E[e]=function(){var a=t.format.apply(t,arguments);console.error('%s %d: %s',e,n,a)}}else E[e]=function(){};return E[e]},t.inspect=r,r.colors={bold:[1,22],italic:[3,23],underline:[4,24],inverse:[7,27],white:[37,39],grey:[90,39],black:[30,39],blue:[34,39],cyan:[36,39],green:[32,39],magenta:[35,39],red:[31,39],yellow:[33,39]},r.styles={special:'cyan',number:'yellow',boolean:'yellow',undefined:'grey',null:'bold',string:'green',date:'magenta',regexp:'red'},t.isArray=f,t.isBoolean=g,t.isNull=m,t.isNullOrUndefined=y,t.isNumber=b,t.isString=_,t.isSymbol=x,t.isUndefined=v,t.isRegExp=w,t.isObject=k,t.isDate=T,t.isError=N,t.isFunction=I,t.isPrimitive=S,t.isBuffer=n(77);var U=['Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec'];t.log=function(){console.log('%s - %s',C(),t.format.apply(t,arguments))},t.inherits=n(7),t._extend=function(e,t){if(!t||!k(t))return e;for(var n=Object.keys(t),a=n.length;a--;)e[n[a]]=t[n[a]];return e}}).call(this,n(3),n(5))},function(e,t,n){function a(e){if(!(this instanceof a))return new a(e);r.call(this,{encoding:'utf8'}),this._writableState.objectMode=!0;var t=this,n=new i({write:function(e,n,a){t.push(e),a&&a()},end:function(e){t.push(null),e&&e()}},e);this._transform=function(e,t,a){n.addTriple(e,a)},this._flush=function(e){n.end(e)}}var r=n(45).Transform,o=n(53),i=n(31);o.inherits(a,r),e.exports=a},function(e,t,n){'use strict';function a(e){return a='function'==typeof Symbol&&'symbol'==typeof Symbol.iterator?function e(t){return typeof t}:function e(t){return t&&'function'==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?'symbol':typeof t},a(e)}function r(e,t){if(!(e instanceof t))throw new TypeError('Cannot call a class as a function')}function o(e,t){for(var n=0,a;n<t.length;n++)a=t[n],a.enumerable=a.enumerable||!1,a.configurable=!0,'value'in a&&(a.writable=!0),Object.defineProperty(e,a.key,a)}function i(e,t,n){return t&&o(e.prototype,t),n&&o(e,n),e}function s(e,t){return t&&('object'===a(t)||'function'==typeof t)?t:d(e)}function d(e){if(void 0===e)throw new ReferenceError('this hasn\'t been initialised - super() hasn\'t been called');return e}function l(e){return l=Object.setPrototypeOf?Object.getPrototypeOf:function e(t){return t.__proto__||Object.getPrototypeOf(t)},l(e)}function p(e,t){if('function'!=typeof t&&null!==t)throw new TypeError('Super expression must either be null or a function');e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&u(e,t)}function u(e,t){return u=Object.setPrototypeOf||function e(t,n){return t.__proto__=n,t},u(e,t)}var c=n(6),h=n(10),f=n(17),g=n(11),m=n(9),y=n(0),b=n(1),x=n(33),_=n(21),v=n(22),w=function(e){function t(e,n,a,o){var i;return r(this,t),i=s(this,l(t).call(this)),i.termType=t.termType,i.statements=e||[],i.constraints=n||[],i.initBindings=a||[],i.optional=o||[],i}return p(t,e),i(t,[{key:'add',value:function e(t,n,a,r){return this.statements.push(new _(t,n,a,r))}},{key:'addStatement',value:function e(t){return this.statements.push(t)}},{key:'bnode',value:function e(t){return new c(t)}},{key:'bottomTypeURIs',value:function e(t){var n,a,r,o,i,s,d,l,p;for(i in n=[],t)if(t.hasOwnProperty(i)){for(p=t[i],l=this.each(void 0,this.sym('http://www.w3.org/2000/01/rdf-schema#subClassOf'),this.sym(i)),a=!0,o=0,s=l.length;o<s;o++)if(r=l[o],d=r.uri,d in t){a=!1;break}a&&(n[i]=p)}return n}},{key:'collection',value:function e(){return new f}},{key:'each',value:function e(t,n,a,r){var o=[],s=this.statementsMatching(t,n,a,r,!1),d,p,i,l,u,c,h,f,g;if(null==t)for(p=0,c=s.length;p<c;p++)d=s[p],o.push(d.subject);else if(null==n)for(i=0,h=s.length;i<h;i++)d=s[i],o.push(d.predicate);else if(null==a)for(l=0,f=s.length;l<f;l++)d=s[l],o.push(d.object);else if(null==r)for(u=0,g=s.length;u<g;u++)d=s[u],o.push(d.why);return o}},{key:'equals',value:function e(t){return!!t&&this.hashString()===t.hashString()}},{key:'findMembersNT',value:function e(n){var a,r,o,i,s,d,l,p,c,h,f,g,m,y,b,x,_,v,w,k,t;for(k in v={},v[n.toNT()]=!0,c={},g=this.transitiveClosure(v,this.sym('http://www.w3.org/2000/01/rdf-schema#subClassOf'),!0),g)if(g.hasOwnProperty(k)){for(m=this.statementsMatching(void 0,this.sym('http://www.w3.org/1999/02/22-rdf-syntax-ns#type'),this.fromNT(k)),a=0,o=m.length;a<o;a++)w=m[a],c[w.subject.toNT()]=w;for(y=this.each(void 0,this.sym('http://www.w3.org/2000/01/rdf-schema#domain'),this.fromNT(k)),r=0,i=y.length;r<i;r++)for(h=y[r],b=this.statementsMatching(void 0,h),(p=0,s=b.length);p<s;p++)w=b[p],c[w.subject.toNT()]=w;for(x=this.each(void 0,this.sym('http://www.w3.org/2000/01/rdf-schema#range'),this.fromNT(k)),f=0,d=x.length;f<d;f++)for(h=x[f],_=this.statementsMatching(void 0,h),(t=0,l=_.length);t<l;t++)w=_[t],c[w.object.toNT()]=w}return c}},{key:'findMemberURIs',value:function e(t){return this.NTtoURI(this.findMembersNT(t))}},{key:'findSubClassesNT',value:function e(t){var n={};return n[t.toNT()]=!0,this.transitiveClosure(n,this.sym('http://www.w3.org/2000/01/rdf-schema#subClassOf'),!0)}},{key:'findSuperClassesNT',value:function e(t){var n={};return n[t.toNT()]=!0,this.transitiveClosure(n,this.sym('http://www.w3.org/2000/01/rdf-schema#subClassOf'),!1)}},{key:'findTypesNT',value:function e(t){var n,a,r,o,i,s,d,l,p,u,c,h,f,g,m,y,b;for(c='http://www.w3.org/1999/02/22-rdf-syntax-ns#type',b=[],h=this.statementsMatching(t,void 0,void 0),(a=0,o=h.length);a<o;a++)if(y=h[a],y.predicate.uri===c)b[y.object.toNT()]=y;else for(f=this.each(y.predicate,this.sym('http://www.w3.org/2000/01/rdf-schema#domain')),r=0,i=f.length;r<i;r++)u=f[r],b[u.toNT()]=y;for(g=this.statementsMatching(void 0,void 0,t),l=0,s=g.length;l<s;l++)for(y=g[l],m=this.each(y.predicate,this.sym('http://www.w3.org/2000/01/rdf-schema#range')),(p=0,d=m.length);p<d;p++)n=m[p],b[n.toNT()]=y;return this.transitiveClosure(b,this.sym('http://www.w3.org/2000/01/rdf-schema#subClassOf'),!1)}},{key:'findTypeURIs',value:function e(t){return this.NTtoURI(this.findTypesNT(t))}},{key:'connectedStatements',value:function e(t,n,a){a=a||[];for(var r=[t],o=[],i=[],s=[],d=this,l=function e(t){var l=function e(t){'BlankNode'!==t.termType||o[t.value]||(o[t.value]=!0,r.push(t))},p=d.statementsMatching(null,null,t,n).concat(d.statementsMatching(t,null,null,n));p=p.filter(function(e){if(a[e.predicate.uri])return!1;var t=e.toNT();return!i[t]&&(i[t]=!0,!0)}),p.forEach(function(e,t){l(e.subject),l(e.object)}),s=s.concat(p)};r.length;)l(r.shift());return s}},{key:'formula',value:function e(){return new t}},{key:'fromNT',value:function e(t){var n,a,r,o;switch(t[0]){case'<':return this.sym(t.slice(1,-1));case'"':if(r=void 0,n=void 0,a=t.lastIndexOf('"'),a<t.length-1)if('@'===t[a+1])r=t.slice(a+2);else if('^^'===t.slice(a+1,a+3))n=this.fromNT(t.slice(a+3));else throw new Error('Can\'t convert string from NT: '+t);return t=t.slice(1,a),t=t.replace(/\\"/g,'"'),t=t.replace(/\\n/g,'\n'),t=t.replace(/\\\\/g,'\\'),this.literal(t,r,n);case'_':return new c(t.slice(2));case'?':return new v(t.slice(1));}throw new Error('Can\'t convert from NT: '+t)}},{key:'holds',value:function e(t,n,a,r){var o;if(1===arguments.length){if(!t)return!0;if(t instanceof Array){for(o=0;o<t.length;o++)if(!this.holds(t[o]))return!1;return!0}if(t instanceof _)return this.holds(t.subject,t.predicate,t.object,t.why);if(t.statements)return this.holds(t.statements)}var i=this.anyStatementMatching(t,n,a,r);return null!=i}},{key:'holdsStatement',value:function e(t){return this.holds(t.subject,t.predicate,t.object,t.why)}},{key:'list',value:function e(t){var n=new f;return t.forEach(function(e){n.append(e)}),n}},{key:'literal',value:function e(t,n,a){return new g(''+t,n,a)}},{key:'NTtoURI',value:function e(n){var t={},a,r;for(a in n)n.hasOwnProperty(a)&&(r=n[a],'<'===a[0]&&(t[a.slice(1,-1)]=r));return t}},{key:'serialize',value:function e(t,n,a){var r,o,i;switch(i=x(this),i.suggestNamespaces(this.namespaces),i.setBase(t),o=a?this.statementsMatching(void 0,void 0,void 0,a):this.statements,null==n?'text/n3':n){case'application/rdf+xml':r=i.statementsToXML(o);break;case'text/n3':case'text/turtle':r=i.statementsToN3(o);break;default:throw new Error('serialize: Content-type '+n+' not supported.');}return r}},{key:'substitute',value:function e(n){var a=this.statements.map(function(e){return e.substitute(n)});console.log('Formula subs statmnts:'+a);var r=new t;return r.add(a),console.log('indexed-form subs formula:'+r),r}},{key:'sym',value:function e(t,n){if(n)throw new Error('This feature (kb.sym with 2 args) is removed. Do not assume prefix mappings.');return new y(t)}},{key:'the',value:function e(t,n,a,r){var o=this.any(t,n,a,r);return null==o&&m.error('No value found for the() {'+t+' '+n+' '+a+'}.'),o}},{key:'transitiveClosure',value:function e(n,a,r){var o={},d,l,i,p,s,u;Object.assign(o,n);for(var t={};!0;){if(u=function(){for(var e in o)if(o.hasOwnProperty(e))return e}(),null==u)return t;for(s=r?this.each(void 0,a,this.fromNT(u)):this.each(this.fromNT(u),a),l=0,i=s.length;l<i;l++)(d=s[l],p=d.toNT(),!(p in t))&&(p in o||(o[p]=o[u]));t[u]=o[u],delete o[u]}}},{key:'topTypeURIs',value:function e(t){var a,r,o,i,s,n,d,l;for(o in d=[],t)if(t.hasOwnProperty(o)){for(l=t[o],s=0,n=this.each(this.sym(o),this.sym('http://www.w3.org/2000/01/rdf-schema#subClassOf')),(a=0,i=n.length);a<i;a++)if(r=n[a],'http://www.w3.org/2000/01/rdf-schema#Resource'!==r.uri){s++;break}s||(d[o]=l)}return d['http://www.w3.org/2000/01/rdf-schema#Resource']&&delete d['http://www.w3.org/2000/01/rdf-schema#Resource'],d['http://www.w3.org/2002/07/owl#Thing']&&delete d['http://www.w3.org/2002/07/owl#Thing'],d}},{key:'toString',value:function e(){return'{'+this.statements.join('\n')+'}'}},{key:'whether',value:function e(t,n,a,r){return this.statementsMatching(t,n,a,r,!1).length}}]),t}(b);w.termType='Graph',w.prototype.classOrder=h.Graph,w.prototype.isVar=0,w.prototype.ns=n(16),w.prototype.variable=function(e){return new v(e)},e.exports=w},function(e,t,n){function a(e,t,n,a,f){function g(){f&&f(null,t)}function m(r){if('application/ld+json'!==a||'application/nquads'!==a||'application/n-quads'!==a)if(f)f(r,t);else throw new Error('Error trying to parse <'+n+'> as '+a+':\n'+r+':\n'+r.stack)}function y(e,n){e&&f(e,t);try{k.parse(n,b)}catch(e){f(e,t)}}function b(e,n,a){if(e&&f(e,t),n)T.push(n);else{for(var r=0;r<T.length;r++)x(t,T[r]);f(null,t)}}function x(e,t){var n=_(t.subject),a=_(t.predicate),r=_(t.object),o=null;t.graph&&(o=_(t.graph)),e.add(n,a,r,o)}function _(e){var t;if(s.Util.isLiteral(e)){t=s.Util.getLiteralValue(e);var n=s.Util.getLiteralLanguage(e),a=new l(s.Util.getLiteralType(e));return new i(t,n,a)}return s.Util.isIRI(e)?new l(e):s.Util.isBlank(e)?(t=e.substring(2,e.length),new r(t)):null}a=a||'text/turtle',a=a.split(';')[0];try{if('text/n3'===a||'text/turtle'===a){var v=d(t,t,n,n,null,null,'',null);v.loadBuf(e),g()}else if('application/rdf+xml'===a){var w=new p(t);w.parse(h.parseXML(e),n,t.sym(n)),g()}else if('application/xhtml+xml'===a)u(h.parseXML(e,{contentType:'application/xhtml+xml'}),t,n),g();else if('text/html'===a)u(h.parseXML(e,{contentType:'text/html'}),t,n),g();else if('application/sparql-update'===a)c(e,t,n),g();else if('application/ld+json'===a||'application/nquads'===a||'application/n-quads'===a){var k=s.Parser(),T=[];if('application/ld+json'===a){var N;try{N=JSON.parse(e)}catch(e){return f(e,null)}o.toRDF(N,{format:'application/nquads',base:n},y)}else y(null,e)}else throw new Error('Don\'t know how to parse '+a+' yet')}catch(t){m(t)}}e.exports=a;var r=n(6),o=n(39),i=n(11),s=n(42),d=n(24),l=n(0),u=n(35).parseRDFaDOM,p=n(36),c=n(57),h=n(4)},function(e,t,n){function a(e,t,n){var a=['INSERT','DELETE','WHERE'],s=o('http://www.w3.org/ns/pim/patch#'),d=r(t,t,n,n,null,null,'',null),l={},p=function e(t,n,a,r,o){return'Line '+(n+1)+' of <'+t+'>: Bad syntax:\n '+o+'\n at: "'+a.slice(r,r+30)+'"'},u,i,c;u=0;var h=t.sym(n+'#query');for(l.query=h;!0;){if(i=d.skipSpace(e,u),0>i)return l;if(';'===e[i]){if(u=d.skipSpace(e,i+1),0>u)return l;i=u}var f=!1;for(c=0;c<a.length;c++){var g=a[c];if(e.slice(i,i+g.length)===g){if(u=d.skipSpace(e,i+g.length),0>u)throw p(d._thisDoc,d.lines,e,i+g.length,'found EOF, needed {...} after '+g);if(('INSERT'===g||'DELETE'===g)&&'DATA'===e.slice(u,u+4)){if(i=d.skipSpace(e,u+4),0>i)throw p(d._thisDoc,d.lines,e,u+4,'needed {...} after INSERT DATA '+g);u=i}var m=[];if(i=d.node(e,u,m),0>i)throw p(d._thisDoc,d.lines,e,u,'bad syntax or EOF in {...} after '+g);l[g.toLowerCase()]=m[0],t.add(h,s(g.toLowerCase()),m[0]),f=!0,u=i}}if(!f&&'@prefix'===e.slice(i,i+7)){if(u=d.directive(e,i),0>u)throw p(d._thisDoc,d.lines,e,u,'bad syntax or EOF after @prefix ');u=d.checkDot(e,u),f=!0}if(!f)throw p(d._thisDoc,d.lines,e,i,'Unknown syntax at start of statememt: \''+e.slice(i).slice(0,20)+'\'')}}e.exports=a;var r=n(24),o=n(16)},function(e,t,n){function a(e,t){if(!(e instanceof t))throw new TypeError('Cannot call a class as a function')}function r(e,t){for(var n=0,a;n<t.length;n++)a=t[n],a.enumerable=a.enumerable||!1,a.configurable=!0,'value'in a&&(a.writable=!0),Object.defineProperty(e,a.key,a)}function o(e,t,n){return t&&r(e.prototype,t),n&&r(e,n),e}var i=n(20).namedNode,s=function(){function e(t,n){a(this,e),this.parent=t,this.via=n,this.connected=!1,this.pending={},this.subscribed={},this.socket={};try{this.socket=new WebSocket(n),this.socket.onopen=this.onOpen,this.socket.onclose=this.onClose,this.socket.onmessage=this.onMessage,this.socket.onerror=this.onError}catch(e){this.onError(e)}}return o(e,[{key:'_decode',value:function e(t){var n,a,o,i,r,s,d;for(a in i={},r=function(){var e,a,r,o;for(r=t.split('&'),o=[],(e=0,a=r.length);e<a;e++)n=r[e],o.push(n.split('='));return o}(),r)n=r[a],s=[decodeURIComponent(n[0]),decodeURIComponent(n[1])],o=s[0],d=s[1],null==i[o]&&(i[o]=[]),i[o].push(d);return i}},{key:'_send',value:function e(t,n,a){var r,o;return o=[t,n,a].join(' '),'function'==typeof(r=this.socket).send?r.send(o):void 0}},{key:'_subscribe',value:function e(t){return this._send('sub',t,''),this.subscribed[t]=!0,this.subscribed[t]}},{key:'onClose',value:function t(n){var e;for(e in this.connected=!1,this.subscribed)this.pending[e]=!0;return this.subscribed={},this.subscribed}},{key:'onError',value:function t(n){throw new Error('onError'+n)}},{key:'onMessage',value:function t(n){var e,a;return(a=n.data.split(' '),'ping'===a[0])?'function'==typeof(e=this.socket).send?e.send('pong '+a.slice(1).join(' ')):void 0:'pub'===a[0]?this.parent.onUpdate(a[1],this._decode(a[2])):void 0}},{key:'onOpen',value:function t(n){var e,a;for(a in this.connected=!0,e=[],this.pending)delete this.pending[a],e.push(this._subscribe(a));return e}},{key:'subscribe',value:function e(t){return this.connected?this._subscribe(t):(this.pending[t]=!0,this.pending[t])}}]),e}(),d=function(){function e(t){a(this,e),this.fetcher=t,this.graph={},this.via={},this.fetcher.addCallback('headers',this.onHeaders)}return o(e,[{key:'onHeaders',value:function e(t){var n,a,r;return null==t.headers||'undefined'==typeof WebSocket||null===WebSocket||(n=t.headers.etag,r=t.headers['updates-via'],a=t.uri,n&&r&&(this.graph[a]={etag:n,via:r},this.register(r,a)),!0)}},{key:'onUpdate',value:function e(t,n){return this.fetcher.refresh(i(t))}},{key:'register',value:function e(t,n){return null==this.via[t]&&(this.via[t]=new s(this,t)),this.via[t].subscribe(n)}}]),e}();e.exports.UpdatesSocket=s,e.exports.UpdatesVia=d},function(e,t,n){e.exports=n(60)},function(e,t,n){var a={BlankNode:n(6),Collection:n(17),convert:n(38),DataFactory:n(20),Empty:n(81),Fetcher:n(32),Formula:n(55),IndexedFormula:n(15),jsonParser:n(82),Literal:n(11),log:n(9),N3Parser:n(24),NamedNode:n(0),Namespace:n(16),Node:n(1),parse:n(56),Query:n(23).Query,queryToSPARQL:n(83),RDFaProcessor:n(35),RDFParser:n(36),serialize:n(33),Serializer:n(34),SPARQLToQuery:n(84),sparqlUpdateParser:n(57),Statement:n(21),term:n(1).fromValue,UpdateManager:n(85),UpdatesSocket:n(58).UpdatesSocket,UpdatesVia:n(58).UpdatesVia,uri:n(2),Util:n(4),Variable:n(22)};a.NextId=a.BlankNode.nextId,a.fromNT=a.Formula.prototype.fromNT,a.fetcher=a.DataFactory.fetcher,a.graph=a.DataFactory.graph,a.lit=a.DataFactory.lit,a.st=a.DataFactory.st,a.sym=a.DataFactory.namedNode,a.variable=a.DataFactory.variable,a.blankNode=a.DataFactory.blankNode,a.defaultGraph=a.DataFactory.defaultGraph,a.literal=a.DataFactory.literal,a.namedNode=a.DataFactory.namedNode,a.quad=a.DataFactory.quad,a.triple=a.DataFactory.triple,e.exports=a},function(e,t,n){(function(n,a){var r,i;/*! * async * https://github.com/caolan/async * * Copyright 2010-2014 Caolan McMahon * Released under the MIT license */(function(){function s(e){var t=!1;return function(){if(t)throw new Error('Callback was already called.');t=!0,e.apply(l,arguments)}}var d={},l,p;l=this,null!=l&&(p=l.async),d.noConflict=function(){return l.async=p,d};var u=Object.prototype.toString,c=Array.isArray||function(e){return'[object Array]'===u.call(e)},h=function(e,t){for(var n=0;n<e.length;n+=1)t(e[n],n,e)},f=function(e,t){if(e.map)return e.map(t);var n=[];return h(e,function(e,r,o){n.push(t(e,r,o))}),n},g=function(e,t,n){return e.reduce?e.reduce(t,n):(h(e,function(e,r,o){n=t(n,e,r,o)}),n)},m=function(e){if(Object.keys)return Object.keys(e);var t=[];for(var n in e)e.hasOwnProperty(n)&&t.push(n);return t};'undefined'!=typeof n&&n.nextTick?(d.nextTick=n.nextTick,d.setImmediate='undefined'==typeof a?d.nextTick:function(e){a(e)}):'function'==typeof a?(d.nextTick=function(e){a(e)},d.setImmediate=d.nextTick):(d.nextTick=function(e){setTimeout(e,0)},d.setImmediate=d.nextTick),d.each=function(e,t,n){function a(t){t?(n(t),n=function(){}):(r+=1,r>=e.length&&n())}if(n=n||function(){},!e.length)return n();var r=0;h(e,function(e){t(e,s(a))})},d.forEach=d.each,d.eachSeries=function(e,t,n){if(n=n||function(){},!e.length)return n();var a=0,r=function(){t(e[a],function(t){t?(n(t),n=function(){}):(a+=1,a>=e.length?n():r())})};r()},d.forEachSeries=d.eachSeries,d.eachLimit=function(e,t,n,a){var r=y(t);r.apply(null,[e,n,a])},d.forEachLimit=d.eachLimit;var y=function(e){return function(t,n,a){if(a=a||function(){},!t.length||0>=e)return a();var r=0,o=0,i=0;(function s(){if(r>=t.length)return a();for(;i<e&&o<t.length;)o+=1,i+=1,n(t[o-1],function(e){e?(a(e),a=function(){}):(r+=1,i-=1,r>=t.length?a():s())})})()}},b=function(e){return function(){var t=Array.prototype.slice.call(arguments);return e.apply(null,[d.each].concat(t))}},x=function(e,t){return function(){var n=Array.prototype.slice.call(arguments);return t.apply(null,[y(e)].concat(n))}},_=function(e){return function(){var t=Array.prototype.slice.call(arguments);return e.apply(null,[d.eachSeries].concat(t))}},v=function(e,t,n,a){if(t=f(t,function(e,t){return{index:t,value:e}}),!a)e(t,function(e,t){n(e.value,function(e){t(e)})});else{var r=[];e(t,function(e,t){n(e.value,function(n,a){r[e.index]=a,t(n)})},function(e){a(e,r)})}};d.map=b(v),d.mapSeries=_(v),d.mapLimit=function(e,t,n,a){return w(t)(e,n,a)};var w=function(e){return x(e,v)};d.reduce=function(e,t,n,a){d.eachSeries(e,function(e,a){n(t,e,function(e,n){t=n,a(e)})},function(e){a(e,t)})},d.inject=d.reduce,d.foldl=d.reduce,d.reduceRight=function(e,t,n,a){var r=f(e,function(e){return e}).reverse();d.reduce(r,t,n,a)},d.foldr=d.reduceRight;var k=function(e,t,n,a){var r=[];t=f(t,function(e,t){return{index:t,value:e}}),e(t,function(e,t){n(e.value,function(n){n&&r.push(e),t()})},function(e){a(f(r.sort(function(e,t){return e.index-t.index}),function(e){return e.value}))})};d.filter=b(k),d.filterSeries=_(k),d.select=d.filter,d.selectSeries=d.filterSeries;var T=function(e,t,n,a){var r=[];t=f(t,function(e,t){return{index:t,value:e}}),e(t,function(e,t){n(e.value,function(n){n||r.push(e),t()})},function(e){a(f(r.sort(function(e,t){return e.index-t.index}),function(e){return e.value}))})};d.reject=b(T),d.rejectSeries=_(T);var N=function(e,t,n,a){e(t,function(e,t){n(e,function(n){n?(a(e),a=function(){}):t()})},function(e){a()})};d.detect=b(N),d.detectSeries=_(N),d.some=function(e,t,n){d.each(e,function(e,a){t(e,function(e){e&&(n(!0),n=function(){}),a()})},function(e){n(!1)})},d.any=d.some,d.every=function(e,t,n){d.each(e,function(e,a){t(e,function(e){e||(n(!1),n=function(){}),a()})},function(e){n(!0)})},d.all=d.every,d.sortBy=function(e,t,n){d.map(e,function(e,n){t(e,function(t,a){t?n(t):n(null,{value:e,criteria:a})})},function(e,t){if(e)return n(e);var a=function(e,t){var n=e.criteria,a=t.criteria;return n<a?-1:n>a?1:0};n(null,f(t.sort(a),function(e){return e.value}))})},d.auto=function(e,t){t=t||function(){};var n=m(e),a=n.length;if(!a)return t();var r={},s=[],i=function(e){s.unshift(e)},l=function(e){for(var t=0;t<s.length;t+=1)if(s[t]===e)return void s.splice(t,1)},p=function(){a--,h(s.slice(0),function(e){e()})};i(function(){if(!a){var e=t;t=function(){},e(null,r)}}),h(n,function(n){var a=c(e[n])?e[n]:[e[n]],s=function(e){var a=Array.prototype.slice.call(arguments,1);if(1>=a.length&&(a=a[0]),e){var o={};h(m(r),function(e){o[e]=r[e]}),o[n]=a,t(e,o),t=function(){}}else r[n]=a,d.setImmediate(p)},u=a.slice(0,o(a.length-1))||[],f=function(){return g(u,function(e,t){return e&&r.hasOwnProperty(t)},!0)&&!r.hasOwnProperty(n)};if(f())a[a.length-1](s,r);else{var y=function(){f()&&(l(y),a[a.length-1](s,r))};i(y)}})},d.retry=function(e,t,n){var a=5,r=[];'function'==typeof e&&(n=t,t=e,e=a),e=parseInt(e,10)||a;var o=function(a,o){for(var i=function(e,t){return function(n){e(function(e,a){n(!e||t,{err:e,result:a})},o)}};e;)r.push(i(t,!(e-=1)));d.series(r,function(e,t){t=t[t.length-1],(a||n)(t.err,t.result)})};return n?o():o},d.waterfall=function(e,t){if(t=t||function(){},!c(e)){var n=new Error('First argument to waterfall must be an array of functions');return t(n)}if(!e.length)return t();var a=function(e){return function(n){if(n)t.apply(null,arguments),t=function(){};else{var r=Array.prototype.slice.call(arguments,1),o=e.next();o?r.push(a(o)):r.push(t),d.setImmediate(function(){e.apply(null,r)})}}};a(d.iterator(e))()};var I=function(e,t,n){if(n=n||function(){},c(t))e.map(t,function(e,t){e&&e(function(e){var n=Array.prototype.slice.call(arguments,1);1>=n.length&&(n=n[0]),t.call(null,e,n)})},n);else{var a={};e.each(m(t),function(e,n){t[e](function(t){var r=Array.prototype.slice.call(arguments,1);1>=r.length&&(r=r[0]),a[e]=r,n(t)})},function(e){n(e,a)})}};d.parallel=function(e,t){I({map:d.map,each:d.each},e,t)},d.parallelLimit=function(e,t,n){I({map:w(t),each:y(t)},e,n)},d.series=function(e,t){if(t=t||function(){},c(e))d.mapSeries(e,function(e,t){e&&e(function(e){var n=Array.prototype.slice.call(arguments,1);1>=n.length&&(n=n[0]),t.call(null,e,n)})},t);else{var n={};d.eachSeries(m(e),function(t,a){e[t](function(e){var r=Array.prototype.slice.call(arguments,1);1>=r.length&&(r=r[0]),n[t]=r,a(e)})},function(e){t(e,n)})}},d.iterator=function(e){var t=function(n){var a=function(){return e.length&&e[n].apply(null,arguments),a.next()};return a.next=function(){return n<e.length-1?t(n+1):null},a};return t(0)},d.apply=function(e){var t=Array.prototype.slice.call(arguments,1);return function(){return e.apply(null,t.concat(Array.prototype.slice.call(arguments)))}};var S=function(e,t,n,a){var o=[];e(t,function(e,t){n(e,function(e,n){o=o.concat(n||[]),t(e)})},function(e){a(e,o)})};d.concat=b(S),d.concatSeries=_(S),d.whilst=function(e,t,n){e()?t(function(a){return a?n(a):void d.whilst(e,t,n)}):n()},d.doWhilst=function(e,t,n){e(function(a){if(a)return n(a);var r=Array.prototype.slice.call(arguments,1);t.apply(null,r)?d.doWhilst(e,t,n):n()})},d.until=function(e,t,n){e()?n():t(function(a){return a?n(a):void d.until(e,t,n)})},d.doUntil=function(e,t,n){e(function(a){if(a)return n(a);var r=Array.prototype.slice.call(arguments,1);t.apply(null,r)?n():d.doUntil(e,t,n)})},d.queue=function(e,t){function n(e,t,n,a){return e.started||(e.started=!0),c(t)||(t=[t]),0==t.length?d.setImmediate(function(){e.drain&&e.drain()}):void h(t,function(t){var r={data:t,callback:'function'==typeof a?a:null};n?e.tasks.unshift(r):e.tasks.push(r),e.saturated&&e.tasks.length===e.concurrency&&e.saturated(),d.setImmediate(e.process)})}t===void 0&&(t=1);var a=0,r={tasks:[],concurrency:t,saturated:null,empty:null,drain:null,started:!1,paused:!1,push:function(e,t){n(r,e,!1,t)},kill:function(){r.drain=null,r.tasks=[]},unshift:function(e,t){n(r,e,!0,t)},process:function(){if(!r.paused&&a<r.concurrency&&r.tasks.length){var t=r.tasks.shift();r.empty&&0===r.tasks.length&&r.empty(),a+=1;var n=function(){a-=1,t.callback&&t.callback.apply(t,arguments),r.drain&&0===r.tasks.length+a&&r.drain(),r.process()},o=s(n);e(t.data,o)}},length:function(){return r.tasks.length},running:function(){return a},idle:function(){return 0===r.tasks.length+a},pause:function(){!0===r.paused||(r.paused=!0)},resume:function(){if(!1!==r.paused){r.paused=!1;for(var e=1;e<=r.concurrency;e++)d.setImmediate(r.process)}}};return r},d.priorityQueue=function(e,t){function n(e,t){return e.priority-t.priority}function a(e,t,n){for(var a=-1,r=e.length-1,o;a<r;)o=a+(r-a+1>>>1),0<=n(t,e[o])?a=o:r=o-1;return a}function r(e,t,r,o){return e.started||(e.started=!0),c(t)||(t=[t]),0==t.length?d.setImmediate(function(){e.drain&&e.drain()}):void h(t,function(t){var i={data:t,priority:r,callback:'function'==typeof o?o:null};e.tasks.splice(a(e.tasks,i,n)+1,0,i),e.saturated&&e.tasks.length===e.concurrency&&e.saturated(),d.setImmediate(e.process)})};var o=d.queue(e,t);return o.push=function(e,t,n){r(o,e,t,n)},delete o.unshift,o},d.cargo=function(e,t){var n=!1,a=[],r={tasks:a,payload:t,saturated:null,empty:null,drain:null,drained:!0,push:function(e,n){c(e)||(e=[e]),h(e,function(e){a.push({data:e,callback:'function'==typeof n?n:null}),r.drained=!1,r.saturated&&a.length===t&&r.saturated()}),d.setImmediate(r.process)},process:function o(){if(!n){if(0===a.length)return r.drain&&!r.drained&&r.drain(),void(r.drained=!0);var i='number'==typeof t?a.splice(0,t):a.splice(0,a.length),s=f(i,function(e){return e.data});r.empty&&r.empty(),n=!0,e(s,function(){n=!1;var e=arguments;h(i,function(t){t.callback&&t.callback.apply(null,e)}),o()})}},length:function(){return a.length},running:function(){return n}};return r};var j=function(e){return function(t){var n=Array.prototype.slice.call(arguments,1);t.apply(null,n.concat([function(t){var n=Array.prototype.slice.call(arguments,1);'undefined'!=typeof console&&(t?console.error&&console.error(t):console[e]&&h(n,function(t){console[e](t)}))}]))}};d.log=j('log'),d.dir=j('dir'),d.memoize=function(e,t){var n={},a={};t=t||function(e){return e};var r=function(){var r=Array.prototype.slice.call(arguments),o=r.pop(),s=t.apply(null,r);s in n?d.nextTick(function(){o.apply(null,n[s])}):s in a?a[s].push(o):(a[s]=[o],e.apply(null,r.concat([function(){n[s]=arguments;var e=a[s];delete a[s];for(var t=0,r=e.length;t<r;t++)e[t].apply(null,arguments)}])))};return r.memo=n,r.unmemoized=e,r},d.unmemoize=function(e){return function(){return(e.unmemoized||e).apply(null,arguments)}},d.times=function(e,t,n){for(var a=[],r=0;r<e;r++)a.push(r);return d.map(a,t,n)},d.timesSeries=function(e,t,n){for(var a=[],r=0;r<e;r++)a.push(r);return d.mapSeries(a,t,n)},d.seq=function(){var e=arguments;return function(){var t=this,n=Array.prototype.slice.call(arguments),a=n.pop();d.reduce(e,n,function(e,n,a){n.apply(t,e.concat([function(){var e=arguments[0],t=Array.prototype.slice.call(arguments,1);a(e,t)}]))},function(e,n){a.apply(t,[e].concat(n))})}},d.compose=function(){return d.seq.apply(null,Array.prototype.reverse.call(arguments))};var R=function(e,t){var n=function(){var n=this,a=Array.prototype.slice.call(arguments),r=a.pop();return e(t,function(e,t){e.apply(n,a.concat([t]))},r)};if(2<arguments.length){var a=Array.prototype.slice.call(arguments,2);return n.apply(this,a)}return n};d.applyEach=b(R),d.applyEachSeries=_(R),d.forever=function(e,t){function n(a){if(a){if(t)return t(a);throw a}e(n)}n()},'undefined'!=typeof e&&e.exports?e.exports=d:(r=[],i=function(){return d}.apply(t,r),!(i!==void 0&&(e.exports=i)))})()}).call(this,n(5),n(13).setImmediate)},function(e,t,n){(function(e,t){(function(e,n){'use strict';function a(e){'function'!=typeof e&&(e=new Function(''+e));for(var t=Array(arguments.length-1),n=0;n<t.length;n++)t[n]=arguments[n+1];var a={callback:e,args:t};return f[h]=a,b(h),h++}function r(e){delete f[e]}function o(e){var t=e.callback,n=e.args;switch(n.length){case 0:t();break;case 1:t(n[0]);break;case 2:t(n[0],n[1]);break;case 3:t(n[0],n[1],n[2]);break;default:t.apply(void 0,n);}}function i(e){if(g)setTimeout(i,0,e);else{var t=f[e];if(t){g=!0;try{o(t)}finally{r(e),g=!1}}}}function s(){b=function(e){t.nextTick(function(){i(e)})}}function d(){if(e.postMessage&&!e.importScripts){var t=!0,n=e.onmessage;return e.onmessage=function(){t=!1},e.postMessage('','*'),e.onmessage=n,t}}function l(){var t='setImmediate$'+Math.random()+'$',n=function(n){n.source===e&&'string'==typeof n.data&&0===n.data.indexOf(t)&&i(+n.data.slice(t.length))};e.addEventListener?e.addEventListener('message',n,!1):e.attachEvent('onmessage',n),b=function(n){e.postMessage(t+n,'*')}}function p(){var e=new MessageChannel;e.port1.onmessage=function(e){var t=e.data;i(t)},b=function(t){e.port2.postMessage(t)}}function u(){var e=m.documentElement;b=function(t){var n=m.createElement('script');n.onreadystatechange=function(){i(t),n.onreadystatechange=null,e.removeChild(n),n=null},e.appendChild(n)}}function c(){b=function(e){setTimeout(i,0,e)}}if(!e.setImmediate){var h=1,f={},g=!1,m=e.document,y=Object.getPrototypeOf&&Object.getPrototypeOf(e),b;y=y&&y.setTimeout?y:e,'[object process]'==={}.toString.call(e.process)?s():d()?l():e.MessageChannel?p():m&&'onreadystatechange'in m.createElement('script')?u():c(),y.setImmediate=a,y.clearImmediate=r}})('undefined'==typeof self?'undefined'==typeof e?this:e:self)}).call(this,n(3),n(5))},function(e,t){},function(e,t){(function(t){e.exports=t}).call(this,{})},function(e,t,n){function a(e){var t=r(e);return n(t)}function r(t){var n=o[t];if(!(n+1)){var a=new Error('Cannot find module \''+t+'\'');throw a.code='MODULE_NOT_FOUND',a}return n}var o={"./N3Lexer":25,"./N3Lexer.js":25,"./N3Parser":26,"./N3Parser.js":26,"./N3Store":43,"./N3Store.js":43,"./N3StreamParser":44,"./N3StreamParser.js":44,"./N3StreamWriter":54,"./N3StreamWriter.js":54,"./N3Util":27,"./N3Util.js":27,"./N3Writer":31,"./N3Writer.js":31};a.keys=function e(){return Object.keys(o)},a.resolve=r,e.exports=a,a.id=65},function(e,t,n){'use strict';function a(e){var t=e.length;if(0<t%4)throw new Error('Invalid string. Length must be a multiple of 4');var n=e.indexOf('=');-1===n&&(n=t);var a=n===t?0:4-n%4;return[n,a]}function r(e){var t=a(e),n=t[0],r=t[1];return 3*(n+r)/4-r}function o(e,t,n){return 3*(t+n)/4-n}function s(e){for(var t=a(e),n=t[0],r=t[1],s=new h(o(e,n,r)),d=0,l=0<r?n-4:n,p=0,i;p<l;p+=4)i=c[e.charCodeAt(p)]<<18|c[e.charCodeAt(p+1)]<<12|c[e.charCodeAt(p+2)]<<6|c[e.charCodeAt(p+3)],s[d++]=255&i>>16,s[d++]=255&i>>8,s[d++]=255&i;return 2===r&&(i=c[e.charCodeAt(p)]<<2|c[e.charCodeAt(p+1)]>>4,s[d++]=255&i),1===r&&(i=c[e.charCodeAt(p)]<<10|c[e.charCodeAt(p+1)]<<4|c[e.charCodeAt(p+2)]>>2,s[d++]=255&i>>8,s[d++]=255&i),s}function d(e){return u[63&e>>18]+u[63&e>>12]+u[63&e>>6]+u[63&e]}function l(e,t,n){for(var a=[],r=t,o;r<n;r+=3)o=(16711680&e[r]<<16)+(65280&e[r+1]<<8)+(255&e[r+2]),a.push(d(o));return a.join('')}function p(e){for(var t=e.length,n=t%3,a=[],r=16383,o=0,i=t-n,s;o<i;o+=r)a.push(l(e,o,o+r>i?i:o+r));return 1==n?(s=e[t-1],a.push(u[s>>2]+u[63&s<<4]+'==')):2==n&&(s=(e[t-2]<<8)+e[t-1],a.push(u[s>>10]+u[63&s>>4]+u[63&s<<2]+'=')),a.join('')}t.byteLength=r,t.toByteArray=s,t.fromByteArray=p;for(var u=[],c=[],h='undefined'==typeof Uint8Array?Array:Uint8Array,f='ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/',g=0,i=f.length;g<i;++g)u[g]=f[g],c[f.charCodeAt(g)]=g;c[45]=62,c[95]=63},function(e,t){t.read=function(t,a,r,o,l){var p=8*l-o-1,u=(1<<p)-1,c=u>>1,h=-7,f=r?l-1:0,i=r?-1:1,d=t[a+f],s,e;for(f+=i,s=d&(1<<-h)-1,d>>=-h,h+=p;0<h;s=256*s+t[a+f],f+=i,h-=8);for(e=s&(1<<-h)-1,s>>=-h,h+=o;0<h;e=256*e+t[a+f],f+=i,h-=8);if(0===s)s=1-c;else{if(s===u)return e?NaN:(d?-1:1)*Infinity;e+=n(2,o),s-=c}return(d?-1:1)*e*n(2,s-o)},t.write=function(t,r,l,p,u,h){var f=8*h-u-1,g=(1<<f)-1,y=g>>1,b=23===u?5.960464477539063e-8-6.617444900424222e-24:0,x=p?0:h-1,i=p?1:-1,d=0>r||0===r&&0>1/r?1:0,s,_,m;for(r=o(r),isNaN(r)||r===Infinity?(_=isNaN(r)?1:0,s=g):(s=a(Math.log(r)/Math.LN2),1>r*(m=n(2,-s))&&(s--,m*=2),r+=1<=s+y?b/m:b*n(2,1-y),2<=r*m&&(s++,m/=2),s+y>=g?(_=0,s=g):1<=s+y?(_=(r*m-1)*n(2,u),s+=y):(_=r*n(2,y-1)*n(2,u),s=0));8<=u;t[l+x]=255&_,x+=i,_/=256,u-=8);for(s=s<<u|_,f+=u;0<f;t[l+x]=255&s,x+=i,s/=256,f-=8);t[l+x-i]|=128*d}},function(e,t){},function(e,t,n){'use strict';function a(e,t){if(!(e instanceof t))throw new TypeError('Cannot call a class as a function')}function r(e,t,n){e.copy(t,n)}var o=n(19).Buffer,i=n(70);e.exports=function(){function e(){a(this,e),this.head=null,this.tail=null,this.length=0}return e.prototype.push=function e(t){var n={data:t,next:null};0<this.length?this.tail.next=n:this.head=n,this.tail=n,++this.length},e.prototype.unshift=function e(t){var n={data:t,next:this.head};0===this.length&&(this.tail=n),this.head=n,++this.length},e.prototype.shift=function e(){if(0!==this.length){var t=this.head.data;return this.head=1===this.length?this.tail=null:this.head.next,--this.length,t}},e.prototype.clear=function e(){this.head=this.tail=null,this.length=0},e.prototype.join=function e(t){if(0===this.length)return'';for(var n=this.head,a=''+n.data;n=n.next;)a+=t+n.data;return a},e.prototype.concat=function e(t){if(0===this.length)return o.alloc(0);if(1===this.length)return this.head.data;for(var n=o.allocUnsafe(t>>>0),a=this.head,s=0;a;)r(a.data,n,s),s+=a.data.length,a=a.next;return n},e}(),i&&i.inspect&&i.inspect.custom&&(e.exports.prototype[i.inspect.custom]=function(){var e=i.inspect({length:this.length});return this.constructor.name+' '+e})},function(e,t){},function(e,t,n){(function(t){function n(e,t){function n(){if(!r){if(a('throwDeprecation'))throw new Error(t);else a('traceDeprecation')?console.trace(t):console.warn(t);r=!0}return e.apply(this,arguments)}if(a('noDeprecation'))return e;var r=!1;return n}function a(e){try{if(!t.localStorage)return!1}catch(e){return!1}var n=t.localStorage[e];return null!=n&&'true'===(n+'').toLowerCase()}e.exports=n}).call(this,n(3))},function(e,t,n){'use strict';function a(e){return this instanceof a?void r.call(this,e):new a(e)}e.exports=a;var r=n(52),o=n(14);o.inherits=n(7),o.inherits(a,r),a.prototype._transform=function(e,t,n){n(null,e)}},function(e,t,n){e.exports=n(30)},function(e,t,n){e.exports=n(8)},function(e,t,n){e.exports=n(29).Transform},function(e,t,n){e.exports=n(29).PassThrough},function(e,t){e.exports=function e(t){return t&&'object'==typeof t&&'function'==typeof t.copy&&'function'==typeof t.fill&&'function'==typeof t.readUInt8}},function(e,t,n){'use strict';function a(e){return a='function'==typeof Symbol&&'symbol'==typeof Symbol.iterator?function e(t){return typeof t}:function e(t){return t&&'function'==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?'symbol':typeof t},a(e)}function r(e,t){if(!(e instanceof t))throw new TypeError('Cannot call a class as a function')}function o(e,t){for(var n=0,a;n<t.length;n++)a=t[n],a.enumerable=a.enumerable||!1,a.configurable=!0,'value'in a&&(a.writable=!0),Object.defineProperty(e,a.key,a)}function i(e,t,n){return t&&o(e.prototype,t),n&&o(e,n),e}function s(e,t){return t&&('object'===a(t)||'function'==typeof t)?t:d(e)}function d(e){if(void 0===e)throw new ReferenceError('this hasn\'t been initialised - super() hasn\'t been called');return e}function l(e){return l=Object.setPrototypeOf?Object.getPrototypeOf:function e(t){return t.__proto__||Object.getPrototypeOf(t)},l(e)}function p(e,t){if('function'!=typeof t&&null!==t)throw new TypeError('Super expression must either be null or a function');e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&u(e,t)}function u(e,t){return u=Object.setPrototypeOf||function e(t,n){return t.__proto__=n,t},u(e,t)}var c=n(1),h=function(e){function t(){var e;return r(this,t),e=s(this,l(t).call(this)),e.termType='DefaultGraph',e.value='',e}return p(t,e),i(t,[{key:'toCanonical',value:function e(){return this.value}}]),t}(c);e.exports=h},function(e,t){e.exports=function(e){return e.webpackPolyfill||(e.deprecate=function(){},e.paths=[],!e.children&&(e.children=[]),Object.defineProperty(e,'loaded',{enumerable:!0,get:function(){return e.l}}),Object.defineProperty(e,'id',{enumerable:!0,get:function(){return e.i}}),e.webpackPolyfill=1),e}},function(e,n){e.exports=t},function(e,t,n){'use strict';function a(e){return a='function'==typeof Symbol&&'symbol'==typeof Symbol.iterator?function e(t){return typeof t}:function e(t){return t&&'function'==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?'symbol':typeof t},a(e)}function r(e,t){if(!(e instanceof t))throw new TypeError('Cannot call a class as a function')}function o(e,t){for(var n=0,a;n<t.length;n++)a=t[n],a.enumerable=a.enumerable||!1,a.configurable=!0,'value'in a&&(a.writable=!0),Object.defineProperty(e,a.key,a)}function i(e,t,n){return t&&o(e.prototype,t),n&&o(e,n),e}function s(e,t){return t&&('object'===a(t)||'function'==typeof t)?t:d(e)}function d(e){if(void 0===e)throw new ReferenceError('this hasn\'t been initialised - super() hasn\'t been called');return e}function l(e){return l=Object.setPrototypeOf?Object.getPrototypeOf:function e(t){return t.__proto__||Object.getPrototypeOf(t)},l(e)}function p(e,t){if('function'!=typeof t&&null!==t)throw new TypeError('Super expression must either be null or a function');e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&u(e,t)}function u(e,t){return u=Object.setPrototypeOf||function e(t,n){return t.__proto__=n,t},u(e,t)}var c=n(1),h=function(e){function t(){var e;return r(this,t),e=s(this,l(t).call(this)),e.termType=t.termType,e}return p(t,e),i(t,[{key:'toString',value:function e(){return'()'}}]),t}(c);h.termType='empty',e.exports=h},function(e,t){var n=function(){return{parseJSON:function e(t,n,a){var r={},o=a.sym(n),i,s,d;for(var l in t){0===l.indexOf('_:')?r[l]?i=r[l]:(i=a.bnode(l),r[l]=i):i=a.sym(l);var p=t[l];for(var u in p){var c=p[u];for(var h in s=a.sym(u),c){var f=c[h];if('uri'===f.type)d=a.sym(f.value),a.add(i,s,d,o);else if('BlankNode'===f.type)r[f.value]?d=r[f.value]:(d=a.bnode(f.value),r[f.value]=d),a.add(i,s,d,o);else if('Literal'===f.type)d=f.datatype?a.literal(f.value,void 0,a.sym(f.datatype)):f.lang?a.literal(f.value,f.lang):a.literal(f.value),a.add(i,s,d,o);else throw new Error('error: unexpected termtype: '+h.type)}}}}}}();e.exports=n},function(e,t,n){function a(e){function t(e){for(var t=s()+'SELECT ',n=0;n<e.vars.length;n++)t+=e.vars[n]+' ';return t+='\n',t}function n(e){var t='',n=e.statements;for(var a in n)r.debug('Found statement: '+n),t+=s()+n[a]+'\n';return t}function a(e){var t='';for(var n in e.constraints){var a=e.constraints[n];t+=s()+'FILTER ( '+a.describe(n)+' ) \n'}return t}function o(e){for(var t='',i=0;i<e.optional.length;i++)r.debug('Found optional query'),t+=s()+'OPTIONAL { \n',l++,t+=n(e.optional[i]),t+=a(e.optional[i]),t+=o(e.optional[i]),l--,t+=s()+'}\n';return t}function i(e){var t=s()+'WHERE \n{ \n';return l++,t+=n(e),t+=a(e),t+=o(e),l--,t+='}',t}function s(){for(var e='',t=0;t<l;t++)e+=' ';return e}function d(e){return t(e)+i(e.pat)}var l=0;return d(e)}var r=n(9);e.exports=a},function(e,t,n){function a(e,t,n){function a(e){if(U[e])return U[e];var t=n.variable(e);return U[e]=t,t}function i(e){return'string'==typeof e&&e.match(/[^ \n\t]/)}function s(e){return'string'==typeof e&&e.match(/^[\?\$]/)}function d(e){return'string'==typeof e?e.replace(/^</,'<').replace(/>$/,'>'):e}function l(e){return'string'==typeof e&&e.match(/^<[^>]*>$/)}function p(e){return'string'==typeof e&&(e.match(/^_:/)||e.match(/^$/))}function u(e){return'string'==typeof e&&e.match(/:$/)}function c(e){return'string'==typeof e&&e.match(/^:|^[^_][^:]*:/)}function h(e){var t=e.split(':');return t[0]}function f(e){var t=e.split(':');return t[1]}function g(e){return l(e)?e.slice(1,e.length-1):e}function m(e){var t=-1===e.indexOf('\'')?null:e.indexOf('\''),o=-1===e.indexOf('"')?null:e.indexOf('"');if(!t&&!o){var i=[,];return i[0]=e,i}var a=[,,],s,d;if(!t||o&&o<t)s='"',d=o;else if(!o||t&&t<o)s='\'',d=t;else return r.error('SQARQL QUERY OOPS!'),a;a[0]=e.slice(0,d);var l=e.slice(d+1).indexOf(s);if(-1===l)return r.error('SPARQL parsing error: no matching parentheses in literal '+e),e;var p;return e.slice(l+d+2).match(/^\^\^/)?(p=e.slice(l+d+2).indexOf(' '),a[1]=n.literal(e.slice(d+1,d+1+l),'',n.sym(g(e.slice(d+4+l,d+2+l+p)))),a=a.concat(m(e.slice(l+d+3+p)))):e.slice(l+d+2).match(/^@/)?(p=e.slice(l+d+2).indexOf(' '),a[1]=n.literal(e.slice(d+1,d+1+l),e.slice(d+3+l,d+2+l+p),null),a=a.concat(m(e.slice(l+d+2+p)))):(a[1]=n.literal(e.slice(d+1,d+1+l),'',null),r.info('Literal found: '+a[1]),a=a.concat(m(e.slice(l+d+2)))),a}function y(e){e=e.replace(/\(/g,' ( ').replace(/\)/g,' ) ').replace(/</g,' <').replace(/>/g,'> ').replace(/{/g,' { ').replace(/}/g,' } ').replace(/[\t\n\r]/g,' ').replace(/; /g,' ; ').replace(/\. /g,' . ').replace(/, /g,' , '),r.info('New str into spaceDelimit: \n'+e);var t=[],n=e.split(' ');for(var a in n)i(n[a])&&(t=t.concat(n[a]));return t}function b(e){for(var t=e,n=0;n<t.length;n++)if('a'===t[n]&&(t[n]='<http://www.w3.org/1999/02/22-rdf-syntax-ns#type>'),'is'===t[n]&&'of'===t[n+2]){t.splice(n,1),t.splice(n+1,1);var a=t[n-1];t[n-1]=t[n+1],t[n+1]=a}return t}function _(e){for(var t=[],o=0;o<e.length;o++){if('string'!=typeof e[o]){t[o]=e[o];continue}e[o]=d(e[o]),s(e[o])?t[o]=a(e[o].slice(1)):p(e[o])?(r.info(e[o]+' was identified as a bnode.'),t[o]=n.bnode()):l(e[o])?(r.info(e[o]+' was identified as a symbol.'),t[o]=n.sym(g(e[o]))):c(e[o])?(r.info(e[o]+' was identified as a prefixed symbol'),M[h(e[o])]?t[o]=n.sym(e[o]=M[h(e[o])]+f(e[o])):(r.error('SPARQL error: '+e[o]+' with prefix '+h(e[o])+' does not have a correct prefix entry.'),t[o]=e[o])):t[o]=e[o]}return t}function v(e){var t=m(e),n=[];for(var a in t)n='string'==typeof t[a]?n.concat(y(t[a])):n.concat(t[a]);return n=b(n),r.info('SPARQL Tokens: '+n),n}function w(e,t){for(var n=0;n<t.length;n++)if('string'==typeof t[n]&&t[n].toLowerCase()===e.toLowerCase())return n;return null}function k(e,t){for(var n=[],a=0;a<t.length;a++)'string'==typeof t[a]&&t[a].toLowerCase()===e.toLowerCase()&&n.push(a);return n}function T(e,t){for(var n in r.info('SPARQL vars: '+e),e)if(s(e[n])){r.info('Added '+e[n]+' to query variables from SPARQL');var o=a(e[n].slice(1));t.vars.push(o),o.label=e[n].slice(1)}else r.warn('Incorrect SPARQL variable in SELECT: '+e[n])}function N(e){var t=k('PREFIX',e),n=[];for(var o in t){var i=e[t[o]+1],a=e[t[o]+2];if(!u(i))r.error('Invalid SPARQL prefix: '+i);else if(!l(a))r.error('Invalid SPARQL symbol: '+a);else{r.info('Prefix found: '+i+' -> '+a);var s=h(i),d=g(a);n[s]=d}}return n}function I(e,t,n){r.info('Looking for a close bracket of type '+n+' in '+e);for(var a=0,o=0;o<e.length;o++)if(e[o]===t&&a++,e[o]===n&&a--,0>a)return o;return r.error('Statement had no close parenthesis in SPARQL query'),0}function S(e){return this.describe=function(t){return t+' > '+e.toNT()},this.test=function(t){return t.value.match(/[0-9]+(\.[0-9]+)?([eE][+-]?[0-9]+)?/)?parseFloat(t.value)>parseFloat(e):t.toNT()>e.toNT()},this}function j(e){return this.describe=function(t){return t+' < '+e.toNT()},this.test=function(t){return t.value.match(/[0-9]+(\.[0-9]+)?([eE][+-]?[0-9]+)?/)?parseFloat(t.value)<parseFloat(e):t.toNT()<e.toNT()},this}function R(e){return this.describe=function(t){return t+' = '+e.toNT()},this.test=function(t){return e.sameTerm(t)},this}function C(e){this.describe=function(t){return'REGEXP( \''+e+'\' , '+t+' )'},this.test=function(t){var n=e,a=new RegExp(n);return!!t.value&&a.test(t.value)}}function L(e,t){3===e.length&&'Variable'===e[0].termType&&('NamedNode'===e[2].termType||'Literal'===e[2].termType)?'='===e[1]?(r.debug('Constraint added: '+e),t.constraints[e[0]]=new R(e[2])):'>'===e[1]?(r.debug('Constraint added: '+e),t.constraints[e[0]]=new R(e[2])):'<'===e[1]?(r.debug('Constraint added: '+e),t.constraints[e[0]]=new R(e[2])):r.warn('I don\'t know how to handle the constraint: '+e):6===e.length&&'string'==typeof e[0]&&'regexp'===e[0].toLowerCase()&&'('===e[1]&&')'===e[5]&&','===e[3]&&'Variable'===e[4].termType&&'Literal'===e[2].termType&&(r.debug('Constraint added: '+e),t.constraints[e[4]]=new C(e[2].value))}function O(e,t){r.debug('Optional query: '+e+' not yet implemented.');var a=n.formula();E(e,a),t.optional.push(a)}function E(e,t){var n=_(e),a;r.debug('WHERE: '+n);for(var o;w('OPTIONAL',n);)o=w('OPTIONAL',n),r.debug('OPT: '+o+' '+n[o]+' in '+n),'{'!==n[o+1]&&r.warn('Bad optional opening bracket in word '+o),a=I(n.slice(o+2),'{','}'),-1===a?r.error('No matching bracket in word '+o):(O(n.slice(o+2,o+2+a),t),o=w('OPTIONAL',n),a=I(n.slice(o+2),'{','}'),n.splice(o,a+3));for(r.debug('WHERE after optionals: '+n);w('FILTER',n);){var i=w('FILTER',n);'('!==n[i+1]&&r.warn('Bad filter opening bracket in word '+i),a=I(n.slice(i+2),'(',')'),-1===a?r.error('No matching bracket in word '+i):(L(n.slice(i+2,i+2+a),t),i=w('FILTER',n),a=I(n.slice(i+2),'(',')'),n.splice(i,a+3))}r.debug('WHERE after filters and optionals: '+n),D(n,t)}function D(e,t){var n=[,];n[0]=-1;for(var a=n.concat(k('.',e)),o=[],i=0;i<a.length-1;i++)o[i]=e.slice(a[i]+1,a[i+1]);for(i in o){r.info('s+p+o '+i+' = '+o[i]);var s=o[i][0];o[i].splice(0,1);var d=n.concat(k(';',o[i]));d.push(o[i].length);for(var l=[],p=0;p<d.length-1;p++)l[p]=o[i].slice(d[p]+1,d[p+1]);for(i in l){r.info('p+o '+i+' = '+o[i]);var u=l[i][0];l[i].splice(0,1);var c=n.concat(k(',',l[i]));c.push(l[i].length);var h=[];for(p=0;p<c.length-1;p++)h[p]=l[i].slice(c[p]+1,c[p+1]);for(i in h){var f=h[i][0];r.info('Subj='+s+' Pred='+u+' Obj='+f),t.add(s,u,f)}}}}var U=[];r.info('SPARQL input: \n'+e);var A=new o,P=v(e),M=N(P);M.rdf||(M.rdf='http://www.w3.org/1999/02/22-rdf-syntax-ns#'),M.rdfs||(M.rdfs='http://www.w3.org/2000/01/rdf-schema#');var F=w('SELECT',P),B=w('WHERE',P);if(0>F||0>B||F>B)return r.error('Invalid or nonexistent SELECT and WHERE tags in SPARQL query'),!1;if(T(P.slice(F+1,B),A),E(P.slice(B+2,P.length-1),A.pat),t)return A;for(var q in A.pat.statements){var x=A.pat.statements[q];'NamedNode'===x.subject.termType&&n.fetcher&&n.fetcher.lookUpThing(x.subject,'sparql:'+x.subject),'NamedNode'===x.object.termType&&n.fetcher&&n.fetcher.lookUpThing(x.object,'sparql:'+x.object)}return A}var r=n(9),o=n(23).Query;e.exports=a},function(e,t,n){function a(e){return a='function'==typeof Symbol&&'symbol'==typeof Symbol.iterator?function e(t){return typeof t}:function e(t){return t&&'function'==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?'symbol':typeof t},a(e)}function r(e,t){if(!(e instanceof t))throw new TypeError('Cannot call a class as a function')}function o(e,t){for(var n=0,a;n<t.length;n++)a=t[n],a.enumerable=a.enumerable||!1,a.configurable=!0,'value'in a&&(a.writable=!0),Object.defineProperty(e,a.key,a)}function i(e,t,n){return t&&o(e.prototype,t),n&&o(e,n),e}var s=n(15),d=n(2).docpart,l=n(32),p=n(20).namedNode,u=n(16),c=n(34),h=n(2).join,f=n(4),g=function(){function e(t){if(r(this,e),t=t||new s,this.store=t,t.updater)throw new Error('You can\'t have two UpdateManagers for the same store');t.fetcher||(t.fetcher=new l(t)),t.updater=this,this.ifps={},this.fps={},this.ns={},this.ns.link=u('http://www.w3.org/2007/ont/link#'),this.ns.http=u('http://www.w3.org/2007/ont/http#'),this.ns.httph=u('http://www.w3.org/2007/ont/httph#'),this.ns.ldp=u('http://www.w3.org/ns/ldp#'),this.ns.rdf=u('http://www.w3.org/1999/02/22-rdf-syntax-ns#'),this.ns.rdfs=u('http://www.w3.org/2000/01/rdf-schema#'),this.ns.rdf=u('http://www.w3.org/1999/02/22-rdf-syntax-ns#'),this.ns.owl=u('http://www.w3.org/2002/07/owl#'),this.patchControl=[]}return i(e,[{key:'patchControlFor',value:function e(t){return this.patchControl[t.uri]||(this.patchControl[t.uri]=[]),this.patchControl[t.uri]}},{key:'editable',value:function e(t,n){if(!t)return!1;if(n||(n=this.store),'file:///'===t.slice(0,8)){if(n.holds(n.sym(t),p('http://www.w3.org/1999/02/22-rdf-syntax-ns#type'),p('http://www.w3.org/2007/ont/link#MachineEditableDocument')))return'LOCALFILE';var a=n.statementsMatching(n.sym(t));return console.log('UpdateManager.editable: Not MachineEditableDocument file '+t+'\n'),console.log(a.map(function(e){return e.toNT()}).join('\n')),!1}var o=!1,s=n.each(void 0,this.ns.link('requestedURI'),d(t)),l;if(n.holds(p(t),this.ns.rdf('type'),this.ns.ldp('Resource')))return'SPARQL';for(var u=0,r;u<s.length;u++)if(l=s[u],void 0!==l){var c=n.any(l,this.ns.link('response'));if(void 0!==l){var h=n.each(c,this.ns.httph('accept-patch'));if(h.length)for(var f=0;f<h.length;f++)if(r=h[f].value.trim(),0<=r.indexOf('application/sparql-update'))return'SPARQL';var i=n.each(c,this.ns.httph('ms-author-via'));if(i.length)for(var g=0;g<i.length;g++){if(r=i[g].value.trim(),0<=r.indexOf('SPARQL'))return'SPARQL';if(0<=r.indexOf('DAV'))return'DAV'}var m=n.each(c,this.ns.http('status'));if(m.length)for(var y=0;y<m.length;y++)(200===m[y]||404===m[y])&&(o=!0)}else console.log('UpdateManager.editable: No response for '+t+'\n')}if(0===s.length)console.log('UpdateManager.editable: No request for '+t+'\n');else if(o)return!1;console.log('UpdateManager.editable: inconclusive for '+t+'\n')}},{key:'anonymize',value:function e(t){return'_:'===t.toNT().substr(0,2)&&this.mentioned(t)?'?'+t.toNT().substr(2):t.toNT()}},{key:'anonymizeNT',value:function e(t){return this.anonymize(t.subject)+' '+this.anonymize(t.predicate)+' '+this.anonymize(t.object)+' .'}},{key:'statementBnodes',value:function e(t){return[t.subject,t.predicate,t.object].filter(function(e){return e.isBlank})}},{key:'statementArrayBnodes',value:function e(t){for(var n=[],a=0;a<t.length;a++)n=n.concat(this.statementBnodes(t[a]));n.sort();for(var r=[],o=0;o<n.length;o++)0!==o&&n[o].sameTerm(n[o-1])||r.push(n[o]);return r}},{key:'cacheIfps',value:function e(){this.ifps={};for(var t=this.store.each(void 0,this.ns.rdf('type'),this.ns.owl('InverseFunctionalProperty')),n=0;n<t.length;n++)this.ifps[t[n].uri]=!0;this.fps={},t=this.store.each(void 0,this.ns.rdf('type'),this.ns.owl('FunctionalProperty'));for(var a=0;a<t.length;a++)this.fps[t[a].uri]=!0}},{key:'bnodeContext2',value:function e(t,n,a){for(var r=this.store.statementsMatching(void 0,void 0,t,n),o=0,i,s;o<r.length;o++)if(this.fps[r[o].predicate.uri]){if(i=r[o].subject,!i.isBlank)return[r[o]];if(a&&(s=this.bnodeContext2(i,n,a-1),s))return s.concat([r[o]])}r=this.store.statementsMatching(t,void 0,void 0,n);for(var d=0;d<r.length;d++)if(this.ifps[r[d].predicate.uri]){if(i=r[d].object,!i.isBlank)return[r[d]];if(a&&(s=this.bnodeContext2(i,n,a-1),s))return s.concat([r[d]])}return null}},{key:'bnodeContext1',value:function e(t,n){for(var a=0,r;3>a;a++)if(r=this.bnodeContext2(t,n,a),null!==r)return r;return this.store.connectedStatements(t,n)}},{key:'mentioned',value:function e(t){return 0!==this.store.statementsMatching(t).length||0!==this.store.statementsMatching(void 0,t).length||0!==this.store.statementsMatching(void 0,void 0,t).length}},{key:'bnodeContext',value:function e(t,n){var a=[];if(t.length){this.cacheIfps();for(var r=0,o;r<t.length;r++)o=t[r],this.mentioned(o)&&(a=a.concat(this.bnodeContext1(o,n)))}return a}},{key:'statementContext',value:function e(t){var n=this.statementBnodes(t);return this.bnodeContext(n,t.why)}},{key:'contextWhere',value:function e(t){var n=this;return t&&0!==t.length?'WHERE { '+t.map(function(e){return n.anonymizeNT(e)}).join('\n')+' }\n':''}},{key:'fire',value:function e(t,n,a){var r=this;return Promise.resolve().then(function(){if(!t)throw new Error('No URI given for remote editing operation: '+n);console.log('UpdateManager: sending update to <'+t+'>');var e={noMeta:!0,contentType:'application/sparql-update',body:n};return r.store.fetcher.webOperation('PATCH',t,e)}).then(function(e){if(!e.ok){var r='UpdateManager: update failed for <'+t+'> status='+e.status+', '+e.statusText+'\n for query: '+n;throw console.log(r),new Error(r)}console.log('UpdateManager: update Ok for <'+t+'>'),a(t,e.ok,e.responseText,e)}).catch(function(e){a(t,!1,e.message,e)})}},{key:'update_statement',value:function e(t){if(!t||t.why){var n=this,a=this.statementContext(t);return{statement:t?[t.subject,t.predicate,t.object,t.why]:void 0,statementNT:t?this.anonymizeNT(t):void 0,where:n.contextWhere(a),set_object:function e(t,a){var r=this.where;r+='DELETE DATA { '+this.statementNT+' } ;\n',r+='INSERT DATA { '+this.anonymize(this.statement[0])+' '+this.anonymize(this.statement[1])+' '+this.anonymize(t)+' . }\n',n.fire(this.statement[3].uri,r,a)}}}}},{key:'insert_statement',value:function e(t,n){var a=t instanceof Array?t[0]:t,r=this.contextWhere(this.statementContext(a));if(t instanceof Array){for(var o='',s=0;s<t.length;s++)o+=t[s]+'\n';r+='INSERT DATA { '+o+' }\n'}else r+='INSERT DATA { '+this.anonymize(t.subject)+' '+this.anonymize(t.predicate)+' '+this.anonymize(t.object)+' . }\n';this.fire(a.why.uri,r,n)}},{key:'delete_statement',value:function e(t,n){var a=t instanceof Array?t[0]:t,r=this.contextWhere(this.statementContext(a));if(t instanceof Array){for(var o='',s=0;s<t.length;s++)o+=t[s]+'\n';r+='DELETE DATA { '+o+' }\n'}else r+='DELETE DATA { '+this.anonymize(t.subject)+' '+this.anonymize(t.predicate)+' '+this.anonymize(t.object)+' . }\n';this.fire(a.why.uri,r,n)}},{key:'requestDownstreamAction',value:function e(t,n){var a=this.patchControlFor(t);if(!a.pendingUpstream)n(t);else if(!a.downstreamAction)a.downstreamAction=n;else if(''+a.downstreamAction!=''+n)throw new Error('Can\'t wait for > 1 different downstream actions')}},{key:'clearUpstreamCount',value:function e(t){var n=this.patchControlFor(t);n.upstreamCount=0}},{key:'getUpdatesVia',value:function e(t){var n=this.store.fetcher.getHeader(t,'updates-via');return n&&n.length?n[0].trim():null}},{key:'addDownstreamChangeListener',value:function e(t,n){var a=this,r=this.patchControlFor(t);r.downstreamChangeListeners||(r.downstreamChangeListeners=[]),r.downstreamChangeListeners.push(n),this.setRefreshHandler(t,function(e){a.reloadAndSync(e)})}},{key:'reloadAndSync',value:function e(t){var n=this.patchControlFor(t),a=this;if(n.reloading)return void console.log(' Already reloading - stop');n.reloading=!0;var r=1e3,o=function e(){console.log('try reload - timeout = '+r),a.reload(a.store,t,function(a,o,s){if(n.reloading=!1,!a)0===s.status?(console.log('Network error refreshing the data. Retrying in '+r/1e3),n.reloading=!0,r*=2,setTimeout(e,r)):console.log('Error '+s.status+'refreshing the data:'+o+'. Stopped'+t);else if(n.downstreamChangeListeners)for(var d=0;d<n.downstreamChangeListeners.length;d++)console.log(' Calling downstream listener '+d),n.downstreamChangeListeners[d]()})};o()}},{key:'setRefreshHandler',value:function e(t,n){var a=this.getUpdatesVia(t),r=n,o=this,i=this,s=1500,d=0;if(!a)return console.log('Server doies not support live updates thoughUpdates-Via :-('),!1;a=h(a,t.uri),a=a.replace(/^http:/,'ws:').replace(/^https:/,'wss:'),console.log('Web socket URI '+a);var l=function e(){var n;if('undefined'!=typeof WebSocket)n=new WebSocket(a);else if('undefined'!=typeof Services)n=Services.wm.getMostRecentWindow('navigator:browser').WebSocket(a);else if('undefined'!=typeof window&&window.WebSocket)n=window.WebSocket(a);else return void console.log('Live update disabled, as WebSocket not supported by platform :-(');n.onopen=function(){console.log(' websocket open'),s=1500,this.send('sub '+t.uri),d&&(console.log('Web socket has been down, better check for any news.'),i.requestDownstreamAction(t,r))};var l=o.patchControlFor(t);l.upstreamCount=0,n.onerror=function e(t){console.log('Error on Websocket:',t)},n.onclose=function(t){console.log('*** Websocket closed with code '+t.code+', reason \''+t.reason+'\' clean = '+t.clean),s*=2,d+=1,console.log('Retrying in '+s+'ms'),setTimeout(function(){console.log('Trying websocket again'),e()},s)},n.onmessage=function(e){if(e.data&&'pub'===e.data.slice(0,3)){if('upstreamCount'in l&&(l.upstreamCount-=1,0<=l.upstreamCount))return void console.log('just an echo: '+l.upstreamCount);console.log('Assume a real downstream change: '+l.upstreamCount+' -> 0'),l.upstreamCount=0,o.requestDownstreamAction(t,r)}}};return l(),!0}},{key:'update',value:function e(t,n,r,o){var d=this;try{var l=this.store,p=t?t instanceof s?t.statements:t instanceof Array?t:[t]:[],u=n?n instanceof s?n.statements:n instanceof Array?n:[n]:[];if(!(p instanceof Array))throw new Error('Type Error '+a(p)+': '+p);if(!(u instanceof Array))throw new Error('Type Error '+a(u)+': '+u);if(0===p.length&&0===u.length)return r(null,!0);var c=p.length?p[0].why:u[0].why;if(!c){var h='Error patching: statement does not specify which document to patch:'+p[0]+', '+u[0];throw console.log(h),new Error(h)}var g=this.patchControlFor(c),m=Date.now(),y=['subject','predicate','object','why'],b=['insert','delete'],x={delete:p,insert:u};b.map(function(e){x[e].map(function(e){if(!c.sameTerm(e.why))throw new Error('update: destination '+c+' inconsistent with delete quad '+e.why);y.map(function(t){if('undefined'==typeof e[t])throw new Error('update: undefined '+t+' of statement.')})})});var _=this.editable(c.uri,l);if(!1===_)throw new Error('Update: Can\'t make changes in uneditable '+c);if(void 0===_){if(o)throw new Error('Update: Loaded '+c+'but stil can\'t figure out what editing protcol it supports.');return console.log('Update: have not loaded '.concat(c,' before: loading now...')),void this.store.fetcher.load(c).then(function(e){d.update(t,n,r,!0)},function(e){throw new Error('Update: Can\'t read '.concat(c,' before patching: ').concat(e))})}if(0<=_.indexOf('SPARQL')){var v=[];p.length&&(v=this.statementArrayBnodes(p)),u.length&&(v=v.concat(this.statementArrayBnodes(u)));var w=this.bnodeContext(v,c),k=this.contextWhere(w),T='';if(k.length){if(p.length){T+='DELETE { ';for(var N=0;N<p.length;N++)T+=this.anonymizeNT(p[N])+'\n';T+=' }\n'}if(u.length){T+='INSERT { ';for(var i=0;i<u.length;i++)T+=this.anonymizeNT(u[i])+'\n';T+=' }\n'}T+=k}else{if(p.length){T+='DELETE DATA { ';for(var I=0;I<p.length;I++)T+=this.anonymizeNT(p[I])+'\n';T+=' } \n'}if(u.length){p.length&&(T+=' ; '),T+='INSERT DATA { ';for(var S=0;S<u.length;S++)T+=this.anonymizeNT(u[S])+'\n';T+=' }\n'}}g.pendingUpstream=g.pendingUpstream?g.pendingUpstream+1:1,'upstreamCount'in g&&(g.upstreamCount+=1,console.log('upstream count up to : '+g.upstreamCount)),this.fire(c.uri,T,function(e,t,n,a){if(a.elapsedTimeMs=Date.now()-m,console.log(' UpdateManager: Return '+(t?'success ':'FAILURE ')+a.status+' elapsed '+a.elapsedTimeMs+'ms'),t){try{l.remove(p)}catch(a){t=!1,n='Remote Ok BUT error deleting '+p.length+' from store!!! '+a}for(var o=0;o<u.length;o++)l.add(u[o].subject,u[o].predicate,u[o].object,c)}if(r(e,t,n,a),g.pendingUpstream-=1,0===g.pendingUpstream&&g.downstreamAction){var i=g.downstreamAction;delete g.downstreamAction,console.log('delayed downstream action:'),i(c)}})}else if(0<=_.indexOf('DAV'))this.updateDav(c,p,u,r);else if(0<=_.indexOf('LOCALFILE'))try{this.updateLocalFile(c,p,u,r)}catch(t){r(c.uri,!1,'Exception trying to write back file <'+c.uri+'>\n')}else throw new Error('Unhandled edit method: \''+_+'\' for '+c)}catch(t){r(void 0,!1,'Exception in update: '+t+'\n'+f.stackString(t))}}},{key:'updateDav',value:function e(t,n,a,r){var o=this.store,s=o.any(t,this.ns.link('request'));if(!s)throw new Error('No record of our HTTP GET request for document: '+t);var d=o.any(s,this.ns.link('response'));if(!d)return null;for(var l=o.the(d,this.ns.httph('content-type')).value,p=o.statementsMatching(void 0,void 0,void 0,t).slice(),u=0,c;u<n.length;u++)f.RDFArrayRemove(p,n[u]);for(var i=0;i<a.length;i++)p.push(a[i]);var g=this.serialize(t.uri,p,l),m=o.the(d,this.ns.httph('content-location')),y;m&&(y=h(m.value,y));var b={contentType:l,noMeta:!0,body:g};return o.fetcher.webOperation('PUT',y,b).then(function(e){if(!e.ok)throw new Error(e.error);for(var i=0;i<n.length;i++)o.remove(n[i]);for(var s=0;s<a.length;s++)o.add(a[s].subject,a[s].predicate,a[s].object,t);r(t.uri,e.ok,e.responseText,e)}).catch(function(e){r(t.uri,!1,e.message,e)})}},{key:'updateLocalFile',value:function e(t,n,a,r){var o=this.store;console.log('Writing back to local file\n');for(var s=o.statementsMatching(void 0,void 0,void 0,t).slice(),d=0,p;d<n.length;d++)f.RDFArrayRemove(s,n[d]);for(var i=0;i<a.length;i++)s.push(a[i]);var u=t.uri.lastIndexOf('.');if(1>u)throw new Error('Rewriting file: No filename extension: '+t.uri);var c=t.uri.slice(u+1),h=l.CONTENT_TYPE_BY_EXT[c];if(!h)throw new Error('File extension .'+c+' not supported for data write');var g=this.serialize(t.uri,s,h);console.log('Writing back: <<<'+g+'>>>');var m=t.uri.slice(7),y=Components.classes['@mozilla.org/file/local;1'].createInstance(Components.interfaces.nsILocalFile);if(y.initWithPath(m),!y.exists())throw new Error('Rewriting file <'+t.uri+'> but it does not exist!');var b=Components.classes['@mozilla.org/network/file-output-stream;1'].createInstance(Components.interfaces.nsIFileOutputStream);b.init(y,42,parseInt('0666',8),0),b.write(g,g.length),b.close();for(var x=0;x<n.length;x++)o.remove(n[x]);for(var _=0;_<a.length;_++)o.add(a[_].subject,a[_].predicate,a[_].object,t);r(t.uri,!0,'')}},{key:'serialize',value:function e(t,n,a){var r=this.store,o;if('string'==typeof n)return n;var i=c(r);switch(i.suggestNamespaces(r.namespaces),i.setBase(t),a){case'text/xml':case'application/rdf+xml':o=i.statementsToXML(n);break;case'text/n3':case'text/turtle':case'application/x-turtle':case'application/n3':o=i.statementsToN3(n);break;default:throw new Error('Content-type '+a+' not supported for data serialization');}return o}},{key:'put',value:function e(t,n,a,r){var o=this,i=this.store,s;return Promise.resolve().then(function(){return s=o.serialize(t.uri,n,a),i.fetcher.webOperation('PUT',t.uri,{contentType:a,body:s})}).then(function(e){return e.ok?void(delete i.fetcher.nonexistent[t.uri],delete i.fetcher.requested[t.uri],'string'!=typeof n&&n.map(function(e){i.addStatement(e)}),r(t.uri,e.ok,'',e)):r(t.uri,e.ok,e.error,e)}).catch(function(e){r(t.uri,!1,e.message)})}},{key:'reload',value:function e(t,n,a){var r=Date.now(),o={force:!0,noMeta:!0,clearPreviousData:!0};t.fetcher.nowOrWhenFetched(n.uri,o,function(e,t,o){if(!e)console.log(' ERROR reloading data: '+t),a(!1,'Error reloading data: '+t,o);else if(o.onErrorWasCalled||200!==o.status)console.log(' Non-HTTP error reloading data! onErrorWasCalled='+o.onErrorWasCalled+' status: '+o.status),a(!1,'Non-HTTP error reloading data: '+t,o);else{var i=Date.now()-r;n.reloadTimeTotal||(n.reloadTimeTotal=0),n.reloadTimeCount||(n.reloadTimeCount=0),n.reloadTimeTotal+=i,n.reloadTimeCount+=1,console.log(' Fetch took '+i+'ms, av. of '+n.reloadTimeCount+' = '+n.reloadTimeTotal/n.reloadTimeCount+'ms.'),a(!0)}})}}]),e}();e.exports=g}])}); //# sourceMappingURL=rdflib.min.js.map