llms-py 2.0.20__py3-none-any.whl → 3.0.18__py3-none-any.whl

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 (207) hide show
  1. llms/__init__.py +3 -1
  2. llms/db.py +359 -0
  3. llms/{ui/Analytics.mjs → extensions/analytics/ui/index.mjs} +254 -327
  4. llms/extensions/app/README.md +20 -0
  5. llms/extensions/app/__init__.py +588 -0
  6. llms/extensions/app/db.py +540 -0
  7. llms/{ui → extensions/app/ui}/Recents.mjs +99 -73
  8. llms/{ui/Sidebar.mjs → extensions/app/ui/index.mjs} +139 -68
  9. llms/extensions/app/ui/threadStore.mjs +440 -0
  10. llms/extensions/computer/README.md +96 -0
  11. llms/extensions/computer/__init__.py +59 -0
  12. llms/extensions/computer/base.py +80 -0
  13. llms/extensions/computer/bash.py +185 -0
  14. llms/extensions/computer/computer.py +523 -0
  15. llms/extensions/computer/edit.py +299 -0
  16. llms/extensions/computer/filesystem.py +542 -0
  17. llms/extensions/computer/platform.py +461 -0
  18. llms/extensions/computer/run.py +37 -0
  19. llms/extensions/core_tools/CALCULATOR.md +32 -0
  20. llms/extensions/core_tools/__init__.py +599 -0
  21. llms/extensions/core_tools/ui/codemirror/addon/edit/closebrackets.js +201 -0
  22. llms/extensions/core_tools/ui/codemirror/addon/edit/closetag.js +185 -0
  23. llms/extensions/core_tools/ui/codemirror/addon/edit/continuelist.js +101 -0
  24. llms/extensions/core_tools/ui/codemirror/addon/edit/matchbrackets.js +160 -0
  25. llms/extensions/core_tools/ui/codemirror/addon/edit/matchtags.js +66 -0
  26. llms/extensions/core_tools/ui/codemirror/addon/edit/trailingspace.js +27 -0
  27. llms/extensions/core_tools/ui/codemirror/addon/selection/active-line.js +72 -0
  28. llms/extensions/core_tools/ui/codemirror/addon/selection/mark-selection.js +119 -0
  29. llms/extensions/core_tools/ui/codemirror/addon/selection/selection-pointer.js +98 -0
  30. llms/extensions/core_tools/ui/codemirror/codemirror.css +344 -0
  31. llms/extensions/core_tools/ui/codemirror/codemirror.js +9884 -0
  32. llms/extensions/core_tools/ui/codemirror/doc/docs.css +225 -0
  33. llms/extensions/core_tools/ui/codemirror/doc/source_sans.woff +0 -0
  34. llms/extensions/core_tools/ui/codemirror/mode/clike/clike.js +942 -0
  35. llms/extensions/core_tools/ui/codemirror/mode/javascript/index.html +118 -0
  36. llms/extensions/core_tools/ui/codemirror/mode/javascript/javascript.js +962 -0
  37. llms/extensions/core_tools/ui/codemirror/mode/javascript/typescript.html +62 -0
  38. llms/extensions/core_tools/ui/codemirror/mode/python/python.js +402 -0
  39. llms/extensions/core_tools/ui/codemirror/theme/dracula.css +40 -0
  40. llms/extensions/core_tools/ui/codemirror/theme/mocha.css +135 -0
  41. llms/extensions/core_tools/ui/index.mjs +650 -0
  42. llms/extensions/gallery/README.md +61 -0
  43. llms/extensions/gallery/__init__.py +63 -0
  44. llms/extensions/gallery/db.py +243 -0
  45. llms/extensions/gallery/ui/index.mjs +482 -0
  46. llms/extensions/katex/README.md +39 -0
  47. llms/extensions/katex/__init__.py +6 -0
  48. llms/extensions/katex/ui/README.md +125 -0
  49. llms/extensions/katex/ui/contrib/auto-render.js +338 -0
  50. llms/extensions/katex/ui/contrib/auto-render.min.js +1 -0
  51. llms/extensions/katex/ui/contrib/auto-render.mjs +244 -0
  52. llms/extensions/katex/ui/contrib/copy-tex.js +127 -0
  53. llms/extensions/katex/ui/contrib/copy-tex.min.js +1 -0
  54. llms/extensions/katex/ui/contrib/copy-tex.mjs +105 -0
  55. llms/extensions/katex/ui/contrib/mathtex-script-type.js +109 -0
  56. llms/extensions/katex/ui/contrib/mathtex-script-type.min.js +1 -0
  57. llms/extensions/katex/ui/contrib/mathtex-script-type.mjs +24 -0
  58. llms/extensions/katex/ui/contrib/mhchem.js +3213 -0
  59. llms/extensions/katex/ui/contrib/mhchem.min.js +1 -0
  60. llms/extensions/katex/ui/contrib/mhchem.mjs +3109 -0
  61. llms/extensions/katex/ui/contrib/render-a11y-string.js +887 -0
  62. llms/extensions/katex/ui/contrib/render-a11y-string.min.js +1 -0
  63. llms/extensions/katex/ui/contrib/render-a11y-string.mjs +800 -0
  64. llms/extensions/katex/ui/fonts/KaTeX_AMS-Regular.ttf +0 -0
  65. llms/extensions/katex/ui/fonts/KaTeX_AMS-Regular.woff +0 -0
  66. llms/extensions/katex/ui/fonts/KaTeX_AMS-Regular.woff2 +0 -0
  67. llms/extensions/katex/ui/fonts/KaTeX_Caligraphic-Bold.ttf +0 -0
  68. llms/extensions/katex/ui/fonts/KaTeX_Caligraphic-Bold.woff +0 -0
  69. llms/extensions/katex/ui/fonts/KaTeX_Caligraphic-Bold.woff2 +0 -0
  70. llms/extensions/katex/ui/fonts/KaTeX_Caligraphic-Regular.ttf +0 -0
  71. llms/extensions/katex/ui/fonts/KaTeX_Caligraphic-Regular.woff +0 -0
  72. llms/extensions/katex/ui/fonts/KaTeX_Caligraphic-Regular.woff2 +0 -0
  73. llms/extensions/katex/ui/fonts/KaTeX_Fraktur-Bold.ttf +0 -0
  74. llms/extensions/katex/ui/fonts/KaTeX_Fraktur-Bold.woff +0 -0
  75. llms/extensions/katex/ui/fonts/KaTeX_Fraktur-Bold.woff2 +0 -0
  76. llms/extensions/katex/ui/fonts/KaTeX_Fraktur-Regular.ttf +0 -0
  77. llms/extensions/katex/ui/fonts/KaTeX_Fraktur-Regular.woff +0 -0
  78. llms/extensions/katex/ui/fonts/KaTeX_Fraktur-Regular.woff2 +0 -0
  79. llms/extensions/katex/ui/fonts/KaTeX_Main-Bold.ttf +0 -0
  80. llms/extensions/katex/ui/fonts/KaTeX_Main-Bold.woff +0 -0
  81. llms/extensions/katex/ui/fonts/KaTeX_Main-Bold.woff2 +0 -0
  82. llms/extensions/katex/ui/fonts/KaTeX_Main-BoldItalic.ttf +0 -0
  83. llms/extensions/katex/ui/fonts/KaTeX_Main-BoldItalic.woff +0 -0
  84. llms/extensions/katex/ui/fonts/KaTeX_Main-BoldItalic.woff2 +0 -0
  85. llms/extensions/katex/ui/fonts/KaTeX_Main-Italic.ttf +0 -0
  86. llms/extensions/katex/ui/fonts/KaTeX_Main-Italic.woff +0 -0
  87. llms/extensions/katex/ui/fonts/KaTeX_Main-Italic.woff2 +0 -0
  88. llms/extensions/katex/ui/fonts/KaTeX_Main-Regular.ttf +0 -0
  89. llms/extensions/katex/ui/fonts/KaTeX_Main-Regular.woff +0 -0
  90. llms/extensions/katex/ui/fonts/KaTeX_Main-Regular.woff2 +0 -0
  91. llms/extensions/katex/ui/fonts/KaTeX_Math-BoldItalic.ttf +0 -0
  92. llms/extensions/katex/ui/fonts/KaTeX_Math-BoldItalic.woff +0 -0
  93. llms/extensions/katex/ui/fonts/KaTeX_Math-BoldItalic.woff2 +0 -0
  94. llms/extensions/katex/ui/fonts/KaTeX_Math-Italic.ttf +0 -0
  95. llms/extensions/katex/ui/fonts/KaTeX_Math-Italic.woff +0 -0
  96. llms/extensions/katex/ui/fonts/KaTeX_Math-Italic.woff2 +0 -0
  97. llms/extensions/katex/ui/fonts/KaTeX_SansSerif-Bold.ttf +0 -0
  98. llms/extensions/katex/ui/fonts/KaTeX_SansSerif-Bold.woff +0 -0
  99. llms/extensions/katex/ui/fonts/KaTeX_SansSerif-Bold.woff2 +0 -0
  100. llms/extensions/katex/ui/fonts/KaTeX_SansSerif-Italic.ttf +0 -0
  101. llms/extensions/katex/ui/fonts/KaTeX_SansSerif-Italic.woff +0 -0
  102. llms/extensions/katex/ui/fonts/KaTeX_SansSerif-Italic.woff2 +0 -0
  103. llms/extensions/katex/ui/fonts/KaTeX_SansSerif-Regular.ttf +0 -0
  104. llms/extensions/katex/ui/fonts/KaTeX_SansSerif-Regular.woff +0 -0
  105. llms/extensions/katex/ui/fonts/KaTeX_SansSerif-Regular.woff2 +0 -0
  106. llms/extensions/katex/ui/fonts/KaTeX_Script-Regular.ttf +0 -0
  107. llms/extensions/katex/ui/fonts/KaTeX_Script-Regular.woff +0 -0
  108. llms/extensions/katex/ui/fonts/KaTeX_Script-Regular.woff2 +0 -0
  109. llms/extensions/katex/ui/fonts/KaTeX_Size1-Regular.ttf +0 -0
  110. llms/extensions/katex/ui/fonts/KaTeX_Size1-Regular.woff +0 -0
  111. llms/extensions/katex/ui/fonts/KaTeX_Size1-Regular.woff2 +0 -0
  112. llms/extensions/katex/ui/fonts/KaTeX_Size2-Regular.ttf +0 -0
  113. llms/extensions/katex/ui/fonts/KaTeX_Size2-Regular.woff +0 -0
  114. llms/extensions/katex/ui/fonts/KaTeX_Size2-Regular.woff2 +0 -0
  115. llms/extensions/katex/ui/fonts/KaTeX_Size3-Regular.ttf +0 -0
  116. llms/extensions/katex/ui/fonts/KaTeX_Size3-Regular.woff +0 -0
  117. llms/extensions/katex/ui/fonts/KaTeX_Size3-Regular.woff2 +0 -0
  118. llms/extensions/katex/ui/fonts/KaTeX_Size4-Regular.ttf +0 -0
  119. llms/extensions/katex/ui/fonts/KaTeX_Size4-Regular.woff +0 -0
  120. llms/extensions/katex/ui/fonts/KaTeX_Size4-Regular.woff2 +0 -0
  121. llms/extensions/katex/ui/fonts/KaTeX_Typewriter-Regular.ttf +0 -0
  122. llms/extensions/katex/ui/fonts/KaTeX_Typewriter-Regular.woff +0 -0
  123. llms/extensions/katex/ui/fonts/KaTeX_Typewriter-Regular.woff2 +0 -0
  124. llms/extensions/katex/ui/index.mjs +92 -0
  125. llms/extensions/katex/ui/katex-swap.css +1230 -0
  126. llms/extensions/katex/ui/katex-swap.min.css +1 -0
  127. llms/extensions/katex/ui/katex.css +1230 -0
  128. llms/extensions/katex/ui/katex.js +19080 -0
  129. llms/extensions/katex/ui/katex.min.css +1 -0
  130. llms/extensions/katex/ui/katex.min.js +1 -0
  131. llms/extensions/katex/ui/katex.min.mjs +1 -0
  132. llms/extensions/katex/ui/katex.mjs +18547 -0
  133. llms/extensions/providers/__init__.py +22 -0
  134. llms/extensions/providers/anthropic.py +260 -0
  135. llms/extensions/providers/cerebras.py +36 -0
  136. llms/extensions/providers/chutes.py +153 -0
  137. llms/extensions/providers/google.py +559 -0
  138. llms/extensions/providers/nvidia.py +103 -0
  139. llms/extensions/providers/openai.py +154 -0
  140. llms/extensions/providers/openrouter.py +74 -0
  141. llms/extensions/providers/zai.py +182 -0
  142. llms/extensions/skills/LICENSE +202 -0
  143. llms/extensions/skills/__init__.py +130 -0
  144. llms/extensions/skills/errors.py +25 -0
  145. llms/extensions/skills/models.py +39 -0
  146. llms/extensions/skills/parser.py +178 -0
  147. llms/extensions/skills/ui/index.mjs +376 -0
  148. llms/extensions/skills/ui/skills/create-plan/SKILL.md +74 -0
  149. llms/extensions/skills/validator.py +177 -0
  150. llms/extensions/system_prompts/README.md +22 -0
  151. llms/extensions/system_prompts/__init__.py +45 -0
  152. llms/extensions/system_prompts/ui/index.mjs +276 -0
  153. llms/extensions/system_prompts/ui/prompts.json +1067 -0
  154. llms/extensions/tools/__init__.py +67 -0
  155. llms/extensions/tools/ui/index.mjs +837 -0
  156. llms/index.html +36 -62
  157. llms/llms.json +180 -879
  158. llms/main.py +4009 -912
  159. llms/providers-extra.json +394 -0
  160. llms/providers.json +1 -0
  161. llms/ui/App.mjs +176 -8
  162. llms/ui/ai.mjs +156 -20
  163. llms/ui/app.css +3768 -321
  164. llms/ui/ctx.mjs +459 -0
  165. llms/ui/index.mjs +131 -0
  166. llms/ui/lib/chart.js +14 -0
  167. llms/ui/lib/charts.mjs +16 -0
  168. llms/ui/lib/color.js +14 -0
  169. llms/ui/lib/highlight.min.mjs +1243 -0
  170. llms/ui/lib/idb.min.mjs +8 -0
  171. llms/ui/lib/marked.min.mjs +8 -0
  172. llms/ui/lib/servicestack-client.mjs +1 -0
  173. llms/ui/lib/servicestack-vue.mjs +37 -0
  174. llms/ui/lib/vue-router.min.mjs +6 -0
  175. llms/ui/lib/vue.min.mjs +13 -0
  176. llms/ui/lib/vue.mjs +18530 -0
  177. llms/ui/markdown.mjs +25 -14
  178. llms/ui/modules/chat/ChatBody.mjs +1156 -0
  179. llms/ui/{SettingsDialog.mjs → modules/chat/SettingsDialog.mjs} +74 -74
  180. llms/ui/modules/chat/index.mjs +995 -0
  181. llms/ui/modules/icons.mjs +46 -0
  182. llms/ui/modules/layout.mjs +271 -0
  183. llms/ui/modules/model-selector.mjs +811 -0
  184. llms/ui/tailwind.input.css +560 -78
  185. llms/ui/typography.css +54 -36
  186. llms/ui/utils.mjs +221 -92
  187. llms_py-3.0.18.dist-info/METADATA +49 -0
  188. llms_py-3.0.18.dist-info/RECORD +194 -0
  189. {llms_py-2.0.20.dist-info → llms_py-3.0.18.dist-info}/WHEEL +1 -1
  190. {llms_py-2.0.20.dist-info → llms_py-3.0.18.dist-info}/licenses/LICENSE +1 -2
  191. llms/ui/Avatar.mjs +0 -28
  192. llms/ui/Brand.mjs +0 -34
  193. llms/ui/ChatPrompt.mjs +0 -443
  194. llms/ui/Main.mjs +0 -740
  195. llms/ui/ModelSelector.mjs +0 -60
  196. llms/ui/ProviderIcon.mjs +0 -29
  197. llms/ui/ProviderStatus.mjs +0 -105
  198. llms/ui/SignIn.mjs +0 -64
  199. llms/ui/SystemPromptEditor.mjs +0 -31
  200. llms/ui/SystemPromptSelector.mjs +0 -36
  201. llms/ui/Welcome.mjs +0 -8
  202. llms/ui/threadStore.mjs +0 -524
  203. llms/ui.json +0 -1069
  204. llms_py-2.0.20.dist-info/METADATA +0 -931
  205. llms_py-2.0.20.dist-info/RECORD +0 -36
  206. {llms_py-2.0.20.dist-info → llms_py-3.0.18.dist-info}/entry_points.txt +0 -0
  207. {llms_py-2.0.20.dist-info → llms_py-3.0.18.dist-info}/top_level.txt +0 -0
