@astl/astrolabe 0.1.1 → 0.1.3
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.
- package/CHANGELOG.md +32 -0
- package/dist/cdn/astrolabe-editor.js +55 -19
- package/dist/cdn/astrolabe-editor.js.map +1 -1
- package/dist/cdn/astrolabe.standalone.js +138 -59
- package/dist/cdn/chunks/{help-form-DaC6KaFG.js → help-form-DhIyMziw.js} +14 -10
- package/dist/cdn/chunks/help-form-DhIyMziw.js.map +1 -0
- package/dist/cdn/chunks/{insert-menu-LgrifBYT.js → insert-menu-Cn2E54V9.js} +2 -2
- package/dist/cdn/chunks/{insert-menu-LgrifBYT.js.map → insert-menu-Cn2E54V9.js.map} +1 -1
- package/dist/cdn/chunks/{issue-list-BgnXzXRM.js → issue-list-CQKAW39i.js} +2 -2
- package/dist/cdn/chunks/{issue-list-BgnXzXRM.js.map → issue-list-CQKAW39i.js.map} +1 -1
- package/dist/cdn/chunks/messages-Qzse5KMX.js +2 -0
- package/dist/cdn/chunks/messages-Qzse5KMX.js.map +1 -0
- package/dist/cdn/chunks/{source-view-DXKPFCl9.js → source-view-BlJ2mRns.js} +2 -2
- package/dist/cdn/chunks/{source-view-DXKPFCl9.js.map → source-view-BlJ2mRns.js.map} +1 -1
- package/dist/cdn/chunks/{style-form-D5haJtWM.js → style-form-D1C2sHzg.js} +2 -2
- package/dist/cdn/chunks/{style-form-D5haJtWM.js.map → style-form-D1C2sHzg.js.map} +1 -1
- package/dist/cdn/chunks/{style-messages-BbZpeD2a.js → style-messages-B136zSom.js} +2 -2
- package/dist/cdn/chunks/{style-messages-BbZpeD2a.js.map → style-messages-B136zSom.js.map} +1 -1
- package/dist/cdn/chunks/{style-rules-D45PZLCv.js → style-rules-ChqPVgZn.js} +2 -2
- package/dist/cdn/chunks/{style-rules-D45PZLCv.js.map → style-rules-ChqPVgZn.js.map} +1 -1
- package/dist/cdn/chunks/{styles-DxJJxVNH.js → styles-CXkkL_Qi.js} +2 -2
- package/dist/cdn/chunks/{styles-DxJJxVNH.js.map → styles-CXkkL_Qi.js.map} +1 -1
- package/dist/cdn/chunks/surface-BhmSAte0.js +1058 -0
- package/dist/cdn/chunks/surface-BhmSAte0.js.map +1 -0
- package/package.json +9 -9
- package/dist/cdn/chunks/help-form-DaC6KaFG.js.map +0 -1
- package/dist/cdn/chunks/messages-9xiYDvRT.js +0 -2
- package/dist/cdn/chunks/messages-9xiYDvRT.js.map +0 -1
- package/dist/cdn/chunks/surface-CgxfAwCR.js +0 -1019
- package/dist/cdn/chunks/surface-CgxfAwCR.js.map +0 -1
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import{H as e}from"./definitions-CNX90WtL.js";import{C as t,Ct as n,E as r,St as i,b as a,bt as o,fn as s,mn as c,vt as l,yt as u}from"./runtime-DxAbpr3S.js";import{i as d,l as f,n as p,o as m,r as h,t as g}from"./scan-jWgPnVxA.js";import{t as _}from"./messages-
|
|
1
|
+
import{H as e}from"./definitions-CNX90WtL.js";import{C as t,Ct as n,E as r,St as i,b as a,bt as o,fn as s,mn as c,vt as l,yt as u}from"./runtime-DxAbpr3S.js";import{i as d,l as f,n as p,o as m,r as h,t as g}from"./scan-jWgPnVxA.js";import{t as _}from"./messages-Qzse5KMX.js";import{n as v,r as y}from"./styles-CXkkL_Qi.js";import{t as b}from"./live-jdiyYln2.js";var x=(e,t)=>t.endTag===null&&t.startTag.selfClosing?``:e.slice(t.startTag.end,t.endTag?.start??t.end),S=e=>e.children.filter(e=>i.has(e.name)),C=e=>o.includes(e);function w(e){let t=h(e)[0],n=[],r=null,i={};for(let a of t===void 0?[]:S(t)){let t=x(e,a);if(a.name===`astl-hint`)n.push({html:t,cost:p(a.startTag,`cost`)});else if(a.name===`astl-explanation`)r??=t;else{let e=p(a.startTag,`when`);C(e)&&(i[e]??=t)}}return{hints:n,explanation:r,feedback:i}}function T(e){let t=e=>e===null?``:` cost="${d(e)}"`;return[...e.hints.map(e=>`<${n}${t(e.cost)}>${e.html}</${n}>`),...e.explanation===null?[]:[`<${l}>${e.explanation}</${l}>`],...o.flatMap(t=>{let n=e.feedback[t];return n===void 0?[]:[`<${u} when="${t}">${n}</${u}>`]})]}function E(e,t){let n=h(e)[0];if(n===void 0)return e;let r=g(e,S(n).map(t=>({start:f(e,t.start),end:t.end,text:``}))),i=T(t),a=h(r)[0];if(a===void 0||i.length===0)return r;let o=a.children.at(-1);if(o===void 0){let e=a.endTag?.start??a.end;return a.endTag===null&&a.startTag.selfClosing?`${r.slice(0,a.start)}${r.slice(a.start,f(r,a.startTag.end-2))}>${i.join(``)}</${a.name}>${r.slice(a.end)}`:g(r,[{start:e,end:e,text:i.join(``)}])}let s=r.slice(f(r,o.start),o.start),c=/^\s*$/.test(s)?s:``;return g(r,[{start:o.end,end:o.end,text:i.map(e=>c+e).join(``)}])}var D=e=>s(e)?e.tag===`br`?`
|
|
2
2
|
`:e.children.map(D).join(``):c(e);function O(t){return(e=>e.flatMap(e=>s(e)?e.tag===`p`||e.tag===`li`?[`\n\n${D(e).trim()}\n\n`]:[D(e)]:[c(e)]))(e(t)).join(``).replace(/[ \t]+/g,` `).split(/\n{2,}/).map(e=>e.trim()).filter(Boolean).join(`
|
|
3
3
|
|
|
4
|
-
`)}function k(t,n){let r=(e,t)=>!n&&Object.keys(e.attrs).length===0&&(t===0?e.tag===`p`:t===1&&e.tag===`br`),i=(e,t)=>e.some(e=>s(e)&&(!r(e,t)||i(e.children,t+1)));return i(e(t),0)}function A(e,t){return t?m(e.replace(/\s+/g,` `).trim()):e.split(/\n\s*\n/).map(e=>e.trim()).filter(Boolean).map(e=>`<p>${m(e).replace(/\n/g,`<br>`)}</p>`).join(``)}var j=[{namespace:_,locale:`en`,messages:{"help.title":`Help for students`,"help.hints":`Hints`,"help.hintsNote":`Students ask for them one at a time, in this order. A cost is the share of the question's points a student loses for using that hint.`,"help.hintN":`Hint {n}`,"help.cost":`Cost (% of the points)`,"help.costN":`Hint {n}: cost (% of the points)`,"help.addHint":`Add a hint`,"help.up":`Up`,"help.down":`Down`,"help.upN":`Move hint {n} up`,"help.downN":`Move hint {n} down`,"help.removeN":`Remove hint {n}`,"help.drag":`Drag to reorder`,"help.explanationNote":`Students open it under "Why?" once their answer is checked. Leave it empty for none.`,"help.feedbackNote":`Shown after a check, by the verdict. Leave a text empty for none.`,"help.formatted":`This text has formatting. A change in this field keeps only the text.`}},{namespace:_,locale:`pl`,messages:{"help.title":`Pomoc dla ucznia`,"help.hints":`Podpowiedzi`,"help.hintsNote":`Uczeń prosi o nie po kolei, w tej kolejności. Koszt to część punktów za to pytanie, którą uczeń traci, gdy użyje podpowiedzi.`,"help.hintN":`Podpowiedź {n}`,"help.cost":`Koszt (% punktów)`,"help.costN":`Podpowiedź {n}: koszt (% punktów)`,"help.addHint":`Dodaj podpowiedź`,"help.up":`W górę`,"help.down":`W dół`,"help.upN":`Przenieś podpowiedź {n} w górę`,"help.downN":`Przenieś podpowiedź {n} w dół`,"help.removeN":`Usuń podpowiedź {n}`,"help.drag":`Przeciągnij, aby zmienić kolejność`,"help.explanationNote":`Uczeń otwiera je pod „Dlaczego?”, gdy jego odpowiedź zostanie sprawdzona. Zostaw puste, jeśli nie ma.`,"help.feedbackNote":`Widać ją po sprawdzeniu, zależnie od wyniku. Zostaw tekst pusty, jeśli nie ma.`,"help.formatted":`Ten tekst ma formatowanie. Zmiana w tym polu zostawi sam tekst.`}}],M=null,N=(e,t)=>e.descriptor(t)?.manifest.graded===!0;function P(e,t,n){let r=t.getSelection(),i=r===null?null:t.getElement(r.id);if(r===null||i===null||!N(e,r.tag)){let e=n===`feedback`?`<astl-feedback when="correct"><p></p></astl-feedback>`:`<astl-${n}><p></p></astl-${n}>`;return t.insert(e),e}let a=w(i),o,s;if(n===`hint`)o={...a,hints:[...a.hints,{html:``,cost:null}]},s=`hint-${a.hints.length}`;else if(n===`explanation`)o={...a,explanation:a.explanation??``},s=`explanation`;else{let e=F.find(e=>a.feedback[e]===void 0)??`correct`;o={...a,feedback:{...a.feedback,[e]:a.feedback[e]??``}},s=`feedback-${e}`}return M={element:r.id,field:s},t.replaceElement(r.id,E(i,o)),null}var F=[`correct`,`incorrect`,`omitted`,`partial`],I=e=>{if(e===null)return`0`;let t=Number(e);return Number.isFinite(t)&&t>=0&&t<=1?String(Math.round(t*100)):``},L=e=>e.target.value,R=class extends y{static properties={...y.properties,element:{},inline:{type:Boolean}};static styles=[v,r`
|
|
4
|
+
`)}function k(t,n){let r=(e,t)=>!n&&Object.keys(e.attrs).length===0&&(t===0?e.tag===`p`:t===1&&e.tag===`br`),i=(e,t)=>e.some(e=>s(e)&&(!r(e,t)||i(e.children,t+1)));return i(e(t),0)}function A(e,t){return t?m(e.replace(/\s+/g,` `).trim()):e.split(/\n\s*\n/).map(e=>e.trim()).filter(Boolean).map(e=>`<p>${m(e).replace(/\n/g,`<br>`)}</p>`).join(``)}var j=[{namespace:_,locale:`en`,messages:{"help.title":`Help for students`,"help.hints":`Hints`,"help.hintsNote":`Students ask for them one at a time, in this order. A cost is the share of the question's points a student loses for using that hint.`,"help.hintN":`Hint {n}`,"help.cost":`Cost (% of the points)`,"help.costN":`Hint {n}: cost (% of the points)`,"help.addHint":`Add a hint`,"help.up":`Up`,"help.down":`Down`,"help.upN":`Move hint {n} up`,"help.downN":`Move hint {n} down`,"help.removeN":`Remove hint {n}`,"help.removeExplanation":`Remove the explanation`,"help.removeFeedback":`Remove the feedback: {when}`,"help.drag":`Drag to reorder`,"help.explanationNote":`Students open it under "Why?" once their answer is checked. Leave it empty for none.`,"help.feedbackNote":`Shown after a check, by the verdict. Leave a text empty for none.`,"help.formatted":`This text has formatting. A change in this field keeps only the text.`}},{namespace:_,locale:`pl`,messages:{"help.title":`Pomoc dla ucznia`,"help.hints":`Podpowiedzi`,"help.hintsNote":`Uczeń prosi o nie po kolei, w tej kolejności. Koszt to część punktów za to pytanie, którą uczeń traci, gdy użyje podpowiedzi.`,"help.hintN":`Podpowiedź {n}`,"help.cost":`Koszt (% punktów)`,"help.costN":`Podpowiedź {n}: koszt (% punktów)`,"help.addHint":`Dodaj podpowiedź`,"help.up":`W górę`,"help.down":`W dół`,"help.upN":`Przenieś podpowiedź {n} w górę`,"help.downN":`Przenieś podpowiedź {n} w dół`,"help.removeN":`Usuń podpowiedź {n}`,"help.removeExplanation":`Usuń wyjaśnienie`,"help.removeFeedback":`Usuń informację zwrotną: {when}`,"help.drag":`Przeciągnij, aby zmienić kolejność`,"help.explanationNote":`Uczeń otwiera je pod „Dlaczego?”, gdy jego odpowiedź zostanie sprawdzona. Zostaw puste, jeśli nie ma.`,"help.feedbackNote":`Widać ją po sprawdzeniu, zależnie od wyniku. Zostaw tekst pusty, jeśli nie ma.`,"help.formatted":`Ten tekst ma formatowanie. Zmiana w tym polu zostawi sam tekst.`}}],M=null,N=(e,t)=>e.descriptor(t)?.manifest.graded===!0;function P(e,t,n){let r=t.getSelection(),i=r===null?null:t.getElement(r.id);if(r===null||i===null||!N(e,r.tag)){let e=n===`feedback`?`<astl-feedback when="correct"><p></p></astl-feedback>`:`<astl-${n}><p></p></astl-${n}>`;return t.insert(e),e}let a=w(i),o,s;if(n===`hint`)o={...a,hints:[...a.hints,{html:``,cost:null}]},s=`hint-${a.hints.length}`;else if(n===`explanation`)o={...a,explanation:a.explanation??``},s=`explanation`;else{let e=F.find(e=>a.feedback[e]===void 0)??`correct`;o={...a,feedback:{...a.feedback,[e]:a.feedback[e]??``}},s=`feedback-${e}`}return M={element:r.id,field:s},t.replaceElement(r.id,E(i,o)),null}var F=[`correct`,`incorrect`,`omitted`,`partial`],I=e=>{if(e===null)return`0`;let t=Number(e);return Number.isFinite(t)&&t>=0&&t<=1?String(Math.round(t*100)):``},L=e=>e.target.value,R=class extends y{static properties={...y.properties,element:{},inline:{type:Boolean}};static styles=[v,r`
|
|
5
5
|
:host {
|
|
6
6
|
display: block;
|
|
7
7
|
}
|
|
@@ -126,18 +126,22 @@ color: var(--astl-danger);
|
|
|
126
126
|
<button type="button" class="delete" aria-label=${this.t(`help.removeN`,{n:i})}
|
|
127
127
|
@click=${()=>{this.#e.clear(),this.#r(e=>({...e,hints:e.hints.filter((e,t)=>t!==n)})),M={element:this.element??``,field:e.hints.length>1?`hint-${Math.max(0,n-1)}`:`add-hint`}}}>${this.t(`inspector.remove`)}</button>
|
|
128
128
|
</div>
|
|
129
|
-
</li>`}#u(e,n,r,i){let
|
|
129
|
+
</li>`}#u(e,n,r,i,o){let s=this.#a(e,i??``);return t`<div class="field">
|
|
130
130
|
<label for=${e}>${n}</label>
|
|
131
131
|
<textarea
|
|
132
132
|
id=${e}
|
|
133
133
|
data-help=${e}
|
|
134
134
|
dir="auto"
|
|
135
|
-
aria-describedby=${
|
|
136
|
-
.value=${b(this.#i(e,
|
|
137
|
-
@input=${t=>{let n=this.#o(e,t);
|
|
135
|
+
aria-describedby=${s===null?a:`${e}-formatted`}
|
|
136
|
+
.value=${b(this.#i(e,i??``))}
|
|
137
|
+
@input=${t=>{let n=this.#o(e,t);o(n===``?null:n)}}
|
|
138
138
|
@change=${()=>this.#s(e)}
|
|
139
139
|
></textarea>
|
|
140
|
-
${
|
|
140
|
+
${s??a}
|
|
141
|
+
${i==null?a:t`<div class="row">
|
|
142
|
+
<button type="button" class="delete" aria-label=${r}
|
|
143
|
+
@click=${()=>{this.#e.delete(e),M={element:this.element??``,field:e},o(null)}}>${this.t(`inspector.remove`)}</button>
|
|
144
|
+
</div>`}
|
|
141
145
|
</div>`}render(){let e=this.#n();if(e===null||this.authoring===null)return a;let{help:n}=e,{lang:r,dir:i}=this.ui;return t`<section class="kit" part="help" lang=${r} dir=${i} aria-labelledby="help-title">
|
|
142
146
|
<h3 id="help-title">${this.t(`help.title`)}</h3>
|
|
143
147
|
<fieldset aria-describedby="hints-note">
|
|
@@ -149,12 +153,12 @@ color: var(--astl-danger);
|
|
|
149
153
|
@click=${()=>{M={element:this.element??``,field:`hint-${n.hints.length}`},this.#r(e=>({...e,hints:[...e.hints,{html:``,cost:null}]}))}}>${this.t(`help.addHint`)}</button>
|
|
150
154
|
</div>
|
|
151
155
|
</fieldset>
|
|
152
|
-
${this.#u(`explanation`,this.t(`insert.explanation`),n.explanation,e=>this.#r(t=>({...t,explanation:e})))}
|
|
156
|
+
${this.#u(`explanation`,this.t(`insert.explanation`),this.t(`help.removeExplanation`),n.explanation,e=>this.#r(t=>({...t,explanation:e})))}
|
|
153
157
|
<p class="note">${this.t(`help.explanationNote`)}</p>
|
|
154
158
|
<fieldset aria-describedby="feedback-note">
|
|
155
159
|
<legend>${this.t(`insert.feedback`)}</legend>
|
|
156
160
|
<p class="note" id="feedback-note">${this.t(`help.feedbackNote`)}</p>
|
|
157
|
-
${o.map(e=>this.#u(`feedback-${e}`,this.t(`help.when.${e}`),n.feedback[e],t=>this.#r(n=>{let r={...n.feedback};return t===null?delete r[e]:r[e]=t,{...n,feedback:r}})))}
|
|
161
|
+
${o.map(e=>this.#u(`feedback-${e}`,this.t(`help.when.${e}`),this.t(`help.removeFeedback`,{when:this.t(`help.when.${e}`)}),n.feedback[e],t=>this.#r(n=>{let r={...n.feedback};return t===null?delete r[e]:r[e]=t,{...n,feedback:r}})))}
|
|
158
162
|
</fieldset>
|
|
159
163
|
</section>`}};export{R as AstlHelpForm,P as addHelp};
|
|
160
|
-
//# sourceMappingURL=help-form-
|
|
164
|
+
//# sourceMappingURL=help-form-DhIyMziw.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"help-form-DhIyMziw.js","names":["en","pl","nothing","live","parseHtml","b","HINT_TAG","i","HELP_TAGS","A","FEEDBACK_VARIANTS","isElement","textContent","EXPLANATION_TAG","FEEDBACK_TAG","escapeAttribute","spaceBefore","attributeValue","escapeText","elementTree","applyEdits","EDITOR_NAMESPACE","kitStyles","AuthoringElement","l","inner","range","source","helpChildren","root","c","isVariant","value","readHelp","html","hints","explanation","feedback","child","content","when","helpSource","cost","help","h","text","writeHelp","first","cleared","added","last","at","gap","sep","a","lines","node","helpText","nodes","part","helpFormatted","plain","inline","depth","formatted","textHelp","helpMessages","pending","graded","authoring","tag","addHelp","selection","adapter","current","block","kind","next","field","FEEDBACK_ORDER","w","percentOf","n","inputValue","event","AstlHelpForm","changed","#drafts","#help","change","#write","to","from","moved","hint","index","#formatted","over","#dragged","on","#move","#text","#typed","x","#done","percent","label","e","set","remove","lang","dir","#hint","#area"],"sources":["../../../../editor/src/help.ts","../../../../editor/src/messages/help/en.json","../../../../editor/src/messages/help/pl.json","../../../../editor/src/elements/help-form.ts"],"sourcesContent":["/**\n * The help for students of one graded element, read from and written to its source HTML: its hints (in order, each\n * with its cost), its explanation and its feedback texts, its direct children. Writing replaces them all, after the\n * element's other children, and leaves everything else byte-identical. The help form edits plain text: a text becomes\n * paragraphs (text alone in an element in a line of text); a text not edited keeps its HTML.\n */\nimport {\n type ElementNode,\n EXPLANATION_TAG,\n FEEDBACK_TAG,\n FEEDBACK_VARIANTS,\n type FeedbackVariant,\n HELP_TAGS,\n HINT_TAG,\n isElement,\n type Node,\n textContent,\n} from '@astl/core';\nimport { parseHtml } from '@astl/engine';\nimport {\n applyEdits,\n attributeValue,\n type ElementRange,\n elementTree,\n escapeAttribute,\n escapeText,\n spaceBefore,\n} from './scan.js';\n\nexport interface HelpHint {\n /** Its content as written. */\n readonly html: string;\n /** Its `cost` attribute as written, null when it has none (free). */\n readonly cost: string | null;\n}\n\n/** An element's help. Contents are HTML as written; an absent explanation or feedback text is null or missing. */\nexport interface HelpValue {\n readonly hints: readonly HelpHint[];\n readonly explanation: string | null;\n readonly feedback: Readonly<Partial<Record<FeedbackVariant, string>>>;\n}\n\nconst inner = (source: string, range: ElementRange): string =>\n range.endTag === null && range.startTag.selfClosing\n ? ''\n : source.slice(range.startTag.end, range.endTag?.start ?? range.end);\n\nconst helpChildren = (root: ElementRange): ElementRange[] =>\n root.children.filter((c) => HELP_TAGS.has(c.name));\n\nconst isVariant = (value: string | null): value is FeedbackVariant =>\n FEEDBACK_VARIANTS.includes(value as FeedbackVariant);\n\n/** The help of the first element in `html`. Later duplicates of an explanation or a feedback text are left out. */\nexport function readHelp(html: string): HelpValue {\n const root = elementTree(html)[0];\n const hints: HelpHint[] = [];\n let explanation: string | null = null;\n const feedback: Partial<Record<FeedbackVariant, string>> = {};\n for (const child of root === undefined ? [] : helpChildren(root)) {\n const content = inner(html, child);\n if (child.name === HINT_TAG) hints.push({ html: content, cost: attributeValue(child.startTag, 'cost') });\n else if (child.name === EXPLANATION_TAG) explanation ??= content;\n else {\n const when = attributeValue(child.startTag, 'when');\n if (isVariant(when)) feedback[when] ??= content;\n }\n }\n return { hints, explanation, feedback };\n}\n\n/** The help as source: hints, the explanation, then the feedback texts in the order of `FEEDBACK_VARIANTS`. */\nfunction helpSource(help: HelpValue): string[] {\n const cost = (value: string | null) => (value === null ? '' : ` cost=\"${escapeAttribute(value)}\"`);\n return [\n ...help.hints.map((h) => `<${HINT_TAG}${cost(h.cost)}>${h.html}</${HINT_TAG}>`),\n ...(help.explanation === null ? [] : [`<${EXPLANATION_TAG}>${help.explanation}</${EXPLANATION_TAG}>`]),\n ...FEEDBACK_VARIANTS.flatMap((when) => {\n const text = help.feedback[when];\n return text === undefined ? [] : [`<${FEEDBACK_TAG} when=\"${when}\">${text}</${FEEDBACK_TAG}>`];\n }),\n ];\n}\n\n/** Replaces the help of the first element in `html` with `help`, after its other children. */\nexport function writeHelp(html: string, help: HelpValue): string {\n const first = elementTree(html)[0];\n if (first === undefined) return html;\n // Out first, then in: an insertion where a removal starts would shift it.\n const cleared = applyEdits(\n html,\n helpChildren(first).map((c) => ({ start: spaceBefore(html, c.start), end: c.end, text: '' })),\n );\n const added = helpSource(help);\n const root = elementTree(cleared)[0];\n if (root === undefined || added.length === 0) return cleared;\n const last = root.children.at(-1);\n if (last === undefined) {\n const at = root.endTag?.start ?? root.end;\n const closed = root.endTag === null && root.startTag.selfClosing;\n return closed\n ? `${cleared.slice(0, root.start)}${cleared.slice(root.start, spaceBefore(cleared, root.startTag.end - 2))}>${added.join('')}</${root.name}>${cleared.slice(root.end)}`\n : applyEdits(cleared, [{ start: at, end: at, text: added.join('') }]);\n }\n // On their own lines when the children are.\n const gap = cleared.slice(spaceBefore(cleared, last.start), last.start);\n const sep = /^\\s*$/.test(gap) ? gap : '';\n return applyEdits(cleared, [{ start: last.end, end: last.end, text: added.map((a) => sep + a).join('') }]);\n}\n\n/** The text of a node with its line breaks, as a field shows them (`textHelp` writes them back as `<br>`). */\nconst lines = (node: Node): string =>\n !isElement(node) ? textContent(node) : node.tag === 'br' ? '\\n' : node.children.map(lines).join('');\n\n/** What a help text says, for a text field: its paragraphs apart by a blank line, its line breaks kept. */\nexport function helpText(html: string): string {\n const blocks = (nodes: readonly Node[]): string[] =>\n nodes.flatMap((node) => {\n if (!isElement(node)) return [textContent(node)];\n return node.tag === 'p' || node.tag === 'li' ? [`\\n\\n${lines(node).trim()}\\n\\n`] : [lines(node)];\n });\n return blocks(parseHtml(html))\n .join('')\n .replace(/[ \\t]+/g, ' ')\n .split(/\\n{2,}/)\n .map((part) => part.trim())\n .filter(Boolean)\n .join('\\n\\n');\n}\n\n/**\n * Whether a help text holds more than its field writes back (paragraphs of plain text, or text alone for an element in\n * a line of text): a change in the field keeps the words and drops the rest, so the form says so first.\n */\nexport function helpFormatted(html: string, inline: boolean): boolean {\n // What a field writes: paragraphs holding text and line breaks; text alone in a line of text.\n const plain = (node: ElementNode, depth: number): boolean =>\n !inline &&\n Object.keys(node.attrs).length === 0 &&\n (depth === 0 ? node.tag === 'p' : depth === 1 && node.tag === 'br');\n const formatted = (nodes: readonly Node[], depth: number): boolean =>\n nodes.some((node) => isElement(node) && (!plain(node, depth) || formatted(node.children, depth + 1)));\n return formatted(parseHtml(html), 0);\n}\n\n/** HTML from a field's text: paragraphs (blank lines part them), or text alone for an element in a line of text. */\nexport function textHelp(text: string, inline: boolean): string {\n if (inline) return escapeText(text.replace(/\\s+/g, ' ').trim());\n return text\n .split(/\\n\\s*\\n/)\n .map((part) => part.trim())\n .filter(Boolean)\n .map((part) => `<p>${escapeText(part).replace(/\\n/g, '<br>')}</p>`)\n .join('');\n}\n","{\n \"help.title\": \"Help for students\",\n \"help.hints\": \"Hints\",\n \"help.hintsNote\": \"Students ask for them one at a time, in this order. A cost is the share of the question's points a student loses for using that hint.\",\n \"help.hintN\": \"Hint {n}\",\n \"help.cost\": \"Cost (% of the points)\",\n \"help.costN\": \"Hint {n}: cost (% of the points)\",\n \"help.addHint\": \"Add a hint\",\n \"help.up\": \"Up\",\n \"help.down\": \"Down\",\n \"help.upN\": \"Move hint {n} up\",\n \"help.downN\": \"Move hint {n} down\",\n \"help.removeN\": \"Remove hint {n}\",\n \"help.removeExplanation\": \"Remove the explanation\",\n \"help.removeFeedback\": \"Remove the feedback: {when}\",\n \"help.drag\": \"Drag to reorder\",\n \"help.explanationNote\": \"Students open it under \\\"Why?\\\" once their answer is checked. Leave it empty for none.\",\n \"help.feedbackNote\": \"Shown after a check, by the verdict. Leave a text empty for none.\",\n \"help.formatted\": \"This text has formatting. A change in this field keeps only the text.\"\n}\n","{\n \"help.title\": \"Pomoc dla ucznia\",\n \"help.hints\": \"Podpowiedzi\",\n \"help.hintsNote\": \"Uczeń prosi o nie po kolei, w tej kolejności. Koszt to część punktów za to pytanie, którą uczeń traci, gdy użyje podpowiedzi.\",\n \"help.hintN\": \"Podpowiedź {n}\",\n \"help.cost\": \"Koszt (% punktów)\",\n \"help.costN\": \"Podpowiedź {n}: koszt (% punktów)\",\n \"help.addHint\": \"Dodaj podpowiedź\",\n \"help.up\": \"W górę\",\n \"help.down\": \"W dół\",\n \"help.upN\": \"Przenieś podpowiedź {n} w górę\",\n \"help.downN\": \"Przenieś podpowiedź {n} w dół\",\n \"help.removeN\": \"Usuń podpowiedź {n}\",\n \"help.removeExplanation\": \"Usuń wyjaśnienie\",\n \"help.removeFeedback\": \"Usuń informację zwrotną: {when}\",\n \"help.drag\": \"Przeciągnij, aby zmienić kolejność\",\n \"help.explanationNote\": \"Uczeń otwiera je pod „Dlaczego?”, gdy jego odpowiedź zostanie sprawdzona. Zostaw puste, jeśli nie ma.\",\n \"help.feedbackNote\": \"Widać ją po sprawdzeniu, zależnie od wyniku. Zostaw tekst pusty, jeśli nie ma.\",\n \"help.formatted\": \"Ten tekst ma formatowanie. Zmiana w tym polu zostawi sam tekst.\"\n}\n","/**\n * `<astl-help-form>`: the inspector's \"Help for students\" section of a graded element: its hints in order, each with\n * its cost (Up, Down, a drag, Remove, Add), its explanation and its four feedback texts. Every edit rewrites the\n * element's help (`writeHelp`) through `EditorAdapter.replaceElement`. A module of its own, outside the editor's first\n * load (`loadHelpForm`), with its messages; `addHelp` is the insert menu's way in.\n */\nimport { type EditorAdapter, FEEDBACK_VARIANTS, type FeedbackVariant, type MessageCatalog } from '@astl/core';\nimport {\n type CSSResultGroup,\n css,\n html,\n nothing,\n type PropertyDeclarations,\n type PropertyValues,\n type TemplateResult,\n} from 'lit';\nimport { live } from 'lit/directives/live.js';\nimport type { Authoring } from '../authoring.js';\nimport { type HelpValue, helpFormatted, helpText, readHelp, textHelp, writeHelp } from '../help.js';\nimport en from '../messages/help/en.json' with { type: 'json' };\nimport pl from '../messages/help/pl.json' with { type: 'json' };\nimport { EDITOR_NAMESPACE } from '../messages.js';\nimport { AuthoringElement } from './base.js';\nimport { kitStyles } from './styles.js';\n\nconst helpMessages: readonly MessageCatalog[] = [\n { namespace: EDITOR_NAMESPACE, locale: 'en', messages: en },\n { namespace: EDITOR_NAMESPACE, locale: 'pl', messages: pl },\n];\n\n/** What the insert menu adds: a hint, the explanation, or the next feedback text the element lacks. */\nexport type HelpKind = 'hint' | 'explanation' | 'feedback';\n\n/** The field to focus once the form shows it (after an insert), by element id. */\nlet pending: { readonly element: string; readonly field: string } | null = null;\n\nconst graded = (authoring: Authoring, tag: string) => authoring.descriptor(tag)?.manifest.graded === true;\n\n/**\n * Adds help to the graded element at the cursor (and asks the form to focus it), or else to the page at the cursor.\n * Returns the HTML inserted on a page, or null when the element got it.\n */\nexport function addHelp(authoring: Authoring, adapter: EditorAdapter, kind: HelpKind): string | null {\n const selection = adapter.getSelection();\n const current = selection === null ? null : adapter.getElement(selection.id);\n if (selection === null || current === null || !graded(authoring, selection.tag)) {\n const block =\n kind === 'feedback'\n ? '<astl-feedback when=\"correct\"><p></p></astl-feedback>'\n : `<astl-${kind}><p></p></astl-${kind}>`;\n adapter.insert(block);\n return block;\n }\n const help = readHelp(current);\n let next: HelpValue;\n let field: string;\n if (kind === 'hint') {\n next = { ...help, hints: [...help.hints, { html: '', cost: null }] };\n field = `hint-${help.hints.length}`;\n } else if (kind === 'explanation') {\n next = { ...help, explanation: help.explanation ?? '' };\n field = 'explanation';\n } else {\n const when = FEEDBACK_ORDER.find((w) => help.feedback[w] === undefined) ?? 'correct';\n next = { ...help, feedback: { ...help.feedback, [when]: help.feedback[when] ?? '' } };\n field = `feedback-${when}`;\n }\n pending = { element: selection.id, field };\n adapter.replaceElement(selection.id, writeHelp(current, next));\n return null;\n}\n\n/** The order the menu fills feedback texts in: right and wrong first. */\nconst FEEDBACK_ORDER: readonly FeedbackVariant[] = ['correct', 'incorrect', 'omitted', 'partial'];\n\n/** A cost in percent of the points (0 to 100) from a `cost` attribute, or '' when there is none or it is not one. */\nconst percentOf = (cost: string | null): string => {\n if (cost === null) return '0';\n const n = Number(cost);\n return Number.isFinite(n) && n >= 0 && n <= 1 ? String(Math.round(n * 100)) : '';\n};\n\nconst inputValue = (event: Event) => (event.target as HTMLInputElement | HTMLTextAreaElement).value;\n\nexport class AstlHelpForm extends AuthoringElement {\n static override properties: PropertyDeclarations = {\n ...AuthoringElement.properties,\n element: {},\n inline: { type: Boolean },\n };\n\n static override styles: CSSResultGroup = [\n kitStyles,\n css`\n :host {\n display: block;\n }\n section {\n display: flex;\n flex-direction: column;\n gap: var(--astl-space-3);\n padding-block-start: var(--astl-space-3);\n border-block-start: var(--astl-outline-width) solid var(--astl-line);\n }\n h3 {\n margin: 0;\n font-size: 1rem;\n }\n fieldset,\n .field {\n display: flex;\n flex-direction: column;\n gap: var(--astl-space-1);\n min-inline-size: 0;\n margin: 0;\n padding: 0;\n border: 0;\n }\n legend,\n label {\n padding: 0;\n font-weight: 600;\n }\n ol {\n display: flex;\n flex-direction: column;\n gap: var(--astl-space-3);\n margin: 0;\n padding: 0;\n list-style: none;\n }\n li {\n display: flex;\n flex-direction: column;\n gap: var(--astl-space-1);\n padding: var(--astl-space-2);\n border: var(--astl-outline-width) solid var(--astl-line);\n border-radius: var(--astl-radius-s);\n }\n li[data-over] {\n border-color: var(--astl-accent);\n }\n .row {\n display: flex;\n flex-wrap: wrap;\n align-items: center;\n gap: var(--astl-space-2);\n }\n .handle {\n cursor: grab;\n user-select: none;\n }\n .cost {\n display: flex;\n align-items: center;\n gap: var(--astl-space-1);\n font-weight: 400;\n }\n .cost input {\n inline-size: 6em;\n }\n textarea {\n field-sizing: content;\n min-block-size: 3lh;\n resize: vertical;\n }\n .delete {\n color: var(--astl-danger);\n }\n `,\n ];\n\n /** Source id of the element whose help this is. */\n declare element: string | null;\n /** The element sits in a line of text: its help holds text, not paragraphs. */\n declare inline: boolean;\n /** What the author is typing in a field, by field: the source has it cleaned, the field keeps it as typed. */\n #drafts = new Map<string, string>();\n #dragged: number | null = null;\n\n constructor() {\n super();\n this.element = null;\n this.inline = false;\n }\n\n protected override willUpdate(changed: PropertyValues<this>): void {\n super.willUpdate(changed);\n if (changed.has('authoring')) this.authoring?.addMessages(helpMessages);\n if (changed.has('element')) this.#drafts.clear();\n }\n\n protected override updated(): void {\n if (pending === null || pending.element !== this.element) return;\n const field = this.renderRoot.querySelector<HTMLElement>(`[data-help=\"${pending.field}\"]`);\n if (field === null) return;\n pending = null;\n field.focus();\n }\n\n #help(): { readonly html: string; readonly help: HelpValue } | null {\n const html = this.element === null ? null : (this.adapter?.getElement(this.element) ?? null);\n return html === null ? null : { html, help: readHelp(html) };\n }\n\n #write(change: (help: HelpValue) => HelpValue): void {\n const current = this.#help();\n if (current === null || this.element === null || this.adapter === null) return;\n const next = writeHelp(current.html, change(current.help));\n if (next !== current.html) this.adapter.replaceElement(this.element, next);\n }\n\n /** A text field's value: as typed while it is being edited, else what the source says. */\n #text(field: string, html: string): string {\n return this.#drafts.get(field) ?? helpText(html);\n }\n\n /** The note under a field whose text has formatting a change there would drop; null when there is none. */\n #formatted(field: string, source: string): TemplateResult | null {\n return helpFormatted(source, this.inline)\n ? html`<p class=\"note\" id=${`${field}-formatted`}>${this.t('help.formatted')}</p>`\n : null;\n }\n\n #typed(field: string, event: Event): string {\n const value = inputValue(event);\n this.#drafts.set(field, value);\n return textHelp(value, this.inline);\n }\n\n #done(field: string): void {\n this.#drafts.delete(field);\n this.requestUpdate();\n }\n\n #move(from: number, to: number): void {\n this.#write((help) => {\n if (to < 0 || to >= help.hints.length || from === to) return help;\n const hints = [...help.hints];\n const [moved] = hints.splice(from, 1);\n if (moved !== undefined) hints.splice(to, 0, moved);\n return { ...help, hints };\n });\n this.#drafts.clear();\n }\n\n #hint(help: HelpValue, index: number): TemplateResult {\n const hint = help.hints[index] as HelpValue['hints'][number];\n const n = index + 1;\n const field = `hint-${index}`;\n const last = index === help.hints.length - 1;\n const formatted = this.#formatted(field, hint.html);\n const over = (event: DragEvent, on: boolean) => {\n if (this.#dragged === null) return;\n event.preventDefault();\n (event.currentTarget as HTMLElement).toggleAttribute('data-over', on);\n };\n return html`<li\n @dragover=${(e: DragEvent) => over(e, true)}\n @dragleave=${(e: DragEvent) => over(e, false)}\n @drop=${(e: DragEvent) => {\n over(e, false);\n if (this.#dragged !== null) this.#move(this.#dragged, index);\n this.#dragged = null;\n }}\n >\n <div class=\"row\">\n <span\n class=\"handle\"\n draggable=\"true\"\n aria-hidden=\"true\"\n title=${this.t('help.drag')}\n @dragstart=${(e: DragEvent) => {\n this.#dragged = index;\n e.dataTransfer?.setData('text/plain', String(n));\n }}\n @dragend=${() => {\n this.#dragged = null;\n }}\n >⠿</span\n >\n <label for=${field}>${this.t('help.hintN', { n })}</label>\n </div>\n <textarea\n id=${field}\n data-help=${field}\n dir=\"auto\"\n aria-describedby=${formatted === null ? nothing : `${field}-formatted`}\n .value=${live(this.#text(field, hint.html))}\n @input=${(e: Event) => {\n const text = this.#typed(field, e);\n this.#write((h) => ({\n ...h,\n hints: h.hints.map((x, i) => (i === index ? { ...x, html: text } : x)),\n }));\n }}\n @change=${() => this.#done(field)}\n ></textarea>\n ${formatted ?? nothing}\n <div class=\"row\">\n <label class=\"cost\">\n ${this.t('help.cost')}\n <input\n type=\"number\"\n aria-label=${this.t('help.costN', { n })}\n min=\"0\"\n max=\"100\"\n step=\"5\"\n inputmode=\"numeric\"\n data-help=${`cost-${index}`}\n .value=${live(percentOf(hint.cost))}\n @change=${(e: Event) => {\n const percent = Number(inputValue(e));\n if (!Number.isFinite(percent) || percent < 0 || percent > 100) return;\n const cost = percent === 0 ? null : String(Math.round(percent) / 100);\n this.#write((h) => ({\n ...h,\n hints: h.hints.map((x, i) => (i === index ? { ...x, cost } : x)),\n }));\n }}\n />\n </label>\n <button type=\"button\" aria-label=${this.t('help.upN', { n })} aria-disabled=${String(index === 0)}\n @click=${() => this.#move(index, index - 1)}>${this.t('help.up')}</button>\n <button type=\"button\" aria-label=${this.t('help.downN', { n })} aria-disabled=${String(last)}\n @click=${() => this.#move(index, index + 1)}>${this.t('help.down')}</button>\n <button type=\"button\" class=\"delete\" aria-label=${this.t('help.removeN', { n })}\n @click=${() => {\n this.#drafts.clear();\n this.#write((h) => ({ ...h, hints: h.hints.filter((_, i) => i !== index) }));\n pending = {\n element: this.element ?? '',\n field: help.hints.length > 1 ? `hint-${Math.max(0, index - 1)}` : 'add-hint',\n };\n }}>${this.t('inspector.remove')}</button>\n </div>\n </li>`;\n }\n\n /**\n * A text field of the help: the explanation or a feedback text. While the element has it, \"Remove\" takes it away:\n * one the menu added stays empty, so clearing the field would not.\n */\n #area(\n field: string,\n label: string,\n remove: string,\n value: string | null | undefined,\n set: (html: string | null) => void,\n ): TemplateResult {\n const formatted = this.#formatted(field, value ?? '');\n return html`<div class=\"field\">\n <label for=${field}>${label}</label>\n <textarea\n id=${field}\n data-help=${field}\n dir=\"auto\"\n aria-describedby=${formatted === null ? nothing : `${field}-formatted`}\n .value=${live(this.#text(field, value ?? ''))}\n @input=${(e: Event) => {\n const text = this.#typed(field, e);\n set(text === '' ? null : text);\n }}\n @change=${() => this.#done(field)}\n ></textarea>\n ${formatted ?? nothing}\n ${\n value === null || value === undefined\n ? nothing\n : html`<div class=\"row\">\n <button type=\"button\" class=\"delete\" aria-label=${remove}\n @click=${() => {\n this.#drafts.delete(field);\n // The field stays, empty: the focus goes back to it.\n pending = { element: this.element ?? '', field };\n set(null);\n }}>${this.t('inspector.remove')}</button>\n </div>`\n }\n </div>`;\n }\n\n protected override render(): TemplateResult | typeof nothing {\n const current = this.#help();\n if (current === null || this.authoring === null) return nothing;\n const { help } = current;\n const { lang, dir } = this.ui;\n return html`<section class=\"kit\" part=\"help\" lang=${lang} dir=${dir} aria-labelledby=\"help-title\">\n <h3 id=\"help-title\">${this.t('help.title')}</h3>\n <fieldset aria-describedby=\"hints-note\">\n <legend>${this.t('help.hints')}</legend>\n <p class=\"note\" id=\"hints-note\">${this.t('help.hintsNote')}</p>\n ${help.hints.length === 0 ? nothing : html`<ol>${help.hints.map((_, i) => this.#hint(help, i))}</ol>`}\n <div class=\"row\">\n <button type=\"button\" data-help=\"add-hint\"\n @click=${() => {\n pending = { element: this.element ?? '', field: `hint-${help.hints.length}` };\n this.#write((h) => ({ ...h, hints: [...h.hints, { html: '', cost: null }] }));\n }}>${this.t('help.addHint')}</button>\n </div>\n </fieldset>\n ${this.#area(\n 'explanation',\n this.t('insert.explanation'),\n this.t('help.removeExplanation'),\n help.explanation,\n (text) => this.#write((h) => ({ ...h, explanation: text })),\n )}\n <p class=\"note\">${this.t('help.explanationNote')}</p>\n <fieldset aria-describedby=\"feedback-note\">\n <legend>${this.t('insert.feedback')}</legend>\n <p class=\"note\" id=\"feedback-note\">${this.t('help.feedbackNote')}</p>\n ${FEEDBACK_VARIANTS.map((when) =>\n this.#area(\n `feedback-${when}`,\n this.t(`help.when.${when}`),\n this.t('help.removeFeedback', { when: this.t(`help.when.${when}`) }),\n help.feedback[when],\n (text) =>\n this.#write((h) => {\n const feedback: Partial<Record<FeedbackVariant, string>> = { ...h.feedback };\n if (text === null) delete feedback[when];\n else feedback[when] = text;\n return { ...h, feedback };\n }),\n ),\n )}\n </fieldset>\n </section>`;\n }\n}\n"],"mappings":"A,0WA2CA,IAAMyB,GAAS,EAAgB,IAC7BC,EAAM,SAAW,MAAQA,EAAM,SAAS,YACpC,GACAC,EAAO,MAAMD,EAAM,SAAS,IAAKA,EAAM,QAAQ,OAASA,EAAM,GAAG,EAEjEE,EAAgB,GACpBC,EAAK,SAAS,OAAQ,GAAMrB,EAAU,IAAIsB,EAAE,IAAI,CAAC,EAE7CC,EAAa,GACjBrB,EAAkB,SAASsB,CAAwB,EAGrD,SAAgBC,EAAS,EAAyB,CAChD,IAAMJ,EAAOV,EAAYe,CAAI,CAAC,CAAC,GACzBC,EAAoB,CAAC,EACvBC,EAA6B,KAC3BC,EAAqD,CAAC,EAC5D,IAAK,IAAMC,KAAST,IAAS,IAAA,GAAY,CAAC,EAAID,EAAaC,CAAI,EAAG,CAChE,IAAMU,EAAUd,EAAMS,EAAMI,CAAK,EACjC,GAAIA,EAAM,OAAA,YAAmBH,EAAM,KAAK,CAAE,KAAMI,EAAS,KAAMtB,EAAeqB,EAAM,SAAU,MAAM,CAAE,CAAC,OAClG,GAAIA,EAAM,OAAA,mBAA0B,IAAgBC,MACpD,CACH,IAAMC,EAAOvB,EAAeqB,EAAM,SAAU,MAAM,EAC9CP,EAAUS,CAAI,IAAG,EAASA,KAAUD,EAC1C,CACF,CACA,MAAO,CAAE,QAAO,cAAa,UAAS,CACxC,CAGA,SAASE,EAAW,EAA2B,CAC7C,IAAMC,EAAQ,GAA0BV,IAAU,KAAO,GAAK,UAAUjB,EAAgBiB,CAAK,EAAE,GAC/F,MAAO,CACL,GAAG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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-9xiYDvRT.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-DxJJxVNH.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-D5haJtWM.js`),import(`./style-rules-D45PZLCv.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-DaC6KaFG.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-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-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-CXkkL_Qi.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-D1C2sHzg.js`),import(`./style-rules-ChqPVgZn.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-DhIyMziw.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-
|
|
80
|
+
//# sourceMappingURL=insert-menu-Cn2E54V9.js.map
|