@semapps/semantic-data-provider 0.4.6 → 0.4.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs.js +1 -1
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.es.js +1 -1
- package/dist/index.es.js.map +1 -1
- package/package.json +2 -2
package/dist/index.es.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import e from"jsonld";import t from"speakingurl";import r,{triple as n,variable as o,namedNode as a}from"@rdfjs/data-model";import i from"crypto";import{fetchUtils as c,DataProviderContext as s,useQueryWithStore as u,ArrayInput as f,SimpleFormIterator as l,TextInput as p}from"react-admin";import d,{useContext as h,useMemo as y,useCallback as v,useState as g,useEffect as m}from"react";import{makeStyles as b}from"@material-ui/core/styles";function w(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function x(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?w(Object(r),!0).forEach((function(t){E(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):w(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}function k(){
|
|
2
2
|
/*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */
|
|
3
|
-
k=function(){return e};var e={},t=Object.prototype,r=t.hasOwnProperty,n="function"==typeof Symbol?Symbol:{},o=n.iterator||"@@iterator",a=n.asyncIterator||"@@asyncIterator",i=n.toStringTag||"@@toStringTag";function c(e,t,r){return Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}),e[t]}try{c({},"")}catch(e){c=function(e,t,r){return e[t]=r}}function s(e,t,r,n){var o=t&&t.prototype instanceof l?t:l,a=Object.create(o.prototype),i=new O(n||[]);return a._invoke=function(e,t,r){var n="suspendedStart";return function(o,a){if("executing"===n)throw new Error("Generator is already running");if("completed"===n){if("throw"===o)throw a;return E()}for(r.method=o,r.arg=a;;){var i=r.delegate;if(i){var c=w(i,r);if(c){if(c===f)continue;return c}}if("next"===r.method)r.sent=r._sent=r.arg;else if("throw"===r.method){if("suspendedStart"===n)throw n="completed",r.arg;r.dispatchException(r.arg)}else"return"===r.method&&r.abrupt("return",r.arg);n="executing";var s=u(e,t,r);if("normal"===s.type){if(n=r.done?"completed":"suspendedYield",s.arg===f)continue;return{value:s.arg,done:r.done}}"throw"===s.type&&(n="completed",r.method="throw",r.arg=s.arg)}}}(e,r,i),a}function u(e,t,r){try{return{type:"normal",arg:e.call(t,r)}}catch(e){return{type:"throw",arg:e}}}e.wrap=s;var f={};function l(){}function p(){}function d(){}var h={};c(h,o,(function(){return this}));var y=Object.getPrototypeOf,v=y&&y(y(j([])));v&&v!==t&&r.call(v,o)&&(h=v);var g=d.prototype=l.prototype=Object.create(h);function m(e){["next","throw","return"].forEach((function(t){c(e,t,(function(e){return this._invoke(t,e)}))}))}function b(e,t){var n;this._invoke=function(o,a){function i(){return new t((function(n,i){!function n(o,a,i,c){var s=u(e[o],e,a);if("throw"!==s.type){var f=s.arg,l=f.value;return l&&"object"==typeof l&&r.call(l,"__await")?t.resolve(l.__await).then((function(e){n("next",e,i,c)}),(function(e){n("throw",e,i,c)})):t.resolve(l).then((function(e){f.value=e,i(f)}),(function(e){return n("throw",e,i,c)}))}c(s.arg)}(o,a,n,i)}))}return n=n?n.then(i,i):i()}}function w(e,t){var r=e.iterator[t.method];if(void 0===r){if(t.delegate=null,"throw"===t.method){if(e.iterator.return&&(t.method="return",t.arg=void 0,w(e,t),"throw"===t.method))return f;t.method="throw",t.arg=new TypeError("The iterator does not provide a 'throw' method")}return f}var n=u(r,e.iterator,t.arg);if("throw"===n.type)return t.method="throw",t.arg=n.arg,t.delegate=null,f;var o=n.arg;return o?o.done?(t[e.resultName]=o.value,t.next=e.nextLoc,"return"!==t.method&&(t.method="next",t.arg=void 0),t.delegate=null,f):o:(t.method="throw",t.arg=new TypeError("iterator result is not an object"),t.delegate=null,f)}function x(e){var t={tryLoc:e[0]};1 in e&&(t.catchLoc=e[1]),2 in e&&(t.finallyLoc=e[2],t.afterLoc=e[3]),this.tryEntries.push(t)}function S(e){var t=e.completion||{};t.type="normal",delete t.arg,e.completion=t}function O(e){this.tryEntries=[{tryLoc:"root"}],e.forEach(x,this),this.reset(!0)}function j(e){if(e){var t=e[o];if(t)return t.call(e);if("function"==typeof e.next)return e;if(!isNaN(e.length)){var n=-1,a=function t(){for(;++n<e.length;)if(r.call(e,n))return t.value=e[n],t.done=!1,t;return t.value=void 0,t.done=!0,t};return a.next=a}}return{next:E}}function E(){return{value:void 0,done:!0}}return p.prototype=d,c(g,"constructor",d),c(d,"constructor",p),p.displayName=c(d,i,"GeneratorFunction"),e.isGeneratorFunction=function(e){var t="function"==typeof e&&e.constructor;return!!t&&(t===p||"GeneratorFunction"===(t.displayName||t.name))},e.mark=function(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,d):(e.__proto__=d,c(e,i,"GeneratorFunction")),e.prototype=Object.create(g),e},e.awrap=function(e){return{__await:e}},m(b.prototype),c(b.prototype,a,(function(){return this})),e.AsyncIterator=b,e.async=function(t,r,n,o,a){void 0===a&&(a=Promise);var i=new b(s(t,r,n,o),a);return e.isGeneratorFunction(r)?i:i.next().then((function(e){return e.done?e.value:i.next()}))},m(g),c(g,i,"Generator"),c(g,o,(function(){return this})),c(g,"toString",(function(){return"[object Generator]"})),e.keys=function(e){var t=[];for(var r in e)t.push(r);return t.reverse(),function r(){for(;t.length;){var n=t.pop();if(n in e)return r.value=n,r.done=!1,r}return r.done=!0,r}},e.values=j,O.prototype={constructor:O,reset:function(e){if(this.prev=0,this.next=0,this.sent=this._sent=void 0,this.done=!1,this.delegate=null,this.method="next",this.arg=void 0,this.tryEntries.forEach(S),!e)for(var t in this)"t"===t.charAt(0)&&r.call(this,t)&&!isNaN(+t.slice(1))&&(this[t]=void 0)},stop:function(){this.done=!0;var e=this.tryEntries[0].completion;if("throw"===e.type)throw e.arg;return this.rval},dispatchException:function(e){if(this.done)throw e;var t=this;function n(r,n){return i.type="throw",i.arg=e,t.next=r,n&&(t.method="next",t.arg=void 0),!!n}for(var o=this.tryEntries.length-1;o>=0;--o){var a=this.tryEntries[o],i=a.completion;if("root"===a.tryLoc)return n("end");if(a.tryLoc<=this.prev){var c=r.call(a,"catchLoc"),s=r.call(a,"finallyLoc");if(c&&s){if(this.prev<a.catchLoc)return n(a.catchLoc,!0);if(this.prev<a.finallyLoc)return n(a.finallyLoc)}else if(c){if(this.prev<a.catchLoc)return n(a.catchLoc,!0)}else{if(!s)throw new Error("try statement without catch or finally");if(this.prev<a.finallyLoc)return n(a.finallyLoc)}}}},abrupt:function(e,t){for(var n=this.tryEntries.length-1;n>=0;--n){var o=this.tryEntries[n];if(o.tryLoc<=this.prev&&r.call(o,"finallyLoc")&&this.prev<o.finallyLoc){var a=o;break}}a&&("break"===e||"continue"===e)&&a.tryLoc<=t&&t<=a.finallyLoc&&(a=null);var i=a?a.completion:{};return i.type=e,i.arg=t,a?(this.method="next",this.next=a.finallyLoc,f):this.complete(i)},complete:function(e,t){if("throw"===e.type)throw e.arg;return"break"===e.type||"continue"===e.type?this.next=e.arg:"return"===e.type?(this.rval=this.arg=e.arg,this.method="return",this.next="end"):"normal"===e.type&&t&&(this.next=t),f},finish:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var r=this.tryEntries[t];if(r.finallyLoc===e)return this.complete(r.completion,r.afterLoc),S(r),f}},catch:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var r=this.tryEntries[t];if(r.tryLoc===e){var n=r.completion;if("throw"===n.type){var o=n.arg;S(r)}return o}}throw new Error("illegal catch attempt")},delegateYield:function(e,t,r){return this.delegate={iterator:j(e),resultName:t,nextLoc:r},"next"===this.method&&(this.arg=void 0),f}},e}function S(e){return(S="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function O(e,t,r,n,o,a,i){try{var c=e[a](i),s=c.value}catch(e){return void r(e)}c.done?t(s):Promise.resolve(s).then(n,o)}function j(e){return function(){var t=this,r=arguments;return new Promise((function(n,o){var a=e.apply(t,r);function i(e){O(a,n,o,i,c,"next",e)}function c(e){O(a,n,o,i,c,"throw",e)}i(void 0)}))}}function E(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function A(){return(A=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(e[n]=r[n])}return e}).apply(this,arguments)}function C(e,t){if(null==e)return{};var r,n,o=function(e,t){if(null==e)return{};var r,n,o={},a=Object.keys(e);for(n=0;n<a.length;n++)r=a[n],t.indexOf(r)>=0||(o[r]=e[r]);return o}(e,t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(n=0;n<a.length;n++)r=a[n],t.indexOf(r)>=0||Object.prototype.propertyIsEnumerable.call(e,r)&&(o[r]=e[r])}return o}function _(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var r=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null==r)return;var n,o,a=[],i=!0,c=!1;try{for(r=r.call(e);!(i=(n=r.next()).done)&&(a.push(n.value),!t||a.length!==t);i=!0);}catch(e){c=!0,o=e}finally{try{i||null==r.return||r.return()}finally{if(c)throw o}}return a}(e,t)||P(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function L(e){return function(e){if(Array.isArray(e))return N(e)}(e)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||P(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function P(e,t){if(e){if("string"==typeof e)return N(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?N(e,t):void 0}}function N(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=new Array(t);r<t;r++)n[r]=e[r];return n}function T(e,t){var r="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!r){if(Array.isArray(e)||(r=P(e))||t&&e&&"number"==typeof e.length){r&&(e=r);var n=0,o=function(){};return{s:o,n:function(){return n>=e.length?{done:!0}:{done:!1,value:e[n++]}},e:function(e){throw e},f:o}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var a,i=!0,c=!1;return{s:function(){r=r.call(e)},n:function(){var e=r.next();return i=e.done,e},e:function(e){c=!0,a=e},f:function(){try{i||null==r.return||r.return()}finally{if(c)throw a}}}}var U="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function q(e,t){return e(t={exports:{}},t.exports),t.exports}var I=q((function(e){var t,r;t=U,r=function(){function e(e){var t=[];if(0===e.length)return"";if("string"!=typeof e[0])throw new TypeError("Url must be a string. Received "+e[0]);if(e[0].match(/^[^/:]+:\/*$/)&&e.length>1){var r=e.shift();e[0]=r+e[0]}e[0].match(/^file:\/\/\//)?e[0]=e[0].replace(/^([^/:]+):\/*/,"$1:///"):e[0]=e[0].replace(/^([^/:]+):\/*/,"$1://");for(var n=0;n<e.length;n++){var o=e[n];if("string"!=typeof o)throw new TypeError("Url must be a string. Received "+o);""!==o&&(n>0&&(o=o.replace(/^[\/]+/,"")),o=n<e.length-1?o.replace(/[\/]+$/,""):o.replace(/[\/]+$/,"/"),t.push(o))}var a=t.join("/"),i=(a=a.replace(/\/(\?|&|#[^!])/g,"$1")).split("?");return a=i.shift()+(i.length>0?"?":"")+i.join("&")}return function(){return e("object"==typeof arguments[0]?arguments[0]:[].slice.call(arguments))}},e.exports?e.exports=r():t.urljoin=r()})),M=function(){var t=j(k().mark((function t(r,n){var o,a,i,c;return k().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return o=n.httpClient,a=n.jsonContext,t.next=3,o(r);case 3:if(i=t.sent,c=i.json){t.next=7;break}throw new Error("Not a valid JSON: "+r);case 7:if(c.id=c.id||c["@id"],c["@context"]===a){t.next=12;break}return t.next=11,e.compact(c,a);case 11:c=t.sent;case 12:return t.abrupt("return",c);case 13:case"end":return t.stop()}}),t)})));return function(e,r){return t.apply(this,arguments)}}(),B=function(e){return function(){var t=j(k().mark((function t(r,n){var o,a,i,c,s,u,f,l;return k().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(a=e.resources,i=a[r]){t.next=4;break}throw new Error("Resource ".concat(r," is not mapped in resources file"));case 4:return t.next=6,M(n.id,e);case 6:if(c=t.sent,null!==(o=i.list)&&void 0!==o&&o.forceArray){u=T(null===(s=i.list)||void 0===s?void 0:s.forceArray);try{for(u.s();!(f=u.n()).done;)l=f.value,c[l]&&!Array.isArray(c[l])&&(c[l]=[c[l]])}catch(e){u.e(e)}finally{u.f()}}return t.abrupt("return",{data:c});case 9:case"end":return t.stop()}}),t)})));return function(e,r){return t.apply(this,arguments)}}()},D=function(e){return e&&e.rawFile&&e.rawFile instanceof File},F=function(e){var t=Object.keys(e.dataServers).find((function(t){return e.dataServers[t].uploadsContainer}));if(t)return I(e.dataServers[t].baseUrl,e.dataServers[t].uploadsContainer)},R=function(){var e=j(k().mark((function e(r,n){var o,a;return k().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(o=F(n)){e.next=3;break}throw new Error("You must define an uploadsContainer in one of the server's configuration");case 3:return e.next=5,n.httpClient(o,{method:"POST",body:r,headers:new Headers({Slug:(i=r.name,c=void 0,s=void 0,c="",s=i.split("."),s.length>1&&(c=s.pop(),i=s.join(".")),t(i,{lang:"fr"})+"."+c),"Content-Type":r.type})});case 5:if(201!==(a=e.sent).status){e.next=8;break}return e.abrupt("return",a.headers.get("Location"));case 8:case"end":return e.stop()}var i,c,s}),e)})));return function(t,r){return e.apply(this,arguments)}}(),H=function(){var e=j(k().mark((function e(t,r){var n,o;return k().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:e.t0=k().keys(t);case 1:if((e.t1=e.t0()).done){e.next=22;break}if(n=e.t1.value,!t.hasOwnProperty(n)){e.next=20;break}if(!Array.isArray(t[n])){e.next=16;break}o=0;case 6:if(!(o<t[n].length)){e.next=14;break}if(!D(t[n][o])){e.next=11;break}return e.next=10,R(t[n][o].rawFile,r);case 10:t[n][o]=e.sent;case 11:o++,e.next=6;break;case 14:e.next=20;break;case 16:if(!D(t[n])){e.next=20;break}return e.next=19,R(t[n].rawFile,r);case 19:t[n]=e.sent;case 20:e.next=1;break;case 22:return e.abrupt("return",t);case 23:case"end":return e.stop()}}),e)})));return function(t,r){return e.apply(this,arguments)}}(),W=function(e,t){return Object.keys(t).find((function(r){return t[r][e]}))},z=function(e,t){switch(e){case"@default":return W("default",t);case"@pod":return W("pod",t);case"@authServer":return W("authServer",t);default:return e}},G=function(e,t,r){var n={},o=[];return t=function(e,t){if(Array.isArray(e))return e.includes("@all")?Object.keys(t):e.map((function(e){return z(e,t)}));if("string"==typeof e){if("@all"===e)return Object.keys(t);if("@remote"===e){var r=W("default",t);return Object.keys(t).filter((function(e){return e!==r}))}return[z(e,t)]}return!1}(t,r),Object.keys(r).forEach((function(a){Object.keys(r[a].containers).forEach((function(i){t&&!t.includes(i)||Object.keys(r[a].containers[i]).forEach((function(t){e.includes(t)&&r[a].containers[i][t].map((function(e){var t=I(r[i].baseUrl,e);o.includes(t)||(o.push(t),n[a]||(n[a]=[]),n[a].push(t))}))}))}))})),n},J=function(e){return function(){var t=j(k().mark((function t(r,n){var o,a,i,c,s,u,f,l,p,d,h,y,v,g,m,b;return k().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(a=e.dataServers,i=e.resources,c=e.httpClient,s=e.jsonContext,u=i[r],f=new Headers,null===(o=u.create)||void 0===o||!o.container){t.next=9;break}p=Object.keys(u.create.container)[0],l=I(a[p].baseUrl,Object.values(u.create.container)[0]),t.next=19;break;case 9:if(p=(null===(d=u.create)||void 0===d?void 0:d.server)||Object.keys(a).find((function(e){return!0===a[e].default}))){t.next=12;break}throw new Error("You must define a server for the creation, or a container, or a default server");case 12:if(h=G(u.types,[p],a),(y=Object.keys(h))&&0!==y.length){t.next=16;break}throw new Error("No container with types ".concat(JSON.stringify(u.types)," found on server ").concat(p));case 16:if(!(y.length>1||h[y[0]].length>1)){t.next=18;break}throw new Error("More than one container detected with types ".concat(JSON.stringify(u.types)," on server ").concat(p));case 18:l=h[y[0]][0];case 19:if(!n.data){t.next=34;break}return null!==(v=u.fieldsMapping)&&void 0!==v&&v.title&&(Array.isArray(u.fieldsMapping.title)?f.set("Slug",u.fieldsMapping.title.map((function(e){return n.data[e]})).join(" ")):f.set("Slug",n.data[u.fieldsMapping.title])),t.next=23,H(n.data,e);case 23:return n.data=t.sent,t.next=26,c(l,{method:"POST",headers:f,body:JSON.stringify(x({"@context":s,"@type":u.types},n.data))});case 26:return g=t.sent,m=g.headers,b=m.get("Location"),t.next=31,B(e)(r,{id:b});case 31:return t.abrupt("return",t.sent);case 34:if(!n.id){t.next=41;break}return f.set("Content-Type","application/sparql-update"),t.next=38,c(l,{method:"PATCH",headers:f,body:"\n PREFIX ldp: <http://www.w3.org/ns/ldp#>\n INSERT DATA { <".concat(l,"> ldp:contains <").concat(n.id,">. };\n ")});case 38:return t.next=40,B(e)(r,{id:n.id});case 40:return t.abrupt("return",t.sent);case 41:case"end":return t.stop()}}),t)})));return function(e,r){return t.apply(this,arguments)}}()},$=function(e){return function(){var t=j(k().mark((function t(r,n){var o;return k().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return o=e.httpClient,t.next=3,o(n.id,{method:"DELETE"});case 3:return t.abrupt("return",{data:{id:n.id}});case 4:case"end":return t.stop()}}),t)})));return function(e,r){return t.apply(this,arguments)}}()},Y=function(e){return function(){var t=j(k().mark((function t(r,n){var o,a,i,c,s;return k().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:o=e.httpClient,a=[],i=T(n.ids),t.prev=3,i.s();case 5:if((c=i.n()).done){t.next=17;break}return s=c.value,t.prev=7,t.next=10,o(s,{method:"DELETE"});case 10:a.push(s),t.next=15;break;case 13:t.prev=13,t.t0=t.catch(7);case 15:t.next=5;break;case 17:t.next=22;break;case 19:t.prev=19,t.t1=t.catch(3),i.e(t.t1);case 22:return t.prev=22,i.f(),t.finish(22);case 25:return t.abrupt("return",{data:a});case 26:case"end":return t.stop()}}),t,null,[[3,19,22,25],[7,13]])})));return function(e,r){return t.apply(this,arguments)}}()},V=function(e){return function(){return e.dataServers}},X=function(e){return function(){return e.resources}};var K=function(){var t=j(k().mark((function t(r,n,o,a){var i,c,s,u,f,l,p;return k().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return i=a.httpClient,c=a.jsonContext,s=Object.keys(r).reduce((function(e,t){return x(x({},e),Object.fromEntries(r[t].map((function(e){return[e,t]}))))}),{}),u=Object.keys(s).map((function(t){return i(t).then((function(t){var r=t.json;return r["@context"]!==c?e.compact(r,c):r})).then((function(e){if(r="ldp:Container",o=(n=e).type||n["@type"],Array.isArray(o)?o.includes(r):o===r)return e["ldp:contains"];throw new Error(t+" is not a LDP container");var r,n,o}))})),t.next=5,Promise.all(u);case 5:if(0!==(f=t.sent).length){t.next=10;break}return t.abrupt("return",{data:[],total:0});case 10:return f=(l=[].concat).apply.apply(l,L(f)),p=f.map((function(e){return e.id=e.id||e["@id"],e})),o.filter&&(o.filter.a&&(o.filter.type=o.filter.a,delete o.filter.a),Object.keys(o.filter).length>0&&(p=p.filter((function(e){return Object.entries(o.filter).some((function(t){var r=_(t,2),n=r[0],o=r[1];return"q"==n?Object.entries(e).some((function(e){var t=_(e,2);t[0];var r,n=t[1];return(null==(r=n)||"object"!=typeof r||!1!==Array.isArray(r))&&(Array.isArray(n)?n:[n]).some((function(e){if("string"==typeof e||e instanceof String)return e.toLowerCase().normalize("NFD").includes(o.toLowerCase().normalize("NFD"))}))})):!!e[n]&&(Array.isArray(e[n])?e[n].some((function(e){return e.includes(o)})):e[n].includes(o))}))})))),o.sort&&(p=p.sort((function(e,t){return!e[o.sort.field]||!t[o.sort.field]||("ASC"===o.sort.order?e[o.sort.field].localeCompare(t[o.sort.field]):t[o.sort.field].localeCompare(e[o.sort.field]))}))),o.pagination&&(p=p.slice((o.pagination.page-1)*o.pagination.perPage,o.pagination.page*o.pagination.perPage)),t.abrupt("return",{data:p,total:f.length});case 16:case"end":return t.stop()}}),t)})));return function(e,r,n,o){return t.apply(this,arguments)}}(),Q=function(e){var t,r={};if(e){var n,o=T(e);try{for(o.s();!(n=o.n()).done;){var a=n.value;t=a.includes("/")?a.split("/").reverse():[a],r=x(x({},r),t.reduce((function(e,t){return E({},t,x({"@embed":"@last"},e))}),{}))}}catch(e){o.e(e)}finally{o.f()}return r}},Z=function(e,t){if(e.startsWith("http://")||e.startsWith("https://"))return e;if("a"===e)return"http://www.w3.org/1999/02/22-rdf-syntax-ns#type";var r=_(e.split(":"),2),n=r[0],o=r[1];if(o){var a=t.find((function(e){return e.prefix===n}));if(a)return a.url+o;throw new Error("No ontology found with prefix "+n)}throw new Error('The value "'.concat(e,'" is not correct. It must include a prefix or be a full URI.'))},ee=n(o("s1"),a("http://www.w3.org/1999/02/22-rdf-syntax-ns#type"),o("type")),te=function(e,t){var r,i;return e?(r=(i=e,i?Array.isArray(i)?i:[i]:[]).map((function(e,r){return n(o("s1"),a(Z(e,t)),o("o"+(r+1)))})),{construct:[ee].concat(L(r)),where:[ee].concat(L(r.map((function(e){return{type:"optional",patterns:[e]}}))))}):{construct:r=[n(o("s1"),o("p1"),o("o1"))],where:r}},re=q((function(e,t){var r;e.exports=r=r||function(e,t){var r;if("undefined"!=typeof window&&window.crypto&&(r=window.crypto),"undefined"!=typeof self&&self.crypto&&(r=self.crypto),"undefined"!=typeof globalThis&&globalThis.crypto&&(r=globalThis.crypto),!r&&"undefined"!=typeof window&&window.msCrypto&&(r=window.msCrypto),!r&&void 0!==U&&U.crypto&&(r=U.crypto),!r)try{r=i}catch(e){}var n=function(){if(r){if("function"==typeof r.getRandomValues)try{return r.getRandomValues(new Uint32Array(1))[0]}catch(e){}if("function"==typeof r.randomBytes)try{return r.randomBytes(4).readInt32LE()}catch(e){}}throw new Error("Native crypto module could not be used to get secure random number.")},o=Object.create||function(){function e(){}return function(t){var r;return e.prototype=t,r=new e,e.prototype=null,r}}(),a={},c=a.lib={},s=c.Base={extend:function(e){var t=o(this);return e&&t.mixIn(e),t.hasOwnProperty("init")&&this.init!==t.init||(t.init=function(){t.$super.init.apply(this,arguments)}),t.init.prototype=t,t.$super=this,t},create:function(){var e=this.extend();return e.init.apply(e,arguments),e},init:function(){},mixIn:function(e){for(var t in e)e.hasOwnProperty(t)&&(this[t]=e[t]);e.hasOwnProperty("toString")&&(this.toString=e.toString)},clone:function(){return this.init.prototype.extend(this)}},u=c.WordArray=s.extend({init:function(e,t){e=this.words=e||[],this.sigBytes=null!=t?t:4*e.length},toString:function(e){return(e||l).stringify(this)},concat:function(e){var t=this.words,r=e.words,n=this.sigBytes,o=e.sigBytes;if(this.clamp(),n%4)for(var a=0;a<o;a++){var i=r[a>>>2]>>>24-a%4*8&255;t[n+a>>>2]|=i<<24-(n+a)%4*8}else for(var c=0;c<o;c+=4)t[n+c>>>2]=r[c>>>2];return this.sigBytes+=o,this},clamp:function(){var t=this.words,r=this.sigBytes;t[r>>>2]&=4294967295<<32-r%4*8,t.length=e.ceil(r/4)},clone:function(){var e=s.clone.call(this);return e.words=this.words.slice(0),e},random:function(e){for(var t=[],r=0;r<e;r+=4)t.push(n());return new u.init(t,e)}}),f=a.enc={},l=f.Hex={stringify:function(e){for(var t=e.words,r=e.sigBytes,n=[],o=0;o<r;o++){var a=t[o>>>2]>>>24-o%4*8&255;n.push((a>>>4).toString(16)),n.push((15&a).toString(16))}return n.join("")},parse:function(e){for(var t=e.length,r=[],n=0;n<t;n+=2)r[n>>>3]|=parseInt(e.substr(n,2),16)<<24-n%8*4;return new u.init(r,t/2)}},p=f.Latin1={stringify:function(e){for(var t=e.words,r=e.sigBytes,n=[],o=0;o<r;o++){var a=t[o>>>2]>>>24-o%4*8&255;n.push(String.fromCharCode(a))}return n.join("")},parse:function(e){for(var t=e.length,r=[],n=0;n<t;n++)r[n>>>2]|=(255&e.charCodeAt(n))<<24-n%4*8;return new u.init(r,t)}},d=f.Utf8={stringify:function(e){try{return decodeURIComponent(escape(p.stringify(e)))}catch(e){throw new Error("Malformed UTF-8 data")}},parse:function(e){return p.parse(unescape(encodeURIComponent(e)))}},h=c.BufferedBlockAlgorithm=s.extend({reset:function(){this._data=new u.init,this._nDataBytes=0},_append:function(e){"string"==typeof e&&(e=d.parse(e)),this._data.concat(e),this._nDataBytes+=e.sigBytes},_process:function(t){var r,n=this._data,o=n.words,a=n.sigBytes,i=this.blockSize,c=a/(4*i),s=(c=t?e.ceil(c):e.max((0|c)-this._minBufferSize,0))*i,f=e.min(4*s,a);if(s){for(var l=0;l<s;l+=i)this._doProcessBlock(o,l);r=o.splice(0,s),n.sigBytes-=f}return new u.init(r,f)},clone:function(){var e=s.clone.call(this);return e._data=this._data.clone(),e},_minBufferSize:0});c.Hasher=h.extend({cfg:s.extend(),init:function(e){this.cfg=this.cfg.extend(e),this.reset()},reset:function(){h.reset.call(this),this._doReset()},update:function(e){return this._append(e),this._process(),this},finalize:function(e){return e&&this._append(e),this._doFinalize()},blockSize:16,_createHelper:function(e){return function(t,r){return new e.init(r).finalize(t)}},_createHmacHelper:function(e){return function(t,r){return new y.HMAC.init(e,r).finalize(t)}}});var y=a.algo={};return a}(Math)})),ne=q((function(e,t){var r;e.exports=(r=re,function(e){var t=r,n=t.lib,o=n.WordArray,a=n.Hasher,i=t.algo,c=[];!function(){for(var t=0;t<64;t++)c[t]=4294967296*e.abs(e.sin(t+1))|0}();var s=i.MD5=a.extend({_doReset:function(){this._hash=new o.init([1732584193,4023233417,2562383102,271733878])},_doProcessBlock:function(e,t){for(var r=0;r<16;r++){var n=t+r,o=e[n];e[n]=16711935&(o<<8|o>>>24)|4278255360&(o<<24|o>>>8)}var a=this._hash.words,i=e[t+0],s=e[t+1],d=e[t+2],h=e[t+3],y=e[t+4],v=e[t+5],g=e[t+6],m=e[t+7],b=e[t+8],w=e[t+9],x=e[t+10],k=e[t+11],S=e[t+12],O=e[t+13],j=e[t+14],E=e[t+15],A=a[0],C=a[1],_=a[2],L=a[3];A=u(A,C,_,L,i,7,c[0]),L=u(L,A,C,_,s,12,c[1]),_=u(_,L,A,C,d,17,c[2]),C=u(C,_,L,A,h,22,c[3]),A=u(A,C,_,L,y,7,c[4]),L=u(L,A,C,_,v,12,c[5]),_=u(_,L,A,C,g,17,c[6]),C=u(C,_,L,A,m,22,c[7]),A=u(A,C,_,L,b,7,c[8]),L=u(L,A,C,_,w,12,c[9]),_=u(_,L,A,C,x,17,c[10]),C=u(C,_,L,A,k,22,c[11]),A=u(A,C,_,L,S,7,c[12]),L=u(L,A,C,_,O,12,c[13]),_=u(_,L,A,C,j,17,c[14]),A=f(A,C=u(C,_,L,A,E,22,c[15]),_,L,s,5,c[16]),L=f(L,A,C,_,g,9,c[17]),_=f(_,L,A,C,k,14,c[18]),C=f(C,_,L,A,i,20,c[19]),A=f(A,C,_,L,v,5,c[20]),L=f(L,A,C,_,x,9,c[21]),_=f(_,L,A,C,E,14,c[22]),C=f(C,_,L,A,y,20,c[23]),A=f(A,C,_,L,w,5,c[24]),L=f(L,A,C,_,j,9,c[25]),_=f(_,L,A,C,h,14,c[26]),C=f(C,_,L,A,b,20,c[27]),A=f(A,C,_,L,O,5,c[28]),L=f(L,A,C,_,d,9,c[29]),_=f(_,L,A,C,m,14,c[30]),A=l(A,C=f(C,_,L,A,S,20,c[31]),_,L,v,4,c[32]),L=l(L,A,C,_,b,11,c[33]),_=l(_,L,A,C,k,16,c[34]),C=l(C,_,L,A,j,23,c[35]),A=l(A,C,_,L,s,4,c[36]),L=l(L,A,C,_,y,11,c[37]),_=l(_,L,A,C,m,16,c[38]),C=l(C,_,L,A,x,23,c[39]),A=l(A,C,_,L,O,4,c[40]),L=l(L,A,C,_,i,11,c[41]),_=l(_,L,A,C,h,16,c[42]),C=l(C,_,L,A,g,23,c[43]),A=l(A,C,_,L,w,4,c[44]),L=l(L,A,C,_,S,11,c[45]),_=l(_,L,A,C,E,16,c[46]),A=p(A,C=l(C,_,L,A,d,23,c[47]),_,L,i,6,c[48]),L=p(L,A,C,_,m,10,c[49]),_=p(_,L,A,C,j,15,c[50]),C=p(C,_,L,A,v,21,c[51]),A=p(A,C,_,L,S,6,c[52]),L=p(L,A,C,_,h,10,c[53]),_=p(_,L,A,C,x,15,c[54]),C=p(C,_,L,A,s,21,c[55]),A=p(A,C,_,L,b,6,c[56]),L=p(L,A,C,_,E,10,c[57]),_=p(_,L,A,C,g,15,c[58]),C=p(C,_,L,A,O,21,c[59]),A=p(A,C,_,L,y,6,c[60]),L=p(L,A,C,_,k,10,c[61]),_=p(_,L,A,C,d,15,c[62]),C=p(C,_,L,A,w,21,c[63]),a[0]=a[0]+A|0,a[1]=a[1]+C|0,a[2]=a[2]+_|0,a[3]=a[3]+L|0},_doFinalize:function(){var t=this._data,r=t.words,n=8*this._nDataBytes,o=8*t.sigBytes;r[o>>>5]|=128<<24-o%32;var a=e.floor(n/4294967296),i=n;r[15+(o+64>>>9<<4)]=16711935&(a<<8|a>>>24)|4278255360&(a<<24|a>>>8),r[14+(o+64>>>9<<4)]=16711935&(i<<8|i>>>24)|4278255360&(i<<24|i>>>8),t.sigBytes=4*(r.length+1),this._process();for(var c=this._hash,s=c.words,u=0;u<4;u++){var f=s[u];s[u]=16711935&(f<<8|f>>>24)|4278255360&(f<<24|f>>>8)}return c},clone:function(){var e=a.clone.call(this);return e._hash=this._hash.clone(),e}});function u(e,t,r,n,o,a,i){var c=e+(t&r|~t&n)+o+i;return(c<<a|c>>>32-a)+t}function f(e,t,r,n,o,a,i){var c=e+(t&n|r&~n)+o+i;return(c<<a|c>>>32-a)+t}function l(e,t,r,n,o,a,i){var c=e+(t^r^n)+o+i;return(c<<a|c>>>32-a)+t}function p(e,t,r,n,o,a,i){var c=e+(r^(t|~n))+o+i;return(c<<a|c>>>32-a)+t}t.MD5=a._createHelper(s),t.HmacMD5=a._createHmacHelper(s)}(Math),r.MD5)})),oe=function(e){return ne(e)},ae=function(e){return e.includes("/")&&e.split("/")[0]},ie=function(e){return e.includes("/")?e.split("/")[1]:e},ce=function(e){return e.map((function(t){var r=t.query,n=e.find((function(e){return t.parentNode===e.node}));return void 0!==n&&(r=r.concat(n.query[0])),{type:"bgp",triples:r}}))},se=function(e,t,r){var i=[],c=function(e){var t=[];if(e){var r,n=T(e);try{for(n.s();!(r=n.n()).done;){var o=r.value;if(o.includes("/"))for(var a=o.split("/"),i=1;i<=a.length;i++)t.push(a.slice(0,i).join("/"));else t.push(o)}}catch(e){n.e(e)}finally{n.f()}}return t}(e);if(c&&r&&r.length>0){var s,u=T(c);try{for(u.s();!(s=u.n()).done;){var f=s.value,l=ae(f),p=ie(f),d=oe(f),h=l?oe(l):"1",y=[n(o("s"+h),a(Z(p,r)),o("s"+d)),n(o("s"+d),o("p"+d),o("o"+d))];i.push({node:f,parentNode:l,query:y,filter:""})}}catch(e){u.e(e)}finally{u.f()}return{construct:i.length>0?i.map((function(e){return e.query})).reduce((function(e,t){return e.concat(t)})):null,where:{type:"union",patterns:[t.where].concat(L(ce(i)))}}}return{construct:"",where:""}},ue=r.literal,fe=r.namedNode,le=r.triple,pe=r.variable,de=new(0,require("sparqljs").Generator)({}),he=["q","sparqlWhere","blankNodes","_servers","_predicates"],ye=function(e){var t=e.containers,r=e.params.filter,n=e.blankNodes,o=e.predicates,a=e.ontologies,i=te(o,a),c={queryType:"CONSTRUCT",template:i.construct,where:[],type:"query",prefixes:Object.fromEntries(a.map((function(e){return[e.prefix,e.url]})))},s=[{type:"values",values:t.map((function(e){return{"?containerUri":fe(e)}}))},le(pe("containerUri"),fe("http://www.w3.org/ns/ldp#contains"),pe("s1")),{type:"filter",expression:{type:"operation",operator:"isiri",args:[pe("s1")]}}],u=[];if(r&&Object.keys(r).length>0){var f=r.sparqlWhere&&Object.keys(r.sparqlWhere).length>0,l=r.q&&r.q.length>0;f&&[].concat(r.sparqlWhere).forEach((function(e){u.push(e)})),l&&u.push({type:"group",patterns:[{queryType:"SELECT",variables:[pe("s1")],where:[le(pe("s1"),pe("p1"),pe("o1")),{type:"filter",expression:{type:"operation",operator:"isliteral",args:[pe("o1")]}},{type:"filter",expression:{type:"operation",operator:"regex",args:[{type:"operation",operator:"lcase",args:[{type:"operation",operator:"str",args:[pe("o1")]}]},ue(r.q.toLowerCase(),"",fe("http://www.w3.org/2001/XMLSchema#string"))]}}],type:"query"}]}),Object.entries(r).forEach((function(e){var t=_(e,2),r=t[0],n=t[1];he.includes(r)||u.unshift(le(pe("s1"),fe(Z(r,a)),fe(Z(n,a))))}))}var p=se(n,i,a);return p&&p.construct?(u=u.concat(p.where),c.template=c.template.concat(p.construct)):u.push(i.where),c.where.push({type:"union",patterns:[s,{type:"graph",name:fe("http://semapps.org/mirror"),patterns:s}]},{type:"union",patterns:[u,{type:"graph",name:fe("http://semapps.org/mirror"),patterns:u}]}),de.stringify(c)},ve=function(e,t){for(var r=[],n=0,o=Object.keys(t);n<o.length;n++){var a=o[n];if(t[a].blankNodes)for(var i=0,c=Object.keys(t[a].blankNodes);i<c.length;i++){var s=c[i];e.includes(s)&&r.push.apply(r,L(t[a].blankNodes[s]))}}return L(new Set(r))},ge=["@context"],me=function(e,t){switch(S(e)){case"string":return e.localeCompare(t);case"number":case"bigint":return e-t;default:return 0}},be=function(){var t=j(k().mark((function t(r,n,o,a){var i,c,s,u,f,l,p,d,h,y;return k().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return i=a.dataServers,c=a.resources,s=a.httpClient,u=a.jsonContext,f=a.ontologies,l=c[n],p=Object.keys(r).map((function(t){return new Promise((function(n,a){var c,p,d,h,y,v,g=(null===(c=o.filter)||void 0===c?void 0:c.blankNodes)||(null===(p=l.list)||void 0===p?void 0:p.blankNodes)||ve(r[t],i),m=(null===(d=o.filter)||void 0===d?void 0:d._predicates)||(null===(h=l.list)||void 0===h?void 0:h.predicates);null!==(y=o.filter)&&void 0!==y&&y.sparqlWhere&&("string"==typeof o.filter.sparqlWhere||o.filter.sparqlWhere instanceof String)&&(o.filter.sparqlWhere=JSON.parse(decodeURIComponent(o.filter.sparqlWhere)));var b=ye({containers:r[t],params:x(x({},o),{},{filter:x(x({},null===(v=l.list)||void 0===v?void 0:v.filter),o.filter)}),blankNodes:g,predicates:m,ontologies:f});s(i[t].sparqlEndpoint,{method:"POST",body:b}).then((function(t){var r,n=t.json,o=!1!==(null===(r=l.list)||void 0===r?void 0:r.explicitEmbedOnFraming)?x({"@context":u,"@type":l.types,"@embed":"@never"},Q(g)):{"@context":u,"@type":l.types};return e.frame(n,o,{omitGraph:!1})})).then((function(e){if(e["@id"]){var t=e;e={"@context":t["@context"],"@graph":[C(t,ge)]}}n(e["@graph"]||[])})).catch((function(e){return a(e)}))}))})),t.next=5,Promise.all(p);case 5:if(0!==(d=t.sent).length){t.next=10;break}return t.abrupt("return",{data:[],total:0});case 10:return d=(h=[]).concat.apply(h,L(d)),y=d.map((function(e){return e.id=e.id||e["@id"],e})),o.sort&&(y=y.sort((function(e,t){return void 0!==e[o.sort.field]&&void 0!==t[o.sort.field]?"ASC"===o.sort.order?me(e[o.sort.field],t[o.sort.field]):me(t[o.sort.field],e[o.sort.field]):0}))),o.pagination&&(y=y.slice((o.pagination.page-1)*o.pagination.perPage,o.pagination.page*o.pagination.perPage)),t.abrupt("return",{data:y,total:d.length});case 15:case"end":return t.stop()}}),t)})));return function(e,r,n,o){return t.apply(this,arguments)}}(),we=function(e,t){var r={};return Object.keys(e).forEach((function(n){if(!t[n])throw new Error("No server found with key "+n);r[n]=[],e[n].forEach((function(e){r[n].push(I(t[n].baseUrl,e))}))})),r},xe=function(e){return function(){var t=j(k().mark((function t(r){var n,o,a,i,c,s,u,f,l,p,d,h=arguments;return k().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(i=h.length>1&&void 0!==h[1]?h[1]:{},c=e.dataServers,s=e.resources,u=s[r]){t.next=5;break}throw new Error("Resource ".concat(r," is not mapped in resources file"));case 5:if(null!==(n=i.filter)&&void 0!==n&&n._servers||null===(o=u.list)||void 0===o||!o.containers){t.next=11;break}if(!Array.isArray(null===(l=u.list)||void 0===l?void 0:l.containers)){t.next=8;break}throw new Error("The list.containers property of ".concat(r," dataModel must be of type object ({ serverKey: [containerUri] })"));case 8:f=we(u.list.containers,c),t.next=12;break;case 11:f=G(u.types,(null===(p=i.filter)||void 0===p?void 0:p._servers)||(null===(d=u.list)||void 0===d?void 0:d.servers),c);case 12:if(null===(a=u.list)||void 0===a||!a.fetchContainer){t.next=16;break}return t.abrupt("return",K(f,r,i,e));case 16:return t.abrupt("return",be(f,r,i,e));case 17:case"end":return t.stop()}}),t)})));return function(e){return t.apply(this,arguments)}}()},ke=function(e){return function(){var t=j(k().mark((function t(r,n){var o,a;return k().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return o=e.returnFailedResources,t.next=3,Promise.all(n.ids.map((function(t){return B(e)(r,{id:"object"===S(t)?t["@id"]:t}).then((function(e){return e.data})).catch((function(){if(o)return{id:t,_error:!0}}))})));case 3:return a=(a=t.sent).filter((function(e){return e})),t.abrupt("return",{data:a});case 6:case"end":return t.stop()}}),t)})));return function(e,r){return t.apply(this,arguments)}}()},Se=function(e){return function(){var t=j(k().mark((function t(r,n){return k().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n.filter=x(x({},n.filter),{},E({},n.target,n.id)),delete n.target,t.next=4,xe(e)(r,n);case 4:return t.abrupt("return",t.sent);case 5:case"end":return t.stop()}}),t)})));return function(e,r){return t.apply(this,arguments)}}()},Oe=function(e){return function(){var t=j(k().mark((function t(r,n){var o,a;return k().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return o=e.httpClient,a=e.jsonContext,t.next=3,H(n.data,e);case 3:return n.data=t.sent,t.next=6,o(n.id,{method:"PUT",body:JSON.stringify(x({"@context":a},n.data))});case 6:return t.abrupt("return",{data:n.data});case 7:case"end":return t.stop()}}),t)})));return function(e,r){return t.apply(this,arguments)}}()};function je(e){this.message=e}je.prototype=new Error,je.prototype.name="InvalidCharacterError";var Ee="undefined"!=typeof window&&window.atob&&window.atob.bind(window)||function(e){var t=String(e).replace(/=+$/,"");if(t.length%4==1)throw new je("'atob' failed: The string to be decoded is not correctly encoded.");for(var r,n,o=0,a=0,i="";n=t.charAt(a++);~n&&(r=o%4?64*r+n:n,o++%4)?i+=String.fromCharCode(255&r>>(-2*o&6)):0)n="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".indexOf(n);return i};function Ae(e){var t=e.replace(/-/g,"+").replace(/_/g,"/");switch(t.length%4){case 0:break;case 2:t+="==";break;case 3:t+="=";break;default:throw"Illegal base64url string!"}try{return function(e){return decodeURIComponent(Ee(e).replace(/(.)/g,(function(e,t){var r=t.charCodeAt(0).toString(16).toUpperCase();return r.length<2&&(r="0"+r),"%"+r})))}(t)}catch(e){return Ee(t)}}function Ce(e){this.message=e}function _e(e,t){if("string"!=typeof e)throw new Ce("Invalid token specified");var r=!0===(t=t||{}).header?0:1;try{return JSON.parse(Ae(e.split(".")[r]))}catch(e){throw new Ce("Invalid token specified: "+e.message)}}Ce.prototype=new Error,Ce.prototype.name="InvalidTokenError";var Le=function(){var e=j(k().mark((function e(t){var r,n,o,a,i,c,s,u,f,l,p,d;return k().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(r=t.dataServers,n=t.httpClient,o=localStorage.getItem("token"),a=W("pod",r),i=W("authServer",r),!o){e.next=24;break}return c=_e(o),s=c.webId,e.prev=6,e.next=9,n(s);case 9:f=e.sent,l=f.json,u=l,e.next=20;break;case 14:return e.prev=14,e.t0=e.catch(6),console.error(e.t0),localStorage.clear(),window.location.reload(),e.abrupt("return");case 20:a&&(t.dataServers[a].name="My Pod",t.dataServers[a].baseUrl=I(s,"data"),t.dataServers[a].sparqlEndpoint=(null===(p=u.endpoints)||void 0===p?void 0:p["void:sparqlEndpoint"])||I(s,"sparql")),i&&(t.dataServers[i].proxyUrl=null===(d=u.endpoints)||void 0===d?void 0:d.proxyUrl),e.next=24;break;case 24:case"end":return e.stop()}}),e,null,[[6,14]])})));return function(t){return e.apply(this,arguments)}}(),Pe=function(e){return e?Array.isArray(e)?e:[e]:void 0},Ne=function(){var e=j(k().mark((function e(t){var r,n,o,a,i,c,s,u;return k().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return r=Object.entries(t.dataServers).filter((function(e){var t=_(e,2);return t[0],!0!==t[1].pod})).map((function(e){var r=_(e,2),n=r[0],o=r[1];return t.httpClient(new URL("/.well-known/void",o.baseUrl).toString()).then((function(e){return{key:n,datasets:e.json["@graph"]}})).catch((function(e){if(404===e.status||401===e.status)return{key:n,error:e};throw e}))})),n=[],e.prev=2,e.next=5,Promise.all(r);case 5:n=e.sent,e.next=10;break;case 8:e.prev=8,e.t0=e.catch(2);case 10:o=T(n);try{for(o.s();!(a=o.n()).done;)if(i=a.value,t.dataServers[i.key].containers=t.dataServers[i.key].containers||{},t.dataServers[i.key].blankNodes=t.dataServers[i.key].blankNodes||{},i.datasets){c=T(i.datasets);try{for(u=function(){var e=s.value,r=Object.keys(t.dataServers).find((function(r){return e["void:uriSpace"]===t.dataServers[r].baseUrl}));if(r){r===i.key&&(t.dataServers[i.key].name=t.dataServers[i.key].name||e["dc:title"],t.dataServers[i.key].description=t.dataServers[i.key].description||e["dc:description"],t.dataServers[i.key].sparqlEndpoint=t.dataServers[i.key].sparqlEndpoint||e["void:sparqlEndpoint"]),t.dataServers[i.key].containers[r]=t.dataServers[i.key].containers[r]||{};var n,o=T(Pe(e["void:classPartition"]));try{for(o.s();!(n=o.n()).done;){var a,c=n.value,u=T(Pe(c["void:class"]));try{for(u.s();!(a=u.n()).done;){var f=a.value,l=c["void:uriSpace"].replace(e["void:uriSpace"],"/");t.dataServers[i.key].containers[r][f]?t.dataServers[i.key].containers[r][f].push(l):t.dataServers[i.key].containers[r][f]=[l],Pe(c["semapps:blankNodes"])&&(t.dataServers[i.key].blankNodes[c["void:uriSpace"]]=Pe(c["semapps:blankNodes"]))}}catch(e){u.e(e)}finally{u.f()}}}catch(e){o.e(e)}finally{o.f()}}},c.s();!(s=c.n()).done;)u()}catch(e){c.e(e)}finally{c.f()}}}catch(e){o.e(e)}finally{o.f()}case 12:case"end":return e.stop()}}),e,null,[[2,8]])})));return function(t){return e.apply(this,arguments)}}(),Te=function(e,t){return Object.keys(t).find((function(r){return t[r].pod?t[r].baseUrl&&e.startsWith(t[r].baseUrl.replace("/data","")):e.startsWith(t[r].baseUrl)}))},Ue=function(e){if(!W("default",e.dataServers))throw new Error("You must define a default server in your dataServers config");var t;e.jsonContext||(e.jsonContext=Object.fromEntries(e.ontologies.map((function(e){return[e.prefix,e.url]})))),e.returnFailedResources||(e.returnFailedResources=!1),e.httpClient=(t=e.dataServers,function(e){var r,n,o=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},a=W("authServer",t),i=Te(e,t),s=i!==a&&(null===(r=t[a])||void 0===r?void 0:r.proxyUrl)&&!0!==(null===(n=t[i])||void 0===n?void 0:n.noProxy);switch(o.headers||(o.headers=new Headers),o.method){case"POST":case"PATCH":case"PUT":o.headers.has("Accept")||o.headers.set("Accept","application/ld+json"),o.headers.has("Content-Type")||o.headers.set("Content-Type","application/ld+json");break;case"DELETE":break;case"GET":default:o.headers.has("Accept")||o.headers.set("Accept","application/ld+json")}if(s){var u=new FormData;return u.append("id",e),u.append("method",o.method||"GET"),u.append("headers",JSON.stringify(Object.fromEntries(o.headers.entries()))),o.body&&(o.body instanceof File?u.append("body",o.body,o.body.name):u.append("body",o.body)),c.fetchJson(t[a].proxyUrl,{method:"POST",headers:new Headers({Authorization:"Bearer ".concat(localStorage.getItem("token"))}),body:u})}if(i===a){var f=localStorage.getItem("token");f&&o.headers.set("Authorization","Bearer ".concat(f))}return c.fetchJson(e,o)});var r=Le(e),n=Ne(e),o=function(e){return j(k().mark((function t(){var o=arguments;return k().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,r;case 2:return t.next=4,n;case 4:return t.next=6,e.apply(void 0,o);case 6:return t.abrupt("return",t.sent);case 7:case"end":return t.stop()}}),t)})))};return{getList:o(xe(e)),getMany:o(ke(e)),getManyReference:o(Se(e)),getOne:o(B(e)),create:o(J(e)),update:o(Oe(e)),updateMany:function(){throw new Error("updateMany is not implemented yet")},delete:o($(e)),deleteMany:o(Y(e)),getDataModels:o(X(e)),getDataServers:o(V(e)),getLocalDataServers:V(e),fetch:o(e.httpClient)}},qe=function(e,t){return"function"==typeof e?e(t):e},Ie=function(e){return"string"==typeof e&&e.startsWith("http")},Me=function(e){var t=h(s).getLocalDataServers(),r=y((function(){if(t)return Object.fromEntries(Object.values(t).map((function(e){var t=void 0!==e.externalLinks?e.externalLinks:!e.default;return[e.baseUrl,t]})))}),[t]);return v((function(t){var n=qe(e,t);if(!1===n)return!1;if(null==t||!t.id)return!1;var o=Object.keys(r).find((function(e){return null==t?void 0:t.id.startsWith(e)}));if(!o)return!1;var a=qe(r[o],t);return!1!==a&&(Ie(n)?n:Ie(a)?a:t.id)}),[r,e])},Be=function(e){var t=h(s),r=_(g(),2),n=r[0],o=r[1];return m((function(){t.getDataModels().then((function(t){return o(t[e])}))}),[t,e,o]),n},De=function(){var e=h(s),t=_(g(),2),r=t[0],n=t[1];return m((function(){e.getDataServers().then((function(e){return n(e)}))}),[e,n]),r},Fe=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"@all",r=Be(e),n=De(),o=g(),a=_(o,2),i=a[0],c=a[1];return m((function(){r&&n&&c(G(r.types,t,n))}),[r,n,t]),i},Re=function(e,t,r){var n=[];if(Object.keys(r[t].containers[t]).length>0&&Object.keys(r[t].containers[t]).forEach((function(o){e.includes(o)&&r[t].containers[t][o].map((function(e){var o=I(r[t].baseUrl,e);n.includes(o)||n.push(o)}))})),0===n.length)throw new Error("No container found matching with types ".concat(JSON.stringify(e),". You can set explicitely the create.container property of the resource."));if(n.length>1)throw new Error("More than one container found matching with types ".concat(JSON.stringify(e),". You must set the create.server or create.container property for the resource."));return n[0]},He=function(e){var t=Be(e),r=De(),n=_(g(),2),o=n[0],a=n[1];return m((function(){var n,o;if(t&&r)if(null!==(n=t.create)&&void 0!==n&&n.container){var i=_(Object.entries(t.create.container)[0],2),c=i[0],s=i[1];if(!c||!r[c])throw new Error("Wrong key for the dataModel.create.container config of resource "+e);a(I(r[c].baseUrl,s))}else if(null!==(o=t.create)&&void 0!==o&&o.server){var u;a(Re(t.types,null===(u=t.create)||void 0===u?void 0:u.server,r))}else{var f=W("default",r);a(Re(t.types,f,r))}}),[t,r,a]),o},We=function(){var e=h(s),t=_(g(),2),r=t[0],n=t[1];return m((function(){e.getDataModels().then((function(e){return n(e)}))}),[e,n]),r},ze=["children","record","filter","source"],Ge=function(e){var t=e.children,r=e.record,n=e.filter,o=e.source,a=C(e,ze),i=_(g(),2),c=i[0],s=i[1];return m((function(){if(r&&o&&Array.isArray(null==r?void 0:r[o])){var e=null==r?void 0:r[o].filter((function(e){var t=!0;for(var r in n){var o=e[r];Array.isArray(o)?o.includes(n[r])||(t=!1):o!==n[r]&&(t=!1)}return t})),t=x({},r);t[o]=e.length>0?e:void 0,s(t)}}),[r,o,n]),d.createElement(d.Fragment,null,d.Children.map(t,(function(e,t){return d.cloneElement(e,x(x({},a),{},{record:c,addLabel:!0,source:o}))})))},Je=["children","groupReference","groupLabel","groupHeader","filterProperty"],$e=function(e){var t=e.children,r=e.groupReference,n=e.groupLabel,o=e.groupHeader,a=e.filterProperty,i=C(e,Je),c=u({type:"getList",resource:r,payload:{}}).data;return d.createElement(d.Fragment,null,null==c?void 0:c.map((function(e,r){var c={};return c[a]=e.id,d.createElement(d.Fragment,null,o&&o(x(x({},i),{},{group:e})),d.createElement(Ge,A({},i,{filter:c,label:e[n]}),t))})))},Ye=["reificationClass","children"],Ve=b({form:{display:"flex"},input:{paddingRight:"20px"}}),Xe=b({root:{display:"none"}}),Ke=function(e){var t=e.reificationClass;e.children;var r=C(e,Ye),n=Ve(),o=Xe();return d.createElement(f,r,d.createElement(l,{classes:{form:n.form}},d.Children.map(e.children,(function(e,t){return d.cloneElement(e,{className:n.input})})),d.createElement(p,{className:o.root,source:"type",initialValue:t})))};export{Ge as FilterHandler,$e as GroupedReferenceHandler,Ke as ReificationArrayInput,se as buildBlankNodesQuery,ye as buildSparqlQuery,Ue as dataProvider,Fe as useContainers,He as useCreateContainer,Be as useDataModel,We as useDataModels,De as useDataServers,Me as useGetExternalLink};
|
|
3
|
+
k=function(){return e};var e={},t=Object.prototype,r=t.hasOwnProperty,n="function"==typeof Symbol?Symbol:{},o=n.iterator||"@@iterator",a=n.asyncIterator||"@@asyncIterator",i=n.toStringTag||"@@toStringTag";function c(e,t,r){return Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}),e[t]}try{c({},"")}catch(e){c=function(e,t,r){return e[t]=r}}function s(e,t,r,n){var o=t&&t.prototype instanceof l?t:l,a=Object.create(o.prototype),i=new O(n||[]);return a._invoke=function(e,t,r){var n="suspendedStart";return function(o,a){if("executing"===n)throw new Error("Generator is already running");if("completed"===n){if("throw"===o)throw a;return E()}for(r.method=o,r.arg=a;;){var i=r.delegate;if(i){var c=w(i,r);if(c){if(c===f)continue;return c}}if("next"===r.method)r.sent=r._sent=r.arg;else if("throw"===r.method){if("suspendedStart"===n)throw n="completed",r.arg;r.dispatchException(r.arg)}else"return"===r.method&&r.abrupt("return",r.arg);n="executing";var s=u(e,t,r);if("normal"===s.type){if(n=r.done?"completed":"suspendedYield",s.arg===f)continue;return{value:s.arg,done:r.done}}"throw"===s.type&&(n="completed",r.method="throw",r.arg=s.arg)}}}(e,r,i),a}function u(e,t,r){try{return{type:"normal",arg:e.call(t,r)}}catch(e){return{type:"throw",arg:e}}}e.wrap=s;var f={};function l(){}function p(){}function d(){}var h={};c(h,o,(function(){return this}));var y=Object.getPrototypeOf,v=y&&y(y(j([])));v&&v!==t&&r.call(v,o)&&(h=v);var g=d.prototype=l.prototype=Object.create(h);function m(e){["next","throw","return"].forEach((function(t){c(e,t,(function(e){return this._invoke(t,e)}))}))}function b(e,t){var n;this._invoke=function(o,a){function i(){return new t((function(n,i){!function n(o,a,i,c){var s=u(e[o],e,a);if("throw"!==s.type){var f=s.arg,l=f.value;return l&&"object"==typeof l&&r.call(l,"__await")?t.resolve(l.__await).then((function(e){n("next",e,i,c)}),(function(e){n("throw",e,i,c)})):t.resolve(l).then((function(e){f.value=e,i(f)}),(function(e){return n("throw",e,i,c)}))}c(s.arg)}(o,a,n,i)}))}return n=n?n.then(i,i):i()}}function w(e,t){var r=e.iterator[t.method];if(void 0===r){if(t.delegate=null,"throw"===t.method){if(e.iterator.return&&(t.method="return",t.arg=void 0,w(e,t),"throw"===t.method))return f;t.method="throw",t.arg=new TypeError("The iterator does not provide a 'throw' method")}return f}var n=u(r,e.iterator,t.arg);if("throw"===n.type)return t.method="throw",t.arg=n.arg,t.delegate=null,f;var o=n.arg;return o?o.done?(t[e.resultName]=o.value,t.next=e.nextLoc,"return"!==t.method&&(t.method="next",t.arg=void 0),t.delegate=null,f):o:(t.method="throw",t.arg=new TypeError("iterator result is not an object"),t.delegate=null,f)}function x(e){var t={tryLoc:e[0]};1 in e&&(t.catchLoc=e[1]),2 in e&&(t.finallyLoc=e[2],t.afterLoc=e[3]),this.tryEntries.push(t)}function S(e){var t=e.completion||{};t.type="normal",delete t.arg,e.completion=t}function O(e){this.tryEntries=[{tryLoc:"root"}],e.forEach(x,this),this.reset(!0)}function j(e){if(e){var t=e[o];if(t)return t.call(e);if("function"==typeof e.next)return e;if(!isNaN(e.length)){var n=-1,a=function t(){for(;++n<e.length;)if(r.call(e,n))return t.value=e[n],t.done=!1,t;return t.value=void 0,t.done=!0,t};return a.next=a}}return{next:E}}function E(){return{value:void 0,done:!0}}return p.prototype=d,c(g,"constructor",d),c(d,"constructor",p),p.displayName=c(d,i,"GeneratorFunction"),e.isGeneratorFunction=function(e){var t="function"==typeof e&&e.constructor;return!!t&&(t===p||"GeneratorFunction"===(t.displayName||t.name))},e.mark=function(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,d):(e.__proto__=d,c(e,i,"GeneratorFunction")),e.prototype=Object.create(g),e},e.awrap=function(e){return{__await:e}},m(b.prototype),c(b.prototype,a,(function(){return this})),e.AsyncIterator=b,e.async=function(t,r,n,o,a){void 0===a&&(a=Promise);var i=new b(s(t,r,n,o),a);return e.isGeneratorFunction(r)?i:i.next().then((function(e){return e.done?e.value:i.next()}))},m(g),c(g,i,"Generator"),c(g,o,(function(){return this})),c(g,"toString",(function(){return"[object Generator]"})),e.keys=function(e){var t=[];for(var r in e)t.push(r);return t.reverse(),function r(){for(;t.length;){var n=t.pop();if(n in e)return r.value=n,r.done=!1,r}return r.done=!0,r}},e.values=j,O.prototype={constructor:O,reset:function(e){if(this.prev=0,this.next=0,this.sent=this._sent=void 0,this.done=!1,this.delegate=null,this.method="next",this.arg=void 0,this.tryEntries.forEach(S),!e)for(var t in this)"t"===t.charAt(0)&&r.call(this,t)&&!isNaN(+t.slice(1))&&(this[t]=void 0)},stop:function(){this.done=!0;var e=this.tryEntries[0].completion;if("throw"===e.type)throw e.arg;return this.rval},dispatchException:function(e){if(this.done)throw e;var t=this;function n(r,n){return i.type="throw",i.arg=e,t.next=r,n&&(t.method="next",t.arg=void 0),!!n}for(var o=this.tryEntries.length-1;o>=0;--o){var a=this.tryEntries[o],i=a.completion;if("root"===a.tryLoc)return n("end");if(a.tryLoc<=this.prev){var c=r.call(a,"catchLoc"),s=r.call(a,"finallyLoc");if(c&&s){if(this.prev<a.catchLoc)return n(a.catchLoc,!0);if(this.prev<a.finallyLoc)return n(a.finallyLoc)}else if(c){if(this.prev<a.catchLoc)return n(a.catchLoc,!0)}else{if(!s)throw new Error("try statement without catch or finally");if(this.prev<a.finallyLoc)return n(a.finallyLoc)}}}},abrupt:function(e,t){for(var n=this.tryEntries.length-1;n>=0;--n){var o=this.tryEntries[n];if(o.tryLoc<=this.prev&&r.call(o,"finallyLoc")&&this.prev<o.finallyLoc){var a=o;break}}a&&("break"===e||"continue"===e)&&a.tryLoc<=t&&t<=a.finallyLoc&&(a=null);var i=a?a.completion:{};return i.type=e,i.arg=t,a?(this.method="next",this.next=a.finallyLoc,f):this.complete(i)},complete:function(e,t){if("throw"===e.type)throw e.arg;return"break"===e.type||"continue"===e.type?this.next=e.arg:"return"===e.type?(this.rval=this.arg=e.arg,this.method="return",this.next="end"):"normal"===e.type&&t&&(this.next=t),f},finish:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var r=this.tryEntries[t];if(r.finallyLoc===e)return this.complete(r.completion,r.afterLoc),S(r),f}},catch:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var r=this.tryEntries[t];if(r.tryLoc===e){var n=r.completion;if("throw"===n.type){var o=n.arg;S(r)}return o}}throw new Error("illegal catch attempt")},delegateYield:function(e,t,r){return this.delegate={iterator:j(e),resultName:t,nextLoc:r},"next"===this.method&&(this.arg=void 0),f}},e}function S(e){return(S="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function O(e,t,r,n,o,a,i){try{var c=e[a](i),s=c.value}catch(e){return void r(e)}c.done?t(s):Promise.resolve(s).then(n,o)}function j(e){return function(){var t=this,r=arguments;return new Promise((function(n,o){var a=e.apply(t,r);function i(e){O(a,n,o,i,c,"next",e)}function c(e){O(a,n,o,i,c,"throw",e)}i(void 0)}))}}function E(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function A(){return(A=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(e[n]=r[n])}return e}).apply(this,arguments)}function C(e,t){if(null==e)return{};var r,n,o=function(e,t){if(null==e)return{};var r,n,o={},a=Object.keys(e);for(n=0;n<a.length;n++)r=a[n],t.indexOf(r)>=0||(o[r]=e[r]);return o}(e,t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(n=0;n<a.length;n++)r=a[n],t.indexOf(r)>=0||Object.prototype.propertyIsEnumerable.call(e,r)&&(o[r]=e[r])}return o}function _(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var r=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null==r)return;var n,o,a=[],i=!0,c=!1;try{for(r=r.call(e);!(i=(n=r.next()).done)&&(a.push(n.value),!t||a.length!==t);i=!0);}catch(e){c=!0,o=e}finally{try{i||null==r.return||r.return()}finally{if(c)throw o}}return a}(e,t)||P(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function L(e){return function(e){if(Array.isArray(e))return N(e)}(e)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||P(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function P(e,t){if(e){if("string"==typeof e)return N(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?N(e,t):void 0}}function N(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=new Array(t);r<t;r++)n[r]=e[r];return n}function T(e,t){var r="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!r){if(Array.isArray(e)||(r=P(e))||t&&e&&"number"==typeof e.length){r&&(e=r);var n=0,o=function(){};return{s:o,n:function(){return n>=e.length?{done:!0}:{done:!1,value:e[n++]}},e:function(e){throw e},f:o}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var a,i=!0,c=!1;return{s:function(){r=r.call(e)},n:function(){var e=r.next();return i=e.done,e},e:function(e){c=!0,a=e},f:function(){try{i||null==r.return||r.return()}finally{if(c)throw a}}}}var U="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function q(e,t){return e(t={exports:{}},t.exports),t.exports}var I=q((function(e){var t,r;t=U,r=function(){function e(e){var t=[];if(0===e.length)return"";if("string"!=typeof e[0])throw new TypeError("Url must be a string. Received "+e[0]);if(e[0].match(/^[^/:]+:\/*$/)&&e.length>1){var r=e.shift();e[0]=r+e[0]}e[0].match(/^file:\/\/\//)?e[0]=e[0].replace(/^([^/:]+):\/*/,"$1:///"):e[0]=e[0].replace(/^([^/:]+):\/*/,"$1://");for(var n=0;n<e.length;n++){var o=e[n];if("string"!=typeof o)throw new TypeError("Url must be a string. Received "+o);""!==o&&(n>0&&(o=o.replace(/^[\/]+/,"")),o=n<e.length-1?o.replace(/[\/]+$/,""):o.replace(/[\/]+$/,"/"),t.push(o))}var a=t.join("/"),i=(a=a.replace(/\/(\?|&|#[^!])/g,"$1")).split("?");return a=i.shift()+(i.length>0?"?":"")+i.join("&")}return function(){return e("object"==typeof arguments[0]?arguments[0]:[].slice.call(arguments))}},e.exports?e.exports=r():t.urljoin=r()})),M=function(){var t=j(k().mark((function t(r,n){var o,a,i,c;return k().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return o=n.httpClient,a=n.jsonContext,t.next=3,o(r);case 3:if(i=t.sent,c=i.json){t.next=7;break}throw new Error("Not a valid JSON: "+r);case 7:if(c.id=c.id||c["@id"],c["@context"]===a){t.next=12;break}return t.next=11,e.compact(c,a);case 11:c=t.sent;case 12:return t.abrupt("return",c);case 13:case"end":return t.stop()}}),t)})));return function(e,r){return t.apply(this,arguments)}}(),B=function(e){return function(){var t=j(k().mark((function t(r,n){var o,a,i,c,s,u,f,l;return k().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(a=e.resources,i=a[r]){t.next=4;break}throw new Error("Resource ".concat(r," is not mapped in resources file"));case 4:return t.next=6,M(n.id,e);case 6:if(c=t.sent,null!==(o=i.list)&&void 0!==o&&o.forceArray){u=T(null===(s=i.list)||void 0===s?void 0:s.forceArray);try{for(u.s();!(f=u.n()).done;)l=f.value,c[l]&&!Array.isArray(c[l])&&(c[l]=[c[l]])}catch(e){u.e(e)}finally{u.f()}}return t.abrupt("return",{data:c});case 9:case"end":return t.stop()}}),t)})));return function(e,r){return t.apply(this,arguments)}}()},D=function(e){return e&&e.rawFile&&e.rawFile instanceof File},F=function(e){var t=Object.keys(e.dataServers).find((function(t){return e.dataServers[t].uploadsContainer}));if(t)return I(e.dataServers[t].baseUrl,e.dataServers[t].uploadsContainer)},R=function(){var e=j(k().mark((function e(r,n){var o,a;return k().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(o=F(n)){e.next=3;break}throw new Error("You must define an uploadsContainer in one of the server's configuration");case 3:return e.next=5,n.httpClient(o,{method:"POST",body:r,headers:new Headers({Slug:(i=r.name,c=void 0,s=void 0,c="",s=i.split("."),s.length>1&&(c=s.pop(),i=s.join(".")),t(i,{lang:"fr"})+"."+c),"Content-Type":r.type})});case 5:if(201!==(a=e.sent).status){e.next=8;break}return e.abrupt("return",a.headers.get("Location"));case 8:case"end":return e.stop()}var i,c,s}),e)})));return function(t,r){return e.apply(this,arguments)}}(),H=function(){var e=j(k().mark((function e(t,r){var n,o;return k().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:e.t0=k().keys(t);case 1:if((e.t1=e.t0()).done){e.next=22;break}if(n=e.t1.value,!t.hasOwnProperty(n)){e.next=20;break}if(!Array.isArray(t[n])){e.next=16;break}o=0;case 6:if(!(o<t[n].length)){e.next=14;break}if(!D(t[n][o])){e.next=11;break}return e.next=10,R(t[n][o].rawFile,r);case 10:t[n][o]=e.sent;case 11:o++,e.next=6;break;case 14:e.next=20;break;case 16:if(!D(t[n])){e.next=20;break}return e.next=19,R(t[n].rawFile,r);case 19:t[n]=e.sent;case 20:e.next=1;break;case 22:return e.abrupt("return",t);case 23:case"end":return e.stop()}}),e)})));return function(t,r){return e.apply(this,arguments)}}(),W=function(e,t){return Object.keys(t).find((function(r){return t[r][e]}))},z=function(e,t){switch(e){case"@default":return W("default",t);case"@pod":return W("pod",t);case"@authServer":return W("authServer",t);default:return e}},G=function(e,t,r){var n={},o=[];return t=function(e,t){if(Array.isArray(e))return e.includes("@all")?Object.keys(t):e.map((function(e){return z(e,t)}));if("string"==typeof e){if("@all"===e)return Object.keys(t);if("@remote"===e){var r=W("default",t);return Object.keys(t).filter((function(e){return e!==r}))}return[z(e,t)]}return!1}(t,r),Object.keys(r).forEach((function(a){Object.keys(r[a].containers).forEach((function(i){t&&!t.includes(i)||Object.keys(r[a].containers[i]).forEach((function(t){e.includes(t)&&r[a].containers[i][t].map((function(e){var t=I(r[i].baseUrl,e);o.includes(t)||(o.push(t),n[a]||(n[a]=[]),n[a].push(t))}))}))}))})),n},J=function(e){return function(){var t=j(k().mark((function t(r,n){var o,a,i,c,s,u,f,l,p,d,h,y,v,g,m,b;return k().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(a=e.dataServers,i=e.resources,c=e.httpClient,s=e.jsonContext,u=i[r],f=new Headers,null===(o=u.create)||void 0===o||!o.container){t.next=9;break}p=Object.keys(u.create.container)[0],l=I(a[p].baseUrl,Object.values(u.create.container)[0]),t.next=19;break;case 9:if(p=(null===(d=u.create)||void 0===d?void 0:d.server)||Object.keys(a).find((function(e){return!0===a[e].default}))){t.next=12;break}throw new Error("You must define a server for the creation, or a container, or a default server");case 12:if(h=G(u.types,[p],a),(y=Object.keys(h))&&0!==y.length){t.next=16;break}throw new Error("No container with types ".concat(JSON.stringify(u.types)," found on server ").concat(p));case 16:if(!(y.length>1||h[y[0]].length>1)){t.next=18;break}throw new Error("More than one container detected with types ".concat(JSON.stringify(u.types)," on server ").concat(p));case 18:l=h[y[0]][0];case 19:if(!n.data){t.next=34;break}return null!==(v=u.fieldsMapping)&&void 0!==v&&v.title&&(Array.isArray(u.fieldsMapping.title)?f.set("Slug",u.fieldsMapping.title.map((function(e){return n.data[e]})).join(" ")):f.set("Slug",n.data[u.fieldsMapping.title])),t.next=23,H(n.data,e);case 23:return n.data=t.sent,t.next=26,c(l,{method:"POST",headers:f,body:JSON.stringify(x({"@context":s,"@type":u.types},n.data))});case 26:return g=t.sent,m=g.headers,b=m.get("Location"),t.next=31,B(e)(r,{id:b});case 31:return t.abrupt("return",t.sent);case 34:if(!n.id){t.next=41;break}return f.set("Content-Type","application/sparql-update"),t.next=38,c(l,{method:"PATCH",headers:f,body:"\n PREFIX ldp: <http://www.w3.org/ns/ldp#>\n INSERT DATA { <".concat(l,"> ldp:contains <").concat(n.id,">. };\n ")});case 38:return t.next=40,B(e)(r,{id:n.id});case 40:return t.abrupt("return",t.sent);case 41:case"end":return t.stop()}}),t)})));return function(e,r){return t.apply(this,arguments)}}()},$=function(e){return function(){var t=j(k().mark((function t(r,n){var o;return k().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return o=e.httpClient,t.next=3,o(n.id,{method:"DELETE"});case 3:return t.abrupt("return",{data:{id:n.id}});case 4:case"end":return t.stop()}}),t)})));return function(e,r){return t.apply(this,arguments)}}()},Y=function(e){return function(){var t=j(k().mark((function t(r,n){var o,a,i,c,s;return k().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:o=e.httpClient,a=[],i=T(n.ids),t.prev=3,i.s();case 5:if((c=i.n()).done){t.next=17;break}return s=c.value,t.prev=7,t.next=10,o(s,{method:"DELETE"});case 10:a.push(s),t.next=15;break;case 13:t.prev=13,t.t0=t.catch(7);case 15:t.next=5;break;case 17:t.next=22;break;case 19:t.prev=19,t.t1=t.catch(3),i.e(t.t1);case 22:return t.prev=22,i.f(),t.finish(22);case 25:return t.abrupt("return",{data:a});case 26:case"end":return t.stop()}}),t,null,[[3,19,22,25],[7,13]])})));return function(e,r){return t.apply(this,arguments)}}()},V=function(e){return function(){return e.dataServers}},X=function(e){return function(){return e.resources}};var K=function(){var t=j(k().mark((function t(r,n,o,a){var i,c,s,u,f,l,p;return k().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return i=a.httpClient,c=a.jsonContext,s=Object.keys(r).reduce((function(e,t){return x(x({},e),Object.fromEntries(r[t].map((function(e){return[e,t]}))))}),{}),u=Object.keys(s).map((function(t){return i(t).then((function(t){var r=t.json;return r["@context"]!==c?e.compact(r,c):r})).then((function(e){if(r="ldp:Container",o=(n=e).type||n["@type"],Array.isArray(o)?o.includes(r):o===r)return e["ldp:contains"];throw new Error(t+" is not a LDP container");var r,n,o}))})),t.next=5,Promise.all(u);case 5:if(0!==(f=t.sent).length){t.next=10;break}return t.abrupt("return",{data:[],total:0});case 10:return f=(l=[].concat).apply.apply(l,L(f)),p=f.map((function(e){return e.id=e.id||e["@id"],e})),o.filter&&(o.filter.a&&(o.filter.type=o.filter.a,delete o.filter.a),Object.keys(o.filter).length>0&&(p=p.filter((function(e){return Object.entries(o.filter).some((function(t){var r=_(t,2),n=r[0],o=r[1];return"q"==n?Object.entries(e).some((function(e){var t=_(e,2);t[0];var r,n=t[1];return(null==(r=n)||"object"!=typeof r||!1!==Array.isArray(r))&&(Array.isArray(n)?n:[n]).some((function(e){if("string"==typeof e||e instanceof String)return e.toLowerCase().normalize("NFD").includes(o.toLowerCase().normalize("NFD"))}))})):!!e[n]&&(Array.isArray(e[n])?e[n].some((function(e){return e.includes(o)})):e[n].includes(o))}))})))),o.sort&&(p=p.sort((function(e,t){return!e[o.sort.field]||!t[o.sort.field]||("ASC"===o.sort.order?e[o.sort.field].localeCompare(t[o.sort.field]):t[o.sort.field].localeCompare(e[o.sort.field]))}))),o.pagination&&(p=p.slice((o.pagination.page-1)*o.pagination.perPage,o.pagination.page*o.pagination.perPage)),t.abrupt("return",{data:p,total:f.length});case 16:case"end":return t.stop()}}),t)})));return function(e,r,n,o){return t.apply(this,arguments)}}(),Q=function(e){var t,r={};if(e){var n,o=T(e);try{for(o.s();!(n=o.n()).done;){var a=n.value;t=a.includes("/")?a.split("/").reverse():[a],r=x(x({},r),t.reduce((function(e,t){return E({},t,x({"@embed":"@last"},e))}),{}))}}catch(e){o.e(e)}finally{o.f()}return r}},Z=function(e,t){if(e.startsWith("http://")||e.startsWith("https://"))return e;if("a"===e)return"http://www.w3.org/1999/02/22-rdf-syntax-ns#type";var r=_(e.split(":"),2),n=r[0],o=r[1];if(o){var a=t.find((function(e){return e.prefix===n}));if(a)return a.url+o;throw new Error("No ontology found with prefix "+n)}throw new Error('The value "'.concat(e,'" is not correct. It must include a prefix or be a full URI.'))},ee=n(o("s1"),a("http://www.w3.org/1999/02/22-rdf-syntax-ns#type"),o("type")),te=function(e,t){var r,i;return e?(r=(i=e,i?Array.isArray(i)?i:[i]:[]).map((function(e,r){return n(o("s1"),a(Z(e,t)),o("o"+(r+1)))})),{construct:[ee].concat(L(r)),where:[ee].concat(L(r.map((function(e){return{type:"optional",patterns:[e]}}))))}):{construct:r=[n(o("s1"),o("p1"),o("o1"))],where:r}},re=q((function(e,t){var r;e.exports=r=r||function(e,t){var r;if("undefined"!=typeof window&&window.crypto&&(r=window.crypto),"undefined"!=typeof self&&self.crypto&&(r=self.crypto),"undefined"!=typeof globalThis&&globalThis.crypto&&(r=globalThis.crypto),!r&&"undefined"!=typeof window&&window.msCrypto&&(r=window.msCrypto),!r&&void 0!==U&&U.crypto&&(r=U.crypto),!r)try{r=i}catch(e){}var n=function(){if(r){if("function"==typeof r.getRandomValues)try{return r.getRandomValues(new Uint32Array(1))[0]}catch(e){}if("function"==typeof r.randomBytes)try{return r.randomBytes(4).readInt32LE()}catch(e){}}throw new Error("Native crypto module could not be used to get secure random number.")},o=Object.create||function(){function e(){}return function(t){var r;return e.prototype=t,r=new e,e.prototype=null,r}}(),a={},c=a.lib={},s=c.Base={extend:function(e){var t=o(this);return e&&t.mixIn(e),t.hasOwnProperty("init")&&this.init!==t.init||(t.init=function(){t.$super.init.apply(this,arguments)}),t.init.prototype=t,t.$super=this,t},create:function(){var e=this.extend();return e.init.apply(e,arguments),e},init:function(){},mixIn:function(e){for(var t in e)e.hasOwnProperty(t)&&(this[t]=e[t]);e.hasOwnProperty("toString")&&(this.toString=e.toString)},clone:function(){return this.init.prototype.extend(this)}},u=c.WordArray=s.extend({init:function(e,t){e=this.words=e||[],this.sigBytes=null!=t?t:4*e.length},toString:function(e){return(e||l).stringify(this)},concat:function(e){var t=this.words,r=e.words,n=this.sigBytes,o=e.sigBytes;if(this.clamp(),n%4)for(var a=0;a<o;a++){var i=r[a>>>2]>>>24-a%4*8&255;t[n+a>>>2]|=i<<24-(n+a)%4*8}else for(var c=0;c<o;c+=4)t[n+c>>>2]=r[c>>>2];return this.sigBytes+=o,this},clamp:function(){var t=this.words,r=this.sigBytes;t[r>>>2]&=4294967295<<32-r%4*8,t.length=e.ceil(r/4)},clone:function(){var e=s.clone.call(this);return e.words=this.words.slice(0),e},random:function(e){for(var t=[],r=0;r<e;r+=4)t.push(n());return new u.init(t,e)}}),f=a.enc={},l=f.Hex={stringify:function(e){for(var t=e.words,r=e.sigBytes,n=[],o=0;o<r;o++){var a=t[o>>>2]>>>24-o%4*8&255;n.push((a>>>4).toString(16)),n.push((15&a).toString(16))}return n.join("")},parse:function(e){for(var t=e.length,r=[],n=0;n<t;n+=2)r[n>>>3]|=parseInt(e.substr(n,2),16)<<24-n%8*4;return new u.init(r,t/2)}},p=f.Latin1={stringify:function(e){for(var t=e.words,r=e.sigBytes,n=[],o=0;o<r;o++){var a=t[o>>>2]>>>24-o%4*8&255;n.push(String.fromCharCode(a))}return n.join("")},parse:function(e){for(var t=e.length,r=[],n=0;n<t;n++)r[n>>>2]|=(255&e.charCodeAt(n))<<24-n%4*8;return new u.init(r,t)}},d=f.Utf8={stringify:function(e){try{return decodeURIComponent(escape(p.stringify(e)))}catch(e){throw new Error("Malformed UTF-8 data")}},parse:function(e){return p.parse(unescape(encodeURIComponent(e)))}},h=c.BufferedBlockAlgorithm=s.extend({reset:function(){this._data=new u.init,this._nDataBytes=0},_append:function(e){"string"==typeof e&&(e=d.parse(e)),this._data.concat(e),this._nDataBytes+=e.sigBytes},_process:function(t){var r,n=this._data,o=n.words,a=n.sigBytes,i=this.blockSize,c=a/(4*i),s=(c=t?e.ceil(c):e.max((0|c)-this._minBufferSize,0))*i,f=e.min(4*s,a);if(s){for(var l=0;l<s;l+=i)this._doProcessBlock(o,l);r=o.splice(0,s),n.sigBytes-=f}return new u.init(r,f)},clone:function(){var e=s.clone.call(this);return e._data=this._data.clone(),e},_minBufferSize:0});c.Hasher=h.extend({cfg:s.extend(),init:function(e){this.cfg=this.cfg.extend(e),this.reset()},reset:function(){h.reset.call(this),this._doReset()},update:function(e){return this._append(e),this._process(),this},finalize:function(e){return e&&this._append(e),this._doFinalize()},blockSize:16,_createHelper:function(e){return function(t,r){return new e.init(r).finalize(t)}},_createHmacHelper:function(e){return function(t,r){return new y.HMAC.init(e,r).finalize(t)}}});var y=a.algo={};return a}(Math)})),ne=q((function(e,t){var r;e.exports=(r=re,function(e){var t=r,n=t.lib,o=n.WordArray,a=n.Hasher,i=t.algo,c=[];!function(){for(var t=0;t<64;t++)c[t]=4294967296*e.abs(e.sin(t+1))|0}();var s=i.MD5=a.extend({_doReset:function(){this._hash=new o.init([1732584193,4023233417,2562383102,271733878])},_doProcessBlock:function(e,t){for(var r=0;r<16;r++){var n=t+r,o=e[n];e[n]=16711935&(o<<8|o>>>24)|4278255360&(o<<24|o>>>8)}var a=this._hash.words,i=e[t+0],s=e[t+1],d=e[t+2],h=e[t+3],y=e[t+4],v=e[t+5],g=e[t+6],m=e[t+7],b=e[t+8],w=e[t+9],x=e[t+10],k=e[t+11],S=e[t+12],O=e[t+13],j=e[t+14],E=e[t+15],A=a[0],C=a[1],_=a[2],L=a[3];A=u(A,C,_,L,i,7,c[0]),L=u(L,A,C,_,s,12,c[1]),_=u(_,L,A,C,d,17,c[2]),C=u(C,_,L,A,h,22,c[3]),A=u(A,C,_,L,y,7,c[4]),L=u(L,A,C,_,v,12,c[5]),_=u(_,L,A,C,g,17,c[6]),C=u(C,_,L,A,m,22,c[7]),A=u(A,C,_,L,b,7,c[8]),L=u(L,A,C,_,w,12,c[9]),_=u(_,L,A,C,x,17,c[10]),C=u(C,_,L,A,k,22,c[11]),A=u(A,C,_,L,S,7,c[12]),L=u(L,A,C,_,O,12,c[13]),_=u(_,L,A,C,j,17,c[14]),A=f(A,C=u(C,_,L,A,E,22,c[15]),_,L,s,5,c[16]),L=f(L,A,C,_,g,9,c[17]),_=f(_,L,A,C,k,14,c[18]),C=f(C,_,L,A,i,20,c[19]),A=f(A,C,_,L,v,5,c[20]),L=f(L,A,C,_,x,9,c[21]),_=f(_,L,A,C,E,14,c[22]),C=f(C,_,L,A,y,20,c[23]),A=f(A,C,_,L,w,5,c[24]),L=f(L,A,C,_,j,9,c[25]),_=f(_,L,A,C,h,14,c[26]),C=f(C,_,L,A,b,20,c[27]),A=f(A,C,_,L,O,5,c[28]),L=f(L,A,C,_,d,9,c[29]),_=f(_,L,A,C,m,14,c[30]),A=l(A,C=f(C,_,L,A,S,20,c[31]),_,L,v,4,c[32]),L=l(L,A,C,_,b,11,c[33]),_=l(_,L,A,C,k,16,c[34]),C=l(C,_,L,A,j,23,c[35]),A=l(A,C,_,L,s,4,c[36]),L=l(L,A,C,_,y,11,c[37]),_=l(_,L,A,C,m,16,c[38]),C=l(C,_,L,A,x,23,c[39]),A=l(A,C,_,L,O,4,c[40]),L=l(L,A,C,_,i,11,c[41]),_=l(_,L,A,C,h,16,c[42]),C=l(C,_,L,A,g,23,c[43]),A=l(A,C,_,L,w,4,c[44]),L=l(L,A,C,_,S,11,c[45]),_=l(_,L,A,C,E,16,c[46]),A=p(A,C=l(C,_,L,A,d,23,c[47]),_,L,i,6,c[48]),L=p(L,A,C,_,m,10,c[49]),_=p(_,L,A,C,j,15,c[50]),C=p(C,_,L,A,v,21,c[51]),A=p(A,C,_,L,S,6,c[52]),L=p(L,A,C,_,h,10,c[53]),_=p(_,L,A,C,x,15,c[54]),C=p(C,_,L,A,s,21,c[55]),A=p(A,C,_,L,b,6,c[56]),L=p(L,A,C,_,E,10,c[57]),_=p(_,L,A,C,g,15,c[58]),C=p(C,_,L,A,O,21,c[59]),A=p(A,C,_,L,y,6,c[60]),L=p(L,A,C,_,k,10,c[61]),_=p(_,L,A,C,d,15,c[62]),C=p(C,_,L,A,w,21,c[63]),a[0]=a[0]+A|0,a[1]=a[1]+C|0,a[2]=a[2]+_|0,a[3]=a[3]+L|0},_doFinalize:function(){var t=this._data,r=t.words,n=8*this._nDataBytes,o=8*t.sigBytes;r[o>>>5]|=128<<24-o%32;var a=e.floor(n/4294967296),i=n;r[15+(o+64>>>9<<4)]=16711935&(a<<8|a>>>24)|4278255360&(a<<24|a>>>8),r[14+(o+64>>>9<<4)]=16711935&(i<<8|i>>>24)|4278255360&(i<<24|i>>>8),t.sigBytes=4*(r.length+1),this._process();for(var c=this._hash,s=c.words,u=0;u<4;u++){var f=s[u];s[u]=16711935&(f<<8|f>>>24)|4278255360&(f<<24|f>>>8)}return c},clone:function(){var e=a.clone.call(this);return e._hash=this._hash.clone(),e}});function u(e,t,r,n,o,a,i){var c=e+(t&r|~t&n)+o+i;return(c<<a|c>>>32-a)+t}function f(e,t,r,n,o,a,i){var c=e+(t&n|r&~n)+o+i;return(c<<a|c>>>32-a)+t}function l(e,t,r,n,o,a,i){var c=e+(t^r^n)+o+i;return(c<<a|c>>>32-a)+t}function p(e,t,r,n,o,a,i){var c=e+(r^(t|~n))+o+i;return(c<<a|c>>>32-a)+t}t.MD5=a._createHelper(s),t.HmacMD5=a._createHmacHelper(s)}(Math),r.MD5)})),oe=function(e){return ne(e)},ae=function(e){return e.includes("/")&&e.split("/")[0]},ie=function(e){return e.includes("/")?e.split("/")[1]:e},ce=function(e){return e.map((function(t){var r=t.query,n=e.find((function(e){return t.parentNode===e.node}));return void 0!==n&&(r=r.concat(n.query[0])),{type:"bgp",triples:r}}))},se=function(e,t,r){var i=[],c=function(e){var t=[];if(e){var r,n=T(e);try{for(n.s();!(r=n.n()).done;){var o=r.value;if(o.includes("/"))for(var a=o.split("/"),i=1;i<=a.length;i++)t.push(a.slice(0,i).join("/"));else t.push(o)}}catch(e){n.e(e)}finally{n.f()}}return t}(e);if(c&&r&&r.length>0){var s,u=T(c);try{for(u.s();!(s=u.n()).done;){var f=s.value,l=ae(f),p=ie(f),d=oe(f),h=l?oe(l):"1",y=[n(o("s"+h),a(Z(p,r)),o("s"+d)),n(o("s"+d),o("p"+d),o("o"+d))];i.push({node:f,parentNode:l,query:y,filter:""})}}catch(e){u.e(e)}finally{u.f()}return{construct:i.length>0?i.map((function(e){return e.query})).reduce((function(e,t){return e.concat(t)})):null,where:{type:"union",patterns:[t.where].concat(L(ce(i)))}}}return{construct:"",where:""}},ue=r.literal,fe=r.namedNode,le=r.triple,pe=r.variable,de=new(0,require("sparqljs").Generator)({}),he=["q","sparqlWhere","blankNodes","_servers","_predicates"],ye=function(e){var t=e.containers,r=e.params.filter,n=e.blankNodes,o=e.predicates,a=e.ontologies,i=te(o,a),c={queryType:"CONSTRUCT",template:i.construct,where:[],type:"query",prefixes:Object.fromEntries(a.map((function(e){return[e.prefix,e.url]})))},s=[{type:"values",values:t.map((function(e){return{"?containerUri":fe(e)}}))},le(pe("containerUri"),fe("http://www.w3.org/ns/ldp#contains"),pe("s1")),{type:"filter",expression:{type:"operation",operator:"isiri",args:[pe("s1")]}}],u=[];if(r&&Object.keys(r).length>0){var f=r.sparqlWhere&&Object.keys(r.sparqlWhere).length>0,l=r.q&&r.q.length>0;f&&[].concat(r.sparqlWhere).forEach((function(e){u.push(e)})),l&&u.push({type:"group",patterns:[{queryType:"SELECT",variables:[pe("s1")],where:[le(pe("s1"),pe("p1"),pe("o1")),{type:"filter",expression:{type:"operation",operator:"isliteral",args:[pe("o1")]}},{type:"filter",expression:{type:"operation",operator:"regex",args:[{type:"operation",operator:"lcase",args:[{type:"operation",operator:"str",args:[pe("o1")]}]},ue(r.q.toLowerCase(),"",fe("http://www.w3.org/2001/XMLSchema#string"))]}}],type:"query"}]}),Object.entries(r).forEach((function(e){var t=_(e,2),r=t[0],n=t[1];he.includes(r)||u.unshift(le(pe("s1"),fe(Z(r,a)),fe(Z(n,a))))}))}var p=se(n,i,a);return p&&p.construct?(u=u.concat(p.where),c.template=c.template.concat(p.construct)):u.push(i.where),c.where.push({type:"union",patterns:[s,{type:"graph",name:fe("http://semapps.org/mirror"),patterns:s}]},{type:"union",patterns:[u,{type:"graph",name:fe("http://semapps.org/mirror"),patterns:u}]}),de.stringify(c)},ve=function(e,t){for(var r=[],n=0,o=Object.keys(t);n<o.length;n++){var a=o[n];if(t[a].blankNodes)for(var i=0,c=Object.keys(t[a].blankNodes);i<c.length;i++){var s=c[i];e.includes(s)&&r.push.apply(r,L(t[a].blankNodes[s]))}}return L(new Set(r))},ge=["@context"],me=function(e,t){switch(S(e)){case"string":return e.localeCompare(t);case"number":case"bigint":return e-t;default:return 0}},be=function(){var t=j(k().mark((function t(r,n,o,a){var i,c,s,u,f,l,p,d,h,y;return k().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return i=a.dataServers,c=a.resources,s=a.httpClient,u=a.jsonContext,f=a.ontologies,l=c[n],p=Object.keys(r).map((function(t){return new Promise((function(n,a){var c,p,d,h,y,v,g=(null===(c=o.filter)||void 0===c?void 0:c.blankNodes)||(null===(p=l.list)||void 0===p?void 0:p.blankNodes)||ve(r[t],i),m=(null===(d=o.filter)||void 0===d?void 0:d._predicates)||(null===(h=l.list)||void 0===h?void 0:h.predicates);null!==(y=o.filter)&&void 0!==y&&y.sparqlWhere&&("string"==typeof o.filter.sparqlWhere||o.filter.sparqlWhere instanceof String)&&(o.filter.sparqlWhere=JSON.parse(decodeURIComponent(o.filter.sparqlWhere)));var b=ye({containers:r[t],params:x(x({},o),{},{filter:x(x({},null===(v=l.list)||void 0===v?void 0:v.filter),o.filter)}),blankNodes:g,predicates:m,ontologies:f});s(i[t].sparqlEndpoint,{method:"POST",body:b}).then((function(t){var r,n=t.json,o=!1!==(null===(r=l.list)||void 0===r?void 0:r.explicitEmbedOnFraming)?x({"@context":u,"@type":l.types,"@embed":"@never"},Q(g)):{"@context":u,"@type":l.types};return e.frame(n,o,{omitGraph:!1})})).then((function(e){if(e["@id"]){var t=e;e={"@context":t["@context"],"@graph":[C(t,ge)]}}n(e["@graph"]||[])})).catch((function(e){return a(e)}))}))})),t.next=5,Promise.all(p);case 5:if(0!==(d=t.sent).length){t.next=10;break}return t.abrupt("return",{data:[],total:0});case 10:return d=(h=[]).concat.apply(h,L(d)),y=d.map((function(e){return e.id=e.id||e["@id"],e})),o.sort&&(y=y.sort((function(e,t){return void 0!==e[o.sort.field]&&void 0!==t[o.sort.field]?"ASC"===o.sort.order?me(e[o.sort.field],t[o.sort.field]):me(t[o.sort.field],e[o.sort.field]):0}))),o.pagination&&(y=y.slice((o.pagination.page-1)*o.pagination.perPage,o.pagination.page*o.pagination.perPage)),t.abrupt("return",{data:y,total:d.length});case 15:case"end":return t.stop()}}),t)})));return function(e,r,n,o){return t.apply(this,arguments)}}(),we=function(e,t){var r={};return Object.keys(e).forEach((function(n){if(!t[n])throw new Error("No server found with key "+n);r[n]=[],e[n].forEach((function(e){r[n].push(I(t[n].baseUrl,e))}))})),r},xe=function(e){return function(){var t=j(k().mark((function t(r){var n,o,a,i,c,s,u,f,l,p,d,h=arguments;return k().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(i=h.length>1&&void 0!==h[1]?h[1]:{},c=e.dataServers,s=e.resources,u=s[r]){t.next=5;break}throw new Error("Resource ".concat(r," is not mapped in resources file"));case 5:if(null!==(n=i.filter)&&void 0!==n&&n._servers||null===(o=u.list)||void 0===o||!o.containers){t.next=11;break}if(!Array.isArray(null===(l=u.list)||void 0===l?void 0:l.containers)){t.next=8;break}throw new Error("The list.containers property of ".concat(r," dataModel must be of type object ({ serverKey: [containerUri] })"));case 8:f=we(u.list.containers,c),t.next=12;break;case 11:f=G(u.types,(null===(p=i.filter)||void 0===p?void 0:p._servers)||(null===(d=u.list)||void 0===d?void 0:d.servers),c);case 12:if(null===(a=u.list)||void 0===a||!a.fetchContainer){t.next=16;break}return t.abrupt("return",K(f,r,i,e));case 16:return t.abrupt("return",be(f,r,i,e));case 17:case"end":return t.stop()}}),t)})));return function(e){return t.apply(this,arguments)}}()},ke=function(e){return function(){var t=j(k().mark((function t(r,n){var o,a;return k().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return o=e.returnFailedResources,t.next=3,Promise.all(n.ids.map((function(t){return B(e)(r,{id:"object"===S(t)?t["@id"]:t}).then((function(e){return e.data})).catch((function(){if(o)return{id:t,_error:!0}}))})));case 3:return a=(a=t.sent).filter((function(e){return e})),t.abrupt("return",{data:a});case 6:case"end":return t.stop()}}),t)})));return function(e,r){return t.apply(this,arguments)}}()},Se=function(e){return function(){var t=j(k().mark((function t(r,n){return k().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n.filter=x(x({},n.filter),{},E({},n.target,n.id)),delete n.target,t.next=4,xe(e)(r,n);case 4:return t.abrupt("return",t.sent);case 5:case"end":return t.stop()}}),t)})));return function(e,r){return t.apply(this,arguments)}}()},Oe=function(e){return function(){var t=j(k().mark((function t(r,n){var o,a;return k().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return o=e.httpClient,a=e.jsonContext,t.next=3,H(n.data,e);case 3:return n.data=t.sent,t.next=6,o(n.id,{method:"PUT",body:JSON.stringify(x({"@context":a},n.data))});case 6:return t.abrupt("return",{data:n.data});case 7:case"end":return t.stop()}}),t)})));return function(e,r){return t.apply(this,arguments)}}()};function je(e){this.message=e}je.prototype=new Error,je.prototype.name="InvalidCharacterError";var Ee="undefined"!=typeof window&&window.atob&&window.atob.bind(window)||function(e){var t=String(e).replace(/=+$/,"");if(t.length%4==1)throw new je("'atob' failed: The string to be decoded is not correctly encoded.");for(var r,n,o=0,a=0,i="";n=t.charAt(a++);~n&&(r=o%4?64*r+n:n,o++%4)?i+=String.fromCharCode(255&r>>(-2*o&6)):0)n="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".indexOf(n);return i};function Ae(e){var t=e.replace(/-/g,"+").replace(/_/g,"/");switch(t.length%4){case 0:break;case 2:t+="==";break;case 3:t+="=";break;default:throw"Illegal base64url string!"}try{return function(e){return decodeURIComponent(Ee(e).replace(/(.)/g,(function(e,t){var r=t.charCodeAt(0).toString(16).toUpperCase();return r.length<2&&(r="0"+r),"%"+r})))}(t)}catch(e){return Ee(t)}}function Ce(e){this.message=e}function _e(e,t){if("string"!=typeof e)throw new Ce("Invalid token specified");var r=!0===(t=t||{}).header?0:1;try{return JSON.parse(Ae(e.split(".")[r]))}catch(e){throw new Ce("Invalid token specified: "+e.message)}}Ce.prototype=new Error,Ce.prototype.name="InvalidTokenError";var Le=function(){var e=j(k().mark((function e(t){var r,n,o,a,i,c,s,u,f,l,p,d;return k().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(r=t.dataServers,n=t.httpClient,o=localStorage.getItem("token"),a=W("pod",r),i=W("authServer",r),!o){e.next=24;break}return c=_e(o),s=c.webId,e.prev=6,e.next=9,n(s);case 9:f=e.sent,l=f.json,u=l,e.next=20;break;case 14:return e.prev=14,e.t0=e.catch(6),console.error(e.t0),localStorage.clear(),window.location.reload(),e.abrupt("return");case 20:a&&(t.dataServers[a].name="My Pod",t.dataServers[a].baseUrl=I(s,"data"),t.dataServers[a].sparqlEndpoint=(null===(p=u.endpoints)||void 0===p?void 0:p["void:sparqlEndpoint"])||I(s,"sparql")),i&&(t.dataServers[i].proxyUrl=null===(d=u.endpoints)||void 0===d?void 0:d.proxyUrl),e.next=25;break;case 24:a&&delete t.dataServers[a];case 25:case"end":return e.stop()}}),e,null,[[6,14]])})));return function(t){return e.apply(this,arguments)}}(),Pe=function(e){return e?Array.isArray(e)?e:[e]:void 0},Ne=function(){var e=j(k().mark((function e(t){var r,n,o,a,i,c,s,u;return k().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return r=Object.entries(t.dataServers).filter((function(e){var t=_(e,2);return t[0],!0!==t[1].pod})).map((function(e){var r=_(e,2),n=r[0],o=r[1];return t.httpClient(new URL("/.well-known/void",o.baseUrl).toString()).then((function(e){return{key:n,datasets:e.json["@graph"]}})).catch((function(e){if(404===e.status||401===e.status)return{key:n,error:e};throw e}))})),n=[],e.prev=2,e.next=5,Promise.all(r);case 5:n=e.sent,e.next=10;break;case 8:e.prev=8,e.t0=e.catch(2);case 10:o=T(n);try{for(o.s();!(a=o.n()).done;)if(i=a.value,t.dataServers[i.key].containers=t.dataServers[i.key].containers||{},t.dataServers[i.key].blankNodes=t.dataServers[i.key].blankNodes||{},i.datasets){c=T(i.datasets);try{for(u=function(){var e=s.value,r=Object.keys(t.dataServers).find((function(r){return e["void:uriSpace"]===t.dataServers[r].baseUrl}));if(r){r===i.key&&(t.dataServers[i.key].name=t.dataServers[i.key].name||e["dc:title"],t.dataServers[i.key].description=t.dataServers[i.key].description||e["dc:description"],t.dataServers[i.key].sparqlEndpoint=t.dataServers[i.key].sparqlEndpoint||e["void:sparqlEndpoint"]),t.dataServers[i.key].containers[r]=t.dataServers[i.key].containers[r]||{};var n,o=T(Pe(e["void:classPartition"]));try{for(o.s();!(n=o.n()).done;){var a,c=n.value,u=T(Pe(c["void:class"]));try{for(u.s();!(a=u.n()).done;){var f=a.value,l=c["void:uriSpace"].replace(e["void:uriSpace"],"/");t.dataServers[i.key].containers[r][f]?t.dataServers[i.key].containers[r][f].push(l):t.dataServers[i.key].containers[r][f]=[l],Pe(c["semapps:blankNodes"])&&(t.dataServers[i.key].blankNodes[c["void:uriSpace"]]=Pe(c["semapps:blankNodes"]))}}catch(e){u.e(e)}finally{u.f()}}}catch(e){o.e(e)}finally{o.f()}}},c.s();!(s=c.n()).done;)u()}catch(e){c.e(e)}finally{c.f()}}}catch(e){o.e(e)}finally{o.f()}case 12:case"end":return e.stop()}}),e,null,[[2,8]])})));return function(t){return e.apply(this,arguments)}}(),Te=function(e,t){return Object.keys(t).find((function(r){return t[r].pod?t[r].baseUrl&&e.startsWith(t[r].baseUrl.replace("/data","")):e.startsWith(t[r].baseUrl)}))},Ue=function(e){if(!W("default",e.dataServers))throw new Error("You must define a default server in your dataServers config");var t;e.jsonContext||(e.jsonContext=Object.fromEntries(e.ontologies.map((function(e){return[e.prefix,e.url]})))),e.returnFailedResources||(e.returnFailedResources=!1),e.httpClient=(t=e.dataServers,function(e){var r,n,o=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},a=W("authServer",t),i=Te(e,t),s=i!==a&&(null===(r=t[a])||void 0===r?void 0:r.proxyUrl)&&!0!==(null===(n=t[i])||void 0===n?void 0:n.noProxy);switch(o.headers||(o.headers=new Headers),o.method){case"POST":case"PATCH":case"PUT":o.headers.has("Accept")||o.headers.set("Accept","application/ld+json"),o.headers.has("Content-Type")||o.headers.set("Content-Type","application/ld+json");break;case"DELETE":break;case"GET":default:o.headers.has("Accept")||o.headers.set("Accept","application/ld+json")}if(s){var u=new FormData;return u.append("id",e),u.append("method",o.method||"GET"),u.append("headers",JSON.stringify(Object.fromEntries(o.headers.entries()))),o.body&&(o.body instanceof File?u.append("body",o.body,o.body.name):u.append("body",o.body)),c.fetchJson(t[a].proxyUrl,{method:"POST",headers:new Headers({Authorization:"Bearer ".concat(localStorage.getItem("token"))}),body:u})}if(i===a){var f=localStorage.getItem("token");f&&o.headers.set("Authorization","Bearer ".concat(f))}return c.fetchJson(e,o)});var r=Le(e),n=Ne(e),o=function(e){return j(k().mark((function t(){var o=arguments;return k().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,r;case 2:return t.next=4,n;case 4:return t.next=6,e.apply(void 0,o);case 6:return t.abrupt("return",t.sent);case 7:case"end":return t.stop()}}),t)})))};return{getList:o(xe(e)),getMany:o(ke(e)),getManyReference:o(Se(e)),getOne:o(B(e)),create:o(J(e)),update:o(Oe(e)),updateMany:function(){throw new Error("updateMany is not implemented yet")},delete:o($(e)),deleteMany:o(Y(e)),getDataModels:o(X(e)),getDataServers:o(V(e)),getLocalDataServers:V(e),fetch:o(e.httpClient)}},qe=function(e,t){return"function"==typeof e?e(t):e},Ie=function(e){return"string"==typeof e&&e.startsWith("http")},Me=function(e){var t=h(s).getLocalDataServers(),r=y((function(){if(t)return Object.fromEntries(Object.values(t).map((function(e){var t=void 0!==e.externalLinks?e.externalLinks:!e.default;return[e.baseUrl,t]})))}),[t]);return v((function(t){var n=qe(e,t);if(!1===n)return!1;if(null==t||!t.id)return!1;var o=Object.keys(r).find((function(e){return null==t?void 0:t.id.startsWith(e)}));if(!o)return!1;var a=qe(r[o],t);return!1!==a&&(Ie(n)?n:Ie(a)?a:t.id)}),[r,e])},Be=function(e){var t=h(s),r=_(g(),2),n=r[0],o=r[1];return m((function(){t.getDataModels().then((function(t){return o(t[e])}))}),[t,e,o]),n},De=function(){var e=h(s),t=_(g(),2),r=t[0],n=t[1];return m((function(){e.getDataServers().then((function(e){return n(e)}))}),[e,n]),r},Fe=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"@all",r=Be(e),n=De(),o=g(),a=_(o,2),i=a[0],c=a[1];return m((function(){r&&n&&c(G(r.types,t,n))}),[r,n,t]),i},Re=function(e,t,r){var n=[];if(Object.keys(r[t].containers[t]).length>0&&Object.keys(r[t].containers[t]).forEach((function(o){e.includes(o)&&r[t].containers[t][o].map((function(e){var o=I(r[t].baseUrl,e);n.includes(o)||n.push(o)}))})),0===n.length)throw new Error("No container found matching with types ".concat(JSON.stringify(e),". You can set explicitely the create.container property of the resource."));if(n.length>1)throw new Error("More than one container found matching with types ".concat(JSON.stringify(e),". You must set the create.server or create.container property for the resource."));return n[0]},He=function(e){var t=Be(e),r=De(),n=_(g(),2),o=n[0],a=n[1];return m((function(){var n,o;if(t&&r)if(null!==(n=t.create)&&void 0!==n&&n.container){var i=_(Object.entries(t.create.container)[0],2),c=i[0],s=i[1];if(!c||!r[c])throw new Error("Wrong key for the dataModel.create.container config of resource "+e);a(I(r[c].baseUrl,s))}else if(null!==(o=t.create)&&void 0!==o&&o.server){var u;a(Re(t.types,null===(u=t.create)||void 0===u?void 0:u.server,r))}else{var f=W("default",r);a(Re(t.types,f,r))}}),[t,r,a]),o},We=function(){var e=h(s),t=_(g(),2),r=t[0],n=t[1];return m((function(){e.getDataModels().then((function(e){return n(e)}))}),[e,n]),r},ze=["children","record","filter","source"],Ge=function(e){var t=e.children,r=e.record,n=e.filter,o=e.source,a=C(e,ze),i=_(g(),2),c=i[0],s=i[1];return m((function(){if(r&&o&&Array.isArray(null==r?void 0:r[o])){var e=null==r?void 0:r[o].filter((function(e){var t=!0;for(var r in n){var o=e[r];Array.isArray(o)?o.includes(n[r])||(t=!1):o!==n[r]&&(t=!1)}return t})),t=x({},r);t[o]=e.length>0?e:void 0,s(t)}}),[r,o,n]),d.createElement(d.Fragment,null,d.Children.map(t,(function(e,t){return d.cloneElement(e,x(x({},a),{},{record:c,addLabel:!0,source:o}))})))},Je=["children","groupReference","groupLabel","groupHeader","filterProperty"],$e=function(e){var t=e.children,r=e.groupReference,n=e.groupLabel,o=e.groupHeader,a=e.filterProperty,i=C(e,Je),c=u({type:"getList",resource:r,payload:{}}).data;return d.createElement(d.Fragment,null,null==c?void 0:c.map((function(e,r){var c={};return c[a]=e.id,d.createElement(d.Fragment,null,o&&o(x(x({},i),{},{group:e})),d.createElement(Ge,A({},i,{filter:c,label:e[n]}),t))})))},Ye=["reificationClass","children"],Ve=b({form:{display:"flex"},input:{paddingRight:"20px"}}),Xe=b({root:{display:"none"}}),Ke=function(e){var t=e.reificationClass;e.children;var r=C(e,Ye),n=Ve(),o=Xe();return d.createElement(f,r,d.createElement(l,{classes:{form:n.form}},d.Children.map(e.children,(function(e,t){return d.cloneElement(e,{className:n.input})})),d.createElement(p,{className:o.root,source:"type",initialValue:t})))};export{Ge as FilterHandler,$e as GroupedReferenceHandler,Ke as ReificationArrayInput,se as buildBlankNodesQuery,ye as buildSparqlQuery,Ue as dataProvider,Fe as useContainers,He as useCreateContainer,Be as useDataModel,We as useDataModels,De as useDataServers,Me as useGetExternalLink};
|
|
4
4
|
//# sourceMappingURL=index.es.js.map
|