@8sheets/data-grid 0.0.0-stage → 1.0.0

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 (290) hide show
  1. package/LICENSE.md +36 -0
  2. package/README.md +52 -2
  3. package/a11y/cell-alt-text.js +1 -0
  4. package/api/overlay.js +1 -0
  5. package/api/serialize.js +1 -0
  6. package/api/skins.js +1 -0
  7. package/api/style-refs.js +1 -0
  8. package/api/watermark-xml.js +2 -0
  9. package/calc/adjust.js +1 -0
  10. package/calc/cell-set.js +1 -0
  11. package/calc/compile.js +1 -0
  12. package/calc/engine.js +1 -0
  13. package/calc/fill-shape.js +2 -0
  14. package/calc/functions/array.js +1 -0
  15. package/calc/functions/database.js +1 -0
  16. package/calc/functions/date.js +1 -0
  17. package/calc/functions/engineering.js +1 -0
  18. package/calc/functions/financial.js +1 -0
  19. package/calc/functions/helpers.js +1 -0
  20. package/calc/functions/index.js +1 -0
  21. package/calc/functions/info.js +1 -0
  22. package/calc/functions/logical.js +1 -0
  23. package/calc/functions/lookup.js +1 -0
  24. package/calc/functions/math.js +1 -0
  25. package/calc/functions/registry.js +1 -0
  26. package/calc/functions/stat.js +1 -0
  27. package/calc/functions/text.js +1 -0
  28. package/calc/parser.js +3 -0
  29. package/calc/values.js +1 -0
  30. package/calcx/ai/client.js +1 -0
  31. package/calcx/ai/functions.js +15 -0
  32. package/calcx/ai/settings.js +1 -0
  33. package/calcx/async.js +1 -0
  34. package/calcx/culture/format-locale.js +1 -0
  35. package/calcx/culture/lcid.js +1 -0
  36. package/calcx/external-read.js +1 -0
  37. package/calcx/external-write.js +3 -0
  38. package/calcx/external.js +1 -0
  39. package/calcx/functions/dynamic.js +1 -0
  40. package/calcx/functions/ets.js +1 -0
  41. package/calcx/functions/index.js +1 -0
  42. package/calcx/functions/misc.js +1 -0
  43. package/calcx/functions/text.js +1 -0
  44. package/calcx/functions/xml.js +1 -0
  45. package/calcx/refresh.js +1 -0
  46. package/cells/auto-merge.js +1 -0
  47. package/cells/axis-limits.js +1 -0
  48. package/cells/axis-ops.js +1 -0
  49. package/cells/background-xml.js +1 -0
  50. package/cells/background.js +1 -0
  51. package/cells/book-css.js +206 -0
  52. package/cells/book-read.js +1 -0
  53. package/cells/book-view.js +1 -0
  54. package/cells/cell-defaults.js +1 -0
  55. package/cells/cell-extras.js +1 -0
  56. package/cells/cell-options-ui.js +1 -0
  57. package/cells/cell-styles-xml.js +1 -0
  58. package/cells/cf-engine.js +1 -0
  59. package/cells/cf-file.js +1 -0
  60. package/cells/cf-paint.js +1 -0
  61. package/cells/consolidate-links.js +1 -0
  62. package/cells/docprops-xml.js +2 -0
  63. package/cells/filter-file.js +1 -0
  64. package/cells/find-engine.js +2 -0
  65. package/cells/find.js +1 -0
  66. package/cells/format-code.js +1 -0
  67. package/cells/format-panes.js +3 -0
  68. package/cells/format-tabs.js +102 -0
  69. package/cells/goto.js +1 -0
  70. package/cells/header-colors.js +1 -0
  71. package/cells/mask.js +1 -0
  72. package/cells/menu-extras.js +1 -0
  73. package/cells/name-box.js +1 -0
  74. package/cells/note-xml.js +1 -0
  75. package/cells/options.js +1 -0
  76. package/cells/outline-column.js +1 -0
  77. package/cells/paint.js +1 -0
  78. package/cells/panes.js +1 -0
  79. package/cells/rich-data-xml.js +2 -0
  80. package/cells/rich-data.js +1 -0
  81. package/cells/rich-runs.js +2 -0
  82. package/cells/rich-values.js +1 -0
  83. package/cells/rich-xml.js +1 -0
  84. package/cells/rounded.js +1 -0
  85. package/cells/sections.js +2 -0
  86. package/cells/selection-modes.js +1 -0
  87. package/cells/style-xml.js +1 -0
  88. package/cells/text-layout.js +8 -0
  89. package/cells/undo-group.js +1 -0
  90. package/cells/validation-alert.js +2 -0
  91. package/cells/view-options.js +1 -0
  92. package/cells/view-xml.js +1 -0
  93. package/celltypes/barcode-tables.js +31 -0
  94. package/celltypes/barcode.js +2 -0
  95. package/celltypes/base.js +1 -0
  96. package/celltypes/cell-buttons.js +1 -0
  97. package/celltypes/cell-types.js +2 -0
  98. package/celltypes/data-object.js +1 -0
  99. package/celltypes/diagonal.js +1 -0
  100. package/celltypes/dropdowns-more.js +13 -0
  101. package/celltypes/dropdowns.js +42 -0
  102. package/celltypes/file-cell.js +2 -0
  103. package/celltypes/glyphs.js +1 -0
  104. package/celltypes/persist.js +2 -0
  105. package/celltypes/range-template.js +2 -0
  106. package/charts/chartex.js +3 -0
  107. package/charts/geo/geo-xml.js +1 -0
  108. package/charts/geo/map-state.js +1 -0
  109. package/charts/patterns.js +1 -0
  110. package/core/address.js +1 -0
  111. package/core/axis.js +1 -0
  112. package/core/base64.js +1 -0
  113. package/core/changes.js +1 -0
  114. package/core/color.js +1 -0
  115. package/core/cond-format.js +1 -0
  116. package/core/custom-views.js +1 -0
  117. package/core/default-names.js +1 -0
  118. package/core/formula-refs.js +1 -0
  119. package/core/formula-store.js +1 -0
  120. package/core/input.js +1 -0
  121. package/core/math.js +1 -0
  122. package/core/numfmt.js +1 -0
  123. package/core/online.js +1 -0
  124. package/core/protection.js +1 -0
  125. package/core/regexp.js +1 -0
  126. package/core/sheet.js +1 -0
  127. package/core/sparklines.js +1 -0
  128. package/core/sparse.js +1 -0
  129. package/core/strings.js +1 -0
  130. package/core/styles.js +1 -0
  131. package/core/table-presets.js +7 -0
  132. package/core/tables.js +2 -0
  133. package/core/tsv.js +4 -0
  134. package/core/whatif.js +1 -0
  135. package/core/workbook.js +1 -0
  136. package/datasheets/bind.js +1 -0
  137. package/datasheets/calendar.js +1 -0
  138. package/datasheets/cross.js +1 -0
  139. package/datasheets/data-core.js +1 -0
  140. package/datasheets/data.js +1 -0
  141. package/datasheets/formula.js +1 -0
  142. package/datasheets/gantt-paint.js +1 -0
  143. package/datasheets/gantt-resources.js +1 -0
  144. package/datasheets/gantt-shapes.js +1 -0
  145. package/datasheets/gantt.js +1 -0
  146. package/datasheets/manager.js +1 -0
  147. package/datasheets/path-binding.js +2 -0
  148. package/datasheets/persist-writer.js +2 -0
  149. package/datasheets/persist.js +1 -0
  150. package/datasheets/query-function.js +1 -0
  151. package/datasheets/remote.js +3 -0
  152. package/datasheets/report-entry.js +1 -0
  153. package/datasheets/report.js +1 -0
  154. package/datasheets/rules.js +1 -0
  155. package/datasheets/sort.js +1 -0
  156. package/datasheets/table-sheet.js +1 -0
  157. package/datasheets/view.js +3 -0
  158. package/datasheets/virtual-sheet.js +1 -0
  159. package/datasheets/window.js +1 -0
  160. package/extras/getdata/persist.js +2 -0
  161. package/extras/getdata/rows.js +1 -0
  162. package/extras/getdata/steps.js +1 -0
  163. package/i18n/dom.js +1 -0
  164. package/i18n/en/a11y.js +1 -0
  165. package/i18n/en/cells.js +1 -0
  166. package/i18n/en/charts.js +1 -0
  167. package/i18n/en/common.js +1 -0
  168. package/i18n/en/datasheets.js +1 -0
  169. package/i18n/en/format.js +1 -0
  170. package/i18n/en/misc.js +1 -0
  171. package/i18n/en/pivot.js +1 -0
  172. package/i18n/en/proofing.js +1 -0
  173. package/i18n/en/ribbon.js +1 -0
  174. package/i18n/en/shapes.js +1 -0
  175. package/i18n/en/shell.js +1 -0
  176. package/i18n/en/touch.js +1 -0
  177. package/i18n/en.js +1 -0
  178. package/i18n/index.js +1 -0
  179. package/i18n/key-text.js +1 -0
  180. package/i18n/languages.js +1 -0
  181. package/i18n/pl/a11y.js +1 -0
  182. package/i18n/pl/cells.js +1 -0
  183. package/i18n/pl/charts.js +1 -0
  184. package/i18n/pl/common.js +1 -0
  185. package/i18n/pl/datasheets.js +1 -0
  186. package/i18n/pl/format.js +1 -0
  187. package/i18n/pl/misc.js +1 -0
  188. package/i18n/pl/pivot.js +1 -0
  189. package/i18n/pl/proofing.js +1 -0
  190. package/i18n/pl/ribbon.js +1 -0
  191. package/i18n/pl/shapes.js +1 -0
  192. package/i18n/pl/shell.js +1 -0
  193. package/i18n/pl/touch.js +1 -0
  194. package/i18n/pl.js +1 -0
  195. package/io/client.js +1 -0
  196. package/io/crc32.js +1 -0
  197. package/io/crypto/aes.js +1 -0
  198. package/io/crypto/agile.js +2 -0
  199. package/io/crypto/cfb-read.js +1 -0
  200. package/io/crypto/cfb-write.js +1 -0
  201. package/io/crypto/dataspaces.js +1 -0
  202. package/io/crypto/errors.js +1 -0
  203. package/io/crypto/hash.js +1 -0
  204. package/io/crypto/index.js +1 -0
  205. package/io/crypto/package-read.js +1 -0
  206. package/io/crypto/package-write.js +1 -0
  207. package/io/crypto/spool.js +1 -0
  208. package/io/crypto/standard.js +1 -0
  209. package/io/csv.js +5 -0
  210. package/io/export-blocks.js +1 -0
  211. package/io/foreign-parts.js +1 -0
  212. package/io/foreign-sheets.js +2 -0
  213. package/io/io.worker.js +1 -0
  214. package/io/package-paths.js +1 -0
  215. package/io/plan.js +1 -0
  216. package/io/xlsx-read.js +1 -0
  217. package/io/xlsx-styles.js +2 -0
  218. package/io/xlsx-tail.js +1 -0
  219. package/io/xlsx-write.js +2 -0
  220. package/io/xml-escape.js +1 -0
  221. package/io/xml-scan.js +1 -0
  222. package/io/zip-reader.js +1 -0
  223. package/io/zip-writer.js +1 -0
  224. package/objects/chart-model.js +1 -0
  225. package/objects/dml.js +5 -0
  226. package/objects/drawing-xml.js +1 -0
  227. package/objects/picture-url.js +1 -0
  228. package/package.json +57 -4
  229. package/pivot/engine.js +1 -0
  230. package/pivot/xml.js +2 -0
  231. package/print/page-setup.js +1 -0
  232. package/print/paginate.js +1 -0
  233. package/print/pdf.js +35 -0
  234. package/print/render-page.js +3 -0
  235. package/render/patterns.js +1 -0
  236. package/shapes/form-xml.js +1 -0
  237. package/shapes/watermark.js +1 -0
  238. package/slicers/custom-styles.js +1 -0
  239. package/slicers/date-filters.js +1 -0
  240. package/slicers/format.js +2 -0
  241. package/slicers/pivot-file.js +1 -0
  242. package/slicers/structured.js +1 -0
  243. package/slicers/table-file.js +1 -0
  244. package/slicers/write.js +1 -0
  245. package/sparklines/colors.js +1 -0
  246. package/sparklines/data.js +1 -0
  247. package/sparklines/descriptor.js +1 -0
  248. package/sparklines/excel-paint.js +1 -0
  249. package/sparklines/functions.js +1 -0
  250. package/sparklines/paint-core.js +1 -0
  251. package/sparklines/paint-measure.js +1 -0
  252. package/sparklines/paint-other.js +2 -0
  253. package/sparklines/paint-series.js +1 -0
  254. package/sparklines/paint.js +1 -0
  255. package/sparklines/print.js +1 -0
  256. package/sparklines/rule.js +1 -0
  257. package/table-view/api.js +1 -0
  258. package/table-view/cell-editor.js +1 -0
  259. package/table-view/cell-format.js +1 -0
  260. package/table-view/chrome.js +1 -0
  261. package/table-view/client.js +1 -0
  262. package/table-view/column-drag.js +1 -0
  263. package/table-view/column-input.js +1 -0
  264. package/table-view/column-window.js +1 -0
  265. package/table-view/events.js +1 -0
  266. package/table-view/files.js +1 -0
  267. package/table-view/grid-keys.js +2 -0
  268. package/table-view/index.d.ts +4 -0
  269. package/table-view/index.js +1 -0
  270. package/table-view/labels.js +1 -0
  271. package/table-view/model.js +1 -0
  272. package/table-view/mount.js +1 -0
  273. package/table-view/panel.js +1 -0
  274. package/table-view/pivot.js +1 -0
  275. package/table-view/public.d.ts +841 -0
  276. package/table-view/quick-filter.js +1 -0
  277. package/table-view/reader.worker.js +1 -0
  278. package/table-view/remote.js +1 -0
  279. package/table-view/row-cache.js +1 -0
  280. package/table-view/row-selection.js +1 -0
  281. package/table-view/table-css.js +1207 -0
  282. package/table-view/totals.js +1 -0
  283. package/table-view/version.js +1 -0
  284. package/table-view/worksheet-table.js +1 -0
  285. package/ui/dialogs.js +3 -0
  286. package/ui/dom.js +1 -0
  287. package/ui/icons.js +1 -0
  288. package/ui/menu-base.js +1 -0
  289. package/ui/protection-ui.js +1 -0
  290. package/ui/ui-scale.js +1 -0
