solid-ui 2.4.23 → 2.4.24

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 (136) hide show
  1. package/dist/main.js +2159 -5039
  2. package/dist/main.js.map +1 -1
  3. package/lib/acl/access-controller.js +4 -67
  4. package/lib/acl/access-controller.js.map +1 -1
  5. package/lib/acl/access-groups.js +59 -137
  6. package/lib/acl/access-groups.js.map +1 -1
  7. package/lib/acl/acl-control.js +14 -54
  8. package/lib/acl/acl-control.js.map +1 -1
  9. package/lib/acl/acl.js +32 -107
  10. package/lib/acl/acl.js.map +1 -1
  11. package/lib/acl/add-agent-buttons.js +0 -92
  12. package/lib/acl/add-agent-buttons.js.map +1 -1
  13. package/lib/acl/index.js +1 -3
  14. package/lib/acl/index.js.map +1 -1
  15. package/lib/acl/styles.js +1 -2
  16. package/lib/acl/styles.js.map +1 -1
  17. package/lib/chat/bookmarks.js +8 -80
  18. package/lib/chat/bookmarks.js.map +1 -1
  19. package/lib/chat/chatLogic.js +109 -180
  20. package/lib/chat/chatLogic.js.map +1 -1
  21. package/lib/chat/dateFolder.js +6 -91
  22. package/lib/chat/dateFolder.js.map +1 -1
  23. package/lib/chat/infinite.js +33 -185
  24. package/lib/chat/infinite.js.map +1 -1
  25. package/lib/chat/message.js +37 -150
  26. package/lib/chat/message.js.map +1 -1
  27. package/lib/chat/messageTools.js +23 -96
  28. package/lib/chat/messageTools.js.map +1 -1
  29. package/lib/chat/thread.js +33 -91
  30. package/lib/chat/thread.js.map +1 -1
  31. package/lib/create/create.js +19 -51
  32. package/lib/create/create.js.map +1 -1
  33. package/lib/create/index.js +0 -2
  34. package/lib/create/index.js.map +1 -1
  35. package/lib/debug.js +0 -8
  36. package/lib/debug.js.map +1 -1
  37. package/lib/folders.js +4 -27
  38. package/lib/folders.js.map +1 -1
  39. package/lib/footer/index.js +2 -24
  40. package/lib/footer/index.js.map +1 -1
  41. package/lib/footer/styleMap.js.map +1 -1
  42. package/lib/header/empty-profile.js.map +1 -1
  43. package/lib/header/index.js +3 -72
  44. package/lib/header/index.js.map +1 -1
  45. package/lib/header/styleMap.js +4 -3
  46. package/lib/header/styleMap.js.map +1 -1
  47. package/lib/iconBase.js +3 -4
  48. package/lib/iconBase.js.map +1 -1
  49. package/lib/index.js +5 -46
  50. package/lib/index.js.map +1 -1
  51. package/lib/jss/index.js +3 -9
  52. package/lib/jss/index.js.map +1 -1
  53. package/lib/log.js +15 -51
  54. package/lib/log.js.map +1 -1
  55. package/lib/login/login.js +74 -303
  56. package/lib/login/login.js.map +1 -1
  57. package/lib/matrix/index.js +0 -2
  58. package/lib/matrix/index.js.map +1 -1
  59. package/lib/matrix/matrix.js +7 -55
  60. package/lib/matrix/matrix.js.map +1 -1
  61. package/lib/media/index.js +0 -2
  62. package/lib/media/index.js.map +1 -1
  63. package/lib/media/media-capture.js +13 -33
  64. package/lib/media/media-capture.js.map +1 -1
  65. package/lib/messageArea.js +23 -64
  66. package/lib/messageArea.js.map +1 -1
  67. package/lib/noun_Camera_1618446_000000.js.map +1 -1
  68. package/lib/ns.js +5 -7
  69. package/lib/ns.js.map +1 -1
  70. package/lib/pad.js +48 -234
  71. package/lib/pad.js.map +1 -1
  72. package/lib/participation.js +10 -65
  73. package/lib/participation.js.map +1 -1
  74. package/lib/preferences.js +21 -42
  75. package/lib/preferences.js.map +1 -1
  76. package/lib/signup/config-default.js +1 -8
  77. package/lib/signup/config-default.js.map +1 -1
  78. package/lib/signup/signup.js +6 -13
  79. package/lib/signup/signup.js.map +1 -1
  80. package/lib/stories/decorators.js +0 -2
  81. package/lib/stories/decorators.js.map +1 -1
  82. package/lib/style.js +8 -5
  83. package/lib/style.js.map +1 -1
  84. package/lib/style_multiSelect.js +1 -5
  85. package/lib/style_multiSelect.js.map +1 -1
  86. package/lib/table.js +309 -322
  87. package/lib/table.js.map +1 -1
  88. package/lib/tabs.js +20 -100
  89. package/lib/tabs.js.map +1 -1
  90. package/lib/utils/headerFooterHelpers.js +4 -52
  91. package/lib/utils/headerFooterHelpers.js.map +1 -1
  92. package/lib/utils/index.js +41 -135
  93. package/lib/utils/index.js.map +1 -1
  94. package/lib/utils/label.js +13 -34
  95. package/lib/utils/label.js.map +1 -1
  96. package/lib/versionInfo.js +4 -4
  97. package/lib/versionInfo.js.map +1 -1
  98. package/lib/widgets/buttons/iconLinks.js +0 -8
  99. package/lib/widgets/buttons/iconLinks.js.map +1 -1
  100. package/lib/widgets/buttons.js +115 -291
  101. package/lib/widgets/buttons.js.map +1 -1
  102. package/lib/widgets/dragAndDrop.js +12 -41
  103. package/lib/widgets/dragAndDrop.js.map +1 -1
  104. package/lib/widgets/error.js +3 -9
  105. package/lib/widgets/error.js.map +1 -1
  106. package/lib/widgets/forms/autocomplete/autocompleteBar.js +8 -71
  107. package/lib/widgets/forms/autocomplete/autocompleteBar.js.map +1 -1
  108. package/lib/widgets/forms/autocomplete/autocompleteField.js +13 -65
  109. package/lib/widgets/forms/autocomplete/autocompleteField.js.map +1 -1
  110. package/lib/widgets/forms/autocomplete/autocompletePicker.js +15 -107
  111. package/lib/widgets/forms/autocomplete/autocompletePicker.js.map +1 -1
  112. package/lib/widgets/forms/autocomplete/language.js +6 -55
  113. package/lib/widgets/forms/autocomplete/language.js.map +1 -1
  114. package/lib/widgets/forms/autocomplete/publicData.js +12 -131
  115. package/lib/widgets/forms/autocomplete/publicData.js.map +1 -1
  116. package/lib/widgets/forms/basic.js +12 -55
  117. package/lib/widgets/forms/basic.js.map +1 -1
  118. package/lib/widgets/forms/comment.js +1 -15
  119. package/lib/widgets/forms/comment.js.map +1 -1
  120. package/lib/widgets/forms/fieldFunction.js +3 -16
  121. package/lib/widgets/forms/fieldFunction.js.map +1 -1
  122. package/lib/widgets/forms/fieldParams.js +0 -12
  123. package/lib/widgets/forms/fieldParams.js.map +1 -1
  124. package/lib/widgets/forms/formStyle.js +1 -14
  125. package/lib/widgets/forms/formStyle.js.map +1 -1
  126. package/lib/widgets/forms.js +70 -474
  127. package/lib/widgets/forms.js.map +1 -1
  128. package/lib/widgets/index.js +0 -21
  129. package/lib/widgets/index.js.map +1 -1
  130. package/lib/widgets/multiSelect.js +48 -171
  131. package/lib/widgets/multiSelect.js.map +1 -1
  132. package/lib/widgets/peoplePicker.js +20 -90
  133. package/lib/widgets/peoplePicker.js.map +1 -1
  134. package/lib/widgets/widgetHelpers.js +2 -9
  135. package/lib/widgets/widgetHelpers.js.map +1 -1
  136. package/package.json +28 -28
@@ -1,22 +1,16 @@
1
1
  "use strict";
2
2
 
3
3
  var _typeof = require("@babel/runtime/helpers/typeof");
4
-
5
4
  Object.defineProperty(exports, "__esModule", {
6
5
  value: true
7
6
  });
8
7
  exports.makeDraggable = makeDraggable;
9
8
  exports.makeDropTarget = makeDropTarget;
10
9
  exports.uploadFiles = uploadFiles;
11
-
12
10
  var debug = _interopRequireWildcard(require("../debug"));
13
-
14
11
  var mime = _interopRequireWildcard(require("mime-types"));
15
-
16
12
  function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
17
-
18
13
  function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
19
-
20
14
  /* Drag and drop common functionality
21
15
  *
22
16
  * It is easy to make something draggable, or to make it a drag target!
@@ -29,16 +23,14 @@ function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj &&
29
23
  */
30
24
 
31
25
  /* global FileReader alert */
26
+
32
27
  function makeDropTarget(ele, droppedURIHandler, droppedFileHandler) {
33
28
  var dragoverListener = function dragoverListener(e) {
34
29
  e.preventDefault(); // Neeed else drop does not work [sic]
35
-
36
30
  e.dataTransfer.dropEffect = 'copy';
37
31
  };
38
-
39
32
  var dragenterListener = function dragenterListener(e) {
40
33
  debug.log('dragenter event dropEffect: ' + e.dataTransfer.dropEffect);
41
-
42
34
  if (this.style) {
43
35
  // necessary not sure when
44
36
  if (!this.savedStyle) {
@@ -47,19 +39,15 @@ function makeDropTarget(ele, droppedURIHandler, droppedFileHandler) {
47
39
  this.savedStyle.backgroundColor = this.style.backgroundColor;
48
40
  this.savedStyle.borderRadius = this.style.borderRadius;
49
41
  }
50
-
51
42
  this.style.backgroundColor = '#ccc';
52
43
  this.style.border = '0.25em dashed black';
53
44
  this.style.borderRadius = '0.3em';
54
45
  }
55
-
56
46
  e.dataTransfer.dropEffect = 'link';
57
47
  debug.log('dragenter event dropEffect 2: ' + e.dataTransfer.dropEffect);
58
48
  };
59
-
60
49
  var dragleaveListener = function dragleaveListener(e) {
61
50
  debug.log('dragleave event dropEffect: ' + e.dataTransfer.dropEffect);
62
-
63
51
  if (this.savedStyle) {
64
52
  this.style.border = this.savedStyle.border;
65
53
  this.style.backgroundColor = this.savedStyle.backgroundColor;
@@ -69,37 +57,29 @@ function makeDropTarget(ele, droppedURIHandler, droppedFileHandler) {
69
57
  this.style.border = '0em solid black';
70
58
  }
71
59
  };
72
-
73
60
  var dropListener = function dropListener(e) {
74
61
  if (e.preventDefault) e.preventDefault(); // stops the browser from redirecting off to the text.
75
-
76
62
  debug.log('Drop event. dropEffect: ' + e.dataTransfer.dropEffect);
77
63
  debug.log('Drop event. types: ' + (e.dataTransfer.types ? e.dataTransfer.types.join(', ') : 'NOPE'));
78
64
  var uris = null;
79
65
  var text;
80
-
81
66
  if (e.dataTransfer.types) {
82
67
  for (var t = 0; t < e.dataTransfer.types.length; t++) {
83
68
  var type = e.dataTransfer.types[t];
84
-
85
69
  if (type === 'text/uri-list') {
86
70
  uris = e.dataTransfer.getData(type).split('\n'); // @ ignore those starting with #
87
-
88
71
  debug.log('Dropped text/uri-list: ' + uris);
89
72
  } else if (type === 'text/plain') {
90
73
  text = e.dataTransfer.getData(type);
91
74
  } else if (type === 'Files' && droppedFileHandler) {
92
75
  var files = e.dataTransfer.files; // FileList object.
93
-
94
76
  for (var i = 0; files[i]; i++) {
95
77
  var f = files[i];
96
78
  debug.log('Filename: ' + f.name + ', type: ' + (f.type || 'n/a') + ' size: ' + f.size + ' bytes, last modified: ' + (f.lastModifiedDate ? f.lastModifiedDate.toLocaleDateString() : 'n/a'));
97
79
  }
98
-
99
80
  droppedFileHandler(files);
100
81
  }
101
82
  }
102
-
103
83
  if (uris === null && text && text.slice(0, 4) === 'http') {
104
84
  uris = text;
105
85
  debug.log("Waring: Poor man's drop: using text for URI"); // chrome disables text/uri-list??
@@ -109,38 +89,30 @@ function makeDropTarget(ele, droppedURIHandler, droppedFileHandler) {
109
89
  uris = [e.dataTransfer.getData('Text')];
110
90
  debug.log('WARNING non-standard drop event: ' + uris[0]);
111
91
  }
112
-
113
92
  debug.log('Dropped URI list (2): ' + uris);
114
-
115
93
  if (uris) {
116
94
  droppedURIHandler(uris);
117
95
  }
118
-
119
96
  this.style.backgroundColor = 'white'; // restore style
120
-
121
97
  return false;
122
98
  }; // dropListener
123
99
 
124
-
125
100
  var addTargetListeners = function addTargetListeners(ele) {
126
101
  if (!ele) {
127
102
  debug.log('@@@ addTargetListeners: ele ' + ele);
128
103
  }
129
-
130
104
  ele.addEventListener('dragover', dragoverListener);
131
105
  ele.addEventListener('dragenter', dragenterListener);
132
106
  ele.addEventListener('dragleave', dragleaveListener);
133
107
  ele.addEventListener('drop', dropListener);
134
108
  };
135
-
136
109
  addTargetListeners(ele, droppedURIHandler);
137
110
  } // listen for dropped URIs
111
+
138
112
  // Make an HTML element draggable as a URI-identified thing
139
113
  //
140
114
  // Possibly later set the drag image too?
141
115
  //
142
-
143
-
144
116
  function makeDraggable(tr, obj) {
145
117
  tr.setAttribute('draggable', 'true'); // Stop the image being dragged instead - just the TR
146
118
 
@@ -153,7 +125,8 @@ function makeDraggable(tr, obj) {
153
125
  }, false);
154
126
  tr.addEventListener('drag', function (e) {
155
127
  e.preventDefault();
156
- e.stopPropagation(); // debug.log('Drag: dropEffect: ' + e.dataTransfer.dropEffect)
128
+ e.stopPropagation();
129
+ // debug.log('Drag: dropEffect: ' + e.dataTransfer.dropEffect)
157
130
  }, false);
158
131
  tr.addEventListener('dragend', function (e) {
159
132
  tr.style.fontWeight = 'normal';
@@ -161,6 +134,7 @@ function makeDraggable(tr, obj) {
161
134
  debug.log('Dragend: ' + tr + ' -> ' + obj);
162
135
  }, false);
163
136
  }
137
+
164
138
  /** uploadFiles
165
139
  **
166
140
  ** Generic uploader of local files to the web
@@ -174,26 +148,22 @@ function makeDraggable(tr, obj) {
174
148
  ** With file object an final URI as params
175
149
  */
176
150
 
177
-
178
151
  function uploadFiles(fetcher, files, fileBase, imageBase, successHandler) {
179
152
  for (var i = 0; files[i]; i++) {
180
153
  var f = files[i];
181
154
  debug.log(' dropped: Filename: ' + f.name + ', type: ' + (f.type || 'n/a') + ' size: ' + f.size + ' bytes, last modified: ' + (f.lastModifiedDate ? f.lastModifiedDate.toLocaleDateString() : 'n/a')); // See e.g. https://www.html5rocks.com/en/tutorials/file/dndfiles/
182
- // @@ Add: progress bar(s)
183
155
 
156
+ // @@ Add: progress bar(s)
184
157
  var reader = new FileReader();
185
-
186
158
  reader.onload = function (theFile) {
187
159
  return function (e) {
188
160
  var data = e.target.result;
189
161
  var suffix = '';
190
162
  debug.log(' File read byteLength : ' + data.byteLength);
191
163
  var contentType = theFile.type;
192
-
193
164
  if (!theFile.type || theFile.type === '') {
194
165
  // Not known by browser
195
166
  contentType = mime.lookup(theFile.name);
196
-
197
167
  if (!contentType) {
198
168
  var msg = 'Filename needs to have an extension which gives a type we know: ' + theFile.name;
199
169
  debug.log(msg);
@@ -201,12 +171,14 @@ function uploadFiles(fetcher, files, fileBase, imageBase, successHandler) {
201
171
  throw new Error(msg);
202
172
  }
203
173
  } else {
204
- var extension = mime.extension(theFile.type); // Note not simple: eg .mp3 => audio/mpeg; .mpga => audio/mpeg; audio/mp3 => .mp3
205
-
206
- if (extension && extension !== 'false' && !theFile.name.endsWith('.' + extension) && // Not already has preferred extension? and ...
174
+ var extension = mime.extension(theFile.type);
175
+ // Note not simple: eg .mp3 => audio/mpeg; .mpga => audio/mpeg; audio/mp3 => .mp3
176
+ if (extension && extension !== 'false' && !theFile.name.endsWith('.' + extension) &&
177
+ // Not already has preferred extension? and ...
207
178
  theFile.type !== mime.lookup(theFile.name)) {
208
179
  // the mime type of this ext is not the right one?
209
- suffix = '_.' + extension; // console.log('MIME TYPE MISMATCH: ' + mime.lookup(theFile.name) + ': adding extension: ' + suffix)
180
+ suffix = '_.' + extension;
181
+ // console.log('MIME TYPE MISMATCH: ' + mime.lookup(theFile.name) + ': adding extension: ' + suffix)
210
182
  }
211
183
  }
212
184
 
@@ -226,7 +198,6 @@ function uploadFiles(fetcher, files, fileBase, imageBase, successHandler) {
226
198
  });
227
199
  };
228
200
  }(f);
229
-
230
201
  reader.readAsArrayBuffer(f);
231
202
  }
232
203
  }
@@ -1 +1 @@
1
- {"version":3,"file":"dragAndDrop.js","names":["makeDropTarget","ele","droppedURIHandler","droppedFileHandler","dragoverListener","e","preventDefault","dataTransfer","dropEffect","dragenterListener","debug","log","style","savedStyle","border","backgroundColor","borderRadius","dragleaveListener","dropListener","types","join","uris","text","t","length","type","getData","split","files","i","f","name","size","lastModifiedDate","toLocaleDateString","slice","addTargetListeners","addEventListener","makeDraggable","tr","obj","setAttribute","fontWeight","setData","uri","outerHTML","stopPropagation","uploadFiles","fetcher","fileBase","imageBase","successHandler","reader","FileReader","onload","theFile","data","target","result","suffix","byteLength","contentType","mime","lookup","msg","alert","Error","extension","endsWith","folderName","startsWith","destURI","encodeURIComponent","webOperation","then","_response","error","readAsArrayBuffer"],"sources":["../../src/widgets/dragAndDrop.js"],"sourcesContent":["/* Drag and drop common functionality\n *\n * It is easy to make something draggable, or to make it a drag target!\n * Just call the functions below. In a solid world, any part of the UI which\n * represent one thing which has a UR, should be made draggable using makeDraggable\n * Any list of things should typically allow you to drag new members of the list\n * onto it.\n * The file upload function uploadFiles is provided as often of someone drags a file from the computer\n * desktop, you may want to upload it into the pod.\n */\nimport * as debug from '../debug'\nimport * as mime from 'mime-types'\n\n/* global FileReader alert */\n\nexport function makeDropTarget (ele, droppedURIHandler, droppedFileHandler) {\n const dragoverListener = function (e) {\n e.preventDefault() // Neeed else drop does not work [sic]\n e.dataTransfer.dropEffect = 'copy'\n }\n\n const dragenterListener = function (e) {\n debug.log('dragenter event dropEffect: ' + e.dataTransfer.dropEffect)\n if (this.style) {\n // necessary not sure when\n if (!this.savedStyle) {\n this.savedStyle = {}\n this.savedStyle.border = this.style.border\n this.savedStyle.backgroundColor = this.style.backgroundColor\n this.savedStyle.borderRadius = this.style.borderRadius\n }\n this.style.backgroundColor = '#ccc'\n this.style.border = '0.25em dashed black'\n this.style.borderRadius = '0.3em'\n }\n\n e.dataTransfer.dropEffect = 'link'\n debug.log('dragenter event dropEffect 2: ' + e.dataTransfer.dropEffect)\n }\n const dragleaveListener = function (e) {\n debug.log('dragleave event dropEffect: ' + e.dataTransfer.dropEffect)\n if (this.savedStyle) {\n this.style.border = this.savedStyle.border\n this.style.backgroundColor = this.savedStyle.backgroundColor\n this.style.borderRadius = this.savedStyle.borderRadius\n } else {\n this.style.backgroundColor = 'white'\n this.style.border = '0em solid black'\n }\n }\n\n const dropListener = function (e) {\n if (e.preventDefault) e.preventDefault() // stops the browser from redirecting off to the text.\n debug.log('Drop event. dropEffect: ' + e.dataTransfer.dropEffect)\n debug.log(\n 'Drop event. types: ' +\n (e.dataTransfer.types ? e.dataTransfer.types.join(', ') : 'NOPE')\n )\n\n let uris = null\n let text\n if (e.dataTransfer.types) {\n for (let t = 0; t < e.dataTransfer.types.length; t++) {\n const type = e.dataTransfer.types[t]\n if (type === 'text/uri-list') {\n uris = e.dataTransfer.getData(type).split('\\n') // @ ignore those starting with #\n debug.log('Dropped text/uri-list: ' + uris)\n } else if (type === 'text/plain') {\n text = e.dataTransfer.getData(type)\n } else if (type === 'Files' && droppedFileHandler) {\n const files = e.dataTransfer.files // FileList object.\n for (let i = 0; files[i]; i++) {\n const f = files[i]\n debug.log(\n 'Filename: ' +\n f.name +\n ', type: ' +\n (f.type || 'n/a') +\n ' size: ' +\n f.size +\n ' bytes, last modified: ' +\n (f.lastModifiedDate\n ? f.lastModifiedDate.toLocaleDateString()\n : 'n/a')\n )\n }\n droppedFileHandler(files)\n }\n }\n if (uris === null && text && text.slice(0, 4) === 'http') {\n uris = text\n debug.log(\"Waring: Poor man's drop: using text for URI\") // chrome disables text/uri-list??\n }\n } else {\n // ... however, if we're IE, we don't have the .types property, so we'll just get the Text value\n uris = [e.dataTransfer.getData('Text')]\n debug.log('WARNING non-standard drop event: ' + uris[0])\n }\n debug.log('Dropped URI list (2): ' + uris)\n if (uris) {\n droppedURIHandler(uris)\n }\n this.style.backgroundColor = 'white' // restore style\n return false\n } // dropListener\n\n const addTargetListeners = function (ele) {\n if (!ele) {\n debug.log('@@@ addTargetListeners: ele ' + ele)\n }\n ele.addEventListener('dragover', dragoverListener)\n ele.addEventListener('dragenter', dragenterListener)\n ele.addEventListener('dragleave', dragleaveListener)\n ele.addEventListener('drop', dropListener)\n }\n addTargetListeners(ele, droppedURIHandler)\n} // listen for dropped URIs\n\n// Make an HTML element draggable as a URI-identified thing\n//\n// Possibly later set the drag image too?\n//\nexport function makeDraggable (tr, obj) {\n tr.setAttribute('draggable', 'true') // Stop the image being dragged instead - just the TR\n\n tr.addEventListener(\n 'dragstart',\n function (e) {\n tr.style.fontWeight = 'bold'\n e.dataTransfer.setData('text/uri-list', obj.uri)\n e.dataTransfer.setData('text/plain', obj.uri)\n e.dataTransfer.setData('text/html', tr.outerHTML)\n debug.log(\n 'Dragstart: ' + tr + ' -> ' + obj + 'de: ' + e.dataTransfer.dropEffect\n )\n },\n false\n )\n\n tr.addEventListener(\n 'drag',\n function (e) {\n e.preventDefault()\n e.stopPropagation()\n // debug.log('Drag: dropEffect: ' + e.dataTransfer.dropEffect)\n },\n false\n )\n\n tr.addEventListener(\n 'dragend',\n function (e) {\n tr.style.fontWeight = 'normal'\n debug.log('Dragend dropeffect: ' + e.dataTransfer.dropEffect)\n debug.log('Dragend: ' + tr + ' -> ' + obj)\n },\n false\n )\n}\n\n/** uploadFiles\n**\n** Generic uploader of local files to the web\n** typically called from dropped file handler\n**\n** @param {Fetcher} fetcher instance of class Fetcher as in kb.fetcher\n** @param {Array<File>} files Array of file objects\n** @param {String} fileBase URI of folder in which to put files (except images) (no trailing slash)\n** @param {String } imageBase URI of folder in which to put images\n** @param successHandler function(file, uploadedURI) Called after EACH success upload\n** With file object an final URI as params\n*/\n\nexport function uploadFiles (fetcher, files, fileBase, imageBase, successHandler) {\n for (let i = 0; files[i]; i++) {\n const f = files[i]\n debug.log(\n ' dropped: Filename: ' +\n f.name +\n ', type: ' +\n (f.type || 'n/a') +\n ' size: ' +\n f.size +\n ' bytes, last modified: ' +\n (f.lastModifiedDate ? f.lastModifiedDate.toLocaleDateString() : 'n/a')\n ) // See e.g. https://www.html5rocks.com/en/tutorials/file/dndfiles/\n\n // @@ Add: progress bar(s)\n const reader = new FileReader()\n reader.onload = (function (theFile) {\n return function (e) {\n const data = e.target.result\n let suffix = ''\n debug.log(' File read byteLength : ' + data.byteLength)\n let contentType = theFile.type\n if (!theFile.type || theFile.type === '') {\n // Not known by browser\n contentType = mime.lookup(theFile.name)\n if (!contentType) {\n const msg =\n 'Filename needs to have an extension which gives a type we know: ' +\n theFile.name\n debug.log(msg)\n alert(msg)\n throw new Error(msg)\n }\n } else {\n const extension = mime.extension(theFile.type)\n // Note not simple: eg .mp3 => audio/mpeg; .mpga => audio/mpeg; audio/mp3 => .mp3\n if (extension && extension !== 'false' && !theFile.name.endsWith('.' + extension) && // Not already has preferred extension? and ...\n theFile.type !== mime.lookup(theFile.name)) { // the mime type of this ext is not the right one?\n suffix = '_.' + extension\n // console.log('MIME TYPE MISMATCH: ' + mime.lookup(theFile.name) + ': adding extension: ' + suffix)\n }\n }\n const folderName = theFile.type.startsWith('image/')\n ? imageBase || fileBase\n : fileBase\n const destURI =\n folderName +\n (folderName.endsWith('/') ? '' : '/') +\n encodeURIComponent(theFile.name) +\n suffix\n\n fetcher\n .webOperation('PUT', destURI, {\n data,\n contentType\n })\n .then(\n _response => {\n debug.log(' Upload: put OK: ' + destURI)\n successHandler(theFile, destURI)\n },\n error => {\n const msg = ' Upload: FAIL ' + destURI + ', Error: ' + error\n debug.log(msg)\n alert(msg)\n throw new Error(msg)\n }\n )\n }\n })(f)\n reader.readAsArrayBuffer(f)\n }\n}\n"],"mappings":";;;;;;;;;;;AAUA;;AACA;;;;;;AAXA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAIA;AAEO,SAASA,cAAT,CAAyBC,GAAzB,EAA8BC,iBAA9B,EAAiDC,kBAAjD,EAAqE;EAC1E,IAAMC,gBAAgB,GAAG,SAAnBA,gBAAmB,CAAUC,CAAV,EAAa;IACpCA,CAAC,CAACC,cAAF,GADoC,CACjB;;IACnBD,CAAC,CAACE,YAAF,CAAeC,UAAf,GAA4B,MAA5B;EACD,CAHD;;EAKA,IAAMC,iBAAiB,GAAG,SAApBA,iBAAoB,CAAUJ,CAAV,EAAa;IACrCK,KAAK,CAACC,GAAN,CAAU,iCAAiCN,CAAC,CAACE,YAAF,CAAeC,UAA1D;;IACA,IAAI,KAAKI,KAAT,EAAgB;MACd;MACA,IAAI,CAAC,KAAKC,UA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file":"dragAndDrop.js","names":["makeDropTarget","ele","droppedURIHandler","droppedFileHandler","dragoverListener","e","preventDefault","dataTransfer","dropEffect","dragenterListener","debug","log","style","savedStyle","border","backgroundColor","borderRadius","dragleaveListener","dropListener","types","join","uris","text","t","length","type","getData","split","files","i","f","name","size","lastModifiedDate","toLocaleDateString","slice","addTargetListeners","addEventListener","makeDraggable","tr","obj","setAttribute","fontWeight","setData","uri","outerHTML","stopPropagation","uploadFiles","fetcher","fileBase","imageBase","successHandler","reader","FileReader","onload","theFile","data","target","result","suffix","byteLength","contentType","mime","lookup","msg","alert","Error","extension","endsWith","folderName","startsWith","destURI","encodeURIComponent","webOperation","then","_response","error","readAsArrayBuffer"],"sources":["../../src/widgets/dragAndDrop.js"],"sourcesContent":["/* Drag and drop common functionality\n *\n * It is easy to make something draggable, or to make it a drag target!\n * Just call the functions below. In a solid world, any part of the UI which\n * represent one thing which has a UR, should be made draggable using makeDraggable\n * Any list of things should typically allow you to drag new members of the list\n * onto it.\n * The file upload function uploadFiles is provided as often of someone drags a file from the computer\n * desktop, you may want to upload it into the pod.\n */\nimport * as debug from '../debug'\nimport * as mime from 'mime-types'\n\n/* global FileReader alert */\n\nexport function makeDropTarget (ele, droppedURIHandler, droppedFileHandler) {\n const dragoverListener = function (e) {\n e.preventDefault() // Neeed else drop does not work [sic]\n e.dataTransfer.dropEffect = 'copy'\n }\n\n const dragenterListener = function (e) {\n debug.log('dragenter event dropEffect: ' + e.dataTransfer.dropEffect)\n if (this.style) {\n // necessary not sure when\n if (!this.savedStyle) {\n this.savedStyle = {}\n this.savedStyle.border = this.style.border\n this.savedStyle.backgroundColor = this.style.backgroundColor\n this.savedStyle.borderRadius = this.style.borderRadius\n }\n this.style.backgroundColor = '#ccc'\n this.style.border = '0.25em dashed black'\n this.style.borderRadius = '0.3em'\n }\n\n e.dataTransfer.dropEffect = 'link'\n debug.log('dragenter event dropEffect 2: ' + e.dataTransfer.dropEffect)\n }\n const dragleaveListener = function (e) {\n debug.log('dragleave event dropEffect: ' + e.dataTransfer.dropEffect)\n if (this.savedStyle) {\n this.style.border = this.savedStyle.border\n this.style.backgroundColor = this.savedStyle.backgroundColor\n this.style.borderRadius = this.savedStyle.borderRadius\n } else {\n this.style.backgroundColor = 'white'\n this.style.border = '0em solid black'\n }\n }\n\n const dropListener = function (e) {\n if (e.preventDefault) e.preventDefault() // stops the browser from redirecting off to the text.\n debug.log('Drop event. dropEffect: ' + e.dataTransfer.dropEffect)\n debug.log(\n 'Drop event. types: ' +\n (e.dataTransfer.types ? e.dataTransfer.types.join(', ') : 'NOPE')\n )\n\n let uris = null\n let text\n if (e.dataTransfer.types) {\n for (let t = 0; t < e.dataTransfer.types.length; t++) {\n const type = e.dataTransfer.types[t]\n if (type === 'text/uri-list') {\n uris = e.dataTransfer.getData(type).split('\\n') // @ ignore those starting with #\n debug.log('Dropped text/uri-list: ' + uris)\n } else if (type === 'text/plain') {\n text = e.dataTransfer.getData(type)\n } else if (type === 'Files' && droppedFileHandler) {\n const files = e.dataTransfer.files // FileList object.\n for (let i = 0; files[i]; i++) {\n const f = files[i]\n debug.log(\n 'Filename: ' +\n f.name +\n ', type: ' +\n (f.type || 'n/a') +\n ' size: ' +\n f.size +\n ' bytes, last modified: ' +\n (f.lastModifiedDate\n ? f.lastModifiedDate.toLocaleDateString()\n : 'n/a')\n )\n }\n droppedFileHandler(files)\n }\n }\n if (uris === null && text && text.slice(0, 4) === 'http') {\n uris = text\n debug.log(\"Waring: Poor man's drop: using text for URI\") // chrome disables text/uri-list??\n }\n } else {\n // ... however, if we're IE, we don't have the .types property, so we'll just get the Text value\n uris = [e.dataTransfer.getData('Text')]\n debug.log('WARNING non-standard drop event: ' + uris[0])\n }\n debug.log('Dropped URI list (2): ' + uris)\n if (uris) {\n droppedURIHandler(uris)\n }\n this.style.backgroundColor = 'white' // restore style\n return false\n } // dropListener\n\n const addTargetListeners = function (ele) {\n if (!ele) {\n debug.log('@@@ addTargetListeners: ele ' + ele)\n }\n ele.addEventListener('dragover', dragoverListener)\n ele.addEventListener('dragenter', dragenterListener)\n ele.addEventListener('dragleave', dragleaveListener)\n ele.addEventListener('drop', dropListener)\n }\n addTargetListeners(ele, droppedURIHandler)\n} // listen for dropped URIs\n\n// Make an HTML element draggable as a URI-identified thing\n//\n// Possibly later set the drag image too?\n//\nexport function makeDraggable (tr, obj) {\n tr.setAttribute('draggable', 'true') // Stop the image being dragged instead - just the TR\n\n tr.addEventListener(\n 'dragstart',\n function (e) {\n tr.style.fontWeight = 'bold'\n e.dataTransfer.setData('text/uri-list', obj.uri)\n e.dataTransfer.setData('text/plain', obj.uri)\n e.dataTransfer.setData('text/html', tr.outerHTML)\n debug.log(\n 'Dragstart: ' + tr + ' -> ' + obj + 'de: ' + e.dataTransfer.dropEffect\n )\n },\n false\n )\n\n tr.addEventListener(\n 'drag',\n function (e) {\n e.preventDefault()\n e.stopPropagation()\n // debug.log('Drag: dropEffect: ' + e.dataTransfer.dropEffect)\n },\n false\n )\n\n tr.addEventListener(\n 'dragend',\n function (e) {\n tr.style.fontWeight = 'normal'\n debug.log('Dragend dropeffect: ' + e.dataTransfer.dropEffect)\n debug.log('Dragend: ' + tr + ' -> ' + obj)\n },\n false\n )\n}\n\n/** uploadFiles\n**\n** Generic uploader of local files to the web\n** typically called from dropped file handler\n**\n** @param {Fetcher} fetcher instance of class Fetcher as in kb.fetcher\n** @param {Array<File>} files Array of file objects\n** @param {String} fileBase URI of folder in which to put files (except images) (no trailing slash)\n** @param {String } imageBase URI of folder in which to put images\n** @param successHandler function(file, uploadedURI) Called after EACH success upload\n** With file object an final URI as params\n*/\n\nexport function uploadFiles (fetcher, files, fileBase, imageBase, successHandler) {\n for (let i = 0; files[i]; i++) {\n const f = files[i]\n debug.log(\n ' dropped: Filename: ' +\n f.name +\n ', type: ' +\n (f.type || 'n/a') +\n ' size: ' +\n f.size +\n ' bytes, last modified: ' +\n (f.lastModifiedDate ? f.lastModifiedDate.toLocaleDateString() : 'n/a')\n ) // See e.g. https://www.html5rocks.com/en/tutorials/file/dndfiles/\n\n // @@ Add: progress bar(s)\n const reader = new FileReader()\n reader.onload = (function (theFile) {\n return function (e) {\n const data = e.target.result\n let suffix = ''\n debug.log(' File read byteLength : ' + data.byteLength)\n let contentType = theFile.type\n if (!theFile.type || theFile.type === '') {\n // Not known by browser\n contentType = mime.lookup(theFile.name)\n if (!contentType) {\n const msg =\n 'Filename needs to have an extension which gives a type we know: ' +\n theFile.name\n debug.log(msg)\n alert(msg)\n throw new Error(msg)\n }\n } else {\n const extension = mime.extension(theFile.type)\n // Note not simple: eg .mp3 => audio/mpeg; .mpga => audio/mpeg; audio/mp3 => .mp3\n if (extension && extension !== 'false' && !theFile.name.endsWith('.' + extension) && // Not already has preferred extension? and ...\n theFile.type !== mime.lookup(theFile.name)) { // the mime type of this ext is not the right one?\n suffix = '_.' + extension\n // console.log('MIME TYPE MISMATCH: ' + mime.lookup(theFile.name) + ': adding extension: ' + suffix)\n }\n }\n const folderName = theFile.type.startsWith('image/')\n ? imageBase || fileBase\n : fileBase\n const destURI =\n folderName +\n (folderName.endsWith('/') ? '' : '/') +\n encodeURIComponent(theFile.name) +\n suffix\n\n fetcher\n .webOperation('PUT', destURI, {\n data,\n contentType\n })\n .then(\n _response => {\n debug.log(' Upload: put OK: ' + destURI)\n successHandler(theFile, destURI)\n },\n error => {\n const msg = ' Upload: FAIL ' + destURI + ', Error: ' + error\n debug.log(msg)\n alert(msg)\n throw new Error(msg)\n }\n )\n }\n })(f)\n reader.readAsArrayBuffer(f)\n }\n}\n"],"mappings":";;;;;;;;;AAUA;AACA;AAAkC;AAAA;AAXlC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAIA;;AAEO,SAASA,cAAc,CAAEC,GAAG,EAAEC,iBAAiB,EAAEC,kBAAkB,EAAE;EAC1E,IAAMC,gBAAgB,GAAG,SAAnBA,gBAAgB,CAAaC,CAAC,EAAE;IACpCA,CAAC,CAACC,cAAc,EAAE,EAAC;IACnBD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4D,OAAO,CAAC;UACxCpB,cAAc,CAACI,OAAO,EAAEgB,OAAO,CAAC;QAClC,CAAC,EACD,UAAAK,KAAK,EAAI;UACP,IAAMZ,GAAG,GAAG,gBAAgB,GAAGO,OAAO,GAAG,WAAW,GAAGK,KAAK;UAC5DlE,KAAK,CAACC,GAAG,CAACqD,GAAG,CAAC;UACdC,KAAK,CAACD,GAAG,CAAC;UACV,MAAM,IAAIE,KAAK,CAACF,GAAG,CAAC;QACtB,CAAC,CACF;MACL,CAAC;IACH,CAAC,CAAElC,CAAC,CAAC;IACLsB,MAAM,CAACyB,iBAAiB,CAAC/C,CAAC,CAAC;EAC7B;AACF"}
@@ -4,9 +4,7 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.errorMessageBlock = errorMessageBlock;
7
-
8
7
  var _widgets = require("../widgets");
9
-
10
8
  /**
11
9
  * Create an error message block
12
10
  * @param dom The DOM on which dom.createElement will be called
@@ -19,24 +17,20 @@ var _widgets = require("../widgets");
19
17
  * Meanwhile the stack is dumped to the console for the developer, so you actually know
20
18
  * where it happened!
21
19
  */
22
-
23
20
  /* eslint-disable no-console */
21
+
24
22
  function errorMessageBlock(dom, err, backgroundColor, err2) {
25
23
  var div = dom.createElement('div');
26
- /* tslint:disable-next-line */
27
- // Too complex for TS?
28
- // @ts-ignore
29
24
 
25
+ /* tslint:disable-next-line */ // Too complex for TS?
26
+ // @ts-ignore
30
27
  var errorObject = err2 || err instanceof Error ? err : null;
31
-
32
28
  if (errorObject) {
33
29
  console.error("errorMessageBlock: ".concat(errorObject, " at: ").concat(errorObject.stack || '??'), errorObject); // @@ pick one
34
-
35
30
  div.textContent = errorObject.message;
36
31
  } else {
37
32
  div.textContent = err;
38
33
  }
39
-
40
34
  div.appendChild((0, _widgets.cancelButton)(dom, function () {
41
35
  if (div.parentNode) div.parentNode.removeChild(div);
42
36
  })).style = 'width: 2em; height: 2em; align: right;';
@@ -1 +1 @@
1
- {"version":3,"file":"error.js","names":["errorMessageBlock","dom","err","backgroundColor","err2","div","createElement","errorObject","Error","console","error","stack","textContent","message","appendChild","cancelButton","parentNode","removeChild","style","setAttribute"],"sources":["../../src/widgets/error.ts"],"sourcesContent":["/**\n * Create an error message block\n * @param dom The DOM on which dom.createElement will be called\n * @param err The error message string to display (or an error object)\n * @param backgroundColor Background color. Default: '#fee'\n * @param err2 Is the second param is a string, you can put the original Error in here\n * @returns A div element with the err string\n *\n * This will return a DOM element you can put in the UI as a notice for the user\n * Meanwhile the stack is dumped to the console for the developer, so you actually know\n * where it happened!\n */\n/* eslint-disable no-console */\nimport { cancelButton } from '../widgets'\n\nexport function errorMessageBlock (dom: HTMLDocument, err: string | Error, backgroundColor?: string, err2?: Error): HTMLDivElement {\n const div = dom.createElement('div')\n\n /* tslint:disable-next-line */ // Too complex for TS?\n // @ts-ignore\n const errorObject:Error = err2 || err instanceof Error ? err : null\n\n if (errorObject) {\n console.error(`errorMessageBlock: ${errorObject} at: ${errorObject.stack || '??'}`, errorObject) // @@ pick one\n div.textContent = errorObject.message\n } else {\n div.textContent = err as string\n }\n\n div.appendChild(cancelButton(dom, () => { if (div.parentNode) div.parentNode.removeChild(div) }))\n .style = 'width: 2em; height: 2em; align: right;'\n\n div.setAttribute(\n 'style',\n 'margin: 0.1em; padding: 0.5em; border: 0.05em solid gray; background-color: ' +\n (backgroundColor || '#fee') +\n '; color:black;'\n )\n return div\n}\n"],"mappings":";;;;;;;AAaA;;AAbA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA;AAGO,SAASA,iBAAT,CAA4BC,GAA5B,EAA+CC,GAA/C,EAAoEC,eAApE,EAA8FC,IAA9F,EAA4H;EACjI,IAAMC,GAAG,GAAGJ,GAAG,CAACK,aAAJ,CAAkB,KAAlB,CAAZ;EAEA;EAA+B;EAC/B;;EACA,IAAMC,WAAiB,GAAGH,IAAI,IAAIF,GAAG,YAAYM,KAAvB,GAA+BN,GAA/B,GAAqC,IAA/D;;EAEA,IAAIK,WAAJ,EAAiB;IACfE,OAAO,CAACC,KAAR,8BAAoCH,WAApC,kBAAuDA,WAAW,CAACI,KAAZ,IAAqB,IAA5E,GAAoFJ,WAApF,EADe,CACkF;;IACjGF,GAAG,CAACO,WAAJ,GAAkBL,WAAW,CAACM,OAA9B;EACD,CAHD,MAGO;IACLR,GAAG,CAACO,WAAJ,GAAkBV,GAAlB;EACD;;EAEDG,GAAG,CAACS,WAAJ,CAAgB,IAAAC,qBAAA,EAAad,GAAb,EAAkB,YAAM;IAAE,IAAII,GAAG,CAACW,UAAR,EAAoBX,GAAG,CAACW,UAAJ,CAAeC,WAAf,CAA2BZ,GAA3B;EAAiC,CAA/E,CAAhB,EACGa,KADH,GACW,wCADX;EAGAb,GAAG,CAACc,YAAJ,CACE,OADF,EAEE,kFACGhB,eAAe,IAAI,MADtB,IAEE,gBAJJ;EAMA,OAAOE,GAAP;AACD"}
1
+ {"version":3,"file":"error.js","names":["errorMessageBlock","dom","err","backgroundColor","err2","div","createElement","errorObject","Error","console","error","stack","textContent","message","appendChild","cancelButton","parentNode","removeChild","style","setAttribute"],"sources":["../../src/widgets/error.ts"],"sourcesContent":["/**\n * Create an error message block\n * @param dom The DOM on which dom.createElement will be called\n * @param err The error message string to display (or an error object)\n * @param backgroundColor Background color. Default: '#fee'\n * @param err2 Is the second param is a string, you can put the original Error in here\n * @returns A div element with the err string\n *\n * This will return a DOM element you can put in the UI as a notice for the user\n * Meanwhile the stack is dumped to the console for the developer, so you actually know\n * where it happened!\n */\n/* eslint-disable no-console */\nimport { cancelButton } from '../widgets'\n\nexport function errorMessageBlock (dom: HTMLDocument, err: string | Error, backgroundColor?: string, err2?: Error): HTMLDivElement {\n const div = dom.createElement('div')\n\n /* tslint:disable-next-line */ // Too complex for TS?\n // @ts-ignore\n const errorObject:Error = err2 || err instanceof Error ? err : null\n\n if (errorObject) {\n console.error(`errorMessageBlock: ${errorObject} at: ${errorObject.stack || '??'}`, errorObject) // @@ pick one\n div.textContent = errorObject.message\n } else {\n div.textContent = err as string\n }\n\n div.appendChild(cancelButton(dom, () => { if (div.parentNode) div.parentNode.removeChild(div) }))\n .style = 'width: 2em; height: 2em; align: right;'\n\n div.setAttribute(\n 'style',\n 'margin: 0.1em; padding: 0.5em; border: 0.05em solid gray; background-color: ' +\n (backgroundColor || '#fee') +\n '; color:black;'\n )\n return div\n}\n"],"mappings":";;;;;;AAaA;AAbA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAGO,SAASA,iBAAiB,CAAEC,GAAiB,EAAEC,GAAmB,EAAEC,eAAwB,EAAEC,IAAY,EAAkB;EACjI,IAAMC,GAAG,GAAGJ,GAAG,CAACK,aAAa,CAAC,KAAK,CAAC;;EAEpC,+BAA+B;EAC/B;EACA,IAAMC,WAAiB,GAAGH,IAAI,IAAIF,GAAG,YAAYM,KAAK,GAAGN,GAAG,GAAG,IAAI;EAEnE,IAAIK,WAAW,EAAE;IACfE,OAAO,CAACC,KAAK,8BAAuBH,WAAW,kBAAQA,WAAW,CAACI,KAAK,IAAI,IAAI,GAAIJ,WAAW,CAAC,EAAC;IACjGF,GAAG,CAACO,WAAW,GAAGL,WAAW,CAACM,OAAO;EACvC,CAAC,MAAM;IACLR,GAAG,CAACO,WAAW,GAAGV,GAAa;EACjC;EAEAG,GAAG,CAACS,WAAW,CAAC,IAAAC,qBAAY,EAACd,GAAG,EAAE,YAAM;IAAE,IAAII,GAAG,CAACW,UAAU,EAAEX,GAAG,CAACW,UAAU,CAACC,WAAW,CAACZ,GAAG,CAAC;EAAC,CAAC,CAAC,CAAC,CAC9Fa,KAAK,GAAG,wCAAwC;EAEnDb,GAAG,CAACc,YAAY,CACd,OAAO,EACP,8EAA8E,IAC3EhB,eAAe,IAAI,MAAM,CAAC,GAC3B,gBAAgB,CACnB;EACD,OAAOE,GAAG;AACZ"}