import * as __WEBPACK_EXTERNAL_MODULE_rdflib__ from "rdflib"; /******/ var __webpack_modules__ = ({ /***/ 52 (__unused_webpack_module, __webpack_exports__, __webpack_require__) { __webpack_require__.r(__webpack_exports__); /* harmony export */ __webpack_require__.d(__webpack_exports__, { /* harmony export */ AJARImage: () => (/* binding */ AJARImage), /* harmony export */ RDFComparePredicateObject: () => (/* binding */ RDFComparePredicateObject), /* harmony export */ RDFComparePredicateSubject: () => (/* binding */ RDFComparePredicateSubject), /* harmony export */ addLoadEvent: () => (/* binding */ addLoadEvent), /* harmony export */ ancestor: () => (/* binding */ ancestor), /* harmony export */ beep: () => (/* binding */ beep), /* harmony export */ clearVariableNames: () => (/* binding */ clearVariableNames), /* harmony export */ emptyNode: () => (/* binding */ emptyNode), /* harmony export */ escapeForXML: () => (/* binding */ escapeForXML), /* harmony export */ findPos: () => (/* binding */ findPos), /* harmony export */ genUuid: () => (/* binding */ genUuid), /* harmony export */ getAbout: () => (/* binding */ getAbout), /* harmony export */ getEyeFocus: () => (/* binding */ getEyeFocus), /* harmony export */ getTarget: () => (/* binding */ getTarget), /* harmony export */ getTerm: () => (/* binding */ getTerm), /* harmony export */ hashColor: () => (/* binding */ hashColor), /* harmony export */ include: () => (/* binding */ include), /* harmony export */ label: () => (/* reexport safe */ _label__WEBPACK_IMPORTED_MODULE_4__.P), /* harmony export */ labelForXML: () => (/* binding */ labelForXML), /* harmony export */ labelWithOntology: () => (/* binding */ labelWithOntology), /* harmony export */ newVariableName: () => (/* binding */ newVariableName), /* harmony export */ ontologyLabel: () => (/* binding */ ontologyLabel), /* harmony export */ predParentOf: () => (/* binding */ predParentOf), /* harmony export */ predicateLabel: () => (/* binding */ predicateLabel), /* harmony export */ predicateLabelForXML: () => (/* binding */ predicateLabelForXML), /* harmony export */ shortName: () => (/* binding */ shortName), /* harmony export */ stackString: () => (/* binding */ stackString), /* harmony export */ syncTableToArray: () => (/* binding */ syncTableToArray), /* harmony export */ syncTableToArrayReOrdered: () => (/* binding */ syncTableToArrayReOrdered) /* harmony export */ }); /* harmony import */ var _log__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(4158); /* harmony import */ var solid_logic_jss__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(5175); /* harmony import */ var _ns__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(1795); /* harmony import */ var rdflib__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(4961); /* harmony import */ var _label__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(9612); // Solid-UI general Utilities // ========================== // // This must load AFTER the rdflib.js and log-ext.js (or log.js). // // pull in first avoid cross-refs var UI = { log: _log__WEBPACK_IMPORTED_MODULE_0__, ns: _ns__WEBPACK_IMPORTED_MODULE_2__/* ["default"] */ .A, rdf: rdflib__WEBPACK_IMPORTED_MODULE_3__ }; var nextVariable = 0; function newVariableName() { return 'v' + nextVariable++; } function clearVariableNames() { nextVariable = 0; } // http://stackoverflow.com/questions/879152/how-do-i-make-javascript-beep // http://www.tsheffler.com/blog/2013/05/14/audiocontext-noteonnoteoff-and-time-units/ var audioContext; if (typeof AudioContext !== 'undefined') { audioContext = AudioContext; } else if (typeof window !== 'undefined') { audioContext = window.AudioContext || window.webkitAudioContext; } function beep() { if (!audioContext) { return; } // Safari 2015 var ContextClass = audioContext; var ctx = new ContextClass(); return function (duration, frequency, type, finishedCallback) { duration = +(duration || 0.3); // Only 0-4 are valid types. type = type || 'sine'; // sine, square, sawtooth, triangle if (typeof finishedCallback !== 'function') { finishedCallback = function finishedCallback() {}; } var osc = ctx.createOscillator(); osc.type = type; osc.frequency.value = frequency || 256; osc.connect(ctx.destination); osc.start(0); osc.stop(duration); }; } // Make pseudorandom color from a uri // NOT USED ANYWHERE function hashColor(who) { who = who.uri || who; var hash = function hash(x) { return x.split('').reduce(function (a, b) { a = (a << 5) - a + b.charCodeAt(0); return a & a; }, 0); }; return '#' + (hash(who) & 0xffffff | 0xc0c0c0).toString(16); // c0c0c0 or 808080 forces pale } function genUuid() { // http://stackoverflow.com/questions/105034/create-guid-uuid-in-javascript return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function (c) { var r = Math.random() * 16 | 0; var v = c === 'x' ? r : r & 0x3 | 0x8; return v.toString(16); }); } /** Sync a DOM table with an array of things * * @param {DomElement} table - will have a tr for each thing * @param {Array} things - ORDERED array of NamedNode objects * @param {function({NamedNode})} createNewRow(thing) returns a TR table row for a new thing * * Tolerates out of order elements but puts new ones in order. * Can be used for any element type; does not have to be a table and tr. */ function syncTableToArray(table, things, createNewRow) { var foundOne; var row; var i; for (i = 0; i < table.children.length; i++) { row = table.children[i]; row.trashMe = true; } for (var g = 0; g < things.length; g++) { var thing = things[g]; foundOne = false; for (i = 0; i < table.children.length; i++) { row = table.children[i]; if (row.subject && row.subject.sameTerm(thing)) { row.trashMe = false; foundOne = true; break; } } if (!foundOne) { var newRow = createNewRow(thing); // Insert new row in position g in the table to match array if (g >= table.children.length) { table.appendChild(newRow); } else { var ele = table.children[g]; table.insertBefore(newRow, ele); } newRow.subject = thing; } // if not foundOne } // loop g for (i = 0; i < table.children.length; i++) { row = table.children[i]; if (row.trashMe) { table.removeChild(row); } } } // syncTableToArray /** Sync a DOM table with an array of things * * @param {DomElement} table - will have a tr for each thing * @param {Array} things - ORDERED array of UNIQUE NamedNode objects. No duplicates * @param {function({NamedNode})} createNewRow(thing) returns a rendering of a new thing * * Ensures order matches exacly. We will re-rder existing elements if necessary * Can be used for any element type; does not have to be a table and tr. * Any RDF node value can only appear ONCE in the array */ function syncTableToArrayReOrdered(table, things, createNewRow) { var elementMap = {}; for (var i = 0; i < table.children.length; i++) { var row = table.children[i]; elementMap[row.subject.toNT()] = row; // More sophisticaed would be to have a bag of duplicates } for (var g = 0; g < things.length; g++) { var thing = things[g]; if (g >= table.children.length) { // table needs extending var newRow = createNewRow(thing); newRow.subject = thing; table.appendChild(newRow); } else { var _row = table.children[g]; if (_row.subject.sameTerm(thing)) { // ... } else { var existingRow = elementMap[thing.toNT()]; if (existingRow) { table.removeChild(existingRow); table.insertBefore(existingRow, _row); // Insert existing row in place of this one } else { var _newRow = createNewRow(thing); _row.before(_newRow); // Insert existing row in place of this one _newRow.subject = thing; } } } } // loop g // Lop off any we don't need any more: while (table.children.length > things.length) { table.removeChild(table.children[table.children.length - 1]); } } // syncTableToArrayReOrdered /* Error stack to string for better diagnotsics ** ** See http://snippets.dzone.com/posts/show/6632 */ function stackString(e) { var str = '' + e + '\n'; var i; if (!e.stack) { return str + 'No stack available.\n'; } var lines = e.stack.toString().split('\n'); var toPrint = []; for (i = 0; i < lines.length; i++) { var line = lines[i]; if (line.indexOf('ecmaunit.js') > -1) { // remove useless bit of traceback break; } if (line.charAt(0) === '(') { line = 'function' + line; } var chunks = line.split('@'); toPrint.push(chunks); } // toPrint.reverse(); No - I prefer the latest at the top by the error message -tbl for (i = 0; i < toPrint.length; i++) { str += ' ' + toPrint[i][1] + '\n ' + toPrint[i][0]; } return str; } function emptyNode(node) { var nodes = node.childNodes; var len = nodes.length; for (var i = len - 1; i >= 0; i--) node.removeChild(nodes[i]); return node; } function getTarget(e) { var target; e = e || window.event; if (e.target) target = e.target;else if (e.srcElement) target = e.srcElement; if (target.nodeType === 3) { // defeat Safari bug [sic] target = target.parentNode; } // UI.log.debug("Click on: " + target.tagName) return target; } function ancestor(target, tagName) { var level; for (level = target; level; level = level.parentNode) { // UI.log.debug("looking for "+tagName+" Level: "+level+" "+level.tagName) try { if (level.tagName === tagName) return level; } catch (e) { // can hit "TypeError: can't access dead object" in ffox return undefined; } } return undefined; } function getAbout(kb, target) { var level, aa; for (level = target; level && level.nodeType === 1; level = level.parentNode) { // UI.log.debug("Level "+level + ' '+level.nodeType + ': '+level.tagName) aa = level.getAttribute('about'); if (aa) { // UI.log.debug("kb.fromNT(aa) = " + kb.fromNT(aa)) return kb.fromNT(aa); // } else { // if (level.tagName=='TR') return undefined//this is to prevent literals passing through } } UI.log.debug('getAbout: No about found'); return undefined; } function getTerm(target) { var statementTr = target.parentNode; var st = statementTr ? statementTr.AJAR_statement : undefined; var className = st ? target.className : ''; // if no st then it's necessary to use getAbout switch (className) { case 'pred': case 'pred selected': return st.predicate; case 'obj': case 'obj selected': if (!statementTr.AJAR_inverse) { return st.object; } else { return st.subject; } case '': case 'selected': // header TD return getAbout(solid_logic_jss__WEBPACK_IMPORTED_MODULE_1__/* .store */ .M_, target); // kb to be changed case 'undetermined selected': return target.nextSibling ? st.predicate : !statementTr.AJAR_inverse ? st.object : st.subject; } } function include(document, linkstr) { var lnk = document.createElement('script'); lnk.setAttribute('type', 'text/javascript'); lnk.setAttribute('src', linkstr); // TODO:This needs to be fixed or no longer used. // document.getElementsByTagName('head')[0].appendChild(lnk) return lnk; } function addLoadEvent(func) { var oldonload = window.onload; if (typeof window.onload !== 'function') { window.onload = func; } else { window.onload = function () { oldonload(); func(); }; } } // addLoadEvent // Find the position of an object relative to the window function findPos(obj) { // C&P from http://www.quirksmode.org/js/findpos.html var myDocument = obj.ownerDocument; var DocBox = myDocument.documentElement.getBoundingClientRect(); var box = obj.getBoundingClientRect(); return [box.left - DocBox.left, box.top - DocBox.top]; } function getEyeFocus(element, instantly, isBottom, myWindow) { if (!myWindow) myWindow = window; var elementPosY = findPos(element)[1]; var appContext = window.SolidAppContext || {}; var scrollDiff = appContext && appContext.scroll || 52; // 52 = magic number for web-based version var totalScroll = elementPosY - scrollDiff - myWindow.scrollY; if (instantly) { if (isBottom) { myWindow.scrollBy(0, elementPosY + element.clientHeight - (myWindow.scrollY + myWindow.innerHeight)); return; } myWindow.scrollBy(0, totalScroll); return; } var id = myWindow.setInterval(scrollAmount, 50); var times = 0; function scrollAmount() { myWindow.scrollBy(0, totalScroll / 10); times++; if (times === 10) { myWindow.clearInterval(id); } } } function AJARImage(src, alt, tt, doc) { if (!doc) { doc = document; } var image = doc.createElement('img'); image.setAttribute('src', src); image.addEventListener('copy', function (e) { e.clipboardData.setData('text/plain', ''); e.clipboardData.setData('text/html', ''); e.preventDefault(); // We want no title data to be written to the clipboard }); // if (typeof alt != 'undefined') // Messes up cut-and-paste of text // image.setAttribute('alt', alt) if (typeof tt !== 'undefined') { image.setAttribute('title', tt); } return image; } // Make short name for ontology function shortName(uri) { var p = uri; if ('#/'.indexOf(p[p.length - 1]) >= 0) p = p.slice(0, -1); var namespaces = []; for (var _ns in this.prefixes) { namespaces[this.prefixes[_ns]] = _ns; // reverse index } var pok; var canUse = function canUse(pp) { // if (!__Serializer.prototype.validPrefix.test(pp)) return false; // bad format if (pp === 'ns') return false; // boring // if (pp in this.namespaces) return false; // already used // this.prefixes[uri] = pp; // this.namespaces[pp] = uri; pok = pp; return true; }; var i; var hash = p.lastIndexOf('#'); if (hash >= 0) p = p.slice(hash - 1); // lop off localid // eslint-disable-next-line no-unreachable-loop for (;;) { var slash = p.lastIndexOf('/'); if (slash >= 0) p = p.slice(slash + 1); i = 0; while (i < p.length) { if (this.prefixchars.indexOf(p[i])) i++;else break; } p = p.slice(0, i); if (p.length < 6 && canUse(p)) return pok; // exact i sbest if (canUse(p.slice(0, 3))) return pok; if (canUse(p.slice(0, 2))) return pok; if (canUse(p.slice(0, 4))) return pok; if (canUse(p.slice(0, 1))) return pok; if (canUse(p.slice(0, 5))) return pok; for (i = 0;; i++) if (canUse(p.slice(0, 3) + i)) return pok; } } // Short name for an ontology function ontologyLabel(term) { if (term.uri === undefined) return '??'; var s = term.uri; var namespaces = []; var i = s.lastIndexOf('#'); var part; if (i >= 0) { s = s.slice(0, i + 1); } else { i = s.lastIndexOf('/'); if (i >= 0) { s = s.slice(0, i + 1); } else { return term.uri + '?!'; // strange should have # or / } } for (var _ns2 in UI.ns) { namespaces[UI.ns[_ns2]] = _ns2; // reverse index } try { return namespaces[s]; } catch (e) {} s = s.slice(0, -1); // Chop off delimiter ... now have just while (s) { i = s.lastIndexOf('/'); if (i >= 0) { part = s.slice(i + 1); s = s.slice(0, i); if (part !== 'ns' && '0123456789'.indexOf(part[0]) < 0) { return part; } } else { return term.uri + '!?'; // strange should have a nice part } } } function labelWithOntology(x, initialCap) { var t = solid_logic_jss__WEBPACK_IMPORTED_MODULE_1__/* .store */ .M_.findTypeURIs(x); if (t[UI.ns.rdf('Predicate').uri] || t[UI.ns.rdfs('Class').uri]) { return (0,_label__WEBPACK_IMPORTED_MODULE_4__/* .label */ .P)(x, initialCap) + ' (' + ontologyLabel(x) + ')'; } return (0,_label__WEBPACK_IMPORTED_MODULE_4__/* .label */ .P)(x, initialCap); } function escapeForXML(str) { return str.replace(/&/g, '&').replace(/ (/* binding */ _isNativeFunction) /* harmony export */ }); function _isNativeFunction(t) { try { return -1 !== Function.toString.call(t).indexOf("[native code]"); } catch (n) { return "function" == typeof t; } } /***/ }, /***/ 386 (__unused_webpack_module, __webpack_exports__, __webpack_require__) { /* harmony export */ __webpack_require__.d(__webpack_exports__, { /* harmony export */ DK: () => (/* binding */ makeDropTarget), /* harmony export */ Zn: () => (/* binding */ uploadFiles), /* harmony export */ eB: () => (/* binding */ makeDraggable) /* harmony export */ }); /* harmony import */ var _debug__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(7423); /* harmony import */ var _utils_mimeTypes__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(6355); /* harmony import */ var _style__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(675); /* Drag and drop common functionality * * It is easy to make something draggable, or to make it a drag target! * Just call the functions below. In a Solid world, any part of the UI which * represents one thing which has a URI, should be made draggable using makeDraggable. * Any list of things should typically allow you to drag new members of the list * onto it. * The file upload function, uploadFiles, is provided as often as someone drags a file from the computer * desktop. You may want to upload it into the pod. */ /* global FileReader alert */ function makeDropTarget(ele, droppedURIHandler, droppedFileHandler) { var dragoverListener = function dragoverListener(e) { e.preventDefault(); // Need this; otherwise, drop does not work. e.dataTransfer.dropEffect = 'copy'; }; var dragenterListener = function dragenterListener(e) { _debug__WEBPACK_IMPORTED_MODULE_0__/* .log */ .Rm('dragenter event dropEffect: ' + e.dataTransfer.dropEffect); if (this.localStyle) { // necessary not sure when if (!this.savedStyle) { this.savedStyle = _style__WEBPACK_IMPORTED_MODULE_2__/* .style */ .i.dragEvent; } } e.dataTransfer.dropEffect = 'link'; _debug__WEBPACK_IMPORTED_MODULE_0__/* .log */ .Rm('dragenter event dropEffect 2: ' + e.dataTransfer.dropEffect); }; var dragleaveListener = function dragleaveListener(e) { _debug__WEBPACK_IMPORTED_MODULE_0__/* .log */ .Rm('dragleave event dropEffect: ' + e.dataTransfer.dropEffect); if (this.savedStyle) { this.localStyle = this.savedStyle; } else { this.localStyle = _style__WEBPACK_IMPORTED_MODULE_2__/* .style */ .i.dropEvent; } }; var dropListener = function dropListener(e) { if (e.preventDefault) e.preventDefault(); // stops the browser from redirecting off to the text. _debug__WEBPACK_IMPORTED_MODULE_0__/* .log */ .Rm('Drop event. dropEffect: ' + e.dataTransfer.dropEffect); _debug__WEBPACK_IMPORTED_MODULE_0__/* .log */ .Rm('Drop event. types: ' + (e.dataTransfer.types ? e.dataTransfer.types.join(', ') : 'NOPE')); var uris = null; var text; if (e.dataTransfer.types) { for (var t = 0; t < e.dataTransfer.types.length; t++) { var type = e.dataTransfer.types[t]; if (type === 'text/uri-list') { uris = e.dataTransfer.getData(type).split('\n'); // @ ignore those starting with # _debug__WEBPACK_IMPORTED_MODULE_0__/* .log */ .Rm('Dropped text/uri-list: ' + uris); } else if (type === 'text/plain') { text = e.dataTransfer.getData(type); } else if (type === 'Files' && droppedFileHandler) { var files = e.dataTransfer.files; // FileList object. for (var i = 0; files[i]; i++) { var f = files[i]; _debug__WEBPACK_IMPORTED_MODULE_0__/* .log */ .Rm('Filename: ' + f.name + ', type: ' + (f.type || 'n/a') + ' size: ' + f.size + ' bytes, last modified: ' + (f.lastModifiedDate ? f.lastModifiedDate.toLocaleDateString() : 'n/a')); } droppedFileHandler(files); } } if (uris === null && text && text.slice(0, 4) === 'http') { uris = text; _debug__WEBPACK_IMPORTED_MODULE_0__/* .log */ .Rm('Waring: Poor man\'s drop: using text for URI'); // chrome disables text/uri-list?? } } else { // ... however, if we're IE, we don't have the .types property, so we'll just get the Text value uris = [e.dataTransfer.getData('Text')]; _debug__WEBPACK_IMPORTED_MODULE_0__/* .log */ .Rm('WARNING non-standard drop event: ' + uris[0]); } _debug__WEBPACK_IMPORTED_MODULE_0__/* .log */ .Rm('Dropped URI list (2): ' + uris); if (uris) { droppedURIHandler(uris); } this.localStyle = _style__WEBPACK_IMPORTED_MODULE_2__/* .style */ .i.restoreStyle; // restore style return false; }; // dropListener var addTargetListeners = function addTargetListeners(ele) { if (!ele) { _debug__WEBPACK_IMPORTED_MODULE_0__/* .log */ .Rm('@@@ addTargetListeners: ele ' + ele); } ele.addEventListener('dragover', dragoverListener); ele.addEventListener('dragenter', dragenterListener); ele.addEventListener('dragleave', dragleaveListener); ele.addEventListener('drop', dropListener); }; addTargetListeners(ele, droppedURIHandler); } // listen for dropped URIs // Make an HTML element draggable as a URI-identified thing // // Possibly later set the drag image too? // function makeDraggable(tr, obj) { tr.setAttribute('draggable', 'true'); // Stop the image being dragged instead - just the TR tr.addEventListener('dragstart', function (e) { tr.style.fontWeight = 'bold'; e.dataTransfer.setData('text/uri-list', obj.uri); e.dataTransfer.setData('text/plain', obj.uri); e.dataTransfer.setData('text/html', tr.outerHTML); _debug__WEBPACK_IMPORTED_MODULE_0__/* .log */ .Rm('Dragstart: ' + tr + ' -> ' + obj + 'de: ' + e.dataTransfer.dropEffect); }, false); tr.addEventListener('drag', function (e) { e.preventDefault(); e.stopPropagation(); // debug.log('Drag: dropEffect: ' + e.dataTransfer.dropEffect) }, false); tr.addEventListener('dragend', function (e) { tr.style.fontWeight = 'normal'; _debug__WEBPACK_IMPORTED_MODULE_0__/* .log */ .Rm('Dragend dropeffect: ' + e.dataTransfer.dropEffect); _debug__WEBPACK_IMPORTED_MODULE_0__/* .log */ .Rm('Dragend: ' + tr + ' -> ' + obj); }, false); } /** uploadFiles ** ** Generic uploader of local files to the web ** typically called from dropped file handler ** ** @param {Fetcher} fetcher instance of class Fetcher as in kb.fetcher ** @param {Array} files Array of file objects ** @param {String} fileBase URI of folder in which to put files (except images) (no trailing slash) ** @param {String } imageBase URI of folder in which to put images ** @param successHandler function(file, uploadedURI) Called after EACH success upload ** With file object an final URI as params */ function uploadFiles(fetcher, files, fileBase, imageBase, successHandler) { for (var i = 0; files[i]; i++) { var f = files[i]; _debug__WEBPACK_IMPORTED_MODULE_0__/* .log */ .Rm(' dropped: Filename: ' + f.name + ', type: ' + (f.type || 'n/a') + ' size: ' + f.size + ' bytes, last modified: ' + (f.lastModifiedDate ? f.lastModifiedDate.toLocaleDateString() : 'n/a')); // See e.g. https://www.html5rocks.com/en/tutorials/file/dndfiles/ // @@ Add: progress bar(s) var reader = new FileReader(); reader.onload = function (theFile) { return function (e) { var data = e.target.result; var suffix = ''; _debug__WEBPACK_IMPORTED_MODULE_0__/* .log */ .Rm(' File read byteLength : ' + data.byteLength); var contentType = theFile.type; if (!theFile.type || theFile.type === '') { // Not known by browser contentType = _utils_mimeTypes__WEBPACK_IMPORTED_MODULE_1__/* .lookup */ .$I(theFile.name); if (!contentType) { var msg = 'Filename needs to have an extension which gives a type we know: ' + theFile.name; _debug__WEBPACK_IMPORTED_MODULE_0__/* .log */ .Rm(msg); alert(msg); throw new Error(msg); } } else { var extension = _utils_mimeTypes__WEBPACK_IMPORTED_MODULE_1__/* .extension */ .ck(theFile.type); // Note not simple: eg .mp3 => audio/mpeg; .mpga => audio/mpeg; audio/mp3 => .mp3 if (extension && extension !== 'false' && !theFile.name.endsWith('.' + extension) && // Not already has preferred extension? and ... theFile.type !== _utils_mimeTypes__WEBPACK_IMPORTED_MODULE_1__/* .lookup */ .$I(theFile.name)) { // the mime type of this ext is not the right one? suffix = '_.' + extension; // console.log('MIME TYPE MISMATCH: ' + mime.lookup(theFile.name) + ': adding extension: ' + suffix) } } var folderName = theFile.type.startsWith('image/') ? imageBase || fileBase : fileBase; var destURI = folderName + (folderName.endsWith('/') ? '' : '/') + encodeURIComponent(theFile.name) + suffix; fetcher.webOperation('PUT', destURI, { data: data, contentType: contentType }).then(function (_response) { _debug__WEBPACK_IMPORTED_MODULE_0__/* .log */ .Rm(' Upload: put OK: ' + destURI); successHandler(theFile, destURI); }, function (error) { var msg = ' Upload: FAIL ' + destURI + ', Error: ' + error; _debug__WEBPACK_IMPORTED_MODULE_0__/* .log */ .Rm(msg); alert(msg); throw new Error(msg); }); }; }(f); reader.readAsArrayBuffer(f); } } /***/ }, /***/ 467 (__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) { /* harmony export */ __webpack_require__.d(__webpack_exports__, { /* harmony export */ A: () => (/* binding */ _asyncToGenerator) /* harmony export */ }); function asyncGeneratorStep(n, t, e, r, o, a, c) { try { var i = n[a](c), u = i.value; } catch (n) { return void e(n); } i.done ? t(u) : Promise.resolve(u).then(r, o); } function _asyncToGenerator(n) { return function () { var t = this, e = arguments; return new Promise(function (r, o) { var a = n.apply(t, e); function _next(n) { asyncGeneratorStep(a, r, o, _next, _throw, "next", n); } function _throw(n) { asyncGeneratorStep(a, r, o, _next, _throw, "throw", n); } _next(void 0); }); }; } /***/ }, /***/ 519 (__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) { /* harmony export */ __webpack_require__.d(__webpack_exports__, { /* harmony export */ A: () => (/* binding */ _nonIterableSpread) /* harmony export */ }); function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } /***/ }, /***/ 579 (module, __unused_webpack_exports, __webpack_require__) { var _typeof = (__webpack_require__(3738)["default"]); function _regeneratorValues(e) { if (null != e) { var t = e["function" == typeof Symbol && Symbol.iterator || "@@iterator"], r = 0; if (t) return t.call(e); if ("function" == typeof e.next) return e; if (!isNaN(e.length)) return { next: function next() { return e && r >= e.length && (e = void 0), { value: e && e[r++], done: !e }; } }; } throw new TypeError(_typeof(e) + " is not iterable"); } module.exports = _regeneratorValues, module.exports.__esModule = true, module.exports["default"] = module.exports; /***/ }, /***/ 580 (module) { /*! * escape-html * Copyright(c) 2012-2013 TJ Holowaychuk * Copyright(c) 2015 Andreas Lubbe * Copyright(c) 2015 Tiancheng "Timothy" Gu * MIT Licensed */ /** * Module variables. * @private */ var matchHtmlRegExp = /["'&<>]/; /** * Module exports. * @public */ module.exports = escapeHtml; /** * Escape special characters in the given string of html. * * @param {string} string The string to escape for inserting into HTML * @return {string} * @public */ function escapeHtml(string) { var str = '' + string; var match = matchHtmlRegExp.exec(str); if (!match) { return str; } var escape; var html = ''; var index = 0; var lastIndex = 0; for (index = match.index; index < str.length; index++) { switch (str.charCodeAt(index)) { case 34: // " escape = '"'; break; case 38: // & escape = '&'; break; case 39: // ' escape = '''; break; case 60: // < escape = '<'; break; case 62: // > escape = '>'; break; default: continue; } if (lastIndex !== index) { html += str.substring(lastIndex, index); } lastIndex = index + 1; html += escape; } return lastIndex !== index ? html + str.substring(lastIndex, index) : html; } /***/ }, /***/ 588 (__unused_webpack_module, __webpack_exports__, __webpack_require__) { /* harmony export */ __webpack_require__.d(__webpack_exports__, { /* harmony export */ t: () => (/* binding */ fieldParams) /* harmony export */ }); /* harmony import */ var _babel_runtime_helpers_defineProperty__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(4467); /* harmony import */ var _ns__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(1795); /* harmony import */ var _style__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(675); var _fieldParams; /** * The fieldParams object defines various constants * for use in various form fields. Depending on the * field in questions, different values may be read * from here. */ var fieldParams = (_fieldParams = {}, (0,_babel_runtime_helpers_defineProperty__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */ .A)((0,_babel_runtime_helpers_defineProperty__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */ .A)((0,_babel_runtime_helpers_defineProperty__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */ .A)((0,_babel_runtime_helpers_defineProperty__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */ .A)((0,_babel_runtime_helpers_defineProperty__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */ .A)((0,_babel_runtime_helpers_defineProperty__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */ .A)((0,_babel_runtime_helpers_defineProperty__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */ .A)((0,_babel_runtime_helpers_defineProperty__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */ .A)((0,_babel_runtime_helpers_defineProperty__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */ .A)((0,_babel_runtime_helpers_defineProperty__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */ .A)(_fieldParams, _ns__WEBPACK_IMPORTED_MODULE_1__/* ["default"] */ .A.ui('ColorField').uri, { size: 9, type: 'color', style: 'height: 3em;', // around 1.5em is padding dt: 'color', pattern: /^\s*#[0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f]([0-9a-f][0-9a-f])?\s*$/ }), _ns__WEBPACK_IMPORTED_MODULE_1__/* ["default"] */ .A.ui('DateField').uri, { size: 20, type: 'date', dt: 'date', pattern: /^\s*[0-9][0-9][0-9][0-9](-[0-1]?[0-9]-[0-3]?[0-9])?Z?\s*$/ }), _ns__WEBPACK_IMPORTED_MODULE_1__/* ["default"] */ .A.ui('DateTimeField').uri, { size: 20, type: 'datetime-local', // See https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input/datetime dt: 'dateTime', pattern: /^\s*[0-9][0-9][0-9][0-9](-[0-1]?[0-9]-[0-3]?[0-9])?(T[0-2][0-9]:[0-5][0-9](:[0-5][0-9])?)?Z?\s*$/ }), _ns__WEBPACK_IMPORTED_MODULE_1__/* ["default"] */ .A.ui('TimeField').uri, { size: 10, type: 'time', dt: 'time', pattern: /^\s*([0-2]?[0-9]:[0-5][0-9](:[0-5][0-9])?)\s*$/ }), _ns__WEBPACK_IMPORTED_MODULE_1__/* ["default"] */ .A.ui('IntegerField').uri, { size: 12, style: 'text-align: right;', dt: 'integer', pattern: /^\s*-?[0-9]+\s*$/ }), _ns__WEBPACK_IMPORTED_MODULE_1__/* ["default"] */ .A.ui('DecimalField').uri, { size: 12, style: 'text-align: right;', dt: 'decimal', pattern: /^\s*-?[0-9]*(\.[0-9]*)?\s*$/ }), _ns__WEBPACK_IMPORTED_MODULE_1__/* ["default"] */ .A.ui('FloatField').uri, { size: 12, style: 'text-align: right;', dt: 'float', pattern: /^\s*-?[0-9]*(\.[0-9]*)?((e|E)-?[0-9]*)?\s*$/ }), _ns__WEBPACK_IMPORTED_MODULE_1__/* ["default"] */ .A.ui('SingleLineTextField').uri, {}), _ns__WEBPACK_IMPORTED_MODULE_1__/* ["default"] */ .A.ui('NamedNodeURIField').uri, { namedNode: true }), _ns__WEBPACK_IMPORTED_MODULE_1__/* ["default"] */ .A.ui('TextField').uri, {}), (0,_babel_runtime_helpers_defineProperty__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */ .A)((0,_babel_runtime_helpers_defineProperty__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */ .A)((0,_babel_runtime_helpers_defineProperty__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */ .A)((0,_babel_runtime_helpers_defineProperty__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */ .A)((0,_babel_runtime_helpers_defineProperty__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */ .A)(_fieldParams, _ns__WEBPACK_IMPORTED_MODULE_1__/* ["default"] */ .A.ui('PhoneField').uri, { size: 20, uriPrefix: 'tel:', pattern: /^\+?[\d-]+[\d]*$/ }), _ns__WEBPACK_IMPORTED_MODULE_1__/* ["default"] */ .A.ui('EmailField').uri, { size: 30, uriPrefix: 'mailto:', pattern: /^\s*.*@.*\..*\s*$/ // @@ Get the right regexp here }), _ns__WEBPACK_IMPORTED_MODULE_1__/* ["default"] */ .A.ui('Group').uri, { style: _style__WEBPACK_IMPORTED_MODULE_2__/* .style */ .i.formGroupStyle }), _ns__WEBPACK_IMPORTED_MODULE_1__/* ["default"] */ .A.ui('Comment').uri, { element: 'p', style: _style__WEBPACK_IMPORTED_MODULE_2__/* .style */ .i.commentStyle }), _ns__WEBPACK_IMPORTED_MODULE_1__/* ["default"] */ .A.ui('Heading').uri, { element: 'h3', style: _style__WEBPACK_IMPORTED_MODULE_2__/* .style */ .i.formHeadingStyle })); /***/ }, /***/ 615 (__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) { /* harmony export */ __webpack_require__.d(__webpack_exports__, { /* harmony export */ Ak: () => (/* binding */ normalizeZ), /* harmony export */ UT: () => (/* binding */ _createCurveFields), /* harmony export */ Xf: () => (/* binding */ pippenger), /* harmony export */ fH: () => (/* binding */ mulEndoUnsafe), /* harmony export */ hT: () => (/* binding */ wNAF), /* harmony export */ u0: () => (/* binding */ negateCt) /* harmony export */ }); /* unused harmony exports precomputeMSMUnsafe, validateBasic */ /* harmony import */ var _utils_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(1848); /* harmony import */ var _modular_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(8030); /** * Methods for elliptic curve multiplication by scalars. * Contains wNAF, pippenger. * @module */ /*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */ const _0n = BigInt(0); const _1n = BigInt(1); function negateCt(condition, item) { const neg = item.negate(); return condition ? neg : item; } /** * Takes a bunch of Projective Points but executes only one * inversion on all of them. Inversion is very slow operation, * so this improves performance massively. * Optimization: converts a list of projective points to a list of identical points with Z=1. */ function normalizeZ(c, points) { const invertedZs = (0,_modular_js__WEBPACK_IMPORTED_MODULE_1__/* .FpInvertBatch */ .pS)(c.Fp, points.map((p) => p.Z)); return points.map((p, i) => c.fromAffine(p.toAffine(invertedZs[i]))); } function validateW(W, bits) { if (!Number.isSafeInteger(W) || W <= 0 || W > bits) throw new Error('invalid window size, expected [1..' + bits + '], got W=' + W); } function calcWOpts(W, scalarBits) { validateW(W, scalarBits); const windows = Math.ceil(scalarBits / W) + 1; // W=8 33. Not 32, because we skip zero const windowSize = 2 ** (W - 1); // W=8 128. Not 256, because we skip zero const maxNumber = 2 ** W; // W=8 256 const mask = (0,_utils_js__WEBPACK_IMPORTED_MODULE_0__/* .bitMask */ .OG)(W); // W=8 255 == mask 0b11111111 const shiftBy = BigInt(W); // W=8 8 return { windows, windowSize, mask, maxNumber, shiftBy }; } function calcOffsets(n, window, wOpts) { const { windowSize, mask, maxNumber, shiftBy } = wOpts; let wbits = Number(n & mask); // extract W bits. let nextN = n >> shiftBy; // shift number by W bits. // What actually happens here: // const highestBit = Number(mask ^ (mask >> 1n)); // let wbits2 = wbits - 1; // skip zero // if (wbits2 & highestBit) { wbits2 ^= Number(mask); // (~); // split if bits > max: +224 => 256-32 if (wbits > windowSize) { // we skip zero, which means instead of `>= size-1`, we do `> size` wbits -= maxNumber; // -32, can be maxNumber - wbits, but then we need to set isNeg here. nextN += _1n; // +256 (carry) } const offsetStart = window * windowSize; const offset = offsetStart + Math.abs(wbits) - 1; // -1 because we skip zero const isZero = wbits === 0; // is current window slice a 0? const isNeg = wbits < 0; // is current window slice negative? const isNegF = window % 2 !== 0; // fake random statement for noise const offsetF = offsetStart; // fake offset for noise return { nextN, offset, isZero, isNeg, isNegF, offsetF }; } function validateMSMPoints(points, c) { if (!Array.isArray(points)) throw new Error('array expected'); points.forEach((p, i) => { if (!(p instanceof c)) throw new Error('invalid point at index ' + i); }); } function validateMSMScalars(scalars, field) { if (!Array.isArray(scalars)) throw new Error('array of scalars expected'); scalars.forEach((s, i) => { if (!field.isValid(s)) throw new Error('invalid scalar at index ' + i); }); } // Since points in different groups cannot be equal (different object constructor), // we can have single place to store precomputes. // Allows to make points frozen / immutable. const pointPrecomputes = new WeakMap(); const pointWindowSizes = new WeakMap(); function getW(P) { // To disable precomputes: // return 1; return pointWindowSizes.get(P) || 1; } function assert0(n) { if (n !== _0n) throw new Error('invalid wNAF'); } /** * Elliptic curve multiplication of Point by scalar. Fragile. * Table generation takes **30MB of ram and 10ms on high-end CPU**, * but may take much longer on slow devices. Actual generation will happen on * first call of `multiply()`. By default, `BASE` point is precomputed. * * Scalars should always be less than curve order: this should be checked inside of a curve itself. * Creates precomputation tables for fast multiplication: * - private scalar is split by fixed size windows of W bits * - every window point is collected from window's table & added to accumulator * - since windows are different, same point inside tables won't be accessed more than once per calc * - each multiplication is 'Math.ceil(CURVE_ORDER / 𝑊) + 1' point additions (fixed for any scalar) * - +1 window is neccessary for wNAF * - wNAF reduces table size: 2x less memory + 2x faster generation, but 10% slower multiplication * * @todo Research returning 2d JS array of windows, instead of a single window. * This would allow windows to be in different memory locations */ class wNAF { // Parametrized with a given Point class (not individual point) constructor(Point, bits) { this.BASE = Point.BASE; this.ZERO = Point.ZERO; this.Fn = Point.Fn; this.bits = bits; } // non-const time multiplication ladder _unsafeLadder(elm, n, p = this.ZERO) { let d = elm; while (n > _0n) { if (n & _1n) p = p.add(d); d = d.double(); n >>= _1n; } return p; } /** * Creates a wNAF precomputation window. Used for caching. * Default window size is set by `utils.precompute()` and is equal to 8. * Number of precomputed points depends on the curve size: * 2^(𝑊−1) * (Math.ceil(𝑛 / 𝑊) + 1), where: * - 𝑊 is the window size * - 𝑛 is the bitlength of the curve order. * For a 256-bit curve and window size 8, the number of precomputed points is 128 * 33 = 4224. * @param point Point instance * @param W window size * @returns precomputed point tables flattened to a single array */ precomputeWindow(point, W) { const { windows, windowSize } = calcWOpts(W, this.bits); const points = []; let p = point; let base = p; for (let window = 0; window < windows; window++) { base = p; points.push(base); // i=1, bc we skip 0 for (let i = 1; i < windowSize; i++) { base = base.add(p); points.push(base); } p = base.double(); } return points; } /** * Implements ec multiplication using precomputed tables and w-ary non-adjacent form. * More compact implementation: * https://github.com/paulmillr/noble-secp256k1/blob/47cb1669b6e506ad66b35fe7d76132ae97465da2/index.ts#L502-L541 * @returns real and fake (for const-time) points */ wNAF(W, precomputes, n) { // Scalar should be smaller than field order if (!this.Fn.isValid(n)) throw new Error('invalid scalar'); // Accumulators let p = this.ZERO; let f = this.BASE; // This code was first written with assumption that 'f' and 'p' will never be infinity point: // since each addition is multiplied by 2 ** W, it cannot cancel each other. However, // there is negate now: it is possible that negated element from low value // would be the same as high element, which will create carry into next window. // It's not obvious how this can fail, but still worth investigating later. const wo = calcWOpts(W, this.bits); for (let window = 0; window < wo.windows; window++) { // (n === _0n) is handled and not early-exited. isEven and offsetF are used for noise const { nextN, offset, isZero, isNeg, isNegF, offsetF } = calcOffsets(n, window, wo); n = nextN; if (isZero) { // bits are 0: add garbage to fake point // Important part for const-time getPublicKey: add random "noise" point to f. f = f.add(negateCt(isNegF, precomputes[offsetF])); } else { // bits are 1: add to result point p = p.add(negateCt(isNeg, precomputes[offset])); } } assert0(n); // Return both real and fake points: JIT won't eliminate f. // At this point there is a way to F be infinity-point even if p is not, // which makes it less const-time: around 1 bigint multiply. return { p, f }; } /** * Implements ec unsafe (non const-time) multiplication using precomputed tables and w-ary non-adjacent form. * @param acc accumulator point to add result of multiplication * @returns point */ wNAFUnsafe(W, precomputes, n, acc = this.ZERO) { const wo = calcWOpts(W, this.bits); for (let window = 0; window < wo.windows; window++) { if (n === _0n) break; // Early-exit, skip 0 value const { nextN, offset, isZero, isNeg } = calcOffsets(n, window, wo); n = nextN; if (isZero) { // Window bits are 0: skip processing. // Move to next window. continue; } else { const item = precomputes[offset]; acc = acc.add(isNeg ? item.negate() : item); // Re-using acc allows to save adds in MSM } } assert0(n); return acc; } getPrecomputes(W, point, transform) { // Calculate precomputes on a first run, reuse them after let comp = pointPrecomputes.get(point); if (!comp) { comp = this.precomputeWindow(point, W); if (W !== 1) { // Doing transform outside of if brings 15% perf hit if (typeof transform === 'function') comp = transform(comp); pointPrecomputes.set(point, comp); } } return comp; } cached(point, scalar, transform) { const W = getW(point); return this.wNAF(W, this.getPrecomputes(W, point, transform), scalar); } unsafe(point, scalar, transform, prev) { const W = getW(point); if (W === 1) return this._unsafeLadder(point, scalar, prev); // For W=1 ladder is ~x2 faster return this.wNAFUnsafe(W, this.getPrecomputes(W, point, transform), scalar, prev); } // We calculate precomputes for elliptic curve point multiplication // using windowed method. This specifies window size and // stores precomputed values. Usually only base point would be precomputed. createCache(P, W) { validateW(W, this.bits); pointWindowSizes.set(P, W); pointPrecomputes.delete(P); } hasCache(elm) { return getW(elm) !== 1; } } /** * Endomorphism-specific multiplication for Koblitz curves. * Cost: 128 dbl, 0-256 adds. */ function mulEndoUnsafe(Point, point, k1, k2) { let acc = point; let p1 = Point.ZERO; let p2 = Point.ZERO; while (k1 > _0n || k2 > _0n) { if (k1 & _1n) p1 = p1.add(acc); if (k2 & _1n) p2 = p2.add(acc); acc = acc.double(); k1 >>= _1n; k2 >>= _1n; } return { p1, p2 }; } /** * Pippenger algorithm for multi-scalar multiplication (MSM, Pa + Qb + Rc + ...). * 30x faster vs naive addition on L=4096, 10x faster than precomputes. * For N=254bit, L=1, it does: 1024 ADD + 254 DBL. For L=5: 1536 ADD + 254 DBL. * Algorithmically constant-time (for same L), even when 1 point + scalar, or when scalar = 0. * @param c Curve Point constructor * @param fieldN field over CURVE.N - important that it's not over CURVE.P * @param points array of L curve points * @param scalars array of L scalars (aka secret keys / bigints) */ function pippenger(c, fieldN, points, scalars) { // If we split scalars by some window (let's say 8 bits), every chunk will only // take 256 buckets even if there are 4096 scalars, also re-uses double. // TODO: // - https://eprint.iacr.org/2024/750.pdf // - https://tches.iacr.org/index.php/TCHES/article/view/10287 // 0 is accepted in scalars validateMSMPoints(points, c); validateMSMScalars(scalars, fieldN); const plength = points.length; const slength = scalars.length; if (plength !== slength) throw new Error('arrays of points and scalars must have equal length'); // if (plength === 0) throw new Error('array must be of length >= 2'); const zero = c.ZERO; const wbits = (0,_utils_js__WEBPACK_IMPORTED_MODULE_0__/* .bitLen */ .dJ)(BigInt(plength)); let windowSize = 1; // bits if (wbits > 12) windowSize = wbits - 3; else if (wbits > 4) windowSize = wbits - 2; else if (wbits > 0) windowSize = 2; const MASK = (0,_utils_js__WEBPACK_IMPORTED_MODULE_0__/* .bitMask */ .OG)(windowSize); const buckets = new Array(Number(MASK) + 1).fill(zero); // +1 for zero array const lastBits = Math.floor((fieldN.BITS - 1) / windowSize) * windowSize; let sum = zero; for (let i = lastBits; i >= 0; i -= windowSize) { buckets.fill(zero); for (let j = 0; j < slength; j++) { const scalar = scalars[j]; const wbits = Number((scalar >> BigInt(i)) & MASK); buckets[wbits] = buckets[wbits].add(points[j]); } let resI = zero; // not using this will do small speed-up, but will lose ct // Skip first bucket, because it is zero for (let j = buckets.length - 1, sumI = zero; j > 0; j--) { sumI = sumI.add(buckets[j]); resI = resI.add(sumI); } sum = sum.add(resI); if (i !== 0) for (let j = 0; j < windowSize; j++) sum = sum.double(); } return sum; } /** * Precomputed multi-scalar multiplication (MSM, Pa + Qb + Rc + ...). * @param c Curve Point constructor * @param fieldN field over CURVE.N - important that it's not over CURVE.P * @param points array of L curve points * @returns function which multiplies points with scaars */ function precomputeMSMUnsafe(c, fieldN, points, windowSize) { /** * Performance Analysis of Window-based Precomputation * * Base Case (256-bit scalar, 8-bit window): * - Standard precomputation requires: * - 31 additions per scalar × 256 scalars = 7,936 ops * - Plus 255 summary additions = 8,191 total ops * Note: Summary additions can be optimized via accumulator * * Chunked Precomputation Analysis: * - Using 32 chunks requires: * - 255 additions per chunk * - 256 doublings * - Total: (255 × 32) + 256 = 8,416 ops * * Memory Usage Comparison: * Window Size | Standard Points | Chunked Points * ------------|-----------------|--------------- * 4-bit | 520 | 15 * 8-bit | 4,224 | 255 * 10-bit | 13,824 | 1,023 * 16-bit | 557,056 | 65,535 * * Key Advantages: * 1. Enables larger window sizes due to reduced memory overhead * 2. More efficient for smaller scalar counts: * - 16 chunks: (16 × 255) + 256 = 4,336 ops * - ~2x faster than standard 8,191 ops * * Limitations: * - Not suitable for plain precomputes (requires 256 constant doublings) * - Performance degrades with larger scalar counts: * - Optimal for ~256 scalars * - Less efficient for 4096+ scalars (Pippenger preferred) */ validateW(windowSize, fieldN.BITS); validateMSMPoints(points, c); const zero = c.ZERO; const tableSize = 2 ** windowSize - 1; // table size (without zero) const chunks = Math.ceil(fieldN.BITS / windowSize); // chunks of item const MASK = bitMask(windowSize); const tables = points.map((p) => { const res = []; for (let i = 0, acc = p; i < tableSize; i++) { res.push(acc); acc = acc.add(p); } return res; }); return (scalars) => { validateMSMScalars(scalars, fieldN); if (scalars.length > points.length) throw new Error('array of scalars must be smaller than array of points'); let res = zero; for (let i = 0; i < chunks; i++) { // No need to double if accumulator is still zero. if (res !== zero) for (let j = 0; j < windowSize; j++) res = res.double(); const shiftBy = BigInt(chunks * windowSize - (i + 1) * windowSize); for (let j = 0; j < scalars.length; j++) { const n = scalars[j]; const curr = Number((n >> shiftBy) & MASK); if (!curr) continue; // skip zero scalars chunks res = res.add(tables[j][curr - 1]); } } return res; }; } // TODO: remove /** @deprecated */ function validateBasic(curve) { validateField(curve.Fp); validateObject(curve, { n: 'bigint', h: 'bigint', Gx: 'field', Gy: 'field', }, { nBitLength: 'isSafeInteger', nByteLength: 'isSafeInteger', }); // Set defaults return Object.freeze({ ...nLength(curve.n, curve.nBitLength), ...curve, ...{ p: curve.Fp.ORDER }, }); } function createField(order, field, isLE) { if (field) { if (field.ORDER !== order) throw new Error('Field.ORDER must match order: Fp == p, Fn == n'); (0,_modular_js__WEBPACK_IMPORTED_MODULE_1__/* .validateField */ .jr)(field); return field; } else { return (0,_modular_js__WEBPACK_IMPORTED_MODULE_1__/* .Field */ .D0)(order, { isLE }); } } /** Validates CURVE opts and creates fields */ function _createCurveFields(type, CURVE, curveOpts = {}, FpFnLE) { if (FpFnLE === undefined) FpFnLE = type === 'edwards'; if (!CURVE || typeof CURVE !== 'object') throw new Error(`expected valid ${type} CURVE object`); for (const p of ['p', 'n', 'h']) { const val = CURVE[p]; if (!(typeof val === 'bigint' && val > _0n)) throw new Error(`CURVE.${p} must be positive bigint`); } const Fp = createField(CURVE.p, curveOpts.Fp, FpFnLE); const Fn = createField(CURVE.n, curveOpts.Fn, FpFnLE); const _b = type === 'weierstrass' ? 'b' : 'd'; const params = ['Gx', 'Gy', 'a', _b]; for (const p of params) { // @ts-ignore if (!Fp.isValid(CURVE[p])) throw new Error(`CURVE.${p} must be valid field element of CURVE.Fp`); } CURVE = Object.freeze(Object.assign({}, CURVE)); return { CURVE, Fp, Fn }; } //# sourceMappingURL=curve.js.map /***/ }, /***/ 675 (__unused_webpack_module, __webpack_exports__, __webpack_require__) { /* harmony export */ __webpack_require__.d(__webpack_exports__, { /* harmony export */ i: () => (/* binding */ style) /* harmony export */ }); /* harmony import */ var _styleConstants__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(4762); // Common readable consistent stylesheet // to avoid using style sheets which are document-global // and make programmable style toggling with selection, drag over, etc easier // These must all end with semicolon so they can be appended to. var style = { // styleModule checkboxStyle: 'color: black; font-size: 100%; padding-left: 0.5 em; padding-right: 0.5 em;', checkboxInputStyle: 'font-size: 150%; height: 1.2em; width: 1.2em; background-color: #eef; border-radius:0.2em; margin: 0.1em;', fieldLabelStyle: 'color: #3B5998; text-decoration: none;', formSelectStyle: 'background-color: #eef; padding: 0.5em; border: .05em solid #88c; border-radius:0.2em; font-size: 100%; margin:0.4em;', textInputStyle: 'background-color: #eef; padding: 0.5em; border: .05em solid #88c; border-radius:0.2em; font-size: 100%; margin:0.4em;', textInputStyleUneditable: // Color difference only 'background-color: white; padding: 0.5em; border: .05em solid white; border-radius:0.2em; font-size: 100%; margin:0.4em;', buttonStyle: 'background-color: #fff; padding: 0.7em; border: .01em solid white; border-radius:0.2em; font-size: 100%; margin: 0.3em;', // 'background-color: #eef; commentStyle: 'padding: 0.7em; border: none; font-size: 100%; white-space: pre-wrap;', iconStyle: 'width: 3em; height: 3em; margin: 0.1em; border-radius: 1em;', smallButtonStyle: 'margin: 0.2em; width: 1em; height:1em;', classIconStyle: 'width: 3em; height: 3em; margin: 0.1em; border-radius: 0.2em; border: 0.1em solid green; padding: 0.2em; background-color: #efe;', // combine with buttonStyle confirmPopupStyle: 'padding: 0.7em; border-radius: 0.2em; border: 0.1em solid orange; background-color: white; box-shadow: 0.5em 0.9em #888;', messageBodyStyle: 'white-space: pre-wrap; width: 99%; font-size:100%; border: 0.07em solid #eee; border-radius:0.2em; padding: .3em 0.5em; margin: 0.1em;', pendingeditModifier: 'color: #bbb;', // Contacts personaBarStyle: 'width: 100%; height: 4em; background-color: #eee; vertical-align: middle;', searchInputStyle: 'border: 0.1em solid #444; border-radius: 0.2em; width: 100%; font-size: 100%; padding: 0.1em 0.6em; margin 0.2em;', autocompleteRowStyle: 'border: 0.2em solid straw;', // Login buttons signInAndUpButtonStyle: 'padding: 1em; border-radius:0.2em; font-size: 100%;', // was 0.5em radius headerBannerLoginInput: 'margin: 0.75em 0 0.75em 0.5em !important; padding: 0.5em !important;', signUpBackground: 'background-color: #eef;', signInBackground: 'background-color: #efe;', // Forms heading1Style: 'font-size: 180%; font-weight: bold; color: #888888; padding: 0.5em; margin: 0.7em 0.0m;', // originally was brown; now grey heading2Style: 'font-size: 130%; font-weight: bold; color: #888888; padding: 0.4em; margin: 0.7em 0.0em;', // originally was brown; now grey heading3Style: 'font-size: 120%; font-weight: bold; color: #888888; padding: 0.3em; margin: 0.7em 0.0em;', // For example, in large forms or before a small form heading4Style: 'font-size: 110%; font-weight: bold; color: #888888; padding: 0.2em; margin: 0.7em 0.0em;', // Lowest level used by default in small things formHeadingStyle: 'font-size: 110%; font-weight: bold; color: #888888; padding: 0.2em; margin: 0.7em 0.0em;', // originally was brown; now grey formTextInput: 'font-size: 100%; margin: 0.1em; padding: 0.1em;', // originally used this formGroupStyle: ["padding-left: 0em; border: 0.0em solid ".concat(_styleConstants__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */ .A.formBorderColor, "; border-radius: 0.2em;"), // weight 0 "padding-left: 2em; border: 0.05em solid ".concat(_styleConstants__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */ .A.formBorderColor, "; border-radius: 0.2em;"), "padding-left: 2em; border: 0.1em solid ".concat(_styleConstants__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */ .A.formBorderColor, "; border-radius: 0.2em;"), "padding-left: 2em; border: 0.2em solid ".concat(_styleConstants__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */ .A.formBorderColor, "; border-radius: 0.2em;") // @@ pink ], formFieldLabelStyle: "color: ".concat(_styleConstants__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */ .A.lowProfileLinkColor, "; text-decoration: none;"), formFieldNameBoxStyle: "padding: 0.3em; vertical-align: middle; width:".concat(_styleConstants__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */ .A.formFieldNameBoxWidth, ";"), multilineTextInputStyle: 'font-size:100%; white-space: pre-wrap; background-color: #eef;' + ' border: 0.07em solid gray; padding: 1em 0.5em; margin: 1em 1em;', // Buttons renderAsDivStyle: 'display: flex; align-items: center; justify-content: space-between; height: 2.5em; padding: 1em;', imageDivStyle: 'width:2.5em; padding:0.5em; height: 2.5em;', linkDivStyle: 'width:2em; padding:0.5em; height: 4em;', // ACL aclControlBoxContainer: 'margin: 1em;', aclControlBoxHeader: 'font-size: 120%; margin: 0 0 1rem;', aclControlBoxStatus: 'display: none; margin: 1rem 0;', aclControlBoxStatusRevealed: 'display: block;', aclGroupContent: 'maxWidth: 650;', accessGroupList: 'display: grid; grid-template-columns: 1fr; margin: 1em; width: 100%;', accessGroupListItem: 'display: grid; grid-template-columns: 100px auto 30%;', defaultsController: 'display: flex;', defaultsControllerNotice: 'color: #888; flexGrow: 1; fontSize: 80%;', bigButton: 'background-color: white; border: 0.1em solid #888; border-radius: 0.3em; max-width: 50%; padding-bottom: 1em; padding-top: 1em;', group: 'color: #888;', group1: 'color: green;', group2: 'color: #cc0;', group3: 'color: orange;', group5: 'color: red;', group9: 'color: blue;', group13: 'color: purple;', trustedAppAddApplicationsTable: 'background-color: #eee;', trustedAppCancelButton: 'float: right;', trustedAppControllerI: 'border-color: orange; border-radius: 1em; border-width: 0.1em;', temporaryStatusInit: 'background: green;', temporaryStatusEnd: 'background: transparent; transition: background 5s linear;', // header headerUserMenuLink: 'background: none; border: 0; color: black; cursor: pointer; display: block; font-family: Arial; font-size: 1em; text-align: left; padding: 1em; width: 100%; text-decoration: none;', headerUserMenuLinkHover: 'background: none; border: 0; color: black; cursor: pointer; display: block; font-family: Arial; font-size: 1em; text-align: left; padding: 1em; width: 100%; text-decoration: none; background-image: linear-gradient(to right, #7C4DFF 0%, #18A9E6 50%, #01C9EA 100%);', headerUserMenuTrigger: 'background: none; border: 0; cursor: pointer; width: 60px; height: 60px;', headerUserMenuTriggerImg: 'border-radius: 50%; height: 56px; width: 28px !important;', headerUserMenuButton: 'background: none; border: 0; color: black; cursor: pointer; display: block; font-family: Arial; font-size: 1em; text-align: left; padding: 1em; width: 100%;', headerUserMenuButtonHover: 'background: none; border: 0; color: black; cursor: pointer; display: block; font-family: Arial; font-size: 1em; text-align: left; padding: 1em; width: 100%; background-image: linear-gradient(to right, #7C4DFF 0%, #18A9E6 50%, #01C9EA 100%);', headerUserMenuList: 'list-style: none; margin: 0; padding: 0;', headerUserMenuListDisplay: 'list-style: none; margin: 0; padding: 0; display:true;', headerUserMenuNavigationMenu: 'background: white; border: solid 1px #000000; border-right: 0; position: absolute; right: 0; top: 60px; width: 200px; z-index: 1; display: true;', headerUserMenuNavigationMenuNotDisplayed: 'background: white; border: solid 1px #000000; border-right: 0; position: absolute; right: 0; top: 60px; width: 200px; z-index: 1; display: none;', headerUserMenuListItem: 'border-bottom: solid 1px #000000;', headerUserMenuPhoto: 'border-radius: 50%; background-position: center; background-repeat: no-repeat; background-size: cover; height: 50px; width: 50px;', headerBanner: 'box-shadow: 0px 1px 4px #000000; display: flex; justify-content: space-between; padding: 0 1.5em; margin-bottom: 4px;', headerBannerLink: 'display: block;', headerBannerRightMenu: 'display: flex;', headerBannerLogin: 'margin-left: auto;', allChildrenVisible: 'display:true;', headerBannerUserMenu: 'border-left: solid 1px #000000; margin-left: auto;', headerBannerHelpMenu: 'border-left: solid 1px #000000; margin-left: auto;', headerBannerIcon: 'background-size: 65px 60px !important; height: 60px !important; width: 65px !important;', // may just be 65px round($icon-size * 352 / 322); // footer footer: 'border-top: solid 1px $divider-color; font-size: 0.9em; padding: 0.5em 1.5em;', // buttons primaryButton: 'background-color: #7c4dff; color: #ffffff; font-family: Raleway, Roboto, sans-serif; border-radius: 0.25em; border-color: #7c4dff; border: 1px solid; cursor: pointer; font-size: .8em; text-decoration: none; padding: 0.5em 4em; transition: 0.25s all ease-in-out; outline: none;', primaryButtonHover: 'background-color: #9f7dff; color: #ffffff; font-family: Raleway, Roboto, sans-serif;border-radius: 0.25em; border-color: #7c4dff; border: 1px solid; cursor: pointer; font-size: .8em; text-decoration: none; padding: 0.5em 4em; transition: 0.25s all ease-in-out; outline: none; transition: 0.25s all ease-in-out;', primaryButtonNoBorder: 'background-color: #ffffff; color: #7c4dff; font-family: Raleway, Roboto, sans-serif;border-radius: 0.25em; border-color: #7c4dff; border: 1px solid; cursor: pointer; font-size: .8em; text-decoration: none; padding: 0.5em 4em; transition: 0.25s all ease-in-out; outline: none;', primaryButtonNoBorderHover: 'background-color: #7c4dff; color: #ffffff; font-family: Raleway, Roboto, sans-serif; border-radius: 0.25em; border-color: #7c4dff; border: 1px solid; cursor: pointer; font-size: .8em; text-decoration: none; padding: 0.5em 4em; transition: 0.25s all ease-in-out; outline: none; transition: 0.25s all ease-in-out;', secondaryButton: 'background-color: #01c9ea; color: #ffffff; font-family: Raleway, Roboto, sans-serif;border-radius: 0.25em; border-color: #01c9ea; border: 1px solid; cursor: pointer; font-size: .8em; text-decoration: none; padding: 0.5em 4em; transition: 0.25s all ease-in-out; outline: none;', secondaryButtonHover: 'background-color: #37cde6; color: #ffffff; font-family: Raleway, Roboto, sans-serif;border-radius: 0.25em; border-color: #7c4dff; border: 1px solid; cursor: pointer; font-size: .8em; text-decoration: none; padding: 0.5em 4em; transition: 0.25s all ease-in-out; outline: none; transition: 0.25s all ease-in-out;', secondaryButtonNoBorder: 'background-color: #ffffff; color: #01c9ea; font-family: Raleway, Roboto, sans-serif; border-radius: 0.25em; border-color: #01c9ea; border: 1px solid; cursor: pointer; font-size: .8em; text-decoration: none; padding: 0.5em 4em; transition: 0.25s all ease-in-out; outline: none;', secondaryButtonNoBorderHover: 'background-color: #01c9ea; color: #ffffff; font-family: Raleway, Roboto, sans-serif; border-radius: 0.25em; border-color: #01c9ea; border: 1px solid; cursor: pointer; font-size: .8em; text-decoration: none; padding: 0.5em 4em; transition: 0.25s all ease-in-out; outline: none; transition: 0.25s all ease-in-out;', // media controlStyle: "border-radius: 0.5em; margin: 0.8em; width:".concat(_styleConstants__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */ .A.mediaModuleCanvasWidth, "; height:").concat(_styleConstants__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */ .A.mediaModuleCanvasHeight, ";"), // dragAndDrop dragEvent: 'background-color: #ccc; border: 0.25em dashed black; border-radius: 0.3em;', dropEvent: 'background-color: white; border: 0em solid black;', restoreStyle: 'background-color: white;', // errors errorCancelButton: 'width: 2em; height: 2em; align: right;', errorMessageBlockStyle: 'margin: 0.1em; padding: 0.5em; border: 0.05em solid gray; color:black;', // pad notepadStyle: 'padding: 1em; overflow: auto; resize: horizontal; min-width: 40em;', upstreamStatus: 'width: 50%;', downstreamStatus: 'width: 50%;', baseStyle: 'font-size: 100%; font-family: monospace; width: 100%; border: none; white-space: pre-wrap;', headingCore: 'font-family: sans-serif; font-weight: bold; border: none;', headingStyle: ['font-size: 110%; padding-top: 0.5em; padding-bottom: 0.5em; width: 100%;', 'font-size: 120%; padding-top: 1em; padding-bottom: 1em; width: 100%;', 'font-size: 150%; padding-top: 1em; padding-bottom: 1em; width: 100%;'], // participation participantsStyle: 'margin: 0.8em;', participantsBlock: 'height: 1.5em; width: 1.5em; margin: 0.3em; border 0.01em solid #888;', personTableTD: 'vertical-align: middle;', // tabs tabsNavElement: 'margin: 0;', tabsRootElement: 'display: flex; height: 100%; width: 100%;', tabsMainElement: 'margin: 0; width:100%; height: 100%;', tabContainer: 'list-style-type: none; display: flex; height: 100%; width: 100%; margin: 0; padding: 0;', makeNewSlot: 'background: none; border: none; font: inherit; cursor: pointer;', ellipsis: 'position: absolute; right: 0; bottom: 0; width: 20%; background: none; color: inherit; border: none; padding: 0; font: inherit; cursor: pointer; outline: inherit;' }; style.setStyle = function setStyle(ele, styleName) { ele.style = style[styleName]; }; /***/ }, /***/ 887 (module, __unused_webpack_exports, __webpack_require__) { var regenerator = __webpack_require__(6993); var regeneratorAsyncIterator = __webpack_require__(1791); function _regeneratorAsyncGen(r, e, t, o, n) { return new regeneratorAsyncIterator(regenerator().w(r, e, t, o), n || Promise); } module.exports = _regeneratorAsyncGen, module.exports.__esModule = true, module.exports["default"] = module.exports; /***/ }, /***/ 967 (__unused_webpack_module, __webpack_exports__, __webpack_require__) { __webpack_require__.r(__webpack_exports__); /* harmony export */ __webpack_require__.d(__webpack_exports__, { /* harmony export */ ensureLoadedPreferences: () => (/* binding */ ensureLoadedPreferences), /* harmony export */ ensureLoadedProfile: () => (/* binding */ ensureLoadedProfile), /* harmony export */ ensureLoggedIn: () => (/* binding */ ensureLoggedIn), /* harmony export */ filterAvailablePanes: () => (/* binding */ filterAvailablePanes), /* harmony export */ findAppInstances: () => (/* binding */ findAppInstances), /* harmony export */ getUserRoles: () => (/* binding */ getUserRoles), /* harmony export */ loginStatusBox: () => (/* binding */ loginStatusBox), /* harmony export */ newAppInstance: () => (/* binding */ newAppInstance), /* harmony export */ registrationControl: () => (/* binding */ registrationControl), /* harmony export */ registrationList: () => (/* binding */ registrationList), /* harmony export */ renderScopeHeadingRow: () => (/* binding */ renderScopeHeadingRow), /* harmony export */ renderSignInPopup: () => (/* binding */ renderSignInPopup), /* harmony export */ scopeLabel: () => (/* binding */ scopeLabel), /* harmony export */ selectWorkspace: () => (/* binding */ selectWorkspace) /* harmony export */ }); /* harmony import */ var _babel_runtime_helpers_asyncToGenerator__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(467); /* harmony import */ var _babel_runtime_regenerator__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(4756); /* harmony import */ var _babel_runtime_regenerator__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(_babel_runtime_regenerator__WEBPACK_IMPORTED_MODULE_1__); /* harmony import */ var rdflib__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(4961); /* harmony import */ var solid_logic_jss__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(5175); /* harmony import */ var _debug__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(7423); /* harmony import */ var _style__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(675); /* harmony import */ var _log__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(4158); /* harmony import */ var _ns__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(1795); /* harmony import */ var _signup_signup_js__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(6247); /* harmony import */ var _utils__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(9612); /* harmony import */ var _widgets__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(3291); /* harmony import */ var _widgets__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(3468); /* harmony import */ var _widgets__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(1763); function _createForOfIteratorHelper(r, e) { var t = "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (!t) { if (Array.isArray(r) || (t = _unsupportedIterableToArray(r)) || e && r && "number" == typeof r.length) { t && (r = t); var _n = 0, F = function F() {}; return { s: F, n: function n() { return _n >= r.length ? { done: !0 } : { done: !1, value: r[_n++] }; }, e: function e(r) { throw r; }, f: F }; } 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 o, a = !0, u = !1; return { s: function s() { t = t.call(r); }, n: function n() { var r = t.next(); return a = r.done, r; }, e: function e(r) { u = !0, o = r; }, f: function f() { try { a || null == t["return"] || t["return"](); } finally { if (u) throw o; } } }; } function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0; } } function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; } /* eslint-disable camelcase */ /** * Signing in, signing up, profile and preferences reloading * Type index management * * Many functions in this module take a context object which * holds various RDF symbols, add to it, and return a promise of it. * * * `me` RDF symbol for the user's WebID * * `publicProfile` The user's public profile, iff loaded * * `preferencesFile` The user's personal preference file, iff loaded * * `index.public` The user's public type index file * * `index.private` The user's private type index file * * Not RDF symbols: * * `noun` A string in english for the type of thing -- like "address book" * * `instance` An array of nodes which are existing instances * * `containers` An array of nodes of containers of instances * * `div` A DOM element where UI can be displayed * * `statusArea` A DOM element (opt) progress stuff can be displayed, or error messages * * * * Vocabulary: "load" loads a file if it exists; * * 'Ensure" CREATES the file if it does not exist (if it can) and then loads it. * @packageDocumentation */ var store = solid_logic_jss__WEBPACK_IMPORTED_MODULE_3__/* .solidLogicSingleton */ .hV.store; var _solidLogicSingleton$ = solid_logic_jss__WEBPACK_IMPORTED_MODULE_3__/* .solidLogicSingleton */ .hV.profile, loadPreferences = _solidLogicSingleton$.loadPreferences, loadProfile = _solidLogicSingleton$.loadProfile; var _solidLogicSingleton$2 = solid_logic_jss__WEBPACK_IMPORTED_MODULE_3__/* .solidLogicSingleton */ .hV.typeIndex, getScopedAppInstances = _solidLogicSingleton$2.getScopedAppInstances, getRegistrations = _solidLogicSingleton$2.getRegistrations, loadAllTypeIndexes = _solidLogicSingleton$2.loadAllTypeIndexes, getScopedAppsFromIndex = _solidLogicSingleton$2.getScopedAppsFromIndex, deleteTypeIndexRegistration = _solidLogicSingleton$2.deleteTypeIndexRegistration; /** * Resolves with the logged in user's WebID * * @param context */ // used to be logIn function ensureLoggedIn(context) { var me = solid_logic_jss__WEBPACK_IMPORTED_MODULE_3__/* .authn */ .jO.currentUser(); if (me) { solid_logic_jss__WEBPACK_IMPORTED_MODULE_3__/* .authn */ .jO.saveUser(me, context); return Promise.resolve(context); } return new Promise(function (resolve) { solid_logic_jss__WEBPACK_IMPORTED_MODULE_3__/* .authn */ .jO.checkUser().then(function (webId) { // Already logged in? if (webId) { _debug__WEBPACK_IMPORTED_MODULE_4__/* .log */ .Rm("logIn: Already logged in as ".concat(webId)); return resolve(context); } if (!context.div || !context.dom) { return resolve(context); } var box = loginStatusBox(context.dom, function (webIdUri) { solid_logic_jss__WEBPACK_IMPORTED_MODULE_3__/* .authn */ .jO.saveUser(webIdUri, context); resolve(context); // always pass growing context }); context.div.appendChild(box); }); }); } /** * Loads preference file * Do this after having done log in and load profile * * @private * * @param context */ // used to be logInLoadPreferences function ensureLoadedPreferences(_x) { return _ensureLoadedPreferences.apply(this, arguments); } /** * Logs the user in and loads their WebID profile document into the store * * @param context * * @returns Resolves with the context after login / fetch */ // used to be logInLoadProfile function _ensureLoadedPreferences() { _ensureLoadedPreferences = (0,_babel_runtime_helpers_asyncToGenerator__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */ .A)(/*#__PURE__*/_babel_runtime_regenerator__WEBPACK_IMPORTED_MODULE_1___default().mark(function _callee4(context) { var progressDisplay, preferencesFile, m2, _t4; return _babel_runtime_regenerator__WEBPACK_IMPORTED_MODULE_1___default().wrap(function (_context4) { while (1) switch (_context4.prev = _context4.next) { case 0: if (!context.preferencesFile) { _context4.next = 1; break; } return _context4.abrupt("return", Promise.resolve(context)); case 1: _context4.prev = 1; _context4.next = 2; return ensureLoadedProfile(context); case 2: context = _context4.sent; _context4.next = 3; return loadPreferences(context.me); case 3: preferencesFile = _context4.sent; if (progressDisplay) { progressDisplay.parentNode.removeChild(progressDisplay); } context.preferencesFile = preferencesFile; _context4.next = 11; break; case 4: _context4.prev = 4; _t4 = _context4["catch"](1); if (!(_t4 instanceof solid_logic_jss__WEBPACK_IMPORTED_MODULE_3__/* .UnauthorizedError */ .D_)) { _context4.next = 5; break; } m2 = 'Oops — you are not authenticated (properly logged in), so SolidOS cannot read your preferences file. Try logging out and then logging back in.'; (0,_log__WEBPACK_IMPORTED_MODULE_6__.alert)(m2); _context4.next = 11; break; case 5: if (!(_t4 instanceof solid_logic_jss__WEBPACK_IMPORTED_MODULE_3__/* .CrossOriginForbiddenError */ .Un)) { _context4.next = 6; break; } m2 = "Unauthorized: Assuming preference file blocked for origin ".concat(window.location.origin); context.preferencesFileError = m2; return _context4.abrupt("return", context); case 6: if (!(_t4 instanceof solid_logic_jss__WEBPACK_IMPORTED_MODULE_3__/* .SameOriginForbiddenError */ .sN)) { _context4.next = 7; break; } m2 = 'You are not authorized to read your preference file. This may be because you are using an untrusted web app.'; _debug__WEBPACK_IMPORTED_MODULE_4__/* .warn */ .R8(m2); return _context4.abrupt("return", context); case 7: if (!(_t4 instanceof solid_logic_jss__WEBPACK_IMPORTED_MODULE_3__/* .NotEditableError */ .ML)) { _context4.next = 8; break; } m2 = 'You are not authorized to edit your preference file. This may be because you are using an untrusted web app.'; _debug__WEBPACK_IMPORTED_MODULE_4__/* .warn */ .R8(m2); return _context4.abrupt("return", context); case 8: if (!(_t4 instanceof solid_logic_jss__WEBPACK_IMPORTED_MODULE_3__/* .WebOperationError */ .ac)) { _context4.next = 9; break; } m2 = 'You are not authorized to edit your preference file. This may be because you are using an untrusted web app.'; _debug__WEBPACK_IMPORTED_MODULE_4__/* .warn */ .R8(m2); _context4.next = 11; break; case 9: if (!(_t4 instanceof solid_logic_jss__WEBPACK_IMPORTED_MODULE_3__/* .FetchError */ .fk)) { _context4.next = 10; break; } m2 = "Strange: Error ".concat(_t4.status, " trying to read your preference file.").concat(_t4.message); (0,_log__WEBPACK_IMPORTED_MODULE_6__.alert)(m2); _context4.next = 11; break; case 10: throw new Error("(via loadPrefs) ".concat(_t4)); case 11: return _context4.abrupt("return", context); case 12: case "end": return _context4.stop(); } }, _callee4, null, [[1, 4]]); })); return _ensureLoadedPreferences.apply(this, arguments); } function ensureLoadedProfile(_x2) { return _ensureLoadedProfile.apply(this, arguments); } /** * Returns promise of context with arrays of symbols * * leaving the `isPublic` param undefined will bring in community index things, too */ function _ensureLoadedProfile() { _ensureLoadedProfile = (0,_babel_runtime_helpers_asyncToGenerator__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */ .A)(/*#__PURE__*/_babel_runtime_regenerator__WEBPACK_IMPORTED_MODULE_1___default().mark(function _callee5(context) { var logInContext, _t5; return _babel_runtime_regenerator__WEBPACK_IMPORTED_MODULE_1___default().wrap(function (_context5) { while (1) switch (_context5.prev = _context5.next) { case 0: if (!context.publicProfile) { _context5.next = 1; break; } return _context5.abrupt("return", context); case 1: _context5.prev = 1; _context5.next = 2; return ensureLoggedIn(context); case 2: logInContext = _context5.sent; if (logInContext.me) { _context5.next = 3; break; } throw new Error('Could not log in'); case 3: _context5.next = 4; return loadProfile(logInContext.me); case 4: context.publicProfile = _context5.sent; _context5.next = 6; break; case 5: _context5.prev = 5; _t5 = _context5["catch"](1); if (context.div && context.dom) { context.div.appendChild(_widgets__WEBPACK_IMPORTED_MODULE_11__/* .errorMessageBlock */ .F(context.dom, _t5.message)); } throw new Error("Can't log in: ".concat(_t5)); case 6: return _context5.abrupt("return", context); case 7: case "end": return _context5.stop(); } }, _callee5, null, [[1, 5]]); })); return _ensureLoadedProfile.apply(this, arguments); } function findAppInstances(_x3, _x4, _x5) { return _findAppInstances.apply(this, arguments); } function _findAppInstances() { _findAppInstances = (0,_babel_runtime_helpers_asyncToGenerator__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */ .A)(/*#__PURE__*/_babel_runtime_regenerator__WEBPACK_IMPORTED_MODULE_1___default().mark(function _callee6(context, theClass, isPublic) { var items, _t6; return _babel_runtime_regenerator__WEBPACK_IMPORTED_MODULE_1___default().wrap(function (_context6) { while (1) switch (_context6.prev = _context6.next) { case 0: if (!context.me) { _context6.next = 2; break; } _context6.next = 1; return getScopedAppInstances(theClass, context.me); case 1: _t6 = _context6.sent; _context6.next = 3; break; case 2: _t6 = []; case 3: items = _t6; if (isPublic === true) { // old API - not recommended! items = items.filter(function (item) { return item.scope.label === 'public'; }); } else if (isPublic === false) { items = items.filter(function (item) { return item.scope.label === 'private'; }); } context.instances = items.map(function (item) { return item.instance; }); return _context6.abrupt("return", context); case 4: case "end": return _context6.stop(); } }, _callee6); })); return _findAppInstances.apply(this, arguments); } function scopeLabel(context, scope) { var mine = context.me && context.me.sameTerm(scope.agent); var name = mine ? '' : _utils__WEBPACK_IMPORTED_MODULE_9__/* .label */ .P(scope.agent) + ' '; return "".concat(name).concat(scope.label); } /** * UI to control registration of instance */ function registrationControl(_x6, _x7, _x8) { return _registrationControl.apply(this, arguments); } function _registrationControl() { _registrationControl = (0,_babel_runtime_helpers_asyncToGenerator__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */ .A)(/*#__PURE__*/_babel_runtime_regenerator__WEBPACK_IMPORTED_MODULE_1___default().mark(function _callee7(context, instance, theClass) { var registrationStatements, renderScopeCheckbox, dom, box, me, scopes, msg, tbody, form, _iterator, _step, scope, row, _t7; return _babel_runtime_regenerator__WEBPACK_IMPORTED_MODULE_1___default().wrap(function (_context7) { while (1) switch (_context7.prev = _context7.next) { case 0: renderScopeCheckbox = function _renderScopeCheckbox(scope) { var statements = registrationStatements(scope.index); var name = scopeLabel(context, scope); var label = "".concat(name, " link to this ").concat(context.noun); return _widgets__WEBPACK_IMPORTED_MODULE_12__/* .buildCheckboxForm */ .WY(context.dom, solid_logic_jss__WEBPACK_IMPORTED_MODULE_3__/* .solidLogicSingleton */ .hV.store, label, null, statements, form, scope.index); }; registrationStatements = function _registrationStatemen(index) { var registrations = getRegistrations(instance, theClass); var reg = registrations.length ? registrations[0] : _widgets__WEBPACK_IMPORTED_MODULE_12__/* .newThing */ .xV(index); return [(0,rdflib__WEBPACK_IMPORTED_MODULE_2__.st)(reg, _ns__WEBPACK_IMPORTED_MODULE_7__/* ["default"] */ .A.solid('instance'), instance, index), (0,rdflib__WEBPACK_IMPORTED_MODULE_2__.st)(reg, _ns__WEBPACK_IMPORTED_MODULE_7__/* ["default"] */ .A.solid('forClass'), theClass, index)]; }; /// / body of registrationControl dom = context.dom; if (!(!dom || !context.div)) { _context7.next = 1; break; } throw new Error('registrationControl: need dom and div'); case 1: box = dom.createElement('div'); context.div.appendChild(box); context.me = solid_logic_jss__WEBPACK_IMPORTED_MODULE_3__/* .authn */ .jO.currentUser(); // @@ me = context.me; if (me) { _context7.next = 2; break; } box.innerHTML = '

(Log in to save a link to this)

'; return _context7.abrupt("return", context); case 2: _context7.prev = 2; _context7.next = 3; return loadAllTypeIndexes(me); case 3: scopes = _context7.sent; _context7.next = 5; break; case 4: _context7.prev = 4; _t7 = _context7["catch"](2); if (context.div && context.preferencesFileError) { msg = '(Lists of stuff not available)'; context.div.appendChild(dom.createElement('p')).textContent = msg; } else if (context.div) { msg = "registrationControl: Type indexes not available: ".concat(_t7); context.div.appendChild(_widgets__WEBPACK_IMPORTED_MODULE_11__/* .errorMessageBlock */ .F(context.dom, _t7)); } _debug__WEBPACK_IMPORTED_MODULE_4__/* .log */ .Rm(msg); return _context7.abrupt("return", context); case 5: box.innerHTML = '
'; // tbody will be inserted anyway box.setAttribute('style', 'font-size: 120%; text-align: right; padding: 1em; border: solid gray 0.05em;'); tbody = box.children[0].children[0]; form = new rdflib__WEBPACK_IMPORTED_MODULE_2__.BlankNode(); // @@ say for now _iterator = _createForOfIteratorHelper(scopes); try { for (_iterator.s(); !(_step = _iterator.n()).done;) { scope = _step.value; row = tbody.appendChild(dom.createElement('tr')); row.appendChild(renderScopeCheckbox(scope)); // @@ index } } catch (err) { _iterator.e(err); } finally { _iterator.f(); } return _context7.abrupt("return", context); case 6: case "end": return _context7.stop(); } }, _callee7, null, [[2, 4]]); })); return _registrationControl.apply(this, arguments); } function renderScopeHeadingRow(context, store, scope) { var backgroundColor = { "private": '#fee', "public": '#efe' }; var dom = context.dom; var name = scopeLabel(context, scope); var row = dom.createElement('tr'); var cell = row.appendChild(dom.createElement('td')); cell.setAttribute('colspan', '3'); cell.style.backgoundColor = backgroundColor[scope.label] || 'white'; var header = cell.appendChild(dom.createElement('h3')); header.textContent = name + ' links'; header.style.textAlign = 'left'; return row; } /** * UI to List at all registered things */ function registrationList(_x9, _x0) { return _registrationList.apply(this, arguments); } // registrationList /** * Bootstrapping identity * (Called by `loginStatusBox()`) * * @param dom * @param setUserCallback * * @returns */ function _registrationList() { _registrationList = (0,_babel_runtime_helpers_asyncToGenerator__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */ .A)(/*#__PURE__*/_babel_runtime_regenerator__WEBPACK_IMPORTED_MODULE_1___default().mark(function _callee9(context, options) { var dom, div, box, scopes, table, tbody, _iterator2, _step2, scope, headingRow, items, _iterator3, _step3, _loop, _t8, _t9; return _babel_runtime_regenerator__WEBPACK_IMPORTED_MODULE_1___default().wrap(function (_context0) { while (1) switch (_context0.prev = _context0.next) { case 0: dom = context.dom; div = context.div; box = dom.createElement('div'); div.appendChild(box); context.me = solid_logic_jss__WEBPACK_IMPORTED_MODULE_3__/* .authn */ .jO.currentUser(); // @@ if (context.me) { _context0.next = 1; break; } box.innerHTML = '

(Log in list your stuff)

'; return _context0.abrupt("return", context); case 1: _context0.next = 2; return loadAllTypeIndexes(context.me); case 2: scopes = _context0.sent; // includes community indexes // console.log('@@ registrationList ', scopes) box.innerHTML = '
'; // tbody will be inserted anyway box.setAttribute('style', 'font-size: 120%; text-align: right; padding: 1em; border: solid #eee 0.5em;'); table = box.firstChild; tbody = table.firstChild; _iterator2 = _createForOfIteratorHelper(scopes); _context0.prev = 3; _iterator2.s(); case 4: if ((_step2 = _iterator2.n()).done) { _context0.next = 13; break; } scope = _step2.value; // need some predicate for listing/adding agents headingRow = renderScopeHeadingRow(context, store, scope); tbody.appendChild(headingRow); _context0.next = 5; return getScopedAppsFromIndex(scope, options.type || null); case 5: items = _context0.sent; // any class if (items.length === 0) headingRow.style.display = 'none'; // console.log(`registrationList: @@ instance items for class ${options.type || 'undefined' }:`, items) _iterator3 = _createForOfIteratorHelper(items); _context0.prev = 6; _loop = /*#__PURE__*/_babel_runtime_regenerator__WEBPACK_IMPORTED_MODULE_1___default().mark(function _loop() { var item, row; return _babel_runtime_regenerator__WEBPACK_IMPORTED_MODULE_1___default().wrap(function (_context9) { while (1) switch (_context9.prev = _context9.next) { case 0: item = _step3.value; row = _widgets__WEBPACK_IMPORTED_MODULE_10__/* .personTR */ .Cl(dom, _ns__WEBPACK_IMPORTED_MODULE_7__/* ["default"] */ .A.solid('instance'), item.instance, { deleteFunction: function () { var _deleteFunction = (0,_babel_runtime_helpers_asyncToGenerator__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */ .A)(/*#__PURE__*/_babel_runtime_regenerator__WEBPACK_IMPORTED_MODULE_1___default().mark(function _callee8() { return _babel_runtime_regenerator__WEBPACK_IMPORTED_MODULE_1___default().wrap(function (_context8) { while (1) switch (_context8.prev = _context8.next) { case 0: _context8.next = 1; return deleteTypeIndexRegistration(item); case 1: tbody.removeChild(row); case 2: case "end": return _context8.stop(); } }, _callee8); })); function deleteFunction() { return _deleteFunction.apply(this, arguments); } return deleteFunction; }() }); row.children[0].style.paddingLeft = '3em'; tbody.appendChild(row); case 1: case "end": return _context9.stop(); } }, _loop); }); _iterator3.s(); case 7: if ((_step3 = _iterator3.n()).done) { _context0.next = 9; break; } return _context0.delegateYield(_loop(), "t0", 8); case 8: _context0.next = 7; break; case 9: _context0.next = 11; break; case 10: _context0.prev = 10; _t8 = _context0["catch"](6); _iterator3.e(_t8); case 11: _context0.prev = 11; _iterator3.f(); return _context0.finish(11); case 12: _context0.next = 4; break; case 13: _context0.next = 15; break; case 14: _context0.prev = 14; _t9 = _context0["catch"](3); _iterator2.e(_t9); case 15: _context0.prev = 15; _iterator2.f(); return _context0.finish(15); case 16: return _context0.abrupt("return", context); case 17: case "end": return _context0.stop(); } }, _callee9, null, [[3, 14, 15, 16], [6, 10, 11, 12]]); })); return _registrationList.apply(this, arguments); } function signInOrSignUpBox(dom, setUserCallback) { var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {}; options = options || {}; var signInButtonStyle = options.buttonStyle || _style__WEBPACK_IMPORTED_MODULE_5__/* .style */ .i.signInAndUpButtonStyle; var box = dom.createElement('div'); var magicClassName = 'SolidSignInOrSignUpBox'; _debug__WEBPACK_IMPORTED_MODULE_4__/* .log */ .Rm('widgets.signInOrSignUpBox'); box.setUserCallback = setUserCallback; box.setAttribute('class', magicClassName); box.setAttribute('style', 'display:flex;'); // Sign in button with PopUP var signInPopUpButton = dom.createElement('input'); // multi box.appendChild(signInPopUpButton); signInPopUpButton.setAttribute('type', 'button'); signInPopUpButton.setAttribute('value', 'Log in'); signInPopUpButton.setAttribute('style', "".concat(signInButtonStyle).concat(_style__WEBPACK_IMPORTED_MODULE_5__/* .style */ .i.headerBannerLoginInput) + _style__WEBPACK_IMPORTED_MODULE_5__/* .style */ .i.signUpBackground); solid_logic_jss__WEBPACK_IMPORTED_MODULE_3__/* .authSession */ .lG.events.on('login', function () { var me = solid_logic_jss__WEBPACK_IMPORTED_MODULE_3__/* .authn */ .jO.currentUser(); // const sessionInfo = authSession.info // if (sessionInfo && sessionInfo.isLoggedIn) { if (me) { // const webIdURI = sessionInfo.webId var webIdURI = me.uri; // setUserCallback(webIdURI) var divs = dom.getElementsByClassName(magicClassName); _debug__WEBPACK_IMPORTED_MODULE_4__/* .log */ .Rm("Logged in, ".concat(divs.length, " panels to be serviced")); // At the same time, satisfy all the other login boxes for (var i = 0; i < divs.length; i++) { var div = divs[i]; // @@ TODO Remove the need to manipulate HTML elements if (div.setUserCallback) { try { div.setUserCallback(webIdURI); var parent = div.parentNode; if (parent) { parent.removeChild(div); } } catch (e) { _debug__WEBPACK_IMPORTED_MODULE_4__/* .log */ .Rm("## Error satisfying login box: ".concat(e)); div.appendChild(_widgets__WEBPACK_IMPORTED_MODULE_11__/* .errorMessageBlock */ .F(dom, e)); } } } } }); signInPopUpButton.addEventListener('click', function () { var offline = (0,solid_logic_jss__WEBPACK_IMPORTED_MODULE_3__/* .offlineTestID */ .TX)(); if (offline) return setUserCallback(offline.uri); renderSignInPopup(dom); }, false); // Sign up button var signupButton = dom.createElement('input'); box.appendChild(signupButton); signupButton.setAttribute('type', 'button'); signupButton.setAttribute('value', 'Sign Up for Solid'); signupButton.setAttribute('style', "".concat(signInButtonStyle).concat(_style__WEBPACK_IMPORTED_MODULE_5__/* .style */ .i.headerBannerLoginInput) + _style__WEBPACK_IMPORTED_MODULE_5__/* .style */ .i.signInBackground); signupButton.addEventListener('click', function (_event) { var signupMgr = new _signup_signup_js__WEBPACK_IMPORTED_MODULE_8__/* .Signup */ .l(); signupMgr.signup().then(function (uri) { _debug__WEBPACK_IMPORTED_MODULE_4__/* .log */ .Rm('signInOrSignUpBox signed up ' + uri); setUserCallback(uri); }); }, false); return box; } function renderSignInPopup(dom) { /** * Issuer Menu */ var issuerPopup = dom.createElement('div'); issuerPopup.setAttribute('style', 'position: fixed; top: 0; left: 0; right: 0; bottom: 0; display: flex; justify-content: center; align-items: center;'); dom.body.appendChild(issuerPopup); var issuerPopupBox = dom.createElement('div'); issuerPopupBox.setAttribute('style', "\n background-color: white;\n box-shadow: 0px 1px 4px rgba(0, 0, 0, 0.2);\n -webkit-box-shadow: 0px 1px 4px rgba(0, 0, 0, 0.2);\n -moz-box-shadow: 0px 1px 4px rgba(0, 0, 0, 0.2);\n -o-box-shadow: 0px 1px 4px rgba(0, 0, 0, 0.2);\n border-radius: 4px;\n min-width: 400px;\n padding: 10px;\n z-index : 10;\n "); issuerPopup.appendChild(issuerPopupBox); var issuerPopupBoxTopMenu = dom.createElement('div'); issuerPopupBoxTopMenu.setAttribute('style', "\n border-bottom: 1px solid #DDD;\n display: flex;\n flex-direction: row;\n align-items: center;\n justify-content: space-between;\n "); issuerPopupBox.appendChild(issuerPopupBoxTopMenu); var issuerPopupBoxLabel = dom.createElement('label'); issuerPopupBoxLabel.setAttribute('style', 'margin-right: 5px; font-weight: 800'); issuerPopupBoxLabel.innerText = 'Select an identity provider'; var issuerPopupBoxCloseButton = dom.createElement('button'); issuerPopupBoxCloseButton.innerHTML = ''; issuerPopupBoxCloseButton.setAttribute('style', 'background-color: transparent; border: none;'); issuerPopupBoxCloseButton.addEventListener('click', function () { issuerPopup.remove(); }); issuerPopupBoxTopMenu.appendChild(issuerPopupBoxLabel); issuerPopupBoxTopMenu.appendChild(issuerPopupBoxCloseButton); var loginToIssuer = /*#__PURE__*/function () { var _ref = (0,_babel_runtime_helpers_asyncToGenerator__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */ .A)(/*#__PURE__*/_babel_runtime_regenerator__WEBPACK_IMPORTED_MODULE_1___default().mark(function _callee(issuerUri) { var preLoginRedirectHash, locationUrl, _t; return _babel_runtime_regenerator__WEBPACK_IMPORTED_MODULE_1___default().wrap(function (_context) { while (1) switch (_context.prev = _context.next) { case 0: _context.prev = 0; // clear authorization metadata from store solid_logic_jss__WEBPACK_IMPORTED_MODULE_3__/* .solidLogicSingleton */ .hV.store.updater.flagAuthorizationMetadata(); // Save hash preLoginRedirectHash = new URL(window.location.href).hash; if (preLoginRedirectHash) { window.localStorage.setItem('preLoginRedirectHash', preLoginRedirectHash); } window.localStorage.setItem('loginIssuer', issuerUri); // Login locationUrl = new URL(window.location.href); locationUrl.hash = ''; // remove hash part _context.next = 1; return solid_logic_jss__WEBPACK_IMPORTED_MODULE_3__/* .authSession */ .lG.login({ redirectUrl: locationUrl.href, oidcIssuer: issuerUri }); case 1: _context.next = 3; break; case 2: _context.prev = 2; _t = _context["catch"](0); (0,_log__WEBPACK_IMPORTED_MODULE_6__.alert)(_t.message); case 3: case "end": return _context.stop(); } }, _callee, null, [[0, 2]]); })); return function loginToIssuer(_x1) { return _ref.apply(this, arguments); }; }(); /** * Text-based idp selection */ var issuerTextContainer = dom.createElement('div'); issuerTextContainer.setAttribute('style', "\n border-bottom: 1px solid #DDD;\n display: flex;\n flex-direction: column;\n padding-top: 10px;\n "); var issuerTextInputContainer = dom.createElement('div'); issuerTextInputContainer.setAttribute('style', "\n display: flex;\n flex-direction: row;\n "); var issuerTextLabel = dom.createElement('label'); issuerTextLabel.innerText = 'Enter the URL of your identity provider:'; issuerTextLabel.setAttribute('style', 'color: #888'); var issuerTextInput = dom.createElement('input'); issuerTextInput.setAttribute('type', 'text'); issuerTextInput.setAttribute('style', 'margin-left: 0 !important; flex: 1; margin-right: 5px !important'); issuerTextInput.setAttribute('placeholder', 'https://example.com'); issuerTextInput.value = localStorage.getItem('loginIssuer') || ''; var issuerTextGoButton = dom.createElement('button'); issuerTextGoButton.innerText = 'Go'; issuerTextGoButton.setAttribute('style', 'margin-top: 12px; margin-bottom: 12px;'); issuerTextGoButton.addEventListener('click', function () { loginToIssuer(issuerTextInput.value); }); issuerTextContainer.appendChild(issuerTextLabel); issuerTextInputContainer.appendChild(issuerTextInput); issuerTextInputContainer.appendChild(issuerTextGoButton); issuerTextContainer.appendChild(issuerTextInputContainer); issuerPopupBox.appendChild(issuerTextContainer); /** * Button-based idp selection */ var issuerButtonContainer = dom.createElement('div'); issuerButtonContainer.setAttribute('style', "\n display: flex;\n flex-direction: column;\n padding-top: 10px;\n "); var issuerBottonLabel = dom.createElement('label'); issuerBottonLabel.innerText = 'Or pick an identity provider from the list below:'; issuerBottonLabel.setAttribute('style', 'color: #888'); issuerButtonContainer.appendChild(issuerBottonLabel); (0,solid_logic_jss__WEBPACK_IMPORTED_MODULE_3__/* .getSuggestedIssuers */ .I0)().forEach(function (issuerInfo) { var issuerButton = dom.createElement('button'); issuerButton.innerText = issuerInfo.name; issuerButton.setAttribute('style', 'height: 38px; margin-top: 10px'); issuerButton.addEventListener('click', function () { loginToIssuer(issuerInfo.uri); }); issuerButtonContainer.appendChild(issuerButton); }); issuerPopupBox.appendChild(issuerButtonContainer); } /** * Login status box * * A big sign-up/sign in box or a logout box depending on the state * * @param dom * @param listener * * @returns */ function loginStatusBox(dom) { var listener = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null; var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {}; // 20190630 var me = (0,solid_logic_jss__WEBPACK_IMPORTED_MODULE_3__/* .offlineTestID */ .TX)(); // @@ TODO Remove the need to cast HTML element to any var box = dom.createElement('div'); function setIt(newidURI) { if (!newidURI) { return; } // const uri = newidURI.uri || newidURI // me = sym(uri) me = solid_logic_jss__WEBPACK_IMPORTED_MODULE_3__/* .authn */ .jO.saveUser(newidURI); box.refresh(); if (listener) listener(me.uri); } function logoutButtonHandler(_event) { var oldMe = me; solid_logic_jss__WEBPACK_IMPORTED_MODULE_3__/* .authSession */ .lG.logout().then(function () { var message = "Your WebID was ".concat(oldMe, ". It has been forgotten."); me = null; try { (0,_log__WEBPACK_IMPORTED_MODULE_6__.alert)(message); } catch (_e) { window.alert(message); } box.refresh(); if (listener) listener(null); }, function (err) { (0,_log__WEBPACK_IMPORTED_MODULE_6__.alert)('Fail to log out:' + err); }); } function logoutButton(me, options) { var signInButtonStyle = options.buttonStyle || _style__WEBPACK_IMPORTED_MODULE_5__/* .style */ .i.signInAndUpButtonStyle; var logoutLabel = 'WebID logout'; if (me) { var nick = solid_logic_jss__WEBPACK_IMPORTED_MODULE_3__/* .solidLogicSingleton */ .hV.store.any(me, _ns__WEBPACK_IMPORTED_MODULE_7__/* ["default"] */ .A.foaf('nick')) || solid_logic_jss__WEBPACK_IMPORTED_MODULE_3__/* .solidLogicSingleton */ .hV.store.any(me, _ns__WEBPACK_IMPORTED_MODULE_7__/* ["default"] */ .A.foaf('name')); if (nick) { logoutLabel = 'Logout ' + nick.value; } } var signOutButton = dom.createElement('input'); // signOutButton.className = 'WebIDCancelButton' signOutButton.setAttribute('type', 'button'); signOutButton.setAttribute('value', logoutLabel); signOutButton.setAttribute('style', "".concat(signInButtonStyle)); signOutButton.addEventListener('click', logoutButtonHandler, false); return signOutButton; } box.refresh = function () { var sessionInfo = solid_logic_jss__WEBPACK_IMPORTED_MODULE_3__/* .authSession */ .lG.info; if (sessionInfo && sessionInfo.webId && sessionInfo.isLoggedIn) { me = solid_logic_jss__WEBPACK_IMPORTED_MODULE_3__/* .solidLogicSingleton */ .hV.store.sym(sessionInfo.webId); } else { me = null; } if (me && box.me !== me.uri || !me && box.me) { _widgets__WEBPACK_IMPORTED_MODULE_10__/* .clearElement */ .EW(box); if (me) { box.appendChild(logoutButton(me, options)); } else { box.appendChild(signInOrSignUpBox(dom, setIt, options)); } } box.me = me ? me.uri : null; }; box.refresh(); function trackSession() { me = solid_logic_jss__WEBPACK_IMPORTED_MODULE_3__/* .authn */ .jO.currentUser(); box.refresh(); } trackSession(); solid_logic_jss__WEBPACK_IMPORTED_MODULE_3__/* .authSession */ .lG.events.on('login', trackSession); solid_logic_jss__WEBPACK_IMPORTED_MODULE_3__/* .authSession */ .lG.events.on('logout', trackSession); box.me = '99999'; // Force refresh box.refresh(); return box; } solid_logic_jss__WEBPACK_IMPORTED_MODULE_3__/* .authSession */ .lG.events.on('logout', /*#__PURE__*/(0,_babel_runtime_helpers_asyncToGenerator__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */ .A)(/*#__PURE__*/_babel_runtime_regenerator__WEBPACK_IMPORTED_MODULE_1___default().mark(function _callee2() { var issuer, wellKnownUri, wellKnownResult, openidConfiguration, _t2; return _babel_runtime_regenerator__WEBPACK_IMPORTED_MODULE_1___default().wrap(function (_context2) { while (1) switch (_context2.prev = _context2.next) { case 0: issuer = window.localStorage.getItem('loginIssuer'); if (!issuer) { _context2.next = 6; break; } _context2.prev = 1; // clear authorization metadata from store solid_logic_jss__WEBPACK_IMPORTED_MODULE_3__/* .solidLogicSingleton */ .hV.store.updater.flagAuthorizationMetadata(); wellKnownUri = new URL(issuer); wellKnownUri.pathname = '/.well-known/openid-configuration'; _context2.next = 2; return fetch(wellKnownUri.toString()); case 2: wellKnownResult = _context2.sent; if (!(wellKnownResult.status === 200)) { _context2.next = 4; break; } _context2.next = 3; return wellKnownResult.json(); case 3: openidConfiguration = _context2.sent; if (!(openidConfiguration && openidConfiguration.end_session_endpoint)) { _context2.next = 4; break; } _context2.next = 4; return fetch(openidConfiguration.end_session_endpoint, { credentials: 'include' }); case 4: _context2.next = 6; break; case 5: _context2.prev = 5; _t2 = _context2["catch"](1); case 6: window.location.reload(); case 7: case "end": return _context2.stop(); } }, _callee2, null, [[1, 5]]); }))); /** * Workspace selection etc * See https://github.com/solidos/userguide/issues/16 */ /** * Returns a UI object which, if it selects a workspace, * will callback(workspace, newBase). * See https://github.com/solidos/userguide/issues/16 for more info on workspaces. * * If necessary, will get an account, preference file, etc. In sequence: * * - If not logged in, log in. * - Load preference file * - Prompt user for workspaces * - Allows the user to just type in a URI by hand * * Calls back with the workspace and the base URI * * @param dom * @param appDetails * @param callbackWS */ function selectWorkspace(dom, appDetails, callbackWS) { var noun = appDetails.noun; var appPathSegment = appDetails.appPathSegment; var me = (0,solid_logic_jss__WEBPACK_IMPORTED_MODULE_3__/* .offlineTestID */ .TX)(); var box = dom.createElement('div'); var context = { me: me, dom: dom, div: box }; function say(s, background) { box.appendChild(_widgets__WEBPACK_IMPORTED_MODULE_11__/* .errorMessageBlock */ .F(dom, s, background)); } function figureOutBase(ws) { var newBaseNode = solid_logic_jss__WEBPACK_IMPORTED_MODULE_3__/* .solidLogicSingleton */ .hV.store.any(ws, _ns__WEBPACK_IMPORTED_MODULE_7__/* ["default"] */ .A.space('uriPrefix')); var newBaseString; if (!newBaseNode) { newBaseString = ws.uri.split('#')[0]; } else { newBaseString = newBaseNode.value; } if (newBaseString.slice(-1) !== '/') { _debug__WEBPACK_IMPORTED_MODULE_4__/* .log */ .Rm("".concat(appPathSegment, ": No / at end of uriPrefix ").concat(newBaseString)); // @@ paramater? newBaseString = "".concat(newBaseString, "/"); } var now = new Date(); newBaseString += "".concat(appPathSegment, "/id").concat(now.getTime(), "/"); // unique id return newBaseString; } function displayOptions(context) { // console.log('displayOptions!', context) function makeNewWorkspace(_x10) { return _makeNewWorkspace.apply(this, arguments); } // const status = '' function _makeNewWorkspace() { _makeNewWorkspace = (0,_babel_runtime_helpers_asyncToGenerator__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */ .A)(/*#__PURE__*/_babel_runtime_regenerator__WEBPACK_IMPORTED_MODULE_1___default().mark(function _callee3(_event) { var row, cell, newBase, newWs, newData, _t3; return _babel_runtime_regenerator__WEBPACK_IMPORTED_MODULE_1___default().wrap(function (_context3) { while (1) switch (_context3.prev = _context3.next) { case 0: row = table.appendChild(dom.createElement('tr')); cell = row.appendChild(dom.createElement('td')); cell.setAttribute('colspan', '3'); cell.style.padding = '0.5em'; _t3 = encodeURI; _context3.next = 1; return _widgets__WEBPACK_IMPORTED_MODULE_10__/* .askName */ .RG(dom, solid_logic_jss__WEBPACK_IMPORTED_MODULE_3__/* .solidLogicSingleton */ .hV.store, cell, _ns__WEBPACK_IMPORTED_MODULE_7__/* ["default"] */ .A.solid('URL'), _ns__WEBPACK_IMPORTED_MODULE_7__/* ["default"] */ .A.space('Workspace'), 'Workspace'); case 1: newBase = _t3(_context3.sent); newWs = _widgets__WEBPACK_IMPORTED_MODULE_12__/* .newThing */ .xV(context.preferencesFile); newData = [(0,rdflib__WEBPACK_IMPORTED_MODULE_2__.st)(context.me, _ns__WEBPACK_IMPORTED_MODULE_7__/* ["default"] */ .A.space('workspace'), newWs, context.preferencesFile), (0,rdflib__WEBPACK_IMPORTED_MODULE_2__.st)(newWs, _ns__WEBPACK_IMPORTED_MODULE_7__/* ["default"] */ .A.space('uriPrefix'), newBase, context.preferencesFile)]; if (solid_logic_jss__WEBPACK_IMPORTED_MODULE_3__/* .solidLogicSingleton */ .hV.store.updater) { _context3.next = 2; break; } throw new Error('store has no updater'); case 2: _context3.next = 3; return solid_logic_jss__WEBPACK_IMPORTED_MODULE_3__/* .solidLogicSingleton */ .hV.store.updater.update([], newData); case 3: case "end": return _context3.stop(); } }, _callee3); })); return _makeNewWorkspace.apply(this, arguments); } var id = context.me; var preferencesFile = context.preferencesFile; var newBase = null; // A workspace specifically defined in the private preference file: var w = solid_logic_jss__WEBPACK_IMPORTED_MODULE_3__/* .solidLogicSingleton */ .hV.store.each(id, _ns__WEBPACK_IMPORTED_MODULE_7__/* ["default"] */ .A.space('workspace'), undefined, preferencesFile); // Only trust preference file here // A workspace in a storage in the public profile: var storages = solid_logic_jss__WEBPACK_IMPORTED_MODULE_3__/* .solidLogicSingleton */ .hV.store.each(id, _ns__WEBPACK_IMPORTED_MODULE_7__/* ["default"] */ .A.space('storage')); // @@ No provenance requirement at the moment if (w.length === 0 && storages) { say("You don't seem to have any workspaces. You have ".concat(storages.length, " storage spaces."), 'white'); storages.map(function (s) { w = w.concat(solid_logic_jss__WEBPACK_IMPORTED_MODULE_3__/* .solidLogicSingleton */ .hV.store.each(s, _ns__WEBPACK_IMPORTED_MODULE_7__/* ["default"] */ .A.ldp('contains'))); return w; }).filter(function (file) { return file.id ? ['public', 'private'].includes(file.id().toLowerCase()) : ''; }); } if (w.length === 1) { say("Workspace used: ".concat(w[0].uri), 'white'); // @@ allow user to see URI newBase = figureOutBase(w[0]); // callbackWS(w[0], newBase) // } else if (w.length === 0) { } // Prompt for ws selection or creation // say( w.length + " workspaces for " + id + "Choose one."); var table = dom.createElement('table'); table.setAttribute('style', 'border-collapse:separate; border-spacing: 0.5em;'); // const popup = window.open(undefined, '_blank', { height: 300, width:400 }, false) box.appendChild(table); // Add a field for directly adding the URI yourself // const hr = box.appendChild(dom.createElement('hr')) // @@ box.appendChild(dom.createElement('hr')); // @@ var p = box.appendChild(dom.createElement('p')); p.setAttribute('style', _style__WEBPACK_IMPORTED_MODULE_5__/* .style */ .i.commentStyle); p.textContent = "Where would you like to store the data for the ".concat(noun, "?\n Give the URL of the folder where you would like the data stored.\n It can be anywhere in solid world - this URI is just an idea."); // @@ TODO Remove the need to cast baseField to any var baseField = box.appendChild(dom.createElement('input')); baseField.setAttribute('type', 'text'); baseField.setAttribute('style', _style__WEBPACK_IMPORTED_MODULE_5__/* .style */ .i.textInputStyle); baseField.size = 80; // really a string baseField.label = 'base URL'; baseField.autocomplete = 'on'; if (newBase) { // set to default baseField.value = newBase; } context.baseField = baseField; box.appendChild(dom.createElement('br')); // @@ var button = box.appendChild(dom.createElement('button')); button.setAttribute('style', _style__WEBPACK_IMPORTED_MODULE_5__/* .style */ .i.buttonStyle); button.textContent = "Start new ".concat(noun, " at this URI"); button.addEventListener('click', function (_event) { var newBase = baseField.value.replace(' ', '%20'); // do not re-encode in general, as % encodings may exist if (newBase.slice(-1) !== '/') { newBase += '/'; } callbackWS(null, newBase); }); // Now go set up the table of spaces // const row = 0 w = w.filter(function (x) { return !solid_logic_jss__WEBPACK_IMPORTED_MODULE_3__/* .solidLogicSingleton */ .hV.store.holds(x, _ns__WEBPACK_IMPORTED_MODULE_7__/* ["default"] */ .A.rdf('type'), // Ignore master workspaces _ns__WEBPACK_IMPORTED_MODULE_7__/* ["default"] */ .A.space('MasterWorkspace')); }); var col1, col2, col3, tr, ws, localStyle, comment; var cellStyle = 'height: 3em; margin: 1em; padding: 1em white; border-radius: 0.3em;'; var deselectedStyle = "".concat(cellStyle, "border: 0px;"); // const selectedStyle = cellStyle + 'border: 1px solid black;' for (var i = 0; i < w.length; i++) { ws = w[i]; tr = dom.createElement('tr'); if (i === 0) { col1 = dom.createElement('td'); col1.setAttribute('rowspan', "".concat(w.length)); col1.textContent = 'Choose a workspace for this:'; col1.setAttribute('style', 'vertical-align:middle;'); tr.appendChild(col1); } col2 = dom.createElement('td'); localStyle = solid_logic_jss__WEBPACK_IMPORTED_MODULE_3__/* .solidLogicSingleton */ .hV.store.anyValue(ws, _ns__WEBPACK_IMPORTED_MODULE_7__/* ["default"] */ .A.ui('style')); if (!localStyle) { // Otherwise make up arbitrary colour var hash = function hash(x) { return x.split('').reduce(function (a, b) { a = (a << 5) - a + b.charCodeAt(0); return a & a; }, 0); }; var bgcolor = "#".concat((hash(ws.uri) & 0xffffff | 0xc0c0c0).toString(16)); // c0c0c0 forces pale localStyle = "color: black ; background-color: ".concat(bgcolor, ";"); } col2.setAttribute('style', deselectedStyle + localStyle); tr.target = ws.uri; var label = solid_logic_jss__WEBPACK_IMPORTED_MODULE_3__/* .solidLogicSingleton */ .hV.store.any(ws, _ns__WEBPACK_IMPORTED_MODULE_7__/* ["default"] */ .A.rdfs('label')); if (!label) { label = ws.uri.split('/').slice(-1)[0] || ws.uri.split('/').slice(-2)[0]; } col2.textContent = label || '???'; tr.appendChild(col2); if (i === 0) { col3 = dom.createElement('td'); col3.setAttribute('rowspan', "".concat(w.length, "1")); // col3.textContent = '@@@@@ remove'; col3.setAttribute('style', 'width:50%;'); tr.appendChild(col3); } table.appendChild(tr); comment = solid_logic_jss__WEBPACK_IMPORTED_MODULE_3__/* .solidLogicSingleton */ .hV.store.any(ws, _ns__WEBPACK_IMPORTED_MODULE_7__/* ["default"] */ .A.rdfs('comment')); comment = comment ? comment.value : 'Use this workspace'; col2.addEventListener('click', function (_event) { col3.textContent = comment ? comment.value : ''; col3.setAttribute('style', deselectedStyle + localStyle); var button = dom.createElement('button'); button.textContent = 'Continue'; // button.setAttribute('style', style); var newBase = figureOutBase(ws); baseField.value = newBase; // show user proposed URI button.addEventListener('click', function (_event) { button.disabled = true; callbackWS(ws, newBase); button.textContent = '---->'; }, true); // capture vs bubble col3.appendChild(button); }, true); // capture vs bubble } // last line with "Make new workspace" var trLast = dom.createElement('tr'); col2 = dom.createElement('td'); col2.setAttribute('style', cellStyle); col2.textContent = '+ Make a new workspace'; col2.addEventListener('click', makeNewWorkspace); trLast.appendChild(col2); table.appendChild(trLast); } // displayOptions // console.log('kicking off async operation') ensureLoadedPreferences(context) // kick off async operation .then(displayOptions)["catch"](function (err) { // console.log("err from async op") box.appendChild(_widgets__WEBPACK_IMPORTED_MODULE_11__/* .errorMessageBlock */ .F(context.dom, err)); }); return box; // return the box element, while login proceeds } // selectWorkspace /** * Creates a new instance of an app. * * An instance of an app could be e.g. an issue tracker for a given project, * or a chess game, or calendar, or a health/fitness record for a person. * * Note that this use of the term 'app' refers more to entries in the user's * type index than to actual software applications that use the personal data * to which these entries point. * * @param dom * @param appDetails * @param callback * * @returns A div with a button in it for making a new app instance */ function newAppInstance(dom, appDetails, callback) { var gotWS = function gotWS(ws, base) { // log.debug("newAppInstance: Selected workspace = " + (ws? ws.uri : 'none')) callback(ws, base); }; var div = dom.createElement('div'); var b = dom.createElement('button'); b.setAttribute('type', 'button'); div.appendChild(b); b.innerHTML = "Make new ".concat(appDetails.noun); b.addEventListener('click', function (_event) { div.appendChild(selectWorkspace(dom, appDetails, gotWS)); }, false); div.appendChild(b); return div; } /** * Retrieves whether the currently logged in user is a power user * and/or a developer */ function getUserRoles() { return _getUserRoles.apply(this, arguments); } /** * Filters which panes should be available, based on the result of [[getUserRoles]] */ function _getUserRoles() { _getUserRoles = (0,_babel_runtime_helpers_asyncToGenerator__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */ .A)(/*#__PURE__*/_babel_runtime_regenerator__WEBPACK_IMPORTED_MODULE_1___default().mark(function _callee0() { var _yield$ensureLoadedPr, me, preferencesFile, preferencesFileError, _t0; return _babel_runtime_regenerator__WEBPACK_IMPORTED_MODULE_1___default().wrap(function (_context1) { while (1) switch (_context1.prev = _context1.next) { case 0: _context1.prev = 0; _context1.next = 1; return ensureLoadedPreferences({}); case 1: _yield$ensureLoadedPr = _context1.sent; me = _yield$ensureLoadedPr.me; preferencesFile = _yield$ensureLoadedPr.preferencesFile; preferencesFileError = _yield$ensureLoadedPr.preferencesFileError; if (!(!preferencesFile || preferencesFileError)) { _context1.next = 2; break; } throw new Error(preferencesFileError); case 2: return _context1.abrupt("return", solid_logic_jss__WEBPACK_IMPORTED_MODULE_3__/* .solidLogicSingleton */ .hV.store.each(me, _ns__WEBPACK_IMPORTED_MODULE_7__/* ["default"] */ .A.rdf('type'), null, preferencesFile.doc())); case 3: _context1.prev = 3; _t0 = _context1["catch"](0); _debug__WEBPACK_IMPORTED_MODULE_4__/* .warn */ .R8('Unable to fetch your preferences - this was the error: ', _t0); return _context1.abrupt("return", []); case 4: case "end": return _context1.stop(); } }, _callee0, null, [[0, 3]]); })); return _getUserRoles.apply(this, arguments); } function filterAvailablePanes(_x11) { return _filterAvailablePanes.apply(this, arguments); } function _filterAvailablePanes() { _filterAvailablePanes = (0,_babel_runtime_helpers_asyncToGenerator__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */ .A)(/*#__PURE__*/_babel_runtime_regenerator__WEBPACK_IMPORTED_MODULE_1___default().mark(function _callee1(panes) { var userRoles; return _babel_runtime_regenerator__WEBPACK_IMPORTED_MODULE_1___default().wrap(function (_context10) { while (1) switch (_context10.prev = _context10.next) { case 0: _context10.next = 1; return getUserRoles(); case 1: userRoles = _context10.sent; return _context10.abrupt("return", panes.filter(function (pane) { return isMatchingAudience(pane, userRoles); })); case 2: case "end": return _context10.stop(); } }, _callee1); })); return _filterAvailablePanes.apply(this, arguments); } function isMatchingAudience(pane, userRoles) { var audience = pane.audience || []; return audience.reduce(function (isMatch, audienceRole) { return isMatch && !!userRoles.find(function (role) { return role.equals(audienceRole); }); }, true); } /***/ }, /***/ 1060 (__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) { /* harmony export */ __webpack_require__.d(__webpack_exports__, { /* harmony export */ k: () => (/* binding */ unsafeStringify) /* harmony export */ }); const byteToHex = []; for (let i = 0; i < 256; ++i) { byteToHex.push((i + 0x100).toString(16).slice(1)); } function unsafeStringify(arr, offset = 0) { return (byteToHex[arr[offset + 0]] + byteToHex[arr[offset + 1]] + byteToHex[arr[offset + 2]] + byteToHex[arr[offset + 3]] + '-' + byteToHex[arr[offset + 4]] + byteToHex[arr[offset + 5]] + '-' + byteToHex[arr[offset + 6]] + byteToHex[arr[offset + 7]] + '-' + byteToHex[arr[offset + 8]] + byteToHex[arr[offset + 9]] + '-' + byteToHex[arr[offset + 10]] + byteToHex[arr[offset + 11]] + byteToHex[arr[offset + 12]] + byteToHex[arr[offset + 13]] + byteToHex[arr[offset + 14]] + byteToHex[arr[offset + 15]]).toLowerCase(); } function stringify(arr, offset = 0) { const uuid = unsafeStringify(arr, offset); if (!validate(uuid)) { throw TypeError('Stringified UUID is invalid'); } return uuid; } /* unused harmony default export */ var __WEBPACK_DEFAULT_EXPORT__ = ((/* unused pure expression or super */ null && (stringify))); /***/ }, /***/ 1214 (__unused_webpack_module, __webpack_exports__, __webpack_require__) { /* harmony export */ __webpack_require__.d(__webpack_exports__, { /* harmony export */ h: () => (/* binding */ AccessGroups) /* harmony export */ }); /* harmony import */ var _babel_runtime_helpers_asyncToGenerator__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(467); /* harmony import */ var _babel_runtime_helpers_slicedToArray__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(3453); /* harmony import */ var _babel_runtime_helpers_classCallCheck__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(3029); /* harmony import */ var _babel_runtime_helpers_createClass__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(2901); /* harmony import */ var _babel_runtime_regenerator__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(4756); /* harmony import */ var _babel_runtime_regenerator__WEBPACK_IMPORTED_MODULE_4___default = /*#__PURE__*/__webpack_require__.n(_babel_runtime_regenerator__WEBPACK_IMPORTED_MODULE_4__); /* harmony import */ var rdflib__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(4961); /* harmony import */ var _acl__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(5619); /* harmony import */ var _widgets__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(386); /* harmony import */ var _widgets__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(3291); /* harmony import */ var _ns__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(1795); /* harmony import */ var _add_agent_buttons__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(1928); /* harmony import */ var _debug__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(7423); /* harmony import */ var _style__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(675); /** * Contains the [[AccessGroups]] * and [[AccessGroupsOptions]] classes * @packageDocumentation */ var ACL = _ns__WEBPACK_IMPORTED_MODULE_9__/* ["default"] */ .A.acl; var COLLOQUIAL = { 13: 'Owners', 9: 'Owners (write locked)', 5: 'Editors', 3: 'Posters', 2: 'Submitters', 1: 'Viewers' }; var RECOMMENDED = { 13: true, 5: true, 3: true, 2: true, 1: true }; var EXPLANATION = { 13: 'can read, write, and control sharing.', 9: 'can read and control sharing, currently write-locked.', 5: 'can read and change information', 3: 'can add new information, and read but not change existing information', 2: 'can add new information but not read any', 1: 'can read but not change information' }; /** * Type for the options parameter of [[AccessGroups]] */ /** * Renders the table of Owners, Editors, Posters, Submitters, Viewers * for https://github.com/solidos/userguide/blob/main/views/sharing/userguide.md */ var AccessGroups = /*#__PURE__*/function () { // @@ was LiveStore but does not need to be connected to web function AccessGroups(doc, aclDoc, controller, store) { var _options = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : {}; (0,_babel_runtime_helpers_classCallCheck__WEBPACK_IMPORTED_MODULE_2__/* ["default"] */ .A)(this, AccessGroups); this.doc = doc; this.aclDoc = aclDoc; this.controller = controller; this._options = _options; this.defaults = this._options.defaults || false; this._store = store; this.aclMap = (0,_acl__WEBPACK_IMPORTED_MODULE_6__/* .readACL */ .fg)(doc, aclDoc, store, this.defaults); this.byCombo = (0,_acl__WEBPACK_IMPORTED_MODULE_6__/* .ACLbyCombination */ .xw)(this.aclMap); this.addAgentButton = new _add_agent_buttons__WEBPACK_IMPORTED_MODULE_10__/* .AddAgentButtons */ .g(this); this.rootElement = this.controller.dom.createElement('div'); this.rootElement.setAttribute('style', _style__WEBPACK_IMPORTED_MODULE_12__/* .style */ .i.accessGroupList); } return (0,_babel_runtime_helpers_createClass__WEBPACK_IMPORTED_MODULE_3__/* ["default"] */ .A)(AccessGroups, [{ key: "store", get: function get() { return this._store; }, set: function set(store) { this._store = store; this.aclMap = (0,_acl__WEBPACK_IMPORTED_MODULE_6__/* .readACL */ .fg)(this.doc, this.aclDoc, store, this.defaults); this.byCombo = (0,_acl__WEBPACK_IMPORTED_MODULE_6__/* .ACLbyCombination */ .xw)(this.aclMap); } }, { key: "render", value: function render() { var _this = this; this.rootElement.innerHTML = ''; this.renderGroups().forEach(function (group) { return _this.rootElement.appendChild(group); }); if (this.controller.isEditable) { this.rootElement.appendChild(this.addAgentButton.render()); } return this.rootElement; } }, { key: "renderGroups", value: function renderGroups() { var groupElements = []; for (var comboIndex = 15; comboIndex > 0; comboIndex--) { var combo = kToCombo(comboIndex); if (this.controller.isEditable && RECOMMENDED[comboIndex] || this.byCombo[combo]) { groupElements.push(this.renderGroup(comboIndex, combo)); } } return groupElements; } }, { key: "renderGroup", value: function renderGroup(comboIndex, combo) { var _this2 = this; var groupRow = this.controller.dom.createElement('div'); groupRow.setAttribute('style', _style__WEBPACK_IMPORTED_MODULE_12__/* .style */ .i.accessGroupListItem); _widgets__WEBPACK_IMPORTED_MODULE_7__/* .makeDropTarget */ .DK(groupRow, function (uris) { return _this2.handleDroppedUris(uris, combo).then(function () { return _this2.controller.render(); })["catch"](function (error) { return _this2.controller.renderStatus(error); }); }); var groupColumns = this.renderGroupElements(comboIndex, combo); groupColumns.forEach(function (column) { return groupRow.appendChild(column); }); return groupRow; } }, { key: "renderGroupElements", value: function renderGroupElements(comboIndex, combo) { var _this3 = this; var groupNameColumn = this.controller.dom.createElement('div'); groupNameColumn.setAttribute('style', _style__WEBPACK_IMPORTED_MODULE_12__/* .style */ .i.group); if (this.controller.isEditable) { switch (comboIndex) { case 1: groupNameColumn.setAttribute('style', _style__WEBPACK_IMPORTED_MODULE_12__/* .style */ .i.group1); break; case 2: groupNameColumn.setAttribute('style', _style__WEBPACK_IMPORTED_MODULE_12__/* .style */ .i.group2); break; case 3: groupNameColumn.setAttribute('style', _style__WEBPACK_IMPORTED_MODULE_12__/* .style */ .i.group3); break; case 5: groupNameColumn.setAttribute('style', _style__WEBPACK_IMPORTED_MODULE_12__/* .style */ .i.group5); break; case 9: groupNameColumn.setAttribute('style', _style__WEBPACK_IMPORTED_MODULE_12__/* .style */ .i.group9); break; case 13: groupNameColumn.setAttribute('style', _style__WEBPACK_IMPORTED_MODULE_12__/* .style */ .i.group13); break; default: groupNameColumn.setAttribute('style', _style__WEBPACK_IMPORTED_MODULE_12__/* .style */ .i.group); } } groupNameColumn.innerText = COLLOQUIAL[comboIndex] || ktToList(comboIndex); var groupAgentsColumn = this.controller.dom.createElement('div'); groupAgentsColumn.setAttribute('style', _style__WEBPACK_IMPORTED_MODULE_12__/* .style */ .i.group); if (this.controller.isEditable) { switch (comboIndex) { case 1: groupAgentsColumn.setAttribute('style', _style__WEBPACK_IMPORTED_MODULE_12__/* .style */ .i.group1); break; case 2: groupAgentsColumn.setAttribute('style', _style__WEBPACK_IMPORTED_MODULE_12__/* .style */ .i.group2); break; case 3: groupAgentsColumn.setAttribute('style', _style__WEBPACK_IMPORTED_MODULE_12__/* .style */ .i.group3); break; case 5: groupAgentsColumn.setAttribute('style', _style__WEBPACK_IMPORTED_MODULE_12__/* .style */ .i.group5); break; case 9: groupAgentsColumn.setAttribute('style', _style__WEBPACK_IMPORTED_MODULE_12__/* .style */ .i.group9); break; case 13: groupAgentsColumn.setAttribute('style', _style__WEBPACK_IMPORTED_MODULE_12__/* .style */ .i.group13); break; default: groupAgentsColumn.setAttribute('style', _style__WEBPACK_IMPORTED_MODULE_12__/* .style */ .i.group); } } var groupAgentsTable = groupAgentsColumn.appendChild(this.controller.dom.createElement('table')); var combos = this.byCombo[combo] || []; combos.map(function (_ref) { var _ref2 = (0,_babel_runtime_helpers_slicedToArray__WEBPACK_IMPORTED_MODULE_1__/* ["default"] */ .A)(_ref, 2), pred = _ref2[0], obj = _ref2[1]; return _this3.renderAgent(groupAgentsTable, combo, pred, obj); }).forEach(function (agentElement) { return groupAgentsTable.appendChild(agentElement); }); var groupDescriptionElement = this.controller.dom.createElement('div'); groupDescriptionElement.setAttribute('style', _style__WEBPACK_IMPORTED_MODULE_12__/* .style */ .i.group); if (this.controller.isEditable) { switch (comboIndex) { case 1: groupDescriptionElement.setAttribute('style', _style__WEBPACK_IMPORTED_MODULE_12__/* .style */ .i.group1); break; case 2: groupDescriptionElement.setAttribute('style', _style__WEBPACK_IMPORTED_MODULE_12__/* .style */ .i.group2); break; case 3: groupDescriptionElement.setAttribute('style', _style__WEBPACK_IMPORTED_MODULE_12__/* .style */ .i.group3); break; case 5: groupDescriptionElement.setAttribute('style', _style__WEBPACK_IMPORTED_MODULE_12__/* .style */ .i.group5); break; case 9: groupDescriptionElement.setAttribute('style', _style__WEBPACK_IMPORTED_MODULE_12__/* .style */ .i.group9); break; case 13: groupDescriptionElement.setAttribute('style', _style__WEBPACK_IMPORTED_MODULE_12__/* .style */ .i.group13); break; default: groupDescriptionElement.setAttribute('style', _style__WEBPACK_IMPORTED_MODULE_12__/* .style */ .i.group); } } groupDescriptionElement.innerText = EXPLANATION[comboIndex] || 'Unusual combination'; return [groupNameColumn, groupAgentsColumn, groupDescriptionElement]; } }, { key: "renderAgent", value: function renderAgent(groupAgentsTable, combo, pred, obj) { var _this4 = this; var personRow = _widgets__WEBPACK_IMPORTED_MODULE_8__/* .personTR */ .Cl(this.controller.dom, ACL(pred), (0,rdflib__WEBPACK_IMPORTED_MODULE_5__.sym)(obj), this.controller.isEditable ? { deleteFunction: function deleteFunction() { return _this4.deleteAgent(combo, pred, obj).then(function () { return groupAgentsTable.removeChild(personRow); })["catch"](function (error) { return _this4.controller.renderStatus(error); }); } } : {}); return personRow; } }, { key: "deleteAgent", value: function () { var _deleteAgent = (0,_babel_runtime_helpers_asyncToGenerator__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */ .A)(/*#__PURE__*/_babel_runtime_regenerator__WEBPACK_IMPORTED_MODULE_4___default().mark(function _callee(combo, pred, obj) { var combos, comboToRemove; return _babel_runtime_regenerator__WEBPACK_IMPORTED_MODULE_4___default().wrap(function (_context) { while (1) switch (_context.prev = _context.next) { case 0: combos = this.byCombo[combo] || []; comboToRemove = combos.find(function (_ref3) { var _ref4 = (0,_babel_runtime_helpers_slicedToArray__WEBPACK_IMPORTED_MODULE_1__/* ["default"] */ .A)(_ref3, 2), comboPred = _ref4[0], comboObj = _ref4[1]; return comboPred === pred && comboObj === obj; }); if (comboToRemove) { combos.splice(combos.indexOf(comboToRemove), 1); } _context.next = 1; return this.controller.save(); case 1: case "end": return _context.stop(); } }, _callee, this); })); function deleteAgent(_x, _x2, _x3) { return _deleteAgent.apply(this, arguments); } return deleteAgent; }() }, { key: "addNewURI", value: function () { var _addNewURI = (0,_babel_runtime_helpers_asyncToGenerator__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */ .A)(/*#__PURE__*/_babel_runtime_regenerator__WEBPACK_IMPORTED_MODULE_4___default().mark(function _callee2(uri) { return _babel_runtime_regenerator__WEBPACK_IMPORTED_MODULE_4___default().wrap(function (_context2) { while (1) switch (_context2.prev = _context2.next) { case 0: _context2.next = 1; return this.handleDroppedUri(uri, kToCombo(1)); case 1: _context2.next = 2; return this.controller.save(); case 2: case "end": return _context2.stop(); } }, _callee2, this); })); function addNewURI(_x4) { return _addNewURI.apply(this, arguments); } return addNewURI; }() }, { key: "handleDroppedUris", value: function () { var _handleDroppedUris = (0,_babel_runtime_helpers_asyncToGenerator__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */ .A)(/*#__PURE__*/_babel_runtime_regenerator__WEBPACK_IMPORTED_MODULE_4___default().mark(function _callee3(uris, combo) { var _this5 = this; var _t; return _babel_runtime_regenerator__WEBPACK_IMPORTED_MODULE_4___default().wrap(function (_context3) { while (1) switch (_context3.prev = _context3.next) { case 0: _context3.prev = 0; _context3.next = 1; return Promise.all(uris.map(function (uri) { return _this5.handleDroppedUri(uri, combo); })); case 1: _context3.next = 2; return this.controller.save(); case 2: _context3.next = 4; break; case 3: _context3.prev = 3; _t = _context3["catch"](0); return _context3.abrupt("return", Promise.reject(_t)); case 4: case "end": return _context3.stop(); } }, _callee3, this, [[0, 3]]); })); function handleDroppedUris(_x5, _x6) { return _handleDroppedUris.apply(this, arguments); } return handleDroppedUris; }() }, { key: "handleDroppedUri", value: function () { var _handleDroppedUri = (0,_babel_runtime_helpers_asyncToGenerator__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */ .A)(/*#__PURE__*/_babel_runtime_regenerator__WEBPACK_IMPORTED_MODULE_4___default().mark(function _callee4(uri, combo) { var secondAttempt, agent, thing, _this$_store, message, error, _args4 = arguments, _t2; return _babel_runtime_regenerator__WEBPACK_IMPORTED_MODULE_4___default().wrap(function (_context4) { while (1) switch (_context4.prev = _context4.next) { case 0: secondAttempt = _args4.length > 2 && _args4[2] !== undefined ? _args4[2] : false; agent = findAgent(uri, this.store); // eg 'agent', 'origin', agentClass' thing = (0,rdflib__WEBPACK_IMPORTED_MODULE_5__.sym)(uri); if (!(!agent && !secondAttempt)) { _context4.next = 5; break; } _debug__WEBPACK_IMPORTED_MODULE_11__/* .log */ .Rm(" Not obvious: looking up dropped thing ".concat(thing)); _context4.prev = 1; _context4.next = 2; return (_this$_store = this._store) === null || _this$_store === void 0 || (_this$_store = _this$_store.fetcher) === null || _this$_store === void 0 ? void 0 : _this$_store.load(thing.doc()); case 2: _context4.next = 4; break; case 3: _context4.prev = 3; _t2 = _context4["catch"](1); message = "Ignore error looking up dropped thing: ".concat(_t2); _debug__WEBPACK_IMPORTED_MODULE_11__/* .error */ .z3(message); return _context4.abrupt("return", Promise.reject(new Error(message))); case 4: return _context4.abrupt("return", this.handleDroppedUri(uri, combo, true)); case 5: if (agent) { _context4.next = 6; break; } error = " Error: Drop fails to drop appropriate thing! ".concat(uri); _debug__WEBPACK_IMPORTED_MODULE_11__/* .error */ .z3(error); return _context4.abrupt("return", Promise.reject(new Error(error))); case 6: this.setACLCombo(combo, uri, agent, this.controller.subject); case 7: case "end": return _context4.stop(); } }, _callee4, this, [[1, 3]]); })); function handleDroppedUri(_x7, _x8) { return _handleDroppedUri.apply(this, arguments); } return handleDroppedUri; }() }, { key: "setACLCombo", value: function setACLCombo(combo, uri, res, subject) { if (!(combo in this.byCombo)) { this.byCombo[combo] = []; } this.removeAgentFromCombos(uri); // Combos are mutually distinct this.byCombo[combo].push([res.pred, res.obj.uri]); _debug__WEBPACK_IMPORTED_MODULE_11__/* .log */ .Rm("ACL: setting access to ".concat(subject, " by ").concat(res.pred, ": ").concat(res.obj)); } }, { key: "removeAgentFromCombos", value: function removeAgentFromCombos(uri) { for (var k = 0; k < 16; k++) { var combos = this.byCombo[kToCombo(k)]; if (combos) { for (var i = 0; i < combos.length; i++) { while (i < combos.length && combos[i][1] === uri) { combos.splice(i, 1); } } } } } }]); }(); function kToCombo(k) { var y = ['Read', 'Append', 'Write', 'Control']; var combo = []; for (var i = 0; i < 4; i++) { if (k & 1 << i) { combo.push('http://www.w3.org/ns/auth/acl#' + y[i]); } } combo.sort(); return combo.join('\n'); } function ktToList(k) { var list = ''; var y = ['Read', 'Append', 'Write', 'Control']; for (var i = 0; i < 4; i++) { if (k & 1 << i) { list += y[i]; } } return list; } function findAgent(uri, kb) { var obj = (0,rdflib__WEBPACK_IMPORTED_MODULE_5__.sym)(uri); var types = kb.findTypeURIs(obj); for (var ty in types) { _debug__WEBPACK_IMPORTED_MODULE_11__/* .log */ .Rm(' drop object type includes: ' + ty); } // An Origin URI is one like https://fred.github.io eith no trailing slash if (uri.startsWith('http') && uri.split('/').length === 3) { // there is no third slash return { pred: 'origin', obj: obj }; // The only way to know an origin alas } // @@ This is an almighty kludge needed because drag and drop adds extra slashes to origins if (uri.startsWith('http') && uri.split('/').length === 4 && uri.endsWith('/')) { // there IS third slash _debug__WEBPACK_IMPORTED_MODULE_11__/* .log */ .Rm('Assuming final slash on dragged origin URI was unintended!'); return { pred: 'origin', obj: (0,rdflib__WEBPACK_IMPORTED_MODULE_5__.sym)(uri.slice(0, -1)) }; // Fix a URI where the drag and drop system has added a spurious slash } if (_ns__WEBPACK_IMPORTED_MODULE_9__/* ["default"] */ .A.vcard('WebID').uri in types) return { pred: 'agent', obj: obj }; if (_ns__WEBPACK_IMPORTED_MODULE_9__/* ["default"] */ .A.vcard('Group').uri in types) { return { pred: 'agentGroup', obj: obj }; // @@ note vcard membership not RDFs } if (obj.sameTerm(_ns__WEBPACK_IMPORTED_MODULE_9__/* ["default"] */ .A.foaf('Agent')) || obj.sameTerm(_ns__WEBPACK_IMPORTED_MODULE_9__/* ["default"] */ .A.acl('AuthenticatedAgent')) || // AuthenticatedAgent obj.sameTerm(_ns__WEBPACK_IMPORTED_MODULE_9__/* ["default"] */ .A.rdf('Resource')) || obj.sameTerm(_ns__WEBPACK_IMPORTED_MODULE_9__/* ["default"] */ .A.owl('Thing'))) { return { pred: 'agentClass', obj: obj }; } if (_ns__WEBPACK_IMPORTED_MODULE_9__/* ["default"] */ .A.vcard('Individual').uri in types || _ns__WEBPACK_IMPORTED_MODULE_9__/* ["default"] */ .A.foaf('Person').uri in types || _ns__WEBPACK_IMPORTED_MODULE_9__/* ["default"] */ .A.foaf('Agent').uri in types) { var pref = kb.any(obj, _ns__WEBPACK_IMPORTED_MODULE_9__/* ["default"] */ .A.foaf('preferredURI')); if (pref) return { pred: 'agent', obj: (0,rdflib__WEBPACK_IMPORTED_MODULE_5__.sym)(pref) }; return { pred: 'agent', obj: obj }; } if (_ns__WEBPACK_IMPORTED_MODULE_9__/* ["default"] */ .A.solid('AppProvider').uri in types) { return { pred: 'origin', obj: obj }; } if (_ns__WEBPACK_IMPORTED_MODULE_9__/* ["default"] */ .A.solid('AppProviderClass').uri in types) { return { pred: 'originClass', obj: obj }; } _debug__WEBPACK_IMPORTED_MODULE_11__/* .log */ .Rm(' Triage fails for ' + uri); return null; } /***/ }, /***/ 1454 (__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) { /* harmony export */ __webpack_require__.d(__webpack_exports__, { /* harmony export */ w: () => (/* binding */ hmac) /* harmony export */ }); /* unused harmony export HMAC */ /* harmony import */ var _utils_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(4976); /** * HMAC: RFC2104 message authentication code. * @module */ class HMAC extends _utils_js__WEBPACK_IMPORTED_MODULE_0__/* .Hash */ .Vw { constructor(hash, _key) { super(); this.finished = false; this.destroyed = false; (0,_utils_js__WEBPACK_IMPORTED_MODULE_0__/* .ahash */ .sd)(hash); const key = (0,_utils_js__WEBPACK_IMPORTED_MODULE_0__/* .toBytes */ .ZJ)(_key); this.iHash = hash.create(); if (typeof this.iHash.update !== 'function') throw new Error('Expected instance of class which extends utils.Hash'); this.blockLen = this.iHash.blockLen; this.outputLen = this.iHash.outputLen; const blockLen = this.blockLen; const pad = new Uint8Array(blockLen); // blockLen can be bigger than outputLen pad.set(key.length > blockLen ? hash.create().update(key).digest() : key); for (let i = 0; i < pad.length; i++) pad[i] ^= 0x36; this.iHash.update(pad); // By doing update (processing of first block) of outer hash here we can re-use it between multiple calls via clone this.oHash = hash.create(); // Undo internal XOR && apply outer XOR for (let i = 0; i < pad.length; i++) pad[i] ^= 0x36 ^ 0x5c; this.oHash.update(pad); (0,_utils_js__WEBPACK_IMPORTED_MODULE_0__/* .clean */ .uH)(pad); } update(buf) { (0,_utils_js__WEBPACK_IMPORTED_MODULE_0__/* .aexists */ .CC)(this); this.iHash.update(buf); return this; } digestInto(out) { (0,_utils_js__WEBPACK_IMPORTED_MODULE_0__/* .aexists */ .CC)(this); (0,_utils_js__WEBPACK_IMPORTED_MODULE_0__/* .abytes */ .DO)(out, this.outputLen); this.finished = true; this.iHash.digestInto(out); this.oHash.update(out); this.oHash.digestInto(out); this.destroy(); } digest() { const out = new Uint8Array(this.oHash.outputLen); this.digestInto(out); return out; } _cloneInto(to) { // Create new instance without calling constructor since key already in state and we don't know it. to || (to = Object.create(Object.getPrototypeOf(this), {})); const { oHash, iHash, finished, destroyed, blockLen, outputLen } = this; to = to; to.finished = finished; to.destroyed = destroyed; to.blockLen = blockLen; to.outputLen = outputLen; to.oHash = oHash._cloneInto(to.oHash); to.iHash = iHash._cloneInto(to.iHash); return to; } clone() { return this._cloneInto(); } destroy() { this.destroyed = true; this.oHash.destroy(); this.iHash.destroy(); } } /** * HMAC: RFC2104 message authentication code. * @param hash - function that would be used e.g. sha256 * @param key - message key * @param message - message data * @example * import { hmac } from '@noble/hashes/hmac'; * import { sha256 } from '@noble/hashes/sha2'; * const mac1 = hmac(sha256, 'key', 'message'); */ const hmac = (hash, key, message) => new HMAC(hash, key).update(message).digest(); hmac.create = (hash, key) => new HMAC(hash, key); //# sourceMappingURL=hmac.js.map /***/ }, /***/ 1648 (__unused_webpack_module, __webpack_exports__, __webpack_require__) { /* harmony export */ __webpack_require__.d(__webpack_exports__, { /* harmony export */ Of: () => (/* binding */ initHeader) /* harmony export */ }); /* unused harmony exports rebuildHeader, createBanner, createHelpMenu, createLoginSignUpButtons, createUserMenuButton, createUserMenuLink, createUserMenu, createUserMenuItem, getProfileImg */ /* harmony import */ var _babel_runtime_helpers_asyncToGenerator__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(467); /* harmony import */ var _babel_runtime_regenerator__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(4756); /* harmony import */ var _babel_runtime_regenerator__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(_babel_runtime_regenerator__WEBPACK_IMPORTED_MODULE_1__); /* harmony import */ var _index__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(3378); /* harmony import */ var solid_logic_jss__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(5175); /* harmony import */ var _login_login__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(967); /* harmony import */ var _widgets__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(3291); /* harmony import */ var _style__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(675); /* harmony import */ var _empty_profile__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(2825); /* harmony import */ var _utils_headerFooterHelpers__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(8565); /* global EventListenerOrEventListenerObject */ /* This file was copied from mashlib/src/global/header.ts file. It is modified to work in solid-ui by adjusting where imported functions are found. */ // import { loginStatusBox, authSession, currentUser } from '../authn/authn' /** * menu icons */ var DEFAULT_HELP_MENU_ICON = _index__WEBPACK_IMPORTED_MODULE_2__/* .icons */ .Pt.iconBase + 'noun_help.svg'; var DEFAUL_SOLID_ICON_URL = 'https://solidproject.org/assets/img/solid-emblem.svg'; /* HeaderOptions allow for customizing the logo and menu list. If a logo is not provided the default is solid. Menulist will always show a link to logout and to the users profile. */ /** * Initialize header component, the header object returned depends on whether the user is authenticated. * @param store the data store * @param userMenuList a list of menu items when the user is logged in * @param options allow the header to be customized with a personalized logo, help icon and a help menu list of links or buttons. * @returns a header for an authenticated user with menu items given or a login screen */ function initHeader(_x, _x2, _x3) { return _initHeader.apply(this, arguments); } /** * @ignore exporting this only for the unit test */ function _initHeader() { _initHeader = (0,_babel_runtime_helpers_asyncToGenerator__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */ .A)(/*#__PURE__*/_babel_runtime_regenerator__WEBPACK_IMPORTED_MODULE_1___default().mark(function _callee2(store, userMenuList, options) { var header, pod; return _babel_runtime_regenerator__WEBPACK_IMPORTED_MODULE_1___default().wrap(function (_context2) { while (1) switch (_context2.prev = _context2.next) { case 0: header = document.getElementById('PageHeader'); if (header) { _context2.next = 1; break; } return _context2.abrupt("return"); case 1: pod = (0,_utils_headerFooterHelpers__WEBPACK_IMPORTED_MODULE_8__/* .getPod */ .E6)(); rebuildHeader(header, store, pod, userMenuList, options)(); solid_logic_jss__WEBPACK_IMPORTED_MODULE_3__/* .authSession */ .lG.events.on('logout', rebuildHeader(header, store, pod, userMenuList, options)); solid_logic_jss__WEBPACK_IMPORTED_MODULE_3__/* .authSession */ .lG.events.on('login', rebuildHeader(header, store, pod, userMenuList, options)); case 2: case "end": return _context2.stop(); } }, _callee2); })); return _initHeader.apply(this, arguments); } function rebuildHeader(header, store, pod, userMenuList, options) { return /*#__PURE__*/(0,_babel_runtime_helpers_asyncToGenerator__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */ .A)(/*#__PURE__*/_babel_runtime_regenerator__WEBPACK_IMPORTED_MODULE_1___default().mark(function _callee() { var user, _t; return _babel_runtime_regenerator__WEBPACK_IMPORTED_MODULE_1___default().wrap(function (_context) { while (1) switch (_context.prev = _context.next) { case 0: user = solid_logic_jss__WEBPACK_IMPORTED_MODULE_3__/* .authn */ .jO.currentUser(); header.innerHTML = ''; _t = header; _context.next = 1; return createBanner(store, pod, user, userMenuList, options); case 1: _t.appendChild.call(_t, _context.sent); case 2: case "end": return _context.stop(); } }, _callee); })); } /** * @ignore exporting this only for the unit test */ function createBanner(_x4, _x5, _x6, _x7, _x8) { return _createBanner.apply(this, arguments); } /** * @ignore exporting this only for the unit test */ function _createBanner() { _createBanner = (0,_babel_runtime_helpers_asyncToGenerator__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */ .A)(/*#__PURE__*/_babel_runtime_regenerator__WEBPACK_IMPORTED_MODULE_1___default().mark(function _callee3(store, pod, user, userMenuList, options) { var podLink, image, userMenu, banner, leftSideOfHeader, helpMenu, _t2; return _babel_runtime_regenerator__WEBPACK_IMPORTED_MODULE_1___default().wrap(function (_context3) { while (1) switch (_context3.prev = _context3.next) { case 0: podLink = document.createElement('a'); podLink.href = pod.uri; podLink.setAttribute('style', _style__WEBPACK_IMPORTED_MODULE_6__/* .style */ .i.headerBannerLink); image = document.createElement('img'); if (options) { image.src = options.logo ? options.logo : DEFAUL_SOLID_ICON_URL; } image.setAttribute('style', _style__WEBPACK_IMPORTED_MODULE_6__/* .style */ .i.headerBannerIcon); podLink.appendChild(image); if (!user) { _context3.next = 2; break; } _context3.next = 1; return createUserMenu(store, user, userMenuList); case 1: _t2 = _context3.sent; _context3.next = 3; break; case 2: _t2 = createLoginSignUpButtons(); case 3: userMenu = _t2; banner = document.createElement('div'); banner.setAttribute('style', _style__WEBPACK_IMPORTED_MODULE_6__/* .style */ .i.headerBanner); banner.appendChild(podLink); leftSideOfHeader = document.createElement('div'); leftSideOfHeader.setAttribute('style', _style__WEBPACK_IMPORTED_MODULE_6__/* .style */ .i.headerBannerRightMenu); leftSideOfHeader.appendChild(userMenu); if (options && options.helpMenuList) { helpMenu = createHelpMenu(options, options.helpMenuList); leftSideOfHeader.appendChild(helpMenu); } banner.appendChild(leftSideOfHeader); return _context3.abrupt("return", banner); case 4: case "end": return _context3.stop(); } }, _callee3); })); return _createBanner.apply(this, arguments); } function createHelpMenu(options, helpMenuItems) { if (!helpMenuItems) return; var helpMenuList = document.createElement('ul'); helpMenuList.setAttribute('style', _style__WEBPACK_IMPORTED_MODULE_6__/* .style */ .i.headerUserMenuList); helpMenuItems.forEach(function (menuItem) { var menuItemType = menuItem.url ? 'url' : 'onclick'; if (menuItemType === 'url') { helpMenuList.appendChild(createUserMenuItem(createUserMenuLink(menuItem.label, menuItem.url, menuItem.target))); } else { helpMenuList.appendChild(createUserMenuItem(createUserMenuButton(menuItem.label, menuItem.onclick))); } }); var helpMenu = document.createElement('nav'); helpMenu.setAttribute('style', _style__WEBPACK_IMPORTED_MODULE_6__/* .style */ .i.headerUserMenuNavigationMenuNotDisplayed); helpMenu.setAttribute('aria-hidden', 'true'); helpMenu.setAttribute('id', 'helperNav'); helpMenu.appendChild(helpMenuList); var helpMenuContainer = document.createElement('div'); helpMenuContainer.setAttribute('style', _style__WEBPACK_IMPORTED_MODULE_6__/* .style */ .i.headerBannerUserMenu); helpMenuContainer.appendChild(helpMenu); var helpMenuTrigger = document.createElement('button'); helpMenuTrigger.setAttribute('style', _style__WEBPACK_IMPORTED_MODULE_6__/* .style */ .i.headerUserMenuTrigger); helpMenuTrigger.type = 'button'; var helpMenuIcon = document.createElement('img'); helpMenuIcon.src = options && options.helpIcon ? options.helpIcon : _index__WEBPACK_IMPORTED_MODULE_2__/* .icons */ .Pt.iconBase + DEFAULT_HELP_MENU_ICON; helpMenuIcon.setAttribute('style', _style__WEBPACK_IMPORTED_MODULE_6__/* .style */ .i.headerUserMenuTriggerImg); helpMenuContainer.appendChild(helpMenuTrigger); helpMenuTrigger.appendChild(helpMenuIcon); var throttledMenuToggle = (0,_utils_headerFooterHelpers__WEBPACK_IMPORTED_MODULE_8__/* .throttle */ .nF)(function (event) { return toggleMenu(event, helpMenuTrigger, helpMenu); }, 50); helpMenuTrigger.addEventListener('click', throttledMenuToggle); var timer = setTimeout(function () { return null; }, 0); helpMenuContainer.addEventListener('mouseover', function (event) { clearTimeout(timer); throttledMenuToggle(event); var nav = document.getElementById('helperNav'); nav === null || nav === void 0 || nav.setAttribute('style', _style__WEBPACK_IMPORTED_MODULE_6__/* .style */ .i.headerUserMenuNavigationMenu); }); helpMenuContainer.addEventListener('mouseout', function (event) { timer = setTimeout(function () { return throttledMenuToggle(event); }, 200); var nav = document.getElementById('helperNav'); nav === null || nav === void 0 || nav.setAttribute('style', _style__WEBPACK_IMPORTED_MODULE_6__/* .style */ .i.headerUserMenuNavigationMenuNotDisplayed); }); return helpMenuContainer; } /** * @ignore exporting this only for the unit test */ function createLoginSignUpButtons() { var profileLoginButtonPre = document.createElement('div'); profileLoginButtonPre.setAttribute('style', _style__WEBPACK_IMPORTED_MODULE_6__/* .style */ .i.headerBannerLogin); profileLoginButtonPre.appendChild((0,_login_login__WEBPACK_IMPORTED_MODULE_4__.loginStatusBox)(document, null, {})); return profileLoginButtonPre; } /** * @ignore exporting this only for the unit test */ function createUserMenuButton(label, onClick) { var button = document.createElement('button'); button.setAttribute('style', _style__WEBPACK_IMPORTED_MODULE_6__/* .style */ .i.headerUserMenuButton); button.onmouseover = function () { button.setAttribute('style', _style__WEBPACK_IMPORTED_MODULE_6__/* .style */ .i.headerUserMenuButtonHover); }; button.onmouseout = function () { button.setAttribute('style', _style__WEBPACK_IMPORTED_MODULE_6__/* .style */ .i.headerUserMenuButton); }; button.addEventListener('click', onClick); button.innerText = label; return button; } /** * @ignore exporting this only for the unit test */ function createUserMenuLink(label, href, target) { var link = document.createElement('a'); link.setAttribute('style', _style__WEBPACK_IMPORTED_MODULE_6__/* .style */ .i.headerUserMenuLink); link.onmouseover = function () { link.setAttribute('style', _style__WEBPACK_IMPORTED_MODULE_6__/* .style */ .i.headerUserMenuLinkHover); }; link.onmouseout = function () { link.setAttribute('style', _style__WEBPACK_IMPORTED_MODULE_6__/* .style */ .i.headerUserMenuLink); }; link.href = href; link.innerText = label; if (target) link.target = target; return link; } /** * @ignore exporting this only for the unit test */ function createUserMenu(_x9, _x0, _x1) { return _createUserMenu.apply(this, arguments); } /** * @ignore exporting this only for the unit test */ function _createUserMenu() { _createUserMenu = (0,_babel_runtime_helpers_asyncToGenerator__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */ .A)(/*#__PURE__*/_babel_runtime_regenerator__WEBPACK_IMPORTED_MODULE_1___default().mark(function _callee4(store, user, userMenuList) { var fetcher, loggedInMenuList, loggedInMenu, loggedInMenuTrigger, profileImg, loggedInMenuContainer, throttledMenuToggle, timer; return _babel_runtime_regenerator__WEBPACK_IMPORTED_MODULE_1___default().wrap(function (_context4) { while (1) switch (_context4.prev = _context4.next) { case 0: fetcher = store.fetcher; if (!fetcher) { _context4.next = 1; break; } _context4.next = 1; return fetcher.load(user); case 1: loggedInMenuList = document.createElement('ul'); loggedInMenuList.setAttribute('style', _style__WEBPACK_IMPORTED_MODULE_6__/* .style */ .i.headerUserMenuList); if (userMenuList) { userMenuList.forEach(function (menuItem) { var menuItemType = menuItem.url ? 'url' : 'onclick'; if (menuItemType === 'url') { loggedInMenuList.appendChild(createUserMenuItem(createUserMenuLink(menuItem.label, menuItem.url, menuItem.target))); } else { loggedInMenuList.appendChild(createUserMenuItem(createUserMenuButton(menuItem.label, menuItem.onclick))); } }); } loggedInMenu = document.createElement('nav'); loggedInMenu.setAttribute('style', _style__WEBPACK_IMPORTED_MODULE_6__/* .style */ .i.headerUserMenuNavigationMenuNotDisplayed); loggedInMenu.setAttribute('aria-hidden', 'true'); loggedInMenu.setAttribute('id', 'loggedInNav'); loggedInMenu.appendChild(loggedInMenuList); loggedInMenuTrigger = document.createElement('button'); loggedInMenuTrigger.setAttribute('style', _style__WEBPACK_IMPORTED_MODULE_6__/* .style */ .i.headerUserMenuTrigger); loggedInMenuTrigger.type = 'button'; profileImg = getProfileImg(store, user); if (typeof profileImg === 'string') { loggedInMenuTrigger.innerHTML = profileImg; } else { loggedInMenuTrigger.appendChild(profileImg); } loggedInMenuContainer = document.createElement('div'); loggedInMenuContainer.setAttribute('style', _style__WEBPACK_IMPORTED_MODULE_6__/* .style */ .i.headerBannerUserMenuNotDisplayed); loggedInMenuContainer.appendChild(loggedInMenuTrigger); loggedInMenuContainer.appendChild(loggedInMenu); throttledMenuToggle = (0,_utils_headerFooterHelpers__WEBPACK_IMPORTED_MODULE_8__/* .throttle */ .nF)(function (event) { return toggleMenu(event, loggedInMenuTrigger, loggedInMenu); }, 50); loggedInMenuTrigger.addEventListener('click', throttledMenuToggle); timer = setTimeout(function () { return null; }, 0); loggedInMenuContainer.addEventListener('mouseover', function (event) { clearTimeout(timer); throttledMenuToggle(event); var nav = document.getElementById('loggedInNav'); nav === null || nav === void 0 || nav.setAttribute('style', _style__WEBPACK_IMPORTED_MODULE_6__/* .style */ .i.headerUserMenuNavigationMenu); }); loggedInMenuContainer.addEventListener('mouseout', function (event) { timer = setTimeout(function () { return throttledMenuToggle(event); }, 200); var nav = document.getElementById('loggedInNav'); nav === null || nav === void 0 || nav.setAttribute('style', _style__WEBPACK_IMPORTED_MODULE_6__/* .style */ .i.headerUserMenuNavigationMenuNotDisplayed); }); return _context4.abrupt("return", loggedInMenuContainer); case 2: case "end": return _context4.stop(); } }, _callee4); })); return _createUserMenu.apply(this, arguments); } function createUserMenuItem(child) { var menuProfileItem = document.createElement('li'); menuProfileItem.setAttribute('style', _style__WEBPACK_IMPORTED_MODULE_6__/* .style */ .i.headerUserMenuListItem); menuProfileItem.appendChild(child); return menuProfileItem; } /** * @ignore exporting this only for the unit test */ function getProfileImg(store, user) { var profileUrl = null; try { profileUrl = _widgets__WEBPACK_IMPORTED_MODULE_5__/* .findImage */ .F1(user); if (!profileUrl) { return _empty_profile__WEBPACK_IMPORTED_MODULE_7__/* .emptyProfile */ .j; } } catch (_unused) { return _empty_profile__WEBPACK_IMPORTED_MODULE_7__/* .emptyProfile */ .j; } var profileImage = document.createElement('div'); profileImage.setAttribute('style', _style__WEBPACK_IMPORTED_MODULE_6__/* .style */ .i.headerUserMenuPhoto); profileImage.style.backgroundImage = "url(".concat(profileUrl, ")"); return profileImage; } /** * @internal */ function toggleMenu(event, trigger, menu) { var isExpanded = trigger.getAttribute('aria-expanded') === 'true'; var expand = event.type === 'mouseover'; var close = event.type === 'mouseout'; if (isExpanded && expand || !isExpanded && close) { return; } trigger.setAttribute('aria-expanded', (!isExpanded).toString()); menu.setAttribute('aria-hidden', isExpanded.toString()); } /***/ }, /***/ 1763 (__unused_webpack_module, __webpack_exports__, __webpack_require__) { /* harmony export */ __webpack_require__.d(__webpack_exports__, { /* harmony export */ Dk: () => (/* binding */ formsFor), /* harmony export */ K: () => (/* reexport safe */ _forms_fieldFunction__WEBPACK_IMPORTED_MODULE_4__.K), /* harmony export */ L1: () => (/* binding */ makeSelectForNestedCategory), /* harmony export */ LC: () => (/* binding */ makeSelectForClassifierOptions), /* harmony export */ LX: () => (/* binding */ makeSelectForChoice), /* harmony export */ Nr: () => (/* reexport safe */ _forms_basic__WEBPACK_IMPORTED_MODULE_8__.Nr), /* harmony export */ Nt: () => (/* binding */ editFormButton), /* harmony export */ PM: () => (/* reexport safe */ _forms_basic__WEBPACK_IMPORTED_MODULE_8__.PM), /* harmony export */ Ru: () => (/* binding */ findClosest), /* harmony export */ WG: () => (/* reexport safe */ _forms_basic__WEBPACK_IMPORTED_MODULE_8__.WG), /* harmony export */ WY: () => (/* binding */ buildCheckboxForm), /* harmony export */ ZA: () => (/* binding */ propertiesForClass), /* harmony export */ ZZ: () => (/* reexport safe */ _forms_fieldFunction__WEBPACK_IMPORTED_MODULE_4__.ZZ), /* harmony export */ bk: () => (/* reexport safe */ _forms_basic__WEBPACK_IMPORTED_MODULE_8__.bk), /* harmony export */ e2: () => (/* binding */ promptForNew), /* harmony export */ eR: () => (/* binding */ makeDescription), /* harmony export */ eb: () => (/* binding */ sortByLabel), /* harmony export */ f6: () => (/* binding */ appendForm), /* harmony export */ iU: () => (/* binding */ makeSelectForOptions), /* harmony export */ rg: () => (/* reexport safe */ _forms_fieldFunction__WEBPACK_IMPORTED_MODULE_4__.rg), /* harmony export */ s2: () => (/* binding */ makeSelectForCategory), /* harmony export */ tE: () => (/* binding */ sortBySequence), /* harmony export */ tk: () => (/* reexport safe */ _forms_fieldParams__WEBPACK_IMPORTED_MODULE_3__.t), /* harmony export */ vx: () => (/* binding */ newButton), /* harmony export */ xV: () => (/* binding */ newThing) /* harmony export */ }); /* harmony import */ var _babel_runtime_helpers_asyncToGenerator__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(467); /* harmony import */ var _babel_runtime_regenerator__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(4756); /* harmony import */ var _babel_runtime_regenerator__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(_babel_runtime_regenerator__WEBPACK_IMPORTED_MODULE_1__); /* harmony import */ var _buttons__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(3291); /* harmony import */ var _forms_fieldParams__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(588); /* harmony import */ var _forms_fieldFunction__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(9086); /* harmony import */ var _forms_formStyle__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(7673); /* harmony import */ var _debug__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(7423); /* harmony import */ var _error__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(3468); /* harmony import */ var _forms_basic__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(6564); /* harmony import */ var _forms_autocomplete_autocompleteField__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(8251); /* harmony import */ var _style__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(675); /* harmony import */ var _styleConstants__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(4762); /* harmony import */ var _iconBase__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(3378); /* harmony import */ var _log__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(4158); /* harmony import */ var _ns__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(1795); /* harmony import */ var rdflib__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(4961); /* harmony import */ var solid_logic_jss__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(5175); /* harmony import */ var _utils__WEBPACK_IMPORTED_MODULE_17__ = __webpack_require__(52); /* harmony import */ var _utils__WEBPACK_IMPORTED_MODULE_18__ = __webpack_require__(9612); /* harmony import */ var _multiSelect__WEBPACK_IMPORTED_MODULE_19__ = __webpack_require__(4101); function _createForOfIteratorHelper(r, e) { var t = "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (!t) { if (Array.isArray(r) || (t = _unsupportedIterableToArray(r)) || e && r && "number" == typeof r.length) { t && (r = t); var _n = 0, F = function F() {}; return { s: F, n: function n() { return _n >= r.length ? { done: !0 } : { done: !1, value: r[_n++] }; }, e: function e(r) { throw r; }, f: F }; } 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 o, a = !0, u = !1; return { s: function s() { t = t.call(r); }, n: function n() { var r = t.next(); return a = r.done, r; }, e: function e(r) { u = !0, o = r; }, f: function f() { try { a || null == t["return"] || t["return"](); } finally { if (u) throw o; } } }; } function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0; } } function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; } /* F O R M S * * A Vanilla Dom implementation of the form language */ /* global alert */ // Note default export var checkMarkCharacter = "\u2713"; var cancelCharacter = "\u2715"; var dashCharacter = '-'; var kb = solid_logic_jss__WEBPACK_IMPORTED_MODULE_16__/* .store */ .M_; _forms_fieldFunction__WEBPACK_IMPORTED_MODULE_4__/* .field */ .ZZ[_ns__WEBPACK_IMPORTED_MODULE_14__/* ["default"] */ .A.ui('AutocompleteField').uri] = _forms_autocomplete_autocompleteField__WEBPACK_IMPORTED_MODULE_9__/* .autocompleteField */ .l; // /////////////////////////////////////////////////////////////////////// /* Form Field implementations ** */ /** Group of different fields ** ** One type of form field is an ordered Group of other fields. ** A Form is actually just the same as a group. ** ** @param {Document} dom The HTML Document object aka Document Object Model ** @param {Element?} container If present, the created widget will be appended to this ** @param {Map} already A hash table of (form, subject) kept to prevent recursive forms looping ** @param {Node} subject The thing about which the form displays/edits data ** @param {Node} form The form or field to be rendered ** @param {Node} dataDoc The web document in which the data is ** @param {function(ok, errorMessage)} callbackFunction Called when data is changed? ** ** @returns {Element} The HTML widget created */ function refreshOpionsSubfieldinGroup(dom, already, subject, dataDoc, callbackFunction, groupDiv, subfields) { var eles = groupDiv.children; for (var j = 0; j < subfields.length; j++) { // This is really messy. var _field = subfields[j]; var t = (0,_forms_fieldFunction__WEBPACK_IMPORTED_MODULE_4__/* .mostSpecificClassURI */ .K)(_field); // Field type if (t === _ns__WEBPACK_IMPORTED_MODULE_14__/* ["default"] */ .A.ui('Options').uri) { var optionsRender = (0,_forms_fieldFunction__WEBPACK_IMPORTED_MODULE_4__/* .fieldFunction */ .rg)(dom, _field); var newOne = optionsRender(dom, null, already, subject, _field, dataDoc, callbackFunction); _debug__WEBPACK_IMPORTED_MODULE_6__/* .log */ .Rm('Refreshing Options field by replacing it.'); // better to support actual refresh groupDiv.insertBefore(newOne, eles[j]); groupDiv.removeChild(eles[j + 1]); // Remove the old one } } } _forms_fieldFunction__WEBPACK_IMPORTED_MODULE_4__/* .field */ .ZZ[_ns__WEBPACK_IMPORTED_MODULE_14__/* ["default"] */ .A.ui('Form').uri] = _forms_fieldFunction__WEBPACK_IMPORTED_MODULE_4__/* .field */ .ZZ[_ns__WEBPACK_IMPORTED_MODULE_14__/* ["default"] */ .A.ui('Group').uri] = function (dom, container, already, subject, form, dataDoc, callbackFunction) { var box = dom.createElement('div'); var ui = _ns__WEBPACK_IMPORTED_MODULE_14__/* ["default"] */ .A.ui; if (container) container.appendChild(box); // Prevent loops if (!form) return; var key = subject.toNT() + '|' + form.toNT(); if (already[key]) { // been there done that box.appendChild(dom.createTextNode('Group: see above ' + key)); // TODO fix dependency cycle to solid-panes by calling outlineManager // const plist = [$rdf.st(subject, ns.owl('sameAs'), subject)] // @@ need prev subject // dom.outlineManager.appendPropertyTRs(box, plist) // dom.appendChild(plist) return box; } var already2 = {}; for (var x in already) already2[x] = 1; already2[key] = 1; var formDoc = form.doc ? form.doc() : null; // @@ if blank no way to know var weight0 = kb.any(form, ui('weight'), null, formDoc); // Say 0-3 var weight = weight0 ? Number(weight0.value) : 1; if (weight > 3 || weight < 0) return box.appendChild((0,_error__WEBPACK_IMPORTED_MODULE_7__/* .errorMessageBlock */ .F)(dom, "Form Group weight ".concat(weight, " should be 0-3"))); box.setAttribute('style', _style__WEBPACK_IMPORTED_MODULE_10__/* .style */ .i.formGroupStyle[weight]); // Indent a group box.style.display = 'flex'; box.style.flexDirection = 'column'; box["class"] = 'form-weight-' + weight; var parts = kb.any(form, ui('parts'), null, formDoc); var subfields; if (parts) { subfields = parts.elements; } else { parts = kb.each(form, ui('part'), null, formDoc); // Warning: unordered subfields = sortBySequence(parts); } if (!parts) { return box.appendChild((0,_error__WEBPACK_IMPORTED_MODULE_7__/* .errorMessageBlock */ .F)(dom, 'No parts to form! ')); } for (var i = 0; i < subfields.length; i++) { var _field2 = subfields[i]; var subFieldFunction = (0,_forms_fieldFunction__WEBPACK_IMPORTED_MODULE_4__/* .fieldFunction */ .rg)(dom, _field2); // var itemChanged = function itemChanged(ok, body) { if (ok && body && body.widget && body.widget === 'select') { refreshOpionsSubfieldinGroup(dom, already, subject, dataDoc, callbackFunction, box, subfields); } callbackFunction(ok, { widget: 'group', change: body }); }; box.appendChild(subFieldFunction(dom, null, already2, subject, _field2, dataDoc, itemChanged)); } return box; }; /** Options field: Select one or more cases ** ** @param {Document} dom The HTML Document object aka Document Object Model ** @param {Element?} container If present, the created widget will be appended to this ** @param {Map} already A hash table of (form, subject) kept to prevent recursive forms looping ** @param {Node} subject The thing about which the form displays/edits data ** @param {Node} form The form or field to be rendered ** @param {Node} dataDoc The web document in which the data is ** @param {function(ok, errorMessage)} callbackFunction Called when data is changed? ** ** @returns {Element} The HTML widget created */ _forms_fieldFunction__WEBPACK_IMPORTED_MODULE_4__/* .field */ .ZZ[_ns__WEBPACK_IMPORTED_MODULE_14__/* ["default"] */ .A.ui('Options').uri] = function (dom, container, already, subject, form, dataDoc, callbackFunction) { var kb = solid_logic_jss__WEBPACK_IMPORTED_MODULE_16__/* .store */ .M_; var box = dom.createElement('div'); var formDoc = form.doc ? form.doc() : null; // @@ if blank no way to know var ui = _ns__WEBPACK_IMPORTED_MODULE_14__/* ["default"] */ .A.ui; if (container) container.appendChild(box); var dependingOn = kb.any(form, ui('dependingOn')); if (!dependingOn) { dependingOn = _ns__WEBPACK_IMPORTED_MODULE_14__/* ["default"] */ .A.rdf('type'); } // @@ default to type (do we want defaults?) var cases = kb.each(form, ui('case'), null, formDoc); if (!cases) { box.appendChild((0,_error__WEBPACK_IMPORTED_MODULE_7__/* .errorMessageBlock */ .F)(dom, 'No cases to Options form. ')); } var values; if (dependingOn.sameTerm(_ns__WEBPACK_IMPORTED_MODULE_14__/* ["default"] */ .A.rdf('type'))) { values = Object.keys(kb.findTypeURIs(subject)).map(function (uri) { return rdflib__WEBPACK_IMPORTED_MODULE_15__.sym(uri); }); // Use RDF-S inference } else { values = kb.each(subject, dependingOn); } for (var i = 0; i < cases.length; i++) { var c = cases[i]; var tests = kb.each(c, ui('for'), null, formDoc); // There can be multiple 'for' var match = false; for (var j = 0; j < tests.length; j++) { var _iterator = _createForOfIteratorHelper(values), _step; try { for (_iterator.s(); !(_step = _iterator.n()).done;) { var value = _step.value; var test = tests[j]; if (value.sameTerm(tests) || value.termType === test.termType && value.value === test.value) { match = true; } } } catch (err) { _iterator.e(err); } finally { _iterator.f(); } } if (match) { var _field3 = kb.the(c, ui('use')); if (!_field3) { box.appendChild((0,_error__WEBPACK_IMPORTED_MODULE_7__/* .errorMessageBlock */ .F)(dom, 'No "use" part for case in form ' + form)); return box; } else { appendForm(dom, box, already, subject, _field3, dataDoc, callbackFunction); } break; } } // @@ Add box.refresh() to sync fields with values return box; }; /** Multiple field: zero or more similar subFields ** ** @param {Document} dom The HTML Document object aka Document Object Model ** @param {Element?} container If present, the created widget will be appended to this ** @param {Map} already A hash table of (form, subject) kept to prevent recursive forms looping ** @param {Node} subject The thing about which the form displays/edits data ** @param {Node} form The form or field to be rendered ** @param {Node} dataDoc The web document in which the data is ** @param {function(ok, errorMessage)} callbackFunction Called when data is changed? ** ** @returns {Element} The HTML widget created ** ** Form properties: ** @param {Boolean} reverse Make e reverse arc in the data OPS not SPO ** @param {NamedNode} property The property to be written in the data ** @param {Boolean} ordered Is the list an ordered one where the user defined the order */ _forms_fieldFunction__WEBPACK_IMPORTED_MODULE_4__/* .field */ .ZZ[_ns__WEBPACK_IMPORTED_MODULE_14__/* ["default"] */ .A.ui('Multiple').uri] = function (dom, container, already, subject, form, dataDoc, callbackFunction) { /** Diagnostic function */ function debugString(values) { return values.map(function (x) { return x.toString().slice(-7); }).join(', '); } /** Add an item to the local quadstore not the UI or the web * * @param {Node} object The RDF object to be represented by this item. */ function addItem() { return _addItem.apply(this, arguments); } /** Make a dom representation for an item * @param {Event} anyEvent if used as an event handler * @param {Node} object The RDF object to be represented by this item. */ function _addItem() { _addItem = (0,_babel_runtime_helpers_asyncToGenerator__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */ .A)(/*#__PURE__*/_babel_runtime_regenerator__WEBPACK_IMPORTED_MODULE_1___default().mark(function _callee6() { var object, toBeInserted, msg, _t; return _babel_runtime_regenerator__WEBPACK_IMPORTED_MODULE_1___default().wrap(function (_context6) { while (1) switch (_context6.prev = _context6.next) { case 0: object = newThing(dataDoc); // by default just add new nodes if (!ordered) { _context6.next = 2; break; } createListIfNecessary(); // Sets list and unsavedList list.elements.push(object); _context6.next = 1; return saveListThenRefresh(); case 1: _context6.next = 7; break; case 2: toBeInserted = reverse ? [rdflib__WEBPACK_IMPORTED_MODULE_15__.st(object, property, subject, dataDoc)] : [rdflib__WEBPACK_IMPORTED_MODULE_15__.st(subject, property, object, dataDoc)]; _context6.prev = 3; _context6.next = 4; return kb.updater.update([], toBeInserted); case 4: _context6.next = 6; break; case 5: _context6.prev = 5; _t = _context6["catch"](3); msg = 'Error adding to unordered multiple: ' + _t; box.appendChild((0,_error__WEBPACK_IMPORTED_MODULE_7__/* .errorMessageBlock */ .F)(dom, msg)); _debug__WEBPACK_IMPORTED_MODULE_6__/* .error */ .z3(msg); case 6: refresh(); case 7: case "end": return _context6.stop(); } }, _callee6, null, [[3, 5]]); })); return _addItem.apply(this, arguments); } function renderItem(object) { function deleteThisItem() { return _deleteThisItem.apply(this, arguments); } /** Move the object up or down in the ordered list * @param {Event} anyEvent if used as an event handler * @param {Boolean} upwards Move this up (true) or down (false). */ function _deleteThisItem() { _deleteThisItem = (0,_babel_runtime_helpers_asyncToGenerator__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */ .A)(/*#__PURE__*/_babel_runtime_regenerator__WEBPACK_IMPORTED_MODULE_1___default().mark(function _callee3() { var i, del; return _babel_runtime_regenerator__WEBPACK_IMPORTED_MODULE_1___default().wrap(function (_context3) { while (1) switch (_context3.prev = _context3.next) { case 0: if (!ordered) { _context3.next = 5; break; } _debug__WEBPACK_IMPORTED_MODULE_6__/* .log */ .Rm('pre delete: ' + debugString(list.elements)); i = 0; case 1: if (!(i < list.elements.length)) { _context3.next = 4; break; } if (!list.elements[i].sameTerm(object)) { _context3.next = 3; break; } list.elements.splice(i, 1); _context3.next = 2; return saveListThenRefresh(); case 2: return _context3.abrupt("return"); case 3: i++; _context3.next = 1; break; case 4: _context3.next = 6; break; case 5: // unordered if (kb.holds(subject, property, object, dataDoc)) { del = [rdflib__WEBPACK_IMPORTED_MODULE_15__.st(subject, property, object, dataDoc)]; kb.updater.update(del, [], function (uri, ok, message) { if (ok) { body.removeChild(subField); } else { body.appendChild((0,_error__WEBPACK_IMPORTED_MODULE_7__/* .errorMessageBlock */ .F)(dom, 'Multiple: delete failed: ' + message)); } }); } case 6: case "end": return _context3.stop(); } }, _callee3); })); return _deleteThisItem.apply(this, arguments); } function moveThisItem(_x, _x2) { return _moveThisItem.apply(this, arguments); } /* A subField has been filled in * * One possibility is to not actually make the link to the thing until * this callback happens to avoid widow links */ function _moveThisItem() { _moveThisItem = (0,_babel_runtime_helpers_asyncToGenerator__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */ .A)(/*#__PURE__*/_babel_runtime_regenerator__WEBPACK_IMPORTED_MODULE_1___default().mark(function _callee4(event, upwards) { var i; return _babel_runtime_regenerator__WEBPACK_IMPORTED_MODULE_1___default().wrap(function (_context4) { while (1) switch (_context4.prev = _context4.next) { case 0: // @@ possibly, allow shift+click to do move to top or bottom? _debug__WEBPACK_IMPORTED_MODULE_6__/* .log */ .Rm('pre move: ' + debugString(list.elements)); i = 0; case 1: if (!(i < list.elements.length)) { _context4.next = 3; break; } if (!list.elements[i].sameTerm(object)) { _context4.next = 2; break; } return _context4.abrupt("continue", 3); case 2: i++; _context4.next = 1; break; case 3: if (i === list.elements.length) { alert('list move: not found element for ' + object); } if (!upwards) { _context4.next = 5; break; } if (!(i === 0)) { _context4.next = 4; break; } alert('@@ boop - already at top -temp message'); // @@ make boop sound return _context4.abrupt("return"); case 4: list.elements.splice(i - 1, 2, list.elements[i], list.elements[i - 1]); _context4.next = 7; break; case 5: if (!(i === list.elements.length - 1)) { _context4.next = 6; break; } alert('@@ boop - already at bottom -temp message'); // @@ make boop sound return _context4.abrupt("return"); case 6: list.elements.splice(i, 2, list.elements[i + 1], list.elements[i]); case 7: _context4.next = 8; return saveListThenRefresh(); case 8: case "end": return _context4.stop(); } }, _callee4); })); return _moveThisItem.apply(this, arguments); } function itemDone(ok, message) { _debug__WEBPACK_IMPORTED_MODULE_6__/* .log */ .Rm("Item done callback for item ".concat(object.toString())); if (!ok) { // when does this happen? errors typically deal with upstream _debug__WEBPACK_IMPORTED_MODULE_6__/* .error */ .z3(' Item done callback: Error: ' + message); } callbackFunction(ok, message); } _log__WEBPACK_IMPORTED_MODULE_13__.debug('Multiple: render object: ' + object); var fn = (0,_forms_fieldFunction__WEBPACK_IMPORTED_MODULE_4__/* .fieldFunction */ .rg)(dom, element); var subField = fn(dom, null, already, object, element, dataDoc, itemDone); // subfields was: body. moving to not passing that subField.subject = object; // Keep a back pointer between the DOM array and the RDF objects // delete button and move buttons if (kb.updater.editable(dataDoc.uri)) { _buttons__WEBPACK_IMPORTED_MODULE_2__/* .deleteButtonWithCheck */ .Qy(dom, subField, multipleUIlabel, deleteThisItem); if (ordered) { // Add controsl in a frame var frame = dom.createElement('div'); frame.style.display = 'grid'; frame.style.gridTemplateColumns = 'auto 3em'; frame.style.gridTemplateRows = '50% 50%'; var moveUpButton = _buttons__WEBPACK_IMPORTED_MODULE_2__/* .button */ .x6(dom, _iconBase__WEBPACK_IMPORTED_MODULE_12__/* .icons */ .Pt.iconBase + 'noun_1369237.svg', 'Move Up', /*#__PURE__*/function () { var _ref = (0,_babel_runtime_helpers_asyncToGenerator__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */ .A)(/*#__PURE__*/_babel_runtime_regenerator__WEBPACK_IMPORTED_MODULE_1___default().mark(function _callee(event) { return _babel_runtime_regenerator__WEBPACK_IMPORTED_MODULE_1___default().wrap(function (_context) { while (1) switch (_context.prev = _context.next) { case 0: return _context.abrupt("return", moveThisItem(event, true)); case 1: case "end": return _context.stop(); } }, _callee); })); return function (_x3) { return _ref.apply(this, arguments); }; }()); var moveDownButton = _buttons__WEBPACK_IMPORTED_MODULE_2__/* .button */ .x6(dom, _iconBase__WEBPACK_IMPORTED_MODULE_12__/* .icons */ .Pt.iconBase + 'noun_1369241.svg', 'Move Down', /*#__PURE__*/function () { var _ref2 = (0,_babel_runtime_helpers_asyncToGenerator__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */ .A)(/*#__PURE__*/_babel_runtime_regenerator__WEBPACK_IMPORTED_MODULE_1___default().mark(function _callee2(event) { return _babel_runtime_regenerator__WEBPACK_IMPORTED_MODULE_1___default().wrap(function (_context2) { while (1) switch (_context2.prev = _context2.next) { case 0: return _context2.abrupt("return", moveThisItem(event, false)); case 1: case "end": return _context2.stop(); } }, _callee2); })); return function (_x4) { return _ref2.apply(this, arguments); }; }()); var _shim = dom.createElement('div'); _shim.appendChild(subField); // Subfield has its own layout frame.appendChild(_shim); frame.appendChild(moveUpButton); frame.appendChild(moveDownButton); moveUpButton.style.gridColumn = 2; moveDownButton.style.gridColumn = 2; moveUpButton.style.gridRow = 1; moveDownButton.style.padding = '0em'; // don't take too much space moveUpButton.style.padding = '0em'; moveDownButton.style.gridRow = 2; _shim.style.gridColumn = 1; _shim.style.gridRowStart = 'span 2'; // Cover both rows // shim.style.gridRowEnd = 2 // Cover both rows return frame; } } return subField; // unused } // renderItem /// ///////// Body of Multiple form field implementation var plusIconURI = _iconBase__WEBPACK_IMPORTED_MODULE_12__/* .icons */ .Pt.iconBase + 'noun_19460_green.svg'; // white plus in green circle var kb = solid_logic_jss__WEBPACK_IMPORTED_MODULE_16__/* .store */ .M_; var formDoc = form.doc ? form.doc() : null; // @@ if blank no way to know var box = dom.createElement('div'); var shim = box; // no shim // We don't indent multiple as it is a sort of a prefix of the next field and has contents of one. // box.setAttribute('style', 'padding-left: 2em; border: 0.05em solid green;') // Indent a multiple var ui = _ns__WEBPACK_IMPORTED_MODULE_14__/* ["default"] */ .A.ui; if (container) container.appendChild(box); var orderedNode = kb.any(form, ui('ordered')); var ordered = orderedNode ? rdflib__WEBPACK_IMPORTED_MODULE_15__.Node.toJS(orderedNode) : false; var property = kb.any(form, ui('property')); var reverse = kb.anyJS(form, ui('reverse'), null, formDoc); if (!property) { box.appendChild((0,_error__WEBPACK_IMPORTED_MODULE_7__/* .errorMessageBlock */ .F)(dom, 'No property to multiple: ' + form)); // used for arcs in the data return shim; } var multipleUIlabel = kb.any(form, ui('label')); if (!multipleUIlabel) multipleUIlabel = _utils__WEBPACK_IMPORTED_MODULE_18__/* .label */ .P(property); var min = kb.any(form, ui('min')); // This is the minimum number -- default 0 min = min ? 0 + min.value : 0; var element = kb.any(form, ui('part')); // This is the form to use for each one if (!element) { box.appendChild((0,_error__WEBPACK_IMPORTED_MODULE_7__/* .errorMessageBlock */ .F)(dom, 'No part to multiple: ' + form)); return shim; } var body = box.appendChild(dom.createElement('div')); body.style.display = 'flex'; body.style.flexDirection = 'column'; var list; // The RDF collection which keeps the ordered version or null var values; // Initial values - always an array. Even when no list yet. values = reverse ? kb.any(null, property, subject, dataDoc) : kb.any(subject, property, null, dataDoc); if (ordered) { list = reverse ? kb.any(null, property, subject, dataDoc) : kb.any(subject, property, null, dataDoc); if (list) { values = list.elements; } else { values = []; } } else { values = reverse ? kb.each(null, property, subject, dataDoc) : kb.each(subject, property, null, dataDoc); list = null; } // Add control on the bottom for adding more items if (kb.updater.editable(dataDoc.uri)) { var tail = box.appendChild(dom.createElement('div')); tail.style.padding = '0.5em'; var img = tail.appendChild(dom.createElement('img')); img.setAttribute('src', plusIconURI); // plus sign img.setAttribute('style', 'margin: 0.2em; width: 1.5em; height:1.5em'); img.title = 'Click to add another ' + multipleUIlabel; var prompt = dom.createElement('span'); prompt.textContent = (values.length === 0 ? 'Add another ' : 'Add ') + multipleUIlabel; tail.addEventListener('click', /*#__PURE__*/function () { var _ref3 = (0,_babel_runtime_helpers_asyncToGenerator__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */ .A)(/*#__PURE__*/_babel_runtime_regenerator__WEBPACK_IMPORTED_MODULE_1___default().mark(function _callee5(_eventNotUsed) { return _babel_runtime_regenerator__WEBPACK_IMPORTED_MODULE_1___default().wrap(function (_context5) { while (1) switch (_context5.prev = _context5.next) { case 0: _context5.next = 1; return addItem(); case 1: case "end": return _context5.stop(); } }, _callee5); })); return function (_x5) { return _ref3.apply(this, arguments); }; }(), true); tail.appendChild(prompt); } function createListIfNecessary() { if (!list) { list = new rdflib__WEBPACK_IMPORTED_MODULE_15__.Collection(); if (reverse) { kb.add(list, property, subject, dataDoc); } else { kb.add(subject, property, list, dataDoc); } } } function saveListThenRefresh() { return _saveListThenRefresh.apply(this, arguments); } function _saveListThenRefresh() { _saveListThenRefresh = (0,_babel_runtime_helpers_asyncToGenerator__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */ .A)(/*#__PURE__*/_babel_runtime_regenerator__WEBPACK_IMPORTED_MODULE_1___default().mark(function _callee7() { var _t2; return _babel_runtime_regenerator__WEBPACK_IMPORTED_MODULE_1___default().wrap(function (_context7) { while (1) switch (_context7.prev = _context7.next) { case 0: _debug__WEBPACK_IMPORTED_MODULE_6__/* .log */ .Rm('save list: ' + debugString(list.elements)); // 20191214 createListIfNecessary(); _context7.prev = 1; _context7.next = 2; return kb.fetcher.putBack(dataDoc); case 2: _context7.next = 4; break; case 3: _context7.prev = 3; _t2 = _context7["catch"](1); box.appendChild((0,_error__WEBPACK_IMPORTED_MODULE_7__/* .errorMessageBlock */ .F)(dom, 'Error trying to put back a list: ' + _t2)); return _context7.abrupt("return"); case 4: refresh(); case 5: case "end": return _context7.stop(); } }, _callee7, null, [[1, 3]]); })); return _saveListThenRefresh.apply(this, arguments); } function refresh() { var vals; if (ordered) { var li = reverse ? kb.the(null, property, subject, dataDoc) : kb.the(subject, property, null, dataDoc); vals = li ? li.elements : []; } else { vals = reverse ? kb.each(null, property, subject, dataDoc) : kb.each(subject, property, null, dataDoc); vals.sort(); // achieve consistency on each refresh } _utils__WEBPACK_IMPORTED_MODULE_17__.syncTableToArrayReOrdered(body, vals, renderItem); } body.refresh = refresh; // Allow live update refresh(); function asyncStuff() { return _asyncStuff.apply(this, arguments); } function _asyncStuff() { _asyncStuff = (0,_babel_runtime_helpers_asyncToGenerator__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */ .A)(/*#__PURE__*/_babel_runtime_regenerator__WEBPACK_IMPORTED_MODULE_1___default().mark(function _callee8() { var extra, j; return _babel_runtime_regenerator__WEBPACK_IMPORTED_MODULE_1___default().wrap(function (_context8) { while (1) switch (_context8.prev = _context8.next) { case 0: extra = min - values.length; if (!(extra > 0)) { _context8.next = 4; break; } j = 0; case 1: if (!(j < extra)) { _context8.next = 3; break; } _debug__WEBPACK_IMPORTED_MODULE_6__/* .log */ .Rm('Adding extra: min ' + min); _context8.next = 2; return addItem(); case 2: j++; _context8.next = 1; break; case 3: _context8.next = 4; return saveListThenRefresh(); case 4: case "end": return _context8.stop(); } }, _callee8); })); return _asyncStuff.apply(this, arguments); } asyncStuff().then(function () { _debug__WEBPACK_IMPORTED_MODULE_6__/* .log */ .Rm(' Multiple render: async stuff ok'); }, function (err) { _debug__WEBPACK_IMPORTED_MODULE_6__/* .error */ .z3(' Multiple render: async stuff fails. #### ', err); }); // async return shim; }; // Multiple /* Text field ** */ // For possible date popups see e.g. http://www.dynamicdrive.com/dynamicindex7/jasoncalendar.htm // or use HTML5: http://www.w3.org/TR/2011/WD-html-markup-20110113/input.date.html // _forms_fieldFunction__WEBPACK_IMPORTED_MODULE_4__/* .field */ .ZZ[_ns__WEBPACK_IMPORTED_MODULE_14__/* ["default"] */ .A.ui('PhoneField').uri] = _forms_basic__WEBPACK_IMPORTED_MODULE_8__/* .basicField */ .PM; _forms_fieldFunction__WEBPACK_IMPORTED_MODULE_4__/* .field */ .ZZ[_ns__WEBPACK_IMPORTED_MODULE_14__/* ["default"] */ .A.ui('EmailField').uri] = _forms_basic__WEBPACK_IMPORTED_MODULE_8__/* .basicField */ .PM; _forms_fieldFunction__WEBPACK_IMPORTED_MODULE_4__/* .field */ .ZZ[_ns__WEBPACK_IMPORTED_MODULE_14__/* ["default"] */ .A.ui('ColorField').uri] = _forms_basic__WEBPACK_IMPORTED_MODULE_8__/* .basicField */ .PM; _forms_fieldFunction__WEBPACK_IMPORTED_MODULE_4__/* .field */ .ZZ[_ns__WEBPACK_IMPORTED_MODULE_14__/* ["default"] */ .A.ui('DateField').uri] = _forms_basic__WEBPACK_IMPORTED_MODULE_8__/* .basicField */ .PM; _forms_fieldFunction__WEBPACK_IMPORTED_MODULE_4__/* .field */ .ZZ[_ns__WEBPACK_IMPORTED_MODULE_14__/* ["default"] */ .A.ui('DateTimeField').uri] = _forms_basic__WEBPACK_IMPORTED_MODULE_8__/* .basicField */ .PM; _forms_fieldFunction__WEBPACK_IMPORTED_MODULE_4__/* .field */ .ZZ[_ns__WEBPACK_IMPORTED_MODULE_14__/* ["default"] */ .A.ui('TimeField').uri] = _forms_basic__WEBPACK_IMPORTED_MODULE_8__/* .basicField */ .PM; _forms_fieldFunction__WEBPACK_IMPORTED_MODULE_4__/* .field */ .ZZ[_ns__WEBPACK_IMPORTED_MODULE_14__/* ["default"] */ .A.ui('NumericField').uri] = _forms_basic__WEBPACK_IMPORTED_MODULE_8__/* .basicField */ .PM; _forms_fieldFunction__WEBPACK_IMPORTED_MODULE_4__/* .field */ .ZZ[_ns__WEBPACK_IMPORTED_MODULE_14__/* ["default"] */ .A.ui('IntegerField').uri] = _forms_basic__WEBPACK_IMPORTED_MODULE_8__/* .basicField */ .PM; _forms_fieldFunction__WEBPACK_IMPORTED_MODULE_4__/* .field */ .ZZ[_ns__WEBPACK_IMPORTED_MODULE_14__/* ["default"] */ .A.ui('DecimalField').uri] = _forms_basic__WEBPACK_IMPORTED_MODULE_8__/* .basicField */ .PM; _forms_fieldFunction__WEBPACK_IMPORTED_MODULE_4__/* .field */ .ZZ[_ns__WEBPACK_IMPORTED_MODULE_14__/* ["default"] */ .A.ui('FloatField').uri] = _forms_basic__WEBPACK_IMPORTED_MODULE_8__/* .basicField */ .PM; _forms_fieldFunction__WEBPACK_IMPORTED_MODULE_4__/* .field */ .ZZ[_ns__WEBPACK_IMPORTED_MODULE_14__/* ["default"] */ .A.ui('TextField').uri] = _forms_basic__WEBPACK_IMPORTED_MODULE_8__/* .basicField */ .PM; _forms_fieldFunction__WEBPACK_IMPORTED_MODULE_4__/* .field */ .ZZ[_ns__WEBPACK_IMPORTED_MODULE_14__/* ["default"] */ .A.ui('SingleLineTextField').uri] = _forms_basic__WEBPACK_IMPORTED_MODULE_8__/* .basicField */ .PM; _forms_fieldFunction__WEBPACK_IMPORTED_MODULE_4__/* .field */ .ZZ[_ns__WEBPACK_IMPORTED_MODULE_14__/* ["default"] */ .A.ui('NamedNodeURIField').uri] = _forms_basic__WEBPACK_IMPORTED_MODULE_8__/* .basicField */ .PM; /* Multiline Text field ** */ _forms_fieldFunction__WEBPACK_IMPORTED_MODULE_4__/* .field */ .ZZ[_ns__WEBPACK_IMPORTED_MODULE_14__/* ["default"] */ .A.ui('MultiLineTextField').uri] = function (dom, container, already, subject, form, dataDoc, callbackFunction) { var ui = _ns__WEBPACK_IMPORTED_MODULE_14__/* ["default"] */ .A.ui; var kb = solid_logic_jss__WEBPACK_IMPORTED_MODULE_16__/* .store */ .M_; var formDoc = form.doc ? form.doc() : null; // @@ if blank no way to know var property = kb.any(form, ui('property')); if (!property) { return (0,_error__WEBPACK_IMPORTED_MODULE_7__/* .errorMessageBlock */ .F)(dom, 'No property to text field: ' + form); } var box = dom.createElement('div'); box.style.display = 'flex'; box.style.flexDirection = 'row'; var left = box.appendChild(dom.createElement('div')); left.style.width = _styleConstants__WEBPACK_IMPORTED_MODULE_11__/* ["default"] */ .A.formFieldNameBoxWidth; var right = box.appendChild(dom.createElement('div')); left.appendChild((0,_forms_basic__WEBPACK_IMPORTED_MODULE_8__/* .fieldLabel */ .bk)(dom, property, form)); dataDoc = (0,_forms_basic__WEBPACK_IMPORTED_MODULE_8__/* .fieldStore */ .WG)(subject, property, dataDoc); var text = kb.anyJS(subject, property, null, dataDoc) || ''; var editable = kb.updater.editable(dataDoc.uri); var suppressEmptyUneditable = form && kb.anyJS(form, _ns__WEBPACK_IMPORTED_MODULE_14__/* ["default"] */ .A.ui('suppressEmptyUneditable'), null, formDoc); if (!editable && suppressEmptyUneditable && text === '') { box.style.display = 'none'; } var field = makeDescription(dom, kb, subject, property, dataDoc, callbackFunction); right.appendChild(field); if (container) container.appendChild(box); return box; }; /* Boolean field and Tri-state version (true/false/null) ** ** @@ todo: remove tristate param */ function booleanField(dom, container, already, subject, form, dataDoc, callbackFunction, tristate) { var ui = _ns__WEBPACK_IMPORTED_MODULE_14__/* ["default"] */ .A.ui; var kb = solid_logic_jss__WEBPACK_IMPORTED_MODULE_16__/* .store */ .M_; var property = kb.any(form, ui('property')); if (!property) { var errorBlock = (0,_error__WEBPACK_IMPORTED_MODULE_7__/* .errorMessageBlock */ .F)(dom, 'No property to boolean field: ' + form); if (container) container.appendChild(errorBlock); return errorBlock; } var lab = kb.any(form, ui('label')); if (!lab) lab = _utils__WEBPACK_IMPORTED_MODULE_18__/* .label */ .P(property, true); // Init capital dataDoc = (0,_forms_basic__WEBPACK_IMPORTED_MODULE_8__/* .fieldStore */ .WG)(subject, property, dataDoc); var state = kb.any(subject, property); if (state === undefined) { state = false; } // @@ sure we want that -- or three-state? var ins = rdflib__WEBPACK_IMPORTED_MODULE_15__.st(subject, property, true, dataDoc); var del = rdflib__WEBPACK_IMPORTED_MODULE_15__.st(subject, property, false, dataDoc); var box = buildCheckboxForm(dom, kb, lab, del, ins, form, dataDoc, tristate); if (container) container.appendChild(box); return box; } _forms_fieldFunction__WEBPACK_IMPORTED_MODULE_4__/* .field */ .ZZ[_ns__WEBPACK_IMPORTED_MODULE_14__/* ["default"] */ .A.ui('BooleanField').uri] = function (dom, container, already, subject, form, dataDoc, callbackFunction) { return booleanField(dom, container, already, subject, form, dataDoc, callbackFunction, false); }; _forms_fieldFunction__WEBPACK_IMPORTED_MODULE_4__/* .field */ .ZZ[_ns__WEBPACK_IMPORTED_MODULE_14__/* ["default"] */ .A.ui('TristateField').uri] = function (dom, container, already, subject, form, dataDoc, callbackFunction) { return booleanField(dom, container, already, subject, form, dataDoc, callbackFunction, true); }; /* Classifier field ** ** Nested categories ** ** @@ To do: If a classification changes, then change any dependent Options fields. */ _forms_fieldFunction__WEBPACK_IMPORTED_MODULE_4__/* .field */ .ZZ[_ns__WEBPACK_IMPORTED_MODULE_14__/* ["default"] */ .A.ui('Classifier').uri] = function (dom, container, already, subject, form, dataDoc, callbackFunction) { var kb = solid_logic_jss__WEBPACK_IMPORTED_MODULE_16__/* .store */ .M_; var ui = _ns__WEBPACK_IMPORTED_MODULE_14__/* ["default"] */ .A.ui; var category = kb.any(form, ui('category')); if (!category) { return (0,_error__WEBPACK_IMPORTED_MODULE_7__/* .errorMessageBlock */ .F)(dom, 'No category for classifier: ' + form); } _log__WEBPACK_IMPORTED_MODULE_13__.debug('Classifier: dataDoc=' + dataDoc); var checkOptions = function checkOptions(ok, body) { if (!ok) return callbackFunction(ok, body); return callbackFunction(ok, body); }; var box = makeSelectForNestedCategory(dom, kb, subject, category, dataDoc, checkOptions); if (container) container.appendChild(box); return box; }; /** Choice field ** ** Not nested. Generates a link to something from a given class. ** Optional subform for the thing selected. ** Generates a subForm based on a ui:use form ** Will look like: **