@astl/astrolabe 0.0.0-stage → 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (188) hide show
  1. package/CHANGELOG.md +119 -0
  2. package/LICENSE +202 -0
  3. package/README.md +64 -2
  4. package/dist/cdn/astrolabe-editor.js +1441 -0
  5. package/dist/cdn/astrolabe-editor.js.map +1 -0
  6. package/dist/cdn/astrolabe-player.js +2 -0
  7. package/dist/cdn/astrolabe-player.js.map +1 -0
  8. package/dist/cdn/astrolabe.css +238 -0
  9. package/dist/cdn/astrolabe.js +3 -0
  10. package/dist/cdn/astrolabe.js.map +1 -0
  11. package/dist/cdn/astrolabe.standalone.js +8007 -0
  12. package/dist/cdn/chunks/audio-B0LSIn5N.js +48 -0
  13. package/dist/cdn/chunks/audio-B0LSIn5N.js.map +1 -0
  14. package/dist/cdn/chunks/audio-manifest-B9FWQzRy.js +2 -0
  15. package/dist/cdn/chunks/audio-manifest-B9FWQzRy.js.map +1 -0
  16. package/dist/cdn/chunks/block-styles-CKo9x7Vt.js +68 -0
  17. package/dist/cdn/chunks/block-styles-CKo9x7Vt.js.map +1 -0
  18. package/dist/cdn/chunks/book-CHzDDaim.js +15 -0
  19. package/dist/cdn/chunks/book-CHzDDaim.js.map +1 -0
  20. package/dist/cdn/chunks/callout-QFLFLPc5.js +49 -0
  21. package/dist/cdn/chunks/callout-QFLFLPc5.js.map +1 -0
  22. package/dist/cdn/chunks/callout-manifest-Cb12O4jl.js +2 -0
  23. package/dist/cdn/chunks/callout-manifest-Cb12O4jl.js.map +1 -0
  24. package/dist/cdn/chunks/categorise-BO2tNVJ3.js +203 -0
  25. package/dist/cdn/chunks/categorise-BO2tNVJ3.js.map +1 -0
  26. package/dist/cdn/chunks/categorise-manifest-C_hEDVYQ.js +2 -0
  27. package/dist/cdn/chunks/categorise-manifest-C_hEDVYQ.js.map +1 -0
  28. package/dist/cdn/chunks/chip-styles-Dme5daTO.js +77 -0
  29. package/dist/cdn/chunks/chip-styles-Dme5daTO.js.map +1 -0
  30. package/dist/cdn/chunks/choice-CExBvqKj.js +136 -0
  31. package/dist/cdn/chunks/choice-CExBvqKj.js.map +1 -0
  32. package/dist/cdn/chunks/choice-manifest-C-XahD7m.js +2 -0
  33. package/dist/cdn/chunks/choice-manifest-C-XahD7m.js.map +1 -0
  34. package/dist/cdn/chunks/color-control-Cl5cuMSO.js +91 -0
  35. package/dist/cdn/chunks/color-control-Cl5cuMSO.js.map +1 -0
  36. package/dist/cdn/chunks/crossword-Cb-a3Tjj.js +270 -0
  37. package/dist/cdn/chunks/crossword-Cb-a3Tjj.js.map +1 -0
  38. package/dist/cdn/chunks/crossword-manifest-2qlu7AYd.js +2 -0
  39. package/dist/cdn/chunks/crossword-manifest-2qlu7AYd.js.map +1 -0
  40. package/dist/cdn/chunks/declarations-BhqOz1ap.js +2 -0
  41. package/dist/cdn/chunks/declarations-BhqOz1ap.js.map +1 -0
  42. package/dist/cdn/chunks/definitions-CNX90WtL.js +6 -0
  43. package/dist/cdn/chunks/definitions-CNX90WtL.js.map +1 -0
  44. package/dist/cdn/chunks/directive-helpers-D7lOZKnB.js +14 -0
  45. package/dist/cdn/chunks/directive-helpers-D7lOZKnB.js.map +1 -0
  46. package/dist/cdn/chunks/drop-manifest-bzNOa5ks.js +2 -0
  47. package/dist/cdn/chunks/drop-manifest-bzNOa5ks.js.map +1 -0
  48. package/dist/cdn/chunks/drop-vRXndjHu.js +86 -0
  49. package/dist/cdn/chunks/drop-vRXndjHu.js.map +1 -0
  50. package/dist/cdn/chunks/flash-cards-0NrrKdrx.js +87 -0
  51. package/dist/cdn/chunks/flash-cards-0NrrKdrx.js.map +1 -0
  52. package/dist/cdn/chunks/flash-cards-manifest-B8nWXbRy.js +2 -0
  53. package/dist/cdn/chunks/flash-cards-manifest-B8nWXbRy.js.map +1 -0
  54. package/dist/cdn/chunks/gap-lor-khst.js +78 -0
  55. package/dist/cdn/chunks/gap-lor-khst.js.map +1 -0
  56. package/dist/cdn/chunks/gap-manifest-RSydA41N.js +2 -0
  57. package/dist/cdn/chunks/gap-manifest-RSydA41N.js.map +1 -0
  58. package/dist/cdn/chunks/help-C-woafz5.js +138 -0
  59. package/dist/cdn/chunks/help-C-woafz5.js.map +1 -0
  60. package/dist/cdn/chunks/help-form-DaC6KaFG.js +160 -0
  61. package/dist/cdn/chunks/help-form-DaC6KaFG.js.map +1 -0
  62. package/dist/cdn/chunks/hotspot-manifest-CNs1oiZ_.js +2 -0
  63. package/dist/cdn/chunks/hotspot-manifest-CNs1oiZ_.js.map +1 -0
  64. package/dist/cdn/chunks/hotspot-oel1Eelo.js +154 -0
  65. package/dist/cdn/chunks/hotspot-oel1Eelo.js.map +1 -0
  66. package/dist/cdn/chunks/image-drop-Dkprw0Kn.js +295 -0
  67. package/dist/cdn/chunks/image-drop-Dkprw0Kn.js.map +1 -0
  68. package/dist/cdn/chunks/image-drop-manifest-BZ6hCoAd.js +2 -0
  69. package/dist/cdn/chunks/image-drop-manifest-BZ6hCoAd.js.map +1 -0
  70. package/dist/cdn/chunks/image-label-Dm5shQSh.js +177 -0
  71. package/dist/cdn/chunks/image-label-Dm5shQSh.js.map +1 -0
  72. package/dist/cdn/chunks/image-label-manifest--1CLRJzd.js +2 -0
  73. package/dist/cdn/chunks/image-label-manifest--1CLRJzd.js.map +1 -0
  74. package/dist/cdn/chunks/inline-styles-CTgXWnHb.js +80 -0
  75. package/dist/cdn/chunks/inline-styles-CTgXWnHb.js.map +1 -0
  76. package/dist/cdn/chunks/insert-menu-LgrifBYT.js +80 -0
  77. package/dist/cdn/chunks/insert-menu-LgrifBYT.js.map +1 -0
  78. package/dist/cdn/chunks/issue-list-BgnXzXRM.js +51 -0
  79. package/dist/cdn/chunks/issue-list-BgnXzXRM.js.map +1 -0
  80. package/dist/cdn/chunks/keys-DU-Qknmz.js +2 -0
  81. package/dist/cdn/chunks/keys-DU-Qknmz.js.map +1 -0
  82. package/dist/cdn/chunks/live-jdiyYln2.js +7 -0
  83. package/dist/cdn/chunks/live-jdiyYln2.js.map +1 -0
  84. package/dist/cdn/chunks/long-answer-CtzClLAx.js +71 -0
  85. package/dist/cdn/chunks/long-answer-CtzClLAx.js.map +1 -0
  86. package/dist/cdn/chunks/long-answer-manifest-BYJpZRtB.js +2 -0
  87. package/dist/cdn/chunks/long-answer-manifest-BYJpZRtB.js.map +1 -0
  88. package/dist/cdn/chunks/mark-words-CpH3gTcX.js +131 -0
  89. package/dist/cdn/chunks/mark-words-CpH3gTcX.js.map +1 -0
  90. package/dist/cdn/chunks/mark-words-manifest-Cs2pXCEx.js +2 -0
  91. package/dist/cdn/chunks/mark-words-manifest-Cs2pXCEx.js.map +1 -0
  92. package/dist/cdn/chunks/match-DKE_4o-x.js +352 -0
  93. package/dist/cdn/chunks/match-DKE_4o-x.js.map +1 -0
  94. package/dist/cdn/chunks/match-manifest-D0UfoajU.js +2 -0
  95. package/dist/cdn/chunks/match-manifest-D0UfoajU.js.map +1 -0
  96. package/dist/cdn/chunks/memory-B6hSyHyz.js +187 -0
  97. package/dist/cdn/chunks/memory-B6hSyHyz.js.map +1 -0
  98. package/dist/cdn/chunks/memory-manifest-D1589iR0.js +2 -0
  99. package/dist/cdn/chunks/memory-manifest-D1589iR0.js.map +1 -0
  100. package/dist/cdn/chunks/menu-messages-Dx3jYUEp.js +2 -0
  101. package/dist/cdn/chunks/menu-messages-Dx3jYUEp.js.map +1 -0
  102. package/dist/cdn/chunks/messages-9xiYDvRT.js +2 -0
  103. package/dist/cdn/chunks/messages-9xiYDvRT.js.map +1 -0
  104. package/dist/cdn/chunks/option-styles-WKzjKmCH.js +50 -0
  105. package/dist/cdn/chunks/option-styles-WKzjKmCH.js.map +1 -0
  106. package/dist/cdn/chunks/order-BhG_6IC-.js +225 -0
  107. package/dist/cdn/chunks/order-BhG_6IC-.js.map +1 -0
  108. package/dist/cdn/chunks/order-manifest-J5IXN0he.js +2 -0
  109. package/dist/cdn/chunks/order-manifest-J5IXN0he.js.map +1 -0
  110. package/dist/cdn/chunks/pick-and-place-DVQIPYuL.js +2 -0
  111. package/dist/cdn/chunks/pick-and-place-DVQIPYuL.js.map +1 -0
  112. package/dist/cdn/chunks/picture-D10YRMYH.js +2 -0
  113. package/dist/cdn/chunks/picture-D10YRMYH.js.map +1 -0
  114. package/dist/cdn/chunks/picture-view-BKnAyScQ.js +92 -0
  115. package/dist/cdn/chunks/picture-view-BKnAyScQ.js.map +1 -0
  116. package/dist/cdn/chunks/repeat-CY2W2URZ.js +8 -0
  117. package/dist/cdn/chunks/repeat-CY2W2URZ.js.map +1 -0
  118. package/dist/cdn/chunks/roving-focus-BxGgi2DD.js +2 -0
  119. package/dist/cdn/chunks/roving-focus-BxGgi2DD.js.map +1 -0
  120. package/dist/cdn/chunks/runtime-DxAbpr3S.js +526 -0
  121. package/dist/cdn/chunks/runtime-DxAbpr3S.js.map +1 -0
  122. package/dist/cdn/chunks/scan-jWgPnVxA.js +2 -0
  123. package/dist/cdn/chunks/scan-jWgPnVxA.js.map +1 -0
  124. package/dist/cdn/chunks/select-DTA3dJzr.js +345 -0
  125. package/dist/cdn/chunks/select-DTA3dJzr.js.map +1 -0
  126. package/dist/cdn/chunks/select-manifest-BBMbvdkH.js +2 -0
  127. package/dist/cdn/chunks/select-manifest-BBMbvdkH.js.map +1 -0
  128. package/dist/cdn/chunks/source-view-DXKPFCl9.js +29 -0
  129. package/dist/cdn/chunks/source-view-DXKPFCl9.js.map +1 -0
  130. package/dist/cdn/chunks/style-form-D5haJtWM.js +240 -0
  131. package/dist/cdn/chunks/style-form-D5haJtWM.js.map +1 -0
  132. package/dist/cdn/chunks/style-messages-BbZpeD2a.js +2 -0
  133. package/dist/cdn/chunks/style-messages-BbZpeD2a.js.map +1 -0
  134. package/dist/cdn/chunks/style-model-ZXNe_c8R.js +2 -0
  135. package/dist/cdn/chunks/style-model-ZXNe_c8R.js.map +1 -0
  136. package/dist/cdn/chunks/style-placing-DPw1zyrz.js +2 -0
  137. package/dist/cdn/chunks/style-placing-DPw1zyrz.js.map +1 -0
  138. package/dist/cdn/chunks/style-popups-BobgX1WK.js +74 -0
  139. package/dist/cdn/chunks/style-popups-BobgX1WK.js.map +1 -0
  140. package/dist/cdn/chunks/style-rules-D45PZLCv.js +136 -0
  141. package/dist/cdn/chunks/style-rules-D45PZLCv.js.map +1 -0
  142. package/dist/cdn/chunks/styled-Dmx5Yjv7.js +57 -0
  143. package/dist/cdn/chunks/styled-Dmx5Yjv7.js.map +1 -0
  144. package/dist/cdn/chunks/styles-DxJJxVNH.js +136 -0
  145. package/dist/cdn/chunks/styles-DxJJxVNH.js.map +1 -0
  146. package/dist/cdn/chunks/surface-CgxfAwCR.js +1019 -0
  147. package/dist/cdn/chunks/surface-CgxfAwCR.js.map +1 -0
  148. package/dist/cdn/chunks/true-false-DP3MO599.js +146 -0
  149. package/dist/cdn/chunks/true-false-DP3MO599.js.map +1 -0
  150. package/dist/cdn/chunks/true-false-manifest-B4exv60u.js +2 -0
  151. package/dist/cdn/chunks/true-false-manifest-B4exv60u.js.map +1 -0
  152. package/dist/cdn/chunks/video-j9MCH6Kw.js +98 -0
  153. package/dist/cdn/chunks/video-j9MCH6Kw.js.map +1 -0
  154. package/dist/cdn/chunks/video-manifest-8OwkhhAI.js +2 -0
  155. package/dist/cdn/chunks/video-manifest-8OwkhhAI.js.map +1 -0
  156. package/dist/cdn/chunks/word-bank-ARjwUKZf.js +80 -0
  157. package/dist/cdn/chunks/word-bank-ARjwUKZf.js.map +1 -0
  158. package/dist/cdn/chunks/word-bank-manifest-C1FSo1kH.js +2 -0
  159. package/dist/cdn/chunks/word-bank-manifest-C1FSo1kH.js.map +1 -0
  160. package/dist/cdn/chunks/word-search-AHvM7yCJ.js +274 -0
  161. package/dist/cdn/chunks/word-search-AHvM7yCJ.js.map +1 -0
  162. package/dist/cdn/chunks/word-search-manifest-Fg1a59Z1.js +2 -0
  163. package/dist/cdn/chunks/word-search-manifest-Fg1a59Z1.js.map +1 -0
  164. package/dist/editor.d.ts +32 -0
  165. package/dist/editor.d.ts.map +1 -0
  166. package/dist/editor.js +51 -0
  167. package/dist/editor.js.map +1 -0
  168. package/dist/engine.d.ts +33 -0
  169. package/dist/engine.d.ts.map +1 -0
  170. package/dist/engine.js +53 -0
  171. package/dist/engine.js.map +1 -0
  172. package/dist/player.d.ts +19 -0
  173. package/dist/player.d.ts.map +1 -0
  174. package/dist/player.js +22 -0
  175. package/dist/player.js.map +1 -0
  176. package/dist/server.d.ts +8 -0
  177. package/dist/server.d.ts.map +1 -0
  178. package/dist/server.js +8 -0
  179. package/dist/server.js.map +1 -0
  180. package/package.json +70 -3
  181. package/src/bundles/astrolabe-editor.ts +11 -0
  182. package/src/bundles/astrolabe-player.ts +10 -0
  183. package/src/bundles/astrolabe-standalone.ts +23 -0
  184. package/src/bundles/astrolabe.ts +12 -0
  185. package/src/editor.ts +98 -0
  186. package/src/engine.ts +59 -0
  187. package/src/player.ts +23 -0
  188. package/src/server.ts +7 -0
