(function(f){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=f()}else if(typeof define==="function"&&define.amd){define([],f)}else{var g;if(typeof window!=="undefined"){g=window}else if(typeof global!=="undefined"){g=global}else if(typeof self!=="undefined"){g=self}else{g=this}g.$rdf = f()}})(function(){var define,module,exports;return (function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o=t.length&&r())}if(r=r||function(){},!t.length)return r();var u=0;c(t,function(t){e(t,n(i))})},r.forEach=r.each,r.eachSeries=function(n,t,e){if(e=e||function(){},!n.length)return e();var r=0,i=function(){t(n[r],function(t){t?(e(t),e=function(){}):(r+=1,r>=n.length?e():i())})};i()},r.forEachSeries=r.eachSeries,r.eachLimit=function(n,t,e,r){var i=f(t);i.apply(null,[n,e,r])},r.forEachLimit=r.eachLimit;var f=function(n){return function(t,e,r){if(r=r||function(){},!t.length||n<=0)return r();var i=0,u=0,c=0;!function o(){if(i>=t.length)return r();for(;c=t.length?r():o())})}()}},s=function(n){return function(){var t=Array.prototype.slice.call(arguments);return n.apply(null,[r.each].concat(t))}},p=function(n,t){return function(){var e=Array.prototype.slice.call(arguments);return t.apply(null,[f(n)].concat(e))}},d=function(n){return function(){var t=Array.prototype.slice.call(arguments);return n.apply(null,[r.eachSeries].concat(t))}},y=function(n,t,e,r){if(t=o(t,function(n,t){return{index:t,value:n}}),r){var i=[];n(t,function(n,t){e(n.value,function(e,r){i[n.index]=r,t(e)})},function(n){r(n,i)})}else n(t,function(n,t){e(n.value,function(n){t(n)})})};r.map=s(y),r.mapSeries=d(y),r.mapLimit=function(n,t,e,r){return v(t)(n,e,r)};var v=function(n){return p(n,y)};r.reduce=function(n,t,e,i){r.eachSeries(n,function(n,r){e(t,n,function(n,e){t=e,r(n)})},function(n){i(n,t)})},r.inject=r.reduce,r.foldl=r.reduce,r.reduceRight=function(n,t,e,i){var u=o(n,function(n){return n}).reverse();r.reduce(u,t,e,i)},r.foldr=r.reduceRight;var h=function(n,t,e,r){var i=[];t=o(t,function(n,t){return{index:t,value:n}}),n(t,function(n,t){e(n.value,function(e){e&&i.push(n),t()})},function(n){r(o(i.sort(function(n,t){return n.index-t.index}),function(n){return n.value}))})};r.filter=s(h),r.filterSeries=d(h),r.select=r.filter,r.selectSeries=r.filterSeries;var m=function(n,t,e,r){var i=[];t=o(t,function(n,t){return{index:t,value:n}}),n(t,function(n,t){e(n.value,function(e){e||i.push(n),t()})},function(n){r(o(i.sort(function(n,t){return n.index-t.index}),function(n){return n.value}))})};r.reject=s(m),r.rejectSeries=d(m);var g=function(n,t,e,r){n(t,function(n,t){e(n,function(e){e?(r(n),r=function(){}):t()})},function(n){r()})};r.detect=s(g),r.detectSeries=d(g),r.some=function(n,t,e){r.each(n,function(n,r){t(n,function(n){n&&(e(!0),e=function(){}),r()})},function(n){e(!1)})},r.any=r.some,r.every=function(n,t,e){r.each(n,function(n,r){t(n,function(n){n||(e(!1),e=function(){}),r()})},function(n){e(!0)})},r.all=r.every,r.sortBy=function(n,t,e){r.map(n,function(n,e){t(n,function(t,r){t?e(t):e(null,{value:n,criteria:r})})},function(n,t){if(n)return e(n);var r=function(n,t){var e=n.criteria,r=t.criteria;return er?1:0};e(null,o(t.sort(r),function(n){return n.value}))})},r.auto=function(n,t){t=t||function(){};var e=l(n),i=e.length;if(!i)return t();var o={},f=[],s=function(n){f.unshift(n)},p=function(n){for(var t=0;t>>1);e(t,n[u])>=0?r=u:i=u-1}return r}function o(n,t,o,a){return n.started||(n.started=!0),u(t)||(t=[t]),0==t.length?r.setImmediate(function(){n.drain&&n.drain()}):void c(t,function(t){var u={data:t,priority:o,callback:"function"==typeof a?a:null};n.tasks.splice(i(n.tasks,u,e)+1,0,u),n.saturated&&n.tasks.length===n.concurrency&&n.saturated(),r.setImmediate(n.process)})}var a=r.queue(n,t);return a.push=function(n,t,e){o(a,n,t,e)},delete a.unshift,a},r.cargo=function(n,t){var e=!1,i=[],a={tasks:i,payload:t,saturated:null,empty:null,drain:null,drained:!0,push:function(n,e){u(n)||(n=[n]),c(n,function(n){i.push({data:n,callback:"function"==typeof e?e:null}),a.drained=!1,a.saturated&&i.length===t&&a.saturated()}),r.setImmediate(a.process)},process:function r(){if(!e){if(0===i.length)return a.drain&&!a.drained&&a.drain(),void(a.drained=!0);var u="number"==typeof t?i.splice(0,t):i.splice(0,i.length),l=o(u,function(n){return n.data});a.empty&&a.empty(),e=!0,n(l,function(){e=!1;var n=arguments;c(u,function(t){t.callback&&t.callback.apply(null,n)}),r()})}},length:function(){return i.length},running:function(){return e}};return a};var x=function(n){return function(t){var e=Array.prototype.slice.call(arguments,1);t.apply(null,e.concat([function(t){var e=Array.prototype.slice.call(arguments,1);"undefined"!=typeof console&&(t?console.error&&console.error(t):console[n]&&c(e,function(t){console[n](t)}))}]))}};r.log=x("log"),r.dir=x("dir"),r.memoize=function(n,t){var e={},i={};t=t||function(n){return n};var u=function(){var u=Array.prototype.slice.call(arguments),c=u.pop(),o=t.apply(null,u);o in e?r.nextTick(function(){c.apply(null,e[o])}):o in i?i[o].push(c):(i[o]=[c],n.apply(null,u.concat([function(){e[o]=arguments;var n=i[o];delete i[o];for(var t=0,r=n.length;t2){var r=Array.prototype.slice.call(arguments,2);return e.apply(this,r)}return e};r.applyEach=s(S),r.applyEachSeries=d(S),r.forever=function(n,t){function e(r){if(r){if(t)return t(r);throw r}n(e)}e()},"undefined"!=typeof module&&module.exports?module.exports=r:"undefined"!=typeof define&&define.amd?define([],function(){return r}):t.async=r}(); }).call(this,require('_process')) },{"_process":23}],2:[function(require,module,exports){ "use strict";function init(){for(var o="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",r=0,e=o.length;r0)throw new Error("Invalid string. Length must be a multiple of 4");n="="===o[a-2]?2:"="===o[a-1]?1:0,p=new Arr(3*a/4-n),t=n>0?a-4:a;var k=0;for(r=0,e=0;r>16&255,p[k++]=u>>8&255,p[k++]=255&u;return 2===n?(u=revLookup[o.charCodeAt(r)]<<2|revLookup[o.charCodeAt(r+1)]>>4,p[k++]=255&u):1===n&&(u=revLookup[o.charCodeAt(r)]<<10|revLookup[o.charCodeAt(r+1)]<<4|revLookup[o.charCodeAt(r+2)]>>2,p[k++]=u>>8&255,p[k++]=255&u),p}function tripletToBase64(o){return lookup[o>>18&63]+lookup[o>>12&63]+lookup[o>>6&63]+lookup[63&o]}function encodeChunk(o,r,e){for(var t,u=[],n=r;nk?k:a+p));return 1===t?(r=o[e-1],u+=lookup[r>>2],u+=lookup[r<<4&63],u+="=="):2===t&&(r=(o[e-2]<<8)+o[e-1],u+=lookup[r>>10],u+=lookup[r>>4&63],u+=lookup[r<<2&63],u+="="),n.push(u),n.join("")}exports.toByteArray=toByteArray,exports.fromByteArray=fromByteArray;var lookup=[],revLookup=[],Arr="undefined"!=typeof Uint8Array?Uint8Array:Array;init(); },{}],3:[function(require,module,exports){ },{}],4:[function(require,module,exports){ (function (global){ "use strict";function typedArraySupport(){try{var t=new Uint8Array(1);return t.__proto__={__proto__:Uint8Array.prototype,foo:function(){return 42}},42===t.foo()&&"function"==typeof t.subarray&&0===t.subarray(1,1).byteLength}catch(t){return!1}}function kMaxLength(){return Buffer.TYPED_ARRAY_SUPPORT?2147483647:1073741823}function createBuffer(t,e){if(kMaxLength()=kMaxLength())throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+kMaxLength().toString(16)+" bytes");return 0|t}function SlowBuffer(t){return+t!=t&&(t=0),Buffer.alloc(+t)}function byteLength(t,e){if(Buffer.isBuffer(t))return t.length;if("undefined"!=typeof ArrayBuffer&&"function"==typeof ArrayBuffer.isView&&(ArrayBuffer.isView(t)||t instanceof ArrayBuffer))return t.byteLength;"string"!=typeof t&&(t=""+t);var r=t.length;if(0===r)return 0;for(var n=!1;;)switch(e){case"ascii":case"latin1":case"binary":return r;case"utf8":case"utf-8":case void 0:return utf8ToBytes(t).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*r;case"hex":return r>>>1;case"base64":return base64ToBytes(t).length;default:if(n)return utf8ToBytes(t).length;e=(""+e).toLowerCase(),n=!0}}function slowToString(t,e,r){var n=!1;if((void 0===e||e<0)&&(e=0),e>this.length)return"";if((void 0===r||r>this.length)&&(r=this.length),r<=0)return"";if(r>>>=0,e>>>=0,r<=e)return"";for(t||(t="utf8");;)switch(t){case"hex":return hexSlice(this,e,r);case"utf8":case"utf-8":return utf8Slice(this,e,r);case"ascii":return asciiSlice(this,e,r);case"latin1":case"binary":return latin1Slice(this,e,r);case"base64":return base64Slice(this,e,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return utf16leSlice(this,e,r);default:if(n)throw new TypeError("Unknown encoding: "+t);t=(t+"").toLowerCase(),n=!0}}function swap(t,e,r){var n=t[e];t[e]=t[r],t[r]=n}function bidirectionalIndexOf(t,e,r,n,f){if(0===t.length)return-1;if("string"==typeof r?(n=r,r=0):r>2147483647?r=2147483647:r<-2147483648&&(r=-2147483648),r=+r,isNaN(r)&&(r=f?0:t.length-1),r<0&&(r=t.length+r),r>=t.length){if(f)return-1;r=t.length-1}else if(r<0){if(!f)return-1;r=0}if("string"==typeof e&&(e=Buffer.from(e,n)),Buffer.isBuffer(e))return 0===e.length?-1:arrayIndexOf(t,e,r,n,f);if("number"==typeof e)return e=255&e,Buffer.TYPED_ARRAY_SUPPORT&&"function"==typeof Uint8Array.prototype.indexOf?f?Uint8Array.prototype.indexOf.call(t,e,r):Uint8Array.prototype.lastIndexOf.call(t,e,r):arrayIndexOf(t,[e],r,n,f);throw new TypeError("val must be string, number or Buffer")}function arrayIndexOf(t,e,r,n,f){function i(t,e){return 1===o?t[e]:t.readUInt16BE(e*o)}var o=1,u=t.length,s=e.length;if(void 0!==n&&(n=String(n).toLowerCase(),"ucs2"===n||"ucs-2"===n||"utf16le"===n||"utf-16le"===n)){if(t.length<2||e.length<2)return-1;o=2,u/=2,s/=2,r/=2}var a;if(f){var h=-1;for(a=r;au&&(r=u-s),a=r;a>=0;a--){for(var c=!0,l=0;lf&&(n=f)):n=f;var i=e.length;if(i%2!==0)throw new TypeError("Invalid hex string");n>i/2&&(n=i/2);for(var o=0;o239?4:i>223?3:i>191?2:1;if(f+u<=r){var s,a,h,c;switch(u){case 1:i<128&&(o=i);break;case 2:s=t[f+1],128===(192&s)&&(c=(31&i)<<6|63&s,c>127&&(o=c));break;case 3:s=t[f+1],a=t[f+2],128===(192&s)&&128===(192&a)&&(c=(15&i)<<12|(63&s)<<6|63&a,c>2047&&(c<55296||c>57343)&&(o=c));break;case 4:s=t[f+1],a=t[f+2],h=t[f+3],128===(192&s)&&128===(192&a)&&128===(192&h)&&(c=(15&i)<<18|(63&s)<<12|(63&a)<<6|63&h,c>65535&&c<1114112&&(o=c))}}null===o?(o=65533,u=1):o>65535&&(o-=65536,n.push(o>>>10&1023|55296),o=56320|1023&o),n.push(o),f+=u}return decodeCodePointsArray(n)}function decodeCodePointsArray(t){var e=t.length;if(e<=MAX_ARGUMENTS_LENGTH)return String.fromCharCode.apply(String,t);for(var r="",n=0;nn)&&(r=n);for(var f="",i=e;ir)throw new RangeError("Trying to access beyond buffer length")}function checkInt(t,e,r,n,f,i){if(!Buffer.isBuffer(t))throw new TypeError('"buffer" argument must be a Buffer instance');if(e>f||et.length)throw new RangeError("Index out of range")}function objectWriteUInt16(t,e,r,n){e<0&&(e=65535+e+1);for(var f=0,i=Math.min(t.length-r,2);f>>8*(n?f:1-f)}function objectWriteUInt32(t,e,r,n){e<0&&(e=4294967295+e+1);for(var f=0,i=Math.min(t.length-r,4);f>>8*(n?f:3-f)&255}function checkIEEE754(t,e,r,n,f,i){if(r+n>t.length)throw new RangeError("Index out of range");if(r<0)throw new RangeError("Index out of range")}function writeFloat(t,e,r,n,f){return f||checkIEEE754(t,e,r,4,3.4028234663852886e38,-3.4028234663852886e38),ieee754.write(t,e,r,n,23,4),r+4}function writeDouble(t,e,r,n,f){return f||checkIEEE754(t,e,r,8,1.7976931348623157e308,-1.7976931348623157e308),ieee754.write(t,e,r,n,52,8),r+8}function base64clean(t){if(t=stringtrim(t).replace(INVALID_BASE64_RE,""),t.length<2)return"";for(;t.length%4!==0;)t+="=";return t}function stringtrim(t){return t.trim?t.trim():t.replace(/^\s+|\s+$/g,"")}function toHex(t){return t<16?"0"+t.toString(16):t.toString(16)}function utf8ToBytes(t,e){e=e||1/0;for(var r,n=t.length,f=null,i=[],o=0;o55295&&r<57344){if(!f){if(r>56319){(e-=3)>-1&&i.push(239,191,189);continue}if(o+1===n){(e-=3)>-1&&i.push(239,191,189);continue}f=r;continue}if(r<56320){(e-=3)>-1&&i.push(239,191,189),f=r;continue}r=(f-55296<<10|r-56320)+65536}else f&&(e-=3)>-1&&i.push(239,191,189);if(f=null,r<128){if((e-=1)<0)break;i.push(r)}else if(r<2048){if((e-=2)<0)break;i.push(r>>6|192,63&r|128)}else if(r<65536){if((e-=3)<0)break;i.push(r>>12|224,r>>6&63|128,63&r|128)}else{if(!(r<1114112))throw new Error("Invalid code point");if((e-=4)<0)break;i.push(r>>18|240,r>>12&63|128,r>>6&63|128,63&r|128)}}return i}function asciiToBytes(t){for(var e=[],r=0;r>8,f=r%256,i.push(f),i.push(n);return i}function base64ToBytes(t){return base64.toByteArray(base64clean(t))}function blitBuffer(t,e,r,n){for(var f=0;f=e.length||f>=t.length);++f)e[f+r]=t[f];return f}function isnan(t){return t!==t}var base64=require("base64-js"),ieee754=require("ieee754"),isArray=require("isarray");exports.Buffer=Buffer,exports.SlowBuffer=SlowBuffer,exports.INSPECT_MAX_BYTES=50,Buffer.TYPED_ARRAY_SUPPORT=void 0!==global.TYPED_ARRAY_SUPPORT?global.TYPED_ARRAY_SUPPORT:typedArraySupport(),exports.kMaxLength=kMaxLength(),Buffer.poolSize=8192,Buffer._augment=function(t){return t.__proto__=Buffer.prototype,t},Buffer.from=function(t,e,r){return from(null,t,e,r)},Buffer.TYPED_ARRAY_SUPPORT&&(Buffer.prototype.__proto__=Uint8Array.prototype,Buffer.__proto__=Uint8Array,"undefined"!=typeof Symbol&&Symbol.species&&Buffer[Symbol.species]===Buffer&&Object.defineProperty(Buffer,Symbol.species,{value:null,configurable:!0})),Buffer.alloc=function(t,e,r){return alloc(null,t,e,r)},Buffer.allocUnsafe=function(t){return allocUnsafe(null,t)},Buffer.allocUnsafeSlow=function(t){return allocUnsafe(null,t)},Buffer.isBuffer=function(t){return!(null==t||!t._isBuffer)},Buffer.compare=function(t,e){if(!Buffer.isBuffer(t)||!Buffer.isBuffer(e))throw new TypeError("Arguments must be Buffers");if(t===e)return 0;for(var r=t.length,n=e.length,f=0,i=Math.min(r,n);f0&&(t=this.toString("hex",0,e).match(/.{2}/g).join(" "),this.length>e&&(t+=" ... ")),""},Buffer.prototype.compare=function(t,e,r,n,f){if(!Buffer.isBuffer(t))throw new TypeError("Argument must be a Buffer");if(void 0===e&&(e=0),void 0===r&&(r=t?t.length:0),void 0===n&&(n=0),void 0===f&&(f=this.length),e<0||r>t.length||n<0||f>this.length)throw new RangeError("out of range index");if(n>=f&&e>=r)return 0;if(n>=f)return-1;if(e>=r)return 1;if(e>>>=0,r>>>=0,n>>>=0,f>>>=0,this===t)return 0;for(var i=f-n,o=r-e,u=Math.min(i,o),s=this.slice(n,f),a=t.slice(e,r),h=0;hf)&&(r=f),t.length>0&&(r<0||e<0)||e>this.length)throw new RangeError("Attempt to write outside buffer bounds");n||(n="utf8");for(var i=!1;;)switch(n){case"hex":return hexWrite(this,t,e,r);case"utf8":case"utf-8":return utf8Write(this,t,e,r);case"ascii":return asciiWrite(this,t,e,r);case"latin1":case"binary":return latin1Write(this,t,e,r);case"base64":return base64Write(this,t,e,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return ucs2Write(this,t,e,r);default:if(i)throw new TypeError("Unknown encoding: "+n);n=(""+n).toLowerCase(),i=!0}},Buffer.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};var MAX_ARGUMENTS_LENGTH=4096;Buffer.prototype.slice=function(t,e){var r=this.length;t=~~t,e=void 0===e?r:~~e,t<0?(t+=r,t<0&&(t=0)):t>r&&(t=r),e<0?(e+=r,e<0&&(e=0)):e>r&&(e=r),e0&&(f*=256);)n+=this[t+--e]*f;return n},Buffer.prototype.readUInt8=function(t,e){return e||checkOffset(t,1,this.length),this[t]},Buffer.prototype.readUInt16LE=function(t,e){return e||checkOffset(t,2,this.length),this[t]|this[t+1]<<8},Buffer.prototype.readUInt16BE=function(t,e){return e||checkOffset(t,2,this.length),this[t]<<8|this[t+1]},Buffer.prototype.readUInt32LE=function(t,e){return e||checkOffset(t,4,this.length),(this[t]|this[t+1]<<8|this[t+2]<<16)+16777216*this[t+3]},Buffer.prototype.readUInt32BE=function(t,e){return e||checkOffset(t,4,this.length),16777216*this[t]+(this[t+1]<<16|this[t+2]<<8|this[t+3])},Buffer.prototype.readIntLE=function(t,e,r){t=0|t,e=0|e,r||checkOffset(t,e,this.length);for(var n=this[t],f=1,i=0;++i=f&&(n-=Math.pow(2,8*e)),n},Buffer.prototype.readIntBE=function(t,e,r){t=0|t,e=0|e,r||checkOffset(t,e,this.length);for(var n=e,f=1,i=this[t+--n];n>0&&(f*=256);)i+=this[t+--n]*f;return f*=128,i>=f&&(i-=Math.pow(2,8*e)),i},Buffer.prototype.readInt8=function(t,e){return e||checkOffset(t,1,this.length),128&this[t]?(255-this[t]+1)*-1:this[t]},Buffer.prototype.readInt16LE=function(t,e){e||checkOffset(t,2,this.length);var r=this[t]|this[t+1]<<8;return 32768&r?4294901760|r:r},Buffer.prototype.readInt16BE=function(t,e){e||checkOffset(t,2,this.length);var r=this[t+1]|this[t]<<8;return 32768&r?4294901760|r:r},Buffer.prototype.readInt32LE=function(t,e){return e||checkOffset(t,4,this.length),this[t]|this[t+1]<<8|this[t+2]<<16|this[t+3]<<24},Buffer.prototype.readInt32BE=function(t,e){return e||checkOffset(t,4,this.length),this[t]<<24|this[t+1]<<16|this[t+2]<<8|this[t+3]},Buffer.prototype.readFloatLE=function(t,e){return e||checkOffset(t,4,this.length),ieee754.read(this,t,!0,23,4)},Buffer.prototype.readFloatBE=function(t,e){return e||checkOffset(t,4,this.length),ieee754.read(this,t,!1,23,4)},Buffer.prototype.readDoubleLE=function(t,e){return e||checkOffset(t,8,this.length),ieee754.read(this,t,!0,52,8)},Buffer.prototype.readDoubleBE=function(t,e){return e||checkOffset(t,8,this.length),ieee754.read(this,t,!1,52,8)},Buffer.prototype.writeUIntLE=function(t,e,r,n){if(t=+t,e=0|e,r=0|r,!n){var f=Math.pow(2,8*r)-1;checkInt(this,t,e,r,f,0)}var i=1,o=0;for(this[e]=255&t;++o=0&&(o*=256);)this[e+i]=t/o&255;return e+r},Buffer.prototype.writeUInt8=function(t,e,r){return t=+t,e=0|e,r||checkInt(this,t,e,1,255,0),Buffer.TYPED_ARRAY_SUPPORT||(t=Math.floor(t)),this[e]=255&t,e+1},Buffer.prototype.writeUInt16LE=function(t,e,r){return t=+t,e=0|e,r||checkInt(this,t,e,2,65535,0),Buffer.TYPED_ARRAY_SUPPORT?(this[e]=255&t,this[e+1]=t>>>8):objectWriteUInt16(this,t,e,!0),e+2},Buffer.prototype.writeUInt16BE=function(t,e,r){return t=+t,e=0|e,r||checkInt(this,t,e,2,65535,0),Buffer.TYPED_ARRAY_SUPPORT?(this[e]=t>>>8,this[e+1]=255&t):objectWriteUInt16(this,t,e,!1),e+2},Buffer.prototype.writeUInt32LE=function(t,e,r){return t=+t,e=0|e,r||checkInt(this,t,e,4,4294967295,0),Buffer.TYPED_ARRAY_SUPPORT?(this[e+3]=t>>>24,this[e+2]=t>>>16,this[e+1]=t>>>8,this[e]=255&t):objectWriteUInt32(this,t,e,!0),e+4},Buffer.prototype.writeUInt32BE=function(t,e,r){return t=+t,e=0|e,r||checkInt(this,t,e,4,4294967295,0),Buffer.TYPED_ARRAY_SUPPORT?(this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t):objectWriteUInt32(this,t,e,!1),e+4},Buffer.prototype.writeIntLE=function(t,e,r,n){if(t=+t,e=0|e,!n){var f=Math.pow(2,8*r-1);checkInt(this,t,e,r,f-1,-f)}var i=0,o=1,u=0;for(this[e]=255&t;++i>0)-u&255;return e+r},Buffer.prototype.writeIntBE=function(t,e,r,n){if(t=+t,e=0|e,!n){var f=Math.pow(2,8*r-1);checkInt(this,t,e,r,f-1,-f)}var i=r-1,o=1,u=0;for(this[e+i]=255&t;--i>=0&&(o*=256);)t<0&&0===u&&0!==this[e+i+1]&&(u=1),this[e+i]=(t/o>>0)-u&255;return e+r},Buffer.prototype.writeInt8=function(t,e,r){return t=+t,e=0|e,r||checkInt(this,t,e,1,127,-128),Buffer.TYPED_ARRAY_SUPPORT||(t=Math.floor(t)),t<0&&(t=255+t+1),this[e]=255&t,e+1},Buffer.prototype.writeInt16LE=function(t,e,r){return t=+t,e=0|e,r||checkInt(this,t,e,2,32767,-32768),Buffer.TYPED_ARRAY_SUPPORT?(this[e]=255&t,this[e+1]=t>>>8):objectWriteUInt16(this,t,e,!0),e+2},Buffer.prototype.writeInt16BE=function(t,e,r){return t=+t,e=0|e,r||checkInt(this,t,e,2,32767,-32768),Buffer.TYPED_ARRAY_SUPPORT?(this[e]=t>>>8,this[e+1]=255&t):objectWriteUInt16(this,t,e,!1),e+2},Buffer.prototype.writeInt32LE=function(t,e,r){return t=+t,e=0|e,r||checkInt(this,t,e,4,2147483647,-2147483648),Buffer.TYPED_ARRAY_SUPPORT?(this[e]=255&t,this[e+1]=t>>>8,this[e+2]=t>>>16,this[e+3]=t>>>24):objectWriteUInt32(this,t,e,!0),e+4},Buffer.prototype.writeInt32BE=function(t,e,r){return t=+t,e=0|e,r||checkInt(this,t,e,4,2147483647,-2147483648),t<0&&(t=4294967295+t+1),Buffer.TYPED_ARRAY_SUPPORT?(this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t):objectWriteUInt32(this,t,e,!1),e+4},Buffer.prototype.writeFloatLE=function(t,e,r){return writeFloat(this,t,e,!0,r)},Buffer.prototype.writeFloatBE=function(t,e,r){return writeFloat(this,t,e,!1,r)},Buffer.prototype.writeDoubleLE=function(t,e,r){return writeDouble(this,t,e,!0,r)},Buffer.prototype.writeDoubleBE=function(t,e,r){return writeDouble(this,t,e,!1,r)},Buffer.prototype.copy=function(t,e,r,n){if(r||(r=0),n||0===n||(n=this.length),e>=t.length&&(e=t.length),e||(e=0),n>0&&n=this.length)throw new RangeError("sourceStart out of bounds");if(n<0)throw new RangeError("sourceEnd out of bounds");n>this.length&&(n=this.length),t.length-e=0;--f)t[f+e]=this[f+r];else if(i<1e3||!Buffer.TYPED_ARRAY_SUPPORT)for(f=0;f>>=0,r=void 0===r?this.length:r>>>0,t||(t=0);var i;if("number"==typeof t)for(i=e;i0&&this._events[e].length>i&&(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},EventEmitter.prototype.on=EventEmitter.prototype.addListener,EventEmitter.prototype.once=function(e,t){function i(){this.removeListener(e,i),n||(n=!0,t.apply(this,arguments))}if(!isFunction(t))throw TypeError("listener must be a function");var n=!1;return i.listener=t,this.on(e,i),this},EventEmitter.prototype.removeListener=function(e,t){var i,n,s,r;if(!isFunction(t))throw TypeError("listener must be a function");if(!this._events||!this._events[e])return this;if(i=this._events[e],s=i.length,n=-1,i===t||isFunction(i.listener)&&i.listener===t)delete this._events[e],this._events.removeListener&&this.emit("removeListener",e,t);else if(isObject(i)){for(r=s;r-- >0;)if(i[r]===t||i[r].listener&&i[r].listener===t){n=r;break}if(n<0)return this;1===i.length?(i.length=0,delete this._events[e]):i.splice(n,1),this._events.removeListener&&this.emit("removeListener",e,t)}return this},EventEmitter.prototype.removeAllListeners=function(e){var t,i;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(i=this._events[e],isFunction(i))this.removeListener(e,i);else if(i)for(;i.length;)this.removeListener(e,i[i.length-1]);return delete this._events[e],this},EventEmitter.prototype.listeners=function(e){var t;return t=this._events&&this._events[e]?isFunction(this._events[e])?[this._events[e]]:this._events[e].slice():[]},EventEmitter.prototype.listenerCount=function(e){if(this._events){var t=this._events[e];if(isFunction(t))return 1;if(t)return t.length}return 0},EventEmitter.listenerCount=function(e,t){return e.listenerCount(t)}; },{}],8:[function(require,module,exports){ exports.read=function(a,o,t,r,h){var M,p,w=8*h-r-1,f=(1<>1,i=-7,N=t?h-1:0,n=t?-1:1,s=a[o+N];for(N+=n,M=s&(1<<-i)-1,s>>=-i,i+=w;i>0;M=256*M+a[o+N],N+=n,i-=8);for(p=M&(1<<-i)-1,M>>=-i,i+=r;i>0;p=256*p+a[o+N],N+=n,i-=8);if(0===M)M=1-e;else{if(M===f)return p?NaN:(s?-1:1)*(1/0);p+=Math.pow(2,r),M-=e}return(s?-1:1)*p*Math.pow(2,M-r)},exports.write=function(a,o,t,r,h,M){var p,w,f,e=8*M-h-1,i=(1<>1,n=23===h?Math.pow(2,-24)-Math.pow(2,-77):0,s=r?0:M-1,u=r?1:-1,l=o<0||0===o&&1/o<0?1:0;for(o=Math.abs(o),isNaN(o)||o===1/0?(w=isNaN(o)?1:0,p=i):(p=Math.floor(Math.log(o)/Math.LN2),o*(f=Math.pow(2,-p))<1&&(p--,f*=2),o+=p+N>=1?n/f:n*Math.pow(2,1-N),o*f>=2&&(p++,f/=2),p+N>=i?(w=0,p=i):p+N>=1?(w=(o*f-1)*Math.pow(2,h),p+=N):(w=o*Math.pow(2,N-1)*Math.pow(2,h),p=0));h>=8;a[t+s]=255&w,s+=u,w/=256,h-=8);for(p=p<0;a[t+s]=255&p,s+=u,p/=256,e-=8);a[t+s-u]|=128*l}; },{}],9:[function(require,module,exports){ "function"==typeof Object.create?module.exports=function(t,e){t.super_=e,t.prototype=Object.create(e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}})}:module.exports=function(t,e){t.super_=e;var o=function(){};o.prototype=e.prototype,t.prototype=new o,t.prototype.constructor=t}; },{}],10:[function(require,module,exports){ function isBuffer(f){return!!f.constructor&&"function"==typeof f.constructor.isBuffer&&f.constructor.isBuffer(f)}function isSlowBuffer(f){return"function"==typeof f.readFloatLE&&"function"==typeof f.slice&&isBuffer(f.slice(0,0))}module.exports=function(f){return null!=f&&(isBuffer(f)||isSlowBuffer(f)||!!f._isBuffer)}; },{}],11:[function(require,module,exports){ var toString={}.toString;module.exports=Array.isArray||function(r){return"[object Array]"==toString.call(r)}; },{}],12:[function(require,module,exports){ arguments[4][3][0].apply(exports,arguments) },{"dup":3}],13:[function(require,module,exports){ (function (process,global,__dirname){ !function(){var e="undefined"!=typeof process&&process.versions&&process.versions.node,t=!e&&("undefined"!=typeof window||"undefined"!=typeof self);t&&"undefined"==typeof global&&("undefined"!=typeof window?global=window:"undefined"!=typeof self?global=self:"undefined"!=typeof $&&(global=$));var n=function(n){function r(){}function a(e){for(var t=[],n=Object.keys(e).sort(),r=0;r=0;--n)if(t[n]["@id"]===e["@id"])return!0;return!1}function y(e,t,n){var r="@"+n,a=r in e?e[r][0]:t[n];return"embed"===n&&(a===!0?a="@last":a===!1?a="@never":"@always"!==a&&"@never"!==a&&"@link"!==a&&(a="@last")),a}function m(e){if(!A(e)||1!==e.length||!T(e[0]))throw new Ee("Invalid JSON-LD syntax; a JSON-LD frame must be a single object.","jsonld.SyntaxError",{frame:e})}function x(e,t,n,r){for(var a={},o=0;o=0;--p)for(var E=j[p],S=E.terms,D=0;D0&&"/"!==o.substr(-1)&&(o+="/"),o+=r.path),a.path=o}a.query=r.query}a.path=ae(a.path,!!a.authority);var i=a.protocol;return null!==a.authority&&(i+="//"+a.authority),i+=a.path,null!==a.query&&(i+="?"+a.query),null!==r.fragment&&(i+="#"+r.fragment),""===i&&(i="./"),i}function C(e,t){if(null===e)return t;J(e)&&(e=n.url.parse(e||""));var r="";if(""!==e.href?r+=(e.protocol||"")+"//"+(e.authority||""):t.indexOf("//")&&(r+="//"),0!==t.indexOf(r))return t;for(var a=n.url.parse(t.substr(r.length)),o=e.normalizedPath.split("/"),i=a.normalizedPath.split("/"),l=a.fragment||a.query?0:1;o.length>0&&i.length>l&&o[0]===i[0];)o.shift(),i.shift();var u="";if(o.length>0){o.pop();for(var s=0;s=a.length?"":a[n],o in l?l[o].push(i[u]):l[o]=[i[u]];for(var t in l)""!==t&&r(l,t,n+1)}function a(e,t,n,r){r in n||(n[r]=t)}function o(){var e={};return e["@base"]=this["@base"],e.mappings=W(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=n.url.parse(e.base||"");return{"@base":i,mappings:{},inverse:null,getInverse:t,clone:o}}function _(e){if(!J(e))return!1;switch(e){case"@base":case"@context":case"@container":case"@default":case"@embed":case"@explicit":case"@graph":case"@id":case"@index":case"@language":case"@list":case"@omitDefault":case"@preserve":case"@requireAll":case"@reverse":case"@set":case"@type":case"@value":case"@vocab":return!0}return!1}function T(e){return"[object Object]"===Object.prototype.toString.call(e)}function U(e){return T(e)&&0===Object.keys(e).length}function A(e){return Array.isArray(e)}function q(e){if(!J(e)&&!U(e)){var t=!1;if(A(e)){t=!0;for(var n=0;n1||!("@id"in e)}return t}function H(e){return T(e)&&1===Object.keys(e).length&&"@id"in e}function X(e){return T(e)&&"@value"in e}function Q(e){return T(e)&&"@list"in e}function G(e){var t=!1;return T(e)&&(t="@id"in e?0===e["@id"].indexOf("_:"):0===Object.keys(e).length||!("@value"in e||"@set"in e||"@list"in e)),t}function $(e){return J(e)&&e.indexOf(":")!==-1}function W(e){if(e&&"object"==typeof e){var t;if(A(e)){t=[];for(var n=0;nOe)return r=new Ee("Maximum number of @context URLs exceeded.","jsonld.ContextUrlError",{code:"loading remote context failed",max:Oe}),i(r);var l={},u=function(){Y(e,l,!0,a),i(null,e)};Y(e,l,!1,a)||u();var s=[];for(var c in l)l[c]===!1&&s.push(c);for(var d=s.length,f=0;f":n.value,i+=" ",i+="IRI"===r.type?"<"+r.value+">":r.value,i+=" ","IRI"===a.type)i+="<"+a.value+">";else if("blank node"===a.type)i+=a.value;else{var l=a.value.replace(/\\/g,"\\\\").replace(/\t/g,"\\t").replace(/\n/g,"\\n").replace(/\r/g,"\\r").replace(/\"/g,'\\"');i+='"'+l+'"',a.datatype===Ie?a.language&&(i+="@"+a.language):a.datatype!==he&&(i+="^^<"+a.datatype+">")}return null!==o&&void 0!==o&&(i+=0!==o.indexOf("_:")?" <"+o+">":" "+o),i+=" .\n"}function ne(e){var t={};t["@default"]=[];for(var n=e.getSubjects(),r=0;r0;)"."===r[0]||""===r[0]&&r.length>1?r.shift():".."!==r[0]?a.push(r.shift()):(r.shift(),t||a.length>0&&".."!==a[a.length-1]?a.pop():a.push(".."));return n+a.join("/")}n.compact=function(e,t,r,a){function o(e,n,r,o){if(e)return a(e);o.compactArrays&&!o.graph&&A(n)?1===n.length?n=n[0]:0===n.length&&(n={}):o.graph&&T(n)&&(n=[n]),T(t)&&"@context"in t&&(t=t["@context"]),t=W(t),A(t)||(t=[t]);var i=t;t=[];for(var l=0;l0)&&t.push(i[l]);var u=t.length>0;if(1===t.length&&(t=t[0]),A(n)){var s=O(r,"@graph"),c=n;n={},u&&(n["@context"]=t),n[s]=c}else if(T(n)&&u){var c=n;n={"@context":t};for(var d in c)n[d]=c[d]}a(null,n,r)}if(arguments.length<2)return n.nextTick(function(){a(new TypeError("Could not compact, too few arguments."))});if("function"==typeof r&&(a=r,r={}),r=r||{},null===t)return n.nextTick(function(){a(new Ee("The compaction context must not be null.","jsonld.CompactError",{code:"invalid local context"}))});if(null===e)return n.nextTick(function(){a(null,null)});"base"in r||(r.base="string"==typeof e?e:""),"compactArrays"in r||(r.compactArrays=!0),"graph"in r||(r.graph=!1),"skipExpansion"in r||(r.skipExpansion=!1),"documentLoader"in r||(r.documentLoader=n.loadDocument),"link"in r||(r.link=!1),r.link&&(r.skipExpansion=!0);var i=function(e,t,r){return t.skipExpansion?n.nextTick(function(){r(null,e)}):void n.expand(e,t,r)};i(e,r,function(e,i){if(e)return a(new Ee("Could not expand input before compaction.","jsonld.CompactError",{cause:e}));var l=R(r);n.processContext(l,t,r,function(e,t){if(e)return a(new Ee("Could not process context before compaction.","jsonld.CompactError",{cause:e}));var n;try{n=(new Se).compact(t,null,i,r)}catch(e){return a(e)}o(null,n,t,r)})})},n.expand=function(e,t,r){function a(e){"base"in t||(t.base=e.documentUrl||"");var n={document:W(e.document),remoteContext:{"@context":e.contextUrl}};if("expandContext"in t){var a=W(t.expandContext);"object"==typeof a&&"@context"in a?n.expandContext=a:n.expandContext={"@context":a}}Z(n,t,function(e,n){if(e)return r(e);var a;try{var o=new Se,i=R(t),l=n.document,u=n.remoteContext["@context"];n.expandContext&&(i=o.processContext(i,n.expandContext["@context"],t)),u&&(i=o.processContext(i,u,t)),a=o.expand(i,null,l,t,!1),T(a)&&"@graph"in a&&1===Object.keys(a).length?a=a["@graph"]:null===a&&(a=[]),A(a)||(a=[a])}catch(e){return r(e)}r(null,a)})}return arguments.length<1?n.nextTick(function(){r(new TypeError("Could not expand, too few arguments."))}):("function"==typeof t&&(r=t,t={}),t=t||{},"documentLoader"in t||(t.documentLoader=n.loadDocument),"keepFreeFloatingNodes"in t||(t.keepFreeFloatingNodes=!1),void n.nextTick(function(){if("string"==typeof e){var n=function(e,t){if(e)return r(e);try{if(!t.document)throw new Ee("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 Ee("Could not retrieve a JSON-LD document from the URL. URL dereferencing not implemented.","jsonld.LoadDocumentError",{code:"loading document failed",cause:e,remoteDoc:t}))}a(t)},o=t.documentLoader(e,n);return void(o&&"then"in o&&o.then(n.bind(null,null),n))}a({contextUrl:null,documentUrl:null,document:e})}))},n.flatten=function(e,t,r,a){return arguments.length<1?n.nextTick(function(){a(new TypeError("Could not flatten, too few arguments."))}):("function"==typeof r?(a=r,r={}):"function"==typeof t&&(a=t,t=null,r={}),r=r||{},"base"in r||(r.base="string"==typeof e?e:""),"documentLoader"in r||(r.documentLoader=n.loadDocument),void n.expand(e,r,function(e,o){if(e)return a(new Ee("Could not expand input before flattening.","jsonld.FlattenError",{cause:e}));var i;try{i=(new Se).flatten(o)}catch(e){return a(e)}return null===t?a(null,i):(r.graph=!0,r.skipExpansion=!0,void n.compact(i,t,r,function(e,t){return e?a(new Ee("Could not compact flattened output.","jsonld.FlattenError",{cause:e})):void a(null,t)}))}))},n.frame=function(e,t,r,a){function o(t){var o,i=t.document;i?(o=i["@context"],t.contextUrl?(o?A(o)?o.push(t.contextUrl):o=[o,t.contextUrl]:o=t.contextUrl,i["@context"]=o):o=o||{}):o={},n.expand(e,r,function(e,t){if(e)return a(new Ee("Could not expand input before framing.","jsonld.FrameError",{cause:e}));var l=W(r);l.isFrame=!0,l.keepFreeFloatingNodes=!0,n.expand(i,l,function(e,r){if(e)return a(new Ee("Could not expand frame before framing.","jsonld.FrameError",{cause:e}));var i;try{i=(new Se).frame(t,r,l)}catch(e){return a(e)}l.graph=!0,l.skipExpansion=!0,l.link={},n.compact(i,o,l,function(e,t,n){if(e)return a(new Ee("Could not compact framed output.","jsonld.FrameError",{cause:e}));var r=O(n,"@graph");l.link={},t[r]=k(n,t[r],l),a(null,t)})})})}return arguments.length<2?n.nextTick(function(){a(new TypeError("Could not frame, too few arguments."))}):("function"==typeof r&&(a=r,r={}),r=r||{},"base"in r||(r.base="string"==typeof e?e:""),"documentLoader"in r||(r.documentLoader=n.loadDocument),"embed"in r||(r.embed="@last"),r.explicit=r.explicit||!1,"requireAll"in r||(r.requireAll=!0),r.omitDefault=r.omitDefault||!1,void n.nextTick(function(){if("string"==typeof t){var e=function(e,t){if(e)return a(e);try{if(!t.document)throw new Ee("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 Ee("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)},n=r.documentLoader(t,e);return void(n&&"then"in n&&n.then(e.bind(null,null),e))}o({contextUrl:null,documentUrl:null,document:t})}))},n.link=function(e,t,r,a){var o={};t&&(o["@context"]=t),o["@embed"]="@link",n.frame(e,o,r,a)},n.objectify=function(e,t,r,a){"function"==typeof r&&(a=r,r={}),r=r||{},"base"in r||(r.base="string"==typeof e?e:""),"documentLoader"in r||(r.documentLoader=n.loadDocument),n.expand(e,r,function(e,o){if(e)return a(new Ee("Could not expand input before linking.","jsonld.LinkError",{cause:e}));var i;try{i=(new Se).flatten(o)}catch(e){return a(e)}r.graph=!0,r.skipExpansion=!0,n.compact(i,t,r,function(e,t,r){if(e)return a(new Ee("Could not compact flattened output before linking.","jsonld.LinkError",{cause:e}));var o=O(r,"@graph"),i=t[o][0],l=function(e){if(T(e)||A(e)){if(T(e)){if(l.visited[e["@id"]])return;l.visited[e["@id"]]=!0}for(var t in e){var a=e[t],o="@id"===n.getContextValue(r,t,"@type"); if(A(a)||T(a)||o)if(J(a)&&o)e[t]=a=i[a],l(a);else if(A(a))for(var u=0;u]*?>|"[^"]*?"|[^,])+/g),r=/\s*<([^>]*?)>\s*(?:;\s*(.*))?/,a=0;a=+new Date)return t.ctx;delete this.cache[e],this.order.splice(this.order.indexOf(e),1)}return null},n.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}},n.ActiveContextCache=function(e){this.order=[],this.cache={},this.size=e||100},n.ActiveContextCache.prototype.get=function(e,t){var n=JSON.stringify(e),r=JSON.stringify(t),a=this.cache[n];return a&&r in a?a[r]:null},n.ActiveContextCache.prototype.set=function(e,t,n){if(this.order.length===this.size){var r=this.order.shift();delete this.cache[r.activeCtx][r.localCtx]}var a=JSON.stringify(e),o=JSON.stringify(t);this.order.push({activeCtx:a,localCtx:o}),a in this.cache||(this.cache[a]={}),this.cache[a][o]=W(n)},n.cache={activeCtx:new n.ActiveContextCache},n.documentLoaders={},n.documentLoaders.jquery=function(e,t){function r(r,a){return 0!==r.indexOf("http:")&&0!==r.indexOf("https:")?a(new Ee('URL could not be dereferenced; only "http" and "https" URLs are supported.',"jsonld.InvalidUrl",{code:"loading document failed",url:r}),{contextUrl:null,documentUrl:r,document:null}):t.secure&&0!==r.indexOf("https")?a(new Ee('URL could not be dereferenced; secure mode is enabled and the URL\'s scheme is not "https".',"jsonld.InvalidUrl",{code:"loading document failed",url:r}),{contextUrl:null,documentUrl:r,document:null}):void e.ajax({url:r,accepts:{json:"application/ld+json, application/json"},headers:{Accept:"application/ld+json, application/json"},dataType:"json",crossDomain:!0,success:function(e,t,o){var i={contextUrl:null,documentUrl:r,document:e},l=o.getResponseHeader("Content-Type"),u=o.getResponseHeader("Link");if(u&&"application/ld+json"!==l){if(u=n.parseLinkHeader(u)[Le],A(u))return a(new Ee("URL could not be dereferenced, it has more than one associated HTTP Link Header.","jsonld.InvalidUrl",{code:"multiple context link headers",url:r}),i);u&&(i.contextUrl=u.target)}a(null,i)},error:function(e,t,n){a(new Ee("URL could not be dereferenced, an error occurred.","jsonld.LoadDocumentError",{code:"loading document failed",url:r,cause:n}),{contextUrl:null,documentUrl:r,document:null})}})}t=t||{};var a=new n.RequestQueue,o="usePromise"in t?t.usePromise:"undefined"!=typeof Promise;return o?a.wrapLoader(function(e){return n.promisify(r,e)}):a.wrapLoader(r)},n.documentLoaders.node=function(e){function t(u,s,c){function d(e,r,o){if(f={contextUrl:null,documentUrl:u,document:o||null},e)return c(new Ee("URL could not be dereferenced, an error occurred.","jsonld.LoadDocumentError",{code:"loading document failed",url:u,cause:e}),f);var i=l.STATUS_CODES[r.statusCode];if(r.statusCode>=400)return c(new Ee("URL could not be dereferenced: "+i,"jsonld.InvalidUrl",{code:"loading document failed",url:u,httpStatusCode:r.statusCode}),f);if(r.headers.link&&"application/ld+json"!==r.headers["content-type"]){var d=n.parseLinkHeader(r.headers.link)[Le];if(A(d))return c(new Ee("URL could not be dereferenced, it has more than one associated HTTP Link Header.","jsonld.InvalidUrl",{code:"multiple context link headers",url:u}),f);d&&(f.contextUrl=d.target)}return r.statusCode>=300&&r.statusCode<400&&r.headers.location?s.length===a?c(new Ee("URL could not be dereferenced; there were too many redirects.","jsonld.TooManyRedirects",{code:"loading document failed",url:u,httpStatusCode:r.statusCode,redirects:s}),f):s.indexOf(u)!==-1?c(new Ee("URL could not be dereferenced; infinite redirection was detected.","jsonld.InfiniteRedirectDetected",{code:"recursive context inclusion",url:u,httpStatusCode:r.statusCode,redirects:s}),f):(s.push(u),t(r.headers.location,s,c)):(s.push(u),void c(e,f))}if(0!==u.indexOf("http:")&&0!==u.indexOf("https:"))return c(new Ee('URL could not be dereferenced; only "http" and "https" URLs are supported.',"jsonld.InvalidUrl",{code:"loading document failed",url:u}),{contextUrl:null,documentUrl:u,document:null});if(e.secure&&0!==u.indexOf("https"))return c(new Ee('URL could not be dereferenced; secure mode is enabled and the URL\'s scheme is not "https".',"jsonld.InvalidUrl",{code:"loading document failed",url:u}),{contextUrl:null,documentUrl:u,document:null});var f=null;if(null!==f)return c(null,f);var p={Accept:i};for(var h in e.headers)p[h]=e.headers[h];o({url:u,headers:p,strictSSL:r,followRedirect:!1},d)}e=e||{};var r=!("strictSSL"in e)||e.strictSSL,a="maxRedirects"in e?e.maxRedirects:-1,o="request"in e?e.request:require("request"),i="application/ld+json, application/json",l=require("http"),u=new n.RequestQueue;if(e.usePromise)return u.wrapLoader(function(e){return n.promisify(t,e,[])});var s=e.headers||{};if("Accept"in s||"accept"in s)throw new RangeError('Accept header may not be specified as an option; only "'+i+'" is supported.');return u.wrapLoader(function(e,n){t(e,[],n)})},n.documentLoaders.xhr=function(e){function t(t,a){if(0!==t.indexOf("http:")&&0!==t.indexOf("https:"))return a(new Ee('URL could not be dereferenced; only "http" and "https" URLs are supported.',"jsonld.InvalidUrl",{code:"loading document failed",url:t}),{contextUrl:null,documentUrl:t,document:null});if(e.secure&&0!==t.indexOf("https"))return a(new Ee('URL could not be dereferenced; secure mode is enabled and the URL\'s scheme is not "https".',"jsonld.InvalidUrl",{code:"loading document failed",url:t}),{contextUrl:null,documentUrl:t,document:null});var o=e.xhr||XMLHttpRequest,i=new o;i.onload=function(){if(i.status>=400)return a(new Ee("URL could not be dereferenced: "+i.statusText,"jsonld.LoadDocumentError",{code:"loading document failed",url:t,httpStatusCode:i.status}),{contextUrl:null,documentUrl:t,document:null});var e,o={contextUrl:null,documentUrl:t,document:i.response},l=i.getResponseHeader("Content-Type");if(r.test(i.getAllResponseHeaders())&&(e=i.getResponseHeader("Link")),e&&"application/ld+json"!==l){if(e=n.parseLinkHeader(e)[Le],A(e))return a(new Ee("URL could not be dereferenced, it has more than one associated HTTP Link Header.","jsonld.InvalidUrl",{code:"multiple context link headers",url:t}),o);e&&(o.contextUrl=e.target)}a(null,o)},i.onerror=function(){a(new Ee("URL could not be dereferenced, an error occurred.","jsonld.LoadDocumentError",{code:"loading document failed",url:t}),{contextUrl:null,documentUrl:t,document:null})},i.open("GET",t,!0),i.setRequestHeader("Accept","application/ld+json, application/json"),i.send()}e=e||{};var r=/(^|(\r\n))link:/i,a=new n.RequestQueue,o="usePromise"in e?e.usePromise:"undefined"!=typeof Promise;return o?a.wrapLoader(function(e){return n.promisify(t,e)}):a.wrapLoader(t)},n.useDocumentLoader=function(e){if(!(e in n.documentLoaders))throw new Ee('Unknown document loader type: "'+e+'"',"jsonld.UnknownDocumentLoader",{type:e});n.documentLoader=n.documentLoaders[e].apply(n,Array.prototype.slice.call(arguments,1))},n.processContext=function(e,t){var r={},a=2;arguments.length>3&&(r=arguments[2]||{},a+=1);var o=arguments[a];return"base"in r||(r.base=""),"documentLoader"in r||(r.documentLoader=n.loadDocument),null===t?o(null,R(r)):(t=W(t),T(t)&&"@context"in t||(t={"@context":t}),void Z(t,r,function(t,n){if(t)return o(t);try{n=(new Se).processContext(e,n,r)}catch(e){return o(e)}o(null,n)}))},n.hasProperty=function(e,t){var n=!1;if(t in e){var r=e[t];n=!A(r)||r.length>0}return n},n.hasValue=function(e,t,r){var a=!1;if(n.hasProperty(e,t)){var o=e[t],i=Q(o);if(A(o)||i){i&&(o=o["@list"]);for(var l=0;l0){var v=O(e,p);n.addValue(o,v,L)}}else{var L;if(J(h))L=O(e,h,null,{vocab:"@type"===p});else{L=[];for(var y=0;y1&&!(2===S&&"@index"in s))throw new Ee('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:s});"@set"in s&&(s=s["@set"],h=Object.keys(s),S=h.length)}else 1===S&&"@language"in s&&(s=null);return!T(s)||o.keepFreeFloatingNodes||l||null!==t&&"@graph"!==p||(0===S||"@value"in s||"@list"in s||1===S&&"@id"in s)&&(s=null),s},Se.prototype.createNodeMap=function(e,t){t=t||{};var n=t.namer||t.issuer||new re("_:b"),r={"@default":{}};return f(e,r,"@default",n),p(r)},Se.prototype.flatten=function(e){for(var t=this.createNodeMap(e),n=[],r=Object.keys(t).sort(),a=0;a=r.MAX_TOTAL_DEPTH?t(new Error("Maximum total call stack depth exceeded; normalization aborting.")):void function a(){if(r.depth===r.MAX_DEPTH)return r.depth=0,r.running=!1,n.nextTick(a);var o=(new Date).getTime();return r.running||(r.start=(new Date).getTime(),r.deadline=r.start+r.timeSlice),o1)return o();var l=i[0];n.canonicalIssuer.getId(l),delete a[l],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,r){var a=[],o=n.hashToBlankNodes[e];n.waterfall([function(e){n.forEach(o,function(e,t,r){if(n.canonicalIssuer.hasId(e))return r();var o=new re("_:b");o.getId(e),n.hashNDegreeQuads(e,o,function(e,t){return e?r(e):(a.push(t),void r())})},e)},function(e){a.sort(function(e,t){return e.hasht.hash?1:0}),n.forEach(a,function(e,t,r){for(var a in e.issuer.existing)n.canonicalIssuer.getId(a);r()},e)}],r)},e)},function(e){var t=[];n.waterfall([function(e){n.forEach(n.quads,function(e,r,a){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(te(e)),a()},e)},function(e){return t.sort(),"application/nquads"===n.options.format?(r=t.join(""),e()):(r=K(t.join("")),void e())}],e)}],function(e){t(e,r)})},t.prototype.hashFirstDegreeQuads=function(e,t){var n=this,r=n.blankNodeInfo[e];if("hash"in r)return t(null,r.hash);var a=[],o=r.quads;n.forEach(o,function(t,r,o){var i={predicate:t.predicate};n.forEachComponent(t,function(t,r){i[r]=n.modifyFirstDegreeComponent(e,t,r)}),a.push(te(i)),o()},function(e){return e?t(e):(a.sort(),r.hash=Re.hashNQuads(n.name,a),void t(null,r.hash))})},t.prototype.modifyFirstDegreeComponent=function(e,t){return"blank node"!==t.type?t:(t=W(t),t.value=t.value===e?"_:a":"_:z",t)},t.prototype.hashRelatedBlankNode=function(e,t,n,r,a){var o,i=this;i.waterfall([function(t){return i.canonicalIssuer.hasId(e)?(o=i.canonicalIssuer.getId(e),t()):n.hasId(e)?(o=n.getId(e),t()):void i.hashFirstDegreeQuads(e,function(e,n){return e?t(e):(o=n,void t())})}],function(e){if(e)return a(e);var n=new Re(i.name);return n.update(r),"g"!==r&&n.update(i.getRelatedPredicate(t)),n.update(o),a(null,n.digest())})},t.prototype.getRelatedPredicate=function(e){return"<"+e.predicate.value+">"},t.prototype.hashNDegreeQuads=function(e,t,n){var r,a=this,o=new Re(a.name);a.waterfall([function(n){a.createHashToRelated(e,t,function(e,t){return e?n(e):(r=t,void n())})},function(e){var n=Object.keys(r).sort();a.forEach(n,function(e,n,i){o.update(e);var l,u="",s=new Ce(r[e]);a.whilst(function(){return s.hasNext()},function(e){var n=s.next(),r=t.clone(),o="",i=[];a.waterfall([function(t){a.forEach(n,function(t,n,l){return a.canonicalIssuer.hasId(t)?o+=a.canonicalIssuer.getId(t):(r.hasId(t)||i.push(t),o+=r.getId(t)),0!==u.length&&o.length>=u.length&&o>u?e():void l()},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!==u.length&&o.length>=u.length&&o>u?e():void i())})},t)},function(e){(0===u.length||ot)&&(i&&a>0&&o>this.list[a-1]||!i&&athis.list[a+1])&&(t=o,n=a)}if(null===t)this.done=!0;else{var l=this.left[t]?n-1:n+1;this.list[n]=this.list[l],this.list[l]=t;for(var a=0;at&&(this.left[this.list[a]]=!this.left[this.list[a]])}return e};var Re=function(e){if(!(this instanceof Re))return new Re(e);if(["URDNA2015","URGNA2012"].indexOf(e)===-1)throw new Error("Invalid RDF Dataset Normalization algorithm: "+e);Re._init.call(this,e)};if(Re.hashNQuads=function(e,t){for(var n=new Re(e),r=0;r0;)1&r&&(n._padding+=t),r>>>=1,r>0&&(t+=t)}this.start()};n.prototype.start=function(){this.messageLength=0,this.fullMessageLength=[];for(var e=this._algorithm.messageLengthSize/4,t=0;t>>0,t>>>0];for(var r=this.fullMessageLength.length-1;r>=0;--r)this.fullMessageLength[r]+=t[1],t[1]=t[0]+(this.fullMessageLength[r]/4294967296>>>0),this.fullMessageLength[r]=this.fullMessageLength[r]>>>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(this._input.read>2048||0===this._input.length())&&this._input.compact(),this},n.prototype.digest=function(){var e=new n.ByteBuffer;e.putBytes(this._input.bytes());var t=this.fullMessageLength[this.fullMessageLength.length-1]+this._algorithm.messageLengthSize,r=t&this._algorithm.blockSize-1;e.putBytes(n._padding.substr(0,this._algorithm.blockSize-r));for(var a=new n.ByteBuffer,o=0;o>>28);this._algorithm.writeMessageLength(e,a);var i=this._algorithm.digest(this.state.copy(),e),l=new n.ByteBuffer;return i.write(l),l},n.ByteBuffer=function(e){"string"==typeof e?this.data=e:this.data="",this.read=0},n.ByteBuffer.prototype.putInt32=function(e){this.data+=String.fromCharCode(e>>24&255)+String.fromCharCode(e>>16&255)+String.fromCharCode(e>>8&255)+String.fromCharCode(255&e)},n.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},n.ByteBuffer.prototype.putBytes=function(e){this.data+=e},n.ByteBuffer.prototype.bytes=function(){return this.data.slice(this.read)},n.ByteBuffer.prototype.length=function(){return this.data.length-this.read},n.ByteBuffer.prototype.compact=function(){this.data=this.data.slice(this.read),this.read=0},n.ByteBuffer.prototype.toHex=function(){for(var e="",t=this.read;t=64;){for(a=e.h0,o=e.h1,i=e.h2,l=e.h3,u=e.h4,c=0;c<16;++c)n=t.getInt32(),f[c]=n,s=l^o&(i^l),n=(a<<5|a>>>27)+s+u+1518500249+n,u=l,l=i,i=o<<30|o>>>2,o=a,a=n;for(;c<20;++c)n=f[c-3]^f[c-8]^f[c-14]^f[c-16],n=n<<1|n>>>31,f[c]=n,s=l^o&(i^l),n=(a<<5|a>>>27)+s+u+1518500249+n,u=l,l=i,i=o<<30|o>>>2,o=a,a=n;for(;c<32;++c)n=f[c-3]^f[c-8]^f[c-14]^f[c-16],n=n<<1|n>>>31,f[c]=n,s=o^i^l,n=(a<<5|a>>>27)+s+u+1859775393+n,u=l,l=i,i=o<<30|o>>>2,o=a,a=n;for(;c<40;++c)n=f[c-6]^f[c-16]^f[c-28]^f[c-32],n=n<<2|n>>>30,f[c]=n,s=o^i^l,n=(a<<5|a>>>27)+s+u+1859775393+n,u=l,l=i,i=o<<30|o>>>2,o=a,a=n;for(;c<60;++c)n=f[c-6]^f[c-16]^f[c-28]^f[c-32],n=n<<2|n>>>30,f[c]=n,s=o&i|l&(o^i),n=(a<<5|a>>>27)+s+u+2400959708+n,u=l,l=i,i=o<<30|o>>>2,o=a,a=n;for(;c<80;++c)n=f[c-6]^f[c-16]^f[c-28]^f[c-32],n=n<<2|n>>>30,f[c]=n,s=o^i^l,n=(a<<5|a>>>27)+s+u+3395469782+n,u=l,l=i,i=o<<30|o>>>2,o=a,a=n;e.h0=e.h0+a|0,e.h1=e.h1+o|0,e.h2=e.h2+i|0,e.h3=e.h3+l|0,e.h4=e.h4+u|0,d-=64}return e},r._createState=function(){var e={h0:1732584193,h1:4023233417,h2:2562383102,h3:271733878,h4:3285377520};return e.copy=function(){var t=r._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 a={_k:null,_w:null};a.Algorithm=function(){this.name="sha256",this.blockSize=64,this.digestLength=32,this.messageLengthSize=8},a.Algorithm.prototype.start=function(){return a._k||a._init(),a._createState()},a.Algorithm.prototype.writeMessageLength=function(e,t){e.putBytes(t.bytes())},a.Algorithm.prototype.digest=function(e,t){for(var n,r,o,i,l,u,s,c,d,f,p,h,v,g,y,m=t.length(),x=a._k,b=a._w;m>=64;){for(s=0;s<16;++s)b[s]=t.getInt32();for(;s<64;++s)n=b[s-2],n=(n>>>17|n<<15)^(n>>>19|n<<13)^n>>>10,r=b[s-15],r=(r>>>7|r<<25)^(r>>>18|r<<14)^r>>>3,b[s]=n+b[s-7]+r+b[s-16]|0;for(c=e.h0,d=e.h1,f=e.h2,p=e.h3,h=e.h4,v=e.h5,g=e.h6,y=e.h7,s=0;s<64;++s)i=(h>>>6|h<<26)^(h>>>11|h<<21)^(h>>>25|h<<7),l=g^h&(v^g),o=(c>>>2|c<<30)^(c>>>13|c<<19)^(c>>>22|c<<10),u=c&d|f&(c^d),n=y+i+l+x[s]+b[s],r=o+u,y=g,g=v,v=h,h=p+n|0,p=f,f=d,d=c,c=n+r|0;e.h0=e.h0+c|0,e.h1=e.h1+d|0,e.h2=e.h2+f|0,e.h3=e.h3+p|0,e.h4=e.h4+h|0,e.h5=e.h5+v|0,e.h6=e.h6+g|0,e.h7=e.h7+y|0,m-=64}return e},a._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=a._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},a._init=function(){a._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],a._w=new Array(64)}}(e),!se)var _e=function(){se=require("xmldom").XMLSerializer};if(n.url={},n.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*))?))?(?:(((?:[^?#\/]*\/)*)([^?#]*))(?:\?([^#]*))?(?:#(.*))?)/}},n.url.parse=function(e,t){for(var r={},a=n.url.parsers[t||"full"],o=a.regex.exec(e),i=a.keys.length;i--;)r[a.keys[i]]=void 0===o[i]?null:o[i];return r.normalizedPath=ae(r.path,!!r.authority),r},e?n.useDocumentLoader("node"):"undefined"!=typeof XMLHttpRequest&&n.useDocumentLoader("xhr"),e){n.use=function(e){switch(e){case"request":n.request=require("jsonld-request");break;default:throw new Ee("Unknown extension.","jsonld.UnknownExtension",{extension:e})}};var Te={exports:{},filename:__dirname};require("pkginfo")(Te,"version"),n.version=Te.exports.version}return n},r=function(){return n(function(){return r()})};return!e&&"function"==typeof define&&define.amd?define([],function(){return n(r),r}):(n(r),"function"==typeof require&&"undefined"!=typeof module&&module.exports&&(module.exports=r),t&&("undefined"==typeof jsonld?jsonld=jsonldjs=r:jsonldjs=r)),r}(); }).call(this,require('_process'),typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {},"/node_modules/jsonld/js") },{"_process":23,"crypto":12,"es6-promise":6,"http":12,"jsonld-request":12,"pkginfo":12,"request":12,"util":12,"xmldom":12}],14:[function(require,module,exports){ var globalRequire=require;require=function(){};var exports=module.exports={Lexer:require("./lib/N3Lexer"),Parser:require("./lib/N3Parser"),Writer:require("./lib/N3Writer"),Store:require("./lib/N3Store"),StreamParser:require("./lib/N3StreamParser"),StreamWriter:require("./lib/N3StreamWriter"),Util:require("./lib/N3Util")};Object.keys(exports).forEach(function(e){Object.defineProperty(exports,e,{configurable:!0,enumerable:!0,get:function(){return delete exports[e],exports[e]=globalRequire("./lib/N3"+e)}})}); },{"./lib/N3Lexer":15,"./lib/N3Parser":16,"./lib/N3Store":17,"./lib/N3StreamParser":18,"./lib/N3StreamWriter":19,"./lib/N3Util":20,"./lib/N3Writer":21}],15:[function(require,module,exports){ function N3Lexer(e){if(!(this instanceof N3Lexer))return new N3Lexer(e);if(e&&e.lineMode){this._tripleQuotedString=this._number=this._boolean=/$0^/;var f=this;this._tokenize=this.tokenize,this.tokenize=function(e,u){this._tokenize(e,function(e,t){!e&&/^(?:IRI|prefixed|literal|langcode|type|\.|eof)$/.test(t.type)?u&&u(e,t):u&&u(e||f._syntaxError(t.type,u=null))})}}}var fromCharCode=String.fromCharCode,immediately="function"==typeof setImmediate?setImmediate:function(e){setTimeout(e,0)},escapeSequence=/\\u([a-fA-F0-9]{4})|\\U([a-fA-F0-9]{8})|\\[uU]|\\(.)/g,escapeReplacements={"\\":"\\","'":"'",'"':'"',n:"\n",r:"\r",t:"\t",f:"\f",b:"\b",_:"_","~":"~",".":".","-":"-","!":"!",$:"$","&":"&","(":"(",")":")","*":"*","+":"+",",":",",";":";","=":"=","/":"/","?":"?","#":"#","@":"@","%":"%"},illegalIriChars=/[\x00-\x20<>\\"\{\}\|\^\`]/;N3Lexer.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,f){function u(f){e(f._syntaxError(/^\S*/.exec(t)[0]))}for(var t=this._input;;){for(var i;i=this._newline.exec(t);)t=t.substr(i[0].length,t.length),this._line++;if((i=this._whitespace.exec(t))&&(t=t.substr(i[0].length,t.length)),this._endOfFile.test(t))return f&&e(t=null,{line:this._line,type:"eof",value:"",prefix:""}),this._input=t;var n,r=this._line,d="",s="",a="",c=t[0],o=null,l=0,x=!1;switch(c){case"^":if(1===t.length)break;if("^"!==t[1])return u(this);if(this._prevTokenType="^",t=t.substr(2),"<"!==t[0]){x=!0;break}case"<":if(o=this._unescapedIri.exec(t))d="IRI",s=o[1];else if(o=this._iri.exec(t)){if(n=this._unescape(o[1]),null===n||illegalIriChars.test(n))return u(this);d="IRI",s=n}break;case"_":((o=this._blank.exec(t))||f&&(o=this._blank.exec(t+" ")))&&(d="prefixed",a="_",s=o[1]);break;case'"':case"'":if(o=this._unescapedString.exec(t))d="literal",s=o[0];else if(o=this._singleQuotedString.exec(t)){if(n=this._unescape(o[0]),null===n)return u(this);d="literal",s=n.replace(/^'|'$/g,'"')}else if(o=this._tripleQuotedString.exec(t)){if(n=o[1]||o[2],this._line+=n.split(/\r\n|\r|\n/).length-1,n=this._unescape(n),null===n)return u(this);d="literal",s=n.replace(/^'|'$/g,'"')}break;case"@":"literal"===this._prevTokenType&&(o=this._langcode.exec(t))?(d="langcode",s=o[1]):(o=this._keyword.exec(t))&&(d=o[0]);break;case".":if(1===t.length?f:t[1]<"0"||t[1]>"9"){d=".",l=1;break}case"0":case"1":case"2":case"3":case"4":case"5":case"6":case"7":case"8":case"9":case"+":case"-":(o=this._number.exec(t))&&(d="literal",s='"'+o[0]+'"^^http://www.w3.org/2001/XMLSchema#'+(o[1]?"double":/^[+\-]?\d+$/.test(o[0])?"integer":"decimal"));break;case"B":case"b":case"p":case"P":case"G":case"g":(o=this._sparqlKeyword.exec(t))?d=o[0].toUpperCase():x=!0;break;case"f":case"t":(o=this._boolean.exec(t))?(d="literal",s='"'+o[0]+'"^^http://www.w3.org/2001/XMLSchema#boolean'):x=!0;break;case"a":(o=this._shortPredicates.exec(t))?(d="abbreviation",s="http://www.w3.org/1999/02/22-rdf-syntax-ns#type"):x=!0;break;case",":case";":case"[":case"]":case"(":case")":case"{":case"}":l=1,d=c;break;default:x=!0}if(x&&("@prefix"!==this._prevTokenType&&"PREFIX"!==this._prevTokenType||!(o=this._prefix.exec(t))?((o=this._prefixed.exec(t))||f&&(o=this._prefixed.exec(t+" ")))&&(d="prefixed",a=o[1]||"",s=this._unescape(o[2])):(d="prefix",s=o[1]||"")),"^"===this._prevTokenType&&(d="IRI"===d||"prefixed"===d?"type":""),!d)return f||!/^'''|^"""/.test(t)&&/\n|\r/.test(t)?u(this):this._input=t;e(null,{line:r,type:d,value:s,prefix:a}),this._prevTokenType=d,t=t.substr(l||o[0].length,t.length)}},_unescape:function(e){try{return e.replace(escapeSequence,function(e,f,u,t){var i;if(f){if(i=parseInt(f,16),isNaN(i))throw new Error;return fromCharCode(i)}if(u){if(i=parseInt(u,16),isNaN(i))throw new Error;return i<=65535?fromCharCode(i):fromCharCode(55296+(i-=65536)/1024,56320+(1023&i))}var n=escapeReplacements[t];if(!n)throw new Error;return n})}catch(e){return null}},_syntaxError:function(e){return this._input=null,new Error('Syntax error: unexpected "'+e+'" on line '+this._line+".")},tokenize:function(e,f){function u(e){null!==i._input&&(i._input+=e,i._tokenizeToEnd(f,!1))}function t(){null!==i._input&&i._tokenizeToEnd(f,!0)}var i=this;this._line=1,"string"==typeof e?(this._input=e,immediately(function(){i._tokenizeToEnd(f,!0)})):(this._input="",e&&"function"!=typeof e?("function"==typeof e.setEncoding&&e.setEncoding("utf8"),e.on("data",u),e.on("end",t)):(this.addChunk=u,this.end=t,f||(f=e)))}},module.exports=N3Lexer; },{}],16:[function(require,module,exports){ function N3Parser(e){if(!(this instanceof N3Parser))return new N3Parser(e);this._tripleStack=[],this._graph=null,e=e||{},this._setBase(e.documentIRI);var t="string"==typeof e.format&&e.format.match(/\w*$/)[0].toLowerCase(),r="turtle"===t,a="trig"===t,s=/triple/.test(t),i=/quad/.test(t),n=s||i;(this._supportsNamedGraphs=!r)||(this._readPredicateOrNamedGraph=this._readPredicate),this._supportsQuads=!(r||a||s),n&&(this._base="",this._resolveIRI=function(e){return this._error("Disallowed relative IRI",e),this._callback=noop,this._subject=null}),this._blankNodePrefix="string"!=typeof e.blankNodePrefix?"":"_:"+e.blankNodePrefix.replace(/^_:/,""),this._lexer=e.lexer||new N3Lexer({lineMode:n})}function noop(){}var N3Lexer=require("./N3Lexer"),RDF_PREFIX="http://www.w3.org/1999/02/22-rdf-syntax-ns#",RDF_NIL=RDF_PREFIX+"nil",RDF_FIRST=RDF_PREFIX+"first",RDF_REST=RDF_PREFIX+"rest",absoluteIRI=/^[a-z][a-z0-9+.-]*:/i,schemeAuthority=/^(?:([a-z][a-z0-9+.-]*:))?(?:\/\/[^\/]*)?/i,dotSegments=/(?:^|\/)\.\.?(?:$|[\/#?])/,blankNodePrefix=0,blankNodeCount=0;N3Parser._resetBlankNodeIds=function(){blankNodePrefix=blankNodeCount=0},N3Parser.prototype={_setBase:function(e){if(e){if(e.indexOf("#")>=0)throw new Error("Invalid base IRI "+e)}else e=null;(this._base=e)&&(this._basePath=e.replace(/[^\/?]*(?:\?.*)?$/,""),e=e.match(schemeAuthority),this._baseRoot=e[0],this._baseScheme=e[1])},_readInTopContext:function(e){switch(e.type){case"eof":return null!==this._graph?this._error("Unclosed graph",e):(delete this._prefixes._,this._callback(null,null,this._prefixes));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":null===this._base||absoluteIRI.test(e.value)?this._subject=e.value:this._subject=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"+blankNodeCount++,this._tripleStack.push({subject:this._subject,predicate:null,object:null,type:"blank"}),this._readBlankNodeHead;case"(":return this._tripleStack.push({subject:RDF_NIL,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":null===this._base||absoluteIRI.test(e.value)?this._predicate=e.value:this._predicate=this._resolveIRI(e);break;case"prefixed":if("_"===e.prefix)return this._error("Disallowed blank node as predicate",e);var r=this._prefixes[e.prefix];if(void 0===r)return this._error('Undefined prefix "'+e.prefix+':"',e);this._predicate=r+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":null===this._base||absoluteIRI.test(e.value)?this._object=e.value:this._object=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 r="_:b"+blankNodeCount++;return this._tripleStack.push({subject:this._subject,predicate:this._predicate,object:r,type:"blank"}),this._subject=r,this._readBlankNodeHead;case"(":return this._tripleStack.push({subject:this._subject,predicate:this._predicate,object:RDF_NIL,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._error("Expected graph but got "+e.type,e):(this._graph=this._subject,this._subject=null,this._readSubject)},_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?(this._predicate=t.predicate,this._object=t.object,this._getTripleEndReader()):null!==this._predicate?this._readPredicate:this._readPredicateOrNamedGraph},_readDataTypeOrLang:function(e){switch(e.type){case"type":var t;if(""===e.prefix)t=null===this._base||absoluteIRI.test(e.value)?e.value:this._resolveIRI(e);else{var r=this._prefixes[e.prefix];if(void 0===r)return this._error('Undefined prefix "'+e.prefix+':"',e);t=r+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,r=null,a=this._subject,s=this._tripleStack,i=s[s.length-1],n=this._readListItem;switch(e.type){case"IRI":t=null===this._base||absoluteIRI.test(e.value)?e.value:this._resolveIRI(e);break;case"prefixed":var l=this._prefixes[e.prefix];if(void 0===l)return this._error('Undefined prefix "'+e.prefix+':"',e);t=l+e.value;break;case"literal":t=e.value,n=this._readDataTypeOrLang;break;case"[":r="_:b"+blankNodeCount++,t="_:b"+blankNodeCount++,s.push({subject:r,predicate:RDF_FIRST,object:t,type:"blank"}),this._subject=t,n=this._readBlankNodeHead;break;case"(":r="_:b"+blankNodeCount++,s.push({subject:r,predicate:RDF_FIRST,object:RDF_NIL,type:"list"}),this._subject=null,n=this._readListItem;break;case")":if(s.pop(),0!==s.length&&"list"===s[s.length-1].type&&this._callback(null,{subject:i.subject,predicate:i.predicate,object:i.object,graph:this._graph||""}),this._subject=i.subject,null===i.predicate){if(n=this._readPredicate,i.subject===RDF_NIL)return n}else if(this._predicate=i.predicate,this._object=i.object,n=this._getTripleEndReader(),i.object===RDF_NIL)return n;r=RDF_NIL;break;default:return this._error('Expected list item instead of "'+e.type+'"',e)}return null===r&&(this._subject=r="_:b"+blankNodeCount++),null===a?i.object===RDF_NIL?i.object=r:i.subject=r:this._callback(null,{subject:a,predicate:RDF_REST,object:r,graph:this._graph||""}),null!==t&&this._callback(null,{subject:r,predicate:RDF_FIRST,object:t,graph:this._graph||""}),n},_readPunctuation:function(e){var t,r=this._subject,a=this._graph;switch(e.type){case"}":if(null===this._graph)return this._error("Unexpected graph closing",e);this._graph=null;case".":this._subject=null,t=this._readInTopContext;break;case";":t=this._readPredicate;break;case",":t=this._readObject;break;case"IRI":if(this._supportsQuads&&null===this._graph){a=null===this._base||absoluteIRI.test(e.value)?e.value:this._resolveIRI(e),r=this._subject,t=this._readQuadPunctuation;break}case"prefixed":if(this._supportsQuads&&null===this._graph){var s=this._prefixes[e.prefix];if(void 0===s)return this._error('Undefined prefix "'+e.prefix+':"',e);a=s+e.value,t=this._readQuadPunctuation;break}default:return this._error('Expected punctuation to follow "'+this._object+'"',e)}return null!==r&&this._callback(null,{subject:r,predicate:this._predicate,object:this._object,graph:a||""}),t},_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._error("Expected dot to follow quad",e):this._readInTopContext},_readPrefix:function(e){return"prefix"!==e.type?this._error("Expected prefix to follow @prefix",e):(this._prefix=e.value,this._readPrefixIRI)},_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||absoluteIRI.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||absoluteIRI.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._error("Invalid graph label",e):(this._subject="_:b"+blankNodeCount++,this._readGraph)},_readDeclarationPunctuation:function(e){return this._sparqlStyle?this._readInTopContext(e):"."!==e.type?this._error("Expected declaration to end with a dot",e):this._readInTopContext},_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(!dotSegments.test(e))return e;for(var t="",r=e.length,a=-1,s=-1,i=0,n="/";a=s&&(t=t.substr(0,i)),"/"!==n)return t+"/"+e.substr(a+1);i=a+1}}}n=e[++a]}return t+e.substring(i)},parse:function(e,t,r){this._readCallback=this._readInTopContext,this._prefixes=Object.create(null),this._prefixes._=this._blankNodePrefix||"_:b"+blankNodePrefix++ +"_","function"==typeof e&&(r=t,t=e,e=null),this._callback=t||noop,this._prefixCallback=r||noop;var a=this;this._lexer.tokenize(e,function(e,t){null!==e?(a._callback(e),a._callback=noop):void 0!==a._readCallback&&(a._readCallback=a._readCallback(t))}),e||(this.addChunk=this._lexer.addChunk,this.end=this._lexer.end)}},module.exports=N3Parser; },{"./N3Lexer":15}],17:[function(require,module,exports){ function N3Store(e,t){return this instanceof N3Store?(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),void(e&&this.addTriples(e))):new N3Store(e,t)}var expandPrefixedName=require("./N3Util").expandPrefixedName;N3Store.prototype={get size(){var e=this._size;if(null!==e)return e;var t,i,n=this._graphs;for(var r in n)for(var s in t=n[r].subjects)for(var d in i=t[s])e+=Object.keys(i[d]).length;return this._size=e},_addToIndex:function(e,t,i,n){var r=e[t]||(e[t]={}),s=r[i]||(r[i]={});s[n]=null},_removeFromIndex:function(e,t,i,n){var r,s=e[t],d=s[i];delete d[n];for(r in d)return;delete s[i];for(r in s)return;delete e[t]},_findInIndex:function(e,t,i,n,r,s,d,a){var o,c,u,h=[],f=Object.keys(this._entities);t&&((o=e,e={})[t]=o[t]);for(var _ in e){var l=f[_];if(c=e[_]){i&&((o=c,c={})[i]=o[i]);for(var x in c){var p=f[x];if(u=c[x])for(var b=(n?n in u?[n]:[]:Object.keys(u)),j=b.length-1;j>=0;j--){var I={subject:"",predicate:"",object:"",graph:a};I[r]=l,I[s]=p,I[d]=f[b[j]],h.push(I)}}}}return h},_countInIndex:function(e,t,i,n){var r,s,d,a=0;t&&((r=e,e={})[t]=r[t]);for(var o in e)if(s=e[o]){i&&((r=s,s={})[i]=r[i]);for(var c in s)(d=s[c])&&(n?n in d&&a++:a+=Object.keys(d).length)}return a},addTriple:function(e,t,i,n){t||(n=e.graph,i=e.object,t=e.predicate,e=e.subject),n=n||"";var r=this._graphs[n];r||(r=this._graphs[n]={subjects:{},predicates:{},objects:{}},Object.freeze(r));var s=this._entities;e=s[e]||(s[e]=++this._entityCount),t=s[t]||(s[t]=++this._entityCount),i=s[i]||(s[i]=++this._entityCount),this._addToIndex(r.subjects,e,t,i),this._addToIndex(r.predicates,t,i,e),this._addToIndex(r.objects,i,e,t),this._size=null},addTriples:function(e){for(var t=e.length-1;t>=0;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,i,n){t||(n=e.graph,i=e.object,t=e.predicate,e=e.subject),n=n||"";var r,s=this._entities,d=this._graphs;if((e=s[e])&&(t=s[t])&&(i=s[i])&&(r=d[n])){var a,o;if((a=r.subjects[e])&&(o=a[t])&&i in o){this._removeFromIndex(r.subjects,e,t,i),this._removeFromIndex(r.predicates,t,i,e),this._removeFromIndex(r.objects,i,e,t),null!==this._size&&this._size--;for(e in r.subjects)return;delete d[n]}}},removeTriples:function(e){for(var t=e.length-1;t>=0;t--)this.removeTriple(e[t])},find:function(e,t,i,n){var r=this._prefixes;return this.findByIRI(expandPrefixedName(e,r),expandPrefixedName(t,r),expandPrefixedName(i,r),expandPrefixedName(n,r))},findByIRI:function(e,t,i,n){n=n||"";var r=this._graphs[n],s=this._entities;return r?e&&!(e=s[e])?[]:t&&!(t=s[t])?[]:i&&!(i=s[i])?[]:e?i?this._findInIndex(r.objects,i,e,t,"object","subject","predicate",n):this._findInIndex(r.subjects,e,t,null,"subject","predicate","object",n):t?this._findInIndex(r.predicates,t,i,null,"predicate","object","subject",n):i?this._findInIndex(r.objects,i,null,null,"object","subject","predicate",n):this._findInIndex(r.subjects,null,null,null,"subject","predicate","object",n):[]},count:function(e,t,i,n){var r=this._prefixes;return this.countByIRI(expandPrefixedName(e,r),expandPrefixedName(t,r),expandPrefixedName(i,r),expandPrefixedName(n,r))},countByIRI:function(e,t,i,n){n=n||"";var r=this._graphs[n],s=this._entities;return r?e&&!(e=s[e])?0:t&&!(t=s[t])?0:i&&!(i=s[i])?0:e?i?this._countInIndex(r.objects,i,e,t):this._countInIndex(r.subjects,e,t,i):t?this._countInIndex(r.predicates,t,i,e):this._countInIndex(r.objects,i,e,t):0},createBlankNode:function(e){var t,i;if(e)for(t=e="_:"+e,i=1;this._entities[t];)t=e+i++;else do t="_:b"+this._blankNodeIndex++;while(this._entities[t]);return this._entities[t]=++this._entityCount,t}},module.exports=N3Store; },{"./N3Util":20}],18:[function(require,module,exports){ function N3StreamParser(r){if(!(this instanceof N3StreamParser))return new N3StreamParser(r);Transform.call(this,{decodeStrings:!0}),this._readableState.objectMode=!0;var e=this,t=new N3Parser(r);t.parse(function(r,t){t&&e.push(t)||r&&e.emit("error",r)},this.emit.bind(this,"prefix")),this._transform=function(r,e,s){t.addChunk(r),s()},this._flush=function(r){t.end(),r()}}var Transform=require("stream").Transform,util=require("util"),N3Parser=require("./N3Parser.js");util.inherits(N3StreamParser,Transform),module.exports=N3StreamParser; },{"./N3Parser.js":16,"stream":34,"util":38}],19:[function(require,module,exports){ function N3StreamWriter(r){if(!(this instanceof N3StreamWriter))return new N3StreamWriter(r);Transform.call(this,{encoding:"utf8"}),this._writableState.objectMode=!0;var t=this,e=new N3Writer({write:function(r,e,i){t.push(r),i&&i()},end:function(r){t.push(null),r&&r()}},r);this._transform=function(r,t,i){e.addTriple(r,i)},this._flush=function(r){e.end(r)}}var Transform=require("stream").Transform,util=require("util"),N3Writer=require("./N3Writer.js");util.inherits(N3StreamWriter,Transform),module.exports=N3StreamWriter; },{"./N3Writer.js":21,"stream":34,"util":38}],20:[function(require,module,exports){ function addN3Util(t,e){for(var r in N3Util)e?t.prototype[r]=applyToThis(N3Util[r]):t[r]=N3Util[r];return t}function applyToThis(t){return function(e){return t(this,e)}}var Xsd="http://www.w3.org/2001/XMLSchema#",XsdString=Xsd+"string",XsdInteger=Xsd+"integer",XsdDecimal=Xsd+"decimal",XsdBoolean=Xsd+"boolean",RdfLangString="http://www.w3.org/1999/02/22-rdf-syntax-ns#langString",N3Util={isIRI:function(t){if(!t)return t;var e=t[0];return'"'!==e&&"_"!==e},isLiteral:function(t){return t&&'"'===t[0]},isBlank:function(t){return t&&"_:"===t.substr(0,2)},getLiteralValue:function(t){var e=/^"([^]*)"/.exec(t);if(!e)throw new Error(t+" is not a literal");return e[1]},getLiteralType:function(t){var e=/^"[^]*"(?:\^\^([^"]+)|(@)[^@"]+)?$/.exec(t);if(!e)throw new Error(t+" is not a literal");return e[1]||(e[2]?RdfLangString:XsdString)},getLiteralLanguage:function(t){var e=/^"[^]*"(?:@([^@"]+)|\^\^[^"]+)?$/.exec(t);if(!e)throw new Error(t+" is not a literal");return e[1]?e[1].toLowerCase():""},isPrefixedName:function(t){return t&&/^[^:\/"']*:[^:\/"']+$/.test(t)},expandPrefixedName:function(t,e){var r,n,i,a=/(?:^|"\^\^)([^:\/#"'\^_]*):[^\/]*$/.exec(t);return a&&(r=a[1],n=e[r],i=a.index),void 0===n?t:0===i?n+t.substr(r.length+1):t.substr(0,i+3)+n+t.substr(i+r.length+4)},createIRI:function(t){return t&&'"'===t[0]?N3Util.getLiteralValue(t):t},createLiteral:function(t,e){if(!e)switch(typeof t){case"boolean":e=XsdBoolean;break;case"number":if(isFinite(t)){e=t%1===0?XsdInteger:XsdDecimal;break}default:return'"'+t+'"'}return'"'+t+(/^[a-z]+(-[a-z0-9]+)*$/i.test(e)?'"@'+e.toLowerCase():'"^^'+e)}};module.exports=addN3Util(addN3Util); },{}],21:[function(require,module,exports){ function N3Writer(e,t){if(!(this instanceof N3Writer))return new N3Writer(e,t);if(e&&"function"!=typeof e.write&&(t=e,e=null),t=t||{},e)this._outputStream=e,this._endStream=void 0===t.end||!!t.end;else{var r="";this._outputStream={write:function(e,t,i){r+=e,i&&i()},end:function(e){e&&e(null,r)}},this._endStream=!0}this._subject=null,/triple|quad/i.test(t.format)?this._writeTriple=this._writeTripleLine:(this._graph="",this._prefixIRIs=Object.create(null),t.prefixes&&this.addPrefixes(t.prefixes))}function characterReplacer(e){var t=escapeReplacements[e];return void 0===t&&(1===e.length?(t=e.charCodeAt(0).toString(16),t="\\u0000".substr(0,6-t.length)+t):(t=(1024*(e.charCodeAt(0)-55296)+e.charCodeAt(1)+9216).toString(16),t="\\U00000000".substr(0,10-t.length)+t)),t}var N3LiteralMatcher=/^"([^]*)"(?:\^\^(.+)|@([\-a-z]+))?$/i,RDF_PREFIX="http://www.w3.org/1999/02/22-rdf-syntax-ns#",RDF_TYPE=RDF_PREFIX+"type",escape=/["\\\t\n\r\b\f\u0000-\u0019\ud800-\udbff]/,escapeAll=/["\\\t\n\r\b\f\u0000-\u0019]|[\ud800-\udbff][\udc00-\udfff]/g,escapeReplacements={"\\":"\\\\",'"':'\\"',"\t":"\\t","\n":"\\n","\r":"\\r","\b":"\\b","\f":"\\f"};N3Writer.prototype={_write:function(e,t){this._outputStream.write(e,"utf8",t)},_writeTriple:function(e,t,r,i,n){try{this._graph!==i&&(this._write((null===this._subject?"":this._graph?"\n}\n":".\n")+(i?this._encodeIriOrBlankNode(i)+" {\n":"")),this._subject=null,this._graph="["!==i[0]?i:"]"),this._subject===e?this._predicate===t?this._write(", "+this._encodeObject(r),n):this._write(";\n "+this._encodePredicate(this._predicate=t)+" "+this._encodeObject(r),n):this._write((null===this._subject?"":".\n")+this._encodeSubject(this._subject=e)+" "+this._encodePredicate(this._predicate=t)+" "+this._encodeObject(r),n)}catch(e){n&&n(e)}},_writeTripleLine:function(e,t,r,i,n){delete this._prefixMatch;try{this._write(this._encodeIriOrBlankNode(e)+" "+this._encodeIriOrBlankNode(t)+" "+this._encodeObject(r)+(i?" "+this._encodeIriOrBlankNode(i)+".\n":".\n"),n)}catch(e){n&&n(e)}},_encodeIriOrBlankNode:function(e){var t=e[0];if("["===t||"("===t||"_"===t&&":"===e[1])return e;escape.test(e)&&(e=e.replace(escapeAll,characterReplacer));var r=this._prefixRegex.exec(e);return r?r[1]?this._prefixIRIs[r[1]]+r[2]:e:"<"+e+">"},_encodeLiteral:function(e,t,r){return escape.test(e)&&(e=e.replace(escapeAll,characterReplacer)),r?'"'+e+'"@'+r: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===RDF_TYPE?"a":this._encodeIriOrBlankNode(e)},_encodeObject:function(e){if('"'!==e[0])return this._encodeIriOrBlankNode(e);var t=N3LiteralMatcher.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,r,i,n){void 0===r?this._writeTriple(e.subject,e.predicate,e.object,e.graph||"",t):"string"!=typeof i?this._writeTriple(e,t,r,"",i):this._writeTriple(e,t,r,i,n)},addTriples:function(e){for(var t=0;t.\n"))}if(i){var s="",a="";for(var h in r)s+=s?"|"+h:h,a+=(a?"|":"")+r[h];s=s.replace(/[\]\/\(\)\*\+\?\.\\\$]/g,"\\$&"),this._prefixRegex=new RegExp("^(?:"+a+")[^/]*$|^("+s+")([a-zA-Z][\\-_a-zA-Z0-9]*)$")}this._write(i?"\n":"",t)},blank:function(e,t){var r,i,n=e;switch(void 0===e?n=[]:"string"==typeof e?n=[{predicate:e,object:t}]:"length"in e||(n=[e]),i=n.length){case 0:return"[]";case 1:if(r=n[0],"["!==r.object[0])return"[ "+this._encodePredicate(r.predicate)+" "+this._encodeObject(r.object)+" ]";default:for(var c="[",s=0;s1)for(var u=1;u0)if(t.ended&&!a){var d=new Error("stream.push() after EOF");e.emit("error",d)}else if(t.endEmitted&&a){var d=new Error("stream.unshift() after end event");e.emit("error",d)}else{var o;!t.decoder||a||n||(r=t.decoder.write(r),o=!t.objectMode&&0===r.length),a||(t.reading=!1),o||(t.flowing&&0===t.length&&!t.sync?(e.emit("data",r),e.read(0)):(t.length+=t.objectMode?1:r.length,a?t.buffer.unshift(r):t.buffer.push(r),t.needReadable&&emitReadable(e))),maybeReadMore(e,t)}else a||(t.reading=!1);return needMoreData(t)}function needMoreData(e){return!e.ended&&(e.needReadable||e.length=MAX_HWM?e=MAX_HWM:(e--,e|=e>>>1,e|=e>>>2,e|=e>>>4,e|=e>>>8,e|=e>>>16,e++),e}function howMuchToRead(e,t){return 0===t.length&&t.ended?0:t.objectMode?0===e?0:1:null===e||isNaN(e)?t.flowing&&t.buffer.length?t.buffer[0].length:t.length:e<=0?0:(e>t.highWaterMark&&(t.highWaterMark=computeNewHighWaterMark(e)),e>t.length?t.ended?t.length:(t.needReadable=!0,0):e)}function chunkInvalid(e,t){var r=null;return Buffer.isBuffer(t)||"string"==typeof t||null===t||void 0===t||e.objectMode||(r=new TypeError("Invalid non-string/buffer chunk")),r}function onEofChunk(e,t){if(!t.ended){if(t.decoder){var r=t.decoder.end();r&&r.length&&(t.buffer.push(r),t.length+=t.objectMode?1:r.length)}t.ended=!0,emitReadable(e)}}function emitReadable(e){var t=e._readableState;t.needReadable=!1,t.emittedReadable||(debug("emitReadable",t.flowing),t.emittedReadable=!0,t.sync?processNextTick(emitReadable_,e):emitReadable_(e))}function emitReadable_(e){debug("emit readable"),e.emit("readable"),flow(e)}function maybeReadMore(e,t){t.readingMore||(t.readingMore=!0,processNextTick(maybeReadMore_,e,t))}function maybeReadMore_(e,t){for(var r=t.length;!t.reading&&!t.flowing&&!t.ended&&t.length=a)r=i?n.join(""):1===n.length?n[0]:Buffer.concat(n,a),n.length=0;else if(e0)throw new Error("endReadable called on non-empty stream");t.endEmitted||(t.ended=!0,processNextTick(endReadableNT,t,e))}function endReadableNT(e,t){e.endEmitted||0!==e.length||(e.endEmitted=!0,t.readable=!1,t.emit("end"))}function forEach(e,t){for(var r=0,n=e.length;r0)&&(t.emittedReadable=!1),0===e&&t.needReadable&&(t.length>=t.highWaterMark||t.ended))return debug("read: emitReadable",t.length,t.ended),0===t.length&&t.ended?endReadable(this):emitReadable(this),null;if(e=howMuchToRead(e,t),0===e&&t.ended)return 0===t.length&&endReadable(this),null;var n=t.needReadable;debug("need readable",n),(0===t.length||t.length-e0?fromList(e,t):null,null===a&&(t.needReadable=!0,e=0),t.length-=e,0!==t.length||t.ended||(t.needReadable=!0),r!==e&&t.ended&&0===t.length&&endReadable(this),null!==a&&this.emit("data",a),a},Readable.prototype._read=function(e){this.emit("error",new Error("not implemented"))},Readable.prototype.pipe=function(e,t){function r(e){debug("onunpipe"),e===s&&a()}function n(){debug("onend"),e.end()}function a(){debug("cleanup"),e.removeListener("close",o),e.removeListener("finish",l),e.removeListener("drain",c),e.removeListener("error",d),e.removeListener("unpipe",r),s.removeListener("end",n),s.removeListener("end",a),s.removeListener("data",i),b=!0,!h.awaitDrain||e._writableState&&!e._writableState.needDrain||c()}function i(t){debug("ondata");var r=e.write(t);!1===r&&(1!==h.pipesCount||h.pipes[0]!==e||1!==s.listenerCount("data")||b||(debug("false write response, pause",s._readableState.awaitDrain),s._readableState.awaitDrain++),s.pause())}function d(t){debug("onerror",t),u(),e.removeListener("error",d),0===EElistenerCount(e,"error")&&e.emit("error",t)}function o(){e.removeListener("finish",l),u()}function l(){debug("onfinish"),e.removeListener("close",o),u()}function u(){debug("unpipe"),s.unpipe(e)}var s=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,debug("pipe count=%d opts=%j",h.pipesCount,t);var f=(!t||t.end!==!1)&&e!==process.stdout&&e!==process.stderr,p=f?n:a;h.endEmitted?processNextTick(p):s.once("end",p),e.on("unpipe",r);var c=pipeOnDrain(s);e.on("drain",c);var b=!1;return s.on("data",i),e._events&&e._events.error?isArray(e._events.error)?e._events.error.unshift(d):e._events.error=[d,e._events.error]:e.on("error",d),e.once("close",o),e.once("finish",l),e.emit("pipe",s),h.flowing||(debug("pipe resume"),s.resume()),e},Readable.prototype.unpipe=function(e){var t=this._readableState;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),this);if(!e){var r=t.pipes,n=t.pipesCount;t.pipes=null,t.pipesCount=0,t.flowing=!1;for(var a=0;a-1?setImmediate:processNextTick,Buffer=require("buffer").Buffer;Writable.WritableState=WritableState;var util=require("core-util-is");util.inherits=require("inherits");var internalUtil={deprecate:require("util-deprecate")},Stream;!function(){try{Stream=require("stream")}catch(e){}finally{Stream||(Stream=require("events").EventEmitter)}}();var Buffer=require("buffer").Buffer;util.inherits(Writable,Stream);var Duplex;WritableState.prototype.getBuffer=function(){for(var e=this.bufferedRequest,t=[];e;)t.push(e),e=e.next;return t},function(){try{Object.defineProperty(WritableState.prototype,"buffer",{get:internalUtil.deprecate(function(){return this.getBuffer()},"_writableState.buffer is deprecated. Use _writableState.getBuffer instead.")})}catch(e){}}();var Duplex;Writable.prototype.pipe=function(){this.emit("error",new Error("Cannot pipe. Not readable."))},Writable.prototype.write=function(e,t,r){var i=this._writableState,n=!1;return"function"==typeof t&&(r=t,t=null),Buffer.isBuffer(e)?t="buffer":t||(t=i.defaultEncoding),"function"!=typeof r&&(r=nop),i.ended?writeAfterEnd(this,r):validChunk(this,i,e,r)&&(i.pendingcb++,n=writeOrBuffer(this,i,e,t,r)),n},Writable.prototype.cork=function(){var e=this._writableState;e.corked++},Writable.prototype.uncork=function(){var e=this._writableState;e.corked&&(e.corked--,e.writing||e.corked||e.finished||e.bufferProcessing||!e.bufferedRequest||clearBuffer(this,e))},Writable.prototype.setDefaultEncoding=function(e){if("string"==typeof e&&(e=e.toLowerCase()),!(["hex","utf8","utf-8","ascii","binary","base64","ucs2","ucs-2","utf16le","utf-16le","raw"].indexOf((e+"").toLowerCase())>-1))throw new TypeError("Unknown encoding: "+e);this._writableState.defaultEncoding=e},Writable.prototype._write=function(e,t,r){r(new Error("not implemented"))},Writable.prototype._writev=null,Writable.prototype.end=function(e,t,r){var i=this._writableState;"function"==typeof e?(r=e,e=null,t=null):"function"==typeof t&&(r=t,t=null),null!==e&&void 0!==e&&this.write(e,t),i.corked&&(i.corked=1,this.uncork()),i.ending||i.finished||endWritable(this,i,r)}; }).call(this,require('_process')) },{"./_stream_duplex":25,"_process":23,"buffer":4,"core-util-is":5,"events":7,"inherits":9,"process-nextick-args":22,"stream":34,"util-deprecate":36}],30:[function(require,module,exports){ module.exports=require("./lib/_stream_passthrough.js"); },{"./lib/_stream_passthrough.js":26}],31:[function(require,module,exports){ var Stream=function(){try{return require("stream")}catch(r){}}();exports=module.exports=require("./lib/_stream_readable.js"),exports.Stream=Stream||exports,exports.Readable=exports,exports.Writable=require("./lib/_stream_writable.js"),exports.Duplex=require("./lib/_stream_duplex.js"),exports.Transform=require("./lib/_stream_transform.js"),exports.PassThrough=require("./lib/_stream_passthrough.js"); },{"./lib/_stream_duplex.js":25,"./lib/_stream_passthrough.js":26,"./lib/_stream_readable.js":27,"./lib/_stream_transform.js":28,"./lib/_stream_writable.js":29,"stream":34}],32:[function(require,module,exports){ module.exports=require("./lib/_stream_transform.js"); },{"./lib/_stream_transform.js":28}],33:[function(require,module,exports){ module.exports=require("./lib/_stream_writable.js"); },{"./lib/_stream_writable.js":29}],34:[function(require,module,exports){ function Stream(){EE.call(this)}module.exports=Stream;var EE=require("events").EventEmitter,inherits=require("inherits");inherits(Stream,EE),Stream.Readable=require("readable-stream/readable.js"),Stream.Writable=require("readable-stream/writable.js"),Stream.Duplex=require("readable-stream/duplex.js"),Stream.Transform=require("readable-stream/transform.js"),Stream.PassThrough=require("readable-stream/passthrough.js"),Stream.Stream=Stream,Stream.prototype.pipe=function(e,r){function t(r){e.writable&&!1===e.write(r)&&m.pause&&m.pause()}function n(){m.readable&&m.resume&&m.resume()}function a(){u||(u=!0,e.end())}function o(){u||(u=!0,"function"==typeof e.destroy&&e.destroy())}function i(e){if(s(),0===EE.listenerCount(this,"error"))throw e}function s(){m.removeListener("data",t),e.removeListener("drain",n),m.removeListener("end",a),m.removeListener("close",o),m.removeListener("error",i),e.removeListener("error",i),m.removeListener("end",s),m.removeListener("close",s),e.removeListener("close",s)}var m=this;m.on("data",t),e.on("drain",n),e._isStdio||r&&r.end===!1||(m.on("end",a),m.on("close",o));var u=!1;return m.on("error",i),e.on("error",i),m.on("end",s),m.on("close",s),e.on("close",s),e.emit("pipe",m),e}; },{"events":7,"inherits":9,"readable-stream/duplex.js":24,"readable-stream/passthrough.js":30,"readable-stream/readable.js":31,"readable-stream/transform.js":32,"readable-stream/writable.js":33}],35:[function(require,module,exports){ function assertEncoding(e){if(e&&!isBufferEncoding(e))throw new Error("Unknown encoding: "+e)}function passThroughWrite(e){return e.toString(this.encoding)}function utf16DetectIncompleteChar(e){this.charReceived=e.length%2,this.charLength=this.charReceived?2:0}function base64DetectIncompleteChar(e){this.charReceived=e.length%3,this.charLength=this.charReceived?3:0}var Buffer=require("buffer").Buffer,isBufferEncoding=Buffer.isEncoding||function(e){switch(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}},StringDecoder=exports.StringDecoder=function(e){switch(this.encoding=(e||"utf8").toLowerCase().replace(/[-_]/,""),assertEncoding(e),this.encoding){case"utf8":this.surrogateSize=3;break;case"ucs2":case"utf16le":this.surrogateSize=2,this.detectIncompleteChar=utf16DetectIncompleteChar;break;case"base64":this.surrogateSize=3,this.detectIncompleteChar=base64DetectIncompleteChar;break;default:return void(this.write=passThroughWrite)}this.charBuffer=new Buffer(6),this.charReceived=0,this.charLength=0};StringDecoder.prototype.write=function(e){for(var t="";this.charLength;){var r=e.length>=this.charLength-this.charReceived?this.charLength-this.charReceived:e.length;if(e.copy(this.charBuffer,this.charReceived,0,r),this.charReceived+=r,this.charReceived=55296&&h<=56319)){if(this.charReceived=this.charLength=0,0===e.length)return t;break}this.charLength+=this.surrogateSize,t=""}this.detectIncompleteChar(e);var i=e.length;this.charLength&&(e.copy(this.charBuffer,0,e.length-this.charReceived,i),i-=this.charReceived),t+=e.toString(this.encoding,0,i);var i=t.length-1,h=t.charCodeAt(i);if(h>=55296&&h<=56319){var c=this.surrogateSize;return this.charLength+=c,this.charReceived+=c,this.charBuffer.copy(this.charBuffer,c,0,c),e.copy(this.charBuffer,0,0,c),t.substring(0,i)}return t},StringDecoder.prototype.detectIncompleteChar=function(e){for(var t=e.length>=3?3:e.length;t>0;t--){var r=e[e.length-t];if(1==t&&r>>5==6){this.charLength=2;break}if(t<=2&&r>>4==14){this.charLength=3;break}if(t<=3&&r>>3==30){this.charLength=4;break}}this.charReceived=t},StringDecoder.prototype.end=function(e){var t="";if(e&&e.length&&(t=this.write(e)),this.charReceived){var r=this.charReceived,h=this.charBuffer,i=this.encoding;t+=h.slice(0,r).toString(i)}return t}; },{"buffer":4}],36:[function(require,module,exports){ (function (global){ function deprecate(r,e){function o(){if(!t){if(config("throwDeprecation"))throw new Error(e);config("traceDeprecation")?console.trace(e):console.warn(e),t=!0}return r.apply(this,arguments)}if(config("noDeprecation"))return r;var t=!1;return o}function config(r){try{if(!global.localStorage)return!1}catch(r){return!1}var e=global.localStorage[r];return null!=e&&"true"===String(e).toLowerCase()}module.exports=deprecate; }).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {}) },{}],37:[function(require,module,exports){ module.exports=function(o){return o&&"object"==typeof o&&"function"==typeof o.copy&&"function"==typeof o.fill&&"function"==typeof o.readUInt8}; },{}],38:[function(require,module,exports){ (function (process,global){ function inspect(e,r){var t={seen:[],stylize:stylizeNoColor};return arguments.length>=3&&(t.depth=arguments[2]),arguments.length>=4&&(t.colors=arguments[3]),isBoolean(r)?t.showHidden=r:r&&exports._extend(t,r),isUndefined(t.showHidden)&&(t.showHidden=!1),isUndefined(t.depth)&&(t.depth=2),isUndefined(t.colors)&&(t.colors=!1),isUndefined(t.customInspect)&&(t.customInspect=!0),t.colors&&(t.stylize=stylizeWithColor),formatValue(t,e,t.depth)}function stylizeWithColor(e,r){var t=inspect.styles[r];return t?"["+inspect.colors[t][0]+"m"+e+"["+inspect.colors[t][1]+"m":e}function stylizeNoColor(e,r){return e}function arrayToHash(e){var r={};return e.forEach(function(e,t){r[e]=!0}),r}function formatValue(e,r,t){if(e.customInspect&&r&&isFunction(r.inspect)&&r.inspect!==exports.inspect&&(!r.constructor||r.constructor.prototype!==r)){var n=r.inspect(t,e);return isString(n)||(n=formatValue(e,n,t)),n}var i=formatPrimitive(e,r);if(i)return i;var o=Object.keys(r),s=arrayToHash(o);if(e.showHidden&&(o=Object.getOwnPropertyNames(r)),isError(r)&&(o.indexOf("message")>=0||o.indexOf("description")>=0))return formatError(r);if(0===o.length){if(isFunction(r)){var u=r.name?": "+r.name:"";return e.stylize("[Function"+u+"]","special")}if(isRegExp(r))return e.stylize(RegExp.prototype.toString.call(r),"regexp");if(isDate(r))return e.stylize(Date.prototype.toString.call(r),"date");if(isError(r))return formatError(r)}var c="",a=!1,l=["{","}"];if(isArray(r)&&(a=!0,l=["[","]"]),isFunction(r)){var p=r.name?": "+r.name:"";c=" [Function"+p+"]"}if(isRegExp(r)&&(c=" "+RegExp.prototype.toString.call(r)),isDate(r)&&(c=" "+Date.prototype.toUTCString.call(r)),isError(r)&&(c=" "+formatError(r)),0===o.length&&(!a||0==r.length))return l[0]+c+l[1];if(t<0)return isRegExp(r)?e.stylize(RegExp.prototype.toString.call(r),"regexp"):e.stylize("[Object]","special");e.seen.push(r);var f;return f=a?formatArray(e,r,t,s,o):o.map(function(n){return formatProperty(e,r,t,s,n,a)}),e.seen.pop(),reduceToSingleString(f,c,l)}function formatPrimitive(e,r){if(isUndefined(r))return e.stylize("undefined","undefined");if(isString(r)){var t="'"+JSON.stringify(r).replace(/^"|"$/g,"").replace(/'/g,"\\'").replace(/\\"/g,'"')+"'";return e.stylize(t,"string")}return isNumber(r)?e.stylize(""+r,"number"):isBoolean(r)?e.stylize(""+r,"boolean"):isNull(r)?e.stylize("null","null"):void 0}function formatError(e){return"["+Error.prototype.toString.call(e)+"]"}function formatArray(e,r,t,n,i){for(var o=[],s=0,u=r.length;s-1&&(u=o?u.split("\n").map(function(e){return" "+e}).join("\n").substr(2):"\n"+u.split("\n").map(function(e){return" "+e}).join("\n"))):u=e.stylize("[Circular]","special")),isUndefined(s)){if(o&&i.match(/^\d+$/))return u;s=JSON.stringify(""+i),s.match(/^"([a-zA-Z_][a-zA-Z_0-9]*)"$/)?(s=s.substr(1,s.length-2),s=e.stylize(s,"name")):(s=s.replace(/'/g,"\\'").replace(/\\"/g,'"').replace(/(^"|"$)/g,"'"),s=e.stylize(s,"string"))}return s+": "+u}function reduceToSingleString(e,r,t){var n=0,i=e.reduce(function(e,r){return n++,r.indexOf("\n")>=0&&n++,e+r.replace(/\u001b\[\d\d?m/g,"").length+1},0);return i>60?t[0]+(""===r?"":r+"\n ")+" "+e.join(",\n ")+" "+t[1]:t[0]+r+" "+e.join(", ")+" "+t[1]}function isArray(e){return Array.isArray(e)}function isBoolean(e){return"boolean"==typeof e}function isNull(e){return null===e}function isNullOrUndefined(e){return null==e}function isNumber(e){return"number"==typeof e}function isString(e){return"string"==typeof e}function isSymbol(e){return"symbol"==typeof e}function isUndefined(e){return void 0===e}function isRegExp(e){return isObject(e)&&"[object RegExp]"===objectToString(e)}function isObject(e){return"object"==typeof e&&null!==e}function isDate(e){return isObject(e)&&"[object Date]"===objectToString(e)}function isError(e){return isObject(e)&&("[object Error]"===objectToString(e)||e instanceof Error)}function isFunction(e){return"function"==typeof e}function isPrimitive(e){return null===e||"boolean"==typeof e||"number"==typeof e||"string"==typeof e||"symbol"==typeof e||"undefined"==typeof e}function objectToString(e){return Object.prototype.toString.call(e)}function pad(e){return e<10?"0"+e.toString(10):e.toString(10)}function timestamp(){var e=new Date,r=[pad(e.getHours()),pad(e.getMinutes()),pad(e.getSeconds())].join(":");return[e.getDate(),months[e.getMonth()],r].join(" ")}function hasOwnProperty(e,r){return Object.prototype.hasOwnProperty.call(e,r)}var formatRegExp=/%[sdj%]/g;exports.format=function(e){if(!isString(e)){for(var r=[],t=0;t=i)return e;switch(e){case"%s":return String(n[t++]);case"%d":return Number(n[t++]);case"%j":try{return JSON.stringify(n[t++])}catch(e){return"[Circular]"}default:return e}}),s=n[t];t=e+n||e?new java.lang.String(t,e,n)+"":t}function appendElement(t,e){t.currentElement?t.currentElement.appendChild(e):t.document.appendChild(e)}if(DOMParser.prototype.parseFromString=function(t,e){var n=this.options,r=new XMLReader,o=n.domBuilder||new DOMHandler,i=n.errorHandler,a=n.locator,c=n.xmlns||{},l={lt:"<",gt:">",amp:"&",quot:'"',apos:"'"};return a&&o.setDocumentLocator(a),r.errorHandler=buildErrorHandler(i,o,a),r.domBuilder=n.domBuilder||o,/\/x?html?$/.test(e)&&(l.nbsp=" ",l.copy="©",c[""]="http://www.w3.org/1999/xhtml"),c.xml=c.xml||"http://www.w3.org/XML/1998/namespace",t?r.parse(t,c,l):r.errorHandler.error("invalid document source"),o.document},DOMHandler.prototype={startDocument:function(){this.document=(new DOMImplementation).createDocument(null,null,null),this.locator&&(this.document.documentURI=this.locator.systemId)},startElement:function(t,e,n,r){var o=this.document,i=o.createElementNS(t,n||e),a=r.length;appendElement(this,i),this.currentElement=i,this.locator&&position(this.locator,i);for(var c=0;c=0))throw DOMException(NOT_FOUND_ERR,new Error);for(var i=t.length-1;o"==e&&">"||"&"==e&&"&"||'"'==e&&"""||"&#"+e.charCodeAt()+";"}function _visitNode(e,t){if(t(e))return!0;if(e=e.firstChild)do if(_visitNode(e,t))return!0;while(e=e.nextSibling)}function Document(){}function _onAddAttribute(e,t,n){e&&e._inc++;var o=n.namespaceURI;"http://www.w3.org/2000/xmlns/"==o&&(t._nsMap[n.prefix?n.localName:""]=n.value)}function _onRemoveAttribute(e,t,n,o){e&&e._inc++;var i=n.namespaceURI;"http://www.w3.org/2000/xmlns/"==i&&delete t._nsMap[n.prefix?n.localName:""]}function _onUpdateChild(e,t,n){if(e&&e._inc){e._inc++;var o=t.childNodes;if(n)o[o.length++]=n;else{for(var i=t.firstChild,r=0;i;)o[r++]=i,i=i.nextSibling;o.length=r}}}function _removeChild(e,t){var n=t.previousSibling,o=t.nextSibling;return n?n.nextSibling=o:e.firstChild=o,o?o.previousSibling=n:e.lastChild=n,_onUpdateChild(e.ownerDocument,e),t}function _insertBefore(e,t,n){var o=t.parentNode;if(o&&o.removeChild(t),t.nodeType===DOCUMENT_FRAGMENT_NODE){var i=t.firstChild;if(null==i)return t;var r=t.lastChild}else i=r=t;var a=n?n.previousSibling:e.lastChild;i.previousSibling=a,r.nextSibling=n,a?a.nextSibling=i:e.firstChild=i,null==n?e.lastChild=r:n.previousSibling=r;do i.parentNode=e;while(i!==r&&(i=i.nextSibling));return _onUpdateChild(e.ownerDocument||e,e),t.nodeType==DOCUMENT_FRAGMENT_NODE&&(t.firstChild=t.lastChild=null),t}function _appendSingleChild(e,t){var n=t.parentNode;if(n){var o=e.lastChild;n.removeChild(t);var o=e.lastChild}var o=e.lastChild;return t.parentNode=e,t.previousSibling=o,t.nextSibling=null,o?o.nextSibling=t:e.firstChild=t,e.lastChild=t,_onUpdateChild(e.ownerDocument,e,t),t}function Element(){this._nsMap={}}function Attr(){}function CharacterData(){}function Text(){}function Comment(){}function CDATASection(){}function DocumentType(){}function Notation(){}function Entity(){}function EntityReference(){}function DocumentFragment(){}function ProcessingInstruction(){}function XMLSerializer(){}function serializeToString(e,t,n,o){switch(e.nodeType){case ELEMENT_NODE:var i=e.attributes,r=i.length,a=e.firstChild,s=e.tagName;o=htmlns===e.namespaceURI||o,t.push("<",s),n&&t.sort.apply(i,n);for(var u=0;u"),o&&/^script$/i.test(s))a&&t.push(a.data);else for(;a;)serializeToString(a,t,n,o),a=a.nextSibling;t.push("")}else t.push("/>");return;case DOCUMENT_NODE:case DOCUMENT_FRAGMENT_NODE:for(var a=e.firstChild;a;)serializeToString(a,t,n,o),a=a.nextSibling;return;case ATTRIBUTE_NODE:return t.push(" ",e.name,'="',e.value.replace(/[<&"]/g,_xmlEncoder),'"');case TEXT_NODE:return t.push(e.data.replace(/[<&]/g,_xmlEncoder));case CDATA_SECTION_NODE:return t.push("");case COMMENT_NODE:return t.push("");case DOCUMENT_TYPE_NODE:var d=e.publicId,c=e.systemId;if(t.push("');else if(c&&"."!=c)t.push(' SYSTEM "',c,'">');else{var N=e.internalSubset;N&&t.push(" [",N,"]"),t.push(">")}return;case PROCESSING_INSTRUCTION_NODE:return t.push("");case ENTITY_REFERENCE_NODE:return t.push("&",e.nodeName,";");default:t.push("??",e.nodeName)}}function importNode(e,t,n){var o;switch(t.nodeType){case ELEMENT_NODE:o=t.cloneNode(!1),o.ownerDocument=e;case DOCUMENT_FRAGMENT_NODE:break;case ATTRIBUTE_NODE:n=!0}if(o||(o=t.cloneNode(!1)),o.ownerDocument=e,o.parentNode=null,n)for(var i=t.firstChild;i;)o.appendChild(importNode(e,i,n)),i=i.nextSibling;return o}function cloneNode(e,t,n){var o=new t.constructor;for(var i in t){var r=t[i];"object"!=typeof r&&r!=o[i]&&(o[i]=r)}switch(t.childNodes&&(o.childNodes=new NodeList),o.ownerDocument=e,o.nodeType){case ELEMENT_NODE:var a=t.attributes,s=o.attributes=new NamedNodeMap,u=a.length;s._ownerElement=o;for(var d=0;d0},lookupPrefix:function(e){for(var t=this;t;){var n=t._nsMap;if(n)for(var o in n)if(n[o]==e)return o;t=2==t.nodeType?t.ownerDocument:t.parentNode}return null},lookupNamespaceURI:function(e){for(var t=this;t;){var n=t._nsMap;if(n&&e in n)return n[e];t=2==t.nodeType?t.ownerDocument:t.parentNode}return null},isDefaultNamespace:function(e){var t=this.lookupPrefix(e);return null==t}},copy(NodeType,Node),copy(NodeType,Node.prototype),Document.prototype={nodeName:"#document",nodeType:DOCUMENT_NODE,doctype:null,documentElement:null,_inc:1,insertBefore:function(e,t){if(e.nodeType==DOCUMENT_FRAGMENT_NODE){for(var n=e.firstChild;n;){var o=n.nextSibling;this.insertBefore(n,t),n=o}return e}return null==this.documentElement&&1==e.nodeType&&(this.documentElement=e),_insertBefore(this,e,t),e.ownerDocument=this,e},removeChild:function(e){return this.documentElement==e&&(this.documentElement=null),_removeChild(this,e)},importNode:function(e,t){return importNode(this,e,t)},getElementById:function(e){var t=null;return _visitNode(this.documentElement,function(n){if(1==n.nodeType&&n.getAttribute("id")==e)return t=n,!0}),t},createElement:function(e){var t=new Element;t.ownerDocument=this,t.nodeName=e,t.tagName=e,t.childNodes=new NodeList;var n=t.attributes=new NamedNodeMap;return n._ownerElement=t,t},createDocumentFragment:function(){var e=new DocumentFragment;return e.ownerDocument=this,e.childNodes=new NodeList,e},createTextNode:function(e){var t=new Text;return t.ownerDocument=this,t.appendData(e),t},createComment:function(e){var t=new Comment;return t.ownerDocument=this,t.appendData(e),t},createCDATASection:function(e){var t=new CDATASection;return t.ownerDocument=this,t.appendData(e),t},createProcessingInstruction:function(e,t){var n=new ProcessingInstruction;return n.ownerDocument=this,n.tagName=n.target=e,n.nodeValue=n.data=t,n},createAttribute:function(e){var t=new Attr;return t.ownerDocument=this,t.name=e,t.nodeName=e,t.localName=e,t.specified=!0,t},createEntityReference:function(e){var t=new EntityReference;return t.ownerDocument=this,t.nodeName=e,t},createElementNS:function(e,t){var n=new Element,o=t.split(":"),i=n.attributes=new NamedNodeMap;return n.childNodes=new NodeList,n.ownerDocument=this,n.nodeName=t,n.tagName=t,n.namespaceURI=e,2==o.length?(n.prefix=o[0],n.localName=o[1]):n.localName=t,i._ownerElement=n,n},createAttributeNS:function(e,t){var n=new Attr,o=t.split(":");return n.ownerDocument=this,n.nodeName=t,n.name=t,n.namespaceURI=e,n.specified=!0,2==o.length?(n.prefix=o[0],n.localName=o[1]):n.localName=t,n}},_extends(Document,Node),Element.prototype={nodeType:ELEMENT_NODE,hasAttribute:function(e){return null!=this.getAttributeNode(e)},getAttribute:function(e){var t=this.getAttributeNode(e);return t&&t.value||""},getAttributeNode:function(e){return this.attributes.getNamedItem(e)},setAttribute:function(e,t){var n=this.ownerDocument.createAttribute(e);n.value=n.nodeValue=""+t,this.setAttributeNode(n)},removeAttribute:function(e){var t=this.getAttributeNode(e);t&&this.removeAttributeNode(t)},appendChild:function(e){return e.nodeType===DOCUMENT_FRAGMENT_NODE?this.insertBefore(e,null):_appendSingleChild(this,e)},setAttributeNode:function(e){return this.attributes.setNamedItem(e)},setAttributeNodeNS:function(e){return this.attributes.setNamedItemNS(e)},removeAttributeNode:function(e){return this.attributes.removeNamedItem(e.nodeName)},removeAttributeNS:function(e,t){var n=this.getAttributeNodeNS(e,t);n&&this.removeAttributeNode(n)},hasAttributeNS:function(e,t){return null!=this.getAttributeNodeNS(e,t)},getAttributeNS:function(e,t){var n=this.getAttributeNodeNS(e,t);return n&&n.value||""},setAttributeNS:function(e,t,n){var o=this.ownerDocument.createAttributeNS(e,t);o.value=o.nodeValue=""+n,this.setAttributeNode(o)},getAttributeNodeNS:function(e,t){return this.attributes.getNamedItemNS(e,t)},getElementsByTagName:function(e){return new LiveNodeList(this,function(t){var n=[];return _visitNode(t,function(o){o===t||o.nodeType!=ELEMENT_NODE||"*"!==e&&o.tagName!=e||n.push(o)}),n})},getElementsByTagNameNS:function(e,t){return new LiveNodeList(this,function(n){var o=[];return _visitNode(n,function(i){i===n||i.nodeType!==ELEMENT_NODE||"*"!==e&&i.namespaceURI!==e||"*"!==t&&i.localName!=t||o.push(i)}),o})}},Document.prototype.getElementsByTagName=Element.prototype.getElementsByTagName,Document.prototype.getElementsByTagNameNS=Element.prototype.getElementsByTagNameNS,_extends(Element,Node),Attr.prototype.nodeType=ATTRIBUTE_NODE,_extends(Attr,Node),CharacterData.prototype={data:"",substringData:function(e,t){return this.data.substring(e,e+t)},appendData:function(e){e=this.data+e,this.nodeValue=this.data=e,this.length=e.length},insertData:function(e,t){this.replaceData(e,0,t)},appendChild:function(e){throw new Error(ExceptionMessage[3])},deleteData:function(e,t){this.replaceData(e,t,"")},replaceData:function(e,t,n){var o=this.data.substring(0,e),i=this.data.substring(e+t);n=o+n+i,this.nodeValue=this.data=n,this.length=n.length}},_extends(CharacterData,Node),Text.prototype={nodeName:"#text",nodeType:TEXT_NODE,splitText:function(e){var t=this.data,n=t.substring(e);t=t.substring(0,e),this.data=this.nodeValue=t,this.length=t.length;var o=this.ownerDocument.createTextNode(n);return this.parentNode&&this.parentNode.insertBefore(o,this.nextSibling),o}},_extends(Text,CharacterData),Comment.prototype={nodeName:"#comment",nodeType:COMMENT_NODE},_extends(Comment,CharacterData),CDATASection.prototype={nodeName:"#cdata-section",nodeType:CDATA_SECTION_NODE},_extends(CDATASection,CharacterData),DocumentType.prototype.nodeType=DOCUMENT_TYPE_NODE,_extends(DocumentType,Node),Notation.prototype.nodeType=NOTATION_NODE,_extends(Notation,Node),Entity.prototype.nodeType=ENTITY_NODE,_extends(Entity,Node),EntityReference.prototype.nodeType=ENTITY_REFERENCE_NODE,_extends(EntityReference,Node),DocumentFragment.prototype.nodeName="#document-fragment",DocumentFragment.prototype.nodeType=DOCUMENT_FRAGMENT_NODE,_extends(DocumentFragment,Node),ProcessingInstruction.prototype.nodeType=PROCESSING_INSTRUCTION_NODE,_extends(ProcessingInstruction,Node),XMLSerializer.prototype.serializeToString=function(e,t){return e.toString(t)},Node.prototype.toString=function(e){var t=[];return serializeToString(this,t,e),t.join("")};try{Object.defineProperty&&(Object.defineProperty(LiveNodeList.prototype,"length",{get:function(){return _updateLiveList(this),this.$$length}}),Object.defineProperty(Node.prototype,"textContent",{get:function(){return getTextContent(this)},set:function(e){switch(this.nodeType){case 1:case 11:for(;this.firstChild;)this.removeChild(this.firstChild);(e||String(e))&&this.appendChild(this.ownerDocument.createTextNode(e));break;default:this.data=e,this.value=value,this.nodeValue=e}}}),__set__=function(e,t,n){e["$$"+t]=n})}catch(e){}"function"==typeof require&&(exports.DOMImplementation=DOMImplementation,exports.XMLSerializer=XMLSerializer); },{}],41:[function(require,module,exports){ function XMLReader(){}function parse(e,t,r,a,n){function s(e){if(e>65535){e-=65536;var t=55296+(e>>10),r=56320+(1023&e);return String.fromCharCode(t,r)}return String.fromCharCode(e)}function i(e){var t=e.slice(1,-1);return t in r?r[t]:"#"===t.charAt(0)?s(parseInt(t.substr(1).replace("x","0x"))):(n.error("entity not found:"+e),e)}function c(t){if(t>S){var r=e.substring(S,t).replace(/&#?\w+;/g,i);m&&u(S),a.characters(r,0,t-S),S=t}}function u(t,r){for(;t>=l&&(r=f.exec(e));)o=r.index,l=o+r[0].length,m.lineNumber++;m.columnNumber=t-o+1}for(var o=0,l=0,f=/.+(?:\r\n?|\n)|.*$/g,m=a.locator,p=[{currentNSMap:t}],d={},S=0;;){try{var _=e.indexOf("<",S);if(_<0){if(!e.substr(S).match(/^\s*$/)){var h=a.document,g=h.createTextNode(e.substr(S));h.appendChild(g),a.currentElement=g}return}switch(_>S&&c(_),e.charAt(_+1)){case"/":var w=e.indexOf(">",_+3),b=e.substring(_+2,w),v=p.pop(),x=v.localNSMap;if(v.tagName!=b&&n.fatalError("end tag name: "+b+" is not match the current start tagName:"+v.tagName),a.endElement(v.uri,v.localName,b),x)for(var T in x)a.endPrefixMapping(T);w++;break;case"?":m&&u(_),w=parseInstruction(e,_,a);break;case"!":m&&u(_),w=parseDCC(e,_,a,n);break;default:m&&u(_);var N=new ElementAttributes,w=parseElementStartPart(e,_,N,i,n),E=N.length;if(m){if(E)for(var A=0;AS?S=w:c(Math.max(_,S)+1)}}function copyLocator(e,t){return t.lineNumber=e.lineNumber,t.columnNumber=e.columnNumber,t}function parseElementStartPart(e,t,r,a,n){for(var s,i,c=++t,u=S_TAG;;){var o=e.charAt(c);switch(o){case"=":if(u===S_ATTR)s=e.slice(t,c),u=S_EQ;else{if(u!==S_ATTR_S)throw new Error("attribute equal must after attrName");u=S_EQ}break;case"'":case'"':if(u===S_EQ){if(t=c+1,c=e.indexOf(o,t),!(c>0))throw new Error("attribute value no end '"+o+"' match");i=e.slice(t,c).replace(/&#?\w+;/g,a),r.add(s,i,t-1),u=S_E}else{if(u!=S_V)throw new Error('attribute value must after "="');i=e.slice(t,c).replace(/&#?\w+;/g,a),r.add(s,i,t),n.warning('attribute "'+s+'" missed start quot('+o+")!!"),t=c+1,u=S_E}break;case"/":switch(u){case S_TAG:r.setTagName(e.slice(t,c));case S_E:case S_S:case S_C:u=S_C,r.closed=!0;case S_V:case S_ATTR:case S_ATTR_S:break;default:throw new Error("attribute invalid close char('/')")}break;case"":n.error("unexpected end of input");case">":switch(u){case S_TAG:r.setTagName(e.slice(t,c));case S_E:case S_S:case S_C:break;case S_V:case S_ATTR:i=e.slice(t,c),"/"===i.slice(-1)&&(r.closed=!0,i=i.slice(0,-1));case S_ATTR_S:u===S_ATTR_S&&(i=s),u==S_V?(n.warning('attribute "'+i+'" missed quot(")!!'),r.add(s,i.replace(/&#?\w+;/g,a),t)):(n.warning('attribute "'+i+'" missed value!! "'+i+'" instead!!'),r.add(i,i,t));break;case S_EQ:throw new Error("attribute value missed!!")}return c;case"€":o=" ";default:if(o<=" ")switch(u){case S_TAG:r.setTagName(e.slice(t,c)),u=S_S;break;case S_ATTR:s=e.slice(t,c),u=S_ATTR_S;break;case S_V:var i=e.slice(t,c).replace(/&#?\w+;/g,a);n.warning('attribute "'+i+'" missed quot(")!!'),r.add(s,i,t);case S_E:u=S_S}else switch(u){case S_ATTR_S:n.warning('attribute "'+s+'" missed value!! "'+s+'" instead!!'),r.add(s,s,t),t=c,u=S_ATTR;break;case S_E:n.warning('attribute space is required"'+s+'"!!');case S_S:u=S_ATTR,t=c;break;case S_EQ:u=S_V,t=c;break;case S_C:throw new Error("elements closed character '/' and '>' must be connected to")}}c++}}function appendElement(e,t,r){for(var a=e.tagName,n=null,s=r[r.length-1].currentNSMap,i=e.length;i--;){var c=e[i],u=c.qName,o=c.value,l=u.indexOf(":");if(l>0)var f=c.prefix=u.slice(0,l),m=u.slice(l+1),p="xmlns"===f&&m;else m=u,f=null,p="xmlns"===u&&"";c.localName=m,p!==!1&&(null==n&&(n={},_copy(s,s={})),s[p]=n[p]=o,c.uri="http://www.w3.org/2000/xmlns/",t.startPrefixMapping(p,o))}for(var i=e.length;i--;){c=e[i];var f=c.prefix;f&&("xml"===f&&(c.uri="http://www.w3.org/XML/1998/namespace"),"xmlns"!==f&&(c.uri=s[f]))}var l=a.indexOf(":");l>0?(f=e.prefix=a.slice(0,l),m=e.localName=a.slice(l+1)):(f=null,m=e.localName=a);var d=e.uri=s[f||""];if(t.startElement(d,m,a,e),e.closed){if(t.endElement(d,m,a),n)for(f in n)t.endPrefixMapping(f)}else e.currentNSMap=s,e.localNSMap=n,r.push(e)}function parseHtmlSpecialContent(e,t,r,a,n){if(/^(?:script|textarea)$/i.test(r)){var s=e.indexOf("",t),i=e.substring(t+1,s);if(/[&<]/.test(i))return/^script$/i.test(r)?(n.characters(i,0,i.length),s):(i=i.replace(/&#?\w+;/g,a),n.characters(i,0,i.length),s)}return t+1}function fixSelfClosed(e,t,r,a){var n=a[r];return null==n&&(n=a[r]=e.lastIndexOf("")),n",t+4);return s>t?(r.comment(e,t+4,s-t-4),s+3):(a.error("Unclosed comment"),-1)}return-1;default:if("CDATA["==e.substr(t+3,6)){var s=e.indexOf("]]>",t+9);return r.startCDATA(),r.characters(e,t+9,s-t-9),r.endCDATA(),s+3}var i=split(e,t),c=i.length;if(c>1&&/!doctype/i.test(i[0][0])){var u=i[1][0],o=c>3&&/^public$/i.test(i[2][0])&&i[3][0],l=c>4&&i[4][0],f=i[c-1];return r.startDTD(u,o&&o.replace(/^(['"])(.*?)\1$/,"$2"),l&&l.replace(/^(['"])(.*?)\1$/,"$2")),r.endDTD(),f.index+f[0].length}}return-1}function parseInstruction(e,t,r){var a=e.indexOf("?>",t);if(a){var n=e.substring(t,a).match(/^<\?(\S*)\s*([\s\S]*?)\s*$/);if(n){n[0].length;return r.processingInstruction(n[1],n[2]),a+2}return-1}return-1}function ElementAttributes(e){}function _set_proto_(e,t){return e.__proto__=t,e}function split(e,t){var r,a=[],n=/'[^']+'|"[^"]+"|[^\s<>\/=]+=?|(\/?\s*>|<)/g;for(n.lastIndex=t,n.exec(e);r=n.exec(e);)if(a.push(r),r[1])return a}var nameStartChar=/[A-Z_a-z\xC0-\xD6\xD8-\xF6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD]/,nameChar=new RegExp("[\\-\\.0-9"+nameStartChar.source.slice(1,-1)+"·̀-ͯ\\u203F-⁀]"),tagNamePattern=new RegExp("^"+nameStartChar.source+nameChar.source+"*(?::"+nameStartChar.source+nameChar.source+"*)?$"),S_TAG=0,S_ATTR=1,S_ATTR_S=2,S_EQ=3,S_V=4,S_E=5,S_S=6,S_C=7;XMLReader.prototype={parse:function(e,t,r){var a=this.domBuilder;a.startDocument(),_copy(t,t={}),parse(e,t,r,a,this.errorHandler),a.endDocument()}},ElementAttributes.prototype={setTagName:function(e){if(!tagNamePattern.test(e))throw new Error("invalid tagName:"+e);this.tagName=e},add:function(e,t,r){if(!tagNamePattern.test(e))throw new Error("invalid attribute:"+e);this[this.length++]={qName:e,value:t,offset:r}},length:0,getLocalName:function(e){return this[e].localName},getOffset:function(e){return this[e].offset},getQName:function(e){return this[e].qName},getURI:function(e){return this[e].uri},getValue:function(e){return this[e].value}},_set_proto_({},_set_proto_.prototype)instanceof _set_proto_||(_set_proto_=function(e,t){function r(){}r.prototype=t,r=new r;for(t in e)r[t]=e[t];return r}),"function"==typeof require&&(exports.XMLReader=XMLReader); },{}],42:[function(require,module,exports){ "use strict";function _classCallCheck(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function _possibleConstructorReturn(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}function _inherits(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}var _createClass=function(){function e(e,t){for(var r=0;re.classOrder?1:this.ide.id?1:0}},{key:"copy",value:function(e){var r=new t;return e.copyTo(this,r),r}},{key:"toCanonical",value:function(){return"_:"+this.value}},{key:"toString",value:function(){return t.NTAnonymousNodePrefix+this.id}}]),t}(Node);BlankNode.nextId=0,BlankNode.termType="BlankNode",BlankNode.NTAnonymousNodePrefix="_:n",BlankNode.prototype.classOrder=ClassOrder.BlankNode,BlankNode.prototype.isBlank=1,BlankNode.prototype.isVar=1,module.exports=BlankNode; },{"./class-order":43,"./node":58}],43:[function(require,module,exports){ "use strict";var ClassOrder={Literal:1,Collection:3,Formula:4,NamedNode:5,BlankNode:6,Variable:7};module.exports=ClassOrder; },{}],44:[function(require,module,exports){ "use strict";function _classCallCheck(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function _possibleConstructorReturn(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}function _inherits(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}var _createClass=function(){function e(e,t){for(var n=0;n0&&e.forEach(function(e){n.elements.push(Node.fromValue(e))}),n}return _inherits(t,e),_createClass(t,[{key:"append",value:function(e){return this.elements.push(e)}},{key:"close",value:function(){return this.closed=!0,this.closed}},{key:"shift",value:function(){return this.elements.shift()}},{key:"substitute",value:function(e){var n=this.elements.map(function(t){t.substitute(e)});return new t(n)}},{key:"toNT",value:function(){return BlankNode.NTAnonymousNodePrefix+this.id}},{key:"toString",value:function(){return"("+this.elements.join(" ")+")"}},{key:"unshift",value:function(e){return this.elements.unshift(e)}}]),t}(Node);Collection.termType="collection",Collection.prototype.classOrder=ClassOrder.Collection,Collection.prototype.compareTerm=BlankNode.prototype.compareTerm,Collection.prototype.isVar=0,module.exports=Collection; },{"./blank-node":42,"./class-order":43,"./node":58}],45:[function(require,module,exports){ "use strict";function convertToJson(n,o){var r,t=N3.Parser(),e=N3.Writer({format:"N-Quads"});asyncLib.waterfall([function(o){t.parse(n,o)},function(n,o,r){null!==n&&e.addTriple(n),"function"==typeof r&&e.end(r)},function(n,o){try{jsonld.fromRDF(n,{format:"application/nquads"},o)}catch(n){o(n)}},function(n,t){r=JSON.stringify(n),o(null,r)}],function(n,t){o(n,r)})}function convertToNQuads(n,o){var r,t=N3.Parser(),e=N3.Writer({format:"N-Quads"});asyncLib.waterfall([function(o){t.parse(n,o)},function(n,o,r){null!==n&&e.addTriple(n),"function"==typeof r&&e.end(r)},function(n,t){r=n,o(null,r)}],function(n,t){o(n,r)})}module.exports.convertToJson=convertToJson,module.exports.convertToNQuads=convertToNQuads;var asyncLib=require("async"),jsonld=require("jsonld"),N3=require("n3"); },{"async":1,"jsonld":13,"n3":14}],46:[function(require,module,exports){ "use strict";function blankNode(e){return new BlankNode(e)}function collection(e){return new Collection(e)}function defaultGraph(){return new DefaultGraph}function fetcher(e,r,t){return new Fetcher(e,r,t)}function graph(){return new IndexedFormula}function lit(e,r,t){return new Literal(""+e,r,t)}function literal(e,r){return"string"==typeof r?r.indexOf(":")===-1?new Literal(e,r):new Literal(e,null,namedNode(r)):new Literal(e,null,r)}function namedNode(e){return new NamedNode(e)}function quad(e,r,t,n){return n=n||new DefaultGraph,new Statement(e,r,t,n)}function st(e,r,t,n){return new Statement(e,r,t,n)}function triple(e,r,t){return quad(e,r,t)}function variable(e){return new Variable(e)}var BlankNode=require("./blank-node"),Collection=require("./collection"),DefaultGraph=require("./default-graph"),Fetcher=require("./fetcher"),IndexedFormula=require("./indexed-formula"),Literal=require("./literal"),NamedNode=require("./named-node"),Statement=require("./statement"),Variable=require("./variable");module.exports.blankNode=blankNode,module.exports.defaultGraph=defaultGraph,module.exports.graph=graph,module.exports.literal=literal,module.exports.namedNode=namedNode,module.exports.quad=quad,module.exports.triple=triple,module.exports.variable=variable,module.exports.collection=collection,module.exports.fetcher=fetcher,module.exports.lit=lit,module.exports.st=st; },{"./blank-node":42,"./collection":44,"./default-graph":47,"./fetcher":49,"./indexed-formula":51,"./literal":53,"./named-node":56,"./statement":68,"./variable":73}],47:[function(require,module,exports){ "use strict";function _classCallCheck(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function _possibleConstructorReturn(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}function _inherits(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}var _createClass=function(){function e(e,t){for(var r=0;r0&&n.add(e.resource,s.dc("title"),n.literal(o[0].textContent),e.resource);for(var d=this.dom.getElementsByTagName("link"),l=d.length-1;l>=0;l--)r=d[l].getAttribute("rel"),a=!1,r||(r=d[l].getAttribute("rev"),a=!0),r&&i.linkData(e,r,d[l].getAttribute("href"),e.resource,a);for(var c=this.dom.getElementsByTagName("script"),u=0;u]+\?>/))return i.addStatus(e.req,"Has an XML declaration. We'll assume it's XHTML as the content-type was text/html.\n"),void i.switchHandler("XHTMLHandler",e,t);if(r.match(/.*/))return i.addStatus(e.req,"Has XHTML DOCTYPE. Switching to XHTMLHandler.\n"),void i.switchHandler("XHTMLHandler",e,t);if(r.match(/[^(/))return i.addStatus(e.req,"Has default namespace for XHTML, so switching to XHTMLHandler.\n"),void i.switchHandler("XHTMLHandler",e,t);var a=new RegExp("([\\s\\S]+?)","im").exec(r);if(a){var n=i.store;return n.add(e.resource,s.dc("title"),n.literal(a[1]),e.resource),n.add(e.resource,s.rdf("type"),s.link("WebPage"),i.appNode),void t()}i.addStatus(e.req,"non-XML HTML document, not parsed for data."),i.doneFetch(e)}}},e.HTMLHandler.toString=function(){return"HTMLHandler"},e.HTMLHandler.register=function(e){e.mediatypes["text/html"]={q:.3}},e.HTMLHandler.pattern=new RegExp("text/html"),e.TextHandler=function(){this.handlerFactory=function(e){e.handle=function(t){var r=e.responseText;return r.match(/\s*<\?xml\s+version\s*=[^<>]+\?>/)?(i.addStatus(e.req,"Warning: "+e.resource+" has an XML declaration. We'll assume it's XML but its content-type wasn't XML.\n"),void i.switchHandler("XMLHandler",e,t)):r.slice(0,500).match(/xmlns:/)?(i.addStatus(e.req,"May have an XML namespace. We'll assume it's XML but its content-type wasn't XML.\n"),void i.switchHandler("XMLHandler",e,t)):(i.addStatus(e.req,"Plain text document, no known RDF semantics."),void i.doneFetch(e))}}},e.TextHandler.toString=function(){return"TextHandler"},e.TextHandler.register=function(e){e.mediatypes["text/plain"]={q:.1}},e.TextHandler.pattern=new RegExp("text/plain"),e.N3Handler=function(){this.handlerFactory=function(e){e.handle=function(t){var r=N3Parser(n,n,e.original.uri,e.original.uri,null,null,"",null);try{r.loadBuf(e.responseText)}catch(t){var a="Error trying to parse "+e.resource+" as Notation3:\n"+t+":\n"+t.stack;return void i.failFetch(e,a)}i.addStatus(e.req,"N3 parsed: "+r.statementCount+" triples in "+r.lines+" lines."),i.store.add(e.original,s.rdf("type"),s.link("RDFDocument"),i.appNode),i.doneFetch(e)}}},e.N3Handler.toString=function(){return"N3Handler"},e.N3Handler.register=function(e){e.mediatypes["text/n3"]={q:"1.0"},e.mediatypes["application/x-turtle"]={q:1},e.mediatypes["text/turtle"]={q:1}},e.N3Handler.pattern=new RegExp("(application|text)/(x-)?(rdf\\+)?(n3|turtle)"),Util.callbackify(this,["request","recv","headers","load","fail","refresh","retract","done"]),this.addHandler=function(e){i.handlers.push(e),e.register(i)},this.switchHandler=function(t,r,a,n){for(var s=null,o=0;o failed: "+t,e);return delete this.fetchCallbacks[e.original.uri],this.fireCallbacks("fail",[e.original.uri,t]),e.abort(),e},this.linkData=function(e,t,r,a,i){if(r){var o,d=n.sym(Uri.join(r,e.original.uri));if("alternate"===t||"seeAlso"===t||"meta"===t||"describedby"===t){if(d.uri===e.original.uri)return;o=s.rdfs("seeAlso")}else o="type"===t?n.sym("http://www.w3.org/1999/02/22-rdf-syntax-ns#type"):n.sym(Uri.join(t,"http://www.iana.org/assignments/link-relations/"));i?n.add(d,o,e.original,a):n.add(e.original,o,d,a)}},this.parseLinkHeader=function(e,t){var r;try{r=e.getResponseHeader("link")}catch(e){}if(r)for(var a=/<[^>]*>\s*(\s*;\s*[^\(\)<>@,;:"\/\[\]\?={} \t]+=(([^\(\)<>@,;:"\/\[\]\?={} \t]+)|("[^"]*")))*(,|$)/g,i=/[^\(\)<>@,;:"\/\[\]\?={} \t]+=(([^\(\)<>@,;:"\/\[\]\?={} \t]+)|("[^"]*"))/g,n=r.match(a),s=0;s"),d=o[0].substring(1),l=o[1],c=l.match(i),u=0;u=200&&s.status<300;r.noMeta||"undefined"==typeof tabulator||a.saveResponseMetadata(s,a.store),e?i(s):n(s.status+" "+s.statusText)}},s.open(e,t,!0),r.contentType&&s.setRequestHeader("Content-type",r.contentType),s.send(r.data?r.data:void 0)})},this.webCopy=function(e,t,r){var a=this;return e=e.uri||e,new Promise(function(i,n){a.webOperation("GET",e).then(function(e){a.webOperation("PUT",t,{data:e.responseText,contentType:r}).then(function(e){i(e)}).catch(function(e){n(e)})}).catch(function(e){n(e)})})},this.lookUpThing=function(e,t,r,a,i){var s,o=n.uris(e),d=!0,l="",c={};if(r===!1||r===!0?(s=r,r={force:s}):(void 0===r&&(r={}),s=!!r.force),"undefined"!=typeof o)for(var u=0;u0||i&&i(d,l)})};f(h)}return o.length},this.load=function(e,t){var r=this;if(e instanceof Array){var a=e.map(function(e){return r.load(e)});return Promise.all(a)}return e=e.uri||e,new Promise(function(a,i){r.nowOrWhenFetched(e,t,function(e,t,r){e?a(r):i(t)})})},this.nowOrWhenFetched=function(e,t,r,a){e=e.uri||e,"function"==typeof t?(a={},r=t):"undefined"==typeof t||(a=t instanceof NamedNode?{referingTerm:t}:t),this.requestURI(e,t,a||{},r)},this.get=this.nowOrWhenFetched,this.getHeader=function(e,t){for(var r=this.store,a=r.each(void 0,s.link("requestedURI"),e.uri),i=0;i Cross-site Proxy to <"+o+">"),t.aborted)return;var d=m.store,l=t.req;t.options.noMeta||d.add(l,s.http("redirectedTo"),d.sym(o),l),t.abort(),t.aborted=!0,m.addStatus(l,"redirected to new request"),m.requested[t.resource.uri]="redirected",m.redirectedTo[t.resource.uri]=o,m.fetchCallbacks[t.resource.uri]&&(m.fetchCallbacks[o]||(m.fetchCallbacks[o]=[]),m.fetchCallbacks[o]===m.fetchCallbacks[o].concat(m.fetchCallbacks[t.resource.uri]),delete m.fetchCallbacks[t.resource.uri]);var c=m.requestURI(o,t.resource,t.options,t.userCallback);if(c&&(c.proxyUsed=!0,c.original=t.original,console.log("Proxying but original still "+c.original)),c&&c.req)return void(t.options.noMeta||d.add(t.req,d.sym("http://www.w3.org/2007/ont/link#redirectedRequest"),c.req,m.appNode))}t.status=999}}},b=function(e){return function(){var r=function(){if(!e.handleResponseDone){e.handleResponseDone=!0;var r=null,i=e.req;m.fireCallbacks("recv",d);var o=m.store;if(m.saveResponseMetadata(e,o),m.fireCallbacks("headers",[{uri:t,headers:e.headers}]),0===e.status){if(console.log("Masked error - status 0 for "+e.resource.uri),v(e))return;return void(e.status=900)}if(e.status>=400){if(404===e.status&&(o.fetcher.nonexistant[e.resource.uri]=!0),e.responseText.length>10){var l=o.bnode();o.add(l,s.http("content"),o.literal(e.responseText),l),e.statusText&&o.add(l,s.http("statusText"),o.literal(e.statusText),l)}return void m.failFetch(e,"HTTP error for "+e.resource+": "+e.status+" "+e.statusText)}var c,u=e.headers["content-location"],h=function(e){var t=i;if(u){var r=o.any(t,s.link("requestedURI"));r!==u&&o.add(o.sym(u),s.rdf("type"),e,m.appNode)}for(;;){var a=o.any(t,s.link("requestedURI"));if(a&&a.value&&o.add(o.sym(a.value),s.rdf("type"),e,m.appNode),t=o.any(void 0,o.sym("http://www.w3.org/2007/ont/link#redirectedRequest"),t),!t)break;var n=o.any(t,o.sym("http://www.w3.org/2007/ont/link#response"));if(!n)break;var d=o.any(n,o.sym("http://www.w3.org/2007/ont/http#status"));if(!d)break;if("301"!==d&&"302"!==d)break}},p={rdf:"application/rdf+xml",owl:"application/rdf+xml",n3:"text/n3",ttl:"text/turtle",nt:"text/n3",acl:"text/n3",html:"text/html",xml:"text/xml"};if(200===e.status){h(s.link("Document"));var f=e.headers["content-type"];a.forceContentType&&(e.headers["content-type"]=a.forceContentType),(!f||f.indexOf("application/octet-stream")>=0)&&(c=p[e.resource.uri.split(".").pop()],c&&(e.headers["content-type"]=c)),f&&(0!==f.indexOf("image/")&&0!==f.indexOf("application/pdf")||h(o.sym("http://purl.org/dc/terms/Image"))),a.clearPreviousData&&o.removeDocument(e.resource)}if("file"!==Uri.protocol(e.resource.uri)&&"chrome"!==Uri.protocol(e.resource.uri)||(a.forceContentType?e.headers["content-type"]=a.forceContentType:(c=p[e.resource.uri.split(".").pop()],c?e.headers["content-type"]=c:e.headers["content-type"]="text/xml")),u){var g=Uri.join(e.resource.uri,u);if(!n&&g!==e.resource.uri&&m.requested[g]&&"done"===m.requested[g])return m.doneFetch(e),void e.abort();m.requested[g]=!0}for(var y=0;y Cross-site Proxy to <"+i+">"),e.aborted)return;var u=m.store,h=e.req;u.add(h,s.http("redirectedTo"),u.sym(i),h);var p=e.req=u.bnode();u.add(h,s.http("redirectedRequest"),p,e.req);var f=new Date,g="["+f.getHours()+":"+f.getMinutes()+":"+f.getSeconds()+"] ";u.add(p,s.rdfs("label"),u.literal(g+" Request for "+i),this.appNode),u.add(p,s.link("status"),u.collection(),this.appNode),u.add(p,s.link("requestedURI"),u.literal(i),this.appNode);var y=u.bnode();u.add(h,s.link("response"),y),e.abort(),e.aborted=!0,e.redirected=!0,m.addStatus(h,"redirected XHR"),m.fetchCallbacks[e.resource.uri]&&(m.fetchCallbacks[i]||(m.fetchCallbacks[i]=[]),m.fetchCallbacks[i]===m.fetchCallbacks[i].concat(m.fetchCallbacks[e.resource.uri]),delete m.fetchCallbacks[e.resource.uri]),m.fireCallbacks("redirected",d),m.requested[e.resource.uri]="redirected";var w=m.requestURI(i,e.resource,e.options||{},e.userCallback);if(w&&w.req)return void u.add(e.req,u.sym("http://www.w3.org/2007/ont/link#redirectedRequest"),w.req,m.appNode)}}m.failFetch(e,"HTTP Blocked. (ReadyState 0) Cross-site violation for <"+t+">");break;case 3:break;case 4:if(r(),e.handle&&void 0!==e.responseText){if("redirected"===m.requested[e.resource.uri])break;m.fireCallbacks("load",d),e.handle(function(){m.doneFetch(e)})}else e.redirected?m.addStatus(e.req,"Aborted and redirected to new request."):m.addStatus(e.req,"Fetch over. No data handled. Aborted = "+e.aborted)}}},q=t;"undefined"!=typeof tabulator&&tabulator.preferences.get("offlineModeUsingLocalhost")&&"http://"===q.slice(0,7)&&"localhost/"!==q.slice(7,17)&&(q="http://localhost/"+q.slice(7),log.warn("Localhost kludge for offline use: actually getting <"+q+">"));var T="https:"===q.slice(0,6);void 0!==a.withCredentials&&(T=a.withCredentials);var H=this.proxyIfNecessary(q);p.onerror=w(p),p.onreadystatechange=b(p),p.timeout=m.timeout,p.withCredentials=T,p.actualProxyURI=H,p.req=f,p.options=a,p.options=a,p.resource=u,p.requestedURI=q,p.ontimeout=function(){m.failFetch(p,"requestTimeout")};try{p.open("GET",H,this.async)}catch(e){return this.failFetch(p,"XHR open for GET failed for <"+q+">:\n\t"+e)}if(n&&p.setRequestHeader("Cache-control","no-cache"),"undefined"!=typeof tabulator&&tabulator.isExtension&&p.channel&&("http"===Uri.protocol(p.resource.uri)||"https"===Uri.protocol(p.resource.uri)))try{p.channel.notificationCallbacks={getInterface:function(e){return e.equals(Components.interfaces.nsIChannelEventSink)?{onChannelRedirect:function(e,t,i){if(!p.aborted){var n=m.store,o=t.URI.spec,l=p.req;if(!p.options.noMeta){m.addStatus(p.req,"Redirected: "+p.status+" to <"+o+">"),n.add(l,s.http("redirectedTo"),n.sym(o),p.req);var c=p.req=n.bnode();n.add(l,s.http("redirectedRequest"),c,this.appNode);var u=new Date,h="["+u.getHours()+":"+u.getMinutes()+":"+u.getSeconds()+"] ";n.add(c,s.rdfs("label"),n.literal(h+" Request for "+o),this.appNode),n.add(c,s.link("status"),n.collection(),this.appNode),n.add(c,s.link("requestedURI"),n.literal(o),this.appNode);var f=n.bnode();n.add(l,s.link("response"),f),n.add(f,s.http("status"),n.literal(p.status),f),p.statusText&&n.add(f,s.http("statusText"),n.literal(p.statusText),f)}if(p.status-0!==303&&(n.HTTPRedirects[p.resource.uri]=o),p.status-0===301&&r){var g=Uri.docpart(r.uri),y="Warning: "+p.resource+" has moved to <"+o+">.";r&&(y+=" Link in <"+g+" >should be changed",n.add(g,n.sym("http://www.w3.org/2007/ont/link#warning"),y,m.appNode))}p.abort(),p.aborted=!0,m.fetchCallbacks[p.resource.uri]&&(m.fetchCallbacks[o]||(m.fetchCallbacks[o]=[]),m.fetchCallbacks[o]===m.fetchCallbacks[o].concat(m.fetchCallbacks[p.resource.uri]),delete m.fetchCallbacks[p.resource.uri]),m.addStatus(l,"redirected"),m.fireCallbacks("redirected",d),m.requested[p.resource.uri]="redirected",m.redirectedTo[p.resource.uri]=o;var v=o.indexOf("#");v>=0&&(p.options.noMeta||n.add(p.resource,n.sym("http://www.w3.org/2007/ont/link#warning"),"Warning: "+p.resource+" HTTP redirects to"+o+' which should not contain a "#" sign'),o=o.slice(0,v));var w=m.requestURI(o,p.resource,p.options,p.userCallback);w&&w.req&&!a.noMeta&&n.add(p.req,n.sym("http://www.w3.org/2007/ont/link#redirectedRequest"),w.req,m.appNode)}},asyncOnChannelRedirect:function(e,t,a,i){if(!p.aborted){var n=m.store,o=t.URI.spec,d=p.req;m.addStatus(p.req,"Redirected: "+p.status+" to <"+o+">"),n.add(d,s.http("redirectedTo"),n.sym(o),p.req);var l=p.req=n.bnode();n.add(d,s.http("redirectedRequest"),l,p.req);var c=new Date,u="["+c.getHours()+":"+c.getMinutes()+":"+c.getSeconds()+"] ";n.add(l,s.rdfs("label"),n.literal(u+" Request for "+o),this.appNode),n.add(l,s.link("status"),n.collection(),this.appNode),n.add(l,s.link("requestedURI"),n.literal(o),this.appNode);var h=n.bnode();if(n.add(d,s.link("response"),h),n.add(h,s.http("status"),n.literal(p.status),h),p.statusText&&n.add(h,s.http("statusText"),n.literal(p.statusText),h),p.status-0!==303&&(n.HTTPRedirects[p.resource.uri]=o),p.status-0===301&&r){var f=Uri.docpart(r.uri),g="Warning: "+p.resource+" has moved to <"+o+">.";r&&(g+=" Link in <"+f+" >should be changed",n.add(f,n.sym("http://www.w3.org/2007/ont/link#warning"),g,m.appNode))}p.abort(),p.aborted=!0;var y=o.indexOf("#");if(y>=0){var v="Warning: "+p.resource+" HTTP redirects to"+o+' which do not normally contain a "#" sign';n.add(p.resource,n.sym("http://www.w3.org/2007/ont/link#warning"),v),o=o.slice(0,y)}m.requested[p.resource.uri]="redirected",m.redirectedTo[p.resource.uri]=o;var w=m.requestURI(o,p.resource,p.options,p.userCallback);w&&(w.original=p.original,w.req&&n.add(p.req,n.sym("http://www.w3.org/2007/ont/link#redirectedRequest"),w.req,m.appNode))}}}:Components.results.NS_NOINTERFACE}}}catch(e){return m.failFetch(p,"@@ Couldn't set callback for redirects: "+e)}try{var k="";for(var x in this.mediatypes){""!==k&&(k+=", "),k+=x;for(var M in this.mediatypes[x])k+=";"+M+"="+this.mediatypes[x][M]}p.setRequestHeader("Accept",k),this.addStatus(p.req,"Accept: "+k)}catch(e){throw new Error("Can't set Accept header: "+e)}try{p.send(null)}catch(e){return this.failFetch(p,"XHR send failed:"+e)}return setTimeout(function(){4!==p.readyState&&m.isPending(p.resource.uri)&&m.failFetch(p,"requestTimeout")},this.timeout),this.addStatus(p.req,"HTTP Request sent."),p}},this.objectRefresh=function(e){var t=n.uris(e);if("undefined"!=typeof t)for(var r=0;r1?n("Patch ambiguous. No patch done."):(o=c[0],void s(n))})}else s(n)}},{key:"declareExistential",value:function(e){return this._existentialVariables||(this._existentialVariables=[]),this._existentialVariables.push(e),e}},{key:"initPropertyActions",value:function(e){this.propertyActions[""]=[handleRDFType],ArrayIndexOf(e,"sameAs")>=0&&(this.propertyActions[""]=[function(e,t,n,r,i){return e.equate(t,r),!0}]),ArrayIndexOf(e,"InverseFunctionalProperty")>=0&&(this.classActions["<"+owl_ns+"InverseFunctionalProperty>"]=[function(e,t,n,r,i){return e.newPropertyAction(t,handle_IFP)}]),ArrayIndexOf(e,"FunctionalProperty")>=0&&(this.classActions["<"+owl_ns+"FunctionalProperty>"]=[function(e,t,n,r,i){return e.newPropertyAction(t,handle_FP)}])}},{key:"add",value:function(e,n,r,i){var a;if(1===arguments.length){if(e instanceof Array)for(a=0;a";return!!this.subjectIndex[t]||!!this.objectIndex[t]||!!this.predicateIndex[t]}},{key:"newExistential",value:function(e){if(!e)return this.bnode();var t=this.sym(e);return this.declareExistential(t)}},{key:"newPropertyAction",value:function(e,t){var n=e.hashString();this.propertyActions[n]||(this.propertyActions[n]=[]),this.propertyActions[n].push(t);for(var r=this.statementsMatching(void 0,e,void 0),i=!1,a=0;a1&&(s=s.slice(0,1)),s=s||[];var f,d,v=1e10;for(d=0;d=0?XSD.float:(""+e).indexOf(".")>=0?XSD.decimal:XSD.integer,new t(""+e,null,r)}},{key:"fromValue",value:function(e){if("undefined"==typeof e||null===e)return e;if(e&&e.termType)return e;switch("undefined"==typeof e?"undefined":_typeof(e)){case"object":if(e instanceof Date)return t.fromDate(e);case"boolean":return t.fromBoolean(e);case"number":return t.fromNumber(e);case"string":return new t(e)}throw new Error("Can't make literal from "+e+" of type "+("undefined"==typeof e?"undefined":_typeof(e)))}}]),t}(Node);Literal.termType="Literal",Literal.prototype.classOrder=ClassOrder.Literal,Literal.prototype.datatype=XSD.string,Literal.prototype.lang="",Literal.prototype.isVar=0,module.exports=Literal; },{"./class-order":43,"./named-node":56,"./node":58,"./xsd":74}],54:[function(require,module,exports){ "use strict";module.exports={debug:function(n){},warn:function(n){},info:function(n){},error:function(n){},success:function(n){},msg:function(n){}}; },{}],55:[function(require,module,exports){ "use strict";var _typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol?"symbol":typeof t},Uri=require("./uri"),ArrayIndexOf=require("./util").ArrayIndexOf,N3Parser=function(){function t(t){return encodeURI(t)}function e(t,e,r,s,n,o,h,a){return new i(t,e,r,s,n,o,h,a)}function i(t,e,i,r,s,n,o,h){"undefined"==typeof e&&(e=null),"undefined"==typeof i&&(i=""),"undefined"==typeof r&&(r=null),"undefined"==typeof s&&(s=""),"undefined"==typeof n&&(n=null),"undefined"==typeof o&&(o=""),"undefined"==typeof h&&(h=null),this._bindings=new f([]),this._flags=o,""!=i&&(v(i.indexOf(":")>=0,"Document URI not absolute: "+i),this._bindings[""]=i+"#"),this._store=t,s&&t.setGenPrefix(s),this._thisDoc=i,this.source=t.sym(i),this.lines=0,this.statementCount=0,this.startOfLine=0,this.previousLine=0,this._genPrefix=s,this.keywords=new a(["a","this","bind","has","is","of","true","false"]),this.keywordsSet=0,this._anonymousNodes=new f([]),this._variables=new f([]),this._parentVariables=new f([]),this._reason=h,this._reason2=null,m&&(this._reason2=why_BecauseOfData(t.sym(i),this._reason)),r?this._baseURI=r:i?this._baseURI=i:this._baseURI=null,v(!this._baseURI||this._baseURI.indexOf(":")>=0),this._genPrefix||(this._thisDoc?this._genPrefix=this._thisDoc+"#_g":this._genPrefix=RDFSink_uniqueURI()),null==e?this._thisDoc?this._formula=t.formula(i+"#_formula"):this._formula=t.formula():this._formula=e,this._context=this._formula,this._parentContext=null}function r(t,e,i,r,s){this._str=i.encode("utf-8"),this._str=i,this._i=r,this._why=s,this.lines=e,this._uri=t}function s(t,e,i,r,s){return"Line "+(e+1)+" of <"+t+">: Bad syntax: "+s+'\nat: "'+c(i,r,r+30)+'"'}var n={encode:function(t){t=t.replace(/\r\n/g,"\n");for(var e="",i=0;i127&&r<2048?(e+=String.fromCharCode(r>>6|192),e+=String.fromCharCode(63&r|128)):(e+=String.fromCharCode(r>>12|224),e+=String.fromCharCode(r>>6&63|128),e+=String.fromCharCode(63&r|128))}return e},decode:function(t){for(var e="",i=0;i191&&r<224?(e+=String.fromCharCode((31&r)<<6|63&t.charCodeAt(i+1)),i+=2):(e+=String.fromCharCode((15&r)<<12|(63&t.charCodeAt(i+1))<<6|63&t.charCodeAt(i+2)),i+=3)}return e}},o="http://www.w3.org/2000/10/swap/log#",h=function(t){return t},a=function(t){return t},f=function(t){if(t.length>0)throw"missing.js: oops nnonempty dict not imp";return[]},u=function(t){return t.length},c=function(t,e,i){if("undefined"==typeof t.slice)throw"@@ mising.js: No .slice function for "+t+" of type "+("undefined"==typeof t?"undefined":_typeof(t));return"undefined"==typeof i||null==i?t.slice(e):t.slice(e,i)},p=Error("dummy error stop iteration"),l=function(t){return this.last=0,this.li=t,this.next=function(){if(this.last==this.li.length)throw p;return this.li[this.last++]},this},d=function(t,e){return t.indexOf(e)},v=function(t,e){if(!t){if(e)throw"python Assertion failed: "+e;throw"(python) Assertion failed."}},_=function(t){return String.fromCharCode(t)};String.prototype.encode=function(t){if("utf-8"!=t)throw"UTF8_converter: can only do utf-8";return n.encode(this)},String.prototype.decode=function(t){if("utf-8"!=t)throw"UTF8_converter: can only do utf-8";return this};var w=function(t,e){return Uri.join(e,t)},y=null,m=0,x=0,b=function(t){},g="http://www.w3.org/1999/02/22-rdf-syntax-ns#type",k="http://www.w3.org/2002/07/owl#sameAs",S="#",D="http://www.w3.org/2001/XMLSchema#integer",O="http://www.w3.org/2001/XMLSchema#double",A="http://www.w3.org/2001/XMLSchema#decimal",I="http://www.w3.org/2001/XMLSchema#date",C="http://www.w3.org/2001/XMLSchema#dateTime",R="\t\r\n !\"#$%&'()*.,+/;<=>?@[\\]^`{|}~",U=R+":",L=(new RegExp("^[ \\t]*(#[^\\n]*)?\\r?\\n","g"),new RegExp("^[ \\t]*(#[^\\n]*)?$","g"),new RegExp("^[ \\t]*","g"),new RegExp("^[-+]?[0-9]+","g"),new RegExp("^([-+]?[0-9]+)(\\.[0-9]+)?(e[-+]?[0-9]+)?","g")),E=new RegExp("^[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?"),N=(new RegExp("^[0-9]+","g"),new RegExp('[\\\\\\r\\n\\"]',"g")),j=new RegExp("^[a-zA-Z0-9]+(-[a-zA-Z0-9]+)?","g");return i.prototype.here=function(t){return this._genPrefix+"_L"+this.lines+"C"+(t-this.startOfLine+1)},i.prototype.formula=function(){return this._formula},i.prototype.loadStream=function(t){return this.loadBuf(t.read())},i.prototype.loadBuf=function(t){return this.startDoc(),this.feed(t),this.endDoc()},i.prototype.feed=function(t){for(var e=t.decode("utf-8"),i=0;i>=0;){var r=this.skipSpace(e,i);if(r<0)return;var i=this.directiveOrStatement(e,r);if(i<0)throw s(this._thisDoc,this.lines,e,r,"expected directive or statement")}},i.prototype.directiveOrStatement=function(t,e){var i=this.skipSpace(t,e);if(i<0)return i;var r=this.directive(t,i);if(r>=0)return this.checkDot(t,r);var r=this.statement(t,i);return r>=0?this.checkDot(t,r):r},i.prototype.tok=function(t,e,i){if("@"==c(e,i,i+1))var i=i+1;else if(ArrayIndexOf(this.keywords,t)<0)return-1;var r=i+u(t);return c(e,i,r)==t&&R.indexOf(e.charAt(r))>=0?r:-1},i.prototype.directive=function(e,i){var r=this.skipSpace(e,i);if(r<0)return r;var n=new a([]),r=this.tok("bind",e,i);if(r>0)throw s(this._thisDoc,this.lines,e,i,"keyword bind is obsolete: use @prefix");var r=this.tok("keywords",e,i);if(r>0){var i=this.commaSeparatedList(e,r,n,!1);if(i<0)throw s(this._thisDoc,this.lines,e,i,"'@keywords' needs comma separated list of words");return this.setKeywords(c(n,null,null)),x>80&&b("Keywords ",this.keywords),i}var r=this.tok("forAll",e,i);if(r>0){var i=this.commaSeparatedList(e,r,n,!0);if(i<0)throw s(this._thisDoc,this.lines,e,i,"Bad variable list after @forAll");var o=new l(n);try{for(;;){var h=o.next();(ArrayIndexOf(this._variables,h)<0||ArrayIndexOf(this._parentVariables,h)>=0)&&(this._variables[h]=this._context.newUniversal(h))}}catch(t){if(t!=p)throw t}return i}var r=this.tok("forSome",e,i);if(r>0){var i=this.commaSeparatedList(e,r,n,this.uri_ref2);if(i<0)throw s(this._thisDoc,this.lines,e,i,"Bad variable list after @forSome");var o=new l(n);try{for(;;){var h=o.next();this._context.declareExistential(h)}}catch(t){if(t!=p)throw t}return i}var r=this.tok("prefix",e,i);if(r>=0){var f=new a([]),i=this.qname(e,r,f);if(i<0)throw s(this._thisDoc,this.lines,e,r,"expected qname after @prefix");var r=this.uri_ref2(e,i,f);if(r<0)throw s(this._thisDoc,this.lines,e,i,"expected after @prefix _qname_");var u=f[1].uri;if(this._baseURI)var u=w(this._baseURI,u);else v(u.indexOf(":")>=0,"With no base URI, cannot handle relative URI for NS");return v(u.indexOf(":")>=0),this._bindings[f[0][0]]=u,this.bind(f[0][0],t(u)),r}var r=this.tok("base",e,i);if(r>=0){var f=new a([]),i=this.uri_ref2(e,r,f);if(i<0)throw s(this._thisDoc,this.lines,e,r,"expected after @base ");var u=f[0].uri;if(!this._baseURI)throw s(this._thisDoc,this.lines,e,r,"With no previous base URI, cannot use relative URI in @base <"+u+">");var u=w(this._baseURI,u);return v(u.indexOf(":")>=0),this._baseURI=u,i}return-1},i.prototype.bind=function(t,e){""==t||this._store.setPrefixForURI(t,e)},i.prototype.setKeywords=function(t){null==t?this.keywordsSet=0:(this.keywords=t,this.keywordsSet=1)},i.prototype.startDoc=function(){},i.prototype.endDoc=function(){return this._formula},i.prototype.makeStatement=function(t){t[0].add(t[2],t[1],t[3],this.source),this.statementCount+=1},i.prototype.statement=function(t,e){var i=new a([]),e=this.object(t,e,i);if(e<0)return e;var r=this.property_list(t,e,i[0]);if(r<0)throw s(this._thisDoc,this.lines,t,e,"expected propertylist");return r},i.prototype.subject=function(t,e,i){return this.item(t,e,i)},i.prototype.verb=function(t,e,i){var r=this.skipSpace(t,e);if(r<0)return r;var n=new a([]),r=this.tok("has",t,e);if(r>=0){var e=this.prop(t,r,n);if(e<0)throw s(this._thisDoc,this.lines,t,r,"expected property after 'has'");return i.push(new h(["->",n[0]])),e}var r=this.tok("is",t,e);if(r>=0){var e=this.prop(t,r,n);if(e<0)throw s(this._thisDoc,this.lines,t,r,"expected after 'is'");var r=this.skipSpace(t,e);if(r<0)throw s(this._thisDoc,this.lines,t,e,"End of file found, expected property after 'is'");var e=r,r=this.tok("of",t,e);if(r<0)throw s(this._thisDoc,this.lines,t,e,"expected 'of' after 'is' ");return i.push(new h(["<-",n[0]])),r}var r=this.tok("a",t,e);if(r>=0)return i.push(new h(["->",this._store.sym(g)])),r;if("<="==c(t,e,e+2))return i.push(new h(["<-",this._store.sym(o+"implies")])),e+2;if("="==c(t,e,e+1))return">"==c(t,e+1,e+2)?(i.push(new h(["->",this._store.sym(o+"implies")])),e+2):(i.push(new h(["->",this._store.sym(k)])),e+1);if(":="==c(t,e,e+2))return i.push(new h(["->",o+"becomes"])),e+2;var r=this.prop(t,e,n);if(r>=0)return i.push(new h(["->",n[0]])),r;if(">-"==c(t,e,e+2)||"<-"==c(t,e,e+2))throw s(this._thisDoc,this.lines,t,r,">- ... -> syntax is obsolete.");return-1},i.prototype.prop=function(t,e,i){return this.item(t,e,i)},i.prototype.item=function(t,e,i){return this.path(t,e,i)},i.prototype.blankNode=function(t){return this._context.bnode(t,this._reason2)},i.prototype.path=function(t,e,i){var r=this.nodeOrLiteral(t,e,i);if(r<0)return r;for(;"!^.".indexOf(c(t,r,r+1))>=0;){var n=c(t,r,r+1);if("."==n){var o=c(t,r+1,r+2);if(!o||U.indexOf(o)>=0&&":?<[{(".indexOf(o)<0)break}var a=i.pop(),f=this.blankNode(this.here(r)),r=this.node(t,r+1,i);if(r<0)throw s(this._thisDoc,this.lines,t,r,"EOF found in middle of path syntax");var u=i.pop();"^"==n?this.makeStatement(new h([this._context,u,f,a])):this.makeStatement(new h([this._context,u,a,f])),i.push(f)}return r},i.prototype.anonymousNode=function(t){var e=this._anonymousNodes[t];if(e)return e;var e=this._store.bnode(this._context,this._reason2);return this._anonymousNodes[t]=e,e},i.prototype.node=function(t,e,i,r){"undefined"==typeof r&&(r=null);var n=r,o=this.skipSpace(t,e);if(o<0)return o;var e=o,d=c(t,e,e+1);if("["==d){var v=this.here(e),o=this.skipSpace(t,e+1);if(o<0)throw s(this._thisDoc,this.lines,t,e,"EOF after '['");if("="==c(t,o,o+1)){var e=o+1,_=new a([]),o=this.objectList(t,e,_);if(!(o>=0))throw s(this._thisDoc,this.lines,t,e,"objectList expected after [= ");var n=_[0];if(u(_)>1){var w=new l(_);try{for(;;){var m=w.next();this.makeStatement(new h([this._context,this._store.sym(k),n,m]))}}catch(t){if(t!=p)throw t}}var o=this.skipSpace(t,o);if(o<0)throw s(this._thisDoc,this.lines,t,e,"EOF when objectList expected after [ = ");if(";"==c(t,o,o+1))var o=o+1}if(null==n)var n=this.blankNode(v);var e=this.property_list(t,o,n);if(e<0)throw s(this._thisDoc,this.lines,t,o,"property_list expected");var o=this.skipSpace(t,e);if(o<0)throw s(this._thisDoc,this.lines,t,e,"EOF when ']' expected after [ ");if("]"!=c(t,o,o+1))throw s(this._thisDoc,this.lines,t,o,"']' expected");return i.push(n),o+1}if("{"==d){var x=c(t,e+1,e+2);if("$"==x){e+=1;for(var o=e+1,b=new a([]),g=!0;;){var e=this.skipSpace(t,o);if(e<0)throw s(this._thisDoc,this.lines,t,e,"needed '$}', found end.");if("$}"==c(t,e,e+2)){var o=e+2;break}if(g)var g=!1;else{if(","!=c(t,e,e+1))throw s(this._thisDoc,this.lines,t,e,"expected: ','");e+=1}var S=new a([]),o=this.item(t,e,S);if(o<0)throw s(this._thisDoc,this.lines,t,e,"expected item in set or '$}'");b.push(S[0])}return i.push(this._store.newSet(b,this._context)),o}var o=e+1,D=this._parentContext;this._parentContext=this._context;var O=this._anonymousNodes,A=this._parentVariables;this._parentVariables=this._variables,this._anonymousNodes=new f([]),this._variables=this._variables.slice();var I=this._reason2;if(this._reason2=y,null==n)var n=this._store.formula();for(this._context=n;;){var e=this.skipSpace(t,o);if(e<0)throw s(this._thisDoc,this.lines,t,e,"needed '}', found end.");if("}"==c(t,e,e+1)){var o=e+1;break}var o=this.directiveOrStatement(t,e);if(o<0)throw s(this._thisDoc,this.lines,t,e,"expected statement or '}'")}return this._anonymousNodes=O,this._variables=this._parentVariables,this._parentVariables=A,this._context=this._parentContext,this._reason2=I,this._parentContext=D,i.push(n.close()),o}if("("==d){var C=this._store.list,x=c(t,e+1,e+2);if("$"==x){var C=this._store.newSet;e+=1}for(var o=e+1,b=new a([]);;){var e=this.skipSpace(t,o);if(e<0)throw s(this._thisDoc,this.lines,t,e,"needed ')', found end.");if(")"==c(t,e,e+1)){var o=e+1;break}var S=new a([]),o=this.item(t,e,S);if(o<0)throw s(this._thisDoc,this.lines,t,e,"expected item in list or ')'");b.push(S[0])}return i.push(C(b,this._context)),o}var o=this.tok("this",t,e);if(o>=0)throw s(this._thisDoc,this.lines,t,e,"Keyword 'this' was ancient N3. Now use @forSome and @forAll keywords.");var o=this.tok("true",t,e);if(o>=0)return i.push(!0),o;var o=this.tok("false",t,e);if(o>=0)return i.push(!1),o;if(null==n){var o=this.uri_ref2(t,e,i);if(o>=0)return o}return-1},i.prototype.property_list=function(t,e,i){for(;;){var r=this.skipSpace(t,e);if(r<0)throw s(this._thisDoc,this.lines,t,e,"EOF found when expected verb in property list");if(":-"!=c(t,r,r+2)){var e=r,n=new a([]),r=this.verb(t,e,n);if(r<=0)return e;var o=new a([]),e=this.objectList(t,r,o);if(e<0)throw s(this._thisDoc,this.lines,t,r,"objectList expected");var f=new l(o);try{for(;;){var u=f.next(),d=n[0],v=d[0],_=d[1];"->"==v?this.makeStatement(new h([this._context,_,i,u])):this.makeStatement(new h([this._context,_,u,i]))}}catch(t){if(t!=p)throw t}var r=this.skipSpace(t,e);if(r<0)throw s(this._thisDoc,this.lines,t,r,"EOF found in list of objects");if(";"!=c(t,e,e+1))return e;var e=e+1}else{var e=r+2,w=new a([]),r=this.node(t,e,w,i);if(r<0)throw s(this._thisDoc,this.lines,t,e,"bad {} or () or [] node after :- ");var e=r}}},i.prototype.commaSeparatedList=function(t,e,i,r){var n=this.skipSpace(t,e);if(n<0)throw s(this._thisDoc,this.lines,t,n,"EOF found expecting comma sep list");if("."==t.charAt(n))return e;if(r)var n=this.uri_ref2(t,n,i);else var n=this.bareWord(t,n,i);if(n<0)return-1;for(;;){var e=this.skipSpace(t,n);if(e<0)return e;var o=c(t,e,e+1);if(","!=o)return"."!=o?-1:e;if(r)var n=this.uri_ref2(t,e+1,i);else var n=this.bareWord(t,e+1,i);if(n<0)throw s(this._thisDoc,this.lines,t,n,"bad list content")}},i.prototype.objectList=function(t,e,i){var e=this.object(t,e,i);if(e<0)return-1;for(;;){var r=this.skipSpace(t,e);if(r<0)throw s(this._thisDoc,this.lines,t,r,"EOF found after object");if(","!=c(t,r,r+1))return r;var e=this.object(t,r+1,i);if(e<0)return e}},i.prototype.checkDot=function(t,e){var i=this.skipSpace(t,e);if(i<0)return i;if("."==c(t,i,i+1))return i+1;if("}"==c(t,i,i+1))return i;if("]"==c(t,i,i+1))return i;throw s(this._thisDoc,this.lines,t,i,"expected '.' or '}' or ']' at end of statement")},i.prototype.uri_ref2=function(t,e,i){var r=new a([]),n=this.qname(t,e,r);if(n>=0){var o=r[0],h=o[0],f=o[1];if(null==h){v(0,"not used?");var p=this._baseURI+S}else{var p=this._bindings[h];if(!p){if("_"==h)return i.push(this.anonymousNode(f)),n;throw s(this._thisDoc,this.lines,t,e,"Prefix "+h+" not bound.")}}var l=this._store.sym(p+f);return ArrayIndexOf(this._variables,l)>=0?i.push(this._variables[l]):i.push(l),n}var e=this.skipSpace(t,e);if(e<0)return-1;if("?"==t.charAt(e)){var d=new a([]),n=this.variable(t,e,d);return n>0?(i.push(d[0]),n):-1}if("<"==t.charAt(e)){for(var e=e+1,_=e;e"==t.charAt(e)){var y=c(t,_,e);if(this._baseURI)var y=w(this._baseURI,y);else v(y.indexOf(":")>=0,"With no base URI, cannot deal with relative URIs");if("#"==c(t,e-1,e)&&"#"!=c(y,-1,null))var y=y+"#";var l=this._store.sym(y);return ArrayIndexOf(this._variables,l)>=0?i.push(this._variables[l]):i.push(l),e+1}var e=e+1}throw s(this._thisDoc,this.lines,t,n,"unterminated URI reference")}if(this.keywordsSet){var d=new a([]),n=this.bareWord(t,e,d);if(n<0)return-1;if(ArrayIndexOf(this.keywords,d[0])>=0)throw s(this._thisDoc,this.lines,t,e,'Keyword "'+d[0]+'" not allowed here.');return i.push(this._store.sym(this._bindings[""]+d[0])),n}return-1},i.prototype.skipSpace=function(t,e){for(var i=" \n\r\t\f\v            ​\u2028\u2029 ",r=e?e:0;r=0)throw s(this._thisDoc,this.lines,t,r,"Varible name can't start with '"+t.charAt(r)+"s'");for(;e=0)return-1;if(U.indexOf(s)>=0)return-1;for(var e=r;e=0)return-1;if(U.indexOf(r)<0)for(var s=r,e=e+1;e=0)return r;var r=this.skipSpace(t,e);if(r<0)return-1;var e=r;if('"'==t.charAt(e)){if('"""'==c(t,e,e+3))var s='"""';else var s='"';var e=e+u(s),n=this.strconst(t,e,s),r=n[0],o=n[1];return i.push(this._store.literal(o)),b("New string const ",o,r),r}return-1},i.prototype.nodeOrLiteral=function(t,e,i){var r=this.node(t,e,i);if(r>=0)return r;var r=this.skipSpace(t,e);if(r<0)return-1;var e=r,n=t.charAt(e);if("-+0987654321".indexOf(n)>=0){E.lastIndex=0;var o=E.exec(t.slice(e));if(null!=o){var h=o[0];r=e+h.length,h.indexOf("T")>=0?i.push(this._store.literal(h,void 0,this._store.sym(C))):i.push(this._store.literal(h,void 0,this._store.sym(I)))}else{L.lastIndex=0;var o=L.exec(t.slice(e));if(null==o)throw s(this._thisDoc,this.lines,t,e,"Bad number or date syntax");r=e+L.lastIndex;var h=c(t,e,r);h.indexOf("e")>=0?i.push(this._store.literal(parseFloat(h),void 0,this._store.sym(O))):c(t,e,r).indexOf(".")>=0?i.push(this._store.literal(parseFloat(h),void 0,this._store.sym(A))):i.push(this._store.literal(parseInt(h),void 0,this._store.sym(D)))}return r}if('"'==t.charAt(e)){if('"""'==c(t,e,e+3))var f='"""';else var f='"';var e=e+u(f),p=null,l=this.strconst(t,e,f),r=l[0],d=l[1],v=null;if("@"==c(t,r,r+1)){j.lastIndex=0;var o=j.exec(t.slice(r+1));if(null==o)throw s(this._thisDoc,startline,t,e,"Bad language code syntax on string literal, after @");var e=j.lastIndex+r+1,v=c(t,r+1,e),r=e}if("^^"==c(t,r,r+2))var _=new a([]),r=this.uri_ref2(t,r+2,_),p=_[0];return i.push(this._store.literal(d,v,p)),r}return-1},i.prototype.strconst=function(t,e,i){for(var r=e,n="",o=this.lines;r=0)var l='a\b\f\r\t\v\n\\"'.charAt(p),n=n+l,r=r+1;else if("u"==f)var v=this.uEscape(t,r+1,o),r=v[0],f=v[1],n=n+f;else{if("U"!=f)throw s(this._thisDoc,this.lines,t,e,"bad escape");var v=this.UEscape(t,r+1,o),r=v[0],f=v[1],n=n+f}}}else var r=e+1;else var r=e}else var n=n+'"',r=r+1}throw s(this._thisDoc,this.lines,t,e,"unterminated string literal")},i.prototype.uEscape=function(t,e,i){for(var r=e,n=0,o=0;n<4;){var a=c(t,r,r+1),f=a.toLowerCase(),r=r+1;if(""==f)throw s(this._thisDoc,i,t,e,"unterminated string literal(3)");var u=d("0123456789abcdef",f);if(u<0)throw s(this._thisDoc,i,t,e,"bad string literal hex escape");var o=16*o+u,n=n+1}var p=String.fromCharCode(o);return new h([r,p])},i.prototype.UEscape=function(t,e,i){for(var r=e,n=0,o="\\U";n<8;){var a=c(t,r,r+1),f=a.toLowerCase(),r=r+1;if(""==f)throw s(this._thisDoc,i,t,e,"unterminated string literal(3)");var u=d("0123456789abcdef",f);if(u<0)throw s(this._thisDoc,i,t,e,"bad string literal hex escape");var o=o+f,n=n+1}var p=_("0x"+c(o,2,10)-0);return new h([r,p])},r.prototype.toString=function(){var t=this._str,e=this._i,i=0;if(e>60)var r="...",i=e-60;else var r="";if(u(t)-e>60)var s="...";else var s="";return'Line %i of <%s>: Bad syntax (%s) at ^ in:\n"%s%s^%s%s"'%new h([this.lines+1,this._uri,this._why,r,c(t,i,e),c(t,e,e+60),s])},e}();module.exports=N3Parser; },{"./uri":71,"./util":72}],56:[function(require,module,exports){ "use strict";function _classCallCheck(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function _possibleConstructorReturn(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}function _inherits(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}var _createClass=function(){function e(e,t){for(var r=0;r=0&&r"}},{key:"uri",get:function(){return this.value},set:function(e){this.value=e}}],[{key:"fromValue",value:function(e){if("undefined"==typeof e||null===e)return e;var r=e&&e.termType;return r?e:new t(e)}}]),t}(Node);NamedNode.termType="NamedNode",NamedNode.prototype.classOrder=ClassOrder.NamedNode,NamedNode.prototype.isVar=0,module.exports=NamedNode; },{"./class-order":43,"./node":58}],57:[function(require,module,exports){ "use strict";function Namespace(e){return function(n){return new NamedNode(e+(n||""))}}var NamedNode=require("./named-node");module.exports=Namespace; },{"./named-node":56}],58:[function(require,module,exports){ "use strict";function _classCallCheck(e,r){if(!(e instanceof r))throw new TypeError("Cannot call a class as a function")}var _createClass=function(){function e(e,r){for(var t=0;te.classOrder?1:this.valuee.value?1:0}},{key:"equals",value:function(e){return!!e&&(this.termType===e.termType&&this.value===e.value)}},{key:"hashString",value:function(){return this.toCanonical()}},{key:"sameTerm",value:function(e){return this.equals(e)}},{key:"toCanonical",value:function(){return this.toNT()}},{key:"toNT",value:function(){return this.toString()}},{key:"toString",value:function(){throw new Error("Node.toString() is abstract - see the subclasses instead")}}]),e}();module.exports=Node,Node.fromValue=function(e){var r=require("./collection"),t=require("./literal");require("./named-node");if("undefined"==typeof e||null===e)return e;var n=e&&e.termType;return n?e:Array.isArray(e)?new r(e):t.fromValue(e)}; },{"./collection":44,"./literal":53,"./named-node":56}],59:[function(require,module,exports){ "use strict";function parse(e,r,a,t,l){function n(){l&&l(null,r)}function i(e){if("application/ld+json"!==t||"application/nquads"!==t||"application/n-quads"!==t){if(!l)throw new Error("Error trying to parse <"+a+"> as "+t+":\n"+e+":\n"+e.stack);l(e,r)}}function s(e,a){e&&l(e,r);try{f.parse(a,p)}catch(e){l(e,r)}}function p(e,a,t){if(e&&l(e,r),a)N.push(a);else{for(var n=0;n: Bad syntax:\n "+i+'\n at: "'+t.slice(a,a+30)+'"'};a=0;var p=r.sym(t+"#query");for(f.query=p;;){if(i=c.skipSpace(e,a),i<0)return f;if(";"===e[i]){if(a=c.skipSpace(e,i+1),a<0)return f;i=a}var h=!1;for(s=0;s "+n[t]);return e},s=function(n){var t,e="Bindings: ",r=n.length;for(t=0;ti.length)&&(t.index=i)}return null===t.index&&(t.index=n.statements),!0},p=0,b=function n(e,r,o,s,a,u,c){log.debug("Match begins, Branch count now: "+c.count+" for "+c.pattern_debug);var l=e.fetcher?e.fetcher:null,d=r.statements;if(0===d.length){if(log.debug("FOUND MATCH WITH BINDINGS:"+i(o)),0===r.optional.length)c.reportMatch(o);else{log.debug("OPTIONAL: "+r.optional);var g,b=new h(t,o),v=[];for(g=0;g in query: "+l),n(e,r,o,s,a,u,c)})};for(x=0;x=0){var n=t.substring(0,i);if(""===n)return s=a[""],s?s+t.substring(i+1):null;if("_"===n)return"_:"+t.substring(i+1);if(e.NCNAME.test(n)&&(s=a[n]))return s+t.substring(i+1)}return null}},{key:"parseCURIEOrURI",value:function(e,t,a){var r=this.parseCURIE(e,t,a);return r?r:this.resolveAndNormalize(a,e)}},{key:"parsePredicate",value:function(e,t,a,r,s,i){if(""===e)return null;var n=this.parseTermOrCURIEOrAbsURI(e,t,i?null:a,r,s);return n&&0===n.indexOf("_:")?null:n}},{key:"parsePrefixMappings",value:function(e,t){for(var a=this.tokenize(e),r=null,s=0;s=0&&(e=e.substring(0,t)),a&&a.baseURIMap&&(e=a.baseURIMap(e)),e};for(s.push({current:t,context:this.push(null,i(t.baseURI))});s.length>0;){var n=s.shift();if(n.parent){if(n.context.parent&&n.context.parent.listMapping===n.listMapping)continue;for(var o in n.listMapping){var l=n.listMapping[o];if(0!==l.length){for(var h=[],p=0;p0){y=M;var O=r.spec;this.addTriple(c,O,"http://www.w3.org/ns/rdfa#usesVocabulary",{type:e.objectURI,value:y})}else y=this.vocabulary}for(var x=0;x0?A:null}var H,_,P=c.getAttributeNode("rel"),X=c.getAttributeNode("rev"),S=c.getAttributeNode("typeof"),F=c.getAttributeNode("property"),z=c.getAttributeNode("datatype"),B=this.inHTMLMode?c.getAttributeNode("datetime"):null,q=c.getAttributeNode("content"),Y=c.getAttributeNode("about"),Z=c.getAttributeNode("src"),G=c.getAttributeNode("resource"),W=c.getAttributeNode("href"),$=c.getAttributeNode("inlist"),V=[];if(P){_=this.tokenize(P.value);for(var J=0;J<_.length;J++)H=this.parsePredicate(_[J],y,d.terms,m,r,this.inHTMLMode&&null!==F),H&&V.push(H)}var K=[];if(X){_=this.tokenize(X.value);for(var Q=0;Q<_.length;Q++)H=this.parsePredicate(_[Q],y,d.terms,m,r,this.inHTMLMode&&F),H&&K.push(H)}if(this.inHTMLMode&&(P||X)&&F&&(0===V.length&&(P=null),0===K.length&&(X=null)),P||X?(Y&&(w=this.parseSafeCURIEOrCURIEOrURI(Y.value,m,r)),S&&(b=w),w||(c.parentNode.nodeType===Node.DOCUMENT_NODE?w=i(c.baseURI):d.parentObject&&(w=i(c.parentNode.baseURI)===d.parentObject?i(c.baseURI):d.parentObject)),G&&(v=this.parseSafeCURIEOrCURIEOrURI(G.value,m,r)),v||(W?v=this.resolveAndNormalize(r,encodeURI(W.value)):Z?v=this.resolveAndNormalize(r,encodeURI(Z.value)):!S||Y||this.inXHTMLMode&&("head"===c.localName||"body"===c.localName)||(v=this.newBlankNode())),!S||Y||!this.inXHTMLMode||"head"!==c.localName&&"body"!==c.localName?S&&!Y&&(b=v):b=w):!F||q||z?(Y&&(w=this.parseSafeCURIEOrCURIEOrURI(Y.value,m,r)),!w&&G&&(w=this.parseSafeCURIEOrCURIEOrURI(G.value,m,r)),!w&&W&&(w=this.resolveAndNormalize(r,encodeURI(W.value))),!w&&Z&&(w=this.resolveAndNormalize(r,encodeURI(Z.value))),w||(c.parentNode.nodeType===Node.DOCUMENT_NODE?w=i(c.baseURI):!this.inXHTMLMode&&!this.inHTMLMode||"head"!==c.localName&&"body"!==c.localName?S?w=this.newBlankNode():d.parentObject&&(w=i(c.parentNode.baseURI)===d.parentObject?i(c.baseURI):d.parentObject,F||(g=!0)):w=i(c.parentNode.baseURI)===d.parentObject?i(c.baseURI):d.parentObject),S&&(b=w)):(Y&&(w=this.parseSafeCURIEOrCURIEOrURI(Y.value,m,r),S&&(b=w)),w||c.parentNode.nodeType!==Node.DOCUMENT_NODE?!w&&d.parentObject&&(w=i(c.parentNode.baseURI)===d.parentObject?i(c.baseURI):d.parentObject):(w=i(c.baseURI),S&&(b=w)),S&&!b&&(G&&(b=this.parseSafeCURIEOrCURIEOrURI(G.value,m,r)),!b&&W&&(b=this.resolveAndNormalize(r,encodeURI(W.value))),!b&&Z&&(b=this.resolveAndNormalize(r,encodeURI(Z.value))),b||!this.inXHTMLMode&&!this.inHTMLMode||"head"!==c.localName&&"body"!==c.localName||(b=w),b||(b=this.newBlankNode()),v=b)),w&&(Y||G||b)){var ee=w;S&&!Y&&!G&&v&&(ee=v),this.newSubjectOrigin(c,ee)}if(b){_=this.tokenize(S.value);for(var te=0;te<_.length;te++){var ae=this.parseTermOrCURIEOrAbsURI(_[te],y,d.terms,m,r);ae&&this.addTriple(c,b,e.typeURI,{type:e.objectURI,value:ae})}}if(w&&w!==d.parentObject&&(N={},U=!0),v){if(P&&$)for(var re=0;re=0?e.nodeName.split(":")[1]:e.nodeName),t}.bind(this),s=!0;t.parent;){var r=t.element,o=r.attributes;if(r.nodeType===e.nodeType.TEXT||r.nodeType===e.nodeType.CDATA_SECTION)t.parent.nodeType===t.NODE&&(t.addArc(e.ns.RDF+"value"),t=this.buildFrame(t)),t.addLiteral(r.nodeValue);else if(n(r)!==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){t.addArc(n(r)),this.reify&&(i=this.getAttributeNodeNS(r,e.ns.RDF,"ID"),i&&(t.rdfid=i.nodeValue,r.removeAttributeNode(i)));var a=this.getAttributeNodeNS(r,e.ns.RDF,"parseType"),d=this.getAttributeNodeNS(r,e.ns.RDF,"datatype");if(d&&(t.datatype=d.nodeValue,r.removeAttributeNode(d)),a){var l=a.nodeValue;"Literal"===l?(t.datatype=e.ns.RDF+"XMLLiteral",t=this.buildFrame(t),t.addLiteral(r),s=!1):"Resource"===l?(t=this.buildFrame(t,t.element),t.parent.element=null,t.addBNode()):"Collection"===l&&(t=this.buildFrame(t,t.element),t.parent.element=null,t.addCollection()),r.removeAttributeNode(a)}if(0!==o.length){var h=this.getAttributeNodeNS(r,e.ns.RDF,"resource"),p=this.getAttributeNodeNS(r,e.ns.RDF,"nodeID");t=this.buildFrame(t),h?(t.addNode(h.nodeValue),r.removeAttributeNode(h)):p?(t.addBNode(p.nodeValue),r.removeAttributeNode(p)):t.addBNode();for(var u=o.length-1;u>=0;u--){var N=this.buildFrame(t);N.addArc(n(o[u])),n(o[u])===e.ns.RDF+"type"?this.buildFrame(N).addNode(o[u].nodeValue):this.buildFrame(N).addLiteral(o[u].nodeValue)}}else 0===r.childNodes.length&&this.buildFrame(t).addLiteral("")}else{var T=this.getAttributeNodeNS(r,e.ns.RDF,"about");if(i=this.getAttributeNodeNS(r,e.ns.RDF,"ID"),T&&i)throw new Error("RDFParser: "+r.nodeName+" has both rdf:id and rdf:about. Halting. Only one of these properties may be specified on a node.");if(!T&&i)t.addNode("#"+i.nodeValue),r.removeAttributeNode(i);else if(null==T&&null==i){var m=this.getAttributeNodeNS(r,e.ns.RDF,"nodeID");m?(t.addBNode(m.nodeValue),r.removeAttributeNode(m)):t.addBNode()}else t.addNode(T.nodeValue),r.removeAttributeNode(T);var y=this.getAttributeNodeNS(r,e.ns.RDF,"type");e.ns.RDF+"Description"!==n(r)&&(y={nodeValue:n(r)}),null!=y&&(this.store.add(t.node,this.store.sym(e.ns.RDF+"type"),this.store.sym(uriUtil.join(y.nodeValue,t.base)),this.why),y.nodeName&&r.removeAttributeNode(y));for(var b=o.length-1;b>=0;b--)this.store.add(t.node,this.store.sym(n(o[b])),this.store.literal(o[b].nodeValue,t.lang),this.why)}for(r=t.element;t.parent;){for(var c=t;null==r;)t=t.parent,r=t.element;var f=r.childNodes&&r.childNodes[t.lastChild];if(f&&s){if((f.nodeType===e.nodeType.ELEMENT||f.nodeType===e.nodeType.TEXT||f.nodeType===e.nodeType.CDATA_SECTION)&&(f.nodeType!==e.nodeType.TEXT&&f.nodeType!==e.nodeType.CDATA_SECTION||1===r.childNodes.length)){t.lastChild++,t=this.buildFrame(c,r.childNodes[t.lastChild-1]);break}t.lastChild++}else{if(t.terminateFrame(),!(t=t.parent))break;r=t.element,s=!0}}}},this.cleanParser=function(){this.bnodes={},this.why=null},this.buildFrame=function(t,i){var n=this.frameFactory(this,t,i);if(t&&(n.base=t.base,n.lang=t.lang),!i||i.nodeType===e.nodeType.TEXT||i.nodeType===e.nodeType.CDATA_SECTION)return n;var s=i.attributes,r=i.getAttributeNode("xml:base");null!=r&&(n.base=r.nodeValue,i.removeAttribute("xml:base"));var o=i.getAttributeNode("xml:lang");null!=o&&(n.lang=o.nodeValue,i.removeAttribute("xml:lang"));for(var a=s.length-1;a>=0;a--)if("xml"===s[a].nodeName.substr(0,3)){if("xmlns:"===s[a].name.slice(0,6)){var d=s[a].nodeValue;this.base&&(d=uriUtil.join(d,this.base)),this.store.setPrefixForURI(s[a].name.slice(6),d)}i.removeAttributeNode(s[a])}return n}};module.exports=RDFParser; },{"./uri":71}],65:[function(require,module,exports){ "use strict";function serialize(e,t,a,r,s){function n(e,t){return s?void s(e,t):t}var i=null;try{var o,c=Serializer(t),l=t.statementsMatching(void 0,void 0,void 0,e);switch(c.suggestNamespaces(t.namespaces),c.setBase(a),r){case"application/rdf+xml":return i=c.statementsToXML(l),n(null,i);case"text/n3":case"application/n3":return i=c.statementsToN3(l),n(null,i);case"text/turtle":case"application/x-turtle":return c.setFlags("si"),i=c.statementsToN3(l),n(null,i);case"application/ld+json":o=c.statementsToN3(l),convert.convertToJson(o,s);break;case"application/n-quads":case"application/nquads":o=c.statementsToN3(l),i=convert.convertToNQuads(o,s);break;default:throw new Error("Serialize: Content-type "+r+" not supported for data write.")}}catch(e){if(s)return s(e);throw e}}module.exports=serialize;var convert=require("./convert"),Serializer=require("./serializer"); },{"./convert":45,"./serializer":66}],66:[function(require,module,exports){ "use strict";var NamedNode=require("./named-node"),Uri=require("./uri"),Util=require("./util"),XSD=require("./xsd"),Serializer=function(){function e(e){return encodeURI(e)}function t(e){for(var t,r="",i=0;i65535?"\\U"+("00000000"+t.toString(16)).slice(-8):t>126?"\\u"+("0000"+t.toString(16)).slice(-4):e[i];return r}var r=function(e){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=e};r.prototype.setBase=function(e){this.base=e},r.prototype.setFlags=function(e){this.flags=e?e:""},r.prototype.toStr=function(e){var t=e.toNT();return"formula"==e.termType&&(this.formulas[t]=e),t},r.prototype.fromStr=function(e){if("{"==e[0]){var t=this.formulas[e];return t||alert("No formula object for "+e),t}return this.store.fromNT(e)},r.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))},r.prototype.suggestNamespaces=function(e){for(var t in e)this.suggestPrefix(t,e[t])},r.prototype.checkIntegrity=function(){var e,t;for(e in this.namespaces)if(this.prefixes[this.namespaces[e]]!==e)throw"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"Serializer integity error 2: "+t+", "+this.prefixs[t]+", "+this.namespaces[this.prefixes[t]]+"!"},r.prototype.makeUpPrefix=function(e){function t(t){return!!r.prototype.validPrefix.test(t)&&("ns"!==t&&(!(t in this.namespaces)&&(this.prefixes[e]=t,this.namespaces[t]=e,i=t,!0)))}var i,n=e;t=t.bind(this),"#/".indexOf(n[n.length-1])>=0&&(n=n.slice(0,-1));var s=n.lastIndexOf("/");s>=0&&(n=n.slice(s+1));for(var a=0;a?@[\\]^`{|}~",r.prototype._notNameChars=r.prototype._notQNameChars+":",r.prototype.statementsToN3=function(e){function t(e){for(var t=this.rootSubjects(e),r=t.roots,i=[],s=0;s.\n");for(var t in this.prefixes)this.prefixes.hasOwnProperty(t)&&this.namespacesUsed[t]&&(e+="@prefix "+this.prefixes[t]+": <"+Uri.refTo(this.base,t)+">.\n");return e+"\n"}var f=4,u=80,p={};this.flags.indexOf("s")<0&&(p["http://www.w3.org/2002/07/owl#sameAs"]="="),this.flags.indexOf("t")<0&&(p["http://www.w3.org/1999/02/22-rdf-syntax-ns#type"]="a"),this.flags.indexOf("i")<0&&(p["http://www.w3.org/2000/10/swap/log#implies"]="=>");var h=function(e){for(var t="",r=0;r=0){i=i.slice(0,-1)+a+"\n",n+=1;continue}if("])}".indexOf(a)>=0){i=i.slice(0,-1)+" "+a+"\n",n+=2;continue}}if(n20&&'"'!=e.slice(-1)&&t.indexOf("n")<0&&(e.indexOf("\n")>0||e.indexOf('"')>0)?(i='"""',n=r.prototype.forbidden3):(i='"',n=r.prototype.forbidden1),a=0;a=0?"\\"+'bfrtvn\\"'[u]:t.indexOf("e")>=0?"\\u"+("000"+f.charCodeAt(0).toString(16).toLowerCase()).slice(-4):f}a=o+1}return i+s+e.slice(a)+i},r.prototype.symbolToN3=function(i){var n=i.uri,s=n.indexOf("#");if(s<0&&this.flags.indexOf("/")<0&&(s=n.lastIndexOf("/")),s>=0&&this.flags.indexOf("p")<0&&(0===n.indexOf("http")||0===n.indexOf("ws")||0===n.indexOf("file"))){for(var a=!0,o=s+1;o=0){a=!1;break}if(n.slice(0,s+1)==this.base+"#")return"<#"+n.slice(s+1)+">";if(a){var c=n.slice(s+1),f=n.slice(0,s+1);if(this.defaultNamespace&&this.defaultNamespace==f&&this.flags.indexOf("d")<0)return this.flags.indexOf("k")>=0&&this.keyords.indexOf(c)<0?c:":"+c;this.checkIntegrity();var u=this.prefixes[f];if(u||(u=this.makeUpPrefix(f)),u)return this.namespacesUsed[f]=!0,u+":"+c}}return n=this.flags.indexOf("r")<0&&this.base?Uri.refTo(this.base,n):this.flags.indexOf("u")>=0?t(n):e(n),"<"+n+">"},r.prototype.writeStore=function(e){var t=this.store,r=t.fetcher,i=r&&r.appNode,n=this.store.index[3];for(s in n){var a=t.fromNT(s);i&&a.sameTerm(i)||e("\n"+this.atomicTermToN3(a)+" "+this.atomicTermToN3(t.sym("http://www.w3.org/2000/10/swap/log#semantics"))+" { "+this.statementsToN3(t.statementsMatching(void 0,void 0,void 0,a))+" }.\n")}t.statementsMatching(void 0,t.sym("http://www.w3.org/2007/ont/link#requestedURI")).map(function(r){e("\n<"+r.object.value+"> log:metadata {\n");var i=t.statementsMatching(void 0,void 0,void 0,r.subject);e(this.statementsToN3(this.statementsToN3(i))),e("}.\n")}),i&&metaSources.push(i);var o=[];metaSources.map(function(e){o=o.concat(t.statementsMatching(void 0,void 0,void 0,e))}),e(this.statementsToN3(o))},r.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),r=t.roots,i=[],n=0;n",s(f.object,t),""]):p.concat(["<"+o+' rdf:nodeID="'+f.object.toNT().slice(2)+'"/>']);break;case"NamedNode":p=p.concat(["<"+o+' rdf:resource="'+n(f.object)+'"/>']);break;case"Literal":p=p.concat(["<"+o+(f.object.datatype.equals(XSD.string)?"":' rdf:datatype="'+i(f.object.datatype.uri)+'"')+(f.object.language?' xml:lang="'+f.object.language+'"':"")+">"+i(f.object.value)+""]);break;case"collection":p=p.concat(["<"+o+' rdf:parseType="Collection">',a(f.object,t),""]);break;default:throw"Can't serialize object of type "+f.object.termType+" into XML"}}else r=f.object;var v=r?c(r):"rdf:Description",b="";return"BlankNode"==e.termType?t.incoming[e]&&1==t.incoming[e].length||(b=' rdf:nodeID="'+e.toNT().slice(2)+'"'):b=' rdf:about="'+n(e)+'"',["<"+v+b+">"].concat([p]).concat([""])}function a(e,t){for(var r=[],i=0;i',""]):r.concat(["<"+c(u.predicate)+' rdf:parseType="Resource">',o(u.object,t),""]);break;case"NamedNode":r=r.concat(["<"+c(u.predicate)+' rdf:resource="'+n(u.object)+'"/>']);break;case"Literal":r=r.concat(["<"+c(u.predicate)+(u.object.datatype.equals(XSD.string)?"":' rdf:datatype="'+i(u.object.datatype.value)+'"')+(u.object.language?' xml:lang="'+u.object.language+'"':"")+">"+i(u.object.value)+""]);break;case"collection":r=r.concat(["<"+c(u.predicate)+' rdf:parseType="Collection">',a(u.object,t),""]);break;default:throw"Can't serialize object of type "+u.object.termType+" into XML"}}return r}function c(e){var t=e.uri,i=t.indexOf("#");if(i<0&&this.flags.indexOf("/")<0&&(i=t.lastIndexOf("/")),i<0)throw"Cannot make qname out of <"+t+">";for(var n=i+1;n=0)throw'Invalid character "'+t[n]+'" cannot be in XML qname for URI: '+t;var s=t.slice(i+1),a=t.slice(0,i+1);if(this.defaultNamespace&&this.defaultNamespace==a&&this.flags.indexOf("d")<0)return s;var o=this.prefixes[a];return o||(o=this.makeUpPrefix(a)),p[a]=!0,o+":"+s}var f=4,u=80,p=[];p["http://www.w3.org/1999/02/22-rdf-syntax-ns#"]=!0;var h="http://www.w3.org/1999/02/22-rdf-syntax-ns#_",l=function(e){for(var t="",r=0;r"];return g(y,-1)};var n=function(e){return new r(e)};return n}();module.exports=Serializer; },{"./named-node":56,"./uri":71,"./util":72,"./xsd":74}],67:[function(require,module,exports){ "use strict";function SPARQLToQuery(e,r,n){function t(e){if(O[e])return O[e];var r=n.variable(e);return O[e]=r,r}function o(e){return"string"==typeof e&&e.match(/[^ \n\t]/)}function i(e){return"string"==typeof e&&e.match(/^[\?\$]/)}function a(e){return"string"==typeof e?e.replace(/^</,"<").replace(/>$/,">"):e}function l(e){return"string"==typeof e&&e.match(/^<[^>]*>$/)}function c(e){return"string"==typeof e&&(e.match(/^_:/)||e.match(/^$/))}function s(e){return"string"==typeof e&&e.match(/:$/)}function f(e){return"string"==typeof e&&e.match(/^:|^[^_][^:]*:/)}function u(e){var r=e.split(":");return r[0]}function g(e){var r=e.split(":");return r[1]}function p(e){return l(e)?e.slice(1,e.length-1):e}function d(e){var r=e.indexOf("'")===-1?null:e.indexOf("'"),t=e.indexOf('"')===-1?null:e.indexOf('"');if(!r&&!t){var o=new Array(1);return o[0]=e,o}var i,a,l=new Array(2);if(!r||t&&t/g,"> ").replace(/{/g," { ").replace(/}/g," } ").replace(/[\t\n\r]/g," ").replace(/; /g," ; ").replace(/\. /g," . ").replace(/, /g," , "),log.info("New str into spaceDelimit: \n"+e);var r=[],n=e.split(" ");for(var t in n)o(n[t])&&(r=r.concat(n[t]));return r}function v(e){for(var r=e,n=0;n"),"is"===r[n]&&"of"===r[n+2]){r.splice(n,1),r.splice(n+1,1);var t=r[n-1];r[n-1]=r[n+1],r[n+1]=t}return r}function y(e){for(var r=[],o=0;o "+i);var a=u(o),c=p(i);n[a]=c}else log.error("Invalid SPARQL symbol: "+i);else log.error("Invalid SPARQL prefix: "+o)}return n}function E(e,r,n){log.info("Looking for a close bracket of type "+n+" in "+e);for(var t=0,o=0;o"===e[1]?(log.debug("Constraint added: "+e),r.constraints[e[0]]=new T(e[2])):"<"===e[1]?(log.debug("Constraint added: "+e),r.constraints[e[0]]=new T(e[2])):log.warn("I don't know how to handle the constraint: "+e)}function Q(e,r){log.debug("Optional query: "+e+" not yet implemented.");var t=n.formula();S(e,t),r.optional.push(t)}function S(e,r){var n,t=y(e);log.debug("WHERE: "+t);for(var o;m("OPTIONAL",t);)o=m("OPTIONAL",t),log.debug("OPT: "+o+" "+t[o]+" in "+t),"{"!==t[o+1]&&log.warn("Bad optional opening bracket in word "+o),n=E(t.slice(o+2),"{","}"),n===-1?log.error("No matching bracket in word "+o):(Q(t.slice(o+2,o+2+n),r),o=m("OPTIONAL",t),n=E(t.slice(o+2),"{","}"),t.splice(o,n+3));for(log.debug("WHERE after optionals: "+t);m("FILTER",t);){var i=m("FILTER",t);"("!==t[i+1]&&log.warn("Bad filter opening bracket in word "+i),n=E(t.slice(i+2),"(",")"),n===-1?log.error("No matching bracket in word "+i):(A(t.slice(i+2,i+2+n),r),i=m("FILTER",t),n=E(t.slice(i+2),"(",")"),t.splice(i,n+3))}log.debug("WHERE after filters and optionals: "+t),x(t,r)}function x(e,r){var n=new Array(1);n[0]=-1;for(var t=n.concat(b(".",e)),o=[],i=0;iq)return log.error("Invalid or nonexistent SELECT and WHERE tags in SPARQL query"),!1;if(L(C.slice(k+1,q),N),S(C.slice(q+2,C.length-1),N.pat),r)return N;for(var j in N.pat.statements){var H=N.pat.statements[j];"NamedNode"===H.subject.termType&&fetcher&&fetcher.lookUpThing(H.subject,"sparql:"+H.subject),"NamedNode"===H.object.termType&&fetcher&&fetcher.lookUpThing(H.object,"sparql:"+H.object)}return N}var log=require("./log"),Query=require("./query").Query,fetcher=require("./fetcher");module.exports=SPARQLToQuery; },{"./fetcher":49,"./log":54,"./query":62}],68:[function(require,module,exports){ "use strict";function _classCallCheck(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}var _createClass=function(){function t(t,e){for(var i=0;i=0)return"SPARQL";var h=t.each(c,this.ns.httph("ms-author-via"));if(h.length)for(s=0;s=0)return"SPARQL";if(i.indexOf("DAV")>=0)return"DAV"}var u=t.each(c,this.ns.http("status"));if(u.length)for(s=0;s");var o=Util.XMLHTTPFactory();o.options={},o.onreadystatechange=function(){if(4===o.readyState){var r=!o.status||o.status>=200&&o.status<300;r?console.log("sparql: update Ok for <"+e+">"):console.log("sparql: update failed for <"+e+"> status="+o.status+", "+o.statusText+", body length="+o.responseText.length+"\n for query: "+t),n(e,r,o.responseText,o)}},o.open("PATCH",e,!0),o.setRequestHeader("Content-type","application/sparql-update"),o.send(t)},e.prototype.update_statement=function(e){if(!e||e.why){var t=this,n=this._statement_context(e);return{statement:e?[e.subject,e.predicate,e.object,e.why]:void 0,statementNT:e?this.anonymizeNT(e):void 0,where:t._context_where(n),set_object:function(e,n){var o=this.where;o+="DELETE DATA { "+this.statementNT+" } ;\n",o+="INSERT DATA { "+this.anonymize(this.statement[0])+" "+this.anonymize(this.statement[1])+" "+this.anonymize(e)+" . }\n",t._fire(this.statement[3].uri,o,n)}}}},e.prototype.insert_statement=function(e,t){var n=e instanceof Array?e[0]:e,o=this._context_where(this._statement_context(n));if(e instanceof Array){for(var r="",a=0;a 1 differnt downstream actions")}n.downstreamAction=t}else t(e)},e.prototype.clearUpstreamCount=function(e){var t=this.patchControlFor(e);t.upstreamCount=0},e.prototype.getUpdatesVia=function(e){var t=this.store.fetcher.getHeader(e,"updates-via");return t&&t.length?t[0].trim():null},e.prototype.addDownstreamChangeListener=function(e,t){var n=this.patchControlFor(e);n.downstreamChangeListeners||(n.downstreamChangeListeners=[]),n.downstreamChangeListeners.push(t);var o=this;this.setRefreshHandler(e,function(e){o.reloadAndSync(e)})},e.prototype.reloadAndSync=function(e){var t=this.patchControlFor(e),n=this;if(t.reloading)return void console.log(" Already reloading - stop");t.reloading=!0;var o=1e3,r=function r(){console.log("try reload - timeout = "+o),n.reload(n.store,e,function(n,a,s){if(t.reloading=!1,n){if(t.downstreamChangeListeners)for(var i=0;i=0))return void console.log("just an echo");c.upstreamCount=0,console.log("Assume a real downstream change"),r.requestDownstreamAction(e,o)}}};return l(),!0},e.prototype.update=function(e,t,n){try{var o=this.store,r=e?e instanceof IndexedFormula?e.statements:e instanceof Array?e:[e]:[],a=t?t instanceof IndexedFormula?t.statements:t instanceof Array?t:[t]:[];if(!(r instanceof Array))throw new Error("Type Error "+("undefined"==typeof r?"undefined":_typeof(r))+": "+r);if(!(a instanceof Array))throw new Error("Type Error "+("undefined"==typeof a?"undefined":_typeof(a))+": "+a);if(0===r.length&&0===a.length)return n(null,!0);var s=r.length?r[0].why:a[0].why,i=this.patchControlFor(s),l=Date.now(),c=["subject","predicate","object","why"],d=["insert","delete"],h={delete:r,insert:a};d.map(function(e){h[e].map(function(e){if(!s.sameTerm(e.why))throw new Error("update: destination "+s+" inconsistent with delete quad "+e.why);c.map(function(t){if("undefined"==typeof e[t])throw new Error("update: undefined "+t+" of statement.")})})});var u=this.editable(s.uri,o);if(!u)throw new Error("Can't make changes in uneditable "+s);var p,f,m,g;if(u.indexOf("SPARQL")>=0){var w=[];r.length&&(w=this._statement_array_bnodes(r)),a.length&&(w=w.concat(this._statement_array_bnodes(a)));var y=this._bnode_context(w,s),v=this._context_where(y),_="";if(v.length){if(r.length){for(_+="DELETE { ",p=0;p=0){var T=o.any(s,this.ns.link("request"));if(!T)throw new Error("No record of our HTTP GET request for document: "+s);var b=o.any(T,this.ns.link("response"));if(!b)return null;var E=o.the(b,this.ns.httph("content-type")).value;for(f=o.statementsMatching(void 0,void 0,void 0,s).slice(),p=0;p=200&&N.status<300;if(e){for(var t=0;t=0))throw new Error("Unhandled edit method: '"+u+"' for "+s);try{for(console.log("Writing back to local file\n"),f=o.statementsMatching(void 0,void 0,void 0,s).slice(),p=0;p>>");var k=s.uri.slice(7),S=Components.classes["@mozilla.org/file/local;1"].createInstance(Components.interfaces.nsILocalFile);if(S.initWithPath(k),!S.exists())throw new Error("Rewriting file <"+s.uri+"> but it does not exist!");var q=Components.classes["@mozilla.org/network/file-output-stream;1"].createInstance(Components.interfaces.nsIFileOutputStream);for(q.init(S,42,parseInt("0666",8),0),q.write(m,m.length),q.close(),p=0;p\n")}}}catch(e){n(void 0,!1,"Exception in update: "+e)}},e.prototype.put=function(e,t,n,o){var r,a=this.store;if(("undefined"==typeof t?"undefined":_typeof(t))===_typeof(""))r=t;else{var s=Serializer(a);switch(s.suggestNamespaces(a.namespaces),s.setBase(e.uri),n){case"application/rdf+xml":r=s.statementsToXML(t);break;case"text/n3":case"text/turtle":case"application/x-turtle":case"application/n3":r=s.statementsToN3(t);break;default:throw new Error("Content-type "+n+" not supported for data PUT")}}var i=Util.XMLHTTPFactory();i.options={},i.onreadystatechange=function(){if(4===i.readyState){var n=!i.status||i.status>=200&&i.status<300;n&&"string"!=typeof t&&t.map(function(e){a.addStatement(e)}),n&&(delete a.fetcher.nonexistant[e.uri],delete a.fetcher.requested[e.uri]),o(e.uri,n,i.responseText,i)}},i.open("PUT",e.uri,!0),i.setRequestHeader("Content-type",n),i.send(r)},e.prototype.reload=function(e,t,n){var o=Date.now();e.fetcher.nowOrWhenFetched(t.uri,{force:!0,noMeta:!0,clearPreviousData:!0},function(e,r,a){if(e)if(a.onErrorWasCalled||200!==a.status)console.log(" Non-HTTP error reloading data! onErrorWasCalled="+a.onErrorWasCalled+" status: "+a.status),n(!1,"Non-HTTP error reloading data: "+r,a);else{var s=Date.now()-o;t.reloadTime_total||(t.reloadTime_total=0),t.reloadTime_count||(t.reloadTime_count=0),t.reloadTime_total+=s,t.reloadTime_count+=1,console.log(" Fetch took "+s+"ms, av. of "+t.reloadTime_count+" = "+t.reloadTime_total/t.reloadTime_count+"ms."),n(!0)}else console.log(" ERROR reloading data: "+r),n(!1,"Error reloading data: "+r,a)})},e.prototype.oldReload=function(e,t,n){var o=graph(),r=fetcher(o),a=Date.now();r.nowOrWhenFetched(t.uri,{force:!0,noMeta:!0,clearPreviousData:!0},function(r,s,i){if(r)if(i.onErrorWasCalled||200!==i.status)console.log(" Non-HTTP error reloading data! onErrorWasCalled="+i.onErrorWasCalled+" status: "+i.status),n(!1,"Non-HTTP error reloading data: "+s,i);else{var l=e.statementsMatching(void 0,void 0,void 0,t).slice(),c=o.statementsMatching(void 0,void 0,void 0,t).slice();console.log(" replacing "+l.length+" with "+c.length+" out of total statements "+e.statements.length),e.remove(l),e.add(c);var d=Date.now()-a;0===c.length&&console.log("????????????????? 0000000"),t.reloadTime_total||(t.reloadTime_total=0),t.reloadTime_count||(t.reloadTime_count=0),t.reloadTime_total+=d,t.reloadTime_count+=1,console.log(" fetch took "+d+"ms, av. of "+t.reloadTime_count+" = "+t.reloadTime_total/t.reloadTime_count+"ms."),n(!0)}else console.log(" ERROR reloading data: "+s),n(!1,"Error reloading data: "+s,i)})},e}();module.exports=UpdateManager; },{"./data-factory":46,"./fetcher":49,"./indexed-formula":51,"./namespace":57,"./serializer":66,"./uri":71,"./util":72}],70:[function(require,module,exports){ "use strict";function _classCallCheck(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}var _createClass=function(){function e(e,t){for(var n=0;n0&&(r=r.slice(0,u)),0===e.length)return r;if(0===e.indexOf("#"))return r+e;if(o=e.indexOf(":"),o>=0)return e;if(n=r.indexOf(":"),0===r.length)return e;if(n<0)return alert("Invalid base: "+r+" in join with given: "+e),e;if(t=r.slice(0,+n+1||9e9),0===e.indexOf("//"))return t+e;if(r.indexOf("//",n)===n+1){if(i=r.indexOf("/",n+3),i<0)return r.length-n-3>0?r+"/"+e:t+e}else if(i=r.indexOf("/",n+1),i<0)return r.length-n-1>0?r+"/"+e:t+e;if(0===e.indexOf("/"))return r.slice(0,i)+e;if(l=r.slice(i),f=l.lastIndexOf("/"),f<0)return t+e;for(f>=0&&f0&&"/"!==r[t-1];)t--;if(t<3)return r;if(e.indexOf("//",t-2)>0||r.indexOf("//",t-2)>0)return r;if(e.indexOf(":",t)>0)return r;for(u=0,s=e.slice(t),d=0,l=s.length;d0)for(a=1,x=u;x>=1?a<=x:a>=x;x>=1?++a:--a)p+="../";return p+r.slice(t)}var alert=alert||console.log;module.exports.docpart=docpart,module.exports.document=document,module.exports.hostpart=hostpart,module.exports.join=join,module.exports.protocol=protocol,module.exports.refTo=refTo;var namedNode=require("./data-factory").namedNode; },{"./data-factory":46}],72:[function(require,module,exports){ "use strict";function ajarHandleNewTerm(e,t,r){var a=null;if("undefined"!=typeof e.fetcher&&(a=e.fetcher,"NamedNode"===t.termType)){var o,n=docpart(t.uri);if(t.uri.indexOf("#")<0){if(stringStartsWith(t.uri,"http://dbpedia.org/resource/Category:"))return;stringStartsWith(t.uri,"http://purl.org/dc/elements/1.1/")||stringStartsWith(t.uri,"http://purl.org/dc/terms/")?o="http://dublincore.org/2005/06/13/dcq":stringStartsWith(t.uri,"http://xmlns.com/wot/0.1/")?o="http://xmlns.com/wot/0.1/index.rdf":stringStartsWith(t.uri,"http://web.resource.org/cc/")&&(o="http://web.resource.org/cc/schema.rdf")}o&&(n=o),a&&"unrequested"!==a.getState(n)||(o&&log.warn("Assuming server still broken, faking redirect of <"+t.uri+"> to <"+n+">"),a.requestURI(n,r))}}function arrayIndexOf(e,t,r){r||(r=0);var a=e.length;for(r<0&&(r=a+r);r=0;r--)e.callbacks[t[r]]=[];e.addHook=function(t){e.callbacks[t]||(e.callbacks[t]=[])},e.addCallback=function(t,r){e.callbacks[t].push(r)},e.removeCallback=function(t,r){for(var a=0;a=0;a--)e.callbacks[t][a].apply(e,r)&&o.push(e.callbacks[t][a]);for(a=o.length-1;a>=0;a--)n.push(o[a]);for(a=s;a=0;o--){var c=e.attributes[o];if(!(a.length>0&&a[c.name]||/^\d+$/.test(c.name))){if("class"===c.name&&"replaceClassItemWith"in t&&c.value.split(" ").indexOf(t.replaceClassItemWith.source)>-1){var u=new RegExp(t.replaceClassItemWith.source,"g");c.value=c.value.replace(u,t.replaceClassItemWith.target).trim()}"class"===c.name&&"skipClassWithValue"in t&&t.skipClassWithValue===c.value||l.push(c.name+"='"+c.value.replace(/&/g,"&").replace(//g,">").replace(/'/g,""")+"'")}}if(l.length>0&&("sortAttributes"in t&&t.sortAttributes&&l.sort(function(e,t){return e.toLowerCase().localeCompare(t.toLowerCase())}),n+=" "+l.join(" ")),r[i])n+=" />";else{for(n+=">",n+="html"===i?"\n ":"",s.push("style"===i||"script"===i),o=0;o\n":""}}}else if(8===e.nodeType)n+="";else if(3===e.nodeType||4===e.nodeType){var p=e.nodeValue.replace(/\n+$/,"");n+=s[s.length-1]?p:p.replace(/&/g,"&").replace(//g,">")}else console.log("Warning; Cannot handle serialising nodes of type: "+e.nodeType),console.log(e);return n}function dtstamp(){var e=new Date,t=e.getYear()+1900,r=e.getMonth()+1,a=e.getDate(),o=e.getUTCHours(),n=e.getUTCMinutes(),s=e.getSeconds();return r<10&&(r="0"+r),a<10&&(a="0"+a),o<10&&(o="0"+o),n<10&&(n="0"+n),s<10&&(s="0"+s),t+"-"+r+"-"+a+"T"+o+":"+n+":"+s+"Z"}function getHTTPHeaders(e){for(var t,r=e.getAllResponseHeaders().split("\n"),a={},o=0;o0){var n=r[o].split(": ");"undefined"==typeof n[1]?a[t]+="\n"+n[0]:(t=n[0].toLowerCase(),a[t]=n[1])}return a}function heavyCompare(e,t,r){var a=function(e){return"BlankNode"===e.termType?null:e},o=function(t){var o=r.statementsMatching(e).map(function(e){return""+a(e.subject)+" "+a(e.predicate)+" "+a(e.object)}).concat(r.statementsMatching(void 0,void 0,e).map(function(e){return""+a(e.subject)+" "+a(e.predicate)+" "+a(e.object)}));return o.sort(),o.join("\n")};return"BlankNode"===e.termType||"BlankNode"===t.termType?0===e.compareTerm(t)?0:o(e)>o(t)?1:o(e)