@@ -0,0 +1 @@
1
+ import{el as c,openModal as M}from"../ui/dialogs.js";import{viewGet as i,viewSet as P}from"./book-view.js";import{ensureBookCss as U}from"./book-css.js";import{t as b}from"../i18n/index.js";function F(e){const t=e.el("app"),{book:o}=e;if(i(o,"showFormulaBar")&&i(o,"showStatusBar")&&!i(o,"ribbonMinimized")&&!i(o,"formulaBarExpanded")&&i(o,"showTabs")&&i(o,"tabPosition")==="bottom"){t.style.removeProperty("grid-template-rows");return}const s=d=>`calc(${d}px * var(--ui-scale))`,n={titlebar:s(38),tabs:s(28),ribbon:"auto","formula-bar":i(o,"formulaBarExpanded")?"auto":s(26),"ds-bar-host":"auto",workspace:"minmax(0, 1fr)",sheetbar:s(24),statusbar:s(28)},r=[];for(const d of t.children)getComputedStyle(d).display!=="none"&&r.push(n[d.id]??"auto");t.style.gridTemplateRows=r.join(" ")}function V(e){const{book:t,grid:o}=e,l=e.el("app");l.classList.toggle("no-formula-bar",!i(t,"showFormulaBar")),l.classList.toggle("bk-fx-expanded",i(t,"formulaBarExpanded"));const s=e.el("statusbar");s.hidden=!i(t,"showStatusBar"),e.el("ribbon").hidden=i(t,"ribbonMinimized");const n=i(t,"widgetBorder");l.style.outline=n?`${n.width??1}px ${n.style??"solid"} ${n.color??"currentColor"}`:"",l.style.outlineOffset=n?`-${n.width??1}px`:"";const r=e.el("name-box")?.parentElement;r&&(r.style.width=`${i(t,"nameBoxWidth")}px`),o.focusCell=i(t,"focusCell");const d=i(t,"selectionBackColor"),h=i(t,"selectionBorderColor"),f=d||h?{...d?{selectionFill:`${d}38`}:{},...h?{accent:h}:{}}:null;(f||o.themeOverride)&&(o.themeOverride=f,o.setMode(o.mode)),F(e)}function $(e){const{book:t,grid:o}=e,l=o.host,s=i(t,"scrollbarShowMax"),n=i(t,"scrollbarMaxAlign"),r=i(t,"scrollByCell"),d=i(t,"scrollPixel"),h=r||d!==1,f=i(t,"scrollAppearance"),g=f==="skin";o.scrollOpts=s||n||h||g?{showMax:s,maxAlign:n,custom:h,byCell:r,pixel:d,arrows:g}:null,g&&W(o);for(const a of[o.barV,o.barH])a.track.classList.toggle("bk-has-ends",g);o.scrollByCell=r,l.classList.toggle("bk-sb-skin",f==="skin"),l.classList.toggle("bk-sb-mobile",f==="mobile");const m=i(t,"scrollColors");l.classList.toggle("bk-sb-colors",!!m),e.el("sheetbar")?.classList.toggle("bk-sb-colors",!!m);for(const a of[l,e.el("sheetbar")])a&&(m?.thumb?a.style.setProperty("--bk-sb-thumb",m.thumb):a.style.removeProperty("--bk-sb-thumb"),m?.track?a.style.setProperty("--bk-sb-track",m.track):a.style.removeProperty("--bk-sb-track"));o.barV.track.hidden=!i(t,"showVScroll"),o.barH.track.hidden=!i(t,"showHScroll"),o.scrollTo(o.scrollX,o.scrollY),o.invalidateTop()}let T=null;function J(e){T=e}function N(e){U(),V(e),T?.(e),$(e),F(e),e.book.allowUndo=i(e.book,"allowUndo")}function w(e,t,o){P(e.book,t,o),N(e),e.shell.syncTitle(),e.ribbon.render()}const Q=e=>w(e,"ribbonMinimized",!i(e.book,"ribbonMinimized")),ee=e=>w(e,"formulaBarExpanded",!i(e.book,"formulaBarExpanded"));function L(e,t,o){const{book:l,grid:s}=e;l.sheet[t]=o,l.sheet.viewChanged=!0,l.dirty=!0,s[t]=o,s.invalidate(),e.shell.syncTitle(),e.ribbon.render()}const G=(e,t)=>L(e,"hideHeadings",!t),R=(e,t)=>L(e,"hideOutline",!t),oe=e=>R(e,e.book.sheet.hideOutline===!0);function I(e,t){const{sheet:o}=e.book;o.hideZeros=!t,o.viewChanged=!0,e.book.dirty=!0,e.grid.invalidate()}function D(e,t,o){const{sheet:l}=e.book,s={horizontal:l.gridlineAxes?.horizontal!==!1,vertical:l.gridlineAxes?.vertical!==!1,[t]:o};l.gridlineAxes=s.horizontal&&s.vertical?void 0:s,e.book.dirty=!0,e.grid.invalidate()}function K(e,t){const{sheet:o}=e.book;o.gridColorId=t,o.viewChanged=!0,e.book.dirty=!0,e.grid.invalidate()}function H(e,t,o){const{sheet:l}=e,s=e._frozen();if(t==="row"){const n=l.rows;let r=n.indexAt(e.scrollY+s.h)+o;for(;r>l.frozenRows&&r<n.count&&n.sizeOf(r)===0;)r+=o;e.scrollTo(e.scrollX,n.offsetOf(Math.max(l.frozenRows,r))-s.h)}else{const n=l.cols;let r=n.indexAt(e.scrollX+s.w)+o;for(;r>l.frozenCols&&r<n.count&&n.sizeOf(r)===0;)r+=o;e.scrollTo(n.offsetOf(Math.max(l.frozenCols,r))-s.w,e.scrollY)}}function W(e){if(e.barEnds)return;e.barEnds=!0;const t=(o,l,s)=>{const n=document.createElement("button");n.type="button",n.className=`sb-end ${s?"sb-end-start":"sb-end-stop"}`,n.tabIndex=-1,n.setAttribute("aria-label",b(l==="row"?s?"Scroll up one row":"Scroll down one row":s?"Scroll left one column":"Scroll right one column")),n.addEventListener("pointerdown",r=>{r.preventDefault(),r.stopPropagation();const d=(s?-1:1)*(l==="col"&&e.rtl?-1:1);H(e,l,d);let h=setTimeout(()=>{h=setInterval(()=>H(e,l,d),60)},350);const f=()=>{clearTimeout(h),clearInterval(h),window.removeEventListener("pointerup",f,!0)};window.addEventListener("pointerup",f,!0)}),o.track.append(n)};t(e.barV,"row",!0),t(e.barV,"row",!1),t(e.barH,"col",!0),t(e.barH,"col",!1)}function te(e,t){const o=e.scrollOpts,l=t.deltaMode===1?16:t.deltaMode===2?e.cssH:1;let s=(e.rtl?-t.deltaX:t.deltaX)*l,n=t.deltaY*l;if(t.shiftKey&&s===0&&(s=n,n=0),!o.byCell){e.scrollTo(e.scrollX+s*o.pixel/e.zoom,e.scrollY+n*o.pixel/e.zoom);return}const{sheet:r}=e,d=e._frozen(),h=e.wheelAcc??={x:0,y:0};h.x+=s*o.pixel,h.y+=n*o.pixel;const f=p=>Math.trunc(p/16),g=(p,S,B)=>{let O=S;const E=Math.sign(B);for(let z=Math.abs(B);z>0;z--){let C=O+E;for(;C>=0&&C<p.count&&p.sizeOf(C)===0;)C+=E;if(C<0||C>=p.count)break;O=C}return O};let{scrollX:m,scrollY:a}=e;const x=f(h.y);x!==0&&(h.y-=x*16,a=r.rows.offsetOf(g(r.rows,r.rows.indexAt(a+d.h),x))-d.h);const k=f(h.x);k!==0&&(h.x-=k*16,m=r.cols.offsetOf(g(r.cols,r.cols.indexAt(m+d.w),k))-d.w),e.scrollTo(m,a)}function le(e){e.addSheet()}function se(e,t){const{book:o}=e,l=o.sheets.length;let s=o.activeSheet+t;for(;s>=0&&s<l&&o.sheets[s].hidden;)s+=t;s<0||s>=l||(o.selectedSheets&&!o.selectedSheets.has(o.sheets[s])&&(o.selectedSheets=null),e.switchSheet(s))}function re(e,t){const o=e.view?.fixedDecimal;return!o||!/^[-+]?\d+$/.test(t)?t:String(Number(t)/10**o)}function u(e,t,o){const l=c("input",{type:"checkbox",checked:t});return l.addEventListener("change",()=>o(l.checked)),c("label",{class:"dlg-row dlg-check"},l,` ${b(e)}`)}function A(e,t,o,l){const s=c("select",{class:"dlg-input","aria-label":b(e)});for(const[n,r]of t)s.append(c("option",{value:r,textContent:b(n)}));return s.value=o,s.addEventListener("change",()=>l(s.value)),c("label",{class:"dlg-row"},`${b(e)} `,s)}const v=(e,t)=>c("label",{class:"dlg-row"},`${b(e)} `,t),y=e=>c("div",{class:"bk-section",textContent:b(e)}),X=[["Automatic",""],["Black","8"],["Dark Gray","23"],["Gray","22"],["Red","10"],["Green","17"],["Blue","12"],["Teal","21"],["Purple","20"],["Orange","53"]];function ne(e){const{book:t}=e,{sheet:o}=t,l=r=>i(t,r),s=r=>d=>w(e,r,d),n=c("div",{},y("Show"),c("div",{class:"bk-grid2"},u("Formula bar",l("showFormulaBar"),s("showFormulaBar")),u("Status bar",l("showStatusBar"),s("showStatusBar")),u("Sheet tabs",l("showTabs"),s("showTabs")),u("Horizontal scroll bar",l("showHScroll"),s("showHScroll")),u("Vertical scroll bar",l("showVScroll"),s("showVScroll")),u("Ribbon",!l("ribbonMinimized"),r=>w(e,"ribbonMinimized",!r))),y("In this sheet"),c("div",{class:"bk-grid2"},u("Headings",o.hideHeadings!==!0,r=>G(e,r)),u("Gridlines",o.showGridlines,()=>e.commands.toggleGridlines()),u("Outline symbols",o.hideOutline!==!0,r=>R(e,r)),u("Zero values",o.hideZeros!==!0,r=>I(e,r))),A("Gridline color:",X,o.gridColorId===null||o.gridColorId===void 0?"":String(o.gridColorId),r=>K(e,r===""?null:Number(r))),c("div",{class:"bk-grid2"},u("Horizontal gridlines",o.gridlineAxes?.horizontal!==!1,r=>D(e,"horizontal",r)),u("Vertical gridlines",o.gridlineAxes?.vertical!==!1,r=>D(e,"vertical",r))),y("Scrolling"),A("Scroll bars:",[["As on macOS","overlay"],["Always visible, with arrows","skin"],["Thin","mobile"]],l("scrollAppearance"),s("scrollAppearance")),c("div",{class:"dlg-row"},c("button",{type:"button",class:"dlg-btn",textContent:b("Scroll Bars and Border…"),on:{click:()=>Z(e)}})),c("div",{class:"bk-grid2"},u("Scroll by whole rows and columns",l("scrollByCell"),s("scrollByCell")),u("Scroll bars span the whole sheet",l("scrollbarShowMax"),s("scrollbarShowMax")),u("End scrolling at the last used cell",l("scrollbarMaxAlign"),s("scrollbarMaxAlign"))),v("Wheel speed:",(()=>{const r=c("input",{class:"dlg-input short",type:"number",min:.25,max:20,step:.25,value:l("scrollPixel")});return r.addEventListener("change",()=>w(e,"scrollPixel",Math.max(.25,Math.min(20,Number(r.value)||1)))),r})()),y("Tab strip"),A("Position:",[["Bottom","bottom"],["Top","top"],["Left","left"],["Right","right"]],l("tabPosition"),s("tabPosition")),c("div",{class:"bk-grid2"},u("New sheet button",l("newTab"),s("newTab")),u("Navigation arrows",l("tabNav"),s("tabNav")),u("Sheets can be reordered",l("allowSheetReorder"),s("allowSheetReorder")),u("Sheets can be renamed",l("tabEditable"),s("tabEditable"))),A("All sheets button:",[["When needed","auto"],["Always","show"],["Never","hide"]],l("allSheets"),s("allSheets")));M(e,"View Options",c("div",{class:"bk-scroll"},n),[{label:"OK",primary:!0}],{width:480})}function Z(e){const{book:t}=e,o=a=>i(t,a),l=(a,x,k,p)=>{const S=c("input",{type:"checkbox",checked:!!x,"aria-label":b("Use {name}",{name:b(a)})}),B=c("input",{type:"color",class:"dlg-color",value:x??k,"aria-label":b(a)}),O=()=>p(S.checked?B.value.toUpperCase():null);return S.addEventListener("change",O),B.addEventListener("input",()=>{S.checked=!0,O()}),c("label",{class:"dlg-row"},S,` ${b(a)} `,B)},s=()=>o("scrollColors")??{},n=a=>x=>{const k={...s(),[a]:x};k[a]||delete k[a],w(e,"scrollColors",Object.keys(k).length?k:null)},r=()=>o("widgetBorder"),d=c("input",{type:"checkbox",checked:!!r(),"aria-label":b("Border around the workbook")}),h=c("select",{class:"dlg-input","aria-label":b("Border style")});for(const[a,x]of[["solid","line|Solid"],["dashed","line|Dashed"],["dotted","line|Dotted"],["double","line|Double"]])h.append(c("option",{value:a,textContent:b(x)}));h.value=r()?.style??"solid";const f=c("input",{class:"dlg-input short",type:"number",min:1,max:12,value:r()?.width??1,"aria-label":b("Border width")}),g=c("input",{type:"color",class:"dlg-color",value:r()?.color??"#808080","aria-label":b("Border color")}),m=()=>w(e,"widgetBorder",d.checked?{style:h.value,width:Math.max(1,Math.min(12,Number(f.value)||1)),color:g.value.toUpperCase()}:null);d.addEventListener("change",m);for(const a of[h,f,g])a.addEventListener("input",()=>{d.checked=!0,m()});M(e,"Scroll Bars and Border",c("div",{class:"dlg-col"},y("Scroll bars"),A("Style:",[["As on macOS","overlay"],["Always visible, with arrows","skin"],["Thin","mobile"]],o("scrollAppearance"),a=>w(e,"scrollAppearance",a)),l("Thumb color",s().thumb,"#808080",n("thumb")),l("Track color",s().track,"#E0E0E0",n("track")),y("Selection"),l("Fill color",o("selectionBackColor"),"#107C41",a=>w(e,"selectionBackColor",a)),l("Border color",o("selectionBorderColor"),"#107C41",a=>w(e,"selectionBorderColor",a)),y("Border around the workbook"),c("label",{class:"dlg-row"},d,` ${b("Show a border")}`),v("Style:",h),v("Width:",f),v("Color:",g)),[{label:"OK",primary:!0}],{width:360})}function ie(e){const{book:t,grid:o}=e,l=i(t,"focusCell")??o.focusCell??{color:"#FFF2CC",colColor:"#FFF2CC",alpha:.35},s=c("input",{type:"checkbox",checked:!!o.focusCell}),n=c("input",{type:"color",class:"dlg-color",value:l.color??"#FFF2CC"}),r=c("input",{type:"color",class:"dlg-color",value:l.colColor??l.color??"#FFF2CC"}),d=c("input",{type:"range",min:5,max:80,value:Math.round((l.alpha??.35)*100),"aria-label":b("Strength")}),h=()=>{w(e,"focusCell",s.checked?{color:n.value.toUpperCase(),colColor:r.value.toUpperCase(),alpha:Number(d.value)/100}:null),o.invalidateTop()};for(const f of[s,n,r,d])f.addEventListener("input",h);M(e,"Focus Cell",c("div",{class:"dlg-col"},c("label",{class:"dlg-row dlg-check"},s,` ${b("Highlight the row and column of the active cell")}`),v("Row color:",n),v("Column color:",r),v("Strength:",d)),[{label:"OK",primary:!0}],{width:360})}function ce(e){const{book:t}=e,o=i(t,"tips"),l=n=>r=>w(e,"tips",{...i(t,"tips"),[n]:r}),s=c("input",{class:"dlg-input short",type:"number",min:0,max:15,value:i(t,"fixedDecimal")});s.addEventListener("change",()=>w(e,"fixedDecimal",Math.max(0,Math.min(15,Math.trunc(Number(s.value)||0))))),M(e,"Editing Options",c("div",{class:"dlg-col"},A("After pressing Return, move:",[["dir|Down","down"],["dir|Right","right"],["dir|Up","up"],["dir|Left","left"],["Don't move","none"]],i(t,"enterDirection"),n=>w(e,"enterDirection",n)),v("Fixed decimal places:",s),u("Cmd over a selected cell takes it out of the selection",i(t,"allowUserDeselect"),n=>w(e,"allowUserDeselect",n)),u("Cmd and the arrow keys take cells out of the selection",i(t,"deselectKeys"),n=>w(e,"deselectKeys",n)),u("Zoom with Cmd and the wheel",i(t,"allowUserZoom"),n=>w(e,"allowUserZoom",n)),u("Keep undo history",i(t,"allowUndo"),n=>w(e,"allowUndo",n)),u("Context menus",i(t,"allowContextMenu"),n=>w(e,"allowContextMenu",n)),y("Tips"),u("Size while resizing",o.resize!==!1,l("resize")),u("Row or column while scrolling",o.scroll!==!1,l("scroll")),u("Value while filling",o.fill!==!1,l("fill")),u("Place while dragging cells",o.drop!==!1,l("drop"))),[{label:"OK",primary:!0}],{width:400})}export{le as addSheetFromUi,N as applyBookView,re as applyFixedDecimal,F as layoutApp,se as nextVisibleSheet,J as onApplyTabs,ce as openEditingOptions,ie as openFocusCellDialog,Z as openScrollbarAndBorder,ne as openViewOptions,D as setGridAxis,K as setGridColor,G as setHeadings,R as setOutlineSymbols,w as setViewOption,I as setZeros,ee as toggleFormulaBarSize,oe as toggleOutlineSymbols,Q as toggleRibbon,te as wheelWithOptions};
@@ -0,0 +1 @@
1
+ import{colName as h}from"../core/address.js";import{escapeMarkup as u}from"../io/xml-escape.js";const m=new Set(["showGridLines","rightToLeft","tabSelected","zoomScale","zoomScaleNormal","zoomScalePageLayoutView","view","showRuler","showRowColHeaders","showOutlineSymbols","showZeros","defaultGridColor","colorId","workbookViewId"]),c=new Set(["pageLayout","pageBreakPreview"]);function b(e,o){let t="";if(e.showGridlines||(t+=' showGridLines="0"'),e.hideHeadings&&(t+=' showRowColHeaders="0"'),e.hideOutline&&(t+=' showOutlineSymbols="0"'),e.hideZeros&&(t+=' showZeros="0"'),e.gridColorId!==void 0&&e.gridColorId!==null&&(t+=` defaultGridColor="0" colorId="${e.gridColorId}"`),e.rtl&&(t+=' rightToLeft="1"'),e.hideRuler&&(t+=' showRuler="0"'),o&&(t+=' tabSelected="1"'),c.has(e.viewMode)&&(t+=` view="${e.viewMode}"`),e.zoom!==1&&(t+=` zoomScale="${Math.round(e.zoom*100)}"`),e.zoomNormal&&e.zoomNormal!==1&&(t+=` zoomScaleNormal="${Math.round(e.zoomNormal*100)}"`),e.zoomPageLayout&&e.zoomPageLayout!==1&&(t+=` zoomScalePageLayoutView="${Math.round(e.zoomPageLayout*100)}"`),e.split?.firstTopLeft&&(t+=` topLeftCell="${e.split.firstTopLeft}"`),e.viewRaw)for(const[l,r]of Object.entries(e.viewRaw))!m.has(l)&&!(l==="topLeftCell"&&e.split)&&(t+=` ${l}="${u(r)}"`);return t}const d=23,n=22;function g(e){const o=e.split;if(!o||!o.x&&!o.y)return"";const t=o.x&&o.y?"bottomRight":o.y?"bottomLeft":"topRight";return`<pane${(o.x?` xSplit="${Math.round((o.x+d)*20)}"`:"")+(o.y?` ySplit="${Math.round((o.y+n)*20)}"`:"")}${o.mainTopLeft?` topLeftCell="${o.mainTopLeft}"`:""} activePane="${t}"/>`}function S(e){const o=e.split;if(!o)return null;const t=(l,r)=>h(e.cols.indexAt(l))+(e.rows.indexAt(r)+1);return{x:o.x,y:o.y,firstTopLeft:t(o.scrollX,o.scrollY),mainTopLeft:t((o.mainX??0)+o.x,(o.mainY??0)+o.y)}}function z(e,o){if(!e.xSplit&&!e.ySplit)return;const t=e.xSplit?Math.max(0,Number(e.xSplit)/20-d):0,l=e.ySplit?Math.max(0,Number(e.ySplit)/20-n):0;(t>0||l>0)&&(o.split={x:t,y:l,scrollX:0,scrollY:0,topLeft:e.topLeftCell??null,firstTopLeft:o.viewRaw?.topLeftCell??null})}function R(e,o){o.viewRaw=e,(e.showRowColHeaders==="0"||e.showRowColHeaders==="false")&&(o.hideHeadings=!0),(e.showOutlineSymbols==="0"||e.showOutlineSymbols==="false")&&(o.hideOutline=!0),(e.showZeros==="0"||e.showZeros==="false")&&(o.hideZeros=!0),(e.defaultGridColor==="0"||e.defaultGridColor==="false")&&e.colorId!==void 0&&(o.gridColorId=Number(e.colorId)),e.zoomScaleNormal&&(o.zoomNormal=Number(e.zoomScaleNormal)/100),e.zoomScalePageLayoutView&&(o.zoomPageLayout=Number(e.zoomScalePageLayoutView)/100),c.has(e.view)&&(o.viewMode=e.view),(e.showRuler==="0"||e.showRuler==="false")&&(o.hideRuler=!0)}function V(e,o){e.hideHeadings=o.hideHeadings===!0,e.hideOutline=o.hideOutline===!0,e.hideZeros=o.hideZeros===!0,o.split&&(e.split=o.split),e.gridColorId=o.gridColorId??null,e.zoomNormal=o.zoomNormal??null,e.zoomPageLayout=o.zoomPageLayout??null,e.viewMode=o.viewMode==="pageLayout"&&(o.frozenRows>0||o.frozenCols>0)?null:o.viewMode??null,e.hideRuler=o.hideRuler===!0,e.viewRaw=o.viewRaw??null,e.tabSelected=o.tabSelected===!0}function L(e,o){const t=o.selectedSheets?.has(e)===!0;return{hideHeadings:e.hideHeadings===!0,hideOutline:e.hideOutline===!0,hideZeros:e.hideZeros===!0,split:S(e),gridColorId:e.gridColorId??null,zoomNormal:e.viewMode||e.zoomNormal===null||e.zoomNormal===void 0?e.zoomNormal??null:e.zoom||1,zoomPageLayout:e.viewMode==="pageLayout"?e.zoom||1:e.zoomPageLayout??null,viewMode:e.viewMode??null,hideRuler:e.hideRuler===!0,viewRaw:e.viewRaw??null,tabSelected:t||o.sheet===e}}function x(e,o){return e.replace(/<sheetView\b[^>]*>/,t=>{const l=t.replace(/\s+tabSelected="[^"]*"/,"");return o.tabSelected?l.replace(/^<sheetView\b/,'<sheetView tabSelected="1"'):l})}const a=600;function y(e){const o=e.view??{};return{activeTab:e.activeSheet,firstSheet:o.firstSheet??0,showHorizontalScroll:o.showHScroll!==!1,showVerticalScroll:o.showVScroll!==!1,showSheetTabs:o.showTabs!==!1,tabRatio:o.tabRatio===void 0?a:Math.round(o.tabRatio*1e3)}}function s(e,o={}){const t={...o},l=(r,i,w)=>{i===w?delete t[r]:t[r]=typeof i=="boolean"?i?"1":"0":String(i)};return l("showHorizontalScroll",e.showHorizontalScroll,!0),l("showVerticalScroll",e.showVerticalScroll,!0),l("showSheetTabs",e.showSheetTabs,!0),l("tabRatio",e.tabRatio,a),l("firstSheet",e.firstSheet,0),l("activeTab",e.activeTab,0),Object.entries(t).map(([r,i])=>` ${r}="${u(i)}"`).join("")}function T(e){const o=e.bookView??{activeTab:e.activeSheet,firstSheet:0,showHorizontalScroll:!0,showVerticalScroll:!0,showSheetTabs:!0,tabRatio:a};return`<bookViews><workbookView${s(o)}/></bookViews>`}function v(e,o){if(!o)return e;const t=/<workbookView\b([^>]*?)\/?>/.exec(e);if(!t){if(/<bookViews\b/.test(e))return e;const r=/<sheets\b/.exec(e);return r?e.slice(0,r.index)+`<bookViews><workbookView${s(o)}/></bookViews>`+e.slice(r.index):e}const l={};for(const r of t[1].matchAll(/([\w:.-]+)="([^"]*)"/g))l[r[1]]=r[2].replace(/&quot;/g,'"').replace(/&lt;/g,"<").replace(/&amp;/g,"&");return`${e.slice(0,t.index)}<workbookView${s(o,l)}/>${e.slice(t.index+t[0].length).replace(/^<\/workbookView>/,"")}`}function k(e,o){if(!e)return;const t=l=>l==="0"||l==="false";t(e.showHorizontalScroll)&&(o.showHScroll=!1),t(e.showVerticalScroll)&&(o.showVScroll=!1),t(e.showSheetTabs)&&(o.showTabs=!1),e.tabRatio!==void 0&&(o.tabRatio=Math.max(0,Math.min(1,Number(e.tabRatio)/1e3))),e.firstSheet!==void 0&&(o.firstSheet=Number(e.firstSheet)||0)}export{V as applySheetViewInfo,y as bookViewPlan,T as bookViewsXml,v as patchBookViews,x as patchTabSelected,k as readBookView,R as readSheetViewAttrs,z as readSplitPane,b as sheetViewAttrs,L as sheetViewPlan,g as splitPaneXml};
@@ -0,0 +1,31 @@
1
+ // Symbol tables fixed by the barcode standards: USS Code 49 words (ANSI/AIM BC6) and
2
+ // PDF417 codewords (ISO/IEC 15438). Any conforming encoder needs these same values. They were
3
+ // extracted by script from bwip-js 4.8.0 (barcode.ps) and packed; no bwip-js code is used here.
4
+ // Each value is three characters of a 64-symbol alphabet, 18 bits, big-endian.
5
+ //
6
+ // bwip-js : Barcode Writer in Pure JavaScript
7
+ //
8
+ // Copyright (c) 2011-2025 Mark Warren
9
+ //
10
+ // The MIT License
11
+ //
12
+ // Permission is hereby granted, free of charge, to any person obtaining a copy
13
+ // of this software and associated documentation files (the "Software"), to deal
14
+ // in the Software without restriction, including without limitation the rights
15
+ // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
16
+ // copies of the Software, and to permit persons to whom the Software is
17
+ // furnished to do so, subject to the following conditions:
18
+ //
19
+ // The above copyright notice and this permission notice shall be included in
20
+ // all copies or substantial portions of the Software.
21
+ //
22
+ // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
23
+ // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
24
+ // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
25
+ // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
26
+ // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
27
+ // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
28
+ // THE SOFTWARE.
29
+
30
+ // Word bits, first module in the top bit: 16 modules for each Code 49 pair value 0..2400.
31
+ const I="L5cMFuIbcMEmIZMJ7cMcmJ5MN8mILMIJEI7MMMiI5EL7MM8iL5EMFiIbEMdiJ7EN9iIEuIcuJ8uINuIMmI9uI8mL9uIFmIEiIdmIciJ9mJ8iINiI9iL9iKLgOi4PouNNwPTcNEwPRMK7gOu4PruKZgOmYPpmKIgOiIPoiNcwPXMNMQPTEK4gOuIPriJFwORcNi4PYuMm4PJuLNwMiYPImLEwOxMJdwOXcJMwOTMJEQORENiIPYiMuYPLmLcwMmIPJiLMQOzEJcQOXENuIPbiIi4OIuMxcLi4O4uMTcJm4MRMJiYOYmNxMIu4OLuImYOJmLu4IiIOIiLmYMxELiIO4iMXMJuYMTEJmIOZiNzEIuIOLiM3ELuIO7iIRcMYuJxcN4uMJuIzcMImIxMLzcM4mLxMIXcITMJ3cIREJzMMYiJxEN4iMLmI3MMJiIzEL3MM5iLzEIXEMbiJ3EN7iIIuI4uIZuIYmJ5uJ4mILuIJmI7uIIiI5mL7uI4iL5mIbmIZiJ7mJ5iILiI7iL7iKFwOhcNG4PRuNCYPQmKdwOncKMwOjMKEQOhENe4PXuNOYPTmNGIPRiK8wOvMKcQOnENeIPXiJC4OQuNhcMjcLG4MhMLCYOwmJO4OTuJGYORmJCIOQiNhEMvcLe4MnMLOYMjELGIOxiJeYOXmJOIOTiNnEMvELeIO3iIhcMwuLhcMRuJjcMQmJhMNwmIncIjMLncI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E_aEfJE_ZAeKA-aAeJB-6A-ZB-5GflEfFE_NAeFA-NB-dAHWAHTAPUEHrAPSAPRAHLAPbEPqEPpAPKAfaAPJAfZGP1"];export{I as CODE49_EVEN,M as CODE49_ODD,O as PDF417_CLUSTERS};
@@ -0,0 +1,2 @@
1
+ import{FUNCS as Y1,lift as q,setCategory as Z1}from"../calc/functions/registry.js";import{ERR as Z,num as K1,opt as Q,str as K,bool as s1,isOmitted as J1}from"../calc/values.js";import{CODE49_EVEN as z1,CODE49_ODD as t0,PDF417_CLUSTERS as o0}from"./barcode-tables.js";import{safeJson as e0}from"../io/xml-escape.js";class c1 extends Error{}const _=t=>{throw new c1(t)},M1=new TextEncoder;function $(t,o,{quiet:e=0,rowScale:n=1,text:r=null}={}){const s=typeof e=="number"?{l:e,r:e,t:e,b:e}:e;return{width:t,height:o,bits:new Uint8Array(t*o),quiet:s,rowScale:n,text:r}}function i1(t,o){let e=0;for(const s of t)e+=s;const n=$(e,1,o);let r=0;for(let s=0;s<t.length;s++)s%2===0&&n.bits.fill(1,r,r+t[s]),r+=t[s];return n}const _1=t=>[...t].map(Number);function w1(t){const o=new Uint8Array(t.length);for(let e=0;e<t.length;e++){const n=t.charCodeAt(e);if(n>255)return{bytes:M1.encode(t),eci:!0};o[e]=n}return{bytes:o,eci:!1}}function n0(t,o){for(let e=0;e<t.length;e++)t.charCodeAt(e)>127&&_(`${o} only encodes ASCII`)}function S1(t){const o=new Uint8Array(512),e=new Uint8Array(256);let n=1;for(let r=0;r<255;r++)o[r]=n,e[n]=r,n<<=1,n&256&&(n^=t);for(let r=255;r<512;r++)o[r]=o[r-255];return{exp:o,log:e}}const J=S1(285),z=S1(301);function t1(t,o,e){let n=[1];for(let r=0;r<o;r++){const s=new Array(n.length+1).fill(0),i=t.exp[(r+e)%255];for(let c=0;c<n.length;c++)s[c]^=n[c],n[c]!==0&&(s[c+1]^=t.exp[t.log[n[c]]+t.log[i]]);n=s}return n.slice(1)}function o1(t,o,e){const n=e.length,r=new Uint8Array(n);for(const s of o){const i=s^r[0];if(r.copyWithin(0,1),r[n-1]=0,i!==0){const c=t.log[i];for(let l=0;l<n;l++)e[l]!==0&&(r[l]^=t.exp[c+t.log[e[l]]])}}return r}function mt(t,o){return[...o1(J,t,t1(J,o,0))]}function Lt(t,o){return[...o1(z,t,t1(z,o,1))]}const r0={L:0,M:1,Q:2,H:3},s0=[1,0,3,2],c0=[[7,10,15,20,26,18,20,24,30,18,20,24,26,30,22,24,28,30,28,28,28,28,30,30,26,28,30,30,30,30,30,30,30,30,30,30,30,30,30,30],[10,16,26,18,24,16,18,22,22,26,30,22,22,24,24,28,28,26,26,26,26,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28],[13,22,18,26,18,24,18,22,20,24,28,26,24,20,30,24,28,28,26,30,28,30,30,30,30,28,30,30,30,30,30,30,30,30,30,30,30,30,30,30],[17,28,22,16,22,28,26,26,24,28,24,28,22,24,24,30,28,28,26,28,30,24,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30]],i0=[[1,1,1,1,1,2,2,2,2,4,4,4,4,4,6,6,6,6,7,8,8,9,9,10,12,12,12,13,14,15,16,17,18,19,19,20,21,22,24,25],[1,1,1,2,2,4,4,4,5,5,5,8,9,9,10,10,11,13,14,16,17,17,18,20,21,23,25,26,28,29,31,33,35,37,38,40,43,45,47,49],[1,1,2,2,4,4,6,6,8,8,8,10,12,16,12,17,16,18,21,20,23,23,25,27,29,34,34,35,38,40,43,45,48,51,53,56,59,62,65,68],[1,1,2,4,4,4,5,6,8,8,11,11,16,16,18,16,19,21,25,25,25,34,30,32,35,37,40,42,45,48,51,54,57,60,63,66,70,74,77,81]];function l0(t){if(t===1)return[];const o=Math.floor(t/7)+2,e=t*4+17,n=t===32?26:Math.ceil((e-13)/(o*2-2))*2,r=[6];for(let s=e-7;r.length<o;s-=n)r.splice(1,0,s);return r}function E1(t){let o=(16*t+128)*t+64;if(t>=2){const e=Math.floor(t/7)+2;o-=(25*e-10)*e-55,t>=7&&(o-=36)}return o>>3}function D1(t,o){const e=c0[o][t-1],n=i0[o][t-1];return{dataCodewords:E1(t)-e*n,ecPerBlock:e,blocks:n}}function R1(t,o){const e=4+(t<10?8:16);return Math.floor((D1(t,o).dataCodewords*8-e)/8)}function T1(t,o){const e=s0[t]<<3|o;let n=e;for(let r=0;r<10;r++)n=n<<1^(n>>9)*1335;return(e<<10|n)^21522}function k1(t){let o=t;for(let e=0;e<12;e++)o=o<<1^(o>>11)*7973;return t<<12|o}const Mt=T1,_t=k1;function f0(t,o,e){switch(t){case 0:return(o+e)%2===0;case 1:return e%2===0;case 2:return o%3===0;case 3:return(o+e)%3===0;case 4:return(Math.floor(o/3)+Math.floor(e/2))%2===0;case 5:return o*e%2+o*e%3===0;case 6:return(o*e%2+o*e%3)%2===0;default:return((o+e)%2+o*e%3)%2===0}}function a0(t,o){let e=0;const n=(i,c)=>{let l=0;for(let u=0;u+11<=c;u++){const f=w=>i(u+w),C=f(0)&&!f(1)&&f(2)&&f(3)&&f(4)&&!f(5)&&f(6),b=f(4)&&!f(5)&&f(6)&&f(7)&&f(8)&&!f(9)&&f(10);C&&!f(7)&&!f(8)&&!f(9)&&!f(10)&&l++,b&&!f(0)&&!f(1)&&!f(2)&&!f(3)&&l++}return l};for(let i=0;i<o;i++){let c=1;for(let l=1;l<o;l++)t[i*o+l]===t[i*o+l-1]?(c++,c===5?e+=3:c>5&&(e+=1)):c=1;e+=40*n(l=>t[i*o+l],o)}for(let i=0;i<o;i++){let c=1;for(let l=1;l<o;l++)t[l*o+i]===t[(l-1)*o+i]?(c++,c===5?e+=3:c>5&&(e+=1)):c=1;e+=40*n(l=>t[l*o+i],o)}let r=0;for(let i=0;i<o;i++)for(let c=0;c<o;c++)if(r+=t[i*o+c],c+1<o&&i+1<o){const l=t[i*o+c];l===t[i*o+c+1]&&l===t[(i+1)*o+c]&&l===t[(i+1)*o+c+1]&&(e+=3)}const s=o*o;return e+=(Math.ceil(Math.abs(r*20-s*10)/s)-1)*10,e}function u0(t,o={}){const e=String(o.ec??"M").toUpperCase(),n=r0[e];n===void 0&&_("QR error correction must be L, M, Q or H");const r=M1.encode(t);r.length===0&&_("QR needs data");let s=Number(o.version??0);if((!Number.isInteger(s)||s<0||s>40)&&_("QR version must be 1 to 40"),s===0){for(s=1;s<=40&&!(R1(s,n)>=r.length);s++);s>40&&_("Too much data for a QR code")}else R1(s,n)<r.length&&_("Too much data for this QR version");const{dataCodewords:i,ecPerBlock:c,blocks:l}=D1(s,n),u=new Uint8Array(i);let f=0;const C=(p,g)=>{for(let A=g-1;A>=0;A--)p>>>A&1&&(u[f>>3]|=128>>(f&7)),f++};C(4,4),C(r.length,s<10?8:16);for(const p of r)C(p,8);f=Math.min(f+4,i*8);let b=f+7>>3;for(let p=236;b<i;b++,p^=253)u[b]=p;const w=t1(J,c,0),L=E1(s),S=Math.floor(i/l),E=i%l,T=[],y=[];let x=0;for(let p=0;p<l;p++){const g=S+(p>=l-E?1:0),A=u.subarray(x,x+g);x+=g,T.push(A),y.push(o1(J,A,w))}const d=new Uint8Array(L);let h=0;for(let p=0;p<=S;p++)for(const g of T)p<g.length&&(d[h++]=g[p]);for(let p=0;p<c;p++)for(const g of y)d[h++]=g[p];const a=s*4+17,R=new Uint8Array(a*a),D=new Uint8Array(a*a),M=(p,g,A)=>{R[g*a+p]=A?1:0,D[g*a+p]=1};for(let p=0;p<a;p++)M(6,p,p%2===0),M(p,6,p%2===0);const k=(p,g)=>{for(let A=-4;A<=4;A++)for(let m=-4;m<=4;m++){const Y=p+m,H=g+A;if(Y<0||H<0||Y>=a||H>=a)continue;const L1=Math.max(Math.abs(m),Math.abs(A));M(Y,H,L1!==2&&L1!==4)}};k(3,3),k(a-4,3),k(3,a-4);const W=l0(s);for(const p of W)for(const g of W)if(!(g===6&&p===6||g===6&&p===a-7||g===a-7&&p===6))for(let A=-2;A<=2;A++)for(let m=-2;m<=2;m++)M(g+m,p+A,Math.max(Math.abs(m),Math.abs(A))!==1);const v=p=>{const g=T1(n,p),A=m=>g>>m&1;for(let m=0;m<=5;m++)M(8,m,A(m));M(8,7,A(6)),M(8,8,A(7)),M(7,8,A(8));for(let m=9;m<15;m++)M(14-m,8,A(m));for(let m=0;m<8;m++)M(a-1-m,8,A(m));for(let m=8;m<15;m++)M(8,a-15+m,A(m));M(8,a-8,1)};if(v(0),s>=7){const p=k1(s);for(let g=0;g<18;g++){const A=a-11+g%3,m=Math.floor(g/3);M(A,m,p>>g&1),M(m,A,p>>g&1)}}let N=0;const I=L*8;for(let p=a-1;p>=1;p-=2){p===6&&(p=5);for(let g=0;g<a;g++)for(let A=0;A<2;A++){const m=p-A,H=(p+1&2)===0?a-1-g:g;D[H*a+m]===0&&N<I&&(R[H*a+m]=d[N>>3]>>7-(N&7)&1,N++)}}const G=p=>{for(let g=0;g<a;g++)for(let A=0;A<a;A++)D[g*a+A]===0&&f0(p,A,g)&&(R[g*a+A]^=1)};let B=Number(o.mask??-1);if((!Number.isInteger(B)||B<-1||B>7)&&_("QR mask must be 0 to 7"),B<0){let p=1/0;for(let g=0;g<8;g++){G(g),v(g);const A=a0(R,a);A<p&&(p=A,B=g),G(g)}}G(B),v(B);const O=$(a,a,{quiet:4});return O.bits.set(R),O.version=s,O.mask=B,O.level=e,O}const d0=[[10,10,1,1,3,5,1],[12,12,1,1,5,7,1],[14,14,1,1,8,10,1],[16,16,1,1,12,12,1],[18,18,1,1,18,14,1],[20,20,1,1,22,18,1],[22,22,1,1,30,20,1],[24,24,1,1,36,24,1],[26,26,1,1,44,28,1],[32,32,2,2,62,36,1],[36,36,2,2,86,42,1],[40,40,2,2,114,48,1],[44,44,2,2,144,56,1],[48,48,2,2,174,68,1],[52,52,2,2,204,42,2],[64,64,4,4,280,56,2],[72,72,4,4,368,36,4],[80,80,4,4,456,48,4],[88,88,4,4,576,56,4],[96,96,4,4,696,68,4],[104,104,4,4,816,56,6],[120,120,6,6,1050,68,6],[132,132,6,6,1304,62,8],[144,144,6,6,1558,62,10],[8,18,1,1,5,7,1],[8,32,2,1,10,11,1],[12,26,1,1,16,14,1],[12,36,2,1,22,18,1],[16,36,2,1,32,24,1],[16,48,2,1,49,28,1]],h0=d0.map(([t,o,e,n,r,s,i])=>({rows:t,cols:o,hRegions:e,vRegions:n,dataWords:r,eccPerBlock:s,blocks:i}));function p0(t){const o=[];for(let e=0;e<t.length;e++){const n=t[e];n>=48&&n<=57&&e+1<t.length&&t[e+1]>=48&&t[e+1]<=57?(o.push((n-48)*10+(t[e+1]-48)+130),e++):n<128?o.push(n+1):o.push(235,n-127)}return o}function x1(t,o){const e=new Int32Array(t*o).fill(-1),n=(u,f,C,b)=>{let w=u,L=f;w<0&&(w+=t,L+=4-(t+4)%8),L<0&&(L+=o,w+=4-(o+4)%8),e[w*o+L]=C*8+b},r=(u,f,C)=>{n(u-2,f-2,C,7),n(u-2,f-1,C,6),n(u-1,f-2,C,5),n(u-1,f-1,C,4),n(u-1,f,C,3),n(u,f-2,C,2),n(u,f-1,C,1),n(u,f,C,0)},s=(u,f)=>f.forEach(([C,b],w)=>n(C,b,u,7-w));let i=0,c=4,l=0;do{c===t&&l===0&&s(i++,[[t-1,0],[t-1,1],[t-1,2],[0,o-2],[0,o-1],[1,o-1],[2,o-1],[3,o-1]]),c===t-2&&l===0&&o%4!==0&&s(i++,[[t-3,0],[t-2,0],[t-1,0],[0,o-4],[0,o-3],[0,o-2],[0,o-1],[1,o-1]]),c===t-2&&l===0&&o%8===4&&s(i++,[[t-3,0],[t-2,0],[t-1,0],[0,o-2],[0,o-1],[1,o-1],[2,o-1],[3,o-1]]),c===t+4&&l===2&&o%8===0&&s(i++,[[t-1,0],[t-1,o-1],[0,o-3],[0,o-2],[0,o-1],[1,o-3],[1,o-2],[1,o-1]]);do c<t&&l>=0&&e[c*o+l]<0&&r(c,l,i++),c-=2,l+=2;while(c>=0&&l<o);c+=1,l+=3;do c>=0&&l<o&&e[c*o+l]<0&&r(c,l,i++),c+=2,l-=2;while(c<t&&l>=0);c+=3,l+=1}while(c<t||l<o);return e}const wt=x1;function C0(t,o={}){const{bytes:e,eci:n}=w1(t);e.length===0&&_("Data Matrix needs data");const r=p0(e);n&&r.unshift(241,27);const s=o.shape??"square",i=h=>h.dataWords>=r.length&&(s==="auto"||(s==="rect"?h.rows!==h.cols:h.rows===h.cols)),c=h0.filter(i).sort((h,a)=>h.dataWords-a.dataWords)[0];c||_("Too much data for a Data Matrix");const l=r.slice();for(let h=l.length;h<c.dataWords;h++)if(h===r.length)l.push(129);else{const a=129+149*(h+1)%253+1;l.push(a>254?a-254:a)}const{blocks:u,eccPerBlock:f}=c,C=t1(z,f,1),b=new Uint8Array(c.dataWords+u*f);b.set(l);for(let h=0;h<u;h++){const a=[];for(let D=h;D<c.dataWords;D+=u)a.push(l[D]);const R=o1(z,a,C);for(let D=0;D<f;D++)b[c.dataWords+h+D*u]=R[D]}const w=(c.rows-2*c.vRegions)/c.vRegions,L=(c.cols-2*c.hRegions)/c.hRegions,S=w*c.vRegions,E=L*c.hRegions,T=x1(S,E),y=$(c.cols,c.rows,{quiet:1}),{bits:x}=y,d=(h,a)=>{const R=T[h*E+a];return R<0?h===S-1&&a===E-1||h===S-2&&a===E-2?1:0:b[R>>3]>>(R&7)&1};for(let h=0;h<c.vRegions;h++)for(let a=0;a<c.hRegions;a++){const R=h*(w+2),D=a*(L+2);for(let M=0;M<L+2;M++)x[(R+w+1)*c.cols+D+M]=1,x[R*c.cols+D+M]=M%2===0?1:0;for(let M=0;M<w+2;M++)x[(R+M)*c.cols+D]=1,x[(R+M)*c.cols+D+L+1]=M%2===1?1:0;for(let M=0;M<w;M++)for(let k=0;k<L;k++)x[(R+1+M)*c.cols+D+1+k]=d(h*w+M,a*L+k)}return y.dataMatrix=c,y}let l1=null;const g0="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_";function y1(t,o,e){const n=new Int8Array(128);for(let s=0;s<64;s++)n[g0.charCodeAt(s)]=s;const r=new Int32Array(o);for(let s=0;s<o;s++){const i=n[t.charCodeAt(s*3)]<<12|n[t.charCodeAt(s*3+1)]<<6|n[t.charCodeAt(s*3+2)];r[s]=e(i)}return r}function A0(){return l1===null&&(l1=o0.map(t=>y1(t,929,o=>65536+(o<<1)))),l1}const b0=[1,1,1,1,1,1,1,1,0,1,0,1,0,1,0,0,0],m0=[1,1,1,1,1,1,1,0,1,0,0,0,1,0,1,0,0,1],L0="ABCDEFGHIJKLMNOPQRSTUVWXYZ ",M0="abcdefghijklmnopqrstuvwxyz ",_0="0123456789&\r ,:#-.$/+%*=^\0 ",w0=`;<>@[\\]_\`~!\r ,:
2
+ -.$/"|*()?{}'`,B1=t=>t===9||t===10||t===13||t>=32&&t<=126;function S0(t,o){const e=[];let n="A";const r=(i,c)=>(i==="A"?L0:i==="L"?M0:i==="M"?_0:w0).indexOf(c),s={AL:[27],AM:[28],AP:[28,25],LA:[28,28],LM:[28],LP:[28,25],MA:[28],ML:[27],MP:[25],PA:[29],PL:[29,27],PM:[29,28]};for(let i=0;i<t.length;i++){const c=String.fromCharCode(t[i]),l=r(n,c);if(l>=0){e.push(l);continue}const u=i+1<t.length&&r(n,String.fromCharCode(t[i+1]))>=0;if(n!=="P"&&u&&r("P",c)>=0&&r("M",c)<0){e.push(29,r("P",c));continue}if(n==="L"&&u&&r("A",c)>=0){e.push(27,r("A",c));continue}const f=["A","L","M","P"].find(C=>C!==n&&r(C,c)>=0);e.push(...s[n+f],r(f,c)),n=f}e.length%2===1&&e.push(29);for(let i=0;i<e.length;i+=2)o.push(e[i]*30+e[i+1])}function E0(t,o){for(let e=0;e<t.length;e+=44){const n=String.fromCharCode(...t.subarray(e,e+44));let r=BigInt(`1${n}`);const s=[];for(;r>0n;)s.unshift(Number(r%900n)),r/=900n;o.push(...s)}}function D0(t,o){let e=0;for(;e+6<=t.length;e+=6){let n=0n;for(let s=0;s<6;s++)n=n*256n+BigInt(t[e+s]);const r=new Array(5);for(let s=4;s>=0;s--)r[s]=Number(n%900n),n/=900n;o.push(...r)}for(;e<t.length;e++)o.push(t[e])}function R0(t){const o=[];let e="T",n=0;for(;n<t.length;){let r=0;for(;n+r<t.length&&t[n+r]>=48&&t[n+r]<=57;)r++;if(r>=13||r>=8&&r===t.length){o.push(902),E0(t.subarray(n,n+r),o),e="N",n+=r;continue}let s=0;for(let c=0;n+s<t.length&&B1(t[n+s])&&c<13;s++)if(c=t[n+s]>=48&&t[n+s]<=57?c+1:0,c===13){s-=12;break}if(s>=5||s>0&&s===t.length-n&&e==="T"){e!=="T"&&o.push(900),S0(t.subarray(n,n+s),o),e="T",n+=s;continue}let i=0;for(;n+i<t.length;i++){let c=0;for(;n+i+c<t.length&&B1(t[n+i+c])&&c<5;)c++;if(c>=5&&i>0)break}i===0&&(i=1),o.push(i%6===0?924:901),D0(t.subarray(n,n+i),o),e="B",n+=i}return o}function T0(t,o){const e=2**(o+1),n=[1];let r=1;for(let c=1;c<=e;c++){r=r*3%929,n.push(0);for(let l=n.length-1;l>=0;l--)n[l]=((l>0?n[l-1]:0)+929-n[l]*r%929)%929}const s=new Array(e).fill(0);for(const c of t){const l=(c+s[e-1])%929;for(let u=e-1;u>=1;u--)s[u]=(s[u-1]+929-l*n[u]%929)%929;s[0]=(929-l*n[0]%929)%929}const i=[];for(let c=e-1;c>=0;c--)i.push(s[c]===0?0:929-s[c]);return i}function k0(t,o={}){let e=o.level;if(e==null||e<0){const S=t.length+1;e=S<=40?2:S<=160?3:S<=320?4:S<=863?5:6}(!Number.isInteger(e)||e>8)&&_("PDF417 level must be 0 to 8");const n=2**(e+1),r=t.length+1+n;r>928&&_("Too much data for a PDF417 symbol");let s=o.columns??0;if(s!==0&&(!Number.isInteger(s)||s<1||s>30)&&_("PDF417 columns must be 1 to 30"),s===0){let S=1/0;for(let E=1;E<=30;E++){const T=Math.max(3,Math.ceil(r/E));if(T>90)continue;const y=Math.abs(Math.log((17*E+69)/(T*3)/2));y<S&&(S=y,s=E)}}const i=Math.max(3,Math.ceil(r/s));(i>90||i*s>928)&&_("Too much data for this PDF417 size");const c=[i*s-n,...t];for(;c.length<i*s-n;)c.push(900);const l=[...c,...T0(c,e)],u=A0(),f=17*(s+3)+18,C=$(f,i,{quiet:2,rowScale:3});C.codewords=l,C.columns=s,C.level=e;const b=Math.floor((i-1)/3),w=e*3+(i-1)%3,L=s-1;for(let S=0;S<i;S++){const E=S%3,T=30*Math.floor(S/3),y=T+(E===0?b:E===1?w:L),x=T+(E===0?L:E===1?b:w);let d=S*f;for(const a of b0)C.bits[d++]=a;const h=a=>{const R=u[E][a];for(let D=16;D>=0;D--)C.bits[d++]=R>>D&1};h(y);for(let a=0;a<s;a++)h(l[S*s+a]);h(x);for(const a of m0)C.bits[d++]=a}return C}function x0(t,o={}){const{bytes:e,eci:n}=w1(t);e.length===0&&_("PDF417 needs data");const r=R0(e);return n&&r.unshift(927,26),k0(r,o)}const P1=["212222","222122","222221","121223","121322","131222","122213","122312","132212","221213","221312","231212","112232","122132","122231","113222","123122","123221","223211","221132","221231","213212","223112","312131","311222","321122","321221","312212","322112","322211","212123","212321","232121","111323","131123","131321","112313","132113","132311","211313","231113","231311","112133","112331","132131","113123","113321","133121","313121","211331","231131","213113","213311","213131","311123","311321","331121","312113","312311","332111","314111","221411","431111","111224","111422","121124","121421","141122","141221","112214","112412","122114","122411","142112","142211","241211","221114","413111","241112","134111","111242","121142","121241","114212","124112","124211","411212","421112","421211","212141","214121","412121","111143","111341","131141","114113","114311","411113","411311","113141","114131","311141","411131","211412","211214","211232","2331112"],e1=-1,y0=[103,104,105],B0=[[-1,100,99],[101,-1,99],[101,100,-1]],P0=[101,100,-1],G1=t=>t>=48&&t<=57;function I1(t,o,e){const n=t[o];if(n===e1)return{cost:1,used:1};if(e===2)return G1(n)&&o+1<t.length&&G1(t[o+1])?{cost:1,used:2}:null;const r=n&127;return(e===0?r<96:r>=32)?{cost:n>127?2:1,used:1}:null}function G0(t,o,e,n){const r=t[o];if(r===e1)return n.push(102),1;if(e===2)return n.push((r-48)*10+(t[o+1]-48)),2;r>127&&n.push(P0[e]);const s=r&127;return n.push(e===0&&s<32?s+64:s-32),1}function I0(t){const o=t.length,e=Array.from({length:o+1},()=>[1/0,1/0,1/0]),n=Array.from({length:o+1},()=>[null,null,null]);e[o]=[0,0,0];for(let l=o-1;l>=0;l--)for(let u=0;u<3;u++)for(let f=0;f<3;f++){const C=I1(t,l,f);if(C===null)continue;const b=(f===u?0:1)+C.cost+e[l+C.used][f];b<e[l][u]&&(e[l][u]=b,n[l][u]={to:f,used:C.used})}let r=0,s=1/0;for(let l=0;l<3;l++){const u=o>0?I1(t,0,l):null,f=u===null?1/0:u.cost+e[u.used][l];f<s&&(s=f,r=l)}s===1/0&&_("Code 128 cannot encode this text");const i=[y0[r]];let c=0;for(;c<o;){const l=n[c][r];l.to!==r&&(i.push(B0[r][l.to]),r=l.to),c+=G0(t,c,r,i)}return i}function O0(t){let o=t[0];for(let e=1;e<t.length;e++)o+=t[e]*e;return o%103}function O1(t,o){const e=I0(t);e.push(O0(e));const n=e.map(r=>P1[r]).join("")+P1[106];return i1([...n].map(Number),{quiet:{l:10,r:10,t:0,b:0},text:o})}function N0(t){t===""&&_("Code 128 needs data");const o=[];for(let e=0;e<t.length;e++){const n=t.charCodeAt(e);n>255&&_("Code 128 only encodes Latin-1 text"),o.push(n)}return O1(o,t.replace(/[\u0000-\u001f\u007f]/g," "))}const $0={"00":20,"01":16,"02":16,"03":16,"04":18,11:8,12:8,13:8,14:8,15:8,16:8,17:8,18:8,19:8,20:4,31:10,32:10,33:10,34:10,35:10,36:10,41:16};function f1(t){let o=0,e=3;for(let n=t.length-1;n>=0;n--)o+=(t.charCodeAt(n)-48)*e,e=4-e;return(10-o%10)%10}function F0(t){const o=[...t.matchAll(/\((\d{2,4})\)([^(]*)/g)];(o.length===0||o.map(n=>n[0]).join("")!==t)&&_("GS1-128 data must look like (01)09501101530003(10)ABC");const e=[e1];return o.forEach((n,r)=>{const[,s,i]=n;i===""&&_(`GS1-128 AI ${s} has no value`),n0(i,"GS1-128");const c=$0[s.slice(0,2)];c!==void 0&&s.length+i.length!==c&&_(`GS1-128 AI ${s} has the wrong length`),["00","01","02"].includes(s)&&(!/^\d+$/.test(i)||f1(i.slice(0,-1))!==Number(i[i.length-1]))&&_(`GS1-128 AI ${s} has a bad check digit`);for(const l of s+i)e.push(l.charCodeAt(0));c===void 0&&r<o.length-1&&e.push(e1)}),O1(e,t)}const n1="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ-. $/+%",U0=["000110100","100100001","001100001","101100000","000110001","100110000","001110000","000100101","100100100","001100100","100001001","001001001","101001000","000011001","100011000","001011000","000001101","100001100","001001100","000011100","100000011","001000011","101000010","000010011","100010010","001010010","000000111","100000110","001000110","000010110","110000001","011000001","111000000","010010001","110010000","011010000","010000101","110000100","011000100","010101000","010100010","010001010","000101010"],N1="010010100";function W0(t){let o=0;for(const e of t)o+=n1.indexOf(e);return n1[o%43]}function v0(t,o={}){t===""&&_("Code 39 needs data");for(const s of t)n1.indexOf(s)<0&&_(`Code 39 cannot encode "${s}"`);const e=o.check?t+W0(t):t,n=[],r=s=>{for(const i of s)n.push(i==="1"?3:1)};r(N1);for(const s of e)n.push(1),r(U0[n1.indexOf(s)]);return n.push(1),r(N1),i1(n,{quiet:{l:10,r:10,t:0,b:0},text:e})}const H0=["100010100","101001000","101000100","101000010","100101000","100100100","100100010","101010000","100010010","100001010","110101000","110100100","110100010","110010100","110010010","110001010","101101000","101100100","101100010","100110100","100011010","101011000","101001100","101000110","100101100","100010110","110110100","110110010","110101100","110100110","110010110","110011010","101101100","101100110","100110110","100111010","100101110","111010100","111010010","111001010","101101110","101110110","110101110","100100110","111011010","111010110","100110010"],$1="101011110",F1="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ-. $/+%",[q0,F,U1,Q0]=[43,44,45,46];function V0(t){const o=[],e=(n,r)=>o.push(n,F1.indexOf(r));for(let n=0;n<t.length;n++){const r=t.charCodeAt(n),s=t[n],i=F1.indexOf(s);i>=0?o.push(i):r===0?e(F,"U"):r<=26?e(q0,String.fromCharCode(64+r)):r<=31?e(F,String.fromCharCode(65+r-27)):r<=47?e(U1,String.fromCharCode(65+r-33)):r===58?e(U1,"Z"):r<=63?e(F,String.fromCharCode(70+r-59)):r===64?e(F,"V"):r<=95?e(F,String.fromCharCode(75+r-91)):r===96?e(F,"W"):r<=122?e(Q0,String.fromCharCode(65+r-97)):r<=127?e(F,String.fromCharCode(80+r-123)):_("Code 93 only encodes ASCII")}return o}function X0(t){const o=(n,r)=>{let s=0;for(let i=n.length-1,c=1;i>=0;i--)s+=n[i]*c,c=c===r?1:c+1;return s%47},e=o(t,20);return[e,o([...t,e],15)]}function j0(t){t===""&&_("Code 93 needs data");const o=V0(t),[e,n]=X0(o),r=$1+[...o,e,n].map(i=>H0[i]).join("")+$1+"1",s=$(r.length,1,{quiet:{l:10,r:10,t:0,b:0},text:t.replace(/[\u0000-\u001f\u007f]/g," ")});for(let i=0;i<r.length;i++)s.bits[i]=r[i]==="1"?1:0;return s}const Y0="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ-. $/+%",W1=43,Z0=44,a1=48,K0=["1 ","1A","1B","1C","1D","1E","1F","1G","1H","1I","1J","1K","1L","1M","1N","1O","1P","1Q","1R","1S","1T","1U","1V","1W","1X","1Y","1Z","11","12","13","14","15"," ","16","17","18"," $"," %","19","10","1-","1.","1$"," +","1/"," -"," ."," /"," 0"," 1"," 2"," 3"," 4"," 5"," 6"," 7"," 8"," 9","1+","21","22","23","24","25","26"," A"," B"," C"," D"," E"," F"," G"," H"," I"," J"," K"," L"," M"," N"," O"," P"," Q"," R"," S"," T"," U"," V"," W"," X"," Y"," Z","27","28","29","20","2-","2.","2A","2B","2C","2D","2E","2F","2G","2H","2I","2J","2K","2L","2M","2N","2O","2P","2Q","2R","2S","2T","2U","2V","2W","2X","2Y","2Z","2$","2/","2+","2%","2 "],u1=[1,9,31,26,2,12,17,23,37,18,22,6,27,44,15,43,39,11,13,5,41,33,36,8,4,32,3,19,40,25,29,10,24,30],d1=[20,...u1.slice(0,32)],v1=[16,...u1.slice(1,33)],J0=[38,...u1.slice(2,34)],H1=[9,16,23,30,37,42,49],z0=["1001","0101","1100","0011","1010","0110","1111","0000"];let h1=null;function tt(){return h1===null&&(h1=[z1,t0].map(t=>y1(t,2401,o=>o))),h1}function p1(t){const o=K0[t],e=Y0.indexOf(o[1]);return o[0]==="1"?[W1,e]:o[0]==="2"?[Z0,e]:[e]}function j(t,o,e){let n=Number(o);const r=new Array(t);for(let s=t-1;s>=0;s--)r[s]=n%48,n=Math.floor(n/48);e.push(...r)}function ot(t,o){const e=t.length%5,n=t.length-(e===2?7:e);for(let s=0;s<n;s+=5)j(3,t.slice(s,s+5),o);const r=t.slice(n);r.length===1?o.push(...p1(r.charCodeAt(0))):r.length===3?j(2,r,o):r.length===4?j(3,`10${r}`,o):r.length===7&&(j(3,`10${r.slice(0,4)}`,o),j(2,r.slice(4),o))}function et(t){const o=[];for(let d=0;d<t.length;d++){const h=t.charCodeAt(d);h>127&&_("Code 49 only encodes ASCII"),o.push(h)}o.length===0&&_("Code 49 needs data");const e=d=>{let h=0;for(;d+h<t.length&&o[d+h]>=48&&o[d+h]<=57;)h++;return h},n=[];let r,s=0,i=!1;if(e(0)>=5)r=2,i=!0;else{const d=p1(o[0]);d.length===1?r=0:(r=d[0]===W1?4:5,n.push(d[1]),s=1)}for(;s<o.length;){const d=e(s);if(i){if(d<5){n.push(a1),i=!1;continue}ot(t.slice(s,s+d),n),s+=d}else{if(d>=5){n.push(a1),i=!0;continue}n.push(...p1(o[s])),s++}}const c=H1.findIndex(d=>d>=n.length);c<0&&_("Too much data for a Code 49 symbol");const l=c+2,u=H1[c];for(;n.length<u;)n.push(a1);const f=new Array(l*8).fill(0);let C=0;for(let d=0;d<l-1;d++){let h=0;for(let a=0;a<7;a++)f[d*8+a]=n[C++],h+=f[d*8+a];f[d*8+7]=h%49}const b=(l-1)*8;for(let d=0;C<u;d++)f[b+d]=n[C++];const w=(l-2)*7+r;f[b+6]=w;const L=d=>{let h=w*d[0];for(let a=0;a<(l-1)*8/2;a++)h+=(f[a*2]*49+f[a*2+1])*d[a+1];return h},S=(d,h)=>{f[b+d]=Math.floor(h/49),f[b+d+1]=h%49};l>=7&&S(0,L(J0)%2401);const E=f[b]*49+f[b+1],T=(L(v1)+E*v1[l*4-3])%2401;S(2,T);const y=(L(d1)+E*d1[l*4-3]+T*d1[l*4-2])%2401;S(4,y);let x=0;for(let d=0;d<7;d++)x+=f[b+d];return f[b+7]=x%49,{rows:l,characters:f}}function nt(t){const{rows:o,characters:e}=et(t),n=tt(),r=70,s=o*8+o+1,i=$(r,s,{quiet:{l:10,r:1,t:0,b:0},rowScale:1,text:null}),{bits:c}=i,l=f=>c.fill(1,f*r,(f+1)*r);let u=0;l(u++);for(let f=0;f<o;f++){const C=f===o-1?"0000":z0[f],b=new Uint8Array(r);b[0]=1;let w=2;for(let L=0;L<4;L++){const S=e[f*8+L*2]*49+e[f*8+L*2+1],E=n[Number(C[L])][S];for(let T=15;T>=0;T--)b[w++]=E>>T&1}b.fill(1,w,w+4);for(let L=0;L<8;L++)c.set(b,u++*r);f<o-1&&l(u++)}return l(u),i.rows=o,i}const rt="0123456789-$:/.+ABCD",st=["0000011","0000110","0001001","1100000","0010010","1000010","0100001","0100100","0110000","1001000","0001100","0011000","1000101","1010001","1010100","0010101","0011010","0101001","0001011","0001110"];function ct(t){let o=t.toUpperCase();o===""&&_("Codabar needs data"),/^[A-D]/.test(o)||(o=`A${o}`),(!/[A-D]$/.test(o)||o.length<2)&&(o=`${o}B`),/^[A-D][0-9\-$:/.+]*[A-D]$/.test(o)||_("Codabar encodes digits and - $ : / . + between A to D");const e=[];return[...o].forEach((n,r)=>{r>0&&e.push(1);for(const s of st[rt.indexOf(n)])e.push(s==="1"?3:1)}),i1(e,{quiet:{l:10,r:10,t:0,b:0},text:o})}const C1=["0001101","0011001","0010011","0111101","0100011","0110001","0101111","0111011","0110111","0001011"],g1=C1.map(t=>[...t].map(o=>o==="1"?"0":"1").join("")),it=g1.map(t=>[...t].reverse().join("")),lt=["LLLLLL","LLGLGG","LLGGLG","LLGGGL","LGLLGG","LGGLLG","LGGGLL","LGLGLG","LGLGGL","LGGLGL"];function q1(t,o,e){return/^\d+$/.test(t)||_(`${e} takes digits only`),t.length===o-1?t+f1(t):(t.length!==o&&_(`${e} takes ${o-1} or ${o} digits`),f1(t.slice(0,-1))!==Number(t[o-1])&&_(`${e} has a bad check digit`),t)}function Q1(t,o,e){const n=$(t.length,1,{quiet:o,text:e});for(let r=0;r<t.length;r++)n.bits[r]=t[r]==="1"?1:0;return n}function ft(t){const o=q1(t,13,"EAN-13"),e=_1(o),n=lt[e[0]];let r="101";for(let s=0;s<6;s++)r+=(n[s]==="L"?C1:it)[e[s+1]];r+="01010";for(let s=0;s<6;s++)r+=g1[e[s+7]];return Q1(`${r}101`,{l:11,r:7,t:0,b:0},o)}function at(t){const o=q1(t,8,"EAN-8"),e=_1(o);let n="101";for(let r=0;r<4;r++)n+=C1[e[r]];n+="01010";for(let r=0;r<4;r++)n+=g1[e[r+4]];return Q1(`${n}101`,{l:7,r:7,t:0,b:0},o)}const A1={qrcode:u0,datamatrix:C0,pdf417:x0,code128:N0,gs1_128:F0,code39:v0,code93:j0,code49:nt,codabar:ct,ean13:ft,ean8:at},St=Object.keys(A1);function ut(t,o,e={}){return Object.hasOwn(A1,t)||_(`Unknown barcode type ${t}`),A1[t](String(o),e)}const V1=10;function dt(t,o,e,n,r,s,i={}){const{color:c="#000000",background:l="#ffffff",showText:u=!0,scale:f=1}=i;l&&(t.fillStyle=l,t.fillRect(e,n,r,s));const{width:C,height:b,bits:w,quiet:L,rowScale:S}=o,E=b===1,T=E&&u&&o.text?Math.round(V1*f*1.3):0,y=C+L.l+L.r,x=s-T;if(r<=0||x<=0)return;let d=r/y;E||(d=Math.min(d,x/(b*S+L.t+L.b))),d>=1&&(d=Math.floor(d));const h=e+(r-y*d)/2+L.l*d,a=E?x:b*S*d,R=E?n:n+(x-a)/2,D=k=>Math.round(h+k*d),M=k=>Math.round(R+k*a/b);t.fillStyle=c;for(let k=0;k<b;k++){const W=M(k),v=M(k+1);if(v<=W)continue;const N=k*C;for(let I=0;I<C;I++){if(w[N+I]===0)continue;let G=I+1;for(;G<C&&w[N+G]===1;)G++;const B=D(I),O=D(G);O>B&&t.fillRect(B,W,O-B,v-W),I=G}}if(T>0){const k=Math.round(V1*f);t.font=`${k}px Menlo, Consolas, monospace`,t.textAlign="center",t.textBaseline="alphabetic",t.fillText(o.text,e+r/2,n+s-Math.round(2*f),r)}}const r1="@@8cBC1:",b1=/^#[0-9a-fA-F]{6}$/;function ht(t,o,e={},n={}){return`${r1}${e0({t,d:o,o:e,c:n.color??void 0,b:n.background??void 0,x:n.showText===!1?0:void 0})}`}function X1(t){if(!t.startsWith(r1))return null;try{const o=JSON.parse(t.slice(r1.length));return typeof o.t!="string"||typeof o.d!="string"?null:{type:o.t,data:o.d,options:o.o&&typeof o.o=="object"?o.o:{},color:b1.test(o.c)?o.c:"#000000",background:b1.test(o.b)?o.b:"#ffffff",showText:o.x!==0}}catch{return null}}const pt=256,U=new Map;function j1(t){let o=U.get(t);if(o!==void 0)return U.delete(t),U.set(t,o),o;o=null;const e=X1(t);if(e)try{o={...e,symbol:ut(e.type,e.data,e.options)}}catch(n){if(!(n instanceof c1))throw n}return U.size>=pt&&U.delete(U.keys().next().value),U.set(t,o),o}const Et=t=>t.startsWith(r1);function Dt(t){return X1(t)?.data??t}function Rt(t,o,e,n,r,s,i){const c=j1(o);if(c===null)return!1;const l=Math.max(1,Math.round(i));return t.save(),t.beginPath(),t.rect(e,n,r,s),t.clip(),dt(t,c.symbol,e+l,n+l,r-l*2,s-l*2,{color:c.color,background:c.background,showText:c.showText,scale:i}),t.restore(),!0}Z1("Barcode");function P(t){if(J1(t)||t===null||t==="")return;const o=K(t);if(!b1.test(o))throw Z.VALUE;return o}function V(t,o,e,n){const r=K(o);if(r==="")return"";try{const s=ht(t,r,e,n);if(j1(s)===null)throw Z.VALUE;return s}catch(s){throw s instanceof c1?Z.VALUE:s}}const m1=(t,o)=>{const e=Q(t,o);return e===null?o:Math.trunc(K1(e))};q("BC_QRCODE",1,5,(t,o,e,n,r)=>V("qrcode",t,{ec:K(Q(o,"M"))||"M",version:m1(e,0)},{color:P(n),background:P(r)})),q("BC_DATAMATRIX",1,4,(t,o,e,n)=>{const r=K(Q(o,"square")).toLowerCase()||"square";if(!["square","rect","auto"].includes(r))throw Z.VALUE;return V("datamatrix",t,{shape:r},{color:P(e),background:P(n)})}),q("BC_PDF417",1,5,(t,o,e,n,r)=>V("pdf417",t,{level:m1(o,-1),columns:m1(e,0)},{color:P(n),background:P(r)}));const X=(t,o,e=()=>({}))=>{q(t,1,4,(n,r,s,i)=>V(o,n,e(),{showText:s1(Q(r,!0)),color:P(s),background:P(i)}))};X("BC_CODE128","code128"),X("BC_GS1_128","gs1_128"),X("BC_CODE93","code93"),X("BC_CODABAR","codabar"),X("BC_EAN13","ean13"),X("BC_EAN8","ean8"),q("BC_CODE49",1,3,(t,o,e)=>V("code49",t,{},{color:P(o),background:P(e)})),q("BC_CODE39",1,5,(t,o,e,n,r)=>V("code39",t,{check:s1(Q(r,!1))},{showText:s1(Q(o,!0)),color:P(e),background:P(n)}));for(const[t,o]of Y1)t.startsWith("BC_")&&(o.notInExcel=!0);export{r1 as BARCODE_PREFIX,St as BARCODE_TYPES,c1 as BarcodeError,h0 as DATA_MATRIX_SIZES,Dt as barcodeDataText,ht as barcodeDescriptor,O0 as code128Check,W0 as code39Check,et as code49Characters,tt as code49Tables,X0 as code93Checks,Lt as dataMatrixErrorCodewords,wt as dataMatrixPlacement,dt as drawBarcode,ut as encodeBarcode,f1 as gs1CheckDigit,Et as isBarcodeText,Rt as paintBarcodeValue,X1 as parseBarcodeDescriptor,A0 as pdf417Clusters,T0 as pdf417ErrorCodewords,k0 as pdf417FromCodewords,l0 as qrAlignmentCenters,R1 as qrByteCapacity,mt as qrErrorCodewords,Mt as qrFormatBits,D1 as qrLayout,E1 as qrTotalCodewords,_t as qrVersionBits};
@@ -0,0 +1 @@
1
+ import{cssFont as b}from"../core/styles.js";import{formatGeneral as S,getFormatter as O}from"../core/numfmt.js";import{parseRangeRef as B}from"../core/address.js";const z=200,J=1e3,F=256*1024,L=64*1024,N={theme:{cellBg:"#ffffff",cellInk:"#000000",accent:"#107c41"},book:null,sheet:null,grid:null,row:0,col:0,printing:!1,id:0},j=/^#[0-9a-fA-F]{6}$/,R=/^data:image\/(png|jpeg|gif|webp|bmp|svg\+xml);base64,[A-Za-z0-9+/=]+$/,w=t=>typeof t=="string"&&j.test(t)?t:void 0,h=(t,e=J)=>t==null?void 0:String(t).slice(0,e),K=t=>typeof t=="string"&&/^(https?:|mailto:)/i.test(t.trim())?t.trim().slice(0,2e3):void 0,Q=t=>typeof t=="string"&&t.length<=300&&B(t.slice(t.lastIndexOf("!")+1))?t:void 0,_=t=>typeof t=="string"&&t.length<=F&&R.test(t)?t:void 0,v=(t,e=-1/0,n=1/0)=>Number.isFinite(t)?Math.max(e,Math.min(n,t)):void 0,tt=(t,e,n)=>Number.isFinite(t)?Math.max(e,Math.min(n,Math.trunc(t))):void 0,et=(t,e)=>e.includes(t)?t:void 0,nt=t=>t===!0?!0:void 0;function it(t){return Array.isArray(t)?t.slice(0,z).map(e=>{if(e!==null&&typeof e=="object"){const i={text:h(e.text??e.value)??"",value:h(e.value??e.text)??""},r=_(e.image),o=w(e.color),s=w(e.ink);return r&&(i.image=r),o&&(i.color=o),s&&(i.ink=s),e.disabled===!0&&(i.disabled=!0),Object.freeze(i)}const n=h(e)??"";return Object.freeze({text:n,value:n})}):[]}function U(t){for(const e of Object.keys(t))t[e]===void 0&&delete t[e];return t}const rt=(t,e)=>t!=null&&String(t).toLowerCase()===String(e).toLowerCase();function ot(t){return typeof t=="boolean"?t:typeof t=="number"?t!==0:typeof t=="string"&&t.toUpperCase()==="TRUE"}function W(t){return t==null?"":typeof t=="number"?S(t):typeof t=="boolean"?t?"TRUE":"FALSE":t}function X(t,e){return typeof t=="number"&&e.numFmt&&e.numFmt!=="General"?O(e.numFmt).number(t):W(t)}const c=new Map;function st(t){if(typeof t!="string"||t==="")return;let e=c.get(t);if(e===void 0){let n;try{n=JSON.parse(t)}catch{n=void 0}c.size>=2048&&c.clear(),e={parsed:n},c.set(t,e)}return e.parsed}const ut=(t,e,n)=>e>=t.x&&e<t.x+t.w&&n>=t.y&&n<t.y+t.h;function G(t,e,n){t.font=b(e,e.fontSize*n)}const $=t=>t.color??N.theme.cellInk;function ft(t,e,n,i,r,o,s){t.fillStyle=s,t.textAlign="center",t.textBaseline="middle",t.fillText(e,n+r/2,i+o/2),t.textBaseline="alphabetic",t.textAlign="left"}function lt(t,e,n,i,r,o){t.fillStyle=o,t.textAlign="left",t.textBaseline="middle",t.fillText(e,n,i+r/2),t.textBaseline="alphabetic"}let a;function at(t,e){return a===void 0&&(a=typeof document>"u"?null:document.createElement("canvas").getContext("2d")),a===null?e.length*t.fontSize*.5:(a.font=b(t,t.fontSize),a.measureText(e).width)}const d=new Map;function pt(t){let e=d.get(t);if(e===void 0){if(typeof Image>"u")return null;d.size>=256&&d.clear(),e={img:new Image,ready:!1};const{grid:n}=N;e.img.onload=()=>{e.ready=!0,n?.invalidate()},e.img.src=t,d.set(t,e)}return e.ready?e.img:null}function ct(t,e,n,i,r,o){const s=Math.min(r/e.naturalWidth,o/e.naturalHeight);if(!(s>0)||!t.drawImage)return;const u=e.naturalWidth*s,f=e.naturalHeight*s;t.drawImage(e,n+(r-u)/2,i+(o-f)/2,u,f)}function T(t,e,n,i,r){const o=X(n,i);if(o==="")return;G(t,i,r);const s=Math.round(2*r),u=i.hAlign??(typeof n=="number"?"right":typeof n=="boolean"?"center":"left");t.fillStyle=$(i),t.textAlign=u==="right"?"right":u==="center"?"center":"left",t.textBaseline="alphabetic";const f=i.fontSize*r,y=i.vAlign??"bottom",E=y==="top"?e.y+Math.round(f*1.05):y==="center"?e.y+Math.round((e.h+f*.72)/2):e.y+e.h-Math.round(3*r),I=u==="right"?e.x+e.w-s:u==="center"?e.x+e.w/2:e.x+s;t.fillText(o,I,E),t.textAlign="left"}class H{constructor(e){this.options=Object.freeze(e)}get type(){return this.constructor.typeName}get blocksEditing(){return!1}get opensList(){return!1}paint(){}hitTest(){return null}activate(){return!1}fitWidth(){return 0}editText(){}parseEdit(e){return e}toJSON(){return{type:this.type,...this.options}}}const m=new Map,p=new Map;let g=0;function dt(t){m.set(t.typeName,t)}const mt=()=>[...m.keys(),...p.keys()],A=new Set;function l(t,e,n){try{return n()}catch(i){return A.has(t)||(A.add(t),console.warn(`Cell type ${t} failed`,i)),e}}class M extends H{constructor(e,n){super(n),this.customName=e,this.generation=-1,this.instance=null}get type(){return this.customName}get impl(){if(this.generation!==g){this.generation=g;const e=p.get(this.customName);this.instance=e?l(this.customName,null,()=>e(this.options)):null}return this.instance}get blocksEditing(){return this.impl?.blocksEditing===!0}get opensList(){return this.impl?.opensList===!0}paint(e,n,i,r,o,s){const u=this.impl;if(!u||!u.paint){T(e,n,i,r,o);return}l(this.customName,!0,()=>u.paint(e,n,i,r,o,s)??!1)===!0&&T(e,n,i,r,o)}hitTest(e,n,i,r,o){return this.impl?.hitTest?l(this.customName,null,()=>this.impl.hitTest(e,n,i,r,o)??null):null}activate(e,n,i,r,o){return this.impl?.activate?l(this.customName,!1,()=>this.impl.activate(e,n,i,r,o)===!0):!1}fitWidth(e,n){return this.impl?.fitWidth?l(this.customName,0,()=>this.impl.fitWidth(e,n)??0):0}editText(e){return this.impl?.editText?l(this.customName,void 0,()=>this.impl.editText(e)):void 0}parseEdit(e){return this.impl?.parseEdit?l(this.customName,e,()=>this.impl.parseEdit(e)):e}toJSON(){const e=this.impl;return{...e?.toJSON?l(this.customName,this.options,()=>e.toJSON()):this.options,type:this.customName}}}const k=/^[A-Za-z][\w.-]{0,63}$/;function ht(t,e){if(!k.test(t)||m.has(t))throw new Error(`Can't register a cell type named ${t}`);if(typeof e=="function")p.set(t,n=>e.fromJSON?e.fromJSON(n):new e(n));else if(e!==null&&typeof e=="object")p.set(t,n=>{const i=Object.create(e);return i.options=e.fromJSON?e.fromJSON(n):n,i});else throw new Error("A cell type is a class or an object");g++}function Z(t,e={}){const n=m.get(t);if(n)return new n(U(n.sanitize(e)));if(p.has(t)){const{type:i,...r}=e;return new M(t,JSON.parse(JSON.stringify(r)))}return null}function gt(t){const e=Z(t.type,t);if(e!==null)return e;if(typeof t.type!="string"||!k.test(t.type))return null;const{type:n,...i}=t;return JSON.stringify(i).length>L?null:new M(n,i)}const C=new Map;function xt(t,e){C.set(t,e)}function yt(t,e){C.get(t)?.(e)}let x=null;function bt(t){x=t}function P(t,e,n,i){return x===null||(t.cellButtons===null||t.cellButtons===void 0)&&i?.ext?.buttons===void 0?null:x(t,e,n,i)}const V=(t,e)=>t.cellButtons!==null&&t.cellButtons!==void 0||e.styles.hasButtons===!0;function Nt(t,e,n){const i=t.grid.cellRect(e,n),{book:r}=t,{sheet:o}=r;if(!V(o,r))return i;const s=o.mergeAt(e,n),u=P(o,s?s.r0:e,s?s.c0:n,r.styles.list[o.style(e,n)]??r.styles.list[0]);if(u===null)return i;const f=t.grid.zoom;return{x:i.x+u[0]*f,y:i.y,w:Math.max(0,i.w-(u[0]+u[1])*f),h:i.h}}export{H as CellType,z as MAX_ITEMS,J as MAX_TEXT,P as buttonInsets,pt as cachedImage,gt as cellTypeFromFile,mt as cellTypeNames,ft as centerText,Nt as controlRect,dt as defineCellType,ct as drawImageFit,U as dropUndefined,nt as flag,X as formatted,N as frame,V as hasCellButtons,ut as inRect,$ as inkOf,ot as isChecked,W as labelOf,lt as leftText,Z as makeCellType,et as oneOf,T as paintPlain,st as parseJsonCached,xt as registerButtonAction,ht as registerCellType,yt as runButtonAction,w as safeColor,_ as safeImage,tt as safeInt,it as safeItems,K as safeLink,Q as safeLocation,v as safeNumber,h as safeText,rt as sameValue,bt as setButtonInsets,G as setFont,at as textWidth};
@@ -0,0 +1 @@
1
+ import{cellKey as B,makeDropdown as X,openCellDropdown as q,openDropdownConfig as J}from"./dropdowns.js";import{cachedImage as Q,drawImageFit as Z,dropUndefined as tt,flag as et,leftText as nt,oneOf as P,runButtonAction as ot,safeColor as W,safeImage as it,safeInt as F,safeText as R,setButtonInsets as lt,setFont as st,textWidth as G}from"./base.js";import{drawGlyph as ct,GLYPH_NAMES as rt}from"./glyphs.js";const ft=8,U=1,wt=["always","hover","selected","editing"];function ut(t){if(t===null||typeof t!="object")return null;let e;return t.dropdown===!0?e=!0:t.dropdown!==null&&typeof t.dropdown=="object"&&(e=X(t.dropdown.type,t.dropdown)??void 0),Object.freeze(tt({id:R(t.id,100),position:P(t.position,["left"]),glyph:P(t.glyph,rt),caption:R(t.caption,100),captionSide:P(t.captionSide,["left"]),image:it(t.image),imageSize:F(t.imageSize,6,64),width:F(t.width,8,400),enabled:t.enabled===!1?!1:void 0,visibility:P(t.visibility,["hover","selected","editing"]),action:R(t.action,200),dropdown:e,buttonStyle:et(t.buttonStyle),color:W(t.color),hoverColor:W(t.hoverColor),title:R(t.title,200)}))}function xt(t){if(!Array.isArray(t))return null;const e=t.slice(0,ft).map(ut).filter(n=>n!==null);return e.length>0?Object.freeze(e):null}function C(t,e,n,o){const i=t.mergeAt(e,n),l=i?i.r0:e,r=i?i.c0:n,c=t.cellButtons?.get(B(l,r));return c!==void 0?c:o===void 0||o.styles.hasButtons!==!0?null:o.styles.list[t.style(l,r)]?.ext?.buttons??null}const Y=t=>t.glyph||t.image?t.imageSize??14:0;function N(t,e){if(t.width!==void 0)return t.width;const n=Y(t),o=t.caption?G(e,t.caption)+6:0;return Math.max(14,n+o+(n&&o?2:0)+(t.buttonStyle?4:2))}function _(t,e,n,o,i){const l=new Array(t.length).fill(null),r=U*n;let c=e.x,f=e.x+e.w;for(let s=t.length-1;s>=0;s--){const u=t[s];if(u.position==="left"||!i(u))continue;const d=N(u,o)*n;f-=d,l[s]={x:f,y:e.y,w:d,h:e.h},f-=r}for(let s=0;s<t.length;s++){const u=t[s];if(u.position!=="left"||!i(u))continue;const d=N(u,o)*n;l[s]={x:c,y:e.y,w:d,h:e.h},c+=d+r}return l}const z=t=>t.visibility===void 0,K=new WeakMap;function dt(t,e,n,o){const i=t.cellButtons?.get(B(e,n))??o?.ext?.buttons;if(i===void 0)return null;let l=K.get(i);if(l===void 0||l.size!==o.fontSize||l.name!==o.fontName){let r=0,c=0;for(const f of i){if(!z(f))continue;const s=N(f,o)+U;f.position==="left"?r+=s:c+=s}l={size:o.fontSize,name:o.fontName,insets:r===0&&c===0?null:[r,c]},K.set(i,l)}return l.insets}lt(dt);function D(t,e,n,o,i,l,r){const c=Math.round(n.x),f=Math.round(n.y),s=Math.round(n.w),u=Math.round(n.h),d=Math.max(1,Math.round(i)),w=e.enabled!==!1;t.save(),t.beginPath(),t.rect(c,f,s,u),t.clip(),w||(t.globalAlpha=.4),t.fillStyle=r,t.fillRect(c,f,s-(e.position==="left"?0:d),u-d),(e.buttonStyle||e.color)&&(t.fillStyle=e.color??"#efefef",t.fillRect(c+d,f+d,s-d*2,u-d*2)),l&&w&&(t.fillStyle=e.hoverColor??"rgba(0, 0, 0, 0.12)",t.fillRect(c+d,f+d,s-d*2,u-d*2)),e.buttonStyle&&(t.strokeStyle="#8f8f8f",t.lineWidth=d,t.strokeRect(c+d/2,f+d/2,s-d,u-d));const h=o.color??"#3c3c3c",a=Math.min(Math.round(Y(e)*i),u-d*2),m=e.caption?G(o,e.caption)*i:0,x=a+m+(a&&m?2*i:0);let v=c+Math.max(d,(s-x)/2);const M=()=>{if(a<=0)return;const g=f+(u-a)/2;if(e.image){const y=Q(e.image);y&&Z(t,y,v,g,a,a)}else ct(t,e.glyph,v,g,a,h);v+=a+(m?2*i:0)},p=()=>{m&&(st(t,o,i),nt(t,e.caption,v,f,u,h),v+=m+2*i)};e.captionSide==="left"?(p(),M()):(M(),p()),t.restore()}function kt(t,e,n,o,i,l,r,c,f,s){const{sheet:u,book:d,theme:w}=e;if(u.cellButtons?.has(B(o,i)))return;const h=d.styles.list[u.style(o,i)]??d.styles.list[0],a=_(n,{x:l,y:r,w:c,h:f},s,h,z);n.forEach((m,x)=>{a[x]!==null&&D(t,m,a[x],h,s,!1,h.fill??w.cellBg)})}function vt(t,e,n,o,i){const{sheet:l,book:r,theme:c}=e,f=l.cellButtons,{ca:s,cb:u,ra:d,rb:w,s:h,xs:a,ys:m}=o,x=i.length>0,v=(p,g,y,k,E,H,T)=>{const A=r.styles.list[l.style(g,y)]??r.styles.list[0],S=_(p,{x:k,y:E,w:H,h:T},h,A,z);p.forEach((b,O)=>{S[O]!==null&&D(t,b,S[O],A,h,!1,A.fill??c.cellBg)})},M=(p,g,y)=>{if(x&&l.mergeAt(g,y)!==null)return;const k=a[y-s+1]-a[y-s],E=m[g-d+1]-m[g-d];k>0&&E>0&&v(p,g,y,a[y-s],m[g-d],k,E)};if(f.size<(u-s+1)*(w-d+1))for(const[p,g]of f){const y=Math.floor(p/16384),k=p-y*16384;y>=d&&y<=w&&k>=s&&k<=u&&M(g,y,k)}else for(let p=d;p<=w;p++)for(let g=s;g<=u;g++){const y=f.get(B(p,g));y!==void 0&&M(y,p,g)}for(const p of i){const g=f.get(B(p.r0,p.c0));if(g===void 0||p.c1<s||p.c0>u)continue;const y=e._rectInPane(p,n,h);v(g,p.r0,p.c0,y.x,y.y,y.w,y.h)}}function V(t,e,n){for(const o of t.selection.ranges)if(e>=o.r0&&e<=o.r1&&n>=o.c0&&n<=o.c1)return!0;return!1}const at=2e3,ht=new Map;function Bt(t,e){const{sheet:n,book:o,dpr:i,zoom:l,theme:r,selection:c}=e,f=n.cellButtons??ht,s=e.buttonHover??null,u=i*l,d=(a,m)=>{const x=Math.floor(a/16384),v=a-x*16384,M=s!==null&&s.key===a,p=V(e,x,v);if(!M&&!p)return;const g=S=>z(S)||S.visibility==="hover"&&M||S.visibility==="selected"&&p,y=e.cellRect(x,v);if(y.w<=0||y.h<=0)return;const k=e.hitCell(y.x+y.w/2,y.y+y.h/2),E=n.mergeAt(k.row,k.col);if((E?B(E.r0,E.c0):B(k.row,k.col))!==a)return;const H={x:Math.round(y.x*i),y:Math.round(y.y*i),w:Math.round(y.w*i),h:Math.round(y.h*i)},T=o.styles.list[n.style(x,v)]??o.styles.list[0],A=_(m,H,u,T,g);m.forEach((S,b)=>{if(A[b]===null)return;const O=M&&s.index===b;z(S)&&!O||D(t,S,A[b],T,u,O,T.fill??r.cellBg)})};if(s!==null){const a=Math.floor(s.key/16384),m=C(n,a,s.key-a*16384,o);m!==null&&d(s.key,m)}const w=n.mergeAt(c.row,c.col),h=w?B(w.r0,w.c0):B(c.row,c.col);if(f.size<=at)for(const[a,m]of f)(s===null||s.key!==a)&&d(a,m);else{const a=f.get(h);a!==void 0&&(s===null||s.key!==h)&&d(h,a)}if(o.styles.hasButtons===!0&&!f.has(h)&&(s===null||s.key!==h)){const a=C(n,c.row,c.col,o);a!==null&&d(h,a)}}function j(t,e,n,o,i,l){const{grid:r,book:c}=t,{sheet:f}=c,s=V(r,e,n),u=h=>z(h)||h.visibility==="hover"||h.visibility==="selected"&&s,d=c.styles.list[f.style(e,n)]??c.styles.list[0];return _(o,r.cellRect(e,n),r.zoom,d,u).findIndex(h=>h!==null&&i>=h.x&&i<h.x+h.w&&l>=h.y&&l<h.y+h.h)}function L(t,e,n,o,i){const l=o[i];if(l.enabled===!1)return;const{sheet:r}=t.book;l.dropdown===!0?q(t,e,n):l.dropdown&&J(t,e,n,l.dropdown);const c={row:e,col:n,sheet:r,action:l.action??null,index:i,id:l.id??null};l.action!==void 0&&ot(l.action,{app:t,...c}),t.grid.host.dispatchEvent(new CustomEvent("cellbutton",{bubbles:!0,detail:c}))}function $(t,e,n){const o=t.mergeAt(e,n);return o?[o.r0,o.c0]:[e,n]}function Mt(t,e,n,o,i){const{sheet:l}=t.book,r=C(l,e,n,t.book);if(r===null)return!1;const c=j(t,e,n,r,o,i);if(c<0)return!1;const[f,s]=$(l,e,n);return L(t,f,s,r,c),!0}function St(t,e,n,o,i){const l=C(t.book.sheet,e,n,t.book);if(l===null)return!1;const r=j(t,e,n,l,o,i);return r>=0&&l[r].enabled!==!1}function Et(t,e,n,o){const{sheet:i}=t.book,l=C(i,e,n,t.book);if(l===null||o>=l.length)return!1;const[r,c]=$(i,e,n);return L(t,r,c,l,o),!0}function Ct(t,e,n){const{sheet:o}=t.book,i=C(o,e,n,t.book);if(i===null)return!1;const l=i.findIndex(f=>f.dropdown&&f.enabled!==!1);if(l<0)return!1;const[r,c]=$(o,e,n);return L(t,r,c,i,l),!0}function At(t,e,n,o){const{grid:i}=t,{sheet:l}=t.book;let r=null;if(e!==null&&e.type==="cell"){const f=C(l,e.row,e.col,t.book);if(f!==null){const[s,u]=$(l,e.row,e.col);r={key:B(s,u),index:j(t,e.row,e.col,f,n,o)}}}const c=i.buttonHover??null;c===null&&r===null||c!==null&&r!==null&&c.key===r.key&&c.index===r.index||(i.buttonHover=r,i.invalidateTop())}let I=null;function zt(t,e,n){yt();const{book:o,grid:i}=t,{sheet:l}=o,r=C(l,e,n,o);if(r===null||!r.some(u=>u.visibility==="editing"))return;const c=o.styles.list[l.style(e,n)]??o.styles.list[0],f=i.cellRect(e,n);I=document.createElement("div"),I.style.cssText=`position:absolute;z-index:40;display:flex;gap:1px;top:${f.y}px;height:${f.h}px;left:${f.x+f.w+1}px`;const s=window.devicePixelRatio||1;r.forEach((u,d)=>{if(u.visibility!=="editing")return;const w=N(u,c),h=document.createElement("button");h.type="button",h.title=u.title??u.caption??u.glyph??"",h.disabled=u.enabled===!1,h.style.cssText=`width:${w}px;height:100%;padding:0;border:1px solid #8f8f8f;background:${u.color??"#efefef"}`;const a=document.createElement("canvas");a.width=Math.ceil(w*s),a.height=Math.ceil(f.h*s),a.style.cssText=`width:${w}px;height:100%;display:block`,D(a.getContext("2d"),{...u,color:void 0,buttonStyle:void 0},{x:0,y:0,w:a.width,h:a.height},c,s,!1,u.color??"#efefef"),h.append(a);for(const m of["pointerdown","pointerup","mousedown","dblclick"])h.addEventListener(m,x=>{x.preventDefault(),x.stopPropagation()});h.addEventListener("click",()=>{t.controller.commitEdit(0,0),L(t,e,n,r,d)}),I.append(h)}),i.host.append(I)}function yt(){I?.remove(),I=null}export{wt as BUTTON_VISIBILITY,St as cellButtonCursor,C as cellButtonsAt,yt as hideEditingButtons,xt as makeCellButtons,Ct as openButtonDropdown,vt as paintCellButtons,Bt as paintFloatingButtons,kt as paintStyleButtons,Mt as pressCellButton,Et as pressNthButton,zt as showEditingButtons,At as trackButtonHover};
@@ -0,0 +1,2 @@
1
+ import{loadBookParts as Ht}from"../cells/book-read.js";import{EMPTY as gt,KIND_MASK as yt}from"../core/sheet.js";import{quoteSheetName as jt,rangeRef as Kt,parseRangeRef as bt}from"../core/address.js";import{sheetRenameHooks as Xt,shiftSparse as Yt}from"../core/sparse.js";import{children as Ut,parseTree as kt,unescapeOoxml as Mt}from"../io/xml-scan.js";import{safeJson as Jt,xmlAttr as wt}from"../io/xml-escape.js";import{openZip as Gt}from"../io/zip-reader.js";import{applyToRanges as Vt,cellKey as I,cellDropdownArrow as qt,closeDropdown as Zt,literalInput as W,makeDropdown as St,openCellDropdown as Tt,openListPopup as lt,readCellValue as _,writeCell as z}from"./dropdowns.js";import{undoGroup as Qt}from"../cells/undo-group.js";import{cellTypePart as te,CELLS_NS as ee,CELLTYPES_NS as ne,readCellTypeParts as oe}from"./persist.js";import{cellsPackage as ie,loadCellsPart as se}from"../cells/sections.js";import{backgroundParts as re,loadBackgrounds as le}from"../cells/background.js";import{loadWatermarks as ae,watermarkParts as fe}from"../api/watermark-xml.js";import{loadRichData as ue,richPackage as ce}from"../cells/rich-data.js";import{buttonInsets as Ct,cachedImage as at,hasCellButtons as V,cellTypeFromFile as xt,CellType as Y,centerText as B,controlRect as Q,defineCellType as de,drawImageFit as ft,flag as A,formatted as he,frame as M,inkOf as U,inRect as F,isChecked as vt,labelOf as L,leftText as j,makeCellType as _t,oneOf as q,runButtonAction as Et,safeColor as R,safeImage as me,safeInt as x,safeItems as Rt,safeLink as zt,safeLocation as pe,safeText as E,sameValue as N,setFont as D,textWidth as O,cellTypeNames as ge,registerButtonAction as ye,registerCellType as be}from"./base.js";import{cellButtonCursor as ke,makeCellButtons as It,openButtonDropdown as Me,paintCellButtons as we,paintFloatingButtons as Se,paintStyleButtons as Te,pressCellButton as Ce,pressNthButton as xe,trackButtonHover as Lt}from"./cell-buttons.js";import{cellFilesPackage as ve,attachFileDrop as Ot}from"./file-cell.js";import{hideEditingButtons as _e,showEditingButtons as Ee}from"./cell-buttons.js";import"./diagonal.js";import"./data-object.js";import"./range-template.js";import"./dropdowns-more.js";import"../a11y/cell-alt-text.js";import{registerFeatureReviver as Re}from"../api/serialize.js";Re("cellTypes",o=>{if(!(o instanceof Map))return null;const t=new Map,e=new Map;for(const[n,s]of o){if(!s||typeof s!="object")continue;const i=JSON.stringify(s);e.has(i)||e.set(i,xt(s));const r=e.get(i);r&&t.set(n,r)}return t.size?t:null});const Pt=1e6,K=(o,t)=>{o.globalAlpha=t?.4:1};function tt(o,t,e,n,s,i){o.beginPath(),o.roundRect?o.roundRect(t,e,n,s,i):o.rect(t,e,n,s)}function Wt(o,t,e,n,s,i,r=!1){const a=Math.max(1,Math.round(i)),l=s!==!1,f=r?Math.round(n*.2):0;tt(o,t+a/2,e+a/2,n-a,n-a,f),o.fillStyle=l?M.theme.accent:"#ffffff",o.fill(),o.strokeStyle=l?M.theme.accent:"#6e6e6e",o.lineWidth=a,o.stroke(),s===null?(o.fillStyle="#ffffff",o.fillRect(t+n*.22,e+n*.44,n*.56,Math.max(1.5,n/7))):s&&(o.strokeStyle="#ffffff",o.lineWidth=Math.max(1.5,n/7),o.lineCap="round",o.beginPath(),o.moveTo(t+n*.22,e+n*.52),o.lineTo(t+n*.42,e+n*.72),o.lineTo(t+n*.78,e+n*.3),o.stroke(),o.lineCap="butt")}function Bt(o,t,e,n,s,i){const r=n/2;o.beginPath(),o.arc(t+r,e+r,r-Math.max(1,i)/2,0,Math.PI*2),o.fillStyle="#ffffff",o.fill(),o.strokeStyle=s?M.theme.accent:"#6e6e6e",o.lineWidth=Math.max(1,Math.round(i)),o.stroke(),s&&(o.beginPath(),o.arc(t+r,e+r,r*.5,0,Math.PI*2),o.fillStyle=M.theme.accent,o.fill())}const et=new Map,ze=120;function ut(o,t,e,n){const s=e.duration??ze;if(s<=0||n===void 0||n===null||n.printing||n.grid===null)return t?1:0;let i=et.get(o);if(i===void 0)return et.size>=4096&&et.clear(),i={on:t,from:t?1:0,start:-1/0,ms:s},et.set(o,i),t?1:0;const r=performance.now(),a=(r-i.start)/i.ms,l=a>=1?i.on?1:0:i.from+((i.on?1:0)-i.from)*a;return i.on!==t?(i.on=t,i.from=l,i.start=r,i.ms=s,n.grid.invalidate(),l):(a<1&&n.grid.invalidate(),l)}const Ie=(o,t,e)=>{const n=s=>{const i=parseInt(o.slice(s,s+2),16),r=parseInt(t.slice(s,s+2),16);return Math.round(i+(r-i)*e).toString(16).padStart(2,"0")};return`#${n(1)}${n(3)}${n(5)}`},At=o=>/^#[0-9a-fA-F]{6}$/.test(o);function X(o,t,e,n=0){return n>0&&o.autoSize!==!1?Math.max(t*2,n+t+8*e):o.toggleWidth!==void 0?o.toggleWidth*e:t*2}function Z(o,t,e,n,s,i,r,a){const l=r.trackOn??M.theme.accent,f=r.trackOff??"#b4b4b4",u=r.trackRadius!==void 0?Math.min(s/2,r.trackRadius*a):s/2;tt(o,t,e,n,s,u),o.fillStyle=At(l)&&At(f)?Ie(f,l,i):i>.5?l:f,o.fill();const c=r.knobMargin!==void 0?r.knobMargin*a:Math.max(1,s/8),d=Math.max(1,s-c*2),h=t+c+(n-c*2-d)*i,m=e+c,p=r.knobOn??r.knob??"#ffffff",w=r.knobOff??r.knob??"#ffffff";o.fillStyle=i>.5?p:w,tt(o,h,m,d,d,r.knobRadius!==void 0?Math.min(d/2,r.knobRadius*a):d/2),o.fill()}function Le(o,t,e){const n=[];let s="";for(const i of t.split(/\s+/)){const r=s===""?i:`${s} ${i}`;s!==""&&o.measureText(r).width>e?(n.push(s),s=i):s=r}return n.push(s),n}const ct=(o,t,e,n)=>`${o?.sheet?.uid??0}:${t}:${e}:${n}`;function Ft(o,t,e,n,s,i,r,a,l,f){const u=Math.min(Math.round((r.boxSize??13)*i),Math.round(t.h-2));if(u<=2)return;const c=Math.round(3*i),d=Math.round(t.y+(t.h-u)/2),h=a===Z;if(e.disabled&&K(o,!0),r.textSide==="inside"&&(h||a===Bt)){const S=o.measureText(e.text).width,T=Math.min(t.w-c*2,h?X(r,u,i,S):S+u+8*i),C=Math.round(t.x+c);if(h){const g=ut(ct(l,l?.row,l?.col,f),n,r,l);Z(o,C,d,T,u,g,r,i),o.save(),o.beginPath(),o.rect(C,d,T,u),o.clip();const k=T-u-4*i;B(o,e.text,g>.5?C+2*i:C+u+2*i,d,k,u,e.ink??"#ffffff"),o.restore()}else tt(o,C,d,T,u,u/2),o.fillStyle=n?M.theme.accent:"#ffffff",o.fill(),o.strokeStyle=n?M.theme.accent:"#6e6e6e",o.lineWidth=Math.max(1,Math.round(i)),o.stroke(),B(o,e.text,C,d,T,u,n?"#ffffff":e.ink??U(s));e.disabled&&K(o,!1);return}const m=h?X(r,u,i):u,p=r.textSide==="left",w=p?t.x+t.w-c-m:t.x+c;h?Z(o,Math.round(w),d,m,u,ut(ct(l,l?.row,l?.col,f),n,r,l),r,i):a(o,Math.round(w),d,u,n,i,r.mode==="modern");let y=p?t.x+c:t.x+c+m+Math.round(4*i);if(e.image){const S=at(e.image);S&&ft(o,S,y,d,u,u),y+=u+Math.round(3*i)}j(o,e.text,y,t.y,t.h,e.ink??U(s)),e.disabled&&K(o,!1)}function Oe(o,t,e,n,s){const{items:i,horizontal:r,flow:a,maxRows:l,maxCols:f}=t,u=[],c=i.length;if(c===0)return u;const d=(t.pad??0)*e,h=(t.spacingX??0)*e,m=(t.spacingY??0)*e,p=o.x+d,w=o.y+d,y=o.w-d*2,S=o.h-d*2;if(a&&r&&n){const b=n.fontSize*1.45*e;let v=p,P=w,H=0;for(const st of i){const rt=s(st,n)*e;H>0&&(f&&H>=f||v+rt>p+y)&&(v=p,P+=b+m,H=0),u.push({x:v,y:P,w:rt,h:b}),v+=rt+h,H++}const G=(S-(P+b-w))/2;if(G>0)for(const st of u)st.y+=G;return u}let T;r?T=l?Math.ceil(c/l):f??c:T=f??(l?Math.ceil(c/l):1),T=Math.max(1,Math.min(T,c));const C=Math.ceil(c/T),g=(y-h*(T-1))/T,k=(S-m*(C-1))/C;for(let b=0;b<c;b++){const v=r?Math.floor(b/T):b%C,P=r?b%T:Math.floor(b/C);u.push({x:p+P*(g+h),y:w+v*(k+m),w:g,h:k})}return u}class Pe extends Y{static typeName="button";static sanitize(t){return{text:E(t.text),value:E(t.value),action:E(t.action),color:R(t.color),image:me(t.image),disabled:A(t.disabled)}}paint(t,e,n,s,i){const r=Math.max(1,Math.round(i)),a=e.x+r,l=e.y+r,f=e.w-r*2,u=e.h-r*2;if(f<=0||u<=0)return;this.options.disabled&&K(t,!0),t.fillStyle=this.options.color??"#efefef",t.fillRect(a,l,f,u),t.strokeStyle="#8f8f8f",t.lineWidth=Math.max(1,Math.round(i)),t.strokeRect(a+.5,l+.5,f-1,u-1),D(t,s,i);const c=this.options.text??L(n),d=this.options.image?at(this.options.image):null;if(d){const h=Math.min(u-2*r,Math.round(16*i)),m=c===""?0:t.measureText(c).width+Math.round(4*i),p=a+Math.max(r,(f-h-m)/2);ft(t,d,p,l+(u-h)/2,h,h),c!==""&&j(t,c,p+h+Math.round(4*i),l,u,s.color??"#000000")}else B(t,c,a,l,f,u,s.color??"#000000");this.options.disabled&&K(t,!1)}hitTest(t,e,n){return!this.options.disabled&&F(t,e,n)?{part:"button"}:null}activate(t,e,n){const{action:s,value:i,disabled:r}=this.options;if(r||i!==void 0&&!z(t,e,n,W(i)))return!1;const a={row:e,col:n,sheet:t.book.sheet,action:s??null};return s!==void 0&&Et(s,{app:t,...a}),t.grid.host.dispatchEvent(new CustomEvent("cellbutton",{bubbles:!0,detail:a})),!0}fitWidth(t,e){return O(e,this.options.text??L(t))+(this.options.image?20:0)+12}}const Nt=o=>({trackOn:R(o.trackOn),trackOff:R(o.trackOff),knob:R(o.knob),knobOn:R(o.knobOn),knobOff:R(o.knobOff),toggleWidth:x(o.toggleWidth,8,400),toggleHeight:x(o.toggleHeight,6,200),autoSize:o.autoSize===!1?!1:void 0,knobMargin:x(o.knobMargin,0,40),trackRadius:x(o.trackRadius,0,100),knobRadius:x(o.knobRadius,0,100),duration:x(o.duration,0,2e3)});class We extends Y{static typeName="checkbox";static sanitize(t){return{text:E(t.text),textTrue:E(t.textTrue),textFalse:E(t.textFalse),textNull:E(t.textNull),mode:q(t.mode,["modern","toggle"]),threeState:t.mode==="toggle"?void 0:A(t.threeState),boxSize:x(t.boxSize,6,64),textSide:q(t.textSide,["left","top","bottom","inside"]),wrap:A(t.wrap),hit:q(t.hit,["box","cell"]),editable:A(t.editable),...Nt(t)}}get blocksEditing(){return this.options.editable!==!0}_state(t){return this.options.threeState&&(t===null||t==="")?null:vt(t)}_caption(t){const e=this.options;return t===!0&&e.textTrue!==void 0?e.textTrue:t===!1&&e.textFalse!==void 0?e.textFalse:t===null&&e.textNull!==void 0?e.textNull:e.text}_hasCaption(){const t=this.options;return t.text!==void 0||t.textTrue!==void 0||t.textFalse!==void 0||t.textNull!==void 0}_side(){const{textSide:t,mode:e}=this.options;return t==="inside"&&e!=="toggle"?void 0:t}_box(t,e,n,s){const i=this.options,r=i.mode==="toggle",a=(r?i.toggleHeight??i.boxSize??13:i.boxSize??13)*e,l=this._side(),f=this._hasCaption(),u=f&&(l==="top"||l==="bottom"),c=u&&n?n.fontSize*1.25*e:0,d=Math.min(a,t.h-2*e-c);let h=r?X(i,d,e):d;if(r&&l==="inside"&&n){const y=this._longestCaption(s);y&&(h=Math.min(t.w-2*e,X(i,d,e,O(n,y)*e)))}const m=3*e;let p;!f||u||l==="inside"?l==="inside"&&n?.hAlign==="left"?p=t.x+m:l==="inside"&&n?.hAlign==="right"?p=t.x+t.w-m-h:p=t.x+(t.w-h)/2:p=l==="left"?t.x+t.w-m-h:t.x+m;let w=t.y+(t.h-d)/2;if(u){const y=d+c,S=t.y+(t.h-y)/2;w=l==="top"?S+c:S}else if(i.wrap&&f){const y=n?.vAlign;y==="top"?w=t.y+2*e:y!=="center"&&(w=t.y+t.h-d-2*e)}return{x:p,y:w,w:h,h:d}}_longestCaption(){const t=this.options;return[t.textTrue,t.textFalse,t.textNull,t.text].filter(Boolean).reduce((e,n)=>e.length>=n.length?e:n,"")}paint(t,e,n,s,i,r){const a=this.options,l=this._box(e,i,s,n);if(l.h<=2)return;const f=this._state(n),u=this._side(),c=this._caption(f);if(D(t,s,i),a.mode==="toggle"){const g=ct(r,r?.row,r?.col,"box"),k=ut(g,f===!0,a,r);if(Z(t,Math.round(l.x),Math.round(l.y),Math.round(l.w),Math.round(l.h),k,a,i),u==="inside"&&c){t.save(),t.beginPath(),t.rect(l.x,l.y,l.w,l.h),t.clip();const b=l.w-l.h-2*i;B(t,c,k>.5?l.x+i:l.x+l.h+i,l.y,b,l.h,"#ffffff"),t.restore();return}}else Wt(t,Math.round(l.x),Math.round(l.y),Math.round(l.w),f,i,a.mode==="modern");if(c===void 0||c==="")return;const d=U(s);if(u==="top"||u==="bottom"){const g=s.fontSize*1.25*i,k=u==="top"?l.y-g:l.y+l.h;B(t,c,e.x,k,e.w,g,d);return}const h=4*i,m=u==="left"?e.x+3*i:l.x+l.w+h,p=u==="left"?l.x-h-m:e.x+e.w-m-2*i;if(!a.wrap){j(t,c,m,e.y,e.h,d);return}const w=Le(t,c,p),y=s.fontSize*1.2*i,S=w.length*y,T=s.vAlign,C=T==="top"?e.y+2*i:T==="center"?e.y+(e.h-S)/2:e.y+e.h-S-2*i;w.forEach((g,k)=>j(t,g,m,C+k*y,y,d))}hitTest(t,e,n,s=1,i=null){const{hit:r}=this.options;return r==="cell"||r!=="box"&&this._hasCaption()?F(t,e,n)?{part:"box"}:null:F(this._box(t,s,i),e,n)?{part:"box"}:null}activate(t,e,n){const{book:s}=t,i=this._state(_(s,s.sheet,e,n));return this.options.threeState?z(t,e,n,i===!0?"FALSE":i===!1?"":"TRUE"):z(t,e,n,i?"FALSE":"TRUE")}fitWidth(t,e){const n=this.options,s=n.mode==="toggle"?n.toggleHeight??n.boxSize??13:n.boxSize??13,i=this._caption(this._state(t)),r=this._side(),a=n.mode==="toggle"?n.toggleWidth??s*2:s,l=i?O(e,i):0;return r==="inside"?X(n,s,1,O(e,this._longestCaption()))+8:r==="top"||r==="bottom"?Math.max(a,l)+6:a+6+(l?l+4:0)}}class nt extends Y{static sanitize(t){return{items:Rt(t.items),horizontal:A(t.horizontal),separator:E(t.separator,16),flow:A(t.flow),maxRows:x(t.maxRows,1,200),maxCols:x(t.maxCols,1,200),spacingX:x(t.spacingX,0,64),spacingY:x(t.spacingY,0,64),pad:x(t.pad,0,64),boxSize:x(t.boxSize,6,64),textSide:q(t.textSide,["left","inside"]),mode:q(t.mode,["modern","toggle"]),...Nt(t)}}get blocksEditing(){return!0}_itemWidth(t,e){const n=this.options,s=n.boxSize??13,i=n.mode==="toggle"?X(n,s,1):s;if(n.textSide==="inside"&&(n.mode==="toggle"||this.type==="radio")){const r=O(e,t.text);return(n.mode==="toggle"?X(n,s,1,r):r+s+8)+6}return i+10+O(e,t.text)+(t.image?16:0)}_slots(t,e,n){return Oe(t,this.options,e,n,(s,i)=>this._itemWidth(s,i))}hitTest(t,e,n,s=1,i=null){if(!F(t,e,n))return null;const r=this._slots(t,s,i).findIndex(a=>F(a,e,n));return r<0||this.options.items[r].disabled?null:{part:"item",index:r}}_hitItem(t,e,n,s,i){const{book:r}=t,a=r.styles.list[r.sheet.style(e,n)]??r.styles.list[0];return this.hitTest(Q(t,e,n),s,i,t.grid.zoom,a)}_nextEnabled(t){const{items:e}=this.options;for(let n=1;n<=e.length;n++){const s=(t+n)%e.length;if(!e[s].disabled)return s}return-1}fitWidth(t,e){const{items:n,horizontal:s,spacingX:i=0,pad:r=0,maxCols:a}=this.options,l=n.map(c=>this._itemWidth(c,e));if(l.length===0)return 0;const f=s?Math.min(a??l.length,l.length):1,u=Math.max(...l);return(s&&f===l.length?l.reduce((c,d)=>c+d,0):u*f)+i*(f-1)+r*2}}class Be extends nt{static typeName="radio";paint(t,e,n,s,i,r){D(t,s,i),this._slots(e,i,s).forEach((a,l)=>{const f=this.options.items[l];Ft(t,a,f,N(n,f.value),s,i,this.options,Bt,r,l)})}activate(t,e,n,s,i){const{items:r}=this.options;if(r.length===0)return!1;let a;if(s==null){const{book:l}=t,f=_(l,l.sheet,e,n);if(a=this._nextEnabled(r.findIndex(u=>N(f,u.value))),a<0)return!1}else{const l=this._hitItem(t,e,n,s,i);if(!l)return!1;a=l.index}return z(t,e,n,W(r[a].value))}}const ot=o=>o.separator??", ";function dt(o,t){if(o==null||o==="")return new Set;const e=String(o).split(ot(t).trim()||",").map(n=>n.trim().toLowerCase());return new Set(t.items.filter(n=>e.includes(String(n.value).toLowerCase())).map(n=>n.value))}class Ae extends nt{static typeName="checklist";paint(t,e,n,s,i,r){D(t,s,i);const a=dt(n,this.options),l=this.options.mode==="toggle"?Z:Wt;this._slots(e,i,s).forEach((f,u)=>{const c=this.options.items[u];Ft(t,f,c,a.has(c.value),s,i,this.options,l,r,u)})}_write(t,e,n,s){return z(t,e,n,W(s.join(ot(this.options))))}activate(t,e,n,s,i){const{items:r}=this.options,{book:a}=t,l=dt(_(a,a.sheet,e,n),this.options);if(s==null)return lt(t,e,n,{items:r.filter(c=>!c.disabled),selected:[...l],multi:!0,label:"Choices",onDone:c=>this._write(t,e,n,c)}),!0;const f=this._hitItem(t,e,n,s,i);if(!f)return!1;const u=r[f.index];return l.has(u.value)?l.delete(u.value):l.add(u.value),this._write(t,e,n,r.filter(c=>l.has(c.value)).map(c=>c.value))}}class Fe extends nt{static typeName="buttonlist";static sanitize(t){return{...nt.sanitize(t),horizontal:t.horizontal!==!1||void 0,multiple:A(t.multiple),selectedColor:R(t.selectedColor),selectedInk:R(t.selectedInk)}}_itemWidth(t,e){return O(e,t.text)+14+(t.image?18:0)}_chosen(t){if(this.options.multiple)return dt(t,this.options);const e=this.options.items.find(n=>N(t,n.value));return new Set(e?[e.value]:[])}paint(t,e,n,s,i){D(t,s,i);const r=this.options,a=Math.max(1,Math.round(i)),l=this._chosen(n);this._slots(e,i,s).forEach((f,u)=>{const c=r.items[u],d=l.has(c.value),h=Math.round(f.x)+a,m=Math.round(f.y)+a,p=Math.round(f.w)-a*2,w=Math.round(f.h)-a*2;if(p<=0||w<=0)return;c.disabled&&K(t,!0);const y=r.selectedColor??M.theme.accent;t.fillStyle=c.color??(d?y:"#efefef"),t.fillRect(h,m,p,w);const S=d&&c.color?a*2:a;t.strokeStyle=d?y:"#8f8f8f",t.lineWidth=S,t.strokeRect(h+S/2,m+S/2,p-S,w-S),t.save(),t.beginPath(),t.rect(h,m,p,w),t.clip();const T=c.ink??(d&&!c.color?r.selectedInk??"#ffffff":s.color??"#000000"),C=c.image?at(c.image):null;if(C){const g=Math.min(w-2*a,Math.round(14*i)),k=t.measureText(c.text).width+(c.text?Math.round(4*i):0),b=h+Math.max(a,(p-g-k)/2);ft(t,C,b,m+(w-g)/2,g,g),j(t,c.text,b+g+Math.round(4*i),m,w,T)}else B(t,c.text,h,m,p,w,T);t.restore(),c.disabled&&K(t,!1)}),r.items.length>0&&(t.textAlign="left")}activate(t,e,n,s,i){const{items:r,multiple:a}=this.options;if(r.length===0)return!1;const{book:l}=t,f=_(l,l.sheet,e,n);if(s==null){if(a)return lt(t,e,n,{items:r.filter(h=>!h.disabled),selected:[...this._chosen(f)],multi:!0,label:"Choices",onDone:h=>z(t,e,n,W(h.join(ot(this.options))))}),!0;const d=this._nextEnabled(r.findIndex(h=>N(f,h.value)));return d>=0&&z(t,e,n,W(r[d].value))}const u=this._hitItem(t,e,n,s,i);if(!u)return!1;const c=r[u.index];if(a){const d=this._chosen(f);return d.has(c.value)?d.delete(c.value):d.add(c.value),z(t,e,n,W(r.filter(h=>d.has(h.value)).map(h=>h.value).join(ot(this.options))))}return z(t,e,n,N(f,c.value)?"":W(c.value))}}function it(o,t,e){if(typeof o=="number")return o;if(typeof o=="string"&&t){const n=t.findIndex(s=>s.toLowerCase()===o.toLowerCase());if(n>=0)return n}return e}function ht(o,t,e,n){const s=[],i=Math.min(o,5e3);for(let r=0;r<i;r++){const a=L(t(r,e)),l=L(t(r,n));(a!==""||l!=="")&&s.push({text:String(a),value:String(l)})}return s}function Ne(o,t,e,{textColumn:n,valueColumn:s},i,r){const a=e.replace(/^=/,"").trim(),l=e[0]==="="?void 0:o.engine?.tables.get(a.toUpperCase());if(l){const y=l.columns?.map(k=>typeof k=="string"?k:k?.name??""),S=it(n,y,0),T=it(s,y,S),C=l.r0+(l.headerRows??1),g=l.r1-C+1-(l.totalsRows??0);return ht(g,(k,b)=>_(o,l.sheet,C+k,l.c0+b),S,T)}const f=it(n,null,0),u=it(s,null,f),c=a.lastIndexOf("!"),d=e[0]==="="?null:bt(c>=0?a.slice(c+1):a);if(d){const y=c>=0?a.slice(0,c).replace(/^'|'$/g,"").replace(/''/g,"'"):null,S=y===null?t:o.sheets.find(C=>C.name.toLowerCase()===y.toLowerCase());if(!S)return[];const T=Math.min(d.r1,S.maxRow)-d.r0+1;return ht(T,(C,g)=>_(o,S,d.r0+C,d.c0+g),f,u)}const{engine:h}=o;if(!h)return[];let m;try{const y=h.template(a,i,r);if(y.invalid)return[];m=y.fn(i,r,t),m&&m.sheet&&(m=h.toArr(m))}catch{return[]}if(!m||!m.data)return m==null||typeof m=="object"?[]:[{text:String(L(m)),value:String(L(m))}];const p=m.cols,w=(y,S)=>{const T=m.data[y*p+S];return T===void 0||T!==null&&typeof T=="object"?null:T};return ht(m.rows,w,f,u)}class De extends Y{static typeName="combobox";static sanitize(t){return{items:Rt(t.items),editable:A(t.editable),source:typeof t.source=="string"&&t.source.length<=500?t.source:void 0,textColumn:typeof t.textColumn=="string"?E(t.textColumn,200):x(t.textColumn,0,49),valueColumn:typeof t.valueColumn=="string"?E(t.valueColumn,200):x(t.valueColumn,0,49),maxItems:x(t.maxItems,1,100),float:t.float===!1?!1:void 0}}get blocksEditing(){return this.options.editable!==!0}get opensList(){return!0}_items(t,e,n,s){const{source:i,items:r}=this.options;return i===void 0?r:((this.sourceFrame!==M.id||this.sourceFrame===void 0)&&(this.sourceFrame=M.id,this.sourceItems=Ne(t,e,i,this.options,n,s)),this.sourceItems)}_arrow(t,e){const n=Math.min(16*e,t.h);return{x:t.x+t.w-n,y:t.y+(t.h-n)/2,w:n,h:n}}paint(t,e,n,s,i,r){const a=r?.printing===!0,l=this._arrow(e,i),u=(r?.book?this._items(r.book,r.sheet,r.row,r.col):this.options.items).find(m=>N(n,m.value))?.text??he(n,s);if(D(t,s,i),t.save(),t.beginPath(),t.rect(e.x,e.y,a?e.w:e.w-l.w,e.h),t.clip(),j(t,u,e.x+Math.round(2*i),e.y,e.h,U(s)),t.restore(),a)return;const c=Math.round(l.x),d=Math.round(l.y),h=Math.round(l.w);t.fillStyle="#f7f7f7",t.fillRect(c,d,h,h),t.strokeStyle="#8f8f8f",t.lineWidth=Math.max(1,Math.round(i/2)),t.strokeRect(c+.5,d+.5,h-1,h-1),t.fillStyle="#444444",t.beginPath(),t.moveTo(c+h*.28,d+h*.4),t.lineTo(c+h*.72,d+h*.4),t.lineTo(c+h*.5,d+h*.66),t.closePath(),t.fill()}hitTest(t,e,n,s=1){return F(t,e,n)?F(this._arrow(t,s),e,n)?{part:"arrow"}:this.options.editable?null:{part:"text"}:null}activate(t,e,n){const{book:s}=t,i=_(s,s.sheet,e,n);this.sourceFrame=void 0;const r=this._items(s,s.sheet,e,n);this.sourceFrame=void 0;const a=r.find(l=>N(i,l.value));return lt(t,e,n,{items:r,selected:a?[a.value]:[],label:"Choices",maxItems:this.options.maxItems??20,moveOnSide:!0,float:this.options.float!==!1,onDone:l=>l.length===0?!0:z(t,e,n,W(l[0]))}),!0}fitWidth(t,e){const n=this.options.items.find(s=>N(t,s.value))?.text??L(t);return O(e,String(n))+22}}const mt=new Set;class $e extends Y{static typeName="hyperlink";static sanitize(t){return{url:zt(t.url),location:pe(t.location),text:E(t.text),color:R(t.color),visitedColor:R(t.visitedColor),tooltip:E(t.tooltip),action:E(t.action),activeOnClick:t.activeOnClick===!1?!1:void 0}}get tooltip(){return this.options.tooltip}get runsWithoutSelecting(){return this.options.activeOnClick===!1}paint(t,e,n,s,i){const r=this.options.text??L(n);if(r==="")return;D(t,s,i);const a=e.x+Math.round(2*i),{url:l,location:f,color:u,visitedColor:c}=this.options,d=l??f??(typeof n=="string"?n:""),h=mt.has(d)?c??"#954f72":u??s.color??"#0563c1";j(t,r,a,e.y,e.h,h);const m=s.fontSize*i,p=Math.min(t.measureText(r).width,e.w-Math.round(4*i));t.fillRect(a,Math.round(e.y+e.h/2+m*.42),p,Math.max(1,Math.round(m/14)))}hitTest(t,e,n){return F(t,e,n)?{part:"link"}:null}activate(t,e,n){const{url:s,location:i,action:r}=this.options,{book:a}=t;if(r!==void 0){const f={row:e,col:n,sheet:a.sheet,action:r};Et(r,{app:t,...f}),t.grid.host.dispatchEvent(new CustomEvent("cellbutton",{bubbles:!0,detail:f}))}if(i)return mt.add(i),t.controller._followLink({location:i}),!0;const l=s??zt(_(a,a.sheet,e,n));return l?(mt.add(l),t.grid.invalidate(),t.controller._followLink({target:l}),!0):(r===void 0&&t.shell.setStatus("This link has no web or mail address to open."),!0)}fitWidth(t,e){return O(e,String(this.options.text??L(t)))+7}}class He extends Y{static typeName="progress";static sanitize(t){const e=n=>Number.isFinite(n)?n:void 0;return{min:e(t.min),max:e(t.max),color:R(t.color),hideText:t.hideText===!0||void 0}}paint(t,e,n,s,i){const r=this.options.min??0,a=this.options.max??1,l=Math.max(1,Math.round(2*i)),f=e.x+l,u=e.y+l,c=e.w-l*2,d=e.h-l*2;if(c<=0||d<=0)return;if(t.fillStyle="#e6e6e6",t.fillRect(f,u,c,d),D(t,s,i),typeof n=="string"&&n.startsWith("#")){B(t,n,f,u,c,d,U(s));return}const h=typeof n=="number"?n:0,m=a>r?Math.max(0,Math.min(1,(h-r)/(a-r))):0;t.fillStyle=this.options.color??M.theme.accent,t.fillRect(f,u,Math.round(c*m),d),this.options.hideText||B(t,`${Math.round(m*100)}%`,f,u,c,d,m>.5?"#ffffff":U(s))}}for(const o of[Pe,We,Be,Ae,Fe,De,$e,He])de(o);const wn=ge();function $(o,t,e){const n=o.cellTypes;if(!n)return null;const s=o.mergeAt(t,e);return n.get(s?I(s.r0,s.c0):I(t,e))??null}const J=(o,t,e,n)=>o.styles.list[t.style(e,n)]??o.styles.list[0];function Dt(o,t,e,n,s,i,r,a,l,f,u,c,d){const h=e.kind(i,r)&yt,m=J(n,e,i,r);h===gt&&(o.fillStyle=m.fill??s.cellBg,o.fillRect(a,l,f-d,u-d));const p=Ct(e,i,r,m);if(p!==null){const w=Math.round(p[0]*c);a+=w,f=Math.max(0,f-w-Math.round(p[1]*c))}o.save(),o.beginPath(),o.rect(a,l,f,u),o.clip(),M.row=i,M.col=r,t.paint(o,{x:a,y:l,w:f,h:u},_(n,e,i,r),m,c,M),o.restore()}function Sn(o,t,e,n,s){const{sheet:i,book:r,theme:a,dpr:l,zoom:f}=t,u=i.cellTypes;M.theme=a,M.book=r,M.sheet=i,M.grid=t,M.printing=!1,M.id++;const{ca:c,cb:d,ra:h,rb:m,s:p,xs:w,ys:y}=n,S=Math.max(1,Math.round(l*Math.min(f,1))),T=s.length>0,C=(g,k,b)=>{if(T&&i.mergeAt(k,b)!==null)return;const v=w[b-c],P=y[k-h],H=w[b-c+1]-v,G=y[k-h+1]-P;H>0&&G>0&&Dt(o,g,i,r,a,k,b,v,P,H,G,p,S)};if(u.size<(d-c+1)*(m-h+1))for(const[g,k]of u){const b=Math.floor(g/16384),v=g-b*16384;b>=h&&b<=m&&v>=c&&v<=d&&C(k,b,v)}else for(let g=h;g<=m;g++)for(let k=c;k<=d;k++){const b=u.get(I(g,k));b!==void 0&&C(b,g,k)}for(const g of s){const k=u.get(I(g.r0,g.c0));if(k===void 0||g.c1<c||g.c0>d)continue;const b=t._rectInPane(g,e,p);Dt(o,k,i,r,a,g.r0,g.c0,b.x,b.y,b.w,b.h,p,S)}}const je={cellBg:"#ffffff",cellInk:"#000000",accent:"#404040"};function Tn(o,t,e,n,s,i,r,a,l){const f=e.cellTypes?.get(I(n,s));return f===void 0?!1:(M.theme=je,M.book=t,M.sheet=e,M.grid=null,M.printing=!0,M.row=n,M.col=s,M.id++,o.save(),o.beginPath(),o.rect(i,r,a,l),o.clip(),f.paint(o,{x:i,y:r,w:a,h:l},_(t,e,n,s),J(t,e,n,s),1,M),o.restore(),M.printing=!1,!0)}function Cn(o,t,e,n,s,i,r){const a=t.cellTypes;if(!(a instanceof Map))return;const l=(f,u)=>{(t.kind(f,u)&yt)===gt&&t.mergeAt(f,u)===null&&r(f,u)};if(a.size<(n-e+1)*(i-s+1))for(const f of a.keys()){const u=Math.floor(f/16384),c=f-u*16384;u>=e&&u<=n&&c>=s&&c<=i&&l(u,c)}else for(let f=e;f<=n;f++)for(let u=s;u<=i;u++)a.has(I(f,u))&&l(f,u)}function xn(o,t,e,n,s){const{book:i}=o,{sheet:r}=i,a=$(r,t,e);if(a===null||a.runsWithoutSelecting!==!0||!a.hitTest(Q(o,t,e),n,s,o.grid.zoom,J(i,r,t,e)))return!1;const l=r.mergeAt(t,e);return a.activate(o,l?l.r0:t,l?l.c0:e,n,s),!0}function vn(o,t,e,n,s){const{book:i}=o,{sheet:r}=i;if(V(r,i)&&Ce(o,t,e,n,s))return!0;const a=r.cellTypes?$(r,t,e):null;if(a===null||!a.hitTest(Q(o,t,e),n,s,o.grid.zoom,J(i,r,t,e)))return!1;const l=r.mergeAt(t,e);return a.activate(o,l?l.r0:t,l?l.c0:e,n,s),!0}function _n(o,t,e,n,s){const{book:i}=o,{sheet:r}=i;if(V(r,i)&&ke(o,t,e,n,s))return"pointer";if(!r.cellTypes)return null;const a=$(r,t,e),l=a?.tooltip,{host:f}=o.grid;return l!==void 0?f.title=l:f.title!==""&&(f.title=""),a!==null&&a.hitTest(Q(o,t,e),n,s,o.grid.zoom,J(i,r,t,e))?"pointer":null}function En(o,t){const{sheet:e}=o.book,n=V(e,o.book);if(!e.cellTypes&&!e.cellDropdowns&&!n)return!1;const s=o.grid.selection,{row:i,col:r}=s,a=t.metaKey||t.ctrlKey||t.shiftKey;if(t.altKey&&!a&&n&&/^Digit[1-9]$/.test(t.code)&&xe(o,i,r,Number(t.code[5])-1))return!0;if(t.key==="ArrowDown"&&t.altKey&&!a){if(Tt(o,i,r)||n&&Me(o,i,r))return!0;const l=$(e,i,r);return l&&l.opensList?l.activate(o,i,r,null,null):!1}if((t.key==="Delete"||t.key==="Backspace")&&!a&&!t.altKey&&e.cellTypes&&Ke(o))return!0;if(t.key===" "&&!a&&!t.altKey){const l=$(e,i,r);if(l===null)return!1;const f=e.mergeAt(i,r);return l.activate(o,f?f.r0:i,f?f.c0:r,null,null)}return!1}function Ke(o){const{book:t,grid:e}=o,{sheet:n}=t,s=e.selection.ranges,i=[];for(const[a,l]of n.cellTypes){if(l?.constructor?.typeName!=="checkbox")continue;const f=Math.floor(a/16384),u=a%16384;s.some(c=>f>=c.r0&&f<=c.r1&&u>=c.c0&&u<=c.c1)&&i.push([f,u])}if(i.length===0)return!1;const r=i.filter(([a,l])=>vt(_(t,n,a,l)));return r.length?t.transact("entry",a=>{for(const[l,f]of r)t.setInput(a,l,f,"FALSE")}):Qt(t,"Clear",()=>{Vt(t,i.map(([a,l])=>({r0:a,c0:l,r1:a,c1:l})),"cellTypes",null),t.clearRange(s)}),e.invalidate(),o.controller?.syncFormulaBar?.(),!0}function Rn(o,t,e){const{sheet:n}=o.book;if(!n.cellTypes)return!1;const s=$(n,t,e);return s===null||!s.blocksEditing?!1:(o.controller.focusGrid(),s.opensList?s.activate(o,t,e,null,null):o.shell.setStatus("This cell holds a control. Click it or press Space to change it."),!0)}function zn(o,t,e){const{book:n}=o,s=$(n.sheet,t,e);return s===null?void 0:s.editText(_(n,n.sheet,t,e))}function In(o,t,e,n){const s=$(o.book.sheet,t,e);return s===null?n:s.parseEdit(n)}function Ln(o,t,e,n,s){const i=o.cellTypes?.get(I(e,n)),r=J(t,o,e,n);let a=s;if(i!==void 0){M.book=t,M.sheet=o,M.row=e,M.col=n;const f=i.fitWidth(_(t,o,e,n),r);f>0&&(a=f-7)}const l=Ct(o,e,n,r);return l===null?a:a+l[0]+l[1]}function On(o){Ot(o),o.grid.host.addEventListener("pointerleave",()=>{V(o.book.sheet,o.book)&&Lt(o,null,0,0)})}function Pn(o,t){const e=[];for(const n of[o.cellTypes,o.cellButtons])if(n instanceof Map)for(const s of n.keys())s%16384===t&&e.push(Math.floor(s/16384));return e}const Wn=(o,t)=>Yt(o,t);function Xe(o,t,e){const n=o.lastIndexOf("!");return n<0||o.slice(0,n).replace(/^'|'$/g,"").replace(/''/g,"'").toLowerCase()!==t.toLowerCase()?o:`${jt(e)}${o.slice(n)}`}function $t(o,t,e){let n=null;for(const s of["source","location"]){if(typeof o[s]!="string")continue;const i=Xe(o[s],t,e);i!==o[s]&&((n??={...o})[s]=i)}return n}Xt.push((o,t,e)=>{const n=new Map,s=(r,a,l)=>{const f=r[a];if(!(f instanceof Map))return;let u=null;for(const[c,d]of f){n.has(d)||n.set(d,l(d));const h=n.get(d);h!==d&&(u??=new Map(f)).set(c,h)}u!==null&&(r[a]=u,r.cellTypesChanged=!0)},i=r=>{const a=$t(r,t,e);return a===null?r:St(r.type,a)};for(const r of o.sheets)s(r,"cellTypes",a=>{const l=$t(a.options,t,e);return l===null?a:_t(a.type,l)}),s(r,"cellDropdowns",i),s(r,"cellButtons",a=>{const l=a.map(f=>{if(!f.dropdown||f.dropdown===!0)return f;const u=i(f.dropdown);return u===f.dropdown?f:{...f,dropdown:u}});return l.some((f,u)=>f!==a[u])?It(l):a})});function Ye(o){o.sort((i,r)=>i%16384-r%16384||i-r);const t=[];let e=-1,n=-1;const s=()=>{if(e<0)return;const i=Math.floor(e/16384),r=e-i*16384,a=Math.floor(n/16384);t.push(Kt({r0:i,c0:r,r1:a,c1:r}))};for(const i of o)e>=0&&i===n+16384||(s(),e=i),n=i;return s(),t}function pt(o,t,e){if(!o||o.size===0)return;const n=new Map;for(const[s,i]of o){const r=Jt(i);let a=n.get(r);a===void 0&&(a=[],n.set(r,a)),a.push(s)}for(const[s,i]of n)e.push({kind:t,json:s,keys:i})}function Ue(o){const t=[];if(pt(o.cellTypes,"type",t),pt(o.cellDropdowns,"dropdown",t),pt(o.cellButtons,"buttons",t),t.length===0)return null;const e=t.map(n=>`<entry kind="${n.kind}" config="${wt(n.json)}" ref="${Ye(n.keys).join(" ")}"/>`).join("");return`<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
2
+ <cellTypes xmlns="${ne}" version="1" sheet="${wt(o.name)}">${e}</cellTypes>`}function Je(o,t){let e;try{e=kt(new TextEncoder().encode(o))}catch{return}if(e?.n!=="cellTypes")return;const n=new Map,s=new Map,i=new Map;let r=0;for(const a of Ut(e,"entry")){let l;try{l=JSON.parse(Mt(a.a.config??""))}catch{continue}if(l===null||typeof l!="object")continue;const{kind:f}=a.a;let u;if(f==="dropdown"?u=St(l.type,l):f==="buttons"?u=It(l):u=xt(l),u===null)continue;const c=f==="dropdown"?s:f==="buttons"?i:n;for(const d of String(a.a.ref??"").split(/\s+/)){const h=bt(d);if(h)for(let m=h.r0;m<=h.r1&&r<Pt;m++)for(let p=h.c0;p<=h.c1&&r<Pt;p++)c.set(I(m,p),u),r++}}t.cellTypes=n.size>0?n:null,t.cellDropdowns=s.size>0?s:null,t.cellButtons=i.size>0?i:null}const Ge=o=>{for(const t of o.formulas.descriptors())if(t.cm||t.tpl?.mayArray)return!0;return!1};function Bn(o){const t=[];return o.sheets.forEach((e,n)=>{const s=Ue(e);s!==null&&t.push(te(n,s))}),t.push(...ie(o),...ve(o),...re(o),...fe(o),...ce(o,o.sheets.some(e=>Ge(e)))),t}async function An(o,t){const e=await Gt(o);for(const{text:n}of await oe(e)){if(n.includes(ee)){se(n,t);continue}let s=null;try{s=kt(new TextEncoder().encode(n))}catch{continue}const i=Mt(s?.a?.sheet),r=t.sheets.find(a=>a.name===i);r&&Je(n,r)}await Ht(e,t),await le(e,t),await ae(e,t),await ue(e,t)}export{wn as CELL_TYPE_NAMES,On as attachCellEvents,Ot as attachFileDrop,qt as cellDropdownArrow,Ln as cellFitWidth,I as cellKey,$ as cellTypeAt,Rn as cellTypeBlocksEdit,_n as cellTypeCursor,zn as cellTypeEditText,In as cellTypeParseEdit,Bn as cellTypesPackage,Zt as closeDropdown,Pn as fitRowsOfColumn,vn as handleCellClick,En as handleCellKey,V as hasCellButtons,_e as hideEditingButtons,An as loadCellTypes,_t as makeCellType,Tt as openCellDropdown,we as paintCellButtons,Sn as paintCellTypes,Se as paintFloatingButtons,Te as paintStyleButtons,Je as parse,xn as pressWithoutSelecting,Tn as printCellType,Cn as printEmptyTypedCells,ye as registerButtonAction,be as registerCellType,Ue as serialize,Wn as shiftCellTypes,Ee as showEditingButtons,Lt as trackButtonHover};
@@ -0,0 +1 @@
1
+ import{EMPTY as B,KIND_MASK as J}from"../core/sheet.js";import{tablesOf as L}from"../core/tables.js";import{canWriteCell as W,closeDropdown as P,commit as D,footer as E,literalInput as A,make as c,openPopup as M,readCellValue as V,writeCell as F}from"./dropdowns.js";import{CellType as I,controlRect as K,defineCellType as Y,formatted as _,frame as Z,inkOf as G,inRect as H,labelOf as U,leftText as $,parseJsonCached as C,safeText as O,setFont as q,textWidth as Q}from"./base.js";import{drawGlyph as X}from"./glyphs.js";import{t as p}from"../i18n/index.js";const v=n=>n!==null&&typeof n=="object"&&!Array.isArray(n);function tt(n){const t=[],e=/"([^"]*)"|\[(\d+)\]|([^.[\]"]+)/g;let r;for(;(r=e.exec(n))!==null;)t.push(r[1]??r[2]??r[3]);return t}function j(n,t){let e=n;for(const r of tt(t)){if(e===null||typeof e!="object"||!Object.prototype.hasOwnProperty.call(e,r))return;e=e[r]}return e}const et=/@\.((?:[A-Za-z_][\w]*|"[^"]*")(?:\.(?:[A-Za-z_][\w]*|"[^"]*"))*)/g;function nt(n){return n.slice(1).split(/("(?:[^"]|"")*")/).map((t,e)=>e%2===1?t:t.replace(et,(r,i)=>`PROPERTY(A1,"${i.replace(/"/g,'""')}")`).replace(/@/g,"A1")).join("")}function rt(n,t,e,r,i){const{engine:s}=n;if(!s)return null;const a=s.template(nt(i),0,0);if(a.invalid)return null;let o;try{o=a.fn(e,r,t),o&&o.sheet&&(o=o.isCell?s.read(o.sheet,o.r0,o.c0):s.toArr(o)),o&&o.data&&(o=o.data[0])}catch(h){o=h}return o??""}const T=n=>n==null?"":typeof n=="object"?JSON.stringify(n):String(U(n));function ot(n,t){return n.replace(/\{([^{}]+)\}/g,(e,r)=>T(j(t,r.trim())))}const it=n=>typeof n=="string"?n:JSON.stringify(n);function N(n){const t=n.trim();if(t==="true"||t==="false"||t==="null"||/^-?\d/.test(t)||t.startsWith("{")||t.startsWith("[")||t.startsWith('"'))try{return JSON.parse(t)}catch{return n}return n}function st(n,t,e,r){const{book:i}=n,{sheet:s}=i;return(s.kind(t,e+1)&J)!==B||s.mergeAt(t,e+1)!==null||L(i,s).some(o=>t>=o.r0&&t<=o.r1&&e+1>=o.c0&&e+1<=o.c1)?(n.shell.setStatus("Can't put the value there: the next cell isn't empty, or it's merged or part of a table."),!1):F(n,t,e+1,A(T(r)))}function at(n,t,e){const{book:r}=n,{sheet:i}=r,s=V(r,i,t,e),a=C(s),o=v(a)?a:{},h=s!==null&&s!==""&&!v(a),u=W(n,t,e);M(n,t,e,"Properties",m=>{const x=c("div");x.style.cssText="display:grid;grid-template-columns:110px 170px auto auto;gap:3px;align-items:center;max-height:320px;overflow:auto";const b=[],k=(l,y)=>{const f=c("input",{type:"text",value:l,ariaLabel:p("Property"),readOnly:!u}),d=c("input",{type:"text",value:y===void 0?"":it(y),ariaLabel:p("Value of {name}",{name:l}),readOnly:!u});f.style.width="100%",d.style.width="100%",f.style.boxSizing="border-box",d.style.boxSizing="border-box";const g={k:f,f:d,nodes:[]},R=c("button",{class:"ct-nav",type:"button",text:"→",title:p("Put this value in the next cell"),ariaLabel:p("Put {name} in the next cell",{name:l}),onclick:()=>{st(n,t,e,N(d.value))&&P()}}),S=c("button",{class:"ct-nav",type:"button",text:"×",title:p("Remove this property"),ariaLabel:p("Remove {name}",{name:l}),onclick:()=>{g.nodes.forEach(z=>z.remove()),b.splice(b.indexOf(g),1)}});return S.disabled=!u,g.nodes=[f,d,R,S],b.push(g),x.append(...g.nodes),f};for(const[l,y]of Object.entries(o))k(l,y);b.length===0&&u&&k("","");const w=()=>{const l={};for(const{k:y,f}of b){const d=y.value.trim();d!==""&&(l[d]=N(f.value))}D(n,t,e,A(JSON.stringify(l)))};if(m.addEventListener("keydown",l=>{l.key==="Enter"&&l.target.tagName==="INPUT"&&u&&(l.preventDefault(),w())}),h&&m.append(c("div",{class:"ct-item",text:p("This cell's text isn't a JSON object yet. OK replaces it.")})),m.append(x),u){const l=c("button",{class:"ct-btn",type:"button",text:p("Add"),onclick:()=>k("","").focus()});m.append(E(n,w,l))}else m.append(c("div",{class:"ct-foot"},c("button",{class:"ct-btn",type:"button",text:p("Close"),onclick:()=>P()})));return b[0]?.f??m})}class lt extends I{static typeName="dataobject";static sanitize(t){return{property:O(t.property,200),template:O(t.template,500),format:O(t.format,500),hideButton:t.hideButton===!0||void 0}}get opensList(){return!0}_text(t,e,r){const i=C(t);if(!v(i))return _(t,e);const{format:s}=this.options;if(s!==void 0&&s[0]==="="&&r?.book){const a=rt(r.book,r.sheet,r.row,r.col,s);if(a!==null)return typeof a=="number"||typeof a=="boolean"?_(a,e):String(a)}return this.options.template!==void 0?ot(this.options.template,i):this.options.property!==void 0?T(j(i,this.options.property)):t}_button(t,e){const r=Math.min(16*e,t.h);return{x:t.x+t.w-r,y:t.y+(t.h-r)/2,w:r,h:r}}paint(t,e,r,i,s,a){const h=a?.printing===!0||this.options.hideButton===!0,u=this._button(e,s);q(t,i,s),t.save(),t.beginPath(),t.rect(e.x,e.y,h?e.w:e.w-u.w,e.h),t.clip(),$(t,String(this._text(r,i,a)),e.x+Math.round(2*s),e.y,e.h,G(i)),t.restore(),h||X(t,"ellipsis",u.x+u.w*.1,u.y+u.h*.1,u.w*.8,"#3c3c3c")}hitTest(t,e,r,i=1){return this.options.hideButton===!0?null:H(this._button(t,i),e,r)?{part:"details"}:null}activate(t,e,r,i,s){return i!=null&&!this.hitTest(K(t,e,r),i,s,t.grid.zoom)?!1:(at(t,e,r),!0)}fitWidth(t,e){return Q(e,String(this._text(t,e,Z)))+7+(this.options.hideButton?0:16)}}Y(lt);export{lt as DataObjectCell,ot as fillTemplate,nt as formulaFormatText,j as pathValue};
@@ -0,0 +1 @@
1
+ import{cellKey as $,clipRange as J,MAX_APPLY_CELLS as R,swapMap as X}from"./dropdowns.js";import{CellType as Y,defineCellType as j,inkOf as F,labelOf as I,makeCellType as H,oneOf as _,paintPlain as K,parseJsonCached as V,safeColor as q,setFont as G,textWidth as Q}from"./base.js";const b=10,U=["thin","medium","thick","hair","dotted","dashed","dashDot","mediumDashed"];function k(o){if(o==null)return[];if(typeof o=="string"&&o.startsWith("[")){const a=V(o);if(Array.isArray(a))return a.slice(0,b).map(s=>String(I(s)))}const t=String(I(o));return t===""?[]:t.split(",").slice(0,b).map(a=>a.trim())}const Z=o=>o.some(t=>t.includes(","))?JSON.stringify(o):o.join(",");function v(o,t,a){const{x:s,y:e,w:n,h:i}=o;if(t===2)return[a?[s+n,e+i]:[s+n,e]];if(t===3)return a?[[s+n,e+i*2/3],[s+n*2/3,e+i]]:[[s+n*2/3,e],[s+n,e+i/3]];const r=n+i,c=[];for(let f=1;f<t;f++){const l=r*f/t;a?c.push(l<=i?[s+n,e+l]:[s+n-(l-i),e+i]):c.push(l<=n?[s+l,e]:[s+n,e+(l-n)])}return c}function x(o,t,a){const s=t.split(/\s+/),e=[];let n="";for(const i of s){const r=n===""?i:`${n} ${i}`;n!==""&&o.measureText(r).width>a?(e.push(n),n=i):n=r}return e.push(n),e}function tt(o,t,a,s,e,n,i,r){const c=Math.max(1,Math.round(r));o.strokeStyle=n,o.lineWidth=(i==="thick"?3:i.startsWith("medium")?2:1)*c,o.setLineDash(i==="dotted"||i==="hair"?[c,c]:/dash/i.test(i)?[3*c,2*c]:[]),o.beginPath(),o.moveTo(t,a),o.lineTo(s,e),o.stroke(),o.setLineDash([])}class et extends Y{static typeName="diagonal";static sanitize(t){return{direction:_(t.direction,["up"]),color:q(t.color),lineStyle:_(t.lineStyle,U)}}realBorder(){const t=this.options.direction==="up";return{d:{style:this.options.lineStyle??"thin",color:this.options.color??"#000000"},up:t,down:!t}}paint(t,a,s,e,n,i){const r=k(s);if(r.length<2){K(t,a,s,e,n);return}const c=this.options.direction!=="up",{x:f,y:l,w:S,h:m}=a,p=e.borders,d=p?.d&&(c?p.down:p.up);r.length>2&&p?.d&&(t.fillStyle=e.fill??i?.theme?.cellBg??"#ffffff",t.fillRect(f+1,l+1,S-2,m-2));const h=f,M=c?l:l+m,T=v(a,r.length,c),z=this.options.color??"#000000",N=this.options.lineStyle??"thin";if(r.length>2||!d)for(const[w,u]of T)tt(t,h,M,w,u,z,N,n);G(t,e,n),t.fillStyle=F(e),t.textBaseline="middle";const C=Math.round(3*n),D=e.fontSize*1.2*n,P=(w,u,g)=>{const L=x(t,w,S*.66);t.textAlign=u?"right":"left";const y=u?f+S-C:f+C;L.forEach((B,E)=>{const A=g?l+C+D*(E+.5):l+m-C-D*(L.length-E-.5);t.fillText(B,y,A)})},O=(w,u,g,L,y)=>{const B=Math.atan2(y-M,L-h),E=Math.atan2(g-M,u-h),A=(B+E)/2,W=Math.hypot((u+L)/2-h,(g+y)/2-M);t.save(),t.translate(h+Math.cos(A)*W*.62,M+Math.sin(A)*W*.62),t.rotate(Math.abs(A)>Math.PI/2?A+Math.PI:A),t.textAlign="center",t.fillText(w,0,0),t.restore()};if(r.length<=3)P(r[0],c,!0),P(r[r.length-1],!c,!1),r.length===3&&O(r[1],T[0][0],T[0][1],T[1][0],T[1][1]);else{const w=c?[f+S,l]:[f,l],u=c?[f,l+m]:[f+S,l+m],g=[w,...T,u];r.forEach((L,y)=>O(L,g[y][0],g[y][1],g[y+1][0],g[y+1][1]))}t.textBaseline="alphabetic",t.textAlign="left"}fitWidth(t,a){const s=k(t);if(s.length<2)return 0;let e=12;for(const n of s)e+=Q(a,n);return e}}j(et);function st(o,t,a,s){const{sheet:e}=o,n=H("diagonal",a),i=t.map(l=>J(e,l));let r=0;for(const l of i)r+=(l.r1-l.r0+1)*(l.c1-l.c0+1);if(r>R)return!1;const c=n.realBorder(),f=s&&s.length>0?Z(s):null;return o.transact("cell type",l=>{const S=X("cellTypes",e.cellTypes??null),m=new Map(e.cellTypes??[]);for(const p of i)for(let d=p.r0;d<=p.r1;d++)for(let h=p.c0;h<=p.c1;h++){l.saveCell(d,h);const M=e.cellStyle(d,h),T=o.styles.get(M).borders??{l:null,r:null,t:null,b:null};e.setStyle(d,h,o.styles.derive(M,{borders:{...T,...c}})),f!==null&&o.setInput(l,d,h,f[0]==="["?`'${f}`:f),m.set($(d,h),n)}return e.cellTypes=m,e.cellTypesChanged=!0,S}),!0}export{et as DiagonalCell,U as LINE_STYLES,st as applyDiagonal,k as labelsOf,Z as labelsToValue};
@@ -0,0 +1,13 @@
1
+ import{rangeRef as ee}from"../core/address.js";import{EMPTY as te,KIND_MASK as ne}from"../core/sheet.js";import{getFormatter as Y,partsToSerial as z,serialToParts as re}from"../core/numfmt.js";import{buildCalendar as se,canWriteCell as K,cellSerial as ae,closeDropdown as ie,commit as E,footer as I,literalInput as T,make as b,openListPopup as $,openPopup as O,readCellValue as M,registerDropdownKind as N,setPopupKeepOpen as le,todaySerial as ue}from"./dropdowns.js";import{labelOf as R,parseJsonCached as oe,safeColor as me,safeItems as G,safeNumber as _,safeText as F}from"./base.js";import{t as A}from"../i18n/index.js";const ce=200,V=200;function W(e){if(Number.isFinite(e))return e;if(typeof e!="string")return;const t=/^(\d{4})-(\d{1,2})-(\d{1,2})$/.exec(e);return t?z(Number(t[1]),Number(t[2]),Number(t[3])):void 0}function X(e){if(Number.isFinite(e)&&e>=0&&e<1)return e;if(typeof e!="string")return;const t=/^(\d{1,2}):(\d{2})$/.exec(e);return t&&Number(t[1])<24&&Number(t[2])<60?(Number(t[1])*60+Number(t[2]))/1440:void 0}const D=(e,t,r)=>{r!==void 0&&(e[t]=r)},P=e=>e.separator??", ",q=["cells","text","object"];function H(e,t,r,n,i,u,v,a){const{book:s}=e,{sheet:m}=s,l=n.output??"cells";if(l==="text")return E(e,t,r,T(v));if(l==="object")return E(e,t,r,T(JSON.stringify({start:i,end:u})));const h=(m.kind(t,r+1)&ne)!==te&&B(e,t,r,n)===null;return m.mergeAt(t,r+1)!==null||h?(e.shell.setStatus("The end of the range goes in the next cell, and it isn't empty."),!1):!K(e,t,r,{overFormula:!0})||!K(e,t,r+1)?!1:(s.transact("entry",y=>{if(s.setInput(y,t,r,String(i)),s.setInput(y,t,r+1,String(u)),a)for(const f of[r,r+1])s.styles.get(m.style(t,f)).numFmt==="General"&&m.setStyle(t,f,s.styles.derive(m.style(t,f),{numFmt:a}))}),e.commands?.afterEntry?.(t,r),e.grid.invalidate(),e.controller.syncFormulaBar(),ie(),!0)}function B(e,t,r,n){const{book:i}=e,{sheet:u}=i,v=M(i,u,t,r),a=n.output??"cells";if(a==="cells"){const s=M(i,u,t,r+1);return typeof v=="number"&&typeof s=="number"?[v,s]:null}if(a==="object"&&typeof v=="string"){const s=oe(v);return s&&Number.isFinite(s.start)&&Number.isFinite(s.end)?[s.start,s.end]:null}return null}function U(e,t){const r=R(e);return r===""?[]:String(r).split(P(t).trim()||",").map(n=>n.trim()).filter(Boolean)}function J(e,t){D(t,"minDate",W(e.minDate)),D(t,"maxDate",W(e.maxDate))}function de(e,t,r,n){const i=y=>Y(n.format??"yyyy-mm-dd").number(y),u=n.minDate,v=n.maxDate,a=ue(),s=B(e,t,r,n);let m=s?s[0]:null,l=s?s[1]:null;const h=()=>{if(m===null)return;const y=Math.min(m,l??m),f=Math.max(m,l??m);H(e,t,r,n,y,f,`${i(y)} - ${i(f)}`,n.format??"yyyy-mm-dd")};O(e,t,r,"Date range",y=>{const f=b("div"),k=b("span",{text:A("Pick the first day")});let p;const C=c=>{p=se(c,o=>{m===null||l!==null?(m=o,l=null,k.textContent=A("{start} to …",{start:i(o)})):(l=o,k.textContent=A("{start} to {end}",{start:i(Math.min(m,l)),end:i(Math.max(m,l))})),C(o),p.focusCell?.focus({preventScroll:!0})},void 0,{min:u,max:v,marked:o=>m!==null&&o>=Math.min(m,l??m)&&o<=Math.max(m,l??m)}),f.replaceChildren(p)};C(m??a);const d=re(a),L=z(d.year,d.month,1),g=d.month===1?z(d.year-1,12,1):z(d.year,d.month-1,1),x=d.month===12?z(d.year+1,1,1):z(d.year,d.month+1,1),w=[["Today",a,a],["Yesterday",a-1,a-1],["Last 7 days",a-6,a],["This month",L,x-1],["Last month",g,L-1]];if(n.presets!==!1){const c=b("div",{class:"ct-row"});c.style.flexWrap="wrap",c.style.justifyContent="flex-start",c.style.marginBottom="6px";for(const[o,S,j]of w)c.append(b("button",{class:"ct-btn",type:"button",text:A(o),onclick:()=>{m=S,l=j,h()}}));y.append(c)}return y.append(f,I(e,h,k)),p.focusCell})}N("calendar",{sanitize(e,t){J(e,t),e.range===!0&&(t.range=!0),e.presets===!1&&(t.presets=!1),q.includes(e.output)&&(t.output=e.output)},open(e,t,r,n){return n.range?(de(e,t,r,n),!0):!1}}),N("datetime",{sanitize:J}),N("month",{sanitize(e,t){D(t,"startYear",_(e.startYear,1901,9999)),D(t,"stopYear",_(e.stopYear,1901,9999))}}),N("time",{sanitize(e,t){D(t,"min",X(e.min)),D(t,"max",X(e.max)),D(t,"step",_(e.step,1,720))},open(e,t,r,n){if(n.min===void 0&&n.max===void 0&&n.step===void 0)return!1;const i=(n.step??30)/1440,u=n.min??0,v=n.max??1-1/86400,a=n.format??"h:mm",s=[];for(let h=u,y=0;h<=v+1e-9&&y<1440;h=u+ ++y*i)s.push({text:Y(a).number(h),value:String(h)});const m=ae(e,t,r),l=m===null?-1:s.findIndex(h=>Math.abs(Number(h.value)-m%1)<1/86400);return $(e,t,r,{items:s,selected:l>=0?[s[l].value]:[],label:"Time",maxItems:12,onDone:([h])=>(h!==void 0&&E(e,t,r,h,{format:a}),!1)}),!0}}),N("color",{sanitize(e,t){if(Array.isArray(e.palette)){const r=e.palette.slice(0,200).map(me).filter(Boolean);r.length>0&&(t.palette=Object.freeze(r))}(e.target==="fill"||e.target==="font")&&(t.target=e.target)}});function fe(e,t,r,n){const i=n.min??0,u=n.max??100,v=n.step??1,{book:a}=e,s=M(a,a.sheet,t,r);O(e,t,r,"Slider",m=>{let l;n.marks&&(l=`ct-marks-${Math.random().toString(36).slice(2)}`,m.append(b("datalist",{id:l},...n.marks.map(c=>b("option",{value:String(c),label:String(c)})))));const h=(c,o)=>{const S=b("input",{type:"range",min:i,max:u,step:v,value:String(c),ariaLabel:A(o)});return l&&S.setAttribute("list",l),n.vertical&&(S.style.writingMode="vertical-lr",S.style.direction="rtl",S.style.width="24px",S.style.height="180px",S.style.display="inline-block"),S},y=typeof s=="string"?/^\s*(-?[\d.]+)\s*-\s*(-?[\d.]+)\s*$/.exec(s):null,f=n.range?B(e,t,r,n):null,k=f?f[0]:y?Number(y[1]):typeof s=="number"?s:i,p=h(k,n.range?"From":"Value"),C=n.range?h(f?f[1]:y?Number(y[2]):u,"To"):null,d=b("span",{class:"ct-value"}),L=()=>{const c=Number(p.value);if(C===null)return[c];const o=Number(C.value);return[Math.min(c,o),Math.max(c,o)]},g=()=>{d.textContent=L().join(" - ")};p.addEventListener("input",g),C?.addEventListener("input",g),g();const x=()=>{if(C===null)return E(e,t,r,p.value);const[c,o]=L();return H(e,t,r,n,c,o,`${c} - ${o}`,null)};m.addEventListener("keydown",c=>{c.key==="Enter"&&c.target.tagName==="INPUT"&&(c.preventDefault(),x())});const w=b("div",{},p,C);return n.vertical&&(w.style.display="flex"),m.append(w,I(e,x,d)),p})}N("slider",{sanitize(e,t){if(Array.isArray(e.marks)){const r=e.marks.slice(0,100).filter(Number.isFinite);r.length>0&&(t.marks=Object.freeze(r))}e.vertical===!0&&(t.vertical=!0),e.range===!0&&(t.range=!0),q.includes(e.output)&&(t.output=e.output)},open(e,t,r,n){return!n.marks&&!n.vertical&&!n.range?!1:(fe(e,t,r,n),!0)}});const pe=500,he=5;function Q(e,t=0,r={left:pe}){if(!Array.isArray(e))return[];const n=[];for(const i of e){if(r.left--<=0)break;if(i!==null&&typeof i=="object"&&Array.isArray(i.items)&&t<he)n.push(Object.freeze({text:F(i.text??i.value)??"",items:Q(i.items,t+1,r)}));else{const[u]=G([i]);n.push(u)}}return Object.freeze(n)}const Z=(e,t=[])=>{for(const r of e)r.items?Z(r.items,t):t.push(r);return t},ye=`
2
+ .ct-menus { display: flex; align-items: flex-start; gap: 2px; }
3
+ .ct-menus .ct-list { min-width: 120px; }
4
+ .ct-menus .ct-item { cursor: default; }
5
+ .ct-item .ct-arrow { margin-left: auto; padding-left: 12px; }
6
+ .ct-item.ct-open { background: var(--hover); }
7
+ `;function ve(e,t,r,n){document.getElementById("ct-menu-style")||document.head.append(b("style",{id:"ct-menu-style",textContent:ye}));const{book:i}=e,u=M(i,i.sheet,t,r),v=U(u,n).map(s=>s.toLowerCase()),a=new Set(Z(n.items).filter(s=>v.includes(String(s.value).toLowerCase())||String(s.value).toLowerCase()===String(R(u)).toLowerCase()).map(s=>s.value));O(e,t,r,"List",s=>{const m=b("div",{class:"ct-menus"}),l=[],h=()=>E(e,t,r,T([...a].join(P(n)))),y=(d,L,g)=>{for(;l.length>d+1;)l.pop().node.remove();const x=l[d];x.lines.forEach((c,o)=>c.classList.toggle("ct-open",o===L&&!!x.items[o].items));const w=x.items[L];w?.items&&p(w.items,g)},f=(d,L,g=!0)=>{d.lines[d.cursor]?.classList.remove("ct-cursor"),d.cursor=L,d.lines[L]?.classList.add("ct-cursor"),g&&d.lines[L]?.scrollIntoView({block:"nearest"})},k=(d,L)=>{const g=l[d],x=g.items[L];if(x.items){y(d,L,!0);return}if(!x.disabled){if(!n.multi){a.clear(),a.add(x.value),h();return}a.has(x.value)?a.delete(x.value):a.add(x.value),g.lines[L].querySelector(".ct-mark").textContent=a.has(x.value)?"✓":""}};function p(d,L){const g=l.length,x=b("div",{class:"ct-list",role:"menu",tabIndex:0}),w=d.map((o,S)=>{const j=b("div",{class:"ct-item",role:o.items?"menuitem":n.multi?"menuitemcheckbox":"menuitem",onclick:()=>k(g,S),onpointerenter:()=>{f(l[g],S,!1),y(g,S,!1)}},b("span",{class:"ct-mark",text:!o.items&&a.has(o.value)?"✓":""}),b("span",{text:o.text}),o.items?b("span",{class:"ct-arrow",text:"›"}):null);return o.items&&j.setAttribute("aria-haspopup","true"),o.disabled&&(j.style.opacity="0.5"),x.append(j),j}),c={items:d,lines:w,cursor:0,node:x};return l.push(c),m.append(x),f(c,0,!1),x.addEventListener("keydown",o=>{const S={ArrowUp:c.cursor-1,ArrowDown:c.cursor+1,Home:0,End:d.length-1}[o.key];if(S!==void 0)o.preventDefault(),f(c,Math.max(0,Math.min(d.length-1,S))),y(g,c.cursor,!1);else if(o.key==="ArrowRight")o.preventDefault(),d[c.cursor]?.items&&y(g,c.cursor,!0);else if(o.key==="ArrowLeft"){if(o.preventDefault(),g>0){for(;l.length>g;)l.pop().node.remove();l[g-1].node.focus({preventScroll:!0})}}else(o.key===" "||o.key==="Enter")&&(o.preventDefault(),n.multi&&o.key==="Enter"&&!d[c.cursor]?.items?h():k(g,c.cursor))}),L&&x.focus({preventScroll:!0}),x}const C=p(n.items,!1);return s.append(m),n.multi&&s.append(I(e,h)),C})}N("list",{sanitize(e,t){Array.isArray(e.items)&&(t.items=Q(e.items)),e.multi===!0&&(t.multi=!0),D(t,"separator",F(e.separator,16)),e.filter===!0&&(t.filter=!0),Array.isArray(e.widths)&&(t.widths=Object.freeze(e.widths.slice(0,50).map(r=>_(r,10,1e3)??0)))},open(e,t,r,n){if(!n.items)return!1;if(n.items.some(s=>s.items))return ve(e,t,r,n),!0;const{book:i}=e,u=M(i,i.sheet,t,r),v=U(u,n).map(s=>s.toLowerCase()),a=n.items.filter(s=>v.includes(String(s.value).toLowerCase())||!n.multi&&String(s.value).toLowerCase()===String(R(u)).toLowerCase()).map(s=>s.value);return $(e,t,r,{items:n.items,selected:a,multi:n.multi===!0,label:"List",moveOnSide:!n.multi,onDone:s=>((n.multi||s.length>0)&&E(e,t,r,T(s.join(P(n)))),!1)}),!0}}),N("workflow",{sanitize(e,t){const r=Array.isArray(e.items)?e.items.slice(0,ce):[];t.items=Object.freeze(r.map(n=>{const i=n!==null&&typeof n=="object"?n:{value:n},u=F(i.value??i.text)??"",v={value:u,text:F(i.text??i.value)??u};return Array.isArray(i.transitions)&&(v.transitions=Object.freeze(i.transitions.filter(a=>Number.isInteger(a)&&a>=0&&a<r.length))),Object.freeze(v)}))},open(e,t,r,n){const{book:i}=e,u=String(R(M(i,i.sheet,t,r))).toLowerCase(),v=n.items.findIndex(s=>s.value.toLowerCase()===u),a=v>=0&&n.items[v].transitions?n.items[v].transitions.map(s=>n.items[s]):n.items;return $(e,t,r,{items:a,selected:[],label:"Next state",onDone:([s])=>(s!==void 0&&E(e,t,r,T(s)),!1)}),!0}});const be=`
8
+ .ct-tags { display: flex; flex-wrap: wrap; gap: 3px; width: 260px; align-items: center; }
9
+ .ct-tag { display: inline-flex; align-items: center; gap: 3px; padding: 1px 2px 1px 7px; border-radius: 10px; background: var(--hover); }
10
+ .ct-popup button.ct-tag-x { width: 16px; height: 16px; border-radius: 8px; line-height: 14px; }
11
+ .ct-tags input { flex: 1; min-width: 80px; }
12
+ .ct-suggest { max-height: 140px; overflow: auto; margin-top: 6px; }
13
+ `;function xe(){if(document.getElementById("ct-tag-style"))return;const e=document.createElement("style");e.id="ct-tag-style",e.textContent=be,document.head.append(e)}N("tags",{sanitize(e,t){t.items=Object.freeze(G(e.items).map(r=>r.value)),e.closed===!0&&(t.closed=!0),D(t,"separator",F(e.separator,16))},open(e,t,r,n){const{book:i}=e,u=U(M(i,i.sheet,t,r),n).slice(0,V);return xe(),O(e,t,r,"Tags",v=>{const a=b("div",{class:"ct-tags"}),s=b("input",{type:"text",placeholder:A("Add a tag"),ariaLabel:A("New tag")}),m=b("div",{class:"ct-suggest",role:"listbox",ariaLabel:A("Suggestions")}),l=k=>u.some(p=>p.toLowerCase()===k.toLowerCase()),h=()=>{for(;a.firstChild!==s&&a.firstChild!==null;)a.firstChild.remove();a.firstChild===null&&a.append(s);for(const p of u.map((C,d)=>b("span",{class:"ct-tag"},b("span",{text:C}),b("button",{class:"ct-tag-x",type:"button",text:"×",ariaLabel:A("Remove {name}",{name:C}),onclick:()=>{u.splice(d,1),h(),s.focus()}}))))a.insertBefore(p,s);const k=s.value.trim().toLowerCase();m.replaceChildren(...n.items.filter(p=>!l(p)&&p.toLowerCase().includes(k)).slice(0,50).map(p=>b("div",{class:"ct-item",role:"option",text:p,onclick:()=>{y(p),s.focus()}})))};function y(k){const p=k.trim();return p===""||l(p)||u.length>=V?!1:(u.push(p),s.value="",h(),!0)}const f=()=>E(e,t,r,T(u.join(P(n))));return s.addEventListener("input",h),s.addEventListener("keydown",k=>{if(k.key==="Enter"){k.preventDefault();const p=s.value.trim();p===""?f():(!n.closed||n.items.some(C=>C.toLowerCase()===p.toLowerCase()))&&y(p)}else k.key==="Backspace"&&s.value===""&&u.length>0&&(u.pop(),h())}),h(),v.append(a,m,I(e,f)),s}),!0}}),N("rangepicker",{sanitize(e,t){e.formula===!0&&(t.formula=!0)},open(e,t,r,n){const{book:i,grid:u,controller:v}=e,a=M(i,i.sheet,t,r),s=typeof a=="string"?a.replace(/^=/,""):"";return O(e,t,r,"Range",m=>{const l=b("input",{type:"text",value:s,placeholder:A("Select cells on the sheet"),ariaLabel:A("Range")});l.style.width="220px";const h=()=>{const f=l.value.trim();document.removeEventListener("pointerup",y,!0),v.moveTo(t,r),f===""?E(e,t,r,""):E(e,t,r,n.formula?`=${f}`:T(f))};function y(f){u.host.contains(f.target)&&requestAnimationFrame(()=>{l.value=u.selection.ranges.map(k=>ee(k)).join(","),l.focus({preventScroll:!0})})}return document.addEventListener("pointerup",y,!0),le(f=>u.host.contains(f.target),()=>document.removeEventListener("pointerup",y,!0)),l.addEventListener("keydown",f=>{f.key==="Enter"&&(f.preventDefault(),h())}),m.append(l,I(e,h)),l}),!0}});
@@ -0,0 +1,42 @@
1
+ import{overlayRoot as rt}from"../api/overlay.js";import{BOOL as ot,EMPTY as at,ERR as st,ERRORS as lt,FORMULA as it,KIND_MASK as V,NUM as ct,STR as ut}from"../core/sheet.js";import{MAX_COLS as dt,MAX_ROWS as pt,parseRangeRef as ft}from"../core/address.js";import{partsToSerial as I,serialToParts as R}from"../core/numfmt.js";import{validateEntry as mt,validationAt as ht}from"../core/cond-format.js";import{parseInput as xt}from"../core/input.js";import{askAboutInvalid as yt}from"../cells/validation-alert.js";import{t as C}from"../i18n/index.js";const P=(e,t)=>e*16384+t,W=["calendar","time","month","datetime","color","slider","calculator","list"],K=new Map;function Xt(e,t){W.includes(e)||W.push(e),K.set(e,t)}const gt=2e5,j=5e3,B={calendar:"yyyy-mm-dd",time:"h:mm:ss",month:"mmm yyyy",datetime:"yyyy-mm-dd h:mm:ss"};function U(e,t,n,a){const r=t.kind(n,a)&V;if(r===at)return null;const o=t.value(n,a);return r===ct?o:r===ut?e.strings.get(o):r===ot?o!==0:r===st?lt[o]??"#N/A":null}function vt(e){const t=String(e??"");return t[0]==="="||t[0]==="'"?`'${t}`:t}function H(e,t,n,{overFormula:a=!1}={}){const{book:r}=e,{sheet:o}=r;return e.loading?!1:o.protection&&!r.styles.get(o.style(t,n)).unlocked?(e.shell.setStatus("This cell is on a protected sheet. Unprotect the sheet to change it."),!1):!a&&(o.kind(t,n)&it)!==0?(e.shell.setStatus("This cell's value comes from a formula, so this control can't change it."),!1):!0}function bt(e,t,n,a,r){const{book:o}=e,{sheet:u}=o,i=ht(u,t,n);if(!i||!i.showError)return!0;const l=xt(a);if(mt(o,u,i,t,n,l.kind??0,l.value,a))return!0;const s=()=>{};return yt(e,i,{retry:s,cancel:s,accept:i.errorStyle==="warning"||i.errorStyle==="information"?r:s}),!1}function kt(e,t,n,a,{format:r,overFormula:o=!1}={}){return!H(e,t,n,{overFormula:o})||!bt(e,t,n,a,()=>q(e,t,n,a,r))?!1:q(e,t,n,a,r)}function q(e,t,n,a,r){const{book:o,grid:u,controller:i}=e,l=o.sheet;return o.transact("entry",s=>{o.setInput(s,t,n,a),r&&o.styles.get(l.style(t,n)).numFmt==="General"&&l.setStyle(t,n,o.styles.derive(l.style(t,n),{numFmt:r}))}),e.commands?.afterEntry?.(t,n),u.invalidate(),i.syncFormulaBar(),!0}const G=(e,t)=>n=>{const a=G(e,n[e]??null);return n[e]=t,n.cellTypesChanged=!0,a};function wt(e,{r0:t,c0:n,r1:a,c1:r}){const o=t===0&&a===pt-1,u=n===0&&r===dt-1;return{r0:t,c0:n,r1:o?Math.max(e.maxRow,999):a,c1:u?Math.max(e.maxCol,25):r}}function Jt(e,t,n,a){const r=e.sheet,o=t.map(i=>wt(r,i));let u=0;for(const i of o)u+=(i.r1-i.r0+1)*(i.c1-i.c0+1);return u>gt?!1:(e.transact("cell type",()=>{const i=G(n,r[n]??null),l=new Map(r[n]??[]);for(const s of o)for(let x=s.r0;x<=s.r1;x++)for(let y=s.c0;y<=s.c1;y++)a===null?l.delete(P(x,y)):l.set(P(x,y),a);return r[n]=l.size>0?l:null,r.cellTypesChanged=!0,i}),!0)}function Qt(e,t={}){if(!W.includes(e))return null;const n={type:e},a=r=>{Number.isFinite(t[r])&&(n[r]=t[r])};return typeof t.format=="string"&&t.format.length<=64&&(n.format=t.format),e==="slider"&&(a("min"),a("max"),a("step")),e==="list"&&(typeof t.source=="string"&&t.source.length<=300&&(n.source=t.source),Number.isInteger(t.valueColumn)&&t.valueColumn>=0&&(n.valueColumn=t.valueColumn),Array.isArray(t.columns)&&(n.columns=t.columns.slice(0,50).map(r=>String(r).slice(0,200))),Array.isArray(t.rows)&&(n.rows=t.rows.slice(0,j).filter(Array.isArray).map(r=>r.slice(0,50).map(o=>typeof o=="number"?o:String(o).slice(0,1e3))))),K.get(e)?.sanitize?.(t,n),Object.freeze(n)}function X(e,t,n){const a=e.cellDropdowns;if(!a)return null;const r=e.mergeAt(t,n);return a.get(r?P(r.r0,r.c0):P(t,n))??null}function Zt(e){const{sheet:t,sel:n,grid:a}=e;if(!t.cellDropdowns||!X(t,n.row,n.col))return null;const r=a.cellRect(n.row,n.col),o=Math.min(16,r.h);return{x:r.x+r.w+1,y:r.y+r.h-o,size:o}}const J="ct-popup-style",Ct=`
2
+ .ct-popup { position: fixed; z-index: 60; padding: 8px; border-radius: 8px; background: var(--menu); color: var(--ink); border: 1px solid var(--panel-line); box-shadow: var(--shadow); font: 12px -apple-system, BlinkMacSystemFont, "Segoe UI", "Helvetica Neue", Arial, sans-serif; outline: none; max-width: calc(100vw - 16px); }
3
+ .ct-popup button { font: inherit; color: inherit; background: none; border: 0; border-radius: 4px; padding: 0; cursor: default; }
4
+ .ct-popup button:where(:not(.ct-btn)):hover:not(:disabled) { background: var(--hover); }
5
+ .ct-popup button:focus-visible, .ct-popup input:focus-visible, .ct-popup [role="option"]:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
6
+ .ct-popup [role="listbox"] { outline: none; }
7
+ .ct-row { display: flex; align-items: center; justify-content: space-between; gap: 6px; }
8
+ .ct-head { font-weight: 600; flex: 1; text-align: center; }
9
+ .ct-nav { min-width: 24px; height: 24px; }
10
+ .ct-grid { display: grid; gap: 1px; margin-top: 4px; }
11
+ .ct-days { grid-template-columns: repeat(7, 28px); }
12
+ .ct-months { grid-template-columns: repeat(3, 56px); }
13
+ .ct-dow { text-align: center; color: var(--ink-soft); font-size: 11px; height: 20px; line-height: 20px; }
14
+ .ct-cell { height: 26px; text-align: center; }
15
+ .ct-popup button.ct-out { color: var(--ink-off); }
16
+ .ct-popup button.ct-today { box-shadow: inset 0 0 0 1px var(--ink-soft); }
17
+ .ct-popup button.ct-on, .ct-popup button.ct-on:hover { background: var(--accent); color: #fff; }
18
+ .ct-foot { display: flex; justify-content: flex-end; gap: 6px; margin-top: 8px; align-items: center; }
19
+ .ct-popup button.ct-btn { padding: 0 10px; }
20
+ .ct-popup input[type="range"] { width: 220px; display: block; }
21
+ .ct-time { display: flex; align-items: center; gap: 4px; justify-content: center; }
22
+ .ct-time input { width: 52px; text-align: right; }
23
+ .ct-swatches { grid-template-columns: repeat(10, 20px); gap: 2px; }
24
+ .ct-popup button.ct-swatch { width: 20px; height: 20px; border-radius: 2px; border: 1px solid rgba(128, 128, 128, 0.45); }
25
+ .ct-swatch.ct-on { box-shadow: 0 0 0 2px var(--accent); }
26
+ .ct-display { width: 100%; text-align: right; height: 30px; font-size: 16px; font-variant-numeric: tabular-nums; }
27
+ .ct-keys { grid-template-columns: repeat(4, 42px); gap: 3px; margin-top: 6px; }
28
+ .ct-popup button.ct-key { height: 32px; background: var(--hover); }
29
+ .ct-popup button.ct-key:hover { background: var(--pressed); }
30
+ .ct-popup button.ct-wide { grid-column: span 2; }
31
+ .ct-list { max-height: 260px; min-width: 150px; overflow: auto; }
32
+ .ct-table { border-collapse: collapse; }
33
+ .ct-table th { position: sticky; top: 0; text-align: left; font-weight: 600; background: var(--menu); color: var(--ink-soft); padding: 3px 8px; border-bottom: 1px solid var(--panel-line); white-space: nowrap; }
34
+ .ct-table td { padding: 3px 8px; white-space: nowrap; }
35
+ .ct-table tr[role="option"]:hover { background: var(--hover); }
36
+ .ct-table tr[aria-selected="true"], .ct-table tr[aria-selected="true"]:hover { background: var(--accent); color: #fff; }
37
+ .ct-item { display: flex; align-items: center; gap: 6px; padding: 3px 8px; border-radius: 4px; white-space: nowrap; }
38
+ .ct-item:hover { background: var(--hover); }
39
+ .ct-item.ct-cursor { background: var(--pressed); }
40
+ .ct-mark { width: 12px; text-align: center; }
41
+ .ct-value { min-width: 56px; text-align: right; font-variant-numeric: tabular-nums; }
42
+ `;function Dt(){if(document.getElementById(J))return;const e=document.createElement("style");e.id=J,e.textContent=Ct,document.head.append(e)}const f=(e,t={},...n)=>{const a=document.createElement(e);for(const[r,o]of Object.entries(t))r==="class"?a.className=o:r==="text"?a.textContent=o:r.startsWith("aria")||r==="role"?a.setAttribute(r==="role"?r:`aria-${r.slice(4).toLowerCase()}`,o):a[r]=o;return a.append(...n.filter(r=>r!=null)),a};let E=null;const te=()=>E!==null;function ee(e,t){E!==null&&(E.keepOpen=e,E.onClose=t)}function Et(e){E!==null&&(E.mode=e?"float":"confine")}function ne(){E!==null&&E.mode!=="float"&&L(!1)}function L(e=!0){if(E===null)return;const{el:t,app:n,onDocPointer:a,onClose:r}=E;E=null,r?.(),document.removeEventListener("pointerdown",a,!0),t.remove(),e&&n.controller.focusGrid()}function S(e,t,n,a,r){L(!1),Dt(),e.grid.ensureVisible(t,n);const o=f("div",{class:"ct-popup",role:"dialog",ariaLabel:C(a),tabIndex:-1}),u=l=>{!o.contains(l.target)&&!E?.keepOpen?.(l)&&L(!1)};E={el:o,app:e,onDocPointer:u},document.addEventListener("pointerdown",u,!0),o.addEventListener("keydown",l=>{if(l.stopPropagation(),l.key==="Escape")l.preventDefault(),L();else if(l.key==="Tab"){const s=[...o.querySelectorAll('button, input, [tabindex="0"]')].filter(y=>!y.disabled&&y.tabIndex>=0&&y.offsetParent!==null);if(s.length===0)return;const x=s.indexOf(document.activeElement);l.preventDefault(),s[(x+(l.shiftKey?-1:1)+s.length)%s.length].focus()}}),rt().append(o);const i=r(o);return St(e,t,n,o),(i??o).focus({preventScroll:!0}),o}function At(e,t,n){const r=e.bottom-(e.top+t.y+t.h)-2,o=t.y-2,u=n.getBoundingClientRect(),i=u.height<=r||r>=o,l=Math.max(60,i?r:o);if(u.height>l){n.style.maxHeight=`${l}px`,n.style.overflow="auto";const x=n.querySelector(".ct-list");x&&(x.style.maxHeight=`${Math.max(30,l-18)}px`)}const s=Math.min(u.height,l);n.style.top=`${i?e.top+t.y+t.h+2:e.top+t.y-2-s}px`,n.style.left=`${Math.max(e.left,Math.min(e.left+t.x,e.right-u.width))}px`}function St(e,t,n,a){const r=e.grid.host.getBoundingClientRect(),o=e.grid.domRect(e.grid.cellRect(t,n));if(E?.mode==="confine"){At(r,o,a);return}const u=a.getBoundingClientRect(),i=2,l=r.top+o.y+o.h+i,s=l+u.height<=window.innerHeight-8?l:Math.max(8,r.top+o.y-u.height-i);a.style.top=`${s}px`,a.style.left=`${Math.max(8,Math.min(r.left+o.x,window.innerWidth-u.width-8))}px`}function M(e,t,n,a,r){const o=kt(e,t,n,a,{...r,overFormula:!0});return o&&L(),o}const $=(e,t,n=null)=>f("div",{class:"ct-foot"},n,f("button",{class:"ct-btn",type:"button",text:C("Cancel"),onclick:()=>L()}),f("button",{class:"ct-btn ct-primary",type:"button",text:C("OK"),onclick:t})),_=["January","February","March","April","May","June","July","August","September","October","November","December"],Ft=["dow|Su","dow|Mo","dow|Tu","dow|We","dow|Th","dow|Fr","dow|Sa"],N=61;function O(){const e=new Date;return I(e.getFullYear(),e.getMonth()+1,e.getDate())}const Q=e=>{const t=Math.round(e/1e3);return{h:Math.floor(t/3600)%24,m:Math.floor(t/60)%60,s:t%60}};function T(e,t,n){const{book:a}=e,r=U(a,a.sheet,t,n);return typeof r=="number"&&r>=0?r:null}const Lt=(e,t)=>(t===12?I(e+1,1,1):I(e,t+1,1))-I(e,t,1);function Z(e,t,n,{min:a=N,max:r=1/0,marked:o=null}={}){const u=f("div"),i=Math.max(N,a),l=h=>Math.min(r,Math.max(i,h));let s=l(e);const x=e,y=O(),c=h=>{const k=R(s),m=I(k.year,k.month,1),D=m-R(m).weekday,b=d=>{const w=k.year*12+k.month-1+d,A=Math.floor(w/12),F=w%12+1;s=l(I(A,F,Math.min(k.day,Lt(A,F)))),c(h),n?.(s)},v=f("div",{class:"ct-grid ct-days",role:"grid",ariaLabel:`${C(_[k.month-1])} ${k.year}`});for(const d of Ft)v.append(f("div",{class:"ct-dow",text:C(d)}));let g=null;for(let d=0;d<42;d++){const w=D+d;if(w<N){v.append(f("div"));continue}const A=w<i||w>r,F=R(w),Y=w===s,z=f("button",{class:`ct-cell${F.month!==k.month||A?" ct-out":""}${w===y?" ct-today":""}${(o?o(w):Math.floor(x)===w)?" ct-on":""}`,disabled:A,type:"button",text:String(F.day),tabIndex:Y?0:-1,role:"gridcell",ariaLabel:`${F.year}-${String(F.month).padStart(2,"0")}-${String(F.day).padStart(2,"0")}`,onclick:()=>t(w)});Y&&(g=z),v.append(z)}v.addEventListener("keydown",d=>{const w={ArrowLeft:-1,ArrowRight:1,ArrowUp:-7,ArrowDown:7}[d.key];if(w!==void 0)d.preventDefault(),s=l(s+w),c(!0),n?.(s);else if(d.key==="PageUp"||d.key==="PageDown")d.preventDefault(),b((d.key==="PageUp"?-1:1)*(d.shiftKey?12:1));else if(d.key==="Home"||d.key==="End"){d.preventDefault();const A=R(s).weekday;s=l(s+(d.key==="Home"?-A:6-A)),c(!0),n?.(s)}else(d.key==="Enter"||d.key===" ")&&(d.preventDefault(),t(s))});const p=f("div",{class:"ct-row"},f("button",{class:"ct-nav",type:"button",text:"‹",ariaLabel:C("Previous month"),tabIndex:-1,onclick:()=>b(-1)}),f("div",{class:"ct-head",text:`${C(_[k.month-1])} ${k.year}`}),f("button",{class:"ct-nav",type:"button",text:"›",ariaLabel:C("Next month"),tabIndex:-1,onclick:()=>b(1)}));u.replaceChildren(p,v),u.focusCell=g,h&&g?.focus({preventScroll:!0})};return c(!1),u}function tt(e){const t=(i,l,s)=>f("input",{type:"number",min:0,max:l,value:String(s),ariaLabel:C(i),onfocus(){this.select()},onkeydown(x){if(x.key==="ArrowUp"||x.key==="ArrowDown"){x.preventDefault();const y=Number(this.value)+(x.key==="ArrowUp"?1:-1);this.value=String(y>l?0:y<0?l:y)}}}),n=t("Hours",23,e.h),a=t("Minutes",59,e.m),r=t("Seconds",59,e.s),o=f("div",{class:"ct-time"},n,f("span",{text:":"}),a,f("span",{text:":"}),r),u=(i,l)=>Math.max(0,Math.min(l,Math.trunc(Number(i.value))||0));return{wrap:o,first:n,read:()=>(u(n,23)*3600+u(a,59)*60+u(r,59))/86400}}function Mt(e,t,n,a){const r=T(e,t,n)??O();S(e,t,n,"Date picker",o=>{const u=s=>M(e,t,n,String(s),{format:a.format??B.calendar}),i=Z(Math.floor(r),u,void 0,{min:a.minDate,max:a.maxDate}),l=f("button",{class:"ct-btn",type:"button",text:C("Today"),onclick:()=>u(O())});return o.append(i,f("div",{class:"ct-foot"},l)),i.focusCell})}function It(e,t,n,a){const r=T(e,t,n),o=r===null?null:R(r).ms,u=new Date,i=o===null?{h:u.getHours(),m:u.getMinutes(),s:0}:Q(o);S(e,t,n,"Time picker",l=>{const s=tt(i),x=()=>M(e,t,n,String(s.read()),{format:a.format??B.time});return s.wrap.addEventListener("keydown",y=>{y.key==="Enter"&&(y.preventDefault(),x())}),l.append(s.wrap,$(e,x)),s.first})}function Rt(e,t,n,a){const r=T(e,t,n),o=R(r!==null&&r>=N?r:O()),u=a.startYear??1901,i=a.stopYear??9999;let l=Math.max(u,Math.min(i,o.year)),s=o.month-1;S(e,t,n,"Month picker",x=>{const y=k=>M(e,t,n,String(I(l,k+1,1)),{format:a.format??B.month}),c=f("div"),h=k=>{const m=f("div",{class:"ct-grid ct-months",role:"grid",ariaLabel:String(l)});let D=null;_.forEach((g,p)=>{const d=f("button",{class:`ct-cell${l===o.year&&p===o.month-1&&r!==null?" ct-on":""}`,type:"button",text:C(g).slice(0,3),ariaLabel:`${C(g)} ${l}`,tabIndex:p===s?0:-1,onclick:()=>y(p)});p===s&&(D=d),m.append(d)});const b=g=>{l=Math.max(u,Math.min(i,l+g)),h(!0)};m.addEventListener("keydown",g=>{const p={ArrowLeft:-1,ArrowRight:1,ArrowUp:-3,ArrowDown:3}[g.key];if(p!==void 0){g.preventDefault();const d=s+p;d<0?(s=d+12,b(-1)):d>11?(s=d-12,b(1)):(s=d,h(!0))}else g.key==="PageUp"||g.key==="PageDown"?(g.preventDefault(),b(g.key==="PageUp"?-1:1)):(g.key==="Enter"||g.key===" ")&&(g.preventDefault(),y(s))});const v=f("div",{class:"ct-row"},f("button",{class:"ct-nav",type:"button",text:"‹",ariaLabel:C("Previous year"),tabIndex:-1,onclick:()=>b(-1)}),f("div",{class:"ct-head",text:String(l)}),f("button",{class:"ct-nav",type:"button",text:"›",ariaLabel:C("Next year"),tabIndex:-1,onclick:()=>b(1)}));c.replaceChildren(v,m),c.focusCell=D,k&&D?.focus({preventScroll:!0})};return h(!1),x.append(c),c.focusCell})}function Tt(e,t,n,a){const r=T(e,t,n),o=new Date,u=r!==null&&r>=N?Math.floor(r):O(),i=r!==null?Q(R(r).ms):{h:o.getHours(),m:o.getMinutes(),s:0};S(e,t,n,"Date and time picker",l=>{let s=u;const x=tt(i),y=()=>M(e,t,n,String(s+x.read()),{format:a.format??B.datetime}),c=Z(s,h=>{s=h,x.first.focus()},h=>{s=h},{min:a.minDate,max:a.maxDate});return x.wrap.addEventListener("keydown",h=>{h.key==="Enter"&&(h.preventDefault(),y())}),x.wrap.style.marginTop="8px",l.append(c,x.wrap,$(e,y)),c.focusCell})}const $t=["#000000","#434343","#666666","#999999","#B7B7B7","#CCCCCC","#D9D9D9","#EFEFEF","#F3F3F3","#FFFFFF","#980000","#FF0000","#FF9900","#FFFF00","#00FF00","#00FFFF","#4A86E8","#0000FF","#9900FF","#FF00FF","#E6B8AF","#F4CCCC","#FCE5CD","#FFF2CC","#D9EAD3","#D0E0E3","#C9DAF8","#CFE2F3","#D9D2E9","#EAD1DC","#DD7E6B","#EA9999","#F9CB9C","#FFE599","#B6D7A8","#A2C4C9","#A4C2F4","#9FC5E8","#B4A7D6","#D5A6BD","#A61C00","#CC0000","#E69138","#F1C232","#6AA84F","#45818E","#3C78D8","#3D85C6","#674EA7","#A64D79","#5B0F00","#660000","#783F04","#7F6000","#274E13","#0C343D","#1C4587","#073763","#20124D","#4C1130"];function Nt(e,t,n,a){const r=a.palette??$t,{book:o}=e,u=U(o,o.sheet,t,n),i=typeof u=="string"&&/^#[0-9a-f]{6}$/i.test(u)?u.toUpperCase():null;S(e,t,n,"Color picker",l=>{let s=Math.max(0,r.indexOf(i));const x=m=>{if(a.target===void 0){M(e,t,n,m);return}H(e,t,n,{overFormula:!0})&&(o.applyStyle([{r0:t,c0:n,r1:t,c1:n}],a.target==="fill"?{fill:m}:{color:m}),e.grid.invalidate(),L())},y=f("div",{class:"ct-grid ct-swatches",role:"grid",ariaLabel:C("Colors")}),c=r.map((m,D)=>{const b=f("button",{class:`ct-swatch${m===i?" ct-on":""}`,type:"button",ariaLabel:m,title:m,tabIndex:D===s?0:-1,onclick:()=>x(m)});return b.style.background=m,y.append(b),b});y.addEventListener("keydown",m=>{const D={ArrowLeft:-1,ArrowRight:1,ArrowUp:-10,ArrowDown:10}[m.key];if(D!==void 0){m.preventDefault();const b=s+D;b>=0&&b<r.length&&(c[s].tabIndex=-1,s=b,c[s].tabIndex=0,c[s].focus())}else(m.key==="Enter"||m.key===" ")&&(m.preventDefault(),x(r[s]))});const h=f("input",{type:"text",value:i??"",placeholder:"#RRGGBB",maxLength:7,size:8,ariaLabel:C("Hex color")}),k=()=>{const m=h.value.trim(),D=/^#?[0-9a-f]{6}$/i.test(m)?`#${m.replace("#","").toUpperCase()}`:null;D?x(D):h.select()};return h.addEventListener("keydown",m=>{m.key==="Enter"&&(m.preventDefault(),k())}),l.append(y,f("div",{class:"ct-foot"},h,f("button",{class:"ct-btn",type:"button",text:C("Apply"),onclick:k}))),c[s]})}function Ot(e,t,n,a){const r=a.min??0,o=a.max??100,u=a.step??1,i=T(e,t,n);S(e,t,n,"Slider",l=>{const s=f("input",{type:"range",min:r,max:o,step:u,value:String(i??r),ariaLabel:C("Value")}),x=f("span",{class:"ct-value",text:s.value});s.addEventListener("input",()=>{x.textContent=s.value});const y=()=>M(e,t,n,s.value);return s.addEventListener("keydown",c=>{c.key==="Enter"&&(c.preventDefault(),y())}),l.append(s,$(e,y,x)),s})}const et=e=>Number(e.toPrecision(15));function Pt(e=0){let t=String(e),n=null,a=null,r=!0,o=!1;const u=()=>{const i=Number(t);if(a===null||n===null)return;let l;a==="+"?l=n+i:a==="-"?l=n-i:a==="*"?l=n*i:l=n/i,Number.isFinite(l)?t=String(et(l)):(o=!0,t="Error"),n=null,a=null};return{get display(){return t},get failed(){return o},press(i){if(i==="C"){t="0",n=null,a=null,r=!0,o=!1;return}o||(/^\d$/.test(i)?(t=r||t==="0"?i:t+i,r=!1):i==="."?(r?t="0.":t.includes(".")||(t+="."),r=!1):i==="back"?r||(t=t.length>1?t.slice(0,-1):"0"):i==="neg"?t=t.startsWith("-")?t.slice(1):t==="0"?t:`-${t}`:i==="%"?(t=String(et(Number(t)/100)),r=!0):i==="="?(u(),r=!0):"+-*/".includes(i)&&((!r||n===null)&&u(),o||(n=Number(t),a=i,r=!0)))}}}function Bt(e,t,n){const a=T(e,t,n),r=Pt(a??0);S(e,t,n,"Calculator",o=>{const u=f("input",{class:"ct-display",type:"text",readOnly:!0,value:r.display,ariaLabel:C("Result"),tabIndex:-1}),i=c=>{r.press(c),u.value=r.failed?C("Error"):r.display},l=()=>{i("="),r.failed||M(e,t,n,r.display)},s=[["C","C"],["±","neg"],["%","%"],["÷","/"],["7","7"],["8","8"],["9","9"],["×","*"],["4","4"],["5","5"],["6","6"],["−","-"],["1","1"],["2","2"],["3","3"],["+","+"],["0","0"],[".","."],["=","="]],x=f("div",{class:"ct-grid ct-keys"});let y=null;for(const[c,h]of s){const k=f("button",{class:`ct-key${h==="0"?" ct-wide":""}`,type:"button",text:c,ariaLabel:c,onclick:()=>i(h)});h==="7"&&(y=k),x.append(k)}return o.addEventListener("keydown",c=>{c.target.tagName==="BUTTON"&&(c.key===" "||c.key==="Enter")&&c.target.closest(".ct-foot")||c.target.tagName==="BUTTON"&&c.key===" "||(c.key==="Enter"?(c.preventDefault(),l()):c.key==="Backspace"?(c.preventDefault(),i("back")):c.key==="c"||c.key==="C"||c.key==="Delete"?(c.preventDefault(),i("C")):/^[\d.+\-*/%=]$/.test(c.key)&&(c.preventDefault(),i(c.key)))}),o.append(u,x,$(e,l)),y})}function Ut(e,t){const{book:n}=e,a=t.valueColumn??0;if(t.source){const r=t.source.replace(/^=/,""),o=r.lastIndexOf("!"),u=o>=0?r.slice(0,o).replace(/^'|'$/g,"").replace(/''/g,"'"):null;let i=u===null?n.sheet:n.sheets.find(c=>c.name.toLowerCase()===u.toLowerCase()),l=ft(o>=0?r.slice(o+1):r);if(!l&&o<0){const c=n.engine?.tables.get(r.toUpperCase());c&&(i=c.sheet,l={r0:c.r0+(c.headerRows??1),c0:c.c0,r1:c.r1,c1:c.c1})}if(!i||!l)return{head:t.columns??null,rows:[]};const s=[],x=Math.min(l.r1,i.maxRow,l.r0+j-1),y=Math.min(l.c1,i.maxCol,l.c0+49);for(let c=l.r0;c<=x;c++){const h=[];let k=null;for(let m=l.c0;m<=y;m++){const D=i.kind(c,m)&V,b=n.styles.list[i.style(c,m)]??n.styles.list[0];h.push(e.grid.displayText(D,i.value(c,m),b)),m-l.c0===a&&(k=U(n,i,c,m))}h.some(m=>m!=="")&&s.push({cells:h,value:k})}return{head:t.columns??null,rows:s}}return{head:t.columns??null,rows:(t.rows??[]).map(r=>({cells:r.map(String),value:r[a]??null}))}}function Ht(e,t,n,a){const{head:r,rows:o}=Ut(e,a),{book:u}=e,i=U(u,u.sheet,t,n);S(e,t,n,"List",l=>{if(o.length===0)return l.append(f("div",{text:C("No items"),class:"ct-item"})),l;let s=Math.max(0,o.findIndex(v=>i!==null&&String(v.value)===String(i)));const x=f("table",{class:"ct-table"});r&&x.append(f("thead",{},f("tr",{},...r.map((v,g)=>{const p=f("th",{text:v});return a.widths?.[g]>0&&(p.style.minWidth=`${a.widths[g]}px`),p}))));const y=f("tbody",{role:"listbox",ariaLabel:C("List"),tabIndex:0}),c=v=>M(e,t,n,vt(o[v].value)),h=o.map((v,g)=>{const p=f("tr",{role:"option",ariaSelected:String(g===s),onclick:()=>c(g)},...v.cells.map(d=>f("td",{text:d})));return y.append(p),p}),k=v=>{let g=Math.max(0,Math.min(o.length-1,v));const p=g<s?-1:1;for(;h[g].hidden&&g+p>=0&&g+p<o.length;)g+=p;h[g].hidden||(h[s].setAttribute("aria-selected","false"),s=g,h[s].setAttribute("aria-selected","true"),h[s].scrollIntoView({block:"nearest"}))};let m="",D=0;y.addEventListener("keydown",v=>{const p={ArrowUp:s-1,ArrowDown:s+1,PageUp:s-8,PageDown:s+8,Home:0,End:o.length-1}[v.key];if(p!==void 0)v.preventDefault(),k(p);else if(v.key==="Enter"||v.key===" ")v.preventDefault(),c(s);else if(v.key.length===1&&!v.metaKey&&!v.ctrlKey){const d=performance.now();m=d-D>800?v.key:m+v.key,D=d;const w=o.findIndex(A=>A.cells[0].toLowerCase().startsWith(m.toLowerCase()));w>=0&&k(w)}}),x.append(y);let b=null;return a.filter&&(b=f("input",{type:"text",placeholder:C("Filter"),ariaLabel:C("Filter the list")}),b.style.width="100%",b.style.boxSizing="border-box",b.style.marginBottom="4px",b.addEventListener("input",()=>{const v=b.value.trim().toLowerCase();o.forEach((p,d)=>{h[d].hidden=v!==""&&!p.cells.some(w=>String(w).toLowerCase().includes(v))});const g=h.findIndex(p=>!p.hidden);g>=0&&h[s].hidden&&k(g)}),b.addEventListener("keydown",v=>{v.key==="ArrowDown"?(v.preventDefault(),y.focus()):v.key==="Enter"&&(v.preventDefault(),h[s].hidden||c(s))}),l.append(b)),l.append(f("div",{class:"ct-list"},x)),requestAnimationFrame(()=>h[s]?.scrollIntoView({block:"nearest"})),b??y})}function re(e,t,n,{items:a,selected:r=[],multi:o=!1,onDone:u,label:i="List",maxItems:l=0,moveOnSide:s=!1,float:x}){S(e,t,n,i,y=>{x!==void 0&&Et(x);const c=new Set(r);let h=Math.max(0,a.findIndex(p=>c.has(p.value)));const k=()=>{const p=a.filter(d=>c.has(d.value)).map(d=>d.value);u(p)!==!1&&L()},m=f("div",{class:"ct-list",role:"listbox",ariaLabel:C(i),ariaMultiselectable:String(o),tabIndex:0});l>0&&(m.style.maxHeight=`${l*24}px`);const D=[],b=a.map((p,d)=>{const w=f("span",{class:"ct-mark",text:c.has(p.value)?"✓":""});D.push(w);const A=f("div",{class:`ct-item${d===h?" ct-cursor":""}`,role:"option",ariaSelected:String(c.has(p.value)),onclick:()=>{v(d),g(),o||k()}},w,f("span",{text:p.text}));return m.append(A),A});function v(p){const d=Math.max(0,Math.min(a.length-1,p));b[h]?.classList.remove("ct-cursor"),h=d,b[h]?.classList.add("ct-cursor"),b[h]?.scrollIntoView({block:"nearest"})}function g(){const p=a[h];p&&(o||c.clear(),c.has(p.value)?c.delete(p.value):c.add(p.value),a.forEach((d,w)=>{D[w].textContent=c.has(d.value)?"✓":"",b[w].setAttribute("aria-selected",String(c.has(d.value)))}))}return m.addEventListener("keydown",p=>{const d={ArrowUp:h-1,ArrowDown:h+1,Home:0,End:a.length-1}[p.key];d!==void 0?(p.preventDefault(),v(d)):p.key===" "?(p.preventDefault(),g(),o||k()):p.key==="Enter"?(p.preventDefault(),o||(c.clear(),g()),k()):s&&!o&&(p.key==="ArrowLeft"||p.key==="ArrowRight")&&(p.preventDefault(),c.clear(),g(),k(),e.controller.moveTo(t,Math.max(0,n+(p.key==="ArrowLeft"?-1:1))))}),y.append(m),o&&y.append($(e,k)),a.length===0&&m.append(f("div",{class:"ct-item",text:C("No items")})),m})}const Wt={calendar:Mt,time:It,month:Rt,datetime:Tt,color:Nt,slider:Ot,calculator:Bt,list:Ht};function nt(e,t,n,a){K.get(a.type)?.open?.(e,t,n,a)!==!0&&Wt[a.type]?.(e,t,n,a)}function oe(e,t,n,a){return e.loading?!1:(H(e,t,n,{overFormula:!0})&&nt(e,t,n,a),!0)}function ae(e,t,n){const{sheet:a}=e.book,r=X(a,t,n);if(!r||e.loading)return!1;if(!H(e,t,n,{overFormula:!0}))return!0;const o=a.mergeAt(t,n);return nt(e,o?o.r0:t,o?o.c0:n,r),!0}export{W as DROPDOWN_TYPES,gt as MAX_APPLY_CELLS,_ as MONTHS,Jt as applyToRanges,Z as buildCalendar,H as canWriteCell,Zt as cellDropdownArrow,P as cellKey,T as cellSerial,wt as clipRange,L as closeDropdown,M as commit,X as dropdownAt,$ as footer,te as isDropdownOpen,Ut as listData,vt as literalInput,f as make,Pt as makeCalculator,Qt as makeDropdown,ae as openCellDropdown,oe as openDropdownConfig,re as openListPopup,S as openPopup,ne as popupViewChanged,U as readCellValue,Xt as registerDropdownKind,Et as setPopupFloat,ee as setPopupKeepOpen,G as swapMap,tt as timeInputs,O as todaySerial,kt as writeCell};
@@ -0,0 +1,2 @@
1
+ import{overlayRoot as Q}from"../api/overlay.js";import{base64ToBytes as ee}from"../core/base64.js";import{xmlAttr as te}from"../io/xml-escape.js";import{STR as ne}from"../core/sheet.js";import{setSparse as A}from"../core/sparse.js";import{parseInput as se}from"../core/input.js";import{CELLS_NS as oe,cellTypePart as ie}from"./persist.js";import{registerSection as le}from"../cells/sections.js";import{canWriteCell as B,closeDropdown as z,make as v,openListPopup as re,openPopup as ae,readCellValue as $}from"./dropdowns.js";import{cachedImage as P,CellType as fe,controlRect as ce,defineCellType as ue,drawImageFit as R,frame as de,inkOf as _,inRect as x,labelOf as pe,leftText as D,makeCellType as O,safeImage as me,safeInt as he,safeText as ge,setFont as W,textWidth as j}from"./base.js";import{drawGlyph as b}from"./glyphs.js";import{t as p}from"../i18n/index.js";const S=10*1024*1024,U=256*1024*1024,q=/^[a-z0-9]{1,40}$/,N=/^[\w.+-]+\/[\w.+-]+$/,we=/^[A-Za-z0-9+/]*={0,2}$/,T=/^image\/(png|jpeg|gif|webp|bmp|svg\+xml|x-icon|vnd\.microsoft\.icon)$/,ye=[["#C43E1C",["ppt","pptx","pps","ppsx","key","odp"]],["#107C41",["xls","xlsx","xlsm","xlsb","csv","tsv","ods","numbers"]],["#185ABD",["doc","docx","rtf","odt","pages"]],["#D13438",["pdf"]],["#7A5C00",["zip","rar","7z","tar","gz","bz2","xz"]],["#8764B8",["mp3","wav","flac","aac","ogg","m4a"]],["#B4009E",["mp4","mov","avi","mkv","webm","wmv"]],["#008272",["png","jpg","jpeg","gif","bmp","svg","ico","webp","tif","tiff","heic"]],["#3A3A3A",["js","mjs","ts","json","xml","html","css","py","java","c","cpp","sh","sql","md"]],["#606060",["txt","log"]]],ve=new Map(ye.flatMap(([t,e])=>e.map(s=>[s,t]))),k=new Map;function We(t,e){const s=String(t).replace(/^\./,"").toLowerCase(),n=me(e);n?k.set(s,n):k.delete(s)}const Fe=t=>{const e=t.lastIndexOf(".");return e>0?t.slice(e+1).toLowerCase():""};function xe(t,e,s,n,o,i){const l=Fe(e),r=k.get(l);if(r){const h=P(r);h&&R(t,h,s,n,o,o);return}const c=ve.get(l);if(c===void 0){b(t,"file",s,n,o,i);return}const f=o*.8,a=s+(o-f)/2,u=o*.26;t.save(),t.fillStyle="#ffffff",t.strokeStyle=c,t.lineWidth=Math.max(1,o/14),t.beginPath(),t.moveTo(a,n),t.lineTo(a+f-u,n),t.lineTo(a+f,n+u),t.lineTo(a+f,n+o),t.lineTo(a,n+o),t.closePath(),t.fill(),t.stroke(),t.fillStyle=c;const m=o*.5;if(t.fillRect(a,n+o-m,f,m),o>=13){const h=l.slice(0,4).toUpperCase();t.font=`600 ${Math.max(5,Math.min(m*.86,f*1.5/h.length))}px -apple-system, "Helvetica Neue", Arial, sans-serif`,t.fillStyle="#ffffff",t.textAlign="center",t.textBaseline="middle",t.fillText(h,a+f/2,n+o-m/2)}t.restore()}const y=t=>t<1024?`${t} B`:t<1024*1024?`${(t/1024).toFixed(t<10240?1:0)} KB`:`${(t/1024/1024).toFixed(1)} MB`,Y=t=>String(t).split(/[/\\]/).pop().replace(/[\u0000-\u001f\u007f￾￿]/g,"").slice(0,200)||"file",I=t=>Math.floor(t.length*3/4)-(t.endsWith("==")?2:t.endsWith("=")?1:0);function V(t){return t.cellFiles||(t.cellFiles=new Map),t.cellFiles}function be(t){let e;do e=Math.random().toString(36).slice(2,14);while(t.has(e));return e}function Se(t,e,s,n){const o=V(t),i=be(o);return o.set(i,{id:i,name:Y(e),type:N.test(s)?s:"application/octet-stream",size:I(n),b64:n,url:null}),i}function M(t){return t.url===null&&(t.url=URL.createObjectURL(new Blob([ee(t.b64)],{type:t.type}))),t.url}function Te(t){const e=t.cellFiles,s=new Set;for(const n of t.sheets)if(n.cellTypes)for(const[o,i]of n.cellTypes){if(i.type!=="file"||i.options.file===void 0||s.has(i.options.file))continue;const l=Math.floor(o/16384);F(e,i.options,$(t,n,l,o-l*16384))&&s.add(i.options.file)}return s}function je(t){if(!t.cellFiles||t.cellFiles.size===0)return[];const e=[];let s=0;for(const n of Te(t)){const o=t.cellFiles.get(n),i=te(JSON.stringify({id:o.id,name:o.name,type:o.type}).slice(0,-1)),l=`<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
2
+ <cells xmlns="${oe}" version="1"><section name="cellFile" data="${i},&quot;b64&quot;:&quot;${o.b64}&quot;}"/></cells>`;e.push(ie(s++,l,"cellFile8c"))}return e}le("cellFile",{book:{save:()=>{},load(t,e){const{id:s,name:n,type:o,b64:i}=e??{};typeof s!="string"||!q.test(s)||typeof i!="string"||!we.test(i)||I(i)>S||V(t).set(s,{id:s,name:Y(n),type:typeof o=="string"&&N.test(o)?o:"application/octet-stream",size:I(i),b64:i,url:null})}}});function F(t,e,s){if(!t||e.file===void 0)return null;const n=t.get(e.file);return n!==void 0&&pe(s)===n.name?n:null}function ke(t,e){if(!e)return!0;const s=t.name.toLowerCase(),n=(t.type||"").toLowerCase();return e.split(",").map(o=>o.trim().toLowerCase()).filter(Boolean).some(o=>o.startsWith(".")?s.endsWith(o):o.endsWith("/*")?n.startsWith(o.slice(0,-1)):n===o)}const Ie=t=>new Promise((e,s)=>{const n=new FileReader;n.onload=()=>e(String(n.result).slice(String(n.result).indexOf(",")+1)),n.onerror=()=>s(n.error),n.readAsDataURL(t)});async function X(t,e,s,n,o){const{book:i,shell:l}=t,{sheet:r}=i;if(!B(t,e,s))return!1;const c=n.options.maxSize??S;if(o.size>c)return l.setStatus(p("{name} is {size}. This cell takes files up to {limit}.",{name:o.name,size:y(o.size),limit:y(c)})),!1;if(!ke(o,n.options.accept))return l.setStatus(p("This cell doesn't take {name}. It accepts {accept}.",{name:o.name,accept:n.options.accept})),!1;let f=o.size;for(const w of i.cellFiles?.values()??[])f+=w.size;if(f>U)return l.setStatus(p("A workbook can hold {size} of files, and this one would go over.",{size:y(U)})),!1;let a;try{a=await Ie(o)}catch{return l.setStatus(p("Couldn't read {name}.",{name:o.name})),!1}if(i.sheet!==r)return l.setStatus("The sheet changed while the file was loading, so it was not added."),!1;const u=Se(i,o.name,o.type,a),m=i.cellFiles.get(u).name,h=se(m).kind===ne&&m[0]!=="="&&m[0]!=="'"?m:`'${m}`;return i.transact("entry",w=>(i.setInput(w,e,s,h),A(r,"cellTypes",[{r0:e,c0:s,r1:e,c1:s}],O("file",{...n.options,file:u})))),t.grid.invalidate(),t.controller.syncFormulaBar(),!0}function G(t,e,s,n){if(!B(t,e,s))return!1;const{book:o}=t,{sheet:i}=o,{file:l,...r}=n.options;return o.transact("entry",c=>(o.setInput(c,e,s,""),A(i,"cellTypes",[{r0:e,c0:s,r1:e,c1:s}],O("file",r)))),t.grid.invalidate(),t.controller.syncFormulaBar(),!0}function C(t){const e=document.createElement("a");e.href=M(t),e.download=t.name,Q().append(e),e.click(),e.remove()}function H(t,e,s,n){ae(t,e,s,p("Preview of {name}",{name:n.name}),o=>{const i=v("img",{alt:n.name,src:M(n)});i.style.cssText="display:block;max-width:min(480px,80vw);max-height:60vh";const l=v("button",{class:"ct-btn",type:"button",text:p("Close"),onclick:()=>z()});return o.append(i,v("div",{class:"ct-foot"},v("button",{class:"ct-btn",type:"button",text:p("Download"),onclick:()=>C(n)}),l)),l})}function J(t,e,s,n){const o=document.createElement("input");o.type="file",n.options.accept&&(o.accept=n.options.accept),o.addEventListener("change",()=>{o.files[0]&&X(t,e,s,n,o.files[0])}),o.click()}class Me extends fe{static typeName="file";static sanitize(e){return{accept:ge(e.accept,300),maxSize:he(e.maxSize,1,S),preview:e.preview===!1?!1:void 0,download:e.download===!1?!1:void 0,file:typeof e.file=="string"&&q.test(e.file)?e.file:void 0}}get blocksEditing(){return!0}_parts(e,s){const n=Math.min(16*s,e.h),o=e.y+(e.h-n)/2,i={x:e.x+e.w-n,y:o,w:n,h:n},l=this.options.download===!1?null:{x:i.x-n,y:o,w:n,h:n};return{clear:i,down:l,thumb:{x:e.x,y:e.y,w:Math.min(e.h,e.w/3),h:e.h}}}paint(e,s,n,o,i,l){const r=F(l?.book?.cellFiles,this.options,n),c=l?.printing===!0,f=Math.round(2*i);if(W(e,o,i),r===null){if(c)return;const d=Math.min(Math.round(14*i),s.h-2),g=s.y+(s.h-d)/2,K=s.w-d-f*3,Z=p("Choose or drop a file"),L="#6e6e6e";b(e,"upload",s.x+f,g,d,L),K>0&&D(e,Z,s.x+f*2+d,s.y,s.h,L);return}const a=this._parts(s,i);let u=s.x+f;if(this.options.preview!==!1&&T.test(r.type)&&typeof URL<"u"&&!c){const d=P(M(r));d&&R(e,d,s.x+1,s.y+1,a.thumb.w-2,s.h-2),u=s.x+a.thumb.w+f}else{const d=Math.min(Math.round(14*i),s.h-2);xe(e,r.name,u,s.y+(s.h-d)/2,d,_(o)),W(e,o,i),u+=d+f}const h=c?s.x+s.w:a.down?a.down.x:a.clear.x;e.save(),e.beginPath(),e.rect(u,s.y,Math.max(0,h-u),s.h),e.clip();const w=`${r.name} (${y(r.size)})`;if(D(e,w,u,s.y,s.h,_(o)),e.restore(),c)return;const E=(d,g)=>b(e,d,g.x+g.w*.1,g.y+g.h*.1,g.w*.8,"#3c3c3c");a.down&&E("download",a.down),E("clear",a.clear)}hitTest(e,s,n,o=1){if(!x(e,s,n))return null;if(this.options.file===void 0)return{part:"pick"};const i=this._parts(e,o);return x(i.clear,s,n)?{part:"clear"}:i.down&&x(i.down,s,n)?{part:"download"}:{part:"file"}}activate(e,s,n,o,i){const{book:l}=e,r=F(l.cellFiles,this.options,$(l,l.sheet,s,n));if(r===null)return J(e,s,n,this),!0;if(o==null){const f=[{text:p("Download"),value:"download"},{text:p("Replace…"),value:"pick"},{text:p("Clear"),value:"clear"}];return T.test(r.type)&&f.unshift({text:p("Preview"),value:"preview"}),re(e,s,n,{items:f,label:"File",onDone:([a])=>(z(),a==="download"?C(r):a==="pick"?J(e,s,n,this):a==="clear"?G(e,s,n,this):a==="preview"&&H(e,s,n,r),!1)}),!0}const c=this.hitTest(ce(e,s,n),o,i,e.grid.zoom);return c?.part==="clear"?G(e,s,n,this):c?.part==="download"?(C(r),!0):T.test(r.type)&&this.options.preview!==!1?(H(e,s,n,r),!0):!1}fitWidth(e,s){const n=F(de.book?.cellFiles,this.options,e);return n===null?j(s,p("Choose or drop a file"))+22:j(s,`${n.name} (${y(n.size)})`)+58}}ue(Me);function Ue(t){const{host:e}=t.grid,s=n=>{const{sheet:o}=t.book;if(!o.cellTypes||!n.dataTransfer?.types?.includes("Files"))return null;const{x:i,y:l}=t.controller._point(n),r=t.controller._hit(i,l);if(r.type!=="cell")return null;const c=o.mergeAt(r.row,r.col),f=c?c.r0:r.row,a=c?c.c0:r.col,u=o.cellTypes.get(f*16384+a);return u!==void 0&&u.type==="file"?{row:f,col:a,t:u}:null};e.addEventListener("dragover",n=>{s(n)!==null&&(n.preventDefault(),n.stopImmediatePropagation(),n.dataTransfer.dropEffect="copy")},!0),e.addEventListener("drop",n=>{const o=s(n);if(o===null)return;n.preventDefault(),n.stopImmediatePropagation();const i=n.dataTransfer.files[0];i&&X(t,o.row,o.col,o.t,i)},!0)}export{Me as FileCell,S as MAX_FILE_BYTES,Ue as attachFileDrop,je as cellFilesPackage,xe as drawFileIcon,y as formatSize,We as setFileIcon,X as takeFile};
@@ -0,0 +1 @@
1
+ const e=(o,l)=>{o.beginPath(),l.forEach(([a,r],t)=>t===0?o.moveTo(a,r):o.lineTo(a,r)),o.stroke()},P=(o,l)=>{o.beginPath(),l.forEach(([a,r],t)=>t===0?o.moveTo(a,r):o.lineTo(a,r)),o.closePath(),o.fill()},k=(o,l,a)=>{e(o,[[l,l],[a,a]]),e(o,[[a,l],[l,a]])},p={clear(o){o.beginPath(),o.arc(.5,.5,.36,0,Math.PI*2),o.stroke(),k(o,.36,.64)},cancel:o=>k(o,.24,.76),ok:o=>e(o,[[.18,.54],[.42,.76],[.84,.26]]),dropdown:o=>P(o,[[.22,.36],[.78,.36],[.5,.68]]),ellipsis(o){for(const l of[.2,.5,.8])o.beginPath(),o.arc(l,.5,.075,0,Math.PI*2),o.fill()},left:o=>e(o,[[.62,.22],[.34,.5],[.62,.78]]),right:o=>e(o,[[.38,.22],[.66,.5],[.38,.78]]),up:o=>e(o,[[.22,.62],[.5,.34],[.78,.62]]),down:o=>e(o,[[.22,.38],[.5,.66],[.78,.38]]),plus(o){e(o,[[.5,.2],[.5,.8]]),e(o,[[.2,.5],[.8,.5]])},minus:o=>e(o,[[.2,.5],[.8,.5]]),search(o){o.beginPath(),o.arc(.43,.43,.25,0,Math.PI*2),o.stroke(),e(o,[[.62,.62],[.84,.84]])},undo(o){o.beginPath(),o.arc(.5,.56,.28,Math.PI,Math.PI*2.5),o.stroke(),e(o,[[.08,.42],[.22,.58],[.38,.44]])},redo(o){o.beginPath(),o.arc(.5,.56,.28,Math.PI*.5,Math.PI*2),o.stroke(),e(o,[[.92,.42],[.78,.58],[.62,.44]])},reload(o){o.beginPath(),o.arc(.5,.5,.3,-Math.PI*.35,Math.PI*1.45),o.stroke(),P(o,[[.62,.06],[.88,.2],[.64,.36]])},separator:o=>e(o,[[.5,.1],[.5,.9]]),spinLeft:o=>P(o,[[.66,.22],[.34,.5],[.66,.78]]),spinRight:o=>P(o,[[.34,.22],[.66,.5],[.34,.78]]),collapse:o=>P(o,[[.22,.66],[.78,.66],[.5,.32]]),expand:o=>P(o,[[.22,.34],[.78,.34],[.5,.68]]),calendar(o){o.strokeRect(.16,.22,.68,.62),o.fillRect(.16,.22,.68,.16),e(o,[[.34,.12],[.34,.28]]),e(o,[[.66,.12],[.66,.28]])},clock(o){o.beginPath(),o.arc(.5,.5,.36,0,Math.PI*2),o.stroke(),e(o,[[.5,.28],[.5,.52],[.68,.62]])},upload(o){e(o,[[.5,.68],[.5,.2]]),e(o,[[.28,.4],[.5,.18],[.72,.4]]),e(o,[[.16,.62],[.16,.84],[.84,.84],[.84,.62]])},download(o){e(o,[[.5,.16],[.5,.62]]),e(o,[[.28,.42],[.5,.64],[.72,.42]]),e(o,[[.16,.84],[.84,.84]])},file(o){e(o,[[.24,.1],[.6,.1],[.78,.3],[.78,.9],[.24,.9],[.24,.1]]),e(o,[[.6,.1],[.6,.3],[.78,.3]])}},u=Object.keys(p);function I(o,l,a,r,t,d){const f=p[l];if(f===void 0)return;const g={beginPath:()=>o.beginPath(),moveTo:(n,h)=>o.moveTo(a+n*t,r+h*t),lineTo:(n,h)=>o.lineTo(a+n*t,r+h*t),closePath:()=>o.closePath(),arc:(n,h,i,s,M)=>o.arc(a+n*t,r+h*t,i*t,s,M),fill:()=>o.fill(),stroke:()=>o.stroke(),strokeRect:(n,h,i,s)=>o.strokeRect(a+n*t,r+h*t,i*t,s*t),fillRect:(n,h,i,s)=>o.fillRect(a+n*t,r+h*t,i*t,s*t)};o.save(),o.fillStyle=d,o.strokeStyle=d,o.lineWidth=Math.max(1,t/10),o.lineCap="round",o.lineJoin="round",f(g),o.restore()}export{u as GLYPH_NAMES,I as drawGlyph};