@@ -0,0 +1,887 @@
1
+ (function webpackUniversalModuleDefinition(root, factory) {
2
+ if(typeof exports === 'object' && typeof module === 'object')
3
+ module.exports = factory(require("katex"));
4
+ else if(typeof define === 'function' && define.amd)
5
+ define(["katex"], factory);
6
+ else {
7
+ var a = typeof exports === 'object' ? factory(require("katex")) : factory(root["katex"]);
8
+ for(var i in a) (typeof exports === 'object' ? exports : root)[i] = a[i];
9
+ }
10
+ })((typeof self !== 'undefined' ? self : this), function(__WEBPACK_EXTERNAL_MODULE__757__) {
11
+ return /******/ (function() { // webpackBootstrap
12
+ /******/ "use strict";
13
+ /******/ var __webpack_modules__ = ({
14
+
15
+ /***/ 757:
16
+ /***/ (function(module) {
17
+
18
+ module.exports = __WEBPACK_EXTERNAL_MODULE__757__;
19
+
20
+ /***/ })
21
+
22
+ /******/ });
23
+ /************************************************************************/
24
+ /******/ // The module cache
25
+ /******/ var __webpack_module_cache__ = {};
26
+ /******/
27
+ /******/ // The require function
28
+ /******/ function __webpack_require__(moduleId) {
29
+ /******/ // Check if module is in cache
30
+ /******/ var cachedModule = __webpack_module_cache__[moduleId];
31
+ /******/ if (cachedModule !== undefined) {
32
+ /******/ return cachedModule.exports;
33
+ /******/ }
34
+ /******/ // Create a new module (and put it into the cache)
35
+ /******/ var module = __webpack_module_cache__[moduleId] = {
36
+ /******/ // no module.id needed
37
+ /******/ // no module.loaded needed
38
+ /******/ exports: {}
39
+ /******/ };
40
+ /******/
41
+ /******/ // Execute the module function
42
+ /******/ __webpack_modules__[moduleId](module, module.exports, __webpack_require__);
43
+ /******/
44
+ /******/ // Return the exports of the module
45
+ /******/ return module.exports;
46
+ /******/ }
47
+ /******/
48
+ /************************************************************************/
49
+ /******/ /* webpack/runtime/compat get default export */
50
+ /******/ !function() {
51
+ /******/ // getDefaultExport function for compatibility with non-harmony modules
52
+ /******/ __webpack_require__.n = function(module) {
53
+ /******/ var getter = module && module.__esModule ?
54
+ /******/ function() { return module['default']; } :
55
+ /******/ function() { return module; };
56
+ /******/ __webpack_require__.d(getter, { a: getter });
57
+ /******/ return getter;
58
+ /******/ };
59
+ /******/ }();
60
+ /******/
61
+ /******/ /* webpack/runtime/define property getters */
62
+ /******/ !function() {
63
+ /******/ // define getter functions for harmony exports
64
+ /******/ __webpack_require__.d = function(exports, definition) {
65
+ /******/ for(var key in definition) {
66
+ /******/ if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {
67
+ /******/ Object.defineProperty(exports, key, { enumerable: true, get: definition[key] });
68
+ /******/ }
69
+ /******/ }
70
+ /******/ };
71
+ /******/ }();
72
+ /******/
73
+ /******/ /* webpack/runtime/hasOwnProperty shorthand */
74
+ /******/ !function() {
75
+ /******/ __webpack_require__.o = function(obj, prop) { return Object.prototype.hasOwnProperty.call(obj, prop); }
76
+ /******/ }();
77
+ /******/
78
+ /************************************************************************/
79
+ var __webpack_exports__ = {};
80
+ /* harmony import */ var katex__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(757);
81
+ /* harmony import */ var katex__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(katex__WEBPACK_IMPORTED_MODULE_0__);
82
+ /**
83
+ * renderA11yString returns a readable string.
84
+ *
85
+ * In some cases the string will have the proper semantic math
86
+ * meaning,:
87
+ * renderA11yString("\\frac{1}{2}"")
88
+ * -> "start fraction, 1, divided by, 2, end fraction"
89
+ *
90
+ * However, other cases do not:
91
+ * renderA11yString("f(x) = x^2")
92
+ * -> "f, left parenthesis, x, right parenthesis, equals, x, squared"
93
+ *
94
+ * The commas in the string aim to increase ease of understanding
95
+ * when read by a screenreader.
96
+ */
97
+ // NOTE: since we're importing types here these files won't actually be
98
+ // included in the build.
99
+ // $FlowIgnore: we import the types directly anyways
100
+
101
+ const stringMap = {
102
+ "(": "left parenthesis",
103
+ ")": "right parenthesis",
104
+ "[": "open bracket",
105
+ "]": "close bracket",
106
+ "\\{": "left brace",
107
+ "\\}": "right brace",
108
+ "\\lvert": "open vertical bar",
109
+ "\\rvert": "close vertical bar",
110
+ "|": "vertical bar",
111
+ "\\uparrow": "up arrow",
112
+ "\\Uparrow": "up arrow",
113
+ "\\downarrow": "down arrow",
114
+ "\\Downarrow": "down arrow",
115
+ "\\updownarrow": "up down arrow",
116
+ "\\leftarrow": "left arrow",
117
+ "\\Leftarrow": "left arrow",
118
+ "\\rightarrow": "right arrow",
119
+ "\\Rightarrow": "right arrow",
120
+ "\\langle": "open angle",
121
+ "\\rangle": "close angle",
122
+ "\\lfloor": "open floor",
123
+ "\\rfloor": "close floor",
124
+ "\\int": "integral",
125
+ "\\intop": "integral",
126
+ "\\lim": "limit",
127
+ "\\ln": "natural log",
128
+ "\\log": "log",
129
+ "\\sin": "sine",
130
+ "\\cos": "cosine",
131
+ "\\tan": "tangent",
132
+ "\\cot": "cotangent",
133
+ "\\sum": "sum",
134
+ "/": "slash",
135
+ ",": "comma",
136
+ ".": "point",
137
+ "-": "negative",
138
+ "+": "plus",
139
+ "~": "tilde",
140
+ ":": "colon",
141
+ "?": "question mark",
142
+ "'": "apostrophe",
143
+ "\\%": "percent",
144
+ " ": "space",
145
+ "\\ ": "space",
146
+ "\\$": "dollar sign",
147
+ "\\angle": "angle",
148
+ "\\degree": "degree",
149
+ "\\circ": "circle",
150
+ "\\vec": "vector",
151
+ "\\triangle": "triangle",
152
+ "\\pi": "pi",
153
+ "\\prime": "prime",
154
+ "\\infty": "infinity",
155
+ "\\alpha": "alpha",
156
+ "\\beta": "beta",
157
+ "\\gamma": "gamma",
158
+ "\\omega": "omega",
159
+ "\\theta": "theta",
160
+ "\\sigma": "sigma",
161
+ "\\lambda": "lambda",
162
+ "\\tau": "tau",
163
+ "\\Delta": "delta",
164
+ "\\delta": "delta",
165
+ "\\mu": "mu",
166
+ "\\rho": "rho",
167
+ "\\nabla": "del",
168
+ "\\ell": "ell",
169
+ "\\ldots": "dots",
170
+ // TODO: add entries for all accents
171
+ "\\hat": "hat",
172
+ "\\acute": "acute"
173
+ };
174
+ const powerMap = {
175
+ "prime": "prime",
176
+ "degree": "degrees",
177
+ "circle": "degrees",
178
+ "2": "squared",
179
+ "3": "cubed"
180
+ };
181
+ const openMap = {
182
+ "|": "open vertical bar",
183
+ ".": ""
184
+ };
185
+ const closeMap = {
186
+ "|": "close vertical bar",
187
+ ".": ""
188
+ };
189
+ const binMap = {
190
+ "+": "plus",
191
+ "-": "minus",
192
+ "\\pm": "plus minus",
193
+ "\\cdot": "dot",
194
+ "*": "times",
195
+ "/": "divided by",
196
+ "\\times": "times",
197
+ "\\div": "divided by",
198
+ "\\circ": "circle",
199
+ "\\bullet": "bullet"
200
+ };
201
+ const relMap = {
202
+ "=": "equals",
203
+ "\\approx": "approximately equals",
204
+ "≠": "does not equal",
205
+ "\\geq": "is greater than or equal to",
206
+ "\\ge": "is greater than or equal to",
207
+ "\\leq": "is less than or equal to",
208
+ "\\le": "is less than or equal to",
209
+ ">": "is greater than",
210
+ "<": "is less than",
211
+ "\\leftarrow": "left arrow",
212
+ "\\Leftarrow": "left arrow",
213
+ "\\rightarrow": "right arrow",
214
+ "\\Rightarrow": "right arrow",
215
+ ":": "colon"
216
+ };
217
+ const accentUnderMap = {
218
+ "\\underleftarrow": "left arrow",
219
+ "\\underrightarrow": "right arrow",
220
+ "\\underleftrightarrow": "left-right arrow",
221
+ "\\undergroup": "group",
222
+ "\\underlinesegment": "line segment",
223
+ "\\utilde": "tilde"
224
+ };
225
+
226
+ const buildString = (str, type, a11yStrings) => {
227
+ if (!str) {
228
+ return;
229
+ }
230
+
231
+ let ret;
232
+
233
+ if (type === "open") {
234
+ ret = str in openMap ? openMap[str] : stringMap[str] || str;
235
+ } else if (type === "close") {
236
+ ret = str in closeMap ? closeMap[str] : stringMap[str] || str;
237
+ } else if (type === "bin") {
238
+ ret = binMap[str] || str;
239
+ } else if (type === "rel") {
240
+ ret = relMap[str] || str;
241
+ } else {
242
+ ret = stringMap[str] || str;
243
+ } // If the text to add is a number and there is already a string
244
+ // in the list and the last string is a number then we should
245
+ // combine them into a single number
246
+
247
+
248
+ if (/^\d+$/.test(ret) && a11yStrings.length > 0 && // TODO(kevinb): check that the last item in a11yStrings is a string
249
+ // I think we might be able to drop the nested arrays, which would make
250
+ // this easier to type
251
+ // $FlowFixMe
252
+ /^\d+$/.test(a11yStrings[a11yStrings.length - 1])) {
253
+ a11yStrings[a11yStrings.length - 1] += ret;
254
+ } else if (ret) {
255
+ a11yStrings.push(ret);
256
+ }
257
+ };
258
+
259
+ const buildRegion = (a11yStrings, callback) => {
260
+ const regionStrings = [];
261
+ a11yStrings.push(regionStrings);
262
+ callback(regionStrings);
263
+ };
264
+
265
+ const handleObject = (tree, a11yStrings, atomType) => {
266
+ // Everything else is assumed to be an object...
267
+ switch (tree.type) {
268
+ case "accent":
269
+ {
270
+ buildRegion(a11yStrings, a11yStrings => {
271
+ buildA11yStrings(tree.base, a11yStrings, atomType);
272
+ a11yStrings.push("with");
273
+ buildString(tree.label, "normal", a11yStrings);
274
+ a11yStrings.push("on top");
275
+ });
276
+ break;
277
+ }
278
+
279
+ case "accentUnder":
280
+ {
281
+ buildRegion(a11yStrings, a11yStrings => {
282
+ buildA11yStrings(tree.base, a11yStrings, atomType);
283
+ a11yStrings.push("with");
284
+ buildString(accentUnderMap[tree.label], "normal", a11yStrings);
285
+ a11yStrings.push("underneath");
286
+ });
287
+ break;
288
+ }
289
+
290
+ case "accent-token":
291
+ {
292
+ // Used internally by accent symbols.
293
+ break;
294
+ }
295
+
296
+ case "atom":
297
+ {
298
+ const {
299
+ text
300
+ } = tree;
301
+
302
+ switch (tree.family) {
303
+ case "bin":
304
+ {
305
+ buildString(text, "bin", a11yStrings);
306
+ break;
307
+ }
308
+
309
+ case "close":
310
+ {
311
+ buildString(text, "close", a11yStrings);
312
+ break;
313
+ }
314
+ // TODO(kevinb): figure out what should be done for inner
315
+
316
+ case "inner":
317
+ {
318
+ buildString(tree.text, "inner", a11yStrings);
319
+ break;
320
+ }
321
+
322
+ case "open":
323
+ {
324
+ buildString(text, "open", a11yStrings);
325
+ break;
326
+ }
327
+
328
+ case "punct":
329
+ {
330
+ buildString(text, "punct", a11yStrings);
331
+ break;
332
+ }
333
+
334
+ case "rel":
335
+ {
336
+ buildString(text, "rel", a11yStrings);
337
+ break;
338
+ }
339
+
340
+ default:
341
+ {
342
+ tree.family;
343
+ throw new Error("\"" + tree.family + "\" is not a valid atom type");
344
+ }
345
+ }
346
+
347
+ break;
348
+ }
349
+
350
+ case "color":
351
+ {
352
+ const color = tree.color.replace(/katex-/, "");
353
+ buildRegion(a11yStrings, regionStrings => {
354
+ regionStrings.push("start color " + color);
355
+ buildA11yStrings(tree.body, regionStrings, atomType);
356
+ regionStrings.push("end color " + color);
357
+ });
358
+ break;
359
+ }
360
+
361
+ case "color-token":
362
+ {
363
+ // Used by \color, \colorbox, and \fcolorbox but not directly rendered.
364
+ // It's a leaf node and has no children so just break.
365
+ break;
366
+ }
367
+
368
+ case "delimsizing":
369
+ {
370
+ if (tree.delim && tree.delim !== ".") {
371
+ buildString(tree.delim, "normal", a11yStrings);
372
+ }
373
+
374
+ break;
375
+ }
376
+
377
+ case "genfrac":
378
+ {
379
+ buildRegion(a11yStrings, regionStrings => {
380
+ // genfrac can have unbalanced delimiters
381
+ const {
382
+ leftDelim,
383
+ rightDelim
384
+ } = tree; // NOTE: Not sure if this is a safe assumption
385
+ // hasBarLine true -> fraction, false -> binomial
386
+
387
+ if (tree.hasBarLine) {
388
+ regionStrings.push("start fraction");
389
+ leftDelim && buildString(leftDelim, "open", regionStrings);
390
+ buildA11yStrings(tree.numer, regionStrings, atomType);
391
+ regionStrings.push("divided by");
392
+ buildA11yStrings(tree.denom, regionStrings, atomType);
393
+ rightDelim && buildString(rightDelim, "close", regionStrings);
394
+ regionStrings.push("end fraction");
395
+ } else {
396
+ regionStrings.push("start binomial");
397
+ leftDelim && buildString(leftDelim, "open", regionStrings);
398
+ buildA11yStrings(tree.numer, regionStrings, atomType);
399
+ regionStrings.push("over");
400
+ buildA11yStrings(tree.denom, regionStrings, atomType);
401
+ rightDelim && buildString(rightDelim, "close", regionStrings);
402
+ regionStrings.push("end binomial");
403
+ }
404
+ });
405
+ break;
406
+ }
407
+
408
+ case "hbox":
409
+ {
410
+ buildA11yStrings(tree.body, a11yStrings, atomType);
411
+ break;
412
+ }
413
+
414
+ case "kern":
415
+ {
416
+ // No op: we don't attempt to present kerning information
417
+ // to the screen reader.
418
+ break;
419
+ }
420
+
421
+ case "leftright":
422
+ {
423
+ buildRegion(a11yStrings, regionStrings => {
424
+ buildString(tree.left, "open", regionStrings);
425
+ buildA11yStrings(tree.body, regionStrings, atomType);
426
+ buildString(tree.right, "close", regionStrings);
427
+ });
428
+ break;
429
+ }
430
+
431
+ case "leftright-right":
432
+ {
433
+ // TODO: double check that this is a no-op
434
+ break;
435
+ }
436
+
437
+ case "lap":
438
+ {
439
+ buildA11yStrings(tree.body, a11yStrings, atomType);
440
+ break;
441
+ }
442
+
443
+ case "mathord":
444
+ {
445
+ buildString(tree.text, "normal", a11yStrings);
446
+ break;
447
+ }
448
+
449
+ case "op":
450
+ {
451
+ const {
452
+ body,
453
+ name
454
+ } = tree;
455
+
456
+ if (body) {
457
+ buildA11yStrings(body, a11yStrings, atomType);
458
+ } else if (name) {
459
+ buildString(name, "normal", a11yStrings);
460
+ }
461
+
462
+ break;
463
+ }
464
+
465
+ case "op-token":
466
+ {
467
+ // Used internally by operator symbols.
468
+ buildString(tree.text, atomType, a11yStrings);
469
+ break;
470
+ }
471
+
472
+ case "ordgroup":
473
+ {
474
+ buildA11yStrings(tree.body, a11yStrings, atomType);
475
+ break;
476
+ }
477
+
478
+ case "overline":
479
+ {
480
+ buildRegion(a11yStrings, function (a11yStrings) {
481
+ a11yStrings.push("start overline");
482
+ buildA11yStrings(tree.body, a11yStrings, atomType);
483
+ a11yStrings.push("end overline");
484
+ });
485
+ break;
486
+ }
487
+
488
+ case "pmb":
489
+ {
490
+ a11yStrings.push("bold");
491
+ break;
492
+ }
493
+
494
+ case "phantom":
495
+ {
496
+ a11yStrings.push("empty space");
497
+ break;
498
+ }
499
+
500
+ case "raisebox":
501
+ {
502
+ buildA11yStrings(tree.body, a11yStrings, atomType);
503
+ break;
504
+ }
505
+
506
+ case "rule":
507
+ {
508
+ a11yStrings.push("rectangle");
509
+ break;
510
+ }
511
+
512
+ case "sizing":
513
+ {
514
+ buildA11yStrings(tree.body, a11yStrings, atomType);
515
+ break;
516
+ }
517
+
518
+ case "spacing":
519
+ {
520
+ a11yStrings.push("space");
521
+ break;
522
+ }
523
+
524
+ case "styling":
525
+ {
526
+ // We ignore the styling and just pass through the contents
527
+ buildA11yStrings(tree.body, a11yStrings, atomType);
528
+ break;
529
+ }
530
+
531
+ case "sqrt":
532
+ {
533
+ buildRegion(a11yStrings, regionStrings => {
534
+ const {
535
+ body,
536
+ index
537
+ } = tree;
538
+
539
+ if (index) {
540
+ const indexString = flatten(buildA11yStrings(index, [], atomType)).join(",");
541
+
542
+ if (indexString === "3") {
543
+ regionStrings.push("cube root of");
544
+ buildA11yStrings(body, regionStrings, atomType);
545
+ regionStrings.push("end cube root");
546
+ return;
547
+ }
548
+
549
+ regionStrings.push("root");
550
+ regionStrings.push("start index");
551
+ buildA11yStrings(index, regionStrings, atomType);
552
+ regionStrings.push("end index");
553
+ return;
554
+ }
555
+
556
+ regionStrings.push("square root of");
557
+ buildA11yStrings(body, regionStrings, atomType);
558
+ regionStrings.push("end square root");
559
+ });
560
+ break;
561
+ }
562
+
563
+ case "supsub":
564
+ {
565
+ const {
566
+ base,
567
+ sub,
568
+ sup
569
+ } = tree;
570
+ let isLog = false;
571
+
572
+ if (base) {
573
+ buildA11yStrings(base, a11yStrings, atomType);
574
+ isLog = base.type === "op" && base.name === "\\log";
575
+ }
576
+
577
+ if (sub) {
578
+ const regionName = isLog ? "base" : "subscript";
579
+ buildRegion(a11yStrings, function (regionStrings) {
580
+ regionStrings.push("start " + regionName);
581
+ buildA11yStrings(sub, regionStrings, atomType);
582
+ regionStrings.push("end " + regionName);
583
+ });
584
+ }
585
+
586
+ if (sup) {
587
+ buildRegion(a11yStrings, function (regionStrings) {
588
+ const supString = flatten(buildA11yStrings(sup, [], atomType)).join(",");
589
+
590
+ if (supString in powerMap) {
591
+ regionStrings.push(powerMap[supString]);
592
+ return;
593
+ }
594
+
595
+ regionStrings.push("start superscript");
596
+ buildA11yStrings(sup, regionStrings, atomType);
597
+ regionStrings.push("end superscript");
598
+ });
599
+ }
600
+
601
+ break;
602
+ }
603
+
604
+ case "text":
605
+ {
606
+ // TODO: handle other fonts
607
+ if (tree.font === "\\textbf") {
608
+ buildRegion(a11yStrings, function (regionStrings) {
609
+ regionStrings.push("start bold text");
610
+ buildA11yStrings(tree.body, regionStrings, atomType);
611
+ regionStrings.push("end bold text");
612
+ });
613
+ break;
614
+ }
615
+
616
+ buildRegion(a11yStrings, function (regionStrings) {
617
+ regionStrings.push("start text");
618
+ buildA11yStrings(tree.body, regionStrings, atomType);
619
+ regionStrings.push("end text");
620
+ });
621
+ break;
622
+ }
623
+
624
+ case "textord":
625
+ {
626
+ buildString(tree.text, atomType, a11yStrings);
627
+ break;
628
+ }
629
+
630
+ case "smash":
631
+ {
632
+ buildA11yStrings(tree.body, a11yStrings, atomType);
633
+ break;
634
+ }
635
+
636
+ case "enclose":
637
+ {
638
+ // TODO: create a map for these.
639
+ // TODO: differentiate between a body with a single atom, e.g.
640
+ // "cancel a" instead of "start cancel, a, end cancel"
641
+ if (/cancel/.test(tree.label)) {
642
+ buildRegion(a11yStrings, function (regionStrings) {
643
+ regionStrings.push("start cancel");
644
+ buildA11yStrings(tree.body, regionStrings, atomType);
645
+ regionStrings.push("end cancel");
646
+ });
647
+ break;
648
+ } else if (/box/.test(tree.label)) {
649
+ buildRegion(a11yStrings, function (regionStrings) {
650
+ regionStrings.push("start box");
651
+ buildA11yStrings(tree.body, regionStrings, atomType);
652
+ regionStrings.push("end box");
653
+ });
654
+ break;
655
+ } else if (/sout/.test(tree.label)) {
656
+ buildRegion(a11yStrings, function (regionStrings) {
657
+ regionStrings.push("start strikeout");
658
+ buildA11yStrings(tree.body, regionStrings, atomType);
659
+ regionStrings.push("end strikeout");
660
+ });
661
+ break;
662
+ } else if (/phase/.test(tree.label)) {
663
+ buildRegion(a11yStrings, function (regionStrings) {
664
+ regionStrings.push("start phase angle");
665
+ buildA11yStrings(tree.body, regionStrings, atomType);
666
+ regionStrings.push("end phase angle");
667
+ });
668
+ break;
669
+ }
670
+
671
+ throw new Error("KaTeX-a11y: enclose node with " + tree.label + " not supported yet");
672
+ }
673
+
674
+ case "vcenter":
675
+ {
676
+ buildA11yStrings(tree.body, a11yStrings, atomType);
677
+ break;
678
+ }
679
+
680
+ case "vphantom":
681
+ {
682
+ throw new Error("KaTeX-a11y: vphantom not implemented yet");
683
+ }
684
+
685
+ case "hphantom":
686
+ {
687
+ throw new Error("KaTeX-a11y: hphantom not implemented yet");
688
+ }
689
+
690
+ case "operatorname":
691
+ {
692
+ buildA11yStrings(tree.body, a11yStrings, atomType);
693
+ break;
694
+ }
695
+
696
+ case "array":
697
+ {
698
+ throw new Error("KaTeX-a11y: array not implemented yet");
699
+ }
700
+
701
+ case "raw":
702
+ {
703
+ throw new Error("KaTeX-a11y: raw not implemented yet");
704
+ }
705
+
706
+ case "size":
707
+ {
708
+ // Although there are nodes of type "size" in the parse tree, they have
709
+ // no semantic meaning and should be ignored.
710
+ break;
711
+ }
712
+
713
+ case "url":
714
+ {
715
+ throw new Error("KaTeX-a11y: url not implemented yet");
716
+ }
717
+
718
+ case "tag":
719
+ {
720
+ throw new Error("KaTeX-a11y: tag not implemented yet");
721
+ }
722
+
723
+ case "verb":
724
+ {
725
+ buildString("start verbatim", "normal", a11yStrings);
726
+ buildString(tree.body, "normal", a11yStrings);
727
+ buildString("end verbatim", "normal", a11yStrings);
728
+ break;
729
+ }
730
+
731
+ case "environment":
732
+ {
733
+ throw new Error("KaTeX-a11y: environment not implemented yet");
734
+ }
735
+
736
+ case "horizBrace":
737
+ {
738
+ buildString("start " + tree.label.slice(1), "normal", a11yStrings);
739
+ buildA11yStrings(tree.base, a11yStrings, atomType);
740
+ buildString("end " + tree.label.slice(1), "normal", a11yStrings);
741
+ break;
742
+ }
743
+
744
+ case "infix":
745
+ {
746
+ // All infix nodes are replace with other nodes.
747
+ break;
748
+ }
749
+
750
+ case "includegraphics":
751
+ {
752
+ throw new Error("KaTeX-a11y: includegraphics not implemented yet");
753
+ }
754
+
755
+ case "font":
756
+ {
757
+ // TODO: callout the start/end of specific fonts
758
+ // TODO: map \BBb{N} to "the naturals" or something like that
759
+ buildA11yStrings(tree.body, a11yStrings, atomType);
760
+ break;
761
+ }
762
+
763
+ case "href":
764
+ {
765
+ throw new Error("KaTeX-a11y: href not implemented yet");
766
+ }
767
+
768
+ case "cr":
769
+ {
770
+ // This is used by environments.
771
+ throw new Error("KaTeX-a11y: cr not implemented yet");
772
+ }
773
+
774
+ case "underline":
775
+ {
776
+ buildRegion(a11yStrings, function (a11yStrings) {
777
+ a11yStrings.push("start underline");
778
+ buildA11yStrings(tree.body, a11yStrings, atomType);
779
+ a11yStrings.push("end underline");
780
+ });
781
+ break;
782
+ }
783
+
784
+ case "xArrow":
785
+ {
786
+ throw new Error("KaTeX-a11y: xArrow not implemented yet");
787
+ }
788
+
789
+ case "cdlabel":
790
+ {
791
+ throw new Error("KaTeX-a11y: cdlabel not implemented yet");
792
+ }
793
+
794
+ case "cdlabelparent":
795
+ {
796
+ throw new Error("KaTeX-a11y: cdlabelparent not implemented yet");
797
+ }
798
+
799
+ case "mclass":
800
+ {
801
+ // \neq and \ne are macros so we let "htmlmathml" render the mathmal
802
+ // side of things and extract the text from that.
803
+ const atomType = tree.mclass.slice(1); // $FlowFixMe: drop the leading "m" from the values in mclass
804
+
805
+ buildA11yStrings(tree.body, a11yStrings, atomType);
806
+ break;
807
+ }
808
+
809
+ case "mathchoice":
810
+ {
811
+ // TODO: track which style we're using, e.g. display, text, etc.
812
+ // default to text style if even that may not be the correct style
813
+ buildA11yStrings(tree.text, a11yStrings, atomType);
814
+ break;
815
+ }
816
+
817
+ case "htmlmathml":
818
+ {
819
+ buildA11yStrings(tree.mathml, a11yStrings, atomType);
820
+ break;
821
+ }
822
+
823
+ case "middle":
824
+ {
825
+ buildString(tree.delim, atomType, a11yStrings);
826
+ break;
827
+ }
828
+
829
+ case "internal":
830
+ {
831
+ // internal nodes are never included in the parse tree
832
+ break;
833
+ }
834
+
835
+ case "html":
836
+ {
837
+ buildA11yStrings(tree.body, a11yStrings, atomType);
838
+ break;
839
+ }
840
+
841
+ default:
842
+ tree.type;
843
+ throw new Error("KaTeX a11y un-recognized type: " + tree.type);
844
+ }
845
+ };
846
+
847
+ const buildA11yStrings = function (tree, a11yStrings, atomType) {
848
+ if (a11yStrings === void 0) {
849
+ a11yStrings = [];
850
+ }
851
+
852
+ if (tree instanceof Array) {
853
+ for (let i = 0; i < tree.length; i++) {
854
+ buildA11yStrings(tree[i], a11yStrings, atomType);
855
+ }
856
+ } else {
857
+ handleObject(tree, a11yStrings, atomType);
858
+ }
859
+
860
+ return a11yStrings;
861
+ };
862
+
863
+ const flatten = function (array) {
864
+ let result = [];
865
+ array.forEach(function (item) {
866
+ if (item instanceof Array) {
867
+ result = result.concat(flatten(item));
868
+ } else {
869
+ result.push(item);
870
+ }
871
+ });
872
+ return result;
873
+ };
874
+
875
+ const renderA11yString = function (text, settings) {
876
+ const tree = katex__WEBPACK_IMPORTED_MODULE_0___default().__parse(text, settings);
877
+
878
+ const a11yStrings = buildA11yStrings(tree, [], "normal");
879
+ return flatten(a11yStrings).join(", ");
880
+ };
881
+
882
+ /* harmony default export */ __webpack_exports__["default"] = (renderA11yString);
883
+ __webpack_exports__ = __webpack_exports__["default"];
884
+ /******/ return __webpack_exports__;
885
+ /******/ })()
886
+ ;
887
+ });