@panphora/clayjs 1.24.0 → 1.25.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 (209) hide show
  1. package/dist/all.js +1 -1
  2. package/dist/clay-dom.js +1 -1
  3. package/dist/clay-events.js +1 -1
  4. package/dist/clay-internals.js +1 -1
  5. package/dist/clay-options.js +1 -1
  6. package/dist/clay-router.js +1 -1
  7. package/dist/clay-ui.js +1 -1
  8. package/dist/clay-utils.js +1 -1
  9. package/dist/clay.js +1 -1
  10. package/dist/clay.standalone.js +16610 -14400
  11. package/dist/m/attrs/{refetch-on-save-DPGJJMGN.js → refetch-on-save-5CBFUJUF.js} +1 -1
  12. package/dist/m/attrs/save-freeze-MH3AOD56.js +1 -0
  13. package/dist/m/c-277QP5ET.js +1 -0
  14. package/dist/m/{c-SXGEWPFC.js → c-3E2IK5HU.js} +1 -1
  15. package/dist/m/{c-A4L7APIU.js → c-4AE2A2LK.js} +1 -1
  16. package/dist/m/{c-DZPO22O3.js → c-4Q6QIODW.js} +1 -1
  17. package/dist/m/{c-RO73MKKR.js → c-52OC3OH3.js} +1 -1
  18. package/dist/m/{c-VNAYHV2J.js → c-5PZYDWTW.js} +1 -1
  19. package/dist/m/c-5Q5XBN56.js +1 -0
  20. package/dist/m/c-5SZ6KFR5.js +1 -0
  21. package/dist/m/{c-ZRGEN6QQ.js → c-AI3H6ETU.js} +2 -2
  22. package/dist/m/{c-7V6MGMX2.js → c-BCWYEG6P.js} +1 -1
  23. package/dist/m/{c-A7N5TNSL.js → c-BJ2RRQBQ.js} +1 -1
  24. package/dist/m/{c-CTGRDT6E.js → c-C6YZNU6E.js} +1 -1
  25. package/dist/m/{c-DLBX4JCJ.js → c-C7SUMNMI.js} +1 -1
  26. package/dist/m/c-CITLTVQ4.js +4 -0
  27. package/dist/m/{c-TWOXQQKV.js → c-CL5LSATX.js} +1 -1
  28. package/dist/m/c-CU33V6RW.js +4 -0
  29. package/dist/m/{c-2R4OBWIP.js → c-D62HRSZK.js} +1 -1
  30. package/dist/m/{c-DD26VXAP.js → c-DT7E76Z2.js} +1 -1
  31. package/dist/m/{c-54ZZZYUN.js → c-EAV7A6BT.js} +1 -1
  32. package/dist/m/{c-RBPZNU2D.js → c-EQ5NBOGA.js} +1 -1
  33. package/dist/m/{c-KQKKIVLW.js → c-FBOO2UY3.js} +1 -1
  34. package/dist/m/{c-RTSRGGTP.js → c-FJDTDGDA.js} +1 -1
  35. package/dist/m/{c-MQKSKQHG.js → c-FKTALXNV.js} +1 -1
  36. package/dist/m/{c-GNIVHLEJ.js → c-GDNZEOOZ.js} +1 -1
  37. package/dist/m/{c-SUXHUL7U.js → c-GEAG5XAK.js} +1 -1
  38. package/dist/m/{c-UM7VZDTW.js → c-GY4BREDT.js} +1 -1
  39. package/dist/m/{c-4PO3YGDC.js → c-HGG7M2S3.js} +1 -1
  40. package/dist/m/c-HKSLOVU4.js +1 -0
  41. package/dist/m/{c-KJHVB2KG.js → c-HXGNH6GY.js} +1 -1
  42. package/dist/m/{c-FLEIU6CG.js → c-IESDKFO6.js} +1 -1
  43. package/dist/m/{c-SNVDWMM3.js → c-IJHF4IO6.js} +1 -1
  44. package/dist/m/{c-SGGGCIVD.js → c-IL5IVTOG.js} +1 -1
  45. package/dist/m/c-JB5YU57S.js +1 -0
  46. package/dist/m/{c-MP6S4AZU.js → c-JD2VFAYG.js} +2 -2
  47. package/dist/m/{c-CV4T65JE.js → c-JWW6BHWD.js} +3 -3
  48. package/dist/m/{c-GM7OA6EJ.js → c-K4M76VPM.js} +1 -1
  49. package/dist/m/{c-RXTPKCMC.js → c-KU3PX7LL.js} +1 -1
  50. package/dist/m/{c-2PVGJFI5.js → c-KYTVZT4D.js} +1 -1
  51. package/dist/m/{c-RJKKRWHW.js → c-M7ITYKMF.js} +1 -1
  52. package/dist/m/c-MFB74XVN.js +3 -0
  53. package/dist/m/c-MOP5KBWZ.js +1 -0
  54. package/dist/m/{c-YB3CDTDZ.js → c-MUM53J5J.js} +1 -1
  55. package/dist/m/{c-YK2L436K.js → c-MV7TEUTD.js} +1 -1
  56. package/dist/m/{c-LA2BW7UY.js → c-MZCOGNZL.js} +1 -1
  57. package/dist/m/{c-YGGO2G2L.js → c-N4GEJMXW.js} +1 -1
  58. package/dist/m/{c-NQAPWM7O.js → c-NADLYVAH.js} +1 -1
  59. package/dist/m/{c-RS77ODLY.js → c-NL4I4KNG.js} +1 -1
  60. package/dist/m/{c-6UPEKW6O.js → c-O2QZDVZ2.js} +1 -1
  61. package/dist/m/{c-LTSPHVAK.js → c-OBMZASYQ.js} +1 -1
  62. package/dist/m/{c-LUXAB2XI.js → c-ORLPQFNU.js} +1 -1
  63. package/dist/m/c-P73XPAOA.js +1 -0
  64. package/dist/m/{c-PWJSJEJU.js → c-PNZIJFG7.js} +1 -1
  65. package/dist/m/{c-ZKKAF4UT.js → c-PRZNJUYZ.js} +2 -2
  66. package/dist/m/{c-Q6VNQDJE.js → c-Q2CB57UG.js} +1 -1
  67. package/dist/m/{c-TWCXBWS3.js → c-QCDVDZIR.js} +1 -1
  68. package/dist/m/{c-P5NKFRL4.js → c-QDVG4NAZ.js} +1 -1
  69. package/dist/m/c-QWB53KRW.js +1 -0
  70. package/dist/m/{c-GNI7WHKF.js → c-RGAALCDU.js} +1 -1
  71. package/dist/m/c-RHPHMTF2.js +2 -0
  72. package/dist/m/{c-BULK5J4M.js → c-RWJ3OSCP.js} +1 -1
  73. package/dist/m/{c-5FXEKU4Y.js → c-SEVOS4UE.js} +1 -1
  74. package/dist/m/{c-PMRRMT72.js → c-SFYTKRU7.js} +1 -1
  75. package/dist/m/{c-47IBJGPQ.js → c-SFZRY6RT.js} +1 -1
  76. package/dist/m/{c-QENKN7QI.js → c-SGG6MUXW.js} +1 -1
  77. package/dist/m/c-SMLAJASY.js +1 -0
  78. package/dist/m/{c-VSEUFJAO.js → c-SUAC5RSG.js} +1 -1
  79. package/dist/m/{c-6RGEQNVV.js → c-SXZYVXD6.js} +1 -1
  80. package/dist/m/{c-ZFO5RW6G.js → c-TCFVG3I4.js} +1 -1
  81. package/dist/m/{c-PZRWZZRO.js → c-TLQINES7.js} +2 -2
  82. package/dist/m/c-U4TWEIKZ.js +1 -0
  83. package/dist/m/{c-FZRZPIFS.js → c-U65PREMC.js} +1 -1
  84. package/dist/m/{c-7YETSAVY.js → c-U7F66I64.js} +1 -1
  85. package/dist/m/{c-WOELSNWS.js → c-UD4VDBGJ.js} +1 -1
  86. package/dist/m/{c-VI3BJHCM.js → c-V2FPBRO6.js} +1 -1
  87. package/dist/m/{c-2OIKXOY6.js → c-V4B3RUWB.js} +1 -1
  88. package/dist/m/{c-O5ARALMJ.js → c-V5L6HWVL.js} +1 -1
  89. package/dist/m/c-VMXCX52Q.js +1 -0
  90. package/dist/m/{c-PVJMJL3P.js → c-VO6RSFCO.js} +1 -1
  91. package/dist/m/c-WDFQ7PBU.js +1 -0
  92. package/dist/m/{c-OG6GFSUX.js → c-WGQVSKKC.js} +1 -1
  93. package/dist/m/c-WSTUCBHV.js +1 -0
  94. package/dist/m/{c-EY5KDUZF.js → c-WVCT3ITX.js} +1 -1
  95. package/dist/m/{c-SE3SIY7Y.js → c-X3V4RWMA.js} +1 -1
  96. package/dist/m/{c-HIX5H5L7.js → c-XHZIKRCV.js} +1 -1
  97. package/dist/m/{c-2BLVA6IN.js → c-XQTERKQA.js} +1 -1
  98. package/dist/m/{c-A5ZBFICF.js → c-YFO6ZJLQ.js} +1 -1
  99. package/dist/m/{c-PD5AKHY3.js → c-YX2MC7YL.js} +1 -1
  100. package/dist/m/{c-OYHI67B6.js → c-YYGUHSZR.js} +1 -1
  101. package/dist/m/{c-YYMZWQLR.js → c-Z2OZFX3N.js} +1 -1
  102. package/dist/m/{c-AT7GLQGV.js → c-ZEA3DCG3.js} +1 -1
  103. package/dist/m/{c-75N3KG35.js → c-ZJG6C2WL.js} +1 -1
  104. package/dist/m/{c-FVPNX2GO.js → c-ZORVIXUR.js} +1 -1
  105. package/dist/m/{c-FV46ZKGX.js → c-ZPI7M5U5.js} +1 -1
  106. package/dist/m/core/{admin-attrs-5UGMYCKW.js → admin-attrs-ZI6K6UGM.js} +1 -1
  107. package/dist/m/core/{autosave-4P66VXX7.js → autosave-BSM2ABJL.js} +1 -1
  108. package/dist/m/core/{conflict-notice-BAR23OWH.js → conflict-notice-7EQLDYPA.js} +1 -1
  109. package/dist/m/core/draft-mode-M5XNYBMY.js +1 -0
  110. package/dist/m/core/{host-permission-3HE4CFD6.js → host-permission-5BYP24GC.js} +1 -1
  111. package/dist/m/core/{is-edit-mode-GK7IFFMT.js → is-edit-mode-73OXKK5H.js} +1 -1
  112. package/dist/m/core/{persist-AIJGTKKI.js → persist-2SZO3PCE.js} +1 -1
  113. package/dist/m/core/{recovery-LPB6X72P.js → recovery-VZF7RJZF.js} +1 -1
  114. package/dist/m/core/{save-FV4ZCKBI.js → save-K6Q47J2X.js} +1 -1
  115. package/dist/m/core/{save-core-K7XFAWQ4.js → save-core-U3Z44XBO.js} +1 -1
  116. package/dist/m/core/{site-edits-TEQORBJU.js → site-edits-CFMF6GHD.js} +1 -1
  117. package/dist/m/core/{snapshot-FJP5IJL3.js → snapshot-PWCHYFL6.js} +1 -1
  118. package/dist/m/core/unsaved-warning-2WRZLJH5.js +1 -0
  119. package/dist/m/events/{index-B6TGDYMG.js → index-YKQIBZE5.js} +1 -1
  120. package/dist/m/internals/index-FSLC4M7J.js +1 -0
  121. package/dist/m/lib/{cache-bust-NH7VBWHO.js → cache-bust-BL4KUQAJ.js} +1 -1
  122. package/dist/m/loader-RC54UV7H.js +1 -0
  123. package/dist/m/manifest-3B84C829.js +1 -0
  124. package/dist/m/manifest-edit-1CB79AD4.js +1 -0
  125. package/dist/m/manifest.json +1215 -1129
  126. package/dist/m/options/{options-55LQHSJ4.js → options-LKIZ7YTG.js} +1 -1
  127. package/dist/m/page/{editor-KAZDJNND.js → editor-PKSPJ2XJ.js} +2 -2
  128. package/dist/m/plugins/{ai-edit-CUKQQWJX.js → ai-edit-3LG6MGS3.js} +1 -1
  129. package/dist/m/plugins/{cms-JANMGPHM.js → cms-T2HLI7JG.js} +16 -16
  130. package/dist/m/plugins/{demo-JIR7DXJA.js → demo-LMCMBILC.js} +1 -1
  131. package/dist/m/plugins/{derive-QVI3LI3A.js → derive-7DR5TUDH.js} +1 -1
  132. package/dist/m/plugins/{indicator-DAKZGAWI.js → indicator-CTKX4EY7.js} +1 -1
  133. package/dist/m/plugins/{live-UAJGWRNP.js → live-IFLL6YN5.js} +1 -1
  134. package/dist/m/plugins/{menu-BFJ644YX.js → menu-YJZ3JWBC.js} +1 -1
  135. package/dist/m/plugins/page-GTDPYGE4.js +2 -0
  136. package/dist/m/plugins/{page-view-OYN7Z5TS.js → page-view-NMCCU6MF.js} +1 -1
  137. package/dist/m/plugins/{people-VBDR5Y22.js → people-6WIWCZEG.js} +1 -1
  138. package/dist/m/plugins/{richclay-CBLZRFB4.js → richclay-L3BZMX4I.js} +3 -3
  139. package/dist/m/plugins/sortable-365SRRL3.js +1 -0
  140. package/dist/m/plugins/{source-ZXDD7F6X.js → source-7LSGOV46.js} +1 -1
  141. package/dist/m/plugins/{undo-5JI5G7CQ.js → undo-UES4KS7B.js} +1 -1
  142. package/dist/m/plugins/{upgrade-6B6QS3NR.js → upgrade-MMPZUCDM.js} +1 -1
  143. package/dist/m/plugins/{upload-DNJNW6H3.js → upload-NZET3DNQ.js} +1 -1
  144. package/dist/m/plugins/visitor-drafts-V5YB7XDH.js +20 -0
  145. package/dist/m/plugins/{visitor-drafts-owner-VIAZC3CF.js → visitor-drafts-owner-TLECTYWS.js} +1 -1
  146. package/dist/m/plugins/{visitor-menu-ZHKWIKKY.js → visitor-menu-QDV2MYJN.js} +1 -1
  147. package/dist/m/plugins/wire-3YGUO3GE.js +1 -0
  148. package/dist/m/{reader-core-F6RY3V64.js → reader-core-VR7EL4WV.js} +2 -2
  149. package/dist/m/sync/live-sync-XMXXZS3G.js +1 -0
  150. package/dist/m/vendor/sap-core.vendor-JANUQULT.js +7 -0
  151. package/dist/offline-manifest.json +724 -664
  152. package/docs/guide.md +1 -0
  153. package/entries/clay-data.js +1 -1
  154. package/entries/sap.js +6 -5
  155. package/package.json +2 -2
  156. package/src/core/draft-mode.js +11 -0
  157. package/src/core/save-core.js +16 -17
  158. package/src/core/save.js +1 -1
  159. package/src/core/unsaved-warning.js +2 -2
  160. package/src/lib/dirty-gate.js +19 -0
  161. package/src/lib/idb-error-code.js +20 -0
  162. package/src/loader.js +2 -0
  163. package/src/plugins/menu/visitor.js +33 -1
  164. package/src/plugins/page.js +19 -5
  165. package/src/plugins/sortable.js +7 -0
  166. package/src/plugins/visitor-drafts/commit.js +350 -0
  167. package/src/plugins/visitor-drafts/idb.js +227 -0
  168. package/src/plugins/visitor-drafts/prompt.js +23 -3
  169. package/src/plugins/visitor-drafts/recovery-menu.js +118 -0
  170. package/src/plugins/visitor-drafts/recovery.js +64 -0
  171. package/src/plugins/visitor-drafts/session.js +393 -0
  172. package/src/plugins/visitor-drafts/store.js +247 -27
  173. package/src/plugins/visitor-drafts.js +177 -28
  174. package/src/sync/live-sync.js +1 -1
  175. package/src/sync/wire-profile.js +9 -4
  176. package/src/vendor/hyper-html-api-data.vendor.js +1 -1
  177. package/src/vendor/hyper-html-api-upgrade.vendor.js +2 -2
  178. package/src/vendor/hypercms.vendor.js +16 -16
  179. package/src/vendor/richclay.vendor.js +1 -1
  180. package/src/vendor/sap-core.vendor.js +6 -5
  181. package/src/vendor/sap-ownership.vendor.js +181 -11
  182. package/tool-generation/system.md +1 -1
  183. package/dist/m/attrs/save-freeze-JZHKRQLR.js +0 -1
  184. package/dist/m/c-234RSEIW.js +0 -1
  185. package/dist/m/c-2YIJ6ZA6.js +0 -1
  186. package/dist/m/c-H2H7TI6O.js +0 -1
  187. package/dist/m/c-HSNGLIFB.js +0 -3
  188. package/dist/m/c-JMDKPBMC.js +0 -4
  189. package/dist/m/c-LO4C4J77.js +0 -1
  190. package/dist/m/c-N7JPUPGC.js +0 -1
  191. package/dist/m/c-NEXFVJIT.js +0 -1
  192. package/dist/m/c-R23UHMXG.js +0 -1
  193. package/dist/m/c-T527QHOB.js +0 -1
  194. package/dist/m/c-V2U3F4QX.js +0 -1
  195. package/dist/m/c-VG5XIN4T.js +0 -1
  196. package/dist/m/c-YINHPF4V.js +0 -1
  197. package/dist/m/core/draft-mode-WSQAT67S.js +0 -1
  198. package/dist/m/core/unsaved-warning-FF63QGKI.js +0 -1
  199. package/dist/m/internals/index-AX4CG7B2.js +0 -1
  200. package/dist/m/loader-5IA5OJ3J.js +0 -1
  201. package/dist/m/manifest-98258645.js +0 -1
  202. package/dist/m/manifest-edit-ABF56000.js +0 -1
  203. package/dist/m/plugins/page-ZBIYHGK4.js +0 -2
  204. package/dist/m/plugins/sortable-HDOQ6GAC.js +0 -1
  205. package/dist/m/plugins/visitor-drafts-A5FDQ2G7.js +0 -20
  206. package/dist/m/plugins/wire-XOT7XKJL.js +0 -1
  207. package/dist/m/sync/live-sync-M2PP2IWY.js +0 -1
  208. package/dist/m/vendor/sap-core.vendor-OA5SKL7Q.js +0 -6
  209. /package/dist/m/plugins/{richclay-CBLZRFB4.js.LEGAL.txt → richclay-L3BZMX4I.js.LEGAL.txt} +0 -0
