@fileverse-dev/fortune-core 1.0.4 → 1.0.6

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 (346) hide show
  1. package/{dist/packages/core/src → es}/api/cell.d.ts +10 -10
  2. package/es/api/cell.js +204 -0
  3. package/{dist/packages/core/src → es}/api/common.d.ts +66 -66
  4. package/es/api/common.js +79 -0
  5. package/{dist/packages/core/src → es}/api/errors.d.ts +2 -2
  6. package/es/api/errors.js +2 -0
  7. package/{dist/packages/core/src → es}/api/index.d.ts +9 -9
  8. package/es/api/index.js +8 -0
  9. package/{dist/packages/core/src → es}/api/merge.d.ts +5 -5
  10. package/es/api/merge.js +15 -0
  11. package/{dist/packages/core/src → es}/api/range.d.ts +22 -22
  12. package/es/api/range.js +123 -0
  13. package/{dist/packages/core/src → es}/api/rowcol.d.ts +14 -14
  14. package/es/api/rowcol.js +207 -0
  15. package/{dist/packages/core/src → es}/api/sheet.d.ts +10 -10
  16. package/es/api/sheet.js +128 -0
  17. package/{dist/packages/core/src → es}/api/workbook.d.ts +15 -15
  18. package/es/api/workbook.js +85 -0
  19. package/{dist/packages/core/src → es}/canvas.d.ts +46 -46
  20. package/es/canvas.js +1350 -0
  21. package/{dist/packages/core/src → es}/context.d.ts +197 -197
  22. package/es/context.js +380 -0
  23. package/{dist/packages/core/src → es}/events/copy.d.ts +2 -2
  24. package/es/events/copy.js +78 -0
  25. package/{dist/packages/core/src → es}/events/index.d.ts +4 -4
  26. package/es/events/index.js +4 -0
  27. package/{dist/packages/core/src → es}/events/keyboard.d.ts +6 -6
  28. package/es/events/keyboard.js +332 -0
  29. package/{dist/packages/core/src → es}/events/mouse.d.ts +22 -22
  30. package/es/events/mouse.js +1725 -0
  31. package/{dist/packages/core/src → es}/events/paste.d.ts +3 -3
  32. package/es/events/paste.js +1358 -0
  33. package/{dist/packages/core/src → es}/index.d.ts +10 -10
  34. package/es/index.js +10 -0
  35. package/{dist/packages/core/src → es}/locale/en.d.ts +992 -992
  36. package/es/locale/en.js +10564 -0
  37. package/{dist/packages/core/src → es}/locale/es.d.ts +1134 -1134
  38. package/es/locale/es.js +10010 -0
  39. package/{dist/packages/core/src → es}/locale/hi.d.ts +1030 -1030
  40. package/es/locale/hi.js +10550 -0
  41. package/{dist/packages/core/src → es}/locale/index.d.ts +1049 -1049
  42. package/es/locale/index.js +23 -0
  43. package/{dist/packages/core/src → es}/locale/zh.d.ts +1048 -1048
  44. package/es/locale/zh.js +10568 -0
  45. package/{dist/packages/core/src → es}/locale/zh_tw.d.ts +1187 -1187
  46. package/es/locale/zh_tw.js +10072 -0
  47. package/{dist/packages/core/src → es}/modules/ConditionFormat.d.ts +17 -17
  48. package/es/modules/ConditionFormat.js +1258 -0
  49. package/{dist/packages/core/src → es}/modules/border.d.ts +3 -3
  50. package/es/modules/border.js +1240 -0
  51. package/{dist/packages/core/src → es}/modules/cell.d.ts +32 -32
  52. package/es/modules/cell.js +1055 -0
  53. package/{dist/packages/core/src → es}/modules/clipboard.d.ts +3 -3
  54. package/es/modules/clipboard.js +36 -0
  55. package/{dist/packages/core/src → es}/modules/color.d.ts +1 -1
  56. package/es/modules/color.js +1 -0
  57. package/{dist/packages/core/src → es}/modules/comment.d.ts +97 -97
  58. package/es/modules/comment.js +597 -0
  59. package/{dist/packages/core/src → es}/modules/conditionalFormat.d.ts +2 -2
  60. package/es/modules/conditionalFormat.js +441 -0
  61. package/{dist/packages/core/src → es}/modules/cursor.d.ts +3 -3
  62. package/es/modules/cursor.js +62 -0
  63. package/{dist/packages/core/src → es}/modules/dataVerification.d.ts +11 -11
  64. package/es/modules/dataVerification.js +700 -0
  65. package/{dist/packages/core/src → es}/modules/dropCell.d.ts +10 -10
  66. package/es/modules/dropCell.js +2266 -0
  67. package/{dist/packages/core/src → es}/modules/filter.d.ts +45 -45
  68. package/es/modules/filter.js +434 -0
  69. package/{dist/packages/core/src → es}/modules/format.d.ts +6 -6
  70. package/es/modules/format.js +323 -0
  71. package/{dist/packages/core/src → es}/modules/formula.d.ts +54 -54
  72. package/es/modules/formula.js +2301 -0
  73. package/{dist/packages/core/src → es}/modules/freeze.d.ts +5 -5
  74. package/es/modules/freeze.js +148 -0
  75. package/{dist/packages/core/src → es}/modules/hyperlink.d.ts +21 -21
  76. package/es/modules/hyperlink.js +216 -0
  77. package/{dist/packages/core/src → es}/modules/iframe.d.ts +12 -12
  78. package/es/modules/iframe.js +220 -0
  79. package/{dist/packages/core/src → es}/modules/image.d.ts +31 -31
  80. package/es/modules/image.js +253 -0
  81. package/{dist/packages/core/src → es}/modules/index.d.ts +36 -36
  82. package/es/modules/index.js +36 -0
  83. package/{dist/packages/core/src → es}/modules/inline-string.d.ts +36 -36
  84. package/es/modules/inline-string.js +437 -0
  85. package/{dist/packages/core/src → es}/modules/location.d.ts +6 -6
  86. package/es/modules/location.js +46 -0
  87. package/{dist/packages/core/src → es}/modules/locationCondition.d.ts +21 -21
  88. package/es/modules/locationCondition.js +218 -0
  89. package/{dist/packages/core/src → es}/modules/merge.d.ts +3 -3
  90. package/es/modules/merge.js +216 -0
  91. package/{dist/packages/core/src → es}/modules/mobile.d.ts +5 -5
  92. package/es/modules/mobile.js +33 -0
  93. package/{dist/packages/core/src → es}/modules/moveCells.d.ts +5 -5
  94. package/es/modules/moveCells.js +348 -0
  95. package/{dist/packages/core/src → es}/modules/protection.d.ts +5 -5
  96. package/es/modules/protection.js +96 -0
  97. package/{dist/packages/core/src → es}/modules/refresh.d.ts +3 -3
  98. package/es/modules/refresh.js +34 -0
  99. package/{dist/packages/core/src → es}/modules/rowcol.d.ts +19 -19
  100. package/es/modules/rowcol.js +1922 -0
  101. package/{dist/packages/core/src → es}/modules/screenshot.d.ts +2 -2
  102. package/es/modules/screenshot.js +90 -0
  103. package/{dist/packages/core/src → es}/modules/searchReplace.d.ts +36 -36
  104. package/es/modules/searchReplace.js +388 -0
  105. package/{dist/packages/core/src → es}/modules/selection.d.ts +46 -46
  106. package/es/modules/selection.js +1674 -0
  107. package/{dist/packages/core/src → es}/modules/sheet.d.ts +10 -10
  108. package/es/modules/sheet.js +237 -0
  109. package/{dist/packages/core/src → es}/modules/sort.d.ts +7 -7
  110. package/es/modules/sort.js +150 -0
  111. package/{dist/packages/core/src → es}/modules/splitColumn.d.ts +5 -5
  112. package/es/modules/splitColumn.js +126 -0
  113. package/es/modules/ssf.js +1533 -0
  114. package/{dist/packages/core/src → es}/modules/text.d.ts +10 -10
  115. package/es/modules/text.js +1207 -0
  116. package/{dist/packages/core/src → es}/modules/toolbar.d.ts +32 -32
  117. package/es/modules/toolbar.js +970 -0
  118. package/{dist/packages/core/src → es}/modules/validation.d.ts +19 -19
  119. package/es/modules/validation.js +190 -0
  120. package/{dist/packages/core/src → es}/modules/zoom.d.ts +3 -3
  121. package/es/modules/zoom.js +29 -0
  122. package/{dist/packages/core/src → es}/settings.d.ts +100 -100
  123. package/es/settings.js +36 -0
  124. package/{dist/packages/core/src → es}/types.d.ts +371 -371
  125. package/es/types.js +1 -0
  126. package/{dist/packages/core/src → es}/utils/freeze.d.ts +7 -7
  127. package/es/utils/freeze.js +86 -0
  128. package/{dist/packages/core/src → es}/utils/index.d.ts +18 -18
  129. package/es/utils/index.js +173 -0
  130. package/{dist/packages/core/src → es}/utils/patch.d.ts +37 -37
  131. package/es/utils/patch.js +381 -0
  132. package/lib/api/cell.d.ts +10 -0
  133. package/lib/api/cell.js +215 -0
  134. package/lib/api/common.d.ts +66 -0
  135. package/lib/api/common.js +88 -0
  136. package/lib/api/errors.d.ts +2 -0
  137. package/lib/api/errors.js +8 -0
  138. package/lib/api/index.d.ts +9 -0
  139. package/lib/api/index.js +101 -0
  140. package/lib/api/merge.d.ts +5 -0
  141. package/lib/api/merge.js +22 -0
  142. package/lib/api/range.d.ts +22 -0
  143. package/lib/api/range.js +138 -0
  144. package/lib/api/rowcol.d.ts +14 -0
  145. package/lib/api/rowcol.js +222 -0
  146. package/lib/api/sheet.d.ts +10 -0
  147. package/lib/api/sheet.js +145 -0
  148. package/lib/api/workbook.d.ts +15 -0
  149. package/lib/api/workbook.js +98 -0
  150. package/lib/canvas.d.ts +46 -0
  151. package/lib/canvas.js +1356 -0
  152. package/lib/context.d.ts +197 -0
  153. package/lib/context.js +392 -0
  154. package/lib/events/copy.d.ts +2 -0
  155. package/lib/events/copy.js +85 -0
  156. package/lib/events/index.d.ts +4 -0
  157. package/lib/events/index.js +49 -0
  158. package/lib/events/keyboard.d.ts +6 -0
  159. package/lib/events/keyboard.js +342 -0
  160. package/lib/events/mouse.d.ts +22 -0
  161. package/lib/events/mouse.js +1744 -0
  162. package/lib/events/paste.d.ts +3 -0
  163. package/lib/events/paste.js +1366 -0
  164. package/lib/index.d.ts +10 -0
  165. package/lib/index.js +109 -0
  166. package/lib/locale/en.d.ts +992 -0
  167. package/lib/locale/en.js +10570 -0
  168. package/lib/locale/es.d.ts +1134 -0
  169. package/lib/locale/es.js +10016 -0
  170. package/lib/locale/hi.d.ts +1030 -0
  171. package/lib/locale/hi.js +10556 -0
  172. package/lib/locale/index.d.ts +1049 -0
  173. package/lib/locale/index.js +29 -0
  174. package/lib/locale/zh.d.ts +1048 -0
  175. package/lib/locale/zh.js +10574 -0
  176. package/lib/locale/zh_tw.d.ts +1187 -0
  177. package/lib/locale/zh_tw.js +10078 -0
  178. package/lib/modules/ConditionFormat.d.ts +17 -0
  179. package/lib/modules/ConditionFormat.js +1273 -0
  180. package/lib/modules/border.d.ts +3 -0
  181. package/lib/modules/border.js +1248 -0
  182. package/lib/modules/cell.d.ts +32 -0
  183. package/lib/modules/cell.js +1085 -0
  184. package/lib/modules/clipboard.d.ts +3 -0
  185. package/lib/modules/clipboard.js +42 -0
  186. package/lib/modules/color.d.ts +1 -0
  187. package/lib/modules/color.js +7 -0
  188. package/lib/modules/comment.d.ts +97 -0
  189. package/lib/modules/comment.js +625 -0
  190. package/lib/modules/conditionalFormat.d.ts +2 -0
  191. package/lib/modules/conditionalFormat.js +447 -0
  192. package/lib/modules/cursor.d.ts +3 -0
  193. package/lib/modules/cursor.js +70 -0
  194. package/lib/modules/dataVerification.d.ts +11 -0
  195. package/lib/modules/dataVerification.js +715 -0
  196. package/lib/modules/dropCell.d.ts +10 -0
  197. package/lib/modules/dropCell.js +2282 -0
  198. package/lib/modules/filter.d.ts +45 -0
  199. package/lib/modules/filter.js +448 -0
  200. package/lib/modules/format.d.ts +6 -0
  201. package/lib/modules/format.js +334 -0
  202. package/lib/modules/formula.d.ts +54 -0
  203. package/lib/modules/formula.js +2330 -0
  204. package/lib/modules/freeze.d.ts +5 -0
  205. package/lib/modules/freeze.js +158 -0
  206. package/lib/modules/hyperlink.d.ts +21 -0
  207. package/lib/modules/hyperlink.js +232 -0
  208. package/lib/modules/iframe.d.ts +12 -0
  209. package/lib/modules/iframe.js +236 -0
  210. package/lib/modules/image.d.ts +31 -0
  211. package/lib/modules/image.js +272 -0
  212. package/lib/modules/index.d.ts +36 -0
  213. package/lib/modules/index.js +401 -0
  214. package/lib/modules/inline-string.d.ts +36 -0
  215. package/lib/modules/inline-string.js +452 -0
  216. package/lib/modules/location.d.ts +6 -0
  217. package/lib/modules/location.js +57 -0
  218. package/lib/modules/locationCondition.d.ts +21 -0
  219. package/lib/modules/locationCondition.js +229 -0
  220. package/lib/modules/merge.d.ts +3 -0
  221. package/lib/modules/merge.js +223 -0
  222. package/lib/modules/mobile.d.ts +5 -0
  223. package/lib/modules/mobile.js +41 -0
  224. package/lib/modules/moveCells.d.ts +5 -0
  225. package/lib/modules/moveCells.js +357 -0
  226. package/lib/modules/protection.d.ts +5 -0
  227. package/lib/modules/protection.js +106 -0
  228. package/lib/modules/refresh.d.ts +3 -0
  229. package/lib/modules/refresh.js +40 -0
  230. package/lib/modules/rowcol.d.ts +19 -0
  231. package/lib/modules/rowcol.js +1935 -0
  232. package/lib/modules/screenshot.d.ts +2 -0
  233. package/lib/modules/screenshot.js +96 -0
  234. package/lib/modules/searchReplace.d.ts +36 -0
  235. package/lib/modules/searchReplace.js +402 -0
  236. package/lib/modules/selection.d.ts +46 -0
  237. package/lib/modules/selection.js +1703 -0
  238. package/lib/modules/sheet.d.ts +10 -0
  239. package/lib/modules/sheet.js +250 -0
  240. package/lib/modules/sort.d.ts +7 -0
  241. package/lib/modules/sort.js +159 -0
  242. package/lib/modules/splitColumn.d.ts +5 -0
  243. package/lib/modules/splitColumn.js +136 -0
  244. package/lib/modules/ssf.js +1539 -0
  245. package/lib/modules/text.d.ts +10 -0
  246. package/lib/modules/text.js +1221 -0
  247. package/lib/modules/toolbar.d.ts +32 -0
  248. package/lib/modules/toolbar.js +1003 -0
  249. package/lib/modules/validation.d.ts +19 -0
  250. package/lib/modules/validation.js +205 -0
  251. package/lib/modules/zoom.d.ts +3 -0
  252. package/lib/modules/zoom.js +36 -0
  253. package/lib/settings.d.ts +100 -0
  254. package/lib/settings.js +42 -0
  255. package/lib/types.d.ts +371 -0
  256. package/lib/types.js +5 -0
  257. package/lib/utils/freeze.d.ts +7 -0
  258. package/lib/utils/freeze.js +92 -0
  259. package/lib/utils/index.d.ts +18 -0
  260. package/lib/utils/index.js +231 -0
  261. package/lib/utils/patch.d.ts +37 -0
  262. package/lib/utils/patch.js +392 -0
  263. package/package.json +7 -6
  264. package/dist/index.esm.js +0 -80255
  265. package/dist/index.js +0 -80601
  266. package/dist/packages/react/src/components/ChangeColor/index.d.ts +0 -7
  267. package/dist/packages/react/src/components/ConditionFormat/ConditionRules.d.ts +0 -6
  268. package/dist/packages/react/src/components/ConditionFormat/index.d.ts +0 -7
  269. package/dist/packages/react/src/components/ContextMenu/Divider.d.ts +0 -3
  270. package/dist/packages/react/src/components/ContextMenu/FilterMenu.d.ts +0 -3
  271. package/dist/packages/react/src/components/ContextMenu/Menu.d.ts +0 -8
  272. package/dist/packages/react/src/components/ContextMenu/SheetTab.d.ts +0 -4
  273. package/dist/packages/react/src/components/ContextMenu/index.d.ts +0 -5
  274. package/dist/packages/react/src/components/CustomSort/index.d.ts +0 -4
  275. package/dist/packages/react/src/components/DataVerification/DropdownList.d.ts +0 -4
  276. package/dist/packages/react/src/components/DataVerification/RangeDialog.d.ts +0 -4
  277. package/dist/packages/react/src/components/DataVerification/getDisplayedRangeTxt.d.ts +0 -2
  278. package/dist/packages/react/src/components/DataVerification/index.d.ts +0 -4
  279. package/dist/packages/react/src/components/Dialog/index.d.ts +0 -15
  280. package/dist/packages/react/src/components/DuneChartsInputModal/DuneChartsInputModal.d.ts +0 -11
  281. package/dist/packages/react/src/components/DunePreview/DunePreview.d.ts +0 -13
  282. package/dist/packages/react/src/components/FilterOption/index.d.ts +0 -5
  283. package/dist/packages/react/src/components/FormatSearch/index.d.ts +0 -6
  284. package/dist/packages/react/src/components/FormulaSearch/index.d.ts +0 -5
  285. package/dist/packages/react/src/components/FxEditor/NameBox.d.ts +0 -3
  286. package/dist/packages/react/src/components/FxEditor/index.d.ts +0 -4
  287. package/dist/packages/react/src/components/IFrameBoxs/iFrameBoxs.d.ts +0 -4
  288. package/dist/packages/react/src/components/ImgBoxs/index.d.ts +0 -3
  289. package/dist/packages/react/src/components/LinkEidtCard/index.d.ts +0 -5
  290. package/dist/packages/react/src/components/LocationCondition/index.d.ts +0 -3
  291. package/dist/packages/react/src/components/MessageBox/index.d.ts +0 -9
  292. package/dist/packages/react/src/components/NotationBoxes/index.d.ts +0 -3
  293. package/dist/packages/react/src/components/ResetColumnWidth/index.d.ts +0 -2
  294. package/dist/packages/react/src/components/SVGDefines.d.ts +0 -5
  295. package/dist/packages/react/src/components/SVGIcon.d.ts +0 -9
  296. package/dist/packages/react/src/components/SearchReplace/index.d.ts +0 -6
  297. package/dist/packages/react/src/components/Sheet/index.d.ts +0 -8
  298. package/dist/packages/react/src/components/SheetList/SheetHiddenButton.d.ts +0 -8
  299. package/dist/packages/react/src/components/SheetList/SheetListItem.d.ts +0 -9
  300. package/dist/packages/react/src/components/SheetList/index.d.ts +0 -4
  301. package/dist/packages/react/src/components/SheetOverlay/ColumnHeader.d.ts +0 -3
  302. package/dist/packages/react/src/components/SheetOverlay/ContentEditable.d.ts +0 -11
  303. package/dist/packages/react/src/components/SheetOverlay/FormulaHint/index.d.ts +0 -4
  304. package/dist/packages/react/src/components/SheetOverlay/FormulaSearch/constant.d.ts +0 -63
  305. package/dist/packages/react/src/components/SheetOverlay/FormulaSearch/index.d.ts +0 -4
  306. package/dist/packages/react/src/components/SheetOverlay/InputBox.d.ts +0 -3
  307. package/dist/packages/react/src/components/SheetOverlay/RowHeader.d.ts +0 -3
  308. package/dist/packages/react/src/components/SheetOverlay/ScrollBar/index.d.ts +0 -7
  309. package/dist/packages/react/src/components/SheetOverlay/index.d.ts +0 -4
  310. package/dist/packages/react/src/components/SheetTab/SheetItem.d.ts +0 -8
  311. package/dist/packages/react/src/components/SheetTab/index.d.ts +0 -4
  312. package/dist/packages/react/src/components/SplitColumn/index.d.ts +0 -3
  313. package/dist/packages/react/src/components/Toolbar/Button.d.ts +0 -12
  314. package/dist/packages/react/src/components/Toolbar/ColorPicker.d.ts +0 -6
  315. package/dist/packages/react/src/components/Toolbar/Combo.d.ts +0 -12
  316. package/dist/packages/react/src/components/Toolbar/CustomBorder.d.ts +0 -7
  317. package/dist/packages/react/src/components/Toolbar/CustomButton.d.ts +0 -11
  318. package/dist/packages/react/src/components/Toolbar/CustomColor.d.ts +0 -8
  319. package/dist/packages/react/src/components/Toolbar/CustomIcon.d.ts +0 -9
  320. package/dist/packages/react/src/components/Toolbar/Divider.d.ts +0 -4
  321. package/dist/packages/react/src/components/Toolbar/MoreItemsContainer.d.ts +0 -6
  322. package/dist/packages/react/src/components/Toolbar/Select.d.ts +0 -14
  323. package/dist/packages/react/src/components/Toolbar/index.d.ts +0 -10
  324. package/dist/packages/react/src/components/Workbook/api.d.ts +0 -1177
  325. package/dist/packages/react/src/components/Workbook/index.d.ts +0 -1185
  326. package/dist/packages/react/src/components/ZoomControl/index.d.ts +0 -4
  327. package/dist/packages/react/src/components/index.d.ts +0 -4
  328. package/dist/packages/react/src/constants.d.ts +0 -1
  329. package/dist/packages/react/src/context/index.d.ts +0 -25
  330. package/dist/packages/react/src/context/modal.d.ts +0 -10
  331. package/dist/packages/react/src/hooks/useAlert.d.ts +0 -4
  332. package/dist/packages/react/src/hooks/useDialog.d.ts +0 -5
  333. package/dist/packages/react/src/hooks/useOutsideClick.d.ts +0 -2
  334. package/dist/packages/react/src/hooks/usePrevious.d.ts +0 -2
  335. package/dist/packages/react/src/index.d.ts +0 -1
  336. package/dist/packages/react/src/utils/datepickerStyles.d.ts +0 -2
  337. package/dist/stories/API.stories.d.ts +0 -1210
  338. package/dist/stories/Collabration.stories.d.ts +0 -2359
  339. package/dist/stories/Features.stories.d.ts +0 -9430
  340. package/dist/stories/data/cell.d.ts +0 -983
  341. package/dist/stories/data/dataVerification.d.ts +0 -131
  342. package/dist/stories/data/empty.d.ts +0 -10
  343. package/dist/stories/data/formula.d.ts +0 -362
  344. package/dist/stories/data/freeze.d.ts +0 -34
  345. package/dist/stories/data/protected.d.ts +0 -40
  346. package/dist/stories/utils.d.ts +0 -1
