solid-ui 3.1.1-test.0 → 3.1.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -10,7 +10,7 @@ const ni={multiselect__container:"\n -webkit-box-align: center;\n
10
10
  * @version IconicMultiSelect v0.7.0
11
11
  * @licence MIT
12
12
  */
13
- class ii{_data;_domElements;_event=()=>{};_itemTemplate;_multiselect;_noData;_noResults;_options=[];_placeholder;_select;_selectContainer;_selectedOptions=[];_tagTemplate;_textField;_valueField;_cross='\n <svg\n width="24"\n height="24"\n viewBox="0 0 24 24"\n fill="none"\n xmlns="http://www.w3.org/2000/svg"\n >\n <path\n d="M6.2253 4.81108C5.83477 4.42056 5.20161 4.42056 4.81108 4.81108C4.42056 5.20161 4.42056 5.83477 4.81108 6.2253L10.5858 12L4.81114 17.7747C4.42062 18.1652 4.42062 18.7984 4.81114 19.1889C5.20167 19.5794 5.83483 19.5794 6.22535 19.1889L12 13.4142L17.7747 19.1889C18.1652 19.5794 18.7984 19.5794 19.1889 19.1889C19.5794 18.7984 19.5794 18.1652 19.1889 17.7747L13.4142 12L19.189 6.2253C19.5795 5.83477 19.5795 5.20161 19.189 4.81108C18.7985 4.42056 18.1653 4.42056 17.7748 4.81108L12 10.5858L6.2253 4.81108Z"\n fill="currentColor"\n />\n </svg>\n ';constructor({data:e,itemTemplate:t,noData:n,noResults:i,placeholder:a,select:o,container:s,tagTemplate:r,textField:c,valueField:l}){this._data=e??[],this._itemTemplate=t??null,this._noData=n??"No data found.",this._noResults=i??"No results found.",this._placeholder=a??"Select...",this._select=o,this._selectContainer=s,this._tagTemplate=r??null,this._textField=c??null,this._valueField=l??null}init(){if(!this._select||"SELECT"!==this._select.nodeName)throw new Error(`The selector '${this._select}' did not select any valid select tag.`);if(this._itemTemplate&&0===this._data.length)throw new Error("itemTemplate must be initialized with data from the component settings");if(this._tagTemplate&&0===this._data.length)throw new Error("tagTemplate must be initialized with data from the component settings");this._options=this._data.length>0?this._getDataFromSettings():this._getDataFromSelectTag(),this._renderMultiselect(),this._renderOptionsList(),this._domElements={clear:this._multiselect.querySelector(".multiselect__clear-btn"),input:this._multiselect.querySelector(".multiselect__input"),optionsContainer:this._multiselect.querySelector(".multiselect__options"),optionsContainerList:this._multiselect.querySelector(".multiselect__options > ul"),options:{list:this._multiselect.querySelectorAll(".multiselect__options > ul > li"),find:function(e){for(let t=0;t<this.list.length;t++){const n=this.list[t];if(e(n))return n}},some:function(e){for(let t=0;t<this.list.length;t++){if(e(this.list[t],t))return!0}return!1}}},this._enableEventListenners(),this._initSelectedList()}subscribe(e){if("function"!=typeof e)throw new Error("parameter in the subscribe method is not a function");this._event=e}_addOptionToList(e,t){const n=`<span class="multiselect__selected" style="${ni.multiselect__selected}" data-value="${e.value}">${this._tagTemplate?this._processTemplate(this._tagTemplate,t):e.text}<span class="multiselect__remove-btn" style="${ni.multiselect__remove_btn}">${this._cross}</span></span>`;this._domElements.input.insertAdjacentHTML("beforebegin",n);const{lastElementChild:i}=this._multiselect.querySelector(`span[data-value="${e.value}"]`);i.addEventListener("click",()=>{const t=this._domElements.options.find(t=>t.dataset.value===e.value);this._handleOption(t)})}_clearSelection(){for(let e=0;e<this._selectedOptions.length;e++){const t=this._selectedOptions[e],n=this._domElements.options.find(e=>e.dataset.value===t.value);n.classList.remove("multiselect__options--selected"),n.setAttribute("style",ni.multiselect__options),this._removeOptionFromList(n.dataset.value)}this._selectedOptions=[],this._handleClearSelectionBtn(),this._handlePlaceholder(),this._dispatchEvent({action:"CLEAR_ALL_OPTIONS",selection:this._selectedOptions})}_closeList(){this._domElements.input.value="",this._domElements.optionsContainer.classList.remove("visible"),this._domElements.optionsContainer.setAttribute("style",ni.multiselect__options),this._filterOptions(""),this._removeAllArrowSelected()}_dispatchEvent(e){this._event(e)}_enableEventListenners(){document.addEventListener("mouseup",({target:e})=>{this._multiselect.contains(e)||(this._filterOptions(""),this._closeList(),this._handlePlaceholder())}),this._domElements.clear.addEventListener("click",()=>{this._clearSelection()});for(let e=0;e<this._domElements.options.list.length;e++){this._domElements.options.list[e].addEventListener("click",({target:e})=>{this._handleOption(e),this._closeList()})}this._domElements.input.addEventListener("focus",()=>{this._domElements.optionsContainer.classList.add("visible"),this._domElements.optionsContainer.setAttribute("style",ni.multiselect__options_visible)}),this._domElements.input.addEventListener("input",({target:{value:e}})=>{this._domElements.options.list.length>0&&this._filterOptions(e)}),this._domElements.input.addEventListener("keydown",e=>{this._handleArrows(e),this._handleBackspace(e),this._handleEnter(e)})}_filterOptions(e){const t=this._domElements.optionsContainer.classList.contains("visible"),n=e.toLowerCase();if(!t&&e.length>0&&(this._domElements.optionsContainer.classList.add("visible"),this._domElements.optionsContainer.setAttribute("style",ni.multiselect__options_visible)),this._domElements.options.list.length>0){for(let e=0;e<this._domElements.options.list.length;e++){const t=this._domElements.options.list[e];(this._itemTemplate?this._data[e][this._textField]:t.textContent).toLowerCase().substring(0,n.length)===n?this._domElements.optionsContainerList.appendChild(t):t.parentNode&&t.parentNode.removeChild(t)}const e=this._domElements.options.some((e,t)=>(this._itemTemplate?this._data[t][this._textField]:e.textContent).toLowerCase().substring(0,n.length)===n);this._showNoResults(!e)}}_generateId(e){let t="";const n="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";for(let i=0;i<e;i++)t+=n.charAt(Math.floor(62*Math.random()));return t}_getDataFromSelectTag(){const e=[],{options:t}=this._select;for(let n=0;n<t.length;n++){const i=t[n];e.push({text:i.text,value:i.value,selected:i.hasAttribute("selected")})}return e}_getDataFromSettings(){if(this._data.length>0&&this._valueField&&this._textField){const e="string"==typeof this._valueField,t="string"==typeof this._textField,n=[];if(!e||!t)throw new Error("textField and valueField must be of type string");for(let e=0;e<this._data.length;e++){const t=this._data[e];n.push({value:t[this._valueField],text:t[this._textField],selected:"boolean"==typeof t.selected&&t.selected})}return n}return null}_handleArrows(e){if(40===e.keyCode||38===e.keyCode){e.preventDefault();const t=this._domElements.optionsContainer.classList.contains("visible"),n=this._multiselect.querySelector(".multiselect__options > ul");if(t){let t=this._multiselect.querySelector(".multiselect__options ul li.arrow-selected");const i={ArrowUp:"previous",Up:"previous",ArrowDown:"next",Down:"next"};if(!t)return n.firstElementChild.classList.add("arrow-selected"),n.firstElementChild.setAttribute("style",ni.multiselect__options_ul_li_arrow_selected),void n.firstElementChild.scrollIntoView(!1);if(t.classList.remove("arrow-selected"),t.setAttribute("style",ni.multiselect__options_ul_li),t=t[i[e.key]+"ElementSibling"],!t)return t=n.children["next"===i[e.key]?0:n.children.length-1],t.classList.add("arrow-selected"),t.setAttribute("style",ni.multiselect__options_ul_li_arrow_selected),void this._scrollIntoView(n,t);t.classList.add("arrow-selected"),t.setAttribute("style",ni.multiselect__options_ul_li_arrow_selected),this._scrollIntoView(n,t)}else this._domElements.optionsContainer.classList.add("visible"),this._domElements.optionsContainer.setAttribute("style",ni.multiselect__options_visible),n.firstElementChild.classList.add("arrow-selected"),n.firstElementChild.setAttribute("style",ni.multiselect__options_ul_li_arrow_selected),n.firstElementChild.scrollIntoView(!1)}}_handleBackspace(e){if(8===e.keyCode&&""===e.target.value){const e=this._selectedOptions.length>0?this._selectedOptions[this._selectedOptions.length-1]:null;if(e){const t=this._multiselect.querySelector(`li[data-value="${e.value}"]`);this._handleOption(t),0===this._selectedOptions.length&&(this._domElements.optionsContainer.classList.remove("visible"),this._domElements.optionsContainer.setAttribute("style",ni.multiselect__options))}}}_handleClearSelectionBtn(){this._selectedOptions.length>0?this._domElements.clear.style.display="flex":this._domElements.clear.style.display="none"}_handleEnter(e){if(13===e.keyCode){const e=this._multiselect.querySelector(".multiselect__options ul li.arrow-selected");e&&(this._handleOption(e),this._closeList())}}_handleOption(e,t=!0){for(let n=0;n<this._selectedOptions.length;n++){if(this._selectedOptions[n].value===e.dataset.value)return e.classList.remove("multiselect__options--selected"),e.setAttribute("style",ni.multiselect__options),this._selectedOptions.splice(n,1),this._removeOptionFromList(e.dataset.value),this._handleClearSelectionBtn(),this._handlePlaceholder(),t&&this._dispatchEvent({action:"REMOVE_OPTION",value:e.dataset.value,selection:this._selectedOptions})}for(let n=0;n<this._options.length;n++){const i=this._options[n];if(i.value===e.dataset.value)return e.classList.add("multiselect__options--selected"),e.setAttribute("style",ni.multiselect__options_selected),this._selectedOptions=[...this._selectedOptions,i],this._addOptionToList(i,n),this._handleClearSelectionBtn(),this._handlePlaceholder(),t&&this._dispatchEvent({action:"ADD_OPTION",value:e.dataset.value,selection:this._selectedOptions})}}_handlePlaceholder(){this._domElements.input.placeholder=this._placeholder}_initSelectedList(){let e=!1;for(let t=0;t<this._options.length;t++){const n=this._options[t];if(n.selected){e=!0;const i=this._domElements.options.find(e=>e.dataset.value===n.value);i.classList.add("multiselect__options--selected"),i.setAttribute("style",ni.multiselect__options_selected),this._selectedOptions=[...this._selectedOptions,n],this._addOptionToList(n,t)}}e&&this._handleClearSelectionBtn(),this._handlePlaceholder()}_processTemplate(e,t){let n=e;const i=e.match(/\$\{(\w+)\}/g).map(e=>e.replace(/\$\{|\}/g,""));for(let e=0;e<i.length;e++){const a=i[e];n=n.replace(`\${${a}}`,this._data[t][a]??"")}return n}_removeAllArrowSelected(){const e="arrow-selected",t=this._domElements.options.find(t=>t.classList.contains(e));t&&t.classList.remove(e)&&t.setAttribute("style",ni.multiselect__options_ul_li)}_removeOptionFromList(e){const t=this._multiselect.querySelector(`span[data-value="${e}"]`);t&&t.parentNode&&t.parentNode.removeChild(t)}_renderOptionsList(){const e=`\n <div class="multiselect__options" style="${ni.multiselect__options}">\n <ul style="${ni.multiselect__options_ul}">\n ${this._options.length>0&&!this._itemTemplate?this._options.map(e=>`\n <li data-value="${e.value}" style="${ni.multiselect__options_ul_li}">${e.text}</li>\n `).join(""):""}\n\n ${this._options.length>0&&this._itemTemplate?this._options.map((e,t)=>`\n <li data-value="${e.value}" style="${ni.multiselect__options_ul_li}">${this._processTemplate(this._itemTemplate,t)}</li>\n `).join(""):""}\n ${this._showNoData(0===this._options.length)}\n </ul>\n </div>\n `;this._multiselect.insertAdjacentHTML("beforeend",e)}_renderMultiselect(){this._select.style.display="none";const e="iconic-"+this._generateId(20);this._multiselect=document.createElement("div"),this._multiselect.setAttribute("id",e),this._multiselect.setAttribute("class","multiselect__container"),this._multiselect.setAttribute("style",ni.multiselect__container);const t=`\n <div class="multiselect__wrapper" style="${ni.multiselect__wrapper}">\n <input class="multiselect__input" style="${ni.multiselect__input}" placeholder="${this._placeholder}" />\n </div>\n <span style="display: none;" class="multiselect__clear-btn" style="${ni.multiselect__clear_btn}">${this._cross}</span>\n `;this._multiselect.innerHTML=t,this._selectContainer.appendChild(this._multiselect)}_scrollIntoView(e,t){const n=e.getBoundingClientRect(),i=t.getBoundingClientRect();n.top<i.bottom-t.offsetHeight||(e.scrollTop=t.clientHeight+(t.offsetTop-t.offsetHeight)),n.bottom>i.top+t.offsetHeight||(e.scrollTop=t.clientHeight+(t.offsetTop-t.offsetHeight)-(e.offsetHeight-(t.offsetHeight+(t.offsetHeight-t.clientHeight))))}_showNoData(e){return e?`<p class="multiselect__options--no-data" style="${ni.multiselect__options_ul_p_multiselect__options_no_data}">${this._noData}</p>`:""}_showNoResults(e){const t=this._multiselect.querySelector(".multiselect__options--no-results");if(e){const e=`<p class="multiselect__options--no-results" style="${ni.multiselect__options_ul_p_multiselect__options_no_results}">${this._noResults}</p>`;!t&&this._domElements.optionsContainerList.insertAdjacentHTML("beforeend",e)}else t&&t.parentNode&&t.parentNode.removeChild(t)}}const ai=v.store;function oi(e,t,n,i,a,o,s){const r=o.children;for(let c=0;c<s.length;c++){const l=s[c];if(un(l)===b.ui("Options").uri){const s=dn(0,l)(e,null,t,n,l,i,a);xe.Rm("Refreshing Options field by replacing it."),o.insertBefore(s,r[c]),o.removeChild(r[c+1])}}}function si(e,t,n,i,a,o,s,r){const c=b.ui,l=v.store,p=l.any(a,c("property"));if(!p){const n=nt(e,"No property to boolean field: "+a);return t&&t.appendChild(n),n}let u=l.any(a,c("label"));u||(u=F(p,!0)),o=bn(i,p,o);let d=l.any(i,p);void 0===d&&(d=!1);const m=g.st(i,p,!0,o),f=Ci(e,l,u,g.st(i,p,!1,o),m,a,o,r);return t&&t.appendChild(f),f}function ri(e,t,n,i,a,o,s){dn(0,a)(e,t,n,i,a,o,s)}function ci(e,t,n,i,a){const o=e.createElement("button");return o.setAttribute("type","button"),o.innerHTML="Edit "+F(b.ui("Form")),o.addEventListener("click",function(s){li(e,t,{},n,b.ui("FormForm"),i,a).setAttribute("style",b.ui("FormForm").sameTerm(n)?"background-color: #fee;":"background-color: #ffffe7;"),o.parentNode.removeChild(o)},!0),o}function li(e,t,n,i,a,o,s){return dn(0,a)(e,t,n,i,a,o,s)}function pi(e,t){const n=e.each(void 0,b.rdf("range"),t);[b.rdfs("comment"),b.dc("title"),b.foaf("name"),b.foaf("homepage")].forEach(function(e){n.push(e)});let i=e.each(void 0,b.rdf("type"),t);i.length>60&&(i=i.slice(0,60));const a={};for(let t=0;t<(i.length>60?60:i.length);t++)e.statementsMatching(i[t],void 0,void 0).forEach(function(e){a[e.predicate.uri]=!0});n.forEach(function(e){a[e.uri]=!0});const o=[];for(const t in a)o.push(e.sym(t));return o}function ui(e,t,n){const i=[e.sym(t)];for(;i.length>0;){const t=i.shift(),a=e.each(t,n);if(T("Lists for "+t+", "+n+": "+a.length),0!==a.length)return a;const o=e.each(t,b.rdfs("subClassOf"));for(let e=0;e<o.length;e++)i.push(o[e]),T("findClosest: add super: "+o[e])}return[]}function di(e){const t=v.store;T("formsFor: subject="+e);const n=t.findTypeURIs(e);let i;for(i in n)T(" type: "+i);const a=t.bottomTypeURIs(n);let o=[];for(const e in a)T("candidatesFor: trying bottom type ="+e),o=o.concat(ui(t,e,b.ui("creationForm"))),o=o.concat(ui(t,e,b.ui("annotationForm")));return o}function mi(e){const t=e.map(function(e){return[ai.any(e,b.ui("sequence"))||9999,e]});return t.sort(function(e,t){return e[0]-t[0]}),t.map(function(e){return e[1]})}function fi(e){const t=e.map(function(e){return[F(e).toLowerCase(),e]});return t.sort(),t.map(function(e){return e[1]})}function hi(e,t,n,i,a,o,s,r){const c=e.createElement("button");return c.setAttribute("type","button"),c.innerHTML="New "+F(a),c.addEventListener("click",function(l){c.parentNode.appendChild(gi(e,t,n,i,a,o,s,r))},!1),c}function gi(e,t,n,i,a,o,s,r){const c=e.createElement("form");if(!o){const n=ui(t,a.uri,b.ui("creationForm"));if(0===n.length){c.appendChild(e.createElement("p")).textContent="I am sorry, you need to provide information about a "+F(a)+" but I don't know enough information about those to ask you.";const t=c.appendChild(e.createElement("button"));return t.setAttribute("type","button"),t.setAttribute("style","float: right;"),t.innerHTML="Goto "+F(a),t.addEventListener("click",function(t){e.outlineManager.GotoSubject(a,!0,void 0,!0,void 0)},!1),c}T("lists[0] is "+n[0]),o=n[0]}T("form is "+o),c.setAttribute("style",`border: 0.05em solid ${qe}; color: ${qe}`),c.innerHTML="<h3>New "+F(a)+"</h3>";const l=dn(0,o),p=Ei(s);let u=!1;function d(e,t,n){return r(t,n)}S("paneUtils Object is "+p);const m=l(e,c,{},p,o,s,function(o,l){if(!o)return r(o,l);const m=[];n&&!t.holds(n,i,p,s)&&m.push(g.st(n,i,p,s)),n&&!t.holds(p,b.rdf("type"),a,s)&&m.push(g.st(p,b.rdf("type"),a,s)),m.length?t.updater.update([],m,d):r(!0,l),u||(u=c.appendChild(Yt(e,p)))});return Kt(e,m).setAttribute("style","float: right;"),c.AJAR_subject=p,c}function bi(e,t,n,i,a,o){const s=e.createElement("div"),r=t.anyJS(n,i,null,a)||"",c=e.createElement("textarea");function l(r){p.disabled=!0,p.setAttribute("style","visibility: hidden; float: right;"),c.disabled=!0,c.style.color=Je;const l=t.statementsMatching(n,i,null,a),u=g.st(n,i,c.value,a);t.updater.update(l,u,function(t,n,i){n?(c.style.color=We,c.disabled=!1):s.appendChild(nt(e,"Error (while saving change to "+a.uri+"): "+i)),o&&o(n,i)})}s.appendChild(c),c.rows=r?r.split("\n").length+2:2,c.cols=80,c.setAttribute("style",Ke.multilineTextInputStyle),null!==r?c.value=r:c.select(),s.refresh=function(){const e=t.any(n,i,null,a);e&&e.value!==c.value&&(c.value=e.value)};let p;return t.updater.editable(a.uri)?(p=Mt(e,l),p.disabled=!0,p.style.visibility="hidden",p.style.float="right",s.appendChild(p),c.addEventListener("keyup",function(e){c.style.color="green",p&&(p.disabled=!1,p.style.visibility="")},!0),c.addEventListener("change",l,!0)):(c.disabled=!0,c.style.backgroundColor=Ge),s}function vi(e,t,n,i,a,o,s,r){T("Select list length now "+a.length);let c=0;const l={},p=t.updater.editable(s.uri);for(let e=0;e<a.length;e++){const t=a[e];t.uri||xe.R8(`makeSelectForClassifierOptions: option does not have an uri: ${t}, with predicate: ${i}`),t.uri&&!(t.uri in l)&&(l[t.uri]=!0,c++)}if(0===c&&!o.mint)return nt(e,"Can't do selector with no options, subject= "+n+" property = "+i+".");let u;T("makeSelectForClassifierOptions: dataDoc="+s);const d=function(){return u={},i.sameTerm(b.rdf("type"))?u=t.findTypeURIs(n):t.each(n,i,null,s).forEach(function(e){u[e.uri]=!0}),u};u=d();const m=function(a){f.disabled=!0;const c=[];let l=[];const p=function(e){t.holds(n,i,e,s)&&c.push(g.st(n,i,e,s))};let m;for(let a=0;a<f.options.length;a++){const c=f.options[a];if(c.selected&&c.AJAR_mint){if(o.mintClass){const a=gi(e,t,n,i,o.mintClass,null,s,function(e,t){e||r(e,t,{change:"new"})});f.parentNode.appendChild(a),m=a.AJAR_subject}else m=Ei(s);l.push(g.st(n,i,m,s)),o.mintStatementsFun&&(l=l.concat(o.mintStatementsFun(m)))}c.AJAR_uri&&(c.selected&&!(c.AJAR_uri in u)&&l.push(g.st(n,i,t.sym(c.AJAR_uri),s)),!c.selected&&c.AJAR_uri in u&&p(t.sym(c.AJAR_uri)),c.selected&&(f.currentURI=c.AJAR_uri))}let h=f.subSelect;for(;h&&h.currentURI;)p(t.sym(h.currentURI)),h=h.subSelect;for(h=f.superSelect;h&&h.currentURI;)p(t.sym(h.currentURI)),h=h.superSelect;function b(e,t){r(e,{widget:"select",event:"new"})}S("makeSelectForClassifierOptions: data doc = "+s),t.updater.update(c,l,function(t,n,i){if(u=d(),!n)return f.parentNode.appendChild(nt(e,"Error updating data in select: "+i));if(f.disabled=!1,m){dn(0,o.subForm)(e,f.parentNode,{},m,o.subForm,s,b)}r&&r(n,{widget:"select",event:"change"})})},f=e.createElement("select");f.setAttribute("style",Ke.formSelectStyle),o.multiple&&f.setAttribute("multiple","true"),f.currentURI=null,f.refresh=function(){u=d();for(let e=0;e<f.children.length;e++){const t=f.children[e];t.AJAR_uri&&(t.selected=t.AJAR_uri in u)}f.disabled=!1};for(const n in l){const i=t.sym(n),a=e.createElement("option");o.disambiguate?a.appendChild(e.createTextNode(ue(i,!0))):a.appendChild(e.createTextNode(F(i,!0)));const s=t.any(i,t.sym("http://www.w3.org/ns/ui#backgroundColor"));s&&a.setAttribute("style","background-color: "+s.value+"; "),a.AJAR_uri=n,n in u&&(a.setAttribute("selected","true"),f.currentURI=n),f.appendChild(a)}if(p&&o.mint){const t=e.createElement("option");t.appendChild(e.createTextNode(o.mint)),t.AJAR_mint=!0,f.insertBefore(t,f.firstChild)}if(null==f.currentURI&&!o.multiple){const t=e.createElement("option");t.appendChild(e.createTextNode(o.nullLabel)),f.insertBefore(t,f.firstChild),t.selected=!0}return p&&f.addEventListener("change",m,!1),f}function xi(e,t,n,i,a,o,s,r){T("Select list length now "+a.length);let c=0;const l={},p=t.updater.editable(s.uri);for(let e=0;e<a.length;e++){const t=a[e];t.uri||xe.R8(`makeSelectForOptions: option does not have an uri: ${t}, with predicate: ${i}`),t.uri&&!(t.uri in l)&&(l[t.uri]=!0,c++)}if(0===c)return nt(e,"Can't do selector with no options, subject= "+n+" property = "+i+".");let u;T("makeSelectForOptions: dataDoc="+s);const d=function(){return u={},i.sameTerm(b.rdf("type"))?u=t.findTypeURIs(n):t.each(n,i,null,s).forEach(function(e){e.uri&&(u[e.uri]=!0)}),u};u=d();const m=function(a){f.disabled=!0;const o=[],c=[],l=function(e){t.holds(n,i,e,s)&&o.push(g.st(n,i,e,s))};for(let e=0;e<f.options.length;e++){const a=f.options[e];a.AJAR_uri&&(a.selected&&!(a.AJAR_uri in u)&&c.push(g.st(n,i,t.sym(a.AJAR_uri),s)),!a.selected&&a.AJAR_uri in u&&l(t.sym(a.AJAR_uri)),a.selected&&(f.currentURI=a.AJAR_uri))}let p=f.subSelect;for(;p&&p.currentURI;)l(t.sym(p.currentURI)),p=p.subSelect;for(p=f.superSelect;p&&p.currentURI;)l(t.sym(p.currentURI)),p=p.superSelect;S("selectForOptions: data doc = "+s),t.updater.update(o,c,function(t,n,i){if(u=d(),!n)return f.parentNode.appendChild(nt(e,"Error updating data in select: "+i));f.disabled=!1,r&&r(n,{widget:"select",event:"change"})})},f=e.createElement("select");f.setAttribute("style",Ke.formSelectStyle),f.currentURI=null,f.refresh=function(){u=d();for(let e=0;e<f.children.length;e++){const t=f.children[e];t.AJAR_uri&&(t.selected=t.AJAR_uri in u)}f.disabled=!1};for(const n in l){const i=t.sym(n),a=e.createElement("option");o.disambiguate?a.appendChild(e.createTextNode(ue(i,!0))):a.appendChild(e.createTextNode(F(i,!0)));const s=t.any(i,t.sym("http://www.w3.org/ns/ui#backgroundColor"));s&&a.setAttribute("style","background-color: "+s.value+"; "),a.AJAR_uri=n,n in u&&(a.setAttribute("selected","true"),f.currentURI=n),f.appendChild(a)}if(!f.currentURI){const t=e.createElement("option");t.appendChild(e.createTextNode(o.nullLabel)),f.insertBefore(t,f.firstChild),t.selected=!0}return p&&f.addEventListener("change",m,!1),f}function yi(e,t,n,i,a,o){const s=t.any(i,b.owl("disjointUnionOf"));let r,c=!1;return s?r=s.elements:(r=t.each(void 0,b.rdfs("subClassOf"),i),c=!0),T("Select list length "+r.length),0===r.length?nt(e,"Can't do "+(c?"multiple ":"")+"selector with no subclasses of category: "+i):1===r.length?nt(e,"Can't do "+(c?"multiple ":"")+"selector with only 1 subclass of category: "+i+":"+r[1]):vi(e,t,n,b.rdf("type"),r,{multiple:c,nullLabel:"* Select type *"},a,o)}function wi(e,t,n,i,a,o){function s(){c&&(r.removeChild(c),c=null),l.currentURI&&t.any(t.sym(l.currentURI),b.owl("disjointUnionOf"))&&(c=wi(e,t,n,t.sym(l.currentURI),a,o),l.subSelect=c.firstChild,l.subSelect.superSelect=l,r.appendChild(c))}const r=e.createElement("span");let c=null;const l=yi(e,t,n,i,a,function(e,t){e&&s(),o(e,t)});return r.appendChild(l),s(),r}function Ci(e,t,n,i,a,o,s,r){const c=e.createElement("div"),l=hn(e,t,c,o,n),p=t.updater.editable(s.uri),u=e.createElement("button"),d=u;function m(e){if(!e)return[];if(e.object)return e.why||(e.why=s),[e];if(e instanceof Array)return e;throw new Error("buildCheckboxForm: bad param "+e)}function f(e){return 0===e.filter(e=>!t.holds(e.subject,e.predicate,e.object,e.why)).length}if(u.style=Ke.checkboxInputStyle,l.appendChild(u),a=m(a),i=m(i),function(){let n=f(a),s=n;if(i.length){const l=f(i);if(n&&l)return c.appendChild(nt(e,"Inconsistent data in dataDoc!\n"+a+" and\n"+i)),c;if(!n&&!l){n=null;const e=t.any(o,b.ui("default"));s=e?"1"===e.value:!!r&&null}}u.state=n,u.textContent={true:"✓",false:r?"✕":" ",null:"-"}[s]}(),!p)return c;let h=!1;return u.addEventListener("click",function(n){if(h)return;h=!0,u.disabled=!0;let o=!1;const s=function(){return!o&&(o=!0,h=!1,u.disabled=!1,!0)},l=function(t){d.style.color="#000",d.style.backgroundColor="#fee",c.appendChild(nt(e,`Checkbox: Error updating dataDoc from ${u.state} to ${u.newState}:\n\n${t}`))};d.style.color="#bbb";const p=!0===u.state?a:!1===u.state?i:[];u.newState=null===u.state||!0!==u.state&&(!r||null);const m=!0===u.newState?a:!1===u.newState?i:[];xe.Rm(` Deleting ${p}`),xe.Rm(` Inserting ${m}`);try{const e=t.updater.update(p,m,function(e,n,i){if(s())if(n)d.style.color="#000",u.state=u.newState,u.textContent={true:"✓",false:"✕",null:"-"}[u.state];else{if(p.why){t.holds(p.subject,p.predicate,p.object,p.why)&&xe.Rm(" @@@@@ weird if 409 - does hold statement")}l(i)}});e&&"function"==typeof e.then&&e.catch(function(e){s()&&l(e instanceof Error?e.message:e)}).finally(function(){s()})}catch(e){throw s(),e}},!1),c}function Ei(e){const t=new Date;return g.sym(e.uri+"#id"+t.getTime())}function ki(e,t,n,i,a,o,s,r,c,l,p){const u={},d=n.updater.editable(l.uri);for(let e=0;e<o.length;e++){const t=o[e];t.uri&&!(t.uri in u)&&(u[t.uri]=!0)}if(0===Object.keys(u).length&&!c.mint)return nt(e,"Can't do selector with no options, subject= "+i+" property = "+a+".");T("makeSelectForChoice: dataDoc="+l);const m=function(e){t.removeChild(t.lastChild),f.refresh()},f=e.createElement("select");f.setAttribute("style",Ke.formSelectStyle),f.setAttribute("id","formSelect"),f.currentURI=null;for(const e in u)f.appendChild(h(e));if(d&&c.mint){const t=e.createElement("option");t.appendChild(e.createTextNode(c.mint)),t.AJAR_mint=!0,f.insertBefore(t,f.firstChild)}function h(t){const i=e.createElement("option"),a=n.sym(t);let o;o=c.disambiguate?ue(a,!0):F(a,!0),i.appendChild(e.createTextNode(o)),i.setAttribute("value",t);const r=n.any(a,n.sym("http://www.w3.org/ns/ui#backgroundColor"));return r&&i.setAttribute("style","background-color: "+r.value+"; "),i.AJAR_uri=t,Ai(a.value,s)&&i.setAttribute("selected","true"),i}return 0===f.children.length&&f.insertBefore(function(){const t=e.createElement("option");return t.appendChild(e.createTextNode(function(){let e="--- choice ---";return a&&"BlankNode"!==a.termType&&(e="* Select for property: "+F(a)+" *"),i&&"BlankNode"!==i.termType&&(e="* Select for "+F(i,!0)+" *"),e}())),t.disabled=!0,t.value=!0,t.hidden=!0,t.selected=!0,t}(),f.firstChild),f.update=function(t){s=t;const o=[],c=[],u=function(e){n.holds(i,a,e,l)&&o.push(g.st(i,a,e,l))},d=function(e){n.holds(i,a,e,l)||c.push(g.st(i,a,e,l)),r&&!n.holds(e,b.rdf("type"),n.sym(r),l)&&c.push(g.st(e,b.rdf("type"),n.sym(r),l))},m=n.each(i,a,null,l).map(e=>e.value);for(const e of m)Ai(e,s)||u(g.sym(e));for(const e of s)e in m||d(g.sym(e));n.updater.update(o,c,function(t,n,i){if(!n)return f.parentNode.appendChild(nt(e,"Error updating data in select: "+i));f.refresh(),p&&p(n,{widget:"select",event:"change"})})},f.refresh=function(){f.disabled=!0;let o,u=[];for(let t=0;t<f.options.length;t++){const d=f.options[t];if(d.selected&&d.AJAR_mint){if(c.mintClass){const t=gi(e,n,i,a,r,c.subForm,l,function(e,t){e||p(e,t,{change:"new"})});f.parentNode.appendChild(t),o=t.AJAR_subject}else o=Ei(l);u.push(g.st(i,a,n.sym(o),l)),r&&u.push(g.st(o,b.rdf("type"),n.sym(r),l)),c.mintStatementsFun&&(u=u.concat(c.mintStatementsFun(o))),f.currentURI=o}d.AJAR_uri&&(d.selected&&Ai(d.AJAR_uri,s)&&(f.currentURI=d.AJAR_uri),Ai(d.AJAR_uri,s)||d.removeAttribute("selected"),Ai(d.AJAR_uri,s)&&d.setAttribute("selected","true"))}S("selectForOptions: data doc = "+l),f.currentURI&&c.subForm&&!c.multiSelect&&ri(e,t,{},g.sym(f.currentURI),c.subForm,l,function(i,a){i?(n.updater.update([],u,function(n,i,a){i||t.appendChild(nt(e,"Error updating select: "+a))}),p&&p(i,{widget:"select",event:"new"})):t.appendChild(nt(e,"Error updating data in field of select: "+a))}),f.disabled=!1},d&&f.addEventListener("change",m,!1),f}function Ai(e,t){let n;for(n=0;n<t.length;n++)if(t[n]===e)return!0;return!1}pn[b.ui("AutocompleteField").uri]=function(e,t,n,i,a,o,s){if("NamedNode"!==i.termType)throw new Error("Sorry this field only works on NamedNode subjects (for editable)");const r=v.store,c=a.doc?a.doc():null,l=e.createElement("div");t&&t.appendChild(l);const p=e.createElement("div");p.setAttribute("class","formFieldName"),p.setAttribute("style",Ke.formFieldNameBoxStyle),l.appendChild(p);const u=e.createElement("div");u.setAttribute("class","formFieldValue"),l.appendChild(u);const d=r.any(a,b.ui("property"));if(!d)return l.appendChild(nt(e,"Error: No property given for autocomplete field: "+a));const m=r.any(a,b.ui("labelProperty"))||b.schema("name"),f=r.any(a,b.ui("dataSource"));if(!f)return l.appendChild(nt(e,"Error: No data source given for autocomplete field: "+a));const h={label:r.anyJS(f,b.schema("name"),null,f.doc()),logo:r.any(f,b.schema("logo"),null,f.doc())},x=r.any(a,b.ui("targetClass"),null,a.doc())||r.any(f,b.ui("targetClass"),null,f.doc());x&&(h.targetClass=x),h.objectURIBase=r.any(f,b.ui("objectURIBase"),null,f.doc())||void 0;const y=r.anyJS(f,b.ui("endpoint"),null,f.doc());if(y){if(h.endpoint=y,h.searchByNameQuery=r.anyJS(f,b.ui("searchByNameQuery"),null,f.doc()),!h.searchByNameQuery)return l.appendChild(nt(e,"Error: No searchByNameQuery given for endpoint data Source: "+a));h.insitituteDetailsQuery=r.anyJS(f,b.ui("insitituteDetailsQuery"),null,f.doc())}else{const t=r.anyJS(f,b.ui("searchByNameURI"));if(!t)return l.appendChild(nt(e,"Error: No searchByNameURI OR sparql endpoint given for dataSource: "+f));h.searchByNameURI=t}const w=r.anyJS(a,b.ui("suppressEmptyUneditable"),null,c),C=r.updater?.editable(o.uri),E={permanent:!0,targetClass:h.targetClass,queryParams:h};E.size=r.anyJS(a,b.ui("size"),null,c)||void 0;let k=r.any(i,d,void 0,o);if(k)E.currentObject=k,E.currentName=r.any(E.currentObject,m,null,o);else if(k=r.any(a,b.ui("default")),k)E.currentObject=k,E.currentName=r.any(E.currentObject,m,null,o);else if(w&&!C)return l.style.display="none",l;return p.appendChild(gn(e,d,a)),ti(e,i,{editable:C,dbLookup:!0},E,async function(t,n){if(!n)throw new Error("autocompleteField: No name set.");const a=r.the(i,d,null,o);if(a){const e=r.any(a,m,null,o);if(a.equals(t)&&e&&e.sameTerm(n))return}const c=a?r.statementsMatching(i,d,a,o).concat(r.statementsMatching(a,m,null,o)):[],p=[(0,g.st)(i,d,t,o),(0,g.st)(t,m,n,o)];try{await(r.updater?.updateMany(c,p))}catch(t){return s(!1,t),void l.appendChild(nt(e,"Autocomplete form data update error:"+t,null,t))}s(!0,"")},async function(t,n){const a=r.the(i,d,null,o);if(!a)return s(!1,"NO data to elete"),void l.appendChild(nt(e,"Autocomplete delete: no old data!"));const c=r.statementsMatching(i,d,a,o).concat(r.statementsMatching(a,m,null,o)),p=[];try{await(r.updater?.updateMany(c,p))}catch(t){const n=new Error("Autocomplete form data delete error:"+t);return s(!1,t),void l.appendChild(nt(e,n,null,t))}s(!0,"")}).then(e=>{u.appendChild(e)},t=>{u.appendChild(nt(e,`Error rendering autocomplete ${a}: ${t}`,"#fee",t))}),l},pn[b.ui("Form").uri]=pn[b.ui("Group").uri]=function(e,t,n,i,a,o,s){const r=e.createElement("div"),c=b.ui;if(t&&t.appendChild(r),!a)return;const l=i.toNT()+"|"+a.toNT();if(n[l])return r.appendChild(e.createTextNode("Group: see above "+l)),r;const p={};for(const e in n)p[e]=1;p[l]=1;const u=a.doc?a.doc():null,d=ai.any(a,c("weight"),null,u),m=d?Number(d.value):1;if(m>3||m<0)return r.appendChild(nt(e,`Form Group weight ${m} should be 0-3`));r.setAttribute("style",Ke.formGroupStyle[m]),r.style.display="flex",r.style.flexDirection="column",r.class="form-weight-"+m;let f,h=ai.any(a,c("parts"),null,u);if(h?f=h.elements:(h=ai.each(a,c("part"),null,u),f=mi(h)),!h)return r.appendChild(nt(e,"No parts to form! "));for(let t=0;t<f.length;t++){const a=f[t],c=dn(0,a),l=function(t,a){t&&a&&a.widget&&"select"===a.widget&&oi(e,n,i,o,s,r,f),s(t,{widget:"group",change:a})};r.appendChild(c(e,null,p,i,a,o,l))}return r},pn[b.ui("Options").uri]=function(e,t,n,i,a,o,s){const r=v.store,c=e.createElement("div"),l=a.doc?a.doc():null,p=b.ui;t&&t.appendChild(c);let u=r.any(a,p("dependingOn"));u||(u=b.rdf("type"));const d=r.each(a,p("case"),null,l);let m;d||c.appendChild(nt(e,"No cases to Options form. ")),m=u.sameTerm(b.rdf("type"))?Object.keys(r.findTypeURIs(i)).map(e=>g.sym(e)):r.each(i,u);for(let t=0;t<d.length;t++){const u=d[t],f=r.each(u,p("for"),null,l);let h=!1;for(let e=0;e<f.length;e++)for(const t of m){const n=f[e];(t.sameTerm(f)||t.termType===n.termType&&t.value===n.value)&&(h=!0)}if(h){const t=r.the(u,p("use"));if(!t)return c.appendChild(nt(e,'No "use" part for case in form '+a)),c;li(e,c,n,i,t,o,s);break}}return c},pn[b.ui("Multiple").uri]=function(e,t,n,i,a,o,s){function r(e){return e.map(e=>e.toString().slice(-7)).join(", ")}async function c(){const t=Ei(o);if(y)L(),S.elements.push(t),await R();else{const n=C?[g.st(t,w,i,o)]:[g.st(i,w,t,o)];try{await u.updater.update([],n)}catch(t){const n="Error adding to unordered multiple: "+t;m.appendChild(nt(e,n)),xe.z3(n)}N()}}function l(t){async function a(e,n){let i;for(xe.Rm("pre move: "+r(S.elements)),i=0;i<S.elements.length&&!S.elements[i].sameTerm(t);i++);if(i===S.elements.length&&alert("list move: not found element for "+t),n){if(0===i)return void alert("@@ boop - already at top -temp message");S.elements.splice(i-1,2,S.elements[i],S.elements[i-1])}else{if(i===S.elements.length-1)return void alert("@@ boop - already at bottom -temp message");S.elements.splice(i,2,S.elements[i+1],S.elements[i])}await R()}T("Multiple: render object: "+t);const c=dn(0,A)(e,null,n,t,A,o,function(e,n){xe.Rm(`Item done callback for item ${t.toString()}`),e||xe.z3(" Item done callback: Error: "+n),s(e,n)});if(c.subject=t,u.updater.editable(o.uri)&&(Bt(e,c,E,async function(){if(y){xe.Rm("pre delete: "+r(S.elements));for(let e=0;e<S.elements.length;e++)if(S.elements[e].sameTerm(t))return S.elements.splice(e,1),void await R()}else if(u.holds(i,w,t,o)){const n=[g.st(i,w,t,o)];u.updater.update(n,[],function(t,n,i){n?_.removeChild(c):_.appendChild(nt(e,"Multiple: delete failed: "+i))})}}),y)){const t=e.createElement("div");t.style.display="grid",t.style.gridTemplateColumns="auto 3em",t.style.gridTemplateRows="50% 50%";const n=Dt(e,it.Pt.iconBase+"noun_1369237.svg","Move Up",async e=>a(0,!0)),i=Dt(e,it.Pt.iconBase+"noun_1369241.svg","Move Down",async e=>a(0,!1)),o=e.createElement("div");return o.appendChild(c),t.appendChild(o),t.appendChild(n),t.appendChild(i),n.style.gridColumn=2,i.style.gridColumn=2,n.style.gridRow=1,i.style.padding="0em",n.style.padding="0em",i.style.gridRow=2,o.style.gridColumn=1,o.style.gridRowStart="span 2",t}return c}const p=it.Pt.iconBase+"noun_19460_green.svg",u=v.store,d=a.doc?a.doc():null,m=e.createElement("div"),f=m,h=b.ui;t&&t.appendChild(m);const x=u.any(a,h("ordered")),y=!!x&&g.Node.toJS(x),w=u.any(a,h("property")),C=u.anyJS(a,h("reverse"),null,d);if(!w)return m.appendChild(nt(e,"No property to multiple: "+a)),f;let E=u.any(a,h("label"));E||(E=F(w));let k=u.any(a,h("min"));k=k?0+k.value:0;const A=u.any(a,h("part"));if(!A)return m.appendChild(nt(e,"No part to multiple: "+a)),f;const _=m.appendChild(e.createElement("div"));let S,j;if(_.style.display="flex",_.style.flexDirection="column",j=C?u.any(null,w,i,o):u.any(i,w,null,o),y?(S=C?u.any(null,w,i,o):u.any(i,w,null,o),j=S?S.elements:[]):(j=C?u.each(null,w,i,o):u.each(i,w,null,o),S=null),u.updater.editable(o.uri)){const t=m.appendChild(e.createElement("div"));t.style.padding="0.5em";const n=t.appendChild(e.createElement("img"));n.setAttribute("src",p),n.setAttribute("style","margin: 0.2em; width: 1.5em; height:1.5em"),n.title="Click to add another "+E;const i=e.createElement("span");i.textContent=(0===j.length?"Add another ":"Add ")+E,t.addEventListener("click",async e=>{await c()},!0),t.appendChild(i)}function L(){S||(S=new g.Collection,C?u.add(S,w,i,o):u.add(i,w,S,o))}async function R(){xe.Rm("save list: "+r(S.elements)),L();try{await u.fetcher.putBack(o)}catch(t){return void m.appendChild(nt(e,"Error trying to put back a list: "+t))}N()}function N(){let e;if(y){const t=C?u.the(null,w,i,o):u.the(i,w,null,o);e=t?t.elements:[]}else e=C?u.each(null,w,i,o):u.each(i,w,null,o),e.sort();Y(_,e,l)}return _.refresh=N,N(),async function(){const e=k-j.length;if(e>0){for(let t=0;t<e;t++)xe.Rm("Adding extra: min "+k),await c();await R()}}().then(()=>{xe.Rm(" Multiple render: async stuff ok")},e=>{xe.z3(" Multiple render: async stuff fails. #### ",e)}),f},pn[b.ui("PhoneField").uri]=vn,pn[b.ui("EmailField").uri]=vn,pn[b.ui("ColorField").uri]=vn,pn[b.ui("DateField").uri]=vn,pn[b.ui("DateTimeField").uri]=vn,pn[b.ui("TimeField").uri]=vn,pn[b.ui("NumericField").uri]=vn,pn[b.ui("IntegerField").uri]=vn,pn[b.ui("DecimalField").uri]=vn,pn[b.ui("FloatField").uri]=vn,pn[b.ui("TextField").uri]=vn,pn[b.ui("SingleLineTextField").uri]=vn,pn[b.ui("NamedNodeURIField").uri]=vn,pn[b.ui("MultiLineTextField").uri]=function(e,t,n,i,a,o,s){const r=b.ui,c=v.store,l=a.doc?a.doc():null,p=c.any(a,r("property"));if(!p)return nt(e,"No property to text field: "+a);const u=e.createElement("div");u.style.display="flex",u.style.flexDirection="row";const d=u.appendChild(e.createElement("div"));d.style.width=He;const m=u.appendChild(e.createElement("div"));d.appendChild(gn(e,p,a)),o=bn(i,p,o);const f=c.anyJS(i,p,null,o)||"",h=c.updater.editable(o.uri),g=a&&c.anyJS(a,b.ui("suppressEmptyUneditable"),null,l);!h&&g&&""===f&&(u.style.display="none");const x=bi(e,c,i,p,o,s);return m.appendChild(x),t&&t.appendChild(u),u},pn[b.ui("BooleanField").uri]=function(e,t,n,i,a,o,s){return si(e,t,0,i,a,o,0,!1)},pn[b.ui("TristateField").uri]=function(e,t,n,i,a,o,s){return si(e,t,0,i,a,o,0,!0)},pn[b.ui("Classifier").uri]=function(e,t,n,i,a,o,s){const r=v.store,c=b.ui,l=r.any(a,c("category"));if(!l)return nt(e,"No category for classifier: "+a);T("Classifier: dataDoc="+o);const p=e.createElement("div");p.setAttribute("class","classifierBox");const u=e.createElement("div");u.setAttribute("class","formFieldName classifierBox-label"),u.appendChild(gn(e,l,a)),p.appendChild(u);const d=e.createElement("div");d.setAttribute("class","formFieldValue classifierBox-selectBox");const m=wi(e,r,i,l,o,function(e,t){return s(e,t)});if(m&&m.querySelectorAll){const e=m.querySelectorAll("select");e.length&&!r.updater.editable(o.uri)&&e.forEach(e=>{e.readOnly=!0,e.style=Ke.textInputStyleUneditable})}return d.appendChild(m),p.appendChild(d),t&&t.appendChild(p),p},pn[b.ui("Choice").uri]=function(e,t,n,i,a,o,s){const r=b.ui,c=v.store,l=a.doc?a.doc():null;let p;const u=e.createElement("div");u.setAttribute("class","choiceBox"),t&&t.appendChild(u);const d=e.createElement("div");d.setAttribute("class","formFieldName choiceBox-label"),u.appendChild(d);const m=e.createElement("div");m.setAttribute("class","formFieldValue choiceBox-selectBox"),u.appendChild(m);const f=c.any(a,r("property"));if(!f)return u.appendChild(nt(e,"No property for Choice: "+a));d.appendChild(gn(e,f,a));const h=c.any(a,r("from"));if(!h)return nt(e,"No 'from' for Choice: "+a);const x=c.any(a,r("use")),y={form:a,subForm:x,disambiguate:!1};c.any(a,r("canMintNew"))&&(y.mint="* Create new *");const w=c.any(a,r("multiselect"));w&&(y.multiSelect=!0);const C=c.each(a,r("search-full-store")).length?null:o;let E;return m.refresh=function(){let t=c.each(i,f,null,o).map(e=>e.value),n=function(e){let t,n=[];n=c.each(void 0,b.rdf("type"),h,l);for(const t in function(e,t,n){let i,a,o,s,r,c,l,p,u,d,m;const f={};f[t.toNT()]=!0;const h={},g=e.transitiveClosure(f,e.rdfFactory.namedNode("http://www.w3.org/2000/01/rdf-schema#subClassOf"),!0);for(const t in g){r=e.statementsMatching(null,e.rdfFactory.namedNode("http://www.w3.org/1999/02/22-rdf-syntax-ns#type"),e.fromNT(t),n);for(let e=0,t=r.length;e<t;e++)d=r[e],h[d.subject.toNT()]=d;c=e.each(null,e.rdfFactory.namedNode("http://www.w3.org/2000/01/rdf-schema#domain"),e.fromNT(t),n);for(let t=0,a=c.length;t<a;t++)for(s=c[t],l=e.statementsMatching(null,s,null,n),o=0,i=l.length;o<i;o++)d=l[o],h[d.subject.toNT()]=d;p=e.each(null,e.rdfFactory.namedNode("http://www.w3.org/2000/01/rdf-schema#range"),e.fromNT(t),n);for(let t=0,i=p.length;t<i;t++)for(s=p[t],u=e.statementsMatching(null,s,null,n),m=0,a=u.length;m<a;m++)d=u[m],h[d.object.toNT()]=d}return h}(c,h,e))n.push(c.fromNT(t));if(h.sameTerm(b.rdfs("Class")))for(p in Qt())n.push(c.sym(p));else if(h.sameTerm(b.rdf("Property"))){for(p in t=Zt(c),t.op)n.push(c.fromNT(p));for(p in t.dp)n.push(c.fromNT(p));y.disambiguate=!0}else if(h.sameTerm(b.owl("ObjectProperty"))){for(p in t=Zt(c),t.op)n.push(c.fromNT(p));y.disambiguate=!0}else if(h.sameTerm(b.owl("DatatypeProperty"))){for(p in t=Zt(c),t.dp)n.push(c.fromNT(p));y.disambiguate=!0}return n}(C);if(n.push(t),n=fi(n),E=ki(e,m,c,i,f,n,t,h,y,o,s),m.innerHTML="",m.appendChild(E),w){const n=new ii({placeholder:E.selected,select:E,container:m,textField:"textField",valueField:"valueField"});n.init(),n.subscribe(function(n){if("REMOVE_OPTION"===n.action&&(t=t.filter(function(e){return e!==n.value})),"CLEAR_ALL_OPTIONS"===n.action&&(t=[]),"ADD_OPTION"===n.action){if((n.value+"").includes("Create new")){const n=Ei(o),a=[];a.push(g.st(i,f,c.sym(n),o)),h&&a.push(g.st(n,b.rdf("type"),c.sym(h),o)),x&&ri(e,m,{},g.sym(n),x,o,function(i,o){i?(c.updater.update([],a,function(t,n,i){n||m.appendChild(nt(e,"Error updating select: "+i))}),t.push(n),s&&s(i,{widget:"select",event:"new"})):m.appendChild(nt(e,"Error updating data in field of select: "+o))})}else t.push(n.value)}E.update(t)})}},m.refresh(),E&&E.refresh&&E.refresh(),u},pn[b.ui("Comment").uri]=pn[b.ui("Heading").uri]=function(e,t,n,i,a,o,s){const r=b.ui,c=v.store;let l=c.any(a,r("contents"));l||(l="Error: No contents in comment field.");const p=a.doc?a.doc():null,u=un(a),d=cn[u]||{},m=e.createElement("div");t&&t.appendChild(m);const f=m.appendChild(e.createElement(d.element));f.textContent=l,function(e,t){const n=un(t),i=cn[n]||{},a=v.store.any(t,b.ui("style"));a?"Literal"===a.termType?a&&e.setAttribute("style",a.value):v.store.statementsMatching(a,null,null,t.doc()).forEach(t=>{if(t.predicate.uri&&t.predicate.uri.startsWith(mn)){const n=t.predicate.uri.slice(26);try{e.style[n]=t.object.value}catch(i){console.warn(`setFieldStyle: Error setting element style ${n} to "${t.object.value}"`),console.warn(`setFieldStyle: ... Element tagName was "${e.tagName||"???"}"`)}}}):i.style&&e.setAttribute("style",i.style)}(f,a);const h=c.anyJS(a,b.ui("suppressIfUneditable"),null,p),g=c.updater.editable(o.uri);return h&&!g&&(m.style.display="none"),m};const _i={authEndpoint:"",fallbackAuthEndpoint:"https://databox.me/",signupEndpoint:"https://solidproject.org/get_a_pod",signupWindowHeight:600,signupWindowWidth:1024,key:"",cert:""};function Ti(e){this.config=e||_i}Ti.prototype.listen=function(){return new Promise(function(e,t){const n=window.addEventListener?"addEventListener":"attachEvent";(0,window[n])("attachEvent"===n?"onmessage":"message",function(n){const i=n.data;if("User:"===i.slice(0,5)){const n=i.slice(5,i.length);return n&&n.length>0&&"http"===n.slice(0,4)?e(n):t(n)}},!0)})},Ti.prototype.signup=function(e){e=e||this.config.signupEndpoint;const t=this.config.signupWindowWidth,n=this.config.signupWindowHeight,i=window.screen.width/2-(t/2+10),a=window.screen.height/2-(n/2+50),o=e+"?origin="+encodeURIComponent(window.location.origin),s="resizable,scrollbars,status,width="+t+",height="+n+",left="+i+",top="+a;window.open(o,"Solid signup",s);const r=this;return new Promise(function(e){r.listen().then(function(t){return e(t)})})};v.solidLogicSingleton.store;const{loadPreferences:Si,loadProfile:ji}=v.solidLogicSingleton.profile,{getScopedAppInstances:Li,getRegistrations:Ri,loadAllTypeIndexes:Ni,getScopedAppsFromIndex:Ii,deleteTypeIndexRegistration:$i}=v.solidLogicSingleton.typeIndex;function Bi(e){const t=v.authn.currentUser();return t?(v.authn.saveUser(t,e),Promise.resolve(e)):new Promise(t=>{v.authn.checkUser().then(n=>{if(n)return xe.Rm(`logIn: Already logged in as ${n}`),t(e);if(!e.div||!e.dom)return t(e);const i=Hi(e.dom,n=>{v.authn.saveUser(n,e),t(e)});e.div.appendChild(i)})})}async function Di(e){if(e.preferencesFile)return Promise.resolve(e);let t;try{e=await Oi(e);const n=await Si(e.me);t,e.preferencesFile=n}catch(t){let n;if(t instanceof v.UnauthorizedError)n="Oops — you are not authenticated (properly logged in), so SolidOS cannot read your preferences file. Try logging out and then logging back in.",R(n);else{if(t instanceof v.CrossOriginForbiddenError)return n=`Unauthorized: Assuming preference file blocked for origin ${window.location.origin}`,e.preferencesFileError=n,e;if(t instanceof v.SameOriginForbiddenError)return n="You are not authorized to read your preference file. This may be because you are using an untrusted web app.",xe.R8(n),e;if(t instanceof v.NotEditableError)return n="You are not authorized to edit your preference file. This may be because you are using an untrusted web app.",xe.R8(n),e;if(t instanceof v.WebOperationError)n="You are not authorized to edit your preference file. This may be because you are using an untrusted web app.",xe.R8(n);else{if(!(t instanceof v.FetchError))throw new Error(`(via loadPrefs) ${t}`);n=`Strange: Error ${t.status} trying to read your preference file.${t.message}`,R(n)}}}return e}async function Oi(e){if(e.publicProfile)return e;try{const t=await Bi(e);if(!t.me)throw new Error("Could not log in");e.publicProfile=await ji(t.me)}catch(t){throw e.div&&e.dom&&e.div.appendChild(nt(e.dom,t.message)),new Error(`Can't log in: ${t}`)}return e}async function Mi(e,t,n){let i=e.me?await Li(t,e.me):[];return!0===n?i=i.filter(e=>"public"===e.scope.label):!1===n&&(i=i.filter(e=>"private"===e.scope.label)),e.instances=i.map(e=>e.instance),e}function Ui(e,t){return`${e.me&&e.me.sameTerm(t.agent)?"":F(t.agent)+" "}${t.label}`}async function Fi(e,t,n){function i(i){const a=function(e){const i=Ri(t,n),a=i.length?i[0]:Ei(e);return[(0,g.st)(a,b.solid("instance"),t,e),(0,g.st)(a,b.solid("forClass"),n,e)]}(i.index),o=`${Ui(e,i)} link to this ${e.noun}`;return Ci(e.dom,v.solidLogicSingleton.store,o,null,a,l,i.index)}const a=e.dom;if(!a||!e.div)throw new Error("registrationControl: need dom and div");const o=a.createElement("div");e.div.appendChild(o),e.me=v.authn.currentUser();const s=e.me;if(!s)return o.innerHTML='<p style="margin:2em;">(Log in to save a link to this)</p>',e;let r;try{r=await Ni(s)}catch(t){let n;return e.div&&e.preferencesFileError?(n="(Lists of stuff not available)",e.div.appendChild(a.createElement("p")).textContent=n):e.div&&(n=`registrationControl: Type indexes not available: ${t}`,e.div.appendChild(nt(e.dom,t))),xe.Rm(n),e}o.innerHTML="<table><tbody></tbody></table>",o.setAttribute("style","font-size: 120%; text-align: right; padding: 1em; border: solid gray 0.05em;");const c=o.children[0].children[0],l=new g.BlankNode;for(const e of r){c.appendChild(a.createElement("tr")).appendChild(i(e))}return e}function Pi(e,t,n){const{dom:i}=e,a=Ui(e,n),o=i.createElement("tr"),s=o.appendChild(i.createElement("td"));s.setAttribute("colspan","3"),s.style.backgoundColor={private:"#fee",public:"#efe"}[n.label]||"white";const r=s.appendChild(i.createElement("h3"));return r.textContent=a+" links",r.style.textAlign="left",o}async function zi(e,t){const n=e.dom,i=e.div,a=n.createElement("div");if(i.appendChild(a),e.me=v.authn.currentUser(),!e.me)return a.innerHTML='<p style="margin:2em;">(Log in list your stuff)</p>',e;const o=await Ni(e.me);a.innerHTML="<table><tbody></tbody></table>",a.setAttribute("style","font-size: 120%; text-align: right; padding: 1em; border: solid #eee 0.5em;");const s=a.firstChild.firstChild;for(const i of o){const a=Pi(e,0,i);s.appendChild(a);const o=await Ii(i,t.type||null);0===o.length&&(a.style.display="none");for(const e of o){const t=Ft(n,b.solid("instance"),e.instance,{deleteFunction:async()=>{await $i(e),s.removeChild(t)}});t.children[0].style.paddingLeft="3em",s.appendChild(t)}}return e}function qi(e){const t=e.createElement("div");t.setAttribute("style","position: fixed; top: 0; left: 0; right: 0; bottom: 0; display: flex; justify-content: center; align-items: center;"),e.body.appendChild(t);const n=e.createElement("div");n.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 "),t.appendChild(n);const i=e.createElement("div");i.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 "),n.appendChild(i);const a=e.createElement("label");a.setAttribute("style","margin-right: 5px; font-weight: 800"),a.innerText="Select an identity provider";const o=e.createElement("button");o.innerHTML='<img src="https://solidos.github.io/solid-ui/src/icons/noun_1180156.svg" style="width: 2em; height: 2em;" title="Cancel">',o.setAttribute("style","background-color: transparent; border: none;"),o.addEventListener("click",()=>{t.remove()}),i.appendChild(a),i.appendChild(o);const s=async e=>{try{v.solidLogicSingleton.store.updater.flagAuthorizationMetadata();const t=new URL(window.location.href).hash;t&&window.localStorage.setItem("preLoginRedirectHash",t),window.localStorage.setItem("loginIssuer",e);const n=new URL(window.location.href);n.hash="",await v.authSession.login({redirectUrl:n.href,oidcIssuer:e})}catch(e){R(e.message)}},r=e.createElement("div");r.setAttribute("style","\n border-bottom: 1px solid #DDD;\n display: flex;\n flex-direction: column;\n padding-top: 10px;\n ");const c=e.createElement("div");c.setAttribute("style","\n display: flex;\n flex-direction: row;\n ");const l=e.createElement("label");l.innerText="Enter the URL of your identity provider:",l.setAttribute("style","color: #888");const p=e.createElement("input");p.setAttribute("type","text"),p.setAttribute("style","margin-left: 0 !important; flex: 1; margin-right: 5px !important"),p.setAttribute("placeholder","https://example.com"),p.value=localStorage.getItem("loginIssuer")||"";const u=e.createElement("button");u.innerText="Go",u.setAttribute("style","margin-top: 12px; margin-bottom: 12px;"),u.addEventListener("click",()=>{s(p.value)}),r.appendChild(l),c.appendChild(p),c.appendChild(u),r.appendChild(c),n.appendChild(r);const d=e.createElement("div");d.setAttribute("style","\n display: flex;\n flex-direction: column;\n padding-top: 10px;\n ");const m=e.createElement("label");m.innerText="Or pick an identity provider from the list below:",m.setAttribute("style","color: #888"),d.appendChild(m),(0,v.getSuggestedIssuers)().forEach(t=>{const n=e.createElement("button");n.innerText=t.name,n.setAttribute("style","height: 38px; margin-top: 10px"),n.addEventListener("click",()=>{s(t.uri)}),d.appendChild(n)}),n.appendChild(d)}function Hi(e,t=null,n={}){let i=(0,v.offlineTestID)();const a=e.createElement("div");function o(e){e&&(i=v.authn.saveUser(e),a.refresh(),t&&t(i.uri))}function s(e){const n=i;v.authSession.logout().then(function(){const e=`Your WebID was ${n}. It has been forgotten.`;i=null;try{R(e)}catch(t){window.alert(e)}a.refresh(),t&&t(null)},e=>{R("Fail to log out:"+e)})}function r(){i=v.authn.currentUser(),a.refresh()}return a.refresh=function(){const t=v.authSession.info;i=t&&t.webId&&t.isLoggedIn?v.solidLogicSingleton.store.sym(t.webId):null,(i&&a.me!==i.uri||!i&&a.me)&&(yt(a),i?a.appendChild(function(t,n){const i=n.buttonStyle||Ke.signInAndUpButtonStyle;let a="WebID logout";if(t){const e=v.solidLogicSingleton.store.any(t,b.foaf("nick"))||v.solidLogicSingleton.store.any(t,b.foaf("name"));e&&(a="Logout "+e.value)}const o=e.createElement("input");return o.setAttribute("type","button"),o.setAttribute("value",a),o.setAttribute("style",`${i}`),o.addEventListener("click",s,!1),o}(i,n)):a.appendChild(function(e,t,n={}){const i=(n=n||{}).buttonStyle||Ke.signInAndUpButtonStyle,a=e.createElement("div"),o="SolidSignInOrSignUpBox";xe.Rm("widgets.signInOrSignUpBox"),a.setUserCallback=t,a.setAttribute("class",o),a.setAttribute("style","display:flex;");const s=e.createElement("input");a.appendChild(s),s.setAttribute("type","button"),s.setAttribute("value","Log in"),s.setAttribute("style",`${i}${Ke.headerBannerLoginInput}`+Ke.signUpBackground),v.authSession.events.on("login",()=>{const t=v.authn.currentUser();if(t){const n=t.uri,i=e.getElementsByClassName(o);xe.Rm(`Logged in, ${i.length} panels to be serviced`);for(let t=0;t<i.length;t++){const a=i[t];if(a.setUserCallback)try{a.setUserCallback(n);const e=a.parentNode;e&&e.removeChild(a)}catch(t){xe.Rm(`## Error satisfying login box: ${t}`),a.appendChild(nt(e,t))}}}}),s.addEventListener("click",()=>{const n=(0,v.offlineTestID)();if(n)return t(n.uri);qi(e)},!1);const r=e.createElement("input");return a.appendChild(r),r.setAttribute("type","button"),r.setAttribute("value","Sign Up for Solid"),r.setAttribute("style",`${i}${Ke.headerBannerLoginInput}`+Ke.signInBackground),r.addEventListener("click",function(e){(new Ti).signup().then(function(e){xe.Rm("signInOrSignUpBox signed up "+e),t(e)})},!1),a}(e,o,n))),a.me=i?i.uri:null},a.refresh(),r(),v.authSession.events.on("login",r),v.authSession.events.on("logout",r),a.me="99999",a.refresh(),a}function Vi(e,t,n){const i=t.noun,a=t.appPathSegment,o=(0,v.offlineTestID)(),s=e.createElement("div"),r={me:o,dom:e,div:s};function c(t,n){s.appendChild(nt(e,t,n))}function l(e){const t=v.solidLogicSingleton.store.any(e,b.space("uriPrefix"));let n;n=t?t.value:e.uri.split("#")[0],"/"!==n.slice(-1)&&(xe.Rm(`${a}: No / at end of uriPrefix ${n}`),n=`${n}/`);const i=new Date;return n+=`${a}/id${i.getTime()}/`,n}return Di(r).then(function(t){const a=t.me,o=t.preferencesFile;let r=null,p=v.solidLogicSingleton.store.each(a,b.space("workspace"),void 0,o);const u=v.solidLogicSingleton.store.each(a,b.space("storage"));0===p.length&&u&&(c(`You don't seem to have any workspaces. You have ${u.length} storage spaces.`,"white"),u.map(function(e){return p=p.concat(v.solidLogicSingleton.store.each(e,b.ldp("contains"))),p}).filter(e=>e.id?["public","private"].includes(e.id().toLowerCase()):"")),1===p.length&&(c(`Workspace used: ${p[0].uri}`,"white"),r=l(p[0]));const d=e.createElement("table");d.setAttribute("style","border-collapse:separate; border-spacing: 0.5em;"),s.appendChild(d),s.appendChild(e.createElement("hr"));const m=s.appendChild(e.createElement("p"));m.setAttribute("style",Ke.commentStyle),m.textContent=`Where would you like to store the data for the ${i}?\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.`;const f=s.appendChild(e.createElement("input"));f.setAttribute("type","text"),f.setAttribute("style",Ke.textInputStyle),f.size=80,f.label="base URL",f.autocomplete="on",r&&(f.value=r),t.baseField=f,s.appendChild(e.createElement("br"));const h=s.appendChild(e.createElement("button"));let x,y,w,C,E,k,A;h.setAttribute("style",Ke.buttonStyle),h.textContent=`Start new ${i} at this URI`,h.addEventListener("click",function(e){let t=f.value.replace(" ","%20");"/"!==t.slice(-1)&&(t+="/"),n(null,t)}),p=p.filter(function(e){return!v.solidLogicSingleton.store.holds(e,b.rdf("type"),b.space("MasterWorkspace"))});const _="height: 3em; margin: 1em; padding: 1em white; border-radius: 0.3em;",T=`${_}border: 0px;`;for(let t=0;t<p.length;t++){if(E=p[t],C=e.createElement("tr"),0===t&&(x=e.createElement("td"),x.setAttribute("rowspan",`${p.length}`),x.textContent="Choose a workspace for this:",x.setAttribute("style","vertical-align:middle;"),C.appendChild(x)),y=e.createElement("td"),k=v.solidLogicSingleton.store.anyValue(E,b.ui("style")),!k){const e=`#${(16777215&function(e){return e.split("").reduce(function(e,t){return(e=(e<<5)-e+t.charCodeAt(0))&e},0)}(E.uri)|12632256).toString(16)}`;k=`color: black ; background-color: ${e};`}y.setAttribute("style",T+k),C.target=E.uri;let i=v.solidLogicSingleton.store.any(E,b.rdfs("label"));i||(i=E.uri.split("/").slice(-1)[0]||E.uri.split("/").slice(-2)[0]),y.textContent=i||"???",C.appendChild(y),0===t&&(w=e.createElement("td"),w.setAttribute("rowspan",`${p.length}1`),w.setAttribute("style","width:50%;"),C.appendChild(w)),d.appendChild(C),A=v.solidLogicSingleton.store.any(E,b.rdfs("comment")),A=A?A.value:"Use this workspace",y.addEventListener("click",function(t){w.textContent=A?A.value:"",w.setAttribute("style",T+k);const i=e.createElement("button");i.textContent="Continue";const a=l(E);f.value=a,i.addEventListener("click",function(e){i.disabled=!0,n(E,a),i.textContent="----\x3e"},!0),w.appendChild(i)},!0)}const S=e.createElement("tr");y=e.createElement("td"),y.setAttribute("style",_),y.textContent="+ Make a new workspace",y.addEventListener("click",async function(n){const i=d.appendChild(e.createElement("tr")).appendChild(e.createElement("td"));i.setAttribute("colspan","3"),i.style.padding="0.5em";const a=encodeURI(await Ut(e,v.solidLogicSingleton.store,i,b.solid("URL"),b.space("Workspace"),"Workspace")),o=Ei(t.preferencesFile),s=[(0,g.st)(t.me,b.space("workspace"),o,t.preferencesFile),(0,g.st)(o,b.space("uriPrefix"),a,t.preferencesFile)];if(!v.solidLogicSingleton.store.updater)throw new Error("store has no updater");await v.solidLogicSingleton.store.updater.update([],s)}),S.appendChild(y),d.appendChild(S)}).catch(e=>{s.appendChild(nt(r.dom,e))}),s}function Gi(e,t,n){const i=function(e,t){n(e,t)},a=e.createElement("div"),o=e.createElement("button");return o.setAttribute("type","button"),a.appendChild(o),o.innerHTML=`Make new ${t.noun}`,o.addEventListener("click",n=>{a.appendChild(Vi(e,t,i))},!1),a.appendChild(o),a}async function Wi(){const e=v.authSession.info;if(!e?.isLoggedIn||!e?.webId)return[];const t=v.authn.currentUser();if(!t)return[];try{const{me:e,preferencesFile:n,preferencesFileError:i}=await Di({me:t});if(!n||i)throw new Error(i||"Unable to load user preferences file.");return v.solidLogicSingleton.store.each(e,b.rdf("type"),null,n.doc())}catch(e){xe.R8("Unable to fetch your preferences - this was the error: ",e)}return[]}async function Ji(e){const t=await Wi();return e.filter(e=>function(e,t){const n=e.audience||[];return n.reduce((e,n)=>e&&!!t.find(e=>e.equals(n)),!0)}(e,t))}v.authSession.events.on("logout",async()=>{const e=window.localStorage.getItem("loginIssuer");if(e)try{v.solidLogicSingleton.store.updater.flagAuthorizationMetadata();const t=new URL(e);t.pathname="/.well-known/openid-configuration";const n=await fetch(t.toString());if(200===n.status){const e=await n.json();e&&e.end_session_endpoint&&await fetch(e.end_session_endpoint,{credentials:"include"})}}catch(e){}window.location.reload()});class Qi{rootElement;barElement;isExpanded=!1;constructor(e){this.groupList=e,this.rootElement=e.controller.dom.createElement("div"),this.barElement=e.controller.dom.createElement("div")}render(){return this.rootElement.innerHTML="",this.rootElement.appendChild(this.renderAddButton()),this.rootElement.appendChild(this.barElement),this.rootElement}renderAddButton(){return Dt(this.groupList.controller.dom,`${it.Pt.iconBase}noun_34653_green.svg`,"Add ...",()=>{this.toggleBar(),this.renderBar()})}renderBar(){this.barElement.innerHTML="",this.isExpanded&&(this.barElement.appendChild(this.renderPersonButton()),this.barElement.appendChild(this.renderGroupButton()),this.barElement.appendChild(this.renderPublicButton()),this.barElement.appendChild(this.renderAuthenticatedAgentButton()),this.barElement.appendChild(this.renderBotButton()),this.barElement.appendChild(this.renderAppsButton()))}renderSimplifiedBar(e){Array.from(this.barElement.children).filter(t=>t!==e).forEach(e=>this.barElement.removeChild(e))}renderPersonButton(){return Dt(this.groupList.controller.dom,it.Pt.iconBase+St["vcard:Individual"],"Add Person",e=>{this.renderSimplifiedBar(e.target),this.renderNameForm(b.vcard("Individual"),"person").then(e=>this.addPerson(e)).then(()=>this.renderCleanup()).catch(e=>this.groupList.controller.renderStatus(e))})}renderGroupButton(){return Dt(this.groupList.controller.dom,it.Pt.iconBase+St["vcard:Group"],"Add Group",e=>{this.renderSimplifiedBar(e.target),this.renderNameForm(b.vcard("Group"),"group").then(e=>this.addGroup(e)).then(()=>this.renderCleanup()).catch(e=>this.groupList.controller.renderStatus(e))})}renderNameForm(e,t){return Ut(this.groupList.controller.dom,this.groupList.store,this.barElement,b.vcard("URI"),e,t)}renderPublicButton(){return Dt(this.groupList.controller.dom,it.Pt.iconBase+St["foaf:Agent"],"Add Everyone",()=>this.addAgent(b.foaf("Agent").uri).then(()=>this.groupList.controller.renderTemporaryStatus("Adding the general public to those who can read. Drag the globe to a different level to give them more access.")).then(()=>this.renderCleanup()))}renderAuthenticatedAgentButton(){return Dt(this.groupList.controller.dom,`${it.Pt.iconBase}noun_99101.svg`,"Anyone logged In",()=>this.addAgent(b.acl("AuthenticatedAgent").uri).then(()=>this.groupList.controller.renderTemporaryStatus("Adding anyone logged in to those who can read. Drag the ID icon to a different level to give them more access.")).then(()=>this.renderCleanup()))}renderBotButton(){return Dt(this.groupList.controller.dom,it.Pt.iconBase+"noun_Robot_849764.svg","A Software Agent (bot)",e=>{this.renderSimplifiedBar(e.target),this.renderNameForm(b.schema("Application"),"bot").then(e=>this.addBot(e)).then(()=>this.renderCleanup())})}renderAppsButton(){return Dt(this.groupList.controller.dom,`${it.Pt.iconBase}noun_15177.svg`,"A Web App (origin)",e=>{this.renderSimplifiedBar(e.target);const t={div:this.barElement,dom:this.groupList.controller.dom},n=this.renderAppsTable(t).catch(e=>this.groupList.controller.renderStatus(e));this.renderAppsView();const i=this.renderNameForm(b.schema("WebApplication"),"webapp domain").then(e=>this.getOriginFromName(e));Promise.race([n,i]).then(e=>{e&&this.groupList.addNewURI(e)}).then(()=>this.renderCleanup())})}renderAppsView(){const e=this.groupList.controller.context.session.paneRegistry.byName("trustedApplications");if(e){const t=e.render(null,this.groupList.controller.context);t.setAttribute("style",Ke.trustedAppController);const n=Ot(this.groupList.controller.dom,()=>this.renderCleanup());n.setAttribute("style",Ke.trustedAppCancelButton),t.insertBefore(n,t.firstChild),this.barElement.appendChild(t)}}async renderAppsTable(e){await Oi(e);const t=this.groupList.store.each(e.me,b.acl("trustedApp")),n=t.flatMap(e=>this.groupList.store.each(e,b.acl("origin")));return this.barElement.appendChild(this.groupList.controller.dom.createElement("p")).textContent=`You have ${n.length} selected web apps.`,new Promise((e,n)=>{const i=this.barElement.appendChild(this.groupList.controller.dom.createElement("table"));i.setAttribute("style",Ke.trustedAppAddApplicationsTable),t.forEach(t=>{const a=this.groupList.store.any(t,b.acl("origin"));a||n(new Error(`Unable to pick app: ${t.value}`));const o=Ft(this.groupList.controller.dom,b.acl("origin"),a,{}),s=this.groupList.controller.dom.createElement("table"),r=s.appendChild(this.groupList.controller.dom.createElement("tr"));r.appendChild(this.groupList.controller.dom.createElement("td")).appendChild(o);r.appendChild(this.groupList.controller.dom.createElement("td")).textContent=`Give access to ${this.groupList.controller.noun} ${F(this.groupList.controller.subject)}?`;r.appendChild(this.groupList.controller.dom.createElement("td")).appendChild(Mt(this.groupList.controller.dom,()=>e(a.value))),i.appendChild(s)})})}renderCleanup(){this.renderBar(),this.groupList.render()}async addPerson(e){if(!e)return this.toggleBar();if(!e.match(/^https?:/i))return Promise.reject(new Error("Not a http URI"));xe.Rm(`Adding to ACL person: ${e}`),await this.groupList.addNewURI(e),this.toggleBar()}async addGroup(e){if(!e)return this.toggleBar();if(!e.match(/^https?:/i))return Promise.reject(new Error("Not a http URI"));xe.Rm("Adding to ACL group: "+e),await this.groupList.addNewURI(e),this.toggleBar()}async addAgent(e){await this.groupList.addNewURI(e),this.toggleBar()}async addBot(e){if(!e)return this.toggleBar();if(!e.match(/^https?:/i))return Promise.reject(new Error("Not a http URI"));xe.Rm("Adding to ACL bot: "+e),await this.groupList.addNewURI(e),this.toggleBar()}async getOriginFromName(e){if(!e)return Promise.resolve();if(!e.match(/^([a-z0-9]+(-[a-z0-9]+)*\.)+[a-z]{2,}$/i))return Promise.reject(new Error("Not a domain name"));const t="https://"+e;return xe.Rm("Adding to ACL origin: "+t),this.toggleBar(),t}toggleBar(){this.isExpanded=!this.isExpanded}}const Zi=b.acl,Yi={13:"Owners",9:"Owners (write locked)",5:"Editors",3:"Posters",2:"Submitters",1:"Viewers"},Ki={13:!0,5:!0,3:!0,2:!0,1:!0},Xi={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"};class ea{defaults;byCombo;aclMap;addAgentButton;rootElement;_store;constructor(e,t,n,i,a={}){this.doc=e,this.aclDoc=t,this.controller=n,this._options=a,this.defaults=this._options.defaults||!1,this._store=i,this.aclMap=Ce(e,0,i,this.defaults),this.byCombo=_e(this.aclMap),this.addAgentButton=new Qi(this),this.rootElement=this.controller.dom.createElement("div"),this.rootElement.setAttribute("style",Ke.accessGroupList)}get store(){return this._store}set store(e){this._store=e,this.aclMap=Ce(this.doc,this.aclDoc,e,this.defaults),this.byCombo=_e(this.aclMap)}render(){return this.rootElement.innerHTML="",this.renderGroups().forEach(e=>this.rootElement.appendChild(e)),this.controller.isEditable&&this.rootElement.appendChild(this.addAgentButton.render()),this.rootElement}renderGroups(){const e=[];for(let t=15;t>0;t--){const n=ta(t);(this.controller.isEditable&&Ki[t]||this.byCombo[n])&&e.push(this.renderGroup(t,n))}return e}renderGroup(e,t){const n=this.controller.dom.createElement("div");n.setAttribute("style",Ke.accessGroupListItem),Xe(n,e=>this.handleDroppedUris(e,t).then(()=>this.controller.render()).catch(e=>this.controller.renderStatus(e)));return this.renderGroupElements(e,t).forEach(e=>n.appendChild(e)),n}renderGroupElements(e,t){const n=this.controller.dom.createElement("div");if(n.setAttribute("style",Ke.group),this.controller.isEditable)switch(e){case 1:n.setAttribute("style",Ke.group1);break;case 2:n.setAttribute("style",Ke.group2);break;case 3:n.setAttribute("style",Ke.group3);break;case 5:n.setAttribute("style",Ke.group5);break;case 9:n.setAttribute("style",Ke.group9);break;case 13:n.setAttribute("style",Ke.group13);break;default:n.setAttribute("style",Ke.group)}n.innerText=Yi[e]||function(e){let t="";const n=["Read","Append","Write","Control"];for(let i=0;i<4;i++)e&1<<i&&(t+=n[i]);return t}(e);const i=this.controller.dom.createElement("div");if(i.setAttribute("style",Ke.group),this.controller.isEditable)switch(e){case 1:i.setAttribute("style",Ke.group1);break;case 2:i.setAttribute("style",Ke.group2);break;case 3:i.setAttribute("style",Ke.group3);break;case 5:i.setAttribute("style",Ke.group5);break;case 9:i.setAttribute("style",Ke.group9);break;case 13:i.setAttribute("style",Ke.group13);break;default:i.setAttribute("style",Ke.group)}const a=i.appendChild(this.controller.dom.createElement("table"));(this.byCombo[t]||[]).map(([e,n])=>this.renderAgent(a,t,e,n)).forEach(e=>a.appendChild(e));const o=this.controller.dom.createElement("div");if(o.setAttribute("style",Ke.group),this.controller.isEditable)switch(e){case 1:o.setAttribute("style",Ke.group1);break;case 2:o.setAttribute("style",Ke.group2);break;case 3:o.setAttribute("style",Ke.group3);break;case 5:o.setAttribute("style",Ke.group5);break;case 9:o.setAttribute("style",Ke.group9);break;case 13:o.setAttribute("style",Ke.group13);break;default:o.setAttribute("style",Ke.group)}return o.innerText=Xi[e]||"Unusual combination",[n,i,o]}renderAgent(e,t,n,i){const a=Ft(this.controller.dom,Zi(n),(0,g.sym)(i),this.controller.isEditable?{deleteFunction:()=>this.deleteAgent(t,n,i).then(()=>e.removeChild(a)).catch(e=>this.controller.renderStatus(e))}:{});return a}async deleteAgent(e,t,n){const i=this.byCombo[e]||[],a=i.find(([e,i])=>e===t&&i===n);a&&i.splice(i.indexOf(a),1),await this.controller.save()}async addNewURI(e){await this.handleDroppedUri(e,ta(1)),await this.controller.save()}async handleDroppedUris(e,t){try{await Promise.all(e.map(e=>this.handleDroppedUri(e,t))),await this.controller.save()}catch(e){return Promise.reject(e)}}async handleDroppedUri(e,t,n=!1){const i=function(e,t){const n=(0,g.sym)(e),i=t.findTypeURIs(n);for(const e in i)xe.Rm(" drop object type includes: "+e);if(e.startsWith("http")&&3===e.split("/").length)return{pred:"origin",obj:n};if(e.startsWith("http")&&4===e.split("/").length&&e.endsWith("/"))return xe.Rm("Assuming final slash on dragged origin URI was unintended!"),{pred:"origin",obj:(0,g.sym)(e.slice(0,-1))};if(b.vcard("WebID").uri in i)return{pred:"agent",obj:n};if(b.vcard("Group").uri in i)return{pred:"agentGroup",obj:n};if(n.sameTerm(b.foaf("Agent"))||n.sameTerm(b.acl("AuthenticatedAgent"))||n.sameTerm(b.rdf("Resource"))||n.sameTerm(b.owl("Thing")))return{pred:"agentClass",obj:n};if(b.vcard("Individual").uri in i||b.foaf("Person").uri in i||b.foaf("Agent").uri in i){const e=t.any(n,b.foaf("preferredURI"));return e?{pred:"agent",obj:(0,g.sym)(e)}:{pred:"agent",obj:n}}if(b.solid("AppProvider").uri in i)return{pred:"origin",obj:n};if(b.solid("AppProviderClass").uri in i)return{pred:"originClass",obj:n};return xe.Rm(" Triage fails for "+e),null}(e,this.store),a=(0,g.sym)(e);if(!i&&!n){xe.Rm(` Not obvious: looking up dropped thing ${a}`);try{await(this._store?.fetcher?.load(a.doc()))}catch(e){const t=`Ignore error looking up dropped thing: ${e}`;return xe.z3(t),Promise.reject(new Error(t))}return this.handleDroppedUri(e,t,!0)}if(!i){const t=Object.keys(this.store.findTypeURIs(a)),n=`Error: Failed to add access target: ${e} is not a recognized ACL target type. Expected one of: vcard:WebID, vcard:Group, foaf:Person, foaf:Agent, solid:AppProvider, solid:AppProviderClass, or recognized ACL classes. Hint: try dropping a WebID profile URI, a vcard:Group URI, or a web app origin.`+(t.length>0?`Detected RDF types: ${t.join(", ")}`:"No RDF type was detected for this URI.");return xe.z3(n),Promise.reject(new Error(n))}this.setACLCombo(t,e,i,this.controller.subject)}setACLCombo(e,t,n,i){e in this.byCombo||(this.byCombo[e]=[]),this.removeAgentFromCombos(t),this.byCombo[e].push([n.pred,n.obj.uri]),xe.Rm(`ACL: setting access to ${i} by ${n.pred}: ${n.obj}`)}removeAgentFromCombos(e){for(let t=0;t<16;t++){const n=this.byCombo[ta(t)];if(n)for(let t=0;t<n.length;t++)for(;t<n.length&&n[t][1]===e;)n.splice(t,1)}}}function ta(e){const t=["Read","Append","Write","Control"],n=[];for(let i=0;i<4;i++)e&1<<i&&n.push("http://www.w3.org/ns/auth/acl#"+t[i]);return n.sort(),n.join("\n")}class na{mainCombo;defaultsCombo;isContainer;defaultsDiffer;rootElement;isUsingDefaults;constructor(e,t,n,i,a,o,s,r,c,l,p,u){if(this.subject=e,this.noun=t,this.context=n,this.statusElement=i,this.targetIsProtected=a,this.targetDoc=o,this.targetACLDoc=s,this.defaultHolder=r,this.defaultACLDoc=c,this.prospectiveDefaultHolder=l,this.store=p,this.dom=u,this.rootElement=u.createElement("div"),this.rootElement.setAttribute("style",Ke.aclGroupContent),this.isContainer="/"===o.uri.slice(-1),r&&c){this.isUsingDefaults=!0;const e=we(this.targetDoc,s,r,c);this.mainCombo=new ea(o,s,this,e,{defaults:this.isContainer}),this.defaultsCombo=null,this.defaultsDiffer=!1}else this.isUsingDefaults=!1,this.mainCombo=new ea(o,s,this,p),this.defaultsCombo=new ea(o,s,this,p,{defaults:this.isContainer}),this.defaultsDiffer=!Ee(this.mainCombo.aclMap,this.defaultsCombo.aclMap)}get isEditable(){return!this.isUsingDefaults}render(){if(this.rootElement.innerHTML="",this.isUsingDefaults){if(this.renderStatus(`The sharing for this ${this.noun} is the default for folder `),this.defaultHolder){const e=this.statusElement.appendChild(this.dom.createElement("a"));e.href=this.defaultHolder.uri,e.innerText=ra(this.defaultHolder)}}else!this.defaultsDiffer&&this.isContainer?this.renderStatus("This is also the default for things in this folder."):this.renderStatus("");return this.rootElement.appendChild(this.mainCombo.render()),this.defaultsCombo&&this.defaultsDiffer?(this.rootElement.appendChild(this.renderRemoveDefaultsController()),this.rootElement.appendChild(this.defaultsCombo.render())):this.isEditable&&this.isContainer&&this.rootElement.appendChild(this.renderAddDefaultsController()),!this.targetIsProtected&&this.isUsingDefaults?this.rootElement.appendChild(this.renderAddAclsController()):this.targetIsProtected||this.rootElement.appendChild(this.renderRemoveAclsController()),this.rootElement}renderRemoveAclsController(){const e=this.dom.createElement("button");return e.innerText=`Remove custom sharing settings for this ${this.noun} -- just use default${this.prospectiveDefaultHolder?` for ${F(this.prospectiveDefaultHolder)}`:""}`,e.setAttribute("style",Ke.bigButton),e.addEventListener("click",()=>this.removeAcls().then(()=>this.render()).catch(e=>this.renderStatus(e))),e}renderAddAclsController(){const e=this.dom.createElement("button");return e.innerText=`Set specific sharing for this ${this.noun}`,e.setAttribute("style",Ke.bigButton),e.addEventListener("click",()=>this.addAcls().then(()=>this.render()).catch(e=>this.renderStatus(e))),e}renderAddDefaultsController(){const e=this.dom.createElement("div");e.setAttribute("style",Ke.defaultsController);const t=e.appendChild(this.dom.createElement("div"));t.innerText="Sharing for things within the folder currently tracks sharing for the folder.",t.setAttribute("style",Ke.defaultsControllerNotice);const n=e.appendChild(this.dom.createElement("button"));return n.innerText="Set the sharing of folder contents separately from the sharing for the folder",n.setAttribute("style",Ke.bigButton),n.addEventListener("click",()=>this.addDefaults().then(()=>this.render())),e}renderRemoveDefaultsController(){const e=this.dom.createElement("div");e.setAttribute("style",Ke.defaultsController);const t=e.appendChild(this.dom.createElement("div"));t.innerText="Access to things within this folder:",t.setAttribute("style",Ke.defaultsControllerNotice);const n=e.appendChild(this.dom.createElement("button"));return n.innerText="Set default for folder contents to just track the sharing for the folder",n.setAttribute("style",Ke.bigButton),n.addEventListener("click",()=>this.removeDefaults().then(()=>this.render()).catch(e=>this.renderStatus(e))),e}renderTemporaryStatus(e){this.statusElement.setAttribute("style",Ke.aclControlBoxStatusRevealed),this.statusElement.innerText=e,this.statusElement.setAttribute("style",Ke.temporaryStatusInit),setTimeout(()=>{this.statusElement.setAttribute("style",Ke.temporaryStatusEnd)}),setTimeout(()=>{this.statusElement.innerText=""},5e3)}renderStatus(e){e||this.statusElement.setAttribute("style",Ke.aclControlBoxStatusRevealed),this.statusElement.innerText=e}async addAcls(){if(!this.defaultHolder||!this.defaultACLDoc){const e="Unable to find defaults to copy";return xe.z3(e),Promise.reject(e)}we(this.targetDoc,this.targetACLDoc,this.defaultHolder,this.defaultACLDoc).statements.forEach(e=>this.store.add(e.subject,e.predicate,e.object,this.targetACLDoc));try{return await this.store.fetcher.putBack(this.targetACLDoc),this.isUsingDefaults=!1,Promise.resolve()}catch(e){const t=` Error writing back access control file! ${e}`;return xe.z3(t),Promise.reject(t)}}async addDefaults(){this.defaultsCombo=new ea(this.targetDoc,this.targetACLDoc,this,this.store,{defaults:!0}),this.defaultsDiffer=!0}async removeAcls(){try{await this.store.fetcher.delete(this.targetACLDoc.uri,{}),this.isUsingDefaults=!0;try{this.prospectiveDefaultHolder=await Be(this.targetDoc.uri)}catch(e){xe.R8(e)}}catch(e){const t=`Error deleting access control file: ${this.targetACLDoc}: ${e}`;return xe.z3(t),Promise.reject(t)}}async removeDefaults(){const e=this.defaultsCombo;try{this.defaultsCombo=null,this.defaultsDiffer=!1,await this.save()}catch(t){return this.defaultsCombo=e,this.defaultsDiffer=!0,xe.z3(t),Promise.reject(t)}}save(){const e=(0,g.graph)();this.isContainer?this.defaultsCombo&&this.defaultsDiffer?(Se(e,this.targetDoc,this.mainCombo.byCombo,this.targetACLDoc,!0),Se(e,this.targetDoc,this.defaultsCombo.byCombo,this.targetACLDoc,!1,!0)):Se(e,this.targetDoc,this.mainCombo.byCombo,this.targetACLDoc,!0,!0):Se(e,this.targetDoc,this.mainCombo.byCombo,this.targetACLDoc,!0),e.fetcher=(0,g.fetcher)(e,{fetch:this.store.fetcher._fetch});const t=e.updater||new g.UpdateManager(e);return new Promise((n,i)=>{t.put(this.targetACLDoc,e.statementsMatching(void 0,void 0,void 0,this.targetACLDoc),"text/turtle",(t,a,o)=>{if(!a)return i(new Error(`ACL file save failed: ${o}`));this.store.fetcher.unload(this.targetACLDoc),this.store.add(e.statements),this.store.fetcher.requested[this.targetACLDoc.uri]="done",this.mainCombo.store=this.store,this.defaultsCombo&&(this.defaultsCombo.store=this.store),this.defaultsDiffer=!!this.defaultsCombo&&!Ee(this.mainCombo.aclMap,this.defaultsCombo.aclMap),xe.Rm("ACL modification: success!"),n()})})}}let ia=window;const aa=Symbol("prevent double triggering of drop event");function oa(e){e.stopPropagation(),e.preventDefault()}function sa(e){e.dataTransfer.files.length>0&&(ia.confirm("Are you sure you want to drop this file here? (Cancel opens it in a new tab)")||(e.stopPropagation(),e.preventDefault(),(0,xe.Rm)("@@@@ document-level DROP suppressed: "+e.dataTransfer.dropEffect)))}function ra(e){let t=e.uri;"/"===t.slice(-1)&&(t=t.slice(0,-1));const n=t.lastIndexOf("/");return n>=0&&(t=t.slice(n+1)),t||"/"}const ca={adoptACLDefault:we,readACL:Ce,sameACL:Ee,ACLunion:ke,loadUnionACL:Ae,ACLbyCombination:_e,makeACLGraph:Te,makeACLGraphbyCombo:Se,ACLToString:function(e){return je(_e(e))},comboToString:je,makeACLString:function(e,t,n){const i=(0,g.graph)();return Te(i,e,t,n),(0,g.serialize)(n,i,n.uri,"text/turtle")||""},putACLObject:Le,putACLbyCombo:Re,fixIndividualCardACL:function(e,t,n){const i=ye.each(void 0,b.vcard("hasMember"),e);i?Ne(e,i,t,n):(t("This card is in no groups"),n(!0))},fixIndividualACL:Ne,setACL:function(e,t,n){const i=ye.any(e,v.ACL_LINK);if(!ye.fetcher)throw new Error("Store has no fetcher");i?ye.fetcher.webOperation("PUT",i.value,{data:t,contentType:"text/turtle"}).then(e=>{n(e.ok,e.error||"")}):ye.fetcher.nowOrWhenFetched(e,void 0,function(i,a){if(!i)return n(i,"Gettting headers for ACL: "+a);const o=ye.any(e,v.ACL_LINK);if(o){if(!ye.fetcher)throw new Error("Store has no fetcher");ye.fetcher.webOperation("PUT",o.value,{data:t,contentType:"text/turtle"}).then(e=>{n(e.ok,e.error||"")})}else n(!1,"No Link rel=ACL header for "+e)})},getACLorDefault:Ie,getACL:$e},la={preventBrowserDropEvents:function(e){if((0,xe.Rm)("preventBrowserDropEvents called."),void 0!==ia){if(ia[aa])return;ia[aa]=!0}e.addEventListener("drop",sa,!1),e.addEventListener("dragenter",oa,!1),e.addEventListener("dragover",oa,!1)},shortNameForFolder:ra,ACLControlBox5:function(e,t,n,i){const a=t.dom,o=e.doc(),s=a.createElement("div");s.setAttribute("style",Ke.aclControlBoxContainer);const r=s.appendChild(a.createElement("h1"));r.textContent=`Sharing for ${n} ${F(e)}`,r.setAttribute("style",Ke.aclControlBoxHeader);const c=s.appendChild(a.createElement("div"));c.setAttribute("style",Ke.aclControlBoxStatus);try{(async function(e,t,n,i,a,o,s){return new Promise((r,c)=>Ie(e,async(e,l,p,u,d,m)=>{if(!e)return c(new Error(`Error reading ${l?"":" default "}ACL. status ${p}: ${u}`));const f=function(e){const t=e.uri.split("#")[0],n=t.slice(0,-1).lastIndexOf("/"),i=t.indexOf("//");return i>=0&&n<i+2||n<0?null:t.slice(0,n+1)}(p),h=function(e,t,n){return n.holds(e,b.rdf("type"),b.space("Storage"),t)}(p,u,t)||function(e){return e.uri===e.site().uri}(p);if(!h&&f)try{const e=await Be(f);return r(g(e))}catch(e){(0,xe.R8)(e)}return r(g());function g(e){return new na(n,i,a,s,h,p,u,d,m,e,t,o)}}))})(o,i,e,n,t,a,c).then(e=>s.appendChild(e.render()))}catch(e){c.innerText=e}return s}},pa=v.solidLogicSingleton.store;const ua={newThingUI:function(e,t,n){const i=e.dom,a=e.div;if(e.me&&!e.me.uri)throw new Error("newThingUI: Invalid userid: "+e.me);const o="padding: 0.7em; width: 2em; height: 2em;",s=a.appendChild(i.createElement("img"));let r=!1;s.setAttribute("src",it.Pt.iconBase+"noun_34653_green.svg"),s.setAttribute("style",o),s.setAttribute("title","Add another tool");const c=function(e){const t=a.appendChild(i.createElement("pre"));t.setAttribute("style","background-color: pink"),t.appendChild(i.createTextNode(e))};function l(e){for(let t=0;t<u.length;t++){let n=o+e;u[t].disabled&&(n+="opacity: 0.3;"),u[t].setAttribute("style",n)}}function p(e){r=!r,s.setAttribute("style",o+(r?"background-color: yellow;":"")),l(r?"":"display: none;")}s.addEventListener("click",p);const u=[],d=Object.values(n).filter(e=>e.mintNew),m=d.reduce((e,t)=>(t.mintClass&&(e[t.mintClass.uri]=(e[t.mintClass.uri]||0)+1),e),{});d.forEach(n=>{const a=e.div.appendChild(i.createElement("img"));a.setAttribute("src",n.icon);const s=n.mintClass?m[n.mintClass.uri]>1?`${F(n.mintClass)} (using ${n.name} pane)`:F(n.mintClass):n.name+" @@";a.setAttribute("title","Make new "+s),a.setAttribute("style",o+"display: none;"),u.push(a),a.disabled||a.addEventListener("click",function(r){var u;!function(e){l("display: none;"),e.setAttribute("style",o+"background-color: yellow;")}(a),u={event:r,folder:e.folder||null,iconEle:a,pane:n,noun:s,noIndexHTML:!0,div:e.div,me:e.me,dom:e.dom,refreshTarget:e.refreshTarget},new Promise(function(n,a){let o;function s(n,o){Oi(e).then(e=>{const s=Object.assign({newBase:o,folder:u.folder||void 0,workspace:n},u);for(const e in u)s[e]=u[e];xe.Rm(`newThingUI: Minting new ${s.pane.name} at ${s.newBase}`),u.pane.mintNew(t,s).then(function(e){if(!e||!e.newInstance)throw new Error("Cannot mint new - missing newInstance");if(e.folder){const t=e.newInstance.uri.slice(e.folder.uri.length).includes("/");xe.Rm(" new thing is packge? "+t),t?pa.add(e.folder,b.ldp("contains"),pa.sym(e.newBase),e.folder.doc()):pa.add(e.folder,b.ldp("contains"),e.newInstance,e.folder.doc()),e.refreshTarget&&e.refreshTarget.refresh&&e.refreshTarget.refresh()}else{const t=u.div.appendChild(i.createElement("p"));t.setAttribute("style","font-size: 120%;"),t.innerHTML="Your <a target='_blank' href='"+e.newInstance.uri+"'><b>new "+u.noun+"</b></a> is ready to be set up. <br/><br/><a target='_blank' href='"+e.newInstance.uri+"'>Go to your new "+u.noun+".</a>"}p()}).catch(function(e){c(e),a(e)})},e=>{c("Error logging on: "+e)})}const r=u.pane;if(u.noun=r.mintClass?F(r.mintClass):r.name,u.appPathSegment=u.noun.slice(0,1).toUpperCase()+u.noun.slice(1),u.folder){const e=function(e){if(e){let t=u.folder.uri;t.endsWith("/")||(t+="/"),t=t+encodeURIComponent(e)+"/",s(null,t)}else p()};Ut(i,0,u.div,b.foaf("name"),null,u.noun).then(e)}else o=Vi(i,{noun:u.noun,appPathSegment:u.appPathSegment},s),u.div.appendChild(o)})})})}},da=v.solidLogicSingleton.store;const ma={matrixForQuery:function(e,t,n,i,a,o,s){const r=e.createElement("table"),c=e.createElement("tr");c.appendChild(e.createElement("td")).setAttribute("class","MatrixCorner"),r.appendChild(c),r.lastHeader=c;let l=[];const p=[],u=function(e,t,n,i){for(;e.firstChild;)e.removeChild(e.firstChild);e.setAttribute("style",""),e.style.textAlign="center",o.cellFunction?o.cellFunction(e,t,n,i):(e.textContent=F(i),e.setAttribute("style","padding: 0.3em")),delete e.old},d=function(t){const n=t.toNT();if(p[n])return p[n];const i=e.createElement("tr"),a=i.appendChild(e.createElement("td"));a.setAttribute("style","padding: 0.3em;"),a.textContent=F(t),"NamedNode"===t.termType&&da.fetcher.nowOrWhenFetched(t.uri.split("#")[0],void 0,function(e,n,i){e&&(a.textContent=F(t))});for(let n=0;n<l.length;n++)u(i.appendChild(e.createElement("td")),g.fromNT(l[n]),t,null);i.dataValueNT=n,p[n]=i;for(let e=r.lastHeader.nextSibling;e;e=e.nextSibling)if(n>e.dataValueNT&&o&&o.yDecreasing||n<e.dataValueNT&&(!o||!o.yDecreasing))return r.insertBefore(i,e);return r.appendChild(i)},m=function(t){const n=t.toNT();let i=null;for(let e=0;e<l.length;e++){if(l[e]===n)return e;if(n>l[e]&&o.xDecreasing||n<l[e]&&!o.xDecreasing){l=l.slice(0,e).concat([n]).concat(l.slice(e)),i=e;break}}null===i&&(i=l.length,l.push(n));for(let n=r.firstChild;n;n=n.nextSibling){const a=n.dataValueNT,o=e.createElement("td");if(o.style.textAlign="center",n===r.firstChild?o.textContent=F(t):u(o,t,g.fromNT(a),null),i===l.length-1)n.appendChild(o);else{let e=n.firstChild;for(let t=0;t<i+1;t++)e=e.nextSibling;n.insertBefore(o,e)}}return i},f=function(){let e,t;const n=[],i=[];if(o.set_y)for(let e=0;e<o.set_y.length;e++)i[o.set_y[e]]=!0;if(o.set_x)for(let e=0;e<o.set_x.length;e++)n[m(o.set_x[e])+1]=!0;for(let a=1;a<r.children.length;a++){e=r.children[a];for(let a=1;a<e.children.length;a++)if(t=e.children[a],t.old){const n=g.fromNT(e.dataValueNT),i=g.fromNT(l[a-1]);u(t,i,n,null)}else i[e.dataValueNT]=!0,n[a]=!0}for(let t=0;t<r.children.length;t++)if(e=r.children[t],t>0&&!i[e.dataValueNT])delete p[e.dataValueNT],r.removeChild(e);else for(let t=e.children.length-1;t>0;t--){const i=e.children[t];n[t]||e.removeChild(i)}const a=[];for(let e=0;e<l.length;e++)n[e+1]&&a.push(l[e]);l=a};r.refresh=function(){!function(){for(let e=1;e<r.children.length;e++){const t=r.children[e];for(let e=1;e<t.children.length;e++)t.children[e].old=!0}}(),da.query(t,h,void 0,f)};const h=function(e){const t=e[n.toString()],o=e[i.toString()],s=e[a.toString()],r=d(o),c=m(t),l=r.children[c+1];u(l,t,o,s)};if(o.set_y)for(let e=0;e<o.set_y.length;e++)d(o.set_y[e]);if(o.set_x)for(let e=0;e<o.set_x.length;e++)m(o.set_x[e]);return da.query(t,h,void 0,s),r}},fa=it.Pt.iconBase+"noun_Camera_1618446_000000.svg",ha=it.Pt.iconBase+"noun_479395.svg";function ga(e,t,n,i){const a=e.createElement("div");let o,s,r,c;const l=a.appendChild(e.createElement("table")),p=l.appendChild(e.createElement("tr")).appendChild(e.createElement("td"));p.setAttribute("colspan","4");const u=l.appendChild(e.createElement("tr"));u.appendChild(e.createElement("td")).appendChild(Ot(e)).addEventListener("click",e=>{b(),i(null)});const d=u.appendChild(e.createElement("td")).appendChild(Dt(e,ha,"Retake"));d.addEventListener("click",e=>{p.removeChild(c),h()}),d.style.visibility="collapse";const m=u.appendChild(e.createElement("td")).appendChild(Dt(e,it.Pt.iconBase+"noun_10636.svg","Snap"));m.addEventListener("click",function(){c=e.createElement("canvas"),c.setAttribute("width",Ke.canvasWidth),c.setAttribute("height",Ke.canvasHeight),c.setAttribute("style",Ke.controlStyle),p.appendChild(c);c.getContext("2d").drawImage(r,0,0,c.width,c.height),r.parentNode.removeChild(r),c.toBlob(e=>{const t=`got blob type ${e.type} size ${e.size}`;xe.Rm(t),o=n(),s=e,f.style.visibility="visible",d.style.visibility="visible",m.style.visibility="collapse"},"image/png")}),m.style.visibility="collapse";const f=u.appendChild(e.createElement("td")).appendChild(Mt(e));function h(){if(r=p.appendChild(e.createElement("video")),r.setAttribute("controls","1"),r.setAttribute("autoplay","1"),r.setAttribute("style",Ke.controlStyle),!navigator.mediaDevices)throw new Error("navigator.mediaDevices not available");navigator.mediaDevices.getUserMedia(g).then(e=>{r.srcObject=e,m.style.visibility="visible",f.style.visibility="collapse",d.style.visibility="collapse"})}f.addEventListener("click",e=>{!function(e,n){const a=e.type;xe.Rm("Putting "+e.size+" bytes of "+a+" to "+n),t.fetcher.webOperation("PUT",n.uri,{data:e,contentType:a}).then(e=>{xe.Rm("ok saved "+n),b(),i(n)},e=>{b(),alert(e)})}(s,o)}),f.style.visibility="collapse";const g={video:!0};function b(){r&&r.srcObject&&r.srcObject.getVideoTracks().forEach(e=>e.stop())}return h(),a}const ba={cameraCaptureControl:ga,cameraButton:function(e,t,n,i){const a=e.createElement("div"),o=Dt(e,fa,"Take picture");let s;async function r(e){a.removeChild(s),a.appendChild(o),i(e)}return a.appendChild(o),o.addEventListener("click",i=>{a.removeChild(o),s=ga(e,t,n,r),a.appendChild(s)}),a}},va={icons:it.Pt,ns:b,rdf:g,style:Ke,widgets:r};async function xa(e){return await v.store.fetcher.load(e),!(v.store.statementsMatching(null,b.dct("created"),null,e).length>0)}class ya{constructor(e,t,n){this.root=e,this.rootFolder=e.dir(),this.leafFileName=t||"index.ttl",this.membershipProperty=n||b.wf("leafObject")}leafDocumentFromDate(e){let t=e.toISOString().split("T")[0].replace(/-/g,"/");return t=this.root.dir().uri+t+"/"+this.leafFileName,v.store.sym(t)}dateFromLeafDocument(e){const t=this.rootFolder.uri.length,n=e.uri.slice(t,t+10).replace(/\//g,"-");return new Date(n)}async loadPrevious(e,t){async function n(e,i){function a(e){const t=e.uri.slice(0,-1).split("/").slice(-1)[0];return!!"0123456789".includes(t[0])}function o(e){return(e=e.filter(a)).sort(),t||e.reverse(),e.pop()}const s=e.dir();try{await v.store.fetcher.load(s);let n=v.store.each(s,b.ldp("contains"));n=n.filter(function(n){return!(t?n.uri>=e.uri:n.uri<=e.uri)});const i=o(n);if(i)return i}catch(e){if(!e.response||!e.response.status||404!==e.response.status)throw xe.Rm("*** Error NON 404 for chat parent file "+s),new Error(`*** ${e.message} for chat folder ${s}`);xe.Rm("Error 404 for chat parent file "+s)}if(0===i)return null;const r=await n(s,i-1);if(!r)return null;await v.store.fetcher.load(r);return o(v.store.each(r,b.ldp("contains")))}let i=this.leafDocumentFromDate(e).dir();for(;;){const t=await n(i,3);if(!t)return null;{const n=v.store.sym(t.uri+this.leafFileName),a=this.dateFromLeafDocument(n);if(!await xa(n))return a;e=a,i=this.leafDocumentFromDate(e).dir()}}}async firstLeaf(e){const t=g.graph(),n=new g.Fetcher(t);async function i(i){delete n.requested[i.uri],await n.load(i,{force:!0});let a=t.each(i,b.ldp("contains"));if(a=a.filter(function(e){const t=e.uri.slice(0,-1).split("/").slice(-1)[0];return!!"0123456789".includes(t[0])}),0===a.length)throw new Error(" @@@ No children to parent2 "+i);return a.sort(),e&&a.reverse(),a[0]}const a=await i(this.root.dir()),o=await i(a),s=await i(o),r=g.sym(s.uri+"chat.ttl");await n.load(r);const c=t.each(this.root,this.membershipProperty,null,r);if(0===c.length){const e=" INCONSISTENCY -- no chat leafObject in file "+r;throw xe.uP(e),new Error(e)}const l=c.map(e=>[t.any(e,b.dct("created")),e]);return l.sort(),e&&l.reverse(),l[0][1]}}function wa(e,t=""){if("number"!=typeof e){throw new TypeError(`${t&&`"${t}" `}expected number, got ${typeof e}`)}if(!Number.isSafeInteger(e)||e<0){throw new RangeError(`${t&&`"${t}" `}expected integer >= 0, got ${e}`)}}function Ca(e,t,n=""){const i=(a=e)instanceof Uint8Array||ArrayBuffer.isView(a)&&"Uint8Array"===a.constructor.name&&"BYTES_PER_ELEMENT"in a&&1===a.BYTES_PER_ELEMENT;var a;const o=e?.length,s=void 0!==t;if(!i||s&&o!==t){const a=(n&&`"${n}" `)+"expected Uint8Array"+(s?` of length ${t}`:"")+", got "+(i?`length=${o}`:"type="+typeof e);if(!i)throw new TypeError(a);throw new RangeError(a)}return e}function Ea(e,t=!0){if(e.destroyed)throw new Error("Hash instance has been destroyed");if(t&&e.finished)throw new Error("Hash#digest() has already been called")}function ka(...e){for(let t=0;t<e.length;t++)e[t].fill(0)}function Aa(e){return new DataView(e.buffer,e.byteOffset,e.byteLength)}function _a(e,t){return e<<32-t|e>>>t}const Ta=(()=>"function"==typeof Uint8Array.from([]).toHex&&"function"==typeof Uint8Array.fromHex)(),Sa=Array.from({length:256},(e,t)=>t.toString(16).padStart(2,"0"));function ja(e){if(Ca(e),Ta)return e.toHex();let t="";for(let n=0;n<e.length;n++)t+=Sa[e[n]];return t}const La=48,Ra=57,Na=65,Ia=70,$a=97,Ba=102;function Da(e){return e>=La&&e<=Ra?e-La:e>=Na&&e<=Ia?e-(Na-10):e>=$a&&e<=Ba?e-($a-10):void 0}function Oa(e){if("string"!=typeof e)throw new TypeError("hex string expected, got "+typeof e);if(Ta)try{return Uint8Array.fromHex(e)}catch(e){if(e instanceof SyntaxError)throw new RangeError(e.message);throw e}const t=e.length,n=t/2;if(t%2)throw new RangeError("hex string expected, got unpadded hex of length "+t);const i=new Uint8Array(n);for(let t=0,a=0;t<n;t++,a+=2){const n=Da(e.charCodeAt(a)),o=Da(e.charCodeAt(a+1));if(void 0===n||void 0===o){const t=e[a]+e[a+1];throw new RangeError('hex string expected, got non-hex character "'+t+'" at index '+a)}i[t]=16*n+o}return i}function Ma(e,t={}){const n=(t,n)=>e(n).update(t).digest(),i=e(void 0);return n.outputLen=i.outputLen,n.blockLen=i.blockLen,n.canXOF=i.canXOF,n.create=t=>e(t),Object.assign(n,t),Object.freeze(n)}function Ua(e=32){wa(e,"bytesLength");const t="object"==typeof globalThis?globalThis.crypto:null;if("function"!=typeof t?.getRandomValues)throw new Error("crypto.getRandomValues must be defined");if(e>65536)throw new RangeError(`"bytesLength" expected <= 65536, got ${e}`);return t.getRandomValues(new Uint8Array(e))}const Fa=e=>({oid:Uint8Array.from([6,9,96,134,72,1,101,3,4,2,e])});function Pa(e,t,n){return e&t^~e&n}function za(e,t,n){return e&t^e&n^t&n}class qa{blockLen;outputLen;canXOF=!1;padOffset;isLE;buffer;view;finished=!1;length=0;pos=0;destroyed=!1;constructor(e,t,n,i){this.blockLen=e,this.outputLen=t,this.padOffset=n,this.isLE=i,this.buffer=new Uint8Array(e),this.view=Aa(this.buffer)}update(e){Ea(this),Ca(e);const{view:t,buffer:n,blockLen:i}=this,a=e.length;for(let o=0;o<a;){const s=Math.min(i-this.pos,a-o);if(s===i){const t=Aa(e);for(;i<=a-o;o+=i)this.process(t,o);continue}n.set(e.subarray(o,o+s),this.pos),this.pos+=s,o+=s,this.pos===i&&(this.process(t,0),this.pos=0)}return this.length+=e.length,this.roundClean(),this}digestInto(e){Ea(this),function(e,t){Ca(e,void 0,"digestInto() output");const n=t.outputLen;if(e.length<n)throw new RangeError('"digestInto() output" expected to be of length >='+n)}(e,this),this.finished=!0;const{buffer:t,view:n,blockLen:i,isLE:a}=this;let{pos:o}=this;t[o++]=128,ka(this.buffer.subarray(o)),this.padOffset>i-o&&(this.process(n,0),o=0);for(let e=o;e<i;e++)t[e]=0;n.setBigUint64(i-8,BigInt(8*this.length),a),this.process(n,0);const s=Aa(e),r=this.outputLen;if(r%4)throw new Error("_sha2: outputLen must be aligned to 32bit");const c=r/4,l=this.get();if(c>l.length)throw new Error("_sha2: outputLen bigger than state");for(let e=0;e<c;e++)s.setUint32(4*e,l[e],a)}digest(){const{buffer:e,outputLen:t}=this;this.digestInto(e);const n=e.slice(0,t);return this.destroy(),n}_cloneInto(e){e||=new this.constructor,e.set(...this.get());const{blockLen:t,buffer:n,length:i,finished:a,destroyed:o,pos:s}=this;return e.destroyed=o,e.finished=a,e.length=i,e.pos=s,i%t&&e.buffer.set(n),e}clone(){return this._cloneInto()}}const Ha=Uint32Array.from([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]);const Va=Uint32Array.from([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]),Ga=new Uint32Array(64);class Wa extends qa{constructor(e){super(64,e,8,!1)}get(){const{A:e,B:t,C:n,D:i,E:a,F:o,G:s,H:r}=this;return[e,t,n,i,a,o,s,r]}set(e,t,n,i,a,o,s,r){this.A=0|e,this.B=0|t,this.C=0|n,this.D=0|i,this.E=0|a,this.F=0|o,this.G=0|s,this.H=0|r}process(e,t){for(let n=0;n<16;n++,t+=4)Ga[n]=e.getUint32(t,!1);for(let e=16;e<64;e++){const t=Ga[e-15],n=Ga[e-2],i=_a(t,7)^_a(t,18)^t>>>3,a=_a(n,17)^_a(n,19)^n>>>10;Ga[e]=a+Ga[e-7]+i+Ga[e-16]|0}let{A:n,B:i,C:a,D:o,E:s,F:r,G:c,H:l}=this;for(let e=0;e<64;e++){const t=l+(_a(s,6)^_a(s,11)^_a(s,25))+Pa(s,r,c)+Va[e]+Ga[e]|0,p=(_a(n,2)^_a(n,13)^_a(n,22))+za(n,i,a)|0;l=c,c=r,r=s,s=o+t|0,o=a,a=i,i=n,n=t+p|0}n=n+this.A|0,i=i+this.B|0,a=a+this.C|0,o=o+this.D|0,s=s+this.E|0,r=r+this.F|0,c=c+this.G|0,l=l+this.H|0,this.set(n,i,a,o,s,r,c,l)}roundClean(){ka(Ga)}destroy(){this.destroyed=!0,this.set(0,0,0,0,0,0,0,0),ka(this.buffer)}}class Ja extends Wa{A=0|Ha[0];B=0|Ha[1];C=0|Ha[2];D=0|Ha[3];E=0|Ha[4];F=0|Ha[5];G=0|Ha[6];H=0|Ha[7];constructor(){super(32)}}const Qa=Ma(()=>new Ja,Fa(1));
13
+ class ii{_data;_domElements;_event=()=>{};_itemTemplate;_multiselect;_noData;_noResults;_options=[];_placeholder;_select;_selectContainer;_selectedOptions=[];_tagTemplate;_textField;_valueField;_cross='\n <svg\n width="24"\n height="24"\n viewBox="0 0 24 24"\n fill="none"\n xmlns="http://www.w3.org/2000/svg"\n >\n <path\n d="M6.2253 4.81108C5.83477 4.42056 5.20161 4.42056 4.81108 4.81108C4.42056 5.20161 4.42056 5.83477 4.81108 6.2253L10.5858 12L4.81114 17.7747C4.42062 18.1652 4.42062 18.7984 4.81114 19.1889C5.20167 19.5794 5.83483 19.5794 6.22535 19.1889L12 13.4142L17.7747 19.1889C18.1652 19.5794 18.7984 19.5794 19.1889 19.1889C19.5794 18.7984 19.5794 18.1652 19.1889 17.7747L13.4142 12L19.189 6.2253C19.5795 5.83477 19.5795 5.20161 19.189 4.81108C18.7985 4.42056 18.1653 4.42056 17.7748 4.81108L12 10.5858L6.2253 4.81108Z"\n fill="currentColor"\n />\n </svg>\n ';constructor({data:e,itemTemplate:t,noData:n,noResults:i,placeholder:a,select:o,container:s,tagTemplate:r,textField:c,valueField:l}){this._data=e??[],this._itemTemplate=t??null,this._noData=n??"No data found.",this._noResults=i??"No results found.",this._placeholder=a??"Select...",this._select=o,this._selectContainer=s,this._tagTemplate=r??null,this._textField=c??null,this._valueField=l??null}init(){if(!this._select||"SELECT"!==this._select.nodeName)throw new Error(`The selector '${this._select}' did not select any valid select tag.`);if(this._itemTemplate&&0===this._data.length)throw new Error("itemTemplate must be initialized with data from the component settings");if(this._tagTemplate&&0===this._data.length)throw new Error("tagTemplate must be initialized with data from the component settings");this._options=this._data.length>0?this._getDataFromSettings():this._getDataFromSelectTag(),this._renderMultiselect(),this._renderOptionsList(),this._domElements={clear:this._multiselect.querySelector(".multiselect__clear-btn"),input:this._multiselect.querySelector(".multiselect__input"),optionsContainer:this._multiselect.querySelector(".multiselect__options"),optionsContainerList:this._multiselect.querySelector(".multiselect__options > ul"),options:{list:this._multiselect.querySelectorAll(".multiselect__options > ul > li"),find:function(e){for(let t=0;t<this.list.length;t++){const n=this.list[t];if(e(n))return n}},some:function(e){for(let t=0;t<this.list.length;t++){if(e(this.list[t],t))return!0}return!1}}},this._enableEventListenners(),this._initSelectedList()}subscribe(e){if("function"!=typeof e)throw new Error("parameter in the subscribe method is not a function");this._event=e}_addOptionToList(e,t){const n=`<span class="multiselect__selected" style="${ni.multiselect__selected}" data-value="${e.value}">${this._tagTemplate?this._processTemplate(this._tagTemplate,t):e.text}<span class="multiselect__remove-btn" style="${ni.multiselect__remove_btn}">${this._cross}</span></span>`;this._domElements.input.insertAdjacentHTML("beforebegin",n);const{lastElementChild:i}=this._multiselect.querySelector(`span[data-value="${e.value}"]`);i.addEventListener("click",()=>{const t=this._domElements.options.find(t=>t.dataset.value===e.value);this._handleOption(t)})}_clearSelection(){for(let e=0;e<this._selectedOptions.length;e++){const t=this._selectedOptions[e],n=this._domElements.options.find(e=>e.dataset.value===t.value);n.classList.remove("multiselect__options--selected"),n.setAttribute("style",ni.multiselect__options),this._removeOptionFromList(n.dataset.value)}this._selectedOptions=[],this._handleClearSelectionBtn(),this._handlePlaceholder(),this._dispatchEvent({action:"CLEAR_ALL_OPTIONS",selection:this._selectedOptions})}_closeList(){this._domElements.input.value="",this._domElements.optionsContainer.classList.remove("visible"),this._domElements.optionsContainer.setAttribute("style",ni.multiselect__options),this._filterOptions(""),this._removeAllArrowSelected()}_dispatchEvent(e){this._event(e)}_enableEventListenners(){document.addEventListener("mouseup",({target:e})=>{this._multiselect.contains(e)||(this._filterOptions(""),this._closeList(),this._handlePlaceholder())}),this._domElements.clear.addEventListener("click",()=>{this._clearSelection()});for(let e=0;e<this._domElements.options.list.length;e++){this._domElements.options.list[e].addEventListener("click",({target:e})=>{this._handleOption(e),this._closeList()})}this._domElements.input.addEventListener("focus",()=>{this._domElements.optionsContainer.classList.add("visible"),this._domElements.optionsContainer.setAttribute("style",ni.multiselect__options_visible)}),this._domElements.input.addEventListener("input",({target:{value:e}})=>{this._domElements.options.list.length>0&&this._filterOptions(e)}),this._domElements.input.addEventListener("keydown",e=>{this._handleArrows(e),this._handleBackspace(e),this._handleEnter(e)})}_filterOptions(e){const t=this._domElements.optionsContainer.classList.contains("visible"),n=e.toLowerCase();if(!t&&e.length>0&&(this._domElements.optionsContainer.classList.add("visible"),this._domElements.optionsContainer.setAttribute("style",ni.multiselect__options_visible)),this._domElements.options.list.length>0){for(let e=0;e<this._domElements.options.list.length;e++){const t=this._domElements.options.list[e];(this._itemTemplate?this._data[e][this._textField]:t.textContent).toLowerCase().substring(0,n.length)===n?this._domElements.optionsContainerList.appendChild(t):t.parentNode&&t.parentNode.removeChild(t)}const e=this._domElements.options.some((e,t)=>(this._itemTemplate?this._data[t][this._textField]:e.textContent).toLowerCase().substring(0,n.length)===n);this._showNoResults(!e)}}_generateId(e){let t="";const n="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";for(let i=0;i<e;i++)t+=n.charAt(Math.floor(62*Math.random()));return t}_getDataFromSelectTag(){const e=[],{options:t}=this._select;for(let n=0;n<t.length;n++){const i=t[n];e.push({text:i.text,value:i.value,selected:i.hasAttribute("selected")})}return e}_getDataFromSettings(){if(this._data.length>0&&this._valueField&&this._textField){const e="string"==typeof this._valueField,t="string"==typeof this._textField,n=[];if(!e||!t)throw new Error("textField and valueField must be of type string");for(let e=0;e<this._data.length;e++){const t=this._data[e];n.push({value:t[this._valueField],text:t[this._textField],selected:"boolean"==typeof t.selected&&t.selected})}return n}return null}_handleArrows(e){if(40===e.keyCode||38===e.keyCode){e.preventDefault();const t=this._domElements.optionsContainer.classList.contains("visible"),n=this._multiselect.querySelector(".multiselect__options > ul");if(t){let t=this._multiselect.querySelector(".multiselect__options ul li.arrow-selected");const i={ArrowUp:"previous",Up:"previous",ArrowDown:"next",Down:"next"};if(!t)return n.firstElementChild.classList.add("arrow-selected"),n.firstElementChild.setAttribute("style",ni.multiselect__options_ul_li_arrow_selected),void n.firstElementChild.scrollIntoView(!1);if(t.classList.remove("arrow-selected"),t.setAttribute("style",ni.multiselect__options_ul_li),t=t[i[e.key]+"ElementSibling"],!t)return t=n.children["next"===i[e.key]?0:n.children.length-1],t.classList.add("arrow-selected"),t.setAttribute("style",ni.multiselect__options_ul_li_arrow_selected),void this._scrollIntoView(n,t);t.classList.add("arrow-selected"),t.setAttribute("style",ni.multiselect__options_ul_li_arrow_selected),this._scrollIntoView(n,t)}else this._domElements.optionsContainer.classList.add("visible"),this._domElements.optionsContainer.setAttribute("style",ni.multiselect__options_visible),n.firstElementChild.classList.add("arrow-selected"),n.firstElementChild.setAttribute("style",ni.multiselect__options_ul_li_arrow_selected),n.firstElementChild.scrollIntoView(!1)}}_handleBackspace(e){if(8===e.keyCode&&""===e.target.value){const e=this._selectedOptions.length>0?this._selectedOptions[this._selectedOptions.length-1]:null;if(e){const t=this._multiselect.querySelector(`li[data-value="${e.value}"]`);this._handleOption(t),0===this._selectedOptions.length&&(this._domElements.optionsContainer.classList.remove("visible"),this._domElements.optionsContainer.setAttribute("style",ni.multiselect__options))}}}_handleClearSelectionBtn(){this._selectedOptions.length>0?this._domElements.clear.style.display="flex":this._domElements.clear.style.display="none"}_handleEnter(e){if(13===e.keyCode){const e=this._multiselect.querySelector(".multiselect__options ul li.arrow-selected");e&&(this._handleOption(e),this._closeList())}}_handleOption(e,t=!0){for(let n=0;n<this._selectedOptions.length;n++){if(this._selectedOptions[n].value===e.dataset.value)return e.classList.remove("multiselect__options--selected"),e.setAttribute("style",ni.multiselect__options),this._selectedOptions.splice(n,1),this._removeOptionFromList(e.dataset.value),this._handleClearSelectionBtn(),this._handlePlaceholder(),t&&this._dispatchEvent({action:"REMOVE_OPTION",value:e.dataset.value,selection:this._selectedOptions})}for(let n=0;n<this._options.length;n++){const i=this._options[n];if(i.value===e.dataset.value)return e.classList.add("multiselect__options--selected"),e.setAttribute("style",ni.multiselect__options_selected),this._selectedOptions=[...this._selectedOptions,i],this._addOptionToList(i,n),this._handleClearSelectionBtn(),this._handlePlaceholder(),t&&this._dispatchEvent({action:"ADD_OPTION",value:e.dataset.value,selection:this._selectedOptions})}}_handlePlaceholder(){this._domElements.input.placeholder=this._placeholder}_initSelectedList(){let e=!1;for(let t=0;t<this._options.length;t++){const n=this._options[t];if(n.selected){e=!0;const i=this._domElements.options.find(e=>e.dataset.value===n.value);i.classList.add("multiselect__options--selected"),i.setAttribute("style",ni.multiselect__options_selected),this._selectedOptions=[...this._selectedOptions,n],this._addOptionToList(n,t)}}e&&this._handleClearSelectionBtn(),this._handlePlaceholder()}_processTemplate(e,t){let n=e;const i=e.match(/\$\{(\w+)\}/g).map(e=>e.replace(/\$\{|\}/g,""));for(let e=0;e<i.length;e++){const a=i[e];n=n.replace(`\${${a}}`,this._data[t][a]??"")}return n}_removeAllArrowSelected(){const e="arrow-selected",t=this._domElements.options.find(t=>t.classList.contains(e));t&&t.classList.remove(e)&&t.setAttribute("style",ni.multiselect__options_ul_li)}_removeOptionFromList(e){const t=this._multiselect.querySelector(`span[data-value="${e}"]`);t&&t.parentNode&&t.parentNode.removeChild(t)}_renderOptionsList(){const e=`\n <div class="multiselect__options" style="${ni.multiselect__options}">\n <ul style="${ni.multiselect__options_ul}">\n ${this._options.length>0&&!this._itemTemplate?this._options.map(e=>`\n <li data-value="${e.value}" style="${ni.multiselect__options_ul_li}">${e.text}</li>\n `).join(""):""}\n\n ${this._options.length>0&&this._itemTemplate?this._options.map((e,t)=>`\n <li data-value="${e.value}" style="${ni.multiselect__options_ul_li}">${this._processTemplate(this._itemTemplate,t)}</li>\n `).join(""):""}\n ${this._showNoData(0===this._options.length)}\n </ul>\n </div>\n `;this._multiselect.insertAdjacentHTML("beforeend",e)}_renderMultiselect(){this._select.style.display="none";const e="iconic-"+this._generateId(20);this._multiselect=document.createElement("div"),this._multiselect.setAttribute("id",e),this._multiselect.setAttribute("class","multiselect__container"),this._multiselect.setAttribute("style",ni.multiselect__container);const t=`\n <div class="multiselect__wrapper" style="${ni.multiselect__wrapper}">\n <input class="multiselect__input" style="${ni.multiselect__input}" placeholder="${this._placeholder}" />\n </div>\n <span style="display: none;" class="multiselect__clear-btn" style="${ni.multiselect__clear_btn}">${this._cross}</span>\n `;this._multiselect.innerHTML=t,this._selectContainer.appendChild(this._multiselect)}_scrollIntoView(e,t){const n=e.getBoundingClientRect(),i=t.getBoundingClientRect();n.top<i.bottom-t.offsetHeight||(e.scrollTop=t.clientHeight+(t.offsetTop-t.offsetHeight)),n.bottom>i.top+t.offsetHeight||(e.scrollTop=t.clientHeight+(t.offsetTop-t.offsetHeight)-(e.offsetHeight-(t.offsetHeight+(t.offsetHeight-t.clientHeight))))}_showNoData(e){return e?`<p class="multiselect__options--no-data" style="${ni.multiselect__options_ul_p_multiselect__options_no_data}">${this._noData}</p>`:""}_showNoResults(e){const t=this._multiselect.querySelector(".multiselect__options--no-results");if(e){const e=`<p class="multiselect__options--no-results" style="${ni.multiselect__options_ul_p_multiselect__options_no_results}">${this._noResults}</p>`;!t&&this._domElements.optionsContainerList.insertAdjacentHTML("beforeend",e)}else t&&t.parentNode&&t.parentNode.removeChild(t)}}const ai=v.store;function oi(e,t,n,i,a,o,s){const r=o.children;for(let c=0;c<s.length;c++){const l=s[c];if(un(l)===b.ui("Options").uri){const s=dn(0,l)(e,null,t,n,l,i,a);xe.Rm("Refreshing Options field by replacing it."),o.insertBefore(s,r[c]),o.removeChild(r[c+1])}}}function si(e,t,n,i,a,o,s,r){const c=b.ui,l=v.store,p=l.any(a,c("property"));if(!p){const n=nt(e,"No property to boolean field: "+a);return t&&t.appendChild(n),n}let u=l.any(a,c("label"));u||(u=F(p,!0)),o=bn(i,p,o);let d=l.any(i,p);void 0===d&&(d=!1);const m=g.st(i,p,!0,o),f=Ci(e,l,u,g.st(i,p,!1,o),m,a,o,r);return t&&t.appendChild(f),f}function ri(e,t,n,i,a,o,s){dn(0,a)(e,t,n,i,a,o,s)}function ci(e,t,n,i,a){const o=e.createElement("button");return o.setAttribute("type","button"),o.innerHTML="Edit "+F(b.ui("Form")),o.addEventListener("click",function(s){li(e,t,{},n,b.ui("FormForm"),i,a).setAttribute("style",b.ui("FormForm").sameTerm(n)?"background-color: #fee;":"background-color: #ffffe7;"),o.parentNode.removeChild(o)},!0),o}function li(e,t,n,i,a,o,s){return dn(0,a)(e,t,n,i,a,o,s)}function pi(e,t){const n=e.each(void 0,b.rdf("range"),t);[b.rdfs("comment"),b.dc("title"),b.foaf("name"),b.foaf("homepage")].forEach(function(e){n.push(e)});let i=e.each(void 0,b.rdf("type"),t);i.length>60&&(i=i.slice(0,60));const a={};for(let t=0;t<(i.length>60?60:i.length);t++)e.statementsMatching(i[t],void 0,void 0).forEach(function(e){a[e.predicate.uri]=!0});n.forEach(function(e){a[e.uri]=!0});const o=[];for(const t in a)o.push(e.sym(t));return o}function ui(e,t,n){const i=[e.sym(t)];for(;i.length>0;){const t=i.shift(),a=e.each(t,n);if(T("Lists for "+t+", "+n+": "+a.length),0!==a.length)return a;const o=e.each(t,b.rdfs("subClassOf"));for(let e=0;e<o.length;e++)i.push(o[e]),T("findClosest: add super: "+o[e])}return[]}function di(e){const t=v.store;T("formsFor: subject="+e);const n=t.findTypeURIs(e);let i;for(i in n)T(" type: "+i);const a=t.bottomTypeURIs(n);let o=[];for(const e in a)T("candidatesFor: trying bottom type ="+e),o=o.concat(ui(t,e,b.ui("creationForm"))),o=o.concat(ui(t,e,b.ui("annotationForm")));return o}function mi(e){const t=e.map(function(e){return[ai.any(e,b.ui("sequence"))||9999,e]});return t.sort(function(e,t){return e[0]-t[0]}),t.map(function(e){return e[1]})}function fi(e){const t=e.map(function(e){return[F(e).toLowerCase(),e]});return t.sort(),t.map(function(e){return e[1]})}function hi(e,t,n,i,a,o,s,r){const c=e.createElement("button");return c.setAttribute("type","button"),c.innerHTML="New "+F(a),c.addEventListener("click",function(l){c.parentNode.appendChild(gi(e,t,n,i,a,o,s,r))},!1),c}function gi(e,t,n,i,a,o,s,r){const c=e.createElement("form");if(!o){const n=ui(t,a.uri,b.ui("creationForm"));if(0===n.length){c.appendChild(e.createElement("p")).textContent="I am sorry, you need to provide information about a "+F(a)+" but I don't know enough information about those to ask you.";const t=c.appendChild(e.createElement("button"));return t.setAttribute("type","button"),t.setAttribute("style","float: right;"),t.innerHTML="Goto "+F(a),t.addEventListener("click",function(t){e.outlineManager.GotoSubject(a,!0,void 0,!0,void 0)},!1),c}T("lists[0] is "+n[0]),o=n[0]}T("form is "+o),c.setAttribute("style",`border: 0.05em solid ${qe}; color: ${qe}`),c.innerHTML="<h3>New "+F(a)+"</h3>";const l=dn(0,o),p=Ei(s);let u=!1;function d(e,t,n){return r(t,n)}S("paneUtils Object is "+p);const m=l(e,c,{},p,o,s,function(o,l){if(!o)return r(o,l);const m=[];n&&!t.holds(n,i,p,s)&&m.push(g.st(n,i,p,s)),n&&!t.holds(p,b.rdf("type"),a,s)&&m.push(g.st(p,b.rdf("type"),a,s)),m.length?t.updater.update([],m,d):r(!0,l),u||(u=c.appendChild(Yt(e,p)))});return Kt(e,m).setAttribute("style","float: right;"),c.AJAR_subject=p,c}function bi(e,t,n,i,a,o){const s=e.createElement("div"),r=t.anyJS(n,i,null,a)||"",c=e.createElement("textarea");function l(r){p.disabled=!0,p.setAttribute("style","visibility: hidden; float: right;"),c.disabled=!0,c.style.color=Je;const l=t.statementsMatching(n,i,null,a),u=g.st(n,i,c.value,a);t.updater.update(l,u,function(t,n,i){n?(c.style.color=We,c.disabled=!1):s.appendChild(nt(e,"Error (while saving change to "+a.uri+"): "+i)),o&&o(n,i)})}s.appendChild(c),c.rows=r?r.split("\n").length+2:2,c.cols=80,c.setAttribute("style",Ke.multilineTextInputStyle),null!==r?c.value=r:c.select(),s.refresh=function(){const e=t.any(n,i,null,a);e&&e.value!==c.value&&(c.value=e.value)};let p;return t.updater.editable(a.uri)?(p=Mt(e,l),p.disabled=!0,p.style.visibility="hidden",p.style.float="right",s.appendChild(p),c.addEventListener("keyup",function(e){c.style.color="green",p&&(p.disabled=!1,p.style.visibility="")},!0),c.addEventListener("change",l,!0)):(c.disabled=!0,c.style.backgroundColor=Ge),s}function vi(e,t,n,i,a,o,s,r){T("Select list length now "+a.length);let c=0;const l={},p=t.updater.editable(s.uri);for(let e=0;e<a.length;e++){const t=a[e];t.uri||xe.R8(`makeSelectForClassifierOptions: option does not have an uri: ${t}, with predicate: ${i}`),t.uri&&!(t.uri in l)&&(l[t.uri]=!0,c++)}if(0===c&&!o.mint)return nt(e,"Can't do selector with no options, subject= "+n+" property = "+i+".");let u;T("makeSelectForClassifierOptions: dataDoc="+s);const d=function(){return u={},i.sameTerm(b.rdf("type"))?u=t.findTypeURIs(n):t.each(n,i,null,s).forEach(function(e){u[e.uri]=!0}),u};u=d();const m=function(a){f.disabled=!0;const c=[];let l=[];const p=function(e){t.holds(n,i,e,s)&&c.push(g.st(n,i,e,s))};let m;for(let a=0;a<f.options.length;a++){const c=f.options[a];if(c.selected&&c.AJAR_mint){if(o.mintClass){const a=gi(e,t,n,i,o.mintClass,null,s,function(e,t){e||r(e,t,{change:"new"})});f.parentNode.appendChild(a),m=a.AJAR_subject}else m=Ei(s);l.push(g.st(n,i,m,s)),o.mintStatementsFun&&(l=l.concat(o.mintStatementsFun(m)))}c.AJAR_uri&&(c.selected&&!(c.AJAR_uri in u)&&l.push(g.st(n,i,t.sym(c.AJAR_uri),s)),!c.selected&&c.AJAR_uri in u&&p(t.sym(c.AJAR_uri)),c.selected&&(f.currentURI=c.AJAR_uri))}let h=f.subSelect;for(;h&&h.currentURI;)p(t.sym(h.currentURI)),h=h.subSelect;for(h=f.superSelect;h&&h.currentURI;)p(t.sym(h.currentURI)),h=h.superSelect;function b(e,t){r(e,{widget:"select",event:"new"})}S("makeSelectForClassifierOptions: data doc = "+s),t.updater.update(c,l,function(t,n,i){if(u=d(),!n)return f.parentNode.appendChild(nt(e,"Error updating data in select: "+i));if(f.disabled=!1,m){dn(0,o.subForm)(e,f.parentNode,{},m,o.subForm,s,b)}r&&r(n,{widget:"select",event:"change"})})},f=e.createElement("select");f.setAttribute("style",Ke.formSelectStyle),o.multiple&&f.setAttribute("multiple","true"),f.currentURI=null,f.refresh=function(){u=d();for(let e=0;e<f.children.length;e++){const t=f.children[e];t.AJAR_uri&&(t.selected=t.AJAR_uri in u)}f.disabled=!1};for(const n in l){const i=t.sym(n),a=e.createElement("option");o.disambiguate?a.appendChild(e.createTextNode(ue(i,!0))):a.appendChild(e.createTextNode(F(i,!0)));const s=t.any(i,t.sym("http://www.w3.org/ns/ui#backgroundColor"));s&&a.setAttribute("style","background-color: "+s.value+"; "),a.AJAR_uri=n,n in u&&(a.setAttribute("selected","true"),f.currentURI=n),f.appendChild(a)}if(p&&o.mint){const t=e.createElement("option");t.appendChild(e.createTextNode(o.mint)),t.AJAR_mint=!0,f.insertBefore(t,f.firstChild)}if(null==f.currentURI&&!o.multiple){const t=e.createElement("option");t.appendChild(e.createTextNode(o.nullLabel)),f.insertBefore(t,f.firstChild),t.selected=!0}return p&&f.addEventListener("change",m,!1),f}function xi(e,t,n,i,a,o,s,r){T("Select list length now "+a.length);let c=0;const l={},p=t.updater.editable(s.uri);for(let e=0;e<a.length;e++){const t=a[e];t.uri||xe.R8(`makeSelectForOptions: option does not have an uri: ${t}, with predicate: ${i}`),t.uri&&!(t.uri in l)&&(l[t.uri]=!0,c++)}if(0===c)return nt(e,"Can't do selector with no options, subject= "+n+" property = "+i+".");let u;T("makeSelectForOptions: dataDoc="+s);const d=function(){return u={},i.sameTerm(b.rdf("type"))?u=t.findTypeURIs(n):t.each(n,i,null,s).forEach(function(e){e.uri&&(u[e.uri]=!0)}),u};u=d();const m=function(a){f.disabled=!0;const o=[],c=[],l=function(e){t.holds(n,i,e,s)&&o.push(g.st(n,i,e,s))};for(let e=0;e<f.options.length;e++){const a=f.options[e];a.AJAR_uri&&(a.selected&&!(a.AJAR_uri in u)&&c.push(g.st(n,i,t.sym(a.AJAR_uri),s)),!a.selected&&a.AJAR_uri in u&&l(t.sym(a.AJAR_uri)),a.selected&&(f.currentURI=a.AJAR_uri))}let p=f.subSelect;for(;p&&p.currentURI;)l(t.sym(p.currentURI)),p=p.subSelect;for(p=f.superSelect;p&&p.currentURI;)l(t.sym(p.currentURI)),p=p.superSelect;S("selectForOptions: data doc = "+s),t.updater.update(o,c,function(t,n,i){if(u=d(),!n)return f.parentNode.appendChild(nt(e,"Error updating data in select: "+i));f.disabled=!1,r&&r(n,{widget:"select",event:"change"})})},f=e.createElement("select");f.setAttribute("style",Ke.formSelectStyle),f.currentURI=null,f.refresh=function(){u=d();for(let e=0;e<f.children.length;e++){const t=f.children[e];t.AJAR_uri&&(t.selected=t.AJAR_uri in u)}f.disabled=!1};for(const n in l){const i=t.sym(n),a=e.createElement("option");o.disambiguate?a.appendChild(e.createTextNode(ue(i,!0))):a.appendChild(e.createTextNode(F(i,!0)));const s=t.any(i,t.sym("http://www.w3.org/ns/ui#backgroundColor"));s&&a.setAttribute("style","background-color: "+s.value+"; "),a.AJAR_uri=n,n in u&&(a.setAttribute("selected","true"),f.currentURI=n),f.appendChild(a)}if(!f.currentURI){const t=e.createElement("option");t.appendChild(e.createTextNode(o.nullLabel)),f.insertBefore(t,f.firstChild),t.selected=!0}return p&&f.addEventListener("change",m,!1),f}function yi(e,t,n,i,a,o){const s=t.any(i,b.owl("disjointUnionOf"));let r,c=!1;return s?r=s.elements:(r=t.each(void 0,b.rdfs("subClassOf"),i),c=!0),T("Select list length "+r.length),0===r.length?nt(e,"Can't do "+(c?"multiple ":"")+"selector with no subclasses of category: "+i):1===r.length?nt(e,"Can't do "+(c?"multiple ":"")+"selector with only 1 subclass of category: "+i+":"+r[1]):vi(e,t,n,b.rdf("type"),r,{multiple:c,nullLabel:"* Select type *"},a,o)}function wi(e,t,n,i,a,o){function s(){c&&(r.removeChild(c),c=null),l.currentURI&&t.any(t.sym(l.currentURI),b.owl("disjointUnionOf"))&&(c=wi(e,t,n,t.sym(l.currentURI),a,o),l.subSelect=c.firstChild,l.subSelect.superSelect=l,r.appendChild(c))}const r=e.createElement("span");let c=null;const l=yi(e,t,n,i,a,function(e,t){e&&s(),o(e,t)});return r.appendChild(l),s(),r}function Ci(e,t,n,i,a,o,s,r){const c=e.createElement("div"),l=hn(e,t,c,o,n),p=t.updater.editable(s.uri),u=e.createElement("button"),d=u;function m(e){if(!e)return[];if(e.object)return e.why||(e.why=s),[e];if(e instanceof Array)return e;throw new Error("buildCheckboxForm: bad param "+e)}function f(e){return 0===e.filter(e=>!t.holds(e.subject,e.predicate,e.object,e.why)).length}if(u.style=Ke.checkboxInputStyle,l.appendChild(u),a=m(a),i=m(i),function(){let n=f(a),s=n;if(i.length){const l=f(i);if(n&&l)return c.appendChild(nt(e,"Inconsistent data in dataDoc!\n"+a+" and\n"+i)),c;if(!n&&!l){n=null;const e=t.any(o,b.ui("default"));s=e?"1"===e.value:!!r&&null}}u.state=n,u.textContent={true:"✓",false:r?"✕":" ",null:"-"}[s]}(),!p)return c;let h=!1;return u.addEventListener("click",function(n){if(h)return;h=!0,u.disabled=!0;let o=!1;const s=function(){return!o&&(o=!0,h=!1,u.disabled=!1,!0)},l=function(t){d.style.color="#000",d.style.backgroundColor="#fee",c.appendChild(nt(e,`Checkbox: Error updating dataDoc from ${u.state} to ${u.newState}:\n\n${t}`))};d.style.color="#bbb";const p=!0===u.state?a:!1===u.state?i:[];u.newState=null===u.state||!0!==u.state&&(!r||null);const m=!0===u.newState?a:!1===u.newState?i:[];xe.Rm(` Deleting ${p}`),xe.Rm(` Inserting ${m}`);try{const e=t.updater.update(p,m,function(e,n,i){if(s())if(n)d.style.color="#000",u.state=u.newState,u.textContent={true:"✓",false:"✕",null:"-"}[u.state];else{if(p.why){t.holds(p.subject,p.predicate,p.object,p.why)&&xe.Rm(" @@@@@ weird if 409 - does hold statement")}l(i)}});e&&"function"==typeof e.then&&e.catch(function(e){s()&&l(e instanceof Error?e.message:e)}).finally(function(){s()})}catch(e){throw s(),e}},!1),c}function Ei(e){const t=new Date;return g.sym(e.uri+"#id"+t.getTime())}function ki(e,t,n,i,a,o,s,r,c,l,p){const u={},d=n.updater.editable(l.uri);for(let e=0;e<o.length;e++){const t=o[e];t.uri&&!(t.uri in u)&&(u[t.uri]=!0)}if(0===Object.keys(u).length&&!c.mint)return nt(e,"Can't do selector with no options, subject= "+i+" property = "+a+".");T("makeSelectForChoice: dataDoc="+l);const m=function(e){t.removeChild(t.lastChild),f.refresh()},f=e.createElement("select");f.setAttribute("style",Ke.formSelectStyle),f.setAttribute("id","formSelect"),f.currentURI=null;for(const e in u)f.appendChild(h(e));if(d&&c.mint){const t=e.createElement("option");t.appendChild(e.createTextNode(c.mint)),t.AJAR_mint=!0,f.insertBefore(t,f.firstChild)}function h(t){const i=e.createElement("option"),a=n.sym(t);let o;o=c.disambiguate?ue(a,!0):F(a,!0),i.appendChild(e.createTextNode(o)),i.setAttribute("value",t);const r=n.any(a,n.sym("http://www.w3.org/ns/ui#backgroundColor"));return r&&i.setAttribute("style","background-color: "+r.value+"; "),i.AJAR_uri=t,Ai(a.value,s)&&i.setAttribute("selected","true"),i}return 0===f.children.length&&f.insertBefore(function(){const t=e.createElement("option");return t.appendChild(e.createTextNode(function(){let e="--- choice ---";return a&&"BlankNode"!==a.termType&&(e="* Select for property: "+F(a)+" *"),i&&"BlankNode"!==i.termType&&(e="* Select for "+F(i,!0)+" *"),e}())),t.disabled=!0,t.value=!0,t.hidden=!0,t.selected=!0,t}(),f.firstChild),f.update=function(t){s=t;const o=[],c=[],u=function(e){n.holds(i,a,e,l)&&o.push(g.st(i,a,e,l))},d=function(e){n.holds(i,a,e,l)||c.push(g.st(i,a,e,l)),r&&!n.holds(e,b.rdf("type"),n.sym(r),l)&&c.push(g.st(e,b.rdf("type"),n.sym(r),l))},m=n.each(i,a,null,l).map(e=>e.value);for(const e of m)Ai(e,s)||u(g.sym(e));for(const e of s)e in m||d(g.sym(e));n.updater.update(o,c,function(t,n,i){if(!n)return f.parentNode.appendChild(nt(e,"Error updating data in select: "+i));f.refresh(),p&&p(n,{widget:"select",event:"change"})})},f.refresh=function(){f.disabled=!0;let o,u=[];for(let t=0;t<f.options.length;t++){const d=f.options[t];if(d.selected&&d.AJAR_mint){if(c.mintClass){const t=gi(e,n,i,a,r,c.subForm,l,function(e,t){e||p(e,t,{change:"new"})});f.parentNode.appendChild(t),o=t.AJAR_subject}else o=Ei(l);u.push(g.st(i,a,n.sym(o),l)),r&&u.push(g.st(o,b.rdf("type"),n.sym(r),l)),c.mintStatementsFun&&(u=u.concat(c.mintStatementsFun(o))),f.currentURI=o}d.AJAR_uri&&(d.selected&&Ai(d.AJAR_uri,s)&&(f.currentURI=d.AJAR_uri),Ai(d.AJAR_uri,s)||d.removeAttribute("selected"),Ai(d.AJAR_uri,s)&&d.setAttribute("selected","true"))}S("selectForOptions: data doc = "+l),f.currentURI&&c.subForm&&!c.multiSelect&&ri(e,t,{},g.sym(f.currentURI),c.subForm,l,function(i,a){i?(n.updater.update([],u,function(n,i,a){i||t.appendChild(nt(e,"Error updating select: "+a))}),p&&p(i,{widget:"select",event:"new"})):t.appendChild(nt(e,"Error updating data in field of select: "+a))}),f.disabled=!1},d&&f.addEventListener("change",m,!1),f}function Ai(e,t){let n;for(n=0;n<t.length;n++)if(t[n]===e)return!0;return!1}pn[b.ui("AutocompleteField").uri]=function(e,t,n,i,a,o,s){if("NamedNode"!==i.termType)throw new Error("Sorry this field only works on NamedNode subjects (for editable)");const r=v.store,c=a.doc?a.doc():null,l=e.createElement("div");t&&t.appendChild(l);const p=e.createElement("div");p.setAttribute("class","formFieldName"),p.setAttribute("style",Ke.formFieldNameBoxStyle),l.appendChild(p);const u=e.createElement("div");u.setAttribute("class","formFieldValue"),l.appendChild(u);const d=r.any(a,b.ui("property"));if(!d)return l.appendChild(nt(e,"Error: No property given for autocomplete field: "+a));const m=r.any(a,b.ui("labelProperty"))||b.schema("name"),f=r.any(a,b.ui("dataSource"));if(!f)return l.appendChild(nt(e,"Error: No data source given for autocomplete field: "+a));const h={label:r.anyJS(f,b.schema("name"),null,f.doc()),logo:r.any(f,b.schema("logo"),null,f.doc())},x=r.any(a,b.ui("targetClass"),null,a.doc())||r.any(f,b.ui("targetClass"),null,f.doc());x&&(h.targetClass=x),h.objectURIBase=r.any(f,b.ui("objectURIBase"),null,f.doc())||void 0;const y=r.anyJS(f,b.ui("endpoint"),null,f.doc());if(y){if(h.endpoint=y,h.searchByNameQuery=r.anyJS(f,b.ui("searchByNameQuery"),null,f.doc()),!h.searchByNameQuery)return l.appendChild(nt(e,"Error: No searchByNameQuery given for endpoint data Source: "+a));h.insitituteDetailsQuery=r.anyJS(f,b.ui("insitituteDetailsQuery"),null,f.doc())}else{const t=r.anyJS(f,b.ui("searchByNameURI"));if(!t)return l.appendChild(nt(e,"Error: No searchByNameURI OR sparql endpoint given for dataSource: "+f));h.searchByNameURI=t}const w=r.anyJS(a,b.ui("suppressEmptyUneditable"),null,c),C=r.updater?.editable(o.uri),E={permanent:!0,targetClass:h.targetClass,queryParams:h};E.size=r.anyJS(a,b.ui("size"),null,c)||void 0;let k=r.any(i,d,void 0,o);if(k)E.currentObject=k,E.currentName=r.any(E.currentObject,m,null,o);else if(k=r.any(a,b.ui("default")),k)E.currentObject=k,E.currentName=r.any(E.currentObject,m,null,o);else if(w&&!C)return l.style.display="none",l;return p.appendChild(gn(e,d,a)),ti(e,i,{editable:C,dbLookup:!0},E,async function(t,n){if(!n)throw new Error("autocompleteField: No name set.");const a=r.the(i,d,null,o);if(a){const e=r.any(a,m,null,o);if(a.equals(t)&&e&&e.sameTerm(n))return}const c=a?r.statementsMatching(i,d,a,o).concat(r.statementsMatching(a,m,null,o)):[],p=[(0,g.st)(i,d,t,o),(0,g.st)(t,m,n,o)];try{await(r.updater?.updateMany(c,p))}catch(t){return s(!1,t),void l.appendChild(nt(e,"Autocomplete form data update error:"+t,null,t))}s(!0,"")},async function(t,n){const a=r.the(i,d,null,o);if(!a)return s(!1,"NO data to elete"),void l.appendChild(nt(e,"Autocomplete delete: no old data!"));const c=r.statementsMatching(i,d,a,o).concat(r.statementsMatching(a,m,null,o)),p=[];try{await(r.updater?.updateMany(c,p))}catch(t){const n=new Error("Autocomplete form data delete error:"+t);return s(!1,t),void l.appendChild(nt(e,n,null,t))}s(!0,"")}).then(e=>{u.appendChild(e)},t=>{u.appendChild(nt(e,`Error rendering autocomplete ${a}: ${t}`,"#fee",t))}),l},pn[b.ui("Form").uri]=pn[b.ui("Group").uri]=function(e,t,n,i,a,o,s){const r=e.createElement("div"),c=b.ui;if(t&&t.appendChild(r),!a)return;const l=i.toNT()+"|"+a.toNT();if(n[l])return r.appendChild(e.createTextNode("Group: see above "+l)),r;const p={};for(const e in n)p[e]=1;p[l]=1;const u=a.doc?a.doc():null,d=ai.any(a,c("weight"),null,u),m=d?Number(d.value):1;if(m>3||m<0)return r.appendChild(nt(e,`Form Group weight ${m} should be 0-3`));r.setAttribute("style",Ke.formGroupStyle[m]),r.style.display="flex",r.style.flexDirection="column",r.class="form-weight-"+m;let f,h=ai.any(a,c("parts"),null,u);if(h?f=h.elements:(h=ai.each(a,c("part"),null,u),f=mi(h)),!h)return r.appendChild(nt(e,"No parts to form! "));for(let t=0;t<f.length;t++){const a=f[t],c=dn(0,a),l=function(t,a){t&&a&&a.widget&&"select"===a.widget&&oi(e,n,i,o,s,r,f),s(t,{widget:"group",change:a})};r.appendChild(c(e,null,p,i,a,o,l))}return r},pn[b.ui("Options").uri]=function(e,t,n,i,a,o,s){const r=v.store,c=e.createElement("div"),l=a.doc?a.doc():null,p=b.ui;t&&t.appendChild(c);let u=r.any(a,p("dependingOn"));u||(u=b.rdf("type"));const d=r.each(a,p("case"),null,l);let m;d||c.appendChild(nt(e,"No cases to Options form. ")),m=u.sameTerm(b.rdf("type"))?Object.keys(r.findTypeURIs(i)).map(e=>g.sym(e)):r.each(i,u);for(let t=0;t<d.length;t++){const u=d[t],f=r.each(u,p("for"),null,l);let h=!1;for(let e=0;e<f.length;e++)for(const t of m){const n=f[e];(t.sameTerm(f)||t.termType===n.termType&&t.value===n.value)&&(h=!0)}if(h){const t=r.the(u,p("use"));if(!t)return c.appendChild(nt(e,'No "use" part for case in form '+a)),c;li(e,c,n,i,t,o,s);break}}return c},pn[b.ui("Multiple").uri]=function(e,t,n,i,a,o,s){function r(e){return e.map(e=>e.toString().slice(-7)).join(", ")}async function c(){const t=Ei(o);if(y)L(),S.elements.push(t),await R();else{const n=C?[g.st(t,w,i,o)]:[g.st(i,w,t,o)];try{await u.updater.update([],n)}catch(t){const n="Error adding to unordered multiple: "+t;m.appendChild(nt(e,n)),xe.z3(n)}N()}}function l(t){async function a(e,n){let i;for(xe.Rm("pre move: "+r(S.elements)),i=0;i<S.elements.length&&!S.elements[i].sameTerm(t);i++);if(i===S.elements.length&&alert("list move: not found element for "+t),n){if(0===i)return void alert("@@ boop - already at top -temp message");S.elements.splice(i-1,2,S.elements[i],S.elements[i-1])}else{if(i===S.elements.length-1)return void alert("@@ boop - already at bottom -temp message");S.elements.splice(i,2,S.elements[i+1],S.elements[i])}await R()}T("Multiple: render object: "+t);const c=dn(0,A)(e,null,n,t,A,o,function(e,n){xe.Rm(`Item done callback for item ${t.toString()}`),e||xe.z3(" Item done callback: Error: "+n),s(e,n)});if(c.subject=t,u.updater.editable(o.uri)&&(Bt(e,c,E,async function(){if(y){xe.Rm("pre delete: "+r(S.elements));for(let e=0;e<S.elements.length;e++)if(S.elements[e].sameTerm(t))return S.elements.splice(e,1),void await R()}else if(u.holds(i,w,t,o)){const n=[g.st(i,w,t,o)];u.updater.update(n,[],function(t,n,i){n?_.removeChild(c):_.appendChild(nt(e,"Multiple: delete failed: "+i))})}}),y)){const t=e.createElement("div");t.style.display="grid",t.style.gridTemplateColumns="auto 3em",t.style.gridTemplateRows="50% 50%";const n=Dt(e,it.Pt.iconBase+"noun_1369237.svg","Move Up",async e=>a(0,!0)),i=Dt(e,it.Pt.iconBase+"noun_1369241.svg","Move Down",async e=>a(0,!1)),o=e.createElement("div");return o.appendChild(c),t.appendChild(o),t.appendChild(n),t.appendChild(i),n.style.gridColumn=2,i.style.gridColumn=2,n.style.gridRow=1,i.style.padding="0em",n.style.padding="0em",i.style.gridRow=2,o.style.gridColumn=1,o.style.gridRowStart="span 2",t}return c}const p=it.Pt.iconBase+"noun_19460_green.svg",u=v.store,d=a.doc?a.doc():null,m=e.createElement("div"),f=m,h=b.ui;t&&t.appendChild(m);const x=u.any(a,h("ordered")),y=!!x&&g.Node.toJS(x),w=u.any(a,h("property")),C=u.anyJS(a,h("reverse"),null,d);if(!w)return m.appendChild(nt(e,"No property to multiple: "+a)),f;let E=u.any(a,h("label"));E||(E=F(w));let k=u.any(a,h("min"));k=k?0+k.value:0;const A=u.any(a,h("part"));if(!A)return m.appendChild(nt(e,"No part to multiple: "+a)),f;const _=m.appendChild(e.createElement("div"));let S,j;if(_.style.display="flex",_.style.flexDirection="column",j=C?u.any(null,w,i,o):u.any(i,w,null,o),y?(S=C?u.any(null,w,i,o):u.any(i,w,null,o),j=S?S.elements:[]):(j=C?u.each(null,w,i,o):u.each(i,w,null,o),S=null),u.updater.editable(o.uri)){const t=m.appendChild(e.createElement("div"));t.style.padding="0.5em";const n=t.appendChild(e.createElement("img"));n.setAttribute("src",p),n.setAttribute("style","margin: 0.2em; width: 1.5em; height:1.5em"),n.title="Click to add another "+E;const i=e.createElement("span");i.textContent=(0===j.length?"Add another ":"Add ")+E,t.addEventListener("click",async e=>{await c()},!0),t.appendChild(i)}function L(){S||(S=new g.Collection,C?u.add(S,w,i,o):u.add(i,w,S,o))}async function R(){xe.Rm("save list: "+r(S.elements)),L();try{await u.fetcher.putBack(o)}catch(t){return void m.appendChild(nt(e,"Error trying to put back a list: "+t))}N()}function N(){let e;if(y){const t=C?u.the(null,w,i,o):u.the(i,w,null,o);e=t?t.elements:[]}else e=C?u.each(null,w,i,o):u.each(i,w,null,o),e.sort();Y(_,e,l)}return _.refresh=N,N(),async function(){const e=k-j.length;if(e>0){for(let t=0;t<e;t++)xe.Rm("Adding extra: min "+k),await c();await R()}}().then(()=>{xe.Rm(" Multiple render: async stuff ok")},e=>{xe.z3(" Multiple render: async stuff fails. #### ",e)}),f},pn[b.ui("PhoneField").uri]=vn,pn[b.ui("EmailField").uri]=vn,pn[b.ui("ColorField").uri]=vn,pn[b.ui("DateField").uri]=vn,pn[b.ui("DateTimeField").uri]=vn,pn[b.ui("TimeField").uri]=vn,pn[b.ui("NumericField").uri]=vn,pn[b.ui("IntegerField").uri]=vn,pn[b.ui("DecimalField").uri]=vn,pn[b.ui("FloatField").uri]=vn,pn[b.ui("TextField").uri]=vn,pn[b.ui("SingleLineTextField").uri]=vn,pn[b.ui("NamedNodeURIField").uri]=vn,pn[b.ui("MultiLineTextField").uri]=function(e,t,n,i,a,o,s){const r=b.ui,c=v.store,l=a.doc?a.doc():null,p=c.any(a,r("property"));if(!p)return nt(e,"No property to text field: "+a);const u=e.createElement("div");u.style.display="flex",u.style.flexDirection="row";const d=u.appendChild(e.createElement("div"));d.style.width=He;const m=u.appendChild(e.createElement("div"));d.appendChild(gn(e,p,a)),o=bn(i,p,o);const f=c.anyJS(i,p,null,o)||"",h=c.updater.editable(o.uri),g=a&&c.anyJS(a,b.ui("suppressEmptyUneditable"),null,l);!h&&g&&""===f&&(u.style.display="none");const x=bi(e,c,i,p,o,s);return m.appendChild(x),t&&t.appendChild(u),u},pn[b.ui("BooleanField").uri]=function(e,t,n,i,a,o,s){return si(e,t,0,i,a,o,0,!1)},pn[b.ui("TristateField").uri]=function(e,t,n,i,a,o,s){return si(e,t,0,i,a,o,0,!0)},pn[b.ui("Classifier").uri]=function(e,t,n,i,a,o,s){const r=v.store,c=b.ui,l=r.any(a,c("category"));if(!l)return nt(e,"No category for classifier: "+a);T("Classifier: dataDoc="+o);const p=e.createElement("div");p.setAttribute("class","classifierBox");const u=e.createElement("div");u.setAttribute("class","formFieldName classifierBox-label"),u.appendChild(gn(e,l,a)),p.appendChild(u);const d=e.createElement("div");d.setAttribute("class","formFieldValue classifierBox-selectBox");const m=wi(e,r,i,l,o,function(e,t){return s(e,t)});if(m&&m.querySelectorAll){const e=m.querySelectorAll("select");e.length&&!r.updater.editable(o.uri)&&e.forEach(e=>{e.readOnly=!0,e.style=Ke.textInputStyleUneditable})}return d.appendChild(m),p.appendChild(d),t&&t.appendChild(p),p},pn[b.ui("Choice").uri]=function(e,t,n,i,a,o,s){const r=b.ui,c=v.store,l=a.doc?a.doc():null;let p;const u=e.createElement("div");u.setAttribute("class","choiceBox"),t&&t.appendChild(u);const d=e.createElement("div");d.setAttribute("class","formFieldName choiceBox-label"),u.appendChild(d);const m=e.createElement("div");m.setAttribute("class","formFieldValue choiceBox-selectBox"),u.appendChild(m);const f=c.any(a,r("property"));if(!f)return u.appendChild(nt(e,"No property for Choice: "+a));d.appendChild(gn(e,f,a));const h=c.any(a,r("from"));if(!h)return nt(e,"No 'from' for Choice: "+a);const x=c.any(a,r("use")),y={form:a,subForm:x,disambiguate:!1};c.any(a,r("canMintNew"))&&(y.mint="* Create new *");const w=c.any(a,r("multiselect"));w&&(y.multiSelect=!0);const C=c.each(a,r("search-full-store")).length?null:o;let E;return m.refresh=function(){let t=c.each(i,f,null,o).map(e=>e.value),n=function(e){let t,n=[];n=c.each(void 0,b.rdf("type"),h,l);for(const t in function(e,t,n){let i,a,o,s,r,c,l,p,u,d,m;const f={};f[t.toNT()]=!0;const h={},g=e.transitiveClosure(f,e.rdfFactory.namedNode("http://www.w3.org/2000/01/rdf-schema#subClassOf"),!0);for(const t in g){r=e.statementsMatching(null,e.rdfFactory.namedNode("http://www.w3.org/1999/02/22-rdf-syntax-ns#type"),e.fromNT(t),n);for(let e=0,t=r.length;e<t;e++)d=r[e],h[d.subject.toNT()]=d;c=e.each(null,e.rdfFactory.namedNode("http://www.w3.org/2000/01/rdf-schema#domain"),e.fromNT(t),n);for(let t=0,a=c.length;t<a;t++)for(s=c[t],l=e.statementsMatching(null,s,null,n),o=0,i=l.length;o<i;o++)d=l[o],h[d.subject.toNT()]=d;p=e.each(null,e.rdfFactory.namedNode("http://www.w3.org/2000/01/rdf-schema#range"),e.fromNT(t),n);for(let t=0,i=p.length;t<i;t++)for(s=p[t],u=e.statementsMatching(null,s,null,n),m=0,a=u.length;m<a;m++)d=u[m],h[d.object.toNT()]=d}return h}(c,h,e))n.push(c.fromNT(t));if(h.sameTerm(b.rdfs("Class")))for(p in Qt())n.push(c.sym(p));else if(h.sameTerm(b.rdf("Property"))){for(p in t=Zt(c),t.op)n.push(c.fromNT(p));for(p in t.dp)n.push(c.fromNT(p));y.disambiguate=!0}else if(h.sameTerm(b.owl("ObjectProperty"))){for(p in t=Zt(c),t.op)n.push(c.fromNT(p));y.disambiguate=!0}else if(h.sameTerm(b.owl("DatatypeProperty"))){for(p in t=Zt(c),t.dp)n.push(c.fromNT(p));y.disambiguate=!0}return n}(C);if(n.push(t),n=fi(n),E=ki(e,m,c,i,f,n,t,h,y,o,s),m.innerHTML="",m.appendChild(E),w){const n=new ii({placeholder:E.selected,select:E,container:m,textField:"textField",valueField:"valueField"});n.init(),n.subscribe(function(n){if("REMOVE_OPTION"===n.action&&(t=t.filter(function(e){return e!==n.value})),"CLEAR_ALL_OPTIONS"===n.action&&(t=[]),"ADD_OPTION"===n.action){if((n.value+"").includes("Create new")){const n=Ei(o),a=[];a.push(g.st(i,f,c.sym(n),o)),h&&a.push(g.st(n,b.rdf("type"),c.sym(h),o)),x&&ri(e,m,{},g.sym(n),x,o,function(i,o){i?(c.updater.update([],a,function(t,n,i){n||m.appendChild(nt(e,"Error updating select: "+i))}),t.push(n),s&&s(i,{widget:"select",event:"new"})):m.appendChild(nt(e,"Error updating data in field of select: "+o))})}else t.push(n.value)}E.update(t)})}},m.refresh(),E&&E.refresh&&E.refresh(),u},pn[b.ui("Comment").uri]=pn[b.ui("Heading").uri]=function(e,t,n,i,a,o,s){const r=b.ui,c=v.store;let l=c.any(a,r("contents"));l||(l="Error: No contents in comment field.");const p=a.doc?a.doc():null,u=un(a),d=cn[u]||{},m=e.createElement("div");t&&t.appendChild(m);const f=m.appendChild(e.createElement(d.element));f.textContent=l,function(e,t){const n=un(t),i=cn[n]||{},a=v.store.any(t,b.ui("style"));a?"Literal"===a.termType?a&&e.setAttribute("style",a.value):v.store.statementsMatching(a,null,null,t.doc()).forEach(t=>{if(t.predicate.uri&&t.predicate.uri.startsWith(mn)){const n=t.predicate.uri.slice(26);try{e.style[n]=t.object.value}catch(i){console.warn(`setFieldStyle: Error setting element style ${n} to "${t.object.value}"`),console.warn(`setFieldStyle: ... Element tagName was "${e.tagName||"???"}"`)}}}):i.style&&e.setAttribute("style",i.style)}(f,a);const h=c.anyJS(a,b.ui("suppressIfUneditable"),null,p),g=c.updater.editable(o.uri);return h&&!g&&(m.style.display="none"),m};const _i={authEndpoint:"",fallbackAuthEndpoint:"https://databox.me/",signupEndpoint:"https://solidproject.org/get_a_pod",signupWindowHeight:600,signupWindowWidth:1024,key:"",cert:""};function Ti(e){this.config=e||_i}Ti.prototype.listen=function(){return new Promise(function(e,t){const n=window.addEventListener?"addEventListener":"attachEvent";(0,window[n])("attachEvent"===n?"onmessage":"message",function(n){const i=n.data;if("User:"===i.slice(0,5)){const n=i.slice(5,i.length);return n&&n.length>0&&"http"===n.slice(0,4)?e(n):t(n)}},!0)})},Ti.prototype.signup=function(e){e=e||this.config.signupEndpoint;const t=this.config.signupWindowWidth,n=this.config.signupWindowHeight,i=window.screen.width/2-(t/2+10),a=window.screen.height/2-(n/2+50),o=e+"?origin="+encodeURIComponent(window.location.origin),s="resizable,scrollbars,status,width="+t+",height="+n+",left="+i+",top="+a;window.open(o,"Solid signup",s);const r=this;return new Promise(function(e){r.listen().then(function(t){return e(t)})})};v.solidLogicSingleton.store;const{loadPreferences:Si,loadProfile:ji}=v.solidLogicSingleton.profile,{getScopedAppInstances:Li,getRegistrations:Ri,loadAllTypeIndexes:Ni,getScopedAppsFromIndex:Ii,deleteTypeIndexRegistration:$i}=v.solidLogicSingleton.typeIndex;function Bi(e){const t=v.authn.currentUser();return t?(v.authn.saveUser(t,e),Promise.resolve(e)):new Promise(t=>{v.authn.checkUser().then(n=>{if(n)return xe.Rm(`logIn: Already logged in as ${n}`),t(e);if(!e.div||!e.dom)return t(e);const i=Hi(e.dom,n=>{v.authn.saveUser(n,e),t(e)});e.div.appendChild(i)})})}async function Di(e){if(e.preferencesFile)return Promise.resolve(e);let t;try{e=await Oi(e);const n=await Si(e.me);t,e.preferencesFile=n}catch(t){let n;if(t instanceof v.UnauthorizedError)n="Oops — you are not authenticated (properly logged in), so SolidOS cannot read your preferences file. Try logging out and then logging back in.",R(n);else{if(t instanceof v.CrossOriginForbiddenError)return n=`Unauthorized: Assuming preference file blocked for origin ${window.location.origin}`,e.preferencesFileError=n,e;if(t instanceof v.SameOriginForbiddenError)return n="You are not authorized to read your preference file. This may be because you are using an untrusted web app.",xe.R8(n),e;if(t instanceof v.NotEditableError)return n="You are not authorized to edit your preference file. This may be because you are using an untrusted web app.",xe.R8(n),e;if(t instanceof v.WebOperationError)n="You are not authorized to edit your preference file. This may be because you are using an untrusted web app.",xe.R8(n);else{if(!(t instanceof v.FetchError))throw new Error(`(via loadPrefs) ${t}`);n=`Strange: Error ${t.status} trying to read your preference file.${t.message}`,R(n)}}e.preferencesFileError=n}return e}async function Oi(e){if(e.publicProfile)return e;try{const t=await Bi(e);if(!t.me)throw new Error("Could not log in");e.publicProfile=await ji(t.me)}catch(t){throw e.div&&e.dom&&e.div.appendChild(nt(e.dom,t.message)),new Error(`Can't log in: ${t}`)}return e}async function Mi(e,t,n){let i=e.me?await Li(t,e.me):[];return!0===n?i=i.filter(e=>"public"===e.scope.label):!1===n&&(i=i.filter(e=>"private"===e.scope.label)),e.instances=i.map(e=>e.instance),e}function Ui(e,t){return`${e.me&&e.me.sameTerm(t.agent)?"":F(t.agent)+" "}${t.label}`}async function Fi(e,t,n){function i(i){const a=function(e){const i=Ri(t,n),a=i.length?i[0]:Ei(e);return[(0,g.st)(a,b.solid("instance"),t,e),(0,g.st)(a,b.solid("forClass"),n,e)]}(i.index),o=`${Ui(e,i)} link to this ${e.noun}`;return Ci(e.dom,v.solidLogicSingleton.store,o,null,a,l,i.index)}const a=e.dom;if(!a||!e.div)throw new Error("registrationControl: need dom and div");const o=a.createElement("div");e.div.appendChild(o),e.me=v.authn.currentUser();const s=e.me;if(!s)return o.innerHTML='<p style="margin:2em;">(Log in to save a link to this)</p>',e;let r;try{r=await Ni(s)}catch(t){let n;return e.div&&e.preferencesFileError?(n="(Lists of stuff not available)",e.div.appendChild(a.createElement("p")).textContent=n):e.div&&(n=`registrationControl: Type indexes not available: ${t}`,e.div.appendChild(nt(e.dom,t))),xe.Rm(n),e}o.innerHTML="<table><tbody></tbody></table>",o.setAttribute("style","font-size: 120%; text-align: right; padding: 1em; border: solid gray 0.05em;");const c=o.children[0].children[0],l=new g.BlankNode;for(const e of r){c.appendChild(a.createElement("tr")).appendChild(i(e))}return e}function Pi(e,t,n){const{dom:i}=e,a=Ui(e,n),o=i.createElement("tr"),s=o.appendChild(i.createElement("td"));s.setAttribute("colspan","3"),s.style.backgoundColor={private:"#fee",public:"#efe"}[n.label]||"white";const r=s.appendChild(i.createElement("h3"));return r.textContent=a+" links",r.style.textAlign="left",o}async function zi(e,t){const n=e.dom,i=e.div,a=n.createElement("div");if(i.appendChild(a),e.me=v.authn.currentUser(),!e.me)return a.innerHTML='<p style="margin:2em;">(Log in list your stuff)</p>',e;const o=await Ni(e.me);a.innerHTML="<table><tbody></tbody></table>",a.setAttribute("style","font-size: 120%; text-align: right; padding: 1em; border: solid #eee 0.5em;");const s=a.firstChild.firstChild;for(const i of o){const a=Pi(e,0,i);s.appendChild(a);const o=await Ii(i,t.type||null);0===o.length&&(a.style.display="none");for(const e of o){const t=Ft(n,b.solid("instance"),e.instance,{deleteFunction:async()=>{await $i(e),s.removeChild(t)}});t.children[0].style.paddingLeft="3em",s.appendChild(t)}}return e}function qi(e){const t=e.createElement("div");t.setAttribute("style","position: fixed; top: 0; left: 0; right: 0; bottom: 0; display: flex; justify-content: center; align-items: center;"),e.body.appendChild(t);const n=e.createElement("div");n.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 "),t.appendChild(n);const i=e.createElement("div");i.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 "),n.appendChild(i);const a=e.createElement("label");a.setAttribute("style","margin-right: 5px; font-weight: 800"),a.innerText="Select an identity provider";const o=e.createElement("button");o.innerHTML='<img src="https://solidos.github.io/solid-ui/src/icons/noun_1180156.svg" style="width: 2em; height: 2em;" title="Cancel">',o.setAttribute("style","background-color: transparent; border: none;"),o.addEventListener("click",()=>{t.remove()}),i.appendChild(a),i.appendChild(o);const s=async e=>{try{v.solidLogicSingleton.store.updater.flagAuthorizationMetadata();const t=new URL(window.location.href).hash;t&&window.localStorage.setItem("preLoginRedirectHash",t),window.localStorage.setItem("loginIssuer",e);const n=new URL(window.location.href);n.hash="",await v.authSession.login({redirectUrl:n.href,oidcIssuer:e})}catch(e){R(e.message)}},r=e.createElement("div");r.setAttribute("style","\n border-bottom: 1px solid #DDD;\n display: flex;\n flex-direction: column;\n padding-top: 10px;\n ");const c=e.createElement("div");c.setAttribute("style","\n display: flex;\n flex-direction: row;\n ");const l=e.createElement("label");l.innerText="Enter the URL of your identity provider:",l.setAttribute("style","color: #888");const p=e.createElement("input");p.setAttribute("type","text"),p.setAttribute("style","margin-left: 0 !important; flex: 1; margin-right: 5px !important"),p.setAttribute("placeholder","https://example.com"),p.value=localStorage.getItem("loginIssuer")||"";const u=e.createElement("button");u.innerText="Go",u.setAttribute("style","margin-top: 12px; margin-bottom: 12px;"),u.addEventListener("click",()=>{s(p.value)}),r.appendChild(l),c.appendChild(p),c.appendChild(u),r.appendChild(c),n.appendChild(r);const d=e.createElement("div");d.setAttribute("style","\n display: flex;\n flex-direction: column;\n padding-top: 10px;\n ");const m=e.createElement("label");m.innerText="Or pick an identity provider from the list below:",m.setAttribute("style","color: #888"),d.appendChild(m),(0,v.getSuggestedIssuers)().forEach(t=>{const n=e.createElement("button");n.innerText=t.name,n.setAttribute("style","height: 38px; margin-top: 10px"),n.addEventListener("click",()=>{s(t.uri)}),d.appendChild(n)}),n.appendChild(d)}function Hi(e,t=null,n={}){let i=(0,v.offlineTestID)();const a=e.createElement("div");function o(e){e&&(i=v.authn.saveUser(e),a.refresh(),t&&t(i.uri))}function s(e){const n=i;v.authSession.logout().then(function(){const e=`Your WebID was ${n}. It has been forgotten.`;i=null;try{R(e)}catch(t){window.alert(e)}a.refresh(),t&&t(null)},e=>{R("Fail to log out:"+e)})}function r(){i=v.authn.currentUser(),a.refresh()}return a.refresh=function(){const t=v.authSession.info;i=t&&t.webId&&t.isLoggedIn?v.solidLogicSingleton.store.sym(t.webId):null,(i&&a.me!==i.uri||!i&&a.me)&&(yt(a),i?a.appendChild(function(t,n){const i=n.buttonStyle||Ke.signInAndUpButtonStyle;let a="WebID logout";if(t){const e=v.solidLogicSingleton.store.any(t,b.foaf("nick"))||v.solidLogicSingleton.store.any(t,b.foaf("name"));e&&(a="Logout "+e.value)}const o=e.createElement("input");return o.setAttribute("type","button"),o.setAttribute("value",a),o.setAttribute("style",`${i}`),o.addEventListener("click",s,!1),o}(i,n)):a.appendChild(function(e,t,n={}){const i=(n=n||{}).buttonStyle||Ke.signInAndUpButtonStyle,a=e.createElement("div"),o="SolidSignInOrSignUpBox";xe.Rm("widgets.signInOrSignUpBox"),a.setUserCallback=t,a.setAttribute("class",o),a.setAttribute("style","display:flex;");const s=e.createElement("input");a.appendChild(s),s.setAttribute("type","button"),s.setAttribute("value","Log in"),s.setAttribute("style",`${i}${Ke.headerBannerLoginInput}`+Ke.signUpBackground),v.authSession.events.on("login",()=>{const t=v.authn.currentUser();if(t){const n=t.uri,i=e.getElementsByClassName(o);xe.Rm(`Logged in, ${i.length} panels to be serviced`);for(let t=0;t<i.length;t++){const a=i[t];if(a.setUserCallback)try{a.setUserCallback(n);const e=a.parentNode;e&&e.removeChild(a)}catch(t){xe.Rm(`## Error satisfying login box: ${t}`),a.appendChild(nt(e,t))}}}}),s.addEventListener("click",()=>{const n=(0,v.offlineTestID)();if(n)return t(n.uri);qi(e)},!1);const r=e.createElement("input");return a.appendChild(r),r.setAttribute("type","button"),r.setAttribute("value","Sign Up for Solid"),r.setAttribute("style",`${i}${Ke.headerBannerLoginInput}`+Ke.signInBackground),r.addEventListener("click",function(e){(new Ti).signup().then(function(e){xe.Rm("signInOrSignUpBox signed up "+e),t(e)})},!1),a}(e,o,n))),a.me=i?i.uri:null},a.refresh(),r(),v.authSession.events.on("login",r),v.authSession.events.on("logout",r),a.me="99999",a.refresh(),a}function Vi(e,t,n){const i=t.noun,a=t.appPathSegment,o=(0,v.offlineTestID)(),s=e.createElement("div"),r={me:o,dom:e,div:s};function c(t,n){s.appendChild(nt(e,t,n))}function l(e){const t=v.solidLogicSingleton.store.any(e,b.space("uriPrefix"));let n;n=t?t.value:e.uri.split("#")[0],"/"!==n.slice(-1)&&(xe.Rm(`${a}: No / at end of uriPrefix ${n}`),n=`${n}/`);const i=new Date;return n+=`${a}/id${i.getTime()}/`,n}return Di(r).then(function(t){const a=t.me,o=t.preferencesFile;let r=null,p=v.solidLogicSingleton.store.each(a,b.space("workspace"),void 0,o);const u=v.solidLogicSingleton.store.each(a,b.space("storage"));0===p.length&&u&&(c(`You don't seem to have any workspaces. You have ${u.length} storage spaces.`,"white"),u.map(function(e){return p=p.concat(v.solidLogicSingleton.store.each(e,b.ldp("contains"))),p}).filter(e=>e.id?["public","private"].includes(e.id().toLowerCase()):"")),1===p.length&&(c(`Workspace used: ${p[0].uri}`,"white"),r=l(p[0]));const d=e.createElement("table");d.setAttribute("style","border-collapse:separate; border-spacing: 0.5em;"),s.appendChild(d),s.appendChild(e.createElement("hr"));const m=s.appendChild(e.createElement("p"));m.setAttribute("style",Ke.commentStyle),m.textContent=`Where would you like to store the data for the ${i}?\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.`;const f=s.appendChild(e.createElement("input"));f.setAttribute("type","text"),f.setAttribute("style",Ke.textInputStyle),f.size=80,f.label="base URL",f.autocomplete="on",r&&(f.value=r),t.baseField=f,s.appendChild(e.createElement("br"));const h=s.appendChild(e.createElement("button"));let x,y,w,C,E,k,A;h.setAttribute("style",Ke.buttonStyle),h.textContent=`Start new ${i} at this URI`,h.addEventListener("click",function(e){let t=f.value.replace(" ","%20");"/"!==t.slice(-1)&&(t+="/"),n(null,t)}),p=p.filter(function(e){return!v.solidLogicSingleton.store.holds(e,b.rdf("type"),b.space("MasterWorkspace"))});const _="height: 3em; margin: 1em; padding: 1em white; border-radius: 0.3em;",T=`${_}border: 0px;`;for(let t=0;t<p.length;t++){if(E=p[t],C=e.createElement("tr"),0===t&&(x=e.createElement("td"),x.setAttribute("rowspan",`${p.length}`),x.textContent="Choose a workspace for this:",x.setAttribute("style","vertical-align:middle;"),C.appendChild(x)),y=e.createElement("td"),k=v.solidLogicSingleton.store.anyValue(E,b.ui("style")),!k){const e=`#${(16777215&function(e){return e.split("").reduce(function(e,t){return(e=(e<<5)-e+t.charCodeAt(0))&e},0)}(E.uri)|12632256).toString(16)}`;k=`color: black ; background-color: ${e};`}y.setAttribute("style",T+k),C.target=E.uri;let i=v.solidLogicSingleton.store.any(E,b.rdfs("label"));i||(i=E.uri.split("/").slice(-1)[0]||E.uri.split("/").slice(-2)[0]),y.textContent=i||"???",C.appendChild(y),0===t&&(w=e.createElement("td"),w.setAttribute("rowspan",`${p.length}1`),w.setAttribute("style","width:50%;"),C.appendChild(w)),d.appendChild(C),A=v.solidLogicSingleton.store.any(E,b.rdfs("comment")),A=A?A.value:"Use this workspace",y.addEventListener("click",function(t){w.textContent=A?A.value:"",w.setAttribute("style",T+k);const i=e.createElement("button");i.textContent="Continue";const a=l(E);f.value=a,i.addEventListener("click",function(e){i.disabled=!0,n(E,a),i.textContent="----\x3e"},!0),w.appendChild(i)},!0)}const S=e.createElement("tr");y=e.createElement("td"),y.setAttribute("style",_),y.textContent="+ Make a new workspace",y.addEventListener("click",async function(n){const i=d.appendChild(e.createElement("tr")).appendChild(e.createElement("td"));i.setAttribute("colspan","3"),i.style.padding="0.5em";const a=encodeURI(await Ut(e,v.solidLogicSingleton.store,i,b.solid("URL"),b.space("Workspace"),"Workspace")),o=Ei(t.preferencesFile),s=[(0,g.st)(t.me,b.space("workspace"),o,t.preferencesFile),(0,g.st)(o,b.space("uriPrefix"),a,t.preferencesFile)];if(!v.solidLogicSingleton.store.updater)throw new Error("store has no updater");await v.solidLogicSingleton.store.updater.update([],s)}),S.appendChild(y),d.appendChild(S)}).catch(e=>{s.appendChild(nt(r.dom,e))}),s}function Gi(e,t,n){const i=function(e,t){n(e,t)},a=e.createElement("div"),o=e.createElement("button");return o.setAttribute("type","button"),a.appendChild(o),o.innerHTML=`Make new ${t.noun}`,o.addEventListener("click",n=>{a.appendChild(Vi(e,t,i))},!1),a.appendChild(o),a}async function Wi(){try{const{me:e,preferencesFile:t,preferencesFileError:n}=await Di({});if(!t||n)throw new Error(n);return v.solidLogicSingleton.store.each(e,b.rdf("type"),null,t.doc())}catch(e){xe.R8("Unable to fetch your preferences - this was the error: ",e)}return[]}async function Ji(e){const t=await Wi();return e.filter(e=>function(e,t){const n=e.audience||[];return n.reduce((e,n)=>e&&!!t.find(e=>e.equals(n)),!0)}(e,t))}v.authSession.events.on("logout",async()=>{const e=window.localStorage.getItem("loginIssuer");if(e)try{v.solidLogicSingleton.store.updater.flagAuthorizationMetadata();const t=new URL(e);t.pathname="/.well-known/openid-configuration";const n=await fetch(t.toString());if(200===n.status){const e=await n.json();e&&e.end_session_endpoint&&await fetch(e.end_session_endpoint,{credentials:"include"})}}catch(e){}window.location.reload()});class Qi{rootElement;barElement;isExpanded=!1;constructor(e){this.groupList=e,this.rootElement=e.controller.dom.createElement("div"),this.barElement=e.controller.dom.createElement("div")}render(){return this.rootElement.innerHTML="",this.rootElement.appendChild(this.renderAddButton()),this.rootElement.appendChild(this.barElement),this.rootElement}renderAddButton(){return Dt(this.groupList.controller.dom,`${it.Pt.iconBase}noun_34653_green.svg`,"Add ...",()=>{this.toggleBar(),this.renderBar()})}renderBar(){this.barElement.innerHTML="",this.isExpanded&&(this.barElement.appendChild(this.renderPersonButton()),this.barElement.appendChild(this.renderGroupButton()),this.barElement.appendChild(this.renderPublicButton()),this.barElement.appendChild(this.renderAuthenticatedAgentButton()),this.barElement.appendChild(this.renderBotButton()),this.barElement.appendChild(this.renderAppsButton()))}renderSimplifiedBar(e){Array.from(this.barElement.children).filter(t=>t!==e).forEach(e=>this.barElement.removeChild(e))}renderPersonButton(){return Dt(this.groupList.controller.dom,it.Pt.iconBase+St["vcard:Individual"],"Add Person",e=>{this.renderSimplifiedBar(e.target),this.renderNameForm(b.vcard("Individual"),"person").then(e=>this.addPerson(e)).then(()=>this.renderCleanup()).catch(e=>this.groupList.controller.renderStatus(e))})}renderGroupButton(){return Dt(this.groupList.controller.dom,it.Pt.iconBase+St["vcard:Group"],"Add Group",e=>{this.renderSimplifiedBar(e.target),this.renderNameForm(b.vcard("Group"),"group").then(e=>this.addGroup(e)).then(()=>this.renderCleanup()).catch(e=>this.groupList.controller.renderStatus(e))})}renderNameForm(e,t){return Ut(this.groupList.controller.dom,this.groupList.store,this.barElement,b.vcard("URI"),e,t)}renderPublicButton(){return Dt(this.groupList.controller.dom,it.Pt.iconBase+St["foaf:Agent"],"Add Everyone",()=>this.addAgent(b.foaf("Agent").uri).then(()=>this.groupList.controller.renderTemporaryStatus("Adding the general public to those who can read. Drag the globe to a different level to give them more access.")).then(()=>this.renderCleanup()))}renderAuthenticatedAgentButton(){return Dt(this.groupList.controller.dom,`${it.Pt.iconBase}noun_99101.svg`,"Anyone logged In",()=>this.addAgent(b.acl("AuthenticatedAgent").uri).then(()=>this.groupList.controller.renderTemporaryStatus("Adding anyone logged in to those who can read. Drag the ID icon to a different level to give them more access.")).then(()=>this.renderCleanup()))}renderBotButton(){return Dt(this.groupList.controller.dom,it.Pt.iconBase+"noun_Robot_849764.svg","A Software Agent (bot)",e=>{this.renderSimplifiedBar(e.target),this.renderNameForm(b.schema("Application"),"bot").then(e=>this.addBot(e)).then(()=>this.renderCleanup())})}renderAppsButton(){return Dt(this.groupList.controller.dom,`${it.Pt.iconBase}noun_15177.svg`,"A Web App (origin)",e=>{this.renderSimplifiedBar(e.target);const t={div:this.barElement,dom:this.groupList.controller.dom},n=this.renderAppsTable(t).catch(e=>this.groupList.controller.renderStatus(e));this.renderAppsView();const i=this.renderNameForm(b.schema("WebApplication"),"webapp domain").then(e=>this.getOriginFromName(e));Promise.race([n,i]).then(e=>{e&&this.groupList.addNewURI(e)}).then(()=>this.renderCleanup())})}renderAppsView(){const e=this.groupList.controller.context.session.paneRegistry.byName("trustedApplications");if(e){const t=e.render(null,this.groupList.controller.context);t.setAttribute("style",Ke.trustedAppController);const n=Ot(this.groupList.controller.dom,()=>this.renderCleanup());n.setAttribute("style",Ke.trustedAppCancelButton),t.insertBefore(n,t.firstChild),this.barElement.appendChild(t)}}async renderAppsTable(e){await Oi(e);const t=this.groupList.store.each(e.me,b.acl("trustedApp")),n=t.flatMap(e=>this.groupList.store.each(e,b.acl("origin")));return this.barElement.appendChild(this.groupList.controller.dom.createElement("p")).textContent=`You have ${n.length} selected web apps.`,new Promise((e,n)=>{const i=this.barElement.appendChild(this.groupList.controller.dom.createElement("table"));i.setAttribute("style",Ke.trustedAppAddApplicationsTable),t.forEach(t=>{const a=this.groupList.store.any(t,b.acl("origin"));a||n(new Error(`Unable to pick app: ${t.value}`));const o=Ft(this.groupList.controller.dom,b.acl("origin"),a,{}),s=this.groupList.controller.dom.createElement("table"),r=s.appendChild(this.groupList.controller.dom.createElement("tr"));r.appendChild(this.groupList.controller.dom.createElement("td")).appendChild(o);r.appendChild(this.groupList.controller.dom.createElement("td")).textContent=`Give access to ${this.groupList.controller.noun} ${F(this.groupList.controller.subject)}?`;r.appendChild(this.groupList.controller.dom.createElement("td")).appendChild(Mt(this.groupList.controller.dom,()=>e(a.value))),i.appendChild(s)})})}renderCleanup(){this.renderBar(),this.groupList.render()}async addPerson(e){if(!e)return this.toggleBar();if(!e.match(/^https?:/i))return Promise.reject(new Error("Not a http URI"));xe.Rm(`Adding to ACL person: ${e}`),await this.groupList.addNewURI(e),this.toggleBar()}async addGroup(e){if(!e)return this.toggleBar();if(!e.match(/^https?:/i))return Promise.reject(new Error("Not a http URI"));xe.Rm("Adding to ACL group: "+e),await this.groupList.addNewURI(e),this.toggleBar()}async addAgent(e){await this.groupList.addNewURI(e),this.toggleBar()}async addBot(e){if(!e)return this.toggleBar();if(!e.match(/^https?:/i))return Promise.reject(new Error("Not a http URI"));xe.Rm("Adding to ACL bot: "+e),await this.groupList.addNewURI(e),this.toggleBar()}async getOriginFromName(e){if(!e)return Promise.resolve();if(!e.match(/^([a-z0-9]+(-[a-z0-9]+)*\.)+[a-z]{2,}$/i))return Promise.reject(new Error("Not a domain name"));const t="https://"+e;return xe.Rm("Adding to ACL origin: "+t),this.toggleBar(),t}toggleBar(){this.isExpanded=!this.isExpanded}}const Zi=b.acl,Yi={13:"Owners",9:"Owners (write locked)",5:"Editors",3:"Posters",2:"Submitters",1:"Viewers"},Ki={13:!0,5:!0,3:!0,2:!0,1:!0},Xi={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"};class ea{defaults;byCombo;aclMap;addAgentButton;rootElement;_store;constructor(e,t,n,i,a={}){this.doc=e,this.aclDoc=t,this.controller=n,this._options=a,this.defaults=this._options.defaults||!1,this._store=i,this.aclMap=Ce(e,0,i,this.defaults),this.byCombo=_e(this.aclMap),this.addAgentButton=new Qi(this),this.rootElement=this.controller.dom.createElement("div"),this.rootElement.setAttribute("style",Ke.accessGroupList)}get store(){return this._store}set store(e){this._store=e,this.aclMap=Ce(this.doc,this.aclDoc,e,this.defaults),this.byCombo=_e(this.aclMap)}render(){return this.rootElement.innerHTML="",this.renderGroups().forEach(e=>this.rootElement.appendChild(e)),this.controller.isEditable&&this.rootElement.appendChild(this.addAgentButton.render()),this.rootElement}renderGroups(){const e=[];for(let t=15;t>0;t--){const n=ta(t);(this.controller.isEditable&&Ki[t]||this.byCombo[n])&&e.push(this.renderGroup(t,n))}return e}renderGroup(e,t){const n=this.controller.dom.createElement("div");n.setAttribute("style",Ke.accessGroupListItem),Xe(n,e=>this.handleDroppedUris(e,t).then(()=>this.controller.render()).catch(e=>this.controller.renderStatus(e)));return this.renderGroupElements(e,t).forEach(e=>n.appendChild(e)),n}renderGroupElements(e,t){const n=this.controller.dom.createElement("div");if(n.setAttribute("style",Ke.group),this.controller.isEditable)switch(e){case 1:n.setAttribute("style",Ke.group1);break;case 2:n.setAttribute("style",Ke.group2);break;case 3:n.setAttribute("style",Ke.group3);break;case 5:n.setAttribute("style",Ke.group5);break;case 9:n.setAttribute("style",Ke.group9);break;case 13:n.setAttribute("style",Ke.group13);break;default:n.setAttribute("style",Ke.group)}n.innerText=Yi[e]||function(e){let t="";const n=["Read","Append","Write","Control"];for(let i=0;i<4;i++)e&1<<i&&(t+=n[i]);return t}(e);const i=this.controller.dom.createElement("div");if(i.setAttribute("style",Ke.group),this.controller.isEditable)switch(e){case 1:i.setAttribute("style",Ke.group1);break;case 2:i.setAttribute("style",Ke.group2);break;case 3:i.setAttribute("style",Ke.group3);break;case 5:i.setAttribute("style",Ke.group5);break;case 9:i.setAttribute("style",Ke.group9);break;case 13:i.setAttribute("style",Ke.group13);break;default:i.setAttribute("style",Ke.group)}const a=i.appendChild(this.controller.dom.createElement("table"));(this.byCombo[t]||[]).map(([e,n])=>this.renderAgent(a,t,e,n)).forEach(e=>a.appendChild(e));const o=this.controller.dom.createElement("div");if(o.setAttribute("style",Ke.group),this.controller.isEditable)switch(e){case 1:o.setAttribute("style",Ke.group1);break;case 2:o.setAttribute("style",Ke.group2);break;case 3:o.setAttribute("style",Ke.group3);break;case 5:o.setAttribute("style",Ke.group5);break;case 9:o.setAttribute("style",Ke.group9);break;case 13:o.setAttribute("style",Ke.group13);break;default:o.setAttribute("style",Ke.group)}return o.innerText=Xi[e]||"Unusual combination",[n,i,o]}renderAgent(e,t,n,i){const a=Ft(this.controller.dom,Zi(n),(0,g.sym)(i),this.controller.isEditable?{deleteFunction:()=>this.deleteAgent(t,n,i).then(()=>e.removeChild(a)).catch(e=>this.controller.renderStatus(e))}:{});return a}async deleteAgent(e,t,n){const i=this.byCombo[e]||[],a=i.find(([e,i])=>e===t&&i===n);a&&i.splice(i.indexOf(a),1),await this.controller.save()}async addNewURI(e){await this.handleDroppedUri(e,ta(1)),await this.controller.save()}async handleDroppedUris(e,t){try{await Promise.all(e.map(e=>this.handleDroppedUri(e,t))),await this.controller.save()}catch(e){return Promise.reject(e)}}async handleDroppedUri(e,t,n=!1){const i=function(e,t){const n=(0,g.sym)(e),i=t.findTypeURIs(n);for(const e in i)xe.Rm(" drop object type includes: "+e);if(e.startsWith("http")&&3===e.split("/").length)return{pred:"origin",obj:n};if(e.startsWith("http")&&4===e.split("/").length&&e.endsWith("/"))return xe.Rm("Assuming final slash on dragged origin URI was unintended!"),{pred:"origin",obj:(0,g.sym)(e.slice(0,-1))};if(b.vcard("WebID").uri in i)return{pred:"agent",obj:n};if(b.vcard("Group").uri in i)return{pred:"agentGroup",obj:n};if(n.sameTerm(b.foaf("Agent"))||n.sameTerm(b.acl("AuthenticatedAgent"))||n.sameTerm(b.rdf("Resource"))||n.sameTerm(b.owl("Thing")))return{pred:"agentClass",obj:n};if(b.vcard("Individual").uri in i||b.foaf("Person").uri in i||b.foaf("Agent").uri in i){const e=t.any(n,b.foaf("preferredURI"));return e?{pred:"agent",obj:(0,g.sym)(e)}:{pred:"agent",obj:n}}if(b.solid("AppProvider").uri in i)return{pred:"origin",obj:n};if(b.solid("AppProviderClass").uri in i)return{pred:"originClass",obj:n};return xe.Rm(" Triage fails for "+e),null}(e,this.store),a=(0,g.sym)(e);if(!i&&!n){xe.Rm(` Not obvious: looking up dropped thing ${a}`);try{await(this._store?.fetcher?.load(a.doc()))}catch(e){const t=`Ignore error looking up dropped thing: ${e}`;return xe.z3(t),Promise.reject(new Error(t))}return this.handleDroppedUri(e,t,!0)}if(!i){const t=Object.keys(this.store.findTypeURIs(a)),n=`Error: Failed to add access target: ${e} is not a recognized ACL target type. Expected one of: vcard:WebID, vcard:Group, foaf:Person, foaf:Agent, solid:AppProvider, solid:AppProviderClass, or recognized ACL classes. Hint: try dropping a WebID profile URI, a vcard:Group URI, or a web app origin.`+(t.length>0?`Detected RDF types: ${t.join(", ")}`:"No RDF type was detected for this URI.");return xe.z3(n),Promise.reject(new Error(n))}this.setACLCombo(t,e,i,this.controller.subject)}setACLCombo(e,t,n,i){e in this.byCombo||(this.byCombo[e]=[]),this.removeAgentFromCombos(t),this.byCombo[e].push([n.pred,n.obj.uri]),xe.Rm(`ACL: setting access to ${i} by ${n.pred}: ${n.obj}`)}removeAgentFromCombos(e){for(let t=0;t<16;t++){const n=this.byCombo[ta(t)];if(n)for(let t=0;t<n.length;t++)for(;t<n.length&&n[t][1]===e;)n.splice(t,1)}}}function ta(e){const t=["Read","Append","Write","Control"],n=[];for(let i=0;i<4;i++)e&1<<i&&n.push("http://www.w3.org/ns/auth/acl#"+t[i]);return n.sort(),n.join("\n")}class na{mainCombo;defaultsCombo;isContainer;defaultsDiffer;rootElement;isUsingDefaults;constructor(e,t,n,i,a,o,s,r,c,l,p,u){if(this.subject=e,this.noun=t,this.context=n,this.statusElement=i,this.targetIsProtected=a,this.targetDoc=o,this.targetACLDoc=s,this.defaultHolder=r,this.defaultACLDoc=c,this.prospectiveDefaultHolder=l,this.store=p,this.dom=u,this.rootElement=u.createElement("div"),this.rootElement.setAttribute("style",Ke.aclGroupContent),this.isContainer="/"===o.uri.slice(-1),r&&c){this.isUsingDefaults=!0;const e=we(this.targetDoc,s,r,c);this.mainCombo=new ea(o,s,this,e,{defaults:this.isContainer}),this.defaultsCombo=null,this.defaultsDiffer=!1}else this.isUsingDefaults=!1,this.mainCombo=new ea(o,s,this,p),this.defaultsCombo=new ea(o,s,this,p,{defaults:this.isContainer}),this.defaultsDiffer=!Ee(this.mainCombo.aclMap,this.defaultsCombo.aclMap)}get isEditable(){return!this.isUsingDefaults}render(){if(this.rootElement.innerHTML="",this.isUsingDefaults){if(this.renderStatus(`The sharing for this ${this.noun} is the default for folder `),this.defaultHolder){const e=this.statusElement.appendChild(this.dom.createElement("a"));e.href=this.defaultHolder.uri,e.innerText=ra(this.defaultHolder)}}else!this.defaultsDiffer&&this.isContainer?this.renderStatus("This is also the default for things in this folder."):this.renderStatus("");return this.rootElement.appendChild(this.mainCombo.render()),this.defaultsCombo&&this.defaultsDiffer?(this.rootElement.appendChild(this.renderRemoveDefaultsController()),this.rootElement.appendChild(this.defaultsCombo.render())):this.isEditable&&this.isContainer&&this.rootElement.appendChild(this.renderAddDefaultsController()),!this.targetIsProtected&&this.isUsingDefaults?this.rootElement.appendChild(this.renderAddAclsController()):this.targetIsProtected||this.rootElement.appendChild(this.renderRemoveAclsController()),this.rootElement}renderRemoveAclsController(){const e=this.dom.createElement("button");return e.innerText=`Remove custom sharing settings for this ${this.noun} -- just use default${this.prospectiveDefaultHolder?` for ${F(this.prospectiveDefaultHolder)}`:""}`,e.setAttribute("style",Ke.bigButton),e.addEventListener("click",()=>this.removeAcls().then(()=>this.render()).catch(e=>this.renderStatus(e))),e}renderAddAclsController(){const e=this.dom.createElement("button");return e.innerText=`Set specific sharing for this ${this.noun}`,e.setAttribute("style",Ke.bigButton),e.addEventListener("click",()=>this.addAcls().then(()=>this.render()).catch(e=>this.renderStatus(e))),e}renderAddDefaultsController(){const e=this.dom.createElement("div");e.setAttribute("style",Ke.defaultsController);const t=e.appendChild(this.dom.createElement("div"));t.innerText="Sharing for things within the folder currently tracks sharing for the folder.",t.setAttribute("style",Ke.defaultsControllerNotice);const n=e.appendChild(this.dom.createElement("button"));return n.innerText="Set the sharing of folder contents separately from the sharing for the folder",n.setAttribute("style",Ke.bigButton),n.addEventListener("click",()=>this.addDefaults().then(()=>this.render())),e}renderRemoveDefaultsController(){const e=this.dom.createElement("div");e.setAttribute("style",Ke.defaultsController);const t=e.appendChild(this.dom.createElement("div"));t.innerText="Access to things within this folder:",t.setAttribute("style",Ke.defaultsControllerNotice);const n=e.appendChild(this.dom.createElement("button"));return n.innerText="Set default for folder contents to just track the sharing for the folder",n.setAttribute("style",Ke.bigButton),n.addEventListener("click",()=>this.removeDefaults().then(()=>this.render()).catch(e=>this.renderStatus(e))),e}renderTemporaryStatus(e){this.statusElement.setAttribute("style",Ke.aclControlBoxStatusRevealed),this.statusElement.innerText=e,this.statusElement.setAttribute("style",Ke.temporaryStatusInit),setTimeout(()=>{this.statusElement.setAttribute("style",Ke.temporaryStatusEnd)}),setTimeout(()=>{this.statusElement.innerText=""},5e3)}renderStatus(e){e||this.statusElement.setAttribute("style",Ke.aclControlBoxStatusRevealed),this.statusElement.innerText=e}async addAcls(){if(!this.defaultHolder||!this.defaultACLDoc){const e="Unable to find defaults to copy";return xe.z3(e),Promise.reject(e)}we(this.targetDoc,this.targetACLDoc,this.defaultHolder,this.defaultACLDoc).statements.forEach(e=>this.store.add(e.subject,e.predicate,e.object,this.targetACLDoc));try{return await this.store.fetcher.putBack(this.targetACLDoc),this.isUsingDefaults=!1,Promise.resolve()}catch(e){const t=` Error writing back access control file! ${e}`;return xe.z3(t),Promise.reject(t)}}async addDefaults(){this.defaultsCombo=new ea(this.targetDoc,this.targetACLDoc,this,this.store,{defaults:!0}),this.defaultsDiffer=!0}async removeAcls(){try{await this.store.fetcher.delete(this.targetACLDoc.uri,{}),this.isUsingDefaults=!0;try{this.prospectiveDefaultHolder=await Be(this.targetDoc.uri)}catch(e){xe.R8(e)}}catch(e){const t=`Error deleting access control file: ${this.targetACLDoc}: ${e}`;return xe.z3(t),Promise.reject(t)}}async removeDefaults(){const e=this.defaultsCombo;try{this.defaultsCombo=null,this.defaultsDiffer=!1,await this.save()}catch(t){return this.defaultsCombo=e,this.defaultsDiffer=!0,xe.z3(t),Promise.reject(t)}}save(){const e=(0,g.graph)();this.isContainer?this.defaultsCombo&&this.defaultsDiffer?(Se(e,this.targetDoc,this.mainCombo.byCombo,this.targetACLDoc,!0),Se(e,this.targetDoc,this.defaultsCombo.byCombo,this.targetACLDoc,!1,!0)):Se(e,this.targetDoc,this.mainCombo.byCombo,this.targetACLDoc,!0,!0):Se(e,this.targetDoc,this.mainCombo.byCombo,this.targetACLDoc,!0),e.fetcher=(0,g.fetcher)(e,{fetch:this.store.fetcher._fetch});const t=e.updater||new g.UpdateManager(e);return new Promise((n,i)=>{t.put(this.targetACLDoc,e.statementsMatching(void 0,void 0,void 0,this.targetACLDoc),"text/turtle",(t,a,o)=>{if(!a)return i(new Error(`ACL file save failed: ${o}`));this.store.fetcher.unload(this.targetACLDoc),this.store.add(e.statements),this.store.fetcher.requested[this.targetACLDoc.uri]="done",this.mainCombo.store=this.store,this.defaultsCombo&&(this.defaultsCombo.store=this.store),this.defaultsDiffer=!!this.defaultsCombo&&!Ee(this.mainCombo.aclMap,this.defaultsCombo.aclMap),xe.Rm("ACL modification: success!"),n()})})}}let ia=window;const aa=Symbol("prevent double triggering of drop event");function oa(e){e.stopPropagation(),e.preventDefault()}function sa(e){e.dataTransfer.files.length>0&&(ia.confirm("Are you sure you want to drop this file here? (Cancel opens it in a new tab)")||(e.stopPropagation(),e.preventDefault(),(0,xe.Rm)("@@@@ document-level DROP suppressed: "+e.dataTransfer.dropEffect)))}function ra(e){let t=e.uri;"/"===t.slice(-1)&&(t=t.slice(0,-1));const n=t.lastIndexOf("/");return n>=0&&(t=t.slice(n+1)),t||"/"}const ca={adoptACLDefault:we,readACL:Ce,sameACL:Ee,ACLunion:ke,loadUnionACL:Ae,ACLbyCombination:_e,makeACLGraph:Te,makeACLGraphbyCombo:Se,ACLToString:function(e){return je(_e(e))},comboToString:je,makeACLString:function(e,t,n){const i=(0,g.graph)();return Te(i,e,t,n),(0,g.serialize)(n,i,n.uri,"text/turtle")||""},putACLObject:Le,putACLbyCombo:Re,fixIndividualCardACL:function(e,t,n){const i=ye.each(void 0,b.vcard("hasMember"),e);i?Ne(e,i,t,n):(t("This card is in no groups"),n(!0))},fixIndividualACL:Ne,setACL:function(e,t,n){const i=ye.any(e,v.ACL_LINK);if(!ye.fetcher)throw new Error("Store has no fetcher");i?ye.fetcher.webOperation("PUT",i.value,{data:t,contentType:"text/turtle"}).then(e=>{n(e.ok,e.error||"")}):ye.fetcher.nowOrWhenFetched(e,void 0,function(i,a){if(!i)return n(i,"Gettting headers for ACL: "+a);const o=ye.any(e,v.ACL_LINK);if(o){if(!ye.fetcher)throw new Error("Store has no fetcher");ye.fetcher.webOperation("PUT",o.value,{data:t,contentType:"text/turtle"}).then(e=>{n(e.ok,e.error||"")})}else n(!1,"No Link rel=ACL header for "+e)})},getACLorDefault:Ie,getACL:$e},la={preventBrowserDropEvents:function(e){if((0,xe.Rm)("preventBrowserDropEvents called."),void 0!==ia){if(ia[aa])return;ia[aa]=!0}e.addEventListener("drop",sa,!1),e.addEventListener("dragenter",oa,!1),e.addEventListener("dragover",oa,!1)},shortNameForFolder:ra,ACLControlBox5:function(e,t,n,i){const a=t.dom,o=e.doc(),s=a.createElement("div");s.setAttribute("style",Ke.aclControlBoxContainer);const r=s.appendChild(a.createElement("h1"));r.textContent=`Sharing for ${n} ${F(e)}`,r.setAttribute("style",Ke.aclControlBoxHeader);const c=s.appendChild(a.createElement("div"));c.setAttribute("style",Ke.aclControlBoxStatus);try{(async function(e,t,n,i,a,o,s){return new Promise((r,c)=>Ie(e,async(e,l,p,u,d,m)=>{if(!e)return c(new Error(`Error reading ${l?"":" default "}ACL. status ${p}: ${u}`));const f=function(e){const t=e.uri.split("#")[0],n=t.slice(0,-1).lastIndexOf("/"),i=t.indexOf("//");return i>=0&&n<i+2||n<0?null:t.slice(0,n+1)}(p),h=function(e,t,n){return n.holds(e,b.rdf("type"),b.space("Storage"),t)}(p,u,t)||function(e){return e.uri===e.site().uri}(p);if(!h&&f)try{const e=await Be(f);return r(g(e))}catch(e){(0,xe.R8)(e)}return r(g());function g(e){return new na(n,i,a,s,h,p,u,d,m,e,t,o)}}))})(o,i,e,n,t,a,c).then(e=>s.appendChild(e.render()))}catch(e){c.innerText=e}return s}},pa=v.solidLogicSingleton.store;const ua={newThingUI:function(e,t,n){const i=e.dom,a=e.div;if(e.me&&!e.me.uri)throw new Error("newThingUI: Invalid userid: "+e.me);const o="padding: 0.7em; width: 2em; height: 2em;",s=a.appendChild(i.createElement("img"));let r=!1;s.setAttribute("src",it.Pt.iconBase+"noun_34653_green.svg"),s.setAttribute("style",o),s.setAttribute("title","Add another tool");const c=function(e){const t=a.appendChild(i.createElement("pre"));t.setAttribute("style","background-color: pink"),t.appendChild(i.createTextNode(e))};function l(e){for(let t=0;t<u.length;t++){let n=o+e;u[t].disabled&&(n+="opacity: 0.3;"),u[t].setAttribute("style",n)}}function p(e){r=!r,s.setAttribute("style",o+(r?"background-color: yellow;":"")),l(r?"":"display: none;")}s.addEventListener("click",p);const u=[],d=Object.values(n).filter(e=>e.mintNew),m=d.reduce((e,t)=>(t.mintClass&&(e[t.mintClass.uri]=(e[t.mintClass.uri]||0)+1),e),{});d.forEach(n=>{const a=e.div.appendChild(i.createElement("img"));a.setAttribute("src",n.icon);const s=n.mintClass?m[n.mintClass.uri]>1?`${F(n.mintClass)} (using ${n.name} pane)`:F(n.mintClass):n.name+" @@";a.setAttribute("title","Make new "+s),a.setAttribute("style",o+"display: none;"),u.push(a),a.disabled||a.addEventListener("click",function(r){var u;!function(e){l("display: none;"),e.setAttribute("style",o+"background-color: yellow;")}(a),u={event:r,folder:e.folder||null,iconEle:a,pane:n,noun:s,noIndexHTML:!0,div:e.div,me:e.me,dom:e.dom,refreshTarget:e.refreshTarget},new Promise(function(n,a){let o;function s(n,o){Oi(e).then(e=>{const s=Object.assign({newBase:o,folder:u.folder||void 0,workspace:n},u);for(const e in u)s[e]=u[e];xe.Rm(`newThingUI: Minting new ${s.pane.name} at ${s.newBase}`),u.pane.mintNew(t,s).then(function(e){if(!e||!e.newInstance)throw new Error("Cannot mint new - missing newInstance");if(e.folder){const t=e.newInstance.uri.slice(e.folder.uri.length).includes("/");xe.Rm(" new thing is packge? "+t),t?pa.add(e.folder,b.ldp("contains"),pa.sym(e.newBase),e.folder.doc()):pa.add(e.folder,b.ldp("contains"),e.newInstance,e.folder.doc()),e.refreshTarget&&e.refreshTarget.refresh&&e.refreshTarget.refresh()}else{const t=u.div.appendChild(i.createElement("p"));t.setAttribute("style","font-size: 120%;"),t.innerHTML="Your <a target='_blank' href='"+e.newInstance.uri+"'><b>new "+u.noun+"</b></a> is ready to be set up. <br/><br/><a target='_blank' href='"+e.newInstance.uri+"'>Go to your new "+u.noun+".</a>"}p()}).catch(function(e){c(e),a(e)})},e=>{c("Error logging on: "+e)})}const r=u.pane;if(u.noun=r.mintClass?F(r.mintClass):r.name,u.appPathSegment=u.noun.slice(0,1).toUpperCase()+u.noun.slice(1),u.folder){const e=function(e){if(e){let t=u.folder.uri;t.endsWith("/")||(t+="/"),t=t+encodeURIComponent(e)+"/",s(null,t)}else p()};Ut(i,0,u.div,b.foaf("name"),null,u.noun).then(e)}else o=Vi(i,{noun:u.noun,appPathSegment:u.appPathSegment},s),u.div.appendChild(o)})})})}},da=v.solidLogicSingleton.store;const ma={matrixForQuery:function(e,t,n,i,a,o,s){const r=e.createElement("table"),c=e.createElement("tr");c.appendChild(e.createElement("td")).setAttribute("class","MatrixCorner"),r.appendChild(c),r.lastHeader=c;let l=[];const p=[],u=function(e,t,n,i){for(;e.firstChild;)e.removeChild(e.firstChild);e.setAttribute("style",""),e.style.textAlign="center",o.cellFunction?o.cellFunction(e,t,n,i):(e.textContent=F(i),e.setAttribute("style","padding: 0.3em")),delete e.old},d=function(t){const n=t.toNT();if(p[n])return p[n];const i=e.createElement("tr"),a=i.appendChild(e.createElement("td"));a.setAttribute("style","padding: 0.3em;"),a.textContent=F(t),"NamedNode"===t.termType&&da.fetcher.nowOrWhenFetched(t.uri.split("#")[0],void 0,function(e,n,i){e&&(a.textContent=F(t))});for(let n=0;n<l.length;n++)u(i.appendChild(e.createElement("td")),g.fromNT(l[n]),t,null);i.dataValueNT=n,p[n]=i;for(let e=r.lastHeader.nextSibling;e;e=e.nextSibling)if(n>e.dataValueNT&&o&&o.yDecreasing||n<e.dataValueNT&&(!o||!o.yDecreasing))return r.insertBefore(i,e);return r.appendChild(i)},m=function(t){const n=t.toNT();let i=null;for(let e=0;e<l.length;e++){if(l[e]===n)return e;if(n>l[e]&&o.xDecreasing||n<l[e]&&!o.xDecreasing){l=l.slice(0,e).concat([n]).concat(l.slice(e)),i=e;break}}null===i&&(i=l.length,l.push(n));for(let n=r.firstChild;n;n=n.nextSibling){const a=n.dataValueNT,o=e.createElement("td");if(o.style.textAlign="center",n===r.firstChild?o.textContent=F(t):u(o,t,g.fromNT(a),null),i===l.length-1)n.appendChild(o);else{let e=n.firstChild;for(let t=0;t<i+1;t++)e=e.nextSibling;n.insertBefore(o,e)}}return i},f=function(){let e,t;const n=[],i=[];if(o.set_y)for(let e=0;e<o.set_y.length;e++)i[o.set_y[e]]=!0;if(o.set_x)for(let e=0;e<o.set_x.length;e++)n[m(o.set_x[e])+1]=!0;for(let a=1;a<r.children.length;a++){e=r.children[a];for(let a=1;a<e.children.length;a++)if(t=e.children[a],t.old){const n=g.fromNT(e.dataValueNT),i=g.fromNT(l[a-1]);u(t,i,n,null)}else i[e.dataValueNT]=!0,n[a]=!0}for(let t=0;t<r.children.length;t++)if(e=r.children[t],t>0&&!i[e.dataValueNT])delete p[e.dataValueNT],r.removeChild(e);else for(let t=e.children.length-1;t>0;t--){const i=e.children[t];n[t]||e.removeChild(i)}const a=[];for(let e=0;e<l.length;e++)n[e+1]&&a.push(l[e]);l=a};r.refresh=function(){!function(){for(let e=1;e<r.children.length;e++){const t=r.children[e];for(let e=1;e<t.children.length;e++)t.children[e].old=!0}}(),da.query(t,h,void 0,f)};const h=function(e){const t=e[n.toString()],o=e[i.toString()],s=e[a.toString()],r=d(o),c=m(t),l=r.children[c+1];u(l,t,o,s)};if(o.set_y)for(let e=0;e<o.set_y.length;e++)d(o.set_y[e]);if(o.set_x)for(let e=0;e<o.set_x.length;e++)m(o.set_x[e]);return da.query(t,h,void 0,s),r}},fa=it.Pt.iconBase+"noun_Camera_1618446_000000.svg",ha=it.Pt.iconBase+"noun_479395.svg";function ga(e,t,n,i){const a=e.createElement("div");let o,s,r,c;const l=a.appendChild(e.createElement("table")),p=l.appendChild(e.createElement("tr")).appendChild(e.createElement("td"));p.setAttribute("colspan","4");const u=l.appendChild(e.createElement("tr"));u.appendChild(e.createElement("td")).appendChild(Ot(e)).addEventListener("click",e=>{b(),i(null)});const d=u.appendChild(e.createElement("td")).appendChild(Dt(e,ha,"Retake"));d.addEventListener("click",e=>{p.removeChild(c),h()}),d.style.visibility="collapse";const m=u.appendChild(e.createElement("td")).appendChild(Dt(e,it.Pt.iconBase+"noun_10636.svg","Snap"));m.addEventListener("click",function(){c=e.createElement("canvas"),c.setAttribute("width",Ke.canvasWidth),c.setAttribute("height",Ke.canvasHeight),c.setAttribute("style",Ke.controlStyle),p.appendChild(c);c.getContext("2d").drawImage(r,0,0,c.width,c.height),r.parentNode.removeChild(r),c.toBlob(e=>{const t=`got blob type ${e.type} size ${e.size}`;xe.Rm(t),o=n(),s=e,f.style.visibility="visible",d.style.visibility="visible",m.style.visibility="collapse"},"image/png")}),m.style.visibility="collapse";const f=u.appendChild(e.createElement("td")).appendChild(Mt(e));function h(){if(r=p.appendChild(e.createElement("video")),r.setAttribute("controls","1"),r.setAttribute("autoplay","1"),r.setAttribute("style",Ke.controlStyle),!navigator.mediaDevices)throw new Error("navigator.mediaDevices not available");navigator.mediaDevices.getUserMedia(g).then(e=>{r.srcObject=e,m.style.visibility="visible",f.style.visibility="collapse",d.style.visibility="collapse"})}f.addEventListener("click",e=>{!function(e,n){const a=e.type;xe.Rm("Putting "+e.size+" bytes of "+a+" to "+n),t.fetcher.webOperation("PUT",n.uri,{data:e,contentType:a}).then(e=>{xe.Rm("ok saved "+n),b(),i(n)},e=>{b(),alert(e)})}(s,o)}),f.style.visibility="collapse";const g={video:!0};function b(){r&&r.srcObject&&r.srcObject.getVideoTracks().forEach(e=>e.stop())}return h(),a}const ba={cameraCaptureControl:ga,cameraButton:function(e,t,n,i){const a=e.createElement("div"),o=Dt(e,fa,"Take picture");let s;async function r(e){a.removeChild(s),a.appendChild(o),i(e)}return a.appendChild(o),o.addEventListener("click",i=>{a.removeChild(o),s=ga(e,t,n,r),a.appendChild(s)}),a}},va={icons:it.Pt,ns:b,rdf:g,style:Ke,widgets:r};async function xa(e){return await v.store.fetcher.load(e),!(v.store.statementsMatching(null,b.dct("created"),null,e).length>0)}class ya{constructor(e,t,n){this.root=e,this.rootFolder=e.dir(),this.leafFileName=t||"index.ttl",this.membershipProperty=n||b.wf("leafObject")}leafDocumentFromDate(e){let t=e.toISOString().split("T")[0].replace(/-/g,"/");return t=this.root.dir().uri+t+"/"+this.leafFileName,v.store.sym(t)}dateFromLeafDocument(e){const t=this.rootFolder.uri.length,n=e.uri.slice(t,t+10).replace(/\//g,"-");return new Date(n)}async loadPrevious(e,t){async function n(e,i){function a(e){const t=e.uri.slice(0,-1).split("/").slice(-1)[0];return!!"0123456789".includes(t[0])}function o(e){return(e=e.filter(a)).sort(),t||e.reverse(),e.pop()}const s=e.dir();try{await v.store.fetcher.load(s);let n=v.store.each(s,b.ldp("contains"));n=n.filter(function(n){return!(t?n.uri>=e.uri:n.uri<=e.uri)});const i=o(n);if(i)return i}catch(e){if(!e.response||!e.response.status||404!==e.response.status)throw xe.Rm("*** Error NON 404 for chat parent file "+s),new Error(`*** ${e.message} for chat folder ${s}`);xe.Rm("Error 404 for chat parent file "+s)}if(0===i)return null;const r=await n(s,i-1);if(!r)return null;await v.store.fetcher.load(r);return o(v.store.each(r,b.ldp("contains")))}let i=this.leafDocumentFromDate(e).dir();for(;;){const t=await n(i,3);if(!t)return null;{const n=v.store.sym(t.uri+this.leafFileName),a=this.dateFromLeafDocument(n);if(!await xa(n))return a;e=a,i=this.leafDocumentFromDate(e).dir()}}}async firstLeaf(e){const t=g.graph(),n=new g.Fetcher(t);async function i(i){delete n.requested[i.uri],await n.load(i,{force:!0});let a=t.each(i,b.ldp("contains"));if(a=a.filter(function(e){const t=e.uri.slice(0,-1).split("/").slice(-1)[0];return!!"0123456789".includes(t[0])}),0===a.length)throw new Error(" @@@ No children to parent2 "+i);return a.sort(),e&&a.reverse(),a[0]}const a=await i(this.root.dir()),o=await i(a),s=await i(o),r=g.sym(s.uri+"chat.ttl");await n.load(r);const c=t.each(this.root,this.membershipProperty,null,r);if(0===c.length){const e=" INCONSISTENCY -- no chat leafObject in file "+r;throw xe.uP(e),new Error(e)}const l=c.map(e=>[t.any(e,b.dct("created")),e]);return l.sort(),e&&l.reverse(),l[0][1]}}function wa(e,t=""){if("number"!=typeof e){throw new TypeError(`${t&&`"${t}" `}expected number, got ${typeof e}`)}if(!Number.isSafeInteger(e)||e<0){throw new RangeError(`${t&&`"${t}" `}expected integer >= 0, got ${e}`)}}function Ca(e,t,n=""){const i=(a=e)instanceof Uint8Array||ArrayBuffer.isView(a)&&"Uint8Array"===a.constructor.name&&"BYTES_PER_ELEMENT"in a&&1===a.BYTES_PER_ELEMENT;var a;const o=e?.length,s=void 0!==t;if(!i||s&&o!==t){const a=(n&&`"${n}" `)+"expected Uint8Array"+(s?` of length ${t}`:"")+", got "+(i?`length=${o}`:"type="+typeof e);if(!i)throw new TypeError(a);throw new RangeError(a)}return e}function Ea(e,t=!0){if(e.destroyed)throw new Error("Hash instance has been destroyed");if(t&&e.finished)throw new Error("Hash#digest() has already been called")}function ka(...e){for(let t=0;t<e.length;t++)e[t].fill(0)}function Aa(e){return new DataView(e.buffer,e.byteOffset,e.byteLength)}function _a(e,t){return e<<32-t|e>>>t}const Ta=(()=>"function"==typeof Uint8Array.from([]).toHex&&"function"==typeof Uint8Array.fromHex)(),Sa=Array.from({length:256},(e,t)=>t.toString(16).padStart(2,"0"));function ja(e){if(Ca(e),Ta)return e.toHex();let t="";for(let n=0;n<e.length;n++)t+=Sa[e[n]];return t}const La=48,Ra=57,Na=65,Ia=70,$a=97,Ba=102;function Da(e){return e>=La&&e<=Ra?e-La:e>=Na&&e<=Ia?e-(Na-10):e>=$a&&e<=Ba?e-($a-10):void 0}function Oa(e){if("string"!=typeof e)throw new TypeError("hex string expected, got "+typeof e);if(Ta)try{return Uint8Array.fromHex(e)}catch(e){if(e instanceof SyntaxError)throw new RangeError(e.message);throw e}const t=e.length,n=t/2;if(t%2)throw new RangeError("hex string expected, got unpadded hex of length "+t);const i=new Uint8Array(n);for(let t=0,a=0;t<n;t++,a+=2){const n=Da(e.charCodeAt(a)),o=Da(e.charCodeAt(a+1));if(void 0===n||void 0===o){const t=e[a]+e[a+1];throw new RangeError('hex string expected, got non-hex character "'+t+'" at index '+a)}i[t]=16*n+o}return i}function Ma(e,t={}){const n=(t,n)=>e(n).update(t).digest(),i=e(void 0);return n.outputLen=i.outputLen,n.blockLen=i.blockLen,n.canXOF=i.canXOF,n.create=t=>e(t),Object.assign(n,t),Object.freeze(n)}function Ua(e=32){wa(e,"bytesLength");const t="object"==typeof globalThis?globalThis.crypto:null;if("function"!=typeof t?.getRandomValues)throw new Error("crypto.getRandomValues must be defined");if(e>65536)throw new RangeError(`"bytesLength" expected <= 65536, got ${e}`);return t.getRandomValues(new Uint8Array(e))}const Fa=e=>({oid:Uint8Array.from([6,9,96,134,72,1,101,3,4,2,e])});function Pa(e,t,n){return e&t^~e&n}function za(e,t,n){return e&t^e&n^t&n}class qa{blockLen;outputLen;canXOF=!1;padOffset;isLE;buffer;view;finished=!1;length=0;pos=0;destroyed=!1;constructor(e,t,n,i){this.blockLen=e,this.outputLen=t,this.padOffset=n,this.isLE=i,this.buffer=new Uint8Array(e),this.view=Aa(this.buffer)}update(e){Ea(this),Ca(e);const{view:t,buffer:n,blockLen:i}=this,a=e.length;for(let o=0;o<a;){const s=Math.min(i-this.pos,a-o);if(s===i){const t=Aa(e);for(;i<=a-o;o+=i)this.process(t,o);continue}n.set(e.subarray(o,o+s),this.pos),this.pos+=s,o+=s,this.pos===i&&(this.process(t,0),this.pos=0)}return this.length+=e.length,this.roundClean(),this}digestInto(e){Ea(this),function(e,t){Ca(e,void 0,"digestInto() output");const n=t.outputLen;if(e.length<n)throw new RangeError('"digestInto() output" expected to be of length >='+n)}(e,this),this.finished=!0;const{buffer:t,view:n,blockLen:i,isLE:a}=this;let{pos:o}=this;t[o++]=128,ka(this.buffer.subarray(o)),this.padOffset>i-o&&(this.process(n,0),o=0);for(let e=o;e<i;e++)t[e]=0;n.setBigUint64(i-8,BigInt(8*this.length),a),this.process(n,0);const s=Aa(e),r=this.outputLen;if(r%4)throw new Error("_sha2: outputLen must be aligned to 32bit");const c=r/4,l=this.get();if(c>l.length)throw new Error("_sha2: outputLen bigger than state");for(let e=0;e<c;e++)s.setUint32(4*e,l[e],a)}digest(){const{buffer:e,outputLen:t}=this;this.digestInto(e);const n=e.slice(0,t);return this.destroy(),n}_cloneInto(e){e||=new this.constructor,e.set(...this.get());const{blockLen:t,buffer:n,length:i,finished:a,destroyed:o,pos:s}=this;return e.destroyed=o,e.finished=a,e.length=i,e.pos=s,i%t&&e.buffer.set(n),e}clone(){return this._cloneInto()}}const Ha=Uint32Array.from([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]);const Va=Uint32Array.from([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]),Ga=new Uint32Array(64);class Wa extends qa{constructor(e){super(64,e,8,!1)}get(){const{A:e,B:t,C:n,D:i,E:a,F:o,G:s,H:r}=this;return[e,t,n,i,a,o,s,r]}set(e,t,n,i,a,o,s,r){this.A=0|e,this.B=0|t,this.C=0|n,this.D=0|i,this.E=0|a,this.F=0|o,this.G=0|s,this.H=0|r}process(e,t){for(let n=0;n<16;n++,t+=4)Ga[n]=e.getUint32(t,!1);for(let e=16;e<64;e++){const t=Ga[e-15],n=Ga[e-2],i=_a(t,7)^_a(t,18)^t>>>3,a=_a(n,17)^_a(n,19)^n>>>10;Ga[e]=a+Ga[e-7]+i+Ga[e-16]|0}let{A:n,B:i,C:a,D:o,E:s,F:r,G:c,H:l}=this;for(let e=0;e<64;e++){const t=l+(_a(s,6)^_a(s,11)^_a(s,25))+Pa(s,r,c)+Va[e]+Ga[e]|0,p=(_a(n,2)^_a(n,13)^_a(n,22))+za(n,i,a)|0;l=c,c=r,r=s,s=o+t|0,o=a,a=i,i=n,n=t+p|0}n=n+this.A|0,i=i+this.B|0,a=a+this.C|0,o=o+this.D|0,s=s+this.E|0,r=r+this.F|0,c=c+this.G|0,l=l+this.H|0,this.set(n,i,a,o,s,r,c,l)}roundClean(){ka(Ga)}destroy(){this.destroyed=!0,this.set(0,0,0,0,0,0,0,0),ka(this.buffer)}}class Ja extends Wa{A=0|Ha[0];B=0|Ha[1];C=0|Ha[2];D=0|Ha[3];E=0|Ha[4];F=0|Ha[5];G=0|Ha[6];H=0|Ha[7];constructor(){super(32)}}const Qa=Ma(()=>new Ja,Fa(1));
14
14
  /*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */
15
15
  const Za=(e,t,n)=>Ca(e,t,n),Ya=wa,Ka=ja,Xa=(...e)=>function(...e){let t=0;for(let n=0;n<e.length;n++){const i=e[n];Ca(i),t+=i.length}const n=new Uint8Array(t);for(let t=0,i=0;t<e.length;t++){const a=e[t];n.set(a,i),i+=a.length}return n}(...e),eo=BigInt(0),to=BigInt(1);function no(e,t=""){if("boolean"!=typeof e){throw new TypeError((t&&`"${t}" `)+"expected boolean, got type="+typeof e)}return e}function io(e){if("bigint"==typeof e){if(!uo(e))throw new RangeError("positive bigint expected, got "+e)}else Ya(e);return e}function ao(e,t=""){if("number"!=typeof e){throw new TypeError((t&&`"${t}" `)+"expected number, got type="+typeof e)}if(!Number.isSafeInteger(e)){throw new RangeError((t&&`"${t}" `)+"expected safe integer, got "+e)}}function oo(e){const t=io(e).toString(16);return 1&t.length?"0"+t:t}function so(e){if("string"!=typeof e)throw new TypeError("hex string expected, got "+typeof e);return""===e?eo:BigInt("0x"+e)}function ro(e){return so(ja(e))}function co(e){return so(ja(function(e){return Uint8Array.from(Za(e))}(Ca(e)).reverse()))}function lo(e,t){if(wa(t),0===t)throw new RangeError("zero length");const n=(e=io(e)).toString(16);if(n.length>2*t)throw new RangeError("number too large");return Oa(n.padStart(2*t,"0"))}function po(e,t){return lo(e,t).reverse()}const uo=e=>"bigint"==typeof e&&eo<=e;function mo(e,t,n,i){if(!function(e,t,n){return uo(e)&&uo(t)&&uo(n)&&t<=e&&e<n}(t,n,i))throw new RangeError("expected valid "+e+": "+n+" <= n < "+i+", got "+t)}function fo(e){if(e<eo)throw new Error("expected non-negative bigint, got "+e);let t;for(t=0;e>eo;e>>=to,t+=1);return t}const ho=e=>(to<<BigInt(e))-to;function go(e,t={},n={}){if("[object Object]"!==Object.prototype.toString.call(e))throw new TypeError("expected valid options object");const i=(t,n)=>Object.entries(t).forEach(([t,i])=>function(t,n,i){if(!i&&"function"!==n&&!Object.hasOwn(e,t))throw new TypeError(`param "${t}" is invalid: expected own property`);const a=e[t];if(i&&void 0===a)return;const o=typeof a;if(o!==n||null===a)throw new TypeError(`param "${t}" is invalid: expected ${n}, got ${o}`)}(t,i,n));i(t,!1),i(n,!0)}const bo=BigInt(0),vo=BigInt(1),xo=BigInt(2),yo=BigInt(3),wo=BigInt(4),Co=BigInt(5),Eo=BigInt(7),ko=BigInt(8),Ao=BigInt(9),_o=BigInt(16);function To(e,t){if(t<=bo)throw new Error("mod: expected positive modulus, got "+t);const n=e%t;return n>=bo?n:t+n}function So(e,t,n){if(t<bo)throw new Error("pow2: expected non-negative exponent, got "+t);let i=e;for(;t-- >bo;)i*=i,i%=n;return i}function jo(e,t){if(e===bo)throw new Error("invert: expected non-zero number");if(t<=bo)throw new Error("invert: expected positive modulus, got "+t);let n=To(e,t),i=t,a=bo,o=vo,s=vo,r=bo;for(;n!==bo;){const e=i/n,t=i-n*e,c=a-s*e,l=o-r*e;i=n,n=t,a=s,o=r,s=c,r=l}if(i!==vo)throw new Error("invert: does not exist");return To(a,t)}function Lo(e,t,n){const i=e;if(!i.eql(i.sqr(t),n))throw new Error("Cannot find square root")}function Ro(e,t){const n=e,i=(n.ORDER+vo)/wo,a=n.pow(t,i);return Lo(n,a,t),a}function No(e,t){const n=e,i=(n.ORDER-Co)/ko,a=n.mul(t,xo),o=n.pow(a,i),s=n.mul(t,o),r=n.mul(n.mul(s,xo),o),c=n.mul(s,n.sub(r,n.ONE));return Lo(n,c,t),c}function Io(e){if(e<yo)throw new Error("sqrt is not defined for small field");let t=e-vo,n=0;for(;t%xo===bo;)t/=xo,n++;let i=xo;const a=Po(e);for(;1===Mo(a,i);)if(i++>1e3)throw new Error("Cannot find square root: probably non-prime P");if(1===n)return Ro;let o=a.pow(i,t);const s=(t+vo)/xo;return function(e,i){const a=e;if(a.is0(i))return i;if(1!==Mo(a,i))throw new Error("Cannot find square root");let r=n,c=a.mul(a.ONE,o),l=a.pow(i,t),p=a.pow(i,s);for(;!a.eql(l,a.ONE);){if(a.is0(l))return a.ZERO;let e=1,t=a.sqr(l);for(;!a.eql(t,a.ONE);)if(e++,t=a.sqr(t),e===r)throw new Error("Cannot find square root");const n=vo<<BigInt(r-e-1),i=a.pow(c,n);r=e,c=a.sqr(i),l=a.mul(l,c),p=a.mul(p,i)}return p}}function $o(e){return e%wo===yo?Ro:e%ko===Co?No:e%_o===Ao?function(e){const t=Po(e),n=Io(e),i=n(t,t.neg(t.ONE)),a=n(t,i),o=n(t,t.neg(i)),s=(e+Eo)/_o;return(e,t)=>{const n=e;let r=n.pow(t,s),c=n.mul(r,i);const l=n.mul(r,a),p=n.mul(r,o),u=n.eql(n.sqr(c),t),d=n.eql(n.sqr(l),t);r=n.cmov(r,c,u),c=n.cmov(p,l,d);const m=n.eql(n.sqr(c),t),f=n.cmov(r,c,m);return Lo(n,f,t),f}}(e):Io(e)}const Bo=["create","isValid","is0","neg","inv","sqrt","sqr","eql","add","sub","mul","pow","div","addN","subN","mulN","sqrN"];function Do(e,t,n){const i=e;if(n<bo)throw new Error("invalid exponent, negatives unsupported");if(n===bo)return i.ONE;if(n===vo)return t;let a=i.ONE,o=t;for(;n>bo;)n&vo&&(a=i.mul(a,o)),o=i.sqr(o),n>>=vo;return a}function Oo(e,t,n=!1){const i=e,a=new Array(t.length).fill(n?i.ZERO:void 0),o=t.reduce((e,t,n)=>i.is0(t)?e:(a[n]=e,i.mul(e,t)),i.ONE),s=i.inv(o);return t.reduceRight((e,t,n)=>i.is0(t)?e:(a[n]=i.mul(e,a[n]),i.mul(e,t)),s),a}function Mo(e,t){const n=e,i=(n.ORDER-vo)/xo,a=n.pow(t,i),o=n.eql(a,n.ONE),s=n.eql(a,n.ZERO),r=n.eql(a,n.neg(n.ONE));if(!o&&!s&&!r)throw new Error("invalid Legendre symbol result");return o?1:s?0:-1}const Uo=new WeakMap;class Fo{ORDER;BITS;BYTES;isLE;ZERO=bo;ONE=vo;_lengths;_mod;constructor(e,t={}){if(e<=vo)throw new Error("invalid field: expected ORDER > 1, got "+e);let n;this.isLE=!1,null!=t&&"object"==typeof t&&("number"==typeof t.BITS&&(n=t.BITS),"function"==typeof t.sqrt&&Object.defineProperty(this,"sqrt",{value:t.sqrt,enumerable:!0}),"boolean"==typeof t.isLE&&(this.isLE=t.isLE),t.allowedLengths&&(this._lengths=Object.freeze(t.allowedLengths.slice())),"boolean"==typeof t.modFromBytes&&(this._mod=t.modFromBytes));const{nBitLength:i,nByteLength:a}=function(e,t){if(void 0!==t&&Ya(t),e<=bo)throw new Error("invalid n length: expected positive n, got "+e);if(void 0!==t&&t<1)throw new Error("invalid n length: expected positive bit length, got "+t);const n=fo(e);if(void 0!==t&&t<n)throw new Error(`invalid n length: expected bit length (${n}) >= n.length (${t})`);const i=void 0!==t?t:n;return{nBitLength:i,nByteLength:Math.ceil(i/8)}}(e,n);if(a>2048)throw new Error("invalid field: expected ORDER of <= 2048 bytes");this.ORDER=e,this.BITS=i,this.BYTES=a,Object.freeze(this)}create(e){return To(e,this.ORDER)}isValid(e){if("bigint"!=typeof e)throw new TypeError("invalid field element: expected bigint, got "+typeof e);return bo<=e&&e<this.ORDER}is0(e){return e===bo}isValidNot0(e){return!this.is0(e)&&this.isValid(e)}isOdd(e){return(e&vo)===vo}neg(e){return To(-e,this.ORDER)}eql(e,t){return e===t}sqr(e){return To(e*e,this.ORDER)}add(e,t){return To(e+t,this.ORDER)}sub(e,t){return To(e-t,this.ORDER)}mul(e,t){return To(e*t,this.ORDER)}pow(e,t){return Do(this,e,t)}div(e,t){return To(e*jo(t,this.ORDER),this.ORDER)}sqrN(e){return e*e}addN(e,t){return e+t}subN(e,t){return e-t}mulN(e,t){return e*t}inv(e){return jo(e,this.ORDER)}sqrt(e){let t=Uo.get(this);return t||Uo.set(this,t=$o(this.ORDER)),t(this,e)}toBytes(e){return this.isLE?po(e,this.BYTES):lo(e,this.BYTES)}fromBytes(e,t=!1){Za(e);const{_lengths:n,BYTES:i,isLE:a,ORDER:o,_mod:s}=this;if(n){if(e.length<1||!n.includes(e.length)||e.length>i)throw new Error("Field.fromBytes: expected "+n+" bytes, got "+e.length);const t=new Uint8Array(i);t.set(e,a?0:t.length-e.length),e=t}if(e.length!==i)throw new Error("Field.fromBytes: expected "+i+" bytes, got "+e.length);let r=a?co(e):ro(e);if(s&&(r=To(r,o)),!t&&!this.isValid(r))throw new Error("invalid field element: outside of range 0..ORDER");return r}invertBatch(e){return Oo(this,e)}cmov(e,t,n){return no(n,"condition"),n?t:e}}function Po(e,t={}){return new Fo(e,t)}function zo(e){if("bigint"!=typeof e)throw new Error("field order must be bigint");if(e<=vo)throw new Error("field order must be greater than 1");const t=fo(e-vo);return Math.ceil(t/8)}function qo(e,t,n=!1){Za(e);const i=e.length,a=zo(t),o=Math.max(function(e){const t=zo(e);return t+Math.ceil(t/2)}(t),16);if(i<o||i>1024)throw new Error("expected "+o+"-1024 bytes of input, got "+i);const s=To(n?co(e):ro(e),t-vo)+vo;return n?po(s,a):lo(s,a)}Object.freeze(Fo.prototype);
16
16
  /*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */