@carbon/ai-chat 0.1.6 → 0.1.7-alpha0

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 (144) hide show
  1. package/dist/cjs/{cds-aichat-internal.js → AppContainer.js} +615 -7203
  2. package/dist/cjs/Carousel.js +24 -16
  3. package/dist/cjs/Chat.js +813 -805
  4. package/dist/cjs/GenesysMessengerServiceDesk.js +60 -52
  5. package/dist/cjs/HumanAgentServiceImpl.js +103 -95
  6. package/dist/cjs/NiceDFOServiceDesk.js +56 -48
  7. package/dist/cjs/PDFViewerContainer.js +58 -149
  8. package/dist/cjs/ReactPlayer.js +2 -2
  9. package/dist/cjs/SFServiceDesk.js +66 -58
  10. package/dist/cjs/ServiceDeskImpl.js +2 -2
  11. package/dist/cjs/Table.js +457 -341
  12. package/dist/cjs/ZendeskServiceDesk.js +36 -28
  13. package/dist/cjs/_node-resolve_empty.js +2 -2
  14. package/dist/cjs/agentActions.js +5 -5
  15. package/dist/cjs/aiChatEntry.js +163 -144
  16. package/dist/cjs/anonymousUserIDStorage.js +8 -8
  17. package/dist/cjs/ar-dz.js +4 -4
  18. package/dist/cjs/ar-kw.js +4 -4
  19. package/dist/cjs/ar-ly.js +4 -4
  20. package/dist/cjs/ar-ma.js +4 -4
  21. package/dist/cjs/ar-sa.js +4 -4
  22. package/dist/cjs/ar-tn.js +4 -4
  23. package/dist/cjs/ar.js +4 -4
  24. package/dist/cjs/ar2.js +2 -2
  25. package/dist/cjs/cds-aichat-container.js +111 -23
  26. package/dist/cjs/cds-aichat-custom-element.js +42 -30
  27. package/dist/cjs/cs.js +4 -4
  28. package/dist/cjs/cs2.js +2 -2
  29. package/dist/cjs/de-at.js +4 -4
  30. package/dist/cjs/de-ch.js +4 -4
  31. package/dist/cjs/de.js +4 -4
  32. package/dist/cjs/de2.js +2 -2
  33. package/dist/cjs/en-au.js +4 -4
  34. package/dist/cjs/en-ca.js +4 -4
  35. package/dist/cjs/en-gb.js +4 -4
  36. package/dist/cjs/en-ie.js +4 -4
  37. package/dist/cjs/en-il.js +4 -4
  38. package/dist/cjs/en-nz.js +4 -4
  39. package/dist/cjs/es-do.js +4 -4
  40. package/dist/cjs/es-us.js +4 -4
  41. package/dist/cjs/es.js +4 -4
  42. package/dist/cjs/es2.js +2 -2
  43. package/dist/cjs/export.js +3 -3
  44. package/dist/cjs/export.legacy.js +3 -3
  45. package/dist/cjs/fontUtils.js +2 -2
  46. package/dist/cjs/fr-ca.js +4 -4
  47. package/dist/cjs/fr-ch.js +4 -4
  48. package/dist/cjs/fr.js +4 -4
  49. package/dist/cjs/fr2.js +2 -2
  50. package/dist/cjs/highlight_js.js +2 -2
  51. package/dist/cjs/it-ch.js +4 -4
  52. package/dist/cjs/it.js +4 -4
  53. package/dist/cjs/it2.js +2 -2
  54. package/dist/cjs/ja.js +4 -4
  55. package/dist/cjs/ja2.js +2 -2
  56. package/dist/cjs/ko.js +4 -4
  57. package/dist/cjs/ko2.js +2 -2
  58. package/dist/cjs/markdown.js +2362 -14
  59. package/dist/cjs/mockServiceDesk.js +42 -34
  60. package/dist/cjs/nl.js +4 -4
  61. package/dist/cjs/nl2.js +2 -2
  62. package/dist/cjs/pt-br.js +4 -4
  63. package/dist/cjs/pt-br2.js +2 -2
  64. package/dist/cjs/pt.js +4 -4
  65. package/dist/cjs/render.js +18 -10
  66. package/dist/cjs/zh-cn.js +4 -4
  67. package/dist/cjs/zh-tw.js +4 -4
  68. package/dist/cjs/zh-tw2.js +2 -2
  69. package/dist/cjs/zh.js +2 -2
  70. package/dist/es/{cds-aichat-internal.js → AppContainer.js} +1117 -7671
  71. package/dist/es/Carousel.js +16 -8
  72. package/dist/es/Chat.js +16 -8
  73. package/dist/es/GenesysMessengerServiceDesk.js +16 -8
  74. package/dist/es/HumanAgentServiceImpl.js +16 -8
  75. package/dist/es/NiceDFOServiceDesk.js +16 -8
  76. package/dist/es/PDFViewerContainer.js +16 -107
  77. package/dist/es/ReactPlayer.js +2 -2
  78. package/dist/es/SFServiceDesk.js +16 -8
  79. package/dist/es/ServiceDeskImpl.js +2 -2
  80. package/dist/es/Table.js +426 -310
  81. package/dist/es/ZendeskServiceDesk.js +16 -8
  82. package/dist/es/_node-resolve_empty.js +2 -2
  83. package/dist/es/agentActions.js +3 -3
  84. package/dist/es/aiChatEntry.js +136 -117
  85. package/dist/es/anonymousUserIDStorage.js +3 -3
  86. package/dist/es/ar-dz.js +3 -3
  87. package/dist/es/ar-kw.js +3 -3
  88. package/dist/es/ar-ly.js +3 -3
  89. package/dist/es/ar-ma.js +3 -3
  90. package/dist/es/ar-sa.js +3 -3
  91. package/dist/es/ar-tn.js +3 -3
  92. package/dist/es/ar.js +3 -3
  93. package/dist/es/ar2.js +2 -2
  94. package/dist/es/cds-aichat-container.js +103 -15
  95. package/dist/es/cds-aichat-custom-element.js +30 -18
  96. package/dist/es/cs.js +3 -3
  97. package/dist/es/cs2.js +2 -2
  98. package/dist/es/de-at.js +3 -3
  99. package/dist/es/de-ch.js +3 -3
  100. package/dist/es/de.js +3 -3
  101. package/dist/es/de2.js +2 -2
  102. package/dist/es/en-au.js +3 -3
  103. package/dist/es/en-ca.js +3 -3
  104. package/dist/es/en-gb.js +3 -3
  105. package/dist/es/en-ie.js +3 -3
  106. package/dist/es/en-il.js +3 -3
  107. package/dist/es/en-nz.js +3 -3
  108. package/dist/es/es-do.js +3 -3
  109. package/dist/es/es-us.js +3 -3
  110. package/dist/es/es.js +3 -3
  111. package/dist/es/es2.js +2 -2
  112. package/dist/es/export.js +3 -3
  113. package/dist/es/export.legacy.js +3 -3
  114. package/dist/es/fontUtils.js +2 -2
  115. package/dist/es/fr-ca.js +3 -3
  116. package/dist/es/fr-ch.js +3 -3
  117. package/dist/es/fr.js +3 -3
  118. package/dist/es/fr2.js +2 -2
  119. package/dist/es/highlight_js.js +2 -2
  120. package/dist/es/it-ch.js +3 -3
  121. package/dist/es/it.js +3 -3
  122. package/dist/es/it2.js +2 -2
  123. package/dist/es/ja.js +3 -3
  124. package/dist/es/ja2.js +2 -2
  125. package/dist/es/ko.js +3 -3
  126. package/dist/es/ko2.js +2 -2
  127. package/dist/es/markdown.js +2361 -15
  128. package/dist/es/mockServiceDesk.js +16 -8
  129. package/dist/es/nl.js +3 -3
  130. package/dist/es/nl2.js +2 -2
  131. package/dist/es/pt-br.js +3 -3
  132. package/dist/es/pt-br2.js +2 -2
  133. package/dist/es/pt.js +3 -3
  134. package/dist/es/render.js +17 -9
  135. package/dist/es/zh-cn.js +3 -3
  136. package/dist/es/zh-tw.js +3 -3
  137. package/dist/es/zh-tw2.js +2 -2
  138. package/dist/es/zh.js +2 -2
  139. package/dist/types/aiChatEntry.d.ts +69 -9
  140. package/package.json +27 -14
  141. package/dist/cjs/jstz.min.js +0 -43
  142. package/dist/cjs/markdown_attrs.js +0 -805
  143. package/dist/es/jstz.min.js +0 -41
  144. package/dist/es/markdown_attrs.js +0 -803
