@wordpress/block-library 10.1.1-next.v.202607070741.0 → 10.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (371) hide show
  1. package/CHANGELOG.md +9 -0
  2. package/build/accordion/block.json +1 -0
  3. package/build/button/edit.cjs +18 -8
  4. package/build/button/edit.cjs.map +2 -2
  5. package/build/cover/block.json +11 -0
  6. package/build/cover/edit/block-controls.cjs +11 -4
  7. package/build/cover/edit/block-controls.cjs.map +2 -2
  8. package/build/cover/edit/embed-video-url-input.cjs +5 -3
  9. package/build/cover/edit/embed-video-url-input.cjs.map +3 -3
  10. package/build/cover/edit/index.cjs +1 -1
  11. package/build/cover/edit/index.cjs.map +2 -2
  12. package/build/cover/embed-video-utils.cjs +17 -7
  13. package/build/cover/embed-video-utils.cjs.map +2 -2
  14. package/build/details/transforms.cjs +1 -3
  15. package/build/details/transforms.cjs.map +2 -2
  16. package/build/embed/embed-placeholder.cjs +0 -1
  17. package/build/embed/embed-placeholder.cjs.map +2 -2
  18. package/build/file/edit.cjs +4 -3
  19. package/build/file/edit.cjs.map +2 -2
  20. package/build/file/transforms.cjs +25 -60
  21. package/build/file/transforms.cjs.map +2 -2
  22. package/build/gallery/block.json +4 -2
  23. package/build/gallery/edit.cjs +1 -1
  24. package/build/gallery/edit.cjs.map +3 -3
  25. package/build/gallery/gap-styles.cjs +49 -13
  26. package/build/gallery/gap-styles.cjs.map +3 -3
  27. package/build/group/transforms.cjs +1 -1
  28. package/build/group/transforms.cjs.map +2 -2
  29. package/build/icon/components/custom-inserter/icon-grid.cjs +25 -12
  30. package/build/icon/components/custom-inserter/icon-grid.cjs.map +2 -2
  31. package/build/icon/components/custom-inserter/index.cjs +100 -31
  32. package/build/icon/components/custom-inserter/index.cjs.map +3 -3
  33. package/build/icon/edit.cjs +11 -12
  34. package/build/icon/edit.cjs.map +2 -2
  35. package/build/image/block.json +1 -1
  36. package/build/image/edit.cjs +0 -34
  37. package/build/image/edit.cjs.map +2 -2
  38. package/build/image/image.cjs +4 -23
  39. package/build/image/image.cjs.map +3 -3
  40. package/build/image/transforms.cjs +78 -0
  41. package/build/image/transforms.cjs.map +3 -3
  42. package/build/index.cjs +18 -8
  43. package/build/index.cjs.map +2 -2
  44. package/build/latest-posts/edit.cjs +5 -8
  45. package/build/latest-posts/edit.cjs.map +2 -2
  46. package/build/list-item/edit.cjs +1 -1
  47. package/build/list-item/edit.cjs.map +2 -2
  48. package/build/list-item/hooks/use-enter.cjs +14 -17
  49. package/build/list-item/hooks/use-enter.cjs.map +3 -3
  50. package/build/list-item/hooks/use-space.cjs +3 -2
  51. package/build/list-item/hooks/use-space.cjs.map +3 -3
  52. package/build/paragraph/block.json +1 -0
  53. package/build/paragraph/use-enter.cjs +3 -7
  54. package/build/paragraph/use-enter.cjs.map +3 -3
  55. package/build/playlist/block.json +29 -10
  56. package/build/playlist/edit.cjs +216 -14
  57. package/build/playlist/edit.cjs.map +3 -3
  58. package/build/playlist/index.cjs +1 -1
  59. package/build/playlist/index.cjs.map +2 -2
  60. package/build/playlist/utils.cjs +19 -5
  61. package/build/playlist/utils.cjs.map +2 -2
  62. package/build/playlist/view.cjs +83 -13
  63. package/build/playlist/view.cjs.map +2 -2
  64. package/build/playlist-track/block.json +4 -2
  65. package/build/playlist-track/edit.cjs +94 -64
  66. package/build/playlist-track/edit.cjs.map +2 -2
  67. package/build/post-content/block.json +1 -0
  68. package/build/post-template/block.json +2 -1
  69. package/build/post-template/edit.cjs +10 -1
  70. package/build/post-template/edit.cjs.map +2 -2
  71. package/build/pullquote/block.json +3 -1
  72. package/build/query/block.json +3 -2
  73. package/build/query/edit/inspector-controls/index.cjs +38 -4
  74. package/build/query/edit/inspector-controls/index.cjs.map +2 -2
  75. package/build/query/edit/inspector-controls/offset-controls.cjs +0 -1
  76. package/build/query/edit/inspector-controls/offset-controls.cjs.map +2 -2
  77. package/build/query/edit/inspector-controls/pages-control.cjs +0 -1
  78. package/build/query/edit/inspector-controls/pages-control.cjs.map +2 -2
  79. package/build/query/edit/query-content.cjs +10 -3
  80. package/build/query/edit/query-content.cjs.map +2 -2
  81. package/build/query/index.cjs +2 -1
  82. package/build/query/index.cjs.map +2 -2
  83. package/build/quote/block.json +3 -1
  84. package/build/quote/transforms.cjs +1 -3
  85. package/build/quote/transforms.cjs.map +2 -2
  86. package/build/rss/edit.cjs +0 -1
  87. package/build/rss/edit.cjs.map +2 -2
  88. package/build/tab-list/block.json +2 -2
  89. package/build/tab-list/edit.cjs +65 -11
  90. package/build/tab-list/edit.cjs.map +3 -3
  91. package/build/tab-panel/block.json +1 -6
  92. package/build/tab-panel/edit.cjs +15 -15
  93. package/build/tab-panel/edit.cjs.map +2 -2
  94. package/build/tab-panels/block.json +0 -1
  95. package/build/tabs/block.json +0 -5
  96. package/build/tabs/edit.cjs +4 -39
  97. package/build/tabs/edit.cjs.map +3 -3
  98. package/build/tabs/use-tab-list-items-sync.cjs +19 -1
  99. package/build/tabs/use-tab-list-items-sync.cjs.map +2 -2
  100. package/build/term-name/block.json +1 -3
  101. package/build/term-name/deprecated.cjs +105 -0
  102. package/build/term-name/deprecated.cjs.map +7 -0
  103. package/build/term-name/edit.cjs +11 -37
  104. package/build/term-name/edit.cjs.map +3 -3
  105. package/build/term-name/index.cjs +3 -1
  106. package/build/term-name/index.cjs.map +3 -3
  107. package/build/utils/waveform-player.cjs +138 -22
  108. package/build/utils/waveform-player.cjs.map +2 -2
  109. package/build/utils/waveform-utils.cjs +315 -17
  110. package/build/utils/waveform-utils.cjs.map +2 -2
  111. package/build/video/edit.cjs +2 -11
  112. package/build/video/edit.cjs.map +3 -3
  113. package/build-module/accordion/block.json +1 -0
  114. package/build-module/button/edit.mjs +19 -14
  115. package/build-module/button/edit.mjs.map +2 -2
  116. package/build-module/cover/block.json +11 -0
  117. package/build-module/cover/edit/block-controls.mjs +11 -4
  118. package/build-module/cover/edit/block-controls.mjs.map +2 -2
  119. package/build-module/cover/edit/embed-video-url-input.mjs +5 -4
  120. package/build-module/cover/edit/embed-video-url-input.mjs.map +2 -2
  121. package/build-module/cover/edit/index.mjs +1 -1
  122. package/build-module/cover/edit/index.mjs.map +2 -2
  123. package/build-module/cover/embed-video-utils.mjs +16 -7
  124. package/build-module/cover/embed-video-utils.mjs.map +2 -2
  125. package/build-module/details/transforms.mjs +2 -7
  126. package/build-module/details/transforms.mjs.map +2 -2
  127. package/build-module/embed/embed-placeholder.mjs +0 -1
  128. package/build-module/embed/embed-placeholder.mjs.map +2 -2
  129. package/build-module/file/edit.mjs +4 -3
  130. package/build-module/file/edit.mjs.map +2 -2
  131. package/build-module/file/transforms.mjs +25 -60
  132. package/build-module/file/transforms.mjs.map +2 -2
  133. package/build-module/gallery/block.json +4 -2
  134. package/build-module/gallery/edit.mjs +3 -3
  135. package/build-module/gallery/edit.mjs.map +2 -2
  136. package/build-module/gallery/gap-styles.mjs +53 -14
  137. package/build-module/gallery/gap-styles.mjs.map +2 -2
  138. package/build-module/group/transforms.mjs +2 -5
  139. package/build-module/group/transforms.mjs.map +2 -2
  140. package/build-module/icon/components/custom-inserter/icon-grid.mjs +25 -12
  141. package/build-module/icon/components/custom-inserter/icon-grid.mjs.map +2 -2
  142. package/build-module/icon/components/custom-inserter/index.mjs +102 -33
  143. package/build-module/icon/components/custom-inserter/index.mjs.map +2 -2
  144. package/build-module/icon/edit.mjs +11 -12
  145. package/build-module/icon/edit.mjs.map +2 -2
  146. package/build-module/image/block.json +1 -1
  147. package/build-module/image/edit.mjs +0 -34
  148. package/build-module/image/edit.mjs.map +2 -2
  149. package/build-module/image/image.mjs +4 -13
  150. package/build-module/image/image.mjs.map +2 -2
  151. package/build-module/image/transforms.mjs +78 -0
  152. package/build-module/image/transforms.mjs.map +2 -2
  153. package/build-module/index.mjs +18 -8
  154. package/build-module/index.mjs.map +2 -2
  155. package/build-module/latest-posts/edit.mjs +5 -8
  156. package/build-module/latest-posts/edit.mjs.map +2 -2
  157. package/build-module/list-item/edit.mjs +1 -1
  158. package/build-module/list-item/edit.mjs.map +2 -2
  159. package/build-module/list-item/hooks/use-enter.mjs +15 -21
  160. package/build-module/list-item/hooks/use-enter.mjs.map +2 -2
  161. package/build-module/list-item/hooks/use-space.mjs +4 -6
  162. package/build-module/list-item/hooks/use-space.mjs.map +2 -2
  163. package/build-module/paragraph/block.json +1 -0
  164. package/build-module/paragraph/use-enter.mjs +4 -11
  165. package/build-module/paragraph/use-enter.mjs.map +2 -2
  166. package/build-module/playlist/block.json +29 -10
  167. package/build-module/playlist/edit.mjs +220 -16
  168. package/build-module/playlist/edit.mjs.map +2 -2
  169. package/build-module/playlist/index.mjs +1 -1
  170. package/build-module/playlist/index.mjs.map +2 -2
  171. package/build-module/playlist/utils.mjs +17 -4
  172. package/build-module/playlist/utils.mjs.map +2 -2
  173. package/build-module/playlist/view.mjs +89 -14
  174. package/build-module/playlist/view.mjs.map +2 -2
  175. package/build-module/playlist-track/block.json +4 -2
  176. package/build-module/playlist-track/edit.mjs +96 -65
  177. package/build-module/playlist-track/edit.mjs.map +2 -2
  178. package/build-module/post-content/block.json +1 -0
  179. package/build-module/post-template/block.json +2 -1
  180. package/build-module/post-template/edit.mjs +10 -1
  181. package/build-module/post-template/edit.mjs.map +2 -2
  182. package/build-module/pullquote/block.json +3 -1
  183. package/build-module/query/block.json +3 -2
  184. package/build-module/query/edit/inspector-controls/index.mjs +40 -5
  185. package/build-module/query/edit/inspector-controls/index.mjs.map +2 -2
  186. package/build-module/query/edit/inspector-controls/offset-controls.mjs +0 -1
  187. package/build-module/query/edit/inspector-controls/offset-controls.mjs.map +2 -2
  188. package/build-module/query/edit/inspector-controls/pages-control.mjs +0 -1
  189. package/build-module/query/edit/inspector-controls/pages-control.mjs.map +2 -2
  190. package/build-module/query/edit/query-content.mjs +10 -3
  191. package/build-module/query/edit/query-content.mjs.map +2 -2
  192. package/build-module/query/index.mjs +2 -1
  193. package/build-module/query/index.mjs.map +2 -2
  194. package/build-module/quote/block.json +3 -1
  195. package/build-module/quote/transforms.mjs +2 -4
  196. package/build-module/quote/transforms.mjs.map +2 -2
  197. package/build-module/rss/edit.mjs +0 -1
  198. package/build-module/rss/edit.mjs.map +2 -2
  199. package/build-module/tab-list/block.json +2 -2
  200. package/build-module/tab-list/edit.mjs +72 -13
  201. package/build-module/tab-list/edit.mjs.map +2 -2
  202. package/build-module/tab-panel/block.json +1 -6
  203. package/build-module/tab-panel/edit.mjs +16 -16
  204. package/build-module/tab-panel/edit.mjs.map +2 -2
  205. package/build-module/tab-panels/block.json +0 -1
  206. package/build-module/tabs/block.json +0 -5
  207. package/build-module/tabs/edit.mjs +5 -45
  208. package/build-module/tabs/edit.mjs.map +2 -2
  209. package/build-module/tabs/use-tab-list-items-sync.mjs +19 -1
  210. package/build-module/tabs/use-tab-list-items-sync.mjs.map +2 -2
  211. package/build-module/term-name/block.json +1 -3
  212. package/build-module/term-name/deprecated.mjs +74 -0
  213. package/build-module/term-name/deprecated.mjs.map +7 -0
  214. package/build-module/term-name/edit.mjs +11 -28
  215. package/build-module/term-name/edit.mjs.map +2 -2
  216. package/build-module/term-name/index.mjs +3 -1
  217. package/build-module/term-name/index.mjs.map +2 -2
  218. package/build-module/utils/waveform-player.mjs +144 -23
  219. package/build-module/utils/waveform-player.mjs.map +2 -2
  220. package/build-module/utils/waveform-utils.mjs +310 -16
  221. package/build-module/utils/waveform-utils.mjs.map +2 -2
  222. package/build-module/video/edit.mjs +2 -11
  223. package/build-module/video/edit.mjs.map +2 -2
  224. package/build-style/editor-rtl.css +46 -21
  225. package/build-style/editor.css +46 -21
  226. package/build-style/icon/editor-rtl.css +80 -7
  227. package/build-style/icon/editor.css +80 -7
  228. package/build-style/more/editor-rtl.css +2 -2
  229. package/build-style/more/editor.css +2 -2
  230. package/build-style/navigation/editor-rtl.css +3 -4
  231. package/build-style/navigation/editor.css +3 -4
  232. package/build-style/navigation-link/editor-rtl.css +1 -1
  233. package/build-style/navigation-link/editor.css +1 -1
  234. package/build-style/nextpage/editor-rtl.css +2 -2
  235. package/build-style/nextpage/editor.css +2 -2
  236. package/build-style/playlist/editor-rtl.css +6 -0
  237. package/build-style/playlist/editor.css +6 -0
  238. package/build-style/playlist/style-rtl.css +37 -1
  239. package/build-style/playlist/style.css +37 -1
  240. package/build-style/playlist-track/style-rtl.css +10 -0
  241. package/build-style/playlist-track/style.css +10 -0
  242. package/build-style/style-rtl.css +47 -1
  243. package/build-style/style.css +47 -1
  244. package/build-style/video/editor-rtl.css +1 -1
  245. package/build-style/video/editor.css +1 -1
  246. package/build-types/table-of-contents/list.d.ts +1 -1
  247. package/build-types/table-of-contents/list.d.ts.map +1 -1
  248. package/package.json +46 -44
  249. package/src/accordion/README.md +1 -0
  250. package/src/accordion/block.json +1 -0
  251. package/src/button/edit.js +21 -15
  252. package/src/cover/README.md +60 -0
  253. package/src/cover/block.json +11 -0
  254. package/src/cover/edit/block-controls.js +21 -11
  255. package/src/cover/edit/embed-video-url-input.js +5 -4
  256. package/src/cover/edit/index.js +9 -11
  257. package/src/cover/embed-video-utils.js +38 -13
  258. package/src/details/transforms.js +2 -7
  259. package/src/embed/embed-placeholder.js +0 -1
  260. package/src/file/edit.js +8 -8
  261. package/src/file/transforms.js +28 -60
  262. package/src/gallery/README.md +1 -1
  263. package/src/gallery/block.json +4 -2
  264. package/src/gallery/edit.js +3 -3
  265. package/src/gallery/gap-styles.js +79 -20
  266. package/src/gallery/index.php +103 -43
  267. package/src/group/transforms.js +2 -5
  268. package/src/icon/components/custom-inserter/icon-grid.js +40 -11
  269. package/src/icon/components/custom-inserter/index.js +98 -25
  270. package/src/icon/edit.js +11 -17
  271. package/src/icon/editor.scss +33 -8
  272. package/src/image/README.md +1 -1
  273. package/src/image/block.json +1 -1
  274. package/src/image/edit.js +0 -52
  275. package/src/image/editor.scss +2 -0
  276. package/src/image/image.js +19 -24
  277. package/src/image/transforms.js +128 -0
  278. package/src/index.js +19 -7
  279. package/src/latest-posts/edit.js +5 -8
  280. package/src/latest-posts/index.php +46 -16
  281. package/src/list-item/edit.js +1 -1
  282. package/src/list-item/hooks/use-enter.js +15 -22
  283. package/src/list-item/hooks/use-space.js +4 -6
  284. package/src/media-text/editor.scss +1 -0
  285. package/src/more/editor.scss +1 -1
  286. package/src/navigation/editor.scss +1 -2
  287. package/src/navigation-link/editor.scss +1 -1
  288. package/src/navigation-link/index.php +6 -3
  289. package/src/navigation-submenu/index.php +6 -3
  290. package/src/nextpage/editor.scss +1 -1
  291. package/src/paragraph/README.md +1 -0
  292. package/src/paragraph/block.json +1 -0
  293. package/src/paragraph/use-enter.js +4 -11
  294. package/src/playlist/README.md +17 -18
  295. package/src/playlist/block.json +29 -10
  296. package/src/playlist/edit.js +247 -15
  297. package/src/playlist/editor.scss +6 -0
  298. package/src/playlist/index.js +1 -1
  299. package/src/playlist/index.php +58 -14
  300. package/src/playlist/style.scss +51 -1
  301. package/src/playlist/test/edit.js +13 -2
  302. package/src/playlist/utils.js +25 -7
  303. package/src/playlist/view.js +97 -16
  304. package/src/playlist-track/README.md +3 -3
  305. package/src/playlist-track/block.json +4 -2
  306. package/src/playlist-track/edit.js +94 -70
  307. package/src/playlist-track/index.php +20 -6
  308. package/src/playlist-track/style.scss +10 -0
  309. package/src/playlist-track/test/edit.js +169 -0
  310. package/src/post-content/README.md +1 -0
  311. package/src/post-content/block.json +1 -0
  312. package/src/post-template/README.md +1 -0
  313. package/src/post-template/block.json +2 -1
  314. package/src/post-template/edit.js +9 -0
  315. package/src/pullquote/README.md +1 -0
  316. package/src/pullquote/block.json +3 -1
  317. package/src/query/README.md +2 -1
  318. package/src/query/block.json +3 -2
  319. package/src/query/edit/inspector-controls/index.js +43 -3
  320. package/src/query/edit/inspector-controls/offset-controls.js +0 -1
  321. package/src/query/edit/inspector-controls/pages-control.js +0 -1
  322. package/src/query/edit/query-content.js +19 -3
  323. package/src/query/index.js +1 -0
  324. package/src/quote/README.md +1 -0
  325. package/src/quote/block.json +3 -1
  326. package/src/quote/transforms.js +2 -4
  327. package/src/rss/edit.js +0 -1
  328. package/src/rss/index.php +1 -1
  329. package/src/tab-list/README.md +4 -5
  330. package/src/tab-list/block.json +2 -2
  331. package/src/tab-list/edit.js +90 -28
  332. package/src/tab-list/index.php +9 -4
  333. package/src/tab-panel/README.md +4 -6
  334. package/src/tab-panel/block.json +1 -6
  335. package/src/tab-panel/edit.js +19 -24
  336. package/src/tab-panels/README.md +5 -3
  337. package/src/tab-panels/block.json +0 -1
  338. package/src/tabs/README.md +18 -9
  339. package/src/tabs/block.json +0 -5
  340. package/src/tabs/edit.js +7 -64
  341. package/src/tabs/use-tab-list-items-sync.js +24 -4
  342. package/src/template-part/index.php +1 -16
  343. package/src/term-name/README.md +1 -1
  344. package/src/term-name/block.json +1 -3
  345. package/src/term-name/deprecated.js +74 -0
  346. package/src/term-name/edit.js +2 -18
  347. package/src/term-name/index.js +2 -0
  348. package/src/utils/media-control.scss +1 -5
  349. package/src/utils/test/waveform-player.js +297 -34
  350. package/src/utils/test/waveform-utils.js +410 -5
  351. package/src/utils/waveform-player.js +189 -59
  352. package/src/utils/waveform-utils.js +443 -40
  353. package/src/video/edit.js +0 -8
  354. package/src/video/editor.scss +1 -1
  355. package/build/image/animated-gif-convert-control.cjs +0 -105
  356. package/build/image/animated-gif-convert-control.cjs.map +0 -7
  357. package/build/utils/gif-conversion-attributes.cjs +0 -40
  358. package/build/utils/gif-conversion-attributes.cjs.map +0 -7
  359. package/build/video/gif-restore-control.cjs +0 -73
  360. package/build/video/gif-restore-control.cjs.map +0 -7
  361. package/build-module/image/animated-gif-convert-control.mjs +0 -87
  362. package/build-module/image/animated-gif-convert-control.mjs.map +0 -7
  363. package/build-module/utils/gif-conversion-attributes.mjs +0 -15
  364. package/build-module/utils/gif-conversion-attributes.mjs.map +0 -7
  365. package/build-module/video/gif-restore-control.mjs +0 -55
  366. package/build-module/video/gif-restore-control.mjs.map +0 -7
  367. package/src/image/animated-gif-convert-control.js +0 -135
  368. package/src/image/test/animated-gif-convert-control.js +0 -276
  369. package/src/utils/gif-conversion-attributes.js +0 -30
  370. package/src/utils/test/gif-conversion-attributes.js +0 -60
  371. package/src/video/gif-restore-control.js +0 -92
