solid-ui 3.1.0 → 3.1.1

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.
Files changed (242) hide show
  1. package/README.md +22 -4
  2. package/dist/components/button/index.d.ts +1 -0
  3. package/dist/components/button/index.esm.js +546 -0
  4. package/dist/components/button/index.esm.js.map +1 -0
  5. package/dist/components/button/index.esm.min.js +268 -0
  6. package/dist/components/button/index.esm.min.js.map +1 -0
  7. package/dist/components/button/index.js +428 -0
  8. package/dist/components/button/index.js.map +1 -0
  9. package/dist/components/button/index.min.js +257 -0
  10. package/dist/components/button/index.min.js.map +1 -0
  11. package/dist/components/combobox/index.d.ts +1 -0
  12. package/dist/components/combobox/index.esm.js +953 -0
  13. package/dist/components/combobox/index.esm.js.map +1 -0
  14. package/dist/components/combobox/index.esm.min.js +339 -0
  15. package/dist/components/combobox/index.esm.min.js.map +1 -0
  16. package/dist/components/combobox/index.js +782 -0
  17. package/dist/components/combobox/index.js.map +1 -0
  18. package/dist/components/combobox/index.min.js +328 -0
  19. package/dist/components/combobox/index.min.js.map +1 -0
  20. package/dist/components/footer/index.d.ts +1 -1
  21. package/dist/components/footer/index.esm.js +105 -63
  22. package/dist/components/footer/index.esm.js.map +1 -1
  23. package/dist/components/footer/index.esm.min.js +4 -4
  24. package/dist/components/footer/index.esm.min.js.map +1 -1
  25. package/dist/components/footer/index.js +103 -52
  26. package/dist/components/footer/index.js.map +1 -1
  27. package/dist/components/footer/index.min.js +8 -8
  28. package/dist/components/footer/index.min.js.map +1 -1
  29. package/dist/components/header/index.d.ts +1 -1
  30. package/dist/components/header/index.esm.js +1405 -1363
  31. package/dist/components/header/index.esm.js.map +1 -1
  32. package/dist/components/header/index.esm.min.js +857 -815
  33. package/dist/components/header/index.esm.min.js.map +1 -1
  34. package/dist/components/header/index.js +61 -19
  35. package/dist/components/header/index.js.map +1 -1
  36. package/dist/components/header/index.min.js +53 -11
  37. package/dist/components/header/index.min.js.map +1 -1
  38. package/dist/components/loginButton/index.d.ts +1 -1
  39. package/dist/components/loginButton/index.esm.js +50 -8
  40. package/dist/components/loginButton/index.esm.js.map +1 -1
  41. package/dist/components/loginButton/index.esm.min.js +60 -18
  42. package/dist/components/loginButton/index.esm.min.js.map +1 -1
  43. package/dist/components/loginButton/index.js +49 -7
  44. package/dist/components/loginButton/index.js.map +1 -1
  45. package/dist/components/loginButton/index.min.js +58 -16
  46. package/dist/components/loginButton/index.min.js.map +1 -1
  47. package/dist/components/photoCapture/index.d.ts +1 -0
  48. package/dist/components/photoCapture/index.esm.js +966 -0
  49. package/dist/components/photoCapture/index.esm.js.map +1 -0
  50. package/dist/components/photoCapture/index.esm.min.js +304 -0
  51. package/dist/components/photoCapture/index.esm.min.js.map +1 -0
  52. package/dist/components/photoCapture/index.js +848 -0
  53. package/dist/components/photoCapture/index.js.map +1 -0
  54. package/dist/components/photoCapture/index.min.js +293 -0
  55. package/dist/components/photoCapture/index.min.js.map +1 -0
  56. package/dist/components/select/index.d.ts +1 -0
  57. package/dist/components/select/index.esm.js +939 -0
  58. package/dist/components/select/index.esm.js.map +1 -0
  59. package/dist/components/select/index.esm.min.js +370 -0
  60. package/dist/components/select/index.esm.min.js.map +1 -0
  61. package/dist/components/select/index.js +771 -0
  62. package/dist/components/select/index.js.map +1 -0
  63. package/dist/components/select/index.min.js +359 -0
  64. package/dist/components/select/index.min.js.map +1 -0
  65. package/dist/components/signupButton/index.d.ts +1 -1
  66. package/dist/components/signupButton/index.esm.js +2 -2
  67. package/dist/components/signupButton/index.esm.js.map +1 -1
  68. package/dist/components/signupButton/index.esm.min.js +2 -2
  69. package/dist/components/signupButton/index.esm.min.js.map +1 -1
  70. package/dist/components/signupButton/index.js +2 -2
  71. package/dist/components/signupButton/index.js.map +1 -1
  72. package/dist/components/signupButton/index.min.js.map +1 -1
  73. package/dist/login/login.d.ts.map +1 -1
  74. package/dist/login/login.js +12 -2
  75. package/dist/login/login.js.map +1 -1
  76. package/dist/matrix/matrix.js.map +1 -1
  77. package/dist/solid-ui.esm.js +103 -61
  78. package/dist/solid-ui.esm.js.map +1 -1
  79. package/dist/solid-ui.esm.min.js +6 -6
  80. package/dist/solid-ui.esm.min.js.map +1 -1
  81. package/dist/solid-ui.js +102 -51
  82. package/dist/solid-ui.js.map +1 -1
  83. package/dist/solid-ui.min.js +9 -9
  84. package/dist/solid-ui.min.js.map +1 -1
  85. package/dist/tabs.js +2 -2
  86. package/dist/tabs.js.map +1 -1
  87. package/dist/v2/components/actions/button/Button.d.ts +97 -0
  88. package/dist/v2/components/actions/button/Button.d.ts.map +1 -0
  89. package/dist/v2/components/actions/button/Button.js +325 -0
  90. package/dist/v2/components/actions/button/Button.js.map +1 -0
  91. package/dist/v2/components/actions/button/Button.test.d.ts +2 -0
  92. package/dist/v2/components/actions/button/Button.test.d.ts.map +1 -0
  93. package/dist/v2/components/actions/button/Button.test.js +117 -0
  94. package/dist/v2/components/actions/button/Button.test.js.map +1 -0
  95. package/dist/v2/components/actions/button/index.d.ts +8 -0
  96. package/dist/v2/components/actions/button/index.d.ts.map +1 -0
  97. package/dist/v2/components/actions/button/index.js +7 -0
  98. package/dist/v2/components/actions/button/index.js.map +1 -0
  99. package/dist/v2/components/auth/loginButton/LoginButton.d.ts.map +1 -0
  100. package/dist/v2/components/{loginButton → auth/loginButton}/LoginButton.js +46 -4
  101. package/dist/v2/components/auth/loginButton/LoginButton.js.map +1 -0
  102. package/dist/v2/components/auth/loginButton/LoginButton.test.d.ts.map +1 -0
  103. package/dist/v2/components/auth/loginButton/LoginButton.test.js.map +1 -0
  104. package/dist/v2/components/auth/loginButton/downArrow.d.ts.map +1 -0
  105. package/dist/v2/components/auth/loginButton/downArrow.js.map +1 -0
  106. package/dist/v2/components/auth/loginButton/index.d.ts.map +1 -0
  107. package/dist/v2/components/auth/loginButton/index.js.map +1 -0
  108. package/dist/v2/components/auth/signupButton/SignupButton.d.ts.map +1 -0
  109. package/dist/v2/components/auth/signupButton/SignupButton.js.map +1 -0
  110. package/dist/v2/components/auth/signupButton/SignupButton.test.d.ts.map +1 -0
  111. package/dist/v2/components/auth/signupButton/SignupButton.test.js.map +1 -0
  112. package/dist/v2/components/auth/signupButton/index.d.ts.map +1 -0
  113. package/dist/v2/components/auth/signupButton/index.js.map +1 -0
  114. package/dist/v2/components/forms/combobox/Combobox.d.ts +82 -0
  115. package/dist/v2/components/forms/combobox/Combobox.d.ts.map +1 -0
  116. package/dist/v2/components/forms/combobox/Combobox.js +506 -0
  117. package/dist/v2/components/forms/combobox/Combobox.js.map +1 -0
  118. package/dist/v2/components/forms/combobox/Combobox.test.d.ts +2 -0
  119. package/dist/v2/components/forms/combobox/Combobox.test.d.ts.map +1 -0
  120. package/dist/v2/components/forms/combobox/Combobox.test.js +201 -0
  121. package/dist/v2/components/forms/combobox/Combobox.test.js.map +1 -0
  122. package/dist/v2/components/forms/combobox/comboboxTypes.d.ts +6 -0
  123. package/dist/v2/components/forms/combobox/comboboxTypes.d.ts.map +1 -0
  124. package/dist/v2/components/forms/combobox/comboboxTypes.js +2 -0
  125. package/dist/v2/components/forms/combobox/comboboxTypes.js.map +1 -0
  126. package/dist/v2/components/forms/combobox/index.d.ts +3 -0
  127. package/dist/v2/components/forms/combobox/index.d.ts.map +1 -0
  128. package/dist/v2/components/forms/combobox/index.js +7 -0
  129. package/dist/v2/components/forms/combobox/index.js.map +1 -0
  130. package/dist/v2/components/forms/select/Select.d.ts +68 -0
  131. package/dist/v2/components/forms/select/Select.d.ts.map +1 -0
  132. package/dist/v2/components/forms/select/Select.js +499 -0
  133. package/dist/v2/components/forms/select/Select.js.map +1 -0
  134. package/dist/v2/components/forms/select/Select.test.d.ts +2 -0
  135. package/dist/v2/components/forms/select/Select.test.d.ts.map +1 -0
  136. package/dist/v2/components/forms/select/Select.test.js +168 -0
  137. package/dist/v2/components/forms/select/Select.test.js.map +1 -0
  138. package/dist/v2/components/forms/select/index.d.ts +3 -0
  139. package/dist/v2/components/forms/select/index.d.ts.map +1 -0
  140. package/dist/v2/components/forms/select/index.js +7 -0
  141. package/dist/v2/components/forms/select/index.js.map +1 -0
  142. package/dist/v2/components/forms/shared/downArrow.d.ts +2 -0
  143. package/dist/v2/components/forms/shared/downArrow.d.ts.map +1 -0
  144. package/dist/v2/components/forms/shared/downArrow.js +10 -0
  145. package/dist/v2/components/forms/shared/downArrow.js.map +1 -0
  146. package/dist/v2/components/forms/shared/keyboard.d.ts +7 -0
  147. package/dist/v2/components/forms/shared/keyboard.d.ts.map +1 -0
  148. package/dist/v2/components/forms/shared/keyboard.js +56 -0
  149. package/dist/v2/components/forms/shared/keyboard.js.map +1 -0
  150. package/dist/v2/components/forms/shared/listboxStyles.d.ts +2 -0
  151. package/dist/v2/components/forms/shared/listboxStyles.d.ts.map +1 -0
  152. package/dist/v2/components/forms/shared/listboxStyles.js +96 -0
  153. package/dist/v2/components/forms/shared/listboxStyles.js.map +1 -0
  154. package/dist/v2/components/forms/shared/listboxTemplate.d.ts +11 -0
  155. package/dist/v2/components/forms/shared/listboxTemplate.d.ts.map +1 -0
  156. package/dist/v2/components/forms/shared/listboxTemplate.js +37 -0
  157. package/dist/v2/components/forms/shared/listboxTemplate.js.map +1 -0
  158. package/dist/v2/components/forms/shared/optionTypes.d.ts +6 -0
  159. package/dist/v2/components/forms/shared/optionTypes.d.ts.map +1 -0
  160. package/dist/v2/components/forms/shared/optionTypes.js +2 -0
  161. package/dist/v2/components/forms/shared/optionTypes.js.map +1 -0
  162. package/dist/v2/components/layout/footer/Footer.d.ts.map +1 -0
  163. package/dist/v2/components/{footer → layout/footer}/Footer.js +1 -1
  164. package/dist/v2/components/layout/footer/Footer.js.map +1 -0
  165. package/dist/v2/components/layout/footer/Footer.test.d.ts.map +1 -0
  166. package/dist/v2/components/layout/footer/Footer.test.js.map +1 -0
  167. package/dist/v2/components/layout/footer/index.d.ts.map +1 -0
  168. package/dist/v2/components/layout/footer/index.js.map +1 -0
  169. package/dist/v2/components/{header → layout/header}/Header.d.ts +2 -2
  170. package/dist/v2/components/layout/header/Header.d.ts.map +1 -0
  171. package/dist/v2/components/{header → layout/header}/Header.js +5 -5
  172. package/dist/v2/components/layout/header/Header.js.map +1 -0
  173. package/dist/v2/components/layout/header/header.test.d.ts.map +1 -0
  174. package/dist/v2/components/layout/header/header.test.js.map +1 -0
  175. package/dist/v2/components/layout/header/index.d.ts.map +1 -0
  176. package/dist/v2/components/layout/header/index.js.map +1 -0
  177. package/dist/v2/components/media/photoCapture/PhotoCapture.d.ts +200 -0
  178. package/dist/v2/components/media/photoCapture/PhotoCapture.d.ts.map +1 -0
  179. package/dist/v2/components/media/photoCapture/PhotoCapture.js +723 -0
  180. package/dist/v2/components/media/photoCapture/PhotoCapture.js.map +1 -0
  181. package/dist/v2/components/media/photoCapture/PhotoCapture.test.d.ts +2 -0
  182. package/dist/v2/components/media/photoCapture/PhotoCapture.test.d.ts.map +1 -0
  183. package/dist/v2/components/media/photoCapture/PhotoCapture.test.js +157 -0
  184. package/dist/v2/components/media/photoCapture/PhotoCapture.test.js.map +1 -0
  185. package/dist/v2/components/media/photoCapture/index.d.ts +3 -0
  186. package/dist/v2/components/media/photoCapture/index.d.ts.map +1 -0
  187. package/dist/v2/components/media/photoCapture/index.js +7 -0
  188. package/dist/v2/components/media/photoCapture/index.js.map +1 -0
  189. package/dist/versionInfo.js +14 -14
  190. package/dist/widgets/buttons.d.ts +1 -0
  191. package/dist/widgets/buttons.d.ts.map +1 -1
  192. package/dist/widgets/buttons.js +15 -2
  193. package/dist/widgets/buttons.js.map +1 -1
  194. package/package.json +223 -157
  195. package/dist/v2/components/footer/Footer.d.ts.map +0 -1
  196. package/dist/v2/components/footer/Footer.js.map +0 -1
  197. package/dist/v2/components/footer/Footer.test.d.ts.map +0 -1
  198. package/dist/v2/components/footer/Footer.test.js.map +0 -1
  199. package/dist/v2/components/footer/index.d.ts.map +0 -1
  200. package/dist/v2/components/footer/index.js.map +0 -1
  201. package/dist/v2/components/header/Header.d.ts.map +0 -1
  202. package/dist/v2/components/header/Header.js.map +0 -1
  203. package/dist/v2/components/header/header.test.d.ts.map +0 -1
  204. package/dist/v2/components/header/header.test.js.map +0 -1
  205. package/dist/v2/components/header/index.d.ts.map +0 -1
  206. package/dist/v2/components/header/index.js.map +0 -1
  207. package/dist/v2/components/loginButton/LoginButton.d.ts.map +0 -1
  208. package/dist/v2/components/loginButton/LoginButton.js.map +0 -1
  209. package/dist/v2/components/loginButton/LoginButton.test.d.ts.map +0 -1
  210. package/dist/v2/components/loginButton/LoginButton.test.js.map +0 -1
  211. package/dist/v2/components/loginButton/downArrow.d.ts.map +0 -1
  212. package/dist/v2/components/loginButton/downArrow.js.map +0 -1
  213. package/dist/v2/components/loginButton/index.d.ts.map +0 -1
  214. package/dist/v2/components/loginButton/index.js.map +0 -1
  215. package/dist/v2/components/signupButton/SignupButton.d.ts.map +0 -1
  216. package/dist/v2/components/signupButton/SignupButton.js.map +0 -1
  217. package/dist/v2/components/signupButton/SignupButton.test.d.ts.map +0 -1
  218. package/dist/v2/components/signupButton/SignupButton.test.js.map +0 -1
  219. package/dist/v2/components/signupButton/index.d.ts.map +0 -1
  220. package/dist/v2/components/signupButton/index.js.map +0 -1
  221. /package/dist/v2/components/{loginButton → auth/loginButton}/LoginButton.d.ts +0 -0
  222. /package/dist/v2/components/{loginButton → auth/loginButton}/LoginButton.test.d.ts +0 -0
  223. /package/dist/v2/components/{loginButton → auth/loginButton}/LoginButton.test.js +0 -0
  224. /package/dist/v2/components/{loginButton → auth/loginButton}/downArrow.d.ts +0 -0
  225. /package/dist/v2/components/{loginButton → auth/loginButton}/downArrow.js +0 -0
  226. /package/dist/v2/components/{loginButton → auth/loginButton}/index.d.ts +0 -0
  227. /package/dist/v2/components/{loginButton → auth/loginButton}/index.js +0 -0
  228. /package/dist/v2/components/{signupButton → auth/signupButton}/SignupButton.d.ts +0 -0
  229. /package/dist/v2/components/{signupButton → auth/signupButton}/SignupButton.js +0 -0
  230. /package/dist/v2/components/{signupButton → auth/signupButton}/SignupButton.test.d.ts +0 -0
  231. /package/dist/v2/components/{signupButton → auth/signupButton}/SignupButton.test.js +0 -0
  232. /package/dist/v2/components/{signupButton → auth/signupButton}/index.d.ts +0 -0
  233. /package/dist/v2/components/{signupButton → auth/signupButton}/index.js +0 -0
  234. /package/dist/v2/components/{footer → layout/footer}/Footer.d.ts +0 -0
  235. /package/dist/v2/components/{footer → layout/footer}/Footer.test.d.ts +0 -0
  236. /package/dist/v2/components/{footer → layout/footer}/Footer.test.js +0 -0
  237. /package/dist/v2/components/{footer → layout/footer}/index.d.ts +0 -0
  238. /package/dist/v2/components/{footer → layout/footer}/index.js +0 -0
  239. /package/dist/v2/components/{header → layout/header}/header.test.d.ts +0 -0
  240. /package/dist/v2/components/{header → layout/header}/header.test.js +0 -0
  241. /package/dist/v2/components/{header → layout/header}/index.d.ts +0 -0
  242. /package/dist/v2/components/{header → layout/header}/index.js +0 -0
@@ -1,24 +1,24 @@
1
- (()=>{var e={423(e,t,n){"use strict";function i(...e){console.log(...e)}function a(...e){console.warn(...e)}function o(...e){console.error(...e)}function s(...e){console.trace(...e)}n.d(t,{R8:()=>a,Rm:()=>i,uP:()=>s,z3:()=>o})},378(e,t,n){"use strict";n.d(t,{LN:()=>s,Pt:()=>o,i1:()=>r});var i=n(423);const a="https://solidos.github.io/solid-ui/src",o=(e=n.hmd(e)).scriptURI?{iconBase:e.scriptURI.slice(0,e.scriptURI.lastIndexOf("/"))+"/icons/",originalIconBase:e.scriptURI.slice(0,e.scriptURI.lastIndexOf("/"))+"/originalIcons/"}:"undefined"!=typeof $SolidTestEnvironment&&$SolidTestEnvironment.iconBase?{iconBase:$SolidTestEnvironment.iconBase,originalIconBase:$SolidTestEnvironment.originalIconBase}:{iconBase:a+"/icons/",originalIconBase:a+"/originalIcons/"};(0,i.Rm)(" icons.iconBase is set to : "+o.iconBase);const s=o.iconBase,r=o.originalIconBase},325(e,t,n){"use strict";n.d(t,{icons:()=>st.Pt,ns:()=>b});var i={};n.r(i),n.d(i,{LogLevel:()=>x,alert:()=>R,clear:()=>N,debug:()=>T,dumpHTML:()=>$,error:()=>j,escapeForXML:()=>O,info:()=>S,logAscending:()=>B,logDescending:()=>D,msg:()=>A,setInternals:()=>M,setLevel:()=>I,success:()=>L,warn:()=>_});var a={};n.r(a),n.d(a,{AJARImage:()=>ce,RDFComparePredicateObject:()=>ge,RDFComparePredicateSubject:()=>be,addLoadEvent:()=>oe,ancestor:()=>te,beep:()=>W,clearVariableNames:()=>G,emptyNode:()=>X,escapeForXML:()=>de,findPos:()=>se,genUuid:()=>Q,getAbout:()=>ne,getEyeFocus:()=>re,getTarget:()=>ee,getTerm:()=>ie,hashColor:()=>J,include:()=>ae,label:()=>F,labelForXML:()=>me,labelWithOntology:()=>ue,newVariableName:()=>V,ontologyLabel:()=>pe,predParentOf:()=>ve,predicateLabel:()=>he,predicateLabelForXML:()=>fe,shortName:()=>le,stackString:()=>K,syncTableToArray:()=>Z,syncTableToArrayReOrdered:()=>Y});var o={};n.r(o),n.d(o,{addDefaults:()=>kn,defaultPreferredLanguages:()=>En,filterByLanguage:()=>Tn,getPreferredLanguages:()=>_n,getPreferredLanguagesFor:()=>An,languageCodeURIBase:()=>Cn});var s={};n.r(s),n.d(s,{AUTOCOMPLETE_LIMIT:()=>Sn,ESCOResultToBindings:()=>zn,bindingToTerm:()=>Fn,dbPediaTypeMap:()=>Bn,dbpediaParameters:()=>$n,escoParameters:()=>In,fetcherOptionsJsonPublicData:()=>Nn,getDbpediaDetails:()=>Kn,getWikidataDetails:()=>Qn,getWikidataDetailsOld:()=>Zn,getWikidataLocation:()=>Yn,instituteDetailsWikidataQuery:()=>Rn,loadFromBindings:()=>Pn,loadPublicDataThing:()=>Jn,queryESCODataByName:()=>qn,queryPublicDataByName:()=>Vn,queryPublicDataConstruct:()=>Wn,queryPublicDataSelect:()=>Gn,variableNameToPredicateMap:()=>Un,wikidataClasses:()=>Ln,wikidataIncomingClassMap:()=>Mn,wikidataOutgoingClassMap:()=>Dn,wikidataParameters:()=>On});var r={};n.r(r),n.d(r,{Group:()=>pt,GroupBuilder:()=>ut,GroupPicker:()=>lt,PeoplePicker:()=>ct,Person:()=>dt,addStyleSheet:()=>sn,allClassURIs:()=>Kt,appendForm:()=>di,askName:()=>zt,attachmentList:()=>Qt,basicField:()=>wn,buildCheckboxForm:()=>Ai,button:()=>Ut,cancelButton:()=>Ft,clearElement:()=>Et,complain:()=>Ct,continueButton:()=>Pt,createLinkDiv:()=>Gt,createLinkForURI:()=>vt,createNameDiv:()=>Vt,defaultAnnotationStore:()=>Yt,deleteButtonWithCheck:()=>Mt,editFormButton:()=>ui,errorMessageBlock:()=>ot,extractLogURI:()=>kt,faviconOrDefault:()=>Ot,field:()=>mn,fieldFunction:()=>hn,fieldLabel:()=>xn,fieldParams:()=>un,fieldStore:()=>yn,fileUploadButtonDiv:()=>pn,findClosest:()=>fi,findImage:()=>$t,findImageFromURI:()=>It,formatDateTime:()=>_t,formsFor:()=>hi,iconForClass:()=>Rt,imagesOf:()=>Lt,index:()=>on,isAudio:()=>rn,isImage:()=>ln,isVideo:()=>cn,linkButton:()=>en,linkIcon:()=>bt,makeDescription:()=>yi,makeDraggable:()=>it,makeDropTarget:()=>nt,makeSelectForCategory:()=>Ei,makeSelectForChoice:()=>Ti,makeSelectForClassifierOptions:()=>wi,makeSelectForNestedCategory:()=>ki,makeSelectForOptions:()=>Ci,mostSpecificClassURI:()=>fn,newButton:()=>vi,newThing:()=>_i,openHrefInOutlineMode:()=>Zt,personTR:()=>qt,promptForNew:()=>xi,propertiesForClass:()=>mi,propertyTriage:()=>Xt,publicData:()=>s,refreshTree:()=>Jt,removeButton:()=>tn,renderAsDiv:()=>Wt,renderAsRow:()=>Ht,renderAutoComplete:()=>ei,renderAutocompleteControl:()=>ai,renderNameValuePair:()=>vn,selectorPanel:()=>nn,selectorPanelRefresh:()=>an,setImage:()=>Dt,setName:()=>jt,setVisible:()=>Xn,shortDate:()=>At,shortTime:()=>St,sortByLabel:()=>bi,sortBySequence:()=>gi,timestamp:()=>Tt,uploadFiles:()=>at});var c={};n.r(c),n.d(c,{ensureLoadedPreferences:()=>Ui,ensureLoadedProfile:()=>Fi,ensureLoggedIn:()=>Mi,filterAvailablePanes:()=>Yi,findAppInstances:()=>Pi,getUserRoles:()=>Zi,loginStatusBox:()=>Wi,newAppInstance:()=>Qi,registrationControl:()=>qi,registrationList:()=>Vi,renderScopeHeadingRow:()=>Hi,renderSignInPopup:()=>Gi,scopeLabel:()=>zi,selectWorkspace:()=>Ji});var l={};n.r(l),n.d(l,{manageParticipation:()=>er,participationObject:()=>Ks,recordParticipation:()=>Xs,renderParticipants:()=>Ys});var p={};n.r(p),n.d(p,{getChunks:()=>or,lightColorHash:()=>ir,manageParticipation:()=>er,notepad:()=>ar,notepadToHTML:()=>rr,participationObject:()=>Ks,recordParticipation:()=>Xs,renderParticipants:()=>Ys,xmlEncode:()=>sr});var u={};n.r(u),n.d(u,{get:()=>Sr,getPreferencesForClass:()=>$r,recordPersonalDefaults:()=>Rr,recordSharedPreferences:()=>Lr,renderPreferencesForm:()=>Nr,set:()=>jr,value:()=>Tr});var d={};n.r(d),n.d(d,{TabWidgetElement:()=>Dr,tabWidget:()=>Or});var m={};n.r(m);var f=n(386),h=n.n(f),g=n(511);const b=h()(g);var v=n(892);let x=function(e){return e[e.Error=1]="Error",e[e.Warning=2]="Warning",e[e.Message=4]="Message",e[e.Success=8]="Success",e[e.Info=16]="Info",e[e.Debug=32]="Debug",e[e.All=63]="All",e}({}),y=7,w=!1,C=document,E=window;function k(e,t=4,n="mesg"){if(y&t)if(void 0!==C){const t=C.getElementById("status");if(!t)return;const i=C.createElement("span");i.setAttribute("class",n);const a=new Date;i.innerHTML=`${a.getHours()}:${a.getMinutes()}:${a.getSeconds()} [${n}] ${O(e)}<br/>`,w?t.insertBefore(i,t.firstChild):t.appendChild(i)}else"undefined"!=typeof console&&console.log(e)}function A(e){k(e)}function _(e){k(e,2,"warn")}function T(e){k(e,32,"dbug")}function S(e){k(e,16,"info")}function j(e){k(e,1,"eror")}function L(e){k(e,8,"good")}function R(e){E&&void 0!==E.alert?E.alert(e):_(e)}function N(){const e=C?.getElementById("status");e&&(e.innerHTML="")}function I(e){y=63,T("Log level is now "+e),y=e}function $(){if(!C)return;const e=y;y=63,T(C?.body?.innerHTML||""),y=e}function B(){w=!0}function D(){w=!1}function O(e){return e.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}function M(e,t){E=e,C=t}const U={log:i,ns:b,rdf:g};function F(e,t=!1){function n(e){return t?e.slice(0,1).toUpperCase()+e.slice(1):e}function i(e){let t="";"/"===e.slice(-1)&&(e=e.slice(0,-1));for(let n=0;n<e.length;n++)"_"!==e[n]&&"-"!==e[n]?(t+=e[n],n+1<e.length&&e[n].toUpperCase()!==e[n]&&e[n+1].toLowerCase()!==e[n+1]&&(t+=" ")):t+=" ";return"has "===t.slice(0,4)&&(t=t.slice(4)),n(t)}const a=function(e){return v.store.any(e,U.ns.ui("label"))||v.store.any(e,U.ns.link("message"))||v.store.any(e,U.ns.vcard("fn"))||v.store.any(e,U.ns.foaf("name"))||v.store.any(e,U.ns.dct("title"))||v.store.any(e,U.ns.dc("title"))||v.store.any(e,U.ns.rss("title"))||v.store.any(e,U.ns.contact("fullName"))||v.store.any(e,v.store.sym("http://www.w3.org/2001/04/roadmap/org#name"))||v.store.any(e,U.ns.cal("summary"))||v.store.any(e,U.ns.foaf("nick"))||v.store.any(e,U.ns.as("name"))||v.store.any(e,U.ns.schema("name"))||v.store.any(e,U.ns.rdfs("label"))||v.store.any(e,v.store.sym("http://www.w3.org/2004/02/skos/core#prefLabel"))}(e);if(a)return n(a.value);if("BlankNode"===e.termType)return"...";if("Collection"===e.termType)return"("+e.elements.length+")";let o=e.uri;if(void 0===o)return e.toString();try{o=o.split("/").map(decodeURIComponent).join("/")}catch(e){for(let e=o.length-3;e>0;e--){const t="0123456789abcefABCDEF";for(;"%"===o[e]&&t.indexOf(o[e+1])>=0&&t.indexOf(o[e+2])>=0;)o=o.slice(0,e)+String.fromCharCode(parseInt(o.slice(e+1,e+3),16))+o.slice(e+3)}}o=P(o,"/profile/card#me"),o=P(o,"#this"),o=P(o,"#me");const s=o.indexOf("#");if(s>=0)return i(o.slice(s+1));const r=o.lastIndexOf("/",o.length-2);return r>=0&&r<e.uri.length?i(o.slice(r+1)):n(decodeURIComponent(e.uri))}function P(e,t){const n=-1*t.length;return e.slice(n)===t?e.slice(0,n):e}const z={log:i,ns:b,rdf:g};let q,H=0;function V(){return"v"+H++}function G(){H=0}function W(){if(!q)return;const e=new q;return function(t,n,i,a){t=+(t||.3),i=i||"sine","function"!=typeof a&&(a=function(){});const o=e.createOscillator();o.type=i,o.frequency.value=n||256,o.connect(e.destination),o.start(0),o.stop(t)}}function J(e){e=e.uri||e;return"#"+(16777215&(t=e,t.split("").reduce(function(e,t){return(e=(e<<5)-e+t.charCodeAt(0))&e},0))|12632256).toString(16);var t}function Q(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(e){const t=16*Math.random()|0;return("x"===e?t:3&t|8).toString(16)})}function Z(e,t,n,i){let a,o,s;for(s=0;s<e.children.length;s++)o=e.children[s],o.trashMe=!0;for(let r=0;r<t.length;r++){const c=t[r];for(a=!1,s=0;s<e.children.length;s++)if(o=e.children[s],o.subject&&o.subject.sameTerm(c)){if(i){const e=i(o,c);e&&e!==o&&(o.parentNode.replaceChild(e,o),e.subject=c,o=e)}o.trashMe=!1,a=!0;break}if(!a){const t=n(c);if(r>=e.children.length)e.appendChild(t);else{const n=e.children[r];e.insertBefore(t,n)}t.subject=c}}for(s=0;s<e.children.length;s++)o=e.children[s],o.trashMe&&e.removeChild(o)}function Y(e,t,n){const i={};for(let t=0;t<e.children.length;t++){const n=e.children[t];i[n.subject.toNT()]=n}for(let a=0;a<t.length;a++){const o=t[a];if(a>=e.children.length){const t=n(o);t.subject=o,e.appendChild(t)}else{const t=e.children[a];if(t.subject.sameTerm(o));else{const a=i[o.toNT()];if(a)e.removeChild(a),e.insertBefore(a,t);else{const e=n(o);t.before(e),e.subject=o}}}}for(;e.children.length>t.length;)e.removeChild(e.children[e.children.length-1])}function K(e){let t,n=e+"\n";if(!e.stack)return n+"No stack available.\n";const i=e.stack.toString().split("\n"),a=[];for(t=0;t<i.length;t++){let e=i[t];if(e.indexOf("ecmaunit.js")>-1)break;"("===e.charAt(0)&&(e="function"+e);const n=e.split("@");a.push(n)}for(t=0;t<a.length;t++)n+=" "+a[t][1]+"\n "+a[t][0];return n}function X(e){const t=e.childNodes;for(let n=t.length-1;n>=0;n--)e.removeChild(t[n]);return e}function ee(e){let t;return(e=e||window.event).target?t=e.target:e.srcElement&&(t=e.srcElement),3===t.nodeType&&(t=t.parentNode),t}function te(e,t){let n;for(n=e;n;n=n.parentNode)try{if(n.tagName===t)return n}catch(e){return}}function ne(e,t){let n,i;for(n=t;n&&1===n.nodeType;n=n.parentNode)if(i=n.getAttribute("about"),i)return e.fromNT(i);z.log.debug("getAbout: No about found")}function ie(e){const t=e.parentNode,n=t?t.AJAR_statement:void 0;switch(n?e.className:""){case"pred":case"pred selected":return n.predicate;case"obj":case"obj selected":return t.AJAR_inverse?n.subject:n.object;case"":case"selected":return ne(v.store,e);case"undetermined selected":return e.nextSibling?n.predicate:t.AJAR_inverse?n.subject:n.object}}function ae(e,t){const n=e.createElement("script");return n.setAttribute("type","text/javascript"),n.setAttribute("src",t),n}function oe(e){const t=window.onload;"function"!=typeof window.onload?window.onload=e:window.onload=function(){t(),e()}}function se(e){const t=e.ownerDocument.documentElement.getBoundingClientRect(),n=e.getBoundingClientRect();return[n.left-t.left,n.top-t.top]}function re(e,t,n,i){i||(i=window);const a=se(e)[1],o=window.SolidAppContext||{},s=a-(o&&o.scroll||52)-i.scrollY;if(t)return n?void i.scrollBy(0,a+e.clientHeight-(i.scrollY+i.innerHeight)):void i.scrollBy(0,s);const r=i.setInterval(function(){i.scrollBy(0,s/10),c++,10===c&&i.clearInterval(r)},50);let c=0}function ce(e,t,n,i){i||(i=document);const a=i.createElement("img");return a.setAttribute("src",e),a.addEventListener("copy",function(e){e.clipboardData.setData("text/plain",""),e.clipboardData.setData("text/html",""),e.preventDefault()}),void 0!==n&&a.setAttribute("title",n),a}function le(e){let t=e;"#/".indexOf(t[t.length-1])>=0&&(t=t.slice(0,-1));const n=[];for(const e in this.prefixes)n[this.prefixes[e]]=e;let i;const a=function(e){return"ns"!==e&&(i=e,!0)};let o;const s=t.lastIndexOf("#");for(s>=0&&(t=t.slice(s-1));;){const e=t.lastIndexOf("/");for(e>=0&&(t=t.slice(e+1)),o=0;o<t.length&&this.prefixchars.indexOf(t[o]);)o++;if(t=t.slice(0,o),t.length<6&&a(t))return i;if(a(t.slice(0,3)))return i;if(a(t.slice(0,2)))return i;if(a(t.slice(0,4)))return i;if(a(t.slice(0,1)))return i;if(a(t.slice(0,5)))return i;for(o=0;;o++)if(a(t.slice(0,3)+o))return i}}function pe(e){if(void 0===e.uri)return"??";let t=e.uri;const n=[];let i,a=t.lastIndexOf("#");if(a>=0)t=t.slice(0,a+1);else{if(a=t.lastIndexOf("/"),!(a>=0))return e.uri+"?!";t=t.slice(0,a+1)}for(const e in z.ns)n[z.ns[e]]=e;try{return n[t]}catch(e){}for(t=t.slice(0,-1);t;){if(a=t.lastIndexOf("/"),!(a>=0))return e.uri+"!?";if(i=t.slice(a+1),t=t.slice(0,a),"ns"!==i&&"0123456789".indexOf(i[0])<0)return i}}function ue(e,t){const n=v.store.findTypeURIs(e);return n[z.ns.rdf("Predicate").uri]||n[z.ns.rdfs("Class").uri]?F(e,t)+" ("+pe(e)+")":F(e,t)}function de(e){return e.replace(/&/g,"&amp;").replace(/</g,"&lt;")}function me(e){return de(F(e))}function fe(e,t){return de(he(e,t))}function he(e,t){const n=F(e);if(t){const t=v.store.any(e,z.ns.owl("inverseOf"))||v.store.any(void 0,z.ns.owl("inverseOf"),e);return t?F(t):"type"===n?"...":"is "+n+" of"}return n}function ge(e,t){const n=e.predicate.compareTerm(t.predicate);return 0!==n?n:e.object.compareTerm(t.object)}function be(e,t){const n=e.predicate.compareTerm(t.predicate);return 0!==n?n:e.subject.compareTerm(t.subject)}function ve(e){let t=e;for(;;){if(t.getAttribute("predTR"))return t;if(!t.previousSibling||"TR"!==t.previousSibling.nodeName)return z.log.error("Could not find predParent"),e;t=t.previousSibling}}"undefined"!=typeof AudioContext?q=AudioContext:"undefined"!=typeof window&&(q=window.AudioContext||window.webkitAudioContext);var xe=n(423);const ye=v.solidLogicSingleton.store;function we(e,t,n,i){const a=b.acl,o="/"===e.uri.slice(-1),s=ye.each(void 0,a("default"),n,i).concat(ye.each(void 0,a("defaultForNew"),n,i)).reduce((t,n)=>t.concat(ye.statementsMatching(n,b.rdf("type"),a("Authorization"),i)).concat(ye.statementsMatching(n,a("agent"),void 0,i)).concat(ye.statementsMatching(n,a("agentClass"),void 0,i)).concat(ye.statementsMatching(n,a("agentGroup"),void 0,i)).concat(ye.statementsMatching(n,a("origin"),void 0,i)).concat(ye.statementsMatching(n,a("originClass"),void 0,i)).concat(ye.statementsMatching(n,a("mode"),void 0,i)).concat((0,g.st)(n,a("accessTo"),e,i)).concat(o?(0,g.st)(n,a("default"),e,i):[]),[]),r=(0,g.graph)();return s.forEach(e=>r.add(c(e.subject),c(e.predicate),c(e.object),(0,g.sym)(t.uri))),r;function c(e){const n=i.uri.length;return(0,g.sym)(e.uri.slice(0,n)===i.uri?t.uri+e.uri.slice(n):e.uri)}}function Ce(e,t,n=ye,i=!1){const a=i?function(t,n){return t.each(void 0,n.acl("default"),e).concat(t.each(void 0,n.acl("defaultForNew"),e))}(n,b):n.each(void 0,b.acl("accessTo"),e),o=b.acl,s={agent:{},agentClass:{},agentGroup:{},origin:{},originClass:{}};return Object.keys(s).forEach(e=>{a.forEach(function(t){n.each(t,o("mode")).forEach(function(i){n.each(t,o(e)).forEach(function(n){s[e][n.uri]=s[e][n.uri]||{},s[e][n.uri][i.uri]=t})})})}),s}function Ee(e,t){const n=function(e,t){for(const n in{agent:!0,agentClass:!0,agentGroup:!0,origin:!0,originClass:!0})if(e[n])for(const i in e[n])for(const a in e[n][i])if(!t[n][i]||!t[n][i][a])return!1;return!0};return n(e,t)&&n(t,e)}function ke(e){const t=e[0];let n,i;for(let a=1;a<e.length;a++)["agent","agentClass","agentGroup","origin","originClass"].forEach(function(o){if(n=e[a],n[o])for(i in n[o])for(const e in n[o][i])t[o][i]||(t[o][i]=[]),t[o][i][e]=!0});return t}function Ae(e,t){const n=[],i=function(e){if(e.length){Ie(e.shift().doc(),function(a,o,s,r,c,l){const p=!o;if(!a||!c||!l)return t(a,r);const u=Ce(p?c:s);n.push(u),i(e.slice(1))})}else t(!0,ke(n))};i(e)}function _e(e){const t={};return["agent","agentClass","agentGroup","origin","originClass"].forEach(function(n){for(const i in e[n]){const a=[];for(const t in e[n][i])a.push(t);a.sort();const o=a.join("\n");t[o]||(t[o]=[]),t[o].push([n,i])}}),t}function Te(e,t,n,i){return Se(e,t,_e(n),i)}function Se(e,t,n,i,a,o){const s=b.acl;for(const r in n){const c=n[r];if(!c.length)continue;const l=r.split("\n");let p=l.map(function(e){return e.split("#")[1]}).join("");o&&!a&&(p+="Default");const u=e.sym(i.uri+"#"+p);e.add(u,b.rdf("type"),s("Authorization"),i),a&&e.add(u,s("accessTo"),t,i),o&&e.add(u,s("default"),t,i);for(let t=0;t<l.length;t++)e.add(u,s("mode"),e.sym(l[t]),i);for(let t=0;t<c.length;t++){const n=c[t][0],a=c[t][1];e.add(u,s(n),e.sym(a),i)}}}function je(e){let t="";for(const n in e){t+=n.split("\n").map(function(e){return e.split("#")[1][0]}).join("")+":";const i=e[n];for(let e=0;e<i.length;e++){const n=i[e][0],a=(0,g.sym)(i[e][1]);t+="agent"===n?"@":"",t+=a.sameTerm(b.foaf("Agent"))?"*":F(a),e<i.length-1&&(t+=",")}t+=";"}return"{"+t.slice(0,-1)+"}"}function Le(e,t,n,i,a){return Re(e,t,_e(n),i,a)}function Re(e,t,n,i,a){const o=(0,g.graph)();Se(o,t,n,i,!0),e.updater?.put(i,o.statementsMatching(void 0,void 0,void 0,i),"text/turtle",function(o,s,r){s?(e.fetcher?.unload(i),Se(e,t,n,i,!0),e.fetcher.requested[i.uri]="done",a(s)):a(s,r)})}function Ne(e,t,n,i){n=n||xe.Rm;const a=e.doc();Ie(a,function(o,s,r,c,l,p){if(!o||!l||!p)return i(!1,c);const u=Ce(s?r:l);Ae(t,function(t,o){if(!t)return i(!1,o);Ee(o,u)?n("Nice - same ACL. no change "+F(e)+" "+a):(n("Group ACLs differ for "+F(e)+" "+a),Le(ye,r,o,c,i))})})}function Ie(e,t){$e(e,function(n,i,a,o){const s=b.acl;if(!n)return t(!1,!1,i,o);const r=function(n){"/"===n.slice(-1)&&(n=n.slice(0,-1));const i=n.lastIndexOf("/");if(n.indexOf("/",n.indexOf("//")+2)>i)return t(!1,!0,404,"Found no ACL resource");n=n.slice(0,i+1);const o=(0,g.sym)(n);$e(o,function(i,c,l){if(!i)return t(!1,!0,c,`( No ACL pointer ${n} ${c})${l}`);if(403===c)return t(!1,!0,c,`( default ACL file FORBIDDEN. Stop.${n})`);if(404===c)return r(n);if(200!==c)return t(!1,!0,c,`Error status '${c}' searching for default for ${o}`);if(!ye.each(void 0,s("default"),ye.sym(n),l).concat(ye.each(void 0,s("defaultForNew"),ye.sym(n),l)).length)return r(n);const p=ye.sym(n);return t(!0,!1,e,a,p,l)})};return n?404!==i?403===i?t(!1,!1,i,`(Sharing not available to you)${o}`):200!==i?t(!1,!1,i,`Error ${i} accessing Access Control information for ${e}: ${o}`):t(!0,!0,e,a):void r(e.uri):t(!1,!1,i,`Error accessing Access Control information for ${e}) ${o}`)})}function $e(e,t){if(!ye.fetcher)throw new Error("kb has no fetcher");ye.fetcher.nowOrWhenFetched(e,void 0,function(n,i){if(!n)return t(n,`Can't get headers to find ACL for ${e}: ${i}`);const a=ye.any(e,v.ACL_LINK);if(a){if(!ye.fetcher)throw new Error("kb has no fetcher");if(ye.fetcher.nonexistent[a.value])return t(!0,404,a,`ACL file ${a} does not exist.`);ye.fetcher.nowOrWhenFetched(a,void 0,function(e,n,i){e?t(!0,200,a):t(!0,i.status,a,`Can't read Access Control File ${a}: ${n}`)})}else t(!1,900,`No Link rel=ACL header for ${e}`)})}async function Be(e){return new Promise((t,n)=>Ie((0,g.sym)(e),(i,a,o,s,r)=>i?t(a?o:r):n(new Error(`Error loading ${e}`))))}var De=n(580),Oe=n.n(De);const Me={randomUUID:"undefined"!=typeof crypto&&crypto.randomUUID&&crypto.randomUUID.bind(crypto)};let Ue;const Fe=new Uint8Array(16);const Pe=[];for(let e=0;e<256;++e)Pe.push((e+256).toString(16).slice(1));function ze(e,t=0){return(Pe[e[t+0]]+Pe[e[t+1]]+Pe[e[t+2]]+Pe[e[t+3]]+"-"+Pe[e[t+4]]+Pe[e[t+5]]+"-"+Pe[e[t+6]]+Pe[e[t+7]]+"-"+Pe[e[t+8]]+Pe[e[t+9]]+"-"+Pe[e[t+10]]+Pe[e[t+11]]+Pe[e[t+12]]+Pe[e[t+13]]+Pe[e[t+14]]+Pe[e[t+15]]).toLowerCase()}function qe(e,t,n){const i=(e=e||{}).random??e.rng?.()??function(){if(!Ue){if("undefined"==typeof crypto||!crypto.getRandomValues)throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");Ue=crypto.getRandomValues.bind(crypto)}return Ue(Fe)}();if(i.length<16)throw new Error("Random bytes length must be >= 16");if(i[6]=15&i[6]|64,i[8]=63&i[8]|128,t){if((n=n||0)<0||n+16>t.length)throw new RangeError(`UUID byte range ${n}:${n+15} is out of buffer bounds`);for(let e=0;e<16;++e)t[n+e]=i[e];return t}return ze(i)}const He=function(e,t,n){return!Me.randomUUID||t||e?qe(e,t,n):Me.randomUUID()};var Ve=n(49);const Ge="#888888",We="8em",Je=20,Qe="#fff",Ze="#000",Ye="#888",Ke="#fee",Xe="white",et="4096",tt={checkboxStyle:"color: black; font-size: 100%; padding-left: 0.5 em; padding-right: 0.5 em;",checkboxInputStyle:"font-size: 150%; height: 1.2em; width: 1.2em; background-color: #eef; border-radius:0.2em; margin: 0.1em;",fieldLabelStyle:"color: #3B5998; text-decoration: none;",formSelectStyle:"background-color: #eef; padding: 0.5em; border: .05em solid #88c; border-radius:0.2em; font-size: 100%; margin:0.4em;",textInputStyle:"background-color: #eef; padding: 0.5em; border: .05em solid #88c; border-radius:0.2em; font-size: 100%; margin:0.4em;",textInputStyleUneditable:"background-color: white; padding: 0.5em; border: .05em solid white; border-radius:0.2em; font-size: 100%; margin:0.4em;",buttonStyle:"background-color: #fff; padding: 0.7em; border: .01em solid white; border-radius:0.2em; font-size: 100%; margin: 0.3em;",commentStyle:"padding: 0.7em; border: none; font-size: 100%; white-space: pre-wrap;",iconStyle:"width: 3em; height: 3em; margin: 0.1em; border-radius: 1em;",smallButtonStyle:"margin: 0.2em; width: 1em; height:1em;",classIconStyle:"width: 3em; height: 3em; margin: 0.1em; border-radius: 0.2em; border: 0.1em solid green; padding: 0.2em; background-color: #efe;",confirmPopupStyle:"padding: 0.7em; border-radius: 0.2em; border: 0.1em solid orange; background-color: white; box-shadow: 0.5em 0.9em #888;",messageBodyStyle:"white-space: pre-wrap; width: 99%; font-size:100%; border: 0.07em solid #eee; border-radius:0.2em; padding: .3em 0.5em; margin: 0.1em;",pendingeditModifier:"color: #bbb;",personaBarStyle:"width: 100%; height: 4em; background-color: #eee; vertical-align: middle;",searchInputStyle:"border: 0.1em solid #444; border-radius: 0.2em; width: 100%; font-size: 100%; padding: 0.1em 0.6em; margin 0.2em;",autocompleteRowStyle:"border: 0.2em solid straw;",signInAndUpButtonStyle:"padding: 1em; border-radius:0.2em; font-size: 100%;",headerBannerLoginInput:"margin: 0.75em 0 0.75em 0.5em !important; padding: 0.5em !important;",signUpBackground:"background-color: #eef;",signInBackground:"background-color: #efe;",heading1Style:"font-size: 180%; font-weight: bold; color: #888888; padding: 0.5em; margin: 0.7em 0.0m;",heading2Style:"font-size: 130%; font-weight: bold; color: #888888; padding: 0.4em; margin: 0.7em 0.0em;",heading3Style:"font-size: 120%; font-weight: bold; color: #888888; padding: 0.3em; margin: 0.7em 0.0em;",heading4Style:"font-size: 110%; font-weight: bold; color: #888888; padding: 0.2em; margin: 0.7em 0.0em;",formHeadingStyle:"font-size: 110%; font-weight: bold; color: #888888; padding: 0.2em; margin: 0.7em 0.0em;",formTextInput:"font-size: 100%; margin: 0.1em; padding: 0.1em;",formGroupStyle:[`padding-left: 0em; border: 0.0em solid ${Ge}; border-radius: 0.2em;`,`padding-left: 2em; border: 0.05em solid ${Ge}; border-radius: 0.2em;`,`padding-left: 2em; border: 0.1em solid ${Ge}; border-radius: 0.2em;`,`padding-left: 2em; border: 0.2em solid ${Ge}; border-radius: 0.2em;`],formFieldLabelStyle:`color: ${"#3B5998"}; text-decoration: none;`,formFieldNameBoxStyle:`padding: 0.3em; vertical-align: middle; width:${We};`,multilineTextInputStyle:"font-size:100%; white-space: pre-wrap; background-color: #eef; border: 0.07em solid gray; padding: 1em 0.5em; margin: 1em 1em;",renderAsDivStyle:"display: flex; align-items: center; justify-content: space-between; height: 2.5em; padding: 1em;",imageDivStyle:"width:2.5em; padding:0.5em; height: 2.5em;",linkDivStyle:"width:2em; padding:0.5em; height: 4em;",aclControlBoxContainer:"margin: 1em;",aclControlBoxHeader:"font-size: 120%; margin: 0 0 1rem;",aclControlBoxStatus:"display: none; margin: 1rem 0;",aclControlBoxStatusRevealed:"display: block;",aclGroupContent:"maxWidth: 650;",accessGroupList:"display: grid; grid-template-columns: 1fr; margin: 1em; width: 100%;",accessGroupListItem:"display: grid; grid-template-columns: 100px auto 30%;",defaultsController:"display: flex;",defaultsControllerNotice:"color: #888; flexGrow: 1; fontSize: 80%;",bigButton:"background-color: white; border: 0.1em solid #888; border-radius: 0.3em; max-width: 50%; padding-bottom: 1em; padding-top: 1em;",group:"color: #888;",group1:"color: green;",group2:"color: #cc0;",group3:"color: orange;",group5:"color: red;",group9:"color: blue;",group13:"color: purple;",trustedAppAddApplicationsTable:"background-color: #eee;",trustedAppCancelButton:"float: right;",trustedAppControllerI:"border-color: orange; border-radius: 1em; border-width: 0.1em;",temporaryStatusInit:"background: green;",temporaryStatusEnd:"background: transparent; transition: background 5s linear;",headerUserMenuLink:"background: none; border: 0; color: black; cursor: pointer; display: block; font-family: Arial; font-size: 1em; text-align: left; padding: 1em; width: 100%; text-decoration: none;",headerUserMenuLinkHover:"background: none; border: 0; color: black; cursor: pointer; display: block; font-family: Arial; font-size: 1em; text-align: left; padding: 1em; width: 100%; text-decoration: none; background-image: linear-gradient(to right, #7C4DFF 0%, #18A9E6 50%, #01C9EA 100%);",headerUserMenuTrigger:"background: none; border: 0; cursor: pointer; width: 60px; height: 60px;",headerUserMenuTriggerImg:"border-radius: 50%; height: 56px; width: 28px !important;",headerUserMenuButton:"background: none; border: 0; color: black; cursor: pointer; display: block; font-family: Arial; font-size: 1em; text-align: left; padding: 1em; width: 100%;",headerUserMenuButtonHover:"background: none; border: 0; color: black; cursor: pointer; display: block; font-family: Arial; font-size: 1em; text-align: left; padding: 1em; width: 100%; background-image: linear-gradient(to right, #7C4DFF 0%, #18A9E6 50%, #01C9EA 100%);",headerUserMenuList:"list-style: none; margin: 0; padding: 0;",headerUserMenuListDisplay:"list-style: none; margin: 0; padding: 0; display:true;",headerUserMenuNavigationMenu:"background: white; border: solid 1px #000000; border-right: 0; position: absolute; right: 0; top: 60px; width: 200px; z-index: 1; display: true;",headerUserMenuNavigationMenuNotDisplayed:"background: white; border: solid 1px #000000; border-right: 0; position: absolute; right: 0; top: 60px; width: 200px; z-index: 1; display: none;",headerUserMenuListItem:"border-bottom: solid 1px #000000;",headerUserMenuPhoto:"border-radius: 50%; background-position: center; background-repeat: no-repeat; background-size: cover; height: 50px; width: 50px;",headerBanner:"box-shadow: 0px 1px 4px #000000; display: flex; justify-content: space-between; padding: 0 1.5em; margin-bottom: 4px;",headerBannerLink:"display: block;",headerBannerRightMenu:"display: flex;",headerBannerLogin:"margin-left: auto;",allChildrenVisible:"display:true;",headerBannerUserMenu:"border-left: solid 1px #000000; margin-left: auto;",headerBannerHelpMenu:"border-left: solid 1px #000000; margin-left: auto;",headerBannerIcon:"background-size: 65px 60px !important; height: 60px !important; width: 65px !important;",footer:"border-top: solid 1px $divider-color; font-size: 0.9em; padding: 0.5em 1.5em;",primaryButton:"background-color: #7c4dff; color: #ffffff; font-family: Raleway, Roboto, sans-serif; border-radius: 0.25em; border-color: #7c4dff; border: 1px solid; cursor: pointer; font-size: .8em; text-decoration: none; padding: 0.5em 4em; transition: 0.25s all ease-in-out; outline: none;",primaryButtonHover:"background-color: #9f7dff; color: #ffffff; font-family: Raleway, Roboto, sans-serif;border-radius: 0.25em; border-color: #7c4dff; border: 1px solid; cursor: pointer; font-size: .8em; text-decoration: none; padding: 0.5em 4em; transition: 0.25s all ease-in-out; outline: none; transition: 0.25s all ease-in-out;",primaryButtonNoBorder:"background-color: #ffffff; color: #7c4dff; font-family: Raleway, Roboto, sans-serif;border-radius: 0.25em; border-color: #7c4dff; border: 1px solid; cursor: pointer; font-size: .8em; text-decoration: none; padding: 0.5em 4em; transition: 0.25s all ease-in-out; outline: none;",primaryButtonNoBorderHover:"background-color: #7c4dff; color: #ffffff; font-family: Raleway, Roboto, sans-serif; border-radius: 0.25em; border-color: #7c4dff; border: 1px solid; cursor: pointer; font-size: .8em; text-decoration: none; padding: 0.5em 4em; transition: 0.25s all ease-in-out; outline: none; transition: 0.25s all ease-in-out;",secondaryButton:"background-color: #01c9ea; color: #ffffff; font-family: Raleway, Roboto, sans-serif;border-radius: 0.25em; border-color: #01c9ea; border: 1px solid; cursor: pointer; font-size: .8em; text-decoration: none; padding: 0.5em 4em; transition: 0.25s all ease-in-out; outline: none;",secondaryButtonHover:"background-color: #37cde6; color: #ffffff; font-family: Raleway, Roboto, sans-serif;border-radius: 0.25em; border-color: #7c4dff; border: 1px solid; cursor: pointer; font-size: .8em; text-decoration: none; padding: 0.5em 4em; transition: 0.25s all ease-in-out; outline: none; transition: 0.25s all ease-in-out;",secondaryButtonNoBorder:"background-color: #ffffff; color: #01c9ea; font-family: Raleway, Roboto, sans-serif; border-radius: 0.25em; border-color: #01c9ea; border: 1px solid; cursor: pointer; font-size: .8em; text-decoration: none; padding: 0.5em 4em; transition: 0.25s all ease-in-out; outline: none;",secondaryButtonNoBorderHover:"background-color: #01c9ea; color: #ffffff; font-family: Raleway, Roboto, sans-serif; border-radius: 0.25em; border-color: #01c9ea; border: 1px solid; cursor: pointer; font-size: .8em; text-decoration: none; padding: 0.5em 4em; transition: 0.25s all ease-in-out; outline: none; transition: 0.25s all ease-in-out;",controlStyle:`border-radius: 0.5em; margin: 0.8em; width:${"640"}; height:${"480"};`,dragEvent:"background-color: #ccc; border: 0.25em dashed black; border-radius: 0.3em;",dropEvent:"background-color: white; border: 0em solid black;",restoreStyle:"background-color: white;",errorCancelButton:"width: 2em; height: 2em; align: right;",errorMessageBlockStyle:"margin: 0.1em; padding: 0.5em; border: 0.05em solid gray; color:black;",notepadStyle:"padding: 1em; overflow: auto; resize: horizontal; min-width: 40em;",upstreamStatus:"width: 50%;",downstreamStatus:"width: 50%;",baseStyle:"font-size: 100%; font-family: monospace; width: 100%; border: none; white-space: pre-wrap;",headingCore:"font-family: sans-serif; font-weight: bold; border: none;",headingStyle:["font-size: 110%; padding-top: 0.5em; padding-bottom: 0.5em; width: 100%;","font-size: 120%; padding-top: 1em; padding-bottom: 1em; width: 100%;","font-size: 150%; padding-top: 1em; padding-bottom: 1em; width: 100%;"],participantsStyle:"margin: 0.8em;",participantsBlock:"height: 1.5em; width: 1.5em; margin: 0.3em; border 0.01em solid #888;",personTableTD:"vertical-align: middle;",tabsNavElement:"margin: 0;",tabsRootElement:"display: flex; height: 100%; width: 100%;",tabsMainElement:"margin: 0; width:100%; height: 100%;",tabContainer:"list-style-type: none; display: flex; height: 100%; width: 100%; margin: 0; padding: 0;",makeNewSlot:"background: none; border: none; font: inherit; cursor: pointer;",ellipsis:"position: absolute; right: 0; bottom: 0; width: 20%; background: none; color: inherit; border: none; padding: 0; font: inherit; cursor: pointer; outline: inherit;"};function nt(e,t,n){const i=function(e){e.preventDefault(),e.dataTransfer.dropEffect="copy"},a=function(e){xe.Rm("dragenter event dropEffect: "+e.dataTransfer.dropEffect),this.localStyle&&(this.savedStyle||(this.savedStyle=tt.dragEvent)),e.dataTransfer.dropEffect="link",xe.Rm("dragenter event dropEffect 2: "+e.dataTransfer.dropEffect)},o=function(e){xe.Rm("dragleave event dropEffect: "+e.dataTransfer.dropEffect),this.savedStyle?this.localStyle=this.savedStyle:this.localStyle=tt.dropEvent},s=function(e){e.preventDefault&&e.preventDefault(),xe.Rm("Drop event. dropEffect: "+e.dataTransfer.dropEffect),xe.Rm("Drop event. types: "+(e.dataTransfer.types?e.dataTransfer.types.join(", "):"NOPE"));let i,a=null;if(e.dataTransfer.types){for(let t=0;t<e.dataTransfer.types.length;t++){const o=e.dataTransfer.types[t];if("text/uri-list"===o)a=e.dataTransfer.getData(o).split("\n"),xe.Rm("Dropped text/uri-list: "+a);else if("text/plain"===o)i=e.dataTransfer.getData(o);else if("Files"===o&&n){const t=e.dataTransfer.files;for(let e=0;t[e];e++){const n=t[e];xe.Rm("Filename: "+n.name+", type: "+(n.type||"n/a")+" size: "+n.size+" bytes, last modified: "+(n.lastModifiedDate?n.lastModifiedDate.toLocaleDateString():"n/a"))}n(t)}}null===a&&i&&"http"===i.slice(0,4)&&(a=i,xe.Rm("Waring: Poor man's drop: using text for URI"))}else a=[e.dataTransfer.getData("Text")],xe.Rm("WARNING non-standard drop event: "+a[0]);return xe.Rm("Dropped URI list (2): "+a),a&&t(a),this.localStyle=tt.restoreStyle,!1};!function(e){e||xe.Rm("@@@ addTargetListeners: ele "+e),e.addEventListener("dragover",i),e.addEventListener("dragenter",a),e.addEventListener("dragleave",o),e.addEventListener("drop",s)}(e)}function it(e,t){e.setAttribute("draggable","true"),e.addEventListener("dragstart",function(n){e.style.fontWeight="bold",n.dataTransfer.setData("text/uri-list",t.uri),n.dataTransfer.setData("text/plain",t.uri),n.dataTransfer.setData("text/html",e.outerHTML),xe.Rm("Dragstart: "+e+" -> "+t+"de: "+n.dataTransfer.dropEffect)},!1),e.addEventListener("drag",function(e){e.preventDefault(),e.stopPropagation()},!1),e.addEventListener("dragend",function(n){e.style.fontWeight="normal",xe.Rm("Dragend dropeffect: "+n.dataTransfer.dropEffect),xe.Rm("Dragend: "+e+" -> "+t)},!1)}function at(e,t,n,i,a){for(let o=0;t[o];o++){const s=t[o];xe.Rm(" dropped: Filename: "+s.name+", type: "+(s.type||"n/a")+" size: "+s.size+" bytes, last modified: "+(s.lastModifiedDate?s.lastModifiedDate.toLocaleDateString():"n/a"));const r=new FileReader;r.onload=function(t){return function(o){const s=o.target.result;let r="";xe.Rm(" File read byteLength : "+s.byteLength);let c=t.type;if(t.type&&""!==t.type){const e=Ve.extension(t.type);e&&"false"!==e&&!t.name.endsWith("."+e)&&t.type!==Ve.lookup(t.name)&&(r="_."+e)}else if(c=Ve.lookup(t.name),!c){const e="Filename needs to have an extension which gives a type we know: "+t.name;throw xe.Rm(e),alert(e),new Error(e)}const l=t.type.startsWith("image/")&&i||n,p=l+(l.endsWith("/")?"":"/")+encodeURIComponent(t.name)+r;e.webOperation("PUT",p,{data:s,contentType:c}).then(e=>{xe.Rm(" Upload: put OK: "+p),a(t,p)},e=>{const t=" Upload: FAIL "+p+", Error: "+e;throw xe.Rm(t),alert(t),new Error(t)})}}(s),r.readAsArrayBuffer(s)}}function ot(e,t,n,i){const a=e.createElement("div"),o=i||t instanceof Error?t:null;return o?(console.error(`errorMessageBlock: ${o} at: ${o.stack||"??"}`,o),a.textContent=o.message):a.textContent=t,a.appendChild(Ft(e,()=>{a.parentNode&&a.parentNode.removeChild(a)})).style=tt.errorCancelButton,a.setAttribute("style",tt.errorMessageBlockStyle),a.style.backgroundColor=n||Ke,a}tt.setStyle=function(e,t){e.style=tt[t]};var st=n(378);const rt=v.solidLogicSingleton.store;class ct{constructor(e,t,n,i){this.options=i||{},this.element=e,this.typeIndex=t,this.groupPickedCb=n,this.selectedgroup=this.options.selectedgroup,this.onSelectGroup=this.onSelectGroup.bind(this)}render(){const e=document.createElement("div");if(e.style.maxWidth="350px",e.style.minHeight="200px",e.style.outline="1px solid black",e.style.display="flex",this.selectedgroup){e.style.flexDirection="column";const t=document.createElement("div");new pt(t,this.selectedgroup).render();const n=document.createElement("button");n.textContent=Oe()("Change group"),n.addEventListener("click",e=>{this.selectedgroup=null,this.render()}),e.appendChild(t),e.appendChild(n)}else this.findAddressBook(this.typeIndex).then(({book:t})=>{const n=document.createElement("button");n.textContent=Oe()("Pick an existing group"),n.style.margin="auto",n.addEventListener("click",n=>{new lt(e,t,this.onSelectGroup).render()});const i=document.createElement("button");i.textContent=Oe()("Create a new group"),i.style.margin="auto",i.addEventListener("click",e=>{this.createNewGroup(t,this.options.defaultNewGroupName).then(({group:e})=>{new ut(this.element,t,e,this.onSelectGroup).render()}).catch(e=>{this.element.appendChild(ot(document,Oe()(`Error creating a new group. (${e})`)))})}),e.appendChild(n),e.appendChild(i),this.element.innerHTML="",this.element.appendChild(e)}).catch(e=>{this.element.appendChild(ot(document,Oe()(`Could find your groups. (${e})`)))});return this.element.innerHTML="",this.element.appendChild(e),this}findAddressBook(e){return new Promise((t,n)=>{rt.fetcher.nowOrWhenFetched(e,(i,a)=>{if(!i)return n(a);const o=rt.any(null,b.solid("forClass"),b.vcard("AddressBook"));if(!o)return n(new Error("no address book registered in the solid type index "+e));const s=rt.any(o,b.solid("instance"));if(!s)return n(new Error("incomplete address book registration"));rt.fetcher.load(s).then(function(e){return t({book:s})}).catch(function(e){return n(new Error("Could not load address book "+e))})})})}createNewGroup(e,t){const{groupIndex:n,groupContainer:i}=ht(e),a=g.sym(`${i.uri}${He().slice(0,8)}.ttl#this`),o=t||"Untitled Group",s=[a.doc(),n].map(t=>{const i=g.st(a,b.rdf("type"),b.vcard("Group"),t),s=g.st(a,b.vcard("fn"),o,a.doc(),t),r=g.st(e,b.vcard("includesGroup"),a,t),c=t.equals(n)?[i,s,r]:[i,s];return ft(t.uri,{toIns:c}).then(()=>{c.forEach(e=>{rt.add(e)})})});return Promise.all(s).then(()=>({group:a})).catch(e=>{throw xe.Rm("Could not create new group. PATCH failed "+e),new Error(`Couldn't create new group. PATCH failed for (${e.xhr?e.xhr.responseURL:""} )`)})}onSelectGroup(e){this.selectedgroup=e,this.groupPickedCb(e),this.render()}}class lt{constructor(e,t,n){this.element=e,this.book=t,this.onSelectGroup=n}render(){return this.loadGroups().then(e=>{const t=document.createElement("div");t.style.display="flex",t.style.flexDirection="column",e.forEach(e=>{const n=document.createElement("button");n.addEventListener("click",this.handleClickGroup(e)),new pt(n,e).render(),t.appendChild(n)}),this.element.innerHTML="",this.element.appendChild(t)}).catch(e=>{this.element.appendChild(ot(document,Oe()(`There was an error loading your groups. (${e})`)))}),this}loadGroups(){return new Promise((e,t)=>{const{groupIndex:n}=ht(this.book);rt.fetcher.nowOrWhenFetched(n,(n,i)=>{if(!n)return t(i);const a=rt.each(this.book,b.vcard("includesGroup"));return e(a)})})}handleClickGroup(e){return t=>{this.onSelectGroup(e)}}}class pt{constructor(e,t){this.element=e,this.group=t}render(){const e=document.createElement("div");return e.textContent=Oe()(mt(this.group,b.vcard("fn"),`[${this.group.value}]`)),this.element.innerHTML="",this.element.appendChild(e),this}}class ut{constructor(e,t,n,i,a){this.element=e,this.book=t,this.group=n,this.onGroupChanged=(e,t,n)=>{a&&a(e,t,n)},this.groupChangedCb=a,this.doneBuildingCb=i}refresh(){}render(){const e=document.createElement("div");e.style.maxWidth="350px",e.style.minHeight="200px",e.style.outline="1px solid black",e.style.display="flex",e.style.flexDirection="column",nt(e,e=>{e.forEach(e=>{this.add(e).catch(e=>{this.element.appendChild(ot(document,Oe()(`Could not add the given WebId. (${e})`)))})})});const t=document.createElement("input");t.type="text",t.value=mt(this.group,b.vcard("fn"),"Untitled Group"),t.addEventListener("change",e=>{this.setGroupName(e.target.value).catch(e=>{this.element.appendChild(ot(document,`Error changing group name. (${e})`))})});const n=document.createElement("label");if(n.textContent=Oe()("Group Name:"),n.appendChild(t),e.appendChild(n),rt.any(this.group,b.vcard("hasMember")))rt.match(this.group,b.vcard("hasMember")).forEach(t=>{const n=t.object,i=document.createElement("div");new dt(i,n,this.handleRemove(n)).render(),e.appendChild(i)});else{const t=document.createElement("p");t.textContent=Oe()`
1
+ (()=>{var e={423(e,t,n){"use strict";function i(...e){console.log(...e)}function a(...e){console.warn(...e)}function o(...e){console.error(...e)}function s(...e){console.trace(...e)}n.d(t,{R8:()=>a,Rm:()=>i,uP:()=>s,z3:()=>o})},378(e,t,n){"use strict";n.d(t,{LN:()=>s,Pt:()=>o,i1:()=>r});var i=n(423);const a="https://solidos.github.io/solid-ui/src",o=(e=n.hmd(e)).scriptURI?{iconBase:e.scriptURI.slice(0,e.scriptURI.lastIndexOf("/"))+"/icons/",originalIconBase:e.scriptURI.slice(0,e.scriptURI.lastIndexOf("/"))+"/originalIcons/"}:"undefined"!=typeof $SolidTestEnvironment&&$SolidTestEnvironment.iconBase?{iconBase:$SolidTestEnvironment.iconBase,originalIconBase:$SolidTestEnvironment.originalIconBase}:{iconBase:a+"/icons/",originalIconBase:a+"/originalIcons/"};(0,i.Rm)(" icons.iconBase is set to : "+o.iconBase);const s=o.iconBase,r=o.originalIconBase},788(e,t,n){"use strict";n.d(t,{icons:()=>it.Pt,ns:()=>b});var i={};n.r(i),n.d(i,{LogLevel:()=>x,alert:()=>R,clear:()=>N,debug:()=>T,dumpHTML:()=>$,error:()=>j,escapeForXML:()=>O,info:()=>S,logAscending:()=>B,logDescending:()=>D,msg:()=>A,setInternals:()=>M,setLevel:()=>I,success:()=>L,warn:()=>_});var a={};n.r(a),n.d(a,{AJARImage:()=>ce,RDFComparePredicateObject:()=>ge,RDFComparePredicateSubject:()=>be,addLoadEvent:()=>oe,ancestor:()=>te,beep:()=>W,clearVariableNames:()=>G,emptyNode:()=>X,escapeForXML:()=>de,findPos:()=>se,genUuid:()=>Q,getAbout:()=>ne,getEyeFocus:()=>re,getTarget:()=>ee,getTerm:()=>ie,hashColor:()=>J,include:()=>ae,label:()=>F,labelForXML:()=>me,labelWithOntology:()=>ue,newVariableName:()=>V,ontologyLabel:()=>pe,predParentOf:()=>ve,predicateLabel:()=>he,predicateLabelForXML:()=>fe,shortName:()=>le,stackString:()=>K,syncTableToArray:()=>Z,syncTableToArrayReOrdered:()=>Y});var o={};n.r(o),n.d(o,{addDefaults:()=>wn,defaultPreferredLanguages:()=>yn,filterByLanguage:()=>kn,getPreferredLanguages:()=>En,getPreferredLanguagesFor:()=>Cn,languageCodeURIBase:()=>xn});var s={};n.r(s),n.d(s,{AUTOCOMPLETE_LIMIT:()=>An,ESCOResultToBindings:()=>Un,bindingToTerm:()=>On,dbPediaTypeMap:()=>Nn,dbpediaParameters:()=>Rn,escoParameters:()=>Ln,fetcherOptionsJsonPublicData:()=>jn,getDbpediaDetails:()=>Qn,getWikidataDetails:()=>Gn,getWikidataDetailsOld:()=>Wn,getWikidataLocation:()=>Jn,instituteDetailsWikidataQuery:()=>Sn,loadFromBindings:()=>Mn,loadPublicDataThing:()=>Vn,queryESCODataByName:()=>Fn,queryPublicDataByName:()=>zn,queryPublicDataConstruct:()=>Hn,queryPublicDataSelect:()=>qn,variableNameToPredicateMap:()=>Dn,wikidataClasses:()=>Tn,wikidataIncomingClassMap:()=>Bn,wikidataOutgoingClassMap:()=>In,wikidataParameters:()=>$n});var r={};n.r(r),n.d(r,{Group:()=>rt,GroupBuilder:()=>ct,GroupPicker:()=>st,PeoplePicker:()=>ot,Person:()=>lt,addStyleSheet:()=>nn,allClassURIs:()=>Qt,appendForm:()=>li,askName:()=>Ut,attachmentList:()=>Gt,basicField:()=>vn,buildCheckboxForm:()=>Ci,button:()=>Dt,cancelButton:()=>Ot,clearElement:()=>yt,complain:()=>xt,continueButton:()=>Mt,createLinkDiv:()=>qt,createLinkForURI:()=>ht,createNameDiv:()=>zt,defaultAnnotationStore:()=>Jt,deleteButtonWithCheck:()=>Bt,editFormButton:()=>ci,errorMessageBlock:()=>nt,extractLogURI:()=>wt,faviconOrDefault:()=>$t,field:()=>pn,fieldFunction:()=>dn,fieldLabel:()=>gn,fieldParams:()=>cn,fieldStore:()=>bn,fileUploadButtonDiv:()=>rn,findClosest:()=>ui,findImage:()=>Rt,findImageFromURI:()=>Lt,formatDateTime:()=>Et,formsFor:()=>di,iconForClass:()=>St,imagesOf:()=>Tt,index:()=>tn,isAudio:()=>an,isImage:()=>sn,isVideo:()=>on,linkButton:()=>Yt,linkIcon:()=>ft,makeDescription:()=>bi,makeDraggable:()=>et,makeDropTarget:()=>Xe,makeSelectForCategory:()=>yi,makeSelectForChoice:()=>ki,makeSelectForClassifierOptions:()=>vi,makeSelectForNestedCategory:()=>wi,makeSelectForOptions:()=>xi,mostSpecificClassURI:()=>un,newButton:()=>hi,newThing:()=>Ei,openHrefInOutlineMode:()=>Wt,personTR:()=>Ft,promptForNew:()=>gi,propertiesForClass:()=>pi,propertyTriage:()=>Zt,publicData:()=>s,refreshTree:()=>Vt,removeButton:()=>Kt,renderAsDiv:()=>Ht,renderAsRow:()=>Pt,renderAutoComplete:()=>Yn,renderAutocompleteControl:()=>ti,renderNameValuePair:()=>hn,selectorPanel:()=>Xt,selectorPanelRefresh:()=>en,setImage:()=>It,setName:()=>_t,setVisible:()=>Zn,shortDate:()=>Ct,shortTime:()=>At,sortByLabel:()=>fi,sortBySequence:()=>mi,timestamp:()=>kt,uploadFiles:()=>tt});var c={};n.r(c),n.d(c,{ensureLoadedPreferences:()=>Di,ensureLoadedProfile:()=>Oi,ensureLoggedIn:()=>Bi,filterAvailablePanes:()=>Ji,findAppInstances:()=>Mi,getUserRoles:()=>Wi,loginStatusBox:()=>Hi,newAppInstance:()=>Gi,registrationControl:()=>Fi,registrationList:()=>zi,renderScopeHeadingRow:()=>Pi,renderSignInPopup:()=>qi,scopeLabel:()=>Ui,selectWorkspace:()=>Vi});var l={};n.r(l),n.d(l,{manageParticipation:()=>Ys,participationObject:()=>Qs,recordParticipation:()=>Zs,renderParticipants:()=>Js});var p={};n.r(p),n.d(p,{getChunks:()=>nr,lightColorHash:()=>er,manageParticipation:()=>Ys,notepad:()=>tr,notepadToHTML:()=>ar,participationObject:()=>Qs,recordParticipation:()=>Zs,renderParticipants:()=>Js,xmlEncode:()=>ir});var u={};n.r(u),n.d(u,{get:()=>Ar,getPreferencesForClass:()=>Rr,recordPersonalDefaults:()=>Sr,recordSharedPreferences:()=>Tr,renderPreferencesForm:()=>jr,set:()=>_r,value:()=>kr});var d={};n.r(d),n.d(d,{TabWidgetElement:()=>Ir,tabWidget:()=>$r});var m={};n.r(m);var f=n(386),h=n.n(f),g=n(511);const b=h()(g);var v=n(892);let x=function(e){return e[e.Error=1]="Error",e[e.Warning=2]="Warning",e[e.Message=4]="Message",e[e.Success=8]="Success",e[e.Info=16]="Info",e[e.Debug=32]="Debug",e[e.All=63]="All",e}({}),y=7,w=!1,C=document,E=window;function k(e,t=4,n="mesg"){if(y&t)if(void 0!==C){const t=C.getElementById("status");if(!t)return;const i=C.createElement("span");i.setAttribute("class",n);const a=new Date;i.innerHTML=`${a.getHours()}:${a.getMinutes()}:${a.getSeconds()} [${n}] ${O(e)}<br/>`,w?t.insertBefore(i,t.firstChild):t.appendChild(i)}else"undefined"!=typeof console&&console.log(e)}function A(e){k(e)}function _(e){k(e,2,"warn")}function T(e){k(e,32,"dbug")}function S(e){k(e,16,"info")}function j(e){k(e,1,"eror")}function L(e){k(e,8,"good")}function R(e){E&&void 0!==E.alert?E.alert(e):_(e)}function N(){const e=C?.getElementById("status");e&&(e.innerHTML="")}function I(e){y=63,T("Log level is now "+e),y=e}function $(){if(!C)return;const e=y;y=63,T(C?.body?.innerHTML||""),y=e}function B(){w=!0}function D(){w=!1}function O(e){return e.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}function M(e,t){E=e,C=t}const U={log:i,ns:b,rdf:g};function F(e,t=!1){function n(e){return t?e.slice(0,1).toUpperCase()+e.slice(1):e}function i(e){let t="";"/"===e.slice(-1)&&(e=e.slice(0,-1));for(let n=0;n<e.length;n++)"_"!==e[n]&&"-"!==e[n]?(t+=e[n],n+1<e.length&&e[n].toUpperCase()!==e[n]&&e[n+1].toLowerCase()!==e[n+1]&&(t+=" ")):t+=" ";return"has "===t.slice(0,4)&&(t=t.slice(4)),n(t)}const a=function(e){return v.store.any(e,U.ns.ui("label"))||v.store.any(e,U.ns.link("message"))||v.store.any(e,U.ns.vcard("fn"))||v.store.any(e,U.ns.foaf("name"))||v.store.any(e,U.ns.dct("title"))||v.store.any(e,U.ns.dc("title"))||v.store.any(e,U.ns.rss("title"))||v.store.any(e,U.ns.contact("fullName"))||v.store.any(e,v.store.sym("http://www.w3.org/2001/04/roadmap/org#name"))||v.store.any(e,U.ns.cal("summary"))||v.store.any(e,U.ns.foaf("nick"))||v.store.any(e,U.ns.as("name"))||v.store.any(e,U.ns.schema("name"))||v.store.any(e,U.ns.rdfs("label"))||v.store.any(e,v.store.sym("http://www.w3.org/2004/02/skos/core#prefLabel"))}(e);if(a)return n(a.value);if("BlankNode"===e.termType)return"...";if("Collection"===e.termType)return"("+e.elements.length+")";let o=e.uri;if(void 0===o)return e.toString();try{o=o.split("/").map(decodeURIComponent).join("/")}catch(e){for(let e=o.length-3;e>0;e--){const t="0123456789abcefABCDEF";for(;"%"===o[e]&&t.indexOf(o[e+1])>=0&&t.indexOf(o[e+2])>=0;)o=o.slice(0,e)+String.fromCharCode(parseInt(o.slice(e+1,e+3),16))+o.slice(e+3)}}o=P(o,"/profile/card#me"),o=P(o,"#this"),o=P(o,"#me");const s=o.indexOf("#");if(s>=0)return i(o.slice(s+1));const r=o.lastIndexOf("/",o.length-2);return r>=0&&r<e.uri.length?i(o.slice(r+1)):n(decodeURIComponent(e.uri))}function P(e,t){const n=-1*t.length;return e.slice(n)===t?e.slice(0,n):e}const z={log:i,ns:b,rdf:g};let q,H=0;function V(){return"v"+H++}function G(){H=0}function W(){if(!q)return;const e=new q;return function(t,n,i,a){t=+(t||.3),i=i||"sine","function"!=typeof a&&(a=function(){});const o=e.createOscillator();o.type=i,o.frequency.value=n||256,o.connect(e.destination),o.start(0),o.stop(t)}}function J(e){e=e.uri||e;return"#"+(16777215&(t=e,t.split("").reduce(function(e,t){return(e=(e<<5)-e+t.charCodeAt(0))&e},0))|12632256).toString(16);var t}function Q(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(e){const t=16*Math.random()|0;return("x"===e?t:3&t|8).toString(16)})}function Z(e,t,n,i){let a,o,s;for(s=0;s<e.children.length;s++)o=e.children[s],o.trashMe=!0;for(let r=0;r<t.length;r++){const c=t[r];for(a=!1,s=0;s<e.children.length;s++)if(o=e.children[s],o.subject&&o.subject.sameTerm(c)){if(i){const e=i(o,c);e&&e!==o&&(o.parentNode.replaceChild(e,o),e.subject=c,o=e)}o.trashMe=!1,a=!0;break}if(!a){const t=n(c);if(r>=e.children.length)e.appendChild(t);else{const n=e.children[r];e.insertBefore(t,n)}t.subject=c}}for(s=0;s<e.children.length;s++)o=e.children[s],o.trashMe&&e.removeChild(o)}function Y(e,t,n){const i={};for(let t=0;t<e.children.length;t++){const n=e.children[t];i[n.subject.toNT()]=n}for(let a=0;a<t.length;a++){const o=t[a];if(a>=e.children.length){const t=n(o);t.subject=o,e.appendChild(t)}else{const t=e.children[a];if(t.subject.sameTerm(o));else{const a=i[o.toNT()];if(a)e.removeChild(a),e.insertBefore(a,t);else{const e=n(o);t.before(e),e.subject=o}}}}for(;e.children.length>t.length;)e.removeChild(e.children[e.children.length-1])}function K(e){let t,n=e+"\n";if(!e.stack)return n+"No stack available.\n";const i=e.stack.toString().split("\n"),a=[];for(t=0;t<i.length;t++){let e=i[t];if(e.indexOf("ecmaunit.js")>-1)break;"("===e.charAt(0)&&(e="function"+e);const n=e.split("@");a.push(n)}for(t=0;t<a.length;t++)n+=" "+a[t][1]+"\n "+a[t][0];return n}function X(e){const t=e.childNodes;for(let n=t.length-1;n>=0;n--)e.removeChild(t[n]);return e}function ee(e){let t;return(e=e||window.event).target?t=e.target:e.srcElement&&(t=e.srcElement),3===t.nodeType&&(t=t.parentNode),t}function te(e,t){let n;for(n=e;n;n=n.parentNode)try{if(n.tagName===t)return n}catch(e){return}}function ne(e,t){let n,i;for(n=t;n&&1===n.nodeType;n=n.parentNode)if(i=n.getAttribute("about"),i)return e.fromNT(i);z.log.debug("getAbout: No about found")}function ie(e){const t=e.parentNode,n=t?t.AJAR_statement:void 0;switch(n?e.className:""){case"pred":case"pred selected":return n.predicate;case"obj":case"obj selected":return t.AJAR_inverse?n.subject:n.object;case"":case"selected":return ne(v.store,e);case"undetermined selected":return e.nextSibling?n.predicate:t.AJAR_inverse?n.subject:n.object}}function ae(e,t){const n=e.createElement("script");return n.setAttribute("type","text/javascript"),n.setAttribute("src",t),n}function oe(e){const t=window.onload;"function"!=typeof window.onload?window.onload=e:window.onload=function(){t(),e()}}function se(e){const t=e.ownerDocument.documentElement.getBoundingClientRect(),n=e.getBoundingClientRect();return[n.left-t.left,n.top-t.top]}function re(e,t,n,i){i||(i=window);const a=se(e)[1],o=window.SolidAppContext||{},s=a-(o&&o.scroll||52)-i.scrollY;if(t)return n?void i.scrollBy(0,a+e.clientHeight-(i.scrollY+i.innerHeight)):void i.scrollBy(0,s);const r=i.setInterval(function(){i.scrollBy(0,s/10),c++,10===c&&i.clearInterval(r)},50);let c=0}function ce(e,t,n,i){i||(i=document);const a=i.createElement("img");return a.setAttribute("src",e),a.addEventListener("copy",function(e){e.clipboardData.setData("text/plain",""),e.clipboardData.setData("text/html",""),e.preventDefault()}),void 0!==n&&a.setAttribute("title",n),a}function le(e){let t=e;"#/".indexOf(t[t.length-1])>=0&&(t=t.slice(0,-1));const n=[];for(const e in this.prefixes)n[this.prefixes[e]]=e;let i;const a=function(e){return"ns"!==e&&(i=e,!0)};let o;const s=t.lastIndexOf("#");for(s>=0&&(t=t.slice(s-1));;){const e=t.lastIndexOf("/");for(e>=0&&(t=t.slice(e+1)),o=0;o<t.length&&this.prefixchars.indexOf(t[o]);)o++;if(t=t.slice(0,o),t.length<6&&a(t))return i;if(a(t.slice(0,3)))return i;if(a(t.slice(0,2)))return i;if(a(t.slice(0,4)))return i;if(a(t.slice(0,1)))return i;if(a(t.slice(0,5)))return i;for(o=0;;o++)if(a(t.slice(0,3)+o))return i}}function pe(e){if(void 0===e.uri)return"??";let t=e.uri;const n=[];let i,a=t.lastIndexOf("#");if(a>=0)t=t.slice(0,a+1);else{if(a=t.lastIndexOf("/"),!(a>=0))return e.uri+"?!";t=t.slice(0,a+1)}for(const e in z.ns)n[z.ns[e]]=e;try{return n[t]}catch(e){}for(t=t.slice(0,-1);t;){if(a=t.lastIndexOf("/"),!(a>=0))return e.uri+"!?";if(i=t.slice(a+1),t=t.slice(0,a),"ns"!==i&&"0123456789".indexOf(i[0])<0)return i}}function ue(e,t){const n=v.store.findTypeURIs(e);return n[z.ns.rdf("Predicate").uri]||n[z.ns.rdfs("Class").uri]?F(e,t)+" ("+pe(e)+")":F(e,t)}function de(e){return e.replace(/&/g,"&amp;").replace(/</g,"&lt;")}function me(e){return de(F(e))}function fe(e,t){return de(he(e,t))}function he(e,t){const n=F(e);if(t){const t=v.store.any(e,z.ns.owl("inverseOf"))||v.store.any(void 0,z.ns.owl("inverseOf"),e);return t?F(t):"type"===n?"...":"is "+n+" of"}return n}function ge(e,t){const n=e.predicate.compareTerm(t.predicate);return 0!==n?n:e.object.compareTerm(t.object)}function be(e,t){const n=e.predicate.compareTerm(t.predicate);return 0!==n?n:e.subject.compareTerm(t.subject)}function ve(e){let t=e;for(;;){if(t.getAttribute("predTR"))return t;if(!t.previousSibling||"TR"!==t.previousSibling.nodeName)return z.log.error("Could not find predParent"),e;t=t.previousSibling}}"undefined"!=typeof AudioContext?q=AudioContext:"undefined"!=typeof window&&(q=window.AudioContext||window.webkitAudioContext);var xe=n(423);const ye=v.solidLogicSingleton.store;function we(e,t,n,i){const a=b.acl,o="/"===e.uri.slice(-1),s=ye.each(void 0,a("default"),n,i).concat(ye.each(void 0,a("defaultForNew"),n,i)).reduce((t,n)=>t.concat(ye.statementsMatching(n,b.rdf("type"),a("Authorization"),i)).concat(ye.statementsMatching(n,a("agent"),void 0,i)).concat(ye.statementsMatching(n,a("agentClass"),void 0,i)).concat(ye.statementsMatching(n,a("agentGroup"),void 0,i)).concat(ye.statementsMatching(n,a("origin"),void 0,i)).concat(ye.statementsMatching(n,a("originClass"),void 0,i)).concat(ye.statementsMatching(n,a("mode"),void 0,i)).concat((0,g.st)(n,a("accessTo"),e,i)).concat(o?(0,g.st)(n,a("default"),e,i):[]),[]),r=(0,g.graph)();return s.forEach(e=>r.add(c(e.subject),c(e.predicate),c(e.object),(0,g.sym)(t.uri))),r;function c(e){const n=i.uri.length;return(0,g.sym)(e.uri.slice(0,n)===i.uri?t.uri+e.uri.slice(n):e.uri)}}function Ce(e,t,n=ye,i=!1){const a=i?function(t,n){return t.each(void 0,n.acl("default"),e).concat(t.each(void 0,n.acl("defaultForNew"),e))}(n,b):n.each(void 0,b.acl("accessTo"),e),o=b.acl,s={agent:{},agentClass:{},agentGroup:{},origin:{},originClass:{}};return Object.keys(s).forEach(e=>{a.forEach(function(t){n.each(t,o("mode")).forEach(function(i){n.each(t,o(e)).forEach(function(n){s[e][n.uri]=s[e][n.uri]||{},s[e][n.uri][i.uri]=t})})})}),s}function Ee(e,t){const n=function(e,t){for(const n in{agent:!0,agentClass:!0,agentGroup:!0,origin:!0,originClass:!0})if(e[n])for(const i in e[n])for(const a in e[n][i])if(!t[n][i]||!t[n][i][a])return!1;return!0};return n(e,t)&&n(t,e)}function ke(e){const t=e[0];let n,i;for(let a=1;a<e.length;a++)["agent","agentClass","agentGroup","origin","originClass"].forEach(function(o){if(n=e[a],n[o])for(i in n[o])for(const e in n[o][i])t[o][i]||(t[o][i]=[]),t[o][i][e]=!0});return t}function Ae(e,t){const n=[],i=function(e){if(e.length){Ie(e.shift().doc(),function(a,o,s,r,c,l){const p=!o;if(!a||!c||!l)return t(a,r);const u=Ce(p?c:s);n.push(u),i(e.slice(1))})}else t(!0,ke(n))};i(e)}function _e(e){const t={};return["agent","agentClass","agentGroup","origin","originClass"].forEach(function(n){for(const i in e[n]){const a=[];for(const t in e[n][i])a.push(t);a.sort();const o=a.join("\n");t[o]||(t[o]=[]),t[o].push([n,i])}}),t}function Te(e,t,n,i){return Se(e,t,_e(n),i)}function Se(e,t,n,i,a,o){const s=b.acl;for(const r in n){const c=n[r];if(!c.length)continue;const l=r.split("\n");let p=l.map(function(e){return e.split("#")[1]}).join("");o&&!a&&(p+="Default");const u=e.sym(i.uri+"#"+p);e.add(u,b.rdf("type"),s("Authorization"),i),a&&e.add(u,s("accessTo"),t,i),o&&e.add(u,s("default"),t,i);for(let t=0;t<l.length;t++)e.add(u,s("mode"),e.sym(l[t]),i);for(let t=0;t<c.length;t++){const n=c[t][0],a=c[t][1];e.add(u,s(n),e.sym(a),i)}}}function je(e){let t="";for(const n in e){t+=n.split("\n").map(function(e){return e.split("#")[1][0]}).join("")+":";const i=e[n];for(let e=0;e<i.length;e++){const n=i[e][0],a=(0,g.sym)(i[e][1]);t+="agent"===n?"@":"",t+=a.sameTerm(b.foaf("Agent"))?"*":F(a),e<i.length-1&&(t+=",")}t+=";"}return"{"+t.slice(0,-1)+"}"}function Le(e,t,n,i,a){return Re(e,t,_e(n),i,a)}function Re(e,t,n,i,a){const o=(0,g.graph)();Se(o,t,n,i,!0),e.updater?.put(i,o.statementsMatching(void 0,void 0,void 0,i),"text/turtle",function(o,s,r){s?(e.fetcher?.unload(i),Se(e,t,n,i,!0),e.fetcher.requested[i.uri]="done",a(s)):a(s,r)})}function Ne(e,t,n,i){n=n||xe.Rm;const a=e.doc();Ie(a,function(o,s,r,c,l,p){if(!o||!l||!p)return i(!1,c);const u=Ce(s?r:l);Ae(t,function(t,o){if(!t)return i(!1,o);Ee(o,u)?n("Nice - same ACL. no change "+F(e)+" "+a):(n("Group ACLs differ for "+F(e)+" "+a),Le(ye,r,o,c,i))})})}function Ie(e,t){$e(e,function(n,i,a,o){const s=b.acl;if(!n)return t(!1,!1,i,o);const r=function(n){"/"===n.slice(-1)&&(n=n.slice(0,-1));const i=n.lastIndexOf("/");if(n.indexOf("/",n.indexOf("//")+2)>i)return t(!1,!0,404,"Found no ACL resource");n=n.slice(0,i+1);const o=(0,g.sym)(n);$e(o,function(i,c,l){if(!i)return t(!1,!0,c,`( No ACL pointer ${n} ${c})${l}`);if(403===c)return t(!1,!0,c,`( default ACL file FORBIDDEN. Stop.${n})`);if(404===c)return r(n);if(200!==c)return t(!1,!0,c,`Error status '${c}' searching for default for ${o}`);if(!ye.each(void 0,s("default"),ye.sym(n),l).concat(ye.each(void 0,s("defaultForNew"),ye.sym(n),l)).length)return r(n);const p=ye.sym(n);return t(!0,!1,e,a,p,l)})};return n?404!==i?403===i?t(!1,!1,i,`(Sharing not available to you)${o}`):200!==i?t(!1,!1,i,`Error ${i} accessing Access Control information for ${e}: ${o}`):t(!0,!0,e,a):void r(e.uri):t(!1,!1,i,`Error accessing Access Control information for ${e}) ${o}`)})}function $e(e,t){if(!ye.fetcher)throw new Error("kb has no fetcher");ye.fetcher.nowOrWhenFetched(e,void 0,function(n,i){if(!n)return t(n,`Can't get headers to find ACL for ${e}: ${i}`);const a=ye.any(e,v.ACL_LINK);if(a){if(!ye.fetcher)throw new Error("kb has no fetcher");if(ye.fetcher.nonexistent[a.value])return t(!0,404,a,`ACL file ${a} does not exist.`);ye.fetcher.nowOrWhenFetched(a,void 0,function(e,n,i){e?t(!0,200,a):t(!0,i.status,a,`Can't read Access Control File ${a}: ${n}`)})}else t(!1,900,`No Link rel=ACL header for ${e}`)})}async function Be(e){return new Promise((t,n)=>Ie((0,g.sym)(e),(i,a,o,s,r)=>i?t(a?o:r):n(new Error(`Error loading ${e}`))))}var De=n(580),Oe=n.n(De);const Me=new Uint8Array(16);const Ue=[];for(let e=0;e<256;++e)Ue.push((e+256).toString(16).slice(1));function Fe(e,t=0){return(Ue[e[t+0]]+Ue[e[t+1]]+Ue[e[t+2]]+Ue[e[t+3]]+"-"+Ue[e[t+4]]+Ue[e[t+5]]+"-"+Ue[e[t+6]]+Ue[e[t+7]]+"-"+Ue[e[t+8]]+Ue[e[t+9]]+"-"+Ue[e[t+10]]+Ue[e[t+11]]+Ue[e[t+12]]+Ue[e[t+13]]+Ue[e[t+14]]+Ue[e[t+15]]).toLowerCase()}const Pe=function(e,t,n){return t||e||!crypto.randomUUID?function(e,t,n){e=e||{};const i=e.random??e.rng?.()??crypto.getRandomValues(Me);if(i.length<16)throw new Error("Random bytes length must be >= 16");if(i[6]=15&i[6]|64,i[8]=63&i[8]|128,t){if((n=n||0)<0||n+16>t.length)throw new RangeError(`UUID byte range ${n}:${n+15} is out of buffer bounds`);for(let e=0;e<16;++e)t[n+e]=i[e];return t}return Fe(i)}(e,t,n):crypto.randomUUID()};var ze=n(49);const qe="#888888",He="8em",Ve=20,Ge="#fff",We="#000",Je="#888",Qe="#fee",Ze="white",Ye="4096",Ke={checkboxStyle:"color: black; font-size: 100%; padding-left: 0.5 em; padding-right: 0.5 em;",checkboxInputStyle:"font-size: 150%; height: 1.2em; width: 1.2em; background-color: #eef; border-radius:0.2em; margin: 0.1em;",fieldLabelStyle:"color: #3B5998; text-decoration: none;",formSelectStyle:"background-color: #eef; padding: 0.5em; border: .05em solid #88c; border-radius:0.2em; font-size: 100%; margin:0.4em;",textInputStyle:"background-color: #eef; padding: 0.5em; border: .05em solid #88c; border-radius:0.2em; font-size: 100%; margin:0.4em;",textInputStyleUneditable:"background-color: white; padding: 0.5em; border: .05em solid white; border-radius:0.2em; font-size: 100%; margin:0.4em;",buttonStyle:"background-color: #fff; padding: 0.7em; border: .01em solid white; border-radius:0.2em; font-size: 100%; margin: 0.3em;",commentStyle:"padding: 0.7em; border: none; font-size: 100%; white-space: pre-wrap;",iconStyle:"width: 3em; height: 3em; margin: 0.1em; border-radius: 1em;",smallButtonStyle:"margin: 0.2em; width: 1em; height:1em;",classIconStyle:"width: 3em; height: 3em; margin: 0.1em; border-radius: 0.2em; border: 0.1em solid green; padding: 0.2em; background-color: #efe;",confirmPopupStyle:"padding: 0.7em; border-radius: 0.2em; border: 0.1em solid orange; background-color: white; box-shadow: 0.5em 0.9em #888;",messageBodyStyle:"white-space: pre-wrap; width: 99%; font-size:100%; border: 0.07em solid #eee; border-radius:0.2em; padding: .3em 0.5em; margin: 0.1em;",pendingeditModifier:"color: #bbb;",personaBarStyle:"width: 100%; height: 4em; background-color: #eee; vertical-align: middle;",searchInputStyle:"border: 0.1em solid #444; border-radius: 0.2em; width: 100%; font-size: 100%; padding: 0.1em 0.6em; margin 0.2em;",autocompleteRowStyle:"border: 0.2em solid straw;",signInAndUpButtonStyle:"padding: 1em; border-radius:0.2em; font-size: 100%;",headerBannerLoginInput:"margin: 0.75em 0 0.75em 0.5em !important; padding: 0.5em !important;",signUpBackground:"background-color: #eef;",signInBackground:"background-color: #efe;",heading1Style:"font-size: 180%; font-weight: bold; color: #888888; padding: 0.5em; margin: 0.7em 0.0m;",heading2Style:"font-size: 130%; font-weight: bold; color: #888888; padding: 0.4em; margin: 0.7em 0.0em;",heading3Style:"font-size: 120%; font-weight: bold; color: #888888; padding: 0.3em; margin: 0.7em 0.0em;",heading4Style:"font-size: 110%; font-weight: bold; color: #888888; padding: 0.2em; margin: 0.7em 0.0em;",formHeadingStyle:"font-size: 110%; font-weight: bold; color: #888888; padding: 0.2em; margin: 0.7em 0.0em;",formTextInput:"font-size: 100%; margin: 0.1em; padding: 0.1em;",formGroupStyle:[`padding-left: 0em; border: 0.0em solid ${qe}; border-radius: 0.2em;`,`padding-left: 2em; border: 0.05em solid ${qe}; border-radius: 0.2em;`,`padding-left: 2em; border: 0.1em solid ${qe}; border-radius: 0.2em;`,`padding-left: 2em; border: 0.2em solid ${qe}; border-radius: 0.2em;`],formFieldLabelStyle:`color: ${"#3B5998"}; text-decoration: none;`,formFieldNameBoxStyle:`padding: 0.3em; vertical-align: middle; width:${He};`,multilineTextInputStyle:"font-size:100%; white-space: pre-wrap; background-color: #eef; border: 0.07em solid gray; padding: 1em 0.5em; margin: 1em 1em;",renderAsDivStyle:"display: flex; align-items: center; justify-content: space-between; height: 2.5em; padding: 1em;",imageDivStyle:"width:2.5em; padding:0.5em; height: 2.5em;",linkDivStyle:"width:2em; padding:0.5em; height: 4em;",aclControlBoxContainer:"margin: 1em;",aclControlBoxHeader:"font-size: 120%; margin: 0 0 1rem;",aclControlBoxStatus:"display: none; margin: 1rem 0;",aclControlBoxStatusRevealed:"display: block;",aclGroupContent:"maxWidth: 650;",accessGroupList:"display: grid; grid-template-columns: 1fr; margin: 1em; width: 100%;",accessGroupListItem:"display: grid; grid-template-columns: 100px auto 30%;",defaultsController:"display: flex;",defaultsControllerNotice:"color: #888; flexGrow: 1; fontSize: 80%;",bigButton:"background-color: white; border: 0.1em solid #888; border-radius: 0.3em; max-width: 50%; padding-bottom: 1em; padding-top: 1em;",group:"color: #888;",group1:"color: green;",group2:"color: #cc0;",group3:"color: orange;",group5:"color: red;",group9:"color: blue;",group13:"color: purple;",trustedAppAddApplicationsTable:"background-color: #eee;",trustedAppCancelButton:"float: right;",trustedAppControllerI:"border-color: orange; border-radius: 1em; border-width: 0.1em;",temporaryStatusInit:"background: green;",temporaryStatusEnd:"background: transparent; transition: background 5s linear;",headerUserMenuLink:"background: none; border: 0; color: black; cursor: pointer; display: block; font-family: Arial; font-size: 1em; text-align: left; padding: 1em; width: 100%; text-decoration: none;",headerUserMenuLinkHover:"background: none; border: 0; color: black; cursor: pointer; display: block; font-family: Arial; font-size: 1em; text-align: left; padding: 1em; width: 100%; text-decoration: none; background-image: linear-gradient(to right, #7C4DFF 0%, #18A9E6 50%, #01C9EA 100%);",headerUserMenuTrigger:"background: none; border: 0; cursor: pointer; width: 60px; height: 60px;",headerUserMenuTriggerImg:"border-radius: 50%; height: 56px; width: 28px !important;",headerUserMenuButton:"background: none; border: 0; color: black; cursor: pointer; display: block; font-family: Arial; font-size: 1em; text-align: left; padding: 1em; width: 100%;",headerUserMenuButtonHover:"background: none; border: 0; color: black; cursor: pointer; display: block; font-family: Arial; font-size: 1em; text-align: left; padding: 1em; width: 100%; background-image: linear-gradient(to right, #7C4DFF 0%, #18A9E6 50%, #01C9EA 100%);",headerUserMenuList:"list-style: none; margin: 0; padding: 0;",headerUserMenuListDisplay:"list-style: none; margin: 0; padding: 0; display:true;",headerUserMenuNavigationMenu:"background: white; border: solid 1px #000000; border-right: 0; position: absolute; right: 0; top: 60px; width: 200px; z-index: 1; display: true;",headerUserMenuNavigationMenuNotDisplayed:"background: white; border: solid 1px #000000; border-right: 0; position: absolute; right: 0; top: 60px; width: 200px; z-index: 1; display: none;",headerUserMenuListItem:"border-bottom: solid 1px #000000;",headerUserMenuPhoto:"border-radius: 50%; background-position: center; background-repeat: no-repeat; background-size: cover; height: 50px; width: 50px;",headerBanner:"box-shadow: 0px 1px 4px #000000; display: flex; justify-content: space-between; padding: 0 1.5em; margin-bottom: 4px;",headerBannerLink:"display: block;",headerBannerRightMenu:"display: flex;",headerBannerLogin:"margin-left: auto;",allChildrenVisible:"display:true;",headerBannerUserMenu:"border-left: solid 1px #000000; margin-left: auto;",headerBannerHelpMenu:"border-left: solid 1px #000000; margin-left: auto;",headerBannerIcon:"background-size: 65px 60px !important; height: 60px !important; width: 65px !important;",footer:"border-top: solid 1px $divider-color; font-size: 0.9em; padding: 0.5em 1.5em;",primaryButton:"background-color: #7c4dff; color: #ffffff; font-family: Raleway, Roboto, sans-serif; border-radius: 0.25em; border-color: #7c4dff; border: 1px solid; cursor: pointer; font-size: .8em; text-decoration: none; padding: 0.5em 4em; transition: 0.25s all ease-in-out; outline: none;",primaryButtonHover:"background-color: #9f7dff; color: #ffffff; font-family: Raleway, Roboto, sans-serif;border-radius: 0.25em; border-color: #7c4dff; border: 1px solid; cursor: pointer; font-size: .8em; text-decoration: none; padding: 0.5em 4em; transition: 0.25s all ease-in-out; outline: none; transition: 0.25s all ease-in-out;",primaryButtonNoBorder:"background-color: #ffffff; color: #7c4dff; font-family: Raleway, Roboto, sans-serif;border-radius: 0.25em; border-color: #7c4dff; border: 1px solid; cursor: pointer; font-size: .8em; text-decoration: none; padding: 0.5em 4em; transition: 0.25s all ease-in-out; outline: none;",primaryButtonNoBorderHover:"background-color: #7c4dff; color: #ffffff; font-family: Raleway, Roboto, sans-serif; border-radius: 0.25em; border-color: #7c4dff; border: 1px solid; cursor: pointer; font-size: .8em; text-decoration: none; padding: 0.5em 4em; transition: 0.25s all ease-in-out; outline: none; transition: 0.25s all ease-in-out;",secondaryButton:"background-color: #01c9ea; color: #ffffff; font-family: Raleway, Roboto, sans-serif;border-radius: 0.25em; border-color: #01c9ea; border: 1px solid; cursor: pointer; font-size: .8em; text-decoration: none; padding: 0.5em 4em; transition: 0.25s all ease-in-out; outline: none;",secondaryButtonHover:"background-color: #37cde6; color: #ffffff; font-family: Raleway, Roboto, sans-serif;border-radius: 0.25em; border-color: #7c4dff; border: 1px solid; cursor: pointer; font-size: .8em; text-decoration: none; padding: 0.5em 4em; transition: 0.25s all ease-in-out; outline: none; transition: 0.25s all ease-in-out;",secondaryButtonNoBorder:"background-color: #ffffff; color: #01c9ea; font-family: Raleway, Roboto, sans-serif; border-radius: 0.25em; border-color: #01c9ea; border: 1px solid; cursor: pointer; font-size: .8em; text-decoration: none; padding: 0.5em 4em; transition: 0.25s all ease-in-out; outline: none;",secondaryButtonNoBorderHover:"background-color: #01c9ea; color: #ffffff; font-family: Raleway, Roboto, sans-serif; border-radius: 0.25em; border-color: #01c9ea; border: 1px solid; cursor: pointer; font-size: .8em; text-decoration: none; padding: 0.5em 4em; transition: 0.25s all ease-in-out; outline: none; transition: 0.25s all ease-in-out;",controlStyle:`border-radius: 0.5em; margin: 0.8em; width:${"640"}; height:${"480"};`,dragEvent:"background-color: #ccc; border: 0.25em dashed black; border-radius: 0.3em;",dropEvent:"background-color: white; border: 0em solid black;",restoreStyle:"background-color: white;",errorCancelButton:"width: 2em; height: 2em; align: right;",errorMessageBlockStyle:"margin: 0.1em; padding: 0.5em; border: 0.05em solid gray; color:black;",notepadStyle:"padding: 1em; overflow: auto; resize: horizontal; min-width: 40em;",upstreamStatus:"width: 50%;",downstreamStatus:"width: 50%;",baseStyle:"font-size: 100%; font-family: monospace; width: 100%; border: none; white-space: pre-wrap;",headingCore:"font-family: sans-serif; font-weight: bold; border: none;",headingStyle:["font-size: 110%; padding-top: 0.5em; padding-bottom: 0.5em; width: 100%;","font-size: 120%; padding-top: 1em; padding-bottom: 1em; width: 100%;","font-size: 150%; padding-top: 1em; padding-bottom: 1em; width: 100%;"],participantsStyle:"margin: 0.8em;",participantsBlock:"height: 1.5em; width: 1.5em; margin: 0.3em; border 0.01em solid #888;",personTableTD:"vertical-align: middle;",tabsNavElement:"margin: 0;",tabsRootElement:"display: flex; height: 100%; width: 100%;",tabsMainElement:"margin: 0; width:100%; height: 100%;",tabContainer:"list-style-type: none; display: flex; height: 100%; width: 100%; margin: 0; padding: 0;",makeNewSlot:"background: none; border: none; font: inherit; cursor: pointer;",ellipsis:"position: absolute; right: 0; bottom: 0; width: 20%; background: none; color: inherit; border: none; padding: 0; font: inherit; cursor: pointer; outline: inherit;"};function Xe(e,t,n){const i=function(e){return e.split("\n").map(e=>e.trim()).filter(e=>e&&"#"!==e[0])},a=function(e){e.preventDefault(),e.stopPropagation(),e.dataTransfer.dropEffect="copy"},o=function(e){e.preventDefault(),e.stopPropagation(),xe.Rm("dragenter event dropEffect: "+e.dataTransfer.dropEffect),this.localStyle&&(this.savedStyle||(this.savedStyle=Ke.dragEvent)),e.dataTransfer.dropEffect="link",xe.Rm("dragenter event dropEffect 2: "+e.dataTransfer.dropEffect)},s=function(e){e.stopPropagation(),xe.Rm("dragleave event dropEffect: "+e.dataTransfer.dropEffect),this.savedStyle?this.localStyle=this.savedStyle:this.localStyle=Ke.dropEvent},r=function(e){e.preventDefault&&e.preventDefault(),e.stopPropagation&&e.stopPropagation(),xe.Rm("Drop event. dropEffect: "+e.dataTransfer.dropEffect),xe.Rm("Drop event. types: "+(e.dataTransfer.types?e.dataTransfer.types.join(", "):"NOPE"));let a,o=null;if(e.dataTransfer.types){for(let t=0;t<e.dataTransfer.types.length;t++){const s=e.dataTransfer.types[t];if("text/uri-list"===s)o=i(e.dataTransfer.getData(s)),xe.Rm("Dropped text/uri-list: "+o);else if("text/plain"===s)a=e.dataTransfer.getData(s);else if("Files"===s&&n){const t=e.dataTransfer.files;for(let e=0;t[e];e++){const n=t[e];xe.Rm("Filename: "+n.name+", type: "+(n.type||"n/a")+" size: "+n.size+" bytes, last modified: "+(n.lastModifiedDate?n.lastModifiedDate.toLocaleDateString():"n/a"))}n(t)}}const t=a?a.trim():"";null===o&&t&&"http"===t.slice(0,4)&&(o=[t],xe.Rm("Warning: Poor man's drop: using text for URI"))}else o=i(e.dataTransfer.getData("Text")),xe.Rm("WARNING non-standard drop event: "+o[0]);return xe.Rm("Dropped URI list (2): "+o),o&&t(o),this.localStyle=Ke.restoreStyle,!1};!function(e){e||xe.Rm("@@@ addTargetListeners: ele "+e),e.addEventListener("dragover",a),e.addEventListener("dragenter",o),e.addEventListener("dragleave",s),e.addEventListener("drop",r)}(e)}function et(e,t){e.setAttribute("draggable","true"),e.addEventListener("dragstart",function(n){e.style.fontWeight="bold",n.dataTransfer.setData("text/uri-list",t.uri),n.dataTransfer.setData("text/plain",t.uri),n.dataTransfer.setData("text/html",e.outerHTML),xe.Rm("Dragstart: "+e+" -> "+t+"de: "+n.dataTransfer.dropEffect)},!1),e.addEventListener("drag",function(e){e.preventDefault(),e.stopPropagation()},!1),e.addEventListener("dragend",function(n){e.style.fontWeight="normal",xe.Rm("Dragend dropeffect: "+n.dataTransfer.dropEffect),xe.Rm("Dragend: "+e+" -> "+t)},!1)}function tt(e,t,n,i,a){for(let o=0;t[o];o++){const s=t[o];xe.Rm(" dropped: Filename: "+s.name+", type: "+(s.type||"n/a")+" size: "+s.size+" bytes, last modified: "+(s.lastModifiedDate?s.lastModifiedDate.toLocaleDateString():"n/a"));const r=new FileReader;r.onload=function(t){return function(o){const s=o.target.result;let r="";xe.Rm(" File read byteLength : "+s.byteLength);let c=t.type;if(t.type&&""!==t.type){const e=ze.extension(t.type);e&&"false"!==e&&!t.name.endsWith("."+e)&&t.type!==ze.lookup(t.name)&&(r="_."+e)}else if(c=ze.lookup(t.name),!c){const e="Filename needs to have an extension which gives a type we know: "+t.name;throw xe.Rm(e),alert(e),new Error(e)}const l=t.type.startsWith("image/")&&i||n,p=l+(l.endsWith("/")?"":"/")+encodeURIComponent(t.name)+r;e.webOperation("PUT",p,{data:s,contentType:c}).then(e=>{xe.Rm(" Upload: put OK: "+p),a(t,p)},e=>{const t=" Upload: FAIL "+p+", Error: "+e;throw xe.Rm(t),alert(t),new Error(t)})}}(s),r.readAsArrayBuffer(s)}}function nt(e,t,n,i){const a=e.createElement("div"),o=i||t instanceof Error?t:null;return o?(console.error(`errorMessageBlock: ${o} at: ${o.stack||"??"}`,o),a.textContent=o.message):a.textContent=t,a.appendChild(Ot(e,()=>{a.parentNode&&a.parentNode.removeChild(a)})).style=Ke.errorCancelButton,a.setAttribute("style",Ke.errorMessageBlockStyle),a.style.backgroundColor=n||Qe,a}Ke.setStyle=function(e,t){e.style=Ke[t]};var it=n(378);const at=v.solidLogicSingleton.store;class ot{constructor(e,t,n,i){this.options=i||{},this.element=e,this.typeIndex=t,this.groupPickedCb=n,this.selectedgroup=this.options.selectedgroup,this.onSelectGroup=this.onSelectGroup.bind(this)}render(){const e=document.createElement("div");if(e.style.maxWidth="350px",e.style.minHeight="200px",e.style.outline="1px solid black",e.style.display="flex",this.selectedgroup){e.style.flexDirection="column";const t=document.createElement("div");new rt(t,this.selectedgroup).render();const n=document.createElement("button");n.textContent=Oe()("Change group"),n.addEventListener("click",e=>{this.selectedgroup=null,this.render()}),e.appendChild(t),e.appendChild(n)}else this.findAddressBook(this.typeIndex).then(({book:t})=>{const n=document.createElement("button");n.textContent=Oe()("Pick an existing group"),n.style.margin="auto",n.addEventListener("click",n=>{new st(e,t,this.onSelectGroup).render()});const i=document.createElement("button");i.textContent=Oe()("Create a new group"),i.style.margin="auto",i.addEventListener("click",e=>{this.createNewGroup(t,this.options.defaultNewGroupName).then(({group:e})=>{new ct(this.element,t,e,this.onSelectGroup).render()}).catch(e=>{this.element.appendChild(nt(document,Oe()(`Error creating a new group. (${e})`)))})}),e.appendChild(n),e.appendChild(i),this.element.innerHTML="",this.element.appendChild(e)}).catch(e=>{this.element.appendChild(nt(document,Oe()(`Could find your groups. (${e})`)))});return this.element.innerHTML="",this.element.appendChild(e),this}findAddressBook(e){return new Promise((t,n)=>{at.fetcher.nowOrWhenFetched(e,(i,a)=>{if(!i)return n(a);const o=at.any(null,b.solid("forClass"),b.vcard("AddressBook"));if(!o)return n(new Error("no address book registered in the solid type index "+e));const s=at.any(o,b.solid("instance"));if(!s)return n(new Error("incomplete address book registration"));at.fetcher.load(s).then(function(e){return t({book:s})}).catch(function(e){return n(new Error("Could not load address book "+e))})})})}createNewGroup(e,t){const{groupIndex:n,groupContainer:i}=dt(e),a=g.sym(`${i.uri}${Pe().slice(0,8)}.ttl#this`),o=t||"Untitled Group",s=[a.doc(),n].map(t=>{const i=g.st(a,b.rdf("type"),b.vcard("Group"),t),s=g.st(a,b.vcard("fn"),o,a.doc(),t),r=g.st(e,b.vcard("includesGroup"),a,t),c=t.equals(n)?[i,s,r]:[i,s];return ut(t.uri,{toIns:c}).then(()=>{c.forEach(e=>{at.add(e)})})});return Promise.all(s).then(()=>({group:a})).catch(e=>{throw xe.Rm("Could not create new group. PATCH failed "+e),new Error(`Couldn't create new group. PATCH failed for (${e.xhr?e.xhr.responseURL:""} )`)})}onSelectGroup(e){this.selectedgroup=e,this.groupPickedCb(e),this.render()}}class st{constructor(e,t,n){this.element=e,this.book=t,this.onSelectGroup=n}render(){return this.loadGroups().then(e=>{const t=document.createElement("div");t.style.display="flex",t.style.flexDirection="column",e.forEach(e=>{const n=document.createElement("button");n.addEventListener("click",this.handleClickGroup(e)),new rt(n,e).render(),t.appendChild(n)}),this.element.innerHTML="",this.element.appendChild(t)}).catch(e=>{this.element.appendChild(nt(document,Oe()(`There was an error loading your groups. (${e})`)))}),this}loadGroups(){return new Promise((e,t)=>{const{groupIndex:n}=dt(this.book);at.fetcher.nowOrWhenFetched(n,(n,i)=>{if(!n)return t(i);const a=at.each(this.book,b.vcard("includesGroup"));return e(a)})})}handleClickGroup(e){return t=>{this.onSelectGroup(e)}}}class rt{constructor(e,t){this.element=e,this.group=t}render(){const e=document.createElement("div");return e.textContent=Oe()(pt(this.group,b.vcard("fn"),`[${this.group.value}]`)),this.element.innerHTML="",this.element.appendChild(e),this}}class ct{constructor(e,t,n,i,a){this.element=e,this.book=t,this.group=n,this.onGroupChanged=(e,t,n)=>{a&&a(e,t,n)},this.groupChangedCb=a,this.doneBuildingCb=i}refresh(){}render(){const e=document.createElement("div");e.style.maxWidth="350px",e.style.minHeight="200px",e.style.outline="1px solid black",e.style.display="flex",e.style.flexDirection="column",Xe(e,e=>{e.forEach(e=>{this.add(e).catch(e=>{this.element.appendChild(nt(document,Oe()(`Could not add the given WebId. (${e})`)))})})});const t=document.createElement("input");t.type="text",t.value=pt(this.group,b.vcard("fn"),"Untitled Group"),t.addEventListener("change",e=>{this.setGroupName(e.target.value).catch(e=>{this.element.appendChild(nt(document,`Error changing group name. (${e})`))})});const n=document.createElement("label");if(n.textContent=Oe()("Group Name:"),n.appendChild(t),e.appendChild(n),at.any(this.group,b.vcard("hasMember")))at.match(this.group,b.vcard("hasMember")).forEach(t=>{const n=t.object,i=document.createElement("div");new lt(i,n,this.handleRemove(n)).render(),e.appendChild(i)});else{const t=document.createElement("p");t.textContent=Oe()`
2
2
  To add someone to this group, drag and drop their WebID URL onto the box.
3
- `,e.appendChild(t)}const i=document.createElement("button");return i.textContent=Oe()("Done"),i.addEventListener("click",e=>{this.doneBuildingCb(this.group)}),e.appendChild(i),this.element.innerHTML="",this.element.appendChild(e),this}add(e){return new Promise((t,n)=>{rt.fetcher.nowOrWhenFetched(e,(i,a)=>{if(!i)return this.onGroupChanged(a),n(a);const o=g.namedNode(e),s=rt.any(o,b.rdf("type"));return s&&s.equals(b.foaf("Person"))?t(o):n(new Error(`Only people supported right now. (tried to add something of type ${s.value})`))})}).then(e=>{const t=g.st(this.group,b.vcard("hasMember"),e);return rt.holdsStatement(t)?e:ft(this.group.doc().uri,{toIns:[t]}).then(()=>{t.why=this.group.doc(),rt.add(t),this.onGroupChanged(null,"added",e),this.render()})})}handleRemove(e){return t=>{const n=g.st(this.group,b.vcard("hasMember"),e);return ft(this.group.doc().uri,{toDel:[n]}).then(()=>(rt.remove(n),this.onGroupChanged(null,"removed",e),this.render(),!0)).catch(t=>{const n=rt.any(e,b.foaf("name")),i=n&&n.value?`Could not remove ${n.value}. (${t})`:`Could not remove ${e.value}. (${t})`;throw new Error(i)})}}setGroupName(e){const{groupIndex:t}=ht(this.book),n=[this.group.doc(),t].map(t=>{const n=rt.match(this.group,b.vcard("fn"),null,t),i=g.st(this.group,b.vcard("fn"),g.literal(e));return ft(t.value,{toDel:n,toIns:[i]}).then(e=>{rt.removeStatements(n),i.why=t,rt.add(i)})});return Promise.all(n)}}class dt{constructor(e,t,n){this.webIdNode=t,this.element=e,this.handleRemove=n}render(){const e=document.createElement("div");e.style.display="flex";const t=mt(this.webIdNode,b.foaf("img"),st.LN+"noun_15059.svg"),n=document.createElement("img");n.src=Oe()(t),n.width="50",n.height="50",n.style.margin="5px";const i=mt(this.webIdNode,b.foaf("name"),`[${this.webIdNode}]`),a=document.createElement("span");a.innerHTML=Oe()(i),a.style.flexGrow="1",a.style.margin="auto 0";const o=document.createElement("button");return o.textContent="Remove",o.addEventListener("click",e=>this.handleRemove().catch(e=>{this.element.appendChild(ot(document,Oe()(`${e}`)))})),o.style.margin="5px",e.appendChild(n),e.appendChild(a),e.appendChild(o),this.element.innerHTML="",this.element.appendChild(e),this}}function mt(e,t,n){const i=rt.any(e,t);return i?i.value:n}function ft(e,{toDel:t,toIns:n}){return new Promise((e,i)=>{rt.updater.update(t,n,(t,n,a)=>{if(!n)return i(new Error(`PATCH failed for resource <${t}>: ${a}`));e()})})}function ht(e){return{groupIndex:rt.any(e,b.vcard("groupIndex")),groupContainer:rt.sym(e.dir().uri+"Group/")}}const gt="data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMjAiIGhlaWdodD0iMjAiIHZpZXdCb3g9IjAgMCAyMCAyMCIgZmlsbD0ibm9uZSIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj4KPHBhdGggZD0iTTEzLjAxNTcgOS4yNzM2M0MxNC4yOTU0IDguMzQwMzEgMTUuMTI4OCA2LjgyOTg0IDE1LjEyODggNS4xMjgyQzE1LjEyODggMi4zMDA1MSAxMi44MjgzIDAgMTAuMDAwNiAwQzcuMTcyODkgMCA0Ljg3MjM4IDIuMzAwNTEgNC44NzIzOCA1LjEyODJDNC44NzIzOCA2LjgyOTg0IDUuNzA1NyA4LjM0MDMxIDYuOTg1NDcgOS4yNzM2M0MzLjgwNDIyIDEwLjQ5MSAxLjUzOTA2IDEzLjU3NTQgMS41MzkwNiAxNy4xNzk1QzEuNTM5MDYgMTguNzM0NyAyLjgwNDM0IDIwIDQuMzU5NTcgMjBIMTUuNjQxNkMxNy4xOTY4IDIwIDE4LjQ2MjEgMTguNzM0NyAxOC40NjIxIDE3LjE3OTVDMTguNDYyMSAxMy41NzU0IDE2LjE5NyAxMC40OTEgMTMuMDE1NyA5LjI3MzYzWk02LjQxMDg2IDUuMTI4MkM2LjQxMDg2IDMuMTQ4ODMgOC4wMjEyMSAxLjUzODQ4IDEwLjAwMDYgMS41Mzg0OEMxMS45OCAxLjUzODQ4IDEzLjU5MDMgMy4xNDg4MyAxMy41OTAzIDUuMTI4MkMxMy41OTAzIDcuMTA3NTggMTEuOTggOC43MTc5NyAxMC4wMDA2IDguNzE3OTdDOC4wMjEyMSA4LjcxNzk3IDYuNDEwODYgNy4xMDc1OCA2LjQxMDg2IDUuMTI4MlpNMTUuNjQxNiAxOC40NjE1SDQuMzU5NTdDMy42NTI2NiAxOC40NjE1IDMuMDc3NTQgMTcuODg2NCAzLjA3NzU0IDE3LjE3OTVDMy4wNzc1NCAxMy4zNjIgNi4xODMxNiAxMC4yNTY0IDEwLjAwMDYgMTAuMjU2NEMxMy44MTgxIDEwLjI1NjQgMTYuOTIzNyAxMy4zNjIgMTYuOTIzNyAxNy4xNzk1QzE2LjkyMzcgMTcuODg2NCAxNi4zNDg2IDE4LjQ2MTUgMTUuNjQxNiAxOC40NjE1WiIgZmlsbD0iIzMxNDE1OCIvPgo8L3N2Zz4K";function bt(e,t,n){const i=e.createElement("a");i.setAttribute("href",t.uri),t.uri.startsWith("http")&&i.setAttribute("target","_blank");const a=i.appendChild(e.createElement("img"));return a.setAttribute("src",n||st.i1+"go-to-this.png"),a.setAttribute("style","margin: 0.3em;"),i}const vt=(e,t,n)=>{const i=bt(e,n);t.appendChild(i).classList.add("HoverControlHide"),t.appendChild(e.createElement("br"))},{iconBase:xt}=st.Pt,yt=xt+"noun_1180156.svg",wt=xt+"noun_1180158.svg";function Ct(e,t){if(!t)return;const n=function(e){let t=e&&e.statusArea||e&&e.div||null;if(t)return t;let n=e&&e.dom;if(n||"undefined"==typeof document||(n=document),n){const i=n.getElementsByTagName("body")[0];return t=n.createElement("div"),i.insertBefore(t,i.firstElementChild),e&&(e.statusArea=t),t}return null}(e);xe.Rm("Complaint: "+t),n?n.appendChild(ot(e&&e.dom||document,t)):alert(t)}function Et(e){for(;e.firstChild;)e.removeChild(e.firstChild);return e}function kt(e){const t=e.search(/logFile=/),n=e.search(/&rulesFile=/);return e.substring(t+8,n)}function At(e,t){if(!e)return"???";const n=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];try{const i=(new Date).toISOString();return e.slice(0,10)!==i.slice(0,10)||t?e.slice(0,4)===i.slice(0,4)?n[parseInt(e.slice(5,7),10)-1]+" "+parseInt(e.slice(8,10),10):e.slice(0,10):e.slice(11,16)}catch(e){return"shortdate:"+e}}function _t(e,t){return t.split("{").map(function(t){const n=t.split("}")[0];return t?("000"+(e["get"+n]()+({Month:1}[n]||0))).slice(-({Milliseconds:3,FullYear:4}[n]||2))+t.split("}")[1]:""}).join("")}function Tt(){return _t(new Date,"{FullYear}-{Month}-{Date}T{Hours}:{Minutes}:{Seconds}.{Milliseconds}")}function St(){return _t(new Date,"{Hours}:{Minutes}:{Seconds}.{Milliseconds}")}function jt(e,t){const n=v.store,i=function(e){const t=n.any(e,b.vcard("fn"))||n.any(e,b.foaf("name"))||n.any(e,b.vcard("organization-name"));return t?t.value:null},a=t.sameTerm(b.foaf("Agent"))?"Everyone":i(t);if(e.textContent=a||F(t),!a&&t.uri){if(!n.fetcher)throw new Error("kb has no fetcher");n.fetcher.nowOrWhenFetched(t.doc(),void 0,function(n){e.textContent=i(t)||F(t)})}}function Lt(e,t){return t.each(e,b.sioc("avatar")).concat(t.each(e,b.foaf("img"))).concat(t.each(e,b.vcard("logo"))).concat(t.each(e,b.vcard("hasPhoto"))).concat(t.each(e,b.vcard("photo"))).concat(t.each(e,b.foaf("depiction")))}const Rt={"solid:AppProviderClass":"noun_144.svg","solid:AppProvider":"noun_15177.svg","solid:Pod":"noun_Cabinet_1434380.svg","vcard:Group":"noun_339237.svg","vcard:Organization":"noun_143899.svg","vcard:Individual":gt,"schema:Person":gt,"foaf:Person":gt,"foaf:Agent":"noun_98053.svg","acl:AuthenticatedAgent":"noun_99101.svg","prov:SoftwareAgent":"noun_Robot_849764.svg","vcard:AddressBook":"noun_15695.svg","trip:Trip":"noun_581629.svg","meeting:LongChat":"noun_1689339.svg","meeting:Meeting":"noun_66617.svg","meeting:Project":"noun_1036577.svg","ui:Form":"noun_122196.svg","rdfs:Class":"class-rectangle.svg","rdf:Property":"property-diamond.svg","owl:Ontology":"noun_classification_1479198.svg","wf:Tracker":"noun_122196.svg","wf:Task":"noun_17020_gray-tick.svg","wf:Open":"noun_17020_sans-tick.svg","wf:Closed":"noun_17020.svg"};function Nt(e){const t=e.uri.split("#")[0],n=t.indexOf("//");if(n<0)throw new Error("This URI does not have a web site part (origin)");const i=t.indexOf("/",n+2);return i<0?t.slice(0)+"/":t.slice(0,i+1)}function It(e){const t=xt;return"string"!=typeof e&&e.uri?4!==e.uri.split("/").length||e.uri.split("/")[1]||e.uri.split("/")[3]?e.uri.startsWith("message:")||e.uri.startsWith("mid:")?t+"noun_480183.svg":e.uri.startsWith("mailto:")?t+"noun_567486.svg":e.uri.startsWith("https:")&&e.uri.indexOf("#")<0?Nt(e)+"favicon.ico":null:t+"noun_15177.svg":t+"noun_10636_grey.svg"}function $t(e){const t=v.store,n=xt;if(e.sameTerm(b.foaf("Agent"))||e.sameTerm(b.rdf("Resource")))return n+"noun_98053.svg";const i=t.any(e,b.sioc("avatar"))||t.any(e,b.foaf("img"))||t.any(e,b.vcard("logo"))||t.any(e,b.vcard("hasPhoto"))||t.any(e,b.vcard("photo"))||t.any(e,b.foaf("depiction"));return i?i.uri:null}function Bt(e,t,n){const i=v.store,a=$t(t);if(a)return e.setAttribute("src",a),!0;const o=n[t.uri];if(o)return e.setAttribute("src",o),e.style=tt.classIconStyle,!0;const s=It(t);if(s)return e.setAttribute("src",s),!0;const r=i.findTypeURIs(t);for(const t in r)if(n[t])return e.setAttribute("src",n[t]),!1;return e.setAttribute("src",xt+"noun_10636_grey.svg"),!1}function Dt(e,t){const n=v.store,i={};for(const e in Rt){const t=e.split(":")[0],n=e.split(":")[1],a=b[t](n),o=Rt[e];o.startsWith("data:")?i[a.uri]=o:i[a.uri]=g.uri.join(o,xt)}if(!Bt(e,t,i)&&t.uri){if(!n.fetcher)throw new Error("kb has no fetcher");n.fetcher.nowOrWhenFetched(t.doc(),void 0,n=>{n&&Bt(e,t,i)})}}function Ot(e,t){const n=e.createElement("img");n.style=tt.iconStyle;if(n.setAttribute("src",xt+(function(e){if(!e.uri)return!1;const t=e.uri.split("/");return 3===t.length||4===t.length&&""===t[3]}(t)?"noun_15177.svg":"noun_681601.svg")),t.uri&&t.uri.startsWith("https:")&&t.uri.indexOf("#")<0){const i=e.createElement("object");return i.setAttribute("data",Nt(t)+"favicon.ico"),i.setAttribute("type","image/x-icon"),i.appendChild(n),i}return Dt(n,t),n}function Mt(e,t,n,i){const a=xt+"noun_2188_red.svg",o=e.createElement("img");o.setAttribute("src",a),o.setAttribute("style",tt.smallButtonStyle),o.style.float="right";const s="Remove this "+n;return o.title=s,o.classList.add("hoverControlHide"),o.addEventListener("click",function(){const n=e.createElement("div");t.insertBefore(n,o),n.style.position="relative",n.appendChild(function(e,t,n,i){function a(){t.parentElement.removeChild(t)}function o(){a(),i()}const s=e.createElement("div");s.style=tt.confirmPopupStyle,s.style.position="absolute",s.style.top="-1em",s.style.display="grid",s.style.gridTemplateColumns="auto auto";const r=e.createElement("div");r.style.gridColumn="1/2",r.style.gridRow="1";const c=e.createElement("div");c.style.gridColumn="1/2",c.style.gridRow="2";const l=Ft(e,a);s.appendChild(l),l.style.gridColumn="1",l.style.gridRow="2";const p=s.appendChild(e.createElement("button"));p.style=tt.buttonStyle,p.style.gridRow="2",p.style.gridColumn="2",p.textContent="Cancel";const u=Ut(e,st.Pt.iconBase+"noun_925021.svg","Delete it");s.appendChild(u),u.style.gridRow="1",u.style.gridColumn="1";const d=s.appendChild(e.createElement("button"));return d.style=tt.buttonStyle,d.style.gridRow="1",d.style.gridColumn="2",d.textContent=n,s.appendChild(d),u.addEventListener("click",o),d.addEventListener("click",o),p.addEventListener("click",a),s}(e,n,s,i))}),t.classList.add("hoverControl"),t.appendChild(o),o.setAttribute("data-testid","deleteButtonWithCheck"),o}function Ut(e,t,n,i,a={buttonColor:"Primary",needsBorder:!1}){const o=e.createElement("button");if(o.setAttribute("type","button"),t){const i=o.appendChild(e.createElement("img"));i.setAttribute("src",t),i.setAttribute("style","width: 2em; height: 2em;"),i.title=n,o.setAttribute("style",tt.buttonStyle)}else o.textContent=n.toLocaleUpperCase(),o.onmouseover=function(){"Secondary"===a.buttonColor?a.needsBorder?o.setAttribute("style",tt.secondaryButtonNoBorderHover):o.setAttribute("style",tt.secondaryButtonHover):a.needsBorder?o.setAttribute("style",tt.primaryButtonNoBorderHover):o.setAttribute("style",tt.primaryButtonHover)},o.onmouseout=function(){"Secondary"===a.buttonColor?a.needsBorder?o.setAttribute("style",tt.secondaryButtonNoBorder):o.setAttribute("style",tt.secondaryButton):a.needsBorder?o.setAttribute("style",tt.primaryButtonNoBorder):o.setAttribute("style",tt.primaryButton)},"Secondary"===a.buttonColor?a.needsBorder?o.setAttribute("style",tt.secondaryButtonNoBorder):o.setAttribute("style",tt.secondaryButton):a.needsBorder?o.setAttribute("style",tt.primaryButtonNoBorder):o.setAttribute("style",tt.primaryButton);return i&&o.addEventListener("click",i,!1),o}function Ft(e,t){const n=Ut(e,yt,"Cancel",t);return n.firstChild&&(n.firstChild.style.opacity="0.3"),n}function Pt(e,t){return Ut(e,wt,"Continue",t)}function zt(e,t,n,i,a,o){return new Promise(function(t,s){const r=e.createElement("div");i=i||b.foaf("name");const c=(o=o||(a?F(a):" "))+" "+F(i)+": ";r.appendChild(e.createElement("p")).textContent=c;const l=e.createElement("input");function p(){r.parentNode.removeChild(r),t(l.value.trim())}l.setAttribute("type","text"),l.setAttribute("size","100"),l.setAttribute("maxLength","2048"),l.setAttribute("style",tt.textInputStyle),l.select(),r.appendChild(l),n.appendChild(r),l.addEventListener("keyup",function(e){13===e.keyCode&&p()},!1),r.appendChild(e.createElement("br")),r.appendChild(Ft(e,function(e){r.parentNode.removeChild(r),t(null)})),r.appendChild(Pt(e,function(e){p()})),l.focus()})}const qt=Ht;function Ht(e,t,n,i){const a=e.createElement("tr");i=i||{};const o=a.appendChild(e.createElement("td")),s=a.appendChild(e.createElement("td")),r=a.appendChild(e.createElement("td")),c=i.image||Ot(e,n);o.setAttribute("style","vertical-align: middle; width:2.5em; padding:0.5em; height: 2.5em;"),s.setAttribute("style","vertical-align: middle; text-align:left;"),r.setAttribute("style","vertical-align: middle; width:2em; padding:0.5em; height: 4em;"),o.appendChild(c);const l=s.appendChild(e.createElement("div")),p=l.appendChild(e.createElement("span"));if(i.title?p.textContent=i.title:jt(p,n),"function"==typeof i.renderNameSuffix){const t=i.renderNameSuffix(n,e);if(t){const n=l.appendChild(e.createElement("span"));n.setAttribute("style","margin-left: 0.4em; opacity: 0.8;"),"string"==typeof t?n.textContent=t:n.appendChild(t)}}if("function"==typeof i.renderSupportingInfo){const t=i.renderSupportingInfo(n,e);if(t){const n=s.appendChild(e.createElement("div"));n.setAttribute("style","font-size: 90%; opacity: 0.8;"),"string"==typeof t?n.textContent=t:n.appendChild(t)}}if(i.deleteFunction&&Mt(e,r,i.noun||"one",i.deleteFunction),n.uri){if(!1!==i.link){r.appendChild(bt(e,n)).classList.add("HoverControlHide"),r.appendChild(e.createElement("br"))}!1!==i.draggable&&(c.setAttribute("draggable","false"),it(a,n))}return a.subject=n,a}function Vt(e,t,n,i){const a=t.appendChild(e.createElement("div"));n?a.textContent=n:jt(a,i)}function Gt(e,t,n,i){const a=t.appendChild(e.createElement("div"));a.setAttribute("style",tt.linkDivStyle),i.deleteFunction&&Mt(e,a,i.noun||"one",i.deleteFunction),n.uri&&(!1!==i.link&&vt(e,a,n),it(t,n))}function Wt(e,t,n){const i=e.createElement("div");i.setAttribute("style",tt.renderAsDivStyle);if(((e,t,n)=>{const i=t.appendChild(e.createElement("div"));i.setAttribute("style",tt.imageDivStyle),i.appendChild(n),n.setAttribute("draggable","false")})(e,i,(n=n||{}).image||Ot(e,t)),Vt(e,i,n.title,t),Gt(e,i,t,n),n.clickable&&n.onClickFunction&&((e,t)=>{e.addEventListener("click",t)})(i,n.onClickFunction),n.wrapInATR){const n=((e,t,n)=>{const i=e.createElement("tr");return i.appendChild(e.createElement("td")).appendChild(t),i.subject=n,i})(e,i,t);return n}return i}function Jt(e){if(e.refresh)e.refresh();else for(let t=0;t<e.children.length;t++)Jt(e.children[t])}function Qt(e,t,n,i={}){const a=new Set,o=!(!i.renderSupportingInfo&&!i.renderNameSuffix);function s(n){const s=n,c={noun:f};if(c.renderSupportingInfo=i.renderSupportingInfo,c.renderNameSuffix=i.renderNameSuffix,o&&n?.uri&&h.fetcher){const e=n.doc(),t=e?.uri?h.fetcher.requested?.[e.uri]:void 0,i="done"!==t&&"failed"!==t;e?.uri&&i&&!a.has(e.uri)&&(a.add(e.uri),h.fetcher.nowOrWhenFetched(e,void 0,()=>{a.delete(e.uri),r()}))}return u&&(c.deleteFunction=function(){!function(e){if(!h.updater)throw new Error("kb has no updater");h.updater.update((0,g.st)(t,m,e,p),[],function(e,t,n,i){t?r():Ct(void 0,"Error deleting one: "+n)})}(s)}),qt(e,m,n,c)}const r=function(){const e=h.each(t,m);e.sort(),Z(C,e,s,o?function(e,t){return s(t)}:void 0)};function c(e){const n=[];if(e.forEach(function(e){const i=(0,g.sym)(e);xe.Rm("Dropped on attachemnt "+e),n.push((0,g.st)(t,m,i,p))}),!h.updater)throw new Error("kb has no updater");h.updater.update([],n,function(e,t,n,i){t?r():Ct(void 0,"Error adding one: "+n)})}function l(e){at(h.fetcher,e,i.uploadFolder?.uri,i.uploadFolder?.uri,function(e,n){const i=[(0,g.st)(t,m,h.sym(n),p)];if(!h.updater)throw new Error("kb has no updater");h.updater.update([],i,function(e,t,n,i){t?r():Ct(void 0,"Error adding link to uploaded file: "+n)})})}const p=i.doc||t.doc();void 0===i.modify&&(i.modify=!0);const u=i.modify,d=i.promptIcon||xt+"noun_748003.svg",m=i.predicate||b.wf("attachment"),f=i.noun||"attachment",h=v.store,x=n.appendChild(e.createElement("table"));x.setAttribute("style","margin-top: 1em; margin-bottom: 1em;");const y=x.appendChild(e.createElement("tr")),w=y.appendChild(e.createElement("td")),C=y.appendChild(e.createElement("td")).appendChild(e.createElement("table"));if(C.appendChild(e.createElement("tr")),x.refresh=r,r(),u){const t=Ut(e,d,"Drop attachments here");w.appendChild(t);const n=i.uploadFolder?l:null;if(nt(t,c,n),nt(w,c,n),i.uploadFolder){const t=pn(e,l);w.appendChild(t)}}return x}function Zt(e){e.preventDefault(),e.stopPropagation();const t=ee(e).getAttribute("href");if(!t)return xe.Rm("openHrefInOutlineMode: No href found!\n");const n=window.document;n.outlineManager?n.outlineManager.GotoSubject(v.store.sym(t),!0,void 0,!0,void 0):window&&window.panes&&window.panes.getOutliner?window.panes.getOutliner().GotoSubject(v.store.sym(t),!0,void 0,!0,void 0):xe.Rm("ERROR: Can't access outline manager in this config")}function Yt(e){if(void 0===e.uri)return;let t=e.uri;if("http://"!==t.slice(0,7))return;t=t.slice(7);const n=t.indexOf("#");if(n>=0)t=t.slice(0,n);else{const e=t.lastIndexOf("/");if(e<0)return;t=t.slice(0,e)}return v.store.sym("http://tabulator.org/wiki/annnotation/"+t)}function Kt(){const e={};return v.store.statementsMatching(void 0,b.rdf("type"),void 0).forEach(function(t){t.object.value&&(e[t.object.value]=!0)}),v.store.statementsMatching(void 0,b.rdfs("subClassOf"),void 0).forEach(function(t){t.object.value&&(e[t.object.value]=!0),t.subject.value&&(e[t.subject.value]=!0)}),v.store.each(void 0,b.rdf("type"),b.rdfs("Class")).forEach(function(t){t.value&&(e[t.value]=!0)}),e}function Xt(e){const t={},n={},i={};let a=0,o=0,s=0;const r=e.predicateIndex;for(const e in r){"Literal"===r[e][0].object.termType?(n[e]=!0,o++):(i[e]=!0,a++)}const c=e.each(void 0,b.rdf("type"),b.rdf("Property"));for(let e=0;e<c.length;e++){const t=c[e].toNT();i[t]||n[t]||(n[t]=!0,i[t]=!0,s++)}return t.op=i,t.dp=n,S(`propertyTriage: ${a} non-lit, ${o} literal. ${s} unknown.`),t}function en(e,t){const n=e.createElement("button");return n.setAttribute("type","button"),n.textContent="Goto "+F(t),n.addEventListener("click",function(n){e.outlineManager.GotoSubject(t,!0,void 0,!0,void 0)},!0),n}function tn(e,t){const n=e.createElement("button");return n.setAttribute("type","button"),n.textContent="✕",n.addEventListener("click",function(e){t.parentNode.removeChild(t)},!0),n}function nn(e,t,n,i,a,o,s,r,c){return an(e.createElement("div"),e,t,n,i,a,o,s,r,c)}function an(e,t,n,i,a,o,s,r,c,l){const p="border: 0.1em solid #ddd; border-bottom: none; width: 95%; height: 2em; padding: 0.5em;";let u=null;e.innerHTML="";const d=function(e,s){let d,m;const f=function(){const e=o?n.each(void 0,a,s):n.each(s,a);v.setAttribute("class",0===e.length?"hideTillHover":""),m.setAttribute("src",r.connectIcon||xt+"noun_25830.svg"),m.setAttribute("title",e.length?e.length:"attach")},h=on.twoLine.widgetForClass(i);d=h(t,s),d.setAttribute("style",p);const g=t.createElement("div");g.setAttribute("class","hideTillHover"),g.setAttribute("style","float:right; width:10%");const b=t.createElement("a");b.setAttribute("href",s.uri),b.setAttribute("style","float:right"),g.appendChild(b).textContent=">",e.appendChild(g);const v=t.createElement("div");return v.setAttribute("style",(o?"float:left;":"float:right;")+" width:30px;"),m=t.createElement("img"),f(),v.appendChild(m),e.appendChild(v),d.addEventListener("click",function(e){u===d?(d.setAttribute("style",p),u=null):(u&&u.setAttribute("style",p),d.setAttribute("style",p+"background-color: #ccc; color:black;"),u=d),c(s,e,u===d),f()},!1),m.addEventListener("click",function(e){l(s,e,o,f)},!1),e.appendChild(d),e};for(let n=0;n<s.length;n++){const i=t.createElement("div");e.appendChild(i),d(i,s[n])}return e}let on={};function sn(e,t){const n=e.querySelectorAll("link");for(let e=0;e<n.length;e++)if("stylesheet"===(n[e].getAttribute("rel")||"")&&(n[e].getAttribute("href")||"")===t)return;const i=e.createElement("link");i.setAttribute("rel","stylesheet"),i.setAttribute("type","text/css"),i.setAttribute("href",t),e.getElementsByTagName("head")[0].appendChild(i)}function rn(e){return ln(e,"audio")}function cn(e){return ln(e,"video")}function ln(e,t){const n=t||"image",i=v.store.findTypeURIs(e),a=g.Util.mediaTypeClass(n+"/*").uri.split("*")[0];for(const e in i)if(e.startsWith(a))return!0;return{audio:"http://purl.org/dc/dcmitype/Sound",image:"http://purl.org/dc/dcmitype/Image",video:"http://purl.org/dc/dcmitype/MovingImage"}[n]in i}function pn(e,t){const n=e.createElement("div"),i=n.appendChild(e.createElement("input"));i.setAttribute("type","file"),i.setAttribute("multiple","true"),i.addEventListener("change",e=>{xe.Rm("File drop event: ",e),e.files?t(e.files):e.target&&e.target.files?t(e.target.files):alert("Sorry no files .. internal error?")},!1),i.style="display:none";return nt(n.appendChild(Ut(e,xt+"noun_Upload_76574_000000.svg","Upload files",e=>{i.click()})),null,t),n}on={line:{},twoLine:{"":function(e,t){const n=e.createElement("div");return n.textContent=F(t),n},"http://www.w3.org/2000/10/swap/pim/qif#Transaction":function(e,t){let n="";const i=function(e){const i=v.store.any(t,b.qu(e));return i||(n+="@@ No value for "+e+"! "),i?de(i.value):"?"},a=e.createElement("table");return a.innerHTML=`\n <tr>\n <td colspan="2"> ${i("payee")}</td>\n < /tr>\n < tr >\n <td>${i("date").slice(0,10)}</td>\n <td style = "text-align: right;">${i("amount")}</td>\n </tr>`,n&&(a.innerHTML=`\n <tr>\n <td><a href="${de(t.uri)}">${de(n)}</a></td>\n </tr>`),a},"http://www.w3.org/ns/pim/trip#Trip":function(e,t){const n=function(e){const n=v.store.any(t,e);return n?de(n.value):"?"},i=e.createElement("table");return i.innerHTML=`\n <tr>\n <td colspan="2">${n(b.dc("title"))}</td>\n </tr>\n <tr style="color: #777">\n <td>${n(b.cal("dtstart"))}</td>\n <td>${n(b.cal("dtend"))}</td>\n </tr>`,i},widgetForClass:function(e){let t=on.twoLine[e.uri];const n=v.store;if(t)return t;const i=n.findSuperClassesNT(e);for(const e in i)if(t=on.twoLine[n.fromNT(e).uri],t)return t;return on.twoLine[""]}}};const un={[b.ui("ColorField").uri]:{size:9,type:"color",style:"height: 3em;",dt:"color",pattern:/^\s*#[0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f]([0-9a-f][0-9a-f])?\s*$/},[b.ui("DateField").uri]:{size:20,type:"date",dt:"date",pattern:/^\s*[0-9][0-9][0-9][0-9](-[0-1]?[0-9]-[0-3]?[0-9])?Z?\s*$/},[b.ui("DateTimeField").uri]:{size:20,type:"datetime-local",dt:"dateTime",pattern:/^\s*[0-9][0-9][0-9][0-9](-[0-1]?[0-9]-[0-3]?[0-9])?(T[0-2][0-9]:[0-5][0-9](:[0-5][0-9])?)?Z?\s*$/},[b.ui("TimeField").uri]:{size:10,type:"time",dt:"time",pattern:/^\s*([0-2]?[0-9]:[0-5][0-9](:[0-5][0-9])?)\s*$/},[b.ui("IntegerField").uri]:{size:12,style:"text-align: right;",dt:"integer",pattern:/^\s*-?[0-9]+\s*$/},[b.ui("DecimalField").uri]:{size:12,style:"text-align: right;",dt:"decimal",pattern:/^\s*-?[0-9]*(\.[0-9]*)?\s*$/},[b.ui("FloatField").uri]:{size:12,style:"text-align: right;",dt:"float",pattern:/^\s*-?[0-9]*(\.[0-9]*)?((e|E)-?[0-9]*)?\s*$/},[b.ui("SingleLineTextField").uri]:{},[b.ui("NamedNodeURIField").uri]:{namedNode:!0},[b.ui("TextField").uri]:{},[b.ui("PhoneField").uri]:{size:20,uriPrefix:"tel:",pattern:/^\+?[\d-]+[\d]*$/},[b.ui("EmailField").uri]:{size:30,uriPrefix:"mailto:",pattern:/^\s*.*@.*\..*\s*$/},[b.ui("Group").uri]:{style:tt.formGroupStyle},[b.ui("Comment").uri]:{element:"p",style:tt.commentStyle},[b.ui("Heading").uri]:{element:"h3",style:tt.formHeadingStyle}},dn=v.solidLogicSingleton.store,mn={};function fn(e){const t=dn,n=t.findTypeURIs(e),i=t.bottomTypeURIs(n),a=[];for(const e in i)a.push(e);return a[0]}function hn(e,t){const n=fn(t),i=mn[n];return T("paneUtils: Going to implement field "+t+" of type "+n),i||function(e,i){const a=ot(e,"No handler for field "+t+" of type "+n);return i&&i.appendChild(a),a}}const gn="https://www.w3.org/ns/css#";const bn=v.solidLogicSingleton.store;function vn(e,t,n,i,a){n.style.display="flex",n.style.flexDirection="row";const o=n.appendChild(e.createElement("div"));o.style.width=We;const s=n.appendChild(e.createElement("div"));return o.setAttribute("class","formFieldName"),o.setAttribute("style",tt.formFieldNameBoxStyle),s.setAttribute("class","formFieldValue"),a?o.appendChild(e.createTextNode(a)):t.any(i,b.ui("property"))?o.appendChild(xn(e,t.any(i,b.ui("property")),i)):(s.appendChild(ot(e,"No property or label given for form field: "+i)),o.appendChild(e.createTextNode("???"))),s}function xn(e,t,n){let i=bn.any(n,b.ui("label"));if(i||(i=F(t,!0)),void 0===t)return e.createTextNode("@@Internal error: undefined property");const a=e.createElement("a");return t.uri&&a.setAttribute("href",t.uri),a.setAttribute("style","color: #3B5998; text-decoration: none;"),a.textContent=i,a}function yn(e,t,n){const i=bn.statementsMatching(e,t);if(0===i.length)return n;if(!bn.updater)throw new Error("Store has no updater");return i.length>0&&i[0].why.value&&bn.updater.editable(i[0].why.value,bn)?bn.sym(i[0].why.value):n}function wn(e,t,n,i,a,o,s){const r=bn,c=a.doc?a.doc():null,l=e.createElement("div"),p=r.any(a,b.ui("property"));if(t&&t.appendChild(l),!p)return l.appendChild(ot(e,"Error: No property given for text field: "+a));const u=vn(e,r,l,a),d=r.anyJS(a,b.ui("suppressEmptyUneditable"),null,c),m=fn(a);let f=un[m];void 0===f&&(f={style:""});const h=f.style||"",v=tt.textInputStyle+h,x=e.createElement("input");x.style=v,u.appendChild(x),x.setAttribute("type",f.type?f.type:"text");const y=(x.getAttribute("type")||"").toLowerCase(),w="date"===y||"datetime-local"===y,C=r.anyJS(a,b.ui("size"))||Je||20;x.setAttribute("size",C);const E=r.any(a,b.ui("maxLength"));x.setAttribute("maxLength",E?""+E:et),o=o||yn(i,p,o);let k=r.any(i,p,void 0,o);if(k||(k=r.any(a,b.ui("default"))),k&&k.value&&f.uriPrefix?x.value=decodeURIComponent(k.value.replace(f.uriPrefix,"")).replace(/ /g,""):k&&(x.value=k.value||k.value||""),x.setAttribute("style",v),!r.updater)throw new Error("kb has no updater");return r.updater.editable(o.uri)?(x.addEventListener("keyup",function(e){f.pattern&&x.setAttribute("style",v+(x.value.match(f.pattern)?"color: green;":"color: red;"))},!0),x.addEventListener("change",function(t){if(w&&e.activeElement===x)return void(x.dataset&&(x.dataset.deferredChange="true"));if(f.pattern&&!x.value.match(f.pattern))return;const n=!w;n&&(x.disabled=!0),x.setAttribute("style",v+"color: gray;");const a=r.statementsMatching(i,p);let c;f.namedNode?c=r.sym(x.value):f.uriPrefix?(c=encodeURIComponent(x.value.replace(/ /g,"")),c=r.sym(f.uriPrefix+x.value)):c=f.dt?new g.Literal(x.value.trim(),void 0,b.xsd(f.dt)):new g.Literal(x.value);let u=a.map(e=>(0,g.st)(e.subject,e.predicate,c,e.why));0===u.length&&(u=[(0,g.st)(i,p,c,o)]),function e(t,n,i){const a=[];if(n.forEach(e=>{a.includes(e.why.uri)||a.push(e.why.uri)}),t.forEach(e=>{a.includes(e.why.uri)||a.push(e.why.uri)}),0===a.length)throw new Error("updateMany has no docs to patch");if(!r.updater)throw new Error("kb has no updater");if(1===a.length)return r.updater.update(t,n,i);const o=a.pop(),s=n.filter(e=>e.why.uri===o),c=n.filter(e=>e.why.uri!==o),l=t.filter(e=>e.why.uri===o),p=t.filter(e=>e.why.uri!==o);r.updater.update(l,s,function(t,n,a){n?e(p,c,i):i(t,n,a)})}(a,u,function(t,i,a){i?(n&&(x.disabled=!1),x.setAttribute("style",v)):l.appendChild(ot(e,a)),s(i,a)})},!0),x.addEventListener("blur",function(e){if(w&&x.dataset&&"true"===x.dataset.deferredChange){delete x.dataset.deferredChange;const e=new Event("change",{bubbles:!0});x.dispatchEvent(e)}},!0),l):(x.readOnly=!0,x.style=tt.textInputStyleUneditable+h,d&&""===x.value&&(l.style.display="none"),l)}const Cn="https://www.w3.org/ns/iana/language-code/",En=["en","fr","de","it","ar"];function kn(e){return e||(e=[]),e.concat(En.filter(t=>!e.includes(t)))}async function An(e){const t=e.doc();await(v.store.fetcher?.load(t));const n=v.store.any(e,b.schema("knowsLanguage"),null,t);if(!n)return En;const i=[];return n.elements.forEach(e=>{const n=v.store.any(e,b.solid("publicId"),null,t);if(!n)return void console.warn("getPreferredLanguages: No publiID of language.");if(!n.value.startsWith(Cn))return void console.error(`What should be a language code ${n.value} does not start with ${Cn}`);const a=n.value.slice(Cn.length);i.push(a)}),i.length>0?(console.log(` User knows languages with codes: "${i.join(",")}"`),kn(i)):null}async function _n(){const e=await v.authn.currentUser();if(e){const t=await An(e);if(t)return t}if("undefined"!=typeof navigator){if(navigator.languages)return kn(navigator.languages.map(e=>e.split("-")[0]));if(navigator.language)return kn([navigator.language.split("-")[0]])}return En}function Tn(e,t){const n={};e.forEach(e=>{const t=e.subject.value;n[t]=n[t]||[],n[t].push(e)});const i=t||En;i.reverse();const a=[];for(const e in n){const t=n[e].map(e=>{const t=e.name["xml:lang"];return[i.indexOf(t),e]});t.sort(),t.reverse(),a.push(t[0][1])}return xe.Rm(` Filter by language: ${e.length} -> ${a.length}`),a}const Sn=200,jn=/\$\(subject\)/g,Ln={Corporation:"http://www.wikidata.org/entity/Q6881511",EducationalOrganization:"http://www.wikidata.org/entity/Q178706",GovernmentOrganization:"http://www.wikidata.org/entity/Q327333",MedicalOrganization:"http://www.wikidata.org/entity/Q4287745",MusicGroup:"http://www.wikidata.org/entity/Q32178211",NGO:"http://www.wikidata.org/entity/Q163740",Occupation:"http://www.wikidata.org/entity/Q28640",Project:"http://www.wikidata.org/entity/Q170584",ResearchOrganization:"http://www.wikidata.org/entity/Q31855",SportsOrganization:"http://www.wikidata.org/entity/Q4438121"},Rn='prefix vcard: <http://www.w3.org/2006/vcard/ns#>\nCONSTRUCT\n{ wd:Q49108 vcard:fn ?itemLabel.\nwd:Q49108 rdf:type ?klass. ?klass rdfs:label ?klassLabel; rdfs:comment ?klassDescription .\nwd:Q49108 schema:logo ?logo;\n schema:image ?image;\n schema:logo ?sealImage;\n schema:subOrganization ?subsidiary .\n ?subsidiary rdfs:label ?subsidiaryLabel .\n ?supersidiary schema:subOrganization wd:Q49108 .\n ?supersidiary rdfs:label ?supersidiaryLabel .\n wd:Q49108 schema:location ?location .\n ?location schema:elevation ?elevation .\n ?location wdt:P131 ?region . ?region rdfs:label ?regionLabel .\n ?location wdt:P625 ?coordinates .\n ?location schema:country ?country . ?country rdfs:label ?countryLabel .\n}\nWHERE\n{ optional {wd:Q49108 rdfs:label ?itemLabel} .\n optional {wd:Q49108 wdt:P154 ?logo .}\n optional {wd:Q49108 wdt:P31 ?klass .}\n optional {wd:Q49108 wdt:P158 ?sealImage .}\n optional {wd:Q49108 wdt:P18 ?image .}\n\n optional { wd:Q49108 wdt:P355 ?subsidiary . }\n optional { ?supersidiary wdt:P355 wd:Q49108. }\n\n optional { wd:Q49108 wdt:P276 ?location .\n\n optional { ?location schema:eleveation ?elevation }\n optional { ?location wdt:P131 ?region }\n optional { ?location wdt:P625 ?coordinates }\n optional { ?location wdt:P17 ?country }\n }\n SERVICE wikibase:label { bd:serviceParam wikibase:language "fr,en,de,it". }\n}',Nn={credentials:"omit",headers:new Headers({Accept:"application/json"})},In={label:"ESCO",logo:v.store.sym("https://ec.europa.eu/esco/portal/static_resource2/images/logo/logo_en.gif"),searchByNameURI:"https://ec.europa.eu/esco/api/search?language=$(language)&type=occupation&text=$(name)"},$n={label:"DBPedia",logo:v.store.sym("https://upload.wikimedia.org/wikipedia/commons/thumb/7/73/DBpediaLogo.svg/263px-DBpediaLogo.svg.png"),searchByNameQuery:'select distinct ?subject, ?name where {\n ?subject a $(targetClass); rdfs:label ?name\n FILTER regex(?name, "$(name)", "i")\n } LIMIT $(limit)',endpoint:"https://dbpedia.org/sparql/"},Bn={AcademicInsitution:"http://umbel.org/umbel/rc/EducationalOrganization"},Dn={AcademicInsitution:"http://www.wikidata.org/entity/Q4671277",Enterprise:"http://www.wikidata.org/entity/Q6881511",Business:"http://www.wikidata.org/entity/Q4830453",NGO:"http://www.wikidata.org/entity/Q79913",CharitableOrganization:"http://www.wikidata.org/entity/Q708676",Insitute:"http://www.wikidata.org/entity/Q1664720"},On={label:"WikiData",limit:3e3,logo:v.store.sym("https://www.wikimedia.org/static/images/project-logos/wikidatawiki.png"),endpoint:"https://query.wikidata.org/sparql",searchByNameQuery:'SELECT ?subject ?name\n WHERE {\n ?klass wdt:P279* $(targetClass) .\n ?subject wdt:P31 ?klass .\n ?subject rdfs:label ?name.\n FILTER regex(?name, "$(name)", "i")\n } LIMIT $(limit) ',insitituteDetailsQuery:'CONSTRUCT\n{ wd:Q49108 schema:name ?itemLabel;\n schema:logo ?logo;\n schema:logo ?sealImage;\n schema:subOrganization ?subsidiary .\n ?subsidiary schema:name ?subsidiaryLabel .\n}\nWHERE\n{\n wd:Q49108 # rdfs:label ?itemLabel ;\n wdt:P154 ?logo;\n wdt:P158 ?sealImage ;\n wdt:P355 ?subsidiary .\n # ?subsidiary rdfs:label ?subsidiaryLabel .\n\n SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE], fr". }\n}'},Mn={"http://www.wikidata.org/entity/Q15936437":b.schema("CollegeOrUniversity"),"http://www.wikidata.org/entity/Q1664720":b.schema("EducationalOrganization"),"http://www.wikidata.org/entity/Q43229":b.schema("Organization"),"http://www.wikidata.org/entity/Q3918":b.schema("CollegeOrUniversity"),"http://www.wikidata.org/entity/Q170584":b.schema("Project"),"http://www.wikidata.org/entity/Q327333":b.schema("GovernmentOrganization"),"http://www.wikidata.org/entity/Q2221906":b.schema("Place"),"http://www.wikidata.org/entity/Q167037":b.schema("Corporation")},Un={targetClass:b.rdf("type"),sealImage:b.schema("logo"),shortName:b.foaf("nick"),subsidiary:b.schema("subOrganization"),city:b.vcard("locality"),state:b.vcard("region"),country:b.vcard("country-name"),homepage:b.foaf("homepage"),lat:b.schema("latitude"),long:b.schema("longitude")};function Fn(e){const t=e.type.toLowerCase();if("uri"===t||"iri"===t)return v.store.sym(e.value);if("literal"===t)return e["xml:lang"]?new g.Literal(e.value,e["xml:lang"]):new g.Literal(e.value);throw new Error(`bindingToTerm: Unexpected type "${e.type}" in sparql binding}`)}function Pn(e,t,n,i,a=Un){const o={};xe.Rm(`loadFromBindings: subject: ${t}`),xe.Rm(` doc: ${i}`),n.forEach(e=>{for(const t in e){const n=e[t],i=JSON.stringify(n);o[t]=o[t]||new Set,o[t].add(i)}});for(const n in o){const s=o[n];xe.Rm(` results ${n} -> ${s}`),s.forEach(o=>{const s=JSON.parse(o),{type:r,value:c}=s;let l;if("uri"===r)l=e.sym(c);else{if("literal"!==r)throw new Error(`loadFromBindings: unexpected type: ${r}`);l=new g.Literal(c,s.language,s.datatype)}if("type"===n)Mn[c]?l=Mn[c]:xe.R8("Unmapped Wikidata Class: "+c);else if("coordinates"===n){xe.Rm(" @@@ hey a point: "+c);const n=/.*\(([-0-9.-]*) ([-0-9.-]*)\)/.exec(c);if(n){const a=b.xsd("float"),o=new g.Literal(n[1],null,a),s=new g.Literal(n[2],null,a);e.add(t,b.schema("longitude"),s,i),e.add(t,b.schema("latitude"),o,i)}else xe.Rm("Bad coordinates syntax: "+c)}else{const o=a[n]||b.schema(n);e.add(t,o,l,i),xe.Rm(` public data ${o} ${l}.`)}})}}function zn(e){return e._embedded.results.map(e=>({name:{value:e.title,type:"literal"},subject:{type:"IRI",value:e.uri}}))}async function qn(e,t,n){if(!n.searchByNameURI)throw new Error("Missing queryTarget.searchByNameURI on queryESCODataByName");const i=n.limit||Sn,a=n.searchByNameURI.replace("$(name)",e).replace("$(limit)",""+i).replace("$(targetClass)",t.toNT());xe.Rm("Querying ESCO data - uri: "+a);const o=await(v.store.fetcher?.webOperation("GET",a,Nn)),s=o?.responseText||"";if(xe.Rm(" Query result text"+s.slice(0,500)+"..."),0===s.length)throw new Error("Wot no text back from ESCO query "+a);const r=JSON.parse(s);return xe.Rm(" ESCO Query result JSON"+JSON.stringify(r,null,4).slice(0,500)+"..."),zn(r)}function Hn(e){const t=e.indexOf("SPARQL-QUERY");if(t<0)return e;xe.R8(" ### Fixing JSON with wikidata error code injection "+e.slice(t,t+200));const n=e.lastIndexOf("}, {");return e.slice(0,n)+" } ] } } "}async function Vn(e,t,n,i){function a(n){const a=i.limit||Sn;return n.replace("$(name)",e).replace("$(limit)",""+a).replace("$(language)",o).replace("$(targetClass)",t.toNT())}if(!t)throw new Error("queryPublicDataByName: No class provided");const o=(await _n()||En)[0]||"en";if(i.searchByNameQuery){const e=a(i.searchByNameQuery);return xe.Rm("Querying public data - sparql: "+e),Gn(e,i)}if(i.searchByNameURI){const e=a(i.searchByNameURI);let t;try{t=await(v.store.fetcher?.webOperation("GET",e,Nn))}catch(t){throw new Error(`Exception when trying to fetch ${e} \n ${t}`)}const n=t.responseText||"";if(200!==t.status)throw new Error(`HTTP error status ${t.status} trying to fetch ${e} `);if(xe.Rm(" Query result text"+n.slice(0,500)+"..."),0===n.length)throw new Error("queryPublicDataByName: No text back from public data query "+e);const o=Hn(n),s=JSON.parse(o);if(xe.Rm(" API Query result JSON"+JSON.stringify(s,null,4).slice(0,500)+"..."),s._embedded){xe.Rm(" Looks like ESCO");return zn(s)}throw alert("Code me: unrecognized API return format"),new Error(`*** Need to add code to parse unrecognized API JSON return\n${JSON.stringify(s,null,4)}`)}throw new Error("Query source must have either rest API or SPARQL endpoint.")}async function Gn(e,t){if(!t.endpoint)throw new Error("Missing queryTarget.endpoint required for queryPublicDataSelect");const n=new URL(t.endpoint);n.searchParams.append("query",e);const i=n.href;xe.Rm(" queryPublicDataSelect uri: "+i);const a=new Headers;a.append("Accept","application/json");const o={credentials:"omit",headers:a},s=await(v.store.fetcher?.webOperation("GET",i,o)),r=s?.responseText||"";if(0===r.length)throw new Error("No text back from query "+i);const c=Hn(r),l=JSON.parse(c);xe.Rm(" Query result JSON"+JSON.stringify(l,null,4).slice(0,100)+"...");return l.results.bindings}async function Wn(e,t,n){if(xe.Rm("queryPublicDataConstruct: sparql:",e),!n.endpoint)throw new Error("Missing queryTarget.endpoint required for queryPublicDataConstruct");const i=new URL(n.endpoint);i.searchParams.append("query",e);const a=i.href;xe.Rm(" queryPublicDataConstruct uri: "+a);const o=new Headers;o.append("Accept","text/turtle");const s={credentials:"omit",headers:o},r=await(v.store.fetcher?.webOperation("GET",a,s)),c=r?.responseText||"No response text?",l=c.length>500?c.slice(0,200)+" ... "+c.slice(-200):c;if(xe.Rm(" queryPublicDataConstruct result text:"+l),0===c.length)throw new Error("queryPublicDataConstruct: No text back from construct query:"+a);(0,g.parse)(c,v.store,t.uri,"text/turtle")}async function Jn(e,t,n){if(n.uri.startsWith("https://dbpedia.org/resource/"))return Kn(e,t,n);if(!n.uri.match(/^https?:\/\/www\.wikidata\.org\/entity\/.*/)){const t=n.uri.startsWith("http:")?e.sym("https:"+n.uri.slice(5)):n,i=new Headers;return i.append("Accept","text/turtle"),e.fetcher.load(t,{credentials:"omit",headers:i})}await Qn(e,t,n)}async function Qn(e,t,n){const i=Rn.replace(/wd:Q49108/g,n.toNT());await Wn(i,n,On),xe.Rm("getWikidataDetails: loaded.",n)}async function Zn(e,t,n){const i='select distinct * where {\n optional { $(subject) wdt:P31 ?targetClass } # instance of\n optional { $(subject) wdt:P154 ?logo }\n optional { $(subject) wdt:P158 ?sealImage }\n# optional { $(subject) wdt:P159 ?headquartersLocation }\n\noptional { $(subject) wdt:P17 ?country }\noptional { $(subject) wdt:P18 ?image }\noptional { $(subject) wdt:P1813 ?shortName }\n\noptional { $(subject) wdt:P355 ?subsidiary }\n# SERVICE wikibase:label { bd:serviceParam wikibase:language "fr,en,de,it" }\n}'.replace(jn,n.toNT());Pn(e,n,await Gn(i,On),n.doc())}async function Yn(e,t,n){const i='select distinct * where {\n\n $(subject) wdt:P276 ?location .\n\n optional { ?location wdt:P2044 ?elevation }\n optional { ?location wdt:P131 ?region }\n optional { ?location wdt:P625 ?coordinates }\noptional { ?location wdt:P17 ?country }\n\n# SERVICE wikibase:label { bd:serviceParam wikibase:language "fr,en,de,it" }\n}'.replace(jn,n.toNT());xe.Rm(" location query sparql:"+i);const a=await Gn(i,On);xe.Rm(" location query bindings:",a),Pn(e,n,a,n.doc())}async function Kn(e,t,n){const i=`select distinct ?city, ?state, ?country, ?homepage, ?logo, ?lat, ?long, WHERE {\n OPTIONAL { <${n}> <http://dbpedia.org/ontology/city> ?city }\n OPTIONAL { ${n} <http://dbpedia.org/ontology/state> ?state }\n OPTIONAL { ${n} <http://dbpedia.org/ontology/country> ?country }\n OPTIONAL { ${n} foaf:homepage ?homepage }\n OPTIONAL { ${n} foaf:lat ?lat; foaf:long ?long }\n OPTIONAL { ${n} <http://dbpedia.org/ontology/country> ?country }\n }`;Pn(e,n,await Gn(i,$n),n.doc()),xe.Rm("Finished getDbpediaDetails.")}function Xn(e,t){e.style.display=t?"":"none"}async function ei(e,t,n,i){function a(e,n){xe.Rm("Auto complete: finish! "+e),"Literal"===e.termType&&t.queryParams.objectURIBase&&(e=v.store.sym(t.queryParams.objectURIBase.value+e.value)),r(),i(e,n)}async function o(e,t){if(n.acceptButton)return n.acceptButton.disbaled=!1,Xn(n.acceptButton,!0),C.value=t.value,b=t,x=e,xe.Rm("Auto complete: name: "+t),xe.Rm("Auto complete: waiting for accept "+e),void r();Xn(n.cancelButton,!0),a(e,t)}async function s(e){b&&C.value===b.value&&a(x,b)}function r(){for(;y.children.length>1;)y.removeChild(y.lastChild)}function c(){t.currentObject?(C.value=t.currentName?t.currentName.value:"??? wot no name for "+t.currentObject,b=t.currentName,u=t.currentName?t.currentName.value:void 0,x=t.currentObject):(C.value="",u=void 0,x=void 0),n.deleteButton&&Xn(n.deleteButton,!!t.currentObject),n.acceptButton&&Xn(n.acceptButton,!1),n.editButton&&Xn(n.editButton,!0),n.cancelButton&&Xn(n.cancelButton,!1),m=!1,r()}const l=t.targetClass;if(!l)throw new Error("renderAutoComplete: missing targetClass");let p;n.acceptButton&&n.acceptButton.addEventListener("click",s,!1),n.cancelButton&&n.cancelButton.addEventListener("click",async function(e){xe.Rm("Auto complete: Canceled by user! "),t.permanent?c():g.parentNode&&g.parentNode.removeChild(g)},!1);let u,d=!1,m=!1,f=!1,h=20;const g=e.createElement("div");let b,x;const y=g.appendChild(e.createElement("table"));y.setAttribute("data-testid","autocomplete-table"),y.setAttribute("style","max-width: 30em; margin: 0.5em;");const w=y.appendChild(e.createElement("tr"));tt.setStyle(w,"autocompleteRowStyle");const C=w.appendChild(e.createElement("td")).appendChild(e.createElement("input"));C.setAttribute("type","text"),c();const E=t.size||Je||20;C.setAttribute("size",E),C.setAttribute("data-testid","autocomplete-input");const k=tt.textInputStyle||"border: 0.1em solid #444; border-radius: 0.5em; width: 100%; font-size: 100%; padding: 0.1em 0.6em";return C.setAttribute("style",k),C.addEventListener("keyup",function(e){13===e.keyCode&&s()},!1),C.addEventListener("input",async function(i){Xn(n.cancelButton,!0),async function(){function n(t){const n=e.createElement("tr");tt.setStyle(n,"autocompleteRowStyle"),n.setAttribute("style","padding: 0.3em;"),n.style.color=f?"#080":"#088",n.textContent=t.name.value;const i=Fn(t.subject),a=Fn(t.name);return n.addEventListener("click",async e=>{xe.Rm(" click row textContent: "+n.textContent),xe.Rm(" click name: "+a.value),i&&a&&o(i,a)}),n}function i(e,t){return t.name.value>e.name.value?1:t.name.name<e.name.value?-1:0}if(m)return void xe.Rm(`Ignoring "${C.value}" because of lock `);xe.Rm(`Setting lock at "${C.value}"`),m=!0;const a=await _n(),s=C.value.trim().toLowerCase();if(s.length<4)r(),h=20;else{f&&u&&s.startsWith(u)||(xe.Rm(` Querying database at "${s}" cf last "${u}".`),p=await async function(n,i){let a;try{a=await Vn(n,l,0,t.queryParams)}catch(t){return function(t){const n=y.appendChild(e.createElement("tr"));xe.Rm(t);const i=new Error(t);n.appendChild(ot(e,i,"pink")),tt.setStyle(n,"autocompleteRowStyle"),n.style.padding="1em"}("Error querying db of organizations: "+t),void(m=!1)}d=a.length<Sn,u=d?n:void 0;r();const o=Tn(a,i);return o}(s,a));const c=function(e,t){return t.filter(t=>function(e,t){const n=e.split(" ");for(let e=0;e<n.length;e++){const i=n[e];if(t.toLowerCase().indexOf(i)<0)return!1}return!0}(e,t.name.value))}(s,p);d&&c.length<=40&&(h=c.length),f=d&&c.length<=h,xe.Rm(` Filter:"${s}" lastBindings: ${p.length}, slimmed to ${c.length}; rows: ${h}, Enough? ${d}, All displayed? ${f}`);const g=c.slice(0,h);g.sort(i),r();for(const e of g)y.appendChild(n(e));1===c.length&&o(Fn(c[0].subject),Fn(c[0].name))}m=!1}()}),g}const ti=st.Pt.iconBase+"noun_34653_green.svg",ni=st.Pt.iconBase+"noun_Search_875351.svg",ii=st.Pt.iconBase+"noun_253504.svg";async function ai(e,t,n,i,a,o){async function s(e,t){return i.permanent?(Xn(m,!0),Xn(c,!1),Xn(l,!1)):x&&(y.removeChild(x),x=void 0),a(e,t)}async function r(){x=e.createElement("div"),x.setAttribute("style","display: flex; flex-flow: wrap;"),x.appendChild(await ei(e,i,g,s)),x.appendChild(c),x.appendChild(l),x.appendChild(m),x.appendChild(p),y.appendChild(x)}const c=Pt(e);c.setAttribute("data-testid","accept-button");const l=Ft(e);l.setAttribute("data-testid","cancel-button");const p=e.createElement("div"),u=i.targetClass?F(i.targetClass):"item",d=Mt(e,p,u,o);d.setAttribute("data-testid","delete-button");const m=Ut(e,ii,"Edit",e=>{f=!f,h()});m.setAttribute("data-testid","edit-button");let f=!0;function h(){f?(Xn(m,!1),Xn(c,!1),Xn(l,!1)):(Xn(m,!0),Xn(c,!1),Xn(l,!1))}const g={acceptButton:c,cancelButton:l,editButton:m,deleteButton:d};let x;const y=e.createElement("div");if(y.style.display="flex",y.style.flexDirection="row",(i.permanent||i.currentObject)&&await r(),n.editable){if(y.style.width="100%",n.manualURIEntry){nt(y.appendChild(Ut(e,ti,n.idNoun,async function(n){const i=await zt(e,v.store,y,b.vcard("url"),void 0,"Solid ID");if(i)return a(t,i)})),async function(e){for(const n of e)await a(t,n)},void 0)}!n.dbLookup||i.currentObject||i.permanent||y.appendChild(Ut(e,ni,n.idNoun,async function(e){x?(y.removeChild(x),x=void 0):await r()}))}return h(),y}
3
+ `,e.appendChild(t)}const i=document.createElement("button");return i.textContent=Oe()("Done"),i.addEventListener("click",e=>{this.doneBuildingCb(this.group)}),e.appendChild(i),this.element.innerHTML="",this.element.appendChild(e),this}add(e){return new Promise((t,n)=>{at.fetcher.nowOrWhenFetched(e,(i,a)=>{if(!i)return this.onGroupChanged(a),n(a);const o=g.namedNode(e),s=at.any(o,b.rdf("type"));return s&&s.equals(b.foaf("Person"))?t(o):n(new Error(`Only people supported right now. (tried to add something of type ${s.value})`))})}).then(e=>{const t=g.st(this.group,b.vcard("hasMember"),e);return at.holdsStatement(t)?e:ut(this.group.doc().uri,{toIns:[t]}).then(()=>{t.why=this.group.doc(),at.add(t),this.onGroupChanged(null,"added",e),this.render()})})}handleRemove(e){return t=>{const n=g.st(this.group,b.vcard("hasMember"),e);return ut(this.group.doc().uri,{toDel:[n]}).then(()=>(at.remove(n),this.onGroupChanged(null,"removed",e),this.render(),!0)).catch(t=>{const n=at.any(e,b.foaf("name")),i=n&&n.value?`Could not remove ${n.value}. (${t})`:`Could not remove ${e.value}. (${t})`;throw new Error(i)})}}setGroupName(e){const{groupIndex:t}=dt(this.book),n=[this.group.doc(),t].map(t=>{const n=at.match(this.group,b.vcard("fn"),null,t),i=g.st(this.group,b.vcard("fn"),g.literal(e));return ut(t.value,{toDel:n,toIns:[i]}).then(e=>{at.removeStatements(n),i.why=t,at.add(i)})});return Promise.all(n)}}class lt{constructor(e,t,n){this.webIdNode=t,this.element=e,this.handleRemove=n}render(){const e=document.createElement("div");e.style.display="flex";const t=pt(this.webIdNode,b.foaf("img"),it.LN+"noun_15059.svg"),n=document.createElement("img");n.src=Oe()(t),n.width="50",n.height="50",n.style.margin="5px";const i=pt(this.webIdNode,b.foaf("name"),`[${this.webIdNode}]`),a=document.createElement("span");a.innerHTML=Oe()(i),a.style.flexGrow="1",a.style.margin="auto 0";const o=document.createElement("button");return o.textContent="Remove",o.addEventListener("click",e=>this.handleRemove().catch(e=>{this.element.appendChild(nt(document,Oe()(`${e}`)))})),o.style.margin="5px",e.appendChild(n),e.appendChild(a),e.appendChild(o),this.element.innerHTML="",this.element.appendChild(e),this}}function pt(e,t,n){const i=at.any(e,t);return i?i.value:n}function ut(e,{toDel:t,toIns:n}){return new Promise((e,i)=>{at.updater.update(t,n,(t,n,a)=>{if(!n)return i(new Error(`PATCH failed for resource <${t}>: ${a}`));e()})})}function dt(e){return{groupIndex:at.any(e,b.vcard("groupIndex")),groupContainer:at.sym(e.dir().uri+"Group/")}}const mt="data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMjAiIGhlaWdodD0iMjAiIHZpZXdCb3g9IjAgMCAyMCAyMCIgZmlsbD0ibm9uZSIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj4KPHBhdGggZD0iTTEzLjAxNTcgOS4yNzM2M0MxNC4yOTU0IDguMzQwMzEgMTUuMTI4OCA2LjgyOTg0IDE1LjEyODggNS4xMjgyQzE1LjEyODggMi4zMDA1MSAxMi44MjgzIDAgMTAuMDAwNiAwQzcuMTcyODkgMCA0Ljg3MjM4IDIuMzAwNTEgNC44NzIzOCA1LjEyODJDNC44NzIzOCA2LjgyOTg0IDUuNzA1NyA4LjM0MDMxIDYuOTg1NDcgOS4yNzM2M0MzLjgwNDIyIDEwLjQ5MSAxLjUzOTA2IDEzLjU3NTQgMS41MzkwNiAxNy4xNzk1QzEuNTM5MDYgMTguNzM0NyAyLjgwNDM0IDIwIDQuMzU5NTcgMjBIMTUuNjQxNkMxNy4xOTY4IDIwIDE4LjQ2MjEgMTguNzM0NyAxOC40NjIxIDE3LjE3OTVDMTguNDYyMSAxMy41NzU0IDE2LjE5NyAxMC40OTEgMTMuMDE1NyA5LjI3MzYzWk02LjQxMDg2IDUuMTI4MkM2LjQxMDg2IDMuMTQ4ODMgOC4wMjEyMSAxLjUzODQ4IDEwLjAwMDYgMS41Mzg0OEMxMS45OCAxLjUzODQ4IDEzLjU5MDMgMy4xNDg4MyAxMy41OTAzIDUuMTI4MkMxMy41OTAzIDcuMTA3NTggMTEuOTggOC43MTc5NyAxMC4wMDA2IDguNzE3OTdDOC4wMjEyMSA4LjcxNzk3IDYuNDEwODYgNy4xMDc1OCA2LjQxMDg2IDUuMTI4MlpNMTUuNjQxNiAxOC40NjE1SDQuMzU5NTdDMy42NTI2NiAxOC40NjE1IDMuMDc3NTQgMTcuODg2NCAzLjA3NzU0IDE3LjE3OTVDMy4wNzc1NCAxMy4zNjIgNi4xODMxNiAxMC4yNTY0IDEwLjAwMDYgMTAuMjU2NEMxMy44MTgxIDEwLjI1NjQgMTYuOTIzNyAxMy4zNjIgMTYuOTIzNyAxNy4xNzk1QzE2LjkyMzcgMTcuODg2NCAxNi4zNDg2IDE4LjQ2MTUgMTUuNjQxNiAxOC40NjE1WiIgZmlsbD0iIzMxNDE1OCIvPgo8L3N2Zz4K";function ft(e,t,n){const i=e.createElement("a");i.setAttribute("href",t.uri),t.uri.startsWith("http")&&i.setAttribute("target","_blank");const a=i.appendChild(e.createElement("img"));return a.setAttribute("src",n||it.i1+"go-to-this.png"),a.setAttribute("style","margin: 0.3em;"),i}const ht=(e,t,n)=>{const i=ft(e,n);t.appendChild(i).classList.add("HoverControlHide"),t.appendChild(e.createElement("br"))},{iconBase:gt}=it.Pt,bt=gt+"noun_1180156.svg",vt=gt+"noun_1180158.svg";function xt(e,t){if(!t)return;const n=function(e){let t=e&&e.statusArea||e&&e.div||null;if(t)return t;let n=e&&e.dom;if(n||"undefined"==typeof document||(n=document),n){const i=n.getElementsByTagName("body")[0];return t=n.createElement("div"),i.insertBefore(t,i.firstElementChild),e&&(e.statusArea=t),t}return null}(e);xe.Rm("Complaint: "+t),n?n.appendChild(nt(e&&e.dom||document,t)):alert(t)}function yt(e){for(;e.firstChild;)e.removeChild(e.firstChild);return e}function wt(e){const t=e.search(/logFile=/),n=e.search(/&rulesFile=/);return e.substring(t+8,n)}function Ct(e,t){if(!e)return"???";const n=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];try{const i=(new Date).toISOString();return e.slice(0,10)!==i.slice(0,10)||t?e.slice(0,4)===i.slice(0,4)?n[parseInt(e.slice(5,7),10)-1]+" "+parseInt(e.slice(8,10),10):e.slice(0,10):e.slice(11,16)}catch(e){return"shortdate:"+e}}function Et(e,t){return t.split("{").map(function(t){const n=t.split("}")[0];return t?("000"+(e["get"+n]()+({Month:1}[n]||0))).slice(-({Milliseconds:3,FullYear:4}[n]||2))+t.split("}")[1]:""}).join("")}function kt(){return Et(new Date,"{FullYear}-{Month}-{Date}T{Hours}:{Minutes}:{Seconds}.{Milliseconds}")}function At(){return Et(new Date,"{Hours}:{Minutes}:{Seconds}.{Milliseconds}")}function _t(e,t){const n=v.store,i=function(e){const t=n.any(e,b.vcard("fn"))||n.any(e,b.foaf("name"))||n.any(e,b.vcard("organization-name"));return t?t.value:null},a=t.sameTerm(b.foaf("Agent"))?"Everyone":i(t);if(e.textContent=a||F(t),!a&&t.uri){if(!n.fetcher)throw new Error("kb has no fetcher");n.fetcher.nowOrWhenFetched(t.doc(),void 0,function(n){e.textContent=i(t)||F(t)})}}function Tt(e,t){return t.each(e,b.sioc("avatar")).concat(t.each(e,b.foaf("img"))).concat(t.each(e,b.vcard("logo"))).concat(t.each(e,b.vcard("hasPhoto"))).concat(t.each(e,b.vcard("photo"))).concat(t.each(e,b.foaf("depiction")))}const St={"solid:AppProviderClass":"noun_144.svg","solid:AppProvider":"noun_15177.svg","solid:Pod":"noun_Cabinet_1434380.svg","vcard:Group":"noun_339237.svg","vcard:Organization":"noun_143899.svg","vcard:Individual":mt,"schema:Person":mt,"foaf:Person":mt,"foaf:Agent":"noun_98053.svg","acl:AuthenticatedAgent":"noun_99101.svg","prov:SoftwareAgent":"noun_Robot_849764.svg","vcard:AddressBook":"noun_15695.svg","trip:Trip":"noun_581629.svg","meeting:LongChat":"noun_1689339.svg","meeting:Meeting":"noun_66617.svg","meeting:Project":"noun_1036577.svg","ui:Form":"noun_122196.svg","rdfs:Class":"class-rectangle.svg","rdf:Property":"property-diamond.svg","owl:Ontology":"noun_classification_1479198.svg","wf:Tracker":"noun_122196.svg","wf:Task":"noun_17020_gray-tick.svg","wf:Open":"noun_17020_sans-tick.svg","wf:Closed":"noun_17020.svg"};function jt(e){const t=e.uri.split("#")[0],n=t.indexOf("//");if(n<0)throw new Error("This URI does not have a web site part (origin)");const i=t.indexOf("/",n+2);return i<0?t.slice(0)+"/":t.slice(0,i+1)}function Lt(e){const t=gt;return"string"!=typeof e&&e.uri?4!==e.uri.split("/").length||e.uri.split("/")[1]||e.uri.split("/")[3]?e.uri.startsWith("message:")||e.uri.startsWith("mid:")?t+"noun_480183.svg":e.uri.startsWith("mailto:")?t+"noun_567486.svg":e.uri.startsWith("https:")&&e.uri.indexOf("#")<0?jt(e)+"favicon.ico":null:t+"noun_15177.svg":t+"noun_10636_grey.svg"}function Rt(e){const t=v.store,n=gt;if(e.sameTerm(b.foaf("Agent"))||e.sameTerm(b.rdf("Resource")))return n+"noun_98053.svg";const i=t.any(e,b.sioc("avatar"))||t.any(e,b.foaf("img"))||t.any(e,b.vcard("logo"))||t.any(e,b.vcard("hasPhoto"))||t.any(e,b.vcard("photo"))||t.any(e,b.foaf("depiction"));return i?i.uri:null}function Nt(e,t,n){const i=v.store,a=Rt(t);if(a)return e.setAttribute("src",a),!0;const o=n[t.uri];if(o)return e.setAttribute("src",o),e.style=Ke.classIconStyle,!0;const s=Lt(t);if(s)return e.setAttribute("src",s),!0;const r=i.findTypeURIs(t);for(const t in r)if(n[t])return e.setAttribute("src",n[t]),!1;return e.setAttribute("src",gt+"noun_10636_grey.svg"),!1}function It(e,t){const n=v.store,i={};for(const e in St){const t=e.split(":")[0],n=e.split(":")[1],a=b[t](n),o=St[e];o.startsWith("data:")?i[a.uri]=o:i[a.uri]=g.uri.join(o,gt)}if(!Nt(e,t,i)&&t.uri){if(!n.fetcher)throw new Error("kb has no fetcher");n.fetcher.nowOrWhenFetched(t.doc(),void 0,n=>{n&&Nt(e,t,i)})}}function $t(e,t){const n=e.createElement("img");n.style=Ke.iconStyle;if(n.setAttribute("src",gt+(function(e){if(!e.uri)return!1;const t=e.uri.split("/");return 3===t.length||4===t.length&&""===t[3]}(t)?"noun_15177.svg":"noun_681601.svg")),t.uri&&t.uri.startsWith("https:")&&t.uri.indexOf("#")<0){const i=e.createElement("object");return i.setAttribute("data",jt(t)+"favicon.ico"),i.setAttribute("type","image/x-icon"),i.appendChild(n),i}return It(n,t),n}function Bt(e,t,n,i){const a=gt+"noun_2188_red.svg",o=e.createElement("img");o.setAttribute("src",a),o.setAttribute("style",Ke.smallButtonStyle),o.style.float="right";const s="Remove this "+n;return o.title=s,o.classList.add("hoverControlHide"),o.addEventListener("click",function(){const n=e.createElement("div");t.insertBefore(n,o),n.style.position="relative",n.appendChild(function(e,t,n,i){function a(){t.parentElement.removeChild(t)}function o(){a(),i()}const s=e.createElement("div");s.style=Ke.confirmPopupStyle,s.style.position="absolute",s.style.top="-1em",s.style.display="grid",s.style.gridTemplateColumns="auto auto";const r=e.createElement("div");r.style.gridColumn="1/2",r.style.gridRow="1";const c=e.createElement("div");c.style.gridColumn="1/2",c.style.gridRow="2";const l=Ot(e,a);s.appendChild(l),l.style.gridColumn="1",l.style.gridRow="2";const p=s.appendChild(e.createElement("button"));p.style=Ke.buttonStyle,p.style.gridRow="2",p.style.gridColumn="2",p.textContent="Cancel";const u=Dt(e,it.Pt.iconBase+"noun_925021.svg","Delete it");s.appendChild(u),u.style.gridRow="1",u.style.gridColumn="1";const d=s.appendChild(e.createElement("button"));return d.style=Ke.buttonStyle,d.style.gridRow="1",d.style.gridColumn="2",d.textContent=n,s.appendChild(d),u.addEventListener("click",o),d.addEventListener("click",o),p.addEventListener("click",a),s}(e,n,s,i))}),t.classList.add("hoverControl"),t.appendChild(o),o.setAttribute("data-testid","deleteButtonWithCheck"),o}function Dt(e,t,n,i,a={buttonColor:"Primary",needsBorder:!1}){const o=e.createElement("button");if(o.setAttribute("type","button"),t){const i=o.appendChild(e.createElement("img"));i.setAttribute("src",t),i.setAttribute("style","width: 2em; height: 2em;"),i.title=n,o.setAttribute("style",Ke.buttonStyle)}else o.textContent=n.toLocaleUpperCase(),o.onmouseover=function(){"Secondary"===a.buttonColor?a.needsBorder?o.setAttribute("style",Ke.secondaryButtonNoBorderHover):o.setAttribute("style",Ke.secondaryButtonHover):a.needsBorder?o.setAttribute("style",Ke.primaryButtonNoBorderHover):o.setAttribute("style",Ke.primaryButtonHover)},o.onmouseout=function(){"Secondary"===a.buttonColor?a.needsBorder?o.setAttribute("style",Ke.secondaryButtonNoBorder):o.setAttribute("style",Ke.secondaryButton):a.needsBorder?o.setAttribute("style",Ke.primaryButtonNoBorder):o.setAttribute("style",Ke.primaryButton)},"Secondary"===a.buttonColor?a.needsBorder?o.setAttribute("style",Ke.secondaryButtonNoBorder):o.setAttribute("style",Ke.secondaryButton):a.needsBorder?o.setAttribute("style",Ke.primaryButtonNoBorder):o.setAttribute("style",Ke.primaryButton);return i&&o.addEventListener("click",i,!1),o}function Ot(e,t){const n=Dt(e,bt,"Cancel",t);return n.firstChild&&(n.firstChild.style.opacity="0.3"),n}function Mt(e,t){return Dt(e,vt,"Continue",t)}function Ut(e,t,n,i,a,o){return new Promise(function(t,s){const r=e.createElement("div");i=i||b.foaf("name");const c=(o=o||(a?F(a):" "))+" "+F(i)+": ";r.appendChild(e.createElement("p")).textContent=c;const l=e.createElement("input");function p(){r.parentNode.removeChild(r),t(l.value.trim())}l.setAttribute("type","text"),l.setAttribute("size","100"),l.setAttribute("maxLength","2048"),l.setAttribute("style",Ke.textInputStyle),l.select(),r.appendChild(l),n.appendChild(r),l.addEventListener("keyup",function(e){13===e.keyCode&&p()},!1),r.appendChild(e.createElement("br")),r.appendChild(Ot(e,function(e){r.parentNode.removeChild(r),t(null)})),r.appendChild(Mt(e,function(e){p()})),l.focus()})}const Ft=Pt;function Pt(e,t,n,i){const a=e.createElement("tr");i=i||{};const o=a.appendChild(e.createElement("td")),s=a.appendChild(e.createElement("td")),r=a.appendChild(e.createElement("td")),c=i.image||$t(e,n);o.setAttribute("style","vertical-align: middle; width:2.5em; padding:0.5em; height: 2.5em;"),s.setAttribute("style","vertical-align: middle; text-align:left;"),r.setAttribute("style","vertical-align: middle; width:2em; padding:0.5em; height: 4em;"),o.appendChild(c);const l=s.appendChild(e.createElement("div")),p=l.appendChild(e.createElement("span"));if(i.title?p.textContent=i.title:_t(p,n),"function"==typeof i.renderNameSuffix){const t=i.renderNameSuffix(n,e);if(t){const n=l.appendChild(e.createElement("span"));n.setAttribute("style","margin-left: 0.4em; opacity: 0.8;"),"string"==typeof t?n.textContent=t:n.appendChild(t)}}if("function"==typeof i.renderSupportingInfo){const t=i.renderSupportingInfo(n,e);if(t){const n=s.appendChild(e.createElement("div"));n.setAttribute("style","font-size: 90%; opacity: 0.8;"),"string"==typeof t?n.textContent=t:n.appendChild(t)}}if(i.deleteFunction&&Bt(e,r,i.noun||"one",i.deleteFunction),n.uri){if(!1!==i.link){r.appendChild(ft(e,n)).classList.add("HoverControlHide"),r.appendChild(e.createElement("br"))}!1!==i.draggable&&(c.setAttribute("draggable","false"),et(a,n))}return a.subject=n,a}function zt(e,t,n,i){const a=t.appendChild(e.createElement("div"));n?a.textContent=n:_t(a,i)}function qt(e,t,n,i){const a=t.appendChild(e.createElement("div"));a.setAttribute("style",Ke.linkDivStyle),i.deleteFunction&&Bt(e,a,i.noun||"one",i.deleteFunction),n.uri&&(!1!==i.link&&ht(e,a,n),et(t,n))}function Ht(e,t,n){const i=e.createElement("div");i.setAttribute("style",Ke.renderAsDivStyle);if(((e,t,n)=>{const i=t.appendChild(e.createElement("div"));i.setAttribute("style",Ke.imageDivStyle),i.appendChild(n),n.setAttribute("draggable","false")})(e,i,(n=n||{}).image||$t(e,t)),zt(e,i,n.title,t),qt(e,i,t,n),n.clickable&&n.onClickFunction&&((e,t)=>{e.addEventListener("click",t)})(i,n.onClickFunction),n.wrapInATR){const n=((e,t,n)=>{const i=e.createElement("tr");return i.appendChild(e.createElement("td")).appendChild(t),i.subject=n,i})(e,i,t);return n}return i}function Vt(e){if(e.refresh)e.refresh();else for(let t=0;t<e.children.length;t++)Vt(e.children[t])}function Gt(e,t,n,i={}){const a=new Set,o=!(!i.renderSupportingInfo&&!i.renderNameSuffix),s=i.refreshOnDocumentLoad??!0;function r(n){const r=n,l={noun:h};if(l.renderSupportingInfo=i.renderSupportingInfo,l.renderNameSuffix=i.renderNameSuffix,o&&s&&n?.uri&&x.fetcher){const e=n.doc(),t=e?.uri?x.fetcher.requested?.[e.uri]:void 0,i="done"!==t&&"failed"!==t;e?.uri&&i&&!a.has(e.uri)&&(a.add(e.uri),x.fetcher.nowOrWhenFetched(e,void 0,()=>{a.delete(e.uri),c()}))}return d&&(l.deleteFunction=function(){!function(e){if(!x.updater)throw new Error("kb has no updater");x.updater.update((0,g.st)(t,f,e,u),[],function(e,t,n,i){t?c():xt(void 0,"Error deleting one: "+n)})}(r)}),Ft(e,f,n,l)}const c=function(){const e=x.each(t,f);e.sort(),Z(E,e,r,o?function(e,t){return r(t)}:void 0)};function l(e){const n=[];if(e.forEach(function(e){const i=(0,g.sym)(e);xe.Rm("Dropped on attachemnt "+e),n.push((0,g.st)(t,f,i,u))}),!x.updater)throw new Error("kb has no updater");x.updater.update([],n,function(e,t,n,i){t?c():xt(void 0,"Error adding one: "+n)})}function p(e){tt(x.fetcher,e,i.uploadFolder?.uri,i.uploadFolder?.uri,function(e,n){const i=[(0,g.st)(t,f,x.sym(n),u)];if(!x.updater)throw new Error("kb has no updater");x.updater.update([],i,function(e,t,n,i){t?c():xt(void 0,"Error adding link to uploaded file: "+n)})})}const u=i.doc||t.doc();void 0===i.modify&&(i.modify=!0);const d=i.modify,m=i.promptIcon||gt+"noun_748003.svg",f=i.predicate||b.wf("attachment"),h=i.noun||"attachment",x=v.store,y=n.appendChild(e.createElement("table"));y.setAttribute("style","margin-top: 1em; margin-bottom: 1em;");const w=y.appendChild(e.createElement("tr")),C=w.appendChild(e.createElement("td")),E=w.appendChild(e.createElement("td")).appendChild(e.createElement("table"));if(E.appendChild(e.createElement("tr")),y.refresh=c,c(),d){const t=Dt(e,m,"Drop attachments here");C.appendChild(t);const n=i.uploadFolder?p:null;Xe(t,l,n);const a=t.querySelector("img");if(a&&Xe(a,l,n),Xe(C,l,n),i.uploadFolder){const t=rn(e,p);C.appendChild(t)}}return y}function Wt(e){e.preventDefault(),e.stopPropagation();const t=ee(e).getAttribute("href");if(!t)return xe.Rm("openHrefInOutlineMode: No href found!\n");const n=window.document;n.outlineManager?n.outlineManager.GotoSubject(v.store.sym(t),!0,void 0,!0,void 0):window&&window.panes&&window.panes.getOutliner?window.panes.getOutliner().GotoSubject(v.store.sym(t),!0,void 0,!0,void 0):xe.Rm("ERROR: Can't access outline manager in this config")}function Jt(e){if(void 0===e.uri)return;let t=e.uri;if("http://"!==t.slice(0,7))return;t=t.slice(7);const n=t.indexOf("#");if(n>=0)t=t.slice(0,n);else{const e=t.lastIndexOf("/");if(e<0)return;t=t.slice(0,e)}return v.store.sym("http://tabulator.org/wiki/annnotation/"+t)}function Qt(){const e={};return v.store.statementsMatching(void 0,b.rdf("type"),void 0).forEach(function(t){t.object.value&&(e[t.object.value]=!0)}),v.store.statementsMatching(void 0,b.rdfs("subClassOf"),void 0).forEach(function(t){t.object.value&&(e[t.object.value]=!0),t.subject.value&&(e[t.subject.value]=!0)}),v.store.each(void 0,b.rdf("type"),b.rdfs("Class")).forEach(function(t){t.value&&(e[t.value]=!0)}),e}function Zt(e){const t={},n={},i={};let a=0,o=0,s=0;const r=e.predicateIndex;for(const e in r){"Literal"===r[e][0].object.termType?(n[e]=!0,o++):(i[e]=!0,a++)}const c=e.each(void 0,b.rdf("type"),b.rdf("Property"));for(let e=0;e<c.length;e++){const t=c[e].toNT();i[t]||n[t]||(n[t]=!0,i[t]=!0,s++)}return t.op=i,t.dp=n,S(`propertyTriage: ${a} non-lit, ${o} literal. ${s} unknown.`),t}function Yt(e,t){const n=e.createElement("button");return n.setAttribute("type","button"),n.textContent="Goto "+F(t),n.addEventListener("click",function(n){e.outlineManager.GotoSubject(t,!0,void 0,!0,void 0)},!0),n}function Kt(e,t){const n=e.createElement("button");return n.setAttribute("type","button"),n.textContent="✕",n.addEventListener("click",function(e){t.parentNode.removeChild(t)},!0),n}function Xt(e,t,n,i,a,o,s,r,c){return en(e.createElement("div"),e,t,n,i,a,o,s,r,c)}function en(e,t,n,i,a,o,s,r,c,l){const p="border: 0.1em solid #ddd; border-bottom: none; width: 95%; height: 2em; padding: 0.5em;";let u=null;e.innerHTML="";const d=function(e,s){let d,m;const f=function(){const e=o?n.each(void 0,a,s):n.each(s,a);v.setAttribute("class",0===e.length?"hideTillHover":""),m.setAttribute("src",r.connectIcon||gt+"noun_25830.svg"),m.setAttribute("title",e.length?e.length:"attach")},h=tn.twoLine.widgetForClass(i);d=h(t,s),d.setAttribute("style",p);const g=t.createElement("div");g.setAttribute("class","hideTillHover"),g.setAttribute("style","float:right; width:10%");const b=t.createElement("a");b.setAttribute("href",s.uri),b.setAttribute("style","float:right"),g.appendChild(b).textContent=">",e.appendChild(g);const v=t.createElement("div");return v.setAttribute("style",(o?"float:left;":"float:right;")+" width:30px;"),m=t.createElement("img"),f(),v.appendChild(m),e.appendChild(v),d.addEventListener("click",function(e){u===d?(d.setAttribute("style",p),u=null):(u&&u.setAttribute("style",p),d.setAttribute("style",p+"background-color: #ccc; color:black;"),u=d),c(s,e,u===d),f()},!1),m.addEventListener("click",function(e){l(s,e,o,f)},!1),e.appendChild(d),e};for(let n=0;n<s.length;n++){const i=t.createElement("div");e.appendChild(i),d(i,s[n])}return e}let tn={};function nn(e,t){const n=e.querySelectorAll("link");for(let e=0;e<n.length;e++)if("stylesheet"===(n[e].getAttribute("rel")||"")&&(n[e].getAttribute("href")||"")===t)return;const i=e.createElement("link");i.setAttribute("rel","stylesheet"),i.setAttribute("type","text/css"),i.setAttribute("href",t),e.getElementsByTagName("head")[0].appendChild(i)}function an(e){return sn(e,"audio")}function on(e){return sn(e,"video")}function sn(e,t){const n=t||"image",i=v.store.findTypeURIs(e),a=g.Util.mediaTypeClass(n+"/*").uri.split("*")[0];for(const e in i)if(e.startsWith(a))return!0;return{audio:"http://purl.org/dc/dcmitype/Sound",image:"http://purl.org/dc/dcmitype/Image",video:"http://purl.org/dc/dcmitype/MovingImage"}[n]in i}function rn(e,t){const n=e.createElement("div"),i=n.appendChild(e.createElement("input"));i.setAttribute("type","file"),i.setAttribute("multiple","true"),i.addEventListener("change",e=>{xe.Rm("File drop event: ",e),e.files?t(e.files):e.target&&e.target.files?t(e.target.files):alert("Sorry no files .. internal error?")},!1),i.style="display:none";return Xe(n.appendChild(Dt(e,gt+"noun_Upload_76574_000000.svg","Upload files",e=>{i.click()})),null,t),n}tn={line:{},twoLine:{"":function(e,t){const n=e.createElement("div");return n.textContent=F(t),n},"http://www.w3.org/2000/10/swap/pim/qif#Transaction":function(e,t){let n="";const i=function(e){const i=v.store.any(t,b.qu(e));return i||(n+="@@ No value for "+e+"! "),i?de(i.value):"?"},a=e.createElement("table");return a.innerHTML=`\n <tr>\n <td colspan="2"> ${i("payee")}</td>\n < /tr>\n < tr >\n <td>${i("date").slice(0,10)}</td>\n <td style = "text-align: right;">${i("amount")}</td>\n </tr>`,n&&(a.innerHTML=`\n <tr>\n <td><a href="${de(t.uri)}">${de(n)}</a></td>\n </tr>`),a},"http://www.w3.org/ns/pim/trip#Trip":function(e,t){const n=function(e){const n=v.store.any(t,e);return n?de(n.value):"?"},i=e.createElement("table");return i.innerHTML=`\n <tr>\n <td colspan="2">${n(b.dc("title"))}</td>\n </tr>\n <tr style="color: #777">\n <td>${n(b.cal("dtstart"))}</td>\n <td>${n(b.cal("dtend"))}</td>\n </tr>`,i},widgetForClass:function(e){let t=tn.twoLine[e.uri];const n=v.store;if(t)return t;const i=n.findSuperClassesNT(e);for(const e in i)if(t=tn.twoLine[n.fromNT(e).uri],t)return t;return tn.twoLine[""]}}};const cn={[b.ui("ColorField").uri]:{size:9,type:"color",style:"height: 3em;",dt:"color",pattern:/^\s*#[0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f]([0-9a-f][0-9a-f])?\s*$/},[b.ui("DateField").uri]:{size:20,type:"date",dt:"date",pattern:/^\s*[0-9][0-9][0-9][0-9](-[0-1]?[0-9]-[0-3]?[0-9])?Z?\s*$/},[b.ui("DateTimeField").uri]:{size:20,type:"datetime-local",dt:"dateTime",pattern:/^\s*[0-9][0-9][0-9][0-9](-[0-1]?[0-9]-[0-3]?[0-9])?(T[0-2][0-9]:[0-5][0-9](:[0-5][0-9])?)?Z?\s*$/},[b.ui("TimeField").uri]:{size:10,type:"time",dt:"time",pattern:/^\s*([0-2]?[0-9]:[0-5][0-9](:[0-5][0-9])?)\s*$/},[b.ui("IntegerField").uri]:{size:12,style:"text-align: right;",dt:"integer",pattern:/^\s*-?[0-9]+\s*$/},[b.ui("DecimalField").uri]:{size:12,style:"text-align: right;",dt:"decimal",pattern:/^\s*-?[0-9]*(\.[0-9]*)?\s*$/},[b.ui("FloatField").uri]:{size:12,style:"text-align: right;",dt:"float",pattern:/^\s*-?[0-9]*(\.[0-9]*)?((e|E)-?[0-9]*)?\s*$/},[b.ui("SingleLineTextField").uri]:{},[b.ui("NamedNodeURIField").uri]:{namedNode:!0},[b.ui("TextField").uri]:{},[b.ui("PhoneField").uri]:{size:20,uriPrefix:"tel:",pattern:/^\+?[\d-]+[\d]*$/},[b.ui("EmailField").uri]:{size:30,uriPrefix:"mailto:",pattern:/^\s*.*@.*\..*\s*$/},[b.ui("Group").uri]:{style:Ke.formGroupStyle},[b.ui("Comment").uri]:{element:"p",style:Ke.commentStyle},[b.ui("Heading").uri]:{element:"h3",style:Ke.formHeadingStyle}},ln=v.solidLogicSingleton.store,pn={};function un(e){const t=ln,n=t.findTypeURIs(e),i=t.bottomTypeURIs(n),a=[];for(const e in i)a.push(e);return a[0]}function dn(e,t){const n=un(t),i=pn[n];return T("paneUtils: Going to implement field "+t+" of type "+n),i||function(e,i){const a=nt(e,"No handler for field "+t+" of type "+n);return i&&i.appendChild(a),a}}const mn="https://www.w3.org/ns/css#";const fn=v.solidLogicSingleton.store;function hn(e,t,n,i,a){n.style.display="flex",n.style.flexDirection="row";const o=n.appendChild(e.createElement("div"));o.style.width=He;const s=n.appendChild(e.createElement("div"));return o.setAttribute("class","formFieldName"),o.setAttribute("style",Ke.formFieldNameBoxStyle),s.setAttribute("class","formFieldValue"),a?o.appendChild(e.createTextNode(a)):t.any(i,b.ui("property"))?o.appendChild(gn(e,t.any(i,b.ui("property")),i)):(s.appendChild(nt(e,"No property or label given for form field: "+i)),o.appendChild(e.createTextNode("???"))),s}function gn(e,t,n){let i=fn.any(n,b.ui("label"));if(i||(i=F(t,!0)),void 0===t)return e.createTextNode("@@Internal error: undefined property");const a=e.createElement("a");return t.uri&&a.setAttribute("href",t.uri),a.setAttribute("style","color: #3B5998; text-decoration: none;"),a.textContent=i,a}function bn(e,t,n){const i=fn.statementsMatching(e,t);if(0===i.length)return n;if(!fn.updater)throw new Error("Store has no updater");return i.length>0&&i[0].why.value&&fn.updater.editable(i[0].why.value,fn)?fn.sym(i[0].why.value):n}function vn(e,t,n,i,a,o,s){const r=fn,c=a.doc?a.doc():null,l=e.createElement("div"),p=r.any(a,b.ui("property"));if(t&&t.appendChild(l),!p)return l.appendChild(nt(e,"Error: No property given for text field: "+a));const u=hn(e,r,l,a),d=r.anyJS(a,b.ui("suppressEmptyUneditable"),null,c),m=un(a);let f=cn[m];void 0===f&&(f={style:""});const h=f.style||"",v=Ke.textInputStyle+h,x=e.createElement("input");x.style=v,u.appendChild(x),x.setAttribute("type",f.type?f.type:"text");const y=(x.getAttribute("type")||"").toLowerCase(),w="date"===y||"datetime-local"===y,C=r.anyJS(a,b.ui("size"))||Ve||20;x.setAttribute("size",C);const E=r.any(a,b.ui("maxLength"));x.setAttribute("maxLength",E?""+E:Ye),o=o||bn(i,p,o);let k=r.any(i,p,void 0,o);if(k||(k=r.any(a,b.ui("default"))),k&&k.value&&f.uriPrefix?x.value=decodeURIComponent(k.value.replace(f.uriPrefix,"")).replace(/ /g,""):k&&(x.value=k.value||k.value||""),x.setAttribute("style",v),!r.updater)throw new Error("kb has no updater");return r.updater.editable(o.uri)?(x.addEventListener("keyup",function(e){f.pattern&&x.setAttribute("style",v+(x.value.match(f.pattern)?"color: green;":"color: red;"))},!0),x.addEventListener("change",function(t){if(w&&e.activeElement===x)return void(x.dataset&&(x.dataset.deferredChange="true"));if(f.pattern&&!x.value.match(f.pattern))return;const n=!w;n&&(x.disabled=!0),x.setAttribute("style",v+"color: gray;");const a=r.statementsMatching(i,p);let c;f.namedNode?c=r.sym(x.value):f.uriPrefix?(c=encodeURIComponent(x.value.replace(/ /g,"")),c=r.sym(f.uriPrefix+x.value)):c=f.dt?new g.Literal(x.value.trim(),void 0,b.xsd(f.dt)):new g.Literal(x.value);let u=a.map(e=>(0,g.st)(e.subject,e.predicate,c,e.why));0===u.length&&(u=[(0,g.st)(i,p,c,o)]),function e(t,n,i){const a=[];if(n.forEach(e=>{a.includes(e.why.uri)||a.push(e.why.uri)}),t.forEach(e=>{a.includes(e.why.uri)||a.push(e.why.uri)}),0===a.length)throw new Error("updateMany has no docs to patch");if(!r.updater)throw new Error("kb has no updater");if(1===a.length)return r.updater.update(t,n,i);const o=a.pop(),s=n.filter(e=>e.why.uri===o),c=n.filter(e=>e.why.uri!==o),l=t.filter(e=>e.why.uri===o),p=t.filter(e=>e.why.uri!==o);r.updater.update(l,s,function(t,n,a){n?e(p,c,i):i(t,n,a)})}(a,u,function(t,i,a){i?(n&&(x.disabled=!1),x.setAttribute("style",v)):l.appendChild(nt(e,a)),s(i,a)})},!0),x.addEventListener("blur",function(e){if(w&&x.dataset&&"true"===x.dataset.deferredChange){delete x.dataset.deferredChange;const e=new Event("change",{bubbles:!0});x.dispatchEvent(e)}},!0),l):(x.readOnly=!0,x.style=Ke.textInputStyleUneditable+h,d&&""===x.value&&(l.style.display="none"),l)}const xn="https://www.w3.org/ns/iana/language-code/",yn=["en","fr","de","it","ar"];function wn(e){return e||(e=[]),e.concat(yn.filter(t=>!e.includes(t)))}async function Cn(e){const t=e.doc();await(v.store.fetcher?.load(t));const n=v.store.any(e,b.schema("knowsLanguage"),null,t);if(!n)return yn;const i=[];return n.elements.forEach(e=>{const n=v.store.any(e,b.solid("publicId"),null,t);if(!n)return void console.warn("getPreferredLanguages: No publiID of language.");if(!n.value.startsWith(xn))return void console.error(`What should be a language code ${n.value} does not start with ${xn}`);const a=n.value.slice(xn.length);i.push(a)}),i.length>0?(console.log(` User knows languages with codes: "${i.join(",")}"`),wn(i)):null}async function En(){const e=await v.authn.currentUser();if(e){const t=await Cn(e);if(t)return t}if("undefined"!=typeof navigator){if(navigator.languages)return wn(navigator.languages.map(e=>e.split("-")[0]));if(navigator.language)return wn([navigator.language.split("-")[0]])}return yn}function kn(e,t){const n={};e.forEach(e=>{const t=e.subject.value;n[t]=n[t]||[],n[t].push(e)});const i=t||yn;i.reverse();const a=[];for(const e in n){const t=n[e].map(e=>{const t=e.name["xml:lang"];return[i.indexOf(t),e]});t.sort(),t.reverse(),a.push(t[0][1])}return xe.Rm(` Filter by language: ${e.length} -> ${a.length}`),a}const An=200,_n=/\$\(subject\)/g,Tn={Corporation:"http://www.wikidata.org/entity/Q6881511",EducationalOrganization:"http://www.wikidata.org/entity/Q178706",GovernmentOrganization:"http://www.wikidata.org/entity/Q327333",MedicalOrganization:"http://www.wikidata.org/entity/Q4287745",MusicGroup:"http://www.wikidata.org/entity/Q32178211",NGO:"http://www.wikidata.org/entity/Q163740",Occupation:"http://www.wikidata.org/entity/Q28640",Project:"http://www.wikidata.org/entity/Q170584",ResearchOrganization:"http://www.wikidata.org/entity/Q31855",SportsOrganization:"http://www.wikidata.org/entity/Q4438121"},Sn='prefix vcard: <http://www.w3.org/2006/vcard/ns#>\nCONSTRUCT\n{ wd:Q49108 vcard:fn ?itemLabel.\nwd:Q49108 rdf:type ?klass. ?klass rdfs:label ?klassLabel; rdfs:comment ?klassDescription .\nwd:Q49108 schema:logo ?logo;\n schema:image ?image;\n schema:logo ?sealImage;\n schema:subOrganization ?subsidiary .\n ?subsidiary rdfs:label ?subsidiaryLabel .\n ?supersidiary schema:subOrganization wd:Q49108 .\n ?supersidiary rdfs:label ?supersidiaryLabel .\n wd:Q49108 schema:location ?location .\n ?location schema:elevation ?elevation .\n ?location wdt:P131 ?region . ?region rdfs:label ?regionLabel .\n ?location wdt:P625 ?coordinates .\n ?location schema:country ?country . ?country rdfs:label ?countryLabel .\n}\nWHERE\n{ optional {wd:Q49108 rdfs:label ?itemLabel} .\n optional {wd:Q49108 wdt:P154 ?logo .}\n optional {wd:Q49108 wdt:P31 ?klass .}\n optional {wd:Q49108 wdt:P158 ?sealImage .}\n optional {wd:Q49108 wdt:P18 ?image .}\n\n optional { wd:Q49108 wdt:P355 ?subsidiary . }\n optional { ?supersidiary wdt:P355 wd:Q49108. }\n\n optional { wd:Q49108 wdt:P276 ?location .\n\n optional { ?location schema:eleveation ?elevation }\n optional { ?location wdt:P131 ?region }\n optional { ?location wdt:P625 ?coordinates }\n optional { ?location wdt:P17 ?country }\n }\n SERVICE wikibase:label { bd:serviceParam wikibase:language "fr,en,de,it". }\n}',jn={credentials:"omit",headers:new Headers({Accept:"application/json"})},Ln={label:"ESCO",logo:v.store.sym("https://ec.europa.eu/esco/portal/static_resource2/images/logo/logo_en.gif"),searchByNameURI:"https://ec.europa.eu/esco/api/search?language=$(language)&type=occupation&text=$(name)"},Rn={label:"DBPedia",logo:v.store.sym("https://upload.wikimedia.org/wikipedia/commons/thumb/7/73/DBpediaLogo.svg/263px-DBpediaLogo.svg.png"),searchByNameQuery:'select distinct ?subject, ?name where {\n ?subject a $(targetClass); rdfs:label ?name\n FILTER regex(?name, "$(name)", "i")\n } LIMIT $(limit)',endpoint:"https://dbpedia.org/sparql/"},Nn={AcademicInsitution:"http://umbel.org/umbel/rc/EducationalOrganization"},In={AcademicInsitution:"http://www.wikidata.org/entity/Q4671277",Enterprise:"http://www.wikidata.org/entity/Q6881511",Business:"http://www.wikidata.org/entity/Q4830453",NGO:"http://www.wikidata.org/entity/Q79913",CharitableOrganization:"http://www.wikidata.org/entity/Q708676",Insitute:"http://www.wikidata.org/entity/Q1664720"},$n={label:"WikiData",limit:3e3,logo:v.store.sym("https://www.wikimedia.org/static/images/project-logos/wikidatawiki.png"),endpoint:"https://query.wikidata.org/sparql",searchByNameQuery:'SELECT ?subject ?name\n WHERE {\n ?klass wdt:P279* $(targetClass) .\n ?subject wdt:P31 ?klass .\n ?subject rdfs:label ?name.\n FILTER regex(?name, "$(name)", "i")\n } LIMIT $(limit) ',insitituteDetailsQuery:'CONSTRUCT\n{ wd:Q49108 schema:name ?itemLabel;\n schema:logo ?logo;\n schema:logo ?sealImage;\n schema:subOrganization ?subsidiary .\n ?subsidiary schema:name ?subsidiaryLabel .\n}\nWHERE\n{\n wd:Q49108 # rdfs:label ?itemLabel ;\n wdt:P154 ?logo;\n wdt:P158 ?sealImage ;\n wdt:P355 ?subsidiary .\n # ?subsidiary rdfs:label ?subsidiaryLabel .\n\n SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE], fr". }\n}'},Bn={"http://www.wikidata.org/entity/Q15936437":b.schema("CollegeOrUniversity"),"http://www.wikidata.org/entity/Q1664720":b.schema("EducationalOrganization"),"http://www.wikidata.org/entity/Q43229":b.schema("Organization"),"http://www.wikidata.org/entity/Q3918":b.schema("CollegeOrUniversity"),"http://www.wikidata.org/entity/Q170584":b.schema("Project"),"http://www.wikidata.org/entity/Q327333":b.schema("GovernmentOrganization"),"http://www.wikidata.org/entity/Q2221906":b.schema("Place"),"http://www.wikidata.org/entity/Q167037":b.schema("Corporation")},Dn={targetClass:b.rdf("type"),sealImage:b.schema("logo"),shortName:b.foaf("nick"),subsidiary:b.schema("subOrganization"),city:b.vcard("locality"),state:b.vcard("region"),country:b.vcard("country-name"),homepage:b.foaf("homepage"),lat:b.schema("latitude"),long:b.schema("longitude")};function On(e){const t=e.type.toLowerCase();if("uri"===t||"iri"===t)return v.store.sym(e.value);if("literal"===t)return e["xml:lang"]?new g.Literal(e.value,e["xml:lang"]):new g.Literal(e.value);throw new Error(`bindingToTerm: Unexpected type "${e.type}" in sparql binding}`)}function Mn(e,t,n,i,a=Dn){const o={};xe.Rm(`loadFromBindings: subject: ${t}`),xe.Rm(` doc: ${i}`),n.forEach(e=>{for(const t in e){const n=e[t],i=JSON.stringify(n);o[t]=o[t]||new Set,o[t].add(i)}});for(const n in o){const s=o[n];xe.Rm(` results ${n} -> ${s}`),s.forEach(o=>{const s=JSON.parse(o),{type:r,value:c}=s;let l;if("uri"===r)l=e.sym(c);else{if("literal"!==r)throw new Error(`loadFromBindings: unexpected type: ${r}`);l=new g.Literal(c,s.language,s.datatype)}if("type"===n)Bn[c]?l=Bn[c]:xe.R8("Unmapped Wikidata Class: "+c);else if("coordinates"===n){xe.Rm(" @@@ hey a point: "+c);const n=/.*\(([-0-9.-]*) ([-0-9.-]*)\)/.exec(c);if(n){const a=b.xsd("float"),o=new g.Literal(n[1],null,a),s=new g.Literal(n[2],null,a);e.add(t,b.schema("longitude"),s,i),e.add(t,b.schema("latitude"),o,i)}else xe.Rm("Bad coordinates syntax: "+c)}else{const o=a[n]||b.schema(n);e.add(t,o,l,i),xe.Rm(` public data ${o} ${l}.`)}})}}function Un(e){return e._embedded.results.map(e=>({name:{value:e.title,type:"literal"},subject:{type:"IRI",value:e.uri}}))}async function Fn(e,t,n){if(!n.searchByNameURI)throw new Error("Missing queryTarget.searchByNameURI on queryESCODataByName");const i=n.limit||An,a=n.searchByNameURI.replace("$(name)",e).replace("$(limit)",""+i).replace("$(targetClass)",t.toNT());xe.Rm("Querying ESCO data - uri: "+a);const o=await(v.store.fetcher?.webOperation("GET",a,jn)),s=o?.responseText||"";if(xe.Rm(" Query result text"+s.slice(0,500)+"..."),0===s.length)throw new Error("Wot no text back from ESCO query "+a);const r=JSON.parse(s);return xe.Rm(" ESCO Query result JSON"+JSON.stringify(r,null,4).slice(0,500)+"..."),Un(r)}function Pn(e){const t=e.indexOf("SPARQL-QUERY");if(t<0)return e;xe.R8(" ### Fixing JSON with wikidata error code injection "+e.slice(t,t+200));const n=e.lastIndexOf("}, {");return e.slice(0,n)+" } ] } } "}async function zn(e,t,n,i){function a(n){const a=i.limit||An;return n.replace("$(name)",e).replace("$(limit)",""+a).replace("$(language)",o).replace("$(targetClass)",t.toNT())}if(!t)throw new Error("queryPublicDataByName: No class provided");const o=(await En()||yn)[0]||"en";if(i.searchByNameQuery){const e=a(i.searchByNameQuery);return xe.Rm("Querying public data - sparql: "+e),qn(e,i)}if(i.searchByNameURI){const e=a(i.searchByNameURI);let t;try{t=await(v.store.fetcher?.webOperation("GET",e,jn))}catch(t){throw new Error(`Exception when trying to fetch ${e} \n ${t}`)}const n=t.responseText||"";if(200!==t.status)throw new Error(`HTTP error status ${t.status} trying to fetch ${e} `);if(xe.Rm(" Query result text"+n.slice(0,500)+"..."),0===n.length)throw new Error("queryPublicDataByName: No text back from public data query "+e);const o=Pn(n),s=JSON.parse(o);if(xe.Rm(" API Query result JSON"+JSON.stringify(s,null,4).slice(0,500)+"..."),s._embedded){xe.Rm(" Looks like ESCO");return Un(s)}throw alert("Code me: unrecognized API return format"),new Error(`*** Need to add code to parse unrecognized API JSON return\n${JSON.stringify(s,null,4)}`)}throw new Error("Query source must have either rest API or SPARQL endpoint.")}async function qn(e,t){if(!t.endpoint)throw new Error("Missing queryTarget.endpoint required for queryPublicDataSelect");const n=new URL(t.endpoint);n.searchParams.append("query",e);const i=n.href;xe.Rm(" queryPublicDataSelect uri: "+i);const a=new Headers;a.append("Accept","application/json");const o={credentials:"omit",headers:a},s=await(v.store.fetcher?.webOperation("GET",i,o)),r=s?.responseText||"";if(0===r.length)throw new Error("No text back from query "+i);const c=Pn(r),l=JSON.parse(c);xe.Rm(" Query result JSON"+JSON.stringify(l,null,4).slice(0,100)+"...");return l.results.bindings}async function Hn(e,t,n){if(xe.Rm("queryPublicDataConstruct: sparql:",e),!n.endpoint)throw new Error("Missing queryTarget.endpoint required for queryPublicDataConstruct");const i=new URL(n.endpoint);i.searchParams.append("query",e);const a=i.href;xe.Rm(" queryPublicDataConstruct uri: "+a);const o=new Headers;o.append("Accept","text/turtle");const s={credentials:"omit",headers:o},r=await(v.store.fetcher?.webOperation("GET",a,s)),c=r?.responseText||"No response text?",l=c.length>500?c.slice(0,200)+" ... "+c.slice(-200):c;if(xe.Rm(" queryPublicDataConstruct result text:"+l),0===c.length)throw new Error("queryPublicDataConstruct: No text back from construct query:"+a);(0,g.parse)(c,v.store,t.uri,"text/turtle")}async function Vn(e,t,n){if(n.uri.startsWith("https://dbpedia.org/resource/"))return Qn(e,t,n);if(!n.uri.match(/^https?:\/\/www\.wikidata\.org\/entity\/.*/)){const t=n.uri.startsWith("http:")?e.sym("https:"+n.uri.slice(5)):n,i=new Headers;return i.append("Accept","text/turtle"),e.fetcher.load(t,{credentials:"omit",headers:i})}await Gn(e,t,n)}async function Gn(e,t,n){const i=Sn.replace(/wd:Q49108/g,n.toNT());await Hn(i,n,$n),xe.Rm("getWikidataDetails: loaded.",n)}async function Wn(e,t,n){const i='select distinct * where {\n optional { $(subject) wdt:P31 ?targetClass } # instance of\n optional { $(subject) wdt:P154 ?logo }\n optional { $(subject) wdt:P158 ?sealImage }\n# optional { $(subject) wdt:P159 ?headquartersLocation }\n\noptional { $(subject) wdt:P17 ?country }\noptional { $(subject) wdt:P18 ?image }\noptional { $(subject) wdt:P1813 ?shortName }\n\noptional { $(subject) wdt:P355 ?subsidiary }\n# SERVICE wikibase:label { bd:serviceParam wikibase:language "fr,en,de,it" }\n}'.replace(_n,n.toNT());Mn(e,n,await qn(i,$n),n.doc())}async function Jn(e,t,n){const i='select distinct * where {\n\n $(subject) wdt:P276 ?location .\n\n optional { ?location wdt:P2044 ?elevation }\n optional { ?location wdt:P131 ?region }\n optional { ?location wdt:P625 ?coordinates }\noptional { ?location wdt:P17 ?country }\n\n# SERVICE wikibase:label { bd:serviceParam wikibase:language "fr,en,de,it" }\n}'.replace(_n,n.toNT());xe.Rm(" location query sparql:"+i);const a=await qn(i,$n);xe.Rm(" location query bindings:",a),Mn(e,n,a,n.doc())}async function Qn(e,t,n){const i=`select distinct ?city, ?state, ?country, ?homepage, ?logo, ?lat, ?long, WHERE {\n OPTIONAL { <${n}> <http://dbpedia.org/ontology/city> ?city }\n OPTIONAL { ${n} <http://dbpedia.org/ontology/state> ?state }\n OPTIONAL { ${n} <http://dbpedia.org/ontology/country> ?country }\n OPTIONAL { ${n} foaf:homepage ?homepage }\n OPTIONAL { ${n} foaf:lat ?lat; foaf:long ?long }\n OPTIONAL { ${n} <http://dbpedia.org/ontology/country> ?country }\n }`;Mn(e,n,await qn(i,Rn),n.doc()),xe.Rm("Finished getDbpediaDetails.")}function Zn(e,t){e.style.display=t?"":"none"}async function Yn(e,t,n,i){function a(e,n){xe.Rm("Auto complete: finish! "+e),"Literal"===e.termType&&t.queryParams.objectURIBase&&(e=v.store.sym(t.queryParams.objectURIBase.value+e.value)),r(),i(e,n)}async function o(e,t){if(n.acceptButton)return n.acceptButton.disbaled=!1,Zn(n.acceptButton,!0),C.value=t.value,b=t,x=e,xe.Rm("Auto complete: name: "+t),xe.Rm("Auto complete: waiting for accept "+e),void r();Zn(n.cancelButton,!0),a(e,t)}async function s(e){b&&C.value===b.value&&a(x,b)}function r(){for(;y.children.length>1;)y.removeChild(y.lastChild)}function c(){t.currentObject?(C.value=t.currentName?t.currentName.value:"??? wot no name for "+t.currentObject,b=t.currentName,u=t.currentName?t.currentName.value:void 0,x=t.currentObject):(C.value="",u=void 0,x=void 0),n.deleteButton&&Zn(n.deleteButton,!!t.currentObject),n.acceptButton&&Zn(n.acceptButton,!1),n.editButton&&Zn(n.editButton,!0),n.cancelButton&&Zn(n.cancelButton,!1),m=!1,r()}const l=t.targetClass;if(!l)throw new Error("renderAutoComplete: missing targetClass");let p;n.acceptButton&&n.acceptButton.addEventListener("click",s,!1),n.cancelButton&&n.cancelButton.addEventListener("click",async function(e){xe.Rm("Auto complete: Canceled by user! "),t.permanent?c():g.parentNode&&g.parentNode.removeChild(g)},!1);let u,d=!1,m=!1,f=!1,h=20;const g=e.createElement("div");let b,x;const y=g.appendChild(e.createElement("table"));y.setAttribute("data-testid","autocomplete-table"),y.setAttribute("style","max-width: 30em; margin: 0.5em;");const w=y.appendChild(e.createElement("tr"));Ke.setStyle(w,"autocompleteRowStyle");const C=w.appendChild(e.createElement("td")).appendChild(e.createElement("input"));C.setAttribute("type","text"),c();const E=t.size||Ve||20;C.setAttribute("size",E),C.setAttribute("data-testid","autocomplete-input");const k=Ke.textInputStyle||"border: 0.1em solid #444; border-radius: 0.5em; width: 100%; font-size: 100%; padding: 0.1em 0.6em";return C.setAttribute("style",k),C.addEventListener("keyup",function(e){13===e.keyCode&&s()},!1),C.addEventListener("input",async function(i){Zn(n.cancelButton,!0),async function(){function n(t){const n=e.createElement("tr");Ke.setStyle(n,"autocompleteRowStyle"),n.setAttribute("style","padding: 0.3em;"),n.style.color=f?"#080":"#088",n.textContent=t.name.value;const i=On(t.subject),a=On(t.name);return n.addEventListener("click",async e=>{xe.Rm(" click row textContent: "+n.textContent),xe.Rm(" click name: "+a.value),i&&a&&o(i,a)}),n}function i(e,t){return t.name.value>e.name.value?1:t.name.name<e.name.value?-1:0}if(m)return void xe.Rm(`Ignoring "${C.value}" because of lock `);xe.Rm(`Setting lock at "${C.value}"`),m=!0;const a=await En(),s=C.value.trim().toLowerCase();if(s.length<4)r(),h=20;else{f&&u&&s.startsWith(u)||(xe.Rm(` Querying database at "${s}" cf last "${u}".`),p=await async function(n,i){let a;try{a=await zn(n,l,0,t.queryParams)}catch(t){return function(t){const n=y.appendChild(e.createElement("tr"));xe.Rm(t);const i=new Error(t);n.appendChild(nt(e,i,"pink")),Ke.setStyle(n,"autocompleteRowStyle"),n.style.padding="1em"}("Error querying db of organizations: "+t),void(m=!1)}d=a.length<An,u=d?n:void 0;r();const o=kn(a,i);return o}(s,a));const c=function(e,t){return t.filter(t=>function(e,t){const n=e.split(" ");for(let e=0;e<n.length;e++){const i=n[e];if(t.toLowerCase().indexOf(i)<0)return!1}return!0}(e,t.name.value))}(s,p);d&&c.length<=40&&(h=c.length),f=d&&c.length<=h,xe.Rm(` Filter:"${s}" lastBindings: ${p.length}, slimmed to ${c.length}; rows: ${h}, Enough? ${d}, All displayed? ${f}`);const g=c.slice(0,h);g.sort(i),r();for(const e of g)y.appendChild(n(e));1===c.length&&o(On(c[0].subject),On(c[0].name))}m=!1}()}),g}const Kn=it.Pt.iconBase+"noun_34653_green.svg",Xn=it.Pt.iconBase+"noun_Search_875351.svg",ei=it.Pt.iconBase+"noun_253504.svg";async function ti(e,t,n,i,a,o){async function s(e,t){return i.permanent?(Zn(m,!0),Zn(c,!1),Zn(l,!1)):x&&(y.removeChild(x),x=void 0),a(e,t)}async function r(){x=e.createElement("div"),x.setAttribute("style","display: flex; flex-flow: wrap;"),x.appendChild(await Yn(e,i,g,s)),x.appendChild(c),x.appendChild(l),x.appendChild(m),x.appendChild(p),y.appendChild(x)}const c=Mt(e);c.setAttribute("data-testid","accept-button");const l=Ot(e);l.setAttribute("data-testid","cancel-button");const p=e.createElement("div"),u=i.targetClass?F(i.targetClass):"item",d=Bt(e,p,u,o);d.setAttribute("data-testid","delete-button");const m=Dt(e,ei,"Edit",e=>{f=!f,h()});m.setAttribute("data-testid","edit-button");let f=!0;function h(){f?(Zn(m,!1),Zn(c,!1),Zn(l,!1)):(Zn(m,!0),Zn(c,!1),Zn(l,!1))}const g={acceptButton:c,cancelButton:l,editButton:m,deleteButton:d};let x;const y=e.createElement("div");if(y.style.display="flex",y.style.flexDirection="row",(i.permanent||i.currentObject)&&await r(),n.editable){if(y.style.width="100%",n.manualURIEntry){Xe(y.appendChild(Dt(e,Kn,n.idNoun,async function(n){const i=await Ut(e,v.store,y,b.vcard("url"),void 0,"Solid ID");if(i)return a(t,i)})),async function(e){for(const n of e)await a(t,n)},void 0)}!n.dbLookup||i.currentObject||i.permanent||y.appendChild(Dt(e,Xn,n.idNoun,async function(e){x?(y.removeChild(x),x=void 0):await r()}))}return h(),y}
4
4
  /**
5
5
  * @version IconicMultiSelect v0.7.0
6
6
  * @licence MIT
7
7
  */
8
- const oi={multiselect__container:"\n -webkit-box-align: center;\n -ms-flex-align: center;\n align-items: center;\n background-color: #fff;\n border-radius: 2px;\n -webkit-box-shadow: 0 1px 3px 0 #d1d1d2, 0 0 0 1px #d1d1d2;\n box-shadow: 0 1px 3px 0 #d1d1d2, 0 0 0 1px #d1d1d2;\n -webkit-box-sizing: border-box;\n box-sizing: border-box;\n display: -webkit-box;\n display: -ms-flexbox;\n display: flex;\n min-height: 36px;\n padding: 4px 8px 0 8px;\n position: relative;\n width: 354px;\n margin-bottom: 5px;\n font-size: 100%\n ",multiselect__wrapper:"\n display: -webkit-box;\n display: -ms-flexbox;\n display: flex;\n -ms-flex-wrap: wrap;\n flex-wrap: wrap;\n height: 100%;\n width: 100%;\n ",multiselect__clear_btn:"\n cursor: pointer;\n align-items: center;\n margin-bottom: 4px;\n margin-left: 4px;\n ",multiselect__options:"\n background-color: #f6f6f6;\n border-radius: 2px;\n left: 0;\n max-height: 0;\n overflow: hidden;\n position: absolute;\n top: calc(100% + 3px);\n z-index: 9999;\n width: 100%;\n opacity: 0;\n transition: max-height 0.1s ease;\n ",multiselect__options_visible:"\n background-color: #f6f6f6;\n border-radius: 2px;\n left: 0;\n max-height: 0;\n overflow: hidden;\n position: absolute;\n top: calc(100% + 3px);\n z-index: 9999;\n width: 100%;\n opacity: 0;\n transition: max-height 0.1s ease;\n max-height: 200px;\n -webkit-box-shadow: 0 1px 3px 0 #d1d1d2, 0 0 0 1px #d1d1d2;\n box-shadow: 0 1px 3px 0 #d1d1d2, 0 0 0 1px #d1d1d2;\n opacity: 1;\n transition: max-height 0.2s ease;\n ",multiselect__options_ul:"\n list-style: none;\n margin: 0;\n padding: 2px 0;\n max-height: 200px;\n overflow: auto;\n ",multiselect__options_ul_li:"\n cursor: pointer;\n padding: 4px 8px;\n ",multiselect__options_ul_li_hover:"\n background-color: #dedede;\n ",multiselect__options_ul_p_multiselect__options_no_results:"\n margin: 0;\n padding: 8px;\n text-align: center;\n ",multiselect__options_ul_p_multiselect__options_no_data:"\n margin: 0;\n padding: 8px;\n text-align: center;\n ",multiselect__options_ul_li_multiselect__options_selected:"\n background-color: #656565;\n color: #fff;\n ",multiselect__options_ul_li_multiselect__options_selected_hover:"\n background-color: #656565;\n ",multiselect__options_ul_li_arrow_selected:"\n border: 2px solid rgba(101, 101, 101, 0.5);\n ",multiselect__selected:"\n background-color: #656565;\n border-radius: 2px;\n color: #fff;\n margin-bottom: 4px;\n margin-right: 4px;\n padding: 4px 8px;\n display: -webkit-box;\n display: -ms-flexbox;\n display: flex;\n -webkit-box-align: center;\n -ms-flex-align: center;\n align-items: center;\n ",multiselect__selected_multiselect__remove_btn:"\n cursor: pointer;\n display: flex;\n margin-left: 6px;\n ",multiselect__input:"\n border: none;\n -ms-flex-preferred-size: 40%;\n flex-basis: 40%;\n -webkit-box-flex: 1;\n -ms-flex-positive: 1;\n flex-grow: 1;\n height: 5px; \n margin-bottom: 4px;\n min-width: 40%;\n outline: none; \n ",setStyle:function(e,t){e.style=oi[t]}};
8
+ const ni={multiselect__container:"\n -webkit-box-align: center;\n -ms-flex-align: center;\n align-items: center;\n background-color: #fff;\n border-radius: 2px;\n -webkit-box-shadow: 0 1px 3px 0 #d1d1d2, 0 0 0 1px #d1d1d2;\n box-shadow: 0 1px 3px 0 #d1d1d2, 0 0 0 1px #d1d1d2;\n -webkit-box-sizing: border-box;\n box-sizing: border-box;\n display: -webkit-box;\n display: -ms-flexbox;\n display: flex;\n min-height: 36px;\n padding: 4px 8px 0 8px;\n position: relative;\n width: 354px;\n margin-bottom: 5px;\n font-size: 100%\n ",multiselect__wrapper:"\n display: -webkit-box;\n display: -ms-flexbox;\n display: flex;\n -ms-flex-wrap: wrap;\n flex-wrap: wrap;\n height: 100%;\n width: 100%;\n ",multiselect__clear_btn:"\n cursor: pointer;\n align-items: center;\n margin-bottom: 4px;\n margin-left: 4px;\n ",multiselect__options:"\n background-color: #f6f6f6;\n border-radius: 2px;\n left: 0;\n max-height: 0;\n overflow: hidden;\n position: absolute;\n top: calc(100% + 3px);\n z-index: 9999;\n width: 100%;\n opacity: 0;\n transition: max-height 0.1s ease;\n ",multiselect__options_visible:"\n background-color: #f6f6f6;\n border-radius: 2px;\n left: 0;\n max-height: 0;\n overflow: hidden;\n position: absolute;\n top: calc(100% + 3px);\n z-index: 9999;\n width: 100%;\n opacity: 0;\n transition: max-height 0.1s ease;\n max-height: 200px;\n -webkit-box-shadow: 0 1px 3px 0 #d1d1d2, 0 0 0 1px #d1d1d2;\n box-shadow: 0 1px 3px 0 #d1d1d2, 0 0 0 1px #d1d1d2;\n opacity: 1;\n transition: max-height 0.2s ease;\n ",multiselect__options_ul:"\n list-style: none;\n margin: 0;\n padding: 2px 0;\n max-height: 200px;\n overflow: auto;\n ",multiselect__options_ul_li:"\n cursor: pointer;\n padding: 4px 8px;\n ",multiselect__options_ul_li_hover:"\n background-color: #dedede;\n ",multiselect__options_ul_p_multiselect__options_no_results:"\n margin: 0;\n padding: 8px;\n text-align: center;\n ",multiselect__options_ul_p_multiselect__options_no_data:"\n margin: 0;\n padding: 8px;\n text-align: center;\n ",multiselect__options_ul_li_multiselect__options_selected:"\n background-color: #656565;\n color: #fff;\n ",multiselect__options_ul_li_multiselect__options_selected_hover:"\n background-color: #656565;\n ",multiselect__options_ul_li_arrow_selected:"\n border: 2px solid rgba(101, 101, 101, 0.5);\n ",multiselect__selected:"\n background-color: #656565;\n border-radius: 2px;\n color: #fff;\n margin-bottom: 4px;\n margin-right: 4px;\n padding: 4px 8px;\n display: -webkit-box;\n display: -ms-flexbox;\n display: flex;\n -webkit-box-align: center;\n -ms-flex-align: center;\n align-items: center;\n ",multiselect__selected_multiselect__remove_btn:"\n cursor: pointer;\n display: flex;\n margin-left: 6px;\n ",multiselect__input:"\n border: none;\n -ms-flex-preferred-size: 40%;\n flex-basis: 40%;\n -webkit-box-flex: 1;\n -ms-flex-positive: 1;\n flex-grow: 1;\n height: 5px; \n margin-bottom: 4px;\n min-width: 40%;\n outline: none; \n ",setStyle:function(e,t){e.style=ni[t]}};
9
9
  /**
10
10
  * @version IconicMultiSelect v0.7.0
11
11
  * @licence MIT
12
12
  */
13
- class si{_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="${oi.multiselect__selected}" data-value="${e.value}">${this._tagTemplate?this._processTemplate(this._tagTemplate,t):e.text}<span class="multiselect__remove-btn" style="${oi.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",oi.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",oi.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",oi.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",oi.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",oi.multiselect__options_ul_li_arrow_selected),void n.firstElementChild.scrollIntoView(!1);if(t.classList.remove("arrow-selected"),t.setAttribute("style",oi.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",oi.multiselect__options_ul_li_arrow_selected),void this._scrollIntoView(n,t);t.classList.add("arrow-selected"),t.setAttribute("style",oi.multiselect__options_ul_li_arrow_selected),this._scrollIntoView(n,t)}else this._domElements.optionsContainer.classList.add("visible"),this._domElements.optionsContainer.setAttribute("style",oi.multiselect__options_visible),n.firstElementChild.classList.add("arrow-selected"),n.firstElementChild.setAttribute("style",oi.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",oi.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",oi.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",oi.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",oi.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",oi.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="${oi.multiselect__options}">\n <ul style="${oi.multiselect__options_ul}">\n ${this._options.length>0&&!this._itemTemplate?this._options.map(e=>`\n <li data-value="${e.value}" style="${oi.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="${oi.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",oi.multiselect__container);const t=`\n <div class="multiselect__wrapper" style="${oi.multiselect__wrapper}">\n <input class="multiselect__input" style="${oi.multiselect__input}" placeholder="${this._placeholder}" />\n </div>\n <span style="display: none;" class="multiselect__clear-btn" style="${oi.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="${oi.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="${oi.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 ri=v.store;function ci(e,t,n,i,a,o,s){const r=o.children;for(let c=0;c<s.length;c++){const l=s[c];if(fn(l)===b.ui("Options").uri){const s=hn(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 li(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=ot(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=yn(i,p,o);let d=l.any(i,p);void 0===d&&(d=!1);const m=g.st(i,p,!0,o),f=Ai(e,l,u,g.st(i,p,!1,o),m,a,o,r);return t&&t.appendChild(f),f}function pi(e,t,n,i,a,o,s){hn(0,a)(e,t,n,i,a,o,s)}function ui(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){di(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 di(e,t,n,i,a,o,s){return hn(0,a)(e,t,n,i,a,o,s)}function mi(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 fi(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 hi(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(fi(t,e,b.ui("creationForm"))),o=o.concat(fi(t,e,b.ui("annotationForm")));return o}function gi(e){const t=e.map(function(e){return[ri.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 bi(e){const t=e.map(function(e){return[F(e).toLowerCase(),e]});return t.sort(),t.map(function(e){return e[1]})}function vi(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(xi(e,t,n,i,a,o,s,r))},!1),c}function xi(e,t,n,i,a,o,s,r){const c=e.createElement("form");if(!o){const n=fi(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 ${Ge}; color: ${Ge}`),c.innerHTML="<h3>New "+F(a)+"</h3>";const l=hn(0,o),p=_i(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(en(e,p)))});return tn(e,m).setAttribute("style","float: right;"),c.AJAR_subject=p,c}function yi(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=Ye;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=Ze,c.disabled=!1):s.appendChild(ot(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",tt.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=Pt(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=Qe),s}function wi(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 ot(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=xi(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=_i(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(ot(e,"Error updating data in select: "+i));if(f.disabled=!1,m){hn(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",tt.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 Ci(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 ot(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(ot(e,"Error updating data in select: "+i));f.disabled=!1,r&&r(n,{widget:"select",event:"change"})})},f=e.createElement("select");f.setAttribute("style",tt.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 Ei(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?ot(e,"Can't do "+(c?"multiple ":"")+"selector with no subclasses of category: "+i):1===r.length?ot(e,"Can't do "+(c?"multiple ":"")+"selector with only 1 subclass of category: "+i+":"+r[1]):wi(e,t,n,b.rdf("type"),r,{multiple:c,nullLabel:"* Select type *"},a,o)}function ki(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=ki(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=Ei(e,t,n,i,a,function(e,t){e&&s(),o(e,t)});return r.appendChild(l),s(),r}function Ai(e,t,n,i,a,o,s,r){const c=e.createElement("div"),l=vn(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=tt.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(ot(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;return u.addEventListener("click",function(n){d.style.color="#bbb";const o=!0===u.state?a:!1===u.state?i:[];u.newState=null===u.state||!0!==u.state&&(!r||null);const s=!0===u.newState?a:!1===u.newState?i:[];xe.Rm(` Deleting ${o}`),xe.Rm(` Inserting ${s}`),t.updater.update(o,s,function(n,i,a){if(i)d.style.color="#000",u.state=u.newState,u.textContent={true:"✓",false:"✕",null:"-"}[u.state];else{if(o.why){t.holds(o.subject,o.predicate,o.object,o.why)&&xe.Rm(" @@@@@ weird if 409 - does hold statement")}d.style.color="#000",d.style.backgroundColor="#fee",c.appendChild(ot(e,`Checkbox: Error updating dataDoc from ${u.state} to ${u.newState}:\n\n${a}`))}})},!1),c}function _i(e){const t=new Date;return g.sym(e.uri+"#id"+t.getTime())}function Ti(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 ot(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",tt.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,Si(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)Si(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(ot(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=xi(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=_i(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&&Si(d.AJAR_uri,s)&&(f.currentURI=d.AJAR_uri),Si(d.AJAR_uri,s)||d.removeAttribute("selected"),Si(d.AJAR_uri,s)&&d.setAttribute("selected","true"))}S("selectForOptions: data doc = "+l),f.currentURI&&c.subForm&&!c.multiSelect&&pi(e,t,{},g.sym(f.currentURI),c.subForm,l,function(i,a){i?(n.updater.update([],u,function(n,i,a){i||t.appendChild(ot(e,"Error updating select: "+a))}),p&&p(i,{widget:"select",event:"new"})):t.appendChild(ot(e,"Error updating data in field of select: "+a))}),f.disabled=!1},d&&f.addEventListener("change",m,!1),f}function Si(e,t){let n;for(n=0;n<t.length;n++)if(t[n]===e)return!0;return!1}mn[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",tt.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(ot(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(ot(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(ot(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(ot(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(xn(e,d,a)),ai(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(ot(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(ot(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(ot(e,n,null,t))}s(!0,"")}).then(e=>{u.appendChild(e)},t=>{u.appendChild(ot(e,`Error rendering autocomplete ${a}: ${t}`,"#fee",t))}),l},mn[b.ui("Form").uri]=mn[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=ri.any(a,c("weight"),null,u),m=d?Number(d.value):1;if(m>3||m<0)return r.appendChild(ot(e,`Form Group weight ${m} should be 0-3`));r.setAttribute("style",tt.formGroupStyle[m]),r.style.display="flex",r.style.flexDirection="column",r.class="form-weight-"+m;let f,h=ri.any(a,c("parts"),null,u);if(h?f=h.elements:(h=ri.each(a,c("part"),null,u),f=gi(h)),!h)return r.appendChild(ot(e,"No parts to form! "));for(let t=0;t<f.length;t++){const a=f[t],c=hn(0,a),l=function(t,a){t&&a&&a.widget&&"select"===a.widget&&ci(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},mn[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(ot(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(ot(e,'No "use" part for case in form '+a)),c;di(e,c,n,i,t,o,s);break}}return c},mn[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=_i(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(ot(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=hn(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)&&(Mt(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(ot(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=Ut(e,st.Pt.iconBase+"noun_1369237.svg","Move Up",async e=>a(0,!0)),i=Ut(e,st.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=st.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(ot(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(ot(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(ot(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},mn[b.ui("PhoneField").uri]=wn,mn[b.ui("EmailField").uri]=wn,mn[b.ui("ColorField").uri]=wn,mn[b.ui("DateField").uri]=wn,mn[b.ui("DateTimeField").uri]=wn,mn[b.ui("TimeField").uri]=wn,mn[b.ui("NumericField").uri]=wn,mn[b.ui("IntegerField").uri]=wn,mn[b.ui("DecimalField").uri]=wn,mn[b.ui("FloatField").uri]=wn,mn[b.ui("TextField").uri]=wn,mn[b.ui("SingleLineTextField").uri]=wn,mn[b.ui("NamedNodeURIField").uri]=wn,mn[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 ot(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=We;const m=u.appendChild(e.createElement("div"));d.appendChild(xn(e,p,a)),o=yn(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=yi(e,c,i,p,o,s);return m.appendChild(x),t&&t.appendChild(u),u},mn[b.ui("BooleanField").uri]=function(e,t,n,i,a,o,s){return li(e,t,0,i,a,o,0,!1)},mn[b.ui("TristateField").uri]=function(e,t,n,i,a,o,s){return li(e,t,0,i,a,o,0,!0)},mn[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 ot(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(xn(e,l,a)),p.appendChild(u);const d=e.createElement("div");d.setAttribute("class","formFieldValue classifierBox-selectBox");const m=ki(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=tt.textInputStyleUneditable})}return d.appendChild(m),p.appendChild(d),t&&t.appendChild(p),p},mn[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(ot(e,"No property for Choice: "+a));d.appendChild(xn(e,f,a));const h=c.any(a,r("from"));if(!h)return ot(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 Kt())n.push(c.sym(p));else if(h.sameTerm(b.rdf("Property"))){for(p in t=Xt(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=Xt(c),t.op)n.push(c.fromNT(p));y.disambiguate=!0}else if(h.sameTerm(b.owl("DatatypeProperty"))){for(p in t=Xt(c),t.dp)n.push(c.fromNT(p));y.disambiguate=!0}return n}(C);if(n.push(t),n=bi(n),E=Ti(e,m,c,i,f,n,t,h,y,o,s),m.innerHTML="",m.appendChild(E),w){const n=new si({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=_i(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&&pi(e,m,{},g.sym(n),x,o,function(i,o){i?(c.updater.update([],a,function(t,n,i){n||m.appendChild(ot(e,"Error updating select: "+i))}),t.push(n),s&&s(i,{widget:"select",event:"new"})):m.appendChild(ot(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},mn[b.ui("Comment").uri]=mn[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=fn(a),d=un[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=fn(t),i=un[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(gn)){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 ji={authEndpoint:"",fallbackAuthEndpoint:"https://databox.me/",signupEndpoint:"https://solidproject.org/get_a_pod",signupWindowHeight:600,signupWindowWidth:1024,key:"",cert:""};function Li(e){this.config=e||ji}Li.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)})},Li.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:Ri,loadProfile:Ni}=v.solidLogicSingleton.profile,{getScopedAppInstances:Ii,getRegistrations:$i,loadAllTypeIndexes:Bi,getScopedAppsFromIndex:Di,deleteTypeIndexRegistration:Oi}=v.solidLogicSingleton.typeIndex;function Mi(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=Wi(e.dom,n=>{v.authn.saveUser(n,e),t(e)});e.div.appendChild(i)})})}async function Ui(e){if(e.preferencesFile)return Promise.resolve(e);let t;try{e=await Fi(e);const n=await Ri(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 Fi(e){if(e.publicProfile)return e;try{const t=await Mi(e);if(!t.me)throw new Error("Could not log in");e.publicProfile=await Ni(t.me)}catch(t){throw e.div&&e.dom&&e.div.appendChild(ot(e.dom,t.message)),new Error(`Can't log in: ${t}`)}return e}async function Pi(e,t,n){let i=e.me?await Ii(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 zi(e,t){return`${e.me&&e.me.sameTerm(t.agent)?"":F(t.agent)+" "}${t.label}`}async function qi(e,t,n){function i(i){const a=function(e){const i=$i(t,n),a=i.length?i[0]:_i(e);return[(0,g.st)(a,b.solid("instance"),t,e),(0,g.st)(a,b.solid("forClass"),n,e)]}(i.index),o=`${zi(e,i)} link to this ${e.noun}`;return Ai(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 Bi(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(ot(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 Hi(e,t,n){const{dom:i}=e,a=zi(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 Vi(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 Bi(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=Hi(e,0,i);s.appendChild(a);const o=await Di(i,t.type||null);0===o.length&&(a.style.display="none");for(const e of o){const t=qt(n,b.solid("instance"),e.instance,{deleteFunction:async()=>{await Oi(e),s.removeChild(t)}});t.children[0].style.paddingLeft="3em",s.appendChild(t)}}return e}function Gi(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 Wi(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)&&(Et(a),i?a.appendChild(function(t,n){const i=n.buttonStyle||tt.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||tt.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}${tt.headerBannerLoginInput}`+tt.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(ot(e,t))}}}}),s.addEventListener("click",()=>{const n=(0,v.offlineTestID)();if(n)return t(n.uri);Gi(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}${tt.headerBannerLoginInput}`+tt.signInBackground),r.addEventListener("click",function(e){(new Li).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 Ji(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(ot(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 Ui(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",tt.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",tt.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",tt.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 zt(e,v.solidLogicSingleton.store,i,b.solid("URL"),b.space("Workspace"),"Workspace")),o=_i(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(ot(r.dom,e))}),s}function Qi(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(Ji(e,t,i))},!1),a.appendChild(o),a}async function Zi(){try{const{me:e,preferencesFile:t,preferencesFileError:n}=await Ui({});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 Yi(e){const t=await Zi();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 Ki{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 Ut(this.groupList.controller.dom,`${st.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 Ut(this.groupList.controller.dom,st.Pt.iconBase+Rt["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 Ut(this.groupList.controller.dom,st.Pt.iconBase+Rt["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 zt(this.groupList.controller.dom,this.groupList.store,this.barElement,b.vcard("URI"),e,t)}renderPublicButton(){return Ut(this.groupList.controller.dom,st.Pt.iconBase+Rt["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 Ut(this.groupList.controller.dom,`${st.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 Ut(this.groupList.controller.dom,st.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 Ut(this.groupList.controller.dom,`${st.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",tt.trustedAppController);const n=Ft(this.groupList.controller.dom,()=>this.renderCleanup());n.setAttribute("style",tt.trustedAppCancelButton),t.insertBefore(n,t.firstChild),this.barElement.appendChild(t)}}async renderAppsTable(e){await Fi(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",tt.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=qt(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(Pt(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 Xi=b.acl,ea={13:"Owners",9:"Owners (write locked)",5:"Editors",3:"Posters",2:"Submitters",1:"Viewers"},ta={13:!0,5:!0,3:!0,2:!0,1:!0},na={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 ia{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 Ki(this),this.rootElement=this.controller.dom.createElement("div"),this.rootElement.setAttribute("style",tt.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=aa(t);(this.controller.isEditable&&ta[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",tt.accessGroupListItem),nt(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",tt.group),this.controller.isEditable)switch(e){case 1:n.setAttribute("style",tt.group1);break;case 2:n.setAttribute("style",tt.group2);break;case 3:n.setAttribute("style",tt.group3);break;case 5:n.setAttribute("style",tt.group5);break;case 9:n.setAttribute("style",tt.group9);break;case 13:n.setAttribute("style",tt.group13);break;default:n.setAttribute("style",tt.group)}n.innerText=ea[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",tt.group),this.controller.isEditable)switch(e){case 1:i.setAttribute("style",tt.group1);break;case 2:i.setAttribute("style",tt.group2);break;case 3:i.setAttribute("style",tt.group3);break;case 5:i.setAttribute("style",tt.group5);break;case 9:i.setAttribute("style",tt.group9);break;case 13:i.setAttribute("style",tt.group13);break;default:i.setAttribute("style",tt.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",tt.group),this.controller.isEditable)switch(e){case 1:o.setAttribute("style",tt.group1);break;case 2:o.setAttribute("style",tt.group2);break;case 3:o.setAttribute("style",tt.group3);break;case 5:o.setAttribute("style",tt.group5);break;case 9:o.setAttribute("style",tt.group9);break;case 13:o.setAttribute("style",tt.group13);break;default:o.setAttribute("style",tt.group)}return o.innerText=na[e]||"Unusual combination",[n,i,o]}renderAgent(e,t,n,i){const a=qt(this.controller.dom,Xi(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,aa(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[aa(t)];if(n)for(let t=0;t<n.length;t++)for(;t<n.length&&n[t][1]===e;)n.splice(t,1)}}}function aa(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 oa{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",tt.aclGroupContent),this.isContainer="/"===o.uri.slice(-1),r&&c){this.isUsingDefaults=!0;const e=we(this.targetDoc,s,r,c);this.mainCombo=new ia(o,s,this,e,{defaults:this.isContainer}),this.defaultsCombo=null,this.defaultsDiffer=!1}else this.isUsingDefaults=!1,this.mainCombo=new ia(o,s,this,p),this.defaultsCombo=new ia(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=pa(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",tt.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",tt.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",tt.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",tt.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",tt.bigButton),n.addEventListener("click",()=>this.addDefaults().then(()=>this.render())),e}renderRemoveDefaultsController(){const e=this.dom.createElement("div");e.setAttribute("style",tt.defaultsController);const t=e.appendChild(this.dom.createElement("div"));t.innerText="Access to things within this folder:",t.setAttribute("style",tt.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",tt.bigButton),n.addEventListener("click",()=>this.removeDefaults().then(()=>this.render()).catch(e=>this.renderStatus(e))),e}renderTemporaryStatus(e){this.statusElement.setAttribute("style",tt.aclControlBoxStatusRevealed),this.statusElement.innerText=e,this.statusElement.setAttribute("style",tt.temporaryStatusInit),setTimeout(()=>{this.statusElement.setAttribute("style",tt.temporaryStatusEnd)}),setTimeout(()=>{this.statusElement.innerText=""},5e3)}renderStatus(e){e||this.statusElement.setAttribute("style",tt.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 ia(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 sa=window;const ra=Symbol("prevent double triggering of drop event");function ca(e){e.stopPropagation(),e.preventDefault()}function la(e){e.dataTransfer.files.length>0&&(sa.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 pa(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 ua={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},da={preventBrowserDropEvents:function(e){if((0,xe.Rm)("preventBrowserDropEvents called."),void 0!==sa){if(sa[ra])return;sa[ra]=!0}e.addEventListener("drop",la,!1),e.addEventListener("dragenter",ca,!1),e.addEventListener("dragover",ca,!1)},shortNameForFolder:pa,ACLControlBox5:function(e,t,n,i){const a=t.dom,o=e.doc(),s=a.createElement("div");s.setAttribute("style",tt.aclControlBoxContainer);const r=s.appendChild(a.createElement("h1"));r.textContent=`Sharing for ${n} ${F(e)}`,r.setAttribute("style",tt.aclControlBoxHeader);const c=s.appendChild(a.createElement("div"));c.setAttribute("style",tt.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 oa(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}},ma=v.solidLogicSingleton.store;const fa={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",st.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){Fi(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?ma.add(e.folder,b.ldp("contains"),ma.sym(e.newBase),e.folder.doc()):ma.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()};zt(i,0,u.div,b.foaf("name"),null,u.noun).then(e)}else o=Ji(i,{noun:u.noun,appPathSegment:u.appPathSegment},s),u.div.appendChild(o)})})})}},ha=v.solidLogicSingleton.store;const ga={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&&ha.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}}(),ha.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 ha.query(t,h,void 0,s),r}},ba=st.Pt.iconBase+"noun_Camera_1618446_000000.svg",va=st.Pt.iconBase+"noun_479395.svg";function xa(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(Ft(e)).addEventListener("click",e=>{b(),i(null)});const d=u.appendChild(e.createElement("td")).appendChild(Ut(e,va,"Retake"));d.addEventListener("click",e=>{p.removeChild(c),h()}),d.style.visibility="collapse";const m=u.appendChild(e.createElement("td")).appendChild(Ut(e,st.Pt.iconBase+"noun_10636.svg","Snap"));m.addEventListener("click",function(){c=e.createElement("canvas"),c.setAttribute("width",tt.canvasWidth),c.setAttribute("height",tt.canvasHeight),c.setAttribute("style",tt.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(Pt(e));function h(){if(r=p.appendChild(e.createElement("video")),r.setAttribute("controls","1"),r.setAttribute("autoplay","1"),r.setAttribute("style",tt.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 ya={cameraCaptureControl:xa,cameraButton:function(e,t,n,i){const a=e.createElement("div"),o=Ut(e,ba,"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=xa(e,t,n,r),a.appendChild(s)}),a}},wa={icons:st.Pt,ns:b,rdf:g,style:tt,widgets:r};async function Ca(e){return await v.store.fetcher.load(e),!(v.store.statementsMatching(null,b.dct("created"),null,e).length>0)}class Ea{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 Ca(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 ka(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 Aa(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 _a(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 Ta(...e){for(let t=0;t<e.length;t++)e[t].fill(0)}function Sa(e){return new DataView(e.buffer,e.byteOffset,e.byteLength)}function ja(e,t){return e<<32-t|e>>>t}const La=(()=>"function"==typeof Uint8Array.from([]).toHex&&"function"==typeof Uint8Array.fromHex)(),Ra=Array.from({length:256},(e,t)=>t.toString(16).padStart(2,"0"));function Na(e){if(Aa(e),La)return e.toHex();let t="";for(let n=0;n<e.length;n++)t+=Ra[e[n]];return t}const Ia=48,$a=57,Ba=65,Da=70,Oa=97,Ma=102;function Ua(e){return e>=Ia&&e<=$a?e-Ia:e>=Ba&&e<=Da?e-(Ba-10):e>=Oa&&e<=Ma?e-(Oa-10):void 0}function Fa(e){if("string"!=typeof e)throw new TypeError("hex string expected, got "+typeof e);if(La)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=Ua(e.charCodeAt(a)),o=Ua(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 Pa(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 za(e=32){ka(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 qa=e=>({oid:Uint8Array.from([6,9,96,134,72,1,101,3,4,2,e])});function Ha(e,t,n){return e&t^~e&n}function Va(e,t,n){return e&t^e&n^t&n}class Ga{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=Sa(this.buffer)}update(e){_a(this),Aa(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=Sa(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){_a(this),function(e,t){Aa(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,Ta(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=Sa(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 Wa=Uint32Array.from([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]);const Ja=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]),Qa=new Uint32Array(64);class Za extends Ga{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)Qa[n]=e.getUint32(t,!1);for(let e=16;e<64;e++){const t=Qa[e-15],n=Qa[e-2],i=ja(t,7)^ja(t,18)^t>>>3,a=ja(n,17)^ja(n,19)^n>>>10;Qa[e]=a+Qa[e-7]+i+Qa[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+(ja(s,6)^ja(s,11)^ja(s,25))+Ha(s,r,c)+Ja[e]+Qa[e]|0,p=(ja(n,2)^ja(n,13)^ja(n,22))+Va(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(){Ta(Qa)}destroy(){this.destroyed=!0,this.set(0,0,0,0,0,0,0,0),Ta(this.buffer)}}class Ya extends Za{A=0|Wa[0];B=0|Wa[1];C=0|Wa[2];D=0|Wa[3];E=0|Wa[4];F=0|Wa[5];G=0|Wa[6];H=0|Wa[7];constructor(){super(32)}}const Ka=Pa(()=>new Ya,qa(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)}}}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));
14
14
  /*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */
15
- const Xa=(e,t,n)=>Aa(e,t,n),eo=ka,to=Na,no=(...e)=>function(...e){let t=0;for(let n=0;n<e.length;n++){const i=e[n];Aa(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),io=BigInt(0),ao=BigInt(1);function oo(e,t=""){if("boolean"!=typeof e){throw new TypeError((t&&`"${t}" `)+"expected boolean, got type="+typeof e)}return e}function so(e){if("bigint"==typeof e){if(!ho(e))throw new RangeError("positive bigint expected, got "+e)}else eo(e);return e}function ro(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 co(e){const t=so(e).toString(16);return 1&t.length?"0"+t:t}function lo(e){if("string"!=typeof e)throw new TypeError("hex string expected, got "+typeof e);return""===e?io:BigInt("0x"+e)}function po(e){return lo(Na(e))}function uo(e){return lo(Na(function(e){return Uint8Array.from(Xa(e))}(Aa(e)).reverse()))}function mo(e,t){if(ka(t),0===t)throw new RangeError("zero length");const n=(e=so(e)).toString(16);if(n.length>2*t)throw new RangeError("number too large");return Fa(n.padStart(2*t,"0"))}function fo(e,t){return mo(e,t).reverse()}const ho=e=>"bigint"==typeof e&&io<=e;function go(e,t,n,i){if(!function(e,t,n){return ho(e)&&ho(t)&&ho(n)&&t<=e&&e<n}(t,n,i))throw new RangeError("expected valid "+e+": "+n+" <= n < "+i+", got "+t)}function bo(e){if(e<io)throw new Error("expected non-negative bigint, got "+e);let t;for(t=0;e>io;e>>=ao,t+=1);return t}const vo=e=>(ao<<BigInt(e))-ao;function xo(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 yo=BigInt(0),wo=BigInt(1),Co=BigInt(2),Eo=BigInt(3),ko=BigInt(4),Ao=BigInt(5),_o=BigInt(7),To=BigInt(8),So=BigInt(9),jo=BigInt(16);function Lo(e,t){if(t<=yo)throw new Error("mod: expected positive modulus, got "+t);const n=e%t;return n>=yo?n:t+n}function Ro(e,t,n){if(t<yo)throw new Error("pow2: expected non-negative exponent, got "+t);let i=e;for(;t-- >yo;)i*=i,i%=n;return i}function No(e,t){if(e===yo)throw new Error("invert: expected non-zero number");if(t<=yo)throw new Error("invert: expected positive modulus, got "+t);let n=Lo(e,t),i=t,a=yo,o=wo,s=wo,r=yo;for(;n!==yo;){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!==wo)throw new Error("invert: does not exist");return Lo(a,t)}function Io(e,t,n){const i=e;if(!i.eql(i.sqr(t),n))throw new Error("Cannot find square root")}function $o(e,t){const n=e,i=(n.ORDER+wo)/ko,a=n.pow(t,i);return Io(n,a,t),a}function Bo(e,t){const n=e,i=(n.ORDER-Ao)/To,a=n.mul(t,Co),o=n.pow(a,i),s=n.mul(t,o),r=n.mul(n.mul(s,Co),o),c=n.mul(s,n.sub(r,n.ONE));return Io(n,c,t),c}function Do(e){if(e<Eo)throw new Error("sqrt is not defined for small field");let t=e-wo,n=0;for(;t%Co===yo;)t/=Co,n++;let i=Co;const a=Ho(e);for(;1===Po(a,i);)if(i++>1e3)throw new Error("Cannot find square root: probably non-prime P");if(1===n)return $o;let o=a.pow(i,t);const s=(t+wo)/Co;return function(e,i){const a=e;if(a.is0(i))return i;if(1!==Po(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=wo<<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 Oo(e){return e%ko===Eo?$o:e%To===Ao?Bo:e%jo===So?function(e){const t=Ho(e),n=Do(e),i=n(t,t.neg(t.ONE)),a=n(t,i),o=n(t,t.neg(i)),s=(e+_o)/jo;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 Io(n,f,t),f}}(e):Do(e)}const Mo=["create","isValid","is0","neg","inv","sqrt","sqr","eql","add","sub","mul","pow","div","addN","subN","mulN","sqrN"];function Uo(e,t,n){const i=e;if(n<yo)throw new Error("invalid exponent, negatives unsupported");if(n===yo)return i.ONE;if(n===wo)return t;let a=i.ONE,o=t;for(;n>yo;)n&wo&&(a=i.mul(a,o)),o=i.sqr(o),n>>=wo;return a}function Fo(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 Po(e,t){const n=e,i=(n.ORDER-wo)/Co,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 zo=new WeakMap;class qo{ORDER;BITS;BYTES;isLE;ZERO=yo;ONE=wo;_lengths;_mod;constructor(e,t={}){if(e<=wo)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&&eo(t),e<=yo)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=bo(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 Lo(e,this.ORDER)}isValid(e){if("bigint"!=typeof e)throw new TypeError("invalid field element: expected bigint, got "+typeof e);return yo<=e&&e<this.ORDER}is0(e){return e===yo}isValidNot0(e){return!this.is0(e)&&this.isValid(e)}isOdd(e){return(e&wo)===wo}neg(e){return Lo(-e,this.ORDER)}eql(e,t){return e===t}sqr(e){return Lo(e*e,this.ORDER)}add(e,t){return Lo(e+t,this.ORDER)}sub(e,t){return Lo(e-t,this.ORDER)}mul(e,t){return Lo(e*t,this.ORDER)}pow(e,t){return Uo(this,e,t)}div(e,t){return Lo(e*No(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 No(e,this.ORDER)}sqrt(e){let t=zo.get(this);return t||zo.set(this,t=Oo(this.ORDER)),t(this,e)}toBytes(e){return this.isLE?fo(e,this.BYTES):mo(e,this.BYTES)}fromBytes(e,t=!1){Xa(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?uo(e):po(e);if(s&&(r=Lo(r,o)),!t&&!this.isValid(r))throw new Error("invalid field element: outside of range 0..ORDER");return r}invertBatch(e){return Fo(this,e)}cmov(e,t,n){return oo(n,"condition"),n?t:e}}function Ho(e,t={}){return new qo(e,t)}function Vo(e){if("bigint"!=typeof e)throw new Error("field order must be bigint");if(e<=wo)throw new Error("field order must be greater than 1");const t=bo(e-wo);return Math.ceil(t/8)}function Go(e,t,n=!1){Xa(e);const i=e.length,a=Vo(t),o=Math.max(function(e){const t=Vo(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=Lo(n?uo(e):po(e),t-wo)+wo;return n?fo(s,a):mo(s,a)}Object.freeze(qo.prototype);
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) */
17
- const Wo=BigInt(0),Jo=BigInt(1);function Qo(e,t){const n=t.negate();return e?n:t}function Zo(e,t){const n=Fo(e.Fp,t.map(e=>e.Z));return t.map((t,i)=>e.fromAffine(t.toAffine(n[i])))}function Yo(e,t){if(!Number.isSafeInteger(e)||e<=0||e>t)throw new Error("invalid window size, expected [1.."+t+"], got W="+e)}function Ko(e,t){Yo(e,t);const n=2**e;return{windows:Math.ceil(t/e)+1,windowSize:2**(e-1),mask:vo(e),maxNumber:n,shiftBy:BigInt(e)}}function Xo(e,t,n){const{windowSize:i,mask:a,maxNumber:o,shiftBy:s}=n;let r=Number(e&a),c=e>>s;r>i&&(r-=o,c+=Jo);const l=t*i;return{nextN:c,offset:l+Math.abs(r)-1,isZero:0===r,isNeg:r<0,isNegF:t%2!=0,offsetF:l}}const es=new WeakMap,ts=new WeakMap;function ns(e){return ts.get(e)||1}function is(e){if(e!==Wo)throw new Error("invalid wNAF")}class as{BASE;ZERO;Fn;bits;constructor(e,t){this.BASE=e.BASE,this.ZERO=e.ZERO,this.Fn=e.Fn,this.bits=t}_unsafeLadder(e,t,n=this.ZERO){let i=e;for(;t>Wo;)t&Jo&&(n=n.add(i)),i=i.double(),t>>=Jo;return n}precomputeWindow(e,t){const{windows:n,windowSize:i}=Ko(t,this.bits),a=[];let o=e,s=o;for(let e=0;e<n;e++){s=o,a.push(s);for(let e=1;e<i;e++)s=s.add(o),a.push(s);o=s.double()}return a}wNAF(e,t,n){if(!this.Fn.isValid(n))throw new Error("invalid scalar");let i=this.ZERO,a=this.BASE;const o=Ko(e,this.bits);for(let e=0;e<o.windows;e++){const{nextN:s,offset:r,isZero:c,isNeg:l,isNegF:p,offsetF:u}=Xo(n,e,o);n=s,c?a=a.add(Qo(p,t[u])):i=i.add(Qo(l,t[r]))}return is(n),{p:i,f:a}}wNAFUnsafe(e,t,n,i=this.ZERO){const a=Ko(e,this.bits);for(let e=0;e<a.windows&&n!==Wo;e++){const{nextN:o,offset:s,isZero:r,isNeg:c}=Xo(n,e,a);if(n=o,!r){const e=t[s];i=i.add(c?e.negate():e)}}return is(n),i}getPrecomputes(e,t,n){let i=es.get(t);return i||(i=this.precomputeWindow(t,e),1!==e&&("function"==typeof n&&(i=n(i)),es.set(t,i))),i}cached(e,t,n){const i=ns(e);return this.wNAF(i,this.getPrecomputes(i,e,n),t)}unsafe(e,t,n,i){const a=ns(e);return 1===a?this._unsafeLadder(e,t,i):this.wNAFUnsafe(a,this.getPrecomputes(a,e,n),t,i)}createCache(e,t){Yo(t,this.bits),ts.set(e,t),es.delete(e)}hasCache(e){return 1!==ns(e)}}function os(e,t,n){if(t){if(t.ORDER!==e)throw new Error("Field.ORDER must match order: Fp == p, Fn == n");return function(e){if(xo(e,Mo.reduce((e,t)=>(e[t]="function",e),{ORDER:"bigint",BYTES:"number",BITS:"number"})),ro(e.BYTES,"BYTES"),ro(e.BITS,"BITS"),e.BYTES<1||e.BITS<1)throw new Error("invalid field: expected BYTES/BITS > 0");if(e.ORDER<=wo)throw new Error("invalid field: expected ORDER > 1, got "+e.ORDER)}(t),t}return Ho(e,{isLE:n})}function ss(e,t){return function(n){const i=e(n);return{secretKey:i,publicKey:t(i)}}}
17
+ const Ho=BigInt(0),Vo=BigInt(1);function Go(e,t){const n=t.negate();return e?n:t}function Wo(e,t){const n=Oo(e.Fp,t.map(e=>e.Z));return t.map((t,i)=>e.fromAffine(t.toAffine(n[i])))}function Jo(e,t){if(!Number.isSafeInteger(e)||e<=0||e>t)throw new Error("invalid window size, expected [1.."+t+"], got W="+e)}function Qo(e,t){Jo(e,t);const n=2**e;return{windows:Math.ceil(t/e)+1,windowSize:2**(e-1),mask:ho(e),maxNumber:n,shiftBy:BigInt(e)}}function Zo(e,t,n){const{windowSize:i,mask:a,maxNumber:o,shiftBy:s}=n;let r=Number(e&a),c=e>>s;r>i&&(r-=o,c+=Vo);const l=t*i;return{nextN:c,offset:l+Math.abs(r)-1,isZero:0===r,isNeg:r<0,isNegF:t%2!=0,offsetF:l}}const Yo=new WeakMap,Ko=new WeakMap;function Xo(e){return Ko.get(e)||1}function es(e){if(e!==Ho)throw new Error("invalid wNAF")}class ts{BASE;ZERO;Fn;bits;constructor(e,t){this.BASE=e.BASE,this.ZERO=e.ZERO,this.Fn=e.Fn,this.bits=t}_unsafeLadder(e,t,n=this.ZERO){let i=e;for(;t>Ho;)t&Vo&&(n=n.add(i)),i=i.double(),t>>=Vo;return n}precomputeWindow(e,t){const{windows:n,windowSize:i}=Qo(t,this.bits),a=[];let o=e,s=o;for(let e=0;e<n;e++){s=o,a.push(s);for(let e=1;e<i;e++)s=s.add(o),a.push(s);o=s.double()}return a}wNAF(e,t,n){if(!this.Fn.isValid(n))throw new Error("invalid scalar");let i=this.ZERO,a=this.BASE;const o=Qo(e,this.bits);for(let e=0;e<o.windows;e++){const{nextN:s,offset:r,isZero:c,isNeg:l,isNegF:p,offsetF:u}=Zo(n,e,o);n=s,c?a=a.add(Go(p,t[u])):i=i.add(Go(l,t[r]))}return es(n),{p:i,f:a}}wNAFUnsafe(e,t,n,i=this.ZERO){const a=Qo(e,this.bits);for(let e=0;e<a.windows&&n!==Ho;e++){const{nextN:o,offset:s,isZero:r,isNeg:c}=Zo(n,e,a);if(n=o,!r){const e=t[s];i=i.add(c?e.negate():e)}}return es(n),i}getPrecomputes(e,t,n){let i=Yo.get(t);return i||(i=this.precomputeWindow(t,e),1!==e&&("function"==typeof n&&(i=n(i)),Yo.set(t,i))),i}cached(e,t,n){const i=Xo(e);return this.wNAF(i,this.getPrecomputes(i,e,n),t)}unsafe(e,t,n,i){const a=Xo(e);return 1===a?this._unsafeLadder(e,t,i):this.wNAFUnsafe(a,this.getPrecomputes(a,e,n),t,i)}createCache(e,t){Jo(t,this.bits),Ko.set(e,t),Yo.delete(e)}hasCache(e){return 1!==Xo(e)}}function ns(e,t,n){if(t){if(t.ORDER!==e)throw new Error("Field.ORDER must match order: Fp == p, Fn == n");return function(e){if(go(e,Bo.reduce((e,t)=>(e[t]="function",e),{ORDER:"bigint",BYTES:"number",BITS:"number"})),ao(e.BYTES,"BYTES"),ao(e.BITS,"BITS"),e.BYTES<1||e.BITS<1)throw new Error("invalid field: expected BYTES/BITS > 0");if(e.ORDER<=vo)throw new Error("invalid field: expected ORDER > 1, got "+e.ORDER)}(t),t}return Po(e,{isLE:n})}function is(e,t){return function(n){const i=e(n);return{secretKey:i,publicKey:t(i)}}}
18
18
  /*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */
19
- const rs=(e,t)=>(e+(e>=0?t:-t)/ds)/t;class cs extends Error{constructor(e=""){super(e)}}const ls={Err:cs,_tlv:{encode:(e,t)=>{const{Err:n}=ls;if(ro(e,"tag"),e<0||e>255)throw new n("tlv.encode: wrong tag");if("string"!=typeof t)throw new TypeError('"data" expected string, got type='+typeof t);if(1&t.length)throw new n("tlv.encode: unpadded data");const i=t.length/2,a=co(i);if(a.length/2&128)throw new n("tlv.encode: long form length too big");const o=i>127?co(a.length/2|128):"";return co(e)+o+a+t},decode(e,t){const{Err:n}=ls;t=Xa(t,void 0,"DER data");let i=0;if(e<0||e>255)throw new n("tlv.encode: wrong tag");if(t.length<2||t[i++]!==e)throw new n("tlv.decode: wrong tlv");const a=t[i++];let o=0;if(!!(128&a)){const e=127&a;if(!e)throw new n("tlv.decode(long): indefinite length not supported");if(e>4)throw new n("tlv.decode(long): byte length is too big");const s=t.subarray(i,i+e);if(s.length!==e)throw new n("tlv.decode: length bytes not complete");if(0===s[0])throw new n("tlv.decode(long): zero leftmost byte");for(const e of s)o=o<<8|e;if(i+=e,o<128)throw new n("tlv.decode(long): not minimal encoding")}else o=a;const s=t.subarray(i,i+o);if(s.length!==o)throw new n("tlv.decode: wrong value length");return{v:s,l:t.subarray(i+o)}}},_int:{encode(e){const{Err:t}=ls;if(so(e),e<ps)throw new t("integer: negative integers are not allowed");let n=co(e);if(8&Number.parseInt(n[0],16)&&(n="00"+n),1&n.length)throw new t("unexpected DER parsing assertion: unpadded hex");return n},decode(e){const{Err:t}=ls;if(e.length<1)throw new t("invalid signature integer: empty");if(128&e[0])throw new t("invalid signature integer: negative");if(e.length>1&&0===e[0]&&!(128&e[1]))throw new t("invalid signature integer: unnecessary leading zero");return po(e)}},toSig(e){const{Err:t,_int:n,_tlv:i}=ls,a=Xa(e,void 0,"signature"),{v:o,l:s}=i.decode(48,a);if(s.length)throw new t("invalid signature: left bytes after parsing");const{v:r,l:c}=i.decode(2,o),{v:l,l:p}=i.decode(2,c);if(p.length)throw new t("invalid signature: left bytes after parsing");return{r:n.decode(r),s:n.decode(l)}},hexFromSig(e){const{_tlv:t,_int:n}=ls,i=t.encode(2,n.encode(e.r))+t.encode(2,n.encode(e.s));return t.encode(48,i)}};Object.freeze(ls._tlv),Object.freeze(ls._int),Object.freeze(ls);const ps=BigInt(0),us=BigInt(1),ds=BigInt(2),ms=BigInt(3),fs=BigInt(4);function hs(e,t={}){const n=function(e,t,n={},i){if(void 0===i&&(i="edwards"===e),!t||"object"!=typeof t)throw new Error(`expected valid ${e} CURVE object`);for(const e of["p","n","h"]){const n=t[e];if(!("bigint"==typeof n&&n>Wo))throw new Error(`CURVE.${e} must be positive bigint`)}const a=os(t.p,n.Fp,i),o=os(t.n,n.Fn,i),s=["Gx","Gy","a","weierstrass"===e?"b":"d"];for(const e of s)if(!a.isValid(t[e]))throw new Error(`CURVE.${e} must be valid field element of CURVE.Fp`);return{CURVE:t=Object.freeze(Object.assign({},t)),Fp:a,Fn:o}}("weierstrass",e,t),i=n.Fp,a=n.Fn;let o=n.CURVE;const{h:s,n:r}=o;xo(t,{},{allowInfinityPoint:"boolean",clearCofactor:"function",isTorsionFree:"function",fromBytes:"function",toBytes:"function",endo:"object"});const{endo:c,allowInfinityPoint:l}=t;if(c&&(!i.is0(o.a)||"bigint"!=typeof c.beta||!Array.isArray(c.basises)))throw new Error('invalid endo: expected "beta": bigint and "basises": array');const p=bs(i,a);function u(){if(!i.isOdd)throw new Error("compression is not supported: Field does not have .isOdd()")}const d=void 0===t.toBytes?function(e,t,n){if(l&&t.is0())return Uint8Array.of(0);const{x:a,y:o}=t.toAffine(),s=i.toBytes(a);if(oo(n,"isCompressed"),n){u();const e=!i.isOdd(o);return no(gs(e),s)}return no(Uint8Array.of(4),s,i.toBytes(o))}:t.toBytes,m=void 0===t.fromBytes?function(e){Xa(e,void 0,"Point");const{publicKey:t,publicKeyUncompressed:n}=p,a=e.length,o=e[0],s=e.subarray(1);if(l&&1===a&&0===o)return{x:i.ZERO,y:i.ZERO};if(a!==t||2!==o&&3!==o){if(a===n&&4===o){const e=i.BYTES,t=i.fromBytes(s.subarray(0,e)),n=i.fromBytes(s.subarray(e,2*e));if(!h(t,n))throw new Error("bad point: is not on curve");return{x:t,y:n}}throw new Error(`bad point: got length ${a}, expected compressed=${t} or uncompressed=${n}`)}{const e=i.fromBytes(s);if(!i.isValid(e))throw new Error("bad point: is not on curve, wrong x");const t=f(e);let n;try{n=i.sqrt(t)}catch(e){const t=e instanceof Error?": "+e.message:"";throw new Error("bad point: is not on curve, sqrt error"+t)}u();return!(1&~o)!==i.isOdd(n)&&(n=i.neg(n)),{x:e,y:n}}}:t.fromBytes;function f(e){const t=i.sqr(e),n=i.mul(t,e);return i.add(i.add(n,i.mul(e,o.a)),o.b)}function h(e,t){const n=i.sqr(t),a=f(e);return i.eql(n,a)}if(!h(o.Gx,o.Gy))throw new Error("bad curve params: generator point");const g=i.mul(i.pow(o.a,ms),fs),b=i.mul(i.sqr(o.b),BigInt(27));if(i.is0(i.add(g,b)))throw new Error("bad curve params: a or b");function v(e,t,n=!1){if(!i.isValid(t)||n&&i.is0(t))throw new Error(`bad point coordinate ${e}`);return t}function x(e){if(!(e instanceof C))throw new Error("Weierstrass Point expected")}function y(e){if(!c||!c.basises)throw new Error("no endo");return function(e,t,n){go("scalar",e,ps,n);const[[i,a],[o,s]]=t,r=rs(s*e,n),c=rs(-a*e,n);let l=e-r*i-c*o,p=-r*a-c*s;const u=l<ps,d=p<ps;u&&(l=-l),d&&(p=-p);const m=vo(Math.ceil(bo(n)/2))+us;if(l<ps||l>=m||p<ps||p>=m)throw new Error("splitScalar (endomorphism): failed for k");return{k1neg:u,k1:l,k2neg:d,k2:p}}(e,c.basises,a.ORDER)}function w(e,t,n,a,o){return n=new C(i.mul(n.X,e),n.Y,n.Z),t=Qo(a,t),n=Qo(o,n),t.add(n)}class C{static BASE=new C(o.Gx,o.Gy,i.ONE);static ZERO=new C(i.ZERO,i.ONE,i.ZERO);static Fp=i;static Fn=a;X;Y;Z;constructor(e,t,n){this.X=v("x",e),this.Y=v("y",t,!0),this.Z=v("z",n),Object.freeze(this)}static CURVE(){return o}static fromAffine(e){const{x:t,y:n}=e||{};if(!e||!i.isValid(t)||!i.isValid(n))throw new Error("invalid affine point");if(e instanceof C)throw new Error("projective point not allowed");return i.is0(t)&&i.is0(n)?C.ZERO:new C(t,n,i.ONE)}static fromBytes(e){const t=C.fromAffine(m(Xa(e,void 0,"point")));return t.assertValidity(),t}static fromHex(e){return C.fromBytes((e=>Fa(e))(e))}get x(){return this.toAffine().x}get y(){return this.toAffine().y}precompute(e=8,t=!0){return k.createCache(this,e),t||this.multiply(ms),this}assertValidity(){const e=this;if(e.is0()){if(t.allowInfinityPoint&&i.is0(e.X)&&i.eql(e.Y,i.ONE)&&i.is0(e.Z))return;throw new Error("bad point: ZERO")}const{x:n,y:a}=e.toAffine();if(!i.isValid(n)||!i.isValid(a))throw new Error("bad point: x or y not field elements");if(!h(n,a))throw new Error("bad point: equation left != right");if(!e.isTorsionFree())throw new Error("bad point: not in prime-order subgroup")}hasEvenY(){const{y:e}=this.toAffine();if(!i.isOdd)throw new Error("Field doesn't support isOdd");return!i.isOdd(e)}equals(e){x(e);const{X:t,Y:n,Z:a}=this,{X:o,Y:s,Z:r}=e,c=i.eql(i.mul(t,r),i.mul(o,a)),l=i.eql(i.mul(n,r),i.mul(s,a));return c&&l}negate(){return new C(this.X,i.neg(this.Y),this.Z)}double(){const{a:e,b:t}=o,n=i.mul(t,ms),{X:a,Y:s,Z:r}=this;let c=i.ZERO,l=i.ZERO,p=i.ZERO,u=i.mul(a,a),d=i.mul(s,s),m=i.mul(r,r),f=i.mul(a,s);return f=i.add(f,f),p=i.mul(a,r),p=i.add(p,p),c=i.mul(e,p),l=i.mul(n,m),l=i.add(c,l),c=i.sub(d,l),l=i.add(d,l),l=i.mul(c,l),c=i.mul(f,c),p=i.mul(n,p),m=i.mul(e,m),f=i.sub(u,m),f=i.mul(e,f),f=i.add(f,p),p=i.add(u,u),u=i.add(p,u),u=i.add(u,m),u=i.mul(u,f),l=i.add(l,u),m=i.mul(s,r),m=i.add(m,m),u=i.mul(m,f),c=i.sub(c,u),p=i.mul(m,d),p=i.add(p,p),p=i.add(p,p),new C(c,l,p)}add(e){x(e);const{X:t,Y:n,Z:a}=this,{X:s,Y:r,Z:c}=e;let l=i.ZERO,p=i.ZERO,u=i.ZERO;const d=o.a,m=i.mul(o.b,ms);let f=i.mul(t,s),h=i.mul(n,r),g=i.mul(a,c),b=i.add(t,n),v=i.add(s,r);b=i.mul(b,v),v=i.add(f,h),b=i.sub(b,v),v=i.add(t,a);let y=i.add(s,c);return v=i.mul(v,y),y=i.add(f,g),v=i.sub(v,y),y=i.add(n,a),l=i.add(r,c),y=i.mul(y,l),l=i.add(h,g),y=i.sub(y,l),u=i.mul(d,v),l=i.mul(m,g),u=i.add(l,u),l=i.sub(h,u),u=i.add(h,u),p=i.mul(l,u),h=i.add(f,f),h=i.add(h,f),g=i.mul(d,g),v=i.mul(m,v),h=i.add(h,g),g=i.sub(f,g),g=i.mul(d,g),v=i.add(v,g),f=i.mul(h,v),p=i.add(p,f),f=i.mul(y,v),l=i.mul(b,l),l=i.sub(l,f),f=i.mul(b,h),u=i.mul(y,u),u=i.add(u,f),new C(l,p,u)}subtract(e){return x(e),this.add(e.negate())}is0(){return this.equals(C.ZERO)}multiply(e){const{endo:n}=t;if(!a.isValidNot0(e))throw new RangeError("invalid scalar: out of range");let i,o;const s=e=>k.cached(this,e,e=>Zo(C,e));if(n){const{k1neg:t,k1:a,k2neg:r,k2:c}=y(e),{p:l,f:p}=s(a),{p:u,f:d}=s(c);o=p.add(d),i=w(n.beta,l,u,t,r)}else{const{p:t,f:n}=s(e);i=t,o=n}return Zo(C,[i,o])[0]}multiplyUnsafe(e){const{endo:n}=t,i=this,o=e;if(!a.isValid(o))throw new RangeError("invalid scalar: out of range");if(o===ps||i.is0())return C.ZERO;if(o===us)return i;if(k.hasCache(this))return this.multiply(o);if(n){const{k1neg:e,k1:t,k2neg:a,k2:s}=y(o),{p1:r,p2:c}=function(e,t,n,i){let a=t,o=e.ZERO,s=e.ZERO;for(;n>Wo||i>Wo;)n&Jo&&(o=o.add(a)),i&Jo&&(s=s.add(a)),a=a.double(),n>>=Jo,i>>=Jo;return{p1:o,p2:s}}(C,i,t,s);return w(n.beta,r,c,e,a)}return k.unsafe(i,o)}toAffine(e){let t=e;const{X:n,Y:a,Z:o}=this;if(i.eql(o,i.ONE))return{x:n,y:a};const s=this.is0();null==t&&(t=s?i.ONE:i.inv(o));const r=i.mul(n,t),c=i.mul(a,t),l=i.mul(o,t);if(s)return{x:i.ZERO,y:i.ZERO};if(!i.eql(l,i.ONE))throw new Error("invZ was invalid");return{x:r,y:c}}isTorsionFree(){const{isTorsionFree:e}=t;return s===us||(e?e(C,this):k.unsafe(this,r).is0())}clearCofactor(){const{clearCofactor:e}=t;return s===us?this:e?e(C,this):this.multiplyUnsafe(s)}isSmallOrder(){return s===us?this.is0():this.clearCofactor().is0()}toBytes(e=!0){return oo(e,"isCompressed"),this.assertValidity(),d(C,this,e)}toHex(e=!0){return to(this.toBytes(e))}toString(){return`<Point ${this.is0()?"ZERO":this.toHex()}>`}}const E=a.BITS,k=new as(C,t.endo?Math.ceil(E/2):E);return E>=8&&C.BASE.precompute(8),Object.freeze(C.prototype),Object.freeze(C),C}function gs(e){return Uint8Array.of(e?2:3)}function bs(e,t){return{secretKey:t.BYTES,publicKey:1+e.BYTES,publicKeyUncompressed:1+2*e.BYTES,publicKeyHasPrefix:!0,signature:2*t.BYTES}}
19
+ const as=(e,t)=>(e+(e>=0?t:-t)/ls)/t;class os extends Error{constructor(e=""){super(e)}}const ss={Err:os,_tlv:{encode:(e,t)=>{const{Err:n}=ss;if(ao(e,"tag"),e<0||e>255)throw new n("tlv.encode: wrong tag");if("string"!=typeof t)throw new TypeError('"data" expected string, got type='+typeof t);if(1&t.length)throw new n("tlv.encode: unpadded data");const i=t.length/2,a=oo(i);if(a.length/2&128)throw new n("tlv.encode: long form length too big");const o=i>127?oo(a.length/2|128):"";return oo(e)+o+a+t},decode(e,t){const{Err:n}=ss;t=Za(t,void 0,"DER data");let i=0;if(e<0||e>255)throw new n("tlv.encode: wrong tag");if(t.length<2||t[i++]!==e)throw new n("tlv.decode: wrong tlv");const a=t[i++];let o=0;if(!!(128&a)){const e=127&a;if(!e)throw new n("tlv.decode(long): indefinite length not supported");if(e>4)throw new n("tlv.decode(long): byte length is too big");const s=t.subarray(i,i+e);if(s.length!==e)throw new n("tlv.decode: length bytes not complete");if(0===s[0])throw new n("tlv.decode(long): zero leftmost byte");for(const e of s)o=o<<8|e;if(i+=e,o<128)throw new n("tlv.decode(long): not minimal encoding")}else o=a;const s=t.subarray(i,i+o);if(s.length!==o)throw new n("tlv.decode: wrong value length");return{v:s,l:t.subarray(i+o)}}},_int:{encode(e){const{Err:t}=ss;if(io(e),e<rs)throw new t("integer: negative integers are not allowed");let n=oo(e);if(8&Number.parseInt(n[0],16)&&(n="00"+n),1&n.length)throw new t("unexpected DER parsing assertion: unpadded hex");return n},decode(e){const{Err:t}=ss;if(e.length<1)throw new t("invalid signature integer: empty");if(128&e[0])throw new t("invalid signature integer: negative");if(e.length>1&&0===e[0]&&!(128&e[1]))throw new t("invalid signature integer: unnecessary leading zero");return ro(e)}},toSig(e){const{Err:t,_int:n,_tlv:i}=ss,a=Za(e,void 0,"signature"),{v:o,l:s}=i.decode(48,a);if(s.length)throw new t("invalid signature: left bytes after parsing");const{v:r,l:c}=i.decode(2,o),{v:l,l:p}=i.decode(2,c);if(p.length)throw new t("invalid signature: left bytes after parsing");return{r:n.decode(r),s:n.decode(l)}},hexFromSig(e){const{_tlv:t,_int:n}=ss,i=t.encode(2,n.encode(e.r))+t.encode(2,n.encode(e.s));return t.encode(48,i)}};Object.freeze(ss._tlv),Object.freeze(ss._int),Object.freeze(ss);const rs=BigInt(0),cs=BigInt(1),ls=BigInt(2),ps=BigInt(3),us=BigInt(4);function ds(e,t={}){const n=function(e,t,n={},i){if(void 0===i&&(i="edwards"===e),!t||"object"!=typeof t)throw new Error(`expected valid ${e} CURVE object`);for(const e of["p","n","h"]){const n=t[e];if(!("bigint"==typeof n&&n>Ho))throw new Error(`CURVE.${e} must be positive bigint`)}const a=ns(t.p,n.Fp,i),o=ns(t.n,n.Fn,i),s=["Gx","Gy","a","weierstrass"===e?"b":"d"];for(const e of s)if(!a.isValid(t[e]))throw new Error(`CURVE.${e} must be valid field element of CURVE.Fp`);return{CURVE:t=Object.freeze(Object.assign({},t)),Fp:a,Fn:o}}("weierstrass",e,t),i=n.Fp,a=n.Fn;let o=n.CURVE;const{h:s,n:r}=o;go(t,{},{allowInfinityPoint:"boolean",clearCofactor:"function",isTorsionFree:"function",fromBytes:"function",toBytes:"function",endo:"object"});const{endo:c,allowInfinityPoint:l}=t;if(c&&(!i.is0(o.a)||"bigint"!=typeof c.beta||!Array.isArray(c.basises)))throw new Error('invalid endo: expected "beta": bigint and "basises": array');const p=fs(i,a);function u(){if(!i.isOdd)throw new Error("compression is not supported: Field does not have .isOdd()")}const d=void 0===t.toBytes?function(e,t,n){if(l&&t.is0())return Uint8Array.of(0);const{x:a,y:o}=t.toAffine(),s=i.toBytes(a);if(no(n,"isCompressed"),n){u();const e=!i.isOdd(o);return Xa(ms(e),s)}return Xa(Uint8Array.of(4),s,i.toBytes(o))}:t.toBytes,m=void 0===t.fromBytes?function(e){Za(e,void 0,"Point");const{publicKey:t,publicKeyUncompressed:n}=p,a=e.length,o=e[0],s=e.subarray(1);if(l&&1===a&&0===o)return{x:i.ZERO,y:i.ZERO};if(a!==t||2!==o&&3!==o){if(a===n&&4===o){const e=i.BYTES,t=i.fromBytes(s.subarray(0,e)),n=i.fromBytes(s.subarray(e,2*e));if(!h(t,n))throw new Error("bad point: is not on curve");return{x:t,y:n}}throw new Error(`bad point: got length ${a}, expected compressed=${t} or uncompressed=${n}`)}{const e=i.fromBytes(s);if(!i.isValid(e))throw new Error("bad point: is not on curve, wrong x");const t=f(e);let n;try{n=i.sqrt(t)}catch(e){const t=e instanceof Error?": "+e.message:"";throw new Error("bad point: is not on curve, sqrt error"+t)}u();return!(1&~o)!==i.isOdd(n)&&(n=i.neg(n)),{x:e,y:n}}}:t.fromBytes;function f(e){const t=i.sqr(e),n=i.mul(t,e);return i.add(i.add(n,i.mul(e,o.a)),o.b)}function h(e,t){const n=i.sqr(t),a=f(e);return i.eql(n,a)}if(!h(o.Gx,o.Gy))throw new Error("bad curve params: generator point");const g=i.mul(i.pow(o.a,ps),us),b=i.mul(i.sqr(o.b),BigInt(27));if(i.is0(i.add(g,b)))throw new Error("bad curve params: a or b");function v(e,t,n=!1){if(!i.isValid(t)||n&&i.is0(t))throw new Error(`bad point coordinate ${e}`);return t}function x(e){if(!(e instanceof C))throw new Error("Weierstrass Point expected")}function y(e){if(!c||!c.basises)throw new Error("no endo");return function(e,t,n){mo("scalar",e,rs,n);const[[i,a],[o,s]]=t,r=as(s*e,n),c=as(-a*e,n);let l=e-r*i-c*o,p=-r*a-c*s;const u=l<rs,d=p<rs;u&&(l=-l),d&&(p=-p);const m=ho(Math.ceil(fo(n)/2))+cs;if(l<rs||l>=m||p<rs||p>=m)throw new Error("splitScalar (endomorphism): failed for k");return{k1neg:u,k1:l,k2neg:d,k2:p}}(e,c.basises,a.ORDER)}function w(e,t,n,a,o){return n=new C(i.mul(n.X,e),n.Y,n.Z),t=Go(a,t),n=Go(o,n),t.add(n)}class C{static BASE=new C(o.Gx,o.Gy,i.ONE);static ZERO=new C(i.ZERO,i.ONE,i.ZERO);static Fp=i;static Fn=a;X;Y;Z;constructor(e,t,n){this.X=v("x",e),this.Y=v("y",t,!0),this.Z=v("z",n),Object.freeze(this)}static CURVE(){return o}static fromAffine(e){const{x:t,y:n}=e||{};if(!e||!i.isValid(t)||!i.isValid(n))throw new Error("invalid affine point");if(e instanceof C)throw new Error("projective point not allowed");return i.is0(t)&&i.is0(n)?C.ZERO:new C(t,n,i.ONE)}static fromBytes(e){const t=C.fromAffine(m(Za(e,void 0,"point")));return t.assertValidity(),t}static fromHex(e){return C.fromBytes((e=>Oa(e))(e))}get x(){return this.toAffine().x}get y(){return this.toAffine().y}precompute(e=8,t=!0){return k.createCache(this,e),t||this.multiply(ps),this}assertValidity(){const e=this;if(e.is0()){if(t.allowInfinityPoint&&i.is0(e.X)&&i.eql(e.Y,i.ONE)&&i.is0(e.Z))return;throw new Error("bad point: ZERO")}const{x:n,y:a}=e.toAffine();if(!i.isValid(n)||!i.isValid(a))throw new Error("bad point: x or y not field elements");if(!h(n,a))throw new Error("bad point: equation left != right");if(!e.isTorsionFree())throw new Error("bad point: not in prime-order subgroup")}hasEvenY(){const{y:e}=this.toAffine();if(!i.isOdd)throw new Error("Field doesn't support isOdd");return!i.isOdd(e)}equals(e){x(e);const{X:t,Y:n,Z:a}=this,{X:o,Y:s,Z:r}=e,c=i.eql(i.mul(t,r),i.mul(o,a)),l=i.eql(i.mul(n,r),i.mul(s,a));return c&&l}negate(){return new C(this.X,i.neg(this.Y),this.Z)}double(){const{a:e,b:t}=o,n=i.mul(t,ps),{X:a,Y:s,Z:r}=this;let c=i.ZERO,l=i.ZERO,p=i.ZERO,u=i.mul(a,a),d=i.mul(s,s),m=i.mul(r,r),f=i.mul(a,s);return f=i.add(f,f),p=i.mul(a,r),p=i.add(p,p),c=i.mul(e,p),l=i.mul(n,m),l=i.add(c,l),c=i.sub(d,l),l=i.add(d,l),l=i.mul(c,l),c=i.mul(f,c),p=i.mul(n,p),m=i.mul(e,m),f=i.sub(u,m),f=i.mul(e,f),f=i.add(f,p),p=i.add(u,u),u=i.add(p,u),u=i.add(u,m),u=i.mul(u,f),l=i.add(l,u),m=i.mul(s,r),m=i.add(m,m),u=i.mul(m,f),c=i.sub(c,u),p=i.mul(m,d),p=i.add(p,p),p=i.add(p,p),new C(c,l,p)}add(e){x(e);const{X:t,Y:n,Z:a}=this,{X:s,Y:r,Z:c}=e;let l=i.ZERO,p=i.ZERO,u=i.ZERO;const d=o.a,m=i.mul(o.b,ps);let f=i.mul(t,s),h=i.mul(n,r),g=i.mul(a,c),b=i.add(t,n),v=i.add(s,r);b=i.mul(b,v),v=i.add(f,h),b=i.sub(b,v),v=i.add(t,a);let y=i.add(s,c);return v=i.mul(v,y),y=i.add(f,g),v=i.sub(v,y),y=i.add(n,a),l=i.add(r,c),y=i.mul(y,l),l=i.add(h,g),y=i.sub(y,l),u=i.mul(d,v),l=i.mul(m,g),u=i.add(l,u),l=i.sub(h,u),u=i.add(h,u),p=i.mul(l,u),h=i.add(f,f),h=i.add(h,f),g=i.mul(d,g),v=i.mul(m,v),h=i.add(h,g),g=i.sub(f,g),g=i.mul(d,g),v=i.add(v,g),f=i.mul(h,v),p=i.add(p,f),f=i.mul(y,v),l=i.mul(b,l),l=i.sub(l,f),f=i.mul(b,h),u=i.mul(y,u),u=i.add(u,f),new C(l,p,u)}subtract(e){return x(e),this.add(e.negate())}is0(){return this.equals(C.ZERO)}multiply(e){const{endo:n}=t;if(!a.isValidNot0(e))throw new RangeError("invalid scalar: out of range");let i,o;const s=e=>k.cached(this,e,e=>Wo(C,e));if(n){const{k1neg:t,k1:a,k2neg:r,k2:c}=y(e),{p:l,f:p}=s(a),{p:u,f:d}=s(c);o=p.add(d),i=w(n.beta,l,u,t,r)}else{const{p:t,f:n}=s(e);i=t,o=n}return Wo(C,[i,o])[0]}multiplyUnsafe(e){const{endo:n}=t,i=this,o=e;if(!a.isValid(o))throw new RangeError("invalid scalar: out of range");if(o===rs||i.is0())return C.ZERO;if(o===cs)return i;if(k.hasCache(this))return this.multiply(o);if(n){const{k1neg:e,k1:t,k2neg:a,k2:s}=y(o),{p1:r,p2:c}=function(e,t,n,i){let a=t,o=e.ZERO,s=e.ZERO;for(;n>Ho||i>Ho;)n&Vo&&(o=o.add(a)),i&Vo&&(s=s.add(a)),a=a.double(),n>>=Vo,i>>=Vo;return{p1:o,p2:s}}(C,i,t,s);return w(n.beta,r,c,e,a)}return k.unsafe(i,o)}toAffine(e){let t=e;const{X:n,Y:a,Z:o}=this;if(i.eql(o,i.ONE))return{x:n,y:a};const s=this.is0();null==t&&(t=s?i.ONE:i.inv(o));const r=i.mul(n,t),c=i.mul(a,t),l=i.mul(o,t);if(s)return{x:i.ZERO,y:i.ZERO};if(!i.eql(l,i.ONE))throw new Error("invZ was invalid");return{x:r,y:c}}isTorsionFree(){const{isTorsionFree:e}=t;return s===cs||(e?e(C,this):k.unsafe(this,r).is0())}clearCofactor(){const{clearCofactor:e}=t;return s===cs?this:e?e(C,this):this.multiplyUnsafe(s)}isSmallOrder(){return s===cs?this.is0():this.clearCofactor().is0()}toBytes(e=!0){return no(e,"isCompressed"),this.assertValidity(),d(C,this,e)}toHex(e=!0){return Ka(this.toBytes(e))}toString(){return`<Point ${this.is0()?"ZERO":this.toHex()}>`}}const E=a.BITS,k=new ts(C,t.endo?Math.ceil(E/2):E);return E>=8&&C.BASE.precompute(8),Object.freeze(C.prototype),Object.freeze(C),C}function ms(e){return Uint8Array.of(e?2:3)}function fs(e,t){return{secretKey:t.BYTES,publicKey:1+e.BYTES,publicKeyUncompressed:1+2*e.BYTES,publicKeyHasPrefix:!0,signature:2*t.BYTES}}
20
20
  /*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */
21
- const vs={p:BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f"),n:BigInt("0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141"),h:BigInt(1),a:BigInt(0),b:BigInt(7),Gx:BigInt("0x79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798"),Gy:BigInt("0x483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8")},xs={beta:BigInt("0x7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee"),basises:[[BigInt("0x3086d221a7d46bcde86c90e49284eb15"),-BigInt("0xe4437ed6010e88286f547fa90abfe4c3")],[BigInt("0x114ca50f7a8e2f3f657c1108d9d44cfd8"),BigInt("0x3086d221a7d46bcde86c90e49284eb15")]]},ys=BigInt(0),ws=BigInt(2);const Cs=Ho(vs.p,{sqrt:function(e){const t=vs.p,n=BigInt(3),i=BigInt(6),a=BigInt(11),o=BigInt(22),s=BigInt(23),r=BigInt(44),c=BigInt(88),l=e*e*e%t,p=l*l*e%t,u=Ro(p,n,t)*p%t,d=Ro(u,n,t)*p%t,m=Ro(d,ws,t)*l%t,f=Ro(m,a,t)*m%t,h=Ro(f,o,t)*f%t,g=Ro(h,r,t)*h%t,b=Ro(g,c,t)*g%t,v=Ro(b,r,t)*h%t,x=Ro(v,n,t)*p%t,y=Ro(x,s,t)*f%t,w=Ro(y,i,t)*l%t,C=Ro(w,ws,t);if(!Cs.eql(Cs.sqr(C),e))throw new Error("Cannot find square root");return C}}),Es=hs(vs,{Fp:Cs,endo:xs}),ks={};function As(e,...t){let n=ks[e];if(void 0===n){const t=Ka(function(e){if("string"!=typeof e)throw new TypeError("ascii string expected, got "+typeof e);return Uint8Array.from(e,(t,n)=>{const i=t.charCodeAt(0);if(1!==t.length||i>127)throw new RangeError(`string contains non-ASCII character "${e[n]}" with code ${i} at position ${n}`);return i})}(e));n=no(t,t),ks[e]=n}return Ka(no(n,...t))}const _s=e=>e.toBytes(!0).slice(1),Ts=e=>e%ws===ys;function Ss(e){const{Fn:t,BASE:n}=Es,i=t.fromBytes(e),a=n.multiply(i);return{scalar:Ts(a.y)?i:t.neg(i),bytes:_s(a)}}function js(e){const t=Cs;if(!t.isValidNot0(e))throw new Error("invalid x: Fail if x ≥ p");const n=t.create(e*e),i=t.create(n*e+BigInt(7));let a=t.sqrt(i);Ts(a)||(a=t.neg(a));const o=Es.fromAffine({x:e,y:a});return o.assertValidity(),o}const Ls=po;function Rs(...e){return Es.Fn.create(Ls(As("BIP0340/challenge",...e)))}function Ns(e){return Ss(e).bytes}function Is(e,t,n=za(32)){const{Fn:i,BASE:a}=Es,o=Xa(e,void 0,"message"),{bytes:s,scalar:r}=Ss(t),c=Xa(n,32,"auxRand"),l=i.toBytes(r^Ls(As("BIP0340/aux",c))),p=As("BIP0340/nonce",l,s,o),u=i.create(Ls(p));if(0n===u)throw new Error("sign failed: k is zero");const d=a.multiply(u),m=Ts(d.y)?u:i.neg(u),f=_s(d),h=Rs(f,s,o),g=new Uint8Array(64);if(g.set(f,0),g.set(i.toBytes(i.create(m+h*r)),32),!$s(g,o,s))throw new Error("sign: Invalid signature produced");return g}function $s(e,t,n){const{Fp:i,Fn:a,BASE:o}=Es,s=Xa(e,64,"signature"),r=Xa(t,void 0,"message"),c=Xa(n,32,"publicKey");try{const e=js(Ls(c)),t=Ls(s.subarray(0,32));if(!i.isValidNot0(t))return!1;const n=Ls(s.subarray(32,64));if(!a.isValidNot0(n))return!1;const l=Rs(a.toBytes(t),_s(e),r),p=o.multiplyUnsafe(n).add(e.multiplyUnsafe(a.neg(l))),{x:u,y:d}=p.toAffine();return!(p.is0()||!Ts(d)||u!==t)}catch(e){return!1}}const Bs=(()=>{const e=e=>Go(e=void 0===e?za(48):e,vs.n);return Object.freeze({keygen:ss(e,Ns),getPublicKey:Ns,sign:Is,verify:$s,Point:Es,utils:Object.freeze({randomSecretKey:e,taggedHash:As,lift_x:js,pointToBytes:_s}),lengths:Object.freeze({secretKey:32,publicKey:32,publicKeyHasPrefix:!1,signature:64,seed:48})})})();new TextDecoder("utf-8");const Ds=new TextEncoder,Os="https://w3id.org/security#";function Ms(e){const t=Ka(Ds.encode(function(e){return JSON.stringify(e)}(e)));return Na(t)}const Us=e=>{let t=v.store.any(e,b.space("preferencesFile"),null,e.doc())?.value;if(t=t?.split("/").slice(0,-2).join("/"),!t)throw new Error(`prefererencesFile is expected to exist in ${e}`);return t},Fs=e=>{let t;try{t=`${Us(e)}/profile/keys/publicKey.ttl`}catch(e){xe.z3(e)}return t};async function Ps(e,t,n){try{await v.store.fetcher.load(t);const i=v.store.any(e,b.solid(n));return i?.value}catch(e){if(404===e.response.status){xe.Rm("createIfNotExists: doc does NOT exist, will create... "+t);try{await v.store.fetcher.webOperation("PUT",t,{data:"",contentType:"text/turtle"})}catch(e){throw xe.Rm("createIfNotExists doc FAILED: "+t+": "+e),e}return void delete v.store.fetcher.requested[t]}throw xe.Rm("createIfNotExists doc FAILED: "+t+": "+e),e}}async function zs(e,t){await v.store.fetcher.load(e);const n=v.store.any(v.store.sym(e),v.store.sym("http://www.iana.org/assignments/link-relations/acl"));if(!n)throw new Error("Key ACL doc not found!");try{await v.store.fetcher.webOperation("PUT",n.value,{data:t,contentType:"text/turtle"})}catch(e){if(404!==e?.response?.status)throw new Error(e);xe.Rm("delete "+n.value+" "+e.response.status)}}function qs(e){return Na(Bs.getPublicKey(Fa(e)))}async function Hs(e){await v.store.fetcher.load(e);const t=await Fs(e),n=await(e=>{let t;try{t=`${Us(e)}/settings/keys/privateKey.ttl`}catch(e){xe.z3(e)}return t})(e),i=await async function(e,t){return await Ps(e,t,"publicKey")}(e,t);let a=await async function(e,t){return await Ps(e,t,"privateKey")}(e,n),o=!0;if(a&&i!==qs(a)&&confirm("This is strange the publicKey is not valid for\n"+e?.uri+"'shall we repair keeping the private key ?")&&(o=!1),!a||!i||!o){let r=[],c=[];if(a||(a=Na(Bs.utils.randomSecretKey()),c=[g.st(e,b.solid("privateKey"),g.literal(a),v.store.sym(n))],await Vs(n,[],c,e.uri)),!i||!o){r=[],i&&(r=[g.st(e,b.solid("publicKey"),g.lit(i),v.store.sym(t))],xe.Rm("delete invalid publicKey "+r));const n=qs(a);c=[g.st(e,b.solid("publicKey"),g.literal(n),v.store.sym(t))],await Vs(t,r,c)}const l=n.substring(0,n.lastIndexOf("/")+1);await zs(l,(s=e.uri,`\n@prefix : <#>.\n@prefix acl: <http://www.w3.org/ns/auth/acl#>.\n@prefix foaf: <http://xmlns.com/foaf/0.1/>.\n@prefix key: <./>.\n\n:ReadWrite\n a acl:Authorization;\n acl:accessTo key:;\n acl:default key:;\n acl:agent <${s}>;\n acl:mode acl:Read, acl:Write.\n`))}var s;return a}async function Vs(e,t,n,i=""){await(async e=>{await v.store.fetcher.load(e);const t=v.store.any(v.store.sym(e),v.store.sym("http://www.iana.org/assignments/link-relations/acl"));if(t)try{const e=await v.store.fetcher.webOperation("DELETE",t.value);xe.Rm("delete keyAcl"+t.value+" "+e.status)}catch(e){if(404!==e.response.status)throw new Error(e);xe.Rm("delete keyAcl"+t.value+" "+e.response.status)}})(e),await v.store.updater.updateMany(t,n);const a=((e,t)=>{let n="acl:agentClass foaf:Agent";return t?.length&&(n=`acl:agent <${t}>`),`\n@prefix foaf: <http://xmlns.com/foaf/0.1/>.\n@prefix acl: <http://www.w3.org/ns/auth/acl#>.\n<#Read>\n a acl:Authorization;\n ${n};\n acl:accessTo <${e.split("/").pop()}>;\n acl:mode acl:Read.\n`})(e,i);await zs(e,a)}class Gs{constructor(e,t){this.channel=e,this.channelRoot=e.doc(),this.options=t,this.dateFolder=new Ea(this.channelRoot,"chat.ttl"),this.div=null}async createMessage(e){return this.updateMessage(e)}async updateMessage(e,t=null,n,i=null){const a=[],o=new Date,s=""+o.getTime(),r=g.term(o),c=t?t.doc():this.dateFolder.leafDocumentFromDate(o),l=v.store.sym(c.uri+"#Msg"+s),p=v.authn.currentUser(),u={id:"",created:"",dateDeleted:"",content:"",maker:"",sig:""};if(u.id=l.uri,t){const e=v.store.any(t,b.foaf("maker"));if(e.uri!==p.uri){const t="Error you cannot delete/edit a message from someone else : \n"+e.uri;throw xe.R8(t),alert(t),new Error(t)}{const e=await Js(t);a.push(g.st(e,b.dct("isReplacedBy"),l,c));const i=v.store.any(e,b.sioc("has_reply"));i&&a.push(g.st(l,b.sioc("has_reply"),i,c)),n&&a.push(g.st(l,b.schema("dateDeleted"),r,c))}}else a.push(g.st(this.channel,b.wf("message"),l,c));if(a.push(g.st(l,b.sioc("content"),v.store.literal(e),c)),u.content=e,a.push(g.st(l,b.dct("created"),r,c)),u.created=r.value,p){a.push(g.st(l,b.foaf("maker"),p,c)),u.maker=p.uri;const e=function(e,t){return Na(Bs.sign(Fa(Ms(e)),Fa(t)))}(u,await Hs(p));a.push(g.st(l,g.sym(`${Os}proofValue`),g.lit(e),c))}i&&(a.push(g.st(i,b.sioc("has_member"),l,c)),i.doc().sameTerm(l.doc())||a.push(g.st(i,b.sioc("has_member"),l,i.doc())));try{await v.store.updater.updateMany([],a)}catch(e){const t="Error saving chat message: "+e;throw xe.R8(t),alert(t),new Error(t)}return l}async deleteMessage(e){return this.updateMessage("(message deleted)",e,!0)}async createThread(e){const t=v.store.each(e,b.sioc("has_reply"),null,e.doc()).filter(e=>v.store.holds(e,b.rdf("type"),b.sioc("Thread"),e.doc()));if(t.length>0)return t[0];const n=g.sym(e.uri+"-thread"),i=[g.st(n,b.rdf("type"),b.sioc("Thread"),n.doc()),g.st(e,b.sioc("has_reply"),n,n.doc())];return await v.store.updater.update([],i),n}}async function Ws(e){const t=[e],n={};n[e.uri]=!0;let i=e;for(;;){const e=v.store.any(null,b.dct("isReplacedBy"),i,i.doc());if(!e||n[e.uri])break;await v.store.fetcher.load(e),t.unshift(e),n[e.uri]=!0,i=e}for(i=e;;){const e=v.store.any(i,b.dct("isReplacedBy"),null,i.doc());if(!e||n[e.uri])break;t.push(e),n[e.uri]=!0,i=e}return t}async function Js(e){let t=e;const n={};for(;t;){if(n[t.uri])return xe.z3("mostRecentVersion: verion loop"+e),e;n[t.uri]=!0,e=t,await v.store.fetcher.load(e),t=v.store.any(e,b.dct("isReplacedBy"),null,e.doc())}return e}function Qs(e){return v.store.holds(e,b.schema("dateDeleted"),null,e.doc())}const Zs=v.solidLogicSingleton.store;function Ys(e,t,n,i,a,o){t.setAttribute("style",tt.participantsStyle);const s=function(n){const i=Zs.any(n,b.wf("participant"));let a;if(!i)return a=e.createElement("tr"),a.textContent="???",a;const s=Zs.anyValue(n,b.ui("backgroundColor"))||Xe,r=e.createElement("div");r.setAttribute("style",tt.participantsBlock),r.style.backgroundColor=s,a=qt(e,null,i,o),t.appendChild(a);const c=e.createElement("td");return c.setAttribute("style",tt.personTableTD),c.appendChild(r),a.insertBefore(c,a.firstChild),a},r=function(){const e=Zs.each(i,b.wf("participation")).map(function(e){return(0,xe.Rm)("in participants"),[Zs.anyValue(e,b.cal("dtstart"))||"9999-12-31",e]});e.sort();const n=e.map(function(e){return e[1]});Z(t,n,s)};return t.refresh=r,r(),t}function Ks(e,t,n){return new Promise(function(i,a){if(!n)throw new Error("No user id");const o=Zs.each(e,b.wf("participation")).filter(function(e){return Zs.holds(e,b.wf("participant"),n)});if(o.length>1){const e=[];for(const t of o){const n=Zs.anyValue(t,b.cal("dtstart"));n&&e.push([n,t])}e.sort(),xe.R8("Multiple participation objects, picking earliest, in "+t),i(e[0][1])}if(o.length)i(o[0]);else{const o=_i(t),s=[(0,g.st)(e,b.wf("participation"),o,t),(0,g.st)(o,b.wf("participant"),n,t),(0,g.st)(o,b.cal("dtstart"),new Date,t),(0,g.st)(o,b.ui("backgroundColor"),ir(n),t)];Zs.updater.update([],s,function(e,t,n){t?i(o):a(new Error("Error recording your participation: "+n))}),i(o)}})}function Xs(e,t,n){const i=v.authn.currentUser();if(!i)return;const a=Zs.each(e,b.wf("participation")).filter(function(e){return Zs.holds(e,b.wf("participant"),i)});if(a.length>1)throw new Error("Multiple records of your participation");if(a.length)return a[0];{if(!Zs.updater.editable(t))return xe.Rm("Not recording participation, as no write access as "+i+" to "+t),null;const a=_i(t),o=[(0,g.st)(e,b.wf("participation"),a,t),(0,g.st)(a,b.wf("participant"),i,t),(0,g.st)(a,b.cal("dtstart"),new Date,t),(0,g.st)(a,b.ui("backgroundColor"),ir(i),t)];return Zs.updater.update([],o,function(e,t,i){if(!t)throw new Error("Error recording your participation: "+i);n&&n.refresh&&n.refresh()}),a}}function er(e,t,n,i,a,o){const s=e.createElement("table");t.appendChild(s),Ys(e,s,0,i,0,o);try{Xs(i,n,s)}catch(n){t.appendChild(ot(e,"Error recording your participation: "+n))}return s}const tr=v.solidLogicSingleton.store,nr=(0,g.Namespace)("http://www.w3.org/ns/pim/pad#");function ir(e){return e&&e.uri?"#"+(16777215&(t=e.uri,t.split("").reduce(function(e,t){return(e=(e<<5)-e+t.charCodeAt(0))&e},0))|12632256).toString(16):"#ffffff";var t}function ar(e,t,n,i,a){const o=(a=a||{}).exists,s=e.createElement("table"),r=tr;if(i&&!i.uri)throw new Error("UI.pad.notepad: Invalid userid");const c=tr.updater,l=(0,g.Namespace)("http://www.w3.org/ns/pim/pad#");s.setAttribute("style",tt.notepadStyle);let p=null,u=null;if(a.statusArea){const t=a.statusArea.appendChild(e.createElement("table")).appendChild(e.createElement("tr"));p=t.appendChild(e.createElement("td")),u=t.appendChild(e.createElement("td")),p&&p.setAttribute("style",tt.upstreamStatus),u&&u.setAttribute("style",tt.downstreamStatus)}const d=function(t,n=!1){(0,xe.Rm)(t),a.statusArea&&(n?p:u).appendChild(ot(e,t,"pink"))},m=function(e){a.statusArea&&(a.statusArea.innerHTML="")},f=function(e,t,n){const i=e.subject;t=t||"";const a=tt.baseStyle,o=tt.headingCore,s=tt.headingStyle,c=r.any(i,b.dc("author"));if(!t&&c){t="color: "+(n?"#888":"black")+"; background-color: "+ir(c)+";"}let p=r.any(i,l("indent"));p=p?p.value:0;const u=p>=0?a+"text-indent: "+3*p+"em;":o+s[-1-p];e.setAttribute("style",u+t)},h=function(e){const i=e.subject;if(!i)throw new Error("No chunk for line to be deleted!");const a=r.any(void 0,l("next"),i),o=r.any(i,l("next"));if(a.sameTerm(n)&&o.sameTerm(n))return void(0,xe.Rm)("You can't delete the only line.");const s=r.statementsMatching(i,void 0,void 0,t).concat(r.statementsMatching(void 0,void 0,i,t)),p=[(0,g.st)(a,l("next"),o,t)];if(i instanceof g.NamedNode){const e=i.uri.slice(-4);(0,xe.Rm)("Deleting line "+e)}if(!c)throw new Error("have no updater");c.update(s,p,function(t,n,a,o){if(n){const t=e.parentNode;if(t){const e=t.previousSibling;t.parentNode&&t.parentNode.removeChild(t),e&&e.firstChild&&e.firstChild.focus()}}else if(o&&409===o.status)f(e,"color: black; background-color: #ffd;"),e.state=0,W(),setTimeout(function(){A()},1e3);else{(0,xe.Rm)(" removePart FAILED "+i+": "+a),(0,xe.Rm)(" removePart was deleting :'"+s),f(e,"color: black; background-color: #fdd;");const t=o?o.status:" [no response field] ";d("Error "+t+" saving changes: "+String(a))}})},v=function(e,n){let i=null;e.addEventListener("keydown",function(i){if(!c)throw new Error("no updater");let a,o;switch(i.keyCode){case 13:{const t=i.shiftKey;if((0,xe.Rm)("enter"),t?(o=r.any(void 0,l("next"),n),a="newlinesAfter"):(o=r.any(n,l("next")),a="newlinesBefore"),o[a]=o[a]||0,o[a]+=1,o[a]>1)return void(0,xe.Rm)(" queueing newline queue = "+o[a]);(0,xe.Rm)(" go ahead line before "+o[a]),y(e,t);break}case 8:if(0===e.value.length)switch((0,xe.Rm)("Delete key line "+n.uri.slice(-4)+" state "+e.state),e.state){case 1:case 2:return void(e.state=4);case 3:case 4:return;case void 0:case 0:e.state=3,h(e),i.preventDefault();break;default:throw new Error("pad: Unexpected state "+e)}break;case 9:{const a=i.shiftKey?-1:1;!function(e,n,i){const a=r.statementsMatching(n,l("indent")),o=a.length?Number(a[0].object.value):0;if(o+i<-3)return;const s=o+i,p=(0,g.st)(n,l("indent"),s,t);if(!c)throw new Error("no updater");c.update(a,p,function(n,i,a){i?f(e):((0,xe.Rm)("Indent change FAILED '"+s+"' for "+t+": "+a),f(e,"color: black; background-color: #fdd;"),c.requestDownstreamAction(t,A))})}(e,n,a),i.preventDefault();break}case 27:(0,xe.Rm)("escape"),c.requestDownstreamAction(t,A),i.preventDefault();break;case 38:e.parentNode.previousSibling&&(e.parentNode.previousSibling.firstChild.focus(),i.preventDefault());break;case 40:e.parentNode.nextSibling&&(e.parentNode.nextSibling.firstChild.focus(),i.preventDefault())}});const a=function(e){const n=e.subject;f(e,void 0,!0);const i=r.any(n,b.sioc("content")).value,o=[(0,g.st)(n,b.sioc("content"),i,t)];let s;e.value&&(s=[(0,g.st)(n,b.sioc("content"),e.value,t)]);const l=e.value;if(e.lastSent&&i!==e.lastSent&&console.warn("Out of order, last sent expected '"+i+"' but found '"+e.lastSent+"'"),e.lastSent=l,!c)throw new Error("no updater");c.update(o,s,function(n,o,s,r){if(o)m(),f(e),(0,xe.Rm)(" Patch ok '"+i+"' -> '"+l+"' "),4===e.state?(e.state=3,h(e)):3===e.state||(2===e.state?(e.state=1,a(e)):e.state=0);else if((0,xe.Rm)(" patch FAILED "+r.status+" for '"+i+"' -> '"+l+"': "+s),409===r.status)f(e,"color: black; background-color: #fdd;"),e.state=0,W(),setTimeout(function(){c.requestDownstreamAction(t,A)},1e3);else{f(e,"color: black; background-color: #fdd;");const t=r?.status;t&&502!==t&&503!==t?(e.state=0,d(" Error "+t+" sending data: "+s,!0),W()):(e.lastSent=void 0,e.state=0,setTimeout(()=>{0!==e.state&&void 0!==e.state||(e.state=1,a(e))},2e3))}})};e.addEventListener("input",function(t){switch(f(e,void 0,!0),(0,xe.Rm)("Input event state "+e.state+" value '"+e.value+"'"),e.state){case 3:case 4:case 2:return;case 1:return void(e.state=2);case 0:case void 0:null!==i&&clearTimeout(i),i=setTimeout(()=>{i=null,0!==e.state&&void 0!==e.state||(e.state=1,a(e))},400)}})},x=function(t,n,a){let o=r.any(n,b.sioc("content"));o=o?o.value:"";const c=e.createElement("tr");a?s.insertBefore(c,t):t&&t.nextSibling?s.insertBefore(c,t.nextSibling):s.appendChild(c);const l=c.appendChild(e.createElement("input"));return l.subject=n,l.setAttribute("type","text"),l.value=o,i?(f(l,""),v(l,n)):(f(l,"color: #222; background-color: #fff"),(0,xe.Rm)("Note can't add listeners - not logged in")),l},y=function(e,a){const o=tr;let s,r,p,u,d,m=0,h=null;e?("input"!==e.tagName.toLowerCase()&&(0,xe.Rm)("return pressed when current document is: "+e.tagName),s=e.subject,m=o.any(s,l("indent")),m=m?Number(m.value):0,a?(r=o.any(void 0,l("next"),s),p=s,u=r,h="newlinesAfter"):(r=s,p=o.any(s,l("next")),u=p,h="newlinesBefore"),d=e.parentNode):(r=n,p=n,d=void 0);const v=_i(t),w=v.uri.slice(-4),C=[(0,g.st)(r,l("next"),p,t)],E=[(0,g.st)(r,l("next"),v,t),(0,g.st)(v,l("next"),p,t),(0,g.st)(v,b.dc("author"),i,t),(0,g.st)(v,b.sioc("content"),"",t)];if(m>0&&E.push((0,g.st)(v,l("indent"),m,t)),(0,xe.Rm)(" Fresh chunk "+w+" proposed"),!c)throw new Error("no updater");c.update(C,E,function(e,t,n,i){if(t){const e=x(d,v,a);f(e),e.focus(),h&&((0,xe.Rm)(" Fresh chunk "+w+" updated, queue = "+u[h]),u[h]-=1,u[h]>0&&((0,xe.Rm)(" Implementing queued newlines = "+p.newLinesBefore),y(e,a)))}else(0,xe.Rm)(" ERROR writing new line "+w+": "+n)})},w=function(){const e={};let t=0;function i(e){d(e),t++}if(!r.the(n,l("next")))return i("No initial next pointer"),!1;let a,o=n;for(;a=r.the(o,l("next")),a||i("No next pointer from "+o),!a.sameTerm(n);){o=a;const t=a.uri.split("#")[1];if(e[a.uri])return i("Loop!"),!1;e[a.uri]=!0;let n=r.each(a,l("next")).length;1!==n&&i("Should be 1 not "+n+" next pointer for "+t),n=r.each(a,l("indent")).length,n>1&&i("Should be 0 or 1 not "+n+" indent for "+t),n=r.each(a,b.sioc("content")).length,1!==n&&i("Should be 1 not "+n+" contents for "+t),n=r.each(a,b.dc("author")).length,1!==n&&i("Should be 1 not "+n+" author for "+t);r.statementsMatching(void 0,b.sioc("contents")).forEach(function(t){e[t.subject.value]||i("Loose chunk! "+t.subject.value)})}return!t},C=function(){if(1!==r.each(n,l("next")).length){const e="Pad: Inconsistent data - NEXT pointers: "+r.each(n,l("next")).length;return(0,xe.Rm)(e),void(a.statusArea&&(a.statusArea.textContent+=e))}let e;const t=[];for(let e=r.the(n,l("next"));!e.sameTerm(n);e=r.the(e,l("next")))for(let n=0;n<s.children.length;n++){const i=s.children[n];i.firstChild&&i.firstChild.subject.sameTerm(e)&&(t[e.uri]=i.firstChild)}for(let n=s.children.length-1;n>=0;n--)e=s.children[n],t[e.firstChild.subject.uri]||s.removeChild(e);e=s.firstChild;for(let i=r.the(n,l("next"));!i.sameTerm(n);i=r.the(i,l("next"))){const n=r.any(i,b.sioc("content")).value;if(e&&t[i.uri]){const t=e.firstChild;n!==t.value&&(t.value=n),f(t),t.state=0,delete t.lastSent,e=e.nextSibling}else x(e,i,!0)}},E=function(e){if(e.refresh)e.refresh();else for(let t=0;t<e.children.length;t++)E(e.children[t])};let k=!1;const A=function(){if(k)return void(0,xe.Rm)(" Already reloading - stop");k=!0;let e=1e3;const n=function(){if((0,xe.Rm)("try reload - timeout = "+e),!c)throw new Error("no updater");c.reload(c.store,t,function(i,a,o){k=!1,i?((0,xe.Rm)(" reloaded OK"),m(),w()?E(s):d("CONSISTENCY CHECK FAILED")):0===o.status?(d("Network error refreshing the pad. Retrying in "+e/1e3),k=!0,e*=2,setTimeout(n,e)):d("Error "+o.status+"refreshing the pad:"+a+". Stopped. "+t)})};n()};if(s.refresh=C,s.reloadAndSync=A,i||(0,xe.Rm)("Warning: must be logged in for pad to be edited"),o)(0,xe.Rm)("Existing pad."),w()?(C(),r.holds(n,l("next"),n)&&y()):(0,xe.Rm)(s.textContent="Inconsistent data. Abort");else{(0,xe.Rm)("No pad exists - making new one.");const e=[(0,g.st)(n,b.rdf("type"),l("Notepad"),t),(0,g.st)(n,b.dc("author"),i,t),(0,g.st)(n,b.dc("created"),new Date,t),(0,g.st)(n,l("next"),n,t)];if(!c)throw new Error("no updater");c.update([],e,function(e,t,n){t?((0,xe.Rm)("Initial pad created"),y()):d(n||"")})}return s}function or(e,t){const n=[];for(let i=t.the(e,nr("next"));!i.sameTerm(e);i=t.the(i,nr("next")))n.push(i);return n}function sr(e){return e.replace("&","&amp;").replace("<","&lt;").replace(">","&gt;")}function rr(e,t){const n=or(e,t);let i="<html>\n <head>\n";const a=t.anyValue(e,b.dct("title"));a&&(i+=` <title>${sr(a)}</title>\n`),i+=" </head>\n <body>\n";let o=0;function s(e){for(;o>e;o--)i+="</ul>\n"}return n.forEach(e=>{const n=t.anyJS(e,nr("indent")),a=t.anyJS(e,b.sioc("content"));if(!a)return;const r=sr(a);if(n<0){s(0);const e=n>=-3?4+n:1;i+=`\n<h${e}>${r}</h${e}>\n`}else n>0?(s(n),function(e){for(;o<e;o++)i+="<ul>\n"}(n),i+=`<li>${r}</li>\n`):(s(n),i+=`<p>${r}</p>\n`)}),s(0),i+=" </body>\n</html>\n",i}const cr={icons:st.Pt,ns:b,media:ya,pad:p,style:tt,utils:a,widgets:r},lr=g.Namespace("http://www.w3.org/2002/01/bookmark#"),pr=F,ur=window.document||null;function dr(e,t){return new Promise(function(n,i){v.store.updater.update(e,t,function(e,t,a){t?n():i(new Error(a))})})}async function mr(e,t,n){await v.store.fetcher.load(e.bookmarkDocument);const i=v.store.each(null,lr("recalls"),t,e.bookmarkDocument);if(i.length){if(!confirm("Delete bookmark on this?"+i.length))return;for(let e=0;e<i.length;e++)try{await dr(v.store.connectedStatements(i[e]),[]),n.style.backgroundColor="white",xe.Rm("Bookmark deleted: "+i[e])}catch(e){xe.z3("Cant delete bookmark:"+e),xe.R8("Cannot delete bookmark:"+e)}}else{const i=await async function(e,t){let n="";const i=v.authn.currentUser();if(!i)throw new Error("Must be logged on to add Bookmark");const a=v.store.any(t,b.foaf("maker"));n=pr(a)+": "+v.store.anyValue(t,b.sioc("content")).slice(0,80);const o=e.bookmarkDocument,s=cr.widgets.newThing(o,n),r=[g.st(o,cr.ns.dct("references"),s,o),g.st(s,cr.ns.rdf("type"),lr("Bookmark"),o),g.st(s,cr.ns.dct("created"),new Date,o),g.st(s,lr("recalls"),t,o),g.st(s,cr.ns.foaf("maker"),i,o),g.st(s,cr.ns.dct("title"),n,o)];try{await dr([],r)}catch(e){const t="Making bookmark: "+e;return xe.R8(t),null}return s}(e,t);n.style.backgroundColor="yellow",xe.Rm("Bookmark added: "+i)}}const fr=window.document,hr={};async function gr(e,t,n,i){async function a(t){c.value===v.store.any(e,b.foaf("maker")).value&&(s(),await async function(e,t,n,i){const a=e.parentNode,o=kr(n,a,i,n.options,await Js(t));a.insertBefore(o,e),o.originalRow=e,e.style.visibility="hidden"}(t,e,i,n))}const o=fr.createElement("div");if(await Js(e).value===b.schema("dateDeleted").value)return o;function s(){o.parentElement.parentElement.removeChild(o.parentElement)}async function r(e){await v.store.updater.update(v.store.connectedStatements(e),[])}let c=v.authn.currentUser();function l(e,n,i,a,o,s){function c(){l.style.backgroundColor=d?"yellow":"white"}const l=Ut(fr,i,F(a),async function(i){if(d)await r(d),d=null,c();else{d=_i(o);const i=[g.st(d,b.schema("agent"),e.me,o),g.st(d,b.rdf("type"),a,o),g.st(d,b.schema("target"),n,o)];if(await v.store.updater.update([],i),c(),s){let e=!1;for(let t=0;t<s.length;t++){const n=p(s[t]);n&&(await r(n),e=!0)}e&&Jt(t)}}});function p(t){const i=v.store.each(null,b.schema("agent"),e.me,o).filter(e=>v.store.holds(e,b.rdf("type"),t,o)).filter(e=>v.store.holds(e,b.schema("target"),n,o));return i.length?i[0]:null}function u(){d=p(a),c()}let d;return l.refresh=u,u(),l}if(c&&v.store.holds(e,b.foaf("maker"),c)&&(o.appendChild(Mt(fr,o,"message",async function(){const a=v.store.any(e,b.foaf("maker"));if(c)if(c.sameTerm(a)){try{await i.deleteMessage(e)}catch(e){const i="Error deleting messaage "+e;xe.R8(i),alert(i),(n.statusArea||t.parentNode).appendChild(ot(fr,i))}t.parentNode.removeChild(t)}else alert("You can't delete the message, you are not logged in as the author, "+a);else alert("You can't delete the message, you are not logged in.");s()})),o.appendChild(Ut(fr,st.Pt.iconBase+"noun_253504.svg","edit",()=>a(t)))),async function(e,t){let n;if(e.bookmarkDocument)return n=cr.widgets.button(ur,cr.icons.iconBase+"noun_45961.svg",pr(lr("Bookmark")),()=>{mr(e,t,n)}),n.target=t,await async function(t){await v.store.fetcher.load(e.bookmarkDocument);const n=v.store.any(null,lr("recalls"),t.target,e.bookmarkDocument);t.style=cr.style.buttonStyle,n&&(t.style.backgroundColor="yellow")}(n),n}(n).then(e=>{e&&o.appendChild(e)}),c=v.authn.currentUser(),c&&await Js(e).value!==b.schema("dateDeleted").value){const t={me:c,dom:fr,div:o};o.appendChild(l(t,e,st.Pt.iconBase+"noun_1384132.svg",b.schema("AgreeAction"),e.doc(),[b.schema("DisagreeAction")])),o.appendChild(l(t,e,st.Pt.iconBase+"noun_1384135.svg",b.schema("DisagreeAction"),e.doc(),[b.schema("AgreeAction")]))}v.store.any(e,b.dct("created"))&&o.appendChild(Ut(fr,st.Pt.iconBase+"noun-reply-5506924.svg","Reply in thread",async()=>{await async function(){const t=await i.createThread(e),a=n.chatOptions;if(!a)throw new Error("replyInThread: missing options");a.showThread(t,a),s()}()}));const p=o.appendChild(Ft(fr));return p.style.float="right",p.firstChild.style.opacity="0.3",p.addEventListener("click",s),o}hr[b.schema("AgreeAction")]="👍",hr[b.schema("DisagreeAction")]="👎",hr[b.schema("EndorseAction")]="⭐️",hr[b.schema("LikeAction")]="❤️";const br=window.document,vr=tt.messageBodyStyle,xr=F;const yr=function(e,t){const n=br.createElement("a");return t&&t.uri&&(n.setAttribute("href",t.uri),n.addEventListener("click",Zt,!0),n.setAttribute("style","color: #3B5998; text-decoration: none; ")),n.textContent=e,n};function wr(e){const t=v.store.any(e,b.foaf("nick"));return t?""+t.value:""+xr(e)}function Cr(e,t,n,i){const a=e.appendChild(yr(wr(t),t));t.uri&&v.store.fetcher.nowOrWhenFetched(t.doc(),void 0,function(e,n){a.textContent=wr(t)}),e.appendChild(br.createElement("br")),e.appendChild(yr(n,i))}async function Er(e,t,n,i,a){let o=!1;const s="1"===i.colorizeByAuthor||!0===i.colorizeByAuthor,r=v.store.any(t,b.foaf("maker")),c=v.store.any(t,b.dct("created")),l=await Js(t),p=v.store.any(l,b.foaf("maker")),u=r.uri===p?.uri?l:t,d=v.store.any(u,b.sioc("content")),m=await Ws(u);m.length>1&&xe.Rm("renderMessageRow versions: ",m.join(", "));const f=m.map(e=>v.store.each(e,b.sioc("has_reply"))).flat();let h=null;const g=[];for(const e of f)v.store.holds(e,b.rdf("type"),b.sioc("Thread"))?(h=e,xe.Rm("renderMessageRow: found thread: "+h)):g.push(e);g.length>1&&xe.Rm("renderMessageRow: found normal replies: ",g),h||(h=v.store.any(null,b.sioc("has_member"),t));const x=v.store.any(u,$rdf.sym(`${Os}proofValue`)),y={id:"",created:"",dateDeleted:"",content:"",maker:"",sig:""};y.id=u.uri,y.created=v.store.any(u,b.dct("created")).value,y.content=d.value,y.maker=r.uri,x?.value?async function(e){await v.store.fetcher.load(e);const t=await Fs(e);try{await v.store.fetcher.load(t);const n=v.store.any(e,b.solid("publicKey"));return n?.value}catch(e){return}}(r).then(e=>{e||xe.R8("message is signed but "+r.uri+" is missing publicKey");e?.match(/[0-9A-Fa-f]{6}/g)?x?.value&&!function(e,t,n){return Bs.verify(Fa(e),Fa(Ms(t)),Fa(n))}(x?.value,y,e)&&xe.R8("invalid signature\n"+y.id):xe.R8("invalid publicKey hex string\n"+r.uri+"\n"+e)}):(o=!0,xe.R8(u.uri+" is unsigned"));const w=await async function(e){let t=e;const n={};for(;t;){if(n[t.uri])return xe.z3("originalVersion: verion loop"+e),e;n[t.uri]=!0,e=t,await v.store.fetcher.load(e),t=v.store.any(null,b.dct("isReplacedBy"),e,e.doc())}return e}(t),C=!t.sameTerm(w),E=v.store.the(w,b.dct("created"),null,w.doc())||v.store.the(t,b.dct("created"),null,t.doc()),k=br.createElement("tr");o&&k.setAttribute("style","background-color: red"),k.AJAR_date=E.value,k.AJAR_subject=t;const A=br.createElement("td");if(k.appendChild(A),i.authorDateOnLeft)Cr(A,r,At(E.value),t);else{const e=br.createElement("img");e.setAttribute("style","max-height: 2.5em; max-width: 2.5em; border-radius: 0.5em; margin: auto;"),Dt(e,r),A.appendChild(e)}let _=At(E.value);C&&(_+=" ... "+At(c.value));const T=k.appendChild(br.createElement("td"));i.authorDateOnLeft||function(e,t,n,i){const a=e.appendChild(yr(xr(t),t));t.uri&&v.store.fetcher.nowOrWhenFetched(t.doc(),void 0,function(e,n){a.textContent=wr(t)});const o=e.appendChild(yr(n,i));o.style.fontSize="80%",o.style.marginLeft="1em",e.appendChild(br.createElement("br"))}(T,r,_,t);const S=d?d.value.trim():"??? no content?";let j=null;if(/^https?:\/[^ <>]*$/i.test(S)){if(/\.(gif|jpg|jpeg|tiff|png|svg)$/i.test(S)&&i.expandImagesInline){const e=function(e,t){const n=br.createElement("img");let i="10";t.inlineImageHeightEms&&(i=(""+t.inlineImageHeightEms).trim()),n.setAttribute("style","max-height: "+i+"em; border-radius: 1em; margin: 0.7em;"),e&&n.setAttribute("src",e);const a=br.createElement("a");return a.setAttribute("href",e),a.setAttribute("target","images"),a.appendChild(n),it(n,$rdf.sym(e)),a}(S,i);T.appendChild(e)}else{const e=T.appendChild(br.createElement("a"));j=e.appendChild(br.createElement("p")),e.href=S,j.textContent=S,T.appendChild(e)}}else j=br.createElement("p"),T.appendChild(j),j.textContent=S;if(j){const e=s?ir(r):function(e){return e?"#e8ffe8":"white"}(n);j.setAttribute("style",vr+"background-color: "+e+";")}const L=await async function(e,t){const n=fr.createElement("span");async function i(){if(n.innerHTML="",Qs(e))return n;const i=(await Ws(e)).map(e=>v.store.each(null,b.schema("target"),e,t)).flat();if(0===i.length)return n;const a=i.map(e=>[v.store.any(e,b.rdf("type"),null,t),v.store.any(e,b.sioc("content"),null,t),v.store.any(e,b.schema("agent"),null,t)]);a.sort(),a.forEach(e=>{const[t,i,a]=e;let o;a?(o=fr.createElement("a"),o.setAttribute("href",a.uri)):o=fr.createTextNode(""),o.textContent=i||hr[t]||"⬜️",n.appendChild(o)})}return i().then(xe.Rm("sentimentStripLinked: sentimentStripLinked async refreshed")),n.refresh=i,n}(t,t.doc());L.children.length&&(T.appendChild(br.createElement("br")),T.appendChild(L));const R=br.createElement("td");k.appendChild(R);const N=Ut(br,st.Pt.iconBase+"noun_243787.svg","...");return R.appendChild(N),N.addEventListener("click",async function(n){if(k.toolTR)return k.parentNode.removeChild(k.toolTR),void delete k.toolTR;const o=br.createElement("tr"),s=await gr(t,k,{...a,chatOptions:i},e);s.style="border: 0.05em solid #888; border-radius: 0 0 0.7em 0.7em; border-top: 0; height:3.5em; background-color: #fff;",k.nextSibling?k.parentElement.insertBefore(o,k.nextSibling):k.parentElement.appendChild(o),k.toolTR=o,o.appendChild(br.createElement("td"));const r=o.appendChild(br.createElement("td"));o.appendChild(br.createElement("td")),r.appendChild(s)}),h&&i.showThread&&R.appendChild(Ut(br,st.Pt.iconBase+"noun_1180164.svg","see thread",e=>{i.showThread(h,i)})),k}function kr(e,t,n,i,a){async function o(e){await s(h.value,!0)}async function s(o,s){let r;s&&(h.setAttribute("style",vr+"color: #bbb;"),h.disabled=!0);try{r=await e.updateMessage(o,a,null,i.thread)}catch(e){return void(n.statusArea||u).appendChild(ot(br,"Error writing message: "+e))}await async function(o){if(await Ar(e,t,o,!1,i,n),a){const e=u.originalRow;e.parentNode?e.parentNode.removeChild(e):(xe.R8("No parentNode on old message "+e.textContent),e.style.backgroundColor="#fee",e.style.visibility="hidden"),u.parentNode.removeChild(u)}else s&&(h.value="",h.setAttribute("style",vr),h.disabled=!1,h.scrollIntoView(i.newestFirst),h.focus(),h.select())}(r)}function r(e){const n=t.chatDocument.dir().uri;at(v.store.fetcher,e,n+"Files",n+"Pictures",async function(e,t){await s(t)})}const c=async function(e){for(const t of e)await s(t)};let l,p;a?(l=v.store.anyValue(a,b.dct("created"),null,a.doc()),p=st.Pt.iconBase+"noun_1180158.svg"):(p=st.Pt.iconBase+"noun_383448.svg",l="9999-01-01T00:00:00Z");const u=br.createElement("tr"),d=br.createElement("td"),m=br.createElement("td"),f=br.createElement("td");let h,x;u.appendChild(d),u.appendChild(m),u.appendChild(f),u.AJAR_date=l;return Mi({div:m,dom:br}).then(t=>{!function(){if(i.menuHandler){const e=Ut(br,st.Pt.iconBase+"noun_243787.svg","More");e.setAttribute("style",tt.buttonStyle+"float: right;"),f.appendChild(e)}i.menuHandler;const t=v.authn.currentUser();if(Cr(d,t,"",null),h=br.createElement("textarea"),m.innerHTML="",m.appendChild(h),h.rows=3,a&&(h.value=v.store.anyValue(a,b.sioc("content"),null,a.doc())),h.setAttribute("style",vr+"background-color: #eef;"),h.addEventListener("keydown",async function(e){"Enter"===e.code&&(!e.shiftKey&&!i.shiftEnterSendsMessage||e.shiftKey&&i.shiftEnterSendsMessage)&&await o()},!1),nt(h,c,r),f.innerHTML="",x=Ut(br,p,"Send"),x.style.float="right",x.addEventListener("click",e=>o(),!1),f.appendChild(x),a){const e=f.appendChild(Ft(br));e.style.float="left",e.addEventListener("click",e=>function(e){e.originalRow.style.visibility="visible",e.parentNode.removeChild(e)}(u),!1),f.appendChild(e)}const n=e.dateFolder.leafDocumentFromDate(new Date);let l;m.appendChild(ya.cameraButton(br,v.store,function(){return l=$rdf.sym(n.dir().uri+"Image_"+Date.now()+".png"),l},async function(e){e&&await s(e.uri)})),Xs(e.channel,e.channel.doc())}(),Object.assign(t,n),async function(e){const t=lr("Bookmark");if(await Pi(e,t,!0),e.instances&&e.instances.length>0)e.bookmarkDocument=e.instances[0],e.instances.length>1&&xe.R8("More than one bookmark file! "+e.instances);else if(e.publicProfile){const n=g.sym(e.publicProfile.dir().uri+"bookmarks.ttl");try{xe.Rm("Creating new bookmark file "+n),await v.store.fetcher.createIfNotExists(n)}catch(t){return xe.R8("Can't make fresh bookmark file:"+t),e}await v.createTypeIndexLogic.registerInTypeIndex(n,e.index,t),e.bookmarkDocument=n}else xe.R8("You seem to have no bookmark file, nor even a profile file!");return e}(t).then(e=>{})}),u}async function Ar(e,t,n,i,a,o){const s=await Er(e,n,i,a,o);a.selectedMessage&&a.selectedMessage.sameTerm(n)&&(s.style.backgroundColor="yellow",a.selectedElement=s,t.selectedElement=s);let r=!1;for(let e=t.firstChild;e;e=e.nextSibling){const n=!0===a.newestfirst,i=s.AJAR_date;if(i>e.AJAR_date&&n||i<e.AJAR_date&&!n){t.insertBefore(s,e),r=!0;break}}r||t.appendChild(s)}const _r=v.store,Tr=[];function Sr(e){return Tr[e]}function jr(e,t){if("string"!=typeof t)throw xe.Rm("Non-string value of preference "+e+": "+t),new Error("Non-string value of preference "+e+": "+t);this.value[e]=t}function Lr(e,t){return new Promise(function(n,i){const a=_r.any(e,b.ui("sharedPreferences"));if(a)t.sharedPreferences=a,n(t);else{_r.updater.editable(e.doc())||(xe.Rm(` Cant make shared preferences, may not change ${e.doc}`),n(t));const a=g.sym(e.doc().uri+"#SharedPreferences"),o=[g.st(e,b.ui("sharedPreferences"),a,e.doc())];xe.Rm("Creating shared preferences "+a),_r.updater.update([],o,function(e,o,s){o?(t.sharedPreferences=a,n(t)):i(new Error("Error creating shared prefs: "+s))})}})}function Rr(e,t){return new Promise(function(n,i){Ui(t).then(t=>{if(!t.preferencesFile)return void xe.Rm("Not doing private class preferences as no access to preferences file. "+t.preferencesFileError);const a=_r.each(null,b.solid("forClass"),e,t.preferencesFile);let o,s,r=[];if(a.length){if(a.forEach(e=>{o=o||_r.any(e,b.solid("personalDefaults"))}),o)return t.personalDefaults=o,void n(t);o=_i(t.preferencesFile),s=a[0]}else s=_i(t.preferencesFile),r=[g.st(s,b.rdf("type"),b.solid("TypeRegistration"),t.preferencesFile),g.st(s,b.solid("forClass"),e,t.preferencesFile)];o=_i(t.preferencesFile),r.push(g.st(s,b.solid("personalDefaults"),o,t.preferencesFile)),_r.updater.update([],r,function(a,s,r){s?(t.personalDefaults=o,n(t)):i(new Error("Setting preferences for "+e+": "+r))})},e=>{i(e)})})}function Nr(e,t,n,i){const a=i.dom.createElement("div");return Ks(e,e.doc(),i.me).then(o=>{const s=i.dom;function r(e){a.appendChild(s.createElement("h5")).textContent=e}r("My view of this "+i.noun),di(s,a,{},o,n,e.doc(),(e,t)=>{e||Ct(i,t)}),r("Everyone's view of this "+i.noun),Lr(e,i).then(i=>{const o=i.sharedPreferences;di(s,a,{},o,n,e.doc(),(e,t)=>{e||Ct(i,t)}),r("My default view of any "+i.noun),Rr(t,i).then(e=>{di(s,a,{},e.personalDefaults,n,e.preferencesFile,(t,n)=>{t||Ct(e,n)})},e=>{Ct(i,e)})})},e=>{a.appendChild(ot(i.dom,e))}),a}function Ir(e){return e.datatype?e.datatype.equals(b.xsd("boolean"))?"1"===e.value:e.datatype.equals(b.xsd("dateTime"))||e.datatype.equals(b.xsd("date"))?new Date(e.value):e.datatype.equals(b.xsd("integer"))||e.datatype.equals(b.xsd("float"))||e.datatype.equals(b.xsd("decimal"))?Number(e.value):e.value:e}function $r(e,t,n,i){return new Promise(function(a,o){Lr(e,i).then(i=>{const s=i.sharedPreferences;if(i.me)Ks(e,e.doc(),i.me).then(e=>{Rr(t,i).then(t=>{const i=[],o=t.personalDefaults;n.forEach(t=>{const n=_r.any(e,t)||_r.any(s,t)||_r.any(o,t);n&&(i[t.uri]=Ir(n))}),a(i)},o)},o);else{const e=[];n.forEach(t=>{const n=_r.any(s,t);n&&(e[t.uri]=Ir(n))}),a(e)}})})}const Br={icons:st.Pt,log:i,ns:b,utils:a,widgets:r};class Dr extends HTMLElement{bodyContainer;refresh;tabContainer}function Or(e){const t=e.subject,n=e.dom||document,i=parseInt(e.orientation||"0"),a=e.backgroundColor||"#ddddcc",o=2&i,s=1&i,r=e.onClose,[c,l]=function(e){return function(e){let t=0;for(let n=0;n<3;n++)t+=parseInt(e.slice(2*n+1,2*n+3),16);return t>384}(e)?[Mr(e,"#ffffff",.3),"#000000"]:[Mr(e,"#000000",.3),"#ffffff"]}(a),p=`display: grid; width: auto; height: 100%; border: 0.1em; border-style: solid; border-color: ${c}; padding: 1em;`,u=n.createElement("div");u.setAttribute("style",tt.tabsRootElement),u.style.flexDirection=(s?"row":"column")+(o?"-reverse":"");const d=u.appendChild(n.createElement("nav"));d.setAttribute("style",tt.tabsNavElement);const m=u.appendChild(n.createElement("main"));m.setAttribute("style",tt.tabsMainElement);const f=d.appendChild(n.createElement("ul"));f.setAttribute("style",tt.tabContainer),f.style.flexDirection=""+(s?"column":"row");const h=m;u.tabContainer=f,u.bodyContainer=h;const g=["0.2em","0.2em","0","0"],b=`border-radius: ${g.concat(g).slice(i,i+4).join(" ")};`,x=["0.3em","0.3em","0","0.3em"],y=x.concat(x).slice(i,i+4),w=`margin: ${y.join(" ")};`,C=`padding: ${y.join(" ")};`,E=b+`position: relative; padding: 0.7em; max-width: 20em; color: ${l};`,k=`${E+w} opacity: 50%; background-color: ${a};`,A=`${E+w} background-color: ${c};`,_="height: 100%; width: 100%;",T=_+"display: none;";if(u.refresh=j,j(),!e.startEmpty&&f.children.length&&e.selectedTab){const t=Array.from(f.children).map(e=>e.firstChild).find(t=>t.dataset.name===e.selectedTab),n=e.selectedTab.uri,i=Array.from(f.children).find(e=>e.subject&&e.subject.uri&&e.subject.uri===n),a=i||t||f.children[0],o=a.firstChild;o?.click?o.click():a instanceof HTMLElement&&a.click()}else if(!e.startEmpty){const e=f.children[0],t=e?.firstChild;t?.click?t.click():e instanceof HTMLElement&&e.click()}return u;function S(t){const i=n.createElement("li");i.setAttribute("style",k),i.subject=t;const a=i.appendChild(n.createElement("button"));if(a.setAttribute("style",tt.makeNewSlot),a.onclick=function(){if(L(),R(),i.setAttribute("style",A),!i.bodyTR)return;i.bodyTR.setAttribute("style",_);const n=o(i);e.renderMain&&i.subject&&!1!==n.asSettings&&(n.innerHTML="loading item ..."+t,e.renderMain(n,i.subject),n.asSettings=!1)},e.renderTabSettings&&i.subject){const a=n.createElement("button");a.textContent="...",a.setAttribute("style",tt.ellipsis),a.onclick=function(){if(L(),R(),i.setAttribute("style",A),!i.bodyTR)return;i.bodyTR.setAttribute("style",_);const n=o(i);e.renderTabSettings&&i.subject&&!0!==n.asSettings&&(n.innerHTML="loading settings ..."+t,e.renderTabSettings(n,i.subject),n.asSettings=!0)},i.appendChild(a)}return e.renderTab?e.renderTab(a,t):a.innerHTML=F(t),i;function o(e){const t=e.bodyTR?.children[0];if(t)return t;const i=e.bodyTR.appendChild(n.createElement("main"));return i.setAttribute("style",p),i}}function j(){const i=e.items?e.items:!1!==e.ordered?v.store.the(t,e.predicate).elements:v.store.each(t,e.predicate);let a,o,s,c,l,p=!1;for(c=0;c<f.children.length;c++)if(a=f.children[c],c>=i.length||a.subject&&!a.subject.sameTerm(i[c])){p=!0;break}if(!p&&i.length===f.children.length)return;for(l=f.children.length-1;l>=0&&(a=f.children[l],s=l-f.children.length+i.length,!a.subject||a.subject.sameTerm(i[s]));l--);const u=i.slice(c,l-f.children.length+i.length+1);for(;l>=c;)f.removeChild(f.children[c]),h.removeChild(h.children[c]),l-=1;for(o=0;o<u.length;o++){const e=S(u[o]),t=n.createElement("div");e.bodyTR=t,c===f.children.length?(f.appendChild(e),h.appendChild(t)):(f.insertBefore(e,f.children[c+o]),h.insertBefore(t,h.children[c+o]))}r&&function(e){if(e.dataset.onCloseSet){const t=e.querySelector(".unstyled");e.removeChild(t)}const t=n.createElement("li");t.classList.add("unstyled");const i=Ft(n,r);i.setAttribute("style",i.getAttribute("style")+C),t.appendChild(i),e.appendChild(t),e.dataset.onCloseSet="true"}(f)}function L(){for(let e=0;e<f.children.length;e++){const t=f.children[e];t.classList.contains("unstyled")||t.setAttribute("style",k)}}function R(){for(let e=0;e<h.children.length;e++)h.children[e].setAttribute("style",T)}}function Mr(e,t,n){let i,a,o,s="#";const r="0123456789abcdef";for(let c=0;c<3;c++){i=parseInt(e.slice(2*c+1,2*c+3),16),a=parseInt(t.slice(2*c+1,2*c+3),16),o=i*(1-n)+a*n;const l=parseInt((""+o).split(".")[0]),p=parseInt((""+l/16).split(".")[0]),u=parseInt((""+l%16).split(".")[0]);s+=r[p]+r[u]}return s}const Ur='\n<svg xmlns="http://www.w3.org/2000/svg" width="26" height="26" viewBox="0 0 26 26" fill="none">\n <path fill-rule="evenodd" clip-rule="evenodd" d="M13 25C19.6274 25 25 19.6274 25 13C25 6.37258 19.6274 1 13 1C6.37258 1 1 6.37258 1 13C1 19.6274 6.37258 25 13 25Z" fill="#D8D8D8" stroke="#8B8B8B"/>\n <mask id="mask0" mask-type="alpha" maskUnits="userSpaceOnUse" x="0" y="0" width="26" height="26">\n <path fill-rule="evenodd" clip-rule="evenodd" d="M13 25C19.6274 25 25 19.6274 25 13C25 6.37258 19.6274 1 13 1C6.37258 1 1 6.37258 1 13C1 19.6274 6.37258 25 13 25Z" fill="white" stroke="white"/>\n </mask>\n <g mask="url(#mask0)">\n <path fill-rule="evenodd" clip-rule="evenodd" d="M17.0468 10.4586C17.0468 14.4979 15.4281 16.9214 12.9999 16.9214C10.5718 16.9214 8.95298 14.4979 8.95298 10.4586C8.95298 6.41931 12.9999 6.41931 12.9999 6.41931C12.9999 6.41931 17.0468 6.41931 17.0468 10.4586ZM4.09668 23.3842C6.52483 17.7293 12.9999 17.7293 12.9999 17.7293C12.9999 17.7293 19.475 17.7293 21.9031 23.3842C21.9031 23.3842 17.8481 25 12.9999 25C8.15169 25 4.09668 23.3842 4.09668 23.3842Z" fill="#8B8B8B"/>\n </g>\n</svg>';var Fr=n(565);const Pr=st.Pt.iconBase+"noun_help.svg",zr="https://solidproject.org/assets/img/solid-emblem.svg";function qr(e,t,n,i,a){return async()=>{const o=v.authn.currentUser();e.innerHTML="",e.appendChild(await async function(e,t,n,i,a){const o=document.createElement("a");o.href=t.uri,o.setAttribute("style",tt.headerBannerLink);const s=document.createElement("img");a&&(s.src=a.logo?a.logo:zr);s.setAttribute("style",tt.headerBannerIcon),o.appendChild(s);const r=n?await async function(e,t,n){const i=e.fetcher;i&&await i.load(t);const a=document.createElement("ul");a.setAttribute("style",tt.headerUserMenuList),n&&n.forEach(function(e){"url"===(e.url?"url":"onclick")?a.appendChild(Gr(Vr(e.label,e.url,e.target))):a.appendChild(Gr(Hr(e.label,e.onclick)))});const o=document.createElement("nav");o.setAttribute("style",tt.headerUserMenuNavigationMenuNotDisplayed),o.setAttribute("aria-hidden","true"),o.setAttribute("id","loggedInNav"),o.appendChild(a);const s=document.createElement("button");s.setAttribute("style",tt.headerUserMenuTrigger),s.type="button";const r=function(e,t){let n=null;try{if(n=$t(t),!n)return Ur}catch{return Ur}const i=document.createElement("div");return i.setAttribute("style",tt.headerUserMenuPhoto),i.style.backgroundImage=`url(${n})`,i}(0,t);"string"==typeof r?s.innerHTML=r:s.appendChild(r);const c=document.createElement("div");c.setAttribute("style",tt.headerBannerUserMenuNotDisplayed),c.appendChild(s),c.appendChild(o);const l=(0,Fr.nF)(e=>Wr(e,s,o),50);s.addEventListener("click",l);let p=setTimeout(()=>null,0);return c.addEventListener("mouseover",e=>{clearTimeout(p),l(e);const t=document.getElementById("loggedInNav");t?.setAttribute("style",tt.headerUserMenuNavigationMenu)}),c.addEventListener("mouseout",e=>{p=setTimeout(()=>l(e),200);const t=document.getElementById("loggedInNav");t?.setAttribute("style",tt.headerUserMenuNavigationMenuNotDisplayed)}),c}(e,n,i):function(){const e=document.createElement("div");return e.setAttribute("style",tt.headerBannerLogin),e.appendChild(Wi(document,null,{})),e}(),c=document.createElement("div");c.setAttribute("style",tt.headerBanner),c.appendChild(o);const l=document.createElement("div");if(l.setAttribute("style",tt.headerBannerRightMenu),l.appendChild(r),a&&a.helpMenuList){const e=function(e,t){if(!t)return;const n=document.createElement("ul");n.setAttribute("style",tt.headerUserMenuList),t.forEach(function(e){"url"===(e.url?"url":"onclick")?n.appendChild(Gr(Vr(e.label,e.url,e.target))):n.appendChild(Gr(Hr(e.label,e.onclick)))});const i=document.createElement("nav");i.setAttribute("style",tt.headerUserMenuNavigationMenuNotDisplayed),i.setAttribute("aria-hidden","true"),i.setAttribute("id","helperNav"),i.appendChild(n);const a=document.createElement("div");a.setAttribute("style",tt.headerBannerUserMenu),a.appendChild(i);const o=document.createElement("button");o.setAttribute("style",tt.headerUserMenuTrigger),o.type="button";const s=document.createElement("img");s.src=e&&e.helpIcon?e.helpIcon:st.Pt.iconBase+Pr,s.setAttribute("style",tt.headerUserMenuTriggerImg),a.appendChild(o),o.appendChild(s);const r=(0,Fr.nF)(e=>Wr(e,o,i),50);o.addEventListener("click",r);let c=setTimeout(()=>null,0);return a.addEventListener("mouseover",e=>{clearTimeout(c),r(e);const t=document.getElementById("helperNav");t?.setAttribute("style",tt.headerUserMenuNavigationMenu)}),a.addEventListener("mouseout",e=>{c=setTimeout(()=>r(e),200);const t=document.getElementById("helperNav");t?.setAttribute("style",tt.headerUserMenuNavigationMenuNotDisplayed)}),a}(a,a.helpMenuList);l.appendChild(e)}return c.appendChild(l),c}(t,n,o,i,a))}}function Hr(e,t){const n=document.createElement("button");return n.setAttribute("style",tt.headerUserMenuButton),n.onmouseover=function(){n.setAttribute("style",tt.headerUserMenuButtonHover)},n.onmouseout=function(){n.setAttribute("style",tt.headerUserMenuButton)},n.addEventListener("click",t),n.innerText=e,n}function Vr(e,t,n){const i=document.createElement("a");return i.setAttribute("style",tt.headerUserMenuLink),i.onmouseover=function(){i.setAttribute("style",tt.headerUserMenuLinkHover)},i.onmouseout=function(){i.setAttribute("style",tt.headerUserMenuLink)},i.href=t,i.innerText=e,n&&(i.target=n),i}function Gr(e){const t=document.createElement("li");return t.setAttribute("style",tt.headerUserMenuListItem),t.appendChild(e),t}function Wr(e,t,n){const i="true"===t.getAttribute("aria-expanded"),a="mouseover"===e.type,o="mouseout"===e.type;i&&a||!i&&o||(t.setAttribute("aria-expanded",(!i).toString()),n.setAttribute("aria-hidden",i.toString()))}const Jr="https://solidproject.org",Qr="solidproject.org";function Zr(e,t,n,i,a){return async()=>{const o=v.authn.currentUser();e.innerHTML="",e.appendChild(await function(e,t,n,i,a){const o=document.createElement("div");o.setAttribute("style",tt.footer);const s=document.createElement("a");if(s.href=a&&a.solidProjectUrl?a.solidProjectUrl:Jr,s.innerText=a&&a.solidProjectName?a.solidProjectName:Qr,!n||!i||t&&t.equals(i)){const e=document.createElement("span");return e.innerText="Powered by ",o.appendChild(e),o.appendChild(s),o}const r=document.createElement("span");r.innerText="You're visiting ";const c=document.createElement("a");c.href=n.uri,c.innerText="the Pod";const l=document.createElement("span");l.innerText=" controlled by ";const p=document.createElement("a");p.href=i.uri,p.innerText=(0,Fr.mG)(e,i);const u=document.createElement("span");u.innerText=". For more info, check out ";const d=document.createElement("span");return d.innerText=".",o.appendChild(r),o.appendChild(c),o.appendChild(l),o.appendChild(p),o.appendChild(u),o.appendChild(s),o.appendChild(d),o}(t,o,n,i,a))}}const Yr=window?window.document:null;"undefined"!=typeof window&&(window.UI={ns:b,acl:ua,aclControl:da,create:fa,createTypes:m,dom:Yr,icons:st.Pt,language:o,log:i,login:c,matrix:ga,media:ya,messageArea:function(e,t,n,i,a){t=t||v.solidLogicSingleton.store,i=i.doc();const o=wa.ns,s=g.Namespace("http://www.w3.org/2005/01/wf/flow#"),r=g.Namespace("http://purl.org/dc/terms/"),c=!!(a=a||{}).newestFirst,l="white-space: pre-wrap; width: 90%; font-size:100%; border: 0.07em solid #eee; padding: .2em 0.5em; margin: 0.1em 1em 0.1em 1em;",p=e.createElement("div");let u,d;const m=v.solidLogicSingleton.store.updater,f=function(t,n){const i=e.createElement("a");return n&&n.uri&&(i.setAttribute("href",n.uri),i.addEventListener("click",wa.widgets.openHrefInOutlineMode,!0),i.setAttribute("style","color: #3B5998; text-decoration: none; ")),i.textContent=t,i},h=function(t,n){const i=e.createElement("pre");return i.setAttribute("style",n||"color: grey"),p.appendChild(i),i.appendChild(e.createTextNode(t)),i},b=function(e){h(e,"color: #800;")};function x(e){const t=v.solidLogicSingleton.store.any(e,wa.ns.foaf("nick"));return t?""+t.value:""+F(e)}function y(t,n,i,a){const o=t.appendChild(f(x(n),n));n.uri&&v.solidLogicSingleton.store.fetcher.nowOrWhenFetched(n.doc(),void 0,function(e,t){o.textContent=x(n)}),t.appendChild(e.createElement("br")),t.appendChild(f(i,a))}function w(e,n){const i={};let a,s;for(a=n.firstChild;a;a=a.nextSibling)a.AJAR_subject&&(i[a.AJAR_subject.uri]=!0);const r=t.each(e,o.wf("message")),c={};for(r.forEach(function(e){c[e.uri]=!0,i[e.uri]||C(e)}),a=n.firstChild;a;)s=a.nextSibling,a.AJAR_subject&&!c[a.AJAR_subject.uri]&&n.removeChild(a),a=s}const C=function(e){const n={"?msg":e,"?creator":t.any(e,o.foaf("maker")),"?date":t.any(e,r("created")),"?content":t.any(e,o.sioc("content"))};E(n,!0)},E=function(i,a){const o=i["?creator"],s=i["?msg"],r=i["?date"],p=i["?content"],d=r.value,f=e.createElement("tr");f.AJAR_date=d,f.AJAR_subject=s;let h=!1;for(let e=u.firstChild;e;e=e.nextSibling)if(d>e.AJAR_date&&c||d<e.AJAR_date&&!c){u.insertBefore(f,e),h=!0;break}h||u.appendChild(f);const g=e.createElement("td");f.appendChild(g),y(g,o,wa.widgets.shortDate(d),s);const v=e.createElement("td");f.appendChild(v);const x=e.createElement("p");x.setAttribute("style",l+(a?"background-color: #e8ffe8;":"background-color: #white;")),v.appendChild(x),x.textContent=p.value;const C=e.createElement("td");f.appendChild(C);const E=e.createElement("button");C.appendChild(E),E.textContent="-",f.setAttribute("class","hoverControl"),E.setAttribute("class","hoverControlHide"),E.setAttribute("style","color: red;"),E.addEventListener("click",function(i){C.removeChild(E);const a=e.createElement("button");a.textContent="cancel",C.appendChild(a).addEventListener("click",function(e){C.removeChild(o),C.removeChild(a),C.appendChild(E)},!1);const o=e.createElement("button");o.textContent="Delete message",C.appendChild(o).addEventListener("click",function(e){C.removeChild(o),C.removeChild(a),function(e){const i=t.statementsMatching(e).concat(t.statementsMatching(void 0,void 0,e));m.update(i,[],function(e,t,i){t?w(n,u):b("Cant delete messages:"+i)})}(s)},!1)},!1)};u=e.createElement("table"),u.fresh=!1,p.appendChild(u),u.setAttribute("style","width: 100%;");const k=function(){const a=e.createElement("tr"),s=e.createElement("td"),c=e.createElement("td"),p=e.createElement("td");a.appendChild(s),a.appendChild(c),a.appendChild(p),a.AJAR_date="9999-01-01T00:00:00Z";const u=function(){f.setAttribute("class","pendingedit"),f.disabled=!0;const s=[],c=new Date,l=""+c.getTime(),p=g.term(c),u=t.sym(i.uri+"#Msg"+l);s.push(new g.Statement(n,o.wf("message"),u,i)),s.push(new g.Statement(u,o.sioc("content"),t.literal(f.value),i)),s.push(new g.Statement(u,r("created"),p,i)),d&&s.push(new g.Statement(u,o.foaf("maker"),d,i)),m.update([],s,function(n,i,o){if(i){const e={"?msg":u,"?content":t.literal(f.value),"?date":p,"?creator":d};E(e,!1),f.value="",f.setAttribute("class",""),f.disabled=!1}else a.appendChild(wa.widgets.errorMessageBlock(e,"Error writing message: "+o))})};let f,h;return a.appendChild(e.createElement("br")),Mi({div:c,dom:e}).then(t=>{d=t.me,y(s,d,"",null),f=e.createElement("textarea"),c.innerHTML="",c.appendChild(f),f.rows=3,f.setAttribute("style",l+"background-color: #eef;"),f.addEventListener("keyup",function(e){13===e.keyCode&&(e.altKey||u())},!1),p.innerHTML="",h=wa.widgets.button(e,wa.icons.iconBase+"noun_383448.svg","Send"),h.setAttribute("style",wa.style.buttonStyle+"float: right;"),h.addEventListener("click",u,!1),p.appendChild(h)}),a}();let A;if(c?u.insertBefore(k,u.firstChild):u.appendChild(k),a.query)A=a.query;else{A=new g.Query("Messages");const e={};["msg","date","creator","content"].forEach(function(t){A.vars.push(e[t]=g.variable(t))}),A.pat.add(n,s("message"),e.msg),A.pat.add(e.msg,o.dct("created"),e.date),A.pat.add(e.msg,o.foaf("maker"),e.creator),A.pat.add(e.msg,o.sioc("content"),e.content)}return t.query(A,E,void 0,function(){u.fresh=!0}),p.refresh=function(){w(n,u)},p},infiniteMessageArea:async function(e,t,n,i){async function a(e,t){if(Qs(e)&&!i.showDeletedMessages)return;let n=v.store.any(null,b.sioc("has_member"),e,e.doc());const a=v.store.any(e,b.sioc("id"),null,e.doc());if(a&&!n&&(n=v.store.any(null,b.sioc("has_member"),a,e.doc())),i.thread){if(v.store.holds(e,b.sioc("has_reply"),i.thread));else if(!n||!n.sameTerm(i.thread))return}else if(n)return;t.fresh||await Ar(u,t,e,t.fresh,i,h)}async function o(e){const t=e?w:C;let n=t.messageTable.date;if(e&&w.limit&&n<=w.limit)return x||await c(),!0;if(n=await d.loadPrevious(n,e),n||e||x||await c(),!n)return!0;let i=!1;if(!e){const e=d.leafDocumentFromDate(new Date);i=d.leafDocumentFromDate(n).sameTerm(e)}const a=await s(n,i);return t.messageTable=a,(e?p:!p)?m.appendChild(a):m.insertBefore(a,m.firstChild),i}async function s(t,n){const i=d.leafDocumentFromDate(t);try{await v.store.fetcher.createIfNotExists(i)}catch(a){const o=e.createElement("table").appendChild(e.createElement("tr"));return a.response&&a.response.status&&404===a.response.status?await r(t,n):(xe.Rm("*** Error NON 404 for chat file "+i),o.appendChild(ot(e,a,"pink")),o)}return await r(t,n)}async function r(t,n){async function s(){return await o(!1)}const r=e.createElement("table");r.style.width="100%",r.extendBackwards=async function(){const e=await o(!0);return e?r.initial=!0:r.extendedBack=!0,e},r.extendForwards=s,r.date=t;const c=d.leafDocumentFromDate(t);if(r.chatDocument=c,r.fresh=!1,r.setAttribute("style","width: 100%;"),n){r.final=!0,x=r,C.messageTable=r;const e=kr(u,r,h,i);p?r.insertBefore(e,r.firstChild):r.appendChild(e),r.inputRow=e}{const n=e.createElement("tr"),a=n.appendChild(e.createElement("td"));a.style="text-align: center; vertical-align: middle; color: #888; font-style: italic;",a.textContent=At(t.toISOString(),!0);const o=n.appendChild(e.createElement("td"));i.includeRemoveButton&&o.appendChild(Ft(e,e=>{m.parentNode.removeChild(m)})),r.extendedForwards=!1,p?r.appendChild(n):r.insertBefore(n,r.firstChild)}const l=v.store.statementsMatching(null,b.wf("message"),null,c);!n&&l.length;for(const e of l)await a(e.object,r);return r.fresh=!0,r}async function c(){const e=new Date,t=d.leafDocumentFromDate(e),i=await s(e,!0);return m.appendChild(i),m.refresh=async function(){var e;await async function(){const e=d.leafDocumentFromDate(new Date);if(!e.sameTerm(C.messageTable.chatDocument)){x.inputRow&&(x.removeChild(x.inputRow),delete x.inputRow);const t=C.messageTable.chatDocument;if(await c(),!v.store.holds(t,b.rdfs("seeAlso"),e,t)){const n=[g.st(t,b.rdfs("seeAlso"),e,t)];try{v.store.updater.update([],n)}catch(e){alert("Unable to link old chat file to new one:"+e)}}}}(new Date),await async function(e,t){const n={};let i,o;for(i=t.firstChild;i;i=i.nextSibling)i.AJAR_subject&&(n[i.AJAR_subject.uri]=!0);const s=v.store.each(e,b.wf("message"),null,t.chatDocument),r={};for(const e of s)r[e.uri]=!0,n[e.uri]||await a(e,t);for(i=t.firstChild;i;)o=i.nextSibling,i.AJAR_subject&&!r[i.AJAR_subject.uri]&&t.removeChild(i),i=o;for(i=t.firstChild;i;i=i.nextSibling)i.AJAR_subject&&Jt(i)}(n,i),e=n,"Notification"in window?"granted"===Notification.permission?new Notification(e):"denied"!==Notification.permission&&Notification.requestPermission().then(function(t){"granted"===t&&new Notification(e)}):xe.R8("This browser does no t support desktop notification")},v.store.updater.addDownstreamChangeListener(t,m.refresh),x=i,C.messageTable=x,i}async function l(e,t){if(E)return;E=!0;const n=!t;let a;for(;m.scrollTop<150&&w.messageTable&&!w.messageTable.initial&&w.messageTable.extendBackwards;){if(0===m.scrollHeight)return setTimeout(l,2e3),void(E=!1);const e=m.scrollHeight-m.scrollTop;if(a=await w.messageTable.extendBackwards(),n&&(m.scrollTop=m.scrollHeight-e),t&&t(),a)break}for(;i.selectedMessage&&m.scrollHeight-m.scrollTop-m.clientHeight<150&&C.messageTable&&!C.messageTable.final&&C.messageTable.extendForwards;){const e=m.scrollTop;if(a=await C.messageTable.extendForwards(),n&&(m.scrollTop=e),t&&t(),a)break}E=!1}(i=i||{}).authorDateOnLeft=!1;const p="1"===i.newestFirst||!0===i.newestFirst,u=new Gs(n,i),d=u.dateFolder,m=e.createElement("div");u.div=m;const f=m.appendChild(e.createElement("div")),h={dom:e,statusArea:f,div:f};let x,y;const w={messageTable:null},C={messageTable:null};if(i.thread){const e=i.thread;if(y=v.store.any(null,b.sioc("has_reply"),e,e.doc()),y){const e=v.store.any(y,b.dct("created"),null,y.doc());e&&(w.limit=new Date(e.value))}}let E=!1;return await async function(){function e(){r&&r.selectedElement&&r.selectedElement.scrollIntoView({block:"center"})}let t,n,a;i.selectedMessage&&(n=i.selectedMessage.doc()),y&&(a=y.doc());const o=n||a;if(o){const e=new Date;t=d.leafDocumentFromDate(e).sameTerm(o)}let r;if(o&&!t){const n=d.dateFromLeafDocument(o);r=await s(n,t),m.appendChild(r),w.messageTable=r,C.messageTable=r,e(),setTimeout(e,1e3)}else await c(),w.messageTable=x,C.messageTable=x;await l(0,function(){i.selectedElement?i.selectedElement.scrollIntoView({block:"center"}):x.inputRow.scrollIntoView&&x.inputRow.scrollIntoView(p)}),m.addEventListener("scroll",l),i.solo&&document.body.addEventListener("scroll",l)}(),m},pad:p,participation:l,preferences:u,style:tt,table:function(e,t){const n=t.sourceDocument,i=t.tableClass,a=t.query,o=Br.ns,s=v.store,r={},c={"http://www.w3.org/2002/07/owl#sameAs":!0,"http://www.w3.org/1999/02/22-rdf-syntax-ns#type":!0},l={"http://www.w3.org/2001/XMLSchema#decimal":!0,"http://www.w3.org/2001/XMLSchema#float":!0,"http://www.w3.org/2001/XMLSchema#double":!0,"http://www.w3.org/2001/XMLSchema#integer":!0,"http://www.w3.org/2001/XMLSchema#nonNegativeInteger":!0,"http://www.w3.org/2001/XMLSchema#positiveInteger":!0,"http://www.w3.org/2001/XMLSchema#nonPositiveInteger":!0,"http://www.w3.org/2001/XMLSchema#negativeInteger":!0,"http://www.w3.org/2001/XMLSchema#long":!0,"http://www.w3.org/2001/XMLSchema#int":!0,"http://www.w3.org/2001/XMLSchema#short":!0,"http://www.w3.org/2001/XMLSchema#byte":!0,"http://www.w3.org/2001/XMLSchema#unsignedLong":!0,"http://www.w3.org/2001/XMLSchema#unsignedInt":!0,"http://www.w3.org/2001/XMLSchema#unsignedShort":!0,"http://www.w3.org/2001/XMLSchema#unsignedByte":!0},p={"http://www.w3.org/2001/XMLSchema#dateTime":!0,"http://www.w3.org/2001/XMLSchema#date":!0},u={"http://xmlns.com/foaf/0.1/Image":!0,"http://purl.org/dc/terms/Image":!0},d=t.keyVariable||"?_row";let m,f,h,b,x=0,y=null,w=null;const C=e.createElement("div");C.className="tableViewPane",C.appendChild(function(){const t=e.createElement("table");t.setAttribute("class","toolbar");const n=e.createElement("tr");return h=e.createElement("td"),n.appendChild(h),b=e.createElement("td"),n.appendChild(b),t.appendChild(n),t}());const E=e.createElement("div");let k;if(C.appendChild(E),C.refresh=function(){Y(k.query,k.logicalRows,k.columns,k)},a)k=te(a),E.appendChild(k);else{const t=function(){let e,t;const a=function(){const e={},t=s.statementsMatching(void 0,Br.ns.rdf("type"),i,n),a={};for(let n=0;n<t.length;++n){const i=t[n].object;if("NamedNode"!==i.termType)continue;const o=I(e,i);i.uri in a||(a[i.uri]=[]),a[i.uri].push(t[n].subject),o.addUse()}return[a,e]}();e=a[0],t=a[1];for(const n in e){const i=e[n];B(t[n],i)}return[new S(null),L(t)]}();m=t[0],f=t[1],i||h.appendChild(function(t,n){const i=e.createElement("div");i.appendChild(e.createTextNode("Select type: "));const a=e.createElement("select");a.appendChild(R("All types","null"));for(const e in n)a.appendChild(R(n[e].getLabel(),e));return a.addEventListener("click",function(){let e;e="null"===a.value?t:n[a.value],_(e)},!1),i.appendChild(a),i}(m,f)),w=function(e){let t,n=-1,i=null;for(t in e){const a=e[t];a.useCount>n&&(i=a,n=a.useCount)}return i}(f),_(w||m)}return C;function A(e){const t=new g.Query,n=s.variable(d.slice(1));return function(e,t){const n=t.getColumns();for(let t=0;t<n.length;++t){const i=s.variable("_col"+t);e.vars.push(i),n[t].setVariable(i)}}(t,e),function(e,t,n){let i=n.type;i||(i=s.variable("_any")),e.pat.add(t,Br.ns.rdf("type"),i)}(t,n,e),function(e,t,n){const i=n.getColumns();for(let n=0;n<i.length;++n){const a=i[n],o=s.formula();o.add(t,a.predicate,a.getVariable()),e.pat.optional.push(o)}}(t,n,e),t}function _(t){T(b),b.appendChild(function(t){const n=e.createElement("div"),i=t.getUnusedColumns();if(i.sort(function(e,t){const n=e.sortKey(),i=t.sortKey();return(n>i)-(n<i)}),i.length>0){n.appendChild(e.createTextNode("Add column: "));const a=e.createElement("select");a.appendChild(R("","-1"));for(let e=0;e<i.length;++e){const t=i[e];a.appendChild(R(t.getLabel(),""+e))}n.appendChild(a),a.addEventListener("click",function(){const e=Number(a.value);e>=0&&(t.addColumn(i[e]),_(t))},!1)}return n}(t)),function(e,t){y&&(y.running=!1);const n=te(e,t);T(E),E.appendChild(n),y=e}(A(t),t)}function T(e){for(;e.childNodes.length>0;)e.removeChild(e.childNodes[0])}function S(e){this.type=e,this.columns=null,this.allColumns=[],this.useCount=0,this.getAllColumns=function(){return this.allColumns},this.getColumns=function(){if(!this.columns){const e=this.getAllColumns();this.columns=e.slice(0,7)}return this.columns},this.getUnusedColumns=function(){const e=this.getAllColumns(),t=this.getColumns(),n=[];for(let i=0;i<e.length;++i)-1===t.indexOf(e[i])&&n.push(e[i]);return n},this.addColumn=function(e){this.columns.push(e)},this.removeColumn=function(e){this.columns=this.columns.filter(function(t){return t!==e})},this.getLabel=function(){return F(this.type)},this.addUse=function(){this.useCount+=1}}function j(){this.useCount=0,this.checkedAnyValues=!1,this.possiblyLiteral=!0,this.possiblyNumber=!0,this.constraints=[],this.checkValue=function(e){const t=e.termType;this.possiblyLiteral&&"Literal"!==t&&"NamedNode"!==t?(this.possiblyNumber=!1,this.possiblyLiteral=!1):this.possiblyNumber&&("Literal"!==t?this.possiblyNumber=!1:e.value.match(/^-?\d+(\.\d*)?$/)||(this.possiblyNumber=!1)),this.checkedAnyValues=!0},this.getVariable=function(){return this.variable},this.setVariable=function(e){this.variable=e},this.getKey=function(){return this.variable.toString()},this.addUse=function(){this.useCount+=1},this.getHints=function(){return t&&t.hints&&this.variable&&t.hints[this.variable.toNT()]?t.hints[this.variable.toNT()]:{}},this.getLabel=function(){return this.getHints().label?this.getHints().label:this.predicate?this.predicate.sameTerm(o.rdf("type"))&&this.superClass?F(this.superClass,!0):F(this.predicate):this.variable?this.variable.toString():"unlabeled column?"},this.setPredicate=function(e,t,n){t?(this.inverse=e,this.constraints=this.constraints.concat(s.each(e,Br.ns.rdfs("domain"))),e.sameTerm(o.rdfs("subClassOf"))&&"NamedNode"===n.termType&&(this.superClass=n,this.alternatives=s.each(void 0,o.rdfs("subClassOf"),n))):(this.predicate=e,this.constraints=this.constraints.concat(s.each(e,Br.ns.rdfs("range"))))},this.getConstraints=function(){return this.constraints},this.filterFunction=function(){return!0},this.sortKey=function(){return this.getLabel().toLowerCase()},this.isImageColumn=function(){for(let e=0;e<this.constraints.length;e++)if(this.constraints[e].uri in u)return!0;return!1}}function L(e,t){const n=[];for(const i in e){const a=e[i];t&&!t(i,a)||n.push(a)}return n}function R(t,n){const i=e.createElement("option");return i.setAttribute("value",n),i.appendChild(e.createTextNode(t)),i}function N(e,t){let n;return t.uri in e?n=e[t.uri]:(n=new j,n.setPredicate(t),e[t.uri]=n),n}function I(e,t){let n;return t.uri in e?n=e[t.uri]:(n=new S(t),e[t.uri]=n),n}function $(e,t){const i=s.statementsMatching(e,void 0,void 0,n),a={};for(let e=0;e<i.length;++e){const n=i[e].predicate;if(n.uri in c)continue;const o=N(t,n);o.checkValue(i[e].object),a[n.uri]=o}return a}function B(e,t){const n={};for(let e=0;e<t.length;++e){const i=$(t[e],n);for(const e in i)i[e].addUse()}const i=L(n);!function(e){function t(e,t){return(e.useCount<t.useCount)-(e.useCount>t.useCount)}e.sort(t)}(i),e.allColumns=i}function D(t,n){const i=e.createElement("a");return i.appendChild(e.createTextNode("[x]")),i.addEventListener("click",function(){t.removeColumn(n),_(t)},!1),i}function O(e,t){let n=!0;for(let i=0;i<t.length;++i){const a=t[i],o=a.getKey();let s=null;if(o in e.values&&(s=e.values[o][0]),!a.filterFunction(s)){n=!1;break}}e._htmlRow.style.display=n?"":"none"}function M(e,t){for(let n=0;n<e.length;++n)O(e[n],t)}function U(e,t,n){function i(e){return e?"Literal"===e.termType?e.value.toLowerCase():"NamedNode"===e.termType?F(e).toLowerCase():e.value.toLowerCase():""}!function(e,t,n,i){const a=t.getKey();if(e.sort(function(e,t){let o=null,s=null;a in e.values&&(o=e.values[a][0]),a in t.values&&(s=t.values[a][0]);const r=n(o,s);return i?-r:r}),e.length){const t=e[0]._htmlRow.parentNode;for(let n=0;n<e.length;++n)t.removeChild(e[n]._htmlRow);for(let n=0;n<e.length;++n)t.appendChild(e[n]._htmlRow)}}(e,t,function(e,t){const n=i(e),a=i(t);return n<a?-1:n>a?1:0},n)}function P(t,n,i){const a=e.createElement("div"),o=e.createElement("input");o.setAttribute("type","text"),o.style.width="70%",a.appendChild(o);const s=e.createElement("span");s.appendChild(e.createTextNode("▼")),s.addEventListener("click",function(){U(t,i,!1)},!1),a.appendChild(s);const r=e.createElement("span");r.appendChild(e.createTextNode("▲")),r.addEventListener("click",function(){U(t,i,!0)},!1),a.appendChild(r);let c=null;return i.filterFunction=function(e){if(c){if(e){let t;return t="Literal"===e.termType?e.value:"NamedNode"===e.termType?F(e):"",t.toLowerCase().indexOf(c)>=0}return!1}return!0},o.addEventListener("keyup",function(){c=""!==o.value?o.value.toLowerCase():null,M(t,n)},!1),a}function z(t,n,i,a){const o=e.createElement("div"),s=e.createElement("select");let r={};for(let e=0;e<a.length;++e){const t=a[e];r[t.uri]=!0}const c=G(i).initialSelection;c&&(r=c),s.setAttribute("multiple","true");for(let e=0;e<a.length;++e){const t=a[e],n=R(F(t),e);r[t.uri]&&(n.selected=!0),s.appendChild(n)}return o.appendChild(s),i.filterFunction=function(e){return!r||e&&r[e.uri]},s.addEventListener("click",function(){{r={};const e=s.options;for(let t=0;t<e.length;t++){const n=e[t],i=Number(n.value);e[t].selected&&(r[a[i].uri]=!0)}}M(t,n)},!0),o}function q(t,n,i){const a=e.createElement("div"),o=e.createElement("input");o.setAttribute("type","text"),o.style.width="40px",a.appendChild(o);const s=e.createElement("input");s.setAttribute("type","text"),s.style.width="40px",a.appendChild(s);let r=null,c=null;function l(){r=""===o.value?null:Number(o.value),c=""===s.value?null:Number(s.value),M(t,n)}return i.filterFunction=function(e){return e&&(e=Number(e)),!(r&&(!e||e<r)||c&&(!e||e>c))},o.addEventListener("keyup",l,!1),s.addEventListener("keyup",l,!1),a}function H(e,t,n){if(n.superClass&&n.alternatives.length>0)return z(e,t,n,n.alternatives);const i=n.getConstraints();let a;for(let o=0;o<i.length;o++){if(a=i[o],n.checkedAnyValues&&n.possiblyNumber||a.uri in l)return q(e,t,n);if("http://www.w3.org/2000/01/rdf-schema#Literal"===a.uri)return P(e,t,n);const r=s.each(a,Br.ns.owl("oneOf"));if(r.length>0)return z(e,t,n,r.elements)}return function(e,t,n){return n.checkedAnyValues&&n.possiblyNumber?q(e,t,n):n.possiblyLiteral?P(e,t,n):null}(e,t,n)}function V(t,n,i){i=i||{};const a=e.createElement("a"),o=i.linkFunction;return a.setAttribute("href",t),a.appendChild(e.createTextNode(n)),o?a.addEventListener("click",function(e){e.preventDefault(),e.stopPropagation();const t=ee(e).getAttribute("href");t||xe.Rm("No href found \n"),o(t)},!0):a.addEventListener("click",Br.widgets.openHrefInOutlineMode,!0),a}function G(e){return t&&t.hints&&e.variable&&t.hints[e.variable.toNT()]?t.hints[e.variable.toNT()]:{}}function W(t,n){const i=G(n),a=i.cellFormat;if(!a){if("Literal"===t.termType){if(t.datatype){if(p[t.datatype.uri])return e.createTextNode(Br.widgets.shortDate(t.value));if(l[t.datatype.uri]){const n=e.createElement("span");return n.textContent=t.value,n.setAttribute("style","text-align: right"),n}}return e.createTextNode(t.value)}if("NamedNode"===t.termType&&n.isImageColumn())return function(t){const n=e.createElement("img");return n.setAttribute("src",t.uri),n.style.height="40px",n}(t);if("NamedNode"===t.termType||"BlankNode"===t.termType)return function(e,t){let n=!1;return e.uri&&(n=e.uri.match(/^mailto:(.*)/)),V(e.uri,n?n[1]:F(e),t)}(t,i);if("Collection"===t.termType){const i=e.createElement("span");return i.appendChild(e.createTextNode("[")),t.elements.forEach(function(t){i.appendChild(W(t,n)),i.appendChild(e.createTextNode(", "))}),i.removeChild(i.lastChild),i.appendChild(e.createTextNode("]")),i}return e.createTextNode("unknown termtype '"+t.termType+"'!")}if("shortDate"===a)return e.createTextNode(Br.widgets.shortDate(t.value))}function J(e,t){let n,i=null;if("Literal"===e.termType)i="value";else{if("NamedNode"!==e.termType)return t.indexOf(e)>=0;i="uri"}for(n=0;n<t.length;++n)if(t[n].termType===e.termType&&t[n][i]===e[i])return!0;return!1}function Q(t,n,i){let a,o=!1;for(a in i){const e=i[a];a in t.values||(t.values[a]=[]),J(e,t.values[a])||(t.values[a].push(e),o=!0)}o&&(T(t._htmlRow),function(t,n,i){const a=e.createElement("td");n._subject&&"uri"in n._subject&&a.appendChild(V(n._subject.uri,"→")),t.appendChild(a);for(let a=0;a<i.length;++a){const o=i[a],s=e.createElement("td");let r;const c=o.getKey();if(c in n.values){const t=n.values[c];let i=!1;n.originalValues&&n.originalValues[c]&&t.length!==n.originalValues[c].length&&(i=!0);for(let a=0;a<t.length;++a){const l=t[a];n.originalValues&&n.originalValues[c]&&n.originalValues[c].length>a&&(r=n.originalValues[c][a],l.toString()!==r.toString()&&(i=!0)),s.appendChild(W(l,o)),a!==t.length-1&&s.appendChild(e.createTextNode(",\n")),i&&(s.style.background="#efe")}}t.appendChild(s)}n._htmlRow=t}(t._htmlRow,t,n)),O(t,n)}function Z(e){if("uri"in e)return e.uri;if("_subject_id"in e)return e._subject_id;{const t=""+x;return e._subject_id=t,++x,t}}function Y(n,i,a,o){n.running=!0;const c=Date.now();let l=e.createElement("tr");o.appendChild(l),l.textContent="Loading ...";for(let e=0;e<i.length;e++)i[e].original=!0,i[e].originalValues||(i[e].originalValues=i[e].values),i[e].values={};s.query(n,function(t){if(!n.running)return;l.textContent+=".";let s,c=null,p=null;if(d in t&&(p=t[d],s=Z(p),s in r&&(c=r[s])),!c){const t=e.createElement("tr");o.appendChild(t),c={_htmlRow:t,_subject:p,values:{}},i.push(c),p&&(r[s]=c)}delete c.original,Q(c,a,t)},void 0,function(){l&&l.parentNode&&l.parentNode.removeChild&&(l.parentNode.removeChild(l),l=null);const e=Date.now()-c;xe.Rm("Query done: "+i.length+" rows, "+e+"ms");for(let e=i.length-1;e>=0;e--)if(i[e].original){xe.Rm(" deleting row "+i[e]._subject);const t=i[e]._htmlRow;t.parentNode.removeChild(t),delete r[Z(i[e]._subject)],i.splice(e,1)}if(t.sortBy){const e=function(e,t){for(const n in e){const i=e[n];if(i.variable.toNT()===t)return i}throw new Error(`getColumnForVariable: no column for variable ${t}`)}(a,t.sortBy);U(i,e,t.sortReverse)}t.onDone&&t.onDone(C)})}function K(e,t){Br.log.debug(">> processing formula");for(let n=0;n<t.statements.length;++n){const i=t.statements[n];if("NamedNode"===i.predicate.termType&&"Variable"===i.object.termType){const t=i.object.toString();t in e&&e[t].setPredicate(i.predicate,!1,i.subject)}if("NamedNode"===i.predicate.termType&&"Variable"===i.subject.termType){const t=i.subject.toString();t in e&&e[t].setPredicate(i.predicate,!0,i.object)}}for(let n=0;n<t.optional.length;++n)Br.log.debug("recurse to optional subformula "+n),K(e,t.optional[n]);Br.log.debug("<< finished processing formula")}function X(e){const t=[],n={};for(let i=0;i<e.vars.length;++i){const a=new j,o=e.vars[i];Br.log.debug("column "+i+" : "+o),a.setVariable(o),n[o]=a,t.push(a)}return K(n,e.pat),t}function te(t,n){let i;i=a?X(t):n.getColumns();const o=[],s=e.createElement("table");return s.appendChild(function(t,n){const i=e.createElement("tr"),a=e.createElement("th");i.appendChild(a);for(let a=0;a<t.length;++a){const o=e.createElement("th"),s=t[a];o.appendChild(e.createTextNode(s.getLabel())),n&&o.appendChild(D(n,s)),i.appendChild(o)}return i}(i,n)),s.appendChild(function(t,n){const i=e.createElement("tr");i.className="selectors",i.appendChild(e.createElement("td"));for(let a=0;a<n.length;++a){const o=e.createElement("td"),s=H(t,n,n[a]);s&&o.appendChild(s),i.appendChild(o)}return i}(o,i)),s.logicalRows=o,s.columns=i,s.query=t,Y(t,o,i,s),s}},tabs:d,utils:a,widgets:r,initHeader:async function(e,t,n){const i=document.getElementById("PageHeader");if(!i)return;const a=(0,Fr.E6)();qr(i,e,a,t,n)(),v.authSession.events.on("logout",qr(i,e,a,t,n)),v.authSession.events.on("login",qr(i,e,a,t,n))},initFooter:async function(e,t){const n=document.getElementById("PageFooter");if(!n)return;const i=(0,Fr.E6)(),a=await(0,Fr.bB)(i,e);Zr(n,e,i,a,t)(),v.authSession.events.on("login",Zr(n,e,i,a,t)),v.authSession.events.on("logout",Zr(n,e,i,a,t))}})},565(e,t,n){"use strict";n.d(t,{E6:()=>o,bB:()=>s,mG:()=>r,nF:()=>c});var i=n(511),a=n(325);function o(){const{origin:e,pathname:t}=document.location,n="databrowser"===document.body?.dataset?.appShell,a=t.split("/").filter(Boolean),o=a[a.length-1]||"",s=/\.[^/]+$/.test(o);return n&&a.length>0&&!s?(0,i.sym)(`${e}/${a[0]}/`):(0,i.sym)(e).site()}async function s(e,t){try{if(!t.any(e,null,a.ns.ldp("Container"),e)){const n=(await t.fetcher.webOperation("GET",e.uri,t.fetcher.initFetchOptions(e.uri,{headers:{accept:"text/turtle"}}))).responseText;(0,i.parse)(n,t,e.uri,"text/turtle")}}catch(t){return console.error("Error loading pod "+e+": "+t),null}if(!t.holds(e,a.ns.rdf("type"),a.ns.space("Storage"),e))return console.warn("Pod "+e+" does not declare itself as a space:Storage"),null;const n=t.any(e,a.ns.solid("owner"),null,e)||t.any(null,a.ns.space("storage"),e,e);if(n){try{await t.fetcher.load(n.doc())}catch(e){return console.warn("Unable to load profile of pod owner "+n),null}return t.holds(n,a.ns.space("storage"),e,n.doc())||console.warn(`Pod owner ${n} does NOT list pod ${e} as their storage`),n}{const n=(0,i.sym)(`${e.uri}profile/card#me`);try{await t.fetcher.load(n)}catch(e){return console.error("Ooops. Guessed wrong pod owner webid {$guess} : can't load it."),null}return t.holds(n,a.ns.space("storage"),e,n.doc())?(console.warn("Using guessed pod owner webid but it links back."),n):null}}function r(e,t){return e.anyValue(t,a.ns.vcard("fn"),null,t.doc())||e.anyValue(t,a.ns.foaf("name"),null,t.doc())||t.uri}function c(e,t,n={}){let i,a,o,s=null,r=0;const c=function(){r=n.leading?Date.now():0,s=null,o=e.apply(i,a),s||(i=a=null)};return function(){const l=Date.now();r||n.leading||(r=l);const p=t-(l-r);return i=this,a=arguments,p<=0||p>t?(s&&(clearTimeout(s),s=null),r=l,o=e.apply(i,a),s||(i=a=null)):s||!1===n.trailing||(s=setTimeout(c,p)),o}}},580(e){"use strict";
21
+ const hs={p:BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f"),n:BigInt("0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141"),h:BigInt(1),a:BigInt(0),b:BigInt(7),Gx:BigInt("0x79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798"),Gy:BigInt("0x483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8")},gs={beta:BigInt("0x7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee"),basises:[[BigInt("0x3086d221a7d46bcde86c90e49284eb15"),-BigInt("0xe4437ed6010e88286f547fa90abfe4c3")],[BigInt("0x114ca50f7a8e2f3f657c1108d9d44cfd8"),BigInt("0x3086d221a7d46bcde86c90e49284eb15")]]},bs=BigInt(0),vs=BigInt(2);const xs=Po(hs.p,{sqrt:function(e){const t=hs.p,n=BigInt(3),i=BigInt(6),a=BigInt(11),o=BigInt(22),s=BigInt(23),r=BigInt(44),c=BigInt(88),l=e*e*e%t,p=l*l*e%t,u=So(p,n,t)*p%t,d=So(u,n,t)*p%t,m=So(d,vs,t)*l%t,f=So(m,a,t)*m%t,h=So(f,o,t)*f%t,g=So(h,r,t)*h%t,b=So(g,c,t)*g%t,v=So(b,r,t)*h%t,x=So(v,n,t)*p%t,y=So(x,s,t)*f%t,w=So(y,i,t)*l%t,C=So(w,vs,t);if(!xs.eql(xs.sqr(C),e))throw new Error("Cannot find square root");return C}}),ys=ds(hs,{Fp:xs,endo:gs}),ws={};function Cs(e,...t){let n=ws[e];if(void 0===n){const t=Qa(function(e){if("string"!=typeof e)throw new TypeError("ascii string expected, got "+typeof e);return Uint8Array.from(e,(t,n)=>{const i=t.charCodeAt(0);if(1!==t.length||i>127)throw new RangeError(`string contains non-ASCII character "${e[n]}" with code ${i} at position ${n}`);return i})}(e));n=Xa(t,t),ws[e]=n}return Qa(Xa(n,...t))}const Es=e=>e.toBytes(!0).slice(1),ks=e=>e%vs===bs;function As(e){const{Fn:t,BASE:n}=ys,i=t.fromBytes(e),a=n.multiply(i);return{scalar:ks(a.y)?i:t.neg(i),bytes:Es(a)}}function _s(e){const t=xs;if(!t.isValidNot0(e))throw new Error("invalid x: Fail if x ≥ p");const n=t.create(e*e),i=t.create(n*e+BigInt(7));let a=t.sqrt(i);ks(a)||(a=t.neg(a));const o=ys.fromAffine({x:e,y:a});return o.assertValidity(),o}const Ts=ro;function Ss(...e){return ys.Fn.create(Ts(Cs("BIP0340/challenge",...e)))}function js(e){return As(e).bytes}function Ls(e,t,n=Ua(32)){const{Fn:i,BASE:a}=ys,o=Za(e,void 0,"message"),{bytes:s,scalar:r}=As(t),c=Za(n,32,"auxRand"),l=i.toBytes(r^Ts(Cs("BIP0340/aux",c))),p=Cs("BIP0340/nonce",l,s,o),u=i.create(Ts(p));if(0n===u)throw new Error("sign failed: k is zero");const d=a.multiply(u),m=ks(d.y)?u:i.neg(u),f=Es(d),h=Ss(f,s,o),g=new Uint8Array(64);if(g.set(f,0),g.set(i.toBytes(i.create(m+h*r)),32),!Rs(g,o,s))throw new Error("sign: Invalid signature produced");return g}function Rs(e,t,n){const{Fp:i,Fn:a,BASE:o}=ys,s=Za(e,64,"signature"),r=Za(t,void 0,"message"),c=Za(n,32,"publicKey");try{const e=_s(Ts(c)),t=Ts(s.subarray(0,32));if(!i.isValidNot0(t))return!1;const n=Ts(s.subarray(32,64));if(!a.isValidNot0(n))return!1;const l=Ss(a.toBytes(t),Es(e),r),p=o.multiplyUnsafe(n).add(e.multiplyUnsafe(a.neg(l))),{x:u,y:d}=p.toAffine();return!(p.is0()||!ks(d)||u!==t)}catch(e){return!1}}const Ns=(()=>{const e=e=>qo(e=void 0===e?Ua(48):e,hs.n);return Object.freeze({keygen:is(e,js),getPublicKey:js,sign:Ls,verify:Rs,Point:ys,utils:Object.freeze({randomSecretKey:e,taggedHash:Cs,lift_x:_s,pointToBytes:Es}),lengths:Object.freeze({secretKey:32,publicKey:32,publicKeyHasPrefix:!1,signature:64,seed:48})})})();new TextDecoder("utf-8");const Is=new TextEncoder,$s="https://w3id.org/security#";function Bs(e){const t=Qa(Is.encode(function(e){return JSON.stringify(e)}(e)));return ja(t)}const Ds=e=>{let t=v.store.any(e,b.space("preferencesFile"),null,e.doc())?.value;if(t=t?.split("/").slice(0,-2).join("/"),!t)throw new Error(`prefererencesFile is expected to exist in ${e}`);return t},Os=e=>{let t;try{t=`${Ds(e)}/profile/keys/publicKey.ttl`}catch(e){xe.z3(e)}return t};async function Ms(e,t,n){try{await v.store.fetcher.load(t);const i=v.store.any(e,b.solid(n));return i?.value}catch(e){if(404===e.response.status){xe.Rm("createIfNotExists: doc does NOT exist, will create... "+t);try{await v.store.fetcher.webOperation("PUT",t,{data:"",contentType:"text/turtle"})}catch(e){throw xe.Rm("createIfNotExists doc FAILED: "+t+": "+e),e}return void delete v.store.fetcher.requested[t]}throw xe.Rm("createIfNotExists doc FAILED: "+t+": "+e),e}}async function Us(e,t){await v.store.fetcher.load(e);const n=v.store.any(v.store.sym(e),v.store.sym("http://www.iana.org/assignments/link-relations/acl"));if(!n)throw new Error("Key ACL doc not found!");try{await v.store.fetcher.webOperation("PUT",n.value,{data:t,contentType:"text/turtle"})}catch(e){if(404!==e?.response?.status)throw new Error(e);xe.Rm("delete "+n.value+" "+e.response.status)}}function Fs(e){return ja(Ns.getPublicKey(Oa(e)))}async function Ps(e){await v.store.fetcher.load(e);const t=await Os(e),n=await(e=>{let t;try{t=`${Ds(e)}/settings/keys/privateKey.ttl`}catch(e){xe.z3(e)}return t})(e),i=await async function(e,t){return await Ms(e,t,"publicKey")}(e,t);let a=await async function(e,t){return await Ms(e,t,"privateKey")}(e,n),o=!0;if(a&&i!==Fs(a)&&confirm("This is strange the publicKey is not valid for\n"+e?.uri+"'shall we repair keeping the private key ?")&&(o=!1),!a||!i||!o){let r=[],c=[];if(a||(a=ja(Ns.utils.randomSecretKey()),c=[g.st(e,b.solid("privateKey"),g.literal(a),v.store.sym(n))],await zs(n,[],c,e.uri)),!i||!o){r=[],i&&(r=[g.st(e,b.solid("publicKey"),g.lit(i),v.store.sym(t))],xe.Rm("delete invalid publicKey "+r));const n=Fs(a);c=[g.st(e,b.solid("publicKey"),g.literal(n),v.store.sym(t))],await zs(t,r,c)}const l=n.substring(0,n.lastIndexOf("/")+1);await Us(l,(s=e.uri,`\n@prefix : <#>.\n@prefix acl: <http://www.w3.org/ns/auth/acl#>.\n@prefix foaf: <http://xmlns.com/foaf/0.1/>.\n@prefix key: <./>.\n\n:ReadWrite\n a acl:Authorization;\n acl:accessTo key:;\n acl:default key:;\n acl:agent <${s}>;\n acl:mode acl:Read, acl:Write.\n`))}var s;return a}async function zs(e,t,n,i=""){await(async e=>{await v.store.fetcher.load(e);const t=v.store.any(v.store.sym(e),v.store.sym("http://www.iana.org/assignments/link-relations/acl"));if(t)try{const e=await v.store.fetcher.webOperation("DELETE",t.value);xe.Rm("delete keyAcl"+t.value+" "+e.status)}catch(e){if(404!==e.response.status)throw new Error(e);xe.Rm("delete keyAcl"+t.value+" "+e.response.status)}})(e),await v.store.updater.updateMany(t,n);const a=((e,t)=>{let n="acl:agentClass foaf:Agent";return t?.length&&(n=`acl:agent <${t}>`),`\n@prefix foaf: <http://xmlns.com/foaf/0.1/>.\n@prefix acl: <http://www.w3.org/ns/auth/acl#>.\n<#Read>\n a acl:Authorization;\n ${n};\n acl:accessTo <${e.split("/").pop()}>;\n acl:mode acl:Read.\n`})(e,i);await Us(e,a)}class qs{constructor(e,t){this.channel=e,this.channelRoot=e.doc(),this.options=t,this.dateFolder=new ya(this.channelRoot,"chat.ttl"),this.div=null}async createMessage(e){return this.updateMessage(e)}async updateMessage(e,t=null,n,i=null){const a=[],o=new Date,s=""+o.getTime(),r=g.term(o),c=t?t.doc():this.dateFolder.leafDocumentFromDate(o),l=v.store.sym(c.uri+"#Msg"+s),p=v.authn.currentUser(),u={id:"",created:"",dateDeleted:"",content:"",maker:"",sig:""};if(u.id=l.uri,t){const e=v.store.any(t,b.foaf("maker"));if(e.uri!==p.uri){const t="Error you cannot delete/edit a message from someone else : \n"+e.uri;throw xe.R8(t),alert(t),new Error(t)}{const e=await Vs(t);a.push(g.st(e,b.dct("isReplacedBy"),l,c));const i=v.store.any(e,b.sioc("has_reply"));i&&a.push(g.st(l,b.sioc("has_reply"),i,c)),n&&a.push(g.st(l,b.schema("dateDeleted"),r,c))}}else a.push(g.st(this.channel,b.wf("message"),l,c));if(a.push(g.st(l,b.sioc("content"),v.store.literal(e),c)),u.content=e,a.push(g.st(l,b.dct("created"),r,c)),u.created=r.value,p){a.push(g.st(l,b.foaf("maker"),p,c)),u.maker=p.uri;const e=function(e,t){return ja(Ns.sign(Oa(Bs(e)),Oa(t)))}(u,await Ps(p));a.push(g.st(l,g.sym(`${$s}proofValue`),g.lit(e),c))}i&&(a.push(g.st(i,b.sioc("has_member"),l,c)),i.doc().sameTerm(l.doc())||a.push(g.st(i,b.sioc("has_member"),l,i.doc())));try{await v.store.updater.updateMany([],a)}catch(e){const t="Error saving chat message: "+e;throw xe.R8(t),alert(t),new Error(t)}return l}async deleteMessage(e){return this.updateMessage("(message deleted)",e,!0)}async createThread(e){const t=v.store.each(e,b.sioc("has_reply"),null,e.doc()).filter(e=>v.store.holds(e,b.rdf("type"),b.sioc("Thread"),e.doc()));if(t.length>0)return t[0];const n=g.sym(e.uri+"-thread"),i=[g.st(n,b.rdf("type"),b.sioc("Thread"),n.doc()),g.st(e,b.sioc("has_reply"),n,n.doc())];return await v.store.updater.update([],i),n}}async function Hs(e){const t=[e],n={};n[e.uri]=!0;let i=e;for(;;){const e=v.store.any(null,b.dct("isReplacedBy"),i,i.doc());if(!e||n[e.uri])break;await v.store.fetcher.load(e),t.unshift(e),n[e.uri]=!0,i=e}for(i=e;;){const e=v.store.any(i,b.dct("isReplacedBy"),null,i.doc());if(!e||n[e.uri])break;t.push(e),n[e.uri]=!0,i=e}return t}async function Vs(e){let t=e;const n={};for(;t;){if(n[t.uri])return xe.z3("mostRecentVersion: verion loop"+e),e;n[t.uri]=!0,e=t,await v.store.fetcher.load(e),t=v.store.any(e,b.dct("isReplacedBy"),null,e.doc())}return e}function Gs(e){return v.store.holds(e,b.schema("dateDeleted"),null,e.doc())}const Ws=v.solidLogicSingleton.store;function Js(e,t,n,i,a,o){t.setAttribute("style",Ke.participantsStyle);const s=function(n){const i=Ws.any(n,b.wf("participant"));let a;if(!i)return a=e.createElement("tr"),a.textContent="???",a;const s=Ws.anyValue(n,b.ui("backgroundColor"))||Ze,r=e.createElement("div");r.setAttribute("style",Ke.participantsBlock),r.style.backgroundColor=s,a=Ft(e,null,i,o),t.appendChild(a);const c=e.createElement("td");return c.setAttribute("style",Ke.personTableTD),c.appendChild(r),a.insertBefore(c,a.firstChild),a},r=function(){const e=Ws.each(i,b.wf("participation")).map(function(e){return(0,xe.Rm)("in participants"),[Ws.anyValue(e,b.cal("dtstart"))||"9999-12-31",e]});e.sort();const n=e.map(function(e){return e[1]});Z(t,n,s)};return t.refresh=r,r(),t}function Qs(e,t,n){return new Promise(function(i,a){if(!n)throw new Error("No user id");const o=Ws.each(e,b.wf("participation")).filter(function(e){return Ws.holds(e,b.wf("participant"),n)});if(o.length>1){const e=[];for(const t of o){const n=Ws.anyValue(t,b.cal("dtstart"));n&&e.push([n,t])}e.sort(),xe.R8("Multiple participation objects, picking earliest, in "+t),i(e[0][1])}if(o.length)i(o[0]);else{const o=Ei(t),s=[(0,g.st)(e,b.wf("participation"),o,t),(0,g.st)(o,b.wf("participant"),n,t),(0,g.st)(o,b.cal("dtstart"),new Date,t),(0,g.st)(o,b.ui("backgroundColor"),er(n),t)];Ws.updater.update([],s,function(e,t,n){t?i(o):a(new Error("Error recording your participation: "+n))}),i(o)}})}function Zs(e,t,n){const i=v.authn.currentUser();if(!i)return;const a=Ws.each(e,b.wf("participation")).filter(function(e){return Ws.holds(e,b.wf("participant"),i)});if(a.length>1)throw new Error("Multiple records of your participation");if(a.length)return a[0];{if(!Ws.updater.editable(t))return xe.Rm("Not recording participation, as no write access as "+i+" to "+t),null;const a=Ei(t),o=[(0,g.st)(e,b.wf("participation"),a,t),(0,g.st)(a,b.wf("participant"),i,t),(0,g.st)(a,b.cal("dtstart"),new Date,t),(0,g.st)(a,b.ui("backgroundColor"),er(i),t)];return Ws.updater.update([],o,function(e,t,i){if(!t)throw new Error("Error recording your participation: "+i);n&&n.refresh&&n.refresh()}),a}}function Ys(e,t,n,i,a,o){const s=e.createElement("table");t.appendChild(s),Js(e,s,0,i,0,o);try{Zs(i,n,s)}catch(n){t.appendChild(nt(e,"Error recording your participation: "+n))}return s}const Ks=v.solidLogicSingleton.store,Xs=(0,g.Namespace)("http://www.w3.org/ns/pim/pad#");function er(e){return e&&e.uri?"#"+(16777215&(t=e.uri,t.split("").reduce(function(e,t){return(e=(e<<5)-e+t.charCodeAt(0))&e},0))|12632256).toString(16):"#ffffff";var t}function tr(e,t,n,i,a){const o=(a=a||{}).exists,s=e.createElement("table"),r=Ks;if(i&&!i.uri)throw new Error("UI.pad.notepad: Invalid userid");const c=Ks.updater,l=(0,g.Namespace)("http://www.w3.org/ns/pim/pad#");s.setAttribute("style",Ke.notepadStyle);let p=null,u=null;if(a.statusArea){const t=a.statusArea.appendChild(e.createElement("table")).appendChild(e.createElement("tr"));p=t.appendChild(e.createElement("td")),u=t.appendChild(e.createElement("td")),p&&p.setAttribute("style",Ke.upstreamStatus),u&&u.setAttribute("style",Ke.downstreamStatus)}const d=function(t,n=!1){(0,xe.Rm)(t),a.statusArea&&(n?p:u).appendChild(nt(e,t,"pink"))},m=function(e){a.statusArea&&(a.statusArea.innerHTML="")},f=function(e,t,n){const i=e.subject;t=t||"";const a=Ke.baseStyle,o=Ke.headingCore,s=Ke.headingStyle,c=r.any(i,b.dc("author"));if(!t&&c){t="color: "+(n?"#888":"black")+"; background-color: "+er(c)+";"}let p=r.any(i,l("indent"));p=p?p.value:0;const u=p>=0?a+"text-indent: "+3*p+"em;":o+s[-1-p];e.setAttribute("style",u+t)},h=function(e){const i=e.subject;if(!i)throw new Error("No chunk for line to be deleted!");const a=r.any(void 0,l("next"),i),o=r.any(i,l("next"));if(a.sameTerm(n)&&o.sameTerm(n))return void(0,xe.Rm)("You can't delete the only line.");const s=r.statementsMatching(i,void 0,void 0,t).concat(r.statementsMatching(void 0,void 0,i,t)),p=[(0,g.st)(a,l("next"),o,t)];if(i instanceof g.NamedNode){const e=i.uri.slice(-4);(0,xe.Rm)("Deleting line "+e)}if(!c)throw new Error("have no updater");c.update(s,p,function(t,n,a,o){if(n){const t=e.parentNode;if(t){const e=t.previousSibling;t.parentNode&&t.parentNode.removeChild(t),e&&e.firstChild&&e.firstChild.focus()}}else if(o&&409===o.status)f(e,"color: black; background-color: #ffd;"),e.state=0,W(),setTimeout(function(){A()},1e3);else{(0,xe.Rm)(" removePart FAILED "+i+": "+a),(0,xe.Rm)(" removePart was deleting :'"+s),f(e,"color: black; background-color: #fdd;");const t=o?o.status:" [no response field] ";d("Error "+t+" saving changes: "+String(a))}})},v=function(e,n){let i=null;e.addEventListener("keydown",function(i){if(!c)throw new Error("no updater");let a,o;switch(i.keyCode){case 13:{const t=i.shiftKey;if((0,xe.Rm)("enter"),t?(o=r.any(void 0,l("next"),n),a="newlinesAfter"):(o=r.any(n,l("next")),a="newlinesBefore"),o[a]=o[a]||0,o[a]+=1,o[a]>1)return void(0,xe.Rm)(" queueing newline queue = "+o[a]);(0,xe.Rm)(" go ahead line before "+o[a]),y(e,t);break}case 8:if(0===e.value.length)switch((0,xe.Rm)("Delete key line "+n.uri.slice(-4)+" state "+e.state),e.state){case 1:case 2:return void(e.state=4);case 3:case 4:return;case void 0:case 0:e.state=3,h(e),i.preventDefault();break;default:throw new Error("pad: Unexpected state "+e)}break;case 9:{const a=i.shiftKey?-1:1;!function(e,n,i){const a=r.statementsMatching(n,l("indent")),o=a.length?Number(a[0].object.value):0;if(o+i<-3)return;const s=o+i,p=(0,g.st)(n,l("indent"),s,t);if(!c)throw new Error("no updater");c.update(a,p,function(n,i,a){i?f(e):((0,xe.Rm)("Indent change FAILED '"+s+"' for "+t+": "+a),f(e,"color: black; background-color: #fdd;"),c.requestDownstreamAction(t,A))})}(e,n,a),i.preventDefault();break}case 27:(0,xe.Rm)("escape"),c.requestDownstreamAction(t,A),i.preventDefault();break;case 38:e.parentNode.previousSibling&&(e.parentNode.previousSibling.firstChild.focus(),i.preventDefault());break;case 40:e.parentNode.nextSibling&&(e.parentNode.nextSibling.firstChild.focus(),i.preventDefault())}});const a=function(e){const n=e.subject;f(e,void 0,!0);const i=r.any(n,b.sioc("content")).value,o=[(0,g.st)(n,b.sioc("content"),i,t)];let s;e.value&&(s=[(0,g.st)(n,b.sioc("content"),e.value,t)]);const l=e.value;if(e.lastSent&&i!==e.lastSent&&console.warn("Out of order, last sent expected '"+i+"' but found '"+e.lastSent+"'"),e.lastSent=l,!c)throw new Error("no updater");c.update(o,s,function(n,o,s,r){if(o)m(),f(e),(0,xe.Rm)(" Patch ok '"+i+"' -> '"+l+"' "),4===e.state?(e.state=3,h(e)):3===e.state||(2===e.state?(e.state=1,a(e)):e.state=0);else if((0,xe.Rm)(" patch FAILED "+r.status+" for '"+i+"' -> '"+l+"': "+s),409===r.status)f(e,"color: black; background-color: #fdd;"),e.state=0,W(),setTimeout(function(){c.requestDownstreamAction(t,A)},1e3);else{f(e,"color: black; background-color: #fdd;");const t=r?.status;t&&502!==t&&503!==t?(e.state=0,d(" Error "+t+" sending data: "+s,!0),W()):(e.lastSent=void 0,e.state=0,setTimeout(()=>{0!==e.state&&void 0!==e.state||(e.state=1,a(e))},2e3))}})};e.addEventListener("input",function(t){switch(f(e,void 0,!0),(0,xe.Rm)("Input event state "+e.state+" value '"+e.value+"'"),e.state){case 3:case 4:case 2:return;case 1:return void(e.state=2);case 0:case void 0:null!==i&&clearTimeout(i),i=setTimeout(()=>{i=null,0!==e.state&&void 0!==e.state||(e.state=1,a(e))},400)}})},x=function(t,n,a){let o=r.any(n,b.sioc("content"));o=o?o.value:"";const c=e.createElement("tr");a?s.insertBefore(c,t):t&&t.nextSibling?s.insertBefore(c,t.nextSibling):s.appendChild(c);const l=c.appendChild(e.createElement("input"));return l.subject=n,l.setAttribute("type","text"),l.value=o,i?(f(l,""),v(l,n)):(f(l,"color: #222; background-color: #fff"),(0,xe.Rm)("Note can't add listeners - not logged in")),l},y=function(e,a){const o=Ks;let s,r,p,u,d,m=0,h=null;e?("input"!==e.tagName.toLowerCase()&&(0,xe.Rm)("return pressed when current document is: "+e.tagName),s=e.subject,m=o.any(s,l("indent")),m=m?Number(m.value):0,a?(r=o.any(void 0,l("next"),s),p=s,u=r,h="newlinesAfter"):(r=s,p=o.any(s,l("next")),u=p,h="newlinesBefore"),d=e.parentNode):(r=n,p=n,d=void 0);const v=Ei(t),w=v.uri.slice(-4),C=[(0,g.st)(r,l("next"),p,t)],E=[(0,g.st)(r,l("next"),v,t),(0,g.st)(v,l("next"),p,t),(0,g.st)(v,b.dc("author"),i,t),(0,g.st)(v,b.sioc("content"),"",t)];if(m>0&&E.push((0,g.st)(v,l("indent"),m,t)),(0,xe.Rm)(" Fresh chunk "+w+" proposed"),!c)throw new Error("no updater");c.update(C,E,function(e,t,n,i){if(t){const e=x(d,v,a);f(e),e.focus(),h&&((0,xe.Rm)(" Fresh chunk "+w+" updated, queue = "+u[h]),u[h]-=1,u[h]>0&&((0,xe.Rm)(" Implementing queued newlines = "+p.newLinesBefore),y(e,a)))}else(0,xe.Rm)(" ERROR writing new line "+w+": "+n)})},w=function(){const e={};let t=0;function i(e){d(e),t++}if(!r.the(n,l("next")))return i("No initial next pointer"),!1;let a,o=n;for(;a=r.the(o,l("next")),a||i("No next pointer from "+o),!a.sameTerm(n);){o=a;const t=a.uri.split("#")[1];if(e[a.uri])return i("Loop!"),!1;e[a.uri]=!0;let n=r.each(a,l("next")).length;1!==n&&i("Should be 1 not "+n+" next pointer for "+t),n=r.each(a,l("indent")).length,n>1&&i("Should be 0 or 1 not "+n+" indent for "+t),n=r.each(a,b.sioc("content")).length,1!==n&&i("Should be 1 not "+n+" contents for "+t),n=r.each(a,b.dc("author")).length,1!==n&&i("Should be 1 not "+n+" author for "+t);r.statementsMatching(void 0,b.sioc("contents")).forEach(function(t){e[t.subject.value]||i("Loose chunk! "+t.subject.value)})}return!t},C=function(){if(1!==r.each(n,l("next")).length){const e="Pad: Inconsistent data - NEXT pointers: "+r.each(n,l("next")).length;return(0,xe.Rm)(e),void(a.statusArea&&(a.statusArea.textContent+=e))}let e;const t=[];for(let e=r.the(n,l("next"));!e.sameTerm(n);e=r.the(e,l("next")))for(let n=0;n<s.children.length;n++){const i=s.children[n];i.firstChild&&i.firstChild.subject.sameTerm(e)&&(t[e.uri]=i.firstChild)}for(let n=s.children.length-1;n>=0;n--)e=s.children[n],t[e.firstChild.subject.uri]||s.removeChild(e);e=s.firstChild;for(let i=r.the(n,l("next"));!i.sameTerm(n);i=r.the(i,l("next"))){const n=r.any(i,b.sioc("content")).value;if(e&&t[i.uri]){const t=e.firstChild;n!==t.value&&(t.value=n),f(t),t.state=0,delete t.lastSent,e=e.nextSibling}else x(e,i,!0)}},E=function(e){if(e.refresh)e.refresh();else for(let t=0;t<e.children.length;t++)E(e.children[t])};let k=!1;const A=function(){if(k)return void(0,xe.Rm)(" Already reloading - stop");k=!0;let e=1e3;const n=function(){if((0,xe.Rm)("try reload - timeout = "+e),!c)throw new Error("no updater");c.reload(c.store,t,function(i,a,o){k=!1,i?((0,xe.Rm)(" reloaded OK"),m(),w()?E(s):d("CONSISTENCY CHECK FAILED")):0===o.status?(d("Network error refreshing the pad. Retrying in "+e/1e3),k=!0,e*=2,setTimeout(n,e)):d("Error "+o.status+"refreshing the pad:"+a+". Stopped. "+t)})};n()};if(s.refresh=C,s.reloadAndSync=A,i||(0,xe.Rm)("Warning: must be logged in for pad to be edited"),o)(0,xe.Rm)("Existing pad."),w()?(C(),r.holds(n,l("next"),n)&&y()):(0,xe.Rm)(s.textContent="Inconsistent data. Abort");else{(0,xe.Rm)("No pad exists - making new one.");const e=[(0,g.st)(n,b.rdf("type"),l("Notepad"),t),(0,g.st)(n,b.dc("author"),i,t),(0,g.st)(n,b.dc("created"),new Date,t),(0,g.st)(n,l("next"),n,t)];if(!c)throw new Error("no updater");c.update([],e,function(e,t,n){t?((0,xe.Rm)("Initial pad created"),y()):d(n||"")})}return s}function nr(e,t){const n=[];for(let i=t.the(e,Xs("next"));!i.sameTerm(e);i=t.the(i,Xs("next")))n.push(i);return n}function ir(e){return e.replace("&","&amp;").replace("<","&lt;").replace(">","&gt;")}function ar(e,t){const n=nr(e,t);let i="<html>\n <head>\n";const a=t.anyValue(e,b.dct("title"));a&&(i+=` <title>${ir(a)}</title>\n`),i+=" </head>\n <body>\n";let o=0;function s(e){for(;o>e;o--)i+="</ul>\n"}return n.forEach(e=>{const n=t.anyJS(e,Xs("indent")),a=t.anyJS(e,b.sioc("content"));if(!a)return;const r=ir(a);if(n<0){s(0);const e=n>=-3?4+n:1;i+=`\n<h${e}>${r}</h${e}>\n`}else n>0?(s(n),function(e){for(;o<e;o++)i+="<ul>\n"}(n),i+=`<li>${r}</li>\n`):(s(n),i+=`<p>${r}</p>\n`)}),s(0),i+=" </body>\n</html>\n",i}const or={icons:it.Pt,ns:b,media:ba,pad:p,style:Ke,utils:a,widgets:r},sr=g.Namespace("http://www.w3.org/2002/01/bookmark#"),rr=F,cr=window.document||null;function lr(e,t){return new Promise(function(n,i){v.store.updater.update(e,t,function(e,t,a){t?n():i(new Error(a))})})}async function pr(e,t,n){await v.store.fetcher.load(e.bookmarkDocument);const i=v.store.each(null,sr("recalls"),t,e.bookmarkDocument);if(i.length){if(!confirm("Delete bookmark on this?"+i.length))return;for(let e=0;e<i.length;e++)try{await lr(v.store.connectedStatements(i[e]),[]),n.style.backgroundColor="white",xe.Rm("Bookmark deleted: "+i[e])}catch(e){xe.z3("Cant delete bookmark:"+e),xe.R8("Cannot delete bookmark:"+e)}}else{const i=await async function(e,t){let n="";const i=v.authn.currentUser();if(!i)throw new Error("Must be logged on to add Bookmark");const a=v.store.any(t,b.foaf("maker"));n=rr(a)+": "+v.store.anyValue(t,b.sioc("content")).slice(0,80);const o=e.bookmarkDocument,s=or.widgets.newThing(o,n),r=[g.st(o,or.ns.dct("references"),s,o),g.st(s,or.ns.rdf("type"),sr("Bookmark"),o),g.st(s,or.ns.dct("created"),new Date,o),g.st(s,sr("recalls"),t,o),g.st(s,or.ns.foaf("maker"),i,o),g.st(s,or.ns.dct("title"),n,o)];try{await lr([],r)}catch(e){const t="Making bookmark: "+e;return xe.R8(t),null}return s}(e,t);n.style.backgroundColor="yellow",xe.Rm("Bookmark added: "+i)}}const ur=window.document,dr={};async function mr(e,t,n,i){async function a(t){c.value===v.store.any(e,b.foaf("maker")).value&&(s(),await async function(e,t,n,i){const a=e.parentNode,o=wr(n,a,i,n.options,await Vs(t));a.insertBefore(o,e),o.originalRow=e,e.style.visibility="hidden"}(t,e,i,n))}const o=ur.createElement("div");if(await Vs(e).value===b.schema("dateDeleted").value)return o;function s(){o.parentElement.parentElement.removeChild(o.parentElement)}async function r(e){await v.store.updater.update(v.store.connectedStatements(e),[])}let c=v.authn.currentUser();function l(e,n,i,a,o,s){function c(){l.style.backgroundColor=d?"yellow":"white"}const l=Dt(ur,i,F(a),async function(i){if(d)await r(d),d=null,c();else{d=Ei(o);const i=[g.st(d,b.schema("agent"),e.me,o),g.st(d,b.rdf("type"),a,o),g.st(d,b.schema("target"),n,o)];if(await v.store.updater.update([],i),c(),s){let e=!1;for(let t=0;t<s.length;t++){const n=p(s[t]);n&&(await r(n),e=!0)}e&&Vt(t)}}});function p(t){const i=v.store.each(null,b.schema("agent"),e.me,o).filter(e=>v.store.holds(e,b.rdf("type"),t,o)).filter(e=>v.store.holds(e,b.schema("target"),n,o));return i.length?i[0]:null}function u(){d=p(a),c()}let d;return l.refresh=u,u(),l}if(c&&v.store.holds(e,b.foaf("maker"),c)&&(o.appendChild(Bt(ur,o,"message",async function(){const a=v.store.any(e,b.foaf("maker"));if(c)if(c.sameTerm(a)){try{await i.deleteMessage(e)}catch(e){const i="Error deleting messaage "+e;xe.R8(i),alert(i),(n.statusArea||t.parentNode).appendChild(nt(ur,i))}t.parentNode.removeChild(t)}else alert("You can't delete the message, you are not logged in as the author, "+a);else alert("You can't delete the message, you are not logged in.");s()})),o.appendChild(Dt(ur,it.Pt.iconBase+"noun_253504.svg","edit",()=>a(t)))),async function(e,t){let n;if(e.bookmarkDocument)return n=or.widgets.button(cr,or.icons.iconBase+"noun_45961.svg",rr(sr("Bookmark")),()=>{pr(e,t,n)}),n.target=t,await async function(t){await v.store.fetcher.load(e.bookmarkDocument);const n=v.store.any(null,sr("recalls"),t.target,e.bookmarkDocument);t.style=or.style.buttonStyle,n&&(t.style.backgroundColor="yellow")}(n),n}(n).then(e=>{e&&o.appendChild(e)}),c=v.authn.currentUser(),c&&await Vs(e).value!==b.schema("dateDeleted").value){const t={me:c,dom:ur,div:o};o.appendChild(l(t,e,it.Pt.iconBase+"noun_1384132.svg",b.schema("AgreeAction"),e.doc(),[b.schema("DisagreeAction")])),o.appendChild(l(t,e,it.Pt.iconBase+"noun_1384135.svg",b.schema("DisagreeAction"),e.doc(),[b.schema("AgreeAction")]))}v.store.any(e,b.dct("created"))&&o.appendChild(Dt(ur,it.Pt.iconBase+"noun-reply-5506924.svg","Reply in thread",async()=>{await async function(){const t=await i.createThread(e),a=n.chatOptions;if(!a)throw new Error("replyInThread: missing options");a.showThread(t,a),s()}()}));const p=o.appendChild(Ot(ur));return p.style.float="right",p.firstChild.style.opacity="0.3",p.addEventListener("click",s),o}dr[b.schema("AgreeAction")]="👍",dr[b.schema("DisagreeAction")]="👎",dr[b.schema("EndorseAction")]="⭐️",dr[b.schema("LikeAction")]="❤️";const fr=window.document,hr=Ke.messageBodyStyle,gr=F;const br=function(e,t){const n=fr.createElement("a");return t&&t.uri&&(n.setAttribute("href",t.uri),n.addEventListener("click",Wt,!0),n.setAttribute("style","color: #3B5998; text-decoration: none; ")),n.textContent=e,n};function vr(e){const t=v.store.any(e,b.foaf("nick"));return t?""+t.value:""+gr(e)}function xr(e,t,n,i){const a=e.appendChild(br(vr(t),t));t.uri&&v.store.fetcher.nowOrWhenFetched(t.doc(),void 0,function(e,n){a.textContent=vr(t)}),e.appendChild(fr.createElement("br")),e.appendChild(br(n,i))}async function yr(e,t,n,i,a){let o=!1;const s="1"===i.colorizeByAuthor||!0===i.colorizeByAuthor,r=v.store.any(t,b.foaf("maker")),c=v.store.any(t,b.dct("created")),l=await Vs(t),p=v.store.any(l,b.foaf("maker")),u=r.uri===p?.uri?l:t,d=v.store.any(u,b.sioc("content")),m=await Hs(u);m.length>1&&xe.Rm("renderMessageRow versions: ",m.join(", "));const f=m.map(e=>v.store.each(e,b.sioc("has_reply"))).flat();let h=null;const g=[];for(const e of f)v.store.holds(e,b.rdf("type"),b.sioc("Thread"))?(h=e,xe.Rm("renderMessageRow: found thread: "+h)):g.push(e);g.length>1&&xe.Rm("renderMessageRow: found normal replies: ",g),h||(h=v.store.any(null,b.sioc("has_member"),t));const x=v.store.any(u,$rdf.sym(`${$s}proofValue`)),y={id:"",created:"",dateDeleted:"",content:"",maker:"",sig:""};y.id=u.uri,y.created=v.store.any(u,b.dct("created")).value,y.content=d.value,y.maker=r.uri,x?.value?async function(e){await v.store.fetcher.load(e);const t=await Os(e);try{await v.store.fetcher.load(t);const n=v.store.any(e,b.solid("publicKey"));return n?.value}catch(e){return}}(r).then(e=>{e||xe.R8("message is signed but "+r.uri+" is missing publicKey");e?.match(/[0-9A-Fa-f]{6}/g)?x?.value&&!function(e,t,n){return Ns.verify(Oa(e),Oa(Bs(t)),Oa(n))}(x?.value,y,e)&&xe.R8("invalid signature\n"+y.id):xe.R8("invalid publicKey hex string\n"+r.uri+"\n"+e)}):(o=!0,xe.R8(u.uri+" is unsigned"));const w=await async function(e){let t=e;const n={};for(;t;){if(n[t.uri])return xe.z3("originalVersion: verion loop"+e),e;n[t.uri]=!0,e=t,await v.store.fetcher.load(e),t=v.store.any(null,b.dct("isReplacedBy"),e,e.doc())}return e}(t),C=!t.sameTerm(w),E=v.store.the(w,b.dct("created"),null,w.doc())||v.store.the(t,b.dct("created"),null,t.doc()),k=fr.createElement("tr");o&&k.setAttribute("style","background-color: red"),k.AJAR_date=E.value,k.AJAR_subject=t;const A=fr.createElement("td");if(k.appendChild(A),i.authorDateOnLeft)xr(A,r,Ct(E.value),t);else{const e=fr.createElement("img");e.setAttribute("style","max-height: 2.5em; max-width: 2.5em; border-radius: 0.5em; margin: auto;"),It(e,r),A.appendChild(e)}let _=Ct(E.value);C&&(_+=" ... "+Ct(c.value));const T=k.appendChild(fr.createElement("td"));i.authorDateOnLeft||function(e,t,n,i){const a=e.appendChild(br(gr(t),t));t.uri&&v.store.fetcher.nowOrWhenFetched(t.doc(),void 0,function(e,n){a.textContent=vr(t)});const o=e.appendChild(br(n,i));o.style.fontSize="80%",o.style.marginLeft="1em",e.appendChild(fr.createElement("br"))}(T,r,_,t);const S=d?d.value.trim():"??? no content?";let j=null;if(/^https?:\/[^ <>]*$/i.test(S)){if(/\.(gif|jpg|jpeg|tiff|png|svg)$/i.test(S)&&i.expandImagesInline){const e=function(e,t){const n=fr.createElement("img");let i="10";t.inlineImageHeightEms&&(i=(""+t.inlineImageHeightEms).trim()),n.setAttribute("style","max-height: "+i+"em; border-radius: 1em; margin: 0.7em;"),e&&n.setAttribute("src",e);const a=fr.createElement("a");return a.setAttribute("href",e),a.setAttribute("target","images"),a.appendChild(n),et(n,$rdf.sym(e)),a}(S,i);T.appendChild(e)}else{const e=T.appendChild(fr.createElement("a"));j=e.appendChild(fr.createElement("p")),e.href=S,j.textContent=S,T.appendChild(e)}}else j=fr.createElement("p"),T.appendChild(j),j.textContent=S;if(j){const e=s?er(r):function(e){return e?"#e8ffe8":"white"}(n);j.setAttribute("style",hr+"background-color: "+e+";")}const L=await async function(e,t){const n=ur.createElement("span");async function i(){if(n.innerHTML="",Gs(e))return n;const i=(await Hs(e)).map(e=>v.store.each(null,b.schema("target"),e,t)).flat();if(0===i.length)return n;const a=i.map(e=>[v.store.any(e,b.rdf("type"),null,t),v.store.any(e,b.sioc("content"),null,t),v.store.any(e,b.schema("agent"),null,t)]);a.sort(),a.forEach(e=>{const[t,i,a]=e;let o;a?(o=ur.createElement("a"),o.setAttribute("href",a.uri)):o=ur.createTextNode(""),o.textContent=i||dr[t]||"⬜️",n.appendChild(o)})}return i().then(xe.Rm("sentimentStripLinked: sentimentStripLinked async refreshed")),n.refresh=i,n}(t,t.doc());L.children.length&&(T.appendChild(fr.createElement("br")),T.appendChild(L));const R=fr.createElement("td");k.appendChild(R);const N=Dt(fr,it.Pt.iconBase+"noun_243787.svg","...");return R.appendChild(N),N.addEventListener("click",async function(n){if(k.toolTR)return k.parentNode.removeChild(k.toolTR),void delete k.toolTR;const o=fr.createElement("tr"),s=await mr(t,k,{...a,chatOptions:i},e);s.style="border: 0.05em solid #888; border-radius: 0 0 0.7em 0.7em; border-top: 0; height:3.5em; background-color: #fff;",k.nextSibling?k.parentElement.insertBefore(o,k.nextSibling):k.parentElement.appendChild(o),k.toolTR=o,o.appendChild(fr.createElement("td"));const r=o.appendChild(fr.createElement("td"));o.appendChild(fr.createElement("td")),r.appendChild(s)}),h&&i.showThread&&R.appendChild(Dt(fr,it.Pt.iconBase+"noun_1180164.svg","see thread",e=>{i.showThread(h,i)})),k}function wr(e,t,n,i,a){async function o(e){await s(h.value,!0)}async function s(o,s){let r;s&&(h.setAttribute("style",hr+"color: #bbb;"),h.disabled=!0);try{r=await e.updateMessage(o,a,null,i.thread)}catch(e){return void(n.statusArea||u).appendChild(nt(fr,"Error writing message: "+e))}await async function(o){if(await Cr(e,t,o,!1,i,n),a){const e=u.originalRow;e.parentNode?e.parentNode.removeChild(e):(xe.R8("No parentNode on old message "+e.textContent),e.style.backgroundColor="#fee",e.style.visibility="hidden"),u.parentNode.removeChild(u)}else s&&(h.value="",h.setAttribute("style",hr),h.disabled=!1,h.scrollIntoView(i.newestFirst),h.focus(),h.select())}(r)}function r(e){const n=t.chatDocument.dir().uri;tt(v.store.fetcher,e,n+"Files",n+"Pictures",async function(e,t){await s(t)})}const c=async function(e){for(const t of e)await s(t)};let l,p;a?(l=v.store.anyValue(a,b.dct("created"),null,a.doc()),p=it.Pt.iconBase+"noun_1180158.svg"):(p=it.Pt.iconBase+"noun_383448.svg",l="9999-01-01T00:00:00Z");const u=fr.createElement("tr"),d=fr.createElement("td"),m=fr.createElement("td"),f=fr.createElement("td");let h,x;u.appendChild(d),u.appendChild(m),u.appendChild(f),u.AJAR_date=l;return Bi({div:m,dom:fr}).then(t=>{!function(){if(i.menuHandler){const e=Dt(fr,it.Pt.iconBase+"noun_243787.svg","More");e.setAttribute("style",Ke.buttonStyle+"float: right;"),f.appendChild(e)}i.menuHandler;const t=v.authn.currentUser();if(xr(d,t,"",null),h=fr.createElement("textarea"),m.innerHTML="",m.appendChild(h),h.rows=3,a&&(h.value=v.store.anyValue(a,b.sioc("content"),null,a.doc())),h.setAttribute("style",hr+"background-color: #eef;"),h.addEventListener("keydown",async function(e){"Enter"===e.code&&(!e.shiftKey&&!i.shiftEnterSendsMessage||e.shiftKey&&i.shiftEnterSendsMessage)&&await o()},!1),Xe(h,c,r),f.innerHTML="",x=Dt(fr,p,"Send"),x.style.float="right",x.addEventListener("click",e=>o(),!1),f.appendChild(x),a){const e=f.appendChild(Ot(fr));e.style.float="left",e.addEventListener("click",e=>function(e){e.originalRow.style.visibility="visible",e.parentNode.removeChild(e)}(u),!1),f.appendChild(e)}const n=e.dateFolder.leafDocumentFromDate(new Date);let l;m.appendChild(ba.cameraButton(fr,v.store,function(){return l=$rdf.sym(n.dir().uri+"Image_"+Date.now()+".png"),l},async function(e){e&&await s(e.uri)})),Zs(e.channel,e.channel.doc())}(),Object.assign(t,n),async function(e){const t=sr("Bookmark");if(await Mi(e,t,!0),e.instances&&e.instances.length>0)e.bookmarkDocument=e.instances[0],e.instances.length>1&&xe.R8("More than one bookmark file! "+e.instances);else if(e.publicProfile){const n=g.sym(e.publicProfile.dir().uri+"bookmarks.ttl");try{xe.Rm("Creating new bookmark file "+n),await v.store.fetcher.createIfNotExists(n)}catch(t){return xe.R8("Can't make fresh bookmark file:"+t),e}await v.createTypeIndexLogic.registerInTypeIndex(n,e.index,t),e.bookmarkDocument=n}else xe.R8("You seem to have no bookmark file, nor even a profile file!");return e}(t).then(e=>{})}),u}async function Cr(e,t,n,i,a,o){const s=await yr(e,n,i,a,o);a.selectedMessage&&a.selectedMessage.sameTerm(n)&&(s.style.backgroundColor="yellow",a.selectedElement=s,t.selectedElement=s);let r=!1;for(let e=t.firstChild;e;e=e.nextSibling){const n=!0===a.newestfirst,i=s.AJAR_date;if(i>e.AJAR_date&&n||i<e.AJAR_date&&!n){t.insertBefore(s,e),r=!0;break}}r||t.appendChild(s)}const Er=v.store,kr=[];function Ar(e){return kr[e]}function _r(e,t){if("string"!=typeof t)throw xe.Rm("Non-string value of preference "+e+": "+t),new Error("Non-string value of preference "+e+": "+t);this.value[e]=t}function Tr(e,t){return new Promise(function(n,i){const a=Er.any(e,b.ui("sharedPreferences"));if(a)t.sharedPreferences=a,n(t);else{Er.updater.editable(e.doc())||(xe.Rm(` Cant make shared preferences, may not change ${e.doc}`),n(t));const a=g.sym(e.doc().uri+"#SharedPreferences"),o=[g.st(e,b.ui("sharedPreferences"),a,e.doc())];xe.Rm("Creating shared preferences "+a),Er.updater.update([],o,function(e,o,s){o?(t.sharedPreferences=a,n(t)):i(new Error("Error creating shared prefs: "+s))})}})}function Sr(e,t){return new Promise(function(n,i){Di(t).then(t=>{if(!t.preferencesFile)return void xe.Rm("Not doing private class preferences as no access to preferences file. "+t.preferencesFileError);const a=Er.each(null,b.solid("forClass"),e,t.preferencesFile);let o,s,r=[];if(a.length){if(a.forEach(e=>{o=o||Er.any(e,b.solid("personalDefaults"))}),o)return t.personalDefaults=o,void n(t);o=Ei(t.preferencesFile),s=a[0]}else s=Ei(t.preferencesFile),r=[g.st(s,b.rdf("type"),b.solid("TypeRegistration"),t.preferencesFile),g.st(s,b.solid("forClass"),e,t.preferencesFile)];o=Ei(t.preferencesFile),r.push(g.st(s,b.solid("personalDefaults"),o,t.preferencesFile)),Er.updater.update([],r,function(a,s,r){s?(t.personalDefaults=o,n(t)):i(new Error("Setting preferences for "+e+": "+r))})},e=>{i(e)})})}function jr(e,t,n,i){const a=i.dom.createElement("div");return Qs(e,e.doc(),i.me).then(o=>{const s=i.dom;function r(e){a.appendChild(s.createElement("h5")).textContent=e}r("My view of this "+i.noun),li(s,a,{},o,n,e.doc(),(e,t)=>{e||xt(i,t)}),r("Everyone's view of this "+i.noun),Tr(e,i).then(i=>{const o=i.sharedPreferences;li(s,a,{},o,n,e.doc(),(e,t)=>{e||xt(i,t)}),r("My default view of any "+i.noun),Sr(t,i).then(e=>{li(s,a,{},e.personalDefaults,n,e.preferencesFile,(t,n)=>{t||xt(e,n)})},e=>{xt(i,e)})})},e=>{a.appendChild(nt(i.dom,e))}),a}function Lr(e){return e.datatype?e.datatype.equals(b.xsd("boolean"))?"1"===e.value:e.datatype.equals(b.xsd("dateTime"))||e.datatype.equals(b.xsd("date"))?new Date(e.value):e.datatype.equals(b.xsd("integer"))||e.datatype.equals(b.xsd("float"))||e.datatype.equals(b.xsd("decimal"))?Number(e.value):e.value:e}function Rr(e,t,n,i){return new Promise(function(a,o){Tr(e,i).then(i=>{const s=i.sharedPreferences;if(i.me)Qs(e,e.doc(),i.me).then(e=>{Sr(t,i).then(t=>{const i=[],o=t.personalDefaults;n.forEach(t=>{const n=Er.any(e,t)||Er.any(s,t)||Er.any(o,t);n&&(i[t.uri]=Lr(n))}),a(i)},o)},o);else{const e=[];n.forEach(t=>{const n=Er.any(s,t);n&&(e[t.uri]=Lr(n))}),a(e)}})})}const Nr={icons:it.Pt,log:i,ns:b,utils:a,widgets:r};class Ir extends HTMLElement{bodyContainer;refresh;tabContainer}function $r(e){const t=e.subject,n=e.dom||document,i=parseInt(e.orientation||"0"),a=e.backgroundColor||"#ddddcc",o=2&i,s=1&i,r=e.onClose,[c,l]=function(e){return function(e){let t=0;for(let n=0;n<3;n++)t+=parseInt(e.slice(2*n+1,2*n+3),16);return t>384}(e)?[Br(e,"#ffffff",.3),"#000000"]:[Br(e,"#000000",.3),"#ffffff"]}(a),p=`display: grid; width: auto; height: 100%; border: 0.1em; border-style: solid; border-color: ${c}; padding: 1em;`,u=n.createElement("div");u.setAttribute("style",Ke.tabsRootElement),u.style.flexDirection=(s?"row":"column")+(o?"-reverse":"");const d=u.appendChild(n.createElement("nav"));d.setAttribute("style",Ke.tabsNavElement);const m=u.appendChild(n.createElement("div"));m.setAttribute("style",Ke.tabsMainElement);const f=d.appendChild(n.createElement("ul"));f.setAttribute("style",Ke.tabContainer),f.style.flexDirection=""+(s?"column":"row");const h=m;u.tabContainer=f,u.bodyContainer=h;const g=["0.2em","0.2em","0","0"],b=`border-radius: ${g.concat(g).slice(i,i+4).join(" ")};`,x=["0.3em","0.3em","0","0.3em"],y=x.concat(x).slice(i,i+4),w=`margin: ${y.join(" ")};`,C=`padding: ${y.join(" ")};`,E=b+`position: relative; padding: 0.7em; max-width: 20em; color: ${l};`,k=`${E+w} opacity: 50%; background-color: ${a};`,A=`${E+w} background-color: ${c};`,_="height: 100%; width: 100%;",T=_+"display: none;";if(u.refresh=j,j(),!e.startEmpty&&f.children.length&&e.selectedTab){const t=Array.from(f.children).map(e=>e.firstChild).find(t=>t.dataset.name===e.selectedTab),n=e.selectedTab.uri,i=Array.from(f.children).find(e=>e.subject&&e.subject.uri&&e.subject.uri===n),a=i||t||f.children[0],o=a.firstChild;o?.click?o.click():a instanceof HTMLElement&&a.click()}else if(!e.startEmpty){const e=f.children[0],t=e?.firstChild;t?.click?t.click():e instanceof HTMLElement&&e.click()}return u;function S(t){const i=n.createElement("li");i.setAttribute("style",k),i.subject=t;const a=i.appendChild(n.createElement("button"));if(a.setAttribute("style",Ke.makeNewSlot),a.onclick=function(){if(L(),R(),i.setAttribute("style",A),!i.bodyTR)return;i.bodyTR.setAttribute("style",_);const n=o(i);e.renderMain&&i.subject&&!1!==n.asSettings&&(n.innerHTML="loading item ..."+t,e.renderMain(n,i.subject),n.asSettings=!1)},e.renderTabSettings&&i.subject){const a=n.createElement("button");a.textContent="...",a.setAttribute("style",Ke.ellipsis),a.onclick=function(){if(L(),R(),i.setAttribute("style",A),!i.bodyTR)return;i.bodyTR.setAttribute("style",_);const n=o(i);e.renderTabSettings&&i.subject&&!0!==n.asSettings&&(n.innerHTML="loading settings ..."+t,e.renderTabSettings(n,i.subject),n.asSettings=!0)},i.appendChild(a)}return e.renderTab?e.renderTab(a,t):a.innerHTML=F(t),i;function o(e){const t=e.bodyTR?.children[0];if(t)return t;const i=e.bodyTR.appendChild(n.createElement("div"));return i.setAttribute("style",p),i}}function j(){const i=e.items?e.items:!1!==e.ordered?v.store.the(t,e.predicate).elements:v.store.each(t,e.predicate);let a,o,s,c,l,p=!1;for(c=0;c<f.children.length;c++)if(a=f.children[c],c>=i.length||a.subject&&!a.subject.sameTerm(i[c])){p=!0;break}if(!p&&i.length===f.children.length)return;for(l=f.children.length-1;l>=0&&(a=f.children[l],s=l-f.children.length+i.length,!a.subject||a.subject.sameTerm(i[s]));l--);const u=i.slice(c,l-f.children.length+i.length+1);for(;l>=c;)f.removeChild(f.children[c]),h.removeChild(h.children[c]),l-=1;for(o=0;o<u.length;o++){const e=S(u[o]),t=n.createElement("div");e.bodyTR=t,c===f.children.length?(f.appendChild(e),h.appendChild(t)):(f.insertBefore(e,f.children[c+o]),h.insertBefore(t,h.children[c+o]))}r&&function(e){if(e.dataset.onCloseSet){const t=e.querySelector(".unstyled");e.removeChild(t)}const t=n.createElement("li");t.classList.add("unstyled");const i=Ot(n,r);i.setAttribute("style",i.getAttribute("style")+C),t.appendChild(i),e.appendChild(t),e.dataset.onCloseSet="true"}(f)}function L(){for(let e=0;e<f.children.length;e++){const t=f.children[e];t.classList.contains("unstyled")||t.setAttribute("style",k)}}function R(){for(let e=0;e<h.children.length;e++)h.children[e].setAttribute("style",T)}}function Br(e,t,n){let i,a,o,s="#";const r="0123456789abcdef";for(let c=0;c<3;c++){i=parseInt(e.slice(2*c+1,2*c+3),16),a=parseInt(t.slice(2*c+1,2*c+3),16),o=i*(1-n)+a*n;const l=parseInt((""+o).split(".")[0]),p=parseInt((""+l/16).split(".")[0]),u=parseInt((""+l%16).split(".")[0]);s+=r[p]+r[u]}return s}const Dr='\n<svg xmlns="http://www.w3.org/2000/svg" width="26" height="26" viewBox="0 0 26 26" fill="none">\n <path fill-rule="evenodd" clip-rule="evenodd" d="M13 25C19.6274 25 25 19.6274 25 13C25 6.37258 19.6274 1 13 1C6.37258 1 1 6.37258 1 13C1 19.6274 6.37258 25 13 25Z" fill="#D8D8D8" stroke="#8B8B8B"/>\n <mask id="mask0" mask-type="alpha" maskUnits="userSpaceOnUse" x="0" y="0" width="26" height="26">\n <path fill-rule="evenodd" clip-rule="evenodd" d="M13 25C19.6274 25 25 19.6274 25 13C25 6.37258 19.6274 1 13 1C6.37258 1 1 6.37258 1 13C1 19.6274 6.37258 25 13 25Z" fill="white" stroke="white"/>\n </mask>\n <g mask="url(#mask0)">\n <path fill-rule="evenodd" clip-rule="evenodd" d="M17.0468 10.4586C17.0468 14.4979 15.4281 16.9214 12.9999 16.9214C10.5718 16.9214 8.95298 14.4979 8.95298 10.4586C8.95298 6.41931 12.9999 6.41931 12.9999 6.41931C12.9999 6.41931 17.0468 6.41931 17.0468 10.4586ZM4.09668 23.3842C6.52483 17.7293 12.9999 17.7293 12.9999 17.7293C12.9999 17.7293 19.475 17.7293 21.9031 23.3842C21.9031 23.3842 17.8481 25 12.9999 25C8.15169 25 4.09668 23.3842 4.09668 23.3842Z" fill="#8B8B8B"/>\n </g>\n</svg>';var Or=n(565);const Mr=it.Pt.iconBase+"noun_help.svg",Ur="https://solidproject.org/assets/img/solid-emblem.svg";function Fr(e,t,n,i,a){return async()=>{const o=v.authn.currentUser();e.innerHTML="",e.appendChild(await async function(e,t,n,i,a){const o=document.createElement("a");o.href=t.uri,o.setAttribute("style",Ke.headerBannerLink);const s=document.createElement("img");a&&(s.src=a.logo?a.logo:Ur);s.setAttribute("style",Ke.headerBannerIcon),o.appendChild(s);const r=n?await async function(e,t,n){const i=e.fetcher;i&&await i.load(t);const a=document.createElement("ul");a.setAttribute("style",Ke.headerUserMenuList),n&&n.forEach(function(e){"url"===(e.url?"url":"onclick")?a.appendChild(qr(zr(e.label,e.url,e.target))):a.appendChild(qr(Pr(e.label,e.onclick)))});const o=document.createElement("nav");o.setAttribute("style",Ke.headerUserMenuNavigationMenuNotDisplayed),o.setAttribute("aria-hidden","true"),o.setAttribute("id","loggedInNav"),o.appendChild(a);const s=document.createElement("button");s.setAttribute("style",Ke.headerUserMenuTrigger),s.type="button";const r=function(e,t){let n=null;try{if(n=Rt(t),!n)return Dr}catch{return Dr}const i=document.createElement("div");return i.setAttribute("style",Ke.headerUserMenuPhoto),i.style.backgroundImage=`url(${n})`,i}(0,t);"string"==typeof r?s.innerHTML=r:s.appendChild(r);const c=document.createElement("div");c.setAttribute("style",Ke.headerBannerUserMenuNotDisplayed),c.appendChild(s),c.appendChild(o);const l=(0,Or.nF)(e=>Hr(e,s,o),50);s.addEventListener("click",l);let p=setTimeout(()=>null,0);return c.addEventListener("mouseover",e=>{clearTimeout(p),l(e);const t=document.getElementById("loggedInNav");t?.setAttribute("style",Ke.headerUserMenuNavigationMenu)}),c.addEventListener("mouseout",e=>{p=setTimeout(()=>l(e),200);const t=document.getElementById("loggedInNav");t?.setAttribute("style",Ke.headerUserMenuNavigationMenuNotDisplayed)}),c}(e,n,i):function(){const e=document.createElement("div");return e.setAttribute("style",Ke.headerBannerLogin),e.appendChild(Hi(document,null,{})),e}(),c=document.createElement("div");c.setAttribute("style",Ke.headerBanner),c.appendChild(o);const l=document.createElement("div");if(l.setAttribute("style",Ke.headerBannerRightMenu),l.appendChild(r),a&&a.helpMenuList){const e=function(e,t){if(!t)return;const n=document.createElement("ul");n.setAttribute("style",Ke.headerUserMenuList),t.forEach(function(e){"url"===(e.url?"url":"onclick")?n.appendChild(qr(zr(e.label,e.url,e.target))):n.appendChild(qr(Pr(e.label,e.onclick)))});const i=document.createElement("nav");i.setAttribute("style",Ke.headerUserMenuNavigationMenuNotDisplayed),i.setAttribute("aria-hidden","true"),i.setAttribute("id","helperNav"),i.appendChild(n);const a=document.createElement("div");a.setAttribute("style",Ke.headerBannerUserMenu),a.appendChild(i);const o=document.createElement("button");o.setAttribute("style",Ke.headerUserMenuTrigger),o.type="button";const s=document.createElement("img");s.src=e&&e.helpIcon?e.helpIcon:it.Pt.iconBase+Mr,s.setAttribute("style",Ke.headerUserMenuTriggerImg),a.appendChild(o),o.appendChild(s);const r=(0,Or.nF)(e=>Hr(e,o,i),50);o.addEventListener("click",r);let c=setTimeout(()=>null,0);return a.addEventListener("mouseover",e=>{clearTimeout(c),r(e);const t=document.getElementById("helperNav");t?.setAttribute("style",Ke.headerUserMenuNavigationMenu)}),a.addEventListener("mouseout",e=>{c=setTimeout(()=>r(e),200);const t=document.getElementById("helperNav");t?.setAttribute("style",Ke.headerUserMenuNavigationMenuNotDisplayed)}),a}(a,a.helpMenuList);l.appendChild(e)}return c.appendChild(l),c}(t,n,o,i,a))}}function Pr(e,t){const n=document.createElement("button");return n.setAttribute("style",Ke.headerUserMenuButton),n.onmouseover=function(){n.setAttribute("style",Ke.headerUserMenuButtonHover)},n.onmouseout=function(){n.setAttribute("style",Ke.headerUserMenuButton)},n.addEventListener("click",t),n.innerText=e,n}function zr(e,t,n){const i=document.createElement("a");return i.setAttribute("style",Ke.headerUserMenuLink),i.onmouseover=function(){i.setAttribute("style",Ke.headerUserMenuLinkHover)},i.onmouseout=function(){i.setAttribute("style",Ke.headerUserMenuLink)},i.href=t,i.innerText=e,n&&(i.target=n),i}function qr(e){const t=document.createElement("li");return t.setAttribute("style",Ke.headerUserMenuListItem),t.appendChild(e),t}function Hr(e,t,n){const i="true"===t.getAttribute("aria-expanded"),a="mouseover"===e.type,o="mouseout"===e.type;i&&a||!i&&o||(t.setAttribute("aria-expanded",(!i).toString()),n.setAttribute("aria-hidden",i.toString()))}const Vr="https://solidproject.org",Gr="solidproject.org";function Wr(e,t,n,i,a){return async()=>{const o=v.authn.currentUser();e.innerHTML="",e.appendChild(await function(e,t,n,i,a){const o=document.createElement("div");o.setAttribute("style",Ke.footer);const s=document.createElement("a");if(s.href=a&&a.solidProjectUrl?a.solidProjectUrl:Vr,s.innerText=a&&a.solidProjectName?a.solidProjectName:Gr,!n||!i||t&&t.equals(i)){const e=document.createElement("span");return e.innerText="Powered by ",o.appendChild(e),o.appendChild(s),o}const r=document.createElement("span");r.innerText="You're visiting ";const c=document.createElement("a");c.href=n.uri,c.innerText="the Pod";const l=document.createElement("span");l.innerText=" controlled by ";const p=document.createElement("a");p.href=i.uri,p.innerText=(0,Or.mG)(e,i);const u=document.createElement("span");u.innerText=". For more info, check out ";const d=document.createElement("span");return d.innerText=".",o.appendChild(r),o.appendChild(c),o.appendChild(l),o.appendChild(p),o.appendChild(u),o.appendChild(s),o.appendChild(d),o}(t,o,n,i,a))}}const Jr=window?window.document:null;"undefined"!=typeof window&&(window.UI={ns:b,acl:ca,aclControl:la,create:ua,createTypes:m,dom:Jr,icons:it.Pt,language:o,log:i,login:c,matrix:ma,media:ba,messageArea:function(e,t,n,i,a){t=t||v.solidLogicSingleton.store,i=i.doc();const o=va.ns,s=g.Namespace("http://www.w3.org/2005/01/wf/flow#"),r=g.Namespace("http://purl.org/dc/terms/"),c=!!(a=a||{}).newestFirst,l="white-space: pre-wrap; width: 90%; font-size:100%; border: 0.07em solid #eee; padding: .2em 0.5em; margin: 0.1em 1em 0.1em 1em;",p=e.createElement("div");let u,d;const m=v.solidLogicSingleton.store.updater,f=function(t,n){const i=e.createElement("a");return n&&n.uri&&(i.setAttribute("href",n.uri),i.addEventListener("click",va.widgets.openHrefInOutlineMode,!0),i.setAttribute("style","color: #3B5998; text-decoration: none; ")),i.textContent=t,i},h=function(t,n){const i=e.createElement("pre");return i.setAttribute("style",n||"color: grey"),p.appendChild(i),i.appendChild(e.createTextNode(t)),i},b=function(e){h(e,"color: #800;")};function x(e){const t=v.solidLogicSingleton.store.any(e,va.ns.foaf("nick"));return t?""+t.value:""+F(e)}function y(t,n,i,a){const o=t.appendChild(f(x(n),n));n.uri&&v.solidLogicSingleton.store.fetcher.nowOrWhenFetched(n.doc(),void 0,function(e,t){o.textContent=x(n)}),t.appendChild(e.createElement("br")),t.appendChild(f(i,a))}function w(e,n){const i={};let a,s;for(a=n.firstChild;a;a=a.nextSibling)a.AJAR_subject&&(i[a.AJAR_subject.uri]=!0);const r=t.each(e,o.wf("message")),c={};for(r.forEach(function(e){c[e.uri]=!0,i[e.uri]||C(e)}),a=n.firstChild;a;)s=a.nextSibling,a.AJAR_subject&&!c[a.AJAR_subject.uri]&&n.removeChild(a),a=s}const C=function(e){const n={"?msg":e,"?creator":t.any(e,o.foaf("maker")),"?date":t.any(e,r("created")),"?content":t.any(e,o.sioc("content"))};E(n,!0)},E=function(i,a){const o=i["?creator"],s=i["?msg"],r=i["?date"],p=i["?content"],d=r.value,f=e.createElement("tr");f.AJAR_date=d,f.AJAR_subject=s;let h=!1;for(let e=u.firstChild;e;e=e.nextSibling)if(d>e.AJAR_date&&c||d<e.AJAR_date&&!c){u.insertBefore(f,e),h=!0;break}h||u.appendChild(f);const g=e.createElement("td");f.appendChild(g),y(g,o,va.widgets.shortDate(d),s);const v=e.createElement("td");f.appendChild(v);const x=e.createElement("p");x.setAttribute("style",l+(a?"background-color: #e8ffe8;":"background-color: #white;")),v.appendChild(x),x.textContent=p.value;const C=e.createElement("td");f.appendChild(C);const E=e.createElement("button");C.appendChild(E),E.textContent="-",f.setAttribute("class","hoverControl"),E.setAttribute("class","hoverControlHide"),E.setAttribute("style","color: red;"),E.addEventListener("click",function(i){C.removeChild(E);const a=e.createElement("button");a.textContent="cancel",C.appendChild(a).addEventListener("click",function(e){C.removeChild(o),C.removeChild(a),C.appendChild(E)},!1);const o=e.createElement("button");o.textContent="Delete message",C.appendChild(o).addEventListener("click",function(e){C.removeChild(o),C.removeChild(a),function(e){const i=t.statementsMatching(e).concat(t.statementsMatching(void 0,void 0,e));m.update(i,[],function(e,t,i){t?w(n,u):b("Cant delete messages:"+i)})}(s)},!1)},!1)};u=e.createElement("table"),u.fresh=!1,p.appendChild(u),u.setAttribute("style","width: 100%;");const k=function(){const a=e.createElement("tr"),s=e.createElement("td"),c=e.createElement("td"),p=e.createElement("td");a.appendChild(s),a.appendChild(c),a.appendChild(p),a.AJAR_date="9999-01-01T00:00:00Z";const u=function(){f.setAttribute("class","pendingedit"),f.disabled=!0;const s=[],c=new Date,l=""+c.getTime(),p=g.term(c),u=t.sym(i.uri+"#Msg"+l);s.push(new g.Statement(n,o.wf("message"),u,i)),s.push(new g.Statement(u,o.sioc("content"),t.literal(f.value),i)),s.push(new g.Statement(u,r("created"),p,i)),d&&s.push(new g.Statement(u,o.foaf("maker"),d,i)),m.update([],s,function(n,i,o){if(i){const e={"?msg":u,"?content":t.literal(f.value),"?date":p,"?creator":d};E(e,!1),f.value="",f.setAttribute("class",""),f.disabled=!1}else a.appendChild(va.widgets.errorMessageBlock(e,"Error writing message: "+o))})};let f,h;return a.appendChild(e.createElement("br")),Bi({div:c,dom:e}).then(t=>{d=t.me,y(s,d,"",null),f=e.createElement("textarea"),c.innerHTML="",c.appendChild(f),f.rows=3,f.setAttribute("style",l+"background-color: #eef;"),f.addEventListener("keyup",function(e){13===e.keyCode&&(e.altKey||u())},!1),p.innerHTML="",h=va.widgets.button(e,va.icons.iconBase+"noun_383448.svg","Send"),h.setAttribute("style",va.style.buttonStyle+"float: right;"),h.addEventListener("click",u,!1),p.appendChild(h)}),a}();let A;if(c?u.insertBefore(k,u.firstChild):u.appendChild(k),a.query)A=a.query;else{A=new g.Query("Messages");const e={};["msg","date","creator","content"].forEach(function(t){A.vars.push(e[t]=g.variable(t))}),A.pat.add(n,s("message"),e.msg),A.pat.add(e.msg,o.dct("created"),e.date),A.pat.add(e.msg,o.foaf("maker"),e.creator),A.pat.add(e.msg,o.sioc("content"),e.content)}return t.query(A,E,void 0,function(){u.fresh=!0}),p.refresh=function(){w(n,u)},p},infiniteMessageArea:async function(e,t,n,i){async function a(e,t){if(Gs(e)&&!i.showDeletedMessages)return;let n=v.store.any(null,b.sioc("has_member"),e,e.doc());const a=v.store.any(e,b.sioc("id"),null,e.doc());if(a&&!n&&(n=v.store.any(null,b.sioc("has_member"),a,e.doc())),i.thread){if(v.store.holds(e,b.sioc("has_reply"),i.thread));else if(!n||!n.sameTerm(i.thread))return}else if(n)return;t.fresh||await Cr(u,t,e,t.fresh,i,h)}async function o(e){const t=e?w:C;let n=t.messageTable.date;if(e&&w.limit&&n<=w.limit)return x||await c(),!0;if(n=await d.loadPrevious(n,e),n||e||x||await c(),!n)return!0;let i=!1;if(!e){const e=d.leafDocumentFromDate(new Date);i=d.leafDocumentFromDate(n).sameTerm(e)}const a=await s(n,i);return t.messageTable=a,(e?p:!p)?m.appendChild(a):m.insertBefore(a,m.firstChild),i}async function s(t,n){const i=d.leafDocumentFromDate(t);try{await v.store.fetcher.createIfNotExists(i)}catch(a){const o=e.createElement("table").appendChild(e.createElement("tr"));return a.response&&a.response.status&&404===a.response.status?await r(t,n):(xe.Rm("*** Error NON 404 for chat file "+i),o.appendChild(nt(e,a,"pink")),o)}return await r(t,n)}async function r(t,n){async function s(){return await o(!1)}const r=e.createElement("table");r.style.width="100%",r.extendBackwards=async function(){const e=await o(!0);return e?r.initial=!0:r.extendedBack=!0,e},r.extendForwards=s,r.date=t;const c=d.leafDocumentFromDate(t);if(r.chatDocument=c,r.fresh=!1,r.setAttribute("style","width: 100%;"),n){r.final=!0,x=r,C.messageTable=r;const e=wr(u,r,h,i);p?r.insertBefore(e,r.firstChild):r.appendChild(e),r.inputRow=e}{const n=e.createElement("tr"),a=n.appendChild(e.createElement("td"));a.style="text-align: center; vertical-align: middle; color: #888; font-style: italic;",a.textContent=Ct(t.toISOString(),!0);const o=n.appendChild(e.createElement("td"));i.includeRemoveButton&&o.appendChild(Ot(e,e=>{m.parentNode.removeChild(m)})),r.extendedForwards=!1,p?r.appendChild(n):r.insertBefore(n,r.firstChild)}const l=v.store.statementsMatching(null,b.wf("message"),null,c);!n&&l.length;for(const e of l)await a(e.object,r);return r.fresh=!0,r}async function c(){const e=new Date,t=d.leafDocumentFromDate(e),i=await s(e,!0);return m.appendChild(i),m.refresh=async function(){var e;await async function(){const e=d.leafDocumentFromDate(new Date);if(!e.sameTerm(C.messageTable.chatDocument)){x.inputRow&&(x.removeChild(x.inputRow),delete x.inputRow);const t=C.messageTable.chatDocument;if(await c(),!v.store.holds(t,b.rdfs("seeAlso"),e,t)){const n=[g.st(t,b.rdfs("seeAlso"),e,t)];try{v.store.updater.update([],n)}catch(e){alert("Unable to link old chat file to new one:"+e)}}}}(new Date),await async function(e,t){const n={};let i,o;for(i=t.firstChild;i;i=i.nextSibling)i.AJAR_subject&&(n[i.AJAR_subject.uri]=!0);const s=v.store.each(e,b.wf("message"),null,t.chatDocument),r={};for(const e of s)r[e.uri]=!0,n[e.uri]||await a(e,t);for(i=t.firstChild;i;)o=i.nextSibling,i.AJAR_subject&&!r[i.AJAR_subject.uri]&&t.removeChild(i),i=o;for(i=t.firstChild;i;i=i.nextSibling)i.AJAR_subject&&Vt(i)}(n,i),e=n,"Notification"in window?"granted"===Notification.permission?new Notification(e):"denied"!==Notification.permission&&Notification.requestPermission().then(function(t){"granted"===t&&new Notification(e)}):xe.R8("This browser does no t support desktop notification")},v.store.updater.addDownstreamChangeListener(t,m.refresh),x=i,C.messageTable=x,i}async function l(e,t){if(E)return;E=!0;const n=!t;let a;for(;m.scrollTop<150&&w.messageTable&&!w.messageTable.initial&&w.messageTable.extendBackwards;){if(0===m.scrollHeight)return setTimeout(l,2e3),void(E=!1);const e=m.scrollHeight-m.scrollTop;if(a=await w.messageTable.extendBackwards(),n&&(m.scrollTop=m.scrollHeight-e),t&&t(),a)break}for(;i.selectedMessage&&m.scrollHeight-m.scrollTop-m.clientHeight<150&&C.messageTable&&!C.messageTable.final&&C.messageTable.extendForwards;){const e=m.scrollTop;if(a=await C.messageTable.extendForwards(),n&&(m.scrollTop=e),t&&t(),a)break}E=!1}(i=i||{}).authorDateOnLeft=!1;const p="1"===i.newestFirst||!0===i.newestFirst,u=new qs(n,i),d=u.dateFolder,m=e.createElement("div");u.div=m;const f=m.appendChild(e.createElement("div")),h={dom:e,statusArea:f,div:f};let x,y;const w={messageTable:null},C={messageTable:null};if(i.thread){const e=i.thread;if(y=v.store.any(null,b.sioc("has_reply"),e,e.doc()),y){const e=v.store.any(y,b.dct("created"),null,y.doc());e&&(w.limit=new Date(e.value))}}let E=!1;return await async function(){function e(){r&&r.selectedElement&&r.selectedElement.scrollIntoView({block:"center"})}let t,n,a;i.selectedMessage&&(n=i.selectedMessage.doc()),y&&(a=y.doc());const o=n||a;if(o){const e=new Date;t=d.leafDocumentFromDate(e).sameTerm(o)}let r;if(o&&!t){const n=d.dateFromLeafDocument(o);r=await s(n,t),m.appendChild(r),w.messageTable=r,C.messageTable=r,e(),setTimeout(e,1e3)}else await c(),w.messageTable=x,C.messageTable=x;await l(0,function(){i.selectedElement?i.selectedElement.scrollIntoView({block:"center"}):x.inputRow.scrollIntoView&&x.inputRow.scrollIntoView(p)}),m.addEventListener("scroll",l),i.solo&&document.body.addEventListener("scroll",l)}(),m},pad:p,participation:l,preferences:u,style:Ke,table:function(e,t){const n=t.sourceDocument,i=t.tableClass,a=t.query,o=Nr.ns,s=v.store,r={},c={"http://www.w3.org/2002/07/owl#sameAs":!0,"http://www.w3.org/1999/02/22-rdf-syntax-ns#type":!0},l={"http://www.w3.org/2001/XMLSchema#decimal":!0,"http://www.w3.org/2001/XMLSchema#float":!0,"http://www.w3.org/2001/XMLSchema#double":!0,"http://www.w3.org/2001/XMLSchema#integer":!0,"http://www.w3.org/2001/XMLSchema#nonNegativeInteger":!0,"http://www.w3.org/2001/XMLSchema#positiveInteger":!0,"http://www.w3.org/2001/XMLSchema#nonPositiveInteger":!0,"http://www.w3.org/2001/XMLSchema#negativeInteger":!0,"http://www.w3.org/2001/XMLSchema#long":!0,"http://www.w3.org/2001/XMLSchema#int":!0,"http://www.w3.org/2001/XMLSchema#short":!0,"http://www.w3.org/2001/XMLSchema#byte":!0,"http://www.w3.org/2001/XMLSchema#unsignedLong":!0,"http://www.w3.org/2001/XMLSchema#unsignedInt":!0,"http://www.w3.org/2001/XMLSchema#unsignedShort":!0,"http://www.w3.org/2001/XMLSchema#unsignedByte":!0},p={"http://www.w3.org/2001/XMLSchema#dateTime":!0,"http://www.w3.org/2001/XMLSchema#date":!0},u={"http://xmlns.com/foaf/0.1/Image":!0,"http://purl.org/dc/terms/Image":!0},d=t.keyVariable||"?_row";let m,f,h,b,x=0,y=null,w=null;const C=e.createElement("div");C.className="tableViewPane",C.appendChild(function(){const t=e.createElement("table");t.setAttribute("class","toolbar");const n=e.createElement("tr");return h=e.createElement("td"),n.appendChild(h),b=e.createElement("td"),n.appendChild(b),t.appendChild(n),t}());const E=e.createElement("div");let k;if(C.appendChild(E),C.refresh=function(){Y(k.query,k.logicalRows,k.columns,k)},a)k=te(a),E.appendChild(k);else{const t=function(){let e,t;const a=function(){const e={},t=s.statementsMatching(void 0,Nr.ns.rdf("type"),i,n),a={};for(let n=0;n<t.length;++n){const i=t[n].object;if("NamedNode"!==i.termType)continue;const o=I(e,i);i.uri in a||(a[i.uri]=[]),a[i.uri].push(t[n].subject),o.addUse()}return[a,e]}();e=a[0],t=a[1];for(const n in e){const i=e[n];B(t[n],i)}return[new S(null),L(t)]}();m=t[0],f=t[1],i||h.appendChild(function(t,n){const i=e.createElement("div");i.appendChild(e.createTextNode("Select type: "));const a=e.createElement("select");a.appendChild(R("All types","null"));for(const e in n)a.appendChild(R(n[e].getLabel(),e));return a.addEventListener("click",function(){let e;e="null"===a.value?t:n[a.value],_(e)},!1),i.appendChild(a),i}(m,f)),w=function(e){let t,n=-1,i=null;for(t in e){const a=e[t];a.useCount>n&&(i=a,n=a.useCount)}return i}(f),_(w||m)}return C;function A(e){const t=new g.Query,n=s.variable(d.slice(1));return function(e,t){const n=t.getColumns();for(let t=0;t<n.length;++t){const i=s.variable("_col"+t);e.vars.push(i),n[t].setVariable(i)}}(t,e),function(e,t,n){let i=n.type;i||(i=s.variable("_any")),e.pat.add(t,Nr.ns.rdf("type"),i)}(t,n,e),function(e,t,n){const i=n.getColumns();for(let n=0;n<i.length;++n){const a=i[n],o=s.formula();o.add(t,a.predicate,a.getVariable()),e.pat.optional.push(o)}}(t,n,e),t}function _(t){T(b),b.appendChild(function(t){const n=e.createElement("div"),i=t.getUnusedColumns();if(i.sort(function(e,t){const n=e.sortKey(),i=t.sortKey();return(n>i)-(n<i)}),i.length>0){n.appendChild(e.createTextNode("Add column: "));const a=e.createElement("select");a.appendChild(R("","-1"));for(let e=0;e<i.length;++e){const t=i[e];a.appendChild(R(t.getLabel(),""+e))}n.appendChild(a),a.addEventListener("click",function(){const e=Number(a.value);e>=0&&(t.addColumn(i[e]),_(t))},!1)}return n}(t)),function(e,t){y&&(y.running=!1);const n=te(e,t);T(E),E.appendChild(n),y=e}(A(t),t)}function T(e){for(;e.childNodes.length>0;)e.removeChild(e.childNodes[0])}function S(e){this.type=e,this.columns=null,this.allColumns=[],this.useCount=0,this.getAllColumns=function(){return this.allColumns},this.getColumns=function(){if(!this.columns){const e=this.getAllColumns();this.columns=e.slice(0,7)}return this.columns},this.getUnusedColumns=function(){const e=this.getAllColumns(),t=this.getColumns(),n=[];for(let i=0;i<e.length;++i)-1===t.indexOf(e[i])&&n.push(e[i]);return n},this.addColumn=function(e){this.columns.push(e)},this.removeColumn=function(e){this.columns=this.columns.filter(function(t){return t!==e})},this.getLabel=function(){return F(this.type)},this.addUse=function(){this.useCount+=1}}function j(){this.useCount=0,this.checkedAnyValues=!1,this.possiblyLiteral=!0,this.possiblyNumber=!0,this.constraints=[],this.checkValue=function(e){const t=e.termType;this.possiblyLiteral&&"Literal"!==t&&"NamedNode"!==t?(this.possiblyNumber=!1,this.possiblyLiteral=!1):this.possiblyNumber&&("Literal"!==t?this.possiblyNumber=!1:e.value.match(/^-?\d+(\.\d*)?$/)||(this.possiblyNumber=!1)),this.checkedAnyValues=!0},this.getVariable=function(){return this.variable},this.setVariable=function(e){this.variable=e},this.getKey=function(){return this.variable.toString()},this.addUse=function(){this.useCount+=1},this.getHints=function(){return t&&t.hints&&this.variable&&t.hints[this.variable.toNT()]?t.hints[this.variable.toNT()]:{}},this.getLabel=function(){return this.getHints().label?this.getHints().label:this.predicate?this.predicate.sameTerm(o.rdf("type"))&&this.superClass?F(this.superClass,!0):F(this.predicate):this.variable?this.variable.toString():"unlabeled column?"},this.setPredicate=function(e,t,n){t?(this.inverse=e,this.constraints=this.constraints.concat(s.each(e,Nr.ns.rdfs("domain"))),e.sameTerm(o.rdfs("subClassOf"))&&"NamedNode"===n.termType&&(this.superClass=n,this.alternatives=s.each(void 0,o.rdfs("subClassOf"),n))):(this.predicate=e,this.constraints=this.constraints.concat(s.each(e,Nr.ns.rdfs("range"))))},this.getConstraints=function(){return this.constraints},this.filterFunction=function(){return!0},this.sortKey=function(){return this.getLabel().toLowerCase()},this.isImageColumn=function(){for(let e=0;e<this.constraints.length;e++)if(this.constraints[e].uri in u)return!0;return!1}}function L(e,t){const n=[];for(const i in e){const a=e[i];t&&!t(i,a)||n.push(a)}return n}function R(t,n){const i=e.createElement("option");return i.setAttribute("value",n),i.appendChild(e.createTextNode(t)),i}function N(e,t){let n;return t.uri in e?n=e[t.uri]:(n=new j,n.setPredicate(t),e[t.uri]=n),n}function I(e,t){let n;return t.uri in e?n=e[t.uri]:(n=new S(t),e[t.uri]=n),n}function $(e,t){const i=s.statementsMatching(e,void 0,void 0,n),a={};for(let e=0;e<i.length;++e){const n=i[e].predicate;if(n.uri in c)continue;const o=N(t,n);o.checkValue(i[e].object),a[n.uri]=o}return a}function B(e,t){const n={};for(let e=0;e<t.length;++e){const i=$(t[e],n);for(const e in i)i[e].addUse()}const i=L(n);!function(e){function t(e,t){return(e.useCount<t.useCount)-(e.useCount>t.useCount)}e.sort(t)}(i),e.allColumns=i}function D(t,n){const i=e.createElement("a");return i.appendChild(e.createTextNode("[x]")),i.addEventListener("click",function(){t.removeColumn(n),_(t)},!1),i}function O(e,t){let n=!0;for(let i=0;i<t.length;++i){const a=t[i],o=a.getKey();let s=null;if(o in e.values&&(s=e.values[o][0]),!a.filterFunction(s)){n=!1;break}}e._htmlRow.style.display=n?"":"none"}function M(e,t){for(let n=0;n<e.length;++n)O(e[n],t)}function U(e,t,n){function i(e){return e?"Literal"===e.termType?e.value.toLowerCase():"NamedNode"===e.termType?F(e).toLowerCase():e.value.toLowerCase():""}!function(e,t,n,i){const a=t.getKey();if(e.sort(function(e,t){let o=null,s=null;a in e.values&&(o=e.values[a][0]),a in t.values&&(s=t.values[a][0]);const r=n(o,s);return i?-r:r}),e.length){const t=e[0]._htmlRow.parentNode;for(let n=0;n<e.length;++n)t.removeChild(e[n]._htmlRow);for(let n=0;n<e.length;++n)t.appendChild(e[n]._htmlRow)}}(e,t,function(e,t){const n=i(e),a=i(t);return n<a?-1:n>a?1:0},n)}function P(t,n,i){const a=e.createElement("div"),o=e.createElement("input");o.setAttribute("type","text"),o.style.width="70%",a.appendChild(o);const s=e.createElement("span");s.appendChild(e.createTextNode("▼")),s.addEventListener("click",function(){U(t,i,!1)},!1),a.appendChild(s);const r=e.createElement("span");r.appendChild(e.createTextNode("▲")),r.addEventListener("click",function(){U(t,i,!0)},!1),a.appendChild(r);let c=null;return i.filterFunction=function(e){if(c){if(e){let t;return t="Literal"===e.termType?e.value:"NamedNode"===e.termType?F(e):"",t.toLowerCase().indexOf(c)>=0}return!1}return!0},o.addEventListener("keyup",function(){c=""!==o.value?o.value.toLowerCase():null,M(t,n)},!1),a}function z(t,n,i,a){const o=e.createElement("div"),s=e.createElement("select");let r={};for(let e=0;e<a.length;++e){const t=a[e];r[t.uri]=!0}const c=G(i).initialSelection;c&&(r=c),s.setAttribute("multiple","true");for(let e=0;e<a.length;++e){const t=a[e],n=R(F(t),e);r[t.uri]&&(n.selected=!0),s.appendChild(n)}return o.appendChild(s),i.filterFunction=function(e){return!r||e&&r[e.uri]},s.addEventListener("click",function(){{r={};const e=s.options;for(let t=0;t<e.length;t++){const n=e[t],i=Number(n.value);e[t].selected&&(r[a[i].uri]=!0)}}M(t,n)},!0),o}function q(t,n,i){const a=e.createElement("div"),o=e.createElement("input");o.setAttribute("type","text"),o.style.width="40px",a.appendChild(o);const s=e.createElement("input");s.setAttribute("type","text"),s.style.width="40px",a.appendChild(s);let r=null,c=null;function l(){r=""===o.value?null:Number(o.value),c=""===s.value?null:Number(s.value),M(t,n)}return i.filterFunction=function(e){return e&&(e=Number(e)),!(r&&(!e||e<r)||c&&(!e||e>c))},o.addEventListener("keyup",l,!1),s.addEventListener("keyup",l,!1),a}function H(e,t,n){if(n.superClass&&n.alternatives.length>0)return z(e,t,n,n.alternatives);const i=n.getConstraints();let a;for(let o=0;o<i.length;o++){if(a=i[o],n.checkedAnyValues&&n.possiblyNumber||a.uri in l)return q(e,t,n);if("http://www.w3.org/2000/01/rdf-schema#Literal"===a.uri)return P(e,t,n);const r=s.each(a,Nr.ns.owl("oneOf"));if(r.length>0)return z(e,t,n,r.elements)}return function(e,t,n){return n.checkedAnyValues&&n.possiblyNumber?q(e,t,n):n.possiblyLiteral?P(e,t,n):null}(e,t,n)}function V(t,n,i){i=i||{};const a=e.createElement("a"),o=i.linkFunction;return a.setAttribute("href",t),a.appendChild(e.createTextNode(n)),o?a.addEventListener("click",function(e){e.preventDefault(),e.stopPropagation();const t=ee(e).getAttribute("href");t||xe.Rm("No href found \n"),o(t)},!0):a.addEventListener("click",Nr.widgets.openHrefInOutlineMode,!0),a}function G(e){return t&&t.hints&&e.variable&&t.hints[e.variable.toNT()]?t.hints[e.variable.toNT()]:{}}function W(t,n){const i=G(n),a=i.cellFormat;if(!a){if("Literal"===t.termType){if(t.datatype){if(p[t.datatype.uri])return e.createTextNode(Nr.widgets.shortDate(t.value));if(l[t.datatype.uri]){const n=e.createElement("span");return n.textContent=t.value,n.setAttribute("style","text-align: right"),n}}return e.createTextNode(t.value)}if("NamedNode"===t.termType&&n.isImageColumn())return function(t){const n=e.createElement("img");return n.setAttribute("src",t.uri),n.style.height="40px",n}(t);if("NamedNode"===t.termType||"BlankNode"===t.termType)return function(e,t){let n=!1;return e.uri&&(n=e.uri.match(/^mailto:(.*)/)),V(e.uri,n?n[1]:F(e),t)}(t,i);if("Collection"===t.termType){const i=e.createElement("span");return i.appendChild(e.createTextNode("[")),t.elements.forEach(function(t){i.appendChild(W(t,n)),i.appendChild(e.createTextNode(", "))}),i.removeChild(i.lastChild),i.appendChild(e.createTextNode("]")),i}return e.createTextNode("unknown termtype '"+t.termType+"'!")}if("shortDate"===a)return e.createTextNode(Nr.widgets.shortDate(t.value))}function J(e,t){let n,i=null;if("Literal"===e.termType)i="value";else{if("NamedNode"!==e.termType)return t.indexOf(e)>=0;i="uri"}for(n=0;n<t.length;++n)if(t[n].termType===e.termType&&t[n][i]===e[i])return!0;return!1}function Q(t,n,i){let a,o=!1;for(a in i){const e=i[a];a in t.values||(t.values[a]=[]),J(e,t.values[a])||(t.values[a].push(e),o=!0)}o&&(T(t._htmlRow),function(t,n,i){const a=e.createElement("td");n._subject&&"uri"in n._subject&&a.appendChild(V(n._subject.uri,"→")),t.appendChild(a);for(let a=0;a<i.length;++a){const o=i[a],s=e.createElement("td");let r;const c=o.getKey();if(c in n.values){const t=n.values[c];let i=!1;n.originalValues&&n.originalValues[c]&&t.length!==n.originalValues[c].length&&(i=!0);for(let a=0;a<t.length;++a){const l=t[a];n.originalValues&&n.originalValues[c]&&n.originalValues[c].length>a&&(r=n.originalValues[c][a],l.toString()!==r.toString()&&(i=!0)),s.appendChild(W(l,o)),a!==t.length-1&&s.appendChild(e.createTextNode(",\n")),i&&(s.style.background="#efe")}}t.appendChild(s)}n._htmlRow=t}(t._htmlRow,t,n)),O(t,n)}function Z(e){if("uri"in e)return e.uri;if("_subject_id"in e)return e._subject_id;{const t=""+x;return e._subject_id=t,++x,t}}function Y(n,i,a,o){n.running=!0;const c=Date.now();let l=e.createElement("tr");o.appendChild(l),l.textContent="Loading ...";for(let e=0;e<i.length;e++)i[e].original=!0,i[e].originalValues||(i[e].originalValues=i[e].values),i[e].values={};s.query(n,function(t){if(!n.running)return;l.textContent+=".";let s,c=null,p=null;if(d in t&&(p=t[d],s=Z(p),s in r&&(c=r[s])),!c){const t=e.createElement("tr");o.appendChild(t),c={_htmlRow:t,_subject:p,values:{}},i.push(c),p&&(r[s]=c)}delete c.original,Q(c,a,t)},void 0,function(){l&&l.parentNode&&l.parentNode.removeChild&&(l.parentNode.removeChild(l),l=null);const e=Date.now()-c;xe.Rm("Query done: "+i.length+" rows, "+e+"ms");for(let e=i.length-1;e>=0;e--)if(i[e].original){xe.Rm(" deleting row "+i[e]._subject);const t=i[e]._htmlRow;t.parentNode.removeChild(t),delete r[Z(i[e]._subject)],i.splice(e,1)}if(t.sortBy){const e=function(e,t){for(const n in e){const i=e[n];if(i.variable.toNT()===t)return i}throw new Error(`getColumnForVariable: no column for variable ${t}`)}(a,t.sortBy);U(i,e,t.sortReverse)}t.onDone&&t.onDone(C)})}function K(e,t){Nr.log.debug(">> processing formula");for(let n=0;n<t.statements.length;++n){const i=t.statements[n];if("NamedNode"===i.predicate.termType&&"Variable"===i.object.termType){const t=i.object.toString();t in e&&e[t].setPredicate(i.predicate,!1,i.subject)}if("NamedNode"===i.predicate.termType&&"Variable"===i.subject.termType){const t=i.subject.toString();t in e&&e[t].setPredicate(i.predicate,!0,i.object)}}for(let n=0;n<t.optional.length;++n)Nr.log.debug("recurse to optional subformula "+n),K(e,t.optional[n]);Nr.log.debug("<< finished processing formula")}function X(e){const t=[],n={};for(let i=0;i<e.vars.length;++i){const a=new j,o=e.vars[i];Nr.log.debug("column "+i+" : "+o),a.setVariable(o),n[o]=a,t.push(a)}return K(n,e.pat),t}function te(t,n){let i;i=a?X(t):n.getColumns();const o=[],s=e.createElement("table");return s.appendChild(function(t,n){const i=e.createElement("tr"),a=e.createElement("th");i.appendChild(a);for(let a=0;a<t.length;++a){const o=e.createElement("th"),s=t[a];o.appendChild(e.createTextNode(s.getLabel())),n&&o.appendChild(D(n,s)),i.appendChild(o)}return i}(i,n)),s.appendChild(function(t,n){const i=e.createElement("tr");i.className="selectors",i.appendChild(e.createElement("td"));for(let a=0;a<n.length;++a){const o=e.createElement("td"),s=H(t,n,n[a]);s&&o.appendChild(s),i.appendChild(o)}return i}(o,i)),s.logicalRows=o,s.columns=i,s.query=t,Y(t,o,i,s),s}},tabs:d,utils:a,widgets:r,initHeader:async function(e,t,n){const i=document.getElementById("PageHeader");if(!i)return;const a=(0,Or.E6)();Fr(i,e,a,t,n)(),v.authSession.events.on("logout",Fr(i,e,a,t,n)),v.authSession.events.on("login",Fr(i,e,a,t,n))},initFooter:async function(e,t){const n=document.getElementById("PageFooter");if(!n)return;const i=(0,Or.E6)(),a=await(0,Or.bB)(i,e);Wr(n,e,i,a,t)(),v.authSession.events.on("login",Wr(n,e,i,a,t)),v.authSession.events.on("logout",Wr(n,e,i,a,t))}})},565(e,t,n){"use strict";n.d(t,{E6:()=>o,bB:()=>s,mG:()=>r,nF:()=>c});var i=n(511),a=n(788);function o(){const{origin:e,pathname:t}=document.location,n="databrowser"===document.body?.dataset?.appShell,a=t.split("/").filter(Boolean),o=a[a.length-1]||"",s=/\.[^/]+$/.test(o);return n&&a.length>0&&!s?(0,i.sym)(`${e}/${a[0]}/`):(0,i.sym)(e).site()}async function s(e,t){try{if(!t.any(e,null,a.ns.ldp("Container"),e)){const n=(await t.fetcher.webOperation("GET",e.uri,t.fetcher.initFetchOptions(e.uri,{headers:{accept:"text/turtle"}}))).responseText;(0,i.parse)(n,t,e.uri,"text/turtle")}}catch(t){return console.error("Error loading pod "+e+": "+t),null}if(!t.holds(e,a.ns.rdf("type"),a.ns.space("Storage"),e))return console.warn("Pod "+e+" does not declare itself as a space:Storage"),null;const n=t.any(e,a.ns.solid("owner"),null,e)||t.any(null,a.ns.space("storage"),e,e);if(n){try{await t.fetcher.load(n.doc())}catch(e){return console.warn("Unable to load profile of pod owner "+n),null}return t.holds(n,a.ns.space("storage"),e,n.doc())||console.warn(`Pod owner ${n} does NOT list pod ${e} as their storage`),n}{const n=(0,i.sym)(`${e.uri}profile/card#me`);try{await t.fetcher.load(n)}catch(e){return console.error("Ooops. Guessed wrong pod owner webid {$guess} : can't load it."),null}return t.holds(n,a.ns.space("storage"),e,n.doc())?(console.warn("Using guessed pod owner webid but it links back."),n):null}}function r(e,t){return e.anyValue(t,a.ns.vcard("fn"),null,t.doc())||e.anyValue(t,a.ns.foaf("name"),null,t.doc())||t.uri}function c(e,t,n={}){let i,a,o,s=null,r=0;const c=function(){r=n.leading?Date.now():0,s=null,o=e.apply(i,a),s||(i=a=null)};return function(){const l=Date.now();r||n.leading||(r=l);const p=t-(l-r);return i=this,a=arguments,p<=0||p>t?(s&&(clearTimeout(s),s=null),r=l,o=e.apply(i,a),s||(i=a=null)):s||!1===n.trailing||(s=setTimeout(c,p)),o}}},580(e){"use strict";
22
22
  /*!
23
23
  * escape-html
24
24
  * Copyright(c) 2012-2013 TJ Holowaychuk