@@ -21,7 +21,7 @@ var richclay=(()=>{var kn=Object.defineProperty;var ds=Object.getOwnPropertyDesc
21
21
  `)),i.appendChild(D(o))}let s=new re(i,4);for(;o=s.nextNode();)o.data=o.data.replace(/ /g," ");return i.normalize(),$(_("PRE",this._config.tagAttributes.pre,[i]))},e),this.focus()):this.changeFormat({tag:"CODE",attributes:this._config.tagAttributes.code},null,e),this}removeCode(){let e=this.getSelection(),t=e.commonAncestorContainer;return w(t,this._root,"PRE")?(this.modifyBlocks(n=>{let i=this._root,r=n.querySelectorAll("PRE"),o=r.length;for(;o--;){let s=r[o],a=new re(s,4),l;for(;l=a.nextNode();){let h=l.data;h=h.replace(/ (?= )/g,"\xA0");let d=document.createDocumentFragment(),u;for(;(u=h.indexOf(`
22
22
  `))>-1;)d.appendChild(document.createTextNode(h.slice(0,u))),d.appendChild(_("BR")),h=h.slice(u+1);l.parentNode.insertBefore(d,l),l.data=h}ge(s,i),Y(s,D(s))}return n},e),this.focus()):this.changeFormat(null,{tag:"CODE"},e),this}toggleCode(){return this.hasFormat("PRE")||this.hasFormat("CODE")?this.removeCode():this.code(),this}_removeFormatting(e,t){for(let n=e.firstChild,i;n;n=i){if(i=n.nextSibling,L(n)){if(n instanceof Text||n.nodeName==="BR"||n.nodeName==="IMG"){t.appendChild(n);continue}}else if(xe(n)){t.appendChild(this.createDefaultBlock([this._removeFormatting(n,document.createDocumentFragment())]));continue}this._removeFormatting(n,t)}return t}removeAllFormatting(e){if(e||(e=this.getSelection()),e.collapsed)return this.focus();let t=this._root,n=e.commonAncestorContainer;for(;n&&n!==t&&!xe(n);)n=n.parentNode;if(n||(nr(e,t),n=t),n instanceof Text)return this.focus();this.saveUndoState(e),He(e,n,n,t);let i=e.startContainer,r=e.startOffset,o=e.endContainer,s=e.endOffset,a=document.createDocumentFragment(),l=document.createDocumentFragment(),h=le(o,s,n,t),d=le(i,r,n,t),u;for(;d!==h;)u=d.nextSibling,a.appendChild(d),d=u;if(this._removeFormatting(a,l),l.normalize(),d=l.firstChild,u=l.lastChild,d){n.insertBefore(l,h);let p=Array.from(n.childNodes);r=p.indexOf(d),s=u?p.indexOf(u)+1:0}else h&&(r=Array.from(n.childNodes).indexOf(h),s=r);return e.setStart(n,r),e.setEnd(n,s),Xe(n,e),X(e),this.setSelection(e),this._updatePath(e,!0),this.focus()}},vr=Js;function Sr(e,t){(t==null||t>e.length)&&(t=e.length);for(var n=0,i=Array(t);n<t;n++)i[n]=e[n];return i}function ea(e){if(Array.isArray(e))return e}function ta(e,t){var n=e==null?null:typeof Symbol<"u"&&e[Symbol.iterator]||e["@@iterator"];if(n!=null){var i,r,o,s,a=[],l=!0,h=!1;try{if(o=(n=n.call(e)).next,t!==0)for(;!(l=(i=o.call(n)).done)&&(a.push(i.value),a.length!==t);l=!0);}catch(d){h=!0,r=d}finally{try{if(!l&&n.return!=null&&(s=n.return(),Object(s)!==s))return}finally{if(h)throw r}}return a}}function na(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
23
23
  In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function ia(e,t){return ea(e)||ta(e,t)||ra(e,t)||na()}function ra(e,t){if(e){if(typeof e=="string")return Sr(e,t);var n={}.toString.call(e).slice(8,-1);return n==="Object"&&e.constructor&&(n=e.constructor.name),n==="Map"||n==="Set"?Array.from(e):n==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?Sr(e,t):void 0}}var Br=Object.entries,Ar=Object.setPrototypeOf,oa=Object.isFrozen,sa=Object.getPrototypeOf,aa=Object.getOwnPropertyDescriptor,j=Object.freeze,Z=Object.seal,tt=Object.create,Hr=typeof Reflect<"u"&&Reflect,jn=Hr.apply,Zn=Hr.construct;j||(j=function(t){return t});Z||(Z=function(t){return t});jn||(jn=function(t,n){for(var i=arguments.length,r=new Array(i>2?i-2:0),o=2;o<i;o++)r[o-2]=arguments[o];return t.apply(n,r)});Zn||(Zn=function(t){for(var n=arguments.length,i=new Array(n>1?n-1:0),r=1;r<n;r++)i[r-1]=arguments[r];return new t(...i)});var yt=F(Array.prototype.forEach),la=F(Array.prototype.lastIndexOf),Cr=F(Array.prototype.pop),et=F(Array.prototype.push),ca=F(Array.prototype.splice),Oe=Array.isArray,_t=F(String.prototype.toLowerCase),Wn=F(String.prototype.toString),Lr=F(String.prototype.match),bt=F(String.prototype.replace),wr=F(String.prototype.indexOf),ha=F(String.prototype.trim),ua=F(Number.prototype.toString),da=F(Boolean.prototype.toString),Nr=typeof BigInt>"u"?null:F(BigInt.prototype.toString),xr=typeof Symbol>"u"?null:F(Symbol.prototype.toString),K=F(Object.prototype.hasOwnProperty),Tt=F(Object.prototype.toString),G=F(RegExp.prototype.test),We=fa(TypeError);function F(e){return function(t){t instanceof RegExp&&(t.lastIndex=0);for(var n=arguments.length,i=new Array(n>1?n-1:0),r=1;r<n;r++)i[r-1]=arguments[r];return jn(e,t,i)}}function fa(e){return function(){for(var t=arguments.length,n=new Array(t),i=0;i<t;i++)n[i]=arguments[i];return Zn(e,n)}}function A(e,t){let n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:_t;if(Ar&&Ar(e,null),!Oe(t))return e;let i=t.length;for(;i--;){let r=t[i];if(typeof r=="string"){let o=n(r);o!==r&&(oa(t)||(t[i]=o),r=o)}e[r]=!0}return e}function pa(e){for(let t=0;t<e.length;t++)K(e,t)||(e[t]=null);return e}function ne(e){let t=tt(null);for(let i of Br(e)){var n=ia(i,2);let r=n[0],o=n[1];K(e,r)&&(Oe(o)?t[r]=pa(o):o&&typeof o=="object"&&o.constructor===Object?t[r]=ne(o):t[r]=o)}return t}function ma(e){switch(typeof e){case"string":return e;case"number":return ua(e);case"boolean":return da(e);case"bigint":return Nr?Nr(e):"0";case"symbol":return xr?xr(e):"Symbol()";case"undefined":return Tt(e);case"function":case"object":{if(e===null)return Tt(e);let t=e,n=be(t,"toString");if(typeof n=="function"){let i=n(t);return typeof i=="string"?i:Tt(i)}return Tt(e)}default:return Tt(e)}}function be(e,t){for(;e!==null;){let i=aa(e,t);if(i){if(i.get)return F(i.get);if(typeof i.value=="function")return F(i.value)}e=sa(e)}function n(){return null}return n}function ga(e){try{return G(e,""),!0}catch{return!1}}var kr=j(["a","abbr","acronym","address","area","article","aside","audio","b","bdi","bdo","big","blink","blockquote","body","br","button","canvas","caption","center","cite","code","col","colgroup","content","data","datalist","dd","decorator","del","details","dfn","dialog","dir","div","dl","dt","element","em","fieldset","figcaption","figure","font","footer","form","h1","h2","h3","h4","h5","h6","head","header","hgroup","hr","html","i","img","input","ins","kbd","label","legend","li","main","map","mark","marquee","menu","menuitem","meter","nav","nobr","ol","optgroup","option","output","p","picture","pre","progress","q","rp","rt","ruby","s","samp","search","section","select","shadow","slot","small","source","spacer","span","strike","strong","style","sub","summary","sup","table","tbody","td","template","textarea","tfoot","th","thead","time","tr","track","tt","u","ul","var","video","wbr"]),$n=j(["svg","a","altglyph","altglyphdef","altglyphitem","animatecolor","animatemotion","animatetransform","circle","clippath","defs","desc","ellipse","enterkeyhint","exportparts","filter","font","g","glyph","glyphref","hkern","image","inputmode","line","lineargradient","marker","mask","metadata","mpath","part","path","pattern","polygon","polyline","radialgradient","rect","stop","style","switch","symbol","text","textpath","title","tref","tspan","view","vkern"]),Kn=j(["feBlend","feColorMatrix","feComponentTransfer","feComposite","feConvolveMatrix","feDiffuseLighting","feDisplacementMap","feDistantLight","feDropShadow","feFlood","feFuncA","feFuncB","feFuncG","feFuncR","feGaussianBlur","feImage","feMerge","feMergeNode","feMorphology","feOffset","fePointLight","feSpecularLighting","feSpotLight","feTile","feTurbulence"]),ya=j(["animate","color-profile","cursor","discard","font-face","font-face-format","font-face-name","font-face-src","font-face-uri","foreignobject","hatch","hatchpath","mesh","meshgradient","meshpatch","meshrow","missing-glyph","script","set","solidcolor","unknown","use"]),Vn=j(["math","menclose","merror","mfenced","mfrac","mglyph","mi","mlabeledtr","mmultiscripts","mn","mo","mover","mpadded","mphantom","mroot","mrow","ms","mspace","msqrt","mstyle","msub","msup","msubsup","mtable","mtd","mtext","mtr","munder","munderover","mprescripts"]),ba=j(["maction","maligngroup","malignmark","mlongdiv","mscarries","mscarry","msgroup","mstack","msline","msrow","semantics","annotation","annotation-xml","mprescripts","none"]),Rr=j(["#text"]),Or=j(["accept","action","align","alt","autocapitalize","autocomplete","autopictureinpicture","autoplay","background","bgcolor","border","capture","cellpadding","cellspacing","checked","cite","class","clear","color","cols","colspan","command","commandfor","controls","controlslist","coords","crossorigin","datetime","decoding","default","dir","disabled","disablepictureinpicture","disableremoteplayback","download","draggable","enctype","enterkeyhint","exportparts","face","for","headers","height","hidden","high","href","hreflang","id","inert","inputmode","integrity","ismap","kind","label","lang","list","loading","loop","low","max","maxlength","media","method","min","minlength","multiple","muted","name","nonce","noshade","novalidate","nowrap","open","optimum","part","pattern","placeholder","playsinline","popover","popovertarget","popovertargetaction","poster","preload","pubdate","radiogroup","readonly","rel","required","rev","reversed","role","rows","rowspan","spellcheck","scope","selected","shape","size","sizes","slot","span","srclang","start","src","srcset","step","style","summary","tabindex","title","translate","type","usemap","valign","value","width","wrap","xmlns"]),Gn=j(["accent-height","accumulate","additive","alignment-baseline","amplitude","ascent","attributename","attributetype","azimuth","basefrequency","baseline-shift","begin","bias","by","class","clip","clippathunits","clip-path","clip-rule","color","color-interpolation","color-interpolation-filters","color-profile","color-rendering","cx","cy","d","dx","dy","diffuseconstant","direction","display","divisor","dur","edgemode","elevation","end","exponent","fill","fill-opacity","fill-rule","filter","filterunits","flood-color","flood-opacity","font-family","font-size","font-size-adjust","font-stretch","font-style","font-variant","font-weight","fx","fy","g1","g2","glyph-name","glyphref","gradientunits","gradienttransform","height","href","id","image-rendering","in","in2","intercept","k","k1","k2","k3","k4","kerning","keypoints","keysplines","keytimes","lang","lengthadjust","letter-spacing","kernelmatrix","kernelunitlength","lighting-color","local","marker-end","marker-mid","marker-start","markerheight","markerunits","markerwidth","maskcontentunits","maskunits","max","mask","mask-type","media","method","mode","min","name","numoctaves","offset","operator","opacity","order","orient","orientation","origin","overflow","paint-order","path","pathlength","patterncontentunits","patterntransform","patternunits","points","preservealpha","preserveaspectratio","primitiveunits","r","rx","ry","radius","refx","refy","repeatcount","repeatdur","restart","result","rotate","scale","seed","shape-rendering","slope","specularconstant","specularexponent","spreadmethod","startoffset","stddeviation","stitchtiles","stop-color","stop-opacity","stroke-dasharray","stroke-dashoffset","stroke-linecap","stroke-linejoin","stroke-miterlimit","stroke-opacity","stroke","stroke-width","style","surfacescale","systemlanguage","tabindex","tablevalues","targetx","targety","transform","transform-origin","text-anchor","text-decoration","text-rendering","textlength","type","u1","u2","unicode","values","viewbox","visibility","version","vert-adv-y","vert-origin-x","vert-origin-y","width","word-spacing","wrap","writing-mode","xchannelselector","ychannelselector","x","x1","x2","xmlns","y","y1","y2","z","zoomandpan"]),Dr=j(["accent","accentunder","align","bevelled","close","columnalign","columnlines","columnspacing","columnspan","denomalign","depth","dir","display","displaystyle","encoding","fence","frame","height","href","id","largeop","length","linethickness","lquote","lspace","mathbackground","mathcolor","mathsize","mathvariant","maxsize","minsize","movablelimits","notation","numalign","open","rowalign","rowlines","rowspacing","rowspan","rspace","rquote","scriptlevel","scriptminsize","scriptsizemultiplier","selection","separator","separators","stretchy","subscriptshift","supscriptshift","symmetric","voffset","width","xmlns"]),Kt=j(["xlink:href","xml:id","xlink:title","xml:space","xmlns:xlink"]),Ta=Z(/{{[\w\W]*|^[\w\W]*}}/g),_a=Z(/<%[\w\W]*|^[\w\W]*%>/g),Ea=Z(/\${[\w\W]*/g),va=Z(/^data-[\-\w.\u00B7-\uFFFF]+$/),Sa=Z(/^aria-[\-\w]+$/),Ir=Z(/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|sms|cid|xmpp|matrix):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i),Aa=Z(/^(?:\w+script|data):/i),Ca=Z(/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g),La=Z(/^html$/i),wa=Z(/^[a-z][.\w]*(-[.\w]+)+$/i),Mr=Z(/<[/\w!]/g),Na=Z(/<[/\w]/g),xa=Z(/<\/no(script|embed|frames)/i),ka=Z(/\/>/i),ye={element:1,attribute:2,text:3,cdataSection:4,entityReference:5,entityNode:6,processingInstruction:7,comment:8,document:9,documentType:10,documentFragment:11,notation:12},Ra=function(){return typeof window>"u"?null:window},Oa=function(t,n){if(typeof t!="object"||typeof t.createPolicy!="function")return null;let i=null,r="data-tt-policy-suffix";n&&n.hasAttribute(r)&&(i=n.getAttribute(r));let o="dompurify"+(i?"#"+i:"");try{return t.createPolicy(o,{createHTML(s){return s},createScriptURL(s){return s}})}catch{return console.warn("TrustedTypes policy "+o+" could not be created."),null}},Pr=function(){return{afterSanitizeAttributes:[],afterSanitizeElements:[],afterSanitizeShadowDOM:[],beforeSanitizeAttributes:[],beforeSanitizeElements:[],beforeSanitizeShadowDOM:[],uponSanitizeAttribute:[],uponSanitizeElement:[],uponSanitizeShadowNode:[]}},Re=function(t,n,i,r){return K(t,n)&&Oe(t[n])?A(r.base?ne(r.base):{},t[n],r.transform):i};function Fr(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:Ra(),t=g=>Fr(g);if(t.version="3.4.11",t.removed=[],!e||!e.document||e.document.nodeType!==ye.document||!e.Element)return t.isSupported=!1,t;let n=e.document,i=n,r=i.currentScript;e.DocumentFragment;let o=e.HTMLTemplateElement,s=e.Node,a=e.Element,l=e.NodeFilter,h=e.NamedNodeMap;h===void 0&&(e.NamedNodeMap||e.MozNamedAttrMap),e.HTMLFormElement;let d=e.DOMParser,u=e.trustedTypes,p=a.prototype,b=be(p,"cloneNode"),y=be(p,"remove"),E=be(p,"nextSibling"),S=be(p,"childNodes"),N=be(p,"parentNode"),P=be(p,"shadowRoot"),J=be(p,"attributes"),U=s&&s.prototype?be(s.prototype,"nodeType"):null,he=s&&s.prototype?be(s.prototype,"nodeName"):null;if(typeof o=="function"){let g=n.createElement("template");g.content&&g.content.ownerDocument&&(n=g.content.ownerDocument)}let ie,Ie="",un,Ai=!1,lt=0,Ci=function(){if(lt>0)throw We('A configured TRUSTED_TYPES_POLICY callback (createHTML or createScriptURL) must not call DOMPurify.sanitize, as that causes infinite recursion. Do not pass a policy whose callbacks wrap DOMPurify as TRUSTED_TYPES_POLICY; see the "DOMPurify and Trusted Types" section of the README.')},Ke=function(c){Ci(),lt++;try{return ie.createHTML(c)}finally{lt--}},Ho=function(c){Ci(),lt++;try{return ie.createScriptURL(c)}finally{lt--}},Fo=function(){return Ai||(un=Oa(u,r),Ai=!0),un},kt=n,dn=kt.implementation,Li=kt.createNodeIterator,Uo=kt.createDocumentFragment,zo=kt.getElementsByTagName,qo=i.importNode,M=Pr();t.isSupported=typeof Br=="function"&&typeof N=="function"&&dn&&dn.createHTMLDocument!==void 0;let Wo=Ta,$o=_a,Ko=Ea,Vo=va,Go=Sa,jo=Aa,wi=Ca,Zo=wa,Ni=Ir,x=null,xi=A({},[...kr,...$n,...Kn,...Vn,...Rr]),k=null,ki=A({},[...Or,...Gn,...Dr,...Kt]),R=Object.seal(tt(null,{tagNameCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeNameCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},allowCustomizedBuiltInElements:{writable:!0,configurable:!1,enumerable:!0,value:!1}})),ct=null,Ri=null,Ce=Object.seal(tt(null,{tagCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeCheck:{writable:!0,configurable:!1,enumerable:!0,value:null}})),Oi=!0,fn=!0,Di=!1,Ii=!0,Le=!1,ht=!0,Me=!1,pn=!1,mn=null,gn=null,yn=!1,Ve=!1,Rt=!1,Ot=!1,Mi=!0,Pi=!1,Bi="user-content-",bn=!0,Tn=!1,Ge={},fe=null,_n=A({},["annotation-xml","audio","colgroup","desc","foreignobject","head","iframe","math","mi","mn","mo","ms","mtext","noembed","noframes","noscript","plaintext","script","selectedcontent","style","svg","template","thead","title","video","xmp"]),Hi=null,Fi=A({},["audio","video","img","source","image","track"]),En=null,Ui=A({},["alt","class","for","id","label","name","pattern","placeholder","role","summary","title","value","style","xmlns"]),Dt="http://www.w3.org/1998/Math/MathML",It="http://www.w3.org/2000/svg",pe="http://www.w3.org/1999/xhtml",je=pe,vn=!1,Sn=null,Yo=A({},[Dt,It,pe],Wn),zi=j(["mi","mo","mn","ms","mtext"]),An=A({},zi),qi=j(["annotation-xml"]),Cn=A({},qi),Xo=A({},["title","style","font","a","script"]),ut=null,Qo=["application/xhtml+xml","text/html"],Jo="text/html",O=null,Ze=null,es=n.createElement("form"),Wi=function(c){return c instanceof RegExp||c instanceof Function},Ln=function(){let c=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};if(Ze&&Ze===c)return;(!c||typeof c!="object")&&(c={}),c=ne(c),ut=Qo.indexOf(c.PARSER_MEDIA_TYPE)===-1?Jo:c.PARSER_MEDIA_TYPE,O=ut==="application/xhtml+xml"?Wn:_t,x=Re(c,"ALLOWED_TAGS",xi,{transform:O}),k=Re(c,"ALLOWED_ATTR",ki,{transform:O}),Sn=Re(c,"ALLOWED_NAMESPACES",Yo,{transform:Wn}),En=Re(c,"ADD_URI_SAFE_ATTR",Ui,{transform:O,base:Ui}),Hi=Re(c,"ADD_DATA_URI_TAGS",Fi,{transform:O,base:Fi}),fe=Re(c,"FORBID_CONTENTS",_n,{transform:O}),ct=Re(c,"FORBID_TAGS",ne({}),{transform:O}),Ri=Re(c,"FORBID_ATTR",ne({}),{transform:O}),Ge=K(c,"USE_PROFILES")?c.USE_PROFILES&&typeof c.USE_PROFILES=="object"?ne(c.USE_PROFILES):c.USE_PROFILES:!1,Oi=c.ALLOW_ARIA_ATTR!==!1,fn=c.ALLOW_DATA_ATTR!==!1,Di=c.ALLOW_UNKNOWN_PROTOCOLS||!1,Ii=c.ALLOW_SELF_CLOSE_IN_ATTR!==!1,Le=c.SAFE_FOR_TEMPLATES||!1,ht=c.SAFE_FOR_XML!==!1,Me=c.WHOLE_DOCUMENT||!1,Ve=c.RETURN_DOM||!1,Rt=c.RETURN_DOM_FRAGMENT||!1,Ot=c.RETURN_TRUSTED_TYPE||!1,yn=c.FORCE_BODY||!1,Mi=c.SANITIZE_DOM!==!1,Pi=c.SANITIZE_NAMED_PROPS||!1,bn=c.KEEP_CONTENT!==!1,Tn=c.IN_PLACE||!1,Ni=ga(c.ALLOWED_URI_REGEXP)?c.ALLOWED_URI_REGEXP:Ir,je=typeof c.NAMESPACE=="string"?c.NAMESPACE:pe,An=K(c,"MATHML_TEXT_INTEGRATION_POINTS")&&c.MATHML_TEXT_INTEGRATION_POINTS&&typeof c.MATHML_TEXT_INTEGRATION_POINTS=="object"?ne(c.MATHML_TEXT_INTEGRATION_POINTS):A({},zi),Cn=K(c,"HTML_INTEGRATION_POINTS")&&c.HTML_INTEGRATION_POINTS&&typeof c.HTML_INTEGRATION_POINTS=="object"?ne(c.HTML_INTEGRATION_POINTS):A({},qi);let f=K(c,"CUSTOM_ELEMENT_HANDLING")&&c.CUSTOM_ELEMENT_HANDLING&&typeof c.CUSTOM_ELEMENT_HANDLING=="object"?ne(c.CUSTOM_ELEMENT_HANDLING):tt(null);if(R=tt(null),K(f,"tagNameCheck")&&Wi(f.tagNameCheck)&&(R.tagNameCheck=f.tagNameCheck),K(f,"attributeNameCheck")&&Wi(f.attributeNameCheck)&&(R.attributeNameCheck=f.attributeNameCheck),K(f,"allowCustomizedBuiltInElements")&&typeof f.allowCustomizedBuiltInElements=="boolean"&&(R.allowCustomizedBuiltInElements=f.allowCustomizedBuiltInElements),Z(R),Le&&(fn=!1),Rt&&(Ve=!0),Ge&&(x=A({},Rr),k=tt(null),Ge.html===!0&&(A(x,kr),A(k,Or)),Ge.svg===!0&&(A(x,$n),A(k,Gn),A(k,Kt)),Ge.svgFilters===!0&&(A(x,Kn),A(k,Gn),A(k,Kt)),Ge.mathMl===!0&&(A(x,Vn),A(k,Dr),A(k,Kt))),Ce.tagCheck=null,Ce.attributeCheck=null,K(c,"ADD_TAGS")&&(typeof c.ADD_TAGS=="function"?Ce.tagCheck=c.ADD_TAGS:Oe(c.ADD_TAGS)&&(x===xi&&(x=ne(x)),A(x,c.ADD_TAGS,O))),K(c,"ADD_ATTR")&&(typeof c.ADD_ATTR=="function"?Ce.attributeCheck=c.ADD_ATTR:Oe(c.ADD_ATTR)&&(k===ki&&(k=ne(k)),A(k,c.ADD_ATTR,O))),K(c,"ADD_URI_SAFE_ATTR")&&Oe(c.ADD_URI_SAFE_ATTR)&&A(En,c.ADD_URI_SAFE_ATTR,O),K(c,"FORBID_CONTENTS")&&Oe(c.FORBID_CONTENTS)&&(fe===_n&&(fe=ne(fe)),A(fe,c.FORBID_CONTENTS,O)),K(c,"ADD_FORBID_CONTENTS")&&Oe(c.ADD_FORBID_CONTENTS)&&(fe===_n&&(fe=ne(fe)),A(fe,c.ADD_FORBID_CONTENTS,O)),bn&&(x["#text"]=!0),Me&&A(x,["html","head","body"]),x.table&&(A(x,["tbody"]),delete ct.tbody),c.TRUSTED_TYPES_POLICY){if(typeof c.TRUSTED_TYPES_POLICY.createHTML!="function")throw We('TRUSTED_TYPES_POLICY configuration option must provide a "createHTML" hook.');if(typeof c.TRUSTED_TYPES_POLICY.createScriptURL!="function")throw We('TRUSTED_TYPES_POLICY configuration option must provide a "createScriptURL" hook.');let m=ie;ie=c.TRUSTED_TYPES_POLICY;try{Ie=Ke("")}catch(T){throw ie=m,T}}else c.TRUSTED_TYPES_POLICY===null?(ie=void 0,Ie=""):(ie===void 0&&(ie=Fo()),ie&&typeof Ie=="string"&&(Ie=Ke("")));j&&j(c),Ze=c},$i=A({},[...$n,...Kn,...ya]),Ki=A({},[...Vn,...ba]),ts=function(c,f,m){return f.namespaceURI===pe?c==="svg":f.namespaceURI===Dt?c==="svg"&&(m==="annotation-xml"||An[m]):!!$i[c]},ns=function(c,f,m){return f.namespaceURI===pe?c==="math":f.namespaceURI===It?c==="math"&&Cn[m]:!!Ki[c]},is=function(c,f,m){return f.namespaceURI===It&&!Cn[m]||f.namespaceURI===Dt&&!An[m]?!1:!Ki[c]&&(Xo[c]||!$i[c])},rs=function(c){let f=N(c);(!f||!f.tagName)&&(f={namespaceURI:je,tagName:"template"});let m=_t(c.tagName),T=_t(f.tagName);return Sn[c.namespaceURI]?c.namespaceURI===It?ts(m,f,T):c.namespaceURI===Dt?ns(m,f,T):c.namespaceURI===pe?is(m,f,T):!!(ut==="application/xhtml+xml"&&Sn[c.namespaceURI]):!1},we=function(c){et(t.removed,{element:c});try{N(c).removeChild(c)}catch{if(y(c),!N(c))throw We("a node selected for removal could not be detached from its tree and cannot be safely returned; refusing to sanitize in place")}},Vi=function(c){let f=S(c);if(f){let T=[];yt(f,v=>{et(T,v)}),yt(T,v=>{try{y(v)}catch{}})}let m=J(c);if(m)for(let T=m.length-1;T>=0;--T){let v=m[T],C=v&&v.name;if(typeof C=="string")try{c.removeAttribute(C)}catch{}}},Pe=function(c,f){try{et(t.removed,{attribute:f.getAttributeNode(c),from:f})}catch{et(t.removed,{attribute:null,from:f})}if(f.removeAttribute(c),c==="is")if(Ve||Rt)try{we(f)}catch{}else try{f.setAttribute(c,"")}catch{}},os=function(c){let f=J(c);if(f)for(let m=f.length-1;m>=0;--m){let T=f[m],v=T&&T.name;if(!(typeof v!="string"||k[O(v)]))try{c.removeAttribute(v)}catch{}}},ss=function(c){let f=[c];for(;f.length>0;){let m=f.pop();(U?U(m):m.nodeType)===ye.element&&os(m);let v=S(m);if(v)for(let C=v.length-1;C>=0;--C)f.push(v[C])}},Gi=function(c){let f=null,m=null;if(yn)c="<remove></remove>"+c;else{let C=Lr(c,/^[\r\n\t ]+/);m=C&&C[0]}ut==="application/xhtml+xml"&&je===pe&&(c='<html xmlns="http://www.w3.org/1999/xhtml"><head></head><body>'+c+"</body></html>");let T=ie?Ke(c):c;if(je===pe)try{f=new d().parseFromString(T,ut)}catch{}if(!f||!f.documentElement){f=dn.createDocument(je,"template",null);try{f.documentElement.innerHTML=vn?Ie:T}catch{}}let v=f.body||f.documentElement;return c&&m&&v.insertBefore(n.createTextNode(m),v.childNodes[0]||null),je===pe?zo.call(f,Me?"html":"body")[0]:Me?f.documentElement:v},ji=function(c){return Li.call(c.ownerDocument||c,c,l.SHOW_ELEMENT|l.SHOW_COMMENT|l.SHOW_TEXT|l.SHOW_PROCESSING_INSTRUCTION|l.SHOW_CDATA_SECTION,null)},Mt=function(c){return c=bt(c,Wo," "),c=bt(c,$o," "),c=bt(c,Ko," "),c},wn=function(c){var f;c.normalize();let m=Li.call(c.ownerDocument||c,c,l.SHOW_TEXT|l.SHOW_COMMENT|l.SHOW_CDATA_SECTION|l.SHOW_PROCESSING_INSTRUCTION,null),T=m.nextNode();for(;T;)T.data=Mt(T.data),T=m.nextNode();let v=(f=c.querySelectorAll)===null||f===void 0?void 0:f.call(c,"template");v&&yt(v,C=>{Ye(C.content)&&wn(C.content)})},Pt=function(c){let f=he?he(c):null;return typeof f!="string"||O(f)!=="form"?!1:typeof c.nodeName!="string"||typeof c.textContent!="string"||typeof c.removeChild!="function"||c.attributes!==J(c)||typeof c.removeAttribute!="function"||typeof c.setAttribute!="function"||typeof c.namespaceURI!="string"||typeof c.insertBefore!="function"||typeof c.hasChildNodes!="function"||c.nodeType!==U(c)||c.childNodes!==S(c)},Ye=function(c){if(!U||typeof c!="object"||c===null)return!1;try{return U(c)===ye.documentFragment}catch{return!1}},dt=function(c){if(!U||typeof c!="object"||c===null)return!1;try{return typeof U(c)=="number"}catch{return!1}};function Te(g,c,f){g.length!==0&&yt(g,m=>{m.call(t,c,f,Ze)})}let as=function(c,f){return!!(ht&&c.hasChildNodes()&&!dt(c.firstElementChild)&&G(Mr,c.textContent)&&G(Mr,c.innerHTML)||ht&&c.namespaceURI===pe&&f==="style"&&dt(c.firstElementChild)||c.nodeType===ye.processingInstruction||ht&&c.nodeType===ye.comment&&G(Na,c.data))},ls=function(c,f){if(!ct[f]&&Xi(f)&&(R.tagNameCheck instanceof RegExp&&G(R.tagNameCheck,f)||R.tagNameCheck instanceof Function&&R.tagNameCheck(f)))return!1;if(bn&&!fe[f]){let m=N(c),T=S(c);if(T&&m){let v=T.length;for(let C=v-1;C>=0;--C){let q=Tn?T[C]:b(T[C],!0);m.insertBefore(q,E(c))}}}return we(c),!0},Zi=function(c){if(Te(M.beforeSanitizeElements,c,null),Pt(c))return we(c),!0;let f=O(he?he(c):c.nodeName);if(Te(M.uponSanitizeElement,c,{tagName:f,allowedTags:x}),as(c,f))return we(c),!0;if(ct[f]||!(Ce.tagCheck instanceof Function&&Ce.tagCheck(f))&&!x[f])return ls(c,f);if((U?U(c):c.nodeType)===ye.element&&!rs(c)||(f==="noscript"||f==="noembed"||f==="noframes")&&G(xa,c.innerHTML))return we(c),!0;if(Le&&c.nodeType===ye.text){let T=Mt(c.textContent);c.textContent!==T&&(et(t.removed,{element:c.cloneNode()}),c.textContent=T)}return Te(M.afterSanitizeElements,c,null),!1},Yi=function(c,f,m){if(Ri[f]||Mi&&(f==="id"||f==="name")&&(m in n||m in es))return!1;let T=k[f]||Ce.attributeCheck instanceof Function&&Ce.attributeCheck(f,c);if(!(fn&&G(Vo,f))){if(!(Oi&&G(Go,f))){if(T){if(!En[f]){if(!G(Ni,bt(m,wi,""))){if(!((f==="src"||f==="xlink:href"||f==="href")&&c!=="script"&&wr(m,"data:")===0&&Hi[c])){if(!(Di&&!G(jo,bt(m,wi,"")))){if(m)return!1}}}}}else if(!(Xi(c)&&(R.tagNameCheck instanceof RegExp&&G(R.tagNameCheck,c)||R.tagNameCheck instanceof Function&&R.tagNameCheck(c))&&(R.attributeNameCheck instanceof RegExp&&G(R.attributeNameCheck,f)||R.attributeNameCheck instanceof Function&&R.attributeNameCheck(f,c))||f==="is"&&R.allowCustomizedBuiltInElements&&(R.tagNameCheck instanceof RegExp&&G(R.tagNameCheck,m)||R.tagNameCheck instanceof Function&&R.tagNameCheck(m))))return!1}}return!0},cs=A({},["annotation-xml","color-profile","font-face","font-face-format","font-face-name","font-face-src","font-face-uri","missing-glyph"]),Xi=function(c){return!cs[_t(c)]&&G(Zo,c)},hs=function(c,f,m,T){if(ie&&typeof u=="object"&&typeof u.getAttributeType=="function"&&!m)switch(u.getAttributeType(c,f)){case"TrustedHTML":return Ke(T);case"TrustedScriptURL":return Ho(T)}return T},us=function(c,f,m,T){try{m?c.setAttributeNS(m,f,T):c.setAttribute(f,T),Pt(c)?we(c):Cr(t.removed)}catch{Pe(f,c)}},Qi=function(c){Te(M.beforeSanitizeAttributes,c,null);let f=c.attributes;if(!f||Pt(c))return;let m={attrName:"",attrValue:"",keepAttr:!0,allowedAttributes:k,forceKeepAttr:void 0},T=f.length,v=O(c.nodeName);for(;T--;){let C=f[T],q=C.name,B=C.namespaceURI,ae=C.value,ue=O(q),xn=ae,ee=q==="value"?xn:ha(xn);if(m.attrName=ue,m.attrValue=ee,m.keepAttr=!0,m.forceKeepAttr=void 0,Te(M.uponSanitizeAttribute,c,m),ee=m.attrValue,Pi&&(ue==="id"||ue==="name")&&wr(ee,Bi)!==0&&(Pe(q,c),ee=Bi+ee),ht&&G(/((--!?|])>)|<\/(style|script|title|xmp|textarea|noscript|iframe|noembed|noframes)/i,ee)){Pe(q,c);continue}if(ue==="attributename"&&Lr(ee,"href")){Pe(q,c);continue}if(!m.forceKeepAttr){if(!m.keepAttr){Pe(q,c);continue}if(!Ii&&G(ka,ee)){Pe(q,c);continue}if(Le&&(ee=Mt(ee)),!Yi(v,ue,ee)){Pe(q,c);continue}ee=hs(v,ue,B,ee),ee!==xn&&us(c,q,B,ee)}}Te(M.afterSanitizeAttributes,c,null)},Bt=function(c){let f=null,m=ji(c);for(Te(M.beforeSanitizeShadowDOM,c,null);f=m.nextNode();)if(Te(M.uponSanitizeShadowNode,f,null),Zi(f),Qi(f),Ye(f.content)&&Bt(f.content),(U?U(f):f.nodeType)===ye.element){let v=P(f);Ye(v)&&(Nn(v),Bt(v))}Te(M.afterSanitizeShadowDOM,c,null)},Nn=function(c){let f=[{node:c,shadow:null}];for(;f.length>0;){let m=f.pop();if(m.shadow){Bt(m.shadow);continue}let T=m.node,C=(U?U(T):T.nodeType)===ye.element,q=S(T);if(q)for(let B=q.length-1;B>=0;--B)f.push({node:q[B],shadow:null});if(C){let B=he?he(T):null;if(typeof B=="string"&&O(B)==="template"){let ae=T.content;Ye(ae)&&f.push({node:ae,shadow:null})}}if(C){let B=P(T);Ye(B)&&f.push({node:null,shadow:B},{node:B,shadow:null})}}};return t.sanitize=function(g){let c=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},f=null,m=null,T=null,v=null;if(vn=!g,vn&&(g="<!-->"),typeof g!="string"&&!dt(g)&&(g=ma(g),typeof g!="string"))throw We("dirty is not a string, aborting");if(!t.isSupported)return g;pn?(x=mn,k=gn):Ln(c),(M.uponSanitizeElement.length>0||M.uponSanitizeAttribute.length>0)&&(x=ne(x)),M.uponSanitizeAttribute.length>0&&(k=ne(k)),t.removed=[];let C=Tn&&typeof g!="string"&&dt(g);if(C){let ae=he?he(g):g.nodeName;if(typeof ae=="string"){let ue=O(ae);if(!x[ue]||ct[ue])throw We("root node is forbidden and cannot be sanitized in-place")}if(Pt(g))throw We("root node is clobbered and cannot be sanitized in-place");try{Nn(g)}catch(ue){throw Vi(g),ue}}else if(dt(g))f=Gi("<!---->"),m=f.ownerDocument.importNode(g,!0),m.nodeType===ye.element&&m.nodeName==="BODY"||m.nodeName==="HTML"?f=m:f.appendChild(m),Nn(m);else{if(!Ve&&!Le&&!Me&&g.indexOf("<")===-1)return ie&&Ot?Ke(g):g;if(f=Gi(g),!f)return Ve?null:Ot?Ie:""}f&&yn&&we(f.firstChild);let q=ji(C?g:f);try{for(;T=q.nextNode();)Zi(T),Qi(T),Ye(T.content)&&Bt(T.content)}catch(ae){throw C&&Vi(g),ae}if(C)return yt(t.removed,ae=>{ae.element&&ss(ae.element)}),Le&&wn(g),g;if(Ve){if(Le&&wn(f),Rt)for(v=Uo.call(f.ownerDocument);f.firstChild;)v.appendChild(f.firstChild);else v=f;return(k.shadowroot||k.shadowrootmode)&&(v=qo.call(i,v,!0)),v}let B=Me?f.outerHTML:f.innerHTML;return Me&&x["!doctype"]&&f.ownerDocument&&f.ownerDocument.doctype&&f.ownerDocument.doctype.name&&G(La,f.ownerDocument.doctype.name)&&(B="<!DOCTYPE "+f.ownerDocument.doctype.name+`>
24
- `+B),Le&&(B=Mt(B)),ie&&Ot?Ke(B):B},t.setConfig=function(){let g=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};Ln(g),pn=!0,mn=x,gn=k},t.clearConfig=function(){Ze=null,pn=!1,mn=null,gn=null,ie=un,Ie=""},t.isValidAttribute=function(g,c,f){Ze||Ln({});let m=O(g),T=O(c);return Yi(m,T,f)},t.addHook=function(g,c){typeof c=="function"&&K(M,g)&&et(M[g],c)},t.removeHook=function(g,c){if(K(M,g)){if(c!==void 0){let f=la(M[g],c);return f===-1?void 0:ca(M[g],f,1)[0]}return Cr(M[g])}},t.removeHooks=function(g){K(M,g)&&(M[g]=[])},t.removeAllHooks=function(){M=Pr()},t}var Ur=Fr();var z=(e,t="0 0 18 18")=>`<svg viewBox="${t}" width="18" height="18" aria-hidden="true" focusable="false">${e}</svg>`,I={bold:z('<path fill="currentColor" d="M178.48,115.7A44,44,0,0,0,148,40H80a8,8,0,0,0-8,8V200a8,8,0,0,0,8,8h80a48,48,0,0,0,18.48-92.3ZM88,56h60a28,28,0,0,1,0,56H88Zm72,136H88V128h72a32,32,0,0,1,0,64Z"/>',"0 0 256 256"),italic:z('<path fill="currentColor" d="M200,56a8,8,0,0,1-8,8H157.77L115.1,192H144a8,8,0,0,1,0,16H64a8,8,0,0,1,0-16H98.23L140.9,64H112a8,8,0,0,1,0-16h80A8,8,0,0,1,200,56Z"/>',"0 0 256 256"),underline:z('<path fill="currentColor" d="M200,224a8,8,0,0,1-8,8H64a8,8,0,0,1,0-16H192A8,8,0,0,1,200,224Zm-72-24a64.07,64.07,0,0,0,64-64V56a8,8,0,0,0-16,0v80a48,48,0,0,1-96,0V56a8,8,0,0,0-16,0v80A64.07,64.07,0,0,0,128,200Z"/>',"0 0 256 256"),strike:z('<path fill="currentColor" d="M224,128a8,8,0,0,1-8,8H175.93c9.19,7.11,16.07,17.2,16.07,32,0,13.34-7,25.7-19.75,34.79C160.33,211.31,144.61,216,128,216s-32.33-4.69-44.25-13.21C71,193.7,64,181.34,64,168a8,8,0,0,1,16,0c0,17.35,22,32,48,32s48-14.65,48-32c0-14.85-10.54-23.58-38.77-32H40a8,8,0,0,1,0-16H216A8,8,0,0,1,224,128ZM76.33,104a8,8,0,0,0,7.61-10.49A17.3,17.3,0,0,1,83.11,88c0-18.24,19.3-32,44.89-32,18.84,0,34.16,7.42,41,19.85a8,8,0,0,0,14-7.7C173.33,50.52,152.77,40,128,40,93.29,40,67.11,60.63,67.11,88a33.73,33.73,0,0,0,1.62,10.49A8,8,0,0,0,76.33,104Z"/>',"0 0 256 256"),link:z('<path fill="currentColor" d="M240,88.23a54.43,54.43,0,0,1-16,37L189.25,160a54.27,54.27,0,0,1-38.63,16h-.05A54.63,54.63,0,0,1,96,119.84a8,8,0,0,1,16,.45A38.62,38.62,0,0,0,150.58,160h0a38.39,38.39,0,0,0,27.31-11.31l34.75-34.75a38.63,38.63,0,0,0-54.63-54.63l-11,11A8,8,0,0,1,135.7,59l11-11A54.65,54.65,0,0,1,224,48,54.86,54.86,0,0,1,240,88.23ZM109,185.66l-11,11A38.41,38.41,0,0,1,70.6,208h0a38.63,38.63,0,0,1-27.29-65.94L78,107.31A38.63,38.63,0,0,1,144,135.71a8,8,0,0,0,16,.45A54.86,54.86,0,0,0,144,96a54.65,54.65,0,0,0-77.27,0L32,130.75A54.62,54.62,0,0,0,70.56,224h0a54.28,54.28,0,0,0,38.64-16l11-11A8,8,0,0,0,109,185.66Z"/>',"0 0 256 256"),unlink:z('<path fill="currentColor" d="M198.63,57.37a32,32,0,0,0-45.19-.06L141.79,69.52a8,8,0,0,1-11.58-11l11.72-12.29a1.59,1.59,0,0,1,.13-.13,48,48,0,0,1,67.88,67.88,1.59,1.59,0,0,1-.13.13l-12.29,11.72a8,8,0,0,1-11-11.58l12.21-11.65A32,32,0,0,0,198.63,57.37ZM114.21,186.48l-11.65,12.21a32,32,0,0,1-45.25-45.25l12.21-11.65a8,8,0,0,0-11-11.58L46.19,141.93a1.59,1.59,0,0,0-.13.13,48,48,0,0,0,67.88,67.88,1.59,1.59,0,0,0,.13-.13l11.72-12.29a8,8,0,1,0-11.58-11ZM216,152H192a8,8,0,0,0,0,16h24a8,8,0,0,0,0-16ZM40,104H64a8,8,0,0,0,0-16H40a8,8,0,0,0,0,16Zm120,80a8,8,0,0,0-8,8v24a8,8,0,0,0,16,0V192A8,8,0,0,0,160,184ZM96,72a8,8,0,0,0,8-8V40a8,8,0,0,0-16,0V64A8,8,0,0,0,96,72Z"/>',"0 0 256 256"),ul:z('<path fill="currentColor" d="M80,64a8,8,0,0,1,8-8H216a8,8,0,0,1,0,16H88A8,8,0,0,1,80,64Zm136,56H88a8,8,0,0,0,0,16H216a8,8,0,0,0,0-16Zm0,64H88a8,8,0,0,0,0,16H216a8,8,0,0,0,0-16ZM44,52A12,12,0,1,0,56,64,12,12,0,0,0,44,52Zm0,64a12,12,0,1,0,12,12A12,12,0,0,0,44,116Zm0,64a12,12,0,1,0,12,12A12,12,0,0,0,44,180Z"/>',"0 0 256 256"),ol:z('<path fill="currentColor" d="M224,128a8,8,0,0,1-8,8H104a8,8,0,0,1,0-16H216A8,8,0,0,1,224,128ZM104,72H216a8,8,0,0,0,0-16H104a8,8,0,0,0,0,16ZM216,184H104a8,8,0,0,0,0,16H216a8,8,0,0,0,0-16ZM43.58,55.16,48,52.94V104a8,8,0,0,0,16,0V40a8,8,0,0,0-11.58-7.16l-16,8a8,8,0,0,0,7.16,14.32ZM79.77,156.72a23.73,23.73,0,0,0-9.6-15.95,24.86,24.86,0,0,0-34.11,4.7,23.63,23.63,0,0,0-3.57,6.46,8,8,0,1,0,15,5.47,7.84,7.84,0,0,1,1.18-2.13,8.76,8.76,0,0,1,12-1.59A7.91,7.91,0,0,1,63.93,159a7.64,7.64,0,0,1-1.57,5.78,1,1,0,0,0-.08.11L33.59,203.21A8,8,0,0,0,40,216H72a8,8,0,0,0,0-16H56l19.08-25.53A23.47,23.47,0,0,0,79.77,156.72Z"/>',"0 0 256 256"),quote:z('<path fill="currentColor" d="M100,56H40A16,16,0,0,0,24,72v64a16,16,0,0,0,16,16h60v8a32,32,0,0,1-32,32,8,8,0,0,0,0,16,48.05,48.05,0,0,0,48-48V72A16,16,0,0,0,100,56Zm0,80H40V72h60ZM216,56H156a16,16,0,0,0-16,16v64a16,16,0,0,0,16,16h60v8a32,32,0,0,1-32,32,8,8,0,0,0,0,16,48.05,48.05,0,0,0,48-48V72A16,16,0,0,0,216,56Zm0,80H156V72h60Z"/>',"0 0 256 256"),undo:z('<path fill="currentColor" d="M224,128a96,96,0,0,1-94.71,96H128A95.38,95.38,0,0,1,62.1,197.8a8,8,0,0,1,11-11.63A80,80,0,1,0,71.43,71.39a3.07,3.07,0,0,1-.26.25L44.59,96H72a8,8,0,0,1,0,16H24a8,8,0,0,1-8-8V56a8,8,0,0,1,16,0V85.8L60.25,60A96,96,0,0,1,224,128Z"/>',"0 0 256 256"),redo:z('<path fill="currentColor" d="M240,56v48a8,8,0,0,1-8,8H184a8,8,0,0,1,0-16H211.4L184.81,71.64l-.25-.24a80,80,0,1,0-1.67,114.78,8,8,0,0,1,11,11.63A95.44,95.44,0,0,1,128,224h-1.32A96,96,0,1,1,195.75,60L224,85.8V56a8,8,0,1,1,16,0Z"/>',"0 0 256 256"),clear:z('<path fill="none" stroke="currentColor" stroke-width="1.6" stroke-linecap="square" stroke-linejoin="miter" d="M3 3l18 18M5 5v3M9 5h10v3M12 5v3M12 12v7M8 19h8"/>',"0 0 24 24"),code:z('<path fill="currentColor" d="M69.12,94.15,28.5,128l40.62,33.85a8,8,0,1,1-10.24,12.29l-48-40a8,8,0,0,1,0-12.29l48-40a8,8,0,0,1,10.24,12.3Zm176,27.7-48-40a8,8,0,1,0-10.24,12.3L227.5,128l-40.62,33.85a8,8,0,1,0,10.24,12.29l48-40a8,8,0,0,0,0-12.29ZM162.73,32.48a8,8,0,0,0-10.25,4.79l-64,176a8,8,0,0,0,4.79,10.26A8.14,8.14,0,0,0,96,224a8,8,0,0,0,7.52-5.27l64-176A8,8,0,0,0,162.73,32.48Z"/>',"0 0 256 256"),indent:z('<path fill="currentColor" d="M224,128a8,8,0,0,1-8,8H112a8,8,0,0,1,0-16H216A8,8,0,0,1,224,128ZM112,72H216a8,8,0,0,0,0-16H112a8,8,0,0,0,0,16ZM216,184H40a8,8,0,0,0,0,16H216a8,8,0,0,0,0-16ZM34.34,141.66a8,8,0,0,0,11.32,0l40-40a8,8,0,0,0,0-11.32l-40-40A8,8,0,0,0,34.34,61.66L68.69,96,34.34,130.34A8,8,0,0,0,34.34,141.66Z"/>',"0 0 256 256"),outdent:z('<path fill="currentColor" d="M224,128a8,8,0,0,1-8,8H112a8,8,0,0,1,0-16H216A8,8,0,0,1,224,128ZM112,72H216a8,8,0,0,0,0-16H112a8,8,0,0,0,0,16ZM216,184H40a8,8,0,0,0,0,16H216a8,8,0,0,0,0-16ZM72,144a8,8,0,0,0,5.66-13.66L43.31,96,77.66,61.66A8,8,0,0,0,66.34,50.34l-40,40a8,8,0,0,0,0,11.32l40,40A8,8,0,0,0,72,144Z"/>',"0 0 256 256"),blocks:z('<path fill="none" stroke="currentColor" stroke-width="1.6" stroke-linecap="square" stroke-linejoin="miter" d="M19 4h-9a4.5 4.5 0 0 0 0 9h3M13 4v16M17 4v16"/>',"0 0 24 24"),h1:z('<path fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round" d="M3.5 5.5v12M12 5.5v12M3.5 11.5H12M17 12l3-2v10"/>',"0 0 24 24"),h2:z('<path fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round" d="M3.5 5.5v12M12 5.5v12M3.5 11.5H12M16 12.5c0-3.5 6-3.5 6 0 0 2-2.5 3.5-6 7.5h6"/>',"0 0 24 24"),h3:z('<path fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round" d="M3.5 5.5v12M12 5.5v12M3.5 11.5H12M16 11c1.5-1.5 6-1.5 6 1.5 0 1.5-1.5 2.5-3 2.5h-1M19 15c1.5 0 3 1 3 2.5 0 3-4.5 3-6 1.5"/>',"0 0 24 24")},Se=e=>e.blocksStayOut(),Da=e=>!!e.element.closest("a"),Et={minimal:["bold","italic","link","unorderedList"],inline:["bold","italic","underline","strikethrough","code","link","undo","redo","clearFormatting"],standard:["blockMenu","bold","italic","underline","strikethrough","code","link","unorderedList","orderedList","quote","outdent","indent","undo","redo","clearFormatting"]};function zr(){return new Map(Ia.map(e=>[e.id,e]))}function nt(e=globalThis){let t=e?.navigator;return t?/Mac|iPhone|iPad|iPod/.test(t.platform||t.userAgent||""):!1}function qr(e,t=globalThis){return e?e.replace("Mod",nt(t)?"Cmd":"Ctrl"):""}var Ia=[De("bold","Bold",I.bold,"Mod+B","inline",e=>e.toggleFormat("B","bold","removeBold")),De("italic","Italic",I.italic,"Mod+I","inline",e=>e.toggleFormat("I","italic","removeItalic")),De("underline","Underline",I.underline,"Mod+U","inline",e=>e.toggleFormat("U","underline","removeUnderline")),De("strikethrough","Strikethrough",I.strike,"Mod+Shift+7","inline",e=>e.toggleFormat("S","strikethrough","removeStrikethrough")),De("code","Code",I.code,null,"inline",e=>e.toggleCode(),e=>e.selectionHasFormat("CODE")||e.selectionHasFormat("PRE")),{id:"link",label:"Link",ariaLabel:"Insert or edit link",icon:I.link,group:"links",shortcut:"Mod+K",mutates:!1,isDisabled:Da,run:e=>e.openLinkDialog(),isActive:e=>!!e.currentLinkElement()},{id:"unlink",label:"Remove link",ariaLabel:"Remove link",icon:I.unlink,group:"links",run:e=>e.squire.removeLink()},De("unorderedList","Bulleted list",I.ul,"Mod+Shift+8","lists",e=>e.toggleList("UL"),e=>e.pathHas("UL"),Se),De("orderedList","Numbered list",I.ol,"Mod+Shift+9","lists",e=>e.toggleList("OL"),e=>e.pathHas("OL"),Se),De("quote","Quote",I.quote,null,"blocks",e=>e.pathHas("BLOCKQUOTE")?e.squire.decreaseQuoteLevel():e.squire.increaseQuoteLevel(),e=>e.pathHas("BLOCKQUOTE"),Se),{id:"outdent",label:"Outdent",ariaLabel:"Decrease indent",icon:I.outdent,group:"blocks",shortcut:"Mod+[",isDisabled:Se,run:e=>e.outdent()},{id:"indent",label:"Indent",ariaLabel:"Increase indent",icon:I.indent,group:"blocks",shortcut:"Mod+]",isDisabled:Se,run:e=>e.indent()},{id:"undo",label:"Undo",ariaLabel:"Undo",icon:I.undo,group:"history",shortcut:"Mod+Z",mutates:!1,run:e=>e.squire.undo()},{id:"redo",label:"Redo",ariaLabel:"Redo",icon:I.redo,group:"history",shortcut:"Mod+Shift+Z",mutates:!1,run:e=>e.squire.redo()},{id:"clearFormatting",label:"Clear formatting",ariaLabel:"Clear formatting",icon:I.clear,group:"cleanup",run:e=>e.squire.removeAllFormatting()},{id:"blockMenu",type:"menu",label:"Block style",ariaLabel:"Choose block style",icon:I.blocks,group:"blocks",isDisabled:Se,options:[Vt("Paragraph","P",I.blocks),Vt("Heading 1","H1",I.h1),Vt("Heading 2","H2",I.h2),Vt("Heading 3","H3",I.h3),{label:"Quote",icon:I.quote,value:"BLOCKQUOTE",isDisabled:Se,run:e=>e.squire.increaseQuoteLevel(),isActive:e=>e.pathHas("BLOCKQUOTE")},{label:"Code block",icon:I.code,value:"PRE",isDisabled:Se,run:e=>e.setBlockType("PRE"),isActive:e=>e.pathHas("PRE")}]}];function De(e,t,n,i,r,o,s=l=>l.selectionHasFormat(Ma(e)),a){return{id:e,label:t,ariaLabel:t,icon:n,group:r,shortcut:i,isDisabled:a,run:o,isActive:s}}function Ma(e){return{bold:"B",italic:"I",underline:"U",strikethrough:"S"}[e]}function Vt(e,t,n){return{label:e,icon:n,value:t,isDisabled:Se,run:i=>i.setBlockType(t),isActive:i=>i.pathHas(t)}}var Xn=/^(?:#text|A(?:BBR|CRONYM)?|B(?:R|D[IO])?|C(?:ITE|ODE)|D(?:ATA|EL|FN)|EM|FONT|HR|I(?:FRAME|MG|NPUT|NS)?|KBD|Q|R(?:P|T|UBY)|S(?:AMP|MALL|PAN|TR(?:IKE|ONG)|U[BP])?|TIME|U|VAR|WBR)$/,jt=/[^ \t\r\n]/;var Pa=new Set(["BR","HR","IFRAME","IMG","INPUT","WBR"]),Qn=e=>e?.nodeType===1&&e.matches('[editor-ui],[clay~="editor-ui"]'),St=new Set(["svg","math"]);function Zt(e){let t=e.nodeType;return t===3||t===8?!0:t!==1?!1:St.has(e.nodeName)?!0:Xn.test(e.nodeName)?Array.from(e.childNodes).every(Zt):!1}function At(e){return Array.from(e.childNodes).some(t=>!Zt(t))}var Yn=e=>e?.nodeType===1&&!St.has(e.nodeName)&&!Xn.test(e.nodeName);function Ct(e,t){let n=Array.from(e.childNodes),i=0;return n.forEach((r,o)=>{if(!(r.nodeType!==1||St.has(r.nodeName))&&(i+=Ct(r,t),!!Yn(r))){for(Yn(n[o-1])&&e.insertBefore(t(),r);r.firstChild;)e.insertBefore(r.firstChild,r);r.remove(),i+=1}}),i}var Jn=new Set(["TABLE","THEAD","TBODY","TFOOT","TR","COLGROUP"]);function Yt(e){return!!e.closest?.("p")||Jn.has(e.nodeName)}var Ba=new Set(["P","H1","H2","H3","H4","H5","H6","PRE","LABEL","LEGEND","LI","TD","TH","DT","DD","FIGCAPTION","SUMMARY","CAPTION"]);function Vr(e){return Ba.has(e.nodeName)||Xt(e)}var Gr=new Set(["AREA","BASE","BR","COL","EMBED","HR","IMG","INPUT","LINK","META","PARAM","SOURCE","TRACK","WBR"]),Ha=new Set(["SCRIPT","STYLE","TEXTAREA","TITLE","IFRAME","NOSCRIPT","XMP"]),jr="http://www.w3.org/1999/xhtml";function Zr(e){return Jn.has(e.nodeName)||Gr.has(e.nodeName)||Ha.has(e.nodeName)||e.nodeName==="TEMPLATE"||!!e.namespaceURI&&e.namespaceURI!==jr}function Yr(e){return Jn.has(e.nodeName)?"a table element cannot be an editable region. Move the editable attribute to a <td>, a <th>, or an element inside one.":e.namespaceURI&&e.namespaceURI!==jr?"an SVG or MathML element cannot be an editable region: an edit puts an HTML block inside it, and the next page load moves that text out of the graphic entirely. Put a <foreignObject> in the SVG and mark an HTML element inside it instead.":Gr.has(e.nodeName)?"this element cannot contain anything, so there is nothing to edit. Move the editable attribute to an element that holds text.":e.nodeName==="TEMPLATE"?"a <template> keeps its content out of the document, so edits to it are never saved.":"this element treats its content as plain text, so any edit would be saved as visible markup rather than formatting."}function Xt(e){return e.nodeType===1&&!St.has(e.nodeName)&&Xn.test(e.nodeName)}function Qt(e){return Array.from(e.querySelectorAll("*")).some(Yn)}function Xr(e,t={}){let{blockTag:n="DIV",wrapBareRoot:i=!1,onBareRootWrapped:r,blocksAllowed:o=!Yt(e)}=t;return eo(e),o&&za(e,n,i,r),e}var Fa=e=>Zt(e)&&e.nodeType!==8&&!Qn(e),Ua=e=>e.nodeType!==8&&!Qn(e)&&!(e.nodeType===3&&!jt.test(e.nodeValue));function Qr(e,{wrapBareRoot:t=!1,blocksAllowed:n=!Yt(e)}={}){return n?At(e)?Array.from(e.childNodes).some(Fa)||Jr(e):t:!1}function Jr(e){return Array.from(e.children).some(t=>At(t)?!ei(t)&&Array.from(t.childNodes).some(i=>i.nodeType===3&&!jt.test(i.nodeValue))||Jr(t):!1)}function eo(e){At(e)&&(ei(e)||Array.from(e.childNodes).forEach(t=>{t.nodeType===3&&!jt.test(t.nodeValue)&&t.remove()}),Array.from(e.children).forEach(eo))}function za(e,t,n,i){if(!At(e)){if(!n)return;let s=e.ownerDocument.createElement(t);if(!Array.from(e.childNodes).some(Ua)){s.appendChild(e.ownerDocument.createElement("BR")),e.appendChild(s);return}for(;e.firstChild;)s.appendChild(e.firstChild);e.appendChild(s),i?.(e,s);return}let r=[],o=()=>{let s=r;if(r=[],!s.some(l=>l.nodeType!==8))return;let a=e.ownerDocument.createElement(t);e.insertBefore(a,s[0]),s.forEach(l=>a.appendChild(l))};Array.from(e.childNodes).forEach(s=>{Qn(s)?o():Zt(s)?r.push(s):o()}),o()}function ei(e){return e.nodeName==="PRE"}function to(e,t){return{start:Wr(e,t.startContainer,t.startOffset),end:Wr(e,t.endContainer,t.endOffset),collapsed:t.collapsed}}function no(e,t,n){Kr(t,"setStart",e,n.start),n.collapsed?t.collapse(!0):Kr(t,"setEnd",e,n.end)}function Wr(e,t,n){if(!e.contains(t))return{scope:e,after:[],before:[]};if(t.nodeType===3){if(!qa(t))return{container:t,offset:n};let i=t.parentNode;return $r(i,Array.from(i.childNodes).indexOf(t))}return{container:t,offset:n,childCount:t.childNodes.length,...$r(t,n)}}function $r(e,t){let n=Array.from(e.childNodes),i=Math.max(0,t);return{scope:e,after:n.slice(i),before:n.slice(0,i).reverse()}}function Kr(e,t,n,i){let{container:r,childCount:o}=i;if(r&&n.contains(r)&&(o===void 0||o===r.childNodes.length)){e[t](r,Math.min(i.offset,Gt(r)));return}let s=i.after?.find(h=>n.contains(h));if(s){e[t](vt(s,!0),0);return}let a=i.before?.find(h=>n.contains(h));if(a){let h=vt(a,!1);e[t](h,Gt(h));return}let l=i.scope&&n.contains(i.scope)?i.scope:n;e[t](l,0)}function qa(e){return e.nodeType===3&&!jt.test(e.nodeValue)&&!!e.parentNode&&e.parentNode.nodeType===1&&At(e.parentNode)&&!ei(e.parentNode)}var it=e=>e.nodeType===1||e.nodeType===3;function vt(e,t=!0){let n=e;for(;n.nodeType===1&&!St.has(n.nodeName);){let i=Array.from(n.childNodes).filter(it),r=t?i[0]:i[i.length-1];if(!r||Pa.has(r.nodeName))break;n=r}return n}function Gt(e){return e.nodeType===3?e.nodeValue.length:e.childNodes.length}var de="[data-richclay], [richclay], [editable], [clay-editable]",Wa="[data-richclay], [richclay], [clay-editable]",$a=["editable","clay-editable"],ii=':is([editable~="single-line"], [clay-editable~="single-line"])';function oi(e){return!e||typeof e.matches!="function"?!1:e.tagName.includes("-")?e.matches(Wa):!0}var Ka="[data-richclay-toolbar], [data-richclay-menu], [data-richclay-dialog], [data-richclay-link-popover], [data-richclay-live], [data-richclay-float]",Va=["richclay-editor","richclay-inline","richclay-active","richclay-empty","richclay-focused"],ri=new WeakSet,io=new WeakSet,ro=["clay:ready","hyperclay:ready"];function oo(e){return[e.clay?.ready,e.hyperclay?.ready].find(t=>t&&typeof t.then=="function")||null}function so(e){return typeof e.clay?.isEditMode=="boolean"?e.clay.isEditMode:typeof e.hyperclay?.isEditMode=="boolean"?e.hyperclay.isEditMode:null}function Ga(e){let t=e.hyperclayModules,n=e.__hyperclayNoAutoExport===!1&&t&&typeof t=="object"&&typeof t.nodeType!="number";return so(e)!==null||!!oo(e)||!!n}function ja(e){return e.clay?.addDocumentTransform||e.hyperclay?.beforeSave||null}function Za(e){return e.clay?.onSnapshot||e.hyperclay?.onSnapshot||null}var Ya={boxSizing:"border-box",minWidth:"100%",overflow:"auto",width:"0"};function Jt(e={},t=window){return e.hyperclay===!1?!1:e.hyperclay===!0?!0:!!(Ga(t)||rl(t))}function si(e=window){let t=co(e);if(t!==null)return t;if(typeof e.__hyperclayEditMode=="boolean")return e.__hyperclayEditMode;let n=so(e);return n!==null?n:ol(e)}function ao(e={},t=window){return e.readOnly?!1:Jt(e,t)?si(t):!0}function lo(e){let t=$a.find(r=>e.hasAttribute(r));if(!t)return null;let n=new Set((e.getAttribute(t)||"").trim().split(/\s+/).filter(Boolean)),i={inline:!0,singleLine:n.has("single-line"),toolbarOnSelect:n.has("toolbar-on-select")};return n.has("no-toolbar")&&(i.toolbar=!1),n.has("link-label")&&(i.singleLine=!0,i.linkLabel=!0,i.toolbar=["link","undo","redo"]),i}function ai(e=window){if(ri.has(e))return;let t=Za(e)||ja(e);if(typeof t!="function"){Xa(e);return}t(n=>li(n)),ri.add(e)}function Xa(e){if(io.has(e))return;let t=e.document,n=oo(e);if(!t&&!n)return;io.add(e);let i=()=>{ai(e),ri.has(e)&&r()},r=()=>{t&&ro.forEach(o=>t.removeEventListener(o,i))};t&&ro.forEach(o=>t.addEventListener(o,i)),n&&n.then(i,()=>{})}function li(e){e.querySelectorAll?.(Ka).forEach(t=>t.remove()),e.querySelectorAll?.(de).forEach(t=>{if(t.getAttribute("data-richclay-active")!=="true")return;if(en(t,"save"),tl(t)){let i=t.ownerDocument,r=!!t.matches?.(ii);Ct(t,()=>r?i.createTextNode(" "):i.createElement("br")),t.querySelectorAll(t.localName).forEach(o=>{for(;o.firstChild;)o.parentNode.insertBefore(o.firstChild,o);o.remove()})}t.matches?.(ii)&&il(t),t.querySelectorAll("#squire-selection-start, #squire-selection-end").forEach(i=>{i.remove()}),t.querySelectorAll(".squire-image-resize-container").forEach(i=>i.remove()),nl(t),(t.matches?.("pre")?[t,...t.querySelectorAll("pre")]:Array.from(t.querySelectorAll("pre"))).filter(i=>i.hasAttribute("data-richclay-pre")).forEach(i=>{Object.entries(Ya).forEach(([r,o])=>{i.style[r]||(i.style[r]=o)}),i.removeAttribute("data-richclay-pre")})}),e.querySelectorAll?.("#squire-selection-start, #squire-selection-end").forEach(t=>t.remove())}var Qa="p, td, th, li, dl, dt, dd, table, blockquote, div, section, article, aside, main, header, footer, figure, figcaption",ti="data-richclay-measure";function Ja(e){let t=e.ownerDocument,n=e.closest(Qa)||e;e.setAttribute(ti,"");let i=t.createElement("div");try{i.innerHTML=n.outerHTML}finally{e.removeAttribute(ti)}let r=i.querySelector(`[${ti}]`);return!r||r.textContent!==e.textContent}var el=e=>!!e.querySelector(e.localName),tl=e=>!!e.matches?.(ii)||(Qt(e)||el(e))&&Ja(e);function en(e,t){let n=e.getAttribute("data-richclay-runtime-contenteditable");e.hasAttribute("contenteditable")&&(n==="true"?e.removeAttribute("contenteditable"):n?t==="destroy"?e.setAttribute("contenteditable",n):(e.setAttribute("inert-contenteditable",n),e.removeAttribute("contenteditable")):t==="save"&&(e.setAttribute("inert-contenteditable",e.getAttribute("contenteditable")),e.removeAttribute("contenteditable"))),Va.forEach(i=>e.classList.remove(i)),e.getAttribute("class")===""&&e.removeAttribute("class"),ni(e,"role","data-richclay-runtime-role"),ni(e,"aria-multiline","data-richclay-runtime-aria-multiline"),ni(e,"no-undo","data-richclay-runtime-no-undo"),e.getAttribute("data-richclay-runtime-display")==="true"&&(e.style.removeProperty("display"),e.getAttribute("style")===""&&e.removeAttribute("style")),sl(e),e.removeAttribute("data-richclay-active"),e.removeAttribute("data-richclay-placeholder"),e.removeAttribute("data-richclay-pre"),e.removeAttribute("data-richclay-runtime-role"),e.removeAttribute("data-richclay-runtime-aria-multiline"),e.removeAttribute("data-richclay-runtime-no-undo"),e.removeAttribute("data-richclay-runtime-describedby"),e.removeAttribute("data-richclay-runtime-contenteditable"),e.removeAttribute("data-richclay-runtime-display"),e.getAttribute("data-richclay-runtime-marker")==="true"&&e.removeAttribute("data-richclay"),e.removeAttribute("data-richclay-runtime-marker")}function nl(e){let n=[e];for(;n.length;)n.pop().childNodes.forEach(r=>{r.nodeType===3?r.nodeValue.includes("\u200B")&&(r.nodeValue=r.nodeValue.split("\u200B").join("")):r.nodeType===1&&n.push(r)});e.querySelectorAll("b, i, u, s, em, strong, code, sub, sup, span").forEach(i=>{i.children.length===0&&(i.textContent||"")===""&&i.attributes.length===0&&i.remove()})}function il(e){let t=Array.from(e.childNodes).filter(i=>i.nodeType!==3||(i.nodeValue||"").trim()!=="");if(t.length!==1)return;let n=t[0];if(!(n.nodeType!==1||n.nodeName!=="P"||n.attributes.length>0)){for(;n.firstChild;)e.insertBefore(n.firstChild,n);n.remove()}}function ci(e){if(!e.hasAttribute("inert-contenteditable"))return null;let t=e.getAttribute("inert-contenteditable");return["false","plaintext-only"].includes(t)||(t="true"),e.setAttribute("contenteditable",t),e.removeAttribute("inert-contenteditable"),t==="true"&&e.setAttribute("data-richclay-runtime-contenteditable","true"),t}function ce(e){return e.setAttribute("snapshot-remove",""),e.setAttribute("no-watch",""),e}function co(e){try{let t=new URLSearchParams(e.location?.search||"");if(t.get("editmode")==="true")return!0;if(t.get("editmode")==="false")return!1}catch{return null}return null}function rl(e){return co(e)!==null||typeof e.__hyperclayEditMode=="boolean"}function ol(e){let n=(e.document?.cookie||"").match(/(?:^|;\s*)isAdminOfCurrentResource=([^;]*)/);return!!(n&&n[1]!=="")}function ni(e,t,n){e.hasAttribute(n)&&e.removeAttribute(t)}function sl(e){let t=e.getAttribute("data-richclay-runtime-describedby");if(!t)return;let n=(e.getAttribute("aria-describedby")||"").split(/\s+/).filter(Boolean).filter(i=>i!==t);n.length?e.setAttribute("aria-describedby",n.join(" ")):e.removeAttribute("aria-describedby")}var al=0;function ho(e=document){let t=e.createElement("div");return t.id=`richclay-live-${++al}`,t.className="richclay-sr-only",t.setAttribute("aria-live","polite"),t.setAttribute("aria-atomic","true"),t.setAttribute("data-richclay-live",""),ce(t),e.body.appendChild(t),t}function rt(e,t){!e||!t||(e.textContent="",e.ownerDocument.defaultView.setTimeout(()=>{e.textContent=t},20))}function Lt(e){e.preventDefault()}function hi(e){try{return e?.cloneRange?.()||null}catch{return null}}function ot(e){try{return hi(e?.getSelection?.())}catch{return null}}function tn(e,t){if(!e||!t)return!1;try{return e.setSelection(t),!0}catch{return!1}}function nn(e,t,n,i){e.hasAttribute(t)||e.setAttribute(i,"true"),e.setAttribute(t,n)}function uo(e,t){let n=new Set((e.getAttribute("aria-describedby")||"").split(/\s+/).filter(Boolean));n.add(t.id),e.setAttribute("aria-describedby",Array.from(n).join(" ")),e.setAttribute("data-richclay-runtime-describedby",t.id)}var ll=0,st=class{constructor(t,n,i={}){this.editor=t,this.controls=n,this.options=i,this.id=++ll,this.items=[],this.menus=new Map,this.activeIndex=0,this.root=this.createRoot(),this.onRootKeydown=r=>this.handleRootKeydown(r),this.onRootClick=r=>this.handleRootClick(r),this.onRootPointerDown=r=>this.handleRootPointerDown(r),this.onDocumentPointerDown=r=>this.handleDocumentPointerDown(r),this.render(),this.root.addEventListener("keydown",this.onRootKeydown),this.root.addEventListener("click",this.onRootClick),this.root.addEventListener("mousedown",this.onRootPointerDown),this.root.ownerDocument.addEventListener("mousedown",this.onDocumentPointerDown)}destroy(){this.closeMenus(),this.root.removeEventListener("keydown",this.onRootKeydown),this.root.removeEventListener("click",this.onRootClick),this.root.removeEventListener("mousedown",this.onRootPointerDown),this.root.ownerDocument.removeEventListener("mousedown",this.onDocumentPointerDown),this.root.remove()}update(){this.items.forEach(t=>{let{def:n,button:i}=t;if(typeof n.isActive=="function"){let r=!!n.isActive(this.editor);i.setAttribute("aria-pressed",r?"true":"false"),i.classList.toggle("is-active",r)}typeof n.isDisabled=="function"&&(i.disabled=!!n.isDisabled(this.editor))}),this.ensureSingleTabStop()}focusFirst(){this.activeIndex=0,this.ensureSingleTabStop(),this.items[0]?.button.focus()}createRoot(){let t=this.editor.element.ownerDocument,n=t.createElement("div");n.className="richclay-toolbar",n.setAttribute("role","toolbar"),n.setAttribute("aria-label",this.options.ariaLabel||"Rich text formatting"),n.setAttribute("data-richclay-toolbar",""),ce(n);let i=cl(this.options.toolbarContainer,t);return i?i.appendChild(n):this.editor.element.insertAdjacentElement("beforebegin",n),n}render(){this.root.textContent="",this.items=[],this.menus.clear();let t=null;this.visibleControls().forEach((n,i)=>{if(n.type==="separator"){this.root.appendChild(po(this.root.ownerDocument)),t=null;return}t&&n.group&&n.group!==t&&this.root.appendChild(po(this.root.ownerDocument)),t=n.group||t,n.type==="menu"?this.renderMenu(n,i):this.renderButton(n,i)}),this.ensureSingleTabStop(),this.update()}visibleControls(){let t=this.controls.filter(i=>i.type==="separator"||!i.isDisabled?.(this.editor)),n=[];for(t.forEach(i=>{let r=n[n.length-1];i.type==="separator"&&(!r||r.type==="separator")||n.push(i)});n[n.length-1]?.type==="separator";)n.pop();return n}renderButton(t,n){let i=fo(this.root.ownerDocument,t);i.dataset.richclayControl=t.id,i.dataset.richclayIndex=String(n),typeof t.isActive=="function"&&i.setAttribute("aria-pressed","false"),this.root.appendChild(i),this.items.push({def:t,button:i,type:"button"})}renderMenu(t,n){let i=this.root.ownerDocument,r=fo(i,t),o=`richclay-menu-${this.id}-${t.id}`;r.dataset.richclayControl=t.id,r.dataset.richclayIndex=String(n),r.setAttribute("aria-haspopup","menu"),r.setAttribute("aria-expanded","false"),r.setAttribute("aria-controls",o);let s=i.createElement("div");s.id=o,s.className="richclay-menu",s.hidden=!0,s.setAttribute("role","menu"),s.setAttribute("data-richclay-menu",""),ce(s),t.options.forEach((l,h)=>{let d=i.createElement("button");d.type="button",d.className="richclay-menu-item",d.setAttribute("role","menuitemradio"),d.setAttribute("tabindex","-1"),d.dataset.richclayMenuItem=t.id,d.dataset.richclayOptionIndex=String(h),d.innerHTML=l.icon||"",d.appendChild(i.createTextNode(l.label)),d.addEventListener("mousedown",Lt),d.addEventListener("click",u=>{u.preventDefault(),this.chooseMenuItem(t,l,r)}),d.addEventListener("keydown",u=>this.handleMenuKeydown(u,t,r)),s.appendChild(d)});let a=i.createElement("span");a.className="richclay-menu-wrap",a.append(r,s),this.root.appendChild(a),this.items.push({def:t,button:r,type:"menu",menu:s}),this.menus.set(t.id,{def:t,button:r,menu:s})}handleRootPointerDown(t){let n=t.target.closest?.("[data-richclay-control]");!n||!this.root.contains(n)||(Lt(t),this.editor.saveSelection())}handleRootClick(t){let n=t.target.closest?.("[data-richclay-control]");if(!n||!this.root.contains(n))return;t.preventDefault();let i=this.items.find(r=>r.button===n);if(!(!i||n.disabled)){if(this.activeIndex=this.items.indexOf(i),this.ensureSingleTabStop(),i.type==="menu"){this.toggleMenu(i.def.id);return}this.closeMenus(),this.editor.runControl(i.def)}}handleRootKeydown(t){let n=t.key,i={ArrowRight:1,ArrowDown:1,ArrowLeft:-1,ArrowUp:-1};if(n in i){t.preventDefault(),this.moveFocus(i[n]);return}if(n==="Home"){t.preventDefault(),this.setFocusIndex(0);return}if(n==="End"){t.preventDefault(),this.setFocusIndex(this.items.length-1);return}let r=this.items[this.activeIndex];if(r&&((n==="Enter"||n===" ")&&r.type==="menu"&&(t.preventDefault(),this.openMenu(r.def.id,"first")),n==="Escape")){let o=Array.from(this.menus.values()).some(s=>!s.menu.hidden);this.closeMenus(),o?r.button.focus():this.editor.focus()}}handleMenuKeydown(t,n,i){t.stopPropagation();let r=this.menus.get(n.id)?.menu,o=Array.from(r.querySelectorAll(".richclay-menu-item")),s=o.indexOf(t.currentTarget),a=s;if(t.key==="ArrowDown"&&(a=(s+1)%o.length),t.key==="ArrowUp"&&(a=(s-1+o.length)%o.length),t.key==="Home"&&(a=0),t.key==="End"&&(a=o.length-1),a!==s){t.preventDefault(),o[a].focus();return}if(t.key==="Escape"){t.preventDefault(),this.closeMenus(),i.focus();return}if(t.key==="Enter"||t.key===" "){t.preventDefault();let l=n.options[s];this.chooseMenuItem(n,l,i)}}handleDocumentPointerDown(t){this.root.contains(t.target)||this.closeMenus()}chooseMenuItem(t,n,i){this.closeMenus(),this.editor.runControl({...n,id:`${t.id}:${n.value}`,ariaLabel:n.label}),i.focus()}toggleMenu(t){let n=this.menus.get(t);n&&(n.menu.hidden?this.openMenu(t,"first"):this.closeMenus())}openMenu(t,n="first"){this.closeMenus(t);let i=this.menus.get(t);if(!i)return;i.menu.hidden=!1,i.button.setAttribute("aria-expanded","true"),this.updateMenuState(i);let r=Array.from(i.menu.querySelectorAll(".richclay-menu-item")),o=r.find(a=>a.getAttribute("aria-checked")==="true");(n==="active"&&o||r[0])?.focus()}closeMenus(t=null){this.menus.forEach((n,i)=>{i!==t&&(n.menu.hidden=!0,n.button.setAttribute("aria-expanded","false"))})}updateMenuState(t){Array.from(t.menu.querySelectorAll(".richclay-menu-item")).forEach((i,r)=>{let s=!!t.def.options[r].isActive?.(this.editor);i.setAttribute("aria-checked",s?"true":"false"),i.classList.toggle("is-active",s)})}moveFocus(t){if(!this.items.length)return;let n=this.activeIndex;do n=(n+t+this.items.length)%this.items.length;while(this.items[n].button.disabled&&n!==this.activeIndex);this.setFocusIndex(n)}setFocusIndex(t){this.activeIndex=Math.max(0,Math.min(t,this.items.length-1)),this.ensureSingleTabStop(),this.items[this.activeIndex]?.button.focus()}ensureSingleTabStop(){let t=this.items.filter(n=>!n.button.disabled);t.length&&(t.includes(this.items[this.activeIndex])||(this.activeIndex=this.items.indexOf(t[0])),this.items.forEach((n,i)=>{n.button.tabIndex=i===this.activeIndex?0:-1}))}};function fo(e,t){let n=e.createElement("button");n.type="button",n.className="richclay-button";let i=qr(t.shortcut,e.defaultView),r=i?`${t.ariaLabel||t.label} (${i})`:t.ariaLabel||t.label;return n.setAttribute("aria-label",r),n.title=r,n.innerHTML=`${t.icon||""}<span class="richclay-sr-only">${t.label}</span>`,n}function po(e){let t=e.createElement("span");return t.className="richclay-separator",t.setAttribute("role","separator"),t.setAttribute("aria-orientation","vertical"),t}function cl(e,t){return e?typeof e=="string"?t.querySelector(e):e:null}var mo=16,hl=[16,8,0],V=8,ul=4;function dl({anchor:e,bar:t,rail:n,viewport:i,current:r=null}){let o=p=>r===p?ul:0;if(e.bottom<=0||e.top>=i.height||e.right<=0||e.left>=i.width)return{mode:"hidden",x:0,y:0};let s=p=>Math.max(V,Math.min(e.left,i.width-p-V)),a=e.top-mo-t.height;if(a>=V-o("above"))return{mode:"above",x:s(t.width),y:a};let l=e.bottom+mo;if(l+t.height<=i.height-V+o("below"))return{mode:"below",x:s(t.width),y:l};let h=i.width-e.right-V,d=e.left-V,u=h>=d?[["rail-right",h],["rail-left",d]]:[["rail-left",d],["rail-right",h]];for(let[p,b]of u)for(let y of hl){if(n.width+y>b+o(p))continue;let E=p==="rail-right"?Math.min(e.right+y,i.width-n.width-V):Math.max(e.left-y-n.width,V),S=Math.min(e.bottom,i.height-V)-n.height,N=Math.max(V,Math.min(Math.max(e.top,V),S));return{mode:p,x:E,y:N,gap:y}}return{mode:"pinned",x:s(t.width),y:V}}var fl=10,pl=28;function on({anchor:e,box:t,viewport:n,gap:i=fl}){let r=n.height-V-e.bottom-i,o=e.top-i-V,s=r>=t.height||r>=o?"below":"above",a=s==="below"?e.bottom+i:e.top-i-t.height,l=Math.max(V,Math.min(a,n.height-V-t.height)),h=(e.left+e.right)/2,d=Math.max(V,Math.min(h-pl,n.width-V-t.width)),u=Math.max(14,Math.min(h-d,t.width-14));return{side:s,x:d,y:l,arrow:u}}function Q(e,t,n){e.style.setProperty(t,n,"important")}var rn=class{constructor(t,n){this.editor=t,this.mode=null,this.hidden=!1,this.frame=0,this.bar={width:0,height:0},this.rail={width:0,height:0};let i=t.element.ownerDocument;this.doc=i,this.win=i.defaultView||globalThis,this.root=i.createElement("div"),this.root.className="richclay-float",this.root.setAttribute("data-richclay-float",""),this.root.setAttribute("save-remove",""),ce(this.root),i.body.appendChild(this.root),this.toolbar=new st(t,n,{toolbarContainer:this.root}),this.onScroll=()=>this.schedule(),this.onResize=()=>{this.measure(),this.schedule()},i.addEventListener("scroll",this.onScroll,{capture:!0,passive:!0}),this.win.addEventListener("resize",this.onResize,{passive:!0}),this.win.visualViewport?.addEventListener("resize",this.onResize,{passive:!0}),this.win.visualViewport?.addEventListener("scroll",this.onScroll,{passive:!0}),this.resizeObserver=typeof this.win.ResizeObserver=="function"?new this.win.ResizeObserver(()=>this.schedule()):null,this.resizeObserver?.observe(t.element),this.measure(),this.reposition()}measure(){let t=this.root.classList.contains("richclay-float-rail");Q(this.root,"visibility","hidden"),this.root.classList.remove("richclay-float-rail"),this.bar={width:this.root.offsetWidth||0,height:this.root.offsetHeight||0},this.root.classList.add("richclay-float-rail"),this.rail={width:this.root.offsetWidth||0,height:this.root.offsetHeight||0},this.root.classList.toggle("richclay-float-rail",t),this.root.style.removeProperty("visibility")}schedule(){if(!this.win.requestAnimationFrame){this.reposition();return}this.frame||(this.frame=this.win.requestAnimationFrame(()=>{this.frame=0,this.reposition()}))}setVisible(t){this.hidden=!t,this.reposition()}reposition(){if(this.hidden){Q(this.root,"display","none");return}let t=this.editor.element.getBoundingClientRect(),n={width:this.win.visualViewport?.width??this.win.innerWidth,height:this.win.visualViewport?.height??this.win.innerHeight},i=dl({anchor:t,bar:this.bar,rail:this.rail,viewport:n,current:this.mode});if(this.mode=i.mode,i.mode==="hidden"){Q(this.root,"display","none");return}this.root.style.removeProperty("display"),this.root.classList.toggle("richclay-float-rail",i.mode==="rail-left"||i.mode==="rail-right"),this.root.classList.toggle("richclay-float-pinned",i.mode==="pinned"),Q(this.root,"transform",`translate(${Math.round(i.x)}px, ${Math.round(i.y)}px)`)}destroy(){this.frame&&this.win.cancelAnimationFrame?.(this.frame),this.frame=0,this.doc.removeEventListener("scroll",this.onScroll,{capture:!0}),this.win.removeEventListener("resize",this.onResize),this.win.visualViewport?.removeEventListener("resize",this.onResize),this.win.visualViewport?.removeEventListener("scroll",this.onScroll),this.resizeObserver?.disconnect(),this.toolbar.destroy(),this.root.remove()}};var ml={ALLOWED_TAGS:["a","b","blockquote","br","code","div","em","h1","h2","h3","h4","h5","h6","i","li","ol","p","pre","s","span","strong","sub","sup","u","ul"],ALLOWED_ATTR:["aria-label","href","rel","target","title"],ALLOW_DATA_ATTR:!1,ALLOW_ARIA_ATTR:!0,ALLOWED_URI_REGEXP:/^(?:(?:(?:f|ht)tps?|mailto|tel):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i,FORBID_TAGS:["script","style","iframe","object","embed","form","input"],FORBID_ATTR:["style","srcset","onerror","onclick","onload"]};function bo(e={},t=document){let n=sn(t);return{sanitizeHTML(i){return ui(i,e,t,n)},sanitizeElement(i){return di(i,e,n)},sanitizeToDOMFragment(i,r){let o=r?.getRoot?.().ownerDocument||t;return gl(i,e,o,n)}}}function ui(e,t={},n=document,i=sn(n)){let r=n.createElement("template");return r.innerHTML=i.sanitize(String(e||""),fi(t)),mi(r.content),r.innerHTML}function di(e,t={},n=sn(e.ownerDocument)){let r=e.ownerDocument.createElement("div");for(;e.firstChild;)r.appendChild(e.firstChild);for(n.sanitize(r,{...fi(t),IN_PLACE:!0}),mi(r);r.firstChild;)e.appendChild(r.firstChild);return e}function gl(e,t={},n=document,i=sn(n)){let r=i.sanitize(String(e||""),{...fi(t),RETURN_DOM_FRAGMENT:!0}),o=r?.ownerDocument===n?r:n.importNode(r,!0);return mi(o),o||n.createDocumentFragment()}function fi(e){return{...ml,...e}}var yl=new Set(["http","https","mailto","tel"]),bl=new RegExp("[\\u0000-\\u0020\\u007F-\\u009F]","g");function pi(e){let n=(String(e??"").replace(bl,"").match(/^([a-z][a-z0-9+.\-]*):/i)||[])[1];return!n||yl.has(n.toLowerCase())}var Tl=/^[^\s/?#:]+\.(?:html?|pdf|txt|csv|json|xml|svg|png|jpe?g|gif|webp|docx?|xlsx?|pptx?|bib|tex|zip)(?:[?#]\S*)?$/i,_l=/^[^\s/?#:.]+\/\S*$/;function To(e){let t=String(e??"").trim();return!t||!pi(t)?"":/^(?:https?:|mailto:|tel:)/i.test(t)?t:/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(t)?`mailto:${t}`:/^(?:[#?]|\/|\.{1,2}\/)/.test(t)||Tl.test(t)||_l.test(t)?t:`https://${t}`}function sn(e){let t=globalThis.DOMPurify;if(t?.sanitize)return t;if(typeof t=="function")return t(e.defaultView||globalThis);throw new Error("RichClay requires DOMPurify. Load vendor/purify.min.js before richclay.js or provide globalThis.DOMPurify.")}function mi(e){e.querySelectorAll?.("a[href]").forEach(t=>{let n=t.getAttribute("href")||"";if(/^\s*javascript:/i.test(n)&&t.removeAttribute("href"),t.getAttribute("target")==="_blank"){let i=new Set((t.getAttribute("rel")||"").split(/\s+/).filter(Boolean));i.add("noopener"),i.add("noreferrer"),t.setAttribute("rel",Array.from(i).join(" "))}})}var go={ADD_TAGS:["img"],ADD_ATTR:["class","id","src","alt","width","height"]};function _o(e={}){return{...e,ADD_TAGS:[...new Set([...go.ADD_TAGS,...e.ADD_TAGS||[]])],ADD_ATTR:[...new Set([...go.ADD_ATTR,...e.ADD_ATTR||[]])],ALLOW_DATA_ATTR:e.ALLOW_DATA_ATTR??!0}}var yo="p, div, h1, h2, h3, h4, h5, h6, blockquote, pre, ul, ol, li, figure, figcaption, table, thead, tbody, tr, td, th";function Eo(e){let t=e.ownerDocument||document;e.querySelectorAll?.("br").forEach(i=>i.replaceWith(t.createTextNode(" ")));let n=e.querySelector?.(yo);for(;n;){let i=n.parentNode;for(i.insertBefore(t.createTextNode(" "),n);n.firstChild;)i.insertBefore(n.firstChild,n);i.insertBefore(t.createTextNode(" "),n),n.remove(),n=e.querySelector(yo)}return El(e,t),e}function El(e,t){e.normalize?.();let n=t.createTreeWalker(e,4),i=[];for(;n.nextNode();)i.push(n.currentNode);i.forEach(s=>{s.nodeValue=s.nodeValue.replace(/\s+/g," ")});let r=e.firstChild;r?.nodeType===3&&(r.nodeValue=r.nodeValue.replace(/^\s+/,""));let o=e.lastChild;o?.nodeType===3&&(o.nodeValue=o.nodeValue.replace(/\s+$/,""))}var vl=300,Sl=e=>e.replace(/^mailto:/i,"").replace(/^https?:\/\//i,""),an=class{constructor(t){this.editor=t,this.root=null,this.anchor=null,this.href=null,this.dismissed=null,this.hideTimer=null,this.pointerInside=!1,this.cleanup=null}currentAnchor(){let t=this.editor;return!t.active||t.options.readOnly||t.dialog||t.element.ownerDocument.hidden?null:t.currentLinkElement()}update(){let t=this.currentAnchor();if(!(t&&t===this.dismissed)){if(this.dismissed=null,!t){this.scheduleHide();return}this.cancelHide(),this.show(t)}}show(t){this.root||this.mount();let n=t.getAttribute("href")||"";if(t!==this.anchor||n!==this.href){this.anchor=t,this.href=n;let i=this.root.querySelector(".richclay-link-address");i.textContent=Sl(n)||n,i.title=n,n&&pi(n)?i.setAttribute("href",n):i.removeAttribute("href"),/^(?:mailto|tel):/i.test(n)?i.removeAttribute("target"):i.setAttribute("target","_blank")}this.position()}mount(){let t=this.editor,n=t.element.ownerDocument,i=n.defaultView||globalThis,r=n.createElement("div");r.className="richclay-dialog richclay-link-popover",r.setAttribute("role","group"),r.setAttribute("aria-label","Link"),r.setAttribute("data-richclay-link-popover",""),ce(r),r.setAttribute("save-remove",""),r.innerHTML=`
24
+ `+B),Le&&(B=Mt(B)),ie&&Ot?Ke(B):B},t.setConfig=function(){let g=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};Ln(g),pn=!0,mn=x,gn=k},t.clearConfig=function(){Ze=null,pn=!1,mn=null,gn=null,ie=un,Ie=""},t.isValidAttribute=function(g,c,f){Ze||Ln({});let m=O(g),T=O(c);return Yi(m,T,f)},t.addHook=function(g,c){typeof c=="function"&&K(M,g)&&et(M[g],c)},t.removeHook=function(g,c){if(K(M,g)){if(c!==void 0){let f=la(M[g],c);return f===-1?void 0:ca(M[g],f,1)[0]}return Cr(M[g])}},t.removeHooks=function(g){K(M,g)&&(M[g]=[])},t.removeAllHooks=function(){M=Pr()},t}var Ur=Fr();var z=(e,t="0 0 18 18")=>`<svg viewBox="${t}" width="18" height="18" aria-hidden="true" focusable="false">${e}</svg>`,I={bold:z('<path fill="currentColor" d="M178.48,115.7A44,44,0,0,0,148,40H80a8,8,0,0,0-8,8V200a8,8,0,0,0,8,8h80a48,48,0,0,0,18.48-92.3ZM88,56h60a28,28,0,0,1,0,56H88Zm72,136H88V128h72a32,32,0,0,1,0,64Z"/>',"0 0 256 256"),italic:z('<path fill="currentColor" d="M200,56a8,8,0,0,1-8,8H157.77L115.1,192H144a8,8,0,0,1,0,16H64a8,8,0,0,1,0-16H98.23L140.9,64H112a8,8,0,0,1,0-16h80A8,8,0,0,1,200,56Z"/>',"0 0 256 256"),underline:z('<path fill="currentColor" d="M200,224a8,8,0,0,1-8,8H64a8,8,0,0,1,0-16H192A8,8,0,0,1,200,224Zm-72-24a64.07,64.07,0,0,0,64-64V56a8,8,0,0,0-16,0v80a48,48,0,0,1-96,0V56a8,8,0,0,0-16,0v80A64.07,64.07,0,0,0,128,200Z"/>',"0 0 256 256"),strike:z('<path fill="currentColor" d="M224,128a8,8,0,0,1-8,8H175.93c9.19,7.11,16.07,17.2,16.07,32,0,13.34-7,25.7-19.75,34.79C160.33,211.31,144.61,216,128,216s-32.33-4.69-44.25-13.21C71,193.7,64,181.34,64,168a8,8,0,0,1,16,0c0,17.35,22,32,48,32s48-14.65,48-32c0-14.85-10.54-23.58-38.77-32H40a8,8,0,0,1,0-16H216A8,8,0,0,1,224,128ZM76.33,104a8,8,0,0,0,7.61-10.49A17.3,17.3,0,0,1,83.11,88c0-18.24,19.3-32,44.89-32,18.84,0,34.16,7.42,41,19.85a8,8,0,0,0,14-7.7C173.33,50.52,152.77,40,128,40,93.29,40,67.11,60.63,67.11,88a33.73,33.73,0,0,0,1.62,10.49A8,8,0,0,0,76.33,104Z"/>',"0 0 256 256"),link:z('<path fill="currentColor" d="M240,88.23a54.43,54.43,0,0,1-16,37L189.25,160a54.27,54.27,0,0,1-38.63,16h-.05A54.63,54.63,0,0,1,96,119.84a8,8,0,0,1,16,.45A38.62,38.62,0,0,0,150.58,160h0a38.39,38.39,0,0,0,27.31-11.31l34.75-34.75a38.63,38.63,0,0,0-54.63-54.63l-11,11A8,8,0,0,1,135.7,59l11-11A54.65,54.65,0,0,1,224,48,54.86,54.86,0,0,1,240,88.23ZM109,185.66l-11,11A38.41,38.41,0,0,1,70.6,208h0a38.63,38.63,0,0,1-27.29-65.94L78,107.31A38.63,38.63,0,0,1,144,135.71a8,8,0,0,0,16,.45A54.86,54.86,0,0,0,144,96a54.65,54.65,0,0,0-77.27,0L32,130.75A54.62,54.62,0,0,0,70.56,224h0a54.28,54.28,0,0,0,38.64-16l11-11A8,8,0,0,0,109,185.66Z"/>',"0 0 256 256"),unlink:z('<path fill="currentColor" d="M198.63,57.37a32,32,0,0,0-45.19-.06L141.79,69.52a8,8,0,0,1-11.58-11l11.72-12.29a1.59,1.59,0,0,1,.13-.13,48,48,0,0,1,67.88,67.88,1.59,1.59,0,0,1-.13.13l-12.29,11.72a8,8,0,0,1-11-11.58l12.21-11.65A32,32,0,0,0,198.63,57.37ZM114.21,186.48l-11.65,12.21a32,32,0,0,1-45.25-45.25l12.21-11.65a8,8,0,0,0-11-11.58L46.19,141.93a1.59,1.59,0,0,0-.13.13,48,48,0,0,0,67.88,67.88,1.59,1.59,0,0,0,.13-.13l11.72-12.29a8,8,0,1,0-11.58-11ZM216,152H192a8,8,0,0,0,0,16h24a8,8,0,0,0,0-16ZM40,104H64a8,8,0,0,0,0-16H40a8,8,0,0,0,0,16Zm120,80a8,8,0,0,0-8,8v24a8,8,0,0,0,16,0V192A8,8,0,0,0,160,184ZM96,72a8,8,0,0,0,8-8V40a8,8,0,0,0-16,0V64A8,8,0,0,0,96,72Z"/>',"0 0 256 256"),ul:z('<path fill="currentColor" d="M80,64a8,8,0,0,1,8-8H216a8,8,0,0,1,0,16H88A8,8,0,0,1,80,64Zm136,56H88a8,8,0,0,0,0,16H216a8,8,0,0,0,0-16Zm0,64H88a8,8,0,0,0,0,16H216a8,8,0,0,0,0-16ZM44,52A12,12,0,1,0,56,64,12,12,0,0,0,44,52Zm0,64a12,12,0,1,0,12,12A12,12,0,0,0,44,116Zm0,64a12,12,0,1,0,12,12A12,12,0,0,0,44,180Z"/>',"0 0 256 256"),ol:z('<path fill="currentColor" d="M224,128a8,8,0,0,1-8,8H104a8,8,0,0,1,0-16H216A8,8,0,0,1,224,128ZM104,72H216a8,8,0,0,0,0-16H104a8,8,0,0,0,0,16ZM216,184H104a8,8,0,0,0,0,16H216a8,8,0,0,0,0-16ZM43.58,55.16,48,52.94V104a8,8,0,0,0,16,0V40a8,8,0,0,0-11.58-7.16l-16,8a8,8,0,0,0,7.16,14.32ZM79.77,156.72a23.73,23.73,0,0,0-9.6-15.95,24.86,24.86,0,0,0-34.11,4.7,23.63,23.63,0,0,0-3.57,6.46,8,8,0,1,0,15,5.47,7.84,7.84,0,0,1,1.18-2.13,8.76,8.76,0,0,1,12-1.59A7.91,7.91,0,0,1,63.93,159a7.64,7.64,0,0,1-1.57,5.78,1,1,0,0,0-.08.11L33.59,203.21A8,8,0,0,0,40,216H72a8,8,0,0,0,0-16H56l19.08-25.53A23.47,23.47,0,0,0,79.77,156.72Z"/>',"0 0 256 256"),quote:z('<path fill="currentColor" d="M100,56H40A16,16,0,0,0,24,72v64a16,16,0,0,0,16,16h60v8a32,32,0,0,1-32,32,8,8,0,0,0,0,16,48.05,48.05,0,0,0,48-48V72A16,16,0,0,0,100,56Zm0,80H40V72h60ZM216,56H156a16,16,0,0,0-16,16v64a16,16,0,0,0,16,16h60v8a32,32,0,0,1-32,32,8,8,0,0,0,0,16,48.05,48.05,0,0,0,48-48V72A16,16,0,0,0,216,56Zm0,80H156V72h60Z"/>',"0 0 256 256"),undo:z('<path fill="currentColor" d="M224,128a96,96,0,0,1-94.71,96H128A95.38,95.38,0,0,1,62.1,197.8a8,8,0,0,1,11-11.63A80,80,0,1,0,71.43,71.39a3.07,3.07,0,0,1-.26.25L44.59,96H72a8,8,0,0,1,0,16H24a8,8,0,0,1-8-8V56a8,8,0,0,1,16,0V85.8L60.25,60A96,96,0,0,1,224,128Z"/>',"0 0 256 256"),redo:z('<path fill="currentColor" d="M240,56v48a8,8,0,0,1-8,8H184a8,8,0,0,1,0-16H211.4L184.81,71.64l-.25-.24a80,80,0,1,0-1.67,114.78,8,8,0,0,1,11,11.63A95.44,95.44,0,0,1,128,224h-1.32A96,96,0,1,1,195.75,60L224,85.8V56a8,8,0,1,1,16,0Z"/>',"0 0 256 256"),clear:z('<path fill="none" stroke="currentColor" stroke-width="1.6" stroke-linecap="square" stroke-linejoin="miter" d="M3 3l18 18M5 5v3M9 5h10v3M12 5v3M12 12v7M8 19h8"/>',"0 0 24 24"),code:z('<path fill="currentColor" d="M69.12,94.15,28.5,128l40.62,33.85a8,8,0,1,1-10.24,12.29l-48-40a8,8,0,0,1,0-12.29l48-40a8,8,0,0,1,10.24,12.3Zm176,27.7-48-40a8,8,0,1,0-10.24,12.3L227.5,128l-40.62,33.85a8,8,0,1,0,10.24,12.29l48-40a8,8,0,0,0,0-12.29ZM162.73,32.48a8,8,0,0,0-10.25,4.79l-64,176a8,8,0,0,0,4.79,10.26A8.14,8.14,0,0,0,96,224a8,8,0,0,0,7.52-5.27l64-176A8,8,0,0,0,162.73,32.48Z"/>',"0 0 256 256"),indent:z('<path fill="currentColor" d="M224,128a8,8,0,0,1-8,8H112a8,8,0,0,1,0-16H216A8,8,0,0,1,224,128ZM112,72H216a8,8,0,0,0,0-16H112a8,8,0,0,0,0,16ZM216,184H40a8,8,0,0,0,0,16H216a8,8,0,0,0,0-16ZM34.34,141.66a8,8,0,0,0,11.32,0l40-40a8,8,0,0,0,0-11.32l-40-40A8,8,0,0,0,34.34,61.66L68.69,96,34.34,130.34A8,8,0,0,0,34.34,141.66Z"/>',"0 0 256 256"),outdent:z('<path fill="currentColor" d="M224,128a8,8,0,0,1-8,8H112a8,8,0,0,1,0-16H216A8,8,0,0,1,224,128ZM112,72H216a8,8,0,0,0,0-16H112a8,8,0,0,0,0,16ZM216,184H40a8,8,0,0,0,0,16H216a8,8,0,0,0,0-16ZM72,144a8,8,0,0,0,5.66-13.66L43.31,96,77.66,61.66A8,8,0,0,0,66.34,50.34l-40,40a8,8,0,0,0,0,11.32l40,40A8,8,0,0,0,72,144Z"/>',"0 0 256 256"),blocks:z('<path fill="none" stroke="currentColor" stroke-width="1.6" stroke-linecap="square" stroke-linejoin="miter" d="M19 4h-9a4.5 4.5 0 0 0 0 9h3M13 4v16M17 4v16"/>',"0 0 24 24"),h1:z('<path fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round" d="M3.5 5.5v12M12 5.5v12M3.5 11.5H12M17 12l3-2v10"/>',"0 0 24 24"),h2:z('<path fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round" d="M3.5 5.5v12M12 5.5v12M3.5 11.5H12M16 12.5c0-3.5 6-3.5 6 0 0 2-2.5 3.5-6 7.5h6"/>',"0 0 24 24"),h3:z('<path fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round" d="M3.5 5.5v12M12 5.5v12M3.5 11.5H12M16 11c1.5-1.5 6-1.5 6 1.5 0 1.5-1.5 2.5-3 2.5h-1M19 15c1.5 0 3 1 3 2.5 0 3-4.5 3-6 1.5"/>',"0 0 24 24")},Se=e=>e.blocksStayOut(),Da=e=>!!e.element.closest("a"),Et={minimal:["bold","italic","link","unorderedList"],inline:["bold","italic","underline","strikethrough","code","link","undo","redo","clearFormatting"],standard:["blockMenu","bold","italic","underline","strikethrough","code","link","unorderedList","orderedList","quote","outdent","indent","undo","redo","clearFormatting"]};function zr(){return new Map(Ia.map(e=>[e.id,e]))}function nt(e=globalThis){let t=e?.navigator;return t?/Mac|iPhone|iPad|iPod/.test(t.platform||t.userAgent||""):!1}function qr(e,t=globalThis){return e?e.replace("Mod",nt(t)?"Cmd":"Ctrl"):""}var Ia=[De("bold","Bold",I.bold,"Mod+B","inline",e=>e.toggleFormat("B","bold","removeBold")),De("italic","Italic",I.italic,"Mod+I","inline",e=>e.toggleFormat("I","italic","removeItalic")),De("underline","Underline",I.underline,"Mod+U","inline",e=>e.toggleFormat("U","underline","removeUnderline")),De("strikethrough","Strikethrough",I.strike,"Mod+Shift+7","inline",e=>e.toggleFormat("S","strikethrough","removeStrikethrough")),De("code","Code",I.code,null,"inline",e=>e.toggleCode(),e=>e.selectionHasFormat("CODE")||e.selectionHasFormat("PRE")),{id:"link",label:"Link",ariaLabel:"Insert or edit link",icon:I.link,group:"links",shortcut:"Mod+K",mutates:!1,isDisabled:Da,run:e=>e.openLinkDialog(),isActive:e=>!!e.currentLinkElement()},{id:"unlink",label:"Remove link",ariaLabel:"Remove link",icon:I.unlink,group:"links",run:e=>e.squire.removeLink()},De("unorderedList","Bulleted list",I.ul,"Mod+Shift+8","lists",e=>e.toggleList("UL"),e=>e.pathHas("UL"),Se),De("orderedList","Numbered list",I.ol,"Mod+Shift+9","lists",e=>e.toggleList("OL"),e=>e.pathHas("OL"),Se),De("quote","Quote",I.quote,null,"blocks",e=>e.pathHas("BLOCKQUOTE")?e.squire.decreaseQuoteLevel():e.squire.increaseQuoteLevel(),e=>e.pathHas("BLOCKQUOTE"),Se),{id:"outdent",label:"Outdent",ariaLabel:"Decrease indent",icon:I.outdent,group:"blocks",shortcut:"Mod+[",isDisabled:Se,run:e=>e.outdent()},{id:"indent",label:"Indent",ariaLabel:"Increase indent",icon:I.indent,group:"blocks",shortcut:"Mod+]",isDisabled:Se,run:e=>e.indent()},{id:"undo",label:"Undo",ariaLabel:"Undo",icon:I.undo,group:"history",shortcut:"Mod+Z",mutates:!1,run:e=>e.squire.undo()},{id:"redo",label:"Redo",ariaLabel:"Redo",icon:I.redo,group:"history",shortcut:"Mod+Shift+Z",mutates:!1,run:e=>e.squire.redo()},{id:"clearFormatting",label:"Clear formatting",ariaLabel:"Clear formatting",icon:I.clear,group:"cleanup",run:e=>e.squire.removeAllFormatting()},{id:"blockMenu",type:"menu",label:"Block style",ariaLabel:"Choose block style",icon:I.blocks,group:"blocks",isDisabled:Se,options:[Vt("Paragraph","P",I.blocks),Vt("Heading 1","H1",I.h1),Vt("Heading 2","H2",I.h2),Vt("Heading 3","H3",I.h3),{label:"Quote",icon:I.quote,value:"BLOCKQUOTE",isDisabled:Se,run:e=>e.squire.increaseQuoteLevel(),isActive:e=>e.pathHas("BLOCKQUOTE")},{label:"Code block",icon:I.code,value:"PRE",isDisabled:Se,run:e=>e.setBlockType("PRE"),isActive:e=>e.pathHas("PRE")}]}];function De(e,t,n,i,r,o,s=l=>l.selectionHasFormat(Ma(e)),a){return{id:e,label:t,ariaLabel:t,icon:n,group:r,shortcut:i,isDisabled:a,run:o,isActive:s}}function Ma(e){return{bold:"B",italic:"I",underline:"U",strikethrough:"S"}[e]}function Vt(e,t,n){return{label:e,icon:n,value:t,isDisabled:Se,run:i=>i.setBlockType(t),isActive:i=>i.pathHas(t)}}var Xn=/^(?:#text|A(?:BBR|CRONYM)?|B(?:R|D[IO])?|C(?:ITE|ODE)|D(?:ATA|EL|FN)|EM|FONT|HR|I(?:FRAME|MG|NPUT|NS)?|KBD|Q|R(?:P|T|UBY)|S(?:AMP|MALL|PAN|TR(?:IKE|ONG)|U[BP])?|TIME|U|VAR|WBR)$/,jt=/[^ \t\r\n]/;var Pa=new Set(["BR","HR","IFRAME","IMG","INPUT","WBR"]),Qn=e=>e?.nodeType===1&&e.matches('[editor-ui],[clay~="editor-ui"]'),St=new Set(["svg","math"]);function Zt(e){let t=e.nodeType;return t===3||t===8?!0:t!==1?!1:St.has(e.nodeName)?!0:Xn.test(e.nodeName)?Array.from(e.childNodes).every(Zt):!1}function At(e){return Array.from(e.childNodes).some(t=>!Zt(t))}var Yn=e=>e?.nodeType===1&&!St.has(e.nodeName)&&!Xn.test(e.nodeName);function Ct(e,t){let n=Array.from(e.childNodes),i=0;return n.forEach((r,o)=>{if(!(r.nodeType!==1||St.has(r.nodeName))&&(i+=Ct(r,t),!!Yn(r))){for(Yn(n[o-1])&&e.insertBefore(t(),r);r.firstChild;)e.insertBefore(r.firstChild,r);r.remove(),i+=1}}),i}var Jn=new Set(["TABLE","THEAD","TBODY","TFOOT","TR","COLGROUP"]);function Yt(e){return!!e.closest?.("p")||Jn.has(e.nodeName)}var Ba=new Set(["P","H1","H2","H3","H4","H5","H6","PRE","LABEL","LEGEND","LI","TD","TH","DT","DD","FIGCAPTION","SUMMARY","CAPTION"]);function Vr(e){return Ba.has(e.nodeName)||Xt(e)}var Gr=new Set(["AREA","BASE","BR","COL","EMBED","HR","IMG","INPUT","LINK","META","PARAM","SOURCE","TRACK","WBR"]),Ha=new Set(["SCRIPT","STYLE","TEXTAREA","TITLE","IFRAME","NOSCRIPT","XMP"]),jr="http://www.w3.org/1999/xhtml";function Zr(e){return Jn.has(e.nodeName)||Gr.has(e.nodeName)||Ha.has(e.nodeName)||e.nodeName==="TEMPLATE"||!!e.namespaceURI&&e.namespaceURI!==jr}function Yr(e){return Jn.has(e.nodeName)?"a table element cannot be an editable region. Move the editable attribute to a <td>, a <th>, or an element inside one.":e.namespaceURI&&e.namespaceURI!==jr?"an SVG or MathML element cannot be an editable region: an edit puts an HTML block inside it, and the next page load moves that text out of the graphic entirely. Put a <foreignObject> in the SVG and mark an HTML element inside it instead.":Gr.has(e.nodeName)?"this element cannot contain anything, so there is nothing to edit. Move the editable attribute to an element that holds text.":e.nodeName==="TEMPLATE"?"a <template> keeps its content out of the document, so edits to it are never saved.":"this element treats its content as plain text, so any edit would be saved as visible markup rather than formatting."}function Xt(e){return e.nodeType===1&&!St.has(e.nodeName)&&Xn.test(e.nodeName)}function Qt(e){return Array.from(e.querySelectorAll("*")).some(Yn)}function Xr(e,t={}){let{blockTag:n="DIV",wrapBareRoot:i=!1,onBareRootWrapped:r,blocksAllowed:o=!Yt(e)}=t;return eo(e),o&&za(e,n,i,r),e}var Fa=e=>Zt(e)&&e.nodeType!==8&&!Qn(e),Ua=e=>e.nodeType!==8&&!Qn(e)&&!(e.nodeType===3&&!jt.test(e.nodeValue));function Qr(e,{wrapBareRoot:t=!1,blocksAllowed:n=!Yt(e)}={}){return n?At(e)?Array.from(e.childNodes).some(Fa)||Jr(e):t:!1}function Jr(e){return Array.from(e.children).some(t=>At(t)?!ei(t)&&Array.from(t.childNodes).some(i=>i.nodeType===3&&!jt.test(i.nodeValue))||Jr(t):!1)}function eo(e){At(e)&&(ei(e)||Array.from(e.childNodes).forEach(t=>{t.nodeType===3&&!jt.test(t.nodeValue)&&t.remove()}),Array.from(e.children).forEach(eo))}function za(e,t,n,i){if(!At(e)){if(!n)return;let s=e.ownerDocument.createElement(t);if(!Array.from(e.childNodes).some(Ua)){s.appendChild(e.ownerDocument.createElement("BR")),e.appendChild(s);return}for(;e.firstChild;)s.appendChild(e.firstChild);e.appendChild(s),i?.(e,s);return}let r=[],o=()=>{let s=r;if(r=[],!s.some(l=>l.nodeType!==8))return;let a=e.ownerDocument.createElement(t);e.insertBefore(a,s[0]),s.forEach(l=>a.appendChild(l))};Array.from(e.childNodes).forEach(s=>{Qn(s)?o():Zt(s)?r.push(s):o()}),o()}function ei(e){return e.nodeName==="PRE"}function to(e,t){return{start:Wr(e,t.startContainer,t.startOffset),end:Wr(e,t.endContainer,t.endOffset),collapsed:t.collapsed}}function no(e,t,n){Kr(t,"setStart",e,n.start),n.collapsed?t.collapse(!0):Kr(t,"setEnd",e,n.end)}function Wr(e,t,n){if(!e.contains(t))return{scope:e,after:[],before:[]};if(t.nodeType===3){if(!qa(t))return{container:t,offset:n};let i=t.parentNode;return $r(i,Array.from(i.childNodes).indexOf(t))}return{container:t,offset:n,childCount:t.childNodes.length,...$r(t,n)}}function $r(e,t){let n=Array.from(e.childNodes),i=Math.max(0,t);return{scope:e,after:n.slice(i),before:n.slice(0,i).reverse()}}function Kr(e,t,n,i){let{container:r,childCount:o}=i;if(r&&n.contains(r)&&(o===void 0||o===r.childNodes.length)){e[t](r,Math.min(i.offset,Gt(r)));return}let s=i.after?.find(h=>n.contains(h));if(s){e[t](vt(s,!0),0);return}let a=i.before?.find(h=>n.contains(h));if(a){let h=vt(a,!1);e[t](h,Gt(h));return}let l=i.scope&&n.contains(i.scope)?i.scope:n;e[t](l,0)}function qa(e){return e.nodeType===3&&!jt.test(e.nodeValue)&&!!e.parentNode&&e.parentNode.nodeType===1&&At(e.parentNode)&&!ei(e.parentNode)}var it=e=>e.nodeType===1||e.nodeType===3;function vt(e,t=!0){let n=e;for(;n.nodeType===1&&!St.has(n.nodeName);){let i=Array.from(n.childNodes).filter(it),r=t?i[0]:i[i.length-1];if(!r||Pa.has(r.nodeName))break;n=r}return n}function Gt(e){return e.nodeType===3?e.nodeValue.length:e.childNodes.length}var de="[data-richclay], [richclay], [editable], [clay-editable]",Wa="[data-richclay], [richclay], [clay-editable]",$a=["editable","clay-editable"],ii=':is([editable~="single-line"], [clay-editable~="single-line"])';function oi(e){return!e||typeof e.matches!="function"?!1:e.tagName.includes("-")?e.matches(Wa):!0}var Ka="[data-richclay-toolbar], [data-richclay-menu], [data-richclay-dialog], [data-richclay-link-popover], [data-richclay-live], [data-richclay-float]",Va=["richclay-editor","richclay-inline","richclay-active","richclay-empty","richclay-focused"],ri=new WeakSet,io=new WeakSet,ro=["clay:ready","hyperclay:ready"];function oo(e){return[e.clay?.ready,e.hyperclay?.ready].find(t=>t&&typeof t.then=="function")||null}function so(e){return typeof e.clay?.isEditMode=="boolean"?e.clay.isEditMode:typeof e.hyperclay?.isEditMode=="boolean"?e.hyperclay.isEditMode:null}function Ga(e){let t=e.hyperclayModules,n=e.__hyperclayNoAutoExport===!1&&t&&typeof t=="object"&&typeof t.nodeType!="number";return so(e)!==null||!!oo(e)||!!n}function ja(e){return e.clay?.addDocumentTransform||e.hyperclay?.beforeSave||null}function Za(e){return e.clay?.onSnapshot||e.hyperclay?.onSnapshot||null}var Ya={boxSizing:"border-box",minWidth:"100%",overflow:"auto",width:"0"};function Jt(e={},t=window){return e.hyperclay===!1?!1:e.hyperclay===!0?!0:!!(Ga(t)||rl(t))}function si(e=window){let t=co(e);if(t!==null)return t;if(typeof e.__hyperclayEditMode=="boolean")return e.__hyperclayEditMode;let n=so(e);return n!==null?n:ol(e)}function ao(e={},t=window){return e.readOnly?!1:Jt(e,t)?si(t):!0}function lo(e){let t=$a.find(r=>e.hasAttribute(r));if(!t)return null;let n=new Set((e.getAttribute(t)||"").trim().split(/\s+/).filter(Boolean)),i={inline:!0,singleLine:n.has("single-line"),toolbarOnSelect:n.has("toolbar-on-select")};return n.has("no-toolbar")&&(i.toolbar=!1),n.has("link-label")&&(i.singleLine=!0,i.linkLabel=!0,i.toolbar=["link","undo","redo"]),i}function ai(e=window){if(ri.has(e))return;let t=Za(e)||ja(e);if(typeof t!="function"){Xa(e);return}t(n=>li(n)),ri.add(e)}function Xa(e){if(io.has(e))return;let t=e.document,n=oo(e);if(!t&&!n)return;io.add(e);let i=()=>{ai(e),ri.has(e)&&r()},r=()=>{t&&ro.forEach(o=>t.removeEventListener(o,i))};t&&ro.forEach(o=>t.addEventListener(o,i)),n&&n.then(i,()=>{})}function li(e){e.querySelectorAll?.(Ka).forEach(t=>t.remove()),e.querySelectorAll?.(de).forEach(t=>{if(t.getAttribute("data-richclay-active")!=="true")return;if(en(t,"save"),tl(t)){let i=t.ownerDocument,r=!!t.matches?.(ii);Ct(t,()=>r?i.createTextNode(" "):i.createElement("br")),t.querySelectorAll(t.localName).forEach(o=>{for(;o.firstChild;)o.parentNode.insertBefore(o.firstChild,o);o.remove()})}t.matches?.(ii)&&il(t),t.querySelectorAll("#squire-selection-start, #squire-selection-end").forEach(i=>{i.remove()}),t.querySelectorAll(".squire-image-resize-container").forEach(i=>i.remove()),nl(t),(t.matches?.("pre")?[t,...t.querySelectorAll("pre")]:Array.from(t.querySelectorAll("pre"))).filter(i=>i.hasAttribute("data-richclay-pre")).forEach(i=>{Object.entries(Ya).forEach(([r,o])=>{i.style[r]||(i.style[r]=o)}),i.removeAttribute("data-richclay-pre")})}),e.querySelectorAll?.("#squire-selection-start, #squire-selection-end").forEach(t=>t.remove())}var Qa="p, td, th, li, dl, dt, dd, table, blockquote, div, section, article, aside, main, header, footer, figure, figcaption",ti="data-richclay-measure";function Ja(e){let t=e.ownerDocument,n=e.closest(Qa)||e;e.setAttribute(ti,"");let i=t.createElement("div");try{i.innerHTML=n.outerHTML}finally{e.removeAttribute(ti)}let r=i.querySelector(`[${ti}]`);return!r||r.textContent!==e.textContent}var el=e=>!!e.querySelector(e.localName),tl=e=>!!e.matches?.(ii)||(Qt(e)||el(e))&&Ja(e);function en(e,t){let n=e.getAttribute("data-richclay-runtime-contenteditable");e.hasAttribute("contenteditable")&&(n==="true"?e.removeAttribute("contenteditable"):n?t==="destroy"?e.setAttribute("contenteditable",n):(e.setAttribute("inert-contenteditable",n),e.removeAttribute("contenteditable")):t==="save"&&(e.setAttribute("inert-contenteditable",e.getAttribute("contenteditable")),e.removeAttribute("contenteditable"))),Va.forEach(i=>e.classList.remove(i)),e.getAttribute("class")===""&&e.removeAttribute("class"),ni(e,"role","data-richclay-runtime-role"),ni(e,"aria-multiline","data-richclay-runtime-aria-multiline"),ni(e,"no-undo","data-richclay-runtime-no-undo"),e.getAttribute("data-richclay-runtime-display")==="true"&&(e.style.removeProperty("display"),e.getAttribute("style")===""&&e.removeAttribute("style")),sl(e),e.removeAttribute("data-richclay-active"),e.removeAttribute("data-richclay-placeholder"),e.removeAttribute("data-richclay-pre"),e.removeAttribute("data-richclay-runtime-role"),e.removeAttribute("data-richclay-runtime-aria-multiline"),e.removeAttribute("data-richclay-runtime-no-undo"),e.removeAttribute("data-richclay-runtime-describedby"),e.removeAttribute("data-richclay-runtime-contenteditable"),e.removeAttribute("data-richclay-runtime-display"),e.getAttribute("data-richclay-runtime-marker")==="true"&&e.removeAttribute("data-richclay"),e.removeAttribute("data-richclay-runtime-marker")}function nl(e){let n=[e];for(;n.length;)n.pop().childNodes.forEach(r=>{r.nodeType===3?r.nodeValue.includes("\u200B")&&(r.nodeValue=r.nodeValue.split("\u200B").join("")):r.nodeType===1&&n.push(r)});e.querySelectorAll("b, i, u, s, em, strong, code, sub, sup, span").forEach(i=>{i.children.length===0&&(i.textContent||"")===""&&i.attributes.length===0&&i.remove()})}function il(e){let t=Array.from(e.childNodes).filter(i=>i.nodeType!==3||(i.nodeValue||"").trim()!=="");if(t.length!==1)return;let n=t[0];if(!(n.nodeType!==1||n.nodeName!=="P"||n.attributes.length>0)){for(;n.firstChild;)e.insertBefore(n.firstChild,n);n.remove()}}function ci(e){if(!e.hasAttribute("inert-contenteditable"))return null;let t=e.getAttribute("inert-contenteditable");return["false","plaintext-only"].includes(t)||(t="true"),e.setAttribute("contenteditable",t),e.removeAttribute("inert-contenteditable"),t==="true"&&e.setAttribute("data-richclay-runtime-contenteditable","true"),t}function ce(e){return e.setAttribute("snapshot-remove",""),e.setAttribute("no-watch",""),e}function co(e){try{let t=new URLSearchParams(e.location?.search||"");if(t.get("editmode")==="true")return!0;if(t.get("editmode")==="false")return!1}catch{return null}return null}function rl(e){return co(e)!==null||typeof e.__hyperclayEditMode=="boolean"}function ol(e){let n=(e.document?.cookie||"").match(/(?:^|;\s*)isAdminOfCurrentResource=([^;]*)/);return!!(n&&n[1]!=="")}function ni(e,t,n){e.hasAttribute(n)&&e.removeAttribute(t)}function sl(e){let t=e.getAttribute("data-richclay-runtime-describedby");if(!t)return;let n=(e.getAttribute("aria-describedby")||"").split(/\s+/).filter(Boolean).filter(i=>i!==t);n.length?e.setAttribute("aria-describedby",n.join(" ")):e.removeAttribute("aria-describedby")}var al=0;function ho(e=document){let t=e.createElement("div");return t.id=`richclay-live-${++al}`,t.className="richclay-sr-only",t.setAttribute("aria-live","polite"),t.setAttribute("aria-atomic","true"),t.setAttribute("data-richclay-live",""),ce(t),e.body.appendChild(t),t}function rt(e,t){!e||!t||(e.textContent="",e.ownerDocument.defaultView.setTimeout(()=>{e.textContent=t},20))}function Lt(e){e.preventDefault()}function hi(e){try{return e?.cloneRange?.()||null}catch{return null}}function ot(e){try{return hi(e?.getSelection?.())}catch{return null}}function tn(e,t){if(!e||!t)return!1;try{return e.setSelection(t),!0}catch{return!1}}function nn(e,t,n,i){e.hasAttribute(t)||e.setAttribute(i,"true"),e.setAttribute(t,n)}function uo(e,t){let n=new Set((e.getAttribute("aria-describedby")||"").split(/\s+/).filter(Boolean));n.add(t.id),e.setAttribute("aria-describedby",Array.from(n).join(" ")),e.setAttribute("data-richclay-runtime-describedby",t.id)}var ll=0,st=class{constructor(t,n,i={}){this.editor=t,this.controls=n,this.options=i,this.id=++ll,this.items=[],this.menus=new Map,this.activeIndex=0,this.root=this.createRoot(),this.onRootKeydown=r=>this.handleRootKeydown(r),this.onRootClick=r=>this.handleRootClick(r),this.onRootPointerDown=r=>this.handleRootPointerDown(r),this.onDocumentPointerDown=r=>this.handleDocumentPointerDown(r),this.render(),this.root.addEventListener("keydown",this.onRootKeydown),this.root.addEventListener("click",this.onRootClick),this.root.addEventListener("mousedown",this.onRootPointerDown),this.root.ownerDocument.addEventListener("mousedown",this.onDocumentPointerDown)}destroy(){this.closeMenus(),this.root.removeEventListener("keydown",this.onRootKeydown),this.root.removeEventListener("click",this.onRootClick),this.root.removeEventListener("mousedown",this.onRootPointerDown),this.root.ownerDocument.removeEventListener("mousedown",this.onDocumentPointerDown),this.root.remove()}update(){this.items.forEach(t=>{let{def:n,button:i}=t;if(typeof n.isActive=="function"){let r=!!n.isActive(this.editor);i.setAttribute("aria-pressed",r?"true":"false"),i.classList.toggle("is-active",r)}typeof n.isDisabled=="function"&&(i.disabled=!!n.isDisabled(this.editor))}),this.ensureSingleTabStop()}focusFirst(){this.activeIndex=0,this.ensureSingleTabStop(),this.items[0]?.button.focus()}createRoot(){let t=this.editor.element.ownerDocument,n=t.createElement("div");n.className="richclay-toolbar",n.setAttribute("role","toolbar"),n.setAttribute("aria-label",this.options.ariaLabel||"Rich text formatting"),n.setAttribute("data-richclay-toolbar",""),ce(n);let i=cl(this.options.toolbarContainer,t);return i?i.appendChild(n):this.editor.element.insertAdjacentElement("beforebegin",n),n}render(){this.root.textContent="",this.items=[],this.menus.clear();let t=null;this.visibleControls().forEach((n,i)=>{if(n.type==="separator"){this.root.appendChild(po(this.root.ownerDocument)),t=null;return}t&&n.group&&n.group!==t&&this.root.appendChild(po(this.root.ownerDocument)),t=n.group||t,n.type==="menu"?this.renderMenu(n,i):this.renderButton(n,i)}),this.ensureSingleTabStop(),this.update()}visibleControls(){let t=this.controls.filter(i=>i.type==="separator"||!i.isDisabled?.(this.editor)),n=[];for(t.forEach(i=>{let r=n[n.length-1];i.type==="separator"&&(!r||r.type==="separator")||n.push(i)});n[n.length-1]?.type==="separator";)n.pop();return n}renderButton(t,n){let i=fo(this.root.ownerDocument,t);i.dataset.richclayControl=t.id,i.dataset.richclayIndex=String(n),typeof t.isActive=="function"&&i.setAttribute("aria-pressed","false"),this.root.appendChild(i),this.items.push({def:t,button:i,type:"button"})}renderMenu(t,n){let i=this.root.ownerDocument,r=fo(i,t),o=`richclay-menu-${this.id}-${t.id}`;r.dataset.richclayControl=t.id,r.dataset.richclayIndex=String(n),r.setAttribute("aria-haspopup","menu"),r.setAttribute("aria-expanded","false"),r.setAttribute("aria-controls",o);let s=i.createElement("div");s.id=o,s.className="richclay-menu",s.hidden=!0,s.setAttribute("role","menu"),s.setAttribute("data-richclay-menu",""),ce(s),t.options.forEach((l,h)=>{let d=i.createElement("button");d.type="button",d.className="richclay-menu-item",d.setAttribute("role","menuitemradio"),d.setAttribute("tabindex","-1"),d.dataset.richclayMenuItem=t.id,d.dataset.richclayOptionIndex=String(h),d.innerHTML=l.icon||"",d.appendChild(i.createTextNode(l.label)),d.addEventListener("mousedown",Lt),d.addEventListener("click",u=>{u.preventDefault(),this.chooseMenuItem(t,l,r)}),d.addEventListener("keydown",u=>this.handleMenuKeydown(u,t,r)),s.appendChild(d)});let a=i.createElement("span");a.className="richclay-menu-wrap",a.append(r,s),this.root.appendChild(a),this.items.push({def:t,button:r,type:"menu",menu:s}),this.menus.set(t.id,{def:t,button:r,menu:s})}handleRootPointerDown(t){let n=t.target.closest?.("[data-richclay-control]");!n||!this.root.contains(n)||(Lt(t),this.editor.saveSelection())}handleRootClick(t){let n=t.target.closest?.("[data-richclay-control]");if(!n||!this.root.contains(n))return;t.preventDefault();let i=this.items.find(r=>r.button===n);if(!(!i||n.disabled)){if(this.activeIndex=this.items.indexOf(i),this.ensureSingleTabStop(),i.type==="menu"){this.toggleMenu(i.def.id);return}this.closeMenus(),this.editor.runControl(i.def)}}handleRootKeydown(t){let n=t.key,i={ArrowRight:1,ArrowDown:1,ArrowLeft:-1,ArrowUp:-1};if(n in i){t.preventDefault(),this.moveFocus(i[n]);return}if(n==="Home"){t.preventDefault(),this.setFocusIndex(0);return}if(n==="End"){t.preventDefault(),this.setFocusIndex(this.items.length-1);return}let r=this.items[this.activeIndex];if(r&&((n==="Enter"||n===" ")&&r.type==="menu"&&(t.preventDefault(),this.openMenu(r.def.id,"first")),n==="Escape")){let o=Array.from(this.menus.values()).some(s=>!s.menu.hidden);this.closeMenus(),o?r.button.focus():this.editor.focus()}}handleMenuKeydown(t,n,i){t.stopPropagation();let r=this.menus.get(n.id)?.menu,o=Array.from(r.querySelectorAll(".richclay-menu-item")),s=o.indexOf(t.currentTarget),a=s;if(t.key==="ArrowDown"&&(a=(s+1)%o.length),t.key==="ArrowUp"&&(a=(s-1+o.length)%o.length),t.key==="Home"&&(a=0),t.key==="End"&&(a=o.length-1),a!==s){t.preventDefault(),o[a].focus();return}if(t.key==="Escape"){t.preventDefault(),this.closeMenus(),i.focus();return}if(t.key==="Enter"||t.key===" "){t.preventDefault();let l=n.options[s];this.chooseMenuItem(n,l,i)}}handleDocumentPointerDown(t){this.root.contains(t.target)||this.closeMenus()}chooseMenuItem(t,n,i){this.closeMenus(),this.editor.runControl({...n,id:`${t.id}:${n.value}`,ariaLabel:n.label}),i.focus()}toggleMenu(t){let n=this.menus.get(t);n&&(n.menu.hidden?this.openMenu(t,"first"):this.closeMenus())}openMenu(t,n="first"){this.closeMenus(t);let i=this.menus.get(t);if(!i)return;i.menu.hidden=!1,i.button.setAttribute("aria-expanded","true"),this.updateMenuState(i);let r=Array.from(i.menu.querySelectorAll(".richclay-menu-item")),o=r.find(a=>a.getAttribute("aria-checked")==="true");(n==="active"&&o||r[0])?.focus()}closeMenus(t=null){this.menus.forEach((n,i)=>{i!==t&&(n.menu.hidden=!0,n.button.setAttribute("aria-expanded","false"))})}updateMenuState(t){Array.from(t.menu.querySelectorAll(".richclay-menu-item")).forEach((i,r)=>{let s=!!t.def.options[r].isActive?.(this.editor);i.setAttribute("aria-checked",s?"true":"false"),i.classList.toggle("is-active",s)})}moveFocus(t){if(!this.items.length)return;let n=this.activeIndex;do n=(n+t+this.items.length)%this.items.length;while(this.items[n].button.disabled&&n!==this.activeIndex);this.setFocusIndex(n)}setFocusIndex(t){this.activeIndex=Math.max(0,Math.min(t,this.items.length-1)),this.ensureSingleTabStop(),this.items[this.activeIndex]?.button.focus()}ensureSingleTabStop(){let t=this.items.filter(n=>!n.button.disabled);t.length&&(t.includes(this.items[this.activeIndex])||(this.activeIndex=this.items.indexOf(t[0])),this.items.forEach((n,i)=>{n.button.tabIndex=i===this.activeIndex?0:-1}))}};function fo(e,t){let n=e.createElement("button");n.type="button",n.className="richclay-button";let i=qr(t.shortcut,e.defaultView),r=i?`${t.ariaLabel||t.label} (${i})`:t.ariaLabel||t.label;return n.setAttribute("aria-label",r),n.title=r,n.innerHTML=`${t.icon||""}<span class="richclay-sr-only">${t.label}</span>`,n}function po(e){let t=e.createElement("span");return t.className="richclay-separator",t.setAttribute("role","separator"),t.setAttribute("aria-orientation","vertical"),t}function cl(e,t){return e?typeof e=="string"?t.querySelector(e):e:null}var mo=16,hl=[16,8,0],V=8,ul=4;function dl({anchor:e,bar:t,rail:n,viewport:i,current:r=null}){let o=p=>r===p?ul:0;if(e.bottom<=0||e.top>=i.height||e.right<=0||e.left>=i.width)return{mode:"hidden",x:0,y:0};let s=p=>Math.max(V,Math.min(e.left,i.width-p-V)),a=e.top-mo-t.height;if(a>=V-o("above"))return{mode:"above",x:s(t.width),y:a};let l=e.bottom+mo;if(l+t.height<=i.height-V+o("below"))return{mode:"below",x:s(t.width),y:l};let h=i.width-e.right-V,d=e.left-V,u=h>=d?[["rail-right",h],["rail-left",d]]:[["rail-left",d],["rail-right",h]];for(let[p,b]of u)for(let y of hl){if(n.width+y>b+o(p))continue;let E=p==="rail-right"?Math.min(e.right+y,i.width-n.width-V):Math.max(e.left-y-n.width,V),S=Math.min(e.bottom,i.height-V)-n.height,N=Math.max(V,Math.min(Math.max(e.top,V),S));return{mode:p,x:E,y:N,gap:y}}return{mode:"pinned",x:s(t.width),y:V}}var fl=10,pl=28;function on({anchor:e,box:t,viewport:n,gap:i=fl}){let r=n.height-V-e.bottom-i,o=e.top-i-V,s=r>=t.height||r>=o?"below":"above",a=s==="below"?e.bottom+i:e.top-i-t.height,l=Math.max(V,Math.min(a,n.height-V-t.height)),h=(e.left+e.right)/2,d=Math.max(V,Math.min(h-pl,n.width-V-t.width)),u=Math.max(14,Math.min(h-d,t.width-14));return{side:s,x:d,y:l,arrow:u}}function Q(e,t,n){e.style.setProperty(t,n,"important")}var rn=class{constructor(t,n){this.editor=t,this.mode=null,this.hidden=!1,this.frame=0,this.bar={width:0,height:0},this.rail={width:0,height:0};let i=t.element.ownerDocument;this.doc=i,this.win=i.defaultView||globalThis,this.root=i.createElement("div"),this.root.className="richclay-float",this.root.setAttribute("data-richclay-float",""),this.root.setAttribute("save-remove",""),ce(this.root),i.body.appendChild(this.root),this.toolbar=new st(t,n,{toolbarContainer:this.root}),this.onScroll=()=>this.schedule(),this.onResize=()=>{this.measure(),this.schedule()},i.addEventListener("scroll",this.onScroll,{capture:!0,passive:!0}),this.win.addEventListener("resize",this.onResize,{passive:!0}),this.win.visualViewport?.addEventListener("resize",this.onResize,{passive:!0}),this.win.visualViewport?.addEventListener("scroll",this.onScroll,{passive:!0}),this.resizeObserver=typeof this.win.ResizeObserver=="function"?new this.win.ResizeObserver(()=>this.schedule()):null,this.resizeObserver?.observe(t.element),this.measure(),this.reposition()}measure(){let t=this.root.classList.contains("richclay-float-rail");Q(this.root,"visibility","hidden"),this.root.classList.remove("richclay-float-rail"),this.bar={width:this.root.offsetWidth||0,height:this.root.offsetHeight||0},this.root.classList.add("richclay-float-rail"),this.rail={width:this.root.offsetWidth||0,height:this.root.offsetHeight||0},this.root.classList.toggle("richclay-float-rail",t),this.root.style.removeProperty("visibility")}schedule(){if(!this.win.requestAnimationFrame){this.reposition();return}this.frame||(this.frame=this.win.requestAnimationFrame(()=>{this.frame=0,this.reposition()}))}setVisible(t){this.hidden=!t,this.reposition()}reposition(){if(this.hidden){Q(this.root,"display","none");return}let t=this.editor.element.getBoundingClientRect(),n={width:this.win.visualViewport?.width??this.win.innerWidth,height:this.win.visualViewport?.height??this.win.innerHeight},i=dl({anchor:t,bar:this.bar,rail:this.rail,viewport:n,current:this.mode});if(this.mode=i.mode,i.mode==="hidden"){Q(this.root,"display","none");return}this.root.style.removeProperty("display"),this.root.classList.toggle("richclay-float-rail",i.mode==="rail-left"||i.mode==="rail-right"),this.root.classList.toggle("richclay-float-pinned",i.mode==="pinned"),Q(this.root,"transform",`translate(${Math.round(i.x)}px, ${Math.round(i.y)}px)`)}destroy(){this.frame&&this.win.cancelAnimationFrame?.(this.frame),this.frame=0,this.doc.removeEventListener("scroll",this.onScroll,{capture:!0}),this.win.removeEventListener("resize",this.onResize),this.win.visualViewport?.removeEventListener("resize",this.onResize),this.win.visualViewport?.removeEventListener("scroll",this.onScroll),this.resizeObserver?.disconnect(),this.toolbar.destroy(),this.root.remove()}};var ml={ALLOWED_TAGS:["a","b","blockquote","br","code","div","em","h1","h2","h3","h4","h5","h6","i","li","ol","p","pre","s","span","strong","sub","sup","u","ul"],ALLOWED_ATTR:["aria-label","href","rel","target","title"],ALLOW_DATA_ATTR:!1,ALLOW_ARIA_ATTR:!0,ALLOWED_URI_REGEXP:/^(?:(?:(?:f|ht)tps?|mailto|tel):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i,FORBID_TAGS:["script","style","iframe","object","embed","form","input"],FORBID_ATTR:["style","srcset","onerror","onclick","onload"]};function bo(e={},t=document){let n=sn(t);return{sanitizeHTML(i){return ui(i,e,t,n)},sanitizeElement(i){return di(i,e,n)},sanitizeToDOMFragment(i,r){let o=r?.getRoot?.().ownerDocument||t;return gl(i,e,o,n)}}}function ui(e,t={},n=document,i=sn(n)){let r=n.createElement("template");return r.innerHTML=i.sanitize(String(e||""),fi(t)),mi(r.content),r.innerHTML}function di(e,t={},n=sn(e.ownerDocument)){let r=e.ownerDocument.createElement("div");for(;e.firstChild;)r.appendChild(e.firstChild);for(n.sanitize(r,{...fi(t),IN_PLACE:!0}),mi(r);r.firstChild;)e.appendChild(r.firstChild);return e}function gl(e,t={},n=document,i=sn(n)){let r=i.sanitize(String(e||""),{...fi(t),RETURN_DOM_FRAGMENT:!0}),o=r?.ownerDocument===n?r:n.importNode(r,!0);return mi(o),o||n.createDocumentFragment()}function fi(e){return{...ml,...e}}var yl=new Set(["http","https","mailto","tel"]),bl=new RegExp("[\\u0000-\\u0020\\u007F-\\u009F]","g");function pi(e){let n=(String(e??"").replace(bl,"").match(/^([a-z][a-z0-9+.\-]*):/i)||[])[1];return!n||yl.has(n.toLowerCase())}var Tl=/^[^\s/?#:]+\.(?:html?|pdf|txt|csv|json|xml|svg|png|jpe?g|gif|webp|docx?|xlsx?|pptx?|bib|tex|zip)(?:[?#]\S*)?$/i,_l=/^[^\s/?#:.]+\/\S*$/;function To(e){let t=String(e??"").trim();return!t||!pi(t)?"":/^(?:https?:|mailto:|tel:)/i.test(t)?t:/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(t)?`mailto:${t}`:/^(?:[#?]|\/|\.{1,2}\/)/.test(t)||Tl.test(t)||_l.test(t)?t:`https://${t}`}function sn(e){let t=globalThis.DOMPurify;if(t?.sanitize)return t;if(typeof t=="function")return t(e.defaultView||globalThis);throw new Error("RichClay requires DOMPurify. Load vendor/purify.min.js before richclay.js or provide globalThis.DOMPurify.")}function mi(e){e.querySelectorAll?.("a[href]").forEach(t=>{let n=t.getAttribute("href")||"";if(/^\s*javascript:/i.test(n)&&t.removeAttribute("href"),t.getAttribute("target")==="_blank"){let i=new Set((t.getAttribute("rel")||"").split(/\s+/).filter(Boolean));i.add("noopener"),i.add("noreferrer"),t.setAttribute("rel",Array.from(i).join(" "))}})}var go={ADD_TAGS:["img"],ADD_ATTR:["class","id","src","alt","width","height"]};function _o(e={}){return{...e,ADD_TAGS:[...new Set([...go.ADD_TAGS,...e.ADD_TAGS||[]])],ADD_ATTR:[...new Set([...go.ADD_ATTR,...e.ADD_ATTR||[]])],ALLOW_DATA_ATTR:e.ALLOW_DATA_ATTR??!0}}var yo="p, div, h1, h2, h3, h4, h5, h6, blockquote, pre, ul, ol, li, figure, figcaption, table, thead, tbody, tr, td, th";function Eo(e){let t=e.ownerDocument||document;e.querySelectorAll?.("br").forEach(i=>i.replaceWith(t.createTextNode(" ")));let n=e.querySelector?.(yo);for(;n;){let i=n.parentNode;for(i.insertBefore(t.createTextNode(" "),n);n.firstChild;)i.insertBefore(n.firstChild,n);i.insertBefore(t.createTextNode(" "),n),n.remove(),n=e.querySelector(yo)}return El(e,t),e}function El(e,t){e.normalize?.();let n=t.createTreeWalker(e,4),i=[];for(;n.nextNode();)i.push(n.currentNode);i.forEach(s=>{s.nodeValue=s.nodeValue.replace(/\s+/g," ")});let r=e.firstChild;r?.nodeType===3&&(r.nodeValue=r.nodeValue.replace(/^\s+/,""));let o=e.lastChild;o?.nodeType===3&&(o.nodeValue=o.nodeValue.replace(/\s+$/,""))}var vl=300,Sl=e=>e.replace(/^mailto:/i,"").replace(/^https?:\/\//i,""),an=class{constructor(t){this.editor=t,this.root=null,this.anchor=null,this.href=null,this.dismissed=null,this.hideTimer=null,this.pointerInside=!1,this.cleanup=null}currentAnchor(){let t=this.editor;if(!t.active||t.options.readOnly||t.dialog)return null;let n=t.element.ownerDocument;if(n.hidden)return null;let i=n.getSelection?.();return!i||!i.rangeCount||!t.element.contains(i.anchorNode)?null:t.currentLinkElement()}update(){let t=this.currentAnchor();if(!(t&&t===this.dismissed)){if(this.dismissed=null,!t){this.scheduleHide();return}this.cancelHide(),this.show(t)}}show(t){this.root||this.mount();let n=t.getAttribute("href")||"";if(t!==this.anchor||n!==this.href){this.anchor=t,this.href=n;let i=this.root.querySelector(".richclay-link-address");i.textContent=Sl(n)||n,i.title=n,n&&pi(n)?i.setAttribute("href",n):i.removeAttribute("href"),/^(?:mailto|tel):/i.test(n)?i.removeAttribute("target"):i.setAttribute("target","_blank")}this.position()}mount(){let t=this.editor,n=t.element.ownerDocument,i=n.defaultView||globalThis,r=n.createElement("div");r.className="richclay-dialog richclay-link-popover",r.setAttribute("role","group"),r.setAttribute("aria-label","Link"),r.setAttribute("data-richclay-link-popover",""),ce(r),r.setAttribute("save-remove",""),r.innerHTML=`
25
25
  <a class="richclay-link-address" rel="noopener noreferrer"></a>
26
26
  <button type="button" class="richclay-secondary" data-richclay-link-edit>Edit</button>
27
27
  <button type="button" class="richclay-secondary" data-richclay-link-remove>Remove</button>