@8sheets/data-grid 1.1.2 → 1.2.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 (226) hide show
  1. package/README.md +1 -1
  2. package/a11y/cell-alt-text.js +1 -1
  3. package/api/serialize.js +1 -1
  4. package/api/style-refs.js +1 -1
  5. package/calc/adjust.js +1 -1
  6. package/calc/compile.js +1 -1
  7. package/calc/engine.js +1 -1
  8. package/calc/functions/array.js +1 -1
  9. package/calc/functions/database.js +1 -1
  10. package/calc/functions/date.js +1 -1
  11. package/calc/functions/engineering.js +1 -1
  12. package/calc/functions/financial.js +1 -1
  13. package/calc/functions/helpers.js +1 -1
  14. package/calc/functions/index.js +3 -2
  15. package/calc/functions/info.js +1 -1
  16. package/calc/functions/logical.js +1 -1
  17. package/calc/functions/lookup.js +1 -1
  18. package/calc/functions/math.js +1 -1
  19. package/calc/functions/stat.js +1 -1
  20. package/calc/functions/text.js +1 -1
  21. package/calc/parser.js +2 -2
  22. package/calc/shown-refs.js +1 -0
  23. package/calc/values.js +1 -1
  24. package/calcx/calc-control.js +1 -0
  25. package/calcx/external-read.js +1 -1
  26. package/calcx/external.js +1 -1
  27. package/cells/axis-ops.js +1 -1
  28. package/cells/cell-styles-xml.js +1 -1
  29. package/cells/cf-engine.js +1 -1
  30. package/cells/cf-file.js +1 -1
  31. package/cells/docprops-xml.js +2 -2
  32. package/cells/filter-eval.js +1 -0
  33. package/cells/filter-file.js +1 -1
  34. package/cells/find-engine.js +1 -1
  35. package/cells/goto.js +1 -1
  36. package/cells/name-box.js +1 -1
  37. package/cells/note-box.js +3 -0
  38. package/cells/options.js +1 -1
  39. package/cells/outline-column.js +1 -1
  40. package/cells/protected-menu.js +1 -0
  41. package/cells/rich-data-xml.js +1 -1
  42. package/cells/sheet-views-file.js +2 -0
  43. package/cells/shift-check.js +1 -1
  44. package/cells/sort-compare.js +1 -0
  45. package/cells/ui-kit.js +1 -1
  46. package/cells/undo-group.js +1 -1
  47. package/celltypes/dropdowns.js +2 -2
  48. package/core/address.js +1 -1
  49. package/core/autofill.js +1 -1
  50. package/core/axis.js +1 -1
  51. package/core/cond-format.js +1 -1
  52. package/core/culture.js +5 -1
  53. package/core/custom-views.js +1 -1
  54. package/core/data-tools.js +1 -0
  55. package/core/date-codes.js +1 -0
  56. package/core/default-names.js +1 -1
  57. package/core/formula-refs.js +1 -1
  58. package/core/input.js +1 -1
  59. package/core/numfmt.js +1 -1
  60. package/core/precision.js +1 -0
  61. package/core/region-input.js +1 -1
  62. package/core/rule-refs.js +1 -0
  63. package/core/shared-view.js +1 -0
  64. package/core/sheet.js +1 -1
  65. package/core/sparklines.js +1 -1
  66. package/core/sparse.js +1 -1
  67. package/core/spills.js +1 -0
  68. package/core/strings.js +1 -1
  69. package/core/structure.js +1 -1
  70. package/core/table-columns.js +1 -0
  71. package/core/tables.js +2 -2
  72. package/core/validation-ranges.js +1 -1
  73. package/core/whatif.js +1 -1
  74. package/core/workbook.js +1 -1
  75. package/datasheets/formula.js +1 -1
  76. package/datasheets/path-binding.js +1 -1
  77. package/datasheets/persist-writer.js +1 -1
  78. package/datasheets/report.js +1 -1
  79. package/extras/getdata/persist.js +2 -2
  80. package/extras/getdata/rows.js +1 -1
  81. package/extras/getdata/shared-steps.js +1 -0
  82. package/extras/getdata/steps-formula.js +1 -0
  83. package/extras/getdata/steps-more.js +1 -0
  84. package/extras/getdata/steps-tables.js +1 -0
  85. package/extras/getdata/steps.js +1 -1
  86. package/i18n/de/a11y.js +1 -0
  87. package/i18n/de/cells.js +2 -0
  88. package/i18n/de/charts.js +1 -0
  89. package/i18n/de/common.js +1 -0
  90. package/i18n/de/datasheets.js +1 -0
  91. package/i18n/de/format.js +1 -0
  92. package/i18n/de/misc.js +1 -0
  93. package/i18n/de/pivot.js +1 -0
  94. package/i18n/de/proofing.js +1 -0
  95. package/i18n/de/ribbon.js +1 -0
  96. package/i18n/de/shapes.js +1 -0
  97. package/i18n/de/shell.js +3 -0
  98. package/i18n/de/touch.js +1 -0
  99. package/i18n/de.js +1 -0
  100. package/i18n/en/cells.js +2 -1
  101. package/i18n/en/charts.js +1 -1
  102. package/i18n/en/format.js +1 -1
  103. package/i18n/en/misc.js +1 -1
  104. package/i18n/en/pivot.js +1 -1
  105. package/i18n/en/proofing.js +1 -1
  106. package/i18n/en/ribbon.js +1 -1
  107. package/i18n/en/shapes.js +1 -1
  108. package/i18n/en/shell.js +3 -2
  109. package/i18n/en/touch.js +1 -1
  110. package/i18n/es/a11y.js +1 -0
  111. package/i18n/es/cells.js +2 -0
  112. package/i18n/es/charts.js +1 -0
  113. package/i18n/es/common.js +1 -0
  114. package/i18n/es/datasheets.js +1 -0
  115. package/i18n/es/format.js +1 -0
  116. package/i18n/es/misc.js +1 -0
  117. package/i18n/es/pivot.js +1 -0
  118. package/i18n/es/proofing.js +1 -0
  119. package/i18n/es/ribbon.js +1 -0
  120. package/i18n/es/shapes.js +1 -0
  121. package/i18n/es/shell.js +3 -0
  122. package/i18n/es/touch.js +1 -0
  123. package/i18n/es.js +1 -0
  124. package/i18n/fr/a11y.js +1 -0
  125. package/i18n/fr/cells.js +2 -0
  126. package/i18n/fr/charts.js +1 -0
  127. package/i18n/fr/common.js +1 -0
  128. package/i18n/fr/datasheets.js +1 -0
  129. package/i18n/fr/format.js +1 -0
  130. package/i18n/fr/misc.js +1 -0
  131. package/i18n/fr/pivot.js +1 -0
  132. package/i18n/fr/proofing.js +1 -0
  133. package/i18n/fr/ribbon.js +1 -0
  134. package/i18n/fr/shapes.js +1 -0
  135. package/i18n/fr/shell.js +3 -0
  136. package/i18n/fr/touch.js +1 -0
  137. package/i18n/fr.js +1 -0
  138. package/i18n/index.js +1 -1
  139. package/i18n/languages.js +1 -1
  140. package/i18n/pl/cells.js +2 -1
  141. package/i18n/pl/charts.js +1 -1
  142. package/i18n/pl/format.js +1 -1
  143. package/i18n/pl/misc.js +1 -1
  144. package/i18n/pl/pivot.js +1 -1
  145. package/i18n/pl/proofing.js +1 -1
  146. package/i18n/pl/ribbon.js +1 -1
  147. package/i18n/pl/shapes.js +1 -1
  148. package/i18n/pl/shell.js +3 -2
  149. package/i18n/pl/touch.js +1 -1
  150. package/io/blob-sink.js +1 -0
  151. package/io/canonical-xml.js +1 -0
  152. package/io/client.js +1 -1
  153. package/io/crypto/cfb-build.js +1 -0
  154. package/io/crypto/cfb-read.js +1 -1
  155. package/io/crypto/cfb-write.js +1 -1
  156. package/io/crypto/errors.js +1 -1
  157. package/io/csv.js +8 -8
  158. package/io/foreign-sheets.js +2 -2
  159. package/io/io.worker.js +1 -1
  160. package/io/open-package.js +1 -0
  161. package/io/package-paths.js +1 -1
  162. package/io/plan.js +1 -1
  163. package/io/text-split.js +3 -3
  164. package/io/xls/chart-sheet.js +1 -0
  165. package/io/xls/chart.js +1 -0
  166. package/io/xls/crypt.js +1 -0
  167. package/io/xls/dml-color.js +1 -0
  168. package/io/xls/drawing.js +1 -0
  169. package/io/xls/formula.js +1 -0
  170. package/io/xls/geometry.js +1 -0
  171. package/io/xls/index.js +1 -0
  172. package/io/xls/pictures.js +1 -0
  173. package/io/xls/pivot.js +1 -0
  174. package/io/xls/props.js +1 -0
  175. package/io/xls/records.js +1 -0
  176. package/io/xls/shapes.js +1 -0
  177. package/io/xls/sheet-ext.js +1 -0
  178. package/io/xls/sheet.js +1 -0
  179. package/io/xls/styles.js +1 -0
  180. package/io/xls/vba.js +1 -0
  181. package/io/xls/workbook.js +1 -0
  182. package/io/xlsb/filter.js +1 -0
  183. package/io/xlsb/formula.js +2 -0
  184. package/io/xlsb/functions.js +1 -0
  185. package/io/xlsb/index.js +1 -0
  186. package/io/xlsb/parts.js +1 -0
  187. package/io/xlsb/pivot.js +1 -0
  188. package/io/xlsb/records.js +1 -0
  189. package/io/xlsb/sheet-ext.js +1 -0
  190. package/io/xlsb/sheet.js +1 -0
  191. package/io/xlsb/slicer.js +1 -0
  192. package/io/xlsb/styles.js +1 -0
  193. package/io/xlsb/workbook.js +1 -0
  194. package/io/xlsb/xml.js +2 -0
  195. package/io/xlsx-read.js +1 -1
  196. package/io/xlsx-styles.js +2 -2
  197. package/io/xlsx-tail.js +1 -1
  198. package/io/xlsx-write.js +2 -2
  199. package/io/xml-escape.js +1 -1
  200. package/io/xml-scan.js +2 -2
  201. package/io/zip-reader.js +1 -1
  202. package/objects/chart-model.js +1 -1
  203. package/objects/drawing-xml.js +1 -1
  204. package/package.json +1 -1
  205. package/pivot/calc-items.js +1 -0
  206. package/pivot/engine.js +1 -1
  207. package/pivot/xml.js +2 -2
  208. package/print/note-pages.js +2 -2
  209. package/print/page-setup.js +1 -1
  210. package/print/paginate.js +1 -1
  211. package/print/pdf-crypt.js +1 -0
  212. package/print/pdf-tags.js +1 -0
  213. package/print/pdf.js +24 -13
  214. package/print/render-page.js +3 -3
  215. package/print/shown-notes.js +1 -0
  216. package/shapes/form-xml.js +1 -1
  217. package/slicers/custom-styles.js +1 -1
  218. package/slicers/format.js +1 -1
  219. package/slicers/structured.js +1 -1
  220. package/slicers/write.js +1 -1
  221. package/table-view/files.js +1 -1
  222. package/table-view/mount.js +1 -1
  223. package/table-view/version.js +1 -1
  224. package/ui/icons.js +1 -1
  225. package/ui/menu-base.js +1 -1
  226. package/ui/protection-ui.js +1 -1
