@heycys/gallery 0.2.1 → 0.2.2

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 (169) hide show
  1. package/THIRD-PARTY-NOTICES.md +1 -1
  2. package/browser/editor/page/annotate/index.mjs +3 -2
  3. package/browser/editor/page/board/index.mjs +2 -1
  4. package/browser/editor/page/board/settings.mjs +2 -1
  5. package/browser/editor/page/core.mjs +3 -2
  6. package/browser/editor/page/custom-page.mjs +4 -3
  7. package/browser/editor/page/editor.mjs +9 -5
  8. package/browser/editor/page/emoji-picker/support.mjs +3 -2
  9. package/browser/editor/page/links/index.mjs +1 -12
  10. package/browser/editor/page/links/pages.mjs +3 -2
  11. package/browser/editor/page/outline/folds.mjs +3 -0
  12. package/browser/editor/page/post.mjs +2 -1
  13. package/browser/editor/page/present-links.mjs +4 -3
  14. package/browser/editor/page/present-shell.mjs +3 -58
  15. package/browser/editor/page/session.mjs +3 -37
  16. package/browser/editor/page/storage.mjs +5 -5
  17. package/browser/shared/component-catalog.mjs +2 -2
  18. package/browser/shared/drafts.mjs +26 -51
  19. package/browser/shared/emoji/icon-value.mjs +2 -1
  20. package/browser/shared/extension-manifest.mjs +90 -0
  21. package/browser/shared/extensions.mjs +26 -16
  22. package/browser/shared/http.mjs +1 -1
  23. package/browser/shared/i18n/en.mjs +46 -15
  24. package/browser/shared/media.mjs +2 -1
  25. package/browser/shared/outline.mjs +11 -51
  26. package/browser/shared/page-address.mjs +8 -15
  27. package/browser/shared/paths.mjs +2 -1
  28. package/browser/shared/preferences.mjs +3 -1
  29. package/browser/shared/preview-server.mjs +51 -63
  30. package/browser/shared/service-location.mjs +18 -0
  31. package/browser/shared/session.mjs +3 -6
  32. package/browser/shared/workspace-address.mjs +19 -0
  33. package/browser/shared/workspace-columns.mjs +1 -2
  34. package/browser/shared/workspace-registry.mjs +6 -40
  35. package/browser/shared/workspace.mjs +3 -6
  36. package/browser/shared/writing-preferences.mjs +6 -4
  37. package/dist/{chunk-BYSF5UMM.mjs → chunk-236JJXWY.mjs} +2 -2
  38. package/dist/{chunk-3A5I2GJK.mjs → chunk-2KAVXMKG.mjs} +1 -1
  39. package/dist/chunk-2T4PZQEP.mjs +2 -0
  40. package/dist/{chunk-SAHS56QM.mjs → chunk-3SKOU6OZ.mjs} +1 -1
  41. package/dist/{chunk-S2Y7VI4H.mjs → chunk-3XZOA7AH.mjs} +2 -2
  42. package/dist/{chunk-MKTX5PGV.mjs → chunk-43B75J5T.mjs} +1 -1
  43. package/dist/{chunk-VKSRM7EY.mjs → chunk-4B2TB5K2.mjs} +1 -1
  44. package/dist/{chunk-LV24RY2E.mjs → chunk-4K5KC6V2.mjs} +1 -1
  45. package/dist/{chunk-SOD23RGL.mjs → chunk-4KUO7R2M.mjs} +8 -8
  46. package/dist/chunk-4SNV4HA5.mjs +2 -0
  47. package/dist/chunk-53XDTHTG.mjs +4 -0
  48. package/dist/chunk-5XV3YYLG.mjs +2 -0
  49. package/dist/{chunk-VNUWREXU.mjs → chunk-65NTKF4N.mjs} +1 -1
  50. package/dist/chunk-6GV3CBB2.mjs +2 -0
  51. package/dist/{chunk-DH6GMDNN.mjs → chunk-6L6V7YR2.mjs} +1 -1
  52. package/dist/{chunk-TOE6DPLH.mjs → chunk-6NLXUKAY.mjs} +1 -1
  53. package/dist/chunk-6Q7ASAXJ.mjs +3 -0
  54. package/dist/{chunk-ZCP7BTOZ.mjs → chunk-6QBHU4DF.mjs} +1 -1
  55. package/dist/{chunk-QXVNUASA.mjs → chunk-6QWQXHAV.mjs} +1 -1
  56. package/dist/chunk-6XD6U3QA.mjs +5 -0
  57. package/dist/{chunk-36FIRJIF.mjs → chunk-742D2WWJ.mjs} +2 -2
  58. package/dist/{chunk-7M7UPWU6.mjs → chunk-7EFHNQ5B.mjs} +1 -1
  59. package/dist/{chunk-JI6T3A4Y.mjs → chunk-7ISBBDJR.mjs} +1 -1
  60. package/dist/{chunk-2GKGEVMR.mjs → chunk-7UZUQQ7Q.mjs} +25 -24
  61. package/dist/{chunk-VPVOAJ7X.mjs → chunk-AGDILNWB.mjs} +1 -1
  62. package/dist/{chunk-5IIH335D.mjs → chunk-ALZ6ZENZ.mjs} +1 -1
  63. package/dist/{chunk-G4YP7GVC.mjs → chunk-BFJGHSQN.mjs} +1 -1
  64. package/dist/chunk-BLNQUR5R.mjs +168 -0
  65. package/dist/chunk-BMX3VUHY.mjs +2 -0
  66. package/dist/chunk-BN7M3IN7.mjs +8 -0
  67. package/dist/{chunk-AMDGVDNV.mjs → chunk-BQNTTFPL.mjs} +1 -1
  68. package/dist/chunk-C257H6IA.mjs +2 -0
  69. package/dist/{chunk-74RPP2M2.mjs → chunk-C564NU2H.mjs} +1 -1
  70. package/dist/chunk-CHQU37CA.mjs +2 -0
  71. package/dist/{chunk-WCWYNFDF.mjs → chunk-E4IHAIJ7.mjs} +1 -1
  72. package/dist/{chunk-7XDYK3UC.mjs → chunk-E7656LR7.mjs} +1 -1
  73. package/dist/{chunk-KFZBYDIS.mjs → chunk-ECZBLQKK.mjs} +1 -1
  74. package/dist/{chunk-PAFSFVYB.mjs → chunk-ERE2BXYV.mjs} +1 -1
  75. package/dist/{chunk-ZEY2RLBT.mjs → chunk-ERLAIBOA.mjs} +2 -2
  76. package/dist/chunk-FFV733MA.mjs +2 -0
  77. package/dist/{chunk-CZ5KJSGK.mjs → chunk-GJJRBGMY.mjs} +1 -1
  78. package/dist/{chunk-VA3KAQZD.mjs → chunk-GKOBB6DH.mjs} +1 -1
  79. package/dist/chunk-GMJD7ID3.mjs +2 -0
  80. package/dist/{chunk-QZ35UAB4.mjs → chunk-GRAXKKG4.mjs} +1 -1
  81. package/dist/{chunk-2RKIHJI2.mjs → chunk-HYMEEXKN.mjs} +1 -1
  82. package/dist/{chunk-DKR7LFIY.mjs → chunk-IA2SIEJQ.mjs} +1 -1
  83. package/dist/{chunk-QK3VISCA.mjs → chunk-IA4PSIMD.mjs} +1 -1
  84. package/dist/chunk-JPG2LBQM.mjs +11 -0
  85. package/dist/{chunk-VGTMLQWZ.mjs → chunk-JXXHAXYH.mjs} +1 -1
  86. package/dist/{chunk-5MEXZ2UF.mjs → chunk-K3JKPFL5.mjs} +1 -1
  87. package/dist/{chunk-LE44MD3O.mjs → chunk-KLQP46Y3.mjs} +1 -1
  88. package/dist/{chunk-NAGMRVW4.mjs → chunk-LKX55H76.mjs} +1 -1
  89. package/dist/chunk-LMUZQK5O.mjs +2 -0
  90. package/dist/{chunk-CG3UHDKH.mjs → chunk-M4NRDYI5.mjs} +1 -1
  91. package/dist/{chunk-HM4E43VM.mjs → chunk-MAFIGVXY.mjs} +1 -1
  92. package/dist/{chunk-4DNHHJSL.mjs → chunk-MKIBJTJZ.mjs} +1 -1
  93. package/dist/{chunk-L7W624FD.mjs → chunk-MNWJ4EZY.mjs} +1 -1
  94. package/dist/{chunk-FXQBADMN.mjs → chunk-NHP66IWR.mjs} +1 -1
  95. package/dist/{chunk-YBB5LWZK.mjs → chunk-OEIJLMPI.mjs} +1 -1
  96. package/dist/{chunk-NWRZXELO.mjs → chunk-PAREWQGB.mjs} +1 -1
  97. package/dist/{chunk-7N2LPG33.mjs → chunk-PDZR3L3C.mjs} +1 -1
  98. package/dist/{chunk-YFJU3O7G.mjs → chunk-PLB7L22J.mjs} +1 -1
  99. package/dist/{chunk-4AMTKWDO.mjs → chunk-PUOQ65NC.mjs} +1 -1
  100. package/dist/chunk-Q4MS6OFC.mjs +2 -0
  101. package/dist/{chunk-3OFXMN6N.mjs → chunk-Q7P3Q5YX.mjs} +1 -1
  102. package/dist/{chunk-6MPKCH3P.mjs → chunk-QNECWMGR.mjs} +1 -1
  103. package/dist/{chunk-HBAUKKQH.mjs → chunk-QP7BOHE4.mjs} +1 -1
  104. package/dist/chunk-QVGOPHOF.mjs +2 -0
  105. package/dist/{chunk-NFABH3QW.mjs → chunk-RRKJMHNX.mjs} +2 -2
  106. package/dist/chunk-S3SX3COT.mjs +20 -0
  107. package/dist/{chunk-ZO7SFB2E.mjs → chunk-SQ6Y2ZMA.mjs} +2 -2
  108. package/dist/{chunk-VG5JEIUQ.mjs → chunk-TKWEX4FD.mjs} +2 -2
  109. package/dist/{chunk-CCSGFCLZ.mjs → chunk-U3SSPL4K.mjs} +1 -1
  110. package/dist/{chunk-DHB7UZ7F.mjs → chunk-U5XL7D6A.mjs} +1 -1
  111. package/dist/{chunk-CPS4SRPF.mjs → chunk-ULXSPX5H.mjs} +2 -2
  112. package/dist/{chunk-JXLSHVJ2.mjs → chunk-UMHUSOPJ.mjs} +1 -1
  113. package/dist/chunk-USIHBCSW.mjs +15 -0
  114. package/dist/{chunk-GWOYMENX.mjs → chunk-V6XZ4VIR.mjs} +1 -1
  115. package/dist/{chunk-AFGUR7SY.mjs → chunk-VPMRP2TL.mjs} +1 -1
  116. package/dist/{chunk-WTEGUPFG.mjs → chunk-VRPVVMRB.mjs} +1 -1
  117. package/dist/chunk-VZ2RQ3AM.mjs +2 -0
  118. package/dist/{chunk-XKOHV4H6.mjs → chunk-W5NPH5UA.mjs} +1 -1
  119. package/dist/chunk-WFGPMCTZ.mjs +4 -0
  120. package/dist/chunk-XZCFPKGO.mjs +2 -0
  121. package/dist/{chunk-QJ3TFJLQ.mjs → chunk-Y34NR5JL.mjs} +1 -1
  122. package/dist/{chunk-V5JRSGZF.mjs → chunk-YN37ZDLW.mjs} +1 -1
  123. package/dist/chunk-ZFGMJVJC.mjs +2 -0
  124. package/dist/{chunk-KH24LWAT.mjs → chunk-ZTHICSSF.mjs} +1 -1
  125. package/dist/cli.mjs +1 -1
  126. package/dist/server.mjs +1 -1
  127. package/dist/worker.mjs +1 -1
  128. package/kit/math.js +1 -1
  129. package/kit/runtime.js +12 -2
  130. package/kit/state.js +2 -0
  131. package/kit/ui.js +5 -1
  132. package/package.json +1 -1
  133. package/release.json +7 -7
  134. package/skill/SKILL.md +13 -13
  135. package/skill/references/building-blocks.md +1 -1
  136. package/skill/references/extensions.md +45 -9
  137. package/web/assets/{index-xP0uw3a0.css → index-FLb9jCfl.css} +1 -1
  138. package/web/assets/index-czjrXVjf.js +15 -0
  139. package/web/index.html +2 -2
  140. package/dist/chunk-46ACXOU5.mjs +0 -2
  141. package/dist/chunk-5DPABPBI.mjs +0 -2
  142. package/dist/chunk-5L26JUYA.mjs +0 -2
  143. package/dist/chunk-AEMVZYZQ.mjs +0 -166
  144. package/dist/chunk-ASAXY2DJ.mjs +0 -2
  145. package/dist/chunk-DAMVDXR3.mjs +0 -2
  146. package/dist/chunk-DLFZJJEE.mjs +0 -2
  147. package/dist/chunk-EKNHM3P4.mjs +0 -2
  148. package/dist/chunk-FCK6NXON.mjs +0 -3
  149. package/dist/chunk-FX42XU6J.mjs +0 -2
  150. package/dist/chunk-HATA2W7X.mjs +0 -2
  151. package/dist/chunk-JJNRIFND.mjs +0 -8
  152. package/dist/chunk-JL6R4FG4.mjs +0 -4
  153. package/dist/chunk-KUILYI7H.mjs +0 -4
  154. package/dist/chunk-NIW7F7LU.mjs +0 -4
  155. package/dist/chunk-OU3S466R.mjs +0 -20
  156. package/dist/chunk-QCEATQC4.mjs +0 -2
  157. package/dist/chunk-TDWJKOLN.mjs +0 -2
  158. package/dist/chunk-UGO5N3EI.mjs +0 -15
  159. package/dist/chunk-XMKHCUI6.mjs +0 -15
  160. package/dist/chunk-XQRUG4G3.mjs +0 -2
  161. package/dist/chunk-YPPJVDQI.mjs +0 -2
  162. package/dist/chunk-ZANMKAWS.mjs +0 -2
  163. package/web/assets/index-BHC5ZOMh.js +0 -15
  164. /package/dist/{chunk-N3DSBH5S.mjs → chunk-A55HN5OK.mjs} +0 -0
  165. /package/dist/{chunk-KNZJT4ET.mjs → chunk-QAIHRH3I.mjs} +0 -0
  166. /package/dist/{chunk-ZW2A6GBW.mjs → chunk-QR6A54KJ.mjs} +0 -0
  167. /package/dist/{chunk-74UW7QSL.mjs → chunk-UH4SIXTR.mjs} +0 -0
  168. /package/dist/{chunk-EKGYYOSP.mjs → chunk-W7XHE4CT.mjs} +0 -0
  169. /package/dist/{chunk-5MMN3N5J.mjs → chunk-YEY3RSFQ.mjs} +0 -0