@@ -2,14 +2,168 @@
2
2
  import { colord } from "colord";
3
3
  import WaveformPlayerLib from "@arraypress/waveform-player";
4
4
  var DEFAULT_WAVEFORM_HEIGHT = 100;
5
+ var DEFAULT_SEEK_LABEL = "Seek";
5
6
  function getComputedStyle(element) {
6
7
  return element.ownerDocument.defaultView.getComputedStyle(element);
7
8
  }
8
- function getWaveformColors(element) {
9
- const textColor = getComputedStyle(element).color;
10
- const waveformColor = colord(textColor).alpha(0.3).toRgbString();
11
- const progressColor = colord(textColor).alpha(0.6).toRgbString();
12
- return { textColor, waveformColor, progressColor };
9
+ function getTopLevelGradientParts(gradientValue) {
10
+ const match = gradientValue?.trim().match(/^[\w-]+-gradient\((.*)\)$/i);
11
+ if (!match) {
12
+ return [];
13
+ }
14
+ const parts = [];
15
+ let depth = 0;
16
+ let current = "";
17
+ for (const character of match[1]) {
18
+ if (character === "(") {
19
+ ++depth;
20
+ } else if (character === ")") {
21
+ --depth;
22
+ }
23
+ if (character === "," && depth === 0) {
24
+ parts.push(current.trim());
25
+ current = "";
26
+ continue;
27
+ }
28
+ current += character;
29
+ }
30
+ if (current.trim()) {
31
+ parts.push(current.trim());
32
+ }
33
+ return parts;
34
+ }
35
+ function getLeadingColorFunction(value) {
36
+ const match = value.match(/^([\w-]+)\(/);
37
+ if (!match) {
38
+ return;
39
+ }
40
+ const supportedFunctions = [
41
+ "color",
42
+ "color-mix",
43
+ "hsl",
44
+ "hsla",
45
+ "hwb",
46
+ "lab",
47
+ "lch",
48
+ "oklab",
49
+ "oklch",
50
+ "rgb",
51
+ "rgba",
52
+ "var"
53
+ ];
54
+ if (!supportedFunctions.includes(match[1].toLowerCase())) {
55
+ return;
56
+ }
57
+ let depth = 0;
58
+ let foundOpeningParenthesis = false;
59
+ for (let index = 0; index < value.length; index++) {
60
+ const character = value[index];
61
+ if (character === "(") {
62
+ foundOpeningParenthesis = true;
63
+ ++depth;
64
+ } else if (character === ")") {
65
+ --depth;
66
+ }
67
+ if (foundOpeningParenthesis && depth === 0) {
68
+ return value.slice(0, index + 1);
69
+ }
70
+ }
71
+ }
72
+ function getColorStopValue(gradientPart) {
73
+ const colorFunction = getLeadingColorFunction(gradientPart);
74
+ if (colorFunction) {
75
+ return colorFunction;
76
+ }
77
+ const [possibleColor] = gradientPart.split(/\s+/);
78
+ if (colord(possibleColor).isValid()) {
79
+ return possibleColor;
80
+ }
81
+ }
82
+ function getWaveformGradientDirection(gradientValue) {
83
+ const parts = getTopLevelGradientParts(gradientValue);
84
+ const direction = parts[0];
85
+ const angleMatch = direction?.match(/^(-?\d+(?:\.\d+)?)deg$/i);
86
+ if (angleMatch) {
87
+ const angle = (Number(angleMatch[1]) % 360 + 360) % 360;
88
+ if (angle === 90 || angle === 270) {
89
+ return "horizontal";
90
+ }
91
+ if (angle === 0 || angle === 180) {
92
+ return "vertical";
93
+ }
94
+ return "diagonal";
95
+ }
96
+ if (!direction?.startsWith("to ")) {
97
+ return void 0;
98
+ }
99
+ const sideOrCorner = direction.toLowerCase().replace(/^to\s+/, "");
100
+ const hasHorizontalSide = sideOrCorner.includes("left") || sideOrCorner.includes("right");
101
+ const hasVerticalSide = sideOrCorner.includes("top") || sideOrCorner.includes("bottom");
102
+ if (hasHorizontalSide && hasVerticalSide) {
103
+ return "diagonal";
104
+ }
105
+ if (hasHorizontalSide) {
106
+ return "horizontal";
107
+ }
108
+ if (hasVerticalSide) {
109
+ return "vertical";
110
+ }
111
+ }
112
+ function resolveColorValue(element, colorValue) {
113
+ if (!colorValue || colord(colorValue).isValid()) {
114
+ return colorValue;
115
+ }
116
+ const colorResolver = element.ownerDocument.createElement("span");
117
+ colorResolver.style.color = colorValue;
118
+ if (!colorResolver.style.color) {
119
+ return colorValue;
120
+ }
121
+ element.appendChild(colorResolver);
122
+ const resolvedColor = getComputedStyle(colorResolver).color;
123
+ colorResolver.remove();
124
+ return resolvedColor && colord(resolvedColor).isValid() ? resolvedColor : colorValue;
125
+ }
126
+ function getResolvedGradientStops(element, gradientValue) {
127
+ const stops = getWaveformGradientStops(gradientValue)?.map((colorValue) => resolveColorValue(element, colorValue)).filter((colorValue) => colord(colorValue).isValid());
128
+ return stops?.length > 1 ? stops : void 0;
129
+ }
130
+ function applyAlpha(colorValue, alpha) {
131
+ if (Array.isArray(colorValue)) {
132
+ return colorValue.map(
133
+ (color) => colord(color).alpha(alpha).toRgbString()
134
+ );
135
+ }
136
+ return colord(colorValue).alpha(alpha).toRgbString();
137
+ }
138
+ function getRepresentativeColor(colorValue) {
139
+ if (Array.isArray(colorValue)) {
140
+ return colorValue[colorValue.length - 1];
141
+ }
142
+ return colorValue;
143
+ }
144
+ function getWaveformGradientStops(gradientValue) {
145
+ const stops = getTopLevelGradientParts(gradientValue).map(getColorStopValue).filter(Boolean);
146
+ return stops.length > 1 ? stops : void 0;
147
+ }
148
+ function serializeColorValue(colorValue) {
149
+ return Array.isArray(colorValue) ? JSON.stringify(colorValue) : colorValue;
150
+ }
151
+ function getWaveformColors(element, waveformColorValue, textColorValue, waveformGradientValue) {
152
+ const textColor = textColorValue || getComputedStyle(element).color;
153
+ const waveformGradientStops = getResolvedGradientStops(
154
+ element,
155
+ waveformGradientValue
156
+ );
157
+ const waveformBaseColor = waveformGradientStops || waveformColorValue || textColor;
158
+ const waveformColor = applyAlpha(waveformBaseColor, 0.3);
159
+ const progressColor = applyAlpha(waveformBaseColor, 0.6);
160
+ const waveformGradient = waveformGradientStops ? getWaveformGradientDirection(waveformGradientValue) : void 0;
161
+ return {
162
+ textColor,
163
+ waveformColor,
164
+ progressColor,
165
+ ...waveformGradient && { waveformGradient }
166
+ };
13
167
  }
14
168
  function createWaveformContainer({
15
169
  url,
@@ -18,7 +172,10 @@ function createWaveformContainer({
18
172
  artwork,
19
173
  waveformColor,
20
174
  progressColor,
175
+ waveformGradient,
21
176
  buttonColor,
177
+ seekLabel,
178
+ seekValueText,
22
179
  height = DEFAULT_WAVEFORM_HEIGHT,
23
180
  waveformStyle = "bars"
24
181
  }) {
@@ -27,22 +184,84 @@ function createWaveformContainer({
27
184
  container.setAttribute("data-url", url);
28
185
  container.setAttribute("data-height", String(height));
29
186
  container.setAttribute("data-waveform-style", waveformStyle);
30
- container.setAttribute("data-waveform-color", waveformColor);
31
- container.setAttribute("data-progress-color", progressColor);
187
+ container.setAttribute(
188
+ "data-waveform-color",
189
+ serializeColorValue(waveformColor)
190
+ );
191
+ container.setAttribute(
192
+ "data-progress-color",
193
+ serializeColorValue(progressColor)
194
+ );
195
+ if (waveformGradient) {
196
+ container.setAttribute("data-waveform-gradient", waveformGradient);
197
+ }
32
198
  container.setAttribute("data-button-color", buttonColor);
199
+ container.setAttribute(
200
+ "data-seek-label",
201
+ getSeekControlLabel(seekLabel)
202
+ );
203
+ if (seekValueText) {
204
+ container.setAttribute("data-seek-value-text", seekValueText);
205
+ }
33
206
  container.setAttribute("data-text-color", buttonColor);
34
207
  container.setAttribute("data-text-secondary-color", buttonColor);
35
208
  if (title) {
36
209
  container.setAttribute("data-title", title);
37
210
  }
38
211
  if (artist) {
39
- container.setAttribute("data-subtitle", artist);
212
+ container.setAttribute("data-artist", artist);
40
213
  }
41
214
  if (artwork) {
42
215
  container.setAttribute("data-artwork", artwork);
43
216
  }
44
217
  return container;
45
218
  }
219
+ function applyWaveformPlayerStyles(container, {
220
+ backgroundColor,
221
+ backgroundGradient,
222
+ textColor,
223
+ playButtonColor,
224
+ playButtonGradient
225
+ } = {}) {
226
+ const waveformContainer = container.querySelector(".waveform-container");
227
+ const playButton = container.querySelector(".waveform-btn");
228
+ const playButtonBaseColor = getRepresentativeColor(
229
+ getResolvedGradientStops(container, playButtonGradient) || playButtonColor
230
+ );
231
+ if (playButtonBaseColor) {
232
+ container.style.setProperty(
233
+ "--wfp-button-color",
234
+ playButtonBaseColor
235
+ );
236
+ } else {
237
+ container.style.removeProperty("--wfp-button-color");
238
+ }
239
+ if (textColor) {
240
+ container.style.setProperty("--wfp-text-color", textColor);
241
+ container.style.setProperty("--wfp-text-secondary-color", textColor);
242
+ } else {
243
+ container.style.removeProperty("--wfp-text-color");
244
+ container.style.removeProperty("--wfp-text-secondary-color");
245
+ }
246
+ if (playButton) {
247
+ if (playButtonGradient) {
248
+ playButton.style.background = playButtonGradient;
249
+ } else {
250
+ playButton.style.removeProperty("background");
251
+ }
252
+ }
253
+ if (waveformContainer) {
254
+ if (backgroundGradient) {
255
+ waveformContainer.style.background = backgroundGradient;
256
+ } else if (backgroundColor) {
257
+ waveformContainer.style.removeProperty("background");
258
+ waveformContainer.style.backgroundColor = backgroundColor;
259
+ } else {
260
+ waveformContainer.style.removeProperty("background");
261
+ waveformContainer.style.removeProperty("background-color");
262
+ }
263
+ }
264
+ }
46
265
  function styleSvgIcons(container, buttonColor) {
47
266
  const isButtonDark = colord(buttonColor).isDark();
48
267
  const iconColor = isButtonDark ? "#ffffff" : "#000000";
@@ -68,31 +287,102 @@ function setupPlayButtonAccessibility(container, { play: playLabel = "Play", pau
68
287
  container.removeEventListener("waveformplayer:ended", onPause);
69
288
  };
70
289
  }
290
+ function getSeekControlLabel(label) {
291
+ return label || DEFAULT_SEEK_LABEL;
292
+ }
293
+ function updateSeekControlLabel(instance, label) {
294
+ const seekLabel = getSeekControlLabel(label);
295
+ instance.options.seekLabel = seekLabel;
296
+ instance.applySeekLabel?.(seekLabel);
297
+ const seekControl = instance?.container?.querySelector(
298
+ ".waveform-container"
299
+ );
300
+ if (seekControl) {
301
+ seekControl.setAttribute("aria-label", seekLabel);
302
+ }
303
+ }
304
+ function setupPlayButtonArtwork(container, artworkUrl) {
305
+ if (!artworkUrl) {
306
+ container.classList.remove("has-play-button-artwork");
307
+ container.style.removeProperty("--wp--playlist--play-button-artwork");
308
+ return;
309
+ }
310
+ container.classList.add("has-play-button-artwork");
311
+ container.style.setProperty(
312
+ "--wp--playlist--play-button-artwork",
313
+ `url(${JSON.stringify(artworkUrl)})`
314
+ );
315
+ }
71
316
  function logPlayError(error) {
72
317
  if (error.name === "AbortError") {
73
318
  return;
74
319
  }
75
320
  console.error("Playlist play error:", error);
76
321
  }
77
- function initWaveformPlayer(element, { src, title, artist, image, autoPlay, onEnded, labels, waveformStyle }) {
78
- const { textColor, waveformColor, progressColor } = getWaveformColors(element);
322
+ function initWaveformPlayer(element, {
323
+ src,
324
+ title,
325
+ artist,
326
+ image,
327
+ imageAlt,
328
+ waveformColor: waveformColorValue,
329
+ waveformGradient: waveformGradientValue,
330
+ textColor: textColorValue,
331
+ backgroundColor,
332
+ backgroundGradient,
333
+ autoPlay,
334
+ onEnded,
335
+ labels,
336
+ waveformStyle,
337
+ showPlayButtonArtwork = false
338
+ }) {
339
+ const playerArtwork = showPlayButtonArtwork ? void 0 : image;
340
+ const { textColor, waveformColor, progressColor, waveformGradient } = getWaveformColors(
341
+ element,
342
+ waveformColorValue,
343
+ textColorValue,
344
+ waveformGradientValue
345
+ );
346
+ const waveformGradientStops = getResolvedGradientStops(
347
+ element,
348
+ waveformGradientValue
349
+ );
350
+ const waveformButtonColor = getRepresentativeColor(
351
+ waveformGradientStops || waveformColorValue
352
+ );
79
353
  const container = createWaveformContainer({
80
354
  url: src,
81
355
  title,
82
356
  artist,
83
- artwork: image,
357
+ artwork: playerArtwork,
84
358
  waveformColor,
85
359
  progressColor,
360
+ waveformGradient,
86
361
  buttonColor: textColor,
362
+ seekLabel: title || labels?.seek,
363
+ seekValueText: labels?.seekValueText,
87
364
  waveformStyle
88
365
  });
89
366
  element.appendChild(container);
90
367
  const instance = new WaveformPlayerLib(container);
91
- let cleanupAccessibility;
368
+ if (instance.artworkEl) {
369
+ instance.artworkEl.alt = imageAlt || "";
370
+ }
371
+ applyWaveformPlayerStyles(container, {
372
+ backgroundColor,
373
+ backgroundGradient,
374
+ textColor,
375
+ playButtonColor: showPlayButtonArtwork ? void 0 : waveformButtonColor,
376
+ playButtonGradient: showPlayButtonArtwork ? void 0 : waveformGradientValue
377
+ });
378
+ let cleanupPlayButtonAccessibility;
92
379
  const handlers = {
93
380
  ready: () => {
94
- styleSvgIcons(container, textColor);
95
- cleanupAccessibility = setupPlayButtonAccessibility(
381
+ styleSvgIcons(container, waveformButtonColor || textColor);
382
+ if (showPlayButtonArtwork) {
383
+ setupPlayButtonArtwork(container, image);
384
+ }
385
+ cleanupPlayButtonAccessibility = setupPlayButtonAccessibility(
96
386
  container,
97
387
  labels
98
388
  );
@@ -108,7 +398,7 @@ function initWaveformPlayer(element, { src, title, artist, image, autoPlay, onEn
108
398
  instance,
109
399
  container,
110
400
  destroy: () => {
111
- cleanupAccessibility?.();
401
+ cleanupPlayButtonAccessibility?.();
112
402
  container.removeEventListener(
113
403
  "waveformplayer:ready",
114
404
  handlers.ready
@@ -123,11 +413,15 @@ function initWaveformPlayer(element, { src, title, artist, image, autoPlay, onEn
123
413
  };
124
414
  }
125
415
  export {
416
+ applyWaveformPlayerStyles,
126
417
  createWaveformContainer,
127
418
  getWaveformColors,
419
+ getWaveformGradientStops,
128
420
  initWaveformPlayer,
129
421
  logPlayError,
130
422
  setupPlayButtonAccessibility,
131
- styleSvgIcons
423
+ setupPlayButtonArtwork,
424
+ styleSvgIcons,
425
+ updateSeekControlLabel
132
426
  };
133
427
  //# sourceMappingURL=waveform-utils.mjs.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../src/utils/waveform-utils.js"],
4
- "sourcesContent": ["/**\n * Shared utilities for waveform audio player functionality.\n * Used by both the WaveformPlayer component (editor) and view.js (frontend).\n */\n\n/**\n * External dependencies\n */\nimport { colord } from 'colord';\nimport WaveformPlayerLib from '@arraypress/waveform-player';\n\n/**\n * Configuration constants.\n * Note: DEFAULT_WAVEFORM_HEIGHT should match $waveform-player-height in style.scss.\n */\nconst DEFAULT_WAVEFORM_HEIGHT = 100;\n\n/**\n * Get computed style for an element, using ownerDocument for iframe compatibility.\n *\n * @param {Element} element - The element to get styles from.\n * @return {CSSStyleDeclaration} The computed style.\n */\nfunction getComputedStyle( element ) {\n\treturn element.ownerDocument.defaultView.getComputedStyle( element );\n}\n\n/**\n * Get all colors needed for the waveform player based on the element's styles.\n *\n * @param {Element} element - The element to derive colors from.\n * @return {Object} Object containing textColor, waveformColor, progressColor.\n */\nexport function getWaveformColors( element ) {\n\tconst textColor = getComputedStyle( element ).color;\n\tconst waveformColor = colord( textColor ).alpha( 0.3 ).toRgbString();\n\tconst progressColor = colord( textColor ).alpha( 0.6 ).toRgbString();\n\n\treturn { textColor, waveformColor, progressColor };\n}\n\n/**\n * Create a waveform container element with the specified attributes.\n *\n * @param {Object} options - The options for the container.\n * @param {string} options.url - The audio URL.\n * @param {string} options.title - The track title.\n * @param {string} options.artist - The track artist.\n * @param {string} options.artwork - The album artwork URL.\n * @param {string} options.waveformColor - The waveform bar color.\n * @param {string} options.progressColor - The progress indicator color.\n * @param {string} options.buttonColor - The play button color.\n * @param {number} options.height - The waveform height in pixels.\n * @param {string} options.waveformStyle - The visualization style (bars, mirror, line, blocks, dots, seekbar).\n * @return {Element} The configured container element.\n */\nexport function createWaveformContainer( {\n\turl,\n\ttitle,\n\tartist,\n\tartwork,\n\twaveformColor,\n\tprogressColor,\n\tbuttonColor,\n\theight = DEFAULT_WAVEFORM_HEIGHT,\n\twaveformStyle = 'bars',\n} ) {\n\tconst container = document.createElement( 'div' );\n\tcontainer.setAttribute( 'data-waveform-player', '' );\n\tcontainer.setAttribute( 'data-url', url );\n\tcontainer.setAttribute( 'data-height', String( height ) );\n\tcontainer.setAttribute( 'data-waveform-style', waveformStyle );\n\tcontainer.setAttribute( 'data-waveform-color', waveformColor );\n\tcontainer.setAttribute( 'data-progress-color', progressColor );\n\tcontainer.setAttribute( 'data-button-color', buttonColor );\n\tcontainer.setAttribute( 'data-text-color', buttonColor );\n\tcontainer.setAttribute( 'data-text-secondary-color', buttonColor );\n\tif ( title ) {\n\t\tcontainer.setAttribute( 'data-title', title );\n\t}\n\tif ( artist ) {\n\t\tcontainer.setAttribute( 'data-subtitle', artist );\n\t}\n\tif ( artwork ) {\n\t\tcontainer.setAttribute( 'data-artwork', artwork );\n\t}\n\treturn container;\n}\n\n/**\n * Apply contrasting color to SVG icon paths for visibility.\n * The icons should contrast with the button background (which uses textColor).\n *\n * @param {Element} container - The waveform container element.\n * @param {string} buttonColor - The button background color (textColor).\n */\nexport function styleSvgIcons( container, buttonColor ) {\n\t// Compute a contrasting color for the icons based on button brightness.\n\tconst isButtonDark = colord( buttonColor ).isDark();\n\tconst iconColor = isButtonDark ? '#ffffff' : '#000000';\n\n\tconst svgPaths = container.querySelectorAll( 'svg path' );\n\tsvgPaths.forEach( ( path ) => {\n\t\tpath.style.fill = iconColor;\n\t} );\n}\n\n/**\n * Set up play button accessibility: aria-label that toggles on play/pause.\n *\n * @param {Element} container - The waveform container element.\n * @param {Object} labels - Button labels.\n * @param {string} labels.play - Label for the play state.\n * @param {string} labels.pause - Label for the pause state.\n */\nexport function setupPlayButtonAccessibility(\n\tcontainer,\n\t{ play: playLabel = 'Play', pause: pauseLabel = 'Pause' } = {}\n) {\n\tconst playBtn = container.querySelector( '.waveform-btn' );\n\tif ( ! playBtn ) {\n\t\treturn;\n\t}\n\n\tplayBtn.setAttribute( 'aria-label', playLabel );\n\n\tconst onPlay = () => playBtn.setAttribute( 'aria-label', pauseLabel );\n\tconst onPause = () => playBtn.setAttribute( 'aria-label', playLabel );\n\n\tcontainer.addEventListener( 'waveformplayer:play', onPlay );\n\tcontainer.addEventListener( 'waveformplayer:pause', onPause );\n\tcontainer.addEventListener( 'waveformplayer:ended', onPause );\n\n\treturn () => {\n\t\tcontainer.removeEventListener( 'waveformplayer:play', onPlay );\n\t\tcontainer.removeEventListener( 'waveformplayer:pause', onPause );\n\t\tcontainer.removeEventListener( 'waveformplayer:ended', onPause );\n\t};\n}\n\n/**\n * Log play errors, filtering out expected AbortError.\n *\n * @param {Error} error - The error from play().\n */\nexport function logPlayError( error ) {\n\t// The browser throws AbortError when a play() promise is interrupted\n\t// by a subsequent pause() or a new audio source load (track change).\n\t// This is normal during rapid user interaction and safe to ignore.\n\tif ( error.name === 'AbortError' ) {\n\t\treturn;\n\t}\n\t// eslint-disable-next-line no-console\n\tconsole.error( 'Playlist play error:', error );\n}\n\n/**\n * Initialize a WaveformPlayer instance on an element.\n *\n * This is the shared core logic used by both the React component (editor)\n * and the Interactivity API (frontend).\n *\n * @param {Element} element - The container element (must be in DOM).\n * @param {Object} options - Configuration options.\n * @param {string} options.src - The audio file URL.\n * @param {string} options.title - The track title.\n * @param {string} options.artist - The artist name.\n * @param {string} options.image - The artwork image URL.\n * @param {boolean} options.autoPlay - Whether to auto-play when ready.\n * @param {Function} options.onEnded - Callback when track ends.\n * @param {Object} options.labels - Translated button labels.\n * @param {string} options.waveformStyle - Waveform style (bars, mirror, line, blocks, dots, seekbar).\n * @return {Object} Object with instance, container, and destroy function.\n */\nexport function initWaveformPlayer(\n\telement,\n\t{ src, title, artist, image, autoPlay, onEnded, labels, waveformStyle }\n) {\n\t// Get colors from computed styles.\n\tconst { textColor, waveformColor, progressColor } =\n\t\tgetWaveformColors( element );\n\n\t// Create the waveform container.\n\tconst container = createWaveformContainer( {\n\t\turl: src,\n\t\ttitle,\n\t\tartist,\n\t\tartwork: image,\n\t\twaveformColor,\n\t\tprogressColor,\n\t\tbuttonColor: textColor,\n\t\twaveformStyle,\n\t} );\n\telement.appendChild( container );\n\n\t// Initialize the WaveformPlayer library.\n\tconst instance = new WaveformPlayerLib( container );\n\n\t// Set up event handlers.\n\tlet cleanupAccessibility;\n\tconst handlers = {\n\t\tready: () => {\n\t\t\tstyleSvgIcons( container, textColor );\n\t\t\tcleanupAccessibility = setupPlayButtonAccessibility(\n\t\t\t\tcontainer,\n\t\t\t\tlabels\n\t\t\t);\n\t\t\tif ( autoPlay ) {\n\t\t\t\tinstance.play()?.catch( logPlayError );\n\t\t\t}\n\t\t},\n\t\tended: () => onEnded?.(),\n\t};\n\n\tcontainer.addEventListener( 'waveformplayer:ready', handlers.ready );\n\tcontainer.addEventListener( 'waveformplayer:ended', handlers.ended );\n\n\t// Return instance, container, and cleanup function.\n\treturn {\n\t\tinstance,\n\t\tcontainer,\n\t\tdestroy: () => {\n\t\t\tcleanupAccessibility?.();\n\t\t\tcontainer.removeEventListener(\n\t\t\t\t'waveformplayer:ready',\n\t\t\t\thandlers.ready\n\t\t\t);\n\t\t\tcontainer.removeEventListener(\n\t\t\t\t'waveformplayer:ended',\n\t\t\t\thandlers.ended\n\t\t\t);\n\t\t\tinstance.destroy();\n\t\t\tcontainer.remove();\n\t\t},\n\t};\n}\n"],
5
- "mappings": ";AAQA,SAAS,cAAc;AACvB,OAAO,uBAAuB;AAM9B,IAAM,0BAA0B;AAQhC,SAAS,iBAAkB,SAAU;AACpC,SAAO,QAAQ,cAAc,YAAY,iBAAkB,OAAQ;AACpE;AAQO,SAAS,kBAAmB,SAAU;AAC5C,QAAM,YAAY,iBAAkB,OAAQ,EAAE;AAC9C,QAAM,gBAAgB,OAAQ,SAAU,EAAE,MAAO,GAAI,EAAE,YAAY;AACnE,QAAM,gBAAgB,OAAQ,SAAU,EAAE,MAAO,GAAI,EAAE,YAAY;AAEnE,SAAO,EAAE,WAAW,eAAe,cAAc;AAClD;AAiBO,SAAS,wBAAyB;AAAA,EACxC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA,SAAS;AAAA,EACT,gBAAgB;AACjB,GAAI;AACH,QAAM,YAAY,SAAS,cAAe,KAAM;AAChD,YAAU,aAAc,wBAAwB,EAAG;AACnD,YAAU,aAAc,YAAY,GAAI;AACxC,YAAU,aAAc,eAAe,OAAQ,MAAO,CAAE;AACxD,YAAU,aAAc,uBAAuB,aAAc;AAC7D,YAAU,aAAc,uBAAuB,aAAc;AAC7D,YAAU,aAAc,uBAAuB,aAAc;AAC7D,YAAU,aAAc,qBAAqB,WAAY;AACzD,YAAU,aAAc,mBAAmB,WAAY;AACvD,YAAU,aAAc,6BAA6B,WAAY;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AG5B,QAAM,YAAY,wBAAyB;AAAA,IAC1C,KAAK;AAAA,IACL;AAAA,IACA;AAAA,IACA,SAAS;AAAA,IACT;AAAA,IACA;AAAA,IACA,aAAa;AAAA,IACb;AAAA,EACD,CAAE;AACF,UAAQ,YAAa,SAAU;AAG/B,QAAM,WAAW,IAAI,kBAAmB,SAAU;AAGlD,MAAI;AACJ,QAAM,WAAW;AAAA,IAChB,OAAO,MAAM;AACZ,oBAAe,WAAW,SAAU;AACpC,6BAAuB;AAAA,QACtB;AAAA,QACA;AAAA,MACD;AACA,UAAK,UAAW;AACf,iBAAS,KAAK,GAAG,MAAO,YAAa;AAAA,MACtC;AAAA,IACD;AAAA,IACA,OAAO,MAAM,UAAU;AAAA,EACxB;AAEA,YAAU,iBAAkB,wBAAwB,SAAS,KAAM;AACnE,YAAU,iBAAkB,wBAAwB,SAAS,KAAM;AAGnE,SAAO;AAAA,IACN;AAAA,IACA;AAAA,IACA,SAAS,MAAM;AACd,6BAAuB;AACvB,gBAAU;AAAA,QACT;AAAA,QACA,SAAS;AAAA,MACV;AACA,gBAAU;AAAA,QACT;AAAA,QACA,SAAS;AAAA,MACV;AACA,eAAS,QAAQ;AACjB,gBAAU,OAAO;AAAA,IAClB;AAAA,EACD;AACD;",
4
+ "sourcesContent": ["/**\n * Shared utilities for waveform audio player functionality.\n * Used by both the WaveformPlayer component (editor) and view.js (frontend).\n */\n\n/**\n * External dependencies\n */\nimport { colord } from 'colord';\nimport WaveformPlayerLib from '@arraypress/waveform-player';\n\n/**\n * Configuration constants.\n * Note: DEFAULT_WAVEFORM_HEIGHT should match $waveform-player-height in style.scss.\n */\nconst DEFAULT_WAVEFORM_HEIGHT = 100;\nconst DEFAULT_SEEK_LABEL = 'Seek';\n\n/**\n * Get computed style for an element, using ownerDocument for iframe compatibility.\n *\n * @param {Element} element - The element to get styles from.\n * @return {CSSStyleDeclaration} The computed style.\n */\nfunction getComputedStyle( element ) {\n\treturn element.ownerDocument.defaultView.getComputedStyle( element );\n}\n\nfunction getTopLevelGradientParts( gradientValue ) {\n\tconst match = gradientValue?.trim().match( /^[\\w-]+-gradient\\((.*)\\)$/i );\n\tif ( ! match ) {\n\t\treturn [];\n\t}\n\n\tconst parts = [];\n\tlet depth = 0;\n\tlet current = '';\n\n\tfor ( const character of match[ 1 ] ) {\n\t\tif ( character === '(' ) {\n\t\t\t++depth;\n\t\t} else if ( character === ')' ) {\n\t\t\t--depth;\n\t\t}\n\n\t\tif ( character === ',' && depth === 0 ) {\n\t\t\tparts.push( current.trim() );\n\t\t\tcurrent = '';\n\t\t\tcontinue;\n\t\t}\n\n\t\tcurrent += character;\n\t}\n\n\tif ( current.trim() ) {\n\t\tparts.push( current.trim() );\n\t}\n\n\treturn parts;\n}\n\nfunction getLeadingColorFunction( value ) {\n\tconst match = value.match( /^([\\w-]+)\\(/ );\n\tif ( ! match ) {\n\t\treturn;\n\t}\n\n\tconst supportedFunctions = [\n\t\t'color',\n\t\t'color-mix',\n\t\t'hsl',\n\t\t'hsla',\n\t\t'hwb',\n\t\t'lab',\n\t\t'lch',\n\t\t'oklab',\n\t\t'oklch',\n\t\t'rgb',\n\t\t'rgba',\n\t\t'var',\n\t];\n\tif ( ! supportedFunctions.includes( match[ 1 ].toLowerCase() ) ) {\n\t\treturn;\n\t}\n\n\tlet depth = 0;\n\tlet foundOpeningParenthesis = false;\n\tfor ( let index = 0; index < value.length; index++ ) {\n\t\tconst character = value[ index ];\n\t\tif ( character === '(' ) {\n\t\t\tfoundOpeningParenthesis = true;\n\t\t\t++depth;\n\t\t} else if ( character === ')' ) {\n\t\t\t--depth;\n\t\t}\n\n\t\tif ( foundOpeningParenthesis && depth === 0 ) {\n\t\t\treturn value.slice( 0, index + 1 );\n\t\t}\n\t}\n}\n\nfunction getColorStopValue( gradientPart ) {\n\tconst colorFunction = getLeadingColorFunction( gradientPart );\n\tif ( colorFunction ) {\n\t\treturn colorFunction;\n\t}\n\n\tconst [ possibleColor ] = gradientPart.split( /\\s+/ );\n\tif ( colord( possibleColor ).isValid() ) {\n\t\treturn possibleColor;\n\t}\n}\n\nfunction getWaveformGradientDirection( gradientValue ) {\n\tconst parts = getTopLevelGradientParts( gradientValue );\n\tconst direction = parts[ 0 ];\n\tconst angleMatch = direction?.match( /^(-?\\d+(?:\\.\\d+)?)deg$/i );\n\tif ( angleMatch ) {\n\t\tconst angle = ( ( Number( angleMatch[ 1 ] ) % 360 ) + 360 ) % 360;\n\t\tif ( angle === 90 || angle === 270 ) {\n\t\t\treturn 'horizontal';\n\t\t}\n\t\tif ( angle === 0 || angle === 180 ) {\n\t\t\treturn 'vertical';\n\t\t}\n\t\treturn 'diagonal';\n\t}\n\n\tif ( ! direction?.startsWith( 'to ' ) ) {\n\t\treturn undefined;\n\t}\n\n\tconst sideOrCorner = direction.toLowerCase().replace( /^to\\s+/, '' );\n\tconst hasHorizontalSide =\n\t\tsideOrCorner.includes( 'left' ) || sideOrCorner.includes( 'right' );\n\tconst hasVerticalSide =\n\t\tsideOrCorner.includes( 'top' ) || sideOrCorner.includes( 'bottom' );\n\n\tif ( hasHorizontalSide && hasVerticalSide ) {\n\t\treturn 'diagonal';\n\t}\n\tif ( hasHorizontalSide ) {\n\t\treturn 'horizontal';\n\t}\n\tif ( hasVerticalSide ) {\n\t\treturn 'vertical';\n\t}\n}\n\nfunction resolveColorValue( element, colorValue ) {\n\tif ( ! colorValue || colord( colorValue ).isValid() ) {\n\t\treturn colorValue;\n\t}\n\n\tconst colorResolver = element.ownerDocument.createElement( 'span' );\n\tcolorResolver.style.color = colorValue;\n\tif ( ! colorResolver.style.color ) {\n\t\treturn colorValue;\n\t}\n\telement.appendChild( colorResolver );\n\n\tconst resolvedColor = getComputedStyle( colorResolver ).color;\n\tcolorResolver.remove();\n\n\treturn resolvedColor && colord( resolvedColor ).isValid()\n\t\t? resolvedColor\n\t\t: colorValue;\n}\n\nfunction getResolvedGradientStops( element, gradientValue ) {\n\tconst stops = getWaveformGradientStops( gradientValue )\n\t\t?.map( ( colorValue ) => resolveColorValue( element, colorValue ) )\n\t\t.filter( ( colorValue ) => colord( colorValue ).isValid() );\n\n\treturn stops?.length > 1 ? stops : undefined;\n}\n\nfunction applyAlpha( colorValue, alpha ) {\n\tif ( Array.isArray( colorValue ) ) {\n\t\treturn colorValue.map( ( color ) =>\n\t\t\tcolord( color ).alpha( alpha ).toRgbString()\n\t\t);\n\t}\n\treturn colord( colorValue ).alpha( alpha ).toRgbString();\n}\n\nfunction getRepresentativeColor( colorValue ) {\n\tif ( Array.isArray( colorValue ) ) {\n\t\treturn colorValue[ colorValue.length - 1 ];\n\t}\n\treturn colorValue;\n}\n\nexport function getWaveformGradientStops( gradientValue ) {\n\tconst stops = getTopLevelGradientParts( gradientValue )\n\t\t.map( getColorStopValue )\n\t\t.filter( Boolean );\n\n\treturn stops.length > 1 ? stops : undefined;\n}\n\nfunction serializeColorValue( colorValue ) {\n\treturn Array.isArray( colorValue )\n\t\t? JSON.stringify( colorValue )\n\t\t: colorValue;\n}\n\n/**\n * Get all colors needed for the waveform player based on the element's styles.\n *\n * @param {Element} element - The element to derive colors from.\n * @param {string} waveformColorValue - The base waveform color value to use.\n * @param {string} textColorValue - The text color value to use.\n * @param {string} waveformGradientValue - The waveform gradient value to use.\n * @return {Object} Object containing textColor, waveformColor, progressColor.\n */\nexport function getWaveformColors(\n\telement,\n\twaveformColorValue,\n\ttextColorValue,\n\twaveformGradientValue\n) {\n\tconst textColor = textColorValue || getComputedStyle( element ).color;\n\tconst waveformGradientStops = getResolvedGradientStops(\n\t\telement,\n\t\twaveformGradientValue\n\t);\n\tconst waveformBaseColor =\n\t\twaveformGradientStops || waveformColorValue || textColor;\n\tconst waveformColor = applyAlpha( waveformBaseColor, 0.3 );\n\tconst progressColor = applyAlpha( waveformBaseColor, 0.6 );\n\tconst waveformGradient = waveformGradientStops\n\t\t? getWaveformGradientDirection( waveformGradientValue )\n\t\t: undefined;\n\n\treturn {\n\t\ttextColor,\n\t\twaveformColor,\n\t\tprogressColor,\n\t\t...( waveformGradient && { waveformGradient } ),\n\t};\n}\n\n/**\n * Create a waveform container element with the specified attributes.\n *\n * @param {Object} options - The options for the container.\n * @param {string} options.url - The audio URL.\n * @param {string} options.title - The track title.\n * @param {string} options.artist - The track artist.\n * @param {string} options.artwork - The track image URL.\n * @param {string} options.waveformColor - The waveform bar color.\n * @param {string} options.progressColor - The progress indicator color.\n * @param {string} options.waveformGradient - The waveform gradient direction.\n * @param {string} options.buttonColor - The play button color.\n * @param {string} options.seekLabel - Accessible label for the seek control.\n * @param {string} options.seekValueText - Accessible value-text template for the seek control (e.g. '%1$s of %2$s').\n * @param {number} options.height - The waveform height in pixels.\n * @param {string} options.waveformStyle - The visualization style (bars, mirror, line, blocks, dots, seekbar).\n * @return {Element} The configured container element.\n */\nexport function createWaveformContainer( {\n\turl,\n\ttitle,\n\tartist,\n\tartwork,\n\twaveformColor,\n\tprogressColor,\n\twaveformGradient,\n\tbuttonColor,\n\tseekLabel,\n\tseekValueText,\n\theight = DEFAULT_WAVEFORM_HEIGHT,\n\twaveformStyle = 'bars',\n} ) {\n\tconst container = document.createElement( 'div' );\n\tcontainer.setAttribute( 'data-waveform-player', '' );\n\tcontainer.setAttribute( 'data-url', url );\n\tcontainer.setAttribute( 'data-height', String( height ) );\n\tcontainer.setAttribute( 'data-waveform-style', waveformStyle );\n\tcontainer.setAttribute(\n\t\t'data-waveform-color',\n\t\tserializeColorValue( waveformColor )\n\t);\n\tcontainer.setAttribute(\n\t\t'data-progress-color',\n\t\tserializeColorValue( progressColor )\n\t);\n\tif ( waveformGradient ) {\n\t\tcontainer.setAttribute( 'data-waveform-gradient', waveformGradient );\n\t}\n\tcontainer.setAttribute( 'data-button-color', buttonColor );\n\tcontainer.setAttribute(\n\t\t'data-seek-label',\n\t\tgetSeekControlLabel( seekLabel )\n\t);\n\t// The library formats the current time and duration and interpolates them\n\t// into this translated template for the seek slider's aria-valuetext.\n\tif ( seekValueText ) {\n\t\tcontainer.setAttribute( 'data-seek-value-text', seekValueText );\n\t}\n\tcontainer.setAttribute( 'data-text-color', buttonColor );\n\tcontainer.setAttribute( 'data-text-secondary-color', buttonColor );\n\n\tif ( title ) {\n\t\tcontainer.setAttribute( 'data-title', title );\n\t}\n\tif ( artist ) {\n\t\tcontainer.setAttribute( 'data-artist', artist );\n\t}\n\tif ( artwork ) {\n\t\tcontainer.setAttribute( 'data-artwork', artwork );\n\t}\n\treturn container;\n}\n\n/**\n * Apply custom styles to a generated waveform player.\n *\n * @param {Element} container - The generated player container.\n * @param {Object} styles - The player styles.\n * @param {string} styles.backgroundColor - The waveform area background color.\n * @param {string} styles.backgroundGradient - The waveform area background gradient.\n * @param {string} styles.textColor - The player text color.\n * @param {string} styles.playButtonColor - The play button color.\n * @param {string} styles.playButtonGradient - The play button gradient.\n */\nexport function applyWaveformPlayerStyles(\n\tcontainer,\n\t{\n\t\tbackgroundColor,\n\t\tbackgroundGradient,\n\t\ttextColor,\n\t\tplayButtonColor,\n\t\tplayButtonGradient,\n\t} = {}\n) {\n\tconst waveformContainer = container.querySelector( '.waveform-container' );\n\tconst playButton = container.querySelector( '.waveform-btn' );\n\tconst playButtonBaseColor = getRepresentativeColor(\n\t\tgetResolvedGradientStops( container, playButtonGradient ) ||\n\t\t\tplayButtonColor\n\t);\n\n\tif ( playButtonBaseColor ) {\n\t\tcontainer.style.setProperty(\n\t\t\t'--wfp-button-color',\n\t\t\tplayButtonBaseColor\n\t\t);\n\t} else {\n\t\tcontainer.style.removeProperty( '--wfp-button-color' );\n\t}\n\n\tif ( textColor ) {\n\t\tcontainer.style.setProperty( '--wfp-text-color', textColor );\n\t\tcontainer.style.setProperty( '--wfp-text-secondary-color', textColor );\n\t} else {\n\t\tcontainer.style.removeProperty( '--wfp-text-color' );\n\t\tcontainer.style.removeProperty( '--wfp-text-secondary-color' );\n\t}\n\n\tif ( playButton ) {\n\t\tif ( playButtonGradient ) {\n\t\t\tplayButton.style.background = playButtonGradient;\n\t\t} else {\n\t\t\tplayButton.style.removeProperty( 'background' );\n\t\t}\n\t}\n\n\tif ( waveformContainer ) {\n\t\tif ( backgroundGradient ) {\n\t\t\twaveformContainer.style.background = backgroundGradient;\n\t\t} else if ( backgroundColor ) {\n\t\t\twaveformContainer.style.removeProperty( 'background' );\n\t\t\twaveformContainer.style.backgroundColor = backgroundColor;\n\t\t} else {\n\t\t\twaveformContainer.style.removeProperty( 'background' );\n\t\t\twaveformContainer.style.removeProperty( 'background-color' );\n\t\t}\n\t}\n}\n\n/**\n * Apply contrasting color to SVG icon paths for visibility.\n * The icons should contrast with the button background.\n *\n * @param {Element} container - The waveform container element.\n * @param {string} buttonColor - The button background color.\n */\nexport function styleSvgIcons( container, buttonColor ) {\n\t// Compute a contrasting color for the icons based on button brightness.\n\tconst isButtonDark = colord( buttonColor ).isDark();\n\tconst iconColor = isButtonDark ? '#ffffff' : '#000000';\n\n\tconst svgPaths = container.querySelectorAll( 'svg path' );\n\tsvgPaths.forEach( ( path ) => {\n\t\tpath.style.fill = iconColor;\n\t} );\n}\n\n/**\n * Set up play button accessibility: aria-label that toggles on play/pause.\n *\n * @param {Element} container - The waveform container element.\n * @param {Object} labels - Button labels.\n * @param {string} labels.play - Label for the play state.\n * @param {string} labels.pause - Label for the pause state.\n */\nexport function setupPlayButtonAccessibility(\n\tcontainer,\n\t{ play: playLabel = 'Play', pause: pauseLabel = 'Pause' } = {}\n) {\n\tconst playBtn = container.querySelector( '.waveform-btn' );\n\tif ( ! playBtn ) {\n\t\treturn;\n\t}\n\n\tplayBtn.setAttribute( 'aria-label', playLabel );\n\n\tconst onPlay = () => playBtn.setAttribute( 'aria-label', pauseLabel );\n\tconst onPause = () => playBtn.setAttribute( 'aria-label', playLabel );\n\n\tcontainer.addEventListener( 'waveformplayer:play', onPlay );\n\tcontainer.addEventListener( 'waveformplayer:pause', onPause );\n\tcontainer.addEventListener( 'waveformplayer:ended', onPause );\n\n\treturn () => {\n\t\tcontainer.removeEventListener( 'waveformplayer:play', onPlay );\n\t\tcontainer.removeEventListener( 'waveformplayer:pause', onPause );\n\t\tcontainer.removeEventListener( 'waveformplayer:ended', onPause );\n\t};\n}\n\n/**\n * Get the accessible label for the waveform seek control.\n *\n * @param {string} label - Accessible label for the seek control.\n * @return {string} The provided label or translated fallback.\n */\nfunction getSeekControlLabel( label ) {\n\treturn label || DEFAULT_SEEK_LABEL;\n}\n\n/**\n * Update the waveform seek control label.\n *\n * @param {Object} instance - The WaveformPlayer instance.\n * @param {string} label - Accessible label for the seek control.\n */\nexport function updateSeekControlLabel( instance, label ) {\n\tconst seekLabel = getSeekControlLabel( label );\n\tinstance.options.seekLabel = seekLabel;\n\tinstance.applySeekLabel?.( seekLabel );\n\n\tconst seekControl = instance?.container?.querySelector(\n\t\t'.waveform-container'\n\t);\n\n\tif ( seekControl ) {\n\t\tseekControl.setAttribute( 'aria-label', seekLabel );\n\t}\n}\n\n/**\n * Show the current artwork as the play button background.\n *\n * @param {Element} container - The waveform player container element.\n * @param {string} artworkUrl - The track image URL.\n */\nexport function setupPlayButtonArtwork( container, artworkUrl ) {\n\tif ( ! artworkUrl ) {\n\t\tcontainer.classList.remove( 'has-play-button-artwork' );\n\t\tcontainer.style.removeProperty( '--wp--playlist--play-button-artwork' );\n\t\treturn;\n\t}\n\n\tcontainer.classList.add( 'has-play-button-artwork' );\n\tcontainer.style.setProperty(\n\t\t'--wp--playlist--play-button-artwork',\n\t\t`url(${ JSON.stringify( artworkUrl ) })`\n\t);\n}\n\n/**\n * Log play errors, filtering out expected AbortError.\n *\n * @param {Error} error - The error from play().\n */\nexport function logPlayError( error ) {\n\t// The browser throws AbortError when a play() promise is interrupted\n\t// by a subsequent pause() or a new audio source load (track change).\n\t// This is normal during rapid user interaction and safe to ignore.\n\tif ( error.name === 'AbortError' ) {\n\t\treturn;\n\t}\n\t// eslint-disable-next-line no-console\n\tconsole.error( 'Playlist play error:', error );\n}\n\n/**\n * Initialize a WaveformPlayer instance on an element.\n *\n * This is the shared core logic used by both the React component (editor)\n * and the Interactivity API (frontend).\n *\n * @param {Element} element - The container element (must be in DOM).\n * @param {Object} options - Configuration options.\n * @param {string} options.src - The audio file URL.\n * @param {string} options.title - The track title.\n * @param {string} options.artist - The artist name.\n * @param {string} options.image - The track image URL.\n * @param {string} options.imageAlt - The track image alt text.\n * @param {string} options.waveformColor - The waveform color.\n * @param {string} options.waveformGradient - The waveform gradient.\n * @param {string} options.textColor - The player text color.\n * @param {string} options.backgroundColor - The player background color.\n * @param {string} options.backgroundGradient - The player background gradient.\n * @param {boolean} options.autoPlay - Whether to auto-play when ready.\n * @param {Function} options.onEnded - Callback when track ends.\n * @param {Object} options.labels - Translated button labels.\n * @param {string} options.waveformStyle - Waveform style (bars, mirror, line, blocks, dots, seekbar).\n * @param {boolean} options.showPlayButtonArtwork - Whether to show artwork on the play button.\n * @return {Object} Object with instance, container, and destroy function.\n */\nexport function initWaveformPlayer(\n\telement,\n\t{\n\t\tsrc,\n\t\ttitle,\n\t\tartist,\n\t\timage,\n\t\timageAlt,\n\t\twaveformColor: waveformColorValue,\n\t\twaveformGradient: waveformGradientValue,\n\t\ttextColor: textColorValue,\n\t\tbackgroundColor,\n\t\tbackgroundGradient,\n\t\tautoPlay,\n\t\tonEnded,\n\t\tlabels,\n\t\twaveformStyle,\n\t\tshowPlayButtonArtwork = false,\n\t}\n) {\n\tconst playerArtwork = showPlayButtonArtwork ? undefined : image;\n\n\t// Get colors from computed styles.\n\tconst { textColor, waveformColor, progressColor, waveformGradient } =\n\t\tgetWaveformColors(\n\t\t\telement,\n\t\t\twaveformColorValue,\n\t\t\ttextColorValue,\n\t\t\twaveformGradientValue\n\t\t);\n\tconst waveformGradientStops = getResolvedGradientStops(\n\t\telement,\n\t\twaveformGradientValue\n\t);\n\tconst waveformButtonColor = getRepresentativeColor(\n\t\twaveformGradientStops || waveformColorValue\n\t);\n\n\t// Create the waveform container.\n\tconst container = createWaveformContainer( {\n\t\turl: src,\n\t\ttitle,\n\t\tartist,\n\t\tartwork: playerArtwork,\n\t\twaveformColor,\n\t\tprogressColor,\n\t\twaveformGradient,\n\t\tbuttonColor: textColor,\n\t\tseekLabel: title || labels?.seek,\n\t\tseekValueText: labels?.seekValueText,\n\t\twaveformStyle,\n\t} );\n\telement.appendChild( container );\n\n\t// Initialize the WaveformPlayer library. The library reads the translated\n\t// seek label and value-text templates from the container's data attributes\n\t// and owns the seek slider's accessible label and value text.\n\tconst instance = new WaveformPlayerLib( container );\n\tif ( instance.artworkEl ) {\n\t\tinstance.artworkEl.alt = imageAlt || '';\n\t}\n\tapplyWaveformPlayerStyles( container, {\n\t\tbackgroundColor,\n\t\tbackgroundGradient,\n\t\ttextColor,\n\t\tplayButtonColor: showPlayButtonArtwork\n\t\t\t? undefined\n\t\t\t: waveformButtonColor,\n\t\tplayButtonGradient: showPlayButtonArtwork\n\t\t\t? undefined\n\t\t\t: waveformGradientValue,\n\t} );\n\n\t// Set up event handlers.\n\tlet cleanupPlayButtonAccessibility;\n\tconst handlers = {\n\t\tready: () => {\n\t\t\tstyleSvgIcons( container, waveformButtonColor || textColor );\n\t\t\tif ( showPlayButtonArtwork ) {\n\t\t\t\tsetupPlayButtonArtwork( container, image );\n\t\t\t}\n\t\t\tcleanupPlayButtonAccessibility = setupPlayButtonAccessibility(\n\t\t\t\tcontainer,\n\t\t\t\tlabels\n\t\t\t);\n\t\t\tif ( autoPlay ) {\n\t\t\t\tinstance.play()?.catch( logPlayError );\n\t\t\t}\n\t\t},\n\t\tended: () => onEnded?.(),\n\t};\n\n\tcontainer.addEventListener( 'waveformplayer:ready', handlers.ready );\n\tcontainer.addEventListener( 'waveformplayer:ended', handlers.ended );\n\n\t// Return instance, container, and cleanup function.\n\treturn {\n\t\tinstance,\n\t\tcontainer,\n\t\tdestroy: () => {\n\t\t\tcleanupPlayButtonAccessibility?.();\n\t\t\tcontainer.removeEventListener(\n\t\t\t\t'waveformplayer:ready',\n\t\t\t\thandlers.ready\n\t\t\t);\n\t\t\tcontainer.removeEventListener(\n\t\t\t\t'waveformplayer:ended',\n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AAA,QACA;AAAA,MACD;AACA,UAAK,UAAW;AACf,iBAAS,KAAK,GAAG,MAAO,YAAa;AAAA,MACtC;AAAA,IACD;AAAA,IACA,OAAO,MAAM,UAAU;AAAA,EACxB;AAEA,YAAU,iBAAkB,wBAAwB,SAAS,KAAM;AACnE,YAAU,iBAAkB,wBAAwB,SAAS,KAAM;AAGnE,SAAO;AAAA,IACN;AAAA,IACA;AAAA,IACA,SAAS,MAAM;AACd,uCAAiC;AACjC,gBAAU;AAAA,QACT;AAAA,QACA,SAAS;AAAA,MACV;AACA,gBAAU;AAAA,QACT;AAAA,QACA,SAAS;AAAA,MACV;AACA,eAAS,QAAQ;AACjB,gBAAU,OAAO;AAAA,IAClB;AAAA,EACD;AACD;",
6
6
  "names": []
7
7
  }
@@ -32,7 +32,6 @@ import Tracks from "./tracks.mjs";
32
32
  import { Caption } from "../utils/caption.mjs";
33
33
  import PosterImage from "../utils/poster-image.mjs";
34
34
  import { isGifVariation } from "./variations.mjs";
35
- import GifRestoreControl from "./gif-restore-control.mjs";
36
35
  import { Fragment, jsx, jsxs } from "react/jsx-runtime";
37
36
  var ALLOWED_MEDIA_TYPES = ["video"];
38
37
  function VideoEdit({
@@ -41,8 +40,7 @@ function VideoEdit({
41
40
  className,
42
41
  setAttributes,
43
42
  insertBlocksAfter,
44
- onReplace,
45
- clientId
43
+ onReplace
46
44
  }) {
47
45
  const videoPlayer = useRef();
48
46
  const { id, controls, poster, src, tracks, width, height } = attributes;
@@ -177,14 +175,7 @@ function VideoEdit({
177
175
  onReset: () => onSelectVideo(void 0),
178
176
  variant: "toolbar"
179
177
  }
180
- ) }),
181
- isGif && /* @__PURE__ */ jsx(
182
- GifRestoreControl,
183
- {
184
- attributes,
185
- clientId
186
- }
187
- )
178
+ ) })
188
179
  ] }),
189
180
  /* @__PURE__ */ jsx(InspectorControls, { children: /* @__PURE__ */ jsxs(
190
181
  ToolsPanel,
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../src/video/edit.js"],
4
- "sourcesContent": ["/**\n * External dependencies\n */\nimport clsx from 'clsx';\n\n/**\n * WordPress dependencies\n */\nimport { isBlobURL } from '@wordpress/blob';\nimport {\n\tSpinner,\n\tPlaceholder,\n\t__experimentalToolsPanel as ToolsPanel,\n} from '@wordpress/components';\nimport {\n\tBlockControls,\n\tBlockIcon,\n\tInspectorControls,\n\tMediaPlaceholder,\n\tMediaReplaceFlow,\n\tuseBlockProps,\n\tuseBlockEditingMode,\n} from '@wordpress/block-editor';\nimport { useRef, useEffect, useState } from '@wordpress/element';\nimport { __ } from '@wordpress/i18n';\nimport { useDispatch } from '@wordpress/data';\nimport { video as icon } from '@wordpress/icons';\nimport { store as noticesStore } from '@wordpress/notices';\nimport { prependHTTPS } from '@wordpress/url';\n\n/**\n * Internal dependencies\n */\nimport { createUpgradedEmbedBlock } from '../embed/util';\nimport {\n\tuseUploadMediaFromBlobURL,\n\tuseToolsPanelDropdownMenuProps,\n} from '../utils/hooks';\nimport VideoCommonSettings from './edit-common-settings';\nimport TracksEditor from './tracks-editor';\nimport Tracks from './tracks';\nimport { Caption } from '../utils/caption';\nimport PosterImage from '../utils/poster-image';\nimport { isGifVariation } from './variations';\nimport GifRestoreControl from './gif-restore-control';\n\nconst ALLOWED_MEDIA_TYPES = [ 'video' ];\n\nfunction VideoEdit( {\n\tisSelected: isSingleSelected,\n\tattributes,\n\tclassName,\n\tsetAttributes,\n\tinsertBlocksAfter,\n\tonReplace,\n\tclientId,\n} ) {\n\tconst videoPlayer = useRef();\n\tconst { id, controls, poster, src, tracks, width, height } = attributes;\n\tconst isGif = isGifVariation( attributes );\n\t// Give the <video> an explicit (non-`auto`) aspect ratio derived from the\n\t// stored dimensions. The width/height attributes alone only yield\n\t// `aspect-ratio: auto W/H`, whose `auto` keyword defers to the element's\n\t// natural ratio while the poster/metadata load - during which Chrome briefly\n\t// computes a runaway height (tens of thousands of pixels) before settling.\n\t// That spike is what reads as a duplicated image during the GIF-to-video\n\t// swap. A non-`auto` ratio governs the box height throughout the load.\n\tconst aspectRatio =\n\t\twidth && height ? `${ width } / ${ height }` : undefined;\n\tconst [ temporaryURL, setTemporaryURL ] = useState( attributes.blob );\n\tconst dropdownMenuProps = useToolsPanelDropdownMenuProps();\n\tconst blockEditingMode = useBlockEditingMode();\n\tconst hasNonContentControls = blockEditingMode === 'default';\n\n\tuseUploadMediaFromBlobURL( {\n\t\turl: temporaryURL,\n\t\tallowedTypes: ALLOWED_MEDIA_TYPES,\n\t\tonChange: onSelectVideo,\n\t\tonError: onUploadError,\n\t} );\n\n\tuseEffect( () => {\n\t\t// Placeholder may be rendered.\n\t\tif ( videoPlayer.current ) {\n\t\t\tvideoPlayer.current.load();\n\t\t}\n\t}, [ poster ] );\n\n\t// The GIF variation plays like an animated GIF in the editor (the playback\n\t// attributes are applied to the preview <video> below). Regular videos do\n\t// not autoplay in the editor, so only nudge GIFs into playing after a\n\t// source change in case the muted autoplay did not start on its own.\n\tuseEffect( () => {\n\t\tif ( isGif ) {\n\t\t\t// Browsers allow muted videos to be played programmatically.\n\t\t\tvideoPlayer.current?.play().catch( () => {} );\n\t\t}\n\t}, [ isGif, src, poster ] );\n\n\t// TODO: Whether the video was obtained from the media library or was provided by URL, obtain the `videoWidth` and `videoHeight` of the video once its metadata has loaded and persist in the block attributes.\n\tfunction onSelectVideo( media ) {\n\t\tif ( ! media || ! media.url ) {\n\t\t\t// In this case there was an error\n\t\t\t// previous attributes should be removed\n\t\t\t// because they may be temporary blob urls.\n\t\t\tsetAttributes( {\n\t\t\t\tsrc: undefined,\n\t\t\t\tid: undefined,\n\t\t\t\tposter: undefined,\n\t\t\t\tcaption: undefined,\n\t\t\t\tblob: undefined,\n\t\t\t} );\n\t\t\tsetTemporaryURL();\n\t\t\treturn;\n\t\t}\n\n\t\tif ( isBlobURL( media.url ) ) {\n\t\t\tsetTemporaryURL( media.url );\n\t\t\treturn;\n\t\t}\n\n\t\t// Sets the block's attribute and updates the edit component from the\n\t\t// selected media.\n\t\tsetAttributes( {\n\t\t\tblob: undefined,\n\t\t\tsrc: media.url,\n\t\t\tid: media.id,\n\t\t\tposter:\n\t\t\t\tmedia.image?.src !== media.icon ? media.image?.src : undefined,\n\t\t\tcaption: media.caption,\n\t\t} );\n\t\tsetTemporaryURL();\n\t}\n\n\tfunction onSelectURL( newSrc ) {\n\t\tif ( newSrc !== src ) {\n\t\t\tconst url = prependHTTPS( newSrc );\n\t\t\t// Check if there's an embed block that handles this URL.\n\t\t\tconst embedBlock = createUpgradedEmbedBlock( {\n\t\t\t\tattributes: { url },\n\t\t\t} );\n\t\t\tif ( undefined !== embedBlock && onReplace ) {\n\t\t\t\tonReplace( embedBlock );\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tsetAttributes( {\n\t\t\t\tblob: undefined,\n\t\t\t\tsrc: url,\n\t\t\t\tid: undefined,\n\t\t\t\tposter: undefined,\n\t\t\t} );\n\t\t\tsetTemporaryURL();\n\t\t}\n\t}\n\n\tconst { createErrorNotice } = useDispatch( noticesStore );\n\tfunction onUploadError( message ) {\n\t\tcreateErrorNotice( message, { type: 'snackbar' } );\n\t}\n\n\t// Much of this description is duplicated from MediaPlaceholder.\n\tconst placeholder = ( content ) => {\n\t\treturn (\n\t\t\t<Placeholder\n\t\t\t\tclassName=\"block-editor-media-placeholder\"\n\t\t\t\twithIllustration={ ! isSingleSelected }\n\t\t\t\ticon={ icon }\n\t\t\t\tlabel={ __( 'Video' ) }\n\t\t\t\tinstructions={ __(\n\t\t\t\t\t'Drag and drop a video, upload, or choose from your library.'\n\t\t\t\t) }\n\t\t\t>\n\t\t\t\t{ content }\n\t\t\t</Placeholder>\n\t\t);\n\t};\n\n\tconst classes = clsx( className, {\n\t\t'is-transient': !! temporaryURL,\n\t} );\n\n\tconst blockProps = useBlockProps( {\n\t\tclassName: classes,\n\t} );\n\n\tif ( ! src && ! temporaryURL ) {\n\t\treturn (\n\t\t\t<div { ...blockProps }>\n\t\t\t\t<MediaPlaceholder\n\t\t\t\t\ticon={ <BlockIcon icon={ icon } /> }\n\t\t\t\t\tonSelect={ onSelectVideo }\n\t\t\t\t\tonSelectURL={ onSelectURL }\n\t\t\t\t\taccept=\"video/*\"\n\t\t\t\t\tallowedTypes={ ALLOWED_MEDIA_TYPES }\n\t\t\t\t\tvalue={ attributes }\n\t\t\t\t\tonError={ onUploadError }\n\t\t\t\t\tplaceholder={ placeholder }\n\t\t\t\t/>\n\t\t\t</div>\n\t\t);\n\t}\n\n\treturn (\n\t\t<>\n\t\t\t{ isSingleSelected && (\n\t\t\t\t<>\n\t\t\t\t\t<BlockControls>\n\t\t\t\t\t\t<TracksEditor\n\t\t\t\t\t\t\ttracks={ tracks }\n\t\t\t\t\t\t\tonChange={ ( newTracks ) => {\n\t\t\t\t\t\t\t\tsetAttributes( { tracks: newTracks } );\n\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t/>\n\t\t\t\t\t</BlockControls>\n\t\t\t\t\t<BlockControls group=\"other\">\n\t\t\t\t\t\t<MediaReplaceFlow\n\t\t\t\t\t\t\tmediaId={ id }\n\t\t\t\t\t\t\tmediaURL={ src }\n\t\t\t\t\t\t\tallowedTypes={ ALLOWED_MEDIA_TYPES }\n\t\t\t\t\t\t\taccept=\"video/*\"\n\t\t\t\t\t\t\tonSelect={ onSelectVideo }\n\t\t\t\t\t\t\tonSelectURL={ onSelectURL }\n\t\t\t\t\t\t\tonError={ onUploadError }\n\t\t\t\t\t\t\tonReset={ () => onSelectVideo( undefined ) }\n\t\t\t\t\t\t\tvariant=\"toolbar\"\n\t\t\t\t\t\t/>\n\t\t\t\t\t</BlockControls>\n\t\t\t\t\t{ isGif && (\n\t\t\t\t\t\t<GifRestoreControl\n\t\t\t\t\t\t\tattributes={ attributes }\n\t\t\t\t\t\t\tclientId={ clientId }\n\t\t\t\t\t\t/>\n\t\t\t\t\t) }\n\t\t\t\t</>\n\t\t\t) }\n\t\t\t<InspectorControls>\n\t\t\t\t<ToolsPanel\n\t\t\t\t\tlabel={ __( 'Settings' ) }\n\t\t\t\t\tresetAll={ () => {\n\t\t\t\t\t\tsetAttributes( {\n\t\t\t\t\t\t\tautoplay: false,\n\t\t\t\t\t\t\tcontrols: true,\n\t\t\t\t\t\t\tloop: false,\n\t\t\t\t\t\t\tmuted: false,\n\t\t\t\t\t\t\tplaysInline: false,\n\t\t\t\t\t\t\tpreload: 'metadata',\n\t\t\t\t\t\t\tposter: undefined,\n\t\t\t\t\t\t} );\n\t\t\t\t\t} }\n\t\t\t\t\tdropdownMenuProps={ dropdownMenuProps }\n\t\t\t\t>\n\t\t\t\t\t<VideoCommonSettings\n\t\t\t\t\t\tsetAttributes={ setAttributes }\n\t\t\t\t\t\tattributes={ attributes }\n\t\t\t\t\t/>\n\t\t\t\t\t<PosterImage\n\t\t\t\t\t\tposter={ poster }\n\t\t\t\t\t\tonChange={ ( posterImage ) =>\n\t\t\t\t\t\t\tsetAttributes( {\n\t\t\t\t\t\t\t\tposter: posterImage?.url,\n\t\t\t\t\t\t\t} )\n\t\t\t\t\t\t}\n\t\t\t\t\t/>\n\t\t\t\t</ToolsPanel>\n\t\t\t</InspectorControls>\n\t\t\t<figure { ...blockProps }>\n\t\t\t\t<video\n\t\t\t\t\tcontrols={ controls }\n\t\t\t\t\tinert={ ! isSingleSelected ? 'true' : undefined }\n\t\t\t\t\tposter={ poster }\n\t\t\t\t\tsrc={ src || temporaryURL }\n\t\t\t\t\tref={ videoPlayer }\n\t\t\t\t\tautoPlay={ isGif }\n\t\t\t\t\tloop={ isGif }\n\t\t\t\t\tmuted={ isGif }\n\t\t\t\t\tplaysInline={ isGif }\n\t\t\t\t\twidth={ width }\n\t\t\t\t\theight={ height }\n\t\t\t\t\tstyle={ aspectRatio ? { aspectRatio } : undefined }\n\t\t\t\t>\n\t\t\t\t\t<Tracks tracks={ tracks } />\n\t\t\t\t</video>\n\t\t\t\t{ !! temporaryURL && <Spinner /> }\n\t\t\t\t<Caption\n\t\t\t\t\tattributes={ attributes }\n\t\t\t\t\tsetAttributes={ setAttributes }\n\t\t\t\t\tisSelected={ isSingleSelected }\n\t\t\t\t\tinsertBlocksAfter={ insertBlocksAfter }\n\t\t\t\t\tlabel={ __( 'Video caption text' ) }\n\t\t\t\t\tshowToolbarButton={\n\t\t\t\t\t\tisSingleSelected && hasNonContentControls\n\t\t\t\t\t}\n\t\t\t\t/>\n\t\t\t</figure>\n\t\t</>\n\t);\n}\n\nexport default VideoEdit;\n"],
5
- "mappings": ";AAGA,OAAO,UAAU;AAKjB,SAAS,iBAAiB;AAC1B;AAAA,EACC;AAAA,EACA;AAAA,EACA,4BAA4B;AAAA,OACtB;AACP;AAAA,EACC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACM;AACP,SAAS,QAAQ,WAAW,gBAAgB;AAC5C,SAAS,UAAU;AACnB,SAAS,mBAAmB;AAC5B,SAAS,SAAS,YAAY;AAC9B,SAAS,SAAS,oBAAoB;AACtC,SAAS,oBAAoB;AAK7B,SAAS,gCAAgC;AACzC;AAAA,EACC;AAAA,EACA;AAAA,OACM;AACP,OAAO,yBAAyB;AAChC,OAAO,kBAAkB;AACzB,OAAO,YAAY;AACnB,SAAS,eAAe;AACxB,OAAO,iBAAiB;AACxB,SAAS,sBAAsB;AAC/B,OAAO,uBAAuB;AAuH3B,SA0CC,UA1CD,KA0CC,YA1CD;AArHH,IAAM,sBAAsB,CAAE,OAAQ;AAEtC,SAAS,UAAW;AAAA,EACnB,YAAY;AAAA,EACZ;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACD,GAAI;AACH,QAAM,cAAc,OAAO;AAC3B,QAAM,EAAE,IAAI,UAAU,QAAQ,KAAK,QAAQ,OAAO,OAAO,IAAI;AAC7D,QAAM,QAAQ,eAAgB,UAAW;AAQzC,QAAM,cACL,SAAS,SAAS,GAAI,KAAM,MAAO,MAAO,KAAK;AAChD,QAAM,CAAE,cAAc,eAAgB,IAAI,S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,KACD;AAEF;AAEA,IAAO,eAAQ;",
4
+ "sourcesContent": ["/**\n * External dependencies\n */\nimport clsx from 'clsx';\n\n/**\n * WordPress dependencies\n */\nimport { isBlobURL } from '@wordpress/blob';\nimport {\n\tSpinner,\n\tPlaceholder,\n\t__experimentalToolsPanel as ToolsPanel,\n} from '@wordpress/components';\nimport {\n\tBlockControls,\n\tBlockIcon,\n\tInspectorControls,\n\tMediaPlaceholder,\n\tMediaReplaceFlow,\n\tuseBlockProps,\n\tuseBlockEditingMode,\n} from '@wordpress/block-editor';\nimport { useRef, useEffect, useState } from '@wordpress/element';\nimport { __ } from '@wordpress/i18n';\nimport { useDispatch } from '@wordpress/data';\nimport { video as icon } from '@wordpress/icons';\nimport { store as noticesStore } from '@wordpress/notices';\nimport { prependHTTPS } from '@wordpress/url';\n\n/**\n * Internal dependencies\n */\nimport { createUpgradedEmbedBlock } from '../embed/util';\nimport {\n\tuseUploadMediaFromBlobURL,\n\tuseToolsPanelDropdownMenuProps,\n} from '../utils/hooks';\nimport VideoCommonSettings from './edit-common-settings';\nimport TracksEditor from './tracks-editor';\nimport Tracks from './tracks';\nimport { Caption } from '../utils/caption';\nimport PosterImage from '../utils/poster-image';\nimport { isGifVariation } from './variations';\n\nconst ALLOWED_MEDIA_TYPES = [ 'video' ];\n\nfunction VideoEdit( {\n\tisSelected: isSingleSelected,\n\tattributes,\n\tclassName,\n\tsetAttributes,\n\tinsertBlocksAfter,\n\tonReplace,\n} ) {\n\tconst videoPlayer = useRef();\n\tconst { id, controls, poster, src, tracks, width, height } = attributes;\n\tconst isGif = isGifVariation( attributes );\n\t// Give the <video> an explicit (non-`auto`) aspect ratio derived from the\n\t// stored dimensions. The width/height attributes alone only yield\n\t// `aspect-ratio: auto W/H`, whose `auto` keyword defers to the element's\n\t// natural ratio while the poster/metadata load - during which Chrome briefly\n\t// computes a runaway height (tens of thousands of pixels) before settling.\n\t// That spike is what reads as a duplicated image during the GIF-to-video\n\t// swap. A non-`auto` ratio governs the box height throughout the load.\n\tconst aspectRatio =\n\t\twidth && height ? `${ width } / ${ height }` : undefined;\n\tconst [ temporaryURL, setTemporaryURL ] = useState( attributes.blob );\n\tconst dropdownMenuProps = useToolsPanelDropdownMenuProps();\n\tconst blockEditingMode = useBlockEditingMode();\n\tconst hasNonContentControls = blockEditingMode === 'default';\n\n\tuseUploadMediaFromBlobURL( {\n\t\turl: temporaryURL,\n\t\tallowedTypes: ALLOWED_MEDIA_TYPES,\n\t\tonChange: onSelectVideo,\n\t\tonError: onUploadError,\n\t} );\n\n\tuseEffect( () => {\n\t\t// Placeholder may be rendered.\n\t\tif ( videoPlayer.current ) {\n\t\t\tvideoPlayer.current.load();\n\t\t}\n\t}, [ poster ] );\n\n\t// The GIF variation plays like an animated GIF in the editor (the playback\n\t// attributes are applied to the preview <video> below). Regular videos do\n\t// not autoplay in the editor, so only nudge GIFs into playing after a\n\t// source change in case the muted autoplay did not start on its own.\n\tuseEffect( () => {\n\t\tif ( isGif ) {\n\t\t\t// Browsers allow muted videos to be played programmatically.\n\t\t\tvideoPlayer.current?.play().catch( () => {} );\n\t\t}\n\t}, [ isGif, src, poster ] );\n\n\t// TODO: Whether the video was obtained from the media library or was provided by URL, obtain the `videoWidth` and `videoHeight` of the video once its metadata has loaded and persist in the block attributes.\n\tfunction onSelectVideo( media ) {\n\t\tif ( ! media || ! media.url ) {\n\t\t\t// In this case there was an error\n\t\t\t// previous attributes should be removed\n\t\t\t// because they may be temporary blob urls.\n\t\t\tsetAttributes( {\n\t\t\t\tsrc: undefined,\n\t\t\t\tid: undefined,\n\t\t\t\tposter: undefined,\n\t\t\t\tcaption: undefined,\n\t\t\t\tblob: undefined,\n\t\t\t} );\n\t\t\tsetTemporaryURL();\n\t\t\treturn;\n\t\t}\n\n\t\tif ( isBlobURL( media.url ) ) {\n\t\t\tsetTemporaryURL( media.url );\n\t\t\treturn;\n\t\t}\n\n\t\t// Sets the block's attribute and updates the edit component from the\n\t\t// selected media.\n\t\tsetAttributes( {\n\t\t\tblob: undefined,\n\t\t\tsrc: media.url,\n\t\t\tid: media.id,\n\t\t\tposter:\n\t\t\t\tmedia.image?.src !== media.icon ? media.image?.src : undefined,\n\t\t\tcaption: media.caption,\n\t\t} );\n\t\tsetTemporaryURL();\n\t}\n\n\tfunction onSelectURL( newSrc ) {\n\t\tif ( newSrc !== src ) {\n\t\t\tconst url = prependHTTPS( newSrc );\n\t\t\t// Check if there's an embed block that handles this URL.\n\t\t\tconst embedBlock = createUpgradedEmbedBlock( {\n\t\t\t\tattributes: { url },\n\t\t\t} );\n\t\t\tif ( undefined !== embedBlock && onReplace ) {\n\t\t\t\tonReplace( embedBlock );\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tsetAttributes( {\n\t\t\t\tblob: undefined,\n\t\t\t\tsrc: url,\n\t\t\t\tid: undefined,\n\t\t\t\tposter: undefined,\n\t\t\t} );\n\t\t\tsetTemporaryURL();\n\t\t}\n\t}\n\n\tconst { createErrorNotice } = useDispatch( noticesStore );\n\tfunction onUploadError( message ) {\n\t\tcreateErrorNotice( message, { type: 'snackbar' } );\n\t}\n\n\t// Much of this description is duplicated from MediaPlaceholder.\n\tconst placeholder = ( content ) => {\n\t\treturn (\n\t\t\t<Placeholder\n\t\t\t\tclassName=\"block-editor-media-placeholder\"\n\t\t\t\twithIllustration={ ! isSingleSelected }\n\t\t\t\ticon={ icon }\n\t\t\t\tlabel={ __( 'Video' ) }\n\t\t\t\tinstructions={ __(\n\t\t\t\t\t'Drag and drop a video, upload, or choose from your library.'\n\t\t\t\t) }\n\t\t\t>\n\t\t\t\t{ content }\n\t\t\t</Placeholder>\n\t\t);\n\t};\n\n\tconst classes = clsx( className, {\n\t\t'is-transient': !! temporaryURL,\n\t} );\n\n\tconst blockProps = useBlockProps( {\n\t\tclassName: classes,\n\t} );\n\n\tif ( ! src && ! temporaryURL ) {\n\t\treturn (\n\t\t\t<div { ...blockProps }>\n\t\t\t\t<MediaPlaceholder\n\t\t\t\t\ticon={ <BlockIcon icon={ icon } /> }\n\t\t\t\t\tonSelect={ onSelectVideo }\n\t\t\t\t\tonSelectURL={ onSelectURL }\n\t\t\t\t\taccept=\"video/*\"\n\t\t\t\t\tallowedTypes={ ALLOWED_MEDIA_TYPES }\n\t\t\t\t\tvalue={ attributes }\n\t\t\t\t\tonError={ onUploadError }\n\t\t\t\t\tplaceholder={ placeholder }\n\t\t\t\t/>\n\t\t\t</div>\n\t\t);\n\t}\n\n\treturn (\n\t\t<>\n\t\t\t{ isSingleSelected && (\n\t\t\t\t<>\n\t\t\t\t\t<BlockControls>\n\t\t\t\t\t\t<TracksEditor\n\t\t\t\t\t\t\ttracks={ tracks }\n\t\t\t\t\t\t\tonChange={ ( newTracks ) => {\n\t\t\t\t\t\t\t\tsetAttributes( { tracks: newTracks } );\n\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t/>\n\t\t\t\t\t</BlockControls>\n\t\t\t\t\t<BlockControls group=\"other\">\n\t\t\t\t\t\t<MediaReplaceFlow\n\t\t\t\t\t\t\tmediaId={ id }\n\t\t\t\t\t\t\tmediaURL={ src }\n\t\t\t\t\t\t\tallowedTypes={ ALLOWED_MEDIA_TYPES }\n\t\t\t\t\t\t\taccept=\"video/*\"\n\t\t\t\t\t\t\tonSelect={ onSelectVideo }\n\t\t\t\t\t\t\tonSelectURL={ onSelectURL }\n\t\t\t\t\t\t\tonError={ onUploadError }\n\t\t\t\t\t\t\tonReset={ () => onSelectVideo( undefined ) }\n\t\t\t\t\t\t\tvariant=\"toolbar\"\n\t\t\t\t\t\t/>\n\t\t\t\t\t</BlockControls>\n\t\t\t\t</>\n\t\t\t) }\n\t\t\t<InspectorControls>\n\t\t\t\t<ToolsPanel\n\t\t\t\t\tlabel={ __( 'Settings' ) }\n\t\t\t\t\tresetAll={ () => {\n\t\t\t\t\t\tsetAttributes( {\n\t\t\t\t\t\t\tautoplay: false,\n\t\t\t\t\t\t\tcontrols: true,\n\t\t\t\t\t\t\tloop: false,\n\t\t\t\t\t\t\tmuted: false,\n\t\t\t\t\t\t\tplaysInline: false,\n\t\t\t\t\t\t\tpreload: 'metadata',\n\t\t\t\t\t\t\tposter: undefined,\n\t\t\t\t\t\t} );\n\t\t\t\t\t} }\n\t\t\t\t\tdropdownMenuProps={ dropdownMenuProps }\n\t\t\t\t>\n\t\t\t\t\t<VideoCommonSettings\n\t\t\t\t\t\tsetAttributes={ setAttributes }\n\t\t\t\t\t\tattributes={ attributes }\n\t\t\t\t\t/>\n\t\t\t\t\t<PosterImage\n\t\t\t\t\t\tposter={ poster }\n\t\t\t\t\t\tonChange={ ( posterImage ) =>\n\t\t\t\t\t\t\tsetAttributes( {\n\t\t\t\t\t\t\t\tposter: posterImage?.url,\n\t\t\t\t\t\t\t} )\n\t\t\t\t\t\t}\n\t\t\t\t\t/>\n\t\t\t\t</ToolsPanel>\n\t\t\t</InspectorControls>\n\t\t\t<figure { ...blockProps }>\n\t\t\t\t<video\n\t\t\t\t\tcontrols={ controls }\n\t\t\t\t\tinert={ ! isSingleSelected ? 'true' : undefined }\n\t\t\t\t\tposter={ poster }\n\t\t\t\t\tsrc={ src || temporaryURL }\n\t\t\t\t\tref={ videoPlayer }\n\t\t\t\t\tautoPlay={ isGif }\n\t\t\t\t\tloop={ isGif }\n\t\t\t\t\tmuted={ isGif }\n\t\t\t\t\tplaysInline={ isGif }\n\t\t\t\t\twidth={ width }\n\t\t\t\t\theight={ height }\n\t\t\t\t\tstyle={ aspectRatio ? { aspectRatio } : undefined }\n\t\t\t\t>\n\t\t\t\t\t<Tracks tracks={ tracks } />\n\t\t\t\t</video>\n\t\t\t\t{ !! temporaryURL && <Spinner /> }\n\t\t\t\t<Caption\n\t\t\t\t\tattributes={ attributes }\n\t\t\t\t\tsetAttributes={ setAttributes }\n\t\t\t\t\tisSelected={ isSingleSelected }\n\t\t\t\t\tinsertBlocksAfter={ insertBlocksAfter }\n\t\t\t\t\tlabel={ __( 'Video caption text' ) }\n\t\t\t\t\tshowToolbarButton={\n\t\t\t\t\t\tis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