package/dist/cjs/Table.js CHANGED
@@ -13,41 +13,49 @@ is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND
13
13
  or implied. See the License for the specific language governing permissions and limitations under
14
14
  the License.
15
15
 
16
- @carbon/ai-chat 0.1.6
16
+ @carbon/ai-chat 0.1.7-alpha0
17
17
 
18
- Built: Feb 3 2025 9:58 am -05:00
18
+ Built: Feb 12 2025 9:14 am -05:00
19
19
 
20
20
 
21
21
 
22
22
  */
23
23
  'use strict';
24
24
 
25
- var cdsAichatInternal = require('./cds-aichat-internal.js');
25
+ var AppContainer = require('./AppContainer.js');
26
26
  var React = require('react');
27
+ var tslib = require('tslib');
27
28
  var lit = require('lit');
28
29
  var decorators_js = require('lit/decorators.js');
29
30
  require('@carbon/web-components/es/components/data-table/index.js');
30
31
  require('@carbon/web-components/es/components/checkbox/index.js');
31
32
  require('@carbon/web-components/es/components/button/index.js');
33
+ var iconHelpers = require('@carbon/icon-helpers');
34
+ var icons = require('@carbon/icons');
32
35
  var unsafeSvg_js = require('lit/directives/unsafe-svg.js');
33
36
  var repeat_js = require('lit-html/directives/repeat.js');
34
37
  require('@carbon/web-components/es/components/pagination/index.js');
35
38
  require('@carbon/web-components/es/components/select/index.js');
36
39
  require('@carbon/web-components/es/components/data-table/table-skeleton.js');
37
- require('react-dom');
38
40
  require('./highlight_js.js');
39
41
  require('@carbon/react');
42
+ require('classnames');
40
43
  require('react-intl');
41
44
  require('react-redux');
45
+ require('tabbable');
46
+ require('@carbon/icons-react');
42
47
  require('./markdown.js');
43
- require('./markdown_attrs.js');
44
48
  require('@carbon/web-components/es/components/overflow-menu/index.js');
45
49
  require('lit/directives/unsafe-html.js');
50
+ require('prop-types');
46
51
  require('@carbon/web-components/es/components/slug/index.js');
47
52
  require('@carbon/web-components/es/components/popover/defs.js');
48
53
  require('@carbon/web-components/es/components/slug/defs.js');
54
+ require('@floating-ui/react');
55
+ require('react-dom');
49
56
  require('@carbon/web-components/es/components/slug/slug-action-button.js');
50
57
  require('@carbon/web-components/es/components/slug/slug.js');
58
+ require('@carbon/web-components/es/components/inline-loading/index.js');
51
59
  require('@carbon/web-components/es/components/textarea/index.js');
52
60
  require('@carbon/web-components/es/components/icon-button/index.js');
53
61
  require('@carbon/web-components/es/components/tag/index.js');
@@ -55,33 +63,6 @@ require('@carbon/web-components/es/components/chat-button/index.js');
55
63
  require('@carbon/web-components/es/components/button/button.js');
56
64
  require('@carbon/web-components/es/components/layer/index.js');
57
65
 
58
- /**
59
- * Copyright IBM Corp. 2016, 2023
60
- *
61
- * This source code is licensed under the Apache-2.0 license found in the
62
- * LICENSE file in the root directory of this source tree.
63
- *
64
- * Code generated by @carbon/icon-build-helpers. DO NOT EDIT.
65
- */
66
- var _16 = {
67
- "elem": "svg",
68
- "attrs": {
69
- "xmlns": "http://www.w3.org/2000/svg",
70
- "viewBox": "0 0 16 16",
71
- "fill": "currentColor",
72
- "width": 16,
73
- "height": 16
74
- },
75
- "content": [{
76
- "elem": "path",
77
- "attrs": {
78
- "d": "M13 7L12.3 6.3 8.5 10.1 8.5 1 7.5 1 7.5 10.1 3.7 6.3 3 7 8 12zM13 12v2H3v-2H2v2l0 0c0 .6.4 1 1 1h10c.6 0 1-.4 1-1l0 0v-2H13z"
79
- }
80
- }],
81
- "name": "download",
82
- "size": 16
83
- };
84
-
85
66
  var global$1 = (typeof global !== "undefined" ? global :
86
67
  typeof self !== "undefined" ? self :
87
68
  typeof window !== "undefined" ? window : {});
@@ -2056,119 +2037,149 @@ function isSlowBuffer (obj) {
2056
2037
 
2057
2038
  // Lodash implementation of `get`
2058
2039
 
2059
- const charCodeOfDot = '.'.charCodeAt(0);
2040
+ const charCodeOfDot = ".".charCodeAt(0);
2060
2041
  const reEscapeChar = /\\(\\)?/g;
2061
2042
  const rePropName = RegExp(
2062
2043
  // Match anything that isn't a dot or bracket.
2063
- '[^.[\\]]+' + '|' +
2064
- // Or match property names within brackets.
2065
- '\\[(?:' +
2044
+ "[^.[\\]]+" +
2045
+ "|" +
2046
+ // Or match property names within brackets.
2047
+ "\\[(?:" +
2066
2048
  // Match a non-string expression.
2067
- '([^"\'][^[]*)' + '|' +
2049
+ "([^\"'][^[]*)" +
2050
+ "|" +
2068
2051
  // Or match strings (supports escaping characters).
2069
- '(["\'])((?:(?!\\2)[^\\\\]|\\\\.)*?)\\2' +
2070
- ')\\]'+ '|' +
2071
- // Or match "" as the space between consecutive dots or empty brackets.
2072
- '(?=(?:\\.|\\[\\])(?:\\.|\\[\\]|$))'
2073
- , 'g');
2052
+ "([\"'])((?:(?!\\2)[^\\\\]|\\\\.)*?)\\2" +
2053
+ ")\\]" +
2054
+ "|" +
2055
+ // Or match "" as the space between consecutive dots or empty brackets.
2056
+ "(?=(?:\\.|\\[\\])(?:\\.|\\[\\]|$))",
2057
+ "g",
2058
+ );
2074
2059
  const reIsDeepProp = /\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/;
2075
2060
  const reIsPlainProp = /^\w*$/;