@@ -1,2 +1,2 @@
1
1
  import{xmlText as X}from"../io/xml-escape.js";import{unescapeXstring as w}from"../io/xml-scan.js";const I="http://schemas.microsoft.com/office/spreadsheetml/2017/richdata",O="http://schemas.microsoft.com/office/spreadsheetml/2017/richdata2",H="http://schemas.microsoft.com/office/spreadsheetml/2022/richvaluerel",N="http://schemas.openxmlformats.org/spreadsheetml/2006/main",L="http://schemas.openxmlformats.org/officeDocument/2006/relationships",R=`<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
2
- `,P="http://schemas.microsoft.com/office/2017/06/relationships/rdRichValue",B="http://schemas.microsoft.com/office/2017/06/relationships/rdRichValueStructure",j="http://schemas.microsoft.com/office/2017/06/relationships/rdRichValueTypes",Y="http://schemas.microsoft.com/office/2022/10/relationships/richValueRel",W=`${L}/sheetMetadata`,G="application/vnd.openxmlformats-officedocument.spreadsheetml.sheetMetadata+xml",_={rv:"application/vnd.ms-excel.rdrichvalue+xml",struct:"application/vnd.ms-excel.rdrichvaluestructure+xml",types:"application/vnd.ms-excel.rdrichvaluetypes+xml",rel:"application/vnd.ms-excel.richvaluerel+xml"},$={rv:"xl/richData/rdrichvalue.xml",struct:"xl/richData/rdrichvaluestructure.xml",types:"xl/richData/rdRichValueTypes.xml",rel:"xl/richData/richValueRel.xml",relRels:"xl/richData/_rels/richValueRel.xml.rels",meta:"xl/metadata.xml"},A='<s t="_localImage"><k n="_rvRel:LocalImageIdentifier" t="i"/><k n="CalcOrigin" t="i"/><k n="Text" t="s"/></s>',q=`${R}<rvTypesInfo xmlns="${O}" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" mc:Ignorable="x" xmlns:x="${N}"><global><keyFlags><key name="_Self"><flag name="ExcludeFromFile" value="1"/><flag name="ExcludeFromCalcComparison" value="1"/></key><key name="_DisplayString"><flag name="ExcludeFromCalcComparison" value="1"/></key><key name="_Flags"><flag name="ExcludeFromCalcComparison" value="1"/></key><key name="_Format"><flag name="ExcludeFromCalcComparison" value="1"/></key><key name="_SubLabel"><flag name="ExcludeFromCalcComparison" value="1"/></key><key name="_Attribution"><flag name="ExcludeFromCalcComparison" value="1"/></key><key name="_Icon"><flag name="ExcludeFromCalcComparison" value="1"/></key><key name="_Display"><flag name="ExcludeFromCalcComparison" value="1"/></key><key name="_CanonicalPropertyNames"><flag name="ExcludeFromCalcComparison" value="1"/></key><key name="_ClassificationId"><flag name="ExcludeFromCalcComparison" value="1"/></key></keyFlags></global></rvTypesInfo>`;function ee(e){const r={vmCount:0,byVm:new Map};if(!e.meta)return r;const d=[...e.meta.matchAll(/<metadataType\b[^>]*\bname="([^"]+)"/g)].map(a=>a[1]).indexOf("XLRICHVALUE")+1,f=/<futureMetadata\b[^>]*name="XLRICHVALUE"[^>]*>([\s\S]*?)<\/futureMetadata>/.exec(e.meta),b=f?[...f[1].matchAll(/<bk>([\s\S]*?)<\/bk>/g)].map(a=>Number(/\bi="(\d+)"/.exec(a[1])?.[1]??-1)):[],v=/<valueMetadata\b[^>]*>([\s\S]*?)<\/valueMetadata>/.exec(e.meta),t=v?[...v[1].matchAll(/<bk>([\s\S]*?)<\/bk>/g)]:[];if(r.vmCount=t.length,!d||!e.rv||!e.struct)return r;const k=[...e.struct.matchAll(/<s\b[^>]*\bt="([^"]+)"[^>]*>([\s\S]*?)<\/s>/g)].map(a=>({t:a[1],keys:[...a[2].matchAll(/<k\b[^>]*\bn="([^"]+)"/g)].map(n=>n[1])})),E=[...e.rv.matchAll(/<rv\b[^>]*\bs="(\d+)"[^>]*>([\s\S]*?)<\/rv>/g)].map(a=>({s:Number(a[1]),v:[...a[2].matchAll(/<v>([\s\S]*?)<\/v>|<v\/>/g)].map(n=>w(n[1]??""))})),m=e.rel?[...e.rel.matchAll(/<rel\b[^>]*r:id="([^"]+)"/g)].map(a=>a[1]):[],u=new Map;if(e.relRels)for(const a of e.relRels.matchAll(/<Relationship\b[^>]*\/>/g)){const n=/\bId="([^"]+)"/.exec(a[0])?.[1],p=/\bTarget="([^"]+)"/.exec(a[0])?.[1];n&&p&&u.set(n,p)}return t.forEach((a,n)=>{const p=/<rc\b[^>]*\bt="(\d+)"[^>]*\bv="(\d+)"/.exec(a[1]);if(!p||Number(p[1])!==d)return;const c=E[b[Number(p[2])]];if(!c)return;const o=k[c.s];if(!o||o.t!=="_localImage")return;const g=o.keys.indexOf("_rvRel:LocalImageIdentifier"),y=u.get(m[Number(c.v[g])]);if(!y)return;const s=o.keys.indexOf("Text");r.byVm.set(n+1,{target:y,alt:s>=0?c.v[s]:""})}),r}const z=(e,r)=>(e.match(new RegExp(`<${r}\\b`,"g"))??[]).length;function T(e,r,h,d){const f=e.lastIndexOf(`</${r}>`),b=e.slice(0,f)+h+e.slice(f);if(d===void 0)return b;const v=z(b,d);return b.replace(new RegExp(`(<${r}\\b[^>]*?)\\s+count="\\d+"`),"$1").replace(new RegExp(`<${r}\\b`),`<${r} count="${v}"`)}function J(e,r,h,d=null){const f='<metadataType name="XLRICHVALUE" minSupportedVersion="120000" copy="1" pasteAll="1" pasteValues="1" merge="1" splitFirst="1" rowColShift="1" clearFormats="1" clearComments="1" assign="1" coerce="1"/>';let t=e??`${R}<metadata xmlns="${N}" xmlns:xda="http://schemas.microsoft.com/office/spreadsheetml/2017/dynamicarray"><metadataTypes count="${h?1:0}">${h?'<metadataType name="XLDAPR" minSupportedVersion="120000" copy="1" pasteAll="1" pasteValues="1" merge="1" splitFirst="1" rowColShift="1" clearFormats="1" clearComments="1" assign="1" coerce="1" cellMeta="1"/>':""}</metadataTypes>${h?'<futureMetadata name="XLDAPR" count="1"><bk><extLst><ext uri="{bdbb8cdc-fa1e-496e-a857-3c3f30c029c3}"><xda:dynamicArrayProperties fDynamic="1" fCollapsed="0"/></ext></extLst></bk></futureMetadata><cellMetadata count="1"><bk><rc t="1" v="0"/></bk></cellMetadata>':""}</metadata>`;/xmlns:xlrd=/.test(t)||(t=t.replace(/<metadata\b/,`<metadata xmlns:xlrd="${I}"`)),/name="XLRICHVALUE"[^>]*minSupportedVersion/.test(t)||(t=T(t,"metadataTypes",f,"metadataType"));const E=[...t.matchAll(/<metadataType\b[^>]*\bname="([^"]+)"/g)].map(s=>s[1]).indexOf("XLRICHVALUE")+1;if(!/<futureMetadata\b[^>]*name="XLRICHVALUE"/.test(t)){const s=/<cellMetadata\b|<valueMetadata\b|<\/metadata>/.exec(t);t=`${t.slice(0,s.index)}<futureMetadata name="XLRICHVALUE" count="0"></futureMetadata>${t.slice(s.index)}`}const m=/<futureMetadata\b[^>]*name="XLRICHVALUE"[^>]*>([\s\S]*?)<\/futureMetadata>/.exec(t),u=(m[1].match(/<bk>/g)??[]).length,a=[...m[1].matchAll(/\bi="(\d+)"/g)].reduce((s,C)=>Math.max(s,Number(C[1])+1),0);let n="",p=0;for(let s=0;s<r;s++)n+=`<bk><extLst><ext uri="{3e2802c4-a4d2-4d8b-9148-e3be6c30e623}"><xlrd:rvb i="${d?.[s]??a+p++}"/></ext></extLst></bk>`;const c=m[0].replace("</futureMetadata>",`${n}</futureMetadata>`).replace(/count="\d+"/,`count="${u+r}"`);if(t=t.replace(m[0],c),!/<valueMetadata\b/.test(t)){const s=t.lastIndexOf("</metadata>");t=`${t.slice(0,s)}<valueMetadata count="0"></valueMetadata>${t.slice(s)}`}const o=/<valueMetadata\b[^>]*>([\s\S]*?)<\/valueMetadata>/.exec(t),g=(o[1].match(/<bk>/g)??[]).length+1;let y="";for(let s=0;s<r;s++)y+=`<bk><rc t="${E}" v="${u+s}"/></bk>`;return t=t.replace(o[0],o[0].replace("</valueMetadata>",`${y}</valueMetadata>`).replace(/count="\d+"/,`count="${g-1+r}"`)),{xml:t,firstVm:g,rvBase:a}}const K={"image/png":"png","image/jpeg":"jpeg","image/gif":"gif","image/bmp":"bmp","image/webp":"webp"},te=e=>K[e]??"png";function ae(e,r,h,d=[],f=null){const v=[...(f??e.map(()=>({}))).map(l=>l.rv??null),...d.map(()=>null)],{xml:t,rvBase:k,firstVm:E}=J(r.meta,v.length,h,v),m=[],u=(l,i,x,S)=>m.push({path:l,xml:i,override:{partName:`/${l}`,contentType:x},relationship:S?{id:`rId8cRich${m.length}`,type:S,target:`/${l}`}:null});u($.meta,t,G,W);let a=r.struct??`${R}<rvStructures xmlns="${I}" count="0"></rvStructures>`;const n=[...a.matchAll(/<s\b[^>]*\bt="([^"]+)"[^>]*>[\s\S]*?<\/s>/g)],p=l=>{const i=[...a.matchAll(/<s\b[^>]*\bt="([^"]+)"[^>]*>[\s\S]*?<\/s>/g)];let x=i.findIndex(S=>S[0]===l);return x<0&&(x=i.length,a=T(a,"rvStructures",l,"s")),x};let c=n.findIndex(l=>l[0]===A);c<0&&e.length>0&&(c=n.length,a=T(a,"rvStructures",A,"s"));let o=r.rv??`${R}<rvData xmlns="${I}" count="0"></rvData>`;const g=(o.match(/<rv\b/g)??[]).length;c<0&&g!==k&&(c=p(A));const y=d.map(l=>`<rv s="${p(l.shape)}">${l.values.map(i=>`<v>${X(i)}</v>`).join("")}</rv>`).join("");u($.struct,a,_.struct,B),u($.types,r.types??q,_.types,j);let s=r.rel??`${R}<richValueRels xmlns="${H}" xmlns:r="${L}"></richValueRels>`,C=r.relRels??`${R}<Relationships xmlns="http://schemas.openxmlformats.org/package/2006/relationships"></Relationships>`;const V=(s.match(/<rel\b/g)??[]).length;let F="",D="",M="";if(e.forEach((l,i)=>{const x=`rId8c${V+i+1}`;D+=`<rel r:id="${x}"/>`,F+=`<Relationship Id="${x}" Type="${L}/image" Target="../media/${l.path.split("/").pop()}"/>`,M+=`<rv s="${c}"><v>${V+i}</v><v>5</v><v>${X(l.alt??"")}</v></rv>`}),s=T(s,"richValueRels",D),C=C.replace("</Relationships>",`${F}</Relationships>`),g!==k){let l="";for(let i=g;i<k;i++)l+=`<rv s="${c}"><v>0</v><v>5</v><v></v></rv>`;M=l+M}return o=T(o,"rvData",M+y,"rv"),u($.rv,o,_.rv,P),(e.length>0||r.rel)&&(u($.rel,s,_.rel,Y),m.push({path:$.relRels,xml:C,override:null,relationship:null})),m.firstVm=E,m}const U={8:{shape:'<s t="_error"><k n="colOffset" t="i"/><k n="errorType" t="i"/><k n="rwOffset" t="i"/></s>',values:["0","8","0"]},9:{shape:'<s t="_error"><k n="errorType" t="i"/></s>',values:["13"]},10:{shape:'<s t="_error"><k n="errorType" t="i"/></s>',values:["14"]},11:{shape:'<s t="_error"><k n="errorType" t="i"/></s>',values:["9"]},12:{shape:'<s t="_error"><k n="errorType" t="i"/></s>',values:["10"]},13:{shape:'<s t="_error"><k n="errorType" t="i"/><k n="field" t="s"/><k n="subType" t="i"/></s>',values:["12","","0"]},14:{shape:'<s t="_error"><k n="errorType" t="i"/></s>',values:["11"]}},re=e=>U[e]!==void 0,se=e=>U[e];export{W as META_REL,G as META_TYPE,$ as PATHS,te as imageExtension,re as isRichError,J as mergeMetadata,ee as parseRichData,se as richErrorValue,ae as richParts};
2
+ `,P="http://schemas.microsoft.com/office/2017/06/relationships/rdRichValue",B="http://schemas.microsoft.com/office/2017/06/relationships/rdRichValueStructure",j="http://schemas.microsoft.com/office/2017/06/relationships/rdRichValueTypes",Y="http://schemas.microsoft.com/office/2022/10/relationships/richValueRel",W=`${L}/sheetMetadata`,G="application/vnd.openxmlformats-officedocument.spreadsheetml.sheetMetadata+xml",_={rv:"application/vnd.ms-excel.rdrichvalue+xml",struct:"application/vnd.ms-excel.rdrichvaluestructure+xml",types:"application/vnd.ms-excel.rdrichvaluetypes+xml",rel:"application/vnd.ms-excel.richvaluerel+xml"},$={rv:"xl/richData/rdrichvalue.xml",struct:"xl/richData/rdrichvaluestructure.xml",types:"xl/richData/rdRichValueTypes.xml",rel:"xl/richData/richValueRel.xml",relRels:"xl/richData/_rels/richValueRel.xml.rels",meta:"xl/metadata.xml"},A='<s t="_localImage"><k n="_rvRel:LocalImageIdentifier" t="i"/><k n="CalcOrigin" t="i"/><k n="Text" t="s"/></s>',q=`${R}<rvTypesInfo xmlns="${O}" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" mc:Ignorable="x" xmlns:x="${N}"><global><keyFlags><key name="_Self"><flag name="ExcludeFromFile" value="1"/><flag name="ExcludeFromCalcComparison" value="1"/></key><key name="_DisplayString"><flag name="ExcludeFromCalcComparison" value="1"/></key><key name="_Flags"><flag name="ExcludeFromCalcComparison" value="1"/></key><key name="_Format"><flag name="ExcludeFromCalcComparison" value="1"/></key><key name="_SubLabel"><flag name="ExcludeFromCalcComparison" value="1"/></key><key name="_Attribution"><flag name="ExcludeFromCalcComparison" value="1"/></key><key name="_Icon"><flag name="ExcludeFromCalcComparison" value="1"/></key><key name="_Display"><flag name="ExcludeFromCalcComparison" value="1"/></key><key name="_CanonicalPropertyNames"><flag name="ExcludeFromCalcComparison" value="1"/></key><key name="_ClassificationId"><flag name="ExcludeFromCalcComparison" value="1"/></key></keyFlags></global></rvTypesInfo>`;function ee(e){const r={vmCount:0,byVm:new Map};if(!e.meta)return r;const d=[...e.meta.matchAll(/<metadataType\b[^>]*\bname="([^"]+)"/g)].map(a=>a[1]).indexOf("XLRICHVALUE")+1,f=/<futureMetadata\b[^>]*name="XLRICHVALUE"[^>]*>([\s\S]*?)<\/futureMetadata>/.exec(e.meta),b=f?[...f[1].matchAll(/<bk>([\s\S]*?)<\/bk>/g)].map(a=>Number(/\bi="(\d+)"/.exec(a[1])?.[1]??-1)):[],v=/<valueMetadata\b[^>]*>([\s\S]*?)<\/valueMetadata>/.exec(e.meta),t=v?[...v[1].matchAll(/<bk>([\s\S]*?)<\/bk>/g)]:[];if(r.vmCount=t.length,!d||!e.rv||!e.struct)return r;const k=[...e.struct.matchAll(/<s\b[^>]*\bt="([^"]+)"[^>]*>([\s\S]*?)<\/s>/g)].map(a=>({t:a[1],keys:[...a[2].matchAll(/<k\b[^>]*\bn="([^"]+)"/g)].map(n=>n[1])})),E=[...e.rv.matchAll(/<rv\b[^>]*\bs="(\d+)"[^>]*>([\s\S]*?)<\/rv>/g)].map(a=>({s:Number(a[1]),v:[...a[2].matchAll(/<v>([\s\S]*?)<\/v>|<v\/>/g)].map(n=>w(n[1]??""))})),m=e.rel?[...e.rel.matchAll(/<rel\b[^>]*r:id="([^"]+)"/g)].map(a=>a[1]):[],u=new Map;if(e.relRels)for(const a of e.relRels.matchAll(/<Relationship\b[^>]*\/>/g)){const n=/\bId="([^"]+)"/.exec(a[0])?.[1],p=/\bTarget="([^"]+)"/.exec(a[0])?.[1];n&&p&&u.set(n,p)}return t.forEach((a,n)=>{const p=/<rc\b[^>]*\bt="(\d+)"[^>]*\bv="(\d+)"/.exec(a[1]);if(!p||Number(p[1])!==d)return;const c=E[b[Number(p[2])]];if(!c)return;const o=k[c.s];if(!o||o.t!=="_localImage")return;const g=o.keys.indexOf("_rvRel:LocalImageIdentifier"),y=u.get(m[Number(c.v[g])]);if(!y)return;const s=o.keys.indexOf("Text");r.byVm.set(n+1,{target:y,alt:s>=0?c.v[s]:""})}),r}const z=(e,r)=>(e.match(new RegExp(`<${r}\\b`,"g"))??[]).length;function T(e,r,h,d){const f=e.lastIndexOf(`</${r}>`),b=e.slice(0,f)+h+e.slice(f);if(d===void 0)return b;const v=z(b,d);return b.replace(new RegExp(`(<${r}\\b[^>]*?)\\s+count="\\d+"`),"$1").replace(new RegExp(`<${r}\\b`),()=>`<${r} count="${v}"`)}function J(e,r,h,d=null){const f='<metadataType name="XLRICHVALUE" minSupportedVersion="120000" copy="1" pasteAll="1" pasteValues="1" merge="1" splitFirst="1" rowColShift="1" clearFormats="1" clearComments="1" assign="1" coerce="1"/>';let t=e??`${R}<metadata xmlns="${N}" xmlns:xda="http://schemas.microsoft.com/office/spreadsheetml/2017/dynamicarray"><metadataTypes count="${h?1:0}">${h?'<metadataType name="XLDAPR" minSupportedVersion="120000" copy="1" pasteAll="1" pasteValues="1" merge="1" splitFirst="1" rowColShift="1" clearFormats="1" clearComments="1" assign="1" coerce="1" cellMeta="1"/>':""}</metadataTypes>${h?'<futureMetadata name="XLDAPR" count="1"><bk><extLst><ext uri="{bdbb8cdc-fa1e-496e-a857-3c3f30c029c3}"><xda:dynamicArrayProperties fDynamic="1" fCollapsed="0"/></ext></extLst></bk></futureMetadata><cellMetadata count="1"><bk><rc t="1" v="0"/></bk></cellMetadata>':""}</metadata>`;/xmlns:xlrd=/.test(t)||(t=t.replace(/<metadata\b/,()=>`<metadata xmlns:xlrd="${I}"`)),/name="XLRICHVALUE"[^>]*minSupportedVersion/.test(t)||(t=T(t,"metadataTypes",f,"metadataType"));const E=[...t.matchAll(/<metadataType\b[^>]*\bname="([^"]+)"/g)].map(s=>s[1]).indexOf("XLRICHVALUE")+1;if(!/<futureMetadata\b[^>]*name="XLRICHVALUE"/.test(t)){const s=/<cellMetadata\b|<valueMetadata\b|<\/metadata>/.exec(t);t=`${t.slice(0,s.index)}<futureMetadata name="XLRICHVALUE" count="0"></futureMetadata>${t.slice(s.index)}`}const m=/<futureMetadata\b[^>]*name="XLRICHVALUE"[^>]*>([\s\S]*?)<\/futureMetadata>/.exec(t),u=(m[1].match(/<bk>/g)??[]).length,a=[...m[1].matchAll(/\bi="(\d+)"/g)].reduce((s,C)=>Math.max(s,Number(C[1])+1),0);let n="",p=0;for(let s=0;s<r;s++)n+=`<bk><extLst><ext uri="{3e2802c4-a4d2-4d8b-9148-e3be6c30e623}"><xlrd:rvb i="${d?.[s]??a+p++}"/></ext></extLst></bk>`;const c=m[0].replace("</futureMetadata>",()=>`${n}</futureMetadata>`).replace(/count="\d+"/,()=>`count="${u+r}"`);if(t=t.replace(m[0],()=>c),!/<valueMetadata\b/.test(t)){const s=t.lastIndexOf("</metadata>");t=`${t.slice(0,s)}<valueMetadata count="0"></valueMetadata>${t.slice(s)}`}const o=/<valueMetadata\b[^>]*>([\s\S]*?)<\/valueMetadata>/.exec(t),g=(o[1].match(/<bk>/g)??[]).length+1;let y="";for(let s=0;s<r;s++)y+=`<bk><rc t="${E}" v="${u+s}"/></bk>`;return t=t.replace(o[0],()=>o[0].replace("</valueMetadata>",()=>`${y}</valueMetadata>`).replace(/count="\d+"/,()=>`count="${g-1+r}"`)),{xml:t,firstVm:g,rvBase:a}}const K={"image/png":"png","image/jpeg":"jpeg","image/gif":"gif","image/bmp":"bmp","image/webp":"webp"},te=e=>K[e]??"png";function ae(e,r,h,d=[],f=null){const v=[...(f??e.map(()=>({}))).map(l=>l.rv??null),...d.map(()=>null)],{xml:t,rvBase:k,firstVm:E}=J(r.meta,v.length,h,v),m=[],u=(l,i,x,S)=>m.push({path:l,xml:i,override:{partName:`/${l}`,contentType:x},relationship:S?{id:`rId8cRich${m.length}`,type:S,target:`/${l}`}:null});u($.meta,t,G,W);let a=r.struct??`${R}<rvStructures xmlns="${I}" count="0"></rvStructures>`;const n=[...a.matchAll(/<s\b[^>]*\bt="([^"]+)"[^>]*>[\s\S]*?<\/s>/g)],p=l=>{const i=[...a.matchAll(/<s\b[^>]*\bt="([^"]+)"[^>]*>[\s\S]*?<\/s>/g)];let x=i.findIndex(S=>S[0]===l);return x<0&&(x=i.length,a=T(a,"rvStructures",l,"s")),x};let c=n.findIndex(l=>l[0]===A);c<0&&e.length>0&&(c=n.length,a=T(a,"rvStructures",A,"s"));let o=r.rv??`${R}<rvData xmlns="${I}" count="0"></rvData>`;const g=(o.match(/<rv\b/g)??[]).length;c<0&&g!==k&&(c=p(A));const y=d.map(l=>`<rv s="${p(l.shape)}">${l.values.map(i=>`<v>${X(i)}</v>`).join("")}</rv>`).join("");u($.struct,a,_.struct,B),u($.types,r.types??q,_.types,j);let s=r.rel??`${R}<richValueRels xmlns="${H}" xmlns:r="${L}"></richValueRels>`,C=r.relRels??`${R}<Relationships xmlns="http://schemas.openxmlformats.org/package/2006/relationships"></Relationships>`;const V=(s.match(/<rel\b/g)??[]).length;let F="",D="",M="";if(e.forEach((l,i)=>{const x=`rId8c${V+i+1}`;D+=`<rel r:id="${x}"/>`,F+=`<Relationship Id="${x}" Type="${L}/image" Target="../media/${l.path.split("/").pop()}"/>`,M+=`<rv s="${c}"><v>${V+i}</v><v>5</v><v>${X(l.alt??"")}</v></rv>`}),s=T(s,"richValueRels",D),C=C.replace("</Relationships>",()=>`${F}</Relationships>`),g!==k){let l="";for(let i=g;i<k;i++)l+=`<rv s="${c}"><v>0</v><v>5</v><v></v></rv>`;M=l+M}return o=T(o,"rvData",M+y,"rv"),u($.rv,o,_.rv,P),(e.length>0||r.rel)&&(u($.rel,s,_.rel,Y),m.push({path:$.relRels,xml:C,override:null,relationship:null})),m.firstVm=E,m}const U={8:{shape:'<s t="_error"><k n="colOffset" t="i"/><k n="errorType" t="i"/><k n="rwOffset" t="i"/></s>',values:["0","8","0"]},9:{shape:'<s t="_error"><k n="errorType" t="i"/></s>',values:["13"]},10:{shape:'<s t="_error"><k n="errorType" t="i"/></s>',values:["14"]},11:{shape:'<s t="_error"><k n="errorType" t="i"/></s>',values:["9"]},12:{shape:'<s t="_error"><k n="errorType" t="i"/></s>',values:["10"]},13:{shape:'<s t="_error"><k n="errorType" t="i"/><k n="field" t="s"/><k n="subType" t="i"/></s>',values:["12","","0"]},14:{shape:'<s t="_error"><k n="errorType" t="i"/></s>',values:["11"]}},re=e=>U[e]!==void 0,se=e=>U[e];export{W as META_REL,G as META_TYPE,$ as PATHS,te as imageExtension,re as isRichError,J as mergeMetadata,ee as parseRichData,se as richErrorValue,ae as richParts};
@@ -0,0 +1,2 @@
1
+ import{child as A,children as g,parseTree as _,unescapeOoxml as j}from"../io/xml-scan.js";import{xmlAttr as V}from"../io/xml-escape.js";import{rangeRef as C}from"../core/address.js";import{newGuid as N}from"../core/custom-views.js";import{viewTableKey as F}from"../core/shared-view.js";import{dxfXml as P}from"../io/xlsx-tail.js";import{columnBodyXml as W,parseColumnBody as k}from"./filter-file.js";import{parseDxfNode as z}from"./cf-file.js";const S="http://schemas.microsoft.com/office/spreadsheetml/2019/namedsheetviews",v="http://schemas.openxmlformats.org/spreadsheetml/2006/main",B="http://schemas.microsoft.com/office/spreadsheetml/2009/9/main",D="http://schemas.microsoft.com/office/spreadsheetml/2017/richdata2",te="application/vnd.ms-excel.namedsheetviews+xml",ne="http://schemas.microsoft.com/office/2019/04/relationships/namedSheetView",L=new TextEncoder,M=n=>`<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
2
+ <namedSheetViews xmlns="${S}" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:x="${v}" xmlns:x14="${B}" xmlns:xlrd2="${D}" mc:Ignorable="x14 xlrd2">${n}</namedSheetViews>`,oe=M("");function h(n,e){const t=new RegExp(`\\bxmlns(?::([\\w.-]+))?="${e.replace(/[.]/g,"\\.")}"`).exec(n);return t?t[1]??"":null}const U=/<([\w.-]+:)?sortRules\b(?:[^>]*\/>|[\s\S]*?<\/\1sortRules>)/,Y=(n,e)=>t=>{let s=!0;const o=t.replace(/<(\/?)(?:([\w.-]+):)?(?=[A-Za-z_])/g,(r,c,i="")=>i===n?`<${c}`:i===e?`<${c}x:`:(/^(x14|xlrd2|mc)$/.test(i)||(s=!1),r));return s&&!/\s(?!xmlns|xml:)[\w.-]+:[\w.-]+\s*=/.test(o)?o:""};function se(n,e){try{const t=new TextDecoder().decode(n),s=[h(t,S),h(t,v)].filter(l=>l),o=s.length?t.replace(new RegExp(`(</?)(?:${s.join("|")}):`,"g"),"$1"):t,r=_(L.encode(o)),c=Y(h(t,S),h(t,v)),i=[...t.matchAll(/<(?:[\w.-]+:)?nsvFilter\b[^>]*?(?:\/>|>([\s\S]*?)<\/(?:[\w.-]+:)?nsvFilter>)/g)].map(l=>({rest:c(U.exec(l[1]??"")?.[0]??""),bodies:[...(l[1]??"").matchAll(/<(?:[\w.-]+:)?columnFilter\b[^>]*?(?:\/>|>([\s\S]*?)<\/(?:[\w.-]+:)?columnFilter>)/g)].map(m=>c(/<(?:[\w.-]+:)?filter\b(?:[^>]*[^>/])?>([\s\S]*)<\/(?:[\w.-]+:)?filter>/.exec(m[1]??"")?.[1]??""))}));let f=0;const a=[];for(const l of g(r,"namedSheetView")){const m=[];for(const u of g(l,"nsvFilter")){const p=[],{rest:d,bodies:w}=i[f++];let $=0;for(const b of g(u,"columnFilter")){const R=w[$++],I=A(b,"filter"),x=I?k(I,R):null;if(!x||x.kind==="raw"&&!R)continue;const T=A(b,"dxf");x.kind==="color"&&T&&(x.dxf=z(T,e)),p.push([Number(b.a.colId??I.a.colId??0),x])}const y=Number(u.a.tableId??0);m.push({...y?{tableId:y}:{},columns:p,uid:u.a.filterId,...d?{rest:d}:{}})}a.push({id:l.a.id??N(),name:j(l.a.name??""),filters:m})}return a}catch{return[]}}function re(n){for(const e of n.sheets){if(!e.namedViews)continue;const t=new Map(E(n,e).map(s=>[s.id,F(s)]));for(const s of e.namedViews)for(const o of s.filters){o.tableId!==void 0&&(o.table=t.get(o.tableId),o.table===void 0&&(o.table=`\0${o.tableId}`),delete o.tableId);for(const[,r]of o.columns)r.dxf&&(n.dxfs??=[],r.dxfId=n.dxfs.push(r.dxf)-1,delete r.dxf)}}}function ie(n){for(const e of n.sheets)if(!(!e.namedViewsChanged||!e.namedViews)){e.autoFilter&&!e.autoFilter.uid&&(e.autoFilter={...e.autoFilter,uid:O(e,void 0)},e.filterChanged=!0);for(const t of E(n,e)){const s=F(t);!t.filter||t.filter.uid||!e.namedViews.some(o=>o.filters.some(r=>r.table===s))||(t.filter={...t.filter,uid:O(e,s)},t.dirty=!0)}}}const O=(n,e)=>n.namedViews.flatMap(t=>t.filters).find(t=>t.table===e&&t.uid)?.uid??N(),E=(n,e)=>[...n.engine?.tables.values()??[]].filter(t=>t.sheet===e),X=n=>n.replace(/<(\/?)([a-zA-Z])/g,"<$1x:$2");function le(n,e){if(!e.namedViews?.length)return"";const t=new Map(E(n,e).map(o=>[F(o),o])),s=e.namedViews.map(o=>{const r=o.filters.map(i=>{const f=i.table===void 0?null:t.get(i.table);if(f===void 0)return"";const a=f?f.filter:e.autoFilter,l=a?.uid??i.uid;if(!l)return"";const m=i.columns.map(([p,d])=>{const w=d.kind==="color"&&d.dxfId!==void 0&&n.dxfs?.[d.dxfId]?P(n.dxfs[d.dxfId]):"",$=w.replace(/^<dxf[^>]*>|<\/dxf>$/g,"");return`<columnFilter colId="${p}">${w?`<dxf>${X($)}</dxf>`:""}<filter colId="${p}">${d.kind==="raw"?d.xml:X(W(d))}</filter></columnFilter>`}).join(""),u=a?` ref="${C(a)}"`:"";return`<nsvFilter filterId="${V(l)}"${u} tableId="${f?f.id??0:0}">${m}${i.rest??""}</nsvFilter>`}).join(""),c=`<namedSheetView name="${V(o.name)}" id="${V(o.id)}"`;return r?`${c}>${r}</namedSheetView>`:`${c}/>`}).join("");return M(s)}export{oe as EMPTY_VIEWS,ne as VIEWS_REL,te as VIEWS_TYPE,re as adoptViews,le as namedViewsXml,se as parseNamedViews,ie as prepareViews};
@@ -1 +1 @@
1
- import{MAX_COLS as b,MAX_ROWS as w}from"../core/address.js";import{rectsTouch as l}from"./block.js";const R="This operation is not allowed. The operation is attempting to shift cells in a table on your worksheet.",M="We can't do that to a merged cell.",S="To prevent possible loss of data, cells can't be shifted off the end of the sheet.",T="You can't change part of an array.",A="The header row of a table cannot be deleted on its own.";function _(s,t,n,i,a=0,u=b-1){for(const r of s.engine?.tables.values()??[])if(r.sheet===t&&r.headerRows&&r.c0<=u&&r.c1>=a&&n<=r.r0&&i>=r.r0&&i<r.r1)return!0;return!1}function O(s,t,n,i,a,u=[]){const r=i==="down";if(r&&a<0&&_(s,t,n.r0,n.r1,n.c0,n.c1))return A;const g=r?n.r1-n.r0+1:n.c1-n.c0+1,f=r?{r0:n.r0,r1:w-1,c0:n.c0,c1:n.c1}:{r0:n.r0,r1:n.r1,c0:n.c0,c1:b-1},d=o=>r?o.c0>=n.c0&&o.c1<=n.c1:o.r0>=n.r0&&o.r1<=n.r1,c=r?n.r0:n.c0,h=o=>r?o.r0:o.c0,p=o=>r?o.r1:o.c1,m=o=>{if(a>0)return h(o)<c&&p(o)>=c;const e=c+g-1;return h(o)<=e&&p(o)>e||h(o)<c&&p(o)>=c};for(const o of t.merges)if(l(o,f)&&(!d(o)||m(o)))return M;if(u.some(o=>o.anchor?.sheet===t&&o.renderedRange&&l(o.renderedRange,f)))return"Cannot change this part of a PivotTable report.";if(s.engine){const o=e=>r?e.c0===n.c0&&e.c1===n.c1:e.r0===n.r0&&e.r1===n.r1;for(const e of s.engine.tables.values())if(!(e.sheet!==t||!l(e,f))&&(!d(e)||m(e)&&!o(e)))return R}if(t.spills){for(const o of t.spills.values())if(o.fixed&&l(o,f)&&(!d(o)||m(o)))return T}if(a>0){const o=r?t.maxRow:t.maxCol,e=r?w:b;if(o+g>=e)return S}return null}export{T as MSG_ARRAY,A as MSG_HEADER,M as MSG_MERGE,S as MSG_OFF,R as MSG_TABLE,O as checkBandShift,_ as deletesTableHeader};
1
+ import{MAX_COLS as T,MAX_ROWS as M,parseRangeRef as R}from"../core/address.js";import{rectsTouch as d}from"./block.js";const x="This operation is not allowed. The operation is attempting to shift cells in a table on your worksheet.",S="We can't do that to a merged cell.",_="To prevent possible loss of data, cells can't be shifted off the end of the sheet.",g="You can't change part of an array.",w="You can't change part of a data table.",v="The header row of a table cannot be deleted on its own.";function G(e,t,o,a,i=0,c=T-1){for(const n of e.engine?.tables.values()??[])if(n.sheet===t&&n.headerRows&&n.c0<=c&&n.c1>=i&&o<=n.r0&&a>=n.r0&&a<n.r1)return!0;return!1}function E(e,{axis:t,at:o,n:a}){if(!e.spills)return!1;const i=a>0?o:o-a;for(const c of e.spills.values()){if(!c.fixed)continue;const[n,f]=t==="row"?[c.r0,c.r1]:[c.c0,c.c1];if(f>=o&&n<i&&(a>0||n<o||f>=i))return!0}return!1}const O=e=>({...e,r0:Math.max(0,e.r0-1),c0:Math.max(0,e.c0-1)});function*A(e){for(const t of e.formulas?.descriptors?.()??[]){const o=t.t==="dataTable"?R(t.ref):null;o&&(yield O(o))}}const C=(e,t,o)=>[...A(e)].some(a=>Math.max(a.r0,t)<Math.min(a.r1,o+1));function L(e,t){if(E(e,t))return g;const{axis:o,at:a,n:i}=t,c=a-i;for(const n of A(e)){const[f,l]=o==="row"?[n.r0,n.r1]:[n.c0,n.c1];if(i>0?f<a&&a<=l:a<=l&&c>f&&!(a<=f&&c>l))return w}return null}function Y(e,t,o,a,i,c=[]){const n=a==="down";if(n&&i<0&&G(e,t,o.r0,o.r1,o.c0,o.c1))return v;const f=n?o.r1-o.r0+1:o.c1-o.c0+1,l=n?{r0:o.r0,r1:M-1,c0:o.c0,c1:o.c1}:{r0:o.r0,r1:o.r1,c0:o.c0,c1:T-1},p=r=>n?r.c0>=o.c0&&r.c1<=o.c1:r.r0>=o.r0&&r.r1<=o.r1,u=n?o.r0:o.c0,m=r=>n?r.r0:r.c0,b=r=>n?r.r1:r.c1,h=r=>{if(i>0)return m(r)<u&&b(r)>=u;const s=u+f-1;return m(r)<=s&&b(r)>s||m(r)<u&&b(r)>=u};for(const r of t.merges)if(d(r,l)&&(!p(r)||h(r)))return S;if(c.some(r=>r.anchor?.sheet===t&&r.renderedRange&&d(r.renderedRange,l)))return"Cannot change this part of a PivotTable report.";if(e.engine){const r=s=>n?s.c0===o.c0&&s.c1===o.c1:s.r0===o.r0&&s.r1===o.r1;for(const s of e.engine.tables.values())if(!(s.sheet!==t||!d(s,l))&&(!p(s)||h(s)&&!r(s)))return x}if(t.spills){for(const r of t.spills.values())if(r.fixed&&d(r,l)&&(!p(r)||h(r)))return g}for(const r of A(t))if(d(r,l)&&(!p(r)||h(r)))return w;if(i>0){const r=n?t.maxRow:t.maxCol,s=n?M:T;if(r+f>=s)return _}return null}export{g as MSG_ARRAY,w as MSG_DATA_TABLE,v as MSG_HEADER,S as MSG_MERGE,_ as MSG_OFF,x as MSG_TABLE,Y as checkBandShift,C as dataTableBeside,G as deletesTableHeader,E as splitsArray,L as structureProblem};
@@ -0,0 +1 @@
1
+ const e=new Map;function n(r,t,{label:o=r}={}){if(typeof r!="string"||r==="")throw new TypeError("A sort compare function needs a name");if(typeof t!="function")throw new TypeError("registerSortCompare needs a function");e.set(r,{name:r,label:o,compare:t})}function i(r){e.delete(r)}const s=()=>[...e.values()];function p(r){return typeof r=="function"?r:e.get(r)?.compare??null}export{n as registerSortCompare,p as resolveSortCompare,s as sortCompares,i as unregisterSortCompare};
package/cells/ui-kit.js CHANGED
@@ -12,4 +12,4 @@ import{el as x,showMessage as k}from"../ui/dialogs.js";import{t as h}from"../i18
12
12
  .clip-group legend { padding: 0; margin-bottom: 2px; color: var(--ink-soft); font-size: 11px; }
13
13
  .clip-lists { display: grid; grid-template-columns: 200px 1fr; gap: 12px; min-height: 240px; }
14
14
  .clip-lists textarea { width: 100%; height: 200px; resize: none; }
15
- `,document.head.append(t)}function M(){g()}const C="8sheets";function T(t,e,s=C){return t.shell?.setStatus(e),k(t,s,e),null}let n=null;function z(t,e,s,c){g(),(!n||n.parentElement!==t.grid.host)&&(n?.remove(),n=x("div",{class:"drag-tip"}),t.grid.host.append(n)),n.textContent=c,n.style.left=`${e+14}px`,n.style.top=`${s+12}px`,n.hidden=!1}function H(){n&&(n.hidden=!0)}const B={paste:'<svg width="14" height="14" viewBox="0 0 14 14" fill="none" stroke="currentColor"><rect x="2.5" y="2.5" width="9" height="10" rx="1"/><rect x="5" y="1" width="4" height="3" rx="0.5" fill="currentColor" stroke="none"/></svg>',fill:'<svg width="14" height="14" viewBox="0 0 14 14" fill="none" stroke="currentColor"><rect x="2" y="2" width="4" height="4"/><rect x="8" y="2" width="4" height="4"/><rect x="2" y="8" width="4" height="4"/><path d="M9 10h3M10.5 8.5v3"/></svg>'},E='<svg width="7" height="14" viewBox="0 0 7 14" fill="currentColor"><path d="M0.5 6l3 3 3-3z"/></svg>';function L(t,e,s,c,v){g(),m(t);const{grid:r,book:l}=t,i=x("button",{type:"button",class:"corner-btn",title:h(c),"aria-label":h(c)});i.innerHTML=`${B[s]}${E}`;const b=l.undoStack[l.undoStack.length-1],w=l.sheet,p={place(){if(t.book!==l||l.sheet!==w||l.undoStack[l.undoStack.length-1]!==b||t.controller.isEditing){m(t);return}const o=r.cellRect(e.r1,e.c1),d=o.x+o.w+2,a=o.y+o.h+2,u=d<r.rowHeaderW||a<r.colHeaderH||d>r.cssW-10||a>r.cssH-10;if(i.hidden=u,!u){const y=r.rtl?r.domRect({x:d,w:28}).x:d;i.style.left=`${y}px`,i.style.top=`${a}px`}},remove(){i.remove()}};return i.addEventListener("pointerdown",o=>{o.preventDefault(),o.stopPropagation()}),i.addEventListener("dblclick",o=>o.stopPropagation()),i.addEventListener("click",o=>{o.stopPropagation();const d=i.getBoundingClientRect();t.ribbon.openMenuAt(d.left,d.bottom+2,v())}),r.host.append(i),r.cornerButton=p,p.place(),r.invalidateTop(),p}function m(t){const{grid:e}=t;e.cornerButton&&(e.cornerButton.remove(),e.cornerButton=null)}const P=(t,e,s)=>[`${e?"✓ ":"  "}${h(t)}`,s];export{C as APP_TITLE,P as checkedItem,M as ensureClipStyle,m as hideCornerButton,H as hideTip,L as showCornerButton,T as showMessage,z as showTip};
15
+ `,document.head.append(t)}function $(){g()}const C="8sheets";function z(t,e,l=C){return t.shell?.setStatus(e),k(t,l,e),null}let n=null;function L(t,e,l,c){g(),(!n||n.parentElement!==t.grid.host)&&(n?.remove(),n=x("div",{class:"drag-tip"}),t.grid.host.append(n)),n.textContent=c,n.style.left=`${e+14}px`,n.style.top=`${l+12}px`,n.hidden=!1}function T(){n&&(n.hidden=!0)}const B={paste:'<svg width="14" height="14" viewBox="0 0 14 14" fill="none" stroke="currentColor"><rect x="2.5" y="2.5" width="9" height="10" rx="1"/><rect x="5" y="1" width="4" height="3" rx="0.5" fill="currentColor" stroke="none"/></svg>',auto:'<svg width="14" height="14" viewBox="0 0 14 14" fill="none" stroke="currentColor"><path d="M8 1L3 8h3.5L6 13l5-7H7.5z"/></svg>',fill:'<svg width="14" height="14" viewBox="0 0 14 14" fill="none" stroke="currentColor"><rect x="2" y="2" width="4" height="4"/><rect x="8" y="2" width="4" height="4"/><rect x="2" y="8" width="4" height="4"/><path d="M9 10h3M10.5 8.5v3"/></svg>'},E='<svg width="7" height="14" viewBox="0 0 7 14" fill="currentColor"><path d="M0.5 6l3 3 3-3z"/></svg>';function H(t,e,l,c,m){g(),v(t);const{grid:r,book:s}=t,i=x("button",{type:"button",class:"corner-btn",title:h(c),"aria-label":h(c)});i.innerHTML=`${B[l]}${E}`;const w=s.undoStack[s.undoStack.length-1],b=s.sheet,p={place(){if(t.book!==s||s.sheet!==b||s.undoStack[s.undoStack.length-1]!==w||t.controller.isEditing){v(t);return}const o=r.cellRect(e.r1,e.c1),d=o.x+o.w+2,a=o.y+o.h+2,u=d<r.rowHeaderW||a<r.colHeaderH||d>r.cssW-10||a>r.cssH-10;if(i.hidden=u,!u){const y=r.rtl?r.domRect({x:d,w:28}).x:d;i.style.left=`${y}px`,i.style.top=`${a}px`}},remove(){i.remove()}};return i.addEventListener("pointerdown",o=>{o.preventDefault(),o.stopPropagation()}),i.addEventListener("dblclick",o=>o.stopPropagation()),i.addEventListener("click",o=>{o.stopPropagation();const d=i.getBoundingClientRect();t.ribbon.openMenuAt(d.left,d.bottom+2,m())}),r.host.append(i),r.cornerButton=p,p.place(),r.invalidateTop(),p}function v(t){const{grid:e}=t;e.cornerButton&&(e.cornerButton.remove(),e.cornerButton=null)}const P=(t,e,l)=>[`${e?"✓ ":"  "}${h(t)}`,l];export{C as APP_TITLE,P as checkedItem,$ as ensureClipStyle,v as hideCornerButton,T as hideTip,H as showCornerButton,z as showMessage,L as showTip};
@@ -1 +1 @@
1
- import{CellLog as f}from"../core/workbook.js";import{growTableOver as h}from"../core/tables.js";function g(e,t,i,{withPrevious:d=!1}={}){const n=e.undoStack[e.undoStack.length-1];if(i(),e.undoStack[e.undoStack.length-1]===n)return;const o=n===void 0?0:e.undoStack.lastIndexOf(n)+1,l=d?Math.max(0,o-1):o,s=e.undoStack.splice(l);if(s.length===0)return;const u=c=>()=>{const a=[];for(let r=c.length-1;r>=0;r--)a.push(e._restore(c[r]));return u(a)};e.undoStack.push({sheetIndex:e.activeSheet,sheet:e.sheet,log:new f,label:t,extra:u(s)})}function m(e,t){!e.book.engine||e.slicers?.autoExpands===!1||g(e.book,"paste",()=>h(e.book,e.book.sheet,t),{withPrevious:!0})}export{m as growTableAfter,g as undoGroup};
1
+ import{CellLog as c,foldEntries as i}from"../core/workbook.js";import{growTableOver as d}from"../core/tables.js";function l(t,e,o,{withPrevious:u=!1}={}){const n=t.undoStack[t.undoStack.length-1];if(o(),t.undoStack[t.undoStack.length-1]===n)return;const r=n===void 0?0:t.undoStack.lastIndexOf(n)+1,a=u?Math.max(0,r-1):r,s=t.undoStack.splice(a);s.length!==0&&t.undoStack.push({sheetIndex:t.activeSheet,sheet:t.sheet,log:new c,label:e,extra:i(t,s)})}function g(t,e){!t.book.engine||t.slicers?.autoExpands===!1||l(t.book,"paste",()=>d(t.book,t.book.sheet,e),{withPrevious:!0})}export{g as growTableAfter,l as undoGroup};
@@ -1,4 +1,4 @@
1
- import{cellEditable as dt}from"../core/protection.js";import{allUndo as pt}from"../cells/block.js";import{writeCellTypes as ft}from"../core/cell-type-rules.js";import{formulaEntryLimit as ht}from"../calc/parser.js";import{overlayRoot as mt}from"../api/overlay.js";import{BOOL as yt,EMPTY as gt,ERR as xt,ERRORS as vt,FORMULA as bt,KIND_MASK as Z,NUM as wt,STR as kt}from"../core/sheet.js";import{MAX_COLS as Ct,MAX_ROWS as Dt,parseRangeRef as St}from"../core/address.js";import{partsToSerial as N,serialToParts as P}from"../core/numfmt.js";import{validateEntry as Lt,validationAt as Et}from"../core/cond-format.js";import{parseInput as At}from"../core/input.js";import{askAboutInvalid as Ft}from"../cells/validation-alert.js";import{t as k}from"../i18n/index.js";const z=(e,t)=>e*16384+t,G=["calendar","time","month","datetime","color","slider","calculator","list"],j=new Map;function he(e,t){G.includes(e)||G.push(e),j.set(e,t)}const Mt=2e5,tt=5e3,K={calendar:"yyyy-mm-dd",time:"h:mm:ss",month:"mmm yyyy",datetime:"yyyy-mm-dd h:mm:ss"};function Y(e,t,n,o){const r=t.kind(n,o)&Z;if(r===gt)return null;const s=t.value(n,o);return r===wt?s:r===kt?e.strings.get(s):r===yt?s!==0:r===xt?vt[s]??"#N/A":null}function Tt(e){const t=String(e??"");return t[0]==="="||t[0]==="'"?`'${t}`:t}function V(e,t,n,{overFormula:o=!1}={}){const{book:r}=e,{sheet:s}=r;return e.loading?!1:s.protection&&!dt(r,s,t,n)?(e.shell.setStatus("This cell is on a protected sheet. Unprotect the sheet to change it."),!1):!o&&(s.kind(t,n)&bt)!==0?(e.shell.setStatus("This cell's value comes from a formula, so this control can't change it."),!1):!0}function Rt(e,t,n,o,r){const{book:s}=e,{sheet:u}=s,i=Et(u,t,n);if(!i||!i.showError)return!0;const l=At(o);if(Lt(s,u,i,t,n,l.kind??0,l.value,l.text??o))return!0;const a=()=>{};return Ft(e,i,{retry:a,cancel:a,accept:i.errorStyle==="warning"||i.errorStyle==="information"?r:a}),!1}function It(e,t,n,o,{format:r,overFormula:s=!1}={}){if(!V(e,t,n,{overFormula:s}))return!1;if(o.startsWith("=")&&e.book.styles.get(e.book.sheet.style(t,n)).numFmt!=="@"){const u=ht(o.slice(1));if(u)return e.shell.setStatus(k(u)),!1}return Rt(e,t,n,o,()=>et(e,t,n,o,r))?et(e,t,n,o,r):!1}function et(e,t,n,o,r){const{book:s,grid:u,controller:i}=e,l=s.sheet;return s.transact("entry",a=>{s.setInput(a,t,n,o),r&&s.styles.get(l.style(t,n)).numFmt==="General"&&l.setStyle(t,n,s.styles.derive(l.style(t,n),{numFmt:r}))}),e.commands?.afterEntry?.(t,n),u.invalidate(),i.syncFormulaBar(),!0}const q=(e,t)=>n=>{const o=q(e,n[e]??null);return n[e]=t,n.cellTypesChanged=!0,o};function $t(e,{r0:t,c0:n,r1:o,c1:r}){const s=t===0&&o===Dt-1,u=n===0&&r===Ct-1;return{r0:t,c0:n,r1:s?Math.max(e.maxRow,999):o,c1:u?Math.max(e.maxCol,25):r}}function me(e,t,n,o){const r=e.sheet;if(n==="cellTypes")return e.transact("cell type",i=>{const l=i.sheet,a=l.cellTypes,y=l.cellTypeRules;return ft(l,t,o),l.cellTypes===a&&l.cellTypeRules===y?null:pt([q(n,a),q("cellTypeRules",y)])}),!0;const s=t.map(i=>$t(r,i));let u=0;for(const i of s)u+=(i.r1-i.r0+1)*(i.c1-i.c0+1);return u>Mt?!1:(e.transact("cell type",()=>{const i=q(n,r[n]??null),l=new Map(r[n]??[]);for(const a of s)for(let y=a.r0;y<=a.r1;y++)for(let x=a.c0;x<=a.c1;x++)o===null?l.delete(z(y,x)):l.set(z(y,x),o);return r[n]=l.size>0?l:null,r.cellTypesChanged=!0,i}),!0)}function ye(e,t={}){if(!G.includes(e))return null;const n={type:e},o=r=>{Number.isFinite(t[r])&&(n[r]=t[r])};return typeof t.format=="string"&&t.format.length<=64&&(n.format=t.format),e==="slider"&&(o("min"),o("max"),o("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,tt).filter(Array.isArray).map(r=>r.slice(0,50).map(s=>typeof s=="number"?s:String(s).slice(0,1e3))))),j.get(e)?.sanitize?.(t,n),Object.freeze(n)}function nt(e,t,n){const o=e.cellDropdowns;if(!o)return null;const r=e.mergeAt(t,n);return o.get(r?z(r.r0,r.c0):z(t,n))??null}function ge(e){const{sheet:t,sel:n,grid:o}=e;if(!t.cellDropdowns||!nt(t,n.row,n.col))return null;const r=o.cellRect(n.row,n.col),s=Math.min(16,r.h);return{x:r.x+r.w+1,y:r.y+r.h-s,size:s}}const rt="ct-popup-style",Ot=`
1
+ import{cellEditable as dt}from"../core/protection.js";import{allUndo as pt}from"../cells/block.js";import{writeCellTypes as ft}from"../core/cell-type-rules.js";import{formulaEntryLimit as ht}from"../calc/parser.js";import{overlayRoot as mt}from"../api/overlay.js";import{BOOL as yt,EMPTY as gt,ERR as xt,ERRORS as vt,FORMULA as bt,KIND_MASK as Z,NUM as wt,STR as kt}from"../core/sheet.js";import{MAX_COLS as Ct,MAX_ROWS as Dt,parseRangeRef as St}from"../core/address.js";import{partsToSerial as N,serialToParts as P}from"../core/numfmt.js";import{validateEntry as Lt,validationAt as Et}from"../core/cond-format.js";import{parseInput as At}from"../core/input.js";import{askAboutInvalid as Ft}from"../cells/validation-alert.js";import{t as k,tc as Mt}from"../i18n/index.js";const z=(e,t)=>e*16384+t,G=["calendar","time","month","datetime","color","slider","calculator","list"],j=new Map;function me(e,t){G.includes(e)||G.push(e),j.set(e,t)}const Tt=2e5,tt=5e3,K={calendar:"yyyy-mm-dd",time:"h:mm:ss",month:"mmm yyyy",datetime:"yyyy-mm-dd h:mm:ss"};function Y(e,t,n,o){const r=t.kind(n,o)&Z;if(r===gt)return null;const s=t.value(n,o);return r===wt?s:r===kt?e.strings.get(s):r===yt?s!==0:r===xt?vt[s]??"#N/A":null}function Rt(e){const t=String(e??"");return t[0]==="="||t[0]==="'"?`'${t}`:t}function V(e,t,n,{overFormula:o=!1}={}){const{book:r}=e,{sheet:s}=r;return e.loading?!1:s.protection&&!dt(r,s,t,n)?(e.shell.setStatus("This cell is on a protected sheet. Unprotect the sheet to change it."),!1):!o&&(s.kind(t,n)&bt)!==0?(e.shell.setStatus("This cell's value comes from a formula, so this control can't change it."),!1):!0}function It(e,t,n,o,r){const{book:s}=e,{sheet:u}=s,i=Et(u,t,n);if(!i||!i.showError)return!0;const l=At(o);if(Lt(s,u,i,t,n,l.kind??0,l.value,l.text??o))return!0;const a=()=>{};return Ft(e,i,{retry:a,cancel:a,accept:i.errorStyle==="warning"||i.errorStyle==="information"?r:a}),!1}function $t(e,t,n,o,{format:r,overFormula:s=!1}={}){if(!V(e,t,n,{overFormula:s}))return!1;if(o.startsWith("=")&&e.book.styles.get(e.book.sheet.style(t,n)).numFmt!=="@"){const u=ht(o.slice(1));if(u)return e.shell.setStatus(k(u)),!1}return It(e,t,n,o,()=>et(e,t,n,o,r))?et(e,t,n,o,r):!1}function et(e,t,n,o,r){const{book:s,grid:u,controller:i}=e,l=s.sheet;return s.transact("entry",a=>{s.setInput(a,t,n,o),r&&s.styles.get(l.style(t,n)).numFmt==="General"&&l.setStyle(t,n,s.styles.derive(l.style(t,n),{numFmt:r}))}),e.commands?.afterEntry?.(t,n),u.invalidate(),i.syncFormulaBar(),!0}const q=(e,t)=>n=>{const o=q(e,n[e]??null);return n[e]=t,n.cellTypesChanged=!0,o};function Ot(e,{r0:t,c0:n,r1:o,c1:r}){const s=t===0&&o===Dt-1,u=n===0&&r===Ct-1;return{r0:t,c0:n,r1:s?Math.max(e.maxRow,999):o,c1:u?Math.max(e.maxCol,25):r}}function ye(e,t,n,o){const r=e.sheet;if(n==="cellTypes")return e.transact("cell type",i=>{const l=i.sheet,a=l.cellTypes,y=l.cellTypeRules;return ft(l,t,o),l.cellTypes===a&&l.cellTypeRules===y?null:pt([q(n,a),q("cellTypeRules",y)])}),!0;const s=t.map(i=>Ot(r,i));let u=0;for(const i of s)u+=(i.r1-i.r0+1)*(i.c1-i.c0+1);return u>Tt?!1:(e.transact("cell type",()=>{const i=q(n,r[n]??null),l=new Map(r[n]??[]);for(const a of s)for(let y=a.r0;y<=a.r1;y++)for(let x=a.c0;x<=a.c1;x++)o===null?l.delete(z(y,x)):l.set(z(y,x),o);return r[n]=l.size>0?l:null,r.cellTypesChanged=!0,i}),!0)}function ge(e,t={}){if(!G.includes(e))return null;const n={type:e},o=r=>{Number.isFinite(t[r])&&(n[r]=t[r])};return typeof t.format=="string"&&t.format.length<=64&&(n.format=t.format),e==="slider"&&(o("min"),o("max"),o("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,tt).filter(Array.isArray).map(r=>r.slice(0,50).map(s=>typeof s=="number"?s:String(s).slice(0,1e3))))),j.get(e)?.sanitize?.(t,n),Object.freeze(n)}function nt(e,t,n){const o=e.cellDropdowns;if(!o)return null;const r=e.mergeAt(t,n);return o.get(r?z(r.r0,r.c0):z(t,n))??null}function xe(e){const{sheet:t,sel:n,grid:o}=e;if(!t.cellDropdowns||!nt(t,n.row,n.col))return null;const r=o.cellRect(n.row,n.col),s=Math.min(16,r.h);return{x:r.x+r.w+1,y:r.y+r.h-s,size:s}}const rt="ct-popup-style",Nt=`
2
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
3
  .ct-popup button { font: inherit; color: inherit; background: none; border: 0; border-radius: 4px; padding: 0; cursor: default; }
4
4
  .ct-popup button:where(:not(.ct-btn)):hover:not(:disabled) { background: var(--hover); }
@@ -40,4 +40,4 @@ import{cellEditable as dt}from"../core/protection.js";import{allUndo as pt}from"
40
40
  .ct-mark { width: 12px; text-align: center; }
41
41
  .ct-count { padding: 4px 8px 0; color: var(--ink-soft); font-size: 11px; }
42
42
  .ct-value { min-width: 56px; text-align: right; font-variant-numeric: tabular-nums; }
43
- `;function Nt(){if(document.getElementById(rt))return;const e=document.createElement("style");e.id=rt,e.textContent=Ot,document.head.append(e)}const p=(e,t={},...n)=>{const o=document.createElement(e);for(const[r,s]of Object.entries(t))r==="class"?o.className=s:r==="text"?o.textContent=s:r.startsWith("aria")||r==="role"?o.setAttribute(r==="role"?r:`aria-${r.slice(4).toLowerCase()}`,s):o[r]=s;return o.append(...n.filter(r=>r!=null)),o};let F=null;const xe=()=>F!==null;function ve(e,t){F!==null&&(F.keepOpen=e,F.onClose=t)}function ot(e){F!==null&&(F.mode=e?"float":"confine")}function be(){F!==null&&F.mode!=="float"&&R(!1)}function R(e=!0){if(F===null)return;const{el:t,app:n,onDocPointer:o,onClose:r}=F;F=null,r?.(),document.removeEventListener("pointerdown",o,!0),t.remove(),e&&n.controller.focusGrid()}function T(e,t,n,o,r){R(!1),Nt(),e.grid.ensureVisible(t,n);const s=p("div",{class:"ct-popup",role:"dialog",ariaLabel:k(o),tabIndex:-1}),u=l=>{!s.contains(l.target)&&!F?.keepOpen?.(l)&&R(!1)};F={el:s,app:e,onDocPointer:u},document.addEventListener("pointerdown",u,!0),s.addEventListener("keydown",l=>{if(l.stopPropagation(),l.key==="Escape")l.preventDefault(),R();else if(l.key==="Tab"){const a=[...s.querySelectorAll('button, input, [tabindex="0"]')].filter(x=>!x.disabled&&x.tabIndex>=0&&x.offsetParent!==null);if(a.length===0)return;const y=a.indexOf(document.activeElement);l.preventDefault(),a[(y+(l.shiftKey?-1:1)+a.length)%a.length].focus()}}),mt().append(s);const i=r(s);return Ut(e,t,n,s),(i??s).focus({preventScroll:!0}),s}function Pt(e,t,n){const r=e.bottom-(e.top+t.y+t.h)-2,s=t.y-2,u=n.getBoundingClientRect(),i=u.height<=r||r>=s,l=Math.max(60,i?r:s);if(u.height>l){n.style.maxHeight=`${l}px`,n.style.overflow="auto";const y=n.querySelector(".ct-list");y&&(y.style.maxHeight=`${Math.max(30,l-18)}px`)}const a=Math.min(u.height,l);n.style.top=`${i?e.top+t.y+t.h+2:e.top+t.y-2-a}px`,n.style.left=`${Math.max(e.left,Math.min(e.left+t.x,e.right-u.width))}px`}function Ut(e,t,n,o){const r=e.grid.host.getBoundingClientRect(),s=e.grid.domRect(e.grid.cellRect(t,n));if(F?.mode==="confine"){Pt(r,s,o);return}const u=o.getBoundingClientRect(),i=2,l=r.top+s.y+s.h+i,a=l+u.height<=window.innerHeight-8?l:Math.max(8,r.top+s.y-u.height-i);o.style.top=`${a}px`,o.style.left=`${Math.max(8,Math.min(r.left+s.x,window.innerWidth-u.width-8))}px`}function $(e,t,n,o,r){const s=It(e,t,n,o,{...r,overFormula:!0});return s&&R(),s}const H=(e,t,n=null)=>p("div",{class:"ct-foot"},n,p("button",{class:"ct-btn",type:"button",text:k("Cancel"),onclick:()=>R()}),p("button",{class:"ct-btn ct-primary",type:"button",text:k("OK"),onclick:t})),X=["January","February","March","April","May","June","July","August","September","October","November","December"],Bt=["dow|Su","dow|Mo","dow|Tu","dow|We","dow|Th","dow|Fr","dow|Sa"],W=61;function _(){const e=new Date;return N(e.getFullYear(),e.getMonth()+1,e.getDate())}const st=e=>{const t=Math.round(e/1e3);return{h:Math.floor(t/3600)%24,m:Math.floor(t/60)%60,s:t%60}};function U(e,t,n){const{book:o}=e,r=Y(o,o.sheet,t,n);return typeof r=="number"&&r>=0?r:null}const Ht=(e,t)=>(t===12?N(e+1,1,1):N(e,t+1,1))-N(e,t,1);function at(e,t,n,{min:o=W,max:r=1/0,marked:s=null}={}){const u=p("div"),i=Math.max(W,o),l=g=>Math.min(r,Math.max(i,g));let a=l(e);const y=e,x=_(),c=g=>{const b=P(a),d=N(b.year,b.month,1),C=d-P(d).weekday,w=h=>{const D=b.year*12+b.month-1+h,L=Math.floor(D/12),M=D%12+1;a=l(N(L,M,Math.min(b.day,Ht(L,M)))),c(g),n?.(a)},f=p("div",{class:"ct-grid ct-days",role:"grid",ariaLabel:`${k(X[b.month-1])} ${b.year}`});for(const h of Bt)f.append(p("div",{class:"ct-dow",text:k(h)}));let v=null;for(let h=0;h<42;h++){const D=C+h;if(D<W){f.append(p("div"));continue}const L=D<i||D>r,M=P(D),B=D===a,S=p("button",{class:`ct-cell${M.month!==b.month||L?" ct-out":""}${D===x?" ct-today":""}${(s?s(D):Math.floor(y)===D)?" ct-on":""}`,disabled:L,type:"button",text:String(M.day),tabIndex:B?0:-1,role:"gridcell",ariaLabel:`${M.year}-${String(M.month).padStart(2,"0")}-${String(M.day).padStart(2,"0")}`,onclick:()=>t(D)});B&&(v=S),f.append(S)}f.addEventListener("keydown",h=>{const D={ArrowLeft:-1,ArrowRight:1,ArrowUp:-7,ArrowDown:7}[h.key];if(D!==void 0)h.preventDefault(),a=l(a+D),c(!0),n?.(a);else if(h.key==="PageUp"||h.key==="PageDown")h.preventDefault(),w((h.key==="PageUp"?-1:1)*(h.shiftKey?12:1));else if(h.key==="Home"||h.key==="End"){h.preventDefault();const L=P(a).weekday;a=l(a+(h.key==="Home"?-L:6-L)),c(!0),n?.(a)}else(h.key==="Enter"||h.key===" ")&&(h.preventDefault(),t(a))});const m=p("div",{class:"ct-row"},p("button",{class:"ct-nav",type:"button",text:"‹",ariaLabel:k("Previous month"),tabIndex:-1,onclick:()=>w(-1)}),p("div",{class:"ct-head",text:`${k(X[b.month-1])} ${b.year}`}),p("button",{class:"ct-nav",type:"button",text:"›",ariaLabel:k("Next month"),tabIndex:-1,onclick:()=>w(1)}));u.replaceChildren(m,f),u.focusCell=v,g&&v?.focus({preventScroll:!0})};return c(!1),u}function lt(e){const t=(i,l,a)=>p("input",{type:"number",min:0,max:l,value:String(a),ariaLabel:k(i),onfocus(){this.select()},onkeydown(y){if(y.key==="ArrowUp"||y.key==="ArrowDown"){y.preventDefault();const x=Number(this.value)+(y.key==="ArrowUp"?1:-1);this.value=String(x>l?0:x<0?l:x)}}}),n=t("Hours",23,e.h),o=t("Minutes",59,e.m),r=t("Seconds",59,e.s),s=p("div",{class:"ct-time"},n,p("span",{text:":"}),o,p("span",{text:":"}),r),u=(i,l)=>Math.max(0,Math.min(l,Math.trunc(Number(i.value))||0));return{wrap:s,first:n,read:()=>(u(n,23)*3600+u(o,59)*60+u(r,59))/86400}}function Wt(e,t,n,o){const r=U(e,t,n)??_();T(e,t,n,"Date picker",s=>{const u=a=>$(e,t,n,String(a),{format:o.format??K.calendar}),i=at(Math.floor(r),u,void 0,{min:o.minDate,max:o.maxDate}),l=p("button",{class:"ct-btn",type:"button",text:k("Today"),onclick:()=>u(_())});return s.append(i,p("div",{class:"ct-foot"},l)),i.focusCell})}function _t(e,t,n,o){const r=U(e,t,n),s=r===null?null:P(r).ms,u=new Date,i=s===null?{h:u.getHours(),m:u.getMinutes(),s:0}:st(s);T(e,t,n,"Time picker",l=>{const a=lt(i),y=()=>$(e,t,n,String(a.read()),{format:o.format??K.time});return a.wrap.addEventListener("keydown",x=>{x.key==="Enter"&&(x.preventDefault(),y())}),l.append(a.wrap,H(e,y)),a.first})}function zt(e,t,n,o){const r=U(e,t,n),s=P(r!==null&&r>=W?r:_()),u=o.startYear??1901,i=o.stopYear??9999;let l=Math.max(u,Math.min(i,s.year)),a=s.month-1;T(e,t,n,"Month picker",y=>{const x=b=>$(e,t,n,String(N(l,b+1,1)),{format:o.format??K.month}),c=p("div"),g=b=>{const d=p("div",{class:"ct-grid ct-months",role:"grid",ariaLabel:String(l)});let C=null;X.forEach((v,m)=>{const h=p("button",{class:`ct-cell${l===s.year&&m===s.month-1&&r!==null?" ct-on":""}`,type:"button",text:k(v).slice(0,3),ariaLabel:`${k(v)} ${l}`,tabIndex:m===a?0:-1,onclick:()=>x(m)});m===a&&(C=h),d.append(h)});const w=v=>{l=Math.max(u,Math.min(i,l+v)),g(!0)};d.addEventListener("keydown",v=>{const m={ArrowLeft:-1,ArrowRight:1,ArrowUp:-3,ArrowDown:3}[v.key];if(m!==void 0){v.preventDefault();const h=a+m;h<0?(a=h+12,w(-1)):h>11?(a=h-12,w(1)):(a=h,g(!0))}else v.key==="PageUp"||v.key==="PageDown"?(v.preventDefault(),w(v.key==="PageUp"?-1:1)):(v.key==="Enter"||v.key===" ")&&(v.preventDefault(),x(a))});const f=p("div",{class:"ct-row"},p("button",{class:"ct-nav",type:"button",text:"‹",ariaLabel:k("Previous year"),tabIndex:-1,onclick:()=>w(-1)}),p("div",{class:"ct-head",text:String(l)}),p("button",{class:"ct-nav",type:"button",text:"›",ariaLabel:k("Next year"),tabIndex:-1,onclick:()=>w(1)}));c.replaceChildren(f,d),c.focusCell=C,b&&C?.focus({preventScroll:!0})};return g(!1),y.append(c),c.focusCell})}function Kt(e,t,n,o){const r=U(e,t,n),s=new Date,u=r!==null&&r>=W?Math.floor(r):_(),i=r!==null?st(P(r).ms):{h:s.getHours(),m:s.getMinutes(),s:0};T(e,t,n,"Date and time picker",l=>{let a=u;const y=lt(i),x=()=>$(e,t,n,String(a+y.read()),{format:o.format??K.datetime}),c=at(a,g=>{a=g,y.first.focus()},g=>{a=g},{min:o.minDate,max:o.maxDate});return y.wrap.addEventListener("keydown",g=>{g.key==="Enter"&&(g.preventDefault(),x())}),y.wrap.style.marginTop="8px",l.append(c,y.wrap,H(e,x)),c.focusCell})}const Yt=["#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 Vt(e,t,n,o){const r=o.palette??Yt,{book:s}=e,u=Y(s,s.sheet,t,n),i=typeof u=="string"&&/^#[0-9a-f]{6}$/i.test(u)?u.toUpperCase():null;T(e,t,n,"Color picker",l=>{let a=Math.max(0,r.indexOf(i));const y=d=>{if(o.target===void 0){$(e,t,n,d);return}V(e,t,n,{overFormula:!0})&&(s.applyStyle([{r0:t,c0:n,r1:t,c1:n}],o.target==="fill"?{fill:d}:{color:d}),e.grid.invalidate(),R())},x=p("div",{class:"ct-grid ct-swatches",role:"grid",ariaLabel:k("Colors")}),c=r.map((d,C)=>{const w=p("button",{class:`ct-swatch${d===i?" ct-on":""}`,type:"button",ariaLabel:d,title:d,tabIndex:C===a?0:-1,onclick:()=>y(d)});return w.style.background=d,x.append(w),w});x.addEventListener("keydown",d=>{const C={ArrowLeft:-1,ArrowRight:1,ArrowUp:-10,ArrowDown:10}[d.key];if(C!==void 0){d.preventDefault();const w=a+C;w>=0&&w<r.length&&(c[a].tabIndex=-1,a=w,c[a].tabIndex=0,c[a].focus())}else(d.key==="Enter"||d.key===" ")&&(d.preventDefault(),y(r[a]))});const g=p("input",{type:"text",value:i??"",placeholder:"#RRGGBB",maxLength:7,size:8,ariaLabel:k("Hex color")}),b=()=>{const d=g.value.trim(),C=/^#?[0-9a-f]{6}$/i.test(d)?`#${d.replace("#","").toUpperCase()}`:null;C?y(C):g.select()};return g.addEventListener("keydown",d=>{d.key==="Enter"&&(d.preventDefault(),b())}),l.append(x,p("div",{class:"ct-foot"},g,p("button",{class:"ct-btn",type:"button",text:k("Apply"),onclick:b}))),c[a]})}function qt(e,t,n,o){const r=o.min??0,s=o.max??100,u=o.step??1,i=U(e,t,n);T(e,t,n,"Slider",l=>{const a=p("input",{type:"range",min:r,max:s,step:u,value:String(i??r),ariaLabel:k("Value")}),y=p("span",{class:"ct-value",text:a.value});a.addEventListener("input",()=>{y.textContent=a.value});const x=()=>$(e,t,n,a.value);return a.addEventListener("keydown",c=>{c.key==="Enter"&&(c.preventDefault(),x())}),l.append(a,H(e,x,y)),a})}const it=e=>Number(e.toPrecision(15));function Gt(e=0){let t=String(e),n=null,o=null,r=!0,s=!1;const u=()=>{const i=Number(t);if(o===null||n===null)return;let l;o==="+"?l=n+i:o==="-"?l=n-i:o==="*"?l=n*i:l=n/i,Number.isFinite(l)?t=String(it(l)):(s=!0,t="Error"),n=null,o=null};return{get display(){return t},get failed(){return s},press(i){if(i==="C"){t="0",n=null,o=null,r=!0,s=!1;return}s||(/^\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(it(Number(t)/100)),r=!0):i==="="?(u(),r=!0):"+-*/".includes(i)&&((!r||n===null)&&u(),s||(n=Number(t),o=i,r=!0)))}}}function jt(e,t,n){const o=U(e,t,n),r=Gt(o??0);T(e,t,n,"Calculator",s=>{const u=p("input",{class:"ct-display",type:"text",readOnly:!0,value:r.display,ariaLabel:k("Result"),tabIndex:-1}),i=c=>{r.press(c),u.value=r.failed?k("Error"):r.display},l=()=>{i("="),r.failed||$(e,t,n,r.display)},a=[["C","C"],["±","neg"],["%","%"],["÷","/"],["7","7"],["8","8"],["9","9"],["×","*"],["4","4"],["5","5"],["6","6"],["−","-"],["1","1"],["2","2"],["3","3"],["+","+"],["0","0"],[".","."],["=","="]],y=p("div",{class:"ct-grid ct-keys"});let x=null;for(const[c,g]of a){const b=p("button",{class:`ct-key${g==="0"?" ct-wide":""}`,type:"button",text:c,ariaLabel:c,onclick:()=>i(g)});g==="7"&&(x=b),y.append(b)}return s.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)))}),s.append(u,y,H(e,l)),x})}function Xt(e,t){const{book:n}=e,o=t.valueColumn??0;if(t.source){const r=t.source.replace(/^=/,""),s=r.lastIndexOf("!"),u=s>=0?r.slice(0,s).replace(/^'|'$/g,"").replace(/''/g,"'"):null;let i=u===null?n.sheet:n.sheets.find(c=>c.name.toLowerCase()===u.toLowerCase()),l=St(s>=0?r.slice(s+1):r);if(!l&&s<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 a=[],y=Math.min(l.r1,i.maxRow,l.r0+tt-1),x=Math.min(l.c1,i.maxCol,l.c0+49);for(let c=l.r0;c<=y;c++){const g=[];let b=null;for(let d=l.c0;d<=x;d++){const C=i.kind(c,d)&Z,w=n.styles.list[i.style(c,d)]??n.styles.list[0];g.push(e.grid.displayText(C,i.value(c,d),w)),d-l.c0===o&&(b=Y(n,i,c,d))}g.some(d=>d!=="")&&a.push({cells:g,value:b})}return{head:t.columns??null,rows:a}}return{head:t.columns??null,rows:(t.rows??[]).map(r=>({cells:r.map(String),value:r[o]??null}))}}function Jt(e,t,n,o){const{head:r,rows:s}=Xt(e,o),{book:u}=e,i=Y(u,u.sheet,t,n);T(e,t,n,"List",l=>{if(s.length===0)return l.append(p("div",{text:k("No items"),class:"ct-item"})),l;let a=Math.max(0,s.findIndex(f=>i!==null&&String(f.value)===String(i)));const y=p("table",{class:"ct-table"});r&&y.append(p("thead",{},p("tr",{},...r.map((f,v)=>{const m=p("th",{text:f});return o.widths?.[v]>0&&(m.style.minWidth=`${o.widths[v]}px`),m}))));const x=p("tbody",{role:"listbox",ariaLabel:k("List"),tabIndex:0}),c=f=>$(e,t,n,Tt(s[f].value)),g=s.map((f,v)=>{const m=p("tr",{role:"option",ariaSelected:String(v===a),onclick:()=>c(v)},...f.cells.map(h=>p("td",{text:h})));return x.append(m),m}),b=f=>{let v=Math.max(0,Math.min(s.length-1,f));const m=v<a?-1:1;for(;g[v].hidden&&v+m>=0&&v+m<s.length;)v+=m;g[v].hidden||(g[a].setAttribute("aria-selected","false"),a=v,g[a].setAttribute("aria-selected","true"),g[a].scrollIntoView({block:"nearest"}))};let d="",C=0;x.addEventListener("keydown",f=>{const m={ArrowUp:a-1,ArrowDown:a+1,PageUp:a-8,PageDown:a+8,Home:0,End:s.length-1}[f.key];if(m!==void 0)f.preventDefault(),b(m);else if(f.key==="Enter"||f.key===" ")f.preventDefault(),c(a);else if(f.key.length===1&&!f.metaKey&&!f.ctrlKey){const h=performance.now();d=h-C>800?f.key:d+f.key,C=h;const D=s.findIndex(L=>L.cells[0].toLowerCase().startsWith(d.toLowerCase()));D>=0&&b(D)}}),y.append(x);let w=null;return o.filter&&(w=p("input",{type:"text",placeholder:k("Filter"),ariaLabel:k("Filter the list")}),w.style.width="100%",w.style.boxSizing="border-box",w.style.marginBottom="4px",w.addEventListener("input",()=>{const f=w.value.trim().toLowerCase();s.forEach((m,h)=>{g[h].hidden=f!==""&&!m.cells.some(D=>String(D).toLowerCase().includes(f))});const v=g.findIndex(m=>!m.hidden);v>=0&&g[a].hidden&&b(v)}),w.addEventListener("keydown",f=>{f.key==="ArrowDown"?(f.preventDefault(),x.focus()):f.key==="Enter"&&(f.preventDefault(),g[a].hidden||c(a))}),l.append(w)),l.append(p("div",{class:"ct-list"},y)),requestAnimationFrame(()=>g[a]?.scrollIntoView({block:"nearest"})),w??x})}function we(e,t,n,{items:o,selected:r=[],multi:s=!1,onDone:u,label:i="List",maxItems:l=0,moveOnSide:a=!1,float:y}){if(!s&&o.length>Qt){te(e,t,n,{items:o,selected:r,onDone:u,label:i,maxItems:l,moveOnSide:a,float:y});return}T(e,t,n,i,x=>{y!==void 0&&ot(y);const c=new Set(r);let g=Math.max(0,o.findIndex(m=>c.has(m.value)));const b=()=>{const m=o.filter(h=>c.has(h.value)).map(h=>h.value);u(m)!==!1&&R()},d=p("div",{class:"ct-list",role:"listbox",ariaLabel:k(i),ariaMultiselectable:String(s),tabIndex:0});l>0&&(d.style.maxHeight=`${l*24}px`);const C=[],w=o.map((m,h)=>{const D=p("span",{class:"ct-mark",text:c.has(m.value)?"✓":""});C.push(D);const L=p("div",{class:`ct-item${h===g?" ct-cursor":""}`,role:"option",ariaSelected:String(c.has(m.value)),onclick:()=>{f(h),v(),s||b()}},D,p("span",{text:m.text}));return d.append(L),L});function f(m){const h=Math.max(0,Math.min(o.length-1,m));w[g]?.classList.remove("ct-cursor"),g=h,w[g]?.classList.add("ct-cursor"),w[g]?.scrollIntoView({block:"nearest"})}function v(){const m=o[g];m&&(s||c.clear(),c.has(m.value)?c.delete(m.value):c.add(m.value),o.forEach((h,D)=>{C[D].textContent=c.has(h.value)?"✓":"",w[D].setAttribute("aria-selected",String(c.has(h.value)))}))}return d.addEventListener("keydown",m=>{const h={ArrowUp:g-1,ArrowDown:g+1,Home:0,End:o.length-1}[m.key];h!==void 0?(m.preventDefault(),f(h)):m.key===" "?(m.preventDefault(),v(),s||b()):m.key==="Enter"?(m.preventDefault(),s||(c.clear(),v()),b()):a&&!s&&(m.key==="ArrowLeft"||m.key==="ArrowRight")&&(m.preventDefault(),c.clear(),v(),b(),e.controller.moveTo(t,Math.max(0,n+(m.key==="ArrowLeft"?-1:1))))}),x.append(d),s&&x.append(H(e,b)),o.length===0&&d.append(p("div",{class:"ct-item",text:k("No items")})),d})}const Qt=300,O=24,ct=new WeakMap;function Zt(e){let t=ct.get(e);return t===void 0&&(t=e.map(n=>String(n.text).toLowerCase()),ct.set(e,t)),t}function te(e,t,n,{items:o,selected:r,onDone:s,label:u,maxItems:i,moveOnSide:l,float:a}){T(e,t,n,u,y=>{a!==void 0&&ot(a);const x=Zt(o),c=r.length?String(r[0]).toLowerCase():null,g=Int32Array.from(o.keys());let b=g,d=Math.max(0,c===null?0:o.findIndex(S=>String(S.value).toLowerCase()===c));const C=p("input",{type:"search",placeholder:k("Search"),ariaLabel:k("Search the list")});C.style.width="100%",C.style.boxSizing="border-box",C.style.marginBottom="4px";const w=p("div",{class:"ct-count"}),f=p("div",{class:"ct-list",role:"listbox",ariaLabel:k(u),tabIndex:0}),v=i>0?i:10;f.style.height=`${v*O}px`,f.style.maxHeight="none",f.style.position="relative";const m=p("div");f.append(m);let h=[];const D=S=>{const A=o[b[S]];A&&s([A.value])!==!1&&R()},L=()=>{m.style.height=`${b.length*O}px`;for(const E of h)E.remove();h=[];const S=Math.max(0,Math.floor(f.scrollTop/O)-2),A=Math.min(b.length,S+v+4);for(let E=S;E<A;E++){const J=o[b[E]],Q=c!==null&&String(J.value).toLowerCase()===c,I=p("div",{class:`ct-item${E===d?" ct-cursor":""}`,role:"option",ariaSelected:String(Q),onclick:()=>D(E)},p("span",{class:"ct-mark",text:Q?"✓":""}),p("span",{text:J.text}));I.style.position="absolute",I.style.top=`${E*O}px`,I.style.left="0",I.style.right="0",I.style.height=`${O}px`,I.style.boxSizing="border-box",f.append(I),h.push(I)}w.textContent=b.length===o.length?k("{n} items",{n:o.length.toLocaleString()}):k("{n} of {total}",{n:b.length.toLocaleString(),total:o.length.toLocaleString()})},M=S=>{d=Math.max(0,Math.min(b.length-1,S));const A=d*O;A<f.scrollTop?f.scrollTop=A:A+O>f.scrollTop+f.clientHeight&&(f.scrollTop=A+O-f.clientHeight),L()};f.addEventListener("scroll",L),C.addEventListener("input",()=>{const S=C.value.trim().toLowerCase();if(S==="")b=g;else{const A=[];for(let E=0;E<x.length;E++)x[E].includes(S)&&A.push(E);b=Int32Array.from(A)}d=0,f.scrollTop=0,L()});const B=S=>{const A=v-1,E={ArrowUp:d-1,ArrowDown:d+1,PageUp:d-A,PageDown:d+A}[S.key];E!==void 0?(S.preventDefault(),M(E)):S.key==="Enter"?(S.preventDefault(),D(d)):l&&S.target===f&&(S.key==="ArrowLeft"||S.key==="ArrowRight")&&(S.preventDefault(),D(d),e.controller.moveTo(t,Math.max(0,n+(S.key==="ArrowLeft"?-1:1))))};return C.addEventListener("keydown",B),f.addEventListener("keydown",B),y.append(C,f,w),L(),requestAnimationFrame(()=>M(d)),C})}const ee={calendar:Wt,time:_t,month:zt,datetime:Kt,color:Vt,slider:qt,calculator:jt,list:Jt};function ut(e,t,n,o){j.get(o.type)?.open?.(e,t,n,o)!==!0&&ee[o.type]?.(e,t,n,o)}function ke(e,t,n,o){return e.loading?!1:(V(e,t,n,{overFormula:!0})&&ut(e,t,n,o),!0)}function Ce(e,t,n){const{sheet:o}=e.book,r=nt(o,t,n);if(!r||e.loading)return!1;if(!V(e,t,n,{overFormula:!0}))return!0;const s=o.mergeAt(t,n);return ut(e,s?s.r0:t,s?s.c0:n,r),!0}export{G as DROPDOWN_TYPES,Mt as MAX_APPLY_CELLS,X as MONTHS,me as applyToRanges,at as buildCalendar,V as canWriteCell,ge as cellDropdownArrow,z as cellKey,U as cellSerial,$t as clipRange,R as closeDropdown,$ as commit,nt as dropdownAt,H as footer,xe as isDropdownOpen,Xt as listData,Tt as literalInput,p as make,Gt as makeCalculator,ye as makeDropdown,Ce as openCellDropdown,ke as openDropdownConfig,we as openListPopup,T as openPopup,be as popupViewChanged,Y as readCellValue,he as registerDropdownKind,ot as setPopupFloat,ve as setPopupKeepOpen,q as swapMap,lt as timeInputs,_ as todaySerial,It as writeCell};
43
+ `;function Pt(){if(document.getElementById(rt))return;const e=document.createElement("style");e.id=rt,e.textContent=Nt,document.head.append(e)}const p=(e,t={},...n)=>{const o=document.createElement(e);for(const[r,s]of Object.entries(t))r==="class"?o.className=s:r==="text"?o.textContent=s:r.startsWith("aria")||r==="role"?o.setAttribute(r==="role"?r:`aria-${r.slice(4).toLowerCase()}`,s):o[r]=s;return o.append(...n.filter(r=>r!=null)),o};let F=null;const ve=()=>F!==null;function be(e,t){F!==null&&(F.keepOpen=e,F.onClose=t)}function ot(e){F!==null&&(F.mode=e?"float":"confine")}function we(){F!==null&&F.mode!=="float"&&R(!1)}function R(e=!0){if(F===null)return;const{el:t,app:n,onDocPointer:o,onClose:r}=F;F=null,r?.(),document.removeEventListener("pointerdown",o,!0),t.remove(),e&&n.controller.focusGrid()}function T(e,t,n,o,r){R(!1),Pt(),e.grid.ensureVisible(t,n);const s=p("div",{class:"ct-popup",role:"dialog",ariaLabel:k(o),tabIndex:-1}),u=l=>{!s.contains(l.target)&&!F?.keepOpen?.(l)&&R(!1)};F={el:s,app:e,onDocPointer:u},document.addEventListener("pointerdown",u,!0),s.addEventListener("keydown",l=>{if(l.stopPropagation(),l.key==="Escape")l.preventDefault(),R();else if(l.key==="Tab"){const a=[...s.querySelectorAll('button, input, [tabindex="0"]')].filter(x=>!x.disabled&&x.tabIndex>=0&&x.offsetParent!==null);if(a.length===0)return;const y=a.indexOf(document.activeElement);l.preventDefault(),a[(y+(l.shiftKey?-1:1)+a.length)%a.length].focus()}}),mt().append(s);const i=r(s);return Bt(e,t,n,s),(i??s).focus({preventScroll:!0}),s}function Ut(e,t,n){const r=e.bottom-(e.top+t.y+t.h)-2,s=t.y-2,u=n.getBoundingClientRect(),i=u.height<=r||r>=s,l=Math.max(60,i?r:s);if(u.height>l){n.style.maxHeight=`${l}px`,n.style.overflow="auto";const y=n.querySelector(".ct-list");y&&(y.style.maxHeight=`${Math.max(30,l-18)}px`)}const a=Math.min(u.height,l);n.style.top=`${i?e.top+t.y+t.h+2:e.top+t.y-2-a}px`,n.style.left=`${Math.max(e.left,Math.min(e.left+t.x,e.right-u.width))}px`}function Bt(e,t,n,o){const r=e.grid.host.getBoundingClientRect(),s=e.grid.domRect(e.grid.cellRect(t,n));if(F?.mode==="confine"){Ut(r,s,o);return}const u=o.getBoundingClientRect(),i=2,l=r.top+s.y+s.h+i,a=l+u.height<=window.innerHeight-8?l:Math.max(8,r.top+s.y-u.height-i);o.style.top=`${a}px`,o.style.left=`${Math.max(8,Math.min(r.left+s.x,window.innerWidth-u.width-8))}px`}function $(e,t,n,o,r){const s=$t(e,t,n,o,{...r,overFormula:!0});return s&&R(),s}const H=(e,t,n=null)=>p("div",{class:"ct-foot"},n,p("button",{class:"ct-btn",type:"button",text:k("Cancel"),onclick:()=>R()}),p("button",{class:"ct-btn ct-primary",type:"button",text:k("OK"),onclick:t})),X=["January","February","March","April","May","June","July","August","September","October","November","December"],Ht=["dow|Su","dow|Mo","dow|Tu","dow|We","dow|Th","dow|Fr","dow|Sa"],W=61;function _(){const e=new Date;return N(e.getFullYear(),e.getMonth()+1,e.getDate())}const st=e=>{const t=Math.round(e/1e3);return{h:Math.floor(t/3600)%24,m:Math.floor(t/60)%60,s:t%60}};function U(e,t,n){const{book:o}=e,r=Y(o,o.sheet,t,n);return typeof r=="number"&&r>=0?r:null}const Wt=(e,t)=>(t===12?N(e+1,1,1):N(e,t+1,1))-N(e,t,1);function at(e,t,n,{min:o=W,max:r=1/0,marked:s=null}={}){const u=p("div"),i=Math.max(W,o),l=g=>Math.min(r,Math.max(i,g));let a=l(e);const y=e,x=_(),c=g=>{const b=P(a),d=N(b.year,b.month,1),C=d-P(d).weekday,w=h=>{const D=b.year*12+b.month-1+h,L=Math.floor(D/12),M=D%12+1;a=l(N(L,M,Math.min(b.day,Wt(L,M)))),c(g),n?.(a)},f=p("div",{class:"ct-grid ct-days",role:"grid",ariaLabel:`${k(X[b.month-1])} ${b.year}`});for(const h of Ht)f.append(p("div",{class:"ct-dow",text:k(h)}));let v=null;for(let h=0;h<42;h++){const D=C+h;if(D<W){f.append(p("div"));continue}const L=D<i||D>r,M=P(D),B=D===a,S=p("button",{class:`ct-cell${M.month!==b.month||L?" ct-out":""}${D===x?" ct-today":""}${(s?s(D):Math.floor(y)===D)?" ct-on":""}`,disabled:L,type:"button",text:String(M.day),tabIndex:B?0:-1,role:"gridcell",ariaLabel:`${M.year}-${String(M.month).padStart(2,"0")}-${String(M.day).padStart(2,"0")}`,onclick:()=>t(D)});B&&(v=S),f.append(S)}f.addEventListener("keydown",h=>{const D={ArrowLeft:-1,ArrowRight:1,ArrowUp:-7,ArrowDown:7}[h.key];if(D!==void 0)h.preventDefault(),a=l(a+D),c(!0),n?.(a);else if(h.key==="PageUp"||h.key==="PageDown")h.preventDefault(),w((h.key==="PageUp"?-1:1)*(h.shiftKey?12:1));else if(h.key==="Home"||h.key==="End"){h.preventDefault();const L=P(a).weekday;a=l(a+(h.key==="Home"?-L:6-L)),c(!0),n?.(a)}else(h.key==="Enter"||h.key===" ")&&(h.preventDefault(),t(a))});const m=p("div",{class:"ct-row"},p("button",{class:"ct-nav",type:"button",text:"‹",ariaLabel:k("Previous month"),tabIndex:-1,onclick:()=>w(-1)}),p("div",{class:"ct-head",text:`${k(X[b.month-1])} ${b.year}`}),p("button",{class:"ct-nav",type:"button",text:"›",ariaLabel:k("Next month"),tabIndex:-1,onclick:()=>w(1)}));u.replaceChildren(m,f),u.focusCell=v,g&&v?.focus({preventScroll:!0})};return c(!1),u}function lt(e){const t=(i,l,a)=>p("input",{type:"number",min:0,max:l,value:String(a),ariaLabel:k(i),onfocus(){this.select()},onkeydown(y){if(y.key==="ArrowUp"||y.key==="ArrowDown"){y.preventDefault();const x=Number(this.value)+(y.key==="ArrowUp"?1:-1);this.value=String(x>l?0:x<0?l:x)}}}),n=t("Hours",23,e.h),o=t("Minutes",59,e.m),r=t("Seconds",59,e.s),s=p("div",{class:"ct-time"},n,p("span",{text:":"}),o,p("span",{text:":"}),r),u=(i,l)=>Math.max(0,Math.min(l,Math.trunc(Number(i.value))||0));return{wrap:s,first:n,read:()=>(u(n,23)*3600+u(o,59)*60+u(r,59))/86400}}function _t(e,t,n,o){const r=U(e,t,n)??_();T(e,t,n,"Date picker",s=>{const u=a=>$(e,t,n,String(a),{format:o.format??K.calendar}),i=at(Math.floor(r),u,void 0,{min:o.minDate,max:o.maxDate}),l=p("button",{class:"ct-btn",type:"button",text:k("Today"),onclick:()=>u(_())});return s.append(i,p("div",{class:"ct-foot"},l)),i.focusCell})}function zt(e,t,n,o){const r=U(e,t,n),s=r===null?null:P(r).ms,u=new Date,i=s===null?{h:u.getHours(),m:u.getMinutes(),s:0}:st(s);T(e,t,n,"Time picker",l=>{const a=lt(i),y=()=>$(e,t,n,String(a.read()),{format:o.format??K.time});return a.wrap.addEventListener("keydown",x=>{x.key==="Enter"&&(x.preventDefault(),y())}),l.append(a.wrap,H(e,y)),a.first})}function Kt(e,t,n,o){const r=U(e,t,n),s=P(r!==null&&r>=W?r:_()),u=o.startYear??1901,i=o.stopYear??9999;let l=Math.max(u,Math.min(i,s.year)),a=s.month-1;T(e,t,n,"Month picker",y=>{const x=b=>$(e,t,n,String(N(l,b+1,1)),{format:o.format??K.month}),c=p("div"),g=b=>{const d=p("div",{class:"ct-grid ct-months",role:"grid",ariaLabel:String(l)});let C=null;X.forEach((v,m)=>{const h=p("button",{class:`ct-cell${l===s.year&&m===s.month-1&&r!==null?" ct-on":""}`,type:"button",text:Mt("month",v.slice(0,3)),ariaLabel:`${k(v)} ${l}`,tabIndex:m===a?0:-1,onclick:()=>x(m)});m===a&&(C=h),d.append(h)});const w=v=>{l=Math.max(u,Math.min(i,l+v)),g(!0)};d.addEventListener("keydown",v=>{const m={ArrowLeft:-1,ArrowRight:1,ArrowUp:-3,ArrowDown:3}[v.key];if(m!==void 0){v.preventDefault();const h=a+m;h<0?(a=h+12,w(-1)):h>11?(a=h-12,w(1)):(a=h,g(!0))}else v.key==="PageUp"||v.key==="PageDown"?(v.preventDefault(),w(v.key==="PageUp"?-1:1)):(v.key==="Enter"||v.key===" ")&&(v.preventDefault(),x(a))});const f=p("div",{class:"ct-row"},p("button",{class:"ct-nav",type:"button",text:"‹",ariaLabel:k("Previous year"),tabIndex:-1,onclick:()=>w(-1)}),p("div",{class:"ct-head",text:String(l)}),p("button",{class:"ct-nav",type:"button",text:"›",ariaLabel:k("Next year"),tabIndex:-1,onclick:()=>w(1)}));c.replaceChildren(f,d),c.focusCell=C,b&&C?.focus({preventScroll:!0})};return g(!1),y.append(c),c.focusCell})}function Yt(e,t,n,o){const r=U(e,t,n),s=new Date,u=r!==null&&r>=W?Math.floor(r):_(),i=r!==null?st(P(r).ms):{h:s.getHours(),m:s.getMinutes(),s:0};T(e,t,n,"Date and time picker",l=>{let a=u;const y=lt(i),x=()=>$(e,t,n,String(a+y.read()),{format:o.format??K.datetime}),c=at(a,g=>{a=g,y.first.focus()},g=>{a=g},{min:o.minDate,max:o.maxDate});return y.wrap.addEventListener("keydown",g=>{g.key==="Enter"&&(g.preventDefault(),x())}),y.wrap.style.marginTop="8px",l.append(c,y.wrap,H(e,x)),c.focusCell})}const Vt=["#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 qt(e,t,n,o){const r=o.palette??Vt,{book:s}=e,u=Y(s,s.sheet,t,n),i=typeof u=="string"&&/^#[0-9a-f]{6}$/i.test(u)?u.toUpperCase():null;T(e,t,n,"Color picker",l=>{let a=Math.max(0,r.indexOf(i));const y=d=>{if(o.target===void 0){$(e,t,n,d);return}V(e,t,n,{overFormula:!0})&&(s.applyStyle([{r0:t,c0:n,r1:t,c1:n}],o.target==="fill"?{fill:d}:{color:d}),e.grid.invalidate(),R())},x=p("div",{class:"ct-grid ct-swatches",role:"grid",ariaLabel:k("Colors")}),c=r.map((d,C)=>{const w=p("button",{class:`ct-swatch${d===i?" ct-on":""}`,type:"button",ariaLabel:d,title:d,tabIndex:C===a?0:-1,onclick:()=>y(d)});return w.style.background=d,x.append(w),w});x.addEventListener("keydown",d=>{const C={ArrowLeft:-1,ArrowRight:1,ArrowUp:-10,ArrowDown:10}[d.key];if(C!==void 0){d.preventDefault();const w=a+C;w>=0&&w<r.length&&(c[a].tabIndex=-1,a=w,c[a].tabIndex=0,c[a].focus())}else(d.key==="Enter"||d.key===" ")&&(d.preventDefault(),y(r[a]))});const g=p("input",{type:"text",value:i??"",placeholder:"#RRGGBB",maxLength:7,size:8,ariaLabel:k("Hex color")}),b=()=>{const d=g.value.trim(),C=/^#?[0-9a-f]{6}$/i.test(d)?`#${d.replace("#","").toUpperCase()}`:null;C?y(C):g.select()};return g.addEventListener("keydown",d=>{d.key==="Enter"&&(d.preventDefault(),b())}),l.append(x,p("div",{class:"ct-foot"},g,p("button",{class:"ct-btn",type:"button",text:k("Apply"),onclick:b}))),c[a]})}function Gt(e,t,n,o){const r=o.min??0,s=o.max??100,u=o.step??1,i=U(e,t,n);T(e,t,n,"Slider",l=>{const a=p("input",{type:"range",min:r,max:s,step:u,value:String(i??r),ariaLabel:k("Value")}),y=p("span",{class:"ct-value",text:a.value});a.addEventListener("input",()=>{y.textContent=a.value});const x=()=>$(e,t,n,a.value);return a.addEventListener("keydown",c=>{c.key==="Enter"&&(c.preventDefault(),x())}),l.append(a,H(e,x,y)),a})}const it=e=>Number(e.toPrecision(15));function jt(e=0){let t=String(e),n=null,o=null,r=!0,s=!1;const u=()=>{const i=Number(t);if(o===null||n===null)return;let l;o==="+"?l=n+i:o==="-"?l=n-i:o==="*"?l=n*i:l=n/i,Number.isFinite(l)?t=String(it(l)):(s=!0,t="Error"),n=null,o=null};return{get display(){return t},get failed(){return s},press(i){if(i==="C"){t="0",n=null,o=null,r=!0,s=!1;return}s||(/^\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(it(Number(t)/100)),r=!0):i==="="?(u(),r=!0):"+-*/".includes(i)&&((!r||n===null)&&u(),s||(n=Number(t),o=i,r=!0)))}}}function Xt(e,t,n){const o=U(e,t,n),r=jt(o??0);T(e,t,n,"Calculator",s=>{const u=p("input",{class:"ct-display",type:"text",readOnly:!0,value:r.display,ariaLabel:k("Result"),tabIndex:-1}),i=c=>{r.press(c),u.value=r.failed?k("Error"):r.display},l=()=>{i("="),r.failed||$(e,t,n,r.display)},a=[["C","C"],["±","neg"],["%","%"],["÷","/"],["7","7"],["8","8"],["9","9"],["×","*"],["4","4"],["5","5"],["6","6"],["−","-"],["1","1"],["2","2"],["3","3"],["+","+"],["0","0"],[".","."],["=","="]],y=p("div",{class:"ct-grid ct-keys"});let x=null;for(const[c,g]of a){const b=p("button",{class:`ct-key${g==="0"?" ct-wide":""}`,type:"button",text:c,ariaLabel:c,onclick:()=>i(g)});g==="7"&&(x=b),y.append(b)}return s.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)))}),s.append(u,y,H(e,l)),x})}function Jt(e,t){const{book:n}=e,o=t.valueColumn??0;if(t.source){const r=t.source.replace(/^=/,""),s=r.lastIndexOf("!"),u=s>=0?r.slice(0,s).replace(/^'|'$/g,"").replace(/''/g,"'"):null;let i=u===null?n.sheet:n.sheets.find(c=>c.name.toLowerCase()===u.toLowerCase()),l=St(s>=0?r.slice(s+1):r);if(!l&&s<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 a=[],y=Math.min(l.r1,i.maxRow,l.r0+tt-1),x=Math.min(l.c1,i.maxCol,l.c0+49);for(let c=l.r0;c<=y;c++){const g=[];let b=null;for(let d=l.c0;d<=x;d++){const C=i.kind(c,d)&Z,w=n.styles.list[i.style(c,d)]??n.styles.list[0];g.push(e.grid.displayText(C,i.value(c,d),w)),d-l.c0===o&&(b=Y(n,i,c,d))}g.some(d=>d!=="")&&a.push({cells:g,value:b})}return{head:t.columns??null,rows:a}}return{head:t.columns??null,rows:(t.rows??[]).map(r=>({cells:r.map(String),value:r[o]??null}))}}function Qt(e,t,n,o){const{head:r,rows:s}=Jt(e,o),{book:u}=e,i=Y(u,u.sheet,t,n);T(e,t,n,"List",l=>{if(s.length===0)return l.append(p("div",{text:k("No items"),class:"ct-item"})),l;let a=Math.max(0,s.findIndex(f=>i!==null&&String(f.value)===String(i)));const y=p("table",{class:"ct-table"});r&&y.append(p("thead",{},p("tr",{},...r.map((f,v)=>{const m=p("th",{text:f});return o.widths?.[v]>0&&(m.style.minWidth=`${o.widths[v]}px`),m}))));const x=p("tbody",{role:"listbox",ariaLabel:k("List"),tabIndex:0}),c=f=>$(e,t,n,Rt(s[f].value)),g=s.map((f,v)=>{const m=p("tr",{role:"option",ariaSelected:String(v===a),onclick:()=>c(v)},...f.cells.map(h=>p("td",{text:h})));return x.append(m),m}),b=f=>{let v=Math.max(0,Math.min(s.length-1,f));const m=v<a?-1:1;for(;g[v].hidden&&v+m>=0&&v+m<s.length;)v+=m;g[v].hidden||(g[a].setAttribute("aria-selected","false"),a=v,g[a].setAttribute("aria-selected","true"),g[a].scrollIntoView({block:"nearest"}))};let d="",C=0;x.addEventListener("keydown",f=>{const m={ArrowUp:a-1,ArrowDown:a+1,PageUp:a-8,PageDown:a+8,Home:0,End:s.length-1}[f.key];if(m!==void 0)f.preventDefault(),b(m);else if(f.key==="Enter"||f.key===" ")f.preventDefault(),c(a);else if(f.key.length===1&&!f.metaKey&&!f.ctrlKey){const h=performance.now();d=h-C>800?f.key:d+f.key,C=h;const D=s.findIndex(L=>L.cells[0].toLowerCase().startsWith(d.toLowerCase()));D>=0&&b(D)}}),y.append(x);let w=null;return o.filter&&(w=p("input",{type:"text",placeholder:k("Filter"),ariaLabel:k("Filter the list")}),w.style.width="100%",w.style.boxSizing="border-box",w.style.marginBottom="4px",w.addEventListener("input",()=>{const f=w.value.trim().toLowerCase();s.forEach((m,h)=>{g[h].hidden=f!==""&&!m.cells.some(D=>String(D).toLowerCase().includes(f))});const v=g.findIndex(m=>!m.hidden);v>=0&&g[a].hidden&&b(v)}),w.addEventListener("keydown",f=>{f.key==="ArrowDown"?(f.preventDefault(),x.focus()):f.key==="Enter"&&(f.preventDefault(),g[a].hidden||c(a))}),l.append(w)),l.append(p("div",{class:"ct-list"},y)),requestAnimationFrame(()=>g[a]?.scrollIntoView({block:"nearest"})),w??x})}function ke(e,t,n,{items:o,selected:r=[],multi:s=!1,onDone:u,label:i="List",maxItems:l=0,moveOnSide:a=!1,float:y}){if(!s&&o.length>Zt){ee(e,t,n,{items:o,selected:r,onDone:u,label:i,maxItems:l,moveOnSide:a,float:y});return}T(e,t,n,i,x=>{y!==void 0&&ot(y);const c=new Set(r);let g=Math.max(0,o.findIndex(m=>c.has(m.value)));const b=()=>{const m=o.filter(h=>c.has(h.value)).map(h=>h.value);u(m)!==!1&&R()},d=p("div",{class:"ct-list",role:"listbox",ariaLabel:k(i),ariaMultiselectable:String(s),tabIndex:0});l>0&&(d.style.maxHeight=`${l*24}px`);const C=[],w=o.map((m,h)=>{const D=p("span",{class:"ct-mark",text:c.has(m.value)?"✓":""});C.push(D);const L=p("div",{class:`ct-item${h===g?" ct-cursor":""}`,role:"option",ariaSelected:String(c.has(m.value)),onclick:()=>{f(h),v(),s||b()}},D,p("span",{text:m.text}));return d.append(L),L});function f(m){const h=Math.max(0,Math.min(o.length-1,m));w[g]?.classList.remove("ct-cursor"),g=h,w[g]?.classList.add("ct-cursor"),w[g]?.scrollIntoView({block:"nearest"})}function v(){const m=o[g];m&&(s||c.clear(),c.has(m.value)?c.delete(m.value):c.add(m.value),o.forEach((h,D)=>{C[D].textContent=c.has(h.value)?"✓":"",w[D].setAttribute("aria-selected",String(c.has(h.value)))}))}return d.addEventListener("keydown",m=>{const h={ArrowUp:g-1,ArrowDown:g+1,Home:0,End:o.length-1}[m.key];h!==void 0?(m.preventDefault(),f(h)):m.key===" "?(m.preventDefault(),v(),s||b()):m.key==="Enter"?(m.preventDefault(),s||(c.clear(),v()),b()):a&&!s&&(m.key==="ArrowLeft"||m.key==="ArrowRight")&&(m.preventDefault(),c.clear(),v(),b(),e.controller.moveTo(t,Math.max(0,n+(m.key==="ArrowLeft"?-1:1))))}),x.append(d),s&&x.append(H(e,b)),o.length===0&&d.append(p("div",{class:"ct-item",text:k("No items")})),d})}const Zt=300,O=24,ct=new WeakMap;function te(e){let t=ct.get(e);return t===void 0&&(t=e.map(n=>String(n.text).toLowerCase()),ct.set(e,t)),t}function ee(e,t,n,{items:o,selected:r,onDone:s,label:u,maxItems:i,moveOnSide:l,float:a}){T(e,t,n,u,y=>{a!==void 0&&ot(a);const x=te(o),c=r.length?String(r[0]).toLowerCase():null,g=Int32Array.from(o.keys());let b=g,d=Math.max(0,c===null?0:o.findIndex(S=>String(S.value).toLowerCase()===c));const C=p("input",{type:"search",placeholder:k("Search"),ariaLabel:k("Search the list")});C.style.width="100%",C.style.boxSizing="border-box",C.style.marginBottom="4px";const w=p("div",{class:"ct-count"}),f=p("div",{class:"ct-list",role:"listbox",ariaLabel:k(u),tabIndex:0}),v=i>0?i:10;f.style.height=`${v*O}px`,f.style.maxHeight="none",f.style.position="relative";const m=p("div");f.append(m);let h=[];const D=S=>{const A=o[b[S]];A&&s([A.value])!==!1&&R()},L=()=>{m.style.height=`${b.length*O}px`;for(const E of h)E.remove();h=[];const S=Math.max(0,Math.floor(f.scrollTop/O)-2),A=Math.min(b.length,S+v+4);for(let E=S;E<A;E++){const J=o[b[E]],Q=c!==null&&String(J.value).toLowerCase()===c,I=p("div",{class:`ct-item${E===d?" ct-cursor":""}`,role:"option",ariaSelected:String(Q),onclick:()=>D(E)},p("span",{class:"ct-mark",text:Q?"✓":""}),p("span",{text:J.text}));I.style.position="absolute",I.style.top=`${E*O}px`,I.style.left="0",I.style.right="0",I.style.height=`${O}px`,I.style.boxSizing="border-box",f.append(I),h.push(I)}w.textContent=b.length===o.length?k("{n} items",{n:o.length.toLocaleString()}):k("{n} of {total}",{n:b.length.toLocaleString(),total:o.length.toLocaleString()})},M=S=>{d=Math.max(0,Math.min(b.length-1,S));const A=d*O;A<f.scrollTop?f.scrollTop=A:A+O>f.scrollTop+f.clientHeight&&(f.scrollTop=A+O-f.clientHeight),L()};f.addEventListener("scroll",L),C.addEventListener("input",()=>{const S=C.value.trim().toLowerCase();if(S==="")b=g;else{const A=[];for(let E=0;E<x.length;E++)x[E].includes(S)&&A.push(E);b=Int32Array.from(A)}d=0,f.scrollTop=0,L()});const B=S=>{const A=v-1,E={ArrowUp:d-1,ArrowDown:d+1,PageUp:d-A,PageDown:d+A}[S.key];E!==void 0?(S.preventDefault(),M(E)):S.key==="Enter"?(S.preventDefault(),D(d)):l&&S.target===f&&(S.key==="ArrowLeft"||S.key==="ArrowRight")&&(S.preventDefault(),D(d),e.controller.moveTo(t,Math.max(0,n+(S.key==="ArrowLeft"?-1:1))))};return C.addEventListener("keydown",B),f.addEventListener("keydown",B),y.append(C,f,w),L(),requestAnimationFrame(()=>M(d)),C})}const ne={calendar:_t,time:zt,month:Kt,datetime:Yt,color:qt,slider:Gt,calculator:Xt,list:Qt};function ut(e,t,n,o){j.get(o.type)?.open?.(e,t,n,o)!==!0&&ne[o.type]?.(e,t,n,o)}function Ce(e,t,n,o){return e.loading?!1:(V(e,t,n,{overFormula:!0})&&ut(e,t,n,o),!0)}function De(e,t,n){const{sheet:o}=e.book,r=nt(o,t,n);if(!r||e.loading)return!1;if(!V(e,t,n,{overFormula:!0}))return!0;const s=o.mergeAt(t,n);return ut(e,s?s.r0:t,s?s.c0:n,r),!0}export{G as DROPDOWN_TYPES,Tt as MAX_APPLY_CELLS,X as MONTHS,ye as applyToRanges,at as buildCalendar,V as canWriteCell,xe as cellDropdownArrow,z as cellKey,U as cellSerial,Ot as clipRange,R as closeDropdown,$ as commit,nt as dropdownAt,H as footer,ve as isDropdownOpen,Jt as listData,Rt as literalInput,p as make,jt as makeCalculator,ge as makeDropdown,De as openCellDropdown,Ce as openDropdownConfig,ke as openListPopup,T as openPopup,we as popupViewChanged,Y as readCellValue,me as registerDropdownKind,ot as setPopupFloat,be as setPopupKeepOpen,q as swapMap,lt as timeInputs,_ as todaySerial,$t as writeCell};
package/core/address.js CHANGED
@@ -1 +1 @@
1
- const F=1048576,T=16384,$=[];function a(t){let e=$[t];if(e!==void 0)return e;e="";for(let n=t+1;n>0;n=Math.floor((n-1)/26))e=String.fromCharCode(65+(n-1)%26)+e;return $[t]=e,e}function s(t){let e=0;for(let n=0;n<t.length;n++){const r=t.charCodeAt(n)&223;if(r<65||r>90)return-1;e=e*26+(r-64)}return e-1}function S(t,e){return a(e)+(t+1)}const h=/^[\p{L}\p{Nl}\p{No}_\\][\p{L}\p{N}\p{M}_.\\?]*$/u,N=/^([A-Za-z]{1,3})(\d+)$/,L=/^[Rr](\d*)(?:[Cc]\d*)?$|^[Cc](\d*)$/,_=(t,e)=>t===""||Number(t)>=1&&Number(t)<=e;function q(t){if(t.length>255||!h.test(t)||/^(TRUE|FALSE)$/i.test(t)||t.length===2&&t[0]==="\\")return!1;const e=N.exec(t);if(e&&s(e[1])<16384&&_(e[2],1048576))return!1;const n=L.exec(t);return!(n&&_(n[1]??n[2],1048576))}const m=/^\$?([A-Za-z]{1,3})\$?([1-9][0-9]{0,6})$/;function C(t){const e=m.exec(t.trim());if(!e)return null;const n=s(e[1]),r=Number(e[2])-1;return n<0||n>=16384||r>=1048576?null:{row:r,col:n}}function P(t){const e=t.trim().split(":");if(e.length>2||!e[0])return null;const n=(o,c)=>{const l=/^\$?[A-Za-z]{1,3}$/.test(o)?s(o.replace("$","")):-1,f=/^\$?[A-Za-z]{1,3}$/.test(c)?s(c.replace("$","")):-1;if(l>=0&&f>=0&&l<16384&&f<16384)return{r0:0,c0:Math.min(l,f),r1:1048575,c1:Math.max(l,f)};const i=/^\$?[0-9]+$/.test(o)?Number(o.replace("$",""))-1:-1,p=/^\$?[0-9]+$/.test(c)?Number(c.replace("$",""))-1:-1;return i>=0&&p>=0&&i<1048576&&p<1048576?{r0:Math.min(i,p),c0:0,r1:Math.max(i,p),c1:16383}:null},r=C(e[0]);if(e.length===1)return r?{r0:r.row,c0:r.col,r1:r.row,c1:r.col}:null;const u=C(e[1]);return r&&u?{r0:Math.min(r.row,u.row),c0:Math.min(r.col,u.col),r1:Math.max(r.row,u.row),c1:Math.max(r.col,u.col)}:n(e[0],e[1])}function U({r0:t,c0:e,r1:n,c1:r}){if(t===0&&n===1048575)return`${a(e)}:${a(r)}`;if(e===0&&r===16383)return`${t+1}:${n+1}`;const u=S(t,e);return t===n&&e===r?u:`${u}:${S(n,r)}`}const R=/[\x00-\x2d\x2f\x3a-\x40\x5b-\x5e\x60\x7b-\x7f]/,M=/[\s\p{C}]/u,O=/^[\p{Nd}.]/u,g=/^([A-Za-z]{1,3})(\p{Nd}+)$/u,X=/^([A-Za-z]{1,3}\p{Nd}+)\.+([A-Za-z]{1,3}\p{Nd}+)$/u,I=/^R(\p{Nd}+)/iu,E=/^R?C(\p{Nd}+)/iu,w=/^[0-9]+$/,x=(t,e)=>!w.test(t)||Number(t)>=1&&Number(t)<=e;function A(t){const e=g.exec(t);return e!==null&&s(e[1])<16384&&x(e[2],1048576)}function d(t,e=!1){const n=String(t??"");if(n===""||R.test(n)||M.test(n)||O.test(n))return!0;const r=n.toUpperCase();if(r==="TRUE"||r==="FALSE"||r==="R"||r==="C"||r==="RC")return!0;if(!e){if(A(n))return!0;const c=X.exec(n);if(c&&A(c[1])&&A(c[2]))return!0}const u=I.exec(n);if(u&&x(u[1],1048576))return e||n[u[0].length]!==".";const o=E.exec(n);return o&&x(o[1],16384)?e||n[o[0].length]!==".":!1}function W(t,{book:e=null,last:n=null,r1c1:r=!1,always:u=!1}={}){const o=String(t??""),c=`${e!=null?`[${e}]`:""}${o}${n!=null?`:${n}`:""}`;return u||(o!==""||e===null||e===void 0)&&d(o,r)||n!=null&&d(n,r)||e!=null&&(R.test(e)||M.test(e))?`'${c.replace(/'/g,"''")}'`:c}const B=String.raw`[A-Za-z_\u0080-￿][\w.\u0080-￿]*`,z=(t,e)=>`${W(t,e)}!`;function Z(t){const e=String(t).replace(/[.*+?^${}()|[\]\\]/g,"\\$&").replace(/'/g,"''");return new RegExp(`(?:'${e}'|(?<![\\p{L}\\p{N}_.'\\]\\u0080-\\u{10FFFF}])${e})!`,"giu")}function G(t,e,n){const r=z(n);return String(t).replace(Z(e),()=>r)}function K(t){const e=String(t??"");return e.length>1&&e[0]==="'"&&e[e.length-1]==="'"?e.slice(1,-1).replace(/''/g,"'"):e}export{T as MAX_COLS,F as MAX_ROWS,B as PLAIN_SHEET,S as cellRef,s as colIndex,a as colName,q as isValidName,C as parseCellRef,P as parseRangeRef,W as quoteSheetName,U as rangeRef,G as renameSheetInFormula,d as sheetNeedsQuotes,z as sheetPrefix,Z as sheetReferencePattern,K as unquoteSheetName};
1
+ const P=1048576,U=16384,S=[];function a(t){let e=S[t];if(e!==void 0)return e;e="";for(let n=t+1;n>0;n=Math.floor((n-1)/26))e=String.fromCharCode(65+(n-1)%26)+e;return S[t]=e,e}function f(t){let e=0;for(let n=0;n<t.length;n++){const r=t.charCodeAt(n)&223;if(r<65||r>90)return-1;e=e*26+(r-64)}return e-1}function d(t,e){return a(e)+(t+1)}const M=/^[\p{L}\p{Nl}\p{No}_\\][\p{L}\p{N}\p{M}_.\\?]*$/u,h=/^([A-Za-z]{1,3})(\d+)$/,N=/^[Rr](\d*)(?:[Cc]\d*)?$|^[Cc](\d*)$/,C=(t,e)=>t===""||Number(t)>=1&&Number(t)<=e;function q(t){if(t.length>255||!M.test(t)||/^(TRUE|FALSE)$/i.test(t)||t.length===2&&t[0]==="\\")return!1;const e=h.exec(t);if(e&&f(e[1])<16384&&C(e[2],1048576))return!1;const n=N.exec(t);return!(n&&C(n[1]??n[2],1048576))}const g=/^\$?([A-Za-z]{1,3})\$?([1-9][0-9]{0,6})$/;function _(t){const e=g.exec(t.trim());if(!e)return null;const n=f(e[1]),r=Number(e[2])-1;return n<0||n>=16384||r>=1048576?null:{row:r,col:n}}function B(t){const e=t.trim().split(":");if(e.length>2||!e[0])return null;const n=(u,c)=>{const i=/^\$?[A-Za-z]{1,3}$/.test(u)?f(u.replace("$","")):-1,s=/^\$?[A-Za-z]{1,3}$/.test(c)?f(c.replace("$","")):-1;if(i>=0&&s>=0&&i<16384&&s<16384)return{r0:0,c0:Math.min(i,s),r1:1048575,c1:Math.max(i,s)};const l=/^\$?[0-9]+$/.test(u)?Number(u.replace("$",""))-1:-1,p=/^\$?[0-9]+$/.test(c)?Number(c.replace("$",""))-1:-1;return l>=0&&p>=0&&l<1048576&&p<1048576?{r0:Math.min(l,p),c0:0,r1:Math.max(l,p),c1:16383}:null},r=_(e[0]);if(e.length===1)return r?{r0:r.row,c0:r.col,r1:r.row,c1:r.col}:null;const o=_(e[1]);return r&&o?{r0:Math.min(r.row,o.row),c0:Math.min(r.col,o.col),r1:Math.max(r.row,o.row),c1:Math.max(r.col,o.col)}:n(e[0],e[1])}function G({r0:t,c0:e,r1:n,c1:r}){if(t===0&&n===1048575)return`${a(e)}:${a(r)}`;if(e===0&&r===16383)return`${t+1}:${n+1}`;const o=d(t,e);return t===n&&e===r?o:`${o}:${d(n,r)}`}const R=/[\x00-\x2d\x2f\x3a-\x40\x5b-\x5e\x60\x7b-\x7f]/,L=/[\s\p{C}]/u,O=/^[\p{Nd}.]/u,m=/^([A-Za-z]{1,3})(\p{Nd}+)$/u,w=/^([A-Za-z]{1,3}\p{Nd}+)\.+([A-Za-z]{1,3}\p{Nd}+)$/u,X=/^R(\p{Nd}+)/iu,E=/^R?C(\p{Nd}+)/iu,I=/^[0-9]+$/,x=(t,e)=>!I.test(t)||Number(t)>=1&&Number(t)<=e;function $(t){const e=m.exec(t);return e!==null&&f(e[1])<16384&&x(e[2],1048576)}function A(t,e=!1){const n=String(t??"");if(n===""||R.test(n)||L.test(n)||O.test(n))return!0;const r=n.toUpperCase();if(r==="TRUE"||r==="FALSE"||r==="R"||r==="C"||r==="RC")return!0;if(!e){if($(n))return!0;const c=w.exec(n);if(c&&$(c[1])&&$(c[2]))return!0}const o=X.exec(n);if(o&&x(o[1],1048576))return e||n[o[0].length]!==".";const u=E.exec(n);return u&&x(u[1],16384)?e||n[u[0].length]!==".":!1}function F(t,{book:e=null,last:n=null,r1c1:r=!1,always:o=!1}={}){const u=String(t??""),c=`${e!=null?`[${e}]`:""}${u}${n!=null?`:${n}`:""}`;return o||(u!==""||e===null||e===void 0)&&A(u,r)||n!=null&&A(n,r)||e!=null&&(R.test(e)||L.test(e))?`'${c.replace(/'/g,"''")}'`:c}const H=String.raw`[A-Za-z_\u0080-￿][\w.\u0080-￿]*`,W=(t,e)=>`${F(t,e)}!`;function K(t){const e=String(t).replace(/[.*+?^${}()|[\]\\]/g,"\\$&").replace(/'/g,"''");return new RegExp(`(?:'${e}'|(?<![\\p{L}\\p{N}_.'\\]\\u0080-\\u{10FFFF}])${e})!`,"giu")}const z=/"(?:[^"]|"")*"|'((?:[^']|'')*)'!|(?<![\p{L}\p{N}_.'\]\u0080-\u{10FFFF}])([^\s"'!:,;()+\-*/^&=<>%{}@#$[\]]+)(?::([^\s"'!:,;()+\-*/^&=<>%{}@#$[\]]+|'(?:[^']|'')*'))?!/gu;function Z(t,e){const n=String(t);return n.includes("!")?n.replace(z,(r,o,u,c)=>{if(o!==void 0){const s=o.replace(/''/g,"'");if(s.includes("]"))return r;const l=s.indexOf(":");return e(l<0?s:s.slice(0,l),l<0?null:s.slice(l+1))??r}if(u===void 0)return r;if(c===void 0)return e(u,null)??r;const i=T(c);if(A(u)){const s=e(i,null);return s===null?r:`${u}:${s}`}return e(u,i)??r}):n}function y(t,e,n){const r=String(e).toLowerCase(),o=u=>u.toLowerCase()===r?n:u;return Z(t,(u,c)=>u.toLowerCase()!==r&&c?.toLowerCase()!==r?null:W(o(u),{last:c===null?null:o(c)}))}function T(t){const e=String(t??"");return e.length>1&&e[0]==="'"&&e[e.length-1]==="'"?e.slice(1,-1).replace(/''/g,"'"):e}export{U as MAX_COLS,P as MAX_ROWS,H as PLAIN_SHEET,d as cellRef,f as colIndex,a as colName,q as isValidName,Z as mapSheetParts,_ as parseCellRef,B as parseRangeRef,F as quoteSheetName,G as rangeRef,y as renameSheetInFormula,A as sheetNeedsQuotes,W as sheetPrefix,K as sheetReferencePattern,T as unquoteSheetName};
package/core/autofill.js CHANGED
@@ -1 +1 @@
1
- import{EMPTY as S,FORMULA as M,KIND_MASK as w,NUM as y,STR as $}from"./sheet.js";import{culture as O}from"./culture.js";import{partsToSerial as v,serialToParts as L}from"./numfmt.js";const T=[["Monday","Tuesday","Wednesday","Thursday","Friday","Saturday","Sunday"],["Mon","Tue","Wed","Thu","Fri","Sat","Sun"],["January","February","March","April","May","June","July","August","September","October","November","December"],["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"]],z=[["Poniedziałek","Wtorek","Środa","Czwartek","Piątek","Sobota","Niedziela"],["Pon","Wt","Śr","Czw","Pt","Sob","Niedz"],["Styczeń","Luty","Marzec","Kwiecień","Maj","Czerwiec","Lipiec","Sierpień","Wrzesień","Październik","Listopad","Grudzień"],["Sty","Lut","Mar","Kwi","Maj","Cze","Lip","Sie","Wrz","Paź","Lis","Gru"]],_=[...T,...z],F=[...z,...T];function B(t,e){return t===t.toUpperCase()?e.toUpperCase():t===t.toLowerCase()?e.toLowerCase():e}const C=t=>/[ymd]/i.test(t.replace(/"[^"]*"|\[[^\]]*\]/g,""))&&!/^general$/i.test(t);function A(t,e){const n=t.toLowerCase(),f=O().language==="pl"?F:_;for(const l of f){const r=l.findIndex(i=>i.toLowerCase()===n);if(r>=0)return{list:l,i:r}}if(e)for(const l of e){const r=l.findIndex(i=>i.toLowerCase()===n);if(r>=0)return{list:l,i:r}}return null}const b=(t,e)=>(e===12?v(t+1,1,1):v(t,e+1,1))-v(t,e,1);function x(t,e){const n=t.year*12+t.month-1+e,f=Math.floor(n/12),l=n-f*12+1;return v(f,l,Math.min(t.day,b(f,l)))}const D=t=>{const e=t%100;return e>=11&&e<=13?"th":["th","st","nd","rd"][t%10]??"th"},I=/^(?:q|qtr|quarter)\.?\s*$/i;function N(t){const e=/^(.*?)(\d+)(st|nd|rd|th)(.*)$/i.exec(t);if(e&&!/\d/.test(e[4])){const[,o,s,u,c]=e,p=Number(s),g=o===""&&I.test(c.trim())&&p>=1&&p<=4;return{pre:o,num:p,width:s.length,ord:!0,upper:u===u.toUpperCase(),rest:c,wrap:g,key:`${o}\0ord\0${c}`}}const n=/^(\d+)( .*)$/s.exec(t);if(n)return{pre:"",num:Number(n[1]),width:n[1].length,ord:!1,rest:n[2],wrap:!1,key:`\0lead\0${n[2]}`};const f=/^(.*?)(\d+)$/s.exec(t);if(!f)return null;const[,l,r]=f,i=Number(r),a=I.test(l)&&i>=1&&i<=4;return{pre:l,num:i,width:r.length,ord:!1,rest:"",wrap:a,key:`${l}\0`}}function E(t,e){const n=t.wrap?((e-1)%4+4)%4+1:Math.abs(e),f=String(n).padStart(t.width,"0");if(!t.ord)return`${t.pre}${f}${t.rest}`;const l=D(n);return`${t.pre}${f}${t.upper?l.toUpperCase():l}${t.rest}`}function J(t,e={}){const n=t.length,f=e.direction??1;if(n===0||t.some(r=>r.kind&M))return()=>null;const l=t.map(r=>r.kind&w);if(l.every(r=>r===y)){const r=C(t[0].format??"General");if(n===1){if(!r&&e.alone&&!e.force)return()=>null;const d=r&&W(t[0].format)?1/24:1;return h=>({kind:y,value:t[0].value+f*d*(h+1)})}const i=t[1].value-t[0].value;let a=!0;for(let d=2;d<n;d++)Math.abs(t[d].value-t[d-1].value-i)>1e-9&&(a=!1);if(r){const d=t.map(m=>L(m.value)),h=(d[1].year-d[0].year)*12+d[1].month-d[0].month,P=m=>m.day===d[0].day||m.day<d[0].day&&m.day===b(m.year,m.month);if(d.every(P)&&h!==0)return m=>({kind:y,value:x(d[0],h*(n+m))})}if(a)return d=>({kind:y,value:t[n-1].value+i*(d+1)});const o=t.map((d,h)=>h),s=o.reduce((d,h)=>d+h,0)/n,u=t.reduce((d,h)=>d+h.value,0)/n;let c=0,p=0;for(let d=0;d<n;d++)c+=(o[d]-s)*(t[d].value-u),p+=(o[d]-s)**2;const g=c/p,k=u-g*s;return d=>({kind:y,value:k+g*(n+d)})}if(l.every(r=>r===$)){const r=t.map(a=>A(a.text,e.lists));if(r.every(Boolean)&&r.every(a=>a.list===r[0].list)){const{list:a}=r[0],o=n>=2&&(r[1].i-r[0].i+a.length)%a.length||f;return s=>{const u=(r[n-1].i+o*(s+1))%a.length;return{text:B(t[0].text,a[u<0?u+a.length:u])}}}const i=t.map(a=>N(a.text));if(i.every(Boolean)&&i.every(a=>a.key===i[0].key)){const a=i.map(u=>u.num),o=n>=2?a[1]-a[0]:f;let s=!0;for(let u=2;u<n;u++)a[u]-a[u-1]!==o&&(s=!1);if(s&&o!==0)return u=>({text:E(i[0],a[n-1]+o*(u+1))})}}return()=>null}function W(t){const e=String(t??"").replace(/"[^"]*"|\[[^\]]*\]|\\./g,"");return!/[dy]/i.test(e)&&/[hs]/i.test(e)}function U(t,e){const n=t.kind&w;if(t.kind&M||n===S)return null;if(n===y)return C(t.format??"General")?"date":"number";if(n!==$)return null;const f=A(t.text,e);if(f)return f.list;const l=N(t.text);return l?`text:${l.key}`:null}function q(t,e={}){const n=[],f=new Int32Array(t.length).fill(-1),l=new Int32Array(t.length),r=a=>(a.kind&w)===S&&!(a.kind&M);let i=!1;for(let a=0;a<t.length;){const o=U(t[a],e.lists);if(o===null){a++;continue}const s=[a];for(let c=a+1;c<t.length;c++)if(!r(t[c])){if(U(t[c],e.lists)!==o)break;s.push(c)}const u=J(s.map(c=>t[c]),{...e,alone:t.length===1});u(0)!==null&&(i=!0),s.forEach((c,p)=>{f[c]=n.length,l[c]=p}),n.push({n:s.length,series:u}),a=s[s.length-1]+1}return{active:i,at(a,o){const s=f[a];if(s<0)return null;const u=n[s];return u.series(o*u.n+l[a])}}}function H(t,e,n=1){const f=t.length,l=t[f-1].value;if(e==="days"){const o=f>=2?t[1].value-t[0].value:n;return(s,u)=>({kind:y,value:l+o*(u*f+s+1)})}if(e==="weekdays")return f>1?(o,s)=>({kind:y,value:t[o].value+n*7*(s+1)}):(o,s)=>({kind:y,value:G(l,"weekday",n,s+1)});const r=n*(e==="months"?1:12),i=L(t[0].value),a=v(i.year,i.month,1);return(o,s)=>{const u=t[o].value,c=Math.floor(u)-a+1,p=i.year*12+i.month-1+r*(s+1),g=Math.floor(p/12),k=p-g*12+1,d=v(g,k,1),h=c>=1&&c<=31?d+Math.min(c,b(g,k))-1:d+c-1;return{kind:y,value:h+(u-Math.floor(u))}}}function G(t,e,n,f){if(e==="day")return t+n*f;const l=L(t),r=t-Math.floor(t);if(e==="month")return x(l,n*f)+r;if(e==="year")return x(l,12*n*f)+r;let i=t;const a=n*f<0?-1:1;for(let o=Math.abs(n*f);o>0;){i+=a;const s=Math.floor(i)%7;s!==0&&s!==1&&o--}return i}function Y(t){const e=[],n=t[0];n.source.forEach((r,i)=>{r.split(/[\s,;._-]+/).filter(Boolean).forEach((o,s)=>{for(const u of[c=>c,c=>c.toUpperCase(),c=>c.toLowerCase(),c=>c.charAt(0).toUpperCase()+c.slice(1).toLowerCase()])e.push(c=>u((c[i]??"").split(/[\s,;._-]+/).filter(Boolean)[s]??""));e.push(u=>((u[i]??"").split(/[\s,;._-]+/).filter(Boolean)[s]??"").charAt(0)),e.push(u=>((u[i]??"").split(/[\s,;._-]+/).filter(Boolean)[s]??"").charAt(0).toUpperCase())}),e.push(o=>(o[i]??"").toUpperCase()),e.push(o=>(o[i]??"").toLowerCase()),e.push(o=>(o[i]??"").replace(/\S+/g,s=>s.charAt(0).toUpperCase()+s.slice(1).toLowerCase())),e.push(o=>(o[i]??"").replace(/\D/g,"")),e.push(o=>(o[i]??"").replace(/[^\p{L}]/gu,""));for(let o=1;o<=Math.min(r.length,12);o++)e.push(s=>(s[i]??"").slice(0,o)),e.push(s=>(s[i]??"").slice(-o))});const f=e.slice(),l=n.target;for(let r=1;r<l.length;r++){const i=l.slice(0,r);for(const a of f)if(a(n.source)===i)for(const o of[0,1,2,3]){const s=l.slice(r,r+o),u=l.slice(r+o);if(!/[\p{L}\d]/u.test(s))for(const c of f)c(n.source)===u&&e.push(p=>`${a(p)}${s}${c(p)}`)}}return e.find(r=>t.every(i=>r(i.source)===i.target))??null}export{_ as BUILTIN_LISTS,S as EMPTY,G as dateStep,Y as flashFillRule,C as isDateFormat,H as makeDatePlan,q as makeFillPlan,J as makeSeries};
1
+ import{EMPTY as x,FORMULA as $,KIND_MASK as A,NUM as y,STR as T}from"./sheet.js";import{culture as D}from"./culture.js";import{partsToSerial as g,serialToParts as L}from"./numfmt.js";const z=[["Monday","Tuesday","Wednesday","Thursday","Friday","Saturday","Sunday"],["Mon","Tue","Wed","Thu","Fri","Sat","Sun"],["January","February","March","April","May","June","July","August","September","October","November","December"],["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"]],U=[["Poniedziałek","Wtorek","Środa","Czwartek","Piątek","Sobota","Niedziela"],["Pon","Wt","Śr","Czw","Pt","Sob","Niedz"],["Styczeń","Luty","Marzec","Kwiecień","Maj","Czerwiec","Lipiec","Sierpień","Wrzesień","Październik","Listopad","Grudzień"],["Sty","Lut","Mar","Kwi","Maj","Cze","Lip","Sie","Wrz","Paź","Lis","Gru"]],E=[...z,...U],J=[...U,...z];function W(t,e){return t===t.toUpperCase()?e.toUpperCase():t===t.toLowerCase()?e.toLowerCase():e}const I=t=>/[ymd]/i.test(t.replace(/"[^"]*"|\[[^\]]*\]|\\.|_.|\*./g,""))&&!/^general$/i.test(t);function P(t,e){const n=t.toLowerCase(),d=D().language==="pl"?J:E;for(const l of d){const r=l.findIndex(i=>i.toLowerCase()===n);if(r>=0)return{list:l,i:r}}if(e)for(const l of e){const r=l.findIndex(i=>i.toLowerCase()===n);if(r>=0)return{list:l,i:r}}return null}const b=(t,e)=>(e===12?g(t+1,1,1):g(t,e+1,1))-g(t,e,1);function C(t,e){const n=t.year*12+t.month-1+e,d=Math.floor(n/12),l=n-d*12+1;return g(d,l,Math.min(t.day,b(d,l)))}const G=t=>{const e=t%100;return e>=11&&e<=13?"th":["th","st","nd","rd"][t%10]??"th"},_=/^(?:q|qtr|quarter)\.?\s*$/i;function O(t){const e=/^(.*?)(\d+)(st|nd|rd|th)(.*)$/i.exec(t);if(e&&!/\d/.test(e[4])){const[,a,s,u,c]=e,m=Number(s),v=a===""&&_.test(c.trim())&&m>=1&&m<=4;return{pre:a,num:m,width:s.length,ord:!0,upper:u===u.toUpperCase(),rest:c,wrap:v,key:`${a}\0ord\0${c}`}}const n=/^(\d+)( .*)$/s.exec(t);if(n)return{pre:"",num:Number(n[1]),width:n[1].length,ord:!1,rest:n[2],wrap:!1,key:`\0lead\0${n[2]}`};const d=/^(.*?)(\d+)$/s.exec(t);if(!d)return null;const[,l,r]=d,i=Number(r),o=_.test(l)&&i>=1&&i<=4;return{pre:l,num:i,width:r.length,ord:!1,rest:"",wrap:o,key:`${l}\0`}}function R(t,e){const n=t.wrap?((e-1)%4+4)%4+1:Math.abs(e),d=String(n).padStart(t.width,"0");if(!t.ord)return`${t.pre}${d}${t.rest}`;const l=G(n);return`${t.pre}${d}${t.upper?l.toUpperCase():l}${t.rest}`}function j(t,e={}){const n=t.length,d=e.direction??1;if(n===0||t.some(r=>r.kind&$))return()=>null;const l=t.map(r=>r.kind&A);if(l.every(r=>r===y)){const r=I(t[0].format??"General");if(n===1){if(!r&&e.alone&&!e.force)return()=>null;const f=r&&F(t[0].format)?1/24:1;return p=>({kind:y,value:t[0].value+d*f*(p+1)})}const i=t[1].value-t[0].value;let o=!0;for(let f=2;f<n;f++)Math.abs(t[f].value-t[f-1].value-i)>1e-9&&(o=!1);if(r){const f=t.map(h=>L(h.value)),p=(f[1].year-f[0].year)*12+f[1].month-f[0].month,k=h=>h.day===f[0].day||h.day<f[0].day&&h.day===b(h.year,h.month),N=f.every((h,M)=>(h.year-f[0].year)*12+h.month-f[0].month===p*M);if(f.every(k)&&p!==0&&N){const h=t[0].value-Math.floor(t[0].value),M=t.every(w=>Math.abs(w.value-Math.floor(w.value)-h)<1e-9);return w=>({kind:y,value:C(f[0],p*(n+w))+(M?h:0)})}}if(o)return f=>({kind:y,value:t[n-1].value+i*(f+1)});if(r&&!F(t[0].format)){const f=t.map(h=>L(h.value)),p=h=>h.year*12+h.month,k=p(f[1])-p(f[0]);if(t.every(h=>Number.isInteger(h.value))&&k!==0&&f.every((h,M)=>h.day===b(h.year,h.month)&&p(h)-p(f[0])===k*M))return h=>({kind:y,value:C({...f[0],day:31},k*(n+h))});if(!e.force)return()=>null}const a=t.map((f,p)=>p),s=a.reduce((f,p)=>f+p,0)/n,u=t.reduce((f,p)=>f+p.value,0)/n;let c=0,m=0;for(let f=0;f<n;f++)c+=(a[f]-s)*(t[f].value-u),m+=(a[f]-s)**2;const v=c/m,S=u-v*s;return f=>({kind:y,value:S+v*(n+f)})}if(l.every(r=>r===T)){const r=t.map(o=>P(o.text,e.lists));if(r.every(Boolean)&&r.every(o=>o.list===r[0].list)){const{list:o}=r[0],a=n>=2&&(r[1].i-r[0].i+o.length)%o.length||d;return s=>{const u=(r[n-1].i+a*(s+1))%o.length;return{text:W(t[0].text,o[u<0?u+o.length:u])}}}const i=t.map(o=>O(o.text));if(i.every(Boolean)&&i.every(o=>o.key===i[0].key)){const o=i.map(u=>u.num),a=n>=2?o[1]-o[0]:d;let s=!0;for(let u=2;u<n;u++)o[u]-o[u-1]!==a&&(s=!1);if(s&&a!==0)return u=>({text:R(i[0],o[n-1]+a*(u+1))})}}return()=>null}function F(t){const e=String(t??"").replace(/"[^"]*"|\[[^\]]*\]|\\./g,"");return!/[dy]/i.test(e)&&/[hs]/i.test(e)}function B(t,e){const n=t.kind&A;if(t.kind&$||n===x)return null;if(n===y)return I(t.format??"General")?"date":"number";if(n!==T)return null;const d=P(t.text,e);if(d)return d.list;const l=O(t.text);return l?`text:${l.key}`:null}function Q(t,e={}){const n=[],d=new Int32Array(t.length).fill(-1),l=new Int32Array(t.length),r=o=>(o.kind&A)===x&&!(o.kind&$);let i=!1;for(let o=0;o<t.length;){const a=B(t[o],e.lists);if(a===null){o++;continue}const s=[o];for(let c=o+1;c<t.length;c++)if(!r(t[c])){if(B(t[c],e.lists)!==a)break;s.push(c)}const u=j(s.map(c=>t[c]),{...e,alone:t.length===1});u(0)!==null&&(i=!0),s.forEach((c,m)=>{d[c]=n.length,l[c]=m}),n.push({n:s.length,series:u,date:a==="date"}),o=s[s.length-1]+1}return{active:i,at(o,a){const s=d[o];if(s<0)return null;const u=n[s],c=u.series(a*u.n+l[o]);return c!==null&&c.kind===y&&c.value<0&&u.date?null:c}}}function X(t,e,n=1){const d=t.length,l=t[d-1].value;if(e==="days"){const a=d>=2?t[1].value-t[0].value:n;return(s,u)=>({kind:y,value:l+a*(u*d+s+1)})}if(e==="weekdays")return d>1?(a,s)=>({kind:y,value:t[a].value+n*7*(s+1)}):(a,s)=>({kind:y,value:K(l,"weekday",n,s+1)});const r=n*(e==="months"?1:12),i=L(t[0].value),o=g(i.year,i.month,1);return(a,s)=>{const u=t[a].value,c=Math.floor(u)-o+1,m=i.year*12+i.month-1+r*(s+1),v=Math.floor(m/12),S=m-v*12+1,f=g(v,S,1),p=c>=1&&c<=31?f+Math.min(c,b(v,S))-1:f+c-1;return{kind:y,value:p+(u-Math.floor(u))}}}function K(t,e,n,d){if(e==="day")return t+n*d;const l=L(t),r=t-Math.floor(t),i=Math.trunc(n*d+Math.sign(n*d)*1e-9);if(e==="month")return C(l,i)+r;if(e==="year")return C(l,12*i)+r;let o=t;const a=i<0?-1:1;for(let s=Math.abs(i);s>0;){o+=a;const u=Math.floor(o)%7;u!==0&&u!==1&&s--}return o}function V(t){const e=[],n=t[0];n.source.forEach((r,i)=>{r.split(/[\s,;._-]+/).filter(Boolean).forEach((a,s)=>{for(const u of[c=>c,c=>c.toUpperCase(),c=>c.toLowerCase(),c=>c.charAt(0).toUpperCase()+c.slice(1).toLowerCase()])e.push(c=>u((c[i]??"").split(/[\s,;._-]+/).filter(Boolean)[s]??""));e.push(u=>((u[i]??"").split(/[\s,;._-]+/).filter(Boolean)[s]??"").charAt(0)),e.push(u=>((u[i]??"").split(/[\s,;._-]+/).filter(Boolean)[s]??"").charAt(0).toUpperCase())}),e.push(a=>(a[i]??"").toUpperCase()),e.push(a=>(a[i]??"").toLowerCase()),e.push(a=>(a[i]??"").replace(/\S+/g,s=>s.charAt(0).toUpperCase()+s.slice(1).toLowerCase())),e.push(a=>(a[i]??"").replace(/\D/g,"")),e.push(a=>(a[i]??"").replace(/[^\p{L}]/gu,""));for(let a=1;a<=Math.min(r.length,12);a++)e.push(s=>(s[i]??"").slice(0,a)),e.push(s=>(s[i]??"").slice(-a))});const d=e.slice(),l=n.target;for(let r=1;r<l.length;r++){const i=l.slice(0,r);for(const o of d)if(o(n.source)===i)for(const a of[0,1,2,3]){const s=l.slice(r,r+a),u=l.slice(r+a);if(!/[\p{L}\d]/u.test(s))for(const c of d)c(n.source)===u&&e.push(m=>`${o(m)}${s}${c(m)}`)}}return e.find(r=>t.every(i=>r(i.source)===i.target))??null}export{E as BUILTIN_LISTS,x as EMPTY,K as dateStep,V as flashFillRule,I as isDateFormat,X as makeDatePlan,Q as makeFillPlan,j as makeSeries};
package/core/axis.js CHANGED
@@ -1 +1 @@
1
- const o=65535;class u{constructor(t,i){this.count=t,this.defaultSize=i,this.sizes=null,this.tree=null,this.hiddenSizes=null,this.autoFlags=null,this.topBit=1<<31-Math.clz32(t),this.delta=0,this.watcher=null,this.version=0}setDefaultSize(t){if(this.tree)throw new Error("Default size must be set before custom sizes");this.defaultSize=t,this.version++}changeDefaultSize(t){if(t!==this.defaultSize){if(this.defaultSize=t,this.version++,this.sizes!==null){this.tree.fill(0);let i=0;for(let s=0;s<this.count;s++){const h=this.sizes[s];h!==65535&&(i+=h-t,this.tree[s+1]+=h-t)}for(let s=1;s<=this.count;s++){const h=s+(s&-s);h<=this.count&&(this.tree[h]+=this.tree[s])}this.delta=i}this.watcher?.axisResized()}}get total(){return this.count*this.defaultSize+this.delta}sizeOf(t){if(this.sizes===null)return this.defaultSize;const i=this.sizes[t];return i===65535||i===void 0?this.defaultSize:i}isCustom(t){return this.sizes!==null&&t<this.count&&this.sizes[t]!==65535}isHidden(t){return this.hiddenSizes!==null&&this.hiddenSizes.has(t)}isAuto(t){return this.autoFlags!==null&&this.autoFlags[t]===1}setSize(t,i,s=!1){s&&this.autoFlags===null&&(this.autoFlags=new Uint8Array(this.count)),this.autoFlags!==null&&(this.autoFlags[t]=s?1:0);const h=i===null;i=h?this.defaultSize:Math.max(0,Math.min(65534,Math.round(i))),this.sizes===null&&(this.sizes=new Uint16Array(this.count).fill(65535),this.tree=new Int32Array(this.count+1));const n=this.sizeOf(t);this.sizes[t]=h?65535:i;const e=i-n;if(e!==0){this.version++,this.delta+=e;for(let l=t+1;l<=this.count;l+=l&-l)this.tree[l]+=e;this.watcher?.axisResized()}}setHidden(t,i){if(i){if(this.isHidden(t))return;this.hiddenSizes===null&&(this.hiddenSizes=new Map),this.hiddenSizes.set(t,this.isCustom(t)?this.sizeOf(t):-1),this.setSize(t,0),this.watcher?.axisHiddenChanged()}else if(this.isHidden(t)){const s=this.hiddenSizes.get(t);this.hiddenSizes.delete(t),this.setSize(t,s<=0?this.defaultSize:s),this.watcher?.axisHiddenChanged()}}offsetOf(t){let i=t*this.defaultSize;if(this.tree!==null)for(let s=Math.min(t,this.count);s>0;s-=s&-s)i+=this.tree[s];return i}indexAt(t){if(t<=0&&this.tree===null)return 0;if(this.tree===null){const n=Math.floor(t/this.defaultSize);return n>=this.count?this.count-1:n}let i=0,s=t;const h=this.defaultSize;for(let n=this.topBit;n>0;n>>=1){const e=i+n;if(e<=this.count){const l=n*h+this.tree[e];l<=s&&(i=e,s-=l)}}return i>=this.count?this.count-1:i}reshaped(t=this.count,i=this.defaultSize){const s=new u(t,i);if(this.sizes!==null){const h=Math.min(t,this.count);for(let n=0;n<h;n++)this.sizes[n]!==65535&&s.setSize(n,this.sizes[n],this.isAuto(n))}if(this.hiddenSizes!==null)for(const[h,n]of this.hiddenSizes)h<t&&(s.hiddenSizes??=new Map,s.hiddenSizes.set(h,n));return s}shifted(t,i){const s=new u(this.count,this.defaultSize);if(this.sizes===null)return s;const h=new Uint16Array(this.count).fill(65535);i>0?(h.set(this.sizes.subarray(0,t)),h.set(this.sizes.subarray(t,this.count-i),t+i)):(h.set(this.sizes.subarray(0,t)),h.set(this.sizes.subarray(t-i),t)),s.sizes=h,s.tree=new Int32Array(this.count+1);let n=0;for(let e=0;e<this.count;e++){const l=h[e];if(l===65535)continue;const r=l-this.defaultSize;n+=r,s.tree[e+1]+=r}for(let e=1;e<=this.count;e++){const l=e+(e&-e);l<=this.count&&(s.tree[l]+=s.tree[e])}if(s.delta=n,this.hiddenSizes!==null){s.hiddenSizes=new Map;for(const[e,l]of this.hiddenSizes)e<t?s.hiddenSizes.set(e,l):(i>0||e>=t-i)&&s.hiddenSizes.set(e+i,l)}if(this.autoFlags!==null){const e=new Uint8Array(this.count);i>0?(e.set(this.autoFlags.subarray(0,t)),e.set(this.autoFlags.subarray(t,this.count-i),t+i)):(e.set(this.autoFlags.subarray(0,t)),e.set(this.autoFlags.subarray(t-i),t)),s.autoFlags=e}return s}*customEntries(){if(this.sizes!==null)for(let t=0;t<this.count;t++)this.sizes[t]!==65535&&(yield t)}}export{u as Axis};
1
+ const o=65535;class u{constructor(t,i){this.count=t,this.defaultSize=i,this.sizes=null,this.tree=null,this.hiddenSizes=null,this.autoFlags=null,this.topBit=1<<31-Math.clz32(t),this.delta=0,this.watcher=null,this.version=0}setDefaultSize(t){if(this.tree)throw new Error("Default size must be set before custom sizes");this.defaultSize=t,this.version++}changeDefaultSize(t){if(t!==this.defaultSize){if(this.defaultSize=t,this.version++,this.sizes!==null){this.tree.fill(0);let i=0;for(let s=0;s<this.count;s++){const h=this.sizes[s];h!==65535&&(i+=h-t,this.tree[s+1]+=h-t)}for(let s=1;s<=this.count;s++){const h=s+(s&-s);h<=this.count&&(this.tree[h]+=this.tree[s])}this.delta=i}this.watcher?.axisResized()}}get total(){return this.count*this.defaultSize+this.delta}sizeOf(t){if(this.sizes===null)return this.defaultSize;const i=this.sizes[t];return i===65535||i===void 0?this.defaultSize:i}isCustom(t){return this.sizes!==null&&t<this.count&&this.sizes[t]!==65535}isHidden(t){return this.hiddenSizes!==null&&this.hiddenSizes.has(t)}isAuto(t){return this.autoFlags!==null&&this.autoFlags[t]===1}setSize(t,i,s=!1){s&&this.autoFlags===null&&(this.autoFlags=new Uint8Array(this.count)),this.autoFlags!==null&&(this.autoFlags[t]=s?1:0);const h=i===null;i=h?this.defaultSize:Math.max(0,Math.min(65534,Math.round(i))),this.sizes===null&&(this.sizes=new Uint16Array(this.count).fill(65535),this.tree=new Int32Array(this.count+1));const n=this.sizeOf(t);this.sizes[t]=h?65535:i;const e=i-n;if(e!==0){this.version++,this.delta+=e;for(let l=t+1;l<=this.count;l+=l&-l)this.tree[l]+=e;this.watcher?.axisResized()}}setHidden(t,i){if(i){if(this.isHidden(t))return;this.hiddenSizes===null&&(this.hiddenSizes=new Map),this.hiddenSizes.set(t,this.isCustom(t)?this.sizeOf(t):-1),this.setSize(t,0),this.watcher?.axisHiddenChanged()}else if(this.isHidden(t)){const s=this.hiddenSizes.get(t);this.hiddenSizes.delete(t),this.setSize(t,s<0?null:s||this.defaultSize),this.watcher?.axisHiddenChanged()}}offsetOf(t){let i=t*this.defaultSize;if(this.tree!==null)for(let s=Math.min(t,this.count);s>0;s-=s&-s)i+=this.tree[s];return i}indexAt(t){if(t<=0&&this.tree===null)return 0;if(this.tree===null){const n=Math.floor(t/this.defaultSize);return n>=this.count?this.count-1:n}let i=0,s=t;const h=this.defaultSize;for(let n=this.topBit;n>0;n>>=1){const e=i+n;if(e<=this.count){const l=n*h+this.tree[e];l<=s&&(i=e,s-=l)}}return i>=this.count?this.count-1:i}reshaped(t=this.count,i=this.defaultSize){const s=new u(t,i);if(this.sizes!==null){const h=Math.min(t,this.count);for(let n=0;n<h;n++)this.sizes[n]!==65535&&s.setSize(n,this.sizes[n],this.isAuto(n))}if(this.hiddenSizes!==null)for(const[h,n]of this.hiddenSizes)h<t&&(s.hiddenSizes??=new Map,s.hiddenSizes.set(h,n));return s}shifted(t,i){const s=new u(this.count,this.defaultSize);if(this.sizes===null)return s;const h=new Uint16Array(this.count).fill(65535);i>0?(h.set(this.sizes.subarray(0,t)),h.set(this.sizes.subarray(t,this.count-i),t+i)):(h.set(this.sizes.subarray(0,t)),h.set(this.sizes.subarray(t-i),t)),s.sizes=h,s.tree=new Int32Array(this.count+1);let n=0;for(let e=0;e<this.count;e++){const l=h[e];if(l===65535)continue;const r=l-this.defaultSize;n+=r,s.tree[e+1]+=r}for(let e=1;e<=this.count;e++){const l=e+(e&-e);l<=this.count&&(s.tree[l]+=s.tree[e])}if(s.delta=n,this.hiddenSizes!==null){s.hiddenSizes=new Map;for(const[e,l]of this.hiddenSizes)e<t?s.hiddenSizes.set(e,l):(i>0||e>=t-i)&&s.hiddenSizes.set(e+i,l)}if(this.autoFlags!==null){const e=new Uint8Array(this.count);i>0?(e.set(this.autoFlags.subarray(0,t)),e.set(this.autoFlags.subarray(t,this.count-i),t+i)):(e.set(this.autoFlags.subarray(0,t)),e.set(this.autoFlags.subarray(t-i),t)),s.autoFlags=e}return s}copy(){const t=Object.assign(new u(this.count,this.defaultSize),this);return t.sizes=this.sizes?.slice()??null,t.tree=this.tree?.slice()??null,t.autoFlags=this.autoFlags?.slice()??null,t.hiddenSizes=this.hiddenSizes&&new Map(this.hiddenSizes),t}*customEntries(){if(this.sizes!==null)for(let t=0;t<this.count;t++)this.sizes[t]!==65535&&(yield t)}}export{u as Axis};
@@ -1 +1 @@
1
- import{parseRangeRef as O}from"./address.js";import{BOOL as x,ERR as T,ERRORS as q,KIND_MASK as _,NUM as E,STR as C}from"./sheet.js";import{numberToText as F}from"../calc/values.js";import{formatGeneral as N,getFormatter as B}from"./numfmt.js";function A(r){return r.split(/\s+/).map(O).filter(Boolean)}import{CondFormats as H,cfEffectAt as J,evaluatorOf as P,iconAt as Q}from"../cells/cf-engine.js";function L(r,n,t){return r._ranges===void 0&&(r._ranges=A(r.sqref)),r._ranges.some(e=>n>=e.r0&&n<=e.r1&&t>=e.c0&&t<=e.c1)}function K(r,n,t){if(r.validations){for(const e of r.validations)if(L(e,n,t))return e}for(const e of r.hostRules??[])for(const{validation:i}of e.entries)if(i&&L(i,n,t))return i;return null}function h(r,n,t){r._ranges===void 0&&(r._ranges=r.sqref?A(r.sqref):[]);const e=r._ranges[0];return e?[e.r0,e.c0]:[n,t]}function S(r,n,t,e,i){const s=t.formula1.trim();if(s.startsWith('"'))return s.slice(1,-1).split(",").map(o=>o.trim());const l=r.engine;let a=l.template(s,...h(t,e,i)).fn(e,i,n);return a&&a.sheet&&(a=l.toArr(a)),a&&a.data?a.data.filter(o=>o!==null):[]}function W(r,n,t,e,i){return I(r,n,t,e,i).map(s=>s.text)}function I(r,n,t,e,i){const s=t.formula1.trim(),l=()=>S(r,n,t,e,i).map(p=>({text:String(p),value:p}));if(s.startsWith('"'))return l();const f=r.engine.template(s,...h(t,e,i)).fn(e,i,n);if(!f||!f.sheet)return l();const a=[],o=f.sheet;for(let p=f.r0;p<=Math.min(f.r1,o.maxRow);p++)for(let u=f.c0;u<=Math.min(f.c1,o.maxCol);u++){const m=o.kind(p,u)&_;if(m===0)continue;const g=o.value(p,u),c=r.styles.get(o.style(p,u)).numFmt;m===E?a.push({text:c==="General"?N(g):B(c).number(g).replace(/\u0001.?\u0001/g," ").trim(),value:g}):m===C?a.push({text:r.strings.get(g),value:r.strings.get(g)}):m===x?a.push({text:g?"TRUE":"FALSE",value:g!==0}):a.push({text:q[g]??"#N/A",value:null})}return a}function D(r,n,t,e,i,s){if(t?.type!=="list"||typeof s!="string"||/^[='"]/.test(s))return null;const l=s.trim().toLowerCase(),f=S(r,n,t,e,i).find(a=>typeof a=="string"&&a.trim().toLowerCase()===l);return f!==void 0&&f.trim()!==s.trim()?f.trim():null}function V(r,n,t,e,i,s,l,f){if(t.type==="none"||t.type===void 0)return!0;if(s===0)return t.allowBlank;const a=r.engine,o=c=>{if(!c)return null;const d=a.template(c,...h(t,e,i)),y=a.legacy;a.legacy=!0;try{const R=d.fn(e,i,n);return R&&R.sheet?a.refAuto(R,e,i):R}finally{a.legacy=y}},p=s===E?F(l):s===x?l?"TRUE":"FALSE":String(f);if(t.type==="list"){if(s===T)return!1;const c=S(r,n,t,e,i);if(s===E&&c.some(y=>(typeof y=="number"?y:Number(y))===l))return!0;const d=p.trim().toLowerCase();return c.some(y=>String(y).trim().toLowerCase()===d)}if(t.type==="custom"){const c=[n.kind(e,i),n.value(e,i),n.maxRow,n.maxCol],d=s===C?r.strings.add(String(f)):s===x?l?1:0:l;n.setCell(e,i,s,d);try{const y=o(t.formula1);return y===!0||typeof y=="number"&&y!==0}finally{n.setCell(e,i,c[0],c[1]),n.maxRow=c[2],n.maxCol=c[3]}}let u;if(t.type==="textLength"){if(s===T)return!1;u=p.length}else if(s===x)u=1/0;else if(s!==E||(u=l,t.type==="whole"&&!Number.isInteger(u)))return!1;const m=o(t.formula1),g=o(t.formula2);switch(t.operator){case"notBetween":return u<m||u>g;case"equal":return u===m;case"notEqual":return u!==m;case"greaterThan":return u>m;case"lessThan":return u<m;case"greaterThanOrEqual":return u>=m;case"lessThanOrEqual":return u<=m;default:return u>=m&&u<=g}}export{x as BOOL,H as CondFormats,C as STR,J as cfEffectAt,P as evaluatorOf,Q as iconAt,I as listEntries,W as listItems,D as listSpelling,S as listValues,A as rangesOf,V as validateEntry,K as validationAt};
1
+ import{MAX_COLS as L,MAX_ROWS as S,parseRangeRef as q}from"./address.js";import{BOOL as R,ERR as _,ERRORS as N,KIND_MASK as O,NUM as B,STR as C}from"./sheet.js";import{numberToText as M}from"../calc/values.js";import{formatGeneral as F,getFormatter as I}from"./numfmt.js";function T(n){return n.split(/\s+/).map(q).filter(Boolean)}import{CondFormats as Q,cfEffectAt as Y,evaluatorOf as Z,iconAt as z}from"../cells/cf-engine.js";function b(n,s,t){return n._ranges===void 0&&(n._ranges=T(n.sqref)),n._ranges.some(e=>s>=e.r0&&s<=e.r1&&t>=e.c0&&t<=e.c1)}function H(n,s,t){if(n.validations){for(const e of n.validations)if(b(e,s,t))return e}for(const e of n.hostRules??[])for(const{validation:a}of e.entries)if(a&&b(a,s,t))return a;return null}function A(n,s,t){n._ranges===void 0&&(n._ranges=n.sqref?T(n.sqref):[]);const e=n._ranges[0];return e?[e.r0,e.c0]:[s,t]}function E(n,s,t,e,a){const u=t.formula1.trim();if(u.startsWith('"'))return u.slice(1,-1).split(",").map(m=>m.trim());const l=n.engine;let i=l.template(u,...A(t,e,a)).fn(e,a,s);return i&&i.sheet&&(i=l.toArr(i)),i&&i.data?i.data.filter(m=>m!==null):[]}function U(n,s,t,e,a){const{engine:u}=n;return(t.formula1?u.template(t.formula1,...A(t,e,a)):null)?.refs.some(r=>{if(r.sheet?.sheet2||r.sheet?.book!==null&&r.sheet?.book!==void 0)return!1;const i=r.sheet?u.sheetByName(r.sheet.sheet):s,m=(x,y,h,p)=>{const d=x?y:h+y;return r.wrap?(d+p)%p:d>=0&&d<p?d:-1},[c,o]=[m(r.rAbs0,r.r0,e,S),m(r.rAbs1,r.r1,e,S)],[f,g]=[m(r.cAbs0,r.c0,a,L),m(r.cAbs1,r.c1,a,L)];return!!i&&c>=0&&f>=0&&c===o&&f===g&&!(i===s&&c===e&&f===a)&&i.kind(c,f)===0})===!0}function W(n,s,t,e,a){const u=t.formula1.trim();if(!/^[\p{L}_\\][\p{L}\p{N}_.\\]*$/u.test(u))return!1;const l=n.engine.template(u,...A(t,e,a)).fn(e,a,s);if(!l||!l.sheet||l.r0===void 0)return!1;for(let r=l.r0;r<=l.r1;r++){if(r>l.sheet.maxRow)return!0;for(let i=l.c0;i<=l.c1;i++)if((l.sheet.kind(r,i)&O)===0)return!0}return!1}function V(n,s,t,e,a){return G(n,s,t,e,a).map(u=>u.text)}function G(n,s,t,e,a){const u=t.formula1.trim(),l=()=>E(n,s,t,e,a).map(c=>({text:String(c),value:c}));if(u.startsWith('"'))return l();const r=n.engine.template(u,...A(t,e,a)).fn(e,a,s);if(!r||!r.sheet)return l();const i=[],m=r.sheet;for(let c=r.r0;c<=Math.min(r.r1,m.maxRow);c++)for(let o=r.c0;o<=Math.min(r.c1,m.maxCol);o++){const f=m.kind(c,o)&O;if(f===0)continue;const g=m.value(c,o),x=n.styles.get(m.style(c,o)).numFmt;f===B?i.push({text:x==="General"?F(g):I(x).number(g).replace(/\u0001.?\u0001/g," ").trim(),value:g}):f===C?i.push({text:n.strings.get(g),value:n.strings.get(g)}):f===R?i.push({text:g?"TRUE":"FALSE",value:g!==0}):i.push({text:N[g]??"#N/A",value:null})}return i}function $(n,s,t,e,a,u){if(t?.type!=="list"||typeof u!="string"||/^[='"]/.test(u))return null;const l=u.trim().toLowerCase(),r=E(n,s,t,e,a).find(i=>typeof i=="string"&&i.trim().toLowerCase()===l);return r!==void 0&&r.trim()!==u.trim()?r.trim():null}function j(n,s,t,e,a,u,l,r){if(t.type==="none"||t.type===void 0)return!0;if(u===0)return t.allowBlank;const i=n.engine,m=y=>{if(!y)return null;const h=i.template(y,...A(t,e,a)),p=i.legacy;i.legacy=!0;try{const d=h.fn(e,a,s);return d&&d.sheet?i.refAuto(d,e,a):d}finally{i.legacy=p}},c=u===B?M(l):u===R?l?"TRUE":"FALSE":String(r);if(t.type==="list"){if(u===_)return!1;if(t.allowBlank&&W(n,s,t,e,a))return!0;const y=E(n,s,t,e,a);if(u===B&&y.some(p=>(typeof p=="number"?p:Number(p))===l))return!0;const h=c.trim().toLowerCase();return y.some(p=>String(p).trim().toLowerCase()===h)}if(t.type==="custom"){if(t.allowBlank&&U(n,s,t,e,a))return!0;const y=[s.kind(e,a),s.value(e,a),s.maxRow,s.maxCol],h=u===C?n.strings.add(String(r)):u===R?l?1:0:l;s.setCell(e,a,u,h);try{const p=m(t.formula1);return p===!0||typeof p=="number"&&p!==0}finally{s.setCell(e,a,y[0],y[1]),s.maxRow=y[2],s.maxCol=y[3]}}let o;if(t.type==="textLength"){if(u===_)return!1;o=c.length}else if(u===R)o=1/0;else if(u!==B||(o=l,t.type==="whole"&&!Number.isInteger(o)))return!1;const f=m(t.formula1),g=m(t.formula2),x=!t.operator||t.operator==="between"||t.operator==="notBetween";if(t.allowBlank&&(f===null&&t.formula1||x&&g===null&&t.formula2))return!0;switch(t.operator){case"notBetween":return o<f||o>g;case"equal":return o===f;case"notEqual":return o!==f;case"greaterThan":return o>f;case"lessThan":return o<f;case"greaterThanOrEqual":return o>=f;case"lessThanOrEqual":return o<=f;default:return o>=f&&o<=g}}export{R as BOOL,Q as CondFormats,C as STR,Y as cfEffectAt,Z as evaluatorOf,z as iconAt,G as listEntries,V as listItems,$ as listSpelling,E as listValues,T as rangesOf,j as validateEntry,H as validationAt};
package/core/culture.js CHANGED
@@ -1 +1,5 @@
1
- import{setNumberLocale as F}from"./numfmt.js";import{setEntryCurrency as L}from"./input.js";import{regionInput as Z}from"./region-input.js";import{arraySeparatorsOf as b}from"../calcx/culture/separators.js";import{customCulture as v}from"../calcx/culture/custom.js";import{localeData as K,preparedEras as G}from"../calcx/culture/format-locale.js";import{formulaFromUser as k,formulaToUser as M}from"../calcx/lang/convert.js";import{ansiEncoding as O}from"../io/encoding.js";import{setDbcsLanguage as W}from"../calc/functions/dbcs.js";const B={US:"USD",GB:"GBP",PL:"PLN",DE:"EUR",FR:"EUR",ES:"EUR",IT:"EUR",NL:"EUR",AT:"EUR",BE:"EUR",IE:"EUR",PT:"EUR",FI:"EUR",GR:"EUR",CZ:"CZK",SK:"EUR",HU:"HUF",RO:"RON",SE:"SEK",NO:"NOK",DK:"DKK",CH:"CHF",UA:"UAH",TR:"TRY",JP:"JPY",CN:"CNY",KR:"KRW",IN:"INR",BR:"BRL",MX:"MXN",CA:"CAD",AU:"AUD",NZ:"NZD",ZA:"ZAR",IL:"ILS",SA:"SAR",AE:"AED",EG:"EGP"},V=[["en-US","English (United States)"],["en-GB","English (United Kingdom)"],["pl-PL","Polish (Poland)"],["de-DE","German (Germany)"],["fr-FR","French (France)"],["es-ES","Spanish (Spain)"],["it-IT","Italian (Italy)"],["nl-NL","Dutch (Netherlands)"],["pt-BR","Portuguese (Brazil)"],["cs-CZ","Czech (Czechia)"],["sv-SE","Swedish (Sweden)"],["uk-UA","Ukrainian (Ukraine)"],["tr-TR","Turkish (Türkiye)"],["ja-JP","Japanese (Japan)"],["zh-CN","Chinese (China)"],["ko-KR","Korean (Korea)"],["ar-SA","Arabic (Saudi Arabia)"],["he-IL","Hebrew (Israel)"]];function u(e){const o=v(e);if(o){const t=u(o.parent);return{...t,monthsWithDay:o.fields.months??t.monthsWithDay,...o.fields,tag:e}}const s=new Intl.NumberFormat(e,{useGrouping:!0,numberingSystem:"latn"}).formatToParts(12345675e-1),m=s.find(t=>t.type==="decimal")?.value??".",C=s.find(t=>t.type==="group")?.value??"",y=[],d=[];for(let t=0;t<12;t++){const n=new Date(Date.UTC(2024,t,15));y.push(new Intl.DateTimeFormat(e,{month:"long",timeZone:"UTC",calendar:"gregory"}).format(n)),d.push(new Intl.DateTimeFormat(e,{month:"short",timeZone:"UTC",calendar:"gregory"}).format(n))}const p=[],h=[];for(let t=0;t<7;t++){const n=new Date(Date.UTC(2024,0,7+t));p.push(new Intl.DateTimeFormat(e,{weekday:"long",timeZone:"UTC",calendar:"gregory"}).format(n)),h.push(new Intl.DateTimeFormat(e,{weekday:"short",timeZone:"UTC",calendar:"gregory"}).format(n))}const i=new Intl.DateTimeFormat(e,{dateStyle:"short",timeZone:"UTC",calendar:"gregory",numberingSystem:"latn"}).formatToParts(new Date(Date.UTC(2024,0,5))),S=i.filter(t=>t.type==="day"||t.type==="month"||t.type==="year").map(t=>t.type),g=i.find(t=>t.type==="literal")?.value.trim()||"/",R=i.find(t=>t.type==="month")?.value.length>1,D={day:t=>t.length>1||R?"dd":"d",month:t=>t.length>1?"mm":"m",year:()=>"yyyy"},E=i.filter(t=>D[t.type]).map(t=>D[t.type](t.value)).join(g),I=new Intl.Locale(e).maximize().region,P=B[I]??"USD",l=new Intl.NumberFormat(e,{style:"currency",currency:P,numberingSystem:"latn"}).formatToParts(1),w=l.find(t=>t.type==="currency")?.value??"$",N=l.findIndex(t=>t.type==="currency")<l.findIndex(t=>t.type==="integer"),f={weekday:()=>"dddd",month:t=>/\d/.test(t)?"m":"mmmm",day:t=>t.length>1?"dd":"d",year:()=>"yyyy"},U=t=>new Intl.DateTimeFormat(e,{dateStyle:t,timeZone:"UTC",calendar:"gregory",numberingSystem:"latn"}).formatToParts(new Date(Date.UTC(2024,0,5))).map(n=>f[n.type]?f[n.type](n.value):n.type==="literal"?`"${n.value}"`:"").join(""),A=new Intl.DateTimeFormat(e,{hour:"numeric",hour12:!0,timeZone:"UTC",calendar:"gregory"}),T=t=>A.formatToParts(new Date(Date.UTC(2024,0,5,t))).find(n=>n.type==="dayPeriod")?.value??(t<12?"AM":"PM");return{tag:e,language:new Intl.Locale(e).language,collator:new Intl.Collator(e,{sensitivity:"accent"}),decimal:m,group:C,listSep:m===","?";":",",...b(e,m),longDate:U("full"),longDateWithoutWeekday:U("long"),longTime:"h:mm:ss AM/PM",amDesignator:T(9),pmDesignator:T(15),months:y,shortMonths:d,monthsWithDay:K(e).monthsWithDay,days:p,shortDays:h,order:S,dateSep:g,shortDate:E,currency:{symbol:w,symbolFirst:N}}}let r=null,c=null;const a=()=>(r??=u("en-US"),r);function x(e=a().currency.symbol){return/^\p{Sc}$/u.test(e)?e:`"${e.replace(/"/g,"")}"`}function ee(e,o=x(),s=!a().currency.symbolFirst){return o?s?`${e} ${o}`:o+e:e}function te(e){return r=u(e),c=null,W(r.tag),L(r.currency),F({decimal:r.decimal,group:r.group,months:r.months,monthsWithDay:r.monthsWithDay,shortMonths:r.shortMonths,days:r.days,shortDays:r.shortDays,shortDate:r.shortDate,longDate:r.longDate,longTime:r.longTime,amDesignator:r.amDesignator,pmDesignator:r.pmDesignator,tag:r.tag,eras:r.eras?G(r.eras):null,numerals:r.numerals??null}),r}function re(e){return M(e,a())}function H(e){return k(e,a())}const ne=(e=a())=>({decimal:e.decimal,group:e.group,listSep:e.listSep,order:e.order,dateSep:e.dateSep,currency:e.currency,ansi:O(e.tag)});function oe(e){return e===""||e[0]==="'"?e:e[0]==="="?e.length>1?H(e):e:(c??=Z(a()),c(e))}export{V as REGIONS,a as culture,u as cultureOf,ee as currencyAmountCode,x as currencySymbolCode,H as formulaToInvariant,re as formulaToLocal,ne as inputRegion,oe as inputToInvariant,te as setCulture};
1
+ import{setNumberLocale as M}from"./numfmt.js";import{fractionEntry as B,setEntryCurrency as K}from"./input.js";import{regionInput as Z}from"./region-input.js";import{arraySeparatorsOf as H}from"../calcx/culture/separators.js";import{customCulture as O}from"../calcx/culture/custom.js";import{localeData as G,preparedEras as Y}from"../calcx/culture/format-locale.js";import{formulaFromUser as w,formulaToUser as F}from"../calcx/lang/convert.js";import{ansiEncoding as v}from"../io/encoding.js";import{setDbcsLanguage as b}from"../calc/functions/dbcs.js";const W={US:"USD",GB:"GBP",PL:"PLN",CZ:"CZK",HU:"HUF",RO:"RON",SE:"SEK",NO:"NOK",DK:"DKK",CH:"CHF",LI:"CHF",UA:"UAH",TR:"TRY",JP:"JPY",CN:"CNY",KR:"KRW",IN:"INR",BR:"BRL",MX:"MXN",CA:"CAD",AU:"AUD",NZ:"NZD",ZA:"ZAR",IL:"ILS",SA:"SAR",AE:"AED",EG:"EGP",IS:"ISK",AL:"ALL",BA:"BAM",MK:"MKD",RS:"RSD",MD:"MDL",BY:"BYN",RU:"RUB",KZ:"KZT",UZ:"UZS",MN:"MNT",AM:"AMD",AZ:"AZN",GE:"GEL",IR:"IRR",IQ:"IQD",JO:"JOD",KW:"KWD",LB:"LBP",LY:"LYD",MA:"MAD",OM:"OMR",QA:"QAR",TN:"TND",YE:"YER",BH:"BHD",DZ:"DZD",KE:"KES",PK:"PKR",BD:"BDT",NP:"NPR",TH:"THB",VN:"VND",ID:"IDR",MY:"MYR",SG:"SGD",PH:"PHP",HK:"HKD",TW:"TWD",AR:"ARS",BO:"BOB",CL:"CLP",CO:"COP",CR:"CRC",DO:"DOP",GT:"GTQ",HN:"HNL",NI:"NIO",PA:"PAB",PY:"PYG",PE:"PEN",UY:"UYU",VE:"VES",EC:"USD",SV:"USD",PR:"USD",AT:"EUR",BE:"EUR",BG:"EUR",CY:"EUR",DE:"EUR",EE:"EUR",ES:"EUR",FI:"EUR",FR:"EUR",GR:"EUR",HR:"EUR",IE:"EUR",IT:"EUR",LT:"EUR",LU:"EUR",LV:"EUR",MT:"EUR",NL:"EUR",PT:"EUR",SI:"EUR",SK:"EUR"},k=`af-ZA sq-AL ar-DZ ar-BH ar-EG ar-IQ ar-JO ar-KW ar-LB ar-LY ar-MA ar-OM ar-QA ar-SA ar-TN ar-AE ar-YE hy-AM az-AZ bn-BD eu-ES be-BY bs-BA bg-BG
2
+ ca-ES zh-CN zh-HK zh-SG zh-TW hr-HR cs-CZ da-DK nl-BE nl-NL en-AU en-CA en-IN en-IE en-NZ en-PH en-SG en-ZA en-GB en-US et-EE fil-PH fi-FI fr-BE fr-CA fr-FR fr-LU fr-MA fr-CH
3
+ gl-ES ka-GE de-AT de-DE de-LI de-LU de-CH el-GR gu-IN he-IL hi-IN hu-HU is-IS id-ID ga-IE it-IT it-CH ja-JP kn-IN kk-KZ ko-KR lv-LV lt-LT mk-MK ms-MY ml-IN mt-MT mr-IN mn-MN
4
+ ne-NP nb-NO nn-NO fa-IR pl-PL pt-BR pt-PT pa-IN ro-MD ro-RO ru-BY ru-KZ ru-RU sr-Cyrl-RS sr-Latn-RS sk-SK sl-SI es-AR es-BO es-CL es-CO es-CR es-DO es-EC es-SV es-GT es-HN es-MX
5
+ es-NI es-PA es-PY es-PE es-PR es-ES es-US es-UY es-VE sw-KE sv-FI sv-SE ta-IN te-IN th-TH tr-TR uk-UA ur-PK uz-UZ vi-VN cy-GB`.split(/\s+/);function te(e="en"){const n=new Intl.DisplayNames([e,"en"],{type:"language",languageDisplay:"standard"}),s=a=>a.charAt(0).toLocaleUpperCase(e)+a.slice(1),{compare:l}=new Intl.Collator(e);return k.map(a=>[a,s(n.of(a)??a)]).sort((a,i)=>l(a[1],i[1]))}function y(e){const n=O(e);if(n){const r=y(n.parent);return{...r,monthsWithDay:n.fields.months??r.monthsWithDay,...n.fields,tag:e}}const s=new Intl.NumberFormat(e,{useGrouping:!0,numberingSystem:"latn"}).formatToParts(12345675e-1),l=s.find(r=>r.type==="decimal")?.value??".",a=s.find(r=>r.type==="group")?.value??"",i=[],d=[];for(let r=0;r<12;r++){const o=new Date(Date.UTC(2024,r,15));i.push(new Intl.DateTimeFormat(e,{month:"long",timeZone:"UTC",calendar:"gregory"}).format(o)),d.push(new Intl.DateTimeFormat(e,{month:"short",timeZone:"UTC",calendar:"gregory"}).format(o))}const p=[],R=[];for(let r=0;r<7;r++){const o=new Date(Date.UTC(2024,0,7+r));p.push(new Intl.DateTimeFormat(e,{weekday:"long",timeZone:"UTC",calendar:"gregory"}).format(o)),R.push(new Intl.DateTimeFormat(e,{weekday:"short",timeZone:"UTC",calendar:"gregory"}).format(o))}const u=new Intl.DateTimeFormat(e,{dateStyle:"short",timeZone:"UTC",calendar:"gregory",numberingSystem:"latn"}).formatToParts(new Date(Date.UTC(2024,0,5))),T=u.filter(r=>r.type==="day"||r.type==="month"||r.type==="year").map(r=>r.type),E=u.find(r=>r.type==="literal")?.value.replace(/[\u200E\u200F\u061C]/g,"").trim()||"/",S=u.find(r=>r.type==="month")?.value.length>1,U={day:r=>r.length>1||S?"dd":"d",month:r=>r.length>1?"mm":"m",year:()=>"yyyy"},C=u.filter(r=>U[r.type]).map(r=>U[r.type](r.value)).join(E),N=new Intl.Locale(e).maximize().region,g=W[N]??"USD",c=new Intl.NumberFormat(e,{style:"currency",currency:g,numberingSystem:"latn"}).formatToParts(1),A=c.find(r=>r.type==="currency")?.value??"$",P=c.findIndex(r=>r.type==="currency")<c.findIndex(r=>r.type==="integer"),h={weekday:()=>"dddd",month:r=>/\d/.test(r)?"m":"mmmm",day:r=>r.length>1?"dd":"d",year:()=>"yyyy"},f=r=>new Intl.DateTimeFormat(e,{dateStyle:r,timeZone:"UTC",calendar:"gregory",numberingSystem:"latn"}).formatToParts(new Date(Date.UTC(2024,0,5))).map(o=>h[o.type]?h[o.type](o.value):o.type==="literal"?`"${o.value}"`:"").join(""),L=new Intl.DateTimeFormat(e,{hour:"numeric",hour12:!0,timeZone:"UTC",calendar:"gregory"}),I=r=>L.formatToParts(new Date(Date.UTC(2024,0,5,r))).find(o=>o.type==="dayPeriod")?.value??(r<12?"AM":"PM");return{tag:e,language:new Intl.Locale(e).language,collator:new Intl.Collator(e,{sensitivity:"accent"}),decimal:l,group:a,listSep:l===","?";":",",...H(e,l),longDate:f("full"),longDateWithoutWeekday:f("long"),longTime:"h:mm:ss AM/PM",amDesignator:I(9),pmDesignator:I(15),months:i,shortMonths:d,monthsWithDay:G(e).monthsWithDay,days:p,shortDays:R,order:T,dateSep:E,shortDate:C,currency:{symbol:A,symbolFirst:P}}}let t=null,D=null;const m=()=>(t??=y("en-US"),t);function V(e=m().currency.symbol){return/^\p{Sc}$/u.test(e)?e:`"${e.replace(/"/g,"")}"`}function ne(e,n=V(),s=!m().currency.symbolFirst){return n?s?`${e} ${n}`:n+e:e}function oe(e){return t=y(e),D=null,b(t.tag),K(t.currency),M({decimal:t.decimal,group:t.group,months:t.months,monthsWithDay:t.monthsWithDay,shortMonths:t.shortMonths,days:t.days,shortDays:t.shortDays,shortDate:t.shortDate,longDate:t.longDate,longTime:t.longTime,amDesignator:t.amDesignator,pmDesignator:t.pmDesignator,tag:t.tag,eras:t.eras?Y(t.eras):null,numerals:t.numerals??null}),t}function ae(e){return F(e,m())}function z(e){return w(e,m())}const Q=(e=m())=>({decimal:e.decimal,group:e.group,listSep:e.listSep,order:e.order,dateSep:e.dateSep,months:[e.months,e.shortMonths],currency:e.currency,ansi:v(e.tag)});function se(e,n="General"){return e===""||e[0]==="'"||n==="@"||B(e,n)!==null?e:e[0]==="="?e.length>1?z(e):e:(D??=Z(Q()),D(e))}export{m as culture,y as cultureOf,ne as currencyAmountCode,V as currencySymbolCode,z as formulaToInvariant,ae as formulaToLocal,Q as inputRegion,se as inputToInvariant,te as regionList,oe as setCulture};
@@ -1 +1 @@
1
- import{colName as h,parseRangeRef as m,quoteSheetName as v,rangeRef as w}from"./address.js";import{escapeMarkup as $,xmlAttr as V,xmlText as b}from"../io/xml-escape.js";import{unescapeOoxml as N,unescapeXml as A,unescapeXstring as H}from"../io/xml-scan.js";function y(){const t=globalThis.crypto?.getRandomValues?crypto.getRandomValues(new Uint8Array(16)):Uint8Array.from({length:16},()=>Math.floor(Math.random()*256));t[6]=t[6]&15|64,t[8]=t[8]&63|128;const i=[...t].map(n=>n.toString(16).padStart(2,"0").toUpperCase()).join("");return`{${i.slice(0,8)}-${i.slice(8,12)}-${i.slice(12,16)}-${i.slice(16,20)}-${i.slice(20)}}`}const p=t=>t.hiddenSizes?[...t.hiddenSizes.keys()].sort((i,n)=>i-n):[];function I(t,{print:i,rowCol:n},e){const r=t.filteredRows??new Set;return{sheet:t,hiddenRows:n?p(t.rows).filter(o=>!r.has(o)):null,hiddenCols:n?p(t.cols):null,filter:n&&t.autoFilter?{...t.autoFilter,columns:new Map(t.autoFilter.columns),filtered:[...r]}:null,zoom:t.zoom||1,showGridlines:t.showGridlines!==!1,frozen:{rows:t.frozenRows||0,cols:t.frozenCols||0},selection:e?{row:e.row,col:e.col,sqref:e.ranges.map(w).join(" ")}:t.viewSelection??null,pageSetup:i&&t.pageSetup?structuredClone(t.pageSetup):null}}function G(t,i,{print:n=!0,rowCol:e=!0}={},r=null){return{name:i,guid:y(),print:n,rowCol:e,activeSheet:t.activeSheet,sheets:t.sheets.filter(o=>!o.isChartSheet).map(o=>I(o,{print:n,rowCol:e},o===t.sheet?r:null))}}function P(t,i){for(const n of i.sheets){const{sheet:e}=n;if(t.sheets.includes(e)){if(i.rowCol&&n.hiddenRows){const r=new Set(n.hiddenRows),o=e.filteredRows??new Set;for(const s of p(e.rows))!r.has(s)&&!o.has(s)&&e.rows.setHidden(s,!1);for(const s of r)e.rows.setHidden(s,!0);const l=new Set(n.hiddenCols??[]);for(const s of p(e.cols))l.has(s)||e.cols.setHidden(s,!1);for(const s of l)e.cols.setHidden(s,!0);if(e.colsChanged=!0,n.filter){for(const s of o)e.rows.setHidden(s,!1);e.autoFilter={...n.filter,columns:new Map(n.filter.columns)},delete e.autoFilter.filtered,e.filteredRows=new Set(n.filter.filtered);for(const s of e.filteredRows)e.rows.setHidden(s,!0);e.filterChanged=!0}}e.zoom=n.zoom,e.showGridlines=n.showGridlines,e.frozenRows=n.frozen.rows,e.frozenCols=n.frozen.cols,e.viewChanged=!0,i.print&&n.pageSetup&&(e.pageSetup=structuredClone(n.pageSetup),e.pageSetupChanged=!0),n.selection&&(e.viewSelection=n.selection),e.revision++}}return i.activeSheet>=0&&i.activeSheet<t.sheets.length&&(t.activeSheet=i.activeSheet),t.dirty=!0,t.sheet.viewSelection??null}const f=t=>`Z_${t.replace(/[{}]/g,"").replace(/-/g,"_")}_`;function C(t,i){const n=[];for(let e=0;e<t.length;e++){let r=e;for(;r+1<t.length&&t[r+1]===t[r]+1;)r++;n.push(i?[`$${h(t[e])}`,`$${h(t[r])}`]:[`$${t[e]+1}`,`$${t[r]+1}`]),e=r}return n}function M(t){const i=[];for(const n of t.customViews??[])for(const e of n.sheets){const r=t.sheets.indexOf(e.sheet);if(r<0)continue;const o=v(e.sheet.name);e.hiddenRows?.length&&i.push({name:`${f(n.guid)}.wvu.Rows`,localSheetId:r,text:C(e.hiddenRows,!1).map(([l,s])=>`${o}!${l}:${s}`).join(",")}),e.hiddenCols?.length&&i.push({name:`${f(n.guid)}.wvu.Cols`,localSheetId:r,text:C(e.hiddenCols,!0).map(([l,s])=>`${o}!${l}:${s}`).join(",")}),n.print&&e.pageSetup?.printAreas?.length&&i.push({name:`${f(n.guid)}.wvu.PrintArea`,localSheetId:r,text:e.pageSetup.printAreas.map(l=>`${o}!${w(l).replace(/([A-Z]+)(\d+)/g,"$$$1$$$2")}`).join(",")}),e.filter&&i.push({name:`${f(n.guid)}.wvu.FilterData`,localSheetId:r,text:`${o}!${w(e.filter).replace(/([A-Z]+)(\d+)/g,"$$$1$$$2")}`})}return i}function q(t){const i=t.customViews??[];return i.length===0?"":`<customWorkbookViews>${i.map(e=>`<customWorkbookView name="${V(e.name)}" guid="${e.guid}"${e.print?"":' includePrintSettings="0"'}${e.rowCol?"":' includeHiddenRowCol="0"'} windowWidth="${e.windowWidth??1440}" windowHeight="${e.windowHeight??900}" activeSheetId="${$(t.sheets[e.activeSheet]?.name??"")}"/>`).join("")}</customWorkbookViews>`}function k(t){if(!t)return"";const i=t.margins??{},n=(l,s)=>Number.isFinite(l)?l/72:s,e=`<pageMargins left="${n(i.left,.7)}" right="${n(i.right,.7)}" top="${n(i.top,.75)}" bottom="${n(i.bottom,.75)}" header="${n(i.header,.3)}" footer="${n(i.footer,.3)}"/>`,r=`<pageSetup${t.paperSize?` paperSize="${t.paperSize}"`:""}${t.scale&&t.scale!==100?` scale="${t.scale}"`:""}${t.orientation?` orientation="${t.orientation}"`:""}/>`,o=t.header?.odd||t.footer?.odd?`<headerFooter>${t.header?.odd?`<oddHeader>${b(t.header.odd)}</oddHeader>`:""}${t.footer?.odd?`<oddFooter>${b(t.footer.odd)}</oddFooter>`:""}</headerFooter>`:"";return e+r+o}function L(t,i,n=()=>""){const e=[];for(const r of t.customViews??[]){const o=r.sheets.find(a=>a.sheet===i);if(!o)continue;const l=o.frozen.rows||o.frozen.cols?`<pane${o.frozen.cols?` xSplit="${o.frozen.cols}"`:""}${o.frozen.rows?` ySplit="${o.frozen.rows}"`:""} topLeftCell="${h(o.frozen.cols)}${o.frozen.rows+1}" activePane="${o.frozen.rows&&o.frozen.cols?"bottomRight":o.frozen.rows?"bottomLeft":"topRight"}" state="frozen"/>`:"",s=o.selection?`<selection${l?` pane="${o.frozen.rows&&o.frozen.cols?"bottomRight":o.frozen.rows?"bottomLeft":"topRight"}"`:""} activeCell="${h(o.selection.col)}${o.selection.row+1}" sqref="${$(o.selection.sqref)}"/>`:"",d=`guid="${r.guid}"${o.zoom!==1?` scale="${Math.round(o.zoom*100)}"`:""}${o.showGridlines?"":' showGridLines="0"'}${r.print&&o.pageSetup?.printAreas?.length?' printArea="1"':""}${o.filter?' filter="1" showAutoFilter="1"':""}${o.hiddenRows?.length?' hiddenRows="1"':""}${o.hiddenCols?.length?' hiddenColumns="1"':""}`;e.push(`<customSheetView ${d}>${l}${s}${r.print?k(o.pageSetup):""}${o.filter?n(o.filter):""}</customSheetView>`)}return e.length?`<customSheetViews>${e.join("")}</customSheetViews>`:""}function Z(t,i,n){let e=t.replace(/<customWorkbookViews\b[\s\S]*?<\/customWorkbookViews>|<customWorkbookViews\b[^>]*\/>/,"");if(e=e.replace(/<definedName\b[^>]*name="Z_[^"]*\.wvu\.[A-Za-z]+"[^>]*>[\s\S]*?<\/definedName>/g,""),e=e.replace(/<definedNames>\s*<\/definedNames>/,""),i){i=i.replace(/\u0001([^\u0001]*)\u0001/g,(o,l)=>{const s=A(l),d=[...e.matchAll(/<sheet\b[^>]*>/g)].map(a=>a[0]).find(a=>{const c=/\bname="([^"]*)"/.exec(a)?.[1];return c!==void 0&&H(c)===s});return/\bsheetId="(\d+)"/.exec(d??"")?.[1]??"1"});const r=/<(?:pivotCaches|smartTagPr|smartTagTypes|webPublishing|fileRecoveryPr|webPublishObjects|extLst)\b|<\/workbook>/.exec(e);e=e.slice(0,r.index)+i+e.slice(r.index)}if(n.length){const r=n.map(o=>`<definedName name="${o.name}" hidden="1" localSheetId="${o.localSheetId}">${$(o.text)}</definedName>`).join("");if(/<definedNames>/.test(e))e=e.replace("<definedNames>",`<definedNames>${r}`);else{const o=/<calcPr\b|<oleSize\b|<customWorkbookViews\b|<pivotCaches\b|<extLst\b|<\/workbook>/.exec(e);e=`${e.slice(0,o.index)}<definedNames>${r}</definedNames>${e.slice(o.index)}`}}return e}function R(t){const i=[],n=[];for(const e of String(t).split(",")){const r=e.slice(e.lastIndexOf("!")+1).replace(/\$/g,"");let o=/^(\d+):(\d+)$/.exec(r);if(o)for(let l=Number(o[1])-1;l<=Number(o[2])-1;l++)i.push(l);if(o=/^([A-Z]+):([A-Z]+)$/.exec(r),o){const l=m(`${o[1]}1`).c0,s=m(`${o[2]}1`).c0;for(let d=l;d<=s;d++)n.push(d)}}return{rows:i,cols:n}}function O(t,i,n,e=[]){i?.length&&(t.customViews=i.map(r=>{const o=f(r.guid),l=Math.max(0,e.findIndex(d=>String(d.sheetId)===String(r.activeSheetId))),s=[];return t.sheets.forEach((d,a)=>{const c=(d.fileSheetViews??[]).find(u=>u.guid===r.guid);if(!c)return;const g=u=>(n??[]).find(z=>z.localSheetId===a&&z.name===`${o}.wvu.${u}`),S=g("Rows"),x=g("Cols");s.push({sheet:d,hiddenRows:S?R(S.text).rows:[],hiddenCols:x?R(x.text).cols:[],filter:null,zoom:c.scale?Number(c.scale)/100:1,showGridlines:c.showGridLines!=="0",frozen:{rows:c.ySplit?Number(c.ySplit):0,cols:c.xSplit?Number(c.xSplit):0},selection:c.activeCell?(()=>{const u=m(c.activeCell);return u?{row:u.r0,col:u.c0,sqref:c.sqref??c.activeCell}:null})():null,pageSetup:null})}),{name:N(r.name),guid:r.guid,print:r.includePrintSettings!=="0",rowCol:r.includeHiddenRowCol!=="0",activeSheet:l,sheets:s,windowWidth:r.windowWidth,windowHeight:r.windowHeight}}))}export{O as adoptCustomViews,P as applyView,G as captureView,L as customSheetViewsXml,q as customWorkbookViewsXml,y as newGuid,Z as patchCustomViews,M as viewNameEntries};
1
+ import{colName as u,parseRangeRef as h,quoteSheetName as V,rangeRef as $}from"./address.js";import{escapeMarkup as w,xmlAttr as v,xmlText as C}from"../io/xml-escape.js";import{unescapeOoxml as N,unescapeXml as A,unescapeXstring as H}from"../io/xml-scan.js";function y(){const t=globalThis.crypto?.getRandomValues?crypto.getRandomValues(new Uint8Array(16)):Uint8Array.from({length:16},()=>Math.floor(Math.random()*256));t[6]=t[6]&15|64,t[8]=t[8]&63|128;const r=[...t].map(n=>n.toString(16).padStart(2,"0").toUpperCase()).join("");return`{${r.slice(0,8)}-${r.slice(8,12)}-${r.slice(12,16)}-${r.slice(16,20)}-${r.slice(20)}}`}const m=t=>t.hiddenSizes?[...t.hiddenSizes.keys()].sort((r,n)=>r-n):[];function I(t,{print:r,rowCol:n},e){const i=t.filteredRows??new Set;return{sheet:t,hiddenRows:n?m(t.rows).filter(o=>!i.has(o)):null,hiddenCols:n?m(t.cols):null,filter:n&&t.autoFilter?{...t.autoFilter,columns:new Map(t.autoFilter.columns),filtered:[...i]}:null,zoom:t.zoom||1,showGridlines:t.showGridlines!==!1,frozen:{rows:t.frozenRows||0,cols:t.frozenCols||0,top:t.frozenTop||0,left:t.frozenLeft||0},selection:e?{row:e.row,col:e.col,sqref:e.ranges.map($).join(" ")}:t.viewSelection??null,pageSetup:r&&t.pageSetup?structuredClone(t.pageSetup):null}}function G(t,r,{print:n=!0,rowCol:e=!0}={},i=null){return{name:r,guid:y(),print:n,rowCol:e,activeSheet:t.activeSheet,sheets:t.sheets.filter(o=>!o.isChartSheet).map(o=>I(o,{print:n,rowCol:e},o===t.sheet?i:null))}}function P(t,r){for(const n of r.sheets){const{sheet:e}=n;if(t.sheets.includes(e)){if(r.rowCol&&n.hiddenRows){const i=new Set(n.hiddenRows),o=e.filteredRows??new Set;for(const s of m(e.rows))!i.has(s)&&!o.has(s)&&e.rows.setHidden(s,!1);for(const s of i)e.rows.setHidden(s,!0);const l=new Set(n.hiddenCols??[]);for(const s of m(e.cols))l.has(s)||e.cols.setHidden(s,!1);for(const s of l)e.cols.setHidden(s,!0);if(e.colsChanged=!0,n.filter){for(const s of o)e.rows.setHidden(s,!1);e.autoFilter={...n.filter,columns:new Map(n.filter.columns)},delete e.autoFilter.filtered,e.filteredRows=new Set(n.filter.filtered);for(const s of e.filteredRows)e.rows.setHidden(s,!0);e.filterChanged=!0}}e.zoom=n.zoom,e.showGridlines=n.showGridlines,e.frozenRows=n.frozen.rows,e.frozenCols=n.frozen.cols,e.frozenTop=n.frozen.top??0,e.frozenLeft=n.frozen.left??0,e.viewChanged=!0,r.print&&n.pageSetup&&(e.pageSetup=structuredClone(n.pageSetup),e.pageSetupChanged=!0),n.selection&&(e.viewSelection=n.selection),e.revision++}}return r.activeSheet>=0&&r.activeSheet<t.sheets.length&&(t.activeSheet=r.activeSheet),t.dirty=!0,t.sheet.viewSelection??null}const p=t=>`Z_${t.replace(/[{}]/g,"").replace(/-/g,"_")}_`;function b(t,r){const n=[];for(let e=0;e<t.length;e++){let i=e;for(;i+1<t.length&&t[i+1]===t[i]+1;)i++;n.push(r?[`$${u(t[e])}`,`$${u(t[i])}`]:[`$${t[e]+1}`,`$${t[i]+1}`]),e=i}return n}function M(t){const r=[];for(const n of t.customViews??[])for(const e of n.sheets){const i=t.sheets.indexOf(e.sheet);if(i<0)continue;const o=V(e.sheet.name);e.hiddenRows?.length&&r.push({name:`${p(n.guid)}.wvu.Rows`,localSheetId:i,text:b(e.hiddenRows,!1).map(([l,s])=>`${o}!${l}:${s}`).join(",")}),e.hiddenCols?.length&&r.push({name:`${p(n.guid)}.wvu.Cols`,localSheetId:i,text:b(e.hiddenCols,!0).map(([l,s])=>`${o}!${l}:${s}`).join(",")}),n.print&&e.pageSetup?.printAreas?.length&&r.push({name:`${p(n.guid)}.wvu.PrintArea`,localSheetId:i,text:e.pageSetup.printAreas.map(l=>`${o}!${$(l).replace(/([A-Z]+)(\d+)/g,"$$$1$$$2")}`).join(",")}),e.filter&&r.push({name:`${p(n.guid)}.wvu.FilterData`,localSheetId:i,text:`${o}!${$(e.filter).replace(/([A-Z]+)(\d+)/g,"$$$1$$$2")}`})}return r}function q(t){const r=t.customViews??[];return r.length===0?"":`<customWorkbookViews>${r.map(e=>`<customWorkbookView name="${v(e.name)}" guid="${e.guid}"${e.print?"":' includePrintSettings="0"'}${e.rowCol?"":' includeHiddenRowCol="0"'} windowWidth="${e.windowWidth??1440}" windowHeight="${e.windowHeight??900}" activeSheetId="${w(t.sheets[e.activeSheet]?.name??"")}"/>`).join("")}</customWorkbookViews>`}function k(t){if(!t)return"";const r=t.margins??{},n=(l,s)=>Number.isFinite(l)?l/72:s,e=`<pageMargins left="${n(r.left,.7)}" right="${n(r.right,.7)}" top="${n(r.top,.75)}" bottom="${n(r.bottom,.75)}" header="${n(r.header,.3)}" footer="${n(r.footer,.3)}"/>`,i=`<pageSetup${t.paperSize?` paperSize="${t.paperSize}"`:""}${t.scale&&t.scale!==100?` scale="${t.scale}"`:""}${t.orientation?` orientation="${t.orientation}"`:""}/>`,o=t.header?.odd||t.footer?.odd?`<headerFooter>${t.header?.odd?`<oddHeader>${C(t.header.odd)}</oddHeader>`:""}${t.footer?.odd?`<oddFooter>${C(t.footer.odd)}</oddFooter>`:""}</headerFooter>`:"";return e+i+o}function F(t){const r=t.topLeftCell?h(t.topLeftCell):null,n=t.ySplit?Number(t.ySplit):0,e=t.xSplit?Number(t.xSplit):0,i=n?r?.r0??0:0,o=e?r?.c0??0:0;return{rows:n+i,cols:e+o,top:i,left:o}}function T(t,r,n=()=>""){const e=[];for(const i of t.customViews??[]){const o=i.sheets.find(c=>c.sheet===r);if(!o)continue;const l=o.frozen.rows||o.frozen.cols?`<pane${o.frozen.cols?` xSplit="${o.frozen.cols-(o.frozen.left??0)}"`:""}${o.frozen.rows?` ySplit="${o.frozen.rows-(o.frozen.top??0)}"`:""} topLeftCell="${u(o.frozen.cols)}${o.frozen.rows+1}" activePane="${o.frozen.rows&&o.frozen.cols?"bottomRight":o.frozen.rows?"bottomLeft":"topRight"}" state="frozen"/>`:"",s=o.selection?`<selection${l?` pane="${o.frozen.rows&&o.frozen.cols?"bottomRight":o.frozen.rows?"bottomLeft":"topRight"}"`:""} activeCell="${u(o.selection.col)}${o.selection.row+1}" sqref="${w(o.selection.sqref)}"/>`:"",d=`guid="${i.guid}"${o.zoom!==1?` scale="${Math.round(o.zoom*100)}"`:""}${o.showGridlines?"":' showGridLines="0"'}${i.print&&o.pageSetup?.printAreas?.length?' printArea="1"':""}${o.filter?' filter="1" showAutoFilter="1"':""}${o.hiddenRows?.length?' hiddenRows="1"':""}${o.hiddenCols?.length?' hiddenColumns="1"':""}`,a=o.frozen.top||o.frozen.left?` topLeftCell="${u(o.frozen.left??0)}${(o.frozen.top??0)+1}"`:"";e.push(`<customSheetView ${d}${a}>${l}${s}${i.print?k(o.pageSetup):""}${o.filter?n(o.filter):""}</customSheetView>`)}return e.length?`<customSheetViews>${e.join("")}</customSheetViews>`:""}function Z(t,r,n){let e=t.replace(/<customWorkbookViews\b[\s\S]*?<\/customWorkbookViews>|<customWorkbookViews\b[^>]*\/>/,"");if(e=e.replace(/<definedName\b[^>]*name="Z_[^"]*\.wvu\.[A-Za-z]+"[^>]*>[\s\S]*?<\/definedName>/g,""),e=e.replace(/<definedNames>\s*<\/definedNames>/,""),r){r=r.replace(/\u0001([^\u0001]*)\u0001/g,(o,l)=>{const s=A(l),d=[...e.matchAll(/<sheet\b[^>]*>/g)].map(a=>a[0]).find(a=>{const c=/\bname="([^"]*)"/.exec(a)?.[1];return c!==void 0&&H(c)===s});return/\bsheetId="(\d+)"/.exec(d??"")?.[1]??"1"});const i=/<(?:pivotCaches|smartTagPr|smartTagTypes|webPublishing|fileRecoveryPr|webPublishObjects|extLst)\b|<\/workbook>/.exec(e);e=e.slice(0,i.index)+r+e.slice(i.index)}if(n.length){const i=n.map(o=>`<definedName name="${o.name}" hidden="1" localSheetId="${o.localSheetId}">${w(o.text)}</definedName>`).join("");if(/<definedNames>/.test(e))e=e.replace("<definedNames>",()=>`<definedNames>${i}`);else{const o=/<calcPr\b|<oleSize\b|<customWorkbookViews\b|<pivotCaches\b|<extLst\b|<\/workbook>/.exec(e);e=`${e.slice(0,o.index)}<definedNames>${i}</definedNames>${e.slice(o.index)}`}}return e}function R(t){const r=[],n=[];for(const e of String(t).split(",")){const i=e.slice(e.lastIndexOf("!")+1).replace(/\$/g,"");let o=/^(\d+):(\d+)$/.exec(i);if(o)for(let l=Number(o[1])-1;l<=Number(o[2])-1;l++)r.push(l);if(o=/^([A-Z]+):([A-Z]+)$/.exec(i),o){const l=h(`${o[1]}1`).c0,s=h(`${o[2]}1`).c0;for(let d=l;d<=s;d++)n.push(d)}}return{rows:r,cols:n}}function O(t,r,n,e=[]){r?.length&&(t.customViews=r.map(i=>{const o=p(i.guid),l=Math.max(0,e.findIndex(d=>String(d.sheetId)===String(i.activeSheetId))),s=[];return t.sheets.forEach((d,a)=>{const c=(d.fileSheetViews??[]).find(f=>f.guid===i.guid);if(!c)return;const g=f=>(n??[]).find(x=>x.localSheetId===a&&x.name===`${o}.wvu.${f}`),S=g("Rows"),z=g("Cols");s.push({sheet:d,hiddenRows:S?R(S.text).rows:[],hiddenCols:z?R(z.text).cols:[],filter:null,zoom:c.scale?Number(c.scale)/100:1,showGridlines:c.showGridLines!=="0",frozen:F(c),selection:c.activeCell?(()=>{const f=h(c.activeCell);return f?{row:f.r0,col:f.c0,sqref:c.sqref??c.activeCell}:null})():null,pageSetup:null})}),{name:N(i.name),guid:i.guid,print:i.includePrintSettings!=="0",rowCol:i.includeHiddenRowCol!=="0",activeSheet:l,sheets:s,windowWidth:i.windowWidth,windowHeight:i.windowHeight}}))}export{O as adoptCustomViews,P as applyView,G as captureView,T as customSheetViewsXml,q as customWorkbookViewsXml,y as newGuid,Z as patchCustomViews,M as viewNameEntries};