commspliant-html-editor 0.0.12 → 0.0.13

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs CHANGED
@@ -1,4 +1,4 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const i=require("react/jsx-runtime"),l=require("react"),Bc=require("react-dom");function Kb({className:e}){return i.jsxs("svg",{className:e,viewBox:"0 0 24 24",width:"16",height:"16",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true","data-icon":"audio",children:[i.jsx("path",{d:"M9 18V5l12-2v13"}),i.jsx("circle",{cx:"6",cy:"18",r:"3"}),i.jsx("circle",{cx:"18",cy:"16",r:"3"})]})}function es({className:e}){return i.jsxs("svg",{className:e,viewBox:"0 0 24 24",width:"16",height:"16",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true","data-icon":"align-center",children:[i.jsx("path",{d:"M4 6h16"}),i.jsx("path",{d:"M7 12h10"}),i.jsx("path",{d:"M4 18h16"})]})}function Hf({className:e}){return i.jsxs("svg",{className:e,viewBox:"0 0 24 24",width:"16",height:"16",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true","data-icon":"align-justify",children:[i.jsx("path",{d:"M4 6h16"}),i.jsx("path",{d:"M4 12h16"}),i.jsx("path",{d:"M4 18h16"})]})}function ts({className:e}){return i.jsxs("svg",{className:e,viewBox:"0 0 24 24",width:"16",height:"16",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true","data-icon":"align-left",children:[i.jsx("path",{d:"M4 6h16"}),i.jsx("path",{d:"M4 12h10"}),i.jsx("path",{d:"M4 18h16"})]})}function ns({className:e}){return i.jsxs("svg",{className:e,viewBox:"0 0 24 24",width:"16",height:"16",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true","data-icon":"align-right",children:[i.jsx("path",{d:"M4 6h16"}),i.jsx("path",{d:"M10 12h10"}),i.jsx("path",{d:"M4 18h16"})]})}function $b({className:e}){return i.jsxs("svg",{className:e,viewBox:"0 0 24 24",width:"16",height:"16",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true","data-icon":"bold",children:[i.jsx("path",{d:"M7 5h6.5a3.5 3.5 0 0 1 0 7H7z"}),i.jsx("path",{d:"M7 12h7.5a3.5 3.5 0 0 1 0 7H7z"}),i.jsx("path",{d:"M7 5v14"})]})}function Ub({className:e}){return i.jsx("svg",{className:e,viewBox:"0 0 24 24",width:"16",height:"16",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true","data-icon":"bookmark",children:i.jsx("path",{d:"M6 4h12a1 1 0 0 1 1 1v16l-7-4-7 4V5a1 1 0 0 1 1-1z"})})}function zf({className:e}){return i.jsxs("svg",{className:e,viewBox:"0 0 24 24",width:"16",height:"16",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true","data-icon":"bullet-list",children:[i.jsx("path",{d:"M9 6h12"}),i.jsx("path",{d:"M9 12h12"}),i.jsx("path",{d:"M9 18h12"}),i.jsx("circle",{cx:"4.5",cy:"6",r:"1.2",fill:"currentColor",stroke:"none"}),i.jsx("circle",{cx:"4.5",cy:"12",r:"1.2",fill:"currentColor",stroke:"none"}),i.jsx("circle",{cx:"4.5",cy:"18",r:"1.2",fill:"currentColor",stroke:"none"})]})}function Vb({className:e}){return i.jsxs("svg",{className:e,viewBox:"0 0 24 24",width:"16",height:"16",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true","data-icon":"cell-properties",children:[i.jsx("rect",{x:"3",y:"4",width:"18",height:"16",rx:"1"}),i.jsx("path",{d:"M3 12h18"}),i.jsx("path",{d:"M12 4v16"}),i.jsx("rect",{x:"12.5",y:"4.5",width:"8",height:"7",fill:"currentColor",stroke:"none",opacity:"0.25"})]})}function Wb({className:e}){return i.jsxs("svg",{className:e,viewBox:"0 0 24 24",width:"16",height:"16",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true","data-icon":"clear-formatting",children:[i.jsx("path",{d:"M4 5h12"}),i.jsx("path",{d:"M10 5v8"}),i.jsx("path",{d:"m14 15 6 6"}),i.jsx("path",{d:"m20 15-6 6"})]})}function et({className:e}){return i.jsxs("svg",{className:e,viewBox:"0 0 24 24",width:"16",height:"16",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true","data-icon":"close",children:[i.jsx("path",{d:"M18 6L6 18"}),i.jsx("path",{d:"M6 6l12 12"})]})}function ym({className:e}){return i.jsx("svg",{className:e,viewBox:"0 0 24 24",width:"16",height:"16",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true","data-icon":"comment",children:i.jsx("path",{d:"M21 15a4 4 0 0 1-4 4H8l-5 3V7a4 4 0 0 1 4-4h10a4 4 0 0 1 4 4z"})})}function Gb({className:e}){return i.jsxs("svg",{className:e,viewBox:"0 0 24 24",width:"16",height:"16",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true","data-icon":"comments-visible",children:[i.jsx("path",{d:"M21 15a4 4 0 0 1-4 4H8l-5 3V7a4 4 0 0 1 4-4h10a4 4 0 0 1 4 4z"}),i.jsx("path",{d:"M8 9h8M8 13h5"})]})}function Zb({className:e}){return i.jsx("svg",{className:e,viewBox:"0 0 616.23 542.09",width:"45",height:"40","aria-hidden":"true","data-icon":"commspliant-shield",children:i.jsxs("g",{transform:"translate(129.79555,688.75474)",children:[i.jsx("path",{fill:"#334E68",d:"m 92.41768,-326.31771 a 0.3,0.3 0 0 1 0.48,0.05 q 5.04,8.55 15.34,22.7 5.5,7.55 11.93,14.77 11.84,13.3 12.69,14.16 11.29,11.41 26.17,23.51 c 4.66,3.79 9.84,8.83 15.07,12.39 18.71,12.72 34.7,23.08 52.84,31.97 q 15.29,7.5 16.67,8.12 5.77,2.59 8.73,3.54 c 1.66,0.54 2.74,-0.25 4.17,-0.93 q 27.98,-13.14 49.38,-25.74 21.15,-12.47 41.94,-29.56 1.28,-1.05 12.72,-11.11 c 11.11,-9.78 22.59,-22.12 30.48,-31.94 q 10.87,-13.52 16.67,-23.55 c 3.7,-6.41 7.66,-12.73 10.29,-18.63 q 9.41,-21.06 13.67,-35.18 8.51,-28.19 9.46,-61.31 0.96,-33.72 0.31,-64.55 -0.09,-4.4 2.81,-7.26 5.42,-5.33 7.5,-7.38 c 6.37,-6.25 11.24,-13.29 18.07,-19.23 q 7.84,-6.84 14.74,-16.11 0.14,-0.19 0.39,-0.15 0.61,0.1 0.52,0.7 -0.37,2.69 -0.35,4.95 c 0.37,45.85 0.81,76.35 -0.95,110.71 q -0.66,12.89 -2.71,28.52 -2.84,21.57 -7.17,36.03 -2.02,6.75 -5.4,17.5 c -5.64,17.94 -13.55,35.09 -23.13,50.9 q -1.72,2.86 -12.91,19.22 c -10.81,15.81 -22.83,29.61 -35.06,41.83 q -4.06,4.07 -17.47,16.38 -9.77,8.98 -18.52,15.14 -19.27,13.56 -32.8,21.84 c -8.27,5.05 -17.73,9.75 -26.22,14.7 q -3.66,2.13 -10.7,5.47 -27.19,12.89 -34.36,16.16 -3.92,1.79 -7.2,0.44 -3.47,-1.43 -11.46,-4.85 c -9.07,-3.89 -16.98,-8.27 -24.9,-11.89 -8.4,-3.84 -18.78,-9.89 -28.06,-15.14 q -43.25,-24.5 -76.54,-56.22 -11.98,-11.41 -24.94,-26.56 -12.76,-14.92 -26.13,-34.48 a 0.43,0.44 56.8 0 1 0.13,-0.61 c 12.12,-7.82 23.12,-17.82 33.81,-29.32 z"}),i.jsx("path",{fill:"#334E68",d:"m -128.82232,-375.77771 a 0.96,0.96 0 0 1 -0.8,-1.51 l 28.86,-41.82 a 3.24,3.2 6.2 0 1 1.45,-1.15 q 0.69,-0.27 3.64,-0.32 15.37,-0.27 46.58,-0.45 12.44,-0.07 19.69,-1.84 c 26.32,-6.42 44.55,-29.39 47.76,-55.67 q 1.05,-8.54 0.87,-20.92 c -0.55,-39.95 0.23,-77.15 -0.1,-117.57 a 0.94,0.95 85.4 0 1 0.81,-0.94 c 35.7,-5.08 70.26,-12.78 104.11,-23.86 q 9.4,-3.07 22.28,-7.05 8.6,-2.65 22.1,-7.58 18.33,-6.69 43.02,-16.74 23.04,-9.38 35.12,-15.34 1.17,-0.58 3.29,0.39 c 14.96,6.81 34.27,13.39 42.79,16.68 q 14.24,5.5 27.59,10.33 23.24,8.41 27.7,10.07 2.01,0.75 9.42,3.41 5.07,1.82 9.47,3.13 40.54,12.1 57.07,16.58 2.54,0.68 4.26,0.82 a 0.48,0.48 0 0 1 0.32,0.79 l -33.68,37.82 a 0.58,0.58 0 0 1 -0.68,0.13 q -3.43,-1.67 -5.84,-2.43 -8.74,-2.79 -47.37,-15.63 -8.92,-2.96 -17.51,-6.16 c -17.92,-6.67 -32.21,-11.74 -65.83,-24.24 -2.89,-1.08 -8.28,-3.56 -11.57,-2.33 -11.44,4.27 -27.67,11.24 -40.6,15.93 q -8.12,2.94 -26.33,9.89 c -21.86,8.35 -43.57,14.34 -67.25,21.47 q -20.07,6.03 -48.78,11.52 a 0.71,0.7 84.6 0 0 -0.57,0.7 q 0.1,95.52 0.1,95.57 c -0.53,30.1 -14.63,58.57 -36,79.25 -10.83,10.49 -23.5,17.98 -37.57,23.68 -10.14,4.1 -18.76,4.57 -31.18,4.79 q -3.1,0.05 -86.64,0.6 z"}),i.jsx("path",{fill:"#C9A227",d:"m 169.86768,-422.45771 q 0.04,-0.4 0.24,-0.59 c 3.41,-3.3 5.96,-6.99 9.56,-10.8 q 10.13,-10.72 15.25,-16.65 2.05,-2.38 5.38,-4.3 a 0.68,0.69 53.4 0 1 0.84,0.12 l 49.51,50.92 a 1.06,1.06 0 0 0 1.52,0 q 17.38,-17.8 26.4,-27.94 c 6.36,-7.14 15.04,-14.76 20.1,-20.56 q 10.29,-11.81 17.14,-18.67 7.41,-7.41 17.44,-18.41 13.85,-15.18 23.56,-24.67 c 3.68,-3.59 5.5,-6.17 8.54,-10.08 2.38,-3.06 4.42,-4.87 8.16,-8.31 6.16,-5.66 10.48,-11.49 16.47,-17.22 6.29,-6.03 12.87,-14.23 18.87,-20.24 q 5.56,-5.56 13.49,-14.45 c 6.79,-7.6 12.13,-13.02 18.46,-19.66 4.83,-5.06 9.88,-11.22 15.21,-16.21 a 1.91,1.91 0 0 1 1.3,-0.51 h 28.15 a 0.83,0.83 0 0 1 0.83,0.82 q 0.28,14.3 0.03,31.53 c -0.07,4.93 -1.9,6.19 -5.19,9.51 -5.86,5.92 -12.79,12.1 -18.21,18.16 q -6.63,7.4 -16.64,16.86 c -2.68,2.53 -6.31,6.91 -8.5,9.17 -8.76,9.01 -14.72,16.05 -22.55,23.36 q -1.37,1.28 -9.09,9.75 -4.93,5.41 -24.32,25.01 c -9.96,10.07 -19.18,20.45 -27.83,28.95 q -11.52,11.33 -20.29,20.96 c -19.16,21.01 -41.14,42.93 -58.64,61.61 q -10.7,11.42 -22.21,22 a 1.97,1.94 24 0 1 -1.38,0.52 q -1.9,-0.06 -3.83,-2.08 c -19.01,-19.93 -45.74,-44.39 -67.08,-67.5 q -5.05,-5.47 -10.42,-9.75 -0.31,-0.24 -0.27,-0.65 z"}),i.jsx("path",{fill:"#5B7B9C",d:"m 351.58768,-544.71771 a 0.41,0.41 0 0 1 0.17,0.69 q -15.9,15.29 -29.64,31.76 a 1.16,1.19 33.7 0 1 -1.44,0.3 c -5.87,-3 -10.72,-6.65 -16.97,-10.42 -17.2,-10.37 -38.83,-14.16 -59.18,-13.16 -12.15,0.6 -23.67,3.62 -34.54,8.11 -5.15,2.13 -9.08,4.66 -14.86,8.63 q -14.63,10.05 -22.02,17.75 -6.98,7.27 -17.47,22.45 c -5.11,7.4 -9.03,15.18 -13.55,23.27 q -5.09,9.08 -10.38,20.93 c -4.39,9.81 -8.53,17.45 -13.72,27.5 q -6,11.58 -11.58,19.91 c -6.74,10.09 -11.32,17.91 -17.68,26.12 -4.94,6.38 -10.92,12.4 -15.22,17.55 q -3.48,4.18 -9.33,9.51 c -20.66,18.83 -45.19,33.15 -72.9,38.24 q -15.17,2.79 -26.21,3.08 -22.84,0.6 -52.01,0.23 a 0.29,0.29 0 0 1 -0.24,-0.43 c 6.02,-10.58 11.85,-19.61 23.29,-37.61 q 2.27,-3.58 5.02,-6.38 a 3.39,3.4 24.3 0 1 2.63,-1 q 16.4,1.07 32.77,-1.23 c 15.39,-2.16 29.33,-7.66 42.1,-15.59 q 4.42,-2.75 14.17,-10.6 3.58,-2.89 14.27,-14.03 6.08,-6.33 9.69,-12.1 c 3.25,-5.19 7.59,-10.59 11.55,-17.24 q 16.77,-28.19 29.52,-56.84 c 4.49,-10.08 8.7,-16.87 15.5,-28.37 q 5.49,-9.29 14.18,-21.09 5.94,-8.07 12.61,-14.76 12.65,-12.7 13.8,-13.72 5.51,-4.84 19.01,-13.66 49.89,-32.59 109.07,-20.31 7.95,1.65 15.41,4.34 14.58,5.25 20.68,8.05 c 10.41,4.78 21.11,12.36 31.15,19.28 a 2.65,2.62 70.1 0 0 0.78,0.37 z"}),i.jsx("path",{fill:"#5B7B9C",d:"m 143.16768,-394.65771 q 0.46,0.11 0.45,0.6 -0.03,2.2 0.62,4.89 2.72,11.27 9.81,22.88 7.25,11.89 15.4,22.7 c 4.71,6.26 10.61,13.06 17.11,18.9 9.38,8.42 15.79,14.58 25.02,21.29 q 13.29,9.65 15.1,10.72 10.62,6.29 20.67,12.58 1.94,1.22 4,1.86 a 2.56,2.59 42.2 0 0 1.81,-0.1 c 7.1,-3.08 12.92,-6.7 21.76,-11.78 q 6.63,-3.81 11.42,-7.45 c 4.56,-3.47 9.98,-6.63 14.83,-10.52 q 18.45,-14.82 32.58,-32 6.8,-8.28 11.17,-16.16 c 7.76,-14.01 13.11,-25.52 16.26,-40.82 1.49,-7.23 1.56,-11.99 2.41,-21.26 a 3.66,3.67 70 0 1 1.06,-2.26 q 9.34,-9.27 20.72,-20.12 c 6.47,-6.15 12.23,-13.51 18.33,-19.07 a 0.67,0.67 0 0 1 1.11,0.43 q 1.92,19.96 1.77,37.52 -0.18,19.95 -4.43,40.76 -3.4,16.65 -11.34,32.24 -0.55,1.09 -4.75,9.06 -3,5.69 -5.08,8.85 c -9.56,14.55 -19.75,27.73 -31.99,39.39 q -7.6,7.24 -9.98,9.35 -10.58,9.37 -24.17,18.04 c -4.91,3.14 -9.19,7.11 -13.77,9.89 q -24.03,14.58 -42.68,23.19 -3.32,1.53 -8.02,-0.31 -1.97,-0.78 -11.41,-5.19 c -8.92,-4.17 -16.04,-8.65 -24.58,-13.03 q -6.75,-3.47 -13.06,-7.8 -18.87,-12.96 -21.03,-14.68 -15.47,-12.4 -29.21,-26.05 -5.39,-5.35 -13.86,-16.13 -6.45,-8.2 -14.56,-19.38 c -3.42,-4.72 -6.19,-10.2 -9.49,-14.45 a 1.33,1.32 44.2 0 1 -0.03,-1.59 c 5.8,-7.95 10.64,-13.7 15.23,-21.14 q 8.66,-14.03 14.39,-23.68 a 0.38,0.39 23.4 0 1 0.41,-0.17 z"})]})})}function qb({className:e}){return i.jsxs("svg",{className:e,viewBox:"0 0 24 24",width:"16",height:"16",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true","data-icon":"custom-action",children:[i.jsx("rect",{x:"4",y:"4",width:"16",height:"16",rx:"2"}),i.jsx("path",{d:"M9 8.5c0-1 .7-1.5 1.5-1.5S12 7.5 12 8.5c0 1.2-3 1.2-3 3.2"}),i.jsx("path",{d:"M10.5 14v.5"}),i.jsx("path",{d:"M15 10v4"}),i.jsx("path",{d:"M13 12h4"})]})}function Yb({className:e}){return i.jsxs("svg",{className:e,viewBox:"0 0 24 24",width:"16",height:"16",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true","data-icon":"custom-css",children:[i.jsx("path",{d:"M8 6h12"}),i.jsx("path",{d:"M8 12h12"}),i.jsx("path",{d:"M8 18h8"}),i.jsx("path",{d:"M4 6h.01"}),i.jsx("path",{d:"M4 12h.01"}),i.jsx("path",{d:"M4 18h.01"})]})}function Xb({className:e}){return i.jsxs("svg",{className:e,viewBox:"0 0 24 24",width:"16",height:"16",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true","data-icon":"customize-toolbar",children:[i.jsx("rect",{x:"3",y:"4",width:"7",height:"7",rx:"1"}),i.jsx("rect",{x:"14",y:"4",width:"7",height:"7",rx:"1"}),i.jsx("rect",{x:"3",y:"13",width:"7",height:"7",rx:"1"}),i.jsx("rect",{x:"14",y:"13",width:"7",height:"7",rx:"1"})]})}function Jb({className:e}){return i.jsx("svg",{className:e,viewBox:"0 0 24 24",width:"16",height:"16",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true","data-icon":"dark-mode",children:i.jsx("path",{d:"M21 14.5A8.5 8.5 0 1 1 9.5 3 7 7 0 0 0 21 14.5z"})})}function Of({className:e}){return i.jsxs("svg",{className:e,viewBox:"0 0 24 24",width:"16",height:"16",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true","data-icon":"font-color",children:[i.jsx("path",{d:"M6 18L12 4l6 14"}),i.jsx("path",{d:"M8.5 13h7"})]})}function Qb({className:e}){return i.jsxs("svg",{className:e,viewBox:"0 0 24 24",width:"16",height:"16",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true","data-icon":"font-family",children:[i.jsx("path",{d:"M4 18L9 6l5 12"}),i.jsx("path",{d:"M6.2 13h5.6"}),i.jsx("path",{d:"M16 18V9"}),i.jsx("path",{d:"M16 9h5"})]})}function ey({className:e}){return i.jsxs("svg",{className:e,viewBox:"0 0 24 24",width:"16",height:"16",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true","data-icon":"font-properties",children:[i.jsx("path",{d:"M4 20h4"}),i.jsx("path",{d:"M6 20V6"}),i.jsx("path",{d:"M4 6h4"}),i.jsx("path",{d:"M12 20V9"}),i.jsx("path",{d:"M12 9h8"}),i.jsx("path",{d:"M16 9v11"})]})}function ty({className:e}){return i.jsxs("svg",{className:e,viewBox:"0 0 24 24",width:"16",height:"16",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true","data-icon":"font-size",children:[i.jsx("path",{d:"M4 18V8h3"}),i.jsx("path",{d:"M4 8h8"}),i.jsx("path",{d:"M10 8v10"}),i.jsx("path",{d:"M16 18V12h2"}),i.jsx("path",{d:"M16 12h5"}),i.jsx("path",{d:"M19 12v6"})]})}function ny({className:e}){return i.jsxs("svg",{className:e,viewBox:"0 0 24 24",width:"16",height:"16",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true","data-icon":"format-brush",children:[i.jsx("path",{d:"m9.06 11.9 8.07-8.06a2.85 2.85 0 1 1 4.03 4.03l-8.06 8.08"}),i.jsx("path",{d:"M7.07 14.94c-1.66 0-3 1.34-3 3v2.06h2.06c1.66 0 3-1.34 3-3v-2.06Z"}),i.jsx("path",{d:"M7.07 14.94 4.01 18"})]})}function ry({className:e}){return i.jsxs("svg",{className:e,viewBox:"0 0 24 24",width:"16",height:"16",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true","data-icon":"fullscreen",children:[i.jsx("path",{d:"M8 3H5a2 2 0 0 0-2 2v3"}),i.jsx("path",{d:"M21 8V5a2 2 0 0 0-2-2h-3"}),i.jsx("path",{d:"M3 16v3a2 2 0 0 0 2 2h3"}),i.jsx("path",{d:"M16 21h3a2 2 0 0 0 2-2v-3"})]})}function Tl({className:e}){return i.jsxs("svg",{className:e,viewBox:"0 0 24 24",width:"16",height:"16",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true","data-icon":"help",children:[i.jsx("circle",{cx:"12",cy:"12",r:"10"}),i.jsx("path",{d:"M9.09 9a3 3 0 0 1 5.83 1c0 2-3 3-3 3"}),i.jsx("path",{d:"M12 17h.01"})]})}function Kf({className:e}){return i.jsxs("svg",{className:e,viewBox:"0 0 24 24",width:"16",height:"16",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true","data-icon":"highlight-color",children:[i.jsx("path",{d:"M15.5 4.5l4 4-9 9H6.5v-4.5z"}),i.jsx("path",{d:"M13.5 6.5l4 4"}),i.jsx("path",{d:"M4 20h8"})]})}function oy({className:e}){return i.jsx("svg",{className:e,viewBox:"0 0 24 24",width:"16",height:"16",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true","data-icon":"horizontalRule",children:i.jsx("path",{d:"M4 12h16"})})}function iy({className:e}){return i.jsxs("svg",{className:e,viewBox:"0 0 24 24",width:"16",height:"16",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true","data-icon":"html",children:[i.jsx("path",{d:"M8 8l-4 4 4 4"}),i.jsx("path",{d:"M16 8l4 4-4 4"})]})}function $f({className:e}){return i.jsxs("svg",{className:e,viewBox:"0 0 24 24",width:"16",height:"16",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true","data-icon":"image",children:[i.jsx("rect",{x:"3",y:"5",width:"18",height:"14",rx:"2"}),i.jsx("circle",{cx:"8.5",cy:"10",r:"1.5"}),i.jsx("path",{d:"m21 15-4.5-4.5L7 20"})]})}function ay({className:e}){return i.jsxs("svg",{className:e,viewBox:"0 0 24 24",width:"16",height:"16",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true","data-icon":"indent",children:[i.jsx("path",{d:"M4 6h16"}),i.jsx("path",{d:"M12 12h8"}),i.jsx("path",{d:"M4 18h16"}),i.jsx("path",{d:"M4 9l4 3-4 3"})]})}function sy({className:e}){return i.jsxs("svg",{className:e,viewBox:"0 0 24 24",width:"16",height:"16",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true","data-icon":"italic",children:[i.jsx("path",{d:"M10 4h9"}),i.jsx("path",{d:"M5 20h9"}),i.jsx("path",{d:"M14 4L8 20"})]})}function ly({className:e}){return i.jsxs("svg",{className:e,viewBox:"0 0 24 24",width:"16",height:"16",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true","data-icon":"light-mode",children:[i.jsx("circle",{cx:"12",cy:"12",r:"4"}),i.jsx("path",{d:"M12 2v2"}),i.jsx("path",{d:"M12 20v2"}),i.jsx("path",{d:"M4.93 4.93l1.41 1.41"}),i.jsx("path",{d:"M17.66 17.66l1.41 1.41"}),i.jsx("path",{d:"M2 12h2"}),i.jsx("path",{d:"M20 12h2"}),i.jsx("path",{d:"M4.93 19.07l1.41-1.41"}),i.jsx("path",{d:"M17.66 6.34l1.41-1.41"})]})}function cy({className:e}){return i.jsxs("svg",{className:e,viewBox:"0 0 24 24",width:"16",height:"16",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true","data-icon":"link",children:[i.jsx("path",{d:"M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71"}),i.jsx("path",{d:"M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71"})]})}function uy({className:e}){return i.jsxs("svg",{className:e,viewBox:"0 0 24 24",width:"16",height:"16",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true","data-icon":"menu",children:[i.jsx("path",{d:"M4 6h16"}),i.jsx("path",{d:"M4 12h16"}),i.jsx("path",{d:"M4 18h16"})]})}function dy({className:e}){return i.jsxs("svg",{className:e,viewBox:"0 0 24 24",width:"16",height:"16",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true","data-icon":"merge-cells",children:[i.jsx("rect",{x:"3",y:"4",width:"18",height:"16",rx:"1"}),i.jsx("path",{d:"M3 12h5"}),i.jsx("path",{d:"M16 12h5"}),i.jsx("path",{d:"M12 4v16"}),i.jsx("path",{d:"M9 9l3 3-3 3"}),i.jsx("path",{d:"M15 9l-3 3 3 3"})]})}function Uf({className:e}){return i.jsxs("svg",{className:e,viewBox:"0 0 24 24",width:"16",height:"16",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true","data-icon":"numbered-list",children:[i.jsx("path",{d:"M10 6h11"}),i.jsx("path",{d:"M10 12h11"}),i.jsx("path",{d:"M10 18h11"}),i.jsx("path",{d:"M4 5v3h2"}),i.jsx("path",{d:"M4 11h2l-2 2h2"}),i.jsx("path",{d:"M4 19h2"}),i.jsx("path",{d:"M4 17h2v2"})]})}function my({className:e}){return i.jsxs("svg",{className:e,viewBox:"0 0 24 24",width:"16",height:"16",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true","data-icon":"open",children:[i.jsx("path",{d:"M3 7h6l2 2h10v3"}),i.jsx("path",{d:"M3 10l2.2 9h13.6L21 10H3z"})]})}function fy({className:e}){return i.jsxs("svg",{className:e,viewBox:"0 0 24 24",width:"16",height:"16",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true","data-icon":"outdent",children:[i.jsx("path",{d:"M4 6h16"}),i.jsx("path",{d:"M12 12h8"}),i.jsx("path",{d:"M4 18h16"}),i.jsx("path",{d:"M8 9l-4 3 4 3"})]})}function py({className:e}){return i.jsxs("svg",{className:e,viewBox:"0 0 24 24",width:"16",height:"16",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true","data-icon":"pageBreak",children:[i.jsx("path",{d:"M4 10h16",strokeDasharray:"3 2"}),i.jsx("path",{d:"M14 10v8"}),i.jsx("path",{d:"M18 14h4v4h-4z"})]})}function zo({className:e}){return i.jsxs("svg",{className:e,viewBox:"0 0 24 24",width:"16",height:"16",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true","data-icon":"page-properties",children:[i.jsx("path",{d:"M6 3h8l6 6v12H6z"}),i.jsx("path",{d:"M14 3v6h6"})]})}function Vf({className:e}){return i.jsxs("svg",{className:e,viewBox:"0 0 24 24",width:"16",height:"16",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true","data-icon":"paragraph-properties",children:[i.jsx("path",{d:"M13 4H9a4 4 0 0 0 0 8h2"}),i.jsx("path",{d:"M15 4v16"}),i.jsx("path",{d:"M11 4v16"})]})}function gy({className:e}){return i.jsxs("svg",{className:e,viewBox:"0 0 24 24",width:"16",height:"16",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true","data-icon":"preview",children:[i.jsx("path",{d:"M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"}),i.jsx("path",{d:"M14 2v6h6"}),i.jsx("path",{d:"M8 13h8"}),i.jsx("path",{d:"M8 17h5"})]})}function hy({className:e}){return i.jsxs("svg",{className:e,viewBox:"0 0 24 24",width:"16",height:"16",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true","data-icon":"paragraph-style",children:[i.jsx("path",{d:"M5 6h14"}),i.jsx("path",{d:"M5 10h10"}),i.jsx("path",{d:"M5 14h14"}),i.jsx("path",{d:"M5 18h8"})]})}function by({className:e}){return i.jsxs("svg",{className:e,viewBox:"0 0 24 24",width:"16",height:"16",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true","data-icon":"plus",children:[i.jsx("path",{d:"M12 5v14"}),i.jsx("path",{d:"M5 12h14"})]})}function yy({className:e}){return i.jsxs("svg",{className:e,viewBox:"0 0 24 24",width:"16",height:"16",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true","data-icon":"print",children:[i.jsx("path",{d:"M6 9V3h12v6"}),i.jsx("path",{d:"M6 18H4a2 2 0 0 1-2-2v-5a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2v5a2 2 0 0 1-2 2h-2"}),i.jsx("path",{d:"M6 14h12v8H6z"})]})}function xy({className:e}){return i.jsxs("svg",{className:e,viewBox:"0 0 24 24",width:"16",height:"16",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true","data-icon":"read-aloud",children:[i.jsx("path",{d:"M11 5L6 9H2v6h4l5 4V5z"}),i.jsx("path",{d:"M15.54 8.46a5 5 0 0 1 0 7.07"}),i.jsx("path",{d:"M19.07 4.93a10 10 0 0 1 0 14.14"})]})}function Cy({className:e}){return i.jsxs("svg",{className:e,viewBox:"0 0 24 24",width:"16",height:"16",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true","data-icon":"redo",children:[i.jsx("path",{d:"M21 10H10a5 5 0 0 0 0 10h1"}),i.jsx("path",{d:"M17 6l4 4-4 4"})]})}function wy({className:e}){return i.jsxs("svg",{className:e,viewBox:"0 0 24 24",width:"16",height:"16",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true","data-icon":"row-properties",children:[i.jsx("rect",{x:"3",y:"4",width:"18",height:"16",rx:"1"}),i.jsx("path",{d:"M3 10h18"}),i.jsx("path",{d:"M3 16h18"}),i.jsx("rect",{x:"3.5",y:"4.5",width:"17",height:"5",fill:"currentColor",stroke:"none",opacity:"0.25"})]})}function vy({className:e}){return i.jsxs("svg",{className:e,viewBox:"0 0 24 24",width:"16",height:"16",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true","data-icon":"ruler",children:[i.jsx("path",{d:"M4 8h16"}),i.jsx("path",{d:"M4 16h16"}),i.jsx("path",{d:"M6 8v8"}),i.jsx("path",{d:"M10 8v4"}),i.jsx("path",{d:"M14 8v6"}),i.jsx("path",{d:"M18 8v8"})]})}function ky({className:e}){return i.jsxs("svg",{className:e,viewBox:"0 0 24 24",width:"16",height:"16",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true","data-icon":"save",children:[i.jsx("path",{d:"M5 3h11l5 5v13H5V3z"}),i.jsx("path",{d:"M15 3v6H9V3"}),i.jsx("path",{d:"M8 21v-7h8v7"})]})}function Rl({className:e}){return i.jsxs("svg",{className:e,viewBox:"0 0 24 24",width:"16",height:"16",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true","data-icon":"table-column",children:[i.jsx("rect",{x:"3",y:"4",width:"18",height:"16",rx:"1"}),i.jsx("path",{d:"M3 10h18"}),i.jsx("path",{d:"M3 16h18"}),i.jsx("path",{d:"M9 4v16"}),i.jsx("path",{d:"M15 4v16"}),i.jsx("rect",{x:"9.5",y:"5",width:"5",height:"14",fill:"currentColor",stroke:"none",opacity:"0.25"})]})}function xm({className:e}){return i.jsxs("svg",{className:e,viewBox:"0 0 24 24",width:"16",height:"16",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true","data-icon":"table",children:[i.jsx("rect",{x:"3",y:"4",width:"18",height:"16",rx:"1"}),i.jsx("path",{d:"M3 10h18"}),i.jsx("path",{d:"M3 16h18"}),i.jsx("path",{d:"M9 4v16"}),i.jsx("path",{d:"M15 4v16"})]})}function Dl({className:e}){return i.jsxs("svg",{className:e,viewBox:"0 0 24 24",width:"16",height:"16",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true","data-icon":"table-row",children:[i.jsx("rect",{x:"3",y:"4",width:"18",height:"16",rx:"1"}),i.jsx("path",{d:"M3 10h18"}),i.jsx("path",{d:"M3 16h18"}),i.jsx("rect",{x:"4",y:"10.5",width:"16",height:"5",fill:"currentColor",stroke:"none",opacity:"0.25"})]})}function Sy({className:e}){return i.jsxs("svg",{className:e,viewBox:"0 0 24 24",width:"16",height:"16",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true","data-icon":"strikethrough",children:[i.jsx("path",{d:"M6 7.5C6 5.5 8 4 12 4s6 1.5 6 3.5-1.8 2.8-6 3.5"}),i.jsx("path",{d:"M6 16.5C6 18.5 8 20 12 20s6-1.5 6-3.5c0-1-.5-1.8-1.8-2.5"}),i.jsx("path",{d:"M4 12h16"})]})}function Ay({className:e}){return i.jsxs("svg",{className:e,viewBox:"0 0 24 24",width:"16",height:"16",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true","data-icon":"underline",children:[i.jsx("path",{d:"M7 4v8a5 5 0 0 0 10 0V4"}),i.jsx("path",{d:"M5 20h14"})]})}function Py({className:e}){return i.jsxs("svg",{className:e,viewBox:"0 0 24 24",width:"16",height:"16",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true","data-icon":"undo",children:[i.jsx("path",{d:"M3 10h11a5 5 0 0 1 0 10h-1"}),i.jsx("path",{d:"M7 6L3 10l4 4"})]})}function Ty({className:e}){return i.jsxs("svg",{className:e,viewBox:"0 0 24 24",width:"16",height:"16",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true","data-icon":"unmerge-cells",children:[i.jsx("rect",{x:"3",y:"4",width:"18",height:"16",rx:"1"}),i.jsx("path",{d:"M12 4v16"}),i.jsx("path",{d:"M3 12h18"}),i.jsx("path",{d:"M9 9l-3 3 3 3"}),i.jsx("path",{d:"M15 9l3 3-3 3"})]})}function Ry({className:e}){return i.jsxs("svg",{className:e,viewBox:"0 0 24 24",width:"16",height:"16",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true","data-icon":"visual",children:[i.jsx("path",{d:"M2 12s4-7 10-7 10 7 10 7-4 7-10 7S2 12 2 12z"}),i.jsx("circle",{cx:"12",cy:"12",r:"3"})]})}function Dy({className:e}){return i.jsxs("svg",{className:e,viewBox:"0 0 24 24",width:"16",height:"16",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true","data-icon":"youtube",children:[i.jsx("rect",{x:"2",y:"5",width:"20",height:"14",rx:"3"}),i.jsx("path",{d:"m10 9 6 3-6 3V9Z",fill:"currentColor",stroke:"none"})]})}const Ce="---";function On(e){return e===Ce}function Kn(e){return typeof e=="object"&&e!==null&&"submenu"in e}const Fc=new Set(["save","open","print","undo","redo","link","bookmark","horizontalRule","pageBreak","insertPageBefore","insertPageAfter","deletePage","visual","html","customizeToolbar","toolbarPositionTop","toolbarPositionLeft","toolbarPositionRight","toolbarPositionBottom","lightMode","darkMode","preview","readAloud","fullscreen","bold","italic","underline","strikethrough","clearFormatting","formatBrush","fontSize","fontFamily","paragraphStyle","fontProperties","customCss","paragraphProperties","pageProperties","imageProperties","fontColor","highlightColor","alignLeft","alignCenter","alignRight","alignJustify","indent","outdent","bulletList","numberedList","table","insertRowBelow","insertRowBefore","deleteRow","insertColumnAfter","insertColumnBefore","deleteColumn","mergeCells","unmergeCells","tableProperties","cellProperties","rowProperties"]),jy=new Set(["file","edit","view","insert","format","table","help"]),Wf="custom",Gf="custom";function Zf(e){return`custom:${e}`}function Iy(e){return e==="menu"||e==="both"}function Ey(e){return e==="toolbar"||e==="both"}function qf(e){return e.map(t=>Kn(t)?{submenu:t.submenu,items:qf(t.items)}:t)}function _y(e){return{menus:e.menus.map(t=>({id:t.id,items:qf(t.items)})),iconGroups:e.iconGroups.map(t=>({id:t.id,items:[...t.items]}))}}function Yf(e){return On(e)?!0:Kn(e)?e.items.every(Yf):Fc.has(e)}function Xf(e,t){for(const n of e)if(n===t||Kn(n)&&Xf(n.items,t))return!0;return!1}function My(e){const t=e.tooltip??e.label;return{id:e.id,command:Zf(e.id),icon:e.icon??qb,label:e.label,ariaLabel:e.label,tooltip:t}}function Ny(e,t,n,r){if(e.menus[n])r&&!e.menus[n].label&&!jy.has(n)&&(e.menus[n]={...e.menus[n],label:r,ariaLabel:r});else if(n===Wf&&!r)e.menus[n]={id:n,labelKey:"menuCustom",ariaKey:"menuCustomAria"};else{const o=r??n;e.menus[n]={id:n,label:o,ariaLabel:o}}t.menus.some(o=>o.id===n)||t.menus.push({id:n,items:[]})}function Ly(e,t,n){if(e.groups[n]||(n===Gf?e.groups[n]={id:n,labelKey:"toolbarGroupCustom"}:e.groups[n]={id:n,label:n}),!t.iconGroups.some(r=>r.id===n)){const r={id:n,items:[]},o=t.iconGroups.findIndex(a=>a.items.includes("fullscreen"));o===-1?t.iconGroups.push(r):t.iconGroups.splice(o,0,r)}}function By(e,t,n){var a,s;const r={menus:{...t.menus},submenus:{...t.submenus},groups:{...t.groups},items:{...t.items}},o=_y(n);for(const u of e??[])if(!(Fc.has(u.id)||On(u.id))){if(r.items[u.id]=My(u),Iy(u.showIn)){const d=((a=u.menu)==null?void 0:a.id)??Wf;Ny(r,o,d,(s=u.menu)==null?void 0:s.label);const f=o.menus.find(g=>g.id===d);if(f&&!Xf(f.items,u.id)){const g=f.items[f.items.length-1];g!==void 0&&!On(g)&&f.items.every(Yf)&&f.items.push(Ce),f.items.push(u.id)}}if(Ey(u.showIn)){const d=u.toolbarGroup??Gf;Ly(r,o,d);const f=o.iconGroups.find(g=>g.id===d);f&&!f.items.includes(u.id)&&f.items.push(u.id)}}return{catalog:r,layout:o}}function Fy(e,t){const n={};for(const r of e??[])Fc.has(r.id)||On(r.id)||(n[Zf(r.id)]=()=>r.onAction(t()));return n}function Hy(e){return{cut:async()=>{await e.cut()},copy:async()=>{await e.copy()},deleteSelection:()=>{e.deleteSelection()}}}const zy="_chrome_boy0f_1",Oy={chrome:zy},Jf=l.createContext(!1);function Ky({dark:e,children:t}){return i.jsx(Jf.Provider,{value:e,children:t})}function $y(){return l.useContext(Jf)}function ec(e){return{className:Oy.chrome,"data-wysiwyg-theme":e?"dark":"light"}}function we({children:e}){const t=$y(),n=ec(t);return Bc.createPortal(i.jsx("div",{className:n.className,"data-wysiwyg-theme":n["data-wysiwyg-theme"],children:e}),document.body)}function Hc(e,t){const n=e[t];n==null||n()}const zc={modeVisual:"Visual",modeHtml:"HTML",modeVisualAria:"Switch to visual mode",modeHtmlAria:"Switch to HTML mode",modeFullscreen:"Full screen",modeFullscreenAria:"Toggle full screen",modeLight:"Light mode",modeLightAria:"Switch to light mode",modeDark:"Dark mode",modeDarkAria:"Switch to dark mode",exitFullscreenAria:"Exit full screen",visualEditorAria:"Visual editor",htmlEditorAria:"HTML editor",htmlModePageTab:"Page {n}",htmlModePageTabsAria:"HTML source pages",htmlModePageTabsScrollLeftAria:"Scroll page tabs left",htmlModePageTabsScrollRightAria:"Scroll page tabs right",menuFile:"File",menuFileAria:"File menu",menuEdit:"Edit",menuEditAria:"Edit menu",menuInsert:"Insert",menuInsertAria:"Insert menu",menuView:"View",menuViewAria:"View menu",menuFormat:"Format",menuFormatAria:"Format menu",menuFont:"Fonts",menuFontAria:"Fonts submenu",menuParagraph:"Paragraph",menuParagraphAria:"Paragraph submenu",menuParagraphStyles:"Paragraph styles",menuParagraphStylesAria:"Paragraph styles submenu",menuPage:"Page",menuPageAria:"Page submenu",menuToolbar:"Toolbar",menuToolbarAria:"Toolbar submenu",menuToolbarPosition:"Position",menuToolbarPositionAria:"Toolbar position submenu",toolbarPositionTop:"Top",toolbarPositionTopAria:"Dock toolbar at the top",toolbarPositionLeft:"Left",toolbarPositionLeftAria:"Dock toolbar on the left",toolbarPositionRight:"Right",toolbarPositionRightAria:"Dock toolbar on the right",toolbarPositionBottom:"Bottom",toolbarPositionBottomAria:"Dock toolbar at the bottom",menuImage:"Image",menuImageAria:"Image properties",menuInsertRow:"Row",menuInsertRowAria:"Insert or delete row",menuInsertColumn:"Column",menuInsertColumnAria:"Insert or delete column",menuTable:"Table",menuTableAria:"Table menu",menuCustom:"Custom",menuCustomAria:"Custom menu",menuHamburgerAria:"Open menu",menuCloseAria:"Close menu",menuOverlayAria:"Editor menu",brandMarkAria:"CommsPliant HTML editor",commandSave:"Save",commandSaveAria:"Save as HTML file",commandOpen:"Open",commandOpenAria:"Open HTML file",htmlFileDropOverlay:"Drop HTML file to open",commandPrint:"Print",commandPrintAria:"Print document",commandUndo:"Undo",commandUndoAria:"Undo",commandRedo:"Redo",commandRedoAria:"Redo",commandCut:"Cut",commandCutAria:"Cut",commandCopy:"Copy",commandCopyAria:"Copy",commandDelete:"Delete",commandDeleteAria:"Delete",commandLink:"Link",commandLinkAria:"Link",commandBookmark:"Bookmark",commandBookmarkAria:"Bookmark",commandImage:"Image",commandImageAria:"Insert image",commandPageBackgroundImage:"Page background image",commandPageBackgroundImageAria:"Insert page background image",commandParagraphBackgroundImage:"Paragraph background image",commandParagraphBackgroundImageAria:"Insert paragraph background image",commandAudio:"Audio",commandAudioAria:"Insert audio",commandYoutube:"YouTube video",commandYoutubeAria:"Insert YouTube video",commandImageProperties:"Image properties…",commandImagePropertiesAria:"Image properties",commandTable:"Table",commandTableAria:"Insert table",commandHorizontalRule:"Horizontal line",commandHorizontalRuleAria:"Insert horizontal line",commandPageBreak:"Page break",commandPageBreakAria:"Insert page break",menuInsertPage:"Page",menuInsertPageAria:"Insert page submenu",commandInsertPageBefore:"Page before",commandInsertPageBeforeAria:"Insert page before selected page",commandInsertPageAfter:"Page after",commandInsertPageAfterAria:"Insert page after selected page",commandTableProperties:"Table properties…",commandTablePropertiesAria:"Table properties",commandCellProperties:"Cell properties…",commandCellPropertiesAria:"Cell properties",commandRowProperties:"Row properties…",commandRowPropertiesAria:"Row properties",commandInsertRowBelow:"Insert row below",commandInsertRowBelowAria:"Insert row below",commandInsertRowBefore:"Insert row above",commandInsertRowBeforeAria:"Insert row above",commandDeleteRow:"Delete row",commandDeleteRowAria:"Delete row",commandInsertColumnAfter:"Insert column right",commandInsertColumnAfterAria:"Insert column right",commandInsertColumnBefore:"Insert column left",commandInsertColumnBeforeAria:"Insert column left",commandDeleteColumn:"Delete column",commandDeleteColumnAria:"Delete column",commandMergeCells:"Merge cells",commandMergeCellsAria:"Merge selected cells",commandUnmergeCells:"Unmerge cells",commandUnmergeCellsAria:"Split merged cells",contextMenuAria:"Editor context menu",commandBold:"Bold",commandBoldAria:"Bold",commandItalic:"Italic",commandItalicAria:"Italic",commandUnderline:"Underline",commandUnderlineAria:"Underline",commandStrikethrough:"Strikethrough",commandStrikethroughAria:"Strikethrough",commandClearFormatting:"Reset formatting",commandClearFormattingAria:"Reset formatting",commandFormatBrush:"Format brush",commandFormatBrushAria:"Copy formatting",commandFontSize:"Font size",commandFontSizeAria:"Font size",commandFontSizeUnitAria:"Font size unit",commandFontFamily:"Font",commandFontFamilyAria:"Font family",commandFontProperties:"Font properties…",commandFontPropertiesAria:"Font properties",commandCustomCss:"Custom CSS",commandCustomCssAria:"Custom CSS",commandParagraphProperties:"Paragraph properties…",commandParagraphPropertiesAria:"Paragraph properties",commandPageProperties:"Page properties…",commandPagePropertiesAria:"Page properties",commandDeletePage:"Delete page",commandDeletePageAria:"Delete selected page",deletePageDialogTitle:"Delete page",deletePageConfirmMessage:"Are you sure you want to delete the selected page?",commandFontColor:"Font color",commandFontColorAria:"Font color",commandHighlightColor:"Highlight color",commandHighlightColorAria:"Highlight color",commandParagraphStyle:"Styles",commandParagraphStyleAria:"Paragraph styles",commandAlignLeft:"Align left",commandAlignLeftAria:"Align left",commandAlignCenter:"Align center",commandAlignCenterAria:"Align center",commandAlignRight:"Align right",commandAlignRightAria:"Align right",commandAlignJustify:"Justify",commandAlignJustifyAria:"Justify",commandIndent:"Increase indent",commandIndentAria:"Increase indent",commandOutdent:"Decrease indent",commandOutdentAria:"Decrease indent",commandBulletList:"Bullet list",commandBulletListAria:"Bullet list",commandNumberedList:"Numbered list",commandNumberedListAria:"Numbered list",commandCustomizeToolbar:"Customize toolbar",commandCustomizeToolbarAria:"Customize toolbar",commandPreview:"Preview",commandPreviewAria:"Preview document",commandReadAloud:"Read aloud",commandReadAloudAria:"Read selection or document aloud",styleParagraph:"Paragraph",styleHeading1:"Heading 1",styleHeading2:"Heading 2",styleHeading3:"Heading 3",styleHeading4:"Heading 4",styleHeading5:"Heading 5",styleHeading6:"Heading 6",styleAddNew:"Add new",styleAddNewAria:"Add new paragraph style",customStyleDialogAddTitle:"Add paragraph style",customStyleDialogEditTitle:"Edit paragraph style",customStyleDialogTabFont:"Font",customStyleDialogTabParagraph:"Paragraph",customStyleDialogName:"Name",customStyleDialogDelete:"Delete",customStyleDialogDeleteConfirm:"Delete this paragraph style?",customStyleDialogCloseAria:"Close",customStyleLoading:"Loading paragraph styles",colorAutomatic:"Automatic",colorNone:"No color",colorCustom:"Custom color",colorHex:"Hex",colorRgbR:"R",colorRgbG:"G",colorRgbB:"B",colorPickFromScreen:"Pick from screen",colorRecent:"Recent colors",fontDialogTitle:"Font properties",fontDialogTabGeneral:"General",fontDialogFamily:"Font",fontFamilyDefault:"Default",fontDialogSize:"Size",fontDialogUnit:"Unit",fontDialogStyle:"Style",fontDialogOk:"OK",fontDialogCancel:"Cancel",linkDialogTitle:"Insert link",linkDialogTabLink:"Link",linkDialogTabBookmark:"Bookmark",linkDialogHref:"URL",linkDialogHoverTitle:"Title",linkDialogTargetBlank:"Open in a new tab",linkDialogTextDecorationNone:"No underline",linkDialogHover:"On hover",linkDialogHoverColor:"Color",linkDialogHoverColorField:"Hover color",linkDialogHoverHtml:"HTML",linkDialogHoverHtmlAria:"Custom hover HTML",linkDialogBookmark:"Bookmark",linkDialogBookmarkEmpty:"No bookmarks in this document.",linkDialogSelect:"Select",bookmarkDialogTitle:"Insert bookmark",bookmarkDialogName:"Bookmark name",bookmarkDialogHelp:"Start with a letter. Use only letters, numbers, hyphens, and underscores. Must be unique in the document.",bookmarkDialogHelpAria:"Bookmark name format",bookmarkDialogCloseAria:"Close",bookmarkDialogErrorEmpty:"Enter a bookmark name.",bookmarkDialogErrorInvalid:"Start with a letter. Use only letters, numbers, hyphens, and underscores.",bookmarkDialogErrorDuplicate:"A bookmark with this name already exists.",customCssDialogTitle:"Custom CSS",customCssDialogField:"CSS",customCssDialogFieldAria:"Custom CSS declarations",customCssDialogCloseAria:"Close",imageDialogTitle:"Insert image",imageDialogSource:"Source",imageDialogFile:"File",imageDialogChooseFile:"Choose file",imageDialogUrl:"Image URL",imageDialogAlt:"Alt text",imageDialogTitleField:"Title",imageDialogCloseAria:"Close",imageDialogErrorEmpty:"Choose a file or enter an image URL.",imageDialogErrorInvalid:"Enter a valid image URL.",imageDialogErrorType:"Use a JPEG, PNG, GIF, WebP, BMP, or AVIF image.",imageDialogErrorTooLarge:"Choose an image smaller than 2 MB.",audioDialogTitle:"Insert audio",audioDialogSource:"Source",audioDialogFile:"File",audioDialogChooseFile:"Choose file",audioDialogUrl:"Audio URL",audioDialogTitleField:"Title",audioDialogCloseAria:"Close",audioDialogErrorEmpty:"Choose a file or enter an audio URL.",audioDialogErrorInvalid:"Enter a valid audio URL.",audioDialogErrorType:"Use an MP3, WAV, OGG, AAC, WebM, or M4A audio file.",audioDialogErrorTooLarge:"Choose an audio file smaller than 5 MB.",youtubeDialogTitle:"Insert YouTube video",youtubeDialogUrl:"YouTube URL",youtubeDialogTitleField:"Title",youtubeDialogCloseAria:"Close",youtubeDialogErrorEmpty:"Enter a YouTube URL.",youtubeDialogErrorInvalid:"Enter a valid YouTube URL.",imagePropertiesDialogTitle:"Image properties",imagePropertiesDialogCloseAria:"Close",imagePropertiesTabAlignment:"Alignment",imagePropertiesTabBorder:"Border & margin",imagePropertiesTabAdvanced:"Advanced",imagePropertiesTabHover:"Hover",imagePropertiesSize:"Size",imagePropertiesSizeMode:"Size mode",imagePropertiesSizeWidth:"Width only",imagePropertiesSizeHeight:"Height only",imagePropertiesSizeLock:"Lock together",imagePropertiesWidth:"Width",imagePropertiesHeight:"Height",imagePropertiesWidthAria:"Image width",imagePropertiesHeightAria:"Image height",imagePropertiesSizeUnitAria:"Image size unit",imagePropertiesFit:"Fit",imagePropertiesFitDefault:"Default",imagePropertiesFitFill:"Fill",imagePropertiesFitContain:"Contain",imagePropertiesFitCover:"Cover",imagePropertiesFitNoneValue:"None",imagePropertiesFitScaleDown:"Scale down",imagePropertiesPosition:"Position",imagePropertiesPositionDefault:"Default",imagePropertiesPositionCenter:"Center",imagePropertiesPositionTop:"Top",imagePropertiesPositionBottom:"Bottom",imagePropertiesPositionLeft:"Left",imagePropertiesPositionRight:"Right",imagePropertiesPositionTopLeft:"Top left",imagePropertiesPositionTopRight:"Top right",imagePropertiesPositionBottomLeft:"Bottom left",imagePropertiesPositionBottomRight:"Bottom right",imagePropertiesRotation:"Rotation",imagePropertiesRotationUnit:"deg",imagePropertiesHoverCss:"Hover CSS",imagePropertiesHoverCssAria:"Custom hover CSS",imagePropertiesHoverHelp:"CSS applied when the pointer is over the image.",imageResizeHandleEastAria:"Resize image width, keep aspect ratio",imageResizeHandleSouthAria:"Resize image height, keep aspect ratio",imageResizeHandleSouthEastAria:"Resize image freely",tableDialogTitle:"Insert table",tableDialogCloseAria:"Close",tableDialogRows:"Rows",tableDialogColumns:"Columns",tableDialogSize:"Size",tableDialogGridAria:"Table size grid",tableDialogInsert:"Insert",tablePropertiesDialogTitle:"Table properties",tablePropertiesDialogCloseAria:"Close",tablePropertiesCollapse:"Border collapse",tablePropertiesCollapseCollapse:"Collapse",tablePropertiesCollapseSeparate:"Separate",tablePropertiesSpacing:"Border spacing",tablePropertiesWidth:"Width",cellPropertiesDialogTitle:"Cell properties",cellPropertiesDialogCloseAria:"Close",cellPropertiesColor:"Text color",cellPropertiesVerticalAlign:"Vertical align",cellPropertiesVerticalAlignDefault:"Default",cellPropertiesVerticalAlignTop:"Top",cellPropertiesVerticalAlignMiddle:"Middle",cellPropertiesVerticalAlignBottom:"Bottom",cellPropertiesVerticalAlignBaseline:"Baseline",cellPropertiesWidth:"Width",cellPropertiesColSpan:"Column span",cellPropertiesRowSpan:"Row span",rowPropertiesDialogTitle:"Row properties",rowPropertiesDialogCloseAria:"Close",rowPropertiesHeight:"Height",paragraphDialogTitle:"Paragraph properties",pageDialogTitle:"Page properties",pageDialogTabBackgroundImage:"Background Image",pageDialogTabPrint:"Print",pageAtRuleSize:"Page size",pageAtRuleSizeAuto:"Auto",pageAtRuleSizeA4:"A4",pageAtRuleSizeLetter:"Letter",pageAtRuleSizeLegal:"Legal",pageAtRuleSizeCustom:"Custom",pageAtRuleWidth:"Width",pageAtRuleHeight:"Height",pageAtRuleOrientation:"Orientation",pageAtRuleOrientationNone:"Default",pageAtRuleOrientationPortrait:"Portrait",pageAtRuleOrientationLandscape:"Landscape",pageAtRuleMargins:"Page margins",pageAtRuleReset:"Reset print settings",pageAtRuleResetAria:"Remove @page print settings from this page",menuZoom:"Zoom",menuZoomAria:"Zoom submenu",pageZoomFitWidth:"Fit width",pageZoomFitWidthAria:"Fit page width to the editor",pageZoomFitPage:"Fit page",pageZoomFitPageAria:"Fit entire page to the editor",pageZoom50:"50%",pageZoom50Aria:"Zoom to 50 percent",pageZoom75:"75%",pageZoom75Aria:"Zoom to 75 percent",pageZoom100:"100%",pageZoom100Aria:"Zoom to 100 percent",pageZoom125:"125%",pageZoom125Aria:"Zoom to 125 percent",pageZoom150:"150%",pageZoom150Aria:"Zoom to 150 percent",pageZoom200:"200%",pageZoom200Aria:"Zoom to 200 percent",pageBackgroundImagePreview:"Preview",pageBackgroundImagePreviewAlt:"Page background image preview",pageBackgroundImageClear:"Remove background image",pageBackgroundImageCurrent:"Image selected",paragraphDialogTabBorder:"Border",paragraphDialogTabBackground:"Background",paragraphDialogAlignment:"Alignment",paragraphDialogLists:"Lists",paragraphDialogSpacing:"Spacing",paragraphDialogMargin:"Margin",paragraphDialogPadding:"Padding",paragraphDialogLineHeight:"Line height",paragraphDialogLineHeightNormal:"Normal",paragraphDialogLineHeightUnitless:"×",paragraphDialogLinkSides:"Same on all sides",paragraphDialogSideTop:"Top",paragraphDialogSideRight:"Right",paragraphDialogSideBottom:"Bottom",paragraphDialogSideLeft:"Left",paragraphDialogBorder:"Border",paragraphDialogBorderStyle:"Style",paragraphDialogBorderWidth:"Width",paragraphDialogBorderColor:"Color",paragraphDialogBorderRadius:"Corner radius",paragraphDialogBoxShadow:"Box shadow",paragraphDialogShadowOffsetX:"Offset X",paragraphDialogShadowOffsetY:"Offset Y",paragraphDialogShadowBlur:"Blur",paragraphDialogShadowSpread:"Spread",paragraphDialogShadowColor:"Color",paragraphDialogShadowInset:"Inset",paragraphDialogLengthUnitAria:"Unit",paragraphDialogBorderStyleNone:"None",paragraphDialogBorderStyleSolid:"Solid",paragraphDialogBorderStyleDotted:"Dotted",paragraphDialogBorderStyleDashed:"Dashed",paragraphDialogBorderStyleDouble:"Double",paragraphDialogBorderStyleGroove:"Groove",paragraphDialogBorderStyleRidge:"Ridge",paragraphDialogBorderStyleInset:"Inset",paragraphDialogBorderStyleOutset:"Outset",paragraphDialogBackgroundColor:"Background color",paragraphDialogOpacity:"Opacity",paragraphDialogPageBreaks:"Page breaks",paragraphDialogBreakInside:"Break inside",paragraphDialogBreakAfter:"Break after",paragraphDialogBreakBefore:"Break before",paragraphDialogBreakAuto:"Auto",paragraphDialogBreakAvoid:"Avoid",paragraphDialogBreakPage:"Page",fontSizeUnitPt:"pt",fontSizeUnitPx:"px",fontSizeUnitEm:"em",fontSizeUnitRem:"rem",fontSizeUnitPercent:"%",fontSizeUnitPc:"pc",toolbarAria:"Formatting toolbar",toolbarGroupFile:"File",toolbarGroupPrint:"Print",toolbarGroupEdit:"Edit",toolbarGroupInsert:"Insert",toolbarGroupTable:"Table",toolbarGroupFont:"Fonts",toolbarGroupAlign:"Align",toolbarGroupParagraph:"Paragraph",toolbarGroupView:"View",toolbarGroupFullscreen:"Full screen",toolbarGroupCustom:"Custom",customizeToolbarDialogTitle:"Customize toolbar",customizeToolbarDialogReset:"Reset",customizeToolbarDialogClose:"Close",customizeToolbarDialogCloseAria:"Close",customizeToolbarDialogLoading:"Loading toolbar settings",customizeToolbarItemVisible:"Show on toolbar",customizeToolbarDragHandle:"Drag to reorder group",customizeToolbarMoveUp:"Move group up",customizeToolbarMoveDown:"Move group down",previewDialogTitle:"Document preview",previewDialogClose:"Close",previewDialogCloseAria:"Close",commandAddComment:"Add comment",commandAddCommentAria:"Add comment on selection",commandInsertComment:"Comment",commandInsertCommentAria:"Insert comment on selection",showComments:"Show comments",hideComments:"Hide comments",toggleCommentsVisibleAria:"Toggle comment visibility",commandRuler:"Ruler",commandRulerAria:"Show or hide rulers",rulerMarginLeft:"Left margin",rulerMarginRight:"Right margin",rulerMarginTop:"Top margin",rulerMarginBottom:"Bottom margin",rulerFirstLineIndent:"First line indent",rulerLeftIndent:"Left indent",rulerRightIndent:"Right indent",commentPanelTitle:"Comment",commentPlaceholder:"Write a comment…",commentReplyPlaceholder:"Write a reply…",commentPost:"Post",commentEmpty:"No messages yet.",commentPanelCloseAria:"Close comment panel",menuHelp:"Help",menuHelpAria:"Help menu",commandEditorHelp:"Editor Help",commandEditorHelpAria:"Open editor help",commandKeyboardShortcuts:"Keyboard shortcuts",commandKeyboardShortcutsAria:"Open keyboard shortcuts help",commandAbout:"About",commandAboutAria:"About this editor",helpDialogTitle:"Help",helpDialogCloseAria:"Close help",helpDialogSearchPlaceholder:"Search help topics…",helpDialogSearchAria:"Search help",helpDialogContentsAria:"Help contents",helpDialogNoResults:"No help topics match your search.",helpDialogRelatedTitle:"Related topics",aboutDialogTitle:"About",aboutDialogCloseAria:"Close about dialog",aboutDialogClose:"Close",aboutDialogVersion:"Version {version}",aboutDialogDescription:"CommsPliant HTML editor is a reusable React WYSIWYG component with Visual and HTML editing modes. Licensed under the MIT License.",aboutDialogWebsiteCta:"See what we're building for regulated communication solutions.",aboutDialogWebsite:"Visit commspliant.com",aboutDialogWebsiteAria:"Visit CommsPliant — regulated communication management",helpCategoryGetStarted:"Get started",helpCategoryFile:"File",helpCategoryEdit:"Edit",helpCategoryInsert:"Insert",helpCategoryFormat:"Format",helpCategoryTable:"Table",helpCategoryView:"View",helpCategoryKeyboard:"Keyboard",helpTopicGetStartedTitle:"How do I use this editor?",helpTopicGetStartedBody:`1. Type in the visual editing area.
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const i=require("react/jsx-runtime"),l=require("react"),Kc=require("react-dom");function Kb({className:e}){return i.jsxs("svg",{className:e,viewBox:"0 0 24 24",width:"16",height:"16",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true","data-icon":"audio",children:[i.jsx("path",{d:"M9 18V5l12-2v13"}),i.jsx("circle",{cx:"6",cy:"18",r:"3"}),i.jsx("circle",{cx:"18",cy:"16",r:"3"})]})}function is({className:e}){return i.jsxs("svg",{className:e,viewBox:"0 0 24 24",width:"16",height:"16",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true","data-icon":"align-center",children:[i.jsx("path",{d:"M4 6h16"}),i.jsx("path",{d:"M7 12h10"}),i.jsx("path",{d:"M4 18h16"})]})}function Hf({className:e}){return i.jsxs("svg",{className:e,viewBox:"0 0 24 24",width:"16",height:"16",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true","data-icon":"align-justify",children:[i.jsx("path",{d:"M4 6h16"}),i.jsx("path",{d:"M4 12h16"}),i.jsx("path",{d:"M4 18h16"})]})}function as({className:e}){return i.jsxs("svg",{className:e,viewBox:"0 0 24 24",width:"16",height:"16",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true","data-icon":"align-left",children:[i.jsx("path",{d:"M4 6h16"}),i.jsx("path",{d:"M4 12h10"}),i.jsx("path",{d:"M4 18h16"})]})}function ss({className:e}){return i.jsxs("svg",{className:e,viewBox:"0 0 24 24",width:"16",height:"16",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true","data-icon":"align-right",children:[i.jsx("path",{d:"M4 6h16"}),i.jsx("path",{d:"M10 12h10"}),i.jsx("path",{d:"M4 18h16"})]})}function $b({className:e}){return i.jsxs("svg",{className:e,viewBox:"0 0 24 24",width:"16",height:"16",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true","data-icon":"bold",children:[i.jsx("path",{d:"M7 5h6.5a3.5 3.5 0 0 1 0 7H7z"}),i.jsx("path",{d:"M7 12h7.5a3.5 3.5 0 0 1 0 7H7z"}),i.jsx("path",{d:"M7 5v14"})]})}function Ub({className:e}){return i.jsx("svg",{className:e,viewBox:"0 0 24 24",width:"16",height:"16",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true","data-icon":"bookmark",children:i.jsx("path",{d:"M6 4h12a1 1 0 0 1 1 1v16l-7-4-7 4V5a1 1 0 0 1 1-1z"})})}function zf({className:e}){return i.jsxs("svg",{className:e,viewBox:"0 0 24 24",width:"16",height:"16",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true","data-icon":"bullet-list",children:[i.jsx("path",{d:"M9 6h12"}),i.jsx("path",{d:"M9 12h12"}),i.jsx("path",{d:"M9 18h12"}),i.jsx("circle",{cx:"4.5",cy:"6",r:"1.2",fill:"currentColor",stroke:"none"}),i.jsx("circle",{cx:"4.5",cy:"12",r:"1.2",fill:"currentColor",stroke:"none"}),i.jsx("circle",{cx:"4.5",cy:"18",r:"1.2",fill:"currentColor",stroke:"none"})]})}function Vb({className:e}){return i.jsxs("svg",{className:e,viewBox:"0 0 24 24",width:"16",height:"16",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true","data-icon":"cell-properties",children:[i.jsx("rect",{x:"3",y:"4",width:"18",height:"16",rx:"1"}),i.jsx("path",{d:"M3 12h18"}),i.jsx("path",{d:"M12 4v16"}),i.jsx("rect",{x:"12.5",y:"4.5",width:"8",height:"7",fill:"currentColor",stroke:"none",opacity:"0.25"})]})}function Wb({className:e}){return i.jsxs("svg",{className:e,viewBox:"0 0 24 24",width:"16",height:"16",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true","data-icon":"clear-formatting",children:[i.jsx("path",{d:"M4 5h12"}),i.jsx("path",{d:"M10 5v8"}),i.jsx("path",{d:"m14 15 6 6"}),i.jsx("path",{d:"m20 15-6 6"})]})}function Je({className:e}){return i.jsxs("svg",{className:e,viewBox:"0 0 24 24",width:"16",height:"16",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true","data-icon":"close",children:[i.jsx("path",{d:"M18 6L6 18"}),i.jsx("path",{d:"M6 6l12 12"})]})}function xm({className:e}){return i.jsx("svg",{className:e,viewBox:"0 0 24 24",width:"16",height:"16",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true","data-icon":"comment",children:i.jsx("path",{d:"M21 15a4 4 0 0 1-4 4H8l-5 3V7a4 4 0 0 1 4-4h10a4 4 0 0 1 4 4z"})})}function Gb({className:e}){return i.jsxs("svg",{className:e,viewBox:"0 0 24 24",width:"16",height:"16",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true","data-icon":"comments-visible",children:[i.jsx("path",{d:"M21 15a4 4 0 0 1-4 4H8l-5 3V7a4 4 0 0 1 4-4h10a4 4 0 0 1 4 4z"}),i.jsx("path",{d:"M8 9h8M8 13h5"})]})}function Zb({className:e}){return i.jsx("svg",{className:e,viewBox:"0 0 616.23 542.09",width:"45",height:"40","aria-hidden":"true","data-icon":"commspliant-shield",children:i.jsxs("g",{transform:"translate(129.79555,688.75474)",children:[i.jsx("path",{fill:"#334E68",d:"m 92.41768,-326.31771 a 0.3,0.3 0 0 1 0.48,0.05 q 5.04,8.55 15.34,22.7 5.5,7.55 11.93,14.77 11.84,13.3 12.69,14.16 11.29,11.41 26.17,23.51 c 4.66,3.79 9.84,8.83 15.07,12.39 18.71,12.72 34.7,23.08 52.84,31.97 q 15.29,7.5 16.67,8.12 5.77,2.59 8.73,3.54 c 1.66,0.54 2.74,-0.25 4.17,-0.93 q 27.98,-13.14 49.38,-25.74 21.15,-12.47 41.94,-29.56 1.28,-1.05 12.72,-11.11 c 11.11,-9.78 22.59,-22.12 30.48,-31.94 q 10.87,-13.52 16.67,-23.55 c 3.7,-6.41 7.66,-12.73 10.29,-18.63 q 9.41,-21.06 13.67,-35.18 8.51,-28.19 9.46,-61.31 0.96,-33.72 0.31,-64.55 -0.09,-4.4 2.81,-7.26 5.42,-5.33 7.5,-7.38 c 6.37,-6.25 11.24,-13.29 18.07,-19.23 q 7.84,-6.84 14.74,-16.11 0.14,-0.19 0.39,-0.15 0.61,0.1 0.52,0.7 -0.37,2.69 -0.35,4.95 c 0.37,45.85 0.81,76.35 -0.95,110.71 q -0.66,12.89 -2.71,28.52 -2.84,21.57 -7.17,36.03 -2.02,6.75 -5.4,17.5 c -5.64,17.94 -13.55,35.09 -23.13,50.9 q -1.72,2.86 -12.91,19.22 c -10.81,15.81 -22.83,29.61 -35.06,41.83 q -4.06,4.07 -17.47,16.38 -9.77,8.98 -18.52,15.14 -19.27,13.56 -32.8,21.84 c -8.27,5.05 -17.73,9.75 -26.22,14.7 q -3.66,2.13 -10.7,5.47 -27.19,12.89 -34.36,16.16 -3.92,1.79 -7.2,0.44 -3.47,-1.43 -11.46,-4.85 c -9.07,-3.89 -16.98,-8.27 -24.9,-11.89 -8.4,-3.84 -18.78,-9.89 -28.06,-15.14 q -43.25,-24.5 -76.54,-56.22 -11.98,-11.41 -24.94,-26.56 -12.76,-14.92 -26.13,-34.48 a 0.43,0.44 56.8 0 1 0.13,-0.61 c 12.12,-7.82 23.12,-17.82 33.81,-29.32 z"}),i.jsx("path",{fill:"#334E68",d:"m -128.82232,-375.77771 a 0.96,0.96 0 0 1 -0.8,-1.51 l 28.86,-41.82 a 3.24,3.2 6.2 0 1 1.45,-1.15 q 0.69,-0.27 3.64,-0.32 15.37,-0.27 46.58,-0.45 12.44,-0.07 19.69,-1.84 c 26.32,-6.42 44.55,-29.39 47.76,-55.67 q 1.05,-8.54 0.87,-20.92 c -0.55,-39.95 0.23,-77.15 -0.1,-117.57 a 0.94,0.95 85.4 0 1 0.81,-0.94 c 35.7,-5.08 70.26,-12.78 104.11,-23.86 q 9.4,-3.07 22.28,-7.05 8.6,-2.65 22.1,-7.58 18.33,-6.69 43.02,-16.74 23.04,-9.38 35.12,-15.34 1.17,-0.58 3.29,0.39 c 14.96,6.81 34.27,13.39 42.79,16.68 q 14.24,5.5 27.59,10.33 23.24,8.41 27.7,10.07 2.01,0.75 9.42,3.41 5.07,1.82 9.47,3.13 40.54,12.1 57.07,16.58 2.54,0.68 4.26,0.82 a 0.48,0.48 0 0 1 0.32,0.79 l -33.68,37.82 a 0.58,0.58 0 0 1 -0.68,0.13 q -3.43,-1.67 -5.84,-2.43 -8.74,-2.79 -47.37,-15.63 -8.92,-2.96 -17.51,-6.16 c -17.92,-6.67 -32.21,-11.74 -65.83,-24.24 -2.89,-1.08 -8.28,-3.56 -11.57,-2.33 -11.44,4.27 -27.67,11.24 -40.6,15.93 q -8.12,2.94 -26.33,9.89 c -21.86,8.35 -43.57,14.34 -67.25,21.47 q -20.07,6.03 -48.78,11.52 a 0.71,0.7 84.6 0 0 -0.57,0.7 q 0.1,95.52 0.1,95.57 c -0.53,30.1 -14.63,58.57 -36,79.25 -10.83,10.49 -23.5,17.98 -37.57,23.68 -10.14,4.1 -18.76,4.57 -31.18,4.79 q -3.1,0.05 -86.64,0.6 z"}),i.jsx("path",{fill:"#C9A227",d:"m 169.86768,-422.45771 q 0.04,-0.4 0.24,-0.59 c 3.41,-3.3 5.96,-6.99 9.56,-10.8 q 10.13,-10.72 15.25,-16.65 2.05,-2.38 5.38,-4.3 a 0.68,0.69 53.4 0 1 0.84,0.12 l 49.51,50.92 a 1.06,1.06 0 0 0 1.52,0 q 17.38,-17.8 26.4,-27.94 c 6.36,-7.14 15.04,-14.76 20.1,-20.56 q 10.29,-11.81 17.14,-18.67 7.41,-7.41 17.44,-18.41 13.85,-15.18 23.56,-24.67 c 3.68,-3.59 5.5,-6.17 8.54,-10.08 2.38,-3.06 4.42,-4.87 8.16,-8.31 6.16,-5.66 10.48,-11.49 16.47,-17.22 6.29,-6.03 12.87,-14.23 18.87,-20.24 q 5.56,-5.56 13.49,-14.45 c 6.79,-7.6 12.13,-13.02 18.46,-19.66 4.83,-5.06 9.88,-11.22 15.21,-16.21 a 1.91,1.91 0 0 1 1.3,-0.51 h 28.15 a 0.83,0.83 0 0 1 0.83,0.82 q 0.28,14.3 0.03,31.53 c -0.07,4.93 -1.9,6.19 -5.19,9.51 -5.86,5.92 -12.79,12.1 -18.21,18.16 q -6.63,7.4 -16.64,16.86 c -2.68,2.53 -6.31,6.91 -8.5,9.17 -8.76,9.01 -14.72,16.05 -22.55,23.36 q -1.37,1.28 -9.09,9.75 -4.93,5.41 -24.32,25.01 c -9.96,10.07 -19.18,20.45 -27.83,28.95 q -11.52,11.33 -20.29,20.96 c -19.16,21.01 -41.14,42.93 -58.64,61.61 q -10.7,11.42 -22.21,22 a 1.97,1.94 24 0 1 -1.38,0.52 q -1.9,-0.06 -3.83,-2.08 c -19.01,-19.93 -45.74,-44.39 -67.08,-67.5 q -5.05,-5.47 -10.42,-9.75 -0.31,-0.24 -0.27,-0.65 z"}),i.jsx("path",{fill:"#5B7B9C",d:"m 351.58768,-544.71771 a 0.41,0.41 0 0 1 0.17,0.69 q -15.9,15.29 -29.64,31.76 a 1.16,1.19 33.7 0 1 -1.44,0.3 c -5.87,-3 -10.72,-6.65 -16.97,-10.42 -17.2,-10.37 -38.83,-14.16 -59.18,-13.16 -12.15,0.6 -23.67,3.62 -34.54,8.11 -5.15,2.13 -9.08,4.66 -14.86,8.63 q -14.63,10.05 -22.02,17.75 -6.98,7.27 -17.47,22.45 c -5.11,7.4 -9.03,15.18 -13.55,23.27 q -5.09,9.08 -10.38,20.93 c -4.39,9.81 -8.53,17.45 -13.72,27.5 q -6,11.58 -11.58,19.91 c -6.74,10.09 -11.32,17.91 -17.68,26.12 -4.94,6.38 -10.92,12.4 -15.22,17.55 q -3.48,4.18 -9.33,9.51 c -20.66,18.83 -45.19,33.15 -72.9,38.24 q -15.17,2.79 -26.21,3.08 -22.84,0.6 -52.01,0.23 a 0.29,0.29 0 0 1 -0.24,-0.43 c 6.02,-10.58 11.85,-19.61 23.29,-37.61 q 2.27,-3.58 5.02,-6.38 a 3.39,3.4 24.3 0 1 2.63,-1 q 16.4,1.07 32.77,-1.23 c 15.39,-2.16 29.33,-7.66 42.1,-15.59 q 4.42,-2.75 14.17,-10.6 3.58,-2.89 14.27,-14.03 6.08,-6.33 9.69,-12.1 c 3.25,-5.19 7.59,-10.59 11.55,-17.24 q 16.77,-28.19 29.52,-56.84 c 4.49,-10.08 8.7,-16.87 15.5,-28.37 q 5.49,-9.29 14.18,-21.09 5.94,-8.07 12.61,-14.76 12.65,-12.7 13.8,-13.72 5.51,-4.84 19.01,-13.66 49.89,-32.59 109.07,-20.31 7.95,1.65 15.41,4.34 14.58,5.25 20.68,8.05 c 10.41,4.78 21.11,12.36 31.15,19.28 a 2.65,2.62 70.1 0 0 0.78,0.37 z"}),i.jsx("path",{fill:"#5B7B9C",d:"m 143.16768,-394.65771 q 0.46,0.11 0.45,0.6 -0.03,2.2 0.62,4.89 2.72,11.27 9.81,22.88 7.25,11.89 15.4,22.7 c 4.71,6.26 10.61,13.06 17.11,18.9 9.38,8.42 15.79,14.58 25.02,21.29 q 13.29,9.65 15.1,10.72 10.62,6.29 20.67,12.58 1.94,1.22 4,1.86 a 2.56,2.59 42.2 0 0 1.81,-0.1 c 7.1,-3.08 12.92,-6.7 21.76,-11.78 q 6.63,-3.81 11.42,-7.45 c 4.56,-3.47 9.98,-6.63 14.83,-10.52 q 18.45,-14.82 32.58,-32 6.8,-8.28 11.17,-16.16 c 7.76,-14.01 13.11,-25.52 16.26,-40.82 1.49,-7.23 1.56,-11.99 2.41,-21.26 a 3.66,3.67 70 0 1 1.06,-2.26 q 9.34,-9.27 20.72,-20.12 c 6.47,-6.15 12.23,-13.51 18.33,-19.07 a 0.67,0.67 0 0 1 1.11,0.43 q 1.92,19.96 1.77,37.52 -0.18,19.95 -4.43,40.76 -3.4,16.65 -11.34,32.24 -0.55,1.09 -4.75,9.06 -3,5.69 -5.08,8.85 c -9.56,14.55 -19.75,27.73 -31.99,39.39 q -7.6,7.24 -9.98,9.35 -10.58,9.37 -24.17,18.04 c -4.91,3.14 -9.19,7.11 -13.77,9.89 q -24.03,14.58 -42.68,23.19 -3.32,1.53 -8.02,-0.31 -1.97,-0.78 -11.41,-5.19 c -8.92,-4.17 -16.04,-8.65 -24.58,-13.03 q -6.75,-3.47 -13.06,-7.8 -18.87,-12.96 -21.03,-14.68 -15.47,-12.4 -29.21,-26.05 -5.39,-5.35 -13.86,-16.13 -6.45,-8.2 -14.56,-19.38 c -3.42,-4.72 -6.19,-10.2 -9.49,-14.45 a 1.33,1.32 44.2 0 1 -0.03,-1.59 c 5.8,-7.95 10.64,-13.7 15.23,-21.14 q 8.66,-14.03 14.39,-23.68 a 0.38,0.39 23.4 0 1 0.41,-0.17 z"})]})})}function qb({className:e}){return i.jsxs("svg",{className:e,viewBox:"0 0 24 24",width:"16",height:"16",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true","data-icon":"custom-action",children:[i.jsx("rect",{x:"4",y:"4",width:"16",height:"16",rx:"2"}),i.jsx("path",{d:"M9 8.5c0-1 .7-1.5 1.5-1.5S12 7.5 12 8.5c0 1.2-3 1.2-3 3.2"}),i.jsx("path",{d:"M10.5 14v.5"}),i.jsx("path",{d:"M15 10v4"}),i.jsx("path",{d:"M13 12h4"})]})}function Yb({className:e}){return i.jsxs("svg",{className:e,viewBox:"0 0 24 24",width:"16",height:"16",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true","data-icon":"custom-css",children:[i.jsx("path",{d:"M8 6h12"}),i.jsx("path",{d:"M8 12h12"}),i.jsx("path",{d:"M8 18h8"}),i.jsx("path",{d:"M4 6h.01"}),i.jsx("path",{d:"M4 12h.01"}),i.jsx("path",{d:"M4 18h.01"})]})}function Xb({className:e}){return i.jsxs("svg",{className:e,viewBox:"0 0 24 24",width:"16",height:"16",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true","data-icon":"customize-toolbar",children:[i.jsx("rect",{x:"3",y:"4",width:"7",height:"7",rx:"1"}),i.jsx("rect",{x:"14",y:"4",width:"7",height:"7",rx:"1"}),i.jsx("rect",{x:"3",y:"13",width:"7",height:"7",rx:"1"}),i.jsx("rect",{x:"14",y:"13",width:"7",height:"7",rx:"1"})]})}function Jb({className:e}){return i.jsx("svg",{className:e,viewBox:"0 0 24 24",width:"16",height:"16",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true","data-icon":"dark-mode",children:i.jsx("path",{d:"M21 14.5A8.5 8.5 0 1 1 9.5 3 7 7 0 0 0 21 14.5z"})})}function Of({className:e}){return i.jsxs("svg",{className:e,viewBox:"0 0 24 24",width:"16",height:"16",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true","data-icon":"font-color",children:[i.jsx("path",{d:"M6 18L12 4l6 14"}),i.jsx("path",{d:"M8.5 13h7"})]})}function Qb({className:e}){return i.jsxs("svg",{className:e,viewBox:"0 0 24 24",width:"16",height:"16",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true","data-icon":"font-family",children:[i.jsx("path",{d:"M4 18L9 6l5 12"}),i.jsx("path",{d:"M6.2 13h5.6"}),i.jsx("path",{d:"M16 18V9"}),i.jsx("path",{d:"M16 9h5"})]})}function ey({className:e}){return i.jsxs("svg",{className:e,viewBox:"0 0 24 24",width:"16",height:"16",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true","data-icon":"font-properties",children:[i.jsx("path",{d:"M4 20h4"}),i.jsx("path",{d:"M6 20V6"}),i.jsx("path",{d:"M4 6h4"}),i.jsx("path",{d:"M12 20V9"}),i.jsx("path",{d:"M12 9h8"}),i.jsx("path",{d:"M16 9v11"})]})}function ty({className:e}){return i.jsxs("svg",{className:e,viewBox:"0 0 24 24",width:"16",height:"16",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true","data-icon":"font-size",children:[i.jsx("path",{d:"M4 18V8h3"}),i.jsx("path",{d:"M4 8h8"}),i.jsx("path",{d:"M10 8v10"}),i.jsx("path",{d:"M16 18V12h2"}),i.jsx("path",{d:"M16 12h5"}),i.jsx("path",{d:"M19 12v6"})]})}function ny({className:e}){return i.jsxs("svg",{className:e,viewBox:"0 0 24 24",width:"16",height:"16",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true","data-icon":"format-brush",children:[i.jsx("path",{d:"m9.06 11.9 8.07-8.06a2.85 2.85 0 1 1 4.03 4.03l-8.06 8.08"}),i.jsx("path",{d:"M7.07 14.94c-1.66 0-3 1.34-3 3v2.06h2.06c1.66 0 3-1.34 3-3v-2.06Z"}),i.jsx("path",{d:"M7.07 14.94 4.01 18"})]})}function ry({className:e}){return i.jsxs("svg",{className:e,viewBox:"0 0 24 24",width:"16",height:"16",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true","data-icon":"fullscreen",children:[i.jsx("path",{d:"M8 3H5a2 2 0 0 0-2 2v3"}),i.jsx("path",{d:"M21 8V5a2 2 0 0 0-2-2h-3"}),i.jsx("path",{d:"M3 16v3a2 2 0 0 0 2 2h3"}),i.jsx("path",{d:"M16 21h3a2 2 0 0 0 2-2v-3"})]})}function El({className:e}){return i.jsxs("svg",{className:e,viewBox:"0 0 24 24",width:"16",height:"16",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true","data-icon":"help",children:[i.jsx("circle",{cx:"12",cy:"12",r:"10"}),i.jsx("path",{d:"M9.09 9a3 3 0 0 1 5.83 1c0 2-3 3-3 3"}),i.jsx("path",{d:"M12 17h.01"})]})}function Kf({className:e}){return i.jsxs("svg",{className:e,viewBox:"0 0 24 24",width:"16",height:"16",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true","data-icon":"highlight-color",children:[i.jsx("path",{d:"M15.5 4.5l4 4-9 9H6.5v-4.5z"}),i.jsx("path",{d:"M13.5 6.5l4 4"}),i.jsx("path",{d:"M4 20h8"})]})}function oy({className:e}){return i.jsx("svg",{className:e,viewBox:"0 0 24 24",width:"16",height:"16",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true","data-icon":"horizontalRule",children:i.jsx("path",{d:"M4 12h16"})})}function iy({className:e}){return i.jsxs("svg",{className:e,viewBox:"0 0 24 24",width:"16",height:"16",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true","data-icon":"html",children:[i.jsx("path",{d:"M8 8l-4 4 4 4"}),i.jsx("path",{d:"M16 8l4 4-4 4"})]})}function $f({className:e}){return i.jsxs("svg",{className:e,viewBox:"0 0 24 24",width:"16",height:"16",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true","data-icon":"image",children:[i.jsx("rect",{x:"3",y:"5",width:"18",height:"14",rx:"2"}),i.jsx("circle",{cx:"8.5",cy:"10",r:"1.5"}),i.jsx("path",{d:"m21 15-4.5-4.5L7 20"})]})}function ay({className:e}){return i.jsxs("svg",{className:e,viewBox:"0 0 24 24",width:"16",height:"16",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true","data-icon":"indent",children:[i.jsx("path",{d:"M4 6h16"}),i.jsx("path",{d:"M12 12h8"}),i.jsx("path",{d:"M4 18h16"}),i.jsx("path",{d:"M4 9l4 3-4 3"})]})}function sy({className:e}){return i.jsxs("svg",{className:e,viewBox:"0 0 24 24",width:"16",height:"16",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true","data-icon":"italic",children:[i.jsx("path",{d:"M10 4h9"}),i.jsx("path",{d:"M5 20h9"}),i.jsx("path",{d:"M14 4L8 20"})]})}function ly({className:e}){return i.jsxs("svg",{className:e,viewBox:"0 0 24 24",width:"16",height:"16",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true","data-icon":"light-mode",children:[i.jsx("circle",{cx:"12",cy:"12",r:"4"}),i.jsx("path",{d:"M12 2v2"}),i.jsx("path",{d:"M12 20v2"}),i.jsx("path",{d:"M4.93 4.93l1.41 1.41"}),i.jsx("path",{d:"M17.66 17.66l1.41 1.41"}),i.jsx("path",{d:"M2 12h2"}),i.jsx("path",{d:"M20 12h2"}),i.jsx("path",{d:"M4.93 19.07l1.41-1.41"}),i.jsx("path",{d:"M17.66 6.34l1.41-1.41"})]})}function cy({className:e}){return i.jsxs("svg",{className:e,viewBox:"0 0 24 24",width:"16",height:"16",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true","data-icon":"link",children:[i.jsx("path",{d:"M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71"}),i.jsx("path",{d:"M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71"})]})}function uy({className:e}){return i.jsxs("svg",{className:e,viewBox:"0 0 24 24",width:"16",height:"16",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true","data-icon":"menu",children:[i.jsx("path",{d:"M4 6h16"}),i.jsx("path",{d:"M4 12h16"}),i.jsx("path",{d:"M4 18h16"})]})}function dy({className:e}){return i.jsxs("svg",{className:e,viewBox:"0 0 24 24",width:"16",height:"16",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true","data-icon":"merge-cells",children:[i.jsx("rect",{x:"3",y:"4",width:"18",height:"16",rx:"1"}),i.jsx("path",{d:"M3 12h5"}),i.jsx("path",{d:"M16 12h5"}),i.jsx("path",{d:"M12 4v16"}),i.jsx("path",{d:"M9 9l3 3-3 3"}),i.jsx("path",{d:"M15 9l-3 3 3 3"})]})}function Uf({className:e}){return i.jsxs("svg",{className:e,viewBox:"0 0 24 24",width:"16",height:"16",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true","data-icon":"numbered-list",children:[i.jsx("path",{d:"M10 6h11"}),i.jsx("path",{d:"M10 12h11"}),i.jsx("path",{d:"M10 18h11"}),i.jsx("path",{d:"M4 5v3h2"}),i.jsx("path",{d:"M4 11h2l-2 2h2"}),i.jsx("path",{d:"M4 19h2"}),i.jsx("path",{d:"M4 17h2v2"})]})}function my({className:e}){return i.jsxs("svg",{className:e,viewBox:"0 0 24 24",width:"16",height:"16",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true","data-icon":"open",children:[i.jsx("path",{d:"M3 7h6l2 2h10v3"}),i.jsx("path",{d:"M3 10l2.2 9h13.6L21 10H3z"})]})}function fy({className:e}){return i.jsxs("svg",{className:e,viewBox:"0 0 24 24",width:"16",height:"16",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true","data-icon":"outdent",children:[i.jsx("path",{d:"M4 6h16"}),i.jsx("path",{d:"M12 12h8"}),i.jsx("path",{d:"M4 18h16"}),i.jsx("path",{d:"M8 9l-4 3 4 3"})]})}function py({className:e}){return i.jsxs("svg",{className:e,viewBox:"0 0 24 24",width:"16",height:"16",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true","data-icon":"pageBreak",children:[i.jsx("path",{d:"M4 10h16",strokeDasharray:"3 2"}),i.jsx("path",{d:"M14 10v8"}),i.jsx("path",{d:"M18 14h4v4h-4z"})]})}function Uo({className:e}){return i.jsxs("svg",{className:e,viewBox:"0 0 24 24",width:"16",height:"16",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true","data-icon":"page-properties",children:[i.jsx("path",{d:"M6 3h8l6 6v12H6z"}),i.jsx("path",{d:"M14 3v6h6"})]})}function Vf({className:e}){return i.jsxs("svg",{className:e,viewBox:"0 0 24 24",width:"16",height:"16",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true","data-icon":"paragraph-properties",children:[i.jsx("path",{d:"M13 4H9a4 4 0 0 0 0 8h2"}),i.jsx("path",{d:"M15 4v16"}),i.jsx("path",{d:"M11 4v16"})]})}function gy({className:e}){return i.jsxs("svg",{className:e,viewBox:"0 0 24 24",width:"16",height:"16",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true","data-icon":"preview",children:[i.jsx("path",{d:"M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"}),i.jsx("path",{d:"M14 2v6h6"}),i.jsx("path",{d:"M8 13h8"}),i.jsx("path",{d:"M8 17h5"})]})}function hy({className:e}){return i.jsxs("svg",{className:e,viewBox:"0 0 24 24",width:"16",height:"16",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true","data-icon":"paragraph-style",children:[i.jsx("path",{d:"M5 6h14"}),i.jsx("path",{d:"M5 10h10"}),i.jsx("path",{d:"M5 14h14"}),i.jsx("path",{d:"M5 18h8"})]})}function by({className:e}){return i.jsxs("svg",{className:e,viewBox:"0 0 24 24",width:"16",height:"16",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true","data-icon":"plus",children:[i.jsx("path",{d:"M12 5v14"}),i.jsx("path",{d:"M5 12h14"})]})}function yy({className:e}){return i.jsxs("svg",{className:e,viewBox:"0 0 24 24",width:"16",height:"16",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true","data-icon":"print",children:[i.jsx("path",{d:"M6 9V3h12v6"}),i.jsx("path",{d:"M6 18H4a2 2 0 0 1-2-2v-5a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2v5a2 2 0 0 1-2 2h-2"}),i.jsx("path",{d:"M6 14h12v8H6z"})]})}function xy({className:e}){return i.jsxs("svg",{className:e,viewBox:"0 0 24 24",width:"16",height:"16",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true","data-icon":"read-aloud",children:[i.jsx("path",{d:"M11 5L6 9H2v6h4l5 4V5z"}),i.jsx("path",{d:"M15.54 8.46a5 5 0 0 1 0 7.07"}),i.jsx("path",{d:"M19.07 4.93a10 10 0 0 1 0 14.14"})]})}function Cy({className:e}){return i.jsxs("svg",{className:e,viewBox:"0 0 24 24",width:"16",height:"16",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true","data-icon":"redo",children:[i.jsx("path",{d:"M21 10H10a5 5 0 0 0 0 10h1"}),i.jsx("path",{d:"M17 6l4 4-4 4"})]})}function wy({className:e}){return i.jsxs("svg",{className:e,viewBox:"0 0 24 24",width:"16",height:"16",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true","data-icon":"row-properties",children:[i.jsx("rect",{x:"3",y:"4",width:"18",height:"16",rx:"1"}),i.jsx("path",{d:"M3 10h18"}),i.jsx("path",{d:"M3 16h18"}),i.jsx("rect",{x:"3.5",y:"4.5",width:"17",height:"5",fill:"currentColor",stroke:"none",opacity:"0.25"})]})}function vy({className:e}){return i.jsxs("svg",{className:e,viewBox:"0 0 24 24",width:"16",height:"16",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true","data-icon":"ruler",children:[i.jsx("path",{d:"M4 8h16"}),i.jsx("path",{d:"M4 16h16"}),i.jsx("path",{d:"M6 8v8"}),i.jsx("path",{d:"M10 8v4"}),i.jsx("path",{d:"M14 8v6"}),i.jsx("path",{d:"M18 8v8"})]})}function ky({className:e}){return i.jsxs("svg",{className:e,viewBox:"0 0 24 24",width:"16",height:"16",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true","data-icon":"save",children:[i.jsx("path",{d:"M5 3h11l5 5v13H5V3z"}),i.jsx("path",{d:"M15 3v6H9V3"}),i.jsx("path",{d:"M8 21v-7h8v7"})]})}function _l({className:e}){return i.jsxs("svg",{className:e,viewBox:"0 0 24 24",width:"16",height:"16",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true","data-icon":"table-column",children:[i.jsx("rect",{x:"3",y:"4",width:"18",height:"16",rx:"1"}),i.jsx("path",{d:"M3 10h18"}),i.jsx("path",{d:"M3 16h18"}),i.jsx("path",{d:"M9 4v16"}),i.jsx("path",{d:"M15 4v16"}),i.jsx("rect",{x:"9.5",y:"5",width:"5",height:"14",fill:"currentColor",stroke:"none",opacity:"0.25"})]})}function Cm({className:e}){return i.jsxs("svg",{className:e,viewBox:"0 0 24 24",width:"16",height:"16",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true","data-icon":"table",children:[i.jsx("rect",{x:"3",y:"4",width:"18",height:"16",rx:"1"}),i.jsx("path",{d:"M3 10h18"}),i.jsx("path",{d:"M3 16h18"}),i.jsx("path",{d:"M9 4v16"}),i.jsx("path",{d:"M15 4v16"})]})}function Ml({className:e}){return i.jsxs("svg",{className:e,viewBox:"0 0 24 24",width:"16",height:"16",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true","data-icon":"table-row",children:[i.jsx("rect",{x:"3",y:"4",width:"18",height:"16",rx:"1"}),i.jsx("path",{d:"M3 10h18"}),i.jsx("path",{d:"M3 16h18"}),i.jsx("rect",{x:"4",y:"10.5",width:"16",height:"5",fill:"currentColor",stroke:"none",opacity:"0.25"})]})}function Sy({className:e}){return i.jsxs("svg",{className:e,viewBox:"0 0 24 24",width:"16",height:"16",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true","data-icon":"strikethrough",children:[i.jsx("path",{d:"M6 7.5C6 5.5 8 4 12 4s6 1.5 6 3.5-1.8 2.8-6 3.5"}),i.jsx("path",{d:"M6 16.5C6 18.5 8 20 12 20s6-1.5 6-3.5c0-1-.5-1.8-1.8-2.5"}),i.jsx("path",{d:"M4 12h16"})]})}function Ay({className:e}){return i.jsxs("svg",{className:e,viewBox:"0 0 24 24",width:"16",height:"16",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true","data-icon":"underline",children:[i.jsx("path",{d:"M7 4v8a5 5 0 0 0 10 0V4"}),i.jsx("path",{d:"M5 20h14"})]})}function Py({className:e}){return i.jsxs("svg",{className:e,viewBox:"0 0 24 24",width:"16",height:"16",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true","data-icon":"undo",children:[i.jsx("path",{d:"M3 10h11a5 5 0 0 1 0 10h-1"}),i.jsx("path",{d:"M7 6L3 10l4 4"})]})}function Ty({className:e}){return i.jsxs("svg",{className:e,viewBox:"0 0 24 24",width:"16",height:"16",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true","data-icon":"unmerge-cells",children:[i.jsx("rect",{x:"3",y:"4",width:"18",height:"16",rx:"1"}),i.jsx("path",{d:"M12 4v16"}),i.jsx("path",{d:"M3 12h18"}),i.jsx("path",{d:"M9 9l-3 3 3 3"}),i.jsx("path",{d:"M15 9l3 3-3 3"})]})}function Ry({className:e}){return i.jsxs("svg",{className:e,viewBox:"0 0 24 24",width:"16",height:"16",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true","data-icon":"visual",children:[i.jsx("path",{d:"M2 12s4-7 10-7 10 7 10 7-4 7-10 7S2 12 2 12z"}),i.jsx("circle",{cx:"12",cy:"12",r:"3"})]})}function Dy({className:e}){return i.jsxs("svg",{className:e,viewBox:"0 0 24 24",width:"16",height:"16",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true","data-icon":"youtube",children:[i.jsx("rect",{x:"2",y:"5",width:"20",height:"14",rx:"3"}),i.jsx("path",{d:"m10 9 6 3-6 3V9Z",fill:"currentColor",stroke:"none"})]})}const Ce="---";function Un(e){return e===Ce}function Vn(e){return typeof e=="object"&&e!==null&&"submenu"in e}const $c=new Set(["save","open","print","undo","redo","link","bookmark","horizontalRule","pageBreak","insertPageBefore","insertPageAfter","deletePage","visual","html","customizeToolbar","toolbarPositionTop","toolbarPositionLeft","toolbarPositionRight","toolbarPositionBottom","lightMode","darkMode","preview","readAloud","fullscreen","bold","italic","underline","strikethrough","clearFormatting","formatBrush","fontSize","fontFamily","paragraphStyle","fontProperties","customCss","paragraphProperties","pageProperties","imageProperties","fontColor","highlightColor","alignLeft","alignCenter","alignRight","alignJustify","indent","outdent","bulletList","numberedList","table","insertRowBelow","insertRowBefore","deleteRow","insertColumnAfter","insertColumnBefore","deleteColumn","mergeCells","unmergeCells","tableProperties","cellProperties","rowProperties"]),jy=new Set(["file","edit","view","insert","format","table","help"]),Wf="custom",Gf="custom";function Zf(e){return`custom:${e}`}function Iy(e){return e==="menu"||e==="both"}function Ey(e){return e==="toolbar"||e==="both"}function qf(e){return e.map(t=>Vn(t)?{submenu:t.submenu,items:qf(t.items)}:t)}function _y(e){return{menus:e.menus.map(t=>({id:t.id,items:qf(t.items)})),iconGroups:e.iconGroups.map(t=>({id:t.id,items:[...t.items]}))}}function Yf(e){return Un(e)?!0:Vn(e)?e.items.every(Yf):$c.has(e)}function Xf(e,t){for(const n of e)if(n===t||Vn(n)&&Xf(n.items,t))return!0;return!1}function My(e){const t=e.tooltip??e.label;return{id:e.id,command:Zf(e.id),icon:e.icon??qb,label:e.label,ariaLabel:e.label,tooltip:t}}function Ny(e,t,n,r){if(e.menus[n])r&&!e.menus[n].label&&!jy.has(n)&&(e.menus[n]={...e.menus[n],label:r,ariaLabel:r});else if(n===Wf&&!r)e.menus[n]={id:n,labelKey:"menuCustom",ariaKey:"menuCustomAria"};else{const o=r??n;e.menus[n]={id:n,label:o,ariaLabel:o}}t.menus.some(o=>o.id===n)||t.menus.push({id:n,items:[]})}function Ly(e,t,n){if(e.groups[n]||(n===Gf?e.groups[n]={id:n,labelKey:"toolbarGroupCustom"}:e.groups[n]={id:n,label:n}),!t.iconGroups.some(r=>r.id===n)){const r={id:n,items:[]},o=t.iconGroups.findIndex(a=>a.items.includes("fullscreen"));o===-1?t.iconGroups.push(r):t.iconGroups.splice(o,0,r)}}function By(e,t,n){var a,s;const r={menus:{...t.menus},submenus:{...t.submenus},groups:{...t.groups},items:{...t.items}},o=_y(n);for(const u of e??[])if(!($c.has(u.id)||Un(u.id))){if(r.items[u.id]=My(u),Iy(u.showIn)){const d=((a=u.menu)==null?void 0:a.id)??Wf;Ny(r,o,d,(s=u.menu)==null?void 0:s.label);const f=o.menus.find(g=>g.id===d);if(f&&!Xf(f.items,u.id)){const g=f.items[f.items.length-1];g!==void 0&&!Un(g)&&f.items.every(Yf)&&f.items.push(Ce),f.items.push(u.id)}}if(Ey(u.showIn)){const d=u.toolbarGroup??Gf;Ly(r,o,d);const f=o.iconGroups.find(g=>g.id===d);f&&!f.items.includes(u.id)&&f.items.push(u.id)}}return{catalog:r,layout:o}}function Fy(e,t){const n={};for(const r of e??[])$c.has(r.id)||Un(r.id)||(n[Zf(r.id)]=()=>r.onAction(t()));return n}function Hy(e){return{cut:async()=>{await e.cut()},copy:async()=>{await e.copy()},deleteSelection:()=>{e.deleteSelection()}}}const zy="_chrome_boy0f_1",Oy={chrome:zy},Jf=l.createContext(!1);function Ky({dark:e,children:t}){return i.jsx(Jf.Provider,{value:e,children:t})}function $y(){return l.useContext(Jf)}function ic(e){return{className:Oy.chrome,"data-wysiwyg-theme":e?"dark":"light"}}function we({children:e}){const t=$y(),n=ic(t);return Kc.createPortal(i.jsx("div",{className:n.className,"data-wysiwyg-theme":n["data-wysiwyg-theme"],children:e}),document.body)}function Uc(e,t){const n=e[t];n==null||n()}const Vc={modeVisual:"Visual",modeHtml:"HTML",modeVisualAria:"Switch to visual mode",modeHtmlAria:"Switch to HTML mode",modeFullscreen:"Full screen",modeFullscreenAria:"Toggle full screen",modeLight:"Light mode",modeLightAria:"Switch to light mode",modeDark:"Dark mode",modeDarkAria:"Switch to dark mode",exitFullscreenAria:"Exit full screen",visualEditorAria:"Visual editor",htmlEditorAria:"HTML editor",htmlModePageTab:"Page {n}",htmlModePageTabsAria:"HTML source pages",htmlModePageTabsScrollLeftAria:"Scroll page tabs left",htmlModePageTabsScrollRightAria:"Scroll page tabs right",menuFile:"File",menuFileAria:"File menu",menuEdit:"Edit",menuEditAria:"Edit menu",menuInsert:"Insert",menuInsertAria:"Insert menu",menuView:"View",menuViewAria:"View menu",menuFormat:"Format",menuFormatAria:"Format menu",menuFont:"Fonts",menuFontAria:"Fonts submenu",menuParagraph:"Paragraph",menuParagraphAria:"Paragraph submenu",menuParagraphStyles:"Paragraph styles",menuParagraphStylesAria:"Paragraph styles submenu",menuPage:"Page",menuPageAria:"Page submenu",menuToolbar:"Toolbar",menuToolbarAria:"Toolbar submenu",menuToolbarPosition:"Position",menuToolbarPositionAria:"Toolbar position submenu",toolbarPositionTop:"Top",toolbarPositionTopAria:"Dock toolbar at the top",toolbarPositionLeft:"Left",toolbarPositionLeftAria:"Dock toolbar on the left",toolbarPositionRight:"Right",toolbarPositionRightAria:"Dock toolbar on the right",toolbarPositionBottom:"Bottom",toolbarPositionBottomAria:"Dock toolbar at the bottom",menuImage:"Image",menuImageAria:"Image properties",menuInsertRow:"Row",menuInsertRowAria:"Insert or delete row",menuInsertColumn:"Column",menuInsertColumnAria:"Insert or delete column",menuTable:"Table",menuTableAria:"Table menu",menuCustom:"Custom",menuCustomAria:"Custom menu",menuHamburgerAria:"Open menu",menuCloseAria:"Close menu",menuOverlayAria:"Editor menu",brandMarkAria:"CommsPliant HTML editor",commandSave:"Save",commandSaveAria:"Save as HTML file",commandOpen:"Open",commandOpenAria:"Open HTML file",htmlFileDropOverlay:"Drop HTML file to open",commandPrint:"Print",commandPrintAria:"Print document",commandUndo:"Undo",commandUndoAria:"Undo",commandRedo:"Redo",commandRedoAria:"Redo",commandCut:"Cut",commandCutAria:"Cut",commandCopy:"Copy",commandCopyAria:"Copy",commandDelete:"Delete",commandDeleteAria:"Delete",commandLink:"Link",commandLinkAria:"Link",commandBookmark:"Bookmark",commandBookmarkAria:"Bookmark",commandImage:"Image",commandImageAria:"Insert image",commandPageBackgroundImage:"Page background image",commandPageBackgroundImageAria:"Insert page background image",commandParagraphBackgroundImage:"Paragraph background image",commandParagraphBackgroundImageAria:"Insert paragraph background image",commandAudio:"Audio",commandAudioAria:"Insert audio",commandYoutube:"YouTube video",commandYoutubeAria:"Insert YouTube video",commandImageProperties:"Image properties…",commandImagePropertiesAria:"Image properties",commandTable:"Table",commandTableAria:"Insert table",commandHorizontalRule:"Horizontal line",commandHorizontalRuleAria:"Insert horizontal line",commandPageBreak:"Page break",commandPageBreakAria:"Insert page break",menuInsertPage:"Page",menuInsertPageAria:"Insert page submenu",commandInsertPageBefore:"Page before",commandInsertPageBeforeAria:"Insert page before selected page",commandInsertPageAfter:"Page after",commandInsertPageAfterAria:"Insert page after selected page",commandTableProperties:"Table properties…",commandTablePropertiesAria:"Table properties",commandCellProperties:"Cell properties…",commandCellPropertiesAria:"Cell properties",commandRowProperties:"Row properties…",commandRowPropertiesAria:"Row properties",commandInsertRowBelow:"Insert row below",commandInsertRowBelowAria:"Insert row below",commandInsertRowBefore:"Insert row above",commandInsertRowBeforeAria:"Insert row above",commandDeleteRow:"Delete row",commandDeleteRowAria:"Delete row",commandInsertColumnAfter:"Insert column right",commandInsertColumnAfterAria:"Insert column right",commandInsertColumnBefore:"Insert column left",commandInsertColumnBeforeAria:"Insert column left",commandDeleteColumn:"Delete column",commandDeleteColumnAria:"Delete column",commandMergeCells:"Merge cells",commandMergeCellsAria:"Merge selected cells",commandUnmergeCells:"Unmerge cells",commandUnmergeCellsAria:"Split merged cells",contextMenuAria:"Editor context menu",commandBold:"Bold",commandBoldAria:"Bold",commandItalic:"Italic",commandItalicAria:"Italic",commandUnderline:"Underline",commandUnderlineAria:"Underline",commandStrikethrough:"Strikethrough",commandStrikethroughAria:"Strikethrough",commandClearFormatting:"Reset formatting",commandClearFormattingAria:"Reset formatting",commandFormatBrush:"Format brush",commandFormatBrushAria:"Copy formatting",commandFontSize:"Font size",commandFontSizeAria:"Font size",commandFontSizeUnitAria:"Font size unit",commandFontFamily:"Font",commandFontFamilyAria:"Font family",commandFontProperties:"Font properties…",commandFontPropertiesAria:"Font properties",commandCustomCss:"Custom CSS",commandCustomCssAria:"Custom CSS",commandParagraphProperties:"Paragraph properties…",commandParagraphPropertiesAria:"Paragraph properties",commandPageProperties:"Page properties…",commandPagePropertiesAria:"Page properties",commandDeletePage:"Delete page",commandDeletePageAria:"Delete selected page",deletePageDialogTitle:"Delete page",deletePageConfirmMessage:"Are you sure you want to delete the selected page?",commandFontColor:"Font color",commandFontColorAria:"Font color",commandHighlightColor:"Highlight color",commandHighlightColorAria:"Highlight color",commandParagraphStyle:"Styles",commandParagraphStyleAria:"Paragraph styles",commandAlignLeft:"Align left",commandAlignLeftAria:"Align left",commandAlignCenter:"Align center",commandAlignCenterAria:"Align center",commandAlignRight:"Align right",commandAlignRightAria:"Align right",commandAlignJustify:"Justify",commandAlignJustifyAria:"Justify",commandIndent:"Increase indent",commandIndentAria:"Increase indent",commandOutdent:"Decrease indent",commandOutdentAria:"Decrease indent",commandBulletList:"Bullet list",commandBulletListAria:"Bullet list",commandNumberedList:"Numbered list",commandNumberedListAria:"Numbered list",commandCustomizeToolbar:"Customize toolbar",commandCustomizeToolbarAria:"Customize toolbar",commandPreview:"Preview",commandPreviewAria:"Preview document",commandReadAloud:"Read aloud",commandReadAloudAria:"Read selection or document aloud",styleParagraph:"Paragraph",styleHeading1:"Heading 1",styleHeading2:"Heading 2",styleHeading3:"Heading 3",styleHeading4:"Heading 4",styleHeading5:"Heading 5",styleHeading6:"Heading 6",styleAddNew:"Add new",styleAddNewAria:"Add new paragraph style",customStyleDialogAddTitle:"Add paragraph style",customStyleDialogEditTitle:"Edit paragraph style",customStyleDialogTabFont:"Font",customStyleDialogTabParagraph:"Paragraph",customStyleDialogName:"Name",customStyleDialogDelete:"Delete",customStyleDialogDeleteConfirm:"Delete this paragraph style?",customStyleDialogCloseAria:"Close",customStyleLoading:"Loading paragraph styles",colorAutomatic:"Automatic",colorNone:"No color",colorCustom:"Custom color",colorHex:"Hex",colorRgbR:"R",colorRgbG:"G",colorRgbB:"B",colorPickFromScreen:"Pick from screen",colorRecent:"Recent colors",fontDialogTitle:"Font properties",fontDialogTabGeneral:"General",fontDialogFamily:"Font",fontFamilyDefault:"Default",fontDialogSize:"Size",fontDialogUnit:"Unit",fontDialogStyle:"Style",fontDialogOk:"OK",fontDialogCancel:"Cancel",linkDialogTitle:"Insert link",linkDialogTabLink:"Link",linkDialogTabBookmark:"Bookmark",linkDialogHref:"URL",linkDialogHoverTitle:"Title",linkDialogTargetBlank:"Open in a new tab",linkDialogTextDecorationNone:"No underline",linkDialogHover:"On hover",linkDialogHoverColor:"Color",linkDialogHoverColorField:"Hover color",linkDialogHoverHtml:"HTML",linkDialogHoverHtmlAria:"Custom hover HTML",linkDialogBookmark:"Bookmark",linkDialogBookmarkEmpty:"No bookmarks in this document.",linkDialogSelect:"Select",bookmarkDialogTitle:"Insert bookmark",bookmarkDialogName:"Bookmark name",bookmarkDialogHelp:"Start with a letter. Use only letters, numbers, hyphens, and underscores. Must be unique in the document.",bookmarkDialogHelpAria:"Bookmark name format",bookmarkDialogCloseAria:"Close",bookmarkDialogErrorEmpty:"Enter a bookmark name.",bookmarkDialogErrorInvalid:"Start with a letter. Use only letters, numbers, hyphens, and underscores.",bookmarkDialogErrorDuplicate:"A bookmark with this name already exists.",customCssDialogTitle:"Custom CSS",customCssDialogField:"CSS",customCssDialogFieldAria:"Custom CSS declarations",customCssDialogCloseAria:"Close",imageDialogTitle:"Insert image",imageDialogSource:"Source",imageDialogFile:"File",imageDialogChooseFile:"Choose file",imageDialogUrl:"Image URL",imageDialogAlt:"Alt text",imageDialogTitleField:"Title",imageDialogCloseAria:"Close",imageDialogErrorEmpty:"Choose a file or enter an image URL.",imageDialogErrorInvalid:"Enter a valid image URL.",imageDialogErrorType:"Use a JPEG, PNG, GIF, WebP, BMP, or AVIF image.",imageDialogErrorTooLarge:"Choose an image smaller than 2 MB.",audioDialogTitle:"Insert audio",audioDialogSource:"Source",audioDialogFile:"File",audioDialogChooseFile:"Choose file",audioDialogUrl:"Audio URL",audioDialogTitleField:"Title",audioDialogCloseAria:"Close",audioDialogErrorEmpty:"Choose a file or enter an audio URL.",audioDialogErrorInvalid:"Enter a valid audio URL.",audioDialogErrorType:"Use an MP3, WAV, OGG, AAC, WebM, or M4A audio file.",audioDialogErrorTooLarge:"Choose an audio file smaller than 5 MB.",youtubeDialogTitle:"Insert YouTube video",youtubeDialogUrl:"YouTube URL",youtubeDialogTitleField:"Title",youtubeDialogCloseAria:"Close",youtubeDialogErrorEmpty:"Enter a YouTube URL.",youtubeDialogErrorInvalid:"Enter a valid YouTube URL.",imagePropertiesDialogTitle:"Image properties",imagePropertiesDialogCloseAria:"Close",imagePropertiesTabAlignment:"Alignment",imagePropertiesTabBorder:"Border & margin",imagePropertiesTabAdvanced:"Advanced",imagePropertiesTabHover:"Hover",imagePropertiesSize:"Size",imagePropertiesSizeMode:"Size mode",imagePropertiesSizeWidth:"Width only",imagePropertiesSizeHeight:"Height only",imagePropertiesSizeLock:"Lock together",imagePropertiesWidth:"Width",imagePropertiesHeight:"Height",imagePropertiesWidthAria:"Image width",imagePropertiesHeightAria:"Image height",imagePropertiesSizeUnitAria:"Image size unit",imagePropertiesFit:"Fit",imagePropertiesFitDefault:"Default",imagePropertiesFitFill:"Fill",imagePropertiesFitContain:"Contain",imagePropertiesFitCover:"Cover",imagePropertiesFitNoneValue:"None",imagePropertiesFitScaleDown:"Scale down",imagePropertiesPosition:"Position",imagePropertiesPositionDefault:"Default",imagePropertiesPositionCenter:"Center",imagePropertiesPositionTop:"Top",imagePropertiesPositionBottom:"Bottom",imagePropertiesPositionLeft:"Left",imagePropertiesPositionRight:"Right",imagePropertiesPositionTopLeft:"Top left",imagePropertiesPositionTopRight:"Top right",imagePropertiesPositionBottomLeft:"Bottom left",imagePropertiesPositionBottomRight:"Bottom right",imagePropertiesRotation:"Rotation",imagePropertiesRotationUnit:"deg",imagePropertiesHoverCss:"Hover CSS",imagePropertiesHoverCssAria:"Custom hover CSS",imagePropertiesHoverHelp:"CSS applied when the pointer is over the image.",imageResizeHandleEastAria:"Resize image width, keep aspect ratio",imageResizeHandleSouthAria:"Resize image height, keep aspect ratio",imageResizeHandleSouthEastAria:"Resize image freely",tableDialogTitle:"Insert table",tableDialogCloseAria:"Close",tableDialogRows:"Rows",tableDialogColumns:"Columns",tableDialogSize:"Size",tableDialogGridAria:"Table size grid",tableDialogInsert:"Insert",tablePropertiesDialogTitle:"Table properties",tablePropertiesDialogCloseAria:"Close",tablePropertiesCollapse:"Border collapse",tablePropertiesCollapseCollapse:"Collapse",tablePropertiesCollapseSeparate:"Separate",tablePropertiesSpacing:"Border spacing",tablePropertiesWidth:"Width",cellPropertiesDialogTitle:"Cell properties",cellPropertiesDialogCloseAria:"Close",cellPropertiesColor:"Text color",cellPropertiesVerticalAlign:"Vertical align",cellPropertiesVerticalAlignDefault:"Default",cellPropertiesVerticalAlignTop:"Top",cellPropertiesVerticalAlignMiddle:"Middle",cellPropertiesVerticalAlignBottom:"Bottom",cellPropertiesVerticalAlignBaseline:"Baseline",cellPropertiesWidth:"Width",cellPropertiesColSpan:"Column span",cellPropertiesRowSpan:"Row span",rowPropertiesDialogTitle:"Row properties",rowPropertiesDialogCloseAria:"Close",rowPropertiesHeight:"Height",paragraphDialogTitle:"Paragraph properties",pageDialogTitle:"Page properties",pageDialogTabBackgroundImage:"Background Image",pageDialogTabPrint:"Print",pageAtRuleSize:"Page size",pageAtRuleSizeAuto:"Auto",pageAtRuleSizeA4:"A4",pageAtRuleSizeLetter:"Letter",pageAtRuleSizeLegal:"Legal",pageAtRuleSizeCustom:"Custom",pageAtRuleWidth:"Width",pageAtRuleHeight:"Height",pageAtRuleOrientation:"Orientation",pageAtRuleOrientationNone:"Default",pageAtRuleOrientationPortrait:"Portrait",pageAtRuleOrientationLandscape:"Landscape",pageAtRuleMargins:"Page margins",pageAtRuleReset:"Reset print settings",pageAtRuleResetAria:"Remove @page print settings from this page",menuZoom:"Zoom",menuZoomAria:"Zoom submenu",pageZoomFitWidth:"Fit width",pageZoomFitWidthAria:"Fit page width to the editor",pageZoomFitPage:"Fit page",pageZoomFitPageAria:"Fit entire page to the editor",pageZoom50:"50%",pageZoom50Aria:"Zoom to 50 percent",pageZoom75:"75%",pageZoom75Aria:"Zoom to 75 percent",pageZoom100:"100%",pageZoom100Aria:"Zoom to 100 percent",pageZoom125:"125%",pageZoom125Aria:"Zoom to 125 percent",pageZoom150:"150%",pageZoom150Aria:"Zoom to 150 percent",pageZoom200:"200%",pageZoom200Aria:"Zoom to 200 percent",pageBackgroundImagePreview:"Preview",pageBackgroundImagePreviewAlt:"Page background image preview",pageBackgroundImageClear:"Remove background image",pageBackgroundImageCurrent:"Image selected",paragraphDialogTabBorder:"Border",paragraphDialogTabBackground:"Background",paragraphDialogAlignment:"Alignment",paragraphDialogLists:"Lists",paragraphDialogSpacing:"Spacing",paragraphDialogMargin:"Margin",paragraphDialogPadding:"Padding",paragraphDialogLineHeight:"Line height",paragraphDialogLineHeightNormal:"Normal",paragraphDialogLineHeightUnitless:"×",paragraphDialogLinkSides:"Same on all sides",paragraphDialogSideTop:"Top",paragraphDialogSideRight:"Right",paragraphDialogSideBottom:"Bottom",paragraphDialogSideLeft:"Left",paragraphDialogBorder:"Border",paragraphDialogBorderStyle:"Style",paragraphDialogBorderWidth:"Width",paragraphDialogBorderColor:"Color",paragraphDialogBorderRadius:"Corner radius",paragraphDialogBoxShadow:"Box shadow",paragraphDialogShadowOffsetX:"Offset X",paragraphDialogShadowOffsetY:"Offset Y",paragraphDialogShadowBlur:"Blur",paragraphDialogShadowSpread:"Spread",paragraphDialogShadowColor:"Color",paragraphDialogShadowInset:"Inset",paragraphDialogLengthUnitAria:"Unit",paragraphDialogBorderStyleNone:"None",paragraphDialogBorderStyleSolid:"Solid",paragraphDialogBorderStyleDotted:"Dotted",paragraphDialogBorderStyleDashed:"Dashed",paragraphDialogBorderStyleDouble:"Double",paragraphDialogBorderStyleGroove:"Groove",paragraphDialogBorderStyleRidge:"Ridge",paragraphDialogBorderStyleInset:"Inset",paragraphDialogBorderStyleOutset:"Outset",paragraphDialogBackgroundColor:"Background color",paragraphDialogOpacity:"Opacity",paragraphDialogPageBreaks:"Page breaks",paragraphDialogBreakInside:"Break inside",paragraphDialogBreakAfter:"Break after",paragraphDialogBreakBefore:"Break before",paragraphDialogBreakAuto:"Auto",paragraphDialogBreakAvoid:"Avoid",paragraphDialogBreakPage:"Page",fontSizeUnitPt:"pt",fontSizeUnitPx:"px",fontSizeUnitEm:"em",fontSizeUnitRem:"rem",fontSizeUnitPercent:"%",fontSizeUnitPc:"pc",toolbarAria:"Formatting toolbar",toolbarGroupFile:"File",toolbarGroupPrint:"Print",toolbarGroupEdit:"Edit",toolbarGroupInsert:"Insert",toolbarGroupTable:"Table",toolbarGroupFont:"Fonts",toolbarGroupAlign:"Align",toolbarGroupParagraph:"Paragraph",toolbarGroupView:"View",toolbarGroupFullscreen:"Full screen",toolbarGroupCustom:"Custom",customizeToolbarDialogTitle:"Customize toolbar",customizeToolbarDialogReset:"Reset",customizeToolbarDialogClose:"Close",customizeToolbarDialogCloseAria:"Close",customizeToolbarDialogLoading:"Loading toolbar settings",customizeToolbarItemVisible:"Show on toolbar",customizeToolbarDragHandle:"Drag to reorder group",customizeToolbarMoveUp:"Move group up",customizeToolbarMoveDown:"Move group down",previewDialogTitle:"Document preview",previewDialogClose:"Close",previewDialogCloseAria:"Close",commandAddComment:"Add comment",commandAddCommentAria:"Add comment on selection",commandInsertComment:"Comment",commandInsertCommentAria:"Insert comment on selection",showComments:"Show comments",hideComments:"Hide comments",toggleCommentsVisibleAria:"Toggle comment visibility",commandRuler:"Ruler",commandRulerAria:"Show or hide rulers",rulerMarginLeft:"Left margin",rulerMarginRight:"Right margin",rulerMarginTop:"Top margin",rulerMarginBottom:"Bottom margin",rulerFirstLineIndent:"First line indent",rulerLeftIndent:"Left indent",rulerRightIndent:"Right indent",commentPanelTitle:"Comment",commentPlaceholder:"Write a comment…",commentReplyPlaceholder:"Write a reply…",commentPost:"Post",commentEmpty:"No messages yet.",commentPanelCloseAria:"Close comment panel",menuHelp:"Help",menuHelpAria:"Help menu",commandEditorHelp:"Editor Help",commandEditorHelpAria:"Open editor help",commandKeyboardShortcuts:"Keyboard shortcuts",commandKeyboardShortcutsAria:"Open keyboard shortcuts help",commandAbout:"About",commandAboutAria:"About this editor",helpDialogTitle:"Help",helpDialogCloseAria:"Close help",helpDialogSearchPlaceholder:"Search help topics…",helpDialogSearchAria:"Search help",helpDialogContentsAria:"Help contents",helpDialogNoResults:"No help topics match your search.",helpDialogRelatedTitle:"Related topics",aboutDialogTitle:"About",aboutDialogCloseAria:"Close about dialog",aboutDialogClose:"Close",aboutDialogVersion:"Version {version}",aboutDialogDescription:"CommsPliant HTML editor is a reusable React WYSIWYG component with Visual and HTML editing modes. Licensed under the MIT License.",aboutDialogWebsiteCta:"See what we're building for regulated communication solutions.",aboutDialogWebsite:"Visit commspliant.com",aboutDialogWebsiteAria:"Visit CommsPliant — regulated communication management",helpCategoryGetStarted:"Get started",helpCategoryFile:"File",helpCategoryEdit:"Edit",helpCategoryInsert:"Insert",helpCategoryFormat:"Format",helpCategoryTable:"Table",helpCategoryView:"View",helpCategoryKeyboard:"Keyboard",helpTopicGetStartedTitle:"How do I use this editor?",helpTopicGetStartedBody:`1. Type in the visual editing area.
2
2
  2. Use the menu bar and icon toolbar for formatting and inserts.
3
3
  3. Open Help → Editor Help (or press F1) anytime you need guidance.`,helpTopicGetStartedKeywords:"start basics toolbar menu",helpTopicSwitchModesTitle:"How do I switch between Visual and HTML?",helpTopicSwitchModesBody:`1. Open View → Visual for WYSIWYG editing.
4
4
  2. Open View → HTML to edit the source directly.
@@ -136,10 +136,10 @@ Tachado: Ctrl+Mayús+X
136
136
  Imprimir: Ctrl+P | Salto de página: Ctrl+Intro
137
137
  Tabla: Tab / Mayús+Tab
138
138
  Salir de pantalla completa o cerrar paneles: Escape
139
- Abrir Ayuda: F1`,helpTopicKeyboardShortcutsKeywords:"atajos teclado"},Vy={en:zc,es:Uy},Qf=l.createContext(e=>zc[e]);function Wy({locale:e="en",children:t}){const n=l.useMemo(()=>{const r=Vy[e]??zc;return o=>r[o]},[e]);return i.jsx(Qf.Provider,{value:n,children:t})}function q(){return l.useContext(Qf)}const Gy="_menu_c1m45_1",Zy="_item_c1m45_19",qy="_separator_c1m45_59",jl={menu:Gy,item:Zy,separator:qy},ua=8,Yy=[{type:"item",command:"deleteSelection",labelKey:"commandDelete",ariaKey:"commandDeleteAria",enabled:e=>e==="text"||e==="image"},{type:"item",command:"cut",labelKey:"commandCut",ariaKey:"commandCutAria",enabled:e=>e==="text"||e==="image"},{type:"item",command:"copy",labelKey:"commandCopy",ariaKey:"commandCopyAria",enabled:e=>e==="text"||e==="image"},{type:"separator"},{type:"item",command:"openLinkDialog",labelKey:"commandLink",ariaKey:"commandLinkAria",enabled:e=>e!=="image"},{type:"item",command:"addComment",labelKey:"commandInsertComment",ariaKey:"commandInsertCommentAria",enabled:(e,t)=>t.canAddComment&&(e==="text"||e==="image")},{type:"separator"},{type:"item",command:"openFontProperties",labelKey:"commandFontProperties",ariaKey:"commandFontPropertiesAria",enabled:e=>e!=="image"},{type:"item",command:"openParagraphProperties",labelKey:"commandParagraphProperties",ariaKey:"commandParagraphPropertiesAria",enabled:e=>e!=="image"},{type:"item",command:"openPageProperties",labelKey:"commandPageProperties",ariaKey:"commandPagePropertiesAria",enabled:e=>e!=="image"},{type:"item",command:"deletePage",labelKey:"commandDeletePage",ariaKey:"commandDeletePageAria",enabled:(e,t)=>t.canDeletePage},{type:"item",command:"openImageProperties",labelKey:"commandImageProperties",ariaKey:"commandImagePropertiesAria",enabled:e=>e==="image"},{type:"item",command:"openTableProperties",labelKey:"commandTableProperties",ariaKey:"commandTablePropertiesAria",enabled:(e,t)=>t.inTable},{type:"item",command:"openCellProperties",labelKey:"commandCellProperties",ariaKey:"commandCellPropertiesAria",enabled:(e,t)=>t.inTable},{type:"item",command:"openRowProperties",labelKey:"commandRowProperties",ariaKey:"commandRowPropertiesAria",enabled:(e,t)=>t.inTable},{type:"item",command:"mergeCells",labelKey:"commandMergeCells",ariaKey:"commandMergeCellsAria",enabled:(e,t)=>t.canMergeCells},{type:"item",command:"unmergeCells",labelKey:"commandUnmergeCells",ariaKey:"commandUnmergeCellsAria",enabled:(e,t)=>t.canUnmergeCells}];function Xy(e,t){const n=[];let r=!1;for(const o of Yy){if(o.type==="separator"){n.length>0&&(r=!0);continue}o.enabled(e,t)&&(r&&(n.push({type:"separator"}),r=!1),n.push(o))}return n}function Cm(){return'[role="menuitem"]:not(:disabled)'}function Jy({open:e,x:t,y:n,kind:r,inTable:o=!1,canMergeCells:a=!1,canUnmergeCells:s=!1,canDeletePage:u=!1,canAddComment:d=!1,commands:f,onClose:g}){const h=q(),C=l.useId(),b=l.useRef(null);if(l.useLayoutEffect(()=>{var R;if(!e)return;const v=b.current;if(!v)return;const k=v.getBoundingClientRect(),S=Math.max(ua,Math.min(t,window.innerWidth-k.width-ua)),P=Math.max(ua,Math.min(n,window.innerHeight-k.height-ua));v.style.left=`${S}px`,v.style.top=`${P}px`,(R=v.querySelector(Cm()))==null||R.focus()},[e,t,n,r]),l.useEffect(()=>{if(!e)return;const v=R=>{var D;(D=b.current)!=null&&D.contains(R.target)||g()},k=R=>{R.key==="Escape"&&(R.preventDefault(),R.stopPropagation(),g())},S=()=>{g()},P=R=>{var D;if((D=b.current)!=null&&D.contains(R.target)){R.preventDefault();return}R.defaultPrevented||g()};return document.addEventListener("pointerdown",v),document.addEventListener("keydown",k,!0),window.addEventListener("scroll",S,!0),document.addEventListener("contextmenu",P),()=>{document.removeEventListener("pointerdown",v),document.removeEventListener("keydown",k,!0),window.removeEventListener("scroll",S,!0),document.removeEventListener("contextmenu",P)}},[e,g]),!e)return null;const x=Xy(r,{inTable:o,canMergeCells:a,canUnmergeCells:s,canDeletePage:u,canAddComment:d}),y=v=>{var D;if(v.key!=="ArrowDown"&&v.key!=="ArrowUp")return;const k=[...((D=b.current)==null?void 0:D.querySelectorAll(Cm()))??[]];if(k.length===0)return;const S=k.indexOf(document.activeElement),P=v.key==="ArrowDown"?1:-1,R=k[(S+P+k.length)%k.length];v.preventDefault(),R==null||R.focus()};return i.jsx(we,{children:i.jsxs("div",{ref:b,className:jl.menu,role:"menu","aria-labelledby":C,style:{left:t,top:n},onMouseDown:v=>v.preventDefault(),onKeyDown:y,children:[i.jsx("span",{id:C,hidden:!0,children:h("contextMenuAria")}),x.map((v,k)=>v.type==="separator"?i.jsx("div",{role:"separator",className:jl.separator},`separator-${k}`):i.jsx("button",{type:"button",role:"menuitem",className:jl.item,"aria-label":h(v.ariaKey),onClick:()=>{g(),Hc(f,v.command)},children:h(v.labelKey)},v.command))]})})}function Qy(e){return e==="touch"||e==="pen"}function ex(e,t){return e.button===2||e.ctrlKey?!0:!Qy(t)}const tx=new Set(["span","strong","b","em","i","u","s","strike","del"]);function ke(e,t){return t?e===t||e.contains(t):!1}function mn(e){return tx.has(e.tagName.toLowerCase())}function nx(e,t){const n=document.createRange();return n.selectNodeContents(t),e.compareBoundaryPoints(Range.END_TO_START,n)<0&&e.compareBoundaryPoints(Range.START_TO_END,n)>0}function Pt(e){const t=e.commonAncestorContainer;if(t.nodeType===Node.TEXT_NODE)return t.nodeValue?[t]:[];const n=[],r=document.createTreeWalker(t,NodeFilter.SHOW_TEXT);let o;for(;o=r.nextNode();)o.nodeValue&&nx(e,o)&&n.push(o);return n}function un(e){const t=e.startContainer,n=e.startOffset;if(t.nodeType===Node.TEXT_NODE){const a=t;if(n>0&&n<a.length){const s=a.splitText(n);e.setStart(s,0),e.endContainer===a&&e.setEnd(s,e.endOffset-n)}}const r=e.endContainer,o=e.endOffset;if(r.nodeType===Node.TEXT_NODE){const a=r;o>0&&o<a.length&&(a.splitText(o),e.setEnd(a,a.length))}}function Gn(e){return e.tagName.toLowerCase()!=="span"||e.style.cssText.trim()?!1:(e.removeAttribute("style"),e.attributes.length===0)}function Nt(e){const t=e.parentNode;if(t){for(;e.firstChild;)t.insertBefore(e.firstChild,e);t.removeChild(e)}}function Zn(e,t){const n=[...e.childNodes],r=n.indexOf(t);if(r<=-1||n.length===1)return;const o=e.parentNode;if(!o)return;const a=n.slice(0,r),s=n.slice(r+1);if(a.length>0){const u=e.cloneNode(!1);for(const d of a)u.appendChild(d);o.insertBefore(u,e)}if(s.length>0){const u=e.cloneNode(!1);for(const d of s)u.appendChild(d);o.insertBefore(u,e.nextSibling)}}function yr(e){if(e.length===0)return;const t=e[0],n=e[e.length-1],r=document.createRange();r.setStart(t,0),r.setEnd(n,n.data.length);const o=window.getSelection();o==null||o.removeAllRanges(),o==null||o.addRange(r)}function ti(e,t){const n=e.parentElement;if(n&&n.tagName.toLowerCase()==="span"&&n.childNodes.length===1)return t(n),n;const r=document.createElement("span");return t(r),n==null||n.insertBefore(r,e),r.appendChild(e),r}const rs="data-wysiwyg-font",rx=[{name:"Arial",family:"Arial, Helvetica, sans-serif"},{name:"Arial Black",family:"'Arial Black', Gadget, sans-serif"},{name:"Comic Sans MS",family:"'Comic Sans MS', Textile, cursive"},{name:"Courier New",family:"'Courier New', Courier, monospace"},{name:"Georgia",family:"Georgia, serif"},{name:"Helvetica",family:"Helvetica, Arial, sans-serif"},{name:"Impact",family:"Impact, Charcoal, sans-serif"},{name:"Lucida Console",family:"'Lucida Console', Monaco, monospace"},{name:"Lucida Sans Unicode",family:"'Lucida Sans Unicode', 'Lucida Grande', sans-serif"},{name:"Palatino Linotype",family:"'Palatino Linotype', Palatino, serif"},{name:"Tahoma",family:"Tahoma, Geneva, sans-serif"},{name:"Times New Roman",family:"'Times New Roman', Times, serif"},{name:"Trebuchet MS",family:"'Trebuchet MS', Helvetica, sans-serif"},{name:"Verdana",family:"Verdana, Geneva, sans-serif"}];function gr(e){return e.split(",").map(t=>t.trim().replace(/^["']|["']$/g,"").toLowerCase()).filter(Boolean).join(",")}function ni(e,t){return e===t?!0:!e||!t?!1:gr(e)===gr(t)}function ep(e=[]){var r;const t=[],n=new Set;for(const o of[...rx,...e]){const a=o.family.trim();if(!a)continue;const s=gr(a);if(n.has(s))continue;n.add(s);const u=(r=o.css)==null?void 0:r.trim();t.push({name:o.name.trim()||a,family:a,...u?{css:u}:{}})}return t}function ox(e,t){return e?t.find(n=>ni(n.family,e))??null:null}function ix(e){try{const t=new URL(e);return t.protocol==="http:"||t.protocol==="https:"}catch{return!1}}function ax(e){return e.replace(/&/g,"&amp;").replace(/"/g,"&quot;").replace(/</g,"&lt;")}function os(e){const t=new Set,n=[];for(const r of e){const o=r.trim();!o||!ix(o)||t.has(o)||(t.add(o),n.push(o))}return n}function sx(e){return e.replace(/&quot;/g,'"').replace(/&lt;/g,"<").replace(/&amp;/g,"&")}const lx=new RegExp(`<link\\b[^>]*\\b${rs}\\b[^>]*>`,"gi");function he(e){if(!e.includes(rs))return{hrefs:[],body:e};const t=[],n=e.replace(lx,r=>{var a,s;const o=((a=r.match(/\bhref\s*=\s*"([^"]*)"/i))==null?void 0:a[1])??((s=r.match(/\bhref\s*=\s*'([^']*)'/i))==null?void 0:s[1]);return o&&t.push(sx(o)),""});return{hrefs:os(t),body:n}}function da(e,t){const n=os(t);return n.length===0?e:`${n.map(o=>`<link rel="stylesheet" href="${ax(o)}" ${rs}="">`).join("")}${e}`}function Oc(e){return e.style.fontFamily.trim()||null}const cx=32,Fo=new Map;function tp(e,t){return`${gr(t)}\0${e}`}function ux(e,t){return Fo.get(tp(e,t))}function Il(e,t,n){const r=tp(e,t);if(Fo.size>=cx){const o=Fo.keys().next().value;o!==void 0&&Fo.delete(o)}Fo.set(r,n)}function np(e,t){const n=e.ownerDocument.createTreeWalker(e,NodeFilter.SHOW_ELEMENT);let r=n.currentNode;for(;r;){if(r instanceof HTMLElement){const o=Oc(r);if(o&&gr(o)===t)return!0}r=n.nextNode()}return!1}function dx(e,t){const n=gr(t);return n?np(e,n):!1}function mx(e,t){const n=gr(t);if(!n)return!1;const r=ux(e,t);if(r!==void 0)return r;const o=e.toLowerCase();if(!o.includes("font-family")&&!o.includes("face="))return Il(e,t,!1),!1;const a=n.split(",")[0].replace(/['"]/g,"").trim().toLowerCase();if(a&&!o.includes(a))return Il(e,t,!1),!1;const s=new DOMParser().parseFromString(e,"text/html"),u=np(s.body,n);return Il(e,t,u),u}function ma(e,t,n=[],r){const o=he(t).hrefs,a=n.filter(s=>s.css?r!=null&&r.liveRoot?dx(r.liveRoot,s.family):mx(e,s.family):!1).map(s=>s.css??"");return os([...o,...a])}function wm(e,t=[]){const n=he(e).hrefs,r=t.map(o=>o.css??"");return os([...n,...r])}function fx(e){return e.nodeType===Node.TEXT_NODE?e.parentElement:e instanceof Element?e:e.parentElement}function Kc(e,t){let n=fx(t);for(;n&&n!==e&&n instanceof HTMLElement;){const r=Oc(n);if(r)return r;n=n.parentElement}return null}function tc(e){return e instanceof HTMLElement&&Oc(e)!==null}function $c(e){e.style.fontFamily="",e.style.removeProperty("font-family")}function px(e,t){let n=t;for(;n.parentElement&&n.parentElement!==e;){const r=n.parentElement;if(!mn(r)||!tc(r)){n=r;continue}if(Zn(r,n),tc(r)&&($c(r),Gn(r))){Nt(r);continue}n=r}}function rp(e){const t=window.getSelection();if(!t||t.rangeCount===0)return null;const n=t.getRangeAt(0);return ke(e,n.commonAncestorContainer)?n:null}function op(e){const t=rp(e);if(!t)return{value:null,mixed:!1};const n=t.collapsed?[]:Pt(t).filter(u=>u.data.length>0),o=(n.length>0?n:[t.startContainer]).map(u=>Kc(e,u)),a=o[0]??null;return o.every(u=>ni(u,a))?{value:a,mixed:!1}:{value:null,mixed:!0}}function nc(e,t){const n=rp(e);if(!n||n.collapsed)return!1;const r=t!=null&&t.trim()?t.trim():null;un(n);const o=Pt(n).filter(a=>a.data.length>0);for(const a of o){const s=Kc(e,a);if(r===null){if(s===null)continue;px(e,a);continue}ni(s,r)||ti(a,u=>{u.style.fontFamily=r})}return yr(o),!0}function gx(e,t){if(t){if(t.value===null){$c(e);return}e.style.fontFamily=t.value}}function hx(e){return e!=null}function bx(e){const t=e.startContainer,n=e.startOffset;if(t.nodeType!==Node.TEXT_NODE)return;const r=t;if(n<=0||n>=r.length)return;const o=r.splitText(n);e.setStart(o,0),e.collapse(!0)}function yx(e){var r,o,a;let t=e.startContainer.nodeType===Node.TEXT_NODE&&e.startOffset===0?e.startContainer:e.startContainer.childNodes[e.startOffset]??e.startContainer.lastChild??e.startContainer;if(e.startContainer.nodeType===Node.TEXT_NODE&&e.startOffset>0){const s=document.createTextNode("");return(r=e.startContainer.parentNode)==null||r.insertBefore(s,e.startContainer.nextSibling),s}if(e.startContainer.nodeType===Node.TEXT_NODE&&e.startOffset===0){const s=document.createTextNode("");return(o=e.startContainer.parentNode)==null||o.insertBefore(s,e.startContainer),s}const n=document.createTextNode("");return t&&t!==e.startContainer?(a=t.parentNode)==null||a.insertBefore(n,t):e.startContainer.appendChild(n),n}function rc(e,t){let n=t;for(;n.parentElement&&n.parentElement!==e;){const r=n.parentElement;if(!mn(r)||!tc(r)){n=r;continue}if(Zn(r,n),$c(r),Gn(r)){Nt(r);continue}n=r.isConnected?r:t}return t}function xx(e,t){bx(t);const n=yx(t);return rc(e,n)}function Cx(e,t,n){return!!(n&&n.value===null&&Kc(e,t))}const Uc=["pt","px","em","rem","%"],Xr="pt",wx={pt:[8,9,10,11,12,14,16,18,20,22,24,26,28,36,48,72],px:[8,9,10,11,12,14,16,18,20,22,24,26,28,36,48,72],em:[.5,.75,1,1.25,1.5,2,2.5,3],rem:[.5,.75,1,1.25,1.5,2,2.5,3],"%":[50,75,100,125,150,200,250,300]},vx={pt:{min:1,max:400},px:{min:1,max:400},em:{min:.1,max:20},rem:{min:.1,max:20},"%":{min:1,max:1e3}},kx=new Set(Uc),Sx=/^([+-]?(?:\d+(?:\.\d+)?|\.\d+))\s*(pt|px|em|rem|%|pc|cm|mm|in|ex|ch|q|vw|vh|vmin|vmax)$/i;function is(e){return kx.has(e)}function rt(e){return Math.round(e*100)/100}function de(e){const t=rt(e);return Number.isInteger(t),String(t)}function Vc(e,t){return`${de(e)}${t}`}function Wc(e){const t=e.trim();if(!t)return null;const n=t.match(Sx);if(!n)return null;const r=Number(n[1]);if(!Number.isFinite(r))return null;const o=n[2]==="%"?"%":n[2].toLowerCase();return{value:r,unit:o}}function Ax(e,t){const n=e.trim();if(!n)return null;const r=Wc(n);if(r)return is(r.unit)?pr(r.value,r.unit):null;const o=Number(n.replace(",","."));return Number.isFinite(o)?pr(o,t):null}function pr(e,t){if(!Number.isFinite(e)||e<=0)return null;const{min:n,max:r}=vx[t];return{value:rt(Math.min(r,Math.max(n,e))),unit:t}}function ip(e,t,n,r){const o=n>0?n:16,a=r>0?r:16;switch(t){case"px":return rt(e);case"pt":return rt(e*.75);case"em":return rt(e/o);case"rem":return rt(e/a);case"%":return rt(e/o*100)}}function Px(e,t,n,r){const o=n>0?n:16,a=r>0?r:16;switch(t){case"px":return e;case"pt":return e*(4/3);case"em":return e*o;case"rem":return e*a;case"%":return e/100*o}}function ap(e,t,n,r,o){if(t===n)return rt(e);const a=Px(e,t,r,o);return ip(a,n,r,o)}const Gc="pt",Tx=/^([+-]?(?:\d+(?:\.\d+)?|\.\d+))\s*(pt|px|em|rem|%)$/i,Rx=/^[+-]?0(?:\.0+)?$/;function Ie(e){return`${de(e.value)}${e.unit}`}function ht(e){const t=e.trim();if(!t)return null;if(Rx.test(t))return{value:0,unit:"px"};const n=t.match(Tx);if(!n)return null;const r=Number(n[1]);if(!Number.isFinite(r))return null;const o=n[2]==="%"?"%":n[2].toLowerCase();return is(o)?{value:rt(r),unit:o}:null}function Wo(e,t,n){const r=e.trim();if(!r)return null;const o=ht(r);if(o)return!n&&o.value<0?{...o,value:0}:o;const a=Number(r.replace(",","."));return Number.isFinite(a)?!n&&a<0?{value:0,unit:t}:{value:rt(a),unit:t}:null}function qn(e){return e.value>=0?e:{value:0,unit:e.unit}}function zt(e,t){return e===t?!0:!e||!t?!1:e.value===t.value&&e.unit===t.unit}function fa(e){return{text:e.text,collapsed:e.collapsed,start:e.start,end:e.end}}function Dx(e,t){return t?e===t||e.contains(t):!1}function vm(e,t){var a;const n=document.createTreeWalker(e,NodeFilter.SHOW_TEXT);let r=0,o;for(;o=n.nextNode();){if(o===t||t.contains(o)||t.compareDocumentPosition(o)&Node.DOCUMENT_POSITION_FOLLOWING)return r;r+=((a=o.textContent)==null?void 0:a.length)??0}return r}function km(e,t,n){var a;if(t.nodeType===Node.TEXT_NODE)return vm(e,t)+n;let r=0;const o=t.childNodes;for(let s=0;s<n&&s<o.length;s+=1)r+=((a=o[s].textContent)==null?void 0:a.length)??0;return vm(e,t)+r}function Sm(e,t){var s,u;const n=document.createTreeWalker(e,NodeFilter.SHOW_TEXT);let r=Math.max(0,t),o,a=null;for(;o=n.nextNode();){a=o;const d=((s=o.textContent)==null?void 0:s.length)??0;if(r<=d)return{node:o,offset:r};r-=d}return a?{node:a,offset:((u=a.textContent)==null?void 0:u.length)??0}:{node:e,offset:e.childNodes.length}}function Zc(e,t,n){const r=document.createRange(),o=Sm(e,t),a=Sm(e,n);return r.setStart(o.node,o.offset),r.setEnd(a.node,a.offset),r}function sp(e,t){try{const n=e.commonAncestorContainer;return t===n||t.contains(n)}catch{return!1}}function Am(e,t){return!!(e&&e.mode==="visual"&&e.visualRange&&(!t.visualRange||!e.collapsed&&t.collapsed))}function jx(e,t){return t.mode!=="visual"?null:t.visualRange&&sp(t.visualRange,e)?t.visualRange:Zc(e,t.start,t.end)}function an(e){var n;if(e.mode==="html"&&e.htmlEl){const r=e.htmlEl.selectionStart,o=e.htmlEl.selectionEnd;return{mode:"html",text:e.htmlEl.value.slice(r,o),collapsed:r===o,start:r,end:o,visualRange:null}}const t=e.visualEl;if(e.mode==="visual"&&t){const r=window.getSelection();if(r&&r.rangeCount>0){const a=r.getRangeAt(0);if(Dx(t,a.commonAncestorContainer)){const s=km(t,a.startContainer,a.startOffset),u=km(t,a.endContainer,a.endOffset);return{mode:"visual",text:a.toString(),collapsed:a.collapsed,start:Math.min(s,u),end:Math.max(s,u),visualRange:a.cloneRange()}}}const o=((n=t.textContent)==null?void 0:n.length)??0;return{mode:"visual",text:"",collapsed:!0,start:o,end:o,visualRange:null}}return{mode:e.mode,text:"",collapsed:!0,start:0,end:0,visualRange:null}}function Pm(e){return e.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}function Ix(e){if(e.snapshot.mode==="html"){const a=e.getHtml(),s=e.snapshot.start,u=e.snapshot.end,d=e.asHtml?e.content:Pm(e.content);e.setHtml(a.slice(0,s)+d+a.slice(u));const f=e.htmlEl;if(f){const g=s+d.length;f.focus(),f.setSelectionRange(g,g)}return}const t=e.visualEl;if(!t){const a=e.asHtml?e.content:Pm(e.content);e.setHtml(e.getHtml()+a);return}const r=(e.snapshot.visualRange&&sp(e.snapshot.visualRange,t)?e.snapshot.visualRange:null)??Zc(t,e.snapshot.start,e.snapshot.end);if(r.deleteContents(),e.content)if(e.asHtml){const a=r.createContextualFragment(e.content),s=a.lastChild;r.insertNode(a),s&&(r.setStartAfter(s),r.collapse(!0))}else{const a=document.createTextNode(e.content);r.insertNode(a),r.setStartAfter(a),r.collapse(!0)}const o=window.getSelection();o==null||o.removeAllRanges(),o==null||o.addRange(r),e.setHtml(t.innerHTML)}const qc=new Set(["p","h1","h2","h3","h4","h5","h6","div","li","blockquote"]),lp=new Set(["table","thead","tbody","tr","td","th"]),Yc=new Set([...lp,"ul","ol","li","pre","hr"]);function Me(e){return e.tagName.toLowerCase()}function ri(e){return e.nodeType===Node.TEXT_NODE?e.parentElement:e instanceof Element?e:e.parentElement}function Xc(e){return e instanceof HTMLElement&&(Me(e)==="ul"||Me(e)==="ol")}function Ot(e){return e instanceof HTMLElement&&Me(e)==="li"}function fn(e){const t=window.getSelection();if(!t||t.rangeCount===0)return null;const n=t.getRangeAt(0);return ke(e,n.commonAncestorContainer)?n:null}function Jc(e){const t=e.collapsed?[]:Pt(e).filter(n=>n.data.length>0);return t.length>0?t:[e.startContainer]}function Jr(e,t,n){var d,f,g;if(t.nodeType===Node.TEXT_NODE){const h=document.createTreeWalker(e,NodeFilter.SHOW_TEXT);let C=0,b;for(;b=h.nextNode();){if(b===t)return C+n;C+=((d=b.textContent)==null?void 0:d.length)??0}return C}let r=0;const o=t.childNodes;for(let h=0;h<n&&h<o.length;h+=1)r+=((f=o[h].textContent)==null?void 0:f.length)??0;const a=document.createTreeWalker(e,NodeFilter.SHOW_TEXT);let s=0,u;for(;u=a.nextNode();){if(t.contains(u)||t.compareDocumentPosition(u)&Node.DOCUMENT_POSITION_FOLLOWING)return s+r;s+=((g=u.textContent)==null?void 0:g.length)??0}return s+r}function Qc(e,t,n){const r=Zc(e,t,n),o=window.getSelection();o==null||o.removeAllRanges(),o==null||o.addRange(r)}function Yn(e,t){const n=fn(e);if(!n)return!1;const r=Jr(e,n.startContainer,n.startOffset),o=Jr(e,n.endContainer,n.endOffset),a=Math.min(r,o),s=Math.max(r,o),u=t();return Qc(e,a,s),u}function eu(e,t){if(Me(e)===t)return e;const n=document.createElement(t);for(const r of[...e.attributes])n.setAttribute(r.name,r.value);for(;e.firstChild;)n.appendChild(e.firstChild);return e.replaceWith(n),n}function kt(e){var t;(t=e.getAttribute("style"))!=null&&t.trim()||e.removeAttribute("style")}function Ex(e,t){let n=ri(t);for(;n&&n!==e;){if(Gp(n,e)||Tt(n)){n=n.parentElement;continue}const r=Me(n);if(qc.has(r)&&n instanceof HTMLElement)return n;if(lp.has(r)||r==="pre")return null;n=n.parentElement}return null}function An(e){const t=fn(e);if(!t)return[];const n=new Set,r=[];for(const o of Jc(t)){const a=Ex(e,o);a&&!n.has(a)&&(n.add(a),r.push(a))}return r}function oc(e){if(e.nodeType===Node.TEXT_NODE||e.nodeType===Node.COMMENT_NODE||!(e instanceof Element))return!0;const t=Me(e);return qc.has(t)||Yc.has(t)?!1:mn(e)||t==="br"||t==="a"||t==="img"||t==="span"}function _x(e,t){let n=ri(t);for(;n&&n!==e;){if(Yc.has(Me(n)))return!0;n=n.parentElement}return!1}function Mx(e,t){let n=t;for(;n&&n.parentNode!==e;)n=n.parentNode;return n&&n.parentNode===e?n:null}function Nx(e,t){const n=[...e.childNodes],r=n.indexOf(t);if(r<0)return[t];let o=r,a=r;for(;o>0&&oc(n[o-1]);)o-=1;for(;a<n.length-1&&oc(n[a+1]);)a+=1;return n.slice(o,a+1)}function ic(e){for(const t of e.childNodes)if(!(t instanceof HTMLElement&&Tt(t)))return t;return null}function Lx(e,t,n){if(n.startContainer===e){const r=e.childNodes[Math.min(n.startOffset,Math.max(0,e.childNodes.length-1))]??e.firstChild;return r instanceof HTMLElement&&Tt(r)?ic(e):r}return n.startContainer===t&&e!==t?ic(e):Mx(e,n.startContainer)}function Bx(e,t){const n=uu(e);if(_x(e,t.startContainer))return null;if(!ic(n)){const s=document.createElement("p");return s.appendChild(document.createElement("br")),n.appendChild(s),s}const r=Lx(n,e,t);if(!r||r instanceof HTMLElement&&Tt(r)||r instanceof Element&&Yc.has(Me(r))||r instanceof HTMLElement&&qc.has(Me(r))||!oc(r))return null;const o=Nx(n,r),a=document.createElement("p");n.insertBefore(a,o[0]);for(const s of o)a.appendChild(s);return a}function xr(e){const t=An(e);if(t.length>0)return t;const n=fn(e);if(!n)return[];const r=Bx(e,n);return r?[r]:[]}function Qr(e){const t=e.parentElement;return t&&Xc(t)?t:null}function cp(e){if(e.length===0)return[];const t=[[e[0]]];for(let n=1;n<e.length;n+=1){const r=e[n-1],o=e[n];r.parentNode===o.parentNode&&Fx(r,o)?t[t.length-1].push(o):t.push([o])}return t}function Fx(e,t){var r;let n=e.nextSibling;for(;n;){if(n===t)return!0;if(n.nodeType===Node.TEXT_NODE&&!((r=n.textContent)!=null&&r.trim())){n=n.nextSibling;continue}return!1}return!1}function Hx(e){return e.nodeType===Node.TEXT_NODE?e.parentElement:e instanceof Element?e:e.parentElement}function El(e){const t=e.trim().match(/^rgba?\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)(?:\s*,\s*(\d*\.?\d+))?\s*\)$/i);if(!t)return null;const n=Number(t[1]),r=Number(t[2]),o=Number(t[3]),a=t[4]===void 0?1:Number(t[4]);return[n,r,o,a].every(s=>Number.isFinite(s))?{r:n,g:r,b:o,a}:null}function _l(e,t,n){const r=o=>Math.max(0,Math.min(255,Math.round(o))).toString(16).padStart(2,"0");return`#${r(e)}${r(t)}${r(n)}`}function Ml(e){const t=e.trim().toLowerCase();return/^#[0-9a-f]{6}$/.test(t)?t:/^#[0-9a-f]{3}$/.test(t)?`#${t[1]}${t[1]}${t[2]}${t[2]}${t[3]}${t[3]}`:null}const zx={black:"#000000",silver:"#c0c0c0",gray:"#808080",grey:"#808080",white:"#ffffff",maroon:"#800000",red:"#ff0000",purple:"#800080",fuchsia:"#ff00ff",magenta:"#ff00ff",green:"#008000",lime:"#00ff00",olive:"#808000",yellow:"#ffff00",navy:"#000080",blue:"#0000ff",teal:"#008080",aqua:"#00ffff",cyan:"#00ffff",orange:"#ffa500"};function Ox(e){const t=e.trim().toLowerCase();return t===""||t==="transparent"||t==="inherit"||t==="initial"||t==="unset"||t==="currentcolor"||t==="currentColor"}function Ve(e){const t=e.trim();if(!t||Ox(t))return null;const n=Ml(t);if(n)return n;const r=El(t);if(r)return r.a===0?null:_l(r.r,r.g,r.b);const o=zx[t.toLowerCase()];if(o)return o;const a=document.createElement("canvas").getContext("2d");if(!a)return null;a.fillStyle="#010203";try{a.fillStyle=t}catch{return null}const s=String(a.fillStyle);if(s==="#010203"){const d=Ml(t);if(d==="#010203")return d;const f=El(t);return f&&_l(f.r,f.g,f.b)==="#010203"?"#010203":t.trim().toLowerCase()==="black"?"#000000":null}if(s.startsWith("#"))return Ml(s);const u=El(s);return!u||u.a===0?null:_l(u.r,u.g,u.b)}function up(e,t){const n=t==="color"?e.style.color:e.style.backgroundColor;return n?Ve(n):null}function Ta(e,t,n){let r=Hx(t);for(;r&&r!==e&&r instanceof HTMLElement;){const o=up(r,n);if(o)return o;r=r.parentElement}return null}function Ra(e,t){return e instanceof HTMLElement?up(e,t)!==null:!1}function tu(e,t){if(t==="color"){e.style.color="",e.style.removeProperty("color");return}e.style.backgroundColor="",e.style.removeProperty("background-color")}function dp(e,t,n){if(t==="color"){e.style.color=n;return}e.style.backgroundColor=n}function Kx(e,t,n){let r=t;for(;r.parentElement&&r.parentElement!==e;){const o=r.parentElement;if(!mn(o)||!Ra(o,n)){r=o;continue}if(Zn(o,r),Ra(o,n)&&(tu(o,n),Gn(o))){Nt(o);continue}r=o}}function mp(e){const t=window.getSelection();if(!t||t.rangeCount===0)return null;const n=t.getRangeAt(0);return ke(e,n.commonAncestorContainer)?n:null}function Da(e,t){const n=mp(e);if(!n)return{value:null,mixed:!1};const r=n.collapsed?[]:Pt(n).filter(d=>d.data.length>0),a=(r.length>0?r:[n.startContainer]).map(d=>Ta(e,d,t)),s=a[0]??null;return a.every(d=>d===s)?{value:s,mixed:!1}:{value:null,mixed:!0}}function Oo(e,t,n){const r=mp(e);if(!r||r.collapsed)return!1;const o=n===null?null:Ve(n);if(n!==null&&o===null)return!1;un(r);const a=Pt(r).filter(s=>s.data.length>0);for(const s of a){const u=Ta(e,s,t);if(o===null){if(u===null)continue;Kx(e,s,t);continue}u!==o&&ti(s,d=>{dp(d,t,o)})}return yr(a),!0}function Tm(e,t,n){if(n.value===null){tu(e,t);return}const r=Ve(n.value);r&&dp(e,t,r)}function $x(e){return!!(e!=null&&e.color||e!=null&&e.backgroundColor)}function Ux(e){const t=e.startContainer,n=e.startOffset;if(t.nodeType!==Node.TEXT_NODE)return;const r=t;if(n<=0||n>=r.length)return;const o=r.splitText(n);e.setStart(o,0),e.collapse(!0)}function Vx(e){var r,o,a;let t=e.startContainer.nodeType===Node.TEXT_NODE&&e.startOffset===0?e.startContainer:e.startContainer.childNodes[e.startOffset]??e.startContainer.lastChild??e.startContainer;if(e.startContainer.nodeType===Node.TEXT_NODE&&e.startOffset>0){const s=document.createTextNode("");return(r=e.startContainer.parentNode)==null||r.insertBefore(s,e.startContainer.nextSibling),s}if(e.startContainer.nodeType===Node.TEXT_NODE&&e.startOffset===0){const s=document.createTextNode("");return(o=e.startContainer.parentNode)==null||o.insertBefore(s,e.startContainer),s}const n=document.createTextNode("");return t&&t!==e.startContainer?(a=t.parentNode)==null||a.insertBefore(n,t):e.startContainer.appendChild(n),n}function fp(e,t,n){let r=t;for(;r.parentElement&&r.parentElement!==e;){const o=r.parentElement;if(!mn(o)||!n.some(a=>Ra(o,a))){r=o;continue}Zn(o,r);for(const a of n)Ra(o,a)&&tu(o,a);if(Gn(o)){Nt(o);continue}r=o.isConnected?o:t}return t}function Wx(e,t,n){Ux(t);const r=Vx(t);return fp(e,r,n)}function Gx(e,t,n){const r=[];return n!=null&&n.color&&n.color.value===null&&Ta(e,t,"color")&&r.push("color"),n!=null&&n.backgroundColor&&n.backgroundColor.value===null&&Ta(e,t,"backgroundColor")&&r.push("backgroundColor"),r}const pp=["auto","avoid"],ac=["auto","avoid","page"];new Set(pp);new Set(ac);function gp(e){return e.trim().toLowerCase()}function Rm(e){return gp(e)==="avoid"?"avoid":"auto"}function ja(e){const t=gp(e);return t==="avoid"?"avoid":t==="page"||t==="always"?"page":"auto"}function hp(e){const t=e.style.breakInside;if(t)return Rm(t);const n=e.style.pageBreakInside;return n?Rm(n):"auto"}function bp(e){const t=e.style.breakAfter;if(t)return ja(t);const n=e.style.pageBreakAfter;return n?ja(n):"auto"}function yp(e){const t=e.style.breakBefore;if(t)return ja(t);const n=e.style.pageBreakBefore;return n?ja(n):"auto"}function Zx(e){e.style.removeProperty("break-inside"),e.style.removeProperty("page-break-inside")}function qx(e){e.style.removeProperty("break-after"),e.style.removeProperty("page-break-after")}function Yx(e){e.style.removeProperty("break-before"),e.style.removeProperty("page-break-before")}function Xx(e){return{breakInside:hp(e),breakAfter:bp(e),breakBefore:yp(e)}}function Jx(e,t){return hp(e)===t?!1:t==="auto"?(Zx(e),!0):(e.style.breakInside="avoid",e.style.pageBreakInside="avoid",!0)}function Qx(e,t){return bp(e)===t?!1:t==="auto"?(qx(e),!0):t==="avoid"?(e.style.breakAfter="avoid",e.style.pageBreakAfter="avoid",!0):(e.style.breakAfter="page",e.style.pageBreakAfter="always",!0)}function eC(e,t){return yp(e)===t?!1:t==="auto"?(Yx(e),!0):t==="avoid"?(e.style.breakBefore="avoid",e.style.pageBreakBefore="avoid",!0):(e.style.breakBefore="page",e.style.pageBreakBefore="always",!0)}function tC(e,t){return e===t}function Dm(e,t){return e===t}const ot=["top","right","bottom","left"],as=["none","solid","dotted","dashed","double","groove","ridge","inset","outset"],Xt={top:null,right:null,bottom:null,left:null},nu={style:"none",width:null,color:null},nC=new Set(as),jm={value:0,unit:"px"};function rC(){return{margin:{...Xt},padding:{...Xt},lineHeight:null,border:{...nu},borderRadius:null,boxShadow:null,backgroundColor:null,opacity:null,breakInside:"auto",breakAfter:"auto",breakBefore:"auto"}}function ru(){const e=rC();return{margin:e.margin,marginMixed:!1,padding:e.padding,paddingMixed:!1,lineHeight:e.lineHeight,lineHeightMixed:!1,border:e.border,borderMixed:!1,borderRadius:e.borderRadius,radiusMixed:!1,boxShadow:e.boxShadow,shadowMixed:!1,backgroundColor:e.backgroundColor,backgroundMixed:!1,opacity:e.opacity,opacityMixed:!1,breakInside:e.breakInside,breakInsideMixed:!1,breakAfter:e.breakAfter,breakAfterMixed:!1,breakBefore:e.breakBefore,breakBeforeMixed:!1}}function vn(e,t){return ot.every(n=>zt(e[n],t[n]))}function xp(e,t){return e===t?!0:!e||!t||e.kind!==t.kind?!1:e.kind==="normal"||t.kind==="normal"?!0:e.kind==="number"&&t.kind==="number"?e.value===t.value:e.kind==="length"&&t.kind==="length"&&e.value===t.value&&e.unit===t.unit}function Cp(e,t){return e.style===t.style&&zt(e.width,t.width)&&e.color===t.color}function wp(e,t){return e===t?!0:!e||!t?!1:zt(e.offsetX,t.offsetX)&&zt(e.offsetY,t.offsetY)&&zt(e.blur,t.blur)&&zt(e.spread,t.spread)&&e.color===t.color&&e.inset===t.inset}function oC(e){return e.kind==="normal"?"normal":e.kind==="number"?de(e.value):Ie({value:e.value,unit:e.unit})}function iC(e){const t=e.trim();if(!t)return null;if(t.endsWith("%")){const r=Number(t.slice(0,-1).trim().replace(",","."));return Number.isFinite(r)?$n(r/100):null}const n=Number(t.replace(",","."));return Number.isFinite(n)?$n(n):null}function $n(e){return rt(Math.min(1,Math.max(0,e)))}function Ia(e){return rt($n(e)*100)}function vp(e){return $n(e/100)}function kp(e){return de($n(e))}function aC(e){const t=e.trim();if(!t)return null;if(t.toLowerCase()==="normal")return{kind:"normal"};if(/^[+]?(?:\d+(?:\.\d+)?|\.\d+)$/.test(t)){const r=Number(t);return!Number.isFinite(r)||r<0?null:{kind:"number",value:rt(r)}}const n=ht(t);return!n||n.value<0?null:{kind:"length",value:n.value,unit:n.unit}}function sC(e,t){const n=[];let r="",o=0;for(const a of e){if(a==="("){o+=1,r+=a;continue}if(a===")"){o=Math.max(0,o-1),r+=a;continue}if(a===t&&o===0){r.trim()&&n.push(r.trim()),r="";continue}r+=a}return r.trim()&&n.push(r.trim()),n}function lC(e){const t=[];let n="",r=0;for(const o of e){if(o==="("){r+=1,n+=o;continue}if(o===")"){r=Math.max(0,r-1),n+=o;continue}if(/\s/.test(o)&&r===0){n&&t.push(n),n="";continue}n+=o}return n&&t.push(n),t}function cC(e){const t=[Ie(e.offsetX),Ie(e.offsetY),Ie(e.blur),Ie(e.spread)];e.color&&t.push(e.color);const n=t.join(" ");return e.inset?`inset ${n}`:n}function uC(e){const t=e.trim();if(!t||t.toLowerCase()==="none")return null;const n=sC(t,",")[0];if(!n)return null;const r=lC(n);let o=!1,a=null;const s=[];for(const u of r){if(u.toLowerCase()==="inset"){o=!0;continue}const d=ht(u);if(d){s.push(d);continue}const f=Ve(u);if(f){a=f;continue}return null}return s.length<2||s.length>4?null:{offsetX:s[0],offsetY:s[1],blur:s[2]??jm,spread:s[3]??jm,color:a,inset:o}}function Ur(e,t){return ht(e.style.getPropertyValue(t))}function dC(e,t,n,r){const o=n&&r?qn(n):n,a=o?Ie(o):"";return e.style.getPropertyValue(t)===a?!1:(a?e.style.setProperty(t,a):e.style.removeProperty(t),!0)}function Im(e,t){return{top:Ur(e,`${t}-top`),right:Ur(e,`${t}-right`),bottom:Ur(e,`${t}-bottom`),left:Ur(e,`${t}-left`)}}function Em(e,t,n,r){let o=!1;for(const a of ot)dC(e,`${t}-${a}`,n[a],r)&&(o=!0);return o}function mC(e){const t=e.trim().toLowerCase();return nC.has(t)?t:"none"}function Sp(e){const t=mC(e.style.borderStyle||e.style.borderTopStyle),n=Ur(e,"border-width")??Ur(e,"border-top-width"),r=e.style.borderColor||e.style.borderTopColor,o=r?Ve(r):null;return{style:t,width:n,color:o}}function fC(e,t){const n=Sp(e),r=t.style==="none"?{style:"none",width:null,color:null}:{style:t.style,width:t.width?qn(t.width):null,color:t.color};return Cp(n,r)?!1:r.style==="none"?(e.style.removeProperty("border"),e.style.removeProperty("border-style"),e.style.removeProperty("border-width"),e.style.removeProperty("border-color"),!0):(e.style.borderStyle=r.style,r.width?e.style.borderWidth=Ie(r.width):e.style.removeProperty("border-width"),r.color?e.style.borderColor=r.color:e.style.removeProperty("border-color"),!0)}function Ap(e){const t=e.style.borderRadius.trim();if(!t)return null;const n=t.split(/\s+/)[0];return ht(n)}function pC(e,t){const n=t?qn(t):null,r=Ap(e);return zt(r,n)?!1:(n?e.style.borderRadius=Ie(n):e.style.removeProperty("border-radius"),!0)}function Pp(e){return uC(e.style.boxShadow)}function gC(e,t){const n=Pp(e),r=t?{...t,blur:qn(t.blur)}:null;return wp(n,r)?!1:(r?e.style.boxShadow=cC(r):e.style.removeProperty("box-shadow"),!0)}function Tp(e){return aC(e.style.lineHeight)}function hC(e,t){const n=Tp(e);return xp(n,t)?!1:(t?e.style.lineHeight=oC(t):e.style.removeProperty("line-height"),!0)}function Rp(e){const t=e.style.backgroundColor;return t?Ve(t):null}function bC(e,t){const n=t?Ve(t):null;return Rp(e)===n?!1:(n?e.style.backgroundColor=n:e.style.removeProperty("background-color"),!0)}function Dp(e){return iC(e.style.opacity)}function yC(e,t){const n=Dp(e),r=t===null?null:$n(t);return n===r?!1:(r===null?e.style.removeProperty("opacity"):e.style.opacity=kp(r),!0)}function ao(e){const t=Xx(e);return{margin:Im(e,"margin"),padding:Im(e,"padding"),lineHeight:Tp(e),border:Sp(e),borderRadius:Ap(e),boxShadow:Pp(e),backgroundColor:Rp(e),opacity:Dp(e),breakInside:t.breakInside,breakAfter:t.breakAfter,breakBefore:t.breakBefore}}function so(e,t){let n=!1;return!t.marginMixed&&Em(e,"margin",t.margin,!1)&&(n=!0),!t.paddingMixed&&Em(e,"padding",t.padding,!0)&&(n=!0),!t.lineHeightMixed&&hC(e,t.lineHeight)&&(n=!0),!t.borderMixed&&fC(e,t.border)&&(n=!0),!t.radiusMixed&&pC(e,t.borderRadius)&&(n=!0),!t.shadowMixed&&gC(e,t.boxShadow)&&(n=!0),!t.backgroundMixed&&bC(e,t.backgroundColor)&&(n=!0),!t.opacityMixed&&yC(e,t.opacity)&&(n=!0),!t.breakInsideMixed&&Jx(e,t.breakInside)&&(n=!0),!t.breakAfterMixed&&Qx(e,t.breakAfter)&&(n=!0),!t.breakBeforeMixed&&eC(e,t.breakBefore)&&(n=!0),n&&kt(e),n}function xC(e){const t=ru(),n=An(e);if(n.length===0)return t;const r=n.map(ao),o=r[0];return{margin:o.margin,marginMixed:r.some(a=>!vn(a.margin,o.margin)),padding:o.padding,paddingMixed:r.some(a=>!vn(a.padding,o.padding)),lineHeight:o.lineHeight,lineHeightMixed:r.some(a=>!xp(a.lineHeight,o.lineHeight)),border:o.border,borderMixed:r.some(a=>!Cp(a.border,o.border)),borderRadius:o.borderRadius,radiusMixed:r.some(a=>!zt(a.borderRadius,o.borderRadius)),boxShadow:o.boxShadow,shadowMixed:r.some(a=>!wp(a.boxShadow,o.boxShadow)),backgroundColor:o.backgroundColor,backgroundMixed:r.some(a=>a.backgroundColor!==o.backgroundColor),opacity:o.opacity,opacityMixed:r.some(a=>a.opacity!==o.opacity),breakInside:o.breakInside,breakInsideMixed:r.some(a=>!tC(a.breakInside,o.breakInside)),breakAfter:o.breakAfter,breakAfterMixed:r.some(a=>!Dm(a.breakAfter,o.breakAfter)),breakBefore:o.breakBefore,breakBeforeMixed:r.some(a=>!Dm(a.breakBefore,o.breakBefore))}}function CC(e,t){return Yn(e,()=>{const n=xr(e);if(n.length===0)return!1;let r=!1;for(const o of n)so(o,t)&&(r=!0);return r})}const Go=96,wC=25.4,ou=Go/wC,jp=ou*10,Ip=72,vC=/^([+-]?(?:\d+(?:\.\d+)?|\.\d+))\s*(in|cm|mm|pt|px|em|rem|%)$/i;function Ep(e){const t=e.trim();if(!t)return null;if(/^[+-]?0(?:\.0+)?$/.test(t))return{value:0,unit:"px"};const n=t.match(vC);if(!n)return null;const r=Number(n[1]);return Number.isFinite(r)?{value:rt(r),unit:n[2].toLowerCase()}:null}function Zo(e,t){switch(t){case"in":return e/Go;case"cm":return e/jp;case"mm":return e/ou;case"pt":return e/Go*Ip;case"px":default:return e}}function qo(e,t){switch(t){case"in":return e*Go;case"cm":return e*jp;case"mm":return e*ou;case"pt":return e/Ip*Go;case"em":case"rem":return e*16;case"px":default:return e}}function Nn(e,t=0){if(!e)return t;const n=typeof e=="string"?Ep(e):e;return!n||!Number.isFinite(n.value)?t:qo(n.value,n.unit)}function Nl(e,t="in"){const n=Zo(e,t);return{value:Math.round(n*1e3)/1e3,unit:t}}function Ho(e){const t=Zo(e,"pt");return{value:Math.round(t*1e3)/1e3,unit:"pt"}}function _p(e,t="in"){const n=Zo(e,t),r=t==="in"?2:t==="cm"?1:0;return`${n.toFixed(r)} ${t}`}function dr(e,t="in",n=!1,r=0){if(n)return e;const o=e-r,s=qo(t==="in"?.125:t==="cm"?.25:t==="mm"?2.5:10,t);if(s<=0)return e;const u=Math.round(o/s)*s;return r+u}function Mp(e,t,n="in"){const r=[];if(e<=0)return r;const o=n==="in",a=o?.125:.1;if(qo(a,n)<=0)return r;const u=-Zo(t,n),d=Zo(e-t,n),f=Math.floor(u/a),g=Math.ceil(d/a);for(let h=f;h<=g;h++){const C=h*a,b=t+qo(C,n);if(b<0||b>e)continue;const x=Math.round(C),y=Math.abs(C-x)<.001,v=o?Math.abs(C-(Math.floor(C)+.5))<.001:!1,k=o?Math.abs(C-(Math.floor(C)+.25))<.001||Math.abs(C-(Math.floor(C)+.75))<.001:!1;let S=4;y?S=10:v?S=7:k&&(S=5);const P={positionPx:Math.round(b),unitValue:C,major:y,height:S};y&&C>=0&&(P.label=String(Math.abs(x))),r.push(P)}return r}function Np(e){const t=ht(e);if(t)return t;const n=Ep(e);return n&&(n.unit==="in"||n.unit==="cm"||n.unit==="mm")?Ho(qo(n.value,n.unit)):null}const Ea="data-page-at-rule";function Ln(){return{sizePreset:"auto",customWidth:null,customHeight:null,orientation:null,margin:{...Xt},marginMixed:!1}}function iu(e){return new DOMParser().parseFromString(`<body>${e}</body>`,"text/html")}function Lp(e){return e.body.innerHTML.replace(/\s*data-page=""/g," data-page")}function Yo(e){var r;const n=iu(e).querySelector(`style[${Ea}]`);return((r=n==null?void 0:n.textContent)==null?void 0:r.trim())??null}function pa(e,t){const n=new RegExp(`margin-${t}\\s*:\\s*([^;]+)`,"i"),r=e.match(n);return r?Np(r[1].trim()):null}function kC(e){const t=e.match(/(?:^|[\s{;])margin\s*:\s*([^;]+)/i);if(!t)return{...Xt};const n=t[1].trim().split(/\s+/).map(u=>Np(u)),[r,o=r,a=r,s=o]=n;return{top:r??null,right:o??null,bottom:a??null,left:s??null}}function SC(e){const t={sizePreset:"auto",customWidth:null,customHeight:null,orientation:null},n=e.match(/(?:^|[\s{;])size\s*:\s*([^;]+)/i);if(!n)return t;const r=n[1].trim().toLowerCase();if(r==="auto")return t;const o=r.includes("landscape"),a=r.includes("portrait"),s=o?"landscape":a?"portrait":null,u=r.replace(/\b(landscape|portrait)\b/g,"").trim(),d=u.split(/\s+/).filter(Boolean);if(d.length===1){if(d[0]==="a4")return{sizePreset:"A4",customWidth:null,customHeight:null,orientation:s};if(d[0]==="letter")return{sizePreset:"letter",customWidth:null,customHeight:null,orientation:s};if(d[0]==="legal")return{sizePreset:"legal",customWidth:null,customHeight:null,orientation:s}}if(d.length>=2){const f=ht(d[0]),g=ht(d[1]);if(f&&g)return{sizePreset:"custom",customWidth:f,customHeight:g,orientation:s}}return!u&&s?{sizePreset:"auto",customWidth:null,customHeight:null,orientation:s}:t}function AC(e){const t=Ln();if(!e)return t;const n=e.match(/@page\s*\{([^}]*)\}/is);if(!n)return t;const r=n[1],o=SC(r),a={top:pa(r,"top"),right:pa(r,"right"),bottom:pa(r,"bottom"),left:pa(r,"left")},u=ot.some(d=>a[d]!==null)?a:kC(r);return{...o,margin:u,marginMixed:!1}}function st(e){return AC(Yo(e))}function sn(e,t){return Yo(e)||!Yo(t)?e:_a(e,st(t))}function PC(e){const t=ot.map(r=>e[r]);if(t.every(r=>r===null))return null;const n=t.map(r=>r?Ie(r):"0");return n[0]===n[1]&&n[1]===n[2]&&n[2]===n[3]?`margin: ${n[0]};`:ot.map(r=>e[r]?`margin-${r}: ${Ie(e[r])};`:null).filter(Boolean).join(" ")}function TC(e){if(e.sizePreset==="auto"&&!e.orientation)return null;const t=[];return e.sizePreset==="A4"?t.push("A4"):e.sizePreset==="letter"?t.push("letter"):e.sizePreset==="legal"?t.push("legal"):e.sizePreset==="custom"&&e.customWidth&&e.customHeight&&t.push(Ie(e.customWidth),Ie(e.customHeight)),e.orientation&&t.push(e.orientation),t.length===0?null:`size: ${t.join(" ")};`}function RC(e){const t=TC(e),n=PC(e.margin);return!t&&!n?null:`@page { ${[t,n].filter(Boolean).join(" ")} }`}function cn(e){const t=iu(e);for(const n of t.querySelectorAll(`style[${Ea}]`))n.remove();return Lp(t)}function DC(e,t){const n=iu(e);let r=n.querySelector(`style[${Ea}]`);return r||(r=n.createElement("style"),r.setAttribute(Ea,""),n.body.insertBefore(r,n.body.firstChild)),r.textContent=t,Lp(n)}function _a(e,t){const n=RC(t);return n?DC(e,n):Bp(e)}function Bp(e){return cn(e)}function Fp(e){const t=e.map(n=>Yo(n)).filter(n=>!!n);return t.length===0?"":t.join(`
140
- `)}const au="data-page-sized",sc={top:"--wysiwyg-page-margin-top",right:"--wysiwyg-page-margin-right",bottom:"--wysiwyg-page-margin-bottom",left:"--wysiwyg-page-margin-left"},jC="0.75rem",lc=["top","right","bottom","left"],Ll={A4:{width:"210mm",height:"297mm"},letter:{width:"8.5in",height:"11in"},legal:{width:"8.5in",height:"14in"}};function lo(e,t=!1){let n=null;return e.sizePreset==="A4"||e.sizePreset==="letter"||e.sizePreset==="legal"?n={...Ll[e.sizePreset]}:e.sizePreset==="custom"&&e.customWidth&&e.customHeight?n={width:Ie(e.customWidth),height:Ie(e.customHeight)}:e.orientation?n=t?{...Ll.letter}:null:n=t?{...Ll.letter}:null,n?e.orientation==="landscape"?{width:n.height,height:n.width}:n:null}function Hp(e){return lo(e,!1)!==null}function IC(e){const t=lo(e);if(!t)return null;const n=document.createElement("div");n.style.position="fixed",n.style.left="-10000px",n.style.top="0",n.style.visibility="hidden",n.style.boxSizing="border-box",n.style.width=t.width,n.style.minHeight=t.height;const r=oi(e);for(const a of ot){const s=r[a];s&&n.style.setProperty(`padding-${a}`,s)}document.body.appendChild(n);const o={width:n.offsetWidth,height:n.offsetHeight};return n.remove(),o}function oi(e){return EC(e.margin)}function EC(e){return{top:e.top?Ie(e.top):null,right:e.right?Ie(e.right):null,bottom:e.bottom?Ie(e.bottom):null,left:e.left?Ie(e.left):null}}const _C=["width","min-height","padding-top","padding-right","padding-bottom","padding-left"];function zp(e){for(const t of lc)e.style.removeProperty(sc[t])}function MC(e){const t=e.querySelector("[data-page-bg]");if(!(t instanceof HTMLElement))return!1;const n=t.style.backgroundImage.trim();if(n&&n!=="none")return!0;const r=t.getAttribute("style")??"";return/background-image\s*:\s*(?!none\b)/i.test(r)}function NC(e,t){if(!MC(e)){zp(e);return}const n=st(t);if(lo(n)){const o=oi(n);for(const a of lc){const s=o[a]??"0px";e.style.setProperty(sc[a],s)}return}for(const o of lc)e.style.setProperty(sc[o],jC)}function LC(e){e.removeAttribute(au);for(const t of _C)e.style.removeProperty(t);zp(e)}function Op(e,t){const n=st(e),r={...n.margin};return t.left!==void 0&&(r.left=Ho(t.left)),t.right!==void 0&&(r.right=Ho(t.right)),t.top!==void 0&&(r.top=Ho(t.top)),t.bottom!==void 0&&(r.bottom=Ho(t.bottom)),_a(e,{...n,margin:r})}function BC(e,t,n){co(e,Op(t,n))}function co(e,t){const n=st(t),r=lo(n);if(!r){LC(e);return}e.setAttribute(au,""),e.style.width=r.width,e.style.minHeight=r.height;const o=oi(n);for(const a of ot){const s=`padding-${a}`,u=o[a];u?e.style.setProperty(s,u):e.style.removeProperty(s)}NC(e,t)}const hr="data-page",eo="data-page-bg",Ma="commspliant-background";function Tt(e){return e instanceof HTMLElement&&(e.id===Ma||e.hasAttribute(eo))}function FC(e){return e.hasAttribute(hr)&&e.parentElement?e.parentElement:e}function su(e){const t=FC(e),n=new Set,r=[],o=a=>{a instanceof HTMLElement&&Tt(a)&&!n.has(a)&&(n.add(a),r.push(a))};o(t.querySelector(`#${Ma}`));for(const a of t.querySelectorAll(`[${eo}]`))o(a);return o(t),r}function lu(e){return su(e)[0]??null}function Ko(e){let t=!1;return e.style.width!=="100%"&&(e.style.width="100%",t=!0),e.style.height!=="100%"&&(e.style.height="100%",t=!0),t}function Kp(e,t){if(!e.hasAttribute(au))return Ko(t);let n=!1;return t.style.width!=="100%"&&(t.style.width="100%",n=!0),t.style.height!=="auto"&&(t.style.height="auto",n=!0),n}const HC=new Set(["p","h1","h2","h3","h4","h5","h6","li","blockquote","pre","div"]);function $p(e){return HC.has(e.tagName.toLowerCase())}function ss(e){const t=e.querySelectorAll("p, h1, h2, h3, h4, h5, h6, li");return t[t.length-1]??null}function Up(e){for(const t of e.childNodes)if(!(t instanceof HTMLElement&&Tt(t))&&t instanceof HTMLElement&&$p(t))return t;return null}function Vp(e){const t=Up(e)??ss(e);if(t)return t;const n=e.ownerDocument.createElement("p");return n.appendChild(e.ownerDocument.createElement("br")),e.appendChild(n),n}function ls(e){let t=!1;for(const n of[...e.childNodes]){if(n instanceof HTMLElement&&Tt(n)||n.nodeType!==Node.TEXT_NODE)continue;if(!(n.textContent??"").trim()){n.remove(),t=!0;continue}(ss(e)??Vp(e)).appendChild(n),t=!0}return t}function cs(e){const t=gt(e);if(!t)return!1;let n=!1;for(const r of[...e.childNodes])r!==t&&r instanceof HTMLElement&&Tt(r)&&(t.insertBefore(r,t.firstChild),n=!0);return n}function Xo(e){const t=gt(e);if(!t)return{changed:!1,absorbedBlocks:[]};let n=cs(e);const r=[];for(const o of[...e.childNodes])if(o!==t&&!(o instanceof HTMLElement&&Tt(o))){if(o.nodeType===Node.TEXT_NODE){if(!(o.textContent??"").trim()){o.remove(),n=!0;continue}let s=ss(t);s||(s=document.createElement("p"),t.appendChild(s)),s.appendChild(o),n=!0;continue}o instanceof HTMLElement&&$p(o)&&r.push(o),t.appendChild(o),n=!0}return ls(t)&&(n=!0),{changed:n,absorbedBlocks:r}}function zC(e){const t=document.createRange(),n=e.firstChild;(n==null?void 0:n.nodeType)===Node.TEXT_NODE?t.setStart(n,0):n?t.setStartBefore(n):t.setStart(e,0),t.collapse(!0);const r=window.getSelection();r&&(r.removeAllRanges(),r.addRange(t))}const OC="p, h1, h2, h3, h4, h5, h6, li, blockquote, pre";function Wp(e,t){if(t<=0)return;const n=gt(e);if(!n)return;const r=n.querySelectorAll(OC);if(r.length===0)return;const o=r[r.length-1],a=window.getSelection();if(!a||a.rangeCount===0)return;const s=a.getRangeAt(0).startContainer;o.contains(s)||zC(o)}function Gp(e,t){return e instanceof HTMLElement&&e!==t&&e.parentElement===t&&e.hasAttribute(hr)}function Zp(e){return[...e.children].filter(t=>t instanceof HTMLElement)}function KC(e){return[...e.childNodes].some(t=>t.nodeType===Node.TEXT_NODE&&(t.textContent??"").trim()!=="")}function gt(e){return Zp(e).find(n=>n.hasAttribute(hr))??null}function $C(e){if(KC(e))return null;const t=Zp(e);if(t.length!==1)return null;const n=t[0];return n.tagName.toLowerCase()!=="div"||Tt(n)?null:n}function cu(e){const t=gt(e);if(t)return Ko(t),t;const n=$C(e);if(n)return n.setAttribute(hr,""),Ko(n),n;const r=document.createElement("div");for(r.setAttribute(hr,"");e.firstChild;)r.appendChild(e.firstChild);return e.appendChild(r),Ko(r),r}function uu(e){return gt(e)??e}function UC(e,t,n){const{startContainer:r}=n;return r===t||t.contains(r)?!1:r===e?!0:e.contains(r)}function VC(e,t){const{startContainer:n}=t;return n===e||n.nodeType===Node.TEXT_NODE&&n.parentElement===e}function WC(e){var o;const t=document.createRange(),n=e.lastChild;(n==null?void 0:n.nodeType)===Node.TEXT_NODE?t.setStart(n,((o=n.textContent)==null?void 0:o.length)??0):n?t.setStartAfter(n):t.setStart(e,0),t.collapse(!0);const r=window.getSelection();r&&(r.removeAllRanges(),r.addRange(t))}function _m(e){ls(e);const t=ss(e)??Up(e)??Vp(e);WC(t)}function to(e){const t=gt(e);if(!t)return;ls(t);const n=window.getSelection();if(!n||n.rangeCount===0)return;const r=n.getRangeAt(0);if(VC(t,r)){_m(t);return}UC(e,t,r)&&_m(t)}const GC=["background-image","background-size","background-position","background-repeat","opacity"];function ZC(e,t,n){const r=(t==null?void 0:t.style.getPropertyValue(n).trim())??"";r?e.style.setProperty(n,r):e.style.removeProperty(n)}function us(e){const t=gt(e);ZC(e,t,"background-color");for(const n of GC)e.style.removeProperty(n)}const Na="<!-- wysiwyg-page-separator -->",Jo="data-page-surface";function Fn(e){const t=e.trim();return t?t.includes(Na)?e.split(Na).map(n=>n.trim()):[e]:[""]}function Mt(e){return e.length===0?"":e.length===1?e[0]??"":e.join(`
141
- ${Na}
142
- `)}function Mn(){return"<p></p>"}function Bn(e){return e.length===0?[Mn()]:e.map(t=>t.trim())}function Bl(e,t){if(e.length===t.length){let a=!1;const s=[],u=[];for(let d=0;d<t.length;d+=1){const f=t[d]??"";e[d]===f?s.push(e[d]):(s.push(f),a=!0,u.push(d))}return a?{pages:s,changed:!0,changedIndices:u}:{pages:e,changed:!1,changedIndices:[]}}const n=[],r=[];for(let a=0;a<t.length;a+=1){const s=t[a]??"";a<e.length&&e[a]===s?n.push(e[a]):(n.push(s),r.push(a))}return r.length>0||e.length!==t.length||!mr(e,n)?{pages:n,changed:!0,changedIndices:r}:{pages:e,changed:!1,changedIndices:[]}}function mr(e,t){if(e.length!==t.length)return!1;for(let n=0;n<e.length;n+=1)if(e[n]!==t[n])return!1;return!0}function cc(e,t,n){if(t<0||t>=e.length)return{pages:[...e],changed:!1};if(e[t]===n)return{pages:e,changed:!1};const r=e.slice();return r[t]=n,{pages:r,changed:!0}}function nt(e,t){const n=e.querySelector(`[${Jo}][data-page-index="${t}"]`);return n||([...e.querySelectorAll(`[${Jo}]`)][t]??null)}function qC(e){const t=e.getAttribute("data-page-index");if(t!==null){const r=Number.parseInt(t,10);if(!Number.isNaN(r))return r}let n=e.parentElement;for(;n;){const o=[...n.querySelectorAll(`[${Jo}]`)].indexOf(e);if(o!==-1)return o;n=n.parentElement}return null}const _t="data-wysiwyg-img-id",uc="data-page-bg",YC=/^data:image\/(?:jpeg|jpg|png|gif|webp|bmp|avif)(?:;charset=[^;,]+)?;base64,/i,dc=/background-image:\s*url\(\s*(["']?)(.+?)\1\s*\)/i;function Mm(e){return new DOMParser().parseFromString(`<body>${e}</body>`,"text/html")}function Nm(e){return e.body.innerHTML}function Fl(e){return YC.test(e.trim())}function Lm(e){return e.includes("<img")||e.includes("IMG")||e.includes(uc)||e.includes(_t)}function XC(e){var r;const t=dc.exec(e);return t&&(((r=t[2])==null?void 0:r.trim())??"")||null}function ga(e,t){const r=`url("${t.replace(/\\/g,"\\\\").replace(/"/g,'\\"')}")`;if(dc.test(e))return e.replace(dc,`background-image: ${r}`);const o=e.trim().replace(/;+$/,"");return o?`${o};background-image: ${r}`:`background-image: ${r}`}function JC(){return typeof crypto<"u"&&typeof crypto.randomUUID=="function"?crypto.randomUUID():`img-${Date.now()}-${Math.random().toString(36).slice(2,10)}`}function QC(){const e=new Map;function t(b,x){const y=e.get(b);if(y){if(y.dataUrl!==x){URL.revokeObjectURL(y.objectUrl);const k=URL.createObjectURL(Bm(x));return e.set(b,{dataUrl:x,objectUrl:k}),k}return y.objectUrl}const v=URL.createObjectURL(Bm(x));return e.set(b,{dataUrl:x,objectUrl:v}),v}function n(b,x){if(!(x!=null&&x.trim())){for(const[v,k]of e)if(k.dataUrl===b)return v}const y=(x==null?void 0:x.trim())||JC();return t(y,b),y}function r(b){var x;return((x=e.get(b))==null?void 0:x.dataUrl)??null}function o(b){var x;return((x=e.get(b))==null?void 0:x.objectUrl)??null}function a(b){return e.has(b)}function s(b){const x=b.trim();if(!x)return null;for(const[y,v]of e)if(v.objectUrl===x)return y;return null}function u(b,x){const y=b.trim();if(!y)return null;if(Fl(y))return y;const v=(x==null?void 0:x.trim())||s(y);return v?r(v):null}function d(b,x){var y,v;for(const k of b.querySelectorAll("img")){const S=(y=k.getAttribute(_t))==null?void 0:y.trim(),P=((v=k.getAttribute("src"))==null?void 0:v.trim())??"";if(x==="hydrate"){const T=u(P,S);if(!T)continue;k.setAttribute("src",T);continue}if(S&&a(S)){const T=o(S);T&&k.setAttribute("src",T);continue}const R=s(P);if(R){k.setAttribute(_t,R);const T=o(R);T&&k.setAttribute("src",T);continue}if(!Fl(P))continue;const D=n(P);k.setAttribute(_t,D);const A=o(D);A&&k.setAttribute("src",A)}}function f(b,x){var y;for(const v of b.querySelectorAll(`[${uc}]`)){if(!(v instanceof HTMLElement))continue;const k=(y=v.getAttribute(_t))==null?void 0:y.trim(),S=v.getAttribute("style")??"",P=XC(S);if(x==="hydrate"){if(!P)continue;const T=u(P,k);if(!T)continue;v.setAttribute("style",ga(S,T));continue}if(!P)continue;if(k&&a(k)){const T=o(k);T&&v.setAttribute("style",ga(S,T));continue}const R=s(P);if(R){v.setAttribute(_t,R);const T=o(R);T&&v.setAttribute("style",ga(S,T));continue}if(!Fl(P))continue;const D=n(P);v.setAttribute(_t,D);const A=o(D);A&&v.setAttribute("style",ga(S,A))}}function g(b){const x=b.trim();if(!x||!Lm(x))return b;const y=Mm(b);return d(y,"externalize"),f(y,"externalize"),Nm(y)}function h(b){const x=b.trim();if(!x||!Lm(x))return b;const y=Mm(b);f(y,"hydrate"),d(y,"hydrate");for(const v of y.querySelectorAll("img"))v.removeAttribute(_t);for(const v of y.querySelectorAll(`[${uc}]`))v.removeAttribute(_t);return Nm(y)}function C(){for(const b of e.values())URL.revokeObjectURL(b.objectUrl);e.clear()}return{register:n,getDataUrl:r,getObjectUrl:o,has:a,externalizeHtml:g,hydrateHtml:h,clear:C}}function Bm(e){const t=e.indexOf(",");if(t<0)return new Blob;const n=e.slice(0,t),r=e.slice(t+1),o=/^data:([^;,]+)/i.exec(n),a=(o==null?void 0:o[1])??"application/octet-stream",s=atob(r),u=new Uint8Array(s.length);for(let d=0;d<s.length;d+=1)u[d]=s.charCodeAt(d);return new Blob([u],{type:a})}const ew=.85,tw=new Set(["image/webp","image/avif","image/gif"]);let Mo=null;function nw(){if(Mo!==null)return Mo;Mo=!1;try{Mo=document.createElement("canvas").toDataURL("image/webp").startsWith("data:image/webp")}catch{}return Mo}function rw(e){const t=e.type.trim().toLowerCase();if(t&&tw.has(t))return!1;const n=aw(e.name);return!(!t&&(n==="webp"||n==="avif"||n==="gif"))}function ow(e,t=ew){return typeof createImageBitmap!="function"?Promise.resolve(null):createImageBitmap(e).then(n=>iw(n,t)).catch(()=>null)}function iw(e,t){const n=document.createElement("canvas");n.width=e.width,n.height=e.height;const r=n.getContext("2d");if(!r)return e.close(),Promise.resolve(null);try{r.drawImage(e,0,0)}finally{e.close()}return new Promise(o=>{n.toBlob(a=>{if(!a){o(null);return}const s=new FileReader;s.onload=()=>{const u=String(s.result??"");o(u.startsWith("data:image/webp")?u:null)},s.onerror=()=>o(null),s.readAsDataURL(a)},"image/webp",t)})}function aw(e){const t=e.lastIndexOf(".");return t<0||t===e.length-1?"":e.slice(t+1).toLowerCase()}const qp=2*1024*1024,sw="image/jpeg,image/png,image/gif,image/webp,image/bmp,image/avif,.jpg,.jpeg,.png,.gif,.webp,.bmp,.avif",lw=new Set(["image/jpeg","image/jpg","image/png","image/gif","image/webp","image/bmp","image/x-ms-bmp","image/avif"]),cw=new Set(["jpg","jpeg","png","gif","webp","bmp","avif"]),Yp=/^data:image\/(?:jpeg|jpg|png|gif|webp|bmp|avif)(?:;charset=[^;,]+)?;base64,/i,uw=/^(javascript|vbscript|file|blob):/i;function dw(e={}){return{src:"",alt:"",title:"",...e}}function dn(e){const t=e.trim();if(!t)return"empty";if(uw.test(t))return"invalid";if(t.toLowerCase().startsWith("data:"))return Yp.test(t)?null:"invalid";if(/^[a-z][a-z0-9+.-]*:/i.test(t)){const n=t.slice(0,t.indexOf(":")).toLowerCase();return n==="http"||n==="https"?null:"invalid"}return null}function mw(e){return e.size>qp?"tooLarge":Cw(e)?null:"type"}function fw(e){const t=mw(e);return t?Promise.reject(new Error(t)):pw(e)}async function pw(e){if(rw(e)&&nw()){const t=await ow(e);if(t&&dn(t)===null&&hw(t)<=qp)return t}return gw(e)}function gw(e){return new Promise((t,n)=>{const r=new FileReader;r.onload=()=>{const o=String(r.result??"");if(dn(o)){n(new Error("invalid"));return}t(o)},r.onerror=()=>n(r.error??new Error("Failed to read file")),r.readAsDataURL(e)})}function hw(e){const t=e.indexOf(",");if(t<0)return e.length;const n=e.slice(t+1),r=n.endsWith("==")?2:n.endsWith("=")?1:0;return Math.floor(n.length*3/4)-r}function bw(e,t,n){const r=Xp(t,n);e.setAttribute("src",r.src.trim()),r.registryId?e.setAttribute(_t,r.registryId):e.removeAttribute(_t);const o=t.alt.trim(),a=t.title.trim();o?e.setAttribute("alt",o):e.removeAttribute("alt"),a?e.setAttribute("title",a):e.removeAttribute("title"),e.style.maxWidth="100%",e.style.height="auto",yw(e,t.css)}function yw(e,t){if(t)for(const n of t.split(";")){const r=n.trim();if(!r)continue;const o=r.indexOf(":");if(o<=0)continue;const a=r.slice(0,o).trim(),s=r.slice(o+1).trim();a&&s&&e.style.setProperty(a,s)}}function Xp(e,t){if(!t)return e;const n=e.src.trim();if(dn(n)||!Yp.test(n))return e;const r=t.register(n),o=t.getObjectUrl(r);return o?{...e,src:o,registryId:r}:e}function xw(e,t,n){const r=dw(t),o=n?Xp(r,n):r;if(o.registryId){const d=n==null?void 0:n.getDataUrl(o.registryId);if(!d||dn(d))return!1}else if(dn(o.src))return!1;const a=window.getSelection();if(!a||a.rangeCount===0)return!1;const s=a.getRangeAt(0);if(!ke(e,s.commonAncestorContainer))return!1;s.collapsed||s.deleteContents();const u=document.createElement("img");return bw(u,o,n),s.insertNode(u),s.setStartAfter(u),s.collapse(!0),a.removeAllRanges(),a.addRange(s),!0}function mc(e,t){let n=t;for(;n&&n!==e;){if(n instanceof HTMLImageElement)return n;n=n.parentNode}return null}function Hl(e,t){if(!ke(e,t)||t===e)return!1;const n=document.createRange();n.selectNode(t);const r=window.getSelection();return r?(r.removeAllRanges(),r.addRange(n),!0):!1}function Cw(e){const t=e.type.trim().toLowerCase();if(t&&lw.has(t))return!0;const n=ww(e.name);return!!(!t&&n&&cw.has(n))}function ww(e){const t=e.lastIndexOf(".");return t<0||t===e.length-1?"":e.slice(t+1).toLowerCase()}const Jp=["%","px","pt","pc","em","rem"],vw="%",kw={"%":[25,50,75,100,125,150,200],px:[50,100,150,200,300,400,600,800],pt:[36,48,72,96,144,192,288],pc:[3,4,6,8,12,16,24],em:[2,4,6,8,12,16,24],rem:[2,4,6,8,12,16,24]},no={"%":{min:1,max:1e3},px:{min:1,max:4e3},pt:{min:1,max:3e3},pc:{min:.1,max:250},em:{min:.1,max:200},rem:{min:.1,max:200}},Sw=new Set(Jp),Aw=/^([+]?(?:\d+(?:\.\d+)?|\.\d+))\s*(pt|px|em|rem|%|pc)$/i;function Pw(e){return Sw.has(e)}function fr(e){return`${de(e.value)}${e.unit}`}function La(e){const t=e.trim();if(!t||t.toLowerCase()==="auto")return null;const n=t.match(Aw);if(!n)return null;const r=Number(n[1]);if(!Number.isFinite(r)||r<=0)return null;const o=n[2]==="%"?"%":n[2].toLowerCase();return Pw(o)?ro(r,o):null}function Fm(e,t){const n=e.trim();if(!n)return null;const r=La(n);if(r)return r;const o=Number(n.replace(",","."));return Number.isFinite(o)?ro(o,t):null}function ro(e,t){if(!Number.isFinite(e)||e<=0)return null;const{min:n,max:r}=no[t];return{value:rt(Math.min(r,Math.max(n,e))),unit:t}}function $o(e,t,n){const r=n>0?n:1;if(e==="width"){const a=ro(t.value/r,t.unit)??t;return{width:t,height:a}}return{width:ro(t.value*r,t.unit)??t,height:t}}const ka="data-hover-css",du=["fill","contain","cover","none","scale-down"],mu=["center","top","bottom","left","right","top left","top right","bottom left","bottom right"],Tw=new Set(du),Rw=new Set(mu),Hm="if(this._hp==null)this._hp=this.getAttribute('style')||'';this.setAttribute('style',(this._hp?this._hp+';':'')+(this.getAttribute('data-hover-css')||''))",Dw="if(this._hp!=null){this.setAttribute('style',this._hp);this._hp=null}",jw=/^-?[a-z][a-z0-9-]*$/i,Iw=/expression\s*\(|javascript:|vbscript:|-moz-binding|\bbehavior\b/i,fc=/rotate\(\s*([+-]?(?:\d+(?:\.\d+)?|\.\d+))\s*deg\s*\)/i;function Qp(e={}){return{sizeMode:"width",width:null,height:null,align:null,margin:{...Xt},border:{...nu},borderRadius:null,boxShadow:null,opacity:null,objectFit:null,objectPosition:null,rotateDeg:null,hoverCss:"",...e}}function Ew(e){const t=e.naturalWidth,n=e.naturalHeight;return t>0&&n>0?t/n:1}function _w(e,t){const n=e.objectFit;if(n!=="cover"&&n!=="contain"&&n!=="fill"||e.width&&e.height||!e.width&&!e.height)return e;if(e.width){const r=$o("width",e.width,t);return{...e,sizeMode:"lock",width:r.width,height:r.height}}if(e.height){const r=$o("height",e.height,t);return{...e,sizeMode:"lock",width:r.width,height:r.height}}return e}function Mw(e){const t=[];for(const n of e.split(";")){const r=n.trim();if(!r)continue;const o=r.indexOf(":");if(o<=0)continue;const a=r.slice(0,o).trim().toLowerCase(),s=r.slice(o+1).trim();!a||!s||jw.test(a)&&(a==="behavior"||a.endsWith("binding")||Iw.test(s)||t.push(`${a}: ${s}`))}return t.join("; ")}function Hn(e){const t=window.getSelection();if(!t||t.rangeCount===0)return null;const n=t.getRangeAt(0);if(!ke(e,n.commonAncestorContainer))return null;if(n.startContainer instanceof HTMLImageElement)return n.startContainer;if(n.startContainer.nodeType===Node.ELEMENT_NODE){const r=n.startContainer.childNodes[n.startOffset];if(r instanceof HTMLImageElement&&ke(e,r))return r}return mc(e,n.commonAncestorContainer)}function Nw(e){const t=Hn(e);return t?eg(t):null}function eg(e){const t=ao(e),n=zw(e),r=n==="center"?{...t.margin,left:null,right:null}:t.margin,o=Bw(e);return Qp({sizeMode:o.sizeMode,width:o.width,height:o.height,align:n,margin:r,border:t.border,borderRadius:t.borderRadius,boxShadow:t.boxShadow,opacity:t.opacity,objectFit:ng(e),objectPosition:Uw(e),rotateDeg:rg(e),hoverCss:e.getAttribute(ka)??""})}function tg(e,t){let n=!1;return Fw(e,t)&&(n=!0),so(e,{margin:t.align==="center"?{...t.margin,left:null,right:null}:t.margin,marginMixed:!1,padding:Xt,paddingMixed:!0,lineHeight:null,lineHeightMixed:!0,border:t.border,borderMixed:!1,borderRadius:t.borderRadius,radiusMixed:!1,boxShadow:t.boxShadow,shadowMixed:!1,backgroundColor:null,backgroundMixed:!0,opacity:t.opacity,opacityMixed:!1})&&(n=!0),Ow(e,t.align)&&(n=!0),Kw(e,t.objectFit)&&(n=!0),$w(e,t.objectPosition)&&(n=!0),Ww(e,t.rotateDeg)&&(n=!0),Gw(e,t.hoverCss)&&(n=!0),n}function Lw(e,t){const n=Hn(e);return n?tg(n,t):!1}function Bw(e){const t=La(e.style.width),n=La(e.style.height);return t&&n?{sizeMode:"lock",width:t,height:n}:n&&!t?{sizeMode:"height",width:null,height:n}:{sizeMode:"width",width:t,height:null}}function Fw(e,t){const n={width:e.style.width,height:e.style.height,maxWidth:e.style.maxWidth},r=Hw(t);return r.width?e.style.width=fr(r.width):e.style.removeProperty("width"),r.height?e.style.height=fr(r.height):e.style.height="auto",r.width||r.height?e.style.removeProperty("max-width"):e.style.maxWidth="100%",n.width!==e.style.width||n.height!==e.style.height||n.maxWidth!==e.style.maxWidth}function Hw(e){return e.sizeMode==="width"?{sizeMode:"width",width:e.width,height:null}:e.sizeMode==="height"?{sizeMode:"height",width:null,height:e.height}:{sizeMode:"lock",width:e.width,height:e.height}}function zw(e){const t=e.style.float.trim().toLowerCase();if(t==="left")return"left";if(t==="right")return"right";const n=e.style.display.trim().toLowerCase(),r=e.style.marginLeft.trim().toLowerCase(),o=e.style.marginRight.trim().toLowerCase();return n==="block"&&r==="auto"&&o==="auto"?"center":null}function Ow(e,t){const n={float:e.style.float,display:e.style.display,marginLeft:e.style.marginLeft,marginRight:e.style.marginRight};return t==="left"?(e.style.float="left",e.style.removeProperty("display"),e.style.marginLeft.trim().toLowerCase()==="auto"&&e.style.removeProperty("margin-left"),e.style.marginRight.trim().toLowerCase()==="auto"&&e.style.removeProperty("margin-right")):t==="right"?(e.style.float="right",e.style.removeProperty("display"),e.style.marginLeft.trim().toLowerCase()==="auto"&&e.style.removeProperty("margin-left"),e.style.marginRight.trim().toLowerCase()==="auto"&&e.style.removeProperty("margin-right")):t==="center"?(e.style.removeProperty("float"),e.style.display="block",e.style.marginLeft="auto",e.style.marginRight="auto"):(e.style.removeProperty("float"),e.style.display.trim().toLowerCase()==="block"&&e.style.removeProperty("display"),e.style.marginLeft.trim().toLowerCase()==="auto"&&e.style.removeProperty("margin-left"),e.style.marginRight.trim().toLowerCase()==="auto"&&e.style.removeProperty("margin-right")),n.float!==e.style.float||n.display!==e.style.display||n.marginLeft!==e.style.marginLeft||n.marginRight!==e.style.marginRight}function ng(e){const t=e.style.objectFit.trim().toLowerCase();return Tw.has(t)?t:null}function Kw(e,t){return ng(e)===t?!1:(t?e.style.objectFit=t:e.style.removeProperty("object-fit"),!0)}function $w(e,t){const n=(t==null?void 0:t.trim().toLowerCase().replace(/\s+/g," "))||"";return e.style.objectPosition.trim().toLowerCase().replace(/\s+/g," ")===n?!1:(n?e.style.objectPosition=n:e.style.removeProperty("object-position"),!0)}function Uw(e){const t=e.style.objectPosition.trim().toLowerCase().replace(/\s+/g," ");return t?(Rw.has(t),t):null}function rg(e){const t=fc.exec(e.style.transform);if(!t)return null;const n=Number(t[1]);return Number.isFinite(n)?rt(n):null}function Vw(e){const t=e.trim();return t?fc.test(t)&&t.replace(fc,"").trim()==="":!0}function Ww(e,t){const n=rg(e),r=t===null||t===0?null:rt(t);return n===r?!1:r===null?Vw(e.style.transform)?(e.style.removeProperty("transform"),!0):!1:(e.style.transform=`rotate(${de(r)}deg)`,!0)}function Gw(e,t){const n=Mw(t),r=e.getAttribute(ka)??"",o=e.getAttribute("onmouseover")??"";return r===n&&(n&&o===Hm||!n&&!o)?!1:n?(e.setAttribute(ka,n),e.setAttribute("onmouseover",Hm),e.setAttribute("onmouseout",Dw),!0):(e.removeAttribute(ka),e.removeAttribute("onmouseover"),e.removeAttribute("onmouseout"),!0)}const qr={value:100,unit:"%"},Zw=new Set(du),qw=new Set(mu),Yw=new Set(["cover","contain","scale-down","none"]),zm={contain:"contain",cover:"cover",auto:"none"},Om={fill:"100% 100%",contain:"contain",cover:"cover",none:"auto","scale-down":"contain"};function kn(){return{src:null,opacity:null,fit:null,position:null,width:{...qr},height:null}}function og(e){return e!=null&&Yw.has(e)}function ig(e){const t=e.style.opacity.trim();if(!t)return null;const n=Number(t);return Number.isFinite(n)?$n(n):null}function Km(e,t){const n=ig(e),r=t===null?null:$n(t);return n===r?!1:(r===null?e.style.removeProperty("opacity"):e.style.opacity=kp(r),!0)}function ag(e){const t=e.style.backgroundImage.trim();if(!t||t==="none")return null;const n=/^url\(\s*["']?(.+?)["']?\s*\)$/i.exec(t);return n&&n[1].trim()||null}function Xw(e){return`url("${e.replace(/\\/g,"\\\\").replace(/"/g,'\\"')}")`}function $m(e,t){const n=ag(e),r=(t==null?void 0:t.trim())??"",o=r&&dn(r)===null?r:null;return n===o?!1:(o?e.style.backgroundImage=Xw(o):e.style.removeProperty("background-image"),!0)}function fu(e){return e.trim().toLowerCase().replace(/\s+/g," ")}function zl(e){return!e||e==="auto"?null:La(e)}function Jw(e){return og(e.fit)&&e.fit?Om[e.fit]:e.fit==="fill"?Om.fill:e.width&&e.height?`${fr(e.width)} ${fr(e.height)}`:e.width?fr(e.width):e.height?`auto ${fr(e.height)}`:null}function Qw(e){const t=fu(e.style.backgroundSize);if(!t)return{fit:null,width:null,height:null};if(t==="100% 100%")return{fit:"fill",width:{...qr},height:{...qr}};if(zm[t])return{fit:zm[t],width:null,height:null};if(Zw.has(t))return{fit:t,width:null,height:null};const n=t.split(" ");return n.length===1?{fit:null,width:zl(n[0]),height:null}:n.length===2?{fit:null,width:zl(n[0]),height:zl(n[1])}:{fit:null,width:null,height:null}}function e1(e,t){const n=fu(e.style.backgroundSize),r=Jw(t);return n===(r??"")?!1:(r?e.style.backgroundSize=r:e.style.removeProperty("background-size"),!0)}function t1(e){const t=e.style.backgroundPosition.trim().toLowerCase().replace(/\s+/g," ");return t?(qw.has(t),t):null}function Um(e,t){const n=(t==null?void 0:t.trim().toLowerCase().replace(/\s+/g," "))||"";return e.style.backgroundPosition.trim().toLowerCase().replace(/\s+/g," ")===n?!1:(n?e.style.backgroundPosition=n:e.style.removeProperty("background-position"),!0)}function Ba(e){let t=!1;return e.id!==Ma&&(e.id=Ma,t=!0),e.hasAttribute(eo)||(e.setAttribute(eo,""),t=!0),e.getAttribute("contenteditable")!=="false"&&(e.setAttribute("contenteditable","false"),t=!0),t}function Fa(e){const t=e.getAttribute("style");e.style.position="absolute",e.style.inset="0",e.style.zIndex="0",e.style.pointerEvents="none",e.style.userSelect="none",e.style.backgroundRepeat="no-repeat",e.style.setProperty("print-color-adjust","exact");const n=e.style.cssText;return n.includes("-webkit-print-color-adjust")||e.setAttribute("style",`${n};-webkit-print-color-adjust:exact`),e.getAttribute("style")!==t}function sg(e){const t=su(e),n=t[0]??null;if(n){let o=Ba(n);for(const a of t.slice(1))a.remove(),o=!0;return(n.parentNode!==e||n!==e.firstChild)&&(e.insertBefore(n,e.firstChild),o=!0),{layer:n,changed:o}}const r=document.createElement("div");return Ba(r),Fa(r),e.insertBefore(r,e.firstChild),{layer:r,changed:!0}}function n1(e){const t=su(e);if(t.length===0)return!1;for(const n of t)n.remove();return!0}function Ha(e){let t=!1;return lu(e)?(e.style.position!=="relative"&&(e.style.position="relative",t=!0),e.style.isolation!=="isolate"&&(e.style.isolation="isolate",t=!0)):(e.style.position==="relative"&&(e.style.removeProperty("position"),t=!0),e.style.isolation==="isolate"&&(e.style.removeProperty("isolation"),t=!0)),t}function pu(e){if(!lu(e))return Ha(e);const n=sg(e);let r=n.changed;return Ba(n.layer)&&(r=!0),Fa(n.layer)&&(r=!0),Ha(e)&&(r=!0),r}function ds(e){const t=gt(e);if(!t)return!1;let n=cs(e);return pu(t)&&(n=!0),n}function r1(e){return e.includes(eo)||e.includes(hr)}function o1(e){const t=new DOMParser().parseFromString(`<body>${e}</body>`,"text/html");cs(t.body);const n=gt(t.body);return n&&(pu(n),ls(n)),t.body.innerHTML}function Vm(e){return r1(e)?o1(e):e}function lg(e){const t=Qw(e);return{src:ag(e),opacity:ig(e),fit:t.fit,position:t1(e),width:t.width,height:t.height}}function cg(e,t){var a;const n=((a=t.src)==null?void 0:a.trim())??"",r=n.length>0&&dn(n)===null;let o=!1;return r?($m(e,n)&&(o=!0),e1(e,t)&&(o=!0),Um(e,t.position)&&(o=!0),Km(e,t.opacity)&&(o=!0),e.style.backgroundRepeat!=="no-repeat"&&(e.style.backgroundRepeat="no-repeat",o=!0),o&&kt(e),o):($m(e,null)&&(o=!0),fu(e.style.backgroundSize)&&(e.style.removeProperty("background-size"),o=!0),Um(e,null)&&(o=!0),Km(e,null)&&(o=!0),e.style.backgroundRepeat&&(e.style.removeProperty("background-repeat"),o=!0),o&&kt(e),o)}function i1(e){const t=lu(e);return t?lg(t):kn()}function a1(e,t){var u;const n=((u=t.src)==null?void 0:u.trim())??"";if(!(n.length>0&&dn(n)===null)){const d=n1(e),f=Ha(e);return(d||f)&&kt(e),d||f}const o=sg(e),a=o.layer;let s=o.changed;return Ba(a)&&(s=!0),Fa(a)&&(s=!0),Ha(e)&&(s=!0),cg(a,t)&&(s=!0),Fa(a)&&(s=!0),s&&(kt(a),kt(e)),s}function s1(e){return new DOMParser().parseFromString(`<body>${e}</body>`,"text/html")}function l1(e){const t=e.style.backgroundImage.trim();if(t&&t!=="none")return!0;const n=e.getAttribute("style")??"";return/background-image\s*:\s*(?!none\b)/i.test(n)}function Wm(e){const t=e.trim().match(/^([\d.]+)pt$/i);return t?Number.parseFloat(t[1]):null}function c1(e,t){if(!t)return e;if(!e)return t;const n=Wm(e),r=Wm(t);return n!==null&&r!==null?`${Math.max(n,r)}pt`:t}function u1(e,t){const n=st(t),r=oi(n);e.style.boxSizing="border-box",e.style.position!=="relative"&&(e.style.position="relative"),e.style.isolation!=="isolate"&&(e.style.isolation="isolate");const o=lo(n);o?(e.style.width=o.width,e.style.minHeight=o.height):(e.style.width||(e.style.width="100%"),e.style.minHeight="100vh"),e.style.height="auto";for(const a of ot){const s=`padding-${a}`,u=r[a],d=e.style.getPropertyValue(s).trim()||null,f=c1(d,u);f&&e.style.setProperty(s,f)}}function gu(e){const t=s1(e);let n=!1;cs(t.body);for(const r of t.querySelectorAll(`[${hr}]`)){if(!(r instanceof HTMLElement))continue;const o=r.querySelector(`[${eo}]`);!(o instanceof HTMLElement)||!l1(o)||(n=!0,u1(r,e),pu(r))}return{html:t.body.innerHTML,hasBleed:n}}const Gm=`
139
+ Abrir Ayuda: F1`,helpTopicKeyboardShortcutsKeywords:"atajos teclado"},Vy={en:Vc,es:Uy},Qf=l.createContext(e=>Vc[e]);function Wy({locale:e="en",children:t}){const n=l.useMemo(()=>{const r=Vy[e]??Vc;return o=>r[o]},[e]);return i.jsx(Qf.Provider,{value:n,children:t})}function Y(){return l.useContext(Qf)}const Gy="_menu_c1m45_1",Zy="_item_c1m45_19",qy="_separator_c1m45_59",Nl={menu:Gy,item:Zy,separator:qy},ha=8,Yy=[{type:"item",command:"deleteSelection",labelKey:"commandDelete",ariaKey:"commandDeleteAria",enabled:e=>e==="text"||e==="image"},{type:"item",command:"cut",labelKey:"commandCut",ariaKey:"commandCutAria",enabled:e=>e==="text"||e==="image"},{type:"item",command:"copy",labelKey:"commandCopy",ariaKey:"commandCopyAria",enabled:e=>e==="text"||e==="image"},{type:"separator"},{type:"item",command:"openLinkDialog",labelKey:"commandLink",ariaKey:"commandLinkAria",enabled:e=>e!=="image"},{type:"item",command:"addComment",labelKey:"commandInsertComment",ariaKey:"commandInsertCommentAria",enabled:(e,t)=>t.canAddComment&&(e==="text"||e==="image")},{type:"separator"},{type:"item",command:"openFontProperties",labelKey:"commandFontProperties",ariaKey:"commandFontPropertiesAria",enabled:e=>e!=="image"},{type:"item",command:"openParagraphProperties",labelKey:"commandParagraphProperties",ariaKey:"commandParagraphPropertiesAria",enabled:e=>e!=="image"},{type:"item",command:"openPageProperties",labelKey:"commandPageProperties",ariaKey:"commandPagePropertiesAria",enabled:e=>e!=="image"},{type:"item",command:"deletePage",labelKey:"commandDeletePage",ariaKey:"commandDeletePageAria",enabled:(e,t)=>t.canDeletePage},{type:"item",command:"openImageProperties",labelKey:"commandImageProperties",ariaKey:"commandImagePropertiesAria",enabled:e=>e==="image"},{type:"item",command:"openTableProperties",labelKey:"commandTableProperties",ariaKey:"commandTablePropertiesAria",enabled:(e,t)=>t.inTable},{type:"item",command:"openCellProperties",labelKey:"commandCellProperties",ariaKey:"commandCellPropertiesAria",enabled:(e,t)=>t.inTable},{type:"item",command:"openRowProperties",labelKey:"commandRowProperties",ariaKey:"commandRowPropertiesAria",enabled:(e,t)=>t.inTable},{type:"item",command:"mergeCells",labelKey:"commandMergeCells",ariaKey:"commandMergeCellsAria",enabled:(e,t)=>t.canMergeCells},{type:"item",command:"unmergeCells",labelKey:"commandUnmergeCells",ariaKey:"commandUnmergeCellsAria",enabled:(e,t)=>t.canUnmergeCells}];function Xy(e,t){const n=[];let r=!1;for(const o of Yy){if(o.type==="separator"){n.length>0&&(r=!0);continue}o.enabled(e,t)&&(r&&(n.push({type:"separator"}),r=!1),n.push(o))}return n}function wm(){return'[role="menuitem"]:not(:disabled)'}function Jy({open:e,x:t,y:n,kind:r,inTable:o=!1,canMergeCells:a=!1,canUnmergeCells:s=!1,canDeletePage:u=!1,canAddComment:d=!1,commands:f,onClose:g}){const h=Y(),y=l.useId(),b=l.useRef(null);if(l.useLayoutEffect(()=>{var T;if(!e)return;const v=b.current;if(!v)return;const k=v.getBoundingClientRect(),S=Math.max(ha,Math.min(t,window.innerWidth-k.width-ha)),P=Math.max(ha,Math.min(n,window.innerHeight-k.height-ha));v.style.left=`${S}px`,v.style.top=`${P}px`,(T=v.querySelector(wm()))==null||T.focus()},[e,t,n,r]),l.useEffect(()=>{if(!e)return;const v=T=>{var D;(D=b.current)!=null&&D.contains(T.target)||g()},k=T=>{T.key==="Escape"&&(T.preventDefault(),T.stopPropagation(),g())},S=()=>{g()},P=T=>{var D;if((D=b.current)!=null&&D.contains(T.target)){T.preventDefault();return}T.defaultPrevented||g()};return document.addEventListener("pointerdown",v),document.addEventListener("keydown",k,!0),window.addEventListener("scroll",S,!0),document.addEventListener("contextmenu",P),()=>{document.removeEventListener("pointerdown",v),document.removeEventListener("keydown",k,!0),window.removeEventListener("scroll",S,!0),document.removeEventListener("contextmenu",P)}},[e,g]),!e)return null;const C=Xy(r,{inTable:o,canMergeCells:a,canUnmergeCells:s,canDeletePage:u,canAddComment:d}),x=v=>{var D;if(v.key!=="ArrowDown"&&v.key!=="ArrowUp")return;const k=[...((D=b.current)==null?void 0:D.querySelectorAll(wm()))??[]];if(k.length===0)return;const S=k.indexOf(document.activeElement),P=v.key==="ArrowDown"?1:-1,T=k[(S+P+k.length)%k.length];v.preventDefault(),T==null||T.focus()};return i.jsx(we,{children:i.jsxs("div",{ref:b,className:Nl.menu,role:"menu","aria-labelledby":y,style:{left:t,top:n},onMouseDown:v=>v.preventDefault(),onKeyDown:x,children:[i.jsx("span",{id:y,hidden:!0,children:h("contextMenuAria")}),C.map((v,k)=>v.type==="separator"?i.jsx("div",{role:"separator",className:Nl.separator},`separator-${k}`):i.jsx("button",{type:"button",role:"menuitem",className:Nl.item,"aria-label":h(v.ariaKey),onClick:()=>{g(),Uc(f,v.command)},children:h(v.labelKey)},v.command))]})})}function Qy(e){return e==="touch"||e==="pen"}function ex(e,t){return e.button===2||e.ctrlKey?!0:!Qy(t)}const tx=new Set(["span","strong","b","em","i","u","s","strike","del"]);function ke(e,t){return t?e===t||e.contains(t):!1}function mn(e){return tx.has(e.tagName.toLowerCase())}function nx(e,t){const n=document.createRange();return n.selectNodeContents(t),e.compareBoundaryPoints(Range.END_TO_START,n)<0&&e.compareBoundaryPoints(Range.START_TO_END,n)>0}function At(e){const t=e.commonAncestorContainer;if(t.nodeType===Node.TEXT_NODE)return t.nodeValue?[t]:[];const n=[],r=document.createTreeWalker(t,NodeFilter.SHOW_TEXT);let o;for(;o=r.nextNode();)o.nodeValue&&nx(e,o)&&n.push(o);return n}function un(e){const t=e.startContainer,n=e.startOffset;if(t.nodeType===Node.TEXT_NODE){const a=t;if(n>0&&n<a.length){const s=a.splitText(n);e.setStart(s,0),e.endContainer===a&&e.setEnd(s,e.endOffset-n)}}const r=e.endContainer,o=e.endOffset;if(r.nodeType===Node.TEXT_NODE){const a=r;o>0&&o<a.length&&(a.splitText(o),e.setEnd(a,a.length))}}function Yn(e){return e.tagName.toLowerCase()!=="span"||e.style.cssText.trim()?!1:(e.removeAttribute("style"),e.attributes.length===0)}function Mt(e){const t=e.parentNode;if(t){for(;e.firstChild;)t.insertBefore(e.firstChild,e);t.removeChild(e)}}function Xn(e,t){const n=[...e.childNodes],r=n.indexOf(t);if(r<=-1||n.length===1)return;const o=e.parentNode;if(!o)return;const a=n.slice(0,r),s=n.slice(r+1);if(a.length>0){const u=e.cloneNode(!1);for(const d of a)u.appendChild(d);o.insertBefore(u,e)}if(s.length>0){const u=e.cloneNode(!1);for(const d of s)u.appendChild(d);o.insertBefore(u,e.nextSibling)}}function xr(e){if(e.length===0)return;const t=e[0],n=e[e.length-1],r=document.createRange();r.setStart(t,0),r.setEnd(n,n.data.length);const o=window.getSelection();o==null||o.removeAllRanges(),o==null||o.addRange(r)}function ai(e,t){const n=e.parentElement;if(n&&n.tagName.toLowerCase()==="span"&&n.childNodes.length===1)return t(n),n;const r=document.createElement("span");return t(r),n==null||n.insertBefore(r,e),r.appendChild(e),r}const ls="data-wysiwyg-font",rx=[{name:"Arial",family:"Arial, Helvetica, sans-serif"},{name:"Arial Black",family:"'Arial Black', Gadget, sans-serif"},{name:"Comic Sans MS",family:"'Comic Sans MS', Textile, cursive"},{name:"Courier New",family:"'Courier New', Courier, monospace"},{name:"Georgia",family:"Georgia, serif"},{name:"Helvetica",family:"Helvetica, Arial, sans-serif"},{name:"Impact",family:"Impact, Charcoal, sans-serif"},{name:"Lucida Console",family:"'Lucida Console', Monaco, monospace"},{name:"Lucida Sans Unicode",family:"'Lucida Sans Unicode', 'Lucida Grande', sans-serif"},{name:"Palatino Linotype",family:"'Palatino Linotype', Palatino, serif"},{name:"Tahoma",family:"Tahoma, Geneva, sans-serif"},{name:"Times New Roman",family:"'Times New Roman', Times, serif"},{name:"Trebuchet MS",family:"'Trebuchet MS', Helvetica, sans-serif"},{name:"Verdana",family:"Verdana, Geneva, sans-serif"}];function hr(e){return e.split(",").map(t=>t.trim().replace(/^["']|["']$/g,"").toLowerCase()).filter(Boolean).join(",")}function si(e,t){return e===t?!0:!e||!t?!1:hr(e)===hr(t)}function ep(e=[]){var r;const t=[],n=new Set;for(const o of[...rx,...e]){const a=o.family.trim();if(!a)continue;const s=hr(a);if(n.has(s))continue;n.add(s);const u=(r=o.css)==null?void 0:r.trim();t.push({name:o.name.trim()||a,family:a,...u?{css:u}:{}})}return t}function ox(e,t){return e?t.find(n=>si(n.family,e))??null:null}function ix(e){try{const t=new URL(e);return t.protocol==="http:"||t.protocol==="https:"}catch{return!1}}function ax(e){return e.replace(/&/g,"&amp;").replace(/"/g,"&quot;").replace(/</g,"&lt;")}function cs(e){const t=new Set,n=[];for(const r of e){const o=r.trim();!o||!ix(o)||t.has(o)||(t.add(o),n.push(o))}return n}function sx(e){return e.replace(/&quot;/g,'"').replace(/&lt;/g,"<").replace(/&amp;/g,"&")}const lx=new RegExp(`<link\\b[^>]*\\b${ls}\\b[^>]*>`,"gi");function ge(e){if(!e.includes(ls))return{hrefs:[],body:e};const t=[],n=e.replace(lx,r=>{var a,s;const o=((a=r.match(/\bhref\s*=\s*"([^"]*)"/i))==null?void 0:a[1])??((s=r.match(/\bhref\s*=\s*'([^']*)'/i))==null?void 0:s[1]);return o&&t.push(sx(o)),""});return{hrefs:cs(t),body:n}}function ba(e,t){const n=cs(t);return n.length===0?e:`${n.map(o=>`<link rel="stylesheet" href="${ax(o)}" ${ls}="">`).join("")}${e}`}function Wc(e){return e.style.fontFamily.trim()||null}const cx=32,Oo=new Map;function tp(e,t){return`${hr(t)}\0${e}`}function ux(e,t){return Oo.get(tp(e,t))}function Ll(e,t,n){const r=tp(e,t);if(Oo.size>=cx){const o=Oo.keys().next().value;o!==void 0&&Oo.delete(o)}Oo.set(r,n)}function np(e,t){const n=e.ownerDocument.createTreeWalker(e,NodeFilter.SHOW_ELEMENT);let r=n.currentNode;for(;r;){if(r instanceof HTMLElement){const o=Wc(r);if(o&&hr(o)===t)return!0}r=n.nextNode()}return!1}function dx(e,t){const n=hr(t);return n?np(e,n):!1}function mx(e,t){const n=hr(t);if(!n)return!1;const r=ux(e,t);if(r!==void 0)return r;const o=e.toLowerCase();if(!o.includes("font-family")&&!o.includes("face="))return Ll(e,t,!1),!1;const a=n.split(",")[0].replace(/['"]/g,"").trim().toLowerCase();if(a&&!o.includes(a))return Ll(e,t,!1),!1;const s=new DOMParser().parseFromString(e,"text/html"),u=np(s.body,n);return Ll(e,t,u),u}function ya(e,t,n=[],r){const o=ge(t).hrefs,a=n.filter(s=>s.css?r!=null&&r.liveRoot?dx(r.liveRoot,s.family):mx(e,s.family):!1).map(s=>s.css??"");return cs([...o,...a])}function vm(e,t=[]){const n=ge(e).hrefs,r=t.map(o=>o.css??"");return cs([...n,...r])}function fx(e){return e.nodeType===Node.TEXT_NODE?e.parentElement:e instanceof Element?e:e.parentElement}function Gc(e,t){let n=fx(t);for(;n&&n!==e&&n instanceof HTMLElement;){const r=Wc(n);if(r)return r;n=n.parentElement}return null}function ac(e){return e instanceof HTMLElement&&Wc(e)!==null}function Zc(e){e.style.fontFamily="",e.style.removeProperty("font-family")}function px(e,t){let n=t;for(;n.parentElement&&n.parentElement!==e;){const r=n.parentElement;if(!mn(r)||!ac(r)){n=r;continue}if(Xn(r,n),ac(r)&&(Zc(r),Yn(r))){Mt(r);continue}n=r}}function rp(e){const t=window.getSelection();if(!t||t.rangeCount===0)return null;const n=t.getRangeAt(0);return ke(e,n.commonAncestorContainer)?n:null}function op(e){const t=rp(e);if(!t)return{value:null,mixed:!1};const n=t.collapsed?[]:At(t).filter(u=>u.data.length>0),o=(n.length>0?n:[t.startContainer]).map(u=>Gc(e,u)),a=o[0]??null;return o.every(u=>si(u,a))?{value:a,mixed:!1}:{value:null,mixed:!0}}function sc(e,t){const n=rp(e);if(!n||n.collapsed)return!1;const r=t!=null&&t.trim()?t.trim():null;un(n);const o=At(n).filter(a=>a.data.length>0);for(const a of o){const s=Gc(e,a);if(r===null){if(s===null)continue;px(e,a);continue}si(s,r)||ai(a,u=>{u.style.fontFamily=r})}return xr(o),!0}function gx(e,t){if(t){if(t.value===null){Zc(e);return}e.style.fontFamily=t.value}}function hx(e){return e!=null}function bx(e){const t=e.startContainer,n=e.startOffset;if(t.nodeType!==Node.TEXT_NODE)return;const r=t;if(n<=0||n>=r.length)return;const o=r.splitText(n);e.setStart(o,0),e.collapse(!0)}function yx(e){var r,o,a;let t=e.startContainer.nodeType===Node.TEXT_NODE&&e.startOffset===0?e.startContainer:e.startContainer.childNodes[e.startOffset]??e.startContainer.lastChild??e.startContainer;if(e.startContainer.nodeType===Node.TEXT_NODE&&e.startOffset>0){const s=document.createTextNode("");return(r=e.startContainer.parentNode)==null||r.insertBefore(s,e.startContainer.nextSibling),s}if(e.startContainer.nodeType===Node.TEXT_NODE&&e.startOffset===0){const s=document.createTextNode("");return(o=e.startContainer.parentNode)==null||o.insertBefore(s,e.startContainer),s}const n=document.createTextNode("");return t&&t!==e.startContainer?(a=t.parentNode)==null||a.insertBefore(n,t):e.startContainer.appendChild(n),n}function lc(e,t){let n=t;for(;n.parentElement&&n.parentElement!==e;){const r=n.parentElement;if(!mn(r)||!ac(r)){n=r;continue}if(Xn(r,n),Zc(r),Yn(r)){Mt(r);continue}n=r.isConnected?r:t}return t}function xx(e,t){bx(t);const n=yx(t);return lc(e,n)}function Cx(e,t,n){return!!(n&&n.value===null&&Gc(e,t))}const qc=["pt","px","em","rem","%"],Xr="pt",wx={pt:[8,9,10,11,12,14,16,18,20,22,24,26,28,36,48,72],px:[8,9,10,11,12,14,16,18,20,22,24,26,28,36,48,72],em:[.5,.75,1,1.25,1.5,2,2.5,3],rem:[.5,.75,1,1.25,1.5,2,2.5,3],"%":[50,75,100,125,150,200,250,300]},vx={pt:{min:1,max:400},px:{min:1,max:400},em:{min:.1,max:20},rem:{min:.1,max:20},"%":{min:1,max:1e3}},kx=new Set(qc),Sx=/^([+-]?(?:\d+(?:\.\d+)?|\.\d+))\s*(pt|px|em|rem|%|pc|cm|mm|in|ex|ch|q|vw|vh|vmin|vmax)$/i;function us(e){return kx.has(e)}function ot(e){return Math.round(e*100)/100}function me(e){const t=ot(e);return Number.isInteger(t),String(t)}function Yc(e,t){return`${me(e)}${t}`}function Xc(e){const t=e.trim();if(!t)return null;const n=t.match(Sx);if(!n)return null;const r=Number(n[1]);if(!Number.isFinite(r))return null;const o=n[2]==="%"?"%":n[2].toLowerCase();return{value:r,unit:o}}function Ax(e,t){const n=e.trim();if(!n)return null;const r=Xc(n);if(r)return us(r.unit)?gr(r.value,r.unit):null;const o=Number(n.replace(",","."));return Number.isFinite(o)?gr(o,t):null}function gr(e,t){if(!Number.isFinite(e)||e<=0)return null;const{min:n,max:r}=vx[t];return{value:ot(Math.min(r,Math.max(n,e))),unit:t}}function ip(e,t,n,r){const o=n>0?n:16,a=r>0?r:16;switch(t){case"px":return ot(e);case"pt":return ot(e*.75);case"em":return ot(e/o);case"rem":return ot(e/a);case"%":return ot(e/o*100)}}function Px(e,t,n,r){const o=n>0?n:16,a=r>0?r:16;switch(t){case"px":return e;case"pt":return e*(4/3);case"em":return e*o;case"rem":return e*a;case"%":return e/100*o}}function ap(e,t,n,r,o){if(t===n)return ot(e);const a=Px(e,t,r,o);return ip(a,n,r,o)}const Jc="pt",Tx=/^([+-]?(?:\d+(?:\.\d+)?|\.\d+))\s*(pt|px|em|rem|%)$/i,Rx=/^[+-]?0(?:\.0+)?$/;function Ie(e){return`${me(e.value)}${e.unit}`}function ht(e){const t=e.trim();if(!t)return null;if(Rx.test(t))return{value:0,unit:"px"};const n=t.match(Tx);if(!n)return null;const r=Number(n[1]);if(!Number.isFinite(r))return null;const o=n[2]==="%"?"%":n[2].toLowerCase();return us(o)?{value:ot(r),unit:o}:null}function Xo(e,t,n){const r=e.trim();if(!r)return null;const o=ht(r);if(o)return!n&&o.value<0?{...o,value:0}:o;const a=Number(r.replace(",","."));return Number.isFinite(a)?!n&&a<0?{value:0,unit:t}:{value:ot(a),unit:t}:null}function Jn(e){return e.value>=0?e:{value:0,unit:e.unit}}function zt(e,t){return e===t?!0:!e||!t?!1:e.value===t.value&&e.unit===t.unit}function xa(e){return{text:e.text,collapsed:e.collapsed,start:e.start,end:e.end}}function Dx(e,t){return t?e===t||e.contains(t):!1}function km(e,t){var a;const n=document.createTreeWalker(e,NodeFilter.SHOW_TEXT);let r=0,o;for(;o=n.nextNode();){if(o===t||t.contains(o)||t.compareDocumentPosition(o)&Node.DOCUMENT_POSITION_FOLLOWING)return r;r+=((a=o.textContent)==null?void 0:a.length)??0}return r}function Sm(e,t,n){var a;if(t.nodeType===Node.TEXT_NODE)return km(e,t)+n;let r=0;const o=t.childNodes;for(let s=0;s<n&&s<o.length;s+=1)r+=((a=o[s].textContent)==null?void 0:a.length)??0;return km(e,t)+r}function Am(e,t){var s,u;const n=document.createTreeWalker(e,NodeFilter.SHOW_TEXT);let r=Math.max(0,t),o,a=null;for(;o=n.nextNode();){a=o;const d=((s=o.textContent)==null?void 0:s.length)??0;if(r<=d)return{node:o,offset:r};r-=d}return a?{node:a,offset:((u=a.textContent)==null?void 0:u.length)??0}:{node:e,offset:e.childNodes.length}}function Qc(e,t,n){const r=document.createRange(),o=Am(e,t),a=Am(e,n);return r.setStart(o.node,o.offset),r.setEnd(a.node,a.offset),r}function sp(e,t){try{const n=e.commonAncestorContainer;return t===n||t.contains(n)}catch{return!1}}function Pm(e,t){return!!(e&&e.mode==="visual"&&e.visualRange&&(!t.visualRange||!e.collapsed&&t.collapsed))}function jx(e,t){return t.mode!=="visual"?null:t.visualRange&&sp(t.visualRange,e)?t.visualRange:Qc(e,t.start,t.end)}function on(e){var n;if(e.mode==="html"&&e.htmlEl){const r=e.htmlEl.selectionStart,o=e.htmlEl.selectionEnd;return{mode:"html",text:e.htmlEl.value.slice(r,o),collapsed:r===o,start:r,end:o,visualRange:null}}const t=e.visualEl;if(e.mode==="visual"&&t){const r=window.getSelection();if(r&&r.rangeCount>0){const a=r.getRangeAt(0);if(Dx(t,a.commonAncestorContainer)){const s=Sm(t,a.startContainer,a.startOffset),u=Sm(t,a.endContainer,a.endOffset);return{mode:"visual",text:a.toString(),collapsed:a.collapsed,start:Math.min(s,u),end:Math.max(s,u),visualRange:a.cloneRange()}}}const o=((n=t.textContent)==null?void 0:n.length)??0;return{mode:"visual",text:"",collapsed:!0,start:o,end:o,visualRange:null}}return{mode:e.mode,text:"",collapsed:!0,start:0,end:0,visualRange:null}}function Tm(e){return e.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}function Ix(e){if(e.snapshot.mode==="html"){const a=e.getHtml(),s=e.snapshot.start,u=e.snapshot.end,d=e.asHtml?e.content:Tm(e.content);e.setHtml(a.slice(0,s)+d+a.slice(u));const f=e.htmlEl;if(f){const g=s+d.length;f.focus(),f.setSelectionRange(g,g)}return}const t=e.visualEl;if(!t){const a=e.asHtml?e.content:Tm(e.content);e.setHtml(e.getHtml()+a);return}const r=(e.snapshot.visualRange&&sp(e.snapshot.visualRange,t)?e.snapshot.visualRange:null)??Qc(t,e.snapshot.start,e.snapshot.end);if(r.deleteContents(),e.content)if(e.asHtml){const a=r.createContextualFragment(e.content),s=a.lastChild;r.insertNode(a),s&&(r.setStartAfter(s),r.collapse(!0))}else{const a=document.createTextNode(e.content);r.insertNode(a),r.setStartAfter(a),r.collapse(!0)}const o=window.getSelection();o==null||o.removeAllRanges(),o==null||o.addRange(r),e.setHtml(t.innerHTML)}const eu=new Set(["p","h1","h2","h3","h4","h5","h6","div","li","blockquote"]),lp=new Set(["table","thead","tbody","tr","td","th"]),tu=new Set([...lp,"ul","ol","li","pre","hr"]);function Me(e){return e.tagName.toLowerCase()}function li(e){return e.nodeType===Node.TEXT_NODE?e.parentElement:e instanceof Element?e:e.parentElement}function nu(e){return e instanceof HTMLElement&&(Me(e)==="ul"||Me(e)==="ol")}function Ot(e){return e instanceof HTMLElement&&Me(e)==="li"}function fn(e){const t=window.getSelection();if(!t||t.rangeCount===0)return null;const n=t.getRangeAt(0);return ke(e,n.commonAncestorContainer)?n:null}function ru(e){const t=e.collapsed?[]:At(e).filter(n=>n.data.length>0);return t.length>0?t:[e.startContainer]}function Jr(e,t,n){var d,f,g;if(t.nodeType===Node.TEXT_NODE){const h=document.createTreeWalker(e,NodeFilter.SHOW_TEXT);let y=0,b;for(;b=h.nextNode();){if(b===t)return y+n;y+=((d=b.textContent)==null?void 0:d.length)??0}return y}let r=0;const o=t.childNodes;for(let h=0;h<n&&h<o.length;h+=1)r+=((f=o[h].textContent)==null?void 0:f.length)??0;const a=document.createTreeWalker(e,NodeFilter.SHOW_TEXT);let s=0,u;for(;u=a.nextNode();){if(t.contains(u)||t.compareDocumentPosition(u)&Node.DOCUMENT_POSITION_FOLLOWING)return s+r;s+=((g=u.textContent)==null?void 0:g.length)??0}return s+r}function ou(e,t,n){const r=Qc(e,t,n),o=window.getSelection();o==null||o.removeAllRanges(),o==null||o.addRange(r)}function Qn(e,t){const n=fn(e);if(!n)return!1;const r=Jr(e,n.startContainer,n.startOffset),o=Jr(e,n.endContainer,n.endOffset),a=Math.min(r,o),s=Math.max(r,o),u=t();return ou(e,a,s),u}function iu(e,t){if(Me(e)===t)return e;const n=document.createElement(t);for(const r of[...e.attributes])n.setAttribute(r.name,r.value);for(;e.firstChild;)n.appendChild(e.firstChild);return e.replaceWith(n),n}function vt(e){var t;(t=e.getAttribute("style"))!=null&&t.trim()||e.removeAttribute("style")}function Ex(e,t){let n=li(t);for(;n&&n!==e;){if(Gp(n,e)||Pt(n)){n=n.parentElement;continue}const r=Me(n);if(eu.has(r)&&n instanceof HTMLElement)return n;if(lp.has(r)||r==="pre")return null;n=n.parentElement}return null}function An(e){const t=fn(e);if(!t)return[];const n=new Set,r=[];for(const o of ru(t)){const a=Ex(e,o);a&&!n.has(a)&&(n.add(a),r.push(a))}return r}function cc(e){if(e.nodeType===Node.TEXT_NODE||e.nodeType===Node.COMMENT_NODE||!(e instanceof Element))return!0;const t=Me(e);return eu.has(t)||tu.has(t)?!1:mn(e)||t==="br"||t==="a"||t==="img"||t==="span"}function _x(e,t){let n=li(t);for(;n&&n!==e;){if(tu.has(Me(n)))return!0;n=n.parentElement}return!1}function Mx(e,t){let n=t;for(;n&&n.parentNode!==e;)n=n.parentNode;return n&&n.parentNode===e?n:null}function Nx(e,t){const n=[...e.childNodes],r=n.indexOf(t);if(r<0)return[t];let o=r,a=r;for(;o>0&&cc(n[o-1]);)o-=1;for(;a<n.length-1&&cc(n[a+1]);)a+=1;return n.slice(o,a+1)}function uc(e){for(const t of e.childNodes)if(!(t instanceof HTMLElement&&Pt(t)))return t;return null}function Lx(e,t,n){if(n.startContainer===e){const r=e.childNodes[Math.min(n.startOffset,Math.max(0,e.childNodes.length-1))]??e.firstChild;return r instanceof HTMLElement&&Pt(r)?uc(e):r}return n.startContainer===t&&e!==t?uc(e):Mx(e,n.startContainer)}function Bx(e,t){const n=gu(e);if(_x(e,t.startContainer))return null;if(!uc(n)){const s=document.createElement("p");return s.appendChild(document.createElement("br")),n.appendChild(s),s}const r=Lx(n,e,t);if(!r||r instanceof HTMLElement&&Pt(r)||r instanceof Element&&tu.has(Me(r))||r instanceof HTMLElement&&eu.has(Me(r))||!cc(r))return null;const o=Nx(n,r),a=document.createElement("p");n.insertBefore(a,o[0]);for(const s of o)a.appendChild(s);return a}function Cr(e){const t=An(e);if(t.length>0)return t;const n=fn(e);if(!n)return[];const r=Bx(e,n);return r?[r]:[]}function Qr(e){const t=e.parentElement;return t&&nu(t)?t:null}function cp(e){if(e.length===0)return[];const t=[[e[0]]];for(let n=1;n<e.length;n+=1){const r=e[n-1],o=e[n];r.parentNode===o.parentNode&&Fx(r,o)?t[t.length-1].push(o):t.push([o])}return t}function Fx(e,t){var r;let n=e.nextSibling;for(;n;){if(n===t)return!0;if(n.nodeType===Node.TEXT_NODE&&!((r=n.textContent)!=null&&r.trim())){n=n.nextSibling;continue}return!1}return!1}function Hx(e){return e.nodeType===Node.TEXT_NODE?e.parentElement:e instanceof Element?e:e.parentElement}function Bl(e){const t=e.trim().match(/^rgba?\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)(?:\s*,\s*(\d*\.?\d+))?\s*\)$/i);if(!t)return null;const n=Number(t[1]),r=Number(t[2]),o=Number(t[3]),a=t[4]===void 0?1:Number(t[4]);return[n,r,o,a].every(s=>Number.isFinite(s))?{r:n,g:r,b:o,a}:null}function Fl(e,t,n){const r=o=>Math.max(0,Math.min(255,Math.round(o))).toString(16).padStart(2,"0");return`#${r(e)}${r(t)}${r(n)}`}function Hl(e){const t=e.trim().toLowerCase();return/^#[0-9a-f]{6}$/.test(t)?t:/^#[0-9a-f]{3}$/.test(t)?`#${t[1]}${t[1]}${t[2]}${t[2]}${t[3]}${t[3]}`:null}const zx={black:"#000000",silver:"#c0c0c0",gray:"#808080",grey:"#808080",white:"#ffffff",maroon:"#800000",red:"#ff0000",purple:"#800080",fuchsia:"#ff00ff",magenta:"#ff00ff",green:"#008000",lime:"#00ff00",olive:"#808000",yellow:"#ffff00",navy:"#000080",blue:"#0000ff",teal:"#008080",aqua:"#00ffff",cyan:"#00ffff",orange:"#ffa500"};function Ox(e){const t=e.trim().toLowerCase();return t===""||t==="transparent"||t==="inherit"||t==="initial"||t==="unset"||t==="currentcolor"||t==="currentColor"}function Ue(e){const t=e.trim();if(!t||Ox(t))return null;const n=Hl(t);if(n)return n;const r=Bl(t);if(r)return r.a===0?null:Fl(r.r,r.g,r.b);const o=zx[t.toLowerCase()];if(o)return o;const a=document.createElement("canvas").getContext("2d");if(!a)return null;a.fillStyle="#010203";try{a.fillStyle=t}catch{return null}const s=String(a.fillStyle);if(s==="#010203"){const d=Hl(t);if(d==="#010203")return d;const f=Bl(t);return f&&Fl(f.r,f.g,f.b)==="#010203"?"#010203":t.trim().toLowerCase()==="black"?"#000000":null}if(s.startsWith("#"))return Hl(s);const u=Bl(s);return!u||u.a===0?null:Fl(u.r,u.g,u.b)}function up(e,t){const n=t==="color"?e.style.color:e.style.backgroundColor;return n?Ue(n):null}function _a(e,t,n){let r=Hx(t);for(;r&&r!==e&&r instanceof HTMLElement;){const o=up(r,n);if(o)return o;r=r.parentElement}return null}function Ma(e,t){return e instanceof HTMLElement?up(e,t)!==null:!1}function au(e,t){if(t==="color"){e.style.color="",e.style.removeProperty("color");return}e.style.backgroundColor="",e.style.removeProperty("background-color")}function dp(e,t,n){if(t==="color"){e.style.color=n;return}e.style.backgroundColor=n}function Kx(e,t,n){let r=t;for(;r.parentElement&&r.parentElement!==e;){const o=r.parentElement;if(!mn(o)||!Ma(o,n)){r=o;continue}if(Xn(o,r),Ma(o,n)&&(au(o,n),Yn(o))){Mt(o);continue}r=o}}function mp(e){const t=window.getSelection();if(!t||t.rangeCount===0)return null;const n=t.getRangeAt(0);return ke(e,n.commonAncestorContainer)?n:null}function Na(e,t){const n=mp(e);if(!n)return{value:null,mixed:!1};const r=n.collapsed?[]:At(n).filter(d=>d.data.length>0),a=(r.length>0?r:[n.startContainer]).map(d=>_a(e,d,t)),s=a[0]??null;return a.every(d=>d===s)?{value:s,mixed:!1}:{value:null,mixed:!0}}function Vo(e,t,n){const r=mp(e);if(!r||r.collapsed)return!1;const o=n===null?null:Ue(n);if(n!==null&&o===null)return!1;un(r);const a=At(r).filter(s=>s.data.length>0);for(const s of a){const u=_a(e,s,t);if(o===null){if(u===null)continue;Kx(e,s,t);continue}u!==o&&ai(s,d=>{dp(d,t,o)})}return xr(a),!0}function Rm(e,t,n){if(n.value===null){au(e,t);return}const r=Ue(n.value);r&&dp(e,t,r)}function $x(e){return!!(e!=null&&e.color||e!=null&&e.backgroundColor)}function Ux(e){const t=e.startContainer,n=e.startOffset;if(t.nodeType!==Node.TEXT_NODE)return;const r=t;if(n<=0||n>=r.length)return;const o=r.splitText(n);e.setStart(o,0),e.collapse(!0)}function Vx(e){var r,o,a;let t=e.startContainer.nodeType===Node.TEXT_NODE&&e.startOffset===0?e.startContainer:e.startContainer.childNodes[e.startOffset]??e.startContainer.lastChild??e.startContainer;if(e.startContainer.nodeType===Node.TEXT_NODE&&e.startOffset>0){const s=document.createTextNode("");return(r=e.startContainer.parentNode)==null||r.insertBefore(s,e.startContainer.nextSibling),s}if(e.startContainer.nodeType===Node.TEXT_NODE&&e.startOffset===0){const s=document.createTextNode("");return(o=e.startContainer.parentNode)==null||o.insertBefore(s,e.startContainer),s}const n=document.createTextNode("");return t&&t!==e.startContainer?(a=t.parentNode)==null||a.insertBefore(n,t):e.startContainer.appendChild(n),n}function fp(e,t,n){let r=t;for(;r.parentElement&&r.parentElement!==e;){const o=r.parentElement;if(!mn(o)||!n.some(a=>Ma(o,a))){r=o;continue}Xn(o,r);for(const a of n)Ma(o,a)&&au(o,a);if(Yn(o)){Mt(o);continue}r=o.isConnected?o:t}return t}function Wx(e,t,n){Ux(t);const r=Vx(t);return fp(e,r,n)}function Gx(e,t,n){const r=[];return n!=null&&n.color&&n.color.value===null&&_a(e,t,"color")&&r.push("color"),n!=null&&n.backgroundColor&&n.backgroundColor.value===null&&_a(e,t,"backgroundColor")&&r.push("backgroundColor"),r}const pp=["auto","avoid"],dc=["auto","avoid","page"];new Set(pp);new Set(dc);function gp(e){return e.trim().toLowerCase()}function Dm(e){return gp(e)==="avoid"?"avoid":"auto"}function La(e){const t=gp(e);return t==="avoid"?"avoid":t==="page"||t==="always"?"page":"auto"}function hp(e){const t=e.style.breakInside;if(t)return Dm(t);const n=e.style.pageBreakInside;return n?Dm(n):"auto"}function bp(e){const t=e.style.breakAfter;if(t)return La(t);const n=e.style.pageBreakAfter;return n?La(n):"auto"}function yp(e){const t=e.style.breakBefore;if(t)return La(t);const n=e.style.pageBreakBefore;return n?La(n):"auto"}function Zx(e){e.style.removeProperty("break-inside"),e.style.removeProperty("page-break-inside")}function qx(e){e.style.removeProperty("break-after"),e.style.removeProperty("page-break-after")}function Yx(e){e.style.removeProperty("break-before"),e.style.removeProperty("page-break-before")}function Xx(e){return{breakInside:hp(e),breakAfter:bp(e),breakBefore:yp(e)}}function Jx(e,t){return hp(e)===t?!1:t==="auto"?(Zx(e),!0):(e.style.breakInside="avoid",e.style.pageBreakInside="avoid",!0)}function Qx(e,t){return bp(e)===t?!1:t==="auto"?(qx(e),!0):t==="avoid"?(e.style.breakAfter="avoid",e.style.pageBreakAfter="avoid",!0):(e.style.breakAfter="page",e.style.pageBreakAfter="always",!0)}function eC(e,t){return yp(e)===t?!1:t==="auto"?(Yx(e),!0):t==="avoid"?(e.style.breakBefore="avoid",e.style.pageBreakBefore="avoid",!0):(e.style.breakBefore="page",e.style.pageBreakBefore="always",!0)}function tC(e,t){return e===t}function jm(e,t){return e===t}const it=["top","right","bottom","left"],ds=["none","solid","dotted","dashed","double","groove","ridge","inset","outset"],Yt={top:null,right:null,bottom:null,left:null},su={style:"none",width:null,color:null},nC=new Set(ds),Im={value:0,unit:"px"};function rC(){return{margin:{...Yt},padding:{...Yt},lineHeight:null,border:{...su},borderRadius:null,boxShadow:null,backgroundColor:null,opacity:null,breakInside:"auto",breakAfter:"auto",breakBefore:"auto"}}function lu(){const e=rC();return{margin:e.margin,marginMixed:!1,padding:e.padding,paddingMixed:!1,lineHeight:e.lineHeight,lineHeightMixed:!1,border:e.border,borderMixed:!1,borderRadius:e.borderRadius,radiusMixed:!1,boxShadow:e.boxShadow,shadowMixed:!1,backgroundColor:e.backgroundColor,backgroundMixed:!1,opacity:e.opacity,opacityMixed:!1,breakInside:e.breakInside,breakInsideMixed:!1,breakAfter:e.breakAfter,breakAfterMixed:!1,breakBefore:e.breakBefore,breakBeforeMixed:!1}}function kn(e,t){return it.every(n=>zt(e[n],t[n]))}function xp(e,t){return e===t?!0:!e||!t||e.kind!==t.kind?!1:e.kind==="normal"||t.kind==="normal"?!0:e.kind==="number"&&t.kind==="number"?e.value===t.value:e.kind==="length"&&t.kind==="length"&&e.value===t.value&&e.unit===t.unit}function Cp(e,t){return e.style===t.style&&zt(e.width,t.width)&&e.color===t.color}function wp(e,t){return e===t?!0:!e||!t?!1:zt(e.offsetX,t.offsetX)&&zt(e.offsetY,t.offsetY)&&zt(e.blur,t.blur)&&zt(e.spread,t.spread)&&e.color===t.color&&e.inset===t.inset}function oC(e){return e.kind==="normal"?"normal":e.kind==="number"?me(e.value):Ie({value:e.value,unit:e.unit})}function iC(e){const t=e.trim();if(!t)return null;if(t.endsWith("%")){const r=Number(t.slice(0,-1).trim().replace(",","."));return Number.isFinite(r)?Wn(r/100):null}const n=Number(t.replace(",","."));return Number.isFinite(n)?Wn(n):null}function Wn(e){return ot(Math.min(1,Math.max(0,e)))}function Ba(e){return ot(Wn(e)*100)}function vp(e){return Wn(e/100)}function kp(e){return me(Wn(e))}function aC(e){const t=e.trim();if(!t)return null;if(t.toLowerCase()==="normal")return{kind:"normal"};if(/^[+]?(?:\d+(?:\.\d+)?|\.\d+)$/.test(t)){const r=Number(t);return!Number.isFinite(r)||r<0?null:{kind:"number",value:ot(r)}}const n=ht(t);return!n||n.value<0?null:{kind:"length",value:n.value,unit:n.unit}}function sC(e,t){const n=[];let r="",o=0;for(const a of e){if(a==="("){o+=1,r+=a;continue}if(a===")"){o=Math.max(0,o-1),r+=a;continue}if(a===t&&o===0){r.trim()&&n.push(r.trim()),r="";continue}r+=a}return r.trim()&&n.push(r.trim()),n}function lC(e){const t=[];let n="",r=0;for(const o of e){if(o==="("){r+=1,n+=o;continue}if(o===")"){r=Math.max(0,r-1),n+=o;continue}if(/\s/.test(o)&&r===0){n&&t.push(n),n="";continue}n+=o}return n&&t.push(n),t}function cC(e){const t=[Ie(e.offsetX),Ie(e.offsetY),Ie(e.blur),Ie(e.spread)];e.color&&t.push(e.color);const n=t.join(" ");return e.inset?`inset ${n}`:n}function uC(e){const t=e.trim();if(!t||t.toLowerCase()==="none")return null;const n=sC(t,",")[0];if(!n)return null;const r=lC(n);let o=!1,a=null;const s=[];for(const u of r){if(u.toLowerCase()==="inset"){o=!0;continue}const d=ht(u);if(d){s.push(d);continue}const f=Ue(u);if(f){a=f;continue}return null}return s.length<2||s.length>4?null:{offsetX:s[0],offsetY:s[1],blur:s[2]??Im,spread:s[3]??Im,color:a,inset:o}}function Vr(e,t){return ht(e.style.getPropertyValue(t))}function dC(e,t,n,r){const o=n&&r?Jn(n):n,a=o?Ie(o):"";return e.style.getPropertyValue(t)===a?!1:(a?e.style.setProperty(t,a):e.style.removeProperty(t),!0)}function Em(e,t){return{top:Vr(e,`${t}-top`),right:Vr(e,`${t}-right`),bottom:Vr(e,`${t}-bottom`),left:Vr(e,`${t}-left`)}}function _m(e,t,n,r){let o=!1;for(const a of it)dC(e,`${t}-${a}`,n[a],r)&&(o=!0);return o}function mC(e){const t=e.trim().toLowerCase();return nC.has(t)?t:"none"}function Sp(e){const t=mC(e.style.borderStyle||e.style.borderTopStyle),n=Vr(e,"border-width")??Vr(e,"border-top-width"),r=e.style.borderColor||e.style.borderTopColor,o=r?Ue(r):null;return{style:t,width:n,color:o}}function fC(e,t){const n=Sp(e),r=t.style==="none"?{style:"none",width:null,color:null}:{style:t.style,width:t.width?Jn(t.width):null,color:t.color};return Cp(n,r)?!1:r.style==="none"?(e.style.removeProperty("border"),e.style.removeProperty("border-style"),e.style.removeProperty("border-width"),e.style.removeProperty("border-color"),!0):(e.style.borderStyle=r.style,r.width?e.style.borderWidth=Ie(r.width):e.style.removeProperty("border-width"),r.color?e.style.borderColor=r.color:e.style.removeProperty("border-color"),!0)}function Ap(e){const t=e.style.borderRadius.trim();if(!t)return null;const n=t.split(/\s+/)[0];return ht(n)}function pC(e,t){const n=t?Jn(t):null,r=Ap(e);return zt(r,n)?!1:(n?e.style.borderRadius=Ie(n):e.style.removeProperty("border-radius"),!0)}function Pp(e){return uC(e.style.boxShadow)}function gC(e,t){const n=Pp(e),r=t?{...t,blur:Jn(t.blur)}:null;return wp(n,r)?!1:(r?e.style.boxShadow=cC(r):e.style.removeProperty("box-shadow"),!0)}function Tp(e){return aC(e.style.lineHeight)}function hC(e,t){const n=Tp(e);return xp(n,t)?!1:(t?e.style.lineHeight=oC(t):e.style.removeProperty("line-height"),!0)}function Rp(e){const t=e.style.backgroundColor;return t?Ue(t):null}function bC(e,t){const n=t?Ue(t):null;return Rp(e)===n?!1:(n?e.style.backgroundColor=n:e.style.removeProperty("background-color"),!0)}function Dp(e){return iC(e.style.opacity)}function yC(e,t){const n=Dp(e),r=t===null?null:Wn(t);return n===r?!1:(r===null?e.style.removeProperty("opacity"):e.style.opacity=kp(r),!0)}function ao(e){const t=Xx(e);return{margin:Em(e,"margin"),padding:Em(e,"padding"),lineHeight:Tp(e),border:Sp(e),borderRadius:Ap(e),boxShadow:Pp(e),backgroundColor:Rp(e),opacity:Dp(e),breakInside:t.breakInside,breakAfter:t.breakAfter,breakBefore:t.breakBefore}}function so(e,t){let n=!1;return!t.marginMixed&&_m(e,"margin",t.margin,!1)&&(n=!0),!t.paddingMixed&&_m(e,"padding",t.padding,!0)&&(n=!0),!t.lineHeightMixed&&hC(e,t.lineHeight)&&(n=!0),!t.borderMixed&&fC(e,t.border)&&(n=!0),!t.radiusMixed&&pC(e,t.borderRadius)&&(n=!0),!t.shadowMixed&&gC(e,t.boxShadow)&&(n=!0),!t.backgroundMixed&&bC(e,t.backgroundColor)&&(n=!0),!t.opacityMixed&&yC(e,t.opacity)&&(n=!0),!t.breakInsideMixed&&Jx(e,t.breakInside)&&(n=!0),!t.breakAfterMixed&&Qx(e,t.breakAfter)&&(n=!0),!t.breakBeforeMixed&&eC(e,t.breakBefore)&&(n=!0),n&&vt(e),n}function xC(e){const t=lu(),n=An(e);if(n.length===0)return t;const r=n.map(ao),o=r[0];return{margin:o.margin,marginMixed:r.some(a=>!kn(a.margin,o.margin)),padding:o.padding,paddingMixed:r.some(a=>!kn(a.padding,o.padding)),lineHeight:o.lineHeight,lineHeightMixed:r.some(a=>!xp(a.lineHeight,o.lineHeight)),border:o.border,borderMixed:r.some(a=>!Cp(a.border,o.border)),borderRadius:o.borderRadius,radiusMixed:r.some(a=>!zt(a.borderRadius,o.borderRadius)),boxShadow:o.boxShadow,shadowMixed:r.some(a=>!wp(a.boxShadow,o.boxShadow)),backgroundColor:o.backgroundColor,backgroundMixed:r.some(a=>a.backgroundColor!==o.backgroundColor),opacity:o.opacity,opacityMixed:r.some(a=>a.opacity!==o.opacity),breakInside:o.breakInside,breakInsideMixed:r.some(a=>!tC(a.breakInside,o.breakInside)),breakAfter:o.breakAfter,breakAfterMixed:r.some(a=>!jm(a.breakAfter,o.breakAfter)),breakBefore:o.breakBefore,breakBeforeMixed:r.some(a=>!jm(a.breakBefore,o.breakBefore))}}function CC(e,t){return Qn(e,()=>{const n=Cr(e);if(n.length===0)return!1;let r=!1;for(const o of n)so(o,t)&&(r=!0);return r})}const Jo=96,wC=25.4,cu=Jo/wC,jp=cu*10,Ip=72,vC=/^([+-]?(?:\d+(?:\.\d+)?|\.\d+))\s*(in|cm|mm|pt|px|em|rem|%)$/i;function Ep(e){const t=e.trim();if(!t)return null;if(/^[+-]?0(?:\.0+)?$/.test(t))return{value:0,unit:"px"};const n=t.match(vC);if(!n)return null;const r=Number(n[1]);return Number.isFinite(r)?{value:ot(r),unit:n[2].toLowerCase()}:null}function Qo(e,t){switch(t){case"in":return e/Jo;case"cm":return e/jp;case"mm":return e/cu;case"pt":return e/Jo*Ip;case"px":default:return e}}function ei(e,t){switch(t){case"in":return e*Jo;case"cm":return e*jp;case"mm":return e*cu;case"pt":return e/Ip*Jo;case"em":case"rem":return e*16;case"px":default:return e}}function Fn(e,t=0){if(!e)return t;const n=typeof e=="string"?Ep(e):e;return!n||!Number.isFinite(n.value)?t:ei(n.value,n.unit)}function zl(e,t="in"){const n=Qo(e,t);return{value:Math.round(n*1e3)/1e3,unit:t}}function Ko(e){const t=Qo(e,"pt");return{value:Math.round(t*1e3)/1e3,unit:"pt"}}function _p(e,t="in"){const n=Qo(e,t),r=t==="in"?2:t==="cm"?1:0;return`${n.toFixed(r)} ${t}`}function dr(e,t="in",n=!1,r=0){if(n)return e;const o=e-r,s=ei(t==="in"?.125:t==="cm"?.25:t==="mm"?2.5:10,t);if(s<=0)return e;const u=Math.round(o/s)*s;return r+u}function Mp(e,t,n="in"){const r=[];if(e<=0)return r;const o=n==="in",a=o?.125:.1;if(ei(a,n)<=0)return r;const u=-Qo(t,n),d=Qo(e-t,n),f=Math.floor(u/a),g=Math.ceil(d/a);for(let h=f;h<=g;h++){const y=h*a,b=t+ei(y,n);if(b<0||b>e)continue;const C=Math.round(y),x=Math.abs(y-C)<.001,v=o?Math.abs(y-(Math.floor(y)+.5))<.001:!1,k=o?Math.abs(y-(Math.floor(y)+.25))<.001||Math.abs(y-(Math.floor(y)+.75))<.001:!1;let S=4;x?S=10:v?S=7:k&&(S=5);const P={positionPx:Math.round(b),unitValue:y,major:x,height:S};x&&y>=0&&(P.label=String(Math.abs(C))),r.push(P)}return r}function Np(e){const t=ht(e);if(t)return t;const n=Ep(e);return n&&(n.unit==="in"||n.unit==="cm"||n.unit==="mm")?Ko(ei(n.value,n.unit)):null}const Fa="data-page-at-rule";function Hn(){return{sizePreset:"auto",customWidth:null,customHeight:null,orientation:null,margin:{...Yt},marginMixed:!1}}function uu(e){return new DOMParser().parseFromString(`<body>${e}</body>`,"text/html")}function Lp(e){return e.body.innerHTML.replace(/\s*data-page=""/g," data-page")}function ti(e){var r;const n=uu(e).querySelector(`style[${Fa}]`);return((r=n==null?void 0:n.textContent)==null?void 0:r.trim())??null}function Ca(e,t){const n=new RegExp(`margin-${t}\\s*:\\s*([^;]+)`,"i"),r=e.match(n);return r?Np(r[1].trim()):null}function kC(e){const t=e.match(/(?:^|[\s{;])margin\s*:\s*([^;]+)/i);if(!t)return{...Yt};const n=t[1].trim().split(/\s+/).map(u=>Np(u)),[r,o=r,a=r,s=o]=n;return{top:r??null,right:o??null,bottom:a??null,left:s??null}}function SC(e){const t={sizePreset:"auto",customWidth:null,customHeight:null,orientation:null},n=e.match(/(?:^|[\s{;])size\s*:\s*([^;]+)/i);if(!n)return t;const r=n[1].trim().toLowerCase();if(r==="auto")return t;const o=r.includes("landscape"),a=r.includes("portrait"),s=o?"landscape":a?"portrait":null,u=r.replace(/\b(landscape|portrait)\b/g,"").trim(),d=u.split(/\s+/).filter(Boolean);if(d.length===1){if(d[0]==="a4")return{sizePreset:"A4",customWidth:null,customHeight:null,orientation:s};if(d[0]==="letter")return{sizePreset:"letter",customWidth:null,customHeight:null,orientation:s};if(d[0]==="legal")return{sizePreset:"legal",customWidth:null,customHeight:null,orientation:s}}if(d.length>=2){const f=ht(d[0]),g=ht(d[1]);if(f&&g)return{sizePreset:"custom",customWidth:f,customHeight:g,orientation:s}}return!u&&s?{sizePreset:"auto",customWidth:null,customHeight:null,orientation:s}:t}function AC(e){const t=Hn();if(!e)return t;const n=e.match(/@page\s*\{([^}]*)\}/is);if(!n)return t;const r=n[1],o=SC(r),a={top:Ca(r,"top"),right:Ca(r,"right"),bottom:Ca(r,"bottom"),left:Ca(r,"left")},u=it.some(d=>a[d]!==null)?a:kC(r);return{...o,margin:u,marginMixed:!1}}function rt(e){return AC(ti(e))}function an(e,t){return ti(e)||!ti(t)?e:Ha(e,rt(t))}function PC(e){const t=it.map(r=>e[r]);if(t.every(r=>r===null))return null;const n=t.map(r=>r?Ie(r):"0");return n[0]===n[1]&&n[1]===n[2]&&n[2]===n[3]?`margin: ${n[0]};`:it.map(r=>e[r]?`margin-${r}: ${Ie(e[r])};`:null).filter(Boolean).join(" ")}function TC(e){if(e.sizePreset==="auto"&&!e.orientation)return null;const t=[];return e.sizePreset==="A4"?t.push("A4"):e.sizePreset==="letter"?t.push("letter"):e.sizePreset==="legal"?t.push("legal"):e.sizePreset==="custom"&&e.customWidth&&e.customHeight&&t.push(Ie(e.customWidth),Ie(e.customHeight)),e.orientation&&t.push(e.orientation),t.length===0?null:`size: ${t.join(" ")};`}function RC(e){const t=TC(e),n=PC(e.margin);return!t&&!n?null:`@page { ${[t,n].filter(Boolean).join(" ")} }`}function ln(e){const t=uu(e);for(const n of t.querySelectorAll(`style[${Fa}]`))n.remove();return Lp(t)}function DC(e,t){const n=uu(e);let r=n.querySelector(`style[${Fa}]`);return r||(r=n.createElement("style"),r.setAttribute(Fa,""),n.body.insertBefore(r,n.body.firstChild)),r.textContent=t,Lp(n)}function Ha(e,t){const n=RC(t);return n?DC(e,n):Bp(e)}function Bp(e){return ln(e)}function Fp(e){const t=e.map(n=>ti(n)).filter(n=>!!n);return t.length===0?"":t.join(`
140
+ `)}const du="data-page-sized",mc={top:"--wysiwyg-page-margin-top",right:"--wysiwyg-page-margin-right",bottom:"--wysiwyg-page-margin-bottom",left:"--wysiwyg-page-margin-left"},jC="0.75rem",fc=["top","right","bottom","left"],Ol={A4:{width:"210mm",height:"297mm"},letter:{width:"8.5in",height:"11in"},legal:{width:"8.5in",height:"14in"}};function lo(e,t=!1){let n=null;return e.sizePreset==="A4"||e.sizePreset==="letter"||e.sizePreset==="legal"?n={...Ol[e.sizePreset]}:e.sizePreset==="custom"&&e.customWidth&&e.customHeight?n={width:Ie(e.customWidth),height:Ie(e.customHeight)}:e.orientation?n=t?{...Ol.letter}:null:n=t?{...Ol.letter}:null,n?e.orientation==="landscape"?{width:n.height,height:n.width}:n:null}function Hp(e){return lo(e,!1)!==null}function IC(e){const t=lo(e);if(!t)return null;const n=document.createElement("div");n.style.position="fixed",n.style.left="-10000px",n.style.top="0",n.style.visibility="hidden",n.style.boxSizing="border-box",n.style.width=t.width,n.style.minHeight=t.height;const r=ci(e);for(const a of it){const s=r[a];s&&n.style.setProperty(`padding-${a}`,s)}document.body.appendChild(n);const o={width:n.offsetWidth,height:n.offsetHeight};return n.remove(),o}function ci(e){return EC(e.margin)}function EC(e){return{top:e.top?Ie(e.top):null,right:e.right?Ie(e.right):null,bottom:e.bottom?Ie(e.bottom):null,left:e.left?Ie(e.left):null}}const _C=["width","min-height","padding-top","padding-right","padding-bottom","padding-left"];function zp(e){for(const t of fc)e.style.removeProperty(mc[t])}function MC(e){const t=e.querySelector("[data-page-bg]");if(!(t instanceof HTMLElement))return!1;const n=t.style.backgroundImage.trim();if(n&&n!=="none")return!0;const r=t.getAttribute("style")??"";return/background-image\s*:\s*(?!none\b)/i.test(r)}function NC(e,t){if(!MC(e)){zp(e);return}const n=rt(t);if(lo(n)){const o=ci(n);for(const a of fc){const s=o[a]??"0px";e.style.setProperty(mc[a],s)}return}for(const o of fc)e.style.setProperty(mc[o],jC)}function LC(e){e.removeAttribute(du);for(const t of _C)e.style.removeProperty(t);zp(e)}function Op(e,t){const n=rt(e),r={...n.margin};return t.left!==void 0&&(r.left=Ko(t.left)),t.right!==void 0&&(r.right=Ko(t.right)),t.top!==void 0&&(r.top=Ko(t.top)),t.bottom!==void 0&&(r.bottom=Ko(t.bottom)),Ha(e,{...n,margin:r})}function BC(e,t,n){co(e,Op(t,n))}function co(e,t){const n=rt(t),r=lo(n);if(!r){LC(e);return}e.setAttribute(du,""),e.style.width=r.width,e.style.minHeight=r.height;const o=ci(n);for(const a of it){const s=`padding-${a}`,u=o[a];u?e.style.setProperty(s,u):e.style.removeProperty(s)}NC(e,t)}const br="data-page",eo="data-page-bg",za="commspliant-background";function Pt(e){return e instanceof HTMLElement&&(e.id===za||e.hasAttribute(eo))}function FC(e){return e.hasAttribute(br)&&e.parentElement?e.parentElement:e}function mu(e){const t=FC(e),n=new Set,r=[],o=a=>{a instanceof HTMLElement&&Pt(a)&&!n.has(a)&&(n.add(a),r.push(a))};o(t.querySelector(`#${za}`));for(const a of t.querySelectorAll(`[${eo}]`))o(a);return o(t),r}function fu(e){return mu(e)[0]??null}function Wo(e){let t=!1;return e.style.width!=="100%"&&(e.style.width="100%",t=!0),e.style.height!=="100%"&&(e.style.height="100%",t=!0),t}function Kp(e,t){if(!e.hasAttribute(du))return Wo(t);let n=!1;return t.style.width!=="100%"&&(t.style.width="100%",n=!0),t.style.height!=="auto"&&(t.style.height="auto",n=!0),n}const HC=new Set(["p","h1","h2","h3","h4","h5","h6","li","blockquote","pre","div"]);function $p(e){return HC.has(e.tagName.toLowerCase())}function ms(e){const t=e.querySelectorAll("p, h1, h2, h3, h4, h5, h6, li");return t[t.length-1]??null}function Up(e){for(const t of e.childNodes)if(!(t instanceof HTMLElement&&Pt(t))&&t instanceof HTMLElement&&$p(t))return t;return null}function Vp(e){const t=Up(e)??ms(e);if(t)return t;const n=e.ownerDocument.createElement("p");return n.appendChild(e.ownerDocument.createElement("br")),e.appendChild(n),n}function fs(e){let t=!1;for(const n of[...e.childNodes]){if(n instanceof HTMLElement&&Pt(n)||n.nodeType!==Node.TEXT_NODE)continue;if(!(n.textContent??"").trim()){n.remove(),t=!0;continue}(ms(e)??Vp(e)).appendChild(n),t=!0}return t}function ps(e){const t=gt(e);if(!t)return!1;let n=!1;for(const r of[...e.childNodes])r!==t&&r instanceof HTMLElement&&Pt(r)&&(t.insertBefore(r,t.firstChild),n=!0);return n}function ni(e){const t=gt(e);if(!t)return{changed:!1,absorbedBlocks:[]};let n=ps(e);const r=[];for(const o of[...e.childNodes])if(o!==t&&!(o instanceof HTMLElement&&Pt(o))){if(o.nodeType===Node.TEXT_NODE){if(!(o.textContent??"").trim()){o.remove(),n=!0;continue}let s=ms(t);s||(s=document.createElement("p"),t.appendChild(s)),s.appendChild(o),n=!0;continue}o instanceof HTMLElement&&$p(o)&&r.push(o),t.appendChild(o),n=!0}return fs(t)&&(n=!0),{changed:n,absorbedBlocks:r}}function zC(e){const t=document.createRange(),n=e.firstChild;(n==null?void 0:n.nodeType)===Node.TEXT_NODE?t.setStart(n,0):n?t.setStartBefore(n):t.setStart(e,0),t.collapse(!0);const r=window.getSelection();r&&(r.removeAllRanges(),r.addRange(t))}const OC="p, h1, h2, h3, h4, h5, h6, li, blockquote, pre";function Wp(e,t){if(t<=0)return;const n=gt(e);if(!n)return;const r=n.querySelectorAll(OC);if(r.length===0)return;const o=r[r.length-1],a=window.getSelection();if(!a||a.rangeCount===0)return;const s=a.getRangeAt(0).startContainer;o.contains(s)||zC(o)}function Gp(e,t){return e instanceof HTMLElement&&e!==t&&e.parentElement===t&&e.hasAttribute(br)}function Zp(e){return[...e.children].filter(t=>t instanceof HTMLElement)}function KC(e){return[...e.childNodes].some(t=>t.nodeType===Node.TEXT_NODE&&(t.textContent??"").trim()!=="")}function gt(e){return Zp(e).find(n=>n.hasAttribute(br))??null}function $C(e){if(KC(e))return null;const t=Zp(e);if(t.length!==1)return null;const n=t[0];return n.tagName.toLowerCase()!=="div"||Pt(n)?null:n}function pu(e){const t=gt(e);if(t)return Wo(t),t;const n=$C(e);if(n)return n.setAttribute(br,""),Wo(n),n;const r=document.createElement("div");for(r.setAttribute(br,"");e.firstChild;)r.appendChild(e.firstChild);return e.appendChild(r),Wo(r),r}function gu(e){return gt(e)??e}function UC(e,t,n){const{startContainer:r}=n;return r===t||t.contains(r)?!1:r===e?!0:e.contains(r)}function VC(e,t){const{startContainer:n}=t;return n===e||n.nodeType===Node.TEXT_NODE&&n.parentElement===e}function WC(e){var o;const t=document.createRange(),n=e.lastChild;(n==null?void 0:n.nodeType)===Node.TEXT_NODE?t.setStart(n,((o=n.textContent)==null?void 0:o.length)??0):n?t.setStartAfter(n):t.setStart(e,0),t.collapse(!0);const r=window.getSelection();r&&(r.removeAllRanges(),r.addRange(t))}function Mm(e){fs(e);const t=ms(e)??Up(e)??Vp(e);WC(t)}function to(e){const t=gt(e);if(!t)return;fs(t);const n=window.getSelection();if(!n||n.rangeCount===0)return;const r=n.getRangeAt(0);if(VC(t,r)){Mm(t);return}UC(e,t,r)&&Mm(t)}const GC=["background-image","background-size","background-position","background-repeat","opacity"];function ZC(e,t,n){const r=(t==null?void 0:t.style.getPropertyValue(n).trim())??"";r?e.style.setProperty(n,r):e.style.removeProperty(n)}function gs(e){const t=gt(e);ZC(e,t,"background-color");for(const n of GC)e.style.removeProperty(n)}const Oa="<!-- wysiwyg-page-separator -->",ri="data-page-surface";function On(e){const t=e.trim();return t?t.includes(Oa)?e.split(Oa).map(n=>n.trim()):[e]:[""]}function _t(e){return e.length===0?"":e.length===1?e[0]??"":e.join(`
141
+ ${Oa}
142
+ `)}function Bn(){return"<p></p>"}function zn(e){return e.length===0?[Bn()]:e.map(t=>t.trim())}function Kl(e,t){if(e.length===t.length){let a=!1;const s=[],u=[];for(let d=0;d<t.length;d+=1){const f=t[d]??"";e[d]===f?s.push(e[d]):(s.push(f),a=!0,u.push(d))}return a?{pages:s,changed:!0,changedIndices:u}:{pages:e,changed:!1,changedIndices:[]}}const n=[],r=[];for(let a=0;a<t.length;a+=1){const s=t[a]??"";a<e.length&&e[a]===s?n.push(e[a]):(n.push(s),r.push(a))}return r.length>0||e.length!==t.length||!mr(e,n)?{pages:n,changed:!0,changedIndices:r}:{pages:e,changed:!1,changedIndices:[]}}function mr(e,t){if(e.length!==t.length)return!1;for(let n=0;n<e.length;n+=1)if(e[n]!==t[n])return!1;return!0}function pc(e,t,n){if(t<0||t>=e.length)return{pages:[...e],changed:!1};if(e[t]===n)return{pages:e,changed:!1};const r=e.slice();return r[t]=n,{pages:r,changed:!0}}function nt(e,t){const n=e.querySelector(`[${ri}][data-page-index="${t}"]`);return n||([...e.querySelectorAll(`[${ri}]`)][t]??null)}function qC(e){const t=e.getAttribute("data-page-index");if(t!==null){const r=Number.parseInt(t,10);if(!Number.isNaN(r))return r}let n=e.parentElement;for(;n;){const o=[...n.querySelectorAll(`[${ri}]`)].indexOf(e);if(o!==-1)return o;n=n.parentElement}return null}const Et="data-wysiwyg-img-id",gc="data-page-bg",YC=/^data:image\/(?:jpeg|jpg|png|gif|webp|bmp|avif)(?:;charset=[^;,]+)?;base64,/i,hc=/background-image:\s*url\(\s*(["']?)(.+?)\1\s*\)/i;function Nm(e){return new DOMParser().parseFromString(`<body>${e}</body>`,"text/html")}function Lm(e){return e.body.innerHTML}function $l(e){return YC.test(e.trim())}function Bm(e){return e.includes("<img")||e.includes("IMG")||e.includes(gc)||e.includes(Et)}function XC(e){var r;const t=hc.exec(e);return t&&(((r=t[2])==null?void 0:r.trim())??"")||null}function wa(e,t){const r=`url("${t.replace(/\\/g,"\\\\").replace(/"/g,'\\"')}")`;if(hc.test(e))return e.replace(hc,`background-image: ${r}`);const o=e.trim().replace(/;+$/,"");return o?`${o};background-image: ${r}`:`background-image: ${r}`}function JC(){return typeof crypto<"u"&&typeof crypto.randomUUID=="function"?crypto.randomUUID():`img-${Date.now()}-${Math.random().toString(36).slice(2,10)}`}function QC(){const e=new Map;function t(b,C){const x=e.get(b);if(x){if(x.dataUrl!==C){URL.revokeObjectURL(x.objectUrl);const k=URL.createObjectURL(Fm(C));return e.set(b,{dataUrl:C,objectUrl:k}),k}return x.objectUrl}const v=URL.createObjectURL(Fm(C));return e.set(b,{dataUrl:C,objectUrl:v}),v}function n(b,C){if(!(C!=null&&C.trim())){for(const[v,k]of e)if(k.dataUrl===b)return v}const x=(C==null?void 0:C.trim())||JC();return t(x,b),x}function r(b){var C;return((C=e.get(b))==null?void 0:C.dataUrl)??null}function o(b){var C;return((C=e.get(b))==null?void 0:C.objectUrl)??null}function a(b){return e.has(b)}function s(b){const C=b.trim();if(!C)return null;for(const[x,v]of e)if(v.objectUrl===C)return x;return null}function u(b,C){const x=b.trim();if(!x)return null;if($l(x))return x;const v=(C==null?void 0:C.trim())||s(x);return v?r(v):null}function d(b,C){var x,v;for(const k of b.querySelectorAll("img")){const S=(x=k.getAttribute(Et))==null?void 0:x.trim(),P=((v=k.getAttribute("src"))==null?void 0:v.trim())??"";if(C==="hydrate"){const A=u(P,S);if(!A)continue;k.setAttribute("src",A);continue}if(S&&a(S)){const A=o(S);A&&k.setAttribute("src",A);continue}const T=s(P);if(T){k.setAttribute(Et,T);const A=o(T);A&&k.setAttribute("src",A);continue}if(!$l(P))continue;const D=n(P);k.setAttribute(Et,D);const R=o(D);R&&k.setAttribute("src",R)}}function f(b,C){var x;for(const v of b.querySelectorAll(`[${gc}]`)){if(!(v instanceof HTMLElement))continue;const k=(x=v.getAttribute(Et))==null?void 0:x.trim(),S=v.getAttribute("style")??"",P=XC(S);if(C==="hydrate"){if(!P)continue;const A=u(P,k);if(!A)continue;v.setAttribute("style",wa(S,A));continue}if(!P)continue;if(k&&a(k)){const A=o(k);A&&v.setAttribute("style",wa(S,A));continue}const T=s(P);if(T){v.setAttribute(Et,T);const A=o(T);A&&v.setAttribute("style",wa(S,A));continue}if(!$l(P))continue;const D=n(P);v.setAttribute(Et,D);const R=o(D);R&&v.setAttribute("style",wa(S,R))}}function g(b){const C=b.trim();if(!C||!Bm(C))return b;const x=Nm(b);return d(x,"externalize"),f(x,"externalize"),Lm(x)}function h(b){const C=b.trim();if(!C||!Bm(C))return b;const x=Nm(b);f(x,"hydrate"),d(x,"hydrate");for(const v of x.querySelectorAll("img"))v.removeAttribute(Et);for(const v of x.querySelectorAll(`[${gc}]`))v.removeAttribute(Et);return Lm(x)}function y(){for(const b of e.values())URL.revokeObjectURL(b.objectUrl);e.clear()}return{register:n,getDataUrl:r,getObjectUrl:o,has:a,externalizeHtml:g,hydrateHtml:h,clear:y}}function Fm(e){const t=e.indexOf(",");if(t<0)return new Blob;const n=e.slice(0,t),r=e.slice(t+1),o=/^data:([^;,]+)/i.exec(n),a=(o==null?void 0:o[1])??"application/octet-stream",s=atob(r),u=new Uint8Array(s.length);for(let d=0;d<s.length;d+=1)u[d]=s.charCodeAt(d);return new Blob([u],{type:a})}const ew=.85,tw=new Set(["image/webp","image/avif","image/gif"]);let Bo=null;function nw(){if(Bo!==null)return Bo;Bo=!1;try{Bo=document.createElement("canvas").toDataURL("image/webp").startsWith("data:image/webp")}catch{}return Bo}function rw(e){const t=e.type.trim().toLowerCase();if(t&&tw.has(t))return!1;const n=aw(e.name);return!(!t&&(n==="webp"||n==="avif"||n==="gif"))}function ow(e,t=ew){return typeof createImageBitmap!="function"?Promise.resolve(null):createImageBitmap(e).then(n=>iw(n,t)).catch(()=>null)}function iw(e,t){const n=document.createElement("canvas");n.width=e.width,n.height=e.height;const r=n.getContext("2d");if(!r)return e.close(),Promise.resolve(null);try{r.drawImage(e,0,0)}finally{e.close()}return new Promise(o=>{n.toBlob(a=>{if(!a){o(null);return}const s=new FileReader;s.onload=()=>{const u=String(s.result??"");o(u.startsWith("data:image/webp")?u:null)},s.onerror=()=>o(null),s.readAsDataURL(a)},"image/webp",t)})}function aw(e){const t=e.lastIndexOf(".");return t<0||t===e.length-1?"":e.slice(t+1).toLowerCase()}const qp=2*1024*1024,sw="image/jpeg,image/png,image/gif,image/webp,image/bmp,image/avif,.jpg,.jpeg,.png,.gif,.webp,.bmp,.avif",lw=new Set(["image/jpeg","image/jpg","image/png","image/gif","image/webp","image/bmp","image/x-ms-bmp","image/avif"]),cw=new Set(["jpg","jpeg","png","gif","webp","bmp","avif"]),Yp=/^data:image\/(?:jpeg|jpg|png|gif|webp|bmp|avif)(?:;charset=[^;,]+)?;base64,/i,uw=/^(javascript|vbscript|file|blob):/i;function dw(e={}){return{src:"",alt:"",title:"",...e}}function dn(e){const t=e.trim();if(!t)return"empty";if(uw.test(t))return"invalid";if(t.toLowerCase().startsWith("data:"))return Yp.test(t)?null:"invalid";if(/^[a-z][a-z0-9+.-]*:/i.test(t)){const n=t.slice(0,t.indexOf(":")).toLowerCase();return n==="http"||n==="https"?null:"invalid"}return null}function mw(e){return e.size>qp?"tooLarge":Cw(e)?null:"type"}function fw(e){const t=mw(e);return t?Promise.reject(new Error(t)):pw(e)}async function pw(e){if(rw(e)&&nw()){const t=await ow(e);if(t&&dn(t)===null&&hw(t)<=qp)return t}return gw(e)}function gw(e){return new Promise((t,n)=>{const r=new FileReader;r.onload=()=>{const o=String(r.result??"");if(dn(o)){n(new Error("invalid"));return}t(o)},r.onerror=()=>n(r.error??new Error("Failed to read file")),r.readAsDataURL(e)})}function hw(e){const t=e.indexOf(",");if(t<0)return e.length;const n=e.slice(t+1),r=n.endsWith("==")?2:n.endsWith("=")?1:0;return Math.floor(n.length*3/4)-r}function bw(e,t,n){const r=Xp(t,n);e.setAttribute("src",r.src.trim()),r.registryId?e.setAttribute(Et,r.registryId):e.removeAttribute(Et);const o=t.alt.trim(),a=t.title.trim();o?e.setAttribute("alt",o):e.removeAttribute("alt"),a?e.setAttribute("title",a):e.removeAttribute("title"),e.style.maxWidth="100%",e.style.height="auto",yw(e,t.css)}function yw(e,t){if(t)for(const n of t.split(";")){const r=n.trim();if(!r)continue;const o=r.indexOf(":");if(o<=0)continue;const a=r.slice(0,o).trim(),s=r.slice(o+1).trim();a&&s&&e.style.setProperty(a,s)}}function Xp(e,t){if(!t)return e;const n=e.src.trim();if(dn(n)||!Yp.test(n))return e;const r=t.register(n),o=t.getObjectUrl(r);return o?{...e,src:o,registryId:r}:e}function xw(e,t,n){const r=dw(t),o=n?Xp(r,n):r;if(o.registryId){const d=n==null?void 0:n.getDataUrl(o.registryId);if(!d||dn(d))return!1}else if(dn(o.src))return!1;const a=window.getSelection();if(!a||a.rangeCount===0)return!1;const s=a.getRangeAt(0);if(!ke(e,s.commonAncestorContainer))return!1;s.collapsed||s.deleteContents();const u=document.createElement("img");return bw(u,o,n),s.insertNode(u),s.setStartAfter(u),s.collapse(!0),a.removeAllRanges(),a.addRange(s),!0}function bc(e,t){let n=t;for(;n&&n!==e;){if(n instanceof HTMLImageElement)return n;n=n.parentNode}return null}function Ul(e,t){if(!ke(e,t)||t===e)return!1;const n=document.createRange();n.selectNode(t);const r=window.getSelection();return r?(r.removeAllRanges(),r.addRange(n),!0):!1}function Cw(e){const t=e.type.trim().toLowerCase();if(t&&lw.has(t))return!0;const n=ww(e.name);return!!(!t&&n&&cw.has(n))}function ww(e){const t=e.lastIndexOf(".");return t<0||t===e.length-1?"":e.slice(t+1).toLowerCase()}const Jp=["%","px","pt","pc","em","rem"],vw="%",kw={"%":[25,50,75,100,125,150,200],px:[50,100,150,200,300,400,600,800],pt:[36,48,72,96,144,192,288],pc:[3,4,6,8,12,16,24],em:[2,4,6,8,12,16,24],rem:[2,4,6,8,12,16,24]},no={"%":{min:1,max:1e3},px:{min:1,max:4e3},pt:{min:1,max:3e3},pc:{min:.1,max:250},em:{min:.1,max:200},rem:{min:.1,max:200}},Sw=new Set(Jp),Aw=/^([+]?(?:\d+(?:\.\d+)?|\.\d+))\s*(pt|px|em|rem|%|pc)$/i;function Pw(e){return Sw.has(e)}function fr(e){return`${me(e.value)}${e.unit}`}function Ka(e){const t=e.trim();if(!t||t.toLowerCase()==="auto")return null;const n=t.match(Aw);if(!n)return null;const r=Number(n[1]);if(!Number.isFinite(r)||r<=0)return null;const o=n[2]==="%"?"%":n[2].toLowerCase();return Pw(o)?ro(r,o):null}function Hm(e,t){const n=e.trim();if(!n)return null;const r=Ka(n);if(r)return r;const o=Number(n.replace(",","."));return Number.isFinite(o)?ro(o,t):null}function ro(e,t){if(!Number.isFinite(e)||e<=0)return null;const{min:n,max:r}=no[t];return{value:ot(Math.min(r,Math.max(n,e))),unit:t}}function Go(e,t,n){const r=n>0?n:1;if(e==="width"){const a=ro(t.value/r,t.unit)??t;return{width:t,height:a}}return{width:ro(t.value*r,t.unit)??t,height:t}}const ja="data-hover-css",hu=["fill","contain","cover","none","scale-down"],bu=["center","top","bottom","left","right","top left","top right","bottom left","bottom right"],Tw=new Set(hu),Rw=new Set(bu),zm="if(this._hp==null)this._hp=this.getAttribute('style')||'';this.setAttribute('style',(this._hp?this._hp+';':'')+(this.getAttribute('data-hover-css')||''))",Dw="if(this._hp!=null){this.setAttribute('style',this._hp);this._hp=null}",jw=/^-?[a-z][a-z0-9-]*$/i,Iw=/expression\s*\(|javascript:|vbscript:|-moz-binding|\bbehavior\b/i,yc=/rotate\(\s*([+-]?(?:\d+(?:\.\d+)?|\.\d+))\s*deg\s*\)/i;function Qp(e={}){return{sizeMode:"width",width:null,height:null,align:null,margin:{...Yt},border:{...su},borderRadius:null,boxShadow:null,opacity:null,objectFit:null,objectPosition:null,rotateDeg:null,hoverCss:"",...e}}function Ew(e){const t=e.naturalWidth,n=e.naturalHeight;return t>0&&n>0?t/n:1}function _w(e,t){const n=e.objectFit;if(n!=="cover"&&n!=="contain"&&n!=="fill"||e.width&&e.height||!e.width&&!e.height)return e;if(e.width){const r=Go("width",e.width,t);return{...e,sizeMode:"lock",width:r.width,height:r.height}}if(e.height){const r=Go("height",e.height,t);return{...e,sizeMode:"lock",width:r.width,height:r.height}}return e}function Mw(e){const t=[];for(const n of e.split(";")){const r=n.trim();if(!r)continue;const o=r.indexOf(":");if(o<=0)continue;const a=r.slice(0,o).trim().toLowerCase(),s=r.slice(o+1).trim();!a||!s||jw.test(a)&&(a==="behavior"||a.endsWith("binding")||Iw.test(s)||t.push(`${a}: ${s}`))}return t.join("; ")}function Kn(e){const t=window.getSelection();if(!t||t.rangeCount===0)return null;const n=t.getRangeAt(0);if(!ke(e,n.commonAncestorContainer))return null;if(n.startContainer instanceof HTMLImageElement)return n.startContainer;if(n.startContainer.nodeType===Node.ELEMENT_NODE){const r=n.startContainer.childNodes[n.startOffset];if(r instanceof HTMLImageElement&&ke(e,r))return r}return bc(e,n.commonAncestorContainer)}function Nw(e){const t=Kn(e);return t?eg(t):null}function eg(e){const t=ao(e),n=zw(e),r=n==="center"?{...t.margin,left:null,right:null}:t.margin,o=Bw(e);return Qp({sizeMode:o.sizeMode,width:o.width,height:o.height,align:n,margin:r,border:t.border,borderRadius:t.borderRadius,boxShadow:t.boxShadow,opacity:t.opacity,objectFit:ng(e),objectPosition:Uw(e),rotateDeg:rg(e),hoverCss:e.getAttribute(ja)??""})}function tg(e,t){let n=!1;return Fw(e,t)&&(n=!0),so(e,{margin:t.align==="center"?{...t.margin,left:null,right:null}:t.margin,marginMixed:!1,padding:Yt,paddingMixed:!0,lineHeight:null,lineHeightMixed:!0,border:t.border,borderMixed:!1,borderRadius:t.borderRadius,radiusMixed:!1,boxShadow:t.boxShadow,shadowMixed:!1,backgroundColor:null,backgroundMixed:!0,opacity:t.opacity,opacityMixed:!1})&&(n=!0),Ow(e,t.align)&&(n=!0),Kw(e,t.objectFit)&&(n=!0),$w(e,t.objectPosition)&&(n=!0),Ww(e,t.rotateDeg)&&(n=!0),Gw(e,t.hoverCss)&&(n=!0),n}function Lw(e,t){const n=Kn(e);return n?tg(n,t):!1}function Bw(e){const t=Ka(e.style.width),n=Ka(e.style.height);return t&&n?{sizeMode:"lock",width:t,height:n}:n&&!t?{sizeMode:"height",width:null,height:n}:{sizeMode:"width",width:t,height:null}}function Fw(e,t){const n={width:e.style.width,height:e.style.height,maxWidth:e.style.maxWidth},r=Hw(t);return r.width?e.style.width=fr(r.width):e.style.removeProperty("width"),r.height?e.style.height=fr(r.height):e.style.height="auto",r.width||r.height?e.style.removeProperty("max-width"):e.style.maxWidth="100%",n.width!==e.style.width||n.height!==e.style.height||n.maxWidth!==e.style.maxWidth}function Hw(e){return e.sizeMode==="width"?{sizeMode:"width",width:e.width,height:null}:e.sizeMode==="height"?{sizeMode:"height",width:null,height:e.height}:{sizeMode:"lock",width:e.width,height:e.height}}function zw(e){const t=e.style.float.trim().toLowerCase();if(t==="left")return"left";if(t==="right")return"right";const n=e.style.display.trim().toLowerCase(),r=e.style.marginLeft.trim().toLowerCase(),o=e.style.marginRight.trim().toLowerCase();return n==="block"&&r==="auto"&&o==="auto"?"center":null}function Ow(e,t){const n={float:e.style.float,display:e.style.display,marginLeft:e.style.marginLeft,marginRight:e.style.marginRight};return t==="left"?(e.style.float="left",e.style.removeProperty("display"),e.style.marginLeft.trim().toLowerCase()==="auto"&&e.style.removeProperty("margin-left"),e.style.marginRight.trim().toLowerCase()==="auto"&&e.style.removeProperty("margin-right")):t==="right"?(e.style.float="right",e.style.removeProperty("display"),e.style.marginLeft.trim().toLowerCase()==="auto"&&e.style.removeProperty("margin-left"),e.style.marginRight.trim().toLowerCase()==="auto"&&e.style.removeProperty("margin-right")):t==="center"?(e.style.removeProperty("float"),e.style.display="block",e.style.marginLeft="auto",e.style.marginRight="auto"):(e.style.removeProperty("float"),e.style.display.trim().toLowerCase()==="block"&&e.style.removeProperty("display"),e.style.marginLeft.trim().toLowerCase()==="auto"&&e.style.removeProperty("margin-left"),e.style.marginRight.trim().toLowerCase()==="auto"&&e.style.removeProperty("margin-right")),n.float!==e.style.float||n.display!==e.style.display||n.marginLeft!==e.style.marginLeft||n.marginRight!==e.style.marginRight}function ng(e){const t=e.style.objectFit.trim().toLowerCase();return Tw.has(t)?t:null}function Kw(e,t){return ng(e)===t?!1:(t?e.style.objectFit=t:e.style.removeProperty("object-fit"),!0)}function $w(e,t){const n=(t==null?void 0:t.trim().toLowerCase().replace(/\s+/g," "))||"";return e.style.objectPosition.trim().toLowerCase().replace(/\s+/g," ")===n?!1:(n?e.style.objectPosition=n:e.style.removeProperty("object-position"),!0)}function Uw(e){const t=e.style.objectPosition.trim().toLowerCase().replace(/\s+/g," ");return t?(Rw.has(t),t):null}function rg(e){const t=yc.exec(e.style.transform);if(!t)return null;const n=Number(t[1]);return Number.isFinite(n)?ot(n):null}function Vw(e){const t=e.trim();return t?yc.test(t)&&t.replace(yc,"").trim()==="":!0}function Ww(e,t){const n=rg(e),r=t===null||t===0?null:ot(t);return n===r?!1:r===null?Vw(e.style.transform)?(e.style.removeProperty("transform"),!0):!1:(e.style.transform=`rotate(${me(r)}deg)`,!0)}function Gw(e,t){const n=Mw(t),r=e.getAttribute(ja)??"",o=e.getAttribute("onmouseover")??"";return r===n&&(n&&o===zm||!n&&!o)?!1:n?(e.setAttribute(ja,n),e.setAttribute("onmouseover",zm),e.setAttribute("onmouseout",Dw),!0):(e.removeAttribute(ja),e.removeAttribute("onmouseover"),e.removeAttribute("onmouseout"),!0)}const Yr={value:100,unit:"%"},Zw=new Set(hu),qw=new Set(bu),Yw=new Set(["cover","contain","scale-down","none"]),Om={contain:"contain",cover:"cover",auto:"none"},Km={fill:"100% 100%",contain:"contain",cover:"cover",none:"auto","scale-down":"contain"};function cn(){return{src:null,opacity:null,fit:null,position:null,width:{...Yr},height:null}}function og(e){return e!=null&&Yw.has(e)}function ig(e){const t=e.style.opacity.trim();if(!t)return null;const n=Number(t);return Number.isFinite(n)?Wn(n):null}function $m(e,t){const n=ig(e),r=t===null?null:Wn(t);return n===r?!1:(r===null?e.style.removeProperty("opacity"):e.style.opacity=kp(r),!0)}function ag(e){const t=e.style.backgroundImage.trim();if(!t||t==="none")return null;const n=/^url\(\s*["']?(.+?)["']?\s*\)$/i.exec(t);return n&&n[1].trim()||null}function Xw(e){return`url("${e.replace(/\\/g,"\\\\").replace(/"/g,'\\"')}")`}function Um(e,t){const n=ag(e),r=(t==null?void 0:t.trim())??"",o=r&&dn(r)===null?r:null;return n===o?!1:(o?e.style.backgroundImage=Xw(o):e.style.removeProperty("background-image"),!0)}function yu(e){return e.trim().toLowerCase().replace(/\s+/g," ")}function Vl(e){return!e||e==="auto"?null:Ka(e)}function Jw(e){return og(e.fit)&&e.fit?Km[e.fit]:e.fit==="fill"?Km.fill:e.width&&e.height?`${fr(e.width)} ${fr(e.height)}`:e.width?fr(e.width):e.height?`auto ${fr(e.height)}`:null}function Qw(e){const t=yu(e.style.backgroundSize);if(!t)return{fit:null,width:null,height:null};if(t==="100% 100%")return{fit:"fill",width:{...Yr},height:{...Yr}};if(Om[t])return{fit:Om[t],width:null,height:null};if(Zw.has(t))return{fit:t,width:null,height:null};const n=t.split(" ");return n.length===1?{fit:null,width:Vl(n[0]),height:null}:n.length===2?{fit:null,width:Vl(n[0]),height:Vl(n[1])}:{fit:null,width:null,height:null}}function e1(e,t){const n=yu(e.style.backgroundSize),r=Jw(t);return n===(r??"")?!1:(r?e.style.backgroundSize=r:e.style.removeProperty("background-size"),!0)}function t1(e){const t=e.style.backgroundPosition.trim().toLowerCase().replace(/\s+/g," ");return t?(qw.has(t),t):null}function Vm(e,t){const n=(t==null?void 0:t.trim().toLowerCase().replace(/\s+/g," "))||"";return e.style.backgroundPosition.trim().toLowerCase().replace(/\s+/g," ")===n?!1:(n?e.style.backgroundPosition=n:e.style.removeProperty("background-position"),!0)}function $a(e){let t=!1;return e.id!==za&&(e.id=za,t=!0),e.hasAttribute(eo)||(e.setAttribute(eo,""),t=!0),e.getAttribute("contenteditable")!=="false"&&(e.setAttribute("contenteditable","false"),t=!0),t}function Ua(e){const t=e.getAttribute("style");e.style.position="absolute",e.style.inset="0",e.style.zIndex="0",e.style.pointerEvents="none",e.style.userSelect="none",e.style.backgroundRepeat="no-repeat",e.style.setProperty("print-color-adjust","exact");const n=e.style.cssText;return n.includes("-webkit-print-color-adjust")||e.setAttribute("style",`${n};-webkit-print-color-adjust:exact`),e.getAttribute("style")!==t}function sg(e){const t=mu(e),n=t[0]??null;if(n){let o=$a(n);for(const a of t.slice(1))a.remove(),o=!0;return(n.parentNode!==e||n!==e.firstChild)&&(e.insertBefore(n,e.firstChild),o=!0),{layer:n,changed:o}}const r=document.createElement("div");return $a(r),Ua(r),e.insertBefore(r,e.firstChild),{layer:r,changed:!0}}function n1(e){const t=mu(e);if(t.length===0)return!1;for(const n of t)n.remove();return!0}function Va(e){let t=!1;return fu(e)?(e.style.position!=="relative"&&(e.style.position="relative",t=!0),e.style.isolation!=="isolate"&&(e.style.isolation="isolate",t=!0)):(e.style.position==="relative"&&(e.style.removeProperty("position"),t=!0),e.style.isolation==="isolate"&&(e.style.removeProperty("isolation"),t=!0)),t}function xu(e){if(!fu(e))return Va(e);const n=sg(e);let r=n.changed;return $a(n.layer)&&(r=!0),Ua(n.layer)&&(r=!0),Va(e)&&(r=!0),r}function hs(e){const t=gt(e);if(!t)return!1;let n=ps(e);return xu(t)&&(n=!0),n}function r1(e){return e.includes(eo)||e.includes(br)}function o1(e){const t=new DOMParser().parseFromString(`<body>${e}</body>`,"text/html");ps(t.body);const n=gt(t.body);return n&&(xu(n),fs(n)),t.body.innerHTML}function Wm(e){return r1(e)?o1(e):e}function lg(e){const t=Qw(e);return{src:ag(e),opacity:ig(e),fit:t.fit,position:t1(e),width:t.width,height:t.height}}function cg(e,t){var a;const n=((a=t.src)==null?void 0:a.trim())??"",r=n.length>0&&dn(n)===null;let o=!1;return r?(Um(e,n)&&(o=!0),e1(e,t)&&(o=!0),Vm(e,t.position)&&(o=!0),$m(e,t.opacity)&&(o=!0),e.style.backgroundRepeat!=="no-repeat"&&(e.style.backgroundRepeat="no-repeat",o=!0),o&&vt(e),o):(Um(e,null)&&(o=!0),yu(e.style.backgroundSize)&&(e.style.removeProperty("background-size"),o=!0),Vm(e,null)&&(o=!0),$m(e,null)&&(o=!0),e.style.backgroundRepeat&&(e.style.removeProperty("background-repeat"),o=!0),o&&vt(e),o)}function i1(e){const t=fu(e);return t?lg(t):cn()}function a1(e,t){var u;const n=((u=t.src)==null?void 0:u.trim())??"";if(!(n.length>0&&dn(n)===null)){const d=n1(e),f=Va(e);return(d||f)&&vt(e),d||f}const o=sg(e),a=o.layer;let s=o.changed;return $a(a)&&(s=!0),Ua(a)&&(s=!0),Va(e)&&(s=!0),cg(a,t)&&(s=!0),Ua(a)&&(s=!0),s&&(vt(a),vt(e)),s}function s1(e){return new DOMParser().parseFromString(`<body>${e}</body>`,"text/html")}function l1(e){const t=e.style.backgroundImage.trim();if(t&&t!=="none")return!0;const n=e.getAttribute("style")??"";return/background-image\s*:\s*(?!none\b)/i.test(n)}function Gm(e){const t=e.trim().match(/^([\d.]+)pt$/i);return t?Number.parseFloat(t[1]):null}function c1(e,t){if(!t)return e;if(!e)return t;const n=Gm(e),r=Gm(t);return n!==null&&r!==null?`${Math.max(n,r)}pt`:t}function u1(e,t){const n=rt(t),r=ci(n);e.style.boxSizing="border-box",e.style.position!=="relative"&&(e.style.position="relative"),e.style.isolation!=="isolate"&&(e.style.isolation="isolate");const o=lo(n);o?(e.style.width=o.width,e.style.minHeight=o.height):(e.style.width||(e.style.width="100%"),e.style.minHeight="100vh"),e.style.height="auto";for(const a of it){const s=`padding-${a}`,u=r[a],d=e.style.getPropertyValue(s).trim()||null,f=c1(d,u);f&&e.style.setProperty(s,f)}}function Cu(e){const t=s1(e);let n=!1;ps(t.body);for(const r of t.querySelectorAll(`[${br}]`)){if(!(r instanceof HTMLElement))continue;const o=r.querySelector(`[${eo}]`);!(o instanceof HTMLElement)||!l1(o)||(n=!0,u1(r,e),xu(r))}return{html:t.body.innerHTML,hasBleed:n}}const Zm=`
143
143
  @page {
144
144
  margin: 0;
145
145
  }
@@ -310,12 +310,12 @@ body:has([data-page-bg]) {
310
310
  box-sizing: border-box;
311
311
  }
312
312
  }
313
- `.trim();function ug(e){return e.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;")}function m1(e){return ug(e).replace(/'/g,"&#39;")}function dg(e){const t=e.trim();if(!/^<!DOCTYPE/i.test(t)&&!/^<html[\s>]/i.test(t))return e;const n=new DOMParser().parseFromString(t,"text/html"),r=[];for(const o of n.body.childNodes)if(o.nodeType===Node.ELEMENT_NODE)r.push(o.outerHTML);else if(o.nodeType===Node.TEXT_NODE){const a=o.textContent??"";a.trim()&&r.push(a)}return r.join("")||n.body.innerHTML}function f1(e,t="Document"){const n=Fn(e),r=n.map(b=>gu(b)),o=r.some(b=>b.hasBleed),a=[],s=[];for(const b of r){const x=he(b.html);a.push(...x.hrefs),s.push(x.body)}const u=s.length<=1?s[0]??"":s.map((b,x)=>`<div data-wysiwyg-print-page="" style="${x===s.length-1?"display: block; break-inside: avoid; page-break-inside: avoid;":"display: block; break-after: page; page-break-after: always; break-inside: avoid; page-break-inside: avoid;"}">${b}</div>`).join(""),d=Fp(n),f=o?"@page { margin: 0 !important; }":"",g=mg(o),h=[d,f,g].filter(Boolean).join(`
314
- `),C=Array.from(new Set(a)).map(b=>`<link rel="stylesheet" href="${m1(b)}" />`).join(`
315
- `);return["<!DOCTYPE html>",'<html lang="en">',"<head>",'<meta charset="utf-8">',`<title>${ug(t)}</title>`,`<style>${h}</style>`,C,"</head>","<body>",u,"</body>","</html>"].filter(Boolean).join(`
316
- `)}function mg(e){return e?`${Gm}
317
- ${d1}`:Gm}function pc(e,t,n="​"){const r=gu(t),{hrefs:o,body:a}=he(r.html),s=e.createElement("meta");s.setAttribute("charset","utf-8");const u=e.createElement("title");u.textContent=n;const d=e.createElement("style");d.textContent=mg(r.hasBleed);const f=o.map(g=>{const h=e.createElement("link");return h.rel="stylesheet",h.href=g,h});e.head.replaceChildren(s,u,d,...f),e.title=n,e.body.innerHTML=a}function hu(e){return typeof e.text=="function"?e.text():new Promise((t,n)=>{const r=new FileReader;r.onload=()=>t(String(r.result??"")),r.onerror=()=>n(r.error??new Error("Failed to read file")),r.readAsText(e)})}function p1(e){const t=e.name.toLowerCase();return e.type==="text/html"||t.endsWith(".html")||t.endsWith(".htm")}function ha(e){var r;if(!e)return!1;if(Array.from(e.types??[]).includes("Files")||e.files&&e.files.length>0)return!0;const n=e.items;if(n){for(let o=0;o<n.length;o++)if(((r=n[o])==null?void 0:r.kind)==="file")return!0}return!1}function g1(e){var r;const t=[],n=e.files;if(n)for(let o=0;o<n.length;o++){const a=((r=n.item)==null?void 0:r.call(n,o))??n[o];a&&t.push(a)}if(t.length===0&&e.items)for(let o=0;o<e.items.length;o++){const a=e.items[o];if((a==null?void 0:a.kind)!=="file")continue;const s=a.getAsFile();s&&t.push(s)}return t}function h1(e){return e?g1(e).find(p1)??null:null}const fg={description:"HTML",accept:{"text/html":[".html",".htm"]}},b1="document.html";function pg(){return window}function gg(e){return e instanceof DOMException&&e.name==="AbortError"}function y1(e,t){const n=new Blob([e],{type:"text/html;charset=utf-8"}),r=URL.createObjectURL(n),o=document.createElement("a");o.href=r,o.download=t,o.rel="noopener",document.body.append(o),o.click(),o.remove(),URL.revokeObjectURL(r)}function x1(){return new Promise(e=>{const t=document.createElement("input");t.type="file",t.accept=".html,.htm,text/html",t.hidden=!0;const n=r=>{t.remove(),e(r)};t.addEventListener("change",()=>{var o;const r=(o=t.files)==null?void 0:o[0];if(!r){n(null);return}hu(r).then(a=>n(dg(a)),()=>n(null))}),t.addEventListener("cancel",()=>n(null)),document.body.append(t),t.click()})}async function C1(e,t=b1){const n=pg().showSaveFilePicker;if(typeof n=="function"){try{const o=await(await n({suggestedName:t,types:[fg]})).createWritable();await o.write(e),await o.close()}catch(r){if(gg(r))return;throw r}return}y1(e,t)}async function w1(){const e=pg().showOpenFilePicker;if(typeof e=="function")try{const[t]=await e({multiple:!1,types:[fg]}),n=await t.getFile();return dg(await hu(n))}catch(t){if(gg(t))return null;throw t}return x1()}const v1=1e3;function k1(e){var t;return e.complete&&e.naturalWidth>0?Promise.resolve((t=e.decode)==null?void 0:t.call(e)).catch(()=>{}):new Promise(n=>{const r=()=>{var o;Promise.resolve((o=e.decode)==null?void 0:o.call(e)).catch(()=>{}).then(()=>n())};e.addEventListener("load",r,{once:!0}),e.addEventListener("error",r,{once:!0})})}function S1(e){const t=[...e.images];return t.length===0?Promise.resolve():Promise.all(t.map(k1)).then(()=>{})}function hg(){const e=document.createElement("iframe");e.setAttribute("aria-hidden","true"),e.setAttribute("data-wysiwyg-print",""),e.style.position="fixed",e.style.left="-9999px",e.style.top="0",e.style.width="1px",e.style.height="1px",e.style.border="0",document.body.append(e);const t=e.contentDocument,n=e.contentWindow;return!t||!n?(e.remove(),null):{iframe:e,doc:t,win:n}}async function bg(e,t,n,r){pc(e,r);let o=!1;const a=()=>{o||(o=!0,n.remove())};t.addEventListener("afterprint",a),await S1(e),t.focus(),t.print(),window.setTimeout(a,v1)}function A1(e){const t=hg();t&&bg(t.doc,t.win,t.iframe,e)}function P1(e){const t=hg();if(!t)return;const n=e.map(gu),r=n.some(g=>g.hasBleed),o=[],a=[];for(const g of n){const h=he(g.html);o.push(...h.hrefs),a.push(h.body)}const s=a.map((g,h)=>`<div data-wysiwyg-print-page="" style="${h===a.length-1?"display: block; break-inside: avoid; page-break-inside: avoid;":"display: block; break-after: page; page-break-after: always; break-inside: avoid; page-break-inside: avoid;"}">${g}</div>`).join(""),u=Fp(e),d=r?"@page { margin: 0 !important; }":"",f=[u?`<style>${u}</style>`:"",d?`<style>${d}</style>`:"",...Array.from(new Set(o)).map(g=>`<link rel="stylesheet" href="${g}" />`),s].filter(Boolean).join("");bg(t.doc,t.win,t.iframe,f)}function T1(e){return{save:async()=>{if(e.onSave){const t=e.isMultiPagesEnabled()?e.getAllPagesHtml():e.getHtml();await e.onSave(t);return}await C1(f1(e.getHtml()))},open:async()=>{const t=e.onOpen?await e.onOpen():await w1();if(t!==null){if(Array.isArray(t)){e.setHtml(Mt(t));return}if(e.isMultiPagesEnabled()){e.setHtml(Mt([t]));return}e.setHtml(t)}},print:()=>{if(e.isMultiPagesEnabled()){P1(Fn(e.getHtml()));return}A1(e.getHtml())}}}function R1(e){return{toggleBold:()=>{e.toggleFontMark("bold")},toggleItalic:()=>{e.toggleFontMark("italic")},toggleUnderline:()=>{e.toggleFontMark("underline")},toggleStrikethrough:()=>{e.toggleFontMark("strikethrough")},clearFormatting:()=>{e.clearFormatting()},toggleFormatBrush:()=>{e.toggleFormatBrush()},setFontSize:(t,n)=>{e.setFontSize(t,n)},setFontSizeUnit:t=>{e.setFontSizeUnit(t)},setFontFamily:t=>{e.setFontFamily(t)},setFontColor:t=>{e.setFontColor(t)},setHighlightColor:t=>{e.setHighlightColor(t)},setParagraphStyle:t=>{e.setParagraphStyle(t)},alignLeft:()=>{e.setTextAlign("left")},alignCenter:()=>{e.setTextAlign("center")},alignRight:()=>{e.setTextAlign("right")},alignJustify:()=>{e.setTextAlign("justify")},indent:()=>{e.indent()},outdent:()=>{e.outdent()},toggleBulletList:()=>{e.toggleList("ul")},toggleNumberedList:()=>{e.toggleList("ol")},openFontProperties:t=>{e.openFontProperties(t??"general")},applyFontProperties:t=>{e.applyFontProperties(t)},openParagraphProperties:t=>{e.openParagraphProperties(t??"general")},applyParagraphProperties:t=>{e.applyParagraphProperties(t)},openPageProperties:t=>{e.openPageProperties(t??"font")},applyPageProperties:t=>{e.applyPageProperties(t)},openCustomParagraphStyleDialog:t=>{e.openCustomParagraphStyleDialog(t)},applyCustomParagraphStyle:t=>{e.applyCustomParagraphStyle(t)},openCustomCss:()=>{e.openCustomCss()},applyCustomCss:t=>{e.applyCustomCss(t)}}}function D1(e){return{isBold:()=>e.isFontMarkActive("bold"),isItalic:()=>e.isFontMarkActive("italic"),isUnderline:()=>e.isFontMarkActive("underline"),isStrikethrough:()=>e.isFontMarkActive("strikethrough"),getFontSize:()=>e.getFontSize(),getFontSizeUnit:()=>e.getFontSizeUnit(),isFontSizeMixed:()=>e.isFontSizeMixed(),getFontFamily:()=>e.getFontFamily(),isFontFamilyMixed:()=>e.isFontFamilyMixed(),getFontFaces:()=>e.getFontFaces(),getFontColor:()=>e.getFontColor(),isFontColorMixed:()=>e.isFontColorMixed(),getHighlightColor:()=>e.getHighlightColor(),isHighlightColorMixed:()=>e.isHighlightColorMixed(),getParagraphStyle:()=>e.getParagraphStyle(),isParagraphStyleMixed:()=>e.isParagraphStyleMixed(),isAlignLeft:()=>e.getTextAlign()==="left"&&!e.isTextAlignMixed(),isAlignCenter:()=>e.getTextAlign()==="center"&&!e.isTextAlignMixed(),isAlignRight:()=>e.getTextAlign()==="right"&&!e.isTextAlignMixed(),isAlignJustify:()=>e.getTextAlign()==="justify"&&!e.isTextAlignMixed(),canOutdent:()=>e.canOutdent(),isBulletList:()=>e.isBulletList(),isNumberedList:()=>e.isNumberedList(),hasTextSelection:()=>e.hasTextSelection(),isFormatBrushActive:()=>e.isFormatBrushActive(),customParagraphStylesEnabled:()=>e.customParagraphStylesEnabled(),getCustomParagraphStyles:()=>e.getCustomParagraphStyles(),isCustomParagraphStylesLoading:()=>e.isCustomParagraphStylesLoading()}}function j1(e){return{undo:()=>{e.undo()},redo:()=>{e.redo()}}}function I1(e){return{canUndo:()=>e.canUndo(),canRedo:()=>e.canRedo()}}function E1(e){return{openLinkDialog:t=>{e.openLinkDialog(t)},applyLink:t=>{e.applyLink(t)},openBookmarkDialog:()=>{e.openBookmarkDialog()},applyBookmark:t=>{e.applyBookmark(t)},openImageDialog:()=>{e.openImageDialog()},openPageBackgroundImage:()=>{e.openPageBackgroundImage()},openParagraphBackgroundImage:()=>{e.openParagraphBackgroundImage()},applyImage:t=>{e.applyImage(t)},openAudioDialog:()=>{e.openAudioDialog()},applyAudio:t=>{e.applyAudio(t)},openYoutubeDialog:()=>{e.openYoutubeDialog()},applyYoutube:t=>{e.applyYoutube(t)},openImageProperties:t=>{e.openImageProperties(t)},applyImageProperties:t=>{e.applyImageProperties(t)},insertHorizontalRule:()=>{e.insertHorizontalRule()},insertPageBreak:()=>{e.insertPageBreak()},insertPageBefore:()=>{e.insertPageBefore()},insertPageAfter:()=>{e.insertPageAfter()},deletePage:()=>{e.deletePage()}}}function _1(e){return{isLink:()=>e.isLink(),isImageSelected:()=>e.isImageSelected(),isMultiPagesEnabled:()=>e.isMultiPagesEnabled(),hasSelectedPage:()=>e.hasSelectedPage(),canDeletePage:()=>e.canDeletePage(),canInsertPageBackgroundImage:()=>e.canInsertPageBackgroundImage(),canInsertParagraphBackgroundImage:()=>e.canInsertParagraphBackgroundImage()}}function M1(e){return{openTableDialog:()=>{e.openTableDialog()},applyTable:t=>{e.applyTable(t)},openTableProperties:()=>{e.openTableProperties()},applyTableProperties:t=>{e.applyTableProperties(t)},openCellProperties:()=>{e.openCellProperties()},applyCellProperties:t=>{e.applyCellProperties(t)},openRowProperties:()=>{e.openRowProperties()},applyRowProperties:t=>{e.applyRowProperties(t)},insertRowBelow:()=>{e.insertRowBelow()},insertRowBefore:()=>{e.insertRowBefore()},deleteRow:()=>{e.deleteRow()},insertColumnAfter:()=>{e.insertColumnAfter()},insertColumnBefore:()=>{e.insertColumnBefore()},deleteColumn:()=>{e.deleteColumn()},mergeCells:()=>{e.mergeCells()},unmergeCells:()=>{e.unmergeCells()}}}function N1(e){return{isInTable:()=>e.isInTable(),canMergeCells:()=>e.canMergeCells(),canUnmergeCells:()=>e.canUnmergeCells()}}function L1(e){return{openHelp:()=>{e.openHelp()},openKeyboardShortcuts:()=>{e.openKeyboardShortcuts()},openAbout:()=>{e.openAbout()}}}const B1=[50,75,100,125,150,200],F1=.1,H1=3;function Ol(e){return!Number.isFinite(e)||e<=0?1:Math.min(H1,Math.max(F1,e))}function z1(e,t,n,r,o){if(e==="fitWidth")return r<=0?1:Ol(t/r);if(e==="fitPage"){if(r<=0||o<=0)return 1;const a=t/r,s=n/o;return Ol(Math.min(a,s))}return Ol(e/100)}function O1(e){let t=null;return{schedule(){t===null&&(t=window.requestAnimationFrame(()=>{t=null,e()}))},cancel(){t!==null&&(window.cancelAnimationFrame(t),t=null)}}}function In(e,t){return()=>{e.setPageZoom(t)}}function En(e,t){return()=>e.getPageZoom()===t}function K1(e){return{setVisualMode:()=>{e.setMode("visual")},setHtmlMode:()=>{e.setMode("html")},toggleFullscreen:()=>{e.setFullscreen(!e.getFullscreen())},openCustomizeToolbar:()=>{e.openCustomizeToolbar()},openDocumentPreview:()=>{e.openDocumentPreview()},toggleReadAloud:()=>{e.toggleReadAloud()},toggleRuler:()=>{e.toggleRuler()},setLightMode:()=>{e.setDarkMode(!1)},setDarkMode:()=>{e.setDarkMode(!0)},setPageZoomFitWidth:In(e,"fitWidth"),setPageZoomFitPage:In(e,"fitPage"),setPageZoom50:In(e,50),setPageZoom75:In(e,75),setPageZoom100:In(e,100),setPageZoom125:In(e,125),setPageZoom150:In(e,150),setPageZoom200:In(e,200),setToolbarPositionTop:()=>{e.setToolbarPosition("top")},setToolbarPositionLeft:()=>{e.setToolbarPosition("left")},setToolbarPositionRight:()=>{e.setToolbarPosition("right")},setToolbarPositionBottom:()=>{e.setToolbarPosition("bottom")}}}function $1(e){return{isVisualMode:()=>e.getMode()==="visual",isHtmlMode:()=>e.getMode()==="html",isFullscreen:()=>e.getFullscreen(),isLightMode:()=>!e.getDarkMode(),isDarkMode:()=>e.getDarkMode(),isPageZoomFitWidth:En(e,"fitWidth"),isPageZoomFitPage:En(e,"fitPage"),isPageZoom50:En(e,50),isPageZoom75:En(e,75),isPageZoom100:En(e,100),isPageZoom125:En(e,125),isPageZoom150:En(e,150),isPageZoom200:En(e,200),isToolbarPositionTop:()=>e.getToolbarPosition()==="top",isToolbarPositionLeft:()=>e.getToolbarPosition()==="left",isToolbarPositionRight:()=>e.getToolbarPosition()==="right",isToolbarPositionBottom:()=>e.getToolbarPosition()==="bottom",isReadingAloud:()=>e.isReadingAloud(),isRulerVisible:()=>e.isRulerVisible(),canReadAloud:()=>e.canReadAloud()}}function U1(e){return{addComment:()=>e.addComment(),toggleCommentsVisible:()=>e.toggleCommentsVisible()}}function V1(e){return{canAddComment:()=>e.canAddComment(),areCommentsVisible:()=>e.areCommentsVisible(),isCommentsEnabled:()=>e.isCommentsEnabled()}}function W1(e){return{...T1(e),...j1(e),...Hy(e),...E1(e),...M1(e),...K1(e),...R1(e),...U1(e),...L1(e)}}function G1(e){return{...$1(e),...I1(e),..._1(e),...N1(e),...D1(e),...V1(e)}}function za(e){return e.nodeType===Node.TEXT_NODE?e.parentElement:e instanceof Element?e:e.parentElement}function Z1(e){const t=e.style.fontSize;if(!t)return null;const n=Wc(t);return!n||!is(n.unit)?null:{value:n.value,unit:n.unit}}function yg(e,t){let n=za(t);for(;n&&n!==e&&n instanceof HTMLElement;){const r=Z1(n);if(r)return r;n=n.parentElement}return null}function q1(e,t){const n=za(e)??t,r=parseFloat(getComputedStyle(n).fontSize);return Number.isFinite(r)&&r>0?r:16}function xg(e,t){var a;let n=za(t);for(;n&&n!==e;){if(n.style.fontSize){const u=n.parentElement??e,d=parseFloat(getComputedStyle(u).fontSize);return Number.isFinite(d)&&d>0?d:16}n=n.parentElement}const r=((a=za(t))==null?void 0:a.parentElement)??e,o=parseFloat(getComputedStyle(r).fontSize);return Number.isFinite(o)&&o>0?o:16}function Cg(e){const t=parseFloat(getComputedStyle(e).fontSize);return Number.isFinite(t)&&t>0?t:16}function Y1(e,t){return e===t?!0:!e||!t?!1:e.value===t.value&&e.unit===t.unit}function Zm(e=Xr){return{value:null,unit:e,mixed:!1}}function wg(e,t=Xr){const n=window.getSelection();if(!n||n.rangeCount===0)return Zm(t);const r=n.getRangeAt(0);if(!ke(e,r.commonAncestorContainer))return Zm(t);const o=r.collapsed?[]:Pt(r).filter(f=>f.data.length>0),a=o.length>0?o:[r.startContainer],s=a.map(f=>yg(e,f)),u=s[0];if(s.every(f=>Y1(f,u))&&u)return{value:u.value,unit:u.unit,mixed:!1};if(s.every(f=>f===null)){const f=a.map(h=>q1(h,e)),g=f[0];if(f.every(h=>Math.abs(h-g)<.05)){const h=xg(e,a[0]),C=Cg(e);return{value:ip(g,t,h,C),unit:t,mixed:!1}}return{value:null,unit:t,mixed:!0}}return{value:null,unit:t,mixed:!0}}function X1(e,t){return{parentPx:xg(e,t),rootPx:Cg(e)}}function J1(e){const t=window.getSelection();if(!t||t.rangeCount===0)return null;const n=t.getRangeAt(0);return ke(e,n.commonAncestorContainer)?n:null}function gc(e,t,n){const r=pr(t,n);if(!r)return!1;const o=J1(e);if(!o||o.collapsed)return!1;const a=Vc(r.value,r.unit);un(o);const s=Pt(o).filter(u=>u.data.length>0);for(const u of s){const d=yg(e,u);d&&d.value===r.value&&d.unit===r.unit||ti(u,f=>{f.style.fontSize=a})}return yr(s),!0}function Q1(e,t){e.style.fontSize=Vc(t.value,t.unit)}function ev(e){return e.nodeType===Node.TEXT_NODE?e.parentElement:e instanceof Element?e:e.parentElement}function tv(e){return e.trim().toLowerCase()}function hc(e){const t={};for(const n of e.split(";")){const r=n.trim();if(!r)continue;const o=r.indexOf(":");if(o<=0)continue;const a=tv(r.slice(0,o)),s=r.slice(o+1).trim();a&&(t[a]=s)}return t}function vg(e){return Object.entries(e).filter(([t])=>t.trim()).map(([t,n])=>`${t}: ${n}`).join("; ")}function nv(e,t){const n={...e};for(const[r,o]of Object.entries(t))o.trim()?n[r]=o:delete n[r];return n}function rv(e){const t=e.trim();if(!t)return"";const n=t.split(";").map(r=>r.trim()).filter(Boolean);return n.length===0?"":n.map(r=>`${r};`).join(`
318
- `)}function ms(e){const t=hc(e);return vg(t)}function ov(e,t){let n=ev(t);for(;n&&n!==e&&n instanceof HTMLElement;){const r=n.style.cssText.trim();if(r)return r;n=n.parentElement}return""}function kg(e){const t=fn(e);if(!t)return{value:null,mixed:!1};const n=t.collapsed?[]:Pt(t).filter(d=>d.data.length>0),a=(n.length>0?n:[t.startContainer]).map(d=>ov(e,d)).map(d=>d.trim()),s=a[0]??"";return a.every(d=>d===s)?{value:s||null,mixed:!1}:{value:null,mixed:!0}}function Sg(e,t){const n=hc(e.style.cssText),r=hc(t),o=nv(n,r),a=vg(o);a?e.style.cssText=a:e.removeAttribute("style")}function Ag(e,t){const n=ms(t);if(!n)return!1;const r=fn(e);if(!r||r.collapsed)return!1;un(r);const o=Pt(r).filter(a=>a.data.length>0);if(o.length===0)return!1;for(const a of o)ti(a,s=>{Sg(s,n),Gn(s)&&Nt(s)});return yr(o),!0}function iv(e,t){const n=ms(t);n&&Sg(e,n)}function av(e){return!!(e&&ms(e))}const Kt=["bold","italic","underline","strikethrough"],Vr={bold:new Set(["strong","b"]),italic:new Set(["em","i"]),underline:new Set(["u"]),strikethrough:new Set(["s","strike","del"])},sv=new Set(["underline","line-through","overline"]);function zn(){return{bold:!1,italic:!1,underline:!1,strikethrough:!1}}function lv(e,t){return Kt.every(n=>e[n]===t[n])}function cv(e){return Kt.some(t=>e[t]!==void 0)}function Pg(e,t){const n={...e};if(!t)return n;for(const r of Kt){const o=t[r];o!==void 0&&(n[r]=o)}return n}function uv(e,t,n){const r=e[n]??t[n],o={...e,[n]:!r};return o[n]===t[n]&&delete o[n],o}function Un(e){return(e.style.textDecorationLine||e.style.textDecoration).split(/\s+/).filter(n=>sv.has(n))}function oo(e,t){if(t.length===0){e.style.textDecorationLine="",e.style.removeProperty("text-decoration-line"),e.style.textDecoration&&(e.style.textDecoration="",e.style.removeProperty("text-decoration"));return}e.style.textDecorationLine=t.join(" ")}function Tg(e,t){const n=e,r=e.tagName.toLowerCase();if(t==="bold"){if(Vr.bold.has(r))return!0;const s=n.style.fontWeight;if(!s)return null;if(s==="bold"||s==="bolder")return!0;const u=Number(s);return Number.isNaN(u)?s==="normal"||s==="lighter"?!1:null:u>=700}if(t==="italic"){if(Vr.italic.has(r))return!0;const s=n.style.fontStyle;return s?s==="italic"||s==="oblique"?!0:s==="normal"?!1:null:null}if(t==="underline"){if(Vr.underline.has(r))return!0;const s=n.style.textDecorationLine||n.style.textDecoration;if(!s)return null;if(s==="none")return!1;const u=Un(n);return u.includes("underline")?!0:u.length>0?!1:null}if(Vr.strikethrough.has(r))return!0;const o=n.style.textDecorationLine||n.style.textDecoration;if(!o)return null;if(o==="none")return!1;const a=Un(n);return a.includes("line-through")?!0:a.length>0?!1:null}function Oa(e,t){return Tg(e,t)===!0}function io(e,t,n){let r=t.nodeType===Node.TEXT_NODE?t.parentElement:t;for(;r&&r!==e&&r instanceof Element;){const o=Tg(r,n);if(o!==null)return o;r=r.parentElement}return!1}function Rg(e,t){if(t==="bold"){e.style.fontWeight="700";return}if(t==="italic"){e.style.fontStyle="italic";return}if(t==="underline"){const r=Un(e);r.includes("underline")||r.push("underline"),oo(e,r);return}const n=Un(e);n.includes("line-through")||n.push("line-through"),oo(e,n)}function Dg(e,t){if(t==="bold"){e.style.fontWeight="",e.style.removeProperty("font-weight");return}if(t==="italic"){e.style.fontStyle="",e.style.removeProperty("font-style");return}if(t==="underline"){oo(e,Un(e).filter(n=>n!=="underline"));return}oo(e,Un(e).filter(n=>n!=="line-through"))}function dv(e,t){if(t==="bold"){e.style.fontWeight="400";return}if(t==="italic"){e.style.fontStyle="normal";return}if(t==="underline"){const r=Un(e).filter(o=>o!=="underline");if(r.length===0){e.style.textDecorationLine="none";return}oo(e,r);return}const n=Un(e).filter(r=>r!=="line-through");if(n.length===0){e.style.textDecorationLine="none";return}oo(e,n)}function mv(e,t){ti(e,n=>Rg(n,t))}function fv(e,t,n){let r=t;for(;r.parentElement&&r.parentElement!==e;){const o=r.parentElement;if(!mn(o)||!Oa(o,n)){r=o;continue}if(Zn(o,r),Oa(o,n)){if(Vr[n].has(o.tagName.toLowerCase())){Nt(o);continue}if(Dg(o,n),Gn(o)){Nt(o);continue}}r=o}}function pv(e,t,n){const r=Pt(t).filter(o=>o.data.length>0);return r.length===0?io(e,t.startContainer,n):r.every(o=>io(e,o,n))}function gv(e,t,n,r){un(t);const o=Pt(t).filter(a=>a.data.length>0);for(const a of o)r?io(e,a,n)||mv(a,n):fv(e,a,n);yr(o)}function Wr(e){const t=window.getSelection();if(!t||t.rangeCount===0)return zn();const n=t.getRangeAt(0);if(!ke(e,n.commonAncestorContainer))return zn();if(n.collapsed)return bc(e,n);const r=Pt(n).filter(a=>a.data.length>0);if(r.length===0)return bc(e,n);const o=zn();for(const a of Kt)o[a]=io(e,r[0],a);for(let a=1;a<r.length;a+=1)for(const s of Kt)o[s]=o[s]&&io(e,r[a],s);return o}function bc(e,t){const n=zn();for(const r of Kt)n[r]=io(e,t.startContainer,r);return n}function yc(e,t){const n=window.getSelection();if(!n||n.rangeCount===0)return!1;const r=n.getRangeAt(0);if(!ke(e,r.commonAncestorContainer)||r.collapsed)return!1;const o=pv(e,r,t);return gv(e,r,t,!o),!0}function hv(e){const t=e.startContainer,n=e.startOffset;if(t.nodeType!==Node.TEXT_NODE)return;const r=t;if(n<=0||n>=r.length)return;const o=r.splitText(n);e.setStart(o,0),e.collapse(!0)}function bv(e,t,n){var a,s,u;hv(t);let r=t.startContainer.nodeType===Node.TEXT_NODE&&t.startOffset===0?t.startContainer:t.startContainer.childNodes[t.startOffset]??t.startContainer.lastChild??t.startContainer;if(t.startContainer.nodeType===Node.TEXT_NODE&&t.startOffset>0){const d=document.createTextNode("");(a=t.startContainer.parentNode)==null||a.insertBefore(d,t.startContainer.nextSibling),r=d}else if(t.startContainer.nodeType===Node.TEXT_NODE&&t.startOffset===0){const d=document.createTextNode("");(s=t.startContainer.parentNode)==null||s.insertBefore(d,t.startContainer),r=d}else{const d=document.createTextNode("");r&&r!==t.startContainer?(u=r.parentNode)==null||u.insertBefore(d,r):t.startContainer.appendChild(d),r=d}let o=r;for(;o.parentElement&&o.parentElement!==e;){const d=o.parentElement;if(!mn(d)){o=d;continue}if(!n.some(g=>Oa(d,g))){o=d;continue}Zn(d,o);for(const g of n)if(Oa(d,g)){if(Vr[g].has(d.tagName.toLowerCase())){Nt(d);break}if(Dg(d,g),Gn(d)){Nt(d);break}}o=d.isConnected?d:r}return r}function yv(e,t,n){for(const r of Kt)n[r]!==t[r]&&(n[r]?Rg(e,r):dv(e,r))}function xv(e,t,n,r,o,a,s){var S,P;const u=window.getSelection();if(!u||u.rangeCount===0)return;const d=u.getRangeAt(0);if(!ke(e,d.commonAncestorContainer))return;const f=bc(e,d),g=Pg(f,n),h=Kt.filter(R=>f[R]&&!g[R]),C=Gx(e,d.startContainer,o),b=Cx(e,d.startContainer,a);let x=null;h.length>0?(x=bv(e,d,h),C.length>0&&fp(e,x,C),b&&rc(e,x)):C.length>0?(x=Wx(e,d,C),b&&rc(e,x)):b?x=xx(e,d):d.deleteContents();const y=document.createElement("span");yv(y,f,g),r&&Q1(y,r),o!=null&&o.color&&Tm(y,"color",o.color),o!=null&&o.backgroundColor&&Tm(y,"backgroundColor",o.backgroundColor),a&&gx(y,a),s&&iv(y,s),y.textContent=t;const v=y.style.cssText.trim()?y:document.createTextNode(t);x?((S=x.parentNode)==null||S.insertBefore(v,x),x.nodeType===Node.TEXT_NODE&&!x.data&&((P=x.parentNode)==null||P.removeChild(x))):d.insertNode(v);const k=document.createRange();k.selectNodeContents(v),k.collapse(!1),u.removeAllRanges(),u.addRange(k)}const Ka=["p","h1","h2","h3","h4","h5","h6"],Cv=new Set(Ka),jg=new Set([...Ka,"div"]),fs=new Set(["li","ul","ol","td","th","tr","thead","tbody","table","blockquote","pre"]),wv=()=>({tag:null,mixed:!1});function Ig(e){return Cv.has(e)}function vv(e){return Ig(e)?e:e==="div"?"p":null}function kv(e){return e instanceof Element&&fs.has(Me(e))}function Eg(e){return e instanceof HTMLElement&&!Tt(e)&&jg.has(Me(e))}function xc(e){if(e.nodeType===Node.TEXT_NODE||e.nodeType===Node.COMMENT_NODE||!(e instanceof Element))return!0;const t=Me(e);return jg.has(t)||fs.has(t)?!1:mn(e)||t==="br"||t==="a"||t==="img"||t==="span"}function Sv(e,t){let n=ri(t);for(;n&&n!==e;){if(fs.has(Me(n)))return!0;n=n.parentElement}return!1}function _g(e,t){let n=ri(t);for(;n&&n!==e;){if(Gp(n,e)){n=n.parentElement;continue}if(Eg(n))return n;if(fs.has(Me(n)))return null;n=n.parentElement}return null}function Av(e,t){const n=new Set,r=[];for(const o of Jc(t)){const a=_g(e,o);a&&!n.has(a)&&(n.add(a),r.push(a))}return r}function Pv(e,t){let n=t;for(;n&&n.parentNode!==e;)n=n.parentNode;return n&&n.parentNode===e?n:null}function Tv(e,t){const n=[...e.childNodes],r=n.indexOf(t);if(r<0)return[t];let o=r,a=r;for(;o>0&&xc(n[o-1]);)o-=1;for(;a<n.length-1&&xc(n[a+1]);)a+=1;return n.slice(o,a+1)}function Cc(e){for(const t of e.childNodes)if(!(t instanceof HTMLElement&&Tt(t)))return t;return null}function Rv(e,t,n){if(n.startContainer===e){const r=e.childNodes[Math.min(n.startOffset,Math.max(0,e.childNodes.length-1))]??e.firstChild;return r instanceof HTMLElement&&Tt(r)?Cc(e):r}return n.startContainer===t&&e!==t?Cc(e):Pv(e,n.startContainer)}function Dv(e,t,n){const r=uu(e);if(Sv(e,t.startContainer))return!1;if(!Cc(r)){const u=document.createElement(n);return u.appendChild(document.createElement("br")),r.appendChild(u),!0}const o=Rv(r,e,t);if(!o||o instanceof HTMLElement&&Tt(o)||kv(o)||Eg(o)||!xc(o))return!1;const a=Tv(r,o),s=document.createElement(n);r.insertBefore(s,a[0]);for(const u of a)s.appendChild(u);return!0}function jv(e){const t=fn(e);if(!t)return wv();const n=Jc(t).map(o=>{const a=_g(e,o);return a?vv(Me(a)):null}),r=n[0];return n.every(o=>o===r)?{tag:r??null,mixed:!1}:{tag:null,mixed:!0}}function Iv(e,t){if(!Ig(t))return!1;const n=fn(e);if(!n)return!1;const r=Jr(e,n.startContainer,n.startOffset),o=Jr(e,n.endContainer,n.endOffset),a=Math.min(r,o),s=Math.max(r,o),u=Av(e,n);let d=!1;if(u.length===0)d=Dv(e,n,t);else for(const f of u)Me(f)!==t&&(eu(f,t),d=!0);return Qc(e,a,s),d}function bu(e){if(!Ot(e))return null;const t=Qr(e);if(!t)return null;const n=Me(t);return n==="ul"||n==="ol"?n:null}function Mg(e){const t=An(e);if(t.length===0)return{type:null,mixed:!1};const n=t.map(bu),r=n[0];return n.every(o=>o===r)?{type:r,mixed:!1}:{type:null,mixed:!0}}function Ev(e,t,n){const r=[...e.children].filter(o=>Xc(o));for(const o of r)t.insertBefore(o,n)}function Ng(e){const t=Qr(e),n=document.createElement("p");for(const f of[...e.attributes])n.setAttribute(f.name,f.value);for(n.style.marginLeft="",kt(n);e.firstChild&&!Xc(e.firstChild);)n.appendChild(e.firstChild);const r=[];let o=e.nextElementSibling;for(;o;)r.push(o),o=o.nextElementSibling;const a=(t==null?void 0:t.parentNode)??e.parentNode;if(!t||!a)return e.replaceWith(n),n;const s=Ot(a)?a.parentNode??a:a,u=Ot(a)?a.nextSibling:t.nextSibling;e.remove();let d=null;if(r.length>0){d=document.createElement(t.tagName);for(const f of r)d.appendChild(f)}return s.insertBefore(n,u),d&&s.insertBefore(d,n.nextSibling),Ev(e,s,n.nextSibling),t.childElementCount===0&&t.remove(),n}function _v(e){if(Ot(e))return e;const t=eu(e,"li");return t.style.marginLeft="",kt(t),t}function Lg(e,t){if(e.length===0)return!1;if(e.every(Ot)){const a=Qr(e[0]);if(a&&e.every(s=>s.parentElement===a)&&[...a.children].every(u=>u instanceof HTMLElement&&e.includes(u)))return Me(a)===t?!1:(eu(a,t),!0)}const n=e[0],r=n.parentNode;if(!r)return!1;const o=document.createElement(t);r.insertBefore(o,n);for(const a of e){const s=Ot(a)?Qr(a):null;o.appendChild(_v(a)),s&&s!==o&&s.childElementCount===0&&s.remove()}return!0}function Bg(e){let t=!1;for(const n of[...e].reverse())Ot(n)&&(Ng(n),t=!0);return t}function Mv(e,t){return Yn(e,()=>{const n=xr(e);if(n.length===0)return!1;if(n.every(a=>bu(a)===t))return Bg(n);let o=!1;for(const a of cp(n))Lg(a,t)&&(o=!0);return o})}function Nv(e,t){return Yn(e,()=>{const n=xr(e);if(n.length===0)return!1;if(t===null)return Bg(n);if(n.every(a=>bu(a)===t))return!1;let o=!1;for(const a of cp(n))Lg(a,t)&&(o=!0);return o})}const Fg=40;function yu(e){const t=e.style.marginLeft;if(!t)return 0;const n=Number.parseFloat(t);return Number.isFinite(n)?n:0}function Hg(e,t){if(t<=0){e.style.marginLeft="",kt(e);return}e.style.marginLeft=`${t}px`}function Lv(e){let t=e.previousElementSibling;for(;t;){if(Ot(t))return t;t=t.previousElementSibling}return null}function Bv(e){for(let t=e.children.length-1;t>=0;t-=1){const n=e.children[t];if(n instanceof HTMLElement&&(Me(n)==="ul"||Me(n)==="ol"))return n}return null}function Fv(e){const t=Lv(e);if(!t)return!1;const n=Qr(e);if(!n)return!1;const r=Me(n)==="ol"?"ol":"ul";let o=Bv(t);return(!o||Me(o)!==r)&&(o=document.createElement(r),t.appendChild(o)),o.appendChild(e),!0}function Hv(e){const t=Qr(e);if(!t)return!1;const n=t.parentElement;if(n&&Ot(n)){const r=n.parentElement;return r?(r.insertBefore(e,n.nextSibling),t.childElementCount===0&&t.remove(),!0):!1}return Ng(e),!0}function zv(e){return An(e).some(n=>Ot(n)||yu(n)>0)}function Ov(e){return Yn(e,()=>{const t=xr(e);if(t.length===0)return!1;let n=!1;for(const r of t){if(Ot(r)){Fv(r)&&(n=!0);continue}Hg(r,yu(r)+Fg),n=!0}return n})}function Kv(e){return Yn(e,()=>{const t=An(e);if(t.length===0)return!1;let n=!1;for(const r of[...t].reverse()){if(Ot(r)){Hv(r)&&(n=!0);continue}const o=yu(r);o<=0||(Hg(r,Math.max(0,o-Fg)),n=!0)}return n})}function ps(e){return{colSpan:Math.max(1,e.colSpan||1),rowSpan:Math.max(1,e.rowSpan||1)}}function br(e,t,n){const r=Math.max(1,Math.floor(t)),o=Math.max(1,Math.floor(n));r<=1?e.removeAttribute("colspan"):e.colSpan=r,o<=1?e.removeAttribute("rowspan"):e.rowSpan=o}function Lt(e){const t=e.rows.length,n=Array.from({length:t},()=>[]),r=[];let o=0;for(let a=0;a<t;a+=1){const s=e.rows[a];let u=0;for(const d of Array.from(s.cells)){for(;n[a][u];)u+=1;const f=ps(d),g={cell:d,originRow:a,originCol:u,rowSpan:f.rowSpan,colSpan:f.colSpan};r.push(g);for(let h=0;h<f.rowSpan;h+=1){const C=a+h;if(C>=t)break;for(let b=0;b<f.colSpan;b+=1)n[C][u+b]=g}u+=f.colSpan,o=Math.max(o,u)}o=Math.max(o,n[a].length)}return{table:e,slots:n,unique:r,rowCount:t,colCount:o}}function $a(e,t,n){var r;return((r=e.slots[t])==null?void 0:r[n])??null}function Jt(e,t){return e.unique.find(n=>n.cell===t)??null}function zg(e,t){return e.originRow<t.minRow||e.originCol<t.minCol||e.originRow+e.rowSpan-1>t.maxRow||e.originCol+e.colSpan-1>t.maxCol}function Og(e){if(e.length===0)return null;let t=1/0,n=-1/0,r=1/0,o=-1/0;for(const a of e)t=Math.min(t,a.originRow),n=Math.max(n,a.originRow+a.rowSpan-1),r=Math.min(r,a.originCol),o=Math.max(o,a.originCol+a.colSpan-1);return{minRow:t,maxRow:n,minCol:r,maxCol:o}}function $v(e,t){const n=new Set,r=[];for(let o=t.minRow;o<=t.maxRow;o+=1)for(let a=t.minCol;a<=t.maxCol;a+=1){const s=$a(e,o,a);!s||n.has(s.cell)||(n.add(s.cell),r.push(s.cell))}return r}function Kg(e,t){if(t.minRow>t.maxRow||t.minCol>t.maxCol)return null;const n=$a(e,t.minRow,t.minCol);if(!n||n.originRow!==t.minRow||n.originCol!==t.minCol)return null;const r=new Set,o=[];for(let a=t.minRow;a<=t.maxRow;a+=1)for(let s=t.minCol;s<=t.maxCol;s+=1){const u=$a(e,a,s);if(!u||zg(u,t))return null;r.has(u.cell)||(r.add(u.cell),o.push(u.cell))}return{origin:n,cells:o,colSpan:t.maxCol-t.minCol+1,rowSpan:t.maxRow-t.minRow+1}}function Uv(e,t,n,r){const o={minRow:t.originRow,maxRow:t.originRow+r-1,minCol:t.originCol,maxCol:t.originCol+n-1};if(o.maxRow>=e.rowCount||o.maxCol>=e.colCount)return!1;for(let a=o.minRow;a<=o.maxRow;a+=1)for(let s=o.minCol;s<=o.maxCol;s+=1){const u=$a(e,a,s);if(!u)return!1;if(u.cell!==t.cell&&zg(u,o))return!1}return!0}const qm=10,Gr=1,Zr=50,Vv="1px solid #000",Wv="0.25em",Gv=new Set(["td","th"]);function $g(e,t){return Number.isInteger(e)&&Number.isInteger(t)&&e>=Gr&&t>=Gr&&e<=Zr&&t<=Zr}function At(e,t){return Cu(e,t,n=>n instanceof HTMLTableElement)}function Ua(e,t){return Cu(e,t,n=>ok(n))}function Zv(e,t){return Cu(e,t,n=>n instanceof HTMLTableRowElement)}function xu(e){return At(e,wu(e))}function pn(e){return Ua(e,wu(e))}function Ug(e){return Zv(e,wu(e))}function qv(e){const t=[];for(const n of Array.from(e.rows))t.push(...Array.from(n.cells));return t}function ii(e){const t=window.getSelection();if(!t||t.rangeCount===0)return[];const n=t.getRangeAt(0);if(!ke(e,n.commonAncestorContainer))return[];const r=Ua(e,n.startContainer),o=Ua(e,n.endContainer);if(!r)return[];if(!o||r===o)return[r];const a=At(e,r);if(!a||At(e,o)!==a)return[r];const s=Lt(a),u=Jt(s,r),d=Jt(s,o);if(!u||!d)return[r];const f=Og([u,d]);if(!f)return[r];const g=$v(s,f);return g.length>0?g:[r]}function Yv(e,t){if(!$g(t.rows,t.cols))return!1;const n=window.getSelection();if(!n||n.rangeCount===0)return!1;const r=n.getRangeAt(0);if(!ke(e,r.commonAncestorContainer))return!1;const o=document.createElement("table");o.style.borderCollapse="collapse",o.style.width="100%";const a=document.createElement("tbody");for(let u=0;u<t.rows;u+=1){const d=document.createElement("tr");for(let f=0;f<t.cols;f+=1)d.appendChild(ik("td"));a.appendChild(d)}o.appendChild(a),r.collapsed||r.deleteContents(),r.insertNode(o),ck(e,o);const s=o.querySelector("td, th");return s instanceof HTMLTableCellElement&&St(s),!0}function wc(e,t){var h,C,b,x;const n=pn(e);if(!n)return!1;const r=At(e,n);if(!r)return!1;const o=Lt(r),a=Jt(o,n);if(!a)return!1;const s=t==="before"?a.originRow:a.originRow+a.rowSpan,u=new Set;for(const y of o.unique)if(y.originRow<s&&y.originRow+y.rowSpan>s){br(y.cell,y.colSpan,y.rowSpan+1);for(let v=y.originCol;v<y.originCol+y.colSpan;v+=1)u.add(v)}const d=document.createElement("tr"),f=Math.min(s,o.rowCount-1);for(let y=0;y<o.colCount;y+=1){if(u.has(y))continue;const v=((C=(h=o.slots[f])==null?void 0:h[y])==null?void 0:C.cell)??n;d.appendChild(vu(v))}if(s>=r.rows.length)(b=r.rows[r.rows.length-1].parentNode)==null||b.appendChild(d);else{const y=r.rows[s];(x=y.parentNode)==null||x.insertBefore(d,y)}const g=sk(d,o.colCount,u,a.originCol);return St(g||n),!0}function Ym(e,t){var f,g,h,C;const n=pn(e);if(!n)return!1;const r=At(e,n);if(!r)return!1;const o=Lt(r),a=Jt(o,n);if(!a)return!1;const s=t==="before"?a.originCol:a.originCol+a.colSpan,u=new Set;for(const b of o.unique)if(b.originCol<s&&b.originCol+b.colSpan>s){br(b.cell,b.colSpan+1,b.rowSpan);for(let x=b.originRow;x<b.originRow+b.rowSpan;x+=1)u.add(x)}let d=null;for(let b=0;b<o.rowCount;b+=1){if(u.has(b))continue;const x=((g=(f=o.slots[b])==null?void 0:f[Math.min(s,Math.max(0,o.colCount-1))])==null?void 0:g.cell)??((C=(h=o.slots[b])==null?void 0:h[Math.max(0,s-1)])==null?void 0:C.cell)??n,y=vu(x);ku(r,b,s,y),b===a.originRow&&(d=y)}return d&&St(d),!0}function Xv(e){var C,b;const t=pn(e);if(!t)return!1;const n=At(e,t);if(!n)return!1;const r=Lt(n),o=Jt(r,t);if(!o)return!1;if(r.rowCount<=1)return vc(e,n);const a=o.originRow,s=a+1,u=[];for(const x of r.unique)x.originRow<=a&&x.originRow+x.rowSpan>a&&(x.originRow<a?br(x.cell,x.colSpan,x.rowSpan-1):x.originRow===a&&x.rowSpan>1&&u.push(x));u.sort((x,y)=>x.originCol-y.originCol);for(const x of u)br(x.cell,x.colSpan,x.rowSpan-1),ku(n,s,x.originCol,x.cell);const d=o.originCol;n.rows[a].remove();const f=n.rows[Math.min(a,n.rows.length-1)],g=Lt(n),h=(b=(C=g.slots[Math.min(a,g.rowCount-1)])==null?void 0:C[Math.min(d,Math.max(0,g.colCount-1))])==null?void 0:b.cell;return h?St(h):f!=null&&f.cells[0]?St(f.cells[0]):dk(n),!0}function Jv(e){var f,g,h;const t=pn(e);if(!t)return!1;const n=At(e,t);if(!n)return!1;const r=Lt(n),o=Jt(r,t);if(!o)return!1;if(r.colCount<=1)return vc(e,n);const a=o.originCol,s=o.originRow;for(const C of r.unique)a<C.originCol||a>=C.originCol+C.colSpan||(C.colSpan===1?C.cell.remove():br(C.cell,C.colSpan-1,C.rowSpan));const u=Lt(n);if(u.colCount===0||u.unique.length===0)return vc(e,n);const d=((g=(f=u.slots[Math.min(s,u.rowCount-1)])==null?void 0:f[Math.min(a,u.colCount-1)])==null?void 0:g.cell)??((h=u.unique[0])==null?void 0:h.cell);return d&&St(d),!0}function Qv(e,t){const n=pn(e);if(!n)return!1;const r=At(e,n);if(!r)return!1;const o=qv(r),a=o.indexOf(n);if(a<0)return!1;if(t)return a===0?!1:(St(o[a-1]),{changed:!1});if(a<o.length-1)return St(o[a+1]),{changed:!1};const s=n.parentElement;if(!wc(e,"below"))return!1;const u=s instanceof HTMLTableRowElement?s.nextElementSibling:null;return u instanceof HTMLTableRowElement&&u.cells[0]&&St(u.cells[0]),{changed:!0}}function ek(e,t){return!ke(e,t)||t===e?!1:(St(t),!0)}function Xm(e){return Vg(e)!==null}function Jm(e){const t=pn(e);if(!t)return!1;const n=ps(t);return n.colSpan>1||n.rowSpan>1}function tk(e){const t=Vg(e);if(!t)return!1;const n=At(e,t.origin.cell);return n?Wg(n,t):!1}function nk(e){const t=pn(e);if(!t)return!1;const n=At(e,t);return n?Gg(n,t):!1}function rk(e,t,n){const r=pn(e);if(!r)return!1;const o=At(e,r);if(!o)return!1;const a=Lt(o),s=Jt(a,r);if(!s)return!1;const u=Math.min(a.colCount-s.originCol,Math.max(1,Math.floor(t))),d=Math.min(a.rowCount-s.originRow,Math.max(1,Math.floor(n)));if(u===s.colSpan&&d===s.rowSpan||!Uv(a,s,u,d))return!1;if((s.colSpan>1||s.rowSpan>1)&&Gg(o,r),u===1&&d===1)return St(r),!0;const f=Lt(o),g=Kg(f,{minRow:s.originRow,maxRow:s.originRow+d-1,minCol:s.originCol,maxCol:s.originCol+u-1});return g?Wg(o,g):!0}function Cu(e,t,n){let r=t;for(;r&&r!==e;){if(r instanceof HTMLElement&&n(r))return r;r=r.parentNode}return null}function ok(e){return Gv.has(e.tagName.toLowerCase())}function wu(e){const t=window.getSelection();if(!t||t.rangeCount===0)return null;const n=t.getRangeAt(0);return ke(e,n.commonAncestorContainer)?n.startContainer:null}function Vg(e){const t=ii(e);if(t.length<2)return null;const n=At(e,t[0]);if(!n)return null;const r=Lt(n),o=[];for(const u of t){const d=Jt(r,u);if(!d)return null;o.push(d)}const a=Og(o);if(!a)return null;const s=Kg(r,a);return!s||s.cells.length<2?null:s}function Wg(e,t){const n=t.origin.cell,r=Lt(e),o=t.cells.map(a=>Jt(r,a)).filter(a=>a!==null).sort((a,s)=>a.originRow-s.originRow||a.originCol-s.originCol);for(const a of o)a.cell!==n&&lk(n,a.cell);br(n,t.colSpan,t.rowSpan);for(const a of o)a.cell!==n&&a.cell.remove();return St(n),!0}function Gg(e,t){const n=Lt(e),r=Jt(n,t);if(!r||r.colSpan===1&&r.rowSpan===1)return!1;br(t,1,1);for(let o=r.originRow;o<r.originRow+r.rowSpan;o+=1)for(let a=r.originCol;a<r.originCol+r.colSpan;a+=1)o===r.originRow&&a===r.originCol||ku(e,o,a,vu(t));return St(t),!0}function ik(e){const t=document.createElement(e);return t.style.border=Vv,t.style.padding=Wv,t.appendChild(document.createElement("br")),t}function vu(e){const t=e.cloneNode(!1);for(t.removeAttribute("colspan"),t.removeAttribute("rowspan");t.firstChild;)t.removeChild(t.firstChild);return t.appendChild(document.createElement("br")),t}function ak(e,t,n){t>=e.cells.length?e.appendChild(n):e.insertBefore(n,e.cells[t])}function ku(e,t,n,r){const o=e.rows[t];if(!o)return;const a=Lt(e);let s=0;for(const u of Array.from(o.cells)){if(u===r)continue;const d=Jt(a,u);if(!d||d.originCol>=n)break;s+=1}ak(o,s,r)}function sk(e,t,n,r){let o=0;for(let a=0;a<t;a+=1)if(!n.has(a)){if(a>=r)return e.cells[o]??null;o+=1}return e.cells[e.cells.length-1]??null}function Qm(e){var t;return e.childNodes.length===0||e.childNodes.length===1&&((t=e.firstChild)==null?void 0:t.nodeName)==="BR"?!0:(e.textContent??"").trim().length===0&&e.querySelector("img, table, ul, ol, hr")===null}function lk(e,t){if(!(e===t||Qm(t)))for(Qm(e)?e.innerHTML="":e.appendChild(document.createTextNode(" "));t.firstChild;)e.appendChild(t.firstChild)}function ck(e,t){var o;const n=t.parentElement;if(!n||n===e)return;const r=n.tagName.toLowerCase();r==="td"||r==="th"||(r==="p"||/^h[1-6]$/.test(r))&&((o=n.parentNode)==null||o.insertBefore(t,n.nextSibling),uk(n)&&n.remove())}function uk(e){var t;return e.childNodes.length===0||e.childNodes.length===1&&((t=e.firstChild)==null?void 0:t.nodeName)==="BR"?!0:(e.textContent??"").trim().length===0&&e.querySelector("img, table, ul, ol")===null}function vc(e,t){if(!t.parentNode||!ke(e,t))return!1;const r=document.createRange();r.setStartBefore(t),r.collapse(!0),t.remove();const o=window.getSelection();return o&&(o.removeAllRanges(),o.addRange(r)),!0}function St(e){const t=document.createRange();t.selectNodeContents(e),t.collapse(!0);const n=window.getSelection();n&&(n.removeAllRanges(),n.addRange(t))}function dk(e){const t=document.createRange();t.setStartAfter(e),t.collapse(!0);const n=window.getSelection();n&&(n.removeAllRanges(),n.addRange(t))}const Zg=["left","center","right","justify"];function mk(e){const t=e.trim().toLowerCase();return t==="center"?"center":t==="right"||t==="end"?"right":t==="justify"?"justify":"left"}function Va(e){return mk(e.style.textAlign)}function kc(e,t){const n=t??"left";return Va(e)===n?t===null&&e.style.textAlign?(e.style.removeProperty("text-align"),!0):!1:(t===null||t==="left"?e.style.removeProperty("text-align"):e.style.textAlign=t,!0)}function ef(e){const t=e[0];return e.every(n=>n===t)?{align:t,mixed:!1}:{align:null,mixed:!0}}function qg(e){const t=ii(e);if(t.length>0)return ef(t.map(Va));const n=An(e);return n.length===0?fn(e)?{align:"left",mixed:!1}:{align:null,mixed:!1}:ef(n.map(Va))}function Yg(e,t){return Zg.includes(t)?Yn(e,()=>{const n=ii(e);if(n.length>0){let a=!1;for(const s of n)kc(s,t)&&(a=!0);return a}const r=xr(e);if(r.length===0)return!1;let o=!1;for(const a of r)kc(a,t)&&(o=!0);return o}):!1}function Yr(){return{...ru(),align:"left",alignMixed:!1,list:null,listMixed:!1}}function Kl(e){const t=xC(e),n=qg(e),r=Mg(e);return{...t,align:n.align,alignMixed:n.mixed,list:r.type,listMixed:r.mixed}}function Xg(e,t){let n=!1;return!t.alignMixed&&t.align&&Yg(e,t.align)&&(n=!0),t.listMixed||Nv(e,t.list)&&(n=!0),CC(e,t)&&(n=!0),n}function fk(e,t){return Xg(e,Sc(t))}function Jg(e){return{align:e.alignMixed?void 0:e.align??"left",list:e.listMixed?void 0:e.list,margin:e.marginMixed?void 0:e.margin,padding:e.paddingMixed?void 0:e.padding,lineHeight:e.lineHeightMixed?void 0:e.lineHeight,border:e.borderMixed?void 0:e.border,borderRadius:e.radiusMixed?void 0:e.borderRadius,boxShadow:e.shadowMixed?void 0:e.boxShadow,backgroundColor:e.backgroundMixed?void 0:e.backgroundColor,opacity:e.opacityMixed?void 0:e.opacity,breakInside:e.breakInsideMixed?void 0:e.breakInside,breakAfter:e.breakAfterMixed?void 0:e.breakAfter,breakBefore:e.breakBeforeMixed?void 0:e.breakBefore}}function Sc(e){const t=Yr();return e?{align:e.align??t.align,alignMixed:e.align===void 0,list:e.list===void 0?t.list:e.list,listMixed:e.list===void 0,margin:e.margin??t.margin,marginMixed:e.margin===void 0,padding:e.padding??t.padding,paddingMixed:e.padding===void 0,lineHeight:e.lineHeight===void 0?t.lineHeight:e.lineHeight,lineHeightMixed:e.lineHeight===void 0,border:e.border??t.border,borderMixed:e.border===void 0,borderRadius:e.borderRadius===void 0?t.borderRadius:e.borderRadius,radiusMixed:e.borderRadius===void 0,boxShadow:e.boxShadow===void 0?t.boxShadow:e.boxShadow,shadowMixed:e.boxShadow===void 0,backgroundColor:e.backgroundColor===void 0?t.backgroundColor:e.backgroundColor,backgroundMixed:e.backgroundColor===void 0,opacity:e.opacity===void 0?t.opacity:e.opacity,opacityMixed:e.opacity===void 0,breakInside:e.breakInside===void 0?t.breakInside:e.breakInside,breakInsideMixed:e.breakInside===void 0,breakAfter:e.breakAfter===void 0?t.breakAfter:e.breakAfter,breakAfterMixed:e.breakAfter===void 0,breakBefore:e.breakBefore===void 0?t.breakBefore:e.breakBefore,breakBeforeMixed:e.breakBefore===void 0}:{...t,alignMixed:!0,listMixed:!0,marginMixed:!0,paddingMixed:!0,lineHeightMixed:!0,borderMixed:!0,radiusMixed:!0,shadowMixed:!0,backgroundMixed:!0,opacityMixed:!0,breakInsideMixed:!0,breakAfterMixed:!0,breakBeforeMixed:!0}}function ba(e){return e?fr(e):""}function pk(e,t){return e.src===t.src&&e.opacity===t.opacity&&e.fit===t.fit&&e.position===t.position&&ba(e.width)===ba(t.width)&&ba(e.height)===ba(t.height)}function tf(e){const t=An(e);if(t.length===0)return kn();const n=t.map(lg),r=n[0];return n.some(o=>!pk(o,r))?kn():r}function gk(e,t){return Yn(e,()=>{const n=xr(e);if(n.length===0)return!1;let r=!1;for(const o of n)cg(o,t)&&(r=!0);return r})}function hk(){return{size:null,unit:Xr,marks:zn(),fontFamily:null,fontFamilyMixed:!1,fontColor:null,highlightColor:null,fontColorMixed:!1,highlightColorMixed:!1}}function Wa(){return{font:hk(),box:ru(),backgroundImage:kn(),atRule:Ln()}}function Ac(e,t){return t?{top:t.top!==void 0?t.top:e.top,right:t.right!==void 0?t.right:e.right,bottom:t.bottom!==void 0?t.bottom:e.bottom,left:t.left!==void 0?t.left:e.left}:e}function bk(e,t){if(!t)return e;const{margin:n,padding:r,...o}=t;return{...e,...o,margin:n?Ac(e.margin,n):e.margin,padding:r?Ac(e.padding,r):e.padding}}function yk(e,t){if(!t)return e;const{marks:n,...r}=t;return{...e,...r,marks:n?{...e.marks,...n}:e.marks}}function xk(e,t){const{margin:n,...r}=t.atRule??{};return{font:yk(e.font,t.font),box:bk(e.box,t.box),backgroundImage:t.backgroundImage?{...e.backgroundImage,...t.backgroundImage}:e.backgroundImage,atRule:t.atRule?{...e.atRule,...r,margin:n?Ac(e.atRule.margin,n):e.atRule.margin}:e.atRule}}function Ck(e){return e?!!(e.font||e.box||e.backgroundImage||e.atRule):!1}function nf(e,t){if(!Ck(t))return e;const n=document.createElement("div");n.innerHTML=e;const r=xk(Sa(n),t);return Pc(n,r).pageHtml}function wk(e){const t=e.style.fontSize,n=t?Wc(t):null,r=n&&is(n.unit)?{value:n.value,unit:n.unit}:null,o=`${e.style.textDecorationLine} ${e.style.textDecoration}`.toLowerCase(),a=e.style.fontWeight.trim().toLowerCase(),s={bold:a==="bold"||Number(a)>=700,italic:e.style.fontStyle.trim().toLowerCase()==="italic",underline:/\bunderline\b/.test(o),strikethrough:/\bline-through\b/.test(o)},u=e.style.color,d=e.style.fontFamily.trim();return{size:(r==null?void 0:r.value)??null,unit:(r==null?void 0:r.unit)??Xr,marks:s,fontFamily:d||null,fontFamilyMixed:!1,fontColor:u?Ve(u):null,highlightColor:null,fontColorMixed:!1,highlightColorMixed:!1}}function vk(e,t){const n=e.style.fontSize,r=t.size===null?null:pr(t.size,t.unit);if(!r)return n?(e.style.removeProperty("font-size"),!0):!1;const o=Vc(r.value,r.unit);return n===o?!1:(e.style.fontSize=o,!0)}function kk(e,t){var o;if(t.fontFamilyMixed)return!1;const n=(o=t.fontFamily)!=null&&o.trim()?t.fontFamily.trim():null,r=e.style.fontFamily.trim()||null;return ni(r,n)?!1:(n?e.style.fontFamily=n:e.style.removeProperty("font-family"),!0)}function Sk(e,t){if(t.fontColorMixed)return!1;const n=t.fontColor?Ve(t.fontColor):null;return(e.style.color?Ve(e.style.color):null)===n?!1:(n?e.style.color=n:e.style.removeProperty("color"),!0)}function Ak(e,t){let n=!1;const r=t.bold?"bold":"";e.style.fontWeight!==r&&(r?e.style.fontWeight=r:e.style.removeProperty("font-weight"),n=!0);const o=t.italic?"italic":"";e.style.fontStyle!==o&&(o?e.style.fontStyle=o:e.style.removeProperty("font-style"),n=!0);const a=[];t.underline&&a.push("underline"),t.strikethrough&&a.push("line-through");const s=a.join(" ");return(e.style.textDecorationLine||e.style.textDecoration).trim()!==s&&(s?e.style.textDecoration=s:(e.style.removeProperty("text-decoration"),e.style.removeProperty("text-decoration-line")),n=!0),n}function Pk(e,t){let n=!1;return vk(e,t)&&(n=!0),kk(e,t)&&(n=!0),Sk(e,t)&&(n=!0),Ak(e,t.marks)&&(n=!0),n&&kt(e),n}function Tk(e){const t=e.box;return t.backgroundMixed||t.backgroundColor?t:!e.font.highlightColorMixed&&e.font.highlightColor?{...t,backgroundColor:e.font.highlightColor}:t}function Sa(e){const t=gt(e);if(!t)return Wa();const n=ao(t);return{font:wk(t),box:{margin:n.margin,marginMixed:!1,padding:n.padding,paddingMixed:!1,lineHeight:n.lineHeight,lineHeightMixed:!1,border:n.border,borderMixed:!1,borderRadius:n.borderRadius,radiusMixed:!1,boxShadow:n.boxShadow,shadowMixed:!1,backgroundColor:n.backgroundColor,backgroundMixed:!1,opacity:n.opacity,opacityMixed:!1},backgroundImage:i1(t),atRule:st(e.innerHTML)}}function Pc(e,t){const n=fn(e),r=n?Jr(e,n.startContainer,n.startOffset):null,o=n?Jr(e,n.endContainer,n.endOffset):null,a=gt(e),s=cu(e);Ko(s);const u=Pk(s,t.font),d=so(s,Tk(t)),f=a1(s,t.backgroundImage);us(e);const g=st(e.innerHTML),h=_a(e.innerHTML,t.atRule),C=cn(h);C!==cn(e.innerHTML)&&(e.innerHTML=C),co(e,h);const b=JSON.stringify(g)!==JSON.stringify(t.atRule);r!==null&&o!==null&&Qc(e,Math.min(r,o),Math.max(r,o)),ds(e);const x=_a(e.innerHTML,t.atRule);return{changed:!a||u||d||f||b,pageHtml:x}}function Rk(e,t){const n=t??e.innerHTML,r=Bp(n);return Yo(n)?(e.innerHTML=cn(r),us(e),co(e,r),{changed:!0,pageHtml:r}):{changed:!1,pageHtml:r}}const Dk=/<script\b[^>]*>[\s\S]*?<\/script>/gi,jk=/^\s*javascript\s*:/i;function Ik(e){return e.replace(/&(#x[0-9a-f]+|#\d+|amp|lt|gt|quot);/gi,(t,n)=>{const r=n.toLowerCase();if(r==="amp")return"&";if(r==="lt")return"<";if(r==="gt")return">";if(r==="quot")return'"';if(r.startsWith("#x")){const o=Number.parseInt(r.slice(2),16);return Number.isFinite(o)?String.fromCodePoint(o):t}if(r.startsWith("#")){const o=Number.parseInt(r.slice(1),10);return Number.isFinite(o)?String.fromCodePoint(o):t}return t}).replace(/\\([0-7]{1,3})/g,(t,n)=>{const r=Number.parseInt(n,8);return Number.isFinite(r)?String.fromCodePoint(r):t})}function Qg(e){const t=Ik(e).replace(/[\u0000-\u001F\u007F\s]+/g,"");return jk.test(t)}function Ek(e){return e.split(";").map(t=>t.trim()).filter(t=>{if(!t)return!1;const n=t.indexOf(":");if(n<=0)return!0;const r=t.slice(n+1);return!Qg(r)&&!/url\s*\(\s*["']?\s*javascript:/i.test(r)}).join("; ")}function _k(e){const t=e instanceof Element?[e,...e.querySelectorAll("*")]:[...e.querySelectorAll("*")];for(const n of t)for(const r of[...n.attributes]){if(Qg(r.value)){n.removeAttribute(r.name);continue}if(r.name.toLowerCase()==="style"){const o=Ek(r.value);o?o!==r.value&&n.setAttribute(r.name,o):n.removeAttribute(r.name)}}}function Mk(e){return new DOMParser().parseFromString(`<body>${e}</body>`,"text/html")}function Nk(e){return e.body.innerHTML}function Tc(e){if(!e.trim())return e;const n=e.replace(Dk,"");if(!/javascript\s*:/i.test(n))return n;const r=Mk(n);return _k(r.body),Nk(r)}function $r(e){if(!e.trim())return e;const n=Fn(e);return n.length===1?Tc(e):Mt(n.map(Tc))}const Su="data-hover-html",Lk="noopener noreferrer",Bk="var n=this._hoverBox;if(!n){n=document.createElement('div');n.style.cssText='position:absolute;z-index:2147483646;background:#fff;border:1px solid #c8c8c8;border-radius:4px;padding:0.35rem 0.5rem;color:#222;max-width:18rem';this._hoverBox=n}n.innerHTML=this.getAttribute('data-hover-html')||'';var r=this.getBoundingClientRect();n.style.left=r.left+window.scrollX+'px';n.style.top=r.bottom+4+window.scrollY+'px';document.body.appendChild(n)",Fk="this._hoverBox&&this._hoverBox.remove()",Hk=/^(#(?:[0-9a-fA-F]{3}|[0-9a-fA-F]{6}|[0-9a-fA-F]{8})|rgba?\(\s*\d+\s*,\s*\d+\s*,\s*\d+(?:\s*,\s*(?:0|0?\.\d+|1))?\s*\))$/;function gs(e={}){return{href:"",title:"",targetBlank:!1,textDecorationNone:!1,hoverMode:"color",hoverColor:null,hoverHtml:"",...e}}function zk(e){return e.tagName.toLowerCase()==="a"&&e.hasAttribute("href")}function Qo(e,t){let n=t;for(;n&&n!==e;){if(n instanceof Element&&zk(n))return n;n=n.parentNode}return null}function eh(e){return Hk.test(e)}function Ok(e){var o;const t=e.getAttribute("onmouseover")??"",n=/this\.style\.color\s*=\s*'([^']+)'/.exec(t),r=((o=n==null?void 0:n[1])==null?void 0:o.trim())??"";return r&&eh(r)?r:null}function th(e){const t=`${e.style.textDecoration} ${e.style.textDecorationLine}`.toLowerCase();return/\bnone\b/.test(t)}function Kk(e){const t=e.getAttribute(Su)??"",n=Ok(e);return{href:e.getAttribute("href")??"",title:e.getAttribute("title")??"",targetBlank:e.getAttribute("target")==="_blank",textDecorationNone:th(e),hoverMode:t.trim()?"html":"color",hoverColor:n,hoverHtml:t}}function nh(e){const t=window.getSelection();if(!t||t.rangeCount===0)return null;const n=t.getRangeAt(0);if(!ke(e,n.commonAncestorContainer))return null;const r=Qo(e,n.commonAncestorContainer);return r?Kk(r):null}function $k(e){return nh(e)!==null}function Uk(e){e.removeAttribute("onmouseover"),e.removeAttribute("onmouseout"),e.removeAttribute(Su)}function Vk(e,t){var r;if(Uk(e),t.hoverMode==="html"){const o=t.hoverHtml.trim();if(!o)return;e.setAttribute(Su,o),e.setAttribute("onmouseover",Bk),e.setAttribute("onmouseout",Fk);return}const n=((r=t.hoverColor)==null?void 0:r.trim())??"";!n||!eh(n)||(e.setAttribute("onmouseover",`this.style.color='${n}'`),e.setAttribute("onmouseout","this.style.color=''"))}function Au(e,t){const n=gs(t);e.setAttribute("href",n.href);const r=n.title.trim();r?e.setAttribute("title",r):e.removeAttribute("title"),n.targetBlank?(e.setAttribute("target","_blank"),e.setAttribute("rel",Lk)):(e.removeAttribute("target"),e.removeAttribute("rel")),n.textDecorationNone?e.style.textDecoration="none":th(e)&&(e.style.removeProperty("text-decoration"),e.style.removeProperty("text-decoration-line")),Vk(e,n)}function Wk(e,t){const n=new Set;for(const r of t){const o=Qo(e,r);o&&!n.has(o)&&n.add(o)}for(const r of n)Nt(r)}function Gk(e,t,n){un(t);const r=Pt(t).filter(u=>u.data.length>0);Wk(e,r),r.length>0&&yr(r);const o=window.getSelection();if(!o||o.rangeCount===0)return!1;const a=o.getRangeAt(0);un(a);const s=document.createElement("a");Au(s,n);try{return a.surroundContents(s),!0}catch{const u=a.extractContents();return u.hasChildNodes()?(s.appendChild(u),a.insertNode(s),!0):!1}}function Zk(e,t){const n=document.createElement("a");Au(n,t),n.textContent=t.href,e.insertNode(n),e.setStartAfter(n),e.collapse(!0);const r=window.getSelection();return r==null||r.removeAllRanges(),r==null||r.addRange(e),!0}function qk(e,t){const n=t.href.trim();if(!n)return!1;const r=gs({...t,href:n}),o=window.getSelection();if(!o||o.rangeCount===0)return!1;const a=o.getRangeAt(0);if(!ke(e,a.commonAncestorContainer))return!1;const s=Qo(e,a.startContainer),u=Qo(e,a.endContainer);return s&&s===u?(Au(s,r),!0):a.collapsed?Zk(a,r):Gk(e,a,r)}const Yk=/^[A-Za-z][A-Za-z0-9_-]*$/,rh="​";function Rc(e){var r;const t=uu(e),n=new Set;for(const o of t.querySelectorAll("[id]")){if(o===t)continue;const a=o.id.trim();a&&n.add(a)}for(const o of t.querySelectorAll("a[name]")){const a=(r=o.getAttribute("name"))==null?void 0:r.trim();a&&n.add(a)}return[...n].sort((o,a)=>o.localeCompare(a)).map(o=>({id:o}))}function Xk(e){return new Set(Rc(e).map(t=>t.id))}function oh(e,t){const n=e.trim();return n?Yk.test(n)?t.has(n)?"duplicate":null:"invalid":"empty"}function rf(e,t){const n=document.createElement("a");n.id=t,n.appendChild(document.createTextNode(rh)),e.insertNode(n),e.setStartAfter(n),e.collapse(!0);const r=window.getSelection();r==null||r.removeAllRanges(),r==null||r.addRange(e)}function Jk(e,t){var r;const n=document.createElement("a");n.id=t,n.appendChild(document.createTextNode(rh)),(r=e.parentNode)==null||r.insertBefore(n,e)}function Qk(e,t){const n=t.trim();if(oh(n,Xk(e)))return!1;const r=window.getSelection();if(!r||r.rangeCount===0)return!1;const o=r.getRangeAt(0);if(!ke(e,o.commonAncestorContainer))return!1;const a=Qo(e,o.startContainer);if(a)return Jk(a,n),!0;if(o.collapsed)return rf(o,n),!0;un(o);const s=document.createElement("span");s.id=n;try{return o.surroundContents(s),!0}catch{return rf(o,n),!0}}const lt="data-comment-thread",of="wysiwyg-comment-anchor";function eS(){return`cmt_${crypto.randomUUID()}`}function tS(){return crypto.randomUUID()}const Ga=20;function af(e,t){if(!e)return null;const n=e instanceof Element?e:e.parentElement;if(!n)return null;const r=n.closest(`[${lt}]`);return r instanceof HTMLElement&&ke(t,r)?r:null}function sf(e,t,n){var C;const r=document.createTreeWalker(e,NodeFilter.SHOW_TEXT);let o=Math.max(0,t),a=Math.max(t,n),s=null,u=0,d=null,f=0,g;for(;g=r.nextNode();){const b=g,x=((C=b.textContent)==null?void 0:C.length)??0;if(!s&&o<=x&&(s=b,u=o),!d&&a<=x){d=b,f=a;break}o-=x,a-=x}if(!s||!d)return null;const h=document.createRange();return h.setStart(s,u),h.setEnd(d,f),h}function nS(e,t,n){const r=e.textContent??"",o=r.slice(Math.max(0,t-Ga),t),a=r.slice(n,n+Ga);return{prefix:o,suffix:a}}function rS(e,t){if(t.mode!=="visual")return null;const n=Hn(e);if(n)return{type:"image",elementId:n.id||void 0,src:n.getAttribute("src")??void 0};if(t.collapsed&&!t.text)return null;const{prefix:r,suffix:o}=nS(e,t.start,t.end);return{type:"text",text:t.text,start:t.start,end:t.end,prefix:r,suffix:o}}function lf(e,t){if(t.mode!=="visual")return null;const n=Hn(e);if(n!=null&&n.hasAttribute(lt))return n.getAttribute(lt)??null;if(t.visualRange){const r=af(t.visualRange.startContainer,e);if(r)return r.getAttribute(lt)??null;const o=af(t.visualRange.endContainer,e);if(o)return o.getAttribute(lt)??null}return null}function Dc(e,t,n){if(!ke(e,n.commonAncestorContainer))return!1;un(n);const r=document.createElement("span");r.setAttribute(lt,t);try{return n.surroundContents(r),!0}catch{const o=n.toString();if(!o)return!1;const a=document.createElement("span");return a.setAttribute(lt,t),a.textContent=o,n.deleteContents(),n.insertNode(a),!0}}function ih(e,t){e.setAttribute(lt,t)}function oS(e,t,n){const r=Hn(e);return r?(ih(r,t),!0):n.visualRange?Dc(e,t,n.visualRange):!1}function iS(e,t){if(t.type!=="image")return null;for(const n of e.querySelectorAll("img"))if(t.elementId&&n.id===t.elementId||t.src&&n.getAttribute("src")===t.src)return n;return null}function aS(e,t,n){if(n.type!=="text")return!1;if(n.start!==void 0&&n.end!==void 0){const s=sf(e,n.start,n.end);if(s&&s.toString()===n.text)return Dc(e,t,s)}const r=e.textContent??"",o=n.text;if(!o)return!1;let a=0;for(;a<=r.length;){const s=r.indexOf(o,a);if(s===-1)return!1;const u=s+o.length,d=r.slice(Math.max(0,s-Ga),s),f=r.slice(u,u+Ga);if(n.prefix!==void 0&&d!==n.prefix){a=s+1;continue}if(n.suffix!==void 0&&f!==n.suffix){a=s+1;continue}const g=sf(e,s,u);return g?Dc(e,t,g):!1}return!1}function sS(e,t){for(const n of t)if(!e.querySelector(`[${lt}="${n.id}"]`)){if(n.anchor.type==="image"){const o=iS(e,n.anchor);o&&ih(o,n.id);continue}aS(e,n.id,n.anchor)}}function ah(e,t){for(const n of e.querySelectorAll(`[${lt}]`))n instanceof HTMLElement&&(t?n.classList.add(of):n.classList.remove(of))}function sh(e,t){if(!t)return null;const n=t instanceof Element?t:t.parentElement;if(!n)return null;const r=n.closest(`[${lt}]`);return r instanceof HTMLElement&&ke(e,r)?r:null}function cf(e,t){const n=e.querySelector(`[${lt}="${t}"]`);if(!(n instanceof HTMLElement))return!1;const r=window.getSelection();if(!r)return!1;const o=document.createRange();if(n instanceof HTMLImageElement)o.selectNode(n);else{const s=document.createTreeWalker(n,NodeFilter.SHOW_TEXT).nextNode();s instanceof Text?(o.setStart(s,0),o.collapse(!0)):(o.selectNodeContents(n),o.collapse(!0))}return r.removeAllRanges(),r.addRange(o),!0}function lS(e,t=[]){return{id:eS(),anchor:e,messages:t,createdAt:new Date().toISOString(),resolvedAt:null,resolvedBy:null}}function cS(e,t){return{id:tS(),userId:e.userId,userName:e.userName,message:t.trim(),createdAt:new Date().toISOString()}}function uS(e,t,n){return e.map(r=>r.id===t?{...r,messages:[...r.messages,n]}:r)}function dS(e,t){return e.find(n=>n.id===t)}function lh(e){const t=window.getSelection();if(!t||t.rangeCount===0)return null;const n=t.getRangeAt(0);return ke(e,n.commonAncestorContainer)?n:null}function mS(e){const t=lh(e);if(!t||t.collapsed)return null;const n=document.createElement("div");n.appendChild(t.cloneContents());const r=n.innerHTML;if(!r)return null;let o=t.toString();if(!o){const a=n.querySelector("img");o=(a==null?void 0:a.getAttribute("alt"))??(a==null?void 0:a.getAttribute("src"))??""}return{html:r,text:o}}function ch(e){const t=lh(e);if(!t||t.collapsed)return!1;t.deleteContents();const n=window.getSelection();return n==null||n.removeAllRanges(),n==null||n.addRange(t),!0}async function fS(e){const t=navigator.clipboard;if(!t)return!1;try{if(typeof ClipboardItem=="function"&&typeof t.write=="function"){const n=new ClipboardItem({"text/plain":new Blob([e.text],{type:"text/plain"}),"text/html":new Blob([e.html],{type:"text/html"})});return await t.write([n]),!0}if(typeof t.writeText=="function")return await t.writeText(e.text),!0}catch{if(typeof t.writeText=="function")try{return await t.writeText(e.text),!0}catch{return!1}return!1}return!1}async function uh(e){const t=mS(e);return t?fS(t):!1}async function pS(e){return await uh(e)?ch(e):!1}const gS=new Set(["strong","b","em","i","u","s","strike","del"]),hS=["font","font-weight","font-style","font-family","font-size","color","background","background-color","text-decoration","text-decoration-line","text-decoration-color","text-decoration-style","text-decoration-thickness"];function bS(e){for(const t of hS)e.style.removeProperty(t)}function yS(e,t){let n=t;for(;n.parentElement&&n.parentElement!==e;){const r=n.parentElement;if(!mn(r)){n=r;continue}if(Zn(r,n),gS.has(r.tagName.toLowerCase())){Nt(r);continue}if(bS(r),Gn(r)){Nt(r);continue}n=r.isConnected?r:t}}function xS(e){const t=fn(e);if(!t||t.collapsed)return!1;const n=e.innerHTML;un(t);const r=Pt(t).filter(o=>o.data.length>0);if(r.length===0)return!1;for(const o of r)yS(e,o);return yr(r),e.innerHTML!==n}function CS(e,t){return e.start===t.start&&e.end===t.end&&e.collapsed===t.collapsed}function wS(e){const t=Wr(e),n=wg(e),r=op(e),o=Da(e,"color"),a=Da(e,"backgroundColor"),s=kg(e);return{size:n.mixed?null:n.value,unit:n.unit,marks:t,fontFamily:r.mixed?null:r.value,fontFamilyMixed:r.mixed,fontColor:o.mixed?null:o.value,fontColorMixed:o.mixed,highlightColor:a.mixed?null:a.value,highlightColorMixed:a.mixed,customCss:s.mixed?null:s.value,customCssMixed:s.mixed}}function vS(e,t){t.size!==null&&gc(e,t.size,t.unit);const n=Wr(e);for(const r of Kt)t.marks[r]!==n[r]&&yc(e,r);return t.fontFamilyMixed||nc(e,t.fontFamily),t.fontColorMixed||Oo(e,"color",t.fontColor),t.highlightColorMixed||Oo(e,"backgroundColor",t.highlightColor),!t.customCssMixed&&t.customCss&&Ag(e,t.customCss),!0}function Aa(){return typeof window<"u"&&"speechSynthesis"in window}function kS(e){const t=document.createElement("div");return t.innerHTML=e,(t.innerText??t.textContent??"").trim()}function uf(e,t){const n=e.text.trim();return n||kS(t)||null}function SS(e){const t=window.speechSynthesis,n=()=>{e()};return{toggle(r){if(!Aa())return;if(t.speaking){t.cancel(),n();return}const o=new SpeechSynthesisUtterance(r);o.onend=n,o.onerror=n,t.speak(o),n()},isSpeaking(){return Aa()&&t.speaking},cancel(){Aa()&&t.speaking&&(t.cancel(),n())}}}const AS=5*1024*1024,PS="audio/mpeg,audio/mp3,audio/wav,audio/x-wav,audio/ogg,audio/aac,audio/webm,audio/mp4,audio/x-m4a,.mp3,.wav,.ogg,.aac,.webm,.m4a",TS=new Set(["audio/mpeg","audio/mp3","audio/wav","audio/x-wav","audio/ogg","audio/aac","audio/webm","audio/mp4","audio/x-m4a"]),RS=new Set(["mp3","wav","ogg","aac","webm","m4a"]),DS=/^data:audio\/(?:mpeg|mp3|wav|x-wav|ogg|aac|webm|mp4|x-m4a)(?:;charset=[^;,]+)?;base64,/i,jS=/^(javascript|vbscript|file|blob):/i;function IS(e={}){return{src:"",title:"",...e}}function Pu(e){const t=e.trim();if(!t)return"empty";if(jS.test(t))return"invalid";if(t.toLowerCase().startsWith("data:"))return DS.test(t)?null:"invalid";if(/^[a-z][a-z0-9+.-]*:/i.test(t)){const n=t.slice(0,t.indexOf(":")).toLowerCase();return n==="http"||n==="https"?null:"invalid"}return null}function ES(e){return e.size>AS?"tooLarge":BS(e)?null:"type"}function _S(e){const t=ES(e);return t?Promise.reject(new Error(t)):new Promise((n,r)=>{const o=new FileReader;o.onload=()=>{const a=String(o.result??"");if(Pu(a)){r(new Error("invalid"));return}n(a)},o.onerror=()=>r(o.error??new Error("Failed to read file")),o.readAsDataURL(e)})}function MS(e,t){e.setAttribute("controls",""),e.setAttribute("src",t.src.trim());const n=t.title.trim();n?e.setAttribute("title",n):e.removeAttribute("title"),e.style.maxWidth="100%",NS(e,t.css)}function NS(e,t){if(t)for(const n of t.split(";")){const r=n.trim();if(!r)continue;const o=r.indexOf(":");if(o<=0)continue;const a=r.slice(0,o).trim(),s=r.slice(o+1).trim();a&&s&&e.style.setProperty(a,s)}}function LS(e,t){const n=IS(t);if(Pu(n.src))return!1;const r=window.getSelection();if(!r||r.rangeCount===0)return!1;const o=r.getRangeAt(0);if(!ke(e,o.commonAncestorContainer))return!1;o.collapsed||o.deleteContents();const a=document.createElement("audio");return MS(a,n),o.insertNode(a),o.setStartAfter(a),o.collapse(!0),r.removeAllRanges(),r.addRange(o),!0}function BS(e){const t=e.type.trim().toLowerCase();if(t&&TS.has(t))return!0;const n=FS(e.name);return!!(!t&&n&&RS.has(n))}function FS(e){const t=e.lastIndexOf(".");return t<0||t===e.length-1?"":e.slice(t+1).toLowerCase()}function df(e,t){const r=(t?t(e):e).trim();if(!r)return"";if(!r.includes("<"))return r;const o=new DOMParser().parseFromString(`<body>${r}</body>`,"text/html");for(const a of o.querySelectorAll("img"))a.removeAttribute(_t);return o.body.innerHTML}function dh(e,t,n){return df(e,n)===df(t,n)}const HS=/^data:image\/(?:jpeg|jpg|png|gif|webp|bmp|avif)(?:;charset=[^;,]+)?;base64,/i;function mf(e,t){var o,a;const n=(o=e.getAttribute(_t))==null?void 0:o.trim();if(n&&t){const s=t(n);if(s)return`embedded:${s}`}const r=((a=e.getAttribute("src"))==null?void 0:a.trim())??"";return HS.test(r)?`embedded:${r}`:r.startsWith("blob:")&&n?`registry:${n}`:r?`url:${r}`:"empty"}function zS(e){return new DOMParser().parseFromString(`<body>${e}</body>`,"text/html").body}function OS(e,t){for(const n of[...e.attributes])t.hasAttribute(n.name)||e.removeAttribute(n.name);for(const n of[...t.attributes])e.setAttribute(n.name,n.value)}function KS(e,t){e.querySelectorAll("img").forEach((n,r)=>{const o=document.createElement("span");o.setAttribute(t,String(r)),n.replaceWith(o)})}function ff(e,t){const n=e.cloneNode(!0);return KS(n,t),n.innerHTML}function $S(e,t,n){const r=zS(t),o=[...e.querySelectorAll("img")],a=[...r.querySelectorAll("img")];if(o.length===0||o.length!==a.length)return!1;const s=o.map(h=>mf(h,n)),u=a.map(h=>mf(h,n));if(!s.every((h,C)=>h===u[C]))return!1;const d="data-wysiwyg-img-marker",f=ff(e,d),g=ff(r,d);if(f!==g)return!1;for(let h=0;h<o.length;h+=1)OS(o[h],a[h]);return!0}function Za(e,t,n={}){const{resolveDataUrl:r,hydrateEmbeddedImages:o}=n;return dh(e.innerHTML,t,o)?{changed:!1}:e.innerHTML===t?{changed:!1}:$S(e,t,r)?{changed:!0}:(e.innerHTML=t,{changed:!0})}const mh=/^(javascript|vbscript|file|blob):/i,US=[/(?:youtube\.com\/watch\?(?:[^&]*&)*v=|youtube\.com\/watch\?v=)([\w-]{11})/i,/youtu\.be\/([\w-]{11})/i,/youtube\.com\/embed\/([\w-]{11})/i,/youtube\.com\/shorts\/([\w-]{11})/i];function VS(e={}){return{url:"",title:"",...e}}function WS(e={}){return{src:"",title:"",...e}}function hs(e){const t=e.trim();if(!t)return null;for(const n of US){const r=t.match(n);if(r!=null&&r[1])return r[1]}return null}function fh(e){return`https://www.youtube.com/embed/${e}`}function ph(e){const t=e.trim();return t?mh.test(t)?"invalid":hs(t)?null:"invalid":"empty"}function GS(e){const t=e.trim();if(!t)return"empty";if(mh.test(t))return"invalid";if(hs(t))return null;if(t.toLowerCase().startsWith("data:"))return/^data:video\//i.test(t)?null:"invalid";if(/^[a-z][a-z0-9+.-]*:/i.test(t)){const n=t.slice(0,t.indexOf(":")).toLowerCase();return n==="http"||n==="https"?null:"invalid"}return null}function gh(e,t){if(t)for(const n of t.split(";")){const r=n.trim();if(!r)continue;const o=r.indexOf(":");if(o<=0)continue;const a=r.slice(0,o).trim(),s=r.slice(o+1).trim();a&&s&&e.style.setProperty(a,s)}}function hh(e,t,n){e.setAttribute("src",t),e.setAttribute("frameborder","0"),e.setAttribute("allow","accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture"),e.setAttribute("allowfullscreen","");const r=n.title.trim();r?e.setAttribute("title",r):e.removeAttribute("title"),e.style.maxWidth="100%",e.style.width="560px",e.style.aspectRatio="16 / 9",e.style.border="0",gh(e,n.css)}function ZS(e,t){e.setAttribute("controls",""),e.setAttribute("src",t.src.trim());const n=t.title.trim();n?e.setAttribute("title",n):e.removeAttribute("title"),e.style.maxWidth="100%",gh(e,t.css)}function qS(e,t){const n=VS(t);if(ph(n.url))return!1;const r=hs(n.url);if(!r)return!1;const o=window.getSelection();if(!o||o.rangeCount===0)return!1;const a=o.getRangeAt(0);if(!ke(e,a.commonAncestorContainer))return!1;a.collapsed||a.deleteContents();const s=document.createElement("iframe");return hh(s,fh(r),n),a.insertNode(s),a.setStartAfter(s),a.collapse(!0),o.removeAllRanges(),o.addRange(a),!0}function YS(e,t){const n=WS(t);if(GS(n.src))return!1;const r=window.getSelection();if(!r||r.rangeCount===0)return!1;const o=r.getRangeAt(0);if(!ke(e,o.commonAncestorContainer))return!1;o.collapsed||o.deleteContents();const a=hs(n.src);if(a){const s=document.createElement("iframe");hh(s,fh(a),{title:n.title,css:n.css}),o.insertNode(s),o.setStartAfter(s)}else{const s=document.createElement("video");ZS(s,n),o.insertNode(s),o.setStartAfter(s)}return o.collapse(!0),r.removeAllRanges(),r.addRange(o),!0}const XS=new Set(["p","h1","h2","h3","h4","h5","h6"]),JS=new Set(["td","th","li","blockquote","pre","table","thead","tbody","tr"]);function bh(e,t){var a;const n=window.getSelection();if(!n||n.rangeCount===0)return!1;const r=n.getRangeAt(0);if(!ke(e,r.commonAncestorContainer))return!1;r.collapsed||r.deleteContents();const o=QS(e,r.startContainer);if(o){const s=e0(o,r);return(a=o.parentNode)==null||a.insertBefore(t,s),gf(t),!0}return r.insertNode(t),t0(e,t),o0(t),gf(t),!0}function QS(e,t){let n=ri(t);for(;n&&n!==e;){const r=Me(n);if(XS.has(r)&&n instanceof HTMLElement)return n;if(JS.has(r))return null;n=n.parentElement}return null}function e0(e,t){var a;const n=document.createRange();n.setStart(t.startContainer,t.startOffset),n.setEnd(e,e.childNodes.length);const r=n.extractContents(),o=e.cloneNode(!1);return o.appendChild(r),pf(e),pf(o),(a=e.parentNode)==null||a.insertBefore(o,e.nextSibling),o}function t0(e,t){for(;;){const n=t.parentElement;if(!n||n===e||!n0(n))return;Zn(n,t),Nt(n)}}function n0(e){const t=Me(e);return mn(e)||t==="a"}function pf(e){r0(e)&&e.appendChild(document.createElement("br"))}function r0(e){var t;return e.childNodes.length===0||e.childNodes.length===1&&((t=e.firstChild)==null?void 0:t.nodeName)==="BR"?!0:(e.textContent??"").trim().length===0&&e.querySelector("img, table, ul, ol, hr")===null}function o0(e){var n;if(e.nextSibling)return;const t=document.createElement("p");t.appendChild(document.createElement("br")),(n=e.parentNode)==null||n.insertBefore(t,e.nextSibling)}function gf(e){const t=e.nextSibling,n=document.createRange();t instanceof HTMLElement||t?(n.setStart(t,0),n.collapse(!0)):(n.setStartAfter(e),n.collapse(!0));const r=window.getSelection();r&&(r.removeAllRanges(),r.addRange(n))}const i0="1em 0",a0="1px solid #d0d0d0";function s0(){const e=document.createElement("hr");return e.style.margin=i0,e.style.border="0",e.style.borderTop=a0,e}function l0(e){return bh(e,s0())}const c0="1.5em 0",u0="2px dashed #bbb",d0="data-wysiwyg-page-break";function m0(){const e=document.createElement("div");return e.setAttribute(d0,""),e.style.display="block",e.style.clear="both",e.style.breakAfter="page",e.style.pageBreakAfter="always",e.style.margin=c0,e.style.border="0",e.style.borderTop=u0,e.style.height="0",e}function f0(e){return bh(e,m0())}const Sn=16;function hf(e){return Math.min(no.px.max,Math.max(Sn,e))}function p0(e){return e.width>0&&e.height>0?e.width/e.height:1}function g0(e,t){const n=Math.max(Sn,Sn*t),r=Math.min(no.px.max,no.px.max*t),o=Math.min(r,Math.max(n,e));return{width:o,height:o/t}}function h0(e,t){const n=Math.max(Sn,Sn/t),r=Math.min(no.px.max,no.px.max/t),o=Math.min(r,Math.max(n,e));return{width:o*t,height:o}}function b0(e,t,n){const r=p0(t);return e==="e"?g0(t.width+n.x,r):e==="s"?h0(t.height+n.y,r):{width:hf(t.width+n.x),height:hf(t.height+n.y)}}function y0(e){const t=e.getBoundingClientRect(),n=e.offsetWidth||t.width,r=e.offsetHeight||t.height;return{width:n>0?n:Sn,height:r>0?r:Sn}}function x0(e,t,n){const r=ro(Math.max(Sn,t),"px"),o=ro(Math.max(Sn,n),"px");return!r||!o?!1:tg(e,{...eg(e),sizeMode:"lock",width:r,height:o})}function C0(e={}){return{border:{...nu},borderCollapse:"collapse",borderSpacing:null,borderRadius:null,boxShadow:null,width:{value:100,unit:"%"},...e}}function w0(e){const t=ao(e);return{border:t.border,borderCollapse:A0(e),borderSpacing:yh(e),borderRadius:t.borderRadius,boxShadow:t.boxShadow,width:ht(e.style.width)}}function v0(e,t){let n=so(e,{margin:{top:null,right:null,bottom:null,left:null},marginMixed:!0,padding:{top:null,right:null,bottom:null,left:null},paddingMixed:!0,lineHeight:null,lineHeightMixed:!0,border:t.border,borderMixed:!1,borderRadius:t.borderRadius,radiusMixed:!1,boxShadow:t.boxShadow,shadowMixed:!1,backgroundColor:null,backgroundMixed:!0,opacity:null,opacityMixed:!0});return P0(e,t.borderCollapse)&&(n=!0),T0(e,t.borderCollapse,t.borderSpacing)&&(n=!0),R0(e,t.width)&&(n=!0),n&&kt(e),n}function k0(e){const t=xu(e);return t?w0(t):null}function S0(e,t){const n=xu(e);return n?v0(n,t):!1}function A0(e){return e.style.borderCollapse.trim().toLowerCase()==="separate"?"separate":"collapse"}function P0(e,t){return e.style.borderCollapse.trim().toLowerCase()===t?!1:(e.style.borderCollapse=t,!0)}function yh(e){const t=e.style.borderSpacing.trim();return t?ht(t.split(/\s+/)[0]??""):null}function T0(e,t,n){if(t!=="separate")return e.style.borderSpacing?(e.style.removeProperty("border-spacing"),!0):!1;const r=n?qn(n):null,o=yh(e);return zt(o,r)?!1:(r?e.style.borderSpacing=Ie(r):e.style.removeProperty("border-spacing"),!0)}function R0(e,t){const n=t?qn(t):null,r=ht(e.style.width);return zt(r,n)?!1:(n?e.style.width=Ie(n):e.style.removeProperty("width"),!0)}const bs=["top","middle","bottom","baseline"],D0=new Set(bs);function j0(e={}){return{backgroundColor:null,color:null,padding:{...Xt},textAlign:null,verticalAlign:null,width:null,colSpan:1,rowSpan:1,...e}}function I0(e){const t=ao(e);return{backgroundColor:t.backgroundColor,color:xh(e),padding:t.padding,textAlign:L0(e),verticalAlign:Ch(e),width:ht(e.style.width),...ps(e)}}function E0(e,t){let n=so(e,{margin:{...Xt},marginMixed:!0,padding:t.padding,paddingMixed:!1,lineHeight:null,lineHeightMixed:!0,border:{style:"none",width:null,color:null},borderMixed:!0,borderRadius:null,radiusMixed:!0,boxShadow:null,shadowMixed:!0,backgroundColor:t.backgroundColor,backgroundMixed:!1,opacity:null,opacityMixed:!0});return N0(e,t.color)&&(n=!0),kc(e,t.textAlign)&&(n=!0),B0(e,t.verticalAlign)&&(n=!0),F0(e,t.width)&&(n=!0),n&&kt(e),n}function _0(e){const t=pn(e);return t?I0(t):null}function M0(e,t){const n=ii(e);if(n.length===0)return!1;let r=!1;for(const a of n)E0(a,t)&&(r=!0);const o=pn(e);if(o){const a=ps(o);(a.colSpan!==t.colSpan||a.rowSpan!==t.rowSpan)&&rk(e,t.colSpan,t.rowSpan)&&(r=!0)}return r}function xh(e){const t=e.style.color;return t?Ve(t):null}function N0(e,t){const n=t?Ve(t):null;return xh(e)===n?!1:(n?e.style.color=n:e.style.removeProperty("color"),!0)}function L0(e){const t=Va(e);return t==="left"?null:t}function Ch(e){const t=e.style.verticalAlign.trim().toLowerCase();return D0.has(t)?t:null}function B0(e,t){return Ch(e)===t?!1:(t?e.style.verticalAlign=t:e.style.removeProperty("vertical-align"),!0)}function F0(e,t){const n=t?qn(t):null,r=ht(e.style.width);return zt(r,n)?!1:(n?e.style.width=Ie(n):e.style.removeProperty("width"),!0)}const H0=new Set(bs);function z0(e={}){return{backgroundColor:null,color:null,padding:{...Xt},height:null,verticalAlign:null,...e}}function O0(e){const t=e.cells[0],n=t?ao(t).padding:{...Xt};return{backgroundColor:wh(e),color:vh(e),padding:n,height:ht(e.style.height),verticalAlign:kh(e)}}function K0(e,t){let n=!1;V0(e,t.backgroundColor)&&(n=!0),W0(e,t.color)&&(n=!0),Z0(e,t.height)&&(n=!0),G0(e,t.verticalAlign)&&(n=!0);for(const r of Array.from(e.cells))so(r,{margin:{...Xt},marginMixed:!0,padding:t.padding,paddingMixed:!1,lineHeight:null,lineHeightMixed:!0,border:{style:"none",width:null,color:null},borderMixed:!0,borderRadius:null,radiusMixed:!0,boxShadow:null,shadowMixed:!0,backgroundColor:null,backgroundMixed:!0,opacity:null,opacityMixed:!0})&&(n=!0);return n&&kt(e),n}function $0(e){const t=Ug(e);return t?O0(t):null}function U0(e,t){const n=Ug(e);return n?K0(n,t):!1}function wh(e){const t=e.style.backgroundColor;return t?Ve(t):null}function V0(e,t){const n=t?Ve(t):null;return wh(e)===n?!1:(n?e.style.backgroundColor=n:e.style.removeProperty("background-color"),!0)}function vh(e){const t=e.style.color;return t?Ve(t):null}function W0(e,t){const n=t?Ve(t):null;return vh(e)===n?!1:(n?e.style.color=n:e.style.removeProperty("color"),!0)}function kh(e){const t=e.style.verticalAlign.trim().toLowerCase();return H0.has(t)?t:null}function G0(e,t){return kh(e)===t?!1:(t?e.style.verticalAlign=t:e.style.removeProperty("vertical-align"),!0)}function Z0(e,t){const n=t?qn(t):null,r=ht(e.style.height);return zt(r,n)?!1:(n?e.style.height=Ie(n):e.style.removeProperty("height"),!0)}const q0=1e3;function Y0(e,t){try{Promise.resolve(e(t)).catch(()=>{})}catch{}}function X0({onAutoSave:e,getHtml:t}){const n=l.useRef(e);n.current=e;const r=l.useRef(t);r.current=t;const o=l.useRef(null),a=e!=null;l.useEffect(()=>{if(!a){o.current=null;return}o.current=r.current();const s=window.setInterval(()=>{const u=n.current;if(!u)return;const d=r.current();d!==o.current&&(o.current=d,queueMicrotask(()=>Y0(u,d)))},q0);return()=>{window.clearInterval(s)}},[a])}function J0(){const[e,t]=l.useState({open:!1,tab:"general"}),[n,r]=l.useState(!1),[o,a]=l.useState({open:!1,html:""}),[s,u]=l.useState(null),[d,f]=l.useState(!1),[g,h]=l.useState(!1),[C,b]=l.useState({open:!1,tab:"general",value:Yr(),backgroundImage:kn()}),[x,y]=l.useState({open:!1,value:""}),[v,k]=l.useState({open:!1,tab:"font",paragraphTab:"spacing",value:Wa()}),[S,P]=l.useState(!1),[R,D]=l.useState({open:!1}),[A,T]=l.useState({open:!1,tab:"link",href:"",title:"",targetBlank:!1,textDecorationNone:!1,hoverMode:"color",hoverColor:null,hoverHtml:"",bookmarks:[],selectedBookmarkId:""}),[_,M]=l.useState({open:!1,existingIds:[]}),[z,E]=l.useState({open:!1}),[N,O]=l.useState({open:!1}),[G,Y]=l.useState({open:!1}),[re,Z]=l.useState({open:!1,tab:"general",value:Qp(),aspectRatio:1}),[J,ne]=l.useState({open:!1}),[ce,X]=l.useState({open:!1,value:C0()}),[I,se]=l.useState({open:!1,value:j0()}),[fe,L]=l.useState({open:!1,value:z0()}),[Le,Ee]=l.useState({open:!1,topicId:"getStarted"}),[ze,bt]=l.useState(!1);return{fontDialog:e,setFontDialog:t,customizeToolbarOpen:n,setCustomizeToolbarOpen:r,documentPreview:o,setDocumentPreview:a,toolbarSettings:s,setToolbarSettings:u,toolbarSettingsLoading:d,setToolbarSettingsLoading:f,toolbarSettingsBusy:g,setToolbarSettingsBusy:h,paragraphDialog:C,setParagraphDialog:b,customCssDialog:x,setCustomCssDialog:y,pageDialog:v,setPageDialog:k,deletePageConfirmOpen:S,setDeletePageConfirmOpen:P,customStyleDialog:R,setCustomStyleDialog:D,linkDialog:A,setLinkDialog:T,bookmarkDialog:_,setBookmarkDialog:M,imageDialog:z,setImageDialog:E,audioDialog:N,setAudioDialog:O,youtubeDialog:G,setYoutubeDialog:Y,imageProperties:re,setImageProperties:Z,tableDialog:J,setTableDialog:ne,tableProperties:ce,setTableProperties:X,cellProperties:I,setCellProperties:se,rowProperties:fe,setRowProperties:L,helpDialog:Le,setHelpDialog:Ee,aboutDialogOpen:ze,setAboutDialogOpen:bt}}const bf={changed:!1,pages:[],joined:"",changedIndices:[]};function yf(e){return{changed:e.changed,pages:e.pages,joined:Mt(e.pages),changedIndices:e.changedIndices}}function Q0({enabled:e,pagesProp:t,defaultPages:n}){const r=e&&t!==void 0,o=l.useMemo(()=>t!==void 0?Bn(t):void 0,[t]),[a,s]=l.useState(()=>({pages:Bn(n),revision:0})),u=l.useRef(o??Bn(n)),d=l.useRef(new Set),f=l.useRef(t);l.useEffect(()=>{if(!e||!r||o===void 0||f.current===t&&mr(u.current,o))return;f.current=t;const k=Bl(u.current,o);if(u.current=k.pages,!!k.changed){for(const S of k.changedIndices)d.current.add(S);s(S=>({pages:k.pages,revision:S.revision+1}))}},[e,r,o,t]);const g=l.useMemo(()=>{if(!e)return[];if(r&&o!==void 0){const k=Bl(u.current,o);return u.current=k.pages,k.pages}return a.pages},[e,r,o,a.pages,a.revision]),h=l.useCallback((k,S)=>{if(!e)return bf;const P=r?u.current:a.pages,R=Bl(P,k);if(!R.changed)return yf(R);for(const D of R.changedIndices)d.current.add(D);return S!==void 0&&d.current.add(S),r?u.current=R.pages:s(D=>({pages:R.pages,revision:D.revision+1})),yf(R)},[e,a.pages,r]),C=l.useCallback((k,S)=>h(k,S==null?void 0:S.editedIndex),[h]),b=l.useCallback((k,S,P)=>{if(!e)return bf;const R=r?u.current:a.pages,D=cc(R,k,S);return D.changed?h(D.pages,(P==null?void 0:P.editedIndex)??k):{changed:!1,pages:R,joined:Mt(R),changedIndices:[]}},[h,e,a.pages,r]),x=l.useCallback(k=>h(Bn(k)),[h]),y=l.useCallback(k=>{if(k===void 0){d.current.clear();return}for(const S of k)d.current.delete(S)},[]),v=l.useCallback(()=>Mt(g),[g]);return l.useMemo(()=>({pages:g,revision:a.revision,dirtyPagesRef:d,setPages:C,updatePage:b,replacePages:x,markPagesClean:y,getJoinedHtml:v}),[g,a.revision,C,b,x,y,v])}function Pa({value:e,defaultValue:t,onChange:n}){const[r,o]=l.useState(t),a=e!==void 0,s=a?e:r,u=l.useCallback(d=>{a||o(d),n==null||n(d)},[a,n]);return[s,u]}const Sh="commspliant-html-editor.darkMode";function eA(e){return typeof e=="boolean"?e:null}function xf(){try{const e=localStorage.getItem(Sh);return e?eA(JSON.parse(e)):null}catch{return null}}function tA(e){try{localStorage.setItem(Sh,JSON.stringify(e))}catch{}}const Ah="commspliant-html-editor.pageZoom",nA=new Set(["fitWidth","fitPage"]);function rA(e){return typeof e=="string"&&nA.has(e)||typeof e=="number"&&B1.includes(e)?e:null}function oA(){try{const e=localStorage.getItem(Ah);return e?rA(JSON.parse(e)):null}catch{return null}}function iA(e){try{localStorage.setItem(Ah,JSON.stringify(e))}catch{}}const Ph="commspliant-html-editor.toolbarPosition",aA=["top","left","right","bottom"];function Th(e){return typeof e=="string"&&aA.includes(e)?e:null}function Cf(){try{const e=localStorage.getItem(Ph);return e?Th(JSON.parse(e)):null}catch{return null}}function sA(e){try{localStorage.setItem(Ph,JSON.stringify(e))}catch{}}function lA({enabled:e,onHtml:t}){const[n,r]=l.useState(!1),o=l.useRef(0),a=l.useRef(e),s=l.useRef(t);a.current=e,s.current=t;const u=l.useCallback(()=>{o.current=0,r(!1)},[]);l.useEffect(()=>{e||u()},[e,u]);const d=l.useCallback(C=>{!a.current||!ha(C.dataTransfer)||(C.preventDefault(),o.current+=1,r(!0))},[]),f=l.useCallback(C=>{!a.current||!ha(C.dataTransfer)||(C.preventDefault(),C.dataTransfer&&(C.dataTransfer.dropEffect="copy"))},[]),g=l.useCallback(C=>{if(!a.current||!ha(C.dataTransfer))return;const b=C.relatedTarget;b instanceof Node&&C.currentTarget.contains(b)||(o.current=Math.max(0,o.current-1),o.current===0&&r(!1))},[]),h=l.useCallback(C=>{if(!a.current||!ha(C.dataTransfer))return;C.preventDefault(),u();const b=h1(C.dataTransfer);b&&hu(b).then(x=>{a.current&&s.current(x)},()=>{})},[u]);return{dragging:n,onDragEnter:d,onDragOver:f,onDragLeave:g,onDrop:h}}const cA={menus:{edit:{id:"edit",labelKey:"menuEdit",ariaKey:"menuEditAria"}},submenus:{page:{id:"page",labelKey:"menuPage",ariaKey:"menuPageAria"}},groups:{edit:{id:"edit",labelKey:"toolbarGroupEdit"}},items:{undo:{id:"undo",command:"undo",icon:Py,labelKey:"commandUndo",ariaKey:"commandUndoAria",enabled:"canUndo"},redo:{id:"redo",command:"redo",icon:Cy,labelKey:"commandRedo",ariaKey:"commandRedoAria",enabled:"canRedo"},pageProperties:{id:"pageProperties",command:"openPageProperties",icon:zo,labelKey:"commandPageProperties",ariaKey:"commandPagePropertiesAria",enabled:"isVisualMode"},deletePage:{id:"deletePage",command:"deletePage",icon:zo,labelKey:"commandDeletePage",ariaKey:"commandDeletePageAria",enabled:"canDeletePage"}}},Rh=400,qa=100,Dh=2e7;function uA(e){let t=[],n=0,r=e,o=[],a=0,s=!1,u=!1,d=0;function f(){if(t.length>qa){const v=t.splice(0,t.length-qa);for(const k of v)n-=k.length}for(;t.length>1&&n+a>Dh;){const v=t.shift();v&&(n-=v.length)}}function g(v){t.push(v),n+=v.length,f()}function h(){o=[],a=0}function C(v,k){if(s){r=v,s=!1;return}if(v===r)return;const S=Date.now(),P=(k==null?void 0:k.coalesce)===!0;if(P&&u&&S-d<Rh){r=v,d=S,o.length>0&&h();return}g(r),r=v,h(),d=S,u=P}function b(){if(t.length===0)return null;u=!1,o.push(r),a+=r.length;const v=t.pop();return n-=v.length,r=v,f(),r}function x(){if(o.length===0)return null;u=!1,g(r);const v=o.pop();return a-=v.length,r=v,r}function y(v){if(s){r=v,s=!1;return}v!==r&&(g(r),r=v,h(),u=!1)}return{record:C,undo:b,redo:x,canUndo:()=>t.length>0,canRedo:()=>o.length>0,syncExternal:y,markApplying:()=>{s=!0},finishApplying:()=>{s=!1}}}function Je(e){return e.map(t=>t)}function lr(e){switch(e.type){case"pageEdit":return e.before.length;case"insertPage":return e.page.length;case"deletePage":return e.page.length;case"replaceAll":return e.beforePages.reduce((t,n)=>t+n.length,0)}}function dA(e){let t=[],n=0,r=Je(e),o=[],a=0,s=!1,u=!1,d=null,f=0;function g(){if(t.length>qa){const A=t.splice(0,t.length-qa);for(const T of A)n-=lr(T)}for(;t.length>1&&n+a>Dh;){const A=t.shift();A&&(n-=lr(A))}}function h(A){t.push(A),n+=lr(A),g()}function C(A){o.push(A),a+=lr(A)}function b(){for(const A of o)a-=lr(A);o=[],a=0}function x(){u=!1,d=null}function y(A,T,_){if(s){const O=Je(r);O[A]=T,r=O,s=!1;return}if(r[A]===T)return;const M=Date.now(),z=(_==null?void 0:_.coalesce)===!0,E=z&&u&&d===A&&M-f<Rh,N=Je(r);if(N[A]=T,E){r=N,f=M;return}h({type:"pageEdit",pageIndex:A,before:r[A]??""}),r=N,b(),f=M,u=z,d=A}function v(A,T){if(s){r=Je(T),s=!1;return}mr(r,T)||(h({type:"insertPage",index:A,page:T[A]??""}),r=Je(T),b(),x())}function k(A,T,_){if(s){r=Je(_),s=!1;return}mr(r,_)||(h({type:"deletePage",index:A,page:T}),r=Je(_),b(),x())}function S(A){if(s){r=Je(A),s=!1;return}mr(r,A)||(h({type:"replaceAll",beforePages:Je(r)}),r=Je(A),b(),x())}function P(A){if(s){r=Je(A),s=!1;return}mr(r,A)||(r=Je(A))}function R(){if(t.length===0)return null;x();const A=t.pop();switch(n-=lr(A),A.type){case"pageEdit":{const T=r[A.pageIndex]??"";C({type:"pageEdit",pageIndex:A.pageIndex,before:T}),r[A.pageIndex]=A.before;break}case"insertPage":{const T=r[A.index]??"";C({type:"insertPage",index:A.index,page:T}),r.splice(A.index,1);break}case"deletePage":{C({type:"deletePage",index:A.index,page:A.page}),r.splice(A.index,0,A.page);break}case"replaceAll":{C({type:"replaceAll",beforePages:Je(r)}),r=Je(A.beforePages);break}}return g(),Je(r)}function D(){if(o.length===0)return null;x();const A=o.pop();switch(a-=lr(A),A.type){case"pageEdit":{const T=r[A.pageIndex]??"";h({type:"pageEdit",pageIndex:A.pageIndex,before:T}),r[A.pageIndex]=A.before;break}case"insertPage":{h({type:"insertPage",index:A.index,page:A.page}),r.splice(A.index,0,A.page);break}case"deletePage":{const T=r[A.index]??"";h({type:"deletePage",index:A.index,page:T}),r.splice(A.index,1);break}case"replaceAll":{h({type:"replaceAll",beforePages:Je(r)}),r=Je(A.beforePages);break}}return Je(r)}return{getPresent:()=>r,recordPageEdit:y,recordInsertPage:v,recordDeletePage:k,recordReplaceAll:S,undo:R,redo:D,canUndo:()=>t.length>0,canRedo:()=>o.length>0,syncPages:A=>S(A),applyPresent:P,markApplying:()=>{s=!0}}}function Ht(e){return typeof e=="object"&&e!==null&&"recordPageEdit"in e&&typeof e.recordPageEdit=="function"}const mA='button:not([disabled]):not([tabindex="-1"]), input:not([disabled]):not([hidden]), select:not([disabled]), textarea:not([disabled])',fA='[role="listbox"], [data-color-picker]';function qe(e,{open:t,onClose:n,focusableSelector:r=mA,escapeIgnoreSelectors:o=fA}){l.useEffect(()=>{if(!t)return;const a=e.current,s=a==null?void 0:a.querySelector(r);s==null||s.focus();const u=d=>{if(d.key==="Escape"){if(o&&document.querySelector(o))return;d.preventDefault(),d.stopPropagation(),n();return}if(d.key!=="Tab"||!a)return;const f=[...a.querySelectorAll(r)];if(f.length===0)return;const g=f[0],h=f[f.length-1];d.shiftKey&&document.activeElement===g?(d.preventDefault(),h.focus()):!d.shiftKey&&document.activeElement===h&&(d.preventDefault(),g.focus())};return document.addEventListener("keydown",u,!0),()=>document.removeEventListener("keydown",u,!0)},[e,o,r,n,t])}function Vn(e,t){return t?t.label?t.label:t.labelKey?e(t.labelKey):"":""}function Ya(e,t){return t?t.ariaLabel?t.ariaLabel:t.ariaKey?e(t.ariaKey):Vn(e,t):""}const ln="fullscreen",jc="commspliant-html-editor.toolbarCustomization";function Ic(e){const t=e.filter(n=>n!==ln);return e.includes(ln)?[...t,ln]:t}function Tu(e,t){if(!t||t.length===0)return Ic(e);const n=new Set(e),r=t.filter(s=>n.has(s)),o=new Set(r),a=[...r];for(let s=0;s<e.length;s++){const u=e[s];if(o.has(u))continue;let d=0;for(let f=s-1;f>=0;f--){const g=e[f],h=a.indexOf(g);if(h>=0){d=h+1;break}}a.splice(d,0,u),o.add(u)}return Ic(a)}function pA(e,t){const n=new Map(e.map(s=>[s.id,s])),r=Tu(e.map(s=>s.id),t==null?void 0:t.groupOrder),o=new Set((t==null?void 0:t.hiddenItemIds)??[]),a=[];for(const s of r){const u=n.get(s);if(!u)continue;const d=u.items.filter(f=>!o.has(f));d.length!==0&&a.push({id:s,items:d})}return a}function gA(e){if(e==null||typeof e!="object")return null;const t=e,n=Array.isArray(t.groupOrder)?t.groupOrder.filter(o=>typeof o=="string"):[],r=Array.isArray(t.hiddenItemIds)?[...new Set(t.hiddenItemIds.filter(o=>typeof o=="string"))]:[];return n.length===0&&r.length===0?null:{groupOrder:n,hiddenItemIds:r}}function hA(){try{const e=localStorage.getItem(jc);return e?gA(JSON.parse(e)):null}catch{return null}}function bA(e){try{if(!e){localStorage.removeItem(jc);return}localStorage.setItem(jc,JSON.stringify(e))}catch{}}function Ru(e,t){return Tu(t.map(n=>n.id),e==null?void 0:e.groupOrder)}function yA(e,t,n,r){const o=new Set((e==null?void 0:e.hiddenItemIds)??[]);return r?o.delete(n):o.add(n),{groupOrder:Ru(e,t),hiddenItemIds:[...o]}}function jh(e,t,n,r){const o=Ru(e,t),a=[...(e==null?void 0:e.hiddenItemIds)??[]];if(n===ln||r===ln)return{groupOrder:o,hiddenItemIds:a};const s=o.indexOf(n),u=o.indexOf(r);if(s<0||u<0||s===u)return{groupOrder:o,hiddenItemIds:a};const d=[...o],[f]=d.splice(s,1);return d.splice(u,0,f),{groupOrder:Ic(d),hiddenItemIds:a}}function wf(e,t,n,r){const o=Ru(e,t),a=o.filter(d=>d!==ln),s=a.indexOf(n),u=s+r;return s<0||u<0||u>=a.length?{groupOrder:o,hiddenItemIds:[...(e==null?void 0:e.hiddenItemIds)??[]]}:jh(e,t,n,a[u])}const xA="_backdrop_11w4e_1",CA="_dialog_11w4e_12",wA="_header_11w4e_31",vA="_body_11w4e_39",kA="_group_11w4e_49",SA="_groupDragging_11w4e_55",AA="_groupDropTarget_11w4e_59",PA="_groupHeader_11w4e_64",TA="_groupTitle_11w4e_72",RA="_dragHandle_11w4e_77",DA="_moveButton_11w4e_78",jA="_items_11w4e_119",IA="_item_11w4e_119",EA="_itemIcon_11w4e_135",_A="_itemTitle_11w4e_144",MA="_itemCheckbox_11w4e_151",NA="_actions_11w4e_155",LA="_action_11w4e_155",BA="_spinnerWrap_11w4e_191",FA="_spinner_11w4e_191",Fe={backdrop:xA,dialog:CA,header:wA,body:vA,group:kA,groupDragging:SA,groupDropTarget:AA,groupHeader:PA,groupTitle:TA,dragHandle:RA,moveButton:DA,items:jA,item:IA,itemIcon:EA,itemTitle:_A,itemCheckbox:MA,actions:NA,action:LA,spinnerWrap:BA,spinner:FA};function HA(){return i.jsxs("svg",{viewBox:"0 0 16 16",width:"14",height:"14","aria-hidden":"true",fill:"currentColor",children:[i.jsx("circle",{cx:"5",cy:"4",r:"1.2"}),i.jsx("circle",{cx:"11",cy:"4",r:"1.2"}),i.jsx("circle",{cx:"5",cy:"8",r:"1.2"}),i.jsx("circle",{cx:"11",cy:"8",r:"1.2"}),i.jsx("circle",{cx:"5",cy:"12",r:"1.2"}),i.jsx("circle",{cx:"11",cy:"12",r:"1.2"})]})}function zA({open:e,catalog:t,groups:n,settings:r,loading:o=!1,busy:a=!1,disabled:s,onChange:u,onReset:d,onClose:f}){const g=q(),h=l.useId(),C=l.useRef(null),[b,x]=l.useState(null),[y,v]=l.useState(null),k=Tu(n.map(E=>E.id),r==null?void 0:r.groupOrder),S=new Set((r==null?void 0:r.hiddenItemIds)??[]),P=new Map(n.map(E=>[E.id,E])),R=k.map(E=>P.get(E)).filter(E=>!!E),D=s||a||o;if(l.useEffect(()=>{e||(x(null),v(null))},[e]),qe(C,{open:e,onClose:f,escapeIgnoreSelectors:!1,focusableSelector:'button:not([disabled]):not([tabindex="-1"]), input:not([disabled]), select:not([disabled])'}),!e)return null;const A=R.map(E=>E.id).filter(E=>E!==ln),T=(E,N)=>{if(D||N===ln){E.preventDefault();return}E.dataTransfer.setData("text/plain",N),E.dataTransfer.effectAllowed="move",x(N)},_=(E,N)=>{D||N===ln||!b||b===N||(E.preventDefault(),E.dataTransfer&&(E.dataTransfer.dropEffect="move"),v(N))},M=(E,N)=>{var G;E.preventDefault();const O=((G=E.dataTransfer)==null?void 0:G.getData("text/plain"))||b;x(null),v(null),!(!O||O===N||D)&&u(jh(r,n,O,N))},z=()=>{x(null),v(null)};return i.jsx(we,{children:i.jsx("div",{className:Fe.backdrop,role:"presentation",onMouseDown:f,children:i.jsxs("div",{ref:C,className:Fe.dialog,role:"dialog","aria-modal":"true","aria-labelledby":h,"aria-busy":o||a?!0:void 0,onMouseDown:E=>E.stopPropagation(),children:[i.jsx("h2",{className:Fe.header,id:h,children:g("customizeToolbarDialogTitle")}),i.jsx("div",{className:Fe.body,children:o?i.jsx("div",{className:Fe.spinnerWrap,role:"status","aria-live":"polite","aria-label":g("customizeToolbarDialogLoading"),children:i.jsx("span",{className:Fe.spinner,"aria-hidden":"true"})}):R.map(E=>{const N=t.groups[E.id],O=N?Vn(g,N):E.id,G=E.id===ln,Y=A.indexOf(E.id);return i.jsxs("section",{className:[Fe.group,b===E.id?Fe.groupDragging:"",y===E.id?Fe.groupDropTarget:""].filter(Boolean).join(" "),"data-toolbar-customize-group":E.id,"aria-label":O,onDragOver:re=>_(re,E.id),onDrop:re=>M(re,E.id),onDragLeave:()=>{y===E.id&&v(null)},children:[i.jsxs("div",{className:Fe.groupHeader,children:[i.jsx("button",{type:"button",className:Fe.dragHandle,draggable:!D&&!G,disabled:D||G,"aria-label":g("customizeToolbarDragHandle"),onDragStart:re=>T(re,E.id),onDragEnd:z,children:i.jsx(HA,{})}),i.jsx("span",{className:Fe.groupTitle,children:O}),i.jsx("button",{type:"button",className:Fe.moveButton,disabled:D||G||Y<=0,"aria-label":g("customizeToolbarMoveUp"),onClick:()=>u(wf(r,n,E.id,-1)),children:"↑"}),i.jsx("button",{type:"button",className:Fe.moveButton,disabled:D||G||Y<0||Y>=A.length-1,"aria-label":g("customizeToolbarMoveDown"),onClick:()=>u(wf(r,n,E.id,1)),children:"↓"})]}),i.jsx("div",{className:Fe.items,children:E.items.map(re=>{const Z=t.items[re];if(!Z)return null;const J=Z.icon,ne=Vn(g,Z),ce=`${h}-${E.id}-${re}`,X=!S.has(re);return i.jsxs("label",{className:Fe.item,htmlFor:ce,children:[i.jsx("span",{className:Fe.itemIcon,"aria-hidden":"true",children:J?i.jsx(J,{}):ne.slice(0,2)}),i.jsx("span",{className:Fe.itemTitle,children:ne}),i.jsx("input",{id:ce,className:Fe.itemCheckbox,type:"checkbox",checked:X,disabled:D,"aria-label":`${ne}: ${g("customizeToolbarItemVisible")}`,onChange:I=>u(yA(r,n,re,I.target.checked))})]},re)})})]},E.id)})}),i.jsxs("div",{className:Fe.actions,children:[i.jsx("button",{type:"button",className:Fe.action,disabled:D,onClick:d,children:g("customizeToolbarDialogReset")}),i.jsx("button",{type:"button",className:Fe.action,"aria-label":g("customizeToolbarDialogCloseAria"),onClick:f,children:g("customizeToolbarDialogClose")})]})]})})})}function OA(e,t){if(!t)return e;const n=t.menus,r=t.toolbar;if(n===void 0&&r===void 0)return e;const o=n===void 0?e.menus:e.menus.filter(s=>n.includes(s.id)),a=r===void 0?e.iconGroups:e.iconGroups.map(s=>({id:s.id,items:s.items.filter(u=>r.includes(u))})).filter(s=>s.items.length>0);return{menus:o,iconGroups:a}}const KA={menus:{file:{id:"file",labelKey:"menuFile",ariaKey:"menuFileAria"}},groups:{file:{id:"file",labelKey:"toolbarGroupFile"},print:{id:"print",labelKey:"toolbarGroupPrint"}},items:{save:{id:"save",command:"save",icon:ky,labelKey:"commandSave",ariaKey:"commandSaveAria"},open:{id:"open",command:"open",icon:my,labelKey:"commandOpen",ariaKey:"commandOpenAria"},print:{id:"print",command:"print",icon:yy,labelKey:"commandPrint",ariaKey:"commandPrintAria"}}},Ih=4;function $A({anchorRect:e,floatingWidth:t,floatingHeight:n,pad:r=Ih,minWidth:o=0,matchAnchorWidth:a=!1}){const s=a?Math.max(e.width,t,o):t;let u=e.bottom;u+n>window.innerHeight-r&&(u=Math.max(r,e.top-n));const d=Math.min(Math.max(e.left,r),window.innerWidth-s-r);return a?{top:u,left:d,width:s}:{top:u,left:d}}function uo(e,t,n,{pad:r=Ih,minWidth:o=0,matchAnchorWidth:a=!1,deps:s=[]}={}){const[u,d]=l.useState({top:0,left:0}),f=l.useCallback(()=>{const g=t.current,h=n.current;if(!g)return;const C=g.getBoundingClientRect(),b=Math.max(a?C.width:0,(h==null?void 0:h.offsetWidth)??0,o),x=(h==null?void 0:h.offsetHeight)??0;d($A({anchorRect:C,floatingWidth:b,floatingHeight:x,pad:r,minWidth:o,matchAnchorWidth:a}))},[t,n,a,o,r]);return l.useLayoutEffect(()=>{if(!e)return;f();const g=()=>f();return window.addEventListener("scroll",g,!0),window.addEventListener("resize",g),()=>{window.removeEventListener("scroll",g,!0),window.removeEventListener("resize",g)}},[e,f,...s]),u}const UA="_toolbar_1aggm_1",VA="_menuBar_1aggm_35",WA="_menuBarDesktop_1aggm_43",GA="_brandMark_1aggm_49",ZA="_brandMarkIcon_1aggm_56",qA="_menuBarCompact_1aggm_68",YA="_menuWrap_1aggm_91",XA="_menuButton_1aggm_97",JA="_iconButton_1aggm_98",QA="_menuItem_1aggm_99",eP="_hamburgerButton_1aggm_142",tP="_iconNav_1aggm_149",nP="_iconNavMain_1aggm_160",rP="_iconNavEnd_1aggm_169",oP="_iconGroup_1aggm_185",iP="_tooltipTrigger_1aggm_276",aP="_menu_1aggm_35",sP="_submenuWrap_1aggm_305",lP="_submenu_1aggm_305",cP="_submenuTrigger_1aggm_315",uP="_menuOverlay_1aggm_330",dP="_menuOverlayHeader_1aggm_342",mP="_menuOverlayTitle_1aggm_352",fP="_menuOverlayBody_1aggm_358",pP="_menuSeparator_1aggm_409",gP="_icon_1aggm_98",hP="_tooltip_1aggm_276",bP="_tooltipElevated_1aggm_494",ae={toolbar:UA,menuBar:VA,menuBarDesktop:WA,brandMark:GA,brandMarkIcon:ZA,menuBarCompact:qA,menuWrap:YA,menuButton:XA,iconButton:JA,menuItem:QA,hamburgerButton:eP,iconNav:tP,iconNavMain:nP,iconNavEnd:rP,iconGroup:oP,tooltipTrigger:iP,menu:aP,submenuWrap:sP,submenu:lP,submenuTrigger:cP,menuOverlay:uP,menuOverlayHeader:dP,menuOverlayTitle:mP,menuOverlayBody:fP,menuSeparator:pP,icon:gP,tooltip:hP,tooltipElevated:bP},yP=400,vf=6,$l=4;function Wn({label:e,children:t,className:n,elevated:r}){const o=l.useRef(null),a=l.useRef(null),s=l.useRef(null),u=l.useRef(!1),d=l.useRef(!1),[f,g]=l.useState(!1),[h,C]=l.useState({top:0,left:0}),b=l.useCallback(()=>{s.current!==null&&(clearTimeout(s.current),s.current=null)},[]),x=l.useCallback(k=>{if(!(u.current||d.current)){b(),g(!1);return}if(k||d.current){b(),g(!0);return}b(),s.current=setTimeout(()=>{s.current=null,g(!0)},yP)},[b]),y=l.useCallback(()=>{const k=o.current,S=a.current;if(!k||!S)return;const P=k.getBoundingClientRect(),R=S.offsetWidth,D=S.offsetHeight;let A=P.bottom+vf;A+D>window.innerHeight-$l&&(A=P.top-vf-D);let T=P.left+P.width/2-R/2;T=Math.min(Math.max(T,$l),window.innerWidth-R-$l),C({top:A,left:T})},[]);l.useEffect(()=>()=>b(),[b]),l.useEffect(()=>{const k=o.current;if(!k)return;const S=()=>{d.current=!0,x(!0)},P=()=>{d.current=!1,x(!1)};return k.addEventListener("focusin",S),k.addEventListener("focusout",P),()=>{k.removeEventListener("focusin",S),k.removeEventListener("focusout",P)}},[x]),l.useLayoutEffect(()=>{if(!f)return;y();const k=()=>y();return window.addEventListener("scroll",k,!0),window.addEventListener("resize",k),()=>{window.removeEventListener("scroll",k,!0),window.removeEventListener("resize",k)}},[f,e,y]);const v=n?`${ae.tooltipTrigger} ${n}`:ae.tooltipTrigger;return i.jsxs(i.Fragment,{children:[i.jsx("span",{ref:o,className:v,"data-tooltip-trigger":"",onMouseEnter:()=>{u.current=!0,x(!1)},onMouseLeave:()=>{u.current=!1,x(!1)},children:t}),f?i.jsx(we,{children:i.jsx("span",{ref:a,className:r?`${ae.tooltip} ${ae.tooltipElevated}`:ae.tooltip,"data-toolbar-tooltip":"",style:{top:h.top,left:h.left},"aria-hidden":"true",children:e})}):null]})}const kf=8,Sf=["#000000","#434343","#666666","#999999","#b7b7b7","#cccccc","#d9d9d9","#ffffff","#980000","#ff0000","#ff9900","#ffff00","#00ff00","#00ffff","#4a86e8","#9900ff","#e6b8af","#f4cccc","#fce5cd","#fff2cc","#d9ead3","#d0e0e3","#c9daf8","#d9d2e9","#cc4125","#e06666","#f6b26b","#ffd966","#93c47d","#76a5af","#6d9eeb","#8e7cc3","#660000","#990000","#b45f06","#bf9000","#38761d","#134f5c","#1155cc","#351c75"],xP=8;let Ec=[];const _c=new Set;function Af(){return Ec}function CP(e){const t=Ve(e);t&&(Ec=[t,...Ec.filter(n=>n!==t)].slice(0,xP),_c.forEach(n=>n()))}function wP(e){return _c.add(e),()=>{_c.delete(e)}}function ya(e){const t=Ve(e);return t?{r:Number.parseInt(t.slice(1,3),16),g:Number.parseInt(t.slice(3,5),16),b:Number.parseInt(t.slice(5,7),16)}:null}function cr(e,t,n){const r=o=>Math.max(0,Math.min(255,Math.round(o))).toString(16).padStart(2,"0");return`#${r(e)}${r(t)}${r(n)}`}function Ul({r:e,g:t,b:n}){const r=e/255,o=t/255,a=n/255,s=Math.max(r,o,a),u=Math.min(r,o,a),d=s-u;let f=0;return d!==0&&(s===r?f=(o-a)/d%6:s===o?f=(a-r)/d+2:f=(r-o)/d+4,f*=60,f<0&&(f+=360)),{h:f,s:s===0?0:d/s,v:s}}function Vl({h:e,s:t,v:n}){const r=(e%360+360)%360,o=n*t,a=o*(1-Math.abs(r/60%2-1)),s=n-o;let u=0,d=0,f=0;return r<60?(u=o,d=a):r<120?(u=a,d=o):r<180?(d=o,f=a):r<240?(d=a,f=o):r<300?(u=a,f=o):(u=o,f=a),{r:Math.round((u+s)*255),g:Math.round((d+s)*255),b:Math.round((f+s)*255)}}function Eh(){return typeof window<"u"&&"EyeDropper"in window}async function vP(){if(!Eh())return null;const e=window.EyeDropper;try{const t=await new e().open();return Ve(t.sRGBHex)}catch{return null}}const kP="_picker_ag1yo_1",SP="_none_ag1yo_12",AP="_customToggle_ag1yo_13",PP="_eyedrop_ag1yo_14",TP="_swatch_ag1yo_48",RP="_field_ag1yo_49",DP="_grid_ag1yo_54",jP="_recents_ag1yo_55",IP="_sectionLabel_ag1yo_84",EP="_custom_ag1yo_13",_P="_sv_ag1yo_95",MP="_svThumb_ag1yo_105",NP="_hue_ag1yo_116",LP="_rgbRow_ag1yo_155",BP="_hexRow_ag1yo_156",tt={picker:kP,none:SP,customToggle:AP,eyedrop:PP,swatch:TP,field:RP,grid:DP,recents:jP,sectionLabel:IP,custom:EP,sv:_P,svThumb:MP,hue:NP,rgbRow:LP,hexRow:BP};function FP(e){if(!/^\d+$/.test(e.trim()))return null;const t=Number(e);return Number.isFinite(t)?Math.max(0,Math.min(255,t)):null}function Du({value:e,mixed:t=!1,noneLabel:n,ariaLabel:r,disabled:o,menu:a=!1,fallbackCustom:s="#000000",onChange:u,onCommit:d}){const f=q(),g=l.useId(),h=a?"menuitemradio":"option",C=t?null:e,b=ya(C??s)??{r:0,g:0,b:0},[x,y]=l.useState(!1),[v,k]=l.useState(()=>Ul(b)),[S,P]=l.useState(()=>({r:String(b.r),g:String(b.g),b:String(b.b)})),[R,D]=l.useState(()=>cr(b.r,b.g,b.b)),[A,T]=l.useState(()=>[...Af()]),_=l.useRef(null),M=l.useRef(cr(b.r,b.g,b.b));l.useEffect(()=>wP(()=>T([...Af()])),[]),l.useEffect(()=>{const I=ya(C??s);if(!I)return;const se=Ul(I);k(se),P({r:String(I.r),g:String(I.g),b:String(I.b)}),D(cr(I.r,I.g,I.b))},[C,s]);const z=(I,se,fe)=>{I&&(M.current=I),fe&&I&&CP(I),u(I),se&&(d==null||d(I))},E=(I,se,fe)=>{const L=cr(I.r,I.g,I.b);k(Ul(I)),P({r:String(I.r),g:String(I.g),b:String(I.b)}),D(L),z(L,se,fe)},N=(I,se,fe)=>{const L=Vl(I),Le=cr(L.r,L.g,L.b);k(I),P({r:String(L.r),g:String(L.g),b:String(L.b)}),D(Le),z(Le,se,fe)},O=I=>{if(!["ArrowLeft","ArrowRight","ArrowUp","ArrowDown"].includes(I.key))return;const fe=[...I.currentTarget.querySelectorAll("button")],L=fe.findIndex(ze=>ze===document.activeElement);if(L<0)return;I.preventDefault();const Le=I.key==="ArrowLeft"?-1:I.key==="ArrowRight"?1:I.key==="ArrowUp"?-kf:kf,Ee=fe[Math.max(0,Math.min(fe.length-1,L+Le))];Ee==null||Ee.focus()},G=(I,se)=>{const fe=_.current;if(!fe||o)return;const L=fe.getBoundingClientRect(),Le=Math.max(0,Math.min(1,(I.clientX-L.left)/L.width)),Ee=Math.max(0,Math.min(1,1-(I.clientY-L.top)/L.height));N({h:v.h,s:Le,v:Ee},se,se)},Y=I=>{o||(I.currentTarget.setPointerCapture(I.pointerId),G(I,!1))},re=Vl({h:v.h,s:1,v:1}),Z=cr(re.r,re.g,re.b),J=Vl(v),ne=cr(J.r,J.g,J.b),ce=new Set(Sf),X=A.filter(I=>!ce.has(I));return i.jsxs("div",{className:tt.picker,role:a?void 0:"listbox","aria-label":r,"data-color-picker":"",children:[i.jsx("button",{type:"button",className:tt.none,role:h,"aria-checked":a?C===null&&!t:void 0,"aria-selected":a?void 0:C===null&&!t,disabled:o,onClick:()=>z(null,!0,!1),children:n}),i.jsx("div",{className:tt.grid,role:a?"group":"none",onKeyDown:O,children:Sf.map(I=>{const se=C===I;return i.jsx("button",{type:"button",className:tt.swatch,role:h,"aria-label":I,"aria-checked":a?se:void 0,"aria-selected":a?void 0:se,disabled:o,style:{backgroundColor:I},onMouseDown:fe=>fe.preventDefault(),onClick:()=>z(I,!0,!1)},I)})}),X.length>0?i.jsxs(i.Fragment,{children:[i.jsx("p",{className:tt.sectionLabel,children:f("colorRecent")}),i.jsx("div",{className:tt.recents,role:a?"group":"none","aria-label":f("colorRecent"),children:X.map(I=>i.jsx("button",{type:"button",className:tt.swatch,role:h,"aria-label":I,"aria-checked":a?C===I:void 0,"aria-selected":a?void 0:C===I,disabled:o,style:{backgroundColor:I},onMouseDown:se=>se.preventDefault(),onClick:()=>z(I,!0,!1)},I))})]}):null,i.jsx("button",{type:"button",className:tt.customToggle,disabled:o,"aria-expanded":x,onClick:()=>y(I=>!I),children:f("colorCustom")}),x?i.jsxs("div",{className:tt.custom,children:[i.jsx("div",{ref:_,className:tt.sv,style:{background:`linear-gradient(to top, #000, transparent), linear-gradient(to right, #fff, ${Z})`},onPointerDown:Y,onPointerMove:I=>{I.currentTarget.hasPointerCapture(I.pointerId)&&G(I,!1)},onPointerUp:I=>{G(I,!0)},children:i.jsx("span",{className:tt.svThumb,style:{left:`${v.s*100}%`,top:`${(1-v.v)*100}%`}})}),i.jsx("input",{className:tt.hue,type:"range",min:0,max:360,value:Math.round(v.h),disabled:o,"aria-label":f("colorCustom"),onChange:I=>N({...v,h:Number(I.target.value)},!1,!1),onPointerUp:()=>z(M.current,!0,!0)}),i.jsx("div",{className:tt.rgbRow,children:["r","g","b"].map(I=>i.jsxs("div",{className:tt.field,children:[i.jsx("label",{htmlFor:`${g}-${I}`,children:f(I==="r"?"colorRgbR":I==="g"?"colorRgbG":"colorRgbB")}),i.jsx("input",{id:`${g}-${I}`,inputMode:"numeric",value:S[I],disabled:o,onChange:se=>{P(fe=>({...fe,[I]:se.target.value}))},onBlur:()=>{const se=FP(S[I]);if(se===null){P({r:String(J.r),g:String(J.g),b:String(J.b)});return}E({...J,[I]:se},!0,!0)},onKeyDown:se=>{se.key==="Enter"&&se.currentTarget.blur()}})]},I))}),i.jsx("div",{className:tt.hexRow,children:i.jsxs("div",{className:tt.field,children:[i.jsx("label",{htmlFor:`${g}-hex`,children:f("colorHex")}),i.jsx("input",{id:`${g}-hex`,value:R,disabled:o,onChange:I=>D(I.target.value),onBlur:()=>{const I=Ve(R);if(!I){D(ne);return}const se=ya(I);se&&E(se,!0,!0)},onKeyDown:I=>{I.key==="Enter"&&I.currentTarget.blur()}})]})}),Eh()?i.jsx("button",{type:"button",className:tt.eyedrop,disabled:o,onClick:()=>{vP().then(I=>{if(!I)return;const se=ya(I);se&&E(se,!0,!0)})},children:f("colorPickFromScreen")}):null]}):null]})}const HP="_wrap_hfz5s_1",zP="_button_hfz5s_8",OP="_icon_hfz5s_18",KP="_bar_hfz5s_24",$P="_barEmpty_hfz5s_33",UP="_popover_hfz5s_43",ur={wrap:HP,button:zP,icon:OP,bar:KP,barEmpty:$P,popover:UP};function _h({icon:e,value:t,mixed:n,noneKey:r,labelKey:o,ariaKey:a,fallbackCustom:s,disabled:u,onChange:d}){const f=q(),g=l.useId(),h=l.useRef(null),C=l.useRef(null),b=l.useRef(null),[x,y]=l.useState(!1),v=uo(x,C,b);l.useEffect(()=>{if(!x)return;const D=T=>{var M,z;const _=T.target;(M=h.current)!=null&&M.contains(_)||(z=b.current)!=null&&z.contains(_)||y(!1)},A=T=>{var _;T.key==="Escape"&&(T.preventDefault(),T.stopPropagation(),y(!1),(_=C.current)==null||_.focus())};return document.addEventListener("pointerdown",D),document.addEventListener("keydown",A,!0),()=>{document.removeEventListener("pointerdown",D),document.removeEventListener("keydown",A,!0)}},[x]);const k=D=>{d(D)},S=`${ur.bar}${!t||n?` ${ur.barEmpty}`:""}`,P=t&&!n?{backgroundColor:t}:void 0,R=i.jsxs("div",{className:ur.wrap,ref:h,children:[i.jsxs("button",{ref:C,type:"button",className:`${ae.iconButton} ${ur.button}`,"aria-label":f(a),"aria-expanded":x,"aria-haspopup":"listbox","aria-controls":x?g:void 0,disabled:u,onMouseDown:D=>D.preventDefault(),onClick:()=>y(D=>!D),children:[i.jsx(e,{className:`${ae.icon} ${ur.icon}`}),i.jsx("span",{className:S,style:P})]}),x?i.jsx(we,{children:i.jsx("div",{ref:b,id:g,className:ur.popover,style:{top:v.top,left:v.left},children:i.jsx(Du,{value:t,mixed:n,noneLabel:f(r),ariaLabel:f(a),disabled:u,fallbackCustom:s,onChange:k,onCommit:()=>y(!1)})})}):null]});return i.jsx(Wn,{label:f(o),children:R})}function VP({commands:e,queries:t,disabled:n}){return i.jsx(_h,{icon:Of,value:t.getFontColor(),mixed:t.isFontColorMixed(),noneKey:"colorAutomatic",labelKey:"commandFontColor",ariaKey:"commandFontColorAria",disabled:!!(n||!t.isVisualMode()),onChange:r=>e.setFontColor(r)})}const WP="_wrap_1vjt0_1",GP="_wrapToolbar_1vjt0_7",ZP="_field_1vjt0_12",qP="_trigger_1vjt0_20",YP="_chevron_1vjt0_50",XP="_list_1vjt0_73",JP="_listInline_1vjt0_88",QP="_option_1vjt0_96",eT="_separator_1vjt0_125",Yt={wrap:WP,wrapToolbar:GP,field:ZP,trigger:qP,chevron:YP,list:XP,listInline:JP,option:QP,separator:eT};function tT({value:e,mixed:t=!1,fonts:n,disabled:r,listId:o,listRef:a,inline:s,style:u,onSelect:d}){const f=q(),g=!t&&e===null;return i.jsxs("ul",{ref:a,id:o,className:s?`${Yt.list} ${Yt.listInline}`:Yt.list,role:"listbox","aria-label":f("commandFontFamilyAria"),style:u,children:[i.jsx("li",{role:"presentation",children:i.jsx("button",{type:"button",className:Yt.option,role:"option","aria-checked":g,disabled:r,onMouseDown:h=>h.preventDefault(),onClick:()=>d(null),children:f("fontFamilyDefault")})}),i.jsx("li",{className:Yt.separator,role:"separator"}),n.map(h=>{const C=!t&&ni(e,h.family);return i.jsx("li",{role:"presentation",children:i.jsx("button",{type:"button",className:Yt.option,role:"option","aria-checked":C,disabled:r,style:{fontFamily:h.family},onMouseDown:b=>b.preventDefault(),onClick:()=>d(h.family),children:h.name})},h.family)})]})}function nT(e,t,n,r){var o;return t?"":e===null?r:((o=ox(e,n))==null?void 0:o.name)??e}function Mh({family:e,mixed:t=!1,fonts:n,disabled:r,tooltip:o,toolbar:a=!1,triggerId:s,onChange:u}){const d=q(),f=l.useId(),g=l.useRef(null),h=l.useRef(null),C=l.useRef(null),[b,x]=l.useState(!1),y=nT(e,t,n,d("fontFamilyDefault")),v=uo(b,h,C,{matchAnchorWidth:!0,deps:[n.length]});l.useEffect(()=>{if(!b)return;const S=R=>{var A,T;const D=R.target;(A=g.current)!=null&&A.contains(D)||(T=C.current)!=null&&T.contains(D)||x(!1)},P=R=>{R.key==="Escape"&&(R.preventDefault(),R.stopPropagation(),x(!1))};return document.addEventListener("pointerdown",S),document.addEventListener("keydown",P,!0),()=>{document.removeEventListener("pointerdown",S),document.removeEventListener("keydown",P,!0)}},[b]);const k=i.jsxs("div",{className:`${Yt.wrap}${a?` ${Yt.wrapToolbar}`:""}`,ref:g,children:[i.jsxs("div",{className:Yt.field,ref:h,children:[i.jsx("button",{type:"button",id:s,className:Yt.trigger,disabled:r,"aria-label":a?d("commandFontFamilyAria"):void 0,"aria-haspopup":"listbox","aria-expanded":b,"aria-controls":b?f:void 0,style:e&&!t?{fontFamily:e}:void 0,onMouseDown:S=>S.preventDefault(),onClick:()=>x(S=>!S),children:y}),i.jsx("span",{className:Yt.chevron,"aria-hidden":"true"})]}),b?i.jsx(we,{children:i.jsx(tT,{listRef:C,listId:f,value:t?null:e,mixed:t,fonts:n,disabled:r,style:{top:v.top,left:v.left,minWidth:v.width},onSelect:S=>{u(S),x(!1)}})}):null]});return o?i.jsx(Wn,{label:o,children:k}):k}function rT({commands:e,queries:t,disabled:n}){const r=q(),o=!!(n||!t.isVisualMode());return i.jsx(Mh,{family:t.isFontFamilyMixed()?null:t.getFontFamily(),mixed:t.isFontFamilyMixed(),fonts:t.getFontFaces(),disabled:o,tooltip:r("commandFontFamily"),toolbar:!0,onChange:a=>{e.setFontFamily(a)}})}const oT="_wrap_58i0x_1",iT="_wrapToolbar_58i0x_9",aT="_field_58i0x_14",sT="_input_58i0x_22",lT="_toggle_58i0x_41",cT="_chevron_58i0x_42",uT="_unit_58i0x_80",dT="_list_58i0x_110",mT="_option_58i0x_125",Ze={wrap:oT,wrapToolbar:iT,field:aT,input:sT,toggle:lT,chevron:cT,unit:uT,list:dT,option:mT},fT={pt:"fontSizeUnitPt",px:"fontSizeUnitPx",em:"fontSizeUnitEm",rem:"fontSizeUnitRem","%":"fontSizeUnitPercent"};function Nh({size:e,unit:t,onSizeChange:n,onUnitChange:r,disabled:o,tooltip:a,sizeInputId:s,toolbar:u=!1}){const d=q(),f=l.useId(),g=l.useRef(null),h=l.useRef(null),C=l.useRef(null),[b,x]=l.useState(()=>e===null?"":de(e)),[y,v]=l.useState(!1),[k,S]=l.useState(!1),P=uo(k,h,C,{matchAnchorWidth:!0,minWidth:72});l.useEffect(()=>{y||x(e===null?"":de(e))},[e,y]),l.useEffect(()=>{if(!k)return;const _=z=>{var N,O;const E=z.target;(N=g.current)!=null&&N.contains(E)||(O=C.current)!=null&&O.contains(E)||S(!1)},M=z=>{z.key==="Escape"&&(z.preventDefault(),z.stopPropagation(),S(!1))};return document.addEventListener("pointerdown",_),document.addEventListener("keydown",M,!0),()=>{document.removeEventListener("pointerdown",_),document.removeEventListener("keydown",M,!0)}},[k]);const R=_=>{const M=Ax(_,t);if(!M){x(e===null?"":de(e));return}n(M.value,M.unit),x(de(M.value))},D=wx[t],A=k?i.jsx(we,{children:i.jsx("ul",{ref:C,className:Ze.list,role:"listbox",id:f,style:{top:P.top,left:P.left,minWidth:P.width},children:D.map(_=>i.jsx("li",{role:"presentation",children:i.jsx("button",{type:"button",className:Ze.option,role:"option","aria-selected":e===_,onMouseDown:M=>M.preventDefault(),onClick:()=>{n(_,t),x(de(_)),S(!1)},children:de(_)})},_))})}):null,T=i.jsxs("div",{className:`${Ze.wrap}${u?` ${Ze.wrapToolbar}`:""}`,ref:g,children:[i.jsxs("div",{className:Ze.field,ref:h,children:[i.jsx("input",{id:s,className:Ze.input,value:b,disabled:o,"aria-label":d("commandFontSizeAria"),"aria-autocomplete":"list","aria-expanded":k,"aria-controls":f,role:"combobox",inputMode:"decimal",onFocus:()=>v(!0),onBlur:()=>{v(!1),R(b)},onChange:_=>x(_.target.value),onKeyDown:_=>{_.key==="Enter"&&(_.preventDefault(),R(b),S(!1),_.currentTarget.blur()),_.key==="ArrowDown"&&(_.preventDefault(),S(!0))}}),i.jsx("button",{type:"button",className:Ze.toggle,tabIndex:-1,disabled:o,"aria-label":d("commandFontSizeAria"),"aria-expanded":k,"aria-controls":f,onMouseDown:_=>_.preventDefault(),onClick:()=>S(_=>!_)})]}),i.jsxs("div",{className:Ze.field,children:[i.jsx("select",{className:Ze.unit,value:t,disabled:o,"aria-label":d("commandFontSizeUnitAria"),onChange:_=>{r(_.target.value)},children:Uc.map(_=>i.jsx("option",{value:_,children:d(fT[_])},_))}),i.jsx("span",{className:Ze.chevron,"aria-hidden":"true"})]}),A]});return a?i.jsx(Wn,{label:a,children:T}):T}function pT({commands:e,queries:t,disabled:n}){const r=q(),o=!!(n||!t.isVisualMode());return i.jsx(Nh,{size:t.getFontSize(),unit:t.getFontSizeUnit(),disabled:o,tooltip:r("commandFontSize"),toolbar:!0,onSizeChange:(a,s)=>{e.setFontSize(a,s)},onUnitChange:a=>{e.setFontSizeUnit(a)}})}function gT({commands:e,queries:t,disabled:n}){return i.jsx(_h,{icon:Kf,value:t.getHighlightColor(),mixed:t.isHighlightColorMixed(),noneKey:"colorNone",labelKey:"commandHighlightColor",ariaKey:"commandHighlightColorAria",fallbackCustom:"#ffff00",disabled:!!(n||!t.isVisualMode()),onChange:r=>e.setHighlightColor(r)})}function hT({commands:e,queries:t,disabled:n,onMenuClose:r}){const o=q(),a=!!(n||!t.isVisualMode());return i.jsx(Du,{value:t.getHighlightColor(),mixed:t.isHighlightColorMixed(),noneLabel:o("colorNone"),ariaLabel:o("commandHighlightColorAria"),disabled:a,menu:!0,fallbackCustom:"#ffff00",onChange:s=>e.setHighlightColor(s),onCommit:()=>r==null?void 0:r()})}const bT="_wrap_1gtdc_1",yT="_wrapToolbar_1gtdc_7",xT="_field_1gtdc_12",CT="_trigger_1gtdc_20",wT="_chevron_1gtdc_46",vT="_list_1gtdc_69",kT="_option_1gtdc_84",ST="_separator_1gtdc_113",wn={wrap:bT,wrapToolbar:yT,field:xT,trigger:CT,chevron:wT,list:vT,option:kT,separator:ST},AT="_backdrop_1p9zk_1",PT="_dialog_1p9zk_12",TT="_dialogWide_1p9zk_31",RT="_header_1p9zk_35",DT="_tabs_1p9zk_43",jT="_tab_1p9zk_43",IT="_body_1p9zk_76",ET="_field_1p9zk_86",_T="_label_1p9zk_92",MT="_sizeRow_1p9zk_96",NT="_fileRow_1p9zk_102",LT="_fileName_1p9zk_108",BT="_previewImage_1p9zk_115",FT="_marks_1p9zk_125",HT="_mark_1p9zk_125",zT="_actions_1p9zk_140",OT="_actionsSpread_1p9zk_148",KT="_actionsEnd_1p9zk_152",$T="_headerRow_1p9zk_157",UT="_close_1p9zk_170",VT="_nameSection_1p9zk_187",WT="_nameInput_1p9zk_192",GT="_labelRow_1p9zk_209",ZT="_help_1p9zk_215",qT="_textInput_1p9zk_233",YT="_fullSelect_1p9zk_245",XT="_error_1p9zk_249",JT="_emptyHint_1p9zk_254",QT="_action_1p9zk_140",eR="_textarea_1p9zk_265",tR="_actionDanger_1p9zk_279",nR="_confirmBody_1p9zk_285",rR="_nestedPanel_1p9zk_294",oR="_spinnerWrap_1p9zk_309",iR="_spinner_1p9zk_309",aR="_actionPrimary_1p9zk_344",sR="_iconButton_1p9zk_358",lR="_select_1p9zk_359",cR="_lengthInput_1p9zk_360",uR="_lengthUnit_1p9zk_361",dR="_group_1p9zk_369",mR="_nestedGroup_1p9zk_379",fR="_subLabel_1p9zk_389",pR="_iconRow_1p9zk_393",gR="_lengthField_1p9zk_425",hR="_sideLabel_1p9zk_431",bR="_lengthRow_1p9zk_435",yR="_sideGrid_1p9zk_463",xR="_shadowGrid_1p9zk_464",p={backdrop:AT,dialog:PT,dialogWide:TT,header:RT,tabs:DT,tab:jT,body:IT,field:ET,label:_T,sizeRow:MT,fileRow:NT,fileName:LT,previewImage:BT,marks:FT,mark:HT,actions:zT,actionsSpread:OT,actionsEnd:KT,headerRow:$T,close:UT,nameSection:VT,nameInput:WT,labelRow:GT,help:ZT,textInput:qT,fullSelect:YT,error:XT,emptyHint:JT,action:QT,textarea:eR,actionDanger:tR,confirmBody:nR,nestedPanel:rR,spinnerWrap:oR,spinner:iR,actionPrimary:aR,iconButton:sR,select:lR,lengthInput:cR,lengthUnit:uR,group:dR,nestedGroup:mR,subLabel:fR,iconRow:pR,lengthField:gR,sideLabel:hR,lengthRow:bR,sideGrid:yR,shadowGrid:xR},Mc={p:"styleParagraph",h1:"styleHeading1",h2:"styleHeading2",h3:"styleHeading3",h4:"styleHeading4",h5:"styleHeading5",h6:"styleHeading6"},CR={p:{fontSize:"1rem",fontWeight:"400"},h1:{fontSize:"1.75rem",fontWeight:"600"},h2:{fontSize:"1.5rem",fontWeight:"600"},h3:{fontSize:"1.25rem",fontWeight:"600"},h4:{fontSize:"1.125rem",fontWeight:"600"},h5:{fontSize:"1rem",fontWeight:"600"},h6:{fontSize:"0.875rem",fontWeight:"600"}};function Pf(){const e=q();return i.jsx("div",{className:p.spinnerWrap,role:"status","aria-live":"polite","aria-label":e("customStyleLoading"),children:i.jsx("span",{className:p.spinner,"aria-hidden":"true"})})}function Lh({value:e,mixed:t=!1,disabled:n,menu:r=!1,listId:o,listRef:a,style:s,customStylesEnabled:u=!1,customStyles:d=[],customStylesLoading:f=!1,onSelect:g,onSelectCustom:h,onAddNew:C}){const b=q(),x=t?null:e,y=u,v=!!(r&&u&&C);return r?i.jsxs(i.Fragment,{children:[Ka.map(k=>i.jsx("button",{type:"button",className:ae.menuItem,role:"menuitemradio","aria-checked":x===k,disabled:n,onMouseDown:S=>S.preventDefault(),onClick:()=>g(k),children:b(Mc[k])},k)),y?i.jsx("div",{role:"separator",className:ae.menuSeparator}):null,y&&f?i.jsx(Pf,{}):null,y&&!f?d.map(k=>i.jsx("button",{type:"button",className:ae.menuItem,role:"menuitem",disabled:n,onMouseDown:S=>S.preventDefault(),onClick:()=>h==null?void 0:h(k.id),children:k.name},k.id)):null,v?i.jsxs(i.Fragment,{children:[y&&(f||d.length>0)?i.jsx("div",{role:"separator",className:ae.menuSeparator}):null,i.jsxs("button",{type:"button",className:ae.menuItem,role:"menuitem","aria-label":b("styleAddNewAria"),disabled:n,onMouseDown:k=>k.preventDefault(),onClick:()=>C==null?void 0:C(),children:[i.jsx(by,{className:ae.icon}),b("styleAddNew")]})]}):null]}):i.jsxs("ul",{ref:a,className:wn.list,role:"listbox",id:o,style:s,"aria-label":b("commandParagraphStyleAria"),"aria-busy":y&&f?!0:void 0,children:[Ka.map(k=>i.jsx("li",{role:"presentation",children:i.jsx("button",{type:"button",className:wn.option,role:"option","aria-selected":x===k,disabled:n,style:CR[k],onMouseDown:S=>S.preventDefault(),onClick:()=>g(k),children:b(Mc[k])})},k)),y&&(f||d.length>0)?i.jsx("li",{role:"separator",className:wn.separator}):null,y&&f?i.jsx("li",{role:"presentation",children:i.jsx(Pf,{})}):null,y&&!f?d.map(k=>i.jsx("li",{role:"presentation",children:i.jsx("button",{type:"button",className:wn.option,role:"option","aria-selected":!1,disabled:n,onMouseDown:S=>S.preventDefault(),onClick:()=>h==null?void 0:h(k.id),children:k.name})},k.id)):null]})}function wR({commands:e,queries:t,disabled:n}){const r=q(),o=l.useId(),a=l.useRef(null),s=l.useRef(null),u=l.useRef(null),[d,f]=l.useState(!1),g=!!(n||!t.isVisualMode()),h=t.isParagraphStyleMixed(),C=h?null:t.getParagraphStyle(),b=C?r(Mc[C]):"",x=t.customParagraphStylesEnabled(),y=x?t.getCustomParagraphStyles():[],v=x&&t.isCustomParagraphStylesLoading(),k=uo(d,s,u,{matchAnchorWidth:!0,deps:[y.length,v]});l.useEffect(()=>{if(!d)return;const P=D=>{var T,_;const A=D.target;(T=a.current)!=null&&T.contains(A)||(_=u.current)!=null&&_.contains(A)||f(!1)},R=D=>{D.key==="Escape"&&(D.preventDefault(),D.stopPropagation(),f(!1))};return document.addEventListener("pointerdown",P),document.addEventListener("keydown",R,!0),()=>{document.removeEventListener("pointerdown",P),document.removeEventListener("keydown",R,!0)}},[d]);const S=i.jsxs("div",{className:`${wn.wrap} ${wn.wrapToolbar}`,ref:a,children:[i.jsxs("div",{className:wn.field,ref:s,children:[i.jsx("button",{type:"button",className:wn.trigger,disabled:g,"aria-label":r("commandParagraphStyleAria"),"aria-haspopup":"listbox","aria-expanded":d,"aria-controls":d?o:void 0,onMouseDown:P=>P.preventDefault(),onClick:()=>f(P=>!P),children:b}),i.jsx("span",{className:wn.chevron,"aria-hidden":"true"})]}),d?i.jsx(we,{children:i.jsx(Lh,{listRef:u,listId:o,value:C,mixed:h,disabled:g,customStylesEnabled:x,customStyles:y,customStylesLoading:v,style:{top:k.top,left:k.left,minWidth:k.width},onSelect:P=>{e.setParagraphStyle(P),f(!1)},onSelectCustom:P=>{e.applyCustomParagraphStyle(P),f(!1)}})}):null]});return i.jsx(Wn,{label:r("commandParagraphStyle"),children:S})}function vR({commands:e,queries:t,disabled:n,onMenuClose:r}){const o=!!(n||!t.isVisualMode()),a=t.isParagraphStyleMixed(),s=a?null:t.getParagraphStyle(),u=t.customParagraphStylesEnabled(),d=u?t.getCustomParagraphStyles():[],f=u&&t.isCustomParagraphStylesLoading();return i.jsx(Lh,{menu:!0,value:s,mixed:a,disabled:o,customStylesEnabled:u,customStyles:d,customStylesLoading:f,onSelect:g=>{e.setParagraphStyle(g),r==null||r()},onSelectCustom:g=>{e.openCustomParagraphStyleDialog(g),r==null||r()},onAddNew:()=>{e.openCustomParagraphStyleDialog(),r==null||r()}})}const kR={menus:{format:{id:"format",labelKey:"menuFormat",ariaKey:"menuFormatAria"}},submenus:{paragraphStyles:{id:"paragraphStyles",labelKey:"menuParagraphStyles",ariaKey:"menuParagraphStylesAria",panel:vR,enabled:"isVisualMode"},font:{id:"font",labelKey:"menuFont",ariaKey:"menuFontAria"},highlightColor:{id:"highlightColor",labelKey:"commandHighlightColor",ariaKey:"commandHighlightColorAria",panel:hT,enabled:"isVisualMode"},paragraph:{id:"paragraph",labelKey:"menuParagraph",ariaKey:"menuParagraphAria"}},groups:{font:{id:"font",labelKey:"toolbarGroupFont"},align:{id:"align",labelKey:"toolbarGroupAlign"},paragraph:{id:"paragraph",labelKey:"toolbarGroupParagraph"}},items:{fontFamily:{id:"fontFamily",widget:rT,icon:Qb,labelKey:"commandFontFamily",ariaKey:"commandFontFamilyAria",enabled:"isVisualMode"},paragraphStyle:{id:"paragraphStyle",widget:wR,icon:hy,labelKey:"commandParagraphStyle",ariaKey:"commandParagraphStyleAria",enabled:"isVisualMode"},fontSize:{id:"fontSize",widget:pT,icon:ty,labelKey:"commandFontSize",ariaKey:"commandFontSizeAria",enabled:"isVisualMode"},fontProperties:{id:"fontProperties",command:"openFontProperties",icon:ey,labelKey:"commandFontProperties",ariaKey:"commandFontPropertiesAria",enabled:"isVisualMode"},customCss:{id:"customCss",command:"openCustomCss",icon:Yb,labelKey:"commandCustomCss",ariaKey:"commandCustomCssAria",enabled:"isVisualMode"},paragraphProperties:{id:"paragraphProperties",command:"openParagraphProperties",icon:Vf,labelKey:"commandParagraphProperties",ariaKey:"commandParagraphPropertiesAria",enabled:"isVisualMode"},imageProperties:{id:"imageProperties",command:"openImageProperties",icon:$f,labelKey:"menuImage",ariaKey:"menuImageAria",enabled:"isImageSelected"},fontColor:{id:"fontColor",widget:VP,icon:Of,labelKey:"commandFontColor",ariaKey:"commandFontColorAria",enabled:"isVisualMode"},highlightColor:{id:"highlightColor",widget:gT,icon:Kf,labelKey:"commandHighlightColor",ariaKey:"commandHighlightColorAria",enabled:"isVisualMode"},bold:{id:"bold",command:"toggleBold",icon:$b,labelKey:"commandBold",ariaKey:"commandBoldAria",active:"isBold",enabled:"isVisualMode",toggle:!0},italic:{id:"italic",command:"toggleItalic",icon:sy,labelKey:"commandItalic",ariaKey:"commandItalicAria",active:"isItalic",enabled:"isVisualMode",toggle:!0},underline:{id:"underline",command:"toggleUnderline",icon:Ay,labelKey:"commandUnderline",ariaKey:"commandUnderlineAria",active:"isUnderline",enabled:"isVisualMode",toggle:!0},strikethrough:{id:"strikethrough",command:"toggleStrikethrough",icon:Sy,labelKey:"commandStrikethrough",ariaKey:"commandStrikethroughAria",active:"isStrikethrough",enabled:"isVisualMode",toggle:!0},clearFormatting:{id:"clearFormatting",command:"clearFormatting",icon:Wb,labelKey:"commandClearFormatting",ariaKey:"commandClearFormattingAria",enabled:"hasTextSelection"},formatBrush:{id:"formatBrush",command:"toggleFormatBrush",icon:ny,labelKey:"commandFormatBrush",ariaKey:"commandFormatBrushAria",active:"isFormatBrushActive",enabled:"isVisualMode",toggle:!0},alignLeft:{id:"alignLeft",command:"alignLeft",icon:ts,labelKey:"commandAlignLeft",ariaKey:"commandAlignLeftAria",active:"isAlignLeft",enabled:"isVisualMode"},alignCenter:{id:"alignCenter",command:"alignCenter",icon:es,labelKey:"commandAlignCenter",ariaKey:"commandAlignCenterAria",active:"isAlignCenter",enabled:"isVisualMode"},alignRight:{id:"alignRight",command:"alignRight",icon:ns,labelKey:"commandAlignRight",ariaKey:"commandAlignRightAria",active:"isAlignRight",enabled:"isVisualMode"},alignJustify:{id:"alignJustify",command:"alignJustify",icon:Hf,labelKey:"commandAlignJustify",ariaKey:"commandAlignJustifyAria",active:"isAlignJustify",enabled:"isVisualMode"},indent:{id:"indent",command:"indent",icon:ay,labelKey:"commandIndent",ariaKey:"commandIndentAria",enabled:"isVisualMode"},outdent:{id:"outdent",command:"outdent",icon:fy,labelKey:"commandOutdent",ariaKey:"commandOutdentAria",enabled:"canOutdent"},bulletList:{id:"bulletList",command:"toggleBulletList",icon:zf,labelKey:"commandBulletList",ariaKey:"commandBulletListAria",active:"isBulletList",enabled:"isVisualMode",toggle:!0},numberedList:{id:"numberedList",command:"toggleNumberedList",icon:Uf,labelKey:"commandNumberedList",ariaKey:"commandNumberedListAria",active:"isNumberedList",enabled:"isVisualMode",toggle:!0}}},SR={menus:{insert:{id:"insert",labelKey:"menuInsert",ariaKey:"menuInsertAria"}},submenus:{insertPage:{id:"insertPage",labelKey:"menuInsertPage",ariaKey:"menuInsertPageAria",enabled:"hasSelectedPage"}},groups:{insert:{id:"insert",labelKey:"toolbarGroupInsert"}},items:{link:{id:"link",command:"openLinkDialog",icon:cy,labelKey:"commandLink",ariaKey:"commandLinkAria",enabled:"isVisualMode",active:"isLink",toggle:!0},bookmark:{id:"bookmark",command:"openBookmarkDialog",icon:Ub,labelKey:"commandBookmark",ariaKey:"commandBookmarkAria",enabled:"isVisualMode"},image:{id:"image",command:"openImageDialog",icon:$f,labelKey:"commandImage",ariaKey:"commandImageAria",enabled:"isVisualMode"},pageBackgroundImage:{id:"pageBackgroundImage",command:"openPageBackgroundImage",icon:zo,labelKey:"commandPageBackgroundImage",ariaKey:"commandPageBackgroundImageAria",enabled:"canInsertPageBackgroundImage"},paragraphBackgroundImage:{id:"paragraphBackgroundImage",command:"openParagraphBackgroundImage",icon:Vf,labelKey:"commandParagraphBackgroundImage",ariaKey:"commandParagraphBackgroundImageAria",enabled:"canInsertParagraphBackgroundImage"},audio:{id:"audio",command:"openAudioDialog",icon:Kb,labelKey:"commandAudio",ariaKey:"commandAudioAria",enabled:"isVisualMode"},youtube:{id:"youtube",command:"openYoutubeDialog",icon:Dy,labelKey:"commandYoutube",ariaKey:"commandYoutubeAria",enabled:"isVisualMode"},horizontalRule:{id:"horizontalRule",command:"insertHorizontalRule",icon:oy,labelKey:"commandHorizontalRule",ariaKey:"commandHorizontalRuleAria",enabled:"isVisualMode"},pageBreak:{id:"pageBreak",command:"insertPageBreak",icon:py,labelKey:"commandPageBreak",ariaKey:"commandPageBreakAria",enabled:"isVisualMode"},insertPageBefore:{id:"insertPageBefore",command:"insertPageBefore",icon:zo,labelKey:"commandInsertPageBefore",ariaKey:"commandInsertPageBeforeAria",enabled:"hasSelectedPage"},insertPageAfter:{id:"insertPageAfter",command:"insertPageAfter",icon:zo,labelKey:"commandInsertPageAfter",ariaKey:"commandInsertPageAfterAria",enabled:"hasSelectedPage"}}},AR={menus:{table:{id:"table",labelKey:"menuTable",ariaKey:"menuTableAria"}},submenus:{insertRow:{id:"insertRow",labelKey:"menuInsertRow",ariaKey:"menuInsertRowAria",enabled:"isInTable"},insertColumn:{id:"insertColumn",labelKey:"menuInsertColumn",ariaKey:"menuInsertColumnAria",enabled:"isInTable"}},groups:{table:{id:"table",labelKey:"toolbarGroupTable"}},items:{table:{id:"table",command:"openTableDialog",icon:xm,labelKey:"commandTable",ariaKey:"commandTableAria",enabled:"isVisualMode"},insertRowBelow:{id:"insertRowBelow",command:"insertRowBelow",icon:Dl,labelKey:"commandInsertRowBelow",ariaKey:"commandInsertRowBelowAria",enabled:"isInTable"},insertRowBefore:{id:"insertRowBefore",command:"insertRowBefore",icon:Dl,labelKey:"commandInsertRowBefore",ariaKey:"commandInsertRowBeforeAria",enabled:"isInTable"},deleteRow:{id:"deleteRow",command:"deleteRow",icon:Dl,labelKey:"commandDeleteRow",ariaKey:"commandDeleteRowAria",enabled:"isInTable"},insertColumnAfter:{id:"insertColumnAfter",command:"insertColumnAfter",icon:Rl,labelKey:"commandInsertColumnAfter",ariaKey:"commandInsertColumnAfterAria",enabled:"isInTable"},insertColumnBefore:{id:"insertColumnBefore",command:"insertColumnBefore",icon:Rl,labelKey:"commandInsertColumnBefore",ariaKey:"commandInsertColumnBeforeAria",enabled:"isInTable"},deleteColumn:{id:"deleteColumn",command:"deleteColumn",icon:Rl,labelKey:"commandDeleteColumn",ariaKey:"commandDeleteColumnAria",enabled:"isInTable"},mergeCells:{id:"mergeCells",command:"mergeCells",icon:dy,labelKey:"commandMergeCells",ariaKey:"commandMergeCellsAria",enabled:"canMergeCells"},unmergeCells:{id:"unmergeCells",command:"unmergeCells",icon:Ty,labelKey:"commandUnmergeCells",ariaKey:"commandUnmergeCellsAria",enabled:"canUnmergeCells"},tableProperties:{id:"tableProperties",command:"openTableProperties",icon:xm,labelKey:"commandTableProperties",ariaKey:"commandTablePropertiesAria",enabled:"isInTable"},cellProperties:{id:"cellProperties",command:"openCellProperties",icon:Vb,labelKey:"commandCellProperties",ariaKey:"commandCellPropertiesAria",enabled:"isInTable"},rowProperties:{id:"rowProperties",command:"openRowProperties",icon:wy,labelKey:"commandRowProperties",ariaKey:"commandRowPropertiesAria",enabled:"isInTable"}}},PR={menus:{help:{id:"help",labelKey:"menuHelp",ariaKey:"menuHelpAria"}},groups:{},items:{editorHelp:{id:"editorHelp",command:"openHelp",icon:Tl,labelKey:"commandEditorHelp",ariaKey:"commandEditorHelpAria"},keyboardShortcuts:{id:"keyboardShortcuts",command:"openKeyboardShortcuts",icon:Tl,labelKey:"commandKeyboardShortcuts",ariaKey:"commandKeyboardShortcutsAria"},about:{id:"about",command:"openAbout",icon:Tl,labelKey:"commandAbout",ariaKey:"commandAboutAria"}}},TR=["getStarted","file","edit","insert","format","table","view","keyboard"],Nc=[{id:"getStarted",category:"getStarted",titleKey:"helpTopicGetStartedTitle",bodyKey:"helpTopicGetStartedBody",keywordsKey:"helpTopicGetStartedKeywords",related:["switchModes","searchHelp","keyboardShortcuts"]},{id:"switchModes",category:"getStarted",titleKey:"helpTopicSwitchModesTitle",bodyKey:"helpTopicSwitchModesBody",keywordsKey:"helpTopicSwitchModesKeywords",related:["getStarted","preview"]},{id:"searchHelp",category:"getStarted",titleKey:"helpTopicSearchHelpTitle",bodyKey:"helpTopicSearchHelpBody",keywordsKey:"helpTopicSearchHelpKeywords",related:["getStarted","keyboardShortcuts"]},{id:"saveDocument",category:"file",titleKey:"helpTopicSaveDocumentTitle",bodyKey:"helpTopicSaveDocumentBody",keywordsKey:"helpTopicSaveDocumentKeywords",related:["openDocument","printDocument"]},{id:"openDocument",category:"file",titleKey:"helpTopicOpenDocumentTitle",bodyKey:"helpTopicOpenDocumentBody",keywordsKey:"helpTopicOpenDocumentKeywords",related:["saveDocument","printDocument"]},{id:"printDocument",category:"file",titleKey:"helpTopicPrintDocumentTitle",bodyKey:"helpTopicPrintDocumentBody",keywordsKey:"helpTopicPrintDocumentKeywords",related:["saveDocument","preview"]},{id:"undoRedo",category:"edit",titleKey:"helpTopicUndoRedoTitle",bodyKey:"helpTopicUndoRedoBody",keywordsKey:"helpTopicUndoRedoKeywords",related:["keyboardShortcuts","clearFormatting"]},{id:"pageProperties",category:"edit",titleKey:"helpTopicPagePropertiesTitle",bodyKey:"helpTopicPagePropertiesBody",keywordsKey:"helpTopicPagePropertiesKeywords",related:["insertPage","deletePage"]},{id:"deletePage",category:"edit",titleKey:"helpTopicDeletePageTitle",bodyKey:"helpTopicDeletePageBody",keywordsKey:"helpTopicDeletePageKeywords",related:["insertPage","pageProperties"]},{id:"insertTable",category:"insert",titleKey:"helpTopicInsertTableTitle",bodyKey:"helpTopicInsertTableBody",keywordsKey:"helpTopicInsertTableKeywords",related:["tableRowsColumns","mergeCells"]},{id:"insertImage",category:"insert",titleKey:"helpTopicInsertImageTitle",bodyKey:"helpTopicInsertImageBody",keywordsKey:"helpTopicInsertImageKeywords",related:["insertLink","pageProperties"]},{id:"insertLink",category:"insert",titleKey:"helpTopicInsertLinkTitle",bodyKey:"helpTopicInsertLinkBody",keywordsKey:"helpTopicInsertLinkKeywords",related:["insertBookmark","insertImage"]},{id:"insertBookmark",category:"insert",titleKey:"helpTopicInsertBookmarkTitle",bodyKey:"helpTopicInsertBookmarkBody",keywordsKey:"helpTopicInsertBookmarkKeywords",related:["insertLink"]},{id:"insertMedia",category:"insert",titleKey:"helpTopicInsertMediaTitle",bodyKey:"helpTopicInsertMediaBody",keywordsKey:"helpTopicInsertMediaKeywords",related:["insertImage","insertLink"]},{id:"pageBreak",category:"insert",titleKey:"helpTopicPageBreakTitle",bodyKey:"helpTopicPageBreakBody",keywordsKey:"helpTopicPageBreakKeywords",related:["insertPage","printDocument"]},{id:"insertPage",category:"insert",titleKey:"helpTopicInsertPageTitle",bodyKey:"helpTopicInsertPageBody",keywordsKey:"helpTopicInsertPageKeywords",related:["pageBreak","deletePage"]},{id:"insertComment",category:"insert",titleKey:"helpTopicInsertCommentTitle",bodyKey:"helpTopicInsertCommentBody",keywordsKey:"helpTopicInsertCommentKeywords",related:["preview"]},{id:"formatFont",category:"format",titleKey:"helpTopicFormatFontTitle",bodyKey:"helpTopicFormatFontBody",keywordsKey:"helpTopicFormatFontKeywords",related:["paragraphStyles","textColor","keyboardShortcuts"]},{id:"paragraphStyles",category:"format",titleKey:"helpTopicParagraphStylesTitle",bodyKey:"helpTopicParagraphStylesBody",keywordsKey:"helpTopicParagraphStylesKeywords",related:["formatFont","alignLists"]},{id:"textColor",category:"format",titleKey:"helpTopicTextColorTitle",bodyKey:"helpTopicTextColorBody",keywordsKey:"helpTopicTextColorKeywords",related:["formatFont","clearFormatting"]},{id:"alignLists",category:"format",titleKey:"helpTopicAlignListsTitle",bodyKey:"helpTopicAlignListsBody",keywordsKey:"helpTopicAlignListsKeywords",related:["paragraphStyles","formatFont"]},{id:"clearFormatting",category:"format",titleKey:"helpTopicClearFormattingTitle",bodyKey:"helpTopicClearFormattingBody",keywordsKey:"helpTopicClearFormattingKeywords",related:["formatFont","customCss"]},{id:"customCss",category:"format",titleKey:"helpTopicCustomCssTitle",bodyKey:"helpTopicCustomCssBody",keywordsKey:"helpTopicCustomCssKeywords",related:["formatFont","clearFormatting"]},{id:"tableRowsColumns",category:"table",titleKey:"helpTopicTableRowsColumnsTitle",bodyKey:"helpTopicTableRowsColumnsBody",keywordsKey:"helpTopicTableRowsColumnsKeywords",related:["insertTable","mergeCells","keyboardShortcuts"]},{id:"mergeCells",category:"table",titleKey:"helpTopicMergeCellsTitle",bodyKey:"helpTopicMergeCellsBody",keywordsKey:"helpTopicMergeCellsKeywords",related:["insertTable","tableRowsColumns"]},{id:"customizeToolbar",category:"view",titleKey:"helpTopicCustomizeToolbarTitle",bodyKey:"helpTopicCustomizeToolbarBody",keywordsKey:"helpTopicCustomizeToolbarKeywords",related:["zoom","fullscreen"]},{id:"zoom",category:"view",titleKey:"helpTopicZoomTitle",bodyKey:"helpTopicZoomBody",keywordsKey:"helpTopicZoomKeywords",related:["preview","fullscreen"]},{id:"darkMode",category:"view",titleKey:"helpTopicDarkModeTitle",bodyKey:"helpTopicDarkModeBody",keywordsKey:"helpTopicDarkModeKeywords",related:["customizeToolbar"]},{id:"preview",category:"view",titleKey:"helpTopicPreviewTitle",bodyKey:"helpTopicPreviewBody",keywordsKey:"helpTopicPreviewKeywords",related:["printDocument","switchModes"]},{id:"fullscreen",category:"view",titleKey:"helpTopicFullscreenTitle",bodyKey:"helpTopicFullscreenBody",keywordsKey:"helpTopicFullscreenKeywords",related:["zoom","keyboardShortcuts"]},{id:"ruler",category:"view",titleKey:"helpTopicRulerTitle",bodyKey:"helpTopicRulerBody",keywordsKey:"helpTopicRulerKeywords",related:["pageProperties","alignLists"]},{id:"keyboardShortcuts",category:"keyboard",titleKey:"helpTopicKeyboardShortcutsTitle",bodyKey:"helpTopicKeyboardShortcutsBody",keywordsKey:"helpTopicKeyboardShortcutsKeywords",related:["getStarted","undoRedo","formatFont"]}],Tf=Object.fromEntries(Nc.map(e=>[e.id,e]));function Bh(e){return e.trim().toLowerCase().split(/\s+/).filter(Boolean)}function RR(e,t){const n=Bh(t);if(n.length===0)return 1;const r=e.title.toLowerCase(),o=e.body.toLowerCase(),a=e.keywords.toLowerCase(),s=`${r} ${o} ${a}`;let u=0;for(const d of n)r.includes(d)&&(u+=30),a.includes(d)&&(u+=20),o.includes(d)&&(u+=10),s.includes(d)&&(u+=5);return u}function DR(e,t){return Bh(t).length===0?e:e.map(r=>({entry:r,score:RR(r,t)})).filter(({score:r})=>r>0).sort((r,o)=>o.score-r.score||r.entry.title.localeCompare(o.entry.title)).map(({entry:r})=>r)}const jR={menus:{view:{id:"view",labelKey:"menuView",ariaKey:"menuViewAria"}},submenus:{toolbar:{id:"toolbar",labelKey:"menuToolbar",ariaKey:"menuToolbarAria"},toolbarPosition:{id:"toolbarPosition",labelKey:"menuToolbarPosition",ariaKey:"menuToolbarPositionAria"},zoom:{id:"zoom",labelKey:"menuZoom",ariaKey:"menuZoomAria"}},groups:{view:{id:"view",labelKey:"toolbarGroupView"},fullscreen:{id:"fullscreen",labelKey:"toolbarGroupFullscreen"}},items:{visual:{id:"visual",command:"setVisualMode",icon:Ry,labelKey:"modeVisual",ariaKey:"modeVisualAria",active:"isVisualMode"},html:{id:"html",command:"setHtmlMode",icon:iy,labelKey:"modeHtml",ariaKey:"modeHtmlAria",active:"isHtmlMode"},customizeToolbar:{id:"customizeToolbar",command:"openCustomizeToolbar",icon:Xb,labelKey:"commandCustomizeToolbar",ariaKey:"commandCustomizeToolbarAria"},toolbarPositionTop:{id:"toolbarPositionTop",command:"setToolbarPositionTop",labelKey:"toolbarPositionTop",ariaKey:"toolbarPositionTopAria",active:"isToolbarPositionTop"},toolbarPositionLeft:{id:"toolbarPositionLeft",command:"setToolbarPositionLeft",labelKey:"toolbarPositionLeft",ariaKey:"toolbarPositionLeftAria",active:"isToolbarPositionLeft"},toolbarPositionRight:{id:"toolbarPositionRight",command:"setToolbarPositionRight",labelKey:"toolbarPositionRight",ariaKey:"toolbarPositionRightAria",active:"isToolbarPositionRight"},toolbarPositionBottom:{id:"toolbarPositionBottom",command:"setToolbarPositionBottom",labelKey:"toolbarPositionBottom",ariaKey:"toolbarPositionBottomAria",active:"isToolbarPositionBottom"},lightMode:{id:"lightMode",command:"setLightMode",icon:ly,labelKey:"modeLight",ariaKey:"modeLightAria",active:"isLightMode"},darkMode:{id:"darkMode",command:"setDarkMode",icon:Jb,labelKey:"modeDark",ariaKey:"modeDarkAria",active:"isDarkMode"},pageZoomFitWidth:{id:"pageZoomFitWidth",command:"setPageZoomFitWidth",labelKey:"pageZoomFitWidth",ariaKey:"pageZoomFitWidthAria",active:"isPageZoomFitWidth"},pageZoomFitPage:{id:"pageZoomFitPage",command:"setPageZoomFitPage",labelKey:"pageZoomFitPage",ariaKey:"pageZoomFitPageAria",active:"isPageZoomFitPage"},pageZoom50:{id:"pageZoom50",command:"setPageZoom50",labelKey:"pageZoom50",ariaKey:"pageZoom50Aria",active:"isPageZoom50"},pageZoom75:{id:"pageZoom75",command:"setPageZoom75",labelKey:"pageZoom75",ariaKey:"pageZoom75Aria",active:"isPageZoom75"},pageZoom100:{id:"pageZoom100",command:"setPageZoom100",labelKey:"pageZoom100",ariaKey:"pageZoom100Aria",active:"isPageZoom100"},pageZoom125:{id:"pageZoom125",command:"setPageZoom125",labelKey:"pageZoom125",ariaKey:"pageZoom125Aria",active:"isPageZoom125"},pageZoom150:{id:"pageZoom150",command:"setPageZoom150",labelKey:"pageZoom150",ariaKey:"pageZoom150Aria",active:"isPageZoom150"},pageZoom200:{id:"pageZoom200",command:"setPageZoom200",labelKey:"pageZoom200",ariaKey:"pageZoom200Aria",active:"isPageZoom200"},preview:{id:"preview",command:"openDocumentPreview",icon:gy,labelKey:"commandPreview",ariaKey:"commandPreviewAria"},ruler:{id:"ruler",command:"toggleRuler",icon:vy,labelKey:"commandRuler",ariaKey:"commandRulerAria",active:"isRulerVisible",toggle:!0},readAloud:{id:"readAloud",command:"toggleReadAloud",icon:xy,labelKey:"commandReadAloud",ariaKey:"commandReadAloudAria",active:"isReadingAloud",toggle:!0,enabled:"canReadAloud"},fullscreen:{id:"fullscreen",command:"toggleFullscreen",icon:ry,labelKey:"modeFullscreen",ariaKey:"modeFullscreenAria",active:"isFullscreen",toggle:!0}}};function IR(...e){return{menus:Object.assign({},...e.map(t=>t.menus)),submenus:Object.assign({},...e.map(t=>t.submenus??{})),groups:Object.assign({},...e.map(t=>t.groups)),items:Object.assign({},...e.map(t=>t.items))}}const ER=IR(KA,cA,SR,AR,jR,kR,PR),_R={menus:[{id:"file",items:["save","open",Ce,"print"]},{id:"edit",items:["undo","redo",Ce,{submenu:"page",items:["pageProperties",Ce,"deletePage"]}]},{id:"view",items:["visual","html",Ce,{submenu:"toolbar",items:["customizeToolbar",Ce,{submenu:"toolbarPosition",items:["toolbarPositionTop","toolbarPositionLeft","toolbarPositionRight","toolbarPositionBottom"]}]},Ce,{submenu:"zoom",items:["pageZoomFitWidth","pageZoomFitPage",Ce,"pageZoom50","pageZoom75","pageZoom100","pageZoom125","pageZoom150","pageZoom200"]},Ce,"lightMode","darkMode",Ce,"toggleCommentsVisible","ruler","preview","readAloud","fullscreen"]},{id:"insert",items:["pageBreak",{submenu:"insertPage",items:["insertPageBefore","insertPageAfter"]},Ce,"table",Ce,"image","pageBackgroundImage","paragraphBackgroundImage","audio","youtube","horizontalRule",Ce,"link","bookmark",Ce,"insertComment"]},{id:"format",items:[{submenu:"paragraphStyles",items:[]},Ce,{submenu:"font",items:["fontProperties","customCss",Ce,{submenu:"highlightColor",items:[]},Ce,"bold","italic","underline","strikethrough"]},Ce,"clearFormatting",Ce,{submenu:"paragraph",items:["paragraphProperties",Ce,"alignLeft","alignCenter","alignRight","alignJustify",Ce,"indent","outdent",Ce,"bulletList","numberedList"]},Ce,"imageProperties"]},{id:"table",items:["table",Ce,{submenu:"insertRow",items:["insertRowBefore","insertRowBelow","deleteRow"]},{submenu:"insertColumn",items:["insertColumnBefore","insertColumnAfter","deleteColumn"]},Ce,"mergeCells","unmergeCells",Ce,"tableProperties","rowProperties","cellProperties"]},{id:"help",items:["editorHelp","keyboardShortcuts",Ce,"about"]}],iconGroups:[{id:"file",items:["save","open"]},{id:"print",items:["print"]},{id:"edit",items:["undo","redo"]},{id:"insert",items:["link","bookmark","image","table","horizontalRule","addComment"]},{id:"table",items:["mergeCells","unmergeCells"]},{id:"font",items:["fontFamily","paragraphStyle","fontSize","fontColor","highlightColor","customCss","formatBrush","bold","italic","underline","strikethrough","clearFormatting"]},{id:"align",items:["alignLeft","alignCenter","alignRight","alignJustify"]},{id:"paragraph",items:["indent","outdent","bulletList","numberedList"]},{id:"view",items:["visual","html","preview","readAloud","toggleCommentsVisible"]},{id:"fullscreen",items:["fullscreen"]}]},Rf={items:{addComment:{id:"addComment",command:"addComment",icon:ym,labelKey:"commandAddComment",ariaKey:"commandAddCommentAria",enabled:"canAddComment"},insertComment:{id:"insertComment",command:"addComment",icon:ym,labelKey:"commandInsertComment",ariaKey:"commandInsertCommentAria",enabled:"canAddComment"},toggleCommentsVisible:{id:"toggleCommentsVisible",command:"toggleCommentsVisible",icon:Gb,labelKey:"showComments",ariaKey:"toggleCommentsVisibleAria",toggle:!0,active:"areCommentsVisible"}}},MR=["addComment","insertComment","toggleCommentsVisible"],NR=new Set(["insert","view"]);function Fh(e,t){return t.disabled?!0:t.readOnly?t.enableComments?!MR.includes(e):!0:!1}function LR(e,t){return t.disabled?!0:t.readOnly?t.enableComments?!NR.has(e):!0:!1}function BR(e,t){const n=t?"hideComments":"showComments",r=Rf.items.toggleCommentsVisible;return{...e,items:{...e.items,...Rf.items,toggleCommentsVisible:r&&{...r,labelKey:n}}}}function FR(e){return{...e,menus:e.menus.map(t=>{if(t.id==="insert"){const n=[...t.items],r=n.findIndex(a=>Kn(a)&&a.submenu==="insertPage"),o=r===-1?n.length:r;return n.includes("insertComment")||n.splice(o,0,"insertComment"),{...t,items:n}}if(t.id==="view"){const n=[...t.items],r=n.indexOf("preview"),o=r===-1?n.length:r;return n.includes("toggleCommentsVisible")||n.splice(o,0,"toggleCommentsVisible"),{...t,items:n}}return t}),iconGroups:e.iconGroups.map(t=>t.id==="insert"&&!t.items.includes("addComment")?{...t,items:[...t.items,"addComment"]}:t.id==="view"&&!t.items.includes("toggleCommentsVisible")?{...t,items:[...t.items,"toggleCommentsVisible"]}:t)}}const Df={canUndo:"history",canRedo:"history",isBold:"marks",isItalic:"marks",isUnderline:"marks",isStrikethrough:"marks",getFontSize:"marks",getFontSizeUnit:"marks",isFontSizeMixed:"marks",getFontFamily:"marks",isFontFamilyMixed:"marks",getFontColor:"marks",isFontColorMixed:"marks",getHighlightColor:"marks",isHighlightColorMixed:"marks",getParagraphStyle:"marks",isParagraphStyleMixed:"marks",isAlignLeft:"marks",isAlignCenter:"marks",isAlignRight:"marks",isAlignJustify:"marks",canOutdent:"marks",isBulletList:"marks",isNumberedList:"marks",isFormatBrushActive:"marks",isInTable:"table",canMergeCells:"table",canUnmergeCells:"table",hasTextSelection:"selection",isImageSelected:"selection",isLink:"selection",canReadAloud:"selection",isReadingAloud:"selection"};function HR(){const e={history:0,marks:0,table:0,selection:0,chrome:0},t=new Map;function n(r,o){let a=t.get(r);return a||(a=new Set,t.set(r,a)),a.add(o),()=>{a==null||a.delete(o)}}return{subscribe:n,getSnapshot:r=>e[r],bump(r){e[r]+=1;const o=t.get(r);if(o)for(const a of o)a()}}}function Hh(e){const t=new Set;return e.active&&t.add(Df[e.active]??"chrome"),e.enabled&&t.add(Df[e.enabled]??"chrome"),t.size===0&&t.add("chrome"),[...t]}const zh=l.createContext(null);function zR({value:e,children:t}){return i.jsx(zh.Provider,{value:e,children:t})}function Oh(e){const t=l.useContext(zh),n=l.useMemo(()=>e.join("\0"),[e]),r=l.useMemo(()=>e,[n,e]);l.useSyncExternalStore(o=>{if(!t)return()=>{};const a=r.map(s=>t.subscribe(s,o));return()=>{for(const s of a)s()}},()=>{if(!t)return 0;let o=0;for(const a of r)o+=t.getSnapshot(a);return o},()=>{if(!t)return 0;let o=0;for(const a of r)o+=t.getSnapshot(a);return o})}const xa="fullscreen";function OR(e){const t=[];let n=null;for(const r of e){const o=r.items.filter(a=>a!==xa);o.length>0&&t.push({id:r.id,items:o}),r.items.includes(xa)&&(n={id:xa,items:[xa]})}return{main:t,trailing:n}}const KR=l.memo(function({item:t,itemId:n,commands:r,queries:o,disabled:a,chromeLock:s}){const u=q(),d=l.useMemo(()=>Hh(t),[t]);if(Oh(d),!t.icon||!t.command)return null;const f=t.icon,g=t.command,h=t.enabled?!o[t.enabled]():!1,C=t.active?o[t.active]():void 0;return i.jsx(Wn,{label:t.tooltip??Vn(u,t),children:i.jsx("button",{type:"button",className:ae.iconButton,"aria-label":Ya(u,t),"aria-pressed":C,disabled:a||(s?Fh(n,s):!1)||h,onPointerDown:b=>b.preventDefault(),onMouseDown:b=>b.preventDefault(),onClick:()=>{Hc(r,g)},children:i.jsx(f,{className:ae.icon})})})});function $R({groups:e,catalog:t,commands:n,queries:r,disabled:o,chromeLock:a}){const s=q(),{main:u,trailing:d}=OR(e),f=g=>{const h=t.groups[g.id];return i.jsx("div",{className:ae.iconGroup,role:"group","aria-label":h?Vn(s,h):void 0,"data-toolbar-group":g.id,children:g.items.map(C=>{const b=t.items[C];if(!b)return null;const x=b.enabled?!r[b.enabled]():!1;if(b.widget){const y=b.widget;return i.jsx(y,{commands:n,queries:r,disabled:o||x},C)}return!b.icon||!b.command?null:i.jsx(KR,{itemId:C,item:b,commands:n,queries:r,disabled:o,chromeLock:a},C)})},g.id)};return i.jsxs("div",{className:ae.iconNav,role:"toolbar","aria-label":s("toolbarAria"),children:[u.length>0?i.jsx("div",{className:ae.iconNavMain,children:u.map(f)}):null,d?i.jsx("div",{className:ae.iconNavEnd,children:f(d)}):null]})}const UR=["--wysiwyg-menu-color","--wysiwyg-menu-background","--wysiwyg-menu-font-size","--wysiwyg-menu-font-family"];function VR(e){const t={};for(const n of UR){const r=getComputedStyle(e).getPropertyValue(n).trim();if(r){t[n]=r;continue}let o=e;for(;o;){const a=o.style.getPropertyValue(n).trim();if(a){t[n]=a;break}o=o.parentElement}}return t}function WR({menus:e,catalog:t,commands:n,queries:r,disabled:o,chromeLock:a,compact:s,openMenuId:u,onOpenMenuIdChange:d}){const f=q(),[g,h]=l.useState(!1),[C,b]=l.useState({}),x=l.useRef(null),y=l.useRef(null),v=l.useRef(null),k=l.useRef(null),S=l.useCallback(()=>{h(!1),d(null)},[d]);l.useLayoutEffect(()=>{!g||!x.current||b(VR(x.current))},[g]),l.useEffect(()=>{var R;g&&((R=v.current)==null||R.focus())},[g]),l.useEffect(()=>{if(!g)return;const R=document.body.style.overflow;return document.body.style.overflow="hidden",()=>{document.body.style.overflow=R}},[g]),l.useEffect(()=>{if(!g)return;const R=A=>{var T;if(A.key==="Escape"){if(A.preventDefault(),A.stopPropagation(),u){d(null);return}S(),(T=y.current)==null||T.focus()}},D=A=>{var T;k.current&&!k.current.contains(A.target)&&(S(),(T=y.current)==null||T.focus())};return document.addEventListener("keydown",R,!0),document.addEventListener("pointerdown",D),()=>{document.removeEventListener("keydown",R,!0),document.removeEventListener("pointerdown",D)}},[g,u,d,S]);const P=R=>e.map(D=>{const A=t.menus[D.id];return A?i.jsx(ZR,{def:A,itemIds:D.items,catalog:t,commands:n,queries:r,disabled:o,chromeLock:a,variant:R,open:(R==="overlay"||!g)&&u===D.id,onOpenChange:T=>d(T?D.id:null),onItemRun:R==="overlay"?()=>{var T;S(),(T=y.current)==null||T.focus()}:void 0},`${R}-${D.id}`):null});return i.jsxs("div",{className:ae.menuBar,ref:x,children:[i.jsx(Wn,{label:f("brandMarkAria"),children:i.jsx("span",{className:ae.brandMark,role:"img","aria-label":f("brandMarkAria"),children:i.jsx(Zb,{className:ae.brandMarkIcon})})}),i.jsx("div",{className:ae.menuBarCompact,hidden:s===void 0?void 0:!s,children:i.jsx(Wn,{label:f("menuHamburgerAria"),children:i.jsx("button",{ref:y,type:"button",className:`${ae.menuButton} ${ae.hamburgerButton}`,"aria-haspopup":"dialog","aria-expanded":g,"aria-label":f("menuHamburgerAria"),disabled:o||(a==null?void 0:a.readOnly)&&!(a!=null&&a.enableComments),onClick:()=>{if(g){S();return}d(null),h(!0)},children:i.jsx(uy,{className:ae.icon})})})}),i.jsx("div",{className:ae.menuBarDesktop,hidden:s===void 0?void 0:s,children:P("dropdown")}),g?i.jsx(we,{children:i.jsx("div",{className:ae.toolbar,"data-menu-overlay-portal":"",style:C,children:i.jsxs("div",{ref:k,className:ae.menuOverlay,role:"dialog","aria-modal":"true","aria-label":f("menuOverlayAria"),children:[i.jsxs("div",{className:ae.menuOverlayHeader,children:[i.jsx("span",{className:ae.menuOverlayTitle,children:f("menuOverlayAria")}),i.jsx("button",{ref:v,type:"button",className:ae.iconButton,"aria-label":f("menuCloseAria"),onClick:()=>{var R;S(),(R=y.current)==null||R.focus()},children:i.jsx(et,{className:ae.icon})})]}),i.jsx("div",{className:ae.menuOverlayBody,children:P("overlay")})]})})}):null]})}function Xa(e,t){var n,r;if(On(e))return!1;if(Kn(e)){const o=(n=t.submenus)==null?void 0:n[e.submenu];return o?o.panel?!0:e.items.some(a=>Xa(a,t)):!1}return!!((r=t.items[e])!=null&&r.command)}function GR(e,t,n){if(!On(e[t])||!e.slice(t+1).some(a=>Xa(a,n)))return!1;let o=!1;for(let a=t-1;a>=0;a--){const s=e[a];if(On(s)){o=!0;continue}if(Xa(s,n))return!o}return!1}function ZR({def:e,itemIds:t,catalog:n,commands:r,queries:o,disabled:a,chromeLock:s,variant:u,open:d,onOpenChange:f,onItemRun:g}){const h=q(),C=l.useRef(null),b=u==="overlay"?`overlay-${e.id}-menu`:`${e.id}-menu`,[x,y]=l.useState(null);l.useEffect(()=>{d||y(null)},[d]),l.useEffect(()=>{if(!d||u==="overlay")return;const k=P=>{C.current&&!C.current.contains(P.target)&&f(!1)},S=P=>{if(P.key==="Escape"){if(P.preventDefault(),P.stopPropagation(),x){y(null);return}f(!1)}};return document.addEventListener("pointerdown",k),document.addEventListener("keydown",S,!0),()=>{document.removeEventListener("pointerdown",k),document.removeEventListener("keydown",S,!0)}},[d,x,f,u]);const v=()=>{f(!1),g==null||g()};return i.jsxs("div",{className:ae.menuWrap,ref:C,children:[i.jsx("button",{type:"button",className:ae.menuButton,"aria-haspopup":"menu","aria-expanded":d,"aria-controls":b,"aria-label":Ya(h,e),disabled:a||(s?LR(e.id,s):!1),onClick:()=>f(!d),children:Vn(h,e)}),d?i.jsx("div",{className:ae.menu,role:"menu",id:b,onMouseDown:k=>k.preventDefault(),children:i.jsx(Kh,{entries:t,catalog:n,commands:r,queries:o,disabled:a,chromeLock:s,variant:u,onClose:v,openSubmenuId:x,onOpenSubmenuIdChange:y})}):null]})}function Kh({entries:e,catalog:t,commands:n,queries:r,disabled:o,chromeLock:a,variant:s,onClose:u,openSubmenuId:d,onOpenSubmenuIdChange:f}){return i.jsx(i.Fragment,{children:e.map((g,h)=>{if(On(g))return GR(e,h,t)?i.jsx("div",{role:"separator",className:ae.menuSeparator},`separator-${h}`):null;if(Kn(g))return i.jsx(YR,{entry:g,catalog:t,commands:n,queries:r,disabled:o,chromeLock:a,variant:s,onClose:u,open:d===g.submenu,onOpenChange:b=>f==null?void 0:f(b?g.submenu:null)},`submenu-${g.submenu}-${h}`);const C=t.items[g];return!C||!C.command?null:i.jsx(qR,{item:C,commands:n,queries:r,disabled:o,chromeLock:a,onClose:u},g)})})}function qR({item:e,commands:t,queries:n,disabled:r,chromeLock:o,onClose:a}){const s=q(),u=l.useMemo(()=>Hh(e),[e]);if(Oh(u),!e.command)return null;const d=e.icon,f=e.command,g=e.active?n[e.active]():void 0,h=e.enabled?!n[e.enabled]():!1,C=e.toggle?"menuitemcheckbox":e.active?"menuitemradio":"menuitem";return i.jsxs("button",{type:"button",role:C,className:ae.menuItem,"aria-checked":g,disabled:r||(o?Fh(e.id,o):!1)||h,onClick:()=>{a(),Hc(t,f)},children:[d?i.jsx(d,{className:ae.icon}):null,Vn(s,e)]})}function YR({entry:e,catalog:t,commands:n,queries:r,disabled:o,chromeLock:a,variant:s,onClose:u,open:d,onOpenChange:f}){var A;const g=q(),h=l.useRef(null),C=l.useRef(null),[b,x]=l.useState(null),y=(A=t.submenus)==null?void 0:A[e.submenu],v=s==="overlay"?`overlay-${e.submenu}-submenu`:`${e.submenu}-submenu`,k=y==null?void 0:y.panel,S=y!=null&&y.enabled?!r[y.enabled]():!1,P=s==="overlay";if(l.useEffect(()=>{d||x(null)},[d]),!y||!k&&!e.items.some(T=>Xa(T,t)))return null;const R=T=>{(T.key==="ArrowRight"||T.key==="Enter"||T.key===" ")&&(T.preventDefault(),T.stopPropagation(),f(!0),requestAnimationFrame(()=>{var M;const _=(M=C.current)==null?void 0:M.querySelector('[role="menuitem"], [role="menuitemcheckbox"], [role="menuitemradio"], [role="option"]');_==null||_.focus()}))},D=T=>{var _;T.key==="ArrowLeft"&&(T.preventDefault(),T.stopPropagation(),f(!1),(_=h.current)==null||_.focus())};return i.jsxs("div",{className:ae.submenuWrap,onMouseEnter:P?void 0:()=>f(!0),onMouseLeave:P?void 0:()=>f(!1),children:[i.jsx("button",{ref:h,type:"button",role:"menuitem",className:`${ae.menuItem} ${ae.submenuTrigger}`,"aria-haspopup":"menu","aria-expanded":d,"aria-controls":v,"aria-label":Ya(g,y),disabled:o||S||(a==null?void 0:a.readOnly)&&!(a!=null&&a.enableComments),onClick:()=>f(P?!d:!0),onKeyDown:R,children:Vn(g,y)}),d?i.jsx("div",{ref:C,className:`${ae.menu} ${ae.submenu}`,role:"menu",id:v,"aria-label":Ya(g,y),onMouseDown:T=>T.preventDefault(),onKeyDown:D,children:k?i.jsx(k,{commands:n,queries:r,disabled:o||S,onMenuClose:u}):i.jsx(Kh,{entries:e.items,catalog:t,commands:n,queries:r,disabled:o,chromeLock:a,variant:s,onClose:u,openSubmenuId:b,onOpenSubmenuIdChange:x})}):null]})}const Lc=l.memo(function({catalog:t,layout:n,commands:r,queries:o,queryRevisions:a,disabled:s,chromeLock:u,menuVisible:d=!0,toolbarVisible:f=!0,compact:g,position:h="top"}){const[C,b]=l.useState(null);if(!d&&!f)return null;const x=i.jsxs("div",{className:ae.toolbar,"data-compact":g?"":void 0,"data-toolbar-position":h,children:[d?i.jsx(WR,{menus:n.menus,catalog:t,commands:r,queries:o,disabled:s,chromeLock:u,compact:g,openMenuId:C,onOpenMenuIdChange:b}):null,f?i.jsx($R,{groups:n.iconGroups,catalog:t,commands:r,queries:o,disabled:s,chromeLock:u}):null]});return a?i.jsx(zR,{value:a,children:x}):x});function XR(e,t){return t?e:{...e,menus:e.menus.map(n=>n.id==="insert"?{...n,items:n.items.filter(r=>!(Kn(r)&&r.submenu==="insertPage"))}:n.id==="edit"?{...n,items:n.items.map(r=>{if(!Kn(r)||r.submenu!=="page")return r;let o=r.items.filter(a=>a!=="deletePage");return o.at(-1)===Ce&&(o=o.slice(0,-1)),{...r,items:o}})}:n)}}function ei(e){return Hp(st(e))}const JR=1.5,Wl=384;function QR(e,t=16){return e>0?JR*t:0}function $h(e,t,n=16){const r=QR(t,n);if(!ei(e))return Wl+r;const o=st(e),a=lo(o,!1);return a?Nn(a.height,Wl)+r:Wl+r}function Ca(e,t){const n=[0];for(let r=0;r<e;r+=1)n.push(n[r]+t(r));return n}function eD(){const e=new Map;return{get(t,n){return e.get(t)??$h(n,t)},set(t,n){n>0&&e.set(t,n)},clear(){e.clear()},invalidateFrom(t){for(const n of[...e.keys()])n>=t&&e.delete(n)}}}const tD=2;function nD(e,t,n){if(n<=0)return 0;let r=0,o=n-1,a=0;for(;r<=o;){const s=r+o>>1;(t[s+1]??0)>e?(a=s,o=s-1):r=s+1}return a}function rD(e,t,n){if(n<=0)return-1;let r=0,o=n-1,a=n-1;for(;r<=o;){const s=r+o>>1;(t[s]??0)<e?(a=s,r=s+1):o=s-1}return a}function jf(e,t,n,r,o,a,s){if(r<=0)return{startIndex:0,endIndex:-1,topSpacerHeight:0,bottomSpacerHeight:0};const u=n[r]??0;if(u<=t)return{startIndex:0,endIndex:r-1,topSpacerHeight:0,bottomSpacerHeight:0};const d=e+t,f=nD(e,n,r),g=rD(d,n,r);let h=Math.max(0,f-o),C=Math.min(r-1,g+o);s&&(h=Math.min(h,a),C=Math.max(C,a));const b=n[h]??0,x=u-(n[C+1]??u);return{startIndex:h,endIndex:C,topSpacerHeight:b,bottomSpacerHeight:x}}function oD({scrollElementRef:e,pageCount:t,getRowHeight:n,overscan:r=tD,activePageIndex:o,pinActivePage:a=!0}){const s=l.useRef(n);s.current=n;const u=l.useRef(new Map),[d,f]=l.useState(0);l.useLayoutEffect(()=>{u.current.clear()},[t]);const g=l.useCallback(S=>{const P=u.current.get(S),R=s.current(S);return P!==void 0?Math.max(P,R):R},[d]),h=l.useMemo(()=>Ca(t,g),[t,g]),[C,b]=l.useState(()=>{const S=Ca(t,P=>s.current(P));return jf(0,300,S,t,r,o,a)}),x=l.useCallback(()=>{const S=e.current;if(!S||t<=0)return;const P=S.clientHeight>0?S.clientHeight:300,R=Ca(t,g);b(jf(S.scrollTop,P,R,t,r,o,a))},[o,r,t,a,g,e]);l.useLayoutEffect(()=>{x()},[x,h,o,t]),l.useLayoutEffect(()=>{const S=e.current;if(!S)return;const P=()=>x();S.addEventListener("scroll",P,{passive:!0});let R;return typeof ResizeObserver<"u"&&(R=new ResizeObserver(()=>x()),R.observe(S)),x(),()=>{S.removeEventListener("scroll",P),R==null||R.disconnect()}},[e,x]);const y=l.useCallback((S,P)=>{if(P<=0)return;const R=u.current.get(S);R!==void 0&&Math.abs(R-P)<1||(u.current.set(S,P),f(D=>D+1))},[]),v=l.useCallback(S=>{const P=e.current;if(!P||S<0||S>=t)return;const R=Ca(t,g);P.scrollTop=R[S]??0,x()},[t,g,e,x]),k=l.useMemo(()=>{if(C.endIndex<C.startIndex)return[];const S=[];for(let P=C.startIndex;P<=C.endIndex;P+=1)S.push(P);return S},[C.endIndex,C.startIndex]);return{...C,visibleIndices:k,scrollToIndex:v,notifyRowMeasured:y}}function ju(){return{firstLineIndentPx:0,leftIndentPx:0,rightIndentPx:0,mixed:!1}}function Ja(e){const t=An(e);if(t.length===0)return ju();let n=null,r=null,o=null,a=!1;for(const s of t){const u=s.style.textIndent,d=s.style.marginLeft,f=s.style.marginRight,g=u?Nn(u,0):0,h=d?Nn(d,0):0,C=f?Nn(f,0):0;n===null?(n=g,r=h,o=C):(Math.abs(n-g)>1||Math.abs((r??0)-h)>1||Math.abs((o??0)-C)>1)&&(a=!0)}return{firstLineIndentPx:n??0,leftIndentPx:r??0,rightIndentPx:o??0,mixed:a}}function iD(e){var r;const t=(r=window.getSelection())==null?void 0:r.getRangeAt(0);if(!t)return null;let n=t.startContainer;for(n.nodeType===Node.TEXT_NODE&&(n=n.parentNode);n&&n!==e&&n!==document.body;){if(n instanceof HTMLElement){const o=n.tagName.toLowerCase();if(["p","h1","h2","h3","h4","h5","h6","li","blockquote","div"].includes(o))return n}n=n.parentNode}return null}function aD(e,t){return Yn(e,()=>{let n=xr(e);if(n.length===0){const a=iD(e);a&&(n=[a])}if(n.length===0)return!1;const r=t.unit??"in";let o=!1;for(const a of n){if(t.firstLineIndentPx!==void 0)if(Math.abs(t.firstLineIndentPx)<.5)a.style.textIndent&&(a.style.removeProperty("text-indent"),o=!0);else{const s=Ie(Nl(t.firstLineIndentPx,r));a.style.textIndent!==s&&(a.style.textIndent=s,o=!0)}if(t.leftIndentPx!==void 0)if(t.leftIndentPx<=.5)a.style.marginLeft&&(a.style.removeProperty("margin-left"),o=!0);else{const s=Ie(Nl(t.leftIndentPx,r));a.style.marginLeft!==s&&(a.style.marginLeft=s,o=!0)}if(t.rightIndentPx!==void 0)if(t.rightIndentPx<=.5)a.style.marginRight&&(a.style.removeProperty("margin-right"),o=!0);else{const s=Ie(Nl(t.rightIndentPx,r));a.style.marginRight!==s&&(a.style.marginRight=s,o=!0)}kt(a)}return o})}const Uh=24,Uo=48;function Vh(e,t){const n=oi(st(t));return{pageWidthPx:e.offsetWidth,pageHeightPx:e.offsetHeight,marginsPx:{top:Nn(n.top,0),right:Nn(n.right,0),bottom:Nn(n.bottom,0),left:Nn(n.left,0)}}}function sD(e,t){const n=Object.keys(t);return Object.keys(e).length!==n.length?!1:n.every(r=>{const o=e[Number(r)],a=t[Number(r)];return(o==null?void 0:o.pageWidthPx)===a.pageWidthPx&&(o==null?void 0:o.pageHeightPx)===a.pageHeightPx&&(o==null?void 0:o.marginsPx.top)===a.marginsPx.top&&(o==null?void 0:o.marginsPx.right)===a.marginsPx.right&&(o==null?void 0:o.marginsPx.bottom)===a.marginsPx.bottom&&(o==null?void 0:o.marginsPx.left)===a.marginsPx.left})}function lD(e,t,n,r,o=!0,a=1){const[s,u]=l.useState({}),[d,f]=l.useState(ju()),g=l.useCallback(C=>s[C]??null,[s]),h=l.useCallback(()=>{const C=e.current;if(!o||!C)return;const b={};for(const y of n){const v=nt(C,y);if(!v)continue;const k=t[y]??t[0]??"";b[y]=Vh(v,k)}u(y=>{const v={...y,...b};return sD(y,v)?y:v});const x=nt(C,r());x&&f(Ja(x))},[e,o,r,n,t]);return l.useLayoutEffect(()=>{if(!o)return;const C=requestAnimationFrame(h);return()=>cancelAnimationFrame(C)},[o,r,n,t,a,h]),l.useLayoutEffect(()=>{if(!o||typeof ResizeObserver>"u")return;const C=e.current;if(!C)return;const b=new ResizeObserver(()=>h());for(const x of n){const y=nt(C,x);y&&b.observe(y)}return()=>b.disconnect()},[e,o,n,h]),l.useLayoutEffect(()=>{if(!o)return;const C=()=>{const b=e.current;if(!b)return;const x=nt(b,r());x&&f(Ja(x))};return document.addEventListener("selectionchange",C),()=>document.removeEventListener("selectionchange",C)},[e,o,r]),{pageGeometries:s,geometryForPage:g,indentState:d,refresh:h}}const cD="_rulerRoot_j57vt_5",uD="_horizontalRulerGroup_j57vt_22",dD="_horizontalRulerTrack_j57vt_28",mD="_horizontalRulerShelf_j57vt_42",fD="_horizontalInner_j57vt_51",pD="_dragEdgeLeft_j57vt_63",gD="_dragEdgeRight_j57vt_73",hD="_dragEdgeActive_j57vt_85",bD="_verticalRuler_j57vt_92",yD="_verticalInner_j57vt_102",xD="_dragEdgeTop_j57vt_114",CD="_dragEdgeBottom_j57vt_124",wD="_dragEdgeActiveV_j57vt_136",vD="_tickH_j57vt_143",kD="_tickV_j57vt_152",SD="_tickLabelH_j57vt_161",AD="_tickLabelV_j57vt_175",PD="_arrowIconWrapper_j57vt_192",TD="_arrowDown_j57vt_203",RD="_arrowGlyph_j57vt_211",DD="_arrowActive_j57vt_220",jD="_arrowUp_j57vt_225",ID="_rulerTooltip_j57vt_249",Ae={rulerRoot:cD,horizontalRulerGroup:uD,horizontalRulerTrack:dD,horizontalRulerShelf:mD,horizontalInner:fD,dragEdgeLeft:pD,dragEdgeRight:gD,dragEdgeActive:hD,verticalRuler:bD,verticalInner:yD,dragEdgeTop:xD,dragEdgeBottom:CD,dragEdgeActiveV:wD,tickH:vD,tickV:kD,tickLabelH:SD,tickLabelV:AD,arrowIconWrapper:PD,arrowDown:TD,arrowGlyph:RD,arrowActive:DD,arrowUp:jD,rulerTooltip:ID},Gl=({type:e,active:t=!1,className:n="",style:r,title:o,"aria-label":a,onPointerDown:s,"data-testid":u})=>{const d=e==="down"?Ae.arrowDown:Ae.arrowUp;return i.jsx("div",{className:`${Ae.arrowIconWrapper} ${d} ${t?Ae.arrowActive:""} ${n}`,style:r,title:o,"aria-label":a||o,onPointerDown:s,"data-testid":u,children:i.jsx("div",{className:Ae.arrowGlyph})})};function Wh(){const[e,t]=l.useState(null),[n,r]=l.useState(null),o=l.useCallback((a,s,u)=>{s.preventDefault(),s.stopPropagation(),t(a);const d=Number.isFinite(s.clientX)?s.clientX:0,f=Number.isFinite(s.clientY)?s.clientY:0,g=s.altKey,h=b=>{var k;const x=Number.isFinite(b.clientX)?b.clientX:d,y=Number.isFinite(b.clientY)?b.clientY:f,v=u.updateDragState(x,y,b.altKey);r(v),(k=u.onPreview)==null||k.call(u,v)},C=b=>{const x=Number.isFinite(b.clientX)?b.clientX:d,y=Number.isFinite(b.clientY)?b.clientY:f,v=u.updateDragState(x,y,b.altKey);window.removeEventListener("pointermove",h),window.removeEventListener("pointerup",C),window.removeEventListener("pointercancel",C),t(null),r(null),u.onCommit(v)};r(u.updateDragState(d,f,g)),window.addEventListener("pointermove",h),window.addEventListener("pointerup",C),window.addEventListener("pointercancel",C)},[]);return{activeTarget:e,dragPreview:n,startPointerDrag:o}}const ED=({geometry:e,indentState:t,unit:n="in",zoomScale:r=1,onMarginChange:o,onMarginPreview:a,onIndentChange:s})=>{const u=q(),{activeTarget:d,dragPreview:f,startPointerDrag:g}=Wh(),h=(e==null?void 0:e.pageWidthPx)??816,C=(e==null?void 0:e.marginsPx.left)??96,b=(e==null?void 0:e.marginsPx.right)??96,x=r>0?r:1,y=(f==null?void 0:f.marginLeft)??C,v=(f==null?void 0:f.marginRight)??b,k=(f==null?void 0:f.firstLineIndentPx)??t.firstLineIndentPx,S=(f==null?void 0:f.leftIndentPx)??t.leftIndentPx,P=(f==null?void 0:f.rightIndentPx)??t.rightIndentPx,R=Math.max(0,h-y-v),D=!t.mixed,A=l.useMemo(()=>Mp(h,y,n),[h,y,n]),T=l.useCallback((N,O)=>{const G=Number.isFinite(O.clientX)?O.clientX:0;Number.isFinite(O.clientY)&&O.clientY,g(N.type,O,{updateDragState:(Y,re,Z)=>{const J=(Y-G)/x;let ne=0;const ce={target:N.type,marginLeft:C,marginRight:b,firstLineIndentPx:t.firstLineIndentPx,leftIndentPx:t.leftIndentPx,rightIndentPx:t.rightIndentPx,measurementPx:0,clientX:Y,clientY:re};if(N.type==="margin-left"){const X=Math.max(0,Math.min(h-b-Uo,N.startMarginPx+J)),I=dr(X,n,Z,0);ce.marginLeft=I,ne=I}else if(N.type==="margin-right"){const X=Math.max(0,Math.min(h-C-Uo,N.startMarginPx-J)),I=dr(X,n,Z,0);ce.marginRight=I,ne=I}else if(N.type==="first-line-indent"){const X=-N.startLeftIndentPx,I=h-C-b-N.startLeftIndentPx-Uo,se=Math.max(X,Math.min(I,N.startFirstLinePx+J)),fe=dr(se,n,Z,0);ce.firstLineIndentPx=fe,ne=fe}else if(N.type==="left-indent"){const X=Math.max(0,N.startLeftIndentPx+J),I=dr(X,n,Z,0);ce.leftIndentPx=I,ce.firstLineIndentPx=N.startFirstLinePx,ne=I}else if(N.type==="right-indent"){const X=Math.max(0,N.startRightIndentPx-J),I=dr(X,n,Z,0);ce.rightIndentPx=I,ne=I}return ce.measurementPx=ne,ce},onPreview:Y=>{N.type==="margin-left"?a==null||a({left:Y.marginLeft}):N.type==="margin-right"&&(a==null||a({right:Y.marginRight}))},onCommit:Y=>{N.type==="margin-left"?o==null||o({left:Y.marginLeft}):N.type==="margin-right"?o==null||o({right:Y.marginRight}):N.type==="first-line-indent"?s==null||s({firstLineIndentPx:Y.firstLineIndentPx}):N.type==="left-indent"?s==null||s({leftIndentPx:Y.leftIndentPx}):N.type==="right-indent"&&(s==null||s({rightIndentPx:Y.rightIndentPx}))}})},[C,b,h,n,x,t,o,a,s,g]),_=y+S,M=_+k,z=h-v-P,E=h*x;return i.jsxs("div",{className:`${Ae.rulerRoot} ${Ae.horizontalRulerGroup}`,style:{width:`${E}px`},"data-testid":"horizontal-ruler",children:[i.jsxs("div",{className:Ae.horizontalRulerTrack,children:[i.jsxs("div",{className:Ae.horizontalInner,style:{left:`${y*x}px`,width:`${R*x}px`},"data-testid":"ruler-printable-area",children:[i.jsx("div",{className:`${Ae.dragEdgeLeft} ${d==="margin-left"?Ae.dragEdgeActive:""}`,title:u("rulerMarginLeft"),"aria-label":u("rulerMarginLeft"),"data-testid":"ruler-margin-splitter-left",onPointerDown:N=>T({type:"margin-left",startMarginPx:C},N)}),i.jsx("div",{className:`${Ae.dragEdgeRight} ${d==="margin-right"?Ae.dragEdgeActive:""}`,title:u("rulerMarginRight"),"aria-label":u("rulerMarginRight"),"data-testid":"ruler-margin-splitter-right",onPointerDown:N=>T({type:"margin-right",startMarginPx:b},N)})]}),A.map((N,O)=>i.jsxs(l.Fragment,{children:[i.jsx("div",{className:Ae.tickH,style:{left:`${N.positionPx*x}px`,height:`${N.height}px`}}),N.label?i.jsx("span",{className:Ae.tickLabelH,style:{left:`${N.positionPx*x}px`},children:N.label}):null]},O)),D?i.jsxs(i.Fragment,{children:[i.jsx(Gl,{type:"down",style:{left:`${M*x}px`},active:d==="first-line-indent",title:u("rulerFirstLineIndent"),"aria-label":u("rulerFirstLineIndent"),"data-testid":"ruler-first-line-indent",onPointerDown:N=>T({type:"first-line-indent",startFirstLinePx:t.firstLineIndentPx,startLeftIndentPx:t.leftIndentPx},N)}),i.jsx(Gl,{type:"up",style:{left:`${_*x}px`},active:d==="left-indent",title:u("rulerLeftIndent"),"aria-label":u("rulerLeftIndent"),"data-testid":"ruler-left-indent",onPointerDown:N=>T({type:"left-indent",startLeftIndentPx:t.leftIndentPx,startFirstLinePx:t.firstLineIndentPx},N)}),i.jsx(Gl,{type:"up",style:{left:`${z*x}px`},active:d==="right-indent",title:u("rulerRightIndent"),"aria-label":u("rulerRightIndent"),"data-testid":"ruler-right-indent",onPointerDown:N=>T({type:"right-indent",startRightIndentPx:t.rightIndentPx},N)})]}):null]}),i.jsx("div",{className:Ae.horizontalRulerShelf,"aria-hidden":!0}),f?i.jsx("div",{className:Ae.rulerTooltip,style:{left:f.clientX,top:f.clientY},"data-testid":"ruler-drag-tooltip",children:_p(f.measurementPx,n)}):null]})},_D=({geometry:e,unit:t="in",zoomScale:n=1,onMarginChange:r,onMarginPreview:o})=>{const a=q(),{activeTarget:s,dragPreview:u,startPointerDrag:d}=Wh(),f=(e==null?void 0:e.pageHeightPx)??1056,g=(e==null?void 0:e.marginsPx.top)??96,h=(e==null?void 0:e.marginsPx.bottom)??96,C=n>0?n:1,b=(u==null?void 0:u.marginTop)??g,x=(u==null?void 0:u.marginBottom)??h,y=Math.max(0,f-b-x),v=l.useMemo(()=>Mp(f,b,t),[f,b,t]),k=l.useCallback((S,P)=>{Number.isFinite(P.clientX)&&P.clientX;const R=Number.isFinite(P.clientY)?P.clientY:0;d(S.type,P,{updateDragState:(D,A,T)=>{const _=(A-R)/C,M={target:S.type,marginTop:g,marginBottom:h,measurementPx:0,clientX:D,clientY:A};if(S.type==="margin-top"){const z=Math.max(0,Math.min(f-h-Uo,S.startMarginPx+_)),E=dr(z,t,T,0);M.marginTop=E,M.measurementPx=E}else if(S.type==="margin-bottom"){const z=Math.max(0,Math.min(f-g-Uo,S.startMarginPx-_)),E=dr(z,t,T,0);M.marginBottom=E,M.measurementPx=E}return M},onPreview:D=>{S.type==="margin-top"?o==null||o({top:D.marginTop}):S.type==="margin-bottom"&&(o==null||o({bottom:D.marginBottom}))},onCommit:D=>{S.type==="margin-top"?r==null||r({top:D.marginTop}):S.type==="margin-bottom"&&(r==null||r({bottom:D.marginBottom}))}})},[g,h,f,t,C,r,o,d]);return i.jsxs("div",{className:`${Ae.rulerRoot} ${Ae.verticalRuler}`,style:{height:`${f}px`},"data-testid":"vertical-ruler",children:[i.jsxs("div",{className:Ae.verticalInner,style:{top:`${b}px`,height:`${y}px`},"data-testid":"ruler-printable-area-vertical",children:[i.jsx("div",{className:`${Ae.dragEdgeTop} ${s==="margin-top"?Ae.dragEdgeActiveV:""}`,title:a("rulerMarginTop"),"aria-label":a("rulerMarginTop"),"data-testid":"ruler-margin-splitter-top",onPointerDown:S=>k({type:"margin-top",startMarginPx:g},S)}),i.jsx("div",{className:`${Ae.dragEdgeBottom} ${s==="margin-bottom"?Ae.dragEdgeActiveV:""}`,title:a("rulerMarginBottom"),"aria-label":a("rulerMarginBottom"),"data-testid":"ruler-margin-splitter-bottom",onPointerDown:S=>k({type:"margin-bottom",startMarginPx:h},S)})]}),v.map((S,P)=>i.jsxs(l.Fragment,{children:[i.jsx("div",{className:Ae.tickV,style:{top:`${S.positionPx}px`,width:`${S.height}px`}}),S.label?i.jsx("span",{className:Ae.tickLabelV,style:{top:`${S.positionPx}px`},children:S.label}):null]},P)),u?i.jsx("div",{className:Ae.rulerTooltip,style:{left:u.clientX,top:u.clientY},"data-testid":"ruler-drag-tooltip",children:_p(u.measurementPx,t)}):null]})},MD="_root_ofshu_1",ND="_fullscreen_ofshu_36",LD="_exitFullscreen_ofshu_48",BD="_exitFullscreenIcon_ofshu_79",FD="_menuChrome_ofshu_94",HD="_body_ofshu_106",zD="_iconChrome_ofshu_136",OD="_workspace_ofshu_181",KD="_workspacePageSized_ofshu_193",$D="_workspaceWithRuler_ofshu_197",UD="_pageCanvasViewport_ofshu_201",VD="_multiPageRulerLayer_ofshu_211",WD="_multiPageContainer_ofshu_234",GD="_pageZoomContent_ofshu_244",ZD="_htmlFileDropOverlay_ofshu_262",qD="_surface_ofshu_276",YD="_visual_ofshu_283",XD="_pageBlock_ofshu_341",JD="_pageBlockFluid_ofshu_348",QD="_pageSurfaceRulerGutter_ofshu_357",ej="_pageSurface_ofshu_357",tj="_htmlModeShell_ofshu_378",nj="_html_ofshu_262",xe={root:MD,fullscreen:ND,exitFullscreen:LD,exitFullscreenIcon:BD,menuChrome:FD,body:HD,iconChrome:zD,workspace:OD,workspacePageSized:KD,workspaceWithRuler:$D,pageCanvasViewport:UD,multiPageRulerLayer:VD,multiPageContainer:WD,pageZoomContent:GD,htmlFileDropOverlay:ZD,surface:qD,visual:YD,pageBlock:XD,pageBlockFluid:JD,pageSurfaceRulerGutter:QD,pageSurface:ej,htmlModeShell:tj,html:nj};function Gh(e){if(e!==1)return{zoom:e,"--page-zoom":String(e)}}function Zh({showRulers:e,geometry:t,indentState:n,rulerUnit:r,zoomScale:o,onMarginChange:a,onMarginPreview:s,onIndentChange:u}){if(!e)return null;const d=Uh;return i.jsx("div",{className:xe.multiPageRulerLayer,children:i.jsxs("div",{className:xe.pageBlock,children:[i.jsx("div",{className:xe.pageSurfaceRulerGutter,style:{width:`${d}px`,flex:`0 0 ${d}px`},"aria-hidden":!0}),i.jsx(ED,{geometry:t,indentState:n,unit:r,zoomScale:o,onMarginChange:a,onMarginPreview:s,onIndentChange:u})]})})}function qh({showVerticalRuler:e=!1,pageSized:t=!1,geometry:n,rulerUnit:r,zoomScale:o,onMarginChange:a,onMarginPreview:s,children:u,pageBlockStyle:d,pageBlockRef:f}){const g=o>0?o:1,h=e?Uh/g:0;return i.jsxs("div",{ref:f,className:`${xe.pageBlock} ${t?"":xe.pageBlockFluid}`,style:d,children:[i.jsx("div",{className:xe.pageSurfaceRulerGutter,style:{width:`${h}px`,flex:`0 0 ${h}px`},children:e?i.jsx(_D,{geometry:n,unit:r,zoomScale:o,onMarginChange:a,onMarginPreview:s}):null}),u]})}function rj({showRulers:e,geometry:t,indentState:n,rulerUnit:r,zoomScale:o,onMarginChange:a,onMarginPreview:s,onIndentChange:u,children:d}){return i.jsxs("div",{style:{display:"flex",flexDirection:"column",alignItems:e?"center":"stretch",width:"100%",height:"100%",minHeight:"100%",position:"relative"},children:[i.jsx(Zh,{showRulers:e,geometry:t,indentState:n,rulerUnit:r,zoomScale:o,onMarginChange:a,onMarginPreview:s,onIndentChange:u}),i.jsx("div",{className:xe.pageZoomContent,style:Gh(o),children:i.jsx(qh,{showVerticalRuler:e,pageSized:e,geometry:t,rulerUnit:r,zoomScale:o,onMarginChange:a,onMarginPreview:s,children:d})})]})}const oj=l.memo(function({index:t,pageHtml:n,showVerticalRuler:r,pageSized:o,geometry:a,rulerUnit:s,zoomScale:u,placeholder:d,disabled:f,visualEditorAria:g,onActivate:h,onPointerDown:C,onPageChange:b,onPageFlush:x,suppressPageFlushRef:y,onMeasured:v,onMarginChange:k,onMarginPreview:S,onMouseUp:P,onContextMenu:R,onRulerRefresh:D}){const A=l.useRef(null),T=l.useRef(null),_=l.useRef(""),M=l.useRef(!1),z=l.useRef(x);z.current=x;const E=l.useRef(v);E.current=v,l.useLayoutEffect(()=>{const O=T.current;if(!O||!E.current)return;const G=()=>{var re;return(re=E.current)==null?void 0:re.call(E,t,O.offsetHeight)};if(G(),typeof ResizeObserver>"u")return;const Y=new ResizeObserver(G);return Y.observe(O),()=>Y.disconnect()},[t,n,o,r]);const N=l.useCallback(O=>{A.current=O,O&&(_.current=O.innerHTML)},[]);return l.useLayoutEffect(()=>()=>{y!=null&&y.current||!M.current||!z.current||z.current(t,_.current)},[t,y]),i.jsx(qh,{pageBlockRef:T,showVerticalRuler:r,pageSized:o,geometry:a,rulerUnit:s,zoomScale:u,pageBlockStyle:{marginTop:t>0?"1.5rem":"0"},onMarginChange:O=>{k==null||k(t,O)},onMarginPreview:O=>{S==null||S(t,O)},children:i.jsx("div",{ref:N,className:`${xe.surface} ${xe.visual} ${o?xe.pageSurface:""}`,[Jo]:"","data-page-index":t,contentEditable:!f,suppressContentEditableWarning:!0,role:"textbox","aria-multiline":"true","aria-label":g,"aria-disabled":f||void 0,"data-placeholder":t===0?d:void 0,onFocus:O=>{const G=O.currentTarget;Xo(G),to(G),h(t)},onPointerDown:O=>C(t,O),onMouseUp:P,onContextMenu:R,onInput:O=>{const G=O.currentTarget;M.current=!0,_.current=G.innerHTML;const{absorbedBlocks:Y}=Xo(G);if(_.current=G.innerHTML,b(t,G.innerHTML),Y.length>0){const re=Y.length;requestAnimationFrame(()=>Wp(G,re))}D()}})})},ij);function ij(e,t){return e.index===t.index&&e.pageHtml===t.pageHtml&&e.showVerticalRuler===t.showVerticalRuler&&e.pageSized===t.pageSized&&e.geometry===t.geometry&&e.rulerUnit===t.rulerUnit&&e.zoomScale===t.zoomScale&&e.placeholder===t.placeholder&&e.disabled===t.disabled&&e.visualEditorAria===t.visualEditorAria}const aj=l.forwardRef(function({pages:t,activePageIndex:n,hasSelectedPage:r=!1,scrollRootRef:o,onActivePageIndexChange:a,onPageSelected:s,onPageChange:u,onPageFlush:d,suppressPageFlushRef:f,placeholder:g,disabled:h,rulerVisible:C=!0,rulerUnit:b="in",zoomScale:x=1,onMarginChange:y,onMarginPreview:v,onIndentChange:k,onBeforeInput:S,resolveEmbeddedImageDataUrl:P,hydrateEmbeddedImages:R,onPointerDown:D,onMouseUp:A,onContextMenu:T},_){const M=q(),z=l.useRef(null),E=l.useRef(n);E.current=n;const N=l.useRef(S);N.current=S;const O=l.useRef(u);O.current=u;const G=l.useRef(d);G.current=d;const Y=l.useRef(s);Y.current=s;const re=l.useRef(D);re.current=D;const Z=l.useRef(y);Z.current=y;const J=l.useRef(v);J.current=v;const ne=l.useRef(null),ce=l.useRef([]),X=l.useRef(eD()),I=f,se=l.useCallback(()=>E.current,[]),fe=l.useCallback(V=>X.current.get(V,t[V]??""),[t]),{visibleIndices:L,topSpacerHeight:Le,bottomSpacerHeight:Ee,scrollToIndex:ze,notifyRowMeasured:bt}=oD({scrollElementRef:o??z,pageCount:t.length,getRowHeight:fe,activePageIndex:n,pinActivePage:r}),{geometryForPage:Ye,indentState:Oe,refresh:pe}=lD(z,t,L,se,!0,x),De=r?n:0,oe=t[De]??"",ve=l.useCallback(V=>ei(t[V]??""),[t]),je=C&&ei(oe),Ne=l.useCallback(V=>{ze(V),requestAnimationFrame(()=>{const ee=z.current;if(!ee)return;const me=nt(ee,V);me&&to(me)})},[ze]),We=l.useRef(ze);We.current=ze,l.useLayoutEffect(()=>{We.current(n)},[n,t.length]);const Ut=l.useCallback(V=>{var Ke;if(E.current=V,V!==n&&a(V),(Ke=Y.current)==null||Ke.call(Y,V),!L.includes(V)){Ne(V);return}pe();const ee=z.current;if(!ee)return;const me=nt(ee,V);me&&requestAnimationFrame(()=>to(me))},[n,a,pe,Ne,L]);l.useImperativeHandle(_,()=>({getContainer:()=>z.current,getActivePageRoot:()=>{const V=z.current;return V?nt(V,E.current):null},getActivePageIndex:()=>E.current,flushPageHtml:V=>{var me;const ee=z.current;return ee?((me=nt(ee,V))==null?void 0:me.innerHTML)??null:null},ensurePageMounted:V=>{Ne(V)}}));const Ue=l.useCallback((V,ee,me,Ke)=>{const Vt=cn(he(me).body),Jn=ee===document.activeElement;(Ke!=null&&Ke.forceBodySync||!Jn)&&Za(ee,Vt,{resolveDataUrl:P,hydrateEmbeddedImages:R}),cu(ee),Xo(ee);const ct=ds(ee);us(ee),co(ee,me);const $e=gt(ee);if($e&&Kp(ee,$e),ct){const Se=cn(he(me).body);ee.innerHTML!==Se&&O.current(V,ee.innerHTML)}},[R,P]);l.useLayoutEffect(()=>{X.current.clear()},[t.length]),l.useLayoutEffect(()=>{const V=z.current;if(!V)return;const ee=ne.current,me=ee===null||ee.length!==t.length;me&&We.current(n);const Ke=new Set(ce.current),Vt=new Set(L);me&&Vt.add(n);for(const ct of Vt){const $e=!Ke.has(ct),Se=t[ct]!==(ee==null?void 0:ee[ct]);if(!me&&!$e&&!Se)continue;const Ge=nt(V,ct);Ge&&Ue(ct,Ge,t[ct]??"",{forceBodySync:me})}ne.current=t,ce.current=L,me&&(I!=null&&I.current)&&(I.current=!1);const Jn=requestAnimationFrame(pe);return()=>cancelAnimationFrame(Jn)},[n,t,I,Ue,pe,L]),l.useLayoutEffect(()=>{const V=z.current;if(!V)return;const ee=me=>{var Ke;(Ke=N.current)==null||Ke.call(N,me)};return V.addEventListener("beforeinput",ee),()=>V.removeEventListener("beforeinput",ee)},[]);const Cr=l.useCallback((V,ee)=>{var me;Ut(V),(me=re.current)==null||me.call(re,ee)},[Ut]),wr=l.useCallback((V,ee)=>{O.current(V,ee)},[]),vr=l.useCallback((V,ee)=>{var me;(me=G.current)==null||me.call(G,V,ee)},[]),Be=l.useCallback((V,ee)=>{const me=$h(t[V]??"",V),Ke=Math.max(ee,me);X.current.set(V,Ke),bt(V,Ke)},[bt,t]),Qt=l.useCallback((V,ee)=>{var me;(me=Z.current)==null||me.call(Z,V,ee)},[]),it=l.useCallback((V,ee)=>{var me;(me=J.current)==null||me.call(J,V,ee)},[]),Xn=M("visualEditorAria"),kr=l.useMemo(()=>L.map(V=>i.jsx(oj,{index:V,pageHtml:t[V]??"",showVerticalRuler:je&&ve(V),pageSized:ve(V),geometry:Ye(V),rulerUnit:b,zoomScale:x,placeholder:g,disabled:h,visualEditorAria:Xn,onActivate:Ut,onPointerDown:Cr,onPageChange:wr,onPageFlush:vr,suppressPageFlushRef:I,onMeasured:Be,onMarginChange:Qt,onMarginPreview:it,onMouseUp:A,onContextMenu:T,onRulerRefresh:pe},V)),[Ut,h,Ye,Qt,it,wr,vr,Cr,Be,T,A,ve,t,g,pe,b,je,L,Xn,x]);return i.jsxs("div",{style:{display:"flex",flexDirection:"column",alignItems:je?"center":"stretch",width:"100%",height:"100%",minHeight:"100%",position:"relative"},children:[i.jsx(Zh,{showRulers:je,geometry:Ye(De),indentState:Oe,rulerUnit:b,zoomScale:x,onMarginChange:V=>{y==null||y(De,V)},onMarginPreview:V=>{v==null||v(De,V)},onIndentChange:V=>{k==null||k(V)}}),i.jsx("div",{className:xe.pageZoomContent,style:Gh(x),children:i.jsxs("div",{ref:z,className:xe.multiPageContainer,style:{display:"flex",flexDirection:"column",alignItems:je?"center":"stretch",width:"100%",minHeight:je?void 0:"100%",position:"relative"},children:[Le>0?i.jsx("div",{"aria-hidden":!0,style:{height:Le,flexShrink:0}}):null,kr,Ee>0?i.jsx("div",{"aria-hidden":!0,style:{height:Ee,flexShrink:0}}):null]})})]})});function sj(e,t,n){return r=>{const o=e();o&&n(o,t(),r)}}function lj(e,t,n,r){return o=>{const a=e();if(!a)return;const s=n(a,t(),o);r(s.pageHtml)}}function cj(e,t,n){return(r,o)=>{const a=e(r);a&&n(a,t(r),o)}}function uj(e,t,n,r){return(o,a)=>{const s=e(o);if(!s)return;const u=n(s,t(o),a);r(o,u.pageHtml)}}function If(e,t,n){return r=>{const o=e();o&&aD(o,{...r,unit:t})&&n(o)}}const dj="_field_1knrr_1",mj="_label_1knrr_8",fj="_button_1knrr_12",pj="_swatch_1knrr_37",gj="_swatchEmpty_1knrr_44",No={field:dj,label:mj,button:fj,swatch:pj,swatchEmpty:gj};function $t({label:e,noneLabel:t,value:n,mixed:r=!1,disabled:o,fallbackCustom:a,onChange:s}){const u=l.useId(),d=l.useRef(null),f=l.useRef(null),g=l.useRef(null),[h,C]=l.useState(!1),b=uo(h,f,g);l.useEffect(()=>{if(!h)return;const v=S=>{var R,D;const P=S.target;(R=d.current)!=null&&R.contains(P)||(D=g.current)!=null&&D.contains(P)||C(!1)},k=S=>{var P;S.key==="Escape"&&(S.preventDefault(),S.stopPropagation(),C(!1),(P=f.current)==null||P.focus())};return document.addEventListener("pointerdown",v),document.addEventListener("keydown",k,!0),()=>{document.removeEventListener("pointerdown",v),document.removeEventListener("keydown",k,!0)}},[h]);const x=`${No.swatch}${!n||r?` ${No.swatchEmpty}`:""}`,y=n&&!r?{backgroundColor:n}:void 0;return i.jsxs("div",{className:No.field,ref:d,children:[i.jsx("span",{className:No.label,children:e}),i.jsx("button",{ref:f,type:"button",className:No.button,"aria-label":e,"aria-haspopup":"listbox","aria-expanded":h,"aria-controls":h?u:void 0,disabled:o,onClick:()=>C(v=>!v),children:i.jsx("span",{className:x,style:y})}),h?i.jsx(we,{children:i.jsx("div",{ref:g,id:u,className:ur.popover,style:{top:b.top,left:b.left,zIndex:1400},children:i.jsx(Du,{value:n,mixed:r,noneLabel:t,ariaLabel:e,disabled:o,fallbackCustom:a,onChange:s,onCommit:()=>C(!1)})})}):null]})}const Zl=[{id:"general",labelKey:"fontDialogTabGeneral",implemented:!0}],hj={bold:{label:"commandBold"},italic:{label:"commandItalic"},underline:{label:"commandUnderline"},strikethrough:{label:"commandStrikethrough"}};function Iu({tab:e,value:t,fonts:n,disabled:r,onTabChange:o,onChange:a}){const s=q(),u=l.useId(),d=l.useId(),f=n??ep(),g=Zl.find(h=>h.id===e)??Zl[0];return i.jsxs(i.Fragment,{children:[i.jsx("div",{className:p.tabs,role:"tablist","aria-label":s("fontDialogTitle"),children:Zl.map(h=>i.jsx("button",{type:"button",className:p.tab,role:"tab","aria-selected":h.id===e,disabled:!h.implemented,onClick:()=>o(h.id),children:s(h.labelKey)},h.id))}),i.jsx("div",{className:p.body,role:"tabpanel",children:g.implemented?i.jsxs(i.Fragment,{children:[i.jsxs("div",{className:p.field,children:[i.jsx("label",{className:p.label,htmlFor:d,children:s("fontDialogFamily")}),i.jsx(Mh,{family:t.fontFamilyMixed?null:t.fontFamily,mixed:t.fontFamilyMixed,fonts:f,disabled:r,triggerId:d,onChange:h=>{a({...t,fontFamily:h,fontFamilyMixed:!1})}})]}),i.jsxs("div",{className:p.field,children:[i.jsx("label",{className:p.label,htmlFor:u,children:s("fontDialogSize")}),i.jsx("div",{className:p.sizeRow,children:i.jsx(Nh,{size:t.size,unit:t.unit,sizeInputId:u,disabled:r,onSizeChange:(h,C)=>{a({...t,size:h,unit:C})},onUnitChange:h=>{const C=t.size!==null?ap(t.size,t.unit,h,16,16):t.size;a({...t,size:C,unit:h})}})})]}),i.jsx("div",{className:p.field,children:i.jsx($t,{label:s("commandFontColor"),noneLabel:s("colorAutomatic"),value:t.fontColor,mixed:t.fontColorMixed,disabled:r,onChange:h=>{a({...t,fontColor:h,fontColorMixed:!1})}})}),i.jsx("div",{className:p.field,children:i.jsx($t,{label:s("commandHighlightColor"),noneLabel:s("colorNone"),value:t.highlightColor,mixed:t.highlightColorMixed,disabled:r,fallbackCustom:"#ffff00",onChange:h=>{a({...t,highlightColor:h,highlightColorMixed:!1})}})}),i.jsxs("fieldset",{className:p.marks,children:[i.jsx("legend",{className:p.label,children:s("fontDialogStyle")}),Kt.map(h=>i.jsxs("label",{className:p.mark,children:[i.jsx("input",{type:"checkbox",checked:t.marks[h],disabled:r,onChange:()=>{a({...t,marks:{...t.marks,[h]:!t.marks[h]}})}}),s(hj[h].label)]},h))]})]}):null})]})}function bj({open:e,tab:t,size:n,unit:r,marks:o,fontFamily:a=null,fontFamilyMixed:s=!1,fontColor:u,fontColorMixed:d=!1,highlightColor:f,highlightColorMixed:g=!1,fonts:h,disabled:C,onTabChange:b,onApply:x,onClose:y}){const v=q(),k=l.useId(),S=l.useRef(null),[P,R]=l.useState({size:n,unit:r,marks:o,fontFamily:a,fontFamilyMixed:s,fontColor:u,highlightColor:f,fontColorMixed:d,highlightColorMixed:g});return l.useEffect(()=>{e&&R({size:n,unit:r,marks:o,fontFamily:a,fontFamilyMixed:s,fontColor:u,highlightColor:f,fontColorMixed:d,highlightColorMixed:g})},[e,n,r,o,a,s,u,d,f,g]),qe(S,{open:e,onClose:y}),e?i.jsx(we,{children:i.jsx("div",{className:p.backdrop,role:"presentation",onMouseDown:y,children:i.jsxs("div",{ref:S,className:p.dialog,role:"dialog","aria-modal":"true","aria-labelledby":k,onMouseDown:D=>D.stopPropagation(),children:[i.jsx("h2",{className:p.header,id:k,children:v("fontDialogTitle")}),i.jsx(Iu,{tab:t,value:P,fonts:h,disabled:C,onTabChange:b,onChange:R}),i.jsxs("div",{className:p.actions,children:[i.jsx("button",{type:"button",className:p.action,onClick:y,children:v("fontDialogCancel")}),i.jsx("button",{type:"button",className:`${p.action} ${p.actionPrimary}`,disabled:C,onClick:()=>x(P),children:v("fontDialogOk")})]})]})})}):null}const yj={pt:"fontSizeUnitPt",px:"fontSizeUnitPx",em:"fontSizeUnitEm",rem:"fontSizeUnitRem","%":"fontSizeUnitPercent"};function Qe({label:e,value:t,disabled:n,allowNegative:r=!1,unitAria:o,inputId:a,onChange:s}){const u=q(),d=l.useId(),f=a??d,g=(t==null?void 0:t.unit)??Gc,[h,C]=l.useState(()=>t?de(t.value):""),[b,x]=l.useState(!1);l.useEffect(()=>{b||C(t?de(t.value):"")},[t,b]);const y=v=>{const k=v.trim();if(!k){s(null),C("");return}const S=Wo(k,g,r);if(!S){C(t?de(t.value):"");return}s(S),C(de(S.value))};return i.jsxs("div",{className:p.lengthField,children:[i.jsx("label",{className:p.sideLabel,htmlFor:f,children:e}),i.jsxs("div",{className:p.lengthRow,children:[i.jsx("input",{id:f,className:p.lengthInput,value:h,disabled:n,inputMode:"decimal",onFocus:()=>x(!0),onBlur:()=>{x(!1),y(h)},onChange:v=>C(v.target.value),onKeyDown:v=>{v.key==="Enter"&&(v.preventDefault(),y(h),v.currentTarget.blur())}}),i.jsx("select",{className:p.lengthUnit,value:g,disabled:n,"aria-label":o??u("paragraphDialogLengthUnitAria"),onChange:v=>{const k=v.target.value;if(t){s({value:t.value,unit:k});return}if(h.trim()){const S=Wo(h,k,r);s(S)}},children:Uc.map(v=>i.jsx("option",{value:v,children:u(yj[v])},v))})]})]})}function Eu({shadow:e,disabled:t,onChange:n}){const r=q();return i.jsxs("div",{className:p.shadowGrid,children:[i.jsx(Qe,{label:r("paragraphDialogShadowOffsetX"),value:e.offsetX,disabled:t,allowNegative:!0,onChange:o=>{n({...e,offsetX:o??{value:0,unit:"px"}})}}),i.jsx(Qe,{label:r("paragraphDialogShadowOffsetY"),value:e.offsetY,disabled:t,allowNegative:!0,onChange:o=>{n({...e,offsetY:o??{value:0,unit:"px"}})}}),i.jsx(Qe,{label:r("paragraphDialogShadowBlur"),value:e.blur,disabled:t,onChange:o=>{n({...e,blur:o??{value:0,unit:"px"}})}}),i.jsx(Qe,{label:r("paragraphDialogShadowSpread"),value:e.spread,disabled:t,allowNegative:!0,onChange:o=>{n({...e,spread:o??{value:0,unit:"px"}})}}),i.jsx($t,{label:r("paragraphDialogShadowColor"),noneLabel:r("colorNone"),value:e.color,disabled:t,onChange:o=>{n({...e,color:o})}}),i.jsxs("label",{className:p.mark,children:[i.jsx("input",{type:"checkbox",checked:e.inset,disabled:t,onChange:()=>{n({...e,inset:!e.inset})}}),r("paragraphDialogShadowInset")]})]})}const Yh=[{id:"general",labelKey:"fontDialogTabGeneral",implemented:!0},{id:"spacing",labelKey:"paragraphDialogSpacing",implemented:!0},{id:"border",labelKey:"paragraphDialogTabBorder",implemented:!0},{id:"background",labelKey:"paragraphDialogTabBackground",implemented:!0},{id:"backgroundImage",labelKey:"pageDialogTabBackgroundImage",implemented:!0}],Xh=[{id:"spacing",labelKey:"paragraphDialogSpacing",implemented:!0},{id:"border",labelKey:"paragraphDialogTabBorder",implemented:!0},{id:"background",labelKey:"paragraphDialogTabBackground",implemented:!0},{id:"backgroundImage",labelKey:"pageDialogTabBackgroundImage",implemented:!0}],xj={fill:"imagePropertiesFitFill",contain:"imagePropertiesFitContain",cover:"imagePropertiesFitCover",none:"imagePropertiesFitNoneValue","scale-down":"imagePropertiesFitScaleDown"},Cj={center:"imagePropertiesPositionCenter",top:"imagePropertiesPositionTop",bottom:"imagePropertiesPositionBottom",left:"imagePropertiesPositionLeft",right:"imagePropertiesPositionRight","top left":"imagePropertiesPositionTopLeft","top right":"imagePropertiesPositionTopRight","bottom left":"imagePropertiesPositionBottomLeft","bottom right":"imagePropertiesPositionBottomRight"};function Jh({legendKey:e="imagePropertiesTabAdvanced",value:t,disabled:n,onChange:r}){const o=q(),a=l.useId(),s=l.useId();return i.jsxs("fieldset",{className:p.group,children:[i.jsx("legend",{className:p.label,children:o(e)}),i.jsx(wj,{value:t.opacity,disabled:n,onChange:u=>{r({...t,opacity:u})}}),i.jsxs("div",{className:p.field,children:[i.jsx("label",{className:p.label,htmlFor:a,children:o("imagePropertiesFit")}),i.jsxs("select",{id:a,className:p.select,value:t.fit??"",disabled:n,onChange:u=>{const d=u.target.value;r({...t,fit:d||null})},children:[i.jsx("option",{value:"",children:o("imagePropertiesFitDefault")}),du.map(u=>i.jsx("option",{value:u,children:o(xj[u])},u))]})]}),i.jsxs("div",{className:p.field,children:[i.jsx("label",{className:p.label,htmlFor:s,children:o("imagePropertiesPosition")}),i.jsxs("select",{id:s,className:p.select,value:t.position??"",disabled:n,onChange:u=>{r({...t,position:u.target.value||null})},children:[i.jsx("option",{value:"",children:o("imagePropertiesPositionDefault")}),mu.map(u=>i.jsx("option",{value:u,children:o(Cj[u])},u))]})]})]})}function wj({value:e,disabled:t,onChange:n}){const r=q(),o=l.useId(),a=e===null?null:Ia(e),[s,u]=l.useState(()=>a===null?"":de(a)),[d,f]=l.useState(!1);l.useEffect(()=>{d||u(a===null?"":de(a))},[a,d]);const g=h=>{const C=h.trim();if(!C){n(null),u("");return}const b=Number(C.replace(",","."));if(!Number.isFinite(b)){u(a===null?"":de(a));return}const x=vp(b);n(x),u(de(Ia(x)))};return i.jsxs("div",{className:p.field,children:[i.jsx("label",{className:p.label,htmlFor:o,children:r("paragraphDialogOpacity")}),i.jsxs("div",{className:p.lengthRow,children:[i.jsx("input",{id:o,className:p.lengthInput,value:s,disabled:t,inputMode:"decimal",onFocus:()=>f(!0),onChange:h=>u(h.target.value),onBlur:()=>{f(!1),g(s)}}),i.jsx("span",{className:p.lengthUnit,"aria-hidden":"true",children:r("fontSizeUnitPercent")})]})]})}const vj={pt:"fontSizeUnitPt",px:"fontSizeUnitPx",em:"fontSizeUnitEm",rem:"fontSizeUnitRem","%":"fontSizeUnitPercent",pc:"fontSizeUnitPc"};function Qa({label:e,inputAria:t,value:n,disabled:r,onChange:o}){const a=q(),s=l.useId(),u=l.useId(),d=l.useRef(null),f=l.useRef(null),g=l.useRef(null),h=(n==null?void 0:n.unit)??vw,[C,b]=l.useState(()=>n?de(n.value):""),[x,y]=l.useState(!1),[v,k]=l.useState(!1),S=uo(v,f,g,{matchAnchorWidth:!0,minWidth:72});l.useEffect(()=>{x||b(n?de(n.value):"")},[n,x]),l.useEffect(()=>{if(!v)return;const T=M=>{var E,N;const z=M.target;(E=d.current)!=null&&E.contains(z)||(N=g.current)!=null&&N.contains(z)||k(!1)},_=M=>{M.key==="Escape"&&(M.preventDefault(),M.stopPropagation(),k(!1))};return document.addEventListener("pointerdown",T),document.addEventListener("keydown",_,!0),()=>{document.removeEventListener("pointerdown",T),document.removeEventListener("keydown",_,!0)}},[v]);const P=T=>{const _=T.trim();if(!_){o(null),b("");return}const M=Fm(_,h);if(!M){b(n?de(n.value):"");return}o(M),b(de(M.value))},R=kw[h],D=(n==null?void 0:n.value)??null,A=v?i.jsx(we,{children:i.jsx("ul",{ref:g,className:Ze.list,role:"listbox",id:s,style:{top:S.top,left:S.left,minWidth:S.width},children:R.map(T=>i.jsx("li",{role:"presentation",children:i.jsx("button",{type:"button",className:Ze.option,role:"option","aria-selected":D===T,onMouseDown:_=>_.preventDefault(),onClick:()=>{o({value:T,unit:h}),b(de(T)),k(!1)},children:de(T)})},T))})}):null;return i.jsxs("div",{className:p.lengthField,children:[i.jsx("label",{className:p.sideLabel,htmlFor:u,children:e}),i.jsxs("div",{className:`${Ze.wrap} ${p.lengthRow}`,ref:d,children:[i.jsxs("div",{className:Ze.field,ref:f,children:[i.jsx("input",{id:u,className:Ze.input,value:C,disabled:r,"aria-label":t,"aria-autocomplete":"list","aria-expanded":v,"aria-controls":s,role:"combobox",inputMode:"decimal",onFocus:()=>y(!0),onBlur:()=>{y(!1),P(C)},onChange:T=>b(T.target.value),onKeyDown:T=>{T.key==="Enter"&&(T.preventDefault(),P(C),k(!1),T.currentTarget.blur()),T.key==="ArrowDown"&&(T.preventDefault(),k(!0))}}),i.jsx("button",{type:"button",className:Ze.toggle,tabIndex:-1,disabled:r,"aria-label":t,"aria-expanded":v,"aria-controls":s,onMouseDown:T=>T.preventDefault(),onClick:()=>k(T=>!T)})]}),i.jsxs("div",{className:Ze.field,children:[i.jsx("select",{className:Ze.unit,value:h,disabled:r,"aria-label":a("imagePropertiesSizeUnitAria"),onChange:T=>{const _=T.target.value;if(n){o({value:n.value,unit:_});return}C.trim()&&o(Fm(C,_))},children:Jp.map(T=>i.jsx("option",{value:T,children:a(vj[T])},T))}),i.jsx("span",{className:Ze.chevron,"aria-hidden":"true"})]}),A]})]})}const kj={empty:"imageDialogErrorEmpty",invalid:"imageDialogErrorInvalid"},Sj={type:"imageDialogErrorType",tooLarge:"imageDialogErrorTooLarge"};function Qh({src:e,disabled:t,customImagePicker:n,onSrcChange:r,onCustomPick:o,onSourceChange:a}){const s=q(),u=l.useId(),d=l.useId(),f=l.useRef(null),[g,h]=l.useState(()=>e.startsWith("data:")?"file":e.trim()?"url":"file"),[C,b]=l.useState(()=>e.startsWith("data:")?"":e),[x,y]=l.useState(""),[v,k]=l.useState(null),[S,P]=l.useState(!1);l.useEffect(()=>{a==null||a(g)},[a,g]);const R=g==="file"&&e.startsWith("data:")?e:g==="url"?C:"",D=g==="custom"?null:dn(R),A=g==="custom"?null:g==="file"&&v?Sj[v]:D&&(g==="file"||C.trim().length>0)?kj[D]:null,T=()=>{t||!n||o==null||o()},_=M=>{var E;const z=(E=M.target.files)==null?void 0:E[0];z&&(P(!0),k(null),fw(z).then(N=>{y(z.name),h("file"),r(N),P(!1)},N=>{const O=N instanceof Error?N.message:"";y(""),h("file"),k(O==="tooLarge"||O==="type"?O:"type"),P(!1),f.current&&(f.current.value="")}))};return i.jsxs("fieldset",{className:p.group,children:[i.jsx("legend",{className:p.subLabel,children:s("imageDialogSource")}),i.jsxs("div",{className:p.sizeRow,role:"radiogroup","aria-label":s("imageDialogSource"),children:[i.jsx("button",{type:"button",className:p.action,role:"radio","aria-checked":g==="file",disabled:t,onClick:()=>h("file"),children:s("imageDialogFile")}),i.jsx("button",{type:"button",className:p.action,role:"radio","aria-checked":g==="url",disabled:t,onClick:()=>h("url"),children:s("imageDialogUrl")}),n?i.jsx("button",{type:"button",className:p.action,role:"radio","aria-checked":g==="custom",disabled:t,onClick:()=>h("custom"),children:n.text}):null]}),g==="file"?i.jsxs("div",{className:p.fileRow,children:[i.jsx("input",{ref:f,type:"file",accept:sw,hidden:!0,disabled:t,"aria-label":s("imageDialogChooseFile"),onChange:_}),i.jsx("button",{type:"button",className:p.action,disabled:t||S,onClick:()=>{var M;return(M=f.current)==null?void 0:M.click()},children:s("imageDialogChooseFile")}),x?i.jsx("span",{className:p.fileName,children:x}):null,e.startsWith("data:")&&!x?i.jsx("span",{className:p.fileName,children:s("pageBackgroundImageCurrent")}):null]}):null,g==="url"?i.jsxs("div",{className:p.field,children:[i.jsx("label",{className:p.label,htmlFor:u,children:s("imageDialogUrl")}),i.jsx("input",{id:u,className:p.textInput,value:C,disabled:t,"aria-invalid":A!==null,"aria-describedby":A?d:void 0,onChange:M=>{const z=M.target.value;b(z),r(z.trim())}})]}):null,g==="custom"&&n?i.jsxs("div",{className:p.field,children:[i.jsx("p",{className:p.emptyHint,children:n.description}),i.jsx("button",{type:"button",className:p.action,disabled:t,onClick:T,children:n.buttonCaption})]}):null,A?i.jsx("p",{id:d,className:p.error,children:s(A)}):null]})}function Aj(e){return dn(e.trim())===null}function Pj(e){return og(e)?{width:null,height:null}:e==="fill"?{width:{...qr},height:{...qr}}:{width:{...qr},height:null}}function Tj({value:e,disabled:t,customImagePicker:n,onCustomImagePick:r,onChange:o}){const a=q(),s=e.src??"",u=(d,f)=>{o({...e,fit:null,[d]:f})};return i.jsxs(i.Fragment,{children:[s?i.jsxs("div",{className:p.field,children:[i.jsx("span",{className:p.label,children:a("pageBackgroundImagePreview")}),i.jsx("img",{className:p.previewImage,src:s,alt:a("pageBackgroundImagePreviewAlt")}),i.jsx("button",{type:"button",className:p.action,disabled:t,onClick:()=>{o({...e,src:null})},children:a("pageBackgroundImageClear")})]}):null,i.jsx(Qh,{src:s,disabled:t,customImagePicker:n,onCustomPick:r,onSrcChange:d=>{o({...e,src:d.trim()||null})}}),s?i.jsxs(i.Fragment,{children:[i.jsx(Qa,{label:a("imagePropertiesWidth"),inputAria:a("imagePropertiesWidthAria"),value:e.width,disabled:t,onChange:d=>u("width",d)}),i.jsx(Qa,{label:a("imagePropertiesHeight"),inputAria:a("imagePropertiesHeightAria"),value:e.height,disabled:t,onChange:d=>u("height",d)}),i.jsx(Jh,{legendKey:"pageDialogTabBackgroundImage",value:{opacity:e.opacity,fit:e.fit,position:e.position},disabled:t,onChange:d=>{const f=d.fit===e.fit?{width:e.width,height:e.height}:Pj(d.fit);o({...e,opacity:d.opacity,fit:d.fit,position:d.position,...f})}})]}):null]})}const Rj={left:ts,center:es,right:ns,justify:Hf},Dj={left:{aria:"commandAlignLeftAria"},center:{aria:"commandAlignCenterAria"},right:{aria:"commandAlignRightAria"},justify:{aria:"commandAlignJustifyAria"}},jj={top:"paragraphDialogSideTop",right:"paragraphDialogSideRight",bottom:"paragraphDialogSideBottom",left:"paragraphDialogSideLeft"},Ij={none:"paragraphDialogBorderStyleNone",solid:"paragraphDialogBorderStyleSolid",dotted:"paragraphDialogBorderStyleDotted",dashed:"paragraphDialogBorderStyleDashed",double:"paragraphDialogBorderStyleDouble",groove:"paragraphDialogBorderStyleGroove",ridge:"paragraphDialogBorderStyleRidge",inset:"paragraphDialogBorderStyleInset",outset:"paragraphDialogBorderStyleOutset"},Ej={pt:"fontSizeUnitPt",px:"fontSizeUnitPx",em:"fontSizeUnitEm",rem:"fontSizeUnitRem","%":"fontSizeUnitPercent"},_j={value:1,unit:"pt"},Mj={offsetX:{value:0,unit:"px"},offsetY:{value:4,unit:"px"},blur:{value:8,unit:"px"},spread:{value:0,unit:"px"},color:"#000000",inset:!1},Nj={auto:"paragraphDialogBreakAuto",avoid:"paragraphDialogBreakAvoid"},Ef={auto:"paragraphDialogBreakAuto",avoid:"paragraphDialogBreakAvoid",page:"paragraphDialogBreakPage"};function Lo(e){return{top:e,right:e,bottom:e,left:e}}function _f(e){for(const t of ot)if(e[t])return e[t];return null}function Lj(){const e=[...Yh];for(const t of Xh)e.some(n=>n.id===t.id)||e.push(t);return e}function _u({tab:e,value:t,disabled:n,tabs:r,tablistLabelKey:o="paragraphDialogTitle",backgroundImage:a,customImagePicker:s,onCustomImagePick:u,onBackgroundImageChange:d,onTabChange:f,onChange:g}){const h=q(),C=r?Lj().filter(A=>r.includes(A.id)):Yh,b=l.useId(),x=l.useId(),y=l.useId(),v=l.useId(),[k,S]=l.useState(()=>vn(t.margin,Lo(t.margin.top))),[P,R]=l.useState(()=>vn(t.padding,Lo(t.padding.top))),D=(A,T,_,M)=>{const z=t[A],E=T?Lo(M):{...z,[_]:M};g({...t,[A]:E,[`${A}Mixed`]:!1})};return i.jsxs(i.Fragment,{children:[i.jsx("div",{className:p.tabs,role:"tablist","aria-label":h(o),children:C.map(A=>i.jsx("button",{type:"button",className:p.tab,role:"tab","aria-selected":A.id===e,disabled:!A.implemented,onClick:()=>f(A.id),children:h(A.labelKey)},A.id))}),i.jsxs("div",{className:p.body,role:"tabpanel",children:[e==="general"?i.jsxs(i.Fragment,{children:[i.jsxs("fieldset",{className:p.group,children:[i.jsx("legend",{className:p.label,children:h("paragraphDialogAlignment")}),i.jsx("div",{className:p.iconRow,role:"radiogroup","aria-label":h("paragraphDialogAlignment"),children:Zg.map(A=>{const T=Rj[A],_=!t.alignMixed&&t.align===A;return i.jsx("button",{type:"button",className:p.iconButton,role:"radio","aria-checked":_,"aria-label":h(Dj[A].aria),disabled:n,onClick:()=>{g({...t,align:A,alignMixed:!1})},children:i.jsx(T,{})},A)})})]}),i.jsxs("fieldset",{className:p.group,children:[i.jsx("legend",{className:p.label,children:h("paragraphDialogLists")}),i.jsxs("div",{className:p.iconRow,children:[i.jsx("button",{type:"button",className:p.iconButton,"aria-pressed":!t.listMixed&&t.list==="ul","aria-label":h("commandBulletListAria"),disabled:n,onClick:()=>{const A=!t.listMixed&&t.list==="ul"?null:"ul";g({...t,list:A,listMixed:!1})},children:i.jsx(zf,{})}),i.jsx("button",{type:"button",className:p.iconButton,"aria-pressed":!t.listMixed&&t.list==="ol","aria-label":h("commandNumberedListAria"),disabled:n,onClick:()=>{const A=!t.listMixed&&t.list==="ol"?null:"ol";g({...t,list:A,listMixed:!1})},children:i.jsx(Uf,{})})]})]})]}):null,e==="spacing"?i.jsxs("fieldset",{className:p.group,children:[i.jsx("legend",{className:p.label,children:h("paragraphDialogSpacing")}),i.jsx(Mf,{legend:h("paragraphDialogMargin"),sides:t.margin,linked:k,disabled:n,allowNegative:!0,onLinkedChange:A=>{S(A),A&&g({...t,margin:Lo(_f(t.margin)),marginMixed:!1})},onSideChange:(A,T)=>D("margin",k,A,T)}),i.jsx(Mf,{legend:h("paragraphDialogPadding"),sides:t.padding,linked:P,disabled:n,onLinkedChange:A=>{R(A),A&&g({...t,padding:Lo(_f(t.padding)),paddingMixed:!1})},onSideChange:(A,T)=>D("padding",P,A,T)}),i.jsx(Fj,{value:t.lineHeight,disabled:n,onChange:A=>{g({...t,lineHeight:A,lineHeightMixed:!1})}}),i.jsxs("fieldset",{className:p.nestedGroup,children:[i.jsx("legend",{className:p.subLabel,children:h("paragraphDialogPageBreaks")}),i.jsxs("div",{className:p.field,children:[i.jsx("label",{className:p.label,htmlFor:x,children:h("paragraphDialogBreakInside")}),i.jsx("select",{id:x,className:p.select,value:t.breakInsideMixed?"auto":t.breakInside,disabled:n,onChange:A=>{g({...t,breakInside:A.target.value,breakInsideMixed:!1})},children:pp.map(A=>i.jsx("option",{value:A,children:h(Nj[A])},A))})]}),i.jsxs("div",{className:p.field,children:[i.jsx("label",{className:p.label,htmlFor:y,children:h("paragraphDialogBreakAfter")}),i.jsx("select",{id:y,className:p.select,value:t.breakAfterMixed?"auto":t.breakAfter,disabled:n,onChange:A=>{g({...t,breakAfter:A.target.value,breakAfterMixed:!1})},children:ac.map(A=>i.jsx("option",{value:A,children:h(Ef[A])},A))})]}),i.jsxs("div",{className:p.field,children:[i.jsx("label",{className:p.label,htmlFor:v,children:h("paragraphDialogBreakBefore")}),i.jsx("select",{id:v,className:p.select,value:t.breakBeforeMixed?"auto":t.breakBefore,disabled:n,onChange:A=>{g({...t,breakBefore:A.target.value,breakBeforeMixed:!1})},children:ac.map(A=>i.jsx("option",{value:A,children:h(Ef[A])},A))})]})]})]}):null,e==="border"?i.jsxs("fieldset",{className:p.group,children:[i.jsx("legend",{className:p.label,children:h("paragraphDialogBorder")}),i.jsxs("div",{className:p.field,children:[i.jsx("label",{className:p.label,htmlFor:b,children:h("paragraphDialogBorderStyle")}),i.jsx("select",{id:b,className:p.select,value:t.border.style,disabled:n,onChange:A=>{const T=A.target.value;g({...t,border:{style:T,width:T==="none"?null:t.border.width??_j,color:T==="none"?null:t.border.color},borderMixed:!1})},children:as.map(A=>i.jsx("option",{value:A,children:h(Ij[A])},A))})]}),t.border.style!=="none"?i.jsxs(i.Fragment,{children:[i.jsx(Qe,{label:h("paragraphDialogBorderWidth"),value:t.border.width,disabled:n,onChange:A=>{g({...t,border:{...t.border,width:A},borderMixed:!1})}}),i.jsx($t,{label:h("paragraphDialogBorderColor"),noneLabel:h("colorNone"),value:t.border.color,mixed:t.borderMixed,disabled:n,onChange:A=>{g({...t,border:{...t.border,color:A},borderMixed:!1})}})]}):null,i.jsx(Qe,{label:h("paragraphDialogBorderRadius"),value:t.borderRadius,disabled:n,onChange:A=>{g({...t,borderRadius:A,radiusMixed:!1})}}),i.jsxs("label",{className:p.mark,children:[i.jsx("input",{type:"checkbox",checked:t.boxShadow!==null,disabled:n,onChange:()=>{g({...t,boxShadow:t.boxShadow?null:Mj,shadowMixed:!1})}}),h("paragraphDialogBoxShadow")]}),t.boxShadow?i.jsx(Eu,{shadow:t.boxShadow,disabled:n,onChange:A=>{g({...t,boxShadow:A,shadowMixed:!1})}}):null]}):null,e==="background"?i.jsxs("fieldset",{className:p.group,children:[i.jsx("legend",{className:p.label,children:h("paragraphDialogTabBackground")}),i.jsx($t,{label:h("paragraphDialogBackgroundColor"),noneLabel:h("colorNone"),value:t.backgroundColor,mixed:t.backgroundMixed,disabled:n,onChange:A=>{g({...t,backgroundColor:A,backgroundMixed:!1})}}),i.jsx(Bj,{value:t.opacity,disabled:n,onChange:A=>{g({...t,opacity:A,opacityMixed:!1})}})]}):null,e==="backgroundImage"&&a&&d?i.jsx(Tj,{value:a,disabled:n,customImagePicker:s,onCustomImagePick:u,onChange:d}):null]})]})}function Bj({value:e,disabled:t,onChange:n}){const r=q(),o=l.useId(),a=e===null?null:Ia(e),[s,u]=l.useState(()=>a===null?"":de(a)),[d,f]=l.useState(!1);l.useEffect(()=>{d||u(a===null?"":de(a))},[a,d]);const g=h=>{const C=h.trim();if(!C){n(null),u("");return}const b=Number(C.replace(",","."));if(!Number.isFinite(b)){u(a===null?"":de(a));return}const x=vp(b);n(x),u(de(Ia(x)))};return i.jsxs("div",{className:p.field,children:[i.jsx("label",{className:p.label,htmlFor:o,children:r("paragraphDialogOpacity")}),i.jsxs("div",{className:p.lengthRow,children:[i.jsx("input",{id:o,className:p.lengthInput,value:s,disabled:t,inputMode:"decimal",onFocus:()=>f(!0),onChange:h=>u(h.target.value),onBlur:()=>{f(!1),g(s)}}),i.jsx("span",{className:p.lengthUnit,"aria-hidden":"true",children:r("fontSizeUnitPercent")})]})]})}function Mf({legend:e,sides:t,linked:n,disabled:r,allowNegative:o=!1,onLinkedChange:a,onSideChange:s}){const u=q(),d=n?["top"]:ot;return i.jsxs("fieldset",{className:p.nestedGroup,children:[i.jsx("legend",{className:p.subLabel,children:e}),i.jsxs("label",{className:p.mark,children:[i.jsx("input",{type:"checkbox",checked:n,disabled:r,onChange:()=>a(!n)}),u("paragraphDialogLinkSides")]}),i.jsx("div",{className:p.sideGrid,children:d.map(f=>i.jsx(Qe,{label:n?e:u(jj[f]),value:t[f],disabled:r,allowNegative:o,onChange:g=>s(f,g)},f))})]})}function Fj({value:e,disabled:t,onChange:n}){const r=q(),o=l.useId(),a=Hj(e),s=(e==null?void 0:e.kind)==="number"||(e==null?void 0:e.kind)==="length"?e.value:null,[u,d]=l.useState(()=>s===null?"":de(s)),f=(e==null?void 0:e.kind)==="length"?e.unit:Gc;return i.jsxs("div",{className:p.field,children:[i.jsx("label",{className:p.label,htmlFor:o,children:r("paragraphDialogLineHeight")}),i.jsxs("div",{className:p.lengthRow,children:[i.jsx("input",{id:o,className:p.lengthInput,value:a==="normal"?"":u,disabled:t||a==="normal",inputMode:"decimal",onChange:g=>d(g.target.value),onBlur:()=>{const g=u.trim();if(!g){n(null);return}if(a==="number"||a==="empty"){const C=Number(g.replace(",","."));if(!Number.isFinite(C)||C<0){d(s===null?"":de(s));return}n({kind:"number",value:C}),d(de(C));return}const h=Wo(g,f,!1);if(!h){d(s===null?"":de(s));return}n({kind:"length",value:h.value,unit:h.unit}),d(de(h.value))}}),i.jsxs("select",{className:p.lengthUnit,value:a==="length"?f:a,disabled:t,"aria-label":r("paragraphDialogLengthUnitAria"),onChange:g=>{const h=g.target.value;if(h==="empty"){n(null),d("");return}if(h==="normal"){n({kind:"normal"}),d("");return}if(h==="number"){const y=Number((u||"1.5").replace(",",".")),v=Number.isFinite(y)&&y>=0?y:1.5;n({kind:"number",value:v}),d(de(v));return}const C=h,b=Wo(u||"1",C,!1),x=(b==null?void 0:b.value)??1;n({kind:"length",value:x,unit:C}),d(de(x))},children:[i.jsx("option",{value:"empty"}),i.jsx("option",{value:"normal",children:r("paragraphDialogLineHeightNormal")}),i.jsx("option",{value:"number",children:r("paragraphDialogLineHeightUnitless")}),["pt","px","em","rem","%"].map(g=>i.jsx("option",{value:g,children:r(Ej[g])},g))]})]})]})}function Hj(e){return e?e.kind==="normal"?"normal":e.kind==="number"?"number":"length":"empty"}function zj({open:e,tab:t,value:n,backgroundImage:r,disabled:o,customImagePicker:a,onCustomImagePick:s,onTabChange:u,onApply:d,onClose:f}){const g=q(),h=l.useId(),C=l.useRef(null),[b,x]=l.useState(n),[y,v]=l.useState(r);return l.useEffect(()=>{e&&(x(n),v(r??kn()))},[e,n,r]),qe(C,{open:e,onClose:f,focusableSelector:'button:not([disabled]):not([tabindex="-1"]), input:not([disabled]), select:not([disabled])'}),e?i.jsx(we,{children:i.jsx("div",{className:p.backdrop,role:"presentation",onMouseDown:f,children:i.jsxs("div",{ref:C,className:`${p.dialog} ${p.dialogWide}`,role:"dialog","aria-modal":"true","aria-labelledby":h,onMouseDown:k=>k.stopPropagation(),children:[i.jsx("h2",{className:p.header,id:h,children:g("paragraphDialogTitle")}),i.jsx(_u,{tab:t,value:b,disabled:o,backgroundImage:y,customImagePicker:a,onCustomImagePick:s,onBackgroundImageChange:v,onTabChange:u,onChange:x}),i.jsxs("div",{className:p.actions,children:[i.jsx("button",{type:"button",className:p.action,onClick:f,children:g("fontDialogCancel")}),i.jsx("button",{type:"button",className:`${p.action} ${p.actionPrimary}`,disabled:o,onClick:()=>d({value:b,backgroundImage:y}),children:g("fontDialogOk")})]})]})})}):null}const Oj=["auto","A4","letter","legal","custom"],Kj={auto:"pageAtRuleSizeAuto",A4:"pageAtRuleSizeA4",letter:"pageAtRuleSizeLetter",legal:"pageAtRuleSizeLegal",custom:"pageAtRuleSizeCustom"},$j={top:"paragraphDialogSideTop",right:"paragraphDialogSideRight",bottom:"paragraphDialogSideBottom",left:"paragraphDialogSideLeft"};function Nf(e){return e===null?"":de(e.value)}function Uj({value:e,disabled:t,onChange:n,onReset:r}){const o=q(),a=l.useId(),[s,u]=l.useState(!0),d=e??Ln(),f=(g,h)=>{if(s){n({...d,margin:{top:h,right:h,bottom:h,left:h},marginMixed:!1});return}n({...d,margin:{...d.margin,[g]:h},marginMixed:!1})};return i.jsxs("div",{className:p.body,children:[i.jsxs("div",{className:p.field,children:[i.jsx("label",{className:p.label,htmlFor:a,children:o("pageAtRuleSize")}),i.jsx("select",{id:a,className:p.select,disabled:t,value:d.sizePreset,onChange:g=>n({...d,sizePreset:g.target.value}),children:Oj.map(g=>i.jsx("option",{value:g,children:o(Kj[g])},g))})]}),d.sizePreset==="custom"?i.jsxs("div",{className:p.sideGrid,children:[i.jsx(ql,{label:o("pageAtRuleWidth"),value:d.customWidth,disabled:t,onChange:g=>n({...d,customWidth:g})}),i.jsx(ql,{label:o("pageAtRuleHeight"),value:d.customHeight,disabled:t,onChange:g=>n({...d,customHeight:g})})]}):null,i.jsxs("div",{className:p.field,children:[i.jsx("span",{className:p.label,children:o("pageAtRuleOrientation")}),i.jsx("div",{className:p.marks,children:[["none","pageAtRuleOrientationNone"],["portrait","pageAtRuleOrientationPortrait"],["landscape","pageAtRuleOrientationLandscape"]].map(([g,h])=>i.jsxs("label",{className:p.mark,children:[i.jsx("input",{type:"radio",name:"page-orientation",checked:(d.orientation??"none")===g,disabled:t,onChange:()=>n({...d,orientation:g==="none"?null:g})}),o(h)]},g))})]}),i.jsxs("fieldset",{className:p.nestedGroup,children:[i.jsx("legend",{className:p.subLabel,children:o("pageAtRuleMargins")}),i.jsxs("label",{className:p.mark,children:[i.jsx("input",{type:"checkbox",checked:s,disabled:t,onChange:()=>u(!s)}),o("paragraphDialogLinkSides")]}),i.jsx("div",{className:p.sideGrid,children:(s?["top"]:ot).map(g=>i.jsx(ql,{label:o(s?"pageAtRuleMargins":$j[g]),value:d.margin[g],disabled:t,onChange:h=>f(g,h)},g))})]}),i.jsx("div",{className:p.actions,children:i.jsx("button",{type:"button",className:p.action,disabled:t,"aria-label":o("pageAtRuleResetAria"),onClick:r,children:o("pageAtRuleReset")})})]})}function ql({label:e,value:t,disabled:n,onChange:r}){const o=q(),a=l.useId(),[s,u]=l.useState(()=>Nf(t)),d=(t==null?void 0:t.unit)??Gc;return i.jsxs("div",{className:p.field,children:[i.jsx("label",{className:p.label,htmlFor:a,children:e}),i.jsxs("div",{className:p.lengthRow,children:[i.jsx("input",{id:a,className:p.lengthInput,value:s,disabled:n,inputMode:"decimal",onChange:f=>u(f.target.value),onBlur:()=>{const f=s.trim();if(!f){r(null);return}const g=Wo(f,d,!1);if(!g){u(Nf(t));return}r(g),u(de(g.value))}}),i.jsxs("select",{className:p.lengthUnit,disabled:n,value:d,"aria-label":o("paragraphDialogLengthUnitAria"),onChange:f=>{const g=f.target.value;t&&r({...t,unit:g})},children:[i.jsx("option",{value:"pt",children:o("fontSizeUnitPt")}),i.jsx("option",{value:"px",children:o("fontSizeUnitPx")}),i.jsx("option",{value:"em",children:o("fontSizeUnitEm")}),i.jsx("option",{value:"rem",children:o("fontSizeUnitRem")}),i.jsx("option",{value:"%",children:o("fontSizeUnitPercent")})]})]})]})}const Vj=Xh.map(e=>e.id);function Wj(e){return{...Yr(),...e}}function Gj(e){const{align:t,alignMixed:n,list:r,listMixed:o,...a}=e;return a}function Zj({open:e,tab:t,value:n,fonts:r,disabled:o,printTabVisible:a=!1,initialParagraphTab:s="spacing",customImagePicker:u,onCustomImagePick:d,onTabChange:f,onApply:g,onResetAtRule:h,onClose:C}){const b=q(),x=l.useId(),y=l.useRef(null),[v,k]=l.useState("general"),[S,P]=l.useState("spacing"),[R,D]=l.useState(n.font),[A,T]=l.useState(n.box),[_,M]=l.useState(n.backgroundImage),[z,E]=l.useState(n.atRule??Ln());if(l.useEffect(()=>{e&&(k("general"),P(s==="general"?"spacing":s),D(n.font),T(n.box),M(n.backgroundImage??kn()),E(n.atRule??Ln()),t==="print"&&!a&&f("font"))},[e,n,t,a,s,f]),qe(y,{open:e,onClose:C,focusableSelector:'button:not([disabled]):not([tabindex="-1"]), input:not([disabled]), select:not([disabled])'}),!e)return null;const N=b("pageDialogTitle"),O=t==="print"&&!a?"font":t;return i.jsx(we,{children:i.jsx("div",{className:p.backdrop,role:"presentation",onMouseDown:C,children:i.jsxs("div",{ref:y,className:`${p.dialog} ${p.dialogWide}`,role:"dialog","aria-modal":"true","aria-labelledby":x,onMouseDown:G=>G.stopPropagation(),children:[i.jsx("h2",{className:p.header,id:x,children:N}),i.jsxs("div",{className:p.tabs,role:"tablist","aria-label":N,children:[i.jsx("button",{type:"button",className:p.tab,role:"tab","aria-selected":O==="font",onClick:()=>f("font"),children:b("customStyleDialogTabFont")}),i.jsx("button",{type:"button",className:p.tab,role:"tab","aria-selected":O==="paragraph",onClick:()=>f("paragraph"),children:b("customStyleDialogTabParagraph")}),a?i.jsx("button",{type:"button",className:p.tab,role:"tab","aria-selected":O==="print",onClick:()=>f("print"),children:b("pageDialogTabPrint")}):null]}),O==="font"?i.jsx("div",{className:p.nestedPanel,children:i.jsx(Iu,{tab:v,value:R,fonts:r,disabled:o,onTabChange:k,onChange:D})}):O==="paragraph"?i.jsx("div",{className:p.nestedPanel,children:i.jsx(_u,{tab:S,value:Wj(A),disabled:o,tabs:Vj,tablistLabelKey:"pageDialogTitle",backgroundImage:_,customImagePicker:u,onCustomImagePick:d,onBackgroundImageChange:M,onTabChange:G=>{G!=="general"&&P(G)},onChange:G=>T(Gj(G))})}):i.jsx("div",{className:p.nestedPanel,children:i.jsx(Uj,{value:z,disabled:o,onChange:E,onReset:()=>{E(Ln()),h==null||h()}})}),i.jsxs("div",{className:p.actions,children:[i.jsx("button",{type:"button",className:p.action,onClick:C,children:b("fontDialogCancel")}),i.jsx("button",{type:"button",className:`${p.action} ${p.actionPrimary}`,disabled:o,onClick:()=>g({font:R,box:A,backgroundImage:_,atRule:a?z:n.atRule??Ln()}),children:b("fontDialogOk")})]})]})})})}function qj({open:e,disabled:t,onClose:n,onConfirm:r}){const o=q(),a=l.useId(),s=l.useRef(null);if(l.useEffect(()=>{if(!e)return;const d=s.current;if(!d)return;const f=d.querySelector('button:not([disabled]):not([tabindex="-1"])');f==null||f.focus();const g=h=>{h.key==="Escape"&&(h.preventDefault(),n())};return document.addEventListener("keydown",g,!0),()=>document.removeEventListener("keydown",g,!0)},[e,n]),!e)return null;const u=!!t;return i.jsx(we,{children:i.jsx("div",{className:p.backdrop,role:"presentation",onMouseDown:n,children:i.jsxs("div",{ref:s,className:p.dialog,role:"dialog","aria-modal":"true","aria-labelledby":a,onMouseDown:d=>d.stopPropagation(),children:[i.jsxs("div",{className:p.headerRow,children:[i.jsx("h2",{className:p.header,id:a,children:o("deletePageDialogTitle")}),i.jsx("button",{type:"button",className:p.close,"aria-label":o("fontDialogCloseAria"),onClick:n,children:i.jsx(et,{})})]}),i.jsx("div",{className:p.confirmBody,children:o("deletePageConfirmMessage")}),i.jsxs("div",{className:p.actions,children:[i.jsx("button",{type:"button",className:p.action,disabled:u,onClick:n,children:o("fontDialogCancel")}),i.jsx("button",{type:"button",className:`${p.action} ${p.actionDanger}`,disabled:u,onClick:r,children:o("commandDeletePage")})]})]})})})}function Yj(){return typeof crypto<"u"&&typeof crypto.randomUUID=="function"?crypto.randomUUID():`style-${Date.now().toString(16)}-${Math.random().toString(16).slice(2)}`}function Lf(e){return{size:e.size,unit:e.unit,marks:e.marks,fontFamily:e.fontFamily??null,fontFamilyMixed:!1,fontColor:e.fontColor,highlightColor:e.highlightColor,fontColorMixed:!1,highlightColorMixed:!1}}function Xj(e){return{size:e.size,unit:e.unit,marks:e.marks,fontFamily:e.fontFamilyMixed?null:e.fontFamily,fontColor:e.fontColorMixed?null:e.fontColor,highlightColor:e.highlightColorMixed?null:e.highlightColor}}function Jj({open:e,mode:t,styleId:n,name:r="",font:o,paragraph:a,canDelete:s=!1,busy:u,disabled:d,fonts:f,defaultOuterTab:g="font",onSave:h,onDelete:C,onClose:b}){const x=q(),y=l.useId(),v=l.useId(),k=l.useRef(null),[S,P]=l.useState(r),[R,D]=l.useState(g),[A,T]=l.useState("general"),[_,M]=l.useState("general"),[z,E]=l.useState(()=>Lf(o)),[N,O]=l.useState(()=>Sc(a)),[G,Y]=l.useState(!1);l.useEffect(()=>{e&&(P(r),D(g),T("general"),M("general"),E(Lf(o)),O(Sc(a)),Y(!1))},[e,r,o,a,g]);const re=l.useCallback(()=>{if(G){Y(!1);return}b()},[G,b]);if(qe(k,{open:e,onClose:re,focusableSelector:'button:not([disabled]):not([tabindex="-1"]), input:not([disabled]), select:not([disabled])'}),!e)return null;const Z=x(t==="create"?"customStyleDialogAddTitle":"customStyleDialogEditTitle"),J=S.trim().length>0,ne=!!(d||u),ce=()=>{const X=S.trim();X&&h({id:n??Yj(),name:X,font:Xj(z),paragraph:Jg(N)})};return i.jsx(we,{children:i.jsx("div",{className:p.backdrop,role:"presentation",onMouseDown:b,children:i.jsxs("div",{ref:k,className:`${p.dialog} ${p.dialogWide}`,role:"dialog","aria-modal":"true","aria-labelledby":y,"aria-busy":u||void 0,onMouseDown:X=>X.stopPropagation(),children:[i.jsxs("div",{className:p.headerRow,children:[i.jsx("h2",{className:p.header,id:y,children:Z}),i.jsx("button",{type:"button",className:p.close,"aria-label":x("customStyleDialogCloseAria"),onClick:b,children:i.jsx(et,{})})]}),G?i.jsxs(i.Fragment,{children:[i.jsx("div",{className:p.confirmBody,children:x("customStyleDialogDeleteConfirm")}),i.jsxs("div",{className:p.actions,children:[i.jsx("button",{type:"button",className:p.action,disabled:ne,onClick:()=>Y(!1),children:x("fontDialogCancel")}),i.jsx("button",{type:"button",className:`${p.action} ${p.actionDanger}`,disabled:ne||!n,onClick:()=>{n&&(C==null||C(n))},children:x("customStyleDialogDelete")})]})]}):i.jsxs(i.Fragment,{children:[i.jsx("div",{className:p.nameSection,children:i.jsxs("div",{className:p.field,children:[i.jsx("label",{className:p.label,htmlFor:v,children:x("customStyleDialogName")}),i.jsx("input",{id:v,className:p.nameInput,value:S,disabled:ne,onChange:X=>P(X.target.value)})]})}),i.jsxs("div",{className:p.tabs,role:"tablist","aria-label":Z,children:[i.jsx("button",{type:"button",className:p.tab,role:"tab","aria-selected":R==="font",onClick:()=>D("font"),children:x("customStyleDialogTabFont")}),i.jsx("button",{type:"button",className:p.tab,role:"tab","aria-selected":R==="paragraph",onClick:()=>D("paragraph"),children:x("customStyleDialogTabParagraph")})]}),R==="font"?i.jsx("div",{className:p.nestedPanel,children:i.jsx(Iu,{tab:A,value:z,fonts:f,disabled:ne,onTabChange:T,onChange:E})}):i.jsx("div",{className:p.nestedPanel,children:i.jsx(_u,{tab:_,value:N,disabled:ne,onTabChange:M,onChange:O})}),i.jsxs("div",{className:t==="edit"&&s?`${p.actions} ${p.actionsSpread}`:p.actions,children:[t==="edit"&&s?i.jsx("button",{type:"button",className:`${p.action} ${p.actionDanger}`,disabled:ne,onClick:()=>Y(!0),children:x("customStyleDialogDelete")}):null,i.jsxs("div",{className:p.actionsEnd,children:[i.jsx("button",{type:"button",className:p.action,onClick:b,children:x("fontDialogCancel")}),i.jsx("button",{type:"button",className:`${p.action} ${p.actionPrimary}`,disabled:ne||!J,onClick:ce,children:x("fontDialogOk")})]})]})]})]})})})}function Qj({open:e,value:t,disabled:n,onApply:r,onClose:o}){const a=q(),s=l.useId(),u=l.useId(),d=l.useRef(null),f=l.useRef(null),[g,h]=l.useState(t);if(l.useEffect(()=>{e&&h(t)},[e,t]),qe(d,{open:e,onClose:o,escapeIgnoreSelectors:!1,focusableSelector:'button:not([disabled]):not([tabindex="-1"]), input:not([disabled]), select:not([disabled]), textarea:not([disabled])'}),l.useEffect(()=>{var b;e&&((b=f.current)==null||b.focus())},[e]),!e)return null;const C=()=>{n||r(g)};return i.jsx(we,{children:i.jsx("div",{className:p.backdrop,role:"presentation",onMouseDown:o,children:i.jsxs("div",{ref:d,className:p.dialog,role:"dialog","aria-modal":"true","aria-labelledby":s,onMouseDown:b=>b.stopPropagation(),children:[i.jsxs("div",{className:p.headerRow,children:[i.jsx("h2",{className:p.header,id:s,children:a("customCssDialogTitle")}),i.jsx("button",{type:"button",className:p.close,"aria-label":a("customCssDialogCloseAria"),onClick:o,children:i.jsx(et,{})})]}),i.jsx("div",{className:p.body,children:i.jsxs("div",{className:p.field,children:[i.jsx("label",{className:p.label,htmlFor:u,children:a("customCssDialogField")}),i.jsx("textarea",{ref:f,id:u,className:p.textarea,value:g,disabled:n,spellCheck:!1,"aria-label":a("customCssDialogFieldAria"),rows:8,onChange:b=>h(b.target.value)})]})}),i.jsxs("div",{className:p.actions,children:[i.jsx("button",{type:"button",className:p.action,onClick:o,children:a("fontDialogCancel")}),i.jsx("button",{type:"button",className:`${p.action} ${p.actionPrimary}`,disabled:n,onClick:C,children:a("fontDialogOk")})]})]})})})}const eI={empty:"bookmarkDialogErrorEmpty",invalid:"bookmarkDialogErrorInvalid",duplicate:"bookmarkDialogErrorDuplicate"};function tI({open:e,existingIds:t,disabled:n,onApply:r,onClose:o}){const a=q(),s=l.useId(),u=l.useId(),d=l.useId(),f=l.useRef(null),[g,h]=l.useState(""),[C,b]=l.useState(!1),x=l.useMemo(()=>new Set(t),[t]),y=oh(g,x);if(l.useEffect(()=>{e&&(h(""),b(!1))},[e]),qe(f,{open:e,onClose:o,escapeIgnoreSelectors:!1,focusableSelector:'button:not([disabled]):not([tabindex="-1"]), input:not([disabled]), select:not([disabled])'}),!e)return null;const v=C||g.trim().length>0?y:null,k=y===null&&!n,S=()=>{b(!0),!(y||n)&&r(g.trim())};return i.jsx(we,{children:i.jsx("div",{className:p.backdrop,role:"presentation",onMouseDown:o,children:i.jsxs("div",{ref:f,className:p.dialog,role:"dialog","aria-modal":"true","aria-labelledby":s,onMouseDown:P=>P.stopPropagation(),children:[i.jsxs("div",{className:p.headerRow,children:[i.jsx("h2",{className:p.header,id:s,children:a("bookmarkDialogTitle")}),i.jsx("button",{type:"button",className:p.close,"aria-label":a("bookmarkDialogCloseAria"),onClick:o,children:i.jsx(et,{})})]}),i.jsx("div",{className:p.body,children:i.jsxs("div",{className:p.field,children:[i.jsxs("div",{className:p.labelRow,children:[i.jsx("label",{className:p.label,htmlFor:u,children:a("bookmarkDialogName")}),i.jsx(Wn,{label:a("bookmarkDialogHelp"),elevated:!0,children:i.jsx("button",{type:"button",className:p.help,"aria-label":a("bookmarkDialogHelpAria"),children:"?"})})]}),i.jsx("input",{id:u,className:p.textInput,value:g,disabled:n,"aria-invalid":v!==null,"aria-describedby":v?d:void 0,onChange:P=>h(P.target.value)}),v?i.jsx("p",{id:d,className:p.error,children:a(eI[v])}):null]})}),i.jsxs("div",{className:p.actions,children:[i.jsx("button",{type:"button",className:p.action,onClick:o,children:a("fontDialogCancel")}),i.jsx("button",{type:"button",className:`${p.action} ${p.actionPrimary}`,disabled:!k,onClick:S,children:a("fontDialogOk")})]})]})})})}const nI={empty:"audioDialogErrorEmpty",invalid:"audioDialogErrorInvalid"},rI={type:"audioDialogErrorType",tooLarge:"audioDialogErrorTooLarge"};function oI({open:e,disabled:t,customAudioPicker:n,onApply:r,onCustomPick:o,onClose:a}){const s=q(),u=l.useId(),d=l.useId(),f=l.useId(),g=l.useId(),h=l.useRef(null),C=l.useRef(null),[b,x]=l.useState("file"),[y,v]=l.useState(""),[k,S]=l.useState(""),[P,R]=l.useState(""),[D,A]=l.useState(""),[T,_]=l.useState(null),[M,z]=l.useState(!1);if(l.useEffect(()=>{e&&(x("file"),v(""),S(""),R(""),A(""),_(null),z(!1),C.current&&(C.current.value=""))},[e]),qe(h,{open:e,onClose:a,escapeIgnoreSelectors:!1}),!e)return null;const E=b==="file"?k:b==="url"?y:"",N=b==="custom"?null:Pu(E),O=b==="custom"?null:b==="file"&&T?rI[T]:N&&(b==="file"||y.trim().length>0)?nI[N]:null,G=b!=="custom"&&N===null&&!(b==="file"&&T)&&!t&&!M,Y=()=>{t||!n||o==null||o()},re=()=>{G&&r({src:E.trim(),title:D.trim()})},Z=J=>{var ce;const ne=(ce=J.target.files)==null?void 0:ce[0];ne&&(z(!0),_(null),_S(ne).then(X=>{S(X),R(ne.name),x("file"),z(!1)},X=>{const I=X instanceof Error?X.message:"";S(""),R(""),x("file"),_(I==="tooLarge"||I==="type"?I:"type"),z(!1),C.current&&(C.current.value="")}))};return i.jsx(we,{children:i.jsx("div",{className:p.backdrop,role:"presentation",onMouseDown:a,children:i.jsxs("div",{ref:h,className:p.dialog,role:"dialog","aria-modal":"true","aria-labelledby":u,onMouseDown:J=>J.stopPropagation(),children:[i.jsxs("div",{className:p.headerRow,children:[i.jsx("h2",{className:p.header,id:u,children:s("audioDialogTitle")}),i.jsx("button",{type:"button",className:p.close,"aria-label":s("audioDialogCloseAria"),onClick:a,children:i.jsx(et,{})})]}),i.jsxs("div",{className:p.body,children:[i.jsxs("fieldset",{className:p.group,children:[i.jsx("legend",{className:p.subLabel,children:s("audioDialogSource")}),i.jsxs("div",{className:p.sizeRow,role:"radiogroup","aria-label":s("audioDialogSource"),children:[i.jsx("button",{type:"button",className:p.action,role:"radio","aria-checked":b==="file",disabled:t,onClick:()=>x("file"),children:s("audioDialogFile")}),i.jsx("button",{type:"button",className:p.action,role:"radio","aria-checked":b==="url",disabled:t,onClick:()=>x("url"),children:s("audioDialogUrl")}),n?i.jsx("button",{type:"button",className:p.action,role:"radio","aria-checked":b==="custom",disabled:t,onClick:()=>x("custom"),children:n.text}):null]}),b==="file"?i.jsxs("div",{className:p.fileRow,children:[i.jsx("input",{ref:C,type:"file",accept:PS,hidden:!0,disabled:t,"aria-label":s("audioDialogChooseFile"),onChange:Z}),i.jsx("button",{type:"button",className:p.action,disabled:t||M,onClick:()=>{var J;return(J=C.current)==null?void 0:J.click()},children:s("audioDialogChooseFile")}),P?i.jsx("span",{className:p.fileName,children:P}):null]}):null,b==="url"?i.jsxs("div",{className:p.field,children:[i.jsx("label",{className:p.label,htmlFor:d,children:s("audioDialogUrl")}),i.jsx("input",{id:d,className:p.textInput,value:y,disabled:t,"aria-invalid":O!==null,"aria-describedby":O?g:void 0,onChange:J=>v(J.target.value)})]}):null,b==="custom"&&n?i.jsxs("div",{className:p.field,children:[i.jsx("p",{className:p.emptyHint,children:n.description}),i.jsx("button",{type:"button",className:p.action,disabled:t,onClick:Y,children:n.buttonCaption})]}):null]}),b!=="custom"?i.jsxs("div",{className:p.field,children:[i.jsx("label",{className:p.label,htmlFor:f,children:s("audioDialogTitleField")}),i.jsx("input",{id:f,className:p.textInput,value:D,disabled:t,onChange:J=>A(J.target.value)})]}):null,O?i.jsx("p",{id:g,className:p.error,children:s(O)}):null]}),i.jsxs("div",{className:p.actions,children:[i.jsx("button",{type:"button",className:p.action,onClick:a,children:s("fontDialogCancel")}),b!=="custom"?i.jsx("button",{type:"button",className:`${p.action} ${p.actionPrimary}`,disabled:!G,onClick:re,children:s("fontDialogOk")}):null]})]})})})}function iI({open:e,disabled:t,customImagePicker:n,onApply:r,onCustomPick:o,onClose:a}){const s=q(),u=l.useId(),d=l.useId(),f=l.useId(),g=l.useRef(null),[h,C]=l.useState(""),[b,x]=l.useState(""),[y,v]=l.useState(""),[k,S]=l.useState("file");if(l.useEffect(()=>{e&&(C(""),x(""),v(""),S("file"))},[e]),qe(g,{open:e,onClose:a,escapeIgnoreSelectors:!1}),!e)return null;const P=Aj(h)&&!t,R=()=>{P&&r({src:h.trim(),alt:b.trim(),title:y.trim()})};return i.jsx(we,{children:i.jsx("div",{className:p.backdrop,role:"presentation",onMouseDown:a,children:i.jsxs("div",{ref:g,className:p.dialog,role:"dialog","aria-modal":"true","aria-labelledby":u,onMouseDown:D=>D.stopPropagation(),children:[i.jsxs("div",{className:p.headerRow,children:[i.jsx("h2",{className:p.header,id:u,children:s("imageDialogTitle")}),i.jsx("button",{type:"button",className:p.close,"aria-label":s("imageDialogCloseAria"),onClick:a,children:i.jsx(et,{})})]}),i.jsxs("div",{className:p.body,children:[i.jsx(Qh,{src:h,disabled:t,customImagePicker:n,onCustomPick:o,onSourceChange:S,onSrcChange:C}),k!=="custom"?i.jsxs(i.Fragment,{children:[i.jsxs("div",{className:p.field,children:[i.jsx("label",{className:p.label,htmlFor:d,children:s("imageDialogAlt")}),i.jsx("input",{id:d,className:p.textInput,value:b,disabled:t,onChange:D=>x(D.target.value)})]}),i.jsxs("div",{className:p.field,children:[i.jsx("label",{className:p.label,htmlFor:f,children:s("imageDialogTitleField")}),i.jsx("input",{id:f,className:p.textInput,value:y,disabled:t,onChange:D=>v(D.target.value)})]})]}):null]}),i.jsxs("div",{className:p.actions,children:[i.jsx("button",{type:"button",className:p.action,onClick:a,children:s("fontDialogCancel")}),k!=="custom"?i.jsx("button",{type:"button",className:`${p.action} ${p.actionPrimary}`,disabled:!P,onClick:R,children:s("fontDialogOk")}):null]})]})})})}const aI=[{id:"general",labelKey:"fontDialogTabGeneral",implemented:!0},{id:"alignment",labelKey:"imagePropertiesTabAlignment",implemented:!0},{id:"border",labelKey:"imagePropertiesTabBorder",implemented:!0},{id:"advanced",labelKey:"imagePropertiesTabAdvanced",implemented:!0},{id:"hover",labelKey:"imagePropertiesTabHover",implemented:!0}],sI={left:ts,center:es,right:ns},lI=["left","center","right"],cI={left:"commandAlignLeftAria",center:"commandAlignCenterAria",right:"commandAlignRightAria"},uI=["width","height","lock"],dI={width:"imagePropertiesSizeWidth",height:"imagePropertiesSizeHeight",lock:"imagePropertiesSizeLock"},mI={top:"paragraphDialogSideTop",right:"paragraphDialogSideRight",bottom:"paragraphDialogSideBottom",left:"paragraphDialogSideLeft"},fI={none:"paragraphDialogBorderStyleNone",solid:"paragraphDialogBorderStyleSolid",dotted:"paragraphDialogBorderStyleDotted",dashed:"paragraphDialogBorderStyleDashed",double:"paragraphDialogBorderStyleDouble",groove:"paragraphDialogBorderStyleGroove",ridge:"paragraphDialogBorderStyleRidge",inset:"paragraphDialogBorderStyleInset",outset:"paragraphDialogBorderStyleOutset"},pI={value:1,unit:"pt"},gI={offsetX:{value:0,unit:"px"},offsetY:{value:4,unit:"px"},blur:{value:8,unit:"px"},spread:{value:0,unit:"px"},color:"#000000",inset:!1};function Yl(e){return{top:e,right:e,bottom:e,left:e}}function hI(e){for(const t of ot)if(e[t])return e[t];return null}function bI({tab:e,value:t,aspectRatio:n,disabled:r,onTabChange:o,onChange:a}){const s=q(),u=l.useId(),d=l.useId(),f=l.useId(),[g,h]=l.useState(()=>vn(t.margin,Yl(t.margin.top))),C=t.align==="center",b=(y,v)=>{if(t.sizeMode==="lock"&&v){const k=$o(y,v,n);a({...t,width:k.width,height:k.height});return}a({...t,[y]:v})},x=y=>{if(y==="width"){a({...t,sizeMode:y,height:null});return}if(y==="height"){a({...t,sizeMode:y,width:null});return}if(t.width){const v=$o("width",t.width,n);a({...t,sizeMode:y,width:v.width,height:v.height});return}if(t.height){const v=$o("height",t.height,n);a({...t,sizeMode:y,width:v.width,height:v.height});return}a({...t,sizeMode:y})};return i.jsxs(i.Fragment,{children:[i.jsx("div",{className:p.tabs,role:"tablist","aria-label":s("imagePropertiesDialogTitle"),children:aI.map(y=>i.jsx("button",{type:"button",className:p.tab,role:"tab","aria-selected":y.id===e,disabled:!y.implemented,onClick:()=>o(y.id),children:s(y.labelKey)},y.id))}),i.jsxs("div",{className:p.body,role:"tabpanel",children:[e==="general"?i.jsxs("fieldset",{className:p.group,children:[i.jsx("legend",{className:p.label,children:s("imagePropertiesSize")}),i.jsx("div",{className:p.iconRow,role:"radiogroup","aria-label":s("imagePropertiesSizeMode"),children:uI.map(y=>i.jsx("button",{type:"button",className:p.action,role:"radio","aria-checked":t.sizeMode===y,disabled:r,onClick:()=>x(y),children:s(dI[y])},y))}),i.jsx(Qa,{label:s("imagePropertiesWidth"),inputAria:s("imagePropertiesWidthAria"),value:t.width,disabled:r||t.sizeMode==="height",onChange:y=>b("width",y)}),i.jsx(Qa,{label:s("imagePropertiesHeight"),inputAria:s("imagePropertiesHeightAria"),value:t.height,disabled:r||t.sizeMode==="width",onChange:y=>b("height",y)})]}):null,e==="alignment"?i.jsxs("fieldset",{className:p.group,children:[i.jsx("legend",{className:p.label,children:s("paragraphDialogAlignment")}),i.jsx("div",{className:p.iconRow,role:"radiogroup","aria-label":s("paragraphDialogAlignment"),children:lI.map(y=>{const v=sI[y];return i.jsx("button",{type:"button",className:p.iconButton,role:"radio","aria-checked":t.align===y,"aria-label":s(cI[y]),disabled:r,onClick:()=>{a({...t,align:t.align===y?null:y})},children:i.jsx(v,{})},y)})})]}):null,e==="border"?i.jsxs(i.Fragment,{children:[i.jsxs("fieldset",{className:p.group,children:[i.jsx("legend",{className:p.label,children:s("paragraphDialogMargin")}),i.jsxs("label",{className:p.mark,children:[i.jsx("input",{type:"checkbox",checked:g,disabled:r||C,onChange:()=>{const y=!g;h(y),y&&a({...t,margin:Yl(hI(t.margin))})}}),s("paragraphDialogLinkSides")]}),i.jsx("div",{className:p.sideGrid,children:(g?["top"]:ot).map(y=>i.jsx(Qe,{label:s(g?"paragraphDialogMargin":mI[y]),value:t.margin[y],disabled:r||C&&(y==="left"||y==="right"),allowNegative:!0,onChange:v=>{const k=g?Yl(v):{...t.margin,[y]:v};a({...t,margin:k})}},y))})]}),i.jsxs("fieldset",{className:p.group,children:[i.jsx("legend",{className:p.label,children:s("paragraphDialogBorder")}),i.jsxs("div",{className:p.field,children:[i.jsx("label",{className:p.label,htmlFor:u,children:s("paragraphDialogBorderStyle")}),i.jsx("select",{id:u,className:p.select,value:t.border.style,disabled:r,onChange:y=>{const v=y.target.value;a({...t,border:{style:v,width:v==="none"?null:t.border.width??pI,color:v==="none"?null:t.border.color}})},children:as.map(y=>i.jsx("option",{value:y,children:s(fI[y])},y))})]}),t.border.style!=="none"?i.jsxs(i.Fragment,{children:[i.jsx(Qe,{label:s("paragraphDialogBorderWidth"),value:t.border.width,disabled:r,onChange:y=>{a({...t,border:{...t.border,width:y}})}}),i.jsx($t,{label:s("paragraphDialogBorderColor"),noneLabel:s("colorNone"),value:t.border.color,disabled:r,onChange:y=>{a({...t,border:{...t.border,color:y}})}})]}):null,i.jsx(Qe,{label:s("paragraphDialogBorderRadius"),value:t.borderRadius,disabled:r,onChange:y=>{a({...t,borderRadius:y})}}),i.jsxs("label",{className:p.mark,children:[i.jsx("input",{type:"checkbox",checked:t.boxShadow!==null,disabled:r,onChange:()=>{a({...t,boxShadow:t.boxShadow?null:gI})}}),s("paragraphDialogBoxShadow")]}),t.boxShadow?i.jsx(Eu,{shadow:t.boxShadow,disabled:r,onChange:y=>{a({...t,boxShadow:y})}}):null]})]}):null,e==="advanced"?i.jsxs(i.Fragment,{children:[i.jsx(Jh,{value:{opacity:t.opacity,fit:t.objectFit,position:t.objectPosition},disabled:r,onChange:y=>{a(_w({...t,opacity:y.opacity,objectFit:y.fit,objectPosition:y.position},n))}}),i.jsxs("fieldset",{className:p.group,children:[i.jsx("legend",{className:p.label,children:s("imagePropertiesRotation")}),i.jsx("div",{className:p.field,children:i.jsxs("div",{className:p.lengthRow,children:[i.jsx("input",{id:d,className:p.lengthInput,value:t.rotateDeg===null?"":de(t.rotateDeg),disabled:r,inputMode:"decimal","aria-label":s("imagePropertiesRotation"),onChange:y=>{const v=y.target.value.trim();if(!v){a({...t,rotateDeg:null});return}const k=Number(v.replace(",","."));Number.isFinite(k)&&a({...t,rotateDeg:k})}}),i.jsx("span",{className:p.lengthUnit,"aria-hidden":"true",children:s("imagePropertiesRotationUnit")})]})})]})]}):null,e==="hover"?i.jsxs("fieldset",{className:p.group,children:[i.jsx("legend",{className:p.label,children:s("imagePropertiesTabHover")}),i.jsx("p",{className:p.emptyHint,children:s("imagePropertiesHoverHelp")}),i.jsxs("div",{className:p.field,children:[i.jsx("label",{className:p.label,htmlFor:f,children:s("imagePropertiesHoverCss")}),i.jsx("textarea",{id:f,className:p.textarea,value:t.hoverCss,disabled:r,spellCheck:!1,"aria-label":s("imagePropertiesHoverCssAria"),onChange:y=>{a({...t,hoverCss:y.target.value})}})]})]}):null]})]})}function yI({open:e,tab:t,value:n,aspectRatio:r=1,disabled:o,onTabChange:a,onApply:s,onClose:u}){const d=q(),f=l.useId(),g=l.useRef(null),[h,C]=l.useState(n);return l.useEffect(()=>{e&&C(n)},[e,n]),qe(g,{open:e,onClose:u,focusableSelector:'button:not([disabled]):not([tabindex="-1"]), input:not([disabled]), select:not([disabled]), textarea:not([disabled])'}),e?i.jsx(we,{children:i.jsx("div",{className:p.backdrop,role:"presentation",onMouseDown:u,children:i.jsxs("div",{ref:g,className:`${p.dialog} ${p.dialogWide}`,role:"dialog","aria-modal":"true","aria-labelledby":f,onMouseDown:b=>b.stopPropagation(),children:[i.jsxs("div",{className:p.headerRow,children:[i.jsx("h2",{className:p.header,id:f,children:d("imagePropertiesDialogTitle")}),i.jsx("button",{type:"button",className:p.close,"aria-label":d("imagePropertiesDialogCloseAria"),onClick:u,children:i.jsx(et,{})})]}),i.jsx(bI,{tab:t,value:h,aspectRatio:r,disabled:o,onTabChange:a,onChange:C}),i.jsxs("div",{className:p.actions,children:[i.jsx("button",{type:"button",className:p.action,onClick:u,children:d("fontDialogCancel")}),i.jsx("button",{type:"button",className:`${p.action} ${p.actionPrimary}`,disabled:o,onClick:()=>s(h),children:d("fontDialogOk")})]})]})})}):null}function xI({open:e,tab:t,href:n,title:r,targetBlank:o,textDecorationNone:a,hoverMode:s,hoverColor:u,hoverHtml:d,bookmarks:f,selectedBookmarkId:g,disabled:h,onTabChange:C,onApply:b,onClose:x}){const y=q(),v=l.useId(),k=l.useId(),S=l.useId(),P=l.useId(),R=l.useId(),D=l.useRef(null),[A,T]=l.useState(n),[_,M]=l.useState(r),[z,E]=l.useState(o),[N,O]=l.useState(a),[G,Y]=l.useState(s),[re,Z]=l.useState(u),[J,ne]=l.useState(d),[ce,X]=l.useState(g);if(l.useEffect(()=>{e&&(T(n),M(r),E(o),O(a),Y(s),Z(u),ne(d),X(g))},[e,n,r,o,a,s,u,d,g]),qe(D,{open:e,onClose:x,focusableSelector:'button:not([disabled]):not([tabindex="-1"]), input:not([disabled]), select:not([disabled]), textarea:not([disabled])'}),!e)return null;const I=()=>gs({title:_,targetBlank:z,textDecorationNone:N,hoverMode:G,hoverColor:re,hoverHtml:J}),se=()=>{const L=A.trim();!L||h||b({...I(),href:L})},fe=()=>{!ce||h||b({...I(),href:`#${ce}`})};return i.jsx(we,{children:i.jsx("div",{className:p.backdrop,role:"presentation",onMouseDown:x,children:i.jsxs("div",{ref:D,className:p.dialog,role:"dialog","aria-modal":"true","aria-labelledby":v,onMouseDown:L=>L.stopPropagation(),children:[i.jsx("h2",{className:p.header,id:v,children:y("linkDialogTitle")}),i.jsxs("div",{className:p.tabs,role:"tablist","aria-label":y("linkDialogTitle"),children:[i.jsx("button",{type:"button",className:p.tab,role:"tab","aria-selected":t==="link",onClick:()=>C("link"),children:y("linkDialogTabLink")}),i.jsx("button",{type:"button",className:p.tab,role:"tab","aria-selected":t==="bookmark",onClick:()=>C("bookmark"),children:y("linkDialogTabBookmark")})]}),i.jsxs("div",{className:p.body,role:"tabpanel",children:[t==="link"?i.jsxs(i.Fragment,{children:[i.jsxs("div",{className:p.field,children:[i.jsx("label",{className:p.label,htmlFor:k,children:y("linkDialogHref")}),i.jsx("input",{id:k,className:p.textInput,value:A,disabled:h,onChange:L=>T(L.target.value)})]}),i.jsxs("div",{className:p.field,children:[i.jsx("label",{className:p.label,htmlFor:S,children:y("linkDialogHoverTitle")}),i.jsx("input",{id:S,className:p.textInput,value:_,disabled:h,onChange:L=>M(L.target.value)})]}),i.jsxs("label",{className:p.mark,children:[i.jsx("input",{type:"checkbox",checked:z,disabled:h,onChange:L=>E(L.target.checked)}),y("linkDialogTargetBlank")]})]}):f.length===0?i.jsx("p",{className:p.emptyHint,children:y("linkDialogBookmarkEmpty")}):i.jsxs("div",{className:p.field,children:[i.jsx("label",{className:p.label,htmlFor:P,children:y("linkDialogBookmark")}),i.jsxs("select",{id:P,className:`${p.select} ${p.fullSelect}`,value:ce,disabled:h,onChange:L=>X(L.target.value),children:[i.jsx("option",{value:""}),f.map(L=>i.jsx("option",{value:L.id,children:L.id},L.id))]})]}),i.jsxs("label",{className:p.mark,children:[i.jsx("input",{type:"checkbox",checked:N,disabled:h,onChange:L=>O(L.target.checked)}),y("linkDialogTextDecorationNone")]}),i.jsxs("fieldset",{className:p.group,children:[i.jsx("legend",{className:p.subLabel,children:y("linkDialogHover")}),i.jsxs("div",{className:p.sizeRow,role:"group","aria-label":y("linkDialogHover"),children:[i.jsx("button",{type:"button",className:p.action,"aria-pressed":G==="color",disabled:h,onClick:()=>Y("color"),children:y("linkDialogHoverColor")}),i.jsx("button",{type:"button",className:p.action,"aria-pressed":G==="html",disabled:h,onClick:()=>Y("html"),children:y("linkDialogHoverHtml")})]}),G==="color"?i.jsx($t,{label:y("linkDialogHoverColorField"),noneLabel:y("colorNone"),value:re,disabled:h,onChange:Z}):i.jsxs("div",{className:p.field,children:[i.jsx("label",{className:p.label,htmlFor:R,children:y("linkDialogHoverHtmlAria")}),i.jsx("textarea",{id:R,className:p.textarea,value:J,disabled:h,spellCheck:!1,onChange:L=>ne(L.target.value)})]})]})]}),i.jsxs("div",{className:p.actions,children:[i.jsx("button",{type:"button",className:p.action,disabled:h||!ce,onClick:fe,children:y("linkDialogSelect")}),i.jsx("button",{type:"button",className:p.action,onClick:x,children:y("fontDialogCancel")}),i.jsx("button",{type:"button",className:`${p.action} ${p.actionPrimary}`,disabled:h||!A.trim(),onClick:se,children:y("fontDialogOk")})]})]})})})}const Bf={empty:"youtubeDialogErrorEmpty",invalid:"youtubeDialogErrorInvalid"};function CI({open:e,disabled:t,customVideoPicker:n,onApply:r,onCustomPick:o,onClose:a}){const s=q(),u=l.useId(),d=l.useId(),f=l.useId(),g=l.useId(),h=l.useRef(null),[C,b]=l.useState("url"),[x,y]=l.useState(""),[v,k]=l.useState("");if(l.useEffect(()=>{e&&(b("url"),y(""),k(""))},[e]),qe(h,{open:e,onClose:a,escapeIgnoreSelectors:!1}),!e)return null;const S=C==="custom"?null:ph(x),P=C==="custom"?null:S&&x.trim().length>0?Bf[S]:S==="empty"&&x.trim().length===0?null:S?Bf[S]:null,R=C!=="custom"&&S===null&&!t&&x.trim().length>0,D=()=>{t||!n||o==null||o()},A=()=>{R&&r({url:x.trim(),title:v.trim()})};return i.jsx(we,{children:i.jsx("div",{className:p.backdrop,role:"presentation",onMouseDown:a,children:i.jsxs("div",{ref:h,className:p.dialog,role:"dialog","aria-modal":"true","aria-labelledby":u,onMouseDown:T=>T.stopPropagation(),children:[i.jsxs("div",{className:p.headerRow,children:[i.jsx("h2",{className:p.header,id:u,children:s("youtubeDialogTitle")}),i.jsx("button",{type:"button",className:p.close,"aria-label":s("youtubeDialogCloseAria"),onClick:a,children:i.jsx(et,{})})]}),i.jsxs("div",{className:p.body,children:[i.jsxs("fieldset",{className:p.group,children:[i.jsx("legend",{className:p.subLabel,children:s("audioDialogSource")}),i.jsxs("div",{className:p.sizeRow,role:"radiogroup","aria-label":s("audioDialogSource"),children:[i.jsx("button",{type:"button",className:p.action,role:"radio","aria-checked":C==="url",disabled:t,onClick:()=>b("url"),children:s("youtubeDialogUrl")}),n?i.jsx("button",{type:"button",className:p.action,role:"radio","aria-checked":C==="custom",disabled:t,onClick:()=>b("custom"),children:n.text}):null]}),C==="url"?i.jsxs("div",{className:p.field,children:[i.jsx("label",{className:p.label,htmlFor:d,children:s("youtubeDialogUrl")}),i.jsx("input",{id:d,className:p.textInput,value:x,disabled:t,"aria-invalid":P!==null,"aria-describedby":P?g:void 0,onChange:T=>y(T.target.value)})]}):null,C==="custom"&&n?i.jsxs("div",{className:p.field,children:[i.jsx("p",{className:p.emptyHint,children:n.description}),i.jsx("button",{type:"button",className:p.action,disabled:t,onClick:D,children:n.buttonCaption})]}):null]}),C!=="custom"?i.jsxs("div",{className:p.field,children:[i.jsx("label",{className:p.label,htmlFor:f,children:s("youtubeDialogTitleField")}),i.jsx("input",{id:f,className:p.textInput,value:v,disabled:t,onChange:T=>k(T.target.value)})]}):null,P?i.jsx("p",{id:g,className:p.error,children:s(P)}):null]}),i.jsxs("div",{className:p.actions,children:[i.jsx("button",{type:"button",className:p.action,onClick:a,children:s("fontDialogCancel")}),C!=="custom"?i.jsx("button",{type:"button",className:`${p.action} ${p.actionPrimary}`,disabled:!R,onClick:A,children:s("fontDialogOk")}):null]})]})})})}const wI="_grid_1bpma_1",vI="_cell_1bpma_8",kI="_sizeLabel_1bpma_27",SI="_sizeFields_1bpma_33",AI="_numberInput_1bpma_37",Or={grid:wI,cell:vI,sizeLabel:kI,sizeFields:SI,numberInput:AI},_n={rows:3,cols:3};function PI({open:e,disabled:t,onApply:n,onClose:r}){const o=q(),a=l.useId(),s=l.useId(),u=l.useId(),d=l.useRef(null),[f,g]=l.useState(_n.rows),[h,C]=l.useState(_n.cols),[b,x]=l.useState(String(_n.rows)),[y,v]=l.useState(String(_n.cols)),[k,S]=l.useState(!1);if(l.useEffect(()=>{e&&(g(_n.rows),C(_n.cols),x(String(_n.rows)),v(String(_n.cols)),S(!1))},[e]),qe(d,{open:e,onClose:r,escapeIgnoreSelectors:!1,focusableSelector:'button:not([disabled]):not([tabindex="-1"]), input:not([disabled]):not([hidden]), select:not([disabled])'}),!e)return null;const R=$g(f,h)&&!t,D=(M,z)=>{const E=Math.min(Zr,Math.max(Gr,M)),N=Math.min(Zr,Math.max(Gr,z));g(E),C(N),x(String(E)),v(String(N))},A=(M,z)=>{const E=Number.parseInt(M,10);if(!Number.isFinite(E)){z==="rows"?x(String(f)):v(String(h));return}S(!0),z==="rows"?D(E,h):D(f,E)},T=(M,z)=>{const E=M.replace(/\D/g,"");if(z==="rows"?x(E):v(E),E==="")return;const N=Number.parseInt(E,10);Number.isFinite(N)&&(S(!0),z==="rows"?D(N,h):D(f,N))},_=M=>{(M.key==="e"||M.key==="E"||M.key==="+"||M.key==="-"||M.key===".")&&M.preventDefault()};return i.jsx(we,{children:i.jsx("div",{className:p.backdrop,role:"presentation",onMouseDown:r,children:i.jsxs("div",{ref:d,className:p.dialog,role:"dialog","aria-modal":"true","aria-labelledby":a,onMouseDown:M=>M.stopPropagation(),children:[i.jsxs("div",{className:p.headerRow,children:[i.jsx("h2",{className:p.header,id:a,children:o("tableDialogTitle")}),i.jsx("button",{type:"button",className:p.close,"aria-label":o("tableDialogCloseAria"),onClick:r,children:i.jsx(et,{})})]}),i.jsxs("div",{className:p.body,children:[i.jsx("div",{className:Or.grid,role:"grid","aria-label":o("tableDialogGridAria"),onMouseLeave:()=>{},children:Array.from({length:qm},(M,z)=>Array.from({length:qm},(E,N)=>{const O=z+1,G=N+1,Y=O<=f&&G<=h;return i.jsx("button",{type:"button",className:Or.cell,role:"gridcell","data-active":Y?"true":void 0,"aria-label":`${O} × ${G}`,"aria-pressed":Y&&O===f&&G===h,disabled:t,onMouseEnter:()=>{k||D(O,G)},onClick:()=>{S(!0),D(O,G)}},`${O}-${G}`)}))}),i.jsxs("p",{className:Or.sizeLabel,children:[o("tableDialogSize"),": ",f," × ",h]}),i.jsxs("div",{className:`${p.sizeRow} ${Or.sizeFields}`,children:[i.jsxs("div",{className:p.field,children:[i.jsx("label",{className:p.label,htmlFor:s,children:o("tableDialogRows")}),i.jsx("input",{id:s,className:Or.numberInput,type:"number",inputMode:"numeric",min:Gr,max:Zr,step:1,value:b,disabled:t,onKeyDown:_,onChange:M=>T(M.target.value,"rows"),onBlur:()=>A(b,"rows")})]}),i.jsxs("div",{className:p.field,children:[i.jsx("label",{className:p.label,htmlFor:u,children:o("tableDialogColumns")}),i.jsx("input",{id:u,className:Or.numberInput,type:"number",inputMode:"numeric",min:Gr,max:Zr,step:1,value:y,disabled:t,onKeyDown:_,onChange:M=>T(M.target.value,"cols"),onBlur:()=>A(y,"cols")})]})]})]}),i.jsxs("div",{className:p.actions,children:[i.jsx("button",{type:"button",className:p.action,onClick:r,children:o("fontDialogCancel")}),i.jsx("button",{type:"button",className:`${p.action} ${p.actionPrimary}`,disabled:!R,onClick:()=>{R&&n({rows:f,cols:h})},children:o("tableDialogInsert")})]})]})})})}const TI={none:"paragraphDialogBorderStyleNone",solid:"paragraphDialogBorderStyleSolid",dotted:"paragraphDialogBorderStyleDotted",dashed:"paragraphDialogBorderStyleDashed",double:"paragraphDialogBorderStyleDouble",groove:"paragraphDialogBorderStyleGroove",ridge:"paragraphDialogBorderStyleRidge",inset:"paragraphDialogBorderStyleInset",outset:"paragraphDialogBorderStyleOutset"},RI={value:1,unit:"pt"},DI={offsetX:{value:0,unit:"px"},offsetY:{value:4,unit:"px"},blur:{value:8,unit:"px"},spread:{value:0,unit:"px"},color:"#000000",inset:!1};function jI({value:e,disabled:t,onChange:n}){const r=q(),o=l.useId(),a=l.useId();return i.jsxs("div",{className:p.body,children:[i.jsxs("fieldset",{className:p.group,children:[i.jsx("legend",{className:p.label,children:r("tablePropertiesWidth")}),i.jsx(Qe,{label:r("tablePropertiesWidth"),value:e.width,disabled:t,onChange:s=>n({...e,width:s})}),i.jsxs("div",{className:p.field,children:[i.jsx("label",{className:p.label,htmlFor:o,children:r("tablePropertiesCollapse")}),i.jsxs("select",{id:o,className:p.select,value:e.borderCollapse,disabled:t,onChange:s=>{const u=s.target.value==="separate"?"separate":"collapse";n({...e,borderCollapse:u,borderSpacing:u==="separate"?e.borderSpacing:null})},children:[i.jsx("option",{value:"collapse",children:r("tablePropertiesCollapseCollapse")}),i.jsx("option",{value:"separate",children:r("tablePropertiesCollapseSeparate")})]})]}),e.borderCollapse==="separate"?i.jsx(Qe,{label:r("tablePropertiesSpacing"),value:e.borderSpacing,disabled:t,onChange:s=>n({...e,borderSpacing:s})}):null]}),i.jsxs("fieldset",{className:p.group,children:[i.jsx("legend",{className:p.label,children:r("paragraphDialogBorder")}),i.jsxs("div",{className:p.field,children:[i.jsx("label",{className:p.label,htmlFor:a,children:r("paragraphDialogBorderStyle")}),i.jsx("select",{id:a,className:p.select,value:e.border.style,disabled:t,onChange:s=>{const u=s.target.value;n({...e,border:{style:u,width:u==="none"?null:e.border.width??RI,color:u==="none"?null:e.border.color}})},children:as.map(s=>i.jsx("option",{value:s,children:r(TI[s])},s))})]}),e.border.style!=="none"?i.jsxs(i.Fragment,{children:[i.jsx(Qe,{label:r("paragraphDialogBorderWidth"),value:e.border.width,disabled:t,onChange:s=>n({...e,border:{...e.border,width:s}})}),i.jsx($t,{label:r("paragraphDialogBorderColor"),noneLabel:r("colorNone"),value:e.border.color,disabled:t,onChange:s=>n({...e,border:{...e.border,color:s}})})]}):null,i.jsx(Qe,{label:r("paragraphDialogBorderRadius"),value:e.borderRadius,disabled:t,onChange:s=>n({...e,borderRadius:s})}),i.jsxs("label",{className:p.mark,children:[i.jsx("input",{type:"checkbox",checked:e.boxShadow!==null,disabled:t,onChange:()=>{n({...e,boxShadow:e.boxShadow?null:DI})}}),r("paragraphDialogBoxShadow")]}),e.boxShadow?i.jsx(Eu,{shadow:e.boxShadow,disabled:t,onChange:s=>n({...e,boxShadow:s})}):null]})]})}function II({open:e,value:t,disabled:n,onApply:r,onClose:o}){const a=q(),s=l.useId(),u=l.useRef(null),[d,f]=l.useState(t);return l.useEffect(()=>{e&&f(t)},[e,t]),qe(u,{open:e,onClose:o,focusableSelector:'button:not([disabled]):not([tabindex="-1"]), input:not([disabled]), select:not([disabled]), textarea:not([disabled])'}),e?i.jsx(we,{children:i.jsx("div",{className:p.backdrop,role:"presentation",onMouseDown:o,children:i.jsxs("div",{ref:u,className:`${p.dialog} ${p.dialogWide}`,role:"dialog","aria-modal":"true","aria-labelledby":s,onMouseDown:g=>g.stopPropagation(),children:[i.jsxs("div",{className:p.headerRow,children:[i.jsx("h2",{className:p.header,id:s,children:a("tablePropertiesDialogTitle")}),i.jsx("button",{type:"button",className:p.close,"aria-label":a("tablePropertiesDialogCloseAria"),onClick:o,children:i.jsx(et,{})})]}),i.jsx(jI,{value:d,disabled:n,onChange:f}),i.jsxs("div",{className:p.actions,children:[i.jsx("button",{type:"button",className:p.action,onClick:o,children:a("fontDialogCancel")}),i.jsx("button",{type:"button",className:`${p.action} ${p.actionPrimary}`,disabled:n,onClick:()=>r(d),children:a("fontDialogOk")})]})]})})}):null}const EI=["left","center","right"],_I={left:ts,center:es,right:ns},MI={left:"commandAlignLeftAria",center:"commandAlignCenterAria",right:"commandAlignRightAria"},NI={top:"paragraphDialogSideTop",right:"paragraphDialogSideRight",bottom:"paragraphDialogSideBottom",left:"paragraphDialogSideLeft"},LI={top:"cellPropertiesVerticalAlignTop",middle:"cellPropertiesVerticalAlignMiddle",bottom:"cellPropertiesVerticalAlignBottom",baseline:"cellPropertiesVerticalAlignBaseline"};function wa(e){return{top:e,right:e,bottom:e,left:e}}function Xl(e){for(const t of ot)if(e[t])return e[t];return null}function BI({value:e,disabled:t,onChange:n}){const r=q(),o=l.useId(),a=l.useId(),s=l.useId(),[u,d]=l.useState(()=>vn(e.padding,wa(Xl(e.padding))));return l.useEffect(()=>{d(vn(e.padding,wa(Xl(e.padding))))},[e.padding]),i.jsxs("div",{className:p.body,children:[i.jsx($t,{label:r("paragraphDialogBackgroundColor"),noneLabel:r("colorNone"),value:e.backgroundColor,disabled:t,onChange:f=>n({...e,backgroundColor:f})}),i.jsx($t,{label:r("cellPropertiesColor"),noneLabel:r("colorNone"),value:e.color,disabled:t,onChange:f=>n({...e,color:f})}),i.jsxs("fieldset",{className:p.group,children:[i.jsx("legend",{className:p.label,children:r("paragraphDialogPadding")}),i.jsxs("label",{className:p.mark,children:[i.jsx("input",{type:"checkbox",checked:u,disabled:t,onChange:()=>{const f=!u;d(f),f&&n({...e,padding:wa(Xl(e.padding))})}}),r("paragraphDialogLinkSides")]}),i.jsx("div",{className:p.sideGrid,children:(u?["top"]:ot).map(f=>i.jsx(Qe,{label:r(u?"paragraphDialogPadding":NI[f]),value:e.padding[f],disabled:t,onChange:g=>{const h=u?wa(g):{...e.padding,[f]:g};n({...e,padding:h})}},f))})]}),i.jsxs("fieldset",{className:p.group,children:[i.jsx("legend",{className:p.label,children:r("paragraphDialogAlignment")}),i.jsx("div",{className:p.iconRow,role:"radiogroup","aria-label":r("paragraphDialogAlignment"),children:EI.map(f=>{const g=_I[f],h=(e.textAlign??"left")===f;return i.jsx("button",{type:"button",className:p.iconButton,role:"radio","aria-checked":h,"aria-label":r(MI[f]),disabled:t,onClick:()=>{n({...e,textAlign:f==="left"?null:f})},children:i.jsx(g,{})},f)})})]}),i.jsxs("div",{className:p.field,children:[i.jsx("label",{className:p.label,htmlFor:o,children:r("cellPropertiesVerticalAlign")}),i.jsxs("select",{id:o,className:p.select,value:e.verticalAlign??"",disabled:t,onChange:f=>{const g=f.target.value;n({...e,verticalAlign:g||null})},children:[i.jsx("option",{value:"",children:r("cellPropertiesVerticalAlignDefault")}),bs.map(f=>i.jsx("option",{value:f,children:r(LI[f])},f))]})]}),i.jsx(Qe,{label:r("cellPropertiesWidth"),value:e.width,disabled:t,onChange:f=>n({...e,width:f})}),i.jsxs("div",{className:p.sizeRow,children:[i.jsxs("div",{className:p.field,children:[i.jsx("label",{className:p.label,htmlFor:a,children:r("cellPropertiesColSpan")}),i.jsx("input",{id:a,className:p.lengthInput,type:"number",inputMode:"numeric",min:1,step:1,value:e.colSpan,disabled:t,onChange:f=>{const g=Number.parseInt(f.target.value,10);n({...e,colSpan:Number.isFinite(g)?Math.max(1,g):1})}})]}),i.jsxs("div",{className:p.field,children:[i.jsx("label",{className:p.label,htmlFor:s,children:r("cellPropertiesRowSpan")}),i.jsx("input",{id:s,className:p.lengthInput,type:"number",inputMode:"numeric",min:1,step:1,value:e.rowSpan,disabled:t,onChange:f=>{const g=Number.parseInt(f.target.value,10);n({...e,rowSpan:Number.isFinite(g)?Math.max(1,g):1})}})]})]})]})}function FI({open:e,value:t,disabled:n,onApply:r,onClose:o}){const a=q(),s=l.useId(),u=l.useRef(null),[d,f]=l.useState(t);return l.useEffect(()=>{e&&f(t)},[e,t]),qe(u,{open:e,onClose:o,focusableSelector:'button:not([disabled]):not([tabindex="-1"]), input:not([disabled]), select:not([disabled]), textarea:not([disabled])'}),e?i.jsx(we,{children:i.jsx("div",{className:p.backdrop,role:"presentation",onMouseDown:o,children:i.jsxs("div",{ref:u,className:`${p.dialog} ${p.dialogWide}`,role:"dialog","aria-modal":"true","aria-labelledby":s,onMouseDown:g=>g.stopPropagation(),children:[i.jsxs("div",{className:p.headerRow,children:[i.jsx("h2",{className:p.header,id:s,children:a("cellPropertiesDialogTitle")}),i.jsx("button",{type:"button",className:p.close,"aria-label":a("cellPropertiesDialogCloseAria"),onClick:o,children:i.jsx(et,{})})]}),i.jsx(BI,{value:d,disabled:n,onChange:f}),i.jsxs("div",{className:p.actions,children:[i.jsx("button",{type:"button",className:p.action,onClick:o,children:a("fontDialogCancel")}),i.jsx("button",{type:"button",className:`${p.action} ${p.actionPrimary}`,disabled:n,onClick:()=>r(d),children:a("fontDialogOk")})]})]})})}):null}const HI={top:"paragraphDialogSideTop",right:"paragraphDialogSideRight",bottom:"paragraphDialogSideBottom",left:"paragraphDialogSideLeft"},zI={top:"cellPropertiesVerticalAlignTop",middle:"cellPropertiesVerticalAlignMiddle",bottom:"cellPropertiesVerticalAlignBottom",baseline:"cellPropertiesVerticalAlignBaseline"};function va(e){return{top:e,right:e,bottom:e,left:e}}function Jl(e){for(const t of ot)if(e[t])return e[t];return null}function OI({value:e,disabled:t,onChange:n}){const r=q(),o=l.useId(),[a,s]=l.useState(()=>vn(e.padding,va(Jl(e.padding))));return l.useEffect(()=>{s(vn(e.padding,va(Jl(e.padding))))},[e.padding]),i.jsxs("div",{className:p.body,children:[i.jsx($t,{label:r("paragraphDialogBackgroundColor"),noneLabel:r("colorNone"),value:e.backgroundColor,disabled:t,onChange:u=>n({...e,backgroundColor:u})}),i.jsx($t,{label:r("cellPropertiesColor"),noneLabel:r("colorNone"),value:e.color,disabled:t,onChange:u=>n({...e,color:u})}),i.jsxs("fieldset",{className:p.group,children:[i.jsx("legend",{className:p.label,children:r("paragraphDialogPadding")}),i.jsxs("label",{className:p.mark,children:[i.jsx("input",{type:"checkbox",checked:a,disabled:t,onChange:()=>{const u=!a;s(u),u&&n({...e,padding:va(Jl(e.padding))})}}),r("paragraphDialogLinkSides")]}),i.jsx("div",{className:p.sideGrid,children:(a?["top"]:ot).map(u=>i.jsx(Qe,{label:r(a?"paragraphDialogPadding":HI[u]),value:e.padding[u],disabled:t,onChange:d=>{const f=a?va(d):{...e.padding,[u]:d};n({...e,padding:f})}},u))})]}),i.jsxs("div",{className:p.field,children:[i.jsx("label",{className:p.label,htmlFor:o,children:r("cellPropertiesVerticalAlign")}),i.jsxs("select",{id:o,className:p.select,value:e.verticalAlign??"",disabled:t,onChange:u=>{const d=u.target.value;n({...e,verticalAlign:d||null})},children:[i.jsx("option",{value:"",children:r("cellPropertiesVerticalAlignDefault")}),bs.map(u=>i.jsx("option",{value:u,children:r(zI[u])},u))]})]}),i.jsx(Qe,{label:r("rowPropertiesHeight"),value:e.height,disabled:t,onChange:u=>n({...e,height:u})})]})}function KI({open:e,value:t,disabled:n,onApply:r,onClose:o}){const a=q(),s=l.useId(),u=l.useRef(null),[d,f]=l.useState(t);return l.useEffect(()=>{e&&f(t)},[e,t]),qe(u,{open:e,onClose:o,focusableSelector:'button:not([disabled]):not([tabindex="-1"]), input:not([disabled]), select:not([disabled]), textarea:not([disabled])'}),e?i.jsx(we,{children:i.jsx("div",{className:p.backdrop,role:"presentation",onMouseDown:o,children:i.jsxs("div",{ref:u,className:`${p.dialog} ${p.dialogWide}`,role:"dialog","aria-modal":"true","aria-labelledby":s,onMouseDown:g=>g.stopPropagation(),children:[i.jsxs("div",{className:p.headerRow,children:[i.jsx("h2",{className:p.header,id:s,children:a("rowPropertiesDialogTitle")}),i.jsx("button",{type:"button",className:p.close,"aria-label":a("rowPropertiesDialogCloseAria"),onClick:o,children:i.jsx(et,{})})]}),i.jsx(OI,{value:d,disabled:n,onChange:f}),i.jsxs("div",{className:p.actions,children:[i.jsx("button",{type:"button",className:p.action,onClick:o,children:a("fontDialogCancel")}),i.jsx("button",{type:"button",className:`${p.action} ${p.actionPrimary}`,disabled:n,onClick:()=>r(d),children:a("fontDialogOk")})]})]})})}):null}const $I="_backdrop_9d3gw_1",UI="_dialog_9d3gw_12",VI="_headerRow_9d3gw_29",WI="_header_9d3gw_29",GI="_close_9d3gw_44",ZI="_body_9d3gw_66",qI="_frame_9d3gw_75",YI="_actions_9d3gw_83",XI="_action_9d3gw_83",Cn={backdrop:$I,dialog:UI,headerRow:VI,header:WI,close:GI,body:ZI,frame:qI,actions:YI,action:XI};function JI(e){const t=Fn(e);if(t.length<=1)return e;const n=[],r=[];for(const a of t){const s=he(a);n.push(...s.hrefs),r.push(s.body)}const o=r.map((a,s)=>`<div class="wysiwyg-preview-page" style="${s===r.length-1?"display: block; break-inside: avoid; page-break-inside: avoid;":"display: block; break-after: page; page-break-after: always; break-inside: avoid; page-break-inside: avoid;"}">${a}</div>`).join("");return[...Array.from(new Set(n)).map(a=>`<link rel="stylesheet" href="${a}" />`),o].filter(Boolean).join("")}function QI({open:e,html:t,onClose:n}){const r=q(),o=l.useId(),a=l.useRef(null),s=l.useRef(null),u=l.useMemo(()=>JI(t),[t]);return qe(a,{open:e,onClose:n,escapeIgnoreSelectors:!1,focusableSelector:'button:not([disabled]):not([tabindex="-1"]), input:not([disabled]), select:not([disabled])'}),l.useEffect(()=>{var f;if(!e)return;const d=(f=s.current)==null?void 0:f.contentDocument;d&&pc(d,u,r("previewDialogTitle"))},[e,u,r]),e?i.jsx(we,{children:i.jsx("div",{className:Cn.backdrop,role:"presentation",onMouseDown:n,children:i.jsxs("div",{ref:a,className:Cn.dialog,role:"dialog","aria-modal":"true","aria-labelledby":o,onMouseDown:d=>d.stopPropagation(),children:[i.jsxs("div",{className:Cn.headerRow,children:[i.jsx("h2",{className:Cn.header,id:o,children:r("previewDialogTitle")}),i.jsx("button",{type:"button",className:Cn.close,"aria-label":r("previewDialogCloseAria"),onClick:n,children:i.jsx(et,{})})]}),i.jsx("div",{className:Cn.body,children:i.jsx("iframe",{ref:s,className:Cn.frame,title:r("previewDialogTitle"),sandbox:"allow-same-origin",tabIndex:-1,onLoad:()=>{var f;const d=(f=s.current)==null?void 0:f.contentDocument;d&&pc(d,u,r("previewDialogTitle"))}})}),i.jsx("div",{className:Cn.actions,children:i.jsx("button",{type:"button",className:Cn.action,onClick:n,children:r("previewDialogClose")})})]})})}):null}const eE="0.0.11",tE="_backdrop_72ox3_1",nE="_dialog_72ox3_12",rE="_headerRow_72ox3_30",oE="_header_72ox3_30",iE="_close_72ox3_46",aE="_body_72ox3_68",sE="_product_72ox3_76",lE="_meta_72ox3_82",cE="_description_72ox3_87",uE="_website_72ox3_92",dE="_cta_72ox3_97",mE="_link_72ox3_102",fE="_actions_72ox3_118",pE="_action_72ox3_118",wt={backdrop:tE,dialog:nE,headerRow:rE,header:oE,close:iE,body:aE,product:sE,meta:lE,description:cE,website:uE,cta:dE,link:mE,actions:fE,action:pE};function gE({open:e,onClose:t}){const n=q(),r=l.useId(),o=l.useRef(null);return qe(o,{open:e,onClose:t,escapeIgnoreSelectors:!1,focusableSelector:'a[href], button:not([disabled]):not([tabindex="-1"])'}),e?i.jsx(we,{children:i.jsx("div",{className:wt.backdrop,role:"presentation",onMouseDown:t,children:i.jsxs("div",{ref:o,className:wt.dialog,role:"dialog","aria-modal":"true","aria-labelledby":r,onMouseDown:a=>a.stopPropagation(),children:[i.jsxs("div",{className:wt.headerRow,children:[i.jsx("h2",{id:r,className:wt.header,children:n("aboutDialogTitle")}),i.jsx("button",{type:"button",className:wt.close,onClick:t,"aria-label":n("aboutDialogCloseAria"),children:i.jsx(et,{})})]}),i.jsxs("div",{className:wt.body,children:[i.jsx("p",{className:wt.product,children:n("brandMarkAria")}),i.jsx("p",{className:wt.meta,children:n("aboutDialogVersion").replace("{version}",eE)}),i.jsx("p",{className:wt.description,children:n("aboutDialogDescription")}),i.jsxs("div",{className:wt.website,children:[i.jsx("p",{className:wt.cta,children:n("aboutDialogWebsiteCta")}),i.jsx("a",{className:wt.link,href:"https://commspliant.com/",target:"_blank",rel:"noopener noreferrer","aria-label":n("aboutDialogWebsiteAria"),children:n("aboutDialogWebsite")})]})]}),i.jsx("div",{className:wt.actions,children:i.jsx("button",{type:"button",className:wt.action,onClick:t,children:n("aboutDialogClose")})})]})})}):null}const hE="_backdrop_12fkg_1",bE="_dialog_12fkg_12",yE="_headerRow_12fkg_31",xE="_header_12fkg_31",CE="_close_12fkg_47",wE="_searchRow_12fkg_69",vE="_search_12fkg_69",kE="_body_12fkg_91",SE="_sidebar_12fkg_99",AE="_category_12fkg_111",PE="_topicList_12fkg_121",TE="_topicButton_12fkg_127",RE="_topicButtonActive_12fkg_147",DE="_main_12fkg_157",jE="_articleTitle_12fkg_164",IE="_articleBody_12fkg_171",EE="_noResults_12fkg_176",_E="_related_12fkg_181",ME="_relatedTitle_12fkg_187",NE="_relatedList_12fkg_194",LE="_relatedButton_12fkg_200",BE="_relatedItem_12fkg_223",He={backdrop:hE,dialog:bE,headerRow:yE,header:xE,close:CE,searchRow:wE,search:vE,body:kE,sidebar:SE,category:AE,topicList:PE,topicButton:TE,topicButtonActive:RE,main:DE,articleTitle:jE,articleBody:IE,noResults:EE,related:_E,relatedTitle:ME,relatedList:NE,relatedButton:LE,relatedItem:BE};function FE(e){return{getStarted:"helpCategoryGetStarted",file:"helpCategoryFile",edit:"helpCategoryEdit",insert:"helpCategoryInsert",format:"helpCategoryFormat",table:"helpCategoryTable",view:"helpCategoryView",keyboard:"helpCategoryKeyboard"}[e]}function HE({open:e,topicId:t,onTopicChange:n,onClose:r}){const o=q(),a=l.useId(),s=l.useRef(null),[u,d]=l.useState("");qe(s,{open:e,onClose:r,escapeIgnoreSelectors:!1,focusableSelector:'button:not([disabled]):not([tabindex="-1"]), input:not([disabled]), select:not([disabled])'}),l.useEffect(()=>{e||d("")},[e]);const f=l.useMemo(()=>Nc.map(b=>({id:b.id,title:o(b.titleKey),body:o(b.bodyKey),keywords:o(b.keywordsKey)})),[o]),g=l.useMemo(()=>{const b=DR(f,u);return new Set(b.map(x=>x.id))},[u,f]),h=Tf[t],C=u.trim().length>0&&g.size===0;return e?i.jsx(we,{children:i.jsx("div",{className:He.backdrop,role:"presentation",onMouseDown:r,children:i.jsxs("div",{ref:s,className:He.dialog,role:"dialog","aria-modal":"true","aria-labelledby":a,onMouseDown:b=>b.stopPropagation(),children:[i.jsxs("div",{className:He.headerRow,children:[i.jsx("h2",{id:a,className:He.header,children:o("helpDialogTitle")}),i.jsx("button",{type:"button",className:He.close,onClick:r,"aria-label":o("helpDialogCloseAria"),children:i.jsx(et,{})})]}),i.jsx("div",{className:He.searchRow,children:i.jsx("input",{type:"search",className:He.search,value:u,onChange:b=>d(b.target.value),placeholder:o("helpDialogSearchPlaceholder"),"aria-label":o("helpDialogSearchAria")})}),i.jsxs("div",{className:He.body,children:[i.jsx("aside",{className:He.sidebar,"aria-label":o("helpDialogContentsAria"),children:TR.map(b=>{const x=Nc.filter(y=>y.category===b&&g.has(y.id));return x.length===0?null:i.jsxs("div",{children:[i.jsx("h3",{className:He.category,children:o(FE(b))}),i.jsx("ul",{className:He.topicList,children:x.map(y=>i.jsx("li",{children:i.jsx("button",{type:"button",className:`${He.topicButton}${y.id===t?` ${He.topicButtonActive}`:""}`,onClick:()=>n(y.id),children:o(y.titleKey)})},y.id))})]},b)})}),i.jsx("div",{className:He.main,children:C?i.jsx("p",{className:He.noResults,children:o("helpDialogNoResults")}):i.jsxs(i.Fragment,{children:[i.jsx("h3",{className:He.articleTitle,children:o(h.titleKey)}),i.jsx("p",{className:He.articleBody,children:o(h.bodyKey)}),h.related.length>0?i.jsxs("div",{className:He.related,children:[i.jsx("h4",{className:He.relatedTitle,children:o("helpDialogRelatedTitle")}),i.jsx("ul",{className:He.relatedList,children:h.related.map(b=>{const x=Tf[b];return!x||!g.has(b)?null:i.jsx("li",{className:He.relatedItem,children:i.jsx("button",{type:"button",className:He.relatedButton,onClick:()=>n(b),children:o(x.titleKey)})},b)})})]}):null]})})]})]})})}):null}function eb(e){return{catalog:e.catalog,layout:e.layout,commands:e.commands,queries:e.queries,queryRevisions:e.queryRevisions,disabled:e.disabled,chromeLock:e.chromeLock}}function zE(e,t){for(const n of Object.keys(e)){const r=e[n],o=t[n];if(!(typeof r=="function"&&typeof o=="function")&&r!==o)return!1}return!0}const OE=l.memo(function({menuVisible:t,captureChromeSelection:n,displayCatalog:r,displayLayout:o,commands:a,queries:s,queryRevisions:u,chromeDisabled:d,chromeLock:f,contentLocked:g,customizeToolbarOpen:h,baseCatalog:C,allowedLayout:b,toolbarSettings:x,toolbarSettingsLoading:y,toolbarSettingsBusy:v,onCustomizeToolbarClose:k,onToolbarSettingsChange:S,onToolbarSettingsReset:P,documentPreview:R,onDocumentPreviewClose:D,helpDialog:A,onHelpDialogClose:T,onHelpTopicChange:_,aboutDialogOpen:M,onAboutDialogClose:z,fontDialog:E,fontSizeState:N,markState:O,fontFamilyState:G,fontColorState:Y,highlightColorState:re,fontFaces:Z,onFontDialogTabChange:J,onFontDialogClose:ne,onApplyFontProperties:ce,paragraphDialog:X,customImagePicker:I,onParagraphCustomImagePick:se,onParagraphDialogTabChange:fe,onParagraphDialogClose:L,onApplyParagraphProperties:Le,customCssDialog:Ee,onCustomCssDialogClose:ze,onApplyCustomCss:bt,pageDialog:Ye,enablePageProperties:Oe,onPageCustomImagePick:pe,onPageDialogTabChange:De,onPageDialogClose:oe,onApplyPageProperties:ve,onPageDialogResetAtRule:je,deletePageConfirmOpen:Ne,onDeletePageConfirmClose:We,onDeletePageConfirm:Ut,customStyleDialog:Ue,canDeleteCustomParagraphStyle:Cr,customStyleBusy:wr,onCustomStyleDialogClose:vr,onCustomStyleSave:Be,onCustomStyleDelete:Qt,linkDialog:it,onLinkDialogTabChange:Xn,onLinkDialogClose:kr,onApplyLink:V,bookmarkDialog:ee,onBookmarkDialogClose:me,onApplyBookmark:Ke,imageDialogOpen:Vt,customAudioPicker:Jn,customVideoPicker:ct,onImageDialogClose:$e,onApplyImage:Se,onImageDialogCustomPick:Ge,audioDialogOpen:en,onAudioDialogClose:ys,onApplyAudio:ai,onAudioDialogCustomPick:xs,youtubeDialogOpen:at,onYoutubeDialogClose:si,onApplyYoutube:Rt,onYoutubeDialogCustomPick:Qn,imageProperties:Wt,onImagePropertiesTabChange:Cs,onImagePropertiesClose:mo,onApplyImageProperties:ws,tableDialogOpen:li,onTableDialogClose:Pn,onApplyTable:gn,tableProperties:Sr,onTablePropertiesClose:er,onApplyTableProperties:H,cellProperties:Dt,onCellPropertiesClose:ci,onApplyCellProperties:Ar,rowProperties:yt,onRowPropertiesClose:tr,onApplyRowProperties:ut}){const be=eb({catalog:r,layout:o,commands:a,queries:s,queryRevisions:u,disabled:d,chromeLock:f});return i.jsxs(i.Fragment,{children:[t?i.jsx("div",{className:xe.menuChrome,onPointerDownCapture:n,children:i.jsx(Lc,{...be,menuVisible:!0,toolbarVisible:!1})}):null,h?i.jsx(zA,{open:!0,catalog:C,groups:b.iconGroups,settings:x,loading:y,busy:v,disabled:g,onChange:S,onReset:P,onClose:k}):null,R.open?i.jsx(QI,{open:!0,html:R.html,onClose:D}):null,A.open?i.jsx(HE,{open:!0,topicId:A.topicId,onTopicChange:_,onClose:T}):null,M?i.jsx(gE,{open:!0,onClose:z}):null,E.open?i.jsx(bj,{open:!0,tab:E.tab,size:N.value,unit:N.unit,marks:O,fontFamily:G.value,fontFamilyMixed:G.mixed,fontColor:Y.value,fontColorMixed:Y.mixed,highlightColor:re.value,highlightColorMixed:re.mixed,fonts:Z,disabled:g,onTabChange:J,onApply:ce,onClose:ne}):null,X.open?i.jsx(zj,{open:!0,tab:X.tab,value:X.value,backgroundImage:X.backgroundImage,disabled:g,customImagePicker:I,onCustomImagePick:se,onTabChange:fe,onApply:Le,onClose:L}):null,Ee.open?i.jsx(Qj,{open:!0,value:Ee.value,disabled:g,onApply:bt,onClose:ze}):null,Ye.open?i.jsx(Zj,{open:!0,tab:Ye.tab,initialParagraphTab:Ye.paragraphTab,value:Ye.value,fonts:Z,disabled:g,printTabVisible:Oe,customImagePicker:I,onCustomImagePick:pe,onTabChange:De,onApply:ve,onResetAtRule:je,onClose:oe}):null,Ne?i.jsx(qj,{open:!0,disabled:g,onClose:We,onConfirm:Ut}):null,Ue.open?i.jsx(Jj,{open:!0,mode:Ue.mode,styleId:Ue.mode==="edit"?Ue.style.id:void 0,name:Ue.mode==="edit"?Ue.style.name:"",font:Ue.mode==="edit"?Ue.style.font:Ue.font,paragraph:Ue.mode==="edit"?Ue.style.paragraph:Ue.paragraph,canDelete:Cr,fonts:Z,busy:wr,disabled:g,onSave:Be,onDelete:Qt,onClose:vr}):null,it.open?i.jsx(xI,{open:!0,tab:it.tab,href:it.href,title:it.title,targetBlank:it.targetBlank,textDecorationNone:it.textDecorationNone,hoverMode:it.hoverMode,hoverColor:it.hoverColor,hoverHtml:it.hoverHtml,bookmarks:it.bookmarks,selectedBookmarkId:it.selectedBookmarkId,disabled:g,onTabChange:Xn,onApply:V,onClose:kr}):null,ee.open?i.jsx(tI,{open:!0,existingIds:ee.existingIds,disabled:g,onApply:Ke,onClose:me}):null,Vt?i.jsx(iI,{open:!0,disabled:g,customImagePicker:I,onApply:Se,onCustomPick:Ge,onClose:$e}):null,en?i.jsx(oI,{open:!0,disabled:g,customAudioPicker:Jn,onApply:ai,onCustomPick:xs,onClose:ys}):null,at?i.jsx(CI,{open:!0,disabled:g,customVideoPicker:ct,onApply:Rt,onCustomPick:Qn,onClose:si}):null,Wt.open?i.jsx(yI,{open:!0,tab:Wt.tab,value:Wt.value,aspectRatio:Wt.aspectRatio,disabled:g,onTabChange:Cs,onApply:ws,onClose:mo}):null,li?i.jsx(PI,{open:!0,disabled:g,onApply:gn,onClose:Pn}):null,Sr.open?i.jsx(II,{open:!0,value:Sr.value,disabled:g,onApply:H,onClose:er}):null,Dt.open?i.jsx(FI,{open:!0,value:Dt.value,disabled:g,onApply:Ar,onClose:ci}):null,yt.open?i.jsx(KI,{open:!0,value:yt.value,disabled:g,onApply:ut,onClose:tr}):null]})},zE);function KE({toolbarVisible:e,toolbarPos:t,captureChromeSelection:n,toolbarShellProps:r,children:o}){return i.jsxs("div",{className:xe.body,"data-icon-dock":e?t:void 0,children:[e&&(t==="top"||t==="left")?i.jsx("div",{className:xe.iconChrome,onPointerDownCapture:n,children:i.jsx(Lc,{...r,menuVisible:!1,toolbarVisible:!0,position:t})}):null,o,e&&(t==="bottom"||t==="right")?i.jsx("div",{className:xe.iconChrome,onPointerDownCapture:n,children:i.jsx(Lc,{...r,menuVisible:!1,toolbarVisible:!0,position:t})}):null]})}const tb=l.createContext(null);function $E({value:e,children:t}){return i.jsx(tb.Provider,{value:e,children:t})}function UE(){const e=l.useContext(tb);if(!e)throw new Error("useEditorShellContext must be used within EditorShellProvider");return e}function VE(e,t){const n=l.useRef([]),r=l.useRef([]);return l.useMemo(()=>{const o=n.current,a=r.current,s=[];for(let u=0;u<e.length;u+=1){const d=e[u]??"";o[u]===d&&a[u]!==void 0?s.push(a[u]):s.push(he(d).body)}return n.current=e,r.current=s,s},[e,t,e.length])}const WE="_panel_6xdnw_1",GE="_header_6xdnw_17",ZE="_title_6xdnw_26",qE="_close_6xdnw_32",YE="_messages_6xdnw_48",XE="_empty_6xdnw_57",JE="_message_6xdnw_48",QE="_messageHeader_6xdnw_69",e_="_author_6xdnw_77",t_="_time_6xdnw_81",n_="_body_6xdnw_86",r_="_reply_6xdnw_92",o_="_input_6xdnw_100",i_="_post_6xdnw_111",vt={panel:WE,header:GE,title:ZE,close:qE,messages:YE,empty:XE,message:JE,messageHeader:QE,author:e_,time:t_,body:n_,reply:r_,input:o_,post:i_};function a_(e,t){const n=new Date(e);return Number.isNaN(n.getTime())?e:new Intl.DateTimeFormat(t,{dateStyle:"medium",timeStyle:"short"}).format(n)}function s_({thread:e,locale:t,disabled:n,commentAuthor:r,panelRef:o,onPost:a,onClose:s}){const u=q(),[d,f]=l.useState(""),g=l.useRef(null);l.useEffect(()=>{var y;(y=g.current)==null||y.focus()},[e==null?void 0:e.id]);const h=!n&&r&&d.trim().length>0,C=l.useMemo(()=>(e==null?void 0:e.messages)??[],[e==null?void 0:e.messages]),b=C.length===0?u("commentPlaceholder"):u("commentReplyPlaceholder");if(!e)return null;const x=()=>{const y=d.trim();!y||!h||(a(y),f(""))};return Bc.createPortal(i.jsxs("div",{ref:o,className:vt.panel,role:"dialog","aria-label":u("commentPanelTitle"),children:[i.jsxs("div",{className:vt.header,children:[i.jsx("h2",{className:vt.title,children:u("commentPanelTitle")}),i.jsx("button",{type:"button",className:vt.close,onClick:s,"aria-label":u("commentPanelCloseAria"),children:i.jsx(et,{})})]}),i.jsx("div",{className:vt.messages,children:C.length===0?i.jsx("p",{className:vt.empty,children:u("commentEmpty")}):C.map(y=>i.jsxs("article",{className:vt.message,children:[i.jsxs("header",{className:vt.messageHeader,children:[i.jsx("span",{className:vt.author,children:y.userName}),i.jsx("time",{className:vt.time,dateTime:y.createdAt,children:a_(y.createdAt,t)})]}),i.jsx("p",{className:vt.body,children:y.message})]},y.id))}),i.jsxs("div",{className:vt.reply,children:[i.jsx("textarea",{ref:g,className:vt.input,value:d,onChange:y=>f(y.target.value),placeholder:b,rows:3,disabled:n||!r}),i.jsx("button",{type:"button",className:vt.post,onClick:x,disabled:!h,children:u("commentPost")})]})]}),document.body)}const l_=l.forwardRef(function({html:t,onChange:n,placeholder:r,disabled:o},a){const s=q();return i.jsx("textarea",{ref:a,className:`${xe.surface} ${xe.html}`,value:t,onChange:u=>n(u.target.value),placeholder:r,disabled:o,"aria-label":s("htmlEditorAria"),spellCheck:!1})}),c_="_shell_yvznc_1",u_="_scrollButton_yvznc_10",d_="_tabList_yvznc_48",m_="_tab_yvznc_48",f_="_tabActive_yvznc_86",Kr={shell:c_,scrollButton:u_,tabList:d_,tab:m_,tabActive:f_},p_=5,Ff=120;function g_({pageCount:e,activeIndex:t,onSelect:n}){const r=q(),o=l.useRef(null),[a,s]=l.useState(!1),[u,d]=l.useState(!1),f=e>=p_,g=l.useCallback(()=>{const b=o.current;if(!b)return;const{scrollLeft:x,scrollWidth:y,clientWidth:v}=b;s(x>1),d(x+v<y-1)},[]);l.useEffect(()=>{g()},[e,t,g]),l.useEffect(()=>{var y;const b=o.current;if(!b)return;const x=b.querySelector(`[data-page-tab="${t}"]`);(y=x==null?void 0:x.scrollIntoView)==null||y.call(x,{block:"nearest",inline:"nearest"}),g()},[t,g]),l.useEffect(()=>{const b=o.current;if(!b)return;const x=()=>g();if(b.addEventListener("scroll",x,{passive:!0}),typeof ResizeObserver>"u")return()=>{b.removeEventListener("scroll",x)};const y=new ResizeObserver(()=>g());return y.observe(b),()=>{b.removeEventListener("scroll",x),y.disconnect()}},[g]);const h=b=>{var x;(x=o.current)==null||x.scrollBy({left:b,behavior:"smooth"})},C=b=>r("htmlModePageTab").replace("{n}",String(b+1));return i.jsxs("div",{className:Kr.shell,children:[f?i.jsx("button",{type:"button",className:Kr.scrollButton,"aria-label":r("htmlModePageTabsScrollLeftAria"),disabled:!a,onClick:()=>h(-Ff),children:"‹"}):null,i.jsx("div",{ref:o,className:Kr.tabList,role:"tablist","aria-label":r("htmlModePageTabsAria"),children:Array.from({length:e},(b,x)=>i.jsx("button",{type:"button",role:"tab","data-page-tab":x,className:`${Kr.tab} ${x===t?Kr.tabActive:""}`,"aria-selected":x===t,tabIndex:x===t?0:-1,onClick:()=>n(x),children:C(x)},x))}),f?i.jsx("button",{type:"button",className:Kr.scrollButton,"aria-label":r("htmlModePageTabsScrollRightAria"),disabled:!u,onClick:()=>h(Ff),children:"›"}):null]})}function h_(e,t,n=!0){const[r,o]=l.useState(null),[a,s]=l.useState(ju()),u=l.useCallback(()=>{!n||!e||(o(Vh(e,t)),s(Ja(e)))},[n,e,t]);return l.useLayoutEffect(()=>{if(!n)return;const d=requestAnimationFrame(u);return()=>cancelAnimationFrame(d)},[n,u]),l.useLayoutEffect(()=>{if(!n||!e||typeof ResizeObserver>"u")return;const d=new ResizeObserver(()=>u());return d.observe(e),()=>d.disconnect()},[n,e,u]),l.useLayoutEffect(()=>{if(!n||!e)return;const d=()=>{s(Ja(e))};return document.addEventListener("selectionchange",d),()=>document.removeEventListener("selectionchange",d)},[n,e]),{geometry:r,indentState:a,refresh:u}}const b_=l.forwardRef(function({html:t,pageHtml:n,onChange:r,placeholder:o,disabled:a,rulerVisible:s=!0,rulerUnit:u="in",zoomScale:d=1,onMarginChange:f,onMarginPreview:g,onIndentChange:h,onBeforeInput:C,propSyncGuardRef:b,resolveEmbeddedImageDataUrl:x,hydrateEmbeddedImages:y,onPointerDown:v,onMouseUp:k,onContextMenu:S},P){const R=q(),D=l.useRef(null),A=l.useRef(!1),[T,_]=l.useState(null),M=l.useRef(C);M.current=C;const z=n??t,E=s&&ei(z),{geometry:N,indentState:O,refresh:G}=h_(T,z,E),Y=Z=>{D.current=Z,_(Z),typeof P=="function"?P(Z):P&&(P.current=Z)};l.useLayoutEffect(()=>{const Z=D.current;if(!Z)return;const J=cn(t),ce=Z===document.activeElement&&A.current;if(A.current=!1,ce||Za(Z,J,{resolveDataUrl:x,hydrateEmbeddedImages:y}),gt(Z)||ei(z)){cu(Z),Xo(Z),ds(Z);const X=gt(Z);X&&Kp(Z,X)}us(Z),co(Z,z)},[t,z,x,y]),l.useLayoutEffect(()=>{if(b)return b.current=()=>{A.current=!0},()=>{b.current=null}},[b]),l.useLayoutEffect(()=>{const Z=D.current;if(!Z)return;const J=ne=>{var ce;(ce=M.current)==null||ce.call(M,ne)};return Z.addEventListener("beforeinput",J),()=>Z.removeEventListener("beforeinput",J)},[]);const re=i.jsx("div",{ref:Y,className:`${xe.surface} ${xe.visual} ${E?xe.pageSurface:""}`,contentEditable:!a,suppressContentEditableWarning:!0,role:"textbox","aria-multiline":"true","aria-label":R("visualEditorAria"),"aria-disabled":a||void 0,"data-placeholder":o,onPointerDown:v,onMouseUp:k,onContextMenu:S,onInput:Z=>{const J=Z.currentTarget;if(A.current=!0,gt(J)){const{absorbedBlocks:ne}=Xo(J);if(r(J.innerHTML),ne.length>0){const ce=ne.length;requestAnimationFrame(()=>Wp(J,ce))}}else r(J.innerHTML);E&&G()}});return i.jsx(rj,{showRulers:E,geometry:N,indentState:O,rulerUnit:u,zoomScale:d,onMarginChange:f,onMarginPreview:g,onIndentChange:h,children:re})}),y_="_frame_bwkh8_1",x_="_handle_bwkh8_9",C_="_handleEast_bwkh8_29",w_="_handleSouth_bwkh8_37",v_="_handleSouthEast_bwkh8_45",Vo={frame:y_,handle:x_,handleEast:C_,handleSouth:w_,handleSouthEast:v_};function Bo(e){const t=e.getBoundingClientRect();return{left:t.left,top:t.top,width:t.width,height:t.height}}const k_=[{handle:"e",className:Vo.handleEast,cursor:"e-resize",ariaKey:"imageResizeHandleEastAria"},{handle:"s",className:Vo.handleSouth,cursor:"s-resize",ariaKey:"imageResizeHandleSouthAria"},{handle:"se",className:Vo.handleSouthEast,cursor:"se-resize",ariaKey:"imageResizeHandleSouthEastAria"}];function Ql(e){return!Number.isFinite(e.clientX)||!Number.isFinite(e.clientY)?null:{x:e.clientX,y:e.clientY}}function S_({img:e,onResize:t,onResizeEnd:n}){const r=q(),o=l.useRef(null),a=l.useRef(e),s=l.useRef(t),u=l.useRef(n),d=l.useRef(null);a.current=e,s.current=t,u.current=n;const f=k=>{const S=o.current;S&&(S.style.left=`${k.left}px`,S.style.top=`${k.top}px`,S.style.width=`${k.width}px`,S.style.height=`${k.height}px`)};l.useLayoutEffect(()=>{f(Bo(e));const k=()=>{e.isConnected&&f(Bo(e))};return window.addEventListener("scroll",k,!0),window.addEventListener("resize",k),()=>{window.removeEventListener("scroll",k,!0),window.removeEventListener("resize",k)}},[e]);const g=(k,S)=>{const P=d.current,R=a.current;if(!P||!R)return;const D=b0(P.handle,P.start,{x:k-P.originX,y:S-P.originY});s.current(D.width,D.height),R.isConnected&&f(Bo(R))},h=()=>{if(!d.current)return;d.current=null;const k=a.current;u.current(),k!=null&&k.isConnected&&f(Bo(k))};l.useLayoutEffect(()=>{const k=P=>{if(!d.current)return;const R=Ql(P);R&&g(R.x,R.y)},S=()=>{h()};return document.addEventListener("pointermove",k),document.addEventListener("pointerup",S),document.addEventListener("pointercancel",S),document.addEventListener("mousemove",k),document.addEventListener("mouseup",S),()=>{document.removeEventListener("pointermove",k),document.removeEventListener("pointerup",S),document.removeEventListener("pointercancel",S),document.removeEventListener("mousemove",k),document.removeEventListener("mouseup",S)}},[]);const C=(k,S)=>{const P=Ql(S);P&&(d.current={handle:k,start:y0(a.current),originX:P.x,originY:P.y})},b=k=>S=>{S.preventDefault(),S.stopPropagation(),C(k,S);try{S.currentTarget.setPointerCapture(S.pointerId)}catch{}},x=k=>S=>{S.preventDefault(),S.stopPropagation(),C(k,S)},y=k=>{const S=Ql(k);S&&g(S.x,S.y)};if(!e.isConnected)return null;const v=Bo(e);return Bc.createPortal(i.jsx("div",{ref:o,className:Vo.frame,"data-image-resize-overlay":"",style:{left:v.left,top:v.top,width:v.width,height:v.height},children:k_.map(k=>i.jsx("button",{type:"button",className:`${Vo.handle} ${k.className}`,style:{cursor:k.cursor},"aria-label":r(k.ariaKey),"data-resize-handle":k.handle,onPointerDown:b(k.handle),onPointerMove:y,onPointerUp:h,onPointerCancel:h,onMouseDown:x(k.handle),onMouseMove:y,onMouseUp:h},k.handle))}),document.body)}function A_(e,t){for(const n of Object.keys(e)){const r=e[n],o=t[n];if(!(typeof r=="function"&&typeof o=="function")&&r!==o)return!1}return!0}function P_(){const e=q();return i.jsx("div",{className:xe.htmlFileDropOverlay,"aria-hidden":"true",children:e("htmlFileDropOverlay")})}function T_({propsRef:e,pageStore:t,mode:n,enableMultiPages:r,contentLocked:o,activePageIndex:a,hasSelectedPage:s,pageZoomScale:u,rulerVisible:d,rulerUnit:f,optimizeEmbeddedImages:g,placeholder:h,controlledHtml:C,initialHtml:b,initialStorageHtml:x,defaultPages:y,ingestedPagesProp:v,onChange:k,fontFaces:S,enableComments:P,commentsVisible:R,disabled:D,locale:A,commentAuthor:T,activeThreadId:_,contextMenu:M,commentThreads:z,commands:E,htmlFileDropDragging:N,selectedImage:O}){const{htmlRef:G,pagesRef:Y,documentBridgeRef:re}=UE(),[Z,J]=l.useState(x),[ne,ce]=Pa({value:g?void 0:C,defaultValue:b,onChange:r||g?void 0:k}),X=g?Z:ne,[I,se]=l.useState(()=>r?y[0]??"":""),fe=l.useRef(I);fe.current=I;const L=e.current;g?r||(G.current=Z):G.current=ne,r&&(Y.current=t.pages);const Le=l.useCallback(()=>r?t.getJoinedHtml():g?Z:ne,[r,ne,g,t,Z]);l.useLayoutEffect(()=>{const oe={pageStore:t,setHtml:ce,setStorageHtml:J,getEditorHtml:Le,replacePagesFromHistory:ve=>t.replacePages([...ve])};return re.current=oe,()=>{re.current===oe&&(re.current=null)}},[re,Le,t,ce,J]);const Ee=l.useMemo(()=>{if(r){const oe=t.pages[a]??t.pages[0]??"";return wm(oe,S).join(`
319
- `)}return wm(X,S).join(`
320
- `)},[r,t.pages,t.revision,a,X,S]),ze=VE(r?t.pages:[],r?t.revision:0);l.useLayoutEffect(()=>{var ve;if(!r)return;const oe=(ve=e.current.multiPageVisualRef.current)==null?void 0:ve.getActivePageRoot();oe instanceof HTMLDivElement&&(e.current.visualRootRef.current=oe)},[r,a,ze.length,e]);const bt=l.useMemo(()=>r?ze[s?a:0]??"":he(X).body,[r,ze,a,s,X]),Ye=l.useMemo(()=>Hp(st(bt)),[bt]);L.activePageHtmlRef.current=bt,L.pageCanvasSizedRef.current=Ye,l.useEffect(()=>{const ve=(Ee?Ee.split(`
321
- `):[]).map(je=>{const Ne=document.createElement("link");return Ne.rel="stylesheet",Ne.href=je,Ne.setAttribute(rs,""),document.head.append(Ne),Ne});return()=>{for(const je of ve)je.remove()}},[Ee]),l.useEffect(()=>{(!P||n!=="visual"||!R)&&e.current.setActiveThreadId(null)},[P,n,R,e]),l.useEffect(()=>{if(!_)return;const oe=ve=>{var Ut;const je=e.current,Ne=ve.target;if((Ut=je.commentPanelRef.current)!=null&&Ut.contains(Ne))return;const We=je.visualRootRef.current;We&&sh(We,Ne)||je.setActiveThreadId(null)};return document.addEventListener("pointerdown",oe),()=>document.removeEventListener("pointerdown",oe)},[_,e]),l.useEffect(()=>{if(!r||n!=="html")return;const oe=t.pages[a]??"";oe!==fe.current&&(fe.current=oe,se(oe))},[r,n,t.pages,t.revision,a]),l.useEffect(()=>{if(!P||n!=="visual")return;const oe=e.current.visualRootRef.current;oe&&(sS(oe,z),ah(oe,R))},[P,n,z,R,X,e]),L.htmlModePageHtmlRef.current=fe.current;const Oe=n==="visual"&&d&&Ye,pe=l.useMemo(()=>_?dS(z,_):null,[_,z]),De=n==="visual"?r?i.jsx(aj,{ref:L.multiPageVisualRef,pages:ze,activePageIndex:a,hasSelectedPage:s,scrollRootRef:L.workspaceRef,suppressPageFlushRef:L.suppressPageFlushRef,onActivePageIndexChange:oe=>{var Ne;L.activePageIndexRef.current=oe,L.setActivePageIndex(oe);const ve=(Ne=L.multiPageVisualRef.current)==null?void 0:Ne.getContainer(),je=ve?nt(ve,oe):null;je instanceof HTMLDivElement&&(L.visualRootRef.current=je)},onPageSelected:()=>{L.setHasSelectedPage(!0)},onPageChange:(oe,ve)=>{const je=Y.current[oe]??"";L.recordPageVisualHtml(oe,sn(ve,he(je).body),!0)},onPageFlush:(oe,ve)=>{const je=Y.current[oe]??"";L.recordPageVisualHtml(oe,sn(ve,he(je).body),!1)},onBeforeInput:L.handleVisualBeforeInput,onPointerDown:oe=>{if(oe.currentTarget instanceof HTMLDivElement&&(L.visualRootRef.current=oe.currentTarget),L.handleVisualPointerDown(oe),oe.currentTarget instanceof HTMLDivElement){const ve=oe.currentTarget;requestAnimationFrame(()=>to(ve))}},onMouseUp:L.handleVisualMouseUp,onContextMenu:L.handleVisualContextMenu,placeholder:h,disabled:o,rulerVisible:d,rulerUnit:f,zoomScale:u,onMarginPreview:L.multiPageRulerMarginPreview,onMarginChange:L.multiPageRulerMarginChange,onIndentChange:L.multiPageRulerIndentChange,resolveEmbeddedImageDataUrl:g?L.resolveEmbeddedImageDataUrl:void 0,hydrateEmbeddedImages:g?L.hydrateExportHtml:void 0}):i.jsx(b_,{ref:L.visualRootRef,html:he(X).body,pageHtml:X,rulerVisible:d,rulerUnit:f,zoomScale:u,propSyncGuardRef:L.visualPropSyncGuardRef,resolveEmbeddedImageDataUrl:g?L.resolveEmbeddedImageDataUrl:void 0,hydrateEmbeddedImages:g?L.hydrateExportHtml:void 0,onMarginPreview:L.singlePageRulerMarginPreview,onMarginChange:L.singlePageRulerMarginChange,onIndentChange:L.singlePageRulerIndentChange,onChange:oe=>L.recordVisualInputHtml(oe,!0),onBeforeInput:L.handleVisualBeforeInput,onPointerDown:oe=>{if(L.handleVisualPointerDown(oe),oe.currentTarget instanceof HTMLDivElement){const ve=oe.currentTarget;requestAnimationFrame(()=>to(ve))}},onMouseUp:L.handleVisualMouseUp,onContextMenu:L.handleVisualContextMenu,placeholder:h,disabled:o}):i.jsxs("div",{className:xe.htmlModeShell,children:[r&&t.pages.length>1?i.jsx(g_,{pageCount:t.pages.length,activeIndex:a,onSelect:L.handleHtmlPageTabSelect}):null,i.jsx(l_,{ref:L.htmlAreaRef,html:r?I:X,onChange:L.handleHtmlSurfaceChange,placeholder:h,disabled:o})]});return i.jsxs(i.Fragment,{children:[i.jsxs("div",{ref:L.workspaceRef,className:`${xe.workspace} ${Ye?xe.workspacePageSized:""} ${Oe?xe.workspaceWithRuler:""}`,onDragEnter:L.htmlFileDrop.onDragEnter,onDragOver:L.htmlFileDrop.onDragOver,onDragLeave:L.htmlFileDrop.onDragLeave,onDrop:L.htmlFileDrop.onDrop,children:[n==="visual"?i.jsx("div",{className:xe.pageCanvasViewport,"data-page-canvas-sized":Ye?"":void 0,children:De}):De,L.htmlFileDrop.dragging?i.jsx(P_,{}):null]}),n==="visual"&&!o&&(O!=null&&O.isConnected)?i.jsx(S_,{img:O,onResize:L.handleImageResize,onResizeEnd:L.handleImageResizeEnd}):null,P&&R&&pe?i.jsx(s_,{panelRef:L.commentPanelRef,thread:pe,locale:A,disabled:D,commentAuthor:T,onPost:L.postCommentMessage,onClose:()=>L.setActiveThreadId(null)}):null,i.jsx(Jy,{open:M.open,x:M.x,y:M.y,kind:M.kind,inTable:M.inTable,canMergeCells:M.canMergeCells,canUnmergeCells:M.canUnmergeCells,canDeletePage:M.canDeletePage,canAddComment:M.canAddComment,commands:E,onClose:()=>L.setContextMenu(oe=>({...oe,open:!1}))})]})}const R_=l.memo(T_,A_),D_=.005;function j_({value:e,defaultValue:t="",onChange:n,onAutoSave:r,onSave:o,onOpen:a,mode:s,defaultMode:u="visual",onModeChange:d,fullscreen:f,defaultFullscreen:g=!1,onFullscreenChange:h,placeholder:C,disabled:b,readOnly:x=!1,className:y,locale:v="en",toolbarBackground:k,menuColor:S,menuBackground:P,menuFontSize:R,menuFontFamily:D,border:A,menuVisible:T=!0,toolbarVisible:_=!0,allowedChrome:M,customActions:z,customFonts:E,transformHtml:N,sanitizeHtml:O=!0,loadCustomParagraphStyles:G,onSaveCustomParagraphStyle:Y,onDeleteCustomParagraphStyle:re,customImagePicker:Z,disableBuiltinImageInsert:J,customAudioPicker:ne,disableBuiltinAudioInsert:ce,customVideoPicker:X,disableBuiltinVideoInsert:I,disableHtmlFileDrop:se=!1,toolbarCustomization:fe,darkMode:L=!1,darkModePersistence:Le,toolbarPosition:Ee="top",toolbarPositionPersistence:ze,enablePageProperties:bt=!1,defaultPageProperties:Ye,optimizeEmbeddedImages:Oe=!1,enableMultiPages:pe=!1,pages:De,defaultPages:oe,onPagesChange:ve,defaultRulerVisible:je=!0,rulerUnit:Ne="in",enableComments:We=!1,defaultCommentsVisible:Ut=!0,commentAuthor:Ue,comments:Cr,defaultComments:wr=[],onCommentsChange:vr}){var mm;const Be=!!(b||x),Qt=!!b,it=pe?De!==void 0:e!==void 0,Xn=Bn(oe??(t.trim()?[t]:[Mn()])),kr=!it&&Ye?Xn.map(c=>nf(c,Ye)):Xn,V=l.useRef(null);Oe&&V.current===null&&(V.current=QC());const ee=l.useRef(null);ee.current===null&&(ee.current=Oe&&V.current?kr.map(c=>V.current.externalizeHtml(c)):[...kr]);const me=pe?Mt(ee.current):ee.current[0]??"",Ke=O?$r(me):me,Vt=pe&&De!==void 0?Mt(Bn(De)):e,Jn=l.useMemo(()=>{if(Vt!==void 0)return O?$r(Vt):Vt},[Vt,O]),ct=l.useRef(n);ct.current=n;const $e=l.useRef(Oe);$e.current=Oe;const Se=l.useCallback(c=>!$e.current||!V.current?c:V.current.externalizeHtml(c),[]),Ge=l.useCallback(c=>!$e.current||!V.current?c:V.current.hydrateHtml(c),[]),en=l.useCallback(c=>c.map(m=>Ge(m)),[Ge]),ys=l.useCallback(c=>{var m;return((m=V.current)==null?void 0:m.getDataUrl(c))??null},[]),ai=l.useCallback(c=>{var m;(m=ct.current)==null||m.call(ct,Ge(c))},[Ge]),[xs]=l.useState(()=>{if(Oe&&e!==void 0&&!pe){const c=O?$r(e):e;return V.current?V.current.externalizeHtml(c):c}return Ke}),[at,si]=Pa({value:s,defaultValue:u,onChange:d}),[Rt,Qn]=Pa({value:f,defaultValue:g,onChange:h}),[Wt,Cs]=l.useState(Ut),[mo,ws]=l.useState(je),li=l.useRef(mo);li.current=mo;const[Pn,gn]=l.useState(null),[Sr,er]=Pa({value:Cr,defaultValue:wr,onChange:vr}),H=l.useRef(null),Dt=l.useRef(null),ci=l.useRef(null),Ar=l.useRef(null),yt=l.useRef(null),tr=l.useRef(!1),ut=l.useRef(null),be=l.useRef(pe);be.current=pe;const vs=l.useRef(Ye);vs.current=Ye;const Tn=l.useRef(We);Tn.current=We;const Mu=l.useRef(x);Mu.current=x;const Nu=l.useRef(Be);Nu.current=Be;const ui=l.useRef(Wt);ui.current=Wt;const di=l.useRef(Sr);di.current=Sr;const mi=l.useRef(ve);mi.current=ve;const fi=l.useRef(null),pi=l.useRef(!1),gi=l.useCallback(()=>{var m;pi.current=!1;const c=fi.current;fi.current=null,c&&((m=mi.current)==null||m.call(mi,c.pages,c.activePageIndex))},[]),Pr=l.useCallback((c,m)=>{fi.current={pages:[...c],activePageIndex:m},!pi.current&&(pi.current=!0,queueMicrotask(gi))},[gi]),ks=l.useRef(De);ks.current=De;const Lu=l.useMemo(()=>!Oe||De===void 0?De:Bn(De).map(c=>{var w;const m=O?$r(c):c;return((w=V.current)==null?void 0:w.externalizeHtml(m))??m}),[Oe,De,O]),dt=Q0({enabled:pe,pagesProp:Lu,defaultPages:ee.current??[Mn()]}),Tr=l.useRef(null),Bu=l.useRef(null),[Rr,fo]=l.useState(0),ye=l.useRef(Rr);ye.current=Rr;const hn=l.useRef(pe?((mm=ee.current)==null?void 0:mm[0])??"":""),[po,go]=l.useState(!1),tn=l.useRef(po);tn.current=po;const[Fu,nb]=l.useState(0),Hu=l.useRef(!1),zu=l.useRef(!1),jt=l.useMemo(()=>HR(),[]),Ss=l.useRef(null);Ss.current===null&&(Ss.current=pe?dA(ee.current??[Mn()]):uA(Se(Ke)));const te=Ss.current,nn=l.useCallback(()=>{const c=te.canUndo(),m=te.canRedo();c===Hu.current&&m===zu.current||(Hu.current=c,zu.current=m,nb(w=>w+1))},[te]),ie=l.useRef(Ke),Pe=l.useRef(ee.current??[Mn()]);pe&&(Pe.current=dt.pages);const Ou=l.useRef(""),Ku=l.useRef(!1),Gt=l.useRef(!0),Dr=l.useRef(""),jr=l.useRef(null),F=l.useRef(at);F.current=at;const $u=l.useRef(Rt);$u.current=Rt;const Xe=l.useRef(null),[,rb]=l.useState(0),ho=l.useRef(null);ho.current===null&&(ho.current=SS(()=>{rb(c=>c+1)}));const hi=l.useRef(N);hi.current=N;const Uu=l.useRef(O);Uu.current=O;const Bt=l.useRef({}),It=l.useRef(null),Ft=l.useRef(null),Zt=l.useRef(null),qt=l.useRef(null),Rn=l.useRef(null),Et=l.useRef(null),[bo,As]=l.useState(zn),Ps=l.useRef(bo);Ps.current=bo;const bn=l.useRef(Xr),[yo,bi]=l.useState({value:null,unit:Xr,mixed:!1}),Dn=l.useRef(yo);Dn.current=yo;const[xo,Ts]=l.useState({value:null,mixed:!1}),Co=l.useRef(xo);Co.current=xo;const[wo,Rs]=l.useState({value:null,mixed:!1}),vo=l.useRef(wo);vo.current=wo;const[ko,Ds]=l.useState({value:null,mixed:!1}),So=l.useRef(ko);So.current=ko;const[yi,js]=l.useState({tag:null,mixed:!1}),Is=l.useRef(yi);Is.current=yi;const[Vu,Es]=l.useState({align:"left",mixed:!1}),_s=l.useRef(Vu);_s.current=Vu;const[Wu,Ms]=l.useState({type:null,mixed:!1}),Ao=l.useRef(Wu);Ao.current=Wu;const[Gu,Ns]=l.useState(!1),Zu=l.useRef(Gu);Zu.current=Gu;const[xi,Ls]=l.useState(!1),Bs=l.useRef(xi);Bs.current=xi;const[Ci,qu]=l.useState(!1),wi=l.useRef(Ci);wi.current=Ci;const vi=l.useRef(null),ki=l.useRef(null),[Yu,Xu]=l.useState(!1),Ju=l.useRef(Yu);Ju.current=Yu;const{fontDialog:Si,setFontDialog:Ai,customizeToolbarOpen:Fs,setCustomizeToolbarOpen:Qu,documentPreview:Pi,setDocumentPreview:ed,toolbarSettings:Hs,setToolbarSettings:Ti,toolbarSettingsLoading:ob,setToolbarSettingsLoading:zs,toolbarSettingsBusy:ib,setToolbarSettingsBusy:Os,paragraphDialog:Po,setParagraphDialog:Ir,customCssDialog:Ks,setCustomCssDialog:$s,pageDialog:To,setPageDialog:nr,deletePageConfirmOpen:Us,setDeletePageConfirmOpen:Vs,customStyleDialog:ab,setCustomStyleDialog:Ro,linkDialog:Ws,setLinkDialog:Ri,bookmarkDialog:td,setBookmarkDialog:Gs,imageDialog:sb,setImageDialog:Di,audioDialog:lb,setAudioDialog:ji,youtubeDialog:cb,setYoutubeDialog:Do,imageProperties:ub,setImageProperties:Ii,tableDialog:Zs,setTableDialog:qs,tableProperties:Ys,setTableProperties:Xs,cellProperties:Js,setCellProperties:Qs,rowProperties:el,setRowProperties:tl,helpDialog:nl,setHelpDialog:jo,aboutDialogOpen:rl,setAboutDialogOpen:nd}=J0(),[rr,Ei]=l.useState(()=>Le?L:xf()??L),[Er,_i]=l.useState(()=>ze?Ee:Cf()??Ee),[Io,db]=l.useState(()=>oA()??"fitWidth"),[ol,mb]=l.useState(1),[Mi,rd]=l.useState([]),[Ni,il]=l.useState(!1),[fb,Li]=l.useState(!1),[pb,al]=l.useState({open:!1,x:0,y:0,kind:"caret",inTable:!1,canMergeCells:!1,canUnmergeCells:!1,canDeletePage:!1,canAddComment:!1}),[mt,_r]=l.useState(null),sl=l.useRef(mt);sl.current=mt;const[Bi,od]=l.useState(!1),id=l.useRef(Bi);id.current=Bi;const[Fi,ad]=l.useState(!1),sd=l.useRef(Fi);sd.current=Fi;const[Hi,ld]=l.useState(!1),cd=l.useRef(Hi);cd.current=Hi;const ud=l.useRef(void 0),zi=l.useRef(Mi);zi.current=Mi;const dd=l.useRef(Ni);dd.current=Ni;const Oi=!!(G&&Y),ll=l.useRef(Oi);ll.current=Oi;const md=l.useRef(G);md.current=G;const fd=l.useRef(Y);fd.current=Y;const pd=l.useRef(re);pd.current=re;const gd=l.useRef(o);gd.current=o;const hd=l.useRef(a);hd.current=a;const bd=l.useRef(Z);bd.current=Z;const yd=l.useRef(ne);yd.current=ne;const xd=l.useRef(X);xd.current=X;const Cd=l.useRef(fe);Cd.current=fe;const wd=l.useRef(Le);wd.current=Le;const vd=l.useRef(ze);vd.current=ze;const kd=l.useRef(rr);kd.current=rr;const Sd=l.useRef(Er);Sd.current=Er;const Ki=l.useRef(Io);Ki.current=Io;const $i=l.useRef(ol);$i.current=ol;const Ad=l.useRef(J);Ad.current=J;const Pd=l.useRef(ce);Pd.current=ce;const Td=l.useRef(I);Td.current=I;const cl=l.useRef(0),Eo=l.useRef(0),Rd=l.useRef(0),Ui=l.useRef(0),Dd=l.useRef(0),Vi=l.useRef(0),jd=l.useRef(0),Mr=l.useMemo(()=>ep(E),[E]),Nr=l.useRef(Mr);Nr.current=Mr;const Wi=l.useCallback(()=>{var c;if(be.current){const m=(c=yt.current)==null?void 0:c.getActivePageRoot();if(m instanceof HTMLElement)return m}return H.current},[]),_o=l.useCallback(()=>{if(be.current){const c=yt.current;if(!c)return null;c.ensurePageMounted(ye.current);const m=c.getContainer(),w=m?nt(m,ye.current):null;return w instanceof HTMLDivElement?(H.current=w,w):null}return H.current},[]);l.useLayoutEffect(()=>{var m;if(!pe)return;const c=(m=yt.current)==null?void 0:m.getActivePageRoot();c instanceof HTMLDivElement&&(H.current=c)},[pe,Rr]);const Gi=l.useRef(()=>{}),ul=l.useRef(!1),gb=l.useCallback(()=>{if(ul.current||F.current!=="visual")return;const c=Ar.current;if(c){ul.current=!0;try{const m=getComputedStyle(c),w=parseFloat(m.paddingLeft)+parseFloat(m.paddingRight),j=parseFloat(m.paddingTop)+parseFloat(m.paddingBottom),B=Math.max(0,c.clientWidth-w),U=Math.max(0,c.clientHeight-j);let Q=0,ue=0;if(Ku.current){const Re=IC(st(Ou.current));Re&&(Q=Re.width,ue=Re.height)}else{const Re=Wi(),ft=$i.current>0?$i.current:1;Q=((Re==null?void 0:Re.offsetWidth)??0)/ft,ue=((Re==null?void 0:Re.offsetHeight)??0)/ft}Q<=0&&(Q=B),ue<=0&&(ue=U);const _e=z1(Ki.current,B,U,Q,ue);Math.abs(_e-$i.current)>=D_&&mb(_e)}finally{ul.current=!1}}},[Wi]);Gi.current=gb,l.useLayoutEffect(()=>{if(at!=="visual")return;const c=Wi();!c||c!==document.activeElement||to(c)},[at,Rr,Wi]);const Zi=l.useCallback(async()=>{const c=md.current;if(!c)return;const m=++cl.current;il(!0);try{const w=await c();if(m!==cl.current)return;rd(w)}catch{}finally{m===cl.current&&il(!1)}},[]);l.useEffect(()=>{if(!G||!Y){rd([]),il(!1);return}Zi()},[G,Y,Zi]);const Id=l.useCallback(async c=>{Ti(c);const m=Cd.current;if(m!=null&&m.load&&m.save){const w=++Rd.current;Os(!0);try{await m.save(c)}catch{}finally{w===Rd.current&&Os(!1)}return}bA(c)},[]);l.useEffect(()=>{const c=fe;if(!(c!=null&&c.load)||!c.save){Ti(hA()),zs(!1),Os(!1);return}const m=++Eo.current;return zs(!0),(async()=>{try{const w=await c.load();if(m!==Eo.current)return;Ti(w)}catch{if(m!==Eo.current)return;Ti(null)}finally{m===Eo.current&&zs(!1)}})(),()=>{Eo.current+=1}},[fe]);const Ed=l.useCallback(async c=>{Ei(c);const m=wd.current;if(m!=null&&m.load&&m.save){const w=++Dd.current;try{await m.save(c)}catch{}finally{if(w!==Dd.current)return}return}tA(c)},[]),_d=l.useCallback(c=>{Ki.current=c,db(c),iA(c);const m=Ar.current;m&&(m.scrollTop=0,m.scrollLeft=0),Gi.current()},[]);l.useEffect(()=>{const c=Le;if(!(c!=null&&c.load)||!c.save){Ei(xf()??L);return}const m=++Ui.current;return(async()=>{try{const w=await c.load();if(m!==Ui.current)return;Ei(typeof w=="boolean"?w:L)}catch{if(m!==Ui.current)return;Ei(L)}})(),()=>{Ui.current+=1}},[Le,L]),l.useLayoutEffect(()=>{if(Gi.current(),at!=="visual")return;const c=Ar.current;if(!c||typeof ResizeObserver>"u")return;const m=O1(()=>{Gi.current()}),w=new ResizeObserver(()=>{m.schedule()});return w.observe(c),()=>{w.disconnect(),m.cancel()}},[at,Rr,Io,pe]);const Md=l.useCallback(async c=>{_i(c);const m=vd.current;if(m!=null&&m.load&&m.save){const w=++jd.current;try{await m.save(c)}catch{}finally{if(w!==jd.current)return}return}sA(c)},[]);l.useEffect(()=>{const c=ze;if(!(c!=null&&c.load)||!c.save){_i(Cf()??Ee);return}const m=++Vi.current;return(async()=>{try{const w=await c.load();if(m!==Vi.current)return;_i(Th(w)??Ee)}catch{if(m!==Vi.current)return;_i(Ee)}})(),()=>{Vi.current+=1}},[ze,Ee]);const Lr=l.useCallback((c,m)=>{var ue,_e;const w=Uu.current?$r(c):c,j=((ue=hi.current)==null?void 0:ue.call(hi,w))??w,B=dh(ie.current,j,Ge);m!=null&&m.fullReplace&&!B&&$e.current&&((_e=V.current)==null||_e.clear());const U=Se(j);if(B)return ie.current=U,{stored:U,stateUpdated:!1};U!==ie.current&&(Gt.current=!0);const Q=Tr.current;if(be.current){const Re=dt;if(!Re)return ie.current=U,{stored:U,stateUpdated:!1};const ft=Re.replacePages(Fn(U));return ie.current=ft.joined,Pe.current=ft.pages,F.current==="html"&&!$e.current&&(Q==null||Q.setHtml(U)),Pr(en(ft.pages),ye.current),{stored:U,stateUpdated:!0}}return $e.current?(ie.current=U,Q==null||Q.setStorageHtml(U),ai(U),{stored:U,stateUpdated:!0}):(ie.current=U,Q==null||Q.setHtml(U),{stored:U,stateUpdated:!0})},[Se,Ge,en,ai,Pr]),rn=l.useCallback((c,m,w,j)=>{var ue;const B=c.map(_e=>Se(_e)),U=dt;if(!U)return Mt(B);const Q=U.setPages(B,{editedIndex:w});if(!Q.changed)return Q.joined;if(Pe.current=Q.pages,Gt.current=!0,ie.current=Q.joined,ks.current===void 0&&F.current==="html"&&!$e.current&&((ue=Tr.current)==null||ue.setHtml(Q.joined)),Pr(en(Q.pages),ye.current),!(j!=null&&j.skipHistory)&&Ht(te)){const{changedIndices:_e,pages:Re}=Q;if(_e.length===1){const ft=w??_e[0];te.recordPageEdit(ft,Re[ft]??"",{coalesce:m})}else _e.length>1?te.recordReplaceAll(Re):w!==void 0?te.recordPageEdit(w,Re[w]??"",{coalesce:m}):te.recordReplaceAll(Re)}return nn(),Q.joined},[nn,Se,en,te,dt,Pr]),jn=l.useCallback(c=>{var U,Q;if(F.current!=="visual")return;const m=$e.current?ue=>{var _e;return((_e=V.current)==null?void 0:_e.getDataUrl(ue))??null}:void 0,w=$e.current?Ge:void 0;if((U=Dt.current)==null||U.call(Dt),be.current){const ue=(Q=yt.current)==null?void 0:Q.getContainer();if(!ue)return;const _e=Fn(c);for(let Re=0;Re<_e.length;Re+=1){const ft=nt(ue,Re);if(!ft)continue;const pt=cn(he(_e[Re]??"").body);Za(ft,pt,{resolveDataUrl:m,hydrateEmbeddedImages:w})}return}const j=H.current;if(!j)return;const B=cn(he(c).body);Za(j,B,{resolveDataUrl:m,hydrateEmbeddedImages:w})},[Ge]),xt=l.useCallback((c,m)=>{const{stored:w,stateUpdated:j}=Lr(c,{fullReplace:!m});return!m&&j&&jn(w),Ht(te)?te.recordReplaceAll(Fn(w)):te.record(w,{coalesce:m}),nn(),w},[nn,Lr,te,jn]),hb=l.useCallback(c=>{if(be.current){const m=ye.current,j=Pe.current.slice();j[m]=c,rn(j,!1,m);return}xt(c,!1)},[rn,xt]),Nd=lA({enabled:!Be&&!se,onHtml:hb}),ge=l.useCallback((c,m)=>{var w;return(w=Dt.current)==null||w.call(Dt),xt(da(c,ma(c,ie.current,Nr.current,{liveRoot:H.current??void 0})),m)},[xt]),bb=l.useCallback((c,m)=>ge(sn(c,ie.current),m),[ge]),qi=l.useCallback((c,m,w)=>{BC(c,m,w)},[]),Yi=l.useCallback((c,m,w)=>{const j={...Sa(c),atRule:st(Op(m,w))};return Pc(c,j)},[]),or=l.useCallback((c,m,w)=>da(c,ma(c,m,Nr.current,{liveRoot:w})),[]),Ct=l.useCallback(c=>{const m=yt.current,w=m==null?void 0:m.getContainer(),j=dt.pages.length>0?dt.pages:Pe.current;if(!w)return[...j];const B=dt;if(!B)return[...j];const U=B.dirtyPagesRef.current,Q=(c==null?void 0:c.allPages)===!0,ue=ye.current;let _e=!1;const Re=j.map((pt,zr)=>{if(!(Q||U.has(zr)||zr===ue))return pt;const la=nt(w,zr);let ca=null;if(la?(ds(la),ca=la.innerHTML):ca=m.flushPageHtml(zr),ca===null){const gm=cn(he(pt).body),hm=Vm(gm);if(hm===gm)return pt;const bm=or(sn(hm,he(pt).body),pt);return bm!==pt&&(_e=!0),bm}const Ob=sn(ca,he(pt).body),pm=or(Ob,pt,la??void 0);return pm!==pt&&(_e=!0),pm});if(_e){const pt=$e.current?Re.map(fm=>Se(fm)):Re,zr=B.setPages(pt);ie.current=zr.joined}B.markPagesClean();const ft=_e?B.pages:j;return $e.current?ft.map(pt=>Se(pt)):[...ft]},[Se,dt,or]),ir=l.useCallback((c,m,w)=>{const j=or(m,Pe.current[c]??""),B=cc(Pe.current,c,j);B.changed&&rn(B.pages,w,c)},[rn,or]),ar=l.useCallback((c,m,w)=>{const j=Pe.current[c]??"",B=he(m).body,U=Vm(B),Q=U===B?m:or(sn(U,he(j).body),j),ue=cc(Pe.current,c,Q);ue.changed&&rn(ue.pages,w,c)},[rn,or]),Ld=l.useCallback((c,m)=>{const w=he(c).body;be.current?ir(ye.current,w,m):ge(w,m)},[ir,ge]),le=l.useCallback((c,m,w)=>{var Q;const j=w?he(w).body:c.innerHTML,B=ue=>w?j:sn(j,he(ue).body);if(!be.current){ge(B(ie.current),m);return}const U=(Q=yt.current)==null?void 0:Q.getContainer();if(!U){ge(B(ie.current),m);return}for(let ue=0;ue<Pe.current.length;ue+=1)if(nt(U,ue)===c){ir(ue,B(Pe.current[ue]??""),m);return}ge(B(ie.current),m)},[ir,ge]),Bd=l.useCallback((c,m)=>{Mu.current||le(c,m)},[le]),yb=l.useMemo(()=>sj(()=>H.current,()=>ie.current,qi),[qi]),xb=l.useMemo(()=>lj(()=>H.current,()=>ie.current,Yi,c=>ge(he(c).body,!1)),[Yi,ge]),Cb=l.useMemo(()=>If(()=>H.current,Ne??"in",c=>le(c,!1)),[Ne,le]),wb=l.useMemo(()=>cj(c=>{var w;const m=(w=yt.current)==null?void 0:w.getContainer();return m?nt(m,c):null},c=>Pe.current[c]??"",qi),[qi]),vb=l.useMemo(()=>uj(c=>{var w;const m=(w=yt.current)==null?void 0:w.getContainer();return m?nt(m,c):null},c=>Pe.current[c]??"",Yi,(c,m)=>ir(c,he(m).body,!1)),[Yi,ir]),kb=l.useMemo(()=>If(()=>{var m;const c=(m=yt.current)==null?void 0:m.getContainer();return c?nt(c,ye.current):null},Ne??"in",c=>le(c,!1)),[Ne,le]),Fd=l.useCallback(()=>{const c=be.current?Ct():[ie.current];return c[ye.current]??c[0]??""},[Ct]),sr=l.useCallback(()=>{if(!be.current)return[ie.current];if(F.current==="html"){const c=Pe.current.slice();return c[ye.current]=hn.current,c}return Ct({allPages:!0})},[Ct]),Xi=l.useCallback(c=>{if(!be.current||F.current!=="visual"||!tn.current)return;tr.current=!0;const m=Ct(),w=Math.max(0,Math.min(c,m.length)),j=[...m],B=vs.current?nf(Mn(),vs.current):Mn();j.splice(w,0,B);const U=j.map(Q=>Se(Q));rn(j,!1,void 0,{skipHistory:!0}),Ht(te)&&te.recordInsertPage(w,U),ye.current=w,fo(w),go(!0)},[Ct,rn,te,Se]),Br=l.useCallback(()=>{var w;const c=H.current;if(c!=null&&c.hasAttribute(Jo)){const j=qC(c);if(j!==null)return j}const m=(w=yt.current)==null?void 0:w.getActivePageIndex();return typeof m=="number"?m:ye.current},[]),Hd=l.useCallback(()=>{const c=Br();c===null||!tn.current||Xi(c)},[Xi,Br]),zd=l.useCallback(()=>{const c=Br();c===null||!tn.current||Xi(c+1)},[Xi,Br]),Od=l.useCallback(()=>{if(!be.current||F.current!=="visual"||!tn.current)return;tr.current=!0;const c=Ct();if(c.length<=1){tr.current=!1;return}const m=Br();if(m===null){tr.current=!1;return}const w=c[m]??"",j=c.filter((ue,_e)=>_e!==m),B=Se(w),U=j.map(ue=>Se(ue));rn(j,!1,void 0,{skipHistory:!0}),Ht(te)&&te.recordDeletePage(m,B,U);const Q=Math.min(m,j.length-1);ye.current=Q,fo(Q),go(!0)},[Ct,rn,te,Br,Se]);l.useEffect(()=>{pe||go(!1)},[pe]),l.useEffect(()=>()=>{fi.current&&(pi.current=!1,gi())},[gi]);const Ji=l.useCallback(c=>{var j,B;const m=dt.replacePages([...c]);ie.current=m.joined,Pe.current=m.pages,Gt.current=!0,Pr(en(m.pages),ye.current);const w=Math.max(0,Math.min(ye.current,m.pages.length-1));w!==ye.current&&(ye.current=w,fo(w)),ks.current===void 0&&F.current==="html"&&!$e.current&&((j=Tr.current)==null||j.setHtml(m.joined)),(B=Dt.current)==null||B.call(Dt),jn(m.joined),Ht(te)&&te.applyPresent(m.pages)},[en,te,dt,Pr,jn]),Qi=l.useCallback(()=>{if(F.current!=="visual"||Be){_r(null);return}const c=H.current;if(!c)return;const m=Hn(c);_r(w=>m||(w&&w.isConnected&&c.contains(w)?w:null))},[Be]),ea=l.useCallback(()=>{if(Ht(te)){const m=te.undo();if(m===null)return;te.markApplying(),Ji(m),nn();return}const c=te.undo();c!==null&&(te.markApplying(),Lr(c,{fullReplace:!0}),jn(c),te.finishApplying(),Qi(),nn())},[Ji,nn,Lr,te,Qi,jn]),ta=l.useCallback(()=>{if(Ht(te)){const m=te.redo();if(m===null)return;te.markApplying(),Ji(m),nn();return}const c=te.redo();c!==null&&(te.markApplying(),Lr(c,{fullReplace:!0}),jn(c),te.finishApplying(),Qi(),nn())},[Ji,nn,Lr,te,Qi,jn]);l.useEffect(()=>{if(pe){Ht(te)&&(De!==void 0&&!Oe?te.syncPages(Pe.current):te.applyPresent(Pe.current));return}Ht(te)||te.syncExternal(ie.current)},[pe,Oe,te,De]);const K=l.useCallback(()=>{Xe.current=an({mode:F.current,visualEl:H.current,htmlEl:ut.current})},[]),on=l.useCallback(c=>{if(!c||F.current!=="visual"){od(!1),ad(!1),ld(!1);return}od(xu(c)!==null),ad(Xm(c)),ld(Jm(c))},[]),Kd=l.useCallback(()=>{const c=an({mode:F.current,visualEl:H.current,htmlEl:ut.current}),m=Xe.current;Am(m,c)||(Xe.current=c)},[]),dl=l.useCallback(()=>{const c=H.current;if(F.current!=="visual"||!c){bi({value:null,unit:bn.current,mixed:!1});return}const m=wg(c,bn.current);It.current&&(m.value=It.current.value,m.unit=It.current.unit,m.mixed=!1),bn.current=m.unit,bi(w=>w.value===m.value&&w.unit===m.unit&&w.mixed===m.mixed?w:m)},[]),ml=l.useCallback(()=>{const c=H.current;if(F.current!=="visual"||!c){Ts({value:null,mixed:!1});return}const m=op(c);Ft.current&&(m.value=Ft.current.value,m.mixed=!1),Ts(w=>w.value===m.value&&w.mixed===m.mixed?w:m)},[]),fl=l.useCallback(()=>{const c=H.current;if(F.current!=="visual"||!c){Rs({value:null,mixed:!1}),Ds({value:null,mixed:!1});return}const m=Da(c,"color");Zt.current&&(m.value=Zt.current.value,m.mixed=!1);const w=Da(c,"backgroundColor");qt.current&&(w.value=qt.current.value,w.mixed=!1),Rs(j=>j.value===m.value&&j.mixed===m.mixed?j:m),Ds(j=>j.value===w.value&&j.mixed===w.mixed?j:w)},[]),pl=l.useCallback(()=>{const c=H.current;if(F.current!=="visual"||!c){js({tag:null,mixed:!1});return}const m=jv(c);js(w=>w.tag===m.tag&&w.mixed===m.mixed?w:m)},[]),gl=l.useCallback(()=>{const c=H.current;if(F.current!=="visual"||!c){Es({align:null,mixed:!1}),Ms({type:null,mixed:!1}),Ns(!1),Xu(!1);return}const m=qg(c);Es(U=>U.align===m.align&&U.mixed===m.mixed?U:m);const w=Mg(c);Ms(U=>U.type===w.type&&U.mixed===w.mixed?U:w);const j=zv(c);Ns(U=>U===j?U:j);const B=$k(c);Xu(U=>U===B?U:B)},[]),$=l.useCallback(()=>{const c=H.current;if(F.current!=="visual"||!c){As(zn()),Ls(!1),dl(),ml(),fl(),pl(),gl();return}const m=Xe.current,w=!!(m&&!m.collapsed);Ls(B=>B===w?B:w);const j=Pg(Wr(c),Bt.current);As(B=>lv(B,j)?B:j),dl(),ml(),fl(),pl(),gl()},[dl,ml,fl,pl,gl]),$d=l.useCallback(()=>{const c=Xe.current,m=Et.current;!m||!c||c.collapsed&&c.start===m.start&&c.end===m.end||(Bt.current={},It.current=null,Ft.current=null,Zt.current=null,qt.current=null,Rn.current=null,Et.current=null)},[]);l.useEffect(()=>{if(at==="visual"){$();return}Bt.current={},It.current=null,Ft.current=null,Zt.current=null,qt.current=null,Rn.current=null,Et.current=null,As(zn()),bi({value:null,unit:bn.current,mixed:!1}),Ts({value:null,mixed:!1}),Rs({value:null,mixed:!1}),Ds({value:null,mixed:!1}),js({tag:null,mixed:!1}),Es({align:null,mixed:!1}),Ms({type:null,mixed:!1}),Ns(!1),Ls(!1)},[at,$]);const Fr=l.useCallback((c,m,w)=>{Ix({snapshot:c,visualEl:H.current,htmlEl:ut.current,getHtml:()=>F.current==="visual"&&H.current?H.current.innerHTML:ie.current,setHtml:j=>{if(F.current==="visual"){const B=be.current?Pe.current[ye.current]??"":ie.current;Ld(sn(he(j).body,he(B).body),!1);return}xt(j,!1)},content:m,asHtml:w})},[xt,Ld]),Sb=l.useCallback(c=>{if(!be.current||c===ye.current)return;ar(ye.current,hn.current,!0),ye.current=c,fo(c);const m=Pe.current[c]??"";hn.current=m},[ar]),Ab=l.useCallback(c=>{if(be.current){if($e.current){const m=Se(c);hn.current=m,ar(ye.current,m,!0)}else hn.current=c,ar(ye.current,c,!0);return}xt(c,!0)},[Se,xt,ar]),Ud=l.useCallback(c=>{var m;if(F.current==="visual"&&c==="html"){if(be.current){const w=Ct({allPages:!0}),j=ye.current,B=w[j]??w[0]??"";hn.current=B,ie.current=Mt(w)}else if(H.current){const w=sn(H.current.innerHTML,he(ie.current).body),j=da(w,ma(w,ie.current,Nr.current,{liveRoot:H.current??void 0}));if($e.current){const B=Se(j),U=ie.current;(m=Tr.current)==null||m.setStorageHtml(B),ie.current=B,B!==U&&(Gt.current=!0,Ht(te)||te.record(B,{coalesce:!0}))}else j!==ie.current&&xt(j,!0)}}F.current==="html"&&c==="visual"&&be.current&&ar(ye.current,hn.current,!0),si(c),c!=="visual"&&go(!1)},[Se,te,xt,ar,si,Ct]);l.useEffect(()=>{if(!Rt)return;const c=document.body.style.overflow;return document.body.style.overflow="hidden",()=>{document.body.style.overflow=c}},[Rt]),l.useEffect(()=>{if(!Rt)return;const c=m=>{m.key==="Escape"&&(m.defaultPrevented||Si.open||Ks.open||Po.open||To.open||Us||Zs.open||Ys.open||Js.open||el.open||Fs||Pi.open||nl.open||rl||(m.preventDefault(),Qn(!1)))};return document.addEventListener("keydown",c),()=>document.removeEventListener("keydown",c)},[Rt,Qn,Si.open,Ks.open,Po.open,To.open,Us,Zs.open,Ys.open,Js.open,el.open,Fs,Pi.open,nl.open,rl]),l.useEffect(()=>{const c=()=>{if(F.current!=="visual"||!H.current)return;const m=window.getSelection();if(!m||m.rangeCount===0)return;const w=m.anchorNode;!w||!H.current.contains(w)&&H.current!==w||jr.current===null&&(jr.current=window.requestAnimationFrame(()=>{var B;jr.current=null;const j=H.current;if(!(!j||F.current!=="visual")&&(K(),$d(),$(),_r(Hn(j)),on(j),Tn.current&&ui.current&&!((B=ci.current)!=null&&B.contains(document.activeElement)))){const U=Xe.current;U&&gn(lf(j,U))}}))};return document.addEventListener("selectionchange",c),()=>{document.removeEventListener("selectionchange",c),jr.current!==null&&(window.cancelAnimationFrame(jr.current),jr.current=null)}},[K,$d,$,on]),l.useEffect(()=>{if(at!=="html")return;const c=ut.current;if(!c)return;const m=()=>K();return c.addEventListener("select",m),c.addEventListener("keyup",m),c.addEventListener("mouseup",m),()=>{c.removeEventListener("select",m),c.removeEventListener("keyup",m),c.removeEventListener("mouseup",m)}},[at,K]);const W=l.useCallback(c=>{const m=an({mode:"visual",visualEl:c,htmlEl:ut.current}),w=Xe.current,j=Am(w,m)?w:m.visualRange?m:w??m;Xe.current=j,c.focus();const B=jx(c,j);if(B){const U=window.getSelection();try{U==null||U.removeAllRanges(),U==null||U.addRange(B),Xe.current={...j,visualRange:B}}catch{}}return Xe.current??j},[]),yn=l.useCallback(()=>{vi.current=null,ki.current=null,qu(!1)},[]),Vd=l.useCallback(()=>{if(!wi.current||!vi.current||!ki.current||F.current!=="visual")return;const c=H.current;if(!c)return;K();const m=Xe.current;!m||m.collapsed||CS(m,ki.current)||(W(c),vS(c,vi.current),le(c,!1),K(),$(),yn())},[K,W,ge,$,yn]),Wd=l.useCallback(()=>{if(F.current!=="visual"){yn();return}if(wi.current){yn();return}const c=H.current;if(!c){yn();return}const m=W(c);if(m.collapsed){yn();return}vi.current=wS(c),ki.current={...m},qu(!0),K()},[yn,W,K]),Pb=l.useCallback(()=>{Vd()},[Vd]);l.useEffect(()=>{(at!=="visual"||Be)&&yn()},[at,Be,yn]);const hl=l.useCallback((c,m)=>{if(F.current!=="visual")return;const w=H.current;if(!w)return;const j=m??bn.current,B=pr(c,j);if(!B)return;bn.current=B.unit;const U=W(w);if(U.collapsed){It.current=B,Et.current={start:U.start,end:U.end},$();return}It.current=null,gc(w,B.value,B.unit)&&(le(w,!1),K(),$())},[W,ge,K,$]),Gd=l.useCallback(c=>{if(F.current!=="visual")return;const m=H.current;if(!m)return;const w=W(m);if(w.collapsed){Ft.current={value:c},Et.current={start:w.start,end:w.end},$();return}Ft.current=null,nc(m,c)&&(le(m,!1),K(),$())},[W,ge,K,$]),bl=l.useCallback((c,m)=>{if(F.current!=="visual")return;const w=H.current;if(!w)return;const j=W(w),B=c==="color"?Zt:qt;if(j.collapsed){B.current={value:m},Et.current={start:j.start,end:j.end},$();return}B.current=null,Oo(w,c,m)&&(le(w,!1),K(),$())},[W,ge,K,$]),yl=l.useCallback(c=>{if(F.current!=="visual")return;const m=H.current;if(!m)return;const w=W(m);if(Ai({open:!1,tab:"general"}),w.collapsed){if(c.size!==null){const Q=pr(c.size,c.unit);Q&&(It.current=Q,bn.current=Q.unit)}const B=Wr(m),U={};for(const Q of Kt)c.marks[Q]!==B[Q]&&(U[Q]=c.marks[Q]);Bt.current=U,c.fontColorMixed||(Zt.current={value:c.fontColor}),c.highlightColorMixed||(qt.current={value:c.highlightColor}),c.fontFamilyMixed||(Ft.current={value:c.fontFamily}),Et.current={start:w.start,end:w.end},$();return}if(Bt.current={},It.current=null,Ft.current=null,Zt.current=null,qt.current=null,Et.current=null,c.size!==null){const B=pr(c.size,c.unit);B&&(bn.current=B.unit,gc(m,B.value,B.unit))}const j=Wr(m);for(const B of Kt)c.marks[B]!==j[B]&&yc(m,B);c.fontFamilyMixed||nc(m,c.fontFamily),c.fontColorMixed||Oo(m,"color",c.fontColor),c.highlightColorMixed||Oo(m,"backgroundColor",c.highlightColor),le(m,!1),K(),$()},[W,ge,K,$]),Zd=l.useCallback((c,m)=>{if(F.current!=="visual")return;const w=H.current;if(!w)return;W(w),Ir(B=>({...B,open:!1}));let j=Xg(w,c);if(m&&gk(w,m)&&(j=!0),!j){K(),$();return}le(w,!1),K(),$()},[W,ge,K,$]),qd=l.useCallback(c=>{if(F.current!=="visual")return;const m=H.current;if(!m)return;const w=W(m);if($s(j=>({...j,open:!1})),!ms(c)){K(),$();return}if(w.collapsed){Rn.current=c,Et.current={start:w.start,end:w.end},$();return}if(Rn.current=null,!Ag(m,c)){K(),$();return}le(m,!1),K(),$()},[W,ge,K,$]),Yd=l.useCallback(c=>{if(F.current!=="visual")return;const m=_o();if(!m)return;W(m),nr(U=>({...U,open:!1}));const w=be.current?Pe.current[ye.current]??"":ie.current,j=JSON.stringify(c.atRule)!==JSON.stringify(st(he(w).body)),B=Pc(m,c);if(j&&co(m,B.pageHtml),!B.changed&&!j){K(),$();return}le(m,!1,B.pageHtml),K(),$()},[W,le,K,$,_o]),Xd=l.useCallback(c=>{if(F.current!=="visual")return;const m=H.current;if(m){if(W(m),Ri(w=>({...w,open:!1})),!qk(m,c)){K(),$();return}le(m,!1),K(),$()}},[W,ge,K,$]),Jd=l.useCallback(c=>{if(F.current!=="visual")return;const m=H.current;if(m){if(W(m),Gs(w=>({...w,open:!1})),!Qk(m,c)){K(),$();return}le(m,!1),K(),$()}},[W,ge,K,$]),na=l.useCallback(c=>{if(F.current!=="visual")return;const m=H.current;if(m){if(W(m),Di({open:!1}),!xw(m,c,V.current)){K(),$();return}le(m,!1),K(),$()}},[W,ge,K,$]),ra=l.useCallback(c=>{if(F.current!=="visual")return;const m=H.current;if(m){if(W(m),ji({open:!1}),!LS(m,c)){K(),$();return}le(m,!1),K(),$()}},[W,ge,K,$]),Qd=l.useCallback(c=>{if(F.current!=="visual")return;const m=H.current;if(m){if(W(m),Do({open:!1}),!qS(m,c)){K(),$();return}le(m,!1),K(),$()}},[W,ge,K,$]),em=l.useCallback(c=>{if(F.current!=="visual")return;const m=H.current;if(m){if(W(m),qs({open:!1}),!Yv(m,c)){K(),$();return}le(m,!1),K(),$(),on(m)}},[W,ge,K,$,on]),tm=l.useCallback(c=>{if(F.current!=="visual")return;const m=H.current;if(m){if(W(m),Xs(w=>({...w,open:!1})),!S0(m,c)){K(),$();return}le(m,!1),K(),$()}},[W,ge,K,$]),nm=l.useCallback(c=>{if(F.current!=="visual")return;const m=H.current;if(m){if(W(m),Qs(w=>({...w,open:!1})),!M0(m,c)){K(),$();return}le(m,!1),K(),$(),on(m)}},[W,ge,K,$,on]),rm=l.useCallback(c=>{if(F.current!=="visual")return;const m=H.current;if(m){if(W(m),tl(w=>({...w,open:!1})),!U0(m,c)){K(),$();return}le(m,!1),K(),$()}},[W,ge,K,$]),xn=l.useCallback(c=>{if(F.current!=="visual")return;const m=H.current;if(m){if(W(m),!c(m)){K(),$();return}le(m,!1),K(),$(),on(m)}},[W,ge,K,$,on]),xl=l.useCallback(c=>{na({src:c.src,alt:c.alt??"",title:c.title??"",css:c.css})},[na]),Cl=l.useCallback(c=>{ra({src:c.src,title:c.title??"",css:c.css})},[ra]),wl=l.useCallback(c=>{if(F.current!=="visual")return;const m=H.current;if(m){if(W(m),Do({open:!1}),!YS(m,{src:c.src,title:c.title??"",css:c.css})){K(),$();return}le(m,!1),K(),$()}},[W,ge,K,$]),om=l.useCallback(c=>{if(F.current!=="visual")return;const m=H.current;if(m){if(W(m),Ii(w=>({...w,open:!1})),!Lw(m,c)){K(),$();return}le(m,!1),K(),$()}},[W,ge,K,$]),Tb=l.useCallback((c,m)=>{mt!=null&&mt.isConnected&&x0(mt,c,m)},[mt]),Rb=l.useCallback(()=>{const c=H.current;!c||!(mt!=null&&mt.isConnected)||(le(c,!1),Hl(c,mt),K(),$())},[mt,ge,K,$]),oa=l.useCallback(()=>{if(F.current!=="visual"||!H.current)return ie.current;const c=sn(H.current.innerHTML,he(ie.current).body);return da(c,ma(c,ie.current,Nr.current,{liveRoot:H.current}))},[]),ia=l.useCallback(()=>{if(be.current){const c=Mt(sr());return ie.current=c,Ge(c)}if(Gt.current){const c=F.current==="visual"?oa():ie.current;c!==ie.current&&(ie.current=c)}return Ge(ie.current)},[sr,Ge,oa]),Db=l.useRef(-1),im=l.useCallback(()=>{if(!Gt.current&&Dr.current)return Dr.current;const c=Gt.current&&F.current==="visual"?oa():ie.current;return c!==ie.current&&(ie.current=c),Dr.current=c,Gt.current=!1,c},[oa]),am=l.useCallback(()=>{if(!Gt.current&&Dr.current)return Dr.current;const c=Ct(),m=JSON.stringify(c);return Dr.current=m,Db.current=dt.revision,Gt.current=!1,m},[Ct,dt.revision]),jb=l.useCallback(()=>be.current?am():im(),[am,im]);X0({onAutoSave:r?async c=>{Gt.current=!1;const m=be.current?en(JSON.parse(c)):Ge(c);return r(m)}:void 0,getHtml:jb}),l.useEffect(()=>()=>{var c;(c=V.current)==null||c.clear()},[]),l.useEffect(()=>{var m;if(!Oe||e===void 0||pe)return;const c=Se(e);(m=Tr.current)==null||m.setStorageHtml(c),ie.current=c,Ht(te)||te.syncExternal(c)},[pe,Se,te,Oe,e]),l.useEffect(()=>{if(!Oe||!pe||De===void 0)return;const c=Bn(De).map(w=>Se(w));if(mr(c,Pe.current))return;const m=dt.replacePages(c);if(ie.current=m.joined,Pe.current=m.pages,Ht(te)&&te.syncPages(m.pages),F.current==="html"){const w=m.pages[ye.current]??"";hn.current=w}},[pe,Se,te,Oe,dt,De]),l.useEffect(()=>()=>{var c;(c=ho.current)==null||c.cancel()},[]);const Te=l.useMemo(()=>({getHtml:ia,setHtml:c=>{xt(c,!1)},getMode:()=>F.current,setMode:Ud,getFullscreen:()=>$u.current,setFullscreen:Qn,getDarkMode:()=>kd.current,setDarkMode:c=>{Ed(c)},getPageZoom:()=>Ki.current,setPageZoom:_d,getToolbarPosition:()=>Sd.current,setToolbarPosition:c=>{Md(c)},openCustomizeToolbar:()=>{Qu(!0)},openDocumentPreview:()=>{ed({open:!0,html:Ge(Mt(sr()))})},openHelp:()=>{jo({open:!0,topicId:"getStarted"})},openKeyboardShortcuts:()=>{jo({open:!0,topicId:"keyboardShortcuts"})},openAbout:()=>{nd(!0)},toggleReadAloud:()=>{const c=ho.current;if(!c)return;const m=Xe.current??an({mode:F.current,visualEl:H.current,htmlEl:ut.current}),w=uf(fa(m),ia());w&&c.toggle(w)},toggleRuler:()=>{ws(c=>!c)},isReadingAloud:()=>{var c;return((c=ho.current)==null?void 0:c.isSpeaking())??!1},isRulerVisible:()=>li.current,canReadAloud:()=>{if(!Aa())return!1;const c=Xe.current??an({mode:F.current,visualEl:H.current,htmlEl:ut.current});return uf(fa(c),ia())!==null},undo:ea,redo:ta,canUndo:()=>te.canUndo(),canRedo:()=>te.canRedo(),getSelection:()=>{const c=Xe.current??an({mode:F.current,visualEl:H.current,htmlEl:ut.current});return fa(c)},insertText:c=>{const m=Xe.current??an({mode:F.current,visualEl:H.current,htmlEl:ut.current});Fr(m,c,!1)},insertHtml:(c,m)=>{const w=Xe.current??an({mode:F.current,visualEl:H.current,htmlEl:ut.current}),j=m===void 0;Fr(w,j?c:m,j)},toggleFontMark:c=>{if(F.current!=="visual")return;const m=H.current;if(!m)return;const w=W(m);if(w.collapsed){const j=Wr(m);Bt.current=uv(Bt.current,j,c),Et.current={start:w.start,end:w.end},$();return}Bt.current={},Et.current=null,yc(m,c)&&(le(m,!1),K(),$())},clearFormatting:()=>{if(F.current!=="visual")return;const c=H.current;!c||W(c).collapsed||(Bt.current={},It.current=null,Ft.current=null,Zt.current=null,qt.current=null,Rn.current=null,Et.current=null,xS(c)&&(le(c,!1),K(),$()))},toggleFormatBrush:Wd,isFormatBrushActive:()=>wi.current,isFontMarkActive:c=>Ps.current[c],hasTextSelection:()=>F.current==="visual"&&Bs.current,setFontSize:(c,m)=>{hl(c,m)},setFontSizeUnit:c=>{var Q;const m=H.current,w=Dn.current;if(F.current!=="visual"||!m||w.value===null||w.mixed){bn.current=c,bi(ue=>({...ue,unit:c}));return}const j=W(m),B=X1(m,((Q=j.visualRange)==null?void 0:Q.startContainer)??m),U=ap(w.value,w.unit,c,B.parentPx,B.rootPx);hl(U,c)},getFontSize:()=>Dn.current.value,getFontSizeUnit:()=>Dn.current.unit,isFontSizeMixed:()=>Dn.current.mixed,setFontFamily:c=>{Gd(c)},getFontFamily:()=>Co.current.value,isFontFamilyMixed:()=>Co.current.mixed,getFontFaces:()=>Nr.current,setFontColor:c=>{bl("color",c)},setHighlightColor:c=>{bl("backgroundColor",c)},getFontColor:()=>vo.current.value,isFontColorMixed:()=>vo.current.mixed,getHighlightColor:()=>So.current.value,isHighlightColorMixed:()=>So.current.mixed,setParagraphStyle:c=>{if(F.current!=="visual")return;const m=H.current;m&&(W(m),Iv(m,c)&&(le(m,!1),K(),$()))},getParagraphStyle:()=>Is.current.tag,isParagraphStyleMixed:()=>Is.current.mixed,setTextAlign:c=>{if(F.current!=="visual")return;const m=H.current;m&&(W(m),Yg(m,c)&&(le(m,!1),K(),$()))},getTextAlign:()=>_s.current.align,isTextAlignMixed:()=>_s.current.mixed,indent:()=>{if(F.current!=="visual")return;const c=H.current;c&&(W(c),Ov(c)&&(le(c,!1),K(),$()))},outdent:()=>{if(F.current!=="visual")return;const c=H.current;c&&(W(c),Kv(c)&&(le(c,!1),K(),$()))},canOutdent:()=>F.current==="visual"&&Zu.current,toggleList:c=>{if(F.current!=="visual")return;const m=H.current;m&&(W(m),Mv(m,c)&&(le(m,!1),K(),$()))},isBulletList:()=>Ao.current.type==="ul"&&!Ao.current.mixed,isNumberedList:()=>Ao.current.type==="ol"&&!Ao.current.mixed,openFontProperties:c=>{F.current==="visual"&&Ai({open:!0,tab:c??"general"})},applyFontProperties:c=>{yl(c)},openCustomCss:()=>{if(F.current!=="visual")return;const c=H.current;c&&W(c);const m=c?kg(c):{value:null,mixed:!1},w=m.mixed||!m.value?"":rv(m.value);$s({open:!0,value:w})},applyCustomCss:c=>{qd(c)},openParagraphProperties:c=>{if(F.current!=="visual")return;const m=H.current;m&&W(m),Ir({open:!0,tab:c??"general",value:m?Kl(m):Yr(),backgroundImage:m?tf(m):kn()})},applyParagraphProperties:(c,m)=>{Zd(c,m)},openPageProperties:(c,m)=>{if(F.current!=="visual")return;const w=_o();w&&W(w);const j=be.current?Pe.current[ye.current]??"":ie.current,B=w?Sa(w):Wa();nr({open:!0,tab:c==="print"&&!bt?"font":c??"font",paragraphTab:m??"spacing",value:{...B,atRule:st(he(j).body)}})},applyPageProperties:c=>{Yd(c)},openPageBackgroundImage:()=>{if(F.current!=="visual")return;const c=_o();c&&W(c);const m=be.current?Pe.current[ye.current]??"":ie.current,w=c?Sa(c):Wa();nr({open:!0,tab:"paragraph",paragraphTab:"backgroundImage",value:{...w,atRule:st(he(m).body)}})},openParagraphBackgroundImage:()=>{if(F.current!=="visual")return;const c=H.current;c&&W(c),Ir({open:!0,tab:"backgroundImage",value:c?Kl(c):Yr(),backgroundImage:c?tf(c):kn()})},openCustomParagraphStyleDialog:c=>{if(F.current!=="visual"||!ll.current)return;if(c){const w=zi.current.find(j=>j.id===c);if(!w)return;Ro({open:!0,mode:"edit",style:w});return}const m=H.current;m&&W(m),Ro({open:!0,mode:"create",font:{size:Dn.current.mixed?null:Dn.current.value,unit:Dn.current.unit,marks:{...Ps.current},fontFamily:Co.current.mixed?null:Co.current.value,fontColor:vo.current.mixed?null:vo.current.value,highlightColor:So.current.mixed?null:So.current.value},paragraph:Jg(m?Kl(m):Yr())})},applyCustomParagraphStyle:c=>{const m=zi.current.find(j=>j.id===c);if(!m||(yl({size:m.font.size,unit:m.font.unit,marks:m.font.marks,fontFamily:m.font.fontFamily??null,fontFamilyMixed:!1,fontColor:m.font.fontColor,highlightColor:m.font.highlightColor,fontColorMixed:!1,highlightColorMixed:!1}),!m.paragraph))return;const w=H.current;!w||F.current!=="visual"||(W(w),fk(w,m.paragraph)&&(le(w,!1),K(),$()))},customParagraphStylesEnabled:()=>ll.current,getCustomParagraphStyles:()=>zi.current,isCustomParagraphStylesLoading:()=>dd.current,openLinkDialog:c=>{if(F.current!=="visual")return;const m=H.current;m&&W(m);const w=m?nh(m):gs(),j=m?Rc(m):[],B=(w==null?void 0:w.href)??"",U=B.startsWith("#")?B.slice(1):"",Q=j.some(ue=>ue.id===U)?U:"";Ri({open:!0,tab:c??"link",href:B,title:(w==null?void 0:w.title)??"",targetBlank:(w==null?void 0:w.targetBlank)??!1,textDecorationNone:(w==null?void 0:w.textDecorationNone)??!1,hoverMode:(w==null?void 0:w.hoverMode)??"color",hoverColor:(w==null?void 0:w.hoverColor)??null,hoverHtml:(w==null?void 0:w.hoverHtml)??"",bookmarks:j,selectedBookmarkId:Q})},applyLink:c=>{Xd(c)},openBookmarkDialog:()=>{if(F.current!=="visual")return;const c=H.current;c&&W(c),Gs({open:!0,existingIds:c?Rc(c).map(m=>m.id):[]})},applyBookmark:c=>{Jd(c)},openImageDialog:()=>{if(F.current!=="visual")return;const c=H.current;c&&W(c);const m=bd.current;if(Ad.current&&m){m.onPick(xl);return}Di({open:!0})},applyImage:c=>{na(c)},openAudioDialog:()=>{if(F.current!=="visual")return;const c=H.current;c&&W(c);const m=yd.current;if(Pd.current&&m){m.onPick(Cl);return}ji({open:!0})},applyAudio:c=>{ra(c)},openYoutubeDialog:()=>{if(F.current!=="visual")return;const c=H.current;c&&W(c);const m=xd.current;if(Td.current&&m){m.onPick(wl);return}Do({open:!0})},applyYoutube:c=>{Qd(c)},openImageProperties:c=>{if(F.current!=="visual")return;const m=H.current;if(!m)return;W(m);const w=Hn(m),j=Nw(m);!w||!j||Ii({open:!0,tab:c??"general",value:j,aspectRatio:Ew(w)})},applyImageProperties:c=>{om(c)},insertHorizontalRule:()=>{if(F.current!=="visual")return;const c=H.current;c&&(W(c),l0(c)&&(le(c,!1),K(),$()))},insertPageBreak:()=>{if(F.current!=="visual")return;const c=H.current;c&&(W(c),f0(c)&&(le(c,!1),K(),$()))},insertPageBefore:()=>{Hd()},insertPageAfter:()=>{zd()},deletePage:()=>{!be.current||F.current!=="visual"||tn.current&&(sr().length<=1||Vs(!0))},isMultiPagesEnabled:()=>be.current,hasSelectedPage:()=>be.current&&F.current==="visual"&&tn.current,canDeletePage:()=>be.current&&F.current==="visual"&&tn.current&&sr().length>1,canInsertPageBackgroundImage:()=>!(F.current!=="visual"||be.current&&!tn.current),canInsertParagraphBackgroundImage:()=>{if(F.current!=="visual")return!1;const c=H.current;return c?An(c).length>0:!1},getActivePageHtml:()=>Fd(),getAllPagesHtml:()=>en(sr()),openTableDialog:()=>{if(F.current!=="visual")return;const c=H.current;c&&W(c),qs({open:!0})},applyTable:c=>{em(c)},openTableProperties:()=>{if(F.current!=="visual")return;const c=H.current;if(!c)return;W(c);const m=k0(c);m&&Xs({open:!0,value:m})},applyTableProperties:c=>{tm(c)},openCellProperties:()=>{if(F.current!=="visual")return;const c=H.current;if(!c)return;W(c);const m=_0(c);m&&Qs({open:!0,value:m})},applyCellProperties:c=>{nm(c)},openRowProperties:()=>{if(F.current!=="visual")return;const c=H.current;if(!c)return;W(c);const m=$0(c);m&&tl({open:!0,value:m})},applyRowProperties:c=>{rm(c)},insertRowBelow:()=>{xn(c=>wc(c,"below"))},insertRowBefore:()=>{xn(c=>wc(c,"before"))},deleteRow:()=>{xn(c=>Xv(c))},insertColumnAfter:()=>{xn(c=>Ym(c,"after"))},insertColumnBefore:()=>{xn(c=>Ym(c,"before"))},deleteColumn:()=>{xn(c=>Jv(c))},mergeCells:()=>{xn(c=>tk(c))},unmergeCells:()=>{xn(c=>nk(c))},cut:async()=>{if(F.current!=="visual")return;const c=H.current;c&&(W(c),await pS(c)&&(le(c,!1),K(),$()))},copy:async()=>{if(F.current!=="visual")return;const c=H.current;c&&(W(c),await uh(c))},deleteSelection:()=>{if(F.current!=="visual")return;const c=H.current;c&&(W(c),ch(c)&&(le(c,!1),K(),$()))},addComment:()=>{if(!Tn.current||b||F.current!=="visual")return;const c=H.current;if(!c)return;const m=W(c),w=lf(c,m);if(w){gn(w);return}const j=rS(c,m);if(!j)return;const B=lS(j);oS(c,B.id,m)&&(cf(c,B.id),K(),Bd(c,!1),er([...di.current,B]),gn(B.id))},toggleCommentsVisible:()=>{Cs(c=>{const m=!c,w=H.current;return w&&ah(w,m),m})},areCommentsVisible:()=>ui.current,canAddComment:()=>!Tn.current||b||F.current!=="visual"?!1:Bs.current||sl.current!==null,isCommentsEnabled:()=>Tn.current,getCommentThreads:()=>di.current,setCommentThreads:c=>er(c),openCommentThread:c=>{const m=H.current;!m||F.current!=="visual"||cf(m,c)&&(K(),gn(c))},isContentLocked:()=>Nu.current,isLink:()=>Ju.current,isImageSelected:()=>F.current==="visual"&&sl.current!==null,isInTable:()=>F.current==="visual"&&id.current,canMergeCells:()=>F.current==="visual"&&sd.current,canUnmergeCells:()=>F.current==="visual"&&cd.current,...o!=null?{onSave:c=>gd.current(c)}:{},...a!=null?{onOpen:()=>hd.current()}:{}}),[xt,ge,le,Bd,Ud,Qn,Ed,_d,Md,Fr,ea,ta,K,$,W,hl,Gd,bl,yl,qd,Zd,Yd,Xd,Jd,na,ra,Qd,om,em,tm,nm,rm,xn,xl,Cl,wl,ia,Fd,sr,Hd,zd,Od,Wd,o,a,b,er,bt]),sm=l.useCallback(()=>{const c=Xe.current??an({mode:F.current,visualEl:H.current,htmlEl:ut.current});return{mode:c.mode,selection:fa(c),getHtml:Te.getHtml,setHtml:m=>{xt(m,!1)},insertText:m=>Fr(c,m,!1),insertHtml:(m,w)=>{const j=w===void 0;Fr(c,j?m:w,j)}}},[Fr,Te.getHtml,xt]),{catalog:aa,layout:lm}=l.useMemo(()=>By(z,ER,_R),[z]),sa=l.useMemo(()=>OA(lm,M),[lm,M]),cm=l.useMemo(()=>({...sa,iconGroups:pA(sa.iconGroups,Hs)}),[sa,Hs]),um=pe&&at==="visual",vl=l.useMemo(()=>XR(cm,um),[cm,um]),kl=l.useMemo(()=>We?BR(aa,Wt):aa,[aa,We,Wt]),Sl=l.useMemo(()=>We?FR(vl):vl,[vl,We]),Al=l.useMemo(()=>({disabled:Qt,readOnly:x,enableComments:We}),[Qt,x,We]),Ib=l.useCallback(c=>{if(!Pn||!Ue||b)return;const m=cS(Ue,c);er(uS(di.current,Pn,m))},[Pn,Ue,b,er]),Hr=l.useMemo(()=>({...W1(Te),...Fy(z,sm)}),[Te,z,sm]),Pl=l.useMemo(()=>G1(Te),[Te,bo,yo,xo,wo,ko,yi,Mi,Ni,Oi,Mr,mt,Bi,Fi,Hi,xi,Ci,rr,Er,Io,po,Fu,Rt]);l.useLayoutEffect(()=>{jt.bump("history")},[Fu,jt]),l.useLayoutEffect(()=>{jt.bump("marks")},[bo,yo,xo,wo,ko,yi,Ci,jt]),l.useLayoutEffect(()=>{jt.bump("table")},[Bi,Fi,Hi,jt]),l.useLayoutEffect(()=>{jt.bump("selection")},[xi,mt,jt]),l.useLayoutEffect(()=>{jt.bump("chrome")},[rr,Er,Io,po,Rt,Mi,Ni,Oi,Mr,jt]);const Eb=l.useCallback(c=>{if(Be||c.inputType!=="insertText"&&c.inputType!=="insertReplacementText"||!c.data||!cv(Bt.current)&&!It.current&&!hx(Ft.current)&&!$x({color:Zt.current,backgroundColor:qt.current})&&!av(Rn.current))return;const m=H.current;m&&(c.preventDefault(),xv(m,c.data,Bt.current,It.current,{color:Zt.current,backgroundColor:qt.current},Ft.current,Rn.current),Bt.current={},It.current=null,Ft.current=null,Zt.current=null,qt.current=null,Rn.current=null,Et.current=null,le(m,!0),K(),$())},[Be,ge,K,$]),_b=l.useCallback(c=>{if(Be||!ex(c,ud.current))return;c.preventDefault(),c.stopPropagation();const m=H.current;if(!m)return;W(m);const w=mc(m,c.target),j=Ua(m,c.target);j&&!ii(m).includes(j)&&ek(m,j);const B={inTable:At(m,c.target)!==null,canMergeCells:Xm(m),canUnmergeCells:Jm(m)},U={canDeletePage:be.current&&tn.current&&Ct().length>1},Q={canAddComment:Tn.current&&!b};if(w){Hl(m,w),K(),_r(w),al({open:!0,x:c.clientX,y:c.clientY,kind:"image",...B,...U,...Q,inTable:At(m,w)!==null});return}const ue=an({mode:"visual",visualEl:m,htmlEl:ut.current});Xe.current=ue,al({open:!0,x:c.clientX,y:c.clientY,kind:ue.collapsed?"caret":"text",...B,...U,canAddComment:Q.canAddComment&&!ue.collapsed})},[Be,K,W,Ct,b]),Mb=l.useCallback(c=>{if(ud.current=c.pointerType,b)return;const m=H.current;if(!m)return;if(Tn.current&&ui.current){const j=sh(m,c.target);if(j){const B=j.getAttribute("data-comment-thread");B&&gn(B);return}}if(Be&&!Tn.current)return;const w=mc(m,c.target);if(!w){_r(null);return}c.preventDefault(),Hl(m,w),K(),_r(w)},[b,Be,K]),dm=l.useCallback(c=>{if(Be)return;if(c.key==="Tab"&&!c.ctrlKey&&!c.metaKey&&!c.altKey){if(F.current!=="visual")return;const w=H.current;if(!w)return;const j=c.target;if(!(j instanceof Node)||!w.contains(j))return;W(w);const B=Qv(w,c.shiftKey);if(!B)return;c.preventDefault(),typeof B=="object"&&B.changed&&le(w,!1),K(),$(),on(w);return}if(!(c.ctrlKey||c.metaKey))return;if(c.key==="Enter"&&!c.shiftKey){c.preventDefault(),Te.insertPageBreak();return}const m=c.key.toLowerCase();if(m==="z"&&!c.shiftKey){c.preventDefault(),ea();return}if(m==="z"&&c.shiftKey||m==="y"){c.preventDefault(),ta();return}if(m==="b"&&!c.shiftKey){c.preventDefault(),Te.toggleFontMark("bold");return}if(m==="i"&&!c.shiftKey){c.preventDefault(),Te.toggleFontMark("italic");return}if(m==="u"&&!c.shiftKey){c.preventDefault(),Te.toggleFontMark("underline");return}if(m==="x"&&c.shiftKey){c.preventDefault(),Te.toggleFontMark("strikethrough");return}m==="p"&&!c.shiftKey&&(c.preventDefault(),Hr.print())},[Be,ea,ta,Te,Hr,W,ge,K,$,on]),Nb=l.useCallback(c=>{if(c.key==="F1"){c.preventDefault(),jo({open:!0,topicId:"getStarted"});return}if(c.key==="Escape"&&Pn){c.preventDefault(),gn(null);return}dm(c)},[Pn,dm]),Lb=[xe.root,ec(rr).className,Rt?xe.fullscreen:"",y].filter(Boolean).join(" "),Bb=I_({toolbarBackground:k,menuColor:S,menuBackground:P,menuFontSize:R,menuFontFamily:D,border:A}),Fb=ec(rr)["data-wysiwyg-theme"];Bu.current={multiPageVisualRef:yt,workspaceRef:Ar,suppressPageFlushRef:tr,visualRootRef:H,visualPropSyncGuardRef:Dt,htmlAreaRef:ut,commentPanelRef:ci,activePageIndexRef:ye,htmlModePageHtmlRef:hn,activePageHtmlRef:Ou,pageCanvasSizedRef:Ku,setActivePageIndex:fo,setHasSelectedPage:go,setActiveThreadId:gn,setContextMenu:al,recordVisualInputHtml:bb,recordPageVisualHtml:ir,handleVisualBeforeInput:Eb,handleVisualPointerDown:Mb,handleVisualMouseUp:Pb,handleVisualContextMenu:_b,handleHtmlPageTabSelect:Sb,handleHtmlSurfaceChange:Ab,handleImageResize:Tb,handleImageResizeEnd:Rb,multiPageRulerMarginPreview:wb,multiPageRulerMarginChange:vb,multiPageRulerIndentChange:kb,singlePageRulerMarginPreview:yb,singlePageRulerMarginChange:xb,singlePageRulerIndentChange:Cb,resolveEmbeddedImageDataUrl:Oe?ys:void 0,hydrateExportHtml:Ge,postCommentMessage:Ib,htmlFileDrop:Nd};const Hb=l.useMemo(()=>eb({catalog:kl,layout:Sl,commands:Hr,queries:Pl,queryRevisions:jt,disabled:Qt,chromeLock:Al}),[Qt,Al,Hr,kl,Sl,Pl,jt]),zb=l.useMemo(()=>({documentBridgeRef:Tr,htmlRef:ie,pagesRef:Pe}),[]);return i.jsx(Wy,{locale:v,children:i.jsx(Ky,{dark:rr,children:i.jsx($E,{value:zb,children:i.jsxs("div",{className:Lb,style:Bb,"data-fullscreen":Rt?"":void 0,"data-wysiwyg-theme":Fb,"data-toolbar-position":Er,"data-comments-visible":We&&Wt?"":void 0,onKeyDown:Nb,children:[i.jsx(OE,{menuVisible:T,captureChromeSelection:Kd,displayCatalog:kl,displayLayout:Sl,commands:Hr,queries:Pl,queryRevisions:jt,chromeDisabled:Qt,chromeLock:Al,contentLocked:Be,customizeToolbarOpen:Fs,baseCatalog:aa,allowedLayout:sa,toolbarSettings:Hs,toolbarSettingsLoading:ob,toolbarSettingsBusy:ib,onCustomizeToolbarClose:()=>Qu(!1),onToolbarSettingsChange:c=>{Id(c)},onToolbarSettingsReset:()=>{Id(null)},documentPreview:Pi,onDocumentPreviewClose:()=>ed({open:!1,html:Pi.html}),helpDialog:nl,onHelpDialogClose:()=>jo(c=>({...c,open:!1})),onHelpTopicChange:c=>jo(m=>({...m,open:!0,topicId:c})),aboutDialogOpen:rl,onAboutDialogClose:()=>nd(!1),fontDialog:Si,fontSizeState:yo,markState:bo,fontFamilyState:xo,fontColorState:wo,highlightColorState:ko,fontFaces:Mr,onFontDialogTabChange:c=>Ai({open:!0,tab:c}),onFontDialogClose:()=>Ai({open:!1,tab:Si.tab}),onApplyFontProperties:c=>Te.applyFontProperties(c),paragraphDialog:Po,customImagePicker:Z,onParagraphCustomImagePick:()=>{Z==null||Z.onPick(c=>{Ir(m=>({...m,tab:"backgroundImage",backgroundImage:{...m.backgroundImage,src:c.src}}))})},onParagraphDialogTabChange:c=>Ir({...Po,open:!0,tab:c}),onParagraphDialogClose:()=>Ir({...Po,open:!1}),onApplyParagraphProperties:({value:c,backgroundImage:m})=>Te.applyParagraphProperties(c,m),customCssDialog:Ks,onCustomCssDialogClose:()=>$s(c=>({...c,open:!1})),onApplyCustomCss:c=>Te.applyCustomCss(c),pageDialog:To,enablePageProperties:bt,onPageCustomImagePick:()=>{Z==null||Z.onPick(c=>{nr(m=>({...m,tab:"paragraph",paragraphTab:"backgroundImage",value:{...m.value,backgroundImage:{...m.value.backgroundImage,src:c.src}}}))})},onPageDialogTabChange:c=>nr({...To,open:!0,tab:c}),onPageDialogClose:()=>nr({...To,open:!1}),onApplyPageProperties:c=>Te.applyPageProperties(c),onPageDialogResetAtRule:()=>{const c=_o();if(!c||F.current!=="visual")return;const m=be.current?Pe.current[ye.current]??"":he(ie.current).body,w=Rk(c,m);w.changed&&(le(c,!1,w.pageHtml),nr(j=>({...j,value:{...j.value,atRule:Ln()}})))},deletePageConfirmOpen:Us,onDeletePageConfirmClose:()=>Vs(!1),onDeletePageConfirm:()=>{Od(),Vs(!1)},customStyleDialog:ab,canDeleteCustomParagraphStyle:!!re,customStyleBusy:fb,onCustomStyleDialogClose:()=>Ro({open:!1}),onCustomStyleSave:async c=>{const m=fd.current;if(m){Li(!0);try{await m(c),Ro({open:!1}),await Zi()}finally{Li(!1)}}},onCustomStyleDelete:async c=>{const m=pd.current;if(m){Li(!0);try{await m(c),Ro({open:!1}),await Zi()}finally{Li(!1)}}},linkDialog:Ws,onLinkDialogTabChange:c=>Ri({...Ws,open:!0,tab:c}),onLinkDialogClose:()=>Ri({...Ws,open:!1}),onApplyLink:c=>Te.applyLink(c),bookmarkDialog:td,onBookmarkDialogClose:()=>Gs({...td,open:!1}),onApplyBookmark:c=>Te.applyBookmark(c),imageDialogOpen:sb.open,customAudioPicker:ne,customVideoPicker:X,onImageDialogClose:()=>Di({open:!1}),onApplyImage:c=>Te.applyImage(c),onImageDialogCustomPick:()=>{Di({open:!1}),Z==null||Z.onPick(xl)},audioDialogOpen:lb.open,onAudioDialogClose:()=>ji({open:!1}),onApplyAudio:c=>Te.applyAudio(c),onAudioDialogCustomPick:()=>{ji({open:!1}),ne==null||ne.onPick(Cl)},youtubeDialogOpen:cb.open,onYoutubeDialogClose:()=>Do({open:!1}),onApplyYoutube:c=>Te.applyYoutube(c),onYoutubeDialogCustomPick:()=>{Do({open:!1}),X==null||X.onPick(wl)},imageProperties:ub,onImagePropertiesTabChange:c=>Ii(m=>({...m,tab:c})),onImagePropertiesClose:()=>Ii(c=>({...c,open:!1})),onApplyImageProperties:c=>Te.applyImageProperties(c),tableDialogOpen:Zs.open,onTableDialogClose:()=>qs({open:!1}),onApplyTable:c=>Te.applyTable(c),tableProperties:Ys,onTablePropertiesClose:()=>Xs(c=>({...c,open:!1})),onApplyTableProperties:c=>Te.applyTableProperties(c),cellProperties:Js,onCellPropertiesClose:()=>Qs(c=>({...c,open:!1})),onApplyCellProperties:c=>Te.applyCellProperties(c),rowProperties:el,onRowPropertiesClose:()=>tl(c=>({...c,open:!1})),onApplyRowProperties:c=>Te.applyRowProperties(c)}),i.jsx(KE,{toolbarVisible:_,toolbarPos:Er,captureChromeSelection:Kd,toolbarShellProps:Hb,children:i.jsx(R_,{propsRef:Bu,pageStore:dt,mode:at,enableMultiPages:pe,contentLocked:Be,activePageIndex:Rr,hasSelectedPage:po,pageZoomScale:ol,rulerVisible:mo,rulerUnit:Ne,optimizeEmbeddedImages:Oe,placeholder:C,value:e,pagesProp:De,controlledHtml:Jn,initialHtml:Ke,initialStorageHtml:xs,defaultPages:ee.current??[Mn()],ingestedPagesProp:Lu,onChange:n,fontFaces:Mr,enableComments:We,commentsVisible:Wt,disabled:b,locale:v,commentAuthor:Ue,activeThreadId:Pn,contextMenu:pb,commentThreads:Sr,commands:Hr,htmlFileDropDragging:Nd.dragging,selectedImage:mt})}),Rt?i.jsx(E_,{onClick:()=>Qn(!1)}):null]})})})})}function I_({toolbarBackground:e,menuColor:t,menuBackground:n,menuFontSize:r,menuFontFamily:o,border:a}){const s={};return e&&(s["--wysiwyg-toolbar-background"]=e),t&&(s["--wysiwyg-menu-color"]=t),n&&(s["--wysiwyg-menu-background"]=n),r&&(s["--wysiwyg-menu-font-size"]=r),o&&(s["--wysiwyg-menu-font-family"]=o),a==="none"?(s["--wysiwyg-border-width"]="0",s["--wysiwyg-border-radius"]="0",s["--wysiwyg-border-shadow"]="none"):a&&(a.width&&(s["--wysiwyg-border-width"]=a.width),a.color&&(s["--wysiwyg-border-color"]=a.color),a.radius&&(s["--wysiwyg-border-radius"]=a.radius),a.shadow&&(s["--wysiwyg-border-shadow"]=a.shadow)),Object.keys(s).length?s:void 0}function E_({onClick:e}){const t=q();return i.jsx("button",{type:"button",className:xe.exitFullscreen,"aria-label":t("exitFullscreenAria"),onClick:e,children:i.jsx(et,{className:xe.exitFullscreenIcon})})}function __(e){var n;if(e.tagName.toLowerCase()!=="span")return!1;const t=[...e.attributes];return t.length===0||t.length===1&&((n=t[0])==null?void 0:n.name)===lt?!0:t.length===2&&t.some(r=>r.name===lt)&&t.some(r=>r.name==="class"&&r.value.includes("wysiwyg-comment-anchor"))?!e.hasAttribute("style"):!1}function M_(e){for(const t of[...e.querySelectorAll(`[${lt}]`)])t.removeAttribute(lt),t instanceof HTMLElement&&t.classList.remove("wysiwyg-comment-anchor");for(const t of[...e.querySelectorAll("span")]){if(!__(t))continue;const n=t.parentNode;if(n){for(;t.firstChild;)n.insertBefore(t.firstChild,t);n.removeChild(t)}}}function N_(e){const t=e.trim();if(!t)return e;const n=new DOMParser().parseFromString(t,"text/html");return M_(n.body),n.body.innerHTML}exports.Editor=j_;exports.PAGE_SEPARATOR=Na;exports.joinPagesToHtml=Mt;exports.sanitizeDocumentHtml=$r;exports.sanitizePageHtml=Tc;exports.splitPagesFromHtml=Fn;exports.stripCommentAnchors=N_;
313
+ `.trim();function ug(e){return e.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;")}function m1(e){return ug(e).replace(/'/g,"&#39;")}function dg(e){const t=e.trim();if(!/^<!DOCTYPE/i.test(t)&&!/^<html[\s>]/i.test(t))return e;const n=new DOMParser().parseFromString(t,"text/html"),r=[];for(const o of n.body.childNodes)if(o.nodeType===Node.ELEMENT_NODE)r.push(o.outerHTML);else if(o.nodeType===Node.TEXT_NODE){const a=o.textContent??"";a.trim()&&r.push(a)}return r.join("")||n.body.innerHTML}function f1(e,t="Document"){const n=On(e),r=n.map(b=>Cu(b)),o=r.some(b=>b.hasBleed),a=[],s=[];for(const b of r){const C=ge(b.html);a.push(...C.hrefs),s.push(C.body)}const u=s.length<=1?s[0]??"":s.map((b,C)=>`<div data-wysiwyg-print-page="" style="${C===s.length-1?"display: block; break-inside: avoid; page-break-inside: avoid;":"display: block; break-after: page; page-break-after: always; break-inside: avoid; page-break-inside: avoid;"}">${b}</div>`).join(""),d=Fp(n),f=o?"@page { margin: 0 !important; }":"",g=mg(o),h=[d,f,g].filter(Boolean).join(`
314
+ `),y=Array.from(new Set(a)).map(b=>`<link rel="stylesheet" href="${m1(b)}" />`).join(`
315
+ `);return["<!DOCTYPE html>",'<html lang="en">',"<head>",'<meta charset="utf-8">',`<title>${ug(t)}</title>`,`<style>${h}</style>`,y,"</head>","<body>",u,"</body>","</html>"].filter(Boolean).join(`
316
+ `)}function mg(e){return e?`${Zm}
317
+ ${d1}`:Zm}function xc(e,t,n="​"){const r=Cu(t),{hrefs:o,body:a}=ge(r.html),s=e.createElement("meta");s.setAttribute("charset","utf-8");const u=e.createElement("title");u.textContent=n;const d=e.createElement("style");d.textContent=mg(r.hasBleed);const f=o.map(g=>{const h=e.createElement("link");return h.rel="stylesheet",h.href=g,h});e.head.replaceChildren(s,u,d,...f),e.title=n,e.body.innerHTML=a}function wu(e){return typeof e.text=="function"?e.text():new Promise((t,n)=>{const r=new FileReader;r.onload=()=>t(String(r.result??"")),r.onerror=()=>n(r.error??new Error("Failed to read file")),r.readAsText(e)})}function p1(e){const t=e.name.toLowerCase();return e.type==="text/html"||t.endsWith(".html")||t.endsWith(".htm")}function va(e){var r;if(!e)return!1;if(Array.from(e.types??[]).includes("Files")||e.files&&e.files.length>0)return!0;const n=e.items;if(n){for(let o=0;o<n.length;o++)if(((r=n[o])==null?void 0:r.kind)==="file")return!0}return!1}function g1(e){var r;const t=[],n=e.files;if(n)for(let o=0;o<n.length;o++){const a=((r=n.item)==null?void 0:r.call(n,o))??n[o];a&&t.push(a)}if(t.length===0&&e.items)for(let o=0;o<e.items.length;o++){const a=e.items[o];if((a==null?void 0:a.kind)!=="file")continue;const s=a.getAsFile();s&&t.push(s)}return t}function h1(e){return e?g1(e).find(p1)??null:null}const fg={description:"HTML",accept:{"text/html":[".html",".htm"]}},b1="document.html";function pg(){return window}function gg(e){return e instanceof DOMException&&e.name==="AbortError"}function y1(e,t){const n=new Blob([e],{type:"text/html;charset=utf-8"}),r=URL.createObjectURL(n),o=document.createElement("a");o.href=r,o.download=t,o.rel="noopener",document.body.append(o),o.click(),o.remove(),URL.revokeObjectURL(r)}function x1(){return new Promise(e=>{const t=document.createElement("input");t.type="file",t.accept=".html,.htm,text/html",t.hidden=!0;const n=r=>{t.remove(),e(r)};t.addEventListener("change",()=>{var o;const r=(o=t.files)==null?void 0:o[0];if(!r){n(null);return}wu(r).then(a=>n(dg(a)),()=>n(null))}),t.addEventListener("cancel",()=>n(null)),document.body.append(t),t.click()})}async function C1(e,t=b1){const n=pg().showSaveFilePicker;if(typeof n=="function"){try{const o=await(await n({suggestedName:t,types:[fg]})).createWritable();await o.write(e),await o.close()}catch(r){if(gg(r))return;throw r}return}y1(e,t)}async function w1(){const e=pg().showOpenFilePicker;if(typeof e=="function")try{const[t]=await e({multiple:!1,types:[fg]}),n=await t.getFile();return dg(await wu(n))}catch(t){if(gg(t))return null;throw t}return x1()}const v1=1e3;function k1(e){var t;return e.complete&&e.naturalWidth>0?Promise.resolve((t=e.decode)==null?void 0:t.call(e)).catch(()=>{}):new Promise(n=>{const r=()=>{var o;Promise.resolve((o=e.decode)==null?void 0:o.call(e)).catch(()=>{}).then(()=>n())};e.addEventListener("load",r,{once:!0}),e.addEventListener("error",r,{once:!0})})}function S1(e){const t=[...e.images];return t.length===0?Promise.resolve():Promise.all(t.map(k1)).then(()=>{})}function hg(){const e=document.createElement("iframe");e.setAttribute("aria-hidden","true"),e.setAttribute("data-wysiwyg-print",""),e.style.position="fixed",e.style.left="-9999px",e.style.top="0",e.style.width="1px",e.style.height="1px",e.style.border="0",document.body.append(e);const t=e.contentDocument,n=e.contentWindow;return!t||!n?(e.remove(),null):{iframe:e,doc:t,win:n}}async function bg(e,t,n,r){xc(e,r);let o=!1;const a=()=>{o||(o=!0,n.remove())};t.addEventListener("afterprint",a),await S1(e),t.focus(),t.print(),window.setTimeout(a,v1)}function A1(e){const t=hg();t&&bg(t.doc,t.win,t.iframe,e)}function P1(e){const t=hg();if(!t)return;const n=e.map(Cu),r=n.some(g=>g.hasBleed),o=[],a=[];for(const g of n){const h=ge(g.html);o.push(...h.hrefs),a.push(h.body)}const s=a.map((g,h)=>`<div data-wysiwyg-print-page="" style="${h===a.length-1?"display: block; break-inside: avoid; page-break-inside: avoid;":"display: block; break-after: page; page-break-after: always; break-inside: avoid; page-break-inside: avoid;"}">${g}</div>`).join(""),u=Fp(e),d=r?"@page { margin: 0 !important; }":"",f=[u?`<style>${u}</style>`:"",d?`<style>${d}</style>`:"",...Array.from(new Set(o)).map(g=>`<link rel="stylesheet" href="${g}" />`),s].filter(Boolean).join("");bg(t.doc,t.win,t.iframe,f)}function T1(e){return{save:async()=>{if(e.onSave){const t=e.isMultiPagesEnabled()?e.getAllPagesHtml():e.getHtml();await e.onSave(t);return}await C1(f1(e.getHtml()))},open:async()=>{const t=e.onOpen?await e.onOpen():await w1();if(t!==null){if(Array.isArray(t)){e.setHtml(_t(t));return}if(e.isMultiPagesEnabled()){e.setHtml(_t([t]));return}e.setHtml(t)}},print:()=>{if(e.isMultiPagesEnabled()){P1(On(e.getHtml()));return}A1(e.getHtml())}}}function R1(e){return{toggleBold:()=>{e.toggleFontMark("bold")},toggleItalic:()=>{e.toggleFontMark("italic")},toggleUnderline:()=>{e.toggleFontMark("underline")},toggleStrikethrough:()=>{e.toggleFontMark("strikethrough")},clearFormatting:()=>{e.clearFormatting()},toggleFormatBrush:()=>{e.toggleFormatBrush()},setFontSize:(t,n)=>{e.setFontSize(t,n)},setFontSizeUnit:t=>{e.setFontSizeUnit(t)},setFontFamily:t=>{e.setFontFamily(t)},setFontColor:t=>{e.setFontColor(t)},setHighlightColor:t=>{e.setHighlightColor(t)},setParagraphStyle:t=>{e.setParagraphStyle(t)},alignLeft:()=>{e.setTextAlign("left")},alignCenter:()=>{e.setTextAlign("center")},alignRight:()=>{e.setTextAlign("right")},alignJustify:()=>{e.setTextAlign("justify")},indent:()=>{e.indent()},outdent:()=>{e.outdent()},toggleBulletList:()=>{e.toggleList("ul")},toggleNumberedList:()=>{e.toggleList("ol")},openFontProperties:t=>{e.openFontProperties(t??"general")},applyFontProperties:t=>{e.applyFontProperties(t)},openParagraphProperties:t=>{e.openParagraphProperties(t??"general")},applyParagraphProperties:t=>{e.applyParagraphProperties(t)},openPageProperties:t=>{e.openPageProperties(t??"font")},applyPageProperties:t=>{e.applyPageProperties(t)},openCustomParagraphStyleDialog:t=>{e.openCustomParagraphStyleDialog(t)},applyCustomParagraphStyle:t=>{e.applyCustomParagraphStyle(t)},openCustomCss:()=>{e.openCustomCss()},applyCustomCss:t=>{e.applyCustomCss(t)}}}function D1(e){return{isBold:()=>e.isFontMarkActive("bold"),isItalic:()=>e.isFontMarkActive("italic"),isUnderline:()=>e.isFontMarkActive("underline"),isStrikethrough:()=>e.isFontMarkActive("strikethrough"),getFontSize:()=>e.getFontSize(),getFontSizeUnit:()=>e.getFontSizeUnit(),isFontSizeMixed:()=>e.isFontSizeMixed(),getFontFamily:()=>e.getFontFamily(),isFontFamilyMixed:()=>e.isFontFamilyMixed(),getFontFaces:()=>e.getFontFaces(),getFontColor:()=>e.getFontColor(),isFontColorMixed:()=>e.isFontColorMixed(),getHighlightColor:()=>e.getHighlightColor(),isHighlightColorMixed:()=>e.isHighlightColorMixed(),getParagraphStyle:()=>e.getParagraphStyle(),isParagraphStyleMixed:()=>e.isParagraphStyleMixed(),isAlignLeft:()=>e.getTextAlign()==="left"&&!e.isTextAlignMixed(),isAlignCenter:()=>e.getTextAlign()==="center"&&!e.isTextAlignMixed(),isAlignRight:()=>e.getTextAlign()==="right"&&!e.isTextAlignMixed(),isAlignJustify:()=>e.getTextAlign()==="justify"&&!e.isTextAlignMixed(),canOutdent:()=>e.canOutdent(),isBulletList:()=>e.isBulletList(),isNumberedList:()=>e.isNumberedList(),hasTextSelection:()=>e.hasTextSelection(),isFormatBrushActive:()=>e.isFormatBrushActive(),customParagraphStylesEnabled:()=>e.customParagraphStylesEnabled(),getCustomParagraphStyles:()=>e.getCustomParagraphStyles(),isCustomParagraphStylesLoading:()=>e.isCustomParagraphStylesLoading()}}function j1(e){return{undo:()=>{e.undo()},redo:()=>{e.redo()}}}function I1(e){return{canUndo:()=>e.canUndo(),canRedo:()=>e.canRedo()}}function E1(e){return{openLinkDialog:t=>{e.openLinkDialog(t)},applyLink:t=>{e.applyLink(t)},openBookmarkDialog:()=>{e.openBookmarkDialog()},applyBookmark:t=>{e.applyBookmark(t)},openImageDialog:()=>{e.openImageDialog()},openPageBackgroundImage:()=>{e.openPageBackgroundImage()},openParagraphBackgroundImage:()=>{e.openParagraphBackgroundImage()},applyImage:t=>{e.applyImage(t)},openAudioDialog:()=>{e.openAudioDialog()},applyAudio:t=>{e.applyAudio(t)},openYoutubeDialog:()=>{e.openYoutubeDialog()},applyYoutube:t=>{e.applyYoutube(t)},openImageProperties:t=>{e.openImageProperties(t)},applyImageProperties:t=>{e.applyImageProperties(t)},insertHorizontalRule:()=>{e.insertHorizontalRule()},insertPageBreak:()=>{e.insertPageBreak()},insertPageBefore:()=>{e.insertPageBefore()},insertPageAfter:()=>{e.insertPageAfter()},deletePage:()=>{e.deletePage()}}}function _1(e){return{isLink:()=>e.isLink(),isImageSelected:()=>e.isImageSelected(),isMultiPagesEnabled:()=>e.isMultiPagesEnabled(),hasSelectedPage:()=>e.hasSelectedPage(),canDeletePage:()=>e.canDeletePage(),canInsertPageBackgroundImage:()=>e.canInsertPageBackgroundImage(),canInsertParagraphBackgroundImage:()=>e.canInsertParagraphBackgroundImage()}}function M1(e){return{openTableDialog:()=>{e.openTableDialog()},applyTable:t=>{e.applyTable(t)},openTableProperties:()=>{e.openTableProperties()},applyTableProperties:t=>{e.applyTableProperties(t)},openCellProperties:()=>{e.openCellProperties()},applyCellProperties:t=>{e.applyCellProperties(t)},openRowProperties:()=>{e.openRowProperties()},applyRowProperties:t=>{e.applyRowProperties(t)},insertRowBelow:()=>{e.insertRowBelow()},insertRowBefore:()=>{e.insertRowBefore()},deleteRow:()=>{e.deleteRow()},insertColumnAfter:()=>{e.insertColumnAfter()},insertColumnBefore:()=>{e.insertColumnBefore()},deleteColumn:()=>{e.deleteColumn()},mergeCells:()=>{e.mergeCells()},unmergeCells:()=>{e.unmergeCells()}}}function N1(e){return{isInTable:()=>e.isInTable(),canMergeCells:()=>e.canMergeCells(),canUnmergeCells:()=>e.canUnmergeCells()}}function L1(e){return{openHelp:()=>{e.openHelp()},openKeyboardShortcuts:()=>{e.openKeyboardShortcuts()},openAbout:()=>{e.openAbout()}}}const B1=[50,75,100,125,150,200],F1=.1,H1=3;function Wl(e){return!Number.isFinite(e)||e<=0?1:Math.min(H1,Math.max(F1,e))}function z1(e,t,n,r,o){if(e==="fitWidth")return r<=0?1:Wl(t/r);if(e==="fitPage"){if(r<=0||o<=0)return 1;const a=t/r,s=n/o;return Wl(Math.min(a,s))}return Wl(e/100)}function O1(e){let t=null;return{schedule(){t===null&&(t=window.requestAnimationFrame(()=>{t=null,e()}))},cancel(){t!==null&&(window.cancelAnimationFrame(t),t=null)}}}function Mn(e,t){return()=>{e.setPageZoom(t)}}function Nn(e,t){return()=>e.getPageZoom()===t}function K1(e){return{setVisualMode:()=>{e.setMode("visual")},setHtmlMode:()=>{e.setMode("html")},toggleFullscreen:()=>{e.setFullscreen(!e.getFullscreen())},openCustomizeToolbar:()=>{e.openCustomizeToolbar()},openDocumentPreview:()=>{e.openDocumentPreview()},toggleReadAloud:()=>{e.toggleReadAloud()},toggleRuler:()=>{e.toggleRuler()},setLightMode:()=>{e.setDarkMode(!1)},setDarkMode:()=>{e.setDarkMode(!0)},setPageZoomFitWidth:Mn(e,"fitWidth"),setPageZoomFitPage:Mn(e,"fitPage"),setPageZoom50:Mn(e,50),setPageZoom75:Mn(e,75),setPageZoom100:Mn(e,100),setPageZoom125:Mn(e,125),setPageZoom150:Mn(e,150),setPageZoom200:Mn(e,200),setToolbarPositionTop:()=>{e.setToolbarPosition("top")},setToolbarPositionLeft:()=>{e.setToolbarPosition("left")},setToolbarPositionRight:()=>{e.setToolbarPosition("right")},setToolbarPositionBottom:()=>{e.setToolbarPosition("bottom")}}}function $1(e){return{isVisualMode:()=>e.getMode()==="visual",isHtmlMode:()=>e.getMode()==="html",isFullscreen:()=>e.getFullscreen(),isLightMode:()=>!e.getDarkMode(),isDarkMode:()=>e.getDarkMode(),isPageZoomFitWidth:Nn(e,"fitWidth"),isPageZoomFitPage:Nn(e,"fitPage"),isPageZoom50:Nn(e,50),isPageZoom75:Nn(e,75),isPageZoom100:Nn(e,100),isPageZoom125:Nn(e,125),isPageZoom150:Nn(e,150),isPageZoom200:Nn(e,200),isToolbarPositionTop:()=>e.getToolbarPosition()==="top",isToolbarPositionLeft:()=>e.getToolbarPosition()==="left",isToolbarPositionRight:()=>e.getToolbarPosition()==="right",isToolbarPositionBottom:()=>e.getToolbarPosition()==="bottom",isReadingAloud:()=>e.isReadingAloud(),isRulerVisible:()=>e.isRulerVisible(),canReadAloud:()=>e.canReadAloud()}}function U1(e){return{addComment:()=>e.addComment(),toggleCommentsVisible:()=>e.toggleCommentsVisible()}}function V1(e){return{canAddComment:()=>e.canAddComment(),areCommentsVisible:()=>e.areCommentsVisible(),isCommentsEnabled:()=>e.isCommentsEnabled()}}function W1(e){return{...T1(e),...j1(e),...Hy(e),...E1(e),...M1(e),...K1(e),...R1(e),...U1(e),...L1(e)}}function G1(e){return{...$1(e),...I1(e),..._1(e),...N1(e),...D1(e),...V1(e)}}function Wa(e){return e.nodeType===Node.TEXT_NODE?e.parentElement:e instanceof Element?e:e.parentElement}function Z1(e){const t=e.style.fontSize;if(!t)return null;const n=Xc(t);return!n||!us(n.unit)?null:{value:n.value,unit:n.unit}}function yg(e,t){let n=Wa(t);for(;n&&n!==e&&n instanceof HTMLElement;){const r=Z1(n);if(r)return r;n=n.parentElement}return null}function q1(e,t){const n=Wa(e)??t,r=parseFloat(getComputedStyle(n).fontSize);return Number.isFinite(r)&&r>0?r:16}function xg(e,t){var a;let n=Wa(t);for(;n&&n!==e;){if(n.style.fontSize){const u=n.parentElement??e,d=parseFloat(getComputedStyle(u).fontSize);return Number.isFinite(d)&&d>0?d:16}n=n.parentElement}const r=((a=Wa(t))==null?void 0:a.parentElement)??e,o=parseFloat(getComputedStyle(r).fontSize);return Number.isFinite(o)&&o>0?o:16}function Cg(e){const t=parseFloat(getComputedStyle(e).fontSize);return Number.isFinite(t)&&t>0?t:16}function Y1(e,t){return e===t?!0:!e||!t?!1:e.value===t.value&&e.unit===t.unit}function qm(e=Xr){return{value:null,unit:e,mixed:!1}}function wg(e,t=Xr){const n=window.getSelection();if(!n||n.rangeCount===0)return qm(t);const r=n.getRangeAt(0);if(!ke(e,r.commonAncestorContainer))return qm(t);const o=r.collapsed?[]:At(r).filter(f=>f.data.length>0),a=o.length>0?o:[r.startContainer],s=a.map(f=>yg(e,f)),u=s[0];if(s.every(f=>Y1(f,u))&&u)return{value:u.value,unit:u.unit,mixed:!1};if(s.every(f=>f===null)){const f=a.map(h=>q1(h,e)),g=f[0];if(f.every(h=>Math.abs(h-g)<.05)){const h=xg(e,a[0]),y=Cg(e);return{value:ip(g,t,h,y),unit:t,mixed:!1}}return{value:null,unit:t,mixed:!0}}return{value:null,unit:t,mixed:!0}}function X1(e,t){return{parentPx:xg(e,t),rootPx:Cg(e)}}function J1(e){const t=window.getSelection();if(!t||t.rangeCount===0)return null;const n=t.getRangeAt(0);return ke(e,n.commonAncestorContainer)?n:null}function Cc(e,t,n){const r=gr(t,n);if(!r)return!1;const o=J1(e);if(!o||o.collapsed)return!1;const a=Yc(r.value,r.unit);un(o);const s=At(o).filter(u=>u.data.length>0);for(const u of s){const d=yg(e,u);d&&d.value===r.value&&d.unit===r.unit||ai(u,f=>{f.style.fontSize=a})}return xr(s),!0}function Q1(e,t){e.style.fontSize=Yc(t.value,t.unit)}function ev(e){return e.nodeType===Node.TEXT_NODE?e.parentElement:e instanceof Element?e:e.parentElement}function tv(e){return e.trim().toLowerCase()}function wc(e){const t={};for(const n of e.split(";")){const r=n.trim();if(!r)continue;const o=r.indexOf(":");if(o<=0)continue;const a=tv(r.slice(0,o)),s=r.slice(o+1).trim();a&&(t[a]=s)}return t}function vg(e){return Object.entries(e).filter(([t])=>t.trim()).map(([t,n])=>`${t}: ${n}`).join("; ")}function nv(e,t){const n={...e};for(const[r,o]of Object.entries(t))o.trim()?n[r]=o:delete n[r];return n}function rv(e){const t=e.trim();if(!t)return"";const n=t.split(";").map(r=>r.trim()).filter(Boolean);return n.length===0?"":n.map(r=>`${r};`).join(`
318
+ `)}function bs(e){const t=wc(e);return vg(t)}function ov(e,t){let n=ev(t);for(;n&&n!==e&&n instanceof HTMLElement;){const r=n.style.cssText.trim();if(r)return r;n=n.parentElement}return""}function kg(e){const t=fn(e);if(!t)return{value:null,mixed:!1};const n=t.collapsed?[]:At(t).filter(d=>d.data.length>0),a=(n.length>0?n:[t.startContainer]).map(d=>ov(e,d)).map(d=>d.trim()),s=a[0]??"";return a.every(d=>d===s)?{value:s||null,mixed:!1}:{value:null,mixed:!0}}function Sg(e,t){const n=wc(e.style.cssText),r=wc(t),o=nv(n,r),a=vg(o);a?e.style.cssText=a:e.removeAttribute("style")}function Ag(e,t){const n=bs(t);if(!n)return!1;const r=fn(e);if(!r||r.collapsed)return!1;un(r);const o=At(r).filter(a=>a.data.length>0);if(o.length===0)return!1;for(const a of o)ai(a,s=>{Sg(s,n),Yn(s)&&Mt(s)});return xr(o),!0}function iv(e,t){const n=bs(t);n&&Sg(e,n)}function av(e){return!!(e&&bs(e))}const Kt=["bold","italic","underline","strikethrough"],Wr={bold:new Set(["strong","b"]),italic:new Set(["em","i"]),underline:new Set(["u"]),strikethrough:new Set(["s","strike","del"])},sv=new Set(["underline","line-through","overline"]);function $n(){return{bold:!1,italic:!1,underline:!1,strikethrough:!1}}function lv(e,t){return Kt.every(n=>e[n]===t[n])}function cv(e){return Kt.some(t=>e[t]!==void 0)}function Pg(e,t){const n={...e};if(!t)return n;for(const r of Kt){const o=t[r];o!==void 0&&(n[r]=o)}return n}function uv(e,t,n){const r=e[n]??t[n],o={...e,[n]:!r};return o[n]===t[n]&&delete o[n],o}function Gn(e){return(e.style.textDecorationLine||e.style.textDecoration).split(/\s+/).filter(n=>sv.has(n))}function oo(e,t){if(t.length===0){e.style.textDecorationLine="",e.style.removeProperty("text-decoration-line"),e.style.textDecoration&&(e.style.textDecoration="",e.style.removeProperty("text-decoration"));return}e.style.textDecorationLine=t.join(" ")}function Tg(e,t){const n=e,r=e.tagName.toLowerCase();if(t==="bold"){if(Wr.bold.has(r))return!0;const s=n.style.fontWeight;if(!s)return null;if(s==="bold"||s==="bolder")return!0;const u=Number(s);return Number.isNaN(u)?s==="normal"||s==="lighter"?!1:null:u>=700}if(t==="italic"){if(Wr.italic.has(r))return!0;const s=n.style.fontStyle;return s?s==="italic"||s==="oblique"?!0:s==="normal"?!1:null:null}if(t==="underline"){if(Wr.underline.has(r))return!0;const s=n.style.textDecorationLine||n.style.textDecoration;if(!s)return null;if(s==="none")return!1;const u=Gn(n);return u.includes("underline")?!0:u.length>0?!1:null}if(Wr.strikethrough.has(r))return!0;const o=n.style.textDecorationLine||n.style.textDecoration;if(!o)return null;if(o==="none")return!1;const a=Gn(n);return a.includes("line-through")?!0:a.length>0?!1:null}function Ga(e,t){return Tg(e,t)===!0}function io(e,t,n){let r=t.nodeType===Node.TEXT_NODE?t.parentElement:t;for(;r&&r!==e&&r instanceof Element;){const o=Tg(r,n);if(o!==null)return o;r=r.parentElement}return!1}function Rg(e,t){if(t==="bold"){e.style.fontWeight="700";return}if(t==="italic"){e.style.fontStyle="italic";return}if(t==="underline"){const r=Gn(e);r.includes("underline")||r.push("underline"),oo(e,r);return}const n=Gn(e);n.includes("line-through")||n.push("line-through"),oo(e,n)}function Dg(e,t){if(t==="bold"){e.style.fontWeight="",e.style.removeProperty("font-weight");return}if(t==="italic"){e.style.fontStyle="",e.style.removeProperty("font-style");return}if(t==="underline"){oo(e,Gn(e).filter(n=>n!=="underline"));return}oo(e,Gn(e).filter(n=>n!=="line-through"))}function dv(e,t){if(t==="bold"){e.style.fontWeight="400";return}if(t==="italic"){e.style.fontStyle="normal";return}if(t==="underline"){const r=Gn(e).filter(o=>o!=="underline");if(r.length===0){e.style.textDecorationLine="none";return}oo(e,r);return}const n=Gn(e).filter(r=>r!=="line-through");if(n.length===0){e.style.textDecorationLine="none";return}oo(e,n)}function mv(e,t){ai(e,n=>Rg(n,t))}function fv(e,t,n){let r=t;for(;r.parentElement&&r.parentElement!==e;){const o=r.parentElement;if(!mn(o)||!Ga(o,n)){r=o;continue}if(Xn(o,r),Ga(o,n)){if(Wr[n].has(o.tagName.toLowerCase())){Mt(o);continue}if(Dg(o,n),Yn(o)){Mt(o);continue}}r=o}}function pv(e,t,n){const r=At(t).filter(o=>o.data.length>0);return r.length===0?io(e,t.startContainer,n):r.every(o=>io(e,o,n))}function gv(e,t,n,r){un(t);const o=At(t).filter(a=>a.data.length>0);for(const a of o)r?io(e,a,n)||mv(a,n):fv(e,a,n);xr(o)}function Gr(e){const t=window.getSelection();if(!t||t.rangeCount===0)return $n();const n=t.getRangeAt(0);if(!ke(e,n.commonAncestorContainer))return $n();if(n.collapsed)return vc(e,n);const r=At(n).filter(a=>a.data.length>0);if(r.length===0)return vc(e,n);const o=$n();for(const a of Kt)o[a]=io(e,r[0],a);for(let a=1;a<r.length;a+=1)for(const s of Kt)o[s]=o[s]&&io(e,r[a],s);return o}function vc(e,t){const n=$n();for(const r of Kt)n[r]=io(e,t.startContainer,r);return n}function kc(e,t){const n=window.getSelection();if(!n||n.rangeCount===0)return!1;const r=n.getRangeAt(0);if(!ke(e,r.commonAncestorContainer)||r.collapsed)return!1;const o=pv(e,r,t);return gv(e,r,t,!o),!0}function hv(e){const t=e.startContainer,n=e.startOffset;if(t.nodeType!==Node.TEXT_NODE)return;const r=t;if(n<=0||n>=r.length)return;const o=r.splitText(n);e.setStart(o,0),e.collapse(!0)}function bv(e,t,n){var a,s,u;hv(t);let r=t.startContainer.nodeType===Node.TEXT_NODE&&t.startOffset===0?t.startContainer:t.startContainer.childNodes[t.startOffset]??t.startContainer.lastChild??t.startContainer;if(t.startContainer.nodeType===Node.TEXT_NODE&&t.startOffset>0){const d=document.createTextNode("");(a=t.startContainer.parentNode)==null||a.insertBefore(d,t.startContainer.nextSibling),r=d}else if(t.startContainer.nodeType===Node.TEXT_NODE&&t.startOffset===0){const d=document.createTextNode("");(s=t.startContainer.parentNode)==null||s.insertBefore(d,t.startContainer),r=d}else{const d=document.createTextNode("");r&&r!==t.startContainer?(u=r.parentNode)==null||u.insertBefore(d,r):t.startContainer.appendChild(d),r=d}let o=r;for(;o.parentElement&&o.parentElement!==e;){const d=o.parentElement;if(!mn(d)){o=d;continue}if(!n.some(g=>Ga(d,g))){o=d;continue}Xn(d,o);for(const g of n)if(Ga(d,g)){if(Wr[g].has(d.tagName.toLowerCase())){Mt(d);break}if(Dg(d,g),Yn(d)){Mt(d);break}}o=d.isConnected?d:r}return r}function yv(e,t,n){for(const r of Kt)n[r]!==t[r]&&(n[r]?Rg(e,r):dv(e,r))}function xv(e,t,n,r,o,a,s){var S,P;const u=window.getSelection();if(!u||u.rangeCount===0)return;const d=u.getRangeAt(0);if(!ke(e,d.commonAncestorContainer))return;const f=vc(e,d),g=Pg(f,n),h=Kt.filter(T=>f[T]&&!g[T]),y=Gx(e,d.startContainer,o),b=Cx(e,d.startContainer,a);let C=null;h.length>0?(C=bv(e,d,h),y.length>0&&fp(e,C,y),b&&lc(e,C)):y.length>0?(C=Wx(e,d,y),b&&lc(e,C)):b?C=xx(e,d):d.deleteContents();const x=document.createElement("span");yv(x,f,g),r&&Q1(x,r),o!=null&&o.color&&Rm(x,"color",o.color),o!=null&&o.backgroundColor&&Rm(x,"backgroundColor",o.backgroundColor),a&&gx(x,a),s&&iv(x,s),x.textContent=t;const v=x.style.cssText.trim()?x:document.createTextNode(t);C?((S=C.parentNode)==null||S.insertBefore(v,C),C.nodeType===Node.TEXT_NODE&&!C.data&&((P=C.parentNode)==null||P.removeChild(C))):d.insertNode(v);const k=document.createRange();k.selectNodeContents(v),k.collapse(!1),u.removeAllRanges(),u.addRange(k)}const Za=["p","h1","h2","h3","h4","h5","h6"],Cv=new Set(Za),jg=new Set([...Za,"div"]),ys=new Set(["li","ul","ol","td","th","tr","thead","tbody","table","blockquote","pre"]),wv=()=>({tag:null,mixed:!1});function Ig(e){return Cv.has(e)}function vv(e){return Ig(e)?e:e==="div"?"p":null}function kv(e){return e instanceof Element&&ys.has(Me(e))}function Eg(e){return e instanceof HTMLElement&&!Pt(e)&&jg.has(Me(e))}function Sc(e){if(e.nodeType===Node.TEXT_NODE||e.nodeType===Node.COMMENT_NODE||!(e instanceof Element))return!0;const t=Me(e);return jg.has(t)||ys.has(t)?!1:mn(e)||t==="br"||t==="a"||t==="img"||t==="span"}function Sv(e,t){let n=li(t);for(;n&&n!==e;){if(ys.has(Me(n)))return!0;n=n.parentElement}return!1}function _g(e,t){let n=li(t);for(;n&&n!==e;){if(Gp(n,e)){n=n.parentElement;continue}if(Eg(n))return n;if(ys.has(Me(n)))return null;n=n.parentElement}return null}function Av(e,t){const n=new Set,r=[];for(const o of ru(t)){const a=_g(e,o);a&&!n.has(a)&&(n.add(a),r.push(a))}return r}function Pv(e,t){let n=t;for(;n&&n.parentNode!==e;)n=n.parentNode;return n&&n.parentNode===e?n:null}function Tv(e,t){const n=[...e.childNodes],r=n.indexOf(t);if(r<0)return[t];let o=r,a=r;for(;o>0&&Sc(n[o-1]);)o-=1;for(;a<n.length-1&&Sc(n[a+1]);)a+=1;return n.slice(o,a+1)}function Ac(e){for(const t of e.childNodes)if(!(t instanceof HTMLElement&&Pt(t)))return t;return null}function Rv(e,t,n){if(n.startContainer===e){const r=e.childNodes[Math.min(n.startOffset,Math.max(0,e.childNodes.length-1))]??e.firstChild;return r instanceof HTMLElement&&Pt(r)?Ac(e):r}return n.startContainer===t&&e!==t?Ac(e):Pv(e,n.startContainer)}function Dv(e,t,n){const r=gu(e);if(Sv(e,t.startContainer))return!1;if(!Ac(r)){const u=document.createElement(n);return u.appendChild(document.createElement("br")),r.appendChild(u),!0}const o=Rv(r,e,t);if(!o||o instanceof HTMLElement&&Pt(o)||kv(o)||Eg(o)||!Sc(o))return!1;const a=Tv(r,o),s=document.createElement(n);r.insertBefore(s,a[0]);for(const u of a)s.appendChild(u);return!0}function jv(e){const t=fn(e);if(!t)return wv();const n=ru(t).map(o=>{const a=_g(e,o);return a?vv(Me(a)):null}),r=n[0];return n.every(o=>o===r)?{tag:r??null,mixed:!1}:{tag:null,mixed:!0}}function Iv(e,t){if(!Ig(t))return!1;const n=fn(e);if(!n)return!1;const r=Jr(e,n.startContainer,n.startOffset),o=Jr(e,n.endContainer,n.endOffset),a=Math.min(r,o),s=Math.max(r,o),u=Av(e,n);let d=!1;if(u.length===0)d=Dv(e,n,t);else for(const f of u)Me(f)!==t&&(iu(f,t),d=!0);return ou(e,a,s),d}function vu(e){if(!Ot(e))return null;const t=Qr(e);if(!t)return null;const n=Me(t);return n==="ul"||n==="ol"?n:null}function Mg(e){const t=An(e);if(t.length===0)return{type:null,mixed:!1};const n=t.map(vu),r=n[0];return n.every(o=>o===r)?{type:r,mixed:!1}:{type:null,mixed:!0}}function Ev(e,t,n){const r=[...e.children].filter(o=>nu(o));for(const o of r)t.insertBefore(o,n)}function Ng(e){const t=Qr(e),n=document.createElement("p");for(const f of[...e.attributes])n.setAttribute(f.name,f.value);for(n.style.marginLeft="",vt(n);e.firstChild&&!nu(e.firstChild);)n.appendChild(e.firstChild);const r=[];let o=e.nextElementSibling;for(;o;)r.push(o),o=o.nextElementSibling;const a=(t==null?void 0:t.parentNode)??e.parentNode;if(!t||!a)return e.replaceWith(n),n;const s=Ot(a)?a.parentNode??a:a,u=Ot(a)?a.nextSibling:t.nextSibling;e.remove();let d=null;if(r.length>0){d=document.createElement(t.tagName);for(const f of r)d.appendChild(f)}return s.insertBefore(n,u),d&&s.insertBefore(d,n.nextSibling),Ev(e,s,n.nextSibling),t.childElementCount===0&&t.remove(),n}function _v(e){if(Ot(e))return e;const t=iu(e,"li");return t.style.marginLeft="",vt(t),t}function Lg(e,t){if(e.length===0)return!1;if(e.every(Ot)){const a=Qr(e[0]);if(a&&e.every(s=>s.parentElement===a)&&[...a.children].every(u=>u instanceof HTMLElement&&e.includes(u)))return Me(a)===t?!1:(iu(a,t),!0)}const n=e[0],r=n.parentNode;if(!r)return!1;const o=document.createElement(t);r.insertBefore(o,n);for(const a of e){const s=Ot(a)?Qr(a):null;o.appendChild(_v(a)),s&&s!==o&&s.childElementCount===0&&s.remove()}return!0}function Bg(e){let t=!1;for(const n of[...e].reverse())Ot(n)&&(Ng(n),t=!0);return t}function Mv(e,t){return Qn(e,()=>{const n=Cr(e);if(n.length===0)return!1;if(n.every(a=>vu(a)===t))return Bg(n);let o=!1;for(const a of cp(n))Lg(a,t)&&(o=!0);return o})}function Nv(e,t){return Qn(e,()=>{const n=Cr(e);if(n.length===0)return!1;if(t===null)return Bg(n);if(n.every(a=>vu(a)===t))return!1;let o=!1;for(const a of cp(n))Lg(a,t)&&(o=!0);return o})}const Fg=40;function ku(e){const t=e.style.marginLeft;if(!t)return 0;const n=Number.parseFloat(t);return Number.isFinite(n)?n:0}function Hg(e,t){if(t<=0){e.style.marginLeft="",vt(e);return}e.style.marginLeft=`${t}px`}function Lv(e){let t=e.previousElementSibling;for(;t;){if(Ot(t))return t;t=t.previousElementSibling}return null}function Bv(e){for(let t=e.children.length-1;t>=0;t-=1){const n=e.children[t];if(n instanceof HTMLElement&&(Me(n)==="ul"||Me(n)==="ol"))return n}return null}function Fv(e){const t=Lv(e);if(!t)return!1;const n=Qr(e);if(!n)return!1;const r=Me(n)==="ol"?"ol":"ul";let o=Bv(t);return(!o||Me(o)!==r)&&(o=document.createElement(r),t.appendChild(o)),o.appendChild(e),!0}function Hv(e){const t=Qr(e);if(!t)return!1;const n=t.parentElement;if(n&&Ot(n)){const r=n.parentElement;return r?(r.insertBefore(e,n.nextSibling),t.childElementCount===0&&t.remove(),!0):!1}return Ng(e),!0}function zv(e){return An(e).some(n=>Ot(n)||ku(n)>0)}function Ov(e){return Qn(e,()=>{const t=Cr(e);if(t.length===0)return!1;let n=!1;for(const r of t){if(Ot(r)){Fv(r)&&(n=!0);continue}Hg(r,ku(r)+Fg),n=!0}return n})}function Kv(e){return Qn(e,()=>{const t=An(e);if(t.length===0)return!1;let n=!1;for(const r of[...t].reverse()){if(Ot(r)){Hv(r)&&(n=!0);continue}const o=ku(r);o<=0||(Hg(r,Math.max(0,o-Fg)),n=!0)}return n})}function xs(e){return{colSpan:Math.max(1,e.colSpan||1),rowSpan:Math.max(1,e.rowSpan||1)}}function yr(e,t,n){const r=Math.max(1,Math.floor(t)),o=Math.max(1,Math.floor(n));r<=1?e.removeAttribute("colspan"):e.colSpan=r,o<=1?e.removeAttribute("rowspan"):e.rowSpan=o}function Nt(e){const t=e.rows.length,n=Array.from({length:t},()=>[]),r=[];let o=0;for(let a=0;a<t;a+=1){const s=e.rows[a];let u=0;for(const d of Array.from(s.cells)){for(;n[a][u];)u+=1;const f=xs(d),g={cell:d,originRow:a,originCol:u,rowSpan:f.rowSpan,colSpan:f.colSpan};r.push(g);for(let h=0;h<f.rowSpan;h+=1){const y=a+h;if(y>=t)break;for(let b=0;b<f.colSpan;b+=1)n[y][u+b]=g}u+=f.colSpan,o=Math.max(o,u)}o=Math.max(o,n[a].length)}return{table:e,slots:n,unique:r,rowCount:t,colCount:o}}function qa(e,t,n){var r;return((r=e.slots[t])==null?void 0:r[n])??null}function Xt(e,t){return e.unique.find(n=>n.cell===t)??null}function zg(e,t){return e.originRow<t.minRow||e.originCol<t.minCol||e.originRow+e.rowSpan-1>t.maxRow||e.originCol+e.colSpan-1>t.maxCol}function Og(e){if(e.length===0)return null;let t=1/0,n=-1/0,r=1/0,o=-1/0;for(const a of e)t=Math.min(t,a.originRow),n=Math.max(n,a.originRow+a.rowSpan-1),r=Math.min(r,a.originCol),o=Math.max(o,a.originCol+a.colSpan-1);return{minRow:t,maxRow:n,minCol:r,maxCol:o}}function $v(e,t){const n=new Set,r=[];for(let o=t.minRow;o<=t.maxRow;o+=1)for(let a=t.minCol;a<=t.maxCol;a+=1){const s=qa(e,o,a);!s||n.has(s.cell)||(n.add(s.cell),r.push(s.cell))}return r}function Kg(e,t){if(t.minRow>t.maxRow||t.minCol>t.maxCol)return null;const n=qa(e,t.minRow,t.minCol);if(!n||n.originRow!==t.minRow||n.originCol!==t.minCol)return null;const r=new Set,o=[];for(let a=t.minRow;a<=t.maxRow;a+=1)for(let s=t.minCol;s<=t.maxCol;s+=1){const u=qa(e,a,s);if(!u||zg(u,t))return null;r.has(u.cell)||(r.add(u.cell),o.push(u.cell))}return{origin:n,cells:o,colSpan:t.maxCol-t.minCol+1,rowSpan:t.maxRow-t.minRow+1}}function Uv(e,t,n,r){const o={minRow:t.originRow,maxRow:t.originRow+r-1,minCol:t.originCol,maxCol:t.originCol+n-1};if(o.maxRow>=e.rowCount||o.maxCol>=e.colCount)return!1;for(let a=o.minRow;a<=o.maxRow;a+=1)for(let s=o.minCol;s<=o.maxCol;s+=1){const u=qa(e,a,s);if(!u)return!1;if(u.cell!==t.cell&&zg(u,o))return!1}return!0}const Ym=10,Zr=1,qr=50,Vv="1px solid #000",Wv="0.25em",Gv=new Set(["td","th"]);function $g(e,t){return Number.isInteger(e)&&Number.isInteger(t)&&e>=Zr&&t>=Zr&&e<=qr&&t<=qr}function St(e,t){return Au(e,t,n=>n instanceof HTMLTableElement)}function Ya(e,t){return Au(e,t,n=>ok(n))}function Zv(e,t){return Au(e,t,n=>n instanceof HTMLTableRowElement)}function Su(e){return St(e,Pu(e))}function pn(e){return Ya(e,Pu(e))}function Ug(e){return Zv(e,Pu(e))}function qv(e){const t=[];for(const n of Array.from(e.rows))t.push(...Array.from(n.cells));return t}function ui(e){const t=window.getSelection();if(!t||t.rangeCount===0)return[];const n=t.getRangeAt(0);if(!ke(e,n.commonAncestorContainer))return[];const r=Ya(e,n.startContainer),o=Ya(e,n.endContainer);if(!r)return[];if(!o||r===o)return[r];const a=St(e,r);if(!a||St(e,o)!==a)return[r];const s=Nt(a),u=Xt(s,r),d=Xt(s,o);if(!u||!d)return[r];const f=Og([u,d]);if(!f)return[r];const g=$v(s,f);return g.length>0?g:[r]}function Yv(e,t){if(!$g(t.rows,t.cols))return!1;const n=window.getSelection();if(!n||n.rangeCount===0)return!1;const r=n.getRangeAt(0);if(!ke(e,r.commonAncestorContainer))return!1;const o=document.createElement("table");o.style.borderCollapse="collapse",o.style.width="100%";const a=document.createElement("tbody");for(let u=0;u<t.rows;u+=1){const d=document.createElement("tr");for(let f=0;f<t.cols;f+=1)d.appendChild(ik("td"));a.appendChild(d)}o.appendChild(a),r.collapsed||r.deleteContents(),r.insertNode(o),ck(e,o);const s=o.querySelector("td, th");return s instanceof HTMLTableCellElement&&kt(s),!0}function Pc(e,t){var h,y,b,C;const n=pn(e);if(!n)return!1;const r=St(e,n);if(!r)return!1;const o=Nt(r),a=Xt(o,n);if(!a)return!1;const s=t==="before"?a.originRow:a.originRow+a.rowSpan,u=new Set;for(const x of o.unique)if(x.originRow<s&&x.originRow+x.rowSpan>s){yr(x.cell,x.colSpan,x.rowSpan+1);for(let v=x.originCol;v<x.originCol+x.colSpan;v+=1)u.add(v)}const d=document.createElement("tr"),f=Math.min(s,o.rowCount-1);for(let x=0;x<o.colCount;x+=1){if(u.has(x))continue;const v=((y=(h=o.slots[f])==null?void 0:h[x])==null?void 0:y.cell)??n;d.appendChild(Tu(v))}if(s>=r.rows.length)(b=r.rows[r.rows.length-1].parentNode)==null||b.appendChild(d);else{const x=r.rows[s];(C=x.parentNode)==null||C.insertBefore(d,x)}const g=sk(d,o.colCount,u,a.originCol);return kt(g||n),!0}function Xm(e,t){var f,g,h,y;const n=pn(e);if(!n)return!1;const r=St(e,n);if(!r)return!1;const o=Nt(r),a=Xt(o,n);if(!a)return!1;const s=t==="before"?a.originCol:a.originCol+a.colSpan,u=new Set;for(const b of o.unique)if(b.originCol<s&&b.originCol+b.colSpan>s){yr(b.cell,b.colSpan+1,b.rowSpan);for(let C=b.originRow;C<b.originRow+b.rowSpan;C+=1)u.add(C)}let d=null;for(let b=0;b<o.rowCount;b+=1){if(u.has(b))continue;const C=((g=(f=o.slots[b])==null?void 0:f[Math.min(s,Math.max(0,o.colCount-1))])==null?void 0:g.cell)??((y=(h=o.slots[b])==null?void 0:h[Math.max(0,s-1)])==null?void 0:y.cell)??n,x=Tu(C);Ru(r,b,s,x),b===a.originRow&&(d=x)}return d&&kt(d),!0}function Xv(e){var y,b;const t=pn(e);if(!t)return!1;const n=St(e,t);if(!n)return!1;const r=Nt(n),o=Xt(r,t);if(!o)return!1;if(r.rowCount<=1)return Tc(e,n);const a=o.originRow,s=a+1,u=[];for(const C of r.unique)C.originRow<=a&&C.originRow+C.rowSpan>a&&(C.originRow<a?yr(C.cell,C.colSpan,C.rowSpan-1):C.originRow===a&&C.rowSpan>1&&u.push(C));u.sort((C,x)=>C.originCol-x.originCol);for(const C of u)yr(C.cell,C.colSpan,C.rowSpan-1),Ru(n,s,C.originCol,C.cell);const d=o.originCol;n.rows[a].remove();const f=n.rows[Math.min(a,n.rows.length-1)],g=Nt(n),h=(b=(y=g.slots[Math.min(a,g.rowCount-1)])==null?void 0:y[Math.min(d,Math.max(0,g.colCount-1))])==null?void 0:b.cell;return h?kt(h):f!=null&&f.cells[0]?kt(f.cells[0]):dk(n),!0}function Jv(e){var f,g,h;const t=pn(e);if(!t)return!1;const n=St(e,t);if(!n)return!1;const r=Nt(n),o=Xt(r,t);if(!o)return!1;if(r.colCount<=1)return Tc(e,n);const a=o.originCol,s=o.originRow;for(const y of r.unique)a<y.originCol||a>=y.originCol+y.colSpan||(y.colSpan===1?y.cell.remove():yr(y.cell,y.colSpan-1,y.rowSpan));const u=Nt(n);if(u.colCount===0||u.unique.length===0)return Tc(e,n);const d=((g=(f=u.slots[Math.min(s,u.rowCount-1)])==null?void 0:f[Math.min(a,u.colCount-1)])==null?void 0:g.cell)??((h=u.unique[0])==null?void 0:h.cell);return d&&kt(d),!0}function Qv(e,t){const n=pn(e);if(!n)return!1;const r=St(e,n);if(!r)return!1;const o=qv(r),a=o.indexOf(n);if(a<0)return!1;if(t)return a===0?!1:(kt(o[a-1]),{changed:!1});if(a<o.length-1)return kt(o[a+1]),{changed:!1};const s=n.parentElement;if(!Pc(e,"below"))return!1;const u=s instanceof HTMLTableRowElement?s.nextElementSibling:null;return u instanceof HTMLTableRowElement&&u.cells[0]&&kt(u.cells[0]),{changed:!0}}function ek(e,t){return!ke(e,t)||t===e?!1:(kt(t),!0)}function Jm(e){return Vg(e)!==null}function Qm(e){const t=pn(e);if(!t)return!1;const n=xs(t);return n.colSpan>1||n.rowSpan>1}function tk(e){const t=Vg(e);if(!t)return!1;const n=St(e,t.origin.cell);return n?Wg(n,t):!1}function nk(e){const t=pn(e);if(!t)return!1;const n=St(e,t);return n?Gg(n,t):!1}function rk(e,t,n){const r=pn(e);if(!r)return!1;const o=St(e,r);if(!o)return!1;const a=Nt(o),s=Xt(a,r);if(!s)return!1;const u=Math.min(a.colCount-s.originCol,Math.max(1,Math.floor(t))),d=Math.min(a.rowCount-s.originRow,Math.max(1,Math.floor(n)));if(u===s.colSpan&&d===s.rowSpan||!Uv(a,s,u,d))return!1;if((s.colSpan>1||s.rowSpan>1)&&Gg(o,r),u===1&&d===1)return kt(r),!0;const f=Nt(o),g=Kg(f,{minRow:s.originRow,maxRow:s.originRow+d-1,minCol:s.originCol,maxCol:s.originCol+u-1});return g?Wg(o,g):!0}function Au(e,t,n){let r=t;for(;r&&r!==e;){if(r instanceof HTMLElement&&n(r))return r;r=r.parentNode}return null}function ok(e){return Gv.has(e.tagName.toLowerCase())}function Pu(e){const t=window.getSelection();if(!t||t.rangeCount===0)return null;const n=t.getRangeAt(0);return ke(e,n.commonAncestorContainer)?n.startContainer:null}function Vg(e){const t=ui(e);if(t.length<2)return null;const n=St(e,t[0]);if(!n)return null;const r=Nt(n),o=[];for(const u of t){const d=Xt(r,u);if(!d)return null;o.push(d)}const a=Og(o);if(!a)return null;const s=Kg(r,a);return!s||s.cells.length<2?null:s}function Wg(e,t){const n=t.origin.cell,r=Nt(e),o=t.cells.map(a=>Xt(r,a)).filter(a=>a!==null).sort((a,s)=>a.originRow-s.originRow||a.originCol-s.originCol);for(const a of o)a.cell!==n&&lk(n,a.cell);yr(n,t.colSpan,t.rowSpan);for(const a of o)a.cell!==n&&a.cell.remove();return kt(n),!0}function Gg(e,t){const n=Nt(e),r=Xt(n,t);if(!r||r.colSpan===1&&r.rowSpan===1)return!1;yr(t,1,1);for(let o=r.originRow;o<r.originRow+r.rowSpan;o+=1)for(let a=r.originCol;a<r.originCol+r.colSpan;a+=1)o===r.originRow&&a===r.originCol||Ru(e,o,a,Tu(t));return kt(t),!0}function ik(e){const t=document.createElement(e);return t.style.border=Vv,t.style.padding=Wv,t.appendChild(document.createElement("br")),t}function Tu(e){const t=e.cloneNode(!1);for(t.removeAttribute("colspan"),t.removeAttribute("rowspan");t.firstChild;)t.removeChild(t.firstChild);return t.appendChild(document.createElement("br")),t}function ak(e,t,n){t>=e.cells.length?e.appendChild(n):e.insertBefore(n,e.cells[t])}function Ru(e,t,n,r){const o=e.rows[t];if(!o)return;const a=Nt(e);let s=0;for(const u of Array.from(o.cells)){if(u===r)continue;const d=Xt(a,u);if(!d||d.originCol>=n)break;s+=1}ak(o,s,r)}function sk(e,t,n,r){let o=0;for(let a=0;a<t;a+=1)if(!n.has(a)){if(a>=r)return e.cells[o]??null;o+=1}return e.cells[e.cells.length-1]??null}function ef(e){var t;return e.childNodes.length===0||e.childNodes.length===1&&((t=e.firstChild)==null?void 0:t.nodeName)==="BR"?!0:(e.textContent??"").trim().length===0&&e.querySelector("img, table, ul, ol, hr")===null}function lk(e,t){if(!(e===t||ef(t)))for(ef(e)?e.innerHTML="":e.appendChild(document.createTextNode(" "));t.firstChild;)e.appendChild(t.firstChild)}function ck(e,t){var o;const n=t.parentElement;if(!n||n===e)return;const r=n.tagName.toLowerCase();r==="td"||r==="th"||(r==="p"||/^h[1-6]$/.test(r))&&((o=n.parentNode)==null||o.insertBefore(t,n.nextSibling),uk(n)&&n.remove())}function uk(e){var t;return e.childNodes.length===0||e.childNodes.length===1&&((t=e.firstChild)==null?void 0:t.nodeName)==="BR"?!0:(e.textContent??"").trim().length===0&&e.querySelector("img, table, ul, ol")===null}function Tc(e,t){if(!t.parentNode||!ke(e,t))return!1;const r=document.createRange();r.setStartBefore(t),r.collapse(!0),t.remove();const o=window.getSelection();return o&&(o.removeAllRanges(),o.addRange(r)),!0}function kt(e){const t=document.createRange();t.selectNodeContents(e),t.collapse(!0);const n=window.getSelection();n&&(n.removeAllRanges(),n.addRange(t))}function dk(e){const t=document.createRange();t.setStartAfter(e),t.collapse(!0);const n=window.getSelection();n&&(n.removeAllRanges(),n.addRange(t))}const Zg=["left","center","right","justify"];function mk(e){const t=e.trim().toLowerCase();return t==="center"?"center":t==="right"||t==="end"?"right":t==="justify"?"justify":"left"}function Xa(e){return mk(e.style.textAlign)}function Rc(e,t){const n=t??"left";return Xa(e)===n?t===null&&e.style.textAlign?(e.style.removeProperty("text-align"),!0):!1:(t===null||t==="left"?e.style.removeProperty("text-align"):e.style.textAlign=t,!0)}function tf(e){const t=e[0];return e.every(n=>n===t)?{align:t,mixed:!1}:{align:null,mixed:!0}}function qg(e){const t=ui(e);if(t.length>0)return tf(t.map(Xa));const n=An(e);return n.length===0?fn(e)?{align:"left",mixed:!1}:{align:null,mixed:!1}:tf(n.map(Xa))}function Yg(e,t){return Zg.includes(t)?Qn(e,()=>{const n=ui(e);if(n.length>0){let a=!1;for(const s of n)Rc(s,t)&&(a=!0);return a}const r=Cr(e);if(r.length===0)return!1;let o=!1;for(const a of r)Rc(a,t)&&(o=!0);return o}):!1}function pr(){return{...lu(),align:"left",alignMixed:!1,list:null,listMixed:!1}}function ka(e){const t=xC(e),n=qg(e),r=Mg(e);return{...t,align:n.align,alignMixed:n.mixed,list:r.type,listMixed:r.mixed}}function Xg(e,t){let n=!1;return!t.alignMixed&&t.align&&Yg(e,t.align)&&(n=!0),t.listMixed||Nv(e,t.list)&&(n=!0),CC(e,t)&&(n=!0),n}function fk(e,t){return Xg(e,Dc(t))}function Jg(e){return{align:e.alignMixed?void 0:e.align??"left",list:e.listMixed?void 0:e.list,margin:e.marginMixed?void 0:e.margin,padding:e.paddingMixed?void 0:e.padding,lineHeight:e.lineHeightMixed?void 0:e.lineHeight,border:e.borderMixed?void 0:e.border,borderRadius:e.radiusMixed?void 0:e.borderRadius,boxShadow:e.shadowMixed?void 0:e.boxShadow,backgroundColor:e.backgroundMixed?void 0:e.backgroundColor,opacity:e.opacityMixed?void 0:e.opacity,breakInside:e.breakInsideMixed?void 0:e.breakInside,breakAfter:e.breakAfterMixed?void 0:e.breakAfter,breakBefore:e.breakBeforeMixed?void 0:e.breakBefore}}function Dc(e){const t=pr();return e?{align:e.align??t.align,alignMixed:e.align===void 0,list:e.list===void 0?t.list:e.list,listMixed:e.list===void 0,margin:e.margin??t.margin,marginMixed:e.margin===void 0,padding:e.padding??t.padding,paddingMixed:e.padding===void 0,lineHeight:e.lineHeight===void 0?t.lineHeight:e.lineHeight,lineHeightMixed:e.lineHeight===void 0,border:e.border??t.border,borderMixed:e.border===void 0,borderRadius:e.borderRadius===void 0?t.borderRadius:e.borderRadius,radiusMixed:e.borderRadius===void 0,boxShadow:e.boxShadow===void 0?t.boxShadow:e.boxShadow,shadowMixed:e.boxShadow===void 0,backgroundColor:e.backgroundColor===void 0?t.backgroundColor:e.backgroundColor,backgroundMixed:e.backgroundColor===void 0,opacity:e.opacity===void 0?t.opacity:e.opacity,opacityMixed:e.opacity===void 0,breakInside:e.breakInside===void 0?t.breakInside:e.breakInside,breakInsideMixed:e.breakInside===void 0,breakAfter:e.breakAfter===void 0?t.breakAfter:e.breakAfter,breakAfterMixed:e.breakAfter===void 0,breakBefore:e.breakBefore===void 0?t.breakBefore:e.breakBefore,breakBeforeMixed:e.breakBefore===void 0}:{...t,alignMixed:!0,listMixed:!0,marginMixed:!0,paddingMixed:!0,lineHeightMixed:!0,borderMixed:!0,radiusMixed:!0,shadowMixed:!0,backgroundMixed:!0,opacityMixed:!0,breakInsideMixed:!0,breakAfterMixed:!0,breakBeforeMixed:!0}}function Sa(e){return e?fr(e):""}function pk(e,t){return e.src===t.src&&e.opacity===t.opacity&&e.fit===t.fit&&e.position===t.position&&Sa(e.width)===Sa(t.width)&&Sa(e.height)===Sa(t.height)}function Gl(e){const t=An(e);if(t.length===0)return cn();const n=t.map(lg),r=n[0];return n.some(o=>!pk(o,r))?cn():r}function gk(e,t){return Qn(e,()=>{const n=Cr(e);if(n.length===0)return!1;let r=!1;for(const o of n)cg(o,t)&&(r=!0);return r})}function hk(){return{size:null,unit:Xr,marks:$n(),fontFamily:null,fontFamilyMixed:!1,fontColor:null,highlightColor:null,fontColorMixed:!1,highlightColorMixed:!1}}function Zo(){return{font:hk(),box:lu(),backgroundImage:cn(),atRule:Hn()}}function jc(e,t){return t?{top:t.top!==void 0?t.top:e.top,right:t.right!==void 0?t.right:e.right,bottom:t.bottom!==void 0?t.bottom:e.bottom,left:t.left!==void 0?t.left:e.left}:e}function bk(e,t){if(!t)return e;const{margin:n,padding:r,...o}=t;return{...e,...o,margin:n?jc(e.margin,n):e.margin,padding:r?jc(e.padding,r):e.padding}}function yk(e,t){if(!t)return e;const{marks:n,...r}=t;return{...e,...r,marks:n?{...e.marks,...n}:e.marks}}function xk(e,t){const{margin:n,...r}=t.atRule??{};return{font:yk(e.font,t.font),box:bk(e.box,t.box),backgroundImage:t.backgroundImage?{...e.backgroundImage,...t.backgroundImage}:e.backgroundImage,atRule:t.atRule?{...e.atRule,...r,margin:n?jc(e.atRule.margin,n):e.atRule.margin}:e.atRule}}function Ck(e){return e?!!(e.font||e.box||e.backgroundImage||e.atRule):!1}function nf(e,t){if(!Ck(t))return e;const n=document.createElement("div");n.innerHTML=e;const r=xk($o(n),t);return Ic(n,r).pageHtml}function wk(e){const t=e.style.fontSize,n=t?Xc(t):null,r=n&&us(n.unit)?{value:n.value,unit:n.unit}:null,o=`${e.style.textDecorationLine} ${e.style.textDecoration}`.toLowerCase(),a=e.style.fontWeight.trim().toLowerCase(),s={bold:a==="bold"||Number(a)>=700,italic:e.style.fontStyle.trim().toLowerCase()==="italic",underline:/\bunderline\b/.test(o),strikethrough:/\bline-through\b/.test(o)},u=e.style.color,d=e.style.fontFamily.trim();return{size:(r==null?void 0:r.value)??null,unit:(r==null?void 0:r.unit)??Xr,marks:s,fontFamily:d||null,fontFamilyMixed:!1,fontColor:u?Ue(u):null,highlightColor:null,fontColorMixed:!1,highlightColorMixed:!1}}function vk(e,t){const n=e.style.fontSize,r=t.size===null?null:gr(t.size,t.unit);if(!r)return n?(e.style.removeProperty("font-size"),!0):!1;const o=Yc(r.value,r.unit);return n===o?!1:(e.style.fontSize=o,!0)}function kk(e,t){var o;if(t.fontFamilyMixed)return!1;const n=(o=t.fontFamily)!=null&&o.trim()?t.fontFamily.trim():null,r=e.style.fontFamily.trim()||null;return si(r,n)?!1:(n?e.style.fontFamily=n:e.style.removeProperty("font-family"),!0)}function Sk(e,t){if(t.fontColorMixed)return!1;const n=t.fontColor?Ue(t.fontColor):null;return(e.style.color?Ue(e.style.color):null)===n?!1:(n?e.style.color=n:e.style.removeProperty("color"),!0)}function Ak(e,t){let n=!1;const r=t.bold?"bold":"";e.style.fontWeight!==r&&(r?e.style.fontWeight=r:e.style.removeProperty("font-weight"),n=!0);const o=t.italic?"italic":"";e.style.fontStyle!==o&&(o?e.style.fontStyle=o:e.style.removeProperty("font-style"),n=!0);const a=[];t.underline&&a.push("underline"),t.strikethrough&&a.push("line-through");const s=a.join(" ");return(e.style.textDecorationLine||e.style.textDecoration).trim()!==s&&(s?e.style.textDecoration=s:(e.style.removeProperty("text-decoration"),e.style.removeProperty("text-decoration-line")),n=!0),n}function Pk(e,t){let n=!1;return vk(e,t)&&(n=!0),kk(e,t)&&(n=!0),Sk(e,t)&&(n=!0),Ak(e,t.marks)&&(n=!0),n&&vt(e),n}function Tk(e){const t=e.box;return t.backgroundMixed||t.backgroundColor?t:!e.font.highlightColorMixed&&e.font.highlightColor?{...t,backgroundColor:e.font.highlightColor}:t}function $o(e){const t=gt(e);if(!t)return Zo();const n=ao(t);return{font:wk(t),box:{margin:n.margin,marginMixed:!1,padding:n.padding,paddingMixed:!1,lineHeight:n.lineHeight,lineHeightMixed:!1,border:n.border,borderMixed:!1,borderRadius:n.borderRadius,radiusMixed:!1,boxShadow:n.boxShadow,shadowMixed:!1,backgroundColor:n.backgroundColor,backgroundMixed:!1,opacity:n.opacity,opacityMixed:!1},backgroundImage:i1(t),atRule:rt(e.innerHTML)}}function Ic(e,t){const n=fn(e),r=n?Jr(e,n.startContainer,n.startOffset):null,o=n?Jr(e,n.endContainer,n.endOffset):null,a=gt(e),s=pu(e);Wo(s);const u=Pk(s,t.font),d=so(s,Tk(t)),f=a1(s,t.backgroundImage);gs(e);const g=rt(e.innerHTML),h=Ha(e.innerHTML,t.atRule),y=ln(h);y!==ln(e.innerHTML)&&(e.innerHTML=y),co(e,h);const b=JSON.stringify(g)!==JSON.stringify(t.atRule);r!==null&&o!==null&&ou(e,Math.min(r,o),Math.max(r,o)),hs(e);const C=Ha(e.innerHTML,t.atRule);return{changed:!a||u||d||f||b,pageHtml:C}}function Rk(e,t){const n=t??e.innerHTML,r=Bp(n);return ti(n)?(e.innerHTML=ln(r),gs(e),co(e,r),{changed:!0,pageHtml:r}):{changed:!1,pageHtml:r}}const Dk=/<script\b[^>]*>[\s\S]*?<\/script>/gi,jk=/^\s*javascript\s*:/i;function Ik(e){return e.replace(/&(#x[0-9a-f]+|#\d+|amp|lt|gt|quot);/gi,(t,n)=>{const r=n.toLowerCase();if(r==="amp")return"&";if(r==="lt")return"<";if(r==="gt")return">";if(r==="quot")return'"';if(r.startsWith("#x")){const o=Number.parseInt(r.slice(2),16);return Number.isFinite(o)?String.fromCodePoint(o):t}if(r.startsWith("#")){const o=Number.parseInt(r.slice(1),10);return Number.isFinite(o)?String.fromCodePoint(o):t}return t}).replace(/\\([0-7]{1,3})/g,(t,n)=>{const r=Number.parseInt(n,8);return Number.isFinite(r)?String.fromCodePoint(r):t})}function Qg(e){const t=Ik(e).replace(/[\u0000-\u001F\u007F\s]+/g,"");return jk.test(t)}function Ek(e){return e.split(";").map(t=>t.trim()).filter(t=>{if(!t)return!1;const n=t.indexOf(":");if(n<=0)return!0;const r=t.slice(n+1);return!Qg(r)&&!/url\s*\(\s*["']?\s*javascript:/i.test(r)}).join("; ")}function _k(e){const t=e instanceof Element?[e,...e.querySelectorAll("*")]:[...e.querySelectorAll("*")];for(const n of t)for(const r of[...n.attributes]){if(Qg(r.value)){n.removeAttribute(r.name);continue}if(r.name.toLowerCase()==="style"){const o=Ek(r.value);o?o!==r.value&&n.setAttribute(r.name,o):n.removeAttribute(r.name)}}}function Mk(e){return new DOMParser().parseFromString(`<body>${e}</body>`,"text/html")}function Nk(e){return e.body.innerHTML}function Ec(e){if(!e.trim())return e;const n=e.replace(Dk,"");if(!/javascript\s*:/i.test(n))return n;const r=Mk(n);return _k(r.body),Nk(r)}function Ur(e){if(!e.trim())return e;const n=On(e);return n.length===1?Ec(e):_t(n.map(Ec))}const Du="data-hover-html",Lk="noopener noreferrer",Bk="var n=this._hoverBox;if(!n){n=document.createElement('div');n.style.cssText='position:absolute;z-index:2147483646;background:#fff;border:1px solid #c8c8c8;border-radius:4px;padding:0.35rem 0.5rem;color:#222;max-width:18rem';this._hoverBox=n}n.innerHTML=this.getAttribute('data-hover-html')||'';var r=this.getBoundingClientRect();n.style.left=r.left+window.scrollX+'px';n.style.top=r.bottom+4+window.scrollY+'px';document.body.appendChild(n)",Fk="this._hoverBox&&this._hoverBox.remove()",Hk=/^(#(?:[0-9a-fA-F]{3}|[0-9a-fA-F]{6}|[0-9a-fA-F]{8})|rgba?\(\s*\d+\s*,\s*\d+\s*,\s*\d+(?:\s*,\s*(?:0|0?\.\d+|1))?\s*\))$/;function Cs(e={}){return{href:"",title:"",targetBlank:!1,textDecorationNone:!1,hoverMode:"color",hoverColor:null,hoverHtml:"",...e}}function zk(e){return e.tagName.toLowerCase()==="a"&&e.hasAttribute("href")}function oi(e,t){let n=t;for(;n&&n!==e;){if(n instanceof Element&&zk(n))return n;n=n.parentNode}return null}function eh(e){return Hk.test(e)}function Ok(e){var o;const t=e.getAttribute("onmouseover")??"",n=/this\.style\.color\s*=\s*'([^']+)'/.exec(t),r=((o=n==null?void 0:n[1])==null?void 0:o.trim())??"";return r&&eh(r)?r:null}function th(e){const t=`${e.style.textDecoration} ${e.style.textDecorationLine}`.toLowerCase();return/\bnone\b/.test(t)}function Kk(e){const t=e.getAttribute(Du)??"",n=Ok(e);return{href:e.getAttribute("href")??"",title:e.getAttribute("title")??"",targetBlank:e.getAttribute("target")==="_blank",textDecorationNone:th(e),hoverMode:t.trim()?"html":"color",hoverColor:n,hoverHtml:t}}function nh(e){const t=window.getSelection();if(!t||t.rangeCount===0)return null;const n=t.getRangeAt(0);if(!ke(e,n.commonAncestorContainer))return null;const r=oi(e,n.commonAncestorContainer);return r?Kk(r):null}function $k(e){return nh(e)!==null}function Uk(e){e.removeAttribute("onmouseover"),e.removeAttribute("onmouseout"),e.removeAttribute(Du)}function Vk(e,t){var r;if(Uk(e),t.hoverMode==="html"){const o=t.hoverHtml.trim();if(!o)return;e.setAttribute(Du,o),e.setAttribute("onmouseover",Bk),e.setAttribute("onmouseout",Fk);return}const n=((r=t.hoverColor)==null?void 0:r.trim())??"";!n||!eh(n)||(e.setAttribute("onmouseover",`this.style.color='${n}'`),e.setAttribute("onmouseout","this.style.color=''"))}function ju(e,t){const n=Cs(t);e.setAttribute("href",n.href);const r=n.title.trim();r?e.setAttribute("title",r):e.removeAttribute("title"),n.targetBlank?(e.setAttribute("target","_blank"),e.setAttribute("rel",Lk)):(e.removeAttribute("target"),e.removeAttribute("rel")),n.textDecorationNone?e.style.textDecoration="none":th(e)&&(e.style.removeProperty("text-decoration"),e.style.removeProperty("text-decoration-line")),Vk(e,n)}function Wk(e,t){const n=new Set;for(const r of t){const o=oi(e,r);o&&!n.has(o)&&n.add(o)}for(const r of n)Mt(r)}function Gk(e,t,n){un(t);const r=At(t).filter(u=>u.data.length>0);Wk(e,r),r.length>0&&xr(r);const o=window.getSelection();if(!o||o.rangeCount===0)return!1;const a=o.getRangeAt(0);un(a);const s=document.createElement("a");ju(s,n);try{return a.surroundContents(s),!0}catch{const u=a.extractContents();return u.hasChildNodes()?(s.appendChild(u),a.insertNode(s),!0):!1}}function Zk(e,t){const n=document.createElement("a");ju(n,t),n.textContent=t.href,e.insertNode(n),e.setStartAfter(n),e.collapse(!0);const r=window.getSelection();return r==null||r.removeAllRanges(),r==null||r.addRange(e),!0}function qk(e,t){const n=t.href.trim();if(!n)return!1;const r=Cs({...t,href:n}),o=window.getSelection();if(!o||o.rangeCount===0)return!1;const a=o.getRangeAt(0);if(!ke(e,a.commonAncestorContainer))return!1;const s=oi(e,a.startContainer),u=oi(e,a.endContainer);return s&&s===u?(ju(s,r),!0):a.collapsed?Zk(a,r):Gk(e,a,r)}const Yk=/^[A-Za-z][A-Za-z0-9_-]*$/,rh="​";function _c(e){var r;const t=gu(e),n=new Set;for(const o of t.querySelectorAll("[id]")){if(o===t)continue;const a=o.id.trim();a&&n.add(a)}for(const o of t.querySelectorAll("a[name]")){const a=(r=o.getAttribute("name"))==null?void 0:r.trim();a&&n.add(a)}return[...n].sort((o,a)=>o.localeCompare(a)).map(o=>({id:o}))}function Xk(e){return new Set(_c(e).map(t=>t.id))}function oh(e,t){const n=e.trim();return n?Yk.test(n)?t.has(n)?"duplicate":null:"invalid":"empty"}function rf(e,t){const n=document.createElement("a");n.id=t,n.appendChild(document.createTextNode(rh)),e.insertNode(n),e.setStartAfter(n),e.collapse(!0);const r=window.getSelection();r==null||r.removeAllRanges(),r==null||r.addRange(e)}function Jk(e,t){var r;const n=document.createElement("a");n.id=t,n.appendChild(document.createTextNode(rh)),(r=e.parentNode)==null||r.insertBefore(n,e)}function Qk(e,t){const n=t.trim();if(oh(n,Xk(e)))return!1;const r=window.getSelection();if(!r||r.rangeCount===0)return!1;const o=r.getRangeAt(0);if(!ke(e,o.commonAncestorContainer))return!1;const a=oi(e,o.startContainer);if(a)return Jk(a,n),!0;if(o.collapsed)return rf(o,n),!0;un(o);const s=document.createElement("span");s.id=n;try{return o.surroundContents(s),!0}catch{return rf(o,n),!0}}const st="data-comment-thread",of="wysiwyg-comment-anchor";function eS(){return`cmt_${crypto.randomUUID()}`}function tS(){return crypto.randomUUID()}const Ja=20;function af(e,t){if(!e)return null;const n=e instanceof Element?e:e.parentElement;if(!n)return null;const r=n.closest(`[${st}]`);return r instanceof HTMLElement&&ke(t,r)?r:null}function sf(e,t,n){var y;const r=document.createTreeWalker(e,NodeFilter.SHOW_TEXT);let o=Math.max(0,t),a=Math.max(t,n),s=null,u=0,d=null,f=0,g;for(;g=r.nextNode();){const b=g,C=((y=b.textContent)==null?void 0:y.length)??0;if(!s&&o<=C&&(s=b,u=o),!d&&a<=C){d=b,f=a;break}o-=C,a-=C}if(!s||!d)return null;const h=document.createRange();return h.setStart(s,u),h.setEnd(d,f),h}function nS(e,t,n){const r=e.textContent??"",o=r.slice(Math.max(0,t-Ja),t),a=r.slice(n,n+Ja);return{prefix:o,suffix:a}}function rS(e,t){if(t.mode!=="visual")return null;const n=Kn(e);if(n)return{type:"image",elementId:n.id||void 0,src:n.getAttribute("src")??void 0};if(t.collapsed&&!t.text)return null;const{prefix:r,suffix:o}=nS(e,t.start,t.end);return{type:"text",text:t.text,start:t.start,end:t.end,prefix:r,suffix:o}}function lf(e,t){if(t.mode!=="visual")return null;const n=Kn(e);if(n!=null&&n.hasAttribute(st))return n.getAttribute(st)??null;if(t.visualRange){const r=af(t.visualRange.startContainer,e);if(r)return r.getAttribute(st)??null;const o=af(t.visualRange.endContainer,e);if(o)return o.getAttribute(st)??null}return null}function Mc(e,t,n){if(!ke(e,n.commonAncestorContainer))return!1;un(n);const r=document.createElement("span");r.setAttribute(st,t);try{return n.surroundContents(r),!0}catch{const o=n.toString();if(!o)return!1;const a=document.createElement("span");return a.setAttribute(st,t),a.textContent=o,n.deleteContents(),n.insertNode(a),!0}}function ih(e,t){e.setAttribute(st,t)}function oS(e,t,n){const r=Kn(e);return r?(ih(r,t),!0):n.visualRange?Mc(e,t,n.visualRange):!1}function iS(e,t){if(t.type!=="image")return null;for(const n of e.querySelectorAll("img"))if(t.elementId&&n.id===t.elementId||t.src&&n.getAttribute("src")===t.src)return n;return null}function aS(e,t,n){if(n.type!=="text")return!1;if(n.start!==void 0&&n.end!==void 0){const s=sf(e,n.start,n.end);if(s&&s.toString()===n.text)return Mc(e,t,s)}const r=e.textContent??"",o=n.text;if(!o)return!1;let a=0;for(;a<=r.length;){const s=r.indexOf(o,a);if(s===-1)return!1;const u=s+o.length,d=r.slice(Math.max(0,s-Ja),s),f=r.slice(u,u+Ja);if(n.prefix!==void 0&&d!==n.prefix){a=s+1;continue}if(n.suffix!==void 0&&f!==n.suffix){a=s+1;continue}const g=sf(e,s,u);return g?Mc(e,t,g):!1}return!1}function sS(e,t){for(const n of t)if(!e.querySelector(`[${st}="${n.id}"]`)){if(n.anchor.type==="image"){const o=iS(e,n.anchor);o&&ih(o,n.id);continue}aS(e,n.id,n.anchor)}}function ah(e,t){for(const n of e.querySelectorAll(`[${st}]`))n instanceof HTMLElement&&(t?n.classList.add(of):n.classList.remove(of))}function sh(e,t){if(!t)return null;const n=t instanceof Element?t:t.parentElement;if(!n)return null;const r=n.closest(`[${st}]`);return r instanceof HTMLElement&&ke(e,r)?r:null}function cf(e,t){const n=e.querySelector(`[${st}="${t}"]`);if(!(n instanceof HTMLElement))return!1;const r=window.getSelection();if(!r)return!1;const o=document.createRange();if(n instanceof HTMLImageElement)o.selectNode(n);else{const s=document.createTreeWalker(n,NodeFilter.SHOW_TEXT).nextNode();s instanceof Text?(o.setStart(s,0),o.collapse(!0)):(o.selectNodeContents(n),o.collapse(!0))}return r.removeAllRanges(),r.addRange(o),!0}function lS(e,t=[]){return{id:eS(),anchor:e,messages:t,createdAt:new Date().toISOString(),resolvedAt:null,resolvedBy:null}}function cS(e,t){return{id:tS(),userId:e.userId,userName:e.userName,message:t.trim(),createdAt:new Date().toISOString()}}function uS(e,t,n){return e.map(r=>r.id===t?{...r,messages:[...r.messages,n]}:r)}function dS(e,t){return e.find(n=>n.id===t)}function lh(e){const t=window.getSelection();if(!t||t.rangeCount===0)return null;const n=t.getRangeAt(0);return ke(e,n.commonAncestorContainer)?n:null}function mS(e){const t=lh(e);if(!t||t.collapsed)return null;const n=document.createElement("div");n.appendChild(t.cloneContents());const r=n.innerHTML;if(!r)return null;let o=t.toString();if(!o){const a=n.querySelector("img");o=(a==null?void 0:a.getAttribute("alt"))??(a==null?void 0:a.getAttribute("src"))??""}return{html:r,text:o}}function ch(e){const t=lh(e);if(!t||t.collapsed)return!1;t.deleteContents();const n=window.getSelection();return n==null||n.removeAllRanges(),n==null||n.addRange(t),!0}async function fS(e){const t=navigator.clipboard;if(!t)return!1;try{if(typeof ClipboardItem=="function"&&typeof t.write=="function"){const n=new ClipboardItem({"text/plain":new Blob([e.text],{type:"text/plain"}),"text/html":new Blob([e.html],{type:"text/html"})});return await t.write([n]),!0}if(typeof t.writeText=="function")return await t.writeText(e.text),!0}catch{if(typeof t.writeText=="function")try{return await t.writeText(e.text),!0}catch{return!1}return!1}return!1}async function uh(e){const t=mS(e);return t?fS(t):!1}async function pS(e){return await uh(e)?ch(e):!1}const gS=new Set(["strong","b","em","i","u","s","strike","del"]),hS=["font","font-weight","font-style","font-family","font-size","color","background","background-color","text-decoration","text-decoration-line","text-decoration-color","text-decoration-style","text-decoration-thickness"];function bS(e){for(const t of hS)e.style.removeProperty(t)}function yS(e,t){let n=t;for(;n.parentElement&&n.parentElement!==e;){const r=n.parentElement;if(!mn(r)){n=r;continue}if(Xn(r,n),gS.has(r.tagName.toLowerCase())){Mt(r);continue}if(bS(r),Yn(r)){Mt(r);continue}n=r.isConnected?r:t}}function xS(e){const t=fn(e);if(!t||t.collapsed)return!1;const n=e.innerHTML;un(t);const r=At(t).filter(o=>o.data.length>0);if(r.length===0)return!1;for(const o of r)yS(e,o);return xr(r),e.innerHTML!==n}function CS(e,t){return e.start===t.start&&e.end===t.end&&e.collapsed===t.collapsed}function wS(e){const t=Gr(e),n=wg(e),r=op(e),o=Na(e,"color"),a=Na(e,"backgroundColor"),s=kg(e);return{size:n.mixed?null:n.value,unit:n.unit,marks:t,fontFamily:r.mixed?null:r.value,fontFamilyMixed:r.mixed,fontColor:o.mixed?null:o.value,fontColorMixed:o.mixed,highlightColor:a.mixed?null:a.value,highlightColorMixed:a.mixed,customCss:s.mixed?null:s.value,customCssMixed:s.mixed}}function vS(e,t){t.size!==null&&Cc(e,t.size,t.unit);const n=Gr(e);for(const r of Kt)t.marks[r]!==n[r]&&kc(e,r);return t.fontFamilyMixed||sc(e,t.fontFamily),t.fontColorMixed||Vo(e,"color",t.fontColor),t.highlightColorMixed||Vo(e,"backgroundColor",t.highlightColor),!t.customCssMixed&&t.customCss&&Ag(e,t.customCss),!0}function Ia(){return typeof window<"u"&&"speechSynthesis"in window}function kS(e){const t=document.createElement("div");return t.innerHTML=e,(t.innerText??t.textContent??"").trim()}function uf(e,t){const n=e.text.trim();return n||kS(t)||null}function SS(e){const t=window.speechSynthesis,n=()=>{e()};return{toggle(r){if(!Ia())return;if(t.speaking){t.cancel(),n();return}const o=new SpeechSynthesisUtterance(r);o.onend=n,o.onerror=n,t.speak(o),n()},isSpeaking(){return Ia()&&t.speaking},cancel(){Ia()&&t.speaking&&(t.cancel(),n())}}}const AS=5*1024*1024,PS="audio/mpeg,audio/mp3,audio/wav,audio/x-wav,audio/ogg,audio/aac,audio/webm,audio/mp4,audio/x-m4a,.mp3,.wav,.ogg,.aac,.webm,.m4a",TS=new Set(["audio/mpeg","audio/mp3","audio/wav","audio/x-wav","audio/ogg","audio/aac","audio/webm","audio/mp4","audio/x-m4a"]),RS=new Set(["mp3","wav","ogg","aac","webm","m4a"]),DS=/^data:audio\/(?:mpeg|mp3|wav|x-wav|ogg|aac|webm|mp4|x-m4a)(?:;charset=[^;,]+)?;base64,/i,jS=/^(javascript|vbscript|file|blob):/i;function IS(e={}){return{src:"",title:"",...e}}function Iu(e){const t=e.trim();if(!t)return"empty";if(jS.test(t))return"invalid";if(t.toLowerCase().startsWith("data:"))return DS.test(t)?null:"invalid";if(/^[a-z][a-z0-9+.-]*:/i.test(t)){const n=t.slice(0,t.indexOf(":")).toLowerCase();return n==="http"||n==="https"?null:"invalid"}return null}function ES(e){return e.size>AS?"tooLarge":BS(e)?null:"type"}function _S(e){const t=ES(e);return t?Promise.reject(new Error(t)):new Promise((n,r)=>{const o=new FileReader;o.onload=()=>{const a=String(o.result??"");if(Iu(a)){r(new Error("invalid"));return}n(a)},o.onerror=()=>r(o.error??new Error("Failed to read file")),o.readAsDataURL(e)})}function MS(e,t){e.setAttribute("controls",""),e.setAttribute("src",t.src.trim());const n=t.title.trim();n?e.setAttribute("title",n):e.removeAttribute("title"),e.style.maxWidth="100%",NS(e,t.css)}function NS(e,t){if(t)for(const n of t.split(";")){const r=n.trim();if(!r)continue;const o=r.indexOf(":");if(o<=0)continue;const a=r.slice(0,o).trim(),s=r.slice(o+1).trim();a&&s&&e.style.setProperty(a,s)}}function LS(e,t){const n=IS(t);if(Iu(n.src))return!1;const r=window.getSelection();if(!r||r.rangeCount===0)return!1;const o=r.getRangeAt(0);if(!ke(e,o.commonAncestorContainer))return!1;o.collapsed||o.deleteContents();const a=document.createElement("audio");return MS(a,n),o.insertNode(a),o.setStartAfter(a),o.collapse(!0),r.removeAllRanges(),r.addRange(o),!0}function BS(e){const t=e.type.trim().toLowerCase();if(t&&TS.has(t))return!0;const n=FS(e.name);return!!(!t&&n&&RS.has(n))}function FS(e){const t=e.lastIndexOf(".");return t<0||t===e.length-1?"":e.slice(t+1).toLowerCase()}function df(e,t){const r=(t?t(e):e).trim();if(!r)return"";if(!r.includes("<"))return r;const o=new DOMParser().parseFromString(`<body>${r}</body>`,"text/html");for(const a of o.querySelectorAll("img"))a.removeAttribute(Et);return o.body.innerHTML}function dh(e,t,n){return df(e,n)===df(t,n)}const HS=/^data:image\/(?:jpeg|jpg|png|gif|webp|bmp|avif)(?:;charset=[^;,]+)?;base64,/i;function mf(e,t){var o,a;const n=(o=e.getAttribute(Et))==null?void 0:o.trim();if(n&&t){const s=t(n);if(s)return`embedded:${s}`}const r=((a=e.getAttribute("src"))==null?void 0:a.trim())??"";return HS.test(r)?`embedded:${r}`:r.startsWith("blob:")&&n?`registry:${n}`:r?`url:${r}`:"empty"}function zS(e){return new DOMParser().parseFromString(`<body>${e}</body>`,"text/html").body}function OS(e,t){for(const n of[...e.attributes])t.hasAttribute(n.name)||e.removeAttribute(n.name);for(const n of[...t.attributes])e.setAttribute(n.name,n.value)}function KS(e,t){e.querySelectorAll("img").forEach((n,r)=>{const o=document.createElement("span");o.setAttribute(t,String(r)),n.replaceWith(o)})}function ff(e,t){const n=e.cloneNode(!0);return KS(n,t),n.innerHTML}function $S(e,t,n){const r=zS(t),o=[...e.querySelectorAll("img")],a=[...r.querySelectorAll("img")];if(o.length===0||o.length!==a.length)return!1;const s=o.map(h=>mf(h,n)),u=a.map(h=>mf(h,n));if(!s.every((h,y)=>h===u[y]))return!1;const d="data-wysiwyg-img-marker",f=ff(e,d),g=ff(r,d);if(f!==g)return!1;for(let h=0;h<o.length;h+=1)OS(o[h],a[h]);return!0}function Qa(e,t,n={}){const{resolveDataUrl:r,hydrateEmbeddedImages:o}=n;return dh(e.innerHTML,t,o)?{changed:!1}:e.innerHTML===t?{changed:!1}:$S(e,t,r)?{changed:!0}:(e.innerHTML=t,{changed:!0})}const mh=/^(javascript|vbscript|file|blob):/i,US=[/(?:youtube\.com\/watch\?(?:[^&]*&)*v=|youtube\.com\/watch\?v=)([\w-]{11})/i,/youtu\.be\/([\w-]{11})/i,/youtube\.com\/embed\/([\w-]{11})/i,/youtube\.com\/shorts\/([\w-]{11})/i];function VS(e={}){return{url:"",title:"",...e}}function WS(e={}){return{src:"",title:"",...e}}function ws(e){const t=e.trim();if(!t)return null;for(const n of US){const r=t.match(n);if(r!=null&&r[1])return r[1]}return null}function fh(e){return`https://www.youtube.com/embed/${e}`}function ph(e){const t=e.trim();return t?mh.test(t)?"invalid":ws(t)?null:"invalid":"empty"}function GS(e){const t=e.trim();if(!t)return"empty";if(mh.test(t))return"invalid";if(ws(t))return null;if(t.toLowerCase().startsWith("data:"))return/^data:video\//i.test(t)?null:"invalid";if(/^[a-z][a-z0-9+.-]*:/i.test(t)){const n=t.slice(0,t.indexOf(":")).toLowerCase();return n==="http"||n==="https"?null:"invalid"}return null}function gh(e,t){if(t)for(const n of t.split(";")){const r=n.trim();if(!r)continue;const o=r.indexOf(":");if(o<=0)continue;const a=r.slice(0,o).trim(),s=r.slice(o+1).trim();a&&s&&e.style.setProperty(a,s)}}function hh(e,t,n){e.setAttribute("src",t),e.setAttribute("frameborder","0"),e.setAttribute("allow","accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture"),e.setAttribute("allowfullscreen","");const r=n.title.trim();r?e.setAttribute("title",r):e.removeAttribute("title"),e.style.maxWidth="100%",e.style.width="560px",e.style.aspectRatio="16 / 9",e.style.border="0",gh(e,n.css)}function ZS(e,t){e.setAttribute("controls",""),e.setAttribute("src",t.src.trim());const n=t.title.trim();n?e.setAttribute("title",n):e.removeAttribute("title"),e.style.maxWidth="100%",gh(e,t.css)}function qS(e,t){const n=VS(t);if(ph(n.url))return!1;const r=ws(n.url);if(!r)return!1;const o=window.getSelection();if(!o||o.rangeCount===0)return!1;const a=o.getRangeAt(0);if(!ke(e,a.commonAncestorContainer))return!1;a.collapsed||a.deleteContents();const s=document.createElement("iframe");return hh(s,fh(r),n),a.insertNode(s),a.setStartAfter(s),a.collapse(!0),o.removeAllRanges(),o.addRange(a),!0}function YS(e,t){const n=WS(t);if(GS(n.src))return!1;const r=window.getSelection();if(!r||r.rangeCount===0)return!1;const o=r.getRangeAt(0);if(!ke(e,o.commonAncestorContainer))return!1;o.collapsed||o.deleteContents();const a=ws(n.src);if(a){const s=document.createElement("iframe");hh(s,fh(a),{title:n.title,css:n.css}),o.insertNode(s),o.setStartAfter(s)}else{const s=document.createElement("video");ZS(s,n),o.insertNode(s),o.setStartAfter(s)}return o.collapse(!0),r.removeAllRanges(),r.addRange(o),!0}const XS=new Set(["p","h1","h2","h3","h4","h5","h6"]),JS=new Set(["td","th","li","blockquote","pre","table","thead","tbody","tr"]);function bh(e,t){var a;const n=window.getSelection();if(!n||n.rangeCount===0)return!1;const r=n.getRangeAt(0);if(!ke(e,r.commonAncestorContainer))return!1;r.collapsed||r.deleteContents();const o=QS(e,r.startContainer);if(o){const s=e0(o,r);return(a=o.parentNode)==null||a.insertBefore(t,s),gf(t),!0}return r.insertNode(t),t0(e,t),o0(t),gf(t),!0}function QS(e,t){let n=li(t);for(;n&&n!==e;){const r=Me(n);if(XS.has(r)&&n instanceof HTMLElement)return n;if(JS.has(r))return null;n=n.parentElement}return null}function e0(e,t){var a;const n=document.createRange();n.setStart(t.startContainer,t.startOffset),n.setEnd(e,e.childNodes.length);const r=n.extractContents(),o=e.cloneNode(!1);return o.appendChild(r),pf(e),pf(o),(a=e.parentNode)==null||a.insertBefore(o,e.nextSibling),o}function t0(e,t){for(;;){const n=t.parentElement;if(!n||n===e||!n0(n))return;Xn(n,t),Mt(n)}}function n0(e){const t=Me(e);return mn(e)||t==="a"}function pf(e){r0(e)&&e.appendChild(document.createElement("br"))}function r0(e){var t;return e.childNodes.length===0||e.childNodes.length===1&&((t=e.firstChild)==null?void 0:t.nodeName)==="BR"?!0:(e.textContent??"").trim().length===0&&e.querySelector("img, table, ul, ol, hr")===null}function o0(e){var n;if(e.nextSibling)return;const t=document.createElement("p");t.appendChild(document.createElement("br")),(n=e.parentNode)==null||n.insertBefore(t,e.nextSibling)}function gf(e){const t=e.nextSibling,n=document.createRange();t instanceof HTMLElement||t?(n.setStart(t,0),n.collapse(!0)):(n.setStartAfter(e),n.collapse(!0));const r=window.getSelection();r&&(r.removeAllRanges(),r.addRange(n))}const i0="1em 0",a0="1px solid #d0d0d0";function s0(){const e=document.createElement("hr");return e.style.margin=i0,e.style.border="0",e.style.borderTop=a0,e}function l0(e){return bh(e,s0())}const c0="1.5em 0",u0="2px dashed #bbb",d0="data-wysiwyg-page-break";function m0(){const e=document.createElement("div");return e.setAttribute(d0,""),e.style.display="block",e.style.clear="both",e.style.breakAfter="page",e.style.pageBreakAfter="always",e.style.margin=c0,e.style.border="0",e.style.borderTop=u0,e.style.height="0",e}function f0(e){return bh(e,m0())}const Sn=16;function hf(e){return Math.min(no.px.max,Math.max(Sn,e))}function p0(e){return e.width>0&&e.height>0?e.width/e.height:1}function g0(e,t){const n=Math.max(Sn,Sn*t),r=Math.min(no.px.max,no.px.max*t),o=Math.min(r,Math.max(n,e));return{width:o,height:o/t}}function h0(e,t){const n=Math.max(Sn,Sn/t),r=Math.min(no.px.max,no.px.max/t),o=Math.min(r,Math.max(n,e));return{width:o*t,height:o}}function b0(e,t,n){const r=p0(t);return e==="e"?g0(t.width+n.x,r):e==="s"?h0(t.height+n.y,r):{width:hf(t.width+n.x),height:hf(t.height+n.y)}}function y0(e){const t=e.getBoundingClientRect(),n=e.offsetWidth||t.width,r=e.offsetHeight||t.height;return{width:n>0?n:Sn,height:r>0?r:Sn}}function x0(e,t,n){const r=ro(Math.max(Sn,t),"px"),o=ro(Math.max(Sn,n),"px");return!r||!o?!1:tg(e,{...eg(e),sizeMode:"lock",width:r,height:o})}function C0(e={}){return{border:{...su},borderCollapse:"collapse",borderSpacing:null,borderRadius:null,boxShadow:null,width:{value:100,unit:"%"},...e}}function w0(e){const t=ao(e);return{border:t.border,borderCollapse:A0(e),borderSpacing:yh(e),borderRadius:t.borderRadius,boxShadow:t.boxShadow,width:ht(e.style.width)}}function v0(e,t){let n=so(e,{margin:{top:null,right:null,bottom:null,left:null},marginMixed:!0,padding:{top:null,right:null,bottom:null,left:null},paddingMixed:!0,lineHeight:null,lineHeightMixed:!0,border:t.border,borderMixed:!1,borderRadius:t.borderRadius,radiusMixed:!1,boxShadow:t.boxShadow,shadowMixed:!1,backgroundColor:null,backgroundMixed:!0,opacity:null,opacityMixed:!0});return P0(e,t.borderCollapse)&&(n=!0),T0(e,t.borderCollapse,t.borderSpacing)&&(n=!0),R0(e,t.width)&&(n=!0),n&&vt(e),n}function k0(e){const t=Su(e);return t?w0(t):null}function S0(e,t){const n=Su(e);return n?v0(n,t):!1}function A0(e){return e.style.borderCollapse.trim().toLowerCase()==="separate"?"separate":"collapse"}function P0(e,t){return e.style.borderCollapse.trim().toLowerCase()===t?!1:(e.style.borderCollapse=t,!0)}function yh(e){const t=e.style.borderSpacing.trim();return t?ht(t.split(/\s+/)[0]??""):null}function T0(e,t,n){if(t!=="separate")return e.style.borderSpacing?(e.style.removeProperty("border-spacing"),!0):!1;const r=n?Jn(n):null,o=yh(e);return zt(o,r)?!1:(r?e.style.borderSpacing=Ie(r):e.style.removeProperty("border-spacing"),!0)}function R0(e,t){const n=t?Jn(t):null,r=ht(e.style.width);return zt(r,n)?!1:(n?e.style.width=Ie(n):e.style.removeProperty("width"),!0)}const vs=["top","middle","bottom","baseline"],D0=new Set(vs);function j0(e={}){return{backgroundColor:null,color:null,padding:{...Yt},textAlign:null,verticalAlign:null,width:null,colSpan:1,rowSpan:1,...e}}function I0(e){const t=ao(e);return{backgroundColor:t.backgroundColor,color:xh(e),padding:t.padding,textAlign:L0(e),verticalAlign:Ch(e),width:ht(e.style.width),...xs(e)}}function E0(e,t){let n=so(e,{margin:{...Yt},marginMixed:!0,padding:t.padding,paddingMixed:!1,lineHeight:null,lineHeightMixed:!0,border:{style:"none",width:null,color:null},borderMixed:!0,borderRadius:null,radiusMixed:!0,boxShadow:null,shadowMixed:!0,backgroundColor:t.backgroundColor,backgroundMixed:!1,opacity:null,opacityMixed:!0});return N0(e,t.color)&&(n=!0),Rc(e,t.textAlign)&&(n=!0),B0(e,t.verticalAlign)&&(n=!0),F0(e,t.width)&&(n=!0),n&&vt(e),n}function _0(e){const t=pn(e);return t?I0(t):null}function M0(e,t){const n=ui(e);if(n.length===0)return!1;let r=!1;for(const a of n)E0(a,t)&&(r=!0);const o=pn(e);if(o){const a=xs(o);(a.colSpan!==t.colSpan||a.rowSpan!==t.rowSpan)&&rk(e,t.colSpan,t.rowSpan)&&(r=!0)}return r}function xh(e){const t=e.style.color;return t?Ue(t):null}function N0(e,t){const n=t?Ue(t):null;return xh(e)===n?!1:(n?e.style.color=n:e.style.removeProperty("color"),!0)}function L0(e){const t=Xa(e);return t==="left"?null:t}function Ch(e){const t=e.style.verticalAlign.trim().toLowerCase();return D0.has(t)?t:null}function B0(e,t){return Ch(e)===t?!1:(t?e.style.verticalAlign=t:e.style.removeProperty("vertical-align"),!0)}function F0(e,t){const n=t?Jn(t):null,r=ht(e.style.width);return zt(r,n)?!1:(n?e.style.width=Ie(n):e.style.removeProperty("width"),!0)}const H0=new Set(vs);function z0(e={}){return{backgroundColor:null,color:null,padding:{...Yt},height:null,verticalAlign:null,...e}}function O0(e){const t=e.cells[0],n=t?ao(t).padding:{...Yt};return{backgroundColor:wh(e),color:vh(e),padding:n,height:ht(e.style.height),verticalAlign:kh(e)}}function K0(e,t){let n=!1;V0(e,t.backgroundColor)&&(n=!0),W0(e,t.color)&&(n=!0),Z0(e,t.height)&&(n=!0),G0(e,t.verticalAlign)&&(n=!0);for(const r of Array.from(e.cells))so(r,{margin:{...Yt},marginMixed:!0,padding:t.padding,paddingMixed:!1,lineHeight:null,lineHeightMixed:!0,border:{style:"none",width:null,color:null},borderMixed:!0,borderRadius:null,radiusMixed:!0,boxShadow:null,shadowMixed:!0,backgroundColor:null,backgroundMixed:!0,opacity:null,opacityMixed:!0})&&(n=!0);return n&&vt(e),n}function $0(e){const t=Ug(e);return t?O0(t):null}function U0(e,t){const n=Ug(e);return n?K0(n,t):!1}function wh(e){const t=e.style.backgroundColor;return t?Ue(t):null}function V0(e,t){const n=t?Ue(t):null;return wh(e)===n?!1:(n?e.style.backgroundColor=n:e.style.removeProperty("background-color"),!0)}function vh(e){const t=e.style.color;return t?Ue(t):null}function W0(e,t){const n=t?Ue(t):null;return vh(e)===n?!1:(n?e.style.color=n:e.style.removeProperty("color"),!0)}function kh(e){const t=e.style.verticalAlign.trim().toLowerCase();return H0.has(t)?t:null}function G0(e,t){return kh(e)===t?!1:(t?e.style.verticalAlign=t:e.style.removeProperty("vertical-align"),!0)}function Z0(e,t){const n=t?Jn(t):null,r=ht(e.style.height);return zt(r,n)?!1:(n?e.style.height=Ie(n):e.style.removeProperty("height"),!0)}const q0=1e3;function Y0(e,t){try{Promise.resolve(e(t)).catch(()=>{})}catch{}}function X0({onAutoSave:e,getHtml:t}){const n=l.useRef(e);n.current=e;const r=l.useRef(t);r.current=t;const o=l.useRef(null),a=e!=null;l.useEffect(()=>{if(!a){o.current=null;return}o.current=r.current();const s=window.setInterval(()=>{const u=n.current;if(!u)return;const d=r.current();d!==o.current&&(o.current=d,queueMicrotask(()=>Y0(u,d)))},q0);return()=>{window.clearInterval(s)}},[a])}function J0(){const[e,t]=l.useState({open:!1,tab:"general"}),[n,r]=l.useState(!1),[o,a]=l.useState({open:!1,html:""}),[s,u]=l.useState(null),[d,f]=l.useState(!1),[g,h]=l.useState(!1),[y,b]=l.useState({open:!1,tab:"general",value:pr(),backgroundImage:cn()}),[C,x]=l.useState({open:!1,value:""}),[v,k]=l.useState({open:!1,tab:"font",paragraphTab:"spacing",value:Zo()}),[S,P]=l.useState(!1),[T,D]=l.useState({open:!1}),[R,A]=l.useState({open:!1,tab:"link",href:"",title:"",targetBlank:!1,textDecorationNone:!1,hoverMode:"color",hoverColor:null,hoverHtml:"",bookmarks:[],selectedBookmarkId:""}),[E,B]=l.useState({open:!1,existingIds:[]}),[z,_]=l.useState({open:!1}),[M,O]=l.useState({open:!1}),[G,q]=l.useState({open:!1}),[re,Z]=l.useState({open:!1,tab:"general",value:Qp(),aspectRatio:1}),[X,ne]=l.useState({open:!1}),[ce,J]=l.useState({open:!1,value:C0()}),[I,se]=l.useState({open:!1,value:j0()}),[fe,L]=l.useState({open:!1,value:z0()}),[Be,Ne]=l.useState({open:!1,topicId:"getStarted"}),[Fe,bt]=l.useState(!1);return{fontDialog:e,setFontDialog:t,customizeToolbarOpen:n,setCustomizeToolbarOpen:r,documentPreview:o,setDocumentPreview:a,toolbarSettings:s,setToolbarSettings:u,toolbarSettingsLoading:d,setToolbarSettingsLoading:f,toolbarSettingsBusy:g,setToolbarSettingsBusy:h,paragraphDialog:y,setParagraphDialog:b,customCssDialog:C,setCustomCssDialog:x,pageDialog:v,setPageDialog:k,deletePageConfirmOpen:S,setDeletePageConfirmOpen:P,customStyleDialog:T,setCustomStyleDialog:D,linkDialog:R,setLinkDialog:A,bookmarkDialog:E,setBookmarkDialog:B,imageDialog:z,setImageDialog:_,audioDialog:M,setAudioDialog:O,youtubeDialog:G,setYoutubeDialog:q,imageProperties:re,setImageProperties:Z,tableDialog:X,setTableDialog:ne,tableProperties:ce,setTableProperties:J,cellProperties:I,setCellProperties:se,rowProperties:fe,setRowProperties:L,helpDialog:Be,setHelpDialog:Ne,aboutDialogOpen:Fe,setAboutDialogOpen:bt}}const bf={changed:!1,pages:[],joined:"",changedIndices:[]};function yf(e){return{changed:e.changed,pages:e.pages,joined:_t(e.pages),changedIndices:e.changedIndices}}function Q0({enabled:e,pagesProp:t,defaultPages:n}){const r=e&&t!==void 0,o=l.useMemo(()=>t!==void 0?zn(t):void 0,[t]),[a,s]=l.useState(()=>({pages:zn(n),revision:0})),u=l.useRef(o??zn(n)),d=l.useRef(new Set),f=l.useRef(t);l.useEffect(()=>{if(!e||!r||o===void 0||f.current===t&&mr(u.current,o))return;f.current=t;const k=Kl(u.current,o);if(u.current=k.pages,!!k.changed){for(const S of k.changedIndices)d.current.add(S);s(S=>({pages:k.pages,revision:S.revision+1}))}},[e,r,o,t]);const g=l.useMemo(()=>{if(!e)return[];if(r&&o!==void 0){const k=Kl(u.current,o);return u.current=k.pages,k.pages}return a.pages},[e,r,o,a.pages,a.revision]),h=l.useCallback((k,S)=>{if(!e)return bf;const P=r?u.current:a.pages,T=Kl(P,k);if(!T.changed)return yf(T);for(const D of T.changedIndices)d.current.add(D);return S!==void 0&&d.current.add(S),r?u.current=T.pages:s(D=>({pages:T.pages,revision:D.revision+1})),yf(T)},[e,a.pages,r]),y=l.useCallback((k,S)=>h(k,S==null?void 0:S.editedIndex),[h]),b=l.useCallback((k,S,P)=>{if(!e)return bf;const T=r?u.current:a.pages,D=pc(T,k,S);return D.changed?h(D.pages,(P==null?void 0:P.editedIndex)??k):{changed:!1,pages:T,joined:_t(T),changedIndices:[]}},[h,e,a.pages,r]),C=l.useCallback(k=>h(zn(k)),[h]),x=l.useCallback(k=>{if(k===void 0){d.current.clear();return}for(const S of k)d.current.delete(S)},[]),v=l.useCallback(()=>_t(g),[g]);return l.useMemo(()=>({pages:g,revision:a.revision,dirtyPagesRef:d,setPages:y,updatePage:b,replacePages:C,markPagesClean:x,getJoinedHtml:v}),[g,a.revision,y,b,C,x,v])}function Ea({value:e,defaultValue:t,onChange:n}){const[r,o]=l.useState(t),a=e!==void 0,s=a?e:r,u=l.useCallback(d=>{a||o(d),n==null||n(d)},[a,n]);return[s,u]}const Sh="commspliant-html-editor.darkMode";function eA(e){return typeof e=="boolean"?e:null}function xf(){try{const e=localStorage.getItem(Sh);return e?eA(JSON.parse(e)):null}catch{return null}}function tA(e){try{localStorage.setItem(Sh,JSON.stringify(e))}catch{}}const Ah="commspliant-html-editor.pageZoom",nA=new Set(["fitWidth","fitPage"]);function rA(e){return typeof e=="string"&&nA.has(e)||typeof e=="number"&&B1.includes(e)?e:null}function oA(){try{const e=localStorage.getItem(Ah);return e?rA(JSON.parse(e)):null}catch{return null}}function iA(e){try{localStorage.setItem(Ah,JSON.stringify(e))}catch{}}const Ph="commspliant-html-editor.toolbarPosition",aA=["top","left","right","bottom"];function Th(e){return typeof e=="string"&&aA.includes(e)?e:null}function Cf(){try{const e=localStorage.getItem(Ph);return e?Th(JSON.parse(e)):null}catch{return null}}function sA(e){try{localStorage.setItem(Ph,JSON.stringify(e))}catch{}}function lA({enabled:e,onHtml:t}){const[n,r]=l.useState(!1),o=l.useRef(0),a=l.useRef(e),s=l.useRef(t);a.current=e,s.current=t;const u=l.useCallback(()=>{o.current=0,r(!1)},[]);l.useEffect(()=>{e||u()},[e,u]);const d=l.useCallback(y=>{!a.current||!va(y.dataTransfer)||(y.preventDefault(),o.current+=1,r(!0))},[]),f=l.useCallback(y=>{!a.current||!va(y.dataTransfer)||(y.preventDefault(),y.dataTransfer&&(y.dataTransfer.dropEffect="copy"))},[]),g=l.useCallback(y=>{if(!a.current||!va(y.dataTransfer))return;const b=y.relatedTarget;b instanceof Node&&y.currentTarget.contains(b)||(o.current=Math.max(0,o.current-1),o.current===0&&r(!1))},[]),h=l.useCallback(y=>{if(!a.current||!va(y.dataTransfer))return;y.preventDefault(),u();const b=h1(y.dataTransfer);b&&wu(b).then(C=>{a.current&&s.current(C)},()=>{})},[u]);return{dragging:n,onDragEnter:d,onDragOver:f,onDragLeave:g,onDrop:h}}const cA={menus:{edit:{id:"edit",labelKey:"menuEdit",ariaKey:"menuEditAria"}},submenus:{page:{id:"page",labelKey:"menuPage",ariaKey:"menuPageAria"}},groups:{edit:{id:"edit",labelKey:"toolbarGroupEdit"}},items:{undo:{id:"undo",command:"undo",icon:Py,labelKey:"commandUndo",ariaKey:"commandUndoAria",enabled:"canUndo"},redo:{id:"redo",command:"redo",icon:Cy,labelKey:"commandRedo",ariaKey:"commandRedoAria",enabled:"canRedo"},pageProperties:{id:"pageProperties",command:"openPageProperties",icon:Uo,labelKey:"commandPageProperties",ariaKey:"commandPagePropertiesAria",enabled:"isVisualMode"},deletePage:{id:"deletePage",command:"deletePage",icon:Uo,labelKey:"commandDeletePage",ariaKey:"commandDeletePageAria",enabled:"canDeletePage"}}},Rh=400,es=100,Dh=2e7;function uA(e){let t=[],n=0,r=e,o=[],a=0,s=!1,u=!1,d=0;function f(){if(t.length>es){const v=t.splice(0,t.length-es);for(const k of v)n-=k.length}for(;t.length>1&&n+a>Dh;){const v=t.shift();v&&(n-=v.length)}}function g(v){t.push(v),n+=v.length,f()}function h(){o=[],a=0}function y(v,k){if(s){r=v,s=!1;return}if(v===r)return;const S=Date.now(),P=(k==null?void 0:k.coalesce)===!0;if(P&&u&&S-d<Rh){r=v,d=S,o.length>0&&h();return}g(r),r=v,h(),d=S,u=P}function b(){if(t.length===0)return null;u=!1,o.push(r),a+=r.length;const v=t.pop();return n-=v.length,r=v,f(),r}function C(){if(o.length===0)return null;u=!1,g(r);const v=o.pop();return a-=v.length,r=v,r}function x(v){if(s){r=v,s=!1;return}v!==r&&(g(r),r=v,h(),u=!1)}return{record:y,undo:b,redo:C,canUndo:()=>t.length>0,canRedo:()=>o.length>0,syncExternal:x,markApplying:()=>{s=!0},finishApplying:()=>{s=!1}}}function Ye(e){return e.map(t=>t)}function lr(e){switch(e.type){case"pageEdit":return e.before.length;case"insertPage":return e.page.length;case"deletePage":return e.page.length;case"replaceAll":return e.beforePages.reduce((t,n)=>t+n.length,0)}}function dA(e){let t=[],n=0,r=Ye(e),o=[],a=0,s=!1,u=!1,d=null,f=0;function g(){if(t.length>es){const R=t.splice(0,t.length-es);for(const A of R)n-=lr(A)}for(;t.length>1&&n+a>Dh;){const R=t.shift();R&&(n-=lr(R))}}function h(R){t.push(R),n+=lr(R),g()}function y(R){o.push(R),a+=lr(R)}function b(){for(const R of o)a-=lr(R);o=[],a=0}function C(){u=!1,d=null}function x(R,A,E){if(s){const O=Ye(r);O[R]=A,r=O,s=!1;return}if(r[R]===A)return;const B=Date.now(),z=(E==null?void 0:E.coalesce)===!0,_=z&&u&&d===R&&B-f<Rh,M=Ye(r);if(M[R]=A,_){r=M,f=B;return}h({type:"pageEdit",pageIndex:R,before:r[R]??""}),r=M,b(),f=B,u=z,d=R}function v(R,A){if(s){r=Ye(A),s=!1;return}mr(r,A)||(h({type:"insertPage",index:R,page:A[R]??""}),r=Ye(A),b(),C())}function k(R,A,E){if(s){r=Ye(E),s=!1;return}mr(r,E)||(h({type:"deletePage",index:R,page:A}),r=Ye(E),b(),C())}function S(R){if(s){r=Ye(R),s=!1;return}mr(r,R)||(h({type:"replaceAll",beforePages:Ye(r)}),r=Ye(R),b(),C())}function P(R){if(s){r=Ye(R),s=!1;return}mr(r,R)||(r=Ye(R))}function T(){if(t.length===0)return null;C();const R=t.pop();switch(n-=lr(R),R.type){case"pageEdit":{const A=r[R.pageIndex]??"";y({type:"pageEdit",pageIndex:R.pageIndex,before:A}),r[R.pageIndex]=R.before;break}case"insertPage":{const A=r[R.index]??"";y({type:"insertPage",index:R.index,page:A}),r.splice(R.index,1);break}case"deletePage":{y({type:"deletePage",index:R.index,page:R.page}),r.splice(R.index,0,R.page);break}case"replaceAll":{y({type:"replaceAll",beforePages:Ye(r)}),r=Ye(R.beforePages);break}}return g(),Ye(r)}function D(){if(o.length===0)return null;C();const R=o.pop();switch(a-=lr(R),R.type){case"pageEdit":{const A=r[R.pageIndex]??"";h({type:"pageEdit",pageIndex:R.pageIndex,before:A}),r[R.pageIndex]=R.before;break}case"insertPage":{h({type:"insertPage",index:R.index,page:R.page}),r.splice(R.index,0,R.page);break}case"deletePage":{const A=r[R.index]??"";h({type:"deletePage",index:R.index,page:A}),r.splice(R.index,1);break}case"replaceAll":{h({type:"replaceAll",beforePages:Ye(r)}),r=Ye(R.beforePages);break}}return Ye(r)}return{getPresent:()=>r,recordPageEdit:x,recordInsertPage:v,recordDeletePage:k,recordReplaceAll:S,undo:T,redo:D,canUndo:()=>t.length>0,canRedo:()=>o.length>0,syncPages:R=>S(R),applyPresent:P,markApplying:()=>{s=!0}}}function Ht(e){return typeof e=="object"&&e!==null&&"recordPageEdit"in e&&typeof e.recordPageEdit=="function"}const mA='button:not([disabled]):not([tabindex="-1"]), input:not([disabled]):not([hidden]), select:not([disabled]), textarea:not([disabled])',fA='[role="listbox"], [data-color-picker]';function Ze(e,{open:t,onClose:n,focusableSelector:r=mA,escapeIgnoreSelectors:o=fA}){l.useEffect(()=>{if(!t)return;const a=e.current,s=a==null?void 0:a.querySelector(r);s==null||s.focus();const u=d=>{if(d.key==="Escape"){if(o&&document.querySelector(o))return;d.preventDefault(),d.stopPropagation(),n();return}if(d.key!=="Tab"||!a)return;const f=[...a.querySelectorAll(r)];if(f.length===0)return;const g=f[0],h=f[f.length-1];d.shiftKey&&document.activeElement===g?(d.preventDefault(),h.focus()):!d.shiftKey&&document.activeElement===h&&(d.preventDefault(),g.focus())};return document.addEventListener("keydown",u,!0),()=>document.removeEventListener("keydown",u,!0)},[e,o,r,n,t])}function Zn(e,t){return t?t.label?t.label:t.labelKey?e(t.labelKey):"":""}function ts(e,t){return t?t.ariaLabel?t.ariaLabel:t.ariaKey?e(t.ariaKey):Zn(e,t):""}const sn="fullscreen",Nc="commspliant-html-editor.toolbarCustomization";function Lc(e){const t=e.filter(n=>n!==sn);return e.includes(sn)?[...t,sn]:t}function Eu(e,t){if(!t||t.length===0)return Lc(e);const n=new Set(e),r=t.filter(s=>n.has(s)),o=new Set(r),a=[...r];for(let s=0;s<e.length;s++){const u=e[s];if(o.has(u))continue;let d=0;for(let f=s-1;f>=0;f--){const g=e[f],h=a.indexOf(g);if(h>=0){d=h+1;break}}a.splice(d,0,u),o.add(u)}return Lc(a)}function pA(e,t){const n=new Map(e.map(s=>[s.id,s])),r=Eu(e.map(s=>s.id),t==null?void 0:t.groupOrder),o=new Set((t==null?void 0:t.hiddenItemIds)??[]),a=[];for(const s of r){const u=n.get(s);if(!u)continue;const d=u.items.filter(f=>!o.has(f));d.length!==0&&a.push({id:s,items:d})}return a}function gA(e){if(e==null||typeof e!="object")return null;const t=e,n=Array.isArray(t.groupOrder)?t.groupOrder.filter(o=>typeof o=="string"):[],r=Array.isArray(t.hiddenItemIds)?[...new Set(t.hiddenItemIds.filter(o=>typeof o=="string"))]:[];return n.length===0&&r.length===0?null:{groupOrder:n,hiddenItemIds:r}}function hA(){try{const e=localStorage.getItem(Nc);return e?gA(JSON.parse(e)):null}catch{return null}}function bA(e){try{if(!e){localStorage.removeItem(Nc);return}localStorage.setItem(Nc,JSON.stringify(e))}catch{}}function _u(e,t){return Eu(t.map(n=>n.id),e==null?void 0:e.groupOrder)}function yA(e,t,n,r){const o=new Set((e==null?void 0:e.hiddenItemIds)??[]);return r?o.delete(n):o.add(n),{groupOrder:_u(e,t),hiddenItemIds:[...o]}}function jh(e,t,n,r){const o=_u(e,t),a=[...(e==null?void 0:e.hiddenItemIds)??[]];if(n===sn||r===sn)return{groupOrder:o,hiddenItemIds:a};const s=o.indexOf(n),u=o.indexOf(r);if(s<0||u<0||s===u)return{groupOrder:o,hiddenItemIds:a};const d=[...o],[f]=d.splice(s,1);return d.splice(u,0,f),{groupOrder:Lc(d),hiddenItemIds:a}}function wf(e,t,n,r){const o=_u(e,t),a=o.filter(d=>d!==sn),s=a.indexOf(n),u=s+r;return s<0||u<0||u>=a.length?{groupOrder:o,hiddenItemIds:[...(e==null?void 0:e.hiddenItemIds)??[]]}:jh(e,t,n,a[u])}const xA="_backdrop_11w4e_1",CA="_dialog_11w4e_12",wA="_header_11w4e_31",vA="_body_11w4e_39",kA="_group_11w4e_49",SA="_groupDragging_11w4e_55",AA="_groupDropTarget_11w4e_59",PA="_groupHeader_11w4e_64",TA="_groupTitle_11w4e_72",RA="_dragHandle_11w4e_77",DA="_moveButton_11w4e_78",jA="_items_11w4e_119",IA="_item_11w4e_119",EA="_itemIcon_11w4e_135",_A="_itemTitle_11w4e_144",MA="_itemCheckbox_11w4e_151",NA="_actions_11w4e_155",LA="_action_11w4e_155",BA="_spinnerWrap_11w4e_191",FA="_spinner_11w4e_191",ze={backdrop:xA,dialog:CA,header:wA,body:vA,group:kA,groupDragging:SA,groupDropTarget:AA,groupHeader:PA,groupTitle:TA,dragHandle:RA,moveButton:DA,items:jA,item:IA,itemIcon:EA,itemTitle:_A,itemCheckbox:MA,actions:NA,action:LA,spinnerWrap:BA,spinner:FA};function HA(){return i.jsxs("svg",{viewBox:"0 0 16 16",width:"14",height:"14","aria-hidden":"true",fill:"currentColor",children:[i.jsx("circle",{cx:"5",cy:"4",r:"1.2"}),i.jsx("circle",{cx:"11",cy:"4",r:"1.2"}),i.jsx("circle",{cx:"5",cy:"8",r:"1.2"}),i.jsx("circle",{cx:"11",cy:"8",r:"1.2"}),i.jsx("circle",{cx:"5",cy:"12",r:"1.2"}),i.jsx("circle",{cx:"11",cy:"12",r:"1.2"})]})}function zA({open:e,catalog:t,groups:n,settings:r,loading:o=!1,busy:a=!1,disabled:s,onChange:u,onReset:d,onClose:f}){const g=Y(),h=l.useId(),y=l.useRef(null),[b,C]=l.useState(null),[x,v]=l.useState(null),k=Eu(n.map(_=>_.id),r==null?void 0:r.groupOrder),S=new Set((r==null?void 0:r.hiddenItemIds)??[]),P=new Map(n.map(_=>[_.id,_])),T=k.map(_=>P.get(_)).filter(_=>!!_),D=s||a||o;if(l.useEffect(()=>{e||(C(null),v(null))},[e]),Ze(y,{open:e,onClose:f,escapeIgnoreSelectors:!1,focusableSelector:'button:not([disabled]):not([tabindex="-1"]), input:not([disabled]), select:not([disabled])'}),!e)return null;const R=T.map(_=>_.id).filter(_=>_!==sn),A=(_,M)=>{if(D||M===sn){_.preventDefault();return}_.dataTransfer.setData("text/plain",M),_.dataTransfer.effectAllowed="move",C(M)},E=(_,M)=>{D||M===sn||!b||b===M||(_.preventDefault(),_.dataTransfer&&(_.dataTransfer.dropEffect="move"),v(M))},B=(_,M)=>{var G;_.preventDefault();const O=((G=_.dataTransfer)==null?void 0:G.getData("text/plain"))||b;C(null),v(null),!(!O||O===M||D)&&u(jh(r,n,O,M))},z=()=>{C(null),v(null)};return i.jsx(we,{children:i.jsx("div",{className:ze.backdrop,role:"presentation",onMouseDown:f,children:i.jsxs("div",{ref:y,className:ze.dialog,role:"dialog","aria-modal":"true","aria-labelledby":h,"aria-busy":o||a?!0:void 0,onMouseDown:_=>_.stopPropagation(),children:[i.jsx("h2",{className:ze.header,id:h,children:g("customizeToolbarDialogTitle")}),i.jsx("div",{className:ze.body,children:o?i.jsx("div",{className:ze.spinnerWrap,role:"status","aria-live":"polite","aria-label":g("customizeToolbarDialogLoading"),children:i.jsx("span",{className:ze.spinner,"aria-hidden":"true"})}):T.map(_=>{const M=t.groups[_.id],O=M?Zn(g,M):_.id,G=_.id===sn,q=R.indexOf(_.id);return i.jsxs("section",{className:[ze.group,b===_.id?ze.groupDragging:"",x===_.id?ze.groupDropTarget:""].filter(Boolean).join(" "),"data-toolbar-customize-group":_.id,"aria-label":O,onDragOver:re=>E(re,_.id),onDrop:re=>B(re,_.id),onDragLeave:()=>{x===_.id&&v(null)},children:[i.jsxs("div",{className:ze.groupHeader,children:[i.jsx("button",{type:"button",className:ze.dragHandle,draggable:!D&&!G,disabled:D||G,"aria-label":g("customizeToolbarDragHandle"),onDragStart:re=>A(re,_.id),onDragEnd:z,children:i.jsx(HA,{})}),i.jsx("span",{className:ze.groupTitle,children:O}),i.jsx("button",{type:"button",className:ze.moveButton,disabled:D||G||q<=0,"aria-label":g("customizeToolbarMoveUp"),onClick:()=>u(wf(r,n,_.id,-1)),children:"↑"}),i.jsx("button",{type:"button",className:ze.moveButton,disabled:D||G||q<0||q>=R.length-1,"aria-label":g("customizeToolbarMoveDown"),onClick:()=>u(wf(r,n,_.id,1)),children:"↓"})]}),i.jsx("div",{className:ze.items,children:_.items.map(re=>{const Z=t.items[re];if(!Z)return null;const X=Z.icon,ne=Zn(g,Z),ce=`${h}-${_.id}-${re}`,J=!S.has(re);return i.jsxs("label",{className:ze.item,htmlFor:ce,children:[i.jsx("span",{className:ze.itemIcon,"aria-hidden":"true",children:X?i.jsx(X,{}):ne.slice(0,2)}),i.jsx("span",{className:ze.itemTitle,children:ne}),i.jsx("input",{id:ce,className:ze.itemCheckbox,type:"checkbox",checked:J,disabled:D,"aria-label":`${ne}: ${g("customizeToolbarItemVisible")}`,onChange:I=>u(yA(r,n,re,I.target.checked))})]},re)})})]},_.id)})}),i.jsxs("div",{className:ze.actions,children:[i.jsx("button",{type:"button",className:ze.action,disabled:D,onClick:d,children:g("customizeToolbarDialogReset")}),i.jsx("button",{type:"button",className:ze.action,"aria-label":g("customizeToolbarDialogCloseAria"),onClick:f,children:g("customizeToolbarDialogClose")})]})]})})})}function OA(e,t){if(!t)return e;const n=t.menus,r=t.toolbar;if(n===void 0&&r===void 0)return e;const o=n===void 0?e.menus:e.menus.filter(s=>n.includes(s.id)),a=r===void 0?e.iconGroups:e.iconGroups.map(s=>({id:s.id,items:s.items.filter(u=>r.includes(u))})).filter(s=>s.items.length>0);return{menus:o,iconGroups:a}}const KA={menus:{file:{id:"file",labelKey:"menuFile",ariaKey:"menuFileAria"}},groups:{file:{id:"file",labelKey:"toolbarGroupFile"},print:{id:"print",labelKey:"toolbarGroupPrint"}},items:{save:{id:"save",command:"save",icon:ky,labelKey:"commandSave",ariaKey:"commandSaveAria"},open:{id:"open",command:"open",icon:my,labelKey:"commandOpen",ariaKey:"commandOpenAria"},print:{id:"print",command:"print",icon:yy,labelKey:"commandPrint",ariaKey:"commandPrintAria"}}},Ih=4;function $A({anchorRect:e,floatingWidth:t,floatingHeight:n,pad:r=Ih,minWidth:o=0,matchAnchorWidth:a=!1}){const s=a?Math.max(e.width,t,o):t;let u=e.bottom;u+n>window.innerHeight-r&&(u=Math.max(r,e.top-n));const d=Math.min(Math.max(e.left,r),window.innerWidth-s-r);return a?{top:u,left:d,width:s}:{top:u,left:d}}function uo(e,t,n,{pad:r=Ih,minWidth:o=0,matchAnchorWidth:a=!1,deps:s=[]}={}){const[u,d]=l.useState({top:0,left:0}),f=l.useCallback(()=>{const g=t.current,h=n.current;if(!g)return;const y=g.getBoundingClientRect(),b=Math.max(a?y.width:0,(h==null?void 0:h.offsetWidth)??0,o),C=(h==null?void 0:h.offsetHeight)??0;d($A({anchorRect:y,floatingWidth:b,floatingHeight:C,pad:r,minWidth:o,matchAnchorWidth:a}))},[t,n,a,o,r]);return l.useLayoutEffect(()=>{if(!e)return;f();const g=()=>f();return window.addEventListener("scroll",g,!0),window.addEventListener("resize",g),()=>{window.removeEventListener("scroll",g,!0),window.removeEventListener("resize",g)}},[e,f,...s]),u}const UA="_toolbar_1aggm_1",VA="_menuBar_1aggm_35",WA="_menuBarDesktop_1aggm_43",GA="_brandMark_1aggm_49",ZA="_brandMarkIcon_1aggm_56",qA="_menuBarCompact_1aggm_68",YA="_menuWrap_1aggm_91",XA="_menuButton_1aggm_97",JA="_iconButton_1aggm_98",QA="_menuItem_1aggm_99",eP="_hamburgerButton_1aggm_142",tP="_iconNav_1aggm_149",nP="_iconNavMain_1aggm_160",rP="_iconNavEnd_1aggm_169",oP="_iconGroup_1aggm_185",iP="_tooltipTrigger_1aggm_276",aP="_menu_1aggm_35",sP="_submenuWrap_1aggm_305",lP="_submenu_1aggm_305",cP="_submenuTrigger_1aggm_315",uP="_menuOverlay_1aggm_330",dP="_menuOverlayHeader_1aggm_342",mP="_menuOverlayTitle_1aggm_352",fP="_menuOverlayBody_1aggm_358",pP="_menuSeparator_1aggm_409",gP="_icon_1aggm_98",hP="_tooltip_1aggm_276",bP="_tooltipElevated_1aggm_494",ae={toolbar:UA,menuBar:VA,menuBarDesktop:WA,brandMark:GA,brandMarkIcon:ZA,menuBarCompact:qA,menuWrap:YA,menuButton:XA,iconButton:JA,menuItem:QA,hamburgerButton:eP,iconNav:tP,iconNavMain:nP,iconNavEnd:rP,iconGroup:oP,tooltipTrigger:iP,menu:aP,submenuWrap:sP,submenu:lP,submenuTrigger:cP,menuOverlay:uP,menuOverlayHeader:dP,menuOverlayTitle:mP,menuOverlayBody:fP,menuSeparator:pP,icon:gP,tooltip:hP,tooltipElevated:bP},yP=400,vf=6,Zl=4;function qn({label:e,children:t,className:n,elevated:r}){const o=l.useRef(null),a=l.useRef(null),s=l.useRef(null),u=l.useRef(!1),d=l.useRef(!1),[f,g]=l.useState(!1),[h,y]=l.useState({top:0,left:0}),b=l.useCallback(()=>{s.current!==null&&(clearTimeout(s.current),s.current=null)},[]),C=l.useCallback(k=>{if(!(u.current||d.current)){b(),g(!1);return}if(k||d.current){b(),g(!0);return}b(),s.current=setTimeout(()=>{s.current=null,g(!0)},yP)},[b]),x=l.useCallback(()=>{const k=o.current,S=a.current;if(!k||!S)return;const P=k.getBoundingClientRect(),T=S.offsetWidth,D=S.offsetHeight;let R=P.bottom+vf;R+D>window.innerHeight-Zl&&(R=P.top-vf-D);let A=P.left+P.width/2-T/2;A=Math.min(Math.max(A,Zl),window.innerWidth-T-Zl),y({top:R,left:A})},[]);l.useEffect(()=>()=>b(),[b]),l.useEffect(()=>{const k=o.current;if(!k)return;const S=()=>{d.current=!0,C(!0)},P=()=>{d.current=!1,C(!1)};return k.addEventListener("focusin",S),k.addEventListener("focusout",P),()=>{k.removeEventListener("focusin",S),k.removeEventListener("focusout",P)}},[C]),l.useLayoutEffect(()=>{if(!f)return;x();const k=()=>x();return window.addEventListener("scroll",k,!0),window.addEventListener("resize",k),()=>{window.removeEventListener("scroll",k,!0),window.removeEventListener("resize",k)}},[f,e,x]);const v=n?`${ae.tooltipTrigger} ${n}`:ae.tooltipTrigger;return i.jsxs(i.Fragment,{children:[i.jsx("span",{ref:o,className:v,"data-tooltip-trigger":"",onMouseEnter:()=>{u.current=!0,C(!1)},onMouseLeave:()=>{u.current=!1,C(!1)},children:t}),f?i.jsx(we,{children:i.jsx("span",{ref:a,className:r?`${ae.tooltip} ${ae.tooltipElevated}`:ae.tooltip,"data-toolbar-tooltip":"",style:{top:h.top,left:h.left},"aria-hidden":"true",children:e})}):null]})}const kf=8,Sf=["#000000","#434343","#666666","#999999","#b7b7b7","#cccccc","#d9d9d9","#ffffff","#980000","#ff0000","#ff9900","#ffff00","#00ff00","#00ffff","#4a86e8","#9900ff","#e6b8af","#f4cccc","#fce5cd","#fff2cc","#d9ead3","#d0e0e3","#c9daf8","#d9d2e9","#cc4125","#e06666","#f6b26b","#ffd966","#93c47d","#76a5af","#6d9eeb","#8e7cc3","#660000","#990000","#b45f06","#bf9000","#38761d","#134f5c","#1155cc","#351c75"],xP=8;let Bc=[];const Fc=new Set;function Af(){return Bc}function CP(e){const t=Ue(e);t&&(Bc=[t,...Bc.filter(n=>n!==t)].slice(0,xP),Fc.forEach(n=>n()))}function wP(e){return Fc.add(e),()=>{Fc.delete(e)}}function Aa(e){const t=Ue(e);return t?{r:Number.parseInt(t.slice(1,3),16),g:Number.parseInt(t.slice(3,5),16),b:Number.parseInt(t.slice(5,7),16)}:null}function cr(e,t,n){const r=o=>Math.max(0,Math.min(255,Math.round(o))).toString(16).padStart(2,"0");return`#${r(e)}${r(t)}${r(n)}`}function ql({r:e,g:t,b:n}){const r=e/255,o=t/255,a=n/255,s=Math.max(r,o,a),u=Math.min(r,o,a),d=s-u;let f=0;return d!==0&&(s===r?f=(o-a)/d%6:s===o?f=(a-r)/d+2:f=(r-o)/d+4,f*=60,f<0&&(f+=360)),{h:f,s:s===0?0:d/s,v:s}}function Yl({h:e,s:t,v:n}){const r=(e%360+360)%360,o=n*t,a=o*(1-Math.abs(r/60%2-1)),s=n-o;let u=0,d=0,f=0;return r<60?(u=o,d=a):r<120?(u=a,d=o):r<180?(d=o,f=a):r<240?(d=a,f=o):r<300?(u=a,f=o):(u=o,f=a),{r:Math.round((u+s)*255),g:Math.round((d+s)*255),b:Math.round((f+s)*255)}}function Eh(){return typeof window<"u"&&"EyeDropper"in window}async function vP(){if(!Eh())return null;const e=window.EyeDropper;try{const t=await new e().open();return Ue(t.sRGBHex)}catch{return null}}const kP="_picker_ag1yo_1",SP="_none_ag1yo_12",AP="_customToggle_ag1yo_13",PP="_eyedrop_ag1yo_14",TP="_swatch_ag1yo_48",RP="_field_ag1yo_49",DP="_grid_ag1yo_54",jP="_recents_ag1yo_55",IP="_sectionLabel_ag1yo_84",EP="_custom_ag1yo_13",_P="_sv_ag1yo_95",MP="_svThumb_ag1yo_105",NP="_hue_ag1yo_116",LP="_rgbRow_ag1yo_155",BP="_hexRow_ag1yo_156",tt={picker:kP,none:SP,customToggle:AP,eyedrop:PP,swatch:TP,field:RP,grid:DP,recents:jP,sectionLabel:IP,custom:EP,sv:_P,svThumb:MP,hue:NP,rgbRow:LP,hexRow:BP};function FP(e){if(!/^\d+$/.test(e.trim()))return null;const t=Number(e);return Number.isFinite(t)?Math.max(0,Math.min(255,t)):null}function Mu({value:e,mixed:t=!1,noneLabel:n,ariaLabel:r,disabled:o,menu:a=!1,fallbackCustom:s="#000000",onChange:u,onCommit:d}){const f=Y(),g=l.useId(),h=a?"menuitemradio":"option",y=t?null:e,b=Aa(y??s)??{r:0,g:0,b:0},[C,x]=l.useState(!1),[v,k]=l.useState(()=>ql(b)),[S,P]=l.useState(()=>({r:String(b.r),g:String(b.g),b:String(b.b)})),[T,D]=l.useState(()=>cr(b.r,b.g,b.b)),[R,A]=l.useState(()=>[...Af()]),E=l.useRef(null),B=l.useRef(cr(b.r,b.g,b.b));l.useEffect(()=>wP(()=>A([...Af()])),[]),l.useEffect(()=>{const I=Aa(y??s);if(!I)return;const se=ql(I);k(se),P({r:String(I.r),g:String(I.g),b:String(I.b)}),D(cr(I.r,I.g,I.b))},[y,s]);const z=(I,se,fe)=>{I&&(B.current=I),fe&&I&&CP(I),u(I),se&&(d==null||d(I))},_=(I,se,fe)=>{const L=cr(I.r,I.g,I.b);k(ql(I)),P({r:String(I.r),g:String(I.g),b:String(I.b)}),D(L),z(L,se,fe)},M=(I,se,fe)=>{const L=Yl(I),Be=cr(L.r,L.g,L.b);k(I),P({r:String(L.r),g:String(L.g),b:String(L.b)}),D(Be),z(Be,se,fe)},O=I=>{if(!["ArrowLeft","ArrowRight","ArrowUp","ArrowDown"].includes(I.key))return;const fe=[...I.currentTarget.querySelectorAll("button")],L=fe.findIndex(Fe=>Fe===document.activeElement);if(L<0)return;I.preventDefault();const Be=I.key==="ArrowLeft"?-1:I.key==="ArrowRight"?1:I.key==="ArrowUp"?-kf:kf,Ne=fe[Math.max(0,Math.min(fe.length-1,L+Be))];Ne==null||Ne.focus()},G=(I,se)=>{const fe=E.current;if(!fe||o)return;const L=fe.getBoundingClientRect(),Be=Math.max(0,Math.min(1,(I.clientX-L.left)/L.width)),Ne=Math.max(0,Math.min(1,1-(I.clientY-L.top)/L.height));M({h:v.h,s:Be,v:Ne},se,se)},q=I=>{o||(I.currentTarget.setPointerCapture(I.pointerId),G(I,!1))},re=Yl({h:v.h,s:1,v:1}),Z=cr(re.r,re.g,re.b),X=Yl(v),ne=cr(X.r,X.g,X.b),ce=new Set(Sf),J=R.filter(I=>!ce.has(I));return i.jsxs("div",{className:tt.picker,role:a?void 0:"listbox","aria-label":r,"data-color-picker":"",children:[i.jsx("button",{type:"button",className:tt.none,role:h,"aria-checked":a?y===null&&!t:void 0,"aria-selected":a?void 0:y===null&&!t,disabled:o,onClick:()=>z(null,!0,!1),children:n}),i.jsx("div",{className:tt.grid,role:a?"group":"none",onKeyDown:O,children:Sf.map(I=>{const se=y===I;return i.jsx("button",{type:"button",className:tt.swatch,role:h,"aria-label":I,"aria-checked":a?se:void 0,"aria-selected":a?void 0:se,disabled:o,style:{backgroundColor:I},onMouseDown:fe=>fe.preventDefault(),onClick:()=>z(I,!0,!1)},I)})}),J.length>0?i.jsxs(i.Fragment,{children:[i.jsx("p",{className:tt.sectionLabel,children:f("colorRecent")}),i.jsx("div",{className:tt.recents,role:a?"group":"none","aria-label":f("colorRecent"),children:J.map(I=>i.jsx("button",{type:"button",className:tt.swatch,role:h,"aria-label":I,"aria-checked":a?y===I:void 0,"aria-selected":a?void 0:y===I,disabled:o,style:{backgroundColor:I},onMouseDown:se=>se.preventDefault(),onClick:()=>z(I,!0,!1)},I))})]}):null,i.jsx("button",{type:"button",className:tt.customToggle,disabled:o,"aria-expanded":C,onClick:()=>x(I=>!I),children:f("colorCustom")}),C?i.jsxs("div",{className:tt.custom,children:[i.jsx("div",{ref:E,className:tt.sv,style:{background:`linear-gradient(to top, #000, transparent), linear-gradient(to right, #fff, ${Z})`},onPointerDown:q,onPointerMove:I=>{I.currentTarget.hasPointerCapture(I.pointerId)&&G(I,!1)},onPointerUp:I=>{G(I,!0)},children:i.jsx("span",{className:tt.svThumb,style:{left:`${v.s*100}%`,top:`${(1-v.v)*100}%`}})}),i.jsx("input",{className:tt.hue,type:"range",min:0,max:360,value:Math.round(v.h),disabled:o,"aria-label":f("colorCustom"),onChange:I=>M({...v,h:Number(I.target.value)},!1,!1),onPointerUp:()=>z(B.current,!0,!0)}),i.jsx("div",{className:tt.rgbRow,children:["r","g","b"].map(I=>i.jsxs("div",{className:tt.field,children:[i.jsx("label",{htmlFor:`${g}-${I}`,children:f(I==="r"?"colorRgbR":I==="g"?"colorRgbG":"colorRgbB")}),i.jsx("input",{id:`${g}-${I}`,inputMode:"numeric",value:S[I],disabled:o,onChange:se=>{P(fe=>({...fe,[I]:se.target.value}))},onBlur:()=>{const se=FP(S[I]);if(se===null){P({r:String(X.r),g:String(X.g),b:String(X.b)});return}_({...X,[I]:se},!0,!0)},onKeyDown:se=>{se.key==="Enter"&&se.currentTarget.blur()}})]},I))}),i.jsx("div",{className:tt.hexRow,children:i.jsxs("div",{className:tt.field,children:[i.jsx("label",{htmlFor:`${g}-hex`,children:f("colorHex")}),i.jsx("input",{id:`${g}-hex`,value:T,disabled:o,onChange:I=>D(I.target.value),onBlur:()=>{const I=Ue(T);if(!I){D(ne);return}const se=Aa(I);se&&_(se,!0,!0)},onKeyDown:I=>{I.key==="Enter"&&I.currentTarget.blur()}})]})}),Eh()?i.jsx("button",{type:"button",className:tt.eyedrop,disabled:o,onClick:()=>{vP().then(I=>{if(!I)return;const se=Aa(I);se&&_(se,!0,!0)})},children:f("colorPickFromScreen")}):null]}):null]})}const HP="_wrap_hfz5s_1",zP="_button_hfz5s_8",OP="_icon_hfz5s_18",KP="_bar_hfz5s_24",$P="_barEmpty_hfz5s_33",UP="_popover_hfz5s_43",ur={wrap:HP,button:zP,icon:OP,bar:KP,barEmpty:$P,popover:UP};function _h({icon:e,value:t,mixed:n,noneKey:r,labelKey:o,ariaKey:a,fallbackCustom:s,disabled:u,onChange:d}){const f=Y(),g=l.useId(),h=l.useRef(null),y=l.useRef(null),b=l.useRef(null),[C,x]=l.useState(!1),v=uo(C,y,b);l.useEffect(()=>{if(!C)return;const D=A=>{var B,z;const E=A.target;(B=h.current)!=null&&B.contains(E)||(z=b.current)!=null&&z.contains(E)||x(!1)},R=A=>{var E;A.key==="Escape"&&(A.preventDefault(),A.stopPropagation(),x(!1),(E=y.current)==null||E.focus())};return document.addEventListener("pointerdown",D),document.addEventListener("keydown",R,!0),()=>{document.removeEventListener("pointerdown",D),document.removeEventListener("keydown",R,!0)}},[C]);const k=D=>{d(D)},S=`${ur.bar}${!t||n?` ${ur.barEmpty}`:""}`,P=t&&!n?{backgroundColor:t}:void 0,T=i.jsxs("div",{className:ur.wrap,ref:h,children:[i.jsxs("button",{ref:y,type:"button",className:`${ae.iconButton} ${ur.button}`,"aria-label":f(a),"aria-expanded":C,"aria-haspopup":"listbox","aria-controls":C?g:void 0,disabled:u,onMouseDown:D=>D.preventDefault(),onClick:()=>x(D=>!D),children:[i.jsx(e,{className:`${ae.icon} ${ur.icon}`}),i.jsx("span",{className:S,style:P})]}),C?i.jsx(we,{children:i.jsx("div",{ref:b,id:g,className:ur.popover,style:{top:v.top,left:v.left},children:i.jsx(Mu,{value:t,mixed:n,noneLabel:f(r),ariaLabel:f(a),disabled:u,fallbackCustom:s,onChange:k,onCommit:()=>x(!1)})})}):null]});return i.jsx(qn,{label:f(o),children:T})}function VP({commands:e,queries:t,disabled:n}){return i.jsx(_h,{icon:Of,value:t.getFontColor(),mixed:t.isFontColorMixed(),noneKey:"colorAutomatic",labelKey:"commandFontColor",ariaKey:"commandFontColorAria",disabled:!!(n||!t.isVisualMode()),onChange:r=>e.setFontColor(r)})}const WP="_wrap_1vjt0_1",GP="_wrapToolbar_1vjt0_7",ZP="_field_1vjt0_12",qP="_trigger_1vjt0_20",YP="_chevron_1vjt0_50",XP="_list_1vjt0_73",JP="_listInline_1vjt0_88",QP="_option_1vjt0_96",eT="_separator_1vjt0_125",qt={wrap:WP,wrapToolbar:GP,field:ZP,trigger:qP,chevron:YP,list:XP,listInline:JP,option:QP,separator:eT};function tT({value:e,mixed:t=!1,fonts:n,disabled:r,listId:o,listRef:a,inline:s,style:u,onSelect:d}){const f=Y(),g=!t&&e===null;return i.jsxs("ul",{ref:a,id:o,className:s?`${qt.list} ${qt.listInline}`:qt.list,role:"listbox","aria-label":f("commandFontFamilyAria"),style:u,children:[i.jsx("li",{role:"presentation",children:i.jsx("button",{type:"button",className:qt.option,role:"option","aria-checked":g,disabled:r,onMouseDown:h=>h.preventDefault(),onClick:()=>d(null),children:f("fontFamilyDefault")})}),i.jsx("li",{className:qt.separator,role:"separator"}),n.map(h=>{const y=!t&&si(e,h.family);return i.jsx("li",{role:"presentation",children:i.jsx("button",{type:"button",className:qt.option,role:"option","aria-checked":y,disabled:r,style:{fontFamily:h.family},onMouseDown:b=>b.preventDefault(),onClick:()=>d(h.family),children:h.name})},h.family)})]})}function nT(e,t,n,r){var o;return t?"":e===null?r:((o=ox(e,n))==null?void 0:o.name)??e}function Mh({family:e,mixed:t=!1,fonts:n,disabled:r,tooltip:o,toolbar:a=!1,triggerId:s,onChange:u}){const d=Y(),f=l.useId(),g=l.useRef(null),h=l.useRef(null),y=l.useRef(null),[b,C]=l.useState(!1),x=nT(e,t,n,d("fontFamilyDefault")),v=uo(b,h,y,{matchAnchorWidth:!0,deps:[n.length]});l.useEffect(()=>{if(!b)return;const S=T=>{var R,A;const D=T.target;(R=g.current)!=null&&R.contains(D)||(A=y.current)!=null&&A.contains(D)||C(!1)},P=T=>{T.key==="Escape"&&(T.preventDefault(),T.stopPropagation(),C(!1))};return document.addEventListener("pointerdown",S),document.addEventListener("keydown",P,!0),()=>{document.removeEventListener("pointerdown",S),document.removeEventListener("keydown",P,!0)}},[b]);const k=i.jsxs("div",{className:`${qt.wrap}${a?` ${qt.wrapToolbar}`:""}`,ref:g,children:[i.jsxs("div",{className:qt.field,ref:h,children:[i.jsx("button",{type:"button",id:s,className:qt.trigger,disabled:r,"aria-label":a?d("commandFontFamilyAria"):void 0,"aria-haspopup":"listbox","aria-expanded":b,"aria-controls":b?f:void 0,style:e&&!t?{fontFamily:e}:void 0,onMouseDown:S=>S.preventDefault(),onClick:()=>C(S=>!S),children:x}),i.jsx("span",{className:qt.chevron,"aria-hidden":"true"})]}),b?i.jsx(we,{children:i.jsx(tT,{listRef:y,listId:f,value:t?null:e,mixed:t,fonts:n,disabled:r,style:{top:v.top,left:v.left,minWidth:v.width},onSelect:S=>{u(S),C(!1)}})}):null]});return o?i.jsx(qn,{label:o,children:k}):k}function rT({commands:e,queries:t,disabled:n}){const r=Y(),o=!!(n||!t.isVisualMode());return i.jsx(Mh,{family:t.isFontFamilyMixed()?null:t.getFontFamily(),mixed:t.isFontFamilyMixed(),fonts:t.getFontFaces(),disabled:o,tooltip:r("commandFontFamily"),toolbar:!0,onChange:a=>{e.setFontFamily(a)}})}const oT="_wrap_58i0x_1",iT="_wrapToolbar_58i0x_9",aT="_field_58i0x_14",sT="_input_58i0x_22",lT="_toggle_58i0x_41",cT="_chevron_58i0x_42",uT="_unit_58i0x_80",dT="_list_58i0x_110",mT="_option_58i0x_125",Ge={wrap:oT,wrapToolbar:iT,field:aT,input:sT,toggle:lT,chevron:cT,unit:uT,list:dT,option:mT},fT={pt:"fontSizeUnitPt",px:"fontSizeUnitPx",em:"fontSizeUnitEm",rem:"fontSizeUnitRem","%":"fontSizeUnitPercent"};function Nh({size:e,unit:t,onSizeChange:n,onUnitChange:r,disabled:o,tooltip:a,sizeInputId:s,toolbar:u=!1}){const d=Y(),f=l.useId(),g=l.useRef(null),h=l.useRef(null),y=l.useRef(null),[b,C]=l.useState(()=>e===null?"":me(e)),[x,v]=l.useState(!1),[k,S]=l.useState(!1),P=uo(k,h,y,{matchAnchorWidth:!0,minWidth:72});l.useEffect(()=>{x||C(e===null?"":me(e))},[e,x]),l.useEffect(()=>{if(!k)return;const E=z=>{var M,O;const _=z.target;(M=g.current)!=null&&M.contains(_)||(O=y.current)!=null&&O.contains(_)||S(!1)},B=z=>{z.key==="Escape"&&(z.preventDefault(),z.stopPropagation(),S(!1))};return document.addEventListener("pointerdown",E),document.addEventListener("keydown",B,!0),()=>{document.removeEventListener("pointerdown",E),document.removeEventListener("keydown",B,!0)}},[k]);const T=E=>{const B=Ax(E,t);if(!B){C(e===null?"":me(e));return}n(B.value,B.unit),C(me(B.value))},D=wx[t],R=k?i.jsx(we,{children:i.jsx("ul",{ref:y,className:Ge.list,role:"listbox",id:f,style:{top:P.top,left:P.left,minWidth:P.width},children:D.map(E=>i.jsx("li",{role:"presentation",children:i.jsx("button",{type:"button",className:Ge.option,role:"option","aria-selected":e===E,onMouseDown:B=>B.preventDefault(),onClick:()=>{n(E,t),C(me(E)),S(!1)},children:me(E)})},E))})}):null,A=i.jsxs("div",{className:`${Ge.wrap}${u?` ${Ge.wrapToolbar}`:""}`,ref:g,children:[i.jsxs("div",{className:Ge.field,ref:h,children:[i.jsx("input",{id:s,className:Ge.input,value:b,disabled:o,"aria-label":d("commandFontSizeAria"),"aria-autocomplete":"list","aria-expanded":k,"aria-controls":f,role:"combobox",inputMode:"decimal",onFocus:()=>v(!0),onBlur:()=>{v(!1),T(b)},onChange:E=>C(E.target.value),onKeyDown:E=>{E.key==="Enter"&&(E.preventDefault(),T(b),S(!1),E.currentTarget.blur()),E.key==="ArrowDown"&&(E.preventDefault(),S(!0))}}),i.jsx("button",{type:"button",className:Ge.toggle,tabIndex:-1,disabled:o,"aria-label":d("commandFontSizeAria"),"aria-expanded":k,"aria-controls":f,onMouseDown:E=>E.preventDefault(),onClick:()=>S(E=>!E)})]}),i.jsxs("div",{className:Ge.field,children:[i.jsx("select",{className:Ge.unit,value:t,disabled:o,"aria-label":d("commandFontSizeUnitAria"),onChange:E=>{r(E.target.value)},children:qc.map(E=>i.jsx("option",{value:E,children:d(fT[E])},E))}),i.jsx("span",{className:Ge.chevron,"aria-hidden":"true"})]}),R]});return a?i.jsx(qn,{label:a,children:A}):A}function pT({commands:e,queries:t,disabled:n}){const r=Y(),o=!!(n||!t.isVisualMode());return i.jsx(Nh,{size:t.getFontSize(),unit:t.getFontSizeUnit(),disabled:o,tooltip:r("commandFontSize"),toolbar:!0,onSizeChange:(a,s)=>{e.setFontSize(a,s)},onUnitChange:a=>{e.setFontSizeUnit(a)}})}function gT({commands:e,queries:t,disabled:n}){return i.jsx(_h,{icon:Kf,value:t.getHighlightColor(),mixed:t.isHighlightColorMixed(),noneKey:"colorNone",labelKey:"commandHighlightColor",ariaKey:"commandHighlightColorAria",fallbackCustom:"#ffff00",disabled:!!(n||!t.isVisualMode()),onChange:r=>e.setHighlightColor(r)})}function hT({commands:e,queries:t,disabled:n,onMenuClose:r}){const o=Y(),a=!!(n||!t.isVisualMode());return i.jsx(Mu,{value:t.getHighlightColor(),mixed:t.isHighlightColorMixed(),noneLabel:o("colorNone"),ariaLabel:o("commandHighlightColorAria"),disabled:a,menu:!0,fallbackCustom:"#ffff00",onChange:s=>e.setHighlightColor(s),onCommit:()=>r==null?void 0:r()})}const bT="_wrap_1gtdc_1",yT="_wrapToolbar_1gtdc_7",xT="_field_1gtdc_12",CT="_trigger_1gtdc_20",wT="_chevron_1gtdc_46",vT="_list_1gtdc_69",kT="_option_1gtdc_84",ST="_separator_1gtdc_113",vn={wrap:bT,wrapToolbar:yT,field:xT,trigger:CT,chevron:wT,list:vT,option:kT,separator:ST},AT="_backdrop_1p9zk_1",PT="_dialog_1p9zk_12",TT="_dialogWide_1p9zk_31",RT="_header_1p9zk_35",DT="_tabs_1p9zk_43",jT="_tab_1p9zk_43",IT="_body_1p9zk_76",ET="_field_1p9zk_86",_T="_label_1p9zk_92",MT="_sizeRow_1p9zk_96",NT="_fileRow_1p9zk_102",LT="_fileName_1p9zk_108",BT="_previewImage_1p9zk_115",FT="_marks_1p9zk_125",HT="_mark_1p9zk_125",zT="_actions_1p9zk_140",OT="_actionsSpread_1p9zk_148",KT="_actionsEnd_1p9zk_152",$T="_headerRow_1p9zk_157",UT="_close_1p9zk_170",VT="_nameSection_1p9zk_187",WT="_nameInput_1p9zk_192",GT="_labelRow_1p9zk_209",ZT="_help_1p9zk_215",qT="_textInput_1p9zk_233",YT="_fullSelect_1p9zk_245",XT="_error_1p9zk_249",JT="_emptyHint_1p9zk_254",QT="_action_1p9zk_140",eR="_textarea_1p9zk_265",tR="_actionDanger_1p9zk_279",nR="_confirmBody_1p9zk_285",rR="_nestedPanel_1p9zk_294",oR="_spinnerWrap_1p9zk_309",iR="_spinner_1p9zk_309",aR="_actionPrimary_1p9zk_344",sR="_iconButton_1p9zk_358",lR="_select_1p9zk_359",cR="_lengthInput_1p9zk_360",uR="_lengthUnit_1p9zk_361",dR="_group_1p9zk_369",mR="_nestedGroup_1p9zk_379",fR="_subLabel_1p9zk_389",pR="_iconRow_1p9zk_393",gR="_lengthField_1p9zk_425",hR="_sideLabel_1p9zk_431",bR="_lengthRow_1p9zk_435",yR="_sideGrid_1p9zk_463",xR="_shadowGrid_1p9zk_464",p={backdrop:AT,dialog:PT,dialogWide:TT,header:RT,tabs:DT,tab:jT,body:IT,field:ET,label:_T,sizeRow:MT,fileRow:NT,fileName:LT,previewImage:BT,marks:FT,mark:HT,actions:zT,actionsSpread:OT,actionsEnd:KT,headerRow:$T,close:UT,nameSection:VT,nameInput:WT,labelRow:GT,help:ZT,textInput:qT,fullSelect:YT,error:XT,emptyHint:JT,action:QT,textarea:eR,actionDanger:tR,confirmBody:nR,nestedPanel:rR,spinnerWrap:oR,spinner:iR,actionPrimary:aR,iconButton:sR,select:lR,lengthInput:cR,lengthUnit:uR,group:dR,nestedGroup:mR,subLabel:fR,iconRow:pR,lengthField:gR,sideLabel:hR,lengthRow:bR,sideGrid:yR,shadowGrid:xR},Hc={p:"styleParagraph",h1:"styleHeading1",h2:"styleHeading2",h3:"styleHeading3",h4:"styleHeading4",h5:"styleHeading5",h6:"styleHeading6"},CR={p:{fontSize:"1rem",fontWeight:"400"},h1:{fontSize:"1.75rem",fontWeight:"600"},h2:{fontSize:"1.5rem",fontWeight:"600"},h3:{fontSize:"1.25rem",fontWeight:"600"},h4:{fontSize:"1.125rem",fontWeight:"600"},h5:{fontSize:"1rem",fontWeight:"600"},h6:{fontSize:"0.875rem",fontWeight:"600"}};function Pf(){const e=Y();return i.jsx("div",{className:p.spinnerWrap,role:"status","aria-live":"polite","aria-label":e("customStyleLoading"),children:i.jsx("span",{className:p.spinner,"aria-hidden":"true"})})}function Lh({value:e,mixed:t=!1,disabled:n,menu:r=!1,listId:o,listRef:a,style:s,customStylesEnabled:u=!1,customStyles:d=[],customStylesLoading:f=!1,onSelect:g,onSelectCustom:h,onAddNew:y}){const b=Y(),C=t?null:e,x=u,v=!!(r&&u&&y);return r?i.jsxs(i.Fragment,{children:[Za.map(k=>i.jsx("button",{type:"button",className:ae.menuItem,role:"menuitemradio","aria-checked":C===k,disabled:n,onMouseDown:S=>S.preventDefault(),onClick:()=>g(k),children:b(Hc[k])},k)),x?i.jsx("div",{role:"separator",className:ae.menuSeparator}):null,x&&f?i.jsx(Pf,{}):null,x&&!f?d.map(k=>i.jsx("button",{type:"button",className:ae.menuItem,role:"menuitem",disabled:n,onMouseDown:S=>S.preventDefault(),onClick:()=>h==null?void 0:h(k.id),children:k.name},k.id)):null,v?i.jsxs(i.Fragment,{children:[x&&(f||d.length>0)?i.jsx("div",{role:"separator",className:ae.menuSeparator}):null,i.jsxs("button",{type:"button",className:ae.menuItem,role:"menuitem","aria-label":b("styleAddNewAria"),disabled:n,onMouseDown:k=>k.preventDefault(),onClick:()=>y==null?void 0:y(),children:[i.jsx(by,{className:ae.icon}),b("styleAddNew")]})]}):null]}):i.jsxs("ul",{ref:a,className:vn.list,role:"listbox",id:o,style:s,"aria-label":b("commandParagraphStyleAria"),"aria-busy":x&&f?!0:void 0,children:[Za.map(k=>i.jsx("li",{role:"presentation",children:i.jsx("button",{type:"button",className:vn.option,role:"option","aria-selected":C===k,disabled:n,style:CR[k],onMouseDown:S=>S.preventDefault(),onClick:()=>g(k),children:b(Hc[k])})},k)),x&&(f||d.length>0)?i.jsx("li",{role:"separator",className:vn.separator}):null,x&&f?i.jsx("li",{role:"presentation",children:i.jsx(Pf,{})}):null,x&&!f?d.map(k=>i.jsx("li",{role:"presentation",children:i.jsx("button",{type:"button",className:vn.option,role:"option","aria-selected":!1,disabled:n,onMouseDown:S=>S.preventDefault(),onClick:()=>h==null?void 0:h(k.id),children:k.name})},k.id)):null]})}function wR({commands:e,queries:t,disabled:n}){const r=Y(),o=l.useId(),a=l.useRef(null),s=l.useRef(null),u=l.useRef(null),[d,f]=l.useState(!1),g=!!(n||!t.isVisualMode()),h=t.isParagraphStyleMixed(),y=h?null:t.getParagraphStyle(),b=y?r(Hc[y]):"",C=t.customParagraphStylesEnabled(),x=C?t.getCustomParagraphStyles():[],v=C&&t.isCustomParagraphStylesLoading(),k=uo(d,s,u,{matchAnchorWidth:!0,deps:[x.length,v]});l.useEffect(()=>{if(!d)return;const P=D=>{var A,E;const R=D.target;(A=a.current)!=null&&A.contains(R)||(E=u.current)!=null&&E.contains(R)||f(!1)},T=D=>{D.key==="Escape"&&(D.preventDefault(),D.stopPropagation(),f(!1))};return document.addEventListener("pointerdown",P),document.addEventListener("keydown",T,!0),()=>{document.removeEventListener("pointerdown",P),document.removeEventListener("keydown",T,!0)}},[d]);const S=i.jsxs("div",{className:`${vn.wrap} ${vn.wrapToolbar}`,ref:a,children:[i.jsxs("div",{className:vn.field,ref:s,children:[i.jsx("button",{type:"button",className:vn.trigger,disabled:g,"aria-label":r("commandParagraphStyleAria"),"aria-haspopup":"listbox","aria-expanded":d,"aria-controls":d?o:void 0,onMouseDown:P=>P.preventDefault(),onClick:()=>f(P=>!P),children:b}),i.jsx("span",{className:vn.chevron,"aria-hidden":"true"})]}),d?i.jsx(we,{children:i.jsx(Lh,{listRef:u,listId:o,value:y,mixed:h,disabled:g,customStylesEnabled:C,customStyles:x,customStylesLoading:v,style:{top:k.top,left:k.left,minWidth:k.width},onSelect:P=>{e.setParagraphStyle(P),f(!1)},onSelectCustom:P=>{e.applyCustomParagraphStyle(P),f(!1)}})}):null]});return i.jsx(qn,{label:r("commandParagraphStyle"),children:S})}function vR({commands:e,queries:t,disabled:n,onMenuClose:r}){const o=!!(n||!t.isVisualMode()),a=t.isParagraphStyleMixed(),s=a?null:t.getParagraphStyle(),u=t.customParagraphStylesEnabled(),d=u?t.getCustomParagraphStyles():[],f=u&&t.isCustomParagraphStylesLoading();return i.jsx(Lh,{menu:!0,value:s,mixed:a,disabled:o,customStylesEnabled:u,customStyles:d,customStylesLoading:f,onSelect:g=>{e.setParagraphStyle(g),r==null||r()},onSelectCustom:g=>{e.openCustomParagraphStyleDialog(g),r==null||r()},onAddNew:()=>{e.openCustomParagraphStyleDialog(),r==null||r()}})}const kR={menus:{format:{id:"format",labelKey:"menuFormat",ariaKey:"menuFormatAria"}},submenus:{paragraphStyles:{id:"paragraphStyles",labelKey:"menuParagraphStyles",ariaKey:"menuParagraphStylesAria",panel:vR,enabled:"isVisualMode"},font:{id:"font",labelKey:"menuFont",ariaKey:"menuFontAria"},highlightColor:{id:"highlightColor",labelKey:"commandHighlightColor",ariaKey:"commandHighlightColorAria",panel:hT,enabled:"isVisualMode"},paragraph:{id:"paragraph",labelKey:"menuParagraph",ariaKey:"menuParagraphAria"}},groups:{font:{id:"font",labelKey:"toolbarGroupFont"},align:{id:"align",labelKey:"toolbarGroupAlign"},paragraph:{id:"paragraph",labelKey:"toolbarGroupParagraph"}},items:{fontFamily:{id:"fontFamily",widget:rT,icon:Qb,labelKey:"commandFontFamily",ariaKey:"commandFontFamilyAria",enabled:"isVisualMode"},paragraphStyle:{id:"paragraphStyle",widget:wR,icon:hy,labelKey:"commandParagraphStyle",ariaKey:"commandParagraphStyleAria",enabled:"isVisualMode"},fontSize:{id:"fontSize",widget:pT,icon:ty,labelKey:"commandFontSize",ariaKey:"commandFontSizeAria",enabled:"isVisualMode"},fontProperties:{id:"fontProperties",command:"openFontProperties",icon:ey,labelKey:"commandFontProperties",ariaKey:"commandFontPropertiesAria",enabled:"isVisualMode"},customCss:{id:"customCss",command:"openCustomCss",icon:Yb,labelKey:"commandCustomCss",ariaKey:"commandCustomCssAria",enabled:"isVisualMode"},paragraphProperties:{id:"paragraphProperties",command:"openParagraphProperties",icon:Vf,labelKey:"commandParagraphProperties",ariaKey:"commandParagraphPropertiesAria",enabled:"isVisualMode"},imageProperties:{id:"imageProperties",command:"openImageProperties",icon:$f,labelKey:"menuImage",ariaKey:"menuImageAria",enabled:"isImageSelected"},fontColor:{id:"fontColor",widget:VP,icon:Of,labelKey:"commandFontColor",ariaKey:"commandFontColorAria",enabled:"isVisualMode"},highlightColor:{id:"highlightColor",widget:gT,icon:Kf,labelKey:"commandHighlightColor",ariaKey:"commandHighlightColorAria",enabled:"isVisualMode"},bold:{id:"bold",command:"toggleBold",icon:$b,labelKey:"commandBold",ariaKey:"commandBoldAria",active:"isBold",enabled:"isVisualMode",toggle:!0},italic:{id:"italic",command:"toggleItalic",icon:sy,labelKey:"commandItalic",ariaKey:"commandItalicAria",active:"isItalic",enabled:"isVisualMode",toggle:!0},underline:{id:"underline",command:"toggleUnderline",icon:Ay,labelKey:"commandUnderline",ariaKey:"commandUnderlineAria",active:"isUnderline",enabled:"isVisualMode",toggle:!0},strikethrough:{id:"strikethrough",command:"toggleStrikethrough",icon:Sy,labelKey:"commandStrikethrough",ariaKey:"commandStrikethroughAria",active:"isStrikethrough",enabled:"isVisualMode",toggle:!0},clearFormatting:{id:"clearFormatting",command:"clearFormatting",icon:Wb,labelKey:"commandClearFormatting",ariaKey:"commandClearFormattingAria",enabled:"hasTextSelection"},formatBrush:{id:"formatBrush",command:"toggleFormatBrush",icon:ny,labelKey:"commandFormatBrush",ariaKey:"commandFormatBrushAria",active:"isFormatBrushActive",enabled:"isVisualMode",toggle:!0},alignLeft:{id:"alignLeft",command:"alignLeft",icon:as,labelKey:"commandAlignLeft",ariaKey:"commandAlignLeftAria",active:"isAlignLeft",enabled:"isVisualMode"},alignCenter:{id:"alignCenter",command:"alignCenter",icon:is,labelKey:"commandAlignCenter",ariaKey:"commandAlignCenterAria",active:"isAlignCenter",enabled:"isVisualMode"},alignRight:{id:"alignRight",command:"alignRight",icon:ss,labelKey:"commandAlignRight",ariaKey:"commandAlignRightAria",active:"isAlignRight",enabled:"isVisualMode"},alignJustify:{id:"alignJustify",command:"alignJustify",icon:Hf,labelKey:"commandAlignJustify",ariaKey:"commandAlignJustifyAria",active:"isAlignJustify",enabled:"isVisualMode"},indent:{id:"indent",command:"indent",icon:ay,labelKey:"commandIndent",ariaKey:"commandIndentAria",enabled:"isVisualMode"},outdent:{id:"outdent",command:"outdent",icon:fy,labelKey:"commandOutdent",ariaKey:"commandOutdentAria",enabled:"canOutdent"},bulletList:{id:"bulletList",command:"toggleBulletList",icon:zf,labelKey:"commandBulletList",ariaKey:"commandBulletListAria",active:"isBulletList",enabled:"isVisualMode",toggle:!0},numberedList:{id:"numberedList",command:"toggleNumberedList",icon:Uf,labelKey:"commandNumberedList",ariaKey:"commandNumberedListAria",active:"isNumberedList",enabled:"isVisualMode",toggle:!0}}},SR={menus:{insert:{id:"insert",labelKey:"menuInsert",ariaKey:"menuInsertAria"}},submenus:{insertPage:{id:"insertPage",labelKey:"menuInsertPage",ariaKey:"menuInsertPageAria",enabled:"hasSelectedPage"}},groups:{insert:{id:"insert",labelKey:"toolbarGroupInsert"}},items:{link:{id:"link",command:"openLinkDialog",icon:cy,labelKey:"commandLink",ariaKey:"commandLinkAria",enabled:"isVisualMode",active:"isLink",toggle:!0},bookmark:{id:"bookmark",command:"openBookmarkDialog",icon:Ub,labelKey:"commandBookmark",ariaKey:"commandBookmarkAria",enabled:"isVisualMode"},image:{id:"image",command:"openImageDialog",icon:$f,labelKey:"commandImage",ariaKey:"commandImageAria",enabled:"isVisualMode"},pageBackgroundImage:{id:"pageBackgroundImage",command:"openPageBackgroundImage",icon:Uo,labelKey:"commandPageBackgroundImage",ariaKey:"commandPageBackgroundImageAria",enabled:"canInsertPageBackgroundImage"},paragraphBackgroundImage:{id:"paragraphBackgroundImage",command:"openParagraphBackgroundImage",icon:Vf,labelKey:"commandParagraphBackgroundImage",ariaKey:"commandParagraphBackgroundImageAria",enabled:"canInsertParagraphBackgroundImage"},audio:{id:"audio",command:"openAudioDialog",icon:Kb,labelKey:"commandAudio",ariaKey:"commandAudioAria",enabled:"isVisualMode"},youtube:{id:"youtube",command:"openYoutubeDialog",icon:Dy,labelKey:"commandYoutube",ariaKey:"commandYoutubeAria",enabled:"isVisualMode"},horizontalRule:{id:"horizontalRule",command:"insertHorizontalRule",icon:oy,labelKey:"commandHorizontalRule",ariaKey:"commandHorizontalRuleAria",enabled:"isVisualMode"},pageBreak:{id:"pageBreak",command:"insertPageBreak",icon:py,labelKey:"commandPageBreak",ariaKey:"commandPageBreakAria",enabled:"isVisualMode"},insertPageBefore:{id:"insertPageBefore",command:"insertPageBefore",icon:Uo,labelKey:"commandInsertPageBefore",ariaKey:"commandInsertPageBeforeAria",enabled:"hasSelectedPage"},insertPageAfter:{id:"insertPageAfter",command:"insertPageAfter",icon:Uo,labelKey:"commandInsertPageAfter",ariaKey:"commandInsertPageAfterAria",enabled:"hasSelectedPage"}}},AR={menus:{table:{id:"table",labelKey:"menuTable",ariaKey:"menuTableAria"}},submenus:{insertRow:{id:"insertRow",labelKey:"menuInsertRow",ariaKey:"menuInsertRowAria",enabled:"isInTable"},insertColumn:{id:"insertColumn",labelKey:"menuInsertColumn",ariaKey:"menuInsertColumnAria",enabled:"isInTable"}},groups:{table:{id:"table",labelKey:"toolbarGroupTable"}},items:{table:{id:"table",command:"openTableDialog",icon:Cm,labelKey:"commandTable",ariaKey:"commandTableAria",enabled:"isVisualMode"},insertRowBelow:{id:"insertRowBelow",command:"insertRowBelow",icon:Ml,labelKey:"commandInsertRowBelow",ariaKey:"commandInsertRowBelowAria",enabled:"isInTable"},insertRowBefore:{id:"insertRowBefore",command:"insertRowBefore",icon:Ml,labelKey:"commandInsertRowBefore",ariaKey:"commandInsertRowBeforeAria",enabled:"isInTable"},deleteRow:{id:"deleteRow",command:"deleteRow",icon:Ml,labelKey:"commandDeleteRow",ariaKey:"commandDeleteRowAria",enabled:"isInTable"},insertColumnAfter:{id:"insertColumnAfter",command:"insertColumnAfter",icon:_l,labelKey:"commandInsertColumnAfter",ariaKey:"commandInsertColumnAfterAria",enabled:"isInTable"},insertColumnBefore:{id:"insertColumnBefore",command:"insertColumnBefore",icon:_l,labelKey:"commandInsertColumnBefore",ariaKey:"commandInsertColumnBeforeAria",enabled:"isInTable"},deleteColumn:{id:"deleteColumn",command:"deleteColumn",icon:_l,labelKey:"commandDeleteColumn",ariaKey:"commandDeleteColumnAria",enabled:"isInTable"},mergeCells:{id:"mergeCells",command:"mergeCells",icon:dy,labelKey:"commandMergeCells",ariaKey:"commandMergeCellsAria",enabled:"canMergeCells"},unmergeCells:{id:"unmergeCells",command:"unmergeCells",icon:Ty,labelKey:"commandUnmergeCells",ariaKey:"commandUnmergeCellsAria",enabled:"canUnmergeCells"},tableProperties:{id:"tableProperties",command:"openTableProperties",icon:Cm,labelKey:"commandTableProperties",ariaKey:"commandTablePropertiesAria",enabled:"isInTable"},cellProperties:{id:"cellProperties",command:"openCellProperties",icon:Vb,labelKey:"commandCellProperties",ariaKey:"commandCellPropertiesAria",enabled:"isInTable"},rowProperties:{id:"rowProperties",command:"openRowProperties",icon:wy,labelKey:"commandRowProperties",ariaKey:"commandRowPropertiesAria",enabled:"isInTable"}}},PR={menus:{help:{id:"help",labelKey:"menuHelp",ariaKey:"menuHelpAria"}},groups:{},items:{editorHelp:{id:"editorHelp",command:"openHelp",icon:El,labelKey:"commandEditorHelp",ariaKey:"commandEditorHelpAria"},keyboardShortcuts:{id:"keyboardShortcuts",command:"openKeyboardShortcuts",icon:El,labelKey:"commandKeyboardShortcuts",ariaKey:"commandKeyboardShortcutsAria"},about:{id:"about",command:"openAbout",icon:El,labelKey:"commandAbout",ariaKey:"commandAboutAria"}}},TR=["getStarted","file","edit","insert","format","table","view","keyboard"],zc=[{id:"getStarted",category:"getStarted",titleKey:"helpTopicGetStartedTitle",bodyKey:"helpTopicGetStartedBody",keywordsKey:"helpTopicGetStartedKeywords",related:["switchModes","searchHelp","keyboardShortcuts"]},{id:"switchModes",category:"getStarted",titleKey:"helpTopicSwitchModesTitle",bodyKey:"helpTopicSwitchModesBody",keywordsKey:"helpTopicSwitchModesKeywords",related:["getStarted","preview"]},{id:"searchHelp",category:"getStarted",titleKey:"helpTopicSearchHelpTitle",bodyKey:"helpTopicSearchHelpBody",keywordsKey:"helpTopicSearchHelpKeywords",related:["getStarted","keyboardShortcuts"]},{id:"saveDocument",category:"file",titleKey:"helpTopicSaveDocumentTitle",bodyKey:"helpTopicSaveDocumentBody",keywordsKey:"helpTopicSaveDocumentKeywords",related:["openDocument","printDocument"]},{id:"openDocument",category:"file",titleKey:"helpTopicOpenDocumentTitle",bodyKey:"helpTopicOpenDocumentBody",keywordsKey:"helpTopicOpenDocumentKeywords",related:["saveDocument","printDocument"]},{id:"printDocument",category:"file",titleKey:"helpTopicPrintDocumentTitle",bodyKey:"helpTopicPrintDocumentBody",keywordsKey:"helpTopicPrintDocumentKeywords",related:["saveDocument","preview"]},{id:"undoRedo",category:"edit",titleKey:"helpTopicUndoRedoTitle",bodyKey:"helpTopicUndoRedoBody",keywordsKey:"helpTopicUndoRedoKeywords",related:["keyboardShortcuts","clearFormatting"]},{id:"pageProperties",category:"edit",titleKey:"helpTopicPagePropertiesTitle",bodyKey:"helpTopicPagePropertiesBody",keywordsKey:"helpTopicPagePropertiesKeywords",related:["insertPage","deletePage"]},{id:"deletePage",category:"edit",titleKey:"helpTopicDeletePageTitle",bodyKey:"helpTopicDeletePageBody",keywordsKey:"helpTopicDeletePageKeywords",related:["insertPage","pageProperties"]},{id:"insertTable",category:"insert",titleKey:"helpTopicInsertTableTitle",bodyKey:"helpTopicInsertTableBody",keywordsKey:"helpTopicInsertTableKeywords",related:["tableRowsColumns","mergeCells"]},{id:"insertImage",category:"insert",titleKey:"helpTopicInsertImageTitle",bodyKey:"helpTopicInsertImageBody",keywordsKey:"helpTopicInsertImageKeywords",related:["insertLink","pageProperties"]},{id:"insertLink",category:"insert",titleKey:"helpTopicInsertLinkTitle",bodyKey:"helpTopicInsertLinkBody",keywordsKey:"helpTopicInsertLinkKeywords",related:["insertBookmark","insertImage"]},{id:"insertBookmark",category:"insert",titleKey:"helpTopicInsertBookmarkTitle",bodyKey:"helpTopicInsertBookmarkBody",keywordsKey:"helpTopicInsertBookmarkKeywords",related:["insertLink"]},{id:"insertMedia",category:"insert",titleKey:"helpTopicInsertMediaTitle",bodyKey:"helpTopicInsertMediaBody",keywordsKey:"helpTopicInsertMediaKeywords",related:["insertImage","insertLink"]},{id:"pageBreak",category:"insert",titleKey:"helpTopicPageBreakTitle",bodyKey:"helpTopicPageBreakBody",keywordsKey:"helpTopicPageBreakKeywords",related:["insertPage","printDocument"]},{id:"insertPage",category:"insert",titleKey:"helpTopicInsertPageTitle",bodyKey:"helpTopicInsertPageBody",keywordsKey:"helpTopicInsertPageKeywords",related:["pageBreak","deletePage"]},{id:"insertComment",category:"insert",titleKey:"helpTopicInsertCommentTitle",bodyKey:"helpTopicInsertCommentBody",keywordsKey:"helpTopicInsertCommentKeywords",related:["preview"]},{id:"formatFont",category:"format",titleKey:"helpTopicFormatFontTitle",bodyKey:"helpTopicFormatFontBody",keywordsKey:"helpTopicFormatFontKeywords",related:["paragraphStyles","textColor","keyboardShortcuts"]},{id:"paragraphStyles",category:"format",titleKey:"helpTopicParagraphStylesTitle",bodyKey:"helpTopicParagraphStylesBody",keywordsKey:"helpTopicParagraphStylesKeywords",related:["formatFont","alignLists"]},{id:"textColor",category:"format",titleKey:"helpTopicTextColorTitle",bodyKey:"helpTopicTextColorBody",keywordsKey:"helpTopicTextColorKeywords",related:["formatFont","clearFormatting"]},{id:"alignLists",category:"format",titleKey:"helpTopicAlignListsTitle",bodyKey:"helpTopicAlignListsBody",keywordsKey:"helpTopicAlignListsKeywords",related:["paragraphStyles","formatFont"]},{id:"clearFormatting",category:"format",titleKey:"helpTopicClearFormattingTitle",bodyKey:"helpTopicClearFormattingBody",keywordsKey:"helpTopicClearFormattingKeywords",related:["formatFont","customCss"]},{id:"customCss",category:"format",titleKey:"helpTopicCustomCssTitle",bodyKey:"helpTopicCustomCssBody",keywordsKey:"helpTopicCustomCssKeywords",related:["formatFont","clearFormatting"]},{id:"tableRowsColumns",category:"table",titleKey:"helpTopicTableRowsColumnsTitle",bodyKey:"helpTopicTableRowsColumnsBody",keywordsKey:"helpTopicTableRowsColumnsKeywords",related:["insertTable","mergeCells","keyboardShortcuts"]},{id:"mergeCells",category:"table",titleKey:"helpTopicMergeCellsTitle",bodyKey:"helpTopicMergeCellsBody",keywordsKey:"helpTopicMergeCellsKeywords",related:["insertTable","tableRowsColumns"]},{id:"customizeToolbar",category:"view",titleKey:"helpTopicCustomizeToolbarTitle",bodyKey:"helpTopicCustomizeToolbarBody",keywordsKey:"helpTopicCustomizeToolbarKeywords",related:["zoom","fullscreen"]},{id:"zoom",category:"view",titleKey:"helpTopicZoomTitle",bodyKey:"helpTopicZoomBody",keywordsKey:"helpTopicZoomKeywords",related:["preview","fullscreen"]},{id:"darkMode",category:"view",titleKey:"helpTopicDarkModeTitle",bodyKey:"helpTopicDarkModeBody",keywordsKey:"helpTopicDarkModeKeywords",related:["customizeToolbar"]},{id:"preview",category:"view",titleKey:"helpTopicPreviewTitle",bodyKey:"helpTopicPreviewBody",keywordsKey:"helpTopicPreviewKeywords",related:["printDocument","switchModes"]},{id:"fullscreen",category:"view",titleKey:"helpTopicFullscreenTitle",bodyKey:"helpTopicFullscreenBody",keywordsKey:"helpTopicFullscreenKeywords",related:["zoom","keyboardShortcuts"]},{id:"ruler",category:"view",titleKey:"helpTopicRulerTitle",bodyKey:"helpTopicRulerBody",keywordsKey:"helpTopicRulerKeywords",related:["pageProperties","alignLists"]},{id:"keyboardShortcuts",category:"keyboard",titleKey:"helpTopicKeyboardShortcutsTitle",bodyKey:"helpTopicKeyboardShortcutsBody",keywordsKey:"helpTopicKeyboardShortcutsKeywords",related:["getStarted","undoRedo","formatFont"]}],Tf=Object.fromEntries(zc.map(e=>[e.id,e]));function Bh(e){return e.trim().toLowerCase().split(/\s+/).filter(Boolean)}function RR(e,t){const n=Bh(t);if(n.length===0)return 1;const r=e.title.toLowerCase(),o=e.body.toLowerCase(),a=e.keywords.toLowerCase(),s=`${r} ${o} ${a}`;let u=0;for(const d of n)r.includes(d)&&(u+=30),a.includes(d)&&(u+=20),o.includes(d)&&(u+=10),s.includes(d)&&(u+=5);return u}function DR(e,t){return Bh(t).length===0?e:e.map(r=>({entry:r,score:RR(r,t)})).filter(({score:r})=>r>0).sort((r,o)=>o.score-r.score||r.entry.title.localeCompare(o.entry.title)).map(({entry:r})=>r)}const jR={menus:{view:{id:"view",labelKey:"menuView",ariaKey:"menuViewAria"}},submenus:{toolbar:{id:"toolbar",labelKey:"menuToolbar",ariaKey:"menuToolbarAria"},toolbarPosition:{id:"toolbarPosition",labelKey:"menuToolbarPosition",ariaKey:"menuToolbarPositionAria"},zoom:{id:"zoom",labelKey:"menuZoom",ariaKey:"menuZoomAria"}},groups:{view:{id:"view",labelKey:"toolbarGroupView"},fullscreen:{id:"fullscreen",labelKey:"toolbarGroupFullscreen"}},items:{visual:{id:"visual",command:"setVisualMode",icon:Ry,labelKey:"modeVisual",ariaKey:"modeVisualAria",active:"isVisualMode"},html:{id:"html",command:"setHtmlMode",icon:iy,labelKey:"modeHtml",ariaKey:"modeHtmlAria",active:"isHtmlMode"},customizeToolbar:{id:"customizeToolbar",command:"openCustomizeToolbar",icon:Xb,labelKey:"commandCustomizeToolbar",ariaKey:"commandCustomizeToolbarAria"},toolbarPositionTop:{id:"toolbarPositionTop",command:"setToolbarPositionTop",labelKey:"toolbarPositionTop",ariaKey:"toolbarPositionTopAria",active:"isToolbarPositionTop"},toolbarPositionLeft:{id:"toolbarPositionLeft",command:"setToolbarPositionLeft",labelKey:"toolbarPositionLeft",ariaKey:"toolbarPositionLeftAria",active:"isToolbarPositionLeft"},toolbarPositionRight:{id:"toolbarPositionRight",command:"setToolbarPositionRight",labelKey:"toolbarPositionRight",ariaKey:"toolbarPositionRightAria",active:"isToolbarPositionRight"},toolbarPositionBottom:{id:"toolbarPositionBottom",command:"setToolbarPositionBottom",labelKey:"toolbarPositionBottom",ariaKey:"toolbarPositionBottomAria",active:"isToolbarPositionBottom"},lightMode:{id:"lightMode",command:"setLightMode",icon:ly,labelKey:"modeLight",ariaKey:"modeLightAria",active:"isLightMode"},darkMode:{id:"darkMode",command:"setDarkMode",icon:Jb,labelKey:"modeDark",ariaKey:"modeDarkAria",active:"isDarkMode"},pageZoomFitWidth:{id:"pageZoomFitWidth",command:"setPageZoomFitWidth",labelKey:"pageZoomFitWidth",ariaKey:"pageZoomFitWidthAria",active:"isPageZoomFitWidth"},pageZoomFitPage:{id:"pageZoomFitPage",command:"setPageZoomFitPage",labelKey:"pageZoomFitPage",ariaKey:"pageZoomFitPageAria",active:"isPageZoomFitPage"},pageZoom50:{id:"pageZoom50",command:"setPageZoom50",labelKey:"pageZoom50",ariaKey:"pageZoom50Aria",active:"isPageZoom50"},pageZoom75:{id:"pageZoom75",command:"setPageZoom75",labelKey:"pageZoom75",ariaKey:"pageZoom75Aria",active:"isPageZoom75"},pageZoom100:{id:"pageZoom100",command:"setPageZoom100",labelKey:"pageZoom100",ariaKey:"pageZoom100Aria",active:"isPageZoom100"},pageZoom125:{id:"pageZoom125",command:"setPageZoom125",labelKey:"pageZoom125",ariaKey:"pageZoom125Aria",active:"isPageZoom125"},pageZoom150:{id:"pageZoom150",command:"setPageZoom150",labelKey:"pageZoom150",ariaKey:"pageZoom150Aria",active:"isPageZoom150"},pageZoom200:{id:"pageZoom200",command:"setPageZoom200",labelKey:"pageZoom200",ariaKey:"pageZoom200Aria",active:"isPageZoom200"},preview:{id:"preview",command:"openDocumentPreview",icon:gy,labelKey:"commandPreview",ariaKey:"commandPreviewAria"},ruler:{id:"ruler",command:"toggleRuler",icon:vy,labelKey:"commandRuler",ariaKey:"commandRulerAria",active:"isRulerVisible",toggle:!0},readAloud:{id:"readAloud",command:"toggleReadAloud",icon:xy,labelKey:"commandReadAloud",ariaKey:"commandReadAloudAria",active:"isReadingAloud",toggle:!0,enabled:"canReadAloud"},fullscreen:{id:"fullscreen",command:"toggleFullscreen",icon:ry,labelKey:"modeFullscreen",ariaKey:"modeFullscreenAria",active:"isFullscreen",toggle:!0}}};function IR(...e){return{menus:Object.assign({},...e.map(t=>t.menus)),submenus:Object.assign({},...e.map(t=>t.submenus??{})),groups:Object.assign({},...e.map(t=>t.groups)),items:Object.assign({},...e.map(t=>t.items))}}const ER=IR(KA,cA,SR,AR,jR,kR,PR),_R={menus:[{id:"file",items:["save","open",Ce,"print"]},{id:"edit",items:["undo","redo",Ce,{submenu:"page",items:["pageProperties",Ce,"deletePage"]}]},{id:"view",items:["visual","html",Ce,{submenu:"toolbar",items:["customizeToolbar",Ce,{submenu:"toolbarPosition",items:["toolbarPositionTop","toolbarPositionLeft","toolbarPositionRight","toolbarPositionBottom"]}]},Ce,{submenu:"zoom",items:["pageZoomFitWidth","pageZoomFitPage",Ce,"pageZoom50","pageZoom75","pageZoom100","pageZoom125","pageZoom150","pageZoom200"]},Ce,"lightMode","darkMode",Ce,"toggleCommentsVisible","ruler","preview","readAloud","fullscreen"]},{id:"insert",items:["pageBreak",{submenu:"insertPage",items:["insertPageBefore","insertPageAfter"]},Ce,"table",Ce,"image","pageBackgroundImage","paragraphBackgroundImage","audio","youtube","horizontalRule",Ce,"link","bookmark",Ce,"insertComment"]},{id:"format",items:[{submenu:"paragraphStyles",items:[]},Ce,{submenu:"font",items:["fontProperties","customCss",Ce,{submenu:"highlightColor",items:[]},Ce,"bold","italic","underline","strikethrough"]},Ce,"clearFormatting",Ce,{submenu:"paragraph",items:["paragraphProperties",Ce,"alignLeft","alignCenter","alignRight","alignJustify",Ce,"indent","outdent",Ce,"bulletList","numberedList"]},Ce,"imageProperties"]},{id:"table",items:["table",Ce,{submenu:"insertRow",items:["insertRowBefore","insertRowBelow","deleteRow"]},{submenu:"insertColumn",items:["insertColumnBefore","insertColumnAfter","deleteColumn"]},Ce,"mergeCells","unmergeCells",Ce,"tableProperties","rowProperties","cellProperties"]},{id:"help",items:["editorHelp","keyboardShortcuts",Ce,"about"]}],iconGroups:[{id:"file",items:["save","open"]},{id:"print",items:["print"]},{id:"edit",items:["undo","redo"]},{id:"insert",items:["link","bookmark","image","table","horizontalRule","addComment"]},{id:"table",items:["mergeCells","unmergeCells"]},{id:"font",items:["fontFamily","paragraphStyle","fontSize","fontColor","highlightColor","customCss","formatBrush","bold","italic","underline","strikethrough","clearFormatting"]},{id:"align",items:["alignLeft","alignCenter","alignRight","alignJustify"]},{id:"paragraph",items:["indent","outdent","bulletList","numberedList"]},{id:"view",items:["visual","html","preview","readAloud","toggleCommentsVisible"]},{id:"fullscreen",items:["fullscreen"]}]},Rf={items:{addComment:{id:"addComment",command:"addComment",icon:xm,labelKey:"commandAddComment",ariaKey:"commandAddCommentAria",enabled:"canAddComment"},insertComment:{id:"insertComment",command:"addComment",icon:xm,labelKey:"commandInsertComment",ariaKey:"commandInsertCommentAria",enabled:"canAddComment"},toggleCommentsVisible:{id:"toggleCommentsVisible",command:"toggleCommentsVisible",icon:Gb,labelKey:"showComments",ariaKey:"toggleCommentsVisibleAria",toggle:!0,active:"areCommentsVisible"}}},MR=["addComment","insertComment","toggleCommentsVisible"],NR=new Set(["insert","view"]);function Fh(e,t){return t.disabled?!0:t.readOnly?t.enableComments?!MR.includes(e):!0:!1}function LR(e,t){return t.disabled?!0:t.readOnly?t.enableComments?!NR.has(e):!0:!1}function BR(e,t){const n=t?"hideComments":"showComments",r=Rf.items.toggleCommentsVisible;return{...e,items:{...e.items,...Rf.items,toggleCommentsVisible:r&&{...r,labelKey:n}}}}function FR(e){return{...e,menus:e.menus.map(t=>{if(t.id==="insert"){const n=[...t.items],r=n.findIndex(a=>Vn(a)&&a.submenu==="insertPage"),o=r===-1?n.length:r;return n.includes("insertComment")||n.splice(o,0,"insertComment"),{...t,items:n}}if(t.id==="view"){const n=[...t.items],r=n.indexOf("preview"),o=r===-1?n.length:r;return n.includes("toggleCommentsVisible")||n.splice(o,0,"toggleCommentsVisible"),{...t,items:n}}return t}),iconGroups:e.iconGroups.map(t=>t.id==="insert"&&!t.items.includes("addComment")?{...t,items:[...t.items,"addComment"]}:t.id==="view"&&!t.items.includes("toggleCommentsVisible")?{...t,items:[...t.items,"toggleCommentsVisible"]}:t)}}const Df={canUndo:"history",canRedo:"history",isBold:"marks",isItalic:"marks",isUnderline:"marks",isStrikethrough:"marks",getFontSize:"marks",getFontSizeUnit:"marks",isFontSizeMixed:"marks",getFontFamily:"marks",isFontFamilyMixed:"marks",getFontColor:"marks",isFontColorMixed:"marks",getHighlightColor:"marks",isHighlightColorMixed:"marks",getParagraphStyle:"marks",isParagraphStyleMixed:"marks",isAlignLeft:"marks",isAlignCenter:"marks",isAlignRight:"marks",isAlignJustify:"marks",canOutdent:"marks",isBulletList:"marks",isNumberedList:"marks",isFormatBrushActive:"marks",isInTable:"table",canMergeCells:"table",canUnmergeCells:"table",hasTextSelection:"selection",isImageSelected:"selection",isLink:"selection",canReadAloud:"selection",isReadingAloud:"selection"};function HR(){const e={history:0,marks:0,table:0,selection:0,chrome:0},t=new Map;function n(r,o){let a=t.get(r);return a||(a=new Set,t.set(r,a)),a.add(o),()=>{a==null||a.delete(o)}}return{subscribe:n,getSnapshot:r=>e[r],bump(r){e[r]+=1;const o=t.get(r);if(o)for(const a of o)a()}}}function Hh(e){const t=new Set;return e.active&&t.add(Df[e.active]??"chrome"),e.enabled&&t.add(Df[e.enabled]??"chrome"),t.size===0&&t.add("chrome"),[...t]}const zh=l.createContext(null);function zR({value:e,children:t}){return i.jsx(zh.Provider,{value:e,children:t})}function Oh(e){const t=l.useContext(zh),n=l.useMemo(()=>e.join("\0"),[e]),r=l.useMemo(()=>e,[n,e]);l.useSyncExternalStore(o=>{if(!t)return()=>{};const a=r.map(s=>t.subscribe(s,o));return()=>{for(const s of a)s()}},()=>{if(!t)return 0;let o=0;for(const a of r)o+=t.getSnapshot(a);return o},()=>{if(!t)return 0;let o=0;for(const a of r)o+=t.getSnapshot(a);return o})}const Pa="fullscreen";function OR(e){const t=[];let n=null;for(const r of e){const o=r.items.filter(a=>a!==Pa);o.length>0&&t.push({id:r.id,items:o}),r.items.includes(Pa)&&(n={id:Pa,items:[Pa]})}return{main:t,trailing:n}}const KR=l.memo(function({item:t,itemId:n,commands:r,queries:o,disabled:a,chromeLock:s}){const u=Y(),d=l.useMemo(()=>Hh(t),[t]);if(Oh(d),!t.icon||!t.command)return null;const f=t.icon,g=t.command,h=t.enabled?!o[t.enabled]():!1,y=t.active?o[t.active]():void 0;return i.jsx(qn,{label:t.tooltip??Zn(u,t),children:i.jsx("button",{type:"button",className:ae.iconButton,"aria-label":ts(u,t),"aria-pressed":y,disabled:a||(s?Fh(n,s):!1)||h,onPointerDown:b=>b.preventDefault(),onMouseDown:b=>b.preventDefault(),onClick:()=>{Uc(r,g)},children:i.jsx(f,{className:ae.icon})})})});function $R({groups:e,catalog:t,commands:n,queries:r,disabled:o,chromeLock:a}){const s=Y(),{main:u,trailing:d}=OR(e),f=g=>{const h=t.groups[g.id];return i.jsx("div",{className:ae.iconGroup,role:"group","aria-label":h?Zn(s,h):void 0,"data-toolbar-group":g.id,children:g.items.map(y=>{const b=t.items[y];if(!b)return null;const C=b.enabled?!r[b.enabled]():!1;if(b.widget){const x=b.widget;return i.jsx(x,{commands:n,queries:r,disabled:o||C},y)}return!b.icon||!b.command?null:i.jsx(KR,{itemId:y,item:b,commands:n,queries:r,disabled:o,chromeLock:a},y)})},g.id)};return i.jsxs("div",{className:ae.iconNav,role:"toolbar","aria-label":s("toolbarAria"),children:[u.length>0?i.jsx("div",{className:ae.iconNavMain,children:u.map(f)}):null,d?i.jsx("div",{className:ae.iconNavEnd,children:f(d)}):null]})}const UR=["--wysiwyg-menu-color","--wysiwyg-menu-background","--wysiwyg-menu-font-size","--wysiwyg-menu-font-family"];function VR(e){const t={};for(const n of UR){const r=getComputedStyle(e).getPropertyValue(n).trim();if(r){t[n]=r;continue}let o=e;for(;o;){const a=o.style.getPropertyValue(n).trim();if(a){t[n]=a;break}o=o.parentElement}}return t}function WR({menus:e,catalog:t,commands:n,queries:r,disabled:o,chromeLock:a,compact:s,openMenuId:u,onOpenMenuIdChange:d}){const f=Y(),[g,h]=l.useState(!1),[y,b]=l.useState({}),C=l.useRef(null),x=l.useRef(null),v=l.useRef(null),k=l.useRef(null),S=l.useCallback(()=>{h(!1),d(null)},[d]);l.useLayoutEffect(()=>{!g||!C.current||b(VR(C.current))},[g]),l.useEffect(()=>{var T;g&&((T=v.current)==null||T.focus())},[g]),l.useEffect(()=>{if(!g)return;const T=document.body.style.overflow;return document.body.style.overflow="hidden",()=>{document.body.style.overflow=T}},[g]),l.useEffect(()=>{if(!g)return;const T=R=>{var A;if(R.key==="Escape"){if(R.preventDefault(),R.stopPropagation(),u){d(null);return}S(),(A=x.current)==null||A.focus()}},D=R=>{var A;k.current&&!k.current.contains(R.target)&&(S(),(A=x.current)==null||A.focus())};return document.addEventListener("keydown",T,!0),document.addEventListener("pointerdown",D),()=>{document.removeEventListener("keydown",T,!0),document.removeEventListener("pointerdown",D)}},[g,u,d,S]);const P=T=>e.map(D=>{const R=t.menus[D.id];return R?i.jsx(ZR,{def:R,itemIds:D.items,catalog:t,commands:n,queries:r,disabled:o,chromeLock:a,variant:T,open:(T==="overlay"||!g)&&u===D.id,onOpenChange:A=>d(A?D.id:null),onItemRun:T==="overlay"?()=>{var A;S(),(A=x.current)==null||A.focus()}:void 0},`${T}-${D.id}`):null});return i.jsxs("div",{className:ae.menuBar,ref:C,children:[i.jsx(qn,{label:f("brandMarkAria"),children:i.jsx("span",{className:ae.brandMark,role:"img","aria-label":f("brandMarkAria"),children:i.jsx(Zb,{className:ae.brandMarkIcon})})}),i.jsx("div",{className:ae.menuBarCompact,hidden:s===void 0?void 0:!s,children:i.jsx(qn,{label:f("menuHamburgerAria"),children:i.jsx("button",{ref:x,type:"button",className:`${ae.menuButton} ${ae.hamburgerButton}`,"aria-haspopup":"dialog","aria-expanded":g,"aria-label":f("menuHamburgerAria"),disabled:o||(a==null?void 0:a.readOnly)&&!(a!=null&&a.enableComments),onClick:()=>{if(g){S();return}d(null),h(!0)},children:i.jsx(uy,{className:ae.icon})})})}),i.jsx("div",{className:ae.menuBarDesktop,hidden:s===void 0?void 0:s,children:P("dropdown")}),g?i.jsx(we,{children:i.jsx("div",{className:ae.toolbar,"data-menu-overlay-portal":"",style:y,children:i.jsxs("div",{ref:k,className:ae.menuOverlay,role:"dialog","aria-modal":"true","aria-label":f("menuOverlayAria"),children:[i.jsxs("div",{className:ae.menuOverlayHeader,children:[i.jsx("span",{className:ae.menuOverlayTitle,children:f("menuOverlayAria")}),i.jsx("button",{ref:v,type:"button",className:ae.iconButton,"aria-label":f("menuCloseAria"),onClick:()=>{var T;S(),(T=x.current)==null||T.focus()},children:i.jsx(Je,{className:ae.icon})})]}),i.jsx("div",{className:ae.menuOverlayBody,children:P("overlay")})]})})}):null]})}function ns(e,t){var n,r;if(Un(e))return!1;if(Vn(e)){const o=(n=t.submenus)==null?void 0:n[e.submenu];return o?o.panel?!0:e.items.some(a=>ns(a,t)):!1}return!!((r=t.items[e])!=null&&r.command)}function GR(e,t,n){if(!Un(e[t])||!e.slice(t+1).some(a=>ns(a,n)))return!1;let o=!1;for(let a=t-1;a>=0;a--){const s=e[a];if(Un(s)){o=!0;continue}if(ns(s,n))return!o}return!1}function ZR({def:e,itemIds:t,catalog:n,commands:r,queries:o,disabled:a,chromeLock:s,variant:u,open:d,onOpenChange:f,onItemRun:g}){const h=Y(),y=l.useRef(null),b=u==="overlay"?`overlay-${e.id}-menu`:`${e.id}-menu`,[C,x]=l.useState(null);l.useEffect(()=>{d||x(null)},[d]),l.useEffect(()=>{if(!d||u==="overlay")return;const k=P=>{y.current&&!y.current.contains(P.target)&&f(!1)},S=P=>{if(P.key==="Escape"){if(P.preventDefault(),P.stopPropagation(),C){x(null);return}f(!1)}};return document.addEventListener("pointerdown",k),document.addEventListener("keydown",S,!0),()=>{document.removeEventListener("pointerdown",k),document.removeEventListener("keydown",S,!0)}},[d,C,f,u]);const v=()=>{f(!1),g==null||g()};return i.jsxs("div",{className:ae.menuWrap,ref:y,children:[i.jsx("button",{type:"button",className:ae.menuButton,"aria-haspopup":"menu","aria-expanded":d,"aria-controls":b,"aria-label":ts(h,e),disabled:a||(s?LR(e.id,s):!1),onClick:()=>f(!d),children:Zn(h,e)}),d?i.jsx("div",{className:ae.menu,role:"menu",id:b,onMouseDown:k=>k.preventDefault(),children:i.jsx(Kh,{entries:t,catalog:n,commands:r,queries:o,disabled:a,chromeLock:s,variant:u,onClose:v,openSubmenuId:C,onOpenSubmenuIdChange:x})}):null]})}function Kh({entries:e,catalog:t,commands:n,queries:r,disabled:o,chromeLock:a,variant:s,onClose:u,openSubmenuId:d,onOpenSubmenuIdChange:f}){return i.jsx(i.Fragment,{children:e.map((g,h)=>{if(Un(g))return GR(e,h,t)?i.jsx("div",{role:"separator",className:ae.menuSeparator},`separator-${h}`):null;if(Vn(g))return i.jsx(YR,{entry:g,catalog:t,commands:n,queries:r,disabled:o,chromeLock:a,variant:s,onClose:u,open:d===g.submenu,onOpenChange:b=>f==null?void 0:f(b?g.submenu:null)},`submenu-${g.submenu}-${h}`);const y=t.items[g];return!y||!y.command?null:i.jsx(qR,{item:y,commands:n,queries:r,disabled:o,chromeLock:a,onClose:u},g)})})}function qR({item:e,commands:t,queries:n,disabled:r,chromeLock:o,onClose:a}){const s=Y(),u=l.useMemo(()=>Hh(e),[e]);if(Oh(u),!e.command)return null;const d=e.icon,f=e.command,g=e.active?n[e.active]():void 0,h=e.enabled?!n[e.enabled]():!1,y=e.toggle?"menuitemcheckbox":e.active?"menuitemradio":"menuitem";return i.jsxs("button",{type:"button",role:y,className:ae.menuItem,"aria-checked":g,disabled:r||(o?Fh(e.id,o):!1)||h,onClick:()=>{a(),Uc(t,f)},children:[d?i.jsx(d,{className:ae.icon}):null,Zn(s,e)]})}function YR({entry:e,catalog:t,commands:n,queries:r,disabled:o,chromeLock:a,variant:s,onClose:u,open:d,onOpenChange:f}){var R;const g=Y(),h=l.useRef(null),y=l.useRef(null),[b,C]=l.useState(null),x=(R=t.submenus)==null?void 0:R[e.submenu],v=s==="overlay"?`overlay-${e.submenu}-submenu`:`${e.submenu}-submenu`,k=x==null?void 0:x.panel,S=x!=null&&x.enabled?!r[x.enabled]():!1,P=s==="overlay";if(l.useEffect(()=>{d||C(null)},[d]),!x||!k&&!e.items.some(A=>ns(A,t)))return null;const T=A=>{(A.key==="ArrowRight"||A.key==="Enter"||A.key===" ")&&(A.preventDefault(),A.stopPropagation(),f(!0),requestAnimationFrame(()=>{var B;const E=(B=y.current)==null?void 0:B.querySelector('[role="menuitem"], [role="menuitemcheckbox"], [role="menuitemradio"], [role="option"]');E==null||E.focus()}))},D=A=>{var E;A.key==="ArrowLeft"&&(A.preventDefault(),A.stopPropagation(),f(!1),(E=h.current)==null||E.focus())};return i.jsxs("div",{className:ae.submenuWrap,onMouseEnter:P?void 0:()=>f(!0),onMouseLeave:P?void 0:()=>f(!1),children:[i.jsx("button",{ref:h,type:"button",role:"menuitem",className:`${ae.menuItem} ${ae.submenuTrigger}`,"aria-haspopup":"menu","aria-expanded":d,"aria-controls":v,"aria-label":ts(g,x),disabled:o||S||(a==null?void 0:a.readOnly)&&!(a!=null&&a.enableComments),onClick:()=>f(P?!d:!0),onKeyDown:T,children:Zn(g,x)}),d?i.jsx("div",{ref:y,className:`${ae.menu} ${ae.submenu}`,role:"menu",id:v,"aria-label":ts(g,x),onMouseDown:A=>A.preventDefault(),onKeyDown:D,children:k?i.jsx(k,{commands:n,queries:r,disabled:o||S,onMenuClose:u}):i.jsx(Kh,{entries:e.items,catalog:t,commands:n,queries:r,disabled:o,chromeLock:a,variant:s,onClose:u,openSubmenuId:b,onOpenSubmenuIdChange:C})}):null]})}const Oc=l.memo(function({catalog:t,layout:n,commands:r,queries:o,queryRevisions:a,disabled:s,chromeLock:u,menuVisible:d=!0,toolbarVisible:f=!0,compact:g,position:h="top"}){const[y,b]=l.useState(null);if(!d&&!f)return null;const C=i.jsxs("div",{className:ae.toolbar,"data-compact":g?"":void 0,"data-toolbar-position":h,children:[d?i.jsx(WR,{menus:n.menus,catalog:t,commands:r,queries:o,disabled:s,chromeLock:u,compact:g,openMenuId:y,onOpenMenuIdChange:b}):null,f?i.jsx($R,{groups:n.iconGroups,catalog:t,commands:r,queries:o,disabled:s,chromeLock:u}):null]});return a?i.jsx(zR,{value:a,children:C}):C});function XR(e,t){return t?e:{...e,menus:e.menus.map(n=>n.id==="insert"?{...n,items:n.items.filter(r=>!(Vn(r)&&r.submenu==="insertPage"))}:n.id==="edit"?{...n,items:n.items.map(r=>{if(!Vn(r)||r.submenu!=="page")return r;let o=r.items.filter(a=>a!=="deletePage");return o.at(-1)===Ce&&(o=o.slice(0,-1)),{...r,items:o}})}:n)}}function ii(e){return Hp(rt(e))}const JR=1.5,Xl=384;function QR(e,t=16){return e>0?JR*t:0}function $h(e,t,n=16){const r=QR(t,n);if(!ii(e))return Xl+r;const o=rt(e),a=lo(o,!1);return a?Fn(a.height,Xl)+r:Xl+r}function Ta(e,t){const n=[0];for(let r=0;r<e;r+=1)n.push(n[r]+t(r));return n}function eD(){const e=new Map;return{get(t,n){return e.get(t)??$h(n,t)},set(t,n){n>0&&e.set(t,n)},clear(){e.clear()},invalidateFrom(t){for(const n of[...e.keys()])n>=t&&e.delete(n)}}}const tD=2;function nD(e,t,n){if(n<=0)return 0;let r=0,o=n-1,a=0;for(;r<=o;){const s=r+o>>1;(t[s+1]??0)>e?(a=s,o=s-1):r=s+1}return a}function rD(e,t,n){if(n<=0)return-1;let r=0,o=n-1,a=n-1;for(;r<=o;){const s=r+o>>1;(t[s]??0)<e?(a=s,r=s+1):o=s-1}return a}function jf(e,t,n,r,o,a,s){if(r<=0)return{startIndex:0,endIndex:-1,topSpacerHeight:0,bottomSpacerHeight:0};const u=n[r]??0;if(u<=t)return{startIndex:0,endIndex:r-1,topSpacerHeight:0,bottomSpacerHeight:0};const d=e+t,f=nD(e,n,r),g=rD(d,n,r);let h=Math.max(0,f-o),y=Math.min(r-1,g+o);s&&(h=Math.min(h,a),y=Math.max(y,a));const b=n[h]??0,C=u-(n[y+1]??u);return{startIndex:h,endIndex:y,topSpacerHeight:b,bottomSpacerHeight:C}}function oD({scrollElementRef:e,pageCount:t,getRowHeight:n,overscan:r=tD,activePageIndex:o,pinActivePage:a=!0}){const s=l.useRef(n);s.current=n;const u=l.useRef(new Map),[d,f]=l.useState(0);l.useLayoutEffect(()=>{u.current.clear()},[t]);const g=l.useCallback(S=>{const P=u.current.get(S),T=s.current(S);return P!==void 0?Math.max(P,T):T},[d]),h=l.useMemo(()=>Ta(t,g),[t,g]),[y,b]=l.useState(()=>{const S=Ta(t,P=>s.current(P));return jf(0,300,S,t,r,o,a)}),C=l.useCallback(()=>{const S=e.current;if(!S||t<=0)return;const P=S.clientHeight>0?S.clientHeight:300,T=Ta(t,g);b(jf(S.scrollTop,P,T,t,r,o,a))},[o,r,t,a,g,e]);l.useLayoutEffect(()=>{C()},[C,h,o,t]),l.useLayoutEffect(()=>{const S=e.current;if(!S)return;const P=()=>C();S.addEventListener("scroll",P,{passive:!0});let T;return typeof ResizeObserver<"u"&&(T=new ResizeObserver(()=>C()),T.observe(S)),C(),()=>{S.removeEventListener("scroll",P),T==null||T.disconnect()}},[e,C]);const x=l.useCallback((S,P)=>{if(P<=0)return;const T=u.current.get(S);T!==void 0&&Math.abs(T-P)<1||(u.current.set(S,P),f(D=>D+1))},[]),v=l.useCallback(S=>{const P=e.current;if(!P||S<0||S>=t)return;const T=Ta(t,g);P.scrollTop=T[S]??0,C()},[t,g,e,C]),k=l.useMemo(()=>{if(y.endIndex<y.startIndex)return[];const S=[];for(let P=y.startIndex;P<=y.endIndex;P+=1)S.push(P);return S},[y.endIndex,y.startIndex]);return{...y,visibleIndices:k,scrollToIndex:v,notifyRowMeasured:x}}function Nu(){return{firstLineIndentPx:0,leftIndentPx:0,rightIndentPx:0,mixed:!1}}function rs(e){const t=An(e);if(t.length===0)return Nu();let n=null,r=null,o=null,a=!1;for(const s of t){const u=s.style.textIndent,d=s.style.marginLeft,f=s.style.marginRight,g=u?Fn(u,0):0,h=d?Fn(d,0):0,y=f?Fn(f,0):0;n===null?(n=g,r=h,o=y):(Math.abs(n-g)>1||Math.abs((r??0)-h)>1||Math.abs((o??0)-y)>1)&&(a=!0)}return{firstLineIndentPx:n??0,leftIndentPx:r??0,rightIndentPx:o??0,mixed:a}}function iD(e){var r;const t=(r=window.getSelection())==null?void 0:r.getRangeAt(0);if(!t)return null;let n=t.startContainer;for(n.nodeType===Node.TEXT_NODE&&(n=n.parentNode);n&&n!==e&&n!==document.body;){if(n instanceof HTMLElement){const o=n.tagName.toLowerCase();if(["p","h1","h2","h3","h4","h5","h6","li","blockquote","div"].includes(o))return n}n=n.parentNode}return null}function aD(e,t){return Qn(e,()=>{let n=Cr(e);if(n.length===0){const a=iD(e);a&&(n=[a])}if(n.length===0)return!1;const r=t.unit??"in";let o=!1;for(const a of n){if(t.firstLineIndentPx!==void 0)if(Math.abs(t.firstLineIndentPx)<.5)a.style.textIndent&&(a.style.removeProperty("text-indent"),o=!0);else{const s=Ie(zl(t.firstLineIndentPx,r));a.style.textIndent!==s&&(a.style.textIndent=s,o=!0)}if(t.leftIndentPx!==void 0)if(t.leftIndentPx<=.5)a.style.marginLeft&&(a.style.removeProperty("margin-left"),o=!0);else{const s=Ie(zl(t.leftIndentPx,r));a.style.marginLeft!==s&&(a.style.marginLeft=s,o=!0)}if(t.rightIndentPx!==void 0)if(t.rightIndentPx<=.5)a.style.marginRight&&(a.style.removeProperty("margin-right"),o=!0);else{const s=Ie(zl(t.rightIndentPx,r));a.style.marginRight!==s&&(a.style.marginRight=s,o=!0)}vt(a)}return o})}const Uh=24,qo=48;function Vh(e,t){const n=ci(rt(t));return{pageWidthPx:e.offsetWidth,pageHeightPx:e.offsetHeight,marginsPx:{top:Fn(n.top,0),right:Fn(n.right,0),bottom:Fn(n.bottom,0),left:Fn(n.left,0)}}}function sD(e,t){const n=Object.keys(t);return Object.keys(e).length!==n.length?!1:n.every(r=>{const o=e[Number(r)],a=t[Number(r)];return(o==null?void 0:o.pageWidthPx)===a.pageWidthPx&&(o==null?void 0:o.pageHeightPx)===a.pageHeightPx&&(o==null?void 0:o.marginsPx.top)===a.marginsPx.top&&(o==null?void 0:o.marginsPx.right)===a.marginsPx.right&&(o==null?void 0:o.marginsPx.bottom)===a.marginsPx.bottom&&(o==null?void 0:o.marginsPx.left)===a.marginsPx.left})}function lD(e,t,n,r,o=!0,a=1){const[s,u]=l.useState({}),[d,f]=l.useState(Nu()),g=l.useCallback(y=>s[y]??null,[s]),h=l.useCallback(()=>{const y=e.current;if(!o||!y)return;const b={};for(const x of n){const v=nt(y,x);if(!v)continue;const k=t[x]??t[0]??"";b[x]=Vh(v,k)}u(x=>{const v={...x,...b};return sD(x,v)?x:v});const C=nt(y,r());C&&f(rs(C))},[e,o,r,n,t]);return l.useLayoutEffect(()=>{if(!o)return;const y=requestAnimationFrame(h);return()=>cancelAnimationFrame(y)},[o,r,n,t,a,h]),l.useLayoutEffect(()=>{if(!o||typeof ResizeObserver>"u")return;const y=e.current;if(!y)return;const b=new ResizeObserver(()=>h());for(const C of n){const x=nt(y,C);x&&b.observe(x)}return()=>b.disconnect()},[e,o,n,h]),l.useLayoutEffect(()=>{if(!o)return;const y=()=>{const b=e.current;if(!b)return;const C=nt(b,r());C&&f(rs(C))};return document.addEventListener("selectionchange",y),()=>document.removeEventListener("selectionchange",y)},[e,o,r]),{pageGeometries:s,geometryForPage:g,indentState:d,refresh:h}}const cD="_rulerRoot_j57vt_5",uD="_horizontalRulerGroup_j57vt_22",dD="_horizontalRulerTrack_j57vt_28",mD="_horizontalRulerShelf_j57vt_42",fD="_horizontalInner_j57vt_51",pD="_dragEdgeLeft_j57vt_63",gD="_dragEdgeRight_j57vt_73",hD="_dragEdgeActive_j57vt_85",bD="_verticalRuler_j57vt_92",yD="_verticalInner_j57vt_102",xD="_dragEdgeTop_j57vt_114",CD="_dragEdgeBottom_j57vt_124",wD="_dragEdgeActiveV_j57vt_136",vD="_tickH_j57vt_143",kD="_tickV_j57vt_152",SD="_tickLabelH_j57vt_161",AD="_tickLabelV_j57vt_175",PD="_arrowIconWrapper_j57vt_192",TD="_arrowDown_j57vt_203",RD="_arrowGlyph_j57vt_211",DD="_arrowActive_j57vt_220",jD="_arrowUp_j57vt_225",ID="_rulerTooltip_j57vt_249",Pe={rulerRoot:cD,horizontalRulerGroup:uD,horizontalRulerTrack:dD,horizontalRulerShelf:mD,horizontalInner:fD,dragEdgeLeft:pD,dragEdgeRight:gD,dragEdgeActive:hD,verticalRuler:bD,verticalInner:yD,dragEdgeTop:xD,dragEdgeBottom:CD,dragEdgeActiveV:wD,tickH:vD,tickV:kD,tickLabelH:SD,tickLabelV:AD,arrowIconWrapper:PD,arrowDown:TD,arrowGlyph:RD,arrowActive:DD,arrowUp:jD,rulerTooltip:ID},Jl=({type:e,active:t=!1,className:n="",style:r,title:o,"aria-label":a,onPointerDown:s,"data-testid":u})=>{const d=e==="down"?Pe.arrowDown:Pe.arrowUp;return i.jsx("div",{className:`${Pe.arrowIconWrapper} ${d} ${t?Pe.arrowActive:""} ${n}`,style:r,title:o,"aria-label":a||o,onPointerDown:s,"data-testid":u,children:i.jsx("div",{className:Pe.arrowGlyph})})};function Wh(){const[e,t]=l.useState(null),[n,r]=l.useState(null),o=l.useCallback((a,s,u)=>{s.preventDefault(),s.stopPropagation(),t(a);const d=Number.isFinite(s.clientX)?s.clientX:0,f=Number.isFinite(s.clientY)?s.clientY:0,g=s.altKey,h=b=>{var k;const C=Number.isFinite(b.clientX)?b.clientX:d,x=Number.isFinite(b.clientY)?b.clientY:f,v=u.updateDragState(C,x,b.altKey);r(v),(k=u.onPreview)==null||k.call(u,v)},y=b=>{const C=Number.isFinite(b.clientX)?b.clientX:d,x=Number.isFinite(b.clientY)?b.clientY:f,v=u.updateDragState(C,x,b.altKey);window.removeEventListener("pointermove",h),window.removeEventListener("pointerup",y),window.removeEventListener("pointercancel",y),t(null),r(null),u.onCommit(v)};r(u.updateDragState(d,f,g)),window.addEventListener("pointermove",h),window.addEventListener("pointerup",y),window.addEventListener("pointercancel",y)},[]);return{activeTarget:e,dragPreview:n,startPointerDrag:o}}const ED=({geometry:e,indentState:t,unit:n="in",zoomScale:r=1,onMarginChange:o,onMarginPreview:a,onIndentChange:s})=>{const u=Y(),{activeTarget:d,dragPreview:f,startPointerDrag:g}=Wh(),h=(e==null?void 0:e.pageWidthPx)??816,y=(e==null?void 0:e.marginsPx.left)??96,b=(e==null?void 0:e.marginsPx.right)??96,C=r>0?r:1,x=(f==null?void 0:f.marginLeft)??y,v=(f==null?void 0:f.marginRight)??b,k=(f==null?void 0:f.firstLineIndentPx)??t.firstLineIndentPx,S=(f==null?void 0:f.leftIndentPx)??t.leftIndentPx,P=(f==null?void 0:f.rightIndentPx)??t.rightIndentPx,T=Math.max(0,h-x-v),D=!t.mixed,R=l.useMemo(()=>Mp(h,x,n),[h,x,n]),A=l.useCallback((M,O)=>{const G=Number.isFinite(O.clientX)?O.clientX:0;Number.isFinite(O.clientY)&&O.clientY,g(M.type,O,{updateDragState:(q,re,Z)=>{const X=(q-G)/C;let ne=0;const ce={target:M.type,marginLeft:y,marginRight:b,firstLineIndentPx:t.firstLineIndentPx,leftIndentPx:t.leftIndentPx,rightIndentPx:t.rightIndentPx,measurementPx:0,clientX:q,clientY:re};if(M.type==="margin-left"){const J=Math.max(0,Math.min(h-b-qo,M.startMarginPx+X)),I=dr(J,n,Z,0);ce.marginLeft=I,ne=I}else if(M.type==="margin-right"){const J=Math.max(0,Math.min(h-y-qo,M.startMarginPx-X)),I=dr(J,n,Z,0);ce.marginRight=I,ne=I}else if(M.type==="first-line-indent"){const J=-M.startLeftIndentPx,I=h-y-b-M.startLeftIndentPx-qo,se=Math.max(J,Math.min(I,M.startFirstLinePx+X)),fe=dr(se,n,Z,0);ce.firstLineIndentPx=fe,ne=fe}else if(M.type==="left-indent"){const J=Math.max(0,M.startLeftIndentPx+X),I=dr(J,n,Z,0);ce.leftIndentPx=I,ce.firstLineIndentPx=M.startFirstLinePx,ne=I}else if(M.type==="right-indent"){const J=Math.max(0,M.startRightIndentPx-X),I=dr(J,n,Z,0);ce.rightIndentPx=I,ne=I}return ce.measurementPx=ne,ce},onPreview:q=>{M.type==="margin-left"?a==null||a({left:q.marginLeft}):M.type==="margin-right"&&(a==null||a({right:q.marginRight}))},onCommit:q=>{M.type==="margin-left"?o==null||o({left:q.marginLeft}):M.type==="margin-right"?o==null||o({right:q.marginRight}):M.type==="first-line-indent"?s==null||s({firstLineIndentPx:q.firstLineIndentPx}):M.type==="left-indent"?s==null||s({leftIndentPx:q.leftIndentPx}):M.type==="right-indent"&&(s==null||s({rightIndentPx:q.rightIndentPx}))}})},[y,b,h,n,C,t,o,a,s,g]),E=x+S,B=E+k,z=h-v-P,_=h*C;return i.jsxs("div",{className:`${Pe.rulerRoot} ${Pe.horizontalRulerGroup}`,style:{width:`${_}px`},"data-testid":"horizontal-ruler",children:[i.jsxs("div",{className:Pe.horizontalRulerTrack,children:[i.jsxs("div",{className:Pe.horizontalInner,style:{left:`${x*C}px`,width:`${T*C}px`},"data-testid":"ruler-printable-area",children:[i.jsx("div",{className:`${Pe.dragEdgeLeft} ${d==="margin-left"?Pe.dragEdgeActive:""}`,title:u("rulerMarginLeft"),"aria-label":u("rulerMarginLeft"),"data-testid":"ruler-margin-splitter-left",onPointerDown:M=>A({type:"margin-left",startMarginPx:y},M)}),i.jsx("div",{className:`${Pe.dragEdgeRight} ${d==="margin-right"?Pe.dragEdgeActive:""}`,title:u("rulerMarginRight"),"aria-label":u("rulerMarginRight"),"data-testid":"ruler-margin-splitter-right",onPointerDown:M=>A({type:"margin-right",startMarginPx:b},M)})]}),R.map((M,O)=>i.jsxs(l.Fragment,{children:[i.jsx("div",{className:Pe.tickH,style:{left:`${M.positionPx*C}px`,height:`${M.height}px`}}),M.label?i.jsx("span",{className:Pe.tickLabelH,style:{left:`${M.positionPx*C}px`},children:M.label}):null]},O)),D?i.jsxs(i.Fragment,{children:[i.jsx(Jl,{type:"down",style:{left:`${B*C}px`},active:d==="first-line-indent",title:u("rulerFirstLineIndent"),"aria-label":u("rulerFirstLineIndent"),"data-testid":"ruler-first-line-indent",onPointerDown:M=>A({type:"first-line-indent",startFirstLinePx:t.firstLineIndentPx,startLeftIndentPx:t.leftIndentPx},M)}),i.jsx(Jl,{type:"up",style:{left:`${E*C}px`},active:d==="left-indent",title:u("rulerLeftIndent"),"aria-label":u("rulerLeftIndent"),"data-testid":"ruler-left-indent",onPointerDown:M=>A({type:"left-indent",startLeftIndentPx:t.leftIndentPx,startFirstLinePx:t.firstLineIndentPx},M)}),i.jsx(Jl,{type:"up",style:{left:`${z*C}px`},active:d==="right-indent",title:u("rulerRightIndent"),"aria-label":u("rulerRightIndent"),"data-testid":"ruler-right-indent",onPointerDown:M=>A({type:"right-indent",startRightIndentPx:t.rightIndentPx},M)})]}):null]}),i.jsx("div",{className:Pe.horizontalRulerShelf,"aria-hidden":!0}),f?i.jsx("div",{className:Pe.rulerTooltip,style:{left:f.clientX,top:f.clientY},"data-testid":"ruler-drag-tooltip",children:_p(f.measurementPx,n)}):null]})},_D=({geometry:e,unit:t="in",zoomScale:n=1,onMarginChange:r,onMarginPreview:o})=>{const a=Y(),{activeTarget:s,dragPreview:u,startPointerDrag:d}=Wh(),f=(e==null?void 0:e.pageHeightPx)??1056,g=(e==null?void 0:e.marginsPx.top)??96,h=(e==null?void 0:e.marginsPx.bottom)??96,y=n>0?n:1,b=(u==null?void 0:u.marginTop)??g,C=(u==null?void 0:u.marginBottom)??h,x=Math.max(0,f-b-C),v=l.useMemo(()=>Mp(f,b,t),[f,b,t]),k=l.useCallback((S,P)=>{Number.isFinite(P.clientX)&&P.clientX;const T=Number.isFinite(P.clientY)?P.clientY:0;d(S.type,P,{updateDragState:(D,R,A)=>{const E=(R-T)/y,B={target:S.type,marginTop:g,marginBottom:h,measurementPx:0,clientX:D,clientY:R};if(S.type==="margin-top"){const z=Math.max(0,Math.min(f-h-qo,S.startMarginPx+E)),_=dr(z,t,A,0);B.marginTop=_,B.measurementPx=_}else if(S.type==="margin-bottom"){const z=Math.max(0,Math.min(f-g-qo,S.startMarginPx-E)),_=dr(z,t,A,0);B.marginBottom=_,B.measurementPx=_}return B},onPreview:D=>{S.type==="margin-top"?o==null||o({top:D.marginTop}):S.type==="margin-bottom"&&(o==null||o({bottom:D.marginBottom}))},onCommit:D=>{S.type==="margin-top"?r==null||r({top:D.marginTop}):S.type==="margin-bottom"&&(r==null||r({bottom:D.marginBottom}))}})},[g,h,f,t,y,r,o,d]);return i.jsxs("div",{className:`${Pe.rulerRoot} ${Pe.verticalRuler}`,style:{height:`${f}px`},"data-testid":"vertical-ruler",children:[i.jsxs("div",{className:Pe.verticalInner,style:{top:`${b}px`,height:`${x}px`},"data-testid":"ruler-printable-area-vertical",children:[i.jsx("div",{className:`${Pe.dragEdgeTop} ${s==="margin-top"?Pe.dragEdgeActiveV:""}`,title:a("rulerMarginTop"),"aria-label":a("rulerMarginTop"),"data-testid":"ruler-margin-splitter-top",onPointerDown:S=>k({type:"margin-top",startMarginPx:g},S)}),i.jsx("div",{className:`${Pe.dragEdgeBottom} ${s==="margin-bottom"?Pe.dragEdgeActiveV:""}`,title:a("rulerMarginBottom"),"aria-label":a("rulerMarginBottom"),"data-testid":"ruler-margin-splitter-bottom",onPointerDown:S=>k({type:"margin-bottom",startMarginPx:h},S)})]}),v.map((S,P)=>i.jsxs(l.Fragment,{children:[i.jsx("div",{className:Pe.tickV,style:{top:`${S.positionPx}px`,width:`${S.height}px`}}),S.label?i.jsx("span",{className:Pe.tickLabelV,style:{top:`${S.positionPx}px`},children:S.label}):null]},P)),u?i.jsx("div",{className:Pe.rulerTooltip,style:{left:u.clientX,top:u.clientY},"data-testid":"ruler-drag-tooltip",children:_p(u.measurementPx,t)}):null]})},MD="_root_ofshu_1",ND="_fullscreen_ofshu_36",LD="_exitFullscreen_ofshu_48",BD="_exitFullscreenIcon_ofshu_79",FD="_menuChrome_ofshu_94",HD="_body_ofshu_106",zD="_iconChrome_ofshu_136",OD="_workspace_ofshu_181",KD="_workspacePageSized_ofshu_193",$D="_workspaceWithRuler_ofshu_197",UD="_pageCanvasViewport_ofshu_201",VD="_multiPageRulerLayer_ofshu_211",WD="_multiPageContainer_ofshu_234",GD="_pageZoomContent_ofshu_244",ZD="_htmlFileDropOverlay_ofshu_262",qD="_surface_ofshu_276",YD="_visual_ofshu_283",XD="_pageBlock_ofshu_341",JD="_pageBlockFluid_ofshu_348",QD="_pageSurfaceRulerGutter_ofshu_357",ej="_pageSurface_ofshu_357",tj="_htmlModeShell_ofshu_378",nj="_html_ofshu_262",xe={root:MD,fullscreen:ND,exitFullscreen:LD,exitFullscreenIcon:BD,menuChrome:FD,body:HD,iconChrome:zD,workspace:OD,workspacePageSized:KD,workspaceWithRuler:$D,pageCanvasViewport:UD,multiPageRulerLayer:VD,multiPageContainer:WD,pageZoomContent:GD,htmlFileDropOverlay:ZD,surface:qD,visual:YD,pageBlock:XD,pageBlockFluid:JD,pageSurfaceRulerGutter:QD,pageSurface:ej,htmlModeShell:tj,html:nj};function Gh(e){if(e!==1)return{zoom:e,"--page-zoom":String(e)}}function Zh({showRulers:e,geometry:t,indentState:n,rulerUnit:r,zoomScale:o,onMarginChange:a,onMarginPreview:s,onIndentChange:u}){if(!e)return null;const d=Uh;return i.jsx("div",{className:xe.multiPageRulerLayer,children:i.jsxs("div",{className:xe.pageBlock,children:[i.jsx("div",{className:xe.pageSurfaceRulerGutter,style:{width:`${d}px`,flex:`0 0 ${d}px`},"aria-hidden":!0}),i.jsx(ED,{geometry:t,indentState:n,unit:r,zoomScale:o,onMarginChange:a,onMarginPreview:s,onIndentChange:u})]})})}function qh({showVerticalRuler:e=!1,pageSized:t=!1,geometry:n,rulerUnit:r,zoomScale:o,onMarginChange:a,onMarginPreview:s,children:u,pageBlockStyle:d,pageBlockRef:f}){const g=o>0?o:1,h=e?Uh/g:0;return i.jsxs("div",{ref:f,className:`${xe.pageBlock} ${t?"":xe.pageBlockFluid}`,style:d,children:[i.jsx("div",{className:xe.pageSurfaceRulerGutter,style:{width:`${h}px`,flex:`0 0 ${h}px`},children:e?i.jsx(_D,{geometry:n,unit:r,zoomScale:o,onMarginChange:a,onMarginPreview:s}):null}),u]})}function rj({showRulers:e,geometry:t,indentState:n,rulerUnit:r,zoomScale:o,onMarginChange:a,onMarginPreview:s,onIndentChange:u,children:d}){return i.jsxs("div",{style:{display:"flex",flexDirection:"column",alignItems:e?"center":"stretch",width:"100%",height:"100%",minHeight:"100%",position:"relative"},children:[i.jsx(Zh,{showRulers:e,geometry:t,indentState:n,rulerUnit:r,zoomScale:o,onMarginChange:a,onMarginPreview:s,onIndentChange:u}),i.jsx("div",{className:xe.pageZoomContent,style:Gh(o),children:i.jsx(qh,{showVerticalRuler:e,pageSized:e,geometry:t,rulerUnit:r,zoomScale:o,onMarginChange:a,onMarginPreview:s,children:d})})]})}const oj=l.memo(function({index:t,pageHtml:n,showVerticalRuler:r,pageSized:o,geometry:a,rulerUnit:s,zoomScale:u,placeholder:d,disabled:f,visualEditorAria:g,onActivate:h,onPointerDown:y,onPageChange:b,onPageFlush:C,suppressPageFlushRef:x,onMeasured:v,onMarginChange:k,onMarginPreview:S,onMouseUp:P,onContextMenu:T,onRulerRefresh:D}){const R=l.useRef(null),A=l.useRef(null),E=l.useRef(""),B=l.useRef(!1),z=l.useRef(C);z.current=C;const _=l.useRef(v);_.current=v,l.useLayoutEffect(()=>{const O=A.current;if(!O||!_.current)return;const G=()=>{var re;return(re=_.current)==null?void 0:re.call(_,t,O.offsetHeight)};if(G(),typeof ResizeObserver>"u")return;const q=new ResizeObserver(G);return q.observe(O),()=>q.disconnect()},[t,n,o,r]);const M=l.useCallback(O=>{R.current=O,O&&(E.current=O.innerHTML)},[]);return l.useLayoutEffect(()=>()=>{x!=null&&x.current||!B.current||!z.current||z.current(t,E.current)},[t,x]),i.jsx(qh,{pageBlockRef:A,showVerticalRuler:r,pageSized:o,geometry:a,rulerUnit:s,zoomScale:u,pageBlockStyle:{marginTop:t>0?"1.5rem":"0"},onMarginChange:O=>{k==null||k(t,O)},onMarginPreview:O=>{S==null||S(t,O)},children:i.jsx("div",{ref:M,className:`${xe.surface} ${xe.visual} ${o?xe.pageSurface:""}`,[ri]:"","data-page-index":t,contentEditable:!f,suppressContentEditableWarning:!0,role:"textbox","aria-multiline":"true","aria-label":g,"aria-disabled":f||void 0,"data-placeholder":t===0?d:void 0,onFocus:O=>{const G=O.currentTarget;ni(G),to(G),h(t)},onPointerDown:O=>y(t,O),onMouseUp:P,onContextMenu:T,onInput:O=>{const G=O.currentTarget;B.current=!0,E.current=G.innerHTML;const{absorbedBlocks:q}=ni(G);if(E.current=G.innerHTML,b(t,G.innerHTML),q.length>0){const re=q.length;requestAnimationFrame(()=>Wp(G,re))}D()}})})},ij);function ij(e,t){return e.index===t.index&&e.pageHtml===t.pageHtml&&e.showVerticalRuler===t.showVerticalRuler&&e.pageSized===t.pageSized&&e.geometry===t.geometry&&e.rulerUnit===t.rulerUnit&&e.zoomScale===t.zoomScale&&e.placeholder===t.placeholder&&e.disabled===t.disabled&&e.visualEditorAria===t.visualEditorAria}const aj=l.forwardRef(function({pages:t,activePageIndex:n,hasSelectedPage:r=!1,scrollRootRef:o,onActivePageIndexChange:a,onPageSelected:s,onPageChange:u,onPageFlush:d,suppressPageFlushRef:f,placeholder:g,disabled:h,rulerVisible:y=!0,rulerUnit:b="in",zoomScale:C=1,onMarginChange:x,onMarginPreview:v,onIndentChange:k,onBeforeInput:S,resolveEmbeddedImageDataUrl:P,hydrateEmbeddedImages:T,onPointerDown:D,onMouseUp:R,onContextMenu:A},E){const B=Y(),z=l.useRef(null),_=l.useRef(n);_.current=n;const M=l.useRef(S);M.current=S;const O=l.useRef(u);O.current=u;const G=l.useRef(d);G.current=d;const q=l.useRef(s);q.current=s;const re=l.useRef(D);re.current=D;const Z=l.useRef(x);Z.current=x;const X=l.useRef(v);X.current=v;const ne=l.useRef(null),ce=l.useRef([]),J=l.useRef(eD()),I=f,se=l.useCallback(()=>_.current,[]),fe=l.useCallback(V=>J.current.get(V,t[V]??""),[t]),{visibleIndices:L,topSpacerHeight:Be,bottomSpacerHeight:Ne,scrollToIndex:Fe,notifyRowMeasured:bt}=oD({scrollElementRef:o??z,pageCount:t.length,getRowHeight:fe,activePageIndex:n,pinActivePage:r}),{geometryForPage:lt,indentState:Ee,refresh:pe}=lD(z,t,L,se,!0,C),De=r?n:0,oe=t[De]??"",ve=l.useCallback(V=>ii(t[V]??""),[t]),je=y&&ii(oe),Le=l.useCallback(V=>{Fe(V),requestAnimationFrame(()=>{const ee=z.current;if(!ee)return;const ue=nt(ee,V);ue&&to(ue)})},[Fe]),Ve=l.useRef(Fe);Ve.current=Fe,l.useLayoutEffect(()=>{Ve.current(n)},[n,t.length]);const Ut=l.useCallback(V=>{var Ke;if(_.current=V,V!==n&&a(V),(Ke=q.current)==null||Ke.call(q,V),!L.includes(V)){Le(V);return}pe();const ee=z.current;if(!ee)return;const ue=nt(ee,V);ue&&requestAnimationFrame(()=>to(ue))},[n,a,pe,Le,L]);l.useImperativeHandle(E,()=>({getContainer:()=>z.current,getActivePageRoot:()=>{const V=z.current;return V?nt(V,_.current):null},getActivePageIndex:()=>_.current,flushPageHtml:V=>{var ue;const ee=z.current;return ee?((ue=nt(ee,V))==null?void 0:ue.innerHTML)??null:null},ensurePageMounted:V=>{Le(V)}}));const gn=l.useCallback((V,ee,ue,Ke)=>{const Vt=ln(ge(ue).body),er=ee===document.activeElement;(Ke!=null&&Ke.forceBodySync||!er)&&Qa(ee,Vt,{resolveDataUrl:P,hydrateEmbeddedImages:T}),pu(ee),ni(ee);const ct=hs(ee);gs(ee),co(ee,ue);const $e=gt(ee);if($e&&Kp(ee,$e),ct){const Se=ln(ge(ue).body);ee.innerHTML!==Se&&O.current(V,ee.innerHTML)}},[T,P]);l.useLayoutEffect(()=>{J.current.clear()},[t.length]),l.useLayoutEffect(()=>{const V=z.current;if(!V)return;const ee=ne.current,ue=ee===null||ee.length!==t.length;ue&&Ve.current(n);const Ke=new Set(ce.current),Vt=new Set(L);ue&&Vt.add(n);for(const ct of Vt){const $e=!Ke.has(ct),Se=t[ct]!==(ee==null?void 0:ee[ct]);if(!ue&&!$e&&!Se)continue;const We=nt(V,ct);We&&gn(ct,We,t[ct]??"",{forceBodySync:ue})}ne.current=t,ce.current=L,ue&&(I!=null&&I.current)&&(I.current=!1);const er=requestAnimationFrame(pe);return()=>cancelAnimationFrame(er)},[n,t,I,gn,pe,L]),l.useLayoutEffect(()=>{const V=z.current;if(!V)return;const ee=ue=>{var Ke;(Ke=M.current)==null||Ke.call(M,ue)};return V.addEventListener("beforeinput",ee),()=>V.removeEventListener("beforeinput",ee)},[]);const Qe=l.useCallback((V,ee)=>{var ue;Ut(V),(ue=re.current)==null||ue.call(re,ee)},[Ut]),wr=l.useCallback((V,ee)=>{O.current(V,ee)},[]),vr=l.useCallback((V,ee)=>{var ue;(ue=G.current)==null||ue.call(G,V,ee)},[]),He=l.useCallback((V,ee)=>{const ue=$h(t[V]??"",V),Ke=Math.max(ee,ue);J.current.set(V,Ke),bt(V,Ke)},[bt,t]),Jt=l.useCallback((V,ee)=>{var ue;(ue=Z.current)==null||ue.call(Z,V,ee)},[]),kr=l.useCallback((V,ee)=>{var ue;(ue=X.current)==null||ue.call(X,V,ee)},[]),et=B("visualEditorAria"),Sr=l.useMemo(()=>L.map(V=>i.jsx(oj,{index:V,pageHtml:t[V]??"",showVerticalRuler:je&&ve(V),pageSized:ve(V),geometry:lt(V),rulerUnit:b,zoomScale:C,placeholder:g,disabled:h,visualEditorAria:et,onActivate:Ut,onPointerDown:Qe,onPageChange:wr,onPageFlush:vr,suppressPageFlushRef:I,onMeasured:He,onMarginChange:Jt,onMarginPreview:kr,onMouseUp:R,onContextMenu:A,onRulerRefresh:pe},V)),[Ut,h,lt,Jt,kr,wr,vr,Qe,He,A,R,ve,t,g,pe,b,je,L,et,C]);return i.jsxs("div",{style:{display:"flex",flexDirection:"column",alignItems:je?"center":"stretch",width:"100%",height:"100%",minHeight:"100%",position:"relative"},children:[i.jsx(Zh,{showRulers:je,geometry:lt(De),indentState:Ee,rulerUnit:b,zoomScale:C,onMarginChange:V=>{x==null||x(De,V)},onMarginPreview:V=>{v==null||v(De,V)},onIndentChange:V=>{k==null||k(V)}}),i.jsx("div",{className:xe.pageZoomContent,style:Gh(C),children:i.jsxs("div",{ref:z,className:xe.multiPageContainer,style:{display:"flex",flexDirection:"column",alignItems:je?"center":"stretch",width:"100%",minHeight:je?void 0:"100%",position:"relative"},children:[Be>0?i.jsx("div",{"aria-hidden":!0,style:{height:Be,flexShrink:0}}):null,Sr,Ne>0?i.jsx("div",{"aria-hidden":!0,style:{height:Ne,flexShrink:0}}):null]})})]})});function sj(e,t,n){return r=>{const o=e();o&&n(o,t(),r)}}function lj(e,t,n,r){return o=>{const a=e();if(!a)return;const s=n(a,t(),o);r(s.pageHtml)}}function cj(e,t,n){return(r,o)=>{const a=e(r);a&&n(a,t(r),o)}}function uj(e,t,n,r){return(o,a)=>{const s=e(o);if(!s)return;const u=n(s,t(o),a);r(o,u.pageHtml)}}function If(e,t,n){return r=>{const o=e();o&&aD(o,{...r,unit:t})&&n(o)}}const dj="_field_1knrr_1",mj="_label_1knrr_8",fj="_button_1knrr_12",pj="_swatch_1knrr_37",gj="_swatchEmpty_1knrr_44",Fo={field:dj,label:mj,button:fj,swatch:pj,swatchEmpty:gj};function $t({label:e,noneLabel:t,value:n,mixed:r=!1,disabled:o,fallbackCustom:a,onChange:s}){const u=l.useId(),d=l.useRef(null),f=l.useRef(null),g=l.useRef(null),[h,y]=l.useState(!1),b=uo(h,f,g);l.useEffect(()=>{if(!h)return;const v=S=>{var T,D;const P=S.target;(T=d.current)!=null&&T.contains(P)||(D=g.current)!=null&&D.contains(P)||y(!1)},k=S=>{var P;S.key==="Escape"&&(S.preventDefault(),S.stopPropagation(),y(!1),(P=f.current)==null||P.focus())};return document.addEventListener("pointerdown",v),document.addEventListener("keydown",k,!0),()=>{document.removeEventListener("pointerdown",v),document.removeEventListener("keydown",k,!0)}},[h]);const C=`${Fo.swatch}${!n||r?` ${Fo.swatchEmpty}`:""}`,x=n&&!r?{backgroundColor:n}:void 0;return i.jsxs("div",{className:Fo.field,ref:d,children:[i.jsx("span",{className:Fo.label,children:e}),i.jsx("button",{ref:f,type:"button",className:Fo.button,"aria-label":e,"aria-haspopup":"listbox","aria-expanded":h,"aria-controls":h?u:void 0,disabled:o,onClick:()=>y(v=>!v),children:i.jsx("span",{className:C,style:x})}),h?i.jsx(we,{children:i.jsx("div",{ref:g,id:u,className:ur.popover,style:{top:b.top,left:b.left,zIndex:1400},children:i.jsx(Mu,{value:n,mixed:r,noneLabel:t,ariaLabel:e,disabled:o,fallbackCustom:a,onChange:s,onCommit:()=>y(!1)})})}):null]})}const Ql=[{id:"general",labelKey:"fontDialogTabGeneral",implemented:!0}],hj={bold:{label:"commandBold"},italic:{label:"commandItalic"},underline:{label:"commandUnderline"},strikethrough:{label:"commandStrikethrough"}};function Lu({tab:e,value:t,fonts:n,disabled:r,onTabChange:o,onChange:a}){const s=Y(),u=l.useId(),d=l.useId(),f=n??ep(),g=Ql.find(h=>h.id===e)??Ql[0];return i.jsxs(i.Fragment,{children:[i.jsx("div",{className:p.tabs,role:"tablist","aria-label":s("fontDialogTitle"),children:Ql.map(h=>i.jsx("button",{type:"button",className:p.tab,role:"tab","aria-selected":h.id===e,disabled:!h.implemented,onClick:()=>o(h.id),children:s(h.labelKey)},h.id))}),i.jsx("div",{className:p.body,role:"tabpanel",children:g.implemented?i.jsxs(i.Fragment,{children:[i.jsxs("div",{className:p.field,children:[i.jsx("label",{className:p.label,htmlFor:d,children:s("fontDialogFamily")}),i.jsx(Mh,{family:t.fontFamilyMixed?null:t.fontFamily,mixed:t.fontFamilyMixed,fonts:f,disabled:r,triggerId:d,onChange:h=>{a({...t,fontFamily:h,fontFamilyMixed:!1})}})]}),i.jsxs("div",{className:p.field,children:[i.jsx("label",{className:p.label,htmlFor:u,children:s("fontDialogSize")}),i.jsx("div",{className:p.sizeRow,children:i.jsx(Nh,{size:t.size,unit:t.unit,sizeInputId:u,disabled:r,onSizeChange:(h,y)=>{a({...t,size:h,unit:y})},onUnitChange:h=>{const y=t.size!==null?ap(t.size,t.unit,h,16,16):t.size;a({...t,size:y,unit:h})}})})]}),i.jsx("div",{className:p.field,children:i.jsx($t,{label:s("commandFontColor"),noneLabel:s("colorAutomatic"),value:t.fontColor,mixed:t.fontColorMixed,disabled:r,onChange:h=>{a({...t,fontColor:h,fontColorMixed:!1})}})}),i.jsx("div",{className:p.field,children:i.jsx($t,{label:s("commandHighlightColor"),noneLabel:s("colorNone"),value:t.highlightColor,mixed:t.highlightColorMixed,disabled:r,fallbackCustom:"#ffff00",onChange:h=>{a({...t,highlightColor:h,highlightColorMixed:!1})}})}),i.jsxs("fieldset",{className:p.marks,children:[i.jsx("legend",{className:p.label,children:s("fontDialogStyle")}),Kt.map(h=>i.jsxs("label",{className:p.mark,children:[i.jsx("input",{type:"checkbox",checked:t.marks[h],disabled:r,onChange:()=>{a({...t,marks:{...t.marks,[h]:!t.marks[h]}})}}),s(hj[h].label)]},h))]})]}):null})]})}function bj({open:e,tab:t,size:n,unit:r,marks:o,fontFamily:a=null,fontFamilyMixed:s=!1,fontColor:u,fontColorMixed:d=!1,highlightColor:f,highlightColorMixed:g=!1,fonts:h,disabled:y,onTabChange:b,onApply:C,onClose:x}){const v=Y(),k=l.useId(),S=l.useRef(null),[P,T]=l.useState({size:n,unit:r,marks:o,fontFamily:a,fontFamilyMixed:s,fontColor:u,highlightColor:f,fontColorMixed:d,highlightColorMixed:g});return l.useEffect(()=>{e&&T({size:n,unit:r,marks:o,fontFamily:a,fontFamilyMixed:s,fontColor:u,highlightColor:f,fontColorMixed:d,highlightColorMixed:g})},[e,n,r,o,a,s,u,d,f,g]),Ze(S,{open:e,onClose:x}),e?i.jsx(we,{children:i.jsx("div",{className:p.backdrop,role:"presentation",onMouseDown:x,children:i.jsxs("div",{ref:S,className:p.dialog,role:"dialog","aria-modal":"true","aria-labelledby":k,onMouseDown:D=>D.stopPropagation(),children:[i.jsx("h2",{className:p.header,id:k,children:v("fontDialogTitle")}),i.jsx(Lu,{tab:t,value:P,fonts:h,disabled:y,onTabChange:b,onChange:T}),i.jsxs("div",{className:p.actions,children:[i.jsx("button",{type:"button",className:p.action,onClick:x,children:v("fontDialogCancel")}),i.jsx("button",{type:"button",className:`${p.action} ${p.actionPrimary}`,disabled:y,onClick:()=>C(P),children:v("fontDialogOk")})]})]})})}):null}const yj={pt:"fontSizeUnitPt",px:"fontSizeUnitPx",em:"fontSizeUnitEm",rem:"fontSizeUnitRem","%":"fontSizeUnitPercent"};function Xe({label:e,value:t,disabled:n,allowNegative:r=!1,unitAria:o,inputId:a,onChange:s}){const u=Y(),d=l.useId(),f=a??d,g=(t==null?void 0:t.unit)??Jc,[h,y]=l.useState(()=>t?me(t.value):""),[b,C]=l.useState(!1);l.useEffect(()=>{b||y(t?me(t.value):"")},[t,b]);const x=v=>{const k=v.trim();if(!k){s(null),y("");return}const S=Xo(k,g,r);if(!S){y(t?me(t.value):"");return}s(S),y(me(S.value))};return i.jsxs("div",{className:p.lengthField,children:[i.jsx("label",{className:p.sideLabel,htmlFor:f,children:e}),i.jsxs("div",{className:p.lengthRow,children:[i.jsx("input",{id:f,className:p.lengthInput,value:h,disabled:n,inputMode:"decimal",onFocus:()=>C(!0),onBlur:()=>{C(!1),x(h)},onChange:v=>y(v.target.value),onKeyDown:v=>{v.key==="Enter"&&(v.preventDefault(),x(h),v.currentTarget.blur())}}),i.jsx("select",{className:p.lengthUnit,value:g,disabled:n,"aria-label":o??u("paragraphDialogLengthUnitAria"),onChange:v=>{const k=v.target.value;if(t){s({value:t.value,unit:k});return}if(h.trim()){const S=Xo(h,k,r);s(S)}},children:qc.map(v=>i.jsx("option",{value:v,children:u(yj[v])},v))})]})]})}function Bu({shadow:e,disabled:t,onChange:n}){const r=Y();return i.jsxs("div",{className:p.shadowGrid,children:[i.jsx(Xe,{label:r("paragraphDialogShadowOffsetX"),value:e.offsetX,disabled:t,allowNegative:!0,onChange:o=>{n({...e,offsetX:o??{value:0,unit:"px"}})}}),i.jsx(Xe,{label:r("paragraphDialogShadowOffsetY"),value:e.offsetY,disabled:t,allowNegative:!0,onChange:o=>{n({...e,offsetY:o??{value:0,unit:"px"}})}}),i.jsx(Xe,{label:r("paragraphDialogShadowBlur"),value:e.blur,disabled:t,onChange:o=>{n({...e,blur:o??{value:0,unit:"px"}})}}),i.jsx(Xe,{label:r("paragraphDialogShadowSpread"),value:e.spread,disabled:t,allowNegative:!0,onChange:o=>{n({...e,spread:o??{value:0,unit:"px"}})}}),i.jsx($t,{label:r("paragraphDialogShadowColor"),noneLabel:r("colorNone"),value:e.color,disabled:t,onChange:o=>{n({...e,color:o})}}),i.jsxs("label",{className:p.mark,children:[i.jsx("input",{type:"checkbox",checked:e.inset,disabled:t,onChange:()=>{n({...e,inset:!e.inset})}}),r("paragraphDialogShadowInset")]})]})}const Yh=[{id:"general",labelKey:"fontDialogTabGeneral",implemented:!0},{id:"spacing",labelKey:"paragraphDialogSpacing",implemented:!0},{id:"border",labelKey:"paragraphDialogTabBorder",implemented:!0},{id:"background",labelKey:"paragraphDialogTabBackground",implemented:!0},{id:"backgroundImage",labelKey:"pageDialogTabBackgroundImage",implemented:!0}],Xh=[{id:"spacing",labelKey:"paragraphDialogSpacing",implemented:!0},{id:"border",labelKey:"paragraphDialogTabBorder",implemented:!0},{id:"background",labelKey:"paragraphDialogTabBackground",implemented:!0},{id:"backgroundImage",labelKey:"pageDialogTabBackgroundImage",implemented:!0}],xj={fill:"imagePropertiesFitFill",contain:"imagePropertiesFitContain",cover:"imagePropertiesFitCover",none:"imagePropertiesFitNoneValue","scale-down":"imagePropertiesFitScaleDown"},Cj={center:"imagePropertiesPositionCenter",top:"imagePropertiesPositionTop",bottom:"imagePropertiesPositionBottom",left:"imagePropertiesPositionLeft",right:"imagePropertiesPositionRight","top left":"imagePropertiesPositionTopLeft","top right":"imagePropertiesPositionTopRight","bottom left":"imagePropertiesPositionBottomLeft","bottom right":"imagePropertiesPositionBottomRight"};function Jh({legendKey:e="imagePropertiesTabAdvanced",value:t,disabled:n,onChange:r}){const o=Y(),a=l.useId(),s=l.useId();return i.jsxs("fieldset",{className:p.group,children:[i.jsx("legend",{className:p.label,children:o(e)}),i.jsx(wj,{value:t.opacity,disabled:n,onChange:u=>{r({...t,opacity:u})}}),i.jsxs("div",{className:p.field,children:[i.jsx("label",{className:p.label,htmlFor:a,children:o("imagePropertiesFit")}),i.jsxs("select",{id:a,className:p.select,value:t.fit??"",disabled:n,onChange:u=>{const d=u.target.value;r({...t,fit:d||null})},children:[i.jsx("option",{value:"",children:o("imagePropertiesFitDefault")}),hu.map(u=>i.jsx("option",{value:u,children:o(xj[u])},u))]})]}),i.jsxs("div",{className:p.field,children:[i.jsx("label",{className:p.label,htmlFor:s,children:o("imagePropertiesPosition")}),i.jsxs("select",{id:s,className:p.select,value:t.position??"",disabled:n,onChange:u=>{r({...t,position:u.target.value||null})},children:[i.jsx("option",{value:"",children:o("imagePropertiesPositionDefault")}),bu.map(u=>i.jsx("option",{value:u,children:o(Cj[u])},u))]})]})]})}function wj({value:e,disabled:t,onChange:n}){const r=Y(),o=l.useId(),a=e===null?null:Ba(e),[s,u]=l.useState(()=>a===null?"":me(a)),[d,f]=l.useState(!1);l.useEffect(()=>{d||u(a===null?"":me(a))},[a,d]);const g=h=>{const y=h.trim();if(!y){n(null),u("");return}const b=Number(y.replace(",","."));if(!Number.isFinite(b)){u(a===null?"":me(a));return}const C=vp(b);n(C),u(me(Ba(C)))};return i.jsxs("div",{className:p.field,children:[i.jsx("label",{className:p.label,htmlFor:o,children:r("paragraphDialogOpacity")}),i.jsxs("div",{className:p.lengthRow,children:[i.jsx("input",{id:o,className:p.lengthInput,value:s,disabled:t,inputMode:"decimal",onFocus:()=>f(!0),onChange:h=>u(h.target.value),onBlur:()=>{f(!1),g(s)}}),i.jsx("span",{className:p.lengthUnit,"aria-hidden":"true",children:r("fontSizeUnitPercent")})]})]})}const vj={pt:"fontSizeUnitPt",px:"fontSizeUnitPx",em:"fontSizeUnitEm",rem:"fontSizeUnitRem","%":"fontSizeUnitPercent",pc:"fontSizeUnitPc"};function os({label:e,inputAria:t,value:n,disabled:r,onChange:o}){const a=Y(),s=l.useId(),u=l.useId(),d=l.useRef(null),f=l.useRef(null),g=l.useRef(null),h=(n==null?void 0:n.unit)??vw,[y,b]=l.useState(()=>n?me(n.value):""),[C,x]=l.useState(!1),[v,k]=l.useState(!1),S=uo(v,f,g,{matchAnchorWidth:!0,minWidth:72});l.useEffect(()=>{C||b(n?me(n.value):"")},[n,C]),l.useEffect(()=>{if(!v)return;const A=B=>{var _,M;const z=B.target;(_=d.current)!=null&&_.contains(z)||(M=g.current)!=null&&M.contains(z)||k(!1)},E=B=>{B.key==="Escape"&&(B.preventDefault(),B.stopPropagation(),k(!1))};return document.addEventListener("pointerdown",A),document.addEventListener("keydown",E,!0),()=>{document.removeEventListener("pointerdown",A),document.removeEventListener("keydown",E,!0)}},[v]);const P=A=>{const E=A.trim();if(!E){o(null),b("");return}const B=Hm(E,h);if(!B){b(n?me(n.value):"");return}o(B),b(me(B.value))},T=kw[h],D=(n==null?void 0:n.value)??null,R=v?i.jsx(we,{children:i.jsx("ul",{ref:g,className:Ge.list,role:"listbox",id:s,style:{top:S.top,left:S.left,minWidth:S.width},children:T.map(A=>i.jsx("li",{role:"presentation",children:i.jsx("button",{type:"button",className:Ge.option,role:"option","aria-selected":D===A,onMouseDown:E=>E.preventDefault(),onClick:()=>{o({value:A,unit:h}),b(me(A)),k(!1)},children:me(A)})},A))})}):null;return i.jsxs("div",{className:p.lengthField,children:[i.jsx("label",{className:p.sideLabel,htmlFor:u,children:e}),i.jsxs("div",{className:`${Ge.wrap} ${p.lengthRow}`,ref:d,children:[i.jsxs("div",{className:Ge.field,ref:f,children:[i.jsx("input",{id:u,className:Ge.input,value:y,disabled:r,"aria-label":t,"aria-autocomplete":"list","aria-expanded":v,"aria-controls":s,role:"combobox",inputMode:"decimal",onFocus:()=>x(!0),onBlur:()=>{x(!1),P(y)},onChange:A=>b(A.target.value),onKeyDown:A=>{A.key==="Enter"&&(A.preventDefault(),P(y),k(!1),A.currentTarget.blur()),A.key==="ArrowDown"&&(A.preventDefault(),k(!0))}}),i.jsx("button",{type:"button",className:Ge.toggle,tabIndex:-1,disabled:r,"aria-label":t,"aria-expanded":v,"aria-controls":s,onMouseDown:A=>A.preventDefault(),onClick:()=>k(A=>!A)})]}),i.jsxs("div",{className:Ge.field,children:[i.jsx("select",{className:Ge.unit,value:h,disabled:r,"aria-label":a("imagePropertiesSizeUnitAria"),onChange:A=>{const E=A.target.value;if(n){o({value:n.value,unit:E});return}y.trim()&&o(Hm(y,E))},children:Jp.map(A=>i.jsx("option",{value:A,children:a(vj[A])},A))}),i.jsx("span",{className:Ge.chevron,"aria-hidden":"true"})]}),R]})]})}const kj={empty:"imageDialogErrorEmpty",invalid:"imageDialogErrorInvalid"},Sj={type:"imageDialogErrorType",tooLarge:"imageDialogErrorTooLarge"};function Aj(e,t,n){return t&&n?"custom":e.startsWith("data:")?"file":e.trim()?"url":"file"}function Qh({src:e,disabled:t,customImagePicker:n,disableBuiltinSources:r=!1,onSrcChange:o,onCustomPick:a,onSourceChange:s}){const u=Y(),d=l.useId(),f=l.useId(),g=l.useRef(null),h=r&&!!n,[y,b]=l.useState(()=>Aj(e,r,n)),[C,x]=l.useState(()=>e.startsWith("data:")?"":e),[v,k]=l.useState(""),[S,P]=l.useState(null),[T,D]=l.useState(!1);l.useEffect(()=>{s==null||s(y)},[s,y]),l.useEffect(()=>{h&&b("custom")},[h]);const R=y==="file"&&e.startsWith("data:")?e:y==="url"?C:"",A=y==="custom"?null:dn(R),E=y==="custom"?null:y==="file"&&S?Sj[S]:A&&(y==="file"||C.trim().length>0)?kj[A]:null,B=()=>{t||!n||a==null||a()},z=_=>{var O;const M=(O=_.target.files)==null?void 0:O[0];M&&(D(!0),P(null),fw(M).then(G=>{k(M.name),b("file"),o(G),D(!1)},G=>{const q=G instanceof Error?G.message:"";k(""),b("file"),P(q==="tooLarge"||q==="type"?q:"type"),D(!1),g.current&&(g.current.value="")}))};return i.jsxs("fieldset",{className:p.group,children:[i.jsx("legend",{className:p.subLabel,children:u("imageDialogSource")}),h?null:i.jsxs("div",{className:p.sizeRow,role:"radiogroup","aria-label":u("imageDialogSource"),children:[i.jsx("button",{type:"button",className:p.action,role:"radio","aria-checked":y==="file",disabled:t,onClick:()=>b("file"),children:u("imageDialogFile")}),i.jsx("button",{type:"button",className:p.action,role:"radio","aria-checked":y==="url",disabled:t,onClick:()=>b("url"),children:u("imageDialogUrl")}),n?i.jsx("button",{type:"button",className:p.action,role:"radio","aria-checked":y==="custom",disabled:t,onClick:()=>b("custom"),children:n.text}):null]}),y==="file"?i.jsxs("div",{className:p.fileRow,children:[i.jsx("input",{ref:g,type:"file",accept:sw,hidden:!0,disabled:t,"aria-label":u("imageDialogChooseFile"),onChange:z}),i.jsx("button",{type:"button",className:p.action,disabled:t||T,onClick:()=>{var _;return(_=g.current)==null?void 0:_.click()},children:u("imageDialogChooseFile")}),v?i.jsx("span",{className:p.fileName,children:v}):null,e.startsWith("data:")&&!v?i.jsx("span",{className:p.fileName,children:u("pageBackgroundImageCurrent")}):null]}):null,y==="url"?i.jsxs("div",{className:p.field,children:[i.jsx("label",{className:p.label,htmlFor:d,children:u("imageDialogUrl")}),i.jsx("input",{id:d,className:p.textInput,value:C,disabled:t,"aria-invalid":E!==null,"aria-describedby":E?f:void 0,onChange:_=>{const M=_.target.value;x(M),o(M.trim())}})]}):null,(h||y==="custom")&&n?i.jsxs("div",{className:p.field,children:[i.jsx("p",{className:p.emptyHint,children:n.description}),i.jsx("button",{type:"button",className:p.action,disabled:t,onClick:B,children:n.buttonCaption})]}):null,E?i.jsx("p",{id:f,className:p.error,children:u(E)}):null]})}function Pj(e){return dn(e.trim())===null}function Tj(e){return og(e)?{width:null,height:null}:e==="fill"?{width:{...Yr},height:{...Yr}}:{width:{...Yr},height:null}}function Rj({value:e,disabled:t,customImagePicker:n,disableBuiltinSources:r,onCustomImagePick:o,onChange:a}){const s=Y(),u=e.src??"",d=(f,g)=>{a({...e,fit:null,[f]:g})};return i.jsxs(i.Fragment,{children:[u?i.jsxs("div",{className:p.field,children:[i.jsx("span",{className:p.label,children:s("pageBackgroundImagePreview")}),i.jsx("img",{className:p.previewImage,src:u,alt:s("pageBackgroundImagePreviewAlt")}),i.jsx("button",{type:"button",className:p.action,disabled:t,onClick:()=>{a({...e,src:null})},children:s("pageBackgroundImageClear")})]}):null,i.jsx(Qh,{src:u,disabled:t,customImagePicker:n,disableBuiltinSources:r,onCustomPick:o,onSrcChange:f=>{a({...e,src:f.trim()||null})}}),u?i.jsxs(i.Fragment,{children:[i.jsx(os,{label:s("imagePropertiesWidth"),inputAria:s("imagePropertiesWidthAria"),value:e.width,disabled:t,onChange:f=>d("width",f)}),i.jsx(os,{label:s("imagePropertiesHeight"),inputAria:s("imagePropertiesHeightAria"),value:e.height,disabled:t,onChange:f=>d("height",f)}),i.jsx(Jh,{legendKey:"pageDialogTabBackgroundImage",value:{opacity:e.opacity,fit:e.fit,position:e.position},disabled:t,onChange:f=>{const g=f.fit===e.fit?{width:e.width,height:e.height}:Tj(f.fit);a({...e,opacity:f.opacity,fit:f.fit,position:f.position,...g})}})]}):null]})}const Dj={left:as,center:is,right:ss,justify:Hf},jj={left:{aria:"commandAlignLeftAria"},center:{aria:"commandAlignCenterAria"},right:{aria:"commandAlignRightAria"},justify:{aria:"commandAlignJustifyAria"}},Ij={top:"paragraphDialogSideTop",right:"paragraphDialogSideRight",bottom:"paragraphDialogSideBottom",left:"paragraphDialogSideLeft"},Ej={none:"paragraphDialogBorderStyleNone",solid:"paragraphDialogBorderStyleSolid",dotted:"paragraphDialogBorderStyleDotted",dashed:"paragraphDialogBorderStyleDashed",double:"paragraphDialogBorderStyleDouble",groove:"paragraphDialogBorderStyleGroove",ridge:"paragraphDialogBorderStyleRidge",inset:"paragraphDialogBorderStyleInset",outset:"paragraphDialogBorderStyleOutset"},_j={pt:"fontSizeUnitPt",px:"fontSizeUnitPx",em:"fontSizeUnitEm",rem:"fontSizeUnitRem","%":"fontSizeUnitPercent"},Mj={value:1,unit:"pt"},Nj={offsetX:{value:0,unit:"px"},offsetY:{value:4,unit:"px"},blur:{value:8,unit:"px"},spread:{value:0,unit:"px"},color:"#000000",inset:!1},Lj={auto:"paragraphDialogBreakAuto",avoid:"paragraphDialogBreakAvoid"},Ef={auto:"paragraphDialogBreakAuto",avoid:"paragraphDialogBreakAvoid",page:"paragraphDialogBreakPage"};function Ho(e){return{top:e,right:e,bottom:e,left:e}}function _f(e){for(const t of it)if(e[t])return e[t];return null}function Bj(){const e=[...Yh];for(const t of Xh)e.some(n=>n.id===t.id)||e.push(t);return e}function Fu({tab:e,value:t,disabled:n,tabs:r,tablistLabelKey:o="paragraphDialogTitle",backgroundImage:a,customImagePicker:s,disableBuiltinImageInsert:u,onCustomImagePick:d,onBackgroundImageChange:f,onTabChange:g,onChange:h}){const y=Y(),b=r?Bj().filter(A=>r.includes(A.id)):Yh,C=l.useId(),x=l.useId(),v=l.useId(),k=l.useId(),[S,P]=l.useState(()=>kn(t.margin,Ho(t.margin.top))),[T,D]=l.useState(()=>kn(t.padding,Ho(t.padding.top))),R=(A,E,B,z)=>{const _=t[A],M=E?Ho(z):{..._,[B]:z};h({...t,[A]:M,[`${A}Mixed`]:!1})};return i.jsxs(i.Fragment,{children:[i.jsx("div",{className:p.tabs,role:"tablist","aria-label":y(o),children:b.map(A=>i.jsx("button",{type:"button",className:p.tab,role:"tab","aria-selected":A.id===e,disabled:!A.implemented,onClick:()=>g(A.id),children:y(A.labelKey)},A.id))}),i.jsxs("div",{className:p.body,role:"tabpanel",children:[e==="general"?i.jsxs(i.Fragment,{children:[i.jsxs("fieldset",{className:p.group,children:[i.jsx("legend",{className:p.label,children:y("paragraphDialogAlignment")}),i.jsx("div",{className:p.iconRow,role:"radiogroup","aria-label":y("paragraphDialogAlignment"),children:Zg.map(A=>{const E=Dj[A],B=!t.alignMixed&&t.align===A;return i.jsx("button",{type:"button",className:p.iconButton,role:"radio","aria-checked":B,"aria-label":y(jj[A].aria),disabled:n,onClick:()=>{h({...t,align:A,alignMixed:!1})},children:i.jsx(E,{})},A)})})]}),i.jsxs("fieldset",{className:p.group,children:[i.jsx("legend",{className:p.label,children:y("paragraphDialogLists")}),i.jsxs("div",{className:p.iconRow,children:[i.jsx("button",{type:"button",className:p.iconButton,"aria-pressed":!t.listMixed&&t.list==="ul","aria-label":y("commandBulletListAria"),disabled:n,onClick:()=>{const A=!t.listMixed&&t.list==="ul"?null:"ul";h({...t,list:A,listMixed:!1})},children:i.jsx(zf,{})}),i.jsx("button",{type:"button",className:p.iconButton,"aria-pressed":!t.listMixed&&t.list==="ol","aria-label":y("commandNumberedListAria"),disabled:n,onClick:()=>{const A=!t.listMixed&&t.list==="ol"?null:"ol";h({...t,list:A,listMixed:!1})},children:i.jsx(Uf,{})})]})]})]}):null,e==="spacing"?i.jsxs("fieldset",{className:p.group,children:[i.jsx("legend",{className:p.label,children:y("paragraphDialogSpacing")}),i.jsx(Mf,{legend:y("paragraphDialogMargin"),sides:t.margin,linked:S,disabled:n,allowNegative:!0,onLinkedChange:A=>{P(A),A&&h({...t,margin:Ho(_f(t.margin)),marginMixed:!1})},onSideChange:(A,E)=>R("margin",S,A,E)}),i.jsx(Mf,{legend:y("paragraphDialogPadding"),sides:t.padding,linked:T,disabled:n,onLinkedChange:A=>{D(A),A&&h({...t,padding:Ho(_f(t.padding)),paddingMixed:!1})},onSideChange:(A,E)=>R("padding",T,A,E)}),i.jsx(Hj,{value:t.lineHeight,disabled:n,onChange:A=>{h({...t,lineHeight:A,lineHeightMixed:!1})}}),i.jsxs("fieldset",{className:p.nestedGroup,children:[i.jsx("legend",{className:p.subLabel,children:y("paragraphDialogPageBreaks")}),i.jsxs("div",{className:p.field,children:[i.jsx("label",{className:p.label,htmlFor:x,children:y("paragraphDialogBreakInside")}),i.jsx("select",{id:x,className:p.select,value:t.breakInsideMixed?"auto":t.breakInside,disabled:n,onChange:A=>{h({...t,breakInside:A.target.value,breakInsideMixed:!1})},children:pp.map(A=>i.jsx("option",{value:A,children:y(Lj[A])},A))})]}),i.jsxs("div",{className:p.field,children:[i.jsx("label",{className:p.label,htmlFor:v,children:y("paragraphDialogBreakAfter")}),i.jsx("select",{id:v,className:p.select,value:t.breakAfterMixed?"auto":t.breakAfter,disabled:n,onChange:A=>{h({...t,breakAfter:A.target.value,breakAfterMixed:!1})},children:dc.map(A=>i.jsx("option",{value:A,children:y(Ef[A])},A))})]}),i.jsxs("div",{className:p.field,children:[i.jsx("label",{className:p.label,htmlFor:k,children:y("paragraphDialogBreakBefore")}),i.jsx("select",{id:k,className:p.select,value:t.breakBeforeMixed?"auto":t.breakBefore,disabled:n,onChange:A=>{h({...t,breakBefore:A.target.value,breakBeforeMixed:!1})},children:dc.map(A=>i.jsx("option",{value:A,children:y(Ef[A])},A))})]})]})]}):null,e==="border"?i.jsxs("fieldset",{className:p.group,children:[i.jsx("legend",{className:p.label,children:y("paragraphDialogBorder")}),i.jsxs("div",{className:p.field,children:[i.jsx("label",{className:p.label,htmlFor:C,children:y("paragraphDialogBorderStyle")}),i.jsx("select",{id:C,className:p.select,value:t.border.style,disabled:n,onChange:A=>{const E=A.target.value;h({...t,border:{style:E,width:E==="none"?null:t.border.width??Mj,color:E==="none"?null:t.border.color},borderMixed:!1})},children:ds.map(A=>i.jsx("option",{value:A,children:y(Ej[A])},A))})]}),t.border.style!=="none"?i.jsxs(i.Fragment,{children:[i.jsx(Xe,{label:y("paragraphDialogBorderWidth"),value:t.border.width,disabled:n,onChange:A=>{h({...t,border:{...t.border,width:A},borderMixed:!1})}}),i.jsx($t,{label:y("paragraphDialogBorderColor"),noneLabel:y("colorNone"),value:t.border.color,mixed:t.borderMixed,disabled:n,onChange:A=>{h({...t,border:{...t.border,color:A},borderMixed:!1})}})]}):null,i.jsx(Xe,{label:y("paragraphDialogBorderRadius"),value:t.borderRadius,disabled:n,onChange:A=>{h({...t,borderRadius:A,radiusMixed:!1})}}),i.jsxs("label",{className:p.mark,children:[i.jsx("input",{type:"checkbox",checked:t.boxShadow!==null,disabled:n,onChange:()=>{h({...t,boxShadow:t.boxShadow?null:Nj,shadowMixed:!1})}}),y("paragraphDialogBoxShadow")]}),t.boxShadow?i.jsx(Bu,{shadow:t.boxShadow,disabled:n,onChange:A=>{h({...t,boxShadow:A,shadowMixed:!1})}}):null]}):null,e==="background"?i.jsxs("fieldset",{className:p.group,children:[i.jsx("legend",{className:p.label,children:y("paragraphDialogTabBackground")}),i.jsx($t,{label:y("paragraphDialogBackgroundColor"),noneLabel:y("colorNone"),value:t.backgroundColor,mixed:t.backgroundMixed,disabled:n,onChange:A=>{h({...t,backgroundColor:A,backgroundMixed:!1})}}),i.jsx(Fj,{value:t.opacity,disabled:n,onChange:A=>{h({...t,opacity:A,opacityMixed:!1})}})]}):null,e==="backgroundImage"&&a&&f?i.jsx(Rj,{value:a,disabled:n,customImagePicker:s,disableBuiltinSources:u,onCustomImagePick:d,onChange:f}):null]})]})}function Fj({value:e,disabled:t,onChange:n}){const r=Y(),o=l.useId(),a=e===null?null:Ba(e),[s,u]=l.useState(()=>a===null?"":me(a)),[d,f]=l.useState(!1);l.useEffect(()=>{d||u(a===null?"":me(a))},[a,d]);const g=h=>{const y=h.trim();if(!y){n(null),u("");return}const b=Number(y.replace(",","."));if(!Number.isFinite(b)){u(a===null?"":me(a));return}const C=vp(b);n(C),u(me(Ba(C)))};return i.jsxs("div",{className:p.field,children:[i.jsx("label",{className:p.label,htmlFor:o,children:r("paragraphDialogOpacity")}),i.jsxs("div",{className:p.lengthRow,children:[i.jsx("input",{id:o,className:p.lengthInput,value:s,disabled:t,inputMode:"decimal",onFocus:()=>f(!0),onChange:h=>u(h.target.value),onBlur:()=>{f(!1),g(s)}}),i.jsx("span",{className:p.lengthUnit,"aria-hidden":"true",children:r("fontSizeUnitPercent")})]})]})}function Mf({legend:e,sides:t,linked:n,disabled:r,allowNegative:o=!1,onLinkedChange:a,onSideChange:s}){const u=Y(),d=n?["top"]:it;return i.jsxs("fieldset",{className:p.nestedGroup,children:[i.jsx("legend",{className:p.subLabel,children:e}),i.jsxs("label",{className:p.mark,children:[i.jsx("input",{type:"checkbox",checked:n,disabled:r,onChange:()=>a(!n)}),u("paragraphDialogLinkSides")]}),i.jsx("div",{className:p.sideGrid,children:d.map(f=>i.jsx(Xe,{label:n?e:u(Ij[f]),value:t[f],disabled:r,allowNegative:o,onChange:g=>s(f,g)},f))})]})}function Hj({value:e,disabled:t,onChange:n}){const r=Y(),o=l.useId(),a=zj(e),s=(e==null?void 0:e.kind)==="number"||(e==null?void 0:e.kind)==="length"?e.value:null,[u,d]=l.useState(()=>s===null?"":me(s)),f=(e==null?void 0:e.kind)==="length"?e.unit:Jc;return i.jsxs("div",{className:p.field,children:[i.jsx("label",{className:p.label,htmlFor:o,children:r("paragraphDialogLineHeight")}),i.jsxs("div",{className:p.lengthRow,children:[i.jsx("input",{id:o,className:p.lengthInput,value:a==="normal"?"":u,disabled:t||a==="normal",inputMode:"decimal",onChange:g=>d(g.target.value),onBlur:()=>{const g=u.trim();if(!g){n(null);return}if(a==="number"||a==="empty"){const y=Number(g.replace(",","."));if(!Number.isFinite(y)||y<0){d(s===null?"":me(s));return}n({kind:"number",value:y}),d(me(y));return}const h=Xo(g,f,!1);if(!h){d(s===null?"":me(s));return}n({kind:"length",value:h.value,unit:h.unit}),d(me(h.value))}}),i.jsxs("select",{className:p.lengthUnit,value:a==="length"?f:a,disabled:t,"aria-label":r("paragraphDialogLengthUnitAria"),onChange:g=>{const h=g.target.value;if(h==="empty"){n(null),d("");return}if(h==="normal"){n({kind:"normal"}),d("");return}if(h==="number"){const x=Number((u||"1.5").replace(",",".")),v=Number.isFinite(x)&&x>=0?x:1.5;n({kind:"number",value:v}),d(me(v));return}const y=h,b=Xo(u||"1",y,!1),C=(b==null?void 0:b.value)??1;n({kind:"length",value:C,unit:y}),d(me(C))},children:[i.jsx("option",{value:"empty"}),i.jsx("option",{value:"normal",children:r("paragraphDialogLineHeightNormal")}),i.jsx("option",{value:"number",children:r("paragraphDialogLineHeightUnitless")}),["pt","px","em","rem","%"].map(g=>i.jsx("option",{value:g,children:r(_j[g])},g))]})]})]})}function zj(e){return e?e.kind==="normal"?"normal":e.kind==="number"?"number":"length":"empty"}function Oj({open:e,tab:t,value:n,backgroundImage:r,disabled:o,customImagePicker:a,disableBuiltinImageInsert:s,onCustomImagePick:u,onTabChange:d,onApply:f,onClose:g}){const h=Y(),y=l.useId(),b=l.useRef(null),[C,x]=l.useState(n),[v,k]=l.useState(r);return l.useEffect(()=>{e&&(x(n),k(r??cn()))},[e,n,r]),Ze(b,{open:e,onClose:g,focusableSelector:'button:not([disabled]):not([tabindex="-1"]), input:not([disabled]), select:not([disabled])'}),e?i.jsx(we,{children:i.jsx("div",{className:p.backdrop,role:"presentation",onMouseDown:g,children:i.jsxs("div",{ref:b,className:`${p.dialog} ${p.dialogWide}`,role:"dialog","aria-modal":"true","aria-labelledby":y,onMouseDown:S=>S.stopPropagation(),children:[i.jsx("h2",{className:p.header,id:y,children:h("paragraphDialogTitle")}),i.jsx(Fu,{tab:t,value:C,disabled:o,backgroundImage:v,customImagePicker:a,disableBuiltinImageInsert:s,onCustomImagePick:u,onBackgroundImageChange:k,onTabChange:d,onChange:x}),i.jsxs("div",{className:p.actions,children:[i.jsx("button",{type:"button",className:p.action,onClick:g,children:h("fontDialogCancel")}),i.jsx("button",{type:"button",className:`${p.action} ${p.actionPrimary}`,disabled:o,onClick:()=>f({value:C,backgroundImage:v}),children:h("fontDialogOk")})]})]})})}):null}const Kj=["auto","A4","letter","legal","custom"],$j={auto:"pageAtRuleSizeAuto",A4:"pageAtRuleSizeA4",letter:"pageAtRuleSizeLetter",legal:"pageAtRuleSizeLegal",custom:"pageAtRuleSizeCustom"},Uj={top:"paragraphDialogSideTop",right:"paragraphDialogSideRight",bottom:"paragraphDialogSideBottom",left:"paragraphDialogSideLeft"};function Nf(e){return e===null?"":me(e.value)}function Vj({value:e,disabled:t,onChange:n,onReset:r}){const o=Y(),a=l.useId(),[s,u]=l.useState(!0),d=e??Hn(),f=(g,h)=>{if(s){n({...d,margin:{top:h,right:h,bottom:h,left:h},marginMixed:!1});return}n({...d,margin:{...d.margin,[g]:h},marginMixed:!1})};return i.jsxs("div",{className:p.body,children:[i.jsxs("div",{className:p.field,children:[i.jsx("label",{className:p.label,htmlFor:a,children:o("pageAtRuleSize")}),i.jsx("select",{id:a,className:p.select,disabled:t,value:d.sizePreset,onChange:g=>n({...d,sizePreset:g.target.value}),children:Kj.map(g=>i.jsx("option",{value:g,children:o($j[g])},g))})]}),d.sizePreset==="custom"?i.jsxs("div",{className:p.sideGrid,children:[i.jsx(ec,{label:o("pageAtRuleWidth"),value:d.customWidth,disabled:t,onChange:g=>n({...d,customWidth:g})}),i.jsx(ec,{label:o("pageAtRuleHeight"),value:d.customHeight,disabled:t,onChange:g=>n({...d,customHeight:g})})]}):null,i.jsxs("div",{className:p.field,children:[i.jsx("span",{className:p.label,children:o("pageAtRuleOrientation")}),i.jsx("div",{className:p.marks,children:[["none","pageAtRuleOrientationNone"],["portrait","pageAtRuleOrientationPortrait"],["landscape","pageAtRuleOrientationLandscape"]].map(([g,h])=>i.jsxs("label",{className:p.mark,children:[i.jsx("input",{type:"radio",name:"page-orientation",checked:(d.orientation??"none")===g,disabled:t,onChange:()=>n({...d,orientation:g==="none"?null:g})}),o(h)]},g))})]}),i.jsxs("fieldset",{className:p.nestedGroup,children:[i.jsx("legend",{className:p.subLabel,children:o("pageAtRuleMargins")}),i.jsxs("label",{className:p.mark,children:[i.jsx("input",{type:"checkbox",checked:s,disabled:t,onChange:()=>u(!s)}),o("paragraphDialogLinkSides")]}),i.jsx("div",{className:p.sideGrid,children:(s?["top"]:it).map(g=>i.jsx(ec,{label:o(s?"pageAtRuleMargins":Uj[g]),value:d.margin[g],disabled:t,onChange:h=>f(g,h)},g))})]}),i.jsx("div",{className:p.actions,children:i.jsx("button",{type:"button",className:p.action,disabled:t,"aria-label":o("pageAtRuleResetAria"),onClick:r,children:o("pageAtRuleReset")})})]})}function ec({label:e,value:t,disabled:n,onChange:r}){const o=Y(),a=l.useId(),[s,u]=l.useState(()=>Nf(t)),d=(t==null?void 0:t.unit)??Jc;return i.jsxs("div",{className:p.field,children:[i.jsx("label",{className:p.label,htmlFor:a,children:e}),i.jsxs("div",{className:p.lengthRow,children:[i.jsx("input",{id:a,className:p.lengthInput,value:s,disabled:n,inputMode:"decimal",onChange:f=>u(f.target.value),onBlur:()=>{const f=s.trim();if(!f){r(null);return}const g=Xo(f,d,!1);if(!g){u(Nf(t));return}r(g),u(me(g.value))}}),i.jsxs("select",{className:p.lengthUnit,disabled:n,value:d,"aria-label":o("paragraphDialogLengthUnitAria"),onChange:f=>{const g=f.target.value;t&&r({...t,unit:g})},children:[i.jsx("option",{value:"pt",children:o("fontSizeUnitPt")}),i.jsx("option",{value:"px",children:o("fontSizeUnitPx")}),i.jsx("option",{value:"em",children:o("fontSizeUnitEm")}),i.jsx("option",{value:"rem",children:o("fontSizeUnitRem")}),i.jsx("option",{value:"%",children:o("fontSizeUnitPercent")})]})]})]})}const Wj=Xh.map(e=>e.id);function Gj(e){return{...pr(),...e}}function Zj(e){const{align:t,alignMixed:n,list:r,listMixed:o,...a}=e;return a}function qj({open:e,tab:t,value:n,fonts:r,disabled:o,printTabVisible:a=!1,initialParagraphTab:s="spacing",customImagePicker:u,disableBuiltinImageInsert:d,onCustomImagePick:f,onTabChange:g,onApply:h,onResetAtRule:y,onClose:b}){const C=Y(),x=l.useId(),v=l.useRef(null),[k,S]=l.useState("general"),[P,T]=l.useState("spacing"),[D,R]=l.useState(n.font),[A,E]=l.useState(n.box),[B,z]=l.useState(n.backgroundImage),[_,M]=l.useState(n.atRule??Hn());if(l.useEffect(()=>{e&&(S("general"),T(s==="general"?"spacing":s),R(n.font),E(n.box),z(n.backgroundImage??cn()),M(n.atRule??Hn()),t==="print"&&!a&&g("font"))},[e,n,t,a,s,g]),Ze(v,{open:e,onClose:b,focusableSelector:'button:not([disabled]):not([tabindex="-1"]), input:not([disabled]), select:not([disabled])'}),!e)return null;const O=C("pageDialogTitle"),G=t==="print"&&!a?"font":t;return i.jsx(we,{children:i.jsx("div",{className:p.backdrop,role:"presentation",onMouseDown:b,children:i.jsxs("div",{ref:v,className:`${p.dialog} ${p.dialogWide}`,role:"dialog","aria-modal":"true","aria-labelledby":x,onMouseDown:q=>q.stopPropagation(),children:[i.jsx("h2",{className:p.header,id:x,children:O}),i.jsxs("div",{className:p.tabs,role:"tablist","aria-label":O,children:[i.jsx("button",{type:"button",className:p.tab,role:"tab","aria-selected":G==="font",onClick:()=>g("font"),children:C("customStyleDialogTabFont")}),i.jsx("button",{type:"button",className:p.tab,role:"tab","aria-selected":G==="paragraph",onClick:()=>g("paragraph"),children:C("customStyleDialogTabParagraph")}),a?i.jsx("button",{type:"button",className:p.tab,role:"tab","aria-selected":G==="print",onClick:()=>g("print"),children:C("pageDialogTabPrint")}):null]}),G==="font"?i.jsx("div",{className:p.nestedPanel,children:i.jsx(Lu,{tab:k,value:D,fonts:r,disabled:o,onTabChange:S,onChange:R})}):G==="paragraph"?i.jsx("div",{className:p.nestedPanel,children:i.jsx(Fu,{tab:P,value:Gj(A),disabled:o,tabs:Wj,tablistLabelKey:"pageDialogTitle",backgroundImage:B,customImagePicker:u,disableBuiltinImageInsert:d,onCustomImagePick:f,onBackgroundImageChange:z,onTabChange:q=>{q!=="general"&&T(q)},onChange:q=>E(Zj(q))})}):i.jsx("div",{className:p.nestedPanel,children:i.jsx(Vj,{value:_,disabled:o,onChange:M,onReset:()=>{M(Hn()),y==null||y()}})}),i.jsxs("div",{className:p.actions,children:[i.jsx("button",{type:"button",className:p.action,onClick:b,children:C("fontDialogCancel")}),i.jsx("button",{type:"button",className:`${p.action} ${p.actionPrimary}`,disabled:o,onClick:()=>h({font:D,box:A,backgroundImage:B,atRule:a?_:n.atRule??Hn()}),children:C("fontDialogOk")})]})]})})})}function Yj({open:e,disabled:t,onClose:n,onConfirm:r}){const o=Y(),a=l.useId(),s=l.useRef(null);if(l.useEffect(()=>{if(!e)return;const d=s.current;if(!d)return;const f=d.querySelector('button:not([disabled]):not([tabindex="-1"])');f==null||f.focus();const g=h=>{h.key==="Escape"&&(h.preventDefault(),n())};return document.addEventListener("keydown",g,!0),()=>document.removeEventListener("keydown",g,!0)},[e,n]),!e)return null;const u=!!t;return i.jsx(we,{children:i.jsx("div",{className:p.backdrop,role:"presentation",onMouseDown:n,children:i.jsxs("div",{ref:s,className:p.dialog,role:"dialog","aria-modal":"true","aria-labelledby":a,onMouseDown:d=>d.stopPropagation(),children:[i.jsxs("div",{className:p.headerRow,children:[i.jsx("h2",{className:p.header,id:a,children:o("deletePageDialogTitle")}),i.jsx("button",{type:"button",className:p.close,"aria-label":o("fontDialogCloseAria"),onClick:n,children:i.jsx(Je,{})})]}),i.jsx("div",{className:p.confirmBody,children:o("deletePageConfirmMessage")}),i.jsxs("div",{className:p.actions,children:[i.jsx("button",{type:"button",className:p.action,disabled:u,onClick:n,children:o("fontDialogCancel")}),i.jsx("button",{type:"button",className:`${p.action} ${p.actionDanger}`,disabled:u,onClick:r,children:o("commandDeletePage")})]})]})})})}function Xj(){return typeof crypto<"u"&&typeof crypto.randomUUID=="function"?crypto.randomUUID():`style-${Date.now().toString(16)}-${Math.random().toString(16).slice(2)}`}function Lf(e){return{size:e.size,unit:e.unit,marks:e.marks,fontFamily:e.fontFamily??null,fontFamilyMixed:!1,fontColor:e.fontColor,highlightColor:e.highlightColor,fontColorMixed:!1,highlightColorMixed:!1}}function Jj(e){return{size:e.size,unit:e.unit,marks:e.marks,fontFamily:e.fontFamilyMixed?null:e.fontFamily,fontColor:e.fontColorMixed?null:e.fontColor,highlightColor:e.highlightColorMixed?null:e.highlightColor}}function Qj({open:e,mode:t,styleId:n,name:r="",font:o,paragraph:a,canDelete:s=!1,busy:u,disabled:d,fonts:f,defaultOuterTab:g="font",onSave:h,onDelete:y,onClose:b}){const C=Y(),x=l.useId(),v=l.useId(),k=l.useRef(null),[S,P]=l.useState(r),[T,D]=l.useState(g),[R,A]=l.useState("general"),[E,B]=l.useState("general"),[z,_]=l.useState(()=>Lf(o)),[M,O]=l.useState(()=>Dc(a)),[G,q]=l.useState(!1);l.useEffect(()=>{e&&(P(r),D(g),A("general"),B("general"),_(Lf(o)),O(Dc(a)),q(!1))},[e,r,o,a,g]);const re=l.useCallback(()=>{if(G){q(!1);return}b()},[G,b]);if(Ze(k,{open:e,onClose:re,focusableSelector:'button:not([disabled]):not([tabindex="-1"]), input:not([disabled]), select:not([disabled])'}),!e)return null;const Z=C(t==="create"?"customStyleDialogAddTitle":"customStyleDialogEditTitle"),X=S.trim().length>0,ne=!!(d||u),ce=()=>{const J=S.trim();J&&h({id:n??Xj(),name:J,font:Jj(z),paragraph:Jg(M)})};return i.jsx(we,{children:i.jsx("div",{className:p.backdrop,role:"presentation",onMouseDown:b,children:i.jsxs("div",{ref:k,className:`${p.dialog} ${p.dialogWide}`,role:"dialog","aria-modal":"true","aria-labelledby":x,"aria-busy":u||void 0,onMouseDown:J=>J.stopPropagation(),children:[i.jsxs("div",{className:p.headerRow,children:[i.jsx("h2",{className:p.header,id:x,children:Z}),i.jsx("button",{type:"button",className:p.close,"aria-label":C("customStyleDialogCloseAria"),onClick:b,children:i.jsx(Je,{})})]}),G?i.jsxs(i.Fragment,{children:[i.jsx("div",{className:p.confirmBody,children:C("customStyleDialogDeleteConfirm")}),i.jsxs("div",{className:p.actions,children:[i.jsx("button",{type:"button",className:p.action,disabled:ne,onClick:()=>q(!1),children:C("fontDialogCancel")}),i.jsx("button",{type:"button",className:`${p.action} ${p.actionDanger}`,disabled:ne||!n,onClick:()=>{n&&(y==null||y(n))},children:C("customStyleDialogDelete")})]})]}):i.jsxs(i.Fragment,{children:[i.jsx("div",{className:p.nameSection,children:i.jsxs("div",{className:p.field,children:[i.jsx("label",{className:p.label,htmlFor:v,children:C("customStyleDialogName")}),i.jsx("input",{id:v,className:p.nameInput,value:S,disabled:ne,onChange:J=>P(J.target.value)})]})}),i.jsxs("div",{className:p.tabs,role:"tablist","aria-label":Z,children:[i.jsx("button",{type:"button",className:p.tab,role:"tab","aria-selected":T==="font",onClick:()=>D("font"),children:C("customStyleDialogTabFont")}),i.jsx("button",{type:"button",className:p.tab,role:"tab","aria-selected":T==="paragraph",onClick:()=>D("paragraph"),children:C("customStyleDialogTabParagraph")})]}),T==="font"?i.jsx("div",{className:p.nestedPanel,children:i.jsx(Lu,{tab:R,value:z,fonts:f,disabled:ne,onTabChange:A,onChange:_})}):i.jsx("div",{className:p.nestedPanel,children:i.jsx(Fu,{tab:E,value:M,disabled:ne,onTabChange:B,onChange:O})}),i.jsxs("div",{className:t==="edit"&&s?`${p.actions} ${p.actionsSpread}`:p.actions,children:[t==="edit"&&s?i.jsx("button",{type:"button",className:`${p.action} ${p.actionDanger}`,disabled:ne,onClick:()=>q(!0),children:C("customStyleDialogDelete")}):null,i.jsxs("div",{className:p.actionsEnd,children:[i.jsx("button",{type:"button",className:p.action,onClick:b,children:C("fontDialogCancel")}),i.jsx("button",{type:"button",className:`${p.action} ${p.actionPrimary}`,disabled:ne||!X,onClick:ce,children:C("fontDialogOk")})]})]})]})]})})})}function eI({open:e,value:t,disabled:n,onApply:r,onClose:o}){const a=Y(),s=l.useId(),u=l.useId(),d=l.useRef(null),f=l.useRef(null),[g,h]=l.useState(t);if(l.useEffect(()=>{e&&h(t)},[e,t]),Ze(d,{open:e,onClose:o,escapeIgnoreSelectors:!1,focusableSelector:'button:not([disabled]):not([tabindex="-1"]), input:not([disabled]), select:not([disabled]), textarea:not([disabled])'}),l.useEffect(()=>{var b;e&&((b=f.current)==null||b.focus())},[e]),!e)return null;const y=()=>{n||r(g)};return i.jsx(we,{children:i.jsx("div",{className:p.backdrop,role:"presentation",onMouseDown:o,children:i.jsxs("div",{ref:d,className:p.dialog,role:"dialog","aria-modal":"true","aria-labelledby":s,onMouseDown:b=>b.stopPropagation(),children:[i.jsxs("div",{className:p.headerRow,children:[i.jsx("h2",{className:p.header,id:s,children:a("customCssDialogTitle")}),i.jsx("button",{type:"button",className:p.close,"aria-label":a("customCssDialogCloseAria"),onClick:o,children:i.jsx(Je,{})})]}),i.jsx("div",{className:p.body,children:i.jsxs("div",{className:p.field,children:[i.jsx("label",{className:p.label,htmlFor:u,children:a("customCssDialogField")}),i.jsx("textarea",{ref:f,id:u,className:p.textarea,value:g,disabled:n,spellCheck:!1,"aria-label":a("customCssDialogFieldAria"),rows:8,onChange:b=>h(b.target.value)})]})}),i.jsxs("div",{className:p.actions,children:[i.jsx("button",{type:"button",className:p.action,onClick:o,children:a("fontDialogCancel")}),i.jsx("button",{type:"button",className:`${p.action} ${p.actionPrimary}`,disabled:n,onClick:y,children:a("fontDialogOk")})]})]})})})}const tI={empty:"bookmarkDialogErrorEmpty",invalid:"bookmarkDialogErrorInvalid",duplicate:"bookmarkDialogErrorDuplicate"};function nI({open:e,existingIds:t,disabled:n,onApply:r,onClose:o}){const a=Y(),s=l.useId(),u=l.useId(),d=l.useId(),f=l.useRef(null),[g,h]=l.useState(""),[y,b]=l.useState(!1),C=l.useMemo(()=>new Set(t),[t]),x=oh(g,C);if(l.useEffect(()=>{e&&(h(""),b(!1))},[e]),Ze(f,{open:e,onClose:o,escapeIgnoreSelectors:!1,focusableSelector:'button:not([disabled]):not([tabindex="-1"]), input:not([disabled]), select:not([disabled])'}),!e)return null;const v=y||g.trim().length>0?x:null,k=x===null&&!n,S=()=>{b(!0),!(x||n)&&r(g.trim())};return i.jsx(we,{children:i.jsx("div",{className:p.backdrop,role:"presentation",onMouseDown:o,children:i.jsxs("div",{ref:f,className:p.dialog,role:"dialog","aria-modal":"true","aria-labelledby":s,onMouseDown:P=>P.stopPropagation(),children:[i.jsxs("div",{className:p.headerRow,children:[i.jsx("h2",{className:p.header,id:s,children:a("bookmarkDialogTitle")}),i.jsx("button",{type:"button",className:p.close,"aria-label":a("bookmarkDialogCloseAria"),onClick:o,children:i.jsx(Je,{})})]}),i.jsx("div",{className:p.body,children:i.jsxs("div",{className:p.field,children:[i.jsxs("div",{className:p.labelRow,children:[i.jsx("label",{className:p.label,htmlFor:u,children:a("bookmarkDialogName")}),i.jsx(qn,{label:a("bookmarkDialogHelp"),elevated:!0,children:i.jsx("button",{type:"button",className:p.help,"aria-label":a("bookmarkDialogHelpAria"),children:"?"})})]}),i.jsx("input",{id:u,className:p.textInput,value:g,disabled:n,"aria-invalid":v!==null,"aria-describedby":v?d:void 0,onChange:P=>h(P.target.value)}),v?i.jsx("p",{id:d,className:p.error,children:a(tI[v])}):null]})}),i.jsxs("div",{className:p.actions,children:[i.jsx("button",{type:"button",className:p.action,onClick:o,children:a("fontDialogCancel")}),i.jsx("button",{type:"button",className:`${p.action} ${p.actionPrimary}`,disabled:!k,onClick:S,children:a("fontDialogOk")})]})]})})})}const rI={empty:"audioDialogErrorEmpty",invalid:"audioDialogErrorInvalid"},oI={type:"audioDialogErrorType",tooLarge:"audioDialogErrorTooLarge"};function iI({open:e,disabled:t,customAudioPicker:n,onApply:r,onCustomPick:o,onClose:a}){const s=Y(),u=l.useId(),d=l.useId(),f=l.useId(),g=l.useId(),h=l.useRef(null),y=l.useRef(null),[b,C]=l.useState("file"),[x,v]=l.useState(""),[k,S]=l.useState(""),[P,T]=l.useState(""),[D,R]=l.useState(""),[A,E]=l.useState(null),[B,z]=l.useState(!1);if(l.useEffect(()=>{e&&(C("file"),v(""),S(""),T(""),R(""),E(null),z(!1),y.current&&(y.current.value=""))},[e]),Ze(h,{open:e,onClose:a,escapeIgnoreSelectors:!1}),!e)return null;const _=b==="file"?k:b==="url"?x:"",M=b==="custom"?null:Iu(_),O=b==="custom"?null:b==="file"&&A?oI[A]:M&&(b==="file"||x.trim().length>0)?rI[M]:null,G=b!=="custom"&&M===null&&!(b==="file"&&A)&&!t&&!B,q=()=>{t||!n||o==null||o()},re=()=>{G&&r({src:_.trim(),title:D.trim()})},Z=X=>{var ce;const ne=(ce=X.target.files)==null?void 0:ce[0];ne&&(z(!0),E(null),_S(ne).then(J=>{S(J),T(ne.name),C("file"),z(!1)},J=>{const I=J instanceof Error?J.message:"";S(""),T(""),C("file"),E(I==="tooLarge"||I==="type"?I:"type"),z(!1),y.current&&(y.current.value="")}))};return i.jsx(we,{children:i.jsx("div",{className:p.backdrop,role:"presentation",onMouseDown:a,children:i.jsxs("div",{ref:h,className:p.dialog,role:"dialog","aria-modal":"true","aria-labelledby":u,onMouseDown:X=>X.stopPropagation(),children:[i.jsxs("div",{className:p.headerRow,children:[i.jsx("h2",{className:p.header,id:u,children:s("audioDialogTitle")}),i.jsx("button",{type:"button",className:p.close,"aria-label":s("audioDialogCloseAria"),onClick:a,children:i.jsx(Je,{})})]}),i.jsxs("div",{className:p.body,children:[i.jsxs("fieldset",{className:p.group,children:[i.jsx("legend",{className:p.subLabel,children:s("audioDialogSource")}),i.jsxs("div",{className:p.sizeRow,role:"radiogroup","aria-label":s("audioDialogSource"),children:[i.jsx("button",{type:"button",className:p.action,role:"radio","aria-checked":b==="file",disabled:t,onClick:()=>C("file"),children:s("audioDialogFile")}),i.jsx("button",{type:"button",className:p.action,role:"radio","aria-checked":b==="url",disabled:t,onClick:()=>C("url"),children:s("audioDialogUrl")}),n?i.jsx("button",{type:"button",className:p.action,role:"radio","aria-checked":b==="custom",disabled:t,onClick:()=>C("custom"),children:n.text}):null]}),b==="file"?i.jsxs("div",{className:p.fileRow,children:[i.jsx("input",{ref:y,type:"file",accept:PS,hidden:!0,disabled:t,"aria-label":s("audioDialogChooseFile"),onChange:Z}),i.jsx("button",{type:"button",className:p.action,disabled:t||B,onClick:()=>{var X;return(X=y.current)==null?void 0:X.click()},children:s("audioDialogChooseFile")}),P?i.jsx("span",{className:p.fileName,children:P}):null]}):null,b==="url"?i.jsxs("div",{className:p.field,children:[i.jsx("label",{className:p.label,htmlFor:d,children:s("audioDialogUrl")}),i.jsx("input",{id:d,className:p.textInput,value:x,disabled:t,"aria-invalid":O!==null,"aria-describedby":O?g:void 0,onChange:X=>v(X.target.value)})]}):null,b==="custom"&&n?i.jsxs("div",{className:p.field,children:[i.jsx("p",{className:p.emptyHint,children:n.description}),i.jsx("button",{type:"button",className:p.action,disabled:t,onClick:q,children:n.buttonCaption})]}):null]}),b!=="custom"?i.jsxs("div",{className:p.field,children:[i.jsx("label",{className:p.label,htmlFor:f,children:s("audioDialogTitleField")}),i.jsx("input",{id:f,className:p.textInput,value:D,disabled:t,onChange:X=>R(X.target.value)})]}):null,O?i.jsx("p",{id:g,className:p.error,children:s(O)}):null]}),i.jsxs("div",{className:p.actions,children:[i.jsx("button",{type:"button",className:p.action,onClick:a,children:s("fontDialogCancel")}),b!=="custom"?i.jsx("button",{type:"button",className:`${p.action} ${p.actionPrimary}`,disabled:!G,onClick:re,children:s("fontDialogOk")}):null]})]})})})}function aI({open:e,disabled:t,customImagePicker:n,onApply:r,onCustomPick:o,onClose:a}){const s=Y(),u=l.useId(),d=l.useId(),f=l.useId(),g=l.useRef(null),[h,y]=l.useState(""),[b,C]=l.useState(""),[x,v]=l.useState(""),[k,S]=l.useState("file");if(l.useEffect(()=>{e&&(y(""),C(""),v(""),S("file"))},[e]),Ze(g,{open:e,onClose:a,escapeIgnoreSelectors:!1}),!e)return null;const P=Pj(h)&&!t,T=()=>{P&&r({src:h.trim(),alt:b.trim(),title:x.trim()})};return i.jsx(we,{children:i.jsx("div",{className:p.backdrop,role:"presentation",onMouseDown:a,children:i.jsxs("div",{ref:g,className:p.dialog,role:"dialog","aria-modal":"true","aria-labelledby":u,onMouseDown:D=>D.stopPropagation(),children:[i.jsxs("div",{className:p.headerRow,children:[i.jsx("h2",{className:p.header,id:u,children:s("imageDialogTitle")}),i.jsx("button",{type:"button",className:p.close,"aria-label":s("imageDialogCloseAria"),onClick:a,children:i.jsx(Je,{})})]}),i.jsxs("div",{className:p.body,children:[i.jsx(Qh,{src:h,disabled:t,customImagePicker:n,onCustomPick:o,onSourceChange:S,onSrcChange:y}),k!=="custom"?i.jsxs(i.Fragment,{children:[i.jsxs("div",{className:p.field,children:[i.jsx("label",{className:p.label,htmlFor:d,children:s("imageDialogAlt")}),i.jsx("input",{id:d,className:p.textInput,value:b,disabled:t,onChange:D=>C(D.target.value)})]}),i.jsxs("div",{className:p.field,children:[i.jsx("label",{className:p.label,htmlFor:f,children:s("imageDialogTitleField")}),i.jsx("input",{id:f,className:p.textInput,value:x,disabled:t,onChange:D=>v(D.target.value)})]})]}):null]}),i.jsxs("div",{className:p.actions,children:[i.jsx("button",{type:"button",className:p.action,onClick:a,children:s("fontDialogCancel")}),k!=="custom"?i.jsx("button",{type:"button",className:`${p.action} ${p.actionPrimary}`,disabled:!P,onClick:T,children:s("fontDialogOk")}):null]})]})})})}const sI=[{id:"general",labelKey:"fontDialogTabGeneral",implemented:!0},{id:"alignment",labelKey:"imagePropertiesTabAlignment",implemented:!0},{id:"border",labelKey:"imagePropertiesTabBorder",implemented:!0},{id:"advanced",labelKey:"imagePropertiesTabAdvanced",implemented:!0},{id:"hover",labelKey:"imagePropertiesTabHover",implemented:!0}],lI={left:as,center:is,right:ss},cI=["left","center","right"],uI={left:"commandAlignLeftAria",center:"commandAlignCenterAria",right:"commandAlignRightAria"},dI=["width","height","lock"],mI={width:"imagePropertiesSizeWidth",height:"imagePropertiesSizeHeight",lock:"imagePropertiesSizeLock"},fI={top:"paragraphDialogSideTop",right:"paragraphDialogSideRight",bottom:"paragraphDialogSideBottom",left:"paragraphDialogSideLeft"},pI={none:"paragraphDialogBorderStyleNone",solid:"paragraphDialogBorderStyleSolid",dotted:"paragraphDialogBorderStyleDotted",dashed:"paragraphDialogBorderStyleDashed",double:"paragraphDialogBorderStyleDouble",groove:"paragraphDialogBorderStyleGroove",ridge:"paragraphDialogBorderStyleRidge",inset:"paragraphDialogBorderStyleInset",outset:"paragraphDialogBorderStyleOutset"},gI={value:1,unit:"pt"},hI={offsetX:{value:0,unit:"px"},offsetY:{value:4,unit:"px"},blur:{value:8,unit:"px"},spread:{value:0,unit:"px"},color:"#000000",inset:!1};function tc(e){return{top:e,right:e,bottom:e,left:e}}function bI(e){for(const t of it)if(e[t])return e[t];return null}function yI({tab:e,value:t,aspectRatio:n,disabled:r,onTabChange:o,onChange:a}){const s=Y(),u=l.useId(),d=l.useId(),f=l.useId(),[g,h]=l.useState(()=>kn(t.margin,tc(t.margin.top))),y=t.align==="center",b=(x,v)=>{if(t.sizeMode==="lock"&&v){const k=Go(x,v,n);a({...t,width:k.width,height:k.height});return}a({...t,[x]:v})},C=x=>{if(x==="width"){a({...t,sizeMode:x,height:null});return}if(x==="height"){a({...t,sizeMode:x,width:null});return}if(t.width){const v=Go("width",t.width,n);a({...t,sizeMode:x,width:v.width,height:v.height});return}if(t.height){const v=Go("height",t.height,n);a({...t,sizeMode:x,width:v.width,height:v.height});return}a({...t,sizeMode:x})};return i.jsxs(i.Fragment,{children:[i.jsx("div",{className:p.tabs,role:"tablist","aria-label":s("imagePropertiesDialogTitle"),children:sI.map(x=>i.jsx("button",{type:"button",className:p.tab,role:"tab","aria-selected":x.id===e,disabled:!x.implemented,onClick:()=>o(x.id),children:s(x.labelKey)},x.id))}),i.jsxs("div",{className:p.body,role:"tabpanel",children:[e==="general"?i.jsxs("fieldset",{className:p.group,children:[i.jsx("legend",{className:p.label,children:s("imagePropertiesSize")}),i.jsx("div",{className:p.iconRow,role:"radiogroup","aria-label":s("imagePropertiesSizeMode"),children:dI.map(x=>i.jsx("button",{type:"button",className:p.action,role:"radio","aria-checked":t.sizeMode===x,disabled:r,onClick:()=>C(x),children:s(mI[x])},x))}),i.jsx(os,{label:s("imagePropertiesWidth"),inputAria:s("imagePropertiesWidthAria"),value:t.width,disabled:r||t.sizeMode==="height",onChange:x=>b("width",x)}),i.jsx(os,{label:s("imagePropertiesHeight"),inputAria:s("imagePropertiesHeightAria"),value:t.height,disabled:r||t.sizeMode==="width",onChange:x=>b("height",x)})]}):null,e==="alignment"?i.jsxs("fieldset",{className:p.group,children:[i.jsx("legend",{className:p.label,children:s("paragraphDialogAlignment")}),i.jsx("div",{className:p.iconRow,role:"radiogroup","aria-label":s("paragraphDialogAlignment"),children:cI.map(x=>{const v=lI[x];return i.jsx("button",{type:"button",className:p.iconButton,role:"radio","aria-checked":t.align===x,"aria-label":s(uI[x]),disabled:r,onClick:()=>{a({...t,align:t.align===x?null:x})},children:i.jsx(v,{})},x)})})]}):null,e==="border"?i.jsxs(i.Fragment,{children:[i.jsxs("fieldset",{className:p.group,children:[i.jsx("legend",{className:p.label,children:s("paragraphDialogMargin")}),i.jsxs("label",{className:p.mark,children:[i.jsx("input",{type:"checkbox",checked:g,disabled:r||y,onChange:()=>{const x=!g;h(x),x&&a({...t,margin:tc(bI(t.margin))})}}),s("paragraphDialogLinkSides")]}),i.jsx("div",{className:p.sideGrid,children:(g?["top"]:it).map(x=>i.jsx(Xe,{label:s(g?"paragraphDialogMargin":fI[x]),value:t.margin[x],disabled:r||y&&(x==="left"||x==="right"),allowNegative:!0,onChange:v=>{const k=g?tc(v):{...t.margin,[x]:v};a({...t,margin:k})}},x))})]}),i.jsxs("fieldset",{className:p.group,children:[i.jsx("legend",{className:p.label,children:s("paragraphDialogBorder")}),i.jsxs("div",{className:p.field,children:[i.jsx("label",{className:p.label,htmlFor:u,children:s("paragraphDialogBorderStyle")}),i.jsx("select",{id:u,className:p.select,value:t.border.style,disabled:r,onChange:x=>{const v=x.target.value;a({...t,border:{style:v,width:v==="none"?null:t.border.width??gI,color:v==="none"?null:t.border.color}})},children:ds.map(x=>i.jsx("option",{value:x,children:s(pI[x])},x))})]}),t.border.style!=="none"?i.jsxs(i.Fragment,{children:[i.jsx(Xe,{label:s("paragraphDialogBorderWidth"),value:t.border.width,disabled:r,onChange:x=>{a({...t,border:{...t.border,width:x}})}}),i.jsx($t,{label:s("paragraphDialogBorderColor"),noneLabel:s("colorNone"),value:t.border.color,disabled:r,onChange:x=>{a({...t,border:{...t.border,color:x}})}})]}):null,i.jsx(Xe,{label:s("paragraphDialogBorderRadius"),value:t.borderRadius,disabled:r,onChange:x=>{a({...t,borderRadius:x})}}),i.jsxs("label",{className:p.mark,children:[i.jsx("input",{type:"checkbox",checked:t.boxShadow!==null,disabled:r,onChange:()=>{a({...t,boxShadow:t.boxShadow?null:hI})}}),s("paragraphDialogBoxShadow")]}),t.boxShadow?i.jsx(Bu,{shadow:t.boxShadow,disabled:r,onChange:x=>{a({...t,boxShadow:x})}}):null]})]}):null,e==="advanced"?i.jsxs(i.Fragment,{children:[i.jsx(Jh,{value:{opacity:t.opacity,fit:t.objectFit,position:t.objectPosition},disabled:r,onChange:x=>{a(_w({...t,opacity:x.opacity,objectFit:x.fit,objectPosition:x.position},n))}}),i.jsxs("fieldset",{className:p.group,children:[i.jsx("legend",{className:p.label,children:s("imagePropertiesRotation")}),i.jsx("div",{className:p.field,children:i.jsxs("div",{className:p.lengthRow,children:[i.jsx("input",{id:d,className:p.lengthInput,value:t.rotateDeg===null?"":me(t.rotateDeg),disabled:r,inputMode:"decimal","aria-label":s("imagePropertiesRotation"),onChange:x=>{const v=x.target.value.trim();if(!v){a({...t,rotateDeg:null});return}const k=Number(v.replace(",","."));Number.isFinite(k)&&a({...t,rotateDeg:k})}}),i.jsx("span",{className:p.lengthUnit,"aria-hidden":"true",children:s("imagePropertiesRotationUnit")})]})})]})]}):null,e==="hover"?i.jsxs("fieldset",{className:p.group,children:[i.jsx("legend",{className:p.label,children:s("imagePropertiesTabHover")}),i.jsx("p",{className:p.emptyHint,children:s("imagePropertiesHoverHelp")}),i.jsxs("div",{className:p.field,children:[i.jsx("label",{className:p.label,htmlFor:f,children:s("imagePropertiesHoverCss")}),i.jsx("textarea",{id:f,className:p.textarea,value:t.hoverCss,disabled:r,spellCheck:!1,"aria-label":s("imagePropertiesHoverCssAria"),onChange:x=>{a({...t,hoverCss:x.target.value})}})]})]}):null]})]})}function xI({open:e,tab:t,value:n,aspectRatio:r=1,disabled:o,onTabChange:a,onApply:s,onClose:u}){const d=Y(),f=l.useId(),g=l.useRef(null),[h,y]=l.useState(n);return l.useEffect(()=>{e&&y(n)},[e,n]),Ze(g,{open:e,onClose:u,focusableSelector:'button:not([disabled]):not([tabindex="-1"]), input:not([disabled]), select:not([disabled]), textarea:not([disabled])'}),e?i.jsx(we,{children:i.jsx("div",{className:p.backdrop,role:"presentation",onMouseDown:u,children:i.jsxs("div",{ref:g,className:`${p.dialog} ${p.dialogWide}`,role:"dialog","aria-modal":"true","aria-labelledby":f,onMouseDown:b=>b.stopPropagation(),children:[i.jsxs("div",{className:p.headerRow,children:[i.jsx("h2",{className:p.header,id:f,children:d("imagePropertiesDialogTitle")}),i.jsx("button",{type:"button",className:p.close,"aria-label":d("imagePropertiesDialogCloseAria"),onClick:u,children:i.jsx(Je,{})})]}),i.jsx(yI,{tab:t,value:h,aspectRatio:r,disabled:o,onTabChange:a,onChange:y}),i.jsxs("div",{className:p.actions,children:[i.jsx("button",{type:"button",className:p.action,onClick:u,children:d("fontDialogCancel")}),i.jsx("button",{type:"button",className:`${p.action} ${p.actionPrimary}`,disabled:o,onClick:()=>s(h),children:d("fontDialogOk")})]})]})})}):null}function CI({open:e,tab:t,href:n,title:r,targetBlank:o,textDecorationNone:a,hoverMode:s,hoverColor:u,hoverHtml:d,bookmarks:f,selectedBookmarkId:g,disabled:h,onTabChange:y,onApply:b,onClose:C}){const x=Y(),v=l.useId(),k=l.useId(),S=l.useId(),P=l.useId(),T=l.useId(),D=l.useRef(null),[R,A]=l.useState(n),[E,B]=l.useState(r),[z,_]=l.useState(o),[M,O]=l.useState(a),[G,q]=l.useState(s),[re,Z]=l.useState(u),[X,ne]=l.useState(d),[ce,J]=l.useState(g);if(l.useEffect(()=>{e&&(A(n),B(r),_(o),O(a),q(s),Z(u),ne(d),J(g))},[e,n,r,o,a,s,u,d,g]),Ze(D,{open:e,onClose:C,focusableSelector:'button:not([disabled]):not([tabindex="-1"]), input:not([disabled]), select:not([disabled]), textarea:not([disabled])'}),!e)return null;const I=()=>Cs({title:E,targetBlank:z,textDecorationNone:M,hoverMode:G,hoverColor:re,hoverHtml:X}),se=()=>{const L=R.trim();!L||h||b({...I(),href:L})},fe=()=>{!ce||h||b({...I(),href:`#${ce}`})};return i.jsx(we,{children:i.jsx("div",{className:p.backdrop,role:"presentation",onMouseDown:C,children:i.jsxs("div",{ref:D,className:p.dialog,role:"dialog","aria-modal":"true","aria-labelledby":v,onMouseDown:L=>L.stopPropagation(),children:[i.jsx("h2",{className:p.header,id:v,children:x("linkDialogTitle")}),i.jsxs("div",{className:p.tabs,role:"tablist","aria-label":x("linkDialogTitle"),children:[i.jsx("button",{type:"button",className:p.tab,role:"tab","aria-selected":t==="link",onClick:()=>y("link"),children:x("linkDialogTabLink")}),i.jsx("button",{type:"button",className:p.tab,role:"tab","aria-selected":t==="bookmark",onClick:()=>y("bookmark"),children:x("linkDialogTabBookmark")})]}),i.jsxs("div",{className:p.body,role:"tabpanel",children:[t==="link"?i.jsxs(i.Fragment,{children:[i.jsxs("div",{className:p.field,children:[i.jsx("label",{className:p.label,htmlFor:k,children:x("linkDialogHref")}),i.jsx("input",{id:k,className:p.textInput,value:R,disabled:h,onChange:L=>A(L.target.value)})]}),i.jsxs("div",{className:p.field,children:[i.jsx("label",{className:p.label,htmlFor:S,children:x("linkDialogHoverTitle")}),i.jsx("input",{id:S,className:p.textInput,value:E,disabled:h,onChange:L=>B(L.target.value)})]}),i.jsxs("label",{className:p.mark,children:[i.jsx("input",{type:"checkbox",checked:z,disabled:h,onChange:L=>_(L.target.checked)}),x("linkDialogTargetBlank")]})]}):f.length===0?i.jsx("p",{className:p.emptyHint,children:x("linkDialogBookmarkEmpty")}):i.jsxs("div",{className:p.field,children:[i.jsx("label",{className:p.label,htmlFor:P,children:x("linkDialogBookmark")}),i.jsxs("select",{id:P,className:`${p.select} ${p.fullSelect}`,value:ce,disabled:h,onChange:L=>J(L.target.value),children:[i.jsx("option",{value:""}),f.map(L=>i.jsx("option",{value:L.id,children:L.id},L.id))]})]}),i.jsxs("label",{className:p.mark,children:[i.jsx("input",{type:"checkbox",checked:M,disabled:h,onChange:L=>O(L.target.checked)}),x("linkDialogTextDecorationNone")]}),i.jsxs("fieldset",{className:p.group,children:[i.jsx("legend",{className:p.subLabel,children:x("linkDialogHover")}),i.jsxs("div",{className:p.sizeRow,role:"group","aria-label":x("linkDialogHover"),children:[i.jsx("button",{type:"button",className:p.action,"aria-pressed":G==="color",disabled:h,onClick:()=>q("color"),children:x("linkDialogHoverColor")}),i.jsx("button",{type:"button",className:p.action,"aria-pressed":G==="html",disabled:h,onClick:()=>q("html"),children:x("linkDialogHoverHtml")})]}),G==="color"?i.jsx($t,{label:x("linkDialogHoverColorField"),noneLabel:x("colorNone"),value:re,disabled:h,onChange:Z}):i.jsxs("div",{className:p.field,children:[i.jsx("label",{className:p.label,htmlFor:T,children:x("linkDialogHoverHtmlAria")}),i.jsx("textarea",{id:T,className:p.textarea,value:X,disabled:h,spellCheck:!1,onChange:L=>ne(L.target.value)})]})]})]}),i.jsxs("div",{className:p.actions,children:[i.jsx("button",{type:"button",className:p.action,disabled:h||!ce,onClick:fe,children:x("linkDialogSelect")}),i.jsx("button",{type:"button",className:p.action,onClick:C,children:x("fontDialogCancel")}),i.jsx("button",{type:"button",className:`${p.action} ${p.actionPrimary}`,disabled:h||!R.trim(),onClick:se,children:x("fontDialogOk")})]})]})})})}const Bf={empty:"youtubeDialogErrorEmpty",invalid:"youtubeDialogErrorInvalid"};function wI({open:e,disabled:t,customVideoPicker:n,onApply:r,onCustomPick:o,onClose:a}){const s=Y(),u=l.useId(),d=l.useId(),f=l.useId(),g=l.useId(),h=l.useRef(null),[y,b]=l.useState("url"),[C,x]=l.useState(""),[v,k]=l.useState("");if(l.useEffect(()=>{e&&(b("url"),x(""),k(""))},[e]),Ze(h,{open:e,onClose:a,escapeIgnoreSelectors:!1}),!e)return null;const S=y==="custom"?null:ph(C),P=y==="custom"?null:S&&C.trim().length>0?Bf[S]:S==="empty"&&C.trim().length===0?null:S?Bf[S]:null,T=y!=="custom"&&S===null&&!t&&C.trim().length>0,D=()=>{t||!n||o==null||o()},R=()=>{T&&r({url:C.trim(),title:v.trim()})};return i.jsx(we,{children:i.jsx("div",{className:p.backdrop,role:"presentation",onMouseDown:a,children:i.jsxs("div",{ref:h,className:p.dialog,role:"dialog","aria-modal":"true","aria-labelledby":u,onMouseDown:A=>A.stopPropagation(),children:[i.jsxs("div",{className:p.headerRow,children:[i.jsx("h2",{className:p.header,id:u,children:s("youtubeDialogTitle")}),i.jsx("button",{type:"button",className:p.close,"aria-label":s("youtubeDialogCloseAria"),onClick:a,children:i.jsx(Je,{})})]}),i.jsxs("div",{className:p.body,children:[i.jsxs("fieldset",{className:p.group,children:[i.jsx("legend",{className:p.subLabel,children:s("audioDialogSource")}),i.jsxs("div",{className:p.sizeRow,role:"radiogroup","aria-label":s("audioDialogSource"),children:[i.jsx("button",{type:"button",className:p.action,role:"radio","aria-checked":y==="url",disabled:t,onClick:()=>b("url"),children:s("youtubeDialogUrl")}),n?i.jsx("button",{type:"button",className:p.action,role:"radio","aria-checked":y==="custom",disabled:t,onClick:()=>b("custom"),children:n.text}):null]}),y==="url"?i.jsxs("div",{className:p.field,children:[i.jsx("label",{className:p.label,htmlFor:d,children:s("youtubeDialogUrl")}),i.jsx("input",{id:d,className:p.textInput,value:C,disabled:t,"aria-invalid":P!==null,"aria-describedby":P?g:void 0,onChange:A=>x(A.target.value)})]}):null,y==="custom"&&n?i.jsxs("div",{className:p.field,children:[i.jsx("p",{className:p.emptyHint,children:n.description}),i.jsx("button",{type:"button",className:p.action,disabled:t,onClick:D,children:n.buttonCaption})]}):null]}),y!=="custom"?i.jsxs("div",{className:p.field,children:[i.jsx("label",{className:p.label,htmlFor:f,children:s("youtubeDialogTitleField")}),i.jsx("input",{id:f,className:p.textInput,value:v,disabled:t,onChange:A=>k(A.target.value)})]}):null,P?i.jsx("p",{id:g,className:p.error,children:s(P)}):null]}),i.jsxs("div",{className:p.actions,children:[i.jsx("button",{type:"button",className:p.action,onClick:a,children:s("fontDialogCancel")}),y!=="custom"?i.jsx("button",{type:"button",className:`${p.action} ${p.actionPrimary}`,disabled:!T,onClick:R,children:s("fontDialogOk")}):null]})]})})})}const vI="_grid_1bpma_1",kI="_cell_1bpma_8",SI="_sizeLabel_1bpma_27",AI="_sizeFields_1bpma_33",PI="_numberInput_1bpma_37",Kr={grid:vI,cell:kI,sizeLabel:SI,sizeFields:AI,numberInput:PI},Ln={rows:3,cols:3};function TI({open:e,disabled:t,onApply:n,onClose:r}){const o=Y(),a=l.useId(),s=l.useId(),u=l.useId(),d=l.useRef(null),[f,g]=l.useState(Ln.rows),[h,y]=l.useState(Ln.cols),[b,C]=l.useState(String(Ln.rows)),[x,v]=l.useState(String(Ln.cols)),[k,S]=l.useState(!1);if(l.useEffect(()=>{e&&(g(Ln.rows),y(Ln.cols),C(String(Ln.rows)),v(String(Ln.cols)),S(!1))},[e]),Ze(d,{open:e,onClose:r,escapeIgnoreSelectors:!1,focusableSelector:'button:not([disabled]):not([tabindex="-1"]), input:not([disabled]):not([hidden]), select:not([disabled])'}),!e)return null;const T=$g(f,h)&&!t,D=(B,z)=>{const _=Math.min(qr,Math.max(Zr,B)),M=Math.min(qr,Math.max(Zr,z));g(_),y(M),C(String(_)),v(String(M))},R=(B,z)=>{const _=Number.parseInt(B,10);if(!Number.isFinite(_)){z==="rows"?C(String(f)):v(String(h));return}S(!0),z==="rows"?D(_,h):D(f,_)},A=(B,z)=>{const _=B.replace(/\D/g,"");if(z==="rows"?C(_):v(_),_==="")return;const M=Number.parseInt(_,10);Number.isFinite(M)&&(S(!0),z==="rows"?D(M,h):D(f,M))},E=B=>{(B.key==="e"||B.key==="E"||B.key==="+"||B.key==="-"||B.key===".")&&B.preventDefault()};return i.jsx(we,{children:i.jsx("div",{className:p.backdrop,role:"presentation",onMouseDown:r,children:i.jsxs("div",{ref:d,className:p.dialog,role:"dialog","aria-modal":"true","aria-labelledby":a,onMouseDown:B=>B.stopPropagation(),children:[i.jsxs("div",{className:p.headerRow,children:[i.jsx("h2",{className:p.header,id:a,children:o("tableDialogTitle")}),i.jsx("button",{type:"button",className:p.close,"aria-label":o("tableDialogCloseAria"),onClick:r,children:i.jsx(Je,{})})]}),i.jsxs("div",{className:p.body,children:[i.jsx("div",{className:Kr.grid,role:"grid","aria-label":o("tableDialogGridAria"),onMouseLeave:()=>{},children:Array.from({length:Ym},(B,z)=>Array.from({length:Ym},(_,M)=>{const O=z+1,G=M+1,q=O<=f&&G<=h;return i.jsx("button",{type:"button",className:Kr.cell,role:"gridcell","data-active":q?"true":void 0,"aria-label":`${O} × ${G}`,"aria-pressed":q&&O===f&&G===h,disabled:t,onMouseEnter:()=>{k||D(O,G)},onClick:()=>{S(!0),D(O,G)}},`${O}-${G}`)}))}),i.jsxs("p",{className:Kr.sizeLabel,children:[o("tableDialogSize"),": ",f," × ",h]}),i.jsxs("div",{className:`${p.sizeRow} ${Kr.sizeFields}`,children:[i.jsxs("div",{className:p.field,children:[i.jsx("label",{className:p.label,htmlFor:s,children:o("tableDialogRows")}),i.jsx("input",{id:s,className:Kr.numberInput,type:"number",inputMode:"numeric",min:Zr,max:qr,step:1,value:b,disabled:t,onKeyDown:E,onChange:B=>A(B.target.value,"rows"),onBlur:()=>R(b,"rows")})]}),i.jsxs("div",{className:p.field,children:[i.jsx("label",{className:p.label,htmlFor:u,children:o("tableDialogColumns")}),i.jsx("input",{id:u,className:Kr.numberInput,type:"number",inputMode:"numeric",min:Zr,max:qr,step:1,value:x,disabled:t,onKeyDown:E,onChange:B=>A(B.target.value,"cols"),onBlur:()=>R(x,"cols")})]})]})]}),i.jsxs("div",{className:p.actions,children:[i.jsx("button",{type:"button",className:p.action,onClick:r,children:o("fontDialogCancel")}),i.jsx("button",{type:"button",className:`${p.action} ${p.actionPrimary}`,disabled:!T,onClick:()=>{T&&n({rows:f,cols:h})},children:o("tableDialogInsert")})]})]})})})}const RI={none:"paragraphDialogBorderStyleNone",solid:"paragraphDialogBorderStyleSolid",dotted:"paragraphDialogBorderStyleDotted",dashed:"paragraphDialogBorderStyleDashed",double:"paragraphDialogBorderStyleDouble",groove:"paragraphDialogBorderStyleGroove",ridge:"paragraphDialogBorderStyleRidge",inset:"paragraphDialogBorderStyleInset",outset:"paragraphDialogBorderStyleOutset"},DI={value:1,unit:"pt"},jI={offsetX:{value:0,unit:"px"},offsetY:{value:4,unit:"px"},blur:{value:8,unit:"px"},spread:{value:0,unit:"px"},color:"#000000",inset:!1};function II({value:e,disabled:t,onChange:n}){const r=Y(),o=l.useId(),a=l.useId();return i.jsxs("div",{className:p.body,children:[i.jsxs("fieldset",{className:p.group,children:[i.jsx("legend",{className:p.label,children:r("tablePropertiesWidth")}),i.jsx(Xe,{label:r("tablePropertiesWidth"),value:e.width,disabled:t,onChange:s=>n({...e,width:s})}),i.jsxs("div",{className:p.field,children:[i.jsx("label",{className:p.label,htmlFor:o,children:r("tablePropertiesCollapse")}),i.jsxs("select",{id:o,className:p.select,value:e.borderCollapse,disabled:t,onChange:s=>{const u=s.target.value==="separate"?"separate":"collapse";n({...e,borderCollapse:u,borderSpacing:u==="separate"?e.borderSpacing:null})},children:[i.jsx("option",{value:"collapse",children:r("tablePropertiesCollapseCollapse")}),i.jsx("option",{value:"separate",children:r("tablePropertiesCollapseSeparate")})]})]}),e.borderCollapse==="separate"?i.jsx(Xe,{label:r("tablePropertiesSpacing"),value:e.borderSpacing,disabled:t,onChange:s=>n({...e,borderSpacing:s})}):null]}),i.jsxs("fieldset",{className:p.group,children:[i.jsx("legend",{className:p.label,children:r("paragraphDialogBorder")}),i.jsxs("div",{className:p.field,children:[i.jsx("label",{className:p.label,htmlFor:a,children:r("paragraphDialogBorderStyle")}),i.jsx("select",{id:a,className:p.select,value:e.border.style,disabled:t,onChange:s=>{const u=s.target.value;n({...e,border:{style:u,width:u==="none"?null:e.border.width??DI,color:u==="none"?null:e.border.color}})},children:ds.map(s=>i.jsx("option",{value:s,children:r(RI[s])},s))})]}),e.border.style!=="none"?i.jsxs(i.Fragment,{children:[i.jsx(Xe,{label:r("paragraphDialogBorderWidth"),value:e.border.width,disabled:t,onChange:s=>n({...e,border:{...e.border,width:s}})}),i.jsx($t,{label:r("paragraphDialogBorderColor"),noneLabel:r("colorNone"),value:e.border.color,disabled:t,onChange:s=>n({...e,border:{...e.border,color:s}})})]}):null,i.jsx(Xe,{label:r("paragraphDialogBorderRadius"),value:e.borderRadius,disabled:t,onChange:s=>n({...e,borderRadius:s})}),i.jsxs("label",{className:p.mark,children:[i.jsx("input",{type:"checkbox",checked:e.boxShadow!==null,disabled:t,onChange:()=>{n({...e,boxShadow:e.boxShadow?null:jI})}}),r("paragraphDialogBoxShadow")]}),e.boxShadow?i.jsx(Bu,{shadow:e.boxShadow,disabled:t,onChange:s=>n({...e,boxShadow:s})}):null]})]})}function EI({open:e,value:t,disabled:n,onApply:r,onClose:o}){const a=Y(),s=l.useId(),u=l.useRef(null),[d,f]=l.useState(t);return l.useEffect(()=>{e&&f(t)},[e,t]),Ze(u,{open:e,onClose:o,focusableSelector:'button:not([disabled]):not([tabindex="-1"]), input:not([disabled]), select:not([disabled]), textarea:not([disabled])'}),e?i.jsx(we,{children:i.jsx("div",{className:p.backdrop,role:"presentation",onMouseDown:o,children:i.jsxs("div",{ref:u,className:`${p.dialog} ${p.dialogWide}`,role:"dialog","aria-modal":"true","aria-labelledby":s,onMouseDown:g=>g.stopPropagation(),children:[i.jsxs("div",{className:p.headerRow,children:[i.jsx("h2",{className:p.header,id:s,children:a("tablePropertiesDialogTitle")}),i.jsx("button",{type:"button",className:p.close,"aria-label":a("tablePropertiesDialogCloseAria"),onClick:o,children:i.jsx(Je,{})})]}),i.jsx(II,{value:d,disabled:n,onChange:f}),i.jsxs("div",{className:p.actions,children:[i.jsx("button",{type:"button",className:p.action,onClick:o,children:a("fontDialogCancel")}),i.jsx("button",{type:"button",className:`${p.action} ${p.actionPrimary}`,disabled:n,onClick:()=>r(d),children:a("fontDialogOk")})]})]})})}):null}const _I=["left","center","right"],MI={left:as,center:is,right:ss},NI={left:"commandAlignLeftAria",center:"commandAlignCenterAria",right:"commandAlignRightAria"},LI={top:"paragraphDialogSideTop",right:"paragraphDialogSideRight",bottom:"paragraphDialogSideBottom",left:"paragraphDialogSideLeft"},BI={top:"cellPropertiesVerticalAlignTop",middle:"cellPropertiesVerticalAlignMiddle",bottom:"cellPropertiesVerticalAlignBottom",baseline:"cellPropertiesVerticalAlignBaseline"};function Ra(e){return{top:e,right:e,bottom:e,left:e}}function nc(e){for(const t of it)if(e[t])return e[t];return null}function FI({value:e,disabled:t,onChange:n}){const r=Y(),o=l.useId(),a=l.useId(),s=l.useId(),[u,d]=l.useState(()=>kn(e.padding,Ra(nc(e.padding))));return l.useEffect(()=>{d(kn(e.padding,Ra(nc(e.padding))))},[e.padding]),i.jsxs("div",{className:p.body,children:[i.jsx($t,{label:r("paragraphDialogBackgroundColor"),noneLabel:r("colorNone"),value:e.backgroundColor,disabled:t,onChange:f=>n({...e,backgroundColor:f})}),i.jsx($t,{label:r("cellPropertiesColor"),noneLabel:r("colorNone"),value:e.color,disabled:t,onChange:f=>n({...e,color:f})}),i.jsxs("fieldset",{className:p.group,children:[i.jsx("legend",{className:p.label,children:r("paragraphDialogPadding")}),i.jsxs("label",{className:p.mark,children:[i.jsx("input",{type:"checkbox",checked:u,disabled:t,onChange:()=>{const f=!u;d(f),f&&n({...e,padding:Ra(nc(e.padding))})}}),r("paragraphDialogLinkSides")]}),i.jsx("div",{className:p.sideGrid,children:(u?["top"]:it).map(f=>i.jsx(Xe,{label:r(u?"paragraphDialogPadding":LI[f]),value:e.padding[f],disabled:t,onChange:g=>{const h=u?Ra(g):{...e.padding,[f]:g};n({...e,padding:h})}},f))})]}),i.jsxs("fieldset",{className:p.group,children:[i.jsx("legend",{className:p.label,children:r("paragraphDialogAlignment")}),i.jsx("div",{className:p.iconRow,role:"radiogroup","aria-label":r("paragraphDialogAlignment"),children:_I.map(f=>{const g=MI[f],h=(e.textAlign??"left")===f;return i.jsx("button",{type:"button",className:p.iconButton,role:"radio","aria-checked":h,"aria-label":r(NI[f]),disabled:t,onClick:()=>{n({...e,textAlign:f==="left"?null:f})},children:i.jsx(g,{})},f)})})]}),i.jsxs("div",{className:p.field,children:[i.jsx("label",{className:p.label,htmlFor:o,children:r("cellPropertiesVerticalAlign")}),i.jsxs("select",{id:o,className:p.select,value:e.verticalAlign??"",disabled:t,onChange:f=>{const g=f.target.value;n({...e,verticalAlign:g||null})},children:[i.jsx("option",{value:"",children:r("cellPropertiesVerticalAlignDefault")}),vs.map(f=>i.jsx("option",{value:f,children:r(BI[f])},f))]})]}),i.jsx(Xe,{label:r("cellPropertiesWidth"),value:e.width,disabled:t,onChange:f=>n({...e,width:f})}),i.jsxs("div",{className:p.sizeRow,children:[i.jsxs("div",{className:p.field,children:[i.jsx("label",{className:p.label,htmlFor:a,children:r("cellPropertiesColSpan")}),i.jsx("input",{id:a,className:p.lengthInput,type:"number",inputMode:"numeric",min:1,step:1,value:e.colSpan,disabled:t,onChange:f=>{const g=Number.parseInt(f.target.value,10);n({...e,colSpan:Number.isFinite(g)?Math.max(1,g):1})}})]}),i.jsxs("div",{className:p.field,children:[i.jsx("label",{className:p.label,htmlFor:s,children:r("cellPropertiesRowSpan")}),i.jsx("input",{id:s,className:p.lengthInput,type:"number",inputMode:"numeric",min:1,step:1,value:e.rowSpan,disabled:t,onChange:f=>{const g=Number.parseInt(f.target.value,10);n({...e,rowSpan:Number.isFinite(g)?Math.max(1,g):1})}})]})]})]})}function HI({open:e,value:t,disabled:n,onApply:r,onClose:o}){const a=Y(),s=l.useId(),u=l.useRef(null),[d,f]=l.useState(t);return l.useEffect(()=>{e&&f(t)},[e,t]),Ze(u,{open:e,onClose:o,focusableSelector:'button:not([disabled]):not([tabindex="-1"]), input:not([disabled]), select:not([disabled]), textarea:not([disabled])'}),e?i.jsx(we,{children:i.jsx("div",{className:p.backdrop,role:"presentation",onMouseDown:o,children:i.jsxs("div",{ref:u,className:`${p.dialog} ${p.dialogWide}`,role:"dialog","aria-modal":"true","aria-labelledby":s,onMouseDown:g=>g.stopPropagation(),children:[i.jsxs("div",{className:p.headerRow,children:[i.jsx("h2",{className:p.header,id:s,children:a("cellPropertiesDialogTitle")}),i.jsx("button",{type:"button",className:p.close,"aria-label":a("cellPropertiesDialogCloseAria"),onClick:o,children:i.jsx(Je,{})})]}),i.jsx(FI,{value:d,disabled:n,onChange:f}),i.jsxs("div",{className:p.actions,children:[i.jsx("button",{type:"button",className:p.action,onClick:o,children:a("fontDialogCancel")}),i.jsx("button",{type:"button",className:`${p.action} ${p.actionPrimary}`,disabled:n,onClick:()=>r(d),children:a("fontDialogOk")})]})]})})}):null}const zI={top:"paragraphDialogSideTop",right:"paragraphDialogSideRight",bottom:"paragraphDialogSideBottom",left:"paragraphDialogSideLeft"},OI={top:"cellPropertiesVerticalAlignTop",middle:"cellPropertiesVerticalAlignMiddle",bottom:"cellPropertiesVerticalAlignBottom",baseline:"cellPropertiesVerticalAlignBaseline"};function Da(e){return{top:e,right:e,bottom:e,left:e}}function rc(e){for(const t of it)if(e[t])return e[t];return null}function KI({value:e,disabled:t,onChange:n}){const r=Y(),o=l.useId(),[a,s]=l.useState(()=>kn(e.padding,Da(rc(e.padding))));return l.useEffect(()=>{s(kn(e.padding,Da(rc(e.padding))))},[e.padding]),i.jsxs("div",{className:p.body,children:[i.jsx($t,{label:r("paragraphDialogBackgroundColor"),noneLabel:r("colorNone"),value:e.backgroundColor,disabled:t,onChange:u=>n({...e,backgroundColor:u})}),i.jsx($t,{label:r("cellPropertiesColor"),noneLabel:r("colorNone"),value:e.color,disabled:t,onChange:u=>n({...e,color:u})}),i.jsxs("fieldset",{className:p.group,children:[i.jsx("legend",{className:p.label,children:r("paragraphDialogPadding")}),i.jsxs("label",{className:p.mark,children:[i.jsx("input",{type:"checkbox",checked:a,disabled:t,onChange:()=>{const u=!a;s(u),u&&n({...e,padding:Da(rc(e.padding))})}}),r("paragraphDialogLinkSides")]}),i.jsx("div",{className:p.sideGrid,children:(a?["top"]:it).map(u=>i.jsx(Xe,{label:r(a?"paragraphDialogPadding":zI[u]),value:e.padding[u],disabled:t,onChange:d=>{const f=a?Da(d):{...e.padding,[u]:d};n({...e,padding:f})}},u))})]}),i.jsxs("div",{className:p.field,children:[i.jsx("label",{className:p.label,htmlFor:o,children:r("cellPropertiesVerticalAlign")}),i.jsxs("select",{id:o,className:p.select,value:e.verticalAlign??"",disabled:t,onChange:u=>{const d=u.target.value;n({...e,verticalAlign:d||null})},children:[i.jsx("option",{value:"",children:r("cellPropertiesVerticalAlignDefault")}),vs.map(u=>i.jsx("option",{value:u,children:r(OI[u])},u))]})]}),i.jsx(Xe,{label:r("rowPropertiesHeight"),value:e.height,disabled:t,onChange:u=>n({...e,height:u})})]})}function $I({open:e,value:t,disabled:n,onApply:r,onClose:o}){const a=Y(),s=l.useId(),u=l.useRef(null),[d,f]=l.useState(t);return l.useEffect(()=>{e&&f(t)},[e,t]),Ze(u,{open:e,onClose:o,focusableSelector:'button:not([disabled]):not([tabindex="-1"]), input:not([disabled]), select:not([disabled]), textarea:not([disabled])'}),e?i.jsx(we,{children:i.jsx("div",{className:p.backdrop,role:"presentation",onMouseDown:o,children:i.jsxs("div",{ref:u,className:`${p.dialog} ${p.dialogWide}`,role:"dialog","aria-modal":"true","aria-labelledby":s,onMouseDown:g=>g.stopPropagation(),children:[i.jsxs("div",{className:p.headerRow,children:[i.jsx("h2",{className:p.header,id:s,children:a("rowPropertiesDialogTitle")}),i.jsx("button",{type:"button",className:p.close,"aria-label":a("rowPropertiesDialogCloseAria"),onClick:o,children:i.jsx(Je,{})})]}),i.jsx(KI,{value:d,disabled:n,onChange:f}),i.jsxs("div",{className:p.actions,children:[i.jsx("button",{type:"button",className:p.action,onClick:o,children:a("fontDialogCancel")}),i.jsx("button",{type:"button",className:`${p.action} ${p.actionPrimary}`,disabled:n,onClick:()=>r(d),children:a("fontDialogOk")})]})]})})}):null}const UI="_backdrop_9d3gw_1",VI="_dialog_9d3gw_12",WI="_headerRow_9d3gw_29",GI="_header_9d3gw_29",ZI="_close_9d3gw_44",qI="_body_9d3gw_66",YI="_frame_9d3gw_75",XI="_actions_9d3gw_83",JI="_action_9d3gw_83",wn={backdrop:UI,dialog:VI,headerRow:WI,header:GI,close:ZI,body:qI,frame:YI,actions:XI,action:JI};function QI(e){const t=On(e);if(t.length<=1)return e;const n=[],r=[];for(const a of t){const s=ge(a);n.push(...s.hrefs),r.push(s.body)}const o=r.map((a,s)=>`<div class="wysiwyg-preview-page" style="${s===r.length-1?"display: block; break-inside: avoid; page-break-inside: avoid;":"display: block; break-after: page; page-break-after: always; break-inside: avoid; page-break-inside: avoid;"}">${a}</div>`).join("");return[...Array.from(new Set(n)).map(a=>`<link rel="stylesheet" href="${a}" />`),o].filter(Boolean).join("")}function eE({open:e,html:t,onClose:n}){const r=Y(),o=l.useId(),a=l.useRef(null),s=l.useRef(null),u=l.useMemo(()=>QI(t),[t]);return Ze(a,{open:e,onClose:n,escapeIgnoreSelectors:!1,focusableSelector:'button:not([disabled]):not([tabindex="-1"]), input:not([disabled]), select:not([disabled])'}),l.useEffect(()=>{var f;if(!e)return;const d=(f=s.current)==null?void 0:f.contentDocument;d&&xc(d,u,r("previewDialogTitle"))},[e,u,r]),e?i.jsx(we,{children:i.jsx("div",{className:wn.backdrop,role:"presentation",onMouseDown:n,children:i.jsxs("div",{ref:a,className:wn.dialog,role:"dialog","aria-modal":"true","aria-labelledby":o,onMouseDown:d=>d.stopPropagation(),children:[i.jsxs("div",{className:wn.headerRow,children:[i.jsx("h2",{className:wn.header,id:o,children:r("previewDialogTitle")}),i.jsx("button",{type:"button",className:wn.close,"aria-label":r("previewDialogCloseAria"),onClick:n,children:i.jsx(Je,{})})]}),i.jsx("div",{className:wn.body,children:i.jsx("iframe",{ref:s,className:wn.frame,title:r("previewDialogTitle"),sandbox:"allow-same-origin",tabIndex:-1,onLoad:()=>{var f;const d=(f=s.current)==null?void 0:f.contentDocument;d&&xc(d,u,r("previewDialogTitle"))}})}),i.jsx("div",{className:wn.actions,children:i.jsx("button",{type:"button",className:wn.action,onClick:n,children:r("previewDialogClose")})})]})})}):null}const tE="0.0.11",nE="_backdrop_72ox3_1",rE="_dialog_72ox3_12",oE="_headerRow_72ox3_30",iE="_header_72ox3_30",aE="_close_72ox3_46",sE="_body_72ox3_68",lE="_product_72ox3_76",cE="_meta_72ox3_82",uE="_description_72ox3_87",dE="_website_72ox3_92",mE="_cta_72ox3_97",fE="_link_72ox3_102",pE="_actions_72ox3_118",gE="_action_72ox3_118",Ct={backdrop:nE,dialog:rE,headerRow:oE,header:iE,close:aE,body:sE,product:lE,meta:cE,description:uE,website:dE,cta:mE,link:fE,actions:pE,action:gE};function hE({open:e,onClose:t}){const n=Y(),r=l.useId(),o=l.useRef(null);return Ze(o,{open:e,onClose:t,escapeIgnoreSelectors:!1,focusableSelector:'a[href], button:not([disabled]):not([tabindex="-1"])'}),e?i.jsx(we,{children:i.jsx("div",{className:Ct.backdrop,role:"presentation",onMouseDown:t,children:i.jsxs("div",{ref:o,className:Ct.dialog,role:"dialog","aria-modal":"true","aria-labelledby":r,onMouseDown:a=>a.stopPropagation(),children:[i.jsxs("div",{className:Ct.headerRow,children:[i.jsx("h2",{id:r,className:Ct.header,children:n("aboutDialogTitle")}),i.jsx("button",{type:"button",className:Ct.close,onClick:t,"aria-label":n("aboutDialogCloseAria"),children:i.jsx(Je,{})})]}),i.jsxs("div",{className:Ct.body,children:[i.jsx("p",{className:Ct.product,children:n("brandMarkAria")}),i.jsx("p",{className:Ct.meta,children:n("aboutDialogVersion").replace("{version}",tE)}),i.jsx("p",{className:Ct.description,children:n("aboutDialogDescription")}),i.jsxs("div",{className:Ct.website,children:[i.jsx("p",{className:Ct.cta,children:n("aboutDialogWebsiteCta")}),i.jsx("a",{className:Ct.link,href:"https://commspliant.com/",target:"_blank",rel:"noopener noreferrer","aria-label":n("aboutDialogWebsiteAria"),children:n("aboutDialogWebsite")})]})]}),i.jsx("div",{className:Ct.actions,children:i.jsx("button",{type:"button",className:Ct.action,onClick:t,children:n("aboutDialogClose")})})]})})}):null}const bE="_backdrop_12fkg_1",yE="_dialog_12fkg_12",xE="_headerRow_12fkg_31",CE="_header_12fkg_31",wE="_close_12fkg_47",vE="_searchRow_12fkg_69",kE="_search_12fkg_69",SE="_body_12fkg_91",AE="_sidebar_12fkg_99",PE="_category_12fkg_111",TE="_topicList_12fkg_121",RE="_topicButton_12fkg_127",DE="_topicButtonActive_12fkg_147",jE="_main_12fkg_157",IE="_articleTitle_12fkg_164",EE="_articleBody_12fkg_171",_E="_noResults_12fkg_176",ME="_related_12fkg_181",NE="_relatedTitle_12fkg_187",LE="_relatedList_12fkg_194",BE="_relatedButton_12fkg_200",FE="_relatedItem_12fkg_223",Oe={backdrop:bE,dialog:yE,headerRow:xE,header:CE,close:wE,searchRow:vE,search:kE,body:SE,sidebar:AE,category:PE,topicList:TE,topicButton:RE,topicButtonActive:DE,main:jE,articleTitle:IE,articleBody:EE,noResults:_E,related:ME,relatedTitle:NE,relatedList:LE,relatedButton:BE,relatedItem:FE};function HE(e){return{getStarted:"helpCategoryGetStarted",file:"helpCategoryFile",edit:"helpCategoryEdit",insert:"helpCategoryInsert",format:"helpCategoryFormat",table:"helpCategoryTable",view:"helpCategoryView",keyboard:"helpCategoryKeyboard"}[e]}function zE({open:e,topicId:t,onTopicChange:n,onClose:r}){const o=Y(),a=l.useId(),s=l.useRef(null),[u,d]=l.useState("");Ze(s,{open:e,onClose:r,escapeIgnoreSelectors:!1,focusableSelector:'button:not([disabled]):not([tabindex="-1"]), input:not([disabled]), select:not([disabled])'}),l.useEffect(()=>{e||d("")},[e]);const f=l.useMemo(()=>zc.map(b=>({id:b.id,title:o(b.titleKey),body:o(b.bodyKey),keywords:o(b.keywordsKey)})),[o]),g=l.useMemo(()=>{const b=DR(f,u);return new Set(b.map(C=>C.id))},[u,f]),h=Tf[t],y=u.trim().length>0&&g.size===0;return e?i.jsx(we,{children:i.jsx("div",{className:Oe.backdrop,role:"presentation",onMouseDown:r,children:i.jsxs("div",{ref:s,className:Oe.dialog,role:"dialog","aria-modal":"true","aria-labelledby":a,onMouseDown:b=>b.stopPropagation(),children:[i.jsxs("div",{className:Oe.headerRow,children:[i.jsx("h2",{id:a,className:Oe.header,children:o("helpDialogTitle")}),i.jsx("button",{type:"button",className:Oe.close,onClick:r,"aria-label":o("helpDialogCloseAria"),children:i.jsx(Je,{})})]}),i.jsx("div",{className:Oe.searchRow,children:i.jsx("input",{type:"search",className:Oe.search,value:u,onChange:b=>d(b.target.value),placeholder:o("helpDialogSearchPlaceholder"),"aria-label":o("helpDialogSearchAria")})}),i.jsxs("div",{className:Oe.body,children:[i.jsx("aside",{className:Oe.sidebar,"aria-label":o("helpDialogContentsAria"),children:TR.map(b=>{const C=zc.filter(x=>x.category===b&&g.has(x.id));return C.length===0?null:i.jsxs("div",{children:[i.jsx("h3",{className:Oe.category,children:o(HE(b))}),i.jsx("ul",{className:Oe.topicList,children:C.map(x=>i.jsx("li",{children:i.jsx("button",{type:"button",className:`${Oe.topicButton}${x.id===t?` ${Oe.topicButtonActive}`:""}`,onClick:()=>n(x.id),children:o(x.titleKey)})},x.id))})]},b)})}),i.jsx("div",{className:Oe.main,children:y?i.jsx("p",{className:Oe.noResults,children:o("helpDialogNoResults")}):i.jsxs(i.Fragment,{children:[i.jsx("h3",{className:Oe.articleTitle,children:o(h.titleKey)}),i.jsx("p",{className:Oe.articleBody,children:o(h.bodyKey)}),h.related.length>0?i.jsxs("div",{className:Oe.related,children:[i.jsx("h4",{className:Oe.relatedTitle,children:o("helpDialogRelatedTitle")}),i.jsx("ul",{className:Oe.relatedList,children:h.related.map(b=>{const C=Tf[b];return!C||!g.has(b)?null:i.jsx("li",{className:Oe.relatedItem,children:i.jsx("button",{type:"button",className:Oe.relatedButton,onClick:()=>n(b),children:o(C.titleKey)})},b)})})]}):null]})})]})]})})}):null}function eb(e){return{catalog:e.catalog,layout:e.layout,commands:e.commands,queries:e.queries,queryRevisions:e.queryRevisions,disabled:e.disabled,chromeLock:e.chromeLock}}function OE(e,t){for(const n of Object.keys(e)){const r=e[n],o=t[n];if(!(typeof r=="function"&&typeof o=="function")&&r!==o)return!1}return!0}const KE=l.memo(function({menuVisible:t,captureChromeSelection:n,displayCatalog:r,displayLayout:o,commands:a,queries:s,queryRevisions:u,chromeDisabled:d,chromeLock:f,contentLocked:g,customizeToolbarOpen:h,baseCatalog:y,allowedLayout:b,toolbarSettings:C,toolbarSettingsLoading:x,toolbarSettingsBusy:v,onCustomizeToolbarClose:k,onToolbarSettingsChange:S,onToolbarSettingsReset:P,documentPreview:T,onDocumentPreviewClose:D,helpDialog:R,onHelpDialogClose:A,onHelpTopicChange:E,aboutDialogOpen:B,onAboutDialogClose:z,fontDialog:_,fontSizeState:M,markState:O,fontFamilyState:G,fontColorState:q,highlightColorState:re,fontFaces:Z,onFontDialogTabChange:X,onFontDialogClose:ne,onApplyFontProperties:ce,paragraphDialog:J,customImagePicker:I,disableBuiltinImageInsert:se,onParagraphCustomImagePick:fe,onParagraphDialogTabChange:L,onParagraphDialogClose:Be,onApplyParagraphProperties:Ne,customCssDialog:Fe,onCustomCssDialogClose:bt,onApplyCustomCss:lt,pageDialog:Ee,enablePageProperties:pe,onPageCustomImagePick:De,onPageDialogTabChange:oe,onPageDialogClose:ve,onApplyPageProperties:je,onPageDialogResetAtRule:Le,deletePageConfirmOpen:Ve,onDeletePageConfirmClose:Ut,onDeletePageConfirm:gn,customStyleDialog:Qe,canDeleteCustomParagraphStyle:wr,customStyleBusy:vr,onCustomStyleDialogClose:He,onCustomStyleSave:Jt,onCustomStyleDelete:kr,linkDialog:et,onLinkDialogTabChange:Sr,onLinkDialogClose:V,onApplyLink:ee,bookmarkDialog:ue,onBookmarkDialogClose:Ke,onApplyBookmark:Vt,imageDialogOpen:er,customAudioPicker:ct,customVideoPicker:$e,onImageDialogClose:Se,onApplyImage:We,onImageDialogCustomPick:Qt,audioDialogOpen:ks,onAudioDialogClose:di,onApplyAudio:Ss,onAudioDialogCustomPick:at,youtubeDialogOpen:mi,onYoutubeDialogClose:Tt,onApplyYoutube:tr,onYoutubeDialogCustomPick:Pn,imageProperties:Ar,onImagePropertiesTabChange:mo,onImagePropertiesClose:As,onApplyImageProperties:fi,tableDialogOpen:Tn,onTableDialogClose:hn,onApplyTable:fo,tableProperties:Rn,onTablePropertiesClose:H,onApplyTableProperties:Lt,cellProperties:po,onCellPropertiesClose:Pr,onApplyCellProperties:Rt,rowProperties:Dn,onRowPropertiesClose:ut,onApplyRowProperties:he}){const go=eb({catalog:r,layout:o,commands:a,queries:s,queryRevisions:u,disabled:d,chromeLock:f});return i.jsxs(i.Fragment,{children:[t?i.jsx("div",{className:xe.menuChrome,onPointerDownCapture:n,children:i.jsx(Oc,{...go,menuVisible:!0,toolbarVisible:!1})}):null,h?i.jsx(zA,{open:!0,catalog:y,groups:b.iconGroups,settings:C,loading:x,busy:v,disabled:g,onChange:S,onReset:P,onClose:k}):null,T.open?i.jsx(eE,{open:!0,html:T.html,onClose:D}):null,R.open?i.jsx(zE,{open:!0,topicId:R.topicId,onTopicChange:E,onClose:A}):null,B?i.jsx(hE,{open:!0,onClose:z}):null,_.open?i.jsx(bj,{open:!0,tab:_.tab,size:M.value,unit:M.unit,marks:O,fontFamily:G.value,fontFamilyMixed:G.mixed,fontColor:q.value,fontColorMixed:q.mixed,highlightColor:re.value,highlightColorMixed:re.mixed,fonts:Z,disabled:g,onTabChange:X,onApply:ce,onClose:ne}):null,J.open?i.jsx(Oj,{open:!0,tab:J.tab,value:J.value,backgroundImage:J.backgroundImage,disabled:g,customImagePicker:I,disableBuiltinImageInsert:se,onCustomImagePick:fe,onTabChange:L,onApply:Ne,onClose:Be}):null,Fe.open?i.jsx(eI,{open:!0,value:Fe.value,disabled:g,onApply:lt,onClose:bt}):null,Ee.open?i.jsx(qj,{open:!0,tab:Ee.tab,initialParagraphTab:Ee.paragraphTab,value:Ee.value,fonts:Z,disabled:g,printTabVisible:pe,customImagePicker:I,disableBuiltinImageInsert:se,onCustomImagePick:De,onTabChange:oe,onApply:je,onResetAtRule:Le,onClose:ve}):null,Ve?i.jsx(Yj,{open:!0,disabled:g,onClose:Ut,onConfirm:gn}):null,Qe.open?i.jsx(Qj,{open:!0,mode:Qe.mode,styleId:Qe.mode==="edit"?Qe.style.id:void 0,name:Qe.mode==="edit"?Qe.style.name:"",font:Qe.mode==="edit"?Qe.style.font:Qe.font,paragraph:Qe.mode==="edit"?Qe.style.paragraph:Qe.paragraph,canDelete:wr,fonts:Z,busy:vr,disabled:g,onSave:Jt,onDelete:kr,onClose:He}):null,et.open?i.jsx(CI,{open:!0,tab:et.tab,href:et.href,title:et.title,targetBlank:et.targetBlank,textDecorationNone:et.textDecorationNone,hoverMode:et.hoverMode,hoverColor:et.hoverColor,hoverHtml:et.hoverHtml,bookmarks:et.bookmarks,selectedBookmarkId:et.selectedBookmarkId,disabled:g,onTabChange:Sr,onApply:ee,onClose:V}):null,ue.open?i.jsx(nI,{open:!0,existingIds:ue.existingIds,disabled:g,onApply:Vt,onClose:Ke}):null,er?i.jsx(aI,{open:!0,disabled:g,customImagePicker:I,onApply:We,onCustomPick:Qt,onClose:Se}):null,ks?i.jsx(iI,{open:!0,disabled:g,customAudioPicker:ct,onApply:Ss,onCustomPick:at,onClose:di}):null,mi?i.jsx(wI,{open:!0,disabled:g,customVideoPicker:$e,onApply:tr,onCustomPick:Pn,onClose:Tt}):null,Ar.open?i.jsx(xI,{open:!0,tab:Ar.tab,value:Ar.value,aspectRatio:Ar.aspectRatio,disabled:g,onTabChange:mo,onApply:fi,onClose:As}):null,Tn?i.jsx(TI,{open:!0,disabled:g,onApply:fo,onClose:hn}):null,Rn.open?i.jsx(EI,{open:!0,value:Rn.value,disabled:g,onApply:Lt,onClose:H}):null,po.open?i.jsx(HI,{open:!0,value:po.value,disabled:g,onApply:Rt,onClose:Pr}):null,Dn.open?i.jsx($I,{open:!0,value:Dn.value,disabled:g,onApply:he,onClose:ut}):null]})},OE);function $E({toolbarVisible:e,toolbarPos:t,captureChromeSelection:n,toolbarShellProps:r,children:o}){return i.jsxs("div",{className:xe.body,"data-icon-dock":e?t:void 0,children:[e&&(t==="top"||t==="left")?i.jsx("div",{className:xe.iconChrome,onPointerDownCapture:n,children:i.jsx(Oc,{...r,menuVisible:!1,toolbarVisible:!0,position:t})}):null,o,e&&(t==="bottom"||t==="right")?i.jsx("div",{className:xe.iconChrome,onPointerDownCapture:n,children:i.jsx(Oc,{...r,menuVisible:!1,toolbarVisible:!0,position:t})}):null]})}const tb=l.createContext(null);function UE({value:e,children:t}){return i.jsx(tb.Provider,{value:e,children:t})}function VE(){const e=l.useContext(tb);if(!e)throw new Error("useEditorShellContext must be used within EditorShellProvider");return e}function WE(e,t){const n=l.useRef([]),r=l.useRef([]);return l.useMemo(()=>{const o=n.current,a=r.current,s=[];for(let u=0;u<e.length;u+=1){const d=e[u]??"";o[u]===d&&a[u]!==void 0?s.push(a[u]):s.push(ge(d).body)}return n.current=e,r.current=s,s},[e,t,e.length])}const GE="_panel_6xdnw_1",ZE="_header_6xdnw_17",qE="_title_6xdnw_26",YE="_close_6xdnw_32",XE="_messages_6xdnw_48",JE="_empty_6xdnw_57",QE="_message_6xdnw_48",e_="_messageHeader_6xdnw_69",t_="_author_6xdnw_77",n_="_time_6xdnw_81",r_="_body_6xdnw_86",o_="_reply_6xdnw_92",i_="_input_6xdnw_100",a_="_post_6xdnw_111",wt={panel:GE,header:ZE,title:qE,close:YE,messages:XE,empty:JE,message:QE,messageHeader:e_,author:t_,time:n_,body:r_,reply:o_,input:i_,post:a_};function s_(e,t){const n=new Date(e);return Number.isNaN(n.getTime())?e:new Intl.DateTimeFormat(t,{dateStyle:"medium",timeStyle:"short"}).format(n)}function l_({thread:e,locale:t,disabled:n,commentAuthor:r,panelRef:o,onPost:a,onClose:s}){const u=Y(),[d,f]=l.useState(""),g=l.useRef(null);l.useEffect(()=>{var x;(x=g.current)==null||x.focus()},[e==null?void 0:e.id]);const h=!n&&r&&d.trim().length>0,y=l.useMemo(()=>(e==null?void 0:e.messages)??[],[e==null?void 0:e.messages]),b=y.length===0?u("commentPlaceholder"):u("commentReplyPlaceholder");if(!e)return null;const C=()=>{const x=d.trim();!x||!h||(a(x),f(""))};return Kc.createPortal(i.jsxs("div",{ref:o,className:wt.panel,role:"dialog","aria-label":u("commentPanelTitle"),children:[i.jsxs("div",{className:wt.header,children:[i.jsx("h2",{className:wt.title,children:u("commentPanelTitle")}),i.jsx("button",{type:"button",className:wt.close,onClick:s,"aria-label":u("commentPanelCloseAria"),children:i.jsx(Je,{})})]}),i.jsx("div",{className:wt.messages,children:y.length===0?i.jsx("p",{className:wt.empty,children:u("commentEmpty")}):y.map(x=>i.jsxs("article",{className:wt.message,children:[i.jsxs("header",{className:wt.messageHeader,children:[i.jsx("span",{className:wt.author,children:x.userName}),i.jsx("time",{className:wt.time,dateTime:x.createdAt,children:s_(x.createdAt,t)})]}),i.jsx("p",{className:wt.body,children:x.message})]},x.id))}),i.jsxs("div",{className:wt.reply,children:[i.jsx("textarea",{ref:g,className:wt.input,value:d,onChange:x=>f(x.target.value),placeholder:b,rows:3,disabled:n||!r}),i.jsx("button",{type:"button",className:wt.post,onClick:C,disabled:!h,children:u("commentPost")})]})]}),document.body)}const c_=l.forwardRef(function({html:t,onChange:n,placeholder:r,disabled:o},a){const s=Y();return i.jsx("textarea",{ref:a,className:`${xe.surface} ${xe.html}`,value:t,onChange:u=>n(u.target.value),placeholder:r,disabled:o,"aria-label":s("htmlEditorAria"),spellCheck:!1})}),u_="_shell_yvznc_1",d_="_scrollButton_yvznc_10",m_="_tabList_yvznc_48",f_="_tab_yvznc_48",p_="_tabActive_yvznc_86",$r={shell:u_,scrollButton:d_,tabList:m_,tab:f_,tabActive:p_},g_=5,Ff=120;function h_({pageCount:e,activeIndex:t,onSelect:n}){const r=Y(),o=l.useRef(null),[a,s]=l.useState(!1),[u,d]=l.useState(!1),f=e>=g_,g=l.useCallback(()=>{const b=o.current;if(!b)return;const{scrollLeft:C,scrollWidth:x,clientWidth:v}=b;s(C>1),d(C+v<x-1)},[]);l.useEffect(()=>{g()},[e,t,g]),l.useEffect(()=>{var x;const b=o.current;if(!b)return;const C=b.querySelector(`[data-page-tab="${t}"]`);(x=C==null?void 0:C.scrollIntoView)==null||x.call(C,{block:"nearest",inline:"nearest"}),g()},[t,g]),l.useEffect(()=>{const b=o.current;if(!b)return;const C=()=>g();if(b.addEventListener("scroll",C,{passive:!0}),typeof ResizeObserver>"u")return()=>{b.removeEventListener("scroll",C)};const x=new ResizeObserver(()=>g());return x.observe(b),()=>{b.removeEventListener("scroll",C),x.disconnect()}},[g]);const h=b=>{var C;(C=o.current)==null||C.scrollBy({left:b,behavior:"smooth"})},y=b=>r("htmlModePageTab").replace("{n}",String(b+1));return i.jsxs("div",{className:$r.shell,children:[f?i.jsx("button",{type:"button",className:$r.scrollButton,"aria-label":r("htmlModePageTabsScrollLeftAria"),disabled:!a,onClick:()=>h(-Ff),children:"‹"}):null,i.jsx("div",{ref:o,className:$r.tabList,role:"tablist","aria-label":r("htmlModePageTabsAria"),children:Array.from({length:e},(b,C)=>i.jsx("button",{type:"button",role:"tab","data-page-tab":C,className:`${$r.tab} ${C===t?$r.tabActive:""}`,"aria-selected":C===t,tabIndex:C===t?0:-1,onClick:()=>n(C),children:y(C)},C))}),f?i.jsx("button",{type:"button",className:$r.scrollButton,"aria-label":r("htmlModePageTabsScrollRightAria"),disabled:!u,onClick:()=>h(Ff),children:"›"}):null]})}function b_(e,t,n=!0){const[r,o]=l.useState(null),[a,s]=l.useState(Nu()),u=l.useCallback(()=>{!n||!e||(o(Vh(e,t)),s(rs(e)))},[n,e,t]);return l.useLayoutEffect(()=>{if(!n)return;const d=requestAnimationFrame(u);return()=>cancelAnimationFrame(d)},[n,u]),l.useLayoutEffect(()=>{if(!n||!e||typeof ResizeObserver>"u")return;const d=new ResizeObserver(()=>u());return d.observe(e),()=>d.disconnect()},[n,e,u]),l.useLayoutEffect(()=>{if(!n||!e)return;const d=()=>{s(rs(e))};return document.addEventListener("selectionchange",d),()=>document.removeEventListener("selectionchange",d)},[n,e]),{geometry:r,indentState:a,refresh:u}}const y_=l.forwardRef(function({html:t,pageHtml:n,onChange:r,placeholder:o,disabled:a,rulerVisible:s=!0,rulerUnit:u="in",zoomScale:d=1,onMarginChange:f,onMarginPreview:g,onIndentChange:h,onBeforeInput:y,propSyncGuardRef:b,resolveEmbeddedImageDataUrl:C,hydrateEmbeddedImages:x,onPointerDown:v,onMouseUp:k,onContextMenu:S},P){const T=Y(),D=l.useRef(null),R=l.useRef(!1),[A,E]=l.useState(null),B=l.useRef(y);B.current=y;const z=n??t,_=s&&ii(z),{geometry:M,indentState:O,refresh:G}=b_(A,z,_),q=Z=>{D.current=Z,E(Z),typeof P=="function"?P(Z):P&&(P.current=Z)};l.useLayoutEffect(()=>{const Z=D.current;if(!Z)return;const X=ln(t),ce=Z===document.activeElement&&R.current;if(R.current=!1,ce||Qa(Z,X,{resolveDataUrl:C,hydrateEmbeddedImages:x}),gt(Z)||ii(z)){pu(Z),ni(Z),hs(Z);const J=gt(Z);J&&Kp(Z,J)}gs(Z),co(Z,z)},[t,z,C,x]),l.useLayoutEffect(()=>{if(b)return b.current=()=>{R.current=!0},()=>{b.current=null}},[b]),l.useLayoutEffect(()=>{const Z=D.current;if(!Z)return;const X=ne=>{var ce;(ce=B.current)==null||ce.call(B,ne)};return Z.addEventListener("beforeinput",X),()=>Z.removeEventListener("beforeinput",X)},[]);const re=i.jsx("div",{ref:q,className:`${xe.surface} ${xe.visual} ${_?xe.pageSurface:""}`,contentEditable:!a,suppressContentEditableWarning:!0,role:"textbox","aria-multiline":"true","aria-label":T("visualEditorAria"),"aria-disabled":a||void 0,"data-placeholder":o,onPointerDown:v,onMouseUp:k,onContextMenu:S,onInput:Z=>{const X=Z.currentTarget;if(R.current=!0,gt(X)){const{absorbedBlocks:ne}=ni(X);if(r(X.innerHTML),ne.length>0){const ce=ne.length;requestAnimationFrame(()=>Wp(X,ce))}}else r(X.innerHTML);_&&G()}});return i.jsx(rj,{showRulers:_,geometry:M,indentState:O,rulerUnit:u,zoomScale:d,onMarginChange:f,onMarginPreview:g,onIndentChange:h,children:re})}),x_="_frame_bwkh8_1",C_="_handle_bwkh8_9",w_="_handleEast_bwkh8_29",v_="_handleSouth_bwkh8_37",k_="_handleSouthEast_bwkh8_45",Yo={frame:x_,handle:C_,handleEast:w_,handleSouth:v_,handleSouthEast:k_};function zo(e){const t=e.getBoundingClientRect();return{left:t.left,top:t.top,width:t.width,height:t.height}}const S_=[{handle:"e",className:Yo.handleEast,cursor:"e-resize",ariaKey:"imageResizeHandleEastAria"},{handle:"s",className:Yo.handleSouth,cursor:"s-resize",ariaKey:"imageResizeHandleSouthAria"},{handle:"se",className:Yo.handleSouthEast,cursor:"se-resize",ariaKey:"imageResizeHandleSouthEastAria"}];function oc(e){return!Number.isFinite(e.clientX)||!Number.isFinite(e.clientY)?null:{x:e.clientX,y:e.clientY}}function A_({img:e,onResize:t,onResizeEnd:n}){const r=Y(),o=l.useRef(null),a=l.useRef(e),s=l.useRef(t),u=l.useRef(n),d=l.useRef(null);a.current=e,s.current=t,u.current=n;const f=k=>{const S=o.current;S&&(S.style.left=`${k.left}px`,S.style.top=`${k.top}px`,S.style.width=`${k.width}px`,S.style.height=`${k.height}px`)};l.useLayoutEffect(()=>{f(zo(e));const k=()=>{e.isConnected&&f(zo(e))};return window.addEventListener("scroll",k,!0),window.addEventListener("resize",k),()=>{window.removeEventListener("scroll",k,!0),window.removeEventListener("resize",k)}},[e]);const g=(k,S)=>{const P=d.current,T=a.current;if(!P||!T)return;const D=b0(P.handle,P.start,{x:k-P.originX,y:S-P.originY});s.current(D.width,D.height),T.isConnected&&f(zo(T))},h=()=>{if(!d.current)return;d.current=null;const k=a.current;u.current(),k!=null&&k.isConnected&&f(zo(k))};l.useLayoutEffect(()=>{const k=P=>{if(!d.current)return;const T=oc(P);T&&g(T.x,T.y)},S=()=>{h()};return document.addEventListener("pointermove",k),document.addEventListener("pointerup",S),document.addEventListener("pointercancel",S),document.addEventListener("mousemove",k),document.addEventListener("mouseup",S),()=>{document.removeEventListener("pointermove",k),document.removeEventListener("pointerup",S),document.removeEventListener("pointercancel",S),document.removeEventListener("mousemove",k),document.removeEventListener("mouseup",S)}},[]);const y=(k,S)=>{const P=oc(S);P&&(d.current={handle:k,start:y0(a.current),originX:P.x,originY:P.y})},b=k=>S=>{S.preventDefault(),S.stopPropagation(),y(k,S);try{S.currentTarget.setPointerCapture(S.pointerId)}catch{}},C=k=>S=>{S.preventDefault(),S.stopPropagation(),y(k,S)},x=k=>{const S=oc(k);S&&g(S.x,S.y)};if(!e.isConnected)return null;const v=zo(e);return Kc.createPortal(i.jsx("div",{ref:o,className:Yo.frame,"data-image-resize-overlay":"",style:{left:v.left,top:v.top,width:v.width,height:v.height},children:S_.map(k=>i.jsx("button",{type:"button",className:`${Yo.handle} ${k.className}`,style:{cursor:k.cursor},"aria-label":r(k.ariaKey),"data-resize-handle":k.handle,onPointerDown:b(k.handle),onPointerMove:x,onPointerUp:h,onPointerCancel:h,onMouseDown:C(k.handle),onMouseMove:x,onMouseUp:h},k.handle))}),document.body)}function P_(e,t){for(const n of Object.keys(e)){const r=e[n],o=t[n];if(!(typeof r=="function"&&typeof o=="function")&&r!==o)return!1}return!0}function T_(){const e=Y();return i.jsx("div",{className:xe.htmlFileDropOverlay,"aria-hidden":"true",children:e("htmlFileDropOverlay")})}function R_({propsRef:e,pageStore:t,mode:n,enableMultiPages:r,contentLocked:o,activePageIndex:a,hasSelectedPage:s,pageZoomScale:u,rulerVisible:d,rulerUnit:f,optimizeEmbeddedImages:g,placeholder:h,controlledHtml:y,initialHtml:b,initialStorageHtml:C,defaultPages:x,ingestedPagesProp:v,onChange:k,fontFaces:S,enableComments:P,commentsVisible:T,disabled:D,locale:R,commentAuthor:A,activeThreadId:E,contextMenu:B,commentThreads:z,commands:_,htmlFileDropDragging:M,selectedImage:O}){const{htmlRef:G,pagesRef:q,documentBridgeRef:re}=VE(),[Z,X]=l.useState(C),[ne,ce]=Ea({value:g?void 0:y,defaultValue:b,onChange:r||g?void 0:k}),J=g?Z:ne,[I,se]=l.useState(()=>r?x[0]??"":""),fe=l.useRef(I);fe.current=I;const L=e.current;g?r||(G.current=Z):G.current=ne,r&&(q.current=t.pages);const Be=l.useCallback(()=>r?t.getJoinedHtml():g?Z:ne,[r,ne,g,t,Z]);l.useLayoutEffect(()=>{const oe={pageStore:t,setHtml:ce,setStorageHtml:X,getEditorHtml:Be,replacePagesFromHistory:ve=>t.replacePages([...ve])};return re.current=oe,()=>{re.current===oe&&(re.current=null)}},[re,Be,t,ce,X]);const Ne=l.useMemo(()=>{if(r){const oe=t.pages[a]??t.pages[0]??"";return vm(oe,S).join(`
319
+ `)}return vm(J,S).join(`
320
+ `)},[r,t.pages,t.revision,a,J,S]),Fe=WE(r?t.pages:[],r?t.revision:0);l.useLayoutEffect(()=>{var ve;if(!r)return;const oe=(ve=e.current.multiPageVisualRef.current)==null?void 0:ve.getActivePageRoot();oe instanceof HTMLDivElement&&(e.current.visualRootRef.current=oe)},[r,a,Fe.length,e]);const bt=l.useMemo(()=>r?Fe[s?a:0]??"":ge(J).body,[r,Fe,a,s,J]),lt=l.useMemo(()=>Hp(rt(bt)),[bt]);L.activePageHtmlRef.current=bt,L.pageCanvasSizedRef.current=lt,l.useEffect(()=>{const ve=(Ne?Ne.split(`
321
+ `):[]).map(je=>{const Le=document.createElement("link");return Le.rel="stylesheet",Le.href=je,Le.setAttribute(ls,""),document.head.append(Le),Le});return()=>{for(const je of ve)je.remove()}},[Ne]),l.useEffect(()=>{(!P||n!=="visual"||!T)&&e.current.setActiveThreadId(null)},[P,n,T,e]),l.useEffect(()=>{if(!E)return;const oe=ve=>{var Ut;const je=e.current,Le=ve.target;if((Ut=je.commentPanelRef.current)!=null&&Ut.contains(Le))return;const Ve=je.visualRootRef.current;Ve&&sh(Ve,Le)||je.setActiveThreadId(null)};return document.addEventListener("pointerdown",oe),()=>document.removeEventListener("pointerdown",oe)},[E,e]),l.useEffect(()=>{if(!r||n!=="html")return;const oe=t.pages[a]??"";oe!==fe.current&&(fe.current=oe,se(oe))},[r,n,t.pages,t.revision,a]),l.useEffect(()=>{if(!P||n!=="visual")return;const oe=e.current.visualRootRef.current;oe&&(sS(oe,z),ah(oe,T))},[P,n,z,T,J,e]),L.htmlModePageHtmlRef.current=fe.current;const Ee=n==="visual"&&d&&lt,pe=l.useMemo(()=>E?dS(z,E):null,[E,z]),De=n==="visual"?r?i.jsx(aj,{ref:L.multiPageVisualRef,pages:Fe,activePageIndex:a,hasSelectedPage:s,scrollRootRef:L.workspaceRef,suppressPageFlushRef:L.suppressPageFlushRef,onActivePageIndexChange:oe=>{var Le;L.activePageIndexRef.current=oe,L.setActivePageIndex(oe);const ve=(Le=L.multiPageVisualRef.current)==null?void 0:Le.getContainer(),je=ve?nt(ve,oe):null;je instanceof HTMLDivElement&&(L.visualRootRef.current=je)},onPageSelected:()=>{L.setHasSelectedPage(!0)},onPageChange:(oe,ve)=>{const je=q.current[oe]??"";L.recordPageVisualHtml(oe,an(ve,ge(je).body),!0)},onPageFlush:(oe,ve)=>{const je=q.current[oe]??"";L.recordPageVisualHtml(oe,an(ve,ge(je).body),!1)},onBeforeInput:L.handleVisualBeforeInput,onPointerDown:oe=>{if(oe.currentTarget instanceof HTMLDivElement&&(L.visualRootRef.current=oe.currentTarget),L.handleVisualPointerDown(oe),oe.currentTarget instanceof HTMLDivElement){const ve=oe.currentTarget;requestAnimationFrame(()=>to(ve))}},onMouseUp:L.handleVisualMouseUp,onContextMenu:L.handleVisualContextMenu,placeholder:h,disabled:o,rulerVisible:d,rulerUnit:f,zoomScale:u,onMarginPreview:L.multiPageRulerMarginPreview,onMarginChange:L.multiPageRulerMarginChange,onIndentChange:L.multiPageRulerIndentChange,resolveEmbeddedImageDataUrl:g?L.resolveEmbeddedImageDataUrl:void 0,hydrateEmbeddedImages:g?L.hydrateExportHtml:void 0}):i.jsx(y_,{ref:L.visualRootRef,html:ge(J).body,pageHtml:J,rulerVisible:d,rulerUnit:f,zoomScale:u,propSyncGuardRef:L.visualPropSyncGuardRef,resolveEmbeddedImageDataUrl:g?L.resolveEmbeddedImageDataUrl:void 0,hydrateEmbeddedImages:g?L.hydrateExportHtml:void 0,onMarginPreview:L.singlePageRulerMarginPreview,onMarginChange:L.singlePageRulerMarginChange,onIndentChange:L.singlePageRulerIndentChange,onChange:oe=>L.recordVisualInputHtml(oe,!0),onBeforeInput:L.handleVisualBeforeInput,onPointerDown:oe=>{if(L.handleVisualPointerDown(oe),oe.currentTarget instanceof HTMLDivElement){const ve=oe.currentTarget;requestAnimationFrame(()=>to(ve))}},onMouseUp:L.handleVisualMouseUp,onContextMenu:L.handleVisualContextMenu,placeholder:h,disabled:o}):i.jsxs("div",{className:xe.htmlModeShell,children:[r&&t.pages.length>1?i.jsx(h_,{pageCount:t.pages.length,activeIndex:a,onSelect:L.handleHtmlPageTabSelect}):null,i.jsx(c_,{ref:L.htmlAreaRef,html:r?I:J,onChange:L.handleHtmlSurfaceChange,placeholder:h,disabled:o})]});return i.jsxs(i.Fragment,{children:[i.jsxs("div",{ref:L.workspaceRef,className:`${xe.workspace} ${lt?xe.workspacePageSized:""} ${Ee?xe.workspaceWithRuler:""}`,onDragEnter:L.htmlFileDrop.onDragEnter,onDragOver:L.htmlFileDrop.onDragOver,onDragLeave:L.htmlFileDrop.onDragLeave,onDrop:L.htmlFileDrop.onDrop,children:[n==="visual"?i.jsx("div",{className:xe.pageCanvasViewport,"data-page-canvas-sized":lt?"":void 0,children:De}):De,L.htmlFileDrop.dragging?i.jsx(T_,{}):null]}),n==="visual"&&!o&&(O!=null&&O.isConnected)?i.jsx(A_,{img:O,onResize:L.handleImageResize,onResizeEnd:L.handleImageResizeEnd}):null,P&&T&&pe?i.jsx(l_,{panelRef:L.commentPanelRef,thread:pe,locale:R,disabled:D,commentAuthor:A,onPost:L.postCommentMessage,onClose:()=>L.setActiveThreadId(null)}):null,i.jsx(Jy,{open:B.open,x:B.x,y:B.y,kind:B.kind,inTable:B.inTable,canMergeCells:B.canMergeCells,canUnmergeCells:B.canUnmergeCells,canDeletePage:B.canDeletePage,canAddComment:B.canAddComment,commands:_,onClose:()=>L.setContextMenu(oe=>({...oe,open:!1}))})]})}const D_=l.memo(R_,P_),j_=.005;function I_({value:e,defaultValue:t="",onChange:n,onAutoSave:r,onSave:o,onOpen:a,mode:s,defaultMode:u="visual",onModeChange:d,fullscreen:f,defaultFullscreen:g=!1,onFullscreenChange:h,placeholder:y,disabled:b,readOnly:C=!1,className:x,locale:v="en",toolbarBackground:k,menuColor:S,menuBackground:P,menuFontSize:T,menuFontFamily:D,border:R,menuVisible:A=!0,toolbarVisible:E=!0,allowedChrome:B,customActions:z,customFonts:_,transformHtml:M,sanitizeHtml:O=!0,loadCustomParagraphStyles:G,onSaveCustomParagraphStyle:q,onDeleteCustomParagraphStyle:re,customImagePicker:Z,disableBuiltinImageInsert:X,customAudioPicker:ne,disableBuiltinAudioInsert:ce,customVideoPicker:J,disableBuiltinVideoInsert:I,disableHtmlFileDrop:se=!1,toolbarCustomization:fe,darkMode:L=!1,darkModePersistence:Be,toolbarPosition:Ne="top",toolbarPositionPersistence:Fe,enablePageProperties:bt=!1,defaultPageProperties:lt,optimizeEmbeddedImages:Ee=!1,enableMultiPages:pe=!1,pages:De,defaultPages:oe,onPagesChange:ve,defaultRulerVisible:je=!0,rulerUnit:Le="in",enableComments:Ve=!1,defaultCommentsVisible:Ut=!0,commentAuthor:gn,comments:Qe,defaultComments:wr=[],onCommentsChange:vr}){var fm;const He=!!(b||C),Jt=!!b,kr=pe?De!==void 0:e!==void 0,et=zn(oe??(t.trim()?[t]:[Bn()])),Sr=!kr&&lt?et.map(c=>nf(c,lt)):et,V=l.useRef(null);Ee&&V.current===null&&(V.current=QC());const ee=l.useRef(null);ee.current===null&&(ee.current=Ee&&V.current?Sr.map(c=>V.current.externalizeHtml(c)):[...Sr]);const ue=pe?_t(ee.current):ee.current[0]??"",Ke=O?Ur(ue):ue,Vt=pe&&De!==void 0?_t(zn(De)):e,er=l.useMemo(()=>{if(Vt!==void 0)return O?Ur(Vt):Vt},[Vt,O]),ct=l.useRef(n);ct.current=n;const $e=l.useRef(Ee);$e.current=Ee;const Se=l.useCallback(c=>!$e.current||!V.current?c:V.current.externalizeHtml(c),[]),We=l.useCallback(c=>!$e.current||!V.current?c:V.current.hydrateHtml(c),[]),Qt=l.useCallback(c=>c.map(m=>We(m)),[We]),ks=l.useCallback(c=>{var m;return((m=V.current)==null?void 0:m.getDataUrl(c))??null},[]),di=l.useCallback(c=>{var m;(m=ct.current)==null||m.call(ct,We(c))},[We]),[Ss]=l.useState(()=>{if(Ee&&e!==void 0&&!pe){const c=O?Ur(e):e;return V.current?V.current.externalizeHtml(c):c}return Ke}),[at,mi]=Ea({value:s,defaultValue:u,onChange:d}),[Tt,tr]=Ea({value:f,defaultValue:g,onChange:h}),[Pn,Ar]=l.useState(Ut),[mo,As]=l.useState(je),fi=l.useRef(mo);fi.current=mo;const[Tn,hn]=l.useState(null),[fo,Rn]=Ea({value:Qe,defaultValue:wr,onChange:vr}),H=l.useRef(null),Lt=l.useRef(null),po=l.useRef(null),Pr=l.useRef(null),Rt=l.useRef(null),Dn=l.useRef(!1),ut=l.useRef(null),he=l.useRef(pe);he.current=pe;const go=l.useRef(lt);go.current=lt;const jn=l.useRef(Ve);jn.current=Ve;const Hu=l.useRef(C);Hu.current=C;const zu=l.useRef(He);zu.current=He;const pi=l.useRef(Pn);pi.current=Pn;const gi=l.useRef(fo);gi.current=fo;const hi=l.useRef(ve);hi.current=ve;const bi=l.useRef(null),yi=l.useRef(!1),xi=l.useCallback(()=>{var m;yi.current=!1;const c=bi.current;bi.current=null,c&&((m=hi.current)==null||m.call(hi,c.pages,c.activePageIndex))},[]),Tr=l.useCallback((c,m)=>{bi.current={pages:[...c],activePageIndex:m},!yi.current&&(yi.current=!0,queueMicrotask(xi))},[xi]),Ps=l.useRef(De);Ps.current=De;const Ou=l.useMemo(()=>!Ee||De===void 0?De:zn(De).map(c=>{var w;const m=O?Ur(c):c;return((w=V.current)==null?void 0:w.externalizeHtml(m))??m}),[Ee,De,O]),dt=Q0({enabled:pe,pagesProp:Ou,defaultPages:ee.current??[Bn()]}),Rr=l.useRef(null),Ku=l.useRef(null),[Dr,ho]=l.useState(0),be=l.useRef(Dr);be.current=Dr;const bn=l.useRef(pe?((fm=ee.current)==null?void 0:fm[0])??"":""),[bo,yo]=l.useState(!1),en=l.useRef(bo);en.current=bo;const[$u,nb]=l.useState(0),Uu=l.useRef(!1),Vu=l.useRef(!1),Dt=l.useMemo(()=>HR(),[]),Ts=l.useRef(null);Ts.current===null&&(Ts.current=pe?dA(ee.current??[Bn()]):uA(Se(Ke)));const te=Ts.current,tn=l.useCallback(()=>{const c=te.canUndo(),m=te.canRedo();c===Uu.current&&m===Vu.current||(Uu.current=c,Vu.current=m,nb(w=>w+1))},[te]),ie=l.useRef(Ke),Ae=l.useRef(ee.current??[Bn()]);pe&&(Ae.current=dt.pages);const Wu=l.useRef(""),Gu=l.useRef(!1),Wt=l.useRef(!0),jr=l.useRef(""),Ir=l.useRef(null),F=l.useRef(at);F.current=at;const Zu=l.useRef(Tt);Zu.current=Tt;const qe=l.useRef(null),[,rb]=l.useState(0),xo=l.useRef(null);xo.current===null&&(xo.current=SS(()=>{rb(c=>c+1)}));const Ci=l.useRef(M);Ci.current=M;const qu=l.useRef(O);qu.current=O;const Bt=l.useRef({}),jt=l.useRef(null),Ft=l.useRef(null),Gt=l.useRef(null),Zt=l.useRef(null),In=l.useRef(null),It=l.useRef(null),[Co,Rs]=l.useState($n),Ds=l.useRef(Co);Ds.current=Co;const yn=l.useRef(Xr),[wo,wi]=l.useState({value:null,unit:Xr,mixed:!1}),En=l.useRef(wo);En.current=wo;const[vo,js]=l.useState({value:null,mixed:!1}),ko=l.useRef(vo);ko.current=vo;const[So,Is]=l.useState({value:null,mixed:!1}),Ao=l.useRef(So);Ao.current=So;const[Po,Es]=l.useState({value:null,mixed:!1}),To=l.useRef(Po);To.current=Po;const[vi,_s]=l.useState({tag:null,mixed:!1}),Ms=l.useRef(vi);Ms.current=vi;const[Yu,Ns]=l.useState({align:"left",mixed:!1}),Ls=l.useRef(Yu);Ls.current=Yu;const[Xu,Bs]=l.useState({type:null,mixed:!1}),Ro=l.useRef(Xu);Ro.current=Xu;const[Ju,Fs]=l.useState(!1),Qu=l.useRef(Ju);Qu.current=Ju;const[ki,Hs]=l.useState(!1),zs=l.useRef(ki);zs.current=ki;const[Si,ed]=l.useState(!1),Ai=l.useRef(Si);Ai.current=Si;const Pi=l.useRef(null),Ti=l.useRef(null),[td,nd]=l.useState(!1),rd=l.useRef(td);rd.current=td;const{fontDialog:Ri,setFontDialog:Di,customizeToolbarOpen:Os,setCustomizeToolbarOpen:od,documentPreview:ji,setDocumentPreview:id,toolbarSettings:Ks,setToolbarSettings:Ii,toolbarSettingsLoading:ob,setToolbarSettingsLoading:$s,toolbarSettingsBusy:ib,setToolbarSettingsBusy:Us,paragraphDialog:Do,setParagraphDialog:Er,customCssDialog:Vs,setCustomCssDialog:Ws,pageDialog:jo,setPageDialog:nr,deletePageConfirmOpen:Gs,setDeletePageConfirmOpen:Zs,customStyleDialog:ab,setCustomStyleDialog:Io,linkDialog:qs,setLinkDialog:Ei,bookmarkDialog:ad,setBookmarkDialog:Ys,imageDialog:sb,setImageDialog:_i,audioDialog:lb,setAudioDialog:Mi,youtubeDialog:cb,setYoutubeDialog:Eo,imageProperties:ub,setImageProperties:Ni,tableDialog:Xs,setTableDialog:Js,tableProperties:Qs,setTableProperties:el,cellProperties:tl,setCellProperties:nl,rowProperties:rl,setRowProperties:ol,helpDialog:il,setHelpDialog:_o,aboutDialogOpen:al,setAboutDialogOpen:sd}=J0(),[rr,Li]=l.useState(()=>Be?L:xf()??L),[_r,Bi]=l.useState(()=>Fe?Ne:Cf()??Ne),[Mo,db]=l.useState(()=>oA()??"fitWidth"),[sl,mb]=l.useState(1),[Fi,ld]=l.useState([]),[Hi,ll]=l.useState(!1),[fb,zi]=l.useState(!1),[pb,cl]=l.useState({open:!1,x:0,y:0,kind:"caret",inTable:!1,canMergeCells:!1,canUnmergeCells:!1,canDeletePage:!1,canAddComment:!1}),[mt,Mr]=l.useState(null),ul=l.useRef(mt);ul.current=mt;const[Oi,cd]=l.useState(!1),ud=l.useRef(Oi);ud.current=Oi;const[Ki,dd]=l.useState(!1),md=l.useRef(Ki);md.current=Ki;const[$i,fd]=l.useState(!1),pd=l.useRef($i);pd.current=$i;const gd=l.useRef(void 0),Ui=l.useRef(Fi);Ui.current=Fi;const hd=l.useRef(Hi);hd.current=Hi;const Vi=!!(G&&q),dl=l.useRef(Vi);dl.current=Vi;const bd=l.useRef(G);bd.current=G;const yd=l.useRef(q);yd.current=q;const xd=l.useRef(re);xd.current=re;const Cd=l.useRef(o);Cd.current=o;const wd=l.useRef(a);wd.current=a;const Wi=l.useRef(Z);Wi.current=Z;const vd=l.useRef(ne);vd.current=ne;const kd=l.useRef(J);kd.current=J;const Sd=l.useRef(fe);Sd.current=fe;const Ad=l.useRef(Be);Ad.current=Be;const Pd=l.useRef(Fe);Pd.current=Fe;const Td=l.useRef(rr);Td.current=rr;const Rd=l.useRef(_r);Rd.current=_r;const Gi=l.useRef(Mo);Gi.current=Mo;const Zi=l.useRef(sl);Zi.current=sl;const qi=l.useRef(X);qi.current=X;const Dd=l.useRef(ce);Dd.current=ce;const jd=l.useRef(I);jd.current=I;const ml=l.useRef(0),No=l.useRef(0),Id=l.useRef(0),Yi=l.useRef(0),Ed=l.useRef(0),Xi=l.useRef(0),_d=l.useRef(0),Nr=l.useMemo(()=>ep(_),[_]),Lr=l.useRef(Nr);Lr.current=Nr;const Ji=l.useCallback(()=>{var c;if(he.current){const m=(c=Rt.current)==null?void 0:c.getActivePageRoot();if(m instanceof HTMLElement)return m}return H.current},[]),Lo=l.useCallback(()=>{if(he.current){const c=Rt.current;if(!c)return null;c.ensurePageMounted(be.current);const m=c.getContainer(),w=m?nt(m,be.current):null;return w instanceof HTMLDivElement?(H.current=w,w):null}return H.current},[]);l.useLayoutEffect(()=>{var m;if(!pe)return;const c=(m=Rt.current)==null?void 0:m.getActivePageRoot();c instanceof HTMLDivElement&&(H.current=c)},[pe,Dr]);const Qi=l.useRef(()=>{}),fl=l.useRef(!1),gb=l.useCallback(()=>{if(fl.current||F.current!=="visual")return;const c=Pr.current;if(c){fl.current=!0;try{const m=getComputedStyle(c),w=parseFloat(m.paddingLeft)+parseFloat(m.paddingRight),j=parseFloat(m.paddingTop)+parseFloat(m.paddingBottom),N=Math.max(0,c.clientWidth-w),U=Math.max(0,c.clientHeight-j);let Q=0,de=0;if(Gu.current){const Re=IC(rt(Wu.current));Re&&(Q=Re.width,de=Re.height)}else{const Re=Ji(),ft=Zi.current>0?Zi.current:1;Q=((Re==null?void 0:Re.offsetWidth)??0)/ft,de=((Re==null?void 0:Re.offsetHeight)??0)/ft}Q<=0&&(Q=N),de<=0&&(de=U);const _e=z1(Gi.current,N,U,Q,de);Math.abs(_e-Zi.current)>=j_&&mb(_e)}finally{fl.current=!1}}},[Ji]);Qi.current=gb,l.useLayoutEffect(()=>{if(at!=="visual")return;const c=Ji();!c||c!==document.activeElement||to(c)},[at,Dr,Ji]);const ea=l.useCallback(async()=>{const c=bd.current;if(!c)return;const m=++ml.current;ll(!0);try{const w=await c();if(m!==ml.current)return;ld(w)}catch{}finally{m===ml.current&&ll(!1)}},[]);l.useEffect(()=>{if(!G||!q){ld([]),ll(!1);return}ea()},[G,q,ea]);const Md=l.useCallback(async c=>{Ii(c);const m=Sd.current;if(m!=null&&m.load&&m.save){const w=++Id.current;Us(!0);try{await m.save(c)}catch{}finally{w===Id.current&&Us(!1)}return}bA(c)},[]);l.useEffect(()=>{const c=fe;if(!(c!=null&&c.load)||!c.save){Ii(hA()),$s(!1),Us(!1);return}const m=++No.current;return $s(!0),(async()=>{try{const w=await c.load();if(m!==No.current)return;Ii(w)}catch{if(m!==No.current)return;Ii(null)}finally{m===No.current&&$s(!1)}})(),()=>{No.current+=1}},[fe]);const Nd=l.useCallback(async c=>{Li(c);const m=Ad.current;if(m!=null&&m.load&&m.save){const w=++Ed.current;try{await m.save(c)}catch{}finally{if(w!==Ed.current)return}return}tA(c)},[]),Ld=l.useCallback(c=>{Gi.current=c,db(c),iA(c);const m=Pr.current;m&&(m.scrollTop=0,m.scrollLeft=0),Qi.current()},[]);l.useEffect(()=>{const c=Be;if(!(c!=null&&c.load)||!c.save){Li(xf()??L);return}const m=++Yi.current;return(async()=>{try{const w=await c.load();if(m!==Yi.current)return;Li(typeof w=="boolean"?w:L)}catch{if(m!==Yi.current)return;Li(L)}})(),()=>{Yi.current+=1}},[Be,L]),l.useLayoutEffect(()=>{if(Qi.current(),at!=="visual")return;const c=Pr.current;if(!c||typeof ResizeObserver>"u")return;const m=O1(()=>{Qi.current()}),w=new ResizeObserver(()=>{m.schedule()});return w.observe(c),()=>{w.disconnect(),m.cancel()}},[at,Dr,Mo,pe]);const Bd=l.useCallback(async c=>{Bi(c);const m=Pd.current;if(m!=null&&m.load&&m.save){const w=++_d.current;try{await m.save(c)}catch{}finally{if(w!==_d.current)return}return}sA(c)},[]);l.useEffect(()=>{const c=Fe;if(!(c!=null&&c.load)||!c.save){Bi(Cf()??Ne);return}const m=++Xi.current;return(async()=>{try{const w=await c.load();if(m!==Xi.current)return;Bi(Th(w)??Ne)}catch{if(m!==Xi.current)return;Bi(Ne)}})(),()=>{Xi.current+=1}},[Fe,Ne]);const Br=l.useCallback((c,m)=>{var de,_e;const w=qu.current?Ur(c):c,j=((de=Ci.current)==null?void 0:de.call(Ci,w))??w,N=dh(ie.current,j,We);m!=null&&m.fullReplace&&!N&&$e.current&&((_e=V.current)==null||_e.clear());const U=Se(j);if(N)return ie.current=U,{stored:U,stateUpdated:!1};U!==ie.current&&(Wt.current=!0);const Q=Rr.current;if(he.current){const Re=dt;if(!Re)return ie.current=U,{stored:U,stateUpdated:!1};const ft=Re.replacePages(On(U));return ie.current=ft.joined,Ae.current=ft.pages,F.current==="html"&&!$e.current&&(Q==null||Q.setHtml(U)),Tr(Qt(ft.pages),be.current),{stored:U,stateUpdated:!0}}return $e.current?(ie.current=U,Q==null||Q.setStorageHtml(U),di(U),{stored:U,stateUpdated:!0}):(ie.current=U,Q==null||Q.setHtml(U),{stored:U,stateUpdated:!0})},[Se,We,Qt,di,Tr]),nn=l.useCallback((c,m,w,j)=>{var de;const N=c.map(_e=>Se(_e)),U=dt;if(!U)return _t(N);const Q=U.setPages(N,{editedIndex:w});if(!Q.changed)return Q.joined;if(Ae.current=Q.pages,Wt.current=!0,ie.current=Q.joined,Ps.current===void 0&&F.current==="html"&&!$e.current&&((de=Rr.current)==null||de.setHtml(Q.joined)),Tr(Qt(Q.pages),be.current),!(j!=null&&j.skipHistory)&&Ht(te)){const{changedIndices:_e,pages:Re}=Q;if(_e.length===1){const ft=w??_e[0];te.recordPageEdit(ft,Re[ft]??"",{coalesce:m})}else _e.length>1?te.recordReplaceAll(Re):w!==void 0?te.recordPageEdit(w,Re[w]??"",{coalesce:m}):te.recordReplaceAll(Re)}return tn(),Q.joined},[tn,Se,Qt,te,dt,Tr]),_n=l.useCallback(c=>{var U,Q;if(F.current!=="visual")return;const m=$e.current?de=>{var _e;return((_e=V.current)==null?void 0:_e.getDataUrl(de))??null}:void 0,w=$e.current?We:void 0;if((U=Lt.current)==null||U.call(Lt),he.current){const de=(Q=Rt.current)==null?void 0:Q.getContainer();if(!de)return;const _e=On(c);for(let Re=0;Re<_e.length;Re+=1){const ft=nt(de,Re);if(!ft)continue;const pt=ln(ge(_e[Re]??"").body);Qa(ft,pt,{resolveDataUrl:m,hydrateEmbeddedImages:w})}return}const j=H.current;if(!j)return;const N=ln(ge(c).body);Qa(j,N,{resolveDataUrl:m,hydrateEmbeddedImages:w})},[We]),yt=l.useCallback((c,m)=>{const{stored:w,stateUpdated:j}=Br(c,{fullReplace:!m});return!m&&j&&_n(w),Ht(te)?te.recordReplaceAll(On(w)):te.record(w,{coalesce:m}),tn(),w},[tn,Br,te,_n]),hb=l.useCallback(c=>{if(he.current){const m=be.current,j=Ae.current.slice();j[m]=c,nn(j,!1,m);return}yt(c,!1)},[nn,yt]),Fd=lA({enabled:!He&&!se,onHtml:hb}),ye=l.useCallback((c,m)=>{var w;return(w=Lt.current)==null||w.call(Lt),yt(ba(c,ya(c,ie.current,Lr.current,{liveRoot:H.current??void 0})),m)},[yt]),bb=l.useCallback((c,m)=>ye(an(c,ie.current),m),[ye]),ta=l.useCallback((c,m,w)=>{BC(c,m,w)},[]),na=l.useCallback((c,m,w)=>{const j={...$o(c),atRule:rt(Op(m,w))};return Ic(c,j)},[]),or=l.useCallback((c,m,w)=>ba(c,ya(c,m,Lr.current,{liveRoot:w})),[]),xt=l.useCallback(c=>{const m=Rt.current,w=m==null?void 0:m.getContainer(),j=dt.pages.length>0?dt.pages:Ae.current;if(!w)return[...j];const N=dt;if(!N)return[...j];const U=N.dirtyPagesRef.current,Q=(c==null?void 0:c.allPages)===!0,de=be.current;let _e=!1;const Re=j.map((pt,Or)=>{if(!(Q||U.has(Or)||Or===de))return pt;const pa=nt(w,Or);let ga=null;if(pa?(hs(pa),ga=pa.innerHTML):ga=m.flushPageHtml(Or),ga===null){const hm=ln(ge(pt).body),bm=Wm(hm);if(bm===hm)return pt;const ym=or(an(bm,ge(pt).body),pt);return ym!==pt&&(_e=!0),ym}const Ob=an(ga,ge(pt).body),gm=or(Ob,pt,pa??void 0);return gm!==pt&&(_e=!0),gm});if(_e){const pt=$e.current?Re.map(pm=>Se(pm)):Re,Or=N.setPages(pt);ie.current=Or.joined}N.markPagesClean();const ft=_e?N.pages:j;return $e.current?ft.map(pt=>Se(pt)):[...ft]},[Se,dt,or]),ir=l.useCallback((c,m,w)=>{const j=or(m,Ae.current[c]??""),N=pc(Ae.current,c,j);N.changed&&nn(N.pages,w,c)},[nn,or]),ar=l.useCallback((c,m,w)=>{const j=Ae.current[c]??"",N=ge(m).body,U=Wm(N),Q=U===N?m:or(an(U,ge(j).body),j),de=pc(Ae.current,c,Q);de.changed&&nn(de.pages,w,c)},[nn,or]),Hd=l.useCallback((c,m)=>{const w=ge(c).body;he.current?ir(be.current,w,m):ye(w,m)},[ir,ye]),le=l.useCallback((c,m,w)=>{var Q;const j=w?ge(w).body:c.innerHTML,N=de=>w?j:an(j,ge(de).body);if(!he.current){ye(N(ie.current),m);return}const U=(Q=Rt.current)==null?void 0:Q.getContainer();if(!U){ye(N(ie.current),m);return}for(let de=0;de<Ae.current.length;de+=1)if(nt(U,de)===c){ir(de,N(Ae.current[de]??""),m);return}ye(N(ie.current),m)},[ir,ye]),zd=l.useCallback((c,m)=>{Hu.current||le(c,m)},[le]),yb=l.useMemo(()=>sj(()=>H.current,()=>ie.current,ta),[ta]),xb=l.useMemo(()=>lj(()=>H.current,()=>ie.current,na,c=>ye(ge(c).body,!1)),[na,ye]),Cb=l.useMemo(()=>If(()=>H.current,Le??"in",c=>le(c,!1)),[Le,le]),wb=l.useMemo(()=>cj(c=>{var w;const m=(w=Rt.current)==null?void 0:w.getContainer();return m?nt(m,c):null},c=>Ae.current[c]??"",ta),[ta]),vb=l.useMemo(()=>uj(c=>{var w;const m=(w=Rt.current)==null?void 0:w.getContainer();return m?nt(m,c):null},c=>Ae.current[c]??"",na,(c,m)=>ir(c,ge(m).body,!1)),[na,ir]),kb=l.useMemo(()=>If(()=>{var m;const c=(m=Rt.current)==null?void 0:m.getContainer();return c?nt(c,be.current):null},Le??"in",c=>le(c,!1)),[Le,le]),Od=l.useCallback(()=>{const c=he.current?xt():[ie.current];return c[be.current]??c[0]??""},[xt]),sr=l.useCallback(()=>{if(!he.current)return[ie.current];if(F.current==="html"){const c=Ae.current.slice();return c[be.current]=bn.current,c}return xt({allPages:!0})},[xt]),ra=l.useCallback(c=>{if(!he.current||F.current!=="visual"||!en.current)return;Dn.current=!0;const m=xt(),w=Math.max(0,Math.min(c,m.length)),j=[...m],N=go.current?nf(Bn(),go.current):Bn();j.splice(w,0,N);const U=j.map(Q=>Se(Q));nn(j,!1,void 0,{skipHistory:!0}),Ht(te)&&te.recordInsertPage(w,U),be.current=w,ho(w),yo(!0)},[xt,nn,te,Se]),Fr=l.useCallback(()=>{var w;const c=H.current;if(c!=null&&c.hasAttribute(ri)){const j=qC(c);if(j!==null)return j}const m=(w=Rt.current)==null?void 0:w.getActivePageIndex();return typeof m=="number"?m:be.current},[]),Kd=l.useCallback(()=>{const c=Fr();c===null||!en.current||ra(c)},[ra,Fr]),$d=l.useCallback(()=>{const c=Fr();c===null||!en.current||ra(c+1)},[ra,Fr]),Ud=l.useCallback(()=>{if(!he.current||F.current!=="visual"||!en.current)return;Dn.current=!0;const c=xt();if(c.length<=1){Dn.current=!1;return}const m=Fr();if(m===null){Dn.current=!1;return}const w=c[m]??"",j=c.filter((de,_e)=>_e!==m),N=Se(w),U=j.map(de=>Se(de));nn(j,!1,void 0,{skipHistory:!0}),Ht(te)&&te.recordDeletePage(m,N,U);const Q=Math.min(m,j.length-1);be.current=Q,ho(Q),yo(!0)},[xt,nn,te,Fr,Se]);l.useEffect(()=>{pe||yo(!1)},[pe]),l.useEffect(()=>()=>{bi.current&&(yi.current=!1,xi())},[xi]);const oa=l.useCallback(c=>{var j,N;const m=dt.replacePages([...c]);ie.current=m.joined,Ae.current=m.pages,Wt.current=!0,Tr(Qt(m.pages),be.current);const w=Math.max(0,Math.min(be.current,m.pages.length-1));w!==be.current&&(be.current=w,ho(w)),Ps.current===void 0&&F.current==="html"&&!$e.current&&((j=Rr.current)==null||j.setHtml(m.joined)),(N=Lt.current)==null||N.call(Lt),_n(m.joined),Ht(te)&&te.applyPresent(m.pages)},[Qt,te,dt,Tr,_n]),ia=l.useCallback(()=>{if(F.current!=="visual"||He){Mr(null);return}const c=H.current;if(!c)return;const m=Kn(c);Mr(w=>m||(w&&w.isConnected&&c.contains(w)?w:null))},[He]),aa=l.useCallback(()=>{if(Ht(te)){const m=te.undo();if(m===null)return;te.markApplying(),oa(m),tn();return}const c=te.undo();c!==null&&(te.markApplying(),Br(c,{fullReplace:!0}),_n(c),te.finishApplying(),ia(),tn())},[oa,tn,Br,te,ia,_n]),sa=l.useCallback(()=>{if(Ht(te)){const m=te.redo();if(m===null)return;te.markApplying(),oa(m),tn();return}const c=te.redo();c!==null&&(te.markApplying(),Br(c,{fullReplace:!0}),_n(c),te.finishApplying(),ia(),tn())},[oa,tn,Br,te,ia,_n]);l.useEffect(()=>{if(pe){Ht(te)&&(De!==void 0&&!Ee?te.syncPages(Ae.current):te.applyPresent(Ae.current));return}Ht(te)||te.syncExternal(ie.current)},[pe,Ee,te,De]);const K=l.useCallback(()=>{qe.current=on({mode:F.current,visualEl:H.current,htmlEl:ut.current})},[]),rn=l.useCallback(c=>{if(!c||F.current!=="visual"){cd(!1),dd(!1),fd(!1);return}cd(Su(c)!==null),dd(Jm(c)),fd(Qm(c))},[]),Vd=l.useCallback(()=>{const c=on({mode:F.current,visualEl:H.current,htmlEl:ut.current}),m=qe.current;Pm(m,c)||(qe.current=c)},[]),pl=l.useCallback(()=>{const c=H.current;if(F.current!=="visual"||!c){wi({value:null,unit:yn.current,mixed:!1});return}const m=wg(c,yn.current);jt.current&&(m.value=jt.current.value,m.unit=jt.current.unit,m.mixed=!1),yn.current=m.unit,wi(w=>w.value===m.value&&w.unit===m.unit&&w.mixed===m.mixed?w:m)},[]),gl=l.useCallback(()=>{const c=H.current;if(F.current!=="visual"||!c){js({value:null,mixed:!1});return}const m=op(c);Ft.current&&(m.value=Ft.current.value,m.mixed=!1),js(w=>w.value===m.value&&w.mixed===m.mixed?w:m)},[]),hl=l.useCallback(()=>{const c=H.current;if(F.current!=="visual"||!c){Is({value:null,mixed:!1}),Es({value:null,mixed:!1});return}const m=Na(c,"color");Gt.current&&(m.value=Gt.current.value,m.mixed=!1);const w=Na(c,"backgroundColor");Zt.current&&(w.value=Zt.current.value,w.mixed=!1),Is(j=>j.value===m.value&&j.mixed===m.mixed?j:m),Es(j=>j.value===w.value&&j.mixed===w.mixed?j:w)},[]),bl=l.useCallback(()=>{const c=H.current;if(F.current!=="visual"||!c){_s({tag:null,mixed:!1});return}const m=jv(c);_s(w=>w.tag===m.tag&&w.mixed===m.mixed?w:m)},[]),yl=l.useCallback(()=>{const c=H.current;if(F.current!=="visual"||!c){Ns({align:null,mixed:!1}),Bs({type:null,mixed:!1}),Fs(!1),nd(!1);return}const m=qg(c);Ns(U=>U.align===m.align&&U.mixed===m.mixed?U:m);const w=Mg(c);Bs(U=>U.type===w.type&&U.mixed===w.mixed?U:w);const j=zv(c);Fs(U=>U===j?U:j);const N=$k(c);nd(U=>U===N?U:N)},[]),$=l.useCallback(()=>{const c=H.current;if(F.current!=="visual"||!c){Rs($n()),Hs(!1),pl(),gl(),hl(),bl(),yl();return}const m=qe.current,w=!!(m&&!m.collapsed);Hs(N=>N===w?N:w);const j=Pg(Gr(c),Bt.current);Rs(N=>lv(N,j)?N:j),pl(),gl(),hl(),bl(),yl()},[pl,gl,hl,bl,yl]),Wd=l.useCallback(()=>{const c=qe.current,m=It.current;!m||!c||c.collapsed&&c.start===m.start&&c.end===m.end||(Bt.current={},jt.current=null,Ft.current=null,Gt.current=null,Zt.current=null,In.current=null,It.current=null)},[]);l.useEffect(()=>{if(at==="visual"){$();return}Bt.current={},jt.current=null,Ft.current=null,Gt.current=null,Zt.current=null,In.current=null,It.current=null,Rs($n()),wi({value:null,unit:yn.current,mixed:!1}),js({value:null,mixed:!1}),Is({value:null,mixed:!1}),Es({value:null,mixed:!1}),_s({tag:null,mixed:!1}),Ns({align:null,mixed:!1}),Bs({type:null,mixed:!1}),Fs(!1),Hs(!1)},[at,$]);const Hr=l.useCallback((c,m,w)=>{Ix({snapshot:c,visualEl:H.current,htmlEl:ut.current,getHtml:()=>F.current==="visual"&&H.current?H.current.innerHTML:ie.current,setHtml:j=>{if(F.current==="visual"){const N=he.current?Ae.current[be.current]??"":ie.current;Hd(an(ge(j).body,ge(N).body),!1);return}yt(j,!1)},content:m,asHtml:w})},[yt,Hd]),Sb=l.useCallback(c=>{if(!he.current||c===be.current)return;ar(be.current,bn.current,!0),be.current=c,ho(c);const m=Ae.current[c]??"";bn.current=m},[ar]),Ab=l.useCallback(c=>{if(he.current){if($e.current){const m=Se(c);bn.current=m,ar(be.current,m,!0)}else bn.current=c,ar(be.current,c,!0);return}yt(c,!0)},[Se,yt,ar]),Gd=l.useCallback(c=>{var m;if(F.current==="visual"&&c==="html"){if(he.current){const w=xt({allPages:!0}),j=be.current,N=w[j]??w[0]??"";bn.current=N,ie.current=_t(w)}else if(H.current){const w=an(H.current.innerHTML,ge(ie.current).body),j=ba(w,ya(w,ie.current,Lr.current,{liveRoot:H.current??void 0}));if($e.current){const N=Se(j),U=ie.current;(m=Rr.current)==null||m.setStorageHtml(N),ie.current=N,N!==U&&(Wt.current=!0,Ht(te)||te.record(N,{coalesce:!0}))}else j!==ie.current&&yt(j,!0)}}F.current==="html"&&c==="visual"&&he.current&&ar(be.current,bn.current,!0),mi(c),c!=="visual"&&yo(!1)},[Se,te,yt,ar,mi,xt]);l.useEffect(()=>{if(!Tt)return;const c=document.body.style.overflow;return document.body.style.overflow="hidden",()=>{document.body.style.overflow=c}},[Tt]),l.useEffect(()=>{if(!Tt)return;const c=m=>{m.key==="Escape"&&(m.defaultPrevented||Ri.open||Vs.open||Do.open||jo.open||Gs||Xs.open||Qs.open||tl.open||rl.open||Os||ji.open||il.open||al||(m.preventDefault(),tr(!1)))};return document.addEventListener("keydown",c),()=>document.removeEventListener("keydown",c)},[Tt,tr,Ri.open,Vs.open,Do.open,jo.open,Gs,Xs.open,Qs.open,tl.open,rl.open,Os,ji.open,il.open,al]),l.useEffect(()=>{const c=()=>{if(F.current!=="visual"||!H.current)return;const m=window.getSelection();if(!m||m.rangeCount===0)return;const w=m.anchorNode;!w||!H.current.contains(w)&&H.current!==w||Ir.current===null&&(Ir.current=window.requestAnimationFrame(()=>{var N;Ir.current=null;const j=H.current;if(!(!j||F.current!=="visual")&&(K(),Wd(),$(),Mr(Kn(j)),rn(j),jn.current&&pi.current&&!((N=po.current)!=null&&N.contains(document.activeElement)))){const U=qe.current;U&&hn(lf(j,U))}}))};return document.addEventListener("selectionchange",c),()=>{document.removeEventListener("selectionchange",c),Ir.current!==null&&(window.cancelAnimationFrame(Ir.current),Ir.current=null)}},[K,Wd,$,rn]),l.useEffect(()=>{if(at!=="html")return;const c=ut.current;if(!c)return;const m=()=>K();return c.addEventListener("select",m),c.addEventListener("keyup",m),c.addEventListener("mouseup",m),()=>{c.removeEventListener("select",m),c.removeEventListener("keyup",m),c.removeEventListener("mouseup",m)}},[at,K]);const W=l.useCallback(c=>{const m=on({mode:"visual",visualEl:c,htmlEl:ut.current}),w=qe.current,j=Pm(w,m)?w:m.visualRange?m:w??m;qe.current=j,c.focus();const N=jx(c,j);if(N){const U=window.getSelection();try{U==null||U.removeAllRanges(),U==null||U.addRange(N),qe.current={...j,visualRange:N}}catch{}}return qe.current??j},[]),xn=l.useCallback(()=>{Pi.current=null,Ti.current=null,ed(!1)},[]),Zd=l.useCallback(()=>{if(!Ai.current||!Pi.current||!Ti.current||F.current!=="visual")return;const c=H.current;if(!c)return;K();const m=qe.current;!m||m.collapsed||CS(m,Ti.current)||(W(c),vS(c,Pi.current),le(c,!1),K(),$(),xn())},[K,W,ye,$,xn]),qd=l.useCallback(()=>{if(F.current!=="visual"){xn();return}if(Ai.current){xn();return}const c=H.current;if(!c){xn();return}const m=W(c);if(m.collapsed){xn();return}Pi.current=wS(c),Ti.current={...m},ed(!0),K()},[xn,W,K]),Pb=l.useCallback(()=>{Zd()},[Zd]);l.useEffect(()=>{(at!=="visual"||He)&&xn()},[at,He,xn]);const xl=l.useCallback((c,m)=>{if(F.current!=="visual")return;const w=H.current;if(!w)return;const j=m??yn.current,N=gr(c,j);if(!N)return;yn.current=N.unit;const U=W(w);if(U.collapsed){jt.current=N,It.current={start:U.start,end:U.end},$();return}jt.current=null,Cc(w,N.value,N.unit)&&(le(w,!1),K(),$())},[W,ye,K,$]),Yd=l.useCallback(c=>{if(F.current!=="visual")return;const m=H.current;if(!m)return;const w=W(m);if(w.collapsed){Ft.current={value:c},It.current={start:w.start,end:w.end},$();return}Ft.current=null,sc(m,c)&&(le(m,!1),K(),$())},[W,ye,K,$]),Cl=l.useCallback((c,m)=>{if(F.current!=="visual")return;const w=H.current;if(!w)return;const j=W(w),N=c==="color"?Gt:Zt;if(j.collapsed){N.current={value:m},It.current={start:j.start,end:j.end},$();return}N.current=null,Vo(w,c,m)&&(le(w,!1),K(),$())},[W,ye,K,$]),wl=l.useCallback(c=>{if(F.current!=="visual")return;const m=H.current;if(!m)return;const w=W(m);if(Di({open:!1,tab:"general"}),w.collapsed){if(c.size!==null){const Q=gr(c.size,c.unit);Q&&(jt.current=Q,yn.current=Q.unit)}const N=Gr(m),U={};for(const Q of Kt)c.marks[Q]!==N[Q]&&(U[Q]=c.marks[Q]);Bt.current=U,c.fontColorMixed||(Gt.current={value:c.fontColor}),c.highlightColorMixed||(Zt.current={value:c.highlightColor}),c.fontFamilyMixed||(Ft.current={value:c.fontFamily}),It.current={start:w.start,end:w.end},$();return}if(Bt.current={},jt.current=null,Ft.current=null,Gt.current=null,Zt.current=null,It.current=null,c.size!==null){const N=gr(c.size,c.unit);N&&(yn.current=N.unit,Cc(m,N.value,N.unit))}const j=Gr(m);for(const N of Kt)c.marks[N]!==j[N]&&kc(m,N);c.fontFamilyMixed||sc(m,c.fontFamily),c.fontColorMixed||Vo(m,"color",c.fontColor),c.highlightColorMixed||Vo(m,"backgroundColor",c.highlightColor),le(m,!1),K(),$()},[W,ye,K,$]),vl=l.useCallback((c,m)=>{if(F.current!=="visual")return;const w=H.current;if(!w)return;W(w),Er(N=>({...N,open:!1}));let j=Xg(w,c);if(m&&gk(w,m)&&(j=!0),!j){K(),$();return}le(w,!1),K(),$()},[W,ye,K,$]),Xd=l.useCallback(c=>{if(F.current!=="visual")return;const m=H.current;if(!m)return;const w=W(m);if(Ws(j=>({...j,open:!1})),!bs(c)){K(),$();return}if(w.collapsed){In.current=c,It.current={start:w.start,end:w.end},$();return}if(In.current=null,!Ag(m,c)){K(),$();return}le(m,!1),K(),$()},[W,ye,K,$]),kl=l.useCallback(c=>{if(F.current!=="visual")return;const m=Lo();if(!m)return;W(m),nr(U=>({...U,open:!1}));const w=he.current?Ae.current[be.current]??"":ie.current,j=JSON.stringify(c.atRule)!==JSON.stringify(rt(ge(w).body)),N=Ic(m,c);if(j&&co(m,N.pageHtml),!N.changed&&!j){K(),$();return}le(m,!1,N.pageHtml),K(),$()},[W,le,K,$,Lo]),Jd=l.useCallback(c=>{if(F.current!=="visual")return;const m=H.current;if(m){if(W(m),Ei(w=>({...w,open:!1})),!qk(m,c)){K(),$();return}le(m,!1),K(),$()}},[W,ye,K,$]),Qd=l.useCallback(c=>{if(F.current!=="visual")return;const m=H.current;if(m){if(W(m),Ys(w=>({...w,open:!1})),!Qk(m,c)){K(),$();return}le(m,!1),K(),$()}},[W,ye,K,$]),la=l.useCallback(c=>{if(F.current!=="visual")return;const m=H.current;if(m){if(W(m),_i({open:!1}),!xw(m,c,V.current)){K(),$();return}le(m,!1),K(),$()}},[W,ye,K,$]),ca=l.useCallback(c=>{if(F.current!=="visual")return;const m=H.current;if(m){if(W(m),Mi({open:!1}),!LS(m,c)){K(),$();return}le(m,!1),K(),$()}},[W,ye,K,$]),em=l.useCallback(c=>{if(F.current!=="visual")return;const m=H.current;if(m){if(W(m),Eo({open:!1}),!qS(m,c)){K(),$();return}le(m,!1),K(),$()}},[W,ye,K,$]),tm=l.useCallback(c=>{if(F.current!=="visual")return;const m=H.current;if(m){if(W(m),Js({open:!1}),!Yv(m,c)){K(),$();return}le(m,!1),K(),$(),rn(m)}},[W,ye,K,$,rn]),nm=l.useCallback(c=>{if(F.current!=="visual")return;const m=H.current;if(m){if(W(m),el(w=>({...w,open:!1})),!S0(m,c)){K(),$();return}le(m,!1),K(),$()}},[W,ye,K,$]),rm=l.useCallback(c=>{if(F.current!=="visual")return;const m=H.current;if(m){if(W(m),nl(w=>({...w,open:!1})),!M0(m,c)){K(),$();return}le(m,!1),K(),$(),rn(m)}},[W,ye,K,$,rn]),om=l.useCallback(c=>{if(F.current!=="visual")return;const m=H.current;if(m){if(W(m),ol(w=>({...w,open:!1})),!U0(m,c)){K(),$();return}le(m,!1),K(),$()}},[W,ye,K,$]),Cn=l.useCallback(c=>{if(F.current!=="visual")return;const m=H.current;if(m){if(W(m),!c(m)){K(),$();return}le(m,!1),K(),$(),rn(m)}},[W,ye,K,$,rn]),Sl=l.useCallback(c=>{la({src:c.src,alt:c.alt??"",title:c.title??"",css:c.css})},[la]),Al=l.useCallback(c=>{ca({src:c.src,title:c.title??"",css:c.css})},[ca]),Pl=l.useCallback(c=>{if(F.current!=="visual")return;const m=H.current;if(m){if(W(m),Eo({open:!1}),!YS(m,{src:c.src,title:c.title??"",css:c.css})){K(),$();return}le(m,!1),K(),$()}},[W,ye,K,$]),im=l.useCallback(c=>{if(F.current!=="visual")return;const m=H.current;if(m){if(W(m),Ni(w=>({...w,open:!1})),!Lw(m,c)){K(),$();return}le(m,!1),K(),$()}},[W,ye,K,$]),Tb=l.useCallback((c,m)=>{mt!=null&&mt.isConnected&&x0(mt,c,m)},[mt]),Rb=l.useCallback(()=>{const c=H.current;!c||!(mt!=null&&mt.isConnected)||(le(c,!1),Ul(c,mt),K(),$())},[mt,ye,K,$]),ua=l.useCallback(()=>{if(F.current!=="visual"||!H.current)return ie.current;const c=an(H.current.innerHTML,ge(ie.current).body);return ba(c,ya(c,ie.current,Lr.current,{liveRoot:H.current}))},[]),da=l.useCallback(()=>{if(he.current){const c=_t(sr());return ie.current=c,We(c)}if(Wt.current){const c=F.current==="visual"?ua():ie.current;c!==ie.current&&(ie.current=c)}return We(ie.current)},[sr,We,ua]),Db=l.useRef(-1),am=l.useCallback(()=>{if(!Wt.current&&jr.current)return jr.current;const c=Wt.current&&F.current==="visual"?ua():ie.current;return c!==ie.current&&(ie.current=c),jr.current=c,Wt.current=!1,c},[ua]),sm=l.useCallback(()=>{if(!Wt.current&&jr.current)return jr.current;const c=xt(),m=JSON.stringify(c);return jr.current=m,Db.current=dt.revision,Wt.current=!1,m},[xt,dt.revision]),jb=l.useCallback(()=>he.current?sm():am(),[sm,am]);X0({onAutoSave:r?async c=>{Wt.current=!1;const m=he.current?Qt(JSON.parse(c)):We(c);return r(m)}:void 0,getHtml:jb}),l.useEffect(()=>()=>{var c;(c=V.current)==null||c.clear()},[]),l.useEffect(()=>{var m;if(!Ee||e===void 0||pe)return;const c=Se(e);(m=Rr.current)==null||m.setStorageHtml(c),ie.current=c,Ht(te)||te.syncExternal(c)},[pe,Se,te,Ee,e]),l.useEffect(()=>{if(!Ee||!pe||De===void 0)return;const c=zn(De).map(w=>Se(w));if(mr(c,Ae.current))return;const m=dt.replacePages(c);if(ie.current=m.joined,Ae.current=m.pages,Ht(te)&&te.syncPages(m.pages),F.current==="html"){const w=m.pages[be.current]??"";bn.current=w}},[pe,Se,te,Ee,dt,De]),l.useEffect(()=>()=>{var c;(c=xo.current)==null||c.cancel()},[]);const Te=l.useMemo(()=>({getHtml:da,setHtml:c=>{yt(c,!1)},getMode:()=>F.current,setMode:Gd,getFullscreen:()=>Zu.current,setFullscreen:tr,getDarkMode:()=>Td.current,setDarkMode:c=>{Nd(c)},getPageZoom:()=>Gi.current,setPageZoom:Ld,getToolbarPosition:()=>Rd.current,setToolbarPosition:c=>{Bd(c)},openCustomizeToolbar:()=>{od(!0)},openDocumentPreview:()=>{id({open:!0,html:We(_t(sr()))})},openHelp:()=>{_o({open:!0,topicId:"getStarted"})},openKeyboardShortcuts:()=>{_o({open:!0,topicId:"keyboardShortcuts"})},openAbout:()=>{sd(!0)},toggleReadAloud:()=>{const c=xo.current;if(!c)return;const m=qe.current??on({mode:F.current,visualEl:H.current,htmlEl:ut.current}),w=uf(xa(m),da());w&&c.toggle(w)},toggleRuler:()=>{As(c=>!c)},isReadingAloud:()=>{var c;return((c=xo.current)==null?void 0:c.isSpeaking())??!1},isRulerVisible:()=>fi.current,canReadAloud:()=>{if(!Ia())return!1;const c=qe.current??on({mode:F.current,visualEl:H.current,htmlEl:ut.current});return uf(xa(c),da())!==null},undo:aa,redo:sa,canUndo:()=>te.canUndo(),canRedo:()=>te.canRedo(),getSelection:()=>{const c=qe.current??on({mode:F.current,visualEl:H.current,htmlEl:ut.current});return xa(c)},insertText:c=>{const m=qe.current??on({mode:F.current,visualEl:H.current,htmlEl:ut.current});Hr(m,c,!1)},insertHtml:(c,m)=>{const w=qe.current??on({mode:F.current,visualEl:H.current,htmlEl:ut.current}),j=m===void 0;Hr(w,j?c:m,j)},toggleFontMark:c=>{if(F.current!=="visual")return;const m=H.current;if(!m)return;const w=W(m);if(w.collapsed){const j=Gr(m);Bt.current=uv(Bt.current,j,c),It.current={start:w.start,end:w.end},$();return}Bt.current={},It.current=null,kc(m,c)&&(le(m,!1),K(),$())},clearFormatting:()=>{if(F.current!=="visual")return;const c=H.current;!c||W(c).collapsed||(Bt.current={},jt.current=null,Ft.current=null,Gt.current=null,Zt.current=null,In.current=null,It.current=null,xS(c)&&(le(c,!1),K(),$()))},toggleFormatBrush:qd,isFormatBrushActive:()=>Ai.current,isFontMarkActive:c=>Ds.current[c],hasTextSelection:()=>F.current==="visual"&&zs.current,setFontSize:(c,m)=>{xl(c,m)},setFontSizeUnit:c=>{var Q;const m=H.current,w=En.current;if(F.current!=="visual"||!m||w.value===null||w.mixed){yn.current=c,wi(de=>({...de,unit:c}));return}const j=W(m),N=X1(m,((Q=j.visualRange)==null?void 0:Q.startContainer)??m),U=ap(w.value,w.unit,c,N.parentPx,N.rootPx);xl(U,c)},getFontSize:()=>En.current.value,getFontSizeUnit:()=>En.current.unit,isFontSizeMixed:()=>En.current.mixed,setFontFamily:c=>{Yd(c)},getFontFamily:()=>ko.current.value,isFontFamilyMixed:()=>ko.current.mixed,getFontFaces:()=>Lr.current,setFontColor:c=>{Cl("color",c)},setHighlightColor:c=>{Cl("backgroundColor",c)},getFontColor:()=>Ao.current.value,isFontColorMixed:()=>Ao.current.mixed,getHighlightColor:()=>To.current.value,isHighlightColorMixed:()=>To.current.mixed,setParagraphStyle:c=>{if(F.current!=="visual")return;const m=H.current;m&&(W(m),Iv(m,c)&&(le(m,!1),K(),$()))},getParagraphStyle:()=>Ms.current.tag,isParagraphStyleMixed:()=>Ms.current.mixed,setTextAlign:c=>{if(F.current!=="visual")return;const m=H.current;m&&(W(m),Yg(m,c)&&(le(m,!1),K(),$()))},getTextAlign:()=>Ls.current.align,isTextAlignMixed:()=>Ls.current.mixed,indent:()=>{if(F.current!=="visual")return;const c=H.current;c&&(W(c),Ov(c)&&(le(c,!1),K(),$()))},outdent:()=>{if(F.current!=="visual")return;const c=H.current;c&&(W(c),Kv(c)&&(le(c,!1),K(),$()))},canOutdent:()=>F.current==="visual"&&Qu.current,toggleList:c=>{if(F.current!=="visual")return;const m=H.current;m&&(W(m),Mv(m,c)&&(le(m,!1),K(),$()))},isBulletList:()=>Ro.current.type==="ul"&&!Ro.current.mixed,isNumberedList:()=>Ro.current.type==="ol"&&!Ro.current.mixed,openFontProperties:c=>{F.current==="visual"&&Di({open:!0,tab:c??"general"})},applyFontProperties:c=>{wl(c)},openCustomCss:()=>{if(F.current!=="visual")return;const c=H.current;c&&W(c);const m=c?kg(c):{value:null,mixed:!1},w=m.mixed||!m.value?"":rv(m.value);Ws({open:!0,value:w})},applyCustomCss:c=>{Xd(c)},openParagraphProperties:c=>{if(F.current!=="visual")return;const m=H.current;m&&W(m),Er({open:!0,tab:c??"general",value:m?ka(m):pr(),backgroundImage:m?Gl(m):cn()})},applyParagraphProperties:(c,m)=>{vl(c,m)},openPageProperties:(c,m)=>{if(F.current!=="visual")return;const w=Lo();w&&W(w);const j=he.current?Ae.current[be.current]??"":ie.current,N=w?$o(w):Zo();nr({open:!0,tab:c==="print"&&!bt?"font":c??"font",paragraphTab:m??"spacing",value:{...N,atRule:rt(ge(j).body)}})},applyPageProperties:c=>{kl(c)},openPageBackgroundImage:()=>{if(F.current!=="visual")return;const c=Lo();c&&W(c);const m=Wi.current;if(qi.current&&m){m.onPick(N=>{const U=he.current?Ae.current[be.current]??"":ie.current,Q=c?$o(c):Zo();kl({...Q,backgroundImage:{...Q.backgroundImage,src:N.src},atRule:rt(ge(U).body)})});return}const w=he.current?Ae.current[be.current]??"":ie.current,j=c?$o(c):Zo();nr({open:!0,tab:"paragraph",paragraphTab:"backgroundImage",value:{...j,atRule:rt(ge(w).body)}})},openParagraphBackgroundImage:()=>{if(F.current!=="visual")return;const c=H.current;c&&W(c);const m=Wi.current;if(qi.current&&m){m.onPick(w=>{const j=c?ka(c):pr(),N=c?Gl(c):cn();vl(j,{...N,src:w.src})});return}Er({open:!0,tab:"backgroundImage",value:c?ka(c):pr(),backgroundImage:c?Gl(c):cn()})},openCustomParagraphStyleDialog:c=>{if(F.current!=="visual"||!dl.current)return;if(c){const w=Ui.current.find(j=>j.id===c);if(!w)return;Io({open:!0,mode:"edit",style:w});return}const m=H.current;m&&W(m),Io({open:!0,mode:"create",font:{size:En.current.mixed?null:En.current.value,unit:En.current.unit,marks:{...Ds.current},fontFamily:ko.current.mixed?null:ko.current.value,fontColor:Ao.current.mixed?null:Ao.current.value,highlightColor:To.current.mixed?null:To.current.value},paragraph:Jg(m?ka(m):pr())})},applyCustomParagraphStyle:c=>{const m=Ui.current.find(j=>j.id===c);if(!m||(wl({size:m.font.size,unit:m.font.unit,marks:m.font.marks,fontFamily:m.font.fontFamily??null,fontFamilyMixed:!1,fontColor:m.font.fontColor,highlightColor:m.font.highlightColor,fontColorMixed:!1,highlightColorMixed:!1}),!m.paragraph))return;const w=H.current;!w||F.current!=="visual"||(W(w),fk(w,m.paragraph)&&(le(w,!1),K(),$()))},customParagraphStylesEnabled:()=>dl.current,getCustomParagraphStyles:()=>Ui.current,isCustomParagraphStylesLoading:()=>hd.current,openLinkDialog:c=>{if(F.current!=="visual")return;const m=H.current;m&&W(m);const w=m?nh(m):Cs(),j=m?_c(m):[],N=(w==null?void 0:w.href)??"",U=N.startsWith("#")?N.slice(1):"",Q=j.some(de=>de.id===U)?U:"";Ei({open:!0,tab:c??"link",href:N,title:(w==null?void 0:w.title)??"",targetBlank:(w==null?void 0:w.targetBlank)??!1,textDecorationNone:(w==null?void 0:w.textDecorationNone)??!1,hoverMode:(w==null?void 0:w.hoverMode)??"color",hoverColor:(w==null?void 0:w.hoverColor)??null,hoverHtml:(w==null?void 0:w.hoverHtml)??"",bookmarks:j,selectedBookmarkId:Q})},applyLink:c=>{Jd(c)},openBookmarkDialog:()=>{if(F.current!=="visual")return;const c=H.current;c&&W(c),Ys({open:!0,existingIds:c?_c(c).map(m=>m.id):[]})},applyBookmark:c=>{Qd(c)},openImageDialog:()=>{if(F.current!=="visual")return;const c=H.current;c&&W(c);const m=Wi.current;if(qi.current&&m){m.onPick(Sl);return}_i({open:!0})},applyImage:c=>{la(c)},openAudioDialog:()=>{if(F.current!=="visual")return;const c=H.current;c&&W(c);const m=vd.current;if(Dd.current&&m){m.onPick(Al);return}Mi({open:!0})},applyAudio:c=>{ca(c)},openYoutubeDialog:()=>{if(F.current!=="visual")return;const c=H.current;c&&W(c);const m=kd.current;if(jd.current&&m){m.onPick(Pl);return}Eo({open:!0})},applyYoutube:c=>{em(c)},openImageProperties:c=>{if(F.current!=="visual")return;const m=H.current;if(!m)return;W(m);const w=Kn(m),j=Nw(m);!w||!j||Ni({open:!0,tab:c??"general",value:j,aspectRatio:Ew(w)})},applyImageProperties:c=>{im(c)},insertHorizontalRule:()=>{if(F.current!=="visual")return;const c=H.current;c&&(W(c),l0(c)&&(le(c,!1),K(),$()))},insertPageBreak:()=>{if(F.current!=="visual")return;const c=H.current;c&&(W(c),f0(c)&&(le(c,!1),K(),$()))},insertPageBefore:()=>{Kd()},insertPageAfter:()=>{$d()},deletePage:()=>{!he.current||F.current!=="visual"||en.current&&(sr().length<=1||Zs(!0))},isMultiPagesEnabled:()=>he.current,hasSelectedPage:()=>he.current&&F.current==="visual"&&en.current,canDeletePage:()=>he.current&&F.current==="visual"&&en.current&&sr().length>1,canInsertPageBackgroundImage:()=>!(F.current!=="visual"||he.current&&!en.current),canInsertParagraphBackgroundImage:()=>{if(F.current!=="visual")return!1;const c=H.current;return c?An(c).length>0:!1},getActivePageHtml:()=>Od(),getAllPagesHtml:()=>Qt(sr()),openTableDialog:()=>{if(F.current!=="visual")return;const c=H.current;c&&W(c),Js({open:!0})},applyTable:c=>{tm(c)},openTableProperties:()=>{if(F.current!=="visual")return;const c=H.current;if(!c)return;W(c);const m=k0(c);m&&el({open:!0,value:m})},applyTableProperties:c=>{nm(c)},openCellProperties:()=>{if(F.current!=="visual")return;const c=H.current;if(!c)return;W(c);const m=_0(c);m&&nl({open:!0,value:m})},applyCellProperties:c=>{rm(c)},openRowProperties:()=>{if(F.current!=="visual")return;const c=H.current;if(!c)return;W(c);const m=$0(c);m&&ol({open:!0,value:m})},applyRowProperties:c=>{om(c)},insertRowBelow:()=>{Cn(c=>Pc(c,"below"))},insertRowBefore:()=>{Cn(c=>Pc(c,"before"))},deleteRow:()=>{Cn(c=>Xv(c))},insertColumnAfter:()=>{Cn(c=>Xm(c,"after"))},insertColumnBefore:()=>{Cn(c=>Xm(c,"before"))},deleteColumn:()=>{Cn(c=>Jv(c))},mergeCells:()=>{Cn(c=>tk(c))},unmergeCells:()=>{Cn(c=>nk(c))},cut:async()=>{if(F.current!=="visual")return;const c=H.current;c&&(W(c),await pS(c)&&(le(c,!1),K(),$()))},copy:async()=>{if(F.current!=="visual")return;const c=H.current;c&&(W(c),await uh(c))},deleteSelection:()=>{if(F.current!=="visual")return;const c=H.current;c&&(W(c),ch(c)&&(le(c,!1),K(),$()))},addComment:()=>{if(!jn.current||b||F.current!=="visual")return;const c=H.current;if(!c)return;const m=W(c),w=lf(c,m);if(w){hn(w);return}const j=rS(c,m);if(!j)return;const N=lS(j);oS(c,N.id,m)&&(cf(c,N.id),K(),zd(c,!1),Rn([...gi.current,N]),hn(N.id))},toggleCommentsVisible:()=>{Ar(c=>{const m=!c,w=H.current;return w&&ah(w,m),m})},areCommentsVisible:()=>pi.current,canAddComment:()=>!jn.current||b||F.current!=="visual"?!1:zs.current||ul.current!==null,isCommentsEnabled:()=>jn.current,getCommentThreads:()=>gi.current,setCommentThreads:c=>Rn(c),openCommentThread:c=>{const m=H.current;!m||F.current!=="visual"||cf(m,c)&&(K(),hn(c))},isContentLocked:()=>zu.current,isLink:()=>rd.current,isImageSelected:()=>F.current==="visual"&&ul.current!==null,isInTable:()=>F.current==="visual"&&ud.current,canMergeCells:()=>F.current==="visual"&&md.current,canUnmergeCells:()=>F.current==="visual"&&pd.current,...o!=null?{onSave:c=>Cd.current(c)}:{},...a!=null?{onOpen:()=>wd.current()}:{}}),[yt,ye,le,zd,Gd,tr,Nd,Ld,Bd,Hr,aa,sa,K,$,W,xl,Yd,Cl,wl,Xd,vl,kl,Jd,Qd,la,ca,em,im,tm,nm,rm,om,Cn,Sl,Al,Pl,da,Od,sr,Kd,$d,Ud,qd,o,a,b,Rn,bt]),lm=l.useCallback(()=>{const c=qe.current??on({mode:F.current,visualEl:H.current,htmlEl:ut.current});return{mode:c.mode,selection:xa(c),getHtml:Te.getHtml,setHtml:m=>{yt(m,!1)},insertText:m=>Hr(c,m,!1),insertHtml:(m,w)=>{const j=w===void 0;Hr(c,j?m:w,j)}}},[Hr,Te.getHtml,yt]),{catalog:ma,layout:cm}=l.useMemo(()=>By(z,ER,_R),[z]),fa=l.useMemo(()=>OA(cm,B),[cm,B]),um=l.useMemo(()=>({...fa,iconGroups:pA(fa.iconGroups,Ks)}),[fa,Ks]),dm=pe&&at==="visual",Tl=l.useMemo(()=>XR(um,dm),[um,dm]),Rl=l.useMemo(()=>Ve?BR(ma,Pn):ma,[ma,Ve,Pn]),Dl=l.useMemo(()=>Ve?FR(Tl):Tl,[Tl,Ve]),jl=l.useMemo(()=>({disabled:Jt,readOnly:C,enableComments:Ve}),[Jt,C,Ve]),Ib=l.useCallback(c=>{if(!Tn||!gn||b)return;const m=cS(gn,c);Rn(uS(gi.current,Tn,m))},[Tn,gn,b,Rn]),zr=l.useMemo(()=>({...W1(Te),...Fy(z,lm)}),[Te,z,lm]),Il=l.useMemo(()=>G1(Te),[Te,Co,wo,vo,So,Po,vi,Fi,Hi,Vi,Nr,mt,Oi,Ki,$i,ki,Si,rr,_r,Mo,bo,$u,Tt]);l.useLayoutEffect(()=>{Dt.bump("history")},[$u,Dt]),l.useLayoutEffect(()=>{Dt.bump("marks")},[Co,wo,vo,So,Po,vi,Si,Dt]),l.useLayoutEffect(()=>{Dt.bump("table")},[Oi,Ki,$i,Dt]),l.useLayoutEffect(()=>{Dt.bump("selection")},[ki,mt,Dt]),l.useLayoutEffect(()=>{Dt.bump("chrome")},[rr,_r,Mo,bo,Tt,Fi,Hi,Vi,Nr,Dt]);const Eb=l.useCallback(c=>{if(He||c.inputType!=="insertText"&&c.inputType!=="insertReplacementText"||!c.data||!cv(Bt.current)&&!jt.current&&!hx(Ft.current)&&!$x({color:Gt.current,backgroundColor:Zt.current})&&!av(In.current))return;const m=H.current;m&&(c.preventDefault(),xv(m,c.data,Bt.current,jt.current,{color:Gt.current,backgroundColor:Zt.current},Ft.current,In.current),Bt.current={},jt.current=null,Ft.current=null,Gt.current=null,Zt.current=null,In.current=null,It.current=null,le(m,!0),K(),$())},[He,ye,K,$]),_b=l.useCallback(c=>{if(He||!ex(c,gd.current))return;c.preventDefault(),c.stopPropagation();const m=H.current;if(!m)return;W(m);const w=bc(m,c.target),j=Ya(m,c.target);j&&!ui(m).includes(j)&&ek(m,j);const N={inTable:St(m,c.target)!==null,canMergeCells:Jm(m),canUnmergeCells:Qm(m)},U={canDeletePage:he.current&&en.current&&xt().length>1},Q={canAddComment:jn.current&&!b};if(w){Ul(m,w),K(),Mr(w),cl({open:!0,x:c.clientX,y:c.clientY,kind:"image",...N,...U,...Q,inTable:St(m,w)!==null});return}const de=on({mode:"visual",visualEl:m,htmlEl:ut.current});qe.current=de,cl({open:!0,x:c.clientX,y:c.clientY,kind:de.collapsed?"caret":"text",...N,...U,canAddComment:Q.canAddComment&&!de.collapsed})},[He,K,W,xt,b]),Mb=l.useCallback(c=>{if(gd.current=c.pointerType,b)return;const m=H.current;if(!m)return;if(jn.current&&pi.current){const j=sh(m,c.target);if(j){const N=j.getAttribute("data-comment-thread");N&&hn(N);return}}if(He&&!jn.current)return;const w=bc(m,c.target);if(!w){Mr(null);return}c.preventDefault(),Ul(m,w),K(),Mr(w)},[b,He,K]),mm=l.useCallback(c=>{if(He)return;if(c.key==="Tab"&&!c.ctrlKey&&!c.metaKey&&!c.altKey){if(F.current!=="visual")return;const w=H.current;if(!w)return;const j=c.target;if(!(j instanceof Node)||!w.contains(j))return;W(w);const N=Qv(w,c.shiftKey);if(!N)return;c.preventDefault(),typeof N=="object"&&N.changed&&le(w,!1),K(),$(),rn(w);return}if(!(c.ctrlKey||c.metaKey))return;if(c.key==="Enter"&&!c.shiftKey){c.preventDefault(),Te.insertPageBreak();return}const m=c.key.toLowerCase();if(m==="z"&&!c.shiftKey){c.preventDefault(),aa();return}if(m==="z"&&c.shiftKey||m==="y"){c.preventDefault(),sa();return}if(m==="b"&&!c.shiftKey){c.preventDefault(),Te.toggleFontMark("bold");return}if(m==="i"&&!c.shiftKey){c.preventDefault(),Te.toggleFontMark("italic");return}if(m==="u"&&!c.shiftKey){c.preventDefault(),Te.toggleFontMark("underline");return}if(m==="x"&&c.shiftKey){c.preventDefault(),Te.toggleFontMark("strikethrough");return}m==="p"&&!c.shiftKey&&(c.preventDefault(),zr.print())},[He,aa,sa,Te,zr,W,ye,K,$,rn]),Nb=l.useCallback(c=>{if(c.key==="F1"){c.preventDefault(),_o({open:!0,topicId:"getStarted"});return}if(c.key==="Escape"&&Tn){c.preventDefault(),hn(null);return}mm(c)},[Tn,mm]),Lb=[xe.root,ic(rr).className,Tt?xe.fullscreen:"",x].filter(Boolean).join(" "),Bb=E_({toolbarBackground:k,menuColor:S,menuBackground:P,menuFontSize:T,menuFontFamily:D,border:R}),Fb=ic(rr)["data-wysiwyg-theme"];Ku.current={multiPageVisualRef:Rt,workspaceRef:Pr,suppressPageFlushRef:Dn,visualRootRef:H,visualPropSyncGuardRef:Lt,htmlAreaRef:ut,commentPanelRef:po,activePageIndexRef:be,htmlModePageHtmlRef:bn,activePageHtmlRef:Wu,pageCanvasSizedRef:Gu,setActivePageIndex:ho,setHasSelectedPage:yo,setActiveThreadId:hn,setContextMenu:cl,recordVisualInputHtml:bb,recordPageVisualHtml:ir,handleVisualBeforeInput:Eb,handleVisualPointerDown:Mb,handleVisualMouseUp:Pb,handleVisualContextMenu:_b,handleHtmlPageTabSelect:Sb,handleHtmlSurfaceChange:Ab,handleImageResize:Tb,handleImageResizeEnd:Rb,multiPageRulerMarginPreview:wb,multiPageRulerMarginChange:vb,multiPageRulerIndentChange:kb,singlePageRulerMarginPreview:yb,singlePageRulerMarginChange:xb,singlePageRulerIndentChange:Cb,resolveEmbeddedImageDataUrl:Ee?ks:void 0,hydrateExportHtml:We,postCommentMessage:Ib,htmlFileDrop:Fd};const Hb=l.useMemo(()=>eb({catalog:Rl,layout:Dl,commands:zr,queries:Il,queryRevisions:Dt,disabled:Jt,chromeLock:jl}),[Jt,jl,zr,Rl,Dl,Il,Dt]),zb=l.useMemo(()=>({documentBridgeRef:Rr,htmlRef:ie,pagesRef:Ae}),[]);return i.jsx(Wy,{locale:v,children:i.jsx(Ky,{dark:rr,children:i.jsx(UE,{value:zb,children:i.jsxs("div",{className:Lb,style:Bb,"data-fullscreen":Tt?"":void 0,"data-wysiwyg-theme":Fb,"data-toolbar-position":_r,"data-comments-visible":Ve&&Pn?"":void 0,onKeyDown:Nb,children:[i.jsx(KE,{menuVisible:A,captureChromeSelection:Vd,displayCatalog:Rl,displayLayout:Dl,commands:zr,queries:Il,queryRevisions:Dt,chromeDisabled:Jt,chromeLock:jl,contentLocked:He,customizeToolbarOpen:Os,baseCatalog:ma,allowedLayout:fa,toolbarSettings:Ks,toolbarSettingsLoading:ob,toolbarSettingsBusy:ib,onCustomizeToolbarClose:()=>od(!1),onToolbarSettingsChange:c=>{Md(c)},onToolbarSettingsReset:()=>{Md(null)},documentPreview:ji,onDocumentPreviewClose:()=>id({open:!1,html:ji.html}),helpDialog:il,onHelpDialogClose:()=>_o(c=>({...c,open:!1})),onHelpTopicChange:c=>_o(m=>({...m,open:!0,topicId:c})),aboutDialogOpen:al,onAboutDialogClose:()=>sd(!1),fontDialog:Ri,fontSizeState:wo,markState:Co,fontFamilyState:vo,fontColorState:So,highlightColorState:Po,fontFaces:Nr,onFontDialogTabChange:c=>Di({open:!0,tab:c}),onFontDialogClose:()=>Di({open:!1,tab:Ri.tab}),onApplyFontProperties:c=>Te.applyFontProperties(c),paragraphDialog:Do,customImagePicker:Z,disableBuiltinImageInsert:X,onParagraphCustomImagePick:()=>{Z==null||Z.onPick(c=>{Er(m=>({...m,tab:"backgroundImage",backgroundImage:{...m.backgroundImage,src:c.src}}))})},onParagraphDialogTabChange:c=>Er({...Do,open:!0,tab:c}),onParagraphDialogClose:()=>Er({...Do,open:!1}),onApplyParagraphProperties:({value:c,backgroundImage:m})=>Te.applyParagraphProperties(c,m),customCssDialog:Vs,onCustomCssDialogClose:()=>Ws(c=>({...c,open:!1})),onApplyCustomCss:c=>Te.applyCustomCss(c),pageDialog:jo,enablePageProperties:bt,onPageCustomImagePick:()=>{Z==null||Z.onPick(c=>{nr(m=>({...m,tab:"paragraph",paragraphTab:"backgroundImage",value:{...m.value,backgroundImage:{...m.value.backgroundImage,src:c.src}}}))})},onPageDialogTabChange:c=>nr({...jo,open:!0,tab:c}),onPageDialogClose:()=>nr({...jo,open:!1}),onApplyPageProperties:c=>Te.applyPageProperties(c),onPageDialogResetAtRule:()=>{const c=Lo();if(!c||F.current!=="visual")return;const m=he.current?Ae.current[be.current]??"":ge(ie.current).body,w=Rk(c,m);w.changed&&(le(c,!1,w.pageHtml),nr(j=>({...j,value:{...j.value,atRule:Hn()}})))},deletePageConfirmOpen:Gs,onDeletePageConfirmClose:()=>Zs(!1),onDeletePageConfirm:()=>{Ud(),Zs(!1)},customStyleDialog:ab,canDeleteCustomParagraphStyle:!!re,customStyleBusy:fb,onCustomStyleDialogClose:()=>Io({open:!1}),onCustomStyleSave:async c=>{const m=yd.current;if(m){zi(!0);try{await m(c),Io({open:!1}),await ea()}finally{zi(!1)}}},onCustomStyleDelete:async c=>{const m=xd.current;if(m){zi(!0);try{await m(c),Io({open:!1}),await ea()}finally{zi(!1)}}},linkDialog:qs,onLinkDialogTabChange:c=>Ei({...qs,open:!0,tab:c}),onLinkDialogClose:()=>Ei({...qs,open:!1}),onApplyLink:c=>Te.applyLink(c),bookmarkDialog:ad,onBookmarkDialogClose:()=>Ys({...ad,open:!1}),onApplyBookmark:c=>Te.applyBookmark(c),imageDialogOpen:sb.open,customAudioPicker:ne,customVideoPicker:J,onImageDialogClose:()=>_i({open:!1}),onApplyImage:c=>Te.applyImage(c),onImageDialogCustomPick:()=>{_i({open:!1}),Z==null||Z.onPick(Sl)},audioDialogOpen:lb.open,onAudioDialogClose:()=>Mi({open:!1}),onApplyAudio:c=>Te.applyAudio(c),onAudioDialogCustomPick:()=>{Mi({open:!1}),ne==null||ne.onPick(Al)},youtubeDialogOpen:cb.open,onYoutubeDialogClose:()=>Eo({open:!1}),onApplyYoutube:c=>Te.applyYoutube(c),onYoutubeDialogCustomPick:()=>{Eo({open:!1}),J==null||J.onPick(Pl)},imageProperties:ub,onImagePropertiesTabChange:c=>Ni(m=>({...m,tab:c})),onImagePropertiesClose:()=>Ni(c=>({...c,open:!1})),onApplyImageProperties:c=>Te.applyImageProperties(c),tableDialogOpen:Xs.open,onTableDialogClose:()=>Js({open:!1}),onApplyTable:c=>Te.applyTable(c),tableProperties:Qs,onTablePropertiesClose:()=>el(c=>({...c,open:!1})),onApplyTableProperties:c=>Te.applyTableProperties(c),cellProperties:tl,onCellPropertiesClose:()=>nl(c=>({...c,open:!1})),onApplyCellProperties:c=>Te.applyCellProperties(c),rowProperties:rl,onRowPropertiesClose:()=>ol(c=>({...c,open:!1})),onApplyRowProperties:c=>Te.applyRowProperties(c)}),i.jsx($E,{toolbarVisible:E,toolbarPos:_r,captureChromeSelection:Vd,toolbarShellProps:Hb,children:i.jsx(D_,{propsRef:Ku,pageStore:dt,mode:at,enableMultiPages:pe,contentLocked:He,activePageIndex:Dr,hasSelectedPage:bo,pageZoomScale:sl,rulerVisible:mo,rulerUnit:Le,optimizeEmbeddedImages:Ee,placeholder:y,value:e,pagesProp:De,controlledHtml:er,initialHtml:Ke,initialStorageHtml:Ss,defaultPages:ee.current??[Bn()],ingestedPagesProp:Ou,onChange:n,fontFaces:Nr,enableComments:Ve,commentsVisible:Pn,disabled:b,locale:v,commentAuthor:gn,activeThreadId:Tn,contextMenu:pb,commentThreads:fo,commands:zr,htmlFileDropDragging:Fd.dragging,selectedImage:mt})}),Tt?i.jsx(__,{onClick:()=>tr(!1)}):null]})})})})}function E_({toolbarBackground:e,menuColor:t,menuBackground:n,menuFontSize:r,menuFontFamily:o,border:a}){const s={};return e&&(s["--wysiwyg-toolbar-background"]=e),t&&(s["--wysiwyg-menu-color"]=t),n&&(s["--wysiwyg-menu-background"]=n),r&&(s["--wysiwyg-menu-font-size"]=r),o&&(s["--wysiwyg-menu-font-family"]=o),a==="none"?(s["--wysiwyg-border-width"]="0",s["--wysiwyg-border-radius"]="0",s["--wysiwyg-border-shadow"]="none"):a&&(a.width&&(s["--wysiwyg-border-width"]=a.width),a.color&&(s["--wysiwyg-border-color"]=a.color),a.radius&&(s["--wysiwyg-border-radius"]=a.radius),a.shadow&&(s["--wysiwyg-border-shadow"]=a.shadow)),Object.keys(s).length?s:void 0}function __({onClick:e}){const t=Y();return i.jsx("button",{type:"button",className:xe.exitFullscreen,"aria-label":t("exitFullscreenAria"),onClick:e,children:i.jsx(Je,{className:xe.exitFullscreenIcon})})}function M_(e){var n;if(e.tagName.toLowerCase()!=="span")return!1;const t=[...e.attributes];return t.length===0||t.length===1&&((n=t[0])==null?void 0:n.name)===st?!0:t.length===2&&t.some(r=>r.name===st)&&t.some(r=>r.name==="class"&&r.value.includes("wysiwyg-comment-anchor"))?!e.hasAttribute("style"):!1}function N_(e){for(const t of[...e.querySelectorAll(`[${st}]`)])t.removeAttribute(st),t instanceof HTMLElement&&t.classList.remove("wysiwyg-comment-anchor");for(const t of[...e.querySelectorAll("span")]){if(!M_(t))continue;const n=t.parentNode;if(n){for(;t.firstChild;)n.insertBefore(t.firstChild,t);n.removeChild(t)}}}function L_(e){const t=e.trim();if(!t)return e;const n=new DOMParser().parseFromString(t,"text/html");return N_(n.body),n.body.innerHTML}exports.Editor=I_;exports.PAGE_SEPARATOR=Oa;exports.joinPagesToHtml=_t;exports.sanitizeDocumentHtml=Ur;exports.sanitizePageHtml=Ec;exports.splitPagesFromHtml=On;exports.stripCommentAnchors=L_;