@astl/astrolabe 0.1.2 → 0.1.4

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 (109) hide show
  1. package/CHANGELOG.md +30 -0
  2. package/dist/cdn/astrolabe-editor.js +3 -3
  3. package/dist/cdn/astrolabe-player.js +1 -1
  4. package/dist/cdn/astrolabe.js +1 -1
  5. package/dist/cdn/astrolabe.standalone.js +1094 -1060
  6. package/dist/cdn/chunks/{audio-B0LSIn5N.js → audio-Biof5aA3.js} +2 -2
  7. package/dist/cdn/chunks/{audio-B0LSIn5N.js.map → audio-Biof5aA3.js.map} +1 -1
  8. package/dist/cdn/chunks/{block-styles-CKo9x7Vt.js → block-styles-CCtSFM4j.js} +2 -2
  9. package/dist/cdn/chunks/{block-styles-CKo9x7Vt.js.map → block-styles-CCtSFM4j.js.map} +1 -1
  10. package/dist/cdn/chunks/{book-CHzDDaim.js → book-IFipARhv.js} +2 -2
  11. package/dist/cdn/chunks/{book-CHzDDaim.js.map → book-IFipARhv.js.map} +1 -1
  12. package/dist/cdn/chunks/{callout-QFLFLPc5.js → callout-CuajbbYY.js} +2 -2
  13. package/dist/cdn/chunks/{callout-QFLFLPc5.js.map → callout-CuajbbYY.js.map} +1 -1
  14. package/dist/cdn/chunks/{categorise-BO2tNVJ3.js → categorise-Cm6kXLXw.js} +2 -2
  15. package/dist/cdn/chunks/{categorise-BO2tNVJ3.js.map → categorise-Cm6kXLXw.js.map} +1 -1
  16. package/dist/cdn/chunks/{chip-styles-Dme5daTO.js → chip-styles--gboWK2Z.js} +2 -2
  17. package/dist/cdn/chunks/{chip-styles-Dme5daTO.js.map → chip-styles--gboWK2Z.js.map} +1 -1
  18. package/dist/cdn/chunks/{choice-CExBvqKj.js → choice-BSpB6LHl.js} +2 -2
  19. package/dist/cdn/chunks/{choice-CExBvqKj.js.map → choice-BSpB6LHl.js.map} +1 -1
  20. package/dist/cdn/chunks/{color-control-Cl5cuMSO.js → color-control-1kkdM8ns.js} +2 -2
  21. package/dist/cdn/chunks/{color-control-Cl5cuMSO.js.map → color-control-1kkdM8ns.js.map} +1 -1
  22. package/dist/cdn/chunks/{crossword-Cb-a3Tjj.js → crossword-BdOAEPcL.js} +2 -2
  23. package/dist/cdn/chunks/{crossword-Cb-a3Tjj.js.map → crossword-BdOAEPcL.js.map} +1 -1
  24. package/dist/cdn/chunks/{definitions-CNX90WtL.js → definitions-BybSa1mq.js} +2 -2
  25. package/dist/cdn/chunks/{definitions-CNX90WtL.js.map → definitions-BybSa1mq.js.map} +1 -1
  26. package/dist/cdn/chunks/{directive-helpers-D7lOZKnB.js → directive-helpers-US6zRjJ1.js} +2 -2
  27. package/dist/cdn/chunks/{directive-helpers-D7lOZKnB.js.map → directive-helpers-US6zRjJ1.js.map} +1 -1
  28. package/dist/cdn/chunks/{drop-vRXndjHu.js → drop-D4NQ0WK_.js} +2 -2
  29. package/dist/cdn/chunks/{drop-vRXndjHu.js.map → drop-D4NQ0WK_.js.map} +1 -1
  30. package/dist/cdn/chunks/{flash-cards-0NrrKdrx.js → flash-cards-D4ebb5m6.js} +2 -2
  31. package/dist/cdn/chunks/{flash-cards-0NrrKdrx.js.map → flash-cards-D4ebb5m6.js.map} +1 -1
  32. package/dist/cdn/chunks/{gap-lor-khst.js → gap-D-Sipuyu.js} +2 -2
  33. package/dist/cdn/chunks/{gap-lor-khst.js.map → gap-D-Sipuyu.js.map} +1 -1
  34. package/dist/cdn/chunks/{help-C-woafz5.js → help-CmCFuNXk.js} +2 -2
  35. package/dist/cdn/chunks/{help-C-woafz5.js.map → help-CmCFuNXk.js.map} +1 -1
  36. package/dist/cdn/chunks/{help-form-CDg3TCwI.js → help-form-Di2NtKDp.js} +14 -10
  37. package/dist/cdn/chunks/help-form-Di2NtKDp.js.map +1 -0
  38. package/dist/cdn/chunks/{hotspot-oel1Eelo.js → hotspot-B3bvqVzf.js} +2 -2
  39. package/dist/cdn/chunks/{hotspot-oel1Eelo.js.map → hotspot-B3bvqVzf.js.map} +1 -1
  40. package/dist/cdn/chunks/{image-drop-Dkprw0Kn.js → image-drop-vLc2B7rF.js} +2 -2
  41. package/dist/cdn/chunks/{image-drop-Dkprw0Kn.js.map → image-drop-vLc2B7rF.js.map} +1 -1
  42. package/dist/cdn/chunks/{image-label-Dm5shQSh.js → image-label-DsKxQDTQ.js} +2 -2
  43. package/dist/cdn/chunks/{image-label-Dm5shQSh.js.map → image-label-DsKxQDTQ.js.map} +1 -1
  44. package/dist/cdn/chunks/{inline-styles-CTgXWnHb.js → inline-styles-CFNlb6f2.js} +2 -2
  45. package/dist/cdn/chunks/{inline-styles-CTgXWnHb.js.map → inline-styles-CFNlb6f2.js.map} +1 -1
  46. package/dist/cdn/chunks/{insert-menu-7vANVmTK.js → insert-menu-DAQglwtG.js} +2 -2
  47. package/dist/cdn/chunks/{insert-menu-7vANVmTK.js.map → insert-menu-DAQglwtG.js.map} +1 -1
  48. package/dist/cdn/chunks/{issue-list-BT9qvnZU.js → issue-list-CzSmohtT.js} +2 -2
  49. package/dist/cdn/chunks/{issue-list-BT9qvnZU.js.map → issue-list-CzSmohtT.js.map} +1 -1
  50. package/dist/cdn/chunks/{live-jdiyYln2.js → live-qnReIRtj.js} +2 -2
  51. package/dist/cdn/chunks/{live-jdiyYln2.js.map → live-qnReIRtj.js.map} +1 -1
  52. package/dist/cdn/chunks/{long-answer-CtzClLAx.js → long-answer-NSWJiK0z.js} +2 -2
  53. package/dist/cdn/chunks/{long-answer-CtzClLAx.js.map → long-answer-NSWJiK0z.js.map} +1 -1
  54. package/dist/cdn/chunks/{mark-words-CpH3gTcX.js → mark-words-BKu-_uIl.js} +2 -2
  55. package/dist/cdn/chunks/{mark-words-CpH3gTcX.js.map → mark-words-BKu-_uIl.js.map} +1 -1
  56. package/dist/cdn/chunks/{match-DKE_4o-x.js → match-BpnJGW_5.js} +21 -13
  57. package/dist/cdn/chunks/match-BpnJGW_5.js.map +1 -0
  58. package/dist/cdn/chunks/{memory-B6hSyHyz.js → memory-BgTHujsU.js} +2 -2
  59. package/dist/cdn/chunks/{memory-B6hSyHyz.js.map → memory-BgTHujsU.js.map} +1 -1
  60. package/dist/cdn/chunks/messages-Qzse5KMX.js +2 -0
  61. package/dist/cdn/chunks/messages-Qzse5KMX.js.map +1 -0
  62. package/dist/cdn/chunks/{option-styles-WKzjKmCH.js → option-styles-B2sBX5Oz.js} +2 -2
  63. package/dist/cdn/chunks/{option-styles-WKzjKmCH.js.map → option-styles-B2sBX5Oz.js.map} +1 -1
  64. package/dist/cdn/chunks/{order-BhG_6IC-.js → order-B9gqH5wm.js} +2 -2
  65. package/dist/cdn/chunks/{order-BhG_6IC-.js.map → order-B9gqH5wm.js.map} +1 -1
  66. package/dist/cdn/chunks/{picture-view-BKnAyScQ.js → picture-view-Deodu_mb.js} +2 -2
  67. package/dist/cdn/chunks/{picture-view-BKnAyScQ.js.map → picture-view-Deodu_mb.js.map} +1 -1
  68. package/dist/cdn/chunks/{repeat-CY2W2URZ.js → repeat-BDXokpxQ.js} +2 -2
  69. package/dist/cdn/chunks/{repeat-CY2W2URZ.js.map → repeat-BDXokpxQ.js.map} +1 -1
  70. package/dist/cdn/chunks/{runtime-DxAbpr3S.js → runtime-C25QK5B0.js} +3 -3
  71. package/dist/cdn/chunks/{runtime-DxAbpr3S.js.map → runtime-C25QK5B0.js.map} +1 -1
  72. package/dist/cdn/chunks/{scan-jWgPnVxA.js → scan-BVhxT2Hw.js} +2 -2
  73. package/dist/cdn/chunks/{scan-jWgPnVxA.js.map → scan-BVhxT2Hw.js.map} +1 -1
  74. package/dist/cdn/chunks/{select-DTA3dJzr.js → select-DPpKJwSg.js} +2 -2
  75. package/dist/cdn/chunks/{select-DTA3dJzr.js.map → select-DPpKJwSg.js.map} +1 -1
  76. package/dist/cdn/chunks/select-QZ35cyns.js +2 -0
  77. package/dist/cdn/chunks/select-QZ35cyns.js.map +1 -0
  78. package/dist/cdn/chunks/{source-view-CZVxgTNQ.js → source-view-gqFlZzwR.js} +2 -2
  79. package/dist/cdn/chunks/{source-view-CZVxgTNQ.js.map → source-view-gqFlZzwR.js.map} +1 -1
  80. package/dist/cdn/chunks/{style-form-DUGbG_kL.js → style-form-DuR0EEum.js} +2 -2
  81. package/dist/cdn/chunks/{style-form-DUGbG_kL.js.map → style-form-DuR0EEum.js.map} +1 -1
  82. package/dist/cdn/chunks/{style-messages-qdf3pZbT.js → style-messages-B136zSom.js} +2 -2
  83. package/dist/cdn/chunks/{style-messages-qdf3pZbT.js.map → style-messages-B136zSom.js.map} +1 -1
  84. package/dist/cdn/chunks/{style-popups-BobgX1WK.js → style-popups-Bcl5imdP.js} +2 -2
  85. package/dist/cdn/chunks/{style-popups-BobgX1WK.js.map → style-popups-Bcl5imdP.js.map} +1 -1
  86. package/dist/cdn/chunks/{style-rules-D17QGzXk.js → style-rules-ozpLz2ec.js} +2 -2
  87. package/dist/cdn/chunks/{style-rules-D17QGzXk.js.map → style-rules-ozpLz2ec.js.map} +1 -1
  88. package/dist/cdn/chunks/{styled-Dmx5Yjv7.js → styled-bQqnDxBf.js} +2 -2
  89. package/dist/cdn/chunks/{styled-Dmx5Yjv7.js.map → styled-bQqnDxBf.js.map} +1 -1
  90. package/dist/cdn/chunks/{styles-CdJT6Pp9.js → styles-DiY3VA_T.js} +5 -5
  91. package/dist/cdn/chunks/styles-DiY3VA_T.js.map +1 -0
  92. package/dist/cdn/chunks/surface-CIz1z2oY.js +1059 -0
  93. package/dist/cdn/chunks/surface-CIz1z2oY.js.map +1 -0
  94. package/dist/cdn/chunks/{true-false-DP3MO599.js → true-false-C-S6RmZY.js} +2 -2
  95. package/dist/cdn/chunks/{true-false-DP3MO599.js.map → true-false-C-S6RmZY.js.map} +1 -1
  96. package/dist/cdn/chunks/{video-j9MCH6Kw.js → video-Dae8Gguf.js} +2 -2
  97. package/dist/cdn/chunks/{video-j9MCH6Kw.js.map → video-Dae8Gguf.js.map} +1 -1
  98. package/dist/cdn/chunks/{word-bank-ARjwUKZf.js → word-bank-CsIle0Ro.js} +2 -2
  99. package/dist/cdn/chunks/{word-bank-ARjwUKZf.js.map → word-bank-CsIle0Ro.js.map} +1 -1
  100. package/dist/cdn/chunks/{word-search-AHvM7yCJ.js → word-search-IOCwqo3y.js} +2 -2
  101. package/dist/cdn/chunks/{word-search-AHvM7yCJ.js.map → word-search-IOCwqo3y.js.map} +1 -1
  102. package/package.json +9 -9
  103. package/dist/cdn/chunks/help-form-CDg3TCwI.js.map +0 -1
  104. package/dist/cdn/chunks/match-DKE_4o-x.js.map +0 -1
  105. package/dist/cdn/chunks/messages-D1aJfyS_.js +0 -2
  106. package/dist/cdn/chunks/messages-D1aJfyS_.js.map +0 -1
  107. package/dist/cdn/chunks/styles-CdJT6Pp9.js.map +0 -1
  108. package/dist/cdn/chunks/surface-C6wtQkTY.js +0 -1037
  109. package/dist/cdn/chunks/surface-C6wtQkTY.js.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"inline-styles-CTgXWnHb.js","names":["i","visuallyHidden","verdictStyles","inlineStyles"],"sources":["../../../../components/src/inline-styles.ts"],"sourcesContent":["/**\n * Shared CSS of the built-in fields in running text (`display: 'inline'`); question blocks take `block-styles.ts`\n * (why two files, and why an element lists these after its own rules: see there).\n */\nimport { verdictStyles, visuallyHidden } from '@astl/player';\nimport { type CSSResultGroup, css } from 'lit';\n\nexport const inlineStyles: CSSResultGroup = [\n visuallyHidden,\n verdictStyles,\n // Inline, so the field is part of the sentence: widths in percent refer to the line, the solution wraps like text\n // and a following full stop stays attached. `hidden` hides it. The focused control shows the focus ring inside its\n // edge, a pixel deeper than its width, over the inner part of its border: outside, it would cover the full stop right\n // after the field and the lines above and below, and room for it would move the text. A pixel deeper, it thickens the\n // frame even where the ring and the border share a colour (hc).\n css`\n :host {\n display: inline;\n }\n :host([hidden]) {\n display: none;\n }\n :focus-visible {\n outline: var(--astl-focus-width) solid var(--astl-focus);\n outline-offset: calc(-1px - var(--astl-focus-width));\n }\n `,\n // The field and its verdict icon never part. The control looks like a text field, on the text's baseline, a little\n // taller than the text (at least 24 px: the WCAG 2.5.8 inline exception) and a little apart from the lines above and\n // below, so fields on two lines never touch. An answer too long for its field ends in an ellipsis. A read-only\n // textarea wraps its answer (the field's nowrap would otherwise reach it) and is as tall as its lines (no input\n // minimum). Without field-sizing (Safari before 26.2, Firefox before 152) it keeps its rows and scrolls, so no\n // answer is cut off. A hair of room after the field (inside the tail the fields keep for punctuation), so a comma or\n // a full stop after it never touches its edge.\n css`\n .field {\n margin-inline-end: 0.2em;\n white-space: nowrap;\n }\n .control {\n box-sizing: border-box;\n min-block-size: 1.75em;\n margin-block: 0.125em;\n margin-inline: 0;\n padding-block: 0;\n border: var(--astl-outline-width) solid var(--astl-outline);\n border-radius: var(--astl-radius-s);\n background: var(--astl-surface);\n color: var(--astl-ink);\n font: inherit;\n line-height: 1.4;\n text-overflow: ellipsis;\n vertical-align: baseline;\n }\n textarea.control {\n min-block-size: 0;\n resize: none;\n white-space: pre-wrap;\n overflow-wrap: anywhere;\n }\n @supports not (field-sizing: content) {\n textarea.control {\n overflow-y: auto;\n }\n }\n `,\n // A placeholder in the muted ink, as in every field. Read-only without verdicts (review): an answer written on a\n // line, plainly not a box to type in or pick from.\n css`\n .control::placeholder {\n color: var(--astl-ink-muted);\n opacity: 1;\n }\n .control[readonly] {\n cursor: default;\n }\n .control[readonly]:not([data-verdict]) {\n border-color: transparent;\n border-block-end-color: var(--astl-outline);\n border-radius: 0;\n background: transparent;\n }\n .control[data-verdict] {\n border-color: var(--astl-verdict-color);\n border-style: var(--astl-verdict-border);\n background: var(--astl-verdict-soft);\n }\n `,\n // The verdict icon's spacing is padding, so its box is exactly the room the field leaves for it. The solution is the\n // \"correct answer\" line of block-styles.ts in running text: the tick in the success colour, then the answer in ink\n // (its label is read, not shown), so it never reads as the answer the verdict before it marks. No end spacing: the\n // full stop after the field follows it directly.\n css`\n .field > .astl-verdict {\n padding-inline-start: var(--astl-space-1);\n vertical-align: middle;\n }\n .solution {\n margin-inline-start: var(--astl-space-1);\n color: var(--astl-ink);\n font-weight: 600;\n overflow-wrap: anywhere;\n hyphens: auto;\n }\n .solution > .astl-verdict-icon {\n margin-inline-end: 0.15em;\n color: var(--astl-success);\n vertical-align: -0.15em;\n }\n `,\n];\n"],"mappings":"A,wDAOA,IAAaG,EAA+B,CAC1CF,EACAC,EAMA,CAAG;;;;;;;;;;;EAmBH,CAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAkCH,CAAG;;;;;;;;;;;;;;;;;;;EAwBH,CAAG;;;;;;;;;;;;;;;;;CAkBL,E"}
1
+ {"version":3,"file":"inline-styles-CFNlb6f2.js","names":["i","visuallyHidden","verdictStyles","inlineStyles"],"sources":["../../../../components/src/inline-styles.ts"],"sourcesContent":["/**\n * Shared CSS of the built-in fields in running text (`display: 'inline'`); question blocks take `block-styles.ts`\n * (why two files, and why an element lists these after its own rules: see there).\n */\nimport { verdictStyles, visuallyHidden } from '@astl/player';\nimport { type CSSResultGroup, css } from 'lit';\n\nexport const inlineStyles: CSSResultGroup = [\n visuallyHidden,\n verdictStyles,\n // Inline, so the field is part of the sentence: widths in percent refer to the line, the solution wraps like text\n // and a following full stop stays attached. `hidden` hides it. The focused control shows the focus ring inside its\n // edge, a pixel deeper than its width, over the inner part of its border: outside, it would cover the full stop right\n // after the field and the lines above and below, and room for it would move the text. A pixel deeper, it thickens the\n // frame even where the ring and the border share a colour (hc).\n css`\n :host {\n display: inline;\n }\n :host([hidden]) {\n display: none;\n }\n :focus-visible {\n outline: var(--astl-focus-width) solid var(--astl-focus);\n outline-offset: calc(-1px - var(--astl-focus-width));\n }\n `,\n // The field and its verdict icon never part. The control looks like a text field, on the text's baseline, a little\n // taller than the text (at least 24 px: the WCAG 2.5.8 inline exception) and a little apart from the lines above and\n // below, so fields on two lines never touch. An answer too long for its field ends in an ellipsis. A read-only\n // textarea wraps its answer (the field's nowrap would otherwise reach it) and is as tall as its lines (no input\n // minimum). Without field-sizing (Safari before 26.2, Firefox before 152) it keeps its rows and scrolls, so no\n // answer is cut off. A hair of room after the field (inside the tail the fields keep for punctuation), so a comma or\n // a full stop after it never touches its edge.\n css`\n .field {\n margin-inline-end: 0.2em;\n white-space: nowrap;\n }\n .control {\n box-sizing: border-box;\n min-block-size: 1.75em;\n margin-block: 0.125em;\n margin-inline: 0;\n padding-block: 0;\n border: var(--astl-outline-width) solid var(--astl-outline);\n border-radius: var(--astl-radius-s);\n background: var(--astl-surface);\n color: var(--astl-ink);\n font: inherit;\n line-height: 1.4;\n text-overflow: ellipsis;\n vertical-align: baseline;\n }\n textarea.control {\n min-block-size: 0;\n resize: none;\n white-space: pre-wrap;\n overflow-wrap: anywhere;\n }\n @supports not (field-sizing: content) {\n textarea.control {\n overflow-y: auto;\n }\n }\n `,\n // A placeholder in the muted ink, as in every field. Read-only without verdicts (review): an answer written on a\n // line, plainly not a box to type in or pick from.\n css`\n .control::placeholder {\n color: var(--astl-ink-muted);\n opacity: 1;\n }\n .control[readonly] {\n cursor: default;\n }\n .control[readonly]:not([data-verdict]) {\n border-color: transparent;\n border-block-end-color: var(--astl-outline);\n border-radius: 0;\n background: transparent;\n }\n .control[data-verdict] {\n border-color: var(--astl-verdict-color);\n border-style: var(--astl-verdict-border);\n background: var(--astl-verdict-soft);\n }\n `,\n // The verdict icon's spacing is padding, so its box is exactly the room the field leaves for it. The solution is the\n // \"correct answer\" line of block-styles.ts in running text: the tick in the success colour, then the answer in ink\n // (its label is read, not shown), so it never reads as the answer the verdict before it marks. No end spacing: the\n // full stop after the field follows it directly.\n css`\n .field > .astl-verdict {\n padding-inline-start: var(--astl-space-1);\n vertical-align: middle;\n }\n .solution {\n margin-inline-start: var(--astl-space-1);\n color: var(--astl-ink);\n font-weight: 600;\n overflow-wrap: anywhere;\n hyphens: auto;\n }\n .solution > .astl-verdict-icon {\n margin-inline-end: 0.15em;\n color: var(--astl-success);\n vertical-align: -0.15em;\n }\n `,\n];\n"],"mappings":"A,wDAOA,IAAaG,EAA+B,CAC1CF,EACAC,EAMA,CAAG;;;;;;;;;;;EAmBH,CAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAkCH,CAAG;;;;;;;;;;;;;;;;;;;EAwBH,CAAG;;;;;;;;;;;;;;;;;CAkBL,E"}
@@ -1,4 +1,4 @@
1
- import{H as e,M as t,W as n}from"./definitions-CNX90WtL.js";import{$ as r,C as i,E as a,It as o,Q as s,T as c,Tt as l,an as u,b as d,dn as f,fn as p,jt as m,lt as h,mn as g,on as _,rt as v}from"./runtime-DxAbpr3S.js";import{o as y,s as b}from"./declarations-BhqOz1ap.js";import{a as x,c as S,d as C,i as w,l as T,n as E,o as D,r as O,s as k,t as A,u as ee}from"./scan-jWgPnVxA.js";import{n as te,t as j}from"./messages-D1aJfyS_.js";import{n as ne,o as re,r as ie,t as ae}from"./style-model-ZXNe_c8R.js";import{n as oe,r as M,t as N}from"./styles-CdJT6Pp9.js";var P=/^[a-z][a-z0-9-]*$/;function F(e,t,n,r){if(!P.test(n))throw TypeError(`Invalid attribute name "${n}"`);let i=t.attributes.filter(e=>e.name===n),a=i[0];if(r===null||r===!1)return i.map(t=>({start:T(e,t.start),end:t.end,text:``}));if(a!==void 0){let e=E(t,n)??``;if(r===!0?e===``||e.toLowerCase()===n:e===r)return[]}let o=r===!0?n:`${n}="${w(r)}"`;if(a!==void 0)return[{start:a.start,end:a.end,text:o}];let s=t.attributes[t.attributes.length-1]?.end??t.start+1+t.name.length;return[{start:s,end:s,text:` ${o}`}]}function I(e,t){return e.children.flatMap(e=>e.name===t?[e]:I(e,t))}function L(t,n){let[r]=e(t.slice(n.start,n.end));return p(r)?g(r):``}function R(e){return e.endTag?.start??e.end}function z(e,t,n){let r=t.startTag;if(r.selfClosing&&t.endTag===null){let i=e.slice(r.start,T(e,r.end-2));return{start:t.start,end:t.end,text:`${i}>${n}</${t.name}>`}}return{start:r.end,end:R(t),text:n}}function B(e,t,n){return t.startTag.selfClosing&&t.endTag===null?z(e,t,n):t.endTag===null?{start:t.end,end:t.end,text:`${n}</${t.name}>`}:{start:t.endTag.start,end:t.endTag.start,text:n}}function se(e,t,n){let[r,i]=n;if(r===void 0)return``;let a=i===void 0?e.slice(Math.max(t.startTag.end,T(e,r.start)),r.start):e.slice(r.end,i.start);return/^\s*$/.test(a)?a:``}function ce(e,t,n,r){let i=I(t,n),a=[];if(i.forEach((t,n)=>{let i=r[n];i===void 0?a.push({start:T(e,t.start),end:t.end,text:``}):L(e,t)!==i&&a.push(z(e,t,D(i)))}),r.length>i.length){let o=se(e,t,i),s=r.slice(i.length).map(e=>`<${n}>${D(e)}</${n}>`),c=i[i.length-1];c===void 0?a.push(B(e,t,s.join(o))):a.push({start:c.end,end:c.end,text:s.map(e=>o+e).join(``)})}return a}function V(e,t){let n=O(e)[0];if(n===void 0)return e;switch(t.kind){case`attribute`:return A(e,F(e,n.startTag,t.name,t.value));case`child-flag`:case`child-choice`:{let r=I(n,t.tag)[t.index];return r===void 0?e:A(e,F(e,r.startTag,t.attribute,t.value))}case`text-list`:return A(e,ce(e,n,t.tag,t.values));case`child-attributes`:{let n=e;for(let[e,r]of Object.entries(t.attributes))n=V(n,{kind:`child-choice`,tag:t.tag,attribute:e,index:t.index,value:r});return n}case`child-add`:{if(!P.test(t.tag))throw TypeError(`Invalid tag name "${t.tag}"`);let r=Object.entries(t.attributes).map(([e,t])=>{if(!P.test(e))throw TypeError(`Invalid attribute name "${e}"`);return` ${e}="${w(t)}"`}),i=`<${t.tag}${r.join(``)}></${t.tag}>`,a=I(n,t.tag),o=a.at(-1)??n.children.at(-1);if(o===void 0)return A(e,[B(e,n,i)]);let s=se(e,n,a.length>0?a:n.children);return A(e,[{start:o.end,end:o.end,text:s+i}])}case`child-remove`:{let r=I(n,t.tag)[t.index];return r===void 0?e:A(e,[{start:T(e,r.start),end:r.end,text:``}])}}}var H=(e,t)=>Object.hasOwn(e.attrs,t)?e.attrs[t]??``:null,U=(e,t)=>e.children.flatMap(e=>e.type===`element`?e.tag===t?[e]:U(e,t):[]);function le(e){let t=e=>({kind:`attribute`,name:e.name,label:`editor.${e.name}`}),n=e=>e.visibility!==`derived`,i=e.scoring===null?[]:[`scoring`,`points`],a=r(e).filter(e=>i.includes(e.name));return[...e.attributes.filter(n).map(t),...e.children.filter(e=>e.visibility===`private`&&e.content===`text`).map(e=>({kind:`text-list`,tag:e.tag,label:`editor.${e.tag}`})),...e.children.flatMap(e=>e.attributes.filter(e=>(e.type===`boolean`||e.type===`enum`)&&n(e)).map(t=>({kind:t.type===`boolean`?`child-flag`:`child-choice`,tag:e.tag,attribute:t.name,label:`editor.${e.tag}.${t.name}`}))),...a.map(t)]}function ue(e,t,n){return(t.name===`scoring`&&e.scoring!==null?Object.keys(e.scoring.modes):[...t.values??[]]).map(e=>({value:e,label:n.message(`editor.value.${t.name}.${e}`,e)}))}function de(e,t){return t.name===`scoring`&&e.scoring!==null?e.scoring.default:t.default===void 0?null:String(t.default)}function fe(e,t,n,i,a=n.name,o=()=>null){let s=r(t).find(e=>e.name===n.name);if(s===void 0)return null;let c=s.name,l=i.message(n.label,a),u=n.help===void 0?null:i.message(n.help,``),d={kind:`attribute`,name:c,label:l,help:u===``?null:u},f=H(e,c),p=s.required===!0,m=n.options===void 0?null:o(H(e,n.options.from)??``);if(m!==null&&n.options!==void 0){let e=f??``;return{...d,control:`select`,value:e,options:ye(m,n.options.tag,i)(e)}}let h=c===`scoring`&&t.scoring!==null;if(s.type===`enum`||h){let e=ue(t,s,i),n=f??de(t,s)??``;return n===``&&!e.some(e=>e.value===``)?e.unshift({value:``,label:i.unset}):e.some(e=>e.value===n)||e.push({value:n,label:n}),{...d,control:`select`,value:n,options:e}}if(s.type===`number`||s.type===`integer`)return{...d,control:`number`,value:f??de(t,s)??``,min:s.min??null,max:s.max??null,step:s.type===`integer`?`1`:`any`,required:p};if(s.type===`boolean`)return{...d,control:`checkbox`,checked:f!==null};let g=s.type===`url`?n.accept??null:null;return{...d,control:`text`,value:f??``,required:p,accept:g}}function pe(e){return new Map(e.flatMap(e=>e.kind===`picture-regions`||e.kind===`picture-points`?[[e.tag,e.kind]]:[]))}function me(e,t){let n=e.children.find(e=>e.tag===t)?.attributes.find(e=>e.name===`shape`);if(n===void 0)return[`rect`];let r=[`rect`,`circle`,`polygon`].filter(e=>n.values?.includes(e));return r.length>0?r:[`rect`]}function he(e,t,n,r,i=[n],a=()=>null){let o=n.help===void 0?null:r.message(n.help,``)||null,s=`tag`in n?pe(i).get(n.tag):void 0,c=(e,t)=>G(e,t,r,s);switch(n.kind){case`attribute`:return fe(e,t,n,r,n.name,a);case`text-list`:return{kind:`text-list`,tag:n.tag,label:r.message(n.label,n.tag),help:o,values:U(e,n.tag).map(g),max:t.children.find(e=>e.tag===n.tag)?.max??null,multiline:n.multiline===!0};case`child-flag`:{let t=U(e,n.tag).map((e,t)=>({index:t,id:H(e,`id`),label:c(e,t),checked:H(e,n.attribute)!==null})),i={count:t.length,checked:t.filter(e=>e.checked).length},a=`${n.tag} ${n.attribute}`,o=n.help===void 0?null:r.message(n.help,``,i)||null;return{kind:`child-flag`,tag:n.tag,attribute:n.attribute,label:r.message(n.label,a,i),help:o,children:t}}case`child-text`:return{kind:`child-text`,tag:n.tag,attribute:n.attribute,label:r.message(n.label,`${n.tag} ${n.attribute}`),help:o,children:U(e,n.tag).map((e,t)=>({index:t,id:H(e,`id`),label:c(e,t),value:H(e,n.attribute)??``}))};case`child-choice`:{let i=be(e,t,n,r);return i===null?null:{kind:`child-choice`,tag:n.tag,attribute:n.attribute,label:r.message(n.label,`${n.tag} ${n.attribute}`),help:o,control:i.control,children:U(e,n.tag).map((e,t)=>{let r=H(e,n.attribute)??``,a=i.options(r);return{index:t,id:H(e,`id`),label:c(e,t),value:r,options:a}})}}case`child-table`:return ge(e,t,n,r,o);case`picture-regions`:case`picture-points`:{let a={tag:n.tag,label:r.message(n.label,n.tag),help:o,elementTag:e.tag,srcAttribute:n.src,src:H(e,n.src)??``},s=U(e,n.tag);if(n.kind===`picture-points`)return{...a,kind:`picture-points`,points:s.map((e,t)=>({index:t,id:H(e,`id`)??``,x:W(H(e,`x`)),y:W(H(e,`y`)),label:H(e,`label`)??``}))};let c=i.find(e=>e.kind===`child-flag`&&e.tag===n.tag),l=c!==void 0&&`attribute`in c?c.attribute:null;return{...a,kind:`picture-regions`,shapes:me(t,n.tag),flag:l,regions:s.map((e,t)=>{let n=H(e,`shape`);return{index:t,id:H(e,`id`)??``,shape:n===`circle`||n===`polygon`?n:`rect`,x:W(H(e,`x`)),y:W(H(e,`y`)),width:W(H(e,`width`)),height:W(H(e,`height`)),r:W(H(e,`r`)),points:_e(H(e,`points`)),label:H(e,`label`)??``,flagged:l!==null&&H(e,l)!==null}})}}}}function ge(e,t,n,r,i){let a=t.children.find(e=>e.tag===n.tag);if(a===void 0)return null;let o=n.columns.flatMap(e=>{let t=a.attributes.find(t=>t.name===e.attribute);if(t===void 0)return[];let n=t.type===`integer`||t.type===`number`;return[{attribute:t.name,label:r.message(e.label,t.name),control:t.type===`enum`?`select`:n?`number`:`text`,options:(t.values??[]).map(e=>({value:e,label:r.message(`editor.value.${t.name}.${e}`,e)})),min:t.min??null,max:t.max??null,step:t.type===`integer`?`1`:`any`,required:t.required===!0}]}),s=U(e,n.tag),c=n.tag.replace(/^astl-/,``),l=new Set(s.map(e=>H(e,`id`))),u=s.length+1;for(;l.has(`${c}-${u}`);)u++;let d={id:`${c}-${u}`};for(let e of a.attributes)e.required===!0&&e.name!==`id`&&(d[e.name]=e.values?.[0]??(e.min===void 0?``:String(e.min)));return{kind:`child-table`,tag:n.tag,label:r.message(n.label,n.tag),help:i,columns:o,rows:s.map((e,t)=>({index:t,id:H(e,`id`),label:G(e,t,r),values:o.map(t=>H(e,t.attribute)??``)})),added:d,min:a.min,max:a.max}}function W(e){let t=Number.parseFloat(e??``);return Number.isFinite(t)?Math.min(100,Math.max(0,t)):0}function _e(e){return(e??``).trim().split(/\s+/).filter(e=>e!==``).map(e=>{let[t=``,n=``]=e.split(`,`);return[W(t),W(n)]})}var ve=e=>e.type===`text`?e.value:e.tag===`img`?` ${e.attrs.alt??``} `:e.children.map(ve).join(``);function G(e,t,n,r){let i=ve(e).replace(/\s+/g,` `).trim();return i!==``||r===void 0?i||n.untitled(t+1):(H(e,`label`)??``).replace(/\s+/g,` `).trim()||(r===`picture-regions`?n.region(t+1):n.point(t+1))}function ye(e,t,n){let r=U(e,t).flatMap((e,t)=>{let r=H(e,`id`);return r===null||r===``?[]:[{value:r,label:G(e,t,n)}]});return e=>e===``?[{value:``,label:n.unset},...r]:r.some(t=>t.value===e)?r:[...r,{value:e,label:e}]}function be(e,t,n,r){if(n.options===void 0){let e=t.children.find(e=>e.tag===n.tag)?.attributes.find(e=>e.name===n.attribute);if(e?.type!==`enum`)return null;let i=(e.values??[]).map(t=>({value:t,label:r.message(`editor.value.${e.name}.${t}`,t)}));return{control:`radios`,options:()=>i}}return{control:`select`,options:ye(e,n.options,r)}}function xe(e,t,n,r){let i=H(e,`style-template`)??``,a=[{value:``,label:n},...r];return a.some(e=>e.value===i)||a.push({value:i,label:i}),{kind:`attribute`,control:`select`,name:v,label:t,help:null,value:i,options:a}}function Se(e,t){if(t.variants===null)return null;let n=H(e,`variant`);return n!==null&&t.variants.values.includes(n)?n:t.variants.default}function Ce(e,t){return e.kind!==`attribute`||e.variants===void 0||e.variants.includes(t??``)}function we(e,t,n,r,i){let a=e=>n.some(t=>t.kind===`attribute`&&t.name===e),o=[];if(t.variants!==null&&!a(`variant`)){let n=fe(e,t,{kind:`attribute`,name:`variant`,label:`editor.variant`},r,r.variant);n!==null&&o.push(n)}let s=H(e,v)!==null;if((i.length>0||s)&&!a(`style-template`)){let t=r.message(`editor.${v}`,r.styleTemplate);o.push(xe(e,t,r.sameAsDocument,i))}return o}function Te(e,t,n,r,i=[],a=()=>null){let o=n?.fields??le(t),s=Se(e,t),c=o.filter(e=>Ce(e,s)).flatMap(n=>he(e,t,n,r,o,a)??[]);return{tag:e.tag,id:H(e,`id`),label:n===null?e.tag:r.message(n.label,e.tag),icon:n?.icon??null,fields:[...c,...we(e,t,c,r,i)]}}function Ee(e){let t=y(`font-family: ${e.stack}`).declarations[0]?.[1];if(t===void 0)throw TypeError(`Font "${e.name}": the style allow-list refuses its stack`);return{name:e.name,stack:t}}function De(e,t){let n=new Set;return e.map(e=>{let{name:r}=e;if(!b(r))throw TypeError(`Style "${r}": not a style name`);if(n.has(r))throw TypeError(`Style "${r}" is given twice`);n.add(r);let{style:i,removed:a}=y(e.style);if(a.length>0)throw TypeError(`Style "${r}": the style allow-list refuses ${a.join(`, `)}`);return{...e,style:i,label:e.label??t(r)}})}var Oe=class extends Error{constructor(e,t){super(e,t),this.name=`UploadRefused`}};function ke(e){return e instanceof Error&&e.name===`UploadRefused`&&e.message.trim()!==``?e.message:void 0}function Ae(e){let t=typeof e==`number`?e:typeof e==`string`&&/^[1-9]\d*$/.test(e)?Number(e):NaN;return Number.isSafeInteger(t)&&t>0?t:void 0}function K(e){let t=(e,t)=>{let n=Ae(t);return n===void 0?``:` ${e}="${n}"`},n=`<img src="${x(String(e.src))}" alt="${x(String(e.alt))}"${t(`width`,e.width)}${t(`height`,e.height)}>`,r=String(e.caption??``).trim();return r===``?n:`<figure>${n}<figcaption>${x(r)}</figcaption></figure>`}function je(){let e=crypto.getRandomValues(new Uint8Array(16));return`preview-${Array.from(e,e=>e.toString(16).padStart(2,`0`)).join(``)}`}var Me=/^[a-z][a-z0-9]*(?:-[a-z0-9]+)*$/;function q(e,t){for(let n=1;;n++){let r=`${e}-${n}`;if(!t.has(r))return r}}var J=e=>e.flatMap(e=>p(e,`astl-style`)?J(e.children):[e]);function Ne(e){return e.find(e=>e.type===`element`)??null}var Pe=Number(s.find(e=>e.name===`points`)?.default??1);function Y(e){let t=e.filter(e=>e!==null);return t.length===0?null:Math.round(t.reduce((e,t)=>e+t,0)*100)/100}function X(e,t){let n={errors:0,warnings:0};for(let r of e)t(r)&&(r.severity===`error`?n.errors++:n.warnings++);return n}function Fe(r){let{engine:i,locale:a}=r,s=new Map(i.manifests.map(e=>[e.tag,e])),c=new Map;for(let e of r.descriptors){let t=e.manifest.tag;if(c.has(t))throw TypeError(`Editor descriptor for <${t}> is given twice`);if(!s.has(t))throw TypeError(`Editor descriptor <${t}> has no component in the engine`);if(!o(`${e.idPrefix}-1`))throw TypeError(`Editor descriptor <${t}>: idPrefix "${e.idPrefix}" does not make valid ids`);let n=(e.templates??[]).map(e=>e.id);if(n.some((e,t)=>!Me.test(e)||n.indexOf(e)!==t))throw TypeError(`Editor descriptor <${t}>: template ids must be distinct kebab-case names`);c.set(t,e)}let d=r.styleTemplates??[],g=e=>h({catalogs:[...te,...t,...r.descriptors.flatMap(e=>e.messages??[]),...e,...d.flatMap(e=>e.catalogs??[]),...r.catalogs??[]]}),y=g([]),b=[],w=e=>{let t=e.filter(e=>!b.includes(e));t.length!==0&&(b=[...b,...t],y=g(b))},T=null,D=(e,t,n)=>y.t(a,e,t,n),re=e=>c.get(e)?.manifest??s.get(e)??null,ie=je(),oe=e=>({message:(t,n,r)=>{let i=D(e.messages,t,r);return i===t?n:i},unset:D(j,`inspector.unset`),untitled:e=>D(j,`inspector.untitled`,{n:e}),region:e=>D(j,`field.region`,{n:e}),point:e=>D(j,`field.point`,{n:e}),variant:D(j,`inspector.variant`),styleTemplate:D(j,`inspector.styleTemplate`),sameAsDocument:D(j,`inspector.styleTemplate.inherit`)}),M=(e,t)=>d.filter(n=>n.scopes.includes(e)&&(t===void 0||n.components===void 0||n.components.includes(t))).map(e=>{let t=D(e.messages,`label`);return{value:e.name,label:t===`label`?e.name:t}}),N=e=>{let t=c.get(e);if(t===void 0)return e;let n=D(t.manifest.messages,t.label);return n===t.label?e:n},P=e=>{if(s.get(e.tag)?.graded!==!0)return null;let t=Object.hasOwn(e.attrs,`points`)?Number(e.attrs.points):NaN;return Number.isFinite(t)&&t>0?t:Pe},F=t=>{let{issues:n}=i.validate(t),r=e=>Object.hasOwn(e.attrs,`id`)?e.attrs.id??null:null,a=e=>{let t=r(e),i=X(n,e=>t!==null&&e.at.element===t);return{id:t,tag:e.tag,label:N(e.tag),points:P(e),...i}},o=(e,t=[])=>{for(let n of e)n.type===`element`&&(s.has(n.tag)?t.push(a(n)):o(n.children,t));return t},c=(e,t,i)=>{let a=new Set(i.flatMap(e=>e.id===null?[]:[e.id])),o=Y(i.map(e=>e.points)),s=t===null?D(j,o===null?`block.text`:`block.gap`):N(t.tag);return{kind:e,id:t===null?null:r(t),tag:t?.tag??null,label:s,points:o,components:i,...X(n,e=>e.at.element!==null&&a.has(e.at.element))}},u=e=>{let t=[],n=[],r=()=>{n.some(e=>e.type===`element`||e.value.trim()!==``)&&t.push(c(`text`,null,o(n))),n=[]};for(let i of e)if(i.type===`element`&&i.tag===`astl-columns`){r();for(let e of i.children)p(e,`astl-column`)&&t.push(...u(e.children))}else i.type===`element`&&s.get(i.tag)?.display===`block`?(r(),t.push(c(`component`,i,[a(i)]))):n.push(i);return r(),t},d=(e,t,r)=>{let i=u(r);return{id:e,label:t,...X(n,t=>e===null?t.at.page===null&&t.at.tag!==null&&t.at.tag!==`astl-doc`:t.at.page===e),components:o(r),blocks:i,points:Y(i.map(e=>e.points))}},f=e(t),m=J(f.find(e=>p(e,l))?.children??f),h=[];if(m.some(e=>p(e,`astl-page`))){let e=[],t=()=>{let t=d(null,null,e);t.components.length>0&&h.push(t),e=[]};for(let n of m){if(!p(n,`astl-page`)){e.push(n);continue}t();let r=e=>Object.hasOwn(n.attrs,e)?n.attrs[e]??null:null;h.push(d(r(`id`),r(`label`),n.children))}t()}else h.push(d(null,null,m));return{pages:h,...X(n,()=>!0),points:Y(h.map(e=>e.points))}},I=null,L=t=>{if(I?.source===t)return I.names;let n=new Map,r=e(t),i=J(r.find(e=>p(e,`astl-doc`))?.children??r),a=i.some(e=>p(e,m)),o=(e,t,r)=>{let i=Object.hasOwn(e.attrs,`id`)?e.attrs.id:void 0;i===void 0||i===``||n.has(i)||n.set(i,{n:t,page:r})},c=(e,t,n)=>{for(let r of e){if(r.type!==`element`)continue;if(!s.has(r.tag)){c(r.children,t,n);continue}let e=(n.get(r.tag)??0)+1;n.set(r.tag,e),o(r,e,t)}},l=(e,t)=>{let n=new Map,r=0,i=!1,a=e=>{for(let l of e)if(l.type===`element`&&l.tag===`astl-columns`){for(let e of l.children)i=!1,p(e,`astl-column`)&&a(e.children);i=!1}else l.type===`element`&&s.get(l.tag)?.display===`block`?(r++,i=!1,o(l,r,t)):(!i&&(l.type===`element`||l.value.trim()!==``)&&(r++,i=!0),c([l],t,n))};a(e)};return a?i.filter(e=>p(e,m)).forEach((e,t)=>{l(e.children,t+1)}):l(i,null),I={source:t,names:n},n};function R(e,t){let n=[];for(let{tag:r,id:i,range:a}of S(e)){if(i!==null&&i.trim()!==``||r!==`astl-page`&&!s.has(r))continue;let e=r===`astl-page`?`page`:c.get(r)?.idPrefix??r.replace(/^astl-/,``),l=q(o(`${e}-1`)?e:`item`,t);t.add(l);let u=a.startTag.attributes.find(e=>e.name===`id`),d=a.startTag.start+1+r.length;n.push(u===void 0?{start:d,end:d,text:` id="${l}"`}:{start:u.start,end:u.end,text:`id="${l}"`})}return A(e,n)}function z(e,t,n){let r=[];for(let{tag:i,range:a}of S(e)){let o=c.get(i)?.companion,s=o===void 0?void 0:c.get(o.tag);if(o===void 0||s===void 0||E(a.startTag,o.attribute))continue;let l=e=>k(e).find(e=>e.tag===o.tag&&e.id)?.id,u=l(e)??l(t)??q(s.idPrefix,n),d=V(e.slice(a.start,a.end),{kind:`attribute`,name:o.attribute,value:u});r.push({start:a.start,end:a.end,text:d})}return A(e,r)}function B(e,t,n,r=``){let i=c.get(e);if(i===void 0)throw TypeError(`No editor descriptor for <${e}>`);let a=n===void 0?null:i.templates?.find(e=>e.id===n);if(a===void 0)throw TypeError(`Editor descriptor <${e}> has no template "${n}"`);let o=C(t),s=q(i.idPrefix,o),l=i.manifest.messages,u=(a?.template??i.template).replace(/\{\{t:([^}]+)\}\}/g,(e,t)=>x(D(l,t.trim()))).replace(/\{\{id\}\}/g,s).replace(/\{\{selection\}\}/g,()=>x(r));for(let e of C(u))o.add(e);return z(R(u,o),t,o)}return{engine:i,locale:a,descriptors:[...c.values()],elements:r.elements??[],styleTemplates:d,urlPolicy:_(r.urlPolicy??u),fonts:(r.fonts??ae).map(Ee),styles:De(r.styles??ne,e=>{let t=`style.preset.${e}`,n=D(j,t);return n===t?e:n}),uploadAsset:r.uploadAsset??null,pickPicture:r.pickPicture??null,descriptor:e=>c.get(e)??null,templates:e=>c.get(e)?.templates??[],t:D,loadMenuMessages:()=>T??=Promise.resolve(r.menuMessages?.()??[]).then(w,e=>{T=null,console.error(e)}),addMessages:w,instantiate:B,withCompanion(e,t,n){let r=c.get(e)?.companion;if(r===void 0||!c.has(r.tag))return null;let i=O(t).find(e=>e.name===l);if(i===void 0)return null;let a=i.children.filter(e=>e.name===m),o=S(t),s=e=>a.find(t=>t.start<=e.start&&e.end<=t.end)??i,u=e=>o.flatMap(t=>t.tag===r.tag&&t.id&&e.start<=t.start&&t.end<=e.end?[t.id]:[]),d=e=>E(e.startTag,r.attribute)??``,f=o.find(t=>t.tag===e&&(n===void 0?!u(s(t.range)).includes(d(t.range)):t.id===n));if(f===void 0)return null;let p=s(f.range),h=u(p);if(h.includes(d(f.range)))return null;let[g]=h,_=g===void 0?B(r.tag,t):``,v=g??k(_).find(e=>e.tag===r.tag)?.id??``,y=t.slice(f.start,f.end),b=p.endTag?.start??p.end;return A(t,[{start:f.start,end:f.end,text:V(y,{kind:`attribute`,name:r.attribute,value:v})},{start:b,end:b,text:_}])},inspect(t,n){let r=Ne(e(t));if(r===null)return null;let i=re(r.tag);if(i===null)return null;let a=M(`component`,r.tag);return Te(r,i,c.get(r.tag)??null,oe(i),a,t=>{if(n===void 0||t===``)return null;let r=k(n).find(e=>e.id===t);return r===void 0?null:Ne(e(n.slice(r.start,r.end)))})},inspectDocument(e){let t=ee(e).find(e=>e.type===`start`);if(t?.name!==`astl-doc`)return null;let n=E(t,v),r=M(`document`);if(r.length===0&&n===null)return null;let i=f(l,n===null?{}:{[v]:n}),a=D(j,`inspector.documentStyle`),o=D(j,`inspector.styleTemplate.default`);return{tag:l,id:null,label:D(j,`inspector.document`),icon:null,fields:[xe(i,a,o,r)]}},update:V,validate:e=>i.validate(e),describe(e,t,n){let{id:r}=e.params,o=t!==void 0&&e.namespace!==`astl.engine`&&r===e.at.element&&typeof r==`string`?L(t).get(r):void 0,s=o===void 0?void 0:o.page===null||n?.page===!1?String(o.n):D(j,`issue.onPage`,{n:o.n,page:o.page}),c=s===void 0?e:{...e,params:{...e.params,id:s}},l=D(c.namespace,c.code,c.params);return l===c.code?i.describe(c,a):l},assignIds:e=>R(e,C(e)),outline:F,async preview(e,t){let r=await i.compile(e,{salt:ie});return r.ok?{ok:!0,view:r.view,checker:n(i,r.key,t?.policy),issues:r.issues}:{ok:!1,issues:r.issues}}}}var Ie=`astl-style-open`,Z=null,Q=null;function Le(e){Z=e}function Re(){return Q??=Promise.all([import(`./style-form-DUGbG_kL.js`),import(`./style-rules-D17QGzXk.js`)]).then(([{AstlStyleForm:e},{AstlStyleRules:t}])=>{let n=Z??customElements;n.get(`astl-style-form`)===void 0&&n.define(`astl-style-form`,e),n.get(`astl-style-rules`)===void 0&&n.define(`astl-style-rules`,t)},e=>{throw Q=null,e}),Q}var $=null;function ze(){let e=import(`./help-form-CDg3TCwI.js`);return $??=e.then(({AstlHelpForm:e})=>{let t=Z??customElements;t.get(`astl-help-form`)===void 0&&t.define(`astl-help-form`,e)},e=>{throw $=null,e}),$.then(()=>e)}var Be={inline:c`<rect x="2.5" y="6.5" width="15" height="7" rx="1.5"/><path d="M6 10h5"/>`,block:c`<path d="M3.5 5h13M3.5 10h13M3.5 15h8"/>`,picture:c`<rect x="2.5" y="3.5" width="15" height="13" rx="1.5"/><path d="M4.5 14l4-4.5 3 3 2-2 2.5 3.5"/><circle cx="13.5" cy="7" r="1.5"/>`,page:c`<path d="M4.5 2.5v4h11v-4M4.5 17.5v-4h11v4M2.5 10h2.5M8.75 10h2.5M15 10h2.5"/>`,columns:c`<rect x="2.5" y="3.5" width="15" height="13" rx="1.5"/><path d="M10 3.5v13"/>`},Ve=new Map([[`list-checks`,c`<path d="M3 6a2 2 0 1 0 4 0 2 2 0 1 0-4 0m0 8a2 2 0 1 0 4 0 2 2 0 1 0-4 0M10 6h7m-7 8h7"/><circle cx="5" cy="6" r="1"/>`],[`list-numbers`,c`<path d="M6.5 16V4M3.5 7l3-3 3 3m4 9V4m-3 9l3 3 3-3"/>`],[`kanban`,c`<path d="M3.5 3.5h5v5h-5zm8 0h5v5h-5zm-8 8h5v5h-5zm8 0h5v5h-5z"/>`],[`help-hint`,c`<path d="M7.5 15.5h5M8.5 18h3M10 2.5a5 5 0 0 0-3 9c.6.5 1 1.2 1 2v.5h4v-.5c0-.8.4-1.5 1-2a5 5 0 0 0-3-9z"/>`],[`help-explanation`,c`<circle cx="10" cy="10" r="7.5"/><path d="M10 9v5m0-7.5v.5"/>`],[`help-feedback`,c`<path d="M3.5 4.5h13v9h-7l-4 3v-3h-2z"/>`]]),He=[`hint`,`explanation`,`feedback`],Ue=[`components`,`exercises`,`content`,`layouts`],We=`astl-inserted`,Ge=e=>e.normalize(`NFD`).replace(/\p{M}/gu,``).toLocaleLowerCase();function Ke(e){for(let t of e.fields??[])if(t.kind===`picture-regions`||t.kind===`picture-points`)return t.src;return null}function qe(e,t,n,r,i){let a=k(t).find(e=>e.tag===n),o=e.descriptor(n)?.manifest;if(a===void 0||o===void 0)return t;let s=e=>o.attributes.some(t=>t.name===e),c=[[r,i.src],[`alt`,s(`alt`)?i.alt:void 0],[`width`,s(`width`)?i.width?.toString():void 0],[`height`,s(`height`)?i.height?.toString():void 0]],l=t.slice(a.start,a.end);for(let[t,n]of c)n!==void 0&&(l=e.update(l,{kind:`attribute`,name:t,value:n}));return t.slice(0,a.start)+l+t.slice(a.end)}var Je=class extends M{static properties={...M.properties,filter:{},groups:{attribute:!1},dialog:{attribute:!1}};constructor(){super(),this.filter=``,this.groups=Ue,this.dialog=null}#e=null;updated(e){super.updated(e);let t=this.authoring,n=this.closest(`[popover]`);t!==null&&t!==this.#e&&n?.matches(`:popover-open`)!==!1&&(this.#e=t,t.loadMenuMessages().then(()=>this.requestUpdate()))}#t(){return this.dialog??this.renderRoot.querySelector(`astl-picture-dialog`)}static styles=[oe,N(`astl-picture-dialog`),a`
1
+ import{H as e,M as t,W as n}from"./definitions-BybSa1mq.js";import{$ as r,C as i,E as a,It as o,Q as s,T as c,Tt as l,an as u,b as d,dn as f,fn as p,jt as m,lt as h,mn as g,on as _,rt as v}from"./runtime-C25QK5B0.js";import{o as y,s as b}from"./declarations-BhqOz1ap.js";import{a as x,c as S,d as C,i as w,l as T,n as E,o as D,r as O,s as k,t as A,u as ee}from"./scan-BVhxT2Hw.js";import{n as te,t as j}from"./messages-Qzse5KMX.js";import{n as ne,o as re,r as ie,t as ae}from"./style-model-ZXNe_c8R.js";import{n as oe,r as M,t as N}from"./styles-DiY3VA_T.js";var P=/^[a-z][a-z0-9-]*$/;function F(e,t,n,r){if(!P.test(n))throw TypeError(`Invalid attribute name "${n}"`);let i=t.attributes.filter(e=>e.name===n),a=i[0];if(r===null||r===!1)return i.map(t=>({start:T(e,t.start),end:t.end,text:``}));if(a!==void 0){let e=E(t,n)??``;if(r===!0?e===``||e.toLowerCase()===n:e===r)return[]}let o=r===!0?n:`${n}="${w(r)}"`;if(a!==void 0)return[{start:a.start,end:a.end,text:o}];let s=t.attributes[t.attributes.length-1]?.end??t.start+1+t.name.length;return[{start:s,end:s,text:` ${o}`}]}function I(e,t){return e.children.flatMap(e=>e.name===t?[e]:I(e,t))}function L(t,n){let[r]=e(t.slice(n.start,n.end));return p(r)?g(r):``}function R(e){return e.endTag?.start??e.end}function z(e,t,n){let r=t.startTag;if(r.selfClosing&&t.endTag===null){let i=e.slice(r.start,T(e,r.end-2));return{start:t.start,end:t.end,text:`${i}>${n}</${t.name}>`}}return{start:r.end,end:R(t),text:n}}function B(e,t,n){return t.startTag.selfClosing&&t.endTag===null?z(e,t,n):t.endTag===null?{start:t.end,end:t.end,text:`${n}</${t.name}>`}:{start:t.endTag.start,end:t.endTag.start,text:n}}function se(e,t,n){let[r,i]=n;if(r===void 0)return``;let a=i===void 0?e.slice(Math.max(t.startTag.end,T(e,r.start)),r.start):e.slice(r.end,i.start);return/^\s*$/.test(a)?a:``}function ce(e,t,n,r){let i=I(t,n),a=[];if(i.forEach((t,n)=>{let i=r[n];i===void 0?a.push({start:T(e,t.start),end:t.end,text:``}):L(e,t)!==i&&a.push(z(e,t,D(i)))}),r.length>i.length){let o=se(e,t,i),s=r.slice(i.length).map(e=>`<${n}>${D(e)}</${n}>`),c=i[i.length-1];c===void 0?a.push(B(e,t,s.join(o))):a.push({start:c.end,end:c.end,text:s.map(e=>o+e).join(``)})}return a}function V(e,t){let n=O(e)[0];if(n===void 0)return e;switch(t.kind){case`attribute`:return A(e,F(e,n.startTag,t.name,t.value));case`child-flag`:case`child-choice`:{let r=I(n,t.tag)[t.index];return r===void 0?e:A(e,F(e,r.startTag,t.attribute,t.value))}case`text-list`:return A(e,ce(e,n,t.tag,t.values));case`child-attributes`:{let n=e;for(let[e,r]of Object.entries(t.attributes))n=V(n,{kind:`child-choice`,tag:t.tag,attribute:e,index:t.index,value:r});return n}case`child-add`:{if(!P.test(t.tag))throw TypeError(`Invalid tag name "${t.tag}"`);let r=Object.entries(t.attributes).map(([e,t])=>{if(!P.test(e))throw TypeError(`Invalid attribute name "${e}"`);return` ${e}="${w(t)}"`}),i=`<${t.tag}${r.join(``)}></${t.tag}>`,a=I(n,t.tag),o=a.at(-1)??n.children.at(-1);if(o===void 0)return A(e,[B(e,n,i)]);let s=se(e,n,a.length>0?a:n.children);return A(e,[{start:o.end,end:o.end,text:s+i}])}case`child-remove`:{let r=I(n,t.tag)[t.index];return r===void 0?e:A(e,[{start:T(e,r.start),end:r.end,text:``}])}}}var H=(e,t)=>Object.hasOwn(e.attrs,t)?e.attrs[t]??``:null,U=(e,t)=>e.children.flatMap(e=>e.type===`element`?e.tag===t?[e]:U(e,t):[]);function le(e){let t=e=>({kind:`attribute`,name:e.name,label:`editor.${e.name}`}),n=e=>e.visibility!==`derived`,i=e.scoring===null?[]:[`scoring`,`points`],a=r(e).filter(e=>i.includes(e.name));return[...e.attributes.filter(n).map(t),...e.children.filter(e=>e.visibility===`private`&&e.content===`text`).map(e=>({kind:`text-list`,tag:e.tag,label:`editor.${e.tag}`})),...e.children.flatMap(e=>e.attributes.filter(e=>(e.type===`boolean`||e.type===`enum`)&&n(e)).map(t=>({kind:t.type===`boolean`?`child-flag`:`child-choice`,tag:e.tag,attribute:t.name,label:`editor.${e.tag}.${t.name}`}))),...a.map(t)]}function ue(e,t,n){return(t.name===`scoring`&&e.scoring!==null?Object.keys(e.scoring.modes):[...t.values??[]]).map(e=>({value:e,label:n.message(`editor.value.${t.name}.${e}`,e)}))}function de(e,t){return t.name===`scoring`&&e.scoring!==null?e.scoring.default:t.default===void 0?null:String(t.default)}function fe(e,t,n,i,a=n.name,o=()=>null){let s=r(t).find(e=>e.name===n.name);if(s===void 0)return null;let c=s.name,l=i.message(n.label,a),u=n.help===void 0?null:i.message(n.help,``),d={kind:`attribute`,name:c,label:l,help:u===``?null:u},f=H(e,c),p=s.required===!0,m=n.options===void 0?null:o(H(e,n.options.from)??``);if(m!==null&&n.options!==void 0){let e=f??``;return{...d,control:`select`,value:e,options:ye(m,n.options.tag,i)(e)}}let h=c===`scoring`&&t.scoring!==null;if(s.type===`enum`||h){let e=ue(t,s,i),n=f??de(t,s)??``;return n===``&&!e.some(e=>e.value===``)?e.unshift({value:``,label:i.unset}):e.some(e=>e.value===n)||e.push({value:n,label:n}),{...d,control:`select`,value:n,options:e}}if(s.type===`number`||s.type===`integer`)return{...d,control:`number`,value:f??de(t,s)??``,min:s.min??null,max:s.max??null,step:s.type===`integer`?`1`:`any`,required:p};if(s.type===`boolean`)return{...d,control:`checkbox`,checked:f!==null};let g=s.type===`url`?n.accept??null:null;return{...d,control:`text`,value:f??``,required:p,accept:g}}function pe(e){return new Map(e.flatMap(e=>e.kind===`picture-regions`||e.kind===`picture-points`?[[e.tag,e.kind]]:[]))}function me(e,t){let n=e.children.find(e=>e.tag===t)?.attributes.find(e=>e.name===`shape`);if(n===void 0)return[`rect`];let r=[`rect`,`circle`,`polygon`].filter(e=>n.values?.includes(e));return r.length>0?r:[`rect`]}function he(e,t,n,r,i=[n],a=()=>null){let o=n.help===void 0?null:r.message(n.help,``)||null,s=`tag`in n?pe(i).get(n.tag):void 0,c=(e,t)=>G(e,t,r,s);switch(n.kind){case`attribute`:return fe(e,t,n,r,n.name,a);case`text-list`:return{kind:`text-list`,tag:n.tag,label:r.message(n.label,n.tag),help:o,values:U(e,n.tag).map(g),max:t.children.find(e=>e.tag===n.tag)?.max??null,multiline:n.multiline===!0};case`child-flag`:{let t=U(e,n.tag).map((e,t)=>({index:t,id:H(e,`id`),label:c(e,t),checked:H(e,n.attribute)!==null})),i={count:t.length,checked:t.filter(e=>e.checked).length},a=`${n.tag} ${n.attribute}`,o=n.help===void 0?null:r.message(n.help,``,i)||null;return{kind:`child-flag`,tag:n.tag,attribute:n.attribute,label:r.message(n.label,a,i),help:o,children:t}}case`child-text`:return{kind:`child-text`,tag:n.tag,attribute:n.attribute,label:r.message(n.label,`${n.tag} ${n.attribute}`),help:o,children:U(e,n.tag).map((e,t)=>({index:t,id:H(e,`id`),label:c(e,t),value:H(e,n.attribute)??``}))};case`child-choice`:{let i=be(e,t,n,r);return i===null?null:{kind:`child-choice`,tag:n.tag,attribute:n.attribute,label:r.message(n.label,`${n.tag} ${n.attribute}`),help:o,control:i.control,children:U(e,n.tag).map((e,t)=>{let r=H(e,n.attribute)??``,a=i.options(r);return{index:t,id:H(e,`id`),label:c(e,t),value:r,options:a}})}}case`child-table`:return ge(e,t,n,r,o);case`picture-regions`:case`picture-points`:{let a={tag:n.tag,label:r.message(n.label,n.tag),help:o,elementTag:e.tag,srcAttribute:n.src,src:H(e,n.src)??``},s=U(e,n.tag);if(n.kind===`picture-points`)return{...a,kind:`picture-points`,points:s.map((e,t)=>({index:t,id:H(e,`id`)??``,x:W(H(e,`x`)),y:W(H(e,`y`)),label:H(e,`label`)??``}))};let c=i.find(e=>e.kind===`child-flag`&&e.tag===n.tag),l=c!==void 0&&`attribute`in c?c.attribute:null;return{...a,kind:`picture-regions`,shapes:me(t,n.tag),flag:l,regions:s.map((e,t)=>{let n=H(e,`shape`);return{index:t,id:H(e,`id`)??``,shape:n===`circle`||n===`polygon`?n:`rect`,x:W(H(e,`x`)),y:W(H(e,`y`)),width:W(H(e,`width`)),height:W(H(e,`height`)),r:W(H(e,`r`)),points:_e(H(e,`points`)),label:H(e,`label`)??``,flagged:l!==null&&H(e,l)!==null}})}}}}function ge(e,t,n,r,i){let a=t.children.find(e=>e.tag===n.tag);if(a===void 0)return null;let o=n.columns.flatMap(e=>{let t=a.attributes.find(t=>t.name===e.attribute);if(t===void 0)return[];let n=t.type===`integer`||t.type===`number`;return[{attribute:t.name,label:r.message(e.label,t.name),control:t.type===`enum`?`select`:n?`number`:`text`,options:(t.values??[]).map(e=>({value:e,label:r.message(`editor.value.${t.name}.${e}`,e)})),min:t.min??null,max:t.max??null,step:t.type===`integer`?`1`:`any`,required:t.required===!0}]}),s=U(e,n.tag),c=n.tag.replace(/^astl-/,``),l=new Set(s.map(e=>H(e,`id`))),u=s.length+1;for(;l.has(`${c}-${u}`);)u++;let d={id:`${c}-${u}`};for(let e of a.attributes)e.required===!0&&e.name!==`id`&&(d[e.name]=e.values?.[0]??(e.min===void 0?``:String(e.min)));return{kind:`child-table`,tag:n.tag,label:r.message(n.label,n.tag),help:i,columns:o,rows:s.map((e,t)=>({index:t,id:H(e,`id`),label:G(e,t,r),values:o.map(t=>H(e,t.attribute)??``)})),added:d,min:a.min,max:a.max}}function W(e){let t=Number.parseFloat(e??``);return Number.isFinite(t)?Math.min(100,Math.max(0,t)):0}function _e(e){return(e??``).trim().split(/\s+/).filter(e=>e!==``).map(e=>{let[t=``,n=``]=e.split(`,`);return[W(t),W(n)]})}var ve=e=>e.type===`text`?e.value:e.tag===`img`?` ${e.attrs.alt??``} `:e.children.map(ve).join(``);function G(e,t,n,r){let i=ve(e).replace(/\s+/g,` `).trim();return i!==``||r===void 0?i||n.untitled(t+1):(H(e,`label`)??``).replace(/\s+/g,` `).trim()||(r===`picture-regions`?n.region(t+1):n.point(t+1))}function ye(e,t,n){let r=U(e,t).flatMap((e,t)=>{let r=H(e,`id`);return r===null||r===``?[]:[{value:r,label:G(e,t,n)}]});return e=>e===``?[{value:``,label:n.unset},...r]:r.some(t=>t.value===e)?r:[...r,{value:e,label:e}]}function be(e,t,n,r){if(n.options===void 0){let e=t.children.find(e=>e.tag===n.tag)?.attributes.find(e=>e.name===n.attribute);if(e?.type!==`enum`)return null;let i=(e.values??[]).map(t=>({value:t,label:r.message(`editor.value.${e.name}.${t}`,t)}));return{control:`radios`,options:()=>i}}return{control:`select`,options:ye(e,n.options,r)}}function xe(e,t,n,r){let i=H(e,`style-template`)??``,a=[{value:``,label:n},...r];return a.some(e=>e.value===i)||a.push({value:i,label:i}),{kind:`attribute`,control:`select`,name:v,label:t,help:null,value:i,options:a}}function Se(e,t){if(t.variants===null)return null;let n=H(e,`variant`);return n!==null&&t.variants.values.includes(n)?n:t.variants.default}function Ce(e,t){return e.kind!==`attribute`||e.variants===void 0||e.variants.includes(t??``)}function we(e,t,n,r,i){let a=e=>n.some(t=>t.kind===`attribute`&&t.name===e),o=[];if(t.variants!==null&&!a(`variant`)){let n=fe(e,t,{kind:`attribute`,name:`variant`,label:`editor.variant`},r,r.variant);n!==null&&o.push(n)}let s=H(e,v)!==null;if((i.length>0||s)&&!a(`style-template`)){let t=r.message(`editor.${v}`,r.styleTemplate);o.push(xe(e,t,r.sameAsDocument,i))}return o}function Te(e,t,n,r,i=[],a=()=>null){let o=n?.fields??le(t),s=Se(e,t),c=o.filter(e=>Ce(e,s)).flatMap(n=>he(e,t,n,r,o,a)??[]);return{tag:e.tag,id:H(e,`id`),label:n===null?e.tag:r.message(n.label,e.tag),icon:n?.icon??null,fields:[...c,...we(e,t,c,r,i)]}}function Ee(e){let t=y(`font-family: ${e.stack}`).declarations[0]?.[1];if(t===void 0)throw TypeError(`Font "${e.name}": the style allow-list refuses its stack`);return{name:e.name,stack:t}}function De(e,t){let n=new Set;return e.map(e=>{let{name:r}=e;if(!b(r))throw TypeError(`Style "${r}": not a style name`);if(n.has(r))throw TypeError(`Style "${r}" is given twice`);n.add(r);let{style:i,removed:a}=y(e.style);if(a.length>0)throw TypeError(`Style "${r}": the style allow-list refuses ${a.join(`, `)}`);return{...e,style:i,label:e.label??t(r)}})}var Oe=class extends Error{constructor(e,t){super(e,t),this.name=`UploadRefused`}};function ke(e){return e instanceof Error&&e.name===`UploadRefused`&&e.message.trim()!==``?e.message:void 0}function Ae(e){let t=typeof e==`number`?e:typeof e==`string`&&/^[1-9]\d*$/.test(e)?Number(e):NaN;return Number.isSafeInteger(t)&&t>0?t:void 0}function K(e){let t=(e,t)=>{let n=Ae(t);return n===void 0?``:` ${e}="${n}"`},n=`<img src="${x(String(e.src))}" alt="${x(String(e.alt))}"${t(`width`,e.width)}${t(`height`,e.height)}>`,r=String(e.caption??``).trim();return r===``?n:`<figure>${n}<figcaption>${x(r)}</figcaption></figure>`}function je(){let e=crypto.getRandomValues(new Uint8Array(16));return`preview-${Array.from(e,e=>e.toString(16).padStart(2,`0`)).join(``)}`}var Me=/^[a-z][a-z0-9]*(?:-[a-z0-9]+)*$/;function q(e,t){for(let n=1;;n++){let r=`${e}-${n}`;if(!t.has(r))return r}}var J=e=>e.flatMap(e=>p(e,`astl-style`)?J(e.children):[e]);function Ne(e){return e.find(e=>e.type===`element`)??null}var Pe=Number(s.find(e=>e.name===`points`)?.default??1);function Y(e){let t=e.filter(e=>e!==null);return t.length===0?null:Math.round(t.reduce((e,t)=>e+t,0)*100)/100}function X(e,t){let n={errors:0,warnings:0};for(let r of e)t(r)&&(r.severity===`error`?n.errors++:n.warnings++);return n}function Fe(r){let{engine:i,locale:a}=r,s=new Map(i.manifests.map(e=>[e.tag,e])),c=new Map;for(let e of r.descriptors){let t=e.manifest.tag;if(c.has(t))throw TypeError(`Editor descriptor for <${t}> is given twice`);if(!s.has(t))throw TypeError(`Editor descriptor <${t}> has no component in the engine`);if(!o(`${e.idPrefix}-1`))throw TypeError(`Editor descriptor <${t}>: idPrefix "${e.idPrefix}" does not make valid ids`);let n=(e.templates??[]).map(e=>e.id);if(n.some((e,t)=>!Me.test(e)||n.indexOf(e)!==t))throw TypeError(`Editor descriptor <${t}>: template ids must be distinct kebab-case names`);c.set(t,e)}let d=r.styleTemplates??[],g=e=>h({catalogs:[...te,...t,...r.descriptors.flatMap(e=>e.messages??[]),...e,...d.flatMap(e=>e.catalogs??[]),...r.catalogs??[]]}),y=g([]),b=[],w=e=>{let t=e.filter(e=>!b.includes(e));t.length!==0&&(b=[...b,...t],y=g(b))},T=null,D=(e,t,n)=>y.t(a,e,t,n),re=e=>c.get(e)?.manifest??s.get(e)??null,ie=je(),oe=e=>({message:(t,n,r)=>{let i=D(e.messages,t,r);return i===t?n:i},unset:D(j,`inspector.unset`),untitled:e=>D(j,`inspector.untitled`,{n:e}),region:e=>D(j,`field.region`,{n:e}),point:e=>D(j,`field.point`,{n:e}),variant:D(j,`inspector.variant`),styleTemplate:D(j,`inspector.styleTemplate`),sameAsDocument:D(j,`inspector.styleTemplate.inherit`)}),M=(e,t)=>d.filter(n=>n.scopes.includes(e)&&(t===void 0||n.components===void 0||n.components.includes(t))).map(e=>{let t=D(e.messages,`label`);return{value:e.name,label:t===`label`?e.name:t}}),N=e=>{let t=c.get(e);if(t===void 0)return e;let n=D(t.manifest.messages,t.label);return n===t.label?e:n},P=e=>{if(s.get(e.tag)?.graded!==!0)return null;let t=Object.hasOwn(e.attrs,`points`)?Number(e.attrs.points):NaN;return Number.isFinite(t)&&t>0?t:Pe},F=t=>{let{issues:n}=i.validate(t),r=e=>Object.hasOwn(e.attrs,`id`)?e.attrs.id??null:null,a=e=>{let t=r(e),i=X(n,e=>t!==null&&e.at.element===t);return{id:t,tag:e.tag,label:N(e.tag),points:P(e),...i}},o=(e,t=[])=>{for(let n of e)n.type===`element`&&(s.has(n.tag)?t.push(a(n)):o(n.children,t));return t},c=(e,t,i)=>{let a=new Set(i.flatMap(e=>e.id===null?[]:[e.id])),o=Y(i.map(e=>e.points)),s=t===null?D(j,o===null?`block.text`:`block.gap`):N(t.tag);return{kind:e,id:t===null?null:r(t),tag:t?.tag??null,label:s,points:o,components:i,...X(n,e=>e.at.element!==null&&a.has(e.at.element))}},u=e=>{let t=[],n=[],r=()=>{n.some(e=>e.type===`element`||e.value.trim()!==``)&&t.push(c(`text`,null,o(n))),n=[]};for(let i of e)if(i.type===`element`&&i.tag===`astl-columns`){r();for(let e of i.children)p(e,`astl-column`)&&t.push(...u(e.children))}else i.type===`element`&&s.get(i.tag)?.display===`block`?(r(),t.push(c(`component`,i,[a(i)]))):n.push(i);return r(),t},d=(e,t,r)=>{let i=u(r);return{id:e,label:t,...X(n,t=>e===null?t.at.page===null&&t.at.tag!==null&&t.at.tag!==`astl-doc`:t.at.page===e),components:o(r),blocks:i,points:Y(i.map(e=>e.points))}},f=e(t),m=J(f.find(e=>p(e,l))?.children??f),h=[];if(m.some(e=>p(e,`astl-page`))){let e=[],t=()=>{let t=d(null,null,e);t.components.length>0&&h.push(t),e=[]};for(let n of m){if(!p(n,`astl-page`)){e.push(n);continue}t();let r=e=>Object.hasOwn(n.attrs,e)?n.attrs[e]??null:null;h.push(d(r(`id`),r(`label`),n.children))}t()}else h.push(d(null,null,m));return{pages:h,...X(n,()=>!0),points:Y(h.map(e=>e.points))}},I=null,L=t=>{if(I?.source===t)return I.names;let n=new Map,r=e(t),i=J(r.find(e=>p(e,`astl-doc`))?.children??r),a=i.some(e=>p(e,m)),o=(e,t,r)=>{let i=Object.hasOwn(e.attrs,`id`)?e.attrs.id:void 0;i===void 0||i===``||n.has(i)||n.set(i,{n:t,page:r})},c=(e,t,n)=>{for(let r of e){if(r.type!==`element`)continue;if(!s.has(r.tag)){c(r.children,t,n);continue}let e=(n.get(r.tag)??0)+1;n.set(r.tag,e),o(r,e,t)}},l=(e,t)=>{let n=new Map,r=0,i=!1,a=e=>{for(let l of e)if(l.type===`element`&&l.tag===`astl-columns`){for(let e of l.children)i=!1,p(e,`astl-column`)&&a(e.children);i=!1}else l.type===`element`&&s.get(l.tag)?.display===`block`?(r++,i=!1,o(l,r,t)):(!i&&(l.type===`element`||l.value.trim()!==``)&&(r++,i=!0),c([l],t,n))};a(e)};return a?i.filter(e=>p(e,m)).forEach((e,t)=>{l(e.children,t+1)}):l(i,null),I={source:t,names:n},n};function R(e,t){let n=[];for(let{tag:r,id:i,range:a}of S(e)){if(i!==null&&i.trim()!==``||r!==`astl-page`&&!s.has(r))continue;let e=r===`astl-page`?`page`:c.get(r)?.idPrefix??r.replace(/^astl-/,``),l=q(o(`${e}-1`)?e:`item`,t);t.add(l);let u=a.startTag.attributes.find(e=>e.name===`id`),d=a.startTag.start+1+r.length;n.push(u===void 0?{start:d,end:d,text:` id="${l}"`}:{start:u.start,end:u.end,text:`id="${l}"`})}return A(e,n)}function z(e,t,n){let r=[];for(let{tag:i,range:a}of S(e)){let o=c.get(i)?.companion,s=o===void 0?void 0:c.get(o.tag);if(o===void 0||s===void 0||E(a.startTag,o.attribute))continue;let l=e=>k(e).find(e=>e.tag===o.tag&&e.id)?.id,u=l(e)??l(t)??q(s.idPrefix,n),d=V(e.slice(a.start,a.end),{kind:`attribute`,name:o.attribute,value:u});r.push({start:a.start,end:a.end,text:d})}return A(e,r)}function B(e,t,n,r=``){let i=c.get(e);if(i===void 0)throw TypeError(`No editor descriptor for <${e}>`);let a=n===void 0?null:i.templates?.find(e=>e.id===n);if(a===void 0)throw TypeError(`Editor descriptor <${e}> has no template "${n}"`);let o=C(t),s=q(i.idPrefix,o),l=i.manifest.messages,u=(a?.template??i.template).replace(/\{\{t:([^}]+)\}\}/g,(e,t)=>x(D(l,t.trim()))).replace(/\{\{id\}\}/g,s).replace(/\{\{selection\}\}/g,()=>x(r));for(let e of C(u))o.add(e);return z(R(u,o),t,o)}return{engine:i,locale:a,descriptors:[...c.values()],elements:r.elements??[],styleTemplates:d,urlPolicy:_(r.urlPolicy??u),fonts:(r.fonts??ae).map(Ee),styles:De(r.styles??ne,e=>{let t=`style.preset.${e}`,n=D(j,t);return n===t?e:n}),uploadAsset:r.uploadAsset??null,pickPicture:r.pickPicture??null,descriptor:e=>c.get(e)??null,templates:e=>c.get(e)?.templates??[],t:D,loadMenuMessages:()=>T??=Promise.resolve(r.menuMessages?.()??[]).then(w,e=>{T=null,console.error(e)}),addMessages:w,instantiate:B,withCompanion(e,t,n){let r=c.get(e)?.companion;if(r===void 0||!c.has(r.tag))return null;let i=O(t).find(e=>e.name===l);if(i===void 0)return null;let a=i.children.filter(e=>e.name===m),o=S(t),s=e=>a.find(t=>t.start<=e.start&&e.end<=t.end)??i,u=e=>o.flatMap(t=>t.tag===r.tag&&t.id&&e.start<=t.start&&t.end<=e.end?[t.id]:[]),d=e=>E(e.startTag,r.attribute)??``,f=o.find(t=>t.tag===e&&(n===void 0?!u(s(t.range)).includes(d(t.range)):t.id===n));if(f===void 0)return null;let p=s(f.range),h=u(p);if(h.includes(d(f.range)))return null;let[g]=h,_=g===void 0?B(r.tag,t):``,v=g??k(_).find(e=>e.tag===r.tag)?.id??``,y=t.slice(f.start,f.end),b=p.endTag?.start??p.end;return A(t,[{start:f.start,end:f.end,text:V(y,{kind:`attribute`,name:r.attribute,value:v})},{start:b,end:b,text:_}])},inspect(t,n){let r=Ne(e(t));if(r===null)return null;let i=re(r.tag);if(i===null)return null;let a=M(`component`,r.tag);return Te(r,i,c.get(r.tag)??null,oe(i),a,t=>{if(n===void 0||t===``)return null;let r=k(n).find(e=>e.id===t);return r===void 0?null:Ne(e(n.slice(r.start,r.end)))})},inspectDocument(e){let t=ee(e).find(e=>e.type===`start`);if(t?.name!==`astl-doc`)return null;let n=E(t,v),r=M(`document`);if(r.length===0&&n===null)return null;let i=f(l,n===null?{}:{[v]:n}),a=D(j,`inspector.documentStyle`),o=D(j,`inspector.styleTemplate.default`);return{tag:l,id:null,label:D(j,`inspector.document`),icon:null,fields:[xe(i,a,o,r)]}},update:V,validate:e=>i.validate(e),describe(e,t,n){let{id:r}=e.params,o=t!==void 0&&e.namespace!==`astl.engine`&&r===e.at.element&&typeof r==`string`?L(t).get(r):void 0,s=o===void 0?void 0:o.page===null||n?.page===!1?String(o.n):D(j,`issue.onPage`,{n:o.n,page:o.page}),c=s===void 0?e:{...e,params:{...e.params,id:s}},l=D(c.namespace,c.code,c.params);return l===c.code?i.describe(c,a):l},assignIds:e=>R(e,C(e)),outline:F,async preview(e,t){let r=await i.compile(e,{salt:ie});return r.ok?{ok:!0,view:r.view,checker:n(i,r.key,t?.policy),issues:r.issues}:{ok:!1,issues:r.issues}}}}var Ie=`astl-style-open`,Z=null,Q=null;function Le(e){Z=e}function Re(){return Q??=Promise.all([import(`./style-form-DuR0EEum.js`),import(`./style-rules-ozpLz2ec.js`)]).then(([{AstlStyleForm:e},{AstlStyleRules:t}])=>{let n=Z??customElements;n.get(`astl-style-form`)===void 0&&n.define(`astl-style-form`,e),n.get(`astl-style-rules`)===void 0&&n.define(`astl-style-rules`,t)},e=>{throw Q=null,e}),Q}var $=null;function ze(){let e=import(`./help-form-Di2NtKDp.js`);return $??=e.then(({AstlHelpForm:e})=>{let t=Z??customElements;t.get(`astl-help-form`)===void 0&&t.define(`astl-help-form`,e)},e=>{throw $=null,e}),$.then(()=>e)}var Be={inline:c`<rect x="2.5" y="6.5" width="15" height="7" rx="1.5"/><path d="M6 10h5"/>`,block:c`<path d="M3.5 5h13M3.5 10h13M3.5 15h8"/>`,picture:c`<rect x="2.5" y="3.5" width="15" height="13" rx="1.5"/><path d="M4.5 14l4-4.5 3 3 2-2 2.5 3.5"/><circle cx="13.5" cy="7" r="1.5"/>`,page:c`<path d="M4.5 2.5v4h11v-4M4.5 17.5v-4h11v4M2.5 10h2.5M8.75 10h2.5M15 10h2.5"/>`,columns:c`<rect x="2.5" y="3.5" width="15" height="13" rx="1.5"/><path d="M10 3.5v13"/>`},Ve=new Map([[`list-checks`,c`<path d="M3 6a2 2 0 1 0 4 0 2 2 0 1 0-4 0m0 8a2 2 0 1 0 4 0 2 2 0 1 0-4 0M10 6h7m-7 8h7"/><circle cx="5" cy="6" r="1"/>`],[`list-numbers`,c`<path d="M6.5 16V4M3.5 7l3-3 3 3m4 9V4m-3 9l3 3 3-3"/>`],[`kanban`,c`<path d="M3.5 3.5h5v5h-5zm8 0h5v5h-5zm-8 8h5v5h-5zm8 0h5v5h-5z"/>`],[`help-hint`,c`<path d="M7.5 15.5h5M8.5 18h3M10 2.5a5 5 0 0 0-3 9c.6.5 1 1.2 1 2v.5h4v-.5c0-.8.4-1.5 1-2a5 5 0 0 0-3-9z"/>`],[`help-explanation`,c`<circle cx="10" cy="10" r="7.5"/><path d="M10 9v5m0-7.5v.5"/>`],[`help-feedback`,c`<path d="M3.5 4.5h13v9h-7l-4 3v-3h-2z"/>`]]),He=[`hint`,`explanation`,`feedback`],Ue=[`components`,`exercises`,`content`,`layouts`],We=`astl-inserted`,Ge=e=>e.normalize(`NFD`).replace(/\p{M}/gu,``).toLocaleLowerCase();function Ke(e){for(let t of e.fields??[])if(t.kind===`picture-regions`||t.kind===`picture-points`)return t.src;return null}function qe(e,t,n,r,i){let a=k(t).find(e=>e.tag===n),o=e.descriptor(n)?.manifest;if(a===void 0||o===void 0)return t;let s=e=>o.attributes.some(t=>t.name===e),c=[[r,i.src],[`alt`,s(`alt`)?i.alt:void 0],[`width`,s(`width`)?i.width?.toString():void 0],[`height`,s(`height`)?i.height?.toString():void 0]],l=t.slice(a.start,a.end);for(let[t,n]of c)n!==void 0&&(l=e.update(l,{kind:`attribute`,name:t,value:n}));return t.slice(0,a.start)+l+t.slice(a.end)}var Je=class extends M{static properties={...M.properties,filter:{},groups:{attribute:!1},dialog:{attribute:!1}};constructor(){super(),this.filter=``,this.groups=Ue,this.dialog=null}#e=null;updated(e){super.updated(e);let t=this.authoring,n=this.closest(`[popover]`);t!==null&&t!==this.#e&&n?.matches(`:popover-open`)!==!1&&(this.#e=t,t.loadMenuMessages().then(()=>this.requestUpdate()))}#t(){return this.dialog??this.renderRoot.querySelector(`astl-picture-dialog`)}static styles=[oe,N(`astl-picture-dialog`),a`
2
2
  .group {
3
3
  display: flex;
4
4
  flex-direction: column;
@@ -77,4 +77,4 @@ stroke: none;
77
77
  ${f?i`<p class="note" part="no-match">${this.t(`insert.noMatch`,{query:this.filter.trim()})}</p>`:d}
78
78
  </section>
79
79
  ${this.dialog===null?i`<astl-picture-dialog .authoring=${e}></astl-picture-dialog>`:d}`}};export{ze as a,Oe as c,Ae as d,ke as f,Ie as i,Fe as l,Be as n,Re as o,Ve as r,Le as s,Je as t,K as u};
80
- //# sourceMappingURL=insert-menu-7vANVmTK.js.map
80
+ //# sourceMappingURL=insert-menu-DAQglwtG.js.map