@@ -0,0 +1,1533 @@
1
+ function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
2
+ /* eslint-disable */
3
+ import numeral from "numeral";
4
+ var SSF = {};
5
+ var make_ssf = function make_ssf(SSF) {
6
+ SSF.version = "0.11.2";
7
+ function _strrev(x) {
8
+ var o = "",
9
+ i = x.length - 1;
10
+ while (i >= 0) o += x.charAt(i--);
11
+ return o;
12
+ }
13
+ function fill(c, l) {
14
+ var o = "";
15
+ while (o.length < l) o += c;
16
+ return o;
17
+ }
18
+ function pad0(v, d) {
19
+ var t = "" + v;
20
+ return t.length >= d ? t : fill("0", d - t.length) + t;
21
+ }
22
+ function pad_(v, d) {
23
+ var t = "" + v;
24
+ return t.length >= d ? t : fill(" ", d - t.length) + t;
25
+ }
26
+ function rpad_(v, d) {
27
+ var t = "" + v;
28
+ return t.length >= d ? t : t + fill(" ", d - t.length);
29
+ }
30
+ function pad0r1(v, d) {
31
+ var t = "" + Math.round(v);
32
+ return t.length >= d ? t : fill("0", d - t.length) + t;
33
+ }
34
+ function pad0r2(v, d) {
35
+ var t = "" + v;
36
+ return t.length >= d ? t : fill("0", d - t.length) + t;
37
+ }
38
+ var p2_32 = Math.pow(2, 32);
39
+ function pad0r(v, d) {
40
+ if (v > p2_32 || v < -p2_32) return pad0r1(v, d);
41
+ var i = Math.round(v);
42
+ return pad0r2(i, d);
43
+ }
44
+ function isgeneral(s, i) {
45
+ i = i || 0;
46
+ return s.length >= 7 + i && (s.charCodeAt(i) | 32) === 103 && (s.charCodeAt(i + 1) | 32) === 101 && (s.charCodeAt(i + 2) | 32) === 110 && (s.charCodeAt(i + 3) | 32) === 101 && (s.charCodeAt(i + 4) | 32) === 114 && (s.charCodeAt(i + 5) | 32) === 97 && (s.charCodeAt(i + 6) | 32) === 108;
47
+ }
48
+ var days = [["Sun", "Sunday"], ["Mon", "Monday"], ["Tue", "Tuesday"], ["Wed", "Wednesday"], ["Thu", "Thursday"], ["Fri", "Friday"], ["Sat", "Saturday"]];
49
+ var months = [["J", "Jan", "January"], ["F", "Feb", "February"], ["M", "Mar", "March"], ["A", "Apr", "April"], ["M", "May", "May"], ["J", "Jun", "June"], ["J", "Jul", "July"], ["A", "Aug", "August"], ["S", "Sep", "September"], ["O", "Oct", "October"], ["N", "Nov", "November"], ["D", "Dec", "December"]];
50
+ function init_table(t) {
51
+ t[0] = "General";
52
+ t[1] = "0";
53
+ t[2] = "0.00";
54
+ t[3] = "#,##0";
55
+ t[4] = "#,##0.00";
56
+ t[9] = "0%";
57
+ t[10] = "0.00%";
58
+ t[11] = "0.00E+00";
59
+ t[12] = "# ?/?";
60
+ t[13] = "# ??/??";
61
+ t[14] = "m/d/yy";
62
+ t[15] = "d-mmm-yy";
63
+ t[16] = "d-mmm";
64
+ t[17] = "mmm-yy";
65
+ t[18] = "h:mm AM/PM";
66
+ t[19] = "h:mm:ss AM/PM";
67
+ t[20] = "h:mm";
68
+ t[21] = "h:mm:ss";
69
+ t[22] = "m/d/yy h:mm";
70
+ t[37] = "#,##0 ;(#,##0)";
71
+ t[38] = "#,##0 ;[Red](#,##0)";
72
+ t[39] = "#,##0.00;(#,##0.00)";
73
+ t[40] = "#,##0.00;[Red](#,##0.00)";
74
+ t[45] = "mm:ss";
75
+ t[46] = "[h]:mm:ss";
76
+ t[47] = "mmss.0";
77
+ t[48] = "##0.0E+0";
78
+ t[49] = "@";
79
+ t[56] = '"上午/下午 "hh"時"mm"分"ss"秒 "';
80
+ t[65535] = "General";
81
+ }
82
+ var table_fmt = {};
83
+ init_table(table_fmt);
84
+ /* Defaults determined by systematically testing in Excel 2019 */
85
+ /* These formats appear to default to other formats in the table */
86
+ var default_map = [];
87
+ var defi = 0;
88
+ // 5 -> 37 ... 8 -> 40
89
+ for (defi = 5; defi <= 8; ++defi) default_map[defi] = 32 + defi;
90
+ // 23 -> 0 ... 26 -> 0
91
+ for (defi = 23; defi <= 26; ++defi) default_map[defi] = 0;
92
+ // 27 -> 14 ... 31 -> 14
93
+ for (defi = 27; defi <= 31; ++defi) default_map[defi] = 14;
94
+ // 50 -> 14 ... 58 -> 14
95
+ for (defi = 50; defi <= 58; ++defi) default_map[defi] = 14;
96
+ // 59 -> 1 ... 62 -> 4
97
+ for (defi = 59; defi <= 62; ++defi) default_map[defi] = defi - 58;
98
+ // 67 -> 9 ... 68 -> 10
99
+ for (defi = 67; defi <= 68; ++defi) default_map[defi] = defi - 58;
100
+ // 72 -> 14 ... 75 -> 17
101
+ for (defi = 72; defi <= 75; ++defi) default_map[defi] = defi - 58;
102
+ // 69 -> 12 ... 71 -> 14
103
+ for (defi = 67; defi <= 68; ++defi) default_map[defi] = defi - 57;
104
+ // 76 -> 20 ... 78 -> 22
105
+ for (defi = 76; defi <= 78; ++defi) default_map[defi] = defi - 56;
106
+ // 79 -> 45 ... 81 -> 47
107
+ for (defi = 79; defi <= 81; ++defi) default_map[defi] = defi - 34;
108
+ // 82 -> 0 ... 65536 -> 0 (omitted)
109
+ /* These formats technically refer to Accounting formats with no equivalent */
110
+ var default_str = [];
111
+ // 5 -- Currency, 0 decimal, black negative
112
+ default_str[5] = default_str[63] = '"$"#,##0_);\\("$"#,##0\\)';
113
+ // 6 -- Currency, 0 decimal, red negative
114
+ default_str[6] = default_str[64] = '"$"#,##0_);[Red]\\("$"#,##0\\)';
115
+ // 7 -- Currency, 2 decimal, black negative
116
+ default_str[7] = default_str[65] = '"$"#,##0.00_);\\("$"#,##0.00\\)';
117
+ // 8 -- Currency, 2 decimal, red negative
118
+ default_str[8] = default_str[66] = '"$"#,##0.00_);[Red]\\("$"#,##0.00\\)';
119
+ // 41 -- Accounting, 0 decimal, No Symbol
120
+ default_str[41] = '_(* #,##0_);_(* \\(#,##0\\);_(* "-"_);_(@_)';
121
+ // 42 -- Accounting, 0 decimal, $ Symbol
122
+ default_str[42] = '_("$"* #,##0_);_("$"* \\(#,##0\\);_("$"* "-"_);_(@_)';
123
+ // 43 -- Accounting, 2 decimal, No Symbol
124
+ default_str[43] = '_(* #,##0.00_);_(* \\(#,##0.00\\);_(* "-"??_);_(@_)';
125
+ // 44 -- Accounting, 2 decimal, $ Symbol
126
+ default_str[44] = '_("$"* #,##0.00_);_("$"* \\(#,##0.00\\);_("$"* "-"??_);_(@_)';
127
+ function frac(x, D, mixed) {
128
+ var sgn = x < 0 ? -1 : 1;
129
+ var B = x * sgn;
130
+ var P_2 = 0,
131
+ P_1 = 1,
132
+ P = 0;
133
+ var Q_2 = 1,
134
+ Q_1 = 0,
135
+ Q = 0;
136
+ var A = Math.floor(B);
137
+ while (Q_1 < D) {
138
+ A = Math.floor(B);
139
+ P = A * P_1 + P_2;
140
+ Q = A * Q_1 + Q_2;
141
+ if (B - A < 0.00000005) break;
142
+ B = 1 / (B - A);
143
+ P_2 = P_1;
144
+ P_1 = P;
145
+ Q_2 = Q_1;
146
+ Q_1 = Q;
147
+ }
148
+ if (Q > D) {
149
+ if (Q_1 > D) {
150
+ Q = Q_2;
151
+ P = P_2;
152
+ } else {
153
+ Q = Q_1;
154
+ P = P_1;
155
+ }
156
+ }
157
+ if (!mixed) return [0, sgn * P, Q];
158
+ var q = Math.floor(sgn * P / Q);
159
+ return [q, sgn * P - q * Q, Q];
160
+ }
161
+ function parse_date_code(v, opts, b2) {
162
+ if (v > 2958465 || v < 0) return null;
163
+ var date = v | 0,
164
+ time = Math.floor(86400 * (v - date)),
165
+ dow = 0;
166
+ var dout = [];
167
+ var out = {
168
+ D: date,
169
+ T: time,
170
+ u: 86400 * (v - date) - time,
171
+ y: 0,
172
+ m: 0,
173
+ d: 0,
174
+ H: 0,
175
+ M: 0,
176
+ S: 0,
177
+ q: 0
178
+ };
179
+ if (Math.abs(out.u) < 1e-6) out.u = 0;
180
+ if (opts && opts.date1904) date += 1462;
181
+ if (out.u > 0.9999) {
182
+ out.u = 0;
183
+ if (++time == 86400) {
184
+ out.T = time = 0;
185
+ ++date;
186
+ ++out.D;
187
+ }
188
+ }
189
+ if (date === 60) {
190
+ dout = b2 ? [1317, 10, 29] : [1900, 2, 29];
191
+ dow = 3;
192
+ } else if (date === 0) {
193
+ dout = b2 ? [1317, 8, 29] : [1900, 1, 0];
194
+ dow = 6;
195
+ } else {
196
+ if (date > 60) --date;
197
+ /* 1 = Jan 1 1900 in Gregorian */
198
+ var d = new Date(1900, 0, 1);
199
+ d.setDate(d.getDate() + date - 1);
200
+ dout = [d.getFullYear(), d.getMonth() + 1, d.getDate()];
201
+ dow = d.getDay();
202
+ if (date < 60) dow = (dow + 6) % 7;
203
+ if (b2) dow = fix_hijri(d, dout);
204
+ }
205
+ out.y = dout[0];
206
+ out.m = dout[1];
207
+ out.d = dout[2];
208
+ out.S = time % 60;
209
+ time = Math.floor(time / 60);
210
+ out.M = time % 60;
211
+ time = Math.floor(time / 60);
212
+ out.H = time;
213
+ out.q = dow;
214
+ return out;
215
+ }
216
+ SSF.parse_date_code = parse_date_code;
217
+ var basedate = new Date(1899, 11, 31, 0, 0, 0);
218
+ var dnthresh = basedate.getTime();
219
+ var base1904 = new Date(1900, 2, 1, 0, 0, 0);
220
+ function datenum_local(v, date1904) {
221
+ var epoch = v.getTime();
222
+ if (date1904) epoch -= 1461 * 24 * 60 * 60 * 1000;else if (v >= base1904) epoch += 24 * 60 * 60 * 1000;
223
+ return (epoch - (dnthresh + (v.getTimezoneOffset() - basedate.getTimezoneOffset()) * 60000)) / (24 * 60 * 60 * 1000);
224
+ }
225
+ /* The longest 32-bit integer text is "-4294967296", exactly 11 chars */
226
+ function general_fmt_int(v) {
227
+ return v.toString(10);
228
+ }
229
+ SSF._general_int = general_fmt_int;
230
+ /* ECMA-376 18.8.30 numFmt*/
231
+ /* Note: `toPrecision` uses standard form when prec > E and E >= -6 */
232
+ var general_fmt_num = function make_general_fmt_num() {
233
+ var trailing_zeroes_and_decimal = /(?:\.0*|(\.\d*[1-9])0+)$/;
234
+ function strip_decimal(o) {
235
+ return o.indexOf(".") == -1 ? o : o.replace(trailing_zeroes_and_decimal, "$1");
236
+ }
237
+ /* General Exponential always shows 2 digits exp and trims the mantissa */
238
+ var mantissa_zeroes_and_decimal = /(?:\.0*|(\.\d*[1-9])0+)[Ee]/;
239
+ var exp_with_single_digit = /(E[+-])(\d)$/;
240
+ function normalize_exp(o) {
241
+ if (o.indexOf("E") == -1) return o;
242
+ return o.replace(mantissa_zeroes_and_decimal, "$1E").replace(exp_with_single_digit, "$10$2");
243
+ }
244
+ /* exponent >= -9 and <= 9 */
245
+ function small_exp(v) {
246
+ var w = v < 0 ? 12 : 11;
247
+ var o = strip_decimal(v.toFixed(12));
248
+ if (o.length <= w) return o;
249
+ o = v.toPrecision(10);
250
+ if (o.length <= w) return o;
251
+ return Number(v).toExponential(5);
252
+ }
253
+ /* exponent >= 11 or <= -10 likely exponential */
254
+ function large_exp(v) {
255
+ var o = strip_decimal(v.toFixed(11));
256
+ return o.length > (v < 0 ? 12 : 11) || o === "0" || o === "-0" ? v.toPrecision(6) : o;
257
+ }
258
+ function general_fmt_num_base(v) {
259
+ var V = Math.floor(Math.log(Math.abs(v)) * Math.LOG10E),
260
+ o;
261
+ if (V >= -4 && V <= -1) o = v.toPrecision(10 + V);else if (Math.abs(V) <= 9) o = small_exp(v);else if (V === 10) o = v.toFixed(10).substr(0, 12);else o = large_exp(v);
262
+ return strip_decimal(normalize_exp(o.toUpperCase()));
263
+ }
264
+ return general_fmt_num_base;
265
+ }();
266
+ SSF._general_num = general_fmt_num;
267
+ /*
268
+ "General" rules:
269
+ - text is passed through ("@")
270
+ - booleans are rendered as TRUE/FALSE
271
+ - "up to 11 characters" displayed for numbers
272
+ - Default date format (code 14) used for Dates
273
+ TODO: technically the display depends on the width of the cell
274
+ */
275
+ function general_fmt(v, opts) {
276
+ switch (_typeof(v)) {
277
+ case "string":
278
+ return v;
279
+ case "boolean":
280
+ return v ? "TRUE" : "FALSE";
281
+ case "number":
282
+ return (v | 0) === v ? v.toString(10) : general_fmt_num(v);
283
+ case "undefined":
284
+ return "";
285
+ case "object":
286
+ if (v == null) return "";
287
+ if (v instanceof Date) return format(14, datenum_local(v, opts && opts.date1904), opts);
288
+ }
289
+ throw new Error("unsupported value in General format: " + v);
290
+ }
291
+ SSF._general = general_fmt;
292
+ function fix_hijri(date, o) {
293
+ /* TODO: properly adjust y/m/d and */
294
+ o[0] -= 581;
295
+ var dow = date.getDay();
296
+ if (date < 60) dow = (dow + 6) % 7;
297
+ return dow;
298
+ }
299
+ var THAI_DIGITS = "\u0E50\u0E51\u0E52\u0E53\u0E54\u0E55\u0E56\u0E57\u0E58\u0E59".split("");
300
+ /*jshint -W086 */
301
+ function write_date(type, fmt, val, ss0) {
302
+ var o = "",
303
+ ss = 0,
304
+ tt = 0,
305
+ y = val.y,
306
+ out,
307
+ outl = 0;
308
+ switch (type) {
309
+ case 98:
310
+ /* 'b' buddhist year */y = val.y + 543;
311
+ /* falls through */
312
+ case 121:
313
+ /* 'y' year */switch (fmt.length) {
314
+ case 1:
315
+ case 2:
316
+ out = y % 100;
317
+ outl = 2;
318
+ break;
319
+ default:
320
+ out = y % 10000;
321
+ outl = 4;
322
+ break;
323
+ }
324
+ break;
325
+ case 109:
326
+ /* 'm' month */switch (fmt.length) {
327
+ case 1:
328
+ case 2:
329
+ out = val.m;
330
+ outl = fmt.length;
331
+ break;
332
+ case 3:
333
+ return months[val.m - 1][1];
334
+ case 5:
335
+ return months[val.m - 1][0];
336
+ default:
337
+ return months[val.m - 1][2];
338
+ }
339
+ break;
340
+ case 100:
341
+ /* 'd' day */switch (fmt.length) {
342
+ case 1:
343
+ case 2:
344
+ out = val.d;
345
+ outl = fmt.length;
346
+ break;
347
+ case 3:
348
+ return days[val.q][0];
349
+ default:
350
+ return days[val.q][1];
351
+ }
352
+ break;
353
+ case 104:
354
+ /* 'h' 12-hour */switch (fmt.length) {
355
+ case 1:
356
+ case 2:
357
+ out = 1 + (val.H + 11) % 12;
358
+ outl = fmt.length;
359
+ break;
360
+ default:
361
+ throw "bad hour format: " + fmt;
362
+ }
363
+ break;
364
+ case 72:
365
+ /* 'H' 24-hour */switch (fmt.length) {
366
+ case 1:
367
+ case 2:
368
+ out = val.H;
369
+ outl = fmt.length;
370
+ break;
371
+ default:
372
+ throw "bad hour format: " + fmt;
373
+ }
374
+ break;
375
+ case 77:
376
+ /* 'M' minutes */switch (fmt.length) {
377
+ case 1:
378
+ case 2:
379
+ out = val.M;
380
+ outl = fmt.length;
381
+ break;
382
+ default:
383
+ throw "bad minute format: " + fmt;
384
+ }
385
+ break;
386
+ case 115:
387
+ /* 's' seconds */if (fmt != "s" && fmt != "ss" && fmt != ".0" && fmt != ".00" && fmt != ".000") throw "bad second format: " + fmt;
388
+ if (val.u === 0 && (fmt == "s" || fmt == "ss")) return pad0(val.S, fmt.length);
389
+ if (ss0 >= 2) tt = ss0 === 3 ? 1000 : 100;else tt = ss0 === 1 ? 10 : 1;
390
+ ss = Math.round(tt * (val.S + val.u));
391
+ if (ss >= 60 * tt) ss = 0;
392
+ if (fmt === "s") return ss === 0 ? "0" : "" + ss / tt;
393
+ o = pad0(ss, 2 + ss0);
394
+ if (fmt === "ss") return o.substr(0, 2);
395
+ return "." + o.substr(2, fmt.length - 1);
396
+ case 90:
397
+ /* 'Z' absolute time */switch (fmt) {
398
+ case "[h]":
399
+ case "[hh]":
400
+ out = val.D * 24 + val.H;
401
+ break;
402
+ case "[m]":
403
+ case "[mm]":
404
+ out = (val.D * 24 + val.H) * 60 + val.M;
405
+ break;
406
+ case "[s]":
407
+ case "[ss]":
408
+ out = ((val.D * 24 + val.H) * 60 + val.M) * 60 + Math.round(val.S + val.u);
409
+ break;
410
+ default:
411
+ throw "bad abstime format: " + fmt;
412
+ }
413
+ outl = fmt.length === 3 ? 1 : 2;
414
+ break;
415
+ case 101:
416
+ /* 'e' era */out = y;
417
+ outl = 1;
418
+ break;
419
+ }
420
+ var outstr = outl > 0 ? pad0(out, outl) : "";
421
+ return outstr;
422
+ }
423
+ /*jshint +W086 */
424
+ function commaify(s) {
425
+ var w = 3;
426
+ if (s.length <= w) return s;
427
+ var j = s.length % w,
428
+ o = s.substr(0, j);
429
+ for (; j != s.length; j += w) o += (o.length > 0 ? "," : "") + s.substr(j, w);
430
+ return o;
431
+ }
432
+ var write_num = function make_write_num() {
433
+ var pct1 = /%/g;
434
+ function write_num_pct(type, fmt, val) {
435
+ var sfmt = fmt.replace(pct1, ""),
436
+ mul = fmt.length - sfmt.length;
437
+ return write_num(type, sfmt, val * Math.pow(10, 2 * mul)) + fill("%", mul);
438
+ }
439
+ function write_num_cm(type, fmt, val) {
440
+ var idx = fmt.length - 1;
441
+ while (fmt.charCodeAt(idx - 1) === 44) --idx;
442
+ return write_num(type, fmt.substr(0, idx), val / Math.pow(10, 3 * (fmt.length - idx)));
443
+ }
444
+ function write_num_exp(fmt, val) {
445
+ var o;
446
+ var idx = fmt.indexOf("E") - fmt.indexOf(".") - 1;
447
+ if (fmt.match(/^#+0.0E\+0$/)) {
448
+ if (val == 0) return "0.0E+0";else if (val < 0) return "-" + write_num_exp(fmt, -val);
449
+ var period = fmt.indexOf(".");
450
+ if (period === -1) period = fmt.indexOf("E");
451
+ var ee = Math.floor(Math.log(val) * Math.LOG10E) % period;
452
+ if (ee < 0) ee += period;
453
+ o = (val / Math.pow(10, ee)).toPrecision(idx + 1 + (period + ee) % period);
454
+ if (o.indexOf("e") === -1) {
455
+ var fakee = Math.floor(Math.log(val) * Math.LOG10E);
456
+ if (o.indexOf(".") === -1) o = o.charAt(0) + "." + o.substr(1) + "E+" + (fakee - o.length + ee);else o += "E+" + (fakee - ee);
457
+ while (o.substr(0, 2) === "0.") {
458
+ o = o.charAt(0) + o.substr(2, period) + "." + o.substr(2 + period);
459
+ o = o.replace(/^0+([1-9])/, "$1").replace(/^0+\./, "0.");
460
+ }
461
+ o = o.replace(/\+-/, "-");
462
+ }
463
+ o = o.replace(/^([+-]?)(\d*)\.(\d*)[Ee]/, function ($$, $1, $2, $3) {
464
+ return $1 + $2 + $3.substr(0, (period + ee) % period) + "." + $3.substr(ee) + "E";
465
+ });
466
+ } else o = Number(val).toExponential(idx);
467
+ if (fmt.match(/E\+00$/) && o.match(/e[+-]\d$/)) o = o.substr(0, o.length - 1) + "0" + o.charAt(o.length - 1);
468
+ if (fmt.match(/E\-/) && o.match(/e\+/)) o = o.replace(/e\+/, "e");
469
+ return o.replace("e", "E");
470
+ }
471
+ var frac1 = /# (\?+)( ?)\/( ?)(\d+)/;
472
+ function write_num_f1(r, aval, sign) {
473
+ var den = parseInt(r[4], 10),
474
+ rr = Math.round(aval * den),
475
+ base = Math.floor(rr / den);
476
+ var myn = rr - base * den,
477
+ myd = den;
478
+ return sign + (base === 0 ? "" : "" + base) + " " + (myn === 0 ? fill(" ", r[1].length + 1 + r[4].length) : pad_(myn, r[1].length) + r[2] + "/" + r[3] + pad0(myd, r[4].length));
479
+ }
480
+ function write_num_f2(r, aval, sign) {
481
+ return sign + (aval === 0 ? "" : "" + aval) + fill(" ", r[1].length + 2 + r[4].length);
482
+ }
483
+ var dec1 = /^#*0*\.([0#]+)/;
484
+ var closeparen = /\).*[0#]/;
485
+ var phone = /\(###\) ###\\?-####/;
486
+ function hashq(str) {
487
+ var o = "",
488
+ cc;
489
+ for (var i = 0; i != str.length; ++i) switch (cc = str.charCodeAt(i)) {
490
+ case 35:
491
+ break;
492
+ case 63:
493
+ o += " ";
494
+ break;
495
+ case 48:
496
+ o += "0";
497
+ break;
498
+ default:
499
+ o += String.fromCharCode(cc);
500
+ }
501
+ return o;
502
+ }
503
+ function rnd(val, d) {
504
+ var dd = Math.pow(10, d);
505
+ return "" + Math.round(val * dd) / dd;
506
+ }
507
+ function dec(val, d) {
508
+ var _frac = val - Math.floor(val),
509
+ dd = Math.pow(10, d);
510
+ if (d < ("" + Math.round(_frac * dd)).length) return 0;
511
+ return Math.round(_frac * dd);
512
+ }
513
+ function carry(val, d) {
514
+ if (d < ("" + Math.round((val - Math.floor(val)) * Math.pow(10, d))).length) {
515
+ return 1;
516
+ }
517
+ return 0;
518
+ }
519
+ function flr(val) {
520
+ if (val < 2147483647 && val > -2147483648) return "" + (val >= 0 ? val | 0 : val - 1 | 0);
521
+ return "" + Math.floor(val);
522
+ }
523
+ function write_num_flt(type, fmt, val) {
524
+ if (type.charCodeAt(0) === 40 && !fmt.match(closeparen)) {
525
+ var ffmt = fmt.replace(/\( */, "").replace(/ \)/, "").replace(/\)/, "");
526
+ if (val >= 0) return write_num_flt("n", ffmt, val);
527
+ return "(" + write_num_flt("n", ffmt, -val) + ")";
528
+ }
529
+ if (fmt.charCodeAt(fmt.length - 1) === 44) return write_num_cm(type, fmt, val);
530
+ if (fmt.indexOf("%") !== -1) return write_num_pct(type, fmt, val);
531
+ if (fmt.indexOf("E") !== -1) return write_num_exp(fmt, val);
532
+ if (fmt.charCodeAt(0) === 36) return "$" + write_num_flt(type, fmt.substr(fmt.charAt(1) == " " ? 2 : 1), val);
533
+ var o;
534
+ var r,
535
+ ri,
536
+ ff,
537
+ aval = Math.abs(val),
538
+ sign = val < 0 ? "-" : "";
539
+ if (fmt.match(/^00+$/)) return sign + pad0r(aval, fmt.length);
540
+ if (fmt.match(/^[#?]+$/)) {
541
+ o = pad0r(val, 0);
542
+ if (o === "0") o = "";
543
+ return o.length > fmt.length ? o : hashq(fmt.substr(0, fmt.length - o.length)) + o;
544
+ }
545
+ if (r = fmt.match(frac1)) return write_num_f1(r, aval, sign);
546
+ if (fmt.match(/^#+0+$/)) return sign + pad0r(aval, fmt.length - fmt.indexOf("0"));
547
+ if (r = fmt.match(dec1)) {
548
+ o = rnd(val, r[1].length).replace(/^([^\.]+)$/, "$1." + hashq(r[1])).replace(/\.$/, "." + hashq(r[1])).replace(/\.(\d*)$/, function ($$, $1) {
549
+ return "." + $1 + fill("0", hashq(r[1]).length - $1.length);
550
+ });
551
+ return fmt.indexOf("0.") !== -1 ? o : o.replace(/^0\./, ".");
552
+ }
553
+ fmt = fmt.replace(/^#+([0.])/, "$1");
554
+ if (r = fmt.match(/^(0*)\.(#*)$/)) {
555
+ return sign + rnd(aval, r[2].length).replace(/\.(\d*[1-9])0*$/, ".$1").replace(/^(-?\d*)$/, "$1.").replace(/^0\./, r[1].length ? "0." : ".");
556
+ }
557
+ if (r = fmt.match(/^#{1,3},##0(\.?)$/)) return sign + commaify(pad0r(aval, 0));
558
+ if (r = fmt.match(/^#,##0\.([#0]*0)$/)) {
559
+ return val < 0 ? "-" + write_num_flt(type, fmt, -val) : commaify("" + (Math.floor(val) + carry(val, r[1].length))) + "." + pad0(dec(val, r[1].length), r[1].length);
560
+ }
561
+ if (r = fmt.match(/^#,#*,#0/)) return write_num_flt(type, fmt.replace(/^#,#*,/, ""), val);
562
+ if (r = fmt.match(/^([0#]+)(\\?-([0#]+))+$/)) {
563
+ o = _strrev(write_num_flt(type, fmt.replace(/[\\-]/g, ""), val));
564
+ ri = 0;
565
+ return _strrev(_strrev(fmt.replace(/\\/g, "")).replace(/[0#]/g, function (x) {
566
+ return ri < o.length ? o.charAt(ri++) : x === "0" ? "0" : "";
567
+ }));
568
+ }
569
+ if (fmt.match(phone)) {
570
+ o = write_num_flt(type, "##########", val);
571
+ return "(" + o.substr(0, 3) + ") " + o.substr(3, 3) + "-" + o.substr(6);
572
+ }
573
+ var oa = "";
574
+ if (r = fmt.match(/^([#0?]+)( ?)\/( ?)([#0?]+)/)) {
575
+ ri = Math.min(r[4].length, 7);
576
+ ff = frac(aval, Math.pow(10, ri) - 1, false);
577
+ o = "" + sign;
578
+ oa = write_num("n", r[1], ff[1]);
579
+ if (oa.charAt(oa.length - 1) == " ") oa = oa.substr(0, oa.length - 1) + "0";
580
+ o += oa + r[2] + "/" + r[3];
581
+ oa = rpad_(ff[2], ri);
582
+ if (oa.length < r[4].length) oa = hashq(r[4].substr(r[4].length - oa.length)) + oa;
583
+ o += oa;
584
+ return o;
585
+ }
586
+ if (r = fmt.match(/^# ([#0?]+)( ?)\/( ?)([#0?]+)/)) {
587
+ ri = Math.min(Math.max(r[1].length, r[4].length), 7);
588
+ ff = frac(aval, Math.pow(10, ri) - 1, true);
589
+ return sign + (ff[0] || (ff[1] ? "" : "0")) + " " + (ff[1] ? pad_(ff[1], ri) + r[2] + "/" + r[3] + rpad_(ff[2], ri) : fill(" ", 2 * ri + 1 + r[2].length + r[3].length));
590
+ }
591
+ if (r = fmt.match(/^[#0?]+$/)) {
592
+ o = pad0r(val, 0);
593
+ if (fmt.length <= o.length) return o;
594
+ return hashq(fmt.substr(0, fmt.length - o.length)) + o;
595
+ }
596
+ if (r = fmt.match(/^([#0?]+)\.([#0]+)$/)) {
597
+ o = "" + val.toFixed(Math.min(r[2].length, 10)).replace(/([^0])0+$/, "$1");
598
+ ri = o.indexOf(".");
599
+ var lres = fmt.indexOf(".") - ri,
600
+ rres = fmt.length - o.length - lres;
601
+ return hashq(fmt.substr(0, lres) + o + fmt.substr(fmt.length - rres));
602
+ }
603
+ if (r = fmt.match(/^00,000\.([#0]*0)$/)) {
604
+ ri = dec(val, r[1].length);
605
+ return val < 0 ? "-" + write_num_flt(type, fmt, -val) : commaify(flr(val)).replace(/^\d,\d{3}$/, "0$&").replace(/^\d*$/, function ($$) {
606
+ return "00," + ($$.length < 3 ? pad0(0, 3 - $$.length) : "") + $$;
607
+ }) + "." + pad0(ri, r[1].length);
608
+ }
609
+ switch (fmt) {
610
+ case "###,##0.00":
611
+ return write_num_flt(type, "#,##0.00", val);
612
+ case "###,###":
613
+ case "##,###":
614
+ case "#,###":
615
+ var x = commaify(pad0r(aval, 0));
616
+ return x !== "0" ? sign + x : "";
617
+ case "###,###.00":
618
+ return write_num_flt(type, "###,##0.00", val).replace(/^0\./, ".");
619
+ case "#,###.00":
620
+ return write_num_flt(type, "#,##0.00", val).replace(/^0\./, ".");
621
+ default:
622
+ }
623
+ throw new Error("unsupported format |" + fmt + "|");
624
+ }
625
+ function write_num_cm2(type, fmt, val) {
626
+ var idx = fmt.length - 1;
627
+ while (fmt.charCodeAt(idx - 1) === 44) --idx;
628
+ return write_num(type, fmt.substr(0, idx), val / Math.pow(10, 3 * (fmt.length - idx)));
629
+ }
630
+ function write_num_pct2(type, fmt, val) {
631
+ var sfmt = fmt.replace(pct1, ""),
632
+ mul = fmt.length - sfmt.length;
633
+ return write_num(type, sfmt, val * Math.pow(10, 2 * mul)) + fill("%", mul);
634
+ }
635
+ function write_num_exp2(fmt, val) {
636
+ var o;
637
+ var idx = fmt.indexOf("E") - fmt.indexOf(".") - 1;
638
+ if (fmt.match(/^#+0.0E\+0$/)) {
639
+ if (val == 0) return "0.0E+0";else if (val < 0) return "-" + write_num_exp2(fmt, -val);
640
+ var period = fmt.indexOf(".");
641
+ if (period === -1) period = fmt.indexOf("E");
642
+ var ee = Math.floor(Math.log(val) * Math.LOG10E) % period;
643
+ if (ee < 0) ee += period;
644
+ o = (val / Math.pow(10, ee)).toPrecision(idx + 1 + (period + ee) % period);
645
+ if (!o.match(/[Ee]/)) {
646
+ var fakee = Math.floor(Math.log(val) * Math.LOG10E);
647
+ if (o.indexOf(".") === -1) o = o.charAt(0) + "." + o.substr(1) + "E+" + (fakee - o.length + ee);else o += "E+" + (fakee - ee);
648
+ o = o.replace(/\+-/, "-");
649
+ }
650
+ o = o.replace(/^([+-]?)(\d*)\.(\d*)[Ee]/, function ($$, $1, $2, $3) {
651
+ return $1 + $2 + $3.substr(0, (period + ee) % period) + "." + $3.substr(ee) + "E";
652
+ });
653
+ } else o = Number(val).toExponential(idx);
654
+ if (fmt.match(/E\+00$/) && o.match(/e[+-]\d$/)) o = o.substr(0, o.length - 1) + "0" + o.charAt(o.length - 1);
655
+ if (fmt.match(/E\-/) && o.match(/e\+/)) o = o.replace(/e\+/, "e");
656
+ return o.replace("e", "E");
657
+ }
658
+ function write_num_int(type, fmt, val) {
659
+ if (type.charCodeAt(0) === 40 && !fmt.match(closeparen)) {
660
+ var ffmt = fmt.replace(/\( */, "").replace(/ \)/, "").replace(/\)/, "");
661
+ if (val >= 0) return write_num_int("n", ffmt, val);
662
+ return "(" + write_num_int("n", ffmt, -val) + ")";
663
+ }
664
+ if (fmt.charCodeAt(fmt.length - 1) === 44) return write_num_cm2(type, fmt, val);
665
+ if (fmt.indexOf("%") !== -1) return write_num_pct2(type, fmt, val);
666
+ if (fmt.indexOf("E") !== -1) return write_num_exp2(fmt, val);
667
+ if (fmt.charCodeAt(0) === 36) return "$" + write_num_int(type, fmt.substr(fmt.charAt(1) == " " ? 2 : 1), val);
668
+ var o;
669
+ var r,
670
+ ri,
671
+ ff,
672
+ aval = Math.abs(val),
673
+ sign = val < 0 ? "-" : "";
674
+ if (fmt.match(/^00+$/)) return sign + pad0(aval, fmt.length);
675
+ if (fmt.match(/^[#?]+$/)) {
676
+ o = "" + val;
677
+ if (val === 0) o = "";
678
+ return o.length > fmt.length ? o : hashq(fmt.substr(0, fmt.length - o.length)) + o;
679
+ }
680
+ if (r = fmt.match(frac1)) return write_num_f2(r, aval, sign);
681
+ if (fmt.match(/^#+0+$/)) return sign + pad0(aval, fmt.length - fmt.indexOf("0"));
682
+ if (r = fmt.match(dec1)) {
683
+ o = ("" + val).replace(/^([^\.]+)$/, "$1." + hashq(r[1])).replace(/\.$/, "." + hashq(r[1]));
684
+ o = o.replace(/\.(\d*)$/, function ($$, $1) {
685
+ return "." + $1 + fill("0", hashq(r[1]).length - $1.length);
686
+ });
687
+ return fmt.indexOf("0.") !== -1 ? o : o.replace(/^0\./, ".");
688
+ }
689
+ fmt = fmt.replace(/^#+([0.])/, "$1");
690
+ if (r = fmt.match(/^(0*)\.(#*)$/)) {
691
+ return sign + ("" + aval).replace(/\.(\d*[1-9])0*$/, ".$1").replace(/^(-?\d*)$/, "$1.").replace(/^0\./, r[1].length ? "0." : ".");
692
+ }
693
+ if (r = fmt.match(/^#{1,3},##0(\.?)$/)) return sign + commaify("" + aval);
694
+ if (r = fmt.match(/^#,##0\.([#0]*0)$/)) {
695
+ return val < 0 ? "-" + write_num_int(type, fmt, -val) : commaify("" + val) + "." + fill("0", r[1].length);
696
+ }
697
+ if (r = fmt.match(/^#,#*,#0/)) return write_num_int(type, fmt.replace(/^#,#*,/, ""), val);
698
+ if (r = fmt.match(/^([0#]+)(\\?-([0#]+))+$/)) {
699
+ o = _strrev(write_num_int(type, fmt.replace(/[\\-]/g, ""), val));
700
+ ri = 0;
701
+ return _strrev(_strrev(fmt.replace(/\\/g, "")).replace(/[0#]/g, function (x) {
702
+ return ri < o.length ? o.charAt(ri++) : x === "0" ? "0" : "";
703
+ }));
704
+ }
705
+ if (fmt.match(phone)) {
706
+ o = write_num_int(type, "##########", val);
707
+ return "(" + o.substr(0, 3) + ") " + o.substr(3, 3) + "-" + o.substr(6);
708
+ }
709
+ var oa = "";
710
+ if (r = fmt.match(/^([#0?]+)( ?)\/( ?)([#0?]+)/)) {
711
+ ri = Math.min(r[4].length, 7);
712
+ ff = frac(aval, Math.pow(10, ri) - 1, false);
713
+ o = "" + sign;
714
+ oa = write_num("n", r[1], ff[1]);
715
+ if (oa.charAt(oa.length - 1) == " ") oa = oa.substr(0, oa.length - 1) + "0";
716
+ o += oa + r[2] + "/" + r[3];
717
+ oa = rpad_(ff[2], ri);
718
+ if (oa.length < r[4].length) oa = hashq(r[4].substr(r[4].length - oa.length)) + oa;
719
+ o += oa;
720
+ return o;
721
+ }
722
+ if (r = fmt.match(/^# ([#0?]+)( ?)\/( ?)([#0?]+)/)) {
723
+ ri = Math.min(Math.max(r[1].length, r[4].length), 7);
724
+ ff = frac(aval, Math.pow(10, ri) - 1, true);
725
+ return sign + (ff[0] || (ff[1] ? "" : "0")) + " " + (ff[1] ? pad_(ff[1], ri) + r[2] + "/" + r[3] + rpad_(ff[2], ri) : fill(" ", 2 * ri + 1 + r[2].length + r[3].length));
726
+ }
727
+ if (r = fmt.match(/^[#0?]+$/)) {
728
+ o = "" + val;
729
+ if (fmt.length <= o.length) return o;
730
+ return hashq(fmt.substr(0, fmt.length - o.length)) + o;
731
+ }
732
+ if (r = fmt.match(/^([#0]+)\.([#0]+)$/)) {
733
+ o = "" + val.toFixed(Math.min(r[2].length, 10)).replace(/([^0])0+$/, "$1");
734
+ ri = o.indexOf(".");
735
+ var lres = fmt.indexOf(".") - ri,
736
+ rres = fmt.length - o.length - lres;
737
+ return hashq(fmt.substr(0, lres) + o + fmt.substr(fmt.length - rres));
738
+ }
739
+ if (r = fmt.match(/^00,000\.([#0]*0)$/)) {
740
+ return val < 0 ? "-" + write_num_int(type, fmt, -val) : commaify("" + val).replace(/^\d,\d{3}$/, "0$&").replace(/^\d*$/, function ($$) {
741
+ return "00," + ($$.length < 3 ? pad0(0, 3 - $$.length) : "") + $$;
742
+ }) + "." + pad0(0, r[1].length);
743
+ }
744
+ switch (fmt) {
745
+ case "###,###":
746
+ case "##,###":
747
+ case "#,###":
748
+ var x = commaify("" + aval);
749
+ return x !== "0" ? sign + x : "";
750
+ default:
751
+ if (fmt.match(/\.[0#?]*$/)) return write_num_int(type, fmt.slice(0, fmt.lastIndexOf(".")), val) + hashq(fmt.slice(fmt.lastIndexOf(".")));
752
+ }
753
+ throw new Error("unsupported format |" + fmt + "|");
754
+ }
755
+ return function write_num(type, fmt, val) {
756
+ return (val | 0) === val ? write_num_int(type, fmt, val) : write_num_flt(type, fmt, val);
757
+ };
758
+ }();
759
+ function split_fmt(fmt) {
760
+ var out = [];
761
+ var in_str = false; /*, cc*/
762
+ for (var i = 0, j = 0; i < fmt.length; ++i) switch (/*cc=*/fmt.charCodeAt(i)) {
763
+ case 34:
764
+ /* '"' */in_str = !in_str;
765
+ break;
766
+ case 95:
767
+ case 42:
768
+ case 92:
769
+ /* '_' '*' '\\' */
770
+ ++i;
771
+ break;
772
+ case 59:
773
+ /* ';' */out[out.length] = fmt.substr(j, i - j);
774
+ j = i + 1;
775
+ }
776
+ out[out.length] = fmt.substr(j);
777
+ if (in_str === true) throw new Error("Format |" + fmt + "| unterminated string ");
778
+ return out;
779
+ }
780
+ SSF._split = split_fmt;
781
+ var abstime = /\[[HhMmSs\u0E0A\u0E19\u0E17]*\]/;
782
+ function fmt_is_date(fmt) {
783
+ var i = 0,
784
+ /*cc = 0,*/c = "",
785
+ o = "";
786
+ while (i < fmt.length) {
787
+ switch (c = fmt.charAt(i)) {
788
+ case "G":
789
+ if (isgeneral(fmt, i)) i += 6;
790
+ i++;
791
+ break;
792
+ case '"':
793
+ for (; /*cc=*/fmt.charCodeAt(++i) !== 34 && i < fmt.length;) {
794
+ /*empty*/
795
+ }
796
+ ++i;
797
+ break;
798
+ case "\\":
799
+ i += 2;
800
+ break;
801
+ case "_":
802
+ i += 2;
803
+ break;
804
+ case "@":
805
+ ++i;
806
+ break;
807
+ case "B":
808
+ case "b":
809
+ if (fmt.charAt(i + 1) === "1" || fmt.charAt(i + 1) === "2") return true;
810
+ /* falls through */
811
+ case "M":
812
+ case "D":
813
+ case "Y":
814
+ case "H":
815
+ case "S":
816
+ case "E":
817
+ /* falls through */
818
+ case "m":
819
+ case "d":
820
+ case "y":
821
+ case "h":
822
+ case "s":
823
+ case "e":
824
+ case "g":
825
+ return true;
826
+ case "A":
827
+ case "a":
828
+ case "上":
829
+ if (fmt.substr(i, 3).toUpperCase() === "A/P") return true;
830
+ if (fmt.substr(i, 5).toUpperCase() === "AM/PM") return true;
831
+ if (fmt.substr(i, 5).toUpperCase() === "上午/下午") return true;
832
+ ++i;
833
+ break;
834
+ case "[":
835
+ o = c;
836
+ while (fmt.charAt(i++) !== "]" && i < fmt.length) o += fmt.charAt(i);
837
+ if (o.match(abstime)) return true;
838
+ break;
839
+ case ".":
840
+ /* falls through */
841
+ case "0":
842
+ case "#":
843
+ while (i < fmt.length && ("0#?.,E+-%".indexOf(c = fmt.charAt(++i)) > -1 || c == "\\" && fmt.charAt(i + 1) == "-" && "0#".indexOf(fmt.charAt(i + 2)) > -1)) {
844
+ /* empty */
845
+ }
846
+ break;
847
+ case "?":
848
+ while (fmt.charAt(++i) === c) {
849
+ /* empty */
850
+ }
851
+ break;
852
+ case "*":
853
+ ++i;
854
+ if (fmt.charAt(i) == " " || fmt.charAt(i) == "*") ++i;
855
+ break;
856
+ case "(":
857
+ case ")":
858
+ ++i;
859
+ break;
860
+ case "1":
861
+ case "2":
862
+ case "3":
863
+ case "4":
864
+ case "5":
865
+ case "6":
866
+ case "7":
867
+ case "8":
868
+ case "9":
869
+ while (i < fmt.length && "0123456789".indexOf(fmt.charAt(++i)) > -1) {
870
+ /* empty */
871
+ }
872
+ break;
873
+ case " ":
874
+ ++i;
875
+ break;
876
+ default:
877
+ ++i;
878
+ break;
879
+ }
880
+ }
881
+ return false;
882
+ }
883
+ SSF.is_date = fmt_is_date;
884
+ function eval_fmt(fmt, v, opts, flen) {
885
+ var out = [],
886
+ o = "",
887
+ i = 0,
888
+ c = "",
889
+ lst = "t",
890
+ dt,
891
+ j,
892
+ cc;
893
+ var hr = "H";
894
+ /* Tokenize */
895
+ while (i < fmt.length) {
896
+ switch (c = fmt.charAt(i)) {
897
+ case "G":
898
+ /* General */if (!isgeneral(fmt, i)) throw new Error("unrecognized character " + c + " in " + fmt);
899
+ out[out.length] = {
900
+ t: "G",
901
+ v: "General"
902
+ };
903
+ i += 7;
904
+ break;
905
+ case '"':
906
+ /* Literal text */for (o = ""; (cc = fmt.charCodeAt(++i)) !== 34 && i < fmt.length;) o += String.fromCharCode(cc);
907
+ out[out.length] = {
908
+ t: "t",
909
+ v: o
910
+ };
911
+ ++i;
912
+ break;
913
+ case "\\":
914
+ var w = fmt.charAt(++i),
915
+ t = w === "(" || w === ")" ? w : "t";
916
+ out[out.length] = {
917
+ t: t,
918
+ v: w
919
+ };
920
+ ++i;
921
+ break;
922
+ case "_":
923
+ out[out.length] = {
924
+ t: "t",
925
+ v: " "
926
+ };
927
+ i += 2;
928
+ break;
929
+ case "@":
930
+ /* Text Placeholder */out[out.length] = {
931
+ t: "T",
932
+ v: v
933
+ };
934
+ ++i;
935
+ break;
936
+ case "B":
937
+ case "b":
938
+ if (fmt.charAt(i + 1) === "1" || fmt.charAt(i + 1) === "2") {
939
+ if (dt == null) {
940
+ dt = parse_date_code(v, opts, fmt.charAt(i + 1) === "2");
941
+ if (dt == null) return "";
942
+ }
943
+ out[out.length] = {
944
+ t: "X",
945
+ v: fmt.substr(i, 2)
946
+ };
947
+ lst = c;
948
+ i += 2;
949
+ break;
950
+ }
951
+ /* falls through */
952
+ case "M":
953
+ case "D":
954
+ case "Y":
955
+ case "H":
956
+ case "S":
957
+ case "E":
958
+ c = c.toLowerCase();
959
+ /* falls through */
960
+ case "m":
961
+ case "d":
962
+ case "y":
963
+ case "h":
964
+ case "s":
965
+ case "e":
966
+ case "g":
967
+ if (v < 0) return "";
968
+ if (dt == null) {
969
+ dt = parse_date_code(v, opts);
970
+ if (dt == null) return "#####";
971
+ }
972
+ o = c;
973
+ while (++i < fmt.length && fmt.charAt(i).toLowerCase() === c) o += c;
974
+ if (c === "m" && lst.toLowerCase() === "h") c = "M";
975
+ if (c === "h") c = hr;
976
+ out[out.length] = {
977
+ t: c,
978
+ v: o
979
+ };
980
+ lst = c;
981
+ break;
982
+ case "A":
983
+ case "a":
984
+ case "上":
985
+ var q = {
986
+ t: c,
987
+ v: c
988
+ };
989
+ if (dt == null) dt = parse_date_code(v, opts);
990
+ if (fmt.substr(i, 3).toUpperCase() === "A/P") {
991
+ if (dt != null) q.v = dt.H >= 12 ? "P" : "A";
992
+ q.t = "T";
993
+ hr = "h";
994
+ i += 3;
995
+ } else if (fmt.substr(i, 5).toUpperCase() === "AM/PM") {
996
+ if (dt != null) q.v = dt.H >= 12 ? "PM" : "AM";
997
+ q.t = "T";
998
+ i += 5;
999
+ hr = "h";
1000
+ } else if (fmt.substr(i, 5).toUpperCase() === "上午/下午") {
1001
+ if (dt != null) q.v = dt.H >= 12 ? "下午" : "上午";
1002
+ q.t = "T";
1003
+ i += 5;
1004
+ hr = "h";
1005
+ } else {
1006
+ q.t = "t";
1007
+ ++i;
1008
+ }
1009
+ if (dt == null && q.t === "T") return "";
1010
+ out[out.length] = q;
1011
+ lst = c;
1012
+ break;
1013
+ case "[":
1014
+ o = c;
1015
+ while (fmt.charAt(i++) !== "]" && i < fmt.length) o += fmt.charAt(i);
1016
+ if (o.slice(-1) !== "]") throw 'unterminated "[" block: |' + o + "|";
1017
+ if (o.match(abstime)) {
1018
+ if (dt == null) {
1019
+ dt = parse_date_code(v, opts);
1020
+ if (dt == null) return "";
1021
+ }
1022
+ out[out.length] = {
1023
+ t: "Z",
1024
+ v: o.toLowerCase()
1025
+ };
1026
+ lst = o.charAt(1);
1027
+ } else if (o.indexOf("$") > -1) {
1028
+ o = (o.match(/\$([^-\[\]]*)/) || [])[1] || "$";
1029
+ if (!fmt_is_date(fmt)) out[out.length] = {
1030
+ t: "t",
1031
+ v: o
1032
+ };
1033
+ }
1034
+ break;
1035
+ /* Numbers */
1036
+ case ".":
1037
+ if (dt != null) {
1038
+ o = c;
1039
+ while (++i < fmt.length && (c = fmt.charAt(i)) === "0") o += c;
1040
+ out[out.length] = {
1041
+ t: "s",
1042
+ v: o
1043
+ };
1044
+ break;
1045
+ }
1046
+ /* falls through */
1047
+ case "0":
1048
+ case "#":
1049
+ o = c;
1050
+ while (++i < fmt.length && "0#?.,E+-%".indexOf(c = fmt.charAt(i)) > -1) o += c;
1051
+ out[out.length] = {
1052
+ t: "n",
1053
+ v: o
1054
+ };
1055
+ break;
1056
+ case "?":
1057
+ o = c;
1058
+ while (fmt.charAt(++i) === c) o += c;
1059
+ out[out.length] = {
1060
+ t: c,
1061
+ v: o
1062
+ };
1063
+ lst = c;
1064
+ break;
1065
+ case "*":
1066
+ ++i;
1067
+ if (fmt.charAt(i) == " " || fmt.charAt(i) == "*") ++i;
1068
+ break;
1069
+ // **
1070
+ case "(":
1071
+ case ")":
1072
+ out[out.length] = {
1073
+ t: flen === 1 ? "t" : c,
1074
+ v: c
1075
+ };
1076
+ ++i;
1077
+ break;
1078
+ case "1":
1079
+ case "2":
1080
+ case "3":
1081
+ case "4":
1082
+ case "5":
1083
+ case "6":
1084
+ case "7":
1085
+ case "8":
1086
+ case "9":
1087
+ o = c;
1088
+ while (i < fmt.length && "0123456789".indexOf(fmt.charAt(++i)) > -1) o += fmt.charAt(i);
1089
+ out[out.length] = {
1090
+ t: "D",
1091
+ v: o
1092
+ };
1093
+ break;
1094
+ case " ":
1095
+ out[out.length] = {
1096
+ t: c,
1097
+ v: c
1098
+ };
1099
+ ++i;
1100
+ break;
1101
+ case "$":
1102
+ out[out.length] = {
1103
+ t: "t",
1104
+ v: "$"
1105
+ };
1106
+ ++i;
1107
+ break;
1108
+ default:
1109
+ // if ("¤฿BsBr₵₡₫ƒFtRs.₭kr£₤Lm₥₦₱PQRSkRp৲৳R$S/.〒₮₩¥NT¥zł₴₪៛руб€$,$-+/():!^&'~{}<>=€acfijklopqrtuvwxzP".indexOf(c) === -1) throw new Error('unrecognized character ' + c + ' in ' + fmt);
1110
+ if ("¤฿BsBr₵₡₫ƒFtRs.₭kr£₤Lm₥₦₱PQRSkRp৲৳R$S/.〒₮₩¥NT¥zł₴₪៛руб€₹$,$-+/():!^&'~{}<>=€acfijklopqrtuvwxzP$¥LekdinAf$dhAflRial?£BirrKzMOPPGKRsGsB/R$ррlevkrKMzBsPNuFBuKPkrRD$NfkCFA?CVEGMDFrCDHTGNAfLFdjKGSFGGHSRielKCFknKshLSLL£LtRFRONArRfMWKRMMURsMROS/KMDLMTnRC$kr€GELCHFSLLSCRDbSZLSDGSOSSomFCFPTShT$VUVQUGXгрнsomWSTNT$FtDramRpZMWFCFA".indexOf(c) === -1) throw new Error("unrecognized character " + c + " in " + fmt);
1111
+ out[out.length] = {
1112
+ t: "t",
1113
+ v: c
1114
+ };
1115
+ ++i;
1116
+ break;
1117
+ }
1118
+ }
1119
+ /* Scan for date/time parts */
1120
+ var bt = 0,
1121
+ ss0 = 0,
1122
+ ssm;
1123
+ for (i = out.length - 1, lst = "t"; i >= 0; --i) {
1124
+ switch (out[i].t) {
1125
+ case "h":
1126
+ case "H":
1127
+ out[i].t = hr;
1128
+ lst = "h";
1129
+ if (bt < 1) bt = 1;
1130
+ break;
1131
+ case "s":
1132
+ if (ssm = out[i].v.match(/\.0+$/)) ss0 = Math.max(ss0, ssm[0].length - 1);
1133
+ if (bt < 3) bt = 3;
1134
+ /* falls through */
1135
+ case "d":
1136
+ case "y":
1137
+ case "M":
1138
+ case "e":
1139
+ lst = out[i].t;
1140
+ break;
1141
+ case "m":
1142
+ if (lst === "s") {
1143
+ out[i].t = "M";
1144
+ if (bt < 2) bt = 2;
1145
+ }
1146
+ break;
1147
+ case "X":
1148
+ /*if(out[i].v === "B2");*/break;
1149
+ case "Z":
1150
+ if (bt < 1 && out[i].v.match(/[Hh]/)) bt = 1;
1151
+ if (bt < 2 && out[i].v.match(/[Mm]/)) bt = 2;
1152
+ if (bt < 3 && out[i].v.match(/[Ss]/)) bt = 3;
1153
+ }
1154
+ }
1155
+ /* time rounding depends on presence of minute / second / usec fields */
1156
+ switch (bt) {
1157
+ case 0:
1158
+ break;
1159
+ case 1:
1160
+ if (dt.u >= 0.5) {
1161
+ dt.u = 0;
1162
+ ++dt.S;
1163
+ }
1164
+ if (dt.S >= 60) {
1165
+ dt.S = 0;
1166
+ ++dt.M;
1167
+ }
1168
+ if (dt.M >= 60) {
1169
+ dt.M = 0;
1170
+ ++dt.H;
1171
+ }
1172
+ break;
1173
+ case 2:
1174
+ if (dt.u >= 0.5) {
1175
+ dt.u = 0;
1176
+ ++dt.S;
1177
+ }
1178
+ if (dt.S >= 60) {
1179
+ dt.S = 0;
1180
+ ++dt.M;
1181
+ }
1182
+ break;
1183
+ }
1184
+ /* replace fields */
1185
+ var nstr = "",
1186
+ jj;
1187
+ for (i = 0; i < out.length; ++i) {
1188
+ switch (out[i].t) {
1189
+ case "t":
1190
+ case "T":
1191
+ case " ":
1192
+ case "D":
1193
+ break;
1194
+ case "X":
1195
+ out[i].v = "";
1196
+ out[i].t = ";";
1197
+ break;
1198
+ case "d":
1199
+ case "m":
1200
+ case "y":
1201
+ case "h":
1202
+ case "H":
1203
+ case "M":
1204
+ case "s":
1205
+ case "e":
1206
+ case "b":
1207
+ case "Z":
1208
+ out[i].v = write_date(out[i].t.charCodeAt(0), out[i].v, dt, ss0);
1209
+ out[i].t = "t";
1210
+ break;
1211
+ case "n":
1212
+ case "?":
1213
+ jj = i + 1;
1214
+ while (out[jj] != null && ((c = out[jj].t) === "?" || c === "D" || (c === " " || c === "t") && out[jj + 1] != null && (out[jj + 1].t === "?" || out[jj + 1].t === "t" && out[jj + 1].v === "/") || out[i].t === "(" && (c === " " || c === "n" || c === ")") || c === "t" && (out[jj].v === "/" || out[jj].v === " " && out[jj + 1] != null && out[jj + 1].t == "?"))) {
1215
+ out[i].v += out[jj].v;
1216
+ out[jj] = {
1217
+ v: "",
1218
+ t: ";"
1219
+ };
1220
+ ++jj;
1221
+ }
1222
+ nstr += out[i].v;
1223
+ i = jj - 1;
1224
+ break;
1225
+ case "G":
1226
+ out[i].t = "t";
1227
+ out[i].v = general_fmt(v, opts);
1228
+ break;
1229
+ }
1230
+ }
1231
+ var vv = "",
1232
+ myv,
1233
+ ostr;
1234
+ if (nstr.length > 0) {
1235
+ if (nstr.charCodeAt(0) == 40) {
1236
+ /* '(' */myv = v < 0 && nstr.charCodeAt(0) === 45 ? -v : v;
1237
+ ostr = write_num("n", nstr, myv);
1238
+ } else {
1239
+ myv = v < 0 && flen > 1 ? -v : v;
1240
+ ostr = write_num("n", nstr, myv);
1241
+ if (myv < 0 && out[0] && out[0].t == "t") {
1242
+ ostr = ostr.substr(1);
1243
+ out[0].v = "-" + out[0].v;
1244
+ }
1245
+ }
1246
+ jj = ostr.length - 1;
1247
+ var decpt = out.length;
1248
+ for (i = 0; i < out.length; ++i) if (out[i] != null && out[i].t != "t" && out[i].v.indexOf(".") > -1) {
1249
+ decpt = i;
1250
+ break;
1251
+ }
1252
+ var lasti = out.length;
1253
+ if (decpt === out.length && ostr.indexOf("E") === -1) {
1254
+ for (i = out.length - 1; i >= 0; --i) {
1255
+ if (out[i] == null || "n?".indexOf(out[i].t) === -1) continue;
1256
+ if (jj >= out[i].v.length - 1) {
1257
+ jj -= out[i].v.length;
1258
+ out[i].v = ostr.substr(jj + 1, out[i].v.length);
1259
+ } else if (jj < 0) out[i].v = "";else {
1260
+ out[i].v = ostr.substr(0, jj + 1);
1261
+ jj = -1;
1262
+ }
1263
+ out[i].t = "t";
1264
+ lasti = i;
1265
+ }
1266
+ if (jj >= 0 && lasti < out.length) out[lasti].v = ostr.substr(0, jj + 1) + out[lasti].v;
1267
+ } else if (decpt !== out.length && ostr.indexOf("E") === -1) {
1268
+ jj = ostr.indexOf(".") - 1;
1269
+ for (i = decpt; i >= 0; --i) {
1270
+ if (out[i] == null || "n?".indexOf(out[i].t) === -1) continue;
1271
+ j = out[i].v.indexOf(".") > -1 && i === decpt ? out[i].v.indexOf(".") - 1 : out[i].v.length - 1;
1272
+ vv = out[i].v.substr(j + 1);
1273
+ for (; j >= 0; --j) {
1274
+ if (jj >= 0 && (out[i].v.charAt(j) === "0" || out[i].v.charAt(j) === "#")) vv = ostr.charAt(jj--) + vv;
1275
+ }
1276
+ out[i].v = vv;
1277
+ out[i].t = "t";
1278
+ lasti = i;
1279
+ }
1280
+ if (jj >= 0 && lasti < out.length) out[lasti].v = ostr.substr(0, jj + 1) + out[lasti].v;
1281
+ jj = ostr.indexOf(".") + 1;
1282
+ for (i = decpt; i < out.length; ++i) {
1283
+ if (out[i] == null || "n?(".indexOf(out[i].t) === -1 && i !== decpt) continue;
1284
+ j = out[i].v.indexOf(".") > -1 && i === decpt ? out[i].v.indexOf(".") + 1 : 0;
1285
+ vv = out[i].v.substr(0, j);
1286
+ for (; j < out[i].v.length; ++j) {
1287
+ if (jj < ostr.length) vv += ostr.charAt(jj++);
1288
+ }
1289
+ out[i].v = vv;
1290
+ out[i].t = "t";
1291
+ lasti = i;
1292
+ }
1293
+ }
1294
+ }
1295
+ for (i = 0; i < out.length; ++i) if (out[i] != null && "n?".indexOf(out[i].t) > -1) {
1296
+ myv = flen > 1 && v < 0 && i > 0 && out[i - 1].v === "-" ? -v : v;
1297
+ out[i].v = write_num(out[i].t, out[i].v, myv);
1298
+ out[i].t = "t";
1299
+ }
1300
+ var retval = "";
1301
+ for (i = 0; i !== out.length; ++i) if (out[i] != null) retval += out[i].v;
1302
+ return retval;
1303
+ }
1304
+ SSF._eval = eval_fmt;
1305
+ var cfregex = /\[[=<>]/;
1306
+ var cfregex2 = /\[(=|>[=]?|<[>=]?)(-?\d+(?:\.\d*)?)\]/;
1307
+ function chkcond(v, rr) {
1308
+ if (rr == null) return false;
1309
+ var thresh = parseFloat(rr[2]);
1310
+ switch (rr[1]) {
1311
+ case "=":
1312
+ if (v == thresh) return true;
1313
+ break;
1314
+ case ">":
1315
+ if (v > thresh) return true;
1316
+ break;
1317
+ case "<":
1318
+ if (v < thresh) return true;
1319
+ break;
1320
+ case "<>":
1321
+ if (v != thresh) return true;
1322
+ break;
1323
+ case ">=":
1324
+ if (v >= thresh) return true;
1325
+ break;
1326
+ case "<=":
1327
+ if (v <= thresh) return true;
1328
+ break;
1329
+ }
1330
+ return false;
1331
+ }
1332
+ function choose_fmt(f, v) {
1333
+ var fmt = split_fmt(f);
1334
+ var l = fmt.length,
1335
+ lat = fmt[l - 1].indexOf("@");
1336
+ if (l < 4 && lat > -1) --l;
1337
+ if (fmt.length > 4) throw new Error("cannot find right format for |" + fmt.join("|") + "|");
1338
+ // 这行代码弃用,有可能v会有"1"的情况出现,并且需要排查true,false,‘ ’这些值所以需要使用parseFloat(v).toString()去判断是不是Number类型
1339
+ // if (typeof v !== "number")
1340
+ if (parseFloat(v).toString() == "NaN") return [4, fmt.length === 4 || lat > -1 ? fmt[fmt.length - 1] : "@"];
1341
+ switch (fmt.length) {
1342
+ case 1:
1343
+ fmt = lat > -1 ? ["General", "General", "General", fmt[0]] : [fmt[0], fmt[0], fmt[0], "@"];
1344
+ break;
1345
+ case 2:
1346
+ fmt = lat > -1 ? [fmt[0], fmt[0], fmt[0], fmt[1]] : [fmt[0], fmt[1], fmt[0], "@"];
1347
+ break;
1348
+ case 3:
1349
+ fmt = lat > -1 ? [fmt[0], fmt[1], fmt[0], fmt[2]] : [fmt[0], fmt[1], fmt[2], "@"];
1350
+ break;
1351
+ case 4:
1352
+ break;
1353
+ }
1354
+ var ff = v > 0 ? fmt[0] : v < 0 ? fmt[1] : fmt[2];
1355
+ if (fmt[0].indexOf("[") === -1 && fmt[1].indexOf("[") === -1) return [l, ff];
1356
+ if (fmt[0].match(cfregex) != null || fmt[1].match(cfregex) != null) {
1357
+ var m1 = fmt[0].match(cfregex2);
1358
+ var m2 = fmt[1].match(cfregex2);
1359
+ return chkcond(v, m1) ? [l, fmt[0]] : chkcond(v, m2) ? [l, fmt[1]] : [l, fmt[m1 != null && m2 != null ? 2 : 1]];
1360
+ }
1361
+ return [l, ff];
1362
+ }
1363
+ function format(fmt, v, o) {
1364
+ if (o == null) o = {};
1365
+ var sfmt = "";
1366
+ switch (_typeof(fmt)) {
1367
+ case "string":
1368
+ if (fmt == "m/d/yy" && o.dateNF) sfmt = o.dateNF;else sfmt = fmt;
1369
+ break;
1370
+ case "number":
1371
+ if (fmt == 14 && o.dateNF) sfmt = o.dateNF;else sfmt = (o.table != null ? o.table : table_fmt)[fmt];
1372
+ if (sfmt == null) sfmt = o.table && o.table[default_map[fmt]] || table_fmt[default_map[fmt]];
1373
+ if (sfmt == null) sfmt = default_str[fmt] || "General";
1374
+ break;
1375
+ }
1376
+
1377
+ //new runze 增加万 亿 格式
1378
+ //注:"w":2万2500 "w0":2万2500 "w0.0":2万2500.2 "w0.00":2万2500.23......自定义精确度
1379
+ var reg = /^(w|W)((0?)|(0\.0+))$/;
1380
+ if (!!sfmt.match(reg)) {
1381
+ if (isNaN(v)) {
1382
+ return v;
1383
+ }
1384
+
1385
+ //var v =300101886.436;
1386
+ var acc = sfmt.slice(1); //取得0/0.0/0.00
1387
+ var isNegative = false;
1388
+ if (!isNaN(v) && Number(v) < 0) {
1389
+ isNegative = true;
1390
+ v = Math.abs(v);
1391
+ }
1392
+ var vInt = parseInt(v);
1393
+ var vlength = vInt.toString().length;
1394
+ if (vlength > 4) {
1395
+ if (vlength > 8) {
1396
+ var y = parseInt(v / 100000000); //亿
1397
+ var w = parseInt(parseFloat(v) - y * 100000000 / 10000); //万
1398
+ var q = parseFloat(v) - (y * 100000000 + w * 10000); //千以后
1399
+ if (acc != "") {
1400
+ q = numeral(q).format(acc); //处理精确度
1401
+ }
1402
+ v = y + "亿" + w + "万" + q;
1403
+ } else {
1404
+ var w = parseInt(v / 10000); //万
1405
+ var q = parseFloat(v) - w * 10000; //千以后
1406
+ if (acc != "") {
1407
+ q = numeral(q).format(acc); //处理精确度
1408
+ }
1409
+ v = w + "万" + q;
1410
+ }
1411
+ if (v.indexOf("亿0万0") != -1) {
1412
+ v = v.replace("0万0", "");
1413
+ } else if (v.indexOf("亿0万") != -1) {
1414
+ v = v.replace("0万", "");
1415
+ } else if (v.indexOf("万0") != -1) {
1416
+ v = v.replace("万0", "万");
1417
+ }
1418
+
1419
+ //舍弃正则后顾断言写法,旧浏览器不识别(360 V9)
1420
+ if (v.indexOf("亿") != -1 && v.indexOf("万") == -1) {
1421
+ //1亿/1亿111 => 1亿/1亿0111
1422
+ var afterYi = v.substring(v.indexOf("亿") + 1);
1423
+ if (afterYi.substring(0, 1) !== "." && afterYi != "") {
1424
+ switch ((parseInt(afterYi) + "").length) {
1425
+ case 1:
1426
+ afterYi = "000" + afterYi;
1427
+ break;
1428
+ case 2:
1429
+ afterYi = "00" + afterYi;
1430
+ break;
1431
+ case 3:
1432
+ afterYi = "0" + afterYi;
1433
+ break;
1434
+ }
1435
+ v = v.substring(0, v.indexOf("亿") + 1) + afterYi;
1436
+ }
1437
+ } else if (v.indexOf("亿") == -1 && v.indexOf("万") != -1) {
1438
+ //3万0011
1439
+ var afterWan = v.substring(v.indexOf("万") + 1);
1440
+ if (afterWan.substring(0, 1) !== "." && afterWan != "") {
1441
+ switch ((parseInt(afterWan) + "").length) {
1442
+ case 1:
1443
+ afterWan = "000" + afterWan;
1444
+ break;
1445
+ case 2:
1446
+ afterWan = "00" + afterWan;
1447
+ break;
1448
+ case 3:
1449
+ afterWan = "0" + afterWan;
1450
+ break;
1451
+ }
1452
+ v = v.substring(0, v.indexOf("万") + 1) + afterWan;
1453
+ }
1454
+ } else if (v.indexOf("亿") != -1 && v.indexOf("万") != -1) {
1455
+ //1亿0053万0611
1456
+ var afterYi = v.substring(v.indexOf("亿") + 1, v.indexOf("万")),
1457
+ afterWan = v.substring(v.indexOf("万") + 1);
1458
+ switch ((parseInt(afterYi) + "").length) {
1459
+ case 1:
1460
+ afterYi = "000" + afterYi;
1461
+ break;
1462
+ case 2:
1463
+ afterYi = "00" + afterYi;
1464
+ break;
1465
+ case 3:
1466
+ afterYi = "0" + afterYi;
1467
+ break;
1468
+ }
1469
+ v = v.substring(0, v.indexOf("亿") + 1) + afterYi + v.substring(v.indexOf("万"));
1470
+ if (afterWan.substring(0, 1) !== "." && afterWan != "") {
1471
+ switch ((parseInt(afterWan) + "").length) {
1472
+ case 1:
1473
+ afterWan = "000" + afterWan;
1474
+ break;
1475
+ case 2:
1476
+ afterWan = "00" + afterWan;
1477
+ break;
1478
+ case 3:
1479
+ afterWan = "0" + afterWan;
1480
+ break;
1481
+ }
1482
+ v = v.substring(0, v.indexOf("万") + 1) + afterWan;
1483
+ }
1484
+ }
1485
+ } else {
1486
+ if (acc != "") {
1487
+ v = numeral(v).format(acc); //处理精确度
1488
+ }
1489
+ }
1490
+ if (isNegative) {
1491
+ return "-" + v;
1492
+ } else {
1493
+ return v;
1494
+ }
1495
+ }
1496
+ if (isgeneral(sfmt, 0)) return general_fmt(v, o);
1497
+ if (v instanceof Date) v = datenum_local(v, o.date1904);
1498
+ var f = choose_fmt(sfmt, v);
1499
+ if (isgeneral(f[1])) return general_fmt(v, o);
1500
+ if (v === true) v = "TRUE";else if (v === false) v = "FALSE";else if (v === "" || v == null) return "";
1501
+ return eval_fmt(f[1], v, o, f[0]);
1502
+ }
1503
+ function load_entry(fmt, idx) {
1504
+ if (typeof idx != "number") {
1505
+ idx = +idx || -1;
1506
+ for (var i = 0; i < 0x0188; ++i) {
1507
+ if (table_fmt[i] == undefined) {
1508
+ if (idx < 0) idx = i;
1509
+ continue;
1510
+ }
1511
+ if (table_fmt[i] == fmt) {
1512
+ idx = i;
1513
+ break;
1514
+ }
1515
+ }
1516
+ if (idx < 0) idx = 0x187;
1517
+ }
1518
+ table_fmt[idx] = fmt;
1519
+ return idx;
1520
+ }
1521
+ SSF.load = load_entry;
1522
+ SSF._table = table_fmt;
1523
+ SSF.get_table = function get_table() {
1524
+ return table_fmt;
1525
+ };
1526
+ SSF.load_table = function load_table(tbl) {
1527
+ for (var i = 0; i != 0x0188; ++i) if (tbl[i] !== undefined) load_entry(tbl[i], i);
1528
+ };
1529
+ SSF.init_table = init_table;
1530
+ SSF.format = format;
1531
+ };
1532
+ make_ssf(SSF);
1533
+ export default SSF;