@@ -0,0 +1,15 @@
1
+ import { createRequire as __galleryRequire } from "node:module"; import { fileURLToPath as __galleryPath } from "node:url"; const require = __galleryRequire(import.meta.url); const __filename = __galleryPath(import.meta.url); const __dirname = __galleryPath(new URL(".", import.meta.url));
2
+ import{a as we,b as q,c as X,f as be,g as L,h as ke,i as Q,l as ye,m as xe}from"./chunk-3SKOU6OZ.mjs";import{a as gt}from"./chunk-ZTHICSSF.mjs";import{b as le,c as $t,e as K,f as de,i as fe,j as he,m as ue,n as pe,o as me,p as ge,q as $e,r as wt}from"./chunk-PLB7L22J.mjs";import{a as pt}from"./chunk-PAREWQGB.mjs";import{a as te,b as ee,c as oe,d as se,e as ne,f as ie,g as ae,h as re,l as ce}from"./chunk-BFJGHSQN.mjs";import{b as mt,c as Yt,d as qt,e as Xt,g as Qt}from"./chunk-U5XL7D6A.mjs";import{a as w,b as Vt,c as Zt}from"./chunk-HYMEEXKN.mjs";import{g as T,j as Kt,l as Gt,m as Jt}from"./chunk-TKWEX4FD.mjs";import{existsSync as bo,readFileSync as ki,readdirSync as yi}from"node:fs";import S from"node:fs/promises";import N from"node:path";function Se(t){if(!t||!Array.isArray(t.lines))throw new Error("diff: lines must be an array.");t.lines.forEach(e=>{if(!e||!["added","removed","unchanged"].includes(e.type)||typeof e.content!="string"||/[\r\n]/.test(e.content))throw new Error("diff: each line needs a valid type and single-line content.");if(e.lineNumber!=null&&(!Number.isInteger(e.lineNumber)||e.lineNumber<1))throw new Error("diff: lineNumber must be a positive integer.")})}import{BODY as kt,isInstance as Wo}from"../browser/shared/components/index.mjs";import{ATTRIBUTE as Bo}from"../browser/shared/components/installed.mjs";import{attr as F,elementsOf as Ne,hasClass as Ho,walk as yt}from"../browser/shared/html-tree.mjs";import{CHART_DATA as Ko,CHART_KEY as Go,CHART_SOURCE as z,VIEW_FROM as tt,cellWords as Jo,rowsReading as ve,tableRows as Vo}from"../browser/shared/table-chart.mjs";var Zo=t=>t.tagName==="script"&&(F(t,"type")??"").trim().toLowerCase()==="application/json",Oe=t=>t.nodeName==="#text"?t.value:(t.childNodes??[]).map(Oe).join("");function Yo(t){let e=t;for(;e&&e.tagName!=="figure";)e=e.parentNode;let s=e?Ne(e).find(o=>/^h[2-4]$/.test(o.tagName)):null;return s?Jo(Oe(s)):""}function Ee(t,e,s=w(t)){let o=[];return yt(s,n=>{let i=e(n);if(i===void 0||!n.sourceCodeLocation)return;let a=n.childNodes.find(Zo);o.push({type:i,line:n.sourceCodeLocation.startLine,text:a?a.childNodes.map(c=>c.value??"").join(""):null,source:F(n,Ko),tag:n.tagName,holder:n.parentNode?.tagName,title:Yo(n)})},kt),o}var qo=t=>t.tagName==="ol"&&F(t,"data-doc-chart")==="flow",et=(t,e)=>Ee(t,s=>qo(s)?void 0:F(s,"data-doc-chart"),e),Xo=t=>Ee(t,e=>Ho(e,"doc-diff")?"diff":void 0);function G(t){let e=new Map;return yt(t,s=>{let o=F(s,z);if(o===void 0||!s.sourceCodeLocation)return;(e.get(o)??e.set(o,[]).get(o)).push({line:s.sourceCodeLocation.startLine,offset:s.sourceCodeLocation.startOffset,table:Ne(s).find(i=>i.tagName==="table")??null})},{...kt,inTemplates:!1}),e}function xt(t,e){let s=e.get(t)??[];if(s.length===0)return{error:`no table's frame carries ${z}="${t}", so the chart has nothing to draw: put the table back, or delete the card`};if(s.length>1)return{error:`${s.length} tables carry ${z}="${t}" (lines ${s.map(({line:c})=>c).join(", ")}): a key names one table (the chart draws the first); take it off the copies`};let[{line:o,table:n}]=s;if(!n)return{error:`the frame carrying ${z}="${t}" (line ${o}) holds no table`};let i=gt(n),a=Vo(i);return a.error?{error:`its table (line ${o}) ${a.error}`}:{...a,line:o,cells:i}}function St(t){let e=[t,...L(t).filter(({files:n})=>n.includes("kit.js")).map(n=>Q(n,"kit.js")??"")].join(`
3
+ `),s=new Set([...e.matchAll(/DocCharts\.define\(\s*(["'`])([a-z][a-z0-9-]*)\1/g)].map(n=>n[2])),o=new Set([...e.matchAll(/DocCharts\.define\(\s*(["'`])([^"'`\n]*)\1/g)].map(n=>n[2]).filter(n=>!s.has(n)));return{defined:s,misnamed:o}}function Nt(t){let e=w(t),s=[],{defined:o,misnamed:n}=St(t),i=null;for(let{type:a,line:c,text:l,source:r,tag:d,holder:f}of et(t,e)){let h=`data-doc-chart="${a}" (line ${c})`;if(d==="table"){s.push(f==="figure"?`${h} is on a table inside a <figure>: the chart's card is a figure of its own, so write the table outside it, its <caption> the chart's title`:`${h} is on a table the tools leave as written (inside a whole block, an element with a class of the document's own, a cell): a chart is drawn from a table outside one`);continue}if(n.has(a)){s.push(`${h}: the document's script defines "${a}" with DocCharts.define, which refuses that name: a chart type's name is lowercase letters, digits and hyphens, a letter first ("interval", "ci-plot"); rename it in both places`);continue}if(!o.has(a)){s.push(`${h}: the document's script does not define "${a}": define it once in the document's <script> with DocCharts.define("${a}", ({ host, data, tokens, width, height }) => { \u2026 }) (references/writing-html.md, "Figures and charts")`);continue}if(r!==void 0){if(l!==null){s.push(`${h}: a chart drawn from a table takes its data from the table: take its <script type="application/json"> out`);continue}let u=xt(r,i??=G(e));u.error&&s.push(`${h}: ${u.error}`);continue}if(l===null){s.push(`${h} needs its data in a <script type="application/json"> child`);continue}try{JSON.parse(l)}catch(u){s.push(`${h}: its data is not valid JSON (${u.message})`)}}s.push(...Le(e,i??=G(e)).failures);for(let{line:a,text:c}of Xo(t)){if(c===null)continue;let l=`.doc-diff (line ${a})`;try{Se(JSON.parse(c))}catch(r){s.push(`${l}: ${r instanceof SyntaxError?`its options are not valid JSON (${r.message})`:r.message}`)}}return s}function Te(t,{written:e=t}={}){let s=w(t),o=[],{defined:n}=St(t),i=null,a=null;for(let{type:c,line:l,text:r,source:d,title:f,tag:h}of et(t,s)){if(d===void 0||h==="table"||r!==null||!n.has(c))continue;let u=`data-doc-chart="${c}" (line ${l})`;if(!f){a??=new Set(e===t?[]:et(e).map(k=>k.source).filter(k=>k!==void 0));let b=e!==t&&!a.has(d);o.push(`${u}: this chart card has no title: ${b?"write a <caption> on its table (the one with data-doc-chart), which becomes the card's h3":"write an h3 in the card's figure, before the chart"}`)}let m=xt(d,i??=G(s));if(m.error)continue;let{blank:p,twice:g}=ve(m.cells,m.data);p&&o.push(`${u}: its table's header (line ${m.line}) has a cell with no words, so that column's values are keyed "" in data: write the column's name there`),g.length>0&&o.push(`${u}: its table's header (line ${m.line}) names ${g.map(b=>`"${b}"`).join(", ")} twice, so data keeps the later column's value under it: give each column a name of its own`)}return o.push(...Le(s,i??=G(s)).notes),o}var bt=500;function Le(t,e){let s=[],o=[],n=T().packages;return yt(t,i=>{let a=F(i,tt);if(a===void 0||!i.sourceCodeLocation)return;let c=F(i,Bo),l=`${c??i.tagName} (line ${i.sourceCodeLocation.startLine})`;if(!Wo(i))return void s.push(`<${i.tagName}> (line ${i.sourceCodeLocation.startLine}) carries ${tt}="${a}", which only a view of a table carries: an instance of a custom block (<div data-doc-component="<scope>/<name>">) whose block's needs hold "tables"; take it off`);if(!Go.test(a))return void s.push(`${l}: ${tt}="${a}" is no key: a letter, then letters, digits, "_" or "-", 32 at most, as the table's frame writes it in ${z}`);let r=e.get(a)??[];if(r.length===0)return void s.push(`${l}: no table's frame carries ${z}="${a}", so the view has no table to read: put the table back, or delete the view`);if(r.length>1)return void s.push(`${l}: ${r.length} tables carry ${z}="${a}" (lines ${r.map(({line:g})=>g).join(", ")}): a key names one table (the view reads the first); take it off the copies`);let[{line:d,offset:f,table:h}]=r;if(!h)return void s.push(`${l}: the frame carrying ${z}="${a}" (line ${d}) holds no table`);i.sourceCodeLocation.startOffset<f&&o.push(`${l} stands before the table it reads (${z}="${a}", line ${d}): it works there, but each block's writing.md writes the table first and the view after it, as its example does: move the view below the table, unless the document is meant to open on it`);let u=n.get(c)?.needs;u&&!u.includes("tables")&&o.push(`${l} carries ${tt}="${a}", but its block's needs hold no "tables", so it reads no table: add "tables" to needs in its component.json, or take the key off`);let m=gt(h);m.merged&&o.push(`${l}: its table (line ${d}) has merged cells, which no view reads, so the view shows nothing of it: write each value in its own cell`);let p=m.names?m.rows.length:Math.max(0,m.rows.length-1);p>bt&&o.push(`${l}: its table (line ${d}) has ${p} rows: every view of a table reads it again as it is typed in, and past ${bt} rows that slows typing in it; split it, or keep what a view shows to ${bt} rows`)},kt),{failures:s,notes:o}}function Ae(t){let e=w(t),s=[],o=[],{defined:n}=St(t),i=null,a=(c,l)=>`${c} ${l}${c===1?"":"s"}`;for(let{type:c,line:l,text:r,source:d,tag:f}of et(t,e)){if(d===void 0||f==="table"||r!==null||!n.has(c))continue;let h=xt(d,i??=G(e));if(h.error)continue;let{rows:u,columns:m,foot:p,extra:g}=ve(h.cells,h.data),b=`data-doc-chart="${c}" (line ${l})`,k=[a(u,"row")];for(let{name:x,numbers:v,words:E,empty:H}of m){let R=v+E+H,Y=v===R&&R>0?"numbers":E===R&&R>0?"words":[v&&a(v,"number"),E&&`${E} as words`,H&&`${H} empty (null)`].filter(Boolean).join(", ")||"no rows";k.push(`"${x}": ${Y}`),v>0&&E>0&&o.push(`${b}: its table's column "${x}" (line ${h.line}) reads as numbers in ${a(v,"row")} and as words in ${E}: write each of its cells as one number (an empty cell, "\u2014" or "n/a" for none: null in data), or, for a column of words, data-sort-type="text" on its header cell`)}p>0&&o.push(`${b}: its table's <tfoot> (line ${h.line}) holds ${a(p,"row")} the chart leaves out, and a table with a <tfoot> has no table tools in the preview: keep a total out of a table you chart and say it in the text`),g>0&&o.push(`${b}: ${a(g,"row")} of its table (line ${h.line}) ${g===1?"has":"have"} cells past the header, which the chart does not read: give each column a header cell`),s.push(`${c} (line ${l}) reads its table (line ${h.line}): ${k.join("; ")}`)}return{readings:s,notes:o}}import{BODY as xi,componentOf as Si,matchesNode as ko}from"../browser/shared/components/index.mjs";import{FLOW as Ni}from"../browser/shared/components/list.mjs";import{attr as O,elementsOf as yo,walk as M}from"../browser/shared/html-tree.mjs";import{GLYPH_SETS as vi,ICON_COLORS as xo,glyphOf as Oi,glyphValue as Ei,iconKind as Pt,iconMarkup as Ti,iconValueOf as Li}from"../browser/shared/emoji/icon-value.mjs";import Qo from"node:vm";import{LINE_START as nt,lineStart as ts}from"../browser/shared/code-lines.mjs";import{BODY as De,COMPONENTS as es,FLOWS as os,instanceSlots as ss,instancesOf as ns,isInstance as D,isSlot as _e,matchesNode as P,ownSlots as is,partOf as Tt,vocabulary as as}from"../browser/shared/components/index.mjs";import{ATTRIBUTE as C,INSTANCE as rs,PACKAGE_ID as it,SCHEMA as vt,SLOT as I,schemaAhead as cs}from"../browser/shared/components/installed.mjs";import{packageScript as ls}from"../browser/shared/export-wrap.mjs";import{asDocName as ds,kitNamespace as fs}from"../browser/shared/old-names.mjs";import{shortSheets as hs}from"../browser/shared/components/sheets.mjs";import{attr as y,curlyQuoted as us,hasClass as ps,walk as J}from"../browser/shared/html-tree.mjs";var{authoring:st,runtime:Ce}=as(),ms="input, select, textarea, button, details, table",at=t=>t.sourceCodeLocation?.startLine,$=t=>at(t)?` (line ${at(t)})`:"";function ze(t){let e=(o,n)=>{let i=Array.from({length:n.length+1},(a,c)=>c);for(let a=1;a<=o.length;a++){let c=i[0];i[0]=a;for(let l=1;l<=n.length;l++){let r=i[l];i[l]=Math.min(i[l]+1,i[l-1]+1,c+(o[a-1]===n[l-1]?0:1)),c=r}}return i[n.length]},[s]=[...st.keys()].filter(o=>o.startsWith(t.slice(0,7))).map(o=>[o,e(t,o)]).sort((o,n)=>o[1]-n[1]);return s&&s[1]<=3?` (${s[0]}?)`:""}function gs(t,e,s){let{part:o,property:n,min:i}=t.shares,a=new RegExp(`(?:^|;)\\s*${n}\\s*:\\s*([^;]*)`),c=s.map(f=>a.exec(y(f,"style")??"")?.[1].trim()??null),l=c.filter(f=>f!==null);if(l.length===0)return[];let r=`${t.id}${$(e)}`;return l.length<c.length?[`${r}: ${n} on ${l.length} of its ${c.length} ${o}: write it on every one of them, or on none (equal widths)`]:l.map(Number).some(f=>!Number.isFinite(f)||f<i-1e-9||f>1)?[`${r}: ${n} is a share of the row, a number from ${Math.round(i*1e3)/1e3} to 1 (${l.join(", ")})`]:[]}var ot={"doc-dialog-header":'a detail card has no header: its content region (<div class="doc-dialog-content">) stands alone in its panel',"doc-dialog-title":"a detail card's title is an ordinary heading (<h3>), first in its content region","doc-dialog-close":"a detail card has no close button: Esc and a press outside it close it","data-doc-dialog-close":"a detail card has no close button: Esc and a press outside it close it","doc-section-header":"a section's title is a plain heading (<h2>) with an ordinary paragraph below it for the line that says what the section is: no <div> goes around them","doc-grid":'a card row is now columns: <div class="doc-columns"> holding one <div class="doc-column"> per card',"doc-grid-3":'a card row is now columns: <div class="doc-columns"> holding three <div class="doc-column">',"doc-lede":`write the line under the title as a paragraph of the header (an ordinary <p>), or as small text, <p class="doc-note"): the header's lines read as the body's paragraphs`,"doc-source":`write the line under the title as a plain paragraph of the header (an ordinary <p>), or as small text (<p class="doc-note">): the header's lines read as the body's paragraphs`,"doc-prose":"write the text straight in its flow (the page, a Sheet panel, a section, a panel, a column\u2026): it reads the same there","doc-prose-h1":"write an h1","doc-prose-h2":"write an h2","doc-prose-h3":"write an h3","doc-prose-h4":"write an h4","doc-state-grid":'put the groups side by side in columns (<div class="doc-columns">)',"doc-state-group":"write the group's title as a heading and its controls as blocks of their own in a column","doc-state-status":'write the line as small text, <p class="doc-note">',"doc-code-block":'a code block is <div class="doc-code"> holding its title (<div class="doc-code-title">) and the <pre><code>',"doc-code-card":'a code block is <div class="doc-code"> holding its title and its <pre>; a diff is <div class="doc-diff">',"doc-code-header":'write the title as <div class="doc-code-title">: the kit draws the rest of the header',"data-doc-diff":'a diff is <div class="doc-diff"> holding its title and its options as JSON (sdk/doc-code.d.ts)',"data-doc-diff-stats":"the kit shows a diff's counts in its header: remove it","doc-code--wrap":"a code block wraps its long lines by itself: remove it (doc-code--nowrap scrolls them instead)"},$s={[nt]:'write it on its <div class="doc-code">',"data-start":`write ${nt} on its <div class="doc-code">`,"data-line-numbers":'write it on its <div class="doc-code">',"data-folded-lines":'write it on its <div class="doc-code">',"data-title":'write the title in its <div class="doc-code-title">',"data-wrap":'for long lines that scroll, write class="doc-code doc-code--nowrap" on its <div class="doc-code">'};function ws(t){let e=[],s=t.tagName==="pre"?t.parentNode:t.tagName==="code"&&t.parentNode?.tagName==="pre"?t.parentNode.parentNode:null;if(s?.tagName&&P(s,".doc-code"))for(let[n,i]of Object.entries($s))y(t,n)!==void 0&&e.push(`${n}${$(t)} on the <${t.tagName}> of a code block does nothing: ${i}`);let o=t.tagName==="div"&&P(t,".doc-code")?y(t,nt):void 0;return o!==void 0&&ts(o)===null&&e.push(`${nt}="${o}"${$(t)}: the number of a code block's first line is a whole number from 1`),e}var Ie=os.join(", "),bs=t=>P(t.parentNode,Ie)||t.parentNode?.tagName==="div"&&!y(t.parentNode,"class")&&P(t.parentNode.parentNode,Ie);function ks(t,e){let s=[];J(e,n=>s.push(...us(t,n)));let o=n=>n.replace(/=(\s*)[“”]/,'=$1"').replace(/[“”]$/,'"');return s.map(({written:n,line:i},a)=>a===0?`line ${i}: attribute ${n} uses curly quotes (U+201C/U+201D), which HTML reads as part of the value: write straight quotes, ${o(n)}; an editor keeping a file's \u201C\u2026\u201D style may change them`:`line ${i}: attribute ${n} uses curly quotes too: write ${o(n)}`)}var je={details:"write a plain <details> without the class (its <summary>, then what it holds): the export makes it the kit's"},ys="write a <section> of no attribute straight in it for each tab, starting with its heading (<h2>\u2013<h4>), the tab's name, the rest its blocks, and nothing else: the export makes the kit's tabs",xs='a bookmark written the short way is a paragraph in a flow holding only <a class="doc-bookmark" href="https://\u2026">its title</a> (a title attribute its description, nothing else on it, words alone in it): the export makes the card';function Me(t){let e=[];return J(t,s=>{y(s,C)!==void 0&&e.push(s)},De),e}var Ss=t=>{let e=t.parentNode;for(;e&&!(D(e)||_e(e));)e=e.parentNode;return e??null};function Ns(t,e){let s=[];return J(t,o=>{let n=y(o,I);if(n===void 0)return;if(D(o))return void s.push(`${I}="${n}"${$(o)} on the instance itself: a slot is an element inside it`);if(!_e(o))return void s.push(`${I}${$(o)} on a <${o.tagName}>: a slot is a block-level <div> or <section>`);let i=Ss(o),a=i&&D(i)?e?.get(y(i,C)):null;if(!i||!D(i)||a&&Pe(i,a,o))return void s.push(`${I}="${n}"${$(o)} stands outside any instance's own markup: a slot is a part of a component package's instance, written in its template`);y(o,"data-block-id")!==void 0&&s.push(`${I}="${n}"${$(o)}: a slot is no block: it carries no data-block-id`)}),s}var vs=(t,e)=>{for(let s=e.parentNode;s;s=s.parentNode)if(s===t)return!0;return!1},Pe=(t,e,s)=>Object.values(e.parts??{}).filter(({edit:o})=>o==="text"||o==="data").some(({at:o})=>Tt(t,o).some(n=>vs(n,s))),Re=(t,e)=>is(t).filter(s=>!Pe(t,e,s)),Os=t=>t.flatMap(e=>D(e)?it.test(y(e,C))?[]:[`${C}="${y(e,C)}"${$(e)} names no custom block: write <scope>/<name>, the id of a custom block of the workspace's components/ folder`]:[`${C}${$(e)} on a <${e.tagName}>: an instance of a component is a block-level <div> or <section>`]);function Ue(t){let e=Me(t).filter(o=>D(o)&&it.test(y(o,C))),s=e.length>0?T():null;return e.flatMap(o=>{let n=y(o,C),i=s.packages.get(n);if(i&&!cs(y(o,vt),i.schema))return[];if(i)return[`line ${at(o)}: <${o.tagName} ${C}="${n}">: ${vt}="${y(o,vt)}" is past the ${i.schema??1} its package's manifest reads (schema): nothing can write it back, and the block shows read-only until the package reads it`];let a=s.problems.get(n)?.problem,c=a?`package ${n} does not load (${Kt("en",a)})`:`no package ${n} in this workspace (components/${n}/component.json)`;return[`line ${at(o)}: <${o.tagName} ${C}="${n}">: ${c}: the block shows what it holds, read-only, and moves, copies and deletes whole`]})}function Ot(t,e){let s=[];for(let{name:o,value:n}of t.attrs){if(ot[o]&&!st.has(o)){s.push(`${o}${$(t)} is gone: ${ot[o]}`);continue}if(o.startsWith("data-doc-")&&!st.has(o)&&s.push(Ce.has(o)?`${o}${$(t)} is the kit's to set: remove it`:`${o}${$(t)} is no attribute of the kit's${ze(o)}`),o==="class"){for(let i of n.split(/\s+/).filter(e))if(!st.has(i)){if(ot[i]){s.push(`class ${i}${$(t)} is gone: ${ot[i]}`);continue}s.push(Ce.has(i)?`class ${i}${$(t)} is the kit's to set: remove it`:`class ${i}${$(t)} is no class of the kit's${ze(ds(i))}: give a class of the document's own a name of its own (not doc-\u2026)`)}}}return s}var Fe=t=>t.startsWith("doc-");function Es(t){try{return new Qo.Script(ls(t),{filename:"kit.js"}),null}catch(e){let s=/^kit\.js:(\d+)/.exec(e.stack??"")?.[1];return{message:e.message,line:s?Number(s):null}}}var Et=new Map;function Ts(t){if(!t.files.includes("kit.js"))return null;if(Et.get(t.folder)?.stamp!==t.stamp){let e=Q(t,"kit.js"),s=e===null?null:Es(e),o=e===null?`${t.id}: its kit.js cannot be read`:s&&`${t.id}: its kit.js does not run: ${s.message}${s.line?` (line ${s.line})`:""}`;Et.set(t.folder,{stamp:t.stamp,failure:o})}return Et.get(t.folder).failure}function Lt(t,e=w(t),s=null){let o=ks(t,e),n=Me(e);o.push(...Os(n));let i=n.length>0?s??T():null,a=i?[...i.packages.values()]:[];i&&o.push(...L(t,i,e).map(Ts).filter(Boolean));for(let r of[...es,...a].filter(d=>d.match&&(d.parts||d.pairs)))for(let d of ns(e,r)){if(r.empty&&!(d.childNodes??[]).some(u=>u.tagName||u.nodeName==="#text"&&u.value.trim()))continue;let f=r.id==="sheets"?hs(d):null;if(f){o.push(`${r.id}${$(d)} has no tabs and is no short form: ${f.why??"it stands where no block does (in a whole block or a figure)"}; ${ys}`);continue}if(je[r.id]&&Object.values(r.parts??{}).some(u=>Tt(d,u.at).length<(u.optional?0:u.min??1))){o.push(`${r.id}${$(d)} carries the kit's class without the kit's parts: ${je[r.id]}`);continue}let h={};for(let[u,m]of Object.entries(r.parts??{})){if(m.edit==="flow"&&it.test(r.id)){let b=Re(d,r).filter(k=>y(k,I)===u);b.length===0&&!m.optional&&o.push(`${r.id}${$(d)} has no ${u} (${I}="${u}")`);for(let k of b.slice(1))o.push(`${r.id}${$(k)}: slot "${u}" twice`);h[u]=b.slice(0,1);continue}h[u]=Tt(d,m.at);let p=m.optional?0:m.min??1,g=m.max??1/0;h[u].length<p?o.push(`${r.id}${$(d)} has ${h[u].length===0?"no":`${h[u].length} of`} ${u} (${m.at.replace(":scope > ","")})${h[u].length>0?`, at least ${p}`:""}`):h[u].length>g&&o.push(`${r.id}${$(d)} has ${h[u].length} of ${u}, at most ${g}`)}if(r.only){let u=new Set(r.only.flatMap(m=>h[m]));for(let m of(d.childNodes??[]).filter(p=>p.tagName&&!u.has(p)))o.push(`${r.id}${$(d)} holds a <${m.tagName}>${$(m)}: only its ${r.only.join(", ")} (${r.only.map(p=>r.parts[p].at.replace(":scope > ","")).join(", ")}) go in it`)}if(r.shares&&o.push(...gs(r,d,h[r.shares.part])),it.test(r.id)){let u=Object.entries(r.parts??{}).filter(([,m])=>m.edit==="flow").map(([m])=>m);for(let m of Re(d,r).filter(p=>!u.includes(y(p,I))))o.push(`${r.id}${$(m)}: slot "${y(m,I)}" is no part of its manifest edited as flow`)}for(let{a:u,attrA:m,b:p,attrB:g}of r.pairs??[]){let b=h[u].map(x=>y(x,m)),k=h[p].map(x=>y(x,g));for(let x of new Set(b.filter((v,E)=>b.indexOf(v)!==E)))o.push(`${r.id}${$(d)}: ${u} "${x}" twice`);for(let x of b.filter(v=>!k.includes(v)))o.push(`${r.id}${$(d)}: ${u.replace(/s$/,"")} "${x}" has no ${p.replace(/s$/,"")} (${g}="${x}")`);for(let x of k.filter(v=>!b.includes(v)))o.push(`${r.id}${$(d)}: ${p.replace(/s$/,"")} "${x}" has no ${u.replace(/s$/,"")} (${m}="${x}")`)}}o.push(...Ns(e,i?.packages));let c=new Set,l=[];J(e,r=>{if(D(r)){let h=new Set(ss(r));o.push(...Ot(r,Fe)),J(r,u=>o.push(...Ot(u,Fe)),{stop:u=>h.has(u)});return}r.tagName==="pre"&&bs(r)&&o.push(`<pre>${$(r)} straight in the text: a code block is <div class="doc-code"> holding its title (<div class="doc-code-title">) and the <pre>`),o.push(...ws(r)),r.tagName==="a"&&ps(r,"doc-bookmark")&&o.push(`<a class="doc-bookmark">${$(r)} is no bookmark: ${xs}`),o.push(...Ot(r,fs));let d=y(r,"data-doc-bind");d!==void 0&&(d.trim()?P(r,ms)?r.tagName==="button"&&y(r,"value")===void 0?o.push(`data-doc-bind${$(r)} on a button without a value: give it the value a click chooses`):c.add(d.trim()):o.push(`data-doc-bind${$(r)} on a ${r.tagName}: only inputs, selects, textareas, buttons with a value, details and tables hold a key`):o.push(`data-doc-bind${$(r)} names no key`));let f=y(r,"data-doc-show");f!==void 0&&l.push([r,f])},De);for(let[r,d]of l){let f=d.split(":")[0].trim();!f||!d.includes(":")?o.push(`data-doc-show="${d}"${$(r)}: write key:value`):c.has(f)||o.push(`data-doc-show="${d}"${$(r)}: nothing binds "${f}" (data-doc-bind="${f}")`)}return o.push(...js(t,e)),o}var Ls=/(?<![\\$])\$(?=[^\s$])([^$]*?[^\s$\\])\$(?![$\d])/g,As=/(?:(?<![A-Za-z0-9_])[A-Za-z]|[)\]}])_[A-Za-z0-9{]/,Cs=t=>/[\\^]/.test(t)||!t.startsWith("{")&&As.test(t),zs=new Set(["head","code","pre","kbd","samp","script","style","template","textarea","noscript","svg","math","title","iframe","object"]),Is=`.doc-math-inline, .doc-math-block, .doc-code, .doc-diff, [data-doc-math-dollar], [data-doc-chart], ${rs}`;function js(t,e){let s=[],o=n=>{for(let i of n.childNodes??[])if(i.nodeName==="#text"&&i.sourceCodeLocation&&i.value.includes("$")){let{startOffset:a,endOffset:c}=i.sourceCodeLocation;for(let l of t.slice(a,c).matchAll(Ls)){if(!Cs(l[1]))continue;let r=l[1].replace(/\s+/g," "),d=r.length>60?`${r.slice(0,59)}\u2026`:r;s.push(`line ${Zt(t,a+l.index)}: $${d}$ is not drawn as a formula (single dollars are off: they are money): write \\(${d}\\)`)}}else i.tagName&&!zs.has(i.tagName)&&!P(i,Is)&&o(i)};return o(e),s}import V from"node:fs";import W from"node:path";import{COLOR_NAMES as Hs}from"../browser/shared/colors.mjs";import{FOLD_DOTS as Ks}from"../browser/shared/code-folds.mjs";import{kitPublicDirectory as Gs,kitSourceDirectory as Js,release as Vs}from"../browser/shared/paths.mjs";import{FLOW_LABEL as Ua}from"../browser/shared/components/list.mjs";var Rs={"code-title":{zh:"\u4EE3\u7801\u5757",en:"Code"},"plain-text":{zh:"\u7EAF\u6587\u672C",en:"Plain text"},"fold-code":{zh:"\u6298\u53E0\u6216\u5C55\u5F00\u4EE3\u7801\u5757",en:"Collapse or expand the code block"},"copy-code":{zh:"\u590D\u5236\u4EE3\u7801",en:"Copy code"},copied:{zh:"\u5DF2\u590D\u5236",en:"Copied"},wrap:{zh:"\u81EA\u52A8\u6362\u884C",en:"Wrap lines"},"no-wrap":{zh:"\u53D6\u6D88\u81EA\u52A8\u6362\u884C",en:"Stop wrapping lines"},fold:{zh:"\u6298\u53E0",en:"Collapse"},unfold:{zh:"\u5C55\u5F00",en:"Expand"},line:{zh:"\u7B2C {0} \u884C",en:"Line {0}"},lines:{zh:"\u7B2C {0}\u2013{1} \u884C",en:"Lines {0}\u2013{1}"},"diff-counts":{zh:"\u65B0\u589E {0} \u884C\uFF0C\u5220\u9664 {1} \u884C",en:"Lines added: {0}, removed: {1}"}};var We="data-ge-language",Fs={"code-title":"--doc-word-code-title"};function Ds(t,e,s,...o){let n=t[s];if(!n)throw new Error(`The kit has no word "${s}" here (src/render/kit/words.js).`);let i=n[e]??n.zh;return o.length===0?i:i.replace(/\{(\d+)\}/g,(a,c)=>c<o.length?String(o[c]):a)}var _s=`:root[${We}="en"], :root:not([${We}])[lang|="en" i]`;function Be(){let t=e=>Object.entries(Fs).map(([s,o])=>`${o}: ${JSON.stringify(Ds(Rs,e,s))};`).join(" ");return`:root { ${t("zh")} }
4
+ ${_s} { ${t("en")} }`}import{LOOK as At,LOOK_ATTRIBUTES as Ms,SERIF_FONT as He,SIZE_FACTOR as Ps,SPACING as Us,WIDTH as Ct}from"../browser/shared/document-look.mjs";var Ke=[["--doc-body-font-size","--doc-body-line-height"],["--doc-small-font-size","--doc-small-line-height"],["--doc-note-font-size","--doc-note-line-height"],["--doc-title-font-size","--doc-title-line-height"],["--doc-h1-font-size","--doc-h1-line-height"],["--doc-h2-font-size","--doc-h2-line-height"],["--doc-h3-font-size","--doc-h3-line-height"],["--doc-h4-font-size","--doc-h4-line-height"],["--doc-card-title-font-size","--doc-card-title-line-height"],["--doc-table-font-size","--doc-table-line-height"]],Ws=["--doc-component-gap","--doc-block-gap","--doc-media-gap","--doc-paragraph-gap","--doc-group-gap","--doc-list-gap"],zt="--doc-content-max-width";function Bs(t){let e=new Map;for(let[,s,o]of String(t).matchAll(/^\s*(--doc-[a-z0-9-]+):\s*([^;]+);/gm))e.has(s)||e.set(s,o.trim());return e}var rt=t=>`${Math.round(t)}px`;function ct(t,{size:e="default",spacing:s="default",width:o="default"}={}){let n=r=>{let d=/^(-?[0-9.]+)px$/.exec(t.get(r)??"");if(!d)throw new Error(`src/render/kit/styles/tokens.css: ${r} is no length in px (src/render/look-css.mjs reads it)`);return Number(d[1])},i=Ps[e],{leading:a,gaps:c}=Us[s],l={};if(e!=="default"||s!=="default")for(let[r,d]of Ke){let f=n(r)*i;e!=="default"&&(l[r]=rt(f)),l[d]=rt(Math.round(f)+(n(d)-n(r))*i*a)}if(s!=="default"){for(let r of Ws)l[r]=rt(n(r)*c);l["--doc-space"]=String(c)}if(o!=="default"){if(n(zt)!==Ct.default)throw new Error(`src/render/kit/styles/tokens.css: ${zt} is not \u9ED8\u8BA4 \u6B63\u6587\u5BBD\u5EA6's ${Ct.default}px (src/shared/document-look.mjs WIDTH)`);l[zt]=rt(Ct[o])}return l}var U=(t,e)=>`${t} { ${Object.entries(e).map(([s,o])=>`${s}: ${o};`).join(" ")} }`,_=(t,e)=>`[${Ms[t]}="${e}"]`;function Ge(t){let e=Bs(t),s=e.get("--doc-font");if(!s)throw new Error("src/render/kit/styles/tokens.css: no --doc-font (src/render/look-css.mjs keeps it as --doc-sans-font)");let o=[U(`:root${_("font","serif")}`,{"--doc-sans-font":s,"--doc-font":He}),U(`:root${_("font","mixed")}`,{"--doc-heading-font":He})],[,...n]=At.size,[,...i]=At.spacing,[,...a]=At.width;for(let c of n)o.push(U(`:root${_("size",c)}`,ct(e,{size:c})));for(let c of i)o.push(U(`:root${_("spacing",c)}`,ct(e,{spacing:c})));for(let c of a)o.push(U(`:root${_("width",c)}`,ct(e,{width:c})));for(let c of n)for(let l of i){let r=ct(e,{size:c,spacing:l});o.push(U(`:root${_("size",c)}${_("spacing",l)}`,Object.fromEntries(Ke.map(([,d])=>[d,r[d]]))))}return o.join(`
5
+ `)}var Je=Object.fromEntries(K.filter(t=>t.file).map(t=>[t.file,t.build])),tr=Object.keys(Je),Z=t=>W.join(Js,t),Zs=(t,e,s)=>({entryPoints:[Z(t)],bundle:!0,write:!1,format:"iife",platform:"browser",target:"es2022",...typeof e=="function"?e():e,...s}),Ys=t=>{let e=Je[t];if(!e)throw new Error(`src/render/kit-build.mjs: no kit file "${t}"`);return e},lt=new Map;function qs(t,e){let s=[...e.matchAll(/^@import\s+"\.\/([a-z0-9-]+\.css)";\s*$/gm)].map(i=>i[1]),o=V.readdirSync(W.dirname(Z(t))).filter(i=>i.endsWith(".css")&&i!==W.basename(t)),n=[...o.filter(i=>!s.includes(i)).map(i=>`${i} is not listed`),...s.filter((i,a)=>!o.includes(i)||s.indexOf(i)!==a).map(i=>`${i} is listed but missing, or listed twice`)];if(n.length>0)throw new Error(`src/render/kit/${t}: ${n.join("; ")}`);return s.map(i=>W.join(W.dirname(t),i))}var Xs=t=>t.replace(/@(text|highlight)-colors\b/g,(e,s)=>Hs.map(o=>`.doc-${s}-${o}`).join(", ")),Qs=t=>{let e=Xs(t.join(`
6
+ `)).replaceAll("@fold-dots",Ks).replace(/^@kit-words;$/m,()=>Be());return e.replace(/^@kit-look;$/m,()=>Ge(e))};function It(t,{fresh:e=!1}={}){let s=Ys(t);if(Vs)return V.promises.readFile(W.join(Gs,t),"utf8");if(s.read)return V.promises.readFile(Z(s.read),"utf8");if(s.styles)return V.promises.readFile(Z(s.styles),"utf8").then(o=>Promise.all(qs(s.styles,o).map(n=>V.promises.readFile(Z(n),"utf8")))).then(Qs);if(e||!lt.has(t)){let o=le(Zs(s.bundle,s.options)).then(n=>n.outputFiles[0].text);o.catch(()=>lt.delete(t)),lt.set(t,o)}return lt.get(t)}import{kitNamespace as tn}from"../browser/shared/old-names.mjs";import{attr as jt,hasClass as ft}from"../browser/shared/html-tree.mjs";var Ve=t=>t.tagName==="section"&&ft(t,"doc-section"),en=new Set(["section","header","footer","nav","script","style","template","dialog","link","meta"]),on=t=>!en.has(t.tagName),dt=t=>t.nodeName==="#text"?t.value:(t.childNodes??[]).map(dt).join("");function Ye(t,e=[]){for(let s of t.childNodes??[])s.tagName&&((s.tagName==="main"&&ft(s,"doc-page")||jt(s,"data-doc-sheet")!==void 0)&&e.push(s),Ye(s.tagName==="template"?s.content:s,e));return e}var sn=/^(p|li|h[1-4]|blockquote|ul|ol)$/,qe=["doc-summary","doc-panel","doc-note","doc-callout"],nn=t=>sn.test(t.tagName)||qe.some(e=>ft(t,e)),an=new Set(["none","auto","100%","inherit","initial","unset","revert"]),Ze=t=>[...t.matchAll(/(?:^|[;{\s])(?:max-)?width\s*:\s*([^;}]+)/gi)].some(([,e])=>!an.has(e.replace(/!important/i,"").trim().toLowerCase())),rn=t=>{let e=t.trim().split(/\s*[\s>+~]\s*/).at(-1)??"",s=/^(p|li|h[1-4]|blockquote|ul|ol)\b/.test(e)||qe.some(n=>e.includes(`.${n}`)),o=[...t.matchAll(/\.([\w-]+)/g)].some(([,n])=>!tn(n))||t.includes("#");return s&&!o};function cn(t){let e=[],s=(o,n)=>{for(let i of o.childNodes??[]){if(!i.tagName)continue;let a=n||i.tagName==="main"&&ft(i,"doc-page");if(a&&nn(i)&&Ze(jt(i,"style")??"")&&e.push(`<${i.tagName}> with style="${jt(i,"style").trim()}"`),i.tagName==="style"){let c=dt(i).replace(/\/\*[\s\S]*?\*\//g,"");for(let[,l,r]of c.matchAll(/([^{}]+)\{([^{}]*)\}/g))if(Ze(r))for(let d of l.split(","))rn(d)&&e.push(`"${d.trim()}" in the document's style`)}s(i.tagName==="template"?i.content:i,a)}};return s(t,!1),e}function Xe(t,{written:e=t}={}){let s=[],o=w(t),n=cn(o);n.length>0&&s.push(`body text given a width of its own (${n.slice(0,3).join("; ")}${n.length>3?`; ${n.length-3} more`:""}): its lines break before the reading column's edge, leaving an extra right margin; let body text fill the column`);for(let i of Ye(o)){let a=i.childNodes.filter(c=>c.tagName);a.forEach((c,l)=>{if(!Ve(c))return;let r=l+1;for(;r<a.length&&on(a[r]);)r++;let d=a.slice(l+1,r);if(d.length===0||!Ve(a[r]??{})||/^h[1-4]$/.test(d[0].tagName))return;let f=c.childNodes.map(g=>g.tagName?g:null).filter(Boolean).map(dt).find(g=>g.trim())?.replace(/\s+/g," ").trim().slice(0,40)??"",[h]=d,u=dt(h).replace(/\s+/g," ").trim(),m=`<${h.tagName}>${u?` "${u.length>30?`${u.slice(0,30)}\u2026`:u}"`:""}`,p=h.sourceCodeLocation?.startLine;s.push(`${d.length} block${d.length===1?"":"s"} of body text right after the section "${f}" stand outside it${p?` (line ${p})`:""}, ${d.length===1?`the ${m}`:`the first a ${m}`}, between two sections, with no heading of their own: fine if meant, otherwise they belong inside that section`)})}return s.push(...Te(t,{written:e})),s}import{attr as Qe,hasClass as ln}from"../browser/shared/html-tree.mjs";var to="Write instead where it came from, in words, or a path relative to materials/ (materials/data.csv)",dn=new Set(["script","style","template","noscript","textarea","pre","code","kbd","samp","var"]),fn=["doc-math-inline","doc-math-block"],hn=/\\\([\s\S]*?\\\)|\\\[[\s\S]*?\\\]|\$\$[\s\S]*?\$\$/g,un=/(?<!\\)\$(?:\\[\s\S]|[^\\$])+\$/g,pn=/[\s"'<>|()[\]{};,。;:、!?()《》「」『』“”‘’【】]/u,mn=/[^\s"'<>|()[\]{};,。;:、!?()《》「」『』“”‘’【】]+/gu,so=/^[\p{Script=Han}\p{Script=Hiragana}\p{Script=Katakana}\p{Script=Hangul}]/u,gn=/\.[A-Za-z0-9]{1,8}$/,$n=[/(?<![A-Za-z0-9_\\])[A-Za-z]:[\\/]/g,/(?<![A-Za-z0-9_.~:/\\-])\/(?:Users|home|root|tmp|private|mnt|opt|Volumes|var\/folders)\/(?=\S)/g,/(?<![A-Za-z0-9_.~:/\\-])~\/(?=\S)/g,/(?<![A-Za-z0-9_$\\])\$(?:HOME|\{HOME\})\/(?=\S)/g,/(?<![A-Za-z0-9_:\\])\\\\[A-Za-z0-9][\w.$-]*\\(?=[^\s\\])/g,/%(?:TEMP|TMP|APPDATA|LOCALAPPDATA|USERPROFILE)%/gi],wn=/(?:^|[\\/])(?:AppData|scratchpad)(?=[\\/]|$)/i,bn=/^(?:[A-Za-z]:|[\\/]|%[A-Za-z]+%)[\s\S]*[\\/](?:temp|tmp)(?=[\\/])/i,kn=t=>t.includes("://")&&!/^file:/i.test(t),eo=12;function oo(t,e){let s=e;for(;s<t.length&&!pn.test(t[s])&&!(so.test(t[s])&&gn.test(t.slice(e,s)));)s++;return t.slice(e,s).replace(/[.,;:!?]+$/,"")}function yn(t,e=!1){let s=c=>c.replace(/[^\n]/g," "),o=t.replace(hn,s),n=e?o.replace(un,s):o,i=[],a=(c,l)=>i.some(r=>r.at<=c+l.length&&c<=r.at+r.path.length);for(let c of $n)for(let l of n.matchAll(c)){let r=oo(n,l.index);r.length>=l[0].length+2&&!a(l.index,r)&&i.push({at:l.index,path:r})}for(let c of n.matchAll(mn)){let l=c.index;for(;l<c.index+c[0].length&&so.test(n[l]);)l++;let r=oo(n,l);/[\\/]/.test(r)&&(wn.test(r)||bn.test(r))&&!kn(r)&&!a(l,r)&&i.push({at:l,path:r})}return i.sort((c,l)=>c.at-l.at)}function no(t,e=w(t)){let s=[],o=(a,c)=>{for(let l of a.childNodes??[])if(l.nodeName==="#text"){if(!l.sourceCodeLocation)continue;for(let{at:r,path:d}of yn(l.value,c))s.push({line:l.sourceCodeLocation.startLine+(l.value.slice(0,r).match(/\n/g)?.length??0),path:d})}else l.tagName&&!dn.has(l.tagName)&&Qe(l,"hidden")===void 0&&!fn.some(r=>ln(l,r))&&o(l,c||Qe(l,"data-doc-math-dollar")!==void 0)};o(e,!1);let n=s.slice(0,eo).map(({line:a,path:c})=>`line ${a}: "${c.length>80?`${c.slice(0,77)}\u2026`:c}" is a path of this machine in the text a reader reads: a reader on another machine cannot open it. ${to}`),i=s.slice(eo);return i.length>0&&n.push(`${i.length} more path${i.length===1?"":"s"} of this machine in the text a reader reads, on line${new Set(i.map(({line:a})=>a)).size===1?"":"s"} ${[...new Set(i.map(({line:a})=>a))].join(", ")}. ${to}`),n}import{elementsOf as io}from"../browser/shared/html-tree.mjs";import{netSnapshot as xn}from"../browser/shared/net-cache.mjs";import{hostIn as Sn,netHostsOf as Nn}from"../browser/shared/net-policy.mjs";var vn=(t,e)=>`<script type="application/json" data-doc-snapshot data-at="${e}">${JSON.stringify(t).replace(/</g,"\\u003c")}</script>`,Rt=t=>t.some(({needs:e})=>Array.isArray(e)&&e.includes("workspace"));function ao(t,{slug:e,packages:s,root:o,at:n=new Date,workspace:i=null}){let a=s.flatMap(({needs:f})=>Nn(f)),c=a.length===0?null:xn(o,e,f=>{try{return Sn(new URL(f).hostname,a)!==null}catch{return!1}}),l={...i&&Rt(s)?i:{},...c?{net:c}:{}};if(Object.keys(l).length===0)return t;let r=io(io(w(t)).find(f=>f.tagName==="html")??{}).find(f=>f.tagName==="head"),d=r?.sourceCodeLocation?.endTag?.startOffset??r?.sourceCodeLocation?.startTag?.endOffset;return d===void 0?t:`${t.slice(0,d)} ${vn(l,n.toISOString())}
7
+ ${t.slice(d)}`}import{MENTION as On,MENTION_ICON as En}from"../browser/shared/components/mention.mjs";import{escapeAttribute as Tn}from"../browser/shared/escape.mjs";import{attr as ro,elementsOf as Ln,hasClass as co,walk as An}from"../browser/shared/html-tree.mjs";import{addressOn as Cn,decoded as zn,fromFile as In,hosted as jn,pageAddress as Rn,workbenchHash as Fn}from"../browser/shared/page-address.mjs";function Dn(t,e,s){let o=In(t,e),n=Cn(o,s);return n||jn(t)?n:Rn(o)??(Fn(o)===null?null:{slug:null,block:null})}function _n(t,e,s,o){let n=w(t),i=new Set,a=[];An(n,r=>{let d=ro(r,"data-block-id");d!==void 0&&i.add(d),r.tagName==="a"&&ro(r,"href")!==void 0&&r.sourceCodeLocation?.startTag&&a.push(r)});let c=new Map,l=({startOffset:r,endOffset:d})=>c.set(r,[d,""]);for(let r of a){let{prefix:d,value:f}=r.attrs.find(({name:k})=>k==="href"),h=f.startsWith("#")?zn(f.slice(1)):null,u=h===null?f&&Dn(f,e,o):i.has(h)?{slug:e,block:h}:null;if(!u)continue;let m=s(u,f);if(m===f)continue;let{attrs:p,startTag:g,endTag:b}=r.sourceCodeLocation;if(m===null)l(g),b&&l(b),co(r,On)&&Ln(r).filter(k=>co(k,En)).forEach(k=>l(k.sourceCodeLocation));else{let k=d?`${d}:href`:"href";c.set(p[k].startOffset,[p[k].endOffset,`${k}="${Tn(m)}"`])}}return[...c].sort(([r],[d])=>d-r).reduce((r,[d,[f,h]])=>`${r.slice(0,d)}${h}${r.slice(f)}`,t)}function lo(t,e,s,{blocks:o=!0,links:n}){return _n(t,e,({slug:i,block:a})=>{let c=s(i);if(c===null)return null;if(!a||!o)return i===e&&a?null:c;let l=`#${encodeURIComponent(a)}`;return i===e?l:`${c}${l}`},n)}import ht from"node:fs";import Mn from"node:path";import{extensionOf as Pn,imageFile as Un,mediaTypeOf as Wn}from"../browser/shared/media.mjs";var _t=1024*1024,Bn=_t,ho=2400,Ft=2e3,Hn=.25,Kn=new Set(["png","gif"]),fo=.75;function Gn(t){if(t.length<16||t.toString("latin1",0,4)!=="RIFF"||t.toString("latin1",8,12)!=="WEBP")return!1;for(let e=12;e+8<=t.length;){let s=t.toString("latin1",e,e+4);if(s==="VP8L")return!0;if(s==="VP8 "||s==="ANMF")return!1;let o=t.readUInt32LE(e+4);e+=8+o+o%2}return!1}function Jn(t){let e=(s,o)=>s+o<=t.length;if(e(0,24)&&t.readUInt32BE(0)===2303741511&&t.toString("latin1",12,16)==="IHDR")return{width:t.readUInt32BE(16),height:t.readUInt32BE(20)};if(e(0,10)&&/^GIF8[79]a$/.test(t.toString("latin1",0,6)))return{width:t.readUInt16LE(6),height:t.readUInt16LE(8)};if(e(0,4)&&t[0]===255&&t[1]===216){for(let s=2;e(s,4);){if(t[s]!==255)return null;let o=t[s+1];if(o===255){s+=1;continue}if(o===216||o===1||o>=208&&o<=215){s+=2;continue}if(o>=192&&o<=207&&![196,200,204].includes(o))return e(s,9)?{width:t.readUInt16BE(s+7),height:t.readUInt16BE(s+5)}:null;if(o===217||o===218)return null;s+=2+t.readUInt16BE(s+2)}return null}if(e(0,30)&&t.toString("latin1",0,4)==="RIFF"&&t.toString("latin1",8,12)==="WEBP"){let s=t.toString("latin1",12,16);if(s==="VP8 ")return{width:t.readUInt16LE(26)&16383,height:t.readUInt16LE(28)&16383};if(s==="VP8L"){let o=t.readUInt32LE(21);return{width:(o&16383)+1,height:(o>>>14&16383)+1}}return s==="VP8X"?{width:t.readUIntLE(24,3)+1,height:t.readUIntLE(27,3)+1}:null}if(e(0,12)&&t.toString("latin1",4,8)==="ftyp"&&/avi[fs]/.test(t.toString("latin1",8,Math.min(t.length,t.readUInt32BE(0))))){let s=null;for(let o=t.indexOf("ispe",0,"latin1");o>=0&&e(o,16);o=t.indexOf("ispe",o+4,"latin1")){let n={width:t.readUInt32BE(o+8),height:t.readUInt32BE(o+12)};(!s||n.width*n.height>s.width*s.height)&&(s=n)}return s}return null}var Vn=_t;function Zn(t){let e;try{e=ht.openSync(t,"r");let{size:s}=ht.fstatSync(e),o=Buffer.alloc(Math.min(s,Vn));return ht.readSync(e,o,0,o.length,0),{length:s,head:o}}catch{return null}finally{e!==void 0&&ht.closeSync(e)}}var j=t=>`${Math.max(.1,t/_t).toFixed(1)} MB`;function Yn({bytes:t,width:e,height:s,extension:o,lossless:n}){let i=Math.max(e,s),a=Math.min(1,Ft/i),c=Math.min(t,e*s*a*a*Hn);if(i>ho){if(!n)return c<=t*fo?` \u2014 a ${Ft}px copy would be about ${j(c)}`:"";let l=t*a*a;return` \u2014 a ${Ft}px copy would be about ${j(l)}${o==="png"&&c<l/2?`, or ${j(c)} as a JPEG (for a photograph)`:""}`}return!n&&c<=t*fo?` \u2014 written again as a JPEG of quality about 82, it would be about ${j(c)}`:o==="png"&&c<t/2?` \u2014 as a JPEG (for a photograph) it would be about ${j(c)}`:""}var Dt=t=>t===2?"twice":`${t} times`;function uo({html:t,directory:e,tree:s=w(t)}){let{embedded:o,unserved:n}=re({html:t,directory:e,tree:s}),i=new Map,a=(l,r,d,f=!1)=>{let h=i.get(l)??i.set(l,{at:[],shows:0,served:d}).get(l);h.at.push(r),f||(h.shows+=1)};for(let{file:l,line:r,icon:d}of o)Un(l)&&a(l,r,!0,d);for(let{file:l,line:r}of n)Wn(l).startsWith("image/")&&a(l,r,!1);let c=[];for(let[l,{at:r,shows:d,served:f}]of[...i].sort(([,h],[,u])=>Math.min(...h.at)-Math.min(...u.at))){let h=Zn(Mn.join(e,l));if(!h)continue;let{length:u,head:m}=h,p=Jn(m),g=p?Math.max(p.width,p.height):0,b=u>Bn||g>ho,k=f&&d>1;if(!b&&!k)continue;let x=[...new Set(r)],v=`line${x.length===1?"":"s"} ${x.length>1?`${x.slice(0,-1).join(", ")} and ${x.at(-1)}`:x[0]}`,E=k?`shown ${Dt(d)}: the export embeds it ${Dt(d)}; show it once and refer back to it in words`:"";if(!b){c.push(`${l} (${v}): ${E} (${j(Math.ceil(u/3)*4*d)} as data: URLs)`);continue}let H=r.length===1||!f?"":`, ${Dt(r.length)}`,R=f?r.length:1,Y=`${j(Math.ceil(u/3)*4*R)} as ${R===1?"a data: URL":"data: URLs"}`,Po=p?`, ${p.width}\xD7${p.height}px`:"",Bt=Pn(l),Ht=p?Yn({bytes:u,...p,extension:Bt,lossless:Kn.has(Bt)||Gn(m)}):"",Uo=f?`the export embeds it as it is${H}, ${Y}${Ht}`:`its name keeps it out of the preview and the export (the failure at its line says why); copied into assets/ under a name they take, the export embeds it as it is, ${Y}${Ht}: copy it in at the size the page needs`;c.push(`${l} (${v}): ${j(u)}${Po}; ${Uo}${E?`; ${E}`:""}`)}return c}import{COMPONENTS as hi}from"../browser/shared/components/index.mjs";import{withLook as ui}from"../browser/shared/document-look.mjs";import{reportsDirectory as pi}from"../browser/shared/paths.mjs";import{documentLook as mi}from"../browser/shared/workspace-look.mjs";import po from"node:fs";import{MENTION as mo,MENTION_ICON as go}from"../browser/shared/components/mention.mjs";import{escapeAttribute as qn,escapeText as Xn}from"../browser/shared/escape.mjs";import{iconUrl as Qn,validIcon as ti}from"../browser/shared/emoji/icon-value.mjs";import{attr as ei,hasClass as oi,walk as si}from"../browser/shared/html-tree.mjs";import{fromFile as ni,isFileLink as ii,pageAddress as ai}from"../browser/shared/page-address.mjs";import{reportsDirectory as ri}from"../browser/shared/paths.mjs";import{documentDirectory as ci,documentFiles as li}from"../browser/shared/workspace.mjs";function di(t,e){let{html:s,json:o}=li(ci(t,e));if(!po.existsSync(s))return null;try{let{title:n,icon:i}=JSON.parse(po.readFileSync(o,"utf8"));return{title:n,icon:i}}catch{return{}}}function fi(t,e,s,o){if(s==="words"||typeof t!="string"||!ti(t))return null;if(s==="preview")return Qn(t,e,{tab:!0});let n=qt({value:t,slug:e,tab:!0,reportsDirectory:o});return n&&`data:${n.type};base64,${n.body.toString("base64")}`}function $o(t,{slug:e,mode:s="export",reportsDirectory:o=ri}){if(!t.includes(mo))return t;let n=new Map,i=c=>(n.has(c)||n.set(c,di(c,o)),n.get(c)),a=new Map;return si(w(t),c=>{let l=c.tagName==="a"&&oi(c,mo)?ei(c,"href"):void 0,{startTag:r,endTag:d}=c.sourceCodeLocation??{};if(!l||!ii(l)||!r||!d)return;let f=ai(ni(l,e))?.slug;if(!f)return;let h=i(f);if(!h)a.set(r.endOffset-1,[r.endOffset-1," data-doc-gone"]);else if(h.title){let u=fi(h.icon,f,s,o);a.set(r.endOffset,[d.startOffset,`${u?`<img class="${go}" src="${qn(u)}" alt="">`:`<span class="${go}"></span>`}${Xn(h.title)}`])}}),[...a].sort(([c],[l])=>l-c).reduce((c,[l,[r,d]])=>`${c.slice(0,l)}${d}${c.slice(r)}`,t)}var gi=/<script\b[^>]*\bdata-doc-kit="runtime"[^>]*><\/script>/;function $i(t,e,s){let o=Gt(e).filter(({id:n})=>!s.some(i=>i.id===n)).map(Jt).join(" ");return o?t.replace(gi,n=>`${n}
8
+ <script data-doc-dev>${o}</script>`):t}var wo=/(<title\b[^>]*>)\s*(<\/title>)/i;function wi(t){if(!wo.test(t))return t;let e=/^en\b/i.test(/<html\b[^>]*\slang=["']?([^"'\s>]*)/i.exec(t)?.[1]??"");return t.replace(wo,(s,o,n)=>`${o}${e?"Untitled":"\u672A\u547D\u540D\u6587\u6863"}${n}`)}function Mt(t,{slug:e,mode:s="export",files:o=!0,reportsDirectory:n,kit:i,catalog:a}){let{html:c,removed:l}=bi(t,{reportsDirectory:n,kit:i,catalog:a,describe:s==="preview"}),r={slug:e,mode:s,...n?{reportsDirectory:n}:{}},d=Xt(ui(c,mi(e,n??pi)),r),f=o?ce(te(oe(ne(d,r),r),r),r):d;return{html:wi($o(f,r)),removed:l}}function bi(t,{reportsDirectory:e,kit:s,page:o=!1,describe:n=!1,catalog:i=T()}){let a=L(t,i),{html:c,removed:l,used:r}=fe(t,[...hi,...a]),d=ke(he(c,{used:r,page:o,...s?{href:s}:{}}),a);return{html:n?$i(d,i,a):d,removed:l,packages:a}}import{exportsDirectory as Ai,kitPublicDirectory as Ci,release as zi,reportsDirectory as A,vendorDirectory as Ii}from"../browser/shared/paths.mjs";import{referencedFile as ji}from"../browser/shared/media.mjs";import{decoded as Ri,fromFile as Fi,hashAddress as Di,hosted as Lo,pageAddress as _i,workbenchHash as Mi}from"../browser/shared/page-address.mjs";import{pageLinks as Pi}from"../browser/shared/page-links.mjs";import{layoutOf as Ao}from"../browser/shared/workspace.mjs";import{documentLinks as Ui,listReportSlugs as Wi}from"../browser/shared/reports.mjs";import{documentDirectory as B,documentFiles as Wt}from"../browser/shared/workspace.mjs";import{sha256 as ut}from"../browser/shared/files.mjs";import{EXPORT_CSP as Bi,GENERATOR as Hi,isolateUmd as Ki,packagesMeta as Gi,sourceMeta as Ji}from"../browser/shared/export-wrap.mjs";var So=/__REPORT_[A-Z_]+__/,No=1e6,vo=t=>t.length>1?`${t.slice(0,-1).join(", ")} and ${t.at(-1)}`:`${t[0]}`;function Vi(t){return t.map(({id:e,lines:s,columns:o})=>{let n=new Set(s).size<s.length,i=s.map((a,c)=>n?`${a}:${o[c]}`:`${a}`);return`data-block-id repeats: "${e}" on lines ${vo(i)}${n?" (line:column)":""}; each id names one block: remove it from the copy, which needs none (the later ${i.length>2?`ones, lines ${vo(i.slice(1))}`:`one, line ${i[1]}`}, unless the copy went before its original)`})}var Zi=({slug:t,htmlPath:e,metadataPath:s})=>{let o=e?{html:e,json:s??e.replace(/\.html$/,".json")}:Wt(B(t,A));return{htmlName:N.basename(o.html),jsonName:N.basename(o.json)}};function Yi({slug:t,html:e,metadata:s,htmlPath:o,metadataPath:n,tree:i=w(e)}){let a=[],{htmlName:c,jsonName:l}=Zi({slug:t,htmlPath:o,metadataPath:n}),r=/<h1\b[^>]*\bclass="[^"]*\bdoc-title\b[^"]*"[^>]*>\s*<\/h1>/i.test(e),d=[[/<meta\s+name=["']viewport["']/i,"missing viewport metadata"],[r?/<title>\s*<\/title>|<title>[^<]+<\/title>/i:/<title>[^<]+<\/title>/i,"missing document title"],[/<main(?:\s|>)/i,"missing semantic main element"],[/aria-label|aria-labelledby|<title>/i,"missing accessible labels"]];for(let[p,g]of d)p.test(e)||a.push(g);let f=Buffer.byteLength(e);f>No&&a.push(`the document's editable source is ${f.toLocaleString("en-US")} bytes, over the ${No.toLocaleString("en-US")}-byte limit: aggregate or sample the embedded data, or split the document`),So.test(e)&&a.push(`${c} still contains a starter placeholder such as __REPORT_TITLE__`);for(let[p,g]of Object.entries(s))typeof g=="string"&&So.test(g)&&a.push(`${l} "${p}" is still a starter placeholder such as __REPORT_TITLE__`);/<[a-z][^>]*\sdata-doc-placeholder\b/i.test(e)&&a.push("starter placeholder content ([data-doc-placeholder]) is still present; replace it with the document's content");let h=new Map;M(i,p=>{let g=O(p,"data-block-id"),b=p.sourceCodeLocation?.attrs?.["data-block-id"]??p.sourceCodeLocation;g!==void 0&&h.set(g,[...h.get(g)??[],{line:b?.startLine,column:b?.startCol}])});let u=[...h].filter(([,p])=>p.length>1);a.push(...Vi(u.map(([p,g])=>({id:p,lines:g.map(({line:b})=>b),columns:g.map(({column:b})=>b)}))));let m=null;if(M(i,p=>{!m&&p.tagName==="main"&&(m=p)},{inTemplates:!1}),m){let p=O(m,"data-doc-id");p===void 0?a.push(`main.doc-page needs data-doc-id="${t}"`):p!==t&&a.push(`main[data-doc-id] is "${p}": it must be the document's slug "${t}"`)}return a}var Co=t=>yo(yo(t).find(e=>e.tagName==="html")??{}).find(e=>e.tagName==="head")?.sourceCodeLocation?.startTag?.endOffset,Ut=new Set(["localStorage","sessionStorage"]);function zo(t){let e=[],s=[];return M(t,o=>{o.tagName==="script"&&O(o,"src")!==void 0&&e.push(O(o,"src")),(o.tagName==="link"?(O(o,"rel")??"").toLowerCase().split(/\s+/):[]).includes("stylesheet")&&O(o,"href")!==void 0&&s.push(O(o,"href"))}),{scripts:e,styles:s}}function Io({slug:t,html:e,directory:s=B(t,A),tree:o=w(e),uses:n=X(e,q,{tree:o}),catalog:i}){let a=[];Co(o)===void 0&&a.push("the page writes no <head> start tag, which an export puts its Content-Security-Policy right after: write <head> \u2026 </head> before <body>");let c=[];M(o,d=>{if(["script","link","img"].includes(d.tagName))for(let f of["src","href"]){let h=O(d,f)?.trim();h&&/^https?:\/\//i.test(h)&&c.push(h)}}),c.length>0&&a.push(`external resources are not portable: ${c.join(", ")}`);for(let{name:d,how:f,line:h,where:u}of n){if(!q.has(d))continue;let m={call:`calls ${d}(\u2026)`,new:`creates new ${d}(\u2026)`}[f]??`uses ${d}`;a.push(`line ${h}: ${u} ${m}: embed its data (inline JSON, DocState); the export blocks the network`)}let{scripts:l,styles:r}=zo(o);for(let d of l)ge.has(d)||a.push(`unsupported script dependency ${d}`);for(let d of r)$e.has(d)||a.push(`unsupported stylesheet dependency ${d}`);return a.push(...ie({html:e,directory:s,tree:o}),...se({html:e,directory:s,tree:o}),...ee({html:e,directory:s,tree:o}),...ae({html:e,directory:s,tree:o})),a.push(...ye(L(e,i,o))),[...new Set(a)]}var qi=[[/\bDocSheets\.mount\s*\(/,"Sheet areas start on their own: remove DocSheets.mount (an area keeps its tab under its data-doc-sheets name)"],[/\bDocCode\.(?:View|DiffView|DiffStats|enhance)\b/,'code blocks are highlighted on their own, and a diff is declared as <div class="doc-diff"> holding { path, lines } as JSON (sdk/doc-code.d.ts)'],[/\bDocTables\.(?:enhance|enhanceAll|makeSortable)\b/,"tables start on their own: remove the call"],[/\bDocDialogs\.(?:enhance|enhanceAll)\b/,"detail cards start on their own: remove the call"]];function Xi({html:t,tree:e=w(t),uses:s=X(t,Ut,{tree:e})}){let o=we(t,e),n=[...ue(t,e),...pe(t,e)];for(let[i,a]of qi)i.test(o)&&n.push(`${o.match(i)[0].replace(/\s*\($/,"")} is gone: ${a}`);for(let{name:i,line:a,where:c}of s)Ut.has(i)&&n.push(`line ${a}: ${c} uses ${i}: use DocState instead of direct browser storage`);return[...new Set(n)]}var Qi=(t,e)=>e.childNodes.find(s=>s.tagName||s.nodeName==="#text"&&s.value.trim())===t,ta=t=>ko(t,Si("highlight").match)||t.tagName==="li"&&ko(t.parentNode,`ol.${Ni}`),ea=`an icon is one of three kinds: an emoji, <div class="doc-icon">\u{1F3AF}</div>; an icon of Gallery's sets in one of ${xo.length} colors, <div class="doc-icon" data-icon="/icons/airplane_blue.svg"></div> (MingCute's names; Tabler's as /icons/tabler/plane_blue.svg; the colors ${xo.join(", ")}); or a picture of the document's folder, <div class="doc-icon"><img src="assets/logo.png" alt=""></div>`,jo=t=>t.nodeName==="#text"?t.value:(t.childNodes??[]).map(jo).join("");function Oo(t,e,s){let o=e.sourceCodeLocation?.attrs?.[s],n=o?t.slice(o.startOffset,o.endOffset):`${s}="${O(e,s)??""}"`;return n.length>72?`${n.slice(0,71)}\u2026`:n}function oa(t,e){let s=O(e,"data-icon");if(s!==void 0)return{held:Oo(t,e,"data-icon"),meant:Pt(s)==="glyph"?s:null};let o=null;if(M(e,i=>{o??=["img","svg"].includes(i.tagName)?i:null}),o?.tagName==="img"){let i=O(o,"src");return{held:`<img ${Oo(t,o,"src")}>`,meant:Pt(i)==="image"?i:null}}if(o)return{held:"an <svg>"};let n=jo(e).replace(/\s+/g," ").trim();return{held:n?`"${n.slice(0,40)}"`:"nothing"}}function sa({set:t,name:e,color:s}){let o=vi.find(a=>a!==t);if(mt(o).includes(e))return`; "${e}" is ${o==="tabler"?"Tabler":"MingCute"}'s: ${Ei(o,e,s)}`;let n=e.split("-").filter(a=>a.length>=3),i=mt(t).filter(a=>a.split("-").some(c=>n.includes(c))).slice(0,6);return i.length>0?`; names of its set near it: ${i.join(", ")}`:""}function na({html:t,tree:e=w(t)}){let{all:s,own:o}=Qt(e),n=[],i=a=>a.sourceCodeLocation?.startLine;o.length>1&&n.push(`line ${i(o[1])}: ${o.length} page icons (.doc-icon) in the header (the first at line ${i(o[0])}): a document has one, right before its title`);for(let a of s){let c=i(a),l=a.parentNode;!o.includes(a)&&!(ta(l)&&Qi(a,l))&&n.push(`line ${c}: an icon (.doc-icon) stands only right before the document's title, first in a highlight block (.doc-panel, .doc-summary), or first in a flowchart's step (ol.doc-flow > li, in its number's place)`);let r=Li(Vt(t,a)),{held:d,meant:f}=r?{}:oa(t,a);f?n.push(`line ${c}: an icon (.doc-icon) holds ${d}, an icon a page reads only in double quotes: write ${Ti(f)}`):r?Pt(r)==="glyph"&&!Yt(r)&&n.push(`line ${c}: the icon ${r} is none of the icon sets' (MingCute: /icons/<name>_<color>.svg, Tabler: /icons/tabler/<name>_<color>.svg; src/shared/emoji/data/icons.json lists the names of each)${sa(Oi(r))}`):n.push(`line ${c}: an icon (.doc-icon) holds no icon (it holds ${d}): ${ea}`)}return[...new Set(n)]}function Ro(t){let e=w(t.html),s={...t,tree:e,uses:X(t.html,new Set([...q,...Ut]),{tree:e})};return[...Yi(s),...Lt(t.html,e),...Xi(s),...na(s),...Io(s)]}function ia(t){let e=new Map(t.map(n=>[n.slug,[...Ro(n),...Nt(n.html)]])),s=new Map(t.map(n=>[N.resolve(n.htmlPath),n.slug])),o=new Map(t.map(n=>[N.resolve(n.htmlPath),n]));for(let n of t)n.scriptNotes=[];if(t.length>0)for(let{htmlPath:n,text:i,typeOnly:a,note:c}of be(t)){if(a){o.get(n)?.scriptNotes.push(c);continue}let l=n?[s.get(n)]:[...e.keys()];for(let r of l)e.get(r).push(n?i:`${i} (shared SDK declaration)`)}for(let[n,i]of e)i.length===0&&e.delete(n);return e}async function Rc(t=[],{prepare:e=null}={}){let{reports:s,failures:o}=await pt(t,{prepare:e});for(let n of s){let i=[...Ro(n),...Nt(n.html)];i.length&&o.set(n.slug,i)}return o}async function aa(t=[],{prepare:e=null,directory:s=A}={}){let{reports:o,failures:n}=await pt(t,{prepare:e,directory:s});for(let[i,a]of ia(o))n.set(i,a);return{reports:o,failures:n}}async function ra({fresh:t=!1,kit:e=Ci,vendor:s=Ii}={}){if(zi)return;let o=K.map(a=>[a,a.file?It(a.file,{fresh:t}):wt(a)]);await S.mkdir(e,{recursive:!0});let n=N.join(s,"katex","fonts");await S.mkdir(n,{recursive:!0});let i=(await S.readdir($t)).filter(a=>a.endsWith(".woff2"));await Promise.all(i.map(a=>S.copyFile(N.join($t,a),N.join(n,a)))),await Promise.all(o.map(async([a,c])=>S.writeFile(a.file?N.join(e,a.file):N.join(s,...a.vendor.path.split("/").slice(2)),await c)))}async function ca(t,e){let s=await S.readdir(t).catch(()=>[]);await Promise.all(s.filter(o=>o.endsWith(".html")&&!e.has(o.slice(0,-5))).map(o=>S.rm(N.join(t,o),{force:!0})))}async function la(t,e){let s=N.join(e,"reports.json"),o=await S.readFile(s,"utf8").then(JSON.parse,()=>[]),n=new Map(Array.isArray(o)?o.map(a=>[a.slug,a]):[]);for(let{entry:a}of t)n.set(a.slug,a);let i=[];for(let[a,c]of[...n].sort(([l],[r])=>l.localeCompare(r))){let l=N.join(e,`${a}.html`);await S.stat(l).then(()=>!0,()=>!1)&&i.push(c)}await S.writeFile(s,`${JSON.stringify(i,null,2)}
9
+ `)}async function da(t=[],{prepare:e=null,directory:s=A}={}){let o=Ao(s).built,{reports:n,failures:i}=await aa(t,{prepare:e,directory:s});await ra(),await S.mkdir(o,{recursive:!0}),await ca(o,new Set(await Wi(s)));let a=[];for(let c of n){let l=`${c.slug}.html`,r=N.join(o,l);if(i.has(c.slug)){await S.rm(r,{force:!0});continue}let{html:d,removed:f}=Mt(c.html,{slug:c.slug,reportsDirectory:s});await S.writeFile(r,d),a.push({report:c,html:d,removed:f,entry:{slug:c.slug,...c.metadata,preview:`/generated/${l}`,sourceSha256:ut(c.html),outputSha256:ut(d)}})}return await la(a,o),{built:a,failures:i}}var fa=t=>t.replace(/<\/script/gi,"<\\/script");async function Fo(){return new Map(await Promise.all(K.map(async t=>{let e=await(t.file?It(t.file):wt(t,{inline:!0}));return de(t).endsWith(".css")||(e=fa(e)),[t.id,t.umd?Ki(e):e]})))}function ha(t,e,s=null,o=[]){let n=Co(w(e));if(n===void 0)throw new Error(`${t}: the page writes no <head> start tag, which the export's Content-Security-Policy goes right after`);let i=s?`
10
+ ${Ji(s)}${o.length>0?`
11
+ ${Gi(o)}`:""}`:"";return`${e.slice(0,n)}
12
+ <meta name="generator" content="${Hi}">
13
+ <meta http-equiv="Content-Security-Policy" content="${Bi}">${i}${e.slice(n)}`}function Do(t,e,s,o=null,n=T(),i=A,a=null){let c=L(e,n);e=ao(ha(t,e,o,c),{slug:t,packages:c,root:i,workspace:a}),e=me(xe(e,n),({id:d,element:f,attribute:h})=>{let u=s.get(d);if(typeof u!="string")throw new Error(`${t}: no inline source for the asset "${d}" (loadInlineSources in src/render/pipeline.mjs)`);return`<${f} ${h}="${d}-inline">${u}</${f}>`});let{scripts:l,styles:r}=zo(w(e));if(l.length+r.length>0)throw new Error(`${t}: export still contains a linked script or stylesheet`);return e}async function Eo(t,e=A,{components:s=!0,catalog:o=T()}={}){let n=B(t,e),i=await S.readFile(Wt(n).html),a=i.toString("utf8"),c=w(a);s||(o={packages:new Map});let l=[...s?Lt(a,c,o):[],...Io({slug:t,html:a,directory:n,tree:c,catalog:o})];if(l.length>0){let r=L(a,o,c).find(({id:d})=>l[0].startsWith(`${d}:`)||l[0].startsWith(`${d} (`))?.id;throw Object.assign(new Error(`${t}: ${l[0]}`),{reason:"check",slug:t,failures:l,...r?{component:r}:{}})}return{html:a,sha256:ut(i)}}async function Fc({directory:t=A,workspace:e=null,catalog:s=T()}={}){let o=await Fo(),n=async(i,{files:a=!0}={})=>{let c=await Eo(i,t,{catalog:s}),l=Mt(c.html,{slug:i,files:a,reportsDirectory:t,catalog:s}).html;return Do(i,l,o,c.sha256,s,t,await _o(e,i,l,s))};return n.check=async i=>{await Eo(i,t,{components:!1})},n}async function _o(t,e,s,o){return typeof t!="function"||!Rt(L(s,o))?null:await t(e).catch(()=>null)??null}async function Dc(t=[],{prepare:e=null,workspace:s=null,directory:o=A}={}){let n=Ao(o).exports,i=T(),{built:a,failures:c}=await da(t,{prepare:e,directory:o}),l=await Fo();await S.mkdir(n,{recursive:!0});let r=new Set(a.map(({report:h})=>h.slug)),{links:d}=await Ui(o),f=[];for(let{report:h,html:u}of a)try{let m=lo(u,h.slug,g=>r.has(g)?`${g}.html`:null,{links:d}),p=Do(h.slug,m,l,h.fileSha256,i,o,await _o(s,h.slug,m,i));await S.writeFile(N.join(n,`${h.slug}.html`),p),f.push({slug:h.slug,bytes:Buffer.byteLength(p),sha256:ut(p)})}catch(m){c.set(h.slug,[m.message])}return{built:a,exported:f,failures:c}}function To(t){let e=new Set;return M(t,s=>{for(let o of["id","data-block-id"])O(s,o)!==void 0&&e.add(O(s,o))}),e}function ua(t,e,s){if(Lo(t)||/^(?:[a-z][a-z0-9+.-]*:|\/)/i.test(t)||ji(t))return!1;let{pathname:o}=new URL(e);return!o.startsWith(`/${s}/`)||o.endsWith(".html")}function pa({slug:t,tree:e,directory:s}){let o=[],n=To(e),i=s===B(N.basename(s),A)?A:N.dirname(s),a=new Map([[t,n]]),c=d=>{if(!a.has(d)){let f=Wt(B(d,i));a.set(d,bo(f.html)?To(w(ki(f.html,"utf8"))):null)}return a.get(d)},l=null,r=(d,f)=>f===null?_i(d):Di(f,l??=Pi((bo(i)?yi(i):[]).map(h=>({slug:h}))));return M(e,d=>{let f=d.tagName==="a"?O(d,"href"):void 0;if(!f||f==="#"||f==="#top")return;let h=d.sourceCodeLocation?.startLine;if(f.startsWith("#")){n.has(Ri(f.slice(1)))||o.push(`the link to ${f} (line ${h}) names no block or element of this document`);return}let u=Fi(f,t),m=Mi(u),p=r(u,m);(p?!c(p.slug):m!==null)?Lo(f)||o.push(`the link to ${f} (line ${h}) names a document that is not there: gallery list has the slugs`):p?.block&&!c(p.slug).has(p.block)?o.push(`the link to ${f} (line ${h}) names a block document ${p.slug} does not hold`):u&&!p&&ua(f,u,t)&&o.push(`the link to ${f} (line ${h}) leads to no document: a link to one is ../<slug>/doc.html, gallery list has the slugs`)},xi),o}function Mo({slug:t,html:e,directory:s=B(t,A),written:o=e,scriptNotes:n=[]}){let i=w(e),a=Ae(e);return{fix:[...no(e,i),...uo({html:e,directory:s,tree:i})],notes:[...Xe(e,{written:o}),...Ue(i),...pa({slug:t,tree:i,directory:s}),...a.notes,...n],readings:a.readings}}function _c(t){let{fix:e,notes:s}=Mo(t);return[...e,...s]}function Mc(t){let e=t.map(s=>[s.slug,Mo(s)]);for(let[s,{fix:o}]of e)for(let n of o)console.log(`fix ${s}: ${n}`);for(let[s,{notes:o}]of e)for(let n of o)console.log(`note ${s}: ${n}`);for(let[s,{readings:o}]of e)for(let n of o)console.log(`chart ${s}: ${n}`)}async function ma(t,{exportNote:e=!1}={}){for(let[s,o]of t){console.error(`
14
+ FAIL ${s}: ${o.length} problem${o.length===1?"":"s"}`);for(let i of o)console.error(` - ${i}`);let n=N.join(Ai,`${s}.html`);e&&await S.stat(n).then(()=>!0,()=>!1)&&console.error(` ${n} was not updated; it still holds an earlier export.`)}}function ga(t,{above:e=!1,allow:s=process.argv.includes("--allow-failures")}={}){t.size!==0&&(console.error(`
15
+ ${t.size} document${t.size===1?"":"s"} failed: ${[...t.keys()].join(", ")}${e?" (the failures are listed first, above)":""}`),s||(process.exitCode=1))}async function Pc(t,{exportNote:e=!1,allow:s}={}){await ma(t,{exportNote:e}),ga(t,{allow:s})}export{Es as a,_n as b,lo as c,$o as d,Mt as e,bi as f,Vi as g,Io as h,Ro as i,ia as j,Rc as k,aa as l,ra as m,da as n,ha as o,Fc as p,Dc as q,Mo as r,_c as s,Mc as t,ma as u,ga as v,Pc as w};
@@ -1,2 +1,2 @@
1
1
  import { createRequire as __galleryRequire } from "node:module"; import { fileURLToPath as __galleryPath } from "node:url"; const require = __galleryRequire(import.meta.url); const __filename = __galleryPath(import.meta.url); const __dirname = __galleryPath(new URL(".", import.meta.url));
2
- import{a,b}from"./chunk-CCSGFCLZ.mjs";import"./chunk-5MMN3N5J.mjs";import"./chunk-EKGYYOSP.mjs";import"./chunk-5L7RYZCL.mjs";export{a as DEFAULT_KEEP_ALIVE_INTERVAL_MS,b as NodeWebSocketTransport};
2
+ import{a,b}from"./chunk-U3SSPL4K.mjs";import"./chunk-YEY3RSFQ.mjs";import"./chunk-W7XHE4CT.mjs";import"./chunk-5L7RYZCL.mjs";export{a as DEFAULT_KEEP_ALIVE_INTERVAL_MS,b as NodeWebSocketTransport};
@@ -1,2 +1,2 @@
1
1
  import { createRequire as __galleryRequire } from "node:module"; import { fileURLToPath as __galleryPath } from "node:url"; const require = __galleryRequire(import.meta.url); const __filename = __galleryPath(import.meta.url); const __dirname = __galleryPath(new URL(".", import.meta.url));
2
- import{$ as ha,A as I,B as J,C as K,D as L,E as M,F as N,G as O,H as P,I as Q,J as R,K as S,L as T,M as U,N as V,O as W,P as X,Q as Y,R as Z,S as _,T as $,U as aa,V as ba,W as ca,X as da,Y as ea,Z as fa,_ as ga,a as i,aa as ia,b as j,ba as ja,c as k,ca as ka,d as l,e as m,f as n,g as o,h as p,i as q,j as r,k as s,l as t,m as u,n as v,o as w,p as x,q as y,r as z,s as A,t as B,u as C,v as D,w as E,x as F,y as G,z as H}from"./chunk-4DNHHJSL.mjs";import"./chunk-342HXE3Q.mjs";import"./chunk-3A5I2GJK.mjs";import"./chunk-XQRUG4G3.mjs";import"./chunk-4AMTKWDO.mjs";import{a,b,c,f as d,g as e,h as f,k as g,l as h}from"./chunk-FCK6NXON.mjs";import"./chunk-OU3S466R.mjs";import"./chunk-QK3VISCA.mjs";import"./chunk-F4ZA6JRZ.mjs";import"./chunk-7M2BQQGZ.mjs";import"./chunk-TOE6DPLH.mjs";import"./chunk-WTEGUPFG.mjs";import"./chunk-4OZWXZE5.mjs";import"./chunk-XMKHCUI6.mjs";import"./chunk-SAHS56QM.mjs";import"./chunk-KH24LWAT.mjs";import"./chunk-YFJU3O7G.mjs";import"./chunk-NWRZXELO.mjs";import"./chunk-G4YP7GVC.mjs";import"./chunk-DHB7UZ7F.mjs";import"./chunk-2RKIHJI2.mjs";import"./chunk-JXLSHVJ2.mjs";import"./chunk-XKOHV4H6.mjs";import"./chunk-KFZBYDIS.mjs";import"./chunk-7XDYK3UC.mjs";import"./chunk-VG5JEIUQ.mjs";import"./chunk-N3DSBH5S.mjs";import"./chunk-5L7RYZCL.mjs";export{_ as ADVICE,t as BLOCK_PICTURES,$ as CODE_SIDEWAYS,X as HAND_OVER,u as INK_MARGIN,i as KINDS,j as LEVELS,k as LOOKS,Y as LOOK_YOURSELF,W as MORE_PICTURES,M as MOSTLY_CHANGED,y as MOVED_PART,x as MOVED_WHOLE,w as NEIGHBOUR_EDGE,p as PICTURED_INFO,ca as SCROLLS,v as SCROLL_FRAMES,s as SCROLL_SLACK,ba as WARNED,l as WIDE,m as WIDTHS,f as adoptIdless,aa as adviceOf,e as baselineOf,L as baselineSaid,b as blocksOf,N as blocksToPicture,da as describeLooks,S as disclosuresSaid,g as exportBaselines,G as exportOf,ga as exportingFirst,Q as findingKey,q as findingLevel,O as inkOf,P as inventory,n as layoutNotesOf,o as levelOf,R as lookAt,J as missedWidths,V as morePictures,H as movedBlocks,z as movedClips,ha as namedBlocks,I as nextBaseline,ea as notPicturedLine,c as pageOf,r as picturedAt,T as picturesSaid,D as placeOf,h as previewBaseline,a as rankOf,d as readBaseline,ka as run,K as seenOf,C as sourceIndex,F as staleExport,Z as startFailure,E as timeOf,ia as unknownBlocks,ja as unknownBlocksSaid,U as unopenedSaid,A as urlName,fa as verdictOf,B as wordsOf};
2
+ import{$ as ha,A as I,B as J,C as K,D as L,E as M,F as N,G as O,H as P,I as Q,J as R,K as S,L as T,M as U,N as V,O as W,P as X,Q as Y,R as Z,S as _,T as $,U as aa,V as ba,W as ca,X as da,Y as ea,Z as fa,_ as ga,a as i,aa as ia,b as j,ba as ja,c as k,ca as ka,d as l,e as m,f as n,g as o,h as p,i as q,j as r,k as s,l as t,m as u,n as v,o as w,p as x,q as y,r as z,s as A,t as B,u as C,v as D,w as E,x as F,y as G,z as H}from"./chunk-MKIBJTJZ.mjs";import"./chunk-342HXE3Q.mjs";import"./chunk-2KAVXMKG.mjs";import"./chunk-XZCFPKGO.mjs";import"./chunk-PUOQ65NC.mjs";import{a,b,c,f as d,g as e,h as f,k as g,l as h}from"./chunk-6Q7ASAXJ.mjs";import"./chunk-S3SX3COT.mjs";import"./chunk-IA4PSIMD.mjs";import"./chunk-F4ZA6JRZ.mjs";import"./chunk-7M2BQQGZ.mjs";import"./chunk-6NLXUKAY.mjs";import"./chunk-VRPVVMRB.mjs";import"./chunk-4OZWXZE5.mjs";import"./chunk-USIHBCSW.mjs";import"./chunk-3SKOU6OZ.mjs";import"./chunk-ZTHICSSF.mjs";import"./chunk-PLB7L22J.mjs";import"./chunk-PAREWQGB.mjs";import"./chunk-BFJGHSQN.mjs";import"./chunk-U5XL7D6A.mjs";import"./chunk-HYMEEXKN.mjs";import"./chunk-UMHUSOPJ.mjs";import"./chunk-W5NPH5UA.mjs";import"./chunk-ECZBLQKK.mjs";import"./chunk-E7656LR7.mjs";import"./chunk-TKWEX4FD.mjs";import"./chunk-A55HN5OK.mjs";import"./chunk-5L7RYZCL.mjs";export{_ as ADVICE,t as BLOCK_PICTURES,$ as CODE_SIDEWAYS,X as HAND_OVER,u as INK_MARGIN,i as KINDS,j as LEVELS,k as LOOKS,Y as LOOK_YOURSELF,W as MORE_PICTURES,M as MOSTLY_CHANGED,y as MOVED_PART,x as MOVED_WHOLE,w as NEIGHBOUR_EDGE,p as PICTURED_INFO,ca as SCROLLS,v as SCROLL_FRAMES,s as SCROLL_SLACK,ba as WARNED,l as WIDE,m as WIDTHS,f as adoptIdless,aa as adviceOf,e as baselineOf,L as baselineSaid,b as blocksOf,N as blocksToPicture,da as describeLooks,S as disclosuresSaid,g as exportBaselines,G as exportOf,ga as exportingFirst,Q as findingKey,q as findingLevel,O as inkOf,P as inventory,n as layoutNotesOf,o as levelOf,R as lookAt,J as missedWidths,V as morePictures,H as movedBlocks,z as movedClips,ha as namedBlocks,I as nextBaseline,ea as notPicturedLine,c as pageOf,r as picturedAt,T as picturesSaid,D as placeOf,h as previewBaseline,a as rankOf,d as readBaseline,ka as run,K as seenOf,C as sourceIndex,F as staleExport,Z as startFailure,E as timeOf,ia as unknownBlocks,ja as unknownBlocksSaid,U as unopenedSaid,A as urlName,fa as verdictOf,B as wordsOf};
@@ -1,5 +1,5 @@
1
1
  import { createRequire as __galleryRequire } from "node:module"; import { fileURLToPath as __galleryPath } from "node:url"; const require = __galleryRequire(import.meta.url); const __filename = __galleryPath(import.meta.url); const __dirname = __galleryPath(new URL(".", import.meta.url));
2
- import{a as We}from"./chunk-JXLSHVJ2.mjs";import{d as Ue,e as Vt,g as Xt,j as ze,k as qe,l as Je,m as Zt}from"./chunk-KFZBYDIS.mjs";import{B as Pe,c as lt,d as Ke,q as St,r as He,y as Jt,z as ft}from"./chunk-7XDYK3UC.mjs";import{b as rt,e as fn}from"./chunk-N3DSBH5S.mjs";fn();import dn from"node:path";import{attr as w,curlyQuoted as un}from"../browser/shared/html-tree.mjs";import{FOLDED_LINES as Ve,LINE_START as Xe,NOWRAP as Qt,lineStart as mn,validFolded as hn}from"../browser/shared/code-lines.mjs";import{COLORS as gn}from"../browser/shared/colors.mjs";import{FLOWS as pn,instanceSlots as at,isInstance as it,isSlot as fs,matchesNode as pt}from"../browser/shared/components/index.mjs";import{HEADED as dt}from"../browser/shared/components/dialog.mjs";import{pageLanguage as Nn}from"../browser/shared/components/page.mjs";import{SHEETS_LABEL as Ze,shortSheets as On}from"../browser/shared/components/sheets.mjs";import{iconMarkup as Qe,iconValueOf as ds}from"../browser/shared/emoji/icon-value.mjs";import{escapeText as mt}from"../browser/shared/escape.mjs";import{COLUMN_GAP as $n,READING_WIDTH as Tt,SPAN as Ye,SPAN_SIZE as ut}from"../browser/shared/media.mjs";import{kitNamespace as us}from"../browser/shared/old-names.mjs";import{CHART_DATA as wn,CHART_SOURCE as tt,TABLE_READERS as bn,nextChartKey as kn}from"../browser/shared/table-chart.mjs";import{ALIGNS as Yt}from"../browser/editor/components/align.mjs";import{BLOCK_COLORS as ie}from"../browser/editor/components/colors.mjs";import{DETAILS as Ln,DIALOG as ee,PAGE as ms,SECTION as yn,SHEETS as vn}from"../browser/editor/components/kit.mjs";import{DIALOG_TRIGGER as Cn}from"../browser/editor/components/dialog/index.mjs";import{CHECKED as ce,FLOW as ht,TODO as se}from"../browser/editor/components/list/index.mjs";import{texSource as xn}from"../browser/editor/components/math/index.mjs";import{BOX_CLASSES as hs,HOLDS_ONE as Sn,UNIT_KINDS as Tn}from"../browser/editor/components/registry.mjs";import{HEADER_LOOK as ts}from"../browser/editor/components/table/index.mjs";import{backgroundColor as En,parseColor as An,textColor as In}from"../browser/editor/page/clipboard/import/colors.mjs";var re=new Set(["script","style","template","textarea","noscript","code","svg","math","select","option","button","iframe","video","audio","canvas","object","picture"]),jt=["doc-figure","doc-code","doc-diff","doc-math-inline","doc-math-block","doc-link-mention","doc-sheet-tabs","doc-state-fields","doc-filter-row","doc-image","doc-file","doc-bookmark","doc-embed","doc-icon","doc-title","doc-table-meta"],le=new Set(["p","h1","h2","h3","h4","h5","h6","li","td","th","dt","dd","blockquote","figcaption","caption","summary"]),Et=new Set(["main","section","div","article","aside","blockquote","li","details","dialog"]),_n=new Set(gn.map(({name:e})=>e)),C=e=>(w(e,"class")??"").split(/\s+/).filter(Boolean),es=e=>C(e).every(n=>ie.includes(n)),jn=ie.filter(e=>e.startsWith("doc-highlight-")),ct=e=>C(e).some(n=>!us(n)),D=e=>e.nodeName==="#text",Bt=/^[\s\u200b-\u200d\u2060\ufeff]*$/,V=e=>D(e)&&Bt.test(e.value),y=e=>(e.childNodes??[]).filter(n=>n.tagName),Z=e=>(e.attrs??[]).map(n=>n.name),F=(e,n)=>Z(e).every(f=>n.includes(f)),Bn=[yn.match,Ln.match,ee.match,vn.match,"table.doc-table"].join(", ");function gs(e){let n=C(e);return n.some(f=>jt.includes(f))||Ke(e)||pt(e,Bn)||hs.some(([f])=>n.includes(f))||Tn.some(f=>f.class&&n.includes(f.class)&&(!f.tag||[f.tag].flat().includes(e.tagName)))}var Mn=e=>{for(let n=e.parentNode;n?.tagName&&n.tagName!=="main";n=n.parentNode)if(n.tagName==="figure")return!0;return!1},ps=new Set(["thead","tbody","tfoot","tr","colgroup","col"]),fe=e=>ct(e)&&e.tagName!=="figure"&&!le.has(e.tagName)&&!ps.has(e.tagName)&&!gs(e),Ns=new Set([...lt].filter(e=>!["header","main","dialog","form","fieldset","caption","dd","dt","figcaption","summary","li","td","th",...ps].includes(e))),Rn=/\\\(([\s\S]*?)\\\)/g,wt=e=>xn(e)&&/\S/.test(e);function Dn(e,n=!0){let f=n?e:/^\s*(?:\\\[[\s\S]*?\\\]|\$\$[\s\S]*?\$\$)/.exec(e)?.[0]??"";return/[<>]/.test(f)&&wt(f.replace(/</g,"\\lt ").replace(/>/g,"\\gt "))}var ne=new Set(["br","wbr","img","input"]),Os=new Set([...lt,"script","style","template","noscript","link","meta"]),$s=new Set(["input","select","textarea","button","label","option"]),Gn=new Set([...lt,"hgroup","search","center","dir","listing","xmp","plaintext"]),oe=e=>y(e).some(n=>Gn.has(n.tagName)||oe(n)),ws=new Set(["main","section","div","article","aside","blockquote"]),Fn=pn.join(", "),bs=e=>ws.has(e.tagName)&&!ct(e)&&(C(e).length===0||pt(e,Fn))||fs(e),et=e=>D(e)?!Bt.test(e.value):(e.childNodes??[]).some(et),Kn=hs.filter(([,e])=>Sn.has(e)).map(([e])=>e),Hn=e=>bs(e)&&C(e).some(n=>Kn.includes(n)),ks=e=>e.childNodes.some(n=>D(n)&&!Bt.test(n.value))&&y(e).some(n=>lt.has(n.tagName)),Pn=/^[ \t\n\r\f]*/;function te(e){let n=[],f=[];for(let u of e)u.tagName&&Os.has(u.tagName)?(n.push(f),f=[]):f.push(u);n.push(f);let p=u=>!u.tagName&&!et(u),O=u=>(D(u)||u.tagName&&!$s.has(u.tagName))&&et(u);return n.map(u=>{let $=u.findIndex(m=>!p(m));return $<0?[]:u.slice($,u.findLastIndex(m=>!p(m))+1)}).filter(u=>u.some(O))}function Wn(e){let n=[],f=p=>{for(let O of p.childNodes??[])O.tagName==="style"?n.push(O.childNodes.map(u=>u.value??"").join("")):O.tagName&&O.tagName!=="template"&&f(O)};return f(e),n.flatMap(p=>[...p.replace(/\/\*[\s\S]*?(?:\*\/|$)/g," ").matchAll(/([^{};]*)\{/g)].map(([,O])=>O))}var Un=(e,{tags:n=[],classes:f=[]})=>{let p=[...n.map(u=>`(?<![\\w.#-])${u}`),...f.map(u=>`\\.${u}`)],O=p.length?new RegExp(`(?:${p.join("|")})(?![\\w-])`,"i"):null;return!!O&&e.some(u=>O.test(u))};function zn(e){let n=[],f=p=>{for(let O of p.childNodes??[])O.tagName==="script"?n.push(O.childNodes.map(u=>u.value??"").join("")):O.tagName&&O.tagName!=="template"&&f(O)};return f(e),n.join(`
2
+ import{a as We}from"./chunk-UMHUSOPJ.mjs";import{d as Ue,e as Vt,g as Xt,j as ze,k as qe,l as Je,m as Zt}from"./chunk-ECZBLQKK.mjs";import{B as Pe,c as lt,d as Ke,q as St,r as He,y as Jt,z as ft}from"./chunk-E7656LR7.mjs";import{b as rt,e as fn}from"./chunk-A55HN5OK.mjs";fn();import dn from"node:path";import{attr as w,curlyQuoted as un}from"../browser/shared/html-tree.mjs";import{FOLDED_LINES as Ve,LINE_START as Xe,NOWRAP as Qt,lineStart as mn,validFolded as hn}from"../browser/shared/code-lines.mjs";import{COLORS as gn}from"../browser/shared/colors.mjs";import{FLOWS as pn,instanceSlots as at,isInstance as it,isSlot as fs,matchesNode as pt}from"../browser/shared/components/index.mjs";import{HEADED as dt}from"../browser/shared/components/dialog.mjs";import{pageLanguage as Nn}from"../browser/shared/components/page.mjs";import{SHEETS_LABEL as Ze,shortSheets as On}from"../browser/shared/components/sheets.mjs";import{iconMarkup as Qe,iconValueOf as ds}from"../browser/shared/emoji/icon-value.mjs";import{escapeText as mt}from"../browser/shared/escape.mjs";import{COLUMN_GAP as $n,READING_WIDTH as Tt,SPAN as Ye,SPAN_SIZE as ut}from"../browser/shared/media.mjs";import{kitNamespace as us}from"../browser/shared/old-names.mjs";import{CHART_DATA as wn,CHART_SOURCE as tt,TABLE_READERS as bn,nextChartKey as kn}from"../browser/shared/table-chart.mjs";import{ALIGNS as Yt}from"../browser/editor/components/align.mjs";import{BLOCK_COLORS as ie}from"../browser/editor/components/colors.mjs";import{DETAILS as Ln,DIALOG as ee,PAGE as ms,SECTION as yn,SHEETS as vn}from"../browser/editor/components/kit.mjs";import{DIALOG_TRIGGER as Cn}from"../browser/editor/components/dialog/index.mjs";import{CHECKED as ce,FLOW as ht,TODO as se}from"../browser/editor/components/list/index.mjs";import{texSource as xn}from"../browser/editor/components/math/index.mjs";import{BOX_CLASSES as hs,HOLDS_ONE as Sn,UNIT_KINDS as Tn}from"../browser/editor/components/registry.mjs";import{HEADER_LOOK as ts}from"../browser/editor/components/table/index.mjs";import{backgroundColor as En,parseColor as An,textColor as In}from"../browser/editor/page/clipboard/import/colors.mjs";var re=new Set(["script","style","template","textarea","noscript","code","svg","math","select","option","button","iframe","video","audio","canvas","object","picture"]),jt=["doc-figure","doc-code","doc-diff","doc-math-inline","doc-math-block","doc-link-mention","doc-sheet-tabs","doc-state-fields","doc-filter-row","doc-image","doc-file","doc-bookmark","doc-embed","doc-icon","doc-title","doc-table-meta"],le=new Set(["p","h1","h2","h3","h4","h5","h6","li","td","th","dt","dd","blockquote","figcaption","caption","summary"]),Et=new Set(["main","section","div","article","aside","blockquote","li","details","dialog"]),_n=new Set(gn.map(({name:e})=>e)),C=e=>(w(e,"class")??"").split(/\s+/).filter(Boolean),es=e=>C(e).every(n=>ie.includes(n)),jn=ie.filter(e=>e.startsWith("doc-highlight-")),ct=e=>C(e).some(n=>!us(n)),D=e=>e.nodeName==="#text",Bt=/^[\s\u200b-\u200d\u2060\ufeff]*$/,V=e=>D(e)&&Bt.test(e.value),y=e=>(e.childNodes??[]).filter(n=>n.tagName),Z=e=>(e.attrs??[]).map(n=>n.name),F=(e,n)=>Z(e).every(f=>n.includes(f)),Bn=[yn.match,Ln.match,ee.match,vn.match,"table.doc-table"].join(", ");function gs(e){let n=C(e);return n.some(f=>jt.includes(f))||Ke(e)||pt(e,Bn)||hs.some(([f])=>n.includes(f))||Tn.some(f=>f.class&&n.includes(f.class)&&(!f.tag||[f.tag].flat().includes(e.tagName)))}var Mn=e=>{for(let n=e.parentNode;n?.tagName&&n.tagName!=="main";n=n.parentNode)if(n.tagName==="figure")return!0;return!1},ps=new Set(["thead","tbody","tfoot","tr","colgroup","col"]),fe=e=>ct(e)&&e.tagName!=="figure"&&!le.has(e.tagName)&&!ps.has(e.tagName)&&!gs(e),Ns=new Set([...lt].filter(e=>!["header","main","dialog","form","fieldset","caption","dd","dt","figcaption","summary","li","td","th",...ps].includes(e))),Rn=/\\\(([\s\S]*?)\\\)/g,wt=e=>xn(e)&&/\S/.test(e);function Dn(e,n=!0){let f=n?e:/^\s*(?:\\\[[\s\S]*?\\\]|\$\$[\s\S]*?\$\$)/.exec(e)?.[0]??"";return/[<>]/.test(f)&&wt(f.replace(/</g,"\\lt ").replace(/>/g,"\\gt "))}var ne=new Set(["br","wbr","img","input"]),Os=new Set([...lt,"script","style","template","noscript","link","meta"]),$s=new Set(["input","select","textarea","button","label","option"]),Gn=new Set([...lt,"hgroup","search","center","dir","listing","xmp","plaintext"]),oe=e=>y(e).some(n=>Gn.has(n.tagName)||oe(n)),ws=new Set(["main","section","div","article","aside","blockquote"]),Fn=pn.join(", "),bs=e=>ws.has(e.tagName)&&!ct(e)&&(C(e).length===0||pt(e,Fn))||fs(e),et=e=>D(e)?!Bt.test(e.value):(e.childNodes??[]).some(et),Kn=hs.filter(([,e])=>Sn.has(e)).map(([e])=>e),Hn=e=>bs(e)&&C(e).some(n=>Kn.includes(n)),ks=e=>e.childNodes.some(n=>D(n)&&!Bt.test(n.value))&&y(e).some(n=>lt.has(n.tagName)),Pn=/^[ \t\n\r\f]*/;function te(e){let n=[],f=[];for(let u of e)u.tagName&&Os.has(u.tagName)?(n.push(f),f=[]):f.push(u);n.push(f);let p=u=>!u.tagName&&!et(u),O=u=>(D(u)||u.tagName&&!$s.has(u.tagName))&&et(u);return n.map(u=>{let $=u.findIndex(m=>!p(m));return $<0?[]:u.slice($,u.findLastIndex(m=>!p(m))+1)}).filter(u=>u.some(O))}function Wn(e){let n=[],f=p=>{for(let O of p.childNodes??[])O.tagName==="style"?n.push(O.childNodes.map(u=>u.value??"").join("")):O.tagName&&O.tagName!=="template"&&f(O)};return f(e),n.flatMap(p=>[...p.replace(/\/\*[\s\S]*?(?:\*\/|$)/g," ").matchAll(/([^{};]*)\{/g)].map(([,O])=>O))}var Un=(e,{tags:n=[],classes:f=[]})=>{let p=[...n.map(u=>`(?<![\\w.#-])${u}`),...f.map(u=>`\\.${u}`)],O=p.length?new RegExp(`(?:${p.join("|")})(?![\\w-])`,"i"):null;return!!O&&e.some(u=>O.test(u))};function zn(e){let n=[],f=p=>{for(let O of p.childNodes??[])O.tagName==="script"?n.push(O.childNodes.map(u=>u.value??"").join("")):O.tagName&&O.tagName!=="template"&&f(O)};return f(e),n.join(`
3
3
  `)}var de=["contains-task-list","task-list-item"],ue=["task-list-item"],Ls=["task-list-item-checkbox"],me=(e,n)=>C(e).every(f=>n.includes(f));function ys(e){let n=e.childNodes.find(f=>!V(f));return n?.tagName==="input"&&F(n,["type","checked","disabled","class"])&&w(n,"type")?.toLowerCase()==="checkbox"&&me(n,Ls)&&n.sourceCodeLocation?.startTag?n:null}var vs=e=>e.tagName==="li"&&me(e,ue)&&w(e,ce)===void 0&&e.sourceCodeLocation?.startTag&&ys(e),qn=e=>e.tagName==="ul"&&me(e,de)&&y(e).length>0&&e.childNodes.every(n=>n.tagName==="li"||V(n))&&y(e).every(vs),Jn={classes:[...new Set([...de,...ue,...Ls])]},Vn=/checkbox|task-list/i,ae=e=>e.tagName==="ol"&&(w(e,"data-doc-chart")==="flow"||w(e,"data-flow")!==void 0&&w(e,"data-doc-chart")===void 0),Xn=e=>e?.tagName==="ol"&&!ct(e)&&(C(e).includes(ht)||ae(e)),Zn=e=>e.tagName==="li"&&Xn(e.parentNode),_t="doc-icon",Qn=e=>e.some(n=>n.tagName==="strong"||n.tagName==="b")&&e.every(n=>n.tagName==="strong"||n.tagName==="b"||D(n)&&Bt.test(n.value)||n.nodeName==="#comment"),Yn=/^(?:inherit|unset|currentcolor|none)$/i,to=/^(?:inherit|initial|unset|revert|revert-layer|transparent|none)$/i,P=e=>e.replace(/\s+/g," ").trim(),ss=/^\s*--doc-(?:table-height|span)\s*:/i,eo=/^(?:p|h[1-4])$/,so=/^(center|right)$/i;function It(e){let n=e.replace(/\/\*[\s\S]*?(?:\*\/|$)/g," "),f=[],p="",O=0,u=0;for(let $=0;$<=n.length;$++){let m=n[$];p?m==="\\"?$++:m===p&&(p=""):m==='"'||m==="'"?p=m:m==="("?O++:m===")"?O=Math.max(0,O-1):(m===";"&&O===0||$===n.length)&&(f.push(n.slice(u,$)),u=$+1)}return f.filter($=>$.trim())}function Cs(e){let n=new Map;for(let r of It(e)){let N=r.indexOf(":"),i=P(N<0?r:r.slice(0,N)).toLowerCase();n.set(i==="background-color"?"background":i,N<0?"":P(r.slice(N+1).replace(/!\s*important\s*$/i,"")))}let f=[],p=[],O,u,$=new Set,m=(r,N,i)=>{if((r==="color"?Yn:to).test(N))return;let d=An(N);if(!d||d.a===0&&r==="color"){f.push(r);return}if(d.a===0)return;let g=i(N,{nearest:!0})?.replace(/_background$/,"");if(!g||!_n.has(g)){p.push(`${r} ${N} left out: the ${r==="color"?"text's":"page's"} own is the nearest`);return}return i(N)?.replace(/_background$/,"")!==g&&p.push(`${r} ${N} written as the kit's ${g}${r==="color"?"":" highlight"}`),g};for(let[r,N]of n)r==="color"?O=m(r,N,In):r==="background"?u=m(r,N,En):r==="font-weight"&&/^(?:bold|bolder|[6-9]\d\d)$/i.test(N)?$.add("strong"):r==="font-style"&&/^(?:italic|oblique)\b/i.test(N)?$.add("em"):(r==="text-decoration"||r==="text-decoration-line")&&/^(?:(?:underline|line-through|solid)\s*)+$/i.test(N)&&/underline|line-through/i.test(N)?(/underline/i.test(N)&&$.add("u"),/line-through/i.test(N)&&$.add("s")):f.push(r);if(f.length)return{foreign:[...new Set(f)]};let v=[];O&&v.push([`<span class="doc-text-${O}">`,"</span>"]),u&&v.push([`<span class="doc-highlight-${u}">`,"</span>"]);for(let r of["strong","em","u","s"])$.has(r)&&v.push([`<${r}>`,`</${r}>`]);return{open:v.map(([r])=>r).join(""),close:v.map(([,r])=>r).reverse().join(""),notes:p}}var ns=/^(?:language|lang)-([\w#+.-]+)$/,no=new Set(["data-language","data-lang","data-block-id"]),oo=[{name:Xe,names:[Xe,"data-start"],value:e=>mn(e)?.toString()??null,says:"the number of its first line is a whole number from 1"},{name:"data-line-numbers",names:["data-line-numbers"],value:e=>/^\s*(?:true|false)\s*$/i.test(e)?e.trim().toLowerCase():null,says:"false hides its line numbers, true shows them"},{name:Ve,names:[Ve],value:e=>hn(P(e))?P(e):null,says:"its folded lines are their numbers from 1, spaces between"}],os="data-title",as="data-wrap",ao=e=>y(e).length===1&&y(e)[0].tagName==="code"&&e.childNodes.every(n=>n.tagName||V(n))?y(e)[0]:null,io=new Set(["a","abbr","b","bdi","bdo","cite","code","data","del","dfn","em","font","i","ins","kbd","mark","q","s","samp","small","span","strike","strong","sub","sup","time","tt","u","var","br","wbr"]),co=new Set(["code","kbd","samp","tt","var"]);function xs(e){for(let n of e.childNodes){if(D(n))continue;if(!n.tagName)return"a comment in its <figcaption>";if(["img","picture","svg"].includes(n.tagName))return"a picture in its <figcaption>";if(!io.has(n.tagName))return`a <${n.tagName}> in its <figcaption>`;if(!n.sourceCodeLocation?.startTag||!(n.sourceCodeLocation.endTag||ne.has(n.tagName)))return`a <${n.tagName}> not closed in its <figcaption>`;let f=xs(n);if(f)return f}return""}function is(e){let n=y(e),f=n.filter(v=>v.tagName==="pre"),p=n.filter(v=>v.tagName==="figcaption");if(!f.length)return null;let[O]=f,[u=null]=p,$=e.childNodes.find(v=>!v.tagName&&!V(v)),m=f.length>1||p.length>1||n.length>f.length+p.length?"more than the pre and one <figcaption> in its <figure>":$?D($)?"words in its <figure> outside its caption":"a comment in its <figure>":u?Z(u).length?`its <figcaption> has an attribute of its own (${Z(u).join(", ")})`:u.sourceCodeLocation?.endTag?xs(u):"its <figcaption> is not closed in the file":"";return m?{pre:O,caption:u,why:m}:{pre:O,caption:u}}function At(e){let n=(e.attrs??[]).filter(({value:p})=>p.trim()),f=e.tagName==="abbr";return n.map(p=>`${p.name} ${JSON.stringify(P(p.value))} dropped: ${f&&p.name==="title"?"write the full name in the text":"write it in the text if the reader needs it"}`)}var z=e=>e.replace(/&/g,"&amp;").replace(/"/g,"&quot;");function ro(e){let n=new Set,f=p=>{for(let O of p.childNodes??[])if(O.tagName){for(let u of[tt,...bn])w(O,u)!==void 0&&n.add(w(O,u));f(O.tagName==="template"?O.content:O)}};return f(e),n}function lo(e){let n=new Map,f=p=>{for(let O of p.childNodes??[]){if(!O.tagName)continue;let u=w(O,"id");u!==void 0&&n.set(u,(n.get(u)??0)+1),f(O.tagName==="template"?O.content:O)}};return f(e),n}var fo=/^[A-Za-z][\w-]{0,63}$/;function uo(e){let n=We(e),f=rt(n,{sourceCodeLocationInfo:!0}),p=bt(f);if(!p)return{text:n,changes:[]};let O=[],u=[],$=t=>n.slice(0,t).split(`
4
4
  `).length,m=(t,s,o=[],l={})=>{let a=$(t.sourceCodeLocation.startOffset);o.length||u.push({line:a,rule:s,...l});for(let c of o)u.push({line:a,rule:s,note:c,...l})},v=0,r=(t,s,o,{opens:l=null,closes:a=null,move:c=null,leaves:h=!1}={})=>O.push({start:t,end:s,text:o,order:v++,opens:l,closes:a,move:c,leaves:h}),N=(t,s,o,l)=>{r(t,t,o,{opens:s}),r(s,s,l,{closes:t})},i=t=>t.sourceCodeLocation?.startTag,d=t=>t.sourceCodeLocation?.endTag,g=(t,s,{drop:o=[]}={})=>{let l=C(t).filter(h=>!o.includes(h)),a=[...l,...s.filter(h=>!l.includes(h))],c=t.sourceCodeLocation.attrs?.class;if(a.join(" ")!==C(t).join(" "))if(c&&a.length)r(c.startOffset,c.endOffset,`class="${z(a.join(" "))}"`);else if(c)x(t,"class");else{let h=i(t).startOffset+1+t.tagName.length;r(h,h,` class="${z(a.join(" "))}"`)}},x=(t,s)=>{let o=t.sourceCodeLocation.attrs[s],l=o.startOffset;for(;/[ \t\n\r\f]/.test(n[l-1]??"");)l--;r(l,o.endOffset,"")},A=(t,s,{classes:o=[],drop:l=[]}={})=>{let a=t.sourceCodeLocation,c=Object.entries(a.attrs??{}).filter(([L])=>L!=="class"&&!l.includes(L)).map(([,L])=>` ${n.slice(L.startOffset,L.endOffset)}`).join(""),h=[...o,...C(t).filter(L=>!o.includes(L))];return`<${s}${h.length?` class="${z(h.join(" "))}"`:""}${c}>`},M,q=t=>Un(M??=Wn(f),t),Q,Ms=t=>t.test(Q??=zn(f)),K=(t,s,o)=>{r(i(t).startOffset,i(t).endOffset,s),d(t)&&r(d(t).startOffset,d(t).endOffset,o)},Rt=t=>K(t,"",""),W=t=>!!(i(t)&&(d(t)||t.tagName==="img")),ge,pe=t=>{let s=w(t,"id");if(t.tagName!=="dialog"||!F(t,["id"])||!fo.test(s??"")||!W(t))return!1;let o=y(t);return!(o.length?Ns.has(o[0].tagName)&&W(o[0]):t.childNodes.some(a=>!V(a)&&a.nodeName!=="#comment"))||o.some(a=>a.tagName==="form")?!1:(ge??=lo(f),ge.get(s)===1)},Rs=t=>{let s=y(t)[0];return!pt(s,ee.short)||Z(s).length?null:t.childNodes.slice(0,t.childNodes.indexOf(s)).every(V)?s:null},Ne=t=>t.tagName==="dialog"&&(C(t).includes("doc-dialog")||pe(t)),Dt=(t,s=[])=>{for(let o of t.childNodes??[])if(o!==p){if(it(o)){at(o).forEach(l=>Dt(l,s));continue}Ne(o)&&W(o)?s.push(o):Dt(o,s)}return s},Gt=d(p)?Dt(f):[],Oe,Ds=t=>(Oe??=new Set((function s(o,l=[]){for(let a of o.childNodes??[])if(a.tagName){if(it(a)){at(a).forEach(c=>s(c,l));continue}Ne(a)&&l.push(w(a,"id")),s(a,l)}return l})({childNodes:[p,...Gt]})),/^#./.test(t??"")&&Oe.has(t.slice(1))),Gs=t=>{let[s,...o]=y(t);if(!s||o.length||!C(s).includes("doc-dialog-panel"))return null;let[l,a,...c]=y(s);if(c.length||!l||!a||!C(l).includes(dt.header)||!C(a).includes("doc-dialog-content"))return null;let h=T=>T.childNodes.some(_=>!_.tagName&&!V(_)&&_.nodeName!=="#comment");if(h(s)||h(l)||!W(l)||!i(a))return null;let L=y(l),b=L.filter(T=>C(T).includes(dt.title)),S=L.filter(T=>!b.includes(T)),E=T=>(C(T).includes(dt.close)||w(T,dt.closeAttribute)!==void 0)&&W(T);return b.length!==1||!W(b[0])||S.length>1||!S.every(E)?null:{header:l,title:b[0],close:S[0]??null,content:a}},Nt,$e=(t,s=[])=>{for(let o of t.childNodes??[])if(o.tagName){for(let{name:l,value:a}of o.attrs)l!=="id"&&l!=="class"&&s.push(a);(o.tagName==="script"||o.tagName==="style")&&s.push(o.childNodes.map(l=>l.value??"").join("")),$e(o,s)}return s},Fs=(t,s)=>{Nt??=$e(f).join(`
5
5
  `);let o=0;for(let l=Nt.indexOf(t);l>=0;l=Nt.indexOf(t,l+t.length))!/[\w-]/.test(Nt[l-1]??"")&&!/[\w-]/.test(Nt[l+t.length]??"")&&o++;return o>(s?1:0)};function Ks(t){let s=Gs(t);if(!s)return;let{header:o,title:l,close:a,content:c}=s,h=w(l,"id"),L=!!h&&w(t,"aria-labelledby")?.trim()===h;L&&x(t,"aria-labelledby"),r(i(o).startOffset,i(o).endOffset,n.slice(i(c).startOffset,i(c).endOffset));let b=i(l).startOffset+1;r(b,b+l.tagName.length,"h3"),g(l,[],{drop:[dt.title]}),h!==void 0&&!(h&&Fs(h,L))&&x(l,"id"),r(d(l).startOffset,d(l).endOffset,"</h3>"),a&&r(a.sourceCodeLocation.startOffset,a.sourceCodeLocation.endOffset,""),r(d(o).startOffset,d(o).endOffset,""),r(i(c).startOffset,i(c).endOffset,"")}let Ft=t=>{for(let s of t.childNodes??[]){if(it(s)){at(s).forEach(Ft);continue}s.tagName&&pt(s,ee.match)&&Ks(s),Ft(s)}},we=new Set;function be(t){let s=t.tagName;if(!W(t))return!1;let o=[];if(s==="mark"&&F(t,[]))K(t,'<span class="doc-highlight-yellow">',"</span>");else if((s==="del"||s==="strike")&&F(t,["cite","datetime"]))K(t,"<s>","</s>"),o=At(t);else if(s==="ins"&&F(t,["cite","datetime"]))K(t,"<u>","</u>"),o=At(t);else{if(["kbd","samp","tt","var"].includes(s)&&F(t,[]))return K(t,"<code>","</code>"),we.add(t),m(t,s),!0;if(s==="a"&&F(t,["href"])&&Ds(w(t,"href")))return g(t,[Cn]),m(t,"dialog link"),!1;if(s==="small"&&F(t,[]))K(t,'<span class="doc-text-gray">',"</span>");else if(s==="q"&&F(t,["cite"]))K(t,"\u201C","\u201D"),o=At(t);else if(["abbr","cite","dfn","time","bdi","data"].includes(s)&&F(t,["title","datetime","value"]))Rt(t),o=At(t);else if(s==="span"&&F(t,[])||s==="font"&&F(t,["color"])&&!w(t,"color")?.trim())Rt(t);else if(s==="span"&&F(t,["style"])||s==="font"&&F(t,["color"])){let l=Cs(s==="span"?w(t,"style")??"":`color: ${w(t,"color")}`);if(l.foreign)return!1;K(t,l.open,l.close),o=l.notes}else return!1}return we.add(t),m(t,s,o),!1}function Hs(t){let{startOffset:s,endOffset:o}=t.sourceCodeLocation,l=n.slice(s,o);for(let a of l.matchAll(Rn))N(s+a.index,s+a.index+a[0].length,'<span class="doc-math-inline">',"</span>"),u.push({line:$(s+a.index),rule:"formula"})}let Kt=new Set,ke=new Set;function kt(t,s=()=>!1){for(let o of te(t)){if(!o.every(b=>b.tagName?i(b)&&(d(b)||ne.has(b.tagName))&&!oe(b):b.sourceCodeLocation))continue;let l=o[0].sourceCodeLocation.startOffset,a=o.at(-1).sourceCodeLocation.endOffset,c=n.slice(l,a),h=l+Pn.exec(c)[0].length,L=a-/[ \t\n\r\f]*$/.exec(c)[0].length;if(o.every(D)&&wt(n.slice(h,L)))N(h,L,'<div class="doc-math-block">',"</div>"),u.push({line:$(h),rule:"display formula"}),o.forEach(b=>ke.add(b));else if(s(o)){let b=Qn(o);N(h,L,b?"<p>":"<p><strong>",b?"</p>":"</strong></p>"),u.push({line:$(h),rule:"step title",...ye(o[0].parentNode)}),o.forEach(S=>Kt.add(S))}else N(h,L,"<p>","</p>"),u.push({line:$(h),rule:"loose words"}),o.forEach(b=>Kt.add(b))}}let Ps=t=>t[0].parentNode.childNodes.slice(0,t[0].parentNode.childNodes.indexOf(t[0])).every(s=>!s.tagName||C(s).includes(_t)),Le=new Set,ye=t=>Le.has(t.parentNode)?{}:(Le.add(t.parentNode),{note:"a step's own words written as its title, the first block of its node: <li><p><strong>\u2026</strong></p> then its content (a paragraph, a list\u2026)</li>"}),Ws=t=>{if(kt(t.childNodes,Ps),t.childNodes.filter(a=>a.tagName&&!C(a).includes(_t)).length>0||te(t.childNodes).length>0||!i(t)||!d(t))return;let l=t.childNodes.filter(a=>a.tagName).at(-1)?.sourceCodeLocation?.endOffset??i(t).endOffset;r(l,l,"<p></p>"),u.push({line:$(l),rule:"step title",...ye(t)})},Ht,ve=()=>{Ht??=ro(f);let t=kn(Ht);return Ht.add(t),t},Us=(t,s)=>`<div data-doc-chart="${z(w(t,"data-doc-chart"))}" ${wn}="${z(s)}"></div>`,Ot=n.includes(`\r
@@ -0,0 +1,2 @@
1
+ import { createRequire as __galleryRequire } from "node:module"; import { fileURLToPath as __galleryPath } from "node:url"; const require = __galleryRequire(import.meta.url); const __filename = __galleryPath(import.meta.url); const __dirname = __galleryPath(new URL(".", import.meta.url));
2
+ import{a,b}from"./chunk-FFV733MA.mjs";import"./chunk-WFGPMCTZ.mjs";import"./chunk-7UZUQQ7Q.mjs";import"./chunk-4B2TB5K2.mjs";import"./chunk-KLQP46Y3.mjs";import"./chunk-4OZWXZE5.mjs";import"./chunk-E7656LR7.mjs";import"./chunk-TKWEX4FD.mjs";import"./chunk-A55HN5OK.mjs";import"./chunk-5L7RYZCL.mjs";export{a as copiedLines,b as run};
@@ -1,5 +1,5 @@
1
1
  import { createRequire as __galleryRequire } from "node:module"; import { fileURLToPath as __galleryPath } from "node:url"; const require = __galleryRequire(import.meta.url); const __filename = __galleryPath(import.meta.url); const __dirname = __galleryPath(new URL(".", import.meta.url));
2
- import{a as Je,b as Qe,c as ge,e as At,h as Xe,i as tn}from"./chunk-KFZBYDIS.mjs";import{A as Ye,B as We,C as Te,D as Q,E as Ze,a as me,g as Oe,h as He,j as Ne,l as Fe,m as wt,n as ke,o as $e,p as ne,q as Ft,r as De,s as Ve,t as vt,u as Le,v as Ge,w as Me,x as kt,y as G,z as je}from"./chunk-7XDYK3UC.mjs";import{g as Ct}from"./chunk-VG5JEIUQ.mjs";import{b as pe,c as he,e as Ee}from"./chunk-N3DSBH5S.mjs";import{BLOCK_TYPES as Ie,COPIED_AS_ITSELF as Kn,IDENTITY as gn}from"../browser/editor/components/registry.mjs";import{copyKeys as Un}from"../browser/editor/components/figure/index.mjs";import{accepts as xe,attributeValue as An,BLOCK_TYPES as Dt,boxRole as we,CHAPTER as En,holdsStraight as On,IDENTITY as Ke,isLead as rn,SIZES as Nn,sizeValue as ln,TOGGLES as an}from"../browser/editor/components/registry.mjs";import{iconMarkup as $n,iconValueOf as Ln,validIcon as Mn}from"../browser/editor/components/icon/index.mjs";Ee();import{attributeValue as bn,BLOCK_TYPES as en,HOSTS as xn,TOGGLES as wn}from"../browser/editor/components/registry.mjs";import{texSource as nn}from"../browser/editor/components/math/index.mjs";var Ce=new Set(Object.entries(en).filter(([,s])=>!s.box&&!s.bare).map(([s])=>s)),se=(s,m,I="")=>{let k=Q[m.type]?.leaf;if(k)return k(s,m,I);let g=[s.className,...m.classes??[]].filter(Boolean).join(" ");return`<${s.tag}${g?` class="${g}"`:""}${ke(m.attributes)}${I}>${m.html}</${s.tag}>`},Be=(s,m)=>s===void 0||!!s&&typeof s=="object"&&!Array.isArray(s)&&Object.entries(s).every(([I,k])=>typeof k=="string"&&bn(m,I,k)),qe=s=>s?.empty===!0,Pe=(s,m)=>s===void 0?null:I=>s.includes(m.slice(I.startOffset,I.endOffset));function ye(s,m,{empty:I=!1,file:k}={}){if(typeof m!="string"||!m.trim()&&!(I&&m===""))return!1;if(m==="")return!0;if(s.tex&&!nn(m))return!1;let g=s.inside??s.tag,$=`<${g}>${m}</${g}>`,[w,...u]=he($,{sourceCodeLocationInfo:!0}).childNodes;return u.length===0&&w?.tagName===g&&ge(w,[],s.inside!==void 0,{cell:g==="td"||g==="th",known:Pe(k,$)})===null}var vn=new Set(Object.values(en).filter(s=>s.text&&s.className).map(s=>s.kind));function ze(s,m){if(s.keep?.reason==="script")return null;if(s.kind==="list")return m.some(k=>k.unit===s.id&&k.kind==="list")?"list":null;let I=Q[s.kind];return I?.written?I.written(s)?"written":null:s.text===void 0||s.nested?null:["p","h1","h2","h3","h4","li"].includes(s.tag)||vn.has(s.kind)?"text":null}function be(s,m,I){if(!Array.isArray(m)||!m.every(g=>Sn(s,g,I)))return"invalid";let k=m.filter(g=>g.keep);return k.length>1?"invalid":m.length>k.length&&!s.caps.split||k.length===0&&!s.caps.remove||m.length===0&&s.nested?"fixed":k.length===1&&k[0].html.trim()===""&&!s.caps.empty?"empty":null}function sn(s,m,I){let k=`<table><tbody><tr><${s}>${m}</${s}></tr></tbody></table>`,[g,...$]=he(k,{sourceCodeLocationInfo:!0}).childNodes,w=$.length===0&&g?.tagName==="table"&&g.childNodes.length===1?g.childNodes[0]:null,u=w?.childNodes.length===1?w.childNodes[0]:null,h=u?.childNodes.length===1?u.childNodes[0]:null;return h?.tagName===s&&ge(h,[],!1,{cell:!0,known:Pe(I,k)})===null}var on={p:"paragraph",h1:"heading",h2:"heading",h3:"heading",h4:"heading",li:"item"},In=(s,m)=>s.classes===void 0||!s.keep&&Array.isArray(s.classes)&&new Set(s.classes).size===s.classes.length&&s.classes.every(I=>(wn[on[m]]??[]).includes(I));function Sn(s,m,I){if(!m||typeof m.html!="string"||xn[s.kind]?.tex&&!nn(m.html))return!1;let k=m.keep?s.tag:m.tag;if(!m.keep&&Je[s.tag]!==k||!In(m,k)||m.attributes!==void 0&&(m.keep||!Be(m.attributes,on[k])))return!1;let g=k==="td"||k==="th",$=g?`<table><tbody><tr><${k}>${m.html}</${k}></tr></tbody></table>`:`<${k}>${m.html}</${k}>`,[w,...u]=he($,{sourceCodeLocationInfo:!0}).childNodes;if(u.length>0||!w)return!1;let h=w;if(g){let p=w.tagName==="table"&&w.childNodes.length===1?w.childNodes[0]:null,f=p?.childNodes.length===1?p.childNodes[0]:null;h=f?.childNodes.length===1?f.childNodes[0]:null}return h?.tagName===k&&ge(h,[],Qe(s.kind,s.tag,s.caps),{cell:g,known:Pe(I,$)})===null}import{attr as cn}from"../browser/shared/html-tree.mjs";import{pageLanguage as jn}from"../browser/shared/components/page.mjs";import{SHEETS as Tn}from"../browser/editor/components/kit.mjs";import{BLOCK_ID as Cn}from"../browser/shared/ids.mjs";function fn({current:s,edits:m,units:I=[],partial:k=!1,ids:g=!1,touch:$=[],proposals:w=null}){let u=At(s),h=u.blocks,p=s.includes(`\r
2
+ import{a as Je,b as Qe,c as ge,e as At,h as Xe,i as tn}from"./chunk-ECZBLQKK.mjs";import{A as Ye,B as We,C as Te,D as Q,E as Ze,a as me,g as Oe,h as He,j as Ne,l as Fe,m as wt,n as ke,o as $e,p as ne,q as Ft,r as De,s as Ve,t as vt,u as Le,v as Ge,w as Me,x as kt,y as G,z as je}from"./chunk-E7656LR7.mjs";import{g as Ct}from"./chunk-TKWEX4FD.mjs";import{b as pe,c as he,e as Ee}from"./chunk-A55HN5OK.mjs";import{BLOCK_TYPES as Ie,COPIED_AS_ITSELF as Kn,IDENTITY as gn}from"../browser/editor/components/registry.mjs";import{copyKeys as Un}from"../browser/editor/components/figure/index.mjs";import{accepts as xe,attributeValue as An,BLOCK_TYPES as Dt,boxRole as we,CHAPTER as En,holdsStraight as On,IDENTITY as Ke,isLead as rn,SIZES as Nn,sizeValue as ln,TOGGLES as an}from"../browser/editor/components/registry.mjs";import{iconMarkup as $n,iconValueOf as Ln,validIcon as Mn}from"../browser/editor/components/icon/index.mjs";Ee();import{attributeValue as bn,BLOCK_TYPES as en,HOSTS as xn,TOGGLES as wn}from"../browser/editor/components/registry.mjs";import{texSource as nn}from"../browser/editor/components/math/index.mjs";var Ce=new Set(Object.entries(en).filter(([,s])=>!s.box&&!s.bare).map(([s])=>s)),se=(s,m,I="")=>{let k=Q[m.type]?.leaf;if(k)return k(s,m,I);let g=[s.className,...m.classes??[]].filter(Boolean).join(" ");return`<${s.tag}${g?` class="${g}"`:""}${ke(m.attributes)}${I}>${m.html}</${s.tag}>`},Be=(s,m)=>s===void 0||!!s&&typeof s=="object"&&!Array.isArray(s)&&Object.entries(s).every(([I,k])=>typeof k=="string"&&bn(m,I,k)),qe=s=>s?.empty===!0,Pe=(s,m)=>s===void 0?null:I=>s.includes(m.slice(I.startOffset,I.endOffset));function ye(s,m,{empty:I=!1,file:k}={}){if(typeof m!="string"||!m.trim()&&!(I&&m===""))return!1;if(m==="")return!0;if(s.tex&&!nn(m))return!1;let g=s.inside??s.tag,$=`<${g}>${m}</${g}>`,[w,...u]=he($,{sourceCodeLocationInfo:!0}).childNodes;return u.length===0&&w?.tagName===g&&ge(w,[],s.inside!==void 0,{cell:g==="td"||g==="th",known:Pe(k,$)})===null}var vn=new Set(Object.values(en).filter(s=>s.text&&s.className).map(s=>s.kind));function ze(s,m){if(s.keep?.reason==="script")return null;if(s.kind==="list")return m.some(k=>k.unit===s.id&&k.kind==="list")?"list":null;let I=Q[s.kind];return I?.written?I.written(s)?"written":null:s.text===void 0||s.nested?null:["p","h1","h2","h3","h4","li"].includes(s.tag)||vn.has(s.kind)?"text":null}function be(s,m,I){if(!Array.isArray(m)||!m.every(g=>Sn(s,g,I)))return"invalid";let k=m.filter(g=>g.keep);return k.length>1?"invalid":m.length>k.length&&!s.caps.split||k.length===0&&!s.caps.remove||m.length===0&&s.nested?"fixed":k.length===1&&k[0].html.trim()===""&&!s.caps.empty?"empty":null}function sn(s,m,I){let k=`<table><tbody><tr><${s}>${m}</${s}></tr></tbody></table>`,[g,...$]=he(k,{sourceCodeLocationInfo:!0}).childNodes,w=$.length===0&&g?.tagName==="table"&&g.childNodes.length===1?g.childNodes[0]:null,u=w?.childNodes.length===1?w.childNodes[0]:null,h=u?.childNodes.length===1?u.childNodes[0]:null;return h?.tagName===s&&ge(h,[],!1,{cell:!0,known:Pe(I,k)})===null}var on={p:"paragraph",h1:"heading",h2:"heading",h3:"heading",h4:"heading",li:"item"},In=(s,m)=>s.classes===void 0||!s.keep&&Array.isArray(s.classes)&&new Set(s.classes).size===s.classes.length&&s.classes.every(I=>(wn[on[m]]??[]).includes(I));function Sn(s,m,I){if(!m||typeof m.html!="string"||xn[s.kind]?.tex&&!nn(m.html))return!1;let k=m.keep?s.tag:m.tag;if(!m.keep&&Je[s.tag]!==k||!In(m,k)||m.attributes!==void 0&&(m.keep||!Be(m.attributes,on[k])))return!1;let g=k==="td"||k==="th",$=g?`<table><tbody><tr><${k}>${m.html}</${k}></tr></tbody></table>`:`<${k}>${m.html}</${k}>`,[w,...u]=he($,{sourceCodeLocationInfo:!0}).childNodes;if(u.length>0||!w)return!1;let h=w;if(g){let p=w.tagName==="table"&&w.childNodes.length===1?w.childNodes[0]:null,f=p?.childNodes.length===1?p.childNodes[0]:null;h=f?.childNodes.length===1?f.childNodes[0]:null}return h?.tagName===k&&ge(h,[],Qe(s.kind,s.tag,s.caps),{cell:g,known:Pe(I,$)})===null}import{attr as cn}from"../browser/shared/html-tree.mjs";import{pageLanguage as jn}from"../browser/shared/components/page.mjs";import{SHEETS as Tn}from"../browser/editor/components/kit.mjs";import{BLOCK_ID as Cn}from"../browser/shared/ids.mjs";function fn({current:s,edits:m,units:I=[],partial:k=!1,ids:g=!1,touch:$=[],proposals:w=null}){let u=At(s),h=u.blocks,p=s.includes(`\r
3
3
  `)?`\r
4
4
  `:`
5
5
  `,f=[],O=[],j=[],K=new Map,q=null,X,xt=!1,tt=(t,n)=>f.push({unit:t.id,reason:n}),et=t=>{let o=Ft(t).replace(/[0-9.]/g,l=>String.fromCharCode(l.charCodeAt(0)-65248)).replace(/[\s,,]/g,"").replace(/[−–]/g,"-").match(/-?\d+(?:\.\d+)?/)?.[0];return o===void 0?null:Number(o)},ht=(t,n,o)=>{if(t.kind!=="cell")return;let l=s.slice(t.start,t.innerStart),a=/\sdata-sort-value(?:\s*=\s*(?:"([^"]*)"|'([^']*)'|([^\s>]+)))?/.exec(l);if(!a)return;let d=(a[1]??a[2]??a[3]??"").trim(),x=/^-?\d+(\.\d+)?(e[-+]?\d+)?$/i.test(d)?Number(d):null,[S,c]=[et(s.slice(t.innerStart,t.innerEnd)),et(n)],b="";x!==null&&c!==null?b=` data-sort-value="${Number((c*(S?x/S:1)).toPrecision(12))}"`:x!==null&&S===null&&(b=a[0]),b!==a[0]&&O.push({start:t.start+a.index,end:t.start+a.index+a[0].length,text:b,of:[{id:o}]})},Vt=t=>{t.keep&&ee(t)?tt(t,"referenced"):j.push({start:t.start,end:t.end},...t.companion?[t.companion]:[])},oe=(t,n)=>{let o=t.classAttr,l=o?o.value.split(/\s+/).filter(Boolean):[],a=l;for(let[x,S]of n)a=S?a.includes(x)?a:[...a,x]:a.filter(c=>c!==x);if(a.join(" ")===l.join(" "))return;if(ut(t),!o){let x=/^<[A-Za-z][\w-]*/.exec(s.slice(t.elStart,t.elStart+40));if(!x)return tt(t,"unknown");let S=t.elStart+x[0].length;O.push({start:S,end:S,text:` class="${a.join(" ")}"`});return}if(a.length===0){O.push({...ne(s,o.start,o.end),text:""});return}let d=/=\s*'/.test(s.slice(o.start,o.end))?"'":'"';O.push({start:o.start,end:o.end,text:`class=${d}${a.join(" ")}${d}`})},It=typeof g=="function"?g:g?Xe:null,ct=new Set([...s.matchAll(tn)].map(t=>t[1]??t[2])),qt=()=>{for(;;){let t=It();if(!ct.has(t))return ct.add(t)&&t}},re=[],Pt=[],Gt=t=>t?` ${Ke}="${t}"`:"",le=t=>typeof t=="string"&&Cn.test(t)&&!ct.has(t),ft=(t,n)=>{let o=It?le(n)?(ct.add(n),n):qt():null;return o&&t!==void 0&&Pt.push({key:t,id:o}),Gt(o)},ot=new Set,zt=t=>{ot.add(t.at);let n=w?.get(t.id),o=It?le(n)?(ct.add(n),n):qt():null;return o&&re.push({at:t.at,id:o}),Gt(o)},ut=t=>{if(!It||!t||t.blockId||t.at===void 0||ot.has(t.at))return;let n=$e(s,t.at);O.push({start:n,end:n,text:zt(t)})},St=t=>{let{element:n,source:o}=vt(t.restore),l=n.sourceCodeLocation,a=cn(n,Ke);if(a&&!ct.has(a))return ct.add(a),t.key!==void 0&&Pt.push({key:t.key,id:a}),o;let d=o,x=l.startTag.endOffset-1;if(a){let S=l.attrs[Ke],c=ne(d,S.startOffset,S.endOffset);d=d.slice(0,c.start)+d.slice(c.end),x-=c.end-c.start}return x=$e(d,x),d.slice(0,x)+ft(t.key,t.blockId)+d.slice(x)},gt=t=>{let n=null;for(let o of u.units)o.elStart<=t.start&&t.start<o.end&&(!n||o.elStart>n.elStart)&&(n=o);return n},_=new Set;for(let t of m){let{id:n,parts:o}=t??{},l=Number.isInteger(n)?h[n]:void 0;if(!l){f.push({id:n,reason:"unknown"});continue}if(Array.isArray(o)&&o.length===0&&l.self!==null&&u.units[l.self].keep){f.push({id:n,reason:"referenced"});continue}let a=be(l,o,s);if(a){f.push({id:n,reason:a});continue}if(o.length===0){let N={...je(s,l.start,l.end),of:[{id:n}]};O.push(N),K.set(n,N),l.self!==null&&_.add(l.self);continue}let d=G(s,l.start),x=d===null?"":p+d,S=N=>`<${N.tag}${N.classes?` class="${N.classes.join(" ")}"`:""}${ke(N.attributes)}${ft(N.key,N.blockId)}>${N.html}</${N.tag}>`,c=o.findIndex(N=>N.keep),b=gt(l),v=b&&b.at===l.innerStart-1;if((!v||l.tag==="li")&&ut(b),l.tag==="li"&&c>=0){let N=o.slice(0,c),z=o.slice(c+1),C=b?{start:b.start,end:b.end}:null;O.push({start:l.innerStart,end:l.innerEnd,text:o[c].html,of:[{id:n}]}),N.length>0&&O.push({start:l.start,end:l.start,seq:1/0,text:N.map(S).join(x)+x,edge:C,of:[{id:n}]}),z.length>0&&O.push({start:l.end,end:l.end,text:x+z.map(S).join(x),edge:C,of:[{id:n}]})}else{let N=s.slice(l.start,l.innerStart);if(v&&It&&!b.blockId&&!ot.has(b.at)&&(N=`${N.slice(0,-1)}${zt(b)}>`),o.length===1&&c===0&&N===s.slice(l.start,l.innerStart)){O.push({start:l.innerStart,end:l.innerEnd,text:o[0].html,of:[{id:n}]}),ht(l,o[0].html,n),l.kind==="title"&&(q={from:Ft(s.slice(l.innerStart,l.innerEnd)),to:Ft(o[0].html)});continue}let z=o.map(C=>C.keep?N+C.html+s.slice(l.innerEnd,l.end):S(C)).join(x);O.push({start:l.start,end:l.end,text:z,of:[{id:n}]})}l.kind==="title"&&(q={from:Ft(s.slice(l.innerStart,l.innerEnd)),to:Ft(o[0].html)})}let Y=(t,n,o)=>{let l=u.units.filter(c=>c.box===t),a=[];for(let c=1;c<l.length;c++){let b=s.slice(l[c-1].end,l[c].start);b.trim()||a.push({pair:[l[c-1],l[c]],gap:b})}let d=a.find(({pair:c})=>c.includes(n))??a[0];if(d)return d.gap.replace(/\r?\n/g,p);let x=G(s,o.start),S=we(u.boxes[t]?.kind)==="root"?p:"";return x===null?"":S+p+x},Yt=t=>{if(t.kind!=="nest"||G(s,t.innerEnd)!==null)return null;let n=u.units[t.unit];return n?G(s,n.elStart):null},Wt=(t,n)=>{let o=s.slice(t.at+1,t.innerEnd).match(/\n([ \t]*)\S/);return o?o[1]:`${n??""} `},Kt=(t,n)=>n!==null&&we(t.kind)==="root",mt=[],Zt=(t,n,o,l)=>{let a=Number.isInteger(n?.into)?u.boxes[n.into]:null,d=Number.isInteger(n?.after),x=a?null:u.units[d?n.after:n?.before],S=a??(x?u.boxes[x.box]:null),c=z=>z>=t.start&&z<t.end;if(!S||!(xe(S.kind,te(t))||l===S.kind)||t.kind==="tab"&&S.id!==t.box||x&&(x===t||!o.has(x.id)||c(x.elStart))||a&&c(S.at))return tt(t,"position");let b=G(s,t.start);if(ut(t),a){if(a.innerEnd===null)return tt(t,"missing");let z=Yt(a);if(z!==null){mt.push({start:t.start,end:t.end,at:a.innerEnd,seq:lt++,from:b,to:z+nt,wrap:R=>p+z+nt+R+p+z});return}let C=G(s,a.innerEnd),W=Wt(a,C),T=C!==null&&W.startsWith(C)?W.slice(C.length):" ",P=Kt(a,C);mt.push({start:t.start,end:t.end,at:P?a.innerEnd-C.length:a.innerEnd,seq:lt++,from:b,to:W,wrap:R=>C===null?R:P?C+T+R+p:T+R+p+C});return}let v=Y(x.box,x,x),N=d?v.includes(`
@@ -0,0 +1,4 @@
1
+ import { createRequire as __galleryRequire } from "node:module"; import { fileURLToPath as __galleryPath } from "node:url"; const require = __galleryRequire(import.meta.url); const __filename = __galleryPath(import.meta.url); const __dirname = __galleryPath(new URL(".", import.meta.url));
2
+ import{a as w,b as k,c as f,g as u}from"./chunk-7UZUQQ7Q.mjs";import{readFileSync as E,realpathSync as S}from"node:fs";import p from"node:path";import{fileURLToPath as $}from"node:url";var j=p.dirname($(import.meta.url));function v(r=j){for(let o=r;;o=p.dirname(o)){try{let n=JSON.parse(E(p.join(o,"package.json"),"utf8"));if(n.name==="@heycys/gallery")return n.version}catch{}if(p.dirname(o)===o)return"0.0.0"}}var x={init:()=>import("./chunk-VZ2RQ3AM.mjs"),new:()=>import("./chunk-Q4MS6OFC.mjs"),import:()=>import("./chunk-65NTKF4N.mjs"),open:()=>import("./chunk-MNWJ4EZY.mjs"),serve:()=>import("./chunk-53XDTHTG.mjs"),stop:()=>import("./chunk-QVGOPHOF.mjs"),check:()=>import("./chunk-BMX3VUHY.mjs"),export:()=>import("./chunk-E4IHAIJ7.mjs"),qa:()=>import("./chunk-VPMRP2TL.mjs"),list:()=>import("./chunk-QNECWMGR.mjs"),workspaces:()=>import("./chunk-ERE2BXYV.mjs"),move:()=>import("./chunk-GKOBB6DH.mjs"),set:()=>import("./chunk-7EFHNQ5B.mjs"),link:()=>import("./chunk-LMUZQK5O.mjs"),extension:()=>import("./chunk-6XD6U3QA.mjs"),block:()=>import("./chunk-OEIJLMPI.mjs"),page:()=>import("./chunk-2T4PZQEP.mjs"),skill:()=>import("./chunk-JXXHAXYH.mjs")},N=new Set(["stop","init","skill","workspaces"]),A=(r,o)=>`${r.split(`
3
+ `)[0]} (gallery ${o?`${o} --help`:"help"} says more)`,g=r=>/^--.|^-[A-Za-z]/.test(r);function L(r){let o=r.indexOf("--"),n=o===-1?r:r.slice(0,o),h=o===-1?[]:r.slice(o),i=[],a=null;for(let e=0;e<n.length;e++){let s=n[e];if(s==="--workspace"||s.startsWith("--workspace=")){let t=s.includes("=")?s.slice(s.indexOf("=")+1):e+1<n.length&&!g(n[e+1])?n[++e]:"";if(!t)return{error:"--workspace takes a folder: --workspace <dir>",usage:u};if(a!==null&&p.resolve(a)!==p.resolve(t))return{error:`Two workspaces named: ${a} and ${t}.`,usage:u};a=t;continue}i.push(s)}if(i[0]==="--version"||i[0]==="-v"||i[0]==="-V")return i.length===1&&h.length===0?{version:!0}:{error:"--version takes nothing else.",usage:u};if(i.length===0||i[0]==="help"||i[0]==="--help"||i[0]==="-h"){let e=i[0]==="help"?i[1]:void 0;return e===void 0?{help:u}:Object.hasOwn(f,e)?{help:f[e]}:{error:`No such command: ${e} (${w.join(", ")}).`,usage:u}}let[c,...m]=i,l=k[c]??c;if(!Object.hasOwn(x,l))return{error:g(l)?`Unknown option: ${l} (the command comes first: gallery <command> [options]).`:`No such command: ${l} (${w.join(", ")}).`,usage:u};let d=[...m,...h];if(m.some(e=>e==="--help"||e==="-h"))return{help:f[l]};if(l==="init"){let e=new Set(["--from","--name"]),s=[];for(let t=0;t<m.length;t++)e.has(m[t])?t++:g(m[t])||s.push(m[t]);if(s.push(...h.slice(1)),s.length>1)return{error:"Name one folder at most.",usage:f.init,command:l};if(s.length===1){if(a!==null&&p.resolve(a)!==p.resolve(s[0]))return{error:`Two workspaces named: ${s[0]} and --workspace ${a}.`,usage:f.init,command:l};a=s[0]}}return{command:l,argv:d,flag:a}}var G=(r,o)=>`Cannot write the workspace ${r} (${o}): allow Gallery to write there, or pass --workspace <a folder you may write>.`,b=(r,o=!0)=>o?`${p.join(r,"gallery.json")} is not Gallery's (another program's file of that name): pass --workspace <another folder> for Gallery's documents.`:`${p.join(r,"gallery.json")} does not read as JSON: mend the file, or pass --workspace <another folder> for Gallery's documents.`;async function W(r=process.argv.slice(2)){process.stdout.on("error",e=>{throw e.code==="EPIPE"&&process.exit(process.exitCode??0),e});let o=L(r);if(o.version){let e=v();console.log(e);try{let{versionNotes:s}=await import("./chunk-TANZRINB.mjs");for(let t of s(e))console.log(t)}catch{}return}if(o.help)return void console.log(o.help);o.error&&(console.error(`${o.error}
4
+ ${A(o.usage,o.command)}`),process.exit(2));let{command:n,flag:h}=o,{findWorkspace:i,defaultWorkspace:a}=await import("../browser/shared/workspace.mjs"),c=["page","block","extension"].includes(n)?{root:a(),how:"default"}:i({flag:h});if(process.env.GALLERY_WORKSPACE=c.root,!N.has(n)){let{ensureWorkspace:e}=await import("../browser/shared/workspace.mjs");try{await e(a());let{ours:t,reads:O}=await e(c.root,{state:n!=="init"||c.root===a()});t||(console.error(b(c.root,O)),process.exit(1))}catch(t){if(!t.code)throw t;console.error(G(c.root,t.code)),process.exit(1)}let{registerQuietly:s}=await import("../browser/shared/workspace-registry.mjs");await s(c.root)}let{UsageError:m,usageFailureText:l}=await import("./chunk-GPIWQ4X4.mjs"),d=await x[n]();try{await d.run(o.argv,{command:n,workspace:c.root,how:c.how,version:v()})}catch(e){if(!(e instanceof m))throw e;console.error(l(f[n],e.message,e.synopsis)),process.exit(2)}}var y=r=>{try{return S.native(r)}catch{return null}};process.argv[1]&&y(process.argv[1])===y($(import.meta.url))&&W();export{v as a,L as b,G as c,b as d,W as e};
@@ -0,0 +1,2 @@
1
+ import { createRequire as __galleryRequire } from "node:module"; import { fileURLToPath as __galleryPath } from "node:url"; const require = __galleryRequire(import.meta.url); const __filename = __galleryPath(import.meta.url); const __dirname = __galleryPath(new URL(".", import.meta.url));
2
+ import{i as p}from"./chunk-S3SX3COT.mjs";import{g as b}from"./chunk-VRPVVMRB.mjs";import{g as k}from"./chunk-USIHBCSW.mjs";import{k as d}from"./chunk-PLB7L22J.mjs";import{workspaceBase as v}from"../browser/shared/service-location.mjs";import j from"node:fs/promises";import f from"node:path";import{editStateDirectory as m,reportsDirectory as h}from"../browser/shared/paths.mjs";import{findPreviewServer as $}from"../browser/shared/preview-server.mjs";import{documentDirectory as S,documentFiles as g,isDocumentSource as D}from"../browser/shared/workspace.mjs";var u=e=>f.resolve(e),N=e=>f.basename(g(f.dirname(e)).json),O={busy:"it kept changing while it was being written (an Agent writing it?); nothing written. Run the export again.",timeout:"the workspace's Gallery server did not answer in 30s; nothing written. Run the export again."};async function w(e,n,o="hand-in",l=3e4){let t=`127.0.0.1:${e.port}`,s;try{s=await fetch(`http://${t}${v(h)}/__gallery/edit/${o}`,{method:"POST",headers:{"Content-Type":"application/json",Origin:`http://${t}`,"X-Gallery-Token":e.token},body:JSON.stringify({slug:n,workspace:h}),signal:AbortSignal.timeout(l)})}catch(a){return a.name==="TimeoutError"?{ok:!1,reason:"timeout"}:null}let i=await s.json().catch(()=>null);return typeof i?.ok!="boolean"||["elsewhere","token","host","origin"].includes(i.reason)?null:i}async function C(e){let n=await $(),o=null,l=[],t=new Map,s=[];for(let i of e){let{html:a,json:c}=g(S(i,h)),r=n?await w(n,i):null;if(r===null&&(o??=p({reportsDirectory:h,stateDirectory:m,finish:d}),r=await o.handIn(i),r.ok&&await o.settleNotes(i)),!r.ok){r.reason!=="missing"&&t.set(i,[`${u(a)} was not handed in: ${O[r.reason]??r.message??r.reason}`]);continue}if(r.repeated?.length){t.set(i,k(r.repeated));continue}s.push(...R(a,r)),r.written&&(r.changes.length&&s.push(...b(a,r.changes,{reread:!1})),r.added&&s.push(...L(a,r.given,r.added)),l.push(u(a))),T(r)&&l.push(u(c))}return{written:l,failures:t,lines:s}}async function H(e){let n=await $();if(n){for(let o of e)if(await w(n,o,"settle")===null)return}}async function K(e,{wait:n=3e4}={}){try{let o=await $(),l=o?await w(o,e,"round",n):null;return l!==null?l.ok?l.ended===!0:null:await p({reportsDirectory:h,stateDirectory:m,finish:d}).beginRound(e)}catch{return null}}async function W(e){try{let n=p({reportsDirectory:h,stateDirectory:m,finish:d}),{html:o}=g(S(e,h));await n.noteTaken(e,await j.readFile(o,"utf8"))}catch{}}var T=({title:e=null,icon:n=null})=>!!(e&&typeof e.from=="string"&&e.from!==e.to||n&&!n.missing),x=10;function L(e,n,o=n?.length??0,{pending:l=!1}={}){let t=`${o} block${o===1?"":"s"}`;if(l){let i=[`ids ${u(e)}: ${t} without an id yet: the export gives ${o===1?"it":"each"} one`];return o>x?i:[...i,...n.map(({line:a,tag:c})=>` line ${a} ${c}`)]}let s=[`ids ${u(e)}: ${t} given an id`];return!n||o>x?s:[...s,...n.map(({line:i,tag:a,id:c})=>` line ${i} ${a} \u2192 ${c}`)]}function R(e,{title:n=null,icon:o=null}={},{pending:l=!1}={}){let t=u(f.dirname(e)),s=N(e),i=(c,r,y)=>l?`${c} not ${r} yet (${y}): the export writes ${c.includes(" and ")?"them":"it"}`:`${c} written ${r}: ${y}`,a=[];if(n){let c=[...n.page?["<title>"]:[],...typeof n.from=="string"&&n.from!==n.to?[`${s}'s title`]:[]];c.length&&a.push(`title ${t}: ${i(c.join(" and "),"as its h1 says it",JSON.stringify(n.to))}`)}return o?.missing?a.push(`icon ${t}: ${s} has the icon ${JSON.stringify(o.from)} and the page's header none: write it there (<div class="doc-icon">\u2026</div> before the h1) or take "icon" out of ${s} (the export leaves ${s}'s as it is)`):o&&a.push(`icon ${t}: ${i(`${s}'s icon`,"as its header has it",o.to===null?"none":JSON.stringify(o.to))}`),a}function X(e,{by:n="this export"}={}){let o=e.length===1,l=[...e.filter(t=>D(f.basename(t))).map(t=>f.basename(t)).filter((t,s,i)=>i.indexOf(t)===s).map(t=>`${t}: the kit's markup, block ids`),...e.filter(t=>/^(doc|report)\.json$/.test(f.basename(t))).map(t=>f.basename(t)).filter((t,s,i)=>i.indexOf(t)===s).map(t=>`${t}: the title or icon said above`)];return`Re-read ${e.join(", ")} before editing ${o?"it":"them"}: ${n} wrote ${o?"it":"them"} (${l.join("; ")}).`}export{C as a,H as b,K as c,W as d,L as e,R as f,X as g};
@@ -1,2 +1,2 @@
1
1
  import { createRequire as __galleryRequire } from "node:module"; import { fileURLToPath as __galleryPath } from "node:url"; const require = __galleryRequire(import.meta.url); const __filename = __galleryPath(import.meta.url); const __dirname = __galleryPath(new URL(".", import.meta.url));
2
- import{c as o}from"./chunk-EKGYYOSP.mjs";var i=class r{static create(e,n,s,c){return new Promise((a,l)=>{let t=new WebSocket(e);t.addEventListener("open",()=>a(new r(t,s))),t.addEventListener("error",l)})}#e;#s;onmessage;onclose;constructor(e,n){this.#e=e,this.#s=n,this.#e.addEventListener("message",s=>{this.onmessage&&this.onmessage.call(null,s.data)}),this.#e.addEventListener("close",()=>{this.onclose&&this.onclose.call(null)}),this.#e.addEventListener("error",()=>{this.#s?.(o.error)})}send(e){this.#e.send(e)}close(){this.#e.close()}};export{i as a};
2
+ import{c as o}from"./chunk-W7XHE4CT.mjs";var i=class r{static create(e,n,s,c){return new Promise((a,l)=>{let t=new WebSocket(e);t.addEventListener("open",()=>a(new r(t,s))),t.addEventListener("error",l)})}#e;#s;onmessage;onclose;constructor(e,n){this.#e=e,this.#s=n,this.#e.addEventListener("message",s=>{this.onmessage&&this.onmessage.call(null,s.data)}),this.#e.addEventListener("close",()=>{this.onclose&&this.onclose.call(null)}),this.#e.addEventListener("error",()=>{this.#s?.(o.error)})}send(e){this.#e.send(e)}close(){this.#e.close()}};export{i as a};
@@ -1,2 +1,2 @@
1
1
  import { createRequire as __galleryRequire } from "node:module"; import { fileURLToPath as __galleryPath } from "node:url"; const require = __galleryRequire(import.meta.url); const __filename = __galleryPath(import.meta.url); const __dirname = __galleryPath(new URL(".", import.meta.url));
2
- import{a,b,c,d,e,f,g,h,i,j}from"./chunk-WTEGUPFG.mjs";import"./chunk-JXLSHVJ2.mjs";import"./chunk-KFZBYDIS.mjs";import"./chunk-7XDYK3UC.mjs";import"./chunk-VG5JEIUQ.mjs";import"./chunk-N3DSBH5S.mjs";import"./chunk-5L7RYZCL.mjs";export{g as changeLines,c as handedInSource,f as headerChanged,e as inStep,a as naturalize,d as pendingBlockIds,h as readOnlyTexts,j as scriptKept,b as shownSource,i as writingNotes};
2
+ import{a,b,c,d,e,f,g,h,i,j}from"./chunk-VRPVVMRB.mjs";import"./chunk-UMHUSOPJ.mjs";import"./chunk-ECZBLQKK.mjs";import"./chunk-E7656LR7.mjs";import"./chunk-TKWEX4FD.mjs";import"./chunk-A55HN5OK.mjs";import"./chunk-5L7RYZCL.mjs";export{g as changeLines,c as handedInSource,f as headerChanged,e as inStep,a as naturalize,d as pendingBlockIds,h as readOnlyTexts,j as scriptKept,b as shownSource,i as writingNotes};
@@ -0,0 +1,2 @@
1
+ import { createRequire as __galleryRequire } from "node:module"; import { fileURLToPath as __galleryPath } from "node:url"; const require = __galleryRequire(import.meta.url); const __filename = __galleryPath(import.meta.url); const __dirname = __galleryPath(new URL(".", import.meta.url));
2
+ import{a as D,b as M}from"./chunk-QP7BOHE4.mjs";import{c as y,d as j}from"./chunk-WFGPMCTZ.mjs";import{b as w,f as A}from"./chunk-4OZWXZE5.mjs";import L from"node:fs/promises";import k from"node:path";import{readAnnouncement as T}from"../browser/shared/preview-server.mjs";import{nameProblem as _,nameStops as v,ownName as B,workspaceLabels as K,workspaceName as b,writeWorkspaceName as Q}from"../browser/shared/workspace-name.mjs";import{forgetWorkspace as R,isWorkspace as C,isWorkspaceId as U,readRegistry as F,registerQuietly as x,registerWorkspace as q,SCAN_DEPTH as P,SCAN_LIMIT as z,scanForWorkspaces as J,workspaceId as V,workspaceKey as l}from"../browser/shared/workspace-registry.mjs";import{defaultWorkspace as X,documentsFolder as E,ensureWorkspace as Y,layoutOf as Z}from"../browser/shared/workspace.mjs";import{clashingIds as ee}from"../browser/shared/drafts.mjs";var u=(o,t)=>`${o} ${t}${o===1?"":"s"}`,W=(o,t)=>l(o)===l(t);function oe(o){if(B(o)||W(o,X()))return null;let{name:t}=b(o,{stops:v()});return`\u5DE5\u4F5C\u533A\u540D\u5B57\uFF1A\u6CA1\u6709\uFF08\u522B\u5904\u6309\u6587\u4EF6\u5939\u53EB\u5B83"${t}"\uFF09\uFF1B\u8FD9\u4E2A\u5DE5\u4F5C\u533A\u662F\u4E3A\u4E00\u4E2A\u9879\u76EE\u5EFA\u7684\uFF0C\u5C31\u7528 gallery workspaces --name "<\u9879\u76EE\u540D>" \u5199\u4E0A\u9879\u76EE\u540D`}async function se(o,t){let n=_(t);if(n)throw new w(n);try{let{ours:r,reads:f}=await Y(o);r||(console.error(j(o,f)),process.exit(1))}catch(r){if(!r.code)throw r;console.error(y(o,r.code)),process.exit(1)}let s;try{s=await Q(o,t)}catch(r){console.error(r.code?y(o,r.code):r.message),process.exit(1)}await x(o),console.log(`\u5DE5\u4F5C\u533A\uFF1A${o}`),console.log(`\u540D\u5B57\uFF1A${s.name} (in ${Z(o).marker}${s.before&&s.before!==s.name?`; it was "${s.before}"`:""}): the sidebar and gallery workspaces call it so.`)}async function re(o,t){let n=await R(o);n.length||(console.error(`No registered workspace is ${U(o)?o:k.resolve(o)}: gallery workspaces lists them, with their paths and ws- ids.`),process.exit(1));for(let s of n)console.log(`Forgot ${s} (only the registry changed: nothing on disk).${W(s,t)?" It is the current workspace: the next command run in it registers it again.":""}`)}async function te(o){let t=k.resolve(o??E());await L.stat(t).then(a=>a.isDirectory(),()=>!1)||(console.error(`No such folder: ${t} (--scan names a folder to look in).`),process.exit(1));let n=new Set(F().workspaces.map(({root:a})=>l(a))),{found:s,read:r,cut:f}=await J(t);console.log(`Scanned ${t}, ${P} levels down (${u(r,"folder")}): ${s.length?`${u(s.length,"workspace")}.`:"no workspace."}`);let i=v();for(let a of s){let{name:d}=b(a,{stops:i});if(n.has(l(a))){await x(a),console.log(` \u5DF2\u767B\u8BB0\uFF1A${a}\uFF08${d}\uFF09`);continue}try{await q(a)}catch(m){console.log(` \u6CA1\u80FD\u767B\u8BB0\uFF08${m.code??m.message}\uFF09\uFF1A${a}`);continue}console.log(` \u65B0\u767B\u8BB0\uFF1A${a}\uFF08${d}\uFF09`)}f&&console.log(`Stopped after ${u(z,"folder")}: gallery workspaces --scan <a folder further down> looks at the rest.`),s.length&&console.log("gallery workspaces lists them; gallery list <words> --all searches their documents.")}async function ne(o){let t=C(o);t&&await x(o);let n=F().workspaces,s=[o,...n.map(({root:e})=>e).filter(e=>!W(e,o))],r=new Map(n.map(({root:e,seen:c})=>[l(e),Date.parse(c)])),f=E(),i=v({documents:f}),a=await Promise.all(s.map(async e=>{let c=C(e),p=c?await D(e):[];return{root:e,there:c,count:p.length,edited:p.reduce((g,{edited:h})=>Math.max(g,h),0),named:{root:e,...b(e,{stops:i})}}})),[d,...m]=a;m.sort((e,c)=>c.there-e.there||c.edited-e.edited||(r.get(l(c.root))??0)-(r.get(l(e.root))??0));let I=[d,...m],G=new Map(K(I.map(({named:e})=>e)).map(e=>[l(e.root),e])),$=await T();console.log($?`Gallery \u670D\u52A1\uFF1Ahttp://127.0.0.1:${$.port}/ (pid ${$.pid})`:"Gallery \u670D\u52A1\uFF1A\u672A\u542F\u52A8");let N=n.length;console.log(`${u(N,"workspace")} on this machine's registry; the current one first (*):`);for(let e of I){let{name:c,own:p,above:g}=G.get(l(e.root)),h=e===d,S=[...p||!e.there?[]:["\u6CA1\u6709\u8D77\u540D\uFF1A\u7528\u7684\u662F\u6587\u4EF6\u5939\u7684\u540D\u5B57"],...e.there?[]:[h?"\u8FD8\u6CA1\u6709\u5EFA":"\u4E0D\u5728\u4E86\uFF1A\u6587\u4EF6\u5939\u6216\u5B83\u7684 gallery.json \u627E\u4E0D\u5230\u4E86"]],H=g?k.isAbsolute(g)?`\uFF08${g}\uFF09`:`\uFF08\u4E0A\u4E00\u7EA7\uFF1A${g}\uFF09`:"";console.log(`${h?"*":" "} ${c}${H} ${V(e.root)}${S.length?` \uFF08${S.join("\uFF1B")}\uFF09`:""}`),console.log(` \u8DEF\u5F84\uFF1A${e.root}`),e.there&&console.log(` \u6587\u6863\uFF1A${e.count?`${e.count} \u7BC7\uFF1B\u4E0A\u6B21\u7F16\u8F91\uFF1A${M(e.edited)}`:"\u6CA1\u6709"}`)}for(let{id:e,roots:c}of ee())console.log(`${e} \u662F ${c.length} \u4E2A\u767B\u8BB0\u7684\u5DE5\u4F5C\u533A\u5171\u7528\u7684\u7F16\u53F7\uFF08${c.join("\u3001")}\uFF09\uFF1A\u4FA7\u8FB9\u680F\u91CC\u5B83\u4EEC\u7684\u5E95\u7A3F\u90FD\u627E\u4E0D\u5230\uFF1Bgallery workspaces --forget <\u8DEF\u5F84> \u53BB\u6389\u5176\u4E2D\u4E00\u4E2A`);let O=t?oe(o):null;O&&console.log(O),m.some(({there:e})=>!e)&&console.log("One no longer there stays registered (a drive may come back): gallery workspaces --forget <\u8DEF\u5F84> takes it off, nothing on disk changed."),N<=1&&console.log(`gallery workspaces --scan registers the workspaces already on this machine (in the Documents folder, ${P} levels down; or --scan <folder>).`),console.log("gallery list <words> --all searches the documents of them all; every command takes --workspace <\u8DEF\u5F84> to work in one.")}async function we(o,t){let{positional:n,options:s,values:r}=A({options:["--scan"],values:["--name","--forget"],argv:o});if([s.has("--scan"),r.has("--name"),r.has("--forget")].filter(Boolean).length>1)throw new w("One of --scan, --name and --forget at a time.");if(n.length>(s.has("--scan")?1:0))throw new w(s.has("--scan")?"--scan takes one folder at most.":"gallery workspaces names no folder: --scan <folder> looks in one, --workspace <dir> names the current workspace.");let i=k.resolve(t.workspace);return r.has("--name")?se(i,r.get("--name")):r.has("--forget")?re(r.get("--forget"),i):s.has("--scan")?te(n[0]):ne(i)}export{oe as a,we as b};
@@ -1,2 +1,2 @@
1
1
  import { createRequire as __galleryRequire } from "node:module"; import { fileURLToPath as __galleryPath } from "node:url"; const require = __galleryRequire(import.meta.url); const __filename = __galleryPath(import.meta.url); const __dirname = __galleryPath(new URL(".", import.meta.url));
2
- import{b as h,e as x}from"./chunk-N3DSBH5S.mjs";x();import{BODY as C}from"../browser/shared/components/index.mjs";import{attr as u,elementsOf as f,walk as w}from"../browser/shared/html-tree.mjs";import{decoded as R,pageAddress as T}from"../browser/shared/page-address.mjs";import{CHART_SOURCE as A,cellWords as N,tableRows as E}from"../browser/shared/table-chart.mjs";var p=a=>a.nodeName==="#text"?a.value:(a.childNodes??[]).map(p).join(""),n=a=>f(a).filter(l=>l.tagName==="td"||l.tagName==="th"),M=a=>["rowspan","colspan"].some(l=>{let o=Number.parseInt(u(a,l)??"1",10);return Number.isFinite(o)&&o!==1});function b(a){let l=f(a),o=t=>f(t).filter(m=>m.tagName==="tr"),e=l.find(t=>t.tagName==="thead"),s=e?o(e)[0]??null:null,r=l.filter(t=>t.tagName==="tbody").flatMap(o);return!s&&r.length>0&&n(r[0]).length>0&&n(r[0]).every(t=>t.tagName==="th")&&([s,...r]=r),{groups:l,rowsOf:o,header:s,rows:r}}function S(a){let{groups:l,rowsOf:o,header:e,rows:s}=b(a),r=t=>N(p(t));return{names:e?n(e).map(r):null,types:e?n(e).map(t=>u(t,"data-sort-type")??null):null,rows:s.map(t=>n(t).map(m=>({words:r(m),sort:u(m,"data-sort-value")?.trim()??null}))),foot:l.filter(t=>t.tagName==="tfoot").flatMap(o).map(t=>n(t)[0]?r(n(t)[0]):""),merged:[e,...s].some(t=>t&&n(t).some(M))}}function W(a,l){let o=[];return w(a,e=>{if(e.tagName!=="a")return;let s=(u(e,"href")??"").trim();if(!s)return;let r=s.startsWith("#")&&s.length>1?l?{slug:l,block:R(s.slice(1))}:null:T(s);r&&o.push({slug:r.slug,title:N(p(e)),block:r.block??null})}),o}function I(a,l,o=null){let e=null;if(w(h(String(a)),i=>{e!==null||u(i,A)!==l||(e=i.tagName==="table"?i:f(i).find(c=>c.tagName==="table")??!1)},{...C,inTemplates:!1}),!e)return{error:"missing"};let s=S(e),r=E(s);if(r.error)return{error:"merged"};let{header:t,rows:m}=b(e),k=t?m:m.slice(1),O=s.names?s.rows:s.rows.slice(1),d=r.data.columns;return{columns:[...d],rows:r.data.map((i,c)=>{let g={};return d.forEach((v,y)=>{g[v]=O[c][y]?.words??""}),{values:{...i},links:W(k[c],o),words:g}})}}export{S as a,I as b};
2
+ import{b as h,e as x}from"./chunk-A55HN5OK.mjs";x();import{BODY as C}from"../browser/shared/components/index.mjs";import{attr as u,elementsOf as f,walk as w}from"../browser/shared/html-tree.mjs";import{decoded as R,pageAddress as T}from"../browser/shared/page-address.mjs";import{CHART_SOURCE as A,cellWords as N,tableRows as E}from"../browser/shared/table-chart.mjs";var p=a=>a.nodeName==="#text"?a.value:(a.childNodes??[]).map(p).join(""),n=a=>f(a).filter(l=>l.tagName==="td"||l.tagName==="th"),M=a=>["rowspan","colspan"].some(l=>{let o=Number.parseInt(u(a,l)??"1",10);return Number.isFinite(o)&&o!==1});function b(a){let l=f(a),o=t=>f(t).filter(m=>m.tagName==="tr"),e=l.find(t=>t.tagName==="thead"),s=e?o(e)[0]??null:null,r=l.filter(t=>t.tagName==="tbody").flatMap(o);return!s&&r.length>0&&n(r[0]).length>0&&n(r[0]).every(t=>t.tagName==="th")&&([s,...r]=r),{groups:l,rowsOf:o,header:s,rows:r}}function S(a){let{groups:l,rowsOf:o,header:e,rows:s}=b(a),r=t=>N(p(t));return{names:e?n(e).map(r):null,types:e?n(e).map(t=>u(t,"data-sort-type")??null):null,rows:s.map(t=>n(t).map(m=>({words:r(m),sort:u(m,"data-sort-value")?.trim()??null}))),foot:l.filter(t=>t.tagName==="tfoot").flatMap(o).map(t=>n(t)[0]?r(n(t)[0]):""),merged:[e,...s].some(t=>t&&n(t).some(M))}}function W(a,l){let o=[];return w(a,e=>{if(e.tagName!=="a")return;let s=(u(e,"href")??"").trim();if(!s)return;let r=s.startsWith("#")&&s.length>1?l?{slug:l,block:R(s.slice(1))}:null:T(s);r&&o.push({slug:r.slug,title:N(p(e)),block:r.block??null})}),o}function I(a,l,o=null){let e=null;if(w(h(String(a)),i=>{e!==null||u(i,A)!==l||(e=i.tagName==="table"?i:f(i).find(c=>c.tagName==="table")??!1)},{...C,inTemplates:!1}),!e)return{error:"missing"};let s=S(e),r=E(s);if(r.error)return{error:"merged"};let{header:t,rows:m}=b(e),k=t?m:m.slice(1),O=s.names?s.rows:s.rows.slice(1),d=r.data.columns;return{columns:[...d],rows:r.data.map((i,c)=>{let g={};return d.forEach((v,y)=>{g[v]=O[c][y]?.words??""}),{values:{...i},links:W(k[c],o),words:g}})}}export{S as a,I as b};
package/dist/cli.mjs CHANGED
@@ -1,2 +1,2 @@
1
1
  import { createRequire as __galleryRequire } from "node:module"; import { fileURLToPath as __galleryPath } from "node:url"; const require = __galleryRequire(import.meta.url); const __filename = __galleryPath(import.meta.url); const __dirname = __galleryPath(new URL(".", import.meta.url));
2
- import{a,b,c,d,e}from"./chunk-KUILYI7H.mjs";import"./chunk-2GKGEVMR.mjs";import"./chunk-5L7RYZCL.mjs";export{e as main,d as notOurs,b as readCommandLine,c as unwritable,a as versionOf};
2
+ import{a,b,c,d,e}from"./chunk-WFGPMCTZ.mjs";import"./chunk-7UZUQQ7Q.mjs";import"./chunk-5L7RYZCL.mjs";export{e as main,d as notOurs,b as readCommandLine,c as unwritable,a as versionOf};
package/dist/server.mjs CHANGED
@@ -1,2 +1,2 @@
1
1
  import { createRequire as __galleryRequire } from "node:module"; import { fileURLToPath as __galleryPath } from "node:url"; const require = __galleryRequire(import.meta.url); const __filename = __galleryPath(import.meta.url); const __dirname = __galleryPath(new URL(".", import.meta.url));
2
- import{a as o}from"./chunk-AEMVZYZQ.mjs";import"./chunk-DR73Y2UJ.mjs";import"./chunk-CG3UHDKH.mjs";import"./chunk-4AMTKWDO.mjs";import"./chunk-QXVNUASA.mjs";import"./chunk-FCK6NXON.mjs";import"./chunk-OU3S466R.mjs";import"./chunk-CZ5KJSGK.mjs";import"./chunk-UGO5N3EI.mjs";import"./chunk-5IIH335D.mjs";import"./chunk-QK3VISCA.mjs";import"./chunk-2OHANJ6Q.mjs";import"./chunk-F4ZA6JRZ.mjs";import"./chunk-7M2BQQGZ.mjs";import"./chunk-TOE6DPLH.mjs";import"./chunk-WTEGUPFG.mjs";import"./chunk-VKSRM7EY.mjs";import"./chunk-LE44MD3O.mjs";import"./chunk-XMKHCUI6.mjs";import"./chunk-SAHS56QM.mjs";import"./chunk-KH24LWAT.mjs";import"./chunk-YFJU3O7G.mjs";import"./chunk-NWRZXELO.mjs";import"./chunk-G4YP7GVC.mjs";import"./chunk-DHB7UZ7F.mjs";import"./chunk-2RKIHJI2.mjs";import"./chunk-JXLSHVJ2.mjs";import"./chunk-XKOHV4H6.mjs";import"./chunk-KFZBYDIS.mjs";import"./chunk-7XDYK3UC.mjs";import"./chunk-VG5JEIUQ.mjs";import"./chunk-N3DSBH5S.mjs";import"./chunk-5L7RYZCL.mjs";var t=process.argv.indexOf("--port"),r=t===-1?Number.NaN:Number(process.argv[t+1]);(!Number.isInteger(r)||r<=0||r>=65536)&&(console.error("Usage: node dist/server.mjs --port <n> (GALLERY_WORKSPACE names the workspace). The gallery command starts it: gallery open."),process.exit(2));try{let{port:e}=await o({port:r});console.log(`[gallery] ${new Date().toISOString()} listening on http://127.0.0.1:${e}/ (pid ${process.pid})`)}catch(e){console.error(`[gallery] could not start on port ${r}: ${e.message}`),process.exit(1)}
2
+ import{a as o}from"./chunk-BLNQUR5R.mjs";import"./chunk-6GV3CBB2.mjs";import"./chunk-DR73Y2UJ.mjs";import"./chunk-M4NRDYI5.mjs";import"./chunk-PUOQ65NC.mjs";import"./chunk-6QWQXHAV.mjs";import"./chunk-6Q7ASAXJ.mjs";import"./chunk-S3SX3COT.mjs";import"./chunk-GJJRBGMY.mjs";import"./chunk-JPG2LBQM.mjs";import"./chunk-ALZ6ZENZ.mjs";import"./chunk-IA4PSIMD.mjs";import"./chunk-2OHANJ6Q.mjs";import"./chunk-F4ZA6JRZ.mjs";import"./chunk-7M2BQQGZ.mjs";import"./chunk-6NLXUKAY.mjs";import"./chunk-VRPVVMRB.mjs";import"./chunk-4B2TB5K2.mjs";import"./chunk-KLQP46Y3.mjs";import"./chunk-USIHBCSW.mjs";import"./chunk-3SKOU6OZ.mjs";import"./chunk-ZTHICSSF.mjs";import"./chunk-PLB7L22J.mjs";import"./chunk-PAREWQGB.mjs";import"./chunk-BFJGHSQN.mjs";import"./chunk-U5XL7D6A.mjs";import"./chunk-HYMEEXKN.mjs";import"./chunk-UMHUSOPJ.mjs";import"./chunk-W5NPH5UA.mjs";import"./chunk-ECZBLQKK.mjs";import"./chunk-E7656LR7.mjs";import"./chunk-TKWEX4FD.mjs";import"./chunk-A55HN5OK.mjs";import"./chunk-5L7RYZCL.mjs";var t=process.argv.indexOf("--port"),r=t===-1?Number.NaN:Number(process.argv[t+1]);(!Number.isInteger(r)||r<=0||r>=65536)&&(console.error("Usage: node dist/server.mjs --port <n> (GALLERY_WORKSPACE names the workspace). The gallery command starts it: gallery open."),process.exit(2));try{let{port:e}=await o({port:r});console.log(`[gallery] ${new Date().toISOString()} listening on http://127.0.0.1:${e}/ (pid ${process.pid})`)}catch(e){console.error(`[gallery] could not start on port ${r}: ${e.message}`),process.exit(1)}
package/dist/worker.mjs CHANGED
@@ -1,5 +1,5 @@
1
1
  import { createRequire as __galleryRequire } from "node:module"; import { fileURLToPath as __galleryPath } from "node:url"; const require = __galleryRequire(import.meta.url); const __filename = __galleryPath(import.meta.url); const __dirname = __galleryPath(new URL(".", import.meta.url));
2
- import{a as P,b as W,c as B,e as H}from"./chunk-NFABH3QW.mjs";import"./chunk-2OHANJ6Q.mjs";import"./chunk-F4ZA6JRZ.mjs";import"./chunk-7M2BQQGZ.mjs";import"./chunk-TOE6DPLH.mjs";import"./chunk-WTEGUPFG.mjs";import"./chunk-G4YP7GVC.mjs";import"./chunk-DHB7UZ7F.mjs";import"./chunk-2RKIHJI2.mjs";import"./chunk-JXLSHVJ2.mjs";import"./chunk-XKOHV4H6.mjs";import"./chunk-KFZBYDIS.mjs";import{c as F}from"./chunk-7XDYK3UC.mjs";import{g as R,i as M}from"./chunk-VG5JEIUQ.mjs";import"./chunk-N3DSBH5S.mjs";import"./chunk-5L7RYZCL.mjs";import{parentPort as N}from"node:worker_threads";import{PAGE as U}from"../browser/editor/components/kit.mjs";import{APART as T,clipboardOf as X,tagKind as j,unitClipboard as _,writtenApart as Y}from"../browser/editor/components/registry.mjs";import{WRITERS as h,heldToWords as Z,unitOpening as tt,wordsIn as et}from"../browser/editor/page/clipboard/own/writers.mjs";import{escapeAttribute as v}from"../browser/shared/escape.mjs";import{referencedFile as rt}from"../browser/shared/media.mjs";var nt=/^\s*\\\(([\s\S]*)\\\)\s*$/,ot=" ",st=["script","style","template","noscript",T,U.header,`${U.header} > h1`].join(", ");function it(r,u){let f=globalThis.document.createElement("template");f.innerHTML=r??"";let d=g=>[...g.childNodes].map(n=>{if(n.nodeType===3)return n.data.replace(/ /g," ");if(n.nodeType!==1)return"";if(n.matches(".doc-math-inline")){let i=nt.exec(n.textContent)?.[1];return i!==void 0?i.trim()?`$${i.trim()}$`:"":n.textContent}if(n.localName==="img"){let i=n.getAttribute("src");return i?`![${at(n.getAttribute("alt")??"")}](${u(i,"image",D(i))})`:""}if(n.matches("a.doc-link-mention")){let i=(n.querySelector(".doc-link-mention-title")??n).textContent.replace(/\s+/g," ").trim();return n.getAttribute("href")?`[${i||n.getAttribute("href")}](${n.getAttribute("href")})`:i}let l=d(n);if(n.localName==="br")return`
2
+ import{a as P,b as W,c as B,e as H}from"./chunk-RRKJMHNX.mjs";import"./chunk-2OHANJ6Q.mjs";import"./chunk-F4ZA6JRZ.mjs";import"./chunk-7M2BQQGZ.mjs";import"./chunk-6NLXUKAY.mjs";import"./chunk-VRPVVMRB.mjs";import"./chunk-BFJGHSQN.mjs";import"./chunk-U5XL7D6A.mjs";import"./chunk-HYMEEXKN.mjs";import"./chunk-UMHUSOPJ.mjs";import"./chunk-W5NPH5UA.mjs";import"./chunk-ECZBLQKK.mjs";import{c as F}from"./chunk-E7656LR7.mjs";import{g as R,i as M}from"./chunk-TKWEX4FD.mjs";import"./chunk-A55HN5OK.mjs";import"./chunk-5L7RYZCL.mjs";import{parentPort as N}from"node:worker_threads";import{PAGE as U}from"../browser/editor/components/kit.mjs";import{APART as T,clipboardOf as X,tagKind as j,unitClipboard as _,writtenApart as Y}from"../browser/editor/components/registry.mjs";import{WRITERS as h,heldToWords as Z,unitOpening as tt,wordsIn as et}from"../browser/editor/page/clipboard/own/writers.mjs";import{escapeAttribute as v}from"../browser/shared/escape.mjs";import{referencedFile as rt}from"../browser/shared/media.mjs";var nt=/^\s*\\\(([\s\S]*)\\\)\s*$/,ot=" ",st=["script","style","template","noscript",T,U.header,`${U.header} > h1`].join(", ");function it(r,u){let f=globalThis.document.createElement("template");f.innerHTML=r??"";let d=g=>[...g.childNodes].map(n=>{if(n.nodeType===3)return n.data.replace(/ /g," ");if(n.nodeType!==1)return"";if(n.matches(".doc-math-inline")){let i=nt.exec(n.textContent)?.[1];return i!==void 0?i.trim()?`$${i.trim()}$`:"":n.textContent}if(n.localName==="img"){let i=n.getAttribute("src");return i?`![${at(n.getAttribute("alt")??"")}](${u(i,"image",D(i))})`:""}if(n.matches("a.doc-link-mention")){let i=(n.querySelector(".doc-link-mention-title")??n).textContent.replace(/\s+/g," ").trim();return n.getAttribute("href")?`[${i||n.getAttribute("href")}](${n.getAttribute("href")})`:i}let l=d(n);if(n.localName==="br")return`
3
3
  `;if(!l.trim())return l;let[c,m,p]=[l.match(/^\s*/)[0],l.trim(),l.match(/\s*$/)[0]];switch(n.localName){case"strong":case"b":return`${c}**${m}**${p}`;case"em":case"i":return`${c}*${m}*${p}`;case"s":case"del":case"strike":return`${c}~~${m}~~${p}`;case"code":return`${c}\`${m}\`${p}`;case"a":{let i=n.getAttribute("href")??"";return!i||i.startsWith("#")?l:rt(i)?`${c}[${m}](${u(i,"file",n.getAttribute("download")||D(i))})${p}`:m===i?`${c}${i}${p}`:`${c}[${m}](${i})${p}`}default:return n.classList.contains("doc-tab")?` ${l}`:l}}).join("");return Z(d(f.content).replace(/[ \t]+\n/g,`
4
4
  `).trim())}function b(r){if(!r.querySelector(T))return r;let u=r.cloneNode(!0);for(let f of u.querySelectorAll(T))f.remove();return u}var ct=r=>(r?.textContent??"").replace(/\s+/g," ").trim(),D=r=>r.replace(/[?#].*$/,"").split("/").pop(),at=r=>r.replace(/[\\[\]]/g,"\\$&"),ut=/(\d+)/g;async function K(r,{title:u,media:f=g=>g,chart:d=()=>null}){let{UNIT:g,unitsOf:n,serializeInner:l,nestedBlocks:c,isHost:m}=await P(),p=e=>it(e,f),i=e=>{let t=b(e),o=[...t.querySelectorAll("img")];if(o.length===0)return l(t);let s=t.cloneNode(!0);return s.querySelectorAll("img").forEach((a,A)=>a.replaceWith(`\uE000${A}\uE001`)),l(s).replace(ut,(a,A)=>`<img src="${v(o[A].getAttribute("src")??"")}" alt="${v(o[A].getAttribute("alt")??"")}">`)},z=e=>p(i(e)),G=(e,{tables:t=!0}={})=>{let o=b(e);return[...o.querySelectorAll("img[src]")].filter(s=>!s.closest("a.doc-link-mention")&&(t||!o.contains(s.closest("table")))).map(s=>p(s.outerHTML))},x=e=>(j(e)&&!e.matches(g)&&e.setAttribute("data-ge-unit-kind",j(e)),e);function w(e){let t=[],o=null;for(let s of e.childNodes){let a=s.nodeType===1;(a?s.matches(st):s.nodeType!==3)||(a&&(s.matches(g)||F.has(s.localName))?(t.push(x(s)),o=null):(a||o||s.data.trim())&&(o||t.push(o=x(r.createElement("p"))),o.append(s.cloneNode(!0))))}return t}let y=e=>h[_(e).kind].list,C=e=>e.map(t=>t&&`${ot}${t}`);function k(e){let t=[],o=null;for(let s of e){let a=E(s);a.length!==0&&(o!==null&&!(y(o)&&y(s))&&t.push(""),t.push(...a),o=s)}return t}function S(e){let t=[];for(let o of e){let s=E(o);if(s.length===0)continue;let a=y(o);!a&&t.length>0&&t.at(-1)!==""&&t.push(""),!a&&t.length===0&&t.push(""),t.push(...C(s)),a||t.push("")}for(;t.at(-1)==="";)t.pop();return t}function J(e,t=null){let s=n(e).length>0?[]:h.words.exported(e,$,{without:t});return s.length>0?["",...C(s)]:S(w(e).filter(a=>a!==t))}function E(e){let t=_(e);return h[t.kind].exported(e,$,t)}function V(e,t){let o=/^en(?:-|$)/i.test(e.ownerDocument.documentElement.getAttribute("lang")??"");return t?o?"Chart":"\u56FE\u8868":o?"Figure":"\u56FE"}let $={isHost:m,nestedBlocks:c,serializeInner:l,media:f,chart:d,inline:p,own:z,withPictures:i,picturesIn:G,lines:k,held:S,heldIn:J,untitled:V,wordsIn:(e,t,o)=>et(b(e),t,o),plain:ct,unitsOf:w,words:e=>h.words.exported(e,$),packageOf:e=>R().packages.get(e),opening:(e,t)=>tt(e,t,$),writtenAs(e,t){let o=X(e);return h[o.kind].exported(t,$,o)}},I=r.querySelector(".doc-header"),O=I?k(w(I)):[],q=r.querySelector("main"),L=k(q?w(q):[]),Q=Y(r).flatMap(({element:e,clipboard:t})=>["",...h[t.kind].exported(e,$,t)]);return[`# ${u||"Untitled"}`,...O.length?["",...O]:[],...L.length?["",...L]:[],...Q].join(`
5
5
  `)}import{saying as lt}from"../browser/shared/i18n/index.mjs";import{referencedFile as pt}from"../browser/shared/media.mjs";var ft=r=>`\0F${r}\0`,mt=r=>`\0C${r}\0`,dt={async markdown({source:r,title:u,pictures:f}){let{document:d}=await W(r),g=[],n=[...d.querySelectorAll("main figure.doc-figure")];return{text:await K(d,{title:u,media:(c,m,p)=>{let i=pt(c);return i?ft(g.push({src:i,kind:m,name:p})-1):c},chart:c=>f&&n.includes(c)?mt(n.indexOf(c)):null}),files:g,charts:n.length,charted:n.map(c=>!!c.querySelector("[data-doc-chart]"))}},import:({uploads:r,scratch:u})=>B(r,u),fill:r=>H(r)};N.on("message",async({id:r,type:u,payload:f})=>{try{M(),N.postMessage({id:r,result:await dt[u](f)})}catch(d){N.postMessage({id:r,error:{...lt(d),stack:d.stack}})}});
package/kit/math.js CHANGED
@@ -3,7 +3,7 @@
3
3
  // src/render/kit/page-katex.js
4
4
  var page_katex_default = globalThis.katex;
5
5
 
6
- // node_modules/katex/contrib/mhchem/mhchem.js
6
+ // ../../../node_modules/katex/contrib/mhchem/mhchem.js
7
7
  page_katex_default.__defineMacro("\\ce", function(context) {
8
8
  return chemParse(context.consumeArgs(1)[0], "ce");
9
9
  });
package/kit/runtime.js CHANGED
@@ -1392,6 +1392,16 @@ ${indent}${list2 ? "]" : "}"}`;
1392
1392
  };
1393
1393
  }
1394
1394
 
1395
+ // src/shared/workspace-address.mjs
1396
+ var PROJECT = /^(\/~(ws-[0-9a-f]{6}))(?=\/|$)/;
1397
+ var projectOfPath = (pathname) => PROJECT.exec(pathname)?.[2] ?? null;
1398
+ var localPath = (pathname) => pathname.replace(PROJECT, "") || "/";
1399
+ var currentProjectBase = () => PROJECT.exec(globalThis.location?.pathname ?? "")?.[1] ?? "";
1400
+ function workspaceAddress(address, base = currentProjectBase()) {
1401
+ if (!base || typeof address !== "string" || projectOfPath(address)) return address;
1402
+ return /^\/(?:__gallery\/|generated\/|pages\/)/.test(address) ? base + address : address;
1403
+ }
1404
+
1395
1405
  // src/shared/page-links.mjs
1396
1406
  var DOC_SLUG = /^doc-([a-z][a-z0-9]{7})$/;
1397
1407
  function hashId(slug) {
@@ -1454,7 +1464,7 @@ ${indent}${list2 ? "]" : "}"}`;
1454
1464
  if (inFile) return known(inFile[1], decoded(inFile[2] ?? ""));
1455
1465
  const url = ownAddress(address);
1456
1466
  if (!url) return null;
1457
- const path = PAGE3.exec(url.pathname) ?? OWN_FILE.exec(url.pathname);
1467
+ const path = PAGE3.exec(localPath(url.pathname)) ?? OWN_FILE.exec(localPath(url.pathname));
1458
1468
  if (path) return known(path[1], decoded(url.hash.slice(1)));
1459
1469
  return url.pathname === "/" && url.hash.length > 1 ? hashAddress(decoded(url.hash.slice(1)), links) : null;
1460
1470
  }
@@ -1957,7 +1967,7 @@ ${indent}${list2 ? "]" : "}"}`;
1957
1967
  const detail = page ? { page } : { slug, block };
1958
1968
  const asked = new CustomEvent(OPEN_EVENT, { cancelable: true, detail });
1959
1969
  if (!globalThis.dispatchEvent(asked)) return;
1960
- globalThis.location.assign(page ? `/pages/${page}` : `/generated/${slug}.html${block ? `#${encodeURIComponent(block)}` : ""}`);
1970
+ globalThis.location.assign(workspaceAddress(page ? `/pages/${page}` : `/generated/${slug}.html${block ? `#${encodeURIComponent(block)}` : ""}`));
1961
1971
  }
1962
1972
  };
1963
1973
  if (place !== "export") {
package/kit/state.js CHANGED
@@ -11,6 +11,8 @@
11
11
  }
12
12
 
13
13
  function storageFor(key) {
14
+ const owner = /^\/(~ws-[0-9a-f]{6})(?=\/|$)/.exec(global.location?.pathname ?? "")?.[1];
15
+ if (owner) key = `gallery-project:${owner}:${key}`;
14
16
  return {
15
17
  key,
16
18
  read() {
package/kit/ui.js CHANGED
@@ -133,6 +133,10 @@ ${source}
133
133
  var GENERATORS = [GENERATOR, "HTML Report Studio"];
134
134
  var OWN_METAS = new RegExp(`<head\\b[^>]*>\\s*<meta name="generator" content="(?:${GENERATORS.join("|")})">\\s*<meta http-equiv="Content-Security-Policy" content="[^"]*">\\s*<meta name="${SOURCE_META}" content="sha256:([0-9a-f]{64})">(?:\\s*<meta name="${PACKAGES_META}" content="([^"]*)">)?`, "i");
135
135
 
136
+ // src/shared/workspace-address.mjs
137
+ var PROJECT = /^(\/~(ws-[0-9a-f]{6}))(?=\/|$)/;
138
+ var localPath = (pathname) => pathname.replace(PROJECT, "") || "/";
139
+
136
140
  // src/shared/page-links.mjs
137
141
  var DOC_SLUG = /^doc-([a-z][a-z0-9]{7})$/;
138
142
  function hashId(slug) {
@@ -196,7 +200,7 @@ ${source}
196
200
  if (inFile) return known(inFile[1], decoded(inFile[2] ?? ""));
197
201
  const url = ownAddress(address);
198
202
  if (!url) return null;
199
- const path = PAGE.exec(url.pathname) ?? OWN_FILE.exec(url.pathname);
203
+ const path = PAGE.exec(localPath(url.pathname)) ?? OWN_FILE.exec(localPath(url.pathname));
200
204
  if (path) return known(path[1], decoded(url.hash.slice(1)));
201
205
  return url.pathname === "/" && url.hash.length > 1 ? hashAddress(decoded(url.hash.slice(1)), links) : null;
202
206
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@heycys/gallery",
3
- "version": "0.2.1",
3
+ "version": "0.2.2",
4
4
  "description": "Gallery: documents written as HTML by an AI agent, shown and edited in the browser, delivered as one offline file. The gallery command and its local server.",
5
5
  "keywords": [
6
6
  "gallery",