2076
- const getTag = function(value){
2061
+
2062
+ const getTag = function (value) {
2077
2063
  return Object.prototype.toString.call(value);
2078
2064
  };
2079
- const isSymbol = function(value){
2065
+
2066
+ const isSymbol = function (value) {
2080
2067
  const type = typeof value;
2081
- return type === 'symbol' || (type === 'object' && value && getTag(value) === '[object Symbol]');
2068
+ return (
2069
+ type === "symbol" ||
2070
+ (type === "object" && value && getTag(value) === "[object Symbol]")
2071
+ );
2082
2072
  };
2083
- const isKey = function(value, object){
2084
- if(Array.isArray(value)){
2073
+
2074
+ const isKey = function (value, object) {
2075
+ if (Array.isArray(value)) {
2085
2076
  return false;
2086
2077
  }
2087
2078
  const type = typeof value;
2088
- if(type === 'number' || type === 'symbol' || type === 'boolean' || !value || isSymbol(value)){
2079
+ if (
2080
+ type === "number" ||
2081
+ type === "symbol" ||
2082
+ type === "boolean" ||
2083
+ !value ||
2084
+ isSymbol(value)
2085
+ ) {
2089
2086
  return true;
2090
2087
  }
2091
- return reIsPlainProp.test(value) || !reIsDeepProp.test(value) ||
2092
- (object != null && value in Object(object));
2088
+ return (
2089
+ reIsPlainProp.test(value) ||
2090
+ !reIsDeepProp.test(value) ||
2091
+ (object != null && value in Object(object))
2092
+ );
2093
2093
  };
2094
- const stringToPath = function(string){
2094
+
2095
+ const stringToPath = function (string) {
2095
2096
  const result = [];
2096
- if(string.charCodeAt(0) === charCodeOfDot){
2097
- result.push('');
2097
+ if (string.charCodeAt(0) === charCodeOfDot) {
2098
+ result.push("");
2098
2099
  }
2099
- string.replace(rePropName, function(match, expression, quote, subString){
2100
+ string.replace(rePropName, function (match, expression, quote, subString) {
2100
2101
  let key = match;
2101
- if(quote){
2102
- key = subString.replace(reEscapeChar, '$1');
2103
- }else if(expression){
2102
+ if (quote) {
2103
+ key = subString.replace(reEscapeChar, "$1");
2104
+ } else if (expression) {
2104
2105
  key = expression.trim();
2105
2106
  }
2106
2107
  result.push(key);
2107
2108
  });
2108
2109
  return result;
2109
2110
  };
2110
- const castPath = function(value, object){
2111
- if(Array.isArray(value)){
2111
+
2112
+ const castPath = function (value, object) {
2113
+ if (Array.isArray(value)) {
2112
2114
  return value;
2113
2115
  } else {
2114
2116
  return isKey(value, object) ? [value] : stringToPath(value);
2115
2117
  }
2116
2118
  };
2117
- const toKey = function(value){
2118
- if(typeof value === 'string' || isSymbol(value))
2119
- return value;
2119
+
2120
+ const toKey = function (value) {
2121
+ if (typeof value === "string" || isSymbol(value)) return value;
2120
2122
  const result = `${value}`;
2121
2123
  // eslint-disable-next-line
2122
- return (result == '0' && (1 / value) == -INFINITY) ? '-0' : result;
2124
+ return result == "0" && 1 / value == -INFINITY ? "-0" : result;
2123
2125
  };
2124
- const get = function(object, path){
2126
+
2127
+ const get = function (object, path) {
2125
2128
  path = castPath(path, object);
2126
2129
  let index = 0;
2127
2130
  const length = path.length;
2128
- while(object != null && index < length){
2131
+ while (object != null && index < length) {
2129
2132
  object = object[toKey(path[index++])];
2130
2133
  }
2131
- return (index && index === length) ? object : undefined;
2134
+ return index && index === length ? object : undefined;
2132
2135
  };
2133
2136
 
2134
- const is_object = function(obj){
2135
- return typeof obj === 'object' && obj !== null && ! Array.isArray(obj);
2137
+ const is_object = function (obj) {
2138
+ return typeof obj === "object" && obj !== null && !Array.isArray(obj);
2136
2139
  };
2137
2140
 
2138
- const normalize_columns = function(columns){
2139
- if(columns === undefined || columns === null){
2141
+ const normalize_columns = function (columns) {
2142
+ if (columns === undefined || columns === null) {
2140
2143
  return [undefined, undefined];
2141
2144
  }
2142
- if(typeof columns !== 'object'){
2145
+ if (typeof columns !== "object") {
2143
2146
  return [Error('Invalid option "columns": expect an array or an object')];
2144
2147
  }
2145
- if(!Array.isArray(columns)){
2148
+ if (!Array.isArray(columns)) {
2146
2149
  const newcolumns = [];
2147
- for(const k in columns){
2150
+ for (const k in columns) {
2148
2151
  newcolumns.push({
2149
2152
  key: k,
2150
- header: columns[k]
2153
+ header: columns[k],
2151
2154
  });
2152
2155
  }
2153
2156
  columns = newcolumns;
2154
- }else {
2157
+ } else {
2155
2158
  const newcolumns = [];
2156
- for(const column of columns){
2157
- if(typeof column === 'string'){
2159
+ for (const column of columns) {
2160
+ if (typeof column === "string") {
2158
2161
  newcolumns.push({
2159
2162
  key: column,
2160
- header: column
2163
+ header: column,
2161
2164
  });
2162
- }else if(typeof column === 'object' && column !== null && !Array.isArray(column)){
2163
- if(!column.key){
2164
- return [Error('Invalid column definition: property "key" is required')];
2165
+ } else if (
2166
+ typeof column === "object" &&
2167
+ column !== null &&
2168
+ !Array.isArray(column)
2169
+ ) {
2170
+ if (!column.key) {
2171
+ return [
2172
+ Error('Invalid column definition: property "key" is required'),
2173
+ ];
2165
2174
  }
2166
- if(column.header === undefined){
2175
+ if (column.header === undefined) {
2167
2176
  column.header = column.key;
2168
2177
  }
2169
2178
  newcolumns.push(column);
2170
- }else {
2171
- return [Error('Invalid column definition: expect a string or an object')];
2179
+ } else {
2180
+ return [
2181
+ Error("Invalid column definition: expect a string or an object"),
2182
+ ];
2172
2183
  }
2173
2184
  }
2174
2185
  columns = newcolumns;
@@ -2178,253 +2189,307 @@ const normalize_columns = function(columns){
2178
2189
 
2179
2190
  class CsvError extends Error {
2180
2191
  constructor(code, message, ...contexts) {
2181
- if(Array.isArray(message)) message = message.join(' ');
2192
+ if (Array.isArray(message)) message = message.join(" ");
2182
2193
  super(message);
2183
- if(Error.captureStackTrace !== undefined){
2194
+ if (Error.captureStackTrace !== undefined) {
2184
2195
  Error.captureStackTrace(this, CsvError);
2185
2196
  }
2186
2197
  this.code = code;
2187
- for(const context of contexts){
2188
- for(const key in context){
2198
+ for (const context of contexts) {
2199
+ for (const key in context) {
2189
2200
  const value = context[key];
2190
- this[key] = isBuffer(value) ? value.toString() : value == null ? value : JSON.parse(JSON.stringify(value));
2201
+ this[key] = isBuffer(value)
2202
+ ? value.toString()
2203
+ : value == null
2204
+ ? value
2205
+ : JSON.parse(JSON.stringify(value));
2191
2206
  }
2192
2207
  }
2193
2208
  }
2194
2209
  }
2195
2210
 
2196
- const underscore = function(str){
2197
- return str.replace(/([A-Z])/g, function(_, match){
2198
- return '_' + match.toLowerCase();
2211
+ const underscore = function (str) {
2212
+ return str.replace(/([A-Z])/g, function (_, match) {
2213
+ return "_" + match.toLowerCase();
2199
2214
  });
2200
2215
  };
2201
2216
 
2202
- const normalize_options = function(opts) {
2217
+ const normalize_options = function (opts) {
2203
2218
  const options = {};
2204
2219
  // Merge with user options
2205
- for(const opt in opts){
2220
+ for (const opt in opts) {
2206
2221
  options[underscore(opt)] = opts[opt];
2207
2222
  }
2208
2223
  // Normalize option `bom`
2209
- if(options.bom === undefined || options.bom === null || options.bom === false){
2224
+ if (
2225
+ options.bom === undefined ||
2226
+ options.bom === null ||
2227
+ options.bom === false
2228
+ ) {
2210
2229
  options.bom = false;
2211
- }else if(options.bom !== true){
2212
- return [new CsvError('CSV_OPTION_BOOLEAN_INVALID_TYPE', [
2213
- 'option `bom` is optional and must be a boolean value,',
2214
- `got ${JSON.stringify(options.bom)}`
2215
- ])];
2230
+ } else if (options.bom !== true) {
2231
+ return [
2232
+ new CsvError("CSV_OPTION_BOOLEAN_INVALID_TYPE", [
2233
+ "option `bom` is optional and must be a boolean value,",
2234
+ `got ${JSON.stringify(options.bom)}`,
2235
+ ]),
2236
+ ];
2216
2237
  }
2217
2238
  // Normalize option `delimiter`
2218
- if(options.delimiter === undefined || options.delimiter === null){
2219
- options.delimiter = ',';
2220
- }else if(isBuffer(options.delimiter)){
2239
+ if (options.delimiter === undefined || options.delimiter === null) {
2240
+ options.delimiter = ",";
2241
+ } else if (isBuffer(options.delimiter)) {
2221
2242
  options.delimiter = options.delimiter.toString();
2222
- }else if(typeof options.delimiter !== 'string'){
2223
- return [new CsvError('CSV_OPTION_DELIMITER_INVALID_TYPE', [
2224
- 'option `delimiter` must be a buffer or a string,',
2225
- `got ${JSON.stringify(options.delimiter)}`
2226
- ])];
2243
+ } else if (typeof options.delimiter !== "string") {
2244
+ return [
2245
+ new CsvError("CSV_OPTION_DELIMITER_INVALID_TYPE", [
2246
+ "option `delimiter` must be a buffer or a string,",
2247
+ `got ${JSON.stringify(options.delimiter)}`,
2248
+ ]),
2249
+ ];
2227
2250
  }
2228
2251
  // Normalize option `quote`
2229
- if(options.quote === undefined || options.quote === null){
2252
+ if (options.quote === undefined || options.quote === null) {
2230
2253
  options.quote = '"';
2231
- }else if(options.quote === true){
2254
+ } else if (options.quote === true) {
2232
2255
  options.quote = '"';
2233
- }else if(options.quote === false){
2234
- options.quote = '';
2235
- }else if (isBuffer(options.quote)){
2256
+ } else if (options.quote === false) {
2257
+ options.quote = "";
2258
+ } else if (isBuffer(options.quote)) {
2236
2259
  options.quote = options.quote.toString();
2237
- }else if(typeof options.quote !== 'string'){
2238
- return [new CsvError('CSV_OPTION_QUOTE_INVALID_TYPE', [
2239
- 'option `quote` must be a boolean, a buffer or a string,',
2240
- `got ${JSON.stringify(options.quote)}`
2241
- ])];
2260
+ } else if (typeof options.quote !== "string") {
2261
+ return [
2262
+ new CsvError("CSV_OPTION_QUOTE_INVALID_TYPE", [
2263
+ "option `quote` must be a boolean, a buffer or a string,",
2264
+ `got ${JSON.stringify(options.quote)}`,
2265
+ ]),
2266
+ ];
2242
2267
  }
2243
2268
  // Normalize option `quoted`
2244
- if(options.quoted === undefined || options.quoted === null){
2269
+ if (options.quoted === undefined || options.quoted === null) {
2245
2270
  options.quoted = false;
2246
2271
  }
2247
2272
  // Normalize option `escape_formulas`
2248
- if(options.escape_formulas === undefined || options.escape_formulas === null){
2273
+ if (
2274
+ options.escape_formulas === undefined ||
2275
+ options.escape_formulas === null
2276
+ ) {
2249
2277
  options.escape_formulas = false;
2250
- }else if(typeof options.escape_formulas !== 'boolean'){
2251
- return [new CsvError('CSV_OPTION_ESCAPE_FORMULAS_INVALID_TYPE', [
2252
- 'option `escape_formulas` must be a boolean,',
2253
- `got ${JSON.stringify(options.escape_formulas)}`
2254
- ])];
2278
+ } else if (typeof options.escape_formulas !== "boolean") {
2279
+ return [
2280
+ new CsvError("CSV_OPTION_ESCAPE_FORMULAS_INVALID_TYPE", [
2281
+ "option `escape_formulas` must be a boolean,",
2282
+ `got ${JSON.stringify(options.escape_formulas)}`,
2283
+ ]),
2284
+ ];
2255
2285
  }
2256
2286
  // Normalize option `quoted_empty`
2257
- if(options.quoted_empty === undefined || options.quoted_empty === null){
2287
+ if (options.quoted_empty === undefined || options.quoted_empty === null) {
2258
2288
  options.quoted_empty = undefined;
2259
2289
  }
2260
2290
  // Normalize option `quoted_match`
2261
- if(options.quoted_match === undefined || options.quoted_match === null || options.quoted_match === false){
2291
+ if (
2292
+ options.quoted_match === undefined ||
2293
+ options.quoted_match === null ||
2294
+ options.quoted_match === false
2295
+ ) {
2262
2296
  options.quoted_match = null;
2263
- }else if(!Array.isArray(options.quoted_match)){
2297
+ } else if (!Array.isArray(options.quoted_match)) {
2264
2298
  options.quoted_match = [options.quoted_match];
2265
2299
  }
2266
- if(options.quoted_match){
2267
- for(const quoted_match of options.quoted_match){
2268
- const isString = typeof quoted_match === 'string';
2300
+ if (options.quoted_match) {
2301
+ for (const quoted_match of options.quoted_match) {
2302
+ const isString = typeof quoted_match === "string";
2269
2303
  const isRegExp = quoted_match instanceof RegExp;
2270
- if(!isString && !isRegExp){
2271
- return [Error(`Invalid Option: quoted_match must be a string or a regex, got ${JSON.stringify(quoted_match)}`)];
2304
+ if (!isString && !isRegExp) {
2305
+ return [
2306
+ Error(
2307
+ `Invalid Option: quoted_match must be a string or a regex, got ${JSON.stringify(quoted_match)}`,
2308
+ ),
2309
+ ];
2272
2310
  }
2273
2311
  }
2274
2312
  }
2275
2313
  // Normalize option `quoted_string`
2276
- if(options.quoted_string === undefined || options.quoted_string === null){
2314
+ if (options.quoted_string === undefined || options.quoted_string === null) {
2277
2315
  options.quoted_string = false;
2278
2316
  }
2279
2317
  // Normalize option `eof`
2280
- if(options.eof === undefined || options.eof === null){
2318
+ if (options.eof === undefined || options.eof === null) {
2281
2319
  options.eof = true;
2282
2320
  }
2283
2321
  // Normalize option `escape`
2284
- if(options.escape === undefined || options.escape === null){
2322
+ if (options.escape === undefined || options.escape === null) {
2285
2323
  options.escape = '"';
2286
- }else if(isBuffer(options.escape)){
2324
+ } else if (isBuffer(options.escape)) {
2287
2325
  options.escape = options.escape.toString();
2288
- }else if(typeof options.escape !== 'string'){
2289
- return [Error(`Invalid Option: escape must be a buffer or a string, got ${JSON.stringify(options.escape)}`)];
2290
- }
2291
- if (options.escape.length > 1){
2292
- return [Error(`Invalid Option: escape must be one character, got ${options.escape.length} characters`)];
2326
+ } else if (typeof options.escape !== "string") {
2327
+ return [
2328
+ Error(
2329
+ `Invalid Option: escape must be a buffer or a string, got ${JSON.stringify(options.escape)}`,
2330
+ ),
2331
+ ];
2332
+ }
2333
+ if (options.escape.length > 1) {
2334
+ return [
2335
+ Error(
2336
+ `Invalid Option: escape must be one character, got ${options.escape.length} characters`,
2337
+ ),
2338
+ ];
2293
2339
  }
2294
2340
  // Normalize option `header`
2295
- if(options.header === undefined || options.header === null){
2341
+ if (options.header === undefined || options.header === null) {
2296
2342
  options.header = false;
2297
2343
  }
2298
2344
  // Normalize option `columns`
2299
2345
  const [errColumns, columns] = normalize_columns(options.columns);
2300
- if(errColumns !== undefined) return [errColumns];
2346
+ if (errColumns !== undefined) return [errColumns];
2301
2347
  options.columns = columns;
2302
2348
  // Normalize option `quoted`
2303
- if(options.quoted === undefined || options.quoted === null){
2349
+ if (options.quoted === undefined || options.quoted === null) {
2304
2350
  options.quoted = false;
2305
2351
  }
2306
2352
  // Normalize option `cast`
2307
- if(options.cast === undefined || options.cast === null){
2353
+ if (options.cast === undefined || options.cast === null) {
2308
2354
  options.cast = {};
2309
2355
  }
2310
2356
  // Normalize option cast.bigint
2311
- if(options.cast.bigint === undefined || options.cast.bigint === null){
2357
+ if (options.cast.bigint === undefined || options.cast.bigint === null) {
2312
2358
  // Cast boolean to string by default
2313
- options.cast.bigint = value => '' + value;
2359
+ options.cast.bigint = (value) => "" + value;
2314
2360
  }
2315
2361
  // Normalize option cast.boolean
2316
- if(options.cast.boolean === undefined || options.cast.boolean === null){
2362
+ if (options.cast.boolean === undefined || options.cast.boolean === null) {
2317
2363
  // Cast boolean to string by default
2318
- options.cast.boolean = value => value ? '1' : '';
2364
+ options.cast.boolean = (value) => (value ? "1" : "");
2319
2365
  }
2320
2366
  // Normalize option cast.date
2321
- if(options.cast.date === undefined || options.cast.date === null){
2367
+ if (options.cast.date === undefined || options.cast.date === null) {
2322
2368
  // Cast date to timestamp string by default
2323
- options.cast.date = value => '' + value.getTime();
2369
+ options.cast.date = (value) => "" + value.getTime();
2324
2370
  }
2325
2371
  // Normalize option cast.number
2326
- if(options.cast.number === undefined || options.cast.number === null){
2372
+ if (options.cast.number === undefined || options.cast.number === null) {
2327
2373
  // Cast number to string using native casting by default
2328
- options.cast.number = value => '' + value;
2374
+ options.cast.number = (value) => "" + value;
2329
2375
  }
2330
2376
  // Normalize option cast.object
2331
- if(options.cast.object === undefined || options.cast.object === null){
2377
+ if (options.cast.object === undefined || options.cast.object === null) {
2332
2378
  // Stringify object as JSON by default
2333
- options.cast.object = value => JSON.stringify(value);
2379
+ options.cast.object = (value) => JSON.stringify(value);
2334
2380
  }
2335
2381
  // Normalize option cast.string
2336
- if(options.cast.string === undefined || options.cast.string === null){
2382
+ if (options.cast.string === undefined || options.cast.string === null) {
2337
2383
  // Leave string untouched
2338
- options.cast.string = function(value){return value;};
2384
+ options.cast.string = function (value) {
2385
+ return value;
2386
+ };
2339
2387
  }
2340
2388
  // Normalize option `on_record`
2341
- if(options.on_record !== undefined && typeof options.on_record !== 'function'){
2389
+ if (
2390
+ options.on_record !== undefined &&
2391
+ typeof options.on_record !== "function"
2392
+ ) {
2342
2393
  return [Error(`Invalid Option: "on_record" must be a function.`)];
2343
2394
  }
2344
2395
  // Normalize option `record_delimiter`
2345
- if(options.record_delimiter === undefined || options.record_delimiter === null){
2346
- options.record_delimiter = '\n';
2347
- }else if(isBuffer(options.record_delimiter)){
2348
- options.record_delimiter = options.record_delimiter.toString();
2349
- }else if(typeof options.record_delimiter !== 'string'){
2350
- return [Error(`Invalid Option: record_delimiter must be a buffer or a string, got ${JSON.stringify(options.record_delimiter)}`)];
2351
- }
2352
- switch(options.record_delimiter){
2353
- case 'unix':
2396
+ if (
2397
+ options.record_delimiter === undefined ||
2398
+ options.record_delimiter === null
2399
+ ) {
2354
2400
  options.record_delimiter = "\n";
2355
- break;
2356
- case 'mac':
2357
- options.record_delimiter = "\r";
2358
- break;
2359
- case 'windows':
2360
- options.record_delimiter = "\r\n";
2361
- break;
2362
- case 'ascii':
2363
- options.record_delimiter = "\u001e";
2364
- break;
2365
- case 'unicode':
2366
- options.record_delimiter = "\u2028";
2367
- break;
2401
+ } else if (isBuffer(options.record_delimiter)) {
2402
+ options.record_delimiter = options.record_delimiter.toString();
2403
+ } else if (typeof options.record_delimiter !== "string") {
2404
+ return [
2405
+ Error(
2406
+ `Invalid Option: record_delimiter must be a buffer or a string, got ${JSON.stringify(options.record_delimiter)}`,
2407
+ ),
2408
+ ];
2409
+ }
2410
+ switch (options.record_delimiter) {
2411
+ case "unix":
2412
+ options.record_delimiter = "\n";
2413
+ break;
2414
+ case "mac":
2415
+ options.record_delimiter = "\r";
2416
+ break;
2417
+ case "windows":
2418
+ options.record_delimiter = "\r\n";
2419
+ break;
2420
+ case "ascii":
2421
+ options.record_delimiter = "\u001e";
2422
+ break;
2423
+ case "unicode":
2424
+ options.record_delimiter = "\u2028";
2425
+ break;
2368
2426
  }
2369
2427
  return [undefined, options];
2370
2428
  };
2371
2429
 
2372
2430
  const bom_utf8 = Buffer.from([239, 187, 191]);
2373
2431
 
2374
- const stringifier = function(options, state, info){
2432
+ const stringifier = function (options, state, info) {
2375
2433
  return {
2376
2434
  options: options,
2377
2435
  state: state,
2378
2436
  info: info,
2379
- __transform: function(chunk, push){
2437
+ __transform: function (chunk, push) {
2380
2438
  // Chunk validation
2381
- if(!Array.isArray(chunk) && typeof chunk !== 'object'){
2382
- return Error(`Invalid Record: expect an array or an object, got ${JSON.stringify(chunk)}`);
2439
+ if (!Array.isArray(chunk) && typeof chunk !== "object") {
2440
+ return Error(
2441
+ `Invalid Record: expect an array or an object, got ${JSON.stringify(chunk)}`,
2442
+ );
2383
2443
  }
2384
2444
  // Detect columns from the first record
2385
- if(this.info.records === 0){
2386
- if(Array.isArray(chunk)){
2387
- if(this.options.header === true && this.options.columns === undefined){
2388
- return Error('Undiscoverable Columns: header option requires column option or object records');
2445
+ if (this.info.records === 0) {
2446
+ if (Array.isArray(chunk)) {
2447
+ if (
2448
+ this.options.header === true &&
2449
+ this.options.columns === undefined
2450
+ ) {
2451
+ return Error(
2452
+ "Undiscoverable Columns: header option requires column option or object records",
2453
+ );
2389
2454
  }
2390
- }else if(this.options.columns === undefined){
2455
+ } else if (this.options.columns === undefined) {
2391
2456
  const [err, columns] = normalize_columns(Object.keys(chunk));
2392
- if(err) return;
2457
+ if (err) return;
2393
2458
  this.options.columns = columns;
2394
2459
  }
2395
2460
  }
2396
2461
  // Emit the header
2397
- if(this.info.records === 0){
2462
+ if (this.info.records === 0) {
2398
2463
  this.bom(push);
2399
2464
  const err = this.headers(push);
2400
- if(err) return err;
2465
+ if (err) return err;
2401
2466
  }
2402
2467
  // Emit and stringify the record if an object or an array
2403
- try{
2468
+ try {
2404
2469
  // this.emit('record', chunk, this.info.records);
2405
- if(this.options.on_record){
2470
+ if (this.options.on_record) {
2406
2471
  this.options.on_record(chunk, this.info.records);
2407
2472
  }
2408
- }catch(err){
2473
+ } catch (err) {
2409
2474
  return err;
2410
2475
  }
2411
2476
  // Convert the record into a string
2412
2477
  let err, chunk_string;
2413
- if(this.options.eof){
2478
+ if (this.options.eof) {
2414
2479
  [err, chunk_string] = this.stringify(chunk);
2415
- if(err) return err;
2416
- if(chunk_string === undefined){
2480
+ if (err) return err;
2481
+ if (chunk_string === undefined) {
2417
2482
  return;
2418
- }else {
2483
+ } else {
2419
2484
  chunk_string = chunk_string + this.options.record_delimiter;
2420
2485
  }
2421
- }else {
2486
+ } else {
2422
2487
  [err, chunk_string] = this.stringify(chunk);
2423
- if(err) return err;
2424
- if(chunk_string === undefined){
2488
+ if (err) return err;
2489
+ if (chunk_string === undefined) {
2425
2490
  return;
2426
- }else {
2427
- if(this.options.header || this.info.records){
2491
+ } else {
2492
+ if (this.options.header || this.info.records) {
2428
2493
  chunk_string = this.options.record_delimiter + chunk_string;
2429
2494
  }
2430
2495
  }
@@ -2433,96 +2498,136 @@ const stringifier = function(options, state, info){
2433
2498
  this.info.records++;
2434
2499
  push(chunk_string);
2435
2500
  },
2436
- stringify: function(chunk, chunkIsHeader=false){
2437
- if(typeof chunk !== 'object'){
2501
+ stringify: function (chunk, chunkIsHeader = false) {
2502
+ if (typeof chunk !== "object") {
2438
2503
  return [undefined, chunk];
2439
2504
  }
2440
- const {columns} = this.options;
2505
+ const { columns } = this.options;
2441
2506
  const record = [];
2442
2507
  // Record is an array
2443
- if(Array.isArray(chunk)){
2508
+ if (Array.isArray(chunk)) {
2444
2509
  // We are getting an array but the user has specified output columns. In
2445
2510
  // this case, we respect the columns indexes
2446
- if(columns){
2511
+ if (columns) {
2447
2512
  chunk.splice(columns.length);
2448
2513
  }
2449
2514
  // Cast record elements
2450
- for(let i=0; i<chunk.length; i++){
2515
+ for (let i = 0; i < chunk.length; i++) {
2451
2516
  const field = chunk[i];
2452
2517
  const [err, value] = this.__cast(field, {
2453
- index: i, column: i, records: this.info.records, header: chunkIsHeader
2518
+ index: i,
2519
+ column: i,
2520
+ records: this.info.records,
2521
+ header: chunkIsHeader,
2454
2522
  });
2455
- if(err) return [err];
2523
+ if (err) return [err];
2456
2524
  record[i] = [value, field];
2457
2525
  }
2458
- // Record is a literal object
2459
- // `columns` is always defined: it is either provided or discovered.
2460
- }else {
2461
- for(let i=0; i<columns.length; i++){
2526
+ // Record is a literal object
2527
+ // `columns` is always defined: it is either provided or discovered.
2528
+ } else {
2529
+ for (let i = 0; i < columns.length; i++) {
2462
2530
  const field = get(chunk, columns[i].key);
2463
2531
  const [err, value] = this.__cast(field, {
2464
- index: i, column: columns[i].key, records: this.info.records, header: chunkIsHeader
2532
+ index: i,
2533
+ column: columns[i].key,
2534
+ records: this.info.records,
2535
+ header: chunkIsHeader,
2465
2536
  });
2466
- if(err) return [err];
2537
+ if (err) return [err];
2467
2538
  record[i] = [value, field];
2468
2539
  }
2469
2540
  }
2470
- let csvrecord = '';
2471
- for(let i=0; i<record.length; i++){
2541
+ let csvrecord = "";
2542
+ for (let i = 0; i < record.length; i++) {
2472
2543
  let options, err;
2473
- // eslint-disable-next-line
2544
+
2474
2545
  let [value, field] = record[i];
2475
- if(typeof value === "string"){
2546
+ if (typeof value === "string") {
2476
2547
  options = this.options;
2477
- }else if(is_object(value)){
2548
+ } else if (is_object(value)) {
2478
2549
  options = value;
2479
2550
  value = options.value;
2480
2551
  delete options.value;
2481
- if(typeof value !== "string" && value !== undefined && value !== null){
2482
- if(err) return [Error(`Invalid Casting Value: returned value must return a string, null or undefined, got ${JSON.stringify(value)}`)];
2552
+ if (
2553
+ typeof value !== "string" &&
2554
+ value !== undefined &&
2555
+ value !== null
2556
+ ) {
2557
+ if (err)
2558
+ return [
2559
+ Error(
2560
+ `Invalid Casting Value: returned value must return a string, null or undefined, got ${JSON.stringify(value)}`,
2561
+ ),
2562
+ ];
2483
2563
  }
2484
- options = {...this.options, ...options};
2564
+ options = { ...this.options, ...options };
2485
2565
  [err, options] = normalize_options(options);
2486
- if(err !== undefined){
2566
+ if (err !== undefined) {
2487
2567
  return [err];
2488
2568
  }
2489
- }else if(value === undefined || value === null){
2569
+ } else if (value === undefined || value === null) {
2490
2570
  options = this.options;
2491
- }else {
2492
- return [Error(`Invalid Casting Value: returned value must return a string, an object, null or undefined, got ${JSON.stringify(value)}`)];
2571
+ } else {
2572
+ return [
2573
+ Error(
2574
+ `Invalid Casting Value: returned value must return a string, an object, null or undefined, got ${JSON.stringify(value)}`,
2575
+ ),
2576
+ ];
2493
2577
  }
2494
- const {delimiter, escape, quote, quoted, quoted_empty, quoted_string, quoted_match, record_delimiter, escape_formulas} = options;
2495
- if('' === value && '' === field){
2496
- let quotedMatch = quoted_match && quoted_match.filter(quoted_match => {
2497
- if(typeof quoted_match === 'string'){
2498
- return value.indexOf(quoted_match) !== -1;
2499
- }else {
2500
- return quoted_match.test(value);
2501
- }
2502
- });
2578
+ const {
2579
+ delimiter,
2580
+ escape,
2581
+ quote,
2582
+ quoted,
2583
+ quoted_empty,
2584
+ quoted_string,
2585
+ quoted_match,
2586
+ record_delimiter,
2587
+ escape_formulas,
2588
+ } = options;
2589
+ if ("" === value && "" === field) {
2590
+ let quotedMatch =
2591
+ quoted_match &&
2592
+ quoted_match.filter((quoted_match) => {
2593
+ if (typeof quoted_match === "string") {
2594
+ return value.indexOf(quoted_match) !== -1;
2595
+ } else {
2596
+ return quoted_match.test(value);
2597
+ }
2598
+ });
2503
2599
  quotedMatch = quotedMatch && quotedMatch.length > 0;
2504
- const shouldQuote = quotedMatch || true === quoted_empty ||
2600
+ const shouldQuote =
2601
+ quotedMatch ||
2602
+ true === quoted_empty ||
2505
2603
  (true === quoted_string && false !== quoted_empty);
2506
- if(shouldQuote === true){
2604
+ if (shouldQuote === true) {
2507
2605
  value = quote + value + quote;
2508
2606
  }
2509
2607
  csvrecord += value;
2510
- }else if(value){
2511
- if(typeof value !== 'string'){
2512
- return [Error(`Formatter must return a string, null or undefined, got ${JSON.stringify(value)}`)];
2608
+ } else if (value) {
2609
+ if (typeof value !== "string") {
2610
+ return [
2611
+ Error(
2612
+ `Formatter must return a string, null or undefined, got ${JSON.stringify(value)}`,
2613
+ ),
2614
+ ];
2513
2615
  }
2514
- const containsdelimiter = delimiter.length && value.indexOf(delimiter) >= 0;
2515
- const containsQuote = (quote !== '') && value.indexOf(quote) >= 0;
2516
- const containsEscape = value.indexOf(escape) >= 0 && (escape !== quote);
2616
+ const containsdelimiter =
2617
+ delimiter.length && value.indexOf(delimiter) >= 0;
2618
+ const containsQuote = quote !== "" && value.indexOf(quote) >= 0;
2619
+ const containsEscape = value.indexOf(escape) >= 0 && escape !== quote;
2517
2620
  const containsRecordDelimiter = value.indexOf(record_delimiter) >= 0;
2518
- const quotedString = quoted_string && typeof field === 'string';
2519
- let quotedMatch = quoted_match && quoted_match.filter(quoted_match => {
2520
- if(typeof quoted_match === 'string'){
2521
- return value.indexOf(quoted_match) !== -1;
2522
- }else {
2523
- return quoted_match.test(value);
2524
- }
2525
- });
2621
+ const quotedString = quoted_string && typeof field === "string";
2622
+ let quotedMatch =
2623
+ quoted_match &&
2624
+ quoted_match.filter((quoted_match) => {
2625
+ if (typeof quoted_match === "string") {
2626
+ return value.indexOf(quoted_match) !== -1;
2627
+ } else {
2628
+ return quoted_match.test(value);
2629
+ }
2630
+ });
2526
2631
  quotedMatch = quotedMatch && quotedMatch.length > 0;
2527
2632
  // See https://github.com/adaltas/node-csv/pull/387
2528
2633
  // More about CSV injection or formula injection, when websites embed
@@ -2532,121 +2637,132 @@ const stringifier = function(options, state, info){
2532
2637
  // Apple Numbers unicode normalization is empirical from testing
2533
2638
  if (escape_formulas) {
2534
2639
  switch (value[0]) {
2535
- case '=':
2536
- case '+':
2537
- case '-':
2538
- case '@':
2539
- case '\t':
2540
- case '\r':
2541
- case '\uFF1D': // Unicode '='
2542
- case '\uFF0B': // Unicode '+'
2543
- case '\uFF0D': // Unicode '-'
2544
- case '\uFF20': // Unicode '@'
2545
- value = `'${value}`;
2546
- break;
2640
+ case "=":
2641
+ case "+":
2642
+ case "-":
2643
+ case "@":
2644
+ case "\t":
2645
+ case "\r":
2646
+ case "\uFF1D": // Unicode '='
2647
+ case "\uFF0B": // Unicode '+'
2648
+ case "\uFF0D": // Unicode '-'
2649
+ case "\uFF20": // Unicode '@'
2650
+ value = `'${value}`;
2651
+ break;
2547
2652
  }
2548
2653
  }
2549
- const shouldQuote = containsQuote === true || containsdelimiter || containsRecordDelimiter || quoted || quotedString || quotedMatch;
2550
- if(shouldQuote === true && containsEscape === true){
2551
- const regexp = escape === '\\'
2552
- ? new RegExp(escape + escape, 'g')
2553
- : new RegExp(escape, 'g');
2654
+ const shouldQuote =
2655
+ containsQuote === true ||
2656
+ containsdelimiter ||
2657
+ containsRecordDelimiter ||
2658
+ quoted ||
2659
+ quotedString ||
2660
+ quotedMatch;
2661
+ if (shouldQuote === true && containsEscape === true) {
2662
+ const regexp =
2663
+ escape === "\\"
2664
+ ? new RegExp(escape + escape, "g")
2665
+ : new RegExp(escape, "g");
2554
2666
  value = value.replace(regexp, escape + escape);
2555
2667
  }
2556
- if(containsQuote === true){
2557
- const regexp = new RegExp(quote,'g');
2668
+ if (containsQuote === true) {
2669
+ const regexp = new RegExp(quote, "g");
2558
2670
  value = value.replace(regexp, escape + quote);
2559
2671
  }
2560
- if(shouldQuote === true){
2672
+ if (shouldQuote === true) {
2561
2673
  value = quote + value + quote;
2562
2674
  }
2563
2675
  csvrecord += value;
2564
- }else if(quoted_empty === true || (field === '' && quoted_string === true && quoted_empty !== false)){
2676
+ } else if (
2677
+ quoted_empty === true ||
2678
+ (field === "" && quoted_string === true && quoted_empty !== false)
2679
+ ) {
2565
2680
  csvrecord += quote + quote;
2566
2681
  }
2567
- if(i !== record.length - 1){
2682
+ if (i !== record.length - 1) {
2568
2683
  csvrecord += delimiter;
2569
2684
  }
2570
2685
  }
2571
2686
  return [undefined, csvrecord];
2572
2687
  },
2573
- bom: function(push){
2574
- if(this.options.bom !== true){
2688
+ bom: function (push) {
2689
+ if (this.options.bom !== true) {
2575
2690
  return;
2576
2691
  }
2577
2692
  push(bom_utf8);
2578
2693
  },
2579
- headers: function(push){
2580
- if(this.options.header === false){
2694
+ headers: function (push) {
2695
+ if (this.options.header === false) {
2581
2696
  return;
2582
2697
  }
2583
- if(this.options.columns === undefined){
2698
+ if (this.options.columns === undefined) {
2584
2699
  return;
2585
2700
  }
2586
2701
  let err;
2587
- let headers = this.options.columns.map(column => column.header);
2588
- if(this.options.eof){
2702
+ let headers = this.options.columns.map((column) => column.header);
2703
+ if (this.options.eof) {
2589
2704
  [err, headers] = this.stringify(headers, true);
2590
2705
  headers += this.options.record_delimiter;
2591
- }else {
2706
+ } else {
2592
2707
  [err, headers] = this.stringify(headers);
2593
2708
  }
2594
- if(err) return err;
2709
+ if (err) return err;
2595
2710
  push(headers);
2596
2711
  },
2597
- __cast: function(value, context){
2712
+ __cast: function (value, context) {
2598
2713
  const type = typeof value;
2599
- try{
2600
- if(type === 'string'){ // Fine for 99% of the cases
2714
+ try {
2715
+ if (type === "string") {
2716
+ // Fine for 99% of the cases
2601
2717
  return [undefined, this.options.cast.string(value, context)];
2602
- }else if(type === 'bigint'){
2718
+ } else if (type === "bigint") {
2603
2719
  return [undefined, this.options.cast.bigint(value, context)];
2604
- }else if(type === 'number'){
2720
+ } else if (type === "number") {
2605
2721
  return [undefined, this.options.cast.number(value, context)];
2606
- }else if(type === 'boolean'){
2722
+ } else if (type === "boolean") {
2607
2723
  return [undefined, this.options.cast.boolean(value, context)];
2608
- }else if(value instanceof Date){
2724
+ } else if (value instanceof Date) {
2609
2725
  return [undefined, this.options.cast.date(value, context)];
2610
- }else if(type === 'object' && value !== null){
2726
+ } else if (type === "object" && value !== null) {
2611
2727
  return [undefined, this.options.cast.object(value, context)];
2612
- }else {
2728
+ } else {
2613
2729
  return [undefined, value, value];
2614
2730
  }
2615
- }catch(err){
2731
+ } catch (err) {
2616
2732
  return [err];
2617
2733
  }
2618
- }
2734
+ },
2619
2735
  };
2620
2736
  };
2621
2737
 
2622
- const stringify = function(records, opts={}){
2738
+ const stringify = function (records, opts = {}) {
2623
2739
  const data = [];
2624
2740
  const [err, options] = normalize_options(opts);
2625
- if(err !== undefined) throw err;
2741
+ if (err !== undefined) throw err;
2626
2742
  const state = {
2627
- stop: false
2743
+ stop: false,
2628
2744
  };
2629
2745
  // Information
2630
2746
  const info = {
2631
- records: 0
2747
+ records: 0,
2632
2748
  };
2633
2749
  const api = stringifier(options, state, info);
2634
- for(const record of records){
2635
- const err = api.__transform(record, function(record){
2750
+ for (const record of records) {
2751
+ const err = api.__transform(record, function (record) {
2636
2752
  data.push(record);
2637
2753
  });
2638
- if(err !== undefined) throw err;
2754
+ if (err !== undefined) throw err;
2639
2755
  }
2640
- if(data.length === 0){
2756
+ if (data.length === 0) {
2641
2757
  api.bom((d) => {
2642
2758
  data.push(d);
2643
2759
  });
2644
2760
  const err = api.headers((headers) => {
2645
2761
  data.push(headers);
2646
2762
  });
2647
- if(err !== undefined) throw err;
2763
+ if (err !== undefined) throw err;
2648
2764
  }
2649
- return data.join('');
2765
+ return data.join("");
2650
2766
  };
2651
2767
 
2652
2768
  var styles = "/**\n *\n * IBM Confidential\n *\n * (C) Copyright IBM Corp. 2024\n *\n * The source code for this program is not published or otherwise\n * divested of its trade secrets, irrespective of what has been\n * deposited with the U. S. Copyright Office\n *\n * US Government Users Restricted Rights - Use, duplication or\n * disclosure restricted by GSA ADP Schedule Contract with IBM Corp.\n *\n */\ncds-table-header-title,\ncds-table-header-description,\ncds-table-toolbar {\n position: sticky;\n width: var(--cds-chat-table-width, auto);\n left: 0;\n}\n\n:dir(rtl) cds-table-header-title,\n:dir(rtl) cds-table-header-description,\n:dir(rtl) cds-table-toolbar {\n left: unset;\n right: 0;\n}\n\ncds-table-header-title,\ncds-table-header-description {\n width: calc(var(--cds-chat-table-width, auto) - 1rem - 1rem);\n margin-left: -1rem;\n margin-right: -1rem;\n padding: 0 1rem;\n}\n\ncds-table-header-description {\n margin-bottom: -0.5rem;\n}\n\ncds-pagination {\n width: 100%;\n}";
@@ -2665,10 +2781,10 @@ var styles = "/**\n *\n * IBM Confidential\n *\n * (C) Copyright IBM Corp. 2024\
2665
2781
  * disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
2666
2782
  *
2667
2783
  */
2668
- const Download16svg = cdsAichatInternal.toString({
2669
- ..._16,
2784
+ const Download16svg = iconHelpers.toString({
2785
+ ...icons.Download16,
2670
2786
  attrs: {
2671
- ..._16.attrs,
2787
+ ...icons.Download16.attrs,
2672
2788
  slot: 'icon',
2673
2789
  },
2674
2790
  });
@@ -3044,80 +3160,80 @@ let TableElement = class TableElement extends lit.LitElement {
3044
3160
  return lit.html `${tableTemplate(this)}`;
3045
3161
  }
3046
3162
  };
3047
- cdsAichatInternal.__decorate([
3163
+ tslib.__decorate([
3048
3164
  decorators_js.property({ type: String, attribute: 'table-title' })
3049
3165
  ], TableElement.prototype, "tableTitle", void 0);
3050
- cdsAichatInternal.__decorate([
3166
+ tslib.__decorate([
3051
3167
  decorators_js.property({ type: String, attribute: 'table-description' })
3052
3168
  ], TableElement.prototype, "tableDescription", void 0);
3053
- cdsAichatInternal.__decorate([
3169
+ tslib.__decorate([
3054
3170
  decorators_js.property({ type: Array })
3055
3171
  ], TableElement.prototype, "headers", void 0);
3056
- cdsAichatInternal.__decorate([
3172
+ tslib.__decorate([
3057
3173
  decorators_js.property({ type: Array })
3058
3174
  ], TableElement.prototype, "rows", void 0);
3059
- cdsAichatInternal.__decorate([
3175
+ tslib.__decorate([
3060
3176
  decorators_js.property({ type: Number, attribute: 'container-width' })
3061
3177
  ], TableElement.prototype, "containerWidth", void 0);
3062
- cdsAichatInternal.__decorate([
3178
+ tslib.__decorate([
3063
3179
  decorators_js.property({ type: Number, attribute: 'chat-height' })
3064
3180
  ], TableElement.prototype, "chatHeight", void 0);
3065
- cdsAichatInternal.__decorate([
3181
+ tslib.__decorate([
3066
3182
  decorators_js.property({ type: Boolean, attribute: 'loading' })
3067
3183
  ], TableElement.prototype, "loading", void 0);
3068
- cdsAichatInternal.__decorate([
3184
+ tslib.__decorate([
3069
3185
  decorators_js.property({ type: String, attribute: 'filter-placeholder-text' })
3070
3186
  ], TableElement.prototype, "filterPlaceholderText", void 0);
3071
- cdsAichatInternal.__decorate([
3187
+ tslib.__decorate([
3072
3188
  decorators_js.property({ type: String, attribute: 'previous-page-text' })
3073
3189
  ], TableElement.prototype, "previousPageText", void 0);
3074
- cdsAichatInternal.__decorate([
3190
+ tslib.__decorate([
3075
3191
  decorators_js.property({ type: String, attribute: 'next-page-text' })
3076
3192
  ], TableElement.prototype, "nextPageText", void 0);
3077
- cdsAichatInternal.__decorate([
3193
+ tslib.__decorate([
3078
3194
  decorators_js.property({ type: String, attribute: 'items-per-page-text' })
3079
3195
  ], TableElement.prototype, "itemsPerPageText", void 0);
3080
- cdsAichatInternal.__decorate([
3196
+ tslib.__decorate([
3081
3197
  decorators_js.property({ type: String, attribute: 'locale' })
3082
3198
  ], TableElement.prototype, "locale", void 0);
3083
- cdsAichatInternal.__decorate([
3199
+ tslib.__decorate([
3084
3200
  decorators_js.property({ type: Function })
3085
3201
  ], TableElement.prototype, "getPaginationSupplementalText", void 0);
3086
- cdsAichatInternal.__decorate([
3202
+ tslib.__decorate([
3087
3203
  decorators_js.property({ type: Function })
3088
3204
  ], TableElement.prototype, "getPaginationStatusText", void 0);
3089
- cdsAichatInternal.__decorate([
3205
+ tslib.__decorate([
3090
3206
  decorators_js.state()
3091
3207
  ], TableElement.prototype, "_isValid", void 0);
3092
- cdsAichatInternal.__decorate([
3208
+ tslib.__decorate([
3093
3209
  decorators_js.state()
3094
3210
  ], TableElement.prototype, "_currentPageNumber", void 0);
3095
- cdsAichatInternal.__decorate([
3211
+ tslib.__decorate([
3096
3212
  decorators_js.state()
3097
3213
  ], TableElement.prototype, "_currentPageSize", void 0);
3098
- cdsAichatInternal.__decorate([
3214
+ tslib.__decorate([
3099
3215
  decorators_js.state()
3100
3216
  ], TableElement.prototype, "_rowsPerPageChanged", void 0);
3101
- cdsAichatInternal.__decorate([
3217
+ tslib.__decorate([
3102
3218
  decorators_js.state()
3103
3219
  ], TableElement.prototype, "_filterVisibleRowIDs", void 0);
3104
- cdsAichatInternal.__decorate([
3220
+ tslib.__decorate([
3105
3221
  decorators_js.state()
3106
3222
  ], TableElement.prototype, "_rowsWithIDs", void 0);
3107
- cdsAichatInternal.__decorate([
3223
+ tslib.__decorate([
3108
3224
  decorators_js.state()
3109
3225
  ], TableElement.prototype, "_allowFiltering", void 0);
3110
- cdsAichatInternal.__decorate([
3111
- cdsAichatInternal._default
3226
+ tslib.__decorate([
3227
+ AppContainer._default
3112
3228
  ], TableElement.prototype, "_handlePageChangeEvent", null);
3113
- cdsAichatInternal.__decorate([
3114
- cdsAichatInternal._default
3229
+ tslib.__decorate([
3230
+ AppContainer._default
3115
3231
  ], TableElement.prototype, "_handlePageSizeChangeEvent", null);
3116
- cdsAichatInternal.__decorate([
3117
- cdsAichatInternal._default
3232
+ tslib.__decorate([
3233
+ AppContainer._default
3118
3234
  ], TableElement.prototype, "_handleFilterEvent", null);
3119
- TableElement = cdsAichatInternal.__decorate([
3120
- cdsAichatInternal.carbonElement(TABLE_COMPONENT_TAG_NAME)
3235
+ TableElement = tslib.__decorate([
3236
+ AppContainer.carbonElement(TABLE_COMPONENT_TAG_NAME)
3121
3237
  ], TableElement);
3122
3238
 
3123
3239
  /**
@@ -3137,7 +3253,7 @@ TableElement = cdsAichatInternal.__decorate([
3137
3253
  /**
3138
3254
  * This file creates React bindings for the Table web component and registers the web component in the DOM.
3139
3255
  */
3140
- const Table = cdsAichatInternal.o({
3256
+ const Table = AppContainer.o({
3141
3257
  tagName: TABLE_COMPONENT_TAG_NAME,
3142
3258
  elementClass: TableElement,
3143
3259
  react: React,