UNPKG

link-rdflib

Version:

an RDF library for node.js, patched for speed.

1 lines 374 kB
'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;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(10),h=n(1),f=function(e){function t(e){var n;if(r(this,t),n=s(this,l(t).call(this)),n.termType=t.termType,e&&e.termType===t.termType&&(e=e.value),!e)throw new Error('Missing IRI for NamedNode');if(!e.includes(':'))throw new Error('NamedNode IRI "'+e+'" must be absolute.');if(e.includes(' ')){var a='Error: NamedNode IRI "'+e+'" must not contain unencoded spaces.';throw new Error(a)}return n.value=e,n}return p(t,e),i(t,[{key:'dir',value:function e(){var n=this.uri.split('#')[0],a=n.slice(0,-1).lastIndexOf('/'),r=n.indexOf('//');return 0<=r&&a<r+2||0>a?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;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=function(){function e(){a(this,e)}return o(e,[{key:'substitute',value:function e(t){return console.log('@@@ node substitute'+this),this}},{key:'compareTerm',value:function e(t){return this.classOrder<t.classOrder?-1:this.classOrder>t.classOrder?1:this.value<t.value?-1:this.value>t.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(0<n&&(t=t.slice(0,n)),0===e.length)return t;if(0===e.indexOf('#'))return t+e;if(i=e.indexOf(':'),0<=i)return e;if(a=t.indexOf(':'),0===t.length)return e;if(0>a)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 0<t.length-a-3?t+'/'+e:r+e;}else if(o=t.indexOf('/',a+1),0>o)return 0<t.length-a-1?t+'/'+e:r+e;if(0===e.indexOf('/'))return t.slice(0,o)+e;if(d=t.slice(o),s=d.lastIndexOf('/'),0>s)return r+e;for(0<=s&&s<d.length-1&&(d=d.slice(0,+s+1||9e9)),d+=e;d.match(/[^\/]*\/\.\.\//);)d=d.replace(/[^\/]*\/\.\.\//,'');return d=d.replace(/\.\//g,''),d=d.replace(/\/\.$/,'/'),t.slice(0,o)+d}function s(e){var t;return t=e.indexOf(':'),0>t?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;n<l&&(r=t[d],r===e[d]);d=++n);if(e.slice(0,d).match(a)&&(i=t.indexOf('//'),0>i&&(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(;0<d&&'/'!==t[d-1];)d--;if(3>d)return t;if(0<e.indexOf('//',d-2)||0<t.indexOf('//',d-2))return t;if(0<e.indexOf(':',d))return t;for(h=0,f=e.slice(d),(o=0,c=f.length);o<c;o++)r=f[o],'/'===r&&h++;if(0===h&&d<t.length&&'#'===t[d])return'./'+t.slice(d);if(0===h&&d===t.length)return'./';if(m='',0<h)for(p=1,g=h;1<=g?p<=g:p>=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<a;n++)if(e[n]===t)return n;return-1}function r(e,t){e.callbacks={};for(var n=t.length-1;0<=n;n--)e.callbacks[t[n]]=[];e.addHook=function(t){e.callbacks[t]||(e.callbacks[t]=[])},e.addCallback=function(t,n){e.callbacks[t].push(n)},e.removeCallback=function(t,n){for(var a=0;a<e.callbacks[t].length;a++)if(e.callbacks[t][a].name===n)return e.callbacks[t].splice(a,1),!0;return!1},e.insertCallback=function(t,n){e.callbacks[t].unshift(n)},e.fireCallbacks=function t(n,a){var r=[],o=[],i=e.callbacks[n].length,s,d;for(s=i-1;0<=s;s--)d=e.callbacks[n][s],d&&d.apply(e,a)&&r.push(d);for(s=r.length-1;0<=s;s--)o.push(r[s]);for(s=i;s<e.callbacks[n].length;s++)o.push(e.callbacks[n][s]);e.callbacks[n]=o}}function o(){return window.DOMParser?new DOMParser:!!window.ActiveXObject&&new ActiveXObject('Microsoft.XMLDOM')}function i(e,t){t=t||{};var a=[];'selfClosing'in t&&t.selfClosing.split(' ').forEach(function(e){a[e]=!0});var r=[];return'skipAttributes'in t&&t.skipAttributes.split(' ').forEach(function(e){r[e]=!0}),s(e,t,a,r)}function s(e,t,n,a){var r='',o=[!1],d;if('undefined'==typeof e.nodeType)return r;if(1===e.nodeType){if(e.hasAttribute('class')&&'classWithChildText'in t&&e.matches(t.classWithChildText.class))r+=e.querySelector(t.classWithChildText.element).textContent;else if(!('skipNodeWithClass'in t&&e.matches('.'+t.skipNodeWithClass))){var i=e.nodeName.toLowerCase();r+='<'+i;var l=[];for(d=e.attributes.length-1;0<=d;d--){var p=e.attributes[d];if(!(0<a.length&&a[p.name])&&!/^\d+$/.test(p.name)){if('class'===p.name&&'replaceClassItemWith'in t&&-1<p.value.split(' ').indexOf(t.replaceClassItemWith.source)){var u=new RegExp(t.replaceClassItemWith.source,'g');p.value=p.value.replace(u,t.replaceClassItemWith.target).trim()}'class'===p.name&&'skipClassWithValue'in t&&t.skipClassWithValue===p.value||l.push(p.name+'=\''+p.value.replace(/&/g,'&amp;').replace(/</g,'&lt;').replace(/>/g,'&gt;').replace(/'/g,'&quot;')+'\'')}}if(0<l.length&&('sortAttributes'in t&&t.sortAttributes&&l.sort(function(e,t){return e.toLowerCase().localeCompare(t.toLowerCase())}),r+=' '+l.join(' ')),n[i])r+=' />';else{for(r+='>',r+='html'===i?'\n ':'',o.push('style'===i||'script'===i),d=0;d<e.childNodes.length;d++)r+=s(e.childNodes[d]);o.pop(),r+='body'===i?'</'+i+'>\n':'</'+i+'>'}}}else if(8===e.nodeType)r+='<!--'+e.nodeValue+'-->';else if(3===e.nodeType||4===e.nodeType){var c=e.nodeValue.replace(/\n+$/,'');r+=o[o.length-1]?c:c.replace(/&/g,'&amp;').replace(/</g,'&lt;').replace(/>/g,'&gt;')}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)<o(t)?-1:e.compareTerm(t):a&&e.uri&&t.uri?(a[e.uri]||e.uri).localeCompare(a[t.uri]||t.uri):e.compareTerm(t)}function p(e,t,n,a){return l(e.subject,t.subject,n,a)||l(e.predicate,t.predicate,n,a)||l(e.object,t.object,n,a)}function u(e){var t=document.createElement('div');t.textContent=e,document.body.appendChild(t)}function c(t,a){var r;if(a=a||{},'undefined'!=typeof e&&e&&e.exports){var o=n(41).DOMParser,i=new o().parseFromString(t,a.contentType||'application/xhtml+xml');return i}return r='undefined'!=typeof window&&window.DOMParser?new window.DOMParser:new o,r.parseFromString(t,'application/xml')}function h(e,t){for(var n=0,a;n<e.length;n++)if(a=e[n],a&&a.subject.sameTerm(t.subject)&&a.predicate.sameTerm(t.predicate)&&a.object.sameTerm(t.object)&&a.why.sameTerm(t.why))return void delete e[n];throw new Error('RDFArrayRemove: Array did not contain '+t+' '+t.why)}function f(e,t){return e.slice(0,t.length)===t}function g(e,t){for(var n=e.split('%s'),a='',r=0;r<t.length;r++)t[r]+='',a+=n[r]+t[r];return a+n.slice(t.length).join()}function m(t){var e=''+t+'\n';if(!t.stack)return e+'No stack available.\n';for(var n=t.stack.toString().split('\n'),a=[],r=0,o;r<n.length&&(o=n[r],!(-1<o.indexOf('ecmaunit.js')));r++){'('==o.charAt(0)&&(o='function'+o);var i=o.split('@');a.push(i)}for(var r=0;r<a.length;r++)e+=' '+a[r][1]+'\n '+a[r][0];return e}var y=n(2).docpart,b=n(9),x=n(0);e.exports.AJAR_handleNewTerm=t,e.exports.ArrayIndexOf=a,e.exports.callbackify=r,e.exports.dtstamp=d,e.exports.DOMParserFactory=o,e.exports.domToString=i,e.exports.dumpNode=s,e.exports.heavyCompare=l,e.exports.heavyCompareSPO=p,e.exports.output=u,e.exports.parseXML=c,e.exports.RDFArrayRemove=h,e.exports.stackString=m,e.exports.string_startswith=f,e.exports.string={},e.exports.string.template=g,e.exports.uri=n(2),e.exports.log=b,e.exports.mediaTypeClass=function(e){return e=e.split(';')[0].trim(),new x('http://www.w3.org/ns/iana/media-types/'+e+'#Resource')},e.exports.linkRelationProperty=function(e){return new x('http://www.w3.org/ns/iana/link-relations/relation#'+e.trim())}}).call(this,n(79)(e))},function(e,t){function n(){throw new Error('setTimeout has not been defined')}function a(){throw new Error('clearTimeout has not been defined')}function r(e){if(u===setTimeout)return setTimeout(e,0);if((u===n||!u)&&setTimeout)return u=setTimeout,setTimeout(e,0);try{return u(e,0)}catch(t){try{return u.call(null,e,0)}catch(t){return u.call(this,e,0)}}}function o(e){if(c===clearTimeout)return clearTimeout(e);if((c===a||!c)&&clearTimeout)return c=clearTimeout,clearTimeout(e);try{return c(e)}catch(t){try{return c.call(null,e)}catch(t){return c.call(this,e)}}}function i(){f&&m&&(f=!1,m.length?h=m.concat(h):g=-1,h.length&&s())}function s(){if(!f){var e=r(i);f=!0;for(var t=h.length;t;){for(m=h,h=[];++g<t;)m&&m[g].run();g=-1,t=h.length}m=null,f=!1,o(e)}}function d(e,t){this.fun=e,this.array=t}function l(){}var p=e.exports={},u,c;(function(){try{u='function'==typeof setTimeout?setTimeout:n}catch(t){u=n}try{c='function'==typeof clearTimeout?clearTimeout:a}catch(t){c=a}})();var h=[],f=!1,g=-1,m;p.nextTick=function(e){var t=Array(arguments.length-1);if(1<arguments.length)for(var n=1;n<arguments.length;n++)t[n-1]=arguments[n];h.push(new d(e,t)),1!==h.length||f||r(s)},d.prototype.run=function(){this.fun.apply(null,this.array)},p.title='browser',p.browser=!0,p.env={},p.argv=[],p.version='',p.versions={},p.on=l,p.addListener=l,p.once=l,p.off=l,p.removeListener=l,p.removeAllListeners=l,p.emit=l,p.prependListener=l,p.prependOnceListener=l,p.listeners=function(e){return[]},p.binding=function(e){throw new Error('process.binding is not supported')},p.cwd=function(){return'/'},p.chdir=function(e){throw new Error('process.chdir is not supported')},p.umask=function(){return 0}},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(10),h=n(1),f=function(e){function t(e){var n;if(r(this,t),n=s(this,l(t).call(this)),n.termType=t.termType,e){if('string'!=typeof e)throw console.log('Bad blank id:',e),new Error('Bad id argument to new blank node: '+e);if(e.includes('#')){var a=e.split('#');e=a[a.length-1]}n.id=e}else n.id='n'+t.nextId++;return n.value=n.id,n}return p(t,e),i(t,[{key:'compareTerm',value:function e(t){return this.classOrder<t.classOrder?-1:this.classOrder>t.classOrder?1:this.id<t.id?-1:this.id>t.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;c<u.length;c++)h=u[c],a.prototype[h]||(a.prototype[h]=p.prototype[h]);Object.defineProperty(a.prototype,'writableHighWaterMark',{enumerable:!1,get:function(){return this._writableState.highWaterMark}}),Object.defineProperty(a.prototype,'destroyed',{get:function(){return void 0!==this._readableState&&void 0!==this._writableState&&this._readableState.destroyed&&this._writableState.destroyed},set:function(e){void 0===this._readableState||void 0===this._writableState||(this._readableState.destroyed=e,this._writableState.destroyed=e)}}),a.prototype._destroy=function(e,t){this.push(null),this.end(),i.nextTick(t,e)}},function(e,t){e.exports={debug:function e(t){},warn:function e(t){},info:function e(t){},error:function e(t){},success:function e(t){},msg:function e(t){}}},function(e,t){var n={Literal:1,Collection:3,Graph:4,NamedNode:5,BlankNode:6,Variable:7};e.exports=n},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 i(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 s(e,t,n){return t&&i(e.prototype,t),n&&i(e,n),e}function d(e,t){return t&&('object'===a(t)||'function'==typeof t)?t:l(e)}function l(e){if(void 0===e)throw new ReferenceError('this hasn\'t been initialised - super() hasn\'t been called');return e}function p(e){return p=Object.setPrototypeOf?Object.getPrototypeOf:function e(t){return t.__proto__||Object.getPrototypeOf(t)},p(e)}function u(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&&c(e,t)}function c(e,t){return c=Object.setPrototypeOf||function e(t,n){return t.__proto__=n,t},c(e,t)}var h=n(10),f=n(0),g=n(1),m=n(37),y=function(e){function t(e,n,a){var o;return r(this,t),o=d(this,p(t).call(this)),o.termType=t.termType,o.value=e,n&&(o.lang=n,a=m.langString),a&&(o.datatype=f.fromValue(a)),o}return u(t,e),s(t,[{key:'copy',value:function e(){return new t(this.value,this.lang,this.datatype)}},{key:'equals',value:function e(t){return!!t&&this.termType===t.termType&&this.value===t.value&&this.language===t.language&&(!this.datatype&&!t.datatype||this.datatype&&this.datatype.equals(t.datatype))}},{key:'toNT',value:function e(){if('number'==typeof this.value)return this.toString();if('string'!=typeof this.value)throw new Error('Value of RDF literal is not string or number: '+this.value);var t=this.value;return t=t.replace(/\\/g,'\\\\'),t=t.replace(/\"/g,'\\"'),t=t.replace(/\n/g,'\\n'),t='"'+t+'"',this.language?t+='@'+this.language:!this.datatype.equals(m.string)&&(t+='^^'+this.datatype.toCanonical()),t}},{key:'toString',value:function e(){return''+this.value}},{key:'language',get:function e(){return this.lang},set:function e(t){this.lang=t||''}}],[{key:'fromBoolean',value:function e(n){var a=n?'1':'0';return new t(a,null,m.boolean)}},{key:'fromDate',value:function e(n){if(!(n instanceof Date))throw new TypeError('Invalid argument to Literal.fromDate()');var a=function e(t){return(''+(100+t)).slice(1,3)},r=''+n.getUTCFullYear()+'-'+a(n.getUTCMonth()+1)+'-'+a(n.getUTCDate())+'T'+a(n.getUTCHours())+':'+a(n.getUTCMinutes())+':'+a(n.getUTCSeconds())+'Z';return new t(r,null,m.dateTime)}},{key:'fromNumber',value:function e(n){if('number'!=typeof n)throw new TypeError('Invalid argument to Literal.fromNumber()');var a=n.toString(),r;return r=0>a.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<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)}function c(e,t,n,a){var r=e.any(t,n,void 0);return!!r&&(e.equate(r,a),!0)}function h(e,t,n,a){var r=e.any(void 0,n,a);return!!r&&(e.equate(r,t),!0)}function f(e,t,n,a,r){e.typeCallback&&e.typeCallback(e,a,r);var o=e.classActions[a.hashString()],s=!1;if(o)for(var d=0;d<o.length;d++)s=s||o[d](e,t,n,a,r);return s}var g=n(4).ArrayIndexOf,m=n(55),y=n(4).RDFArrayRemove,b=n(21),x=n(1),_=n(22),v='http://www.w3.org/2002/07/owl#',w='chrome:theSession',k=function(e){function t(e){var n;return r(this,t),n=s(this,l(t).call(this)),n.propertyActions=[],n.classActions=[],n.redirections=[],n.aliases=[],n.HTTPRedirects=[],n.subjectIndex=[],n.predicateIndex=[],n.objectIndex=[],n.whyIndex=[],n.index=[n.subjectIndex,n.predicateIndex,n.objectIndex,n.whyIndex],n.namespaces={},n.features=e||['sameAs','InverseFunctionalProperty','FunctionalProperty'],n.initPropertyActions(n.features),n}return p(t,e),i(t,[{key:'substitute',value:function e(n){var a=this.statements.map(function(e){return e.substitute(n)}),r=new t;return r.add(a),r}},{key:'applyPatch',value:function e(t,a,r){var o=n(23).Query,i=this,s=null,d=function e(n){if(t['delete']){l=t['delete'],s&&(l=l.substitute(s)),l=l.statements;var o=[],d=l.map(function(e){var t=i.statementsMatching(e.subject,e.predicate,e.object,a);return 0===t.length?(o.push(e),null):t[0]});if(o.length)return r('Could not find to delete: '+o.join('\n or '));d.map(function(e){i.remove(e)})}t.insert&&(l=t.insert,s&&(l=l.substitute(s)),l=l.statements,l.map(function(e){e.why=a,i.add(e.subject,e.predicate,e.object,e.why)})),n()},l;if(t.where){var p=new o('patch');p.pat=t.where,p.pat.statements.map(function(e){e.why=a});var u=[];i.query(p,function e(t){u.push(t)},i.fetcher,function e(){return 0===u.length?r('No match found to be patched:'+t.where):1<u.length?r('Patch ambiguous. No patch done.'):void(s=u[0],d(r))})}else d(r)}},{key:'declareExistential',value:function e(t){return this._existentialVariables||(this._existentialVariables=[]),this._existentialVariables.push(t),t}},{key:'initPropertyActions',value:function e(t){this.propertyActions['<http://www.w3.org/1999/02/22-rdf-syntax-ns#type>']=[f],0<=g(t,'sameAs')&&(this.propertyActions['<http://www.w3.org/2002/07/owl#sameAs>']=[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;s<n.length;s++)this.add(n[s]);else n instanceof b?this.add(n.subject,n.predicate,n.object,n.why):n instanceof t&&this.add(n.statements);return this}var i,d;o||(o=this.fetcher?this.fetcher.appNode:this.sym(w)),n=x.fromValue(n),a=x.fromValue(a),r=x.fromValue(r),o=x.fromValue(o),this.predicateCallback&&this.predicateCallback(this,a,o);var l=this.canon(a).hashString();i=this.propertyActions[l];var p=!1;if(i)for(s=0;s<i.length;s++)p=p||i[s](this,n,a,r,o);if(this.holds(n,a,r,o))return null;var u=[this.canon(n).hashString(),l,this.canon(r).hashString(),this.canon(o).hashString()];for(d=new b(n,a,r,o),s=0;4>s;s++){var c=this.index[s],f=u[s];c[f]||(c[f]=[]),c[f].push(d)}return this.statements.push(d),d}},{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;o<t.length;o++){i=t[o];for(var s=[i.subject,i.predicate,i.object,i.why],d=function e(t,n){for(var a=0,r;a<t.length;a++)if(r=t[a],r&&r.subject.sameTerm(n.subject)&&r.predicate.sameTerm(n.predicate)&&r.object.sameTerm(n.object)&&r.why.sameTerm(n.why))return!0},l=0;4>l;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;o<r.length;o++){switch(i=r[o],i.object.termType){case'NamedNode':this.add(n,i.predicate,i.object);break;case'Literal':case'BlankNode':case'Collection':this.add(n,i.predicate,i.object.copy(this));}-1!==g(a,'delete')&&this.remove(i)}}},{key:'equate',value:function e(t,n){t=this.canon(t),n=this.canon(n);var a=t.compareTerm(n);return!a||(0>a?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;s<r.length;s++)o=o||n(this,r[s].subject,t,r[s].object);return o}},{key:'newUniversal',value:function e(t){var n=this.sym(t);return this._universalVariables||(this._universalVariables=[]),this._universalVariables.push(n),n}},{key:'variable',value:function e(t){return new _(t)}},{key:'nextSymbol',value:function e(t){for(var n=0,a;;n++)if(a=t.uri+'#n'+n,!this.mentionsURI(a))return this.sym(a)}},{key:'query',value:function e(t,a,r,o){var i=n(23).indexedFormulaQuery;return i.call(this,t,a,r,o)}},{key:'remove',value:function e(n){if(n instanceof Array){for(var a=0;a<n.length;a++)this.remove(n[a]);return this}if(n instanceof t)return this.remove(n.statements);var r=this.statementsMatching(n.subject,n.predicate,n.object,n.why);if(!r.length)throw new Error('Statement to be removed is not on store: '+n);return this.removeStatement(r[0]),this}},{key:'removeDocument',value:function e(t){for(var n=this.statementsMatching(void 0,void 0,void 0,t).slice(),a=0;a<n.length;a++)this.removeStatement(n[a]);return this}},{key:'removeMany',value:function e(t,n,a,r,o){for(var s=this.statementsMatching(t,n,a,r,!1),d=[],l=0;l<s.length;l++)d.push(s[l]);for(o&&(d=d.slice(0,o)),l=0;l<d.length;l++)this.remove(d[l])}},{key:'removeMatches',value:function e(t,n,a,r){return this.removeStatements(this.statementsMatching(t,n,a,r)),this}},{key:'removeStatement',value:function e(t){for(var n=[t.subject,t.predicate,t.object,t.why],a=0;4>a;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;n<t.length;n++)this.remove(t[n]);return this}},{key:'replaceWith',value:function e(t,n){for(var a=t.hashString(),r=n.hashString(),o=function e(t){var n=t[a];if(n){var o=t[r];t[r]=o?n.concat(o):n,delete t[a]}},s=0;4>s;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;s<this.aliases[a].length;s++)this.redirections[this.aliases[a][s].hashString()]=n,this.aliases[r].push(this.aliases[a][s]);this.add(n,this.sym('http://www.w3.org/2007/ont/link#uri'),t.uri),this.fetcher&&this.fetcher.nowKnownAs(t,n)}return o(this.classActions),o(this.propertyActions),!0}},{key:'allAliases',value:function e(t){var n=this.aliases[this.canon(t).hashString()]||[];return n.push(this.canon(t)),n}},{key:'sameThings',value:function e(t,n){if(t.sameTerm(n))return!0;var a=this.canon(t);if(!a)return!1;var r=this.canon(n);return!!r&&a.uri===r.uri}},{key:'setPrefixForURI',value:function e(t,n){'tab'===t&&this.namespaces.tab||'ns'===t.slice(0,2)||'default'===t.slice(0,7)||(this.namespaces[t]=n)}},{key:'statementsMatching',value:function e(t,n,a,r,o){var s=[t,n,a,r],d=[],l=[],u=[],c=[],h,p;for(h=0;4>h;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<p.length&&(p=p.slice(0,1)),p=p||[],p;var f=1e10,g,m;for(m=0;m<c.length;m++){if(h=c[m],p=this.index[h][l[h]],!p)return[];p.length<f&&(f=p.length,g=m)}for(var i=c[g],y=this.index[i][l[i]],b=c.slice(0,g).concat(c.slice(g+1)),_=[],v=['subject','predicate','object','why'],w=0,k;w<y.length;w++){for(k=y[w],m=0;m<b.length;m++)if(h=b[m],!this.canon(k[v[h]]).sameTerm(d[h])){k=null;break}if(null!=k&&(_.push(k),o))break}return _}},{key:'uris',value:function e(t){var n=this.canon(t),a=this.aliases[n.hashString()];if(!n.uri)return[];var r=[n.uri];if(a)for(var o=0;o<a.length;o++)r.push(a[o].uri);return r}},{key:'length',get:function e(){return this.statements.length}}],[{key:'defaultGraphURI',get:function e(){return w}}]),t}(m);e.exports=k,k.handleRDFType=f},function(e,t,n){function a(e){return function(t){return new r(e+(t||''))}}var r=n(0);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(1),g=function(e){function t(e){var n;return r(this,t),n=s(this,l(t).call(this)),n.termType=t.termType,n.id=c.nextId++,n.elements=[],n.closed=!1,e&&0<e.length&&e.forEach(function(e){n.elements.push(f.fromValue(e))}),n}return p(t,e),i(t,[{key:'append',value:function e(t){return this.elements.push(t)}},{key:'close',value:function e(){return this.closed=!0,this.closed}},{key:'shift',value:function e(){return this.elements.shift()}},{key:'substitute',value:function e(n){var a=this.elements.map(function(e){e.substitute(n)});return new t(a)}},{key:'toNT',value:function e(){return c.NTAnonymousNodePrefix+this.id}},{key:'toString',value:function e(){return'('+this.elements.join(' ')+')'}},{key:'unshift',value:function e(t){return this.elements.unshift(t)}}]),t}(f);g.termType='Collection',g.prototype.classOrder=h.Collection,g.prototype.compareTerm=c.prototype.compareTerm,g.prototype.isVar=0,e.exports=g},function(e,t,n){'use strict';(function(t){function n(e,n,a,r){if('function'!=typeof e)throw new TypeError('"callback" argument must be a function');var o=arguments.length,s,d;switch(o){case 0:case 1:return t.nextTick(e);case 2:return t.nextTick(function t(){e.call(null,n)});case 3:return t.nextTick(function t(){e.call(null,n,a)});case 4:return t.nextTick(function t(){e.call(null,n,a,r)});default:for(s=Array(o-1),d=0;d<s.length;)s[d++]=arguments[d];return t.nextTick(function t(){e.apply(null,s)});}}e.exports=t.version&&0!==t.version.indexOf('v0.')&&(0!==t.version.indexOf('v1.')||0===t.version.indexOf('v1.8.'))?t:{nextTick:n}}).call(this,n(5))},function(e,t,n){function a(e,t){for(var n in e)t[n]=e[n]}function r(e,t,n){return i(e,t,n)}var o=n(49),i=o.Buffer;i.from&&i.alloc&&i.allocUnsafe&&i.allocUnsafeSlow?e.exports=o:(a(o,t),t.Buffer=r),a(i,r),r.from=function(e,t,n){if('number'==typeof e)throw new TypeError('Argument must not be a number');return i(e,t,n)},r.alloc=function(e,t,n){if('number'!=typeof e)throw new TypeError('Argument must be a number');var a=i(e);return void 0===t?a.fill(0):'string'==typeof n?a.fill(t,n):a.fill(t),a},r.allocUnsafe=function(e){if('number'!=typeof e)throw new TypeError('Argument must be a number');return i(e)},r.allocUnsafeSlow=function(e){if('number'!=typeof e)throw new TypeError('Argument must be a number');return o.SlowBuffer(e)}},function(e,t,n){'use strict';function a(e){return new g(e)}function r(e){return new m(e)}function o(){return new y}function i(e,t){return new b(e,t)}function s(){return new x}function d(e,t,n){return new _(''+e,t,n)}function l(e,t){return'string'==typeof t?-1===t.indexOf(':')?new _(e,t):new _(e,null,p(t)):new _(e,null,t)}function p(e){return new v(e)}function u(e,t,n,a){return a=a||new y,new w(e,t,n,a)}function c(e,t,n,a){return new w(e,t,n,a)}function h(e,t,n){return u(e,t,n)}function f(e){return new k(e)}var g=n(6),m=n(17),y=n(78),b=n(32),x=n(15),_=n(11),v=n(0),w=n(21),k=n(22);e.exports.blankNode=a,e.exports.defaultGraph=o,e.exports.graph=s,e.exports.literal=l,e.exports.namedNode=p,e.exports.quad=u,e.exports.triple=h,e.exports.variable=f,e.exports.collection=r,e.exports.fetcher=i,e.exports.lit=d,e.exports.st=c},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;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(1),s=function(){function e(t,n,r,o){a(this,e),this.subject=i.fromValue(t),this.predicate=i.fromValue(n),this.object=i.fromValue(r),this.why=o}return o(e,[{key:'equals',value:function e(t){return t.subject.equals(this.subject)&&t.predicate.equals(this.predicate)&&t.object.equals(this.object)&&t.graph.equals(this.graph)}},{key:'substitute',value:function t(n){var a=new e(this.subject.substitute(n),this.predicate.substitute(n),this.object.substitute(n),this.why.substitute(n));return console.log('@@@ statement substitute:'+a),a}},{key:'toCanonical',value:function e(){var t=[this.subject.toCanonical(),this.predicate.toCanonical(),this.object.toCanonical()];return this.graph&&'DefaultGraph'!==this.graph.termType&&t.push(this.graph.toCanonical()),t.join(' ')+' .'}},{key:'toNT',value:function e(){return[this.subject.toNT(),this.predicate.toNT(),this.object.toNT()].join(' ')+' .'}},{key:'toString',value:function e(){return this.toNT()}},{key:'graph',get:function e(){return this.why},set:function e(t){this.why=t}}]),e}();e.exports=s},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(10),h=n(1),f=n(2),g=function(e){function t(){var e=0<arguments.length&&void 0!==arguments[0]?arguments[0]:'',n;return r(this,t),n=s(this,l(t).call(this)),n.termType=t.termType,n.value=e,n.base='varid:',n.uri=f.join(e,n.base),n}return p(t,e),i(t,[{key:'equals',value:function e(t){return!!t&&this.termType===t.termType&&this.value===t.value}},{key:'hashString',value:function e(){return this.toString()}},{key:'substitute',value:function e(t){var n;return null==(n=t[this.toNT()])?this:n}},{key:'toString',value:function e(){return this.uri.slice(0,this.base.length)===this.base?'?'+this.uri.slice(this.base.length):'?'+this.uri}}]),t}(h);g.termType='Variable',g.prototype.classOrder=c.Variable,g.prototype.isVar=1,e.exports=g},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,n,a){function r(e,t){return e.nvars===t.nvars?e.index.length-t.index.length:e.nvars-t.nvars}var o=function e(t){var n='',a;for(a in t)t.hasOwnProperty(a)&&(n+=' '+a+' -> '+t[a]);return n},i=function e(t){var a='Bindings: ',r=t.length,n;for(n=0;n<r;n++)a+=o(t[n][0])+';\n\t';return a},p=function e(t,n,a,r){var o=a[t];if(void 0===o){if(t.isVar){var i=[];return i[t]=n,[[i,null]]}o=t}if(!o.complexType)return r.redirections[o]&&(o=r.redirections[o]),r.redirections[n]&&(n=r.redirections[n]),o.sameTerm(n)||o.uri&&o.uri===l?[[[],null]]:[];if(t instanceof Array)return n instanceof Array?u(t,n,a):[];throw new Error('query.js: oops - code not written yet')},u=function e(t,a,r,o){var s;if(t.length!==a.length)return[];if(!t.length)return[[[],null]];var d=p(t[0],a[0],r,o);if(0===d.length)return d;var l=[],u=d.length,n,i,c,h,f,g,m;for(n=0;n<u;n++){for(f in i=d[n][0],m=[],i)i.hasOwnProperty(f)&&(m[f]=i[f]);for(f in r)r.hasOwnProperty(f)&&(m[f]=r[f]);for(s=e(t.slice(1),a.slice(1),m,o),h=s.length,c=0;c<h;c++){for(f in g=s[c][0],i)i.hasOwnProperty(f)&&(g[f]=i[f]);l.push([g,null])}}return l},c=function e(t,n){var a=n[t];return void 0===a?t:a},h=function e(t,n){var a={},r;for(r in t)t.hasOwnProperty(r)&&(a[r]=t[r]);for(r in n)n.hasOwnProperty(r)&&(a[r]=n[r]);return a},m=function e(t,n){return this.trunkBindings=n,this.originalCallback=t,this.branches=[],this};m.prototype.checkAllDone=function(){var e;for(e=0;e<this.branches.length;e++)if(!this.branches[e].done)return;s.debug('OPTIONAL BIDNINGS ALL DONE:'),this.doCallBacks(this.branches.length-1,this.trunkBindings)},m.prototype.doCallBacks=function(e,t){var n;if(0>e)return this.originalCallback(t);for(n=0;n<this.branches[e].results.length;n++)this.doCallBacks(e-1,h(t,this.branches[e].results[n]))};var g=function e(t,n){return this.count=0,this.success=!1,this.done=!1,this.callback=t,this.onDone=n,this};g.prototype.reportMatch=function(e){this.callback(e),this.success=!0},g.prototype.reportDone=function(){this.done=!0,s.info('Mandatory query branch finished.***'),void 0!==this.onDone&&this.onDone()};var y=function e(t){return this.count=0,this.done=!1,this.results=[],this.junction=t,t.branches.push(this),this};y.prototype.reportMatch=function(e){this.results.push(e)},y.prototype.reportDone=function(){s.debug('Optional branch finished - results.length = '+this.results.length),0===this.results.length&&(this.results.push({}),s.debug('Optional branch FAILED - that\'s OK.')),this.done=!0,this.junction.checkAllDone()};var b=function e(n,a,r){var o,s,d,i;for(a.nvars=0,a.index=null,o=[a.subject,a.predicate,a.object,a.why],i=[n.subjectIndex,n.predicateIndex,n.objectIndex,n.whyIndex],d=0;4>d;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<r.optional.length;k++)w[k]=new y(_),w[k].pattern_debug=r.optional[k];for(k=0;k<r.optional.length;k++)++w[k].count,e(a,r.optional[k],l,'',u,t,w[k])}return h.count--,void s.debug('Match ends -- success , Branch count now: '+h.count+' for '+h.pattern_debug)}var b=g.length,n,T;if(f){var i='match'+x++,N=function t(n,o){var i=n.uri.split('#')[0];f.nowOrWhenFetched(i,void 0,function(t,o,i){t||console.log('Error following link to <'+n.uri+'> in query: '+o),e(a,r,l,p,u,c,h)})};for(T=0;T<b;T++){if(n=g[T],void 0!==l[n.subject]&&l[n.subject].uri&&f&&'unrequested'===f.getState(d(l[n.subject].uri)))return void N(l[n.subject],i);if(void 0!==l[n.object]&&l[n.object].uri&&f&&'unrequested'===f.getState(d(l[n.object].uri)))return void N(l[n.object],i)}}v(a,r,l,p,u,c,h)},w=function e(t,n){var a=!0,r,o;for(r in t)t.hasOwnProperty(r)&&n[r]&&(o=n[r].test,o&&!o(t[r])&&(a=!1));return a},v=function e(t,a,d,l,p,h,f){var g=a.statements,m=g.length,n,y,x,k,v,T,N;for(n=0;n<m;n++)N=g[n],b(t,N,d);g.sort(r),N=g[0];var I=t.formula();I.optional=a.optional,I.constraints=a.constraints,I.statements=g.slice(1),s.debug(l+'match2 searching '+N.index.length+' for '+N+'; bindings so far='+o(d));var S=N.index.length,j=0,R,c,C;for(R=0;R<S;R++)for(C=N.index[R],c=u([N.subject,N.predicate,N.object,N.why],[C.subject,C.predicate,C.object,C.why],d,t),s.info(l+' From first: '+c.length+': '+i(c)),x=c.length,y=0;y<x;y++)if(v=[],T=c[y][0],!w(T,a.constraints))s.debug('Branch count CS: '+f.count);else{for(k in T)T.hasOwnProperty(k)&&(v[k]=T[k]);for(k in d)d.hasOwnProperty(k)&&(v[k]=d[k]);f.count++,j++,_(t,I,v,l+' ',p,h,f)}f.count--,0==j&&s.debug('Match2 fails completely on '+N),s.debug('Match2 ends, Branch count: '+f.count+' for '+f.pattern_debug),0===f.count&&(s.debug('Branch finished.'),f.reportDone())},k=this;s.debug('Query on '+this.statements.length);var f=new g(t,a);return f.count++,void setTimeout(function(){_(k,e.pat,e.pat.initBindings,'',n,t,f)},0)}var o=n(15),s=n(9),d=n(2).docpart,l=o.defaultGraphURI,i=function e(t,n){a(this,e),this.pat=new o,this.vars=[],this.name=t,this.id=n};e.exports.Query=i,e.exports.indexedFormulaQuery=r},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)}var o=n(2),s=n(4).ArrayIndexOf,i=function(){function e(e){return encodeURI(e)}function t(e){this.details=e}function n(e,t,n,a,r,o,s,d){return new i(e,t,n,a,r,o,s,d)}function i(e,t,n,a,r,o,i,s){'undefined'==typeof t&&(t=null),'undefined'==typeof n&&(n=''),'undefined'==typeof a&&(a=null),'undefined'==typeof r&&(r=''),'undefined'==typeof o&&(o=null),'undefined'==typeof i&&(i=''),'undefined'==typeof s&&(s=null),this._bindings=new x([]),this._flags=i,''!=n&&(S(0<=n.indexOf(':'),'Document URI not absolute: '+n),this._bindings['']=n+'#'),this._store=e,r&&e.setGenPrefix(r),this._thisDoc=n,this.source=e.sym(n),this.lines=0,this.statementCount=0,this.startOfLine=0,this.previousLine=0,this._genPrefix=r,this.keywords=new _(['a','this','bind','has','is','of','true','false']),this.keywordsSet=0,this._anonymousNodes=new x([]),this._variables=new x([]),this._parentVariables=new x([]),this._reason=s,this._reason2=null,j,this._baseURI=a?a:n?n:null,S(!this._baseURI||0<=this._baseU