@@ -0,0 +1,2 @@
1
+ var e=/^-?(\d+(\.\d+)?|\.\d+)$/,t=t=>t!==null&&e.test(t.trim())?Number(t):null;function n(e){let n=(e??``).trim().split(/\s+/).filter(Boolean),r=[];for(let e of n){let[n=null,i=null,a]=e.split(`,`).map(e=>t(e));if(n===null||i===null||a!==void 0)return null;r.push([n,i])}return r}var r=e=>{let t=e(`shape`);return t===`circle`||t===`polygon`?t:`rect`};function i(e){let i=n=>t(e(n))??0;return{shape:r(e),x:i(`x`),y:i(`y`),width:i(`width`),height:i(`height`),r:i(`r`),points:n(e(`points`))??[]}}function a(e){let t=0;return e.forEach(([n,r],i)=>{let[a,o]=e[(i+1)%e.length]??[n,r];t+=n*o-a*r}),t}function o(e){let o=r(e),s=(...n)=>n.every(n=>t(e(n))!==null);if(o===`polygon`){let t=n(e(`points`));return t===null||t.length<3||t.length>64?`points`:t.some(([e,t])=>e<0||e>100||t<0||t>100)?`outside`:Math.abs(a(t))>1e-9?null:`empty`}let{x:c,y:l,width:u,height:d,r:f}=i(e);return o===`circle`?s(`x`,`y`,`r`)?c-f<-1e-9||c+f>100.000000001||l<0||l>100?`outside`:f>0?null:`empty`:`incomplete`:s(`x`,`y`,`width`,`height`)?c<0||l<0||c+u>100.000000001||l+d>100.000000001?`outside`:u>0&&d>0?null:`empty`:`incomplete`}function s(e,t){let{shape:n,x:r,y:i,width:a,height:o,r:s,points:c}=e;if(n===`circle`)return{left:r-s,top:i-s*t,right:r+s,bottom:i+s*t};if(n===`rect`)return{left:r,top:i,right:r+a,bottom:i+o};let l={left:100,top:100,right:0,bottom:0};for(let[e,t]of c)l.left=Math.min(l.left,e),l.top=Math.min(l.top,t),l.right=Math.max(l.right,e),l.bottom=Math.max(l.bottom,t);return l}function c(e){if(e.shape===`circle`)return[e.x,e.y];let t=s(e,1);return[(t.left+t.right)/2,(t.top+t.bottom)/2]}function l(e,t){return e.shape===`circle`?Math.PI*e.r*e.r*t:e.shape===`rect`?e.width*e.height:Math.abs(a(e.points))/2}function u(e,t){return e.map((e,n)=>({item:e,index:n,at:t(e)})).sort((e,t)=>e.at[1]-t.at[1]||e.at[0]-t.at[0]||e.index-t.index).map(({item:e})=>e)}export{u as a,i,s as n,o,c as r,l as t};
2
+ //# sourceMappingURL=picture-D10YRMYH.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"picture-D10YRMYH.js","names":["DECIMAL","numberOf","value","parsePoints","pairs","points","pair","x","y","extra","n","shapeOf","shape","read","readRegion","name","shoelace","sum","nx","ny","regionProblem","has","names","r","width","height","boundsOf","region","aspect","box","px","py","centreOf","areaOf","readingOrder","items","centre","item","a","b"],"sources":["../../../../components/src/picture.ts"],"sourcesContent":["/**\n * Geometry of the picture types (hotspot regions, image-drop zones, image-label pins), shared by their definitions\n * (validation, view order) and their elements (layout). Coordinates are percent of the picture, which never mirrors:\n * x of its width from the left edge, y of its height from the top. A circle's radius is percent of the width, so it\n * stays round on a picture of any shape. No imports: the engine side and the student side both load it.\n */\n\nexport type Shape = 'rect' | 'circle' | 'polygon';\nexport type Point = readonly [x: number, y: number];\n\n/** Fewest and most points a polygon takes. */\nexport const MIN_POINTS = 3;\nexport const MAX_POINTS = 64;\n\n/** A zone of a picture: a rectangle (x, y its top-left corner), a circle (x, y its centre) or a polygon. */\nexport interface Region {\n readonly shape: Shape;\n readonly x: number;\n readonly y: number;\n readonly width: number;\n readonly height: number;\n /** The radius of a circle, in percent of the picture's width. */\n readonly r: number;\n readonly points: readonly Point[];\n}\n\n/** Reads one attribute of a zone: definitions read source nodes, elements DOM elements. */\nexport type Read = (name: string) => string | null;\n\n/** What a region lacks: a value of its shape, valid points, room inside the picture, an area. */\nexport type RegionProblem = 'incomplete' | 'points' | 'outside' | 'empty';\n\n/** The decimal grammar of number attributes (a dot, no exponent), as the engine checks them. */\nconst DECIMAL = /^-?(\\d+(\\.\\d+)?|\\.\\d+)$/;\n/** Sums of decimals such as 33.3 + 66.7 land a hair past 100. */\nconst EPSILON = 1e-9;\n\nconst numberOf = (value: string | null): number | null =>\n value !== null && DECIMAL.test(value.trim()) ? Number(value) : null;\n\n/** Polygon points written as `x,y x,y ...`; null when one is not two numbers. */\nexport function parsePoints(value: string | null): Point[] | null {\n const pairs = (value ?? '').trim().split(/\\s+/).filter(Boolean);\n const points: Point[] = [];\n for (const pair of pairs) {\n const [x = null, y = null, extra] = pair.split(',').map((n) => numberOf(n));\n if (x === null || y === null || extra !== undefined) return null;\n points.push([x, y]);\n }\n return points;\n}\n\nconst shapeOf = (read: Read): Shape => {\n const shape = read('shape');\n return shape === 'circle' || shape === 'polygon' ? shape : 'rect';\n};\n\n/** The region the attributes describe; a missing or unreadable value reads as 0 (views are validated). */\nexport function readRegion(read: Read): Region {\n const n = (name: string) => numberOf(read(name)) ?? 0;\n return {\n shape: shapeOf(read),\n x: n('x'),\n y: n('y'),\n width: n('width'),\n height: n('height'),\n r: n('r'),\n points: parsePoints(read('points')) ?? [],\n };\n}\n\n/** Twice the signed area of a polygon (shoelace). */\nfunction shoelace(points: readonly Point[]): number {\n let sum = 0;\n points.forEach(([x, y], i) => {\n const [nx, ny] = points[(i + 1) % points.length] ?? [x, y];\n sum += x * ny - nx * y;\n });\n return sum;\n}\n\n/**\n * What is wrong with a region, or null. The engine has checked each value against the manifest (numbers from 0 to\n * 100, a radius up to 50); this adds what spans values: every value of the shape there, polygons of 3 to 64 points\n * inside the picture, a rectangle or a circle's width inside it, and an area. A circle's height depends on the\n * picture's shape, which the source need not say.\n */\nexport function regionProblem(read: Read): RegionProblem | null {\n const shape = shapeOf(read);\n const has = (...names: string[]) => names.every((name) => numberOf(read(name)) !== null);\n if (shape === 'polygon') {\n const points = parsePoints(read('points'));\n if (points === null || points.length < MIN_POINTS || points.length > MAX_POINTS) return 'points';\n if (points.some(([x, y]) => x < 0 || x > 100 || y < 0 || y > 100)) return 'outside';\n return Math.abs(shoelace(points)) > EPSILON ? null : 'empty';\n }\n const { x, y, width, height, r } = readRegion(read);\n if (shape === 'circle') {\n if (!has('x', 'y', 'r')) return 'incomplete';\n if (x - r < -EPSILON || x + r > 100 + EPSILON || y < 0 || y > 100) return 'outside';\n return r > 0 ? null : 'empty';\n }\n if (!has('x', 'y', 'width', 'height')) return 'incomplete';\n if (x < 0 || y < 0 || x + width > 100 + EPSILON || y + height > 100 + EPSILON) return 'outside';\n return width > 0 && height > 0 ? null : 'empty';\n}\n\nexport interface Bounds {\n readonly left: number;\n readonly top: number;\n readonly right: number;\n readonly bottom: number;\n}\n\n/**\n * A region's bounding box in percent. `aspect` is the picture's width over its height: a circle's radius in percent\n * of the height is its radius in percent of the width times the aspect.\n */\nexport function boundsOf(region: Region, aspect: number): Bounds {\n const { shape, x, y, width, height, r, points } = region;\n if (shape === 'circle') return { left: x - r, top: y - r * aspect, right: x + r, bottom: y + r * aspect };\n if (shape === 'rect') return { left: x, top: y, right: x + width, bottom: y + height };\n // A loop, not Math.min(...xs): any number of points stays off the call stack.\n const box = { left: 100, top: 100, right: 0, bottom: 0 };\n for (const [px, py] of points) {\n box.left = Math.min(box.left, px);\n box.top = Math.min(box.top, py);\n box.right = Math.max(box.right, px);\n box.bottom = Math.max(box.bottom, py);\n }\n return box;\n}\n\n/** Where a region's marker sits: its centre (the centre of the bounding box of a polygon). */\nexport function centreOf(region: Region): Point {\n if (region.shape === 'circle') return [region.x, region.y];\n const box = boundsOf(region, 1);\n return [(box.left + box.right) / 2, (box.top + box.bottom) / 2];\n}\n\n/** A region's area in square percent of the picture (`aspect` as in `boundsOf`). */\nexport function areaOf(region: Region, aspect: number): number {\n if (region.shape === 'circle') return Math.PI * region.r * region.r * aspect;\n if (region.shape === 'rect') return region.width * region.height;\n return Math.abs(shoelace(region.points)) / 2;\n}\n\n/** Items in reading order of their centres: top to bottom, then left to right (the source order breaks ties). */\nexport function readingOrder<T>(items: readonly T[], centre: (item: T) => Point): T[] {\n return items\n .map((item, index) => ({ item, index, at: centre(item) }))\n .sort((a, b) => a.at[1] - b.at[1] || a.at[0] - b.at[0] || a.index - b.index)\n .map(({ item }) => item);\n}\n"],"mappings":"AAiCA,IAAMA,EAAU,0BAIVC,EAAY,GAChBC,IAAU,MAAQF,EAAQ,KAAKE,EAAM,KAAK,CAAC,EAAI,OAAOA,CAAK,EAAI,KAGjE,SAAgBC,EAAY,EAAsC,CAChE,IAAMC,GAASF,GAAS,GAAA,CAAI,KAAK,CAAC,CAAC,MAAM,KAAK,CAAC,CAAC,OAAO,OAAO,EACxDG,EAAkB,CAAC,EACzB,IAAK,IAAMC,KAAQF,EAAO,CACxB,GAAM,CAACG,EAAI,KAAMC,EAAI,KAAMC,GAASH,EAAK,MAAM,GAAG,CAAC,CAAC,IAAK,GAAML,EAASS,CAAC,CAAC,EAC1E,GAAIH,IAAM,MAAQC,IAAM,MAAQC,IAAU,IAAA,GAAW,OAAO,KAC5DJ,EAAO,KAAK,CAACE,EAAGC,CAAC,CAAC,CACpB,CACA,OAAOH,CACT,CAEA,IAAMM,EAAW,GAAsB,CACrC,IAAMC,EAAQC,EAAK,OAAO,EA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IC,EAClED,EAAO,QAAU,OAAeA,EAAO,MAAQA,EAAO,OACnD,KAAK,IAAIX,EAASW,EAAO,MAAM,CAAC,EAAI,CAC7C,CAGA,SAAgBO,EAAgB,EAAqB,EAAiC,CACpF,OAAOC,EACJ,KAAK,EAAM,KAAW,CAAE,OAAM,QAAO,GAAIC,EAAOC,CAAI,CAAE,EAAE,CAAC,CACzD,MAAM,EAAG,IAAMC,EAAE,GAAG,GAAKC,EAAE,GAAG,IAAMD,EAAE,GAAG,GAAKC,EAAE,GAAG,IAAMD,EAAE,MAAQC,EAAE,KAAK,CAAC,CAC3E,KAAK,CAAE,UAAWF,CAAI,CAC3B,C"}
@@ -0,0 +1,92 @@
1
+ import{C as e,E as t,S as n,b as r}from"./runtime-DxAbpr3S.js";import{c as i,l as a,s as o}from"./directive-helpers-D7lOZKnB.js";var s=o(class extends i{#e={};constructor(e){if(super(e),e.type!==a.ELEMENT)throw Error(`styles() belongs on an element, not in an attribute or text`)}render(e){return n}update(e,[t]){let{style:r}=e.element;for(let e of Object.keys(this.#e))Object.hasOwn(t,e)||r.removeProperty(e);for(let[e,n]of Object.entries(t))this.#e[e]!==n&&r.setProperty(e,n);return this.#e={...t},n}});function c(e,t){if(t!==null)return t;let n=Number(e.getAttribute(`width`)),r=Number(e.getAttribute(`height`));return n>0&&r>0?n/r:4/3}function l(t,n,i,a,o={}){let c=t.getAttribute(`src`)??``;return e`<div
2
+ class="picture"
3
+ part="picture"
4
+ dir="ltr"
5
+ role=${o.role??r}
6
+ aria-label=${o.label??r}
7
+ aria-describedby=${o.describedBy??r}
8
+ ${s({"aspect-ratio":String(n)})}
9
+ >
10
+ ${c===``?r:e`<img
11
+ class="photo"
12
+ src=${c}
13
+ alt=${o.alt??``}
14
+ loading="lazy"
15
+ decoding="async"
16
+ referrerpolicy="no-referrer"
17
+ draggable="false"
18
+ @load=${e=>{let t=e.target;t.naturalHeight>0&&i(t.naturalWidth/t.naturalHeight)}}
19
+ />`}${a}
20
+ </div>`}function u(e){return Object.fromEntries(Object.entries(e).map(([e,t])=>[`--${e}`,`${t}%`]))}function d(t,n,r){return e`<div class="slide" ${s(u({x:t,y:n}))}><div class="lane">${r}</div></div>`}var f=t`
21
+ .picture {
22
+ position: relative;
23
+ box-sizing: border-box;
24
+ inline-size: 100%;
25
+ border-radius: var(--astl-radius-m);
26
+ background: var(--astl-canvas);
27
+ user-select: none;
28
+ -webkit-user-select: none;
29
+ }
30
+ .photo {
31
+ position: absolute;
32
+ inset: 0;
33
+ display: block;
34
+ inline-size: 100%;
35
+ block-size: 100%;
36
+ border-radius: inherit;
37
+ }
38
+ .box {
39
+ position: absolute;
40
+ inset-inline-start: var(--x);
41
+ inset-block-start: var(--y);
42
+ inline-size: var(--w);
43
+ block-size: var(--h);
44
+ }
45
+ .point {
46
+ position: absolute;
47
+ inset-inline-start: clamp(calc(var(--size) / 2), var(--x), calc(100% - var(--size) / 2));
48
+ inset-block-start: clamp(calc(var(--size) / 2), var(--y), calc(100% - var(--size) / 2));
49
+ translate: -50% -50%;
50
+ }
51
+ .slide,
52
+ .lane {
53
+ display: flex;
54
+ pointer-events: none;
55
+ }
56
+ .slide {
57
+ position: absolute;
58
+ inset: 0;
59
+ flex-direction: column;
60
+ }
61
+ .slide::before,
62
+ .slide::after,
63
+ .lane::before,
64
+ .lane::after {
65
+ content: '';
66
+ flex-grow: 0;
67
+ flex-shrink: 1;
68
+ }
69
+ .slide::before {
70
+ flex-basis: max(0%, calc(2 * var(--y) - 100%));
71
+ }
72
+ .slide::after {
73
+ flex-basis: max(0%, calc(100% - 2 * var(--y)));
74
+ }
75
+ .lane::before {
76
+ flex-basis: max(0%, calc(2 * var(--x) - 100%));
77
+ }
78
+ .lane::after {
79
+ flex-basis: max(0%, calc(100% - 2 * var(--x)));
80
+ }
81
+ .lane {
82
+ flex: none;
83
+ margin-block: auto;
84
+ }
85
+ .lane > * {
86
+ flex: none;
87
+ max-inline-size: 100%;
88
+ margin-inline: auto;
89
+ pointer-events: auto;
90
+ }
91
+ `;export{d as a,l as i,u as n,s as o,f as r,c as t};
92
+ //# sourceMappingURL=picture-view-BKnAyScQ.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"picture-view-BKnAyScQ.js","names":["Directive","PartType","noChange","directive","nothing","b","i","E","A","i$1","t","e","styles","part","name","#last","style","value","aspectOf","loaded","width","host","height","renderPicture","src","attributes","aspect","img","event","content","percent","values","renderSlide","item","pictureStyles"],"sources":["../../../../components/src/picture-view.ts"],"sourcesContent":["/**\n * The picture of the picture types (hotspot, image drop, image label) on the student side: one box of the picture's\n * shape, the picture filling it, and what sits on it placed in percent of the picture. Elements only (it loads Lit);\n * the geometry both sides share is in `picture.ts`.\n *\n * The box takes the picture's aspect ratio: as loaded, else from the element's `width` and `height`, else 4:3 until it\n * loads. So the layout never waits for the picture, and places stay where they belong if it fails to load.\n */\nimport { type CSSResultGroup, css, html, noChange, nothing, type TemplateResult } from 'lit';\nimport {\n Directive,\n type DirectiveResult,\n directive,\n type ElementPart,\n type PartInfo,\n PartType,\n} from 'lit/directive.js';\n\ntype Styles = Readonly<Record<string, string>>;\n\n/**\n * Sets CSS properties (hyphenated names, `--x` too) on the element it sits on, always through the CSSOM. Lit's\n * `styleMap` writes its first render as a `style` attribute, which a strict Content Security Policy blocks\n * (`style-src-attr`). On a change it sets only what changed, and removes what is gone.\n */\nclass StylesDirective extends Directive {\n #last: Styles = {};\n\n constructor(part: PartInfo) {\n super(part);\n if (part.type !== PartType.ELEMENT)\n throw new Error('styles() belongs on an element, not in an attribute or text');\n }\n\n render(_styles: Styles): unknown {\n return noChange;\n }\n\n override update(part: ElementPart, [styles]: [Styles]): unknown {\n const { style } = part.element as HTMLElement;\n for (const name of Object.keys(this.#last)) if (!Object.hasOwn(styles, name)) style.removeProperty(name);\n for (const [name, value] of Object.entries(styles))\n if (this.#last[name] !== value) style.setProperty(name, value);\n this.#last = { ...styles };\n return noChange;\n }\n}\n\n/** The CSS properties of an element, set through the CSSOM (see `StylesDirective`): `<span ${styles({...})}>`. */\nexport const styles: (styles: Styles) => DirectiveResult = directive(StylesDirective);\n\n/** The picture's width over its height (see above); `loaded` is the aspect of the loaded picture, if any. */\nexport function aspectOf(host: Element, loaded: number | null): number {\n if (loaded !== null) return loaded;\n const width = Number(host.getAttribute('width'));\n const height = Number(host.getAttribute('height'));\n return width > 0 && height > 0 ? width / height : 4 / 3;\n}\n\n/**\n * The picture's box with `content` on it. The picture loads as pictures in content do: lazily, decoded off the main\n * thread, and with no referrer (its host learns nothing of the page). `loaded` gets its aspect once it is there. The\n * box never mirrors (coordinates count from the left edge), and its shape is set through the CSSOM (`styles`).\n */\nexport function renderPicture(\n host: Element,\n aspect: number,\n loaded: (aspect: number) => void,\n content: unknown,\n attributes: {\n readonly alt?: string;\n readonly role?: string;\n readonly label?: string;\n readonly describedBy?: string | undefined;\n } = {},\n): TemplateResult {\n const src = host.getAttribute('src') ?? '';\n return html`<div\n class=\"picture\"\n part=\"picture\"\n dir=\"ltr\"\n role=${attributes.role ?? nothing}\n aria-label=${attributes.label ?? nothing}\n aria-describedby=${attributes.describedBy ?? nothing}\n ${styles({ 'aspect-ratio': String(aspect) })}\n >\n ${\n src === ''\n ? nothing\n : html`<img\n class=\"photo\"\n src=${src}\n alt=${attributes.alt ?? ''}\n loading=\"lazy\"\n decoding=\"async\"\n referrerpolicy=\"no-referrer\"\n draggable=\"false\"\n @load=${(event: Event) => {\n const img = event.target as HTMLImageElement;\n if (img.naturalHeight > 0) loaded(img.naturalWidth / img.naturalHeight);\n }}\n />`\n }${content}\n </div>`;\n}\n\n/** CSS variables in percent of the picture, for `styles`: `{ x: 10 }` gives `--x: 10%`. */\nexport function percent(values: Readonly<Record<string, number>>): Record<string, string> {\n return Object.fromEntries(Object.entries(values).map(([name, value]) => [`--${name}`, `${value}%`]));\n}\n\n/** `item` centred on the point (`x`, `y` in percent of the picture) and kept inside the picture: see `.slide`. */\nexport function renderSlide(x: number, y: number, item: TemplateResult): TemplateResult {\n return html`<div class=\"slide\" ${styles(percent({ x, y }))}><div class=\"lane\">${item}</div></div>`;\n}\n\n// `.box` covers a zone (`--x`, `--y` its corner, `--w`, `--h` its size). `.point` centres an item of the size `--size`\n// on the point `--x`, `--y`, kept inside the picture near its edges. `.slide` centres an item of any size on the point\n// `--x`, `--y` and keeps it inside the picture, so it still covers the point. Laid out, not moved: a column across\n// the picture's height holds a row across its width, which holds the item; in each, a spacer before or after takes\n// twice the point's distance from the middle, and auto margins centre what is left over the point. An item too big\n// for that shrinks the spacer instead, so it stops at the picture's edge. Neither the column nor the row takes the\n// pointer. The picture fills the box: it is drawn as the box has it, so places in percent stay true.\nexport const pictureStyles: CSSResultGroup = css`\n .picture {\n position: relative;\n box-sizing: border-box;\n inline-size: 100%;\n border-radius: var(--astl-radius-m);\n background: var(--astl-canvas);\n user-select: none;\n -webkit-user-select: none;\n }\n .photo {\n position: absolute;\n inset: 0;\n display: block;\n inline-size: 100%;\n block-size: 100%;\n border-radius: inherit;\n }\n .box {\n position: absolute;\n inset-inline-start: var(--x);\n inset-block-start: var(--y);\n inline-size: var(--w);\n block-size: var(--h);\n }\n .point {\n position: absolute;\n inset-inline-start: clamp(calc(var(--size) / 2), var(--x), calc(100% - var(--size) / 2));\n inset-block-start: clamp(calc(var(--size) / 2), var(--y), calc(100% - var(--size) / 2));\n translate: -50% -50%;\n }\n .slide,\n .lane {\n display: flex;\n pointer-events: none;\n }\n .slide {\n position: absolute;\n inset: 0;\n flex-direction: column;\n }\n .slide::before,\n .slide::after,\n .lane::before,\n .lane::after {\n content: '';\n flex-grow: 0;\n flex-shrink: 1;\n }\n .slide::before {\n flex-basis: max(0%, calc(2 * var(--y) - 100%));\n }\n .slide::after {\n flex-basis: max(0%, calc(100% - 2 * var(--y)));\n }\n .lane::before {\n flex-basis: max(0%, calc(2 * var(--x) - 100%));\n }\n .lane::after {\n flex-basis: max(0%, calc(100% - 2 * var(--x)));\n }\n .lane {\n flex: none;\n margin-block: auto;\n }\n .lane > * {\n flex: none;\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AAiB,CACxB,IAAME,EAAMC,EAAM,OACdD,EAAI,cAAgB,GAAGR,EAAOQ,EAAI,aAAeA,EAAI,aAAa,CACxE,EAAE;gBAEPE,EAAQ;SAEf,CAGA,SAAgBC,EAAQ,EAAkE,CACxF,OAAO,OAAO,YAAY,OAAO,QAAQC,CAAM,CAAC,CAAC,KAAK,CAACjB,EAAMG,KAAW,CAAC,KAAKH,IAAQ,GAAGG,EAAM,EAAE,CAAC,CAAC,CACrG,CAGA,SAAgBe,EAAY,EAAW,EAAW,EAAsC,CACtF,MAAO,EAAI,sBAAsBpB,EAAOkB,EAAQ,CAAE,IAAG,GAAE,CAAC,CAAC,EAAE,qBAAqBG,EAAK,aACvF,CASA,IAAaC,EAAgC,CAAG"}
@@ -0,0 +1,8 @@
1
+ import{S as e}from"./runtime-DxAbpr3S.js";import{a as t,c as n,l as r,n as i,o as a,r as o,s,t as c}from"./directive-helpers-D7lOZKnB.js";
2
+ /**
3
+ * @license
4
+ * Copyright 2017 Google LLC
5
+ * SPDX-License-Identifier: BSD-3-Clause
6
+ */
7
+ var l=(e,t,n)=>{let r=new Map;for(let i=t;i<=n;i++)r.set(e[i],i);return r},u=s(class extends n{constructor(e){if(super(e),e.type!==r.CHILD)throw Error(`repeat() can only be used in text expressions`)}dt(e,t,n){let r;n===void 0?n=t:t!==void 0&&(r=t);let i=[],a=[],o=0;for(let t of e)i[o]=r?r(t,o):o,a[o]=n(t,o),o++;return{values:a,keys:i}}render(e,t,n){return this.dt(e,t,n).values}update(n,[r,s,u]){let d=c(n),{values:f,keys:p}=this.dt(r,s,u);if(!Array.isArray(d))return this.ut=p,f;let m=this.ut??=[],h=[],g,_,v=0,y=d.length-1,b=0,x=f.length-1;for(;v<=y&&b<=x;)if(d[v]===null)v++;else if(d[y]===null)y--;else if(m[v]===p[b])h[b]=t(d[v],f[b]),v++,b++;else if(m[y]===p[x])h[x]=t(d[y],f[x]),y--,x--;else if(m[v]===p[x])h[x]=t(d[v],f[x]),a(n,h[x+1],d[v]),v++,x--;else if(m[y]===p[b])h[b]=t(d[y],f[b]),a(n,d[v],d[y]),y--,b++;else if(g===void 0&&(g=l(p,b,x),_=l(m,v,y)),g.has(m[v])){if(g.has(m[y])){let e=_.get(p[b]),r=e===void 0?null:d[e];if(r===null){let e=a(n,d[v]);t(e,f[b]),h[b]=e}else h[b]=t(r,f[b]),a(n,d[v],r),d[e]=null;b++}else i(d[y]),y--}else i(d[v]),v++;for(;b<=x;){let e=a(n,h[x+1]);t(e,f[b]),h[b++]=e}for(;v<=y;){let e=d[v++];e!==null&&i(e)}return this.ut=p,o(n,h),e}});export{u as t};
8
+ //# sourceMappingURL=repeat-CY2W2URZ.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"repeat-CY2W2URZ.js","names":["s","t","r","l","p","h","v","o","i","n","f","e","E","u$1","i","t","h","v","p","M","u","l","s","c","e","o","r","p$1","a","h$1","v$1","m","y","x","j","k","w"],"sources":["../../../../../node_modules/.pnpm/lit-html@3.3.3/node_modules/lit-html/directives/repeat.js"],"sourcesContent":["import{noChange as e}from\"../lit-html.js\";import{directive as s,Directive as t,PartType as r}from\"../directive.js\";import{getCommittedValue as l,setChildPartValue as o,insertPart as i,removePart as n,setCommittedValue as f}from\"../directive-helpers.js\";\n/**\n * @license\n * Copyright 2017 Google LLC\n * SPDX-License-Identifier: BSD-3-Clause\n */\nconst u=(e,s,t)=>{const r=new Map;for(let l=s;l<=t;l++)r.set(e[l],l);return r},c=s(class extends t{constructor(e){if(super(e),e.type!==r.CHILD)throw Error(\"repeat() can only be used in text expressions\")}dt(e,s,t){let r;void 0===t?t=s:void 0!==s&&(r=s);const l=[],o=[];let i=0;for(const s of e)l[i]=r?r(s,i):i,o[i]=t(s,i),i++;return{values:o,keys:l}}render(e,s,t){return this.dt(e,s,t).values}update(s,[t,r,c]){const d=l(s),{values:p,keys:a}=this.dt(t,r,c);if(!Array.isArray(d))return this.ut=a,p;const h=this.ut??=[],v=[];let m,y,x=0,j=d.length-1,k=0,w=p.length-1;for(;x<=j&&k<=w;)if(null===d[x])x++;else if(null===d[j])j--;else if(h[x]===a[k])v[k]=o(d[x],p[k]),x++,k++;else if(h[j]===a[w])v[w]=o(d[j],p[w]),j--,w--;else if(h[x]===a[w])v[w]=o(d[x],p[w]),i(s,v[w+1],d[x]),x++,w--;else if(h[j]===a[k])v[k]=o(d[j],p[k]),i(s,d[x],d[j]),j--,k++;else if(void 0===m&&(m=u(a,k,w),y=u(h,x,j)),m.has(h[x]))if(m.has(h[j])){const e=y.get(a[k]),t=void 0!==e?d[e]:null;if(null===t){const e=i(s,d[x]);o(e,p[k]),v[k]=e}else v[k]=o(t,p[k]),i(s,d[x],t),d[e]=null;k++}else n(d[j]),j--;else n(d[x]),x++;for(;k<=w;){const e=i(s,v[w+1]);o(e,p[k]),v[k++]=e}for(;x<=j;){const e=d[x++];null!==e&&n(e)}return this.ut=a,f(s,v),e}});export{c as repeat};\n//# sourceMappingURL=repeat.js.map\n"],"ignoreList":[0],"mappings":";;;;;;AAMA,IAAMoB,GAAG,EAAE,EAAE,IAAI,CAAC,IAAM,EAAE,IAAI,IAAI,IAAI,IAAIC,EAAEC,EAAED,GAAGN,EAAE,IAAI,EAAE,IAAI,EAAEM,GAAGA,CAAC,EAAE,OAAO,CAAC,EAAEE,EAAEvB,EAAE,cAAcC,CAAC,CAAC,YAAY,EAAE,CAAC,GAAG,MAAM,CAAC,EAAE,EAAE,OAAOC,EAAE,MAAM,MAAM,MAAM,+CAA+C,CAAC,CAAC,GAAG,EAAE,EAAE,EAAE,CAAC,IAAI,EAAWa,IAAT,IAAK,GAAM,EAAEO,EAAWA,IAAT,IAAK,KAAQ,EAAEA,GAAG,IAAMD,EAAE,CAAC,EAAEI,EAAE,CAAC,EAAMX,EAAE,EAAE,IAAI,IAAMQ,KAAK,EAAE,EAAER,GAAG,EAAE,EAAEQ,EAAER,CAAC,EAAEA,EAAE,EAAEA,GAAGC,EAAEO,EAAER,CAAC,EAAE,IAAI,MAAM,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AAEf,EAAE4B,EAAEC,CAAC,GAAGH,EAAE,IAAI1B,EAAE4B,EAAE,EAAE,IAAGF,EAAE,IAAI1B,EAAE6B,EAAE,EAAE,CAAC,IAAM,EAAEF,EAAE,IAAIJ,EAAEO,EAAE,EAAEpB,EAAW,IAAT,IAAK,GAAW,KAAL,EAAE,GAAQ,GAAUA,IAAP,KAAS,CAAC,IAAM,EAAEP,EAAEc,EAAE,EAAEW,EAAE,EAAEpB,EAAE,EAAET,EAAE+B,EAAE,EAAE,EAAEA,GAAG,CAAC,KAAM,GAAEA,GAAG5B,EAAEQ,EAAEX,EAAE+B,EAAE,EAAE3B,EAAEc,EAAE,EAAEW,GAAGlB,CAAC,EAAE,EAAE,GAAG,KAAK,GAAG,MAAMC,EAAE,EAAEkB,EAAE,EAAE,GAAA,MAASlB,EAAE,EAAEiB,EAAE,EAAE,IAAI,KAAKE,GAAGC,GAAG,CAAC,IAAM,EAAE5B,EAAEc,EAAEhB,EAAE8B,EAAE,EAAE,EAAEvB,EAAE,EAAET,EAAE+B,EAAE,EAAE,EAAE,KAAK,CAAC,CAAC,KAAKF,GAAGC,GAAG,CAAC,IAAM,EAAE,EAAE,KAAY,IAAP,MAAUzB,EAAE,CAAC,CAAC,CAAC,MAAO,MAAK,GAAGmB,EAAElB,EAAEY,EAAEhB,CAAC,EAAEK,CAAC,CAAC,CAAC,E"}
@@ -0,0 +1,2 @@
1
+ import{t as e}from"./keys-DU-Qknmz.js";var t=class{#e;#t;#n=0;#r=!1;#i=!1;constructor(e,t){this.#e=e,this.#t=t,e.addController(this),e.addEventListener(`pointerdown`,()=>{this.#i=!0},{capture:!0}),e.addEventListener(`keydown`,()=>{this.#i=!1},{capture:!0})}get active(){return this.#n}tabIndex(e){return e===this.#n?0:-1}focus(e){let t=this.#e,n=t.shadowRoot;this.#n=e,this.#r=n?n.activeElement!==null:t.contains(document.activeElement),t.requestUpdate()}keydown(t,n=this.#n){let r=this.#t,i=r.count(),a=t.key,o=r.axis===`grid`&&(a===`Home`||a===`End`);if(i===0||t.altKey||t.metaKey||t.ctrlKey&&!o)return!1;let s=null;if(r.axis!==`grid`){let o=e(t,r.axis,this.#e);o===0?a===`Home`?s=0:a===`End`&&(s=i-1):s=r.wrap?(n+o+i)%i:Math.min(Math.max(n+o,0),i-1)}else{let o=Math.max(1,r.columns??1),c=n%o,l=n-c,u=Math.min(l+o,i)-1,d=c+Math.floor((i-1-c)/o)*o,f=e(t,`inline`,this.#e),p=e(t,`block`,this.#e),m=(a===`PageDown`?1:a===`PageUp`?-1:0)*(r.page??5);if(f!==0)s=r.wrap?(n+f+i)%i:Math.min(Math.max(n+f,l),u);else if(p!==0){let e=n+p*o;s=e>=0&&e<i?e:r.wrap?p>0?c:d:n}else m===0?a===`Home`?s=t.ctrlKey?0:l:a===`End`&&(s=t.ctrlKey?i-1:u):s=Math.min(Math.max(n+m*o,c),d)}return s!==null&&(t.preventDefault(),this.focus(s),!0)}hostUpdate(){this.#n=Math.max(0,Math.min(this.#n,this.#t.count()-1))}hostUpdated(){if(!this.#r)return;this.#r=!1;let e=this.#t.item(this.#n);e!==null&&(this.#e.shadowRoot??document).activeElement!==e&&(e.focus(),this.#i||e.scrollIntoView({block:`nearest`,inline:`nearest`}))}};export{t};
2
+ //# sourceMappingURL=roving-focus-BxGgi2DD.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"roving-focus-BxGgi2DD.js","names":["arrowDelta","RovingFocus","#host","host","#options","options","#pressed","#active","index","root","#pending","n","key","event","ends","to","delta","from","columns","column","start","end","bottom","across","down","rows","next","target"],"sources":["../../../../player/src/interaction/roving-focus.ts"],"sourcesContent":["import type { ReactiveController, ReactiveControllerHost } from 'lit';\nimport { type Axis, arrowDelta } from './keys.js';\n\nexport interface RovingFocusOptions {\n /** How many items share the one tab stop, now. */\n count(): number;\n /** The rendered element of item `index` (focused after a render), or null. */\n item(index: number): HTMLElement | null;\n /** A list along an axis (see `Axis`), or `grid`: rows of `columns` items in reading order. */\n readonly axis: Axis | 'grid';\n /** Items per row of a grid. */\n readonly columns?: number;\n /** Past the last item comes the first (in a grid: the next row, or the top of the column), and back. */\n readonly wrap?: boolean;\n /** Rows that PageUp and PageDown move in a grid. Default 5. */\n readonly page?: number;\n}\n\n/**\n * Roving tabindex (WAI-ARIA APG): many items, one tab stop. The arrow keys move it (a grid: Left and Right along the\n * row, Up and Down along the column), Home and End go to the ends (a grid: of the row; with Ctrl, of the grid),\n * PageUp and PageDown move a few rows of a grid. Render each item with `tabindex=${roving.tabIndex(i)}`; after a\n * render the active item gets the focus back, but only while the focus is in the host (never pulled from elsewhere).\n * An item the focus moves to by key comes all into view (its scroll margin too), scrolled as little as that needs; one\n * a pointer presses stays where it is.\n */\nexport class RovingFocus implements ReactiveController {\n readonly #host: ReactiveControllerHost & HTMLElement;\n readonly #options: RovingFocusOptions;\n #active = 0;\n /** Focus the active item after the next render: the focus was in the host when the move was asked for. */\n #pending = false;\n /** The last input in the host was a pointer's press, not a key. */\n #pressed = false;\n\n constructor(host: ReactiveControllerHost & HTMLElement, options: RovingFocusOptions) {\n this.#host = host;\n this.#options = options;\n host.addController(this);\n // Captured: known before the host's own handlers ask for a move.\n host.addEventListener(\n 'pointerdown',\n () => {\n this.#pressed = true;\n },\n { capture: true },\n );\n host.addEventListener(\n 'keydown',\n () => {\n this.#pressed = false;\n },\n { capture: true },\n );\n }\n\n /** The item with the tab stop. */\n get active(): number {\n return this.#active;\n }\n\n tabIndex(index: number): 0 | -1 {\n return index === this.#active ? 0 : -1;\n }\n\n /**\n * Makes item `index` the tab stop and, when the focus is in the host now, moves it there after the next render\n * (also when the render replaces the focused element).\n */\n focus(index: number): void {\n const host = this.#host;\n const root = host.shadowRoot;\n this.#active = index;\n this.#pending = root ? root.activeElement !== null : host.contains(document.activeElement);\n host.requestUpdate();\n }\n\n /**\n * Moves the tab stop from item `from` (default: the active one) for a navigation key and returns true (the key is\n * used); false for other keys and for Alt and Meta shortcuts (also Ctrl, except Ctrl+Home and Ctrl+End in a grid).\n */\n keydown(event: KeyboardEvent, from: number = this.#active): boolean {\n const options = this.#options;\n const n = options.count();\n const key = event.key;\n const ends = options.axis === 'grid' && (key === 'Home' || key === 'End');\n if (n === 0 || event.altKey || event.metaKey || (event.ctrlKey && !ends)) return false;\n let to: number | null = null;\n if (options.axis !== 'grid') {\n const delta = arrowDelta(event, options.axis, this.#host);\n if (delta !== 0)\n to = options.wrap ? (from + delta + n) % n : Math.min(Math.max(from + delta, 0), n - 1);\n else if (key === 'Home') to = 0;\n else if (key === 'End') to = n - 1;\n } else {\n const columns = Math.max(1, options.columns ?? 1);\n const column = from % columns;\n const start = from - column;\n const end = Math.min(start + columns, n) - 1;\n const bottom = column + Math.floor((n - 1 - column) / columns) * columns;\n const across = arrowDelta(event, 'inline', this.#host);\n const down = arrowDelta(event, 'block', this.#host);\n const rows = (key === 'PageDown' ? 1 : key === 'PageUp' ? -1 : 0) * (options.page ?? 5);\n if (across !== 0) {\n to = options.wrap ? (from + across + n) % n : Math.min(Math.max(from + across, start), end);\n } else if (down !== 0) {\n const next = from + down * columns;\n to = next >= 0 && next < n ? next : !options.wrap ? from : down > 0 ? column : bottom;\n } else if (rows !== 0) to = Math.min(Math.max(from + rows * columns, column), bottom);\n else if (key === 'Home') to = event.ctrlKey ? 0 : start;\n else if (key === 'End') to = event.ctrlKey ? n - 1 : end;\n }\n if (to === null) return false;\n event.preventDefault();\n this.focus(to);\n return true;\n }\n\n hostUpdate(): void {\n this.#active = Math.max(0, Math.min(this.#active, this.#options.count() - 1));\n }\n\n hostUpdated(): void {\n if (!this.#pending) return;\n this.#pending = false;\n const target = this.#options.item(this.#active);\n if (target === null || (this.#host.shadowRoot ?? document).activeElement === target) return;\n target.focus();\n // focus() centres an item it finds hidden, but one partly hidden sideways stays cut (Chromium). After a press,\n // nothing more: scrolling would move what is under the pointer (a word search reads a drag from where letters are).\n if (!this.#pressed) target.scrollIntoView({ block: 'nearest', inline: 'nearest' });\n }\n}\n"],"mappings":"A,